svelteuidev / svelteui

SvelteUI Monorepo
https://svelteui.dev
MIT License
1.28k stars 64 forks source link

[Feature Request] NativeSelect should support `any` type values for options #278

Open vsergeev opened 1 year ago

vsergeev commented 1 year ago

Usage example, including component, action, motion, or utility API

const items = [
  { label: 'Stem bolt', value: {price: 5, quantity: 1000}},
  { label: 'Phaser', value: {price: 1000, quantity: 6}},
];

let value;

...

<NativeSelect bind:value={value} data={items} />

Support for this is more consistent with how Svelte presently handles <select>.

Possible implementation - describe how the feature can be implemented

Change the value type in SelectItem from string to any, and anywhere value is currently being coerced into a string.

Do you want to contribute this feature and create a pull request

No

BeeMargarida commented 1 year ago

Hum, I understand what you are requesting, since it's supposed to have the same behaviour as native <select>. I'll explore a way of making this work without impacting other components that use the Input component, since these changes will also make way to the future components of Select