{"name":"svelte-select","version":"5.0.0-beta.17","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/adapter-auto":"next","@sveltejs/kit":"1.0.0-next.405","autoprefixer":"^10.4.8","cross-env":"^7.0.3","find-in-files":"^0.5.0","prettier":"~2.7.1","prettier-plugin-svelte":"^2.7.0","release-it":"^15.3.0","rollup":"^2.77.2","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.49.0","svelte-preprocess":"^4.10.7","svelte-tiny-virtual-list":"^2.0.5","svelte2tsx":"^0.5.13","tape-modern":"^1.1.2","typescript":"^4.7.4","vite":"^3.0.4"},"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","./LoadingIcon.svelte":"./LoadingIcon.svelte","./Select.svelte":"./Select.svelte","./compute-placement":"./compute-placement.js","./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/LoadingIcon.svelte":"./no-styles/LoadingIcon.svelte","./no-styles/Select.svelte":"./no-styles/Select.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## Examples\n\n[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/rob-balfre/svelte-select/tree/feature/v5?file=EXAMPLES.md)\n\n\n## Installation\n\n```bash\nnpm install svelte-select@beta\n```\n\n## Upgrading to v5\nSee [migration guide](/MIGRATION_GUIDE.md) if upgrading from v4 to v5.\n\n\n## Props\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| 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| listPlacement         | `string`  | `auto`          | Display list `'auto'`, `'top'` or `'bottom'`               |\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| appendListTarget      | `Element` | `null`          | Change where list gets appended                            |\n\n\n## Named slots\n\n```svelte\n<Select>\n  <div slot=\"prepend\" />\n  <div slot=\"selection\" let:selection />\n  <div slot=\"clear-icon\" />  \n  <div slot=\"multi-clear-icon\" />  \n  <div slot=\"loading-icon\" />  \n  <div slot=\"chevron-icon\" /> \n  <div slot=\"list\" let:filteredItems />  \n  <div slot=\"item\" let:item let:index />  \n  <!-- Remember you can also use `svelte:fragment` to avoid a container DOM element. -->\n  <svelte:fragment slot=\"empty\" />  \n</Select>\n```\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| error       | { type, details } | fires when error is caught                                                     |\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\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### Change where list gets appended\n\nBy default list gets prepended to `div.svelte-select`. For most use-cases this is fine. If you want more control then supply a `appendListTarget` Element\n\n```html\n<script>\n  import Select from 'svelte-select';\n\n  let target = document.body;\n</script>\n\n<Select appendListTarget={target} />\n<!-- list will now get appended to the DOM inside this form Element> -->\n```\n\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 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```js\nexport const sanitiseLabel = (text) => text && `${text}`.replace(/\\</gi, '&lt;');\n```\n\n> Override core functionality at your own risk! See ([get-items.js](/src/lib/get-items.js), [filter.js](/src/lib/filter.js), [compute-placement.js](/src/lib/compute-placement.js))\n```js\n    // core replaceable methods...\n    <Select \n      filter={...}\n      getItems={...}\n      computePlacement={...}\n    />\n```\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```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/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('...', async (t) => {\n  const select = new Select({\n    target,\n    props: {\n      ...\n    }\n  });\n\n  t.ok(...);\n\n  //select.$destroy();\n});\n\n```\n\n\n## License\n\n[LIL](LICENSE)\n","readmeFilename":"README.md","gitHead":"7a1e52cd0c444d0cd147ffc0cf3e18f2de3b2dcb","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.17","_nodeVersion":"17.9.0","_npmVersion":"8.5.5","dist":{"integrity":"sha512-z/DRuN1/STq9LC2fBC3v9C4UVskPrhFDq23oc+4c/62JoGRYSL0swcBrjRMmScgAq1nb7K01zrwCezjAcfIxEA==","shasum":"5856f58a8b6504355c3c88a6069575df0ae102f0","tarball":"http://registry-npm.ywwl.com/svelte-select/download/svelte-select-5.0.0-beta.17.tgz","fileCount":29,"unpackedSize":107272,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDeZz0p3SdZeIRQ1bA9OIP3DJeYXVyv0Cbi6Jzm8YsUsgIhAOcyjCZQt9d6qMFSwYLv9MjD9XeR8OFDevLh5bkS8tQW"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi9D+MACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqQcA/+MZoOY1YXKS777K+d8A0OJpusT2t85OJaggA4GdSJ9MNG97GI\r\n5io30Yo0fRAd54PnBKqTgBcndvtbzFaGuyhPNFwu3qYTksNR43BpcjevIVBt\r\nmJKZBDnlr6ALCb2t+QuO3zkiMq8oaPTo4qO3xQ6T2orqlROTsfpOifOtuy+c\r\nC6BVgoAxxBAaq44r2njGfa8nPpXdqd8ijxEgTO/V+mNE58i6u9Rbz3aalM6J\r\nj6adsojP1wtZEriVo+CIbnO8np4SsRDY446/N9KUcd3hDGuJEO53xci/DqXz\r\nJY7QywLQv3LMTkyr/Z724bRlPsCKdLjpcjI99/wMFkElvaGvQijtLdJ7t/Sy\r\nf3g+CVjm9qvNkhmwE8crZ0xsin2+Jhsz+9OGE+CTnv/aOQkhjJjiUSnE/44R\r\nZGA8OalDAeLGruwxuzwBygIAuNds4REVmlbPfhMkn4OYGSxI3SGYaZMJDAJZ\r\nOjEPzZVInCxu55v3CJD9LDbtbRzd3Ga8dOgrZ2NVmtt98+2IdTJQiEti4v3L\r\nwHqVtHt7iP9hon2mjRmBUQUaGFaLEetfuCCE8uiUcvW4tJEo3bRL6ElM/YyB\r\nNojCdZT3iasc5QKRc8HDhZAqmGeAcy7EXEe2Bb6dyTL/c/KrXM+XJhAtW0pB\r\nSTRdKdYEuhIuF6gLsVAf8+n7hjJeFfuuJ6E=\r\n=GUsY\r\n-----END PGP SIGNATURE-----\r\n","size":19700,"noattachment":false,"key":"/svelte-select/-/svelte-select-5.0.0-beta.17.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.17_1660174219787_0.7557973359732537"},"_hasShrinkwrap":false,"publish_time":1660174220316,"_cnpm_publish_time":1660174220316,"dist-tags":{"alpha":"5.0.0-alpha.10","beta":"5.3.0-beta.7","latest":"6.0.0"}}