simple-svelte-autocomplete icon indicating copy to clipboard operation
simple-svelte-autocomplete copied to clipboard

Pre-selected auto complete multiple

Open gponty opened this issue 1 year ago • 0 comments

Hi, Thank you for your good job, but i have a question, it's possible to pre-select, like this :


<script>
import AutoComplete from 'simple-svelte-autocomplete';

	const colorList = [
  { id: 1, name: "White", code: "#FFFFFF" },
  { id: 2, name: "Red", code: "#FF0000" },
  { id: 3, name: "Yellow", code: "#FF00FF" },
  { id: 4, name: "Green", code: "#00FF00" },
  { id: 5, name: "Blue", code: "#0000FF" },
  { id: 6, name: "Black", code: "#000000" }
];

let selectedColorsItems = [
	{ id: 1, name: "White", code: "#FFFFFF" }
];
let selectedColorsValues = [1];
	
</script>

<AutoComplete
    multiple=true
    orderableSelection=true
    items={colorList}
    labelFieldName="name"
    valueFieldName="id"
    bind:selectedItem={selectedColorsItems}
    bind:value={selectedColorsValues}
    />

REPL : https://svelte.dev/repl/ef51e70ba1894da291048bcbdb287661?version=4.2.9

(this example doesnt work but may be i made a mistake).

Thank you

gponty avatar Jan 26 '24 10:01 gponty