@3t-transform/threeteeui 1.9.101 → 1.9.103

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 (418) hide show
  1. package/dist/cjs/{auto-be8ad100.js → auto-356ad09b.js} +177 -177
  2. package/dist/cjs/{domsanitiser.options-55ce2d65.js → domsanitiser.options-065dbed8.js} +12 -12
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{tttx-action-dropdown_1_9_101.cjs.entry.js → tttx-action-dropdown_1_9_103.cjs.entry.js} +51 -51
  5. package/dist/cjs/{tttx-button-v2_1_9_101.cjs.entry.js → tttx-button-v2_1_9_103.cjs.entry.js} +147 -147
  6. package/dist/cjs/{tttx-button_1_9_101.cjs.entry.js → tttx-button_1_9_103.cjs.entry.js} +26 -26
  7. package/dist/cjs/{tttx-chart_1_9_101.cjs.entry.js → tttx-chart_1_9_103.cjs.entry.js} +524 -524
  8. package/dist/cjs/{tttx-checkbox-group-caption_1_9_101.cjs.entry.js → tttx-checkbox-group-caption_1_9_103.cjs.entry.js} +9 -9
  9. package/dist/cjs/{tttx-checkbox-group-heading_1_9_101.cjs.entry.js → tttx-checkbox-group-heading_1_9_103.cjs.entry.js} +9 -9
  10. package/dist/cjs/{tttx-checkbox-group_1_9_101.cjs.entry.js → tttx-checkbox-group_1_9_103.cjs.entry.js} +9 -9
  11. package/dist/cjs/{tttx-checkbox_1_9_101.cjs.entry.js → tttx-checkbox_1_9_103.cjs.entry.js} +33 -33
  12. package/dist/cjs/{tttx-comments_1_9_101.cjs.entry.js → tttx-comments_1_9_103.cjs.entry.js} +204 -204
  13. package/dist/cjs/{tttx-data-pattern_1_9_101.cjs.entry.js → tttx-data-pattern_1_9_103.cjs.entry.js} +20 -20
  14. package/dist/cjs/{tttx-datacard_1_9_101.cjs.entry.js → tttx-datacard_1_9_103.cjs.entry.js} +43 -43
  15. package/dist/cjs/tttx-date-range-picker.cjs.entry.js +212 -212
  16. package/dist/cjs/{tttx-dialog-box_1_9_101.cjs.entry.js → tttx-dialog-box_1_9_103.cjs.entry.js} +94 -94
  17. package/dist/cjs/{tttx-dialog_1_9_101.cjs.entry.js → tttx-dialog_1_9_103.cjs.entry.js} +69 -69
  18. package/dist/cjs/{tttx-expander_1_9_101.cjs.entry.js → tttx-expander_1_9_103.cjs.entry.js} +28 -28
  19. package/dist/cjs/{tttx-filter_1_9_101_4.cjs.entry.js → tttx-filter_1_9_103_4.cjs.entry.js} +386 -386
  20. package/dist/cjs/{tttx-form_1_9_101.cjs.entry.js → tttx-form_1_9_103.cjs.entry.js} +985 -985
  21. package/dist/cjs/{tttx-graph_1_9_101.cjs.entry.js → tttx-graph_1_9_103.cjs.entry.js} +124 -124
  22. package/dist/cjs/{tttx-icon_1_9_101.cjs.entry.js → tttx-icon_1_9_103.cjs.entry.js} +24 -24
  23. package/dist/cjs/{tttx-keyvalue-block_1_9_101.cjs.entry.js → tttx-keyvalue-block_1_9_103.cjs.entry.js} +62 -62
  24. package/dist/cjs/{tttx-loading-spinner_1_9_101_3.cjs.entry.js → tttx-loading-spinner_1_9_103_3.cjs.entry.js} +172 -172
  25. package/dist/cjs/{tttx-multiselect-box_1_9_101.cjs.entry.js → tttx-multiselect-box_1_9_103.cjs.entry.js} +175 -175
  26. package/dist/cjs/{tttx-percentage-bar_1_9_101.cjs.entry.js → tttx-percentage-bar_1_9_103.cjs.entry.js} +56 -56
  27. package/dist/cjs/{tttx-qrcode_1_9_101.cjs.entry.js → tttx-qrcode_1_9_103.cjs.entry.js} +28 -28
  28. package/dist/cjs/{tttx-range-slider_1_9_101.cjs.entry.js → tttx-range-slider_1_9_103.cjs.entry.js} +185 -185
  29. package/dist/cjs/{tttx-select-box_1_9_101.cjs.entry.js → tttx-select-box_1_9_103.cjs.entry.js} +239 -239
  30. package/dist/cjs/{tttx-skeleton_loader_1_9_101.cjs.entry.js → tttx-skeleton_loader_1_9_103.cjs.entry.js} +30 -30
  31. package/dist/cjs/{tttx-table_1_9_101.cjs.entry.js → tttx-table_1_9_103.cjs.entry.js} +72 -72
  32. package/dist/cjs/{tttx-tabs_1_9_101.cjs.entry.js → tttx-tabs_1_9_103.cjs.entry.js} +103 -103
  33. package/dist/cjs/{tttx-tag-v2_1_9_101.cjs.entry.js → tttx-tag-v2_1_9_103.cjs.entry.js} +72 -72
  34. package/dist/cjs/{tttx-textarea_1_9_101.cjs.entry.js → tttx-textarea_1_9_103.cjs.entry.js} +50 -50
  35. package/dist/cjs/{tttx-toggle_1_9_101.cjs.entry.js → tttx-toggle_1_9_103.cjs.entry.js} +30 -30
  36. package/dist/cjs/{tttx-tooltip_1_9_101.cjs.entry.js → tttx-tooltip_1_9_103.cjs.entry.js} +87 -87
  37. package/dist/cjs/{tttx-tree-view_1_9_101.cjs.entry.js → tttx-tree-view_1_9_103.cjs.entry.js} +342 -342
  38. package/dist/cjs/tttx.cjs.js +1 -1
  39. package/dist/collection/components/atoms/tttx-button/tttx-button.js +129 -129
  40. package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +40 -40
  41. package/dist/collection/components/atoms/tttx-button-v2/tttx-button-v2.css +1 -1
  42. package/dist/collection/components/atoms/tttx-button-v2/tttx-button-v2.js +436 -436
  43. package/dist/collection/components/atoms/tttx-button-v2/tttx-button-v2.stories.js +143 -143
  44. package/dist/collection/components/atoms/tttx-checkbox/tttx-checkbox.js +154 -154
  45. package/dist/collection/components/atoms/tttx-checkbox/tttx-checkbox.stories.js +58 -58
  46. package/dist/collection/components/atoms/tttx-datacard/tttx-datacard.js +186 -186
  47. package/dist/collection/components/atoms/tttx-datacard/tttx-datacard.stories.js +92 -92
  48. package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +92 -92
  49. package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +26 -26
  50. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +137 -137
  51. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +94 -94
  52. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +194 -194
  53. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +53 -53
  54. package/dist/collection/components/atoms/tttx-percentage-bar/tttx-percentage-bar.js +168 -168
  55. package/dist/collection/components/atoms/tttx-percentage-bar/tttx-percentage-bar.stories.js +52 -52
  56. package/dist/collection/components/atoms/tttx-qrcode/tttx-qrcode.js +81 -81
  57. package/dist/collection/components/atoms/tttx-qrcode/tttx-qrcode.stories.js +22 -22
  58. package/dist/collection/components/atoms/tttx-skeleton-loader/tttx-skeleton-loader.js +225 -225
  59. package/dist/collection/components/atoms/tttx-skeleton-loader/tttx-skeleton-loader.stories.js +44 -44
  60. package/dist/collection/components/atoms/tttx-tag/tttx-tag.js +157 -157
  61. package/dist/collection/components/atoms/tttx-tag/tttx-tag.stories.js +53 -53
  62. package/dist/collection/components/atoms/tttx-tag-v2/tttx-tag-v2.js +281 -281
  63. package/dist/collection/components/atoms/tttx-tag-v2/tttx-tag-v2.stories.js +84 -84
  64. package/dist/collection/components/atoms/tttx-toggle/tttx-toggle.js +84 -84
  65. package/dist/collection/components/atoms/tttx-toggle/tttx-toggle.stories.js +8 -8
  66. package/dist/collection/components/domsanitiser.options.js +14 -14
  67. package/dist/collection/components/molecules/tttx-action-dropdown/tttx-action-dropdown.js +213 -213
  68. package/dist/collection/components/molecules/tttx-action-dropdown/tttx-action-dropdown.stories.js +55 -55
  69. package/dist/collection/components/molecules/tttx-chart/tttx-chart.js +793 -793
  70. package/dist/collection/components/molecules/tttx-chart/tttx-chart.stories.js +209 -209
  71. package/dist/collection/components/molecules/tttx-checkbox-group/components/tttx-checkbox-group-caption.js +17 -17
  72. package/dist/collection/components/molecules/tttx-checkbox-group/components/tttx-checkbox-group-heading.js +17 -17
  73. package/dist/collection/components/molecules/tttx-checkbox-group/tttx-checkbox-group.js +18 -18
  74. package/dist/collection/components/molecules/tttx-checkbox-group/tttx-checkbox-group.stories.js +62 -62
  75. package/dist/collection/components/molecules/tttx-comments/tttx-comments.js +536 -536
  76. package/dist/collection/components/molecules/tttx-comments/tttx-comments.stories.js +151 -151
  77. package/dist/collection/components/molecules/tttx-date-range-picker/tttx-date-range-picker.js +292 -292
  78. package/dist/collection/components/molecules/tttx-date-range-picker/tttx-date-range-picker.stories.js +48 -48
  79. package/dist/collection/components/molecules/tttx-dialog/icon-types.js +6 -6
  80. package/dist/collection/components/molecules/tttx-dialog/tttx-dialog.js +218 -218
  81. package/dist/collection/components/molecules/tttx-dialog/tttx-dialog.stories.js +50 -50
  82. package/dist/collection/components/molecules/tttx-dialog-box/tttx-dialog-box.js +246 -246
  83. package/dist/collection/components/molecules/tttx-dialog-box/tttx-dialog-box.stories.js +314 -314
  84. package/dist/collection/components/molecules/tttx-expander/tttx-expander.js +134 -134
  85. package/dist/collection/components/molecules/tttx-expander/tttx-expander.stories.js +46 -46
  86. package/dist/collection/components/molecules/tttx-filter/tttx-filter.js +416 -416
  87. package/dist/collection/components/molecules/tttx-filter/tttx-filter.stories.js +81 -81
  88. package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +49 -49
  89. package/dist/collection/components/molecules/tttx-form/lib/timecomparatorChecks.js +64 -64
  90. package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +76 -76
  91. package/dist/collection/components/molecules/tttx-form/tttx-form.js +1267 -1267
  92. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +595 -595
  93. package/dist/collection/components/molecules/tttx-graph/gauge-label-plugin.js +14 -14
  94. package/dist/collection/components/molecules/tttx-graph/tttx-graph.js +184 -184
  95. package/dist/collection/components/molecules/tttx-graph/tttx-graph.stories.js +32 -32
  96. package/dist/collection/components/molecules/tttx-list/tttx-list.js +165 -165
  97. package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +134 -134
  98. package/dist/collection/components/molecules/tttx-multiselect-box/tttx-multiselect-box.js +499 -499
  99. package/dist/collection/components/molecules/tttx-multiselect-box/tttx-multiselect-box.stories.js +151 -151
  100. package/dist/collection/components/molecules/tttx-range-slider/tttx-range-slider.js +304 -304
  101. package/dist/collection/components/molecules/tttx-range-slider/tttx-range-slider.stories.js +22 -22
  102. package/dist/collection/components/molecules/tttx-select-box/tttx-select-box.js +671 -671
  103. package/dist/collection/components/molecules/tttx-select-box/tttx-select-box.stories.js +140 -140
  104. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.js +253 -253
  105. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.stories.js +43 -43
  106. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +764 -764
  107. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +191 -191
  108. package/dist/collection/components/molecules/tttx-table/tttx-table.css +1 -1
  109. package/dist/collection/components/molecules/tttx-table/tttx-table.js +318 -318
  110. package/dist/collection/components/molecules/tttx-table/tttx-table.stories.js +191 -191
  111. package/dist/collection/components/molecules/tttx-table/tttx-table.types.js +1 -1
  112. package/dist/collection/components/molecules/tttx-tabs/tttx-tabs.js +253 -253
  113. package/dist/collection/components/molecules/tttx-tabs/tttx-tabs.stories.js +82 -82
  114. package/dist/collection/components/molecules/tttx-textarea/tttx-textarea.js +420 -420
  115. package/dist/collection/components/molecules/tttx-textarea/tttx-textarea.stories.js +81 -81
  116. package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.js +73 -73
  117. package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.stories.js +97 -97
  118. package/dist/collection/components/molecules/tttx-tooltip/tttx-tooltip.js +253 -253
  119. package/dist/collection/components/molecules/tttx-tooltip/tttx-tootip.stories.js +117 -117
  120. package/dist/collection/components/molecules/tttx-tree-view/helper/helper.js +1 -1
  121. package/dist/collection/components/molecules/tttx-tree-view/tttx-tree-view.css +1 -1
  122. package/dist/collection/components/molecules/tttx-tree-view/tttx-tree-view.js +463 -463
  123. package/dist/collection/components/molecules/tttx-tree-view/tttx-tree-view.stories.js +402 -402
  124. package/dist/collection/components/organisms/tttx-data-pattern/tttx-data-pattern.js +176 -176
  125. package/dist/collection/components/organisms/tttx-data-pattern/tttx-data-pattern.stories.js +28 -28
  126. package/dist/collection/components/palette.stories.js +7 -7
  127. package/dist/collection/icons.js +2838 -2838
  128. package/dist/collection/index.js +1 -1
  129. package/dist/collection/shared/domsanitiser.options.js +14 -14
  130. package/dist/components/auto.js +177 -177
  131. package/dist/components/domsanitiser.options.js +12 -12
  132. package/dist/components/index.d.ts +38 -38
  133. package/dist/components/index.js +38 -38
  134. package/dist/components/tttx-action-dropdown_1_9_103.d.ts +11 -0
  135. package/dist/components/{tttx-action-dropdown_1_9_101.js → tttx-action-dropdown_1_9_103.js} +81 -81
  136. package/dist/components/tttx-button-v2.js +182 -182
  137. package/dist/components/tttx-button-v2_1_9_103.d.ts +11 -0
  138. package/dist/components/{tttx-button-v2_1_9_101.js → tttx-button-v2_1_9_103.js} +2 -2
  139. package/dist/components/tttx-button.js +51 -51
  140. package/dist/components/{tttx-dialog_1_9_101.d.ts → tttx-button_1_9_103.d.ts} +4 -4
  141. package/dist/components/{tttx-button_1_9_101.js → tttx-button_1_9_103.js} +2 -2
  142. package/dist/components/{tttx-table_1_9_101.d.ts → tttx-chart_1_9_103.d.ts} +4 -4
  143. package/dist/components/{tttx-chart_1_9_101.js → tttx-chart_1_9_103.js} +574 -574
  144. package/dist/components/tttx-checkbox-group-caption_1_9_103.d.ts +11 -0
  145. package/dist/components/{tttx-checkbox-group-caption_1_9_101.js → tttx-checkbox-group-caption_1_9_103.js} +24 -24
  146. package/dist/components/tttx-checkbox-group-heading_1_9_103.d.ts +11 -0
  147. package/dist/components/{tttx-checkbox-group-heading_1_9_101.js → tttx-checkbox-group-heading_1_9_103.js} +24 -24
  148. package/dist/components/tttx-checkbox-group_1_9_103.d.ts +11 -0
  149. package/dist/components/{tttx-checkbox-group_1_9_101.js → tttx-checkbox-group_1_9_103.js} +25 -25
  150. package/dist/components/tttx-checkbox_1_9_103.d.ts +11 -0
  151. package/dist/components/{tttx-checkbox_1_9_101.js → tttx-checkbox_1_9_103.js} +59 -59
  152. package/dist/components/tttx-comments_1_9_103.d.ts +11 -0
  153. package/dist/components/{tttx-comments_1_9_101.js → tttx-comments_1_9_103.js} +241 -241
  154. package/dist/components/tttx-data-pattern_1_9_103.d.ts +11 -0
  155. package/dist/components/{tttx-data-pattern_1_9_101.js → tttx-data-pattern_1_9_103.js} +80 -80
  156. package/dist/components/tttx-datacard_1_9_103.d.ts +11 -0
  157. package/dist/components/{tttx-datacard_1_9_101.js → tttx-datacard_1_9_103.js} +79 -79
  158. package/dist/components/tttx-date-range-picker.js +242 -242
  159. package/dist/components/tttx-dialog-box_1_9_103.d.ts +11 -0
  160. package/dist/components/{tttx-dialog-box_1_9_101.js → tttx-dialog-box_1_9_103.js} +125 -125
  161. package/dist/components/{tttx-filter_1_9_101.d.ts → tttx-dialog_1_9_103.d.ts} +4 -4
  162. package/dist/components/{tttx-dialog_1_9_101.js → tttx-dialog_1_9_103.js} +103 -103
  163. package/dist/components/tttx-expander_1_9_103.d.ts +11 -0
  164. package/dist/components/{tttx-expander_1_9_101.js → tttx-expander_1_9_103.js} +55 -55
  165. package/dist/components/tttx-filter.js +217 -217
  166. package/dist/components/{tttx-button_1_9_101.d.ts → tttx-filter_1_9_103.d.ts} +4 -4
  167. package/dist/components/{tttx-filter_1_9_101.js → tttx-filter_1_9_103.js} +2 -2
  168. package/dist/components/{tttx-form_1_9_101.d.ts → tttx-form_1_9_103.d.ts} +4 -4
  169. package/dist/components/{tttx-form_1_9_101.js → tttx-form_1_9_103.js} +1039 -1039
  170. package/dist/components/tttx-graph.js +143 -143
  171. package/dist/components/{tttx-graph_1_9_101.d.ts → tttx-graph_1_9_103.d.ts} +4 -4
  172. package/dist/components/{tttx-graph_1_9_101.js → tttx-graph_1_9_103.js} +2 -2
  173. package/dist/components/tttx-icon.js +42 -42
  174. package/dist/components/{tttx-list_1_9_101.d.ts → tttx-icon_1_9_103.d.ts} +4 -4
  175. package/dist/components/{tttx-icon_1_9_101.js → tttx-icon_1_9_103.js} +2 -2
  176. package/dist/components/tttx-keyvalue-block_1_9_103.d.ts +11 -0
  177. package/dist/components/{tttx-keyvalue-block_1_9_101.js → tttx-keyvalue-block_1_9_103.js} +83 -83
  178. package/dist/components/tttx-list.js +92 -92
  179. package/dist/components/{tttx-tabs_1_9_101.d.ts → tttx-list_1_9_103.d.ts} +4 -4
  180. package/dist/components/{tttx-list_1_9_101.js → tttx-list_1_9_103.js} +2 -2
  181. package/dist/components/tttx-loading-spinner.js +92 -92
  182. package/dist/components/tttx-loading-spinner_1_9_103.d.ts +11 -0
  183. package/dist/components/{tttx-loading-spinner_1_9_101.js → tttx-loading-spinner_1_9_103.js} +2 -2
  184. package/dist/components/tttx-multiselect-box_1_9_103.d.ts +11 -0
  185. package/dist/components/{tttx-multiselect-box_1_9_101.js → tttx-multiselect-box_1_9_103.js} +231 -231
  186. package/dist/components/tttx-percentage-bar_1_9_103.d.ts +11 -0
  187. package/dist/components/{tttx-percentage-bar_1_9_101.js → tttx-percentage-bar_1_9_103.js} +80 -80
  188. package/dist/components/tttx-qrcode_1_9_103.d.ts +11 -0
  189. package/dist/components/{tttx-qrcode_1_9_101.js → tttx-qrcode_1_9_103.js} +47 -47
  190. package/dist/components/tttx-range-slider_1_9_103.d.ts +11 -0
  191. package/dist/components/{tttx-range-slider_1_9_101.js → tttx-range-slider_1_9_103.js} +208 -208
  192. package/dist/components/tttx-select-box.js +295 -295
  193. package/dist/components/tttx-select-box_1_9_103.d.ts +11 -0
  194. package/dist/components/{tttx-select-box_1_9_101.js → tttx-select-box_1_9_103.js} +2 -2
  195. package/dist/components/tttx-skeleton_loader_1_9_103.d.ts +11 -0
  196. package/dist/components/{tttx-skeleton_loader_1_9_101.js → tttx-skeleton_loader_1_9_103.js} +57 -57
  197. package/dist/components/tttx-sorter.js +136 -136
  198. package/dist/components/tttx-sorter_1_9_103.d.ts +11 -0
  199. package/dist/components/{tttx-sorter_1_9_101.js → tttx-sorter_1_9_103.js} +2 -2
  200. package/dist/components/tttx-standalone-input.js +136 -136
  201. package/dist/components/tttx-standalone-input_1_9_103.d.ts +11 -0
  202. package/dist/components/{tttx-standalone-input_1_9_101.js → tttx-standalone-input_1_9_103.js} +2 -2
  203. package/dist/components/{tttx-chart_1_9_101.d.ts → tttx-table_1_9_103.d.ts} +4 -4
  204. package/dist/components/{tttx-table_1_9_101.js → tttx-table_1_9_103.js} +109 -109
  205. package/dist/components/{tttx-icon_1_9_101.d.ts → tttx-tabs_1_9_103.d.ts} +4 -4
  206. package/dist/components/{tttx-tabs_1_9_101.js → tttx-tabs_1_9_103.js} +128 -128
  207. package/dist/components/{tttx-tag-v2_1_9_101.d.ts → tttx-tag-v2_1_9_103.d.ts} +4 -4
  208. package/dist/components/{tttx-tag-v2_1_9_101.js → tttx-tag-v2_1_9_103.js} +105 -105
  209. package/dist/components/tttx-tag.js +44 -44
  210. package/dist/components/{tttx-tag_1_9_101.d.ts → tttx-tag_1_9_103.d.ts} +4 -4
  211. package/dist/components/{tttx-tag_1_9_101.js → tttx-tag_1_9_103.js} +2 -2
  212. package/dist/components/tttx-textarea_1_9_103.d.ts +11 -0
  213. package/dist/components/{tttx-textarea_1_9_101.js → tttx-textarea_1_9_103.js} +83 -83
  214. package/dist/components/tttx-toggle_1_9_103.d.ts +11 -0
  215. package/dist/components/{tttx-toggle_1_9_101.js → tttx-toggle_1_9_103.js} +49 -49
  216. package/dist/components/tttx-toolbar.js +42 -42
  217. package/dist/components/tttx-toolbar_1_9_103.d.ts +11 -0
  218. package/dist/components/{tttx-toolbar_1_9_101.js → tttx-toolbar_1_9_103.js} +2 -2
  219. package/dist/components/tttx-tooltip_1_9_103.d.ts +11 -0
  220. package/dist/components/{tttx-tooltip_1_9_101.js → tttx-tooltip_1_9_103.js} +114 -114
  221. package/dist/components/tttx-tree-view_1_9_103.d.ts +11 -0
  222. package/dist/components/{tttx-tree-view_1_9_101.js → tttx-tree-view_1_9_103.js} +371 -371
  223. package/dist/esm/{auto-421f2656.js → auto-a07ee1b1.js} +177 -177
  224. package/dist/esm/{domsanitiser.options-38a67458.js → domsanitiser.options-2c1ef894.js} +12 -12
  225. package/dist/esm/loader.js +1 -1
  226. package/dist/esm/polyfills/core-js.js +0 -0
  227. package/dist/esm/polyfills/dom.js +0 -0
  228. package/dist/esm/polyfills/es5-html-element.js +0 -0
  229. package/dist/esm/polyfills/index.js +0 -0
  230. package/dist/esm/polyfills/system.js +0 -0
  231. package/dist/esm/{tttx-action-dropdown_1_9_101.entry.js → tttx-action-dropdown_1_9_103.entry.js} +51 -51
  232. package/dist/esm/{tttx-button-v2_1_9_101.entry.js → tttx-button-v2_1_9_103.entry.js} +147 -147
  233. package/dist/esm/{tttx-button_1_9_101.entry.js → tttx-button_1_9_103.entry.js} +26 -26
  234. package/dist/esm/{tttx-chart_1_9_101.entry.js → tttx-chart_1_9_103.entry.js} +524 -524
  235. package/dist/esm/{tttx-checkbox-group-caption_1_9_101.entry.js → tttx-checkbox-group-caption_1_9_103.entry.js} +9 -9
  236. package/dist/esm/{tttx-checkbox-group-heading_1_9_101.entry.js → tttx-checkbox-group-heading_1_9_103.entry.js} +9 -9
  237. package/dist/esm/{tttx-checkbox-group_1_9_101.entry.js → tttx-checkbox-group_1_9_103.entry.js} +9 -9
  238. package/dist/esm/{tttx-checkbox_1_9_101.entry.js → tttx-checkbox_1_9_103.entry.js} +33 -33
  239. package/dist/esm/{tttx-comments_1_9_101.entry.js → tttx-comments_1_9_103.entry.js} +204 -204
  240. package/dist/esm/{tttx-data-pattern_1_9_101.entry.js → tttx-data-pattern_1_9_103.entry.js} +20 -20
  241. package/dist/esm/{tttx-datacard_1_9_101.entry.js → tttx-datacard_1_9_103.entry.js} +43 -43
  242. package/dist/esm/tttx-date-range-picker.entry.js +212 -212
  243. package/dist/esm/{tttx-dialog-box_1_9_101.entry.js → tttx-dialog-box_1_9_103.entry.js} +94 -94
  244. package/dist/esm/{tttx-dialog_1_9_101.entry.js → tttx-dialog_1_9_103.entry.js} +69 -69
  245. package/dist/esm/{tttx-expander_1_9_101.entry.js → tttx-expander_1_9_103.entry.js} +28 -28
  246. package/dist/esm/{tttx-filter_1_9_101_4.entry.js → tttx-filter_1_9_103_4.entry.js} +383 -383
  247. package/dist/esm/{tttx-form_1_9_101.entry.js → tttx-form_1_9_103.entry.js} +985 -985
  248. package/dist/esm/{tttx-graph_1_9_101.entry.js → tttx-graph_1_9_103.entry.js} +124 -124
  249. package/dist/esm/{tttx-icon_1_9_101.entry.js → tttx-icon_1_9_103.entry.js} +24 -24
  250. package/dist/esm/{tttx-keyvalue-block_1_9_101.entry.js → tttx-keyvalue-block_1_9_103.entry.js} +62 -62
  251. package/dist/esm/{tttx-loading-spinner_1_9_101_3.entry.js → tttx-loading-spinner_1_9_103_3.entry.js} +170 -170
  252. package/dist/esm/{tttx-multiselect-box_1_9_101.entry.js → tttx-multiselect-box_1_9_103.entry.js} +175 -175
  253. package/dist/esm/{tttx-percentage-bar_1_9_101.entry.js → tttx-percentage-bar_1_9_103.entry.js} +56 -56
  254. package/dist/esm/{tttx-qrcode_1_9_101.entry.js → tttx-qrcode_1_9_103.entry.js} +28 -28
  255. package/dist/esm/{tttx-range-slider_1_9_101.entry.js → tttx-range-slider_1_9_103.entry.js} +185 -185
  256. package/dist/esm/{tttx-select-box_1_9_101.entry.js → tttx-select-box_1_9_103.entry.js} +239 -239
  257. package/dist/esm/{tttx-skeleton_loader_1_9_101.entry.js → tttx-skeleton_loader_1_9_103.entry.js} +30 -30
  258. package/dist/esm/{tttx-table_1_9_101.entry.js → tttx-table_1_9_103.entry.js} +72 -72
  259. package/dist/esm/{tttx-tabs_1_9_101.entry.js → tttx-tabs_1_9_103.entry.js} +103 -103
  260. package/dist/esm/{tttx-tag-v2_1_9_101.entry.js → tttx-tag-v2_1_9_103.entry.js} +72 -72
  261. package/dist/esm/{tttx-textarea_1_9_101.entry.js → tttx-textarea_1_9_103.entry.js} +50 -50
  262. package/dist/esm/{tttx-toggle_1_9_101.entry.js → tttx-toggle_1_9_103.entry.js} +30 -30
  263. package/dist/esm/{tttx-tooltip_1_9_101.entry.js → tttx-tooltip_1_9_103.entry.js} +87 -87
  264. package/dist/esm/{tttx-tree-view_1_9_101.entry.js → tttx-tree-view_1_9_103.entry.js} +342 -342
  265. package/dist/esm/tttx.js +1 -1
  266. package/dist/tttx/{p-b3f49d83.entry.js → p-0c5bc253.entry.js} +1 -1
  267. package/dist/tttx/{p-82b4e575.entry.js → p-10d2d044.entry.js} +1 -1
  268. package/dist/tttx/p-1623f3cf.entry.js +1 -1
  269. package/dist/tttx/{p-b161205b.entry.js → p-16aa3f67.entry.js} +1 -1
  270. package/dist/tttx/p-21707b8d.entry.js +1 -1
  271. package/dist/tttx/p-2251ab85.entry.js +1 -1
  272. package/dist/tttx/p-2d19c46c.entry.js +1 -1
  273. package/dist/tttx/p-358eaa44.entry.js +1 -1
  274. package/dist/tttx/p-362999b3.entry.js +1 -1
  275. package/dist/tttx/p-3ec67d75.entry.js +1 -1
  276. package/dist/tttx/p-44f0af69.entry.js +1 -1
  277. package/dist/tttx/p-4664d065.entry.js +1 -1
  278. package/dist/tttx/{p-00a849cf.entry.js → p-486ca932.entry.js} +1 -1
  279. package/dist/tttx/{p-e21e3a9c.entry.js → p-59115c8f.entry.js} +1 -1
  280. package/dist/tttx/p-5d289334.entry.js +1 -1
  281. package/dist/tttx/p-6ec18b4a.entry.js +1 -1
  282. package/dist/tttx/{p-a59ad197.entry.js → p-700c2816.entry.js} +1 -1
  283. package/dist/tttx/p-7b5b0670.entry.js +1 -1
  284. package/dist/tttx/p-7d1712fe.entry.js +1 -1
  285. package/dist/tttx/{p-41b69e01.entry.js → p-8f85ab3e.entry.js} +1 -1
  286. package/dist/tttx/p-a1b8ecda.entry.js +1 -1
  287. package/dist/tttx/p-a43e2c5e.entry.js +1 -1
  288. package/dist/tttx/p-b8cc0cb2.entry.js +1 -1
  289. package/dist/tttx/p-b9003a76.entry.js +1 -1
  290. package/dist/tttx/p-bb59054f.entry.js +1 -1
  291. package/dist/tttx/p-c66bc14c.entry.js +1 -1
  292. package/dist/tttx/p-c8051143.entry.js +1 -1
  293. package/dist/tttx/p-ca93f786.entry.js +1 -1
  294. package/dist/tttx/p-d21b0507.entry.js +1 -1
  295. package/dist/tttx/p-d945d492.entry.js +1 -1
  296. package/dist/tttx/{p-34e0e487.entry.js → p-df708b75.entry.js} +2 -2
  297. package/dist/tttx/p-f0c1380f.entry.js +1 -1
  298. package/dist/tttx/{p-0bb158ce.js → p-f411d1e5.js} +2 -2
  299. package/dist/tttx/{p-d4c4edbd.entry.js → p-fa25ee03.entry.js} +1 -1
  300. package/dist/tttx/{p-41f0bf7f.entry.js → p-fbdd1046.entry.js} +1 -1
  301. package/dist/tttx/tttx.esm.js +1 -1
  302. package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +11 -11
  303. package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +11 -11
  304. package/dist/types/components/atoms/tttx-button-v2/tttx-button-v2.d.ts +36 -36
  305. package/dist/types/components/atoms/tttx-button-v2/tttx-button-v2.stories.d.ts +68 -68
  306. package/dist/types/components/atoms/tttx-checkbox/tttx-checkbox.d.ts +17 -17
  307. package/dist/types/components/atoms/tttx-datacard/tttx-datacard.d.ts +21 -21
  308. package/dist/types/components/atoms/tttx-datacard/tttx-datacard.stories.d.ts +44 -44
  309. package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +9 -9
  310. package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +25 -25
  311. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +13 -13
  312. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +11 -11
  313. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +23 -23
  314. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +47 -47
  315. package/dist/types/components/atoms/tttx-percentage-bar/tttx-percentage-bar.d.ts +22 -22
  316. package/dist/types/components/atoms/tttx-percentage-bar/tttx-percentage-bar.stories.d.ts +10 -10
  317. package/dist/types/components/atoms/tttx-qrcode/tttx-qrcode.d.ts +8 -8
  318. package/dist/types/components/atoms/tttx-qrcode/tttx-qrcode.stories.d.ts +23 -23
  319. package/dist/types/components/atoms/tttx-skeleton-loader/tttx-skeleton-loader.d.ts +14 -14
  320. package/dist/types/components/atoms/tttx-tag/tttx-tag.d.ts +10 -10
  321. package/dist/types/components/atoms/tttx-tag/tttx-tag.stories.d.ts +51 -51
  322. package/dist/types/components/atoms/tttx-tag-v2/tttx-tag-v2.d.ts +15 -15
  323. package/dist/types/components/atoms/tttx-tag-v2/tttx-tag-v2.stories.d.ts +48 -48
  324. package/dist/types/components/atoms/tttx-toggle/tttx-toggle.d.ts +11 -11
  325. package/dist/types/components/atoms/tttx-toggle/tttx-toggle.stories.d.ts +6 -6
  326. package/dist/types/components/domsanitiser.options.d.ts +10 -10
  327. package/dist/types/components/molecules/tttx-action-dropdown/tttx-action-dropdown.d.ts +21 -21
  328. package/dist/types/components/molecules/tttx-chart/tttx-chart.d.ts +60 -60
  329. package/dist/types/components/molecules/tttx-chart/tttx-chart.stories.d.ts +38 -38
  330. package/dist/types/components/molecules/tttx-checkbox-group/components/tttx-checkbox-group-caption.d.ts +3 -3
  331. package/dist/types/components/molecules/tttx-checkbox-group/components/tttx-checkbox-group-heading.d.ts +3 -3
  332. package/dist/types/components/molecules/tttx-checkbox-group/tttx-checkbox-group.d.ts +3 -3
  333. package/dist/types/components/molecules/tttx-checkbox-group/tttx-checkbox-group.stories.d.ts +15 -15
  334. package/dist/types/components/molecules/tttx-comments/tttx-comments.d.ts +68 -68
  335. package/dist/types/components/molecules/tttx-date-range-picker/tttx-date-range-picker.d.ts +42 -42
  336. package/dist/types/components/molecules/tttx-dialog/icon-types.d.ts +18 -18
  337. package/dist/types/components/molecules/tttx-dialog/tttx-dialog.d.ts +27 -27
  338. package/dist/types/components/molecules/tttx-dialog-box/tttx-dialog-box.d.ts +26 -26
  339. package/dist/types/components/molecules/tttx-dialog-box/tttx-dialog-box.stories.d.ts +24 -24
  340. package/dist/types/components/molecules/tttx-expander/tttx-expander.d.ts +16 -16
  341. package/dist/types/components/molecules/tttx-filter/tttx-filter.d.ts +44 -44
  342. package/dist/types/components/molecules/tttx-form/lib/setErrorState.d.ts +14 -14
  343. package/dist/types/components/molecules/tttx-form/lib/timecomparatorChecks.d.ts +4 -4
  344. package/dist/types/components/molecules/tttx-form/lib/validityCheck.d.ts +15 -15
  345. package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +297 -297
  346. package/dist/types/components/molecules/tttx-graph/gauge-label-plugin.d.ts +4 -4
  347. package/dist/types/components/molecules/tttx-graph/tttx-graph.d.ts +13 -13
  348. package/dist/types/components/molecules/tttx-graph/tttx-graph.stories.d.ts +26 -26
  349. package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +23 -23
  350. package/dist/types/components/molecules/tttx-multiselect-box/tttx-multiselect-box.d.ts +50 -50
  351. package/dist/types/components/molecules/tttx-range-slider/tttx-range-slider.d.ts +45 -45
  352. package/dist/types/components/molecules/tttx-range-slider/tttx-range-slider.stories.d.ts +7 -7
  353. package/dist/types/components/molecules/tttx-select-box/tttx-select-box.d.ts +55 -55
  354. package/dist/types/components/molecules/tttx-select-box/tttx-select-box.stories.d.ts +28 -28
  355. package/dist/types/components/molecules/tttx-sorter/tttx-sorter.d.ts +21 -21
  356. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +69 -69
  357. package/dist/types/components/molecules/tttx-table/tttx-table.d.ts +32 -32
  358. package/dist/types/components/molecules/tttx-table/tttx-table.types.d.ts +6 -6
  359. package/dist/types/components/molecules/tttx-tabs/tttx-tabs.d.ts +25 -25
  360. package/dist/types/components/molecules/tttx-textarea/tttx-textarea.d.ts +42 -42
  361. package/dist/types/components/molecules/tttx-textarea/tttx-textarea.stories.d.ts +89 -89
  362. package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.d.ts +8 -8
  363. package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.stories.d.ts +19 -19
  364. package/dist/types/components/molecules/tttx-tooltip/tttx-tooltip.d.ts +37 -37
  365. package/dist/types/components/molecules/tttx-tooltip/tttx-tootip.stories.d.ts +12 -12
  366. package/dist/types/components/molecules/tttx-tree-view/helper/helper.d.ts +24 -24
  367. package/dist/types/components/molecules/tttx-tree-view/tttx-tree-view.d.ts +57 -57
  368. package/dist/types/components/organisms/tttx-data-pattern/tttx-data-pattern.d.ts +11 -11
  369. package/dist/types/components/organisms/tttx-data-pattern/tttx-data-pattern.stories.d.ts +13 -13
  370. package/dist/types/components/palette.stories.d.ts +6 -6
  371. package/dist/types/components.d.ts +451 -451
  372. package/dist/types/icons.d.ts +2 -2
  373. package/dist/types/index.d.ts +1 -1
  374. package/dist/types/shared/domsanitiser.options.d.ts +10 -10
  375. package/package.json +1 -1
  376. package/dist/components/tttx-action-dropdown_1_9_101.d.ts +0 -11
  377. package/dist/components/tttx-button-v2_1_9_101.d.ts +0 -11
  378. package/dist/components/tttx-checkbox-group-caption_1_9_101.d.ts +0 -11
  379. package/dist/components/tttx-checkbox-group-heading_1_9_101.d.ts +0 -11
  380. package/dist/components/tttx-checkbox-group_1_9_101.d.ts +0 -11
  381. package/dist/components/tttx-checkbox_1_9_101.d.ts +0 -11
  382. package/dist/components/tttx-comments_1_9_101.d.ts +0 -11
  383. package/dist/components/tttx-data-pattern_1_9_101.d.ts +0 -11
  384. package/dist/components/tttx-datacard_1_9_101.d.ts +0 -11
  385. package/dist/components/tttx-dialog-box_1_9_101.d.ts +0 -11
  386. package/dist/components/tttx-expander_1_9_101.d.ts +0 -11
  387. package/dist/components/tttx-keyvalue-block_1_9_101.d.ts +0 -11
  388. package/dist/components/tttx-loading-spinner_1_9_101.d.ts +0 -11
  389. package/dist/components/tttx-multiselect-box_1_9_101.d.ts +0 -11
  390. package/dist/components/tttx-percentage-bar_1_9_101.d.ts +0 -11
  391. package/dist/components/tttx-qrcode_1_9_101.d.ts +0 -11
  392. package/dist/components/tttx-range-slider_1_9_101.d.ts +0 -11
  393. package/dist/components/tttx-select-box_1_9_101.d.ts +0 -11
  394. package/dist/components/tttx-skeleton_loader_1_9_101.d.ts +0 -11
  395. package/dist/components/tttx-sorter_1_9_101.d.ts +0 -11
  396. package/dist/components/tttx-standalone-input_1_9_101.d.ts +0 -11
  397. package/dist/components/tttx-textarea_1_9_101.d.ts +0 -11
  398. package/dist/components/tttx-toggle_1_9_101.d.ts +0 -11
  399. package/dist/components/tttx-toolbar_1_9_101.d.ts +0 -11
  400. package/dist/components/tttx-tooltip_1_9_101.d.ts +0 -11
  401. package/dist/components/tttx-tree-view_1_9_101.d.ts +0 -11
  402. package/dist/types/components/atoms/tttx-checkbox/tttx-checkbox.stories.d.ts +0 -47
  403. package/dist/types/components/atoms/tttx-skeleton-loader/tttx-skeleton-loader.stories.d.ts +0 -58
  404. package/dist/types/components/molecules/tttx-action-dropdown/tttx-action-dropdown.stories.d.ts +0 -36
  405. package/dist/types/components/molecules/tttx-comments/tttx-comments.stories.d.ts +0 -8
  406. package/dist/types/components/molecules/tttx-date-range-picker/tttx-date-range-picker.stories.d.ts +0 -28
  407. package/dist/types/components/molecules/tttx-dialog/tttx-dialog.stories.d.ts +0 -42
  408. package/dist/types/components/molecules/tttx-expander/tttx-expander.stories.d.ts +0 -27
  409. package/dist/types/components/molecules/tttx-filter/tttx-filter.stories.d.ts +0 -76
  410. package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +0 -718
  411. package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +0 -15
  412. package/dist/types/components/molecules/tttx-multiselect-box/tttx-multiselect-box.stories.d.ts +0 -17
  413. package/dist/types/components/molecules/tttx-sorter/tttx-sorter.stories.d.ts +0 -30
  414. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +0 -150
  415. package/dist/types/components/molecules/tttx-table/tttx-table.stories.d.ts +0 -79
  416. package/dist/types/components/molecules/tttx-tabs/tttx-tabs.stories.d.ts +0 -13
  417. package/dist/types/components/molecules/tttx-tree-view/tttx-tree-view.stories.d.ts +0 -15
  418. /package/dist/tttx/{p-55799798.js → p-62d92a44.js} +0 -0
@@ -1,1267 +1,1267 @@
1
- import { h, Host } from '@stencil/core';
2
- import * as DOMPurify from 'dompurify';
3
- import domSanitiserOptions from '../../../shared/domsanitiser.options';
4
- import validityCheck from './lib/validityCheck';
5
- import setErrorState from './lib/setErrorState';
6
- import { endDateComparisonValidator, startEndTimeComparator, startDateComparisonValidator } from './lib/timecomparatorChecks';
7
- export class TttxForm {
8
- constructor() {
9
- // Create a new template element using the HTMLTemplateElement interface.
10
- this.template = document.createElement('template');
11
- this.formschema = undefined;
12
- this.data = undefined;
13
- }
14
- // This method is called whenever the "formschema" property changes
15
- onFormSchemaChange(newValue) {
16
- // Check if the new value is a string, indicating that it needs to be parsed
17
- if (typeof newValue === 'string') {
18
- // Parse the string and set the "_formSchema" property
19
- this._formSchema = JSON.parse(newValue);
20
- }
21
- else {
22
- // If the new value is already an object, set the "_formSchema" property directly
23
- this._formSchema = newValue;
24
- }
25
- return this._formSchema;
26
- }
27
- onDataChange(newValue) {
28
- if (typeof newValue === 'string') {
29
- this._data = JSON.parse(newValue);
30
- }
31
- else {
32
- this._data = newValue;
33
- }
34
- return this._data;
35
- }
36
- /**
37
- * Handles the focus event for a form field and emits a "dataChanged" event
38
- * to the parent component with the field name and its new value.
39
- *
40
- * @param {KeyboardEvent | Event} event - The focus event triggered by the field.
41
- * @return {void}
42
- */
43
- fieldChanged(event) {
44
- // Extract the name and value of the field from the event
45
- const target = event.target;
46
- const fieldName = target.name;
47
- let fieldValue = target.value;
48
- if (target.type === 'checkbox') {
49
- fieldValue = target.checked ? 'on' : 'off';
50
- }
51
- // Emit an event to signal that the field's data has changed
52
- this.dataChanged.emit({ name: fieldName, value: fieldValue });
53
- }
54
- async submit() {
55
- this.submitButton.click();
56
- }
57
- async showLoadingSpinner(fieldname, value) {
58
- const tttxSelect = this.fieldset.querySelector(`[name=overlay-${fieldname}]`);
59
- tttxSelect.isLoading = value;
60
- }
61
- async setSelectedItem(fieldname, id) {
62
- const tttxSelect = this.fieldset.querySelector(`[name=overlay-${fieldname}]`);
63
- // select option with id
64
- await tttxSelect.setSelectedItem(id);
65
- }
66
- /**
67
- * Replace all children in a given select list with a list of new options
68
- * @param { string } fieldname the form name of the given field
69
- * @param { {label: string, value: string}[] } options a list of option values and labels
70
- */
71
- async setSelectOptions(fieldname, options, skipDefultSelection) {
72
- const select = this.fieldset.querySelector(`[name=${fieldname}]`);
73
- const tttxSelect = this.fieldset.querySelector(`[name=overlay-${fieldname}]`);
74
- const fragment = new DocumentFragment();
75
- for (const option of options) {
76
- const o = document.createElement('option');
77
- o.innerText = option.label;
78
- o.value = option.value;
79
- if (option.disabled) {
80
- o.disabled = true;
81
- }
82
- fragment.appendChild(o);
83
- }
84
- select.replaceChildren(fragment);
85
- tttxSelect.optionsData = options;
86
- // skip the first option selection if skipDefultSelection is true.
87
- if (!skipDefultSelection) {
88
- await tttxSelect.setSelectedItem(options.length > 0 ? options[0].value : undefined);
89
- }
90
- }
91
- async isValid() {
92
- const valid = this.form.checkValidity();
93
- const allElements = this.fieldset.querySelectorAll('[custom-validation-set=true]');
94
- if (allElements.length || !valid) {
95
- return false;
96
- }
97
- return true;
98
- }
99
- /**
100
- * Submits the form data to the server.
101
- *
102
- * @param {SubmitEvent} event - The event object for the form submission.
103
- * @returns {void}
104
- */
105
- doSubmit(event) {
106
- // prevent the form from submitting normally
107
- event.preventDefault();
108
- const allElements = this.fieldset.querySelectorAll('[custom-validation-set=true]');
109
- if (allElements.length) {
110
- return;
111
- }
112
- // create a new FormData object with the form data
113
- const formData = new FormData(event.target);
114
- // get a list of checkboxes, if any, so we can manually set unchecked box data
115
- const formProperties = this._formSchema.properties;
116
- for (const formKey of Object.keys(formProperties)) {
117
- if (formProperties[formKey].form.type === 'checkbox' && !formData.has(formKey)) {
118
- formData.append(formKey, 'off');
119
- }
120
- }
121
- // emit the form data through the `dataSubmitted` event
122
- this.dataSubmitted.emit(formData);
123
- }
124
- // This method is called before the component is loaded into the DOM
125
- componentWillLoad() {
126
- // Initialize the form schema by calling the "onFormSchemaChange" method with the current "formschema" property
127
- this.onFormSchemaChange(this.formschema);
128
- if (this.data) {
129
- this.onDataChange(this.data);
130
- }
131
- }
132
- // This method is called before the component is rendered
133
- componentWillRender() {
134
- // Clear the template to account for a potential re-render scenario
135
- this.template = document.createElement('template');
136
- // Populate the form from the form schema
137
- this.populateFormFromSchema();
138
- }
139
- /**
140
- * Creates a new HTMLSelectElement with a set of options.
141
- *
142
- * @param {string} formKey - The name of the dropdown field, as specified in the form schema.
143
- * @param {object} formProperties - An object containing additional properties, such as the field type and options properties.
144
- * @param {'select'} formProperties.type - The type of form field. In this case, it will always be "select".
145
- * @param {object} formProperties.validation - A set of validation rules for the field.
146
- * @param {Array<{label:string, value:string, placeholder?:boolean}>} formProperties.options - A list of properties to pass to the select options.
147
- * @param {string} formProperties.options[].label - The visible value of the option.
148
- * @param {string} formProperties.options[].value - The actual value of the option.
149
- * @param {boolean} [formProperties.options[].placeholder]
150
- */
151
- createSelect(formKey, formProperties) {
152
- var _a, _b, _c, _d, _e, _f;
153
- const select = document.createElement('select');
154
- select.setAttribute('name', formKey);
155
- (_a = formProperties.options) === null || _a === void 0 ? void 0 : _a.forEach(optionProperties => {
156
- this.appendOption(select, optionProperties);
157
- });
158
- if ((_b = this._data) === null || _b === void 0 ? void 0 : _b[formKey]) {
159
- select.classList.remove('placeholder');
160
- }
161
- const tttxSelect = document.createElement('tttx-select-box_1_9_101');
162
- tttxSelect.optionsData = (_c = formProperties.options) === null || _c === void 0 ? void 0 : _c.filter(o => !o.placeholder);
163
- tttxSelect.placeholder = (_e = (_d = formProperties.options) === null || _d === void 0 ? void 0 : _d.filter(o => o.placeholder)[0]) === null || _e === void 0 ? void 0 : _e.label;
164
- tttxSelect.inline = false;
165
- tttxSelect.searchEnabled = true;
166
- tttxSelect.useExternalFiltering = formProperties.useExternalFiltering || false;
167
- tttxSelect.style.width = '100%';
168
- tttxSelect.style.marginTop = '6px';
169
- tttxSelect.isLoading = formProperties.isLoading || false;
170
- tttxSelect.readOnly = (_f = formProperties.readOnly) !== null && _f !== void 0 ? _f : false;
171
- tttxSelect.setAttribute('name', 'overlay-' + formKey);
172
- const fragment = document.createDocumentFragment();
173
- fragment.append(tttxSelect);
174
- select.style.display = 'none';
175
- tttxSelect.addEventListener('selectItemEvent', this.selectItemEventCallback.bind(select));
176
- // emit the event for searchTermChanged.
177
- tttxSelect.addEventListener('multiselectSearchUpdated', (ev) => this.searchTermChanged.emit({
178
- name: formKey,
179
- value: ev.detail,
180
- type: 'SearchTermChanged'
181
- }));
182
- tttxSelect.addEventListener('toggleOpen', (ev) => this.selectToggleOpen.emit({
183
- name: formKey,
184
- value: ev.detail,
185
- type: 'ToggleOpen'
186
- }));
187
- return { input: select, overlay: fragment };
188
- }
189
- selectItemEventCallback(ev) {
190
- // this function MUST be bound to a HTMLSelectElement
191
- // 'this' will be the select element
192
- // the function was split out for testing
193
- const select = this;
194
- select.value = ev.detail.value;
195
- select.onblur({ target: select }); // triggers validator
196
- select.onchange({ target: select }); // triggers dataChanged event
197
- }
198
- /**
199
- * Appends an option to a select element
200
- *
201
- * @param {HTMLSelectElement} select - The select elements to attach the option to.
202
- * @param {Object} optionProperties
203
- * @param {string} optionProperties.value - The value of the option.
204
- * @param {string} optionProperties.label - The label which will be displayed on the form for the option.
205
- * @param {boolean} [optionProperties.placeholder]
206
- */
207
- appendOption(select, optionProperties) {
208
- const option = document.createElement('option');
209
- option.setAttribute('value', optionProperties.value);
210
- if (optionProperties.placeholder) {
211
- option.setAttribute('disabled', (optionProperties.disabled) ? 'true' : '');
212
- option.setAttribute('selected', '');
213
- option.setAttribute('hidden', '');
214
- select.classList.add('placeholder');
215
- }
216
- if (optionProperties.label)
217
- option.innerHTML = DOMPurify.sanitize(optionProperties.label, domSanitiserOptions);
218
- select.appendChild(option);
219
- }
220
- /**
221
- * Creates a new HTMLInputElement with the specified name, type, and placeholder (if any),
222
- * and sets its autocomplete and autocapitalization properties to off.
223
- *
224
- * @param {string} formKey - The name of the input field, as specified in the form schema.
225
- * @param {Record<string, any>} formProperties - An object containing additional properties for the input field, such as its type and placeholder value.
226
- * @param {string} formProperties.type - The type of the input field (e.g., "text", "email", "number", etc.).
227
- * @param {string} [formProperties.placeholder] - An optional placeholder value to display in the input field.
228
- * @return {HTMLInputElement} - The new input element.
229
- */
230
- createInput(formKey, formProperties) {
231
- var _a;
232
- // Create a new <input> element with the specified name and type
233
- const input = document.createElement('input');
234
- input.type = formProperties.type;
235
- input.name = formKey;
236
- // Set the placeholder attribute to the specified value (if any)
237
- input.placeholder = (_a = formProperties.placeholder) !== null && _a !== void 0 ? _a : '';
238
- // Disable autocomplete and autocapitalization
239
- input.autocomplete = 'off';
240
- input.autocapitalize = 'off';
241
- if (formProperties.readonly) {
242
- input.readOnly = true;
243
- }
244
- if (formProperties.maskedValue) {
245
- // Clear input on focus
246
- input.onfocus = () => {
247
- if (input.value === formProperties.maskedValue) {
248
- input.value = '';
249
- }
250
- };
251
- // Restore value or update it on blur
252
- input.addEventListener('blur', () => {
253
- if (input.value.trim() === '') {
254
- input.value = formProperties.maskedValue;
255
- }
256
- else {
257
- formProperties.value = input.value;
258
- }
259
- });
260
- }
261
- // Return the input element
262
- return input;
263
- }
264
- /**
265
- * Creates a new HTMLTextAreaElement with the specified name and placeholder (if any),
266
- * and sets its autocomplete and autocapitalization properties to off.
267
- *
268
- * @param {string} formKey - The name of the input field, as specified in the form schema.
269
- * @param {Record<string, any>} formProperties - An object containing additional properties for the input field, such as its type and placeholder value.
270
- * @param {string} [formProperties.placeholder] - An optional placeholder value to display in the input field.
271
- * @return {HTMLTextAreaElement} - The new input element.
272
- */
273
- createTextArea(formKey, formProperties) {
274
- var _a;
275
- const input = document.createElement('textarea');
276
- input.name = formKey;
277
- // Set the placeholder attribute to the specified value (if any)
278
- input.placeholder = (_a = formProperties.placeholder) !== null && _a !== void 0 ? _a : '';
279
- // Disable autocomplete and autocapitalization
280
- input.autocomplete = 'off';
281
- input.autocapitalize = 'off';
282
- if (formProperties.readonly) {
283
- input.readOnly = true;
284
- }
285
- if (formProperties.resize === 'none') {
286
- input.classList.add('resize-none');
287
- }
288
- // Return the input element
289
- return input;
290
- }
291
- createStartEndDateComponent(formKey, formProperties) {
292
- var _a, _b, _c, _d;
293
- const startDate = document.createElement('input');
294
- const endDate = document.createElement('input');
295
- startDate.type = endDate.type = 'date';
296
- startDate.name = `${formKey}-startdate`;
297
- endDate.name = `${formKey}-enddate`;
298
- startDate.setAttribute('data-formkey', formKey);
299
- endDate.setAttribute('data-formkey', formKey);
300
- if (formProperties.readonly) {
301
- startDate.readOnly = true;
302
- endDate.readOnly = true;
303
- }
304
- this.applyValidation(startDate, Object.assign({ required: { message: 'Please enter a start date' }, dateCompare: { to: endDate.name } }, (_a = formProperties.validation) === null || _a === void 0 ? void 0 : _a.startDate));
305
- this.applyValidation(endDate, Object.assign({ required: { message: 'Please enter an end date' }, dateCompare: { with: startDate.name, message: 'End date cannot be before the start date' } }, (_b = formProperties.validation) === null || _b === void 0 ? void 0 : _b.endDate));
306
- let startTime;
307
- let endTime;
308
- if (formProperties.includeTime) {
309
- startTime = document.createElement('input');
310
- endTime = document.createElement('input');
311
- startTime.type = endTime.type = 'time';
312
- startTime.name = `${formKey}-starttime`;
313
- endTime.name = `${formKey}-endtime`;
314
- startTime.setAttribute('data-formkey', formKey);
315
- endTime.setAttribute('data-formkey', formKey);
316
- if (formProperties.readonly) {
317
- startTime.readOnly = true;
318
- endTime.readOnly = true;
319
- }
320
- this.applyValidation(startTime, Object.assign({ required: { message: 'Please enter a start time' } }, (_c = formProperties.validation) === null || _c === void 0 ? void 0 : _c.startTime));
321
- this.applyValidation(endTime, Object.assign({ required: { message: 'Please enter an end time' } }, (_d = formProperties.validation) === null || _d === void 0 ? void 0 : _d.endTime));
322
- }
323
- const startLabel = document.createElement('label');
324
- startLabel.innerText = 'Start date';
325
- const endLabel = document.createElement('label');
326
- endLabel.innerText = 'End date';
327
- const startContainer = document.createElement('div');
328
- const endContainer = document.createElement('div');
329
- startContainer.className = endContainer.className = 'outer-container inputBlock';
330
- startLabel.className = endLabel.className = 'flex-label';
331
- startContainer.append(startDate);
332
- if (startTime) {
333
- startContainer.append(startTime);
334
- }
335
- startLabel.append(startContainer);
336
- startLabel.append(this.createErrorBubble());
337
- endContainer.append(endDate);
338
- if (endTime) {
339
- endContainer.append(endTime);
340
- }
341
- endLabel.append(endContainer);
342
- endLabel.append(this.createErrorBubble());
343
- return { start: startLabel, end: endLabel };
344
- }
345
- /**
346
- * Applies validation attributes to an input element based on the specified validation object.
347
- * If a certain property is present in the object, it will set the corresponding attribute on
348
- * the input element (e.g., "required" will set the "required" and "data-required" attributes,
349
- * "pattern" will set the "pattern" and "data-pattern" attributes, etc.).
350
- *
351
- * @param {FormField} input - The input element to apply validation attributes to.
352
- * @param {object} validation - An object containing the validation rules for the input field.
353
- * @param {object} [validation.required] - An object containing a "message" property to display if the field is required.
354
- * @param {string} [validation.required.message]
355
- * @param {object} [validation.pattern] - An object containing a "pattern" property to match against the field value, and a "message" property to display if the pattern doesn't match.
356
- * @param {string} [validation.pattern.pattern]
357
- * @param {string} [validation.pattern.message]
358
- * @param {object} [validation.badInput] - An object containing a "message" property to display if the field value is invalid.
359
- * @param {string} [validation.badInput.message]
360
- * @param {object} [validation.minmax] - An object containing "min" and "max" properties to validate the field value against, and a "message" property to display if the value is out of range.
361
- * @param {string} [validation.minmax.min]
362
- * @param {string} [validation.minmax.max]
363
- * @param {string} [validation.minmax.message]
364
- * @param {string} [validation.maxlength] - The maximum length of the input field.
365
- * @param {string} [validation.datecompare] - To compare start and end date fields.
366
- * @return {void}
367
- */
368
- applyValidation(input, validation) {
369
- var _a, _b;
370
- // If the "required" property is present, add the "required" attribute to the input element and
371
- // set its "data-required" attribute to the specified message (if any)
372
- if (validation.required) {
373
- input.setAttribute('required', '');
374
- input.setAttribute('data-required', (_a = validation.required.message) !== null && _a !== void 0 ? _a : '');
375
- }
376
- // If the "pattern" property is present, add the "pattern" attribute to the input element and set
377
- // its "data-pattern" attribute to the specified message (if any)
378
- if (validation.pattern) {
379
- input.setAttribute('pattern', validation.pattern.pattern);
380
- input.setAttribute('data-pattern', (_b = validation.pattern.message) !== null && _b !== void 0 ? _b : '');
381
- }
382
- // If the "badInput" property is present, set the input element's "data-badinput" attribute to
383
- // the specified message
384
- if (validation.badInput) {
385
- input.setAttribute('data-badinput', validation.badInput.message);
386
- }
387
- // If the "minmax" property is present, add the "min" and "max" attributes to the input element
388
- // and set its "data-range" attribute to the specified message (if any)
389
- if (validation.minmax) {
390
- input.setAttribute('min', validation.minmax.min);
391
- input.setAttribute('max', validation.minmax.max);
392
- input.setAttribute('data-range', validation.minmax.message);
393
- }
394
- // If the "maxlength" property is present, add the "maxlength" attribute to the input element
395
- if (validation.maxlength) {
396
- input.setAttribute('maxlength', validation.maxlength);
397
- }
398
- // Custom validation parameters for start date and end date comparison
399
- if (validation.dateCompare) {
400
- if (validation.dateCompare.message && validation.dateCompare.with) {
401
- input.setAttribute('data-compare', validation.dateCompare.message);
402
- input.setAttribute('data-compare-with', validation.dateCompare.with);
403
- }
404
- if (validation.dateCompare.to) {
405
- input.setAttribute('data-compare-to', validation.dateCompare.to);
406
- }
407
- }
408
- }
409
- // Create a new error bubble element
410
- createErrorBubble() {
411
- // Create a new <div> element with the "errorBubble" class
412
- const errorBubble = document.createElement('div');
413
- errorBubble.className = 'errorBubble';
414
- // Return the error bubble element
415
- return errorBubble;
416
- }
417
- /**
418
- *
419
- * @param {Record<string, any>} formProperties
420
- * @param {HTMLInputElement | HTMLSelectElement} input
421
- * @param {HTMLLabelElement} label
422
- * @returns {void}
423
- */
424
- appendCheckboxInput(formProperties, input, label) {
425
- if (formProperties.label) {
426
- const lineBreak = document.createElement('br');
427
- label.appendChild(lineBreak);
428
- }
429
- // Append the input element and error bubble element to the label
430
- label.appendChild(input);
431
- if (!formProperties.inlineLabel)
432
- return;
433
- const inlineLabel = document.createElement('span');
434
- inlineLabel.className = 'inlineLabel';
435
- inlineLabel.textContent = formProperties.inlineLabel;
436
- label.appendChild(inlineLabel);
437
- }
438
- /**
439
- * Creates a new <label> element with the "inputBlock" class and the specified label text,
440
- * and appends the input element and error bubble element to it. If the form property has
441
- * no validation object, it adds an "optional" span element to the label.
442
- *
443
- * @param {Record<string, any>} formProperties - An object containing properties for the form field, including its label text and validation rules.
444
- * @param {HTMLInputElement | HTMLSelectElement} input - The input element to associate with the label.
445
- * @param {never} overlay - The Child Element which will be rendered atop the standard HTML5 element
446
- * @param {HTMLDivElement} errorBubble - The error bubble element to display error messages in.
447
- * @return {HTMLLabelElement} - The new label element.
448
- */
449
- createLabel(formProperties, input, overlay = null, errorBubble) {
450
- var _a;
451
- const outerContainer = document.createElement('div');
452
- let outerContainerClassName = 'outer-container inputBlock';
453
- // Create a new <label> element with the "inputBlock" class and the specified text
454
- const label = document.createElement('label');
455
- label.innerText = formProperties.label;
456
- // If the form property has no validation object, add an "optional" span element to the label
457
- if (!((_a = formProperties.validation) === null || _a === void 0 ? void 0 : _a.required) && formProperties.label) {
458
- const optionalSpan = document.createElement('span');
459
- optionalSpan.className = 'optional';
460
- optionalSpan.innerHTML = '&nbsp;(optional)';
461
- label.appendChild(optionalSpan);
462
- }
463
- if (formProperties.type === 'radio') {
464
- outerContainerClassName += ' radioBlock';
465
- }
466
- outerContainer.className = outerContainerClassName;
467
- if (formProperties.readonly) {
468
- label.classList.add('readonly');
469
- }
470
- if (formProperties.type === 'checkbox') {
471
- this.appendCheckboxInput(formProperties, input, label);
472
- }
473
- else {
474
- // Append the input element and error bubble element to the outerContainer
475
- if (overlay) {
476
- outerContainer.appendChild(overlay);
477
- }
478
- outerContainer.appendChild(input);
479
- }
480
- if (formProperties.type !== 'checkbox') {
481
- label.appendChild(outerContainer);
482
- }
483
- label.appendChild(errorBubble);
484
- // Return the label element
485
- return label;
486
- }
487
- /**
488
- * Creates a new radio input with a set of options.
489
- *
490
- * @param {string} formKey - The name of the dropdown field, as specified in the form schema.
491
- * @param {Object} formProperties - An object containing additional properties, such as the field type and options properties.
492
- * @param {'radio'} formProperties.type - The type of form field. In this case, it will always be "radio".
493
- * @param {Object} formProperties.validation - A set of validation rules for the field.
494
- * @param {Object[]} formProperties.options - A list of properties to pass to the select options.
495
- * @param {string} formProperties.options.label - The visible value of the option.
496
- * @param {string} formProperties.options.value - The actual value of the option.
497
- */
498
- createRadio(formKey, formProperties) {
499
- var _a, _b;
500
- const fragment = document.createDocumentFragment();
501
- for (const optionProperties of formProperties.options) {
502
- // Create a new <input> element with the specified name and type
503
- const input = document.createElement('input');
504
- input.type = 'radio';
505
- input.name = formKey;
506
- input.value = optionProperties.value;
507
- if ((_a = formProperties === null || formProperties === void 0 ? void 0 : formProperties.validation) === null || _a === void 0 ? void 0 : _a.required) {
508
- input.setAttribute('required', 'required');
509
- input.setAttribute('data-required', (_b = formProperties.validation.required.message) !== null && _b !== void 0 ? _b : '');
510
- }
511
- const span = document.createElement('span');
512
- span.innerText = optionProperties.label;
513
- fragment.appendChild(input);
514
- fragment.appendChild(span);
515
- fragment.appendChild(document.createElement('br'));
516
- }
517
- return fragment;
518
- }
519
- /**
520
- * Populates the form template with input fields and labels based on the properties of the
521
- * current form schema. For each property in the schema, it creates an input element, applies
522
- * any validation rules to it, creates an error bubble and label element, and appends them
523
- * to the form template. Finally, it creates and appends a submit button element to the form.
524
- *
525
- * @return {void}
526
- */
527
- populateFormFromSchema() {
528
- var _a;
529
- // If there is no form schema, return early
530
- if (!this._formSchema) {
531
- return;
532
- }
533
- // Get the properties of the form schema and their keys
534
- const properties = this._formSchema.properties;
535
- const propertyKeys = Object.keys(properties);
536
- // Loop through each property key and create an input, label, and error bubble for it
537
- for (const formKey of propertyKeys) {
538
- const formItem = properties[formKey];
539
- const formProperties = formItem.form;
540
- // complex form types which require
541
- // custom HTML should be done here
542
- if (formProperties.type === 'startenddate') {
543
- const { start, end } = this.createStartEndDateComponent(formKey, formProperties);
544
- this.template.content.append(start);
545
- this.template.content.append(end);
546
- continue;
547
- }
548
- let fragments = {};
549
- switch (formProperties.type) {
550
- case 'select':
551
- fragments = this.createSelect(formKey, formProperties);
552
- break;
553
- case 'radio':
554
- fragments.input = this.createRadio(formKey, formProperties);
555
- break;
556
- case 'textarea':
557
- fragments.input = this.createTextArea(formKey, formProperties);
558
- break;
559
- default:
560
- fragments.input = this.createInput(formKey, formProperties);
561
- }
562
- // If the form property has validation, apply it to the input
563
- if (formProperties.validation &&
564
- formProperties.type !== 'radio') {
565
- this.applyValidation(fragments.input, formProperties.validation);
566
- }
567
- // Create an error bubble and label element for the input
568
- const errorBubble = this.createErrorBubble();
569
- const label = this.createLabel(formProperties, fragments.input, fragments.overlay, errorBubble);
570
- // If explicitly setting input as invalid, set invalid state and error message on render
571
- if ((_a = formProperties.validation) === null || _a === void 0 ? void 0 : _a.invalid) {
572
- const errorMessage = formProperties.validation.invalid.message;
573
- fragments.input.setCustomValidity(errorMessage); // Prevents the invalid styling from resetting on blur
574
- setErrorState(fragments.input, true, errorMessage);
575
- }
576
- // Append the label element to the form template
577
- this.template.content.append(label);
578
- if (formProperties.disabled) {
579
- this.toggleFormField(fragments.input, true);
580
- }
581
- }
582
- }
583
- /**
584
- * Clones the form template and binds event listeners to its input elements. First, it checks if
585
- * there is a form schema present. If so, it clones the template's content, binds events to form
586
- * input elements, and appends the cloned form elements to the fieldset. The event listeners include
587
- * "oninvalid" (to check input validity on submit), "onblur" (to check input validity on blur),
588
- * "onkeyup" (to handle changes in input fields), and "onchange" (to handle changes in select fields).
589
- *
590
- * @return {void}
591
- */
592
- componentDidRender() {
593
- // If there's no form schema, return
594
- if (!this._formSchema) {
595
- return;
596
- }
597
- // Clone the template's content and store it in a variable
598
- const formItems = this.template.content;
599
- // Bind event listeners to form elements
600
- const properties = this._formSchema.properties;
601
- const propertyKeys = Object.keys(properties);
602
- for (const formKey of propertyKeys) {
603
- this.applyValidationFunctionsToFormElement(formItems, formKey, properties);
604
- }
605
- // populate with existing form data if available
606
- if ((this._data && Object.keys(this._data).length > 0)) {
607
- this.populateFormWithExistingData(formItems);
608
- }
609
- // Append the cloned form elements to the fieldset
610
- this.fieldset.replaceChildren(formItems);
611
- }
612
- /**
613
- * Assign validation events to a given form item
614
- * @param formItems The document fragment template of form items to be rendered
615
- * @param formKey The key of the form item to bind events too
616
- * @param properties The form item's properties, such as type and name
617
- */
618
- applyValidationFunctionsToFormElement(formItems, formKey, properties) {
619
- const formItemsByKey = formItems.querySelectorAll(`[name^=${formKey}]`);
620
- for (const formInput of formItemsByKey) {
621
- // Bind events to form input elements
622
- formInput.oninvalid = this.validityCheckWrapper.bind(this);
623
- formInput.onblur = this.validityCheckWrapper.bind(this);
624
- formInput.onkeyup = this.fieldChanged.bind(this);
625
- formInput.onchange = this.fieldChanged.bind(this);
626
- if (properties[formKey].form.type === 'select' && formInput.classList.contains('placeholder')) {
627
- formInput.addEventListener('change', this.selectRemovePlaceholderCallback.bind(formInput));
628
- }
629
- if (properties[formKey].form.type === 'startenddate' && formInput.hasAttribute('data-compare-with')) {
630
- formInput.oninvalid = endDateComparisonValidator.bind(this);
631
- formInput.onblur = endDateComparisonValidator.bind(this);
632
- }
633
- if (properties[formKey].form.type === 'startenddate' && formInput.type === 'time') {
634
- formInput.oninvalid = startEndTimeComparator.bind(this);
635
- formInput.onblur = startEndTimeComparator.bind(this);
636
- }
637
- if (properties[formKey].form.type === 'startenddate' && formInput.hasAttribute('data-compare-to')) {
638
- formInput.oninvalid = startDateComparisonValidator.bind(this);
639
- formInput.onblur = startDateComparisonValidator.bind(this);
640
- }
641
- }
642
- }
643
- /**
644
- * If data exists, set form input values before rendering
645
- * @param formItems The document fragment template of form items to be rendered
646
- */
647
- populateFormWithExistingData(formItems) {
648
- var _a;
649
- const dataKeys = Object.keys(this._data);
650
- for (const key of dataKeys) {
651
- const formItemsByKey = formItems.querySelectorAll(`[name=${key}]`);
652
- for (const formItem of formItemsByKey) {
653
- switch (formItem.type) {
654
- case 'checkbox':
655
- if (this._data[key] === 'on') {
656
- formItem.checked = true;
657
- }
658
- break;
659
- case 'radio':
660
- if (formItem.value === this._data[key]) {
661
- formItem.checked = true;
662
- }
663
- break;
664
- case 'select':
665
- case 'select-one':
666
- formItems.querySelector(`[name=overlay-${key}]`)['selectedValue'] = this._data[key];
667
- formItem.value = this._data[key];
668
- break;
669
- case 'date':
670
- formItem.value = (_a = this._data[key]) === null || _a === void 0 ? void 0 : _a.split('T')[0];
671
- break;
672
- default:
673
- formItem.value = this._data[key];
674
- }
675
- }
676
- }
677
- }
678
- /**
679
- * Remove the placeholder class on the bound THIS select element
680
- */
681
- selectRemovePlaceholderCallback() {
682
- const select = this;
683
- select.classList.remove('placeholder');
684
- }
685
- /**
686
- * A wrapper around validity check and set error state
687
- */
688
- validityCheckWrapper(event) {
689
- const { target, hasError, errorMessage } = validityCheck(event);
690
- setErrorState(target, hasError, errorMessage);
691
- }
692
- assignFieldsetReference(el) {
693
- this.fieldset = el;
694
- }
695
- assignButtonReference(el) {
696
- this.submitButton = el;
697
- }
698
- /**
699
- * An external validation trigger to apply to a form field
700
- * @param { string } fieldName The form field name to apply the validation too
701
- * @param { string } message The validation message to display under the form field
702
- */
703
- async setValidationFor(fieldName, message) {
704
- const formField = this.fieldset.querySelector(`[name=${fieldName}]`);
705
- if (formField.disabled) {
706
- return;
707
- }
708
- formField.setCustomValidity(message);
709
- formField.setAttribute('custom-validation-set', 'true');
710
- setErrorState(formField, true, message);
711
- }
712
- /**
713
- * Clear the validation message on a given form field
714
- * @param { string } fieldName The form field name to clear the validation of
715
- */
716
- async clearValidationFor(fieldName) {
717
- const formField = this.fieldset.querySelector(`[name=${fieldName}]`);
718
- formField.setCustomValidity('');
719
- formField.removeAttribute('custom-validation-set');
720
- setErrorState(formField, false, '');
721
- }
722
- toggleFormField(formField, disabled) {
723
- formField.disabled = disabled;
724
- let parent = formField.parentElement;
725
- if (parent) {
726
- do {
727
- if (parent.nodeName !== 'LABEL') {
728
- parent = parent.parentElement;
729
- }
730
- } while (parent && parent.nodeName !== 'LABEL');
731
- if (parent) {
732
- parent.style.display = (disabled) ? 'none' : 'block';
733
- }
734
- }
735
- }
736
- /**
737
- * Disable a form field and visually remove it from the form.
738
- * If custom validation is set, this function will return without affecting the form field.
739
- * @param { string } fieldName The form field name to disable
740
- */
741
- async disableFormField(fieldName) {
742
- const formField = this.fieldset.querySelector(`[name=${fieldName}]`);
743
- if (formField.hasAttribute('custom-validation-set')) {
744
- return;
745
- }
746
- this.toggleFormField(formField, true);
747
- }
748
- /**
749
- * Enable a form field and visually add it back to the form.
750
- * @param { string } fieldName The form field name to enable
751
- */
752
- async enableFormField(fieldName) {
753
- const formField = this.fieldset.querySelector(`[name=${fieldName}]`);
754
- this.toggleFormField(formField, false);
755
- }
756
- /**
757
- * Set the value of a form field progromatically
758
- * @param { string } fieldName The form field name having it's value set
759
- * @param { string } fieldValue The form field value to set
760
- */
761
- async setInputFieldValue(fieldName, fieldValue) {
762
- const formField = this.fieldset.querySelector(`[name=${fieldName}]`);
763
- formField.value = fieldValue;
764
- }
765
- /**
766
- * Change the readonly property on an input field. If set to 'true' any validation will also be cleared.
767
- * @param { string } fieldName The form field name to set
768
- * @param { boolean } readonly The state of the read-only attribute
769
- */
770
- async setFieldReadOnlyMode(fieldName, readonly) {
771
- const formField = this.fieldset.querySelector(`[name=${fieldName}]`);
772
- if (formField && formField.nodeName === 'SELECT') {
773
- const tttxSelect = this.fieldset.querySelector(`[name=overlay-${fieldName}]`);
774
- tttxSelect.readOnly = readonly;
775
- formField.disabled = readonly;
776
- }
777
- else {
778
- formField.readOnly = readonly;
779
- }
780
- if (readonly) {
781
- await this.clearValidationFor(fieldName);
782
- }
783
- }
784
- /**
785
- * Renders the component's template as a form element with a fieldset container. The form's
786
- * "onSubmit" event is bound to the "doSubmit" function, which handles the form submission
787
- * and emits a "dataSubmitted" event with the form data. The fieldset element is assigned
788
- * to the "fieldset" instance variable using a ref, so it can be populated with form elements
789
- * later on.
790
- */
791
- render() {
792
- //react rendering so we can't JEST it
793
- //ignore so it doesn't ruin coverage
794
- /*istanbul ignore next*/
795
- return (h(Host, null, h("form", { onSubmit: this.doSubmit.bind(this), ref: frm => this.form = frm }, h("fieldset", { ref: this.assignFieldsetReference.bind(this) }), h("input", { type: "submit", ref: this.assignButtonReference.bind(this), style: { display: 'none' } }))));
796
- }
797
- static get is() { return "tttx-form_1_9_101"; }
798
- static get encapsulation() { return "shadow"; }
799
- static get originalStyleUrls() {
800
- return {
801
- "$": ["tttx-form.scss"]
802
- };
803
- }
804
- static get styleUrls() {
805
- return {
806
- "$": ["tttx-form.css"]
807
- };
808
- }
809
- static get properties() {
810
- return {
811
- "formschema": {
812
- "type": "string",
813
- "mutable": true,
814
- "complexType": {
815
- "original": "Record<string, any> | string",
816
- "resolved": "string | { [x: string]: any; }",
817
- "references": {
818
- "Record": {
819
- "location": "global"
820
- }
821
- }
822
- },
823
- "required": false,
824
- "optional": false,
825
- "docs": {
826
- "tags": [],
827
- "text": ""
828
- },
829
- "attribute": "formschema",
830
- "reflect": false
831
- },
832
- "data": {
833
- "type": "any",
834
- "mutable": true,
835
- "complexType": {
836
- "original": "any",
837
- "resolved": "any",
838
- "references": {}
839
- },
840
- "required": false,
841
- "optional": false,
842
- "docs": {
843
- "tags": [],
844
- "text": ""
845
- },
846
- "attribute": "data",
847
- "reflect": false
848
- }
849
- };
850
- }
851
- static get events() {
852
- return [{
853
- "method": "dataSubmitted",
854
- "name": "dataSubmitted",
855
- "bubbles": true,
856
- "cancelable": true,
857
- "composed": true,
858
- "docs": {
859
- "tags": [],
860
- "text": ""
861
- },
862
- "complexType": {
863
- "original": "FormData",
864
- "resolved": "FormData",
865
- "references": {
866
- "FormData": {
867
- "location": "global"
868
- }
869
- }
870
- }
871
- }, {
872
- "method": "dataChanged",
873
- "name": "dataChanged",
874
- "bubbles": true,
875
- "cancelable": true,
876
- "composed": true,
877
- "docs": {
878
- "tags": [],
879
- "text": ""
880
- },
881
- "complexType": {
882
- "original": "{ name: string; value: string }",
883
- "resolved": "{ name: string; value: string; }",
884
- "references": {}
885
- }
886
- }, {
887
- "method": "searchTermChanged",
888
- "name": "searchTermChanged",
889
- "bubbles": true,
890
- "cancelable": true,
891
- "composed": true,
892
- "docs": {
893
- "tags": [],
894
- "text": ""
895
- },
896
- "complexType": {
897
- "original": "{ name: string; value: string, type: string }",
898
- "resolved": "{ name: string; value: string; type: string; }",
899
- "references": {}
900
- }
901
- }, {
902
- "method": "selectToggleOpen",
903
- "name": "selectToggleOpen",
904
- "bubbles": true,
905
- "cancelable": true,
906
- "composed": true,
907
- "docs": {
908
- "tags": [],
909
- "text": ""
910
- },
911
- "complexType": {
912
- "original": "{ name: string; value: string, type: string }",
913
- "resolved": "{ name: string; value: string; type: string; }",
914
- "references": {}
915
- }
916
- }];
917
- }
918
- static get methods() {
919
- return {
920
- "submit": {
921
- "complexType": {
922
- "signature": "() => Promise<void>",
923
- "parameters": [],
924
- "references": {
925
- "Promise": {
926
- "location": "global"
927
- }
928
- },
929
- "return": "Promise<void>"
930
- },
931
- "docs": {
932
- "text": "",
933
- "tags": []
934
- }
935
- },
936
- "showLoadingSpinner": {
937
- "complexType": {
938
- "signature": "(fieldname: string, value: boolean) => Promise<void>",
939
- "parameters": [{
940
- "tags": [],
941
- "text": ""
942
- }, {
943
- "tags": [],
944
- "text": ""
945
- }],
946
- "references": {
947
- "Promise": {
948
- "location": "global"
949
- },
950
- "TttxSelectBox": {
951
- "location": "import",
952
- "path": "../tttx-select-box/tttx-select-box"
953
- }
954
- },
955
- "return": "Promise<void>"
956
- },
957
- "docs": {
958
- "text": "",
959
- "tags": []
960
- }
961
- },
962
- "setSelectedItem": {
963
- "complexType": {
964
- "signature": "(fieldname: string, id: string) => Promise<void>",
965
- "parameters": [{
966
- "tags": [],
967
- "text": ""
968
- }, {
969
- "tags": [],
970
- "text": ""
971
- }],
972
- "references": {
973
- "Promise": {
974
- "location": "global"
975
- },
976
- "TttxSelectBox": {
977
- "location": "import",
978
- "path": "../tttx-select-box/tttx-select-box"
979
- }
980
- },
981
- "return": "Promise<void>"
982
- },
983
- "docs": {
984
- "text": "",
985
- "tags": []
986
- }
987
- },
988
- "setSelectOptions": {
989
- "complexType": {
990
- "signature": "(fieldname: string, options: { label: string; value: string; disabled?: boolean; }[], skipDefultSelection?: boolean) => Promise<void>",
991
- "parameters": [{
992
- "tags": [{
993
- "name": "param",
994
- "text": "fieldname the form name of the given field"
995
- }],
996
- "text": "the form name of the given field"
997
- }, {
998
- "tags": [{
999
- "name": "param",
1000
- "text": "options a list of option values and labels"
1001
- }],
1002
- "text": "a list of option values and labels"
1003
- }, {
1004
- "tags": [],
1005
- "text": ""
1006
- }],
1007
- "references": {
1008
- "Promise": {
1009
- "location": "global"
1010
- },
1011
- "TttxSelectBox": {
1012
- "location": "import",
1013
- "path": "../tttx-select-box/tttx-select-box"
1014
- }
1015
- },
1016
- "return": "Promise<void>"
1017
- },
1018
- "docs": {
1019
- "text": "Replace all children in a given select list with a list of new options",
1020
- "tags": [{
1021
- "name": "param",
1022
- "text": "fieldname the form name of the given field"
1023
- }, {
1024
- "name": "param",
1025
- "text": "options a list of option values and labels"
1026
- }]
1027
- }
1028
- },
1029
- "isValid": {
1030
- "complexType": {
1031
- "signature": "() => Promise<boolean>",
1032
- "parameters": [],
1033
- "references": {
1034
- "Promise": {
1035
- "location": "global"
1036
- }
1037
- },
1038
- "return": "Promise<boolean>"
1039
- },
1040
- "docs": {
1041
- "text": "",
1042
- "tags": []
1043
- }
1044
- },
1045
- "setValidationFor": {
1046
- "complexType": {
1047
- "signature": "(fieldName: string, message: string) => Promise<void>",
1048
- "parameters": [{
1049
- "tags": [{
1050
- "name": "param",
1051
- "text": "fieldName The form field name to apply the validation too"
1052
- }],
1053
- "text": "The form field name to apply the validation too"
1054
- }, {
1055
- "tags": [{
1056
- "name": "param",
1057
- "text": "message The validation message to display under the form field"
1058
- }],
1059
- "text": "The validation message to display under the form field"
1060
- }],
1061
- "references": {
1062
- "Promise": {
1063
- "location": "global"
1064
- },
1065
- "HTMLInputElement": {
1066
- "location": "global"
1067
- },
1068
- "HTMLSelectElement": {
1069
- "location": "global"
1070
- }
1071
- },
1072
- "return": "Promise<void>"
1073
- },
1074
- "docs": {
1075
- "text": "An external validation trigger to apply to a form field",
1076
- "tags": [{
1077
- "name": "param",
1078
- "text": "fieldName The form field name to apply the validation too"
1079
- }, {
1080
- "name": "param",
1081
- "text": "message The validation message to display under the form field"
1082
- }]
1083
- }
1084
- },
1085
- "clearValidationFor": {
1086
- "complexType": {
1087
- "signature": "(fieldName: string) => Promise<void>",
1088
- "parameters": [{
1089
- "tags": [{
1090
- "name": "param",
1091
- "text": "fieldName The form field name to clear the validation of"
1092
- }],
1093
- "text": "The form field name to clear the validation of"
1094
- }],
1095
- "references": {
1096
- "Promise": {
1097
- "location": "global"
1098
- },
1099
- "HTMLInputElement": {
1100
- "location": "global"
1101
- },
1102
- "HTMLSelectElement": {
1103
- "location": "global"
1104
- }
1105
- },
1106
- "return": "Promise<void>"
1107
- },
1108
- "docs": {
1109
- "text": "Clear the validation message on a given form field",
1110
- "tags": [{
1111
- "name": "param",
1112
- "text": "fieldName The form field name to clear the validation of"
1113
- }]
1114
- }
1115
- },
1116
- "disableFormField": {
1117
- "complexType": {
1118
- "signature": "(fieldName: string) => Promise<void>",
1119
- "parameters": [{
1120
- "tags": [{
1121
- "name": "param",
1122
- "text": "fieldName The form field name to disable"
1123
- }],
1124
- "text": "The form field name to disable"
1125
- }],
1126
- "references": {
1127
- "Promise": {
1128
- "location": "global"
1129
- },
1130
- "HTMLInputElement": {
1131
- "location": "global"
1132
- },
1133
- "HTMLSelectElement": {
1134
- "location": "global"
1135
- }
1136
- },
1137
- "return": "Promise<void>"
1138
- },
1139
- "docs": {
1140
- "text": "Disable a form field and visually remove it from the form.\nIf custom validation is set, this function will return without affecting the form field.",
1141
- "tags": [{
1142
- "name": "param",
1143
- "text": "fieldName The form field name to disable"
1144
- }]
1145
- }
1146
- },
1147
- "enableFormField": {
1148
- "complexType": {
1149
- "signature": "(fieldName: string) => Promise<void>",
1150
- "parameters": [{
1151
- "tags": [{
1152
- "name": "param",
1153
- "text": "fieldName The form field name to enable"
1154
- }],
1155
- "text": "The form field name to enable"
1156
- }],
1157
- "references": {
1158
- "Promise": {
1159
- "location": "global"
1160
- },
1161
- "HTMLInputElement": {
1162
- "location": "global"
1163
- },
1164
- "HTMLSelectElement": {
1165
- "location": "global"
1166
- }
1167
- },
1168
- "return": "Promise<void>"
1169
- },
1170
- "docs": {
1171
- "text": "Enable a form field and visually add it back to the form.",
1172
- "tags": [{
1173
- "name": "param",
1174
- "text": "fieldName The form field name to enable"
1175
- }]
1176
- }
1177
- },
1178
- "setInputFieldValue": {
1179
- "complexType": {
1180
- "signature": "(fieldName: string, fieldValue: string) => Promise<void>",
1181
- "parameters": [{
1182
- "tags": [{
1183
- "name": "param",
1184
- "text": "fieldName The form field name having it's value set"
1185
- }],
1186
- "text": "The form field name having it's value set"
1187
- }, {
1188
- "tags": [{
1189
- "name": "param",
1190
- "text": "fieldValue The form field value to set"
1191
- }],
1192
- "text": "The form field value to set"
1193
- }],
1194
- "references": {
1195
- "Promise": {
1196
- "location": "global"
1197
- },
1198
- "HTMLInputElement": {
1199
- "location": "global"
1200
- }
1201
- },
1202
- "return": "Promise<void>"
1203
- },
1204
- "docs": {
1205
- "text": "Set the value of a form field progromatically",
1206
- "tags": [{
1207
- "name": "param",
1208
- "text": "fieldName The form field name having it's value set"
1209
- }, {
1210
- "name": "param",
1211
- "text": "fieldValue The form field value to set"
1212
- }]
1213
- }
1214
- },
1215
- "setFieldReadOnlyMode": {
1216
- "complexType": {
1217
- "signature": "(fieldName: string, readonly: boolean) => Promise<void>",
1218
- "parameters": [{
1219
- "tags": [{
1220
- "name": "param",
1221
- "text": "fieldName The form field name to set"
1222
- }],
1223
- "text": "The form field name to set"
1224
- }, {
1225
- "tags": [{
1226
- "name": "param",
1227
- "text": "readonly The state of the read-only attribute"
1228
- }],
1229
- "text": "The state of the read-only attribute"
1230
- }],
1231
- "references": {
1232
- "Promise": {
1233
- "location": "global"
1234
- },
1235
- "HTMLInputElement": {
1236
- "location": "global"
1237
- },
1238
- "TttxSelectBox": {
1239
- "location": "import",
1240
- "path": "../tttx-select-box/tttx-select-box"
1241
- }
1242
- },
1243
- "return": "Promise<void>"
1244
- },
1245
- "docs": {
1246
- "text": "Change the readonly property on an input field. If set to 'true' any validation will also be cleared.",
1247
- "tags": [{
1248
- "name": "param",
1249
- "text": "fieldName The form field name to set"
1250
- }, {
1251
- "name": "param",
1252
- "text": "readonly The state of the read-only attribute"
1253
- }]
1254
- }
1255
- }
1256
- };
1257
- }
1258
- static get watchers() {
1259
- return [{
1260
- "propName": "formschema",
1261
- "methodName": "onFormSchemaChange"
1262
- }, {
1263
- "propName": "data",
1264
- "methodName": "onDataChange"
1265
- }];
1266
- }
1267
- }
1
+ import { h, Host } from '@stencil/core';
2
+ import * as DOMPurify from 'dompurify';
3
+ import domSanitiserOptions from '../../../shared/domsanitiser.options';
4
+ import validityCheck from './lib/validityCheck';
5
+ import setErrorState from './lib/setErrorState';
6
+ import { endDateComparisonValidator, startEndTimeComparator, startDateComparisonValidator } from './lib/timecomparatorChecks';
7
+ export class TttxForm {
8
+ constructor() {
9
+ // Create a new template element using the HTMLTemplateElement interface.
10
+ this.template = document.createElement('template');
11
+ this.formschema = undefined;
12
+ this.data = undefined;
13
+ }
14
+ // This method is called whenever the "formschema" property changes
15
+ onFormSchemaChange(newValue) {
16
+ // Check if the new value is a string, indicating that it needs to be parsed
17
+ if (typeof newValue === 'string') {
18
+ // Parse the string and set the "_formSchema" property
19
+ this._formSchema = JSON.parse(newValue);
20
+ }
21
+ else {
22
+ // If the new value is already an object, set the "_formSchema" property directly
23
+ this._formSchema = newValue;
24
+ }
25
+ return this._formSchema;
26
+ }
27
+ onDataChange(newValue) {
28
+ if (typeof newValue === 'string') {
29
+ this._data = JSON.parse(newValue);
30
+ }
31
+ else {
32
+ this._data = newValue;
33
+ }
34
+ return this._data;
35
+ }
36
+ /**
37
+ * Handles the focus event for a form field and emits a "dataChanged" event
38
+ * to the parent component with the field name and its new value.
39
+ *
40
+ * @param {KeyboardEvent | Event} event - The focus event triggered by the field.
41
+ * @return {void}
42
+ */
43
+ fieldChanged(event) {
44
+ // Extract the name and value of the field from the event
45
+ const target = event.target;
46
+ const fieldName = target.name;
47
+ let fieldValue = target.value;
48
+ if (target.type === 'checkbox') {
49
+ fieldValue = target.checked ? 'on' : 'off';
50
+ }
51
+ // Emit an event to signal that the field's data has changed
52
+ this.dataChanged.emit({ name: fieldName, value: fieldValue });
53
+ }
54
+ async submit() {
55
+ this.submitButton.click();
56
+ }
57
+ async showLoadingSpinner(fieldname, value) {
58
+ const tttxSelect = this.fieldset.querySelector(`[name=overlay-${fieldname}]`);
59
+ tttxSelect.isLoading = value;
60
+ }
61
+ async setSelectedItem(fieldname, id) {
62
+ const tttxSelect = this.fieldset.querySelector(`[name=overlay-${fieldname}]`);
63
+ // select option with id
64
+ await tttxSelect.setSelectedItem(id);
65
+ }
66
+ /**
67
+ * Replace all children in a given select list with a list of new options
68
+ * @param { string } fieldname the form name of the given field
69
+ * @param { {label: string, value: string}[] } options a list of option values and labels
70
+ */
71
+ async setSelectOptions(fieldname, options, skipDefultSelection) {
72
+ const select = this.fieldset.querySelector(`[name=${fieldname}]`);
73
+ const tttxSelect = this.fieldset.querySelector(`[name=overlay-${fieldname}]`);
74
+ const fragment = new DocumentFragment();
75
+ for (const option of options) {
76
+ const o = document.createElement('option');
77
+ o.innerText = option.label;
78
+ o.value = option.value;
79
+ if (option.disabled) {
80
+ o.disabled = true;
81
+ }
82
+ fragment.appendChild(o);
83
+ }
84
+ select.replaceChildren(fragment);
85
+ tttxSelect.optionsData = options;
86
+ // skip the first option selection if skipDefultSelection is true.
87
+ if (!skipDefultSelection) {
88
+ await tttxSelect.setSelectedItem(options.length > 0 ? options[0].value : undefined);
89
+ }
90
+ }
91
+ async isValid() {
92
+ const valid = this.form.checkValidity();
93
+ const allElements = this.fieldset.querySelectorAll('[custom-validation-set=true]');
94
+ if (allElements.length || !valid) {
95
+ return false;
96
+ }
97
+ return true;
98
+ }
99
+ /**
100
+ * Submits the form data to the server.
101
+ *
102
+ * @param {SubmitEvent} event - The event object for the form submission.
103
+ * @returns {void}
104
+ */
105
+ doSubmit(event) {
106
+ // prevent the form from submitting normally
107
+ event.preventDefault();
108
+ const allElements = this.fieldset.querySelectorAll('[custom-validation-set=true]');
109
+ if (allElements.length) {
110
+ return;
111
+ }
112
+ // create a new FormData object with the form data
113
+ const formData = new FormData(event.target);
114
+ // get a list of checkboxes, if any, so we can manually set unchecked box data
115
+ const formProperties = this._formSchema.properties;
116
+ for (const formKey of Object.keys(formProperties)) {
117
+ if (formProperties[formKey].form.type === 'checkbox' && !formData.has(formKey)) {
118
+ formData.append(formKey, 'off');
119
+ }
120
+ }
121
+ // emit the form data through the `dataSubmitted` event
122
+ this.dataSubmitted.emit(formData);
123
+ }
124
+ // This method is called before the component is loaded into the DOM
125
+ componentWillLoad() {
126
+ // Initialize the form schema by calling the "onFormSchemaChange" method with the current "formschema" property
127
+ this.onFormSchemaChange(this.formschema);
128
+ if (this.data) {
129
+ this.onDataChange(this.data);
130
+ }
131
+ }
132
+ // This method is called before the component is rendered
133
+ componentWillRender() {
134
+ // Clear the template to account for a potential re-render scenario
135
+ this.template = document.createElement('template');
136
+ // Populate the form from the form schema
137
+ this.populateFormFromSchema();
138
+ }
139
+ /**
140
+ * Creates a new HTMLSelectElement with a set of options.
141
+ *
142
+ * @param {string} formKey - The name of the dropdown field, as specified in the form schema.
143
+ * @param {object} formProperties - An object containing additional properties, such as the field type and options properties.
144
+ * @param {'select'} formProperties.type - The type of form field. In this case, it will always be "select".
145
+ * @param {object} formProperties.validation - A set of validation rules for the field.
146
+ * @param {Array<{label:string, value:string, placeholder?:boolean}>} formProperties.options - A list of properties to pass to the select options.
147
+ * @param {string} formProperties.options[].label - The visible value of the option.
148
+ * @param {string} formProperties.options[].value - The actual value of the option.
149
+ * @param {boolean} [formProperties.options[].placeholder]
150
+ */
151
+ createSelect(formKey, formProperties) {
152
+ var _a, _b, _c, _d, _e, _f;
153
+ const select = document.createElement('select');
154
+ select.setAttribute('name', formKey);
155
+ (_a = formProperties.options) === null || _a === void 0 ? void 0 : _a.forEach(optionProperties => {
156
+ this.appendOption(select, optionProperties);
157
+ });
158
+ if ((_b = this._data) === null || _b === void 0 ? void 0 : _b[formKey]) {
159
+ select.classList.remove('placeholder');
160
+ }
161
+ const tttxSelect = document.createElement('tttx-select-box_1_9_103');
162
+ tttxSelect.optionsData = (_c = formProperties.options) === null || _c === void 0 ? void 0 : _c.filter(o => !o.placeholder);
163
+ tttxSelect.placeholder = (_e = (_d = formProperties.options) === null || _d === void 0 ? void 0 : _d.filter(o => o.placeholder)[0]) === null || _e === void 0 ? void 0 : _e.label;
164
+ tttxSelect.inline = false;
165
+ tttxSelect.searchEnabled = true;
166
+ tttxSelect.useExternalFiltering = formProperties.useExternalFiltering || false;
167
+ tttxSelect.style.width = '100%';
168
+ tttxSelect.style.marginTop = '6px';
169
+ tttxSelect.isLoading = formProperties.isLoading || false;
170
+ tttxSelect.readOnly = (_f = formProperties.readOnly) !== null && _f !== void 0 ? _f : false;
171
+ tttxSelect.setAttribute('name', 'overlay-' + formKey);
172
+ const fragment = document.createDocumentFragment();
173
+ fragment.append(tttxSelect);
174
+ select.style.display = 'none';
175
+ tttxSelect.addEventListener('selectItemEvent', this.selectItemEventCallback.bind(select));
176
+ // emit the event for searchTermChanged.
177
+ tttxSelect.addEventListener('multiselectSearchUpdated', (ev) => this.searchTermChanged.emit({
178
+ name: formKey,
179
+ value: ev.detail,
180
+ type: 'SearchTermChanged'
181
+ }));
182
+ tttxSelect.addEventListener('toggleOpen', (ev) => this.selectToggleOpen.emit({
183
+ name: formKey,
184
+ value: ev.detail,
185
+ type: 'ToggleOpen'
186
+ }));
187
+ return { input: select, overlay: fragment };
188
+ }
189
+ selectItemEventCallback(ev) {
190
+ // this function MUST be bound to a HTMLSelectElement
191
+ // 'this' will be the select element
192
+ // the function was split out for testing
193
+ const select = this;
194
+ select.value = ev.detail.value;
195
+ select.onblur({ target: select }); // triggers validator
196
+ select.onchange({ target: select }); // triggers dataChanged event
197
+ }
198
+ /**
199
+ * Appends an option to a select element
200
+ *
201
+ * @param {HTMLSelectElement} select - The select elements to attach the option to.
202
+ * @param {Object} optionProperties
203
+ * @param {string} optionProperties.value - The value of the option.
204
+ * @param {string} optionProperties.label - The label which will be displayed on the form for the option.
205
+ * @param {boolean} [optionProperties.placeholder]
206
+ */
207
+ appendOption(select, optionProperties) {
208
+ const option = document.createElement('option');
209
+ option.setAttribute('value', optionProperties.value);
210
+ if (optionProperties.placeholder) {
211
+ option.setAttribute('disabled', (optionProperties.disabled) ? 'true' : '');
212
+ option.setAttribute('selected', '');
213
+ option.setAttribute('hidden', '');
214
+ select.classList.add('placeholder');
215
+ }
216
+ if (optionProperties.label)
217
+ option.innerHTML = DOMPurify.sanitize(optionProperties.label, domSanitiserOptions);
218
+ select.appendChild(option);
219
+ }
220
+ /**
221
+ * Creates a new HTMLInputElement with the specified name, type, and placeholder (if any),
222
+ * and sets its autocomplete and autocapitalization properties to off.
223
+ *
224
+ * @param {string} formKey - The name of the input field, as specified in the form schema.
225
+ * @param {Record<string, any>} formProperties - An object containing additional properties for the input field, such as its type and placeholder value.
226
+ * @param {string} formProperties.type - The type of the input field (e.g., "text", "email", "number", etc.).
227
+ * @param {string} [formProperties.placeholder] - An optional placeholder value to display in the input field.
228
+ * @return {HTMLInputElement} - The new input element.
229
+ */
230
+ createInput(formKey, formProperties) {
231
+ var _a;
232
+ // Create a new <input> element with the specified name and type
233
+ const input = document.createElement('input');
234
+ input.type = formProperties.type;
235
+ input.name = formKey;
236
+ // Set the placeholder attribute to the specified value (if any)
237
+ input.placeholder = (_a = formProperties.placeholder) !== null && _a !== void 0 ? _a : '';
238
+ // Disable autocomplete and autocapitalization
239
+ input.autocomplete = 'off';
240
+ input.autocapitalize = 'off';
241
+ if (formProperties.readonly) {
242
+ input.readOnly = true;
243
+ }
244
+ if (formProperties.maskedValue) {
245
+ // Clear input on focus
246
+ input.onfocus = () => {
247
+ if (input.value === formProperties.maskedValue) {
248
+ input.value = '';
249
+ }
250
+ };
251
+ // Restore value or update it on blur
252
+ input.addEventListener('blur', () => {
253
+ if (input.value.trim() === '') {
254
+ input.value = formProperties.maskedValue;
255
+ }
256
+ else {
257
+ formProperties.value = input.value;
258
+ }
259
+ });
260
+ }
261
+ // Return the input element
262
+ return input;
263
+ }
264
+ /**
265
+ * Creates a new HTMLTextAreaElement with the specified name and placeholder (if any),
266
+ * and sets its autocomplete and autocapitalization properties to off.
267
+ *
268
+ * @param {string} formKey - The name of the input field, as specified in the form schema.
269
+ * @param {Record<string, any>} formProperties - An object containing additional properties for the input field, such as its type and placeholder value.
270
+ * @param {string} [formProperties.placeholder] - An optional placeholder value to display in the input field.
271
+ * @return {HTMLTextAreaElement} - The new input element.
272
+ */
273
+ createTextArea(formKey, formProperties) {
274
+ var _a;
275
+ const input = document.createElement('textarea');
276
+ input.name = formKey;
277
+ // Set the placeholder attribute to the specified value (if any)
278
+ input.placeholder = (_a = formProperties.placeholder) !== null && _a !== void 0 ? _a : '';
279
+ // Disable autocomplete and autocapitalization
280
+ input.autocomplete = 'off';
281
+ input.autocapitalize = 'off';
282
+ if (formProperties.readonly) {
283
+ input.readOnly = true;
284
+ }
285
+ if (formProperties.resize === 'none') {
286
+ input.classList.add('resize-none');
287
+ }
288
+ // Return the input element
289
+ return input;
290
+ }
291
+ createStartEndDateComponent(formKey, formProperties) {
292
+ var _a, _b, _c, _d;
293
+ const startDate = document.createElement('input');
294
+ const endDate = document.createElement('input');
295
+ startDate.type = endDate.type = 'date';
296
+ startDate.name = `${formKey}-startdate`;
297
+ endDate.name = `${formKey}-enddate`;
298
+ startDate.setAttribute('data-formkey', formKey);
299
+ endDate.setAttribute('data-formkey', formKey);
300
+ if (formProperties.readonly) {
301
+ startDate.readOnly = true;
302
+ endDate.readOnly = true;
303
+ }
304
+ this.applyValidation(startDate, Object.assign({ required: { message: 'Please enter a start date' }, dateCompare: { to: endDate.name } }, (_a = formProperties.validation) === null || _a === void 0 ? void 0 : _a.startDate));
305
+ this.applyValidation(endDate, Object.assign({ required: { message: 'Please enter an end date' }, dateCompare: { with: startDate.name, message: 'End date cannot be before the start date' } }, (_b = formProperties.validation) === null || _b === void 0 ? void 0 : _b.endDate));
306
+ let startTime;
307
+ let endTime;
308
+ if (formProperties.includeTime) {
309
+ startTime = document.createElement('input');
310
+ endTime = document.createElement('input');
311
+ startTime.type = endTime.type = 'time';
312
+ startTime.name = `${formKey}-starttime`;
313
+ endTime.name = `${formKey}-endtime`;
314
+ startTime.setAttribute('data-formkey', formKey);
315
+ endTime.setAttribute('data-formkey', formKey);
316
+ if (formProperties.readonly) {
317
+ startTime.readOnly = true;
318
+ endTime.readOnly = true;
319
+ }
320
+ this.applyValidation(startTime, Object.assign({ required: { message: 'Please enter a start time' } }, (_c = formProperties.validation) === null || _c === void 0 ? void 0 : _c.startTime));
321
+ this.applyValidation(endTime, Object.assign({ required: { message: 'Please enter an end time' } }, (_d = formProperties.validation) === null || _d === void 0 ? void 0 : _d.endTime));
322
+ }
323
+ const startLabel = document.createElement('label');
324
+ startLabel.innerText = 'Start date';
325
+ const endLabel = document.createElement('label');
326
+ endLabel.innerText = 'End date';
327
+ const startContainer = document.createElement('div');
328
+ const endContainer = document.createElement('div');
329
+ startContainer.className = endContainer.className = 'outer-container inputBlock';
330
+ startLabel.className = endLabel.className = 'flex-label';
331
+ startContainer.append(startDate);
332
+ if (startTime) {
333
+ startContainer.append(startTime);
334
+ }
335
+ startLabel.append(startContainer);
336
+ startLabel.append(this.createErrorBubble());
337
+ endContainer.append(endDate);
338
+ if (endTime) {
339
+ endContainer.append(endTime);
340
+ }
341
+ endLabel.append(endContainer);
342
+ endLabel.append(this.createErrorBubble());
343
+ return { start: startLabel, end: endLabel };
344
+ }
345
+ /**
346
+ * Applies validation attributes to an input element based on the specified validation object.
347
+ * If a certain property is present in the object, it will set the corresponding attribute on
348
+ * the input element (e.g., "required" will set the "required" and "data-required" attributes,
349
+ * "pattern" will set the "pattern" and "data-pattern" attributes, etc.).
350
+ *
351
+ * @param {FormField} input - The input element to apply validation attributes to.
352
+ * @param {object} validation - An object containing the validation rules for the input field.
353
+ * @param {object} [validation.required] - An object containing a "message" property to display if the field is required.
354
+ * @param {string} [validation.required.message]
355
+ * @param {object} [validation.pattern] - An object containing a "pattern" property to match against the field value, and a "message" property to display if the pattern doesn't match.
356
+ * @param {string} [validation.pattern.pattern]
357
+ * @param {string} [validation.pattern.message]
358
+ * @param {object} [validation.badInput] - An object containing a "message" property to display if the field value is invalid.
359
+ * @param {string} [validation.badInput.message]
360
+ * @param {object} [validation.minmax] - An object containing "min" and "max" properties to validate the field value against, and a "message" property to display if the value is out of range.
361
+ * @param {string} [validation.minmax.min]
362
+ * @param {string} [validation.minmax.max]
363
+ * @param {string} [validation.minmax.message]
364
+ * @param {string} [validation.maxlength] - The maximum length of the input field.
365
+ * @param {string} [validation.datecompare] - To compare start and end date fields.
366
+ * @return {void}
367
+ */
368
+ applyValidation(input, validation) {
369
+ var _a, _b;
370
+ // If the "required" property is present, add the "required" attribute to the input element and
371
+ // set its "data-required" attribute to the specified message (if any)
372
+ if (validation.required) {
373
+ input.setAttribute('required', '');
374
+ input.setAttribute('data-required', (_a = validation.required.message) !== null && _a !== void 0 ? _a : '');
375
+ }
376
+ // If the "pattern" property is present, add the "pattern" attribute to the input element and set
377
+ // its "data-pattern" attribute to the specified message (if any)
378
+ if (validation.pattern) {
379
+ input.setAttribute('pattern', validation.pattern.pattern);
380
+ input.setAttribute('data-pattern', (_b = validation.pattern.message) !== null && _b !== void 0 ? _b : '');
381
+ }
382
+ // If the "badInput" property is present, set the input element's "data-badinput" attribute to
383
+ // the specified message
384
+ if (validation.badInput) {
385
+ input.setAttribute('data-badinput', validation.badInput.message);
386
+ }
387
+ // If the "minmax" property is present, add the "min" and "max" attributes to the input element
388
+ // and set its "data-range" attribute to the specified message (if any)
389
+ if (validation.minmax) {
390
+ input.setAttribute('min', validation.minmax.min);
391
+ input.setAttribute('max', validation.minmax.max);
392
+ input.setAttribute('data-range', validation.minmax.message);
393
+ }
394
+ // If the "maxlength" property is present, add the "maxlength" attribute to the input element
395
+ if (validation.maxlength) {
396
+ input.setAttribute('maxlength', validation.maxlength);
397
+ }
398
+ // Custom validation parameters for start date and end date comparison
399
+ if (validation.dateCompare) {
400
+ if (validation.dateCompare.message && validation.dateCompare.with) {
401
+ input.setAttribute('data-compare', validation.dateCompare.message);
402
+ input.setAttribute('data-compare-with', validation.dateCompare.with);
403
+ }
404
+ if (validation.dateCompare.to) {
405
+ input.setAttribute('data-compare-to', validation.dateCompare.to);
406
+ }
407
+ }
408
+ }
409
+ // Create a new error bubble element
410
+ createErrorBubble() {
411
+ // Create a new <div> element with the "errorBubble" class
412
+ const errorBubble = document.createElement('div');
413
+ errorBubble.className = 'errorBubble';
414
+ // Return the error bubble element
415
+ return errorBubble;
416
+ }
417
+ /**
418
+ *
419
+ * @param {Record<string, any>} formProperties
420
+ * @param {HTMLInputElement | HTMLSelectElement} input
421
+ * @param {HTMLLabelElement} label
422
+ * @returns {void}
423
+ */
424
+ appendCheckboxInput(formProperties, input, label) {
425
+ if (formProperties.label) {
426
+ const lineBreak = document.createElement('br');
427
+ label.appendChild(lineBreak);
428
+ }
429
+ // Append the input element and error bubble element to the label
430
+ label.appendChild(input);
431
+ if (!formProperties.inlineLabel)
432
+ return;
433
+ const inlineLabel = document.createElement('span');
434
+ inlineLabel.className = 'inlineLabel';
435
+ inlineLabel.textContent = formProperties.inlineLabel;
436
+ label.appendChild(inlineLabel);
437
+ }
438
+ /**
439
+ * Creates a new <label> element with the "inputBlock" class and the specified label text,
440
+ * and appends the input element and error bubble element to it. If the form property has
441
+ * no validation object, it adds an "optional" span element to the label.
442
+ *
443
+ * @param {Record<string, any>} formProperties - An object containing properties for the form field, including its label text and validation rules.
444
+ * @param {HTMLInputElement | HTMLSelectElement} input - The input element to associate with the label.
445
+ * @param {never} overlay - The Child Element which will be rendered atop the standard HTML5 element
446
+ * @param {HTMLDivElement} errorBubble - The error bubble element to display error messages in.
447
+ * @return {HTMLLabelElement} - The new label element.
448
+ */
449
+ createLabel(formProperties, input, overlay = null, errorBubble) {
450
+ var _a;
451
+ const outerContainer = document.createElement('div');
452
+ let outerContainerClassName = 'outer-container inputBlock';
453
+ // Create a new <label> element with the "inputBlock" class and the specified text
454
+ const label = document.createElement('label');
455
+ label.innerText = formProperties.label;
456
+ // If the form property has no validation object, add an "optional" span element to the label
457
+ if (!((_a = formProperties.validation) === null || _a === void 0 ? void 0 : _a.required) && formProperties.label) {
458
+ const optionalSpan = document.createElement('span');
459
+ optionalSpan.className = 'optional';
460
+ optionalSpan.innerHTML = '&nbsp;(optional)';
461
+ label.appendChild(optionalSpan);
462
+ }
463
+ if (formProperties.type === 'radio') {
464
+ outerContainerClassName += ' radioBlock';
465
+ }
466
+ outerContainer.className = outerContainerClassName;
467
+ if (formProperties.readonly) {
468
+ label.classList.add('readonly');
469
+ }
470
+ if (formProperties.type === 'checkbox') {
471
+ this.appendCheckboxInput(formProperties, input, label);
472
+ }
473
+ else {
474
+ // Append the input element and error bubble element to the outerContainer
475
+ if (overlay) {
476
+ outerContainer.appendChild(overlay);
477
+ }
478
+ outerContainer.appendChild(input);
479
+ }
480
+ if (formProperties.type !== 'checkbox') {
481
+ label.appendChild(outerContainer);
482
+ }
483
+ label.appendChild(errorBubble);
484
+ // Return the label element
485
+ return label;
486
+ }
487
+ /**
488
+ * Creates a new radio input with a set of options.
489
+ *
490
+ * @param {string} formKey - The name of the dropdown field, as specified in the form schema.
491
+ * @param {Object} formProperties - An object containing additional properties, such as the field type and options properties.
492
+ * @param {'radio'} formProperties.type - The type of form field. In this case, it will always be "radio".
493
+ * @param {Object} formProperties.validation - A set of validation rules for the field.
494
+ * @param {Object[]} formProperties.options - A list of properties to pass to the select options.
495
+ * @param {string} formProperties.options.label - The visible value of the option.
496
+ * @param {string} formProperties.options.value - The actual value of the option.
497
+ */
498
+ createRadio(formKey, formProperties) {
499
+ var _a, _b;
500
+ const fragment = document.createDocumentFragment();
501
+ for (const optionProperties of formProperties.options) {
502
+ // Create a new <input> element with the specified name and type
503
+ const input = document.createElement('input');
504
+ input.type = 'radio';
505
+ input.name = formKey;
506
+ input.value = optionProperties.value;
507
+ if ((_a = formProperties === null || formProperties === void 0 ? void 0 : formProperties.validation) === null || _a === void 0 ? void 0 : _a.required) {
508
+ input.setAttribute('required', 'required');
509
+ input.setAttribute('data-required', (_b = formProperties.validation.required.message) !== null && _b !== void 0 ? _b : '');
510
+ }
511
+ const span = document.createElement('span');
512
+ span.innerText = optionProperties.label;
513
+ fragment.appendChild(input);
514
+ fragment.appendChild(span);
515
+ fragment.appendChild(document.createElement('br'));
516
+ }
517
+ return fragment;
518
+ }
519
+ /**
520
+ * Populates the form template with input fields and labels based on the properties of the
521
+ * current form schema. For each property in the schema, it creates an input element, applies
522
+ * any validation rules to it, creates an error bubble and label element, and appends them
523
+ * to the form template. Finally, it creates and appends a submit button element to the form.
524
+ *
525
+ * @return {void}
526
+ */
527
+ populateFormFromSchema() {
528
+ var _a;
529
+ // If there is no form schema, return early
530
+ if (!this._formSchema) {
531
+ return;
532
+ }
533
+ // Get the properties of the form schema and their keys
534
+ const properties = this._formSchema.properties;
535
+ const propertyKeys = Object.keys(properties);
536
+ // Loop through each property key and create an input, label, and error bubble for it
537
+ for (const formKey of propertyKeys) {
538
+ const formItem = properties[formKey];
539
+ const formProperties = formItem.form;
540
+ // complex form types which require
541
+ // custom HTML should be done here
542
+ if (formProperties.type === 'startenddate') {
543
+ const { start, end } = this.createStartEndDateComponent(formKey, formProperties);
544
+ this.template.content.append(start);
545
+ this.template.content.append(end);
546
+ continue;
547
+ }
548
+ let fragments = {};
549
+ switch (formProperties.type) {
550
+ case 'select':
551
+ fragments = this.createSelect(formKey, formProperties);
552
+ break;
553
+ case 'radio':
554
+ fragments.input = this.createRadio(formKey, formProperties);
555
+ break;
556
+ case 'textarea':
557
+ fragments.input = this.createTextArea(formKey, formProperties);
558
+ break;
559
+ default:
560
+ fragments.input = this.createInput(formKey, formProperties);
561
+ }
562
+ // If the form property has validation, apply it to the input
563
+ if (formProperties.validation &&
564
+ formProperties.type !== 'radio') {
565
+ this.applyValidation(fragments.input, formProperties.validation);
566
+ }
567
+ // Create an error bubble and label element for the input
568
+ const errorBubble = this.createErrorBubble();
569
+ const label = this.createLabel(formProperties, fragments.input, fragments.overlay, errorBubble);
570
+ // If explicitly setting input as invalid, set invalid state and error message on render
571
+ if ((_a = formProperties.validation) === null || _a === void 0 ? void 0 : _a.invalid) {
572
+ const errorMessage = formProperties.validation.invalid.message;
573
+ fragments.input.setCustomValidity(errorMessage); // Prevents the invalid styling from resetting on blur
574
+ setErrorState(fragments.input, true, errorMessage);
575
+ }
576
+ // Append the label element to the form template
577
+ this.template.content.append(label);
578
+ if (formProperties.disabled) {
579
+ this.toggleFormField(fragments.input, true);
580
+ }
581
+ }
582
+ }
583
+ /**
584
+ * Clones the form template and binds event listeners to its input elements. First, it checks if
585
+ * there is a form schema present. If so, it clones the template's content, binds events to form
586
+ * input elements, and appends the cloned form elements to the fieldset. The event listeners include
587
+ * "oninvalid" (to check input validity on submit), "onblur" (to check input validity on blur),
588
+ * "onkeyup" (to handle changes in input fields), and "onchange" (to handle changes in select fields).
589
+ *
590
+ * @return {void}
591
+ */
592
+ componentDidRender() {
593
+ // If there's no form schema, return
594
+ if (!this._formSchema) {
595
+ return;
596
+ }
597
+ // Clone the template's content and store it in a variable
598
+ const formItems = this.template.content;
599
+ // Bind event listeners to form elements
600
+ const properties = this._formSchema.properties;
601
+ const propertyKeys = Object.keys(properties);
602
+ for (const formKey of propertyKeys) {
603
+ this.applyValidationFunctionsToFormElement(formItems, formKey, properties);
604
+ }
605
+ // populate with existing form data if available
606
+ if ((this._data && Object.keys(this._data).length > 0)) {
607
+ this.populateFormWithExistingData(formItems);
608
+ }
609
+ // Append the cloned form elements to the fieldset
610
+ this.fieldset.replaceChildren(formItems);
611
+ }
612
+ /**
613
+ * Assign validation events to a given form item
614
+ * @param formItems The document fragment template of form items to be rendered
615
+ * @param formKey The key of the form item to bind events too
616
+ * @param properties The form item's properties, such as type and name
617
+ */
618
+ applyValidationFunctionsToFormElement(formItems, formKey, properties) {
619
+ const formItemsByKey = formItems.querySelectorAll(`[name^=${formKey}]`);
620
+ for (const formInput of formItemsByKey) {
621
+ // Bind events to form input elements
622
+ formInput.oninvalid = this.validityCheckWrapper.bind(this);
623
+ formInput.onblur = this.validityCheckWrapper.bind(this);
624
+ formInput.onkeyup = this.fieldChanged.bind(this);
625
+ formInput.onchange = this.fieldChanged.bind(this);
626
+ if (properties[formKey].form.type === 'select' && formInput.classList.contains('placeholder')) {
627
+ formInput.addEventListener('change', this.selectRemovePlaceholderCallback.bind(formInput));
628
+ }
629
+ if (properties[formKey].form.type === 'startenddate' && formInput.hasAttribute('data-compare-with')) {
630
+ formInput.oninvalid = endDateComparisonValidator.bind(this);
631
+ formInput.onblur = endDateComparisonValidator.bind(this);
632
+ }
633
+ if (properties[formKey].form.type === 'startenddate' && formInput.type === 'time') {
634
+ formInput.oninvalid = startEndTimeComparator.bind(this);
635
+ formInput.onblur = startEndTimeComparator.bind(this);
636
+ }
637
+ if (properties[formKey].form.type === 'startenddate' && formInput.hasAttribute('data-compare-to')) {
638
+ formInput.oninvalid = startDateComparisonValidator.bind(this);
639
+ formInput.onblur = startDateComparisonValidator.bind(this);
640
+ }
641
+ }
642
+ }
643
+ /**
644
+ * If data exists, set form input values before rendering
645
+ * @param formItems The document fragment template of form items to be rendered
646
+ */
647
+ populateFormWithExistingData(formItems) {
648
+ var _a;
649
+ const dataKeys = Object.keys(this._data);
650
+ for (const key of dataKeys) {
651
+ const formItemsByKey = formItems.querySelectorAll(`[name=${key}]`);
652
+ for (const formItem of formItemsByKey) {
653
+ switch (formItem.type) {
654
+ case 'checkbox':
655
+ if (this._data[key] === 'on') {
656
+ formItem.checked = true;
657
+ }
658
+ break;
659
+ case 'radio':
660
+ if (formItem.value === this._data[key]) {
661
+ formItem.checked = true;
662
+ }
663
+ break;
664
+ case 'select':
665
+ case 'select-one':
666
+ formItems.querySelector(`[name=overlay-${key}]`)['selectedValue'] = this._data[key];
667
+ formItem.value = this._data[key];
668
+ break;
669
+ case 'date':
670
+ formItem.value = (_a = this._data[key]) === null || _a === void 0 ? void 0 : _a.split('T')[0];
671
+ break;
672
+ default:
673
+ formItem.value = this._data[key];
674
+ }
675
+ }
676
+ }
677
+ }
678
+ /**
679
+ * Remove the placeholder class on the bound THIS select element
680
+ */
681
+ selectRemovePlaceholderCallback() {
682
+ const select = this;
683
+ select.classList.remove('placeholder');
684
+ }
685
+ /**
686
+ * A wrapper around validity check and set error state
687
+ */
688
+ validityCheckWrapper(event) {
689
+ const { target, hasError, errorMessage } = validityCheck(event);
690
+ setErrorState(target, hasError, errorMessage);
691
+ }
692
+ assignFieldsetReference(el) {
693
+ this.fieldset = el;
694
+ }
695
+ assignButtonReference(el) {
696
+ this.submitButton = el;
697
+ }
698
+ /**
699
+ * An external validation trigger to apply to a form field
700
+ * @param { string } fieldName The form field name to apply the validation too
701
+ * @param { string } message The validation message to display under the form field
702
+ */
703
+ async setValidationFor(fieldName, message) {
704
+ const formField = this.fieldset.querySelector(`[name=${fieldName}]`);
705
+ if (formField.disabled) {
706
+ return;
707
+ }
708
+ formField.setCustomValidity(message);
709
+ formField.setAttribute('custom-validation-set', 'true');
710
+ setErrorState(formField, true, message);
711
+ }
712
+ /**
713
+ * Clear the validation message on a given form field
714
+ * @param { string } fieldName The form field name to clear the validation of
715
+ */
716
+ async clearValidationFor(fieldName) {
717
+ const formField = this.fieldset.querySelector(`[name=${fieldName}]`);
718
+ formField.setCustomValidity('');
719
+ formField.removeAttribute('custom-validation-set');
720
+ setErrorState(formField, false, '');
721
+ }
722
+ toggleFormField(formField, disabled) {
723
+ formField.disabled = disabled;
724
+ let parent = formField.parentElement;
725
+ if (parent) {
726
+ do {
727
+ if (parent.nodeName !== 'LABEL') {
728
+ parent = parent.parentElement;
729
+ }
730
+ } while (parent && parent.nodeName !== 'LABEL');
731
+ if (parent) {
732
+ parent.style.display = (disabled) ? 'none' : 'block';
733
+ }
734
+ }
735
+ }
736
+ /**
737
+ * Disable a form field and visually remove it from the form.
738
+ * If custom validation is set, this function will return without affecting the form field.
739
+ * @param { string } fieldName The form field name to disable
740
+ */
741
+ async disableFormField(fieldName) {
742
+ const formField = this.fieldset.querySelector(`[name=${fieldName}]`);
743
+ if (formField.hasAttribute('custom-validation-set')) {
744
+ return;
745
+ }
746
+ this.toggleFormField(formField, true);
747
+ }
748
+ /**
749
+ * Enable a form field and visually add it back to the form.
750
+ * @param { string } fieldName The form field name to enable
751
+ */
752
+ async enableFormField(fieldName) {
753
+ const formField = this.fieldset.querySelector(`[name=${fieldName}]`);
754
+ this.toggleFormField(formField, false);
755
+ }
756
+ /**
757
+ * Set the value of a form field progromatically
758
+ * @param { string } fieldName The form field name having it's value set
759
+ * @param { string } fieldValue The form field value to set
760
+ */
761
+ async setInputFieldValue(fieldName, fieldValue) {
762
+ const formField = this.fieldset.querySelector(`[name=${fieldName}]`);
763
+ formField.value = fieldValue;
764
+ }
765
+ /**
766
+ * Change the readonly property on an input field. If set to 'true' any validation will also be cleared.
767
+ * @param { string } fieldName The form field name to set
768
+ * @param { boolean } readonly The state of the read-only attribute
769
+ */
770
+ async setFieldReadOnlyMode(fieldName, readonly) {
771
+ const formField = this.fieldset.querySelector(`[name=${fieldName}]`);
772
+ if (formField && formField.nodeName === 'SELECT') {
773
+ const tttxSelect = this.fieldset.querySelector(`[name=overlay-${fieldName}]`);
774
+ tttxSelect.readOnly = readonly;
775
+ formField.disabled = readonly;
776
+ }
777
+ else {
778
+ formField.readOnly = readonly;
779
+ }
780
+ if (readonly) {
781
+ await this.clearValidationFor(fieldName);
782
+ }
783
+ }
784
+ /**
785
+ * Renders the component's template as a form element with a fieldset container. The form's
786
+ * "onSubmit" event is bound to the "doSubmit" function, which handles the form submission
787
+ * and emits a "dataSubmitted" event with the form data. The fieldset element is assigned
788
+ * to the "fieldset" instance variable using a ref, so it can be populated with form elements
789
+ * later on.
790
+ */
791
+ render() {
792
+ //react rendering so we can't JEST it
793
+ //ignore so it doesn't ruin coverage
794
+ /*istanbul ignore next*/
795
+ return (h(Host, null, h("form", { onSubmit: this.doSubmit.bind(this), ref: frm => this.form = frm }, h("fieldset", { ref: this.assignFieldsetReference.bind(this) }), h("input", { type: "submit", ref: this.assignButtonReference.bind(this), style: { display: 'none' } }))));
796
+ }
797
+ static get is() { return "tttx-form_1_9_103"; }
798
+ static get encapsulation() { return "shadow"; }
799
+ static get originalStyleUrls() {
800
+ return {
801
+ "$": ["tttx-form.scss"]
802
+ };
803
+ }
804
+ static get styleUrls() {
805
+ return {
806
+ "$": ["tttx-form.css"]
807
+ };
808
+ }
809
+ static get properties() {
810
+ return {
811
+ "formschema": {
812
+ "type": "string",
813
+ "mutable": true,
814
+ "complexType": {
815
+ "original": "Record<string, any> | string",
816
+ "resolved": "string | { [x: string]: any; }",
817
+ "references": {
818
+ "Record": {
819
+ "location": "global"
820
+ }
821
+ }
822
+ },
823
+ "required": false,
824
+ "optional": false,
825
+ "docs": {
826
+ "tags": [],
827
+ "text": ""
828
+ },
829
+ "attribute": "formschema",
830
+ "reflect": false
831
+ },
832
+ "data": {
833
+ "type": "any",
834
+ "mutable": true,
835
+ "complexType": {
836
+ "original": "any",
837
+ "resolved": "any",
838
+ "references": {}
839
+ },
840
+ "required": false,
841
+ "optional": false,
842
+ "docs": {
843
+ "tags": [],
844
+ "text": ""
845
+ },
846
+ "attribute": "data",
847
+ "reflect": false
848
+ }
849
+ };
850
+ }
851
+ static get events() {
852
+ return [{
853
+ "method": "dataSubmitted",
854
+ "name": "dataSubmitted",
855
+ "bubbles": true,
856
+ "cancelable": true,
857
+ "composed": true,
858
+ "docs": {
859
+ "tags": [],
860
+ "text": ""
861
+ },
862
+ "complexType": {
863
+ "original": "FormData",
864
+ "resolved": "FormData",
865
+ "references": {
866
+ "FormData": {
867
+ "location": "global"
868
+ }
869
+ }
870
+ }
871
+ }, {
872
+ "method": "dataChanged",
873
+ "name": "dataChanged",
874
+ "bubbles": true,
875
+ "cancelable": true,
876
+ "composed": true,
877
+ "docs": {
878
+ "tags": [],
879
+ "text": ""
880
+ },
881
+ "complexType": {
882
+ "original": "{ name: string; value: string }",
883
+ "resolved": "{ name: string; value: string; }",
884
+ "references": {}
885
+ }
886
+ }, {
887
+ "method": "searchTermChanged",
888
+ "name": "searchTermChanged",
889
+ "bubbles": true,
890
+ "cancelable": true,
891
+ "composed": true,
892
+ "docs": {
893
+ "tags": [],
894
+ "text": ""
895
+ },
896
+ "complexType": {
897
+ "original": "{ name: string; value: string, type: string }",
898
+ "resolved": "{ name: string; value: string; type: string; }",
899
+ "references": {}
900
+ }
901
+ }, {
902
+ "method": "selectToggleOpen",
903
+ "name": "selectToggleOpen",
904
+ "bubbles": true,
905
+ "cancelable": true,
906
+ "composed": true,
907
+ "docs": {
908
+ "tags": [],
909
+ "text": ""
910
+ },
911
+ "complexType": {
912
+ "original": "{ name: string; value: string, type: string }",
913
+ "resolved": "{ name: string; value: string; type: string; }",
914
+ "references": {}
915
+ }
916
+ }];
917
+ }
918
+ static get methods() {
919
+ return {
920
+ "submit": {
921
+ "complexType": {
922
+ "signature": "() => Promise<void>",
923
+ "parameters": [],
924
+ "references": {
925
+ "Promise": {
926
+ "location": "global"
927
+ }
928
+ },
929
+ "return": "Promise<void>"
930
+ },
931
+ "docs": {
932
+ "text": "",
933
+ "tags": []
934
+ }
935
+ },
936
+ "showLoadingSpinner": {
937
+ "complexType": {
938
+ "signature": "(fieldname: string, value: boolean) => Promise<void>",
939
+ "parameters": [{
940
+ "tags": [],
941
+ "text": ""
942
+ }, {
943
+ "tags": [],
944
+ "text": ""
945
+ }],
946
+ "references": {
947
+ "Promise": {
948
+ "location": "global"
949
+ },
950
+ "TttxSelectBox": {
951
+ "location": "import",
952
+ "path": "../tttx-select-box/tttx-select-box"
953
+ }
954
+ },
955
+ "return": "Promise<void>"
956
+ },
957
+ "docs": {
958
+ "text": "",
959
+ "tags": []
960
+ }
961
+ },
962
+ "setSelectedItem": {
963
+ "complexType": {
964
+ "signature": "(fieldname: string, id: string) => Promise<void>",
965
+ "parameters": [{
966
+ "tags": [],
967
+ "text": ""
968
+ }, {
969
+ "tags": [],
970
+ "text": ""
971
+ }],
972
+ "references": {
973
+ "Promise": {
974
+ "location": "global"
975
+ },
976
+ "TttxSelectBox": {
977
+ "location": "import",
978
+ "path": "../tttx-select-box/tttx-select-box"
979
+ }
980
+ },
981
+ "return": "Promise<void>"
982
+ },
983
+ "docs": {
984
+ "text": "",
985
+ "tags": []
986
+ }
987
+ },
988
+ "setSelectOptions": {
989
+ "complexType": {
990
+ "signature": "(fieldname: string, options: { label: string; value: string; disabled?: boolean; }[], skipDefultSelection?: boolean) => Promise<void>",
991
+ "parameters": [{
992
+ "tags": [{
993
+ "name": "param",
994
+ "text": "fieldname the form name of the given field"
995
+ }],
996
+ "text": "the form name of the given field"
997
+ }, {
998
+ "tags": [{
999
+ "name": "param",
1000
+ "text": "options a list of option values and labels"
1001
+ }],
1002
+ "text": "a list of option values and labels"
1003
+ }, {
1004
+ "tags": [],
1005
+ "text": ""
1006
+ }],
1007
+ "references": {
1008
+ "Promise": {
1009
+ "location": "global"
1010
+ },
1011
+ "TttxSelectBox": {
1012
+ "location": "import",
1013
+ "path": "../tttx-select-box/tttx-select-box"
1014
+ }
1015
+ },
1016
+ "return": "Promise<void>"
1017
+ },
1018
+ "docs": {
1019
+ "text": "Replace all children in a given select list with a list of new options",
1020
+ "tags": [{
1021
+ "name": "param",
1022
+ "text": "fieldname the form name of the given field"
1023
+ }, {
1024
+ "name": "param",
1025
+ "text": "options a list of option values and labels"
1026
+ }]
1027
+ }
1028
+ },
1029
+ "isValid": {
1030
+ "complexType": {
1031
+ "signature": "() => Promise<boolean>",
1032
+ "parameters": [],
1033
+ "references": {
1034
+ "Promise": {
1035
+ "location": "global"
1036
+ }
1037
+ },
1038
+ "return": "Promise<boolean>"
1039
+ },
1040
+ "docs": {
1041
+ "text": "",
1042
+ "tags": []
1043
+ }
1044
+ },
1045
+ "setValidationFor": {
1046
+ "complexType": {
1047
+ "signature": "(fieldName: string, message: string) => Promise<void>",
1048
+ "parameters": [{
1049
+ "tags": [{
1050
+ "name": "param",
1051
+ "text": "fieldName The form field name to apply the validation too"
1052
+ }],
1053
+ "text": "The form field name to apply the validation too"
1054
+ }, {
1055
+ "tags": [{
1056
+ "name": "param",
1057
+ "text": "message The validation message to display under the form field"
1058
+ }],
1059
+ "text": "The validation message to display under the form field"
1060
+ }],
1061
+ "references": {
1062
+ "Promise": {
1063
+ "location": "global"
1064
+ },
1065
+ "HTMLInputElement": {
1066
+ "location": "global"
1067
+ },
1068
+ "HTMLSelectElement": {
1069
+ "location": "global"
1070
+ }
1071
+ },
1072
+ "return": "Promise<void>"
1073
+ },
1074
+ "docs": {
1075
+ "text": "An external validation trigger to apply to a form field",
1076
+ "tags": [{
1077
+ "name": "param",
1078
+ "text": "fieldName The form field name to apply the validation too"
1079
+ }, {
1080
+ "name": "param",
1081
+ "text": "message The validation message to display under the form field"
1082
+ }]
1083
+ }
1084
+ },
1085
+ "clearValidationFor": {
1086
+ "complexType": {
1087
+ "signature": "(fieldName: string) => Promise<void>",
1088
+ "parameters": [{
1089
+ "tags": [{
1090
+ "name": "param",
1091
+ "text": "fieldName The form field name to clear the validation of"
1092
+ }],
1093
+ "text": "The form field name to clear the validation of"
1094
+ }],
1095
+ "references": {
1096
+ "Promise": {
1097
+ "location": "global"
1098
+ },
1099
+ "HTMLInputElement": {
1100
+ "location": "global"
1101
+ },
1102
+ "HTMLSelectElement": {
1103
+ "location": "global"
1104
+ }
1105
+ },
1106
+ "return": "Promise<void>"
1107
+ },
1108
+ "docs": {
1109
+ "text": "Clear the validation message on a given form field",
1110
+ "tags": [{
1111
+ "name": "param",
1112
+ "text": "fieldName The form field name to clear the validation of"
1113
+ }]
1114
+ }
1115
+ },
1116
+ "disableFormField": {
1117
+ "complexType": {
1118
+ "signature": "(fieldName: string) => Promise<void>",
1119
+ "parameters": [{
1120
+ "tags": [{
1121
+ "name": "param",
1122
+ "text": "fieldName The form field name to disable"
1123
+ }],
1124
+ "text": "The form field name to disable"
1125
+ }],
1126
+ "references": {
1127
+ "Promise": {
1128
+ "location": "global"
1129
+ },
1130
+ "HTMLInputElement": {
1131
+ "location": "global"
1132
+ },
1133
+ "HTMLSelectElement": {
1134
+ "location": "global"
1135
+ }
1136
+ },
1137
+ "return": "Promise<void>"
1138
+ },
1139
+ "docs": {
1140
+ "text": "Disable a form field and visually remove it from the form.\nIf custom validation is set, this function will return without affecting the form field.",
1141
+ "tags": [{
1142
+ "name": "param",
1143
+ "text": "fieldName The form field name to disable"
1144
+ }]
1145
+ }
1146
+ },
1147
+ "enableFormField": {
1148
+ "complexType": {
1149
+ "signature": "(fieldName: string) => Promise<void>",
1150
+ "parameters": [{
1151
+ "tags": [{
1152
+ "name": "param",
1153
+ "text": "fieldName The form field name to enable"
1154
+ }],
1155
+ "text": "The form field name to enable"
1156
+ }],
1157
+ "references": {
1158
+ "Promise": {
1159
+ "location": "global"
1160
+ },
1161
+ "HTMLInputElement": {
1162
+ "location": "global"
1163
+ },
1164
+ "HTMLSelectElement": {
1165
+ "location": "global"
1166
+ }
1167
+ },
1168
+ "return": "Promise<void>"
1169
+ },
1170
+ "docs": {
1171
+ "text": "Enable a form field and visually add it back to the form.",
1172
+ "tags": [{
1173
+ "name": "param",
1174
+ "text": "fieldName The form field name to enable"
1175
+ }]
1176
+ }
1177
+ },
1178
+ "setInputFieldValue": {
1179
+ "complexType": {
1180
+ "signature": "(fieldName: string, fieldValue: string) => Promise<void>",
1181
+ "parameters": [{
1182
+ "tags": [{
1183
+ "name": "param",
1184
+ "text": "fieldName The form field name having it's value set"
1185
+ }],
1186
+ "text": "The form field name having it's value set"
1187
+ }, {
1188
+ "tags": [{
1189
+ "name": "param",
1190
+ "text": "fieldValue The form field value to set"
1191
+ }],
1192
+ "text": "The form field value to set"
1193
+ }],
1194
+ "references": {
1195
+ "Promise": {
1196
+ "location": "global"
1197
+ },
1198
+ "HTMLInputElement": {
1199
+ "location": "global"
1200
+ }
1201
+ },
1202
+ "return": "Promise<void>"
1203
+ },
1204
+ "docs": {
1205
+ "text": "Set the value of a form field progromatically",
1206
+ "tags": [{
1207
+ "name": "param",
1208
+ "text": "fieldName The form field name having it's value set"
1209
+ }, {
1210
+ "name": "param",
1211
+ "text": "fieldValue The form field value to set"
1212
+ }]
1213
+ }
1214
+ },
1215
+ "setFieldReadOnlyMode": {
1216
+ "complexType": {
1217
+ "signature": "(fieldName: string, readonly: boolean) => Promise<void>",
1218
+ "parameters": [{
1219
+ "tags": [{
1220
+ "name": "param",
1221
+ "text": "fieldName The form field name to set"
1222
+ }],
1223
+ "text": "The form field name to set"
1224
+ }, {
1225
+ "tags": [{
1226
+ "name": "param",
1227
+ "text": "readonly The state of the read-only attribute"
1228
+ }],
1229
+ "text": "The state of the read-only attribute"
1230
+ }],
1231
+ "references": {
1232
+ "Promise": {
1233
+ "location": "global"
1234
+ },
1235
+ "HTMLInputElement": {
1236
+ "location": "global"
1237
+ },
1238
+ "TttxSelectBox": {
1239
+ "location": "import",
1240
+ "path": "../tttx-select-box/tttx-select-box"
1241
+ }
1242
+ },
1243
+ "return": "Promise<void>"
1244
+ },
1245
+ "docs": {
1246
+ "text": "Change the readonly property on an input field. If set to 'true' any validation will also be cleared.",
1247
+ "tags": [{
1248
+ "name": "param",
1249
+ "text": "fieldName The form field name to set"
1250
+ }, {
1251
+ "name": "param",
1252
+ "text": "readonly The state of the read-only attribute"
1253
+ }]
1254
+ }
1255
+ }
1256
+ };
1257
+ }
1258
+ static get watchers() {
1259
+ return [{
1260
+ "propName": "formschema",
1261
+ "methodName": "onFormSchemaChange"
1262
+ }, {
1263
+ "propName": "data",
1264
+ "methodName": "onDataChange"
1265
+ }];
1266
+ }
1267
+ }