wireui / wireui

TallStack UI components
https://v1.wireui.dev
MIT License
1.37k stars 166 forks source link

Accept key value array as Select Options #45

Closed trippo closed 2 years ago

trippo commented 2 years ago

I would like to have the possibility to pass an key value array as options params on select like this

[ 
   1 => "name1" ,
   2 => "name2" ,
]

So without

option-label="name"
option-value="id" 
PH7-Jack commented 2 years ago

Maybe option-key-label option-key-value as boolean prop

What do you think about this?

trippo commented 2 years ago

I think is better if the default (without passing option-label and option-value) work with an key value arrya. If you specify option-label and option-value work like now.

PH7-Jack commented 2 years ago

You talk about defaulting to key as value?

$array = [ 
   1 => "name1" ,
   2 => "name2" ,
];

the value is 1 and 2, the label is name1 and name2

trippo commented 2 years ago

Yes

PH7-Jack commented 2 years ago

It will break if pass an array of values, like $array = ['Active', 'Pending', 'Stuck', 'Done'], the value will be 0,1,2... and not Active, Pending...

PH7-Jack commented 2 years ago

I believe a prop to define this would be good

trippo commented 2 years ago

You are the magician :) what did you think about option-key-label option-key-value as boolean prop?

PH7-Jack commented 2 years ago

I believe it can be a way, I am open to suggestions. I'm still thinking about it

PH7-Jack commented 2 years ago

@trippo it is now released

You can use option-key-label or option-key-value

trippo commented 2 years ago

Work like a charme