@taiga-ui/cdk 2.23.0 → 2.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/abstract/control.d.ts +1 -1
- package/abstract/dialog.directive.d.ts +12 -0
- package/abstract/index.d.ts +1 -0
- package/abstract/interactive.d.ts +4 -4
- package/abstract/taiga-ui-cdk-abstract.metadata.json +1 -1
- package/bundles/taiga-ui-cdk-abstract.umd.js +45 -7
- package/bundles/taiga-ui-cdk-abstract.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-abstract.umd.min.js +2 -2
- package/bundles/taiga-ui-cdk-abstract.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-components-dialog-host.umd.js +1 -1
- package/bundles/taiga-ui-cdk-components-dialog-host.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-components-dialog-host.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-components-dialog-host.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-components-portal-host.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-components-portal-host.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-constants.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-constants.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-date-time.umd.js +349 -349
- package/bundles/taiga-ui-cdk-date-time.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-date-time.umd.min.js +2 -2
- package/bundles/taiga-ui-cdk-date-time.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-active-zone.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-active-zone.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-auto-focus.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-auto-focus.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-autofilled.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-autofilled.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-checked.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-checked.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-copy-processor.umd.js +276 -0
- package/bundles/taiga-ui-cdk-directives-copy-processor.umd.js.map +1 -0
- package/bundles/taiga-ui-cdk-directives-copy-processor.umd.min.js +16 -0
- package/bundles/taiga-ui-cdk-directives-copy-processor.umd.min.js.map +1 -0
- package/bundles/taiga-ui-cdk-directives-drag.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-drag.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-droppable.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-droppable.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-element.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-element.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-focus-trap.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-focus-trap.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-focus-visible.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-focus-visible.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-focusable.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-focusable.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-focused.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-focused.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-for.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-for.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-high-dpi.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-high-dpi.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-hovered.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-hovered.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-input-mode.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-input-mode.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-item.umd.js +259 -0
- package/bundles/taiga-ui-cdk-directives-item.umd.js.map +1 -0
- package/bundles/taiga-ui-cdk-directives-item.umd.min.js +16 -0
- package/bundles/taiga-ui-cdk-directives-item.umd.min.js.map +1 -0
- package/bundles/taiga-ui-cdk-directives-let.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-let.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-media.umd.js +1 -1
- package/bundles/taiga-ui-cdk-directives-media.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-media.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-directives-media.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-obscured.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-obscured.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-overscroll.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-overscroll.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-pan.umd.js +5 -5
- package/bundles/taiga-ui-cdk-directives-pan.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-pan.umd.min.js +2 -2
- package/bundles/taiga-ui-cdk-directives-pan.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-pressed.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-pressed.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-prevent-default.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-prevent-default.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-repeat-times.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-repeat-times.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-resize.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-resize.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-swipe.umd.js +5 -5
- package/bundles/taiga-ui-cdk-directives-swipe.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-swipe.umd.min.js +2 -2
- package/bundles/taiga-ui-cdk-directives-swipe.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-validator.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-validator.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-zoom.umd.js +5 -5
- package/bundles/taiga-ui-cdk-directives-zoom.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-zoom.umd.min.js +2 -2
- package/bundles/taiga-ui-cdk-directives-zoom.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives.umd.js +26 -18
- package/bundles/taiga-ui-cdk-directives.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-enums.umd.js +11 -11
- package/bundles/taiga-ui-cdk-enums.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-enums.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-enums.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-observables.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-observables.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-pipes-filter.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-pipes-filter.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-pipes-mapper.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-pipes-mapper.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-services.umd.js +38 -38
- package/bundles/taiga-ui-cdk-services.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-services.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-services.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-tokens.umd.js +11 -11
- package/bundles/taiga-ui-cdk-tokens.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-tokens.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-tokens.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-dom.umd.js +8 -10
- package/bundles/taiga-ui-cdk-utils-dom.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-dom.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-focus.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-focus.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js +14 -14
- package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js.map +1 -1
- package/components/dialog-host/taiga-ui-cdk-components-dialog-host.metadata.json +1 -1
- package/components/portal-host/taiga-ui-cdk-components-portal-host.metadata.json +1 -1
- package/constants/taiga-ui-cdk-constants.metadata.json +1 -1
- package/date-time/day-range.d.ts +14 -14
- package/date-time/day.d.ts +57 -57
- package/date-time/index.d.ts +4 -4
- package/date-time/month-range.d.ts +1 -1
- package/date-time/month.d.ts +26 -26
- package/date-time/taiga-ui-cdk-date-time.metadata.json +1 -1
- package/date-time/time.d.ts +12 -12
- package/date-time/year.d.ts +27 -27
- package/directives/active-zone/taiga-ui-cdk-directives-active-zone.metadata.json +1 -1
- package/directives/auto-focus/taiga-ui-cdk-directives-auto-focus.metadata.json +1 -1
- package/directives/autofilled/taiga-ui-cdk-directives-autofilled.metadata.json +1 -1
- package/directives/checked/taiga-ui-cdk-directives-checked.metadata.json +1 -1
- package/directives/copy-processor/copy-processor.directive.d.ts +7 -0
- package/directives/copy-processor/copy-processor.module.d.ts +2 -0
- package/directives/copy-processor/index.d.ts +2 -0
- package/directives/copy-processor/package.json +13 -0
- package/directives/copy-processor/taiga-ui-cdk-directives-copy-processor.d.ts +4 -0
- package/directives/copy-processor/taiga-ui-cdk-directives-copy-processor.metadata.json +1 -0
- package/directives/drag/taiga-ui-cdk-directives-drag.metadata.json +1 -1
- package/directives/droppable/taiga-ui-cdk-directives-droppable.metadata.json +1 -1
- package/directives/element/taiga-ui-cdk-directives-element.metadata.json +1 -1
- package/directives/focus-trap/taiga-ui-cdk-directives-focus-trap.metadata.json +1 -1
- package/directives/focus-visible/taiga-ui-cdk-directives-focus-visible.metadata.json +1 -1
- package/directives/focusable/taiga-ui-cdk-directives-focusable.metadata.json +1 -1
- package/directives/focused/taiga-ui-cdk-directives-focused.metadata.json +1 -1
- package/directives/for/for.directive.d.ts +1 -1
- package/directives/for/taiga-ui-cdk-directives-for.metadata.json +1 -1
- package/directives/high-dpi/taiga-ui-cdk-directives-high-dpi.metadata.json +1 -1
- package/directives/hovered/taiga-ui-cdk-directives-hovered.metadata.json +1 -1
- package/directives/index.d.ts +5 -4
- package/directives/input-mode/taiga-ui-cdk-directives-input-mode.metadata.json +1 -1
- package/directives/item/index.d.ts +2 -0
- package/directives/item/item.directive.d.ts +6 -0
- package/directives/item/item.module.d.ts +2 -0
- package/directives/item/package.json +13 -0
- package/directives/item/taiga-ui-cdk-directives-item.d.ts +4 -0
- package/directives/item/taiga-ui-cdk-directives-item.metadata.json +1 -0
- package/directives/let/taiga-ui-cdk-directives-let.metadata.json +1 -1
- package/directives/media/media.directive.d.ts +1 -1
- package/directives/media/taiga-ui-cdk-directives-media.metadata.json +1 -1
- package/directives/obscured/taiga-ui-cdk-directives-obscured.metadata.json +1 -1
- package/directives/overscroll/taiga-ui-cdk-directives-overscroll.metadata.json +1 -1
- package/directives/pan/pan.directive.d.ts +3 -3
- package/directives/pan/taiga-ui-cdk-directives-pan.metadata.json +1 -1
- package/directives/pressed/taiga-ui-cdk-directives-pressed.metadata.json +1 -1
- package/directives/prevent-default/taiga-ui-cdk-directives-prevent-default.metadata.json +1 -1
- package/directives/repeat-times/taiga-ui-cdk-directives-repeat-times.metadata.json +1 -1
- package/directives/resize/taiga-ui-cdk-directives-resize.metadata.json +1 -1
- package/directives/swipe/swipe.directive.d.ts +4 -3
- package/directives/swipe/taiga-ui-cdk-directives-swipe.metadata.json +1 -1
- package/directives/taiga-ui-cdk-directives.metadata.json +1 -1
- package/directives/validator/taiga-ui-cdk-directives-validator.metadata.json +1 -1
- package/directives/zoom/taiga-ui-cdk-directives-zoom.metadata.json +1 -1
- package/directives/zoom/zoom.directive.d.ts +4 -3
- package/enums/index.d.ts +1 -1
- package/enums/taiga-ui-cdk-enums.metadata.json +1 -1
- package/esm2015/abstract/control.js +1 -1
- package/esm2015/abstract/dialog.directive.js +35 -0
- package/esm2015/abstract/index.js +2 -1
- package/esm2015/abstract/interactive.js +4 -4
- package/esm2015/abstract/multiple-control.js +1 -1
- package/esm2015/abstract/nullable-control.js +1 -1
- package/esm2015/components/dialog-host/dialog-host.component.js +3 -3
- package/esm2015/components/dialog-host/dialog-host.module.js +1 -1
- package/esm2015/components/portal-host/portal-host.component.js +1 -1
- package/esm2015/components/portal-host/portal-host.module.js +1 -1
- package/esm2015/components/portal-host/portal.service.js +1 -1
- package/esm2015/constants/matcher.js +1 -1
- package/esm2015/date-time/date-fillers.js +1 -1
- package/esm2015/date-time/day-range.js +26 -26
- package/esm2015/date-time/day.js +120 -120
- package/esm2015/date-time/index.js +5 -5
- package/esm2015/date-time/month-range.js +6 -6
- package/esm2015/date-time/month.js +56 -56
- package/esm2015/date-time/time.js +40 -40
- package/esm2015/date-time/year.js +49 -49
- package/esm2015/directives/active-zone/active-zone.module.js +1 -1
- package/esm2015/directives/auto-focus/autofocus.module.js +1 -1
- package/esm2015/directives/autofilled/autofilled.module.js +1 -1
- package/esm2015/directives/checked/checked.module.js +1 -1
- package/esm2015/directives/copy-processor/copy-processor.directive.js +37 -0
- package/esm2015/directives/copy-processor/copy-processor.module.js +13 -0
- package/esm2015/directives/copy-processor/index.js +3 -0
- package/esm2015/directives/copy-processor/taiga-ui-cdk-directives-copy-processor.js +5 -0
- package/esm2015/directives/drag/drag.module.js +1 -1
- package/esm2015/directives/droppable/droppable.module.js +1 -1
- package/esm2015/directives/element/element.module.js +1 -1
- package/esm2015/directives/focus-trap/focus-trap.module.js +1 -1
- package/esm2015/directives/focus-visible/focus-visible.module.js +1 -1
- package/esm2015/directives/focusable/focusable.module.js +1 -1
- package/esm2015/directives/focused/focused.module.js +1 -1
- package/esm2015/directives/for/for.directive.js +1 -1
- package/esm2015/directives/for/for.module.js +1 -1
- package/esm2015/directives/high-dpi/high-dpi.module.js +1 -1
- package/esm2015/directives/hovered/hovered.module.js +1 -1
- package/esm2015/directives/index.js +6 -5
- package/esm2015/directives/input-mode/input-mode.module.js +1 -1
- package/esm2015/directives/item/index.js +3 -0
- package/esm2015/directives/item/item.directive.js +15 -0
- package/esm2015/directives/item/item.module.js +13 -0
- package/esm2015/directives/item/taiga-ui-cdk-directives-item.js +5 -0
- package/esm2015/directives/let/let.directive.js +1 -1
- package/esm2015/directives/let/let.module.js +1 -1
- package/esm2015/directives/media/media.directive.js +2 -2
- package/esm2015/directives/media/media.module.js +1 -1
- package/esm2015/directives/obscured/obscured.module.js +1 -1
- package/esm2015/directives/overscroll/overscroll.module.js +1 -1
- package/esm2015/directives/pan/pan.directive.js +3 -2
- package/esm2015/directives/pan/pan.module.js +1 -1
- package/esm2015/directives/pressed/pressed.module.js +1 -1
- package/esm2015/directives/prevent-default/prevent-default.module.js +1 -1
- package/esm2015/directives/repeat-times/repeat-times.module.js +1 -1
- package/esm2015/directives/resize/resize.module.js +1 -1
- package/esm2015/directives/swipe/swipe.directive.js +3 -2
- package/esm2015/directives/swipe/swipe.module.js +1 -1
- package/esm2015/directives/validator/validator.module.js +1 -1
- package/esm2015/directives/zoom/zoom.directive.js +3 -2
- package/esm2015/directives/zoom/zoom.module.js +1 -1
- package/esm2015/enums/index.js +2 -2
- package/esm2015/interfaces/base-dialog-context.js +1 -1
- package/esm2015/interfaces/base-dialog.js +1 -1
- package/esm2015/interfaces/focusable-element-accessor.js +1 -1
- package/esm2015/interfaces/index.js +1 -1
- package/esm2015/observables/drag-and-drop-from.js +1 -1
- package/esm2015/observables/focus-visible-observable.js +1 -1
- package/esm2015/observables/mouse-drag-finish-from.js +1 -1
- package/esm2015/observables/pressed-observable.js +1 -1
- package/esm2015/pipes/filter/filter.module.js +1 -1
- package/esm2015/pipes/mapper/mapper.module.js +1 -1
- package/esm2015/services/focus-visible.service.js +1 -1
- package/esm2015/services/index.js +2 -2
- package/esm2015/services/obscured.service.js +1 -1
- package/esm2015/services/pan.service.js +3 -3
- package/esm2015/services/resize.service.js +1 -1
- package/esm2015/services/static-request.service.js +1 -1
- package/esm2015/tokens/active-element.js +4 -5
- package/esm2015/tokens/index.js +3 -3
- package/esm2015/tokens/is-android.js +1 -1
- package/esm2015/types/index.js +1 -1
- package/esm2015/utils/dom/contains-or-after.js +2 -4
- package/esm2015/utils/dom/get-element-obscurers.js +1 -1
- package/esm2015/utils/dom/index.js +2 -2
- package/esm2015/utils/focus/get-closest-keyboard-focusable.js +1 -1
- package/esm2015/utils/miscellaneous/index.js +3 -3
- package/esm5/abstract/control.js +1 -1
- package/esm5/abstract/dialog.directive.js +44 -0
- package/esm5/abstract/index.js +2 -1
- package/esm5/abstract/interactive.js +4 -4
- package/esm5/abstract/multiple-control.js +1 -1
- package/esm5/abstract/nullable-control.js +1 -1
- package/esm5/components/dialog-host/dialog-host.component.js +3 -3
- package/esm5/components/dialog-host/dialog-host.module.js +1 -1
- package/esm5/components/portal-host/portal-host.component.js +1 -1
- package/esm5/components/portal-host/portal-host.module.js +1 -1
- package/esm5/components/portal-host/portal.service.js +1 -1
- package/esm5/constants/matcher.js +1 -1
- package/esm5/date-time/date-fillers.js +1 -1
- package/esm5/date-time/day-range.js +26 -26
- package/esm5/date-time/day.js +120 -120
- package/esm5/date-time/index.js +5 -5
- package/esm5/date-time/month-range.js +6 -6
- package/esm5/date-time/month.js +56 -56
- package/esm5/date-time/time.js +41 -41
- package/esm5/date-time/year.js +49 -49
- package/esm5/directives/active-zone/active-zone.module.js +1 -1
- package/esm5/directives/auto-focus/autofocus.module.js +1 -1
- package/esm5/directives/autofilled/autofilled.module.js +1 -1
- package/esm5/directives/checked/checked.module.js +1 -1
- package/esm5/directives/copy-processor/copy-processor.directive.js +38 -0
- package/esm5/directives/copy-processor/copy-processor.module.js +16 -0
- package/esm5/directives/copy-processor/index.js +3 -0
- package/esm5/directives/copy-processor/taiga-ui-cdk-directives-copy-processor.js +5 -0
- package/esm5/directives/drag/drag.module.js +1 -1
- package/esm5/directives/droppable/droppable.module.js +1 -1
- package/esm5/directives/element/element.module.js +1 -1
- package/esm5/directives/focus-trap/focus-trap.module.js +1 -1
- package/esm5/directives/focus-visible/focus-visible.module.js +1 -1
- package/esm5/directives/focusable/focusable.module.js +1 -1
- package/esm5/directives/focused/focused.module.js +1 -1
- package/esm5/directives/for/for.directive.js +1 -1
- package/esm5/directives/for/for.module.js +1 -1
- package/esm5/directives/high-dpi/high-dpi.module.js +1 -1
- package/esm5/directives/hovered/hovered.module.js +1 -1
- package/esm5/directives/index.js +6 -5
- package/esm5/directives/input-mode/input-mode.module.js +1 -1
- package/esm5/directives/item/index.js +3 -0
- package/esm5/directives/item/item.directive.js +18 -0
- package/esm5/directives/item/item.module.js +16 -0
- package/esm5/directives/item/taiga-ui-cdk-directives-item.js +5 -0
- package/esm5/directives/let/let.directive.js +1 -1
- package/esm5/directives/let/let.module.js +1 -1
- package/esm5/directives/media/media.directive.js +2 -2
- package/esm5/directives/media/media.module.js +1 -1
- package/esm5/directives/obscured/obscured.module.js +1 -1
- package/esm5/directives/overscroll/overscroll.module.js +1 -1
- package/esm5/directives/pan/pan.directive.js +3 -2
- package/esm5/directives/pan/pan.module.js +1 -1
- package/esm5/directives/pressed/pressed.module.js +1 -1
- package/esm5/directives/prevent-default/prevent-default.module.js +1 -1
- package/esm5/directives/repeat-times/repeat-times.module.js +1 -1
- package/esm5/directives/resize/resize.module.js +1 -1
- package/esm5/directives/swipe/swipe.directive.js +3 -2
- package/esm5/directives/swipe/swipe.module.js +1 -1
- package/esm5/directives/validator/validator.module.js +1 -1
- package/esm5/directives/zoom/zoom.directive.js +3 -2
- package/esm5/directives/zoom/zoom.module.js +1 -1
- package/esm5/enums/index.js +2 -2
- package/esm5/interfaces/base-dialog-context.js +1 -1
- package/esm5/interfaces/base-dialog.js +1 -1
- package/esm5/interfaces/focusable-element-accessor.js +1 -1
- package/esm5/interfaces/index.js +1 -1
- package/esm5/observables/drag-and-drop-from.js +1 -1
- package/esm5/observables/focus-visible-observable.js +1 -1
- package/esm5/observables/mouse-drag-finish-from.js +1 -1
- package/esm5/observables/pressed-observable.js +1 -1
- package/esm5/pipes/filter/filter.module.js +1 -1
- package/esm5/pipes/mapper/mapper.module.js +1 -1
- package/esm5/services/focus-visible.service.js +1 -1
- package/esm5/services/index.js +2 -2
- package/esm5/services/obscured.service.js +1 -1
- package/esm5/services/pan.service.js +3 -3
- package/esm5/services/resize.service.js +1 -1
- package/esm5/services/static-request.service.js +1 -1
- package/esm5/tokens/active-element.js +5 -5
- package/esm5/tokens/index.js +3 -3
- package/esm5/tokens/is-android.js +1 -1
- package/esm5/types/index.js +1 -1
- package/esm5/utils/dom/contains-or-after.js +2 -4
- package/esm5/utils/dom/get-element-obscurers.js +1 -1
- package/esm5/utils/dom/index.js +2 -2
- package/esm5/utils/focus/get-closest-keyboard-focusable.js +1 -1
- package/esm5/utils/miscellaneous/index.js +3 -3
- package/fesm2015/taiga-ui-cdk-abstract.js +36 -7
- package/fesm2015/taiga-ui-cdk-abstract.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-components-dialog-host.js +1 -1
- package/fesm2015/taiga-ui-cdk-components-dialog-host.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-components-portal-host.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-constants.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-date-time.js +343 -343
- package/fesm2015/taiga-ui-cdk-date-time.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-active-zone.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-auto-focus.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-autofilled.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-checked.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-copy-processor.js +52 -0
- package/fesm2015/taiga-ui-cdk-directives-copy-processor.js.map +1 -0
- package/fesm2015/taiga-ui-cdk-directives-drag.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-droppable.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-element.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-focus-trap.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-focus-visible.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-focusable.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-focused.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-for.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-high-dpi.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-hovered.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-input-mode.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-item.js +30 -0
- package/fesm2015/taiga-ui-cdk-directives-item.js.map +1 -0
- package/fesm2015/taiga-ui-cdk-directives-let.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-media.js +1 -1
- package/fesm2015/taiga-ui-cdk-directives-media.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-obscured.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-overscroll.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-pan.js +2 -1
- package/fesm2015/taiga-ui-cdk-directives-pan.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-pressed.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-prevent-default.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-repeat-times.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-resize.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-swipe.js +2 -1
- package/fesm2015/taiga-ui-cdk-directives-swipe.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-validator.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-zoom.js +2 -1
- package/fesm2015/taiga-ui-cdk-directives-zoom.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives.js +5 -4
- package/fesm2015/taiga-ui-cdk-directives.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-enums.js +11 -11
- package/fesm2015/taiga-ui-cdk-enums.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-observables.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-pipes-filter.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-pipes-mapper.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-services.js +29 -29
- package/fesm2015/taiga-ui-cdk-services.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-tokens.js +10 -11
- package/fesm2015/taiga-ui-cdk-tokens.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-utils-dom.js +8 -10
- package/fesm2015/taiga-ui-cdk-utils-dom.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-utils-focus.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-utils-miscellaneous.js +13 -13
- package/fesm2015/taiga-ui-cdk-utils-miscellaneous.js.map +1 -1
- package/fesm5/taiga-ui-cdk-abstract.js +45 -7
- package/fesm5/taiga-ui-cdk-abstract.js.map +1 -1
- package/fesm5/taiga-ui-cdk-components-dialog-host.js +1 -1
- package/fesm5/taiga-ui-cdk-components-dialog-host.js.map +1 -1
- package/fesm5/taiga-ui-cdk-components-portal-host.js.map +1 -1
- package/fesm5/taiga-ui-cdk-constants.js.map +1 -1
- package/fesm5/taiga-ui-cdk-date-time.js +343 -343
- package/fesm5/taiga-ui-cdk-date-time.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-active-zone.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-auto-focus.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-autofilled.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-checked.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-copy-processor.js +56 -0
- package/fesm5/taiga-ui-cdk-directives-copy-processor.js.map +1 -0
- package/fesm5/taiga-ui-cdk-directives-drag.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-droppable.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-element.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-focus-trap.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-focus-visible.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-focusable.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-focused.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-for.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-high-dpi.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-hovered.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-input-mode.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-item.js +36 -0
- package/fesm5/taiga-ui-cdk-directives-item.js.map +1 -0
- package/fesm5/taiga-ui-cdk-directives-let.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-media.js +1 -1
- package/fesm5/taiga-ui-cdk-directives-media.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-obscured.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-overscroll.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-pan.js +2 -1
- package/fesm5/taiga-ui-cdk-directives-pan.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-pressed.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-prevent-default.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-repeat-times.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-resize.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-swipe.js +2 -1
- package/fesm5/taiga-ui-cdk-directives-swipe.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-validator.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives-zoom.js +2 -1
- package/fesm5/taiga-ui-cdk-directives-zoom.js.map +1 -1
- package/fesm5/taiga-ui-cdk-directives.js +5 -4
- package/fesm5/taiga-ui-cdk-directives.js.map +1 -1
- package/fesm5/taiga-ui-cdk-enums.js +11 -11
- package/fesm5/taiga-ui-cdk-enums.js.map +1 -1
- package/fesm5/taiga-ui-cdk-observables.js.map +1 -1
- package/fesm5/taiga-ui-cdk-pipes-filter.js.map +1 -1
- package/fesm5/taiga-ui-cdk-pipes-mapper.js.map +1 -1
- package/fesm5/taiga-ui-cdk-services.js +39 -39
- package/fesm5/taiga-ui-cdk-services.js.map +1 -1
- package/fesm5/taiga-ui-cdk-tokens.js +11 -11
- package/fesm5/taiga-ui-cdk-tokens.js.map +1 -1
- package/fesm5/taiga-ui-cdk-utils-dom.js +8 -10
- package/fesm5/taiga-ui-cdk-utils-dom.js.map +1 -1
- package/fesm5/taiga-ui-cdk-utils-focus.js.map +1 -1
- package/fesm5/taiga-ui-cdk-utils-miscellaneous.js +14 -14
- package/fesm5/taiga-ui-cdk-utils-miscellaneous.js.map +1 -1
- package/interfaces/focusable-element-accessor.d.ts +2 -0
- package/interfaces/index.d.ts +1 -1
- package/interfaces/taiga-ui-cdk-interfaces.metadata.json +1 -1
- package/observables/taiga-ui-cdk-observables.metadata.json +1 -1
- package/package.json +3 -3
- package/pipes/filter/taiga-ui-cdk-pipes-filter.metadata.json +1 -1
- package/pipes/mapper/taiga-ui-cdk-pipes-mapper.metadata.json +1 -1
- package/services/index.d.ts +1 -1
- package/services/taiga-ui-cdk-services.metadata.json +1 -1
- package/tokens/index.d.ts +2 -2
- package/tokens/taiga-ui-cdk-tokens.metadata.json +1 -1
- package/types/index.d.ts +1 -1
- package/types/taiga-ui-cdk-types.metadata.json +1 -1
- package/utils/dom/index.d.ts +1 -1
- package/utils/dom/taiga-ui-cdk-utils-dom.metadata.json +1 -1
- package/utils/miscellaneous/index.d.ts +2 -2
- package/utils/miscellaneous/taiga-ui-cdk-utils-miscellaneous.metadata.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { InjectionToken, inject } from '@angular/core';
|
|
2
|
+
import { CHAR_NO_BREAK_SPACE, CHAR_EN_DASH } from '@taiga-ui/cdk/constants';
|
|
1
3
|
import { tuiAssert } from '@taiga-ui/cdk/classes';
|
|
2
4
|
import { padStart } from '@taiga-ui/cdk/utils/format';
|
|
3
5
|
import { inRange, normalizeToIntNumber } from '@taiga-ui/cdk/utils/math';
|
|
4
|
-
import { CHAR_NO_BREAK_SPACE, CHAR_EN_DASH } from '@taiga-ui/cdk/constants';
|
|
5
|
-
import { InjectionToken, inject } from '@angular/core';
|
|
6
6
|
|
|
7
7
|
const DAYS_IN_WEEK = 7;
|
|
8
8
|
const DAYS_IN_NORMAL_YEAR = 365;
|
|
@@ -22,6 +22,44 @@ const MILLISECONDS_IN_MINUTE = MILLISECONDS_IN_SECOND * SECONDS_IN_MINUTE;
|
|
|
22
22
|
const MILLISECONDS_IN_HOUR = MILLISECONDS_IN_MINUTE * MINUTES_IN_HOUR;
|
|
23
23
|
const MILLISECONDS_IN_DAY = MILLISECONDS_IN_HOUR * HOURS_IN_DAY;
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated dont use it. See {@link TUI_DATE_FORMAT}
|
|
27
|
+
* TODO: get rid of this in v3.0
|
|
28
|
+
*/
|
|
29
|
+
const TUI_DATE_FILLER = new InjectionToken('date filler for Taiga UI', {
|
|
30
|
+
factory: () => `dd.mm.yyyy`,
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated dont use it
|
|
34
|
+
* TODO: get rid of this in v3.0
|
|
35
|
+
*/
|
|
36
|
+
const TUI_DATE_RANGE_FILLER = new InjectionToken('date range filler for Taiga UI', {
|
|
37
|
+
factory: () => {
|
|
38
|
+
const dateFiller = inject(TUI_DATE_FILLER);
|
|
39
|
+
return `${dateFiller}${RANGE_SEPARATOR_CHAR}${dateFiller}`;
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* @internal 'dd.mm.yyyy'.length
|
|
44
|
+
* Used in:
|
|
45
|
+
* - {@link TuiInputDateComponent}
|
|
46
|
+
* - {@link TuiInputDateRangeComponent}
|
|
47
|
+
* - {@link TuiInputDateTimeComponent}
|
|
48
|
+
*/
|
|
49
|
+
const DATE_FILLER_LENGTH = 10;
|
|
50
|
+
/**
|
|
51
|
+
* @internal
|
|
52
|
+
* Used in {@link TuiInputDateRangeComponent}
|
|
53
|
+
*/
|
|
54
|
+
const DATE_RANGE_FILLER_LENGTH = 2 * DATE_FILLER_LENGTH + RANGE_SEPARATOR_CHAR.length;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* TODO This token supports only DMY now. Add other {@link TuiDateMode} support
|
|
58
|
+
*/
|
|
59
|
+
const TUI_DATE_FORMAT = new InjectionToken('Active date format for Taiga UI', {
|
|
60
|
+
factory: () => 'DMY',
|
|
61
|
+
});
|
|
62
|
+
|
|
25
63
|
/**
|
|
26
64
|
* Immutable year object
|
|
27
65
|
* @nosideeffects
|
|
@@ -31,6 +69,54 @@ class TuiYear {
|
|
|
31
69
|
this.year = year;
|
|
32
70
|
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
33
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Checks year for validity
|
|
74
|
+
*/
|
|
75
|
+
static isValidYear(year) {
|
|
76
|
+
return Number.isInteger(year) && inRange(year, MIN_YEAR, MAX_YEAR + 1);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Check if passed year is a leap year
|
|
80
|
+
*/
|
|
81
|
+
static isLeapYear(year) {
|
|
82
|
+
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
83
|
+
return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns amount of leap years from year 0 to the passed one
|
|
87
|
+
*/
|
|
88
|
+
static getAbsoluteLeapYears(year) {
|
|
89
|
+
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
90
|
+
return Math.ceil(year / 400) + (Math.ceil(year / 4) - Math.ceil(year / 100));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated DONT USE IT (will be deleted soon)
|
|
94
|
+
*
|
|
95
|
+
* Returns day of week offset of the beginning of the passed year
|
|
96
|
+
*
|
|
97
|
+
* @param year
|
|
98
|
+
* @param absoluteLeapYears amount of leap years prior to the passed one
|
|
99
|
+
* @return offset in days
|
|
100
|
+
*/
|
|
101
|
+
static getYearStartDaysOffset(year, absoluteLeapYears) {
|
|
102
|
+
tuiAssert.assert(TuiYear.isValidYear(year));
|
|
103
|
+
tuiAssert.assert(Number.isInteger(absoluteLeapYears));
|
|
104
|
+
tuiAssert.assert(year >= absoluteLeapYears);
|
|
105
|
+
tuiAssert.assert(absoluteLeapYears >= 0);
|
|
106
|
+
return ((absoluteLeapYears * DAYS_IN_LEAP_YEAR +
|
|
107
|
+
(year - absoluteLeapYears) * DAYS_IN_NORMAL_YEAR +
|
|
108
|
+
5) %
|
|
109
|
+
DAYS_IN_WEEK);
|
|
110
|
+
}
|
|
111
|
+
static lengthBetween(from, to) {
|
|
112
|
+
return to.year - from.year;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Normalizes year by clamping it between min and max years
|
|
116
|
+
*/
|
|
117
|
+
static normalizeYearPart(year) {
|
|
118
|
+
return normalizeToIntNumber(year, MIN_YEAR, MAX_YEAR);
|
|
119
|
+
}
|
|
34
120
|
get formattedYear() {
|
|
35
121
|
return padStart(this.year.toString(), 4, '0');
|
|
36
122
|
}
|
|
@@ -100,68 +186,75 @@ class TuiYear {
|
|
|
100
186
|
toJSON() {
|
|
101
187
|
return this.formattedYear;
|
|
102
188
|
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Immutable object consisting of year and month
|
|
193
|
+
*/
|
|
194
|
+
class TuiMonth extends TuiYear {
|
|
103
195
|
/**
|
|
104
|
-
*
|
|
196
|
+
* @param year
|
|
197
|
+
* @param month (starting with 0)
|
|
105
198
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
199
|
+
constructor(year, month) {
|
|
200
|
+
super(year);
|
|
201
|
+
this.month = month;
|
|
202
|
+
tuiAssert.assert(TuiMonth.isValidMonth(year, month));
|
|
108
203
|
}
|
|
109
204
|
/**
|
|
110
|
-
*
|
|
205
|
+
* Tests month and year for validity
|
|
111
206
|
*/
|
|
112
|
-
static
|
|
113
|
-
|
|
114
|
-
return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0);
|
|
207
|
+
static isValidMonth(year, month) {
|
|
208
|
+
return TuiYear.isValidYear(year) && TuiMonth.isValidMonthPart(month);
|
|
115
209
|
}
|
|
116
210
|
/**
|
|
117
|
-
* Returns
|
|
211
|
+
* Returns number of days in a month
|
|
118
212
|
*/
|
|
119
|
-
static
|
|
120
|
-
tuiAssert.assert(
|
|
121
|
-
|
|
213
|
+
static getMonthDaysCount(month, isLeapYear) {
|
|
214
|
+
tuiAssert.assert(TuiMonth.isValidMonthPart(month));
|
|
215
|
+
switch (month) {
|
|
216
|
+
case 1 /* February */:
|
|
217
|
+
return isLeapYear ? 29 : 28;
|
|
218
|
+
case 3 /* April */:
|
|
219
|
+
case 5 /* June */:
|
|
220
|
+
case 8 /* September */:
|
|
221
|
+
case 10 /* November */:
|
|
222
|
+
return 30;
|
|
223
|
+
default:
|
|
224
|
+
return 31;
|
|
225
|
+
}
|
|
122
226
|
}
|
|
123
227
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* Returns day of week offset of the beginning of the passed year
|
|
127
|
-
*
|
|
128
|
-
* @param year
|
|
129
|
-
* @param absoluteLeapYears amount of leap years prior to the passed one
|
|
130
|
-
* @return offset in days
|
|
228
|
+
* Returns current month and year based on local time zone
|
|
229
|
+
* @nosideeffects
|
|
131
230
|
*/
|
|
132
|
-
static
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
231
|
+
static currentLocal() {
|
|
232
|
+
const nativeDate = new Date();
|
|
233
|
+
return new TuiMonth(nativeDate.getFullYear(), nativeDate.getMonth());
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Returns current month and year based on UTC
|
|
237
|
+
*/
|
|
238
|
+
static currentUtc() {
|
|
239
|
+
const nativeDate = new Date();
|
|
240
|
+
return new TuiMonth(nativeDate.getUTCFullYear(), nativeDate.getUTCMonth());
|
|
141
241
|
}
|
|
142
242
|
static lengthBetween(from, to) {
|
|
143
|
-
|
|
243
|
+
const absoluteFrom = from.month + from.year * 12;
|
|
244
|
+
const absoluteTo = to.month + to.year * 12;
|
|
245
|
+
return absoluteTo - absoluteFrom;
|
|
144
246
|
}
|
|
145
247
|
/**
|
|
146
|
-
* Normalizes
|
|
248
|
+
* Normalizes number by clamping it between min and max month
|
|
147
249
|
*/
|
|
148
|
-
static
|
|
149
|
-
return normalizeToIntNumber(
|
|
250
|
+
static normalizeMonthPart(month) {
|
|
251
|
+
return normalizeToIntNumber(month, MIN_MONTH, MAX_MONTH);
|
|
150
252
|
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Immutable object consisting of year and month
|
|
155
|
-
*/
|
|
156
|
-
class TuiMonth extends TuiYear {
|
|
157
253
|
/**
|
|
158
|
-
*
|
|
159
|
-
* @param month (starting with 0)
|
|
254
|
+
* Tests month for validity
|
|
160
255
|
*/
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
this.month = month;
|
|
164
|
-
tuiAssert.assert(TuiMonth.isValidMonth(year, month));
|
|
256
|
+
static isValidMonthPart(month) {
|
|
257
|
+
return Number.isInteger(month) && inRange(month, MIN_MONTH, MAX_MONTH + 1);
|
|
165
258
|
}
|
|
166
259
|
get formattedMonthPart() {
|
|
167
260
|
return padStart((this.month + 1).toString(), 2, '0');
|
|
@@ -266,61 +359,6 @@ class TuiMonth extends TuiYear {
|
|
|
266
359
|
toUtcNativeDate() {
|
|
267
360
|
return new Date(Date.UTC(this.year, this.month));
|
|
268
361
|
}
|
|
269
|
-
/**
|
|
270
|
-
* Tests month and year for validity
|
|
271
|
-
*/
|
|
272
|
-
static isValidMonth(year, month) {
|
|
273
|
-
return TuiYear.isValidYear(year) && TuiMonth.isValidMonthPart(month);
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Returns number of days in a month
|
|
277
|
-
*/
|
|
278
|
-
static getMonthDaysCount(month, isLeapYear) {
|
|
279
|
-
tuiAssert.assert(TuiMonth.isValidMonthPart(month));
|
|
280
|
-
switch (month) {
|
|
281
|
-
case 1 /* February */:
|
|
282
|
-
return isLeapYear ? 29 : 28;
|
|
283
|
-
case 3 /* April */:
|
|
284
|
-
case 5 /* June */:
|
|
285
|
-
case 8 /* September */:
|
|
286
|
-
case 10 /* November */:
|
|
287
|
-
return 30;
|
|
288
|
-
default:
|
|
289
|
-
return 31;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Returns current month and year based on local time zone
|
|
294
|
-
* @nosideeffects
|
|
295
|
-
*/
|
|
296
|
-
static currentLocal() {
|
|
297
|
-
const nativeDate = new Date();
|
|
298
|
-
return new TuiMonth(nativeDate.getFullYear(), nativeDate.getMonth());
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Returns current month and year based on UTC
|
|
302
|
-
*/
|
|
303
|
-
static currentUtc() {
|
|
304
|
-
const nativeDate = new Date();
|
|
305
|
-
return new TuiMonth(nativeDate.getUTCFullYear(), nativeDate.getUTCMonth());
|
|
306
|
-
}
|
|
307
|
-
static lengthBetween(from, to) {
|
|
308
|
-
const absoluteFrom = from.month + from.year * 12;
|
|
309
|
-
const absoluteTo = to.month + to.year * 12;
|
|
310
|
-
return absoluteTo - absoluteFrom;
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Normalizes number by clamping it between min and max month
|
|
314
|
-
*/
|
|
315
|
-
static normalizeMonthPart(month) {
|
|
316
|
-
return normalizeToIntNumber(month, MIN_MONTH, MAX_MONTH);
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Tests month for validity
|
|
320
|
-
*/
|
|
321
|
-
static isValidMonthPart(month) {
|
|
322
|
-
return Number.isInteger(month) && inRange(month, MIN_MONTH, MAX_MONTH + 1);
|
|
323
|
-
}
|
|
324
362
|
}
|
|
325
363
|
|
|
326
364
|
// TODO: Localized formatting
|
|
@@ -333,24 +371,143 @@ class TuiDay extends TuiMonth {
|
|
|
333
371
|
this.day = day;
|
|
334
372
|
tuiAssert.assert(TuiDay.isValidDay(year, month, day));
|
|
335
373
|
}
|
|
336
|
-
get formattedDayPart() {
|
|
337
|
-
return padStart(this.day.toString(), 2, '0');
|
|
338
|
-
}
|
|
339
374
|
/**
|
|
340
|
-
*
|
|
375
|
+
* Creates {@link TuiDay} from native {@link Date} based on local time zone
|
|
341
376
|
*/
|
|
342
|
-
|
|
343
|
-
return
|
|
344
|
-
}
|
|
345
|
-
get isWeekend() {
|
|
346
|
-
const dayOfWeek = this.dayOfWeek(false);
|
|
347
|
-
return dayOfWeek === 6 /* Saturday */ || dayOfWeek === 0 /* Sunday */;
|
|
377
|
+
static fromLocalNativeDate(date) {
|
|
378
|
+
return new TuiDay(date.getFullYear(), date.getMonth(), date.getDate());
|
|
348
379
|
}
|
|
349
380
|
/**
|
|
350
|
-
*
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
381
|
+
* Creates {@link TuiDay} from native {@link Date} using UTC
|
|
382
|
+
*/
|
|
383
|
+
static fromUtcNativeDate(date) {
|
|
384
|
+
return new TuiDay(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Check validity of year, month and day
|
|
388
|
+
*
|
|
389
|
+
* @param year
|
|
390
|
+
* @param month
|
|
391
|
+
* @param day
|
|
392
|
+
* @return boolean validity
|
|
393
|
+
*/
|
|
394
|
+
static isValidDay(year, month, day) {
|
|
395
|
+
return (TuiMonth.isValidMonth(year, month) &&
|
|
396
|
+
Number.isInteger(day) &&
|
|
397
|
+
inRange(day, MIN_DAY, TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year)) + 1));
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* @deprecated DONT USE IT (will be deleted soon)
|
|
401
|
+
*
|
|
402
|
+
* Calculated day on a calendar grid
|
|
403
|
+
*
|
|
404
|
+
* @param month
|
|
405
|
+
* @param row row in a calendar
|
|
406
|
+
* @param col column in a calendar
|
|
407
|
+
* @return resulting day on these coordinates (could exceed passed month)
|
|
408
|
+
*/
|
|
409
|
+
static getDayFromMonthRowCol(month, row, col) {
|
|
410
|
+
tuiAssert.assert(Number.isInteger(row));
|
|
411
|
+
tuiAssert.assert(inRange(row, 0, 6));
|
|
412
|
+
tuiAssert.assert(Number.isInteger(col));
|
|
413
|
+
tuiAssert.assert(inRange(col, 0, DAYS_IN_WEEK));
|
|
414
|
+
let day = row * DAYS_IN_WEEK + col - month.monthStartDaysOffset + 1;
|
|
415
|
+
if (day > month.daysCount) {
|
|
416
|
+
day = day - month.daysCount;
|
|
417
|
+
month = month.append({ month: 1 });
|
|
418
|
+
}
|
|
419
|
+
if (day <= 0) {
|
|
420
|
+
month = month.append({ month: -1 });
|
|
421
|
+
day = month.daysCount + day;
|
|
422
|
+
}
|
|
423
|
+
return new TuiDay(month.year, month.month, day);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Current day based on local time zone
|
|
427
|
+
*/
|
|
428
|
+
static currentLocal() {
|
|
429
|
+
const nativeDate = new Date();
|
|
430
|
+
const year = nativeDate.getFullYear();
|
|
431
|
+
const month = nativeDate.getMonth();
|
|
432
|
+
const day = nativeDate.getDate();
|
|
433
|
+
return new TuiDay(year, month, day);
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Calculates {@link TuiDay} normalizing year, month and day. {@link NaN} is turned into minimal value.
|
|
437
|
+
*
|
|
438
|
+
* @param year any year value, including invalid
|
|
439
|
+
* @param month any month value, including invalid (months start with 0)
|
|
440
|
+
* @param day any day value, including invalid
|
|
441
|
+
* @return normalized date
|
|
442
|
+
*/
|
|
443
|
+
static normalizeOf(year, month, day) {
|
|
444
|
+
const normalizedYear = TuiYear.normalizeYearPart(year);
|
|
445
|
+
const normalizedMonth = TuiMonth.normalizeMonthPart(month);
|
|
446
|
+
const normalizedDay = TuiDay.normalizeDayPart(day, normalizedMonth, normalizedYear);
|
|
447
|
+
return new TuiDay(normalizedYear, normalizedMonth, normalizedDay);
|
|
448
|
+
}
|
|
449
|
+
static lengthBetween(from, to) {
|
|
450
|
+
return Math.round((to.toLocalNativeDate().getTime() - from.toLocalNativeDate().getTime()) /
|
|
451
|
+
(1000 * 60 * 60 * 24));
|
|
452
|
+
}
|
|
453
|
+
// TODO: Move month and year related code corresponding classes
|
|
454
|
+
/**
|
|
455
|
+
* Parsing a string with date with normalization
|
|
456
|
+
*
|
|
457
|
+
* @param yearMonthDayString date string in format of DD.MM.Yyyy
|
|
458
|
+
* @return normalized date
|
|
459
|
+
*/
|
|
460
|
+
static normalizeParse(yearMonthDayString) {
|
|
461
|
+
const day = parseInt(yearMonthDayString.slice(0, 2), 10);
|
|
462
|
+
const month = parseInt(yearMonthDayString.slice(3, 5), 10) - 1;
|
|
463
|
+
const year = parseInt(yearMonthDayString.slice(6, 10), 10);
|
|
464
|
+
return TuiDay.normalizeOf(year, month, day);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Parsing a date stringified in a toJSON format
|
|
468
|
+
* @param yearMonthDayString date string in format of YYYY-MM-DD
|
|
469
|
+
* @return date
|
|
470
|
+
* @throws exceptions if any part of the date is invalid
|
|
471
|
+
*/
|
|
472
|
+
static jsonParse(yearMonthDayString) {
|
|
473
|
+
const day = parseInt(yearMonthDayString.slice(8, 10), 10);
|
|
474
|
+
const month = parseInt(yearMonthDayString.slice(5, 7), 10) - 1;
|
|
475
|
+
const year = parseInt(yearMonthDayString.slice(0, 4), 10);
|
|
476
|
+
if (!TuiYear.isValidYear(year)) {
|
|
477
|
+
throw new Error('Invalid year: ' + year);
|
|
478
|
+
}
|
|
479
|
+
if (!TuiMonth.isValidMonth(year, month)) {
|
|
480
|
+
throw new Error('Invalid month: ' + month);
|
|
481
|
+
}
|
|
482
|
+
if (!Number.isInteger(day) ||
|
|
483
|
+
!inRange(day, MIN_DAY, TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year)) + 1)) {
|
|
484
|
+
throw new Error('Invalid day: ' + day);
|
|
485
|
+
}
|
|
486
|
+
return new TuiDay(year, month, day);
|
|
487
|
+
}
|
|
488
|
+
static normalizeDayPart(day, month, year) {
|
|
489
|
+
tuiAssert.assert(TuiMonth.isValidMonth(year, month));
|
|
490
|
+
const monthDaysCount = TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year));
|
|
491
|
+
return normalizeToIntNumber(day, 1, monthDaysCount);
|
|
492
|
+
}
|
|
493
|
+
get formattedDayPart() {
|
|
494
|
+
return padStart(this.day.toString(), 2, '0');
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Formatted whole date
|
|
498
|
+
*/
|
|
499
|
+
get formattedDay() {
|
|
500
|
+
return `${this.formattedDayPart}.${this.formattedMonth}`;
|
|
501
|
+
}
|
|
502
|
+
get isWeekend() {
|
|
503
|
+
const dayOfWeek = this.dayOfWeek(false);
|
|
504
|
+
return dayOfWeek === 6 /* Saturday */ || dayOfWeek === 0 /* Sunday */;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Returns day of week
|
|
508
|
+
*
|
|
509
|
+
* @param startFromMonday whether week starts from Monday and not from Sunday
|
|
510
|
+
* @return day of week (from 0 to 6)
|
|
354
511
|
*/
|
|
355
512
|
dayOfWeek(startFromMonday = true) {
|
|
356
513
|
const dayOfWeek = startFromMonday
|
|
@@ -470,161 +627,8 @@ class TuiDay extends TuiMonth {
|
|
|
470
627
|
toUtcNativeDate() {
|
|
471
628
|
return new Date(Date.UTC(this.year, this.month, this.day));
|
|
472
629
|
}
|
|
473
|
-
/**
|
|
474
|
-
* Creates {@link TuiDay} from native {@link Date} based on local time zone
|
|
475
|
-
*/
|
|
476
|
-
static fromLocalNativeDate(date) {
|
|
477
|
-
return new TuiDay(date.getFullYear(), date.getMonth(), date.getDate());
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* Creates {@link TuiDay} from native {@link Date} using UTC
|
|
481
|
-
*/
|
|
482
|
-
static fromUtcNativeDate(date) {
|
|
483
|
-
return new TuiDay(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Check validity of year, month and day
|
|
487
|
-
*
|
|
488
|
-
* @param year
|
|
489
|
-
* @param month
|
|
490
|
-
* @param day
|
|
491
|
-
* @return boolean validity
|
|
492
|
-
*/
|
|
493
|
-
static isValidDay(year, month, day) {
|
|
494
|
-
return (TuiMonth.isValidMonth(year, month) &&
|
|
495
|
-
Number.isInteger(day) &&
|
|
496
|
-
inRange(day, MIN_DAY, TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year)) + 1));
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* @deprecated DONT USE IT (will be deleted soon)
|
|
500
|
-
*
|
|
501
|
-
* Calculated day on a calendar grid
|
|
502
|
-
*
|
|
503
|
-
* @param month
|
|
504
|
-
* @param row row in a calendar
|
|
505
|
-
* @param col column in a calendar
|
|
506
|
-
* @return resulting day on these coordinates (could exceed passed month)
|
|
507
|
-
*/
|
|
508
|
-
static getDayFromMonthRowCol(month, row, col) {
|
|
509
|
-
tuiAssert.assert(Number.isInteger(row));
|
|
510
|
-
tuiAssert.assert(inRange(row, 0, 6));
|
|
511
|
-
tuiAssert.assert(Number.isInteger(col));
|
|
512
|
-
tuiAssert.assert(inRange(col, 0, DAYS_IN_WEEK));
|
|
513
|
-
let day = row * DAYS_IN_WEEK + col - month.monthStartDaysOffset + 1;
|
|
514
|
-
if (day > month.daysCount) {
|
|
515
|
-
day = day - month.daysCount;
|
|
516
|
-
month = month.append({ month: 1 });
|
|
517
|
-
}
|
|
518
|
-
if (day <= 0) {
|
|
519
|
-
month = month.append({ month: -1 });
|
|
520
|
-
day = month.daysCount + day;
|
|
521
|
-
}
|
|
522
|
-
return new TuiDay(month.year, month.month, day);
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Current day based on local time zone
|
|
526
|
-
*/
|
|
527
|
-
static currentLocal() {
|
|
528
|
-
const nativeDate = new Date();
|
|
529
|
-
const year = nativeDate.getFullYear();
|
|
530
|
-
const month = nativeDate.getMonth();
|
|
531
|
-
const day = nativeDate.getDate();
|
|
532
|
-
return new TuiDay(year, month, day);
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* Calculates {@link TuiDay} normalizing year, month and day. {@link NaN} is turned into minimal value.
|
|
536
|
-
*
|
|
537
|
-
* @param year any year value, including invalid
|
|
538
|
-
* @param month any month value, including invalid (months start with 0)
|
|
539
|
-
* @param day any day value, including invalid
|
|
540
|
-
* @return normalized date
|
|
541
|
-
*/
|
|
542
|
-
static normalizeOf(year, month, day) {
|
|
543
|
-
const normalizedYear = TuiYear.normalizeYearPart(year);
|
|
544
|
-
const normalizedMonth = TuiMonth.normalizeMonthPart(month);
|
|
545
|
-
const normalizedDay = TuiDay.normalizeDayPart(day, normalizedMonth, normalizedYear);
|
|
546
|
-
return new TuiDay(normalizedYear, normalizedMonth, normalizedDay);
|
|
547
|
-
}
|
|
548
|
-
static lengthBetween(from, to) {
|
|
549
|
-
return Math.round((to.toLocalNativeDate().getTime() - from.toLocalNativeDate().getTime()) /
|
|
550
|
-
(1000 * 60 * 60 * 24));
|
|
551
|
-
}
|
|
552
|
-
// TODO: Move month and year related code corresponding classes
|
|
553
|
-
/**
|
|
554
|
-
* Parsing a string with date with normalization
|
|
555
|
-
*
|
|
556
|
-
* @param yearMonthDayString date string in format of DD.MM.Yyyy
|
|
557
|
-
* @return normalized date
|
|
558
|
-
*/
|
|
559
|
-
static normalizeParse(yearMonthDayString) {
|
|
560
|
-
const day = parseInt(yearMonthDayString.slice(0, 2), 10);
|
|
561
|
-
const month = parseInt(yearMonthDayString.slice(3, 5), 10) - 1;
|
|
562
|
-
const year = parseInt(yearMonthDayString.slice(6, 10), 10);
|
|
563
|
-
return TuiDay.normalizeOf(year, month, day);
|
|
564
|
-
}
|
|
565
|
-
/**
|
|
566
|
-
* Parsing a date stringified in a toJSON format
|
|
567
|
-
* @param yearMonthDayString date string in format of YYYY-MM-DD
|
|
568
|
-
* @return date
|
|
569
|
-
* @throws exceptions if any part of the date is invalid
|
|
570
|
-
*/
|
|
571
|
-
static jsonParse(yearMonthDayString) {
|
|
572
|
-
const day = parseInt(yearMonthDayString.slice(8, 10), 10);
|
|
573
|
-
const month = parseInt(yearMonthDayString.slice(5, 7), 10) - 1;
|
|
574
|
-
const year = parseInt(yearMonthDayString.slice(0, 4), 10);
|
|
575
|
-
if (!TuiYear.isValidYear(year)) {
|
|
576
|
-
throw new Error('Invalid year: ' + year);
|
|
577
|
-
}
|
|
578
|
-
if (!TuiMonth.isValidMonth(year, month)) {
|
|
579
|
-
throw new Error('Invalid month: ' + month);
|
|
580
|
-
}
|
|
581
|
-
if (!Number.isInteger(day) ||
|
|
582
|
-
!inRange(day, MIN_DAY, TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year)) + 1)) {
|
|
583
|
-
throw new Error('Invalid day: ' + day);
|
|
584
|
-
}
|
|
585
|
-
return new TuiDay(year, month, day);
|
|
586
|
-
}
|
|
587
|
-
static normalizeDayPart(day, month, year) {
|
|
588
|
-
tuiAssert.assert(TuiMonth.isValidMonth(year, month));
|
|
589
|
-
const monthDaysCount = TuiMonth.getMonthDaysCount(month, TuiYear.isLeapYear(year));
|
|
590
|
-
return normalizeToIntNumber(day, 1, monthDaysCount);
|
|
591
|
-
}
|
|
592
630
|
}
|
|
593
631
|
|
|
594
|
-
const TUI_FIRST_DAY = new TuiDay(MIN_YEAR, MIN_MONTH, MIN_DAY);
|
|
595
|
-
const TUI_LAST_DAY = new TuiDay(MAX_YEAR, MAX_MONTH, 31);
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
* @deprecated dont use it. See {@link TUI_DATE_FORMAT}
|
|
599
|
-
* TODO: get rid of this in v3.0
|
|
600
|
-
*/
|
|
601
|
-
const TUI_DATE_FILLER = new InjectionToken('date filler for Taiga UI', {
|
|
602
|
-
factory: () => `dd.mm.yyyy`,
|
|
603
|
-
});
|
|
604
|
-
/**
|
|
605
|
-
* @deprecated dont use it
|
|
606
|
-
* TODO: get rid of this in v3.0
|
|
607
|
-
*/
|
|
608
|
-
const TUI_DATE_RANGE_FILLER = new InjectionToken('date range filler for Taiga UI', {
|
|
609
|
-
factory: () => {
|
|
610
|
-
const dateFiller = inject(TUI_DATE_FILLER);
|
|
611
|
-
return `${dateFiller}${RANGE_SEPARATOR_CHAR}${dateFiller}`;
|
|
612
|
-
},
|
|
613
|
-
});
|
|
614
|
-
/**
|
|
615
|
-
* @internal 'dd.mm.yyyy'.length
|
|
616
|
-
* Used in:
|
|
617
|
-
* - {@link TuiInputDateComponent}
|
|
618
|
-
* - {@link TuiInputDateRangeComponent}
|
|
619
|
-
* - {@link TuiInputDateTimeComponent}
|
|
620
|
-
*/
|
|
621
|
-
const DATE_FILLER_LENGTH = 10;
|
|
622
|
-
/**
|
|
623
|
-
* @internal
|
|
624
|
-
* Used in {@link TuiInputDateRangeComponent}
|
|
625
|
-
*/
|
|
626
|
-
const DATE_RANGE_FILLER_LENGTH = 2 * DATE_FILLER_LENGTH + RANGE_SEPARATOR_CHAR.length;
|
|
627
|
-
|
|
628
632
|
/**
|
|
629
633
|
* An immutable range of two {@link TuiMonth} objects
|
|
630
634
|
*/
|
|
@@ -634,6 +638,11 @@ class TuiMonthRange {
|
|
|
634
638
|
this.to = to;
|
|
635
639
|
tuiAssert.assert(from.monthSameOrBefore(to));
|
|
636
640
|
}
|
|
641
|
+
static sort(month1, month2) {
|
|
642
|
+
return month1.monthSameOrBefore(month2)
|
|
643
|
+
? new TuiMonthRange(month1, month2)
|
|
644
|
+
: new TuiMonthRange(month2, month1);
|
|
645
|
+
}
|
|
637
646
|
get isSingleMonth() {
|
|
638
647
|
return this.from.monthSame(this.to);
|
|
639
648
|
}
|
|
@@ -646,11 +655,6 @@ class TuiMonthRange {
|
|
|
646
655
|
toString() {
|
|
647
656
|
return `${this.from}${RANGE_SEPARATOR_CHAR}${this.to}`;
|
|
648
657
|
}
|
|
649
|
-
static sort(month1, month2) {
|
|
650
|
-
return month1.monthSameOrBefore(month2)
|
|
651
|
-
? new TuiMonthRange(month1, month2)
|
|
652
|
-
: new TuiMonthRange(month2, month1);
|
|
653
|
-
}
|
|
654
658
|
}
|
|
655
659
|
|
|
656
660
|
/**
|
|
@@ -663,6 +667,31 @@ class TuiDayRange extends TuiMonthRange {
|
|
|
663
667
|
this.to = to;
|
|
664
668
|
tuiAssert.assert(from.daySameOrBefore(to));
|
|
665
669
|
}
|
|
670
|
+
/**
|
|
671
|
+
* Creates range from two days after sorting them
|
|
672
|
+
*
|
|
673
|
+
* @param day1
|
|
674
|
+
* @param day2
|
|
675
|
+
* @return new range with sorted days
|
|
676
|
+
*/
|
|
677
|
+
static sort(day1, day2) {
|
|
678
|
+
return day1.daySameOrBefore(day2)
|
|
679
|
+
? new TuiDayRange(day1, day2)
|
|
680
|
+
: new TuiDayRange(day2, day1);
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Parse and correct a day range in string format
|
|
684
|
+
*
|
|
685
|
+
* @param rangeString a string of dates in a format dd.mm.yyyy - dd.mm.yyyy
|
|
686
|
+
* @return normalized day range object
|
|
687
|
+
*/
|
|
688
|
+
static normalizeParse(rangeString) {
|
|
689
|
+
const leftDay = TuiDay.normalizeParse(rangeString.slice(0, DATE_FILLER_LENGTH));
|
|
690
|
+
if (rangeString.length < DATE_RANGE_FILLER_LENGTH) {
|
|
691
|
+
return new TuiDayRange(leftDay, leftDay);
|
|
692
|
+
}
|
|
693
|
+
return TuiDayRange.sort(leftDay, TuiDay.normalizeParse(rangeString.slice(DATE_FILLER_LENGTH + RANGE_SEPARATOR_CHAR.length)));
|
|
694
|
+
}
|
|
666
695
|
get isSingleDay() {
|
|
667
696
|
return this.from.daySame(this.to);
|
|
668
697
|
}
|
|
@@ -691,33 +720,11 @@ class TuiDayRange extends TuiMonthRange {
|
|
|
691
720
|
dayLimit(min, max) {
|
|
692
721
|
return new TuiDayRange(this.from.dayLimit(min, max), this.to.dayLimit(min, max));
|
|
693
722
|
}
|
|
694
|
-
/**
|
|
695
|
-
* Creates range from two days after sorting them
|
|
696
|
-
*
|
|
697
|
-
* @param day1
|
|
698
|
-
* @param day2
|
|
699
|
-
* @return new range with sorted days
|
|
700
|
-
*/
|
|
701
|
-
static sort(day1, day2) {
|
|
702
|
-
return day1.daySameOrBefore(day2)
|
|
703
|
-
? new TuiDayRange(day1, day2)
|
|
704
|
-
: new TuiDayRange(day2, day1);
|
|
705
|
-
}
|
|
706
|
-
/**
|
|
707
|
-
* Parse and correct a day range in string format
|
|
708
|
-
*
|
|
709
|
-
* @param rangeString a string of dates in a format dd.mm.yyyy - dd.mm.yyyy
|
|
710
|
-
* @return normalized day range object
|
|
711
|
-
*/
|
|
712
|
-
static normalizeParse(rangeString) {
|
|
713
|
-
const leftDay = TuiDay.normalizeParse(rangeString.slice(0, DATE_FILLER_LENGTH));
|
|
714
|
-
if (rangeString.length < DATE_RANGE_FILLER_LENGTH) {
|
|
715
|
-
return new TuiDayRange(leftDay, leftDay);
|
|
716
|
-
}
|
|
717
|
-
return TuiDayRange.sort(leftDay, TuiDay.normalizeParse(rangeString.slice(DATE_FILLER_LENGTH + RANGE_SEPARATOR_CHAR.length)));
|
|
718
|
-
}
|
|
719
723
|
}
|
|
720
724
|
|
|
725
|
+
const TUI_FIRST_DAY = new TuiDay(MIN_YEAR, MIN_MONTH, MIN_DAY);
|
|
726
|
+
const TUI_LAST_DAY = new TuiDay(MAX_YEAR, MAX_MONTH, 31);
|
|
727
|
+
|
|
721
728
|
/**
|
|
722
729
|
* Immutable time object with hours, minutes, seconds and ms
|
|
723
730
|
*/
|
|
@@ -729,45 +736,6 @@ class TuiTime {
|
|
|
729
736
|
this.ms = ms;
|
|
730
737
|
tuiAssert.assert(TuiTime.isValidTime(hours, minutes, seconds, ms), 'Time must be real, but got:', hours, minutes, seconds, ms);
|
|
731
738
|
}
|
|
732
|
-
/**
|
|
733
|
-
* Shifts time by hours and minutes
|
|
734
|
-
*/
|
|
735
|
-
shift({ hours = 0, minutes = 0, seconds = 0, ms = 0 }) {
|
|
736
|
-
const newMs = (1000 + this.ms + (ms % 1000)) % 1000;
|
|
737
|
-
const secondsInMs = ms < 0 ? Math.ceil(ms / 1000) : Math.floor(ms / 1000);
|
|
738
|
-
const secondsToAdd = secondsInMs + seconds;
|
|
739
|
-
const newSeconds = (60 + this.seconds + (secondsToAdd % 60)) % 60;
|
|
740
|
-
const minutesInSeconds = secondsToAdd < 0
|
|
741
|
-
? Math.ceil(secondsToAdd / 60)
|
|
742
|
-
: Math.floor(secondsToAdd / 60);
|
|
743
|
-
const minutesToAdd = minutesInSeconds + minutes;
|
|
744
|
-
const newMinutes = (60 + this.minutes + (minutesToAdd % 60)) % 60;
|
|
745
|
-
const hoursInMinutes = minutesToAdd < 0
|
|
746
|
-
? Math.ceil(minutesToAdd / 60)
|
|
747
|
-
: Math.floor(minutesToAdd / 60);
|
|
748
|
-
const hoursToAdd = hoursInMinutes + hours;
|
|
749
|
-
const newHours = (24 + this.hours + (hoursToAdd % 24)) % 24;
|
|
750
|
-
return new TuiTime(newHours, newMinutes, newSeconds, newMs);
|
|
751
|
-
}
|
|
752
|
-
/**
|
|
753
|
-
* Converts TuiTime to string
|
|
754
|
-
*/
|
|
755
|
-
toString(mode) {
|
|
756
|
-
const needAddMs = mode === 'HH:MM:SS.MSS' || (!mode && this.ms > 0);
|
|
757
|
-
const needAddSeconds = needAddMs || mode === 'HH:MM:SS' || (!mode && this.seconds > 0);
|
|
758
|
-
return (`${this.formatTime(this.hours)}:${this.formatTime(this.minutes)}` +
|
|
759
|
-
`${needAddSeconds ? ':' + this.formatTime(this.seconds) : ''}` +
|
|
760
|
-
`${needAddMs ? '.' + this.formatTime(this.ms, 3) : ''}`);
|
|
761
|
-
}
|
|
762
|
-
/**
|
|
763
|
-
* Converts TuiTime to milliseconds
|
|
764
|
-
*/
|
|
765
|
-
toAbsoluteMilliseconds() {
|
|
766
|
-
return (this.hours * MILLISECONDS_IN_HOUR +
|
|
767
|
-
this.minutes * MILLISECONDS_IN_MINUTE +
|
|
768
|
-
this.seconds * 1000 +
|
|
769
|
-
this.ms);
|
|
770
|
-
}
|
|
771
739
|
/**
|
|
772
740
|
* Checks if time is valid
|
|
773
741
|
*/
|
|
@@ -824,18 +792,50 @@ class TuiTime {
|
|
|
824
792
|
static fromLocalNativeDate(date) {
|
|
825
793
|
return new TuiTime(date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
|
|
826
794
|
}
|
|
795
|
+
/**
|
|
796
|
+
* Shifts time by hours and minutes
|
|
797
|
+
*/
|
|
798
|
+
shift({ hours = 0, minutes = 0, seconds = 0, ms = 0 }) {
|
|
799
|
+
const newMs = (1000 + this.ms + (ms % 1000)) % 1000;
|
|
800
|
+
const secondsInMs = ms < 0 ? Math.ceil(ms / 1000) : Math.floor(ms / 1000);
|
|
801
|
+
const secondsToAdd = secondsInMs + seconds;
|
|
802
|
+
const newSeconds = (60 + this.seconds + (secondsToAdd % 60)) % 60;
|
|
803
|
+
const minutesInSeconds = secondsToAdd < 0
|
|
804
|
+
? Math.ceil(secondsToAdd / 60)
|
|
805
|
+
: Math.floor(secondsToAdd / 60);
|
|
806
|
+
const minutesToAdd = minutesInSeconds + minutes;
|
|
807
|
+
const newMinutes = (60 + this.minutes + (minutesToAdd % 60)) % 60;
|
|
808
|
+
const hoursInMinutes = minutesToAdd < 0
|
|
809
|
+
? Math.ceil(minutesToAdd / 60)
|
|
810
|
+
: Math.floor(minutesToAdd / 60);
|
|
811
|
+
const hoursToAdd = hoursInMinutes + hours;
|
|
812
|
+
const newHours = (24 + this.hours + (hoursToAdd % 24)) % 24;
|
|
813
|
+
return new TuiTime(newHours, newMinutes, newSeconds, newMs);
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Converts TuiTime to string
|
|
817
|
+
*/
|
|
818
|
+
toString(mode) {
|
|
819
|
+
const needAddMs = mode === 'HH:MM:SS.MSS' || (!mode && this.ms > 0);
|
|
820
|
+
const needAddSeconds = needAddMs || mode === 'HH:MM:SS' || (!mode && this.seconds > 0);
|
|
821
|
+
return (`${this.formatTime(this.hours)}:${this.formatTime(this.minutes)}` +
|
|
822
|
+
`${needAddSeconds ? ':' + this.formatTime(this.seconds) : ''}` +
|
|
823
|
+
`${needAddMs ? '.' + this.formatTime(this.ms, 3) : ''}`);
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Converts TuiTime to milliseconds
|
|
827
|
+
*/
|
|
828
|
+
toAbsoluteMilliseconds() {
|
|
829
|
+
return (this.hours * MILLISECONDS_IN_HOUR +
|
|
830
|
+
this.minutes * MILLISECONDS_IN_MINUTE +
|
|
831
|
+
this.seconds * 1000 +
|
|
832
|
+
this.ms);
|
|
833
|
+
}
|
|
827
834
|
formatTime(time, digits = 2) {
|
|
828
835
|
return padStart(time.toString(), digits, '0');
|
|
829
836
|
}
|
|
830
837
|
}
|
|
831
838
|
|
|
832
|
-
/**
|
|
833
|
-
* TODO This token supports only DMY now. Add other {@link TuiDateMode} support
|
|
834
|
-
*/
|
|
835
|
-
const TUI_DATE_FORMAT = new InjectionToken('Active date format for Taiga UI', {
|
|
836
|
-
factory: () => 'DMY',
|
|
837
|
-
});
|
|
838
|
-
|
|
839
839
|
/**
|
|
840
840
|
* Generated bundle index. Do not edit.
|
|
841
841
|
*/
|