primefaces / primevue

Next Generation Vue UI Component Library
https://primevue.org
MIT License
8.89k stars 1.1k forks source link

General: Passthrough default props and icons #4607

Open m-thorsen opened 9 months ago

m-thorsen commented 9 months ago

Describe the feature you would like to see added

Add possibility to define default props via passthrough.
Add possibility to set icons and/or default slot content via passthrough.

In order to keep configuration to a single config file and/or plugin and eliminate the need for wrapping.

Some examples:

Is your feature request related to a problem?

Having to wrap/extend/template component every project and/or usage.

Describe the solution you'd like

Some examples:

Panel

<Panel :pt="{
   togglerIcon: ({ props}) => ({
      icon: props.collapsed ? 'pi-angle-up' : 'pi-angle-down'
   })
}" />

AND/OR

import { Icon } from '@iconify/vue';
...
<Panel :pt="{
   togglerIcon: ({ props}) => ({
      icon:  `<Icon icon=${props.collapsed ? 'mdi:chevron-up'  :  'mdi:chevron-down'} />`
   })
}" />

AND/OR

import { Icon } from '@iconify/vue';
...
<Panel :pt="{
   slots: {
      togglericon: ({ props}) => `<Icon icon=${props.collapsed ? 'mdi:chevron-up'  :  'mdi:chevron-down'} />`
   }
}
}" />

Dialog

<Dialog :pt="{
   root: {
      modal: true,
      draggable: false,
   }
}" />

OR

<Dialog :pt="{
   modal: true,
   draggable: false,
}" />

Describe alternatives you have considered

Wrapping each component, templating every use case

Additional context

The passthrough options seems like very natural place for this!

mertsincan commented 9 months ago

Hi @m-thorsen,

I did a preliminary study on this. https://twitter.com/primevue/status/1656258065014968324 Certainly, I plan to create an API related to it and enable this functionality on a component basis, but that will be in the future. Right now, I am working on developing a new styled mode structure. Once I complete this task, I will move on to configuring the default options.

Best Regards,

slavco86 commented 2 months ago

Faced the same problem as well. Lack of ability to pass through prop values down to internal components of more complex components. E.g. passing props to Button inside DataTable, such as severity, label. Any update on this, @mertsincan ? Is this something we can expect to see in V4?

alqa-dash commented 2 months ago

Interesting thread. I tried to change Panel toggle icon but with example above it does not work. At least in v.3.51.0. <Panel :pt="{ togglerIcon: ({ props}) => ({ icon: props.collapsed ? 'pi-angle-up' : 'pi-angle-down' }) }" />

I manage to change icon with <template #togglericon> but want to know is it possible with passthrough approach?

Looks like passthrough options are pretty powerful.