@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.
Files changed (441) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/cjs/{date-utils-0ae9a12d.js → date-utils-b3af910d.js} +2 -2
  3. package/dist/cjs/date-utils-b3af910d.js.map +1 -0
  4. package/dist/cjs/{global-0d4f3b77.js → global-989678ec.js} +1 -8
  5. package/dist/cjs/global-989678ec.js.map +1 -0
  6. package/dist/cjs/index.cjs.js +2 -0
  7. package/dist/cjs/index.cjs.js.map +1 -1
  8. package/dist/cjs/loader.cjs.js +2 -2
  9. package/dist/cjs/nano-algolia.cjs.entry.js +5 -1
  10. package/dist/cjs/nano-algolia.cjs.entry.js.map +1 -1
  11. package/dist/cjs/nano-components.cjs.js +2 -2
  12. package/dist/cjs/nano-datalist_3.cjs.entry.js +3 -1
  13. package/dist/cjs/nano-datalist_3.cjs.entry.js.map +1 -1
  14. package/dist/cjs/nano-date-input.cjs.entry.js +16 -5
  15. package/dist/cjs/nano-date-input.cjs.entry.js.map +1 -1
  16. package/dist/cjs/nano-date-picker.cjs.entry.js +2 -2
  17. package/dist/cjs/nano-date-picker.cjs.entry.js.map +1 -1
  18. package/dist/cjs/nano-details.cjs.entry.js +1 -2
  19. package/dist/cjs/nano-details.cjs.entry.js.map +1 -1
  20. package/dist/cjs/nano-field-validator.cjs.entry.js +292 -96
  21. package/dist/cjs/nano-field-validator.cjs.entry.js.map +1 -1
  22. package/dist/cjs/nano-file-upload.cjs.entry.js +5 -2
  23. package/dist/cjs/nano-file-upload.cjs.entry.js.map +1 -1
  24. package/dist/cjs/nano-global-search-results.cjs.entry.js +21 -6
  25. package/dist/cjs/nano-global-search-results.cjs.entry.js.map +1 -1
  26. package/dist/cjs/nano-grid_3.cjs.entry.js +1 -2
  27. package/dist/cjs/nano-grid_3.cjs.entry.js.map +1 -1
  28. package/dist/cjs/nano-icon-button.cjs.entry.js +4 -0
  29. package/dist/cjs/nano-icon-button.cjs.entry.js.map +1 -1
  30. package/dist/cjs/nano-input.cjs.entry.js +16 -3
  31. package/dist/cjs/nano-input.cjs.entry.js.map +1 -1
  32. package/dist/cjs/nano-nav-item_2.cjs.entry.js +2 -0
  33. package/dist/cjs/nano-nav-item_2.cjs.entry.js.map +1 -1
  34. package/dist/cjs/nano-resize-observe_2.cjs.entry.js +1 -2
  35. package/dist/cjs/nano-resize-observe_2.cjs.entry.js.map +1 -1
  36. package/dist/cjs/nano-slides.cjs.entry.js +1 -2
  37. package/dist/cjs/nano-slides.cjs.entry.js.map +1 -1
  38. package/dist/cjs/nano-sticker.cjs.entry.js +2 -3
  39. package/dist/cjs/nano-sticker.cjs.entry.js.map +1 -1
  40. package/dist/cjs/nano-tab-group.cjs.entry.js +4 -2
  41. package/dist/cjs/nano-tab-group.cjs.entry.js.map +1 -1
  42. package/dist/cjs/nano-tab.cjs.entry.js +5 -1
  43. package/dist/cjs/nano-tab.cjs.entry.js.map +1 -1
  44. package/dist/cjs/nano-tooltip.cjs.entry.js +1 -1
  45. package/dist/cjs/nano-tooltip.cjs.entry.js.map +1 -1
  46. package/dist/collection/components/accordion/accordion.js +1 -1
  47. package/dist/collection/components/alert/alert.js +1 -1
  48. package/dist/collection/components/algolia/algolia-filter.js +2 -2
  49. package/dist/collection/components/algolia/algolia-input.js +5 -5
  50. package/dist/collection/components/algolia/algolia-results.js +1 -1
  51. package/dist/collection/components/algolia/algolia.js +12 -6
  52. package/dist/collection/components/algolia/algolia.js.map +1 -1
  53. package/dist/collection/components/checkbox/checkbox-group.js +2 -2
  54. package/dist/collection/components/checkbox/checkbox.js +3 -3
  55. package/dist/collection/components/datalist/datalist.js +4 -2
  56. package/dist/collection/components/datalist/datalist.js.map +1 -1
  57. package/dist/collection/components/date-input/date-input.js +65 -11
  58. package/dist/collection/components/date-input/date-input.js.map +1 -1
  59. package/dist/collection/components/date-picker/date-picker.css +1 -1
  60. package/dist/collection/components/date-picker/date-picker.js +5 -5
  61. package/dist/collection/components/details/details.js +1 -2
  62. package/dist/collection/components/details/details.js.map +1 -1
  63. package/dist/collection/components/dialog/dialog.js +1 -1
  64. package/dist/collection/components/dropdown/dropdown.js +1 -1
  65. package/dist/collection/components/field-validator/field-validator-interface.js +5 -0
  66. package/dist/collection/components/field-validator/field-validator-interface.js.map +1 -0
  67. package/dist/collection/components/field-validator/field-validator.js +434 -113
  68. package/dist/collection/components/field-validator/field-validator.js.map +1 -1
  69. package/dist/collection/components/file-upload/file-upload.css +0 -1
  70. package/dist/collection/components/file-upload/file-upload.js +10 -7
  71. package/dist/collection/components/file-upload/file-upload.js.map +1 -1
  72. package/dist/collection/components/global-nav/global-nav.js +4 -4
  73. package/dist/collection/components/global-search-results/global-search-results.css +7 -0
  74. package/dist/collection/components/global-search-results/global-search-results.js +19 -4
  75. package/dist/collection/components/global-search-results/global-search-results.js.map +1 -1
  76. package/dist/collection/components/grid/grid-item.js +1 -1
  77. package/dist/collection/components/grid/grid.js +0 -1
  78. package/dist/collection/components/grid/grid.js.map +1 -1
  79. package/dist/collection/components/icon/icon.js +1 -1
  80. package/dist/collection/components/icon-button/icon-button.js +23 -1
  81. package/dist/collection/components/icon-button/icon-button.js.map +1 -1
  82. package/dist/collection/components/input/input.js +37 -8
  83. package/dist/collection/components/input/input.js.map +1 -1
  84. package/dist/collection/components/nav-item/nav-item.js +4 -4
  85. package/dist/collection/components/range/range.js +4 -4
  86. package/dist/collection/components/resize-observe/resize-observe.js +1 -2
  87. package/dist/collection/components/resize-observe/resize-observe.js.map +1 -1
  88. package/dist/collection/components/select/select.js +9 -7
  89. package/dist/collection/components/select/select.js.map +1 -1
  90. package/dist/collection/components/slides/slides.js +7 -8
  91. package/dist/collection/components/slides/slides.js.map +1 -1
  92. package/dist/collection/components/sticker/sticker.js +0 -1
  93. package/dist/collection/components/sticker/sticker.js.map +1 -1
  94. package/dist/collection/components/tabs/tab-group.js +5 -3
  95. package/dist/collection/components/tabs/tab-group.js.map +1 -1
  96. package/dist/collection/components/tabs/tab.js +5 -1
  97. package/dist/collection/components/tabs/tab.js.map +1 -1
  98. package/dist/collection/components/tooltip/tooltip.css +0 -1
  99. package/dist/collection/global/script/global.js +0 -7
  100. package/dist/collection/global/script/global.js.map +1 -1
  101. package/dist/collection/index.js +1 -0
  102. package/dist/collection/index.js.map +1 -1
  103. package/dist/collection/utils/date-utils.js +1 -1
  104. package/dist/collection/utils/date-utils.js.map +1 -1
  105. package/dist/components/algolia.js +5 -1
  106. package/dist/components/algolia.js.map +1 -1
  107. package/dist/components/datalist.js +3 -1
  108. package/dist/components/datalist.js.map +1 -1
  109. package/dist/components/date-picker.js +2 -2
  110. package/dist/components/date-picker.js.map +1 -1
  111. package/dist/components/grid.js +1 -2
  112. package/dist/components/grid.js.map +1 -1
  113. package/dist/components/icon-button.js +6 -1
  114. package/dist/components/icon-button.js.map +1 -1
  115. package/dist/components/index.js +1 -7
  116. package/dist/components/index.js.map +1 -1
  117. package/dist/components/input.js +17 -3
  118. package/dist/components/input.js.map +1 -1
  119. package/dist/components/nano-date-input.js +17 -4
  120. package/dist/components/nano-date-input.js.map +1 -1
  121. package/dist/components/nano-details.js +1 -2
  122. package/dist/components/nano-details.js.map +1 -1
  123. package/dist/components/nano-field-validator.js +300 -99
  124. package/dist/components/nano-field-validator.js.map +1 -1
  125. package/dist/components/nano-file-upload.js +6 -3
  126. package/dist/components/nano-file-upload.js.map +1 -1
  127. package/dist/components/nano-global-search-results.js +21 -6
  128. package/dist/components/nano-global-search-results.js.map +1 -1
  129. package/dist/components/nano-slides.js +1 -2
  130. package/dist/components/nano-slides.js.map +1 -1
  131. package/dist/components/nano-tab-group.js +4 -2
  132. package/dist/components/nano-tab-group.js.map +1 -1
  133. package/dist/components/nano-tab.js +5 -1
  134. package/dist/components/nano-tab.js.map +1 -1
  135. package/dist/components/resize-observe.js +1 -2
  136. package/dist/components/resize-observe.js.map +1 -1
  137. package/dist/components/select.js +2 -0
  138. package/dist/components/select.js.map +1 -1
  139. package/dist/components/sticker.js +2 -3
  140. package/dist/components/sticker.js.map +1 -1
  141. package/dist/components/tooltip.js +1 -1
  142. package/dist/components/tooltip.js.map +1 -1
  143. package/dist/custom-elements/index.js +386 -2046
  144. package/dist/custom-elements/index.js.map +1 -1
  145. package/dist/esm/{date-utils-e4b757ff.js → date-utils-839cb010.js} +2 -2
  146. package/dist/esm/date-utils-839cb010.js.map +1 -0
  147. package/dist/esm/{global-d5ec4d53.js → global-8047b4ff.js} +1 -8
  148. package/dist/esm/global-8047b4ff.js.map +1 -0
  149. package/dist/esm/index.js +1 -0
  150. package/dist/esm/index.js.map +1 -1
  151. package/dist/esm/loader.js +2 -2
  152. package/dist/esm/nano-algolia.entry.js +5 -1
  153. package/dist/esm/nano-algolia.entry.js.map +1 -1
  154. package/dist/esm/nano-components.js +2 -2
  155. package/dist/esm/nano-datalist_3.entry.js +3 -1
  156. package/dist/esm/nano-datalist_3.entry.js.map +1 -1
  157. package/dist/esm/nano-date-input.entry.js +16 -5
  158. package/dist/esm/nano-date-input.entry.js.map +1 -1
  159. package/dist/esm/nano-date-picker.entry.js +2 -2
  160. package/dist/esm/nano-date-picker.entry.js.map +1 -1
  161. package/dist/esm/nano-details.entry.js +1 -2
  162. package/dist/esm/nano-details.entry.js.map +1 -1
  163. package/dist/esm/nano-field-validator.entry.js +292 -96
  164. package/dist/esm/nano-field-validator.entry.js.map +1 -1
  165. package/dist/esm/nano-file-upload.entry.js +5 -2
  166. package/dist/esm/nano-file-upload.entry.js.map +1 -1
  167. package/dist/esm/nano-global-search-results.entry.js +21 -6
  168. package/dist/esm/nano-global-search-results.entry.js.map +1 -1
  169. package/dist/esm/nano-grid_3.entry.js +1 -2
  170. package/dist/esm/nano-grid_3.entry.js.map +1 -1
  171. package/dist/esm/nano-icon-button.entry.js +4 -0
  172. package/dist/esm/nano-icon-button.entry.js.map +1 -1
  173. package/dist/esm/nano-input.entry.js +16 -3
  174. package/dist/esm/nano-input.entry.js.map +1 -1
  175. package/dist/esm/nano-nav-item_2.entry.js +2 -0
  176. package/dist/esm/nano-nav-item_2.entry.js.map +1 -1
  177. package/dist/esm/nano-resize-observe_2.entry.js +1 -2
  178. package/dist/esm/nano-resize-observe_2.entry.js.map +1 -1
  179. package/dist/esm/nano-slides.entry.js +1 -2
  180. package/dist/esm/nano-slides.entry.js.map +1 -1
  181. package/dist/esm/nano-sticker.entry.js +2 -3
  182. package/dist/esm/nano-sticker.entry.js.map +1 -1
  183. package/dist/esm/nano-tab-group.entry.js +4 -2
  184. package/dist/esm/nano-tab-group.entry.js.map +1 -1
  185. package/dist/esm/nano-tab.entry.js +5 -1
  186. package/dist/esm/nano-tab.entry.js.map +1 -1
  187. package/dist/esm/nano-tooltip.entry.js +1 -1
  188. package/dist/esm/nano-tooltip.entry.js.map +1 -1
  189. package/dist/esm-es5/date-utils-839cb010.js +5 -0
  190. package/dist/esm-es5/date-utils-839cb010.js.map +1 -0
  191. package/dist/esm-es5/{global-d5ec4d53.js → global-8047b4ff.js} +2 -2
  192. package/dist/esm-es5/global-8047b4ff.js.map +1 -0
  193. package/dist/esm-es5/index.js +2 -2
  194. package/dist/esm-es5/index.js.map +1 -1
  195. package/dist/esm-es5/loader.js +1 -1
  196. package/dist/esm-es5/loader.js.map +1 -1
  197. package/dist/esm-es5/nano-algolia.entry.js +1 -1
  198. package/dist/esm-es5/nano-algolia.entry.js.map +1 -1
  199. package/dist/esm-es5/nano-components.js +1 -1
  200. package/dist/esm-es5/nano-components.js.map +1 -1
  201. package/dist/esm-es5/nano-datalist_3.entry.js +1 -1
  202. package/dist/esm-es5/nano-datalist_3.entry.js.map +1 -1
  203. package/dist/esm-es5/nano-date-input.entry.js +1 -1
  204. package/dist/esm-es5/nano-date-input.entry.js.map +1 -1
  205. package/dist/esm-es5/nano-date-picker.entry.js +1 -1
  206. package/dist/esm-es5/nano-date-picker.entry.js.map +1 -1
  207. package/dist/esm-es5/nano-details.entry.js +1 -1
  208. package/dist/esm-es5/nano-details.entry.js.map +1 -1
  209. package/dist/esm-es5/nano-field-validator.entry.js +2 -2
  210. package/dist/esm-es5/nano-field-validator.entry.js.map +1 -1
  211. package/dist/esm-es5/nano-file-upload.entry.js +1 -1
  212. package/dist/esm-es5/nano-file-upload.entry.js.map +1 -1
  213. package/dist/esm-es5/nano-global-search-results.entry.js +1 -1
  214. package/dist/esm-es5/nano-global-search-results.entry.js.map +1 -1
  215. package/dist/esm-es5/nano-grid_3.entry.js +1 -1
  216. package/dist/esm-es5/nano-grid_3.entry.js.map +1 -1
  217. package/dist/esm-es5/nano-icon-button.entry.js +2 -2
  218. package/dist/esm-es5/nano-icon-button.entry.js.map +1 -1
  219. package/dist/esm-es5/nano-input.entry.js +1 -1
  220. package/dist/esm-es5/nano-input.entry.js.map +1 -1
  221. package/dist/esm-es5/nano-nav-item_2.entry.js +1 -1
  222. package/dist/esm-es5/nano-nav-item_2.entry.js.map +1 -1
  223. package/dist/esm-es5/nano-resize-observe_2.entry.js +1 -1
  224. package/dist/esm-es5/nano-resize-observe_2.entry.js.map +1 -1
  225. package/dist/esm-es5/nano-slides.entry.js +2 -2
  226. package/dist/esm-es5/nano-slides.entry.js.map +1 -1
  227. package/dist/esm-es5/nano-sticker.entry.js +1 -1
  228. package/dist/esm-es5/nano-sticker.entry.js.map +1 -1
  229. package/dist/esm-es5/nano-tab-group.entry.js +2 -2
  230. package/dist/esm-es5/nano-tab-group.entry.js.map +1 -1
  231. package/dist/esm-es5/nano-tab.entry.js +2 -2
  232. package/dist/esm-es5/nano-tab.entry.js.map +1 -1
  233. package/dist/esm-es5/nano-tooltip.entry.js +1 -1
  234. package/dist/esm-es5/nano-tooltip.entry.js.map +1 -1
  235. package/dist/nano-components/index.esm.js +1 -1
  236. package/dist/nano-components/index.esm.js.map +1 -1
  237. package/dist/nano-components/nano-components.esm.js +1 -1
  238. package/dist/nano-components/nano-components.esm.js.map +1 -1
  239. package/dist/nano-components/nano-components.js +1 -1
  240. package/dist/nano-components/p-018b7047.entry.js +5 -0
  241. package/dist/nano-components/p-018b7047.entry.js.map +1 -0
  242. package/dist/nano-components/p-0193a282.entry.js +5 -0
  243. package/dist/nano-components/p-0193a282.entry.js.map +1 -0
  244. package/dist/nano-components/p-0320410c.entry.js +5 -0
  245. package/dist/nano-components/p-0320410c.entry.js.map +1 -0
  246. package/dist/nano-components/p-0d699368.system.js +5 -0
  247. package/dist/nano-components/{p-3258c568.system.js.map → p-0d699368.system.js.map} +1 -1
  248. package/dist/nano-components/p-18863670.system.entry.js +5 -0
  249. package/dist/nano-components/p-18863670.system.entry.js.map +1 -0
  250. package/dist/nano-components/p-32900c91.entry.js +5 -0
  251. package/dist/nano-components/p-32900c91.entry.js.map +1 -0
  252. package/dist/nano-components/p-33fce1a6.js +5 -0
  253. package/dist/nano-components/p-33fce1a6.js.map +1 -0
  254. package/dist/nano-components/p-371aebe7.system.entry.js +23 -0
  255. package/dist/nano-components/p-371aebe7.system.entry.js.map +1 -0
  256. package/dist/nano-components/p-41899a31.system.entry.js +5 -0
  257. package/dist/nano-components/p-41899a31.system.entry.js.map +1 -0
  258. package/dist/nano-components/p-53957ec6.system.js +5 -0
  259. package/dist/nano-components/{p-e7140887.system.js.map → p-53957ec6.system.js.map} +1 -1
  260. package/dist/nano-components/p-561500f0.system.entry.js +5 -0
  261. package/dist/nano-components/p-561500f0.system.entry.js.map +1 -0
  262. package/dist/nano-components/p-596c1711.system.entry.js +5 -0
  263. package/dist/nano-components/p-596c1711.system.entry.js.map +1 -0
  264. package/dist/nano-components/{p-01667573.entry.js → p-634a58f7.entry.js} +2 -2
  265. package/dist/nano-components/p-634a58f7.entry.js.map +1 -0
  266. package/dist/nano-components/p-6a949280.system.entry.js +5 -0
  267. package/dist/nano-components/p-6a949280.system.entry.js.map +1 -0
  268. package/dist/nano-components/{p-bf9aa89d.system.entry.js → p-6af10533.system.entry.js} +3 -3
  269. package/dist/nano-components/p-6af10533.system.entry.js.map +1 -0
  270. package/dist/nano-components/p-70272eae.js +5 -0
  271. package/dist/nano-components/p-70272eae.js.map +1 -0
  272. package/dist/nano-components/p-755d9227.entry.js +5 -0
  273. package/dist/nano-components/p-755d9227.entry.js.map +1 -0
  274. package/dist/nano-components/p-7bd25494.entry.js +5 -0
  275. package/dist/nano-components/p-7bd25494.entry.js.map +1 -0
  276. package/dist/nano-components/p-7c837460.entry.js +5 -0
  277. package/dist/nano-components/p-7c837460.entry.js.map +1 -0
  278. package/dist/nano-components/p-7f051c20.entry.js +5 -0
  279. package/dist/nano-components/p-7f051c20.entry.js.map +1 -0
  280. package/dist/nano-components/{p-93880c28.system.js → p-82e28afd.system.js} +2 -2
  281. package/dist/nano-components/p-82e28afd.system.js.map +1 -0
  282. package/dist/nano-components/p-8378428e.system.js +5 -0
  283. package/dist/nano-components/p-8378428e.system.js.map +1 -0
  284. package/dist/nano-components/p-8df4f125.system.entry.js +5 -0
  285. package/dist/nano-components/p-8df4f125.system.entry.js.map +1 -0
  286. package/dist/nano-components/{p-d0385948.system.entry.js → p-93596c3d.system.entry.js} +2 -2
  287. package/dist/nano-components/p-93596c3d.system.entry.js.map +1 -0
  288. package/dist/nano-components/{p-3e930ac7.entry.js → p-9d9b0b66.entry.js} +2 -2
  289. package/dist/nano-components/p-9d9b0b66.entry.js.map +1 -0
  290. package/dist/nano-components/p-9ffdf6cc.entry.js +5 -0
  291. package/dist/nano-components/{p-222d8095.entry.js.map → p-9ffdf6cc.entry.js.map} +1 -1
  292. package/dist/nano-components/p-a07cf44c.system.entry.js +5 -0
  293. package/dist/nano-components/p-a07cf44c.system.entry.js.map +1 -0
  294. package/dist/nano-components/p-a1444980.entry.js +5 -0
  295. package/dist/nano-components/p-a1444980.entry.js.map +1 -0
  296. package/dist/nano-components/p-aa84c727.system.entry.js +5 -0
  297. package/dist/nano-components/p-aa84c727.system.entry.js.map +1 -0
  298. package/dist/nano-components/p-ac5e3775.system.entry.js +5 -0
  299. package/dist/nano-components/p-ac5e3775.system.entry.js.map +1 -0
  300. package/dist/nano-components/p-b85cf493.system.entry.js +5 -0
  301. package/dist/nano-components/{p-e817ab4a.system.entry.js.map → p-b85cf493.system.entry.js.map} +1 -1
  302. package/dist/nano-components/{p-96d9b8b9.system.entry.js → p-c2bbf0fb.system.entry.js} +2 -2
  303. package/dist/nano-components/p-c2bbf0fb.system.entry.js.map +1 -0
  304. package/dist/nano-components/{p-f780d2f6.system.entry.js → p-cb512cff.system.entry.js} +2 -2
  305. package/dist/nano-components/p-cb512cff.system.entry.js.map +1 -0
  306. package/dist/nano-components/{p-4e2c0abb.entry.js → p-ccd6c206.entry.js} +2 -2
  307. package/dist/nano-components/p-ccd6c206.entry.js.map +1 -0
  308. package/dist/nano-components/{p-1030797a.entry.js → p-d37e1489.entry.js} +2 -2
  309. package/dist/nano-components/p-d37e1489.entry.js.map +1 -0
  310. package/dist/nano-components/p-da88981f.entry.js +23 -0
  311. package/dist/nano-components/p-da88981f.entry.js.map +1 -0
  312. package/dist/nano-components/p-e8a913ac.system.entry.js +5 -0
  313. package/dist/nano-components/p-e8a913ac.system.entry.js.map +1 -0
  314. package/dist/nano-components/p-e9fddc1a.entry.js +5 -0
  315. package/dist/nano-components/p-e9fddc1a.entry.js.map +1 -0
  316. package/dist/nano-components/p-ea54ee12.entry.js +5 -0
  317. package/dist/nano-components/p-ea54ee12.entry.js.map +1 -0
  318. package/dist/nano-components/{p-86bd5194.entry.js → p-ed0bdea9.entry.js} +2 -2
  319. package/dist/nano-components/p-ed0bdea9.entry.js.map +1 -0
  320. package/dist/nano-components/p-faba2fc1.system.entry.js +5 -0
  321. package/dist/nano-components/p-faba2fc1.system.entry.js.map +1 -0
  322. package/dist/nano-components/p-ff026352.system.entry.js +5 -0
  323. package/dist/nano-components/p-ff026352.system.entry.js.map +1 -0
  324. package/dist/themes/nanopore.css +1 -1
  325. package/dist/themes/nanopore.css.map +1 -1
  326. package/dist/types/components/algolia/algolia.d.ts +1 -0
  327. package/dist/types/components/date-input/date-input.d.ts +6 -1
  328. package/dist/types/components/field-validator/field-validator-interface.d.ts +19 -0
  329. package/dist/types/components/field-validator/field-validator.d.ts +77 -31
  330. package/dist/types/components/file-upload/file-upload.d.ts +2 -1
  331. package/dist/types/components/global-search-results/global-search-results.d.ts +1 -0
  332. package/dist/types/components/icon-button/icon-button.d.ts +2 -0
  333. package/dist/types/components/input/input.d.ts +6 -1
  334. package/dist/types/components/tabs/tab.d.ts +1 -0
  335. package/dist/types/components.d.ts +67 -12
  336. package/dist/types/index.d.ts +1 -0
  337. package/dist/types/interface.d.ts +1 -0
  338. package/docs-json.json +161 -13
  339. package/docs-vscode.json +6 -2
  340. package/package.json +2 -4
  341. package/dist/cjs/ResizeObserver.es-09b81a1b.js +0 -935
  342. package/dist/cjs/ResizeObserver.es-09b81a1b.js.map +0 -1
  343. package/dist/cjs/date-utils-0ae9a12d.js.map +0 -1
  344. package/dist/cjs/global-0d4f3b77.js.map +0 -1
  345. package/dist/cjs/intersection-observer-1822c787.js +0 -987
  346. package/dist/cjs/intersection-observer-1822c787.js.map +0 -1
  347. package/dist/components/ResizeObserver.es.js +0 -933
  348. package/dist/components/ResizeObserver.es.js.map +0 -1
  349. package/dist/components/intersection-observer.js +0 -985
  350. package/dist/components/intersection-observer.js.map +0 -1
  351. package/dist/esm/ResizeObserver.es-724af9fd.js +0 -933
  352. package/dist/esm/ResizeObserver.es-724af9fd.js.map +0 -1
  353. package/dist/esm/date-utils-e4b757ff.js.map +0 -1
  354. package/dist/esm/global-d5ec4d53.js.map +0 -1
  355. package/dist/esm/intersection-observer-dff9fb5b.js +0 -985
  356. package/dist/esm/intersection-observer-dff9fb5b.js.map +0 -1
  357. package/dist/esm-es5/ResizeObserver.es-724af9fd.js +0 -5
  358. package/dist/esm-es5/ResizeObserver.es-724af9fd.js.map +0 -1
  359. package/dist/esm-es5/date-utils-e4b757ff.js +0 -5
  360. package/dist/esm-es5/date-utils-e4b757ff.js.map +0 -1
  361. package/dist/esm-es5/global-d5ec4d53.js.map +0 -1
  362. package/dist/esm-es5/intersection-observer-dff9fb5b.js +0 -5
  363. package/dist/esm-es5/intersection-observer-dff9fb5b.js.map +0 -1
  364. package/dist/nano-components/p-00eaa36a.entry.js +0 -5
  365. package/dist/nano-components/p-00eaa36a.entry.js.map +0 -1
  366. package/dist/nano-components/p-01667573.entry.js.map +0 -1
  367. package/dist/nano-components/p-1030797a.entry.js.map +0 -1
  368. package/dist/nano-components/p-11a2dcce.js +0 -5
  369. package/dist/nano-components/p-11a2dcce.js.map +0 -1
  370. package/dist/nano-components/p-1a30dfdd.system.entry.js +0 -5
  371. package/dist/nano-components/p-1a30dfdd.system.entry.js.map +0 -1
  372. package/dist/nano-components/p-1b120f53.entry.js +0 -5
  373. package/dist/nano-components/p-1b120f53.entry.js.map +0 -1
  374. package/dist/nano-components/p-21d6d31e.system.entry.js +0 -5
  375. package/dist/nano-components/p-21d6d31e.system.entry.js.map +0 -1
  376. package/dist/nano-components/p-222d8095.entry.js +0 -5
  377. package/dist/nano-components/p-241d90eb.system.entry.js +0 -5
  378. package/dist/nano-components/p-241d90eb.system.entry.js.map +0 -1
  379. package/dist/nano-components/p-2c8d7273.entry.js +0 -5
  380. package/dist/nano-components/p-2c8d7273.entry.js.map +0 -1
  381. package/dist/nano-components/p-3093915f.entry.js +0 -5
  382. package/dist/nano-components/p-3093915f.entry.js.map +0 -1
  383. package/dist/nano-components/p-3258c568.system.js +0 -5
  384. package/dist/nano-components/p-325c1cad.entry.js +0 -5
  385. package/dist/nano-components/p-325c1cad.entry.js.map +0 -1
  386. package/dist/nano-components/p-32f396c0.system.entry.js +0 -5
  387. package/dist/nano-components/p-32f396c0.system.entry.js.map +0 -1
  388. package/dist/nano-components/p-35108e08.entry.js +0 -5
  389. package/dist/nano-components/p-35108e08.entry.js.map +0 -1
  390. package/dist/nano-components/p-3ccb176c.system.entry.js +0 -5
  391. package/dist/nano-components/p-3ccb176c.system.entry.js.map +0 -1
  392. package/dist/nano-components/p-3e930ac7.entry.js.map +0 -1
  393. package/dist/nano-components/p-42cebbfe.system.entry.js +0 -5
  394. package/dist/nano-components/p-42cebbfe.system.entry.js.map +0 -1
  395. package/dist/nano-components/p-4e2c0abb.entry.js.map +0 -1
  396. package/dist/nano-components/p-5d17cfbb.system.entry.js +0 -23
  397. package/dist/nano-components/p-5d17cfbb.system.entry.js.map +0 -1
  398. package/dist/nano-components/p-5d5ea4ab.system.entry.js +0 -5
  399. package/dist/nano-components/p-5d5ea4ab.system.entry.js.map +0 -1
  400. package/dist/nano-components/p-6722447c.entry.js +0 -5
  401. package/dist/nano-components/p-6722447c.entry.js.map +0 -1
  402. package/dist/nano-components/p-6d138abf.entry.js +0 -5
  403. package/dist/nano-components/p-6d138abf.entry.js.map +0 -1
  404. package/dist/nano-components/p-76d9d1d4.entry.js +0 -5
  405. package/dist/nano-components/p-76d9d1d4.entry.js.map +0 -1
  406. package/dist/nano-components/p-866f083f.system.entry.js +0 -5
  407. package/dist/nano-components/p-866f083f.system.entry.js.map +0 -1
  408. package/dist/nano-components/p-86bd5194.entry.js.map +0 -1
  409. package/dist/nano-components/p-88779174.system.entry.js +0 -5
  410. package/dist/nano-components/p-88779174.system.entry.js.map +0 -1
  411. package/dist/nano-components/p-93880c28.system.js.map +0 -1
  412. package/dist/nano-components/p-96d9b8b9.system.entry.js.map +0 -1
  413. package/dist/nano-components/p-97b13ad2.entry.js +0 -5
  414. package/dist/nano-components/p-97b13ad2.entry.js.map +0 -1
  415. package/dist/nano-components/p-b430a9b6.system.js +0 -5
  416. package/dist/nano-components/p-b430a9b6.system.js.map +0 -1
  417. package/dist/nano-components/p-bc394857.system.entry.js +0 -5
  418. package/dist/nano-components/p-bc394857.system.entry.js.map +0 -1
  419. package/dist/nano-components/p-bf9aa89d.system.entry.js.map +0 -1
  420. package/dist/nano-components/p-c3830c43.entry.js +0 -5
  421. package/dist/nano-components/p-c3830c43.entry.js.map +0 -1
  422. package/dist/nano-components/p-d0385948.system.entry.js.map +0 -1
  423. package/dist/nano-components/p-debd9efc.js +0 -5
  424. package/dist/nano-components/p-debd9efc.js.map +0 -1
  425. package/dist/nano-components/p-e195ab77.system.js +0 -5
  426. package/dist/nano-components/p-e195ab77.system.js.map +0 -1
  427. package/dist/nano-components/p-e7140887.system.js +0 -5
  428. package/dist/nano-components/p-e817ab4a.system.entry.js +0 -5
  429. package/dist/nano-components/p-f5d4d13b.system.js +0 -5
  430. package/dist/nano-components/p-f5d4d13b.system.js.map +0 -1
  431. package/dist/nano-components/p-f66958c1.js +0 -5
  432. package/dist/nano-components/p-f66958c1.js.map +0 -1
  433. package/dist/nano-components/p-f710c763.system.entry.js +0 -5
  434. package/dist/nano-components/p-f710c763.system.entry.js.map +0 -1
  435. package/dist/nano-components/p-f780d2f6.system.entry.js.map +0 -1
  436. package/dist/nano-components/p-f9c7d961.js +0 -5
  437. package/dist/nano-components/p-f9c7d961.js.map +0 -1
  438. package/dist/nano-components/p-ffc2063a.entry.js +0 -23
  439. package/dist/nano-components/p-ffc2063a.entry.js.map +0 -1
  440. package/dist/nano-components/p-fff27907.system.entry.js +0 -5
  441. package/dist/nano-components/p-fff27907.system.entry.js.map +0 -1
@@ -194,8 +194,15 @@ let FieldValidator = class {
194
194
  this.nanoSubmit = createEvent(this, "nanoSubmit", 7);
195
195
  this.nanoInvalid = createEvent(this, "nanoInvalid", 7);
196
196
  this.submitted = false;
197
- this.fields = [];
198
- // annoyingly, whenever we attempt to checkValidty it fires `invalid` events.
197
+ this.allFields = [];
198
+ this.nanoFieldSelector = `
199
+ nano-input,
200
+ nano-select,
201
+ nano-file-upload,
202
+ nano-date-input,
203
+ nano-checkbox
204
+ `;
205
+ // annoyingly, whenever we attempt to `checkValidty()` it fires `invalid` events.
199
206
  // this is used to prevent infinite loops / multiple calls
200
207
  this.internalValidate = false;
201
208
  // Public API
@@ -204,39 +211,80 @@ let FieldValidator = class {
204
211
  /** Tries to scroll to the first invalid field on submit */
205
212
  this.scrollToInvalid = true;
206
213
  this._dirty = false;
214
+ /** By default, `nano-field-validator` will also track all native form field elements.
215
+ * You can add extra web-component form fields to listen to
216
+ * (as long as they match the standard form field spec) by using the `fieldSelector` prop.
217
+ */
218
+ this.extraFieldSelector = 'input, select, textarea';
207
219
  // Event handlers
208
- /** Fired whenever store values change and potentially checks validity */
209
- this.handleStoreChange = async (_key, _newVal) => {
220
+ /**
221
+ * Fired whenever store values change and potentially checks validity
222
+ * @param key - the key of the store that's just changed
223
+ * @param newVal - the incoming, new value
224
+ */
225
+ this.handleStoreChange = async (key, newVal) => {
226
+ const found = this.allFields.find((field) => field.name === key);
227
+ // field update has come programmatically (not from ui),
228
+ // so let's update the underlying ui field
229
+ if ((found &&
230
+ found.tagName === 'NANO-FILE-UPLOAD' &&
231
+ !this.fileStateEqual(key, found)) ||
232
+ (found.tagName !== 'NANO-FILE-UPLOAD' && found.value !== newVal)) {
233
+ this.storeToFields([found]);
234
+ }
210
235
  if (this.validateOn === 'dirty' && this.dirty) {
211
236
  this.internalValidate = true;
212
237
  await this.validateAllFields();
213
238
  this._valid = this.activeForm.checkValidity();
214
239
  this.internalValidate = false;
215
240
  }
216
- this.nanoPayloadChange.emit(this.store.state);
241
+ this.nanoPayloadChange.emit(this._store.state);
217
242
  };
218
- /** Handles field value changes and passes to store */
243
+ /**
244
+ * Handles nano field value changes and passes to store
245
+ * @param ev - the incoming change event
246
+ */
219
247
  this.handleFieldChange = (ev) => {
248
+ if (!this.nanoFields.includes(ev.target))
249
+ return;
220
250
  this._dirty = true;
221
- this.setFieldValue([ev.target]);
251
+ this.fieldsToStore([ev.target]);
222
252
  };
223
- /** Handles default field validation events */
253
+ /**
254
+ * Handles non-nano field value changes and passes to store
255
+ * @param ev - the incoming change event
256
+ */
257
+ this.handlePlainFieldChange = (ev) => {
258
+ if (!this.plainFields.includes(ev.target))
259
+ return;
260
+ this.fieldsToStore([ev.target]);
261
+ };
262
+ /**
263
+ * Handles default field validation events
264
+ * @param ev - the invalid event
265
+ */
224
266
  this.handleFormInvalid = async (ev) => {
225
- ev.preventDefault();
267
+ // if it's a non-nano field, we'll let default html5 validation do it's thing
268
+ if (!this.plainFields.includes(ev.target)) {
269
+ ev.preventDefault();
270
+ }
226
271
  this._valid = false;
272
+ // whenever `checkValidity` is called, this handler is in-turn called.
273
+ // this flag is used to stop infinite loops
227
274
  if (this.internalValidate)
228
275
  return;
276
+ // a submit must have happened to if 'submitThenDirty' turn on 'dirty' checking now
229
277
  if (this.validateOn === 'submitThenDirty')
230
278
  this.validateOn = 'dirty';
231
279
  this.submitted = true;
232
280
  await this.validateAllFields();
281
+ this.internalValidate = true;
282
+ this._valid = this.activeForm.checkValidity();
283
+ this.internalValidate = false;
233
284
  // kinda insane...but if we're only validating on submit, then if the form is currently
234
285
  // in an invalid state, when submitting, it will fire an invalid event and not
235
286
  // submit the form. So let's test to make sure it is really invalid, and submit if not
236
287
  if (this.validateOn === 'submit') {
237
- this.internalValidate = true;
238
- this._valid = this.activeForm.checkValidity();
239
- this.internalValidate = false;
240
288
  if (this._valid) {
241
289
  this.submitForm();
242
290
  return;
@@ -245,7 +293,10 @@ let FieldValidator = class {
245
293
  this.scrollToFirstInvalid();
246
294
  this.nanoInvalid.emit();
247
295
  };
248
- /** stops default form submission, checks if valid, then submits manually */
296
+ /**
297
+ * stops default form submission, checks if valid, then submits manually
298
+ * @param e - a submit event from the nested form element
299
+ */
249
300
  this.handleSubmit = async (e) => {
250
301
  e.preventDefault();
251
302
  if (this.validateOn === 'submitThenDirty')
@@ -270,15 +321,18 @@ let FieldValidator = class {
270
321
  return this._activeForm;
271
322
  }
272
323
  set activeForm(form) {
273
- if (this._activeForm)
324
+ // manages event listners on whatever form is used (slotted on created here)
325
+ if (!form)
326
+ return;
327
+ if (this._activeForm) {
274
328
  this._activeForm.removeEventListener('invalid', this.handleFormInvalid, true);
275
- if (form)
276
- form.addEventListener('invalid', this.handleFormInvalid, true);
329
+ }
330
+ form.addEventListener('invalid', this.handleFormInvalid, true);
277
331
  this._activeForm = form;
278
332
  }
279
333
  /** Sync up validateOn with all fields */
280
334
  validateOnChange() {
281
- this.fields.forEach((field) => {
335
+ this.nanoFields.forEach((field) => {
282
336
  if (field.tagName === 'NANO-CHECKBOX') {
283
337
  const cbg = field.closest('nano-checkbox-group');
284
338
  if (cbg)
@@ -298,11 +352,15 @@ let FieldValidator = class {
298
352
  get valid() {
299
353
  return this._valid;
300
354
  }
301
- /** The current form payload as a reactive store. @readonly */
355
+ /** The current form state as a stencil store. */
356
+ get store() {
357
+ return this._store;
358
+ }
359
+ /** The current form payload as a reactive proxy. @readonly */
302
360
  get payload() {
303
- return this.store.state;
361
+ return this._store.state;
304
362
  }
305
- /** Returns true if validation errors will be displayed to the user */
363
+ /** Returns true if validation errors will be displayed to the user. @readonly */
306
364
  get showValidation() {
307
365
  return (this.validateOn === 'dirty' && this.dirty) || this.submitted;
308
366
  }
@@ -319,37 +377,94 @@ let FieldValidator = class {
319
377
  ```
320
378
  */
321
379
  get validationState() {
380
+ // TODO - migrate nano-fields away from using proprietary methods in a bid to be closer to the spec
381
+ // this is big and ugly.
382
+ // why? Cos' it must unify checking validity state for both
383
+ // `nano-...` and plain form fields.
322
384
  const validationState = [];
323
- this.fields.forEach(async (field) => {
385
+ this.allFields.forEach(async (field) => {
324
386
  const found = validationState.find((v) => v.name === field.name);
387
+ let pf;
388
+ let nf;
325
389
  if (found) {
326
- found.validityMessage = field.validityMessage.length
327
- ? field.validityMessage
328
- : found.validityMessage;
390
+ if (field.validationMessage) {
391
+ pf = field;
392
+ found.validityMessage = pf.validationMessage.length
393
+ ? pf.validationMessage
394
+ : found.validityMessage;
395
+ this.internalValidate = true;
396
+ if (found.valid && !pf.checkValidity())
397
+ found.valid = false;
398
+ this.internalValidate = false;
399
+ }
400
+ else if (field.validityMessage) {
401
+ nf = field;
402
+ found.validityMessage = nf.validityMessage.length
403
+ ? nf.validityMessage
404
+ : nf.validityMessage;
405
+ if (found.valid && nf.invalid)
406
+ found.valid = false;
407
+ }
329
408
  if (!found.fields.find((f) => f === field))
330
409
  found.fields.push(field);
331
- if (found.valid && field.invalid)
332
- found.valid = false;
333
- return;
410
+ }
411
+ let valid;
412
+ let validityMessage;
413
+ if (field.checkValidity) {
414
+ pf = field;
415
+ this.internalValidate = true;
416
+ valid = pf.checkValidity();
417
+ this.internalValidate = false;
418
+ validityMessage = pf.validationMessage;
419
+ }
420
+ else {
421
+ nf = field;
422
+ valid = !nf.invalid;
423
+ validityMessage = nf.validityMessage;
334
424
  }
335
425
  validationState.push({
336
426
  fields: [field],
337
427
  name: field.name,
338
- valid: !field.invalid,
339
- value: this.store.state[field.name],
428
+ value: this._store.state[field.name],
340
429
  dirty: false,
341
- validityMessage: field.validityMessage,
430
+ valid,
431
+ validityMessage,
342
432
  });
343
433
  });
344
434
  return validationState;
345
435
  }
436
+ /**
437
+ * Sets the state of the form using an object of key / value pairs.
438
+ * @param state - the state to load in the store
439
+ */
440
+ async setStore(state) {
441
+ Object.entries(state).forEach(([key, val]) => (this.store.state[key] = val));
442
+ }
443
+ /**
444
+ * Sets custom validity for all / some form fields.
445
+ * @param validity - a validity object of `{fieldName: errorString}` pairs. Set as an empty string to clear the error.
446
+ */
447
+ async setCustomValidity(validity) {
448
+ return await Promise.all(Object.entries(validity).map(async ([key, err]) => {
449
+ const field = this.allFields.find((f) => f.name === key);
450
+ if (!!field)
451
+ await this.setFieldError(field, err);
452
+ }));
453
+ }
454
+ /**
455
+ * Clear all custom validation.
456
+ * @param validity
457
+ */
458
+ async resetValidity() {
459
+ return await Promise.all(this.allFields.map(async (field) => await this.setFieldError(field, '')));
460
+ }
346
461
  // private methods
347
462
  attachSlotObserver() {
348
463
  if (!!this.mo)
349
464
  return;
350
465
  const mo = (this.mo = new MutationObserver((_entries) => {
351
466
  const form = this.host.querySelector('form');
352
- if (form !== this.activeForm)
467
+ if (form && form !== this.activeForm)
353
468
  this.activeForm = form;
354
469
  this.setupFields();
355
470
  }));
@@ -362,95 +477,177 @@ let FieldValidator = class {
362
477
  }
363
478
  /** Checks for new `nano-...` fields and adds them to our watch array and value store */
364
479
  setupFields() {
365
- let fields = Array.from(this.host.querySelectorAll(`
366
- nano-input,
367
- nano-select,
368
- nano-file-upload,
369
- nano-date-input,
370
- nano-checkbox
371
- `));
372
- fields = fields.filter((f) => !!f.name && !!f.name.length);
480
+ let nanoFields = Array.from(this.host.querySelectorAll(this.nanoFieldSelector));
481
+ let plainFields = Array.from(this.host.querySelectorAll(this.extraFieldSelector)).filter((e) => !e.closest(this.nanoFieldSelector));
482
+ nanoFields = nanoFields.filter((f) => !!f.name && !!f.name.length);
483
+ plainFields = plainFields.filter((f) => !!f.name && !!f.name.length);
373
484
  // do we have any currently un-watched fields?
374
- if (!fields.filter((f) => !this.fields.includes(f)).length)
485
+ if (![...nanoFields, ...plainFields].filter((f) => !this.allFields.includes(f)).length)
375
486
  return;
376
487
  // setup the initial store state / refresh on new fields
377
- this.fields = fields;
488
+ this.nanoFields = nanoFields;
489
+ this.plainFields = plainFields;
490
+ this.allFields = [...nanoFields, ...plainFields];
491
+ this.storeToFields(this.allFields);
378
492
  this.validateOnChange();
379
- this.setFieldValue(this.fields);
380
- this.nanoPayloadChange.emit(this.store.state);
493
+ this.fieldsToStore(this.allFields);
494
+ this.nanoPayloadChange.emit(this._store.state);
495
+ }
496
+ storeToFields(fields) {
497
+ fields.forEach((field) => {
498
+ var _a;
499
+ const fieldName = field.name;
500
+ if (!fieldName.length ||
501
+ typeof this._store.state[fieldName] === 'undefined')
502
+ return;
503
+ if (field.tagName === 'NANO-CHECKBOX' ||
504
+ ['radio', 'checkbox'].includes(field.type)) {
505
+ let cb = field;
506
+ if (cb.type === 'radio' ||
507
+ cb.type === 'segment' ||
508
+ cb.type === 'segment-pill') {
509
+ // single radio type control
510
+ if (this._store.state[fieldName] === cb.value)
511
+ cb.checked = true;
512
+ else
513
+ cb.checked = false;
514
+ }
515
+ else if (Array.isArray(this._store.state[fieldName])) {
516
+ // multiple checkbox like controls
517
+ if (this._store.state[fieldName].includes(cb.value))
518
+ cb.checked = true;
519
+ else
520
+ cb.checked = false;
521
+ }
522
+ else {
523
+ // single checkbox like control
524
+ if (this._store.state[fieldName] === cb.value)
525
+ cb.checked = true;
526
+ else
527
+ cb.checked = false;
528
+ }
529
+ return;
530
+ }
531
+ if (field.tagName === 'NANO-FILE-UPLOAD') {
532
+ const ff = field;
533
+ // this can only work if the field is empty rn... a one-time deal
534
+ if (!((_a = ff.files) === null || _a === void 0 ? void 0 : _a.length))
535
+ ff.files = this._store.state[fieldName];
536
+ return;
537
+ }
538
+ // default
539
+ field.value = this._store.state[fieldName];
540
+ });
381
541
  }
382
542
  /** Loops through all `nano-...` fields and extracts their values into our store */
383
- setFieldValue(fields) {
543
+ fieldsToStore(fields) {
384
544
  fields.forEach((field) => {
385
545
  const fieldName = field.name;
386
546
  if (!fieldName.length)
387
547
  return;
388
- switch (field.tagName) {
389
- case 'NANO-CHECKBOX':
390
- let cb = field;
391
- if (cb.type === 'radio' ||
392
- cb.type === 'segment' ||
393
- cb.type === 'segment-pill') {
394
- if (cb.checked)
395
- this.store.state[fieldName] = cb.value;
396
- else if (!cb.checked &&
397
- (cb.value === this.store.state[fieldName] ||
398
- !this.store.state[fieldName]))
399
- this.store.state[fieldName] = '';
400
- }
401
- else if (this.fields.filter((f) => f.name === fieldName && f.tagName === 'NANO-CHECKBOX').length > 1) {
402
- const currentArr = Array.isArray(this.store.state[fieldName])
403
- ? this.store.state[fieldName]
404
- : [];
405
- if (cb.checked) {
406
- if (!this.store.state[fieldName].includes(cb.value)) {
407
- this.store.state[fieldName] = [...currentArr, cb.value];
408
- }
409
- }
410
- else {
411
- this.store.state[fieldName] = currentArr.filter((v) => v !== cb.value);
548
+ if (field.tagName === 'NANO-CHECKBOX' ||
549
+ ['radio', 'checkbox'].includes(field.type)) {
550
+ let cb = field;
551
+ if (cb.type === 'radio' ||
552
+ cb.type === 'segment' ||
553
+ cb.type === 'segment-pill') {
554
+ // radio type control - only one can be checked
555
+ if (cb.checked)
556
+ this._store.state[fieldName] = cb.value;
557
+ }
558
+ else if (this.allFields.filter((f) => f.name === fieldName &&
559
+ (f.tagName === 'NANO-CHECKBOX' ||
560
+ f.type === 'checkbox')).length > 1) {
561
+ // multiple checkbox type control
562
+ const currentArr = Array.isArray(this._store.state[fieldName])
563
+ ? this._store.state[fieldName]
564
+ : [];
565
+ if (cb.checked) {
566
+ // checked
567
+ if (!this._store.state[fieldName].includes(cb.value)) {
568
+ this._store.state[fieldName] = [...currentArr, cb.value];
412
569
  }
413
570
  }
571
+ else {
572
+ // unchecked
573
+ this._store.state[fieldName] = currentArr.filter((v) => v !== cb.value);
574
+ }
575
+ }
576
+ else {
577
+ // single checkbox - on or off
578
+ if (cb.checked)
579
+ this._store.state[fieldName] = cb.value;
414
580
  else
415
- this.store.state[fieldName] = cb.value;
416
- break;
417
- case 'NANO-FILE-UPLOAD':
418
- this.store.state[fieldName] = field.files;
419
- break;
420
- default:
421
- this.store.state[fieldName] = field.value;
422
- break;
581
+ this._store.state[fieldName] = '';
582
+ }
583
+ return;
584
+ }
585
+ if (field.tagName === 'NANO-FILE-UPLOAD') {
586
+ const ff = field;
587
+ if (!this.fileStateEqual(fieldName, ff))
588
+ this._store.state[fieldName] = ff.files;
589
+ return;
423
590
  }
591
+ // default
592
+ this._store.state[fieldName] = field.value;
424
593
  });
425
594
  }
426
- /** Checks for user defined validations */
595
+ /**
596
+ * Tries to ascertain whether the current model
597
+ * value is the same as the `nano-file-upload` value
598
+ * @param fieldName - the key to access from the data store
599
+ * @param field - the nano-file-upload field to assess against
600
+ * @returns true for equal, false for not equal
601
+ */
602
+ fileStateEqual(fieldName, field) {
603
+ return (JSON.stringify(this._store.state[fieldName]) ===
604
+ JSON.stringify(field.files) ||
605
+ this._store.state[fieldName] == field.files);
606
+ }
607
+ /**
608
+ * Checks for user defined validations
609
+ * @param key - current key of the data model to validate
610
+ * @param newVal - the newly set, incoming value to validate
611
+ */
427
612
  async validate(key, newVal) {
428
613
  if (!this.validation)
429
614
  return;
430
- const res = this.validation(key, newVal, this.store.state);
615
+ const res = this.validation(key, newVal, this._store.state);
431
616
  // no nothing - return
432
617
  if (!res)
433
618
  return;
434
619
  // stencil public methods are async
435
- // so we must to coerce our validation
620
+ // so we must coerce our validation
436
621
  // collection loop into a promise
437
622
  await Promise.all(Object.entries(res).map(async ([key, o]) => {
438
623
  // switch on/off validation messages
439
- const field = this.fields.find((f) => f.name === key);
624
+ const field = this.allFields.find((f) => f.name === key);
440
625
  let validityTarget = field;
441
626
  if (field.tagName === 'NANO-CHECKBOX') {
627
+ // if we have a checkbox-group, set the validation message there
442
628
  const cbg = field.closest('nano-checkbox-group');
443
629
  validityTarget = cbg || field;
444
630
  }
445
- // status is now valid - clear the error
446
- if (validityTarget.validityMessage === o.msg && o.valid)
631
+ if ((validityTarget.validityMessage ||
632
+ validityTarget.validationMessage) === o.msg &&
633
+ o.valid) {
634
+ // status is now valid - clear the error
447
635
  await this.setFieldError(validityTarget, '');
448
- // status is invalid. Set the error
636
+ }
449
637
  else if (!o.valid) {
638
+ // status is invalid. Set the error
450
639
  await this.setFieldError(validityTarget, o.msg);
451
640
  }
452
641
  }));
453
642
  }
643
+ /** Loops through all store entries and checks custom validation */
644
+ async validateAllFields() {
645
+ // This forces our loop to `await` and finish sequentially ... silly async stencil methods
646
+ await Object.entries(this._store.state).reduce(async (memo, [key, value]) => {
647
+ await memo;
648
+ await this.validate(key, value);
649
+ }, undefined);
650
+ }
454
651
  /**
455
652
  * Utility to smooth out setting error messages
456
653
  * (it's a different method on `nano-checkbox` 'cos they don't show errors themselves)
@@ -460,16 +657,10 @@ let FieldValidator = class {
460
657
  async setFieldError(field, msg) {
461
658
  if (field['showError'])
462
659
  await field.showError(msg);
463
- else
660
+ else if (field['setError'])
464
661
  await field.setError(msg);
465
- }
466
- /** Loops through all store entries and checks field validity */
467
- async validateAllFields() {
468
- // This forces our loop to `await` and finish sequentially ... silly async stencil methods
469
- await Object.entries(this.store.state).reduce(async (memo, [key, value]) => {
470
- await memo;
471
- await this.validate(key, value);
472
- }, undefined);
662
+ else
663
+ field.setCustomValidity(msg);
473
664
  }
474
665
  scrollToFirstInvalid() {
475
666
  if (!this.scrollToInvalid)
@@ -492,23 +683,27 @@ let FieldValidator = class {
492
683
  }
493
684
  connectedCallback() {
494
685
  this.userForm = this.host.querySelector('form');
686
+ this._store = createStore({});
495
687
  }
496
688
  componentDidLoad() {
497
689
  requestAnimationFrame(() => {
498
- this.store = createStore({});
499
690
  this.setupFields();
500
691
  this.attachSlotObserver();
501
- this.store.on('set', (key, value) => this.handleStoreChange(key, value));
502
692
  this.host.addEventListener('nanoChange', this.handleFieldChange);
693
+ this.host.addEventListener('input', this.handlePlainFieldChange);
694
+ this.host.addEventListener('change', this.handlePlainFieldChange);
503
695
  this.host.addEventListener('submit', this.handleSubmit);
696
+ this._store.on('set', this.handleStoreChange);
504
697
  });
505
698
  }
506
699
  disconnectedCallback() {
507
700
  if (this.mo)
508
701
  this.mo.disconnect();
509
- this.store.dispose();
510
702
  this.host.removeEventListener('nanoChange', this.handleFieldChange);
703
+ this.host.removeEventListener('input', this.handlePlainFieldChange);
704
+ this.host.removeEventListener('change', this.handlePlainFieldChange);
511
705
  this.host.removeEventListener('submit', this.handleSubmit);
706
+ this._store.reset();
512
707
  if (this.activeForm)
513
708
  this.activeForm.removeEventListener('invalid', this.handleFormInvalid, true);
514
709
  }
@@ -518,7 +713,8 @@ let FieldValidator = class {
518
713
  get host() { return getElement(this); }
519
714
  static get watchers() { return {
520
715
  "userForm": ["userFormChange"],
521
- "validateOn": ["validateOnChange"]
716
+ "validateOn": ["validateOnChange"],
717
+ "extraFieldSelector": ["attachSlotObserver"]
522
718
  }; }
523
719
  };
524
720