@zeedhi/common 3.0.0 → 3.0.2

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 (292) hide show
  1. package/coverage/clover.xml +2570 -1531
  2. package/coverage/coverage-final.json +171 -158
  3. package/coverage/lcov-report/block-navigation.js +1 -1
  4. package/coverage/lcov-report/index.html +194 -44
  5. package/coverage/lcov-report/sorter.js +21 -7
  6. package/coverage/lcov-report/src/components/index.html +5 -5
  7. package/coverage/lcov-report/src/components/index.ts.html +244 -142
  8. package/coverage/lcov-report/src/components/tek-grid/columns-searcher.ts.html +2 -2
  9. package/coverage/lcov-report/src/components/tek-grid/dynamic-filter-datasource-factory.ts.html +3 -3
  10. package/coverage/lcov-report/src/components/tek-grid/filter-helper.ts.html +3 -3
  11. package/coverage/lcov-report/src/components/tek-grid/grid-filter-button.ts.html +6 -6
  12. package/coverage/lcov-report/src/components/tek-grid/grouped-data-manager.ts.html +6 -6
  13. package/coverage/lcov-report/src/components/tek-grid/grouped-data-selector.ts.html +3 -3
  14. package/coverage/lcov-report/src/components/tek-grid/grouped-view-navigator.ts.html +3 -3
  15. package/coverage/lcov-report/src/components/tek-grid/index.html +1 -1
  16. package/coverage/lcov-report/src/components/tek-grid/index.ts.html +19 -19
  17. package/coverage/lcov-report/src/components/tek-grid/interfaces.ts.html +3 -3
  18. package/coverage/lcov-report/src/components/tek-grid/keymap-grouped.ts.html +2 -2
  19. package/coverage/lcov-report/src/components/tek-grid/layout-options.ts.html +6 -6
  20. package/coverage/lcov-report/src/components/tek-grid/tek-datasource/index.html +1 -1
  21. package/coverage/lcov-report/src/components/tek-grid/tek-datasource/index.ts.html +4 -4
  22. package/coverage/lcov-report/src/components/tek-grid/tek-datasource/interfaces.ts.html +3 -3
  23. package/coverage/lcov-report/src/components/tek-grid/tek-datasource/tek-memory-datasource.ts.html +5 -5
  24. package/coverage/lcov-report/src/components/tek-grid/tek-datasource/tek-rest-datasource.ts.html +5 -5
  25. package/coverage/lcov-report/src/components/tek-grid/tek-grid-column.ts.html +4 -4
  26. package/coverage/lcov-report/src/components/tek-grid/tek-grid-columns-button/index.html +1 -1
  27. package/coverage/lcov-report/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.ts.html +3 -3
  28. package/coverage/lcov-report/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.ts.html +6 -6
  29. package/coverage/lcov-report/src/components/tek-grid/tek-grid-controller.ts.html +2 -2
  30. package/coverage/lcov-report/src/components/tek-grid/tek-grid-events.ts.html +3 -3
  31. package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/export-options/button-option.ts.html +2 -2
  32. package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/export-options/index.html +1 -1
  33. package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/export-options/index.ts.html +4 -4
  34. package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.ts.html +2 -2
  35. package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/index.html +1 -1
  36. package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/index.ts.html +3 -3
  37. package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.ts.html +5 -5
  38. package/coverage/lcov-report/src/components/tek-grid/tek-grid.ts.html +22 -22
  39. package/coverage/lcov-report/src/components/zd-alert/alert.ts.html +3 -3
  40. package/coverage/lcov-report/src/components/zd-alert/index.html +1 -1
  41. package/coverage/lcov-report/src/components/zd-badge/badge.ts.html +3 -3
  42. package/coverage/lcov-report/src/components/zd-badge/index.html +1 -1
  43. package/coverage/lcov-report/src/components/zd-breadcrumbs/breadcrumbs.ts.html +3 -3
  44. package/coverage/lcov-report/src/components/zd-breadcrumbs/index.html +1 -1
  45. package/coverage/lcov-report/src/components/zd-button/button.ts.html +36 -36
  46. package/coverage/lcov-report/src/components/zd-button/index.html +1 -1
  47. package/coverage/lcov-report/src/components/zd-button-group/button-group.ts.html +113 -131
  48. package/coverage/lcov-report/src/components/zd-button-group/index.html +17 -17
  49. package/coverage/lcov-report/src/components/zd-card/card.ts.html +3 -3
  50. package/coverage/lcov-report/src/components/zd-card/index.html +1 -1
  51. package/coverage/lcov-report/src/components/zd-carousel/carousel.ts.html +3 -3
  52. package/coverage/lcov-report/src/components/zd-carousel/index.html +1 -1
  53. package/coverage/lcov-report/src/components/zd-checkbox/checkbox.ts.html +6 -6
  54. package/coverage/lcov-report/src/components/zd-checkbox/index.html +1 -1
  55. package/coverage/lcov-report/src/components/zd-checkbox-multiple/checkbox-multiple.ts.html +77 -122
  56. package/coverage/lcov-report/src/components/zd-checkbox-multiple/index.html +17 -17
  57. package/coverage/lcov-report/src/components/zd-chip/chip.ts.html +352 -0
  58. package/coverage/lcov-report/src/components/zd-chip/index.html +116 -0
  59. package/coverage/lcov-report/src/components/zd-code-viewer/code-viewer.ts.html +4 -4
  60. package/coverage/lcov-report/src/components/zd-code-viewer/index.html +1 -1
  61. package/coverage/lcov-report/src/components/zd-col/col.ts.html +3 -3
  62. package/coverage/lcov-report/src/components/zd-col/index.html +1 -1
  63. package/coverage/lcov-report/src/components/zd-collapse-card/collapse-card.ts.html +80 -68
  64. package/coverage/lcov-report/src/components/zd-collapse-card/index.html +1 -1
  65. package/coverage/lcov-report/src/components/zd-component/child-not-found.ts.html +2 -2
  66. package/coverage/lcov-report/src/components/zd-component/component-render.ts.html +5 -5
  67. package/coverage/lcov-report/src/components/zd-component/component.ts.html +117 -69
  68. package/coverage/lcov-report/src/components/zd-component/index.html +9 -9
  69. package/coverage/lcov-report/src/components/zd-container/container.ts.html +3 -3
  70. package/coverage/lcov-report/src/components/zd-container/index.html +1 -1
  71. package/coverage/lcov-report/src/components/zd-currency/currency.ts.html +259 -0
  72. package/coverage/lcov-report/src/components/zd-currency/index.html +116 -0
  73. package/coverage/lcov-report/src/components/zd-date-input/date-input.ts.html +113 -98
  74. package/coverage/lcov-report/src/components/zd-date-input/index.html +5 -5
  75. package/coverage/lcov-report/src/components/zd-date-range/date-range.ts.html +2059 -0
  76. package/coverage/lcov-report/src/components/zd-date-range/index.html +116 -0
  77. package/coverage/lcov-report/src/components/zd-dialog/dialog.ts.html +30 -30
  78. package/coverage/lcov-report/src/components/zd-dialog/index.html +1 -1
  79. package/coverage/lcov-report/src/components/zd-divider/divider.ts.html +3 -3
  80. package/coverage/lcov-report/src/components/zd-divider/index.html +1 -1
  81. package/coverage/lcov-report/src/components/zd-dropdown/dropdown.ts.html +3 -3
  82. package/coverage/lcov-report/src/components/zd-dropdown/index.html +1 -1
  83. package/coverage/lcov-report/src/components/zd-footer/footer.ts.html +3 -3
  84. package/coverage/lcov-report/src/components/zd-footer/index.html +1 -1
  85. package/coverage/lcov-report/src/components/zd-form/form.ts.html +288 -18
  86. package/coverage/lcov-report/src/components/zd-form/index.html +9 -9
  87. package/coverage/lcov-report/src/components/zd-frame/frame.ts.html +8 -8
  88. package/coverage/lcov-report/src/components/zd-frame/index.html +1 -1
  89. package/coverage/lcov-report/src/components/zd-frame-page/frame-page.ts.html +4 -4
  90. package/coverage/lcov-report/src/components/zd-frame-page/index.html +1 -1
  91. package/coverage/lcov-report/src/components/zd-grid/data-navigator.ts.html +3 -3
  92. package/coverage/lcov-report/src/components/zd-grid/data-selector.ts.html +3 -3
  93. package/coverage/lcov-report/src/components/zd-grid/grid-column.ts.html +10 -10
  94. package/coverage/lcov-report/src/components/zd-grid/grid-events.ts.html +4 -4
  95. package/coverage/lcov-report/src/components/zd-grid/grid.ts.html +84 -84
  96. package/coverage/lcov-report/src/components/zd-grid/index.html +1 -1
  97. package/coverage/lcov-report/src/components/zd-grid/index.ts.html +12 -12
  98. package/coverage/lcov-report/src/components/zd-grid/iterable-table.ts.html +6 -6
  99. package/coverage/lcov-report/src/components/zd-grid/keymap-merger.ts.html +14 -14
  100. package/coverage/lcov-report/src/components/zd-grid/keymap-navigation.ts.html +3 -3
  101. package/coverage/lcov-report/src/components/zd-grid/table-action-builder.ts.html +5 -5
  102. package/coverage/lcov-report/src/components/zd-grid/view-navigator.ts.html +3 -3
  103. package/coverage/lcov-report/src/components/zd-grid-editable/data-editor-with-add.ts.html +6 -6
  104. package/coverage/lcov-report/src/components/zd-grid-editable/data-editor.ts.html +7 -7
  105. package/coverage/lcov-report/src/components/zd-grid-editable/errors/index.html +1 -1
  106. package/coverage/lcov-report/src/components/zd-grid-editable/errors/index.ts.html +3 -3
  107. package/coverage/lcov-report/src/components/zd-grid-editable/errors/not-editing.ts.html +2 -2
  108. package/coverage/lcov-report/src/components/zd-grid-editable/errors/row-not-found.ts.html +2 -2
  109. package/coverage/lcov-report/src/components/zd-grid-editable/grid-column-editable.ts.html +3 -3
  110. package/coverage/lcov-report/src/components/zd-grid-editable/grid-editable-controller.ts.html +2 -2
  111. package/coverage/lcov-report/src/components/zd-grid-editable/grid-editable-events.ts.html +2 -2
  112. package/coverage/lcov-report/src/components/zd-grid-editable/grid-editable.ts.html +9 -9
  113. package/coverage/lcov-report/src/components/zd-grid-editable/index.html +1 -1
  114. package/coverage/lcov-report/src/components/zd-grid-editable/index.ts.html +8 -8
  115. package/coverage/lcov-report/src/components/zd-grid-editable/keymap-editing.ts.html +2 -2
  116. package/coverage/lcov-report/src/components/zd-header/header.ts.html +3 -3
  117. package/coverage/lcov-report/src/components/zd-header/index.html +1 -1
  118. package/coverage/lcov-report/src/components/zd-icon/icon.ts.html +3 -3
  119. package/coverage/lcov-report/src/components/zd-icon/index.html +1 -1
  120. package/coverage/lcov-report/src/components/zd-image/image.ts.html +3 -3
  121. package/coverage/lcov-report/src/components/zd-image/index.html +1 -1
  122. package/coverage/lcov-report/src/components/zd-increment/increment.ts.html +436 -0
  123. package/coverage/lcov-report/src/components/zd-increment/index.html +116 -0
  124. package/coverage/lcov-report/src/components/zd-input/index.html +5 -5
  125. package/coverage/lcov-report/src/components/zd-input/input-factory.ts.html +4 -4
  126. package/coverage/lcov-report/src/components/zd-input/input.ts.html +73 -61
  127. package/coverage/lcov-report/src/components/zd-iterable/column-not-found.ts.html +2 -2
  128. package/coverage/lcov-report/src/components/zd-iterable/column.ts.html +6 -6
  129. package/coverage/lcov-report/src/components/zd-iterable/conditions-manager.ts.html +9 -9
  130. package/coverage/lcov-report/src/components/zd-iterable/index.html +1 -1
  131. package/coverage/lcov-report/src/components/zd-iterable/iterable-columns-button-controller.ts.html +2 -2
  132. package/coverage/lcov-report/src/components/zd-iterable/iterable-columns-button.ts.html +6 -6
  133. package/coverage/lcov-report/src/components/zd-iterable/iterable-controller.ts.html +4 -4
  134. package/coverage/lcov-report/src/components/zd-iterable/iterable-page-component.ts.html +5 -5
  135. package/coverage/lcov-report/src/components/zd-iterable/iterable-page-info.ts.html +3 -3
  136. package/coverage/lcov-report/src/components/zd-iterable/iterable-page-size.ts.html +5 -5
  137. package/coverage/lcov-report/src/components/zd-iterable/iterable-pagination.ts.html +3 -3
  138. package/coverage/lcov-report/src/components/zd-iterable/iterable.ts.html +29 -29
  139. package/coverage/lcov-report/src/components/zd-iterable/search.ts.html +8 -8
  140. package/coverage/lcov-report/src/components/zd-iterable-component-render/index.html +1 -1
  141. package/coverage/lcov-report/src/components/zd-iterable-component-render/iterable-component-render.ts.html +5 -5
  142. package/coverage/lcov-report/src/components/zd-layout/index.html +1 -1
  143. package/coverage/lcov-report/src/components/zd-layout/layout.ts.html +3 -3
  144. package/coverage/lcov-report/src/components/zd-list/index.html +1 -1
  145. package/coverage/lcov-report/src/components/zd-list/item-not-found.ts.html +2 -2
  146. package/coverage/lcov-report/src/components/zd-list/list-group.ts.html +4 -4
  147. package/coverage/lcov-report/src/components/zd-list/list-item.ts.html +3 -3
  148. package/coverage/lcov-report/src/components/zd-list/list.ts.html +4 -4
  149. package/coverage/lcov-report/src/components/zd-loading/index.html +1 -1
  150. package/coverage/lcov-report/src/components/zd-loading/loading.ts.html +3 -3
  151. package/coverage/lcov-report/src/components/zd-login/index.html +1 -1
  152. package/coverage/lcov-report/src/components/zd-login/login-button.ts.html +4 -4
  153. package/coverage/lcov-report/src/components/zd-login/login.ts.html +3 -3
  154. package/coverage/lcov-report/src/components/zd-main/index.html +1 -1
  155. package/coverage/lcov-report/src/components/zd-main/main.ts.html +3 -3
  156. package/coverage/lcov-report/src/components/zd-master-detail/detail-not-found.ts.html +118 -0
  157. package/coverage/lcov-report/src/components/zd-master-detail/index.html +146 -0
  158. package/coverage/lcov-report/src/components/zd-master-detail/master-detail.ts.html +331 -0
  159. package/coverage/lcov-report/src/components/zd-master-detail/master-not-found.ts.html +118 -0
  160. package/coverage/lcov-report/src/components/zd-menu/index.html +1 -1
  161. package/coverage/lcov-report/src/components/zd-menu/menu-button.ts.html +4 -4
  162. package/coverage/lcov-report/src/components/zd-menu/menu-group.ts.html +3 -3
  163. package/coverage/lcov-report/src/components/zd-menu/menu-link.ts.html +3 -3
  164. package/coverage/lcov-report/src/components/zd-menu/menu-separator.ts.html +3 -3
  165. package/coverage/lcov-report/src/components/zd-menu/menu.ts.html +4 -4
  166. package/coverage/lcov-report/src/components/zd-modal/index.html +1 -1
  167. package/coverage/lcov-report/src/components/zd-modal/modal-close-button.ts.html +4 -4
  168. package/coverage/lcov-report/src/components/zd-modal/modal.ts.html +5 -5
  169. package/coverage/lcov-report/src/components/zd-month/index.html +116 -0
  170. package/coverage/lcov-report/src/components/zd-month/month.ts.html +568 -0
  171. package/coverage/lcov-report/src/components/zd-number-input/index.html +1 -1
  172. package/coverage/lcov-report/src/components/zd-number-input/number-input.ts.html +27 -27
  173. package/coverage/lcov-report/src/components/zd-password/index.html +1 -1
  174. package/coverage/lcov-report/src/components/zd-password/password.ts.html +7 -7
  175. package/coverage/lcov-report/src/components/zd-progress/index.html +116 -0
  176. package/coverage/lcov-report/src/components/zd-progress/progress.ts.html +262 -0
  177. package/coverage/lcov-report/src/components/zd-radio/index.html +1 -1
  178. package/coverage/lcov-report/src/components/zd-radio/radio.ts.html +6 -6
  179. package/coverage/lcov-report/src/components/zd-row/index.html +1 -1
  180. package/coverage/lcov-report/src/components/zd-row/row.ts.html +3 -3
  181. package/coverage/lcov-report/src/components/zd-select/index.html +1 -1
  182. package/coverage/lcov-report/src/components/zd-select/select.ts.html +9 -9
  183. package/coverage/lcov-report/src/components/zd-select-multiple/index.html +1 -1
  184. package/coverage/lcov-report/src/components/zd-select-multiple/select-multiple.ts.html +5 -5
  185. package/coverage/lcov-report/src/components/zd-svg-map/index.html +116 -0
  186. package/coverage/lcov-report/src/components/zd-svg-map/svg-map.ts.html +475 -0
  187. package/coverage/lcov-report/src/components/zd-switch/index.html +1 -1
  188. package/coverage/lcov-report/src/components/zd-switch/switch.ts.html +5 -5
  189. package/coverage/lcov-report/src/components/zd-table/index.html +1 -1
  190. package/coverage/lcov-report/src/components/zd-table/table.ts.html +4 -4
  191. package/coverage/lcov-report/src/components/zd-tabs/index.html +1 -1
  192. package/coverage/lcov-report/src/components/zd-tabs/tab-not-found.ts.html +2 -2
  193. package/coverage/lcov-report/src/components/zd-tabs/tab.ts.html +5 -5
  194. package/coverage/lcov-report/src/components/zd-tabs/tabs.ts.html +7 -7
  195. package/coverage/lcov-report/src/components/zd-tag/index.html +1 -1
  196. package/coverage/lcov-report/src/components/zd-tag/tag.ts.html +3 -3
  197. package/coverage/lcov-report/src/components/zd-text/index.html +1 -1
  198. package/coverage/lcov-report/src/components/zd-text/text.ts.html +3 -3
  199. package/coverage/lcov-report/src/components/zd-text-input/index.html +1 -1
  200. package/coverage/lcov-report/src/components/zd-text-input/text-input.ts.html +22 -22
  201. package/coverage/lcov-report/src/components/zd-textarea/index.html +1 -1
  202. package/coverage/lcov-report/src/components/zd-textarea/textarea.ts.html +5 -5
  203. package/coverage/lcov-report/src/components/zd-time/index.html +131 -0
  204. package/coverage/lcov-report/src/components/zd-time/time-format-selector.ts.html +157 -0
  205. package/coverage/lcov-report/src/components/zd-time/time.ts.html +1669 -0
  206. package/coverage/lcov-report/src/components/zd-toggleable/index.html +1 -1
  207. package/coverage/lcov-report/src/components/zd-toggleable/toggleable.ts.html +3 -3
  208. package/coverage/lcov-report/src/components/zd-tooltip/index.html +1 -1
  209. package/coverage/lcov-report/src/components/zd-tooltip/tooltip.ts.html +3 -3
  210. package/coverage/lcov-report/src/components/zd-tree/index.html +116 -0
  211. package/coverage/lcov-report/src/components/zd-tree/tree.ts.html +1849 -0
  212. package/coverage/lcov-report/src/components/zd-tree-grid/index.html +1 -1
  213. package/coverage/lcov-report/src/components/zd-tree-grid/index.ts.html +7 -7
  214. package/coverage/lcov-report/src/components/zd-tree-grid/iterable-tree.ts.html +9 -9
  215. package/coverage/lcov-report/src/components/zd-tree-grid/keymap-tree.ts.html +3 -3
  216. package/coverage/lcov-report/src/components/zd-tree-grid/tree-data-navigator.ts.html +5 -5
  217. package/coverage/lcov-report/src/components/zd-tree-grid/tree-data-selector.ts.html +5 -5
  218. package/coverage/lcov-report/src/components/zd-tree-grid/tree-grid.ts.html +108 -108
  219. package/coverage/lcov-report/src/error/delete-rows.ts.html +3 -3
  220. package/coverage/lcov-report/src/error/index.html +1 -1
  221. package/coverage/lcov-report/src/error/non-initialized.ts.html +3 -3
  222. package/coverage/lcov-report/src/error/tek-grid-delete-rows.ts.html +3 -3
  223. package/coverage/lcov-report/src/error/teknisa-common-error.ts.html +2 -2
  224. package/coverage/lcov-report/src/error/zeedhi-error.ts.html +3 -3
  225. package/coverage/lcov-report/src/index.html +1 -1
  226. package/coverage/lcov-report/src/index.ts.html +9 -27
  227. package/coverage/lcov-report/src/services/index.html +1 -1
  228. package/coverage/lcov-report/src/services/index.ts.html +5 -5
  229. package/coverage/lcov-report/src/services/zd-alert/alert-queue.ts.html +3 -3
  230. package/coverage/lcov-report/src/services/zd-alert/alert-replace.ts.html +3 -3
  231. package/coverage/lcov-report/src/services/zd-alert/alert-service.ts.html +5 -5
  232. package/coverage/lcov-report/src/services/zd-alert/alert-stack.ts.html +3 -3
  233. package/coverage/lcov-report/src/services/zd-alert/index.html +1 -1
  234. package/coverage/lcov-report/src/services/zd-alert/index.ts.html +6 -6
  235. package/coverage/lcov-report/src/services/zd-dialog/dialog-service.ts.html +4 -4
  236. package/coverage/lcov-report/src/services/zd-dialog/index.html +1 -1
  237. package/coverage/lcov-report/src/services/zd-loading/index.html +1 -1
  238. package/coverage/lcov-report/src/services/zd-loading/loading-service.ts.html +2 -2
  239. package/coverage/lcov-report/src/services/zd-modal/index.html +1 -1
  240. package/coverage/lcov-report/src/services/zd-modal/modal-service.ts.html +5 -5
  241. package/coverage/lcov-report/src/utils/data-value-out/data-value-out.ts.html +3 -3
  242. package/coverage/lcov-report/src/utils/data-value-out/index.html +1 -1
  243. package/coverage/lcov-report/src/utils/data-value-out/index.ts.html +3 -3
  244. package/coverage/lcov-report/src/utils/datasource-searcher/datasource-searcher.ts.html +3 -3
  245. package/coverage/lcov-report/src/utils/datasource-searcher/index.html +1 -1
  246. package/coverage/lcov-report/src/utils/datasource-searcher/index.ts.html +3 -3
  247. package/coverage/lcov-report/src/utils/icons/icons.ts.html +6 -6
  248. package/coverage/lcov-report/src/utils/icons/index.html +1 -1
  249. package/coverage/lcov-report/src/utils/index.html +1 -1
  250. package/coverage/lcov-report/src/utils/index.ts.html +11 -11
  251. package/coverage/lcov-report/src/utils/is-filled-object/index.html +1 -1
  252. package/coverage/lcov-report/src/utils/is-filled-object/is-filled-object.ts.html +3 -3
  253. package/coverage/lcov-report/src/utils/is-nil.ts.html +2 -2
  254. package/coverage/lcov-report/src/utils/omit/index.html +1 -1
  255. package/coverage/lcov-report/src/utils/omit/omit.ts.html +2 -2
  256. package/coverage/lcov-report/src/utils/theme/index.html +1 -1
  257. package/coverage/lcov-report/src/utils/theme/theme.ts.html +4 -4
  258. package/coverage/lcov-report/src/utils/tree-data-structure/index.html +7 -7
  259. package/coverage/lcov-report/src/utils/tree-data-structure/index.ts.html +3 -3
  260. package/coverage/lcov-report/src/utils/tree-data-structure/tree-data-structure.ts.html +90 -87
  261. package/coverage/lcov-report/src/utils/unique-by/index.html +1 -1
  262. package/coverage/lcov-report/src/utils/unique-by/unique-by.ts.html +3 -3
  263. package/coverage/lcov-report/tests/unit/components/zd-component/ComponentMock.ts.html +1 -1
  264. package/coverage/lcov-report/tests/unit/components/zd-component/index.html +1 -1
  265. package/coverage/lcov.info +3991 -2050
  266. package/dist/types/components/index.d.ts +2 -0
  267. package/dist/types/components/zd-date-range/date-range.d.ts +152 -0
  268. package/dist/types/components/zd-date-range/interfaces.d.ts +18 -0
  269. package/dist/types/components/zd-form/form.d.ts +15 -0
  270. package/dist/types/components/zd-form/interfaces.d.ts +3 -0
  271. package/dist/types/components/zd-input/input.d.ts +2 -0
  272. package/dist/types/components/zd-input/interfaces.d.ts +2 -0
  273. package/dist/types/components/zd-time/interfaces.d.ts +1 -1
  274. package/dist/types/components/zd-time/time.d.ts +6 -6
  275. package/dist/types/index.d.ts +1 -1
  276. package/dist/zd-common.js +634 -23
  277. package/dist/zd-common.min.js +634 -23
  278. package/package.json +3 -3
  279. package/src/components/index.ts +7 -5
  280. package/src/components/zd-date-range/date-range.ts +658 -0
  281. package/src/components/zd-date-range/interfaces.ts +19 -0
  282. package/src/components/zd-form/form.ts +91 -1
  283. package/src/components/zd-form/interfaces.ts +3 -0
  284. package/src/components/zd-input/input.ts +4 -0
  285. package/src/components/zd-input/interfaces.ts +2 -0
  286. package/src/components/zd-time/interfaces.ts +16 -16
  287. package/src/components/zd-time/time-format-selector.ts +13 -13
  288. package/src/components/zd-time/time.ts +510 -488
  289. package/src/index.ts +1 -8
  290. package/tests/unit/components/zd-date-range/date-range.spec.ts +1125 -0
  291. package/tests/unit/components/zd-form/form.spec.ts +30 -0
  292. package/tests/unit/components/zd-menu/menu-button.spec.ts +1 -1
@@ -1,506 +1,528 @@
1
- import {
2
- Config, FormatterParserProvider, I18n, dayjs, Mask,
3
- } from '@zeedhi/core';
1
+ import { Config, FormatterParserProvider, I18n, Mask, dayjs } from '@zeedhi/core';
4
2
  import isUndefined from 'lodash.isundefined';
5
- import { ITime } from './interfaces';
3
+ import { InputFactory } from '../zd-input/input-factory';
6
4
  import { TextInput } from '../zd-text-input/text-input';
5
+ import { ITime } from './interfaces';
7
6
  import { TimeFormatSelector } from './time-format-selector';
8
- import { InputFactory } from '../zd-input/input-factory';
9
7
 
10
8
  /**
11
9
  * Base class for Time Picker component.
12
10
  */
13
11
  export class Time extends TextInput implements ITime {
14
- /**
15
- * Restricts which hours can be selected.
16
- */
17
- public allowedHours?: any[];
18
-
19
- /**
20
- * Restricts which minutes can be selected.
21
- */
22
- public allowedMinutes?: any[];
23
-
24
- /**
25
- * Restricts which seconds can be selected.
26
- */
27
- public allowedSeconds?: any[];
28
-
29
- /**
30
- * Input auto complete.
31
- */
32
- public autofill = false;
33
-
34
- /**
35
- * Defines the format of a time displayed in picker. Available options are ampm and 24hr.
36
- */
37
- public timeFormat: string = Config.timeFormat || 'ampm'; // change props to pickerFormat
38
-
39
- /**
40
- * Forces 100% width.
41
- */
42
- public fullWidth = false;
43
-
44
- /**
45
- * Maximum allowed time.
46
- */
47
- public maxTime = '';
48
-
49
- /**
50
- * Minimum allowed time.
51
- */
52
- public minTime = '';
53
-
54
- /**
55
- * Allows changing hour/minute with mouse scroll.
56
- */
57
- public scrollable = false;
58
-
59
- /**
60
- * Shows the time picker.
61
- */
62
- public showTimePicker = false;
63
-
64
- /**
65
- * Toggles the use of seconds in picker.
66
- */
67
- public useSeconds = false;
68
-
69
- /**
70
- * Width of the picker.
71
- */
72
- public width: number | string = 290;
73
-
74
- protected formatterFn = FormatterParserProvider.getFormatter('ZdTime');
75
-
76
- protected parserFn = FormatterParserProvider.getParser('ZdTime');
77
-
78
- private isoFormatValue = 'HH:mm';
79
-
80
- private valueFormatInternal: string = Config.valueTimeFormat;
81
-
82
- private displayFormatInternal: string = Config.displayTimeFormat;
83
-
84
- /**
85
- * Defines the time input format.
86
- */
87
- public inputFormat?: string = Config.timeInputFormat;
88
-
89
- /**
90
- * True when displayValue is valid
91
- */
92
- protected isDisplayValid = true;
93
-
94
- protected initialMask?: string;
95
-
96
- protected isSimpleDisplay!: boolean;
97
-
98
- protected timeError = false;
99
-
100
- /**
101
- * Create a new Time Picker.
102
- * @param props Time properties
103
- */
104
- constructor(props: ITime) {
105
- super(props);
106
- this.allowedHours = this.getInitValue('allowedHours', props.allowedHours, this.allowedHours);
107
- this.allowedMinutes = this.getInitValue('allowedMinutes', props.allowedMinutes, this.allowedMinutes);
108
- this.allowedSeconds = this.getInitValue('allowedSeconds', props.allowedSeconds, this.allowedSeconds);
109
- this.timeFormat = this.getInitValue('timeFormat', props.timeFormat, this.timeFormat);
110
- this.fullWidth = this.getInitValue('fullWidth', props.fullWidth, this.fullWidth);
111
- this.maxTime = this.getInitValue('maxTime', props.maxTime, this.maxTime);
112
- this.minTime = this.getInitValue('minTime', props.minTime, this.minTime);
113
- this.scrollable = this.getInitValue('scrollable', props.scrollable, this.scrollable);
114
- this.showTimePicker = this.getInitValue('showTimePicker', props.showTimePicker, this.showTimePicker);
115
- this.useSeconds = this.getInitValue('useSeconds', props.useSeconds, this.useSeconds);
116
- this.width = this.getInitValue('width', props.width, this.width);
117
- this.autofill = this.getInitValue('autofill', props.autofill, this.autofill);
118
- this.timeValidation = this.timeValidation.bind(this);
119
-
120
- this.valueFormat = this.getInitValue('valueFormat', props.valueFormat, this.valueFormatInternal);
121
- this.displayFormat = this.getInitValue('displayFormat', props.displayFormat, this.displayFormatInternal);
122
- this.inputFormat = this.getInitValue('inputFormat', props.inputFormat, this.inputFormat);
123
-
124
- this.timeAllowedValidation = this.timeAllowedValidation.bind(this);
125
- this.rules.push(this.timeValidation, this.timeAllowedValidation);
126
- this.mask = this.getInitValue('mask', props.mask, undefined);
127
-
128
- this.initialMask = this.getInitialMask();
129
- this.isSimpleDisplay = this.isSimpleFormat(this.displayFormat);
130
- }
131
-
132
- private getFormat(format: string, timeFormat: string) {
133
- const timeFormatSelector = new TimeFormatSelector();
134
- const selectedFormat = timeFormatSelector.getFormat(format, timeFormat, this.useSeconds);
135
-
136
- return selectedFormat;
137
- }
138
-
139
- public get displayFormat() {
140
- this.displayFormatInternal = this.getFormat(this.displayFormatInternal, this.timeFormat);
141
- return this.displayFormatInternal;
142
- }
143
-
144
- public set displayFormat(value: string) {
145
- this.displayFormatInternal = value;
146
- }
147
-
148
- public get valueFormat() {
149
- this.valueFormatInternal = this.getFormat(this.valueFormatInternal, '24hr');
150
- return this.valueFormatInternal;
151
- }
152
-
153
- public set valueFormat(value: string) {
154
- this.valueFormatInternal = value;
155
- }
156
-
157
- private get isoFormat() {
158
- this.isoFormatValue = this.useSeconds ? 'HH:mm:ss' : 'HH:mm';
159
- return this.isoFormatValue;
160
- }
161
-
162
- private getInitialMask() {
163
- if (isUndefined(this.mask)) {
164
- this.mask = this.inputFormat && this.maskFormat(this.inputFormat);
165
- }
166
-
167
- return this.mask;
168
- }
169
-
170
- public formatter(value: string): string { return this.formatterFn(value, this); }
171
-
172
- public parser(value: string): any { return this.parserFn(value, this); }
173
-
174
- /**
175
- * Triggered when date is clicked.
176
- * @param event
177
- * @param element
178
- */
179
- public selectTime(time: string, event?: Event, element?: any) {
180
- if (this.events.onSelectTime && typeof this.events.onSelectTime === 'function') {
181
- this.events.onSelectTime({
182
- time, event, element, component: this,
183
- });
184
- }
185
- }
186
-
187
- get displayValue() {
188
- return this.internalDisplayValue;
189
- }
190
-
191
- set displayValue(newValue: string) {
192
- this.timeError = false;
193
- this.internalDisplayValue = newValue;
194
- this.internalValue = this.parser(newValue);
195
- this.value = this.internalValue; // forces value accessor to be called if necessary
196
- }
197
-
198
- /**
199
- * Assign the updated mask to mask property
200
- */
201
- public updateMask() {
202
- this.isSimpleDisplay = this.isSimpleFormat(this.displayFormat);
203
- this.mask = this.getUpdatedMask();
204
- return this.mask;
205
- }
206
-
207
- /**
208
- * Gets the updated masked, based on displayFormat if the initial mask is undefined
209
- */
210
- protected getUpdatedMask(): string {
211
- if (isUndefined(this.initialMask)) {
212
- return this.maskFormat(this.displayFormat);
213
- }
214
-
215
- return this.mask;
216
- }
217
-
218
- protected maskFormat(format: string) {
219
- return format.replace(/[A-Za-z]/gi, '#');
220
- }
221
-
222
- public setTimeValue(displayValue: string) {
223
- const lastValue = this.displayValue;
224
- if (this.isValidTime(displayValue, this.displayFormat)) {
225
- this.internalDisplayValue = displayValue;
226
- this.internalValue = this.parser(displayValue);
227
- this.timeError = false;
228
- if (lastValue !== this.displayValue) this.change(this.value);
229
- } else {
230
- if (!displayValue) {
231
- this.internalDisplayValue = displayValue;
232
- this.internalValue = null;
233
- if (lastValue !== this.displayValue) this.change(this.value);
234
- }
235
- this.timeError = !!displayValue;
236
- }
237
- this.value = this.internalValue; // forces value accessor to be called if necessary
238
- }
239
-
240
- public isValidTime(value: string, format: string | undefined, strict = true): boolean {
241
- return dayjs(value, format, strict).isValid();
242
- }
243
-
244
- get isoValue() {
245
- return this.formatISOTimeValue(this.value);
246
- }
247
-
248
- set isoValue(newValue: string) {
249
- const lastValue = this.value;
250
- this.timeError = false;
251
- this.value = this.parseISOTimeValue(newValue);
252
- if (lastValue !== this.value) this.change(this.value);
253
- }
254
-
255
- public formatISOTimeValue(value: string): string {
256
- if (value && this.isValidTime(value, this.valueFormat)) {
257
- return dayjs(value, this.valueFormat).format(this.isoFormat);
258
- }
259
- return '';
260
- }
261
-
262
- public parseISOTimeValue(value: string): any {
263
- if (value && this.isValidTime(value, this.valueFormat)) {
264
- return dayjs(value, this.isoFormat).format(this.valueFormat);
265
- }
266
- return null;
267
- }
268
-
269
- /**
270
- * Checks if a time format is simple.
271
- * Simple time formats are the ones that consists only of 'HH', 'mm', 'mm' or 'YYYY', and mask delimiters
272
- * @param format The format to be checked
273
- * @returns true if it is simple, false otherwise
274
- */
275
- protected isSimpleFormat(format: string): boolean {
276
- const simpleTokens = ['HH', 'mm', 'ss', 'hh', 'A', 'a', 'p', 'P'];
277
- // remove the simple tokens from the string
278
- const replaced = simpleTokens.reduce((result, token) => result.replace(token, ''), format);
279
- const chars = replaced.split('');
280
- return chars.length ? chars.every((char) => Mask.isMaskDelimiter(char)) : true;
281
- }
282
-
283
- public timeValidation(): boolean | string {
284
- if (this.isValidTime(this.displayValue, this.displayFormat) || !this.displayValue) {
285
- return true;
286
- }
287
- return I18n.translate('VALIDATION_INVALID_TIME');
288
- }
289
-
290
- public timeAllowedValidation(): boolean | string {
291
- return !this.displayValue
292
- || (
293
- this.isValidTime(this.displayValue, this.displayFormat)
294
- && this.isTimeAllowed()
295
- )
296
- || I18n.translate('VALIDATION_TIME_NOT_ALLOWED');
297
- }
298
-
299
- public click(event?: Event, element?: any) {
300
- const clickEvent = event || new MouseEvent('click');
301
- super.click(clickEvent, element);
302
- if (!clickEvent.defaultPrevented) {
303
- this.showTimePicker = !this.showTimePicker;
304
- }
305
- }
306
-
307
- public blur(event: Event, element: any) {
308
- this.removeTimeMask();
309
- this.setTimeValue(this.formatter(this.value));
310
- super.blur(event, element);
311
- }
312
-
313
- public focus(event: Event, element: any) {
314
- this.addTimeMask();
315
- super.focus(event, element);
316
- }
317
-
318
- /**
319
- * Add date mask
320
- */
321
- protected addTimeMask() {
322
- if (!this.value) return;
323
-
324
- this.mask = this.initialMask;
325
- this.internalDisplayValue = dayjs(this.value, this.valueFormat).format(this.inputFormat || this.displayFormat);
326
- }
327
-
328
- /**
329
- * Removes the component mask if value is valid
330
- */
331
- protected removeTimeMask() {
332
- if (
333
- isUndefined(this.initialMask) || !this.value || this.timeError
334
- || !this.isValidTime(this.value, this.valueFormat)
335
- ) {
336
- return;
337
- }
338
-
339
- this.mask = '';
340
- }
341
-
342
- /**
343
- * Checks if value is valid according to valueFormat and if displayValue
344
- * is true
345
- */
346
- public isFullyValid(value: string = this.value) {
347
- return this.isValidTime(value, this.valueFormat, true) && this.isDisplayValid;
348
- }
349
-
350
- /**
351
- * Last invalid value passed to formatter
352
- */
353
- // private lastInvalid: string = '';
354
-
355
- public isTimeAllowed(value: string = this.value) {
356
- return this.isSameOrAfterMin(value) && this.isSameOrBeforeMax(value)
357
- && this.isHourAllowed(value) && this.isMinuteAllowed(value)
358
- && this.isSecondAllowed(value);
359
- }
360
-
361
- public isSameOrAfterMin(value: string) {
362
- if (!this.minTime) return true;
363
-
364
- const min = dayjs(this.minTime, this.valueFormat);
365
- return dayjs(value, this.valueFormat).isSame(min) || dayjs(value, this.valueFormat).isAfter(min);
366
- }
367
-
368
- public isSameOrBeforeMax(value: string) {
369
- if (!this.maxTime) return true;
370
-
371
- const max = dayjs(this.maxTime, this.valueFormat);
372
- return dayjs(value, this.valueFormat).isSame(max) || dayjs(value, this.valueFormat).isBefore(max);
373
- }
374
-
375
- public isHourAllowed(value: string) {
376
- if (!this.allowedHours) return true;
377
-
378
- const hour = dayjs(value, this.valueFormat).hour();
379
-
380
- return this.allowedHours.includes(hour);
381
- }
382
-
383
- public isMinuteAllowed(value: string) {
384
- if (!this.allowedMinutes) return true;
385
-
386
- const minute = dayjs(value, this.valueFormat).minute();
387
-
388
- return this.allowedMinutes.includes(minute);
389
- }
390
-
391
- public isSecondAllowed(value: string) {
392
- if (!this.allowedSeconds) return true;
393
-
394
- const second = dayjs(value, this.valueFormat).second();
395
-
396
- return this.allowedSeconds.includes(second);
397
- }
398
-
399
- public clear() {
400
- this.value = null;
401
- this.change(this.value);
402
- if (typeof this.events?.onClear === 'function') {
403
- this.events.onClear({
404
- component: this,
405
- value: this.value,
406
- });
407
- }
408
- }
409
- /**
12
+ /**
13
+ * Restricts which hours can be selected.
14
+ */
15
+ public allowedHours?: any[];
16
+
17
+ /**
18
+ * Restricts which minutes can be selected.
19
+ */
20
+ public allowedMinutes?: any[];
21
+
22
+ /**
23
+ * Restricts which seconds can be selected.
24
+ */
25
+ public allowedSeconds?: any[];
26
+
27
+ /**
28
+ * Input auto complete.
29
+ */
30
+ public autofill = false;
31
+
32
+ /**
33
+ * Defines the format of a time displayed in picker. Available options are ampm and 24hr.
34
+ */
35
+ public timeFormat: string = Config.timeFormat || 'ampm'; // change props to pickerFormat
36
+
37
+ /**
38
+ * Forces 100% width.
39
+ */
40
+ public fullWidth = false;
41
+
42
+ /**
43
+ * Maximum allowed time.
44
+ */
45
+ public maxTime = '';
46
+
47
+ /**
48
+ * Minimum allowed time.
49
+ */
50
+ public minTime = '';
51
+
52
+ /**
53
+ * Allows changing hour/minute with mouse scroll.
54
+ */
55
+ public scrollable = false;
56
+
57
+ /**
58
+ * Shows the time picker.
59
+ */
60
+ public showTimePicker = false;
61
+
62
+ /**
63
+ * Toggles the use of seconds in picker.
64
+ */
65
+ public useSeconds = false;
66
+
67
+ /**
68
+ * Width of the picker.
69
+ */
70
+ public width: number | string = 290;
71
+
72
+ protected formatterFn = FormatterParserProvider.getFormatter('ZdTime');
73
+
74
+ protected parserFn = FormatterParserProvider.getParser('ZdTime');
75
+
76
+ private isoFormatValue = 'HH:mm';
77
+
78
+ private valueFormatInternal: string = Config.valueTimeFormat;
79
+
80
+ private displayFormatInternal: string = Config.displayTimeFormat;
81
+
82
+ /**
83
+ * Defines the time input format.
84
+ */
85
+ public inputFormat?: string = Config.timeInputFormat;
86
+
87
+ /**
88
+ * True when displayValue is valid
89
+ */
90
+ protected isDisplayValid = true;
91
+
92
+ protected initialMask?: string;
93
+
94
+ protected isSimpleDisplay!: boolean;
95
+
96
+ protected timeError = false;
97
+
98
+ /**
99
+ * Create a new Time Picker.
100
+ * @param props Time properties
101
+ */
102
+ constructor(props: ITime) {
103
+ super(props);
104
+ this.allowedHours = this.getInitValue('allowedHours', props.allowedHours, this.allowedHours);
105
+ this.allowedMinutes = this.getInitValue('allowedMinutes', props.allowedMinutes, this.allowedMinutes);
106
+ this.allowedSeconds = this.getInitValue('allowedSeconds', props.allowedSeconds, this.allowedSeconds);
107
+ this.timeFormat = this.getInitValue('timeFormat', props.timeFormat, this.timeFormat);
108
+ this.fullWidth = this.getInitValue('fullWidth', props.fullWidth, this.fullWidth);
109
+ this.maxTime = this.getInitValue('maxTime', props.maxTime, this.maxTime);
110
+ this.minTime = this.getInitValue('minTime', props.minTime, this.minTime);
111
+ this.scrollable = this.getInitValue('scrollable', props.scrollable, this.scrollable);
112
+ this.showTimePicker = this.getInitValue('showTimePicker', props.showTimePicker, this.showTimePicker);
113
+ this.useSeconds = this.getInitValue('useSeconds', props.useSeconds, this.useSeconds);
114
+ this.width = this.getInitValue('width', props.width, this.width);
115
+ this.autofill = this.getInitValue('autofill', props.autofill, this.autofill);
116
+ this.timeValidation = this.timeValidation.bind(this);
117
+
118
+ this.valueFormat = this.getInitValue('valueFormat', props.valueFormat, this.valueFormatInternal);
119
+ this.displayFormat = this.getInitValue('displayFormat', props.displayFormat, this.displayFormatInternal);
120
+ this.inputFormat = this.getInitValue('inputFormat', props.inputFormat, this.inputFormat);
121
+
122
+ this.timeAllowedValidation = this.timeAllowedValidation.bind(this);
123
+ this.rules.push(this.timeValidation, this.timeAllowedValidation);
124
+ this.mask = this.getInitValue('mask', props.mask, undefined);
125
+
126
+ this.initialMask = this.getInitialMask();
127
+ this.isSimpleDisplay = this.isSimpleFormat(this.displayFormat);
128
+ }
129
+
130
+ private getFormat(format: string, timeFormat: string) {
131
+ const timeFormatSelector = new TimeFormatSelector();
132
+ const selectedFormat = timeFormatSelector.getFormat(format, timeFormat, this.useSeconds);
133
+
134
+ return selectedFormat;
135
+ }
136
+
137
+ public get displayFormat() {
138
+ this.displayFormatInternal = this.getFormat(this.displayFormatInternal, this.timeFormat);
139
+ return this.displayFormatInternal;
140
+ }
141
+
142
+ public set displayFormat(value: string) {
143
+ this.displayFormatInternal = value;
144
+ }
145
+
146
+ public get valueFormat() {
147
+ this.valueFormatInternal = this.getFormat(this.valueFormatInternal, '24hr');
148
+ return this.valueFormatInternal;
149
+ }
150
+
151
+ public set valueFormat(value: string) {
152
+ this.valueFormatInternal = value;
153
+ }
154
+
155
+ private get isoFormat() {
156
+ this.isoFormatValue = this.useSeconds ? 'HH:mm:ss' : 'HH:mm';
157
+ return this.isoFormatValue;
158
+ }
159
+
160
+ private getInitialMask() {
161
+ if (isUndefined(this.mask)) {
162
+ this.mask = this.inputFormat && this.maskFormat(this.inputFormat);
163
+ }
164
+
165
+ return this.mask;
166
+ }
167
+
168
+ public formatter(value: string): string {
169
+ return this.formatterFn(value, this);
170
+ }
171
+
172
+ public parser(value: string): any {
173
+ return this.parserFn(value, this);
174
+ }
175
+
176
+ /**
177
+ * Triggered when date is clicked.
178
+ * @param event
179
+ * @param element
180
+ */
181
+ public selectTime(time: string, event?: Event, element?: any) {
182
+ if (this.events.onSelectTime && typeof this.events.onSelectTime === 'function') {
183
+ this.events.onSelectTime({
184
+ time,
185
+ event,
186
+ element,
187
+ component: this,
188
+ });
189
+ }
190
+ }
191
+
192
+ get displayValue() {
193
+ return this.internalDisplayValue;
194
+ }
195
+
196
+ set displayValue(newValue: string) {
197
+ this.timeError = false;
198
+ this.internalDisplayValue = newValue;
199
+ this.internalValue = this.parser(newValue);
200
+ this.value = this.internalValue; // forces value accessor to be called if necessary
201
+ }
202
+
203
+ /**
204
+ * Assign the updated mask to mask property
205
+ */
206
+ public updateMask() {
207
+ this.isSimpleDisplay = this.isSimpleFormat(this.displayFormat);
208
+ this.mask = this.getUpdatedMask();
209
+ return this.mask;
210
+ }
211
+
212
+ /**
213
+ * Gets the updated masked, based on displayFormat if the initial mask is undefined
214
+ */
215
+ protected getUpdatedMask(): string {
216
+ if (isUndefined(this.initialMask)) {
217
+ return this.maskFormat(this.displayFormat);
218
+ }
219
+
220
+ return this.mask;
221
+ }
222
+
223
+ protected maskFormat(format: string) {
224
+ return format.replace(/[A-Za-z]/gi, '#');
225
+ }
226
+
227
+ public setTimeValue(displayValue: string) {
228
+ const lastValue = this.displayValue;
229
+ if (this.isValidTime(displayValue, this.displayFormat)) {
230
+ this.internalDisplayValue = displayValue;
231
+ this.internalValue = this.parser(displayValue);
232
+ this.timeError = false;
233
+ if (lastValue !== this.displayValue) this.change(this.value);
234
+ } else {
235
+ if (!displayValue) {
236
+ this.internalDisplayValue = displayValue;
237
+ this.internalValue = null;
238
+ if (lastValue !== this.displayValue) this.change(this.value);
239
+ }
240
+ this.timeError = !!displayValue;
241
+ }
242
+ this.value = this.internalValue; // forces value accessor to be called if necessary
243
+ }
244
+
245
+ public isValidTime(value: string, format: string | undefined, strict = true): boolean {
246
+ return dayjs(value, format, strict).isValid();
247
+ }
248
+
249
+ get isoValue() {
250
+ return this.formatISOTimeValue(this.value);
251
+ }
252
+
253
+ set isoValue(newValue: string) {
254
+ const lastValue = this.value;
255
+ this.timeError = false;
256
+ this.value = this.parseISOTimeValue(newValue);
257
+ if (lastValue !== this.value) this.change(this.value);
258
+ }
259
+
260
+ public formatISOTimeValue(value: string): string {
261
+ if (value && this.isValidTime(value, this.valueFormat)) {
262
+ return dayjs(value, this.valueFormat).format(this.isoFormat);
263
+ }
264
+ return '';
265
+ }
266
+
267
+ public parseISOTimeValue(value: string): any {
268
+ if (value && this.isValidTime(value, this.valueFormat)) {
269
+ return dayjs(value, this.isoFormat).format(this.valueFormat);
270
+ }
271
+ return null;
272
+ }
273
+
274
+ /**
275
+ * Checks if a time format is simple.
276
+ * Simple time formats are the ones that consists only of 'HH', 'mm', 'mm' or 'YYYY', and mask delimiters
277
+ * @param format The format to be checked
278
+ * @returns true if it is simple, false otherwise
279
+ */
280
+ protected isSimpleFormat(format: string): boolean {
281
+ const simpleTokens = ['HH', 'mm', 'ss', 'hh', 'A', 'a', 'p', 'P'];
282
+ // remove the simple tokens from the string
283
+ const replaced = simpleTokens.reduce((result, token) => result.replace(token, ''), format);
284
+ const chars = replaced.split('');
285
+ return chars.length ? chars.every((char) => Mask.isMaskDelimiter(char)) : true;
286
+ }
287
+
288
+ public timeValidation(): boolean | string {
289
+ if (this.isValidTime(this.displayValue, this.displayFormat) || !this.displayValue) {
290
+ return true;
291
+ }
292
+ return I18n.translate('VALIDATION_INVALID_TIME');
293
+ }
294
+
295
+ public timeAllowedValidation(): boolean | string {
296
+ return (
297
+ !this.displayValue ||
298
+ (this.isValidTime(this.displayValue, this.displayFormat) && this.isTimeAllowed()) ||
299
+ I18n.translate('VALIDATION_TIME_NOT_ALLOWED')
300
+ );
301
+ }
302
+
303
+ public click(event?: Event, element?: any) {
304
+ const clickEvent = event || new MouseEvent('click');
305
+ super.click(clickEvent, element);
306
+ if (!clickEvent.defaultPrevented) {
307
+ this.showTimePicker = !this.showTimePicker;
308
+ }
309
+ }
310
+
311
+ public blur(event: Event, element: any) {
312
+ this.removeTimeMask();
313
+ this.setTimeValue(this.formatter(this.value));
314
+ super.blur(event, element);
315
+ }
316
+
317
+ public focus(event: Event, element: any) {
318
+ this.addTimeMask();
319
+ super.focus(event, element);
320
+ }
321
+
322
+ /**
323
+ * Add date mask
324
+ */
325
+ protected addTimeMask() {
326
+ if (!this.value) return;
327
+
328
+ this.mask = this.initialMask;
329
+ this.internalDisplayValue = dayjs(this.value, this.valueFormat).format(this.inputFormat || this.displayFormat);
330
+ }
331
+
332
+ /**
333
+ * Removes the component mask if value is valid
334
+ */
335
+ protected removeTimeMask() {
336
+ if (
337
+ isUndefined(this.initialMask) ||
338
+ !this.value ||
339
+ this.timeError ||
340
+ !this.isValidTime(this.value, this.valueFormat)
341
+ ) {
342
+ return;
343
+ }
344
+
345
+ this.mask = '';
346
+ }
347
+
348
+ /**
349
+ * Checks if value is valid according to valueFormat and if displayValue
350
+ * is true
351
+ */
352
+ public isFullyValid(value: string = this.value) {
353
+ return this.isValidTime(value, this.valueFormat, true) && this.isDisplayValid;
354
+ }
355
+
356
+ /**
357
+ * Last invalid value passed to formatter
358
+ */
359
+ // private lastInvalid: string = '';
360
+
361
+ public isTimeAllowed(value: string = this.value) {
362
+ return (
363
+ this.isSameOrAfterMin(value) &&
364
+ this.isSameOrBeforeMax(value) &&
365
+ this.isHourAllowed(value) &&
366
+ this.isMinuteAllowed(value) &&
367
+ this.isSecondAllowed(value)
368
+ );
369
+ }
370
+
371
+ public isSameOrAfterMin(value: string) {
372
+ if (!this.minTime) return true;
373
+
374
+ const min = dayjs(this.minTime, this.valueFormat);
375
+ return dayjs(value, this.valueFormat).isSame(min) || dayjs(value, this.valueFormat).isAfter(min);
376
+ }
377
+
378
+ public isSameOrBeforeMax(value: string) {
379
+ if (!this.maxTime) return true;
380
+
381
+ const max = dayjs(this.maxTime, this.valueFormat);
382
+ return dayjs(value, this.valueFormat).isSame(max) || dayjs(value, this.valueFormat).isBefore(max);
383
+ }
384
+
385
+ public isHourAllowed(value: string) {
386
+ if (!this.allowedHours) return true;
387
+
388
+ const hour = dayjs(value, this.valueFormat).hour();
389
+
390
+ return this.allowedHours.includes(hour);
391
+ }
392
+
393
+ public isMinuteAllowed(value: string) {
394
+ if (!this.allowedMinutes) return true;
395
+
396
+ const minute = dayjs(value, this.valueFormat).minute();
397
+
398
+ return this.allowedMinutes.includes(minute);
399
+ }
400
+
401
+ public isSecondAllowed(value: string) {
402
+ if (!this.allowedSeconds) return true;
403
+
404
+ const second = dayjs(value, this.valueFormat).second();
405
+
406
+ return this.allowedSeconds.includes(second);
407
+ }
408
+
409
+ public clear() {
410
+ this.value = null;
411
+ this.change(this.value);
412
+ if (typeof this.events?.onClear === 'function') {
413
+ this.events.onClear({
414
+ component: this,
415
+ value: this.value,
416
+ });
417
+ }
418
+ }
419
+ /**
410
420
  * Converts a date format to a mask
411
421
  */
412
422
  private toMask(format: string) {
413
423
  return format.replace(/[A-Za-z]/gi, '#'); // .split('').map((char: string) => (char === '#' ? /\d/ : char));
414
424
  }
415
425
 
416
- public getMask() {
417
- if (this.mask && !this.mask.includes('{{') && !this.mask.includes('}}')) {
418
- if (this.isFocused) {
419
- return this.toMask(this.displayFormat || '');
420
- }
421
- }
422
- return '';
423
- }
426
+ public getMask() {
427
+ if (this.mask && !this.mask.includes('{{') && !this.mask.includes('}}')) {
428
+ if (this.isFocused) {
429
+ return this.toMask(this.displayFormat || '');
430
+ }
431
+ }
432
+ return '';
433
+ }
424
434
  }
425
435
 
426
- FormatterParserProvider.registerFormatter('ZdTime', (value: string, {
427
- valueFormat = Config.valueTimeFormat,
428
- displayFormat = Config.displayTimeFormat,
429
- inputFormat = Config.timeInputFormat,
430
- timeFormat = Config.timeFormat || 'ampm',
431
- useSeconds = false,
432
- mask = '',
433
- initialMask,
434
- isSimpleDisplay = false,
435
- }: any = {}) => {
436
- if (!value) {
437
- return '';
438
- }
439
- const timeFormatSelector = new TimeFormatSelector();
440
- const timeDisplayFormat = timeFormatSelector.getFormat(displayFormat, timeFormat, useSeconds);
441
- const timeValueFormat = timeFormatSelector.getFormat(valueFormat, '24hr', useSeconds);
442
-
443
- const isTimeValid = dayjs(value, timeValueFormat, true).isValid();
444
- if (!isTimeValid) {
445
- return value;
446
- }
447
-
448
- if (mask && initialMask) {
449
- if (inputFormat) {
450
- return dayjs(value, timeValueFormat).format(inputFormat);
451
- }
452
-
453
- let valueToUnmask = value;
454
- if (isSimpleDisplay) {
455
- valueToUnmask = dayjs(value, timeValueFormat).format(timeDisplayFormat);
456
- }
457
-
458
- const unmasked = Mask.getValueWithoutMask(valueToUnmask);
459
- const masked = Mask.getValueWithMask(unmasked, mask);
460
- return masked;
461
- }
462
-
463
- return dayjs(value, timeValueFormat).format(timeDisplayFormat);
464
- });
465
-
466
- FormatterParserProvider.registerParser('ZdTime', (value: string, {
467
- displayFormat = Config.displayTimeFormat,
468
- valueFormat = Config.valueTimeFormat,
469
- timeFormat = Config.timeFormat || 'ampm',
470
- useSeconds = false,
471
- mask = '',
472
- initialMask,
473
- }: any = {}) => {
474
- if (!value) {
475
- return null;
476
- }
477
- const timeFormatSelector = new TimeFormatSelector();
478
- const timeDisplayFormat = timeFormatSelector.getFormat(displayFormat, timeFormat, useSeconds);
479
- const timeValueFormat = timeFormatSelector.getFormat(valueFormat, '24hr', useSeconds);
480
-
481
- if (dayjs(value, timeDisplayFormat, true).isValid()) {
482
- return dayjs(value, timeDisplayFormat).format(timeValueFormat);
483
- }
484
-
485
- if (mask && Mask.checkMask(value, mask)) {
486
- const unmasked = Mask.getValueWithoutMask(value);
487
- let masked;
488
-
489
- if (!initialMask) {
490
- const displayFmtMask = timeDisplayFormat.replace(/[A-Za-z]/gi, '#');
491
-
492
- masked = Mask.getValueWithMask(unmasked, displayFmtMask);
493
- }
494
-
495
- const timeFmtMask = timeValueFormat.replace(/[A-Za-z]/gi, '#');
496
-
497
- masked = Mask.getValueWithMask(unmasked, timeFmtMask);
498
-
499
- if (dayjs(masked, timeValueFormat, true).format(timeValueFormat) === masked) {
500
- return masked;
501
- }
502
- }
503
- return value;
504
- });
436
+ FormatterParserProvider.registerFormatter(
437
+ 'ZdTime',
438
+ (
439
+ value: string,
440
+ {
441
+ valueFormat = Config.valueTimeFormat,
442
+ displayFormat = Config.displayTimeFormat,
443
+ inputFormat = Config.timeInputFormat,
444
+ timeFormat = Config.timeFormat || 'ampm',
445
+ useSeconds = false,
446
+ mask = '',
447
+ initialMask,
448
+ isSimpleDisplay = false,
449
+ }: any = {},
450
+ ) => {
451
+ if (!value) {
452
+ return '';
453
+ }
454
+ const timeFormatSelector = new TimeFormatSelector();
455
+ const timeDisplayFormat = timeFormatSelector.getFormat(displayFormat, timeFormat, useSeconds);
456
+ const timeValueFormat = timeFormatSelector.getFormat(valueFormat, '24hr', useSeconds);
457
+
458
+ const isTimeValid = dayjs(value, timeValueFormat, true).isValid();
459
+ if (!isTimeValid) {
460
+ return value;
461
+ }
462
+
463
+ if (mask && initialMask) {
464
+ if (inputFormat) {
465
+ return dayjs(value, timeValueFormat).format(inputFormat);
466
+ }
467
+
468
+ let valueToUnmask = value;
469
+ if (isSimpleDisplay) {
470
+ valueToUnmask = dayjs(value, timeValueFormat).format(timeDisplayFormat);
471
+ }
472
+
473
+ const unmasked = Mask.getValueWithoutMask(valueToUnmask);
474
+ const masked = Mask.getValueWithMask(unmasked, mask);
475
+ return masked;
476
+ }
477
+
478
+ return dayjs(value, timeValueFormat).format(timeDisplayFormat);
479
+ },
480
+ );
481
+
482
+ FormatterParserProvider.registerParser(
483
+ 'ZdTime',
484
+ (
485
+ value: string,
486
+ {
487
+ displayFormat = Config.displayTimeFormat,
488
+ valueFormat = Config.valueTimeFormat,
489
+ timeFormat = Config.timeFormat || 'ampm',
490
+ useSeconds = false,
491
+ mask = '',
492
+ initialMask,
493
+ }: any = {},
494
+ ) => {
495
+ if (!value) {
496
+ return null;
497
+ }
498
+ const timeFormatSelector = new TimeFormatSelector();
499
+ const timeDisplayFormat = timeFormatSelector.getFormat(displayFormat, timeFormat, useSeconds);
500
+ const timeValueFormat = timeFormatSelector.getFormat(valueFormat, '24hr', useSeconds);
501
+
502
+ if (dayjs(value, timeDisplayFormat, true).isValid()) {
503
+ return dayjs(value, timeDisplayFormat).format(timeValueFormat);
504
+ }
505
+
506
+ if (mask && Mask.checkMask(value, mask)) {
507
+ const unmasked = Mask.getValueWithoutMask(value);
508
+ let masked;
509
+
510
+ if (!initialMask) {
511
+ const displayFmtMask = timeDisplayFormat.replace(/[A-Za-z]/gi, '#');
512
+
513
+ masked = Mask.getValueWithMask(unmasked, displayFmtMask);
514
+ }
515
+
516
+ const timeFmtMask = timeValueFormat.replace(/[A-Za-z]/gi, '#');
517
+
518
+ masked = Mask.getValueWithMask(unmasked, timeFmtMask);
519
+
520
+ if (dayjs(masked, timeValueFormat, true).format(timeValueFormat) === masked) {
521
+ return masked;
522
+ }
523
+ }
524
+ return value;
525
+ },
526
+ );
505
527
 
506
528
  InputFactory.register('ZdTime', Time);