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