@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Zeedhi Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@zeedhi/autonumeric": "^4.6.3",
|
|
24
|
-
"@zeedhi/core": "^3.0.
|
|
24
|
+
"@zeedhi/core": "^3.0.2",
|
|
25
25
|
"lodash.clonedeep": "^4.5.0",
|
|
26
26
|
"lodash.debounce": "^4.0.8",
|
|
27
27
|
"lodash.get": "^4.4.2",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"lodash.times": "^4.3.2",
|
|
43
43
|
"mockdate": "^3.0.5"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "3998ba0d7d1747ed341a90f01839d8de065d6c37"
|
|
46
46
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -206,10 +206,12 @@ export * from './zd-increment/interfaces';
|
|
|
206
206
|
export * from './zd-currency/currency';
|
|
207
207
|
export * from './zd-currency/interfaces';
|
|
208
208
|
|
|
209
|
-
export * from './zd-month/interfaces'
|
|
210
|
-
export * from './zd-month/month'
|
|
209
|
+
export * from './zd-month/interfaces';
|
|
210
|
+
export * from './zd-month/month';
|
|
211
211
|
|
|
212
|
-
export * from './zd-time/interfaces'
|
|
213
|
-
export * from './zd-time/time'
|
|
214
|
-
export * from './zd-time/time-format-selector'
|
|
212
|
+
export * from './zd-time/interfaces';
|
|
213
|
+
export * from './zd-time/time';
|
|
214
|
+
export * from './zd-time/time-format-selector';
|
|
215
215
|
|
|
216
|
+
export * from './zd-date-range/interfaces';
|
|
217
|
+
export * from './zd-date-range/date-range';
|
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
import { Config, DateHelper, FormatterParserProvider, I18n, Mask, Utils, dayjs } from '@zeedhi/core';
|
|
2
|
+
import isUndefined from 'lodash.isundefined';
|
|
3
|
+
import { IDateRange } from './interfaces';
|
|
4
|
+
|
|
5
|
+
import { InputFactory } from '../zd-input/input-factory';
|
|
6
|
+
import { TextInput } from '../zd-text-input/text-input';
|
|
7
|
+
|
|
8
|
+
export class DateRange extends TextInput implements IDateRange {
|
|
9
|
+
/**
|
|
10
|
+
* Input auto complete.
|
|
11
|
+
*/
|
|
12
|
+
public autocomplete = false;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Defines the date format.
|
|
16
|
+
*/
|
|
17
|
+
public dateFormat: string = Config.dateFormat;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Defines the date format displayed.
|
|
21
|
+
*/
|
|
22
|
+
public displayFormat: string = Config.displayFormat;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Defines the date input format.
|
|
26
|
+
*/
|
|
27
|
+
public inputFormat?: string = Config.dateInputFormat;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Shows the date picker.
|
|
31
|
+
*/
|
|
32
|
+
public showDatePicker = false;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Sets the first day of the week, starting with 0 for Sunday.
|
|
36
|
+
*/
|
|
37
|
+
public firstDayOfWeek: number | string = 0;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Forces 100% width.
|
|
41
|
+
*/
|
|
42
|
+
public fullWidth = false;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Sets the locale. Accepts a string with a BCP 47 language tag.
|
|
46
|
+
*/
|
|
47
|
+
public locale?: string = I18n.instance.language;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Allows changing displayed month with mouse scroll
|
|
51
|
+
*/
|
|
52
|
+
public scrollable = false;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Toggles visibility of the week numbers in the body of the calendar.
|
|
56
|
+
*/
|
|
57
|
+
public showWeek = false;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Character that will separate the two dates
|
|
61
|
+
*/
|
|
62
|
+
public get splitter(): string {
|
|
63
|
+
return I18n.translate(this.internalSplitter);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public set splitter(splitter: string) {
|
|
67
|
+
this.internalSplitter = splitter;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private internalSplitter = ' ~ ';
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Width of the picker.
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
public width: number | string = 248;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Helper options.
|
|
80
|
+
*/
|
|
81
|
+
public helperOptions?: string[] = [];
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Max value allowed.
|
|
85
|
+
*/
|
|
86
|
+
public max?: string = '';
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Min value allowed.
|
|
90
|
+
*/
|
|
91
|
+
public min?: string = '';
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Helper value.
|
|
95
|
+
*/
|
|
96
|
+
public helperValue?: string = '';
|
|
97
|
+
|
|
98
|
+
protected isoFormat = 'YYYY-MM-DD';
|
|
99
|
+
|
|
100
|
+
protected dateError = false;
|
|
101
|
+
|
|
102
|
+
protected formatterFn = FormatterParserProvider.getFormatter('ZdDateRange');
|
|
103
|
+
|
|
104
|
+
protected parserFn = FormatterParserProvider.getParser('ZdDateRange');
|
|
105
|
+
|
|
106
|
+
protected initialMask?: string;
|
|
107
|
+
|
|
108
|
+
public unitMask?: string;
|
|
109
|
+
|
|
110
|
+
protected isSimpleDisplay!: boolean;
|
|
111
|
+
|
|
112
|
+
/* istanbul ignore next */
|
|
113
|
+
/**
|
|
114
|
+
* Creates a new Date.
|
|
115
|
+
* @param props Date properties
|
|
116
|
+
*/
|
|
117
|
+
constructor(props: IDateRange) {
|
|
118
|
+
super(props);
|
|
119
|
+
// Add this logic to resolve template strings
|
|
120
|
+
if (typeof props.appendIcon === 'string' && props.appendIcon.startsWith('{{') && props.appendIcon.endsWith('}}')) {
|
|
121
|
+
const match = props.appendIcon.match(/{{(.*?)}}/);
|
|
122
|
+
if (match) {
|
|
123
|
+
const path = match[1].trim().split('.');
|
|
124
|
+
let value: any = window;
|
|
125
|
+
for (const key of path) {
|
|
126
|
+
value = value?.[key];
|
|
127
|
+
}
|
|
128
|
+
this.appendIcon = value ?? props.appendIcon;
|
|
129
|
+
} else {
|
|
130
|
+
this.appendIcon = props.appendIcon;
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
|
|
134
|
+
}
|
|
135
|
+
this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
|
|
136
|
+
this.dateFormat = this.getInitValue('dateFormat', props.dateFormat, this.dateFormat);
|
|
137
|
+
this.dateValidation = this.dateValidation.bind(this);
|
|
138
|
+
this.displayFormat = this.getInitValue('displayFormat', props.displayFormat, this.displayFormat);
|
|
139
|
+
this.inputFormat = this.getInitValue('inputFormat', props.inputFormat, this.inputFormat);
|
|
140
|
+
this.firstDayOfWeek = this.getInitValue('firstDayOfWeek', props.firstDayOfWeek, this.firstDayOfWeek);
|
|
141
|
+
this.fullWidth = this.getInitValue('fullWidth', props.fullWidth, this.fullWidth);
|
|
142
|
+
this.locale = this.getInitValue('locale', props.locale, this.locale);
|
|
143
|
+
this.scrollable = this.getInitValue('scrollable', props.scrollable, this.scrollable);
|
|
144
|
+
this.showDatePicker = this.getInitValue('showDatePicker', props.showDatePicker, this.showDatePicker);
|
|
145
|
+
this.showWeek = this.getInitValue('showWeek', props.showWeek, this.showWeek);
|
|
146
|
+
this.splitter = this.getInitValue('splitter', props.splitter, this.internalSplitter);
|
|
147
|
+
this.width = this.getInitValue('width', props.width, this.width);
|
|
148
|
+
this.mask = this.getInitValue('mask', props.mask, undefined);
|
|
149
|
+
this.helperOptions = this.getInitValue('helperOptions', props.helperOptions, this.helperOptions);
|
|
150
|
+
this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
|
|
151
|
+
this.min = this.getInitValue('min', props.min, this.min);
|
|
152
|
+
this.max = this.getInitValue('max', props.max, this.max);
|
|
153
|
+
this.rules.push(this.dateValidation);
|
|
154
|
+
|
|
155
|
+
this.unitMask = this.mask;
|
|
156
|
+
this.initialMask = this.getInitialMask();
|
|
157
|
+
|
|
158
|
+
this.isSimpleDisplay = this.isSimpleFormat(this.displayFormat);
|
|
159
|
+
const userAppendIconClick = this.events.appendIconClick;
|
|
160
|
+
this.events.appendIconClick = ({ event, element, component }) => {
|
|
161
|
+
this.iconClick(event!, element!);
|
|
162
|
+
if (userAppendIconClick && typeof userAppendIconClick === 'function') {
|
|
163
|
+
userAppendIconClick({ event, element, component });
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private getInitialMask() {
|
|
169
|
+
if (isUndefined(this.mask)) {
|
|
170
|
+
this.unitMask = this.inputFormat && this.maskFormat(this.inputFormat);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (!this.unitMask) {
|
|
174
|
+
this.mask = this.unitMask;
|
|
175
|
+
return this.unitMask;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
this.mask = `${this.unitMask}${this.splitter}${this.unitMask}`;
|
|
179
|
+
|
|
180
|
+
return this.mask;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
public formatter(value: any): string {
|
|
184
|
+
return this.formatterFn(value, this);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
public parser(value: string): any {
|
|
188
|
+
return this.parserFn(value, this);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
get displayValue() {
|
|
192
|
+
return this.internalDisplayValue;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
set displayValue(newValue: string) {
|
|
196
|
+
this.dateError = false;
|
|
197
|
+
this.internalDisplayValue = newValue;
|
|
198
|
+
if (newValue) this.internalValue = this.parser(newValue);
|
|
199
|
+
else this.internalValue = [];
|
|
200
|
+
this.value = this.internalValue; // forces value accessor to be called if necessary
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
get value(): any {
|
|
204
|
+
return this.internalValue;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
set value(value: any) {
|
|
208
|
+
if (this.internalValue !== value) {
|
|
209
|
+
this.internalDisplayValue = this.formatter(value);
|
|
210
|
+
this.internalValue = value;
|
|
211
|
+
}
|
|
212
|
+
if (value === null) {
|
|
213
|
+
this.internalValue = [];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Assign the updated mask to mask property
|
|
219
|
+
*/
|
|
220
|
+
public updateMask() {
|
|
221
|
+
this.isSimpleDisplay = this.isSimpleFormat(this.displayFormat);
|
|
222
|
+
this.mask = this.getUpdatedMask();
|
|
223
|
+
return this.mask;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Gets the updated masked, based on displayFormat if the initial mask is undefined
|
|
228
|
+
*/
|
|
229
|
+
protected getUpdatedMask(): string | undefined {
|
|
230
|
+
if (isUndefined(this.getInitialMask())) {
|
|
231
|
+
return this.maskFormat(`${this.displayFormat}${this.splitter}${this.displayFormat}`);
|
|
232
|
+
}
|
|
233
|
+
return this.mask;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
protected maskFormat(format: string) {
|
|
237
|
+
return format.replace(/[A-Za-z]/gi, '#');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public setDateValue(displayValue: string) {
|
|
241
|
+
const lastValue = this.displayValue;
|
|
242
|
+
const values = this.splitValues(displayValue);
|
|
243
|
+
if (this.isValidDateArray(this.displayFormat, values)) {
|
|
244
|
+
this.internalDisplayValue = displayValue;
|
|
245
|
+
this.internalValue = this.parser(displayValue);
|
|
246
|
+
this.dateError = false;
|
|
247
|
+
if (lastValue !== this.displayValue) this.change(this.value);
|
|
248
|
+
} else {
|
|
249
|
+
if (!displayValue) {
|
|
250
|
+
this.internalDisplayValue = displayValue;
|
|
251
|
+
this.internalValue = [];
|
|
252
|
+
if (lastValue !== this.displayValue) this.change(this.value);
|
|
253
|
+
}
|
|
254
|
+
this.dateError = !!displayValue;
|
|
255
|
+
}
|
|
256
|
+
this.value = this.internalValue; // forces value accessor to be called if necessary
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Faz a validação do array de datas
|
|
261
|
+
* @param format o formato da data
|
|
262
|
+
* @param values o array de datas
|
|
263
|
+
* @returns true se todos os valores forem validados
|
|
264
|
+
* */
|
|
265
|
+
public isValidDateArray(format: string, values?: string[]) {
|
|
266
|
+
if (!values || values.length < 2) return false;
|
|
267
|
+
return values.every((value) => this.isValidDate(value, format));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
private splitValues(value: string) {
|
|
271
|
+
let splitedValue: string[] = [];
|
|
272
|
+
if (!value) return splitedValue;
|
|
273
|
+
|
|
274
|
+
if (value.indexOf(this.splitter) !== -1) {
|
|
275
|
+
splitedValue = value.split(this.splitter);
|
|
276
|
+
if (splitedValue[1] === '') return [splitedValue[0]];
|
|
277
|
+
return splitedValue;
|
|
278
|
+
}
|
|
279
|
+
return [value];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
public isValidDate(value: string, format: string, strict = true): boolean {
|
|
283
|
+
const date = dayjs(value, format, strict);
|
|
284
|
+
const isValidFormat = date.isValid();
|
|
285
|
+
if (!isValidFormat) return false;
|
|
286
|
+
|
|
287
|
+
const minDate = this.min ? dayjs(this.min, this.dateFormat) : null;
|
|
288
|
+
const isValidMin = !minDate || date.isAfter(minDate) || date.isSame(minDate);
|
|
289
|
+
if (!isValidMin) return false;
|
|
290
|
+
|
|
291
|
+
const maxDate = this.max ? dayjs(this.max, this.dateFormat) : null;
|
|
292
|
+
const isValidMax = !maxDate || date.isBefore(maxDate) || date.isSame(maxDate);
|
|
293
|
+
if (!isValidMax) return false;
|
|
294
|
+
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
public isValidFormatDate(value: string, format: string, strict = true): boolean {
|
|
299
|
+
return dayjs(value, format, strict).isValid();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
get isoRangeValue() {
|
|
303
|
+
return this.formatISODateRangeValue(this.value);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
set isoRangeValue(newValue: string[]) {
|
|
307
|
+
const lastValue: string[] = this.value;
|
|
308
|
+
this.dateError = false;
|
|
309
|
+
this.value = this.parseISODateRangeValue(newValue);
|
|
310
|
+
if (!Utils.isEqual(lastValue, this.value)) this.change(this.value);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
public formatISODateRangeValue(dates: string[] | string): string[] {
|
|
314
|
+
let splitedValue: string[];
|
|
315
|
+
|
|
316
|
+
if (Array.isArray(dates)) splitedValue = dates;
|
|
317
|
+
else splitedValue = this.splitValues(dates);
|
|
318
|
+
|
|
319
|
+
const formattedValue: string[] = [];
|
|
320
|
+
splitedValue.forEach((value) => {
|
|
321
|
+
if (value && this.isValidFormatDate(value, this.dateFormat)) {
|
|
322
|
+
formattedValue.push(dayjs(value, this.dateFormat, true).format(this.isoFormat));
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
return formattedValue;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
public parseISODateRangeValue(values: string[]): any {
|
|
329
|
+
const parsedValue: string[] = [];
|
|
330
|
+
if (values.length) {
|
|
331
|
+
values.forEach((value) => {
|
|
332
|
+
if (value && this.isValidFormatDate(value, this.isoFormat)) {
|
|
333
|
+
parsedValue.push(dayjs(value, this.isoFormat, true).format(this.dateFormat));
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
return this.sortDates(parsedValue);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
private sortDates(parsedValue: string[]): string[] {
|
|
341
|
+
return parsedValue.sort((a: string, b: string) =>
|
|
342
|
+
dayjs(a, this.dateFormat).isAfter(dayjs(b, this.dateFormat)) ? 1 : -1,
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
public dateValidation(): boolean | string {
|
|
347
|
+
return !this.dateError || I18n.translate('VALIDATION_INVALID_DATE');
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
public click(event?: Event, element?: any) {
|
|
351
|
+
const clickEvent = event || new MouseEvent('click');
|
|
352
|
+
super.click(clickEvent, element);
|
|
353
|
+
if (!clickEvent.defaultPrevented) {
|
|
354
|
+
this.showDatePicker = !this.showDatePicker;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
public blur(event: Event, element: any) {
|
|
359
|
+
if (this.value) {
|
|
360
|
+
this.value = this.sortDates(this.value);
|
|
361
|
+
this.removeDateMask();
|
|
362
|
+
this.setDateValue(this.formatter(this.value));
|
|
363
|
+
super.blur(event, element);
|
|
364
|
+
}
|
|
365
|
+
if (!Utils.isMobile()) {
|
|
366
|
+
this.showDatePicker = false;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
public focus(event: Event, element: any) {
|
|
371
|
+
this.addDateMask();
|
|
372
|
+
super.focus(event, element);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Add date mask
|
|
377
|
+
*/
|
|
378
|
+
protected addDateMask() {
|
|
379
|
+
if (isUndefined(this.getInitialMask()) || !this.value) return;
|
|
380
|
+
|
|
381
|
+
setTimeout(() => {
|
|
382
|
+
this.mask = this.getInitialMask();
|
|
383
|
+
const firstDate = this.value[0]
|
|
384
|
+
? dayjs(this.value[0], this.dateFormat).format(this.inputFormat || this.displayFormat)
|
|
385
|
+
: '';
|
|
386
|
+
const lastDate = this.value[1]
|
|
387
|
+
? dayjs(this.value[1], this.dateFormat).format(this.inputFormat || this.displayFormat)
|
|
388
|
+
: '';
|
|
389
|
+
this.internalDisplayValue = `${firstDate}${lastDate ? this.splitter : ''}${lastDate}`;
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Removes the component mask if value is valid
|
|
395
|
+
*/
|
|
396
|
+
protected removeDateMask() {
|
|
397
|
+
if (
|
|
398
|
+
isUndefined(this.getInitialMask()) ||
|
|
399
|
+
!this.value ||
|
|
400
|
+
this.dateError ||
|
|
401
|
+
!this.isValidDateArray(this.dateFormat, this.value)
|
|
402
|
+
) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
this.mask = '';
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Toggle showDatePicker value
|
|
410
|
+
*/
|
|
411
|
+
public togglePicker() {
|
|
412
|
+
this.showDatePicker = !this.showDatePicker;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Triggered when the appended icon is clicked.
|
|
417
|
+
* @param event DOM event
|
|
418
|
+
* @param element Text input
|
|
419
|
+
*/
|
|
420
|
+
public iconClick(event: Event, element: any) {
|
|
421
|
+
super.click(event, element);
|
|
422
|
+
if (!event.defaultPrevented) {
|
|
423
|
+
this.togglePicker();
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Checks if a date format is simple.
|
|
429
|
+
* Simple date formats are the ones that consists only of 'DD', 'MM' or 'YYYY', and mask delimiters
|
|
430
|
+
* @param format The format to be checked
|
|
431
|
+
* @returns true if it is simple, false otherwise
|
|
432
|
+
*/
|
|
433
|
+
protected isSimpleFormat(format: string): boolean {
|
|
434
|
+
const simpleTokens = ['DD', 'MM', 'YYYY'];
|
|
435
|
+
|
|
436
|
+
// remove the simple tokens from the string
|
|
437
|
+
const replaced = simpleTokens.reduce((result, token) => result.replace(token, ''), format);
|
|
438
|
+
|
|
439
|
+
const chars = replaced.split('');
|
|
440
|
+
|
|
441
|
+
return chars.length ? chars.every((char) => Mask.isMaskDelimiter(char)) : true;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
private previousHint = '';
|
|
445
|
+
|
|
446
|
+
private previousPersistentHint = false;
|
|
447
|
+
|
|
448
|
+
public updateHelperHint(helperValue: string) {
|
|
449
|
+
const previousHelperHint = this.helperValue ? DateHelper.getLabel(this.helperValue) : '';
|
|
450
|
+
|
|
451
|
+
if (!this.hint || previousHelperHint !== this.hint) {
|
|
452
|
+
this.previousHint = this.hint;
|
|
453
|
+
this.previousPersistentHint = this.persistentHint;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
this.helperValue = helperValue;
|
|
457
|
+
const label = DateHelper.getLabel(helperValue);
|
|
458
|
+
|
|
459
|
+
if (!helperValue || !label) {
|
|
460
|
+
this.hint = this.previousHint;
|
|
461
|
+
this.persistentHint = this.previousPersistentHint;
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
this.hint = label;
|
|
466
|
+
this.persistentHint = true;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
public change(event?: Event, element?: any): void {
|
|
470
|
+
super.change(event, element);
|
|
471
|
+
this.updateHelperHint('');
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
private getExtremities<T>(arr: T[]) {
|
|
475
|
+
if (arr.length === 0) return [];
|
|
476
|
+
|
|
477
|
+
if (arr.length === 1) return [arr[0]];
|
|
478
|
+
|
|
479
|
+
return [arr[0], arr[arr.length - 1]];
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
public setNativeDate(date: Date[]) {
|
|
483
|
+
this.dateError = false;
|
|
484
|
+
this.dateObject = date.map((obj) => dayjs(obj));
|
|
485
|
+
|
|
486
|
+
const extremityDates = this.getExtremities(this.dateObject);
|
|
487
|
+
this.value = extremityDates
|
|
488
|
+
.filter((obj): obj is dayjs.Dayjs => obj !== null)
|
|
489
|
+
.map((obj) => obj.format(this.dateFormat));
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
private dateObject: (dayjs.Dayjs | null)[] = [null, null];
|
|
493
|
+
|
|
494
|
+
public getNativeDate() {
|
|
495
|
+
return this.dateObject.filter((obj): obj is dayjs.Dayjs => obj !== null).map((obj) => obj.toDate());
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
public getMaskValue() {
|
|
499
|
+
let mask: any = '';
|
|
500
|
+
|
|
501
|
+
if (typeof this.mask === 'function') {
|
|
502
|
+
mask = this.mask(Mask.getValueWithoutMask(this.value?.[0] || ''));
|
|
503
|
+
} else if (typeof this.mask === 'string') {
|
|
504
|
+
mask = this.mask.split(this.splitter)[0] || '';
|
|
505
|
+
mask = Mask.getMaskArray(mask);
|
|
506
|
+
if (Array.isArray(mask) && mask.length > 0) {
|
|
507
|
+
mask = mask.concat(this.splitter.split('')).concat(mask);
|
|
508
|
+
}
|
|
509
|
+
} else if (Array.isArray(this.mask)) {
|
|
510
|
+
mask = this.mask;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
return mask;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
FormatterParserProvider.registerFormatter(
|
|
518
|
+
'ZdDateRange',
|
|
519
|
+
(
|
|
520
|
+
value: string[],
|
|
521
|
+
{
|
|
522
|
+
dateFormat = Config.dateFormat,
|
|
523
|
+
displayFormat = Config.displayFormat,
|
|
524
|
+
inputFormat = Config.dateInputFormat,
|
|
525
|
+
initialMask,
|
|
526
|
+
splitter = ' ~ ',
|
|
527
|
+
unitMask = '',
|
|
528
|
+
mask = '',
|
|
529
|
+
isSimpleDisplay = false,
|
|
530
|
+
}: any = {},
|
|
531
|
+
) => {
|
|
532
|
+
if (!value || value.length === 0 || (value.length === 1 && !value[0])) {
|
|
533
|
+
return '';
|
|
534
|
+
}
|
|
535
|
+
const formattedValue: string[] = [];
|
|
536
|
+
value.forEach((date) => {
|
|
537
|
+
if (date) {
|
|
538
|
+
const isDateValid = dayjs(date, dateFormat, true).isValid();
|
|
539
|
+
|
|
540
|
+
if (!isDateValid) {
|
|
541
|
+
formattedValue.push(date);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
if (initialMask && mask && unitMask) {
|
|
546
|
+
if (inputFormat) {
|
|
547
|
+
const formatted = dayjs(date, dateFormat).format(inputFormat);
|
|
548
|
+
formattedValue.push(formatted);
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
let valueToUnmask = date;
|
|
553
|
+
if (isSimpleDisplay) {
|
|
554
|
+
valueToUnmask = dayjs(date, dateFormat).format(displayFormat);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
const unmasked = Mask.getValueWithoutMask(valueToUnmask);
|
|
558
|
+
const masked = Mask.getValueWithMask(unmasked, unitMask);
|
|
559
|
+
|
|
560
|
+
formattedValue.push(masked);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
const formatted = dayjs(date, dateFormat).format(displayFormat);
|
|
565
|
+
formattedValue.push(formatted);
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
let displayOutput: string = formattedValue[0];
|
|
570
|
+
if (formattedValue.length === 2) {
|
|
571
|
+
displayOutput += `${splitter}${formattedValue[1]}`;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
return displayOutput;
|
|
575
|
+
},
|
|
576
|
+
);
|
|
577
|
+
|
|
578
|
+
FormatterParserProvider.registerParser(
|
|
579
|
+
'ZdDateRange',
|
|
580
|
+
(
|
|
581
|
+
value: string,
|
|
582
|
+
{
|
|
583
|
+
dateFormat = Config.dateFormat,
|
|
584
|
+
displayFormat = Config.displayFormat,
|
|
585
|
+
inputFormat = Config.dateInputFormat,
|
|
586
|
+
splitter = ' ~ ',
|
|
587
|
+
unitMask = '',
|
|
588
|
+
mask = '',
|
|
589
|
+
initialMask,
|
|
590
|
+
isSimpleDisplay = false,
|
|
591
|
+
}: any = {},
|
|
592
|
+
) => {
|
|
593
|
+
if (!value) {
|
|
594
|
+
return [];
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
let splitedValue: string[] = [];
|
|
598
|
+
|
|
599
|
+
if (value.indexOf(splitter) !== -1) {
|
|
600
|
+
splitedValue = value.split(splitter);
|
|
601
|
+
} else {
|
|
602
|
+
splitedValue.push(value);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
const formattedValue: string[] = [];
|
|
606
|
+
splitedValue.forEach((date) => {
|
|
607
|
+
if (date) {
|
|
608
|
+
if (dayjs(date, displayFormat, true).isValid()) {
|
|
609
|
+
const parsedDate = dayjs(date, displayFormat).format(dateFormat);
|
|
610
|
+
formattedValue.push(parsedDate);
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
if (unitMask && mask && Mask.checkMask(date, unitMask)) {
|
|
615
|
+
if (inputFormat) {
|
|
616
|
+
if (dayjs(date, inputFormat, true).isValid()) {
|
|
617
|
+
const parsedDate = dayjs(date, inputFormat).format(dateFormat);
|
|
618
|
+
formattedValue.push(parsedDate);
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
formattedValue.push(date);
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
const unmasked = Mask.getValueWithoutMask(date);
|
|
627
|
+
let masked;
|
|
628
|
+
|
|
629
|
+
if (!initialMask || isSimpleDisplay) {
|
|
630
|
+
const displayFmtMask = displayFormat.replace(/[A-Za-z]/gi, '#');
|
|
631
|
+
|
|
632
|
+
masked = Mask.getValueWithMask(unmasked, displayFmtMask);
|
|
633
|
+
|
|
634
|
+
if (dayjs(masked, displayFormat, true).format(displayFormat) === masked) {
|
|
635
|
+
const parsedDate = dayjs(masked, displayFormat).format(dateFormat);
|
|
636
|
+
formattedValue.push(parsedDate);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
const dateFmtMask = dateFormat.replace(/[A-Za-z]/gi, '#');
|
|
642
|
+
|
|
643
|
+
masked = Mask.getValueWithMask(unmasked, dateFmtMask);
|
|
644
|
+
|
|
645
|
+
if (dayjs(masked, dateFormat, true).isValid()) {
|
|
646
|
+
formattedValue.push(masked);
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
formattedValue.push(date);
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
return formattedValue;
|
|
655
|
+
},
|
|
656
|
+
);
|
|
657
|
+
|
|
658
|
+
InputFactory.register('ZdDateRange', DateRange);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ITextInput } from '../zd-text-input/interfaces';
|
|
2
|
+
|
|
3
|
+
export interface IDateRange extends ITextInput {
|
|
4
|
+
allowedDates?: ((date: string) => boolean) | string[];
|
|
5
|
+
dateFormat?: string;
|
|
6
|
+
displayFormat?: string;
|
|
7
|
+
firstDayOfWeek?: number | string;
|
|
8
|
+
fullWidth?: boolean;
|
|
9
|
+
inputFormat?: string;
|
|
10
|
+
showDatePicker?: boolean;
|
|
11
|
+
showWeek?: boolean;
|
|
12
|
+
width?: number | string;
|
|
13
|
+
orderedDates?: boolean;
|
|
14
|
+
helperOptions?: string[];
|
|
15
|
+
helperValue?: string;
|
|
16
|
+
max?: string;
|
|
17
|
+
min?: string;
|
|
18
|
+
viewMode?: string;
|
|
19
|
+
}
|