vue-final / vue-final-modal

🍕Vue Final Modal is a tiny, renderless, mobile-friendly, feature-rich modal component for Vue.js.
https://vue-final-modal.org
MIT License
864 stars 95 forks source link

Add slots to `useModalSlot` #348

Closed matthew-dean closed 7 months ago

matthew-dean commented 1 year ago

Is your feature request related to a problem? Please describe.

I want to be able to use a SFC for a modal slot. This content also has slots. However, useModalSlots throws a type error when trying to define content for slots.

Describe the solution you'd like

I want to slot in content from the parent wrapper into the slot wrapper, like:

const slots = useSlots()

useModal({
  component: VueFinalModal,
  defaultModelValue: props.modelValue,
  attrs: {
  // ...
  },
  slots: {
    default: useModalSlot({
      component: DialogContent,
      attrs: {
        title: props.title
      },
      slots: {
        default: slots.default
      }
    })
  }
})

Describe alternatives you've considered

I guess the alternative is just using a string template, which I'm trying to avoid.

Additional context

hunterliu1003 commented 1 year ago

@matthew-dean Currently, useModal() only allowed to pass slots with one layer, this is designed in purpose because it's hard to manage nested slots. I don't have a good idea of how to implement the feature yet.

hunterliu1003 commented 1 year ago

@Mini-ghost Do you have any idea to achieve this?