@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
@@ -198,8 +198,15 @@ let FieldValidator = class {
|
|
198
198
|
this.nanoSubmit = index.createEvent(this, "nanoSubmit", 7);
|
199
199
|
this.nanoInvalid = index.createEvent(this, "nanoInvalid", 7);
|
200
200
|
this.submitted = false;
|
201
|
-
this.
|
202
|
-
|
201
|
+
this.allFields = [];
|
202
|
+
this.nanoFieldSelector = `
|
203
|
+
nano-input,
|
204
|
+
nano-select,
|
205
|
+
nano-file-upload,
|
206
|
+
nano-date-input,
|
207
|
+
nano-checkbox
|
208
|
+
`;
|
209
|
+
// annoyingly, whenever we attempt to `checkValidty()` it fires `invalid` events.
|
203
210
|
// this is used to prevent infinite loops / multiple calls
|
204
211
|
this.internalValidate = false;
|
205
212
|
// Public API
|
@@ -208,39 +215,80 @@ let FieldValidator = class {
|
|
208
215
|
/** Tries to scroll to the first invalid field on submit */
|
209
216
|
this.scrollToInvalid = true;
|
210
217
|
this._dirty = false;
|
218
|
+
/** By default, `nano-field-validator` will also track all native form field elements.
|
219
|
+
* You can add extra web-component form fields to listen to
|
220
|
+
* (as long as they match the standard form field spec) by using the `fieldSelector` prop.
|
221
|
+
*/
|
222
|
+
this.extraFieldSelector = 'input, select, textarea';
|
211
223
|
// Event handlers
|
212
|
-
/**
|
213
|
-
|
224
|
+
/**
|
225
|
+
* Fired whenever store values change and potentially checks validity
|
226
|
+
* @param key - the key of the store that's just changed
|
227
|
+
* @param newVal - the incoming, new value
|
228
|
+
*/
|
229
|
+
this.handleStoreChange = async (key, newVal) => {
|
230
|
+
const found = this.allFields.find((field) => field.name === key);
|
231
|
+
// field update has come programmatically (not from ui),
|
232
|
+
// so let's update the underlying ui field
|
233
|
+
if ((found &&
|
234
|
+
found.tagName === 'NANO-FILE-UPLOAD' &&
|
235
|
+
!this.fileStateEqual(key, found)) ||
|
236
|
+
(found.tagName !== 'NANO-FILE-UPLOAD' && found.value !== newVal)) {
|
237
|
+
this.storeToFields([found]);
|
238
|
+
}
|
214
239
|
if (this.validateOn === 'dirty' && this.dirty) {
|
215
240
|
this.internalValidate = true;
|
216
241
|
await this.validateAllFields();
|
217
242
|
this._valid = this.activeForm.checkValidity();
|
218
243
|
this.internalValidate = false;
|
219
244
|
}
|
220
|
-
this.nanoPayloadChange.emit(this.
|
245
|
+
this.nanoPayloadChange.emit(this._store.state);
|
221
246
|
};
|
222
|
-
/**
|
247
|
+
/**
|
248
|
+
* Handles nano field value changes and passes to store
|
249
|
+
* @param ev - the incoming change event
|
250
|
+
*/
|
223
251
|
this.handleFieldChange = (ev) => {
|
252
|
+
if (!this.nanoFields.includes(ev.target))
|
253
|
+
return;
|
224
254
|
this._dirty = true;
|
225
|
-
this.
|
255
|
+
this.fieldsToStore([ev.target]);
|
226
256
|
};
|
227
|
-
/**
|
257
|
+
/**
|
258
|
+
* Handles non-nano field value changes and passes to store
|
259
|
+
* @param ev - the incoming change event
|
260
|
+
*/
|
261
|
+
this.handlePlainFieldChange = (ev) => {
|
262
|
+
if (!this.plainFields.includes(ev.target))
|
263
|
+
return;
|
264
|
+
this.fieldsToStore([ev.target]);
|
265
|
+
};
|
266
|
+
/**
|
267
|
+
* Handles default field validation events
|
268
|
+
* @param ev - the invalid event
|
269
|
+
*/
|
228
270
|
this.handleFormInvalid = async (ev) => {
|
229
|
-
|
271
|
+
// if it's a non-nano field, we'll let default html5 validation do it's thing
|
272
|
+
if (!this.plainFields.includes(ev.target)) {
|
273
|
+
ev.preventDefault();
|
274
|
+
}
|
230
275
|
this._valid = false;
|
276
|
+
// whenever `checkValidity` is called, this handler is in-turn called.
|
277
|
+
// this flag is used to stop infinite loops
|
231
278
|
if (this.internalValidate)
|
232
279
|
return;
|
280
|
+
// a submit must have happened to if 'submitThenDirty' turn on 'dirty' checking now
|
233
281
|
if (this.validateOn === 'submitThenDirty')
|
234
282
|
this.validateOn = 'dirty';
|
235
283
|
this.submitted = true;
|
236
284
|
await this.validateAllFields();
|
285
|
+
this.internalValidate = true;
|
286
|
+
this._valid = this.activeForm.checkValidity();
|
287
|
+
this.internalValidate = false;
|
237
288
|
// kinda insane...but if we're only validating on submit, then if the form is currently
|
238
289
|
// in an invalid state, when submitting, it will fire an invalid event and not
|
239
290
|
// submit the form. So let's test to make sure it is really invalid, and submit if not
|
240
291
|
if (this.validateOn === 'submit') {
|
241
|
-
this.internalValidate = true;
|
242
|
-
this._valid = this.activeForm.checkValidity();
|
243
|
-
this.internalValidate = false;
|
244
292
|
if (this._valid) {
|
245
293
|
this.submitForm();
|
246
294
|
return;
|
@@ -249,7 +297,10 @@ let FieldValidator = class {
|
|
249
297
|
this.scrollToFirstInvalid();
|
250
298
|
this.nanoInvalid.emit();
|
251
299
|
};
|
252
|
-
/**
|
300
|
+
/**
|
301
|
+
* stops default form submission, checks if valid, then submits manually
|
302
|
+
* @param e - a submit event from the nested form element
|
303
|
+
*/
|
253
304
|
this.handleSubmit = async (e) => {
|
254
305
|
e.preventDefault();
|
255
306
|
if (this.validateOn === 'submitThenDirty')
|
@@ -274,15 +325,18 @@ let FieldValidator = class {
|
|
274
325
|
return this._activeForm;
|
275
326
|
}
|
276
327
|
set activeForm(form) {
|
277
|
-
|
328
|
+
// manages event listners on whatever form is used (slotted on created here)
|
329
|
+
if (!form)
|
330
|
+
return;
|
331
|
+
if (this._activeForm) {
|
278
332
|
this._activeForm.removeEventListener('invalid', this.handleFormInvalid, true);
|
279
|
-
|
280
|
-
|
333
|
+
}
|
334
|
+
form.addEventListener('invalid', this.handleFormInvalid, true);
|
281
335
|
this._activeForm = form;
|
282
336
|
}
|
283
337
|
/** Sync up validateOn with all fields */
|
284
338
|
validateOnChange() {
|
285
|
-
this.
|
339
|
+
this.nanoFields.forEach((field) => {
|
286
340
|
if (field.tagName === 'NANO-CHECKBOX') {
|
287
341
|
const cbg = field.closest('nano-checkbox-group');
|
288
342
|
if (cbg)
|
@@ -302,11 +356,15 @@ let FieldValidator = class {
|
|
302
356
|
get valid() {
|
303
357
|
return this._valid;
|
304
358
|
}
|
305
|
-
/** The current form
|
359
|
+
/** The current form state as a stencil store. */
|
360
|
+
get store() {
|
361
|
+
return this._store;
|
362
|
+
}
|
363
|
+
/** The current form payload as a reactive proxy. @readonly */
|
306
364
|
get payload() {
|
307
|
-
return this.
|
365
|
+
return this._store.state;
|
308
366
|
}
|
309
|
-
/** Returns true if validation errors will be displayed to the user */
|
367
|
+
/** Returns true if validation errors will be displayed to the user. @readonly */
|
310
368
|
get showValidation() {
|
311
369
|
return (this.validateOn === 'dirty' && this.dirty) || this.submitted;
|
312
370
|
}
|
@@ -323,37 +381,94 @@ let FieldValidator = class {
|
|
323
381
|
```
|
324
382
|
*/
|
325
383
|
get validationState() {
|
384
|
+
// TODO - migrate nano-fields away from using proprietary methods in a bid to be closer to the spec
|
385
|
+
// this is big and ugly.
|
386
|
+
// why? Cos' it must unify checking validity state for both
|
387
|
+
// `nano-...` and plain form fields.
|
326
388
|
const validationState = [];
|
327
|
-
this.
|
389
|
+
this.allFields.forEach(async (field) => {
|
328
390
|
const found = validationState.find((v) => v.name === field.name);
|
391
|
+
let pf;
|
392
|
+
let nf;
|
329
393
|
if (found) {
|
330
|
-
|
331
|
-
|
332
|
-
|
394
|
+
if (field.validationMessage) {
|
395
|
+
pf = field;
|
396
|
+
found.validityMessage = pf.validationMessage.length
|
397
|
+
? pf.validationMessage
|
398
|
+
: found.validityMessage;
|
399
|
+
this.internalValidate = true;
|
400
|
+
if (found.valid && !pf.checkValidity())
|
401
|
+
found.valid = false;
|
402
|
+
this.internalValidate = false;
|
403
|
+
}
|
404
|
+
else if (field.validityMessage) {
|
405
|
+
nf = field;
|
406
|
+
found.validityMessage = nf.validityMessage.length
|
407
|
+
? nf.validityMessage
|
408
|
+
: nf.validityMessage;
|
409
|
+
if (found.valid && nf.invalid)
|
410
|
+
found.valid = false;
|
411
|
+
}
|
333
412
|
if (!found.fields.find((f) => f === field))
|
334
413
|
found.fields.push(field);
|
335
|
-
|
336
|
-
|
337
|
-
|
414
|
+
}
|
415
|
+
let valid;
|
416
|
+
let validityMessage;
|
417
|
+
if (field.checkValidity) {
|
418
|
+
pf = field;
|
419
|
+
this.internalValidate = true;
|
420
|
+
valid = pf.checkValidity();
|
421
|
+
this.internalValidate = false;
|
422
|
+
validityMessage = pf.validationMessage;
|
423
|
+
}
|
424
|
+
else {
|
425
|
+
nf = field;
|
426
|
+
valid = !nf.invalid;
|
427
|
+
validityMessage = nf.validityMessage;
|
338
428
|
}
|
339
429
|
validationState.push({
|
340
430
|
fields: [field],
|
341
431
|
name: field.name,
|
342
|
-
|
343
|
-
value: this.store.state[field.name],
|
432
|
+
value: this._store.state[field.name],
|
344
433
|
dirty: false,
|
345
|
-
|
434
|
+
valid,
|
435
|
+
validityMessage,
|
346
436
|
});
|
347
437
|
});
|
348
438
|
return validationState;
|
349
439
|
}
|
440
|
+
/**
|
441
|
+
* Sets the state of the form using an object of key / value pairs.
|
442
|
+
* @param state - the state to load in the store
|
443
|
+
*/
|
444
|
+
async setStore(state) {
|
445
|
+
Object.entries(state).forEach(([key, val]) => (this.store.state[key] = val));
|
446
|
+
}
|
447
|
+
/**
|
448
|
+
* Sets custom validity for all / some form fields.
|
449
|
+
* @param validity - a validity object of `{fieldName: errorString}` pairs. Set as an empty string to clear the error.
|
450
|
+
*/
|
451
|
+
async setCustomValidity(validity) {
|
452
|
+
return await Promise.all(Object.entries(validity).map(async ([key, err]) => {
|
453
|
+
const field = this.allFields.find((f) => f.name === key);
|
454
|
+
if (!!field)
|
455
|
+
await this.setFieldError(field, err);
|
456
|
+
}));
|
457
|
+
}
|
458
|
+
/**
|
459
|
+
* Clear all custom validation.
|
460
|
+
* @param validity
|
461
|
+
*/
|
462
|
+
async resetValidity() {
|
463
|
+
return await Promise.all(this.allFields.map(async (field) => await this.setFieldError(field, '')));
|
464
|
+
}
|
350
465
|
// private methods
|
351
466
|
attachSlotObserver() {
|
352
467
|
if (!!this.mo)
|
353
468
|
return;
|
354
469
|
const mo = (this.mo = new MutationObserver((_entries) => {
|
355
470
|
const form = this.host.querySelector('form');
|
356
|
-
if (form !== this.activeForm)
|
471
|
+
if (form && form !== this.activeForm)
|
357
472
|
this.activeForm = form;
|
358
473
|
this.setupFields();
|
359
474
|
}));
|
@@ -366,95 +481,177 @@ let FieldValidator = class {
|
|
366
481
|
}
|
367
482
|
/** Checks for new `nano-...` fields and adds them to our watch array and value store */
|
368
483
|
setupFields() {
|
369
|
-
let
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
nano-date-input,
|
374
|
-
nano-checkbox
|
375
|
-
`));
|
376
|
-
fields = fields.filter((f) => !!f.name && !!f.name.length);
|
484
|
+
let nanoFields = Array.from(this.host.querySelectorAll(this.nanoFieldSelector));
|
485
|
+
let plainFields = Array.from(this.host.querySelectorAll(this.extraFieldSelector)).filter((e) => !e.closest(this.nanoFieldSelector));
|
486
|
+
nanoFields = nanoFields.filter((f) => !!f.name && !!f.name.length);
|
487
|
+
plainFields = plainFields.filter((f) => !!f.name && !!f.name.length);
|
377
488
|
// do we have any currently un-watched fields?
|
378
|
-
if (!
|
489
|
+
if (![...nanoFields, ...plainFields].filter((f) => !this.allFields.includes(f)).length)
|
379
490
|
return;
|
380
491
|
// setup the initial store state / refresh on new fields
|
381
|
-
this.
|
492
|
+
this.nanoFields = nanoFields;
|
493
|
+
this.plainFields = plainFields;
|
494
|
+
this.allFields = [...nanoFields, ...plainFields];
|
495
|
+
this.storeToFields(this.allFields);
|
382
496
|
this.validateOnChange();
|
383
|
-
this.
|
384
|
-
this.nanoPayloadChange.emit(this.
|
497
|
+
this.fieldsToStore(this.allFields);
|
498
|
+
this.nanoPayloadChange.emit(this._store.state);
|
499
|
+
}
|
500
|
+
storeToFields(fields) {
|
501
|
+
fields.forEach((field) => {
|
502
|
+
var _a;
|
503
|
+
const fieldName = field.name;
|
504
|
+
if (!fieldName.length ||
|
505
|
+
typeof this._store.state[fieldName] === 'undefined')
|
506
|
+
return;
|
507
|
+
if (field.tagName === 'NANO-CHECKBOX' ||
|
508
|
+
['radio', 'checkbox'].includes(field.type)) {
|
509
|
+
let cb = field;
|
510
|
+
if (cb.type === 'radio' ||
|
511
|
+
cb.type === 'segment' ||
|
512
|
+
cb.type === 'segment-pill') {
|
513
|
+
// single radio type control
|
514
|
+
if (this._store.state[fieldName] === cb.value)
|
515
|
+
cb.checked = true;
|
516
|
+
else
|
517
|
+
cb.checked = false;
|
518
|
+
}
|
519
|
+
else if (Array.isArray(this._store.state[fieldName])) {
|
520
|
+
// multiple checkbox like controls
|
521
|
+
if (this._store.state[fieldName].includes(cb.value))
|
522
|
+
cb.checked = true;
|
523
|
+
else
|
524
|
+
cb.checked = false;
|
525
|
+
}
|
526
|
+
else {
|
527
|
+
// single checkbox like control
|
528
|
+
if (this._store.state[fieldName] === cb.value)
|
529
|
+
cb.checked = true;
|
530
|
+
else
|
531
|
+
cb.checked = false;
|
532
|
+
}
|
533
|
+
return;
|
534
|
+
}
|
535
|
+
if (field.tagName === 'NANO-FILE-UPLOAD') {
|
536
|
+
const ff = field;
|
537
|
+
// this can only work if the field is empty rn... a one-time deal
|
538
|
+
if (!((_a = ff.files) === null || _a === void 0 ? void 0 : _a.length))
|
539
|
+
ff.files = this._store.state[fieldName];
|
540
|
+
return;
|
541
|
+
}
|
542
|
+
// default
|
543
|
+
field.value = this._store.state[fieldName];
|
544
|
+
});
|
385
545
|
}
|
386
546
|
/** Loops through all `nano-...` fields and extracts their values into our store */
|
387
|
-
|
547
|
+
fieldsToStore(fields) {
|
388
548
|
fields.forEach((field) => {
|
389
549
|
const fieldName = field.name;
|
390
550
|
if (!fieldName.length)
|
391
551
|
return;
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
}
|
414
|
-
else {
|
415
|
-
this.store.state[fieldName] = currentArr.filter((v) => v !== cb.value);
|
552
|
+
if (field.tagName === 'NANO-CHECKBOX' ||
|
553
|
+
['radio', 'checkbox'].includes(field.type)) {
|
554
|
+
let cb = field;
|
555
|
+
if (cb.type === 'radio' ||
|
556
|
+
cb.type === 'segment' ||
|
557
|
+
cb.type === 'segment-pill') {
|
558
|
+
// radio type control - only one can be checked
|
559
|
+
if (cb.checked)
|
560
|
+
this._store.state[fieldName] = cb.value;
|
561
|
+
}
|
562
|
+
else if (this.allFields.filter((f) => f.name === fieldName &&
|
563
|
+
(f.tagName === 'NANO-CHECKBOX' ||
|
564
|
+
f.type === 'checkbox')).length > 1) {
|
565
|
+
// multiple checkbox type control
|
566
|
+
const currentArr = Array.isArray(this._store.state[fieldName])
|
567
|
+
? this._store.state[fieldName]
|
568
|
+
: [];
|
569
|
+
if (cb.checked) {
|
570
|
+
// checked
|
571
|
+
if (!this._store.state[fieldName].includes(cb.value)) {
|
572
|
+
this._store.state[fieldName] = [...currentArr, cb.value];
|
416
573
|
}
|
417
574
|
}
|
575
|
+
else {
|
576
|
+
// unchecked
|
577
|
+
this._store.state[fieldName] = currentArr.filter((v) => v !== cb.value);
|
578
|
+
}
|
579
|
+
}
|
580
|
+
else {
|
581
|
+
// single checkbox - on or off
|
582
|
+
if (cb.checked)
|
583
|
+
this._store.state[fieldName] = cb.value;
|
418
584
|
else
|
419
|
-
this.
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
585
|
+
this._store.state[fieldName] = '';
|
586
|
+
}
|
587
|
+
return;
|
588
|
+
}
|
589
|
+
if (field.tagName === 'NANO-FILE-UPLOAD') {
|
590
|
+
const ff = field;
|
591
|
+
if (!this.fileStateEqual(fieldName, ff))
|
592
|
+
this._store.state[fieldName] = ff.files;
|
593
|
+
return;
|
427
594
|
}
|
595
|
+
// default
|
596
|
+
this._store.state[fieldName] = field.value;
|
428
597
|
});
|
429
598
|
}
|
430
|
-
/**
|
599
|
+
/**
|
600
|
+
* Tries to ascertain whether the current model
|
601
|
+
* value is the same as the `nano-file-upload` value
|
602
|
+
* @param fieldName - the key to access from the data store
|
603
|
+
* @param field - the nano-file-upload field to assess against
|
604
|
+
* @returns true for equal, false for not equal
|
605
|
+
*/
|
606
|
+
fileStateEqual(fieldName, field) {
|
607
|
+
return (JSON.stringify(this._store.state[fieldName]) ===
|
608
|
+
JSON.stringify(field.files) ||
|
609
|
+
this._store.state[fieldName] == field.files);
|
610
|
+
}
|
611
|
+
/**
|
612
|
+
* Checks for user defined validations
|
613
|
+
* @param key - current key of the data model to validate
|
614
|
+
* @param newVal - the newly set, incoming value to validate
|
615
|
+
*/
|
431
616
|
async validate(key, newVal) {
|
432
617
|
if (!this.validation)
|
433
618
|
return;
|
434
|
-
const res = this.validation(key, newVal, this.
|
619
|
+
const res = this.validation(key, newVal, this._store.state);
|
435
620
|
// no nothing - return
|
436
621
|
if (!res)
|
437
622
|
return;
|
438
623
|
// stencil public methods are async
|
439
|
-
// so we must
|
624
|
+
// so we must coerce our validation
|
440
625
|
// collection loop into a promise
|
441
626
|
await Promise.all(Object.entries(res).map(async ([key, o]) => {
|
442
627
|
// switch on/off validation messages
|
443
|
-
const field = this.
|
628
|
+
const field = this.allFields.find((f) => f.name === key);
|
444
629
|
let validityTarget = field;
|
445
630
|
if (field.tagName === 'NANO-CHECKBOX') {
|
631
|
+
// if we have a checkbox-group, set the validation message there
|
446
632
|
const cbg = field.closest('nano-checkbox-group');
|
447
633
|
validityTarget = cbg || field;
|
448
634
|
}
|
449
|
-
|
450
|
-
|
635
|
+
if ((validityTarget.validityMessage ||
|
636
|
+
validityTarget.validationMessage) === o.msg &&
|
637
|
+
o.valid) {
|
638
|
+
// status is now valid - clear the error
|
451
639
|
await this.setFieldError(validityTarget, '');
|
452
|
-
|
640
|
+
}
|
453
641
|
else if (!o.valid) {
|
642
|
+
// status is invalid. Set the error
|
454
643
|
await this.setFieldError(validityTarget, o.msg);
|
455
644
|
}
|
456
645
|
}));
|
457
646
|
}
|
647
|
+
/** Loops through all store entries and checks custom validation */
|
648
|
+
async validateAllFields() {
|
649
|
+
// This forces our loop to `await` and finish sequentially ... silly async stencil methods
|
650
|
+
await Object.entries(this._store.state).reduce(async (memo, [key, value]) => {
|
651
|
+
await memo;
|
652
|
+
await this.validate(key, value);
|
653
|
+
}, undefined);
|
654
|
+
}
|
458
655
|
/**
|
459
656
|
* Utility to smooth out setting error messages
|
460
657
|
* (it's a different method on `nano-checkbox` 'cos they don't show errors themselves)
|
@@ -464,16 +661,10 @@ let FieldValidator = class {
|
|
464
661
|
async setFieldError(field, msg) {
|
465
662
|
if (field['showError'])
|
466
663
|
await field.showError(msg);
|
467
|
-
else
|
664
|
+
else if (field['setError'])
|
468
665
|
await field.setError(msg);
|
469
|
-
|
470
|
-
|
471
|
-
async validateAllFields() {
|
472
|
-
// This forces our loop to `await` and finish sequentially ... silly async stencil methods
|
473
|
-
await Object.entries(this.store.state).reduce(async (memo, [key, value]) => {
|
474
|
-
await memo;
|
475
|
-
await this.validate(key, value);
|
476
|
-
}, undefined);
|
666
|
+
else
|
667
|
+
field.setCustomValidity(msg);
|
477
668
|
}
|
478
669
|
scrollToFirstInvalid() {
|
479
670
|
if (!this.scrollToInvalid)
|
@@ -496,23 +687,27 @@ let FieldValidator = class {
|
|
496
687
|
}
|
497
688
|
connectedCallback() {
|
498
689
|
this.userForm = this.host.querySelector('form');
|
690
|
+
this._store = createStore({});
|
499
691
|
}
|
500
692
|
componentDidLoad() {
|
501
693
|
requestAnimationFrame(() => {
|
502
|
-
this.store = createStore({});
|
503
694
|
this.setupFields();
|
504
695
|
this.attachSlotObserver();
|
505
|
-
this.store.on('set', (key, value) => this.handleStoreChange(key, value));
|
506
696
|
this.host.addEventListener('nanoChange', this.handleFieldChange);
|
697
|
+
this.host.addEventListener('input', this.handlePlainFieldChange);
|
698
|
+
this.host.addEventListener('change', this.handlePlainFieldChange);
|
507
699
|
this.host.addEventListener('submit', this.handleSubmit);
|
700
|
+
this._store.on('set', this.handleStoreChange);
|
508
701
|
});
|
509
702
|
}
|
510
703
|
disconnectedCallback() {
|
511
704
|
if (this.mo)
|
512
705
|
this.mo.disconnect();
|
513
|
-
this.store.dispose();
|
514
706
|
this.host.removeEventListener('nanoChange', this.handleFieldChange);
|
707
|
+
this.host.removeEventListener('input', this.handlePlainFieldChange);
|
708
|
+
this.host.removeEventListener('change', this.handlePlainFieldChange);
|
515
709
|
this.host.removeEventListener('submit', this.handleSubmit);
|
710
|
+
this._store.reset();
|
516
711
|
if (this.activeForm)
|
517
712
|
this.activeForm.removeEventListener('invalid', this.handleFormInvalid, true);
|
518
713
|
}
|
@@ -522,7 +717,8 @@ let FieldValidator = class {
|
|
522
717
|
get host() { return index.getElement(this); }
|
523
718
|
static get watchers() { return {
|
524
719
|
"userForm": ["userFormChange"],
|
525
|
-
"validateOn": ["validateOnChange"]
|
720
|
+
"validateOn": ["validateOnChange"],
|
721
|
+
"extraFieldSelector": ["attachSlotObserver"]
|
526
722
|
}; }
|
527
723
|
};
|
528
724
|
|