@luzmo/lucero 1.0.1-alpha.18 → 1.0.1-alpha.19
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/components/NumberFormatter-DewVDY5w.cjs +18 -0
- package/components/NumberFormatter-DgOUVrge.js +136 -0
- package/components/NumberParser-Dik4a0h-.cjs +18 -0
- package/components/NumberParser-ci9J5EKv.js +173 -0
- package/components/accordion/index.cjs +6 -183
- package/components/accordion/index.js +88 -136
- package/components/action-bar/index.cjs +4 -85
- package/components/action-bar/index.js +50 -72
- package/components/action-button/index.cjs +3 -205
- package/components/action-button/index.js +93 -167
- package/components/action-group/index.cjs +1 -7
- package/components/action-group/index.js +8 -12
- package/components/action-group-C54IxNZk.cjs +20 -0
- package/components/action-group-C9dsPJg-.js +258 -0
- package/components/action-menu/index.cjs +11 -91
- package/components/action-menu/index.js +47 -66
- package/components/async-directive-BwIAw5tB.js +82 -0
- package/components/async-directive-DLz6JB0v.cjs +22 -0
- package/components/avatar/index.cjs +3 -63
- package/components/avatar/index.js +42 -54
- package/components/{focusable-selectors-D0t_5P7C.cjs → base-BjTwmyRF.cjs} +5 -16
- package/components/base-CFWO09N1.js +684 -0
- package/components/base-Cy0MQrPT.cjs +40 -0
- package/components/base-D76d76ww.js +26 -0
- package/components/button/index.cjs +2 -134
- package/components/button/index.js +72 -106
- package/components/button-base-B8bWcklV.js +144 -0
- package/components/button-base-tf95Lyl4.cjs +25 -0
- package/components/button-group/index.cjs +1 -45
- package/components/button-group/index.js +25 -37
- package/components/calendar/index.cjs +1 -632
- package/components/calendar/index.js +7 -637
- package/components/checkbox/index.cjs +4 -111
- package/components/checkbox/index.js +53 -98
- package/components/checkbox-mixin-BOTvuPEu.js +70 -0
- package/components/checkbox-mixin-BVPpXtsq.cjs +27 -0
- package/components/class-map-CGfNk3Ee.js +51 -0
- package/components/class-map-D-Y-hsN5.cjs +22 -0
- package/components/clear-button-CuPbWwZY.cjs +18 -0
- package/components/clear-button-DzZ5ulBW.js +53 -0
- package/components/close-button-BTo4yrFR.cjs +18 -0
- package/components/close-button-CuQdsez5.js +51 -0
- package/components/color-area/index.cjs +13 -440
- package/components/color-area/index.js +187 -322
- package/components/color-controller-B0uX6Zso.js +3230 -0
- package/components/color-controller-CoUL5f9K.cjs +18 -0
- package/components/color-field/index.cjs +2 -95
- package/components/color-field/index.js +41 -77
- package/components/color-handle/index.cjs +3 -64
- package/components/color-handle/index.js +37 -58
- package/components/color-loupe/index.cjs +1 -7
- package/components/color-loupe/index.js +8 -12
- package/components/color-loupe-CrM2DVY3.cjs +56 -0
- package/components/color-loupe-DmQe3SpP.js +81 -0
- package/components/color-menu/index.cjs +12 -217
- package/components/color-menu/index.js +93 -187
- package/components/color-palette/index.cjs +1 -89
- package/components/color-palette/index.js +51 -78
- package/components/color-palette-group/index.cjs +3 -259
- package/components/color-palette-group/index.js +105 -193
- package/components/color-picker/index.cjs +6 -114
- package/components/color-picker/index.js +72 -92
- package/components/color-slider/index.cjs +1 -585
- package/components/color-slider/index.js +7 -590
- package/components/condition-attribute-with-id-DrQYZzFS.cjs +18 -0
- package/components/condition-attribute-with-id-Dv4lSRbe.js +31 -0
- package/components/date-time-picker/index.cjs +31 -1357
- package/components/date-time-picker/index.js +637 -951
- package/components/{dependency-manger-XHpQjFgK.js → dependency-manger-CO-VPlqq.js} +14 -24
- package/components/dependency-manger-uthev62E.cjs +18 -0
- package/components/directive-C7oCP5Bh.cjs +22 -0
- package/components/directive-helpers-D4KMv2dC.js +62 -0
- package/components/directive-helpers-t-TVum7J.cjs +22 -0
- package/components/{slottable-request-event-CANixJnR.cjs → directive-oAbCiebi.js} +25 -14
- package/components/divider/index.cjs +1 -54
- package/components/divider/index.js +30 -49
- package/components/divider.module-DDvBo9zo.cjs +18 -0
- package/components/divider.module-DoQWQEIJ.js +21 -0
- package/components/element-resolution-BvRLGqIU.cjs +18 -0
- package/components/element-resolution-FCUT-wql.js +91 -0
- package/components/field-group/index.cjs +1 -7
- package/components/field-group/index.js +8 -12
- package/components/field-group-5WQMBOk4.cjs +23 -0
- package/components/field-group-D4B0IOdA.js +66 -0
- package/components/field-label/index.cjs +1 -7
- package/components/field-label/index.js +8 -12
- package/components/field-label-DxmPiC5p.js +106 -0
- package/components/field-label-Dz9kisdW.cjs +25 -0
- package/components/flow-D-0MTYCm.js +527 -0
- package/components/flow-DM3dNAKs.cjs +30 -0
- package/components/focus-group-DHeTq18L.js +218 -0
- package/components/focus-group-DnxZUBhQ.cjs +18 -0
- package/components/focus-visible-BvScGDCE.js +74 -0
- package/components/focus-visible-D4BXb5RB.cjs +18 -0
- package/components/focusable-B_KwfEec.cjs +18 -0
- package/components/focusable-C5JjRZmT.js +153 -0
- package/components/{focusable-selectors-IltOAOd9.js → focusable-selectors-B4YgbghQ.js} +4 -7
- package/components/focusable-selectors-BgFlyFcY.cjs +18 -0
- package/components/icon/index.cjs +1 -90
- package/components/icon/index.js +46 -74
- package/components/if-defined-DULpqYwi.js +27 -0
- package/components/if-defined-DaXWqfzc.cjs +22 -0
- package/components/index-CNK8wHXu.cjs +57 -0
- package/components/index-Cf6G4q52.js +1490 -0
- package/components/index-D3ICqC7S.js +1174 -0
- package/components/index-hqVbNKYy.cjs +113 -0
- package/components/index.cjs +1 -174
- package/components/index.js +172 -174
- package/components/infield-button/index.cjs +2 -46
- package/components/infield-button/index.js +30 -41
- package/components/label/index.cjs +1 -37
- package/components/label/index.js +24 -36
- package/components/{language-resolution-BSGJAWiQ.js → language-resolution-B-wjV5bb.js} +17 -21
- package/components/language-resolution-EUER43cg.cjs +18 -0
- package/components/like-anchor-Bu3pXbjT.cjs +32 -0
- package/components/like-anchor-DCFJN0LV.js +69 -0
- package/components/luzmo-icons-CiSek5iM.js +229 -0
- package/components/luzmo-icons-CtA-TJPd.cjs +29 -0
- package/components/manage-help-text-CHfMLzSa.js +92 -0
- package/components/manage-help-text-DNqdEkTA.cjs +30 -0
- package/components/menu/index.cjs +29 -1297
- package/components/menu/index.js +499 -954
- package/components/multi-language-field/index.cjs +2 -132
- package/components/multi-language-field/index.js +88 -118
- package/components/mutation-controller-DH7YOCyj.js +52 -0
- package/components/mutation-controller-DkOMCW-c.cjs +22 -0
- package/components/number-field/index.cjs +10 -613
- package/components/number-field/index.js +243 -442
- package/components/observe-slot-presence-CmVi0zTc.js +68 -0
- package/components/observe-slot-presence-bc9chhsi.cjs +18 -0
- package/components/observe-slot-text-C3moTjwy.js +87 -0
- package/components/observe-slot-text-D2VAEFSd.cjs +18 -0
- package/components/options/index.cjs +60 -693
- package/components/options/index.js +953 -519
- package/components/overlay/index.cjs +21 -367
- package/components/overlay/index.js +189 -273
- package/components/overlay-B3ajDLLq.cjs +47 -0
- package/components/overlay-CUKs69yr.js +2745 -0
- package/components/{pending-state-CXbe-Xul.js → pending-state-B2wWssTo.js} +13 -28
- package/components/pending-state-bJr-nEJl.cjs +26 -0
- package/components/picker/index.cjs +1 -9
- package/components/picker/index.js +11 -15
- package/components/picker-C0LvseZe.cjs +123 -0
- package/components/picker-W1qNmtsh.js +461 -0
- package/components/picker-button/index.cjs +4 -56
- package/components/picker-button/index.js +34 -45
- package/components/{condition-attribute-with-id-Cn815e9W.js → platform-BM-uMWpX.js} +49 -24
- package/components/platform-BiXhwqk3.cjs +18 -0
- package/components/popover/index.cjs +1 -7
- package/components/popover/index.js +8 -12
- package/components/popover-fwJeZHMQ.cjs +30 -0
- package/components/popover-iD8f5Jkp.js +67 -0
- package/components/progress-circle/index.cjs +1 -7
- package/components/progress-circle/index.js +8 -12
- package/components/progress-circle-DZxaMe8L.cjs +33 -0
- package/components/progress-circle-USIIU1up.js +97 -0
- package/components/query-BL-TJj7K.cjs +22 -0
- package/components/query-D_KR_GUc.js +51 -0
- package/components/query-assigned-elements-DjfhL1cl.js +36 -0
- package/components/query-assigned-elements-DsKsfk7G.cjs +22 -0
- package/components/query-assigned-nodes-BcKWmGzy.cjs +22 -0
- package/components/query-assigned-nodes-C76XVPWY.js +36 -0
- package/components/radio/index.cjs +2 -244
- package/components/radio/index.js +110 -192
- package/components/{random-id-BEc6QIUL.js → random-id-ByCz1xaq.js} +3 -3
- package/components/random-id-CqvckpWe.cjs +18 -0
- package/components/roving-tabindex-By_fCy_e.cjs +18 -0
- package/components/roving-tabindex-DOg4z6ZU.js +66 -0
- package/components/search/index.cjs +8 -115
- package/components/search/index.js +66 -96
- package/components/select/index.cjs +51 -720
- package/components/select/index.js +347 -563
- package/components/sized-mixin-CJbBHWRQ.js +63 -0
- package/components/sized-mixin-WPHH0a_D.cjs +18 -0
- package/components/slider/index.cjs +1 -119
- package/components/slider/index.js +1113 -100
- package/components/slottable-request-event-BfUUt1Mh.cjs +18 -0
- package/components/{slottable-request-event-D9WzrdWv.js → slottable-request-event-DggLA4Rx.js} +9 -12
- package/components/state-DwIwYPvt.js +29 -0
- package/components/state-vf0PJN3_.cjs +22 -0
- package/components/strategies-C6HsQpU2.cjs +18 -0
- package/components/strategies-CUMLHtQI.js +195 -0
- package/components/streaming-listener-BQ68fKMa.js +91 -0
- package/components/streaming-listener-DeGQYM-9.cjs +18 -0
- package/components/style-map-Bnhf_mVZ.js +53 -0
- package/components/style-map-DuMd5xlY.cjs +22 -0
- package/components/swatch/index.cjs +7 -436
- package/components/swatch/index.js +205 -350
- package/components/switch/index.cjs +2 -61
- package/components/switch/index.js +34 -51
- package/components/tabs/index.cjs +26 -693
- package/components/tabs/index.js +388 -521
- package/components/tags/index.cjs +4 -201
- package/components/tags/index.js +87 -152
- package/components/text-field/index.cjs +3 -49
- package/components/text-field/index.js +30 -44
- package/components/text-field-BkFPYo7S.cjs +85 -0
- package/components/text-field-C2n3rzCK.js +314 -0
- package/components/text-field.module-C2KVUJcX.js +21 -0
- package/components/text-field.module-DXhFA9G-.cjs +18 -0
- package/components/toast/index.cjs +12 -177
- package/components/toast/index.js +73 -145
- package/components/tooltip/index.cjs +6 -250
- package/components/tooltip/index.js +124 -177
- package/components/unit-input/index.cjs +8 -232
- package/components/unit-input/index.js +108 -201
- package/components/utils.cjs +1 -25
- package/components/utils.js +22 -22
- package/components/{random-id-BE6HA503.cjs → when-CDK1Tt5Y.js} +10 -7
- package/components/when-CDZyJPvd.cjs +22 -0
- package/package.json +1 -1
- package/components/action-group-DHp8RHDf.js +0 -392
- package/components/action-group-MPf19RPV.cjs +0 -391
- package/components/base-COw9n7UR.cjs +0 -119
- package/components/base-DmeVy0cq.js +0 -120
- package/components/button-base-7Ak55xFd.cjs +0 -206
- package/components/button-base-C3kf6BTK.js +0 -207
- package/components/checkbox-mixin-8cL-vfDy.js +0 -84
- package/components/checkbox-mixin-CE7dJj3J.cjs +0 -83
- package/components/clear-button-Co6oKSgl.js +0 -59
- package/components/clear-button-X_HDY2eH.cjs +0 -58
- package/components/close-button-DPBK6Kpu.cjs +0 -59
- package/components/close-button-Miw9ZjoJ.js +0 -60
- package/components/color-controller-BjDZaxhX.js +0 -491
- package/components/color-controller-C3c_vb2P.cjs +0 -490
- package/components/color-loupe-BQqNR8YD.cjs +0 -88
- package/components/color-loupe-B_DDFv8l.js +0 -89
- package/components/condition-attribute-with-id-DEc2Yjne.cjs +0 -43
- package/components/dependency-manger-CcIE1uvQ.cjs +0 -63
- package/components/divider.module-Cm5LcDRV.cjs +0 -20
- package/components/divider.module-DauH6k2_.js +0 -21
- package/components/element-resolution-DCsrhGZO.cjs +0 -112
- package/components/element-resolution-nMlmW4Jy.js +0 -113
- package/components/field-group-DNmY8W9v.cjs +0 -86
- package/components/field-group-DVdAWCQF.js +0 -87
- package/components/field-label-CKH9EXpR.cjs +0 -156
- package/components/field-label-Dpsecoc6.js +0 -157
- package/components/focus-group-BqDAk9Is.js +0 -337
- package/components/focus-group-DFzOlalL.cjs +0 -336
- package/components/focus-visible-B-B8-P9R.cjs +0 -104
- package/components/focus-visible-BUPRWlsh.js +0 -105
- package/components/focusable-BPrTcZPd.cjs +0 -262
- package/components/focusable-ChCLg1k4.js +0 -263
- package/components/language-resolution-iN9EImbb.cjs +0 -57
- package/components/like-anchor-D62faRNG.cjs +0 -79
- package/components/like-anchor-v3cJ9RWM.js +0 -80
- package/components/manage-help-text-BYx84zZR.cjs +0 -125
- package/components/manage-help-text-DOuMTGht.js +0 -126
- package/components/observe-slot-presence-9AwLGUQ_.cjs +0 -78
- package/components/observe-slot-presence-DcMdoumP.js +0 -79
- package/components/observe-slot-text-CSofZeeF.cjs +0 -104
- package/components/observe-slot-text-CjnkkBPn.js +0 -105
- package/components/overlay-CN8ISP1F.js +0 -2485
- package/components/overlay-LViy9VWM.cjs +0 -2484
- package/components/pending-state-e4RbXe9u.cjs +0 -75
- package/components/picker-DNde3awt.cjs +0 -672
- package/components/picker-PfUAF05y.js +0 -673
- package/components/platform-CxDar3Dn.cjs +0 -68
- package/components/platform-Cxn0WbyT.js +0 -69
- package/components/popover-BkbYhl3i.js +0 -74
- package/components/popover-BkgUf0kL.cjs +0 -74
- package/components/progress-circle-Hu_ivPHf.js +0 -133
- package/components/progress-circle-_Etqsj9f.cjs +0 -132
- package/components/roving-tabindex-AsmAh2In.cjs +0 -95
- package/components/roving-tabindex-DPF9NmrH.js +0 -96
- package/components/sized-mixin-DmkrNdWB.js +0 -80
- package/components/sized-mixin-UaTVa-AE.cjs +0 -79
- package/components/strategies-DlMlaSJR.cjs +0 -317
- package/components/strategies-DlPQoTFE.js +0 -318
- package/components/streaming-listener-D4sHaMub.cjs +0 -145
- package/components/streaming-listener-cAz5zJyk.js +0 -146
- package/components/text-field-11tcnftU.cjs +0 -338
- package/components/text-field-Chi9J2Cz.js +0 -339
- package/components/text-field.module-CMBS0jSL.js +0 -21
- package/components/text-field.module-DIJdV_sA.cjs +0 -20
|
@@ -15,944 +15,31 @@
|
|
|
15
15
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
16
|
* SOFTWARE.
|
|
17
17
|
* */
|
|
18
|
-
"use strict";
|
|
19
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
20
|
-
const date = require("@internationalized/date");
|
|
21
|
-
const number = require("@internationalized/number");
|
|
22
|
-
const lit = require("lit");
|
|
23
|
-
const decorators_js = require("lit/decorators.js");
|
|
24
|
-
const classMap_js = require("lit/directives/class-map.js");
|
|
25
|
-
const ifDefined_js = require("lit/directives/if-defined.js");
|
|
26
|
-
const styleMap_js = require("lit/directives/style-map.js");
|
|
27
|
-
const when_js = require("lit/directives/when.js");
|
|
28
|
-
const focusable = require("../focusable-BPrTcZPd.cjs");
|
|
29
|
-
const sizedMixin = require("../sized-mixin-UaTVa-AE.cjs");
|
|
30
|
-
const icons = require("@luzmo/icons");
|
|
31
|
-
require("../calendar/index.cjs");
|
|
32
|
-
require("../icon/index.cjs");
|
|
33
|
-
require("../overlay/index.cjs");
|
|
34
|
-
require("../picker-button/index.cjs");
|
|
35
|
-
require("../popover/index.cjs");
|
|
36
|
-
const manageHelpText = require("../manage-help-text-BYx84zZR.cjs");
|
|
37
|
-
const textField_module = require("../text-field.module-DIJdV_sA.cjs");
|
|
38
|
-
const SegmentTypes = {
|
|
39
|
-
Year: "year",
|
|
40
|
-
Month: "month",
|
|
41
|
-
Day: "day",
|
|
42
|
-
Hour: "hour",
|
|
43
|
-
Minute: "minute",
|
|
44
|
-
Second: "second",
|
|
45
|
-
Millisecond: "fractionalSecond",
|
|
46
|
-
DayPeriod: "dayPeriod",
|
|
47
|
-
Literal: "literal"
|
|
48
|
-
};
|
|
49
|
-
const SegmentPlaceholders = {
|
|
50
|
-
[SegmentTypes.Year]: "––––",
|
|
51
|
-
[SegmentTypes.Month]: "––",
|
|
52
|
-
[SegmentTypes.Day]: "––",
|
|
53
|
-
[SegmentTypes.Hour]: "––",
|
|
54
|
-
[SegmentTypes.Minute]: "––",
|
|
55
|
-
[SegmentTypes.Second]: "––",
|
|
56
|
-
[SegmentTypes.Millisecond]: "–––",
|
|
57
|
-
[SegmentTypes.DayPeriod]: "––"
|
|
58
|
-
};
|
|
59
|
-
const Precisions = {
|
|
60
|
-
Day: "day",
|
|
61
|
-
Hour: "hour",
|
|
62
|
-
Minute: "minute",
|
|
63
|
-
Second: "second",
|
|
64
|
-
Millisecond: "millisecond"
|
|
65
|
-
};
|
|
66
|
-
const AM = 0;
|
|
67
|
-
const PM = 12;
|
|
68
|
-
const DEFAULT_LEAP_YEAR = 2e3;
|
|
69
|
-
const MAX_DAYS_PER_MONTH = 31;
|
|
70
|
-
function isNumber(value) {
|
|
71
|
-
return typeof value === "number";
|
|
72
|
-
}
|
|
73
|
-
function isZonedDateTime(date$1) {
|
|
74
|
-
return date$1 instanceof date.ZonedDateTime;
|
|
75
|
-
}
|
|
76
|
-
function isCalendarDateTime(date$1) {
|
|
77
|
-
return date$1 instanceof date.CalendarDateTime;
|
|
78
|
-
}
|
|
79
|
-
function isCalendarDate(date$1) {
|
|
80
|
-
return date$1 instanceof date.CalendarDate;
|
|
81
|
-
}
|
|
82
|
-
function convertHourTo24hFormat(hour, dayPeriod) {
|
|
83
|
-
return hour = hour % PM + dayPeriod;
|
|
84
|
-
}
|
|
85
|
-
function getDayPeriodModifier(hour) {
|
|
86
|
-
return hour >= PM ? PM : AM;
|
|
87
|
-
}
|
|
88
|
-
function equalSegmentValues(a, b) {
|
|
89
|
-
return a.length === b.length && a.every((value, index) => value === b[index]);
|
|
90
|
-
}
|
|
91
|
-
function dateValueToDate(dateValue) {
|
|
92
|
-
if (isCalendarDate(dateValue)) {
|
|
93
|
-
return new Date(dateValue.year, dateValue.month - 1, dateValue.day);
|
|
94
|
-
}
|
|
95
|
-
return new Date(
|
|
96
|
-
dateValue.year,
|
|
97
|
-
dateValue.month - 1,
|
|
98
|
-
dateValue.day,
|
|
99
|
-
dateValue.hour,
|
|
100
|
-
dateValue.minute,
|
|
101
|
-
dateValue.second,
|
|
102
|
-
dateValue.millisecond
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
class EditableSegment {
|
|
106
|
-
constructor(type, formatted, label) {
|
|
107
|
-
this.type = type;
|
|
108
|
-
this.formatted = formatted;
|
|
109
|
-
this.label = label;
|
|
110
|
-
this.placeholder = SegmentPlaceholders[type];
|
|
111
|
-
}
|
|
112
|
-
increment(_value) {
|
|
113
|
-
if (this.value === void 0) this.value = this.minValue;
|
|
114
|
-
else {
|
|
115
|
-
this.value = this.value + 1;
|
|
116
|
-
if (this.value > this.maxValue) this.value = this.minValue;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
decrement(_value) {
|
|
120
|
-
if (this.value === void 0) this.value = this.maxValue;
|
|
121
|
-
else {
|
|
122
|
-
this.value = this.value - 1;
|
|
123
|
-
if (this.value < this.minValue) this.value = this.maxValue;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
setValueFromDate(currentDate) {
|
|
127
|
-
if (this.type === "fractionalSecond") {
|
|
128
|
-
this.value = currentDate.millisecond;
|
|
129
|
-
} else if (this.type !== SegmentTypes.DayPeriod) {
|
|
130
|
-
this.value = currentDate[this.type];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
clear() {
|
|
134
|
-
this.value = void 0;
|
|
135
|
-
}
|
|
136
|
-
handleInput(eventData, numberParser) {
|
|
137
|
-
const typedValue = numberParser.parse(eventData);
|
|
138
|
-
if (Number.isNaN(typedValue)) return;
|
|
139
|
-
const newValue = numberParser.parse(
|
|
140
|
-
`${this.value ?? ""}${typedValue}`
|
|
141
|
-
);
|
|
142
|
-
if (this.isInputValueCompliant(newValue)) {
|
|
143
|
-
this.value = newValue;
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
if (this.isInputValueCompliant(typedValue)) this.value = typedValue;
|
|
147
|
-
}
|
|
148
|
-
isInputValueCompliant(value) {
|
|
149
|
-
const { minValue, maxValue } = this.inputValidationLimits;
|
|
150
|
-
return value >= minValue && value <= maxValue;
|
|
151
|
-
}
|
|
152
|
-
get inputValidationLimits() {
|
|
153
|
-
return {
|
|
154
|
-
minValue: this.minValue,
|
|
155
|
-
maxValue: this.maxValue
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
updateValueToLimits() {
|
|
159
|
-
if (this.value === void 0) return;
|
|
160
|
-
if (this.value < this.minValue) this.value = this.minValue;
|
|
161
|
-
if (this.value > this.maxValue) this.value = this.maxValue;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
class YearSegment extends EditableSegment {
|
|
165
|
-
constructor(formatted, label) {
|
|
166
|
-
super(SegmentTypes.Year, formatted, label);
|
|
167
|
-
this.minValue = 1;
|
|
168
|
-
this.maxValue = 9999;
|
|
169
|
-
}
|
|
170
|
-
setLimits(currentDate) {
|
|
171
|
-
this.minValue = 1;
|
|
172
|
-
this.maxValue = currentDate.calendar.getYearsInEra(currentDate);
|
|
173
|
-
this.updateValueToLimits();
|
|
174
|
-
}
|
|
175
|
-
increment(currentDate) {
|
|
176
|
-
if (this.value === void 0) this.value = currentDate.year;
|
|
177
|
-
else super.increment();
|
|
178
|
-
}
|
|
179
|
-
decrement(currentDate) {
|
|
180
|
-
if (this.value === void 0) this.value = currentDate.year;
|
|
181
|
-
else super.decrement();
|
|
182
|
-
}
|
|
183
|
-
clear() {
|
|
184
|
-
if (this.value === void 0) return;
|
|
185
|
-
const newValue = Math.floor(this.value / 10);
|
|
186
|
-
this.value = newValue > 0 ? newValue : void 0;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
class DateTimeSegments {
|
|
190
|
-
constructor(segments) {
|
|
191
|
-
this.segments = segments;
|
|
192
|
-
}
|
|
193
|
-
get all() {
|
|
194
|
-
return this.segments;
|
|
195
|
-
}
|
|
196
|
-
get editableValues() {
|
|
197
|
-
return this.all.filter((segment) => segment instanceof EditableSegment).map((segment) => segment.value);
|
|
198
|
-
}
|
|
199
|
-
get year() {
|
|
200
|
-
const yearSegment = this.getByType(SegmentTypes.Year);
|
|
201
|
-
if (yearSegment && yearSegment instanceof YearSegment) return yearSegment;
|
|
202
|
-
return void 0;
|
|
203
|
-
}
|
|
204
|
-
get month() {
|
|
205
|
-
const monthSegment = this.getByType(SegmentTypes.Month);
|
|
206
|
-
if (monthSegment) return monthSegment;
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
get day() {
|
|
210
|
-
const daySegment = this.getByType(SegmentTypes.Day);
|
|
211
|
-
if (daySegment) return daySegment;
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
get hour() {
|
|
215
|
-
const hourSegment = this.getByType(SegmentTypes.Hour);
|
|
216
|
-
if (hourSegment) return hourSegment;
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
get minute() {
|
|
220
|
-
const minuteSegment = this.getByType(SegmentTypes.Minute);
|
|
221
|
-
if (minuteSegment) return minuteSegment;
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
get second() {
|
|
225
|
-
const secondSegment = this.getByType(SegmentTypes.Second);
|
|
226
|
-
if (secondSegment) return secondSegment;
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
get millisecond() {
|
|
230
|
-
const millisecondSegment = this.getByType(SegmentTypes.Millisecond);
|
|
231
|
-
if (millisecondSegment) return millisecondSegment;
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
get dayPeriod() {
|
|
235
|
-
const dayPeriodSegment = this.getByType(SegmentTypes.DayPeriod);
|
|
236
|
-
if (dayPeriodSegment) return dayPeriodSegment;
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
getByType(type) {
|
|
240
|
-
return this.segments.find(
|
|
241
|
-
(segment) => segment.type === type
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Returns a `CalendarDate` object with the year, month and day values of the segments if they are all defined. The time values
|
|
246
|
-
* are checked and included based on the precision provided, returning a `CalendarDateTime` instead.
|
|
247
|
-
*
|
|
248
|
-
* @param precision - The precision to use when creating the date object
|
|
249
|
-
*/
|
|
250
|
-
getFormattedDate(precision = Precisions.Day) {
|
|
251
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
252
|
-
const year = (_a = this.year) == null ? void 0 : _a.value;
|
|
253
|
-
const month = (_b = this.month) == null ? void 0 : _b.value;
|
|
254
|
-
const day = (_c = this.day) == null ? void 0 : _c.value;
|
|
255
|
-
if (!isNumber(year) || !isNumber(month) || !isNumber(day)) return;
|
|
256
|
-
if (precision === Precisions.Day) return new date.CalendarDate(year, month, day);
|
|
257
|
-
let hour = (_d = this.hour) == null ? void 0 : _d.value;
|
|
258
|
-
if (!isNumber(hour)) return;
|
|
259
|
-
if (this.dayPeriod) {
|
|
260
|
-
const dayPeriod = this.dayPeriod.value;
|
|
261
|
-
if (!isNumber(dayPeriod)) return;
|
|
262
|
-
hour = convertHourTo24hFormat(hour, dayPeriod);
|
|
263
|
-
}
|
|
264
|
-
if (precision === Precisions.Hour)
|
|
265
|
-
return new date.CalendarDateTime(year, month, day, hour);
|
|
266
|
-
const minute = (_e = this.minute) == null ? void 0 : _e.value;
|
|
267
|
-
if (!isNumber(minute)) return;
|
|
268
|
-
if (precision === Precisions.Minute)
|
|
269
|
-
return new date.CalendarDateTime(year, month, day, hour, minute);
|
|
270
|
-
const second = (_f = this.second) == null ? void 0 : _f.value;
|
|
271
|
-
if (!isNumber(second)) return;
|
|
272
|
-
if (precision === Precisions.Second)
|
|
273
|
-
return new date.CalendarDateTime(year, month, day, hour, minute, second);
|
|
274
|
-
const millisecond = (_g = this.millisecond) == null ? void 0 : _g.value;
|
|
275
|
-
if (!isNumber(millisecond)) return;
|
|
276
|
-
return new date.CalendarDateTime(
|
|
277
|
-
year,
|
|
278
|
-
month,
|
|
279
|
-
day,
|
|
280
|
-
hour,
|
|
281
|
-
minute,
|
|
282
|
-
second,
|
|
283
|
-
millisecond
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
class SegmentsFormatter {
|
|
288
|
-
constructor(dateFormatter, currentDate) {
|
|
289
|
-
this.dateFormatter = dateFormatter;
|
|
290
|
-
this.currentDate = currentDate;
|
|
291
|
-
this.numberFormatter = new number.NumberFormatter(
|
|
292
|
-
this.dateFormatter.resolvedOptions().locale,
|
|
293
|
-
{ useGrouping: false }
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Formats all the `DateTimeSegments` to have the formatted property based on the value property, according to the date formatter.
|
|
298
|
-
* @param segments - `DateTimeSegments` to format
|
|
299
|
-
* @returns Formatted DateTimeSegments
|
|
300
|
-
*/
|
|
301
|
-
format(segments) {
|
|
302
|
-
if (!segments.year || !segments.month || !segments.day) return segments;
|
|
303
|
-
const dateInfo = this.getDateInfoWithDefaults(segments);
|
|
304
|
-
if (!dateInfo) return segments;
|
|
305
|
-
this.setSegmentsFormatted(segments, dateInfo);
|
|
306
|
-
this.padSegmentsFormatted(segments);
|
|
307
|
-
return segments;
|
|
308
|
-
}
|
|
309
|
-
setSegmentsFormatted(segments, dateInfo) {
|
|
310
|
-
var _a;
|
|
311
|
-
segments = new DateTimeSegments(segments.all);
|
|
312
|
-
const { year, month, day, hour, minute, second, millisecond } = dateInfo;
|
|
313
|
-
const date2 = new Date(
|
|
314
|
-
year,
|
|
315
|
-
month - 1,
|
|
316
|
-
day,
|
|
317
|
-
hour,
|
|
318
|
-
minute,
|
|
319
|
-
second,
|
|
320
|
-
millisecond
|
|
321
|
-
);
|
|
322
|
-
if (!segments.year) return;
|
|
323
|
-
segments.year.formatted = this.numberFormatter.format(year);
|
|
324
|
-
const segmentTypesToFormat = [
|
|
325
|
-
SegmentTypes.Month,
|
|
326
|
-
SegmentTypes.Day,
|
|
327
|
-
SegmentTypes.Hour,
|
|
328
|
-
SegmentTypes.Minute,
|
|
329
|
-
SegmentTypes.Second,
|
|
330
|
-
SegmentTypes.DayPeriod
|
|
331
|
-
];
|
|
332
|
-
const formattedDateParts = this.dateFormatter.formatToParts(date2);
|
|
333
|
-
for (const segmentType of segmentTypesToFormat) {
|
|
334
|
-
const segment = segments[segmentType];
|
|
335
|
-
if (!segment) continue;
|
|
336
|
-
const formattedPart = (_a = formattedDateParts.find(
|
|
337
|
-
(part) => part.type === segmentType
|
|
338
|
-
)) == null ? void 0 : _a.value;
|
|
339
|
-
if (!formattedPart) continue;
|
|
340
|
-
segment.formatted = formattedPart;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
padSegmentsFormatted(segments) {
|
|
344
|
-
if (!segments.hour) return;
|
|
345
|
-
const segmentTypesToPad = [
|
|
346
|
-
SegmentTypes.Month,
|
|
347
|
-
SegmentTypes.Day,
|
|
348
|
-
SegmentTypes.Hour,
|
|
349
|
-
SegmentTypes.Minute,
|
|
350
|
-
SegmentTypes.Second
|
|
351
|
-
];
|
|
352
|
-
for (const segmentType of segmentTypesToPad) {
|
|
353
|
-
const segment = segments[segmentType];
|
|
354
|
-
if (!segment) continue;
|
|
355
|
-
segment.formatted = segment.formatted.padStart(
|
|
356
|
-
2,
|
|
357
|
-
this.numberFormatter.format(0)
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
getDateInfoWithDefaults(segments) {
|
|
362
|
-
var _a, _b, _c, _d, _e;
|
|
363
|
-
if (!segments.year || !segments.month || !segments.day) return;
|
|
364
|
-
const day = segments.day.value ?? date.getMinimumDayInMonth(this.currentDate);
|
|
365
|
-
const month = segments.month.value ?? date.getMinimumMonthInYear(this.currentDate);
|
|
366
|
-
const year = segments.year.value ?? DEFAULT_LEAP_YEAR;
|
|
367
|
-
const dayPeriod = (_a = segments.dayPeriod) == null ? void 0 : _a.value;
|
|
368
|
-
let hour = (_b = segments.hour) == null ? void 0 : _b.value;
|
|
369
|
-
if (!isNumber(hour)) {
|
|
370
|
-
hour = isNumber(dayPeriod) ? dayPeriod : this.currentDate.hour;
|
|
371
|
-
} else if (isNumber(dayPeriod)) {
|
|
372
|
-
hour = convertHourTo24hFormat(hour, dayPeriod);
|
|
373
|
-
}
|
|
374
|
-
const minute = ((_c = segments.minute) == null ? void 0 : _c.value) ?? this.currentDate.minute;
|
|
375
|
-
const second = ((_d = segments.second) == null ? void 0 : _d.value) ?? this.currentDate.second;
|
|
376
|
-
const millisecond = ((_e = segments.millisecond) == null ? void 0 : _e.value) ?? this.currentDate.millisecond;
|
|
377
|
-
return { year, month, day, hour, minute, second, millisecond };
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
class SegmentsModifier {
|
|
381
|
-
constructor(params) {
|
|
382
|
-
const { dateFormatter, segments, currentDate } = params;
|
|
383
|
-
this.segments = new DateTimeSegments(segments.all);
|
|
384
|
-
this.dateFormatter = dateFormatter;
|
|
385
|
-
this.currentDate = currentDate;
|
|
386
|
-
}
|
|
387
|
-
modify(segmentType) {
|
|
388
|
-
const segment = this.segments.getByType(segmentType);
|
|
389
|
-
if (!segment) return this.segments;
|
|
390
|
-
this.modifySegment(segment);
|
|
391
|
-
this.updateSegmentsLimits(segmentType);
|
|
392
|
-
const segmentsFormatter = new SegmentsFormatter(
|
|
393
|
-
this.dateFormatter,
|
|
394
|
-
this.currentDate
|
|
395
|
-
);
|
|
396
|
-
this.segments = segmentsFormatter.format(this.segments);
|
|
397
|
-
return this.segments;
|
|
398
|
-
}
|
|
399
|
-
updateSegmentsLimits(modifiedSegmentType) {
|
|
400
|
-
const changedYear = modifiedSegmentType === SegmentTypes.Year;
|
|
401
|
-
const changedMonth = modifiedSegmentType === SegmentTypes.Month;
|
|
402
|
-
const year = this.segments.year;
|
|
403
|
-
const month = this.segments.month;
|
|
404
|
-
const day = this.segments.day;
|
|
405
|
-
if (changedYear) {
|
|
406
|
-
month == null ? void 0 : month.setLimits(this.currentDate);
|
|
407
|
-
day == null ? void 0 : day.setLimits(this.currentDate, month == null ? void 0 : month.value, year == null ? void 0 : year.value);
|
|
408
|
-
}
|
|
409
|
-
if (changedMonth)
|
|
410
|
-
day == null ? void 0 : day.setLimits(this.currentDate, month == null ? void 0 : month.value, year == null ? void 0 : year.value);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
class ClearModifier extends SegmentsModifier {
|
|
414
|
-
modifySegment(segment) {
|
|
415
|
-
segment.clear();
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
class DecrementModifier extends SegmentsModifier {
|
|
419
|
-
modifySegment(segment) {
|
|
420
|
-
segment.decrement(this.currentDate);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
class IncrementModifier extends SegmentsModifier {
|
|
424
|
-
modifySegment(segment) {
|
|
425
|
-
segment.increment(this.currentDate);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
class InputModifier extends SegmentsModifier {
|
|
429
|
-
constructor(params) {
|
|
430
|
-
const { dateFormatter, segments, currentDate } = params;
|
|
431
|
-
super({ dateFormatter, segments, currentDate });
|
|
432
|
-
this.eventData = params.eventData;
|
|
433
|
-
this.numberParser = params.numberParser;
|
|
434
|
-
}
|
|
435
|
-
modifySegment(segment) {
|
|
436
|
-
if (this.eventData === null) return;
|
|
437
|
-
segment.handleInput(this.eventData, this.numberParser);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
class DaySegment extends EditableSegment {
|
|
441
|
-
constructor(formatted, label) {
|
|
442
|
-
super(SegmentTypes.Day, formatted, label);
|
|
443
|
-
this.minValue = 1;
|
|
444
|
-
this.maxValue = 31;
|
|
445
|
-
}
|
|
446
|
-
setLimits(currentDate, month, year) {
|
|
447
|
-
if (!isNumber(month)) {
|
|
448
|
-
this.minValue = 1;
|
|
449
|
-
this.maxValue = MAX_DAYS_PER_MONTH;
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
if (!isNumber(year)) year = DEFAULT_LEAP_YEAR;
|
|
453
|
-
const dateToUse = new date.CalendarDate(year, month, 1);
|
|
454
|
-
this.maxValue = currentDate.calendar.getDaysInMonth(dateToUse);
|
|
455
|
-
this.minValue = date.getMinimumDayInMonth(dateToUse);
|
|
456
|
-
this.updateValueToLimits();
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
class MonthSegment extends EditableSegment {
|
|
460
|
-
constructor(formatted, label) {
|
|
461
|
-
super(SegmentTypes.Month, formatted, label);
|
|
462
|
-
this.minValue = 1;
|
|
463
|
-
this.maxValue = 12;
|
|
464
|
-
}
|
|
465
|
-
setLimits(currentDate) {
|
|
466
|
-
this.minValue = date.getMinimumMonthInYear(currentDate);
|
|
467
|
-
this.maxValue = currentDate.calendar.getMonthsInYear(currentDate);
|
|
468
|
-
this.updateValueToLimits();
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
class LiteralSegment {
|
|
472
|
-
constructor(formatted) {
|
|
473
|
-
this.formatted = formatted;
|
|
474
|
-
this.type = SegmentTypes.Literal;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
class DayPeriodSegment extends EditableSegment {
|
|
478
|
-
constructor(formatted, label) {
|
|
479
|
-
super(SegmentTypes.DayPeriod, formatted, label);
|
|
480
|
-
this.minValue = AM;
|
|
481
|
-
this.maxValue = PM;
|
|
482
|
-
this.localizedMinValue = "AM";
|
|
483
|
-
this.localizedMaxValue = "PM";
|
|
484
|
-
}
|
|
485
|
-
toggleAmPm() {
|
|
486
|
-
this.value = this.value === AM ? PM : AM;
|
|
487
|
-
}
|
|
488
|
-
increment() {
|
|
489
|
-
if (this.value === void 0) this.value = this.minValue;
|
|
490
|
-
else this.toggleAmPm();
|
|
491
|
-
}
|
|
492
|
-
decrement() {
|
|
493
|
-
if (this.value === void 0) this.value = this.maxValue;
|
|
494
|
-
else this.toggleAmPm();
|
|
495
|
-
}
|
|
496
|
-
setValueFromDate(currentDate) {
|
|
497
|
-
this.value = getDayPeriodModifier(currentDate.hour);
|
|
498
|
-
}
|
|
499
|
-
handleInput(eventData) {
|
|
500
|
-
const charTypedIn = eventData.toLowerCase();
|
|
501
|
-
const isCharFromAM = this.localizedMinValue.toLowerCase().includes(charTypedIn);
|
|
502
|
-
const isCharFromPM = this.localizedMaxValue.toLowerCase().includes(charTypedIn);
|
|
503
|
-
if (isCharFromAM && isCharFromPM) return;
|
|
504
|
-
if (isCharFromAM) this.value = AM;
|
|
505
|
-
if (isCharFromPM) this.value = PM;
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
setLocalizedLimits(dateFormatter) {
|
|
509
|
-
const amDate = new Date(0, 0, 0, this.minValue, 0);
|
|
510
|
-
const pmDate = new Date(0, 0, 0, this.maxValue, 0);
|
|
511
|
-
const [am, pm] = [amDate, pmDate].map(
|
|
512
|
-
this.getDayPeriodFromDate.bind(this, dateFormatter)
|
|
513
|
-
);
|
|
514
|
-
if (am) this.localizedMinValue = am;
|
|
515
|
-
if (pm) this.localizedMaxValue = pm;
|
|
516
|
-
}
|
|
517
|
-
getDayPeriodFromDate(dateFormatter, date2) {
|
|
518
|
-
var _a;
|
|
519
|
-
return (_a = dateFormatter.formatToParts(date2).find((part) => part.type === this.type)) == null ? void 0 : _a.value;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
class HourSegment extends EditableSegment {
|
|
523
|
-
constructor(formatted, label) {
|
|
524
|
-
super(SegmentTypes.Hour, formatted, label);
|
|
525
|
-
this.minValue = 0;
|
|
526
|
-
this.maxValue = 23;
|
|
527
|
-
}
|
|
528
|
-
setLimits(is12HourClock) {
|
|
529
|
-
this.minValue = 0;
|
|
530
|
-
this.maxValue = 23;
|
|
531
|
-
if (is12HourClock) {
|
|
532
|
-
this.minValue = 0;
|
|
533
|
-
this.maxValue = 11;
|
|
534
|
-
}
|
|
535
|
-
this.updateValueToLimits();
|
|
536
|
-
}
|
|
537
|
-
setValueFromDate(currentDate, is12HourClock) {
|
|
538
|
-
if (is12HourClock)
|
|
539
|
-
this.value = currentDate.hour - getDayPeriodModifier(currentDate.hour);
|
|
540
|
-
else super.setValueFromDate(currentDate);
|
|
541
|
-
}
|
|
542
|
-
/**
|
|
543
|
-
* Returns the limits used to validate a user typed-in value.
|
|
544
|
-
*
|
|
545
|
-
* Different limits are needed when the user is typing in the hour segment and the clock is in 12-hour format due to the fact that
|
|
546
|
-
* the hour value of 0 should be displayed as 12. Therefore, in the 12h format, the user should be able to type in "12" but not "00",
|
|
547
|
-
* for the 00 time, which is represented by the value of 0 of the hour segment.
|
|
548
|
-
*/
|
|
549
|
-
get inputValidationLimits() {
|
|
550
|
-
const isAmPm = this.maxValue === 11;
|
|
551
|
-
return {
|
|
552
|
-
minValue: isAmPm ? 1 : 0,
|
|
553
|
-
maxValue: isAmPm ? 12 : 23
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
class MillisecondSegment extends EditableSegment {
|
|
558
|
-
constructor(formatted, label) {
|
|
559
|
-
super(SegmentTypes.Millisecond, formatted, label);
|
|
560
|
-
this.minValue = 0;
|
|
561
|
-
this.maxValue = 999;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
class MinuteSegment extends EditableSegment {
|
|
565
|
-
constructor(formatted, label) {
|
|
566
|
-
super(SegmentTypes.Minute, formatted, label);
|
|
567
|
-
this.minValue = 0;
|
|
568
|
-
this.maxValue = 59;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
class SecondSegment extends EditableSegment {
|
|
572
|
-
constructor(formatted, label) {
|
|
573
|
-
super(SegmentTypes.Second, formatted, label);
|
|
574
|
-
this.minValue = 0;
|
|
575
|
-
this.maxValue = 59;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
class SegmentsFactory {
|
|
579
|
-
constructor(dateFormatter) {
|
|
580
|
-
this.dateFormatter = dateFormatter;
|
|
581
|
-
const locale = this.dateFormatter.resolvedOptions().locale;
|
|
582
|
-
this.numberFormatter = new number.NumberFormatter(locale, {
|
|
583
|
-
useGrouping: false
|
|
584
|
-
});
|
|
585
|
-
this.dateTimeFieldDisplayNames = new Intl.DisplayNames([locale], {
|
|
586
|
-
type: "dateTimeField"
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
/**
|
|
590
|
-
* Creates the `DateTimeSegments` needed for the DateTimePicker
|
|
591
|
-
* @param currentDate - The date to create the segments from. This is used to set the limits and values of the segments.
|
|
592
|
-
* @param setValues - If true, the segments will have their values set from the currentDate. If false, the segments will have no values.
|
|
593
|
-
*/
|
|
594
|
-
createSegments(currentDate, setValues = false) {
|
|
595
|
-
const date2 = dateValueToDate(currentDate);
|
|
596
|
-
const createdSegments = this.dateFormatter.formatToParts(date2).map((part) => {
|
|
597
|
-
const type = part.type;
|
|
598
|
-
let formatted = part.value;
|
|
599
|
-
if (type === "year")
|
|
600
|
-
formatted = this.numberFormatter.format(currentDate.year);
|
|
601
|
-
return this.createSegment(type, formatted);
|
|
602
|
-
});
|
|
603
|
-
const segments = new DateTimeSegments(createdSegments);
|
|
604
|
-
const year = segments.year;
|
|
605
|
-
const month = segments.month;
|
|
606
|
-
const day = segments.day;
|
|
607
|
-
year.setLimits(currentDate);
|
|
608
|
-
month.setLimits(currentDate);
|
|
609
|
-
if (setValues) {
|
|
610
|
-
year.setValueFromDate(currentDate);
|
|
611
|
-
month.setValueFromDate(currentDate);
|
|
612
|
-
}
|
|
613
|
-
day.setLimits(currentDate, month.value, year.value);
|
|
614
|
-
if (setValues) day.setValueFromDate(currentDate);
|
|
615
|
-
const hour = segments.hour;
|
|
616
|
-
const minute = segments.minute;
|
|
617
|
-
const second = segments.second;
|
|
618
|
-
const millisecond = segments.millisecond;
|
|
619
|
-
const dayPeriod = segments.dayPeriod;
|
|
620
|
-
if (dayPeriod) dayPeriod.setLocalizedLimits(this.dateFormatter);
|
|
621
|
-
if (!hour) return segments;
|
|
622
|
-
const is12HourFormat = Boolean(dayPeriod);
|
|
623
|
-
hour.setLimits(is12HourFormat);
|
|
624
|
-
if (setValues) {
|
|
625
|
-
hour.setValueFromDate(currentDate, is12HourFormat);
|
|
626
|
-
if (is12HourFormat) {
|
|
627
|
-
const dayPeriodSegment = segments.dayPeriod;
|
|
628
|
-
dayPeriodSegment.setValueFromDate(currentDate);
|
|
629
|
-
}
|
|
630
|
-
if (!minute) return segments;
|
|
631
|
-
minute.setValueFromDate(currentDate);
|
|
632
|
-
if (!second) return segments;
|
|
633
|
-
second.setValueFromDate(currentDate);
|
|
634
|
-
if (!millisecond) return segments;
|
|
635
|
-
millisecond.setValueFromDate(currentDate);
|
|
636
|
-
}
|
|
637
|
-
return segments;
|
|
638
|
-
}
|
|
639
|
-
createSegment(type, formatted) {
|
|
640
|
-
if (type === SegmentTypes.Literal) return new LiteralSegment(formatted);
|
|
641
|
-
const label = this.displayNameOfType(type);
|
|
642
|
-
switch (type) {
|
|
643
|
-
case SegmentTypes.Year: {
|
|
644
|
-
return new YearSegment(formatted, label);
|
|
645
|
-
}
|
|
646
|
-
case SegmentTypes.Month: {
|
|
647
|
-
return new MonthSegment(formatted, label);
|
|
648
|
-
}
|
|
649
|
-
case SegmentTypes.Day: {
|
|
650
|
-
return new DaySegment(formatted, label);
|
|
651
|
-
}
|
|
652
|
-
case SegmentTypes.Hour: {
|
|
653
|
-
return new HourSegment(formatted, label);
|
|
654
|
-
}
|
|
655
|
-
case SegmentTypes.Minute: {
|
|
656
|
-
return new MinuteSegment(formatted, label);
|
|
657
|
-
}
|
|
658
|
-
case SegmentTypes.Second: {
|
|
659
|
-
return new SecondSegment(formatted, label);
|
|
660
|
-
}
|
|
661
|
-
case SegmentTypes.Millisecond: {
|
|
662
|
-
return new MillisecondSegment(formatted, label);
|
|
663
|
-
}
|
|
664
|
-
case SegmentTypes.DayPeriod: {
|
|
665
|
-
return new DayPeriodSegment(formatted, label);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
displayNameOfType(type) {
|
|
670
|
-
const label = type === "fractionalSecond" ? "millisecond" : this.dateTimeFieldDisplayNames.of(type);
|
|
671
|
-
if (!label) return "";
|
|
672
|
-
return label.charAt(0).toUpperCase() + label.slice(1);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
const dateTimePickerStyles = '@charset "UTF-8";:host{font-family:var(--luzmo-font-family);--date-time-picker-border-radius: var( --luzmo-date-time-picker-border-radius, var(--luzmo-border-radius) );--date-time-picker-border-radius-quiet: var( --luzmo-date-time-picker-border-radius-quiet, 0 );--date-time-picker-border-width: var(--luzmo-border-width);--date-time-picker-button-border-color: var( --highcontrast-datepicker-pickerbutton-border-color, var( --luzmo-date-time-picker-pickerbutton-border-color, var(--luzmo-border-color) ) );--date-time-picker-button-border-color-focus: var( --highcontrast-datepicker-pickerbutton-border-color, var( --luzmo-date-time-picker-pickerbutton-border-color-focus, var(--luzmo-primary) ) );--date-time-picker-button-border-color-invalid: var( --highcontrast-datepicker-pickerbutton-border-color, var( --luzmo-date-time-picker-pickerbutton-border-color-invalid, var(--luzmo-negative-color) ) );--date-time-picker-button-width: calc( var(--date-time-picker-edge-to-disclosure-icon) * 2 + var(--date-time-picker-icon-size) );--date-time-picker-quiet-button-offset: var( --luzmo-date-time-picker-quiet-button-offset, var(--date-time-picker-text-to-visual) );--date-time-picker-icon-to-text: var(--date-time-picker-edge-to-text);--date-time-picker-button-width-quiet: calc( var(--date-time-picker-button-width) - var( --date-time-picker-quiet-button-offset ) );--date-time-picker-focus-ring-gap: var( --luzmo-date-time-picker-focus-ring-gap, var(--luzmo-indicator-gap) );--date-time-picker-focus-thickness: var( --luzmo-date-time-picker-focus-thickness, var(--luzmo-indicator-width) );--date-time-picker-focus-animation: var( --luzmo-date-time-picker-focus-animation, var(--luzmo-animation-duration) );--date-time-picker-focus-ring-width: var( --luzmo-date-time-picker-focus-ring-width, var(--luzmo-border-width) );--date-time-picker-focus-ring-color: var( --highcontrast-datepicker-focus-ring-color, var(--luzmo-date-time-picker-focus-ring-color, var(--luzmo-indicator-color)) );--date-time-picker-focus-line-gap: var( --luzmo-date-time-picker-focus-line-gap, var(--luzmo-spacing-2) );--date-time-picker-invalid-quiet-color: var( --luzmo-date-time-picker-invalid-quiet-color, var(--luzmo-negative-color) );--date-time-picker-quiet-border-color-hover: var( --luzmo-date-time-picker-quiet-border-color-hover, var(--luzmo-border-color-hover) );--date-time-picker-border-color-disabled: var( --luzmo-date-time-picker-border-color-disabled, var(--luzmo-border-color-disabled) );--date-time-picker-dash-font-size: var( --luzmo-date-time-picker-dash-font-size, var(--date-time-picker-dash-font-size) );--date-time-picker-dash-color: var( --highcontrast-datepicker-dash-color, var(--luzmo-date-time-picker-dash-color, var(--luzmo-font-color)) );--date-time-picker-range-dash-padding-top: var( --luzmo-date-time-picker-range-dash-padding-top, 0 );--date-time-picker-range-dash-margin-inline-start: var( --luzmo-date-time-picker-range-dash-margin-left, calc(var(--date-time-picker-dash-font-size) * -.5) );--date-time-picker-range-input-width-first: var( --luzmo-date-time-picker-range-input-width-first, calc( var(--date-time-picker-initial-width) - var( --date-time-picker-generic-padding ) * 2 ) );--date-time-picker-input-width-base: calc( var(--date-time-picker-range-input-width-first) + var(--date-time-picker-icon-size) );--date-time-picker-input-width: var( --luzmo-date-time-picker-input-width, calc( var(--date-time-picker-input-width-base) + var(--date-time-picker-initial-height) ) );--date-time-picker-range-input-width-quiet-first: var( --luzmo-date-time-picker-range-input-width-quiet-first, calc( var(--date-time-picker-width-quiet-first) + var(--date-time-picker-width-quiet-second) ) );--date-time-picker-input-width-quiet: var( --luzmo-date-time-picker-input-width-quiet, calc( var(--date-time-picker-range-input-width-quiet-first) + var(--date-time-picker-icon-size) + var(--date-time-picker-initial-height) ) );--date-time-picker-datetime-input-width-first: var( --luzmo-date-time-picker-datetime-input-width-first, calc( var(--date-time-picker-input-width-base) + var(--date-time-picker-datetime-width-first) ) );--date-time-picker-datetime-input-width: var( --luzmo-date-time-picker-datetime-input-width, calc( var(--date-time-picker-datetime-input-width-first) + var(--date-time-picker-icon-size) + var(--date-time-picker-initial-height) ) );--date-time-picker-datetime-quiet-input-width-first: var( --luzmo-date-time-picker-datetime-quiet-input-width-first, calc( var(--date-time-picker-input-width-base) + var(--date-time-picker-input-datetime-width) ) );--date-time-picker-datetime-quiet-input-width: var( --luzmo-date-time-picker-datetime-quiet-input-width, calc( var(--date-time-picker-datetime-quiet-input-width-first) + var(--date-time-picker-icon-size) + var(--date-time-picker-initial-height) ) );--date-time-picker-padding-inline-end: var( --luzmo-date-time-picker-padding-inline, calc( var(--date-time-picker-button-width) + var(--date-time-picker-edge-to-text) - var( --date-time-picker-border-width ) * 2 ) );--date-time-picker-padding-inline-end-quiet: var( --luzmo-date-time-picker-padding-inline-quiet, calc( var(--date-time-picker-button-width) + var(--date-time-picker-edge-to-text) - var( --date-time-picker-quiet-button-offset ) ) );--date-time-picker-padding-inline-end-invalid-quiet: var( --luzmo-date-time-picker-padding-inline-end-invalid-quiet, calc( var(--date-time-picker-button-width-quiet) + var(--date-time-picker-icon-size) + var(--date-time-picker-icon-to-text) ) );min-inline-size:var(--luzmo-date-time-picker-min-width, var(--date-time-picker-min-width));border-radius:var(--date-time-picker-border-radius);flex-flow:row;display:inline-flex;position:relative}:host([disabled]) luzmo-picker-button{cursor:default}:host([disabled]){--luzmo-date-time-picker-dash-color: var( --luzmo-date-time-picker-dash-color-disabled, var(--disabled-content-color) );--luzmo-text-field-border-color-disabled: transparent}:host([invalid]),:host([invalid]) #text-field .icon{--luzmo-text-field-icon-spacing-inline-end-invalid: calc( var(--date-time-picker-button-width) + var(--date-time-picker-invalid-icon-to-button) );--luzmo-text-field-icon-spacing-inline-end-quiet-invalid: calc( var(--date-time-picker-button-width-quiet) + var(--date-time-picker-invalid-icon-to-button-quiet) )}:host(:not([quiet])){inline-size:var(--luzmo-date-time-picker-width, var(--date-time-picker-width))}:host([quiet]){inline-size:var(--luzmo-date-time-picker-width-quiet, var(--date-time-picker-width-quiet, var(--date-time-picker-width)))}:host(:not([quiet],[disabled])){--luzmo-picker-button-border-color: var( --date-time-picker-button-border-color )}:host([focused]),:host([focused]:not([quiet],[disabled])){--luzmo-picker-button-border-color: var( --date-time-picker-button-border-color-focus )}:host([invalid]:not([quiet],[disabled])){--luzmo-picker-button-border-color: var( --date-time-picker-button-border-color-invalid )}.input{inline-size:100%;flex:1;padding-inline-end:var(--date-time-picker-padding-inline-end);border-color:var(--luzmo-date-time-picker-border-color, var(--datepicker-border-color))}:host .input:read-only{border-color:var(--luzmo-date-time-picker-border-color, var(--datepicker-border-color))}.input.luzmo-DatePicker-startField{border-inline-end:0;border-start-end-radius:0;border-end-end-radius:0;padding-inline-end:var(--luzmo-date-time-picker-generic-padding, var(--date-time-picker-generic-padding))}.input.luzmo-DatePicker-endField{border-inline-start:0;border-start-start-radius:0;border-end-start-radius:0;padding-inline-start:var(--luzmo-date-time-picker-generic-padding, var(--date-time-picker-generic-padding))}luzmo-picker-button{cursor:pointer;position:absolute;inset-inline-end:0}.luzmo-DatePicker-rangeDash{color:var(--date-time-picker-dash-color);line-height:var(--luzmo-date-time-picker-dash-line-height, var(--date-time-picker-dash-line-height));flex:initial;inline-size:0;z-index:1;padding-block-start:var(--date-time-picker-range-dash-padding-top)}.luzmo-DatePicker-rangeDash:before{content:"–";margin-block:0;margin-inline:var(--date-time-picker-range-dash-margin-inline-start);text-align:center;vertical-align:middle;inline-size:var(--date-time-picker-dash-font-size);display:inline-block;overflow:hidden}:host([quiet]){--luzmo-date-time-picker-border-radius: var( --date-time-picker-border-radius-quiet );--luzmo-date-time-picker-padding-inline: var( --date-time-picker-padding-inline-end-quiet );--luzmo-picker-button-border-color-disabled: var( --date-time-picker-border-color-disabled );--luzmo-picker-button-background-color-hover-disabled: var( --date-time-picker-border-color-disabled )}:host([quiet][disabled]){--luzmo-text-field-border-color-disabled: var( --date-time-picker-border-color-disabled )}:host([quiet][invalid]) .input:not(.luzmo-DatePicker-startField){padding-inline-end:var(--date-time-picker-padding-inline-end-invalid-quiet)}@media (hover: hover){:host(:hover):not([focused],[disabled],[invalid]){--luzmo-picker-button-border-color: var( --date-time-picker-quiet-border-color-hover )}}:host([quiet][invalid]){--luzmo-picker-button-border-color: var( --date-time-picker-invalid-quiet-color )}:host([quiet]) luzmo-picker-button{inline-size:auto;inset-inline-end:calc(var(--date-time-picker-quiet-button-offset) * -1)}:host([quiet]) luzmo-picker-button:not(.is-open){--luzmo-picker-button-border-color-disabled: transparent}:host([quiet]) luzmo-picker-button:not(:disabled,.is-open){--luzmo-picker-button-background-color: transparent}.luzmo-DatePicker--range{--luzmo-date-time-picker-border-radius: var(--date-time-picker-border-radius)}.luzmo-DatePicker--range:after{pointer-events:none;content:"";margin:calc(var(--date-time-picker-focus-ring-gap) * -1);border-radius:calc(var(--date-time-picker-border-radius) + var(--date-time-picker-focus-ring-gap));transition:box-shadow var(--date-time-picker-focus-animation) ease-in-out,border-color var(--date-time-picker-focus-animation) ease-in-out;border-color:#0000;position:absolute;top:0;right:0;bottom:0;left:0}:host([focused]) .luzmo-DatePicker--range:not(.luzmo-DatePicker--quiet):after{box-shadow:0 0 0 var(--date-time-picker-focus-ring-width) var(--date-time-picker-focus-ring-color)}:host([focused]) .luzmo-DatePicker--range:not(.luzmo-DatePicker--quiet) #text-field:after{display:none}:host([quiet]) .luzmo-DatePicker--range{--luzmo-date-time-picker-border-radius: var( --date-time-picker-border-radius-quiet )}:host([quiet][focused]) .luzmo-DatePicker--range:after{box-shadow:none;border-block-end:var(--date-time-picker-focus-thickness) solid var(--date-time-picker-focus-ring-color);border-radius:0;margin:0;inset-block-end:calc(var(--date-time-picker-focus-line-gap) * -1)}:host([quiet]) .luzmo-DatePicker--range #text-field{min-inline-size:0;inline-size:var(--date-time-picker-input-width-quiet)}:host([quiet]) .luzmo-DatePicker--range #text-field:first-of-type{inline-size:var(--date-time-picker-range-input-width-quiet-first)}.luzmo-DatePicker--range.luzmo-DatePicker--datetimeRange #text-field{inline-size:var(--date-time-picker-datetime-input-width);min-inline-size:0}.luzmo-DatePicker--range.luzmo-DatePicker--datetimeRange #text-field:first-of-type{inline-size:var(--date-time-picker-datetime-input-width-first)}:host([quiet]) .luzmo-DatePicker--range.luzmo-DatePicker--datetimeRange #text-field{inline-size:var(--date-time-picker-datetime-quiet-input-width)}:host([quiet]) .luzmo-DatePicker--range.luzmo-DatePicker--datetimeRange #text-field:first-of-type{inline-size:var(--date-time-picker-datetime-quiet-input-width-first)}.luzmo-DatePicker--range #text-field{flex:initial;min-inline-size:0;inline-size:var(--date-time-picker-input-width)}.luzmo-DatePicker--range #text-field:first-of-type{inline-size:var(--date-time-picker-range-input-width-first)}@media (forced-colors: active){:host{--highcontrast-datepicker-dash-color: CanvasText;--highcontrast-datepicker-focus-ring-color: Highlight;--highcontrast-datepicker-pickerbutton-border-color: Highlight}:host([disabled]){--highcontrast-datepicker-dash-color: GrayText}:host([quiet][invalid]){--highcontrast-datepicker-pickerbutton-border-color: Highlight}}:host{--date-time-picker-width: auto;--date-time-picker-initial-height: var(--system-date-picker-initial-height);--date-time-picker-font-color-default: var(--luzmo-font-color);--datepicker-border-color: var(--luzmo-border-color);--date-time-picker-button-indicator-color: var(--luzmo-indicator-color);--text-field-focus-indicator-color: var(--luzmo-background-color-highlight);--date-time-picker-initial-width: 120px;--date-time-picker-min-width: 160px;--date-time-picker-calendar-padding: var(--luzmo-spacing-4);--date-time-picker-icon-size: 18px;--date-time-picker-dash-font-size: var(--luzmo-font-size);--date-time-picker-text-to-visual: var(--luzmo-spacing-3);--date-time-picker-edge-to-disclosure-icon: var(--luzmo-spacing-3);--date-time-picker-edge-to-text: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) );--date-time-picker-icon-to-text: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) );--date-time-picker-invalid-icon-to-button: var(--luzmo-spacing-3);--date-time-picker-generic-padding: var(--luzmo-spacing-4)}:host([size=s]){--date-time-picker-min-width: 140px;--date-time-picker-calendar-padding: var(--luzmo-spacing-3);--date-time-picker-icon-size: 16px;--date-time-picker-dash-font-size: var(--luzmo-font-size-s);--date-time-picker-text-to-visual: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) );--date-time-picker-edge-to-disclosure-icon: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) );--date-time-picker-edge-to-text: var(--luzmo-spacing-3);--date-time-picker-invalid-icon-to-button: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) );--date-time-picker-icon-to-text: var(--luzmo-spacing-3)}:host([invalid][size=s]){--text-field-icon-spacing-block-invalid: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) )}:host([size=m]){--date-time-picker-min-width: 160px;--date-time-picker-calendar-padding: var(--luzmo-spacing-4);--date-time-picker-icon-size: 18px;--date-time-picker-dash-font-size: var(--luzmo-font-size-m);--date-time-picker-text-to-visual: var(--luzmo-spacing-3);--date-time-picker-edge-to-disclosure-icon: var(--luzmo-spacing-3);--date-time-picker-edge-to-text: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) );--date-time-picker-invalid-icon-to-button: var(--luzmo-spacing-3);--date-time-picker-icon-to-text: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) )}:host([size=l]){--date-time-picker-min-width: 180px;--date-time-picker-calendar-padding: var(--luzmo-spacing-5);--date-time-picker-icon-size: 20px;--date-time-picker-dash-font-size: var(--luzmo-font-size-l);--date-time-picker-text-to-visual: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) );--date-time-picker-edge-to-disclosure-icon: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) );--date-time-picker-edge-to-text: var(--luzmo-spacing-4);--date-time-picker-invalid-icon-to-button: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) );--date-time-picker-icon-to-text: var(--luzmo-spacing-4)}:host([size=xl]){--date-time-picker-min-width: 200px;--date-time-picker-calendar-padding: calc( var(--luzmo-spacing-5) + var(--luzmo-spacing-1) );--date-time-picker-icon-size: 22px;--date-time-picker-dash-font-size: var(--luzmo-font-size-xl);--date-time-picker-text-to-visual: var(--luzmo-spacing-4);--date-time-picker-edge-to-disclosure-icon: var(--luzmo-spacing-4);--date-time-picker-edge-to-text: calc( var(--luzmo-spacing-4) + var(--luzmo-spacing-1) );--date-time-picker-invalid-icon-to-button: var(--luzmo-spacing-4);--date-time-picker-icon-to-text: calc( var(--luzmo-spacing-4) + var(--luzmo-spacing-1) )}:host{--status-icon-size: var( --luzmo-text-field-icon-size-invalid, var(--text-field-icon-size-invalid) );--picker-button-size: var( --luzmo-text-field-height, var(--text-field-height) );--input-spacing: var( --luzmo-text-field-spacing-inline, var(--text-field-spacing-inline) );--input-border-width: var( --luzmo-text-field-border-width, var(--luzmo-border-width) );--text-to-icon: var( --luzmo-text-field-icon-spacing-inline-start-invalid, var(--text-field-icon-spacing-inline-start-invalid) );--date-time-picker-input-width: var(--date-time-picker-width);flex-wrap:wrap}:host #text-field{display:inline-block}:host #text-field .input,:host([quiet]) #text-field .input,:host([valid]) #text-field .input,:host([invalid]) #text-field .input{inline-size:100%}:host #text-field .input,:host([quiet]) #text-field .input{padding-inline-end:calc(var(--picker-button-size) + var(--input-spacing) - var(--input-border-width))}:host([valid]) #text-field .input,:host([invalid]) #text-field .input{inline-size:100%;padding-inline-end:calc(var(--status-icon-size) + var(--picker-button-size) + var(--input-spacing) - var(--input-border-width) + var(--text-to-icon))}@media (hover: hover){:host([invalid]) #text-field:hover .input,:host([focused][invalid]) .input:hover,:host([focused][invalid]) #text-field:hover .input{border-color:var(--highcontrast-text-field-border-color-invalid-default, var(--luzmo-text-field-border-color-invalid-default, var(--luzmo-negative-color-hover)))}}luzmo-picker-button:focus-visible{outline:none}luzmo-popover{overflow-y:auto}luzmo-popover .popover-content{padding:var(--luzmo-date-time-picker-calendar-padding, var(--date-time-picker-calendar-padding))}.input-content{display:flex;align-items:center;height:100%;overflow:auto hidden;scrollbar-width:none;line-height:normal}.input-content::-webkit-scrollbar{display:none;width:0;height:0}.literal-segment,.editable-segment{display:inline-block;color:var(--luzmo-date-time-picker-font-color-default, var(--date-time-picker-font-color-default))}.editable-segment{padding:0 .15em;font-variant-numeric:tabular-nums;text-align:end;white-space:nowrap;caret-color:transparent;outline:none}[dir=ltr] .editable-segment{text-align:start}.literal-segment{white-space:pre;user-select:none;-webkit-user-select:none}.is-placeholder,.is-placeholder+.literal-segment{color:var(--luzmo-font-color-disabled)}.editable-segment:focus-visible{color:var(--white);background-color:var(--highcontrast-text-field-focus-indicator-color, var(--luzmo-text-field-focus-indicator-color, var(--text-field-focus-indicator-color)))}.editable-segment::selection{background-color:transparent}';
|
|
676
|
-
var __defProp = Object.defineProperty;
|
|
677
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
678
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
679
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
680
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
681
|
-
if (decorator = decorators[i])
|
|
682
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
683
|
-
if (kind && result) __defProp(target, key, result);
|
|
684
|
-
return result;
|
|
685
|
-
};
|
|
686
|
-
class LuzmoDateTimePicker extends manageHelpText.ManageHelpText(
|
|
687
|
-
sizedMixin.SizedMixin(focusable.Focusable, {
|
|
688
|
-
validSizes: Object.values(sizedMixin.ElementSizes)
|
|
689
|
-
})
|
|
690
|
-
) {
|
|
691
|
-
constructor() {
|
|
692
|
-
super();
|
|
693
|
-
this._precision = Precisions.Minute;
|
|
694
|
-
this.isUserSetPrecision = false;
|
|
695
|
-
this.invalid = false;
|
|
696
|
-
this.readonly = false;
|
|
697
|
-
this.quiet = false;
|
|
698
|
-
this.placement = "bottom";
|
|
699
|
-
this.language = "en";
|
|
700
|
-
this.labels = {
|
|
701
|
-
previous: "Previous",
|
|
702
|
-
next: "Next",
|
|
703
|
-
today: "Today",
|
|
704
|
-
selected: "Selected",
|
|
705
|
-
empty: "Empty",
|
|
706
|
-
calendar: "Calendar"
|
|
707
|
-
};
|
|
708
|
-
this.focused = false;
|
|
709
|
-
this.segments = new DateTimeSegments([]);
|
|
710
|
-
this.isCalendarOpen = false;
|
|
711
|
-
this._timeZone = this.timeZone ?? date.getLocalTimeZone();
|
|
712
|
-
this.cachedLocalTime = date.now(this._timeZone);
|
|
713
|
-
this.setNumberParser();
|
|
714
|
-
this.setDateFormatter();
|
|
715
|
-
this.setAriaDateFormatter();
|
|
716
|
-
this.addEventListener(
|
|
717
|
-
"focusin",
|
|
718
|
-
() => this.previousCommitedValue = this._value
|
|
719
|
-
);
|
|
720
|
-
this.addEventListener("focusout", () => this.commitValue());
|
|
721
|
-
}
|
|
722
|
-
/**
|
|
723
|
-
* The styles of the calendar
|
|
724
|
-
* @internal
|
|
725
|
-
*/
|
|
726
|
-
static get styles() {
|
|
727
|
-
return [lit.unsafeCSS(dateTimePickerStyles), lit.unsafeCSS(textField_module.textFieldStyles)];
|
|
728
|
-
}
|
|
729
|
-
get precision() {
|
|
730
|
-
return this._precision;
|
|
731
|
-
}
|
|
732
|
-
set precision(value) {
|
|
733
|
-
this.isUserSetPrecision = true;
|
|
734
|
-
const oldValue = this._precision;
|
|
735
|
-
if (value === oldValue) return;
|
|
736
|
-
this._precision = value;
|
|
737
|
-
this.requestUpdate("precision", oldValue);
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* The language used to format the dates and weekdays.
|
|
741
|
-
* @internal
|
|
742
|
-
*/
|
|
743
|
-
get _language() {
|
|
744
|
-
try {
|
|
745
|
-
if (this.language) {
|
|
746
|
-
const locale = new Intl.Locale(this.language);
|
|
747
|
-
return locale.language;
|
|
748
|
-
}
|
|
749
|
-
return "en";
|
|
750
|
-
} catch {
|
|
751
|
-
return "en";
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
/**
|
|
755
|
-
* The focus element of the component
|
|
756
|
-
* @internal
|
|
757
|
-
*/
|
|
758
|
-
get focusElement() {
|
|
759
|
-
return this.firstEditableSegment;
|
|
760
|
-
}
|
|
761
|
-
/**
|
|
762
|
-
* The current date of the component
|
|
763
|
-
* @internal
|
|
764
|
-
*/
|
|
765
|
-
get currentDate() {
|
|
766
|
-
if (this._value) return date.toZoned(this._value, this._timeZone);
|
|
767
|
-
return this.cachedLocalTime;
|
|
768
|
-
}
|
|
769
|
-
/**
|
|
770
|
-
* @return Whether the component's precision includes time segments (hour, minute, second, millisecond)
|
|
771
|
-
* @internal
|
|
772
|
-
*/
|
|
773
|
-
get includesTime() {
|
|
774
|
-
const timePrecisions = [
|
|
775
|
-
Precisions.Hour,
|
|
776
|
-
Precisions.Minute,
|
|
777
|
-
Precisions.Second,
|
|
778
|
-
Precisions.Millisecond
|
|
779
|
-
];
|
|
780
|
-
return timePrecisions.includes(this.precision);
|
|
781
|
-
}
|
|
782
|
-
/**
|
|
783
|
-
* Resets the component's value and segments
|
|
784
|
-
*/
|
|
785
|
-
clear() {
|
|
786
|
-
this._value = void 0;
|
|
787
|
-
this.setSegments();
|
|
788
|
-
}
|
|
789
|
-
willUpdate(changedProperties) {
|
|
790
|
-
const changesValue = changedProperties.has("value");
|
|
791
|
-
const changesTimeZone = changedProperties.has("timeZone");
|
|
792
|
-
const changesMin = changedProperties.has("min");
|
|
793
|
-
const changesMax = changedProperties.has("max");
|
|
794
|
-
const changesLocale = changedProperties.has("language");
|
|
795
|
-
const changesDateFormat = changedProperties.has("dateFormat");
|
|
796
|
-
const changesDateSeparator = changedProperties.has("dateSeparator");
|
|
797
|
-
const changesPrecision = changedProperties.has("precision");
|
|
798
|
-
const changesSegments = changedProperties.has("segments");
|
|
799
|
-
const changesDisabled = changedProperties.has("disabled");
|
|
800
|
-
if (changesLocale) this.setNumberParser();
|
|
801
|
-
if (changesLocale || changesPrecision) {
|
|
802
|
-
this.setDateFormatter();
|
|
803
|
-
this.setAriaDateFormatter();
|
|
804
|
-
}
|
|
805
|
-
if (changesValue || changesMin || changesMax || changesTimeZone) {
|
|
806
|
-
this._value = this.value ? date.parseAbsolute(new Date(this.value).toISOString(), "UTC") : void 0;
|
|
807
|
-
this._min = this.min ? date.parseAbsolute(new Date(this.min).toISOString(), "UTC") : void 0;
|
|
808
|
-
this._max = this.max ? date.parseAbsolute(new Date(this.max).toISOString(), "UTC") : void 0;
|
|
809
|
-
const mostSpecificDateValue = this.mostSpecificDateValue;
|
|
810
|
-
if (mostSpecificDateValue) {
|
|
811
|
-
this.convertDatePropsToMatch(mostSpecificDateValue);
|
|
812
|
-
this.checkDatePropsCompliance(changesMin || changesMax);
|
|
813
|
-
this.updateDateProps();
|
|
814
|
-
this.updateDefaultPrecision();
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
if (changesValue || changesLocale || changesPrecision || changesDateFormat || changesTimeZone || changesDateSeparator)
|
|
818
|
-
this.setSegments();
|
|
819
|
-
if (changesSegments) this.setValueFromSegments();
|
|
820
|
-
if (changesDisabled && this.isCalendarOpen) this.isCalendarOpen = false;
|
|
821
|
-
const selectedDateLabel = this._value && this.labels.selected + ": " + this.ariaDateFormatter.format(dateValueToDate(this._value));
|
|
822
|
-
this.setAttribute("aria-label", selectedDateLabel ?? this.labels.empty);
|
|
823
|
-
}
|
|
824
|
-
/**
|
|
825
|
-
* Computes the component's most precise date property (min, max or value) or undefined if none is defined.
|
|
826
|
-
* The order of precedence is: ZonedDateTime, CalendarDateTime, CalendarDate.
|
|
827
|
-
* @internal
|
|
828
|
-
*/
|
|
829
|
-
get mostSpecificDateValue() {
|
|
830
|
-
const dateValuesDefined = [this._value, this._min, this._max].filter(
|
|
831
|
-
(date2) => date2 !== void 0
|
|
832
|
-
);
|
|
833
|
-
if (dateValuesDefined.length === 0) return;
|
|
834
|
-
const zonedDateTimes = dateValuesDefined.filter((d) => isZonedDateTime(d));
|
|
835
|
-
if (zonedDateTimes.length > 0) return zonedDateTimes[0];
|
|
836
|
-
const dateTimes = dateValuesDefined.filter((d) => isCalendarDateTime(d));
|
|
837
|
-
if (dateTimes.length > 0) return dateTimes[0];
|
|
838
|
-
const mostSpecificDate = dateValuesDefined.find((d) => isCalendarDate(d));
|
|
839
|
-
return mostSpecificDate;
|
|
840
|
-
}
|
|
841
|
-
/**
|
|
842
|
-
* Converts the DateTimePicker's date properties (min, max and value) to match the provided date's type.
|
|
843
|
-
*
|
|
844
|
-
* @param dateValue - The date value to be used as a reference for the conversion
|
|
845
|
-
*/
|
|
846
|
-
convertDatePropsToMatch(dateValue) {
|
|
847
|
-
if (isZonedDateTime(dateValue)) {
|
|
848
|
-
this._timeZone = this.timeZone ?? dateValue.timeZone;
|
|
849
|
-
this._value = this._value && date.toZoned(this._value, this._timeZone);
|
|
850
|
-
this._min = this._min && date.toZoned(this._min, this._timeZone);
|
|
851
|
-
this._max = this._max && date.toZoned(this._max, this._timeZone);
|
|
852
|
-
return;
|
|
853
|
-
}
|
|
854
|
-
this._timeZone = this.timeZone ?? date.getLocalTimeZone();
|
|
855
|
-
if (isCalendarDateTime(dateValue)) {
|
|
856
|
-
this._value = this._value && date.toCalendarDateTime(this._value);
|
|
857
|
-
this._min = this._min && date.toCalendarDateTime(this._min);
|
|
858
|
-
this._max = this._max && date.toCalendarDateTime(this._max);
|
|
859
|
-
return;
|
|
860
|
-
}
|
|
861
|
-
this._value = this._value && date.toCalendarDate(this._value);
|
|
862
|
-
this._min = this._min && date.toCalendarDate(this._min);
|
|
863
|
-
this._max = this._max && date.toCalendarDate(this._max);
|
|
864
|
-
}
|
|
865
|
-
/**
|
|
866
|
-
* Validates the component's date properties (min, max and value) compliance with one another.
|
|
867
|
-
* If the [min, max] constraint interval is invalid, both properties are reset.
|
|
868
|
-
* If the value is not within the [min, max] (valid) interval, it is reset.
|
|
869
|
-
*
|
|
870
|
-
* @param checkInterval - Whether to check the [min, max] interval
|
|
871
|
-
*/
|
|
872
|
-
checkDatePropsCompliance(checkInterval) {
|
|
873
|
-
if (checkInterval && this._min && this._max) {
|
|
874
|
-
const isValidInterval = this._min.compare(this._max) < 0;
|
|
875
|
-
if (!isValidInterval) {
|
|
876
|
-
console.warn(
|
|
877
|
-
this,
|
|
878
|
-
`<${this.localName}> expects the 'min' to be less than 'max'. Please ensure that 'min' property's date is earlier than 'max' property's date.`
|
|
879
|
-
);
|
|
880
|
-
this._min = void 0;
|
|
881
|
-
this._max = void 0;
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
if (this.isNonCompliantValue()) {
|
|
885
|
-
console.warn(
|
|
886
|
-
this,
|
|
887
|
-
`<${this.localName}> expects the preselected value to comply with the min and max constraints. Please ensure that 'value' property's date is in between the dates for the 'min' and 'max' properties.`
|
|
888
|
-
);
|
|
889
|
-
this._value = void 0;
|
|
890
|
-
}
|
|
891
|
-
if (!this._min && !this._max && !this._value)
|
|
892
|
-
this._timeZone = date.getLocalTimeZone();
|
|
893
|
-
}
|
|
894
|
-
isNonCompliantValue() {
|
|
895
|
-
if (this._value === void 0) return false;
|
|
896
|
-
return Boolean(
|
|
897
|
-
this._min && this._value.compare(this._min) < 0 || this._max && this._value.compare(this._max) > 0
|
|
898
|
-
);
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* Update the component's date properties' types to include the provided precision.
|
|
902
|
-
*/
|
|
903
|
-
updateDateProps() {
|
|
904
|
-
const mostSpecificDateValue = this.mostSpecificDateValue;
|
|
905
|
-
if (!mostSpecificDateValue || !this.isUserSetPrecision) return;
|
|
906
|
-
const shouldConvertToDateTime = this.includesTime && isCalendarDate(mostSpecificDateValue);
|
|
907
|
-
if (shouldConvertToDateTime)
|
|
908
|
-
this.convertDatePropsToMatch(date.toCalendarDateTime(mostSpecificDateValue));
|
|
909
|
-
}
|
|
910
|
-
/**
|
|
911
|
-
* Changes the component's default precision according to the most specific date property (min, max or value).
|
|
912
|
-
*/
|
|
913
|
-
updateDefaultPrecision() {
|
|
914
|
-
if (this.isUserSetPrecision) return;
|
|
915
|
-
const mostSpecificDateValue = this.mostSpecificDateValue;
|
|
916
|
-
if (!mostSpecificDateValue) return;
|
|
917
|
-
this._precision = isCalendarDate(mostSpecificDateValue) ? Precisions.Day : Precisions.Minute;
|
|
918
|
-
}
|
|
919
|
-
render() {
|
|
920
|
-
return lit.html`
|
|
18
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../index-hqVbNKYy.cjs"),R=require("../NumberParser-Dik4a0h-.cjs"),u=require("../base-Cy0MQrPT.cjs"),P=require("../state-vf0PJN3_.cjs"),A=require("../query-BL-TJj7K.cjs"),j=require("../class-map-D-Y-hsN5.cjs"),S=require("../if-defined-DaXWqfzc.cjs"),W=require("../style-map-DuMd5xlY.cjs"),L=require("../when-CDZyJPvd.cjs"),G=require("../focusable-B_KwfEec.cjs"),I=require("../sized-mixin-WPHH0a_D.cjs"),O=require("../luzmo-icons-CtA-TJPd.cjs");require("../icon/index.cjs");require("../overlay/index.cjs");require("../picker-button/index.cjs");require("../popover/index.cjs");const K=require("../manage-help-text-DNqdEkTA.cjs"),B=require("../NumberFormatter-DewVDY5w.cjs"),X=require("../text-field.module-DXhFA9G-.cjs"),o={Year:"year",Month:"month",Day:"day",Hour:"hour",Minute:"minute",Second:"second",Millisecond:"fractionalSecond",DayPeriod:"dayPeriod",Literal:"literal"},J={[o.Year]:"––––",[o.Month]:"––",[o.Day]:"––",[o.Hour]:"––",[o.Minute]:"––",[o.Second]:"––",[o.Millisecond]:"–––",[o.DayPeriod]:"––"},v={Day:"day",Hour:"hour",Minute:"minute",Second:"second",Millisecond:"millisecond"},V=0,D=12,H=2e3,Q=31;function x(n){return typeof n=="number"}function _(n){return n instanceof c.$35ea8db9cb2ccb90$export$d3b7288e7994edea}function C(n){return n instanceof c.$35ea8db9cb2ccb90$export$ca871e8dbb80966f}function F(n){return n instanceof c.$35ea8db9cb2ccb90$export$99faa760c7908e4f}function N(n,e){return n=n%D+e}function Z(n){return n>=D?D:V}function E(n,e){return n.length===e.length&&n.every((t,i)=>t===e[i])}function U(n){return F(n)?new Date(n.year,n.month-1,n.day):new Date(n.year,n.month-1,n.day,n.hour,n.minute,n.second,n.millisecond)}class ${constructor(e,t,i){this.type=e,this.formatted=t,this.label=i,this.placeholder=J[e]}increment(e){this.value===void 0?this.value=this.minValue:(this.value=this.value+1,this.value>this.maxValue&&(this.value=this.minValue))}decrement(e){this.value===void 0?this.value=this.maxValue:(this.value=this.value-1,this.value<this.minValue&&(this.value=this.maxValue))}setValueFromDate(e){this.type==="fractionalSecond"?this.value=e.millisecond:this.type!==o.DayPeriod&&(this.value=e[this.type])}clear(){this.value=void 0}handleInput(e,t){const i=t.parse(e);if(Number.isNaN(i))return;const a=t.parse(`${this.value??""}${i}`);if(this.isInputValueCompliant(a)){this.value=a;return}this.isInputValueCompliant(i)&&(this.value=i)}isInputValueCompliant(e){const{minValue:t,maxValue:i}=this.inputValidationLimits;return e>=t&&e<=i}get inputValidationLimits(){return{minValue:this.minValue,maxValue:this.maxValue}}updateValueToLimits(){this.value!==void 0&&(this.value<this.minValue&&(this.value=this.minValue),this.value>this.maxValue&&(this.value=this.maxValue))}}class Y extends ${constructor(e,t){super(o.Year,e,t),this.minValue=1,this.maxValue=9999}setLimits(e){this.minValue=1,this.maxValue=e.calendar.getYearsInEra(e),this.updateValueToLimits()}increment(e){this.value===void 0?this.value=e.year:super.increment()}decrement(e){this.value===void 0?this.value=e.year:super.decrement()}clear(){if(this.value===void 0)return;const e=Math.floor(this.value/10);this.value=e>0?e:void 0}}class M{constructor(e){this.segments=e}get all(){return this.segments}get editableValues(){return this.all.filter(e=>e instanceof $).map(e=>e.value)}get year(){const e=this.getByType(o.Year);if(e&&e instanceof Y)return e}get month(){const e=this.getByType(o.Month);if(e)return e}get day(){const e=this.getByType(o.Day);if(e)return e}get hour(){const e=this.getByType(o.Hour);if(e)return e}get minute(){const e=this.getByType(o.Minute);if(e)return e}get second(){const e=this.getByType(o.Second);if(e)return e}get millisecond(){const e=this.getByType(o.Millisecond);if(e)return e}get dayPeriod(){const e=this.getByType(o.DayPeriod);if(e)return e}getByType(e){return this.segments.find(t=>t.type===e)}getFormattedDate(e=v.Day){var d,g,b,k,f,z,y;const t=(d=this.year)==null?void 0:d.value,i=(g=this.month)==null?void 0:g.value,a=(b=this.day)==null?void 0:b.value;if(!x(t)||!x(i)||!x(a))return;if(e===v.Day)return new c.$35ea8db9cb2ccb90$export$99faa760c7908e4f(t,i,a);let r=(k=this.hour)==null?void 0:k.value;if(!x(r))return;if(this.dayPeriod){const w=this.dayPeriod.value;if(!x(w))return;r=N(r,w)}if(e===v.Hour)return new c.$35ea8db9cb2ccb90$export$ca871e8dbb80966f(t,i,a,r);const s=(f=this.minute)==null?void 0:f.value;if(!x(s))return;if(e===v.Minute)return new c.$35ea8db9cb2ccb90$export$ca871e8dbb80966f(t,i,a,r,s);const l=(z=this.second)==null?void 0:z.value;if(!x(l))return;if(e===v.Second)return new c.$35ea8db9cb2ccb90$export$ca871e8dbb80966f(t,i,a,r,s,l);const h=(y=this.millisecond)==null?void 0:y.value;if(x(h))return new c.$35ea8db9cb2ccb90$export$ca871e8dbb80966f(t,i,a,r,s,l,h)}}class ee{constructor(e,t){this.dateFormatter=e,this.currentDate=t,this.numberFormatter=new B.$488c6ddbf4ef74c2$export$cc77c4ff7e8673c5(this.dateFormatter.resolvedOptions().locale,{useGrouping:!1})}format(e){if(!e.year||!e.month||!e.day)return e;const t=this.getDateInfoWithDefaults(e);return t&&(this.setSegmentsFormatted(e,t),this.padSegmentsFormatted(e)),e}setSegmentsFormatted(e,t){var f;e=new M(e.all);const{year:i,month:a,day:r,hour:s,minute:l,second:h,millisecond:d}=t,g=new Date(i,a-1,r,s,l,h,d);if(!e.year)return;e.year.formatted=this.numberFormatter.format(i);const b=[o.Month,o.Day,o.Hour,o.Minute,o.Second,o.DayPeriod],k=this.dateFormatter.formatToParts(g);for(const z of b){const y=e[z];if(!y)continue;const w=(f=k.find(q=>q.type===z))==null?void 0:f.value;w&&(y.formatted=w)}}padSegmentsFormatted(e){if(!e.hour)return;const t=[o.Month,o.Day,o.Hour,o.Minute,o.Second];for(const i of t){const a=e[i];a&&(a.formatted=a.formatted.padStart(2,this.numberFormatter.format(0)))}}getDateInfoWithDefaults(e){var g,b,k,f,z;if(!e.year||!e.month||!e.day)return;const t=e.day.value??c.$14e0f24ef4ac5c92$export$b2f4953d301981d5(this.currentDate),i=e.month.value??c.$14e0f24ef4ac5c92$export$5412ac11713b72ad(this.currentDate),a=e.year.value??H,r=(g=e.dayPeriod)==null?void 0:g.value;let s=(b=e.hour)==null?void 0:b.value;x(s)?x(r)&&(s=N(s,r)):s=x(r)?r:this.currentDate.hour;const l=((k=e.minute)==null?void 0:k.value)??this.currentDate.minute,h=((f=e.second)==null?void 0:f.value)??this.currentDate.second,d=((z=e.millisecond)==null?void 0:z.value)??this.currentDate.millisecond;return{year:a,month:i,day:t,hour:s,minute:l,second:h,millisecond:d}}}class T{constructor(e){const{dateFormatter:t,segments:i,currentDate:a}=e;this.segments=new M(i.all),this.dateFormatter=t,this.currentDate=a}modify(e){const t=this.segments.getByType(e);if(!t)return this.segments;this.modifySegment(t),this.updateSegmentsLimits(e);const i=new ee(this.dateFormatter,this.currentDate);return this.segments=i.format(this.segments),this.segments}updateSegmentsLimits(e){const t=e===o.Year,i=e===o.Month,a=this.segments.year,r=this.segments.month,s=this.segments.day;t&&(r==null||r.setLimits(this.currentDate),s==null||s.setLimits(this.currentDate,r==null?void 0:r.value,a==null?void 0:a.value)),i&&(s==null||s.setLimits(this.currentDate,r==null?void 0:r.value,a==null?void 0:a.value))}}class te extends T{modifySegment(e){e.clear()}}class ie extends T{modifySegment(e){e.decrement(this.currentDate)}}class ae extends T{modifySegment(e){e.increment(this.currentDate)}}class re extends T{constructor(e){const{dateFormatter:t,segments:i,currentDate:a}=e;super({dateFormatter:t,segments:i,currentDate:a}),this.eventData=e.eventData,this.numberParser=e.numberParser}modifySegment(e){this.eventData!==null&&e.handleInput(this.eventData,this.numberParser)}}class oe extends ${constructor(e,t){super(o.Day,e,t),this.minValue=1,this.maxValue=31}setLimits(e,t,i){if(!x(t)){this.minValue=1,this.maxValue=Q;return}x(i)||(i=H);const a=new c.$35ea8db9cb2ccb90$export$99faa760c7908e4f(i,t,1);this.maxValue=e.calendar.getDaysInMonth(a),this.minValue=c.$14e0f24ef4ac5c92$export$b2f4953d301981d5(a),this.updateValueToLimits()}}class ne extends ${constructor(e,t){super(o.Month,e,t),this.minValue=1,this.maxValue=12}setLimits(e){this.minValue=c.$14e0f24ef4ac5c92$export$5412ac11713b72ad(e),this.maxValue=e.calendar.getMonthsInYear(e),this.updateValueToLimits()}}class se{constructor(e){this.formatted=e,this.type=o.Literal}}class ce extends ${constructor(e,t){super(o.DayPeriod,e,t),this.minValue=V,this.maxValue=D,this.localizedMinValue="AM",this.localizedMaxValue="PM"}toggleAmPm(){this.value=this.value===V?D:V}increment(){this.value===void 0?this.value=this.minValue:this.toggleAmPm()}decrement(){this.value===void 0?this.value=this.maxValue:this.toggleAmPm()}setValueFromDate(e){this.value=Z(e.hour)}handleInput(e){const t=e.toLowerCase(),i=this.localizedMinValue.toLowerCase().includes(t),a=this.localizedMaxValue.toLowerCase().includes(t);i&&a||(i&&(this.value=V),a&&(this.value=D))}setLocalizedLimits(e){const t=new Date(0,0,0,this.minValue,0),i=new Date(0,0,0,this.maxValue,0),[a,r]=[t,i].map(this.getDayPeriodFromDate.bind(this,e));a&&(this.localizedMinValue=a),r&&(this.localizedMaxValue=r)}getDayPeriodFromDate(e,t){var i;return(i=e.formatToParts(t).find(a=>a.type===this.type))==null?void 0:i.value}}class le extends ${constructor(e,t){super(o.Hour,e,t),this.minValue=0,this.maxValue=23}setLimits(e){this.minValue=0,this.maxValue=23,e&&(this.minValue=0,this.maxValue=11),this.updateValueToLimits()}setValueFromDate(e,t){t?this.value=e.hour-Z(e.hour):super.setValueFromDate(e)}get inputValidationLimits(){const e=this.maxValue===11;return{minValue:e?1:0,maxValue:e?12:23}}}class de extends ${constructor(e,t){super(o.Millisecond,e,t),this.minValue=0,this.maxValue=999}}class ue extends ${constructor(e,t){super(o.Minute,e,t),this.minValue=0,this.maxValue=59}}class me extends ${constructor(e,t){super(o.Second,e,t),this.minValue=0,this.maxValue=59}}class he{constructor(e){this.dateFormatter=e;const t=this.dateFormatter.resolvedOptions().locale;this.numberFormatter=new B.$488c6ddbf4ef74c2$export$cc77c4ff7e8673c5(t,{useGrouping:!1}),this.dateTimeFieldDisplayNames=new Intl.DisplayNames([t],{type:"dateTimeField"})}createSegments(e,t=!1){const i=U(e),a=this.dateFormatter.formatToParts(i).map(y=>{const w=y.type;let q=y.value;return w==="year"&&(q=this.numberFormatter.format(e.year)),this.createSegment(w,q)}),r=new M(a),s=r.year,l=r.month,h=r.day;s.setLimits(e),l.setLimits(e),t&&(s.setValueFromDate(e),l.setValueFromDate(e)),h.setLimits(e,l.value,s.value),t&&h.setValueFromDate(e);const d=r.hour,g=r.minute,b=r.second,k=r.millisecond,f=r.dayPeriod;if(f&&f.setLocalizedLimits(this.dateFormatter),!d)return r;const z=!!f;if(d.setLimits(z),t){if(d.setValueFromDate(e,z),z&&r.dayPeriod.setValueFromDate(e),!g||(g.setValueFromDate(e),!b)||(b.setValueFromDate(e),!k))return r;k.setValueFromDate(e)}return r}createSegment(e,t){if(e===o.Literal)return new se(t);const i=this.displayNameOfType(e);switch(e){case o.Year:return new Y(t,i);case o.Month:return new ne(t,i);case o.Day:return new oe(t,i);case o.Hour:return new le(t,i);case o.Minute:return new ue(t,i);case o.Second:return new me(t,i);case o.Millisecond:return new de(t,i);case o.DayPeriod:return new ce(t,i)}}displayNameOfType(e){const t=e==="fractionalSecond"?"millisecond":this.dateTimeFieldDisplayNames.of(e);return t?t.charAt(0).toUpperCase()+t.slice(1):""}}const pe='@charset "UTF-8";:host{font-family:var(--luzmo-font-family);--date-time-picker-border-radius: var( --luzmo-date-time-picker-border-radius, var(--luzmo-border-radius) );--date-time-picker-border-radius-quiet: var( --luzmo-date-time-picker-border-radius-quiet, 0 );--date-time-picker-border-width: var(--luzmo-border-width);--date-time-picker-button-border-color: var( --highcontrast-datepicker-pickerbutton-border-color, var( --luzmo-date-time-picker-pickerbutton-border-color, var(--luzmo-border-color) ) );--date-time-picker-button-border-color-focus: var( --highcontrast-datepicker-pickerbutton-border-color, var( --luzmo-date-time-picker-pickerbutton-border-color-focus, var(--luzmo-primary) ) );--date-time-picker-button-border-color-invalid: var( --highcontrast-datepicker-pickerbutton-border-color, var( --luzmo-date-time-picker-pickerbutton-border-color-invalid, var(--luzmo-negative-color) ) );--date-time-picker-button-width: calc( var(--date-time-picker-edge-to-disclosure-icon) * 2 + var(--date-time-picker-icon-size) );--date-time-picker-quiet-button-offset: var( --luzmo-date-time-picker-quiet-button-offset, var(--date-time-picker-text-to-visual) );--date-time-picker-icon-to-text: var(--date-time-picker-edge-to-text);--date-time-picker-button-width-quiet: calc( var(--date-time-picker-button-width) - var( --date-time-picker-quiet-button-offset ) );--date-time-picker-focus-ring-gap: var( --luzmo-date-time-picker-focus-ring-gap, var(--luzmo-indicator-gap) );--date-time-picker-focus-thickness: var( --luzmo-date-time-picker-focus-thickness, var(--luzmo-indicator-width) );--date-time-picker-focus-animation: var( --luzmo-date-time-picker-focus-animation, var(--luzmo-animation-duration) );--date-time-picker-focus-ring-width: var( --luzmo-date-time-picker-focus-ring-width, var(--luzmo-border-width) );--date-time-picker-focus-ring-color: var( --highcontrast-datepicker-focus-ring-color, var(--luzmo-date-time-picker-focus-ring-color, var(--luzmo-indicator-color)) );--date-time-picker-focus-line-gap: var( --luzmo-date-time-picker-focus-line-gap, var(--luzmo-spacing-2) );--date-time-picker-invalid-quiet-color: var( --luzmo-date-time-picker-invalid-quiet-color, var(--luzmo-negative-color) );--date-time-picker-quiet-border-color-hover: var( --luzmo-date-time-picker-quiet-border-color-hover, var(--luzmo-border-color-hover) );--date-time-picker-border-color-disabled: var( --luzmo-date-time-picker-border-color-disabled, var(--luzmo-border-color-disabled) );--date-time-picker-dash-font-size: var( --luzmo-date-time-picker-dash-font-size, var(--date-time-picker-dash-font-size) );--date-time-picker-dash-color: var( --highcontrast-datepicker-dash-color, var(--luzmo-date-time-picker-dash-color, var(--luzmo-font-color)) );--date-time-picker-range-dash-padding-top: var( --luzmo-date-time-picker-range-dash-padding-top, 0 );--date-time-picker-range-dash-margin-inline-start: var( --luzmo-date-time-picker-range-dash-margin-left, calc(var(--date-time-picker-dash-font-size) * -.5) );--date-time-picker-range-input-width-first: var( --luzmo-date-time-picker-range-input-width-first, calc( var(--date-time-picker-initial-width) - var( --date-time-picker-generic-padding ) * 2 ) );--date-time-picker-input-width-base: calc( var(--date-time-picker-range-input-width-first) + var(--date-time-picker-icon-size) );--date-time-picker-input-width: var( --luzmo-date-time-picker-input-width, calc( var(--date-time-picker-input-width-base) + var(--date-time-picker-initial-height) ) );--date-time-picker-range-input-width-quiet-first: var( --luzmo-date-time-picker-range-input-width-quiet-first, calc( var(--date-time-picker-width-quiet-first) + var(--date-time-picker-width-quiet-second) ) );--date-time-picker-input-width-quiet: var( --luzmo-date-time-picker-input-width-quiet, calc( var(--date-time-picker-range-input-width-quiet-first) + var(--date-time-picker-icon-size) + var(--date-time-picker-initial-height) ) );--date-time-picker-datetime-input-width-first: var( --luzmo-date-time-picker-datetime-input-width-first, calc( var(--date-time-picker-input-width-base) + var(--date-time-picker-datetime-width-first) ) );--date-time-picker-datetime-input-width: var( --luzmo-date-time-picker-datetime-input-width, calc( var(--date-time-picker-datetime-input-width-first) + var(--date-time-picker-icon-size) + var(--date-time-picker-initial-height) ) );--date-time-picker-datetime-quiet-input-width-first: var( --luzmo-date-time-picker-datetime-quiet-input-width-first, calc( var(--date-time-picker-input-width-base) + var(--date-time-picker-input-datetime-width) ) );--date-time-picker-datetime-quiet-input-width: var( --luzmo-date-time-picker-datetime-quiet-input-width, calc( var(--date-time-picker-datetime-quiet-input-width-first) + var(--date-time-picker-icon-size) + var(--date-time-picker-initial-height) ) );--date-time-picker-padding-inline-end: var( --luzmo-date-time-picker-padding-inline, calc( var(--date-time-picker-button-width) + var(--date-time-picker-edge-to-text) - var( --date-time-picker-border-width ) * 2 ) );--date-time-picker-padding-inline-end-quiet: var( --luzmo-date-time-picker-padding-inline-quiet, calc( var(--date-time-picker-button-width) + var(--date-time-picker-edge-to-text) - var( --date-time-picker-quiet-button-offset ) ) );--date-time-picker-padding-inline-end-invalid-quiet: var( --luzmo-date-time-picker-padding-inline-end-invalid-quiet, calc( var(--date-time-picker-button-width-quiet) + var(--date-time-picker-icon-size) + var(--date-time-picker-icon-to-text) ) );min-inline-size:var(--luzmo-date-time-picker-min-width, var(--date-time-picker-min-width));border-radius:var(--date-time-picker-border-radius);flex-flow:row;display:inline-flex;position:relative}:host([disabled]) luzmo-picker-button{cursor:default}:host([disabled]){--luzmo-date-time-picker-dash-color: var( --luzmo-date-time-picker-dash-color-disabled, var(--disabled-content-color) );--luzmo-text-field-border-color-disabled: transparent}:host([invalid]),:host([invalid]) #text-field .icon{--luzmo-text-field-icon-spacing-inline-end-invalid: calc( var(--date-time-picker-button-width) + var(--date-time-picker-invalid-icon-to-button) );--luzmo-text-field-icon-spacing-inline-end-quiet-invalid: calc( var(--date-time-picker-button-width-quiet) + var(--date-time-picker-invalid-icon-to-button-quiet) )}:host(:not([quiet])){inline-size:var(--luzmo-date-time-picker-width, var(--date-time-picker-width))}:host([quiet]){inline-size:var(--luzmo-date-time-picker-width-quiet, var(--date-time-picker-width-quiet, var(--date-time-picker-width)))}:host(:not([quiet],[disabled])){--luzmo-picker-button-border-color: var( --date-time-picker-button-border-color )}:host([focused]),:host([focused]:not([quiet],[disabled])){--luzmo-picker-button-border-color: var( --date-time-picker-button-border-color-focus )}:host([invalid]:not([quiet],[disabled])){--luzmo-picker-button-border-color: var( --date-time-picker-button-border-color-invalid )}.input{inline-size:100%;flex:1;padding-inline-end:var(--date-time-picker-padding-inline-end);border-color:var(--luzmo-date-time-picker-border-color, var(--datepicker-border-color))}:host .input:read-only{border-color:var(--luzmo-date-time-picker-border-color, var(--datepicker-border-color))}.input.luzmo-DatePicker-startField{border-inline-end:0;border-start-end-radius:0;border-end-end-radius:0;padding-inline-end:var(--luzmo-date-time-picker-generic-padding, var(--date-time-picker-generic-padding))}.input.luzmo-DatePicker-endField{border-inline-start:0;border-start-start-radius:0;border-end-start-radius:0;padding-inline-start:var(--luzmo-date-time-picker-generic-padding, var(--date-time-picker-generic-padding))}luzmo-picker-button{cursor:pointer;position:absolute;inset-inline-end:0}.luzmo-DatePicker-rangeDash{color:var(--date-time-picker-dash-color);line-height:var(--luzmo-date-time-picker-dash-line-height, var(--date-time-picker-dash-line-height));flex:initial;inline-size:0;z-index:1;padding-block-start:var(--date-time-picker-range-dash-padding-top)}.luzmo-DatePicker-rangeDash:before{content:"–";margin-block:0;margin-inline:var(--date-time-picker-range-dash-margin-inline-start);text-align:center;vertical-align:middle;inline-size:var(--date-time-picker-dash-font-size);display:inline-block;overflow:hidden}:host([quiet]){--luzmo-date-time-picker-border-radius: var( --date-time-picker-border-radius-quiet );--luzmo-date-time-picker-padding-inline: var( --date-time-picker-padding-inline-end-quiet );--luzmo-picker-button-border-color-disabled: var( --date-time-picker-border-color-disabled );--luzmo-picker-button-background-color-hover-disabled: var( --date-time-picker-border-color-disabled )}:host([quiet][disabled]){--luzmo-text-field-border-color-disabled: var( --date-time-picker-border-color-disabled )}:host([quiet][invalid]) .input:not(.luzmo-DatePicker-startField){padding-inline-end:var(--date-time-picker-padding-inline-end-invalid-quiet)}@media (hover: hover){:host(:hover):not([focused],[disabled],[invalid]){--luzmo-picker-button-border-color: var( --date-time-picker-quiet-border-color-hover )}}:host([quiet][invalid]){--luzmo-picker-button-border-color: var( --date-time-picker-invalid-quiet-color )}:host([quiet]) luzmo-picker-button{inline-size:auto;inset-inline-end:calc(var(--date-time-picker-quiet-button-offset) * -1)}:host([quiet]) luzmo-picker-button:not(.is-open){--luzmo-picker-button-border-color-disabled: transparent}:host([quiet]) luzmo-picker-button:not(:disabled,.is-open){--luzmo-picker-button-background-color: transparent}.luzmo-DatePicker--range{--luzmo-date-time-picker-border-radius: var(--date-time-picker-border-radius)}.luzmo-DatePicker--range:after{pointer-events:none;content:"";margin:calc(var(--date-time-picker-focus-ring-gap) * -1);border-radius:calc(var(--date-time-picker-border-radius) + var(--date-time-picker-focus-ring-gap));transition:box-shadow var(--date-time-picker-focus-animation) ease-in-out,border-color var(--date-time-picker-focus-animation) ease-in-out;border-color:#0000;position:absolute;top:0;right:0;bottom:0;left:0}:host([focused]) .luzmo-DatePicker--range:not(.luzmo-DatePicker--quiet):after{box-shadow:0 0 0 var(--date-time-picker-focus-ring-width) var(--date-time-picker-focus-ring-color)}:host([focused]) .luzmo-DatePicker--range:not(.luzmo-DatePicker--quiet) #text-field:after{display:none}:host([quiet]) .luzmo-DatePicker--range{--luzmo-date-time-picker-border-radius: var( --date-time-picker-border-radius-quiet )}:host([quiet][focused]) .luzmo-DatePicker--range:after{box-shadow:none;border-block-end:var(--date-time-picker-focus-thickness) solid var(--date-time-picker-focus-ring-color);border-radius:0;margin:0;inset-block-end:calc(var(--date-time-picker-focus-line-gap) * -1)}:host([quiet]) .luzmo-DatePicker--range #text-field{min-inline-size:0;inline-size:var(--date-time-picker-input-width-quiet)}:host([quiet]) .luzmo-DatePicker--range #text-field:first-of-type{inline-size:var(--date-time-picker-range-input-width-quiet-first)}.luzmo-DatePicker--range.luzmo-DatePicker--datetimeRange #text-field{inline-size:var(--date-time-picker-datetime-input-width);min-inline-size:0}.luzmo-DatePicker--range.luzmo-DatePicker--datetimeRange #text-field:first-of-type{inline-size:var(--date-time-picker-datetime-input-width-first)}:host([quiet]) .luzmo-DatePicker--range.luzmo-DatePicker--datetimeRange #text-field{inline-size:var(--date-time-picker-datetime-quiet-input-width)}:host([quiet]) .luzmo-DatePicker--range.luzmo-DatePicker--datetimeRange #text-field:first-of-type{inline-size:var(--date-time-picker-datetime-quiet-input-width-first)}.luzmo-DatePicker--range #text-field{flex:initial;min-inline-size:0;inline-size:var(--date-time-picker-input-width)}.luzmo-DatePicker--range #text-field:first-of-type{inline-size:var(--date-time-picker-range-input-width-first)}@media (forced-colors: active){:host{--highcontrast-datepicker-dash-color: CanvasText;--highcontrast-datepicker-focus-ring-color: Highlight;--highcontrast-datepicker-pickerbutton-border-color: Highlight}:host([disabled]){--highcontrast-datepicker-dash-color: GrayText}:host([quiet][invalid]){--highcontrast-datepicker-pickerbutton-border-color: Highlight}}:host{--date-time-picker-width: auto;--date-time-picker-initial-height: var(--system-date-picker-initial-height);--date-time-picker-font-color-default: var(--luzmo-font-color);--datepicker-border-color: var(--luzmo-border-color);--date-time-picker-button-indicator-color: var(--luzmo-indicator-color);--text-field-focus-indicator-color: var(--luzmo-background-color-highlight);--date-time-picker-initial-width: 120px;--date-time-picker-min-width: 160px;--date-time-picker-calendar-padding: var(--luzmo-spacing-4);--date-time-picker-icon-size: 18px;--date-time-picker-dash-font-size: var(--luzmo-font-size);--date-time-picker-text-to-visual: var(--luzmo-spacing-3);--date-time-picker-edge-to-disclosure-icon: var(--luzmo-spacing-3);--date-time-picker-edge-to-text: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) );--date-time-picker-icon-to-text: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) );--date-time-picker-invalid-icon-to-button: var(--luzmo-spacing-3);--date-time-picker-generic-padding: var(--luzmo-spacing-4)}:host([size=s]){--date-time-picker-min-width: 140px;--date-time-picker-calendar-padding: var(--luzmo-spacing-3);--date-time-picker-icon-size: 16px;--date-time-picker-dash-font-size: var(--luzmo-font-size-s);--date-time-picker-text-to-visual: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) );--date-time-picker-edge-to-disclosure-icon: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) );--date-time-picker-edge-to-text: var(--luzmo-spacing-3);--date-time-picker-invalid-icon-to-button: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) );--date-time-picker-icon-to-text: var(--luzmo-spacing-3)}:host([invalid][size=s]){--text-field-icon-spacing-block-invalid: calc( var(--luzmo-spacing-2) + var(--luzmo-spacing-1) )}:host([size=m]){--date-time-picker-min-width: 160px;--date-time-picker-calendar-padding: var(--luzmo-spacing-4);--date-time-picker-icon-size: 18px;--date-time-picker-dash-font-size: var(--luzmo-font-size-m);--date-time-picker-text-to-visual: var(--luzmo-spacing-3);--date-time-picker-edge-to-disclosure-icon: var(--luzmo-spacing-3);--date-time-picker-edge-to-text: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) );--date-time-picker-invalid-icon-to-button: var(--luzmo-spacing-3);--date-time-picker-icon-to-text: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) )}:host([size=l]){--date-time-picker-min-width: 180px;--date-time-picker-calendar-padding: var(--luzmo-spacing-5);--date-time-picker-icon-size: 20px;--date-time-picker-dash-font-size: var(--luzmo-font-size-l);--date-time-picker-text-to-visual: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) );--date-time-picker-edge-to-disclosure-icon: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) );--date-time-picker-edge-to-text: var(--luzmo-spacing-4);--date-time-picker-invalid-icon-to-button: calc( var(--luzmo-spacing-3) + var(--luzmo-spacing-1) );--date-time-picker-icon-to-text: var(--luzmo-spacing-4)}:host([size=xl]){--date-time-picker-min-width: 200px;--date-time-picker-calendar-padding: calc( var(--luzmo-spacing-5) + var(--luzmo-spacing-1) );--date-time-picker-icon-size: 22px;--date-time-picker-dash-font-size: var(--luzmo-font-size-xl);--date-time-picker-text-to-visual: var(--luzmo-spacing-4);--date-time-picker-edge-to-disclosure-icon: var(--luzmo-spacing-4);--date-time-picker-edge-to-text: calc( var(--luzmo-spacing-4) + var(--luzmo-spacing-1) );--date-time-picker-invalid-icon-to-button: var(--luzmo-spacing-4);--date-time-picker-icon-to-text: calc( var(--luzmo-spacing-4) + var(--luzmo-spacing-1) )}:host{--status-icon-size: var( --luzmo-text-field-icon-size-invalid, var(--text-field-icon-size-invalid) );--picker-button-size: var( --luzmo-text-field-height, var(--text-field-height) );--input-spacing: var( --luzmo-text-field-spacing-inline, var(--text-field-spacing-inline) );--input-border-width: var( --luzmo-text-field-border-width, var(--luzmo-border-width) );--text-to-icon: var( --luzmo-text-field-icon-spacing-inline-start-invalid, var(--text-field-icon-spacing-inline-start-invalid) );--date-time-picker-input-width: var(--date-time-picker-width);flex-wrap:wrap}:host #text-field{display:inline-block}:host #text-field .input,:host([quiet]) #text-field .input,:host([valid]) #text-field .input,:host([invalid]) #text-field .input{inline-size:100%}:host #text-field .input,:host([quiet]) #text-field .input{padding-inline-end:calc(var(--picker-button-size) + var(--input-spacing) - var(--input-border-width))}:host([valid]) #text-field .input,:host([invalid]) #text-field .input{inline-size:100%;padding-inline-end:calc(var(--status-icon-size) + var(--picker-button-size) + var(--input-spacing) - var(--input-border-width) + var(--text-to-icon))}@media (hover: hover){:host([invalid]) #text-field:hover .input,:host([focused][invalid]) .input:hover,:host([focused][invalid]) #text-field:hover .input{border-color:var(--highcontrast-text-field-border-color-invalid-default, var(--luzmo-text-field-border-color-invalid-default, var(--luzmo-negative-color-hover)))}}luzmo-picker-button:focus-visible{outline:none}luzmo-popover{overflow-y:auto}luzmo-popover .popover-content{padding:var(--luzmo-date-time-picker-calendar-padding, var(--date-time-picker-calendar-padding))}.input-content{display:flex;align-items:center;height:100%;overflow:auto hidden;scrollbar-width:none;line-height:normal}.input-content::-webkit-scrollbar{display:none;width:0;height:0}.literal-segment,.editable-segment{display:inline-block;color:var(--luzmo-date-time-picker-font-color-default, var(--date-time-picker-font-color-default))}.editable-segment{padding:0 .15em;font-variant-numeric:tabular-nums;text-align:end;white-space:nowrap;caret-color:transparent;outline:none}[dir=ltr] .editable-segment{text-align:start}.literal-segment{white-space:pre;user-select:none;-webkit-user-select:none}.is-placeholder,.is-placeholder+.literal-segment{color:var(--luzmo-font-color-disabled)}.editable-segment:focus-visible{color:var(--white);background-color:var(--highcontrast-text-field-focus-indicator-color, var(--luzmo-text-field-focus-indicator-color, var(--text-field-focus-indicator-color)))}.editable-segment::selection{background-color:transparent}';var fe=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,p=(n,e,t,i)=>{for(var a=i>1?void 0:i?ve(e,t):e,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=(i?s(e,t,a):s(a))||a);return i&&a&&fe(e,t,a),a};class m extends K.ManageHelpText(I.SizedMixin(G.Focusable,{validSizes:Object.values(I.ElementSizes)})){constructor(){super(),this._precision=v.Minute,this.isUserSetPrecision=!1,this.invalid=!1,this.readonly=!1,this.quiet=!1,this.placement="bottom",this.language="en",this.labels={previous:"Previous",next:"Next",today:"Today",selected:"Selected",empty:"Empty",calendar:"Calendar"},this.focused=!1,this.segments=new M([]),this.isCalendarOpen=!1,this._timeZone=this.timeZone??c.$14e0f24ef4ac5c92$export$aa8b41735afcabd2(),this.cachedLocalTime=c.$14e0f24ef4ac5c92$export$461939dd4422153(this._timeZone),this.setNumberParser(),this.setDateFormatter(),this.setAriaDateFormatter(),this.addEventListener("focusin",()=>this.previousCommitedValue=this._value),this.addEventListener("focusout",()=>this.commitValue())}static get styles(){return[u.r(pe),u.r(X.textFieldStyles)]}get precision(){return this._precision}set precision(e){this.isUserSetPrecision=!0;const t=this._precision;e!==t&&(this._precision=e,this.requestUpdate("precision",t))}get _language(){try{return this.language?new Intl.Locale(this.language).language:"en"}catch{return"en"}}get focusElement(){return this.firstEditableSegment}get currentDate(){return this._value?c.$11d87f3f76e88657$export$84c95a83c799e074(this._value,this._timeZone):this.cachedLocalTime}get includesTime(){return[v.Hour,v.Minute,v.Second,v.Millisecond].includes(this.precision)}clear(){this._value=void 0,this.setSegments()}willUpdate(e){const t=e.has("value"),i=e.has("timeZone"),a=e.has("min"),r=e.has("max"),s=e.has("language"),l=e.has("dateFormat"),h=e.has("dateSeparator"),d=e.has("precision"),g=e.has("segments"),b=e.has("disabled");if(s&&this.setNumberParser(),(s||d)&&(this.setDateFormatter(),this.setAriaDateFormatter()),t||a||r||i){this._value=this.value?c.$fae977aafc393c5c$export$5adfdab05168c219(new Date(this.value).toISOString(),"UTC"):void 0,this._min=this.min?c.$fae977aafc393c5c$export$5adfdab05168c219(new Date(this.min).toISOString(),"UTC"):void 0,this._max=this.max?c.$fae977aafc393c5c$export$5adfdab05168c219(new Date(this.max).toISOString(),"UTC"):void 0;const f=this.mostSpecificDateValue;f&&(this.convertDatePropsToMatch(f),this.checkDatePropsCompliance(a||r),this.updateDateProps(),this.updateDefaultPrecision())}(t||s||d||l||i||h)&&this.setSegments(),g&&this.setValueFromSegments(),b&&this.isCalendarOpen&&(this.isCalendarOpen=!1);const k=this._value&&this.labels.selected+": "+this.ariaDateFormatter.format(U(this._value));this.setAttribute("aria-label",k??this.labels.empty)}get mostSpecificDateValue(){const e=[this._value,this._min,this._max].filter(r=>r!==void 0);if(e.length===0)return;const t=e.filter(r=>_(r));if(t.length>0)return t[0];const i=e.filter(r=>C(r));return i.length>0?i[0]:e.find(r=>F(r))}convertDatePropsToMatch(e){if(_(e)){this._timeZone=this.timeZone??e.timeZone,this._value=this._value&&c.$11d87f3f76e88657$export$84c95a83c799e074(this._value,this._timeZone),this._min=this._min&&c.$11d87f3f76e88657$export$84c95a83c799e074(this._min,this._timeZone),this._max=this._max&&c.$11d87f3f76e88657$export$84c95a83c799e074(this._max,this._timeZone);return}if(this._timeZone=this.timeZone??c.$14e0f24ef4ac5c92$export$aa8b41735afcabd2(),C(e)){this._value=this._value&&c.$11d87f3f76e88657$export$b21e0b124e224484(this._value),this._min=this._min&&c.$11d87f3f76e88657$export$b21e0b124e224484(this._min),this._max=this._max&&c.$11d87f3f76e88657$export$b21e0b124e224484(this._max);return}this._value=this._value&&c.$11d87f3f76e88657$export$93522d1a439f3617(this._value),this._min=this._min&&c.$11d87f3f76e88657$export$93522d1a439f3617(this._min),this._max=this._max&&c.$11d87f3f76e88657$export$93522d1a439f3617(this._max)}checkDatePropsCompliance(e){e&&this._min&&this._max&&(this._min.compare(this._max)<0||(console.warn(this,`<${this.localName}> expects the 'min' to be less than 'max'. Please ensure that 'min' property's date is earlier than 'max' property's date.`),this._min=void 0,this._max=void 0)),this.isNonCompliantValue()&&(console.warn(this,`<${this.localName}> expects the preselected value to comply with the min and max constraints. Please ensure that 'value' property's date is in between the dates for the 'min' and 'max' properties.`),this._value=void 0),!this._min&&!this._max&&!this._value&&(this._timeZone=c.$14e0f24ef4ac5c92$export$aa8b41735afcabd2())}isNonCompliantValue(){return this._value===void 0?!1:!!(this._min&&this._value.compare(this._min)<0||this._max&&this._value.compare(this._max)>0)}updateDateProps(){const e=this.mostSpecificDateValue;if(!e||!this.isUserSetPrecision)return;this.includesTime&&F(e)&&this.convertDatePropsToMatch(c.$11d87f3f76e88657$export$b21e0b124e224484(e))}updateDefaultPrecision(){if(this.isUserSetPrecision)return;const e=this.mostSpecificDateValue;e&&(this._precision=F(e)?v.Day:v.Minute)}render(){return u.x`
|
|
921
19
|
<div id="text-field">
|
|
922
20
|
${this.renderStateIcons()} ${this.renderInputContent()}
|
|
923
21
|
</div>
|
|
924
22
|
${this.renderHelpText(this.invalid)}${this.renderPicker()}
|
|
925
|
-
|
|
926
|
-
}
|
|
927
|
-
renderStateIcons() {
|
|
928
|
-
if (this.invalid)
|
|
929
|
-
return lit.html`
|
|
23
|
+
`}renderStateIcons(){return this.invalid?u.x`
|
|
930
24
|
<luzmo-icon
|
|
931
|
-
.icon=${
|
|
25
|
+
.icon=${O.$}
|
|
932
26
|
.size=${this.size}
|
|
933
27
|
id="invalid"
|
|
934
28
|
class="icon"
|
|
935
29
|
></luzmo-icon>
|
|
936
|
-
|
|
937
|
-
return lit.nothing;
|
|
938
|
-
}
|
|
939
|
-
renderPicker() {
|
|
940
|
-
if (this.readonly) return lit.nothing;
|
|
941
|
-
const closeCalendar = () => this.isCalendarOpen = false;
|
|
942
|
-
const openCalendar = () => this.isCalendarOpen = true;
|
|
943
|
-
return lit.html`
|
|
30
|
+
`:u.E}renderPicker(){if(this.readonly)return u.E;const e=()=>this.isCalendarOpen=!1,t=()=>this.isCalendarOpen=!0;return u.x`
|
|
944
31
|
<luzmo-picker-button
|
|
945
32
|
?open=${this.isCalendarOpen}
|
|
946
33
|
?quiet=${this.quiet}
|
|
947
34
|
?invalid=${this.invalid}
|
|
948
35
|
?disabled=${this.disabled}
|
|
949
36
|
.size=${this.size}
|
|
950
|
-
@click=${
|
|
37
|
+
@click=${t}
|
|
951
38
|
label=${this.labels.calendar}
|
|
952
39
|
>
|
|
953
40
|
<slot name="calendar-icon" slot="icon">
|
|
954
41
|
<luzmo-icon
|
|
955
|
-
.icon=${
|
|
42
|
+
.icon=${O.o0}
|
|
956
43
|
.size=${this.size}
|
|
957
44
|
block
|
|
958
45
|
></luzmo-icon>
|
|
@@ -962,20 +49,17 @@ class LuzmoDateTimePicker extends manageHelpText.ManageHelpText(
|
|
|
962
49
|
<luzmo-overlay
|
|
963
50
|
.triggerElement=${this.input}
|
|
964
51
|
type="modal"
|
|
965
|
-
placement=${this.placement
|
|
52
|
+
placement=${this.placement??"bottom"}
|
|
966
53
|
offset="0"
|
|
967
54
|
?open=${this.isCalendarOpen}
|
|
968
|
-
@luzmo-closed=${
|
|
55
|
+
@luzmo-closed=${e}
|
|
969
56
|
>
|
|
970
57
|
<luzmo-popover>
|
|
971
58
|
<div class="popover-content">
|
|
972
59
|
<luzmo-calendar
|
|
973
|
-
.value=${this._value
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
) : void 0}
|
|
977
|
-
.min=${this._min ? this._min.toString() : void 0}
|
|
978
|
-
.max=${this._max ? this._max.toString() : void 0}
|
|
60
|
+
.value=${this._value?this._value.toString().slice(0,10):void 0}
|
|
61
|
+
.min=${this._min?this._min.toString():void 0}
|
|
62
|
+
.max=${this._max?this._max.toString():void 0}
|
|
979
63
|
.labels=${this.labels}
|
|
980
64
|
.size=${this.size}
|
|
981
65
|
.language=${this.language}
|
|
@@ -984,448 +68,38 @@ class LuzmoDateTimePicker extends manageHelpText.ManageHelpText(
|
|
|
984
68
|
</div>
|
|
985
69
|
</luzmo-popover>
|
|
986
70
|
</luzmo-overlay>
|
|
987
|
-
|
|
988
|
-
}
|
|
989
|
-
handleChange(event) {
|
|
990
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
991
|
-
event.stopPropagation();
|
|
992
|
-
this.isCalendarOpen = false;
|
|
993
|
-
if ((_a = event.target) == null ? void 0 : _a.value) {
|
|
994
|
-
this.value = (_b = event.target) == null ? void 0 : _b.value;
|
|
995
|
-
}
|
|
996
|
-
const calendarValue = date.parseDate(
|
|
997
|
-
((_c = event.target) == null ? void 0 : _c.value) ?? ""
|
|
998
|
-
);
|
|
999
|
-
if (this.includesTime) {
|
|
1000
|
-
const hour = ((_d = this.segments.hour) == null ? void 0 : _d.value) ?? 0;
|
|
1001
|
-
const minute = ((_e = this.segments.minute) == null ? void 0 : _e.value) ?? 0;
|
|
1002
|
-
const second = ((_f = this.segments.second) == null ? void 0 : _f.value) ?? 0;
|
|
1003
|
-
const millisecond = ((_g = this.segments.millisecond) == null ? void 0 : _g.value) ?? 0;
|
|
1004
|
-
const time = new date.Time(hour, minute, second, millisecond);
|
|
1005
|
-
const mostSpecificDateValue = this.mostSpecificDateValue;
|
|
1006
|
-
this._value = date.toCalendarDateTime(calendarValue, time);
|
|
1007
|
-
if (mostSpecificDateValue && isZonedDateTime(mostSpecificDateValue))
|
|
1008
|
-
this._value = date.toZoned(this._value, this._timeZone);
|
|
1009
|
-
} else {
|
|
1010
|
-
this._value = calendarValue;
|
|
1011
|
-
}
|
|
1012
|
-
this.commitValue();
|
|
1013
|
-
}
|
|
1014
|
-
renderInputContent() {
|
|
1015
|
-
const focusIn = () => this.focused = !this.readonly;
|
|
1016
|
-
const focusOut = () => this.focused = false;
|
|
1017
|
-
return lit.html`
|
|
71
|
+
`}handleChange(e){var i,a,r,s,l,h,d;e.stopPropagation(),this.isCalendarOpen=!1,(i=e.target)!=null&&i.value&&(this.value=(a=e.target)==null?void 0:a.value);const t=c.$fae977aafc393c5c$export$6b862160d295c8e(((r=e.target)==null?void 0:r.value)??"");if(this.includesTime){const g=((s=this.segments.hour)==null?void 0:s.value)??0,b=((l=this.segments.minute)==null?void 0:l.value)??0,k=((h=this.segments.second)==null?void 0:h.value)??0,f=((d=this.segments.millisecond)==null?void 0:d.value)??0,z=new c.$35ea8db9cb2ccb90$export$680ea196effce5f(g,b,k,f),y=this.mostSpecificDateValue;this._value=c.$11d87f3f76e88657$export$b21e0b124e224484(t,z),y&&_(y)&&(this._value=c.$11d87f3f76e88657$export$84c95a83c799e074(this._value,this._timeZone))}else this._value=t;this.commitValue()}renderInputContent(){const e=()=>this.focused=!this.readonly,t=()=>this.focused=!1;return u.x`
|
|
1018
72
|
<div class="input">
|
|
1019
73
|
<span
|
|
1020
74
|
class="input-content"
|
|
1021
|
-
@focusin=${
|
|
1022
|
-
@focusout=${
|
|
75
|
+
@focusin=${e}
|
|
76
|
+
@focusout=${t}
|
|
1023
77
|
@keydown=${this.handleKeydown}
|
|
1024
78
|
@input=${this.handleInput}
|
|
1025
79
|
>
|
|
1026
80
|
${this.renderSegments()}
|
|
1027
81
|
</span>
|
|
1028
82
|
</div>
|
|
1029
|
-
|
|
1030
|
-
}
|
|
1031
|
-
renderSegments() {
|
|
1032
|
-
return this.segments.all.map(
|
|
1033
|
-
(segment) => when_js.when(
|
|
1034
|
-
segment.type === SegmentTypes.Literal,
|
|
1035
|
-
() => this.renderLiteralSegment(segment),
|
|
1036
|
-
() => this.renderEditableSegment(segment)
|
|
1037
|
-
)
|
|
1038
|
-
);
|
|
1039
|
-
}
|
|
1040
|
-
renderLiteralSegment(segment) {
|
|
1041
|
-
return lit.html`
|
|
83
|
+
`}renderSegments(){return this.segments.all.map(e=>L.n(e.type===o.Literal,()=>this.renderLiteralSegment(e),()=>this.renderEditableSegment(e)))}renderLiteralSegment(e){return u.x`
|
|
1042
84
|
<span
|
|
1043
85
|
class="literal-segment"
|
|
1044
|
-
data-test-id=${
|
|
86
|
+
data-test-id=${e.type}
|
|
1045
87
|
aria-hidden="true"
|
|
1046
|
-
>${
|
|
1047
|
-
|
|
1048
|
-
}
|
|
1049
|
-
renderEditableSegment(segment) {
|
|
1050
|
-
const isActive = !this.disabled && !this.readonly;
|
|
1051
|
-
const usePlaceholder = segment.value === void 0;
|
|
1052
|
-
const inputMode = segment.type === SegmentTypes.DayPeriod ? "text" : "numeric";
|
|
1053
|
-
const segmentClasses = {
|
|
1054
|
-
"editable-segment": true,
|
|
1055
|
-
"is-placeholder": usePlaceholder
|
|
1056
|
-
};
|
|
1057
|
-
const minWidth = segment.type !== SegmentTypes.Year && String(segment.maxValue).length > 0;
|
|
1058
|
-
const segmentStyles = {
|
|
1059
|
-
minWidth: minWidth ? `${minWidth}ch` : void 0
|
|
1060
|
-
};
|
|
1061
|
-
return lit.html`
|
|
88
|
+
>${e.formatted}</span>
|
|
89
|
+
`}renderEditableSegment(e){const t=!this.disabled&&!this.readonly,i=e.value===void 0,a=e.type===o.DayPeriod?"text":"numeric",r={"editable-segment":!0,"is-placeholder":i},s=e.type!==o.Year&&String(e.maxValue).length>0,l={minWidth:s?`${s}ch`:void 0};return u.x`
|
|
1062
90
|
<div
|
|
1063
91
|
role="spinbutton"
|
|
1064
|
-
aria-valuenow=${
|
|
1065
|
-
aria-valuemin=${
|
|
1066
|
-
aria-valuemax=${
|
|
1067
|
-
aria-label=${
|
|
1068
|
-
aria-valuetext=${
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
data-type=${segment.type}
|
|
1077
|
-
.innerText=${this.renderSegmentText(segment)}
|
|
92
|
+
aria-valuenow=${S.o(e.value)}
|
|
93
|
+
aria-valuemin=${e.minValue}
|
|
94
|
+
aria-valuemax=${e.maxValue}
|
|
95
|
+
aria-label=${e.label}
|
|
96
|
+
aria-valuetext=${S.o(e.value===void 0?this.labels.empty:e.formatted)}
|
|
97
|
+
contenteditable=${S.o(t?!0:void 0)}
|
|
98
|
+
inputmode=${S.o(t?a:void 0)}
|
|
99
|
+
tabindex=${S.o(t?"0":void 0)}
|
|
100
|
+
class=${j.e(r)}
|
|
101
|
+
style=${W.o(l)}
|
|
102
|
+
data-type=${e.type}
|
|
103
|
+
.innerText=${this.renderSegmentText(e)}
|
|
1078
104
|
></div>
|
|
1079
|
-
|
|
1080
|
-
}
|
|
1081
|
-
renderSegmentText(segment) {
|
|
1082
|
-
const usePlaceholder = segment.value === void 0;
|
|
1083
|
-
return when_js.when(
|
|
1084
|
-
usePlaceholder,
|
|
1085
|
-
() => segment.placeholder ?? "",
|
|
1086
|
-
() => segment.formatted ?? ""
|
|
1087
|
-
);
|
|
1088
|
-
}
|
|
1089
|
-
handleKeydown(event) {
|
|
1090
|
-
var _a;
|
|
1091
|
-
const segmentElement = event.target;
|
|
1092
|
-
const segmentType = segmentElement.dataset.type;
|
|
1093
|
-
if (!segmentType) return;
|
|
1094
|
-
switch (event.code) {
|
|
1095
|
-
case "ArrowUp": {
|
|
1096
|
-
this.incrementValue(segmentType);
|
|
1097
|
-
break;
|
|
1098
|
-
}
|
|
1099
|
-
case "ArrowDown": {
|
|
1100
|
-
this.decrementValue(segmentType);
|
|
1101
|
-
break;
|
|
1102
|
-
}
|
|
1103
|
-
case "ArrowRight": {
|
|
1104
|
-
this.focusSegment(segmentElement, "next");
|
|
1105
|
-
break;
|
|
1106
|
-
}
|
|
1107
|
-
case "ArrowLeft": {
|
|
1108
|
-
this.focusSegment(segmentElement, "previous");
|
|
1109
|
-
break;
|
|
1110
|
-
}
|
|
1111
|
-
case "Enter":
|
|
1112
|
-
case "Space": {
|
|
1113
|
-
this.commitValue();
|
|
1114
|
-
break;
|
|
1115
|
-
}
|
|
1116
|
-
case "Backspace":
|
|
1117
|
-
case "Delete": {
|
|
1118
|
-
event.preventDefault();
|
|
1119
|
-
if (((_a = this.segments.getByType(segmentType)) == null ? void 0 : _a.value) === void 0)
|
|
1120
|
-
this.focusSegment(segmentElement, "previous");
|
|
1121
|
-
else this.clearSegmentContent(segmentType);
|
|
1122
|
-
break;
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
/**
|
|
1127
|
-
* The modifier parameters of the component
|
|
1128
|
-
* @internal
|
|
1129
|
-
*/
|
|
1130
|
-
get modifierParams() {
|
|
1131
|
-
return {
|
|
1132
|
-
dateFormatter: this.dateFormatter,
|
|
1133
|
-
segments: this.segments,
|
|
1134
|
-
currentDate: this.currentDate
|
|
1135
|
-
};
|
|
1136
|
-
}
|
|
1137
|
-
incrementValue(segmentType) {
|
|
1138
|
-
const incrementModifier = new IncrementModifier(this.modifierParams);
|
|
1139
|
-
this.segments = incrementModifier.modify(segmentType);
|
|
1140
|
-
this.dispatchInput();
|
|
1141
|
-
}
|
|
1142
|
-
decrementValue(segmentType) {
|
|
1143
|
-
const decrementModifier = new DecrementModifier(this.modifierParams);
|
|
1144
|
-
this.segments = decrementModifier.modify(segmentType);
|
|
1145
|
-
this.dispatchInput();
|
|
1146
|
-
}
|
|
1147
|
-
/**
|
|
1148
|
-
* Focuses the segment according to the direction, if there is one to focus on
|
|
1149
|
-
*
|
|
1150
|
-
* @param segment - Segment on which the event was triggered (the segment being changed)
|
|
1151
|
-
* @param elementToFocus - Defines which element will be focused: is it the previous one or the next one?
|
|
1152
|
-
*/
|
|
1153
|
-
focusSegment(segment, elementToFocus) {
|
|
1154
|
-
let segmentFound = false;
|
|
1155
|
-
let currentSegment = segment;
|
|
1156
|
-
while (!segmentFound) {
|
|
1157
|
-
const siblingSegment = elementToFocus === "previous" ? currentSegment.previousElementSibling : currentSegment.nextElementSibling;
|
|
1158
|
-
if (!siblingSegment) {
|
|
1159
|
-
break;
|
|
1160
|
-
}
|
|
1161
|
-
if (siblingSegment.getAttribute("contenteditable")) {
|
|
1162
|
-
siblingSegment.focus();
|
|
1163
|
-
segmentFound = true;
|
|
1164
|
-
}
|
|
1165
|
-
currentSegment = siblingSegment;
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
/**
|
|
1169
|
-
* Mark the user intent to commit the selected value. If the current value
|
|
1170
|
-
* is different from the previous commited value, dispatch a change event.
|
|
1171
|
-
*/
|
|
1172
|
-
commitValue() {
|
|
1173
|
-
if (this._value && this.previousCommitedValue && this._value.compare(this.previousCommitedValue) === 0)
|
|
1174
|
-
return;
|
|
1175
|
-
if (this._value === void 0 && this.previousCommitedValue === void 0) {
|
|
1176
|
-
const allSegmentsEmpty = this.segments.editableValues.every(
|
|
1177
|
-
(value) => value === void 0
|
|
1178
|
-
);
|
|
1179
|
-
this.invalid = allSegmentsEmpty ? false : true;
|
|
1180
|
-
return;
|
|
1181
|
-
}
|
|
1182
|
-
this.invalid = this._value === void 0 || this.isNonCompliantValue() ? true : false;
|
|
1183
|
-
this.previousCommitedValue = this._value;
|
|
1184
|
-
this.dispatchChange();
|
|
1185
|
-
}
|
|
1186
|
-
clearSegmentContent(segmentType) {
|
|
1187
|
-
const valuesBefore = this.segments.editableValues;
|
|
1188
|
-
const clearModifier = new ClearModifier(this.modifierParams);
|
|
1189
|
-
this.segments = clearModifier.modify(segmentType);
|
|
1190
|
-
const valuesAfter = this.segments.editableValues;
|
|
1191
|
-
if (!equalSegmentValues(valuesBefore, valuesAfter)) this.dispatchInput();
|
|
1192
|
-
}
|
|
1193
|
-
handleInput(event) {
|
|
1194
|
-
event.stopPropagation();
|
|
1195
|
-
const segmentType = event.target.dataset.type;
|
|
1196
|
-
const valuesBefore = this.segments.editableValues;
|
|
1197
|
-
const inputModifier = new InputModifier({
|
|
1198
|
-
...this.modifierParams,
|
|
1199
|
-
eventData: event.data,
|
|
1200
|
-
numberParser: this.numberParser
|
|
1201
|
-
});
|
|
1202
|
-
this.segments = inputModifier.modify(segmentType);
|
|
1203
|
-
this.updateSegmentContent(
|
|
1204
|
-
this.segments.getByType(segmentType),
|
|
1205
|
-
event.target
|
|
1206
|
-
);
|
|
1207
|
-
const valuesAfter = this.segments.editableValues;
|
|
1208
|
-
if (!equalSegmentValues(valuesBefore, valuesAfter)) this.dispatchInput();
|
|
1209
|
-
}
|
|
1210
|
-
/**
|
|
1211
|
-
* Updates the content of the segments by binding it to the `.innerText` property of the element,
|
|
1212
|
-
* instead of using string interpolation. This allows to not show user typed characters, but
|
|
1213
|
-
* only the formatted content of the segment, needed for the 'contenteditable' elements.
|
|
1214
|
-
*
|
|
1215
|
-
* @param segment - Segment on which the event was triggered (the segment being changed)
|
|
1216
|
-
* @param event - Triggered event details
|
|
1217
|
-
*/
|
|
1218
|
-
updateSegmentContent(segment, segmentElement) {
|
|
1219
|
-
segmentElement.textContent = segment.value === void 0 ? segment.placeholder : segment.formatted;
|
|
1220
|
-
}
|
|
1221
|
-
createOutputString(value) {
|
|
1222
|
-
if (value) {
|
|
1223
|
-
if (isZonedDateTime(value))
|
|
1224
|
-
return this._value.toAbsoluteString();
|
|
1225
|
-
return new Date(this._value.toString()).toISOString();
|
|
1226
|
-
}
|
|
1227
|
-
return "";
|
|
1228
|
-
}
|
|
1229
|
-
dispatchChange() {
|
|
1230
|
-
const value = this.createOutputString(this._value);
|
|
1231
|
-
this.dispatchEvent(
|
|
1232
|
-
new CustomEvent("change", {
|
|
1233
|
-
bubbles: true,
|
|
1234
|
-
composed: true,
|
|
1235
|
-
cancelable: true,
|
|
1236
|
-
detail: {
|
|
1237
|
-
value
|
|
1238
|
-
}
|
|
1239
|
-
})
|
|
1240
|
-
);
|
|
1241
|
-
}
|
|
1242
|
-
dispatchInput() {
|
|
1243
|
-
const value = this.createOutputString(this._value);
|
|
1244
|
-
this.dispatchEvent(
|
|
1245
|
-
new CustomEvent("input", {
|
|
1246
|
-
bubbles: true,
|
|
1247
|
-
composed: true,
|
|
1248
|
-
cancelable: true,
|
|
1249
|
-
detail: {
|
|
1250
|
-
value
|
|
1251
|
-
}
|
|
1252
|
-
})
|
|
1253
|
-
);
|
|
1254
|
-
}
|
|
1255
|
-
setValueFromSegments() {
|
|
1256
|
-
const formattedDate = this.segments.getFormattedDate(this.precision);
|
|
1257
|
-
if (!formattedDate) {
|
|
1258
|
-
if (this._value) this.dispatchChange();
|
|
1259
|
-
this._value = void 0;
|
|
1260
|
-
return;
|
|
1261
|
-
}
|
|
1262
|
-
if (this._value === void 0) this.dispatchChange();
|
|
1263
|
-
const mostSpecificDateValue = this.mostSpecificDateValue;
|
|
1264
|
-
if (mostSpecificDateValue) {
|
|
1265
|
-
if (isZonedDateTime(mostSpecificDateValue))
|
|
1266
|
-
this._value = date.toZoned(formattedDate, this._timeZone);
|
|
1267
|
-
else if (isCalendarDateTime(mostSpecificDateValue))
|
|
1268
|
-
this._value = date.toCalendarDateTime(formattedDate);
|
|
1269
|
-
else this._value = date.toCalendarDate(formattedDate);
|
|
1270
|
-
} else {
|
|
1271
|
-
this._value = formattedDate;
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
setSegments() {
|
|
1275
|
-
var _a, _b, _c, _d;
|
|
1276
|
-
const segmentsFactory = new SegmentsFactory(this.dateFormatter);
|
|
1277
|
-
const segments = segmentsFactory.createSegments(
|
|
1278
|
-
this.currentDate,
|
|
1279
|
-
this._value !== void 0
|
|
1280
|
-
);
|
|
1281
|
-
if (this.dateFormat) {
|
|
1282
|
-
const monthIndex = segments.all.findIndex(
|
|
1283
|
-
(d) => d.type === SegmentTypes.Month
|
|
1284
|
-
);
|
|
1285
|
-
const dayIndex = segments.all.findIndex(
|
|
1286
|
-
(d) => d.type === SegmentTypes.Day
|
|
1287
|
-
);
|
|
1288
|
-
if (monthIndex !== -1 && dayIndex !== -1) {
|
|
1289
|
-
if (this.dateFormat === "mmdd" && monthIndex > dayIndex) {
|
|
1290
|
-
const temp = segments.all[monthIndex];
|
|
1291
|
-
segments.all[monthIndex] = segments.all[dayIndex];
|
|
1292
|
-
segments.all[dayIndex] = temp;
|
|
1293
|
-
} else if (this.dateFormat === "ddmm" && dayIndex > monthIndex) {
|
|
1294
|
-
const temp = segments.all[dayIndex];
|
|
1295
|
-
segments.all[dayIndex] = segments.all[monthIndex];
|
|
1296
|
-
segments.all[monthIndex] = temp;
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
if (typeof this.dateSeparator === "string" && this.dateSeparator) {
|
|
1301
|
-
if (((_b = (_a = segments.all) == null ? void 0 : _a[1]) == null ? void 0 : _b.type) === SegmentTypes.Literal) {
|
|
1302
|
-
segments.all[1].formatted = this.dateSeparator;
|
|
1303
|
-
}
|
|
1304
|
-
if (((_d = (_c = segments.all) == null ? void 0 : _c[3]) == null ? void 0 : _d.type) === SegmentTypes.Literal) {
|
|
1305
|
-
segments.all[3].formatted = this.dateSeparator;
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
this.segments = segments;
|
|
1309
|
-
}
|
|
1310
|
-
setNumberParser() {
|
|
1311
|
-
this.numberParser = new number.NumberParser(this._language, {
|
|
1312
|
-
maximumFractionDigits: 0
|
|
1313
|
-
});
|
|
1314
|
-
}
|
|
1315
|
-
setDateFormatter() {
|
|
1316
|
-
this.dateFormatter = new date.DateFormatter(this._language, {
|
|
1317
|
-
day: "2-digit",
|
|
1318
|
-
month: "2-digit",
|
|
1319
|
-
year: "numeric",
|
|
1320
|
-
...this.getTimeOptions("2-digit")
|
|
1321
|
-
});
|
|
1322
|
-
}
|
|
1323
|
-
setAriaDateFormatter() {
|
|
1324
|
-
this.ariaDateFormatter = new date.DateFormatter(this._language, {
|
|
1325
|
-
day: "numeric",
|
|
1326
|
-
month: "long",
|
|
1327
|
-
year: "numeric",
|
|
1328
|
-
...this.getTimeOptions("numeric")
|
|
1329
|
-
});
|
|
1330
|
-
}
|
|
1331
|
-
getTimeOptions(digitType) {
|
|
1332
|
-
switch (this.precision) {
|
|
1333
|
-
case Precisions.Millisecond: {
|
|
1334
|
-
return {
|
|
1335
|
-
hour: digitType,
|
|
1336
|
-
minute: digitType,
|
|
1337
|
-
second: digitType,
|
|
1338
|
-
fractionalSecondDigits: 3
|
|
1339
|
-
};
|
|
1340
|
-
}
|
|
1341
|
-
case Precisions.Second: {
|
|
1342
|
-
return {
|
|
1343
|
-
hour: digitType,
|
|
1344
|
-
minute: digitType,
|
|
1345
|
-
second: digitType
|
|
1346
|
-
};
|
|
1347
|
-
}
|
|
1348
|
-
case Precisions.Minute: {
|
|
1349
|
-
return {
|
|
1350
|
-
hour: digitType,
|
|
1351
|
-
minute: digitType
|
|
1352
|
-
};
|
|
1353
|
-
}
|
|
1354
|
-
case Precisions.Hour: {
|
|
1355
|
-
return {
|
|
1356
|
-
hour: digitType
|
|
1357
|
-
};
|
|
1358
|
-
}
|
|
1359
|
-
default: {
|
|
1360
|
-
return {};
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
__decorateClass([
|
|
1366
|
-
decorators_js.property({ type: String, reflect: true })
|
|
1367
|
-
], LuzmoDateTimePicker.prototype, "value", 2);
|
|
1368
|
-
__decorateClass([
|
|
1369
|
-
decorators_js.property({ type: String, reflect: true })
|
|
1370
|
-
], LuzmoDateTimePicker.prototype, "min", 2);
|
|
1371
|
-
__decorateClass([
|
|
1372
|
-
decorators_js.property({ type: String, reflect: true })
|
|
1373
|
-
], LuzmoDateTimePicker.prototype, "max", 2);
|
|
1374
|
-
__decorateClass([
|
|
1375
|
-
decorators_js.property({ type: String, attribute: "date-format", reflect: true })
|
|
1376
|
-
], LuzmoDateTimePicker.prototype, "dateFormat", 2);
|
|
1377
|
-
__decorateClass([
|
|
1378
|
-
decorators_js.property({ type: String, attribute: "date-separator", reflect: true })
|
|
1379
|
-
], LuzmoDateTimePicker.prototype, "dateSeparator", 2);
|
|
1380
|
-
__decorateClass([
|
|
1381
|
-
decorators_js.property({ type: String, reflect: true })
|
|
1382
|
-
], LuzmoDateTimePicker.prototype, "precision", 1);
|
|
1383
|
-
__decorateClass([
|
|
1384
|
-
decorators_js.property({ type: Boolean, reflect: true })
|
|
1385
|
-
], LuzmoDateTimePicker.prototype, "invalid", 2);
|
|
1386
|
-
__decorateClass([
|
|
1387
|
-
decorators_js.property({ type: Boolean, reflect: true })
|
|
1388
|
-
], LuzmoDateTimePicker.prototype, "readonly", 2);
|
|
1389
|
-
__decorateClass([
|
|
1390
|
-
decorators_js.property({ type: Boolean, reflect: true })
|
|
1391
|
-
], LuzmoDateTimePicker.prototype, "quiet", 2);
|
|
1392
|
-
__decorateClass([
|
|
1393
|
-
decorators_js.property({ type: String, reflect: true })
|
|
1394
|
-
], LuzmoDateTimePicker.prototype, "placement", 2);
|
|
1395
|
-
__decorateClass([
|
|
1396
|
-
decorators_js.property({ type: String, attribute: "time-zone", reflect: true })
|
|
1397
|
-
], LuzmoDateTimePicker.prototype, "timeZone", 2);
|
|
1398
|
-
__decorateClass([
|
|
1399
|
-
decorators_js.property({ type: String, reflect: true })
|
|
1400
|
-
], LuzmoDateTimePicker.prototype, "language", 2);
|
|
1401
|
-
__decorateClass([
|
|
1402
|
-
decorators_js.property({ attribute: false })
|
|
1403
|
-
], LuzmoDateTimePicker.prototype, "labels", 2);
|
|
1404
|
-
__decorateClass([
|
|
1405
|
-
decorators_js.property({ type: Boolean, reflect: true })
|
|
1406
|
-
], LuzmoDateTimePicker.prototype, "focused", 2);
|
|
1407
|
-
__decorateClass([
|
|
1408
|
-
decorators_js.state()
|
|
1409
|
-
], LuzmoDateTimePicker.prototype, "_value", 2);
|
|
1410
|
-
__decorateClass([
|
|
1411
|
-
decorators_js.state()
|
|
1412
|
-
], LuzmoDateTimePicker.prototype, "_min", 2);
|
|
1413
|
-
__decorateClass([
|
|
1414
|
-
decorators_js.state()
|
|
1415
|
-
], LuzmoDateTimePicker.prototype, "_max", 2);
|
|
1416
|
-
__decorateClass([
|
|
1417
|
-
decorators_js.state()
|
|
1418
|
-
], LuzmoDateTimePicker.prototype, "segments", 2);
|
|
1419
|
-
__decorateClass([
|
|
1420
|
-
decorators_js.state()
|
|
1421
|
-
], LuzmoDateTimePicker.prototype, "isCalendarOpen", 2);
|
|
1422
|
-
__decorateClass([
|
|
1423
|
-
decorators_js.query(".editable-segment")
|
|
1424
|
-
], LuzmoDateTimePicker.prototype, "firstEditableSegment", 2);
|
|
1425
|
-
__decorateClass([
|
|
1426
|
-
decorators_js.query(".input")
|
|
1427
|
-
], LuzmoDateTimePicker.prototype, "input", 2);
|
|
1428
|
-
if (!customElements.get("luzmo-date-time-picker")) {
|
|
1429
|
-
customElements.define("luzmo-date-time-picker", LuzmoDateTimePicker);
|
|
1430
|
-
}
|
|
1431
|
-
exports.LuzmoDateTimePicker = LuzmoDateTimePicker;
|
|
105
|
+
`}renderSegmentText(e){const t=e.value===void 0;return L.n(t,()=>e.placeholder??"",()=>e.formatted??"")}handleKeydown(e){var a;const t=e.target,i=t.dataset.type;if(i)switch(e.code){case"ArrowUp":{this.incrementValue(i);break}case"ArrowDown":{this.decrementValue(i);break}case"ArrowRight":{this.focusSegment(t,"next");break}case"ArrowLeft":{this.focusSegment(t,"previous");break}case"Enter":case"Space":{this.commitValue();break}case"Backspace":case"Delete":{e.preventDefault(),((a=this.segments.getByType(i))==null?void 0:a.value)===void 0?this.focusSegment(t,"previous"):this.clearSegmentContent(i);break}}}get modifierParams(){return{dateFormatter:this.dateFormatter,segments:this.segments,currentDate:this.currentDate}}incrementValue(e){const t=new ae(this.modifierParams);this.segments=t.modify(e),this.dispatchInput()}decrementValue(e){const t=new ie(this.modifierParams);this.segments=t.modify(e),this.dispatchInput()}focusSegment(e,t){let i=!1,a=e;for(;!i;){const r=t==="previous"?a.previousElementSibling:a.nextElementSibling;if(!r)break;r.getAttribute("contenteditable")&&(r.focus(),i=!0),a=r}}commitValue(){if(!(this._value&&this.previousCommitedValue&&this._value.compare(this.previousCommitedValue)===0)){if(this._value===void 0&&this.previousCommitedValue===void 0){const e=this.segments.editableValues.every(t=>t===void 0);this.invalid=!e;return}this.invalid=!!(this._value===void 0||this.isNonCompliantValue()),this.previousCommitedValue=this._value,this.dispatchChange()}}clearSegmentContent(e){const t=this.segments.editableValues,i=new te(this.modifierParams);this.segments=i.modify(e);const a=this.segments.editableValues;E(t,a)||this.dispatchInput()}handleInput(e){e.stopPropagation();const t=e.target.dataset.type,i=this.segments.editableValues,a=new re({...this.modifierParams,eventData:e.data,numberParser:this.numberParser});this.segments=a.modify(t),this.updateSegmentContent(this.segments.getByType(t),e.target);const r=this.segments.editableValues;E(i,r)||this.dispatchInput()}updateSegmentContent(e,t){t.textContent=e.value===void 0?e.placeholder:e.formatted}createOutputString(e){return e?_(e)?this._value.toAbsoluteString():new Date(this._value.toString()).toISOString():""}dispatchChange(){const e=this.createOutputString(this._value);this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,cancelable:!0,detail:{value:e}}))}dispatchInput(){const e=this.createOutputString(this._value);this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,cancelable:!0,detail:{value:e}}))}setValueFromSegments(){const e=this.segments.getFormattedDate(this.precision);if(!e){this._value&&this.dispatchChange(),this._value=void 0;return}this._value===void 0&&this.dispatchChange();const t=this.mostSpecificDateValue;t?_(t)?this._value=c.$11d87f3f76e88657$export$84c95a83c799e074(e,this._timeZone):C(t)?this._value=c.$11d87f3f76e88657$export$b21e0b124e224484(e):this._value=c.$11d87f3f76e88657$export$93522d1a439f3617(e):this._value=e}setSegments(){var i,a,r,s;const t=new he(this.dateFormatter).createSegments(this.currentDate,this._value!==void 0);if(this.dateFormat){const l=t.all.findIndex(d=>d.type===o.Month),h=t.all.findIndex(d=>d.type===o.Day);if(l!==-1&&h!==-1){if(this.dateFormat==="mmdd"&&l>h){const d=t.all[l];t.all[l]=t.all[h],t.all[h]=d}else if(this.dateFormat==="ddmm"&&h>l){const d=t.all[h];t.all[h]=t.all[l],t.all[l]=d}}}typeof this.dateSeparator=="string"&&this.dateSeparator&&(((a=(i=t.all)==null?void 0:i[1])==null?void 0:a.type)===o.Literal&&(t.all[1].formatted=this.dateSeparator),((s=(r=t.all)==null?void 0:r[3])==null?void 0:s.type)===o.Literal&&(t.all[3].formatted=this.dateSeparator)),this.segments=t}setNumberParser(){this.numberParser=new R.$6c7bd7858deea686$export$cd11ab140839f11d(this._language,{maximumFractionDigits:0})}setDateFormatter(){this.dateFormatter=new c.$fb18d541ea1ad717$export$ad991b66133851cf(this._language,{day:"2-digit",month:"2-digit",year:"numeric",...this.getTimeOptions("2-digit")})}setAriaDateFormatter(){this.ariaDateFormatter=new c.$fb18d541ea1ad717$export$ad991b66133851cf(this._language,{day:"numeric",month:"long",year:"numeric",...this.getTimeOptions("numeric")})}getTimeOptions(e){switch(this.precision){case v.Millisecond:return{hour:e,minute:e,second:e,fractionalSecondDigits:3};case v.Second:return{hour:e,minute:e,second:e};case v.Minute:return{hour:e,minute:e};case v.Hour:return{hour:e};default:return{}}}}p([u.n({type:String,reflect:!0})],m.prototype,"value",2);p([u.n({type:String,reflect:!0})],m.prototype,"min",2);p([u.n({type:String,reflect:!0})],m.prototype,"max",2);p([u.n({type:String,attribute:"date-format",reflect:!0})],m.prototype,"dateFormat",2);p([u.n({type:String,attribute:"date-separator",reflect:!0})],m.prototype,"dateSeparator",2);p([u.n({type:String,reflect:!0})],m.prototype,"precision",1);p([u.n({type:Boolean,reflect:!0})],m.prototype,"invalid",2);p([u.n({type:Boolean,reflect:!0})],m.prototype,"readonly",2);p([u.n({type:Boolean,reflect:!0})],m.prototype,"quiet",2);p([u.n({type:String,reflect:!0})],m.prototype,"placement",2);p([u.n({type:String,attribute:"time-zone",reflect:!0})],m.prototype,"timeZone",2);p([u.n({type:String,reflect:!0})],m.prototype,"language",2);p([u.n({attribute:!1})],m.prototype,"labels",2);p([u.n({type:Boolean,reflect:!0})],m.prototype,"focused",2);p([P.r()],m.prototype,"_value",2);p([P.r()],m.prototype,"_min",2);p([P.r()],m.prototype,"_max",2);p([P.r()],m.prototype,"segments",2);p([P.r()],m.prototype,"isCalendarOpen",2);p([A.e(".editable-segment")],m.prototype,"firstEditableSegment",2);p([A.e(".input")],m.prototype,"input",2);customElements.get("luzmo-date-time-picker")||customElements.define("luzmo-date-time-picker",m);exports.LuzmoDateTimePicker=m;
|