@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.
- package/coverage/clover.xml +2570 -1531
- package/coverage/coverage-final.json +171 -158
- package/coverage/lcov-report/block-navigation.js +1 -1
- package/coverage/lcov-report/index.html +194 -44
- package/coverage/lcov-report/sorter.js +21 -7
- package/coverage/lcov-report/src/components/index.html +5 -5
- package/coverage/lcov-report/src/components/index.ts.html +244 -142
- package/coverage/lcov-report/src/components/tek-grid/columns-searcher.ts.html +2 -2
- package/coverage/lcov-report/src/components/tek-grid/dynamic-filter-datasource-factory.ts.html +3 -3
- package/coverage/lcov-report/src/components/tek-grid/filter-helper.ts.html +3 -3
- package/coverage/lcov-report/src/components/tek-grid/grid-filter-button.ts.html +6 -6
- package/coverage/lcov-report/src/components/tek-grid/grouped-data-manager.ts.html +6 -6
- package/coverage/lcov-report/src/components/tek-grid/grouped-data-selector.ts.html +3 -3
- package/coverage/lcov-report/src/components/tek-grid/grouped-view-navigator.ts.html +3 -3
- package/coverage/lcov-report/src/components/tek-grid/index.html +1 -1
- package/coverage/lcov-report/src/components/tek-grid/index.ts.html +19 -19
- package/coverage/lcov-report/src/components/tek-grid/interfaces.ts.html +3 -3
- package/coverage/lcov-report/src/components/tek-grid/keymap-grouped.ts.html +2 -2
- package/coverage/lcov-report/src/components/tek-grid/layout-options.ts.html +6 -6
- package/coverage/lcov-report/src/components/tek-grid/tek-datasource/index.html +1 -1
- package/coverage/lcov-report/src/components/tek-grid/tek-datasource/index.ts.html +4 -4
- package/coverage/lcov-report/src/components/tek-grid/tek-datasource/interfaces.ts.html +3 -3
- package/coverage/lcov-report/src/components/tek-grid/tek-datasource/tek-memory-datasource.ts.html +5 -5
- package/coverage/lcov-report/src/components/tek-grid/tek-datasource/tek-rest-datasource.ts.html +5 -5
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-column.ts.html +4 -4
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-columns-button/index.html +1 -1
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.ts.html +3 -3
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.ts.html +6 -6
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-controller.ts.html +2 -2
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-events.ts.html +3 -3
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/export-options/button-option.ts.html +2 -2
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/export-options/index.html +1 -1
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/export-options/index.ts.html +4 -4
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.ts.html +2 -2
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/index.html +1 -1
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/index.ts.html +3 -3
- package/coverage/lcov-report/src/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.ts.html +5 -5
- package/coverage/lcov-report/src/components/tek-grid/tek-grid.ts.html +22 -22
- package/coverage/lcov-report/src/components/zd-alert/alert.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-alert/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-badge/badge.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-badge/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-breadcrumbs/breadcrumbs.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-breadcrumbs/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-button/button.ts.html +36 -36
- package/coverage/lcov-report/src/components/zd-button/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-button-group/button-group.ts.html +113 -131
- package/coverage/lcov-report/src/components/zd-button-group/index.html +17 -17
- package/coverage/lcov-report/src/components/zd-card/card.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-card/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-carousel/carousel.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-carousel/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-checkbox/checkbox.ts.html +6 -6
- package/coverage/lcov-report/src/components/zd-checkbox/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-checkbox-multiple/checkbox-multiple.ts.html +77 -122
- package/coverage/lcov-report/src/components/zd-checkbox-multiple/index.html +17 -17
- package/coverage/lcov-report/src/components/zd-chip/chip.ts.html +352 -0
- package/coverage/lcov-report/src/components/zd-chip/index.html +116 -0
- package/coverage/lcov-report/src/components/zd-code-viewer/code-viewer.ts.html +4 -4
- package/coverage/lcov-report/src/components/zd-code-viewer/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-col/col.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-col/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-collapse-card/collapse-card.ts.html +80 -68
- package/coverage/lcov-report/src/components/zd-collapse-card/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-component/child-not-found.ts.html +2 -2
- package/coverage/lcov-report/src/components/zd-component/component-render.ts.html +5 -5
- package/coverage/lcov-report/src/components/zd-component/component.ts.html +117 -69
- package/coverage/lcov-report/src/components/zd-component/index.html +9 -9
- package/coverage/lcov-report/src/components/zd-container/container.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-container/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-currency/currency.ts.html +259 -0
- package/coverage/lcov-report/src/components/zd-currency/index.html +116 -0
- package/coverage/lcov-report/src/components/zd-date-input/date-input.ts.html +113 -98
- package/coverage/lcov-report/src/components/zd-date-input/index.html +5 -5
- package/coverage/lcov-report/src/components/zd-date-range/date-range.ts.html +2059 -0
- package/coverage/lcov-report/src/components/zd-date-range/index.html +116 -0
- package/coverage/lcov-report/src/components/zd-dialog/dialog.ts.html +30 -30
- package/coverage/lcov-report/src/components/zd-dialog/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-divider/divider.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-divider/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-dropdown/dropdown.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-dropdown/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-footer/footer.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-footer/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-form/form.ts.html +288 -18
- package/coverage/lcov-report/src/components/zd-form/index.html +9 -9
- package/coverage/lcov-report/src/components/zd-frame/frame.ts.html +8 -8
- package/coverage/lcov-report/src/components/zd-frame/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-frame-page/frame-page.ts.html +4 -4
- package/coverage/lcov-report/src/components/zd-frame-page/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-grid/data-navigator.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-grid/data-selector.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-grid/grid-column.ts.html +10 -10
- package/coverage/lcov-report/src/components/zd-grid/grid-events.ts.html +4 -4
- package/coverage/lcov-report/src/components/zd-grid/grid.ts.html +84 -84
- package/coverage/lcov-report/src/components/zd-grid/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-grid/index.ts.html +12 -12
- package/coverage/lcov-report/src/components/zd-grid/iterable-table.ts.html +6 -6
- package/coverage/lcov-report/src/components/zd-grid/keymap-merger.ts.html +14 -14
- package/coverage/lcov-report/src/components/zd-grid/keymap-navigation.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-grid/table-action-builder.ts.html +5 -5
- package/coverage/lcov-report/src/components/zd-grid/view-navigator.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-grid-editable/data-editor-with-add.ts.html +6 -6
- package/coverage/lcov-report/src/components/zd-grid-editable/data-editor.ts.html +7 -7
- package/coverage/lcov-report/src/components/zd-grid-editable/errors/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-grid-editable/errors/index.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-grid-editable/errors/not-editing.ts.html +2 -2
- package/coverage/lcov-report/src/components/zd-grid-editable/errors/row-not-found.ts.html +2 -2
- package/coverage/lcov-report/src/components/zd-grid-editable/grid-column-editable.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-grid-editable/grid-editable-controller.ts.html +2 -2
- package/coverage/lcov-report/src/components/zd-grid-editable/grid-editable-events.ts.html +2 -2
- package/coverage/lcov-report/src/components/zd-grid-editable/grid-editable.ts.html +9 -9
- package/coverage/lcov-report/src/components/zd-grid-editable/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-grid-editable/index.ts.html +8 -8
- package/coverage/lcov-report/src/components/zd-grid-editable/keymap-editing.ts.html +2 -2
- package/coverage/lcov-report/src/components/zd-header/header.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-header/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-icon/icon.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-icon/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-image/image.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-image/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-increment/increment.ts.html +436 -0
- package/coverage/lcov-report/src/components/zd-increment/index.html +116 -0
- package/coverage/lcov-report/src/components/zd-input/index.html +5 -5
- package/coverage/lcov-report/src/components/zd-input/input-factory.ts.html +4 -4
- package/coverage/lcov-report/src/components/zd-input/input.ts.html +73 -61
- package/coverage/lcov-report/src/components/zd-iterable/column-not-found.ts.html +2 -2
- package/coverage/lcov-report/src/components/zd-iterable/column.ts.html +6 -6
- package/coverage/lcov-report/src/components/zd-iterable/conditions-manager.ts.html +9 -9
- package/coverage/lcov-report/src/components/zd-iterable/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-iterable/iterable-columns-button-controller.ts.html +2 -2
- package/coverage/lcov-report/src/components/zd-iterable/iterable-columns-button.ts.html +6 -6
- package/coverage/lcov-report/src/components/zd-iterable/iterable-controller.ts.html +4 -4
- package/coverage/lcov-report/src/components/zd-iterable/iterable-page-component.ts.html +5 -5
- package/coverage/lcov-report/src/components/zd-iterable/iterable-page-info.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-iterable/iterable-page-size.ts.html +5 -5
- package/coverage/lcov-report/src/components/zd-iterable/iterable-pagination.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-iterable/iterable.ts.html +29 -29
- package/coverage/lcov-report/src/components/zd-iterable/search.ts.html +8 -8
- package/coverage/lcov-report/src/components/zd-iterable-component-render/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-iterable-component-render/iterable-component-render.ts.html +5 -5
- package/coverage/lcov-report/src/components/zd-layout/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-layout/layout.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-list/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-list/item-not-found.ts.html +2 -2
- package/coverage/lcov-report/src/components/zd-list/list-group.ts.html +4 -4
- package/coverage/lcov-report/src/components/zd-list/list-item.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-list/list.ts.html +4 -4
- package/coverage/lcov-report/src/components/zd-loading/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-loading/loading.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-login/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-login/login-button.ts.html +4 -4
- package/coverage/lcov-report/src/components/zd-login/login.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-main/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-main/main.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-master-detail/detail-not-found.ts.html +118 -0
- package/coverage/lcov-report/src/components/zd-master-detail/index.html +146 -0
- package/coverage/lcov-report/src/components/zd-master-detail/master-detail.ts.html +331 -0
- package/coverage/lcov-report/src/components/zd-master-detail/master-not-found.ts.html +118 -0
- package/coverage/lcov-report/src/components/zd-menu/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-menu/menu-button.ts.html +4 -4
- package/coverage/lcov-report/src/components/zd-menu/menu-group.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-menu/menu-link.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-menu/menu-separator.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-menu/menu.ts.html +4 -4
- package/coverage/lcov-report/src/components/zd-modal/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-modal/modal-close-button.ts.html +4 -4
- package/coverage/lcov-report/src/components/zd-modal/modal.ts.html +5 -5
- package/coverage/lcov-report/src/components/zd-month/index.html +116 -0
- package/coverage/lcov-report/src/components/zd-month/month.ts.html +568 -0
- package/coverage/lcov-report/src/components/zd-number-input/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-number-input/number-input.ts.html +27 -27
- package/coverage/lcov-report/src/components/zd-password/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-password/password.ts.html +7 -7
- package/coverage/lcov-report/src/components/zd-progress/index.html +116 -0
- package/coverage/lcov-report/src/components/zd-progress/progress.ts.html +262 -0
- package/coverage/lcov-report/src/components/zd-radio/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-radio/radio.ts.html +6 -6
- package/coverage/lcov-report/src/components/zd-row/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-row/row.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-select/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-select/select.ts.html +9 -9
- package/coverage/lcov-report/src/components/zd-select-multiple/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-select-multiple/select-multiple.ts.html +5 -5
- package/coverage/lcov-report/src/components/zd-svg-map/index.html +116 -0
- package/coverage/lcov-report/src/components/zd-svg-map/svg-map.ts.html +475 -0
- package/coverage/lcov-report/src/components/zd-switch/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-switch/switch.ts.html +5 -5
- package/coverage/lcov-report/src/components/zd-table/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-table/table.ts.html +4 -4
- package/coverage/lcov-report/src/components/zd-tabs/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-tabs/tab-not-found.ts.html +2 -2
- package/coverage/lcov-report/src/components/zd-tabs/tab.ts.html +5 -5
- package/coverage/lcov-report/src/components/zd-tabs/tabs.ts.html +7 -7
- package/coverage/lcov-report/src/components/zd-tag/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-tag/tag.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-text/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-text/text.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-text-input/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-text-input/text-input.ts.html +22 -22
- package/coverage/lcov-report/src/components/zd-textarea/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-textarea/textarea.ts.html +5 -5
- package/coverage/lcov-report/src/components/zd-time/index.html +131 -0
- package/coverage/lcov-report/src/components/zd-time/time-format-selector.ts.html +157 -0
- package/coverage/lcov-report/src/components/zd-time/time.ts.html +1669 -0
- package/coverage/lcov-report/src/components/zd-toggleable/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-toggleable/toggleable.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-tooltip/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-tooltip/tooltip.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-tree/index.html +116 -0
- package/coverage/lcov-report/src/components/zd-tree/tree.ts.html +1849 -0
- package/coverage/lcov-report/src/components/zd-tree-grid/index.html +1 -1
- package/coverage/lcov-report/src/components/zd-tree-grid/index.ts.html +7 -7
- package/coverage/lcov-report/src/components/zd-tree-grid/iterable-tree.ts.html +9 -9
- package/coverage/lcov-report/src/components/zd-tree-grid/keymap-tree.ts.html +3 -3
- package/coverage/lcov-report/src/components/zd-tree-grid/tree-data-navigator.ts.html +5 -5
- package/coverage/lcov-report/src/components/zd-tree-grid/tree-data-selector.ts.html +5 -5
- package/coverage/lcov-report/src/components/zd-tree-grid/tree-grid.ts.html +108 -108
- package/coverage/lcov-report/src/error/delete-rows.ts.html +3 -3
- package/coverage/lcov-report/src/error/index.html +1 -1
- package/coverage/lcov-report/src/error/non-initialized.ts.html +3 -3
- package/coverage/lcov-report/src/error/tek-grid-delete-rows.ts.html +3 -3
- package/coverage/lcov-report/src/error/teknisa-common-error.ts.html +2 -2
- package/coverage/lcov-report/src/error/zeedhi-error.ts.html +3 -3
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +9 -27
- package/coverage/lcov-report/src/services/index.html +1 -1
- package/coverage/lcov-report/src/services/index.ts.html +5 -5
- package/coverage/lcov-report/src/services/zd-alert/alert-queue.ts.html +3 -3
- package/coverage/lcov-report/src/services/zd-alert/alert-replace.ts.html +3 -3
- package/coverage/lcov-report/src/services/zd-alert/alert-service.ts.html +5 -5
- package/coverage/lcov-report/src/services/zd-alert/alert-stack.ts.html +3 -3
- package/coverage/lcov-report/src/services/zd-alert/index.html +1 -1
- package/coverage/lcov-report/src/services/zd-alert/index.ts.html +6 -6
- package/coverage/lcov-report/src/services/zd-dialog/dialog-service.ts.html +4 -4
- package/coverage/lcov-report/src/services/zd-dialog/index.html +1 -1
- package/coverage/lcov-report/src/services/zd-loading/index.html +1 -1
- package/coverage/lcov-report/src/services/zd-loading/loading-service.ts.html +2 -2
- package/coverage/lcov-report/src/services/zd-modal/index.html +1 -1
- package/coverage/lcov-report/src/services/zd-modal/modal-service.ts.html +5 -5
- package/coverage/lcov-report/src/utils/data-value-out/data-value-out.ts.html +3 -3
- package/coverage/lcov-report/src/utils/data-value-out/index.html +1 -1
- package/coverage/lcov-report/src/utils/data-value-out/index.ts.html +3 -3
- package/coverage/lcov-report/src/utils/datasource-searcher/datasource-searcher.ts.html +3 -3
- package/coverage/lcov-report/src/utils/datasource-searcher/index.html +1 -1
- package/coverage/lcov-report/src/utils/datasource-searcher/index.ts.html +3 -3
- package/coverage/lcov-report/src/utils/icons/icons.ts.html +6 -6
- package/coverage/lcov-report/src/utils/icons/index.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov-report/src/utils/index.ts.html +11 -11
- package/coverage/lcov-report/src/utils/is-filled-object/index.html +1 -1
- package/coverage/lcov-report/src/utils/is-filled-object/is-filled-object.ts.html +3 -3
- package/coverage/lcov-report/src/utils/is-nil.ts.html +2 -2
- package/coverage/lcov-report/src/utils/omit/index.html +1 -1
- package/coverage/lcov-report/src/utils/omit/omit.ts.html +2 -2
- package/coverage/lcov-report/src/utils/theme/index.html +1 -1
- package/coverage/lcov-report/src/utils/theme/theme.ts.html +4 -4
- package/coverage/lcov-report/src/utils/tree-data-structure/index.html +7 -7
- package/coverage/lcov-report/src/utils/tree-data-structure/index.ts.html +3 -3
- package/coverage/lcov-report/src/utils/tree-data-structure/tree-data-structure.ts.html +90 -87
- package/coverage/lcov-report/src/utils/unique-by/index.html +1 -1
- package/coverage/lcov-report/src/utils/unique-by/unique-by.ts.html +3 -3
- package/coverage/lcov-report/tests/unit/components/zd-component/ComponentMock.ts.html +1 -1
- package/coverage/lcov-report/tests/unit/components/zd-component/index.html +1 -1
- package/coverage/lcov.info +3991 -2050
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/zd-date-range/date-range.d.ts +152 -0
- package/dist/types/components/zd-date-range/interfaces.d.ts +18 -0
- package/dist/types/components/zd-form/form.d.ts +15 -0
- package/dist/types/components/zd-form/interfaces.d.ts +3 -0
- package/dist/types/components/zd-input/input.d.ts +2 -0
- package/dist/types/components/zd-input/interfaces.d.ts +2 -0
- package/dist/types/components/zd-time/interfaces.d.ts +1 -1
- package/dist/types/components/zd-time/time.d.ts +6 -6
- package/dist/types/index.d.ts +1 -1
- package/dist/zd-common.js +634 -23
- package/dist/zd-common.min.js +634 -23
- package/package.json +3 -3
- package/src/components/index.ts +7 -5
- package/src/components/zd-date-range/date-range.ts +658 -0
- package/src/components/zd-date-range/interfaces.ts +19 -0
- package/src/components/zd-form/form.ts +91 -1
- package/src/components/zd-form/interfaces.ts +3 -0
- package/src/components/zd-input/input.ts +4 -0
- package/src/components/zd-input/interfaces.ts +2 -0
- package/src/components/zd-time/interfaces.ts +16 -16
- package/src/components/zd-time/time-format-selector.ts +13 -13
- package/src/components/zd-time/time.ts +510 -488
- package/src/index.ts +1 -8
- package/tests/unit/components/zd-date-range/date-range.spec.ts +1125 -0
- package/tests/unit/components/zd-form/form.spec.ts +30 -0
- 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 {
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
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
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
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(
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
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);
|