Compare commits

...

787 commits

Author SHA1 Message Date
Matt Triff 5dbea2825a
Prep for 10.2.0 (#1077) 2022-11-29 13:44:43 -05:00
Morez 312971acea
[BUGFIX] Fix support for non-Latin characters (#1072)
* solve 1068

* resolve problems

* resolve npm problem

* Merge master and rebuild, fix lint error

* Create fresh package-lock.json

Co-authored-by: محمدرضا ضربی زاده <mohammad.zarbizadeh@samim.net>
Co-authored-by: Matt Triff <matt.triff@gmail.com>
2022-11-29 13:01:01 -05:00
Matt Triff a7ed4d880e
Merge pull request #1001 from brosua/feature/custom-properties
[BUGFIX] Correct evaluation of HTML custom properties and JSON support
2022-11-29 11:18:59 -05:00
Matt Triff ba27dbb533 Convert npx to npm exec 2022-11-29 10:46:06 -05:00
Matt Triff 9c6de739c7 Update build 2022-11-28 17:25:48 -05:00
Matt Triff 2730d7aad4
Merge pull request #1051 from Sysix/update-readme
Documentation: Add option "uniqueItemText" and "customAddItemText" to README
2022-11-28 17:15:03 -05:00
Matt Triff 5d17dd8531 Fix CI workflows 2022-11-28 17:11:41 -05:00
Matt Triff d1f39c6cda Update screenshot 2022-11-28 15:51:16 -05:00
Matt Triff bbdacdfe3b Update all CI workflows to use latest LTS (v18) 2022-11-28 14:18:14 -05:00
Matt Triff 92eabcbd4a Update all CI workflows to use latest LTS (v18) 2022-11-28 12:08:05 -05:00
Matt Triff 2a8107f379 Update package-lock.json 2022-11-28 11:45:39 -05:00
Matt Triff ea45c47d43 Merge branch 'master' into feature/custom-properties 2022-11-28 11:43:15 -05:00
Matt Triff d130beb4e9 Update dependencies, add e2e tests for HTML custom properties 2022-11-28 11:36:04 -05:00
Matt Triff 6056cce4e9
Merge pull request #1073 from Choices-js/dependabot/npm_and_yarn/minimatch-3.1.2
Bump minimatch from 3.0.4 to 3.1.2
2022-11-17 16:15:02 -05:00
dependabot[bot] ce590e3785
Bump minimatch from 3.0.4 to 3.1.2
Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
- [Release notes](https://github.com/isaacs/minimatch/releases)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-17 16:54:11 +00:00
Matt Triff 30e6dbadda
Merge pull request #1048 from Choices-js/dependabot/npm_and_yarn/terser-5.14.2
Bump terser from 5.10.0 to 5.14.2
2022-11-17 11:29:49 -05:00
Matt Triff 4da6239a67
Merge pull request #1069 from Choices-js/dependabot/npm_and_yarn/loader-utils-1.4.2
Bump loader-utils from 1.4.0 to 1.4.2
2022-11-17 11:29:09 -05:00
dependabot[bot] 9ac71c4717
Bump loader-utils from 1.4.0 to 1.4.2
Bumps [loader-utils](https://github.com/webpack/loader-utils) from 1.4.0 to 1.4.2.
- [Release notes](https://github.com/webpack/loader-utils/releases)
- [Changelog](https://github.com/webpack/loader-utils/blob/v1.4.2/CHANGELOG.md)
- [Commits](https://github.com/webpack/loader-utils/compare/v1.4.0...v1.4.2)

---
updated-dependencies:
- dependency-name: loader-utils
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-13 12:19:25 +00:00
Alexander Schlegel 835ea12ac9 add option "uniqueItemText" and "customAddItemText" into README.md 2022-08-27 16:50:32 +02:00
dependabot[bot] 1b67baec25
Bump terser from 5.10.0 to 5.14.2
Bumps [terser](https://github.com/terser/terser) from 5.10.0 to 5.14.2.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

---
updated-dependencies:
- dependency-name: terser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-20 01:34:00 +00:00
Matt Triff 624dd797a4
Merge pull request #1030 from Choices-js/dependabot/npm_and_yarn/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6
2022-07-09 11:05:50 -04:00
Matt Triff cbbdbda95b
Merge pull request #1034 from Moonlight-Angel/patch-1
Allow to overwrite the `$choices-z-index` variable
2022-07-09 10:38:20 -04:00
Genesis d796e90955
Allow to overwrite the $choices-z-index variable
#794 introduced a new SCSS variable for configuring the z-index, but it didn't set the `!default` flag, making it impossible to overwrite in external files.
2022-05-04 11:41:57 +02:00
Matt Triff 06d16cd857
Merge pull request #1026 from comxd/master
Fix typo on aria-labelledby attribute
2022-04-11 20:26:47 -04:00
dependabot[bot] d26b753f6b
Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 18:22:59 +00:00
David DIVERRES 72da548a64 Fix typo on aria-labelledby attribute 2022-04-01 14:13:08 +02:00
Josua Vogel 490e341db5 Build public code 2022-03-14 15:57:05 +01:00
Josua Vogel 76780ccc34 Adding unit test and lint 2022-03-14 15:52:48 +01:00
Josua Vogel beb07ebc2c Merge branch 'master' into feature/custom-properties 2022-03-14 15:11:52 +01:00
Matt Triff 20d3f5cd55
Merge pull request #1021 from Choices-js/fix-param
Fix type for parameter on setChoiceByValue
2022-03-13 17:30:36 -04:00
Matt Triff f63201d929 Fix type for parameter on setChoiceByValue 2022-03-13 17:22:37 -04:00
Matt Triff 08d4f1fee7
Merge pull request #1011 from Choices-js/prep-10-1-0
Prep for 10.1.0
2022-02-13 21:49:32 -05:00
Matt Triff 09eeca0db0 Prep for 10.1.0 2022-02-13 21:39:17 -05:00
Matt Triff e2aab31bc0
Merge pull request #1010 from Choices-js/fix-hidden-first-char
Fix first character not appearing in webkit browsers
2022-02-13 21:12:40 -05:00
Matt Triff c01144ab23 Merge branch 'master' into fix-hidden-first-char 2022-02-13 21:07:18 -05:00
Matt Triff 86694c138e
Merge pull request #1009 from Choices-js/sponsor
Add sponsor
2022-02-13 21:05:30 -05:00
Matt Triff 7c360b44b3 Update snapshots 2022-02-13 20:58:20 -05:00
Matt Triff 2099c3dc2e Add sponsor 2022-02-13 20:46:02 -05:00
Matt Triff d25c065210 Fix first character not appearing in webkit browsers 2022-01-27 18:04:49 -05:00
Josua Vogel eb22895f00
Add option labelId to improve a11y (#971)
* Add option labelId to improve a11y

* Console.log entfernt

* Add test case for aria-labeledby

Co-authored-by: Josua Vogel <josua.vogel@t-systems.com>
2022-01-18 17:07:07 -05:00
Josua Vogel ac8d27facf [BUGFIX] Correct evaluation of custom properties 2022-01-17 13:46:19 +01:00
Matt Triff 06d4435c82
Merge pull request #1000 from mysliwietzflorian/mysliwietzflorian-patch-1
README Fix: Use select-single everywhere, fix missing comma in default options
2022-01-15 22:04:42 -05:00
Mysliwietz Florian bb76a572c0
minor update docs/readme
- use  `select-one` consistently (instead of `select-single` with two occurrences)
- add missing comma (,) in setup example with default options
2022-01-15 21:59:42 +01:00
Matt Triff 6df44b1044
Merge pull request #999 from Choices-js/bump-deps
Bump dev dependencies
2022-01-13 20:41:56 -05:00
Matt Triff 29097d5457 Bump dev dependencies 2022-01-13 20:31:33 -05:00
Matt Triff c21b998eaa Lint on style PRs 2022-01-13 20:16:49 -05:00
Matt Triff 96e4ac53d9 Merge branch 'master' of github.com:Choices-js/Choices 2022-01-11 20:24:30 -05:00
Matt Triff 770342b7e8 Split GitHub pages action, allow manual dispatch 2022-01-11 20:24:15 -05:00
Matt Triff eef836a037
Merge pull request #996 from supermueller/resolve-887
Fix multiple select in Internet Explorer 11
2022-01-11 20:07:58 -05:00
Matt Triff 8ab8157607 Bump CSS max size 2022-01-11 20:01:38 -05:00
Karsten Müller 75caa0b1f3 Resolve #887
Fix compatibility with Internet Explorer 11
2022-01-10 10:56:10 +01:00
Matt Triff 3d42067bbd Version 10.0.0 2022-01-02 23:38:07 -05:00
Matt Triff ce3d1111d8
Merge pull request #991 from Choices-js/fuse6
Upgrade to Fuse v6
2022-01-02 13:27:09 -05:00
Matt Triff 7758226d64
Merge pull request #992 from Choices-js/searchfloor0
Trigger search when clearing the input field with search floor of 0
2021-12-31 22:06:22 -05:00
Matt Triff 25a7ed0318 Add test with searchFloor of 0 2021-12-31 21:51:00 -05:00
Daiana Cambruzzi Ávila 23f0b7cb9d Fix Issue 630: allow triggering of 'search' event when clearing the input field 2021-12-31 18:23:13 -05:00
Matt Triff 303d12504c Upgrade to Fuse v6 2021-12-31 18:11:45 -05:00
Matt Triff 3b4d7543e5 Set line endings for type definition files 2021-12-31 18:10:15 -05:00
Matt Triff 781c729e13
Merge pull request #990 from Choices-js/fix-search-sanitisation
Remove character sanitisation when searching
2021-12-30 22:12:53 -05:00
Matt Triff 9605f367f9 Search using non-sanitised input value 2021-12-30 22:05:03 -05:00
Matt Triff 1b4d3553ef
Merge pull request #989 from Choices-js/update-actions
Update GitHub Actions
2021-12-30 20:45:24 -05:00
Matt Triff f12c62c4b8
Add methods to Table of Contents 2021-12-30 20:37:27 -05:00
Matt Triff c7976b7acd Add pause after resize to fix inconsistent dropdown/dropup direction behaviour 2021-12-30 20:25:33 -05:00
Matt Triff 4df199e0b9
Add checklist items for tests 2021-12-30 20:21:45 -05:00
Matt Triff 0903934848 Update GitHub Actions 2021-12-30 20:16:52 -05:00
Matt Triff 64b5df6874
Merge pull request #987 from victiondev/fix/typings
Fix/typings
2021-12-27 11:38:02 -05:00
Mason Rogers 824eca6f81 fix: Fix non-string-valeus 2021-12-27 15:58:25 +00:00
Mason Rogers 9c9aded8b2 chore: Build 2021-12-27 14:50:45 +00:00
Mason Rogers 7e200664c4 feat: Export interfaces 2021-12-27 14:46:22 +00:00
Matt Triff 04571e36d3
Merge pull request #986 from victiondev/fix/typings
fix: Add typings to published files
2021-12-27 09:01:45 -05:00
Mason Rogers 11208fe62d fix: Add typings to published files 2021-12-27 13:27:26 +00:00
Matt Triff b9acfa773d Add table of contents 2021-12-26 17:47:34 -05:00
Matt Triff 6e4903e852
Merge pull request #985 from Choices-js/fix-typings
Fix typings
2021-12-26 16:59:28 -05:00
Matt Triff a8862e78be Add typings and declaration maps 2021-12-26 16:38:09 -05:00
Matt Triff bf94386cc5 Update configuration to output types 2021-12-26 16:37:23 -05:00
Matt Triff 0b6973b322
Merge pull request #984 from victiondev/feat/allowHTML
feat: Introduce allowHTML option to allow people to disable injecting HTML into choices.
2021-12-26 09:47:07 -05:00
Matt Triff 66c6864267 Update allowHTML wording, set remote examples to allowHTML false 2021-12-26 09:36:12 -05:00
viction 391c3e39cb fix: README examples & change template type 2021-12-26 02:47:49 +00:00
viction 3d402d4560 fix: Circular dep caused by requiring options 2021-12-25 21:38:19 +00:00
viction 545a442f5c fix: Custom template displaying/unit tests 2021-12-25 20:29:54 +00:00
viction c989be1491 test: select-multiple coverage 2021-12-25 20:29:31 +00:00
viction 3633c4ac0f test: select-one coverage 2021-12-25 20:29:15 +00:00
viction 859f6262eb test: Coverage for allowHTML 2021-12-24 17:33:32 +00:00
viction 6b16e93977 fix: template testing & type errors 2021-12-24 17:32:50 +00:00
viction 7f727480e8 feat: allowHTML 2021-12-23 16:59:48 +00:00
Bob Maerten 82b94228f9
Enhance inputCloned text input with type and name (#908)
* Enhance inputCloned text input with type and name

Safari will display a contact autocomplete on every text input which `name` attribute contains "*name*" or does not have any `name` attribute.
Adding a fine tuned `name`attribute to the input should prevent that.

Plus, input type="search" seems more suited to the field intent (https://developer.mozilla.org/fr/docs/Web/HTML/Element/Input/search).

* Adapt inputCloned related test
2021-12-22 16:56:04 -05:00
Matt Triff b92823b70c
Merge pull request #983 from Choices-js/patch-1
Fix Sanitization of > Characters
2021-12-21 21:50:44 -05:00
Matt Triff 22f9be0d93 Update tests for &gt; 2021-12-21 18:07:31 -05:00
Raphaël Jorel 2222f767a9 Fix sanitise function
HTML uses `&gt;` to encode `>` characters.
2021-12-21 11:15:44 -05:00
Matt Triff f0ec43fa20 Version 9.1.0 2021-12-19 20:54:48 -05:00
Matt Triff c4f3a81d41
Merge pull request #979 from Choices-js/npm-audit-fix
Switch to dart-sass, fix npm audit issues, add stylelint
2021-12-19 18:25:44 -05:00
Matt Triff fb379408c1 Use Chrome for cypress:ci runs (fixes flakey test in Electron) 2021-12-19 18:21:42 -05:00
Matt Triff c26596e9ec Simplify linting GitHub Action 2021-12-19 18:09:41 -05:00
Matt Triff 9835eb756a Implement stylelint 2021-12-19 17:43:03 -05:00
Matt Triff 70397fd89a Switch to dart-sass, fix npm audit issues 2021-12-19 16:58:00 -05:00
Matt Triff 59ea75ef14
Update README.md
De-emphasize call for maintainers.
2021-12-19 14:07:02 -05:00
Ryan B 8647f36fbe
Documentation of input type terms (#873)
* Documentation of input type terms

Add a table with documentation of HTML5 input tag correspondence to terms used in Choices documentation

* Update README.md

Clean up typos, simplify table and use MDN for reference links

Co-authored-by: Matt Triff <matt.triff@gmail.com>
2021-12-19 10:14:20 -05:00
Hans Kuijpers 046afbb614
Solve deprecated warning using / for division outside of calc() (#976)
* replace / by *

* replace / by *

* add leading zero

* add leading zero
2021-12-19 10:02:21 -05:00
flip111 de5307ce4d
Update README.md (#844)
* Update README.md

* Update README.md

Switch to the Choices-js organization link.

Co-authored-by: Matt Triff <matt.triff@gmail.com>
2021-12-19 09:51:45 -05:00
Matt Triff 05a41c5c7d
Merge pull request #848 from JoshuaCrewe/fix/readme-typo
Fix typo in README.md s/withing/within
2021-12-18 23:22:54 -05:00
Matt Triff 9e656397cd
Merge pull request #977 from Choices-js/fix-selenium-workflow
Update dependencies, refactor to remove dependency cycles, fix GitHub Action workflows
2021-12-18 22:54:10 -05:00
Matt Triff 20579bad35 Use Chrome with Cypress (Electron resulted in flaky dropdown test), save Puppeteer diff image even if pixelmatch throws error, update Chrome snapshot 2021-12-18 22:36:40 -05:00
Matt Triff 977221650a Update snapshots, add Chrome to browser test, remove linting JS, bump dependencies - replace deprecated eslint-loader 2021-12-18 22:07:37 -05:00
Matt Triff e09a342ac8 PostCSS now required as a separate dependency of postcss-cli 2021-12-18 12:08:26 -05:00
Matt Triff e64eface11 Update all workflows to use Node 12+ for node-sass and other module compatibility, switch IE to Edge for browser testing (IE web driver no longer pre-installed on runner) 2021-12-17 16:59:43 -05:00
Matt Triff de6c46cdd0 Disable committing built files in GitHub Actions, conflicts with protected branch 2021-12-17 16:40:06 -05:00
Matt Triff a1ec9d0de6 eslint 8.x requires Node 12.22.0^ 2021-12-17 16:39:16 -05:00
Matt Triff 3d921621b7 Update dependencies, fix linting issues, split interfaces and default objects to resolve dependency cycles 2021-12-17 16:26:52 -05:00
Matt Triff 46deb9abe5 Switch to new brew cask syntax, IE driver no longer available - switch to hardcoded path 2021-12-15 20:59:31 -05:00
Matt Triff 6b6fb17bca Update adding to path to new syntax 2021-12-15 20:37:52 -05:00
Matt Triff b4a6371cc8
Merge pull request #975 from bzf/fix-demo-links
Fix broken demo link in README.md
2021-12-14 17:11:04 -05:00
André Ligné 60adc56bbf Fix broken demo link in README.md
After trying to see the demo for this project I noticed that the link
leads to a 404 page.

I found the updated link in [#957] and this commit updates the README to
link to the proper URL.

[#957]: https://github.com/Choices-js/Choices/issues/957
2021-11-15 14:56:35 +01:00
Josh Johnson ebbea8c3b0
Update README.md 2020-07-28 11:01:32 +01:00
Joshua Crewe 41f81d22ed Fix typo in README.md 2020-04-07 14:22:00 +01:00
Alex Chan cbaf43232c Fix a typo in the README: s/seperates/separates (#807) 2020-01-14 08:50:42 +00:00
Josh Johnson 825efc6fd0
Update release drafter to latest (#800) 2019-12-23 18:33:31 +00:00
Josh Johnson 68313da412
Convert to typescript (#795)
* Typescript config setup

* Add type annotations to components

* Further type additions

* And more...

* Add types to actions

* Add types to templates

* Further type checks

* Further type additons

* Install fuse latest

* Housekeeping

* Remove old type definitions

* Fix remaning type issues

* Fix some failing tests

* Remove types workflow

* Fix failing unit tests

* Resolve back space event regression

* Convert cypress files to .ts

* Fix eslint issues

* Remove cachebusting urls

* Resolve delete button bug

* Resolve regression bugs

* Fix lint script

* Fix lint workflow

* Pass args instead of object to keyboard handlers

* Flatten misc reducer

* Resolve keyboad action test failures

* Use Pick instead of Partial

* Use interfaces in action tests

* Update firefox image

* Incorporate #791

* Incorporate #788
2019-12-23 18:22:54 +00:00
dGrammatiko 3ed027229d Adds a variable for the z-index (#794) 2019-12-15 19:26:56 +00:00
Josh Johnson 44b4326a52
Resolve #780 (#785)
* Attempt #1

* Remove console.log

* Update puppeteer screenshot
2019-12-03 12:56:47 +00:00
Josh Johnson b3b7b3f14f Update README 2019-11-28 18:52:45 +00:00
Josh Johnson 3d099d85fc Update README 2019-11-28 18:06:33 +00:00
Josh Johnson 9676cff128
Resolve #622 and #781 (#784)
* Resolve duplicate initialise in demo

* Update README with versioned cdn links

* Update log

* Re-add env var
2019-11-27 11:46:40 +00:00
Josh Johnson 47aba515fb
Add fetch to polyfill bundle on the demo page (#783) 2019-11-26 16:59:16 +00:00
Josh Johnson 62e849d1b4
Resolve 774 (#777)
* Include customProperties in removeItem

* Add tests

* Housekeeping

* Update mac vm label

* Add .nvmrc
2019-11-24 17:32:02 +00:00
Josh Johnson d116f95c54 Update issue templates 2019-11-23 22:41:44 +00:00
GitHub Action 6215ca5e59 Update build files 🏗 2019-11-22 19:13:46 +00:00
Josh Johnson 67266a3aae
Resolve #762 (#767)
* Update value with character value

* Remove .only

* Lowercase character before updating value

* Add cypress tests covering change

* Update logic to affect both select inputs

* Update cypress

* Emphasise remove button focus

* Text change

* Revert "Update cypress"

This reverts commit 81e406de85.

* Remove false positive tests
2019-11-22 19:09:45 +00:00
GitHub Action 85f0b5f9be Update build files 🏗 2019-11-19 18:38:17 +00:00
Josh Johnson 592c326442
Update polyfill list (#765)
* Update polyfill list

* Update eslintrc.json

* Add keydown methods to types

* Resolve type issue
2019-11-19 18:34:08 +00:00
GitHub Action 214b6e80df Update build files 🏗 2019-11-18 09:55:07 +00:00
Josh Johnson 9f2661023d
Next release (#763)
* 🔖 Version 9.0.1

* Remove post version check
2019-11-18 09:51:24 +00:00
GitHub Action d2516e7de3 Update build files 🏗 2019-11-17 12:38:39 +00:00
Kazuki Nishikawa 0e8e42e015 Fix #573 (#574)
* add specs

* fix to restore preset choices after destroy

* avoid to modify `this.config.choices` directly

* Update cypress/integration/select-one.spec.js

Co-Authored-By: Josh Johnson <josh@joshuajohnson.co.uk>

* Update public/test/select-one.html

Co-Authored-By: Josh Johnson <josh@joshuajohnson.co.uk>

* Update public/test/select-one.html

Co-Authored-By: Josh Johnson <josh@joshuajohnson.co.uk>

* Update public/test/select-one.html

Co-Authored-By: Josh Johnson <josh@joshuajohnson.co.uk>

* Update public/test/select-one.html

Co-Authored-By: Josh Johnson <josh@joshuajohnson.co.uk>

* fix specs

* restoring passed element initial options

 - Save `passedElement.options` values as `this._presetOptions`
 - Restore saved `this._presetOptions` to `passedElement.options` on `destroy`
 - It avoids restoring options in `this.config.choices`

* Update cypress/integration/select-one.spec.js

Co-Authored-By: Josh Johnson <josh@joshuajohnson.co.uk>

* Update cypress/integration/select-one.spec.js

Co-Authored-By: Josh Johnson <josh@joshuajohnson.co.uk>

* Update public/test/select-one.html

Co-Authored-By: Josh Johnson <josh@joshuajohnson.co.uk>

* move preset options assignment statement
2019-11-17 12:34:34 +00:00
Josh Johnson e7b4afd472
Fix releases (#761)
* Testing

* Re add "needs" flags

* Further testing

* Add skip husky install flag

* Revert "on" flag
2019-11-15 19:34:20 +00:00
GitHub Action 952b3fc146 Update build files 🏗 2019-11-14 23:06:48 +00:00
Josh Johnson 760f39dbf3 Remove "needs" from deployment.yaml 2019-11-14 23:03:03 +00:00
Josh Johnson 573c840de4 Fix deployment.yml 2019-11-14 23:00:06 +00:00
Josh Johnson 44da784f29
🔖 Version 9.0.0 (#758) 2019-11-14 22:51:50 +00:00
agamemnus 6be462c80b Typo. (#759) 2019-11-14 20:34:05 +00:00
Josh Johnson e67b8a3e4c
Commit and push built files to master (#756)
* Commit and push built files to master

* Testing...

* Add  name

* Add fallback

* Revert back to master branch
2019-11-14 09:47:20 +00:00
Josh Johnson 933ea6093f
Remove redundant check (#755)
* Remove redundant check

* Add integration tests covering fix

* Add missing test
2019-11-13 15:40:47 +00:00
Josh Johnson 84b952e115
Resolve bug #637 (#754)
* Add is-selected class when item is selected

* Remove console.log

* Update README
2019-11-13 14:49:23 +00:00
Chris DeLuca f745be449d Always hide remove button if no value is selected (#744)
In some cases, the remove item X button is not hidden when there is no
selection made from the dropdown. This is not as usable, since there's
no item to clear, hence an effective noop.

The condition I saw seeing this issue arise is in single selects with
a placeholder value, a selection has been made, and then cleared: the
button HTML remains.

To fix, add some styles to hide the button if the select doesn't have a
value selected, in this case keying off of it's parents `data-value`
property.

fixes #684
2019-11-12 12:29:34 +00:00
Konstantin Vyatkin 8775bacdd9 improve whole-page performance by scoping events handlers (#740)
* scope onMouseDown event capture

* supercedes #710

* make isIE11 a const

* scope keydown

* scope mouseover

* fix removeEventListener for keyup
2019-11-12 09:47:41 +00:00
Oleg Dmitrochenko fb2310cb56 Indent fixed in "choices__list--dropdown" (#750)
Indent fixed in "choices__list--dropdown". Added "box-sizing: border-box;".
2019-11-12 09:03:04 +00:00
Konstantin Vyatkin 68322d9528 Upgrade Cypress to 3.6 and use cache in Github Actions (#748)
* try to cache cypress cache

* try to fix

* try cache hit

* Upgrade Cypress to 3.6

* remove uneeded prefix
2019-11-08 13:24:57 +00:00
Josh Johnson d04031e02f
Fix id types (#743)
* Set ids to be numbers

* Split out _setLoading into start/stop methods

* Build
2019-11-08 09:19:18 +00:00
Konstantin Vyatkin 7dcc155b8f remove safari test, update snapshots for new macOS, use dependency caching (#745)
* remove safari test

* add node modules caching

* update macos snapshots

* try to fix caching

* try like this

* cache .npm

* adjust cache keys
2019-11-08 07:48:29 +00:00
Josh Johnson b5b593a62f
Resolve bug 473 (#739)
* Fix #473

* Add tests

* Tweak cypress tests

* Build
2019-11-07 08:50:19 +00:00
Konstantin Vyatkin 81c44ba8f2 Enable test on Safari (#737)
* Enable test on Safari

* fix platform name

* update base Safari snapshot
2019-11-04 13:17:45 +00:00
Josh Johnson f30b976424
Resolve bug 533 (#736)
* Add placeholder options to demo page

* Use constant types in components

* Refactor adding predefined groups/items/choices

* Add 'highlighted' flag to Item type

* Fix dispatch param type

* Build

* Add jsdoc comments to utils

* Remove unused file

* Add default values to js doc comments

* Use Redux Action type

* Housekeeping

* Increase utils coverage

* Apply suggestions from code review

* Add _getTemplate unit tests

* Resolve #533

* Add tests
2019-11-03 18:12:47 +00:00
Josh Johnson ab22347d7b
Code refactoring (#735)
* Add placeholder options to demo page

* Use constant types in components

* Refactor adding predefined groups/items/choices

* Add 'highlighted' flag to Item type

* Fix dispatch param type

* Build

* Add jsdoc comments to utils

* Remove unused file

* Add default values to js doc comments

* Use Redux Action type

* Housekeeping

* Increase utils coverage

* Apply suggestions from code review

* Add _getTemplate unit tests
2019-11-03 17:45:16 +00:00
Josh Johnson e6882f3e4b
Add missing type definitions + rename sortFn (#734)
* Add wrapped element getters + fix some types

* Remove comment

* Add missing config options to types

* Add types to constants

* Rename sortFn to sorter

* Update PR template

* Add refactor to PR template

* Add passed element types to constants

* Add js doc comments to actions

* Add "returns" to js doc comments

* Add missing choice prop to type

* Add types to store.js

* Add jsdoc comments to components

* Ignore strict null checks

* Move loading action into misc.js

* Further type def additions

* Rename itemCompare to valueCompare

* Update badges

* Rename scrollToChoice to scrollToChildElement
2019-11-03 13:18:16 +00:00
Josh Johnson 452c8fa666 Fix release drafter 2019-11-02 14:03:27 +00:00
Josh Johnson a0fe05f926
Fix #727 (#731)
* Housekeeping

* Resolve placeholder bug + hide from choice list

* Restructure test folder

* Update cypress test to assert one placeholder

* Fix breaking e2e test

* Remove ability to pass placeholder via config for select boxes

* Add further e2e tests covering placeholders

* Add unit tests for _generatePlaceholderValue

* Display placeholder choice for select one

* Add further e2e test to assert on placeholder ordering

* Add labels to exclude from draft releases

* Add failure case to e2e test workflow

* Resolve broken e2e test

* Update puppeteer snapshot baseline
2019-11-02 13:49:33 +00:00
Konstantin Vyatkin 939a73b762 fix setChoices flow (#730)
* fix setChoices flow

* ignore Promise as it gate checked

* re-run cypress
2019-11-02 12:58:18 +00:00
Konstantin Vyatkin 68f6b8e398 [bug] Override Prettier settings for Demo page (#733)
* add prettier override

* run prettier
2019-11-02 11:19:09 +00:00
Konstantin Vyatkin dddba5b35b [TEST] Automatic screenshots comparing and error checking in IE11, Firefox and Chrome (#715)
* taking screenshots

* let's try

* save artifacts

* better exceptiosn

* try to install geskodriver

* fix edge name

* add check for safari

* check os

* try this

* again

* fix syntax

* try this

* try firefox on windows

* and again

* handle error

* and again

* try older macos

* add firefox screenshot

* switch back env

* switch back env

* add IE screenshot

* try sudo for safari

* try not install nuget

* try more

* more

* try this

* install firefox

* add chrome

* increase threshold

* add firefox-darwin

* push

* fixing

* let's go

* increase threeshold

* again

* try safari tp

* tap cask versions

* fix conditions

* try like this

* last run

* increase threshold

* reenable macos firefox

* last try for safari

* rename screenshots to snapshots

* check console

* console workarounds

* fix safari misspleings

* logging is not supported by everyone

* maximize and set rect

* errors only for Chrome

* remove safari for now

* try to decrease threshold

* cleanup

* increase threeshold

* sleep more and increase threeshold

* add pupeeter

* handle errors

* build

* add prettier end of line

* add gitattributes

* add png to binary

* more attributest

* limit run

* run on chages to snapshots

* hey!

* make artifacts named as snapshots

* just for fun: we don't need express here

* update pupeeter snapshot

* no audit

* don't wait for quit?

* try more IE capabilities

* add wait timeout

* use server.js
2019-11-02 11:18:19 +00:00
Konstantin Vyatkin 5afe8b5a7f speed up getAdjacentEl (#726)
* use element accessors

* don't change params
2019-10-31 17:49:27 +00:00
Josh Johnson 9e11db8181
Add documentation label + headings (#729) 2019-10-31 17:40:02 +00:00
Josh Johnson 00e53f76ee
Update GitHub action workflows (#728)
* Deploy on published release

* Run build and test on merge to master

* Update release drafter template

* Update title of releases

* Testing cypress fix

* Pass group to --group flag
2019-10-31 17:28:12 +00:00
Konstantin Vyatkin 5051bf1b10 Fix lint (#723)
* adjust eslint config

* run prettier

* limit cypress run

* add all cypress files
2019-10-31 12:11:46 +00:00
Konstantin Vyatkin 034191c78a use CSS queries (#718)
* use matchMedia

* use last-of-type

* better type check

* simplify distanceFromTopWindow

* use visibility

* update JSDoc
2019-10-30 17:28:15 +00:00
Josh Johnson c03fcf5d03
Store config in file (#722) 2019-10-30 13:19:34 +00:00
Josh Johnson eb17194ff3
Add release drafter (#720)
* Add release management github action

* Simplify PR template

* Add chore to PR template

* Simplify labels

* Add housekeeping label

* Add refactor label
2019-10-30 13:10:52 +00:00
Josh Johnson 0e44a916e3
Fix constructor (#693)
* breaking test

* Remove ablity to pass multiple elements + tests

* Update readme

* Update README.md

* 🔖 Version 8.0.0

* Remove type definition hack

* Update coverage command

* Add some missing list tests

* Remove .only

* Update demo page to loop over elements

* Update constructor to set initialised flag if already active

* Make templates private

* Throw type error once if element is invalid

* Fix list children bug

* Re-add generic examples to index.html

* Housekeeping

* Use typeof instead of isType where applicable

* Remove isElement

* Add test for isIE11
2019-10-29 21:19:56 +00:00
Josh Johnson 88f63faa0b
Update code styling rules (#713)
* Enforce curly braces around conditionals

* Install sort class members + update rules

* Satisfy linting changes

* Add todo

* Add tests for clearChoices

* Update eslint-plugin-prettier to latest

* Resolve conflicts

* Fix linting errors
2019-10-29 18:26:11 +00:00
Konstantin Vyatkin 172366d6fa [Tooling] Expand browsers target while keeping Polyfills under control (#709)
* expand browsers target

* add eslint-plugin-compat

* sort polyfils

* adjust readme

* add polyfills sync check action

* only build js

* trim

* add Element.prototype.closest

* add closest to demo links

* fix ignore
2019-10-29 18:19:19 +00:00
Konstantin Vyatkin e3cc6eaf1b [MAJOR] Remove .ajax and allow async function for .setChoices (#701)
* WIP: remove ajax

* copy #700

* remove ajax, add fetchChoices

* extend setChoices

* update README
2019-10-29 18:12:32 +00:00
Konstantin Vyatkin 1f5192b4ad remove delegateEvents (#703) 2019-10-29 17:46:10 +00:00
Konstantin Vyatkin 2e004015d5 fix preventPaste (#707)
* what is preventPaste?

* fix preventPaste
2019-10-29 17:35:20 +00:00
Konstantin Vyatkin b080bcda7d rename addItemFilterFn (#699) 2019-10-29 17:29:31 +00:00
Konstantin Vyatkin 2a03d9be12 don't reemplement localeCompare (#695) 2019-10-29 17:09:49 +00:00
Tadeusz Wawszczak 2b8acc5f37 add clearChoices typings (#717) 2019-10-29 17:07:22 +00:00
Konstantin Vyatkin 9504cfcec5 [MAJOR] expose defaults and original Template rendering functions (#708)
* expose original Template rendering functions

* add to types

* add moduleResolution

* use `defaults`
2019-10-29 15:13:00 +00:00
Konstantin Vyatkin 1c751472b2 [Tooling] Transpile tests targeting Node, not browser (#700)
* transplite tests for higher target

* fix test

* add to lint-stagged too
2019-10-29 14:05:37 +00:00
Konstantin Vyatkin b48395ce36 fix dir (#711) 2019-10-29 14:02:24 +00:00
Konstantin Vyatkin a2485392a5 don't reimplement native closest (#696) 2019-10-28 20:26:19 +00:00
Josh Johnson 50fae125ed
Resolve on save vscode conflict (#714) 2019-10-28 20:26:03 +00:00
Josh Johnson 264a0cb486 Build 2019-10-28 19:53:24 +00:00
Konstantin Vyatkin 92d5e49fb6 [Tooling] VSCode Debug configurations and project settings (#705)
* configure tasks

* configure VSCode debugging

* adjust VSCode project settings

* fix bdd

* fix cypress path on macos/linux

* enforce checkJs

* make buildAndWatch default build task

* recommend and configure mocha-sidebar

* tune settings
2019-10-28 19:43:21 +00:00
Konstantin Vyatkin 64407174e3 closes #587 (#704) 2019-10-28 19:33:27 +00:00
Konstantin Vyatkin dbd15d7823 don't calculate pixel width (#694) 2019-10-28 19:27:10 +00:00
Konstantin Vyatkin 99f945bc03 raf is supported natively by JSDOM (#706) 2019-10-27 20:18:59 +00:00
Konstantin Vyatkin 312569a734 make hidden important (#702) 2019-10-27 20:17:30 +00:00
Konstantin Vyatkin 15d54c7d34 Remove classnames and use createElement (#687)
* enable restricted syntax in tests

* add Options to global

* crearte native elements

* remove unused helper

* fix/improve typings

* add JSDoc typings

* remove if/else
2019-10-25 15:43:28 +01:00
Konstantin Vyatkin ef2c70fb7a use default parameters (#698)
* use default parameters

* Fix argument name in README
2019-10-25 13:21:38 +01:00
Konstantin Vyatkin 69582349bb remove redundant CSS (#697)
* remove redundant CSS

* fix error with lack of test for false

* destruct dataset

* fix typo
2019-10-25 13:09:27 +01:00
Konstantin Vyatkin bef6743c3b set window target for minified build (#685)
* set `globalObject` option

* commit builded assets

* set window target for minified build
2019-10-24 18:21:40 +01:00
Konstantin Vyatkin 472e0dff39 [Tooling] use lint-stagged and unleash full Prettier (#692)
* switch to lint-stagged

* separate prettier config into external file

* recommend and configure VSCode extensions
2019-10-24 18:13:06 +01:00
Konstantin Vyatkin 7887c05249 [MAJOR] use attribute hidden (#691)
* use attribute hidden

* commit something to re-run tests
2019-10-24 18:09:44 +01:00
Josh Johnson 9bb0c628b2
Add deploy to gh pages action (#690) 2019-10-24 17:20:57 +01:00
Konstantin Vyatkin a35c8b9009 Fixing typings (again 🤷🏼‍♂️) + test for them (#682)
* add index notation

* add types check
2019-10-24 12:02:34 +01:00
Konstantin Vyatkin 1dbab0f29e upgrade Cypress to 3.5 (#686) 2019-10-24 07:50:00 +01:00
Konstantin Vyatkin e83f40956b fix typings (#681)
* fix typings

* allow array in constructor
2019-10-23 19:11:22 +01:00
Josh Johnson dc7cf42e90
Ignore branches that are not master (#678)
* Ignore branches that are not master

* List branches and ignored branches

* Remove tags check from npm publish instead

* 🔖 Version 7.1.5
2019-10-23 11:01:05 +01:00
Josh Johnson 4c6acb5de2
Further ci tweaks (#677)
* Align codecov actions

* Update post version command to include tag

* 🔖 Version 7.1.4
2019-10-23 10:27:53 +01:00
Josh Johnson 7e38f83b9e
Further ci tweaks (#676)
* Align codecov actions

* Remove preversion

* Remove npm conditional

* 🔖 Version 7.1.3
2019-10-23 10:00:14 +01:00
Josh Johnson 71e64e0f52
Further CI tweaks + vulnerability fix (#675)
* Update workflow job names

* Update csso-cli

* Add conditional to publish-npm

* 🔖 Version 7.1.2
2019-10-23 09:32:25 +01:00
Konstantin Vyatkin 4b9dd1efe3 Remove unused devDependencies (#673)
* remove `opn`

* remove `whatwg-fetch`

* remove `wrapper-webpack-plugin` in favor of built-in plugin
2019-10-23 08:45:49 +01:00
Konstantin Vyatkin 4acd6d6ca8 Improve GitHub actions and fix package.json SCSS script (#669)
* run actions on dependencies change

* add bundlesize token to master run

* fix bundlesize commit number

* add cypress env

* also run on - '.browserslistrc' changes

* update node-sass to allow install on Node 12 and trigger events

* use script

* add group

* skip husky on cypress

* upgrade csso dependency to make it trim sourcemaps

* fix run-p / run-s use

* remove commited assets on check

* commit assets

* remove cypress record

* restore recording

* reduce bundlesize limits

* try to specify key implicity

* remove Cypress recording

* restore build in bundlesize

* regenerate package-json.lock

* commit generated assets

* handle no-js case in lint

* fix lint error
2019-10-22 22:20:40 +01:00
Konstantin Vyatkin 6848970fd9 improve Babel and webpack configurations --> reduce JS bundle size (#670)
* simplify babel config

* fix Cypress VSCode checks

* introduce webpack base config

* fix flacky cypress test

* fix class properties definition

* fix default export

* upgrade affected deps, decrease bundlesize

* run ESLint only on changed files
2019-10-22 17:08:43 +01:00
Josh Johnson 00bf028904 Update typo 2019-10-22 12:57:57 +01:00
Josh Johnson 1285602b2f
Publish version after npm publish (#672)
* Add publish to github step

* Include file with release

* Supress logs if silent mode = true

* 🔖 Version 7.1.1

* Rejig console logs

* Update error log conditional
2019-10-22 12:50:40 +01:00
Christophe Coevoet 8782564ddf Add support for standard-compliant placeholder option (#617)
* Add support for standard-compliant placeholder option

* Bump version and rebuild files
2019-10-22 11:25:36 +01:00
Josh Johnson 4de6e677d1
Fix css minifying (#671)
* Remove source maps from outputted CSS

* 🔖 Version 7.0.6
2019-10-22 07:02:48 +01:00
dependabot[bot] 2fca709814 Bump lodash-es from 4.17.8 to 4.17.15 (#665)
Bumps [lodash-es](https://github.com/lodash/lodash) from 4.17.8 to 4.17.15.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/commits/4.17.15)

Signed-off-by: dependabot[bot] <support@github.com>
2019-10-21 21:44:14 +01:00
Josh Johnson ffc32df462
Resolve vulnerabilities + fix tests (#668)
* Remove GPR Github action (for now)

* Update test badge

* Remove stale.yml

* Upgrade cypress + fix failing tests

* Upgrade postcss-cli

* Update postcss command

* Remove space

* Add slight delay between scrolling animations

* Update test descriptions

* Remove signed commits/tagging (for now)

* chore(release): 🔖 version 7.0.5

* Update commit message

* Revert "Upgrade cypress + fix failing tests"

This reverts commit b6fbd0f51a.
2019-10-21 21:43:38 +01:00
Josh Johnson f597bc9aff
Remove travis (#667)
* Remove travis.yml

* Remove versioning from index file

* Resolve linting issues

* Resolve further linting issues

* Uppercase NPM_TOKEN

* Run audit fix

* Update postversion command

* Update @babel/core to latest

* Update post version command

* Housekeeping

* Revert cypress upgrade

* Enforce cypress version

* Update package.lock

* Add cypress project id
2019-10-21 20:03:57 +01:00
Konstantin Vyatkin bc8a044ab1 Chore: Use GitHub actions (#661)
* run cypress on github action

* add lint action

* add test and coverage action

* upgrade testing dependencies

* upgrade linting dependencies

* add bundlesize action

* fix env name, prevent husky

* add npm publish step

* upgrade cypress to latest non-breaking version

* fix postversion script

* don't share full token with bundlesize

* nicer version commit

* add preversion script, use `--atomic` and don't publish tests

* enforce tagged and signed version

* restored bump-cache
2019-10-21 17:20:39 +01:00
Benoît Rouleau 31ef5bb065 Improve callbackOnCreateTemplates example (#647)
Shows how to add the placeholder class(es) when the item is the placeholder.
2019-10-21 10:51:53 +01:00
Konstantin Vyatkin 7de0887e7d use templates from instance, fixes #461 (#660)
* use template from instance

* adjust test

* fix lint

* try to move `this` out of loop

* fixes late init bound
2019-10-21 10:48:49 +01:00
Josh Johnson 4e8842d013 Build 2019-10-15 09:50:12 +01:00
Josh Johnson b8074733c9 7.0.2 2019-10-15 09:49:42 +01:00
Josh Johnson 98206e899d Build 2019-10-15 09:49:38 +01:00
Josh Johnson 659c3545fb Bump demo version 2019-10-15 09:47:00 +01:00
Josh Johnson 97f91c240c Remove github actions 2019-10-15 09:33:19 +01:00
Josh Johnson 7022c238fd Add build and test stage 2019-10-15 09:01:31 +01:00
Josh Johnson bbeb556a48 Lower version to 10 in npmpublish 2019-10-15 08:57:39 +01:00
Josh Johnson bb0736e8fc
Update npmpublish.yml 2019-10-15 08:53:50 +01:00
Josh Johnson b8f5bd1680 7.0.1 2019-10-15 08:50:23 +01:00
Josh Johnson 6c1e02fa82
Update npmpublish.yml 2019-10-15 08:49:06 +01:00
Josh Johnson f872caf1f8
Update npmpublish.yml (#654) 2019-10-15 08:47:20 +01:00
Josh Johnson 585859f4cd
Update and rename .github/workflows/npmpublish.yml to npmpublish.yml 2019-10-15 08:46:34 +01:00
Chris DeLuca e7d775e2ae Use event delegation (#644)
Instead of attaching a new root-level event listener for bubbling events
for every choices instance, use a simple event delegation script to
handle each event type.

Each event callback function already is coded as if it were fully
delegated, since the events are attached at the document level, so
no changes are needed to detect which element is being called.

Note that focus and blur event do not bubble, so they have been left as
they are.

Also note that the event delegation uses an IIFE purposely instead of
ES6 modules, since the event list should be globally cached, and it
doesn't make sense to instantiate a new scope for each instance (then
we're back where we started!)

fix #643
2019-10-15 08:42:31 +01:00
bradwade 5cf226f166 ADA accessibility label fixes (#642)
* Update incorrect 'label-for' in demo index.html file.

* Use placeholder value for search input aria label.

* Updated input template test.

* Adding the compiled, uglified JS.
2019-10-10 09:49:00 +01:00
Tomakava 37db45e651 fix unhighlightAll performance issue (#648) 2019-10-03 09:41:53 +01:00
Josh Johnson 57807e88f6 Resolving broken CI 2019-10-02 09:13:08 +01:00
Duane Cilliers 589578f420 Fix types on Templates interface function signatures (#619)
* Fix types on Templates interface method signatures

* Add missing type fixes
2019-10-02 09:08:34 +01:00
Alex Webb 39b6eed395 Resolve issue in utils::calcWidthOfInput() (#608) 2019-10-02 09:03:38 +01:00
Dieter Luypaert 061219cb00 Add type info for choice, group, and item (#609)
Refs: 551
2019-07-03 10:43:57 +01:00
Jason Cooke 62ccd923ff docs: fix typos (#605) 2019-06-30 20:02:52 +01:00
David Kennell 43e670d02d fix typo (#596) 2019-05-28 18:52:26 +01:00
Josh Johnson 0829899284
Update stale.yml 2019-05-21 13:13:08 +01:00
Josh Johnson 7540d39f95 Merge branch 'stof-remove_polyfill' 2019-03-29 09:13:10 +00:00
Josh Johnson 67382a3f31 Use v3 of polyfill 2019-03-29 09:12:29 +00:00
Josh Johnson 899e4b16bb Merge branch 'DarrenMack-OD-master' 2019-03-29 09:09:27 +00:00
Josh Johnson 63e5b51683 Update polyfill url 2019-03-29 09:08:42 +00:00
Josh Johnson 3c05016920 Merge branch 'master' of https://github.com/DarrenMack-OD/Choices into DarrenMack-OD-master 2019-03-29 08:57:38 +00:00
Josh Johnson 0580a0433f 7.0.0 2019-03-29 08:56:12 +00:00
Josh Johnson fee575d6d9 Merge branch 'Spone-improve-clear-choices' 2019-03-29 08:56:05 +00:00
Darren Mackintosh b08a5412f9
Update text.html 2019-03-15 17:18:58 +00:00
Darren Mackintosh f32995367b
Update select-one.html 2019-03-15 17:18:23 +00:00
Darren Mackintosh 201b3c8ada
Updated version numbers 2019-03-15 17:17:43 +00:00
Darren Mackintosh 9c021408fa
Update choices.test.js 2019-03-15 16:57:57 +00:00
Darren Mackintosh aceb838988
Rolled back webpack changes in Choices.js 2019-03-15 16:57:35 +00:00
Darren Mackintosh 03a45094b7
Update index.test.js 2019-03-14 12:31:29 +00:00
Darren Mackintosh 92680c0dc0
Update index.js 2019-03-14 12:20:43 +00:00
Darren Mackintosh da87fa07cf
Update choices.test.js 2019-03-14 12:13:06 +00:00
Darren Mackintosh 2247eff08a
Added linting exclusion for WebPack 2019-03-14 12:03:22 +00:00
Darren Mackintosh 5018e4a7d4
Updated reference to choices
Because I have attempted to fix the WebPack issue with choices, I need to change how it is referenced
2019-03-14 11:47:11 +00:00
Darren Mackintosh cc32284e8a
Updated reference to choices
Because I have attempted to fix the WebPack issue with choices, I need to change how it is referenced
2019-03-14 11:46:39 +00:00
Darren Mackintosh b1005061ff
Changed reference to Choices
Because I have attempted to fix the WebPack issue with choices, I need to change how it is referenced
2019-03-14 11:44:46 +00:00
Darren Mackintosh 6486bbbd6d
Updated tests to reflect changes to choices.js 2019-03-14 11:23:57 +00:00
Darren Mackintosh f9f63e7aba
Fix for the webpack issue
export choices as a class to circumvent the webpack issue
2019-03-14 11:23:12 +00:00
Hans Lemuet 5c17250e20
Allow passing an empty array to setChoices 2019-03-13 10:34:06 +01:00
Hans Lemuet fc9bca2ece
Rename _clearChoices to clearChoices 2019-03-13 10:05:38 +01:00
Darren Mackintosh 2fa92520ef
Updated Choices.js
Fixes scrollbar issue in IE11. There is an EDGE-CASE where-by if a user were to select the same option twice, the dropdown doesn't go away. This is, however a very extreme case and we are on the right track
2019-03-12 20:27:54 +00:00
Josh Johnson bbbc31594c
Update README.md 2019-03-11 12:19:52 +00:00
Christophe Coevoet 56845e3897 Remove the CustomEvent polyfill from the bundle 2019-02-28 11:51:04 +01:00
Josh Johnson 9bebf2e99e
Resolve compiling problem (#532)
* Specify exact fuse version

* 6.0.3

* Version 6.0.3
2019-02-26 12:20:52 +00:00
Josh Johnson 4d1c3cd2ae Version 6.0.2 2019-02-22 22:06:59 +00:00
Josh Johnson e8b96b0a6e 6.0.2 2019-02-22 22:05:58 +00:00
Josh Johnson 879c97f64c
Resolve undefined error (#528)
* Remove run-p from test command

* Remove dropdown interaction tests

* Tidy utils

* Use merge lib

* Remove string casting

* Sanitise in constants

* Housekeeping

* Add non-string value tests
2019-02-22 22:04:55 +00:00
Josh Johnson 5d4d3be1b5 Version 6.0.1 2019-02-19 09:02:48 +00:00
Josh Johnson a99547c2f4 6.0.1 2019-02-19 09:01:31 +00:00
Josh Johnson a846534ffb Upgrade fuse.js 2019-02-19 09:00:45 +00:00
Josh Johnson efaf8f8aae Remove build and release from travis 2019-02-19 09:00:09 +00:00
Hans Lemuet c424ae2f3b Fix #499 documentation error about passedElement (#517) 2019-02-14 08:34:44 +00:00
Josh Johnson 22e1884ad4 Remove building for publish stage 2019-02-12 18:37:59 +00:00
Josh Johnson 0cf05f4eff Version 6.0.0 2019-02-12 18:37:04 +00:00
Josh Johnson 31f9d33327 6.0.0 2019-02-12 18:36:46 +00:00
Josh Johnson 8540d5aabd
Api changes (#515)
* Combine regexFilter and addItemFilter + minor tweaks

* Update tests to accomodate fixed dropdown notice

* Remove broken `toggleDropdown` method

* Unskip dropdown interaction tests

* Remove reference to removed method
2019-02-12 18:35:46 +00:00
Josh Johnson 55b356ec69
Add travis pipeline (#516)
* Update travis.yml

* Simplify ci pipeline

* Include css in bundle size check

* Set npm username via env var

* Specify branches

* Add build scripts

* Consistent ifs

* Add linting stage to pipeline

* Cache npm

* Cache cypress & npm folders + install using ci method

* Unignore package-lock
2019-02-12 18:04:50 +00:00
Glade ba09fb00e6 callback to filter items before adding (#485)
* Add item custom callback

* Minor unit test updates

* Test updates, Changed callback name to more clearly distinguish it's function

* Fix description wording in cypress

* Update README

* Updated filter item callback name to be addItemFilter
2019-02-11 22:56:21 +00:00
Josh Johnson 23e5e7674f Tweak doc page 2019-02-11 21:47:47 +00:00
Josh Johnson 7091daa0d1 Merge branch 'julian-kuroiwa-add-custom-properties-options' 2019-02-11 21:46:56 +00:00
Guilherme de Oliveira Costa 71a3131d3c Added custom properties to options
Added custom properties to options to be searchable on select.
2019-02-11 16:05:59 -02:00
Josh Johnson caed692440 Version 5.0.0 2019-02-09 18:14:16 +00:00
Josh Johnson c36f76460c 5.0.0 2019-02-09 18:13:49 +00:00
Josh Johnson 5c9dfdf2db
Upgrade old packages (#508)
* Upgrade Webpack to v4

* Upgrade Mocha

* Export unminfied and minified version

* Add browserslistrc

* Remove core.js polyfills

* Run bundle size on pre push

* Run bundlesize last

* Update readme gzip side
2019-02-09 18:13:25 +00:00
Josh Johnson 2f873167f6 Increase stale thresholds 2019-02-04 08:45:21 +00:00
Josh Johnson 437651411f
Fix render blocking (#456)
* Reapply changes from PR #310

* Version 4.1.1

* Update action name

* Update test

* Resolved broken test
2019-01-26 12:36:47 +00:00
Josh Johnson 6c3bad777d
Add bundlesize (#502)
* Configure bundlesize

* Update travis script

* Remove node modules cache

* Run bundlesize as after script

* Remove duplicate coverage check

* Remove test:size from test command
2019-01-24 23:21:00 +00:00
Josh Johnson d02cdffcdb Version 4.1.4 2019-01-24 19:42:26 +00:00
Josh Johnson dc9e7eb44d 4.1.4 2019-01-24 19:41:28 +00:00
Josh Johnson 5c30a1f0de Upgrade cypress 2019-01-24 19:38:17 +00:00
Jeremy Hou 48b74a91bc fixes the 'invalid input type' check (#498) 2019-01-21 08:46:14 +00:00
Jeremy Hou 9c001487ba Fixes an issue where deepmerge concatenates array configs (#496) 2019-01-19 14:47:22 +00:00
Josh Johnson 826384b9d5
Fix set choice by value bug (#471)
* Resolve bug with setChoiceByValue not removing choice from dropdown

* 4.1.3

* Version 4.1.3
2018-11-25 12:48:49 +00:00
Josh Johnson 16e16a181c Remove redundant file 2018-11-24 18:13:00 +00:00
Josh Johnson 490a2bb37b Version 4.1.2 2018-11-24 18:09:51 +00:00
Josh Johnson 35d8b6f603 4.1.2 2018-11-24 18:08:57 +00:00
Josh Johnson 24d6aea68f Version 1.1.1 2018-11-24 17:49:14 +00:00
Josh Johnson c3e46e55aa
Fix form submission bug in firefox (#470)
* Fix form submission bug in firefox

* 4.1.1
2018-11-24 17:48:03 +00:00
Limon Monte bded79386f Add the "files" section to package.json (#469) 2018-11-24 13:40:51 +00:00
Andrey Nering 367fee6885 README: Fix CDN URLs (#465)
Thanks 👍
2018-11-22 22:35:43 +00:00
Josh Johnson 3182c7f2c2 Add enabling/disabling e2e tests 2018-11-09 08:38:12 +00:00
Josh Johnson 28f36bf6f5 Remove base path from package.json 2018-11-07 18:49:09 +00:00
Josh Johnson 3431d03ef0 Version 4.1.0 2018-11-03 13:25:58 +00:00
Josh Johnson cd4454201b 4.1.0 2018-11-03 13:25:30 +00:00
Josh Johnson 496db95153 Disable input when loading remote data 2018-11-03 13:24:52 +00:00
Josh Johnson 307881a068 Update documentation 2018-11-03 12:42:42 +00:00
Josh Johnson f3c0abef95 Add e2e tests to interact with dropdown 2018-11-03 12:26:02 +00:00
Josh Johnson 90a92656be Add custom property tests 2018-11-03 12:00:37 +00:00
Josh Johnson cd165deb3c Version 4.0.6 2018-10-30 22:10:21 +00:00
Josh Johnson 6f2bf5770b 4.0.6 2018-10-30 22:09:25 +00:00
Josh Johnson feb2a15edc Disable at a later stage of intialising 2018-10-30 22:04:08 +00:00
Josh Johnson 2292b5282f Test for class instead of visibility 2018-10-30 21:44:58 +00:00
Josh Johnson d657b17568 Urghh CI 2018-10-30 21:33:35 +00:00
Josh Johnson 5fe6e18077 Remove unnecessary beforeEachs 2018-10-30 21:21:11 +00:00
Josh Johnson bd674b5bdf Add further test delays 2018-10-30 21:11:45 +00:00
Josh Johnson 8d11eae895 Add slight delay for dropdown assertion 2018-10-30 21:05:16 +00:00
Josh Johnson c9d86fd826 Inverse dropdown test 2018-10-30 20:52:10 +00:00
Josh Johnson 0010afa109 Remove unnecessary test 2018-10-30 20:40:06 +00:00
Josh Johnson 8d1aa239ac Version 4.0.5 2018-10-30 20:29:22 +00:00
Josh Johnson 6192ebd5db 4.0.5 2018-10-30 20:28:59 +00:00
Josh Johnson b0f3b28ef4 Do not open dropdown if element is disabled 2018-10-30 20:28:40 +00:00
Josh Johnson 798b49d565 Disable element if disabled attr passed 2018-10-30 20:21:52 +00:00
Josh Johnson 139a756ef9 Update deploy script name 2018-10-30 19:22:01 +00:00
Josh Johnson 11e9719bbb Version 4.0.4 2018-10-30 19:21:07 +00:00
Josh Johnson 4d87fa6532 4.0.4 2018-10-30 19:20:21 +00:00
Josh Johnson 7e4347b183 Resolve issue with Firefox not selecting choices via enter key 2018-10-30 19:20:16 +00:00
Josh Johnson bd44abb629 Version 4.0.3 2018-10-30 08:40:48 +00:00
Josh Johnson 293eed2091 4.0.3 2018-10-30 08:40:15 +00:00
zackschuster 3e0246f2f2 Fix types (#452) 2018-10-30 08:36:52 +00:00
Josh Johnson ff08408c84 Update README 2018-10-28 11:18:35 +00:00
Josh Johnson 2288d47672 Update CDN badge 2018-10-28 11:17:08 +00:00
Josh Johnson 728b570e57 Woops 2018-10-28 11:15:49 +00:00
Josh Johnson 58a3d66cd3 Update CDN links 2018-10-28 11:13:43 +00:00
Josh Johnson d14f1c503f Update stale.yaml file config 2018-10-28 10:58:18 +00:00
Josh Johnson 88a2bc1b7c Update npmFileMap 2018-10-28 10:51:47 +00:00
Josh Johnson 5587ec6063 Add PR template 2018-10-28 10:38:17 +00:00
Josh Johnson 9a14daedc3 Tweak version script to update to current npm version 2018-10-28 09:59:30 +00:00
Josh Johnson e060ceaad4 Prevent test directory being indexed 2018-10-28 09:40:50 +00:00
Josh Johnson f6c77fbac0 Version 4.0.2 2018-10-28 09:35:46 +00:00
Josh Johnson 7920f20c98 4.0.2 2018-10-28 09:32:43 +00:00
Josh Johnson 608358a9f8 Fix bug where selected options were not being selected 2018-10-28 09:32:35 +00:00
Josh Johnson 8e6daa64f0 Update codebeat badge url 2018-10-27 21:16:28 +01:00
Josh Johnson a45bcdaf49 Ensure test hook is correct 2018-10-27 21:12:28 +01:00
Josh Johnson ea9e322931 Update test descs 2018-10-27 21:07:01 +01:00
Josh Johnson d5437413a4 Update choice value/labels + add test for parent/child link 2018-10-27 21:00:49 +01:00
Josh Johnson dad2b345cd Version 4.0.1 2018-10-27 20:18:23 +01:00
Josh Johnson 4fdf7b8d1d 4.0.1 2018-10-27 20:17:04 +01:00
Josh Johnson de71fb7ef4 Resolve issue with disable/enable methods 2018-10-27 20:16:46 +01:00
Josh Johnson 013058dd7f Update readme to document multiple instances 2018-10-27 20:03:53 +01:00
Josh Johnson 315b2f8f36 Add e2e tests for choice groups 2018-10-27 18:12:15 +01:00
Josh Johnson a06988406a Add Adidas web component link to README 2018-10-27 17:39:46 +01:00
Josh Johnson 498b7fe70a Add stale github app config 2018-10-27 17:14:42 +01:00
Josh Johnson 0439728374 Add CDN examples to README 2018-10-27 17:01:54 +01:00
Josh Johnson 2c434feb43 Add CDN link to README 2018-10-27 17:00:40 +01:00
Josh Johnson e39cb73a70 Add gh-pages task 2018-10-27 16:55:56 +01:00
Josh Johnson 62bfde18bc Version 4.0.0 2018-10-27 16:45:19 +01:00
Leonard 8149db8436 Make it work in Internet Explorer (#434)
+ IE does not support multiple-parameter classList.add() /
  classList.remove(); Replace it with single-parameter calls
  https://caniuse.com/#feat=classlist
+ IE needs polyfills for Array.prototype.find / Array.prototype.includes
2018-10-27 16:26:52 +01:00
Josh Johnson 15082ccd03 Add scrolling e2e tests 2018-10-27 16:25:46 +01:00
Josh Johnson 54c026ec61 Add e2e tests for addItems: false 2018-10-21 19:26:19 +01:00
Josh Johnson 4193422cf6 Resolve an issue with disabling/enabling instances 2018-10-21 19:26:08 +01:00
Josh Johnson 620bfeae0d Add scrolling e2e tests 2018-10-21 18:39:37 +01:00
Josh Johnson 462d8b764c Add ajax e2e tests 2018-10-20 13:32:58 +01:00
Josh Johnson 17e02df269 Fix coverage task 2018-10-18 22:35:59 +01:00
Josh Johnson e37b051b5a Run build 2018-10-18 22:22:22 +01:00
Josh Johnson 69ee88ae88 Add plcaeholder tests 2018-10-18 22:18:17 +01:00
Josh Johnson 544763017e Further e2e tests 2018-10-17 23:13:24 +01:00
Josh Johnson 92cfd989ff Add search tests + refactor tests 2018-10-17 22:36:37 +01:00
Josh Johnson b224a96e08 Add select one e2e tests 2018-10-14 16:00:46 +01:00
Josh Johnson e07e14bd8f Add select multiple e2e tests 2018-10-13 16:38:51 +01:00
Josh Johnson 1f06a32b30 Resolve bug with text value 2018-10-13 15:49:44 +01:00
Josh Johnson 0f7cbfb6bf Remove unnecessary polyfills from test file 2018-10-13 13:12:01 +01:00
Josh Johnson 57f16c23ee Finish up e2e tests for text elements 2018-10-13 12:42:33 +01:00
Josh Johnson 2f96c239ff Better organisation of e2e tests 2018-10-13 12:18:02 +01:00
Josh Johnson 5b68505b1a Use npm-run-all instead of concurrently 2018-10-13 11:19:24 +01:00
Josh Johnson e53ebdda42 Add enabled/disabled tests 2018-10-11 19:58:06 +01:00
Josh Johnson 447f53a078 Sigterm tweaks 2018-10-11 19:57:44 +01:00
Josh Johnson af4dd13ffe Run e2e in travis 2018-10-11 19:46:50 +01:00
Josh Johnson 81b2e23d0d Use test.html for testing + add additional tests 2018-10-11 19:33:19 +01:00
Josh Johnson 71662e0e4b Add initial text input tests 2018-10-10 21:00:32 +01:00
Josh Johnson 83bc319801 Add cypress globals to eslint 2018-10-10 13:27:58 +01:00
Josh Johnson 3ce59432bc Add CI command and server sigterm handler 2018-10-10 12:44:08 +01:00
Josh Johnson 7d3c8daf07 Install cypress 2018-10-10 12:36:43 +01:00
Josh Johnson 3319529b98 Seperate key methods into class methods 2018-10-09 13:17:11 +01:00
Josh Johnson 60d52a2d3b Check no unknown config keys are passed 2018-10-09 13:16:58 +01:00
Josh Johnson 4431a0ec23 Use deepmerge lib + store all defaults in DEFAULT_CONFIG 2018-10-09 12:43:25 +01:00
Josh Johnson 4824958e4d Make render method private 2018-10-09 12:26:47 +01:00
Joshua Dorenkamp 49c6a648c0 npm --save no longer necessary 2018-08-14 09:14:34 +01:00
Joshua Dorenkamp 28da5683e5 remove bower add yarn 2018-08-14 09:14:34 +01:00
Ryan Mahoney 8dedc6f1e0 update documentation 2018-07-03 09:51:18 +01:00
Ryan Mahoney 5e215907f4 expose new event that triggers when choice is highlighted 2018-07-03 09:51:18 +01:00
Josh Johnson 129d01c396 Amend copy 2018-05-29 20:39:40 +01:00
Josh Johnson 3886cbbd5c Minor tweaks 2018-05-29 20:30:58 +01:00
Josh Johnson 5640744bf3 Ignore root level js files 2018-05-29 20:11:55 +01:00
Josh Johnson 9ac62aec31 Codebeat fixes 2018-05-29 20:08:05 +01:00
Josh Johnson 1b7b3045b8 Ignore webpack files from codebeat 2018-05-29 19:56:43 +01:00
Josh Johnson 38cc568341 Use objects for args where necessary 2018-05-29 19:55:33 +01:00
Josh Johnson 6f1d012ed2 Add codebeatignore file 2018-05-29 19:01:53 +01:00
Josh Johnson bc2e0b8be0 Build 2018-05-29 15:47:45 +01:00
Josh Johnson 32f32703cb Use internal flag for enabling/disabling search 2018-05-29 15:46:30 +01:00
Josh Johnson 5a6c8142b9 Inverse focus calls when opening/closing dropdown 2018-05-29 15:08:43 +01:00
Josh Johnson 138b7772f2 Remove unused file 2018-05-29 12:01:39 +01:00
Josh Johnson 8a21c12482 Rename duplicateItems to duplicateItemsAllowed for clarity 2018-05-29 09:30:05 +01:00
Josh Johnson f286dbc653 Add util tests 2018-05-28 17:56:36 +01:00
Josh Johnson bfb6571ce9 Merge into latest 2018-05-28 16:22:22 +01:00
Josh Johnson fe6208f427 Ensure eslint rules aren't being ignored 2018-05-28 16:22:09 +01:00
Josh Johnson 056ece0238 Run linter 2018-05-28 15:50:16 +01:00
Josh Johnson 179542897c
Merge branch 'develop' into develop 2018-05-28 15:47:27 +01:00
Josh Johnson 67e1940232 Avoid name conflict with stripHTML 2018-05-28 15:46:27 +01:00
Josh Johnson 9dbb2e9733 Rename stripHTML + cast values to string 2018-05-28 15:39:12 +01:00
Josh Johnson 8214eea7a9 Resolve conflict + add test 2018-05-28 15:33:13 +01:00
Tőrös Egon Richárd 6e45d3f9b0
Merge branch 'develop' into develop 2018-05-28 16:19:31 +02:00
Josh Johnson a023d92b35 Resolve conflict 2018-05-28 15:17:43 +01:00
Egon Richárd Tőrös 0cbf951845 Merge branch 'develop' of https://github.com/jshjohnson/Choices into develop 2018-05-28 16:13:55 +02:00
Josh Johnson 39beb20245 Remove pointless comments + minor tidying 2018-05-28 14:18:44 +01:00
Josh Johnson 804a4a442b Move scrolling logic into list component 2018-05-28 14:09:11 +01:00
Josh Johnson f9455b1a25 Install prettier + resolve linting issues 2018-05-28 13:55:44 +01:00
Josh Johnson a6bfdc0993 Refactor _scrollToChoice 2018-05-27 17:34:16 +01:00
Josh Johnson 1df8d81ae4 Refactor _canAddItem 2018-05-27 17:22:58 +01:00
Josh Johnson ba67ff4a4d Remove old dependencies 2018-05-27 17:13:29 +01:00
Josh Johnson 9219552ce3 Remove cypress 2018-05-27 17:08:50 +01:00
Josh Johnson a63fae8f5b Serve bundle from memory when devving 2018-05-27 13:35:37 +01:00
Josh Johnson 9a9e7f7b25 Restructure style folders 2018-05-27 12:04:42 +01:00
Josh Johnson 257a038262 Use express for development + folder restructuring 2018-05-27 11:57:21 +01:00
Josh Johnson 9f8dfb19ec Build into public folder 2018-05-25 16:51:21 +01:00
Josh Johnson 831a79ea44 Move public assets into public foldeR 2018-05-25 14:00:27 +01:00
Josh Johnson 9eb69a03b1 Init cypress 2018-05-25 13:16:37 +01:00
Josh Johnson 8f67de4844 Make event handlers private 2018-05-25 09:22:14 +01:00
Josh Johnson b3956db628 Export components from index file 2018-05-25 09:01:55 +01:00
Josh Johnson 579138f756 Remove unused utils 2018-05-25 08:58:07 +01:00
Josh Johnson 478df0fac1 Minor tweaks 2018-05-25 08:53:58 +01:00
Josh Johnson 25309c91fc Use dep for event polyfill 2018-05-25 08:53:50 +01:00
Josh Johnson 1608d815e9 Use core js for polyfills 2018-05-25 08:44:54 +01:00
Josh Johnson 62389ff744 More private variables 2018-05-24 09:22:07 +01:00
Josh Johnson 109a232171 Minor variable name change 2018-05-23 14:43:52 +01:00
Josh Johnson a591c32a24 Break out public functions into more private methods + housekeeping 2018-05-23 13:09:45 +01:00
Philipp Eichhorn 8ab0387857 perf: removed forced reflow ("layout thrashing") by reading testEl.offsetWidth in a separate animation frame 2018-05-22 15:19:00 +02:00
Philipp Eichhorn 92e968462c perf: removed forced reflow ("layout thrashing") by executing choiceList.scrollTo(0) in a separate animation frame 2018-05-22 13:46:24 +02:00
Josh Johnson d3a18e255b Destructure class args 2018-05-21 17:01:03 +01:00
Egon Richárd Tőrös ec061adc7c Merge branch 'develop' of https://github.com/jshjohnson/Choices into develop 2018-05-10 14:42:53 +02:00
Josh Johnson b3108835bb Use babel env config 2018-04-25 09:20:59 +01:00
Josh Johnson 18456153ff Remove redundant super calls 2018-04-25 09:16:02 +01:00
Josh Johnson 85c0a488cd
Add template tests (#387)
* Begun template tests

* Further tests

* Add further tests
2018-04-24 15:13:13 +01:00
Josh Johnson bf1eb3b8ac Seperate out element creation logic 2018-04-24 13:57:31 +01:00
Josh Johnson 54b8935aee Clearer store naming conventions 2018-04-24 13:52:13 +01:00
Josh Johnson f02abdaacf Final few store getters 2018-04-24 13:49:57 +01:00
Josh Johnson 80f4d929ac Further getters 2018-04-24 13:23:26 +01:00
Josh Johnson 152b740670 Use getters and setters appropriately 2018-04-24 12:54:45 +01:00
c5254061 c2fccdc398 Fix xss vulnerability(escape html in item label) 2018-04-18 11:05:21 +03:00
c5254061 d15ab02db8 Merge branch 'develop' of https://github.com/jshjohnson/Choices into develop 2018-04-18 10:50:44 +03:00
Andy Nutt 275295adc5 Remove inline styling (#306)
* Remove inline styling (#279)

- Remove the JS styling to prevent CSP violations.
- Add "display: none;" CSS rule for the default class "is-hidden".

* Increase the specificity of the hidden class (#279)

* Include "is-hidden" class in utils section of base style sheet (#279)

* Add top level selector for hiding Choices inputs (#279)
2018-03-27 15:02:19 +01:00
Josh Johnson 82c389bc56
Install husky (#373)
* Add prepush hook and install husky
2018-03-27 10:48:01 +01:00
c5254061 38cf04b0d8 Fix xss vulnerability(escape html in input) 2018-03-25 20:26:47 +01:00
c5254061 e46ae74209 Fix xss vulnerability(escape html in input) 2018-03-23 18:51:50 +03:00
Egon Richárd Tőrös 00ac0d879e 🔥 Typo 2018-03-19 11:48:29 +01:00
Egon Richárd Tőrös e60be87a94 🚑 Add example 2018-03-19 11:46:28 +01:00
Egon Richárd Tőrös 3019d96ad9 💄 Code formatting 2018-03-12 21:44:55 +01:00
Egon Richárd Tőrös 4f5711c7e3 💄 Build Javascript 2018-03-12 21:43:43 +01:00
Egon Richárd Tőrös 8a586fc32a Ajax - fetch properties from object 2018-03-12 21:42:13 +01:00
Waltton Morais b49980d169 Replace hardcoded color for input with $choices-bg-color variable 2018-03-09 09:07:15 +00:00
Bart Langedijk 2514cbcd51 Update README.md 2018-03-08 12:33:54 +00:00
Bart Langedijk e5a3b0e308 Update of build files 2018-03-08 12:33:54 +00:00
Bart Langedijk 3cb2a897fa ESLint fix 2018-03-08 12:33:54 +00:00
Bart Langedijk 56c4888aea Add custom properties to 'addItem' event 2018-03-08 12:33:54 +00:00
= 6276d17a2a Resolving the issue 342: we can't select an empty empty string or 0 as value. EDIT 2. 2018-03-08 09:23:25 +00:00
= a2a9953b1b Resolving the issue 342: we can't select an empty empty string or 0 as value. EDIT. 2018-03-08 09:23:25 +00:00
= 1d9fd326f0 Resolving the issue 342: we can't select an empty empty string or 0 as value 2018-03-08 09:23:25 +00:00
Travis Tidwell 1e6ae4e3f9 Add ability to configure the item comparer function. 2018-02-02 10:28:44 +00:00
Josh Johnson 5048379e68 Rename rendering methods + createGroupsFragment test 2017-12-20 15:10:01 +00:00
Josh Johnson a5277a49e7 Wrapped select tests + minor refactors 2017-12-20 12:38:16 +00:00
Josh Johnson 9c9a4c115a Add further component tests 2017-12-19 13:08:57 +00:00
Josh Johnson 905f31abf1 Merge remote-tracking branch 'origin/develop' into develop 2017-12-19 12:19:57 +00:00
Josh Johnson afd5935866 Setup rendering test 2017-12-19 12:19:54 +00:00
Josh Johnson e3aa6e723e Rename sortFilter to sortFn 2017-12-19 12:19:43 +00:00
Josh Johnson f54a81f7f4 Resolve janky scrolling 2017-12-18 12:17:35 +00:00
Josh Johnson 9777287b92 Ensure destroying instance reinstates options + tests 2017-12-18 12:06:38 +00:00
Josh Johnson beeeeb87ad Move wrapping into container class 2017-12-11 14:40:38 +00:00
Josh Johnson 6130ee00d5 Enable/disable tests 2017-12-10 18:13:13 +00:00
Josh Johnson e79699facd More coverage 2017-12-10 18:00:57 +00:00
Josh Johnson 43417510cd Various unit test improvements + focus flipping 2017-12-10 16:41:39 +00:00
Josh Johnson e9469816d5 Update example 2017-12-08 15:14:38 +00:00
Josh Johnson 053ec770d3 Remove border-radius from button 2017-12-06 16:16:00 +00:00
Josh Johnson d97857e013 Merge remote-tracking branch 'origin/develop' into develop 2017-12-06 16:13:15 +00:00
Josh Johnson a5befca2fe Resolve item rendering bug 2017-12-06 16:12:53 +00:00
Josh Johnson f3ab15a53c Merge remote-tracking branch 'origin' into develop 2017-12-06 15:43:56 +00:00
George Brook 622d658f6b Update choices.css 2017-12-05 13:55:36 +00:00
George Brook 40ed67453c Update choices.scss 2017-12-05 13:55:36 +00:00
Josh Johnson 7d96ff2dcf Update README.md 2017-12-05 13:54:56 +00:00
Josh Johnson e18971fd6d Further test coverage 2017-11-29 13:48:49 +00:00
Josh Johnson 760ecde4c1 Add tests for removeHighlightedItems + setChoices 2017-11-29 13:25:20 +00:00
Arthur Vasconcelos 4d5ab91a72 New interface for passedElement 2017-11-29 09:58:32 +00:00
Arthur Vasconcelos 06e18c528e Fix typo 2017-11-29 09:58:32 +00:00
Arthur Vasconcelos 7f713ed8e5 Updating types 2017-11-29 09:58:32 +00:00
Josh Johnson b3486ccfbb Further public method unit tests 2017-11-21 16:17:00 +00:00
Josh Johnson 2f094e8e10 Merge branch 'indacloud-master' into develop 2017-11-21 15:53:41 +00:00
Josh Johnson 92037ba5b9 Keep icons for future usage 2017-11-21 15:53:28 +00:00
Josh Johnson 78bfa5dac4 Merge branch 'master' of https://github.com/indacloud/Choices into indacloud-master 2017-11-21 15:53:06 +00:00
Josh Johnson 0f64611057
Update README.md 2017-11-21 15:48:42 +00:00
Josh Johnson a46915718f Minor refactoring 2017-11-21 15:19:46 +00:00
Josh Johnson 3adccb3ce5 Prepare test descriptions 2017-11-21 14:10:29 +00:00
Josh Johnson dd0b4bc086 Build with latest deps 2017-11-20 12:59:12 +00:00
Josh Johnson e8d8f8662e Export properly 2017-11-15 06:51:53 +00:00
Josh Johnson 7c1a18895e Use export for classes 2017-11-13 19:13:37 +00:00
Josh Johnson dd0a06a946 Further unit tests 2017-11-11 13:40:18 +00:00
Tom Brehm f7e63ce35c Move icons to css with encoded data
### This is the problem:

the `$choices-button-icon-path` needed to be changed for use with Weppack and I still had some complications when building my project.

### This is my solution:

The icons can be encoded and used directly in the stylesheet. This makes it easier to customize and removes 2 dependencies.
You can then customize `$choices-icon-cross` and `$choices-icon-cross-inverse` with one of your one data or asset.
2017-11-09 11:17:13 -05:00
Josh Johnson b44c918022 Better splitting up of functions 2017-11-07 14:08:55 +00:00
Josh Johnson 97e8c04536 Further unit tests 2017-11-07 14:04:37 +00:00
Josh Johnson f20b9fc59f Clear store unit test 2017-11-07 12:56:54 +00:00
Josh Johnson 9746d26b97 Merge remote-tracking branch 'origin/master' 2017-11-07 12:56:45 +00:00
Josh Johnson fdbc2a890f Further public method unit tests 2017-11-07 12:51:43 +00:00
Josh Johnson 1dc040d7f8 Ignore test files from coverage 2017-11-07 12:19:56 +00:00
Josh Johnson ad797c2b5e
Update README.md 2017-11-07 12:01:09 +00:00
Josh Johnson 09cffecc69 Add further public method unit tests 2017-11-07 12:00:10 +00:00
Josh Johnson 487e878b88 Ensure webpack config is valid 2017-11-07 11:59:49 +00:00
Raymond Zhou cc11d6bfd6 Update to Webpack 3 2017-11-07 10:40:47 +00:00
Josh Johnson 8c7fc17811 init() and destroy() unit tests 2017-11-06 13:52:27 +00:00
Josh Johnson a7484fa093
Merge pull request #227 from jshjohnson/feature/modularise-code
NEXT RELEASE
2017-11-06 13:19:25 +00:00
Josh Johnson affd67e542 Merge with latest + housekeeping 2017-10-29 18:59:17 +00:00
Josh Johnson 71dcb6c140 Minor test tweaks 2017-10-29 18:56:24 +00:00
Josh Johnson a325a75a23 Early returns + refactoring 2017-10-19 12:35:26 +01:00
Josh Johnson 30c31a406c Abstract various methods 2017-10-18 13:05:07 +01:00
Josh Johnson 920d41d0f5 Remove 'shoulds' from tests 2017-10-18 13:04:52 +01:00
Josh Johnson 5304de02a7 Move event triggering to wrapped element class 2017-10-18 09:08:27 +01:00
Josh Johnson a77b93b25a Resolve conflict 2017-10-18 08:56:19 +01:00
Josh Johnson 88ccdc6917 Template functions as pure functions 2017-10-18 08:54:23 +01:00
Josh Johnson 859653ff72 Expose methods from wrapped elements 2017-10-18 08:43:56 +01:00
Josh Johnson 8b71f277ff Resolve passedElement issues 2017-10-14 11:29:08 +01:00
Josh Johnson bd77f458b3 Begin to move passedElement logic into wrapped component 2017-10-13 13:43:58 +01:00
Josh Johnson 82cb17ec2b Minor refactoring 2017-10-13 09:17:20 +01:00
Josh Johnson d48fdf4e02 Minor fixes 2017-10-13 08:51:28 +01:00
Josh Johnson e79aeaa93e Move key codes into constant 2017-10-12 16:27:23 +01:00
Josh Johnson d5167b0106 Add further container tests 2017-10-12 12:43:53 +01:00
Josh Johnson 843d1f66bb Use parentInstance + begin adding container tests 2017-10-12 12:34:47 +01:00
Josh Johnson 48e35a88da Finish input unit tests 2017-10-12 09:35:58 +01:00
Josh Johnson f9303d86b0 Add list unit tests 2017-10-11 09:39:31 +01:00
Josh Johnson d211cf9507 Add dropdown unit tests 2017-10-11 09:19:13 +01:00
Josh Johnson 806edca24f Move templates into own file 2017-10-10 16:59:49 +01:00
Josh Johnson f98e79e218 Move action types into constant file 2017-10-10 15:30:06 +01:00
Josh Johnson fb4f80b5f1 Break out actions into action files 2017-10-10 15:26:38 +01:00
Josh Johnson 865f96d0da Move event keys into constants 2017-10-10 13:03:04 +01:00
Josh Johnson ff7cadbd85 Begin component tests 2017-10-10 12:56:36 +01:00
Josh Johnson af1dc1243d Finish add store tests 2017-10-10 12:35:05 +01:00
Josh Johnson 180e0fc609 Begin adding store tests 2017-10-10 12:06:00 +01:00
Josh Johnson 2a8a8340f6 Items/groups tests 2017-10-10 11:40:59 +01:00
Josh Johnson c63b9ff439 Group reducer tests 2017-10-10 11:28:08 +01:00
Josh Johnson b9750e3c83 Don't map over state for reducer tests 2017-10-10 11:20:00 +01:00
Josh Johnson a9cdbc54c4 Rename choices main test file 2017-10-09 17:47:18 +01:00
Josh Johnson a8cbeb91bc Begun adding reducer tests 2017-10-09 17:46:47 +01:00
Josh Johnson 4666e33845 Export default state with reducer 2017-10-08 15:52:54 +01:00
Josh Johnson 6f5673a6a3 Add action unit tests 2017-10-08 15:48:51 +01:00
Josh Johnson efc87cc6ce Update node version on Travis build 2017-10-06 09:59:42 +01:00
Josh Johnson 0f3b42ee2c Update test watch command 2017-10-06 09:38:13 +01:00
Josh Johnson da133747eb Revert "Begin to abstract passedElement code"
This reverts commit 55fca5d402.
2017-10-06 09:37:17 +01:00
Josh Johnson 55fca5d402 Begin to abstract passedElement code 2017-10-06 09:07:49 +01:00
Josh Johnson b8c53bdd49 Remove karma tests 2017-10-03 13:18:42 +01:00
Josh Johnson e96e5fdc74 Resolve final broken tests 2017-10-03 13:17:31 +01:00
Josh Johnson 498e45f6db Merge branch 'feature/modularise-code' of github.com:jshjohnson/Choices into feature/modularise-code 2017-09-29 13:27:26 +01:00
Josh Johnson 098f71172d Fix further tests 2017-09-29 13:26:47 +01:00
Josh Johnson 8e703b5bfc Merge remote-tracking branch 'origin' into feature/modularise-code 2017-09-29 13:05:55 +01:00
Josh Johnson 85bd985a5e Merge pull request #261 from JayKid/update-fuse
Update Fuse dependency
2017-09-28 12:37:40 +01:00
Jay Kid 4a68f6acf3 Merge branch 'feature/modularise-code' of github.com:jshjohnson/Choices into update-fuse 2017-09-28 12:49:10 +02:00
Jay Kid 509eed587c Access id instead of item.id since Fuse has flattened its object structure 2017-09-21 20:55:57 +02:00
Josh Johnson 4c080cdc06 Add example placeholder to single select 2017-09-20 13:18:49 +01:00
Josh Johnson 5937afdc48 Merge pull request #257 from maximmig/feature/modularise-code
Addressing issue #253
2017-09-20 09:04:40 +01:00
Josh Johnson 92f7263e77 Resolve breaking tests 2017-09-19 18:13:35 +01:00
Maxim Mig 955716d846 Addressing issue #253 2017-09-19 16:22:00 +03:00
Josh Johnson a048fced4f Merge pull request #255 from maximmig/feature/modularise-code
Addressing issue #224
2017-09-19 13:00:05 +01:00
Maxim Mig 020905676a Fixing NRE 2017-09-19 14:43:20 +03:00
Maxim Mig 721441f32d Addressing issue #224 2017-09-18 18:46:48 +03:00
Josh Johnson 26d4c2304e Resolve conflicts 2017-09-06 08:48:42 +01:00
Josh Johnson 79638ae88d Merge pull request #244 from MaksimShakavin/master
Change window.scrollY to window.pageYOffset for IE
2017-09-06 08:41:00 +01:00
Josh Johnson 2c4a74496a Merge pull request #245 from yannicsmeets/master
Fixed typescript typings
2017-09-06 07:01:59 +01:00
Yannic Smeets 3ab9bca6e6 Fixed typescript typings 2017-09-05 20:22:25 +02:00
c5254061 671a696962 Change window.scrollY to window.pageYOffset for IE 2017-09-05 17:17:51 +03:00
Josh Johnson f29307ec47 Merge pull request #241 from Hacktivista/set-user-defaults-2
Allow user to set his own defaults (simpler)
2017-09-05 08:39:45 +01:00
Hacktivista badb5c3cfe Allow user to set his own defaults 2017-08-30 16:19:59 -03:00
Josh Johnson 31396569b7 Early returns + reduce repitition 2017-08-30 13:04:19 +01:00
Josh Johnson c1df7461c0 Merge pull request #238 from jshjohnson/feature/mocha-and-chai
Feature/mocha and chai
2017-08-29 13:09:07 +01:00
Josh Johnson 971262c4a9 Port components into src folder 2017-08-29 13:08:46 +01:00
Josh Johnson e6216983f6 Pass majority of failing tests 2017-08-29 13:04:53 +01:00
Josh Johnson 241c9e5dcc Begun mocha/chai setup 2017-08-29 13:04:51 +01:00
Josh Johnson 753f163195 Revert karma config change 2017-08-29 12:59:56 +01:00
Josh Johnson 809b62c60d Add remaining components 2017-08-29 12:56:54 +01:00
Josh Johnson 4c7cc047dc Further modularisation 2017-08-27 13:49:35 +01:00
Josh Johnson 9c4f1f4963 Resolve eslint issues 2017-08-26 15:41:11 +01:00
Josh Johnson c9c1eab014 Abstract more input methods: 2017-08-23 13:32:07 +01:00
Josh Johnson fc7b53350a Move input specific events to input component 2017-08-23 13:23:37 +01:00
Josh Johnson ebcf6c957d Merge pull request #233 from adevade/patch-1
Update README.md
2017-08-23 08:43:58 +01:00
Josh Johnson 329bcbd1ce Merge pull request #234 from sufuf3/add-badge
Add CDNJS and npm version badge in README.md
2017-08-23 08:43:31 +01:00
sufuf3 28f34be704 Add CDNJS and npm version badge in README.md 2017-08-23 09:55:03 +08:00
Andréas Lundgren dc6921bea2 Update README.md
Fix small typo in README.md
2017-08-22 14:52:52 +02:00
Josh Johnson 852837cd37 Resolve dropdown bug 2017-08-21 17:09:55 +01:00
Josh Johnson bf5ee6ea5a Resolve failing tests 2017-08-21 16:59:56 +01:00
Josh Johnson 336b65fef9 Begin moving input to component 2017-08-21 08:53:19 +01:00
Josh Johnson 579fd3e824 Merge master 2017-08-18 13:14:49 +01:00
Josh Johnson 00ad96bfb3 Add missing comma 2017-08-18 08:45:12 +01:00
Josh Johnson 02f7bdcd2f Merge pull request #230 from lion-man44/remove/choices/min-map/lion
The source map is unnecessary in the production
2017-08-18 08:43:24 +01:00
lion-man44 edd68171b5 The source map is unnecessary in the production. 2017-08-18 13:01:03 +09:00
Josh Johnson 746c910452 Handle enabling/disabling 2017-08-17 13:50:14 +01:00
Josh Johnson c7fae9b3ed Housekeeping 2017-08-17 09:04:45 +01:00
Josh Johnson b8917d84ba Merge pull request #229 from vkolmakov1/ie11-accessibility-fix
Add aria-activedescendant attribute only when dropdown is active
2017-08-17 08:51:52 +01:00
Vladimir Kolmakov 7aee340a8b Add aria-activedescendant attribute only when dropdown is active 2017-08-16 13:08:38 -05:00
Josh Johnson b70f062acd Integrate dropdown opening with container class 2017-08-16 16:59:10 +01:00
Josh Johnson 1e40b60c3f Seperate out container class 2017-08-16 16:31:47 +01:00
Josh Johnson 9b9662ee99 Utilise dropdown state 2017-08-16 13:12:20 +01:00
Josh Johnson 9eebfc7ad1 Eslint spec files 2017-08-16 13:08:14 +01:00
Josh Johnson 67fe5d7dda Update dropdown methods 2017-08-16 13:01:17 +01:00
Josh Johnson b86b8f0ed0 Begin extracting dropdown from core class 2017-08-16 12:40:09 +01:00
Josh Johnson 0f81a03e19 Autofix errors 2017-08-16 09:47:22 +01:00
Josh Johnson 364aca20a6 Early returns 2017-08-15 16:57:29 +01:00
Josh Johnson 6261962caf Housekeeping 2017-08-15 14:31:14 +01:00
Josh Johnson 3b7e49dadb Remove space 2017-08-15 14:26:36 +01:00
Josh Johnson ed458a61d4 Refactor variable names to make more sense 2017-08-15 13:15:01 +01:00
Josh Johnson 74703665df Resolve constructor issue 2017-08-15 13:06:59 +01:00
Josh Johnson c2c297d986 Housekeeping 2017-08-15 12:51:07 +01:00
Josh Johnson f82ddb3530 Resolve eslint errors 2017-08-15 12:50:37 +01:00
Josh Johnson 6b3437627d Eslint fixes 2017-08-15 09:29:42 +01:00
Josh Johnson 7967874597 Add missing commas 2017-08-14 13:53:58 +01:00
Josh Johnson 913da73a56 Begin to remove eslint errors 2017-08-14 13:46:46 +01:00
Josh Johnson 3c037e0682 Use airbnb eslint config 2017-08-14 13:39:07 +01:00
Josh Johnson f64369cc9f Add eslint ignore 2017-08-14 13:35:28 +01:00
Josh Johnson e16ddb404f Remove assignment within if 2017-08-14 13:33:20 +01:00
Josh Johnson bfef79d3ee Move regex filter into util 2017-08-10 11:57:17 +01:00
Josh Johnson d0a3c99ef5 Merge pull request #218 from zackschuster/types
Add types
2017-08-07 06:58:12 +01:00
Zack Schuster 4d2caa129c Update types for 3.0.0 2017-08-04 14:49:37 -07:00
Josh Johnson dc9d083d89 Version 3.0.2 2017-08-03 16:16:08 +01:00
Josh Johnson 5eac8d4bdd Remove active descendant tag from input - causing virtual keyboard issues 2017-08-03 16:15:00 +01:00
Josh Johnson a4999d0286 Version 3.0.1 2017-08-03 14:14:35 +01:00
Josh Johnson bc757a6485 Add default notice type 2017-08-03 13:17:34 +01:00
Josh Johnson 99461846a0 Merge remote-tracking branch 'origin/master' 2017-08-03 13:15:56 +01:00
Josh Johnson 8fa852e4b8 Add appropriate classes to notices 2017-08-03 13:15:49 +01:00
Josh Johnson 57987c7215 Update README.md 2017-08-03 12:48:32 +01:00
Josh Johnson bfa7b1d97f Version 3.0.0 2017-08-03 12:28:01 +01:00
Josh Johnson bab75d6af1 Add placeholder example to read me 2017-08-03 12:27:33 +01:00
Josh Johnson 899a7f1531 Resolve conflicts 2017-08-03 12:09:44 +01:00
Josh Johnson 75a0b2e7b5 . 2017-08-03 11:44:06 +01:00
Josh Johnson ad476c2480 Refactoring 2017-08-03 11:22:21 +01:00
Josh Johnson a75e7c6a03 Update readme 2017-08-03 11:13:23 +01:00
Josh Johnson 0e307b5bf0 Only consider last instance of a placeholder option 2017-08-03 11:07:54 +01:00
Josh Johnson 4d94fa57a6 Resolve search issue 2017-08-03 10:58:17 +01:00
Josh Johnson 565d659c0a Fix search + use choice placeholder on remove button 2017-08-03 10:56:49 +01:00
Josh Johnson 171f59cf65 Merge master 2017-08-03 10:07:45 +01:00
Josh Johnson c3a7330e5b Typo + set placeholder value to instance 2017-08-03 10:03:09 +01:00
Josh Johnson 3817bb33dd Add search placeholder to example 2017-08-03 09:57:15 +01:00
Josh Johnson 84f149ee83 searchPlaceholderValue option 2017-08-03 09:55:31 +01:00
Josh Johnson 55e81d188b Version 2.8.12 2017-08-02 14:19:08 +01:00
Josh Johnson 61dc200bab Remove unnecessary method 2017-08-02 14:14:51 +01:00
Josh Johnson 1013f32ce6 A few tests 2017-08-02 14:14:08 +01:00
Josh Johnson 94e3c97b4e Placeholder work 2017-08-02 14:05:26 +01:00
Josh Johnson bc9adcf4ff Remove console log from index file 2017-08-02 09:45:00 +01:00
Josh Johnson 4d16787997 IE11 test 2017-08-02 09:42:12 +01:00
Josh Johnson 29ab3ca55a IE scroll fix 2017-08-02 09:30:00 +01:00
Josh Johnson cf3c2e67dd IE11 flag 2017-08-01 16:55:38 +01:00
Josh Johnson 153cd1bc56 Update readme 2017-07-31 16:22:21 +01:00
Josh Johnson 16c114a6e3 Version 2.8.11 2017-07-31 16:18:36 +01:00
Josh Johnson 21f67b4289 Return result count on search 2017-07-31 16:17:03 +01:00
Josh Johnson 6ebc0ea37a Update README.md 2017-07-31 16:06:26 +01:00
Zack Schuster 791eb9a95b Add types 2017-07-27 13:39:17 -07:00
Josh Johnson 8c95ae35fc Add es6.io message 2017-07-24 15:23:30 +01:00
Josh Johnson 562242664d Merge remote-tracking branch 'origin/master' 2017-07-24 14:50:45 +01:00
Josh Johnson 18d5c12462 Typos 2017-07-24 14:50:40 +01:00
Josh Johnson ca3bda1f70 Ability to only render a portion of choices 2017-07-24 14:46:30 +01:00
Josh Johnson eff1f00c2e Update README.md 2017-07-24 13:49:35 +01:00
Josh Johnson 04aca852c3 Version 2.8.10 2017-07-20 12:06:32 +01:00
Josh Johnson fd52de1835 Resolve keycode issue 2017-07-20 12:05:56 +01:00
Josh Johnson f862a3a055 Version 2.8.9 2017-07-19 20:48:25 +01:00
Josh Johnson 73940d7d04 Set value of text element 2017-07-19 20:47:42 +01:00
Josh Johnson 621ac1b78f Update README.md 2017-07-19 20:29:44 +01:00
Josh Johnson 40242f696e Merge pull request #211 from oWallyson/master
Added keyCode to choice objects
2017-07-19 19:33:52 +01:00
Andrew Whalley dba6093297 Added keyCode to choice objects 2017-07-19 13:48:46 -04:00
Josh Johnson d3ebae6cab Remove unnecessary bindings 2017-07-19 12:59:54 +01:00
Josh Johnson a7ee256a85 Merge pull request #209 from maximmig/master
Backup & recover original styles: added test
2017-07-18 08:39:01 +01:00
Maxim Mig d8e8e1ab97 Backup & recover original styles: added test 2017-07-17 13:35:50 +03:00
Josh Johnson 23871cc943 Merge pull request #206 from maximmig/master
Various minor corrections.
2017-07-17 08:50:07 +01:00
Maxim Mig c88f00513e Persisting original styles of the passed element (we don't need to store null if there are no styles at all). 2017-07-15 00:53:43 +03:00
Maxim Mig c04f637a3f Persisting original styles of the passed element (built files). 2017-07-15 00:37:35 +03:00
Maxim Mig 8e8df3e455 Persisting original styles of the passed element. 2017-07-15 00:31:45 +03:00
Maxim Mig 51a4f28b65 Various minor corrections (dist files). 2017-07-13 18:00:51 +03:00
Maxim Mig bc1715125d Various minor corrections. 2017-07-13 17:59:33 +03:00
Maxim Mig 9a1258d10f Merge remote-tracking branch 'refs/remotes/jshjohnson/master' 2017-07-13 11:35:21 +03:00
Josh Johnson 147341b846 Version 2.8.8 2017-07-13 09:04:55 +01:00
Josh Johnson 49c76da629 Merge branch 'maximmig-master' 2017-07-13 09:01:44 +01:00
Josh Johnson 89289ab692 Remove errors to reduce file size 2017-07-13 09:01:24 +01:00
Josh Johnson 3b350eb71e xMerge branch 'master' of https://github.com/maximmig/Choices into maximmig-master 2017-07-13 08:55:05 +01:00
Maxim Mig 7b294a80b6 Fix handling 'renderSelectedChoices' config option. Added two tests. 2017-07-12 13:21:35 +03:00
Josh Johnson bc66ae5291 Update read me 2017-07-12 09:05:36 +01:00
Maxim Mig 4627bb3201 Tests corrections. 2017-07-11 20:34:37 +03:00
Maxim Mig ef661f4615 Added two config options: shouldSortItems and renderSelectedChoices. 2017-07-11 08:36:10 +03:00
Maxim Mig fdced6276a Merge remote-tracking branch 'refs/remotes/jshjohnson/master' 2017-07-06 13:00:05 +03:00
Josh Johnson b8b09ceb9d Merge pull request #199 from jshjohnson/add-code-of-conduct-1
Create CODE_OF_CONDUCT.md
2017-07-05 09:12:46 +01:00
Josh Johnson b9de7f1027 Create CODE_OF_CONDUCT.md 2017-07-05 09:12:28 +01:00
Josh Johnson 0a5c3e404c Update README.md 2017-07-05 09:11:51 +01:00
Josh Johnson 44943633a4 Create CONTRIBUTING.md 2017-07-05 09:11:23 +01:00
Josh Johnson 011be2306d Version 2.8.7 2017-07-05 09:03:10 +01:00
Josh Johnson 2fefb904a3 Merge pull request #197 from JayKid/fix/extra-parameter-in-add-item
Fix extra parameter in call to _addItem
2017-06-30 15:23:37 +01:00
Jay Kid af9feb3e2c fix: remove extra 'undefined' argument when calling _addItem from _addChoice
+ Added integration-like test
2017-06-30 15:45:47 +02:00
Jay Kid 8ed2139335 fix: typo 2017-06-30 15:37:11 +02:00
Josh Johnson bb69d231e1 Merge pull request #193 from JayKid/doc/set-value-by-choice-extend-example
update readme regarding setValueByChoice
2017-06-29 16:46:10 +01:00
Jay Kid 8327af90f7 doc: Point out in the readme that setValueByChoice can be supplied an array of strings as well. 2017-06-29 16:49:08 +02:00
Josh Johnson 955a7c1206 Remove space 2017-06-29 08:53:04 +01:00
Josh Johnson a5f49fe864 Version 2.8.6 2017-06-29 08:42:16 +01:00
Josh Johnson 2d5c863f5a Merge branch 'JayKid-master' 2017-06-29 08:41:08 +01:00
Josh Johnson 4370616519 Documentation + housekeeping + ensure custom props are passed to preset items 2017-06-29 08:40:56 +01:00
Jay Kid 271d2a20b3 test: added a more "integration"-like test for the custom properties feature 2017-06-28 11:58:41 +02:00
Jay Kid 600f59a440 fix: add pause between "Remove item" and the value of the item by adding a colon
Helps understanding when using VoiceOver
2017-06-28 11:12:45 +02:00
Jay Kid 0b3cf1a355 feat: implement custom properties for items and choices
+ Added unit tests for both choice and item reducers
+ Had to add some visually unpleasant undefineds, sorry :P
2017-06-28 11:11:02 +02:00
Josh Johnson 1eaceb1345 Version 2.8.5 2017-06-27 16:39:08 +01:00
Josh Johnson 8485137121 More appropriate naming 2017-06-27 16:35:46 +01:00
Josh Johnson f6ea9224e2 Introduce search render limit 2017-06-27 16:30:08 +01:00
Josh Johnson cd9797e9d0 Housekeeping 2017-06-27 15:54:22 +01:00
Josh Johnson d632b3383f Remove package lock - breaking Travis checks 2017-06-27 13:22:10 +01:00
Josh Johnson 098e191771 Resolve isUnique test + minor fixes 2017-06-27 13:11:31 +01:00
Josh Johnson b1cfa5441c Use classnames lib for generating class lists 2017-06-27 12:42:01 +01:00
Josh Johnson 3084cae9f0 Update travis task 2017-06-27 11:35:53 +01:00
Josh Johnson 62d814ddf7 Merge in search PR + use normal test commands 2017-06-27 11:32:21 +01:00
Josh Johnson 149d576fe1 Merge branch 'maximmig-master' 2017-06-27 11:28:14 +01:00
Maxim Mig 9d4102bc03 Typo correction: this.config.search -> this.config.searchEnabled. Error in action: https://www.screencast.com/t/e23Ti7eT7J 2017-06-22 18:31:36 +03:00
Josh Johnson d28ad92033 Version 2.8.4 2017-06-03 12:38:33 +01:00
Josh Johnson 38761ca4ae Merge pull request #176 from adamsro/bugfix/maintain-container-focus-on-escape
Refocus outer container when dropdown is closed via escape key
2017-06-03 12:36:24 +01:00
Josh Johnson 7883254f16 Merge branch 'p-bernal-accessibility-improvements' 2017-06-03 12:05:10 +01:00
Josh Johnson 9020740f16 Don't re-assign arg 2017-06-03 12:04:46 +01:00
Pablo Bernal 8d481b4f2c Accessiblity improvements: usage of activedescendant to read options, allow arrow keys to browse options when screen reader is on, fix for aria-selected 2017-06-02 15:34:07 -05:00
Josh Johnson d95d4129e6 Merge pull request #177 from thetar/patch-1
Added missed comma
2017-06-01 09:05:55 +01:00
Tony be31f38706 Added missed comma 2017-05-30 15:46:06 -05:00
Josh Johnson bc79e6af75 Use node v5 - node-sass issues 2017-05-30 20:14:23 +01:00
Josh Johnson ac2def86af Merge pull request #175 from adamsro/bugfix/trim-is-not-a-function
Check `item.value` is type 'string' before calling `trim()`
2017-05-30 19:54:33 +01:00
Marshall Adams c3166d6e60 Refocus outer container when dropdown is closed via escape key 2017-05-30 11:35:34 -07:00
Marshall Adams e4df3a8cb7 Merge updated master into bugfix 2017-05-30 11:11:19 -07:00
Marshall Adams 110796e25f Check value is type string before calling trim() 2017-05-30 10:43:25 -07:00
Josh Johnson 3b203d892b Version 2.8.3 2017-05-29 11:12:48 +01:00
Josh Johnson 75e5801585 Revert breaking focus PR 2017-05-29 11:11:50 +01:00
Josh Johnson e5bf9b76bd Update README.md 2017-05-18 18:08:55 +01:00
Josh Johnson 777df12fe5 Update README.md 2017-05-18 18:04:49 +01:00
Josh Johnson 1350c6a9ac Version 2.8.2 2017-05-18 17:57:35 +01:00
Josh Johnson bc48904765 Silent config option 2017-05-18 17:56:29 +01:00
Josh Johnson 4ad0406ad5 Housekeeping 2017-05-18 12:20:01 +01:00
Josh Johnson 6caea25fff Merge branch 'rstacruz-fix/ie-on-blur-fix' 2017-05-18 12:00:14 +01:00
Josh Johnson c7d2d8beb6 Merge branch 'fix/ie-on-blur-fix' of https://github.com/rstacruz/Choices into rstacruz-fix/ie-on-blur-fix 2017-05-18 11:57:15 +01:00
Josh Johnson f9f4400d7d Check duplicate items for multiple select inputs too 2017-05-18 11:55:45 +01:00
Josh Johnson f64cf87801 Move away from one line returns 2017-05-18 09:36:33 +01:00
Josh Johnson fb13c49990 Housekeeping 2017-05-18 09:29:18 +01:00
Josh Johnson be3b574105 Search floor equal to or greater to 2017-05-18 09:17:51 +01:00
Rico Sta. Cruz aad2e7a858
Fix dropdown hiding on blur 2017-05-16 18:31:06 +08:00
Josh Johnson 1b8621b54e Upgrade node version on travis 2017-05-11 15:29:01 +01:00
Josh Johnson 71baf01a97 Node-sass issue test 2017-05-11 15:23:42 +01:00
Josh Johnson c8e9ce9f27 Version 2.8.1 2017-05-11 15:12:14 +01:00
Josh Johnson 43f618822d Revert add items functionality - buggy 2017-05-11 15:11:26 +01:00
Josh Johnson 13288ed38f Merge branch 'adammockor-fix/dropdown-height' 2017-05-09 09:05:22 +01:00
Adam Mockor cdc06efbf9 do not remove flippedState class if shouldFlip !== true 2017-05-02 15:17:57 +02:00
Adam Mockor dfafebc50a use dropdown offsetHeight instead of getBoundingClientRect.height 2017-05-02 15:16:53 +02:00
Josh Johnson 01dad3ac77 Version 2.7.8 2017-04-07 08:51:41 +01:00
Josh Johnson 64fd957b56 Merge branch 'manelmadeira-feature/disable-filter-option' 2017-04-07 08:49:53 +01:00
Josh Johnson 99a1eb5e3a Rename sortFields to searchFields for clarity 2017-04-07 08:49:15 +01:00
Manuel Madeira 7ec1e5310c Add option to remove search filter choices but emit the search event. 2017-04-06 14:42:11 +01:00
Josh Johnson c1327c9f55 Merge pull request #138 from adammockor/master
select-one input is now not focusable in disabled state (fixes #137)
2017-04-04 12:10:57 +01:00
Adam Mockor 6d894d4352 select-one input is now not focusable in disabled state (fixes #137) 2017-04-04 12:58:16 +02:00
Josh Johnson 9bb84df8d0 Don't use template literals on demo 2017-03-31 09:23:01 +01:00
Josh Johnson 750f98e54c Merge remote-tracking branch 'origin/master' 2017-03-31 09:09:29 +01:00
Josh Johnson 31a57a0e2b Use nornmal functions on demo 2017-03-31 09:09:22 +01:00
Josh Johnson d8b4108a4b Update README.md 2017-03-28 14:48:37 +01:00
Josh Johnson 7255fa42ce Version 2.7.7 2017-03-28 14:42:35 +01:00
Josh Johnson 7efd189c7d Resolve broken cancel buttons 2017-03-28 14:41:12 +01:00
Josh Johnson 779d2e0292 Resolve ARIA role bug 2017-03-28 14:08:38 +01:00
Josh Johnson 7552882cad Update README.md 2017-03-21 15:51:04 +00:00
Josh Johnson 27b907ae19 Merge pull request #128 from kostkobv/custom-templates-fix
Custom templates fix
2017-03-13 10:01:38 +00:00
Bohdan Kostko c33a89501a naming change 2017-03-12 14:21:00 +01:00
Bohdan Kostko 9df1310a52 lint fixes 2017-03-12 14:19:27 +01:00
Bohdan Kostko c21893e6fa Fix item custom template select bug 2017-03-12 14:17:46 +01:00
Josh Johnson 13afb13be7 Version 2.7.6 2017-03-08 15:15:11 +00:00
Josh Johnson 63b50f5c0f Version 2.7.6 2017-03-08 15:14:09 +00:00
Josh Johnson 4aa2a047bd Merge pull request #123 from samueldjack/dropdown-events
Dropdown events
2017-03-02 19:19:02 +00:00
Samuel Jack 437e419ae3 Update documentation
Added showDropdown/hideDropdown to list of events
2017-03-02 16:39:46 +00:00
Samuel Jack 00af5279e9 Added showDropdown/hideDropdown events 2017-03-02 16:13:53 +00:00
Josh Johnson fbb456f9b5 Version 2.7.5 2017-03-01 19:10:46 +00:00
Josh Johnson 930f84c005 Merge pull request #121 from rstacruz/patch-1
Fix choices.css crash with wicked_pdf
2017-03-01 19:09:28 +00:00
Josh Johnson 7de4be283a Merge branch 'alexb974-feature/label_within_event_add-remove_item' 2017-03-01 19:07:39 +00:00
Josh Johnson eec8a667ad Add label to highlighting events too 2017-03-01 19:07:22 +00:00
alexandre.baillif@kosmos.fr 8c6fbdd97a Add example in index.html + refactoring 2017-03-01 15:00:22 +01:00
alexandre.baillif@kosmos.fr b8979563ab Adding generated sources 2017-03-01 13:43:31 +01:00
alexandre.baillif@kosmos.fr 34e8a430e1 Add feature of passing the label through the event of add/remove item 2017-03-01 13:41:01 +01:00
Rico Sta. Cruz 3bca2b2c98 Fix choices crash with wicked_pdf 2017-03-01 17:43:07 +08:00
Josh Johnson 4f61ac5e7a Update readme 2017-02-21 20:52:31 +00:00
Josh Johnson d0fc0571a0 Typo 2017-02-21 20:50:46 +00:00
Josh Johnson a895ef9f6a Correct version number - Version 2.7.4 2017-02-21 20:48:51 +00:00
Josh Johnson ea4c5ae1f8 Version 2.7.3 2017-02-21 20:47:12 +00:00
Josh Johnson e35ef8040c Comment 2017-02-17 09:27:01 +00:00
Josh Johnson ca33f15504 Version 2.7.3 2017-02-17 09:26:08 +00:00
Josh Johnson c63d025e96 Minor improvements to type checking 2017-02-17 09:23:52 +00:00
Josh Johnson bc36c3c5af Update README.md 2017-02-13 09:41:55 +00:00
Josh Johnson f485814dd0 Version 2.7.2 2017-02-10 09:02:10 +00:00
Josh Johnson 6abeb65c95 Remove loading state if empty array passed to .ajax() 2017-02-10 09:01:20 +00:00
319 changed files with 52094 additions and 10995 deletions

View file

@ -1,3 +1,17 @@
{
"presets": ["es2015"]
"presets": [["@babel/preset-env", { "loose": true }]],
"env": {
"test": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": true
}
}
]
]
}
}
}

1
.browserslistrc Normal file
View file

@ -0,0 +1 @@
> 1%

3
.codebeatignore Normal file
View file

@ -0,0 +1,3 @@
public/**
webpack.config.*.js
*.js

4
.codecov.yml Normal file
View file

@ -0,0 +1,4 @@
coverage:
parsers:
javascript:
enable_partials: yes

3
.eslintignore Normal file
View file

@ -0,0 +1,3 @@
node_modules/
types/
public/

View file

@ -1,27 +0,0 @@
{
"ecmaFeatures": {
"modules": true
},
"env": {
"browser": true,
"node": true
},
"parser": "babel-eslint",
"rules": {
"quotes": [2, "single"],
"strict": [2, "never"],
"indent": ["error", 2, {"SwitchCase": 1}],
"eol-last": "off",
"arrow-body-style": "off",
"no-underscore-dangle": "off",
"no-new": 0,
"max-len": "off",
"no-console": "off",
"consistent-return": "off",
"no-param-reassign": ["error", { "props": false }],
"no-unused-vars": ["error", { "args": "none" }],
"no-lonely-if": "off",
"class-methods-use-this": "error",
"react/require-extension": "off",
},
}

123
.eslintrc.json Normal file
View file

@ -0,0 +1,123 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier", "sort-class-members"],
"extends": [
"airbnb-base",
"airbnb-typescript",
"plugin:prettier/recommended",
"plugin:compat/recommended",
"plugin:@typescript-eslint/recommended"
],
"env": {
"es6": true,
"browser": true,
"mocha": true,
"cypress/globals": true
},
"parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 2020
},
"rules": {
"import/prefer-default-export": "off",
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
],
"no-console": [
"warn",
{
"allow": ["warn", "error"]
}
],
"no-plusplus": "off",
"no-unused-expressions": "off",
"no-underscore-dangle": "off",
"consistent-return": "off",
"import/no-useless-path-segments": "warn",
"prefer-destructuring": [
"warn",
{
"array": false,
"object": true
}
],
"curly": ["error", "all"],
"newline-before-return": "error",
"sort-class-members/sort-class-members": [
2,
{
"order": [
"[static-properties]",
"[static-methods]",
"[properties]",
"[conventional-private-properties]",
"constructor",
"[methods]",
"[conventional-private-methods]"
],
"accessorPairPositioning": "getThenSet"
}
],
"lines-between-class-members": "off",
"@typescript-eslint/no-namespace": "off",
"react/jsx-filename-extension": [0]
},
"overrides": [
{
"files": ["*.test.ts"],
"env": {
"mocha": true
},
"rules": {
"no-restricted-syntax": "off",
"compat/compat": "off",
"no-new": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "default",
"format": ["camelCase", "PascalCase", "UPPER_CASE"],
"leadingUnderscore": "allow"
}
]
}
},
{
"files": ["cypress/**"],
"plugins": ["cypress"],
"rules": {
"no-unused-vars": "warn"
},
"env": {
"cypress/globals": true
}
}
],
"settings": {
"polyfills": [
"Array.from",
"Array.prototype.find",
"Array.prototype.includes",
"Symbol",
"Symbol.iterator",
"DOMTokenList",
"Object.assign",
"CustomEvent",
"Element.prototype.classList",
"Element.prototype.closest",
"Element.prototype.dataset"
],
"import/resolver": {
"node": {
"extensions": [".js", ".ts"]
}
}
}
}

64
.gitattributes vendored Normal file
View file

@ -0,0 +1,64 @@
## GITATTRIBUTES FOR WEB PROJECTS
#
# These settings are for any web project.
#
# Details per file setting:
# text These files should be normalized (i.e. convert CRLF to LF).
# binary These files are binary and should be left untouched.
#
# Note that binary is a macro for -text -diff.
######################################################################
# Auto detect
## Handle line endings automatically for files detected as
## text and leave all files detected as binary untouched.
## This will handle all files NOT defined below.
* text eol=lf
# Source code
*.css text eol=lf
*.html text diff=html eol=lf
*.js text eol=lf
*.json text eol=lf
*.scss text diff=css eol=lf
*.ts text eol=lf
# Documentation
*.md text eol=lf
*.txt text eol=lf
AUTHORS text eol=lf
CHANGELOG text eol=lf
CHANGES text eol=lf
CONTRIBUTING text eol=lf
COPYING text eol=lf
copyright text eol=lf
*COPYRIGHT* text eol=lf
INSTALL text eol=lf
license text eol=lf
LICENSE text eol=lf
NEWS text eol=lf
readme text eol=lf
*README* text eol=lf
TODO text eol=lf
# Linters
.eslintrc text eol=lf
.stylelintrc text eol=lf
# Configs
.babelrc text eol=lf
.browserslistrc text eol=lf
.editorconfig text eol=lf
.env text eol=lf
.gitattributes text eol=lf
.gitconfig text eol=lf
package-lock.json text -diff eol=lf
*.npmignore text eol=lf
*.yaml text eol=lf
*.yml text eol=lf
browserslist text eol=lf
# Graphics
# SVG treated as an asset (binary) by default.
*.svg text eol=lf
*.png binary

38
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View file

@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

View file

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: feature request
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

28
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,28 @@
## Description
<!--- Describe your changes in detail -->
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
## Screenshots (if appropriate)
## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Chore (tooling change or documentation change)
- [ ] Refactor (non-breaking change which maintains existing functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
## Checklist
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My code follows the code style of this project.
- [ ] I have added new tests for the bug I fixed/the new feature I added.
- [ ] I have modified existing tests for the bug I fixed/the new feature I added.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

View file

@ -0,0 +1,14 @@
const { readFileSync } = require('fs');
const path = require('path');
const assert = require('assert');
const readme = readFileSync(path.resolve(__dirname, '../../README.md'), 'utf8');
const polyfillsFromDocs = /^```polyfills\s*\n([^`]+)\n^```/m
.exec(readme)[1]
.split('\n')
.map(v => v.trim())
.sort();
// @ts-ignore
const polyfillsFromSettings = require('../../.eslintrc.json').settings.polyfills.sort();
assert.deepStrictEqual(polyfillsFromDocs, polyfillsFromSettings);

92
.github/actions-scripts/puppeteer.js vendored Normal file
View file

@ -0,0 +1,92 @@
const { readFileSync, writeFileSync, mkdirSync } = require('fs');
const path = require('path');
const { once } = require('events');
const puppeteer = require('puppeteer');
const pixelmatch = require('pixelmatch');
const { PNG } = require('pngjs');
const server = require('../../server');
async function test() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const artifactsPath = 'screenshot';
const snapshotName = `puppeteer-${process.platform}.png`;
let error;
let pixelDifference;
let diff;
if (!server.listening) await once(server, 'listening');
try {
page.on('console', msg => {
if (msg.type() === 'error') throw new Error(msg.text());
});
page.on('pageerror', err => {
throw err;
});
await page.goto(`http://127.0.0.1:${server.address().port}`, {
waitUntil: 'networkidle2',
});
await page.setViewport({ width: 640, height: 1000 });
await page.waitForTimeout(500); // Wait for resize to complete
await page.click('label[for="choices-single-custom-templates"]');
await page.keyboard.press('ArrowDown');
await page.keyboard.press('ArrowDown');
mkdirSync(artifactsPath, { recursive: true });
const imageBuffer = await page.screenshot({
path: path.join(artifactsPath, snapshotName),
fullPage: true,
});
// compare with snapshot
const screenshot = PNG.sync.read(imageBuffer);
const snapshot = PNG.sync.read(
readFileSync(path.resolve(__dirname, `./__snapshots__/${snapshotName}`)),
);
const { width, height } = screenshot;
diff = new PNG({ width, height });
pixelDifference = pixelmatch(
screenshot.data,
snapshot.data,
diff.data,
width,
height,
{
threshold: 0.6,
},
);
} catch (err) {
console.error(err);
error = err;
} finally {
if (diff) {
writeFileSync(path.join(artifactsPath, 'diff-' + snapshotName), PNG.sync.write(diff));
}
await Promise.all([
browser.close(),
new Promise(resolve => server.close(resolve)),
]);
}
if (pixelDifference > 200) {
console.error(
`Snapshot is different from screenshot by ${pixelDifference} pixels`,
);
process.exit(1);
}
if (error) process.exit(1);
}
process.on('unhandledRejection', err => {
console.error(err);
process.exit(1);
});
process.once('uncaughtException', err => {
console.error(err);
process.exit(1);
});
setImmediate(test);

155
.github/actions-scripts/selenium.js vendored Normal file
View file

@ -0,0 +1,155 @@
const path = require('path');
const { readFileSync, writeFileSync, mkdirSync } = require('fs');
const { once } = require('events');
const pixelmatch = require('pixelmatch');
const { PNG } = require('pngjs');
const {
Builder,
By,
Key,
until,
Capabilities,
logging,
} = require('selenium-webdriver');
const server = require('../../server');
async function test() {
let pixelDifference;
let error;
let capabilities;
switch (process.env.BROWSER) {
case 'ie':
capabilities = Capabilities.ie();
capabilities.set('ignoreProtectedModeSettings', true);
capabilities.set('ignoreZoomSetting', true);
capabilities.set('ie.options', {
enableFullPageScreenshot: true,
ensureCleanSession: true,
});
break;
case 'edge':
capabilities = Capabilities.edge();
break;
case 'safari':
capabilities = Capabilities.safari();
capabilities.set('safari.options', { technologyPreview: false });
break;
case 'firefox': {
capabilities = Capabilities.firefox().setLoggingPrefs({ browser: 'ALL' });
break;
}
case 'chrome': {
capabilities = Capabilities.chrome().setLoggingPrefs({ browser: 'ALL' });
capabilities.set('chromeOptions', {
args: ['--headless', '--no-sandbox', '--disable-gpu'],
});
break;
}
}
let driver = await new Builder().withCapabilities(capabilities).build();
if (!server.listening) await once(server, 'listening');
try {
await driver.get(`http://127.0.0.1:${server.address().port}`);
// wait for last choice to init
await driver.wait(
until.elementLocated(By.css('#reset-multiple ~ .choices__list')),
10000,
'waiting for all Choices instances to init',
);
// Resize window
await driver
.manage()
.window()
.maximize();
await driver
.manage()
.window()
// magic numbers here to make sure all demo page are fit inside
.setRect({ x: 0, y: 0, width: 630, height: 4000 });
// and click on press space on it, so it should open choices
await driver
.findElement(By.css('#reset-multiple ~ .choices__list button'))
.sendKeys(Key.SPACE);
await driver.sleep(1000);
// take screenshot
const image = await driver.takeScreenshot();
const imageBuffer = Buffer.from(image, 'base64');
const snapshotName = `${process.env.BROWSER}-${process.platform}.png`;
const artifactsPath = 'screenshot';
mkdirSync(artifactsPath, { recursive: true });
writeFileSync(path.join(artifactsPath, snapshotName), imageBuffer);
// compare with snapshot
const screenshot = PNG.sync.read(imageBuffer);
const snapshot = PNG.sync.read(
readFileSync(path.resolve(__dirname, `./__snapshots__/${snapshotName}`)),
);
const { width, height } = screenshot;
const diff = new PNG({ width, height });
pixelDifference = pixelmatch(
screenshot.data,
snapshot.data,
diff.data,
width,
height,
{
threshold: 1,
},
);
writeFileSync(path.join(artifactsPath, 'diff.png'), PNG.sync.write(diff));
// getting console logs
// ensure no errors in console (only supported in Chrome currently)
if (process.env.BROWSER === 'chrome') {
const entries = await driver
.manage()
.logs()
.get(logging.Type.BROWSER);
if (
Array.isArray(entries) &&
entries.some(entry => entry.level.name_ === 'SEVERE')
)
throw new Error(JSON.stringify(entries));
}
} catch (err) {
console.error(err);
error = err;
} finally {
await Promise.all([
driver.quit(),
new Promise(resolve => server.close(resolve)),
]);
}
if (pixelDifference > 200) {
console.error(
`Snapshot is different from screenshot by ${pixelDifference} pixels`,
);
process.exit(1);
}
if (error) process.exit(1);
}
process.on('unhandledRejection', err => {
console.error(err);
process.exit(1);
});
process.once('uncaughtException', err => {
console.error(err);
process.exit(1);
});
setImmediate(test);

29
.github/release-drafter.yml vendored Normal file
View file

@ -0,0 +1,29 @@
name-template: 'Draft (next release)'
tag-template: 'v$NEXT_PATCH_VERSION'
sort-direction: descending
exclude-labels:
- 'skip-changelog'
- 'release'
categories:
- title: '🚨 Breaking changes'
labels:
- 'breaking change'
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'bugfix'
- title: '🔧 Maintenance'
labels:
- 'chore'
- 'housekeeping'
- 'refactor'
- 'documentation'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
template: |
# Changes
$CHANGES
# Contributors
$CONTRIBUTORS

131
.github/workflows/browsers.yml vendored Normal file
View file

@ -0,0 +1,131 @@
name: Browsers
on:
pull_request:
paths:
- 'src/**'
- 'package-lock.json'
- '.browserslistrc'
- '.babelrc'
- 'webpack.config.*'
- 'public/index.html'
- '.github/actions-scripts/__snapshots__/**'
- '.github/workflows/browsers.yml'
jobs:
selenium:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
browser: [edge, firefox, safari, chrome]
exclude:
- os: windows-latest
browser: safari
- os: macos-latest
browser: edge
- os: macos-latest
browser: chrome
# Safari workaround is not working in Catalina
- browser: safari
runs-on: ${{ matrix.os }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-build-${{ matrix.browser }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
- run: |
npm ci
npm run build
env:
CYPRESS_INSTALL_BINARY: 0
HUSKY_SKIP_INSTALL: true
# install drivers
- name: Enable Safari Driver
run: |
# Workaround for `sudo safardriver --enable` not working:
# https://github.com/web-platform-tests/wpt/issues/19845
# https://github.com/web-platform-tests/wpt/blob/master/tools/ci/azure/install_safari.yml
mkdir -p ~/Library/WebDriver/
curl https://raw.githubusercontent.com/web-platform-tests/wpt/master/tools/ci/azure/com.apple.Safari.plist -o ~/Library/WebDriver/com.apple.Safari.plist
defaults write com.apple.Safari WebKitJavaScriptCanOpenWindowsAutomatically 1
# sudo safaridriver --enable
if: matrix.browser == 'safari'
- run: |
brew install --cask firefox
brew install geckodriver
if: matrix.browser == 'firefox' && matrix.os == 'macos-latest'
- run: echo "$env:GeckoWebDriver" >> $GITHUB_PATH
if: matrix.browser == 'firefox' && matrix.os == 'windows-latest'
- run: echo "$env:EdgeWebDriver" >> $GITHUB_PATH
if: matrix.browser == 'edge' && matrix.os == 'windows-latest'
- run: echo "$env:ChromeWebDriver" >> $GITHUB_PATH
if: matrix.browser == 'chrome' && matrix.os == 'windows-latest'
- run: npm i --no-optional --no-audit selenium-webdriver pixelmatch pngjs
- run: node .github/actions-scripts/selenium.js
env:
BROWSER: ${{ matrix.browser }}
PORT: 0
NODE_ENV: production # prevent watching
- uses: actions/upload-artifact@v2
if: failure()
with:
name: screenshot-${{ matrix.browser }}-${{ matrix.os }}
path: screenshot
puppeteer:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-build-puppeteer
restore-keys: |
${{ runner.OS }}-build-puppeteer
- run: |
npm ci
npm run build
env:
CYPRESS_INSTALL_BINARY: 0
HUSKY_SKIP_INSTALL: true
- run: npm i --no-optional --no-audit puppeteer pixelmatch pngjs
- run: node .github/actions-scripts/puppeteer.js
env:
PORT: 0
NODE_ENV: production # prevent watching
- uses: actions/upload-artifact@v2
if: failure()
with:
name: screenshot-puppeteer-darwin
path: screenshot

60
.github/workflows/build-and-test.yml vendored Normal file
View file

@ -0,0 +1,60 @@
name: Build and test
on:
push:
branches:
- master
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v2
with:
node-version: 18
- name: Build and run all tests
run: |
npm ci
npm run build
npx bundlesize
npm run test:unit:coverage
npm run test:e2e
env:
CI: true
CI_REPO_NAME: ${{ github.event.repository.name }}
CI_REPO_OWNER: ${{ github.event.organization.login }}
CI_COMMIT_SHA: ${{ github.sha }}
GIT_COMMIT: ${{ github.sha }}
CI_BRANCH: ${{ github.head_ref }}
BUNDLESIZE_GITHUB_TOKEN: ${{secrets.BUNDLESIZE_GITHUB_TOKEN}}
FORCE_COLOR: 2
HUSKY_SKIP_INSTALL: true
##
## Disabling for now. There does not appear to be a secure way to do this
## with protected branches. See discussion:
## https://github.community/t/how-to-push-to-protected-branches-in-a-github-action/16101
##
# - name: Commit built files
# run: |
# git config --local user.email "action@github.com"
# git config --local user.name "GitHub Action"
# git commit -m "Update build files 🏗" -a || echo "No changes to commit" && exit 0
# - name: Push changes
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)
-f ./coverage/lcov.info
-B ${{ github.head_ref }}
-C ${{ github.sha }}
-Z || echo 'Codecov upload failed'
env:
CI: true
GITLAB_CI: true # pretend we are GitLab CI, while Codecov adding support for Github Actions
CODECOV_ENV: github-action
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}

42
.github/workflows/bundlesize.yml vendored Normal file
View file

@ -0,0 +1,42 @@
name: Bundle size checks
on:
pull_request:
paths:
- 'src/scripts/**'
- 'src/styles/**'
- 'package-lock.json'
- '.browserslistrc'
jobs:
measure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v2
with:
node-version: 18
- name: Install dependencies and build
run: |
npm ci
npm run build
env:
CYPRESS_INSTALL_BINARY: 0
HUSKY_SKIP_INSTALL: true
# we don't need to build here, as even minized assets expected to be commited
- run: npx bundlesize
env:
CI: true
BUNDLESIZE_GITHUB_TOKEN: ${{secrets.BUNDLESIZE_GITHUB_TOKEN}}
CI_REPO_NAME: ${{ github.event.repository.name }}
CI_REPO_OWNER: ${{ github.event.organization.login }}
CI_COMMIT_SHA: ${{ github.event.after }}
GIT_COMMIT: ${{ github.event.after }}
CI_BRANCH: ${{ github.head_ref }}
FORCE_COLOR: 2

32
.github/workflows/deploy-pages.yml vendored Normal file
View file

@ -0,0 +1,32 @@
name: Deploy Pages
on:
release:
types: [published]
workflow_dispatch:
jobs:
deploy-gh-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v2
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- name: Build
run: |
npm ci
npm run build
rm -rf public/test
env:
CYPRESS_INSTALL_BINARY: 0
HUSKY_SKIP_INSTALL: true
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public

24
.github/workflows/deployment.yml vendored Normal file
View file

@ -0,0 +1,24 @@
name: Publish to npm
on:
release:
types: [published]
jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v2
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
env:
CYPRESS_INSTALL_BINARY: 0
HUSKY_SKIP_INSTALL: true
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

71
.github/workflows/e2e-tests.yml vendored Normal file
View file

@ -0,0 +1,71 @@
name: End-to-end tests
on:
pull_request:
paths:
- 'src/**'
- 'package-lock.json'
- '.browserslistrc'
- '.babelrc'
- 'webpack.config.*'
- 'public/test/**'
- 'cypress/**'
- '.github/workflows/e2e-tests.yml'
jobs:
test-e2e:
runs-on: ubuntu-latest
env:
CI: true
TERM: xterm-256color
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Get Cypress info
id: cypress-info
run: |
echo ::set-output name=version::$(jq -r .devDependencies.cypress ./package.json)
echo ::set-output name=cache::$(npx cypress cache path)
env:
CYPRESS_INSTALL_BINARY: 0
- name: Cache Cypress cache
uses: actions/cache@v2
with:
path: ${{ steps.cypress-info.outputs.cache }}
key: ${{ runner.OS }}-cypress-${{ steps.cypress-info.outputs.version }}
restore-keys: |
${{ runner.OS }}-cypress-${{ steps.cypress-info.outputs.version }}
- name: Install dependencies
run: npm ci
env:
HUSKY_SKIP_INSTALL: true
- name: run Cypress (with or without recording)
# if we have ran out of free Cypress recordings, run Cypress with recording switched off
run: npm exec -- run-p --race start cypress:ci || npm exec -- run-p --race start cypress:run
env:
NODE_ENV: production # prevent watching
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
DEBUG: commit-info,cypress:server:record
# https://docs.cypress.io/guides/guides/continuous-integration.html#Environment-variables
COMMIT_INFO_BRANCH: ${{ github.head_ref }}
COMMIT_INFO_AUTHOR: ${{ github.event.sender.login }}
COMMIT_INFO_SHA: ${{ github.event.after }}

41
.github/workflows/lint.yml vendored Normal file
View file

@ -0,0 +1,41 @@
name: Code linting
on:
pull_request:
paths:
- 'src/scripts/**'
- 'src/styles/**'
- package-lock.json
- '.browserslistrc'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v2
with:
node-version: 18
- name: Install dependencies
run: npm ci
env:
CYPRESS_INSTALL_BINARY: 0
HUSKY_SKIP_INSTALL: true
- name: run eslint
run: npm run lint:js
## Can't use same eslint config for TypeScript and JavaScript
## TypeScript rules cause rule definition not found errors
## Can be re-enabled if this is resolved: https://github.com/eslint/eslint/issues/14851
# - name: Lint JS bundle
# run: |
# npm run js:build
# npx eslint --no-ignore ./public/assets/scripts/*.js
- name: run stylelint
run: npm run lint:scss

23
.github/workflows/polyfills-sync.yml vendored Normal file
View file

@ -0,0 +1,23 @@
name: Polyfills documentation
on:
pull_request:
paths:
- 'README.md'
- '.browserslistrc'
- '.eslintrc.json'
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v2
with:
node-version: 18
- name: Check Polyfills documentation and settings sync
run: node .github/actions-scripts/polyfills-sync.js

14
.github/workflows/release-drafter.yml vendored Normal file
View file

@ -0,0 +1,14 @@
name: Release drafter
on:
push:
branches:
- master
jobs:
update-draft-release:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

42
.github/workflows/unit-tests.yml vendored Normal file
View file

@ -0,0 +1,42 @@
name: Unit tests
on:
pull_request:
paths:
- 'src/scripts/**'
- package-lock.json
- '.browserslistrc'
jobs:
test-unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v2
with:
node-version: 18
- name: Install dependencies
run: npm install --no-optional --no-audit --ignore-scripts
env:
CYPRESS_INSTALL_BINARY: 0
HUSKY_SKIP_INSTALL: true
- run: npm run test:unit:coverage
env:
FORCE_COLOR: 2
- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)
-f ./coverage/lcov.info
-B ${{ github.head_ref }}
-C ${{ github.sha }}
-Z || echo 'Codecov upload failed'
env:
CI: true
GITLAB_CI: true # pretend we are GitLab CI, while Codecov adding support for Github Actions
CODECOV_ENV: github-action
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}

7
.gitignore vendored
View file

@ -1,7 +1,12 @@
node_modules
npm-debug.log
.DS_Store
.idea
# Test
tests/reports
tests/results
tests/results
.nyc_output
coverage
cypress/videos
cypress/screenshots

6
.huskyrc Normal file
View file

@ -0,0 +1,6 @@
{
"skipCI": true,
"hooks": {
"pre-commit": "lint-staged"
}
}

8
.mocharc.yml Normal file
View file

@ -0,0 +1,8 @@
require:
- 'ts-node/register'
- './config/jsdom.js'
exit: true
spec: src/**/**/*.test.ts
extension:
- ts
- js

2
.npmrc Normal file
View file

@ -0,0 +1,2 @@
message=":bookmark: Version %s"
git-tag-version=true

1
.nvmrc Normal file
View file

@ -0,0 +1 @@
v12.13.1

20
.prettierrc.json Normal file
View file

@ -0,0 +1,20 @@
{
"singleQuote": true,
"trailingComma": "all",
"endOfLine": "lf",
"overrides": [
{
"files": ["*.svg"],
"options": {
"parser": "html",
"htmlWhitespaceSensitivity": "ignore"
}
},
{
"files": ["public/*.html"],
"options": {
"trailingComma": "es5"
}
}
]
}

6
.stylelintrc.json Normal file
View file

@ -0,0 +1,6 @@
{
"extends": "stylelint-config-standard-scss",
"rules": {
"declaration-block-no-redundant-longhand-properties": null
}
}

View file

@ -1,9 +0,0 @@
language: node_js
node_js:
- "0.10"
before_install:
- '[ "${TRAVIS_NODE_VERSION}" != "0.8" ] || npm install -g npm@1.4.28'
- npm install -g npm@latest
install:
- npm install
script: npm run js:test

17
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,17 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
// we enforce ESLint rules, so, recommend extension
"dbaeumer.vscode-eslint",
// we use prettier, so, recommend extension
"esbenp.prettier-vscode",
// we are on GitHub, so, recommend extension
"github.vscode-pull-request-github",
// needed for our configured debug configuration with Chrome
"msjsdiag.debugger-for-chrome"
// Mocha recommended - https://mochajs.org/#mocha-sidebar-vs-code,
// but it's buggy
// "maty.vscode-mocha-sidebar"
]
}

70
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,70 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"preLaunchTask": "buildAndWatch",
"url": "http://localhost:3001",
"webRoot": "${workspaceFolder}",
"sourceMapPathOverrides": {
"webpack://Choices/*": "${workspaceFolder}/*"
}
},
{
"type": "node",
"request": "launch",
"name": "Mocha Current File",
"program": "${workspaceFolder}/node_modules/mocha/bin/mocha",
"args": ["-u", "bdd", "--timeout", "999999", "--colors", "${file}"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"env": {
"NODE_ENV": "test"
}
},
{
"type": "node",
"request": "launch",
"name": "Mocha All",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": ["-u", "bdd", "--timeout", "999999", "--colors"],
"console": "integratedTerminal",
"internalConsoleOptions": "openOnSessionStart",
"env": {
"NODE_ENV": "test"
}
},
{
"type": "node",
"request": "launch",
"name": "Cypress Current File",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/cypress",
"windows": {
"runtimeExecutable": "${workspaceFolder}\\node_modules\\.bin\\cypress.cmd"
},
"runtimeArgs": [
"run",
"--headed",
"--no-exit",
"--browser=electron",
"--port",
"9898",
"--spec"
],
"protocol": "legacy",
"port": 9898,
"program": "${file}",
"console": "integratedTerminal",
"preLaunchTask": "buildAndWatch",
"internalConsoleOptions": "openOnSessionStart",
"timeout": 999999999999999,
"autoAttachChildProcesses": false,
"env": {
"NODE_ENV": "test"
// "DEBUG": "cypress:*"
}
}
]
}

72
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,72 @@
{
"eslint.enable": true,
// prevent watch task failures on lint errors
"eslint.autoFixOnSave": true,
// switch off default VSCode formatting rules
"javascript.format.enable": false,
// Javascript prettier runs via ESLint
"prettier.disableLanguages": ["javascript"],
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.formatOnSave": false
},
"search.exclude": {
"**/node_modules": true,
"public/assets": true,
"**/coverage": true
},
// Mocha Sidebar settings
"mocha.env": {
"NODE_ENV": "test"
},
"mocha.files.glob": "src/scripts/**/*.test.js",
"mocha.requires": ["@babel/register", "./config/jsdom.js"],
// for Windows collaborators
"files.eol": "\n",
"files.encoding": "utf8",
// associations for some files this project is using
"files.associations": {
".browserslistrc": "gitignore",
".huskyrc": "jsonc",
".npmrc": "ini"
},
// We use NPM as package manager
"npm.packageManager": "npm",
"npm.autoDetect": "on",
"npm.fetchOnlinePackageInfo": true,
"eslint.packageManager": "npm",
"json.schemas": [
// Cypress related settings - https://docs.cypress.io/guides/tooling/intelligent-code-completion.html#Features-1
{
"fileMatch": ["cypress.json"],
"url": "https://on.cypress.io/cypress.schema.json"
},
// Husky config file
{
"fileMatch": [".huskyrc"],
"url": "http://json.schemastore.org/huskyrc"
},
// Prettier config
{
"fileMatch": [".prettierrc.json"],
"url": "http://json.schemastore.org/prettierrc"
}
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"stylelint.validate": [
"css",
"less",
"postcss",
"scss"
]
}

87
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,87 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"label": "buildAndWatch",
"script": "js:watch",
"group": {
"kind": "build",
"isDefault": true
},
"isBackground": true,
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true,
"clear": false
},
"problemMatcher": [
"$eslint-stylish",
{
"owner": "webpack",
"fileLocation": "absolute",
"pattern": [
{
"regexp": "^Module build failed \\(from (\\.+)\\)",
"file": 1,
"line": 2,
"column": 3
},
{
"regexp": "\\s*TS\\d+:\\s*(.*)",
"message": 1
}
],
"severity": "error",
"source": "webpack",
"background": {
"activeOnStart": true,
"beginsPattern": "^Listening at",
"endsPattern": "Compiled successfully\\."
}
}
]
},
{
"type": "npm",
"script": "css:build",
"group": "build",
"problemMatcher": ["$node-sass"]
},
{
"type": "npm",
"script": "lint",
"problemMatcher": ["$eslint-stylish"]
},
{
"type": "npm",
"script": "build",
"group": "build"
},
{
"type": "npm",
"script": "test",
"group": "test"
},
{
"type": "npm",
"script": "test:e2e",
"group": "test"
},
{
"type": "npm",
"script": "test:unit",
"group": "test"
},
{
"type": "npm",
"script": "cypress:open",
"isBackground": true
}
]
}

46
CODE_OF_CONDUCT.md Normal file
View file

@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at josh@joshuajohnson.co.uk. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

24
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,24 @@
# Contributions
In lieu of a formal styleguide, take care to maintain the existing coding style ensuring there are no linting errors. Add unit tests for any new or changed functionality. Lint and test your code using the npm scripts below:
### NPM tasks
| Task | Usage |
| -------------------- | ------------------------------------------------------------ |
| `npm run start` | Fire up local server for development |
| `npm run test:unit` | Run sequence of unit tests once |
| `npm run test:e2e` | Run sequence of integration tests once |
| `npm run test:watch` | Fire up test server and re-test on file change |
| `npm run js:build` | Compile Choices to an uglified JavaScript file |
| `npm run css:watch` | Watch SCSS files for changes. On a change, run build process |
| `npm run css:build` | Compile, minify and prefix SCSS files to CSS |
## Pull requests
When submitting a pull request that resolves a bug, feel free to use the following template:
```md
## This is the problem:
## Steps to reproduce:
## This is my solution:
```

944
README.md

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
{"version":3,"file":"choices.min.js","sources":[],"mappings":";;","sourceRoot":""}

View file

@ -1,73 +0,0 @@
export const addItem = (value, label, id, choiceId, groupId) => {
return {
type: 'ADD_ITEM',
value,
label,
id,
choiceId,
groupId,
};
};
export const removeItem = (id, choiceId) => {
return {
type: 'REMOVE_ITEM',
id,
choiceId,
};
};
export const highlightItem = (id, highlighted) => {
return {
type: 'HIGHLIGHT_ITEM',
id,
highlighted,
};
};
export const addChoice = (value, label, id, groupId, disabled) => {
return {
type: 'ADD_CHOICE',
value,
label,
id,
groupId,
disabled,
};
};
export const filterChoices = (results) => {
return {
type: 'FILTER_CHOICES',
results,
};
};
export const activateChoices = (active = true) => {
return {
type: 'ACTIVATE_CHOICES',
active,
};
};
export const clearChoices = () => {
return {
type: 'CLEAR_CHOICES',
};
};
export const addGroup = (value, id, active, disabled) => {
return {
type: 'ADD_GROUP',
value,
id,
active,
disabled,
};
};
export const clearAll = () => {
return {
type: 'CLEAR_ALL',
};
};

File diff suppressed because it is too large Load diff

View file

@ -1,129 +0,0 @@
/* eslint-disable */
(function () {
// Production steps of ECMA-262, Edition 6, 22.1.2.1
// Reference: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from
if (!Array.from) {
Array.from = (function() {
var toStr = Object.prototype.toString;
var isCallable = function(fn) {
return typeof fn === 'function' || toStr.call(fn) === '[object Function]';
};
var toInteger = function(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number === 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
// The length property of the from method is 1.
return function from(arrayLike /*, mapFn, thisArg */ ) {
// 1. Let C be the this value.
var C = this;
// 2. Let items be ToObject(arrayLike).
var items = Object(arrayLike);
// 3. ReturnIfAbrupt(items).
if (arrayLike == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
}
// 4. If mapfn is undefined, then let mapping be false.
var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
var T;
if (typeof mapFn !== 'undefined') {
// 5. else
// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
// 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (arguments.length > 2) {
T = arguments[2];
}
}
// 10. Let lenValue be Get(items, "length").
// 11. Let len be ToLength(lenValue).
var len = toLength(items.length);
// 13. If IsConstructor(C) is true, then
// 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len.
// 14. a. Else, Let A be ArrayCreate(len).
var A = isCallable(C) ? Object(new C(len)) : new Array(len);
// 16. Let k be 0.
var k = 0;
// 17. Repeat, while k < len… (also steps a - h)
var kValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k += 1;
}
// 18. Let putStatus be Put(A, "length", len, true).
A.length = len;
// 20. Return A.
return A;
};
}());
}
// Reference: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find
if (!Array.prototype.find) {
Array.prototype.find = function(predicate) {
'use strict';
if (this == null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
}
}
return undefined;
};
}
function CustomEvent (event, params) {
params = params || {
bubbles: false,
cancelable: false,
detail: undefined
};
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype = window.Event.prototype;
window.CustomEvent = CustomEvent;
})();

View file

@ -1,506 +0,0 @@
/* eslint-disable */
/**
* Capitalises the first letter of each word in a string
* @param {String} str String to capitalise
* @return {String} Capitalised string
*/
export const capitalise = function(str) {
return str.replace(/\w\S*/g, function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
};
/**
* Tests the type of an object
* @param {String} type Type to test object against
* @param {Object} obj Object to be tested
* @return {Boolean}
*/
export const isType = function(type, obj) {
var clas = Object.prototype.toString.call(obj).slice(8, -1);
return obj !== undefined && obj !== null && clas === type;
};
/**
* Tests to see if a passed object is a node
* @param {Object} obj Object to be tested
* @return {Boolean}
*/
export const isNode = (o) => {
return (
typeof Node === "object" ? o instanceof Node :
o && typeof o === "object" && typeof o.nodeType === "number" && typeof o.nodeName === "string"
);
};
/**
* Tests to see if a passed object is an element
* @param {Object} obj Object to be tested
* @return {Boolean}
*/
export const isElement = (o) => {
return (
typeof HTMLElement === "object" ? o instanceof HTMLElement : //DOM2
o && typeof o === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string"
);
};
/**
* Merges unspecified amount of objects into new object
* @private
* @return {Object} Merged object of arguments
*/
export const extend = function() {
let extended = {};
let length = arguments.length;
/**
* Merge one object into another
* @param {Object} obj Object to merge into extended object
*/
let merge = function(obj) {
for (let prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
// If deep merge and property is an object, merge properties
if (isType('Object', obj[prop])) {
extended[prop] = extend(true, extended[prop], obj[prop]);
} else {
extended[prop] = obj[prop];
}
}
}
};
// Loop through each passed argument
for (let i = 0; i < length; i++) {
// store argument at position i
let obj = arguments[i];
// If we are in fact dealing with an object, merge it.
if (isType('Object', obj)) {
merge(obj);
}
}
return extended;
};
/**
* CSS transition end event listener
* @return
*/
export const whichTransitionEvent = function() {
var t,
el = document.createElement("fakeelement");
var transitions = {
"transition": "transitionend",
"OTransition": "oTransitionEnd",
"MozTransition": "transitionend",
"WebkitTransition": "webkitTransitionEnd"
}
for (t in transitions) {
if (el.style[t] !== undefined) {
return transitions[t];
}
}
};
/**
* CSS animation end event listener
* @return
*/
export const whichAnimationEvent = function() {
var t,
el = document.createElement('fakeelement');
var animations = {
'animation': 'animationend',
'OAnimation': 'oAnimationEnd',
'MozAnimation': 'animationend',
'WebkitAnimation': 'webkitAnimationEnd'
};
for (t in animations) {
if (el.style[t] !== undefined) {
return animations[t];
}
}
};
/**
* Get the ancestors of each element in the current set of matched elements,
* up to but not including the element matched by the selector
* @param {NodeElement} elem Element to begin search from
* @param {NodeElement} parent Parent to find
* @param {String} selector Class to find
* @return {Array} Array of parent elements
*/
export const getParentsUntil = function(elem, parent, selector) {
var parents = [];
// Get matches
for (; elem && elem !== document; elem = elem.parentNode) {
// Check if parent has been reached
if (parent) {
var parentType = parent.charAt(0);
// If parent is a class
if (parentType === '.') {
if (elem.classList.contains(parent.substr(1))) {
break;
}
}
// If parent is an ID
if (parentType === '#') {
if (elem.id === parent.substr(1)) {
break;
}
}
// If parent is a data attribute
if (parentType === '[') {
if (elem.hasAttribute(parent.substr(1, parent.length - 1))) {
break;
}
}
// If parent is a tag
if (elem.tagName.toLowerCase() === parent) {
break;
}
}
if (selector) {
var selectorType = selector.charAt(0);
// If selector is a class
if (selectorType === '.') {
if (elem.classList.contains(selector.substr(1))) {
parents.push(elem);
}
}
// If selector is an ID
if (selectorType === '#') {
if (elem.id === selector.substr(1)) {
parents.push(elem);
}
}
// If selector is a data attribute
if (selectorType === '[') {
if (elem.hasAttribute(selector.substr(1, selector.length - 1))) {
parents.push(elem);
}
}
// If selector is a tag
if (elem.tagName.toLowerCase() === selector) {
parents.push(elem);
}
} else {
parents.push(elem);
}
}
// Return parents if any exist
if (parents.length === 0) {
return null;
} else {
return parents;
}
};
export const wrap = function(element, wrapper) {
wrapper = wrapper || document.createElement('div');
if (element.nextSibling) {
element.parentNode.insertBefore(wrapper, element.nextSibling);
} else {
element.parentNode.appendChild(wrapper);
}
return wrapper.appendChild(element);
};
export const getSiblings = function(elem) {
var siblings = [];
var sibling = elem.parentNode.firstChild;
for (; sibling; sibling = sibling.nextSibling) {
if (sibling.nodeType === 1 && sibling !== elem) {
siblings.push(sibling);
}
}
return siblings;
};
/**
* Find ancestor in DOM tree
* @param {NodeElement} el Element to start search from
* @param {[type]} cls Class of parent
* @return {NodeElement} Found parent element
*/
export const findAncestor = function(el, cls) {
while ((el = el.parentElement) && !el.classList.contains(cls));
return el;
};
/**
* Debounce an event handler.
* @param {Function} func Function to run after wait
* @param {Number} wait The delay before the function is executed
* @param {Boolean} immediate If passed, trigger the function on the leading edge, instead of the trailing.
* @return {Function} A function will be called after it stops being called for a given delay
*/
export const debounce = function(func, wait, immediate) {
var timeout;
return function() {
var context = this,
args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
/**
* Get an element's distance from the top of the page
* @private
* @param {NodeElement} el Element to test for
* @return {Number} Elements Distance from top of page
*/
export const getElemDistance = function(el) {
var location = 0;
if (el.offsetParent) {
do {
location += el.offsetTop;
el = el.offsetParent;
} while (el);
}
return location >= 0 ? location : 0;
};
/**
* Determine element height multiplied by any offsets
* @private
* @param {HTMLElement} el Element to test for
* @return {Number} Height of element
*/
export const getElementOffset = function(el, offset) {
var elOffset = offset;
if (elOffset > 1) elOffset = 1;
if (elOffset > 0) elOffset = 0;
return Math.max(el.offsetHeight * elOffset);
};
/**
* Get the next or previous element from a given start point
* @param {HTMLElement} startEl Element to start position from
* @param {String} className The class we will look through
* @param {Number} direction Positive next element, negative previous element
* @return {[HTMLElement} Found element
*/
export const getAdjacentEl = (startEl, className, direction = 1) => {
if (!startEl || !className) return;
const parent = startEl.parentNode.parentNode;
const children = Array.from(parent.querySelectorAll(className));
const startPos = children.indexOf(startEl);
const operatorDirection = direction > 0 ? 1 : -1;
return children[startPos + operatorDirection];
};
/**
* Get scroll position based on top/bottom position
* @private
* @return {String} Position of scroll
*/
export const getScrollPosition = function(position) {
if (position === 'bottom') {
// Scroll position from the bottom of the viewport
return Math.max((window.scrollY || window.pageYOffset) + (window.innerHeight || document.documentElement.clientHeight));
} else {
// Scroll position from the top of the viewport
return (window.scrollY || window.pageYOffset);
}
};
/**
* Determine whether an element is within the viewport
* @param {HTMLElement} el Element to test
* @return {String} Position of scroll
* @return {Boolean}
*/
export const isInView = function(el, position, offset) {
// If the user has scrolled further than the distance from the element to the top of its parent
return this.getScrollPosition(position) > (this.getElemDistance(el) + this.getElementOffset(el, offset)) ? true : false;
};
/**
* Determine whether an element is within
* @param {HTMLElement} el Element to test
* @param {HTMLElement} parent Scrolling parent
* @param {Number} direction Whether element is visible from above or below
* @return {Boolean}
*/
export const isScrolledIntoView = (el, parent, direction = 1) => {
if (!el) return;
let isVisible;
if (direction > 0) {
// In view from bottom
isVisible = (parent.scrollTop + parent.offsetHeight) >= (el.offsetTop + el.offsetHeight);
} else {
// In view from top
isVisible = el.offsetTop >= parent.scrollTop;
}
return isVisible;
};
/**
* Remove html tags from a string
* @param {String} Initial string/html
* @return {String} Sanitised string
*/
export const stripHTML = function(html) {
let el = document.createElement("DIV");
el.innerHTML = html;
return el.textContent || el.innerText || "";
};
/**
* Adds animation to an element and removes it upon animation completion
* @param {Element} el Element to add animation to
* @param {String} animation Animation class to add to element
* @return
*/
export const addAnimation = (el, animation) => {
let animationEvent = whichAnimationEvent();
let removeAnimation = () => {
el.classList.remove(animation);
el.removeEventListener(animationEvent, removeAnimation, false);
};
el.classList.add(animation);
el.addEventListener(animationEvent, removeAnimation, false);
};
/**
* Get a random number between a range
* @param {Number} min Minimum range
* @param {Number} max Maximum range
* @return {Number} Random number
*/
export const getRandomNumber = function(min, max) {
return Math.floor(Math.random() * (max - min) + min);
};
/**
* Turn a string into a node
* @param {String} String to convert
* @return {HTMLElement} Converted node element
*/
export const strToEl = (function() {
var tmpEl = document.createElement('div');
return function(str) {
var r;
tmpEl.innerHTML = str;
r = tmpEl.children[0];
while (tmpEl.firstChild) {
tmpEl.removeChild(tmpEl.firstChild);
}
return r;
};
}());
/**
* Sets the width of a passed input based on its value
* @return {Number} Width of input
*/
export const getWidthOfInput = (input) => {
const value = input.value || input.placeholder;
let width = input.offsetWidth;
if (value) {
const testEl = strToEl(`<span>${ value }</span>`);
testEl.style.position = 'absolute';
testEl.style.padding = '0';
testEl.style.top = '-9999px';
testEl.style.left = '-9999px';
testEl.style.width = 'auto';
testEl.style.whiteSpace = 'pre';
document.body.appendChild(testEl);
if (value && testEl.offsetWidth !== input.offsetWidth) {
width = testEl.offsetWidth + 4;
}
document.body.removeChild(testEl);
}
return `${width}px`;
};
/**
* Sorting function for current and previous string
* @param {String} a Current value
* @param {String} b Next value
* @return {Number} -1 for after previous,
* 1 for before,
* 0 for same location
*/
export const sortByAlpha = (a, b) => {
const labelA = (a.label || a.value).toLowerCase();
const labelB = (b.label || b.value).toLowerCase();
if (labelA < labelB) return -1;
if (labelA > labelB) return 1;
return 0;
};
/**
* Sort by numeric score
* @param {Object} a Current value
* @param {Object} b Next value
* @return {Number} -1 for after previous,
* 1 for before,
* 0 for same location
*/
export const sortByScore = (a, b) => {
return a.score - b.score;
};
/**
* Trigger native event
* @param {NodeElement} element Element to trigger event on
* @param {String} type Type of event to trigger
* @param {Object} customArgs Data to pass with event
* @return {Object} Triggered event
*/
export const triggerEvent = (element, type, customArgs = null) => {
const event = new CustomEvent(type, {
detail: customArgs,
bubbles: true,
cancelable: true
});
return element.dispatchEvent(event);
};

View file

@ -1,97 +0,0 @@
const choices = (state = [], action) => {
switch (action.type) {
case 'ADD_CHOICE': {
/*
A disabled choice appears in the choice dropdown but cannot be selected
A selected choice has been added to the passed input's value (added as an item)
An active choice appears within the choice dropdown
*/
return [...state, {
id: action.id,
groupId: action.groupId,
value: action.value,
label: action.label,
disabled: action.disabled,
selected: false,
active: true,
score: 9999,
}];
}
case 'ADD_ITEM': {
let newState = state;
// If all choices need to be activated
if (action.activateOptions) {
newState = state.map((choice) => {
choice.active = action.active;
return choice;
});
}
// When an item is added and it has an associated choice,
// we want to disable it so it can't be chosen again
if (action.choiceId > -1) {
newState = state.map((choice) => {
if (choice.id === parseInt(action.choiceId, 10)) {
choice.selected = true;
}
return choice;
});
}
return newState;
}
case 'REMOVE_ITEM': {
// When an item is removed and it has an associated choice,
// we want to re-enable it so it can be chosen again
if (action.choiceId > -1) {
return state.map((choice) => {
if (choice.id === parseInt(action.choiceId, 10)) {
choice.selected = false;
}
return choice;
});
}
return state;
}
case 'FILTER_CHOICES': {
const filteredResults = action.results;
const filteredState = state.map((choice) => {
// Set active state based on whether choice is
// within filtered results
choice.active = filteredResults.some((result) => {
if (result.item.id === choice.id) {
choice.score = result.score;
return true;
}
return false;
});
return choice;
});
return filteredState;
}
case 'ACTIVATE_CHOICES': {
return state.map((choice) => {
choice.active = action.active;
return choice;
});
}
case 'CLEAR_CHOICES': {
return state.choices = [];
}
default: {
return state;
}
}
};
export default choices;

View file

@ -1,22 +0,0 @@
const groups = (state = [], action) => {
switch (action.type) {
case 'ADD_GROUP': {
return [...state, {
id: action.id,
value: action.value,
active: action.active,
disabled: action.disabled,
}];
}
case 'CLEAR_CHOICES': {
return state.groups = [];
}
default: {
return state;
}
}
};
export default groups;

View file

@ -1,48 +0,0 @@
const items = (state = [], action) => {
switch (action.type) {
case 'ADD_ITEM': {
// Add object to items array
const newState = [...state, {
id: action.id,
choiceId: action.choiceId,
groupId: action.groupId,
value: action.value,
label: action.label,
active: true,
highlighted: false,
}];
return newState.map((item) => {
if (item.highlighted) {
item.highlighted = false;
}
return item;
});
}
case 'REMOVE_ITEM': {
// Set item to inactive
return state.map((item) => {
if (item.id === action.id) {
item.active = false;
}
return item;
});
}
case 'HIGHLIGHT_ITEM': {
return state.map((item) => {
if (item.id === action.id) {
item.highlighted = action.highlighted;
}
return item;
});
}
default: {
return state;
}
}
};
export default items;

View file

@ -1,164 +0,0 @@
import { createStore } from 'redux';
import rootReducer from './../reducers/index.js';
export default class Store {
constructor() {
this.store = createStore(
rootReducer
, window.devToolsExtension ? window.devToolsExtension() : undefined
);
}
/**
* Get store object (wrapping Redux method)
* @return {Object} State
*/
getState() {
return this.store.getState();
}
/**
* Dispatch event to store (wrapped Redux method)
* @param {Function} action Action function to trigger
* @return
*/
dispatch(action) {
this.store.dispatch(action);
}
/**
* Subscribe store to function call (wrapped Redux method)
* @param {Function} onChange Function to trigger when state changes
* @return
*/
subscribe(onChange) {
this.store.subscribe(onChange);
}
/**
* Get items from store
* @return {Array} Item objects
*/
getItems() {
const state = this.store.getState();
return state.items;
}
/**
* Get active items from store
* @return {Array} Item objects
*/
getItemsFilteredByActive() {
const items = this.getItems();
const values = items.filter((item) => {
return item.active === true;
}, []);
return values;
}
/**
* Get items from store reduced to just their values
* @return {Array} Item objects
*/
getItemsReducedToValues(items = this.getItems()) {
const values = items.reduce((prev, current) => {
prev.push(current.value);
return prev;
}, []);
return values;
}
/**
* Get choices from store
* @return {Array} Option objects
*/
getChoices() {
const state = this.store.getState();
return state.choices;
}
/**
* Get active choices from store
* @return {Array} Option objects
*/
getChoicesFilteredByActive() {
const choices = this.getChoices();
const values = choices.filter((choice) => {
return choice.active === true;
}, []);
return values;
}
/**
* Get selectable choices from store
* @return {Array} Option objects
*/
getChoicesFilteredBySelectable() {
const choices = this.getChoices();
const values = choices.filter((choice) => {
return choice.disabled !== true;
}, []);
return values;
}
/**
* Get single choice by it's ID
* @return {Object} Found choice
*/
getChoiceById(id) {
if (id) {
const choices = this.getChoicesFilteredByActive();
const foundChoice = choices.find((choice) => choice.id === parseInt(id, 10));
return foundChoice;
}
return false;
}
/**
* Get groups from store
* @return {Array} Group objects
*/
getGroups() {
const state = this.store.getState();
return state.groups;
}
/**
* Get active groups from store
* @return {Array} Group objects
*/
getGroupsFilteredByActive() {
const groups = this.getGroups();
const choices = this.getChoices();
const values = groups.filter((group) => {
const isActive = group.active === true && group.disabled === false;
const hasActiveOptions = choices.some((choice) => {
return choice.active === true && choice.disabled === false;
});
return isActive && hasActiveOptions;
}, []);
return values;
}
/**
* Get group by group id
* @param {Number} id Group ID
* @return {Object} Group data
*/
getGroupById(id) {
const groups = this.getGroups();
const foundGroup = groups.find((group) => {
return group.id === id;
});
return foundGroup;
}
}
module.exports = Store;

View file

@ -1 +0,0 @@
*{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}*,:after,:before{box-sizing:border-box}body,html{position:relative;margin:0;width:100%;height:100%}body{font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;font-size:16px;line-height:1.4;color:#fff;background-color:#333;overflow-x:hidden}hr,label{display:block}label{margin-bottom:8px;font-size:14px;font-weight:500;cursor:pointer}p{margin-top:0}hr{margin:36px 0;border:0;border-bottom:1px solid #eaeaea;height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:12px;font-weight:400;line-height:1.2}a,a:focus,a:visited{color:#fff;text-decoration:none;font-weight:600}.form-control{display:block;width:100%;background-color:#f9f9f9;padding:12px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;-webkit-appearance:none;-moz-appearance:none;appearance:none;margin-bottom:24px}.h1,h1{font-size:32px}.h2,h2{font-size:24px}.h3,h3{font-size:20px}.h4,h4{font-size:18px}.h5,h5{font-size:16px}.h6,h6{font-size:14px}.container{display:block;margin:auto;max-width:40em;padding:48px}@media (max-width:620px){.container{padding:0}}.section{background-color:#fff;padding:24px;color:#333}.section a,.section a:focus,.section a:visited{color:#00bcd4}.logo{display:block;margin-bottom:12px}.logo__img{width:100%;height:auto;display:inline-block;max-width:100%;vertical-align:top;padding:6px 0}.visible-ie{display:none}

File diff suppressed because one or more lines are too long

View file

@ -1,122 +0,0 @@
$global-guttering: 24px;
$global-font-size-h1: 32px;
$global-font-size-h2: 24px;
$global-font-size-h3: 20px;
$global-font-size-h4: 18px;
$global-font-size-h5: 16px;
$global-font-size-h6: 14px;
/*=============================================
= Generic styling =
=============================================*/
* {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale
}
*, *:before, *:after {
box-sizing: border-box
}
html, body {
position: relative;
margin: 0;
width: 100%;
height: 100%;
}
body {
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-size: 16px;
line-height: 1.4;
color: #FFFFFF;
background-color: #333;
overflow-x: hidden;
}
label {
display: block;
margin-bottom: 8px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
}
p { margin-top: 0; }
hr {
display: block;
margin: $global-guttering*1.5 0;
border: 0;
border-bottom: 1px solid #eaeaea;
height: 1px;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: $global-guttering/2;
font-weight: 400;
line-height: 1.2;
}
a, a:visited, a:focus {
color: #FFFFFF;
text-decoration: none;
font-weight: 600;
}
.form-control {
display: block;
width: 100%;
background-color: #f9f9f9;
padding: 12px;
border: 1px solid #ddd;
border-radius: 2.5px;
font-size: 14px;
-webkit-appearance: none;
appearance: none;
margin-bottom: $global-guttering;
}
h1, .h1 { font-size: $global-font-size-h1; }
h2, .h2 { font-size: $global-font-size-h2; }
h3, .h3 { font-size: $global-font-size-h3; }
h4, .h4 { font-size: $global-font-size-h4; }
h5, .h5 { font-size: $global-font-size-h5; }
h6, .h6 { font-size: $global-font-size-h6; }
.container {
display: block;
margin: auto;
max-width: 40em;
padding: $global-guttering*2;
@media (max-width: 620px) { padding: 0; }
}
.section {
background-color: #FFFFFF;
padding: $global-guttering;
color: #333;
a, a:visited, a:focus { color: #00bcd4; }
}
.logo {
display: block;
margin-bottom: $global-guttering/2;
}
.logo__img {
width: 100%;
height: auto;
display: inline-block;
max-width: 100%;
vertical-align: top;
padding: $global-guttering/4 0;
}
.visible-ie { display: none; }
/*===== End of Section comment block ======*/

View file

@ -1,29 +0,0 @@
{
"name": "choices.js",
"version": "2.7.1",
"description": "A vanilla JS customisable text input/select box plugin",
"main": [
"./assets/scripts/dist/choices.js",
"./assets/styles/css/choices.css"
],
"authors": [
"Josh Johnson"
],
"license": "MIT",
"homepage": "https://joshuajohnson.co.uk/Choices/",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"keywords": [
"customisable",
"input",
"select",
"vanilla",
"plugin",
"js"
]
}

50
config/jsdom.js Normal file
View file

@ -0,0 +1,50 @@
/* eslint-disable no-param-reassign */
const { JSDOM } = require('jsdom');
const jsdom = new JSDOM(
'<!doctype html><html><head><meta charset="utf-8"></head><body></body></html>',
{
pretendToBeVisual: true,
},
);
const { window } = jsdom;
function copyProps(src, target) {
const props = Object.getOwnPropertyNames(src)
.filter(prop => typeof target[prop] === 'undefined')
.map(prop => Object.getOwnPropertyDescriptor(src, prop));
Object.defineProperties(target, props);
}
function ignoreExtensions(extensions = [], returnValue = {}) {
function noop() {
return returnValue;
}
extensions.forEach(ext => {
require.extensions[ext] = noop;
});
}
global.window = window;
global.document = window.document;
global.navigator = {
userAgent: 'node.js',
};
global.CustomEvent = window.CustomEvent;
global.Element = window.Element;
global.HTMLElement = window.HTMLElement;
global.Option = window.Option;
global.HTMLOptionElement = window.HTMLOptionElement;
global.HTMLOptGroupElement = window.HTMLOptGroupElement;
global.HTMLSelectElement = window.HTMLSelectElement;
global.HTMLInputElement = window.HTMLInputElement;
global.DocumentFragment = window.DocumentFragment;
global.requestAnimationFrame = window.requestAnimationFrame;
window.matchMedia = () => true;
copyProps(window, global);
ignoreExtensions(['.scss', '.css']);
ignoreExtensions(['.jpg', '.png', '.svg'], '');

15
cypress.config.ts Normal file
View file

@ -0,0 +1,15 @@
import { defineConfig } from 'cypress'
export default defineConfig({
video: false,
projectId: 'n7g5qp',
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'http://localhost:3001/test',
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
},
})

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

431
cypress/e2e/text.spec.ts Normal file
View file

@ -0,0 +1,431 @@
describe('Choices - text element', () => {
beforeEach(() => {
cy.visit('/text', {
onBeforeLoad(win) {
cy.stub(win.console, 'warn').as('consoleWarn');
},
});
});
describe('scenarios', () => {
const textInput = 'testing';
describe('basic', () => {
describe('adding items', () => {
it('allows me to input items', () => {
cy.get('[data-test-hook=basic]')
.find('.choices__input--cloned')
.type(textInput)
.type('{enter}');
cy.get('[data-test-hook=basic]')
.find('.choices__list--multiple .choices__item')
.last()
.should(($el) => {
expect($el).to.contain(textInput);
});
});
it('updates the value of the original input', () => {
cy.get('[data-test-hook=basic]')
.find('.choices__input--cloned')
.type(textInput)
.type('{enter}');
cy.get('[data-test-hook=basic]')
.find('.choices__input[hidden]')
.should('have.value', textInput);
});
describe('inputting data', () => {
it('shows a dropdown prompt', () => {
cy.get('[data-test-hook=basic]')
.find('.choices__input--cloned')
.type(textInput);
cy.get('[data-test-hook=basic]')
.find('.choices__list--dropdown')
.should('be.visible')
.should(($dropdown) => {
const dropdownText = $dropdown.text().trim();
expect(dropdownText).to.equal(
`Press Enter to add "${textInput}"`,
);
});
});
});
});
});
describe('editing items', () => {
beforeEach(() => {
for (let index = 0; index < 3; index++) {
cy.get('[data-test-hook=edit-items]')
.find('.choices__input--cloned')
.type(textInput)
.type('{enter}');
}
});
describe('on back space', () => {
it('allows me to change my entry', () => {
cy.get('[data-test-hook=edit-items]')
.find('.choices__input--cloned')
.type('{backspace}')
.type('-edited')
.type('{enter}');
cy.get('[data-test-hook=edit-items]')
.find('.choices__list--multiple .choices__item')
.last()
.should(($choice) => {
expect($choice.data('value')).to.equal(`${textInput}-edited`);
});
});
});
describe('on cmd+a', () => {
beforeEach(() => {
cy.get('[data-test-hook=edit-items]')
.find('.choices__input--cloned')
.type('{cmd}a');
});
it('highlights all items', () => {
cy.get('[data-test-hook=edit-items]')
.find('.choices__list--multiple .choices__item')
.each(($choice) => {
expect($choice.hasClass('is-highlighted')).to.equal(true);
});
});
describe('on backspace', () => {
it('clears all inputted values', () => {
// two backspaces are needed as Cypress has an issue where
// it will also insert an 'a' character into the text input
cy.get('[data-test-hook=edit-items]')
.find('.choices__input--cloned')
.type('{backspace}{backspace}');
cy.get('[data-test-hook=edit-items]')
.find('.choices__list--multiple .choices__item')
.should('have.length', 0);
});
});
});
});
describe('remove button', () => {
beforeEach(() => {
cy.get('[data-test-hook=remove-button]')
.find('.choices__input--cloned')
.type(`${textInput}`)
.type('{enter}');
});
describe('on click', () => {
it('removes respective choice', () => {
cy.get('[data-test-hook=remove-button]')
.find('.choices__list--multiple')
.children()
.should(($items) => {
expect($items.length).to.equal(1);
});
cy.get('[data-test-hook=remove-button]')
.find('.choices__list--multiple .choices__item')
.last()
.find('.choices__button')
.focus()
.click();
cy.get('[data-test-hook=remove-button]')
.find('.choices__list--multiple .choices__item')
.should(($items) => {
expect($items.length).to.equal(0);
});
});
it('updates the value of the original input', () => {
cy.get('[data-test-hook=remove-button]')
.find('.choices__list--multiple .choices__item')
.last()
.find('.choices__button')
.focus()
.click();
cy.get('[data-test-hook=remove-button]')
.find('.choices__input[hidden]')
.then(($input) => {
expect($input.val()).to.not.contain(textInput);
});
});
});
});
describe('unique values only', () => {
describe('unique values', () => {
beforeEach(() => {
cy.get('[data-test-hook=unique-values]')
.find('.choices__input--cloned')
.type(`${textInput}`)
.type('{enter}')
.type(`${textInput}`)
.type('{enter}');
});
it('only allows me to input unique values', () => {
cy.get('[data-test-hook=unique-values]')
.find('.choices__list--multiple')
.first()
.children()
.should(($items) => {
expect($items.length).to.equal(1);
});
});
describe('inputting a non-unique value', () => {
it('displays dropdown prompt', () => {
cy.get('[data-test-hook=unique-values]')
.find('.choices__list--dropdown')
.should('be.visible')
.should(($dropdown) => {
const dropdownText = $dropdown.text().trim();
expect(dropdownText).to.equal(
'Only unique values can be added',
);
});
});
});
});
});
describe('input limit', () => {
const inputLimit = 5;
beforeEach(() => {
for (let index = 0; index < inputLimit + 1; index++) {
cy.get('[data-test-hook=input-limit]')
.find('.choices__input--cloned')
.type(`${textInput} + ${index}`)
.type('{enter}');
}
});
it('does not let me input more than 5 choices', () => {
cy.get('[data-test-hook=input-limit]')
.find('.choices__list--multiple')
.first()
.children()
.should(($items) => {
expect($items.length).to.equal(inputLimit);
});
});
describe('reaching input limit', () => {
it('displays dropdown prompt', () => {
cy.get('[data-test-hook=input-limit]')
.find('.choices__list--dropdown')
.should('be.visible')
.should(($dropdown) => {
const dropdownText = $dropdown.text().trim();
expect(dropdownText).to.equal(
`Only ${inputLimit} values can be added`,
);
});
});
});
});
describe('add item filter', () => {
describe('inputting a value that satisfies the filter', () => {
const input = 'joe@bloggs.com';
it('allows me to add choice', () => {
cy.get('[data-test-hook=add-item-filter]')
.find('.choices__input--cloned')
.type(input)
.type('{enter}');
cy.get('[data-test-hook=add-item-filter]')
.find('.choices__list--multiple .choices__item')
.last()
.should(($choice) => {
expect($choice.text().trim()).to.equal(input);
});
});
});
describe('inputting a value that does not satisfy the regex', () => {
it('displays dropdown prompt', () => {
cy.get('[data-test-hook=add-item-filter]')
.find('.choices__input--cloned')
.type(`this is not an email address`)
.type('{enter}');
cy.get('[data-test-hook=add-item-filter]')
.find('.choices__list--dropdown')
.should('be.visible')
.should(($dropdown) => {
const dropdownText = $dropdown.text().trim();
expect(dropdownText).to.equal(
'Only values matching specific conditions can be added',
);
});
});
});
});
describe('prepend/append', () => {
beforeEach(() => {
cy.get('[data-test-hook=prepend-append]')
.find('.choices__input--cloned')
.type(textInput)
.type('{enter}');
});
it('prepends and appends value to inputted value', () => {
cy.get('[data-test-hook=prepend-append]')
.find('.choices__list--multiple .choices__item')
.last()
.should(($choice) => {
expect($choice.data('value')).to.equal(`before-${textInput}-after`);
});
});
it('displays just the inputted value to the user', () => {
cy.get('[data-test-hook=prepend-append]')
.find('.choices__list--multiple .choices__item')
.last()
.should(($choice) => {
expect($choice.text()).to.not.contain(`before-${textInput}-after`);
expect($choice.text()).to.contain(textInput);
});
});
});
describe('adding items disabled', () => {
it('does not allow me to input data', () => {
cy.get('[data-test-hook=adding-items-disabled]')
.find('.choices__input--cloned')
.should('be.disabled');
});
});
describe('disabled via attribute', () => {
it('does not allow me to input data', () => {
cy.get('[data-test-hook=disabled-via-attr]')
.find('.choices__input--cloned')
.should('be.disabled');
});
});
describe('pre-populated choices', () => {
it('pre-populates choices', () => {
cy.get('[data-test-hook=prepopulated]')
.find('.choices__list--multiple .choices__item')
.should(($choices) => {
expect($choices.length).to.equal(2);
});
cy.get('[data-test-hook=prepopulated]')
.find('.choices__list--multiple .choices__item')
.first()
.should(($choice) => {
expect($choice.text().trim()).to.equal('Josh Johnson');
});
cy.get('[data-test-hook=prepopulated]')
.find('.choices__list--multiple .choices__item')
.last()
.should(($choice) => {
expect($choice.text().trim()).to.equal('Joe Bloggs');
});
});
});
describe('placeholder', () => {
/*
{
placeholder: true,
placeholderValue: 'I am a placeholder',
}
*/
describe('when no value has been inputted', () => {
it('displays a placeholder', () => {
cy.get('[data-test-hook=placeholder]')
.find('.choices__input--cloned')
.should('have.attr', 'placeholder', 'I am a placeholder');
});
});
});
describe('allow html', () => {
describe('is undefined', () => {
it('logs a deprecation warning', () => {
cy.get('@consoleWarn').should(
'be.calledOnceWithExactly',
'Deprecation warning: allowHTML will default to false in a future release. To render HTML in Choices, you will need to set it to true. Setting allowHTML will suppress this message.',
);
});
it('does not show html as text', () => {
cy.get('[data-test-hook=allowhtml-undefined]')
.find('.choices__list--multiple .choices__item')
.first()
.should(($choice) => {
expect($choice.text().trim()).to.equal('Mason Rogers');
});
});
});
describe('set to true', () => {
it('does not show html as text', () => {
cy.get('[data-test-hook=allowhtml-true]')
.find('.choices__list--multiple .choices__item')
.first()
.should(($choice) => {
expect($choice.text().trim()).to.equal('Mason Rogers');
});
});
});
describe('set to false', () => {
it('shows html as text', () => {
cy.get('[data-test-hook=allowhtml-false]')
.find('.choices__list--multiple .choices__item')
.first()
.should(($choice) => {
expect($choice.text().trim()).to.equal('<b>Mason Rogers</b>');
});
});
});
});
describe('within form', () => {
describe('inputting item', () => {
describe('on enter key', () => {
it('does not submit form', () => {
cy.get('[data-test-hook=within-form] form').then(($form) => {
$form.submit(() => {
// this will fail the test if the form submits
throw new Error('Form submitted');
});
});
cy.get('[data-test-hook=within-form]')
.find('.choices__input--cloned')
.type(textInput)
.type('{enter}');
cy.get('[data-test-hook=within-form]')
.find('.choices__list--multiple .choices__item')
.last()
.should(($el) => {
expect($el).to.contain(textInput);
});
});
});
});
});
});
});

View file

@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}

17
cypress/plugins/index.js Normal file
View file

@ -0,0 +1,17 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
};

View file

@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

20
cypress/support/e2e.js Normal file
View file

@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands';
// Alternatively you can use CommonJS syntax:
// require('./commands')

View file

@ -1,51 +0,0 @@
const fs = require('fs'),
path = require('path'),
config = {
files: ['bower.json', 'package.json', 'index.html']
};
/**
* Convert node arguments into an object
* @return {Object} Arguments
*/
const argvToObject = () => {
const args = {};
let arg = null;
process.argv.forEach((val, index) => {
if(/^--/.test(val)) {
arg = {
index: index,
name: val.replace(/^--/, '')
}
return;
}
if(arg && ((arg.index+1 === index ))) {
args[arg.name] = val;
}
});
return args;
};
/**
* Loop through passed files updating version number
* @param {Object} config
*/
const updateVersion = (config) => {
const args = argvToObject();
const currentVersion = args.current;
const newVersion = args.new;
config.files.forEach((file) => {
const filePath = path.join(__dirname, file);
const regex = new RegExp(currentVersion, 'g');
let contents = fs.readFileSync(filePath, 'utf-8');
contents = contents.replace(regex, newVersion);
fs.writeFileSync(filePath, contents);
});
console.log(`Updated version to ${newVersion}`);
};
updateVersion(config);

View file

@ -1,466 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<title>Choices</title>
<meta name=description itemprop=description content="A lightweight, configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency.">
<link rel="apple-touch-icon" sizes="180x180" href="assets/images/apple-touch-icon.png">
<link rel="icon" type="image/png" href="assets/images/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="assets/images/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="assets/images/manifest.json">
<link rel="mask-icon" href="assets/images/safari-pinned-tab.svg" color="#00bcd4">
<link rel="shortcut icon" href="assets/images/favicon.ico">
<meta name="msapplication-config" content="/assets/images/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<!-- Ignore these -->
<link rel="stylesheet" href="assets/styles/css/base.min.css?version=2.7.1">
<!-- End ignore these -->
<!-- Optional includes -->
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=es5,fetch,Element.prototype.classList,requestAnimationFrame,Node.insertBefore,Node.firstChild,Object.assign"></script>
<!-- End optional includes -->
<!-- Choices includes -->
<link rel="stylesheet" href="assets/styles/css/choices.min.css?version=2.7.1">
<script src="assets/scripts/dist/choices.min.js?version=2.7.1"></script>
<!-- End Choices includes -->
<!--[if lt IE 9]>
<style>
.hidden-ie { display: none; }
.visible-ie { display: block; }
</style>
<![endif]-->
</head>
<body>
<div class="container">
<div class="section">
<a href="https://github.com/jshjohnson/Choices" class="logo">
<img src="assets/images/logo.svg" alt="Choices.js logo" class="logo__img hidden-ie">
<h1 class="visible-ie">Choices.js</h1>
</a>
<p>Choices.js is a lightweight, configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency.</p>
<p>For all config options, visit the <a href="https://github.com/jshjohnson/Choices">GitHub repo</a>.</p>
<hr>
<h2>Text inputs</h2>
<label for="choices-text-remove-button">Limited to 5 values with remove button</label>
<input class="form-control" id="choices-text-remove-button" type="text" value="preset-1,preset-2" placeholder="Enter something">
<label for="choices-text-unique-values">Unique values only, no pasting</label>
<input class="form-control" id="choices-text-unique-values" type="text" value="preset-1, preset-2" placeholder="This is a placeholder" class="custom class">
<label for="choices-text-email-filter">Email addresses only</label>
<input class="form-control" id="choices-text-email-filter" type="text" placeholder="This is a placeholder">
<label for="choices-text-disabled">Disabled</label>
<input class="form-control" id="choices-text-disabled" type="text" value="josh@joshuajohnson.co.uk, joe@bloggs.co.uk" placeholder="This is a placeholder">
<label for="choices-text-prepend-append-value">Prepends and appends a value to each items return value</label>
<input class="form-control" id="choices-text-prepend-append-value" type="text" value="preset-1, preset-2" placeholder="This is a placeholder">
<label for="choices-text-preset-values">Preset values passed through options</label>
<input class="form-control" id="choices-text-preset-values" type="text" value="olivia@benson.com" placeholder="This is a placeholder">
<label for="choices-text-i18n">I18N labels</label>
<input class="form-control" data-trigger id="choices-text-i18n" type="text">
<label for="choices-text-rtl">Right-to-left</label>
<input class="form-control" data-trigger id="choices-text-rtl" type="text" value="Value 1, Value 2" dir="rtl">
<hr>
<h2>Multiple select input</h2>
<label for="choices-multiple-default">Default</label>
<select class="form-control" data-trigger name="choices-multiple-default" id="choices-multiple-default" placeholder="This is a placeholder" multiple>
<option value="Dropdown item 1" selected>Dropdown item 1</option>
<option value="Dropdown item 2">Dropdown item 2</option>
<option value="Dropdown item 3">Dropdown item 3</option>
<option value="Dropdown item 4" disabled>Dropdown item 4</option>
</select>
<label for="choices-multiple-remove-button">With remove button</label>
<select class="form-control" name="choices-multiple-remove-button" id="choices-multiple-remove-button" placeholder="This is a placeholder" multiple>
<option value="Dropdown item 1" selected>Dropdown item 1</option>
<option value="Dropdown item 2">Dropdown item 2</option>
<option value="Dropdown item 3">Dropdown item 3</option>
<option value="Dropdown item 4">Dropdown item 4</option>
</select>
<label for="choices-multiple-groups">Option groups</label>
<select class="form-control" name="choices-multiple-groups" id="choices-multiple-groups" placeholder="This is a placeholder" multiple>
<optgroup label="UK">
<option value="London">London</option>
<option value="Manchester">Manchester</option>
<option value="Liverpool">Liverpool</option>
</optgroup>
<optgroup label="FR">
<option value="Paris">Paris</option>
<option value="Lyon">Lyon</option>
<option value="Marseille">Marseille</option>
</optgroup>
<optgroup label="DE" disabled>
<option value="Hamburg">Hamburg</option>
<option value="Munich">Munich</option>
<option value="Berlin">Berlin</option>
</optgroup>
<optgroup label="US">
<option value="New York">New York</option>
<option value="Washington" disabled>Washington</option>
<option value="Michigan">Michigan</option>
</optgroup>
<optgroup label="SP">
<option value="Madrid">Madrid</option>
<option value="Barcelona">Barcelona</option>
<option value="Malaga">Malaga</option>
</optgroup>
<optgroup label="CA">
<option value="Montreal">Montreal</option>
<option value="Toronto">Toronto</option>
<option value="Vancouver">Vancouver</option>
</optgroup>
</select>
<p><small>If the following example do not load, the Discogs rate limit has probably been reached. Try again later!</small></p>
<label for="choices-multiple-remote-fetch">Options from remote source (Fetch API) &amp; limited to 5</label>
<select class="form-control" name="choices-multiple-remote-fetch" id="choices-multiple-remote-fetch" multiple></select>
<label for="choices-multiple-rtl">Right-to-left</label>
<select class="form-control" data-trigger name="choices-multiple-rtl" id="choices-multiple-rtl" placeholder="This is a placeholder" multiple dir="rtl">
<option value="Dropdown item 1" selected>Dropdown item 1</option>
<option value="Dropdown item 2">Dropdown item 2</option>
<option value="Dropdown item 3">Dropdown item 3</option>
<option value="Dropdown item 4" disabled>Dropdown item 4</option>
</select>
<hr>
<h2>Single select input</h2>
<label for="choices-single-default">Default</label>
<select class="form-control" data-trigger name="choices-single-default" id="choices-single-default" placeholder="This is a search placeholder">
<option selected disabled>This is a placeholder</option>
<option value="Dropdown item 1">Dropdown item 1</option>
<option value="Dropdown item 2">Dropdown item 2</option>
<option value="Dropdown item 3">Dropdown item 3</option>
</select>
<p><small>If the following two examples do not load, the Discogs rate limit has probably been reached. Try again later!</small></p>
<label for="choices-single-remote-fetch">Options from remote source (Fetch API)</label>
<select class="form-control" name="choices-single-remote-fetch" id="choices-single-remote-fetch" placeholder="Pick an Arctic Monkeys record"></select>
<label for="choices-single-remove-xhr">Options from remote source (XHR) &amp; remove button</label>
<select class="form-control" name="choices-single-remove-xhr" id="choices-single-remove-xhr" placeholder="Pick a Smiths record"></select>
<label for="choices-single-groups">Option groups</label>
<select class="form-control" data-trigger name="choices-single-groups" id="choices-single-groups" placeholder="This is a placeholder">
<optgroup label="UK">
<option value="London">London</option>
<option value="Manchester">Manchester</option>
<option value="Liverpool">Liverpool</option>
</optgroup>
<optgroup label="FR">
<option value="Paris">Paris</option>
<option value="Lyon">Lyon</option>
<option value="Marseille">Marseille</option>
</optgroup>
<optgroup label="DE" disabled>
<option value="Hamburg">Hamburg</option>
<option value="Munich">Munich</option>
<option value="Berlin">Berlin</option>
</optgroup>
<optgroup label="US">
<option value="New York">New York</option>
<option value="Washington" disabled>Washington</option>
<option value="Michigan">Michigan</option>
</optgroup>
<optgroup label="SP">
<option value="Madrid">Madrid</option>
<option value="Barcelona">Barcelona</option>
<option value="Malaga">Malaga</option>
</optgroup>
<optgroup label="CA">
<option value="Montreal">Montreal</option>
<option value="Toronto">Toronto</option>
<option value="Vancouver">Vancouver</option>
</optgroup>
</select>
<label for="choices-single-rtl">Right-to-left</label>
<select class="form-control" data-trigger name="choices-single-rtl" id="choices-single-rtl" placeholder="This is a placeholder" dir="rtl">
<option value="Dropdown item 1">Dropdown item 1</option>
<option value="Dropdown item 2">Dropdown item 2</option>
<option value="Dropdown item 3">Dropdown item 3</option>
</select>
<label for="choices-single-no-search">Options added via config with no search</label>
<select class="form-control" name="choices-single-no-search" id="choices-single-no-search">
<option value="0">Zero</option>
</select>
<label for="choices-single-preset-options">Option and option groups added via config</label>
<select class="form-control" name="choices-single-preset-options" id="choices-single-preset-options" placeholder="This is a placeholder"></select>
<label for="choices-single-selected-option">Option selected via config</label>
<select class="form-control" name="choices-single-selected-option" id="choices-single-selected-option" placeholder="This is a placeholder"></select>
<label for="choices-single-no-sorting">Options without sorting</label>
<select class="form-control" name="choices-single-no-sorting" id="choices-single-no-sorting" placeholder="This is a placeholder">
<option value="Madrid">Madrid</option>
<option value="Toronto">Toronto</option>
<option value="Vancouver">Vancouver</option>
<option value="London">London</option>
<option value="Manchester">Manchester</option>
<option value="Liverpool">Liverpool</option>
<option value="Paris">Paris</option>
<option value="Malaga">Malaga</option>
<option value="Washington" disabled>Washington</option>
<option value="Lyon">Lyon</option>
<option value="Marseille">Marseille</option>
<option value="Hamburg">Hamburg</option>
<option value="Munich">Munich</option>
<option value="Barcelona">Barcelona</option>
<option value="Berlin">Berlin</option>
<option value="Montreal">Montreal</option>
<option value="New York">New York</option>
<option value="Michigan">Michigan</option>
</select>
<label for="choices-custom-templates">Custom templates</label>
<select class="form-control" name="choices-custom-templates" id="choices-custom-templates" placeholder="This is a placeholder">
<option value="React">React</option>
<option value="React">Angular</option>
<option value="React">Ember</option>
<option value="React">Vue</option>
</select>
<p>Below is an example of how you could have two select inputs depend on eachother. 'Boroughs' will only be enabled if the value of 'States' is 'New York'</p>
<label for="states">States</label>
<select class="form-control" name="states" id="states" placeholder="Choose a state">
<option value="Michigan">Michigan</option>
<option value="Texas">Texas</option>
<option value="Chicago">Chicago</option>
<option value="New York">New York</option>
<option value="Washington">Washington</option>
</select>
<label for="boroughs">Boroughs</label>
<select class="form-control" name="boroughs" id="boroughs" placeholder="Choose a borough">
<option value="The Bronx">The Bronx</option>
<option value="Brooklyn">Brooklyn</option>
<option value="Manhattan">Manhattan</option>
<option value="Queens">Queens</option>
<option value="Staten Island">Staten Island</option>
</select>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var textRemove = new Choices(document.getElementById('choices-text-remove-button'), {
delimiter: ',',
editItems: true,
maxItemCount: 5,
removeItemButton: true,
});
var textUniqueVals = new Choices('#choices-text-unique-values', {
paste: false,
duplicateItems: false,
editItems: true,
});
var texti18n = new Choices('#choices-text-i18n', {
paste: false,
duplicateItems: false,
editItems: true,
addItemText: (value) => {
return `Appuyez sur Entrée pour ajouter <b>"${value}"</b>`;
},
maxItemText: (maxItemCount) => {
return `${maxItemCount} valeurs peuvent être ajoutées`;
},
uniqueItemText: 'Cette valeur est déjà présente',
});
var textEmailFilter = new Choices('#choices-text-email-filter', {
editItems: true,
regexFilter: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
});
var textDisabled = new Choices('#choices-text-disabled', {
addItems: false,
removeItems: false,
}).disable();
var textPrependAppendVal = new Choices('#choices-text-prepend-append-value', {
prependValue: 'item-',
appendValue: '-' + Date.now(),
}).removeActiveItems();
var textPresetVal = new Choices('#choices-text-preset-values', {
items: ['josh@joshuajohnson.co.uk', { value: 'joe@bloggs.co.uk', label: 'Joe Bloggs' } ],
});
var multipleDefault = new Choices(document.getElementById('choices-multiple-groups'));
var multipleFetch = new Choices('#choices-multiple-remote-fetch', {
placeholder: true,
placeholderValue: 'Pick an Strokes record',
maxItemCount: 5,
}).ajax(function(callback) {
fetch('https://api.discogs.com/artists/55980/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW')
.then(function(response) {
response.json().then(function(data) {
callback(data.releases, 'title', 'title');
});
})
.catch(function(error) {
console.error(error);
});
});
var multipleCancelButton = new Choices('#choices-multiple-remove-button', {
removeItemButton: true,
})
var singleFetch = new Choices('#choices-single-remote-fetch', {
placeholder: true,
placeholderValue: 'Pick an Arctic Monkeys record'
}).ajax(function(callback) {
fetch('https://api.discogs.com/artists/391170/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW')
.then(function(response) {
response.json().then(function(data) {
callback(data.releases, 'title', 'title');
singleFetch.setValueByChoice('Fake Tales Of San Francisco');
});
})
.catch(function(error) {
console.error(error);
});
});
var singleXhrRemove = new Choices('#choices-single-remove-xhr', {
removeItemButton: true,
}).ajax(function(callback) {
var request = new XMLHttpRequest();
request.open('get', 'https://api.discogs.com/artists/83080/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW', true);
request.onreadystatechange = function() {
var status;
var data;
if (request.readyState === 4) {
status = request.status;
if (status === 200) {
data = JSON.parse(request.responseText);
callback(data.releases, 'title', 'title');
singleXhrRemove.setValueByChoice('How Soon Is Now?');
} else {
console.error(status);
}
}
}
request.send();
});
var genericExamples = new Choices('[data-trigger]', {
placeholderValue: 'This is a placeholder set in the config'
});
var singleNoSearch = new Choices('#choices-single-no-search', {
search: false,
removeItemButton: true,
choices: [
{value: 'One', label: 'Label One'},
{value: 'Two', label: 'Label Two', disabled: true},
{value: 'Three', label: 'Label Three'},
],
}).setChoices([
{value: 'Four', label: 'Label Four', disabled: true},
{value: 'Five', label: 'Label Five'},
{value: 'Six', label: 'Label Six', selected: true},
], 'value', 'label', false);
var singlePresetOpts = new Choices('#choices-single-preset-options', {
placeholder: true,
}).setChoices([{
label: 'Group one',
id: 1,
disabled: false,
choices: [
{value: 'Child One', label: 'Child One', selected: true},
{value: 'Child Two', label: 'Child Two', disabled: true},
{value: 'Child Three', label: 'Child Three'},
]
},
{
label: 'Group two',
id: 2,
disabled: false,
choices: [
{value: 'Child Four', label: 'Child Four', disabled: true},
{value: 'Child Five', label: 'Child Five'},
{value: 'Child Six', label: 'Child Six'},
]
}], 'value', 'label');
var singleSelectedOpt = new Choices('#choices-single-selected-option', {
choices: [
{value: 'One', label: 'Label One', selected: true},
{value: 'Two', label: 'Label Two', disabled: true},
{value: 'Three', label: 'Label Three'},
],
}).setValueByChoice('Two');
var singleNoSorting = new Choices('#choices-single-no-sorting', {
shouldSort: false,
});
var states = new Choices(document.getElementById('states'));
states.passedElement.addEventListener('change', function(e) {
if(e.detail.value === 'New York') {
boroughs.enable();
} else {
boroughs.disable();
}
});
var customTemplates = new Choices(document.getElementById('choices-custom-templates'), {
callbackOnCreateTemplates: function (strToEl) {
var classNames = this.config.classNames;
return {
item: (data) => {
return strToEl(`
<div class="${classNames.item} ${data.highlighted ? classNames.highlightedState : classNames.itemSelectable}" data-item data-id="${data.id}" data-value="${data.value}" ${data.active ? 'aria-selected="true"' : ''} ${data.disabled ? 'aria-disabled="true"' : ''}>
<span style="margin-right:10px;">🎉</span> ${data.label}
</div>
`);
},
choice: (data) => {
return strToEl(`
<div class="${classNames.item} ${classNames.itemChoice} ${data.disabled ? classNames.itemDisabled : classNames.itemSelectable}" data-select-text="${this.config.itemSelectText}" data-choice ${data.disabled ? 'data-choice-disabled aria-disabled="true"' : 'data-choice-selectable'} data-id="${data.id}" data-value="${data.value}" ${data.groupId > 0 ? 'role="treeitem"' : 'role="option"'}>
<span style="margin-right:10px;">👉🏽</span> ${data.label}
</div>
`);
},
};
}
});
var boroughs = new Choices(document.getElementById('boroughs')).disable();
});
</script>
<!-- Google Analytics - Ignore me -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-31575166-1', 'auto');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics -->
</body>
</html>

17
jsconfig.json Normal file
View file

@ -0,0 +1,17 @@
{
"compilerOptions": {
"checkJs": true,
"target": "es2020",
"lib": ["esnext", "dom"],
"types": ["cypress"],
"strict": true,
"moduleResolution": "node",
/* Additional Checks */
"noImplicitAny": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"strictNullChecks": false
}
}

14
lint-staged.config.js Normal file
View file

@ -0,0 +1,14 @@
module.exports = {
'*.js': ['eslint --fix --quiet -f visualstudio', 'git add'],
'*.{ts,scss,yaml,yml,md,html,json,babelrc,eslintrc}': [
'prettier --write',
'git add',
],
'src/icons/*.svg': [
'prettier --write --parser=html --html-whitespace-sensitivity=ignore',
'git add',
],
'.codecov.yml': () =>
'curl -f --silent --data-binary @.codecov.yml https://codecov.io/validate',
'src/scripts/**/*.js': () => 'npm run test:unit',
};

23844
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,20 +1,33 @@
{
"name": "choices.js",
"version": "2.7.1",
"version": "10.2.0",
"description": "A vanilla JS customisable text input/select box plugin",
"main": "./assets/scripts/dist/choices.min.js",
"main": "./public/assets/scripts/choices.js",
"types": "./public/types/src/index.d.ts",
"scripts": {
"start": "node server.js",
"start": "run-p js:watch css:watch",
"build": "run-p js:build css:build",
"lint": "run-p lint:js lint:scss",
"lint:js": "eslint src/scripts/**/*.ts",
"lint:scss": "stylelint src/**/*.scss",
"bundlesize": "bundlesize",
"cypress:run": "cypress run --browser chrome",
"cypress:open": "cypress open",
"cypress:ci": "cypress run --browser chrome --record --group $GITHUB_REF --ci-build-id $GITHUB_SHA",
"test": "run-s test:unit test:e2e",
"test:unit": "cross-env TS_NODE_TRANSPILE_ONLY=true NODE_ENV=test mocha",
"test:unit:watch": "npm run test:unit -- --watch --inspect=5556",
"test:unit:coverage": "NODE_ENV=test nyc --reporter=lcov --reporter=text --reporter=text-summary mocha",
"test:e2e": "run-p --race start cypress:run",
"js:watch": "cross-env NODE_ENV=development node server.js",
"js:build": "webpack --config webpack.config.prod.js",
"css:watch": "nodemon -e scss -x \"npm run css:build\"",
"css:build": "npm run css:sass -s && npm run css:prefix -s && npm run css:min -s",
"css:sass": "node-sass --output-style expanded --include-path scss assets/styles/scss/base.scss assets/styles/css/base.css && node-sass --output-style expanded --include-path scss assets/styles/scss/choices.scss assets/styles/css/choices.css",
"css:prefix": "postcss --use autoprefixer -b 'last 2 versions' assets/styles/css/*.css -d assets/styles/css/",
"css:min": "csso assets/styles/css/base.css assets/styles/css/base.min.css && csso assets/styles/css/choices.css assets/styles/css/choices.min.css",
"js:build": "concurrently --prefix-colors yellow,green \"webpack --minimize --config webpack.config.prod.js\" \"webpack --config webpack.config.prod.js\"",
"js:test": "./node_modules/karma/bin/karma start --single-run --no-auto-watch tests/karma.config.js",
"js:test:watch": "./node_modules/karma/bin/karma start --auto-watch --no-single-run tests/karma.config.js",
"version": "node version.js --current $npm_package_version --new $npm_config_newVersion",
"postversion": "npm run js:build"
"css:build": "run-s css:sass css:prefix css:min",
"css:sass": "sass -I scss src/styles/base.scss public/assets/styles/base.css && sass -I scss src/styles/choices.scss public/assets/styles/choices.css",
"css:prefix": "postcss public/assets/styles/*.css --use autoprefixer --no-map --env prod --dir public/assets/styles",
"css:min": "csso public/assets/styles/base.css --output public/assets/styles/base.min.css && csso public/assets/styles/choices.css --output public/assets/styles/choices.min.css",
"deploy": "git subtree push --prefix public origin gh-pages",
"prepublishOnly": "npm run build"
},
"repository": {
"type": "git",
@ -22,57 +35,110 @@
},
"author": "Josh Johnson",
"license": "MIT",
"files": [
"public/assets/scripts",
"public/assets/styles",
"public/types",
"src",
"!src/**/*.test.js",
"types"
],
"bugs": {
"url": "https://github.com/jshjohnson/Choices/issues"
},
"homepage": "https://github.com/jshjohnson/Choices#readme",
"keywords": [
"customisable",
"input",
"select",
"vanilla",
"plugin",
"js"
],
"devDependencies": {
"autoprefixer": "^6.3.3",
"babel-core": "^6.7.2",
"babel-eslint": "^6.1.2",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"concurrently": "^3.1.0",
"csso": "^1.8.2",
"es6-promise": "^3.2.1",
"eslint": "^3.3.0",
"eslint-config-airbnb": "^10.0.1",
"eslint-loader": "^1.5.0",
"eslint-plugin-import": "^1.13.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.4.1",
"jasmine-core": "2.4.1",
"karma": "^1.1.0",
"karma-coverage": "^1.0.0",
"karma-es6-shim": "^1.0.0",
"karma-htmlfile-reporter": "^0.3.4",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.1",
"karma-spec-reporter": "0.0.26",
"karma-webpack": "^1.7.0",
"node-sass": "^3.4.2",
"nodemon": "^1.9.1",
"opn-cli": "^3.1.0",
"postcss-cli": "^2.5.1",
"webpack": "^1.12.14",
"webpack-dashboard": "^0.1.8",
"webpack-dev-server": "^1.14.1",
"whatwg-fetch": "^1.0.0",
"wrapper-webpack-plugin": "^0.1.7"
"@babel/core": "^7.20.5",
"@babel/preset-env": "^7.20.2",
"@babel/register": "^7.18.9",
"@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1",
"@types/sinon": "^10.0.13",
"@types/sinon-chai": "^3.2.9",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"autoprefixer": "^10.4.13",
"babel-loader": "^9.1.0",
"bundlesize": "^0.18.1",
"chai": "^4.3.7",
"cross-env": "^7.0.3",
"csso-cli": "^4.0.1",
"cypress": "11.2.0",
"eslint": "^8.28.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-compat": "4.0.2",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-sort-class-members": "^1.15.2",
"eslint-webpack-plugin": "^3.2.0",
"express": "^4.18.2",
"husky": "^8.0.2",
"jsdom": "^20.0.3",
"lint-staged": "^13.0.4",
"mocha": "^10.1.0",
"nodemon": "^2.0.20",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"postcss": "^8.4.19",
"postcss-cli": "^10.0.0",
"prettier": "^2.8.0",
"sass": "^1.56.1",
"sinon": "^15.0.0",
"sinon-chai": "^3.7.0",
"stylelint": "^14.15.0",
"stylelint-config-standard": "^29.0.0",
"stylelint-config-standard-scss": "^6.1.0",
"ts-loader": "^9.4.1",
"ts-node": "^10.9.1",
"typescript": "^4.9.3",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.0",
"webpack-dev-middleware": "^6.0.1",
"webpack-hot-middleware": "^2.25.3"
},
"dependencies": {
"redux": "^3.3.1",
"fuse.js": "^2.2.2"
"deepmerge": "^4.2.2",
"fuse.js": "^6.6.2",
"redux": "^4.2.0"
},
"npmName": "choices.js",
"npmFileMap": [
{
"basePath": "assets",
"files": [
"scripts/dist/*",
"styles/css/*",
"icons/*"
"public/assets/scripts/*",
"public/assets/styles/*",
"public/types/*",
"src/icons/*"
]
}
],
"nyc": {
"include": [
"src/scripts/**/**/*.js"
],
"exclude": [
"src/scripts/**/**/*.test.js"
]
},
"bundlesize": [
{
"path": "public/assets/scripts/choices.min.js",
"maxSize": "25 kB"
},
{
"path": "public/assets/styles/choices.min.css",
"maxSize": "2.5 kB"
}
]
}

View file

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/assets/images/mstile-150x150.png"/>
<TileColor>#ffffff</TileColor>
</tile>
</msapplication>
</browserconfig>
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/assets/images/mstile-150x150.png"/>
<TileColor>#ffffff</TileColor>
</tile>
</msapplication>
</browserconfig>

View file

Before

Width:  |  Height:  |  Size: 574 B

After

Width:  |  Height:  |  Size: 574 B

View file

Before

Width:  |  Height:  |  Size: 887 B

After

Width:  |  Height:  |  Size: 887 B

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

Before

Width:  |  Height:  |  Size: 6 KiB

After

Width:  |  Height:  |  Size: 6 KiB

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

View file

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -0,0 +1,27 @@
// get polyfill settings from top level config
// @ts-ignore
const { settings } = require('../../../.eslintrc.json');
// Adding non-polyfilable Symbol-related functions as they are most probably
// behind the flag
settings.polyfills.push(
'Symbol.toStringTag',
'Symbol.for',
'Object.getOwnPropertySymbols',
'Object.getOwnPropertyDescriptors',
'Promise', // Promise is gate checked
);
module.exports = /** @type {import('eslint').Linter.Config} */ ({
root: true,
extends: ['plugin:compat/recommended'],
parserOptions: {
// ensure that it's compatible with ES5 browsers, so, no `const`, etc
ecmaVersion: 5,
},
env: {
browser: true,
},
settings,
});

File diff suppressed because it is too large Load diff

2
public/assets/scripts/choices.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
/*! choices.js v10.2.0 | © 2022 Josh Johnson | https://github.com/jshjohnson/Choices#readme */

View file

@ -1,16 +1,19 @@
/*=============================================
/* =============================================
= Generic styling =
=============================================*/
============================================= */
* {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
*, *:before, *:after {
*,
*::before,
*::after {
box-sizing: border-box;
}
html, body {
html,
body {
position: relative;
margin: 0;
width: 100%;
@ -21,7 +24,7 @@ body {
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-size: 16px;
line-height: 1.4;
color: #FFFFFF;
color: #fff;
background-color: #333;
overflow-x: hidden;
}
@ -36,25 +39,33 @@ label {
p {
margin-top: 0;
margin-bottom: 8px;
}
hr {
display: block;
margin: 36px 0;
margin: 30px 0;
border: 0;
border-bottom: 1px solid #eaeaea;
height: 1px;
}
h1, h2, h3, h4, h5, h6 {
h1,
h2,
h3,
h4,
h5,
h6 {
margin-top: 0;
margin-bottom: 12px;
font-weight: 400;
line-height: 1.2;
}
a, a:visited, a:focus {
color: #FFFFFF;
a,
a:visited,
a:focus {
color: #fff;
text-decoration: none;
font-weight: 600;
}
@ -68,42 +79,50 @@ a, a:visited, a:focus {
border-radius: 2.5px;
font-size: 14px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
appearance: none;
margin-bottom: 24px;
}
h1, .h1 {
h1,
.h1 {
font-size: 32px;
}
h2, .h2 {
h2,
.h2 {
font-size: 24px;
}
h3, .h3 {
h3,
.h3 {
font-size: 20px;
}
h4, .h4 {
h4,
.h4 {
font-size: 18px;
}
h5, .h5 {
h5,
.h5 {
font-size: 16px;
}
h6, .h6 {
h6,
.h6 {
font-size: 14px;
}
label + p {
margin-top: -4px;
}
.container {
display: block;
margin: auto;
max-width: 40em;
padding: 48px;
}
@media (max-width: 620px) {
.container {
padding: 0;
@ -111,12 +130,13 @@ h6, .h6 {
}
.section {
background-color: #FFFFFF;
background-color: #fff;
padding: 24px;
color: #333;
}
.section a, .section a:visited, .section a:focus {
.section a,
.section a:visited,
.section a:focus {
color: #00bcd4;
}
@ -125,7 +145,7 @@ h6, .h6 {
margin-bottom: 12px;
}
.logo__img {
.logo-img {
width: 100%;
height: auto;
display: inline-block;
@ -138,4 +158,24 @@ h6, .h6 {
display: none;
}
/*===== End of Section comment block ======*/
.push-bottom {
margin-bottom: 24px;
}
.zero-bottom {
margin-bottom: 0;
}
.zero-top {
margin-top: 0;
}
.text-center {
text-align: center;
}
[data-test-hook] {
margin-bottom: 24px;
}
/* ===== End of Section comment block ====== */

View file

@ -0,0 +1 @@
{"version":3,"sourceRoot":"","sources":["../../../src/styles/base.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAYA;EACE;EACA;;;AAGF;AAAA;AAAA;EAGE;;;AAGF;AAAA;EAEE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AAGF;AAAA;AAAA;AAAA;AAAA;AAAA;EAME;EACA;EACA;EACA;;;AAGF;AAAA;AAAA;EAGE;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAtFiB;;;AAyFnB;AAAA;EAEE,WA1FoB;;;AA6FtB;AAAA;EAEE,WA9FoB;;;AAiGtB;AAAA;EAEE,WAlGoB;;;AAqGtB;AAAA;EAEE,WAtGoB;;;AAyGtB;AAAA;EAEE,WA1GoB;;;AA6GtB;AAAA;EAEE,WA9GoB;;;AAiHtB;EACE;;;AAGF;EACE;EACA;EACA;EACA;;AAEA;EANF;IAOI;;;;AAIJ;EACE;EACA,SAxIiB;EAyIjB;;AAEA;AAAA;AAAA;EAGE;;;AAIJ;EACE;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE,eArKiB;;;AAwKnB;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE,eArLiB;;;AAwLnB","file":"base.css"}

1
public/assets/styles/base.min.css vendored Normal file
View file

@ -0,0 +1 @@
*{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}*,::after,::before{box-sizing:border-box}body,html{position:relative;margin:0;width:100%;height:100%}body{font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;font-size:16px;line-height:1.4;color:#fff;background-color:#333;overflow-x:hidden}hr,label{display:block}label,p{margin-bottom:8px}label{font-size:14px;font-weight:500;cursor:pointer}p{margin-top:0}hr{margin:30px 0;border:0;border-bottom:1px solid #eaeaea;height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:12px;font-weight:400;line-height:1.2}a,a:focus,a:visited{color:#fff;text-decoration:none;font-weight:600}.form-control{display:block;width:100%;background-color:#f9f9f9;padding:12px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;-webkit-appearance:none;appearance:none;margin-bottom:24px}.h1,h1{font-size:32px}.h2,h2{font-size:24px}.h3,h3{font-size:20px}.h4,h4{font-size:18px}.h5,h5{font-size:16px}.h6,h6{font-size:14px}label+p{margin-top:-4px}.container{display:block;margin:auto;max-width:40em;padding:48px}@media (max-width:620px){.container{padding:0}}.section{background-color:#fff;padding:24px;color:#333}.section a,.section a:focus,.section a:visited{color:#00bcd4}.logo{display:block;margin-bottom:12px}.logo-img{width:100%;height:auto;display:inline-block;max-width:100%;vertical-align:top;padding:6px 0}.visible-ie{display:none}.push-bottom{margin-bottom:24px}.zero-bottom{margin-bottom:0}.zero-top{margin-top:0}.text-center{text-align:center}[data-test-hook]{margin-bottom:24px}

View file

@ -1,55 +1,53 @@
/*===============================
/* ===============================
= Choices =
===============================*/
=============================== */
.choices {
position: relative;
overflow: hidden;
margin-bottom: 24px;
font-size: 16px;
}
.choices:focus {
outline: none;
}
.choices:last-child {
margin-bottom: 0;
}
.choices.is-disabled .choices__inner, .choices.is-disabled .choices__input {
background-color: #EAEAEA;
.choices.is-open {
overflow: visible;
}
.choices.is-disabled .choices__inner,
.choices.is-disabled .choices__input {
background-color: #eaeaea;
cursor: not-allowed;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.choices.is-disabled .choices__item {
cursor: not-allowed;
}
.choices [hidden] {
display: none !important;
}
.choices[data-type*="select-one"] {
.choices[data-type*=select-one] {
cursor: pointer;
}
.choices[data-type*="select-one"] .choices__inner {
.choices[data-type*=select-one] .choices__inner {
padding-bottom: 7.5px;
}
.choices[data-type*="select-one"] .choices__input {
.choices[data-type*=select-one] .choices__input {
display: block;
width: 100%;
padding: 10px;
border-bottom: 1px solid #DDDDDD;
background-color: #FFFFFF;
border-bottom: 1px solid #ddd;
background-color: #fff;
margin: 0;
}
.choices[data-type*="select-one"] .choices__button {
background-image: url("../../icons//cross-inverse.svg");
.choices[data-type*=select-one] .choices__button {
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==");
padding: 0;
background-size: 8px;
height: 100%;
position: absolute;
top: 50%;
right: 0;
@ -58,23 +56,23 @@
height: 20px;
width: 20px;
border-radius: 10em;
opacity: .5;
opacity: 0.25;
}
.choices[data-type*="select-one"] .choices__button:hover, .choices[data-type*="select-one"] .choices__button:focus {
.choices[data-type*=select-one] .choices__button:hover, .choices[data-type*=select-one] .choices__button:focus {
opacity: 1;
}
.choices[data-type*="select-one"] .choices__button:focus {
box-shadow: 0px 0px 0px 2px #00BCD4;
.choices[data-type*=select-one] .choices__button:focus {
box-shadow: 0 0 0 2px #00bcd4;
}
.choices[data-type*="select-one"]:after {
.choices[data-type*=select-one] .choices__item[data-value=""] .choices__button {
display: none;
}
.choices[data-type*=select-one]::after {
content: "";
height: 0;
width: 0;
border-style: solid;
border-color: #333333 transparent transparent transparent;
border-color: #333 transparent transparent transparent;
border-width: 5px;
position: absolute;
right: 11.5px;
@ -82,29 +80,27 @@
margin-top: -2.5px;
pointer-events: none;
}
.choices[data-type*="select-one"].is-open:after {
border-color: transparent transparent #333333 transparent;
.choices[data-type*=select-one].is-open::after {
border-color: transparent transparent #333 transparent;
margin-top: -7.5px;
}
.choices[data-type*="select-one"][dir="rtl"]:after {
.choices[data-type*=select-one][dir=rtl]::after {
left: 11.5px;
right: auto;
}
.choices[data-type*="select-one"][dir="rtl"] .choices__button {
.choices[data-type*=select-one][dir=rtl] .choices__button {
right: auto;
left: 0;
margin-left: 25px;
margin-right: 0;
}
.choices[data-type*="select-multiple"] .choices__inner, .choices[data-type*="text"] .choices__inner {
.choices[data-type*=select-multiple] .choices__inner,
.choices[data-type*=text] .choices__inner {
cursor: text;
}
.choices[data-type*="select-multiple"] .choices__button, .choices[data-type*="text"] .choices__button {
.choices[data-type*=select-multiple] .choices__button,
.choices[data-type*=text] .choices__button {
position: relative;
display: inline-block;
margin-top: 0;
@ -113,14 +109,16 @@
margin-left: 8px;
padding-left: 16px;
border-left: 1px solid #008fa1;
background-image: url("../../icons//cross.svg");
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==");
background-size: 8px;
width: 8px;
line-height: 1;
opacity: .75;
opacity: 0.75;
border-radius: 0;
}
.choices[data-type*="select-multiple"] .choices__button:hover, .choices[data-type*="select-multiple"] .choices__button:focus, .choices[data-type*="text"] .choices__button:hover, .choices[data-type*="text"] .choices__button:focus {
.choices[data-type*=select-multiple] .choices__button:hover, .choices[data-type*=select-multiple] .choices__button:focus,
.choices[data-type*=text] .choices__button:hover,
.choices[data-type*=text] .choices__button:focus {
opacity: 1;
}
@ -130,21 +128,18 @@
width: 100%;
background-color: #f9f9f9;
padding: 7.5px 7.5px 3.75px;
border: 1px solid #DDDDDD;
border: 1px solid #ddd;
border-radius: 2.5px;
font-size: 14px;
min-height: 44px;
overflow: hidden;
}
.is-focused .choices__inner, .is-open .choices__inner {
border-color: #b7b7b7;
}
.is-open .choices__inner {
border-radius: 2.5px 2.5px 0 0;
}
.is-flipped.is-open .choices__inner {
border-radius: 0 0 2.5px 2.5px;
}
@ -154,18 +149,15 @@
padding-left: 0;
list-style: none;
}
.choices__list--single {
display: inline-block;
padding: 4px 16px 4px 4px;
width: 100%;
}
[dir="rtl"] .choices__list--single {
[dir=rtl] .choices__list--single {
padding-right: 4px;
padding-left: 16px;
}
.choices__list--single .choices__item {
width: 100%;
}
@ -173,7 +165,6 @@
.choices__list--multiple {
display: inline;
}
.choices__list--multiple .choices__item {
display: inline-block;
vertical-align: middle;
@ -183,111 +174,99 @@
font-weight: 500;
margin-right: 3.75px;
margin-bottom: 3.75px;
background-color: #00BCD4;
background-color: #00bcd4;
border: 1px solid #00a5bb;
color: #FFFFFF;
color: #fff;
word-break: break-all;
box-sizing: border-box;
}
.choices__list--multiple .choices__item[data-deletable] {
padding-right: 5px;
}
[dir="rtl"] .choices__list--multiple .choices__item {
[dir=rtl] .choices__list--multiple .choices__item {
margin-right: 0;
margin-left: 3.75px;
}
.choices__list--multiple .choices__item.is-highlighted {
background-color: #00a5bb;
border: 1px solid #008fa1;
}
.is-disabled .choices__list--multiple .choices__item {
background-color: #aaaaaa;
border: 1px solid #919191;
}
.choices__list--dropdown {
display: none;
.choices__list--dropdown, .choices__list[aria-expanded] {
visibility: hidden;
z-index: 1;
position: absolute;
width: 100%;
background-color: #FFFFFF;
border: 1px solid #DDDDDD;
background-color: #fff;
border: 1px solid #ddd;
top: 100%;
margin-top: -1px;
border-bottom-left-radius: 2.5px;
border-bottom-right-radius: 2.5px;
overflow: hidden;
word-break: break-all;
will-change: visibility;
}
.choices__list--dropdown.is-active {
display: block;
.is-active.choices__list--dropdown, .is-active.choices__list[aria-expanded] {
visibility: visible;
}
.is-open .choices__list--dropdown {
.is-open .choices__list--dropdown, .is-open .choices__list[aria-expanded] {
border-color: #b7b7b7;
}
.is-flipped .choices__list--dropdown {
.is-flipped .choices__list--dropdown, .is-flipped .choices__list[aria-expanded] {
top: auto;
bottom: 100%;
margin-top: 0;
margin-bottom: -1px;
border-radius: .25rem .25rem 0 0;
border-radius: 0.25rem 0.25rem 0 0;
}
.choices__list--dropdown .choices__list {
.choices__list--dropdown .choices__list, .choices__list[aria-expanded] .choices__list {
position: relative;
max-height: 300px;
overflow: auto;
-webkit-overflow-scrolling: touch;
will-change: scroll-position;
}
.choices__list--dropdown .choices__item {
.choices__list--dropdown .choices__item, .choices__list[aria-expanded] .choices__item {
position: relative;
padding: 10px;
font-size: 14px;
}
[dir="rtl"] .choices__list--dropdown .choices__item {
[dir=rtl] .choices__list--dropdown .choices__item, [dir=rtl] .choices__list[aria-expanded] .choices__item {
text-align: right;
}
@media (min-width: 640px) {
.choices__list--dropdown .choices__item--selectable {
.choices__list--dropdown .choices__item--selectable, .choices__list[aria-expanded] .choices__item--selectable {
padding-right: 100px;
}
.choices__list--dropdown .choices__item--selectable:after {
.choices__list--dropdown .choices__item--selectable::after, .choices__list[aria-expanded] .choices__item--selectable::after {
content: attr(data-select-text);
font-size: 12px;
opacity: 0;
position: absolute;
right: 10px;
top: 50%;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
transform: translateY(-50%);
}
[dir="rtl"] .choices__list--dropdown .choices__item--selectable {
[dir=rtl] .choices__list--dropdown .choices__item--selectable, [dir=rtl] .choices__list[aria-expanded] .choices__item--selectable {
text-align: right;
padding-left: 100px;
padding-right: 10px;
}
[dir="rtl"] .choices__list--dropdown .choices__item--selectable:after {
[dir=rtl] .choices__list--dropdown .choices__item--selectable::after, [dir=rtl] .choices__list[aria-expanded] .choices__item--selectable::after {
right: auto;
left: 10px;
}
}
.choices__list--dropdown .choices__item--selectable.is-highlighted {
.choices__list--dropdown .choices__item--selectable.is-highlighted, .choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
background-color: #f2f2f2;
}
.choices__list--dropdown .choices__item--selectable.is-highlighted:after {
opacity: .5;
.choices__list--dropdown .choices__item--selectable.is-highlighted::after, .choices__list[aria-expanded] .choices__item--selectable.is-highlighted::after {
opacity: 0.5;
}
.choices__item {
@ -301,10 +280,8 @@
.choices__item--disabled {
cursor: not-allowed;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
opacity: .5;
opacity: 0.5;
}
.choices__heading {
@ -318,15 +295,13 @@
.choices__button {
text-indent: -9999px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
appearance: none;
border: 0;
background-color: transparent;
background-repeat: no-repeat;
background-position: center;
cursor: pointer;
}
.choices__button:focus {
outline: none;
}
@ -342,18 +317,24 @@
max-width: 100%;
padding: 4px 0 4px 2px;
}
.choices__input:focus {
outline: 0;
}
[dir="rtl"] .choices__input {
.choices__input::-webkit-search-decoration, .choices__input::-webkit-search-cancel-button, .choices__input::-webkit-search-results-button, .choices__input::-webkit-search-results-decoration {
display: none;
}
.choices__input::-ms-clear, .choices__input::-ms-reveal {
display: none;
width: 0;
height: 0;
}
[dir=rtl] .choices__input {
padding-right: 2px;
padding-left: 0;
}
.choices__placeholder {
opacity: .5;
opacity: 0.5;
}
/*===== End of Choices ======*/
/* ===== End of Choices ====== */

View file

@ -0,0 +1 @@
{"version":3,"sourceRoot":"","sources":["../../../src/styles/choices.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AA2BA;EACE;EACA;EACA,eApBkB;EAqBlB,WAxBqB;;AA0BrB;EACE;;AAGF;EACE;;AAGF;EACE;;AAIA;AAAA;EAEE,kBAlCsB;EAmCtB;EACA;;AAEF;EACE;;AAIJ;EACE;;;AAIJ;EACE;;AACA;EACE;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;;AAEF;EACE,kBApDyB;EAqDzB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EAEE;;AAGF;EACE;;AAGJ;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;;AAIA;EACE;EACA;;AAEF;EACE;EACA;EACA;EACA;;;AAOJ;AAAA;EACE;;AAEF;AAAA;EACE;EACA;EACA;EACA;EACA;EACA,aA5HoB;EA6HpB;EACA;EACA,kBA9HiB;EA+HjB,iBAjIuB;EAkIvB,OAlIuB;EAmIvB;EACA;EACA;;AAEA;AAAA;AAAA;EAEE;;;AAKN;EACE;EACA;EACA;EACA,kBA1JiB;EA2JjB;EACA;EACA,eA/JsB;EAgKtB,WAnKqB;EAoKrB;EACA;;AAEA;EAEE;;AAGF;EACE;;AAGF;EACE;;;AAIJ;EACE;EACA;EACA;;AAOF;EACE;EACA;EACA;;AAEA;EACE;EACA;;AAEF;EACE;;;AAIJ;EACE;;AACA;EACE;EACA;EACA,eA9MyB;EA+MzB;EACA,WAnNmB;EAoNnB;EACA;EACA;EACA,kBA9MoB;EA+MpB;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;;AAGF;EACE;EACA;;AAGF;EACE;EACA;;;AAKN;EACE;EACA,SApOgB;EAqOhB;EACA;EACA,kBAjP0B;EAkP1B;EACA;EACA;EACA,2BAzPsB;EA0PtB,4BA1PsB;EA2PtB;EACA;EACA;;AAEA;EACE;;AAGF;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA,WA3RmB;;AA6RnB;EACE;;AAIF;EADF;IAEI;;EAEA;IACE;IACA,WAtSe;IAuSf;IACA;IACA;IACA;IACA;;EAGF;IACE;IACA;IACA;;EAEA;IACE;IACA;;;AAKN;EACE;;AAEA;EACE;;;AAUR;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA,WAxVqB;EAyVrB;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;;AAIJ;EACE;EACA;EACA,kBA3WiB;EA4WjB,WAjXqB;EAkXrB;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EAIE;;AAGF;EAEE;EACA;EACA;;AAGF;EACE;EACA;;;AAIJ;EACE;;;AAGF","file":"choices.css"}

1
public/assets/styles/choices.min.css vendored Normal file

File diff suppressed because one or more lines are too long

957
public/index.html Normal file
View file

@ -0,0 +1,957 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width,initial-scale=1,user-scalable=no"
/>
<title>Choices</title>
<meta
name="description"
itemprop="description"
content="A lightweight, configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency."
/>
<link
rel="apple-touch-icon"
sizes="180x180"
href="assets/images/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
href="assets/images/favicon-32x32.png"
sizes="32x32"
/>
<link
rel="icon"
type="image/png"
href="assets/images/favicon-16x16.png"
sizes="16x16"
/>
<link rel="manifest" href="assets/images/manifest.json" />
<link
rel="mask-icon"
href="assets/images/safari-pinned-tab.svg"
color="#00bcd4"
/>
<link rel="shortcut icon" href="assets/images/favicon.ico" />
<meta
name="msapplication-config"
content="/assets/images/browserconfig.xml"
/>
<meta name="theme-color" content="#ffffff" />
<!-- Ignore these -->
<link rel="stylesheet" href="assets/styles/base.min.css" />
<!-- End ignore these -->
<!-- Optional includes -->
<script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=Array.from%2Ces5%2Ces6%2CSymbol%2CSymbol.iterator%2CDOMTokenList%2CObject.assign%2CCustomEvent%2CElement.prototype.classList%2CElement.prototype.closest%2CElement.prototype.dataset%2CArray.prototype.find%2CArray.prototype.includes%2Cfetch"></script>
<!-- End optional includes -->
<!-- Choices includes -->
<link rel="stylesheet" href="assets/styles/choices.min.css" />
<script src="assets/scripts/choices.js"></script>
<!-- End Choices includes -->
<!--[if lt IE 9]>
<style>
.hidden-ie {
display: none;
}
.visible-ie {
display: block;
}
</style>
<![endif]-->
</head>
<body>
<div class="container">
<div class="section">
<a href="https://github.com/jshjohnson/Choices" class="logo">
<img
src="assets/images/logo.svg"
alt="Choices.js logo"
class="logo-img hidden-ie"
/>
<h1 class="visible-ie">Choices.js</h1>
</a>
<p>
Choices.js is a lightweight, configurable select box/text input
plugin. Similar to Select2 and Selectize but without the jQuery
dependency.
</p>
<p>
For all config options, visit the
<a href="https://github.com/jshjohnson/Choices">GitHub repo</a>.
</p>
<hr />
<p class="h4 text-center">
<strong
>Interested in writing your own ES6 JavaScript plugins? Check out
<a href="https://ES6.io/friend/JOHNSON">ES6.io</a> for great
tutorials! 💪🏼</strong
>
</p>
<p class="h4 text-center">
<strong>Sponsored by:</strong>
<br />
<a href="https://wanderermaps.com/" target="_blank" rel="noopener noreferrer">
<img src="https://cdn.shopify.com/s/files/1/0614/3357/7715/files/Logo_BlackWithBackground_150x.png?v=1644802773" alt="Wanderer Maps logo">
</a>
</p>
<hr />
<h2>Text inputs</h2>
<label for="choices-text-remove-button"
>Limited to 5 values with remove button</label
>
<input
class="form-control"
id="choices-text-remove-button"
type="text"
value="preset-1,preset-2"
placeholder="Enter something"
/>
<label for="choices-text-unique-values"
>Unique values only, no pasting</label
>
<input
class="form-control"
id="choices-text-unique-values"
type="text"
value="preset-1, preset-2"
placeholder="This is a placeholder"
class="custom class"
/>
<label for="choices-text-email-filter">Email addresses only</label>
<input
class="form-control"
id="choices-text-email-filter"
type="text"
placeholder="This is a placeholder"
/>
<label for="choices-text-disabled">Disabled</label>
<input
class="form-control"
id="choices-text-disabled"
type="text"
value="josh@joshuajohnson.co.uk, joe@bloggs.co.uk"
placeholder="This is a placeholder"
/>
<label for="choices-text-prepend-append-value"
>Prepends and appends a value to each items return value</label
>
<input
class="form-control"
id="choices-text-prepend-append-value"
type="text"
value="preset-1, preset-2"
placeholder="This is a placeholder"
/>
<label for="choices-text-preset-values"
>Preset values passed through options</label
>
<input
class="form-control"
id="choices-text-preset-values"
type="text"
value="Michael Smith"
placeholder="This is a placeholder"
/>
<label for="choices-text-i18n">I18N labels</label>
<input class="form-control" id="choices-text-i18n" type="text" />
<label for="choices-text-rtl">Right-to-left</label>
<input
data-trigger
class="form-control"
id="choices-text-rtl"
type="text"
value="Value 1, Value 2"
dir="rtl"
/>
<hr />
<h2>Multiple select input</h2>
<label for="choices-multiple-default">Default</label>
<select
class="form-control"
data-trigger
name="choices-multiple-default"
id="choices-multiple-default"
placeholder="This is a placeholder"
multiple
>
<option value="Choice 1" selected>Choice 1</option>
<option value="Choice 2">Choice 2</option>
<option value="Choice 3">Choice 3</option>
<option value="Choice 4" disabled>Choice 4</option>
</select>
<label for="choices-multiple-remove-button">With remove button</label>
<select
class="form-control"
name="choices-multiple-remove-button"
id="choices-multiple-remove-button"
placeholder="This is a placeholder"
multiple
>
<option value="Choice 1" selected>Choice 1</option>
<option value="Choice 2">Choice 2</option>
<option value="Choice 3">Choice 3</option>
<option value="Choice 4">Choice 4</option>
</select>
<label for="choices-multiple-groups">Option groups</label>
<select
class="form-control"
name="choices-multiple-groups"
id="choices-multiple-groups"
placeholder="This is a placeholder"
multiple
>
<option value="">Choose a city</option>
<optgroup label="UK">
<option value="London">London</option>
<option value="Manchester">Manchester</option>
<option value="Liverpool">Liverpool</option>
</optgroup>
<optgroup label="FR">
<option value="Paris">Paris</option>
<option value="Lyon">Lyon</option>
<option value="Marseille">Marseille</option>
</optgroup>
<optgroup label="DE" disabled>
<option value="Hamburg">Hamburg</option>
<option value="Munich">Munich</option>
<option value="Berlin">Berlin</option>
</optgroup>
<optgroup label="US">
<option value="New York">New York</option>
<option value="Washington" disabled>Washington</option>
<option value="Michigan">Michigan</option>
</optgroup>
<optgroup label="SP">
<option value="Madrid">Madrid</option>
<option value="Barcelona">Barcelona</option>
<option value="Malaga">Malaga</option>
</optgroup>
<optgroup label="CA">
<option value="Montreal">Montreal</option>
<option value="Toronto">Toronto</option>
<option value="Vancouver">Vancouver</option>
</optgroup>
</select>
<p>
<small
>If the following example do not load, the Discogs rate limit has
probably been reached. Try again later!</small
>
</p>
<label for="choices-multiple-remote-fetch"
>Options from remote source (Fetch API) &amp; limited to 5</label
>
<select
class="form-control"
name="choices-multiple-remote-fetch"
id="choices-multiple-remote-fetch"
multiple
></select>
<label for="choices-multiple-rtl">Right-to-left</label>
<select
class="form-control"
data-trigger
name="choices-multiple-rtl"
id="choices-multiple-rtl"
placeholder="This is a placeholder"
multiple
dir="rtl"
>
<option value="Choice 1" selected>Choice 1</option>
<option value="Choice 2">Choice 2</option>
<option value="Choice 3">Choice 3</option>
<option value="Choice 4" disabled>Choice 4</option>
</select>
<label for="choices-multiple-labels"
>Use label in event (add/remove)</label
>
<p id="message"></p>
<select id="choices-multiple-labels" multiple></select>
<hr />
<h2>Single select input</h2>
<label id="choices-single-default-label" for="choices-single-default"
>Default</label
>
<select
class="form-control"
data-trigger
name="choices-single-default"
id="choices-single-default"
placeholder="This is a search placeholder"
>
<option value="">This is a placeholder</option>
<option value="Choice 1">Choice 1</option>
<option value="Choice 2">Choice 2</option>
<option value="Choice 3">Choice 3</option>
</select>
<p>
<small
>If the following two examples do not load, the Discogs rate limit
has probably been reached. Try again later!</small
>
</p>
<label for="choices-single-remote-fetch"
>Options from remote source (Fetch API)</label
>
<select
class="form-control"
name="choices-single-remote-fetch"
id="choices-single-remote-fetch"
>
<option value="">Pick an Arctic Monkeys' record</option>
</select>
<label for="choices-single-remove-xhr"
>Options from remote source (Fetch API) &amp; remove button</label
>
<select
class="form-control"
name="choices-single-remove-xhr"
id="choices-single-remove-xhr"
>
<option value="">Pick a Smiths' record</option>
</select>
<label for="choices-single-groups">Option groups</label>
<select
class="form-control"
data-trigger
name="choices-single-groups"
id="choices-single-groups"
>
<option value="">Choose a city</option>
<optgroup label="UK">
<option value="London">London</option>
<option value="Manchester">Manchester</option>
<option value="Liverpool">Liverpool</option>
</optgroup>
<optgroup label="FR">
<option value="Paris">Paris</option>
<option value="Lyon">Lyon</option>
<option value="Marseille">Marseille</option>
</optgroup>
<optgroup label="DE" disabled>
<option value="Hamburg">Hamburg</option>
<option value="Munich">Munich</option>
<option value="Berlin">Berlin</option>
</optgroup>
<optgroup label="US">
<option value="New York">New York</option>
<option value="Washington" disabled>Washington</option>
<option value="Michigan">Michigan</option>
</optgroup>
<optgroup label="SP">
<option value="Madrid">Madrid</option>
<option value="Barcelona">Barcelona</option>
<option value="Malaga">Malaga</option>
</optgroup>
<optgroup label="CA">
<option value="Montreal">Montreal</option>
<option value="Toronto">Toronto</option>
<option value="Vancouver">Vancouver</option>
</optgroup>
</select>
<label for="choices-single-rtl">Right-to-left</label>
<select
class="form-control"
data-trigger
name="choices-single-rtl"
id="choices-single-rtl"
dir="rtl"
>
<option value="Choice 1">Choice 1</option>
<option value="Choice 2">Choice 2</option>
<option value="Choice 3">Choice 3</option>
</select>
<label for="choices-single-no-search"
>Options added via config with no search</label
>
<select
class="form-control"
name="choices-single-no-search"
id="choices-single-no-search"
>
<option value="0">Zero</option>
</select>
<label for="choices-single-preset-options"
>Option and option groups added via config</label
>
<select
class="form-control"
name="choices-single-preset-options"
id="choices-single-preset-options"
></select>
<label for="choices-single-selected-option"
>Option selected via config with custom properties</label
>
<p>
<small>Try searching for 'fantastic', "Label 3" should display</small>
</p>
<select
class="form-control"
name="choices-single-selected-option"
id="choices-single-selected-option"
></select>
<label for="choices-with-custom-props-via-html"
>Option searchable by custom properties via
<code>data-custom-properties</code> attribute</label
>
<p>
<small>Try searching for 'fantastic', "Label 3" should display</small>
</p>
<select class="form-control" id="choices-with-custom-props-via-html">
<option value="Dropdown item 1">Label One</option>
<option value="Dropdown item 2" selected disabled>Label Two</option>
<option
value="Dropdown item 3"
data-custom-properties="This option is fantastic"
>Label Three</option
>
<option
value="Dropdown item 4"
data-custom-properties="{ 'description': 'foo' }"
>Label Four</option
>
</select>
<label
id="choices-single-no-sorting-label"
for="choices-single-no-sorting"
>Options without sorting</label
>
<select
class="form-control"
name="choices-single-no-sorting"
id="choices-single-no-sorting"
>
<option value="Madrid">Madrid</option>
<option value="Toronto">Toronto</option>
<option value="Vancouver">Vancouver</option>
<option value="London">London</option>
<option value="Manchester">Manchester</option>
<option value="Liverpool">Liverpool</option>
<option value="Paris">Paris</option>
<option value="Malaga">Malaga</option>
<option value="Washington" disabled>Washington</option>
<option value="Lyon">Lyon</option>
<option value="Marseille">Marseille</option>
<option value="Hamburg">Hamburg</option>
<option value="Munich">Munich</option>
<option value="Barcelona">Barcelona</option>
<option value="Berlin">Berlin</option>
<option value="Montreal">Montreal</option>
<option value="New York">New York</option>
<option value="Michigan">Michigan</option>
</select>
<label for="choices-single-custom-templates">Custom templates</label>
<select
class="form-control"
name="choices-single-custom-templates"
id="choices-single-custom-templates"
>
<option value="React">React</option>
<option value="Angular">Angular</option>
<option value="Ember">Ember</option>
<option value="Vue">Vue</option>
</select>
<p>
Below is an example of how you could have two select inputs depend on
eachother. 'Tube stations' will only be enabled if the value of
'Cities' is 'London'
</p>
<label for="cities">Cities</label>
<select class="form-control" name="cities" id="cities">
<option value="">Choose a city</option>
<option value="Leeds">Leeds</option>
<option value="Manchester">Manchester</option>
<option value="London">London</option>
<option value="Sheffield">Sheffield</option>
<option value="Newcastle">Newcastle</option>
</select>
<label for="tube-stations">Tube stations</label>
<select class="form-control" name="tube-stations" id="tube-stations">
<option value="">Choose a tube station</option>
<option value="Moorgate">Moorgate</option>
<option value="St Pauls">St Pauls</option>
<option value="Old Street">Old Street</option>
<option value="Liverpool Street">Liverpool Street</option>
<option value="Kings Cross St. Pancras"
>Kings Cross St. Pancras</option
>
</select>
<hr />
<h2>Form interaction</h2>
<p>Change the values and press reset to restore to initial state.</p>
<form>
<label for="reset-simple">Change me!</label>
<select class="form-control" name="reset-simple" id="reset-simple">
<option value="Option 1">Option 1</option>
<option value="Option 2" selected>Option 2</option>
<option value="Option 3">Option 3</option>
<option value="Option 4">Option 4</option>
<option value="Option 5">Option 5</option>
</select>
<label for="reset-multiple">And me!</label>
<select
class="form-control"
name="reset-multiple"
id="reset-multiple"
multiple
>
<option value="Choice 1" selected>Choice 1</option>
<option value="Choice 2">Choice 2</option>
<option value="Choice 3">Choice 3</option>
<option value="Choice 4" disabled>Choice 4</option>
</select>
<button type="reset">Reset</button>
</form>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var genericExamples = document.querySelectorAll('[data-trigger]');
for (i = 0; i < genericExamples.length; ++i) {
var element = genericExamples[i];
new Choices(element, {
allowHTML: true,
placeholderValue: 'This is a placeholder set in the config',
searchPlaceholderValue: 'This is a search placeholder',
});
}
var textRemove = new Choices(
document.getElementById('choices-text-remove-button'),
{
allowHTML: true,
delimiter: ',',
editItems: true,
maxItemCount: 5,
removeItemButton: true,
}
);
var textUniqueVals = new Choices('#choices-text-unique-values', {
allowHTML: true,
paste: false,
duplicateItemsAllowed: false,
editItems: true,
});
var texti18n = new Choices('#choices-text-i18n', {
allowHTML: true,
paste: false,
duplicateItemsAllowed: false,
editItems: true,
maxItemCount: 5,
addItemText: function(value) {
return (
'Appuyez sur Entrée pour ajouter <b>"' + String(value) + '"</b>'
);
},
maxItemText: function(maxItemCount) {
return String(maxItemCount) + 'valeurs peuvent être ajoutées';
},
uniqueItemText: 'Cette valeur est déjà présente',
});
var textEmailFilter = new Choices('#choices-text-email-filter', {
allowHTML: true,
editItems: true,
addItemFilter: function(value) {
if (!value) {
return false;
}
const regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
const expression = new RegExp(regex.source, 'i');
return expression.test(value);
},
}).setValue(['joe@bloggs.com']);
var textDisabled = new Choices('#choices-text-disabled', {
allowHTML: true,
addItems: false,
removeItems: false,
}).disable();
var textPrependAppendVal = new Choices(
'#choices-text-prepend-append-value',
{
allowHTML: true,
prependValue: 'item-',
appendValue: '-' + Date.now(),
}
).removeActiveItems();
var textPresetVal = new Choices('#choices-text-preset-values', {
allowHTML: true,
items: [
'Josh Johnson',
{
value: 'joe@bloggs.co.uk',
label: 'Joe Bloggs',
customProperties: {
description: 'Joe Blogg is such a generic name',
},
},
],
});
var multipleDefault = new Choices(
document.getElementById('choices-multiple-groups'),
{ allowHTML: true }
);
var multipleFetch = new Choices('#choices-multiple-remote-fetch', {
allowHTML: false,
placeholder: true,
placeholderValue: 'Pick an Strokes record',
maxItemCount: 5,
}).setChoices(function() {
return fetch(
'https://api.discogs.com/artists/55980/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW'
)
.then(function(response) {
return response.json();
})
.then(function(data) {
return data.releases.map(function(release) {
return { value: release.title, label: release.title };
});
});
});
var multipleCancelButton = new Choices(
'#choices-multiple-remove-button',
{
allowHTML: true,
removeItemButton: true,
}
);
/* Use label on event */
var choicesSelect = new Choices('#choices-multiple-labels', {
allowHTML: true,
removeItemButton: true,
choices: [
{ value: 'One', label: 'Label One' },
{ value: 'Two', label: 'Label Two', disabled: true },
{ value: 'Three', label: 'Label Three' },
],
}).setChoices(
[
{ value: 'Four', label: 'Label Four', disabled: true },
{ value: 'Five', label: 'Label Five' },
{ value: 'Six', label: 'Label Six', selected: true },
],
'value',
'label',
false
);
choicesSelect.passedElement.element.addEventListener(
'addItem',
function(event) {
document.getElementById('message').innerHTML =
'You just added "' + event.detail.label + '"';
}
);
choicesSelect.passedElement.element.addEventListener(
'removeItem',
function(event) {
document.getElementById('message').innerHTML =
'You just removed "' + event.detail.label + '"';
}
);
var singleFetch = new Choices('#choices-single-remote-fetch', {
allowHTML: false,
searchPlaceholderValue: 'Search for an Arctic Monkeys record',
})
.setChoices(function() {
return fetch(
'https://api.discogs.com/artists/391170/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW'
)
.then(function(response) {
return response.json();
})
.then(function(data) {
return data.releases.map(function(release) {
return { label: release.title, value: release.title };
});
});
})
.then(function(instance) {
instance.setChoiceByValue('Fake Tales Of San Francisco');
});
var singleXhrRemove = new Choices('#choices-single-remove-xhr', {
allowHTML: true,
removeItemButton: true,
searchPlaceholderValue: "Search for a Smiths' record",
}).setChoices(function(callback) {
return fetch(
'https://api.discogs.com/artists/83080/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW'
)
.then(function(res) {
return res.json();
})
.then(function(data) {
return data.releases.map(function(release) {
return { label: release.title, value: release.title };
});
});
});
var singleNoSearch = new Choices('#choices-single-no-search', {
allowHTML: true,
searchEnabled: false,
removeItemButton: true,
choices: [
{ value: 'One', label: 'Label One' },
{ value: 'Two', label: 'Label Two', disabled: true },
{ value: 'Three', label: 'Label Three' },
],
}).setChoices(
[
{ value: 'Four', label: 'Label Four', disabled: true },
{ value: 'Five', label: 'Label Five' },
{ value: 'Six', label: 'Label Six', selected: true },
],
'value',
'label',
false
);
var singlePresetOpts = new Choices('#choices-single-preset-options', {
allowHTML: true,
placeholder: true,
}).setChoices(
[
{
label: 'Group one',
id: 1,
disabled: false,
choices: [
{ value: 'Child One', label: 'Child One', selected: true },
{ value: 'Child Two', label: 'Child Two', disabled: true },
{ value: 'Child Three', label: 'Child Three' },
],
},
{
label: 'Group two',
id: 2,
disabled: false,
choices: [
{ value: 'Child Four', label: 'Child Four', disabled: true },
{ value: 'Child Five', label: 'Child Five' },
{ value: 'Child Six', label: 'Child Six' },
],
},
],
'value',
'label'
);
var singleSelectedOpt = new Choices('#choices-single-selected-option', {
allowHTML: true,
searchFields: ['label', 'value', 'customProperties.description'],
choices: [
{ value: 'One', label: 'Label One', selected: true },
{ value: 'Two', label: 'Label Two', disabled: true },
{
value: 'Three',
label: 'Label Three',
customProperties: {
description: 'This option is fantastic',
},
},
],
}).setChoiceByValue('Two');
var customChoicesPropertiesViaDataAttributes = new Choices(
'#choices-with-custom-props-via-html',
{
allowHTML: true,
searchFields: ['label', 'value', 'customProperties'],
}
);
var singleNoSorting = new Choices('#choices-single-no-sorting', {
allowHTML: true,
shouldSort: false,
labelId: 'choices-single-no-sorting-label',
});
var cities = new Choices(document.getElementById('cities'), { allowHTML: true });
var tubeStations = new Choices(
document.getElementById('tube-stations'),
{ allowHTML: true }
).disable();
cities.passedElement.element.addEventListener('change', function(e) {
if (e.detail.value === 'London') {
tubeStations.enable();
} else {
tubeStations.disable();
}
});
var customTemplates = new Choices(
document.getElementById('choices-single-custom-templates'),
{
allowHTML: true,
callbackOnCreateTemplates: function(strToEl) {
var classNames = this.config.classNames;
var itemSelectText = this.config.itemSelectText;
return {
item: function({ classNames }, data) {
return strToEl(
'\
<div\
class="' +
String(classNames.item) +
' ' +
String(
data.highlighted
? classNames.highlightedState
: classNames.itemSelectable
) +
'"\
data-item\
data-id="' +
String(data.id) +
'"\
data-value="' +
String(data.value) +
'"\
' +
String(data.active ? 'aria-selected="true"' : '') +
'\
' +
String(data.disabled ? 'aria-disabled="true"' : '') +
'\
>\
<span style="margin-right:10px;">🎉</span> ' +
String(data.label) +
'\
</div>\
'
);
},
choice: function({ classNames }, data) {
return strToEl(
'\
<div\
class="' +
String(classNames.item) +
' ' +
String(classNames.itemChoice) +
' ' +
String(
data.disabled
? classNames.itemDisabled
: classNames.itemSelectable
) +
'"\
data-select-text="' +
String(itemSelectText) +
'"\
data-choice \
' +
String(
data.disabled
? 'data-choice-disabled aria-disabled="true"'
: 'data-choice-selectable'
) +
'\
data-id="' +
String(data.id) +
'"\
data-value="' +
String(data.value) +
'"\
' +
String(
data.groupId > 0 ? 'role="treeitem"' : 'role="option"'
) +
'\
>\
<span style="margin-right:10px;">👉🏽</span> ' +
String(data.label) +
'\
</div>\
'
);
},
};
},
}
);
var resetSimple = new Choices(document.getElementById('reset-simple'), {
allowHTML: true,
});
var resetMultiple = new Choices('#reset-multiple', {
allowHTML: true,
removeItemButton: true,
});
});
</script>
<!-- Google Analytics - Ignore me -->
<script>
window.ga =
window.ga ||
function() {
(ga.q = ga.q || []).push(arguments);
};
ga.l = +new Date();
ga('create', 'UA-31575166-1', 'auto');
ga('send', 'pageview');
</script>
<script async src="https://www.google-analytics.com/analytics.js"></script>
<!-- End Google Analytics -->
</body>
</html>

Some files were not shown because too many files have changed in this diff Show more