{"name":"svelte-select","version":"6.0.0","repository":{"type":"git","url":"git+https://rob-balfre@github.com/rob-balfre/svelte-select.git"},"description":"A <Select> component for Svelte apps","peerDependencies":{"svelte":">=5"},"devDependencies":{"@changesets/cli":"^2.31.0","@sveltejs/adapter-auto":"^3.0.0","@sveltejs/adapter-static":"^3.0.0","@sveltejs/kit":"^2.66.0","@sveltejs/package":"^2.3.7","@sveltejs/vite-plugin-svelte":"^4.0.0","@vitest/browser":"^3.2.4","autoprefixer":"^10.4.14","cross-env":"^7.0.3","find-in-files":"^0.5.0","fuse.js":"^6.6.2","playwright":"^1.54.2","prettier":"~3.8.4","prettier-plugin-svelte":"^3.2.6","svelte":"^5.56.4","svelte-check":"^4.6.0","svelte-highlight":"^7.2.1","svelte-preprocess":"^6.0.0","svelte-tiny-virtual-list":"^2.0.5","typescript":"^5.5.0","vite":"^5.4.4","vitest":"^3.2.4"},"author":{"name":"Robert Balfré","email":"rob.balfre@gmail.com","url":"https://github.com/rob-balfre"},"license":"ISC","keywords":["svelte"],"type":"module","exports":{"./package.json":"./package.json",".":{"types":"./package/index.d.ts","svelte":"./package/index.js"},"./no-styles":{"types":"./package/no-styles/Select.svelte.d.ts","svelte":"./package/no-styles/Select.svelte"},"./no-styles/Select.svelte":{"types":"./package/no-styles/Select.svelte.d.ts","svelte":"./package/no-styles/Select.svelte"},"./tailwind.css":"./package/tailwind.css"},"dependencies":{"svelte-floating-ui":"1.5.8"},"svelte":"./package/index.js","types":"./package/index.d.ts","scripts":{"dev":"vite dev","build":"vite build","preview":"vite preview","check":"svelte-kit sync && svelte-check","lint":"prettier --check .","format":"prettier --write .","test":"vitest run --browser","test:watch":"vitest --browser","gen:docs":"node docs/generate_theming_variables_md.js","package":"node src/remove-styles.js && svelte-package -o package && node src/post-prepare.js && npm run gen:docs","changeset:version":"changeset version","changeset:publish":"changeset publish"},"_id":"svelte-select@6.0.0","bugs":{"url":"https://github.com/rob-balfre/svelte-select/issues"},"homepage":"https://github.com/rob-balfre/svelte-select#readme","_integrity":"sha512-WJ1UDw0a1Z3I7oVFgaCS7G9D2rCSmYAPpufNEj/DNuk5Oyb2a5dju6F36o0urBVw9bTE3WkM9cZkI0x+Sfo8Bg==","_resolved":"/tmp/421bd8664004bd81ebc0734fec503c36/svelte-select-6.0.0.tgz","_from":"file:svelte-select-6.0.0.tgz","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-WJ1UDw0a1Z3I7oVFgaCS7G9D2rCSmYAPpufNEj/DNuk5Oyb2a5dju6F36o0urBVw9bTE3WkM9cZkI0x+Sfo8Bg==","shasum":"b1d11e0a811c6f4904b14fb7b2406b7022d52195","tarball":"http://registry-npm.ywwl.com/svelte-select/download/svelte-select-6.0.0.tgz","fileCount":28,"unpackedSize":118554,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/svelte-select@6.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCTm9YiVmk8KT6BnhBtaJPrvJ3hYDtmcfHX4R7ap42DPwIgG5kDlZNj2oUYddtF6PCNZrqQ2Kpof4OdL1oX6BQQNXE="}],"size":26318,"noattachment":false,"key":"/svelte-select/-/svelte-select-6.0.0.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:55cb8694-7af3-4d9b-b5c4-e38cd28b012a"}},"directories":{},"maintainers":[{"name":"rob-balfre","email":"rob.balfre@gmail.com"},{"name":"dummdidumm","email":"sholthausen@web.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/svelte-select_6.0.0_1786436420056_0.15205033476451102"},"_hasShrinkwrap":false,"readme":"<div align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/rob-balfre/svelte-select/master/svelte-select.png\" alt=\"Svelte Select\" width=\"150\" />\n  <h1>Svelte Select</h1>\n</div>\n\n<div align=\"center\">\n  <a href=\"https://npmjs.org/package/svelte-select\">\n    <img src=\"https://badgen.now.sh/npm/v/svelte-select\" alt=\"version\" />\n  </a>\n  <a href=\"https://npmjs.org/package/svelte-select\">\n    <img src=\"https://badgen.now.sh/npm/dm/svelte-select\" alt=\"downloads\" />\n  </a>\n</div>\n<div align=\"center\">A select/autocomplete/typeahead Svelte component.</div>\n\n## Demos\n\n[💥 Examples of every prop, callback, snippet and more 💥](https://svelte-select-examples.vercel.app)\n\n[✨ REPL: Simple ✨](https://svelte.dev/repl/c3bbe052fdfc4e87a46ccd9091ee002b)\n\n[💃 REPL: Show me everything 🕺](https://svelte.dev/repl/3df87e32340e4e9e85bf371becae2af0)\n\n## Installation\n\n```bash\nnpm install svelte-select\n```\n\n## Svelte 5\n\n`svelte-select` v6+ requires **Svelte 5**. The component uses runes, callback props instead of `createEventDispatcher`, and snippet props instead of named slots.\n\nIf you are upgrading from an older version, see the [migration guide](/MIGRATION_GUIDE.md).\n\n\n## Rollup and low/no-build setups\n\nList position and floating is powered by `floating-ui`, see their [package-entry-points](https://github.com/floating-ui/floating-ui#package-entry-points) docs if you encounter build errors.\n\n\n\n## Props\n\n| Prop                   | Type      | Default         | Description                                                    |\n| ---------------------- | --------- | --------------- | -------------------------------------------------------------- |\n| items                  | `any[]`   | `[]`            | Array of items available to display / filter                   |\n| value                  | `any`     | `undefined`     | Selected value(s). Shape depends on `valueMode` — see below.   |\n| valueMode              | `string`  | `item`          | `item`: full item object(s). `id`: primitive id(s) via `itemId`. String/primitive `items` keep primitive `value` without setting `id`. |\n| itemId                 | `string`  | `value`         | Override default identifier                                    |\n| label                  | `string`  | `label`         | Override default label                                         |\n| id                     | `string`  | `null`          | id attr for input field                                        |\n| filterText             | `string`  | `''`            | Text to filter `items` by                                      |\n| placeholder            | `string`  | `Please select` | Placeholder text                                               |\n| hideEmptyState         | `boolean` | `false`         | When no items hide list                                        |\n| listOpen               | `boolean` | `false`         | Open/close list                                                |\n| class                  | `string`  | `''`            | container classes                                              |\n| containerStyles        | `string`  | `''`            | Add inline styles to container                                 |\n| clearable              | `boolean` | `true`          | Enable clearing of value(s)                                    |\n| disabled               | `boolean` | `false`         | Disable select                                                 |\n| multiple               | `boolean` | `false`         | Enable multi-select                                            |\n| searchable             | `boolean` | `true`          | If `false` search/filtering is disabled                        |\n| groupHeaderSelectable  | `boolean` | `false`         | Enable selectable group headers                                |\n| focused                | `boolean` | `false`         | Controls input focus                                           |\n| listAutoWidth          | `boolean` | `true`          | If `false` will ignore width of select                         |\n| showChevron            | `boolean` | `false`         | Show chevron                                                   |\n| inputAttributes        | `object`  | `{}`            | Pass in HTML attributes to Select's input                      |\n| placeholderAlwaysShow  | `boolean` | `false`         | When `multiple` placeholder text will always show              |\n| loading                | `boolean` | `false`         | Shows `loading-icon`. `loadOptions` will override this         |\n| listOffset             | `number`  | `5`             | `px` space between select and list                             |\n| debounceWait           | `number`  | `300`           | `milliseconds` debounce wait                                   |\n| floatingConfig         | `object`  | `{}`            | [Floating UI Config](https://floating-ui.com/)                 |\n| hasError               | `boolean` | `false`         | If `true` sets error class and styles                          |\n| name                   | `string`  | `null`          | Name attribute of hidden input, helpful for form actions       |\n| required               | `boolean` | `false`         | If `Select` is within a `<form>` will restrict form submission |\n| multiFullItemClearable | `boolean` | `false`         | When `multiple` selected items will clear on click             |\n| closeListOnChange      | `boolean` | `true`          | After `onchange` list will close                               |\n| clearFilterTextOnBlur  | `boolean` | `true`          | If `false`, `filterText` value is preserved on blur            |\n\nThese props support two-way binding: `value`, `filterText`, `items`, `loading`, `listOpen`, `focused`, `hoverItemIndex`, `container`, and `input`.\n\n\n## Snippets\n\nCustomize parts of the select by passing snippet props. Kebab-case slot names from v4 map to camelCase snippet names (for example `clear-icon` → `clearIcon`, `list-prepend` → `listPrepend`). The `required` slot is now `requiredIndicator` to avoid clashing with the `required` prop.\n\n```svelte\n<Select {items}>\n  {#snippet prepend()}{/snippet}\n  {#snippet selection({ selection, index })}{/snippet} <!-- index only available when multiple -->\n  {#snippet clearIcon()}{/snippet}\n  {#snippet multiClearIcon()}{/snippet}\n  {#snippet loadingIcon()}{/snippet}\n  {#snippet chevronIcon({ listOpen })}{/snippet}\n  {#snippet listPrepend()}{/snippet}\n  {#snippet list({ filteredItems })}{/snippet}\n  {#snippet listAppend()}{/snippet}\n  {#snippet item({ item, index })}{/snippet}\n  {#snippet empty()}{/snippet}\n  {#snippet inputHidden({ value })}{/snippet}\n  {#snippet requiredIndicator({ value })}{/snippet}\n</Select>\n```\n\n\n## Callback props\n\nPass functions as props to respond to select behaviour. Callbacks receive their payload directly.\n\n| Callback     | Payload                              | Description                                                                |\n| ------------ | ------------------------------------ | -------------------------------------------------------------------------- |\n| onchange     | `value`                              | Fires when the user selects an option                                      |\n| oninput      | `value`                              | Fires when the bound value changes                                         |\n| onselect     | `selection`                          | Fires with the selected item when an option is chosen                       |\n| onfocus      | `FocusEvent`                         | Fires when the select input receives focus                                 |\n| onblur       | `FocusEvent`                         | Fires when the select input loses focus                                    |\n| onclear      | `value` or removed item              | Fires when clear is invoked or an item is removed from a multi select      |\n| onloaded     | `{ items }`                          | Fires when `loadOptions` resolves                                          |\n| onerror      | `{ type, details }`                  | Fires when an error is caught (for example a rejected `loadOptions`)       |\n| onfilter     | `filteredItems`                    | Fires when `listOpen: true` and items are filtered                         |\n| onhoverItem  | `hoverItemIndex`                     | Fires when the hovered list item index changes                             |\n\n```svelte\n<script>\n  import Select from 'svelte-select';\n\n  let items = [\n    { value: 'one', label: 'One' },\n    { value: 'two', label: 'Two' },\n  ];\n\n  function handleChange(value) {\n    console.log(value);\n  }\n</script>\n\n<Select {items} onchange={handleChange} />\n```\n\n\n### Items\n\n`items` can be simple arrays or collections.\n\n```html\n<script>\n  import Select from 'svelte-select';\n\n  let simple = ['one', 'two', 'three'];\n\n  let collection = [\n    { value: 1, label: 'one' },\n    { value: 2, label: 'two' },\n    { value: 3, label: 'three' },\n  ];\n</script>\n\n<Select items={simple} />\n\n<Select items={collection} />\n```\n\nThey can also be grouped and include non-selectable items.\n\n```html\n<script>\n  import Select from 'svelte-select';\n\n  const items = [\n    {value: 'chocolate', label: 'Chocolate', group: 'Sweet'},\n    {value: 'pizza', label: 'Pizza', group: 'Savory'},\n    {value: 'cake', label: 'Cake', group: 'Sweet', selectable: false},\n    {value: 'chips', label: 'Chips', group: 'Savory'},\n    {value: 'ice-cream', label: 'Ice Cream', group: 'Sweet'}\n  ];\n\n  const groupBy = (item) => item.group;\n</script>\n\n<Select {items} {groupBy} />\n```\n\n### valueMode\n\n`valueMode` controls what shape `bind:value` uses. It must match how you pass `value` and how your `items` identify options (`itemId`, default `'value'`).\n\n| Mode | `value` (single) | `value` (`multiple`) | On select |\n| ---- | ---------------- | -------------------- | --------- |\n| `item` (default) | item object | item object[] | list item |\n| `id` | primitive id | primitive id[] | `item[itemId]` only |\n\n- **`item`** — `value` is the full row. Use with object `items`. Labels come from `value.label` (or `label` prop).\n- **`id`** — `value` is just the identifier. Use for forms/APIs when `items` are objects. Labels are resolved from `items` by matching `itemId`.\n\n**String / primitive `items`:** when `items` is a string (or other primitive) array, `value` stays a matching primitive automatically — you do **not** need `valueMode=\"id\"`. On select, `value` is not upgraded to `{ value, label }`.\n\nFor object `items`, `value` and `valueMode` must align — the component does not convert between shapes. Object `items` with `valueMode=\"id\"` means `value` should be `'cake'`, not `{ value: 'cake', label: 'Cake' }`.\n\n```html\n<!-- string items → bind a string (no valueMode needed) -->\n<Select items={['one', 'two']} bind:value />\n\n<!-- object items, bind the id only -->\n<Select items={collection} valueMode=\"id\" bind:value />\n\n<!-- object items, bind the full item (default) -->\n<Select items={collection} bind:value />\n```\n\nYou can also use custom collections.\n\n```html\n<script>\n  import Select from 'svelte-select';\n\n  const itemId = 'id';\n  const label = 'title';\n\n  const items = [\n    {id: 0, title: 'Foo'},\n    {id: 1, title: 'Bar'},\n  ];\n</script>\n\n<Select {itemId} {label} {items} />\n```\n\n### Async Items\n\nTo load items asynchronously then `loadOptions` is the simplest solution. Supply a function that returns a `Promise` that resolves with a list of items. `loadOptions` has debounce baked in and fires each time `filterText` is updated.\n\n```html\n<script>\n  import Select from 'svelte-select';\n\n  import { someApiCall } from './services';\n\n  async function examplePromise(filterText) {\n    // Put your async code here...\n    // For example call an API using filterText as your search params\n    // When your API responds resolve your Promise\n    let res = await someApiCall(filterText);\n    return res;\n  }\n</script>\n\n<Select loadOptions={examplePromise} />\n```\n\n\n### Advanced List Positioning / Floating \n\n`svelte-select` uses [floating-ui](https://floating-ui.com/) to control the list floating. See their docs and pass in your config via the `floatingConfig` prop.\n\n```html\n<script>\n  import Select from 'svelte-select';\n\n  let floatingConfig = {\n    strategy: 'fixed'\n  }\n</script>\n\n<Select {floatingConfig} />\n```\n\n### Exposed methods and overridable props\n\nThese props and methods are exposed for advanced customization. See `test/src/tests.js` for examples.\n\nOverride filtering, grouping, or async loading:\n\n```svelte\n<Select\n  itemFilter={(label, filterText) => label.toLowerCase().includes(filterText.toLowerCase())}\n  groupBy={(item) => item.group}\n  groupFilter={(groups) => groups}\n  createGroupHeaderItem={(groupValue) => ({ value: groupValue, label: groupValue })}\n  loadOptions={async (filterText) => []}\n  debounce={(fn, wait = 1) => setTimeout(fn, wait)}\n  filter={customFilter}\n  getItems={customGetItems}\n/>\n```\n\nImperative methods (via `bind:this`):\n\n```js\n// Returns the current filtered list items\ngetFilteredItems();\n\n// Clears the current value and focuses the input\nhandleClear();\n```\n\n`loadOptions` must return a `Promise` that resolves with a list of items. Return `{ cancelled: true }` to keep the loading state active.\n\nCore replaceable helpers live in [`get-items.js`](/src/lib/get-items.js) and [`filter.js`](/src/lib/filter.js).\n\n## A11y (Accessibility)\n\nOverride these props to change the `aria-context` and `aria-selection` text.\n\n```svelte\n<Select\n  ariaValues={(values) => `Option ${values}, selected.`}\n  ariaListOpen={(label, count) =>\n    `You are currently focused on option ${label}. There are ${count} results available.`}\n  ariaFocused={() => `Select is focused, type to refine list, press down to open the menu.`}\n/>\n```\n\n## CSS custom properties (variables)\n\nYou can style a component by overriding [the available CSS custom properties](/docs/theming_variables.md).\n\n```html\n<script>\n  import Select from 'svelte-select';\n</script>\n\n<Select --border-radius= \"10px\" --placeholder-color=\"blue\" />\n```\n\nYou can also use the `inputStyles` prop to write in any override styles needed for the input.\n\n```html\n<script>\n  import Select from 'svelte-select';\n\n  const items = ['One', 'Two', 'Three'];\n</script>\n\n<Select {items} inputStyles=\"box-sizing: border-box;\"></Select>\n```\n\n### 🧪 Experimental: Replace styles (Tailwind, Bootstrap, Bulma etc)\nIf you'd like to supply your own styles use: `import Select from 'svelte-select/no-styles'`. Then somewhere in your code or build pipeline add your own. There is a tailwind stylesheet via `import 'svelte-select/tailwind.css'`. It uses `@extend` so PostCSS is required.\n\n\n## License\n\n[LIL](LICENSE)\n","publish_time":1786436420208,"_cnpm_publish_time":1786436420208,"dist-tags":{"alpha":"5.0.0-alpha.10","beta":"5.3.0-beta.7","latest":"6.0.0"}}