@refinitiv-ui/elements 5.12.2 → 6.0.0-next.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/README.md +4 -4
- package/lib/accordion/index.d.ts +5 -0
- package/lib/accordion/index.js +2 -2
- package/lib/accordion/themes/halo/dark/index.js +1 -1
- package/lib/accordion/themes/halo/light/index.js +1 -1
- package/lib/accordion/themes/solar/charcoal/index.js +1 -1
- package/lib/accordion/themes/solar/pearl/index.js +1 -1
- package/lib/appstate-bar/index.d.ts +11 -0
- package/lib/appstate-bar/index.js +8 -3
- package/lib/appstate-bar/themes/halo/dark/index.js +1 -1
- package/lib/appstate-bar/themes/halo/light/index.js +1 -1
- package/lib/appstate-bar/themes/solar/charcoal/index.js +1 -1
- package/lib/appstate-bar/themes/solar/pearl/index.js +1 -1
- package/lib/autosuggest/index.d.ts +5 -0
- package/lib/autosuggest/index.js +22 -12
- package/lib/autosuggest/themes/halo/dark/index.js +3 -3
- package/lib/autosuggest/themes/halo/light/index.js +3 -3
- package/lib/autosuggest/themes/solar/charcoal/index.js +3 -3
- package/lib/autosuggest/themes/solar/pearl/index.js +3 -3
- package/lib/button/index.d.ts +7 -13
- package/lib/button/index.js +8 -43
- package/lib/button/themes/halo/dark/index.js +1 -1
- package/lib/button/themes/halo/light/index.js +1 -1
- package/lib/button/themes/solar/charcoal/index.js +1 -1
- package/lib/button/themes/solar/pearl/index.js +1 -1
- package/lib/button-bar/index.d.ts +5 -0
- package/lib/button-bar/index.js +4 -5
- package/lib/button-bar/themes/halo/dark/index.js +1 -1
- package/lib/button-bar/themes/halo/light/index.js +1 -1
- package/lib/button-bar/themes/solar/charcoal/index.js +1 -1
- package/lib/button-bar/themes/solar/pearl/index.js +1 -1
- package/lib/calendar/constants.js +1 -1
- package/lib/calendar/index.d.ts +6 -1
- package/lib/calendar/index.js +39 -15
- package/lib/calendar/locales.js +5 -5
- package/lib/calendar/themes/halo/dark/index.js +1 -1
- package/lib/calendar/themes/halo/light/index.js +1 -1
- package/lib/calendar/themes/solar/charcoal/index.js +1 -1
- package/lib/calendar/themes/solar/pearl/index.js +1 -1
- package/lib/calendar/types.d.ts +1 -1
- package/lib/calendar/utils.js +5 -5
- package/lib/canvas/index.d.ts +5 -0
- package/lib/canvas/index.js +3 -4
- package/lib/card/index.d.ts +21 -0
- package/lib/card/index.js +37 -15
- package/lib/card/themes/halo/dark/index.js +3 -3
- package/lib/card/themes/halo/light/index.js +3 -3
- package/lib/card/themes/solar/charcoal/index.js +3 -3
- package/lib/card/themes/solar/pearl/index.js +3 -3
- package/lib/chart/index.d.ts +5 -0
- package/lib/chart/index.js +18 -22
- package/lib/chart/plugins/doughnut-center-label.js +6 -11
- package/lib/chart/themes/halo/dark/index.js +2 -2
- package/lib/chart/themes/halo/light/index.js +2 -2
- package/lib/chart/themes/solar/charcoal/index.js +2 -2
- package/lib/chart/themes/solar/pearl/index.js +2 -2
- package/lib/checkbox/index.d.ts +5 -0
- package/lib/checkbox/index.js +3 -3
- package/lib/checkbox/themes/halo/dark/index.js +2 -2
- package/lib/checkbox/themes/halo/light/index.js +2 -2
- package/lib/checkbox/themes/solar/charcoal/index.js +2 -2
- package/lib/checkbox/themes/solar/pearl/index.js +2 -2
- package/lib/clock/index.d.ts +5 -0
- package/lib/clock/index.js +6 -6
- package/lib/clock/utils/TickManager.js +2 -2
- package/lib/collapse/index.d.ts +5 -0
- package/lib/collapse/index.js +7 -9
- package/lib/collapse/themes/halo/dark/index.js +3 -3
- package/lib/collapse/themes/halo/light/index.js +3 -3
- package/lib/collapse/themes/solar/charcoal/index.js +3 -3
- package/lib/collapse/themes/solar/pearl/index.js +3 -3
- package/lib/color-dialog/elements/color-palettes.d.ts +5 -0
- package/lib/color-dialog/elements/color-palettes.js +1 -1
- package/lib/color-dialog/elements/grayscale-palettes.d.ts +5 -0
- package/lib/color-dialog/elements/grayscale-palettes.js +2 -2
- package/lib/color-dialog/elements/palettes.js +4 -5
- package/lib/color-dialog/helpers/value-model.js +1 -1
- package/lib/color-dialog/index.d.ts +6 -1
- package/lib/color-dialog/index.js +17 -12
- package/lib/color-dialog/themes/halo/dark/index.js +5 -5
- package/lib/color-dialog/themes/halo/light/index.js +5 -5
- package/lib/color-dialog/themes/solar/charcoal/index.js +5 -5
- package/lib/color-dialog/themes/solar/pearl/index.js +5 -5
- package/lib/combo-box/helpers/filter.d.ts +1 -1
- package/lib/combo-box/helpers/types.d.ts +1 -1
- package/lib/combo-box/index.d.ts +9 -4
- package/lib/combo-box/index.js +31 -14
- package/lib/combo-box/themes/halo/dark/index.js +5 -5
- package/lib/combo-box/themes/halo/light/index.js +5 -5
- package/lib/combo-box/themes/solar/charcoal/index.js +5 -5
- package/lib/combo-box/themes/solar/pearl/index.js +5 -5
- package/lib/counter/index.d.ts +11 -6
- package/lib/counter/index.js +8 -8
- package/lib/counter/themes/halo/dark/index.js +1 -1
- package/lib/counter/themes/halo/light/index.js +1 -1
- package/lib/counter/themes/solar/charcoal/index.js +1 -1
- package/lib/counter/themes/solar/pearl/index.js +1 -1
- package/lib/datetime-field/constants.d.ts +4 -0
- package/lib/datetime-field/constants.js +5 -0
- package/lib/datetime-field/custom-elements.json +345 -0
- package/lib/datetime-field/custom-elements.md +61 -0
- package/lib/datetime-field/index.d.ts +322 -0
- package/lib/datetime-field/index.js +660 -0
- package/lib/datetime-field/themes/halo/dark/index.js +3 -0
- package/lib/datetime-field/themes/halo/light/index.js +3 -0
- package/lib/datetime-field/themes/solar/charcoal/index.js +3 -0
- package/lib/datetime-field/themes/solar/pearl/index.js +3 -0
- package/lib/datetime-field/types.d.ts +10 -0
- package/lib/datetime-field/types.js +1 -0
- package/lib/datetime-field/utils.d.ts +25 -0
- package/lib/datetime-field/utils.js +79 -0
- package/lib/datetime-picker/index.d.ts +5 -0
- package/lib/datetime-picker/index.js +6 -7
- package/lib/datetime-picker/themes/halo/dark/index.js +5 -5
- package/lib/datetime-picker/themes/halo/light/index.js +5 -5
- package/lib/datetime-picker/themes/solar/charcoal/index.js +5 -5
- package/lib/datetime-picker/themes/solar/pearl/index.js +5 -5
- package/lib/datetime-picker/utils.js +1 -1
- package/lib/dialog/draggable-element.js +1 -2
- package/lib/dialog/index.d.ts +6 -1
- package/lib/dialog/index.js +5 -5
- package/lib/dialog/themes/halo/dark/index.js +5 -5
- package/lib/dialog/themes/halo/light/index.js +5 -5
- package/lib/dialog/themes/solar/charcoal/index.js +5 -5
- package/lib/dialog/themes/solar/pearl/index.js +5 -5
- package/lib/email-field/index.d.ts +6 -1
- package/lib/email-field/index.js +8 -3
- package/lib/email-field/themes/halo/dark/index.js +1 -1
- package/lib/email-field/themes/halo/light/index.js +1 -1
- package/lib/email-field/themes/solar/charcoal/index.js +1 -1
- package/lib/email-field/themes/solar/pearl/index.js +1 -1
- package/lib/flag/index.d.ts +5 -0
- package/lib/flag/index.js +3 -3
- package/lib/flag/utils/FlagLoader.d.ts +1 -1
- package/lib/flag/utils/FlagLoader.js +1 -1
- package/lib/header/index.d.ts +5 -0
- package/lib/header/index.js +2 -2
- package/lib/heatmap/helpers/color.d.ts +1 -1
- package/lib/heatmap/helpers/color.js +3 -5
- package/lib/heatmap/helpers/text.d.ts +1 -7
- package/lib/heatmap/helpers/text.js +1 -18
- package/lib/heatmap/index.d.ts +5 -0
- package/lib/heatmap/index.js +22 -30
- package/lib/heatmap/themes/halo/dark/index.js +2 -2
- package/lib/heatmap/themes/halo/light/index.js +2 -2
- package/lib/heatmap/themes/solar/charcoal/index.js +2 -2
- package/lib/heatmap/themes/solar/pearl/index.js +2 -2
- package/lib/icon/index.d.ts +5 -0
- package/lib/icon/index.js +3 -3
- package/lib/icon/utils/IconLoader.d.ts +1 -1
- package/lib/icon/utils/IconLoader.js +1 -1
- package/lib/interactive-chart/helpers/types.d.ts +1 -1
- package/lib/interactive-chart/index.d.ts +5 -12
- package/lib/interactive-chart/index.js +20 -36
- package/lib/interactive-chart/themes/halo/dark/index.js +1 -1
- package/lib/interactive-chart/themes/halo/light/index.js +1 -1
- package/lib/interactive-chart/themes/solar/charcoal/index.js +1 -1
- package/lib/interactive-chart/themes/solar/pearl/index.js +1 -1
- package/lib/item/helpers/types.d.ts +1 -1
- package/lib/item/index.d.ts +24 -17
- package/lib/item/index.js +45 -48
- package/lib/item/themes/halo/dark/index.js +2 -2
- package/lib/item/themes/halo/light/index.js +2 -2
- package/lib/item/themes/solar/charcoal/index.js +2 -2
- package/lib/item/themes/solar/pearl/index.js +2 -2
- package/lib/label/index.d.ts +6 -1
- package/lib/label/index.js +6 -6
- package/lib/label/themes/halo/dark/index.js +1 -1
- package/lib/label/themes/halo/light/index.js +1 -1
- package/lib/label/themes/solar/charcoal/index.js +1 -1
- package/lib/label/themes/solar/pearl/index.js +1 -1
- package/lib/layout/index.d.ts +5 -0
- package/lib/layout/index.js +2 -2
- package/lib/led-gauge/index.d.ts +5 -0
- package/lib/led-gauge/index.js +2 -2
- package/lib/led-gauge/themes/halo/dark/index.js +1 -1
- package/lib/led-gauge/themes/halo/light/index.js +1 -1
- package/lib/led-gauge/themes/solar/charcoal/index.js +1 -1
- package/lib/led-gauge/themes/solar/pearl/index.js +1 -1
- package/lib/list/custom-elements.json +0 -13
- package/lib/list/custom-elements.md +9 -10
- package/lib/list/helpers/item-id.d.ts +8 -0
- package/lib/list/helpers/item-id.js +13 -0
- package/lib/list/helpers/{list-renderer.d.ts → renderer.d.ts} +4 -0
- package/lib/list/helpers/{list-renderer.js → renderer.js} +8 -0
- package/lib/list/helpers/types.d.ts +1 -1
- package/lib/list/index.d.ts +18 -12
- package/lib/list/index.js +30 -29
- package/lib/list/renderer.d.ts +1 -1
- package/lib/list/themes/halo/dark/index.js +2 -2
- package/lib/list/themes/halo/light/index.js +2 -2
- package/lib/list/themes/solar/charcoal/index.js +2 -2
- package/lib/list/themes/solar/pearl/index.js +2 -2
- package/lib/loader/index.d.ts +6 -0
- package/lib/loader/index.js +5 -1
- package/lib/multi-input/helpers/types.d.ts +1 -1
- package/lib/multi-input/index.d.ts +5 -0
- package/lib/multi-input/index.js +6 -7
- package/lib/multi-input/themes/halo/dark/index.js +2 -2
- package/lib/multi-input/themes/halo/light/index.js +2 -2
- package/lib/multi-input/themes/solar/charcoal/index.js +2 -2
- package/lib/multi-input/themes/solar/pearl/index.js +2 -2
- package/lib/notification/elements/notification-tray.d.ts +5 -0
- package/lib/notification/elements/notification-tray.js +4 -4
- package/lib/notification/elements/notification.d.ts +15 -0
- package/lib/notification/elements/notification.js +12 -3
- package/lib/notification/themes/halo/dark/index.js +1 -1
- package/lib/notification/themes/halo/light/index.js +1 -1
- package/lib/notification/themes/solar/charcoal/index.js +1 -1
- package/lib/notification/themes/solar/pearl/index.js +1 -1
- package/lib/number-field/index.d.ts +8 -3
- package/lib/number-field/index.js +14 -4
- package/lib/number-field/themes/halo/dark/index.js +1 -1
- package/lib/number-field/themes/halo/light/index.js +1 -1
- package/lib/number-field/themes/solar/charcoal/index.js +1 -1
- package/lib/number-field/themes/solar/pearl/index.js +1 -1
- package/lib/overlay/elements/overlay-backdrop.d.ts +5 -0
- package/lib/overlay/elements/overlay-backdrop.js +2 -2
- package/lib/overlay/elements/overlay-viewport.d.ts +5 -0
- package/lib/overlay/elements/overlay-viewport.js +1 -1
- package/lib/overlay/elements/overlay.d.ts +5 -0
- package/lib/overlay/elements/overlay.js +7 -5
- package/lib/overlay/managers/focus-manager.js +11 -6
- package/lib/overlay/managers/interaction-lock-manager.js +1 -1
- package/lib/overlay/managers/viewport-manager.js +4 -5
- package/lib/overlay/managers/zindex-manager.js +1 -1
- package/lib/overlay-menu/helpers/types.d.ts +7 -1
- package/lib/overlay-menu/helpers/types.js +7 -1
- package/lib/overlay-menu/index.d.ts +14 -4
- package/lib/overlay-menu/index.js +57 -29
- package/lib/overlay-menu/managers/menu-manager.js +2 -1
- package/lib/overlay-menu/themes/halo/dark/index.js +3 -3
- package/lib/overlay-menu/themes/halo/light/index.js +3 -3
- package/lib/overlay-menu/themes/solar/charcoal/index.js +3 -3
- package/lib/overlay-menu/themes/solar/pearl/index.js +3 -3
- package/lib/pagination/index.d.ts +79 -91
- package/lib/pagination/index.js +205 -239
- package/lib/pagination/themes/halo/dark/index.js +4 -5
- package/lib/pagination/themes/halo/light/index.js +4 -5
- package/lib/pagination/themes/solar/charcoal/index.js +4 -5
- package/lib/pagination/themes/solar/pearl/index.js +4 -5
- package/lib/panel/index.d.ts +5 -0
- package/lib/panel/index.js +2 -2
- package/lib/password-field/index.d.ts +7 -2
- package/lib/password-field/index.js +7 -4
- package/lib/password-field/themes/halo/dark/index.js +1 -1
- package/lib/password-field/themes/halo/light/index.js +1 -1
- package/lib/password-field/themes/solar/charcoal/index.js +1 -1
- package/lib/password-field/themes/solar/pearl/index.js +1 -1
- package/lib/pill/index.d.ts +21 -0
- package/lib/pill/index.js +36 -5
- package/lib/pill/themes/halo/dark/index.js +2 -2
- package/lib/pill/themes/halo/light/index.js +2 -2
- package/lib/pill/themes/solar/charcoal/index.js +2 -2
- package/lib/pill/themes/solar/pearl/index.js +2 -2
- package/lib/progress-bar/index.d.ts +5 -0
- package/lib/progress-bar/index.js +3 -3
- package/lib/radio-button/index.d.ts +5 -0
- package/lib/radio-button/index.js +3 -3
- package/lib/radio-button/radio-button-registry.d.ts +1 -1
- package/lib/radio-button/radio-button-registry.js +4 -2
- package/lib/radio-button/themes/halo/dark/index.js +1 -1
- package/lib/radio-button/themes/halo/light/index.js +1 -1
- package/lib/radio-button/themes/solar/charcoal/index.js +1 -1
- package/lib/radio-button/themes/solar/pearl/index.js +1 -1
- package/lib/rating/index.d.ts +5 -0
- package/lib/rating/index.js +4 -4
- package/lib/search-field/index.d.ts +7 -2
- package/lib/search-field/index.js +8 -4
- package/lib/search-field/themes/halo/dark/index.js +1 -1
- package/lib/search-field/themes/halo/light/index.js +1 -1
- package/lib/search-field/themes/solar/charcoal/index.js +1 -1
- package/lib/search-field/themes/solar/pearl/index.js +1 -1
- package/lib/select/index.d.ts +5 -0
- package/lib/select/index.js +11 -14
- package/lib/select/themes/halo/dark/index.js +3 -3
- package/lib/select/themes/halo/light/index.js +3 -3
- package/lib/select/themes/solar/charcoal/index.js +3 -3
- package/lib/select/themes/solar/pearl/index.js +3 -3
- package/lib/sidebar-layout/index.d.ts +5 -0
- package/lib/sidebar-layout/index.js +4 -4
- package/lib/sidebar-layout/themes/halo/dark/index.js +1 -1
- package/lib/sidebar-layout/themes/halo/light/index.js +1 -1
- package/lib/sidebar-layout/themes/solar/charcoal/index.js +1 -1
- package/lib/sidebar-layout/themes/solar/pearl/index.js +1 -1
- package/lib/slider/constants.d.ts +15 -0
- package/lib/slider/constants.js +18 -0
- package/lib/slider/index.d.ts +55 -80
- package/lib/slider/index.js +365 -460
- package/lib/slider/themes/halo/dark/index.js +1 -1
- package/lib/slider/themes/halo/light/index.js +1 -1
- package/lib/slider/themes/solar/charcoal/index.js +1 -1
- package/lib/slider/themes/solar/pearl/index.js +1 -1
- package/lib/slider/utils.d.ts +35 -0
- package/lib/slider/utils.js +54 -0
- package/lib/sparkline/index.d.ts +5 -0
- package/lib/sparkline/index.js +9 -10
- package/lib/swing-gauge/index.d.ts +5 -0
- package/lib/swing-gauge/index.js +14 -8
- package/lib/swing-gauge/themes/halo/dark/index.js +1 -1
- package/lib/swing-gauge/themes/halo/light/index.js +1 -1
- package/lib/swing-gauge/themes/solar/charcoal/index.js +1 -1
- package/lib/swing-gauge/themes/solar/pearl/index.js +1 -1
- package/lib/tab/index.d.ts +5 -0
- package/lib/tab/index.js +4 -4
- package/lib/tab/themes/halo/dark/index.js +2 -2
- package/lib/tab/themes/halo/light/index.js +2 -2
- package/lib/tab/themes/solar/charcoal/index.js +2 -2
- package/lib/tab/themes/solar/pearl/index.js +2 -2
- package/lib/tab-bar/index.d.ts +5 -0
- package/lib/tab-bar/index.js +6 -6
- package/lib/tab-bar/themes/halo/dark/index.js +2 -2
- package/lib/tab-bar/themes/halo/light/index.js +2 -2
- package/lib/tab-bar/themes/solar/charcoal/index.js +2 -2
- package/lib/tab-bar/themes/solar/pearl/index.js +2 -2
- package/lib/text-field/index.d.ts +19 -1
- package/lib/text-field/index.js +35 -11
- package/lib/text-field/themes/halo/dark/index.js +1 -1
- package/lib/text-field/themes/halo/light/index.js +1 -1
- package/lib/text-field/themes/solar/charcoal/index.js +1 -1
- package/lib/text-field/themes/solar/pearl/index.js +1 -1
- package/lib/time-picker/index.d.ts +6 -1
- package/lib/time-picker/index.js +11 -11
- package/lib/time-picker/themes/halo/dark/index.js +2 -2
- package/lib/time-picker/themes/halo/light/index.js +2 -2
- package/lib/time-picker/themes/solar/charcoal/index.js +2 -2
- package/lib/time-picker/themes/solar/pearl/index.js +2 -2
- package/lib/toggle/index.d.ts +5 -0
- package/lib/toggle/index.js +2 -2
- package/lib/tooltip/elements/tooltip-element.d.ts +1 -2
- package/lib/tooltip/index.d.ts +6 -0
- package/lib/tooltip/index.js +7 -8
- package/lib/tooltip/managers/tooltip-manager.js +2 -2
- package/lib/tooltip/themes/halo/dark/index.js +1 -1
- package/lib/tooltip/themes/halo/light/index.js +1 -1
- package/lib/tooltip/themes/solar/charcoal/index.js +1 -1
- package/lib/tooltip/themes/solar/pearl/index.js +1 -1
- package/lib/tornado-chart/elements/tornado-chart.d.ts +5 -0
- package/lib/tornado-chart/elements/tornado-chart.js +2 -2
- package/lib/tornado-chart/elements/tornado-item.d.ts +5 -0
- package/lib/tornado-chart/elements/tornado-item.js +3 -3
- package/lib/tornado-chart/themes/halo/dark/index.js +2 -2
- package/lib/tornado-chart/themes/halo/light/index.js +2 -2
- package/lib/tornado-chart/themes/solar/charcoal/index.js +2 -2
- package/lib/tornado-chart/themes/solar/pearl/index.js +2 -2
- package/lib/tree/elements/tree-item.d.ts +8 -3
- package/lib/tree/elements/tree-item.js +5 -6
- package/lib/tree/elements/tree.d.ts +7 -3
- package/lib/tree/elements/tree.js +6 -7
- package/lib/tree/helpers/renderer.d.ts +4 -0
- package/lib/tree/helpers/renderer.js +20 -13
- package/lib/tree/helpers/types.d.ts +1 -1
- package/lib/tree/managers/tree-manager.d.ts +1 -1
- package/lib/tree/themes/halo/dark/index.js +4 -4
- package/lib/tree/themes/halo/light/index.js +4 -4
- package/lib/tree/themes/solar/charcoal/index.js +4 -4
- package/lib/tree/themes/solar/pearl/index.js +4 -4
- package/lib/tree-select/index.d.ts +8 -7
- package/lib/tree-select/index.js +39 -38
- package/lib/tree-select/themes/halo/dark/index.js +9 -9
- package/lib/tree-select/themes/halo/light/index.js +9 -9
- package/lib/tree-select/themes/solar/charcoal/index.js +9 -9
- package/lib/tree-select/themes/solar/pearl/index.js +9 -9
- package/lib/version.js +1 -1
- package/package.json +35 -295
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { FocusedPropertyKey, WarningNotice, html } from '@refinitiv-ui/core';
|
|
3
|
+
import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
|
|
4
|
+
import { property } from '@refinitiv-ui/core/decorators/property.js';
|
|
5
|
+
import { state } from '@refinitiv-ui/core/decorators/state.js';
|
|
6
|
+
import { AnimationTaskRunner } from '@refinitiv-ui/utils/async.js';
|
|
7
|
+
import { utcParse, utcFormat, getFormat, isBefore, isAfter, iterateUnit, Locale } from '@refinitiv-ui/utils/date.js';
|
|
8
|
+
import { translate, getLocale, TranslatePropertyKey } from '@refinitiv-ui/translate';
|
|
9
|
+
import { Direction } from './constants.js';
|
|
10
|
+
import { TextField } from '../text-field/index.js';
|
|
11
|
+
import { getSelectedPartIndex, getNextSelectedPartIndex, selectPart } from './utils.js';
|
|
12
|
+
import { VERSION } from '../version.js';
|
|
13
|
+
import '@refinitiv-ui/phrasebook/locale/en/datetime-field.js';
|
|
14
|
+
/**
|
|
15
|
+
* A form control element for datetime input.
|
|
16
|
+
*
|
|
17
|
+
* @fires value-changed - Dispatched when value changes
|
|
18
|
+
* @fires error-changed - Dispatched when error state changes
|
|
19
|
+
* @fires icon-click - Dispatched when icon is clicked
|
|
20
|
+
*
|
|
21
|
+
* @attr {boolean} disabled - Set disabled state
|
|
22
|
+
* @prop {boolean} [disabled=false] - Set disabled state
|
|
23
|
+
*
|
|
24
|
+
* @attr {boolean} error - Set error state
|
|
25
|
+
* @prop {boolean} [error=false] - Set error state
|
|
26
|
+
*
|
|
27
|
+
* @attr {string} icon - Specify icon to display in input. Value can be icon name
|
|
28
|
+
* @prop {string | null} [icon=null] - Specify icon to display in input. Value can be icon name
|
|
29
|
+
*
|
|
30
|
+
* @attr {boolean} icon-has-action - Specify when icon need to be clickable
|
|
31
|
+
* @prop {boolean} [iconHasAction=false] - Specify when icon need to be clickable
|
|
32
|
+
*
|
|
33
|
+
* @attr {number} maxlength - Set character max limit
|
|
34
|
+
* @prop {number | null} [maxLength=null] - Set character max limit
|
|
35
|
+
*
|
|
36
|
+
* @attr {number} minlength - Set character min limit
|
|
37
|
+
* @prop {number | null} [minLength=null] - Set character min limit
|
|
38
|
+
*
|
|
39
|
+
* @prop {string} [pattern=""] - Set regular expression for input validation
|
|
40
|
+
*
|
|
41
|
+
* @attr {string} placeholder - Set placeholder text
|
|
42
|
+
* @prop {string} [placeholder=""] - Set placeholder text
|
|
43
|
+
*
|
|
44
|
+
* @attr {boolean} readonly - Set readonly state
|
|
45
|
+
* @prop {boolean} [readonly=false] - Set readonly state
|
|
46
|
+
*
|
|
47
|
+
* @attr {boolean} transparent - Disables all other states and border/background styles.
|
|
48
|
+
* @prop {boolean} [transparent=false] - Disables all other states and border/background styles.
|
|
49
|
+
*
|
|
50
|
+
* @attr {boolean} warning - Set warning state
|
|
51
|
+
* @prop {boolean} [warning=false] - Set warning state
|
|
52
|
+
*/
|
|
53
|
+
let DatetimeField = class DatetimeField extends TextField {
|
|
54
|
+
constructor() {
|
|
55
|
+
super(...arguments);
|
|
56
|
+
/**
|
|
57
|
+
* Delay selecting a part to ensure
|
|
58
|
+
* that scroll can be updated
|
|
59
|
+
*/
|
|
60
|
+
this.selectPartFrame = new AnimationTaskRunner();
|
|
61
|
+
/**
|
|
62
|
+
* Set minimum date.
|
|
63
|
+
* This value must follow the `format` and be less
|
|
64
|
+
* than or equal to the value of the `max` attribute
|
|
65
|
+
*/
|
|
66
|
+
this.min = null;
|
|
67
|
+
/**
|
|
68
|
+
* Set maximum date.
|
|
69
|
+
* This value must follow the `format` and be greater
|
|
70
|
+
* than or equal to the value of the `min` attribute
|
|
71
|
+
*/
|
|
72
|
+
this.max = null;
|
|
73
|
+
this._timepicker = false;
|
|
74
|
+
this._showSeconds = false;
|
|
75
|
+
this._amPm = false;
|
|
76
|
+
this._formatOptions = null;
|
|
77
|
+
/**
|
|
78
|
+
* Format, which is based on locale
|
|
79
|
+
*/
|
|
80
|
+
this._locale = null;
|
|
81
|
+
this.interimValueState = false; // make sure that internal input field value is updated only on external value change
|
|
82
|
+
/**
|
|
83
|
+
* Currently selected part
|
|
84
|
+
*/
|
|
85
|
+
this.partLabel = '';
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Element version number
|
|
89
|
+
* @returns version number
|
|
90
|
+
*/
|
|
91
|
+
static get version() {
|
|
92
|
+
return VERSION;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Toggle to display the time picker
|
|
96
|
+
* @param timepicker true to set timepicker mode
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
99
|
+
set timepicker(timepicker) {
|
|
100
|
+
const oldTimepicker = this._timepicker;
|
|
101
|
+
if (timepicker !== oldTimepicker) {
|
|
102
|
+
this._timepicker = timepicker;
|
|
103
|
+
this._locale = null;
|
|
104
|
+
this.requestUpdate('timepicker', oldTimepicker);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
get timepicker() {
|
|
108
|
+
return this._timepicker;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Toggle to display the seconds
|
|
112
|
+
* @param showSeconds true to show seconds
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
set showSeconds(showSeconds) {
|
|
116
|
+
const oldShowSeconds = this._showSeconds;
|
|
117
|
+
if (oldShowSeconds !== showSeconds) {
|
|
118
|
+
this._showSeconds = showSeconds;
|
|
119
|
+
this._locale = null;
|
|
120
|
+
this.requestUpdate('showSeconds', oldShowSeconds);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
get showSeconds() {
|
|
124
|
+
return this._showSeconds;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Overrides 12hr time display format
|
|
128
|
+
* @param amPm true to show 12hr time format
|
|
129
|
+
* @default false
|
|
130
|
+
*/
|
|
131
|
+
set amPm(amPm) {
|
|
132
|
+
const oldAmPm = this._amPm;
|
|
133
|
+
if (oldAmPm !== amPm) {
|
|
134
|
+
this._amPm = amPm;
|
|
135
|
+
this._locale = null;
|
|
136
|
+
this.requestUpdate('amPm', oldAmPm);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
get amPm() {
|
|
140
|
+
return this._amPm;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Set the datetime format options based on
|
|
144
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat
|
|
145
|
+
* `formatOptions` overrides `timepicker` and `showSeconds` properties.
|
|
146
|
+
* Note: time-zone is not supported
|
|
147
|
+
* @param formatOptions Format options
|
|
148
|
+
* @default - null
|
|
149
|
+
*/
|
|
150
|
+
set formatOptions(formatOptions) {
|
|
151
|
+
const oldFormatOptions = this._formatOptions;
|
|
152
|
+
if (oldFormatOptions !== formatOptions) {
|
|
153
|
+
this._formatOptions = formatOptions;
|
|
154
|
+
this._locale = null;
|
|
155
|
+
this.requestUpdate('formatOptions', oldFormatOptions);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
get formatOptions() {
|
|
159
|
+
return this._formatOptions;
|
|
160
|
+
}
|
|
161
|
+
get locale() {
|
|
162
|
+
if (!this._locale) {
|
|
163
|
+
this._locale = this.resolveLocale();
|
|
164
|
+
}
|
|
165
|
+
return this._locale;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Current date time value
|
|
169
|
+
* @param value Calendar value
|
|
170
|
+
* @default -
|
|
171
|
+
*/
|
|
172
|
+
set value(value) {
|
|
173
|
+
this.interimValueState = true;
|
|
174
|
+
super.value = value;
|
|
175
|
+
// Always call update cycle when value is set externally
|
|
176
|
+
// This is to ensure that value and inputValue never run out of sync
|
|
177
|
+
this.requestUpdate('interimValueState', false);
|
|
178
|
+
}
|
|
179
|
+
get value() {
|
|
180
|
+
return super.value;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Returns the value of the element, interpreted as double number
|
|
184
|
+
*/
|
|
185
|
+
get valueAsNumber() {
|
|
186
|
+
const date = this.valueAsDate;
|
|
187
|
+
return date ? date.getTime() : Number.NaN;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Set the value of the element, interpreted as double number
|
|
191
|
+
* @param value number value
|
|
192
|
+
*/
|
|
193
|
+
set valueAsNumber(value) {
|
|
194
|
+
const date = new Date(value);
|
|
195
|
+
this.valueAsDate = date;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Returns the value of the element, interpreted as Date
|
|
199
|
+
*/
|
|
200
|
+
get valueAsDate() {
|
|
201
|
+
return this.value ? utcParse(this.value) : null;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Set the value of the element, interpreted as Date
|
|
205
|
+
* @param value date value
|
|
206
|
+
*/
|
|
207
|
+
set valueAsDate(value) {
|
|
208
|
+
this.value = value ? this.dateToString(value) : '';
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Transform Date object to date string
|
|
212
|
+
* @param value Date
|
|
213
|
+
* @returns dateSting
|
|
214
|
+
*/
|
|
215
|
+
dateToString(value) {
|
|
216
|
+
return isNaN(value.getTime()) ? '' : utcFormat(value, this.locale.isoFormat);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Returns true if the datetime field has timepicker
|
|
220
|
+
* @returns hasTimePicker
|
|
221
|
+
*/
|
|
222
|
+
get hasTimePicker() {
|
|
223
|
+
// need to check for attribute to resolve the value correctly until the first lifecycle is run
|
|
224
|
+
return this.timepicker || this.hasAttribute('timepicker') || this.hasAmPm || this.hasSeconds;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Returns true if the datetime field has seconds
|
|
228
|
+
* @returns hasSeconds
|
|
229
|
+
*/
|
|
230
|
+
get hasSeconds() {
|
|
231
|
+
return this.showSeconds || this.hasAttribute('show-seconds');
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Returns true if the datetime field has am-pm
|
|
235
|
+
* @returns hasAmPm
|
|
236
|
+
*/
|
|
237
|
+
get hasAmPm() {
|
|
238
|
+
return this.amPm || this.hasAttribute('am-pm');
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Get today's date noon as the start date when the value is not set
|
|
242
|
+
*/
|
|
243
|
+
get startDate() {
|
|
244
|
+
// Noon in UTC
|
|
245
|
+
const today = new Date();
|
|
246
|
+
const date = new Date(0);
|
|
247
|
+
date.setUTCFullYear(today.getFullYear());
|
|
248
|
+
date.setUTCMonth(today.getMonth());
|
|
249
|
+
date.setUTCDate(today.getDate());
|
|
250
|
+
date.setUTCHours(12);
|
|
251
|
+
return this.dateToString(date);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Updates the element
|
|
255
|
+
* @param changedProperties Properties that has changed
|
|
256
|
+
* @returns {void}
|
|
257
|
+
*/
|
|
258
|
+
willUpdate(changedProperties) {
|
|
259
|
+
super.willUpdate(changedProperties);
|
|
260
|
+
if (changedProperties.has(TranslatePropertyKey)) {
|
|
261
|
+
this._locale = null; // Locale is updated on next call via getter
|
|
262
|
+
}
|
|
263
|
+
if (changedProperties.has(FocusedPropertyKey) && !this.focused) {
|
|
264
|
+
this.partLabel = '';
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Check if input value should be synchronised with component value
|
|
269
|
+
* @param changedProperties Properties that has changed
|
|
270
|
+
* @returns True if input should be synchronised
|
|
271
|
+
*/
|
|
272
|
+
shouldSyncInputValue(changedProperties) {
|
|
273
|
+
// Note: changing any of these properties override the input value
|
|
274
|
+
// On blur, if the value is correct makes sure strict format is used
|
|
275
|
+
return changedProperties.has('interimValueState')
|
|
276
|
+
|| changedProperties.has(TranslatePropertyKey)
|
|
277
|
+
|| changedProperties.has('formatOptions')
|
|
278
|
+
|| changedProperties.has('timepicker')
|
|
279
|
+
|| changedProperties.has('showSeconds')
|
|
280
|
+
|| changedProperties.has('amPm')
|
|
281
|
+
|| (changedProperties.has(FocusedPropertyKey) && this.value !== '' && !this.focused);
|
|
282
|
+
}
|
|
283
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
284
|
+
syncInputValue(changedProperties) {
|
|
285
|
+
this.interimValueState = false;
|
|
286
|
+
const inputValue = this.toInputValue(this.value);
|
|
287
|
+
if (inputValue !== this.inputValue) {
|
|
288
|
+
this.inputValue = inputValue; // setting the value resets selection
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Check if input should be re-validated
|
|
293
|
+
* @param changedProperties Properties that has changed
|
|
294
|
+
* @returns True if input should be re-validated
|
|
295
|
+
*/
|
|
296
|
+
shouldValidateInput(changedProperties) {
|
|
297
|
+
// TODO: this needs refactoring with all other fields to support common validation patterns
|
|
298
|
+
return (changedProperties.has(FocusedPropertyKey) && !this.focused);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Validate input according `pattern`, `minLength` and `maxLength` properties
|
|
302
|
+
* change state of `error` property according pattern validation
|
|
303
|
+
* @returns {void}
|
|
304
|
+
*/
|
|
305
|
+
validateInput() {
|
|
306
|
+
this.reportValidity();
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Override validation method for value
|
|
310
|
+
* @param value value
|
|
311
|
+
* @returns value validity
|
|
312
|
+
*/
|
|
313
|
+
isValidValue(value) {
|
|
314
|
+
if (value === '') {
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
// value format depends on locale.
|
|
318
|
+
return getFormat(value) === this.locale.isoFormat;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Used to show a warning when the value does not pass the validation
|
|
322
|
+
* @param value that is invalid
|
|
323
|
+
* @returns {void}
|
|
324
|
+
*/
|
|
325
|
+
warnInvalidValue(value) {
|
|
326
|
+
new WarningNotice(`${this.localName}: the specified value "${value}" does not conform to the required format. The format is '${this.locale.isoFormat}'.`).show();
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Resolve locale based on element parameters
|
|
330
|
+
* @returns locale Resolved locale
|
|
331
|
+
*/
|
|
332
|
+
resolveLocale() {
|
|
333
|
+
const hasTimePicker = this.hasTimePicker;
|
|
334
|
+
// TODO: Do not use dateStyle and timeStyle as these are supported only in modern browsers
|
|
335
|
+
return Locale.fromOptions(this.formatOptions || {
|
|
336
|
+
year: 'numeric',
|
|
337
|
+
month: 'short',
|
|
338
|
+
day: 'numeric',
|
|
339
|
+
hour: hasTimePicker ? 'numeric' : undefined,
|
|
340
|
+
minute: hasTimePicker ? 'numeric' : undefined,
|
|
341
|
+
second: this.hasSeconds ? 'numeric' : undefined,
|
|
342
|
+
hour12: this.hasAmPm ? true : undefined // force am-pm if provided, otherwise rely on locale
|
|
343
|
+
}, `${getLocale(this)}`);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Get Intl.DateTimeFormat object from locale
|
|
347
|
+
*/
|
|
348
|
+
get formatter() {
|
|
349
|
+
return this.locale.formatter;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Try to format ISO date/time/datetime string into datetime format parts
|
|
353
|
+
* Throw an error if value is invalid
|
|
354
|
+
* @param value ISO string date/time/datetime
|
|
355
|
+
* @returns parts
|
|
356
|
+
*/
|
|
357
|
+
formatToParts(value) {
|
|
358
|
+
const date = utcParse(value);
|
|
359
|
+
return this.formatter.formatToParts(date);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Format value to inputValue
|
|
363
|
+
* @param value Date string
|
|
364
|
+
* @returns inputValue
|
|
365
|
+
*/
|
|
366
|
+
toInputValue(value) {
|
|
367
|
+
return value ? this.formatter.format(utcParse(value)) : '';
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Format inputValue to value
|
|
371
|
+
* @param inputValue Date string
|
|
372
|
+
* @returns value
|
|
373
|
+
*/
|
|
374
|
+
toValue(inputValue) {
|
|
375
|
+
let value = '';
|
|
376
|
+
try {
|
|
377
|
+
value = inputValue ? this.locale.parse(inputValue, this.value || this.startDate) : '';
|
|
378
|
+
}
|
|
379
|
+
catch (error) {
|
|
380
|
+
// do nothing
|
|
381
|
+
}
|
|
382
|
+
return value;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* On *user-interaction* set the value and notify.
|
|
386
|
+
* @param value New value
|
|
387
|
+
* @returns {void}
|
|
388
|
+
*/
|
|
389
|
+
setValueAndNotify(value) {
|
|
390
|
+
// must be called on super to avoid re-rendering of actual value
|
|
391
|
+
if (super.value !== value) {
|
|
392
|
+
super.value = value;
|
|
393
|
+
this.notifyPropertyChange('value', value);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Reset error state on input
|
|
398
|
+
* @returns {void}
|
|
399
|
+
*/
|
|
400
|
+
resetError() {
|
|
401
|
+
if (this.error && this.checkValidity()) {
|
|
402
|
+
this.reportValidity();
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Returns true if an input element contains valid data.
|
|
407
|
+
* @returns true if input is valid
|
|
408
|
+
*/
|
|
409
|
+
checkValidity() {
|
|
410
|
+
const inputValue = this.inputValue;
|
|
411
|
+
// Invalid input value
|
|
412
|
+
if (inputValue && !this.toValue(inputValue)) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
const value = this.value;
|
|
416
|
+
// No support for required
|
|
417
|
+
if (value === '') {
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
// Value before min
|
|
421
|
+
if (this.min && value !== this.min && isBefore(value, this.min)) {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
// Value after max
|
|
425
|
+
if (this.max && value !== this.max && isAfter(value, this.max)) {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Validate input. Mark as error if input is invalid
|
|
432
|
+
* @returns false if there is an error
|
|
433
|
+
*/
|
|
434
|
+
reportValidity() {
|
|
435
|
+
const hasError = !this.checkValidity();
|
|
436
|
+
this.notifyErrorChange(hasError);
|
|
437
|
+
return !hasError;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Select part
|
|
441
|
+
* @param index Part index
|
|
442
|
+
* @param parts The list of parts
|
|
443
|
+
* @returns {void}
|
|
444
|
+
*/
|
|
445
|
+
selectPart(index = 0, parts) {
|
|
446
|
+
const { selectionStart, selectionEnd } = selectPart(index, parts);
|
|
447
|
+
this.partLabel = parts[index] ? parts[index].type : '';
|
|
448
|
+
this.setSelectionRange(selectionStart, selectionEnd);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Change value or selection based on keyboard navigation
|
|
452
|
+
* @param key Navigation key
|
|
453
|
+
* @param event Keyboard event
|
|
454
|
+
* @returns {void}
|
|
455
|
+
*/
|
|
456
|
+
onNavigation(key, event) {
|
|
457
|
+
this.selectPartFrame.cancel();
|
|
458
|
+
this.partLabel = '';
|
|
459
|
+
// Invalid value
|
|
460
|
+
if (this.inputValue && !this.value) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
// Empty value
|
|
464
|
+
if (!this.inputValue) {
|
|
465
|
+
this.setValueAndNotify(this.startDate);
|
|
466
|
+
this.syncInputValue();
|
|
467
|
+
this.select();
|
|
468
|
+
event.preventDefault();
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
// Set selection into cursor mode with Escape key
|
|
472
|
+
if (key === 'Escape') {
|
|
473
|
+
if (this.selectionStart !== this.selectionEnd) {
|
|
474
|
+
this.selectionStart = this.selectionEnd;
|
|
475
|
+
event.preventDefault();
|
|
476
|
+
}
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
// Because of weak formatting, the result of formatting to part might be
|
|
480
|
+
// different to actual input value
|
|
481
|
+
const selection = {
|
|
482
|
+
selectionStart: this.selectionStart,
|
|
483
|
+
selectionEnd: this.selectionEnd
|
|
484
|
+
};
|
|
485
|
+
this.syncInputValue();
|
|
486
|
+
const parts = this.formatToParts(this.value);
|
|
487
|
+
const selectedPartIndex = getSelectedPartIndex(selection, parts);
|
|
488
|
+
// If no segments selected, select the segment where the cursor is
|
|
489
|
+
if (this.selectionStart === this.selectionEnd) {
|
|
490
|
+
this.selectPart(selectedPartIndex, parts);
|
|
491
|
+
event.preventDefault();
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
const selectedPart = parts[selectedPartIndex];
|
|
495
|
+
switch (key) {
|
|
496
|
+
case 'ArrowUp':
|
|
497
|
+
case 'ArrowDown':
|
|
498
|
+
if (selectedPart) {
|
|
499
|
+
let newValue = '';
|
|
500
|
+
const amount = key === 'ArrowDown' ? -1 : 1;
|
|
501
|
+
switch (selectedPart.type) {
|
|
502
|
+
case 'year':
|
|
503
|
+
case 'month':
|
|
504
|
+
case 'day':
|
|
505
|
+
case 'hour':
|
|
506
|
+
case 'minute':
|
|
507
|
+
case 'second':
|
|
508
|
+
newValue = iterateUnit(this.value, selectedPart.type, amount);
|
|
509
|
+
break;
|
|
510
|
+
case 'weekday':
|
|
511
|
+
newValue = iterateUnit(this.value, 'day', amount);
|
|
512
|
+
break;
|
|
513
|
+
case 'dayPeriod':
|
|
514
|
+
newValue = iterateUnit(this.value, 'hour', amount * 12);
|
|
515
|
+
break;
|
|
516
|
+
case 'fractionalSecond':
|
|
517
|
+
newValue = iterateUnit(this.value, 'millisecond', amount * 100);
|
|
518
|
+
break;
|
|
519
|
+
// no default
|
|
520
|
+
}
|
|
521
|
+
this.setValueAndNotify(newValue);
|
|
522
|
+
this.syncInputValue();
|
|
523
|
+
this.selectPart(selectedPartIndex, this.formatToParts(newValue));
|
|
524
|
+
this.resetError();
|
|
525
|
+
event.preventDefault();
|
|
526
|
+
}
|
|
527
|
+
break;
|
|
528
|
+
case 'ArrowRight':
|
|
529
|
+
case 'ArrowLeft':
|
|
530
|
+
const nextPartIdx = getNextSelectedPartIndex(selection, parts, this.inputValue, key === 'ArrowLeft' ? Direction.Down : Direction.Up);
|
|
531
|
+
this.selectPartFrame.schedule(() => {
|
|
532
|
+
this.selectPart(nextPartIdx, parts);
|
|
533
|
+
});
|
|
534
|
+
break;
|
|
535
|
+
// no default
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Check if value is changed and fire event
|
|
540
|
+
* @returns {void}
|
|
541
|
+
*/
|
|
542
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
543
|
+
onPossibleValueChange(event) {
|
|
544
|
+
// Nobody likes to see a red border
|
|
545
|
+
this.resetError();
|
|
546
|
+
this.selectPartFrame.cancel(); // ensure no pending selection
|
|
547
|
+
this.partLabel = '';
|
|
548
|
+
const inputValue = this.inputElement?.value || '';
|
|
549
|
+
const parsedValue = this.toValue(inputValue);
|
|
550
|
+
this.setValueAndNotify(parsedValue);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Handles key down input event
|
|
554
|
+
* @param event Key down event object
|
|
555
|
+
* @returns {void}
|
|
556
|
+
*/
|
|
557
|
+
onInputKeyDown(event) {
|
|
558
|
+
if (this.readonly || this.disabled || event.defaultPrevented) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
// Ignore special keys
|
|
562
|
+
if (event.shiftKey || event.ctrlKey || event.altKey || event.metaKey) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
switch (event.key) {
|
|
566
|
+
case 'Up': // IE11
|
|
567
|
+
case 'ArrowUp':
|
|
568
|
+
this.onNavigation('ArrowUp', event);
|
|
569
|
+
break;
|
|
570
|
+
case 'Down':
|
|
571
|
+
case 'ArrowDown':
|
|
572
|
+
this.onNavigation('ArrowDown', event);
|
|
573
|
+
break;
|
|
574
|
+
case 'Left':
|
|
575
|
+
case 'ArrowLeft':
|
|
576
|
+
this.onNavigation('ArrowLeft', event);
|
|
577
|
+
break;
|
|
578
|
+
case 'Right':
|
|
579
|
+
case 'ArrowRight':
|
|
580
|
+
this.onNavigation('ArrowRight', event);
|
|
581
|
+
break;
|
|
582
|
+
case 'Esc':
|
|
583
|
+
case 'Escape':
|
|
584
|
+
this.onNavigation('Escape', event);
|
|
585
|
+
break;
|
|
586
|
+
default:
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Decorate `<input>` element with common properties.
|
|
592
|
+
* @returns template map
|
|
593
|
+
*/
|
|
594
|
+
get decorateInputMap() {
|
|
595
|
+
return {
|
|
596
|
+
...super.decorateInputMap,
|
|
597
|
+
'@keydown': this.onInputKeyDown
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Used to announce part and value statuses
|
|
602
|
+
*/
|
|
603
|
+
get screenReaderTemplate() {
|
|
604
|
+
if (!this.focused) {
|
|
605
|
+
return null;
|
|
606
|
+
}
|
|
607
|
+
return html `
|
|
608
|
+
${this.partLabel && this.value ? html `<div
|
|
609
|
+
aria-label="${this.t(`PICK_${this.partLabel.toUpperCase()}`)}"
|
|
610
|
+
aria-live="polite"
|
|
611
|
+
role="status"></div>` : undefined}
|
|
612
|
+
<div
|
|
613
|
+
aria-label="${this.value ? this.t('VALUE', { value: this.toInputValue(this.value) }) : this.t('NO_VALUE')}"
|
|
614
|
+
aria-live="polite"
|
|
615
|
+
role="status"></div>
|
|
616
|
+
`;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* A `TemplateResult` that will be used
|
|
620
|
+
* to render the updated internal template.
|
|
621
|
+
* @return Render template
|
|
622
|
+
*/
|
|
623
|
+
render() {
|
|
624
|
+
return html `
|
|
625
|
+
${super.render()}
|
|
626
|
+
${this.screenReaderTemplate}
|
|
627
|
+
`;
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
__decorate([
|
|
631
|
+
property({ type: String, reflect: true })
|
|
632
|
+
], DatetimeField.prototype, "min", void 0);
|
|
633
|
+
__decorate([
|
|
634
|
+
property({ type: String, reflect: true })
|
|
635
|
+
], DatetimeField.prototype, "max", void 0);
|
|
636
|
+
__decorate([
|
|
637
|
+
property({ type: Boolean, reflect: true })
|
|
638
|
+
], DatetimeField.prototype, "timepicker", null);
|
|
639
|
+
__decorate([
|
|
640
|
+
property({ type: Boolean, attribute: 'show-seconds', reflect: true })
|
|
641
|
+
], DatetimeField.prototype, "showSeconds", null);
|
|
642
|
+
__decorate([
|
|
643
|
+
property({ type: Boolean, attribute: 'am-pm', reflect: true })
|
|
644
|
+
], DatetimeField.prototype, "amPm", null);
|
|
645
|
+
__decorate([
|
|
646
|
+
property({ attribute: false })
|
|
647
|
+
], DatetimeField.prototype, "formatOptions", null);
|
|
648
|
+
__decorate([
|
|
649
|
+
translate({ mode: 'directive', scope: 'ef-datetime-field' })
|
|
650
|
+
], DatetimeField.prototype, "t", void 0);
|
|
651
|
+
__decorate([
|
|
652
|
+
property({ type: String })
|
|
653
|
+
], DatetimeField.prototype, "value", null);
|
|
654
|
+
__decorate([
|
|
655
|
+
state()
|
|
656
|
+
], DatetimeField.prototype, "partLabel", void 0);
|
|
657
|
+
DatetimeField = __decorate([
|
|
658
|
+
customElement('ef-datetime-field')
|
|
659
|
+
], DatetimeField);
|
|
660
|
+
export { DatetimeField };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare type NavigationKeys = 'ArrowLeft' | 'ArrowRight' | 'ArrowUp' | 'ArrowDown' | 'Escape';
|
|
2
|
+
export declare type DateTimeFormatPartTypes = Intl.DateTimeFormatPartTypes | 'fractionalSecond';
|
|
3
|
+
export interface DateTimeFormatPart {
|
|
4
|
+
type: DateTimeFormatPartTypes;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export declare type InputSelection = {
|
|
8
|
+
selectionStart: number | null;
|
|
9
|
+
selectionEnd: number | null;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|