@nanoporetech-digital/components 2.10.1 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/dist/cjs/{date-utils-0ae9a12d.js → date-utils-b3af910d.js} +2 -2
- package/dist/cjs/date-utils-b3af910d.js.map +1 -0
- package/dist/cjs/{global-0d4f3b77.js → global-989678ec.js} +1 -8
- package/dist/cjs/global-989678ec.js.map +1 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/nano-algolia.cjs.entry.js +5 -1
- package/dist/cjs/nano-algolia.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-components.cjs.js +2 -2
- package/dist/cjs/nano-datalist_3.cjs.entry.js +3 -1
- package/dist/cjs/nano-datalist_3.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-date-input.cjs.entry.js +16 -5
- package/dist/cjs/nano-date-input.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-date-picker.cjs.entry.js +2 -2
- package/dist/cjs/nano-date-picker.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-details.cjs.entry.js +1 -2
- package/dist/cjs/nano-details.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-field-validator.cjs.entry.js +292 -96
- package/dist/cjs/nano-field-validator.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-file-upload.cjs.entry.js +5 -2
- package/dist/cjs/nano-file-upload.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-global-search-results.cjs.entry.js +21 -6
- package/dist/cjs/nano-global-search-results.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-grid_3.cjs.entry.js +1 -2
- package/dist/cjs/nano-grid_3.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-icon-button.cjs.entry.js +4 -0
- package/dist/cjs/nano-icon-button.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-input.cjs.entry.js +16 -3
- package/dist/cjs/nano-input.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-nav-item_2.cjs.entry.js +2 -0
- package/dist/cjs/nano-nav-item_2.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-resize-observe_2.cjs.entry.js +1 -2
- package/dist/cjs/nano-resize-observe_2.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-slides.cjs.entry.js +1 -2
- package/dist/cjs/nano-slides.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-sticker.cjs.entry.js +2 -3
- package/dist/cjs/nano-sticker.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-tab-group.cjs.entry.js +4 -2
- package/dist/cjs/nano-tab-group.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-tab.cjs.entry.js +5 -1
- package/dist/cjs/nano-tab.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/nano-tooltip.cjs.entry.js.map +1 -1
- package/dist/collection/components/accordion/accordion.js +1 -1
- package/dist/collection/components/alert/alert.js +1 -1
- package/dist/collection/components/algolia/algolia-filter.js +2 -2
- package/dist/collection/components/algolia/algolia-input.js +5 -5
- package/dist/collection/components/algolia/algolia-results.js +1 -1
- package/dist/collection/components/algolia/algolia.js +12 -6
- package/dist/collection/components/algolia/algolia.js.map +1 -1
- package/dist/collection/components/checkbox/checkbox-group.js +2 -2
- package/dist/collection/components/checkbox/checkbox.js +3 -3
- package/dist/collection/components/datalist/datalist.js +4 -2
- package/dist/collection/components/datalist/datalist.js.map +1 -1
- package/dist/collection/components/date-input/date-input.js +65 -11
- package/dist/collection/components/date-input/date-input.js.map +1 -1
- package/dist/collection/components/date-picker/date-picker.css +1 -1
- package/dist/collection/components/date-picker/date-picker.js +5 -5
- package/dist/collection/components/details/details.js +1 -2
- package/dist/collection/components/details/details.js.map +1 -1
- package/dist/collection/components/dialog/dialog.js +1 -1
- package/dist/collection/components/dropdown/dropdown.js +1 -1
- package/dist/collection/components/field-validator/field-validator-interface.js +5 -0
- package/dist/collection/components/field-validator/field-validator-interface.js.map +1 -0
- package/dist/collection/components/field-validator/field-validator.js +434 -113
- package/dist/collection/components/field-validator/field-validator.js.map +1 -1
- package/dist/collection/components/file-upload/file-upload.css +0 -1
- package/dist/collection/components/file-upload/file-upload.js +10 -7
- package/dist/collection/components/file-upload/file-upload.js.map +1 -1
- package/dist/collection/components/global-nav/global-nav.js +4 -4
- package/dist/collection/components/global-search-results/global-search-results.css +7 -0
- package/dist/collection/components/global-search-results/global-search-results.js +19 -4
- package/dist/collection/components/global-search-results/global-search-results.js.map +1 -1
- package/dist/collection/components/grid/grid-item.js +1 -1
- package/dist/collection/components/grid/grid.js +0 -1
- package/dist/collection/components/grid/grid.js.map +1 -1
- package/dist/collection/components/icon/icon.js +1 -1
- package/dist/collection/components/icon-button/icon-button.js +23 -1
- package/dist/collection/components/icon-button/icon-button.js.map +1 -1
- package/dist/collection/components/input/input.js +37 -8
- package/dist/collection/components/input/input.js.map +1 -1
- package/dist/collection/components/nav-item/nav-item.js +4 -4
- package/dist/collection/components/range/range.js +4 -4
- package/dist/collection/components/resize-observe/resize-observe.js +1 -2
- package/dist/collection/components/resize-observe/resize-observe.js.map +1 -1
- package/dist/collection/components/select/select.js +9 -7
- package/dist/collection/components/select/select.js.map +1 -1
- package/dist/collection/components/slides/slides.js +7 -8
- package/dist/collection/components/slides/slides.js.map +1 -1
- package/dist/collection/components/sticker/sticker.js +0 -1
- package/dist/collection/components/sticker/sticker.js.map +1 -1
- package/dist/collection/components/tabs/tab-group.js +5 -3
- package/dist/collection/components/tabs/tab-group.js.map +1 -1
- package/dist/collection/components/tabs/tab.js +5 -1
- package/dist/collection/components/tabs/tab.js.map +1 -1
- package/dist/collection/components/tooltip/tooltip.css +0 -1
- package/dist/collection/global/script/global.js +0 -7
- package/dist/collection/global/script/global.js.map +1 -1
- package/dist/collection/index.js +1 -0
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/utils/date-utils.js +1 -1
- package/dist/collection/utils/date-utils.js.map +1 -1
- package/dist/components/algolia.js +5 -1
- package/dist/components/algolia.js.map +1 -1
- package/dist/components/datalist.js +3 -1
- package/dist/components/datalist.js.map +1 -1
- package/dist/components/date-picker.js +2 -2
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/grid.js +1 -2
- package/dist/components/grid.js.map +1 -1
- package/dist/components/icon-button.js +6 -1
- package/dist/components/icon-button.js.map +1 -1
- package/dist/components/index.js +1 -7
- package/dist/components/index.js.map +1 -1
- package/dist/components/input.js +17 -3
- package/dist/components/input.js.map +1 -1
- package/dist/components/nano-date-input.js +17 -4
- package/dist/components/nano-date-input.js.map +1 -1
- package/dist/components/nano-details.js +1 -2
- package/dist/components/nano-details.js.map +1 -1
- package/dist/components/nano-field-validator.js +300 -99
- package/dist/components/nano-field-validator.js.map +1 -1
- package/dist/components/nano-file-upload.js +6 -3
- package/dist/components/nano-file-upload.js.map +1 -1
- package/dist/components/nano-global-search-results.js +21 -6
- package/dist/components/nano-global-search-results.js.map +1 -1
- package/dist/components/nano-slides.js +1 -2
- package/dist/components/nano-slides.js.map +1 -1
- package/dist/components/nano-tab-group.js +4 -2
- package/dist/components/nano-tab-group.js.map +1 -1
- package/dist/components/nano-tab.js +5 -1
- package/dist/components/nano-tab.js.map +1 -1
- package/dist/components/resize-observe.js +1 -2
- package/dist/components/resize-observe.js.map +1 -1
- package/dist/components/select.js +2 -0
- package/dist/components/select.js.map +1 -1
- package/dist/components/sticker.js +2 -3
- package/dist/components/sticker.js.map +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/custom-elements/index.js +386 -2046
- package/dist/custom-elements/index.js.map +1 -1
- package/dist/esm/{date-utils-e4b757ff.js → date-utils-839cb010.js} +2 -2
- package/dist/esm/date-utils-839cb010.js.map +1 -0
- package/dist/esm/{global-d5ec4d53.js → global-8047b4ff.js} +1 -8
- package/dist/esm/global-8047b4ff.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/nano-algolia.entry.js +5 -1
- package/dist/esm/nano-algolia.entry.js.map +1 -1
- package/dist/esm/nano-components.js +2 -2
- package/dist/esm/nano-datalist_3.entry.js +3 -1
- package/dist/esm/nano-datalist_3.entry.js.map +1 -1
- package/dist/esm/nano-date-input.entry.js +16 -5
- package/dist/esm/nano-date-input.entry.js.map +1 -1
- package/dist/esm/nano-date-picker.entry.js +2 -2
- package/dist/esm/nano-date-picker.entry.js.map +1 -1
- package/dist/esm/nano-details.entry.js +1 -2
- package/dist/esm/nano-details.entry.js.map +1 -1
- package/dist/esm/nano-field-validator.entry.js +292 -96
- package/dist/esm/nano-field-validator.entry.js.map +1 -1
- package/dist/esm/nano-file-upload.entry.js +5 -2
- package/dist/esm/nano-file-upload.entry.js.map +1 -1
- package/dist/esm/nano-global-search-results.entry.js +21 -6
- package/dist/esm/nano-global-search-results.entry.js.map +1 -1
- package/dist/esm/nano-grid_3.entry.js +1 -2
- package/dist/esm/nano-grid_3.entry.js.map +1 -1
- package/dist/esm/nano-icon-button.entry.js +4 -0
- package/dist/esm/nano-icon-button.entry.js.map +1 -1
- package/dist/esm/nano-input.entry.js +16 -3
- package/dist/esm/nano-input.entry.js.map +1 -1
- package/dist/esm/nano-nav-item_2.entry.js +2 -0
- package/dist/esm/nano-nav-item_2.entry.js.map +1 -1
- package/dist/esm/nano-resize-observe_2.entry.js +1 -2
- package/dist/esm/nano-resize-observe_2.entry.js.map +1 -1
- package/dist/esm/nano-slides.entry.js +1 -2
- package/dist/esm/nano-slides.entry.js.map +1 -1
- package/dist/esm/nano-sticker.entry.js +2 -3
- package/dist/esm/nano-sticker.entry.js.map +1 -1
- package/dist/esm/nano-tab-group.entry.js +4 -2
- package/dist/esm/nano-tab-group.entry.js.map +1 -1
- package/dist/esm/nano-tab.entry.js +5 -1
- package/dist/esm/nano-tab.entry.js.map +1 -1
- package/dist/esm/nano-tooltip.entry.js +1 -1
- package/dist/esm/nano-tooltip.entry.js.map +1 -1
- package/dist/esm-es5/date-utils-839cb010.js +5 -0
- package/dist/esm-es5/date-utils-839cb010.js.map +1 -0
- package/dist/esm-es5/{global-d5ec4d53.js → global-8047b4ff.js} +2 -2
- package/dist/esm-es5/global-8047b4ff.js.map +1 -0
- package/dist/esm-es5/index.js +2 -2
- package/dist/esm-es5/index.js.map +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/loader.js.map +1 -1
- package/dist/esm-es5/nano-algolia.entry.js +1 -1
- package/dist/esm-es5/nano-algolia.entry.js.map +1 -1
- package/dist/esm-es5/nano-components.js +1 -1
- package/dist/esm-es5/nano-components.js.map +1 -1
- package/dist/esm-es5/nano-datalist_3.entry.js +1 -1
- package/dist/esm-es5/nano-datalist_3.entry.js.map +1 -1
- package/dist/esm-es5/nano-date-input.entry.js +1 -1
- package/dist/esm-es5/nano-date-input.entry.js.map +1 -1
- package/dist/esm-es5/nano-date-picker.entry.js +1 -1
- package/dist/esm-es5/nano-date-picker.entry.js.map +1 -1
- package/dist/esm-es5/nano-details.entry.js +1 -1
- package/dist/esm-es5/nano-details.entry.js.map +1 -1
- package/dist/esm-es5/nano-field-validator.entry.js +2 -2
- package/dist/esm-es5/nano-field-validator.entry.js.map +1 -1
- package/dist/esm-es5/nano-file-upload.entry.js +1 -1
- package/dist/esm-es5/nano-file-upload.entry.js.map +1 -1
- package/dist/esm-es5/nano-global-search-results.entry.js +1 -1
- package/dist/esm-es5/nano-global-search-results.entry.js.map +1 -1
- package/dist/esm-es5/nano-grid_3.entry.js +1 -1
- package/dist/esm-es5/nano-grid_3.entry.js.map +1 -1
- package/dist/esm-es5/nano-icon-button.entry.js +2 -2
- package/dist/esm-es5/nano-icon-button.entry.js.map +1 -1
- package/dist/esm-es5/nano-input.entry.js +1 -1
- package/dist/esm-es5/nano-input.entry.js.map +1 -1
- package/dist/esm-es5/nano-nav-item_2.entry.js +1 -1
- package/dist/esm-es5/nano-nav-item_2.entry.js.map +1 -1
- package/dist/esm-es5/nano-resize-observe_2.entry.js +1 -1
- package/dist/esm-es5/nano-resize-observe_2.entry.js.map +1 -1
- package/dist/esm-es5/nano-slides.entry.js +2 -2
- package/dist/esm-es5/nano-slides.entry.js.map +1 -1
- package/dist/esm-es5/nano-sticker.entry.js +1 -1
- package/dist/esm-es5/nano-sticker.entry.js.map +1 -1
- package/dist/esm-es5/nano-tab-group.entry.js +2 -2
- package/dist/esm-es5/nano-tab-group.entry.js.map +1 -1
- package/dist/esm-es5/nano-tab.entry.js +2 -2
- package/dist/esm-es5/nano-tab.entry.js.map +1 -1
- package/dist/esm-es5/nano-tooltip.entry.js +1 -1
- package/dist/esm-es5/nano-tooltip.entry.js.map +1 -1
- package/dist/nano-components/index.esm.js +1 -1
- package/dist/nano-components/index.esm.js.map +1 -1
- package/dist/nano-components/nano-components.esm.js +1 -1
- package/dist/nano-components/nano-components.esm.js.map +1 -1
- package/dist/nano-components/nano-components.js +1 -1
- package/dist/nano-components/p-018b7047.entry.js +5 -0
- package/dist/nano-components/p-018b7047.entry.js.map +1 -0
- package/dist/nano-components/p-0193a282.entry.js +5 -0
- package/dist/nano-components/p-0193a282.entry.js.map +1 -0
- package/dist/nano-components/p-0320410c.entry.js +5 -0
- package/dist/nano-components/p-0320410c.entry.js.map +1 -0
- package/dist/nano-components/p-0d699368.system.js +5 -0
- package/dist/nano-components/{p-3258c568.system.js.map → p-0d699368.system.js.map} +1 -1
- package/dist/nano-components/p-18863670.system.entry.js +5 -0
- package/dist/nano-components/p-18863670.system.entry.js.map +1 -0
- package/dist/nano-components/p-32900c91.entry.js +5 -0
- package/dist/nano-components/p-32900c91.entry.js.map +1 -0
- package/dist/nano-components/p-33fce1a6.js +5 -0
- package/dist/nano-components/p-33fce1a6.js.map +1 -0
- package/dist/nano-components/p-371aebe7.system.entry.js +23 -0
- package/dist/nano-components/p-371aebe7.system.entry.js.map +1 -0
- package/dist/nano-components/p-41899a31.system.entry.js +5 -0
- package/dist/nano-components/p-41899a31.system.entry.js.map +1 -0
- package/dist/nano-components/p-53957ec6.system.js +5 -0
- package/dist/nano-components/{p-e7140887.system.js.map → p-53957ec6.system.js.map} +1 -1
- package/dist/nano-components/p-561500f0.system.entry.js +5 -0
- package/dist/nano-components/p-561500f0.system.entry.js.map +1 -0
- package/dist/nano-components/p-596c1711.system.entry.js +5 -0
- package/dist/nano-components/p-596c1711.system.entry.js.map +1 -0
- package/dist/nano-components/{p-01667573.entry.js → p-634a58f7.entry.js} +2 -2
- package/dist/nano-components/p-634a58f7.entry.js.map +1 -0
- package/dist/nano-components/p-6a949280.system.entry.js +5 -0
- package/dist/nano-components/p-6a949280.system.entry.js.map +1 -0
- package/dist/nano-components/{p-bf9aa89d.system.entry.js → p-6af10533.system.entry.js} +3 -3
- package/dist/nano-components/p-6af10533.system.entry.js.map +1 -0
- package/dist/nano-components/p-70272eae.js +5 -0
- package/dist/nano-components/p-70272eae.js.map +1 -0
- package/dist/nano-components/p-755d9227.entry.js +5 -0
- package/dist/nano-components/p-755d9227.entry.js.map +1 -0
- package/dist/nano-components/p-7bd25494.entry.js +5 -0
- package/dist/nano-components/p-7bd25494.entry.js.map +1 -0
- package/dist/nano-components/p-7c837460.entry.js +5 -0
- package/dist/nano-components/p-7c837460.entry.js.map +1 -0
- package/dist/nano-components/p-7f051c20.entry.js +5 -0
- package/dist/nano-components/p-7f051c20.entry.js.map +1 -0
- package/dist/nano-components/{p-93880c28.system.js → p-82e28afd.system.js} +2 -2
- package/dist/nano-components/p-82e28afd.system.js.map +1 -0
- package/dist/nano-components/p-8378428e.system.js +5 -0
- package/dist/nano-components/p-8378428e.system.js.map +1 -0
- package/dist/nano-components/p-8df4f125.system.entry.js +5 -0
- package/dist/nano-components/p-8df4f125.system.entry.js.map +1 -0
- package/dist/nano-components/{p-d0385948.system.entry.js → p-93596c3d.system.entry.js} +2 -2
- package/dist/nano-components/p-93596c3d.system.entry.js.map +1 -0
- package/dist/nano-components/{p-3e930ac7.entry.js → p-9d9b0b66.entry.js} +2 -2
- package/dist/nano-components/p-9d9b0b66.entry.js.map +1 -0
- package/dist/nano-components/p-9ffdf6cc.entry.js +5 -0
- package/dist/nano-components/{p-222d8095.entry.js.map → p-9ffdf6cc.entry.js.map} +1 -1
- package/dist/nano-components/p-a07cf44c.system.entry.js +5 -0
- package/dist/nano-components/p-a07cf44c.system.entry.js.map +1 -0
- package/dist/nano-components/p-a1444980.entry.js +5 -0
- package/dist/nano-components/p-a1444980.entry.js.map +1 -0
- package/dist/nano-components/p-aa84c727.system.entry.js +5 -0
- package/dist/nano-components/p-aa84c727.system.entry.js.map +1 -0
- package/dist/nano-components/p-ac5e3775.system.entry.js +5 -0
- package/dist/nano-components/p-ac5e3775.system.entry.js.map +1 -0
- package/dist/nano-components/p-b85cf493.system.entry.js +5 -0
- package/dist/nano-components/{p-e817ab4a.system.entry.js.map → p-b85cf493.system.entry.js.map} +1 -1
- package/dist/nano-components/{p-96d9b8b9.system.entry.js → p-c2bbf0fb.system.entry.js} +2 -2
- package/dist/nano-components/p-c2bbf0fb.system.entry.js.map +1 -0
- package/dist/nano-components/{p-f780d2f6.system.entry.js → p-cb512cff.system.entry.js} +2 -2
- package/dist/nano-components/p-cb512cff.system.entry.js.map +1 -0
- package/dist/nano-components/{p-4e2c0abb.entry.js → p-ccd6c206.entry.js} +2 -2
- package/dist/nano-components/p-ccd6c206.entry.js.map +1 -0
- package/dist/nano-components/{p-1030797a.entry.js → p-d37e1489.entry.js} +2 -2
- package/dist/nano-components/p-d37e1489.entry.js.map +1 -0
- package/dist/nano-components/p-da88981f.entry.js +23 -0
- package/dist/nano-components/p-da88981f.entry.js.map +1 -0
- package/dist/nano-components/p-e8a913ac.system.entry.js +5 -0
- package/dist/nano-components/p-e8a913ac.system.entry.js.map +1 -0
- package/dist/nano-components/p-e9fddc1a.entry.js +5 -0
- package/dist/nano-components/p-e9fddc1a.entry.js.map +1 -0
- package/dist/nano-components/p-ea54ee12.entry.js +5 -0
- package/dist/nano-components/p-ea54ee12.entry.js.map +1 -0
- package/dist/nano-components/{p-86bd5194.entry.js → p-ed0bdea9.entry.js} +2 -2
- package/dist/nano-components/p-ed0bdea9.entry.js.map +1 -0
- package/dist/nano-components/p-faba2fc1.system.entry.js +5 -0
- package/dist/nano-components/p-faba2fc1.system.entry.js.map +1 -0
- package/dist/nano-components/p-ff026352.system.entry.js +5 -0
- package/dist/nano-components/p-ff026352.system.entry.js.map +1 -0
- package/dist/themes/nanopore.css +1 -1
- package/dist/themes/nanopore.css.map +1 -1
- package/dist/types/components/algolia/algolia.d.ts +1 -0
- package/dist/types/components/date-input/date-input.d.ts +6 -1
- package/dist/types/components/field-validator/field-validator-interface.d.ts +19 -0
- package/dist/types/components/field-validator/field-validator.d.ts +77 -31
- package/dist/types/components/file-upload/file-upload.d.ts +2 -1
- package/dist/types/components/global-search-results/global-search-results.d.ts +1 -0
- package/dist/types/components/icon-button/icon-button.d.ts +2 -0
- package/dist/types/components/input/input.d.ts +6 -1
- package/dist/types/components/tabs/tab.d.ts +1 -0
- package/dist/types/components.d.ts +67 -12
- package/dist/types/index.d.ts +1 -0
- package/dist/types/interface.d.ts +1 -0
- package/docs-json.json +161 -13
- package/docs-vscode.json +6 -2
- package/package.json +2 -4
- package/dist/cjs/ResizeObserver.es-09b81a1b.js +0 -935
- package/dist/cjs/ResizeObserver.es-09b81a1b.js.map +0 -1
- package/dist/cjs/date-utils-0ae9a12d.js.map +0 -1
- package/dist/cjs/global-0d4f3b77.js.map +0 -1
- package/dist/cjs/intersection-observer-1822c787.js +0 -987
- package/dist/cjs/intersection-observer-1822c787.js.map +0 -1
- package/dist/components/ResizeObserver.es.js +0 -933
- package/dist/components/ResizeObserver.es.js.map +0 -1
- package/dist/components/intersection-observer.js +0 -985
- package/dist/components/intersection-observer.js.map +0 -1
- package/dist/esm/ResizeObserver.es-724af9fd.js +0 -933
- package/dist/esm/ResizeObserver.es-724af9fd.js.map +0 -1
- package/dist/esm/date-utils-e4b757ff.js.map +0 -1
- package/dist/esm/global-d5ec4d53.js.map +0 -1
- package/dist/esm/intersection-observer-dff9fb5b.js +0 -985
- package/dist/esm/intersection-observer-dff9fb5b.js.map +0 -1
- package/dist/esm-es5/ResizeObserver.es-724af9fd.js +0 -5
- package/dist/esm-es5/ResizeObserver.es-724af9fd.js.map +0 -1
- package/dist/esm-es5/date-utils-e4b757ff.js +0 -5
- package/dist/esm-es5/date-utils-e4b757ff.js.map +0 -1
- package/dist/esm-es5/global-d5ec4d53.js.map +0 -1
- package/dist/esm-es5/intersection-observer-dff9fb5b.js +0 -5
- package/dist/esm-es5/intersection-observer-dff9fb5b.js.map +0 -1
- package/dist/nano-components/p-00eaa36a.entry.js +0 -5
- package/dist/nano-components/p-00eaa36a.entry.js.map +0 -1
- package/dist/nano-components/p-01667573.entry.js.map +0 -1
- package/dist/nano-components/p-1030797a.entry.js.map +0 -1
- package/dist/nano-components/p-11a2dcce.js +0 -5
- package/dist/nano-components/p-11a2dcce.js.map +0 -1
- package/dist/nano-components/p-1a30dfdd.system.entry.js +0 -5
- package/dist/nano-components/p-1a30dfdd.system.entry.js.map +0 -1
- package/dist/nano-components/p-1b120f53.entry.js +0 -5
- package/dist/nano-components/p-1b120f53.entry.js.map +0 -1
- package/dist/nano-components/p-21d6d31e.system.entry.js +0 -5
- package/dist/nano-components/p-21d6d31e.system.entry.js.map +0 -1
- package/dist/nano-components/p-222d8095.entry.js +0 -5
- package/dist/nano-components/p-241d90eb.system.entry.js +0 -5
- package/dist/nano-components/p-241d90eb.system.entry.js.map +0 -1
- package/dist/nano-components/p-2c8d7273.entry.js +0 -5
- package/dist/nano-components/p-2c8d7273.entry.js.map +0 -1
- package/dist/nano-components/p-3093915f.entry.js +0 -5
- package/dist/nano-components/p-3093915f.entry.js.map +0 -1
- package/dist/nano-components/p-3258c568.system.js +0 -5
- package/dist/nano-components/p-325c1cad.entry.js +0 -5
- package/dist/nano-components/p-325c1cad.entry.js.map +0 -1
- package/dist/nano-components/p-32f396c0.system.entry.js +0 -5
- package/dist/nano-components/p-32f396c0.system.entry.js.map +0 -1
- package/dist/nano-components/p-35108e08.entry.js +0 -5
- package/dist/nano-components/p-35108e08.entry.js.map +0 -1
- package/dist/nano-components/p-3ccb176c.system.entry.js +0 -5
- package/dist/nano-components/p-3ccb176c.system.entry.js.map +0 -1
- package/dist/nano-components/p-3e930ac7.entry.js.map +0 -1
- package/dist/nano-components/p-42cebbfe.system.entry.js +0 -5
- package/dist/nano-components/p-42cebbfe.system.entry.js.map +0 -1
- package/dist/nano-components/p-4e2c0abb.entry.js.map +0 -1
- package/dist/nano-components/p-5d17cfbb.system.entry.js +0 -23
- package/dist/nano-components/p-5d17cfbb.system.entry.js.map +0 -1
- package/dist/nano-components/p-5d5ea4ab.system.entry.js +0 -5
- package/dist/nano-components/p-5d5ea4ab.system.entry.js.map +0 -1
- package/dist/nano-components/p-6722447c.entry.js +0 -5
- package/dist/nano-components/p-6722447c.entry.js.map +0 -1
- package/dist/nano-components/p-6d138abf.entry.js +0 -5
- package/dist/nano-components/p-6d138abf.entry.js.map +0 -1
- package/dist/nano-components/p-76d9d1d4.entry.js +0 -5
- package/dist/nano-components/p-76d9d1d4.entry.js.map +0 -1
- package/dist/nano-components/p-866f083f.system.entry.js +0 -5
- package/dist/nano-components/p-866f083f.system.entry.js.map +0 -1
- package/dist/nano-components/p-86bd5194.entry.js.map +0 -1
- package/dist/nano-components/p-88779174.system.entry.js +0 -5
- package/dist/nano-components/p-88779174.system.entry.js.map +0 -1
- package/dist/nano-components/p-93880c28.system.js.map +0 -1
- package/dist/nano-components/p-96d9b8b9.system.entry.js.map +0 -1
- package/dist/nano-components/p-97b13ad2.entry.js +0 -5
- package/dist/nano-components/p-97b13ad2.entry.js.map +0 -1
- package/dist/nano-components/p-b430a9b6.system.js +0 -5
- package/dist/nano-components/p-b430a9b6.system.js.map +0 -1
- package/dist/nano-components/p-bc394857.system.entry.js +0 -5
- package/dist/nano-components/p-bc394857.system.entry.js.map +0 -1
- package/dist/nano-components/p-bf9aa89d.system.entry.js.map +0 -1
- package/dist/nano-components/p-c3830c43.entry.js +0 -5
- package/dist/nano-components/p-c3830c43.entry.js.map +0 -1
- package/dist/nano-components/p-d0385948.system.entry.js.map +0 -1
- package/dist/nano-components/p-debd9efc.js +0 -5
- package/dist/nano-components/p-debd9efc.js.map +0 -1
- package/dist/nano-components/p-e195ab77.system.js +0 -5
- package/dist/nano-components/p-e195ab77.system.js.map +0 -1
- package/dist/nano-components/p-e7140887.system.js +0 -5
- package/dist/nano-components/p-e817ab4a.system.entry.js +0 -5
- package/dist/nano-components/p-f5d4d13b.system.js +0 -5
- package/dist/nano-components/p-f5d4d13b.system.js.map +0 -1
- package/dist/nano-components/p-f66958c1.js +0 -5
- package/dist/nano-components/p-f66958c1.js.map +0 -1
- package/dist/nano-components/p-f710c763.system.entry.js +0 -5
- package/dist/nano-components/p-f710c763.system.entry.js.map +0 -1
- package/dist/nano-components/p-f780d2f6.system.entry.js.map +0 -1
- package/dist/nano-components/p-f9c7d961.js +0 -5
- package/dist/nano-components/p-f9c7d961.js.map +0 -1
- package/dist/nano-components/p-ffc2063a.entry.js +0 -23
- package/dist/nano-components/p-ffc2063a.entry.js.map +0 -1
- package/dist/nano-components/p-fff27907.system.entry.js +0 -5
- package/dist/nano-components/p-fff27907.system.entry.js.map +0 -1
@@ -1,21 +1,28 @@
|
|
1
1
|
/*!
|
2
2
|
* Web Components for Nanopore digital Web Apps
|
3
3
|
*/
|
4
|
-
import { Component, Prop, h, Host, Element, State, Watch, Event, } from '@stencil/core';
|
4
|
+
import { Component, Prop, h, Host, Element, State, Watch, Event, Method, } from '@stencil/core';
|
5
5
|
import { createStore } from '@stencil/store';
|
6
6
|
/**
|
7
7
|
* A toolbox for `nano-...` form fields and form validation.
|
8
|
-
*
|
9
8
|
* - Easy to add validation accross field dependencies - e.g. "When Field1 contains '123' Field2 must contain '456'"
|
10
9
|
* - Easy access to whole form and individual field validity states
|
11
10
|
* - Easy access to form data payload
|
11
|
+
* = Access to 2-way, data bound reactive store
|
12
12
|
* - Scroll to invalid field on submit
|
13
13
|
*/
|
14
14
|
export class FieldValidator {
|
15
15
|
constructor() {
|
16
16
|
this.submitted = false;
|
17
|
-
this.
|
18
|
-
|
17
|
+
this.allFields = [];
|
18
|
+
this.nanoFieldSelector = `
|
19
|
+
nano-input,
|
20
|
+
nano-select,
|
21
|
+
nano-file-upload,
|
22
|
+
nano-date-input,
|
23
|
+
nano-checkbox
|
24
|
+
`;
|
25
|
+
// annoyingly, whenever we attempt to `checkValidty()` it fires `invalid` events.
|
19
26
|
// this is used to prevent infinite loops / multiple calls
|
20
27
|
this.internalValidate = false;
|
21
28
|
// Public API
|
@@ -24,39 +31,80 @@ export class FieldValidator {
|
|
24
31
|
/** Tries to scroll to the first invalid field on submit */
|
25
32
|
this.scrollToInvalid = true;
|
26
33
|
this._dirty = false;
|
34
|
+
/** By default, `nano-field-validator` will also track all native form field elements.
|
35
|
+
* You can add extra web-component form fields to listen to
|
36
|
+
* (as long as they match the standard form field spec) by using the `fieldSelector` prop.
|
37
|
+
*/
|
38
|
+
this.extraFieldSelector = 'input, select, textarea';
|
27
39
|
// Event handlers
|
28
|
-
/**
|
29
|
-
|
40
|
+
/**
|
41
|
+
* Fired whenever store values change and potentially checks validity
|
42
|
+
* @param key - the key of the store that's just changed
|
43
|
+
* @param newVal - the incoming, new value
|
44
|
+
*/
|
45
|
+
this.handleStoreChange = async (key, newVal) => {
|
46
|
+
const found = this.allFields.find((field) => field.name === key);
|
47
|
+
// field update has come programmatically (not from ui),
|
48
|
+
// so let's update the underlying ui field
|
49
|
+
if ((found &&
|
50
|
+
found.tagName === 'NANO-FILE-UPLOAD' &&
|
51
|
+
!this.fileStateEqual(key, found)) ||
|
52
|
+
(found.tagName !== 'NANO-FILE-UPLOAD' && found.value !== newVal)) {
|
53
|
+
this.storeToFields([found]);
|
54
|
+
}
|
30
55
|
if (this.validateOn === 'dirty' && this.dirty) {
|
31
56
|
this.internalValidate = true;
|
32
57
|
await this.validateAllFields();
|
33
58
|
this._valid = this.activeForm.checkValidity();
|
34
59
|
this.internalValidate = false;
|
35
60
|
}
|
36
|
-
this.nanoPayloadChange.emit(this.
|
61
|
+
this.nanoPayloadChange.emit(this._store.state);
|
37
62
|
};
|
38
|
-
/**
|
63
|
+
/**
|
64
|
+
* Handles nano field value changes and passes to store
|
65
|
+
* @param ev - the incoming change event
|
66
|
+
*/
|
39
67
|
this.handleFieldChange = (ev) => {
|
68
|
+
if (!this.nanoFields.includes(ev.target))
|
69
|
+
return;
|
40
70
|
this._dirty = true;
|
41
|
-
this.
|
71
|
+
this.fieldsToStore([ev.target]);
|
42
72
|
};
|
43
|
-
/**
|
73
|
+
/**
|
74
|
+
* Handles non-nano field value changes and passes to store
|
75
|
+
* @param ev - the incoming change event
|
76
|
+
*/
|
77
|
+
this.handlePlainFieldChange = (ev) => {
|
78
|
+
if (!this.plainFields.includes(ev.target))
|
79
|
+
return;
|
80
|
+
this.fieldsToStore([ev.target]);
|
81
|
+
};
|
82
|
+
/**
|
83
|
+
* Handles default field validation events
|
84
|
+
* @param ev - the invalid event
|
85
|
+
*/
|
44
86
|
this.handleFormInvalid = async (ev) => {
|
45
|
-
|
87
|
+
// if it's a non-nano field, we'll let default html5 validation do it's thing
|
88
|
+
if (!this.plainFields.includes(ev.target)) {
|
89
|
+
ev.preventDefault();
|
90
|
+
}
|
46
91
|
this._valid = false;
|
92
|
+
// whenever `checkValidity` is called, this handler is in-turn called.
|
93
|
+
// this flag is used to stop infinite loops
|
47
94
|
if (this.internalValidate)
|
48
95
|
return;
|
96
|
+
// a submit must have happened to if 'submitThenDirty' turn on 'dirty' checking now
|
49
97
|
if (this.validateOn === 'submitThenDirty')
|
50
98
|
this.validateOn = 'dirty';
|
51
99
|
this.submitted = true;
|
52
100
|
await this.validateAllFields();
|
101
|
+
this.internalValidate = true;
|
102
|
+
this._valid = this.activeForm.checkValidity();
|
103
|
+
this.internalValidate = false;
|
53
104
|
// kinda insane...but if we're only validating on submit, then if the form is currently
|
54
105
|
// in an invalid state, when submitting, it will fire an invalid event and not
|
55
106
|
// submit the form. So let's test to make sure it is really invalid, and submit if not
|
56
107
|
if (this.validateOn === 'submit') {
|
57
|
-
this.internalValidate = true;
|
58
|
-
this._valid = this.activeForm.checkValidity();
|
59
|
-
this.internalValidate = false;
|
60
108
|
if (this._valid) {
|
61
109
|
this.submitForm();
|
62
110
|
return;
|
@@ -65,7 +113,10 @@ export class FieldValidator {
|
|
65
113
|
this.scrollToFirstInvalid();
|
66
114
|
this.nanoInvalid.emit();
|
67
115
|
};
|
68
|
-
/**
|
116
|
+
/**
|
117
|
+
* stops default form submission, checks if valid, then submits manually
|
118
|
+
* @param e - a submit event from the nested form element
|
119
|
+
*/
|
69
120
|
this.handleSubmit = async (e) => {
|
70
121
|
e.preventDefault();
|
71
122
|
if (this.validateOn === 'submitThenDirty')
|
@@ -90,15 +141,18 @@ export class FieldValidator {
|
|
90
141
|
return this._activeForm;
|
91
142
|
}
|
92
143
|
set activeForm(form) {
|
93
|
-
|
144
|
+
// manages event listners on whatever form is used (slotted on created here)
|
145
|
+
if (!form)
|
146
|
+
return;
|
147
|
+
if (this._activeForm) {
|
94
148
|
this._activeForm.removeEventListener('invalid', this.handleFormInvalid, true);
|
95
|
-
|
96
|
-
|
149
|
+
}
|
150
|
+
form.addEventListener('invalid', this.handleFormInvalid, true);
|
97
151
|
this._activeForm = form;
|
98
152
|
}
|
99
153
|
/** Sync up validateOn with all fields */
|
100
154
|
validateOnChange() {
|
101
|
-
this.
|
155
|
+
this.nanoFields.forEach((field) => {
|
102
156
|
if (field.tagName === 'NANO-CHECKBOX') {
|
103
157
|
const cbg = field.closest('nano-checkbox-group');
|
104
158
|
if (cbg)
|
@@ -118,11 +172,15 @@ export class FieldValidator {
|
|
118
172
|
get valid() {
|
119
173
|
return this._valid;
|
120
174
|
}
|
121
|
-
/** The current form
|
175
|
+
/** The current form state as a stencil store. */
|
176
|
+
get store() {
|
177
|
+
return this._store;
|
178
|
+
}
|
179
|
+
/** The current form payload as a reactive proxy. @readonly */
|
122
180
|
get payload() {
|
123
|
-
return this.
|
181
|
+
return this._store.state;
|
124
182
|
}
|
125
|
-
/** Returns true if validation errors will be displayed to the user */
|
183
|
+
/** Returns true if validation errors will be displayed to the user. @readonly */
|
126
184
|
get showValidation() {
|
127
185
|
return (this.validateOn === 'dirty' && this.dirty) || this.submitted;
|
128
186
|
}
|
@@ -139,37 +197,94 @@ export class FieldValidator {
|
|
139
197
|
```
|
140
198
|
*/
|
141
199
|
get validationState() {
|
200
|
+
// TODO - migrate nano-fields away from using proprietary methods in a bid to be closer to the spec
|
201
|
+
// this is big and ugly.
|
202
|
+
// why? Cos' it must unify checking validity state for both
|
203
|
+
// `nano-...` and plain form fields.
|
142
204
|
const validationState = [];
|
143
|
-
this.
|
205
|
+
this.allFields.forEach(async (field) => {
|
144
206
|
const found = validationState.find((v) => v.name === field.name);
|
207
|
+
let pf;
|
208
|
+
let nf;
|
145
209
|
if (found) {
|
146
|
-
|
147
|
-
|
148
|
-
|
210
|
+
if (field.validationMessage) {
|
211
|
+
pf = field;
|
212
|
+
found.validityMessage = pf.validationMessage.length
|
213
|
+
? pf.validationMessage
|
214
|
+
: found.validityMessage;
|
215
|
+
this.internalValidate = true;
|
216
|
+
if (found.valid && !pf.checkValidity())
|
217
|
+
found.valid = false;
|
218
|
+
this.internalValidate = false;
|
219
|
+
}
|
220
|
+
else if (field.validityMessage) {
|
221
|
+
nf = field;
|
222
|
+
found.validityMessage = nf.validityMessage.length
|
223
|
+
? nf.validityMessage
|
224
|
+
: nf.validityMessage;
|
225
|
+
if (found.valid && nf.invalid)
|
226
|
+
found.valid = false;
|
227
|
+
}
|
149
228
|
if (!found.fields.find((f) => f === field))
|
150
229
|
found.fields.push(field);
|
151
|
-
|
152
|
-
|
153
|
-
|
230
|
+
}
|
231
|
+
let valid;
|
232
|
+
let validityMessage;
|
233
|
+
if (field.checkValidity) {
|
234
|
+
pf = field;
|
235
|
+
this.internalValidate = true;
|
236
|
+
valid = pf.checkValidity();
|
237
|
+
this.internalValidate = false;
|
238
|
+
validityMessage = pf.validationMessage;
|
239
|
+
}
|
240
|
+
else {
|
241
|
+
nf = field;
|
242
|
+
valid = !nf.invalid;
|
243
|
+
validityMessage = nf.validityMessage;
|
154
244
|
}
|
155
245
|
validationState.push({
|
156
246
|
fields: [field],
|
157
247
|
name: field.name,
|
158
|
-
|
159
|
-
value: this.store.state[field.name],
|
248
|
+
value: this._store.state[field.name],
|
160
249
|
dirty: false,
|
161
|
-
|
250
|
+
valid,
|
251
|
+
validityMessage,
|
162
252
|
});
|
163
253
|
});
|
164
254
|
return validationState;
|
165
255
|
}
|
256
|
+
/**
|
257
|
+
* Sets the state of the form using an object of key / value pairs.
|
258
|
+
* @param state - the state to load in the store
|
259
|
+
*/
|
260
|
+
async setStore(state) {
|
261
|
+
Object.entries(state).forEach(([key, val]) => (this.store.state[key] = val));
|
262
|
+
}
|
263
|
+
/**
|
264
|
+
* Sets custom validity for all / some form fields.
|
265
|
+
* @param validity - a validity object of `{fieldName: errorString}` pairs. Set as an empty string to clear the error.
|
266
|
+
*/
|
267
|
+
async setCustomValidity(validity) {
|
268
|
+
return await Promise.all(Object.entries(validity).map(async ([key, err]) => {
|
269
|
+
const field = this.allFields.find((f) => f.name === key);
|
270
|
+
if (!!field)
|
271
|
+
await this.setFieldError(field, err);
|
272
|
+
}));
|
273
|
+
}
|
274
|
+
/**
|
275
|
+
* Clear all custom validation.
|
276
|
+
* @param validity
|
277
|
+
*/
|
278
|
+
async resetValidity() {
|
279
|
+
return await Promise.all(this.allFields.map(async (field) => await this.setFieldError(field, '')));
|
280
|
+
}
|
166
281
|
// private methods
|
167
282
|
attachSlotObserver() {
|
168
283
|
if (!!this.mo)
|
169
284
|
return;
|
170
285
|
const mo = (this.mo = new MutationObserver((_entries) => {
|
171
286
|
const form = this.host.querySelector('form');
|
172
|
-
if (form !== this.activeForm)
|
287
|
+
if (form && form !== this.activeForm)
|
173
288
|
this.activeForm = form;
|
174
289
|
this.setupFields();
|
175
290
|
}));
|
@@ -182,95 +297,177 @@ export class FieldValidator {
|
|
182
297
|
}
|
183
298
|
/** Checks for new `nano-...` fields and adds them to our watch array and value store */
|
184
299
|
setupFields() {
|
185
|
-
let
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
nano-date-input,
|
190
|
-
nano-checkbox
|
191
|
-
`));
|
192
|
-
fields = fields.filter((f) => !!f.name && !!f.name.length);
|
300
|
+
let nanoFields = Array.from(this.host.querySelectorAll(this.nanoFieldSelector));
|
301
|
+
let plainFields = Array.from(this.host.querySelectorAll(this.extraFieldSelector)).filter((e) => !e.closest(this.nanoFieldSelector));
|
302
|
+
nanoFields = nanoFields.filter((f) => !!f.name && !!f.name.length);
|
303
|
+
plainFields = plainFields.filter((f) => !!f.name && !!f.name.length);
|
193
304
|
// do we have any currently un-watched fields?
|
194
|
-
if (!
|
305
|
+
if (![...nanoFields, ...plainFields].filter((f) => !this.allFields.includes(f)).length)
|
195
306
|
return;
|
196
307
|
// setup the initial store state / refresh on new fields
|
197
|
-
this.
|
308
|
+
this.nanoFields = nanoFields;
|
309
|
+
this.plainFields = plainFields;
|
310
|
+
this.allFields = [...nanoFields, ...plainFields];
|
311
|
+
this.storeToFields(this.allFields);
|
198
312
|
this.validateOnChange();
|
199
|
-
this.
|
200
|
-
this.nanoPayloadChange.emit(this.
|
313
|
+
this.fieldsToStore(this.allFields);
|
314
|
+
this.nanoPayloadChange.emit(this._store.state);
|
315
|
+
}
|
316
|
+
storeToFields(fields) {
|
317
|
+
fields.forEach((field) => {
|
318
|
+
var _a;
|
319
|
+
const fieldName = field.name;
|
320
|
+
if (!fieldName.length ||
|
321
|
+
typeof this._store.state[fieldName] === 'undefined')
|
322
|
+
return;
|
323
|
+
if (field.tagName === 'NANO-CHECKBOX' ||
|
324
|
+
['radio', 'checkbox'].includes(field.type)) {
|
325
|
+
let cb = field;
|
326
|
+
if (cb.type === 'radio' ||
|
327
|
+
cb.type === 'segment' ||
|
328
|
+
cb.type === 'segment-pill') {
|
329
|
+
// single radio type control
|
330
|
+
if (this._store.state[fieldName] === cb.value)
|
331
|
+
cb.checked = true;
|
332
|
+
else
|
333
|
+
cb.checked = false;
|
334
|
+
}
|
335
|
+
else if (Array.isArray(this._store.state[fieldName])) {
|
336
|
+
// multiple checkbox like controls
|
337
|
+
if (this._store.state[fieldName].includes(cb.value))
|
338
|
+
cb.checked = true;
|
339
|
+
else
|
340
|
+
cb.checked = false;
|
341
|
+
}
|
342
|
+
else {
|
343
|
+
// single checkbox like control
|
344
|
+
if (this._store.state[fieldName] === cb.value)
|
345
|
+
cb.checked = true;
|
346
|
+
else
|
347
|
+
cb.checked = false;
|
348
|
+
}
|
349
|
+
return;
|
350
|
+
}
|
351
|
+
if (field.tagName === 'NANO-FILE-UPLOAD') {
|
352
|
+
const ff = field;
|
353
|
+
// this can only work if the field is empty rn... a one-time deal
|
354
|
+
if (!((_a = ff.files) === null || _a === void 0 ? void 0 : _a.length))
|
355
|
+
ff.files = this._store.state[fieldName];
|
356
|
+
return;
|
357
|
+
}
|
358
|
+
// default
|
359
|
+
field.value = this._store.state[fieldName];
|
360
|
+
});
|
201
361
|
}
|
202
362
|
/** Loops through all `nano-...` fields and extracts their values into our store */
|
203
|
-
|
363
|
+
fieldsToStore(fields) {
|
204
364
|
fields.forEach((field) => {
|
205
365
|
const fieldName = field.name;
|
206
366
|
if (!fieldName.length)
|
207
367
|
return;
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
}
|
230
|
-
else {
|
231
|
-
this.store.state[fieldName] = currentArr.filter((v) => v !== cb.value);
|
368
|
+
if (field.tagName === 'NANO-CHECKBOX' ||
|
369
|
+
['radio', 'checkbox'].includes(field.type)) {
|
370
|
+
let cb = field;
|
371
|
+
if (cb.type === 'radio' ||
|
372
|
+
cb.type === 'segment' ||
|
373
|
+
cb.type === 'segment-pill') {
|
374
|
+
// radio type control - only one can be checked
|
375
|
+
if (cb.checked)
|
376
|
+
this._store.state[fieldName] = cb.value;
|
377
|
+
}
|
378
|
+
else if (this.allFields.filter((f) => f.name === fieldName &&
|
379
|
+
(f.tagName === 'NANO-CHECKBOX' ||
|
380
|
+
f.type === 'checkbox')).length > 1) {
|
381
|
+
// multiple checkbox type control
|
382
|
+
const currentArr = Array.isArray(this._store.state[fieldName])
|
383
|
+
? this._store.state[fieldName]
|
384
|
+
: [];
|
385
|
+
if (cb.checked) {
|
386
|
+
// checked
|
387
|
+
if (!this._store.state[fieldName].includes(cb.value)) {
|
388
|
+
this._store.state[fieldName] = [...currentArr, cb.value];
|
232
389
|
}
|
233
390
|
}
|
391
|
+
else {
|
392
|
+
// unchecked
|
393
|
+
this._store.state[fieldName] = currentArr.filter((v) => v !== cb.value);
|
394
|
+
}
|
395
|
+
}
|
396
|
+
else {
|
397
|
+
// single checkbox - on or off
|
398
|
+
if (cb.checked)
|
399
|
+
this._store.state[fieldName] = cb.value;
|
234
400
|
else
|
235
|
-
this.
|
236
|
-
|
237
|
-
|
238
|
-
this.store.state[fieldName] = field.files;
|
239
|
-
break;
|
240
|
-
default:
|
241
|
-
this.store.state[fieldName] = field.value;
|
242
|
-
break;
|
401
|
+
this._store.state[fieldName] = '';
|
402
|
+
}
|
403
|
+
return;
|
243
404
|
}
|
405
|
+
if (field.tagName === 'NANO-FILE-UPLOAD') {
|
406
|
+
const ff = field;
|
407
|
+
if (!this.fileStateEqual(fieldName, ff))
|
408
|
+
this._store.state[fieldName] = ff.files;
|
409
|
+
return;
|
410
|
+
}
|
411
|
+
// default
|
412
|
+
this._store.state[fieldName] = field.value;
|
244
413
|
});
|
245
414
|
}
|
246
|
-
/**
|
415
|
+
/**
|
416
|
+
* Tries to ascertain whether the current model
|
417
|
+
* value is the same as the `nano-file-upload` value
|
418
|
+
* @param fieldName - the key to access from the data store
|
419
|
+
* @param field - the nano-file-upload field to assess against
|
420
|
+
* @returns true for equal, false for not equal
|
421
|
+
*/
|
422
|
+
fileStateEqual(fieldName, field) {
|
423
|
+
return (JSON.stringify(this._store.state[fieldName]) ===
|
424
|
+
JSON.stringify(field.files) ||
|
425
|
+
this._store.state[fieldName] == field.files);
|
426
|
+
}
|
427
|
+
/**
|
428
|
+
* Checks for user defined validations
|
429
|
+
* @param key - current key of the data model to validate
|
430
|
+
* @param newVal - the newly set, incoming value to validate
|
431
|
+
*/
|
247
432
|
async validate(key, newVal) {
|
248
433
|
if (!this.validation)
|
249
434
|
return;
|
250
|
-
const res = this.validation(key, newVal, this.
|
435
|
+
const res = this.validation(key, newVal, this._store.state);
|
251
436
|
// no nothing - return
|
252
437
|
if (!res)
|
253
438
|
return;
|
254
439
|
// stencil public methods are async
|
255
|
-
// so we must
|
440
|
+
// so we must coerce our validation
|
256
441
|
// collection loop into a promise
|
257
442
|
await Promise.all(Object.entries(res).map(async ([key, o]) => {
|
258
443
|
// switch on/off validation messages
|
259
|
-
const field = this.
|
444
|
+
const field = this.allFields.find((f) => f.name === key);
|
260
445
|
let validityTarget = field;
|
261
446
|
if (field.tagName === 'NANO-CHECKBOX') {
|
447
|
+
// if we have a checkbox-group, set the validation message there
|
262
448
|
const cbg = field.closest('nano-checkbox-group');
|
263
449
|
validityTarget = cbg || field;
|
264
450
|
}
|
265
|
-
|
266
|
-
|
451
|
+
if ((validityTarget.validityMessage ||
|
452
|
+
validityTarget.validationMessage) === o.msg &&
|
453
|
+
o.valid) {
|
454
|
+
// status is now valid - clear the error
|
267
455
|
await this.setFieldError(validityTarget, '');
|
268
|
-
|
456
|
+
}
|
269
457
|
else if (!o.valid) {
|
458
|
+
// status is invalid. Set the error
|
270
459
|
await this.setFieldError(validityTarget, o.msg);
|
271
460
|
}
|
272
461
|
}));
|
273
462
|
}
|
463
|
+
/** Loops through all store entries and checks custom validation */
|
464
|
+
async validateAllFields() {
|
465
|
+
// This forces our loop to `await` and finish sequentially ... silly async stencil methods
|
466
|
+
await Object.entries(this._store.state).reduce(async (memo, [key, value]) => {
|
467
|
+
await memo;
|
468
|
+
await this.validate(key, value);
|
469
|
+
}, undefined);
|
470
|
+
}
|
274
471
|
/**
|
275
472
|
* Utility to smooth out setting error messages
|
276
473
|
* (it's a different method on `nano-checkbox` 'cos they don't show errors themselves)
|
@@ -280,16 +477,10 @@ export class FieldValidator {
|
|
280
477
|
async setFieldError(field, msg) {
|
281
478
|
if (field['showError'])
|
282
479
|
await field.showError(msg);
|
283
|
-
else
|
480
|
+
else if (field['setError'])
|
284
481
|
await field.setError(msg);
|
285
|
-
|
286
|
-
|
287
|
-
async validateAllFields() {
|
288
|
-
// This forces our loop to `await` and finish sequentially ... silly async stencil methods
|
289
|
-
await Object.entries(this.store.state).reduce(async (memo, [key, value]) => {
|
290
|
-
await memo;
|
291
|
-
await this.validate(key, value);
|
292
|
-
}, undefined);
|
482
|
+
else
|
483
|
+
field.setCustomValidity(msg);
|
293
484
|
}
|
294
485
|
scrollToFirstInvalid() {
|
295
486
|
if (!this.scrollToInvalid)
|
@@ -312,23 +503,27 @@ export class FieldValidator {
|
|
312
503
|
}
|
313
504
|
connectedCallback() {
|
314
505
|
this.userForm = this.host.querySelector('form');
|
506
|
+
this._store = createStore({});
|
315
507
|
}
|
316
508
|
componentDidLoad() {
|
317
509
|
requestAnimationFrame(() => {
|
318
|
-
this.store = createStore({});
|
319
510
|
this.setupFields();
|
320
511
|
this.attachSlotObserver();
|
321
|
-
this.store.on('set', (key, value) => this.handleStoreChange(key, value));
|
322
512
|
this.host.addEventListener('nanoChange', this.handleFieldChange);
|
513
|
+
this.host.addEventListener('input', this.handlePlainFieldChange);
|
514
|
+
this.host.addEventListener('change', this.handlePlainFieldChange);
|
323
515
|
this.host.addEventListener('submit', this.handleSubmit);
|
516
|
+
this._store.on('set', this.handleStoreChange);
|
324
517
|
});
|
325
518
|
}
|
326
519
|
disconnectedCallback() {
|
327
520
|
if (this.mo)
|
328
521
|
this.mo.disconnect();
|
329
|
-
this.store.dispose();
|
330
522
|
this.host.removeEventListener('nanoChange', this.handleFieldChange);
|
523
|
+
this.host.removeEventListener('input', this.handlePlainFieldChange);
|
524
|
+
this.host.removeEventListener('change', this.handlePlainFieldChange);
|
331
525
|
this.host.removeEventListener('submit', this.handleSubmit);
|
526
|
+
this._store.reset();
|
332
527
|
if (this.activeForm)
|
333
528
|
this.activeForm.removeEventListener('invalid', this.handleFormInvalid, true);
|
334
529
|
}
|
@@ -419,19 +614,36 @@ export class FieldValidator {
|
|
419
614
|
"attribute": "valid",
|
420
615
|
"reflect": true
|
421
616
|
},
|
617
|
+
"store": {
|
618
|
+
"type": "unknown",
|
619
|
+
"mutable": false,
|
620
|
+
"complexType": {
|
621
|
+
"original": "ObservableMap<ValidatorValueStore>",
|
622
|
+
"resolved": "ObservableMap<ValidatorValueStore>",
|
623
|
+
"references": {}
|
624
|
+
},
|
625
|
+
"required": false,
|
626
|
+
"optional": false,
|
627
|
+
"docs": {
|
628
|
+
"tags": [],
|
629
|
+
"text": "The current form state as a stencil store."
|
630
|
+
},
|
631
|
+
"getter": true,
|
632
|
+
"setter": false
|
633
|
+
},
|
422
634
|
"payload": {
|
423
635
|
"type": "unknown",
|
424
636
|
"mutable": false,
|
425
637
|
"complexType": {
|
426
|
-
"original": "
|
427
|
-
"resolved": "
|
638
|
+
"original": "ValidatorValueStore",
|
639
|
+
"resolved": "ValidatorValueStore",
|
428
640
|
"references": {}
|
429
641
|
},
|
430
642
|
"required": false,
|
431
643
|
"optional": false,
|
432
644
|
"docs": {
|
433
645
|
"tags": [],
|
434
|
-
"text": "The current form payload as a reactive
|
646
|
+
"text": "The current form payload as a reactive proxy. @readonly"
|
435
647
|
},
|
436
648
|
"getter": true,
|
437
649
|
"setter": false
|
@@ -448,7 +660,7 @@ export class FieldValidator {
|
|
448
660
|
"optional": false,
|
449
661
|
"docs": {
|
450
662
|
"tags": [],
|
451
|
-
"text": "Returns true if validation errors will be displayed to the user"
|
663
|
+
"text": "Returns true if validation errors will be displayed to the user. @readonly"
|
452
664
|
},
|
453
665
|
"getter": true,
|
454
666
|
"setter": false,
|
@@ -463,7 +675,16 @@ export class FieldValidator {
|
|
463
675
|
"resolved": "ValidationState[]",
|
464
676
|
"references": {
|
465
677
|
"ValidationState": {
|
466
|
-
"location": "
|
678
|
+
"location": "import",
|
679
|
+
"path": "/builds/f85YXDf1/0/Digital/nano-components/packages/components/src/interface.d.ts"
|
680
|
+
},
|
681
|
+
"PlainFormEles": {
|
682
|
+
"location": "import",
|
683
|
+
"path": "/builds/f85YXDf1/0/Digital/nano-components/packages/components/src/interface.d.ts"
|
684
|
+
},
|
685
|
+
"NanoFormEles": {
|
686
|
+
"location": "import",
|
687
|
+
"path": "/builds/f85YXDf1/0/Digital/nano-components/packages/components/src/interface.d.ts"
|
467
688
|
}
|
468
689
|
}
|
469
690
|
},
|
@@ -476,15 +697,36 @@ export class FieldValidator {
|
|
476
697
|
"getter": true,
|
477
698
|
"setter": false
|
478
699
|
},
|
700
|
+
"extraFieldSelector": {
|
701
|
+
"type": "string",
|
702
|
+
"mutable": false,
|
703
|
+
"complexType": {
|
704
|
+
"original": "string",
|
705
|
+
"resolved": "string",
|
706
|
+
"references": {}
|
707
|
+
},
|
708
|
+
"required": false,
|
709
|
+
"optional": false,
|
710
|
+
"docs": {
|
711
|
+
"tags": [],
|
712
|
+
"text": "By default, `nano-field-validator` will also track all native form field elements.\nYou can add extra web-component form fields to listen to\n(as long as they match the standard form field spec) by using the `fieldSelector` prop."
|
713
|
+
},
|
714
|
+
"getter": false,
|
715
|
+
"setter": false,
|
716
|
+
"attribute": "extra-field-selector",
|
717
|
+
"reflect": false,
|
718
|
+
"defaultValue": "'input, select, textarea'"
|
719
|
+
},
|
479
720
|
"validation": {
|
480
721
|
"type": "unknown",
|
481
722
|
"mutable": false,
|
482
723
|
"complexType": {
|
483
|
-
"original": "(\n field: string,\n value: string,\n fields:
|
484
|
-
"resolved": "(field: string, value: string, fields:
|
724
|
+
"original": "(\n field: string,\n value: string,\n fields: ValidatorValueStore\n ) => { [key: string]: { msg: string; valid?: boolean } }",
|
725
|
+
"resolved": "(field: string, value: string, fields: ValidatorValueStore) => { [key: string]: { msg: string; valid?: boolean; }; }",
|
485
726
|
"references": {
|
486
|
-
"
|
487
|
-
"location": "
|
727
|
+
"ValidatorValueStore": {
|
728
|
+
"location": "import",
|
729
|
+
"path": "/builds/f85YXDf1/0/Digital/nano-components/packages/components/src/interface.d.ts"
|
488
730
|
}
|
489
731
|
}
|
490
732
|
},
|
@@ -511,11 +753,11 @@ export class FieldValidator {
|
|
511
753
|
}
|
512
754
|
}; }
|
513
755
|
static get states() { return {
|
514
|
-
"store": {},
|
515
|
-
"userForm": {},
|
516
756
|
"submitted": {},
|
757
|
+
"userForm": {},
|
517
758
|
"_dirty": {},
|
518
|
-
"_valid": {}
|
759
|
+
"_valid": {},
|
760
|
+
"_store": {}
|
519
761
|
}; }
|
520
762
|
static get events() { return [{
|
521
763
|
"method": "nanoPayloadChange",
|
@@ -528,11 +770,12 @@ export class FieldValidator {
|
|
528
770
|
"text": "Fired whenever the payload changes"
|
529
771
|
},
|
530
772
|
"complexType": {
|
531
|
-
"original": "
|
532
|
-
"resolved": "
|
773
|
+
"original": "ValidatorValueStore",
|
774
|
+
"resolved": "ValidatorValueStore",
|
533
775
|
"references": {
|
534
|
-
"
|
535
|
-
"location": "
|
776
|
+
"ValidatorValueStore": {
|
777
|
+
"location": "import",
|
778
|
+
"path": "/builds/f85YXDf1/0/Digital/nano-components/packages/components/src/interface.d.ts"
|
536
779
|
}
|
537
780
|
}
|
538
781
|
}
|
@@ -567,6 +810,81 @@ export class FieldValidator {
|
|
567
810
|
"references": {}
|
568
811
|
}
|
569
812
|
}]; }
|
813
|
+
static get methods() { return {
|
814
|
+
"setStore": {
|
815
|
+
"complexType": {
|
816
|
+
"signature": "(state: ValidatorValueStore) => Promise<void>",
|
817
|
+
"parameters": [{
|
818
|
+
"tags": [{
|
819
|
+
"name": "param",
|
820
|
+
"text": "state - the state to load in the store"
|
821
|
+
}],
|
822
|
+
"text": "- the state to load in the store"
|
823
|
+
}],
|
824
|
+
"references": {
|
825
|
+
"Promise": {
|
826
|
+
"location": "global"
|
827
|
+
},
|
828
|
+
"ValidatorValueStore": {
|
829
|
+
"location": "import",
|
830
|
+
"path": "/builds/f85YXDf1/0/Digital/nano-components/packages/components/src/interface.d.ts"
|
831
|
+
}
|
832
|
+
},
|
833
|
+
"return": "Promise<void>"
|
834
|
+
},
|
835
|
+
"docs": {
|
836
|
+
"text": "Sets the state of the form using an object of key / value pairs.",
|
837
|
+
"tags": [{
|
838
|
+
"name": "param",
|
839
|
+
"text": "state - the state to load in the store"
|
840
|
+
}]
|
841
|
+
}
|
842
|
+
},
|
843
|
+
"setCustomValidity": {
|
844
|
+
"complexType": {
|
845
|
+
"signature": "(validity: { [key: string]: string; }) => Promise<void[]>",
|
846
|
+
"parameters": [{
|
847
|
+
"tags": [{
|
848
|
+
"name": "param",
|
849
|
+
"text": "validity - a validity object of `{fieldName: errorString}` pairs. Set as an empty string to clear the error."
|
850
|
+
}],
|
851
|
+
"text": "- a validity object of `{fieldName: errorString}` pairs. Set as an empty string to clear the error."
|
852
|
+
}],
|
853
|
+
"references": {
|
854
|
+
"Promise": {
|
855
|
+
"location": "global"
|
856
|
+
}
|
857
|
+
},
|
858
|
+
"return": "Promise<void[]>"
|
859
|
+
},
|
860
|
+
"docs": {
|
861
|
+
"text": "Sets custom validity for all / some form fields.",
|
862
|
+
"tags": [{
|
863
|
+
"name": "param",
|
864
|
+
"text": "validity - a validity object of `{fieldName: errorString}` pairs. Set as an empty string to clear the error."
|
865
|
+
}]
|
866
|
+
}
|
867
|
+
},
|
868
|
+
"resetValidity": {
|
869
|
+
"complexType": {
|
870
|
+
"signature": "() => Promise<void[]>",
|
871
|
+
"parameters": [],
|
872
|
+
"references": {
|
873
|
+
"Promise": {
|
874
|
+
"location": "global"
|
875
|
+
}
|
876
|
+
},
|
877
|
+
"return": "Promise<void[]>"
|
878
|
+
},
|
879
|
+
"docs": {
|
880
|
+
"text": "Clear all custom validation.",
|
881
|
+
"tags": [{
|
882
|
+
"name": "param",
|
883
|
+
"text": "validity"
|
884
|
+
}]
|
885
|
+
}
|
886
|
+
}
|
887
|
+
}; }
|
570
888
|
static get elementRef() { return "host"; }
|
571
889
|
static get watchers() { return [{
|
572
890
|
"propName": "userForm",
|
@@ -574,6 +892,9 @@ export class FieldValidator {
|
|
574
892
|
}, {
|
575
893
|
"propName": "validateOn",
|
576
894
|
"methodName": "validateOnChange"
|
895
|
+
}, {
|
896
|
+
"propName": "extraFieldSelector",
|
897
|
+
"methodName": "attachSlotObserver"
|
577
898
|
}]; }
|
578
899
|
}
|
579
900
|
//# sourceMappingURL=field-validator.js.map
|