{"name":"svelte-select","version":"5.0.0-beta.14","repository":{"type":"git","url":"git+https://rob-balfre@github.com/rob-balfre/svelte-select.git"},"description":"A <Select> component for Svelte apps","devDependencies":{"@rollup/plugin-alias":"^3.1.9","@sveltejs/kit":"1.0.0-next.348","autoprefixer":"^10.4.7","cross-env":"^7.0.3","find-in-files":"^0.5.0","prettier":"~2.6.2","prettier-plugin-svelte":"^2.7.0","release-it":"^15.0.0","rollup":"^2.75.5","rollup-plugin-cleaner":"^1.0.0","rollup-plugin-css-only":"^3.1.0","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-postcss":"^4.0.2","rollup-plugin-svelte":"^7.1.0","sirv-cli":"^2.0.2","svelte":"^3.48.0","svelte-preprocess":"^4.10.7","svelte-tiny-virtual-list":"^2.0.5","svelte2tsx":"^0.5.10","tape-modern":"^1.1.2","typescript":"^4.7.3"},"author":{"name":"Robert Balfré","email":"rob.balfre@gmail.com","url":"https://github.com/rob-balfre"},"license":"ISC","keywords":["svelte"],"release-it":{"hooks":{"after:bump":"npm run prepare"},"github":{"release":false},"npm":{"publishPath":"./package"}},"type":"module","exports":{"./package.json":"./package.json","./.DS_Store":"./.DS_Store","./ChevronIcon.svelte":"./ChevronIcon.svelte","./ClearIcon.svelte":"./ClearIcon.svelte","./Item.svelte":"./Item.svelte","./List.svelte":"./List.svelte","./LoadingIcon.svelte":"./LoadingIcon.svelte","./Multi.svelte":"./Multi.svelte","./Select.svelte":"./Select.svelte","./Selection.svelte":"./Selection.svelte","./filter":"./filter.js","./get-items":"./get-items.js",".":"./index.js","./no-styles/ChevronIcon.svelte":"./no-styles/ChevronIcon.svelte","./no-styles/ClearIcon.svelte":"./no-styles/ClearIcon.svelte","./no-styles/Item.svelte":"./no-styles/Item.svelte","./no-styles/List.svelte":"./no-styles/List.svelte","./no-styles/LoadingIcon.svelte":"./no-styles/LoadingIcon.svelte","./no-styles/Multi.svelte":"./no-styles/Multi.svelte","./no-styles/Select.svelte":"./no-styles/Select.svelte","./no-styles/Selection.svelte":"./no-styles/Selection.svelte","./tailwind.css":"./tailwind.css"},"svelte":"./index.js","types":"./index.d.ts","readme":"<div align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/rob-balfre/svelte-select/feature/v5/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## Demo\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@beta\n```\n\n## Migrating for v4 to v5\n\nv5 is a major release that that includes some ⚠️ BREAKING CHANGES ⚠️ \n\nRemoved `isVirtualList` instead `npm i svelte-tiny-virtual-list -D` and\n\n```svelte\n<script>\n  import VirtualList from 'svelte-tiny-virtual-list';\n</script>\n\n<Select {VirtualList} />\n```\n\n### CSS Camel to kebab:\n\nCSS classes and custom properties changed (only depreciated, no need to update if upgrading from v4) from camel to kebab case. For example `selectedItem` → `selected-item` and `--borderRadius` → `--border-radius`\n\n### Redundant CSS custom properties:\n\nThe following CSS custom properties were removed in v5.\n\n```css\n--clearSelectColor\n--clearSelectFocusColor\n--clearSelectHoverColor\n--groupTitleTextTransform\n--indicatorColor\n--indicatorFill\n--indicatorHeight\n--listLeft\n--listRight\n--multiClearBG\n--multiClearFill\n--multiClearHeight\n--multiClearHoverBG\n--multiClearHoverFill\n--multiClearPadding\n--multiClearRadius\n--multiClearTextAlign\n--multiClearTop\n--multiClearWidth\n--multiItemActiveBG\n--multiItemActiveColor\n--spinnerLeft\n--spinnerRight\n--virtualListHeight\n```\n\n\n### Other CSS class name changes:\n`selectContainer` → `svelte-select`<br/>\n`listContainer` → `list`<br/>\n`indicator` → `chevron`<br/>\n`--clear-icon-colour` → `--clear-icon-color`<br/>\n`virtual-list` removed\n\n\n### Prop changes:\n`containerClasses` → `class`<br/>\n`MultiSelection` → `Multi`<br/>\n`indicatorSvg` → `ChevronIcon`<br/>\n`showIndicator` → `showChevron`<br/>\n`selectedValue` removed (was already deprecated in v4 in favour of `value`)<br/>\n`loadOptionsInterval` → `debounceWait`\n\n\n### Event change:\nThe `select` event now only fires when the user selects an item. If you also want to track programmatic changes use the new `change` event.\n\n\n## Props\n\n\n| Prop                    | Type       | Default         | Description                                                |\n| ----------------------- | ---------- | --------------- | ---------------------------------------------------------- |\n| items                   | `any[]`    | `[]`            | Array of items available to display / filter               |\n| value                   | `any`      | `null`          | Selected value(s)                                          |\n| justValue               | `any`      | `null`          | **READ-ONLY** Selected value(s) excluding container object |\n| optionIdentifier        | `string`   | `value`         | Override default identifier                                |\n| labelIdentifier         | `string`   | `label`         | Override default identifier                                |\n| id                      | `string`   | `null`          | Add an id to the filter input field                        |\n| filterText              | `string`   | `''`            | Text to filter `items` by                                  |\n| placeholder             | `string`   | `Please select` | Placeholder text                                           |\n| noOptionsMessage        | `string`   | `No options`    | Message displayed when no items                            |\n| hideEmptyState          | `boolean`  | `false`         | When no items hide list and `noOptionsMessage`             |\n| listOpen                | `boolean`  | `false`         | Open/close list                                            |\n| class                   | `string`   | `''`            | container classes                                          |\n| containerStyles         | `string`   | `''`            | Add inline styles to container                             |\n| isClearable             | `boolean`  | `true`          | Enable clearing of value(s)                                |\n| isCreatable             | `boolean`  | `false`         | Can create new item(s) to be added to `value`              |\n| isDisabled              | `boolean`  | `false`         | Disable select                                             |\n| isMulti                 | `boolean`  | `false`         | Enable multi-select                                        |\n| isSearchable            | `boolean`  | `true`          | If `false` search/filtering is disabled                    |\n| isGroupHeaderSelectable | `boolean`  | `false`         | Enable selectable group headers                            |\n| listPlacement           | `string`   | `auto`          | Display list `'auto'`, `'top'` or `'bottom'`               |\n| hasError                | `boolean`  | `false`         | Show error styles around select input                      |\n| listAutoWidth           | `boolean`  | `true`          | If `false` will ignore width of select                     |\n| showChevron             | `boolean`  | `false`         | Show chevron at all times                                  |\n| inputAttributes         | `object`   | `{}`            | Pass in HTML attributes to Select's input                  |\n| iconProps               | `object`   | `{}`            | Icon props                                                 |\n| filteredItems           | `array`    | `[]`            | List of items after filtering (read only)                  |\n| placeholderAlwaysShow   | `boolean`  | `false`         | When `isMulti` placeholder text will always show           |\n| isWaiting               | `boolean`  | `false`         | Show LoadingIcon. `loadOptions` will override this         |\n| listOffset              | `number`   | `5`             | `px` space between select and list                         |\n| debounceWait            | `number`   | `300`           | `milliseconds` debounce wait                               |\n| suggestions             | `string[]` | `null`          | Show search suggestions before user input                  |\n\n\n### Replaceable components\n\n| Import      | Type        | Description           |\n| ----------- | ----------- | --------------------- |\n| Item        | `component` | Item component        |\n| Selection   | `component` | Selection component   |\n| Multi       | `component` | Multi select support  |\n| ChevronIcon | `component` | Chevron Icon          |\n| ClearIcon   | `component` | Clear Icon            |\n| LoadingIcon | `component` | Spinning Loading Icon |\n\n\n### Optional component imports\n\n| Import      | Type        | Description                                            |\n| ----------- | ----------- | ------------------------------------------------------ |\n| VirtualList | `component` | Virtual list support (uses `svelte-tiny-virtual-list`) |\n| Icon        | `component` | Icon component                                         |\n\n\n## Events\n\n| Event Name  | Callback          | Description                                                                    |\n| ----------- | ----------------- | ------------------------------------------------------------------------------ |\n| select      | { detail }        | fires when item is selected                                                    |\n| change      | { detail }        | fires when value changes                                                       |\n| focus       | { detail }        | fires when select > input on:focus                                             |\n| blur        | { detail }        | fires when select > input on:blur                                              |\n| clear       | { detail }        | fires when clear all is invoked or item is removed (by user) from multi select |\n| loaded      | { options }       | fires when `loadOptions` resolves                                              |\n| itemCreated | { options }       | fires when `isCreatable` true and item is created                              |\n| error       | { type, details } | fires when error is caught                                                     |\n\n\n### Items\n\n`items` can be simple arrays or collections.\n\n```svelte\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```svelte\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\nYou can also use custom collections.\n\n```svelte\n<script>\n  import Select from 'svelte-select';\n\n  const optionIdentifier = 'id';\n  const labelIdentifier = 'title';\n\n  const items = [\n    {id: 0, title: 'Foo'},\n    {id: 1, title: 'Bar'},\n  ];\n</script>\n\n<Select {optionIdentifier} {labelIdentifier} {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```svelte\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### Exposed methods\nThese internal functions are exposed to override if needed. See the adv demo or look through the test file (test/src/index.js) for examples.\n\n```js\nexport let itemFilter = (label, filterText, option) => label.toLowerCase().includes(filterText.toLowerCase());\n```\n\n```js\nexport let groupBy = undefined;\n```\n\n```js\nexport let groupFilter = groups => groups;\n```\n\n```js\nexport let createGroupHeaderItem = groupValue => {\n  return {\n    value: groupValue,\n    label: groupValue\n  };\n};\n```\n\n```js\nexport let createItem = filterText => {\n  return {\n    value: filterText,\n    label: filterText\n  };\n};\n```\n\n```js\nexport let getOptionLabel = (option, filterText) => {\n  return option.isCreator ? `Create \\\"${filterText}\\\"` : option.label;\n};\n```\n\n```js\nexport let getSelectionLabel = option => {\n  if (option) return option.label;\n};\n```\n\n```js\nexport let getGroupHeaderLabel = option => {\n  return option.label;\n};\n```\n\n```js\nexport function handleClear() {\n  value = undefined;\n  listOpen = false;\n  dispatch(\"clear\", value);\n  handleFocus();\n}\n```\n\n```js\nexport let loadOptions = undefined; // if used must return a Promise that updates 'items'\n/* Return an object with { cancelled: true } to keep the loading state as active. */\n```\n\n```js\nexport const getFilteredItems = () => {\n  return filteredItems;\n};\n```\n\n```js\nexport function debounce(fn, wait = 1) {\n    let timeout;\n    return function (...args) {\n        clearTimeout(timeout);\n        timeout = setTimeout(() => fn.apply(this, ...args), wait);\n    };\n}\n```\n\n| debounce    | `function`  | Debounce function                                   |\n| filter      | `function`  | Filter options function                             |\n| loadOptions | `function`  | Return a `Promise` that resolves with items         |\n| getItems    | `function`  | Take full control of async and loadOptions defaults |\n\n## A11y (Accessibility)\n\nOverride these methods to change the `aria-context` and `aria-selection` text.\n\n```js\nexport let ariaValues = (values) => {\n  return `Option ${values}, selected.`;\n}\n\nexport let ariaListOpen = (label, count) => {\n  return `You are currently focused on option ${label}. There are ${count} results available.`;\n}\n\nexport let ariaFocused = () => {\n  return `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```svelte\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```svelte\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/Select.svelte'`. 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## Development\n\n```bash\nnpm i\nnpm run dev-tests\nnpm test:browser\n```\n\nOpen http://localhost:3000 and see devtools console output. When developing it's useful to see the component on the page; comment out the `select.$destroy();` on test your debugging in /test/src/index.js and use `test.only()` to target just one test.\n\nFor example:\n\n```js\ntest.only('when getSelectionLabel contains HTML then render the HTML', async (t) => {\n  const select = new Select({\n    target,\n    props: {\n      value: items[0],\n      getSelectionLabel: (option) => `<p>${option.label}</p>`,\n    }\n  });\n\n  t.ok(document.querySelector('.selection').innerHTML === '<p>Chocolate</p>');\n\n  //select.$destroy();\n});\n\n```\n\n\n## License\n\n[LIL](LICENSE)\n","readmeFilename":"README.md","gitHead":"9cf0efb1485dbac81bf905750af9d594c6968cbe","bugs":{"url":"https://github.com/rob-balfre/svelte-select/issues"},"homepage":"https://github.com/rob-balfre/svelte-select#readme","_id":"svelte-select@5.0.0-beta.14","_nodeVersion":"17.9.0","_npmVersion":"8.5.5","dist":{"integrity":"sha512-ICs0gjTZDv8yMnUjJY53DYGEV8xVbXa93WIWlczEOujRgEzIMAxAA2m7aIv9GCu7VWh2Pd/7gDJZUF5Dy/FSbw==","shasum":"84f6c63a3b58068cfe6bad5d7fac33b2489b1597","tarball":"http://registry-npm.ywwl.com/svelte-select/download/svelte-select-5.0.0-beta.14.tgz","fileCount":43,"unpackedSize":134059,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFaUPfpMtquJ237ZWqZ93otdbe8nfJwQmBzJ735pZ51DAiAKJQ/uLdmDBzgJiH53osUmBZfcAd0ibs84KTxnJXXE/Q=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJioTR4ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpq6Q/+IygZWO4Fd5M4end36CKg+9qxJB5Hw1nReWLiSBPvymPHTBlt\r\nW0CwQzXqJzIuXKT8A/0TtPmMEF8kZGJn6FlOLpvKF4a5Ffl/EOSh2z+GzhIs\r\nIRt4WWLKAshXiecktg5FiuQj6TIY/zbaLaix82S1+VqPVGB7cpegF7YY/Wgu\r\nXDkL6S/s4c8OK1oufy2xuRjyxVgYFPtGbR8z4VsC/eR/pKOJk4fU/c4IsAkJ\r\n9673xMweWJl5EsLO6mSLZs950bDq+OWIe1n++rH3k7YYZi3Mh7MiPS3XDmK6\r\nZ+0s6uVrNheAWG1IGRzrxQECb+76Vtfrv3gYft0m8oQvehArmXRsbqBoSFjf\r\nmvjfezP+LDaL3+ANbzmY3+hWR0lryfUgERu3mNmuoqp6+uqQLP7j2GYOf7yE\r\nFu4y4ljtA8ZRPcBsNXoSujVruymDFZTVBP6TruSk/RSJuHy7N/yI9H+44x/r\r\nuAiVF0eiuCEvMre5FYaLvgCm89bWaamT4k6pd68dJWwGeqPY0p3K0P67bQMS\r\n1zU+wBXi2aYGwNx07mVGTzzRatHhQpcgv4YEqhSepQxNWmrnNkZDpk6qFlED\r\nUgcYG9u4Anq0yLTpNJM1vjZOXA57fK9n1qsH1aekK9JylcUDM/qth/Vu9BIl\r\nnRfOJKYE+P7EYjXgFWQYaP9hjFhqNB+MQtU=\r\n=9x/C\r\n-----END PGP SIGNATURE-----\r\n","size":22719,"noattachment":false,"key":"/svelte-select/-/svelte-select-5.0.0-beta.14.tgz"},"_npmUser":{"name":"rob-balfre","email":"rob.balfre@gmail.com"},"directories":{},"maintainers":[{"name":"rob-balfre","email":"rob.balfre@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-select_5.0.0-beta.14_1654731896719_0.5054420311620165"},"_hasShrinkwrap":false,"publish_time":1654731896859,"_cnpm_publish_time":1654731896859,"dist-tags":{"alpha":"5.0.0-alpha.10","beta":"5.3.0-beta.7","latest":"6.0.0"}}