@vonage/vivid 4.17.0 → 4.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +3903 -3860
- package/date-time-picker/index.cjs +5 -0
- package/date-time-picker/index.js +3 -0
- package/dial-pad/index.cjs +1 -1
- package/dial-pad/index.js +1 -1
- package/dialog/index.cjs +1 -1
- package/dialog/index.js +1 -1
- package/divider/index.cjs +1 -1
- package/divider/index.js +1 -1
- package/elevation/index.cjs +1 -1
- package/elevation/index.js +1 -1
- package/empty-state/index.cjs +1 -1
- package/empty-state/index.js +1 -1
- package/fab/index.cjs +1 -1
- package/fab/index.js +1 -1
- package/file-picker/index.cjs +1 -1
- package/file-picker/index.js +1 -1
- package/header/index.cjs +1 -1
- package/header/index.js +1 -1
- package/icon/index.cjs +1 -1
- package/icon/index.js +1 -1
- package/index.cjs +136 -133
- package/index.js +45 -44
- package/layout/index.cjs +1 -1
- package/layout/index.js +1 -1
- package/lib/action-group/action-group.d.ts +449 -3
- package/lib/banner/banner.d.ts +449 -3
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +449 -1
- package/lib/checkbox/checkbox.d.ts +449 -4
- package/lib/components.d.ts +1 -0
- package/lib/date-picker/date-picker.d.ts +2182 -4
- package/lib/date-picker/date-picker.template.d.ts +2 -0
- package/lib/date-range-picker/date-range-picker.d.ts +1110 -4
- package/lib/date-range-picker/date-range-picker.template.d.ts +2 -0
- package/lib/date-time-picker/date-time-picker.d.ts +2175 -0
- package/lib/date-time-picker/date-time-picker.template.d.ts +2 -0
- package/lib/date-time-picker/definition.d.ts +1 -0
- package/lib/date-time-picker/locale.d.ts +9 -0
- package/lib/dialog/dialog.d.ts +449 -2
- package/lib/divider/divider.d.ts +448 -1
- package/lib/menu/menu.d.ts +446 -1
- package/lib/nav-disclosure/nav-disclosure.d.ts +449 -2
- package/lib/number-field/number-field.d.ts +450 -3
- package/lib/option/option.d.ts +1 -11
- package/lib/progress/progress.d.ts +449 -2
- package/lib/progress-ring/progress-ring.d.ts +449 -2
- package/lib/rich-text-editor/facades/vivid-prose-mirror.facade.d.ts +1 -0
- package/lib/rich-text-editor/rich-text-editor.d.ts +7 -4
- package/lib/select/select.d.ts +1 -5
- package/lib/selectable-box/selectable-box.d.ts +449 -2
- package/lib/slider/slider.d.ts +449 -3
- package/lib/split-button/split-button.d.ts +449 -3
- package/lib/switch/switch.d.ts +449 -2
- package/lib/tag-group/tag-group.d.ts +449 -2
- package/lib/text-anchor/text-anchor.d.ts +449 -1
- package/lib/text-area/text-area.d.ts +450 -3
- package/lib/text-field/text-field.d.ts +450 -7
- package/lib/time-picker/locale.d.ts +0 -2
- package/lib/time-picker/time-picker.d.ts +1053 -9
- package/lib/time-picker/time-picker.template.d.ts +2 -1
- package/locales/de-DE.cjs +29 -5
- package/locales/de-DE.js +29 -5
- package/locales/en-GB.cjs +29 -5
- package/locales/en-GB.js +29 -5
- package/locales/en-US.cjs +29 -5
- package/locales/en-US.js +29 -5
- package/locales/ja-JP.cjs +29 -5
- package/locales/ja-JP.js +29 -5
- package/locales/zh-CN.cjs +29 -5
- package/locales/zh-CN.js +29 -5
- package/menu/index.cjs +1 -1
- package/menu/index.js +1 -1
- package/menu-item/index.cjs +1 -1
- package/menu-item/index.js +1 -1
- package/nav/index.cjs +1 -1
- package/nav/index.js +1 -1
- package/nav-disclosure/index.cjs +1 -1
- package/nav-disclosure/index.js +1 -1
- package/nav-item/index.cjs +1 -1
- package/nav-item/index.js +1 -1
- package/note/index.cjs +1 -1
- package/note/index.js +1 -1
- package/number-field/index.cjs +1 -1
- package/number-field/index.js +1 -1
- package/option/index.cjs +1 -1
- package/option/index.js +1 -1
- package/package.json +1 -1
- package/pagination/index.cjs +1 -1
- package/pagination/index.js +1 -1
- package/popup/index.cjs +1 -1
- package/popup/index.js +1 -1
- package/progress/index.cjs +1 -1
- package/progress/index.js +1 -1
- package/progress-ring/index.cjs +1 -1
- package/progress-ring/index.js +1 -1
- package/radio/index.cjs +1 -1
- package/radio/index.js +1 -1
- package/radio-group/index.cjs +1 -1
- package/radio-group/index.js +1 -1
- package/range-slider/index.cjs +1 -1
- package/range-slider/index.js +1 -1
- package/rich-text-editor/index.cjs +1 -1
- package/rich-text-editor/index.js +1 -1
- package/searchable-select/index.cjs +1 -1
- package/searchable-select/index.js +1 -1
- package/select/index.cjs +1 -1
- package/select/index.js +1 -1
- package/selectable-box/index.cjs +1 -1
- package/selectable-box/index.js +1 -1
- package/shared/Reflector.cjs +71 -0
- package/shared/Reflector.js +69 -0
- package/shared/affix.cjs +1 -1
- package/shared/affix.js +1 -1
- package/shared/anchor.cjs +0 -10
- package/shared/anchor.js +0 -10
- package/shared/aria/delegates-aria.d.ts +454 -0
- package/shared/base-progress.js +1 -1
- package/shared/breadcrumb-item.cjs +2 -1
- package/shared/breadcrumb-item.js +2 -1
- package/shared/button.cjs +2 -13
- package/shared/button.js +2 -13
- package/shared/{presentationDate.cjs → calendar-picker.template.cjs} +730 -900
- package/shared/{presentationDate.js → calendar-picker.template.js} +672 -845
- package/shared/datetime/dateTimeStr.d.ts +6 -0
- package/shared/datetime/presentationDate.d.ts +4 -0
- package/shared/{date-picker/calendar → datetime}/presentationDateRange.d.ts +3 -3
- package/shared/datetime/presentationDateTime.d.ts +4 -0
- package/{lib/time-picker/time → shared/datetime}/time.d.ts +1 -0
- package/shared/definition.cjs +1 -1
- package/shared/definition.js +1 -1
- package/shared/definition11.cjs +8 -11
- package/shared/definition11.js +8 -11
- package/shared/definition14.cjs +2 -2
- package/shared/definition14.js +2 -2
- package/shared/definition15.cjs +3 -10
- package/shared/definition15.js +3 -10
- package/shared/definition16.cjs +29 -33
- package/shared/definition16.js +29 -33
- package/shared/definition17.cjs +1 -1
- package/shared/definition17.js +1 -1
- package/shared/definition18.cjs +56 -91
- package/shared/definition18.js +56 -91
- package/shared/definition19.cjs +68 -32
- package/shared/definition19.js +58 -22
- package/shared/definition20.cjs +253 -220
- package/shared/definition20.js +254 -220
- package/shared/definition21.cjs +200 -286
- package/shared/definition21.js +198 -284
- package/shared/definition22.cjs +302 -31
- package/shared/definition22.js +301 -30
- package/shared/definition23.cjs +37 -58
- package/shared/definition23.js +36 -57
- package/shared/definition24.cjs +50 -70
- package/shared/definition24.js +49 -69
- package/shared/definition25.cjs +75 -2475
- package/shared/definition25.js +74 -2475
- package/shared/definition26.cjs +2480 -50
- package/shared/definition26.js +2479 -48
- package/shared/definition27.cjs +53 -271
- package/shared/definition27.js +52 -269
- package/shared/definition28.cjs +271 -48
- package/shared/definition28.js +269 -47
- package/shared/definition29.cjs +37 -764
- package/shared/definition29.js +36 -758
- package/shared/definition3.cjs +2 -9
- package/shared/definition3.js +2 -9
- package/shared/definition30.cjs +739 -57
- package/shared/definition30.js +733 -56
- package/shared/definition31.cjs +93 -22
- package/shared/definition31.js +92 -21
- package/shared/definition32.cjs +28 -10
- package/shared/definition32.js +27 -9
- package/shared/definition33.cjs +10 -52
- package/shared/definition33.js +9 -51
- package/shared/definition34.cjs +30 -411
- package/shared/definition34.js +30 -412
- package/shared/definition35.cjs +422 -52
- package/shared/definition35.js +423 -53
- package/shared/definition36.cjs +53 -216
- package/shared/definition36.js +53 -215
- package/shared/definition37.cjs +201 -71
- package/shared/definition37.js +200 -70
- package/shared/definition38.cjs +53 -48
- package/shared/definition38.js +51 -46
- package/shared/definition39.cjs +57 -263
- package/shared/definition39.js +56 -262
- package/shared/definition4.cjs +2 -2
- package/shared/definition4.js +2 -2
- package/shared/definition40.cjs +220 -148
- package/shared/definition40.js +220 -148
- package/shared/definition41.cjs +143 -567
- package/shared/definition41.js +143 -568
- package/shared/definition42.cjs +596 -12573
- package/shared/definition42.js +596 -12573
- package/shared/definition43.cjs +13489 -1058
- package/shared/definition43.js +13489 -1059
- package/shared/definition44.cjs +936 -698
- package/shared/definition44.js +937 -698
- package/shared/definition45.cjs +850 -105
- package/shared/definition45.js +850 -104
- package/shared/definition46.cjs +110 -90
- package/shared/definition46.js +108 -88
- package/shared/definition47.cjs +88 -464
- package/shared/definition47.js +87 -463
- package/shared/definition48.cjs +457 -111
- package/shared/definition48.js +456 -110
- package/shared/definition49.cjs +103 -109
- package/shared/definition49.js +102 -108
- package/shared/definition5.cjs +3 -3
- package/shared/definition5.js +3 -3
- package/shared/definition50.cjs +136 -14
- package/shared/definition50.js +135 -13
- package/shared/definition51.cjs +16 -115
- package/shared/definition51.js +15 -114
- package/shared/definition52.cjs +79 -486
- package/shared/definition52.js +78 -485
- package/shared/definition53.cjs +503 -24
- package/shared/definition53.js +502 -23
- package/shared/definition54.cjs +23 -137
- package/shared/definition54.js +22 -136
- package/shared/definition55.cjs +96 -241
- package/shared/definition55.js +95 -241
- package/shared/definition56.cjs +261 -61
- package/shared/definition56.js +260 -60
- package/shared/definition57.cjs +419 -788
- package/shared/definition57.js +420 -789
- package/shared/definition58.cjs +27 -144
- package/shared/definition58.js +27 -143
- package/shared/definition59.cjs +83 -54
- package/shared/definition59.js +82 -53
- package/shared/definition6.cjs +1 -1
- package/shared/definition6.js +1 -1
- package/shared/definition60.cjs +80 -165
- package/shared/definition60.js +79 -163
- package/shared/definition61.cjs +143 -230
- package/shared/definition61.js +141 -229
- package/shared/definition62.cjs +233 -69344
- package/shared/definition62.js +232 -69343
- package/shared/definition63.cjs +69381 -28
- package/shared/definition63.js +69379 -26
- package/shared/definition64.cjs +28 -2168
- package/shared/definition64.js +27 -2166
- package/shared/definition65.cjs +2195 -0
- package/shared/definition65.js +2190 -0
- package/shared/definition7.cjs +1 -1
- package/shared/definition7.js +1 -1
- package/shared/definition8.cjs +3 -9
- package/shared/definition8.js +3 -9
- package/shared/definition9.cjs +1 -1
- package/shared/definition9.js +1 -1
- package/shared/delegates-aria.cjs +69 -0
- package/shared/delegates-aria.js +67 -0
- package/shared/form-associated.js +1 -1
- package/shared/form-elements.cjs +1 -1
- package/shared/form-elements.js +1 -1
- package/shared/foundation/anchor/anchor.d.ts +0 -8
- package/shared/foundation/button/button.d.ts +449 -7
- package/shared/foundation/listbox/listbox.d.ts +0 -9
- package/shared/listbox.cjs +4 -30
- package/shared/listbox.js +4 -30
- package/shared/localization/Locale.d.ts +6 -2
- package/shared/option.cjs +1 -38
- package/shared/option.js +1 -38
- package/shared/picker-field/locale.d.ts +4 -0
- package/shared/picker-field/mixins/calendar-picker.d.ts +558 -0
- package/shared/{date-picker/locale.d.ts → picker-field/mixins/calendar-picker.locale.d.ts} +1 -3
- package/shared/picker-field/mixins/calendar-picker.template.d.ts +555 -0
- package/shared/picker-field/mixins/calendar-segments/calendarGrid.d.ts +17 -0
- package/shared/{date-picker/calendar → picker-field/mixins/calendar-segments}/monthPickerGrid.d.ts +3 -3
- package/{lib/time-picker → shared/picker-field/mixins}/inline-time-picker/columns.d.ts +1 -1
- package/{lib/time-picker → shared/picker-field/mixins}/inline-time-picker/inline-time-picker.d.ts +2 -2
- package/{lib/time-picker/time/picker.d.ts → shared/picker-field/mixins/inline-time-picker/picker-option.d.ts} +1 -1
- package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +1110 -0
- package/shared/picker-field/mixins/single-date-picker.d.ts +1626 -0
- package/shared/picker-field/mixins/single-value-picker.d.ts +518 -0
- package/shared/picker-field/mixins/time-selection-picker.d.ts +1053 -0
- package/shared/picker-field/mixins/time-selection-picker.template.d.ts +1050 -0
- package/shared/picker-field/picker-field.d.ts +11 -0
- package/shared/picker-field/picker-field.form-associated.d.ts +11 -0
- package/shared/picker-field/picker-field.template.d.ts +7 -0
- package/shared/picker-field.template.cjs +315 -0
- package/shared/picker-field.template.js +310 -0
- package/shared/single-date-picker.cjs +46 -0
- package/shared/single-date-picker.js +44 -0
- package/shared/single-value-picker.cjs +77 -0
- package/shared/single-value-picker.js +75 -0
- package/shared/slider.template.cjs +3 -3
- package/shared/slider.template.js +3 -3
- package/shared/text-anchor.cjs +2 -1
- package/shared/text-anchor.js +2 -1
- package/shared/text-anchor.template.cjs +3 -5
- package/shared/text-anchor.template.js +3 -5
- package/shared/text-field.cjs +2 -555
- package/shared/text-field.js +2 -554
- package/shared/time-selection-picker.template.cjs +776 -0
- package/shared/time-selection-picker.template.js +767 -0
- package/shared/vivid-element.cjs +1 -1
- package/shared/vivid-element.js +1 -1
- package/side-drawer/index.cjs +1 -1
- package/side-drawer/index.js +1 -1
- package/slider/index.cjs +1 -1
- package/slider/index.js +1 -1
- package/split-button/index.cjs +1 -1
- package/split-button/index.js +1 -1
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/switch/index.cjs +1 -1
- package/switch/index.js +1 -1
- package/tab/index.cjs +1 -1
- package/tab/index.js +1 -1
- package/tab-panel/index.cjs +1 -1
- package/tab-panel/index.js +1 -1
- package/tabs/index.cjs +1 -1
- package/tabs/index.js +1 -1
- package/tag/index.cjs +1 -1
- package/tag/index.js +1 -1
- package/tag-group/index.cjs +1 -1
- package/tag-group/index.js +1 -1
- package/text-anchor/index.cjs +1 -1
- package/text-anchor/index.js +1 -1
- package/text-area/index.cjs +1 -1
- package/text-area/index.js +1 -1
- package/text-field/index.cjs +1 -1
- package/text-field/index.js +1 -1
- package/time-picker/index.cjs +1 -1
- package/time-picker/index.js +1 -1
- package/toggletip/index.cjs +1 -1
- package/toggletip/index.js +1 -1
- package/tooltip/index.cjs +1 -1
- package/tooltip/index.js +1 -1
- package/tree-item/index.cjs +1 -1
- package/tree-item/index.js +1 -1
- package/tree-view/index.cjs +1 -1
- package/tree-view/index.js +1 -1
- package/video-player/index.cjs +1 -1
- package/video-player/index.js +1 -1
- package/vivid.api.json +105 -1152
- package/lib/time-picker/time-picker.form-associated.d.ts +0 -11
- package/shared/aria-global.cjs +0 -93
- package/shared/aria-global.js +0 -91
- package/shared/date-picker/calendar/calendarGrid.d.ts +0 -17
- package/shared/date-picker/calendar/presentationDate.d.ts +0 -4
- package/shared/date-picker/date-picker-base.d.ts +0 -21
- package/shared/date-picker/date-picker-base.form-associated.d.ts +0 -11
- package/shared/date-picker/date-picker-base.template.d.ts +0 -3
- package/shared/foundation/patterns/aria-global.d.ts +0 -21
- package/shared/foundation/patterns/index.d.ts +0 -1
- package/shared/text-field2.cjs +0 -5
- package/shared/text-field2.js +0 -3
- package/shared/trapped-focus.cjs +0 -35
- package/shared/trapped-focus.js +0 -33
- /package/shared/{date-picker/calendar → datetime}/dateRange.d.ts +0 -0
- /package/shared/{date-picker/calendar → datetime}/dateStr.d.ts +0 -0
- /package/shared/{date-picker/calendar → datetime}/month.d.ts +0 -0
- /package/{lib/time-picker/time → shared/datetime}/presentationTime.d.ts +0 -0
- /package/shared/{date-picker/calendar → datetime}/year.d.ts +0 -0
- /package/shared/{date-picker/calendar → picker-field/mixins/calendar-segments}/segment.d.ts +0 -0
- /package/{lib/time-picker → shared/picker-field/mixins}/inline-time-picker/definition.d.ts +0 -0
- /package/{lib/time-picker → shared/picker-field/mixins}/inline-time-picker/inline-time-picker.template.d.ts +0 -0
|
@@ -1,21 +1,11 @@
|
|
|
1
|
+
import { o as observable, v as volatile, D as DOM, a as attr, h as html } from './vivid-element.js';
|
|
2
|
+
import { D as Divider } from './definition23.js';
|
|
1
3
|
import { B as Button } from './definition11.js';
|
|
2
|
-
import { P as Popup } from './definition64.js';
|
|
3
|
-
import { T as TextField } from './text-field.js';
|
|
4
|
-
import { D as Divider } from './definition22.js';
|
|
5
|
-
import { r as ref } from './ref.js';
|
|
6
|
-
import { s as slotted } from './slotted.js';
|
|
7
4
|
import { r as repeat } from './repeat.js';
|
|
8
5
|
import { w as when } from './when.js';
|
|
9
|
-
import { h as html, V as VividElement, O as Observable, i as defaultExecutionContext, D as DOM, a as attr, o as observable, v as volatile } from './vivid-element.js';
|
|
10
6
|
import { c as classNames } from './class-names.js';
|
|
11
|
-
import { a as applyMixinsWithObservables } from './applyMixinsWithObservables.js';
|
|
12
|
-
import { h as handleEscapeKeyAndStopPropogation } from './index.js';
|
|
13
|
-
import { F as FormAssociated } from './form-associated.js';
|
|
14
|
-
import { T as TrappedFocus } from './trapped-focus.js';
|
|
15
|
-
import { a as FormElementHelperText } from './form-elements.js';
|
|
16
|
-
import { L as Localized } from './localized.js';
|
|
17
7
|
|
|
18
|
-
const
|
|
8
|
+
const calendarStyles = ".segments{display:inline-flex;gap:24px}.segment{display:flex;flex-direction:column;gap:12px}.segment .header{display:flex;align-items:center;padding-block:8px}.segment .title{display:flex;flex-grow:1;justify-content:center}.segment .title-action{border-radius:8px;block-size:24px;font:var(--vvd-typography-base-extended);padding-inline:8px}.calendar{display:flex;flex-direction:column;margin-top:8px;gap:4px}.calendar .calendar-separator{margin-inline:10px}.calendar .calendar-weekdays{display:flex;justify-content:center}.calendar .calendar-weekday{display:inline-flex;align-items:center;justify-content:center;block-size:16px;font:var(--vvd-typography-base-condensed);inline-size:40px}.calendar .calendar-week{display:flex;justify-content:center}.calendar .calendar-day{display:inline-flex;align-items:center;justify-content:center;border-radius:50%;aspect-ratio:1/1;block-size:28px;font:var(--vvd-typography-base);margin-inline:6px;--focus-inset: -2px}.calendar .calendar-day.start,.calendar .calendar-day.end{border:2px solid var(--vvd-color-cta-50);background-color:var(--vvd-color-cta-200)}.calendar .calendar-day:before,.calendar .calendar-day:after{position:absolute;z-index:-1;display:block;width:20px;height:28px}.calendar .calendar-day:before{right:50%}.calendar .calendar-day:after{left:50%}.calendar .calendar-day.range:before,.calendar .calendar-day.range:after{background-color:var(--vvd-color-cta-50)}.calendar .calendar-day.range:not(.start):before,.calendar .calendar-day.range:not(.end):after{content:\"\"}.calendar .calendar-day.outside-month,.calendar .calendar-day:disabled{color:var(--vvd-color-neutral-400)}.months-separator{margin-inline:-12px}.month-grid{display:flex;flex-direction:column;gap:34px}.month-grid .months-row{display:flex;justify-content:center;gap:29px}.month-grid .month{display:inline-flex;align-items:center;justify-content:center;border-radius:50%;aspect-ratio:1/1;block-size:48px;font:var(--vvd-typography-base-extended);text-transform:uppercase}.month-grid .month:disabled{color:var(--vvd-color-neutral-400)}.button{--_connotation-color-primary: var(--vvd-date-picker-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-firm: var(--vvd-date-picker-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-faint: var(--vvd-date-picker-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-date-picker-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-dim: var(--vvd-date-picker-accent-dim, var(--vvd-color-neutral-200));--_connotation-color-pale: var(--vvd-date-picker-accent-pale, var(--vvd-color-neutral-300))}.button{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.button:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.button:where(.active,:active):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.button:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.button:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.button:where(.selected):where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-200);--_appearance-color-outline: transparent}.button{position:relative;padding:0;border:none;background-color:var(--_appearance-color-fill);color:var(--_appearance-color-text);cursor:pointer}.button:focus-visible{--focus-stroke-gap-color: transparent;box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px));color:var(--vvd-color-canvas-text)}.button.current{border:1px solid var(--vvd-color-neutral-200)}.button:disabled{cursor:not-allowed}";
|
|
19
9
|
|
|
20
10
|
/**
|
|
21
11
|
* @name toDate
|
|
@@ -5503,6 +5493,15 @@ const isValidDateStr = (string) => {
|
|
|
5503
5493
|
return hasThreeComponents(components) && allComponentsAreNumbers(components) && isValidDate(components);
|
|
5504
5494
|
};
|
|
5505
5495
|
|
|
5496
|
+
const formatPresentationDate = (dateStr, locale) => {
|
|
5497
|
+
const date = parseDateStr(dateStr);
|
|
5498
|
+
return format(date, locale.dateFormat);
|
|
5499
|
+
};
|
|
5500
|
+
const parsePresentationDate = (presentationDate, locale) => {
|
|
5501
|
+
const date = parse(presentationDate, locale.dateFormat, /* @__PURE__ */ new Date());
|
|
5502
|
+
return formatDateStr(date);
|
|
5503
|
+
};
|
|
5504
|
+
|
|
5506
5505
|
const getCurrentMonth = (now = /* @__PURE__ */ new Date()) => ({
|
|
5507
5506
|
month: now.getMonth(),
|
|
5508
5507
|
year: now.getFullYear()
|
|
@@ -5520,36 +5519,564 @@ const compareMonths = (a, b) => a.year === b.year ? a.month - b.month : a.year -
|
|
|
5520
5519
|
const areMonthsEqual = (a, b) => compareMonths(a, b) === 0;
|
|
5521
5520
|
const monthToStr = ({ month, year }) => `${year.toString().padStart(4, "0")}-${(month + 1).toString().padStart(2, "0")}`;
|
|
5522
5521
|
|
|
5522
|
+
const yearOfDate = (dateStr) => {
|
|
5523
|
+
const date = parseDateStr(dateStr);
|
|
5524
|
+
return date.getFullYear();
|
|
5525
|
+
};
|
|
5526
|
+
|
|
5527
|
+
const MonthsPerRow = 4;
|
|
5528
|
+
const buildMonthPickerGrid = (year, locale) => {
|
|
5529
|
+
const grid = [];
|
|
5530
|
+
let row = [];
|
|
5531
|
+
for (let i = 0; i < 12; i++) {
|
|
5532
|
+
const month = { month: i, year };
|
|
5533
|
+
row.push({
|
|
5534
|
+
label: locale.months.shorthand[i],
|
|
5535
|
+
monthName: locale.months.name[i],
|
|
5536
|
+
month
|
|
5537
|
+
});
|
|
5538
|
+
if (row.length === MonthsPerRow) {
|
|
5539
|
+
grid.push(row);
|
|
5540
|
+
row = [];
|
|
5541
|
+
}
|
|
5542
|
+
}
|
|
5543
|
+
return grid;
|
|
5544
|
+
};
|
|
5545
|
+
|
|
5546
|
+
const getWeekdays = (locale) => {
|
|
5547
|
+
const firstDayOfWeek = locale.firstDayOfWeek;
|
|
5548
|
+
const localeWeekdayToNative = (day) => (day + firstDayOfWeek) % 7;
|
|
5549
|
+
const days = [];
|
|
5550
|
+
for (let i = 0; i < 7; i++) {
|
|
5551
|
+
days.push({
|
|
5552
|
+
name: locale.weekdays.name[localeWeekdayToNative(i)],
|
|
5553
|
+
shortName: locale.weekdays.shorthand[localeWeekdayToNative(i)]
|
|
5554
|
+
});
|
|
5555
|
+
}
|
|
5556
|
+
return days;
|
|
5557
|
+
};
|
|
5558
|
+
const gridDate = (date, isOutsideMonth2) => ({
|
|
5559
|
+
date: formatDateStr(date),
|
|
5560
|
+
label: `${date.getDate()}`,
|
|
5561
|
+
isOutsideMonth: isOutsideMonth2
|
|
5562
|
+
});
|
|
5563
|
+
function isOutsideMonth(dayIndexInMonth, daysInMonth) {
|
|
5564
|
+
return dayIndexInMonth < 0 || dayIndexInMonth >= daysInMonth;
|
|
5565
|
+
}
|
|
5566
|
+
const buildDateGrid = ({ month, year }, getDay) => {
|
|
5567
|
+
const grid = [];
|
|
5568
|
+
const firstDay = new Date(year, month, 1);
|
|
5569
|
+
const lastDay = new Date(year, month + 1, 0);
|
|
5570
|
+
const firstDayInWeek = getDay(firstDay);
|
|
5571
|
+
const daysInMonth = lastDay.getDate();
|
|
5572
|
+
const daysOutsideMonthInLastWeek = 7 - getDay(lastDay);
|
|
5573
|
+
const totalDaysInCalendar = daysInMonth + firstDayInWeek + daysOutsideMonthInLastWeek;
|
|
5574
|
+
let week = [];
|
|
5575
|
+
for (let i = 0; i < totalDaysInCalendar; i++) {
|
|
5576
|
+
const dayIndexInMonth = i - firstDayInWeek;
|
|
5577
|
+
week.push(
|
|
5578
|
+
gridDate(
|
|
5579
|
+
addDays$1(firstDay, dayIndexInMonth),
|
|
5580
|
+
isOutsideMonth(dayIndexInMonth, daysInMonth)
|
|
5581
|
+
)
|
|
5582
|
+
);
|
|
5583
|
+
if (week.length === 7) {
|
|
5584
|
+
grid.push(week);
|
|
5585
|
+
week = [];
|
|
5586
|
+
}
|
|
5587
|
+
}
|
|
5588
|
+
return grid;
|
|
5589
|
+
};
|
|
5590
|
+
const buildCalendarGrid = (month, locale) => {
|
|
5591
|
+
const { firstDayOfWeek } = locale;
|
|
5592
|
+
const getShiftedDay = (date) => (date.getDay() - firstDayOfWeek + 7) % 7;
|
|
5593
|
+
return {
|
|
5594
|
+
weekdays: getWeekdays(locale),
|
|
5595
|
+
grid: buildDateGrid(month, getShiftedDay)
|
|
5596
|
+
};
|
|
5597
|
+
};
|
|
5598
|
+
|
|
5599
|
+
var __defProp$1 = Object.defineProperty;
|
|
5600
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5601
|
+
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
5602
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5603
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
5604
|
+
if (decorator = decorators[i])
|
|
5605
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
5606
|
+
if (kind && result) __defProp$1(target, key, result);
|
|
5607
|
+
return result;
|
|
5608
|
+
};
|
|
5609
|
+
const CalendarPicker = (Base) => {
|
|
5610
|
+
class CalendarPickerElement extends Base {
|
|
5611
|
+
// --- Core ---
|
|
5612
|
+
constructor(...args) {
|
|
5613
|
+
super(...args);
|
|
5614
|
+
this._selectedMonth = getCurrentMonth();
|
|
5615
|
+
/**
|
|
5616
|
+
* Today's date.
|
|
5617
|
+
* @internal
|
|
5618
|
+
*/
|
|
5619
|
+
this._currentDate = currentDateStr();
|
|
5620
|
+
/**
|
|
5621
|
+
* Today's month.
|
|
5622
|
+
* @internal
|
|
5623
|
+
*/
|
|
5624
|
+
this._currentMonth = getCurrentMonth();
|
|
5625
|
+
this._numCalendars = 1;
|
|
5626
|
+
// --- Date picker ---
|
|
5627
|
+
/**
|
|
5628
|
+
* @internal
|
|
5629
|
+
*/
|
|
5630
|
+
this._hideDatesOutsideMonth = false;
|
|
5631
|
+
this._lastFocussedDate = null;
|
|
5632
|
+
this._monthPickerYear = null;
|
|
5633
|
+
this._lastFocussedMonth = null;
|
|
5634
|
+
this.value = "";
|
|
5635
|
+
}
|
|
5636
|
+
/**
|
|
5637
|
+
* @internal
|
|
5638
|
+
*/
|
|
5639
|
+
_adjustSelectedMonthToEnsureVisibilityOf(date) {
|
|
5640
|
+
const month = monthOfDate(date);
|
|
5641
|
+
const firstDisplayedMonth = this._selectedMonth;
|
|
5642
|
+
const lastDisplayedMonth = addMonths(
|
|
5643
|
+
this._selectedMonth,
|
|
5644
|
+
this._numCalendars - 1
|
|
5645
|
+
);
|
|
5646
|
+
if (compareMonths(month, firstDisplayedMonth) < 0) {
|
|
5647
|
+
this._selectedMonth = month;
|
|
5648
|
+
return true;
|
|
5649
|
+
} else if (compareMonths(month, lastDisplayedMonth) > 0) {
|
|
5650
|
+
this._selectedMonth = addMonths(month, 1 - this._numCalendars);
|
|
5651
|
+
return true;
|
|
5652
|
+
}
|
|
5653
|
+
return false;
|
|
5654
|
+
}
|
|
5655
|
+
/**
|
|
5656
|
+
* @internal
|
|
5657
|
+
*/
|
|
5658
|
+
_isDateInValidRange(date) {
|
|
5659
|
+
return (!this._resolvedMinDate || compareDateStr(date, this._resolvedMinDate) >= 0) && (!this._resolvedMaxDate || compareDateStr(date, this._resolvedMaxDate) <= 0);
|
|
5660
|
+
}
|
|
5661
|
+
#isMonthAfterValidRange(month) {
|
|
5662
|
+
return this._resolvedMaxDate && compareMonths(month, monthOfDate(this._resolvedMaxDate)) > 0;
|
|
5663
|
+
}
|
|
5664
|
+
#isMonthBeforeValidRange(month) {
|
|
5665
|
+
return this._resolvedMinDate && compareMonths(month, monthOfDate(this._resolvedMinDate)) < 0;
|
|
5666
|
+
}
|
|
5667
|
+
/**
|
|
5668
|
+
* @internal
|
|
5669
|
+
*/
|
|
5670
|
+
_isMonthInValidRange(month) {
|
|
5671
|
+
return !(this.#isMonthBeforeValidRange(month) || this.#isMonthAfterValidRange(month));
|
|
5672
|
+
}
|
|
5673
|
+
/**
|
|
5674
|
+
* @internal
|
|
5675
|
+
*/
|
|
5676
|
+
_closePopup(restoreFocusToTextField = true) {
|
|
5677
|
+
super._closePopup(restoreFocusToTextField);
|
|
5678
|
+
this._monthPickerYear = null;
|
|
5679
|
+
}
|
|
5680
|
+
/**
|
|
5681
|
+
* @internal
|
|
5682
|
+
*/
|
|
5683
|
+
_onPickerButtonClick() {
|
|
5684
|
+
super._onPickerButtonClick();
|
|
5685
|
+
if (this._popupOpen) {
|
|
5686
|
+
DOM.processUpdates();
|
|
5687
|
+
const tabbableDate = this._tabbableDate;
|
|
5688
|
+
if (tabbableDate)
|
|
5689
|
+
this.shadowRoot.querySelector(
|
|
5690
|
+
`[data-date="${tabbableDate}"]`
|
|
5691
|
+
).focus();
|
|
5692
|
+
}
|
|
5693
|
+
}
|
|
5694
|
+
// --- Calendar header ---
|
|
5695
|
+
/**
|
|
5696
|
+
* @internal
|
|
5697
|
+
*/
|
|
5698
|
+
_onTitleActionClick() {
|
|
5699
|
+
if (this._inMonthPicker) {
|
|
5700
|
+
this._monthPickerYear = null;
|
|
5701
|
+
} else {
|
|
5702
|
+
this._monthPickerYear = this._selectedMonth.year;
|
|
5703
|
+
}
|
|
5704
|
+
}
|
|
5705
|
+
get _isPrevYearDisabled() {
|
|
5706
|
+
const currentYear = this._inMonthPicker ? this._monthPickerYear : this._selectedMonth.year;
|
|
5707
|
+
const prevYear = currentYear - 1;
|
|
5708
|
+
return this._resolvedMinDate && prevYear < yearOfDate(this._resolvedMinDate);
|
|
5709
|
+
}
|
|
5710
|
+
/**
|
|
5711
|
+
* @internal
|
|
5712
|
+
*/
|
|
5713
|
+
_onPrevYearClick() {
|
|
5714
|
+
if (this._inMonthPicker) {
|
|
5715
|
+
this._monthPickerYear = this._monthPickerYear - 1;
|
|
5716
|
+
} else {
|
|
5717
|
+
this._selectedMonth = {
|
|
5718
|
+
year: this._selectedMonth.year - 1,
|
|
5719
|
+
month: this._selectedMonth.month
|
|
5720
|
+
};
|
|
5721
|
+
}
|
|
5722
|
+
}
|
|
5723
|
+
get _isNextYearDisabled() {
|
|
5724
|
+
const currentYear = this._inMonthPicker ? this._monthPickerYear : this._selectedMonth.year;
|
|
5725
|
+
const nextYear = currentYear + 1;
|
|
5726
|
+
return this._resolvedMaxDate && nextYear > yearOfDate(this._resolvedMaxDate);
|
|
5727
|
+
}
|
|
5728
|
+
/**
|
|
5729
|
+
* @internal
|
|
5730
|
+
*/
|
|
5731
|
+
_onNextYearClick() {
|
|
5732
|
+
if (this._inMonthPicker) {
|
|
5733
|
+
this._monthPickerYear = this._monthPickerYear + 1;
|
|
5734
|
+
} else {
|
|
5735
|
+
this._selectedMonth = {
|
|
5736
|
+
year: this._selectedMonth.year + 1,
|
|
5737
|
+
month: this._selectedMonth.month
|
|
5738
|
+
};
|
|
5739
|
+
}
|
|
5740
|
+
}
|
|
5741
|
+
/**
|
|
5742
|
+
* @internal
|
|
5743
|
+
*/
|
|
5744
|
+
get _isPrevMonthDisabled() {
|
|
5745
|
+
return this.#isMonthBeforeValidRange(addMonths(this._selectedMonth, -1));
|
|
5746
|
+
}
|
|
5747
|
+
/**
|
|
5748
|
+
* @internal
|
|
5749
|
+
*/
|
|
5750
|
+
_onPrevMonthClick() {
|
|
5751
|
+
this._selectedMonth = addMonths(this._selectedMonth, -1);
|
|
5752
|
+
}
|
|
5753
|
+
/**
|
|
5754
|
+
* @internal
|
|
5755
|
+
*/
|
|
5756
|
+
get _isNextMonthDisabled() {
|
|
5757
|
+
return this.#isMonthAfterValidRange(addMonths(this._selectedMonth, 1));
|
|
5758
|
+
}
|
|
5759
|
+
/**
|
|
5760
|
+
* @internal
|
|
5761
|
+
*/
|
|
5762
|
+
_onNextMonthClick() {
|
|
5763
|
+
this._selectedMonth = addMonths(this._selectedMonth, 1);
|
|
5764
|
+
}
|
|
5765
|
+
/**
|
|
5766
|
+
* @internal
|
|
5767
|
+
*/
|
|
5768
|
+
get _segments() {
|
|
5769
|
+
const segments = [];
|
|
5770
|
+
if (this._inMonthPicker) {
|
|
5771
|
+
segments.push({
|
|
5772
|
+
id: 0,
|
|
5773
|
+
type: "month-picker",
|
|
5774
|
+
title: `${this._monthPickerYear}`,
|
|
5775
|
+
titleClickable: true,
|
|
5776
|
+
prevYearButton: true,
|
|
5777
|
+
nextYearButton: true,
|
|
5778
|
+
months: buildMonthPickerGrid(
|
|
5779
|
+
this._monthPickerYear,
|
|
5780
|
+
this.locale.calendarPicker
|
|
5781
|
+
)
|
|
5782
|
+
});
|
|
5783
|
+
} else {
|
|
5784
|
+
for (let i = 0; i < this._numCalendars; i++) {
|
|
5785
|
+
const month = addMonths(this._selectedMonth, i);
|
|
5786
|
+
const isSingle = this._numCalendars === 1;
|
|
5787
|
+
const isFirst = i === 0;
|
|
5788
|
+
const isLast = i === this._numCalendars - 1;
|
|
5789
|
+
segments.push({
|
|
5790
|
+
id: i,
|
|
5791
|
+
type: "calendar",
|
|
5792
|
+
title: `${this.locale.calendarPicker.months.name[month.month]} ${month.year}`,
|
|
5793
|
+
titleClickable: isSingle,
|
|
5794
|
+
prevYearButton: isFirst && isSingle,
|
|
5795
|
+
prevMonthButton: isFirst,
|
|
5796
|
+
nextMonthButton: isLast,
|
|
5797
|
+
nextYearButton: isLast && isSingle,
|
|
5798
|
+
calendar: buildCalendarGrid(month, this.locale.calendarPicker)
|
|
5799
|
+
});
|
|
5800
|
+
}
|
|
5801
|
+
}
|
|
5802
|
+
return segments;
|
|
5803
|
+
}
|
|
5804
|
+
/**
|
|
5805
|
+
* @internal
|
|
5806
|
+
*/
|
|
5807
|
+
_isDateSelected(_) {
|
|
5808
|
+
return false;
|
|
5809
|
+
}
|
|
5810
|
+
/**
|
|
5811
|
+
* @internal
|
|
5812
|
+
* @private
|
|
5813
|
+
*/
|
|
5814
|
+
_isDateInSelectedRange(_) {
|
|
5815
|
+
return false;
|
|
5816
|
+
}
|
|
5817
|
+
/**
|
|
5818
|
+
* @internal
|
|
5819
|
+
*/
|
|
5820
|
+
_isDateRangeStart(_) {
|
|
5821
|
+
return false;
|
|
5822
|
+
}
|
|
5823
|
+
/**
|
|
5824
|
+
* @internal
|
|
5825
|
+
*/
|
|
5826
|
+
_isDateRangeEnd(_) {
|
|
5827
|
+
return false;
|
|
5828
|
+
}
|
|
5829
|
+
/**
|
|
5830
|
+
* @internal
|
|
5831
|
+
*/
|
|
5832
|
+
_onDateMouseEnter(_) {
|
|
5833
|
+
}
|
|
5834
|
+
/**
|
|
5835
|
+
* @internal
|
|
5836
|
+
*/
|
|
5837
|
+
_onDateMouseLeave(_) {
|
|
5838
|
+
}
|
|
5839
|
+
/**
|
|
5840
|
+
* Handle keydown on a date in the calendar.
|
|
5841
|
+
* @internal
|
|
5842
|
+
*/
|
|
5843
|
+
_onDateKeydown(date, event) {
|
|
5844
|
+
let newDate = null;
|
|
5845
|
+
if (event.key === "ArrowUp") {
|
|
5846
|
+
newDate = addDays(date, -7);
|
|
5847
|
+
} else if (event.key === "ArrowDown") {
|
|
5848
|
+
newDate = addDays(date, 7);
|
|
5849
|
+
} else if (event.key === "ArrowLeft") {
|
|
5850
|
+
newDate = addDays(date, -1);
|
|
5851
|
+
} else if (event.key === "ArrowRight") {
|
|
5852
|
+
newDate = addDays(date, 1);
|
|
5853
|
+
}
|
|
5854
|
+
if (newDate && this._isDateInValidRange(newDate)) {
|
|
5855
|
+
if (this._adjustSelectedMonthToEnsureVisibilityOf(newDate)) {
|
|
5856
|
+
DOM.processUpdates();
|
|
5857
|
+
}
|
|
5858
|
+
this._dialogEl.querySelector(
|
|
5859
|
+
`[data-date="${newDate}"]`
|
|
5860
|
+
).focus();
|
|
5861
|
+
return false;
|
|
5862
|
+
}
|
|
5863
|
+
return true;
|
|
5864
|
+
}
|
|
5865
|
+
/**
|
|
5866
|
+
* @internal
|
|
5867
|
+
*/
|
|
5868
|
+
_onDateFocus(date) {
|
|
5869
|
+
this._lastFocussedDate = date;
|
|
5870
|
+
}
|
|
5871
|
+
get _tabbableDate() {
|
|
5872
|
+
const datesInSegments = this._segments.filter(
|
|
5873
|
+
(segment) => segment.type === "calendar"
|
|
5874
|
+
).flatMap((segment) => segment.calendar.grid.flat().map((d) => d.date));
|
|
5875
|
+
const candidates = [
|
|
5876
|
+
this._lastFocussedDate,
|
|
5877
|
+
...this._getSelectedDates(),
|
|
5878
|
+
currentDateStr(),
|
|
5879
|
+
...datesInSegments
|
|
5880
|
+
];
|
|
5881
|
+
const firstVisibleMonth = this._selectedMonth;
|
|
5882
|
+
const lastVisibleMonth = addMonths(
|
|
5883
|
+
this._selectedMonth,
|
|
5884
|
+
this._numCalendars - 1
|
|
5885
|
+
);
|
|
5886
|
+
return candidates.find(
|
|
5887
|
+
(date) => date && compareMonths(monthOfDate(date), firstVisibleMonth) >= 0 && compareMonths(monthOfDate(date), lastVisibleMonth) <= 0 && this._isDateInValidRange(date)
|
|
5888
|
+
) ?? null;
|
|
5889
|
+
}
|
|
5890
|
+
/**
|
|
5891
|
+
* @internal
|
|
5892
|
+
*/
|
|
5893
|
+
get _inMonthPicker() {
|
|
5894
|
+
return this._monthPickerYear !== null;
|
|
5895
|
+
}
|
|
5896
|
+
/**
|
|
5897
|
+
* Handle month selected in the month picker.
|
|
5898
|
+
* @internal
|
|
5899
|
+
*/
|
|
5900
|
+
_onMonthClick(month) {
|
|
5901
|
+
this._selectedMonth = month;
|
|
5902
|
+
this._monthPickerYear = null;
|
|
5903
|
+
}
|
|
5904
|
+
/**
|
|
5905
|
+
* Handle keydown on a month in the month picker.
|
|
5906
|
+
* @internal
|
|
5907
|
+
*/
|
|
5908
|
+
_onMonthKeydown(month, event) {
|
|
5909
|
+
let newMonth = null;
|
|
5910
|
+
if (event.key === "ArrowUp") {
|
|
5911
|
+
newMonth = addMonths(month, -4);
|
|
5912
|
+
} else if (event.key === "ArrowDown") {
|
|
5913
|
+
newMonth = addMonths(month, MonthsPerRow);
|
|
5914
|
+
} else if (event.key === "ArrowLeft") {
|
|
5915
|
+
newMonth = addMonths(month, -1);
|
|
5916
|
+
} else if (event.key === "ArrowRight") {
|
|
5917
|
+
newMonth = addMonths(month, 1);
|
|
5918
|
+
}
|
|
5919
|
+
if (newMonth && this._isMonthInValidRange(newMonth)) {
|
|
5920
|
+
if (newMonth.year !== this._monthPickerYear) {
|
|
5921
|
+
this._monthPickerYear = newMonth.year;
|
|
5922
|
+
DOM.processUpdates();
|
|
5923
|
+
}
|
|
5924
|
+
this._dialogEl.querySelector(
|
|
5925
|
+
`[data-month="${monthToStr(newMonth)}"]`
|
|
5926
|
+
).focus();
|
|
5927
|
+
return false;
|
|
5928
|
+
}
|
|
5929
|
+
return true;
|
|
5930
|
+
}
|
|
5931
|
+
/**
|
|
5932
|
+
* @internal
|
|
5933
|
+
*/
|
|
5934
|
+
_onMonthFocus(month) {
|
|
5935
|
+
this._lastFocussedMonth = month;
|
|
5936
|
+
}
|
|
5937
|
+
get _tabbableMonth() {
|
|
5938
|
+
const monthsInSegments = this._segments.filter(
|
|
5939
|
+
(segments) => segments.type === "month-picker"
|
|
5940
|
+
).flatMap((segment) => segment.months.flat().map((c) => c.month));
|
|
5941
|
+
const candidates = [
|
|
5942
|
+
this._lastFocussedMonth,
|
|
5943
|
+
this._selectedMonth,
|
|
5944
|
+
getCurrentMonth(),
|
|
5945
|
+
...monthsInSegments
|
|
5946
|
+
];
|
|
5947
|
+
return candidates.find(
|
|
5948
|
+
(month) => month && month.year === this._monthPickerYear && this._isMonthInValidRange(month)
|
|
5949
|
+
) ?? null;
|
|
5950
|
+
}
|
|
5951
|
+
}
|
|
5952
|
+
__decorateClass$1([
|
|
5953
|
+
observable
|
|
5954
|
+
], CalendarPickerElement.prototype, "_selectedMonth", 2);
|
|
5955
|
+
__decorateClass$1([
|
|
5956
|
+
volatile
|
|
5957
|
+
], CalendarPickerElement.prototype, "_isPrevYearDisabled", 1);
|
|
5958
|
+
__decorateClass$1([
|
|
5959
|
+
volatile
|
|
5960
|
+
], CalendarPickerElement.prototype, "_isNextYearDisabled", 1);
|
|
5961
|
+
__decorateClass$1([
|
|
5962
|
+
observable
|
|
5963
|
+
], CalendarPickerElement.prototype, "_numCalendars", 2);
|
|
5964
|
+
__decorateClass$1([
|
|
5965
|
+
observable
|
|
5966
|
+
], CalendarPickerElement.prototype, "_lastFocussedDate", 2);
|
|
5967
|
+
__decorateClass$1([
|
|
5968
|
+
volatile
|
|
5969
|
+
], CalendarPickerElement.prototype, "_tabbableDate", 1);
|
|
5970
|
+
__decorateClass$1([
|
|
5971
|
+
observable
|
|
5972
|
+
], CalendarPickerElement.prototype, "_monthPickerYear", 2);
|
|
5973
|
+
__decorateClass$1([
|
|
5974
|
+
observable
|
|
5975
|
+
], CalendarPickerElement.prototype, "_lastFocussedMonth", 2);
|
|
5976
|
+
__decorateClass$1([
|
|
5977
|
+
volatile
|
|
5978
|
+
], CalendarPickerElement.prototype, "_tabbableMonth", 1);
|
|
5979
|
+
return CalendarPickerElement;
|
|
5980
|
+
};
|
|
5981
|
+
|
|
5982
|
+
var __defProp = Object.defineProperty;
|
|
5983
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
5984
|
+
var result = void 0 ;
|
|
5985
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
5986
|
+
if (decorator = decorators[i])
|
|
5987
|
+
result = (decorator(target, key, result) ) || result;
|
|
5988
|
+
if (result) __defProp(target, key, result);
|
|
5989
|
+
return result;
|
|
5990
|
+
};
|
|
5991
|
+
const ValidDateFilter = {
|
|
5992
|
+
fromView: (value) => {
|
|
5993
|
+
if (value && isValidDateStr(value)) {
|
|
5994
|
+
return value;
|
|
5995
|
+
}
|
|
5996
|
+
return "";
|
|
5997
|
+
},
|
|
5998
|
+
toView(value) {
|
|
5999
|
+
return value;
|
|
6000
|
+
}
|
|
6001
|
+
};
|
|
6002
|
+
const MinMaxCalendarPicker = (SuperClass) => {
|
|
6003
|
+
class MinMaxDatePickerElement extends SuperClass {
|
|
6004
|
+
/**
|
|
6005
|
+
* @internal
|
|
6006
|
+
*/
|
|
6007
|
+
minChanged(_, newMin) {
|
|
6008
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
6009
|
+
this.proxy.min = newMin;
|
|
6010
|
+
this.validate();
|
|
6011
|
+
}
|
|
6012
|
+
}
|
|
6013
|
+
/**
|
|
6014
|
+
* @internal
|
|
6015
|
+
*/
|
|
6016
|
+
get _resolvedMinDate() {
|
|
6017
|
+
return this.min;
|
|
6018
|
+
}
|
|
6019
|
+
/**
|
|
6020
|
+
* @internal
|
|
6021
|
+
*/
|
|
6022
|
+
maxChanged(_, newMax) {
|
|
6023
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
6024
|
+
this.proxy.max = newMax;
|
|
6025
|
+
this.validate();
|
|
6026
|
+
}
|
|
6027
|
+
}
|
|
6028
|
+
/**
|
|
6029
|
+
* The latest accepted date.
|
|
6030
|
+
* @internal
|
|
6031
|
+
*/
|
|
6032
|
+
get _resolvedMaxDate() {
|
|
6033
|
+
return this.max;
|
|
6034
|
+
}
|
|
6035
|
+
constructor(...args) {
|
|
6036
|
+
super(...args);
|
|
6037
|
+
this.min = "";
|
|
6038
|
+
this.max = "";
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
__decorateClass([
|
|
6042
|
+
attr({ converter: ValidDateFilter })
|
|
6043
|
+
], MinMaxDatePickerElement.prototype, "min");
|
|
6044
|
+
__decorateClass([
|
|
6045
|
+
attr({ converter: ValidDateFilter })
|
|
6046
|
+
], MinMaxDatePickerElement.prototype, "max");
|
|
6047
|
+
return MinMaxDatePickerElement;
|
|
6048
|
+
};
|
|
6049
|
+
|
|
5523
6050
|
function renderDialogHeader(context) {
|
|
5524
6051
|
const buttonTag = context.tagFor(Button);
|
|
5525
|
-
return html
|
|
6052
|
+
return html` <div class="header">
|
|
5526
6053
|
${when(
|
|
5527
6054
|
(x) => x.prevYearButton,
|
|
5528
6055
|
html`
|
|
5529
6056
|
<${buttonTag}
|
|
5530
|
-
tabindex=
|
|
5531
|
-
class=
|
|
5532
|
-
size=
|
|
5533
|
-
icon=
|
|
5534
|
-
aria-label=
|
|
5535
|
-
?disabled=
|
|
5536
|
-
@click=
|
|
6057
|
+
tabindex='1'
|
|
6058
|
+
class='vwc-button'
|
|
6059
|
+
size='super-condensed'
|
|
6060
|
+
icon='${(_, c) => c.parent._inMonthPicker ? "chevron-left-line" : "double-chevron-left-line"}'
|
|
6061
|
+
aria-label='${(_, c) => c.parent.locale.calendarPicker.prevYearLabel}'
|
|
6062
|
+
?disabled='${(_, c) => c.parent._isPrevYearDisabled}'
|
|
6063
|
+
@click='${(_, c) => c.parent._onPrevYearClick()}'
|
|
5537
6064
|
></${buttonTag}>
|
|
5538
|
-
|
|
6065
|
+
`
|
|
5539
6066
|
)}
|
|
5540
6067
|
${when(
|
|
5541
6068
|
(x) => x.prevMonthButton,
|
|
5542
6069
|
html`
|
|
5543
6070
|
<${buttonTag}
|
|
5544
|
-
tabindex=
|
|
5545
|
-
class=
|
|
5546
|
-
size=
|
|
5547
|
-
icon=
|
|
5548
|
-
aria-label=
|
|
5549
|
-
?disabled=
|
|
5550
|
-
@click=
|
|
6071
|
+
tabindex='1'
|
|
6072
|
+
class='vwc-button'
|
|
6073
|
+
size='super-condensed'
|
|
6074
|
+
icon='chevron-left-line'
|
|
6075
|
+
aria-label='${(_, c) => c.parent.locale.calendarPicker.prevMonthLabel}'
|
|
6076
|
+
?disabled='${(_, c) => c.parent._isPrevMonthDisabled}'
|
|
6077
|
+
@click='${(_, c) => c.parent._onPrevMonthClick()}'
|
|
5551
6078
|
></${buttonTag}>
|
|
5552
|
-
|
|
6079
|
+
`
|
|
5553
6080
|
)}
|
|
5554
6081
|
<div class="title">
|
|
5555
6082
|
${when(
|
|
@@ -5583,70 +6110,71 @@ function renderDialogHeader(context) {
|
|
|
5583
6110
|
${when(
|
|
5584
6111
|
(x) => x.nextMonthButton,
|
|
5585
6112
|
html`
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
6113
|
+
<${buttonTag}
|
|
6114
|
+
tabindex='1'
|
|
6115
|
+
class='vwc-button'
|
|
6116
|
+
size='super-condensed'
|
|
6117
|
+
icon='chevron-right-line'
|
|
6118
|
+
aria-label='${(_, c) => c.parent.locale.calendarPicker.nextMonthLabel}'
|
|
6119
|
+
?disabled='${(_, c) => c.parent._isNextMonthDisabled}'
|
|
6120
|
+
@click='${(_, c) => c.parent._onNextMonthClick()}'
|
|
6121
|
+
></${buttonTag}>
|
|
6122
|
+
`
|
|
5596
6123
|
)}
|
|
5597
6124
|
${when(
|
|
5598
6125
|
(x) => x.nextYearButton,
|
|
5599
6126
|
html`
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
6127
|
+
<${buttonTag}
|
|
6128
|
+
tabindex='1'
|
|
6129
|
+
class='vwc-button'
|
|
6130
|
+
size='super-condensed'
|
|
6131
|
+
icon='${(_, c) => c.parent._inMonthPicker ? "chevron-right-line" : "double-chevron-right-line"}'
|
|
6132
|
+
aria-label='${(_, c) => c.parent.locale.calendarPicker.nextYearLabel}'
|
|
6133
|
+
?disabled='${(_, c) => c.parent._isNextYearDisabled}'
|
|
6134
|
+
@click='${(_, c) => c.parent._onNextYearClick()}'
|
|
6135
|
+
></${buttonTag}>
|
|
6136
|
+
`
|
|
5610
6137
|
)}
|
|
5611
6138
|
</div>`;
|
|
5612
6139
|
}
|
|
5613
6140
|
function renderCalendarGrid(context) {
|
|
5614
6141
|
const dividerTag = context.tagFor(Divider);
|
|
5615
|
-
return html
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
6142
|
+
return html`
|
|
6143
|
+
<div
|
|
6144
|
+
class='calendar'
|
|
6145
|
+
role='grid'
|
|
6146
|
+
aria-labelledby='${(x) => `grid-label-${x.id}`}'
|
|
6147
|
+
>
|
|
6148
|
+
<div class='calendar-weekdays' role='row'>
|
|
6149
|
+
${repeat(
|
|
5622
6150
|
(x) => x.calendar.weekdays,
|
|
5623
6151
|
html`
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
6152
|
+
<div
|
|
6153
|
+
class="calendar-weekday"
|
|
6154
|
+
role="columnheader"
|
|
6155
|
+
aria-label="${(x) => x.name}"
|
|
6156
|
+
>
|
|
6157
|
+
${(x) => x.shortName}
|
|
6158
|
+
</div>
|
|
6159
|
+
`
|
|
5632
6160
|
)}
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
6161
|
+
</div>
|
|
6162
|
+
<${dividerTag} class='calendar-separator' role='presentation'></${dividerTag}>
|
|
6163
|
+
${repeat(
|
|
5636
6164
|
(x) => x.calendar.grid,
|
|
5637
6165
|
html` <div class="calendar-week" role="row">
|
|
5638
|
-
|
|
6166
|
+
${repeat(
|
|
5639
6167
|
(x) => x,
|
|
5640
6168
|
html`
|
|
5641
|
-
|
|
6169
|
+
${when(
|
|
5642
6170
|
(x, c) => c.parentContext.parentContext.parent._hideDatesOutsideMonth && x.isOutsideMonth,
|
|
5643
6171
|
html`<div class="calendar-day"></div>`
|
|
5644
6172
|
)}
|
|
5645
|
-
|
|
6173
|
+
${when(
|
|
5646
6174
|
(x, c) => !c.parentContext.parentContext.parent._hideDatesOutsideMonth || !x.isOutsideMonth,
|
|
5647
6175
|
html` <span role="gridcell">
|
|
5648
|
-
|
|
5649
|
-
|
|
6176
|
+
<button
|
|
6177
|
+
class="${(x, c) => classNames(
|
|
5650
6178
|
"calendar-day",
|
|
5651
6179
|
"button",
|
|
5652
6180
|
[
|
|
@@ -5655,7 +6183,9 @@ function renderCalendarGrid(context) {
|
|
|
5655
6183
|
],
|
|
5656
6184
|
[
|
|
5657
6185
|
"selected",
|
|
5658
|
-
c.parentContext.parentContext.parent._isDateSelected(
|
|
6186
|
+
c.parentContext.parentContext.parent._isDateSelected(
|
|
6187
|
+
x.date
|
|
6188
|
+
)
|
|
5659
6189
|
],
|
|
5660
6190
|
[
|
|
5661
6191
|
"range",
|
|
@@ -5671,57 +6201,69 @@ function renderCalendarGrid(context) {
|
|
|
5671
6201
|
],
|
|
5672
6202
|
[
|
|
5673
6203
|
"end",
|
|
5674
|
-
c.parentContext.parentContext.parent._isDateRangeEnd(
|
|
6204
|
+
c.parentContext.parentContext.parent._isDateRangeEnd(
|
|
6205
|
+
x.date
|
|
6206
|
+
)
|
|
5675
6207
|
],
|
|
5676
6208
|
["outside-month", x.isOutsideMonth]
|
|
5677
6209
|
)}"
|
|
5678
|
-
|
|
6210
|
+
?disabled="${(x, c) => !c.parentContext.parentContext.parent._isDateInValidRange(
|
|
6211
|
+
x.date
|
|
6212
|
+
)}"
|
|
6213
|
+
tabindex="${(x, c) => x.date === c.parentContext.parentContext.parent._tabbableDate ? 2 : -1}"
|
|
6214
|
+
aria-selected="${(x, c) => c.parentContext.parentContext.parent._isDateAriaSelected(
|
|
6215
|
+
x.date
|
|
6216
|
+
)}"
|
|
6217
|
+
data-date="${(x) => x.date}"
|
|
6218
|
+
@click="${(x, c) => c.parentContext.parentContext.parent._onDateClick(
|
|
5679
6219
|
x.date
|
|
5680
6220
|
)}"
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
6221
|
+
@focus="${(x, c) => c.parentContext.parentContext.parent._onDateFocus(
|
|
6222
|
+
x.date
|
|
6223
|
+
)}"
|
|
6224
|
+
@mouseenter="${(x, c) => c.parentContext.parentContext.parent._onDateMouseEnter(
|
|
6225
|
+
x.date
|
|
6226
|
+
)}"
|
|
6227
|
+
@mouseleave="${(x, c) => c.parentContext.parentContext.parent._onDateMouseLeave(
|
|
6228
|
+
x.date
|
|
6229
|
+
)}"
|
|
6230
|
+
@keydown="${(x, c) => c.parentContext.parentContext.parent._onDateKeydown(
|
|
5689
6231
|
x.date,
|
|
5690
6232
|
c.event
|
|
5691
6233
|
)}"
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
6234
|
+
>
|
|
6235
|
+
${(x) => x.label}
|
|
6236
|
+
</button>
|
|
6237
|
+
</span>`
|
|
5696
6238
|
)}
|
|
5697
|
-
|
|
5698
|
-
|
|
6239
|
+
</div>
|
|
6240
|
+
`
|
|
5699
6241
|
)}
|
|
5700
|
-
|
|
6242
|
+
</div>`
|
|
5701
6243
|
)}`;
|
|
5702
6244
|
}
|
|
5703
6245
|
function renderMonthPickerGrid(context) {
|
|
5704
6246
|
const dividerTag = context.tagFor(Divider);
|
|
5705
6247
|
return html`
|
|
5706
6248
|
<${dividerTag}
|
|
5707
|
-
class=
|
|
5708
|
-
role=
|
|
6249
|
+
class='months-separator'
|
|
6250
|
+
role='presentation'
|
|
5709
6251
|
></${dividerTag}>
|
|
5710
6252
|
<div
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
6253
|
+
class='month-grid'
|
|
6254
|
+
role='grid'
|
|
6255
|
+
aria-labelledby='grid-label'
|
|
6256
|
+
>
|
|
6257
|
+
${repeat(
|
|
5716
6258
|
(x) => x.months,
|
|
5717
6259
|
html`
|
|
5718
|
-
|
|
5719
|
-
|
|
6260
|
+
<div class="months-row" role="row">
|
|
6261
|
+
${repeat(
|
|
5720
6262
|
(x) => x,
|
|
5721
6263
|
html`
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
6264
|
+
<span role="gridcell">
|
|
6265
|
+
<button
|
|
6266
|
+
class="${(x, c) => classNames(
|
|
5725
6267
|
"month",
|
|
5726
6268
|
"button",
|
|
5727
6269
|
[
|
|
@@ -5739,774 +6281,59 @@ function renderMonthPickerGrid(context) {
|
|
|
5739
6281
|
)
|
|
5740
6282
|
]
|
|
5741
6283
|
)}"
|
|
5742
|
-
|
|
6284
|
+
tabindex="${(x, c) => c.parentContext.parentContext.parent._tabbableMonth && areMonthsEqual(
|
|
5743
6285
|
x.month,
|
|
5744
6286
|
c.parentContext.parentContext.parent._tabbableMonth
|
|
5745
6287
|
) ? 2 : -1}"
|
|
5746
|
-
|
|
5747
|
-
|
|
6288
|
+
aria-label="${(x) => x.monthName}"
|
|
6289
|
+
aria-selected="${(x, c) => areMonthsEqual(
|
|
5748
6290
|
x.month,
|
|
5749
6291
|
c.parentContext.parentContext.parent._selectedMonth
|
|
5750
6292
|
)}"
|
|
5751
|
-
|
|
5752
|
-
|
|
6293
|
+
data-month="${(x) => monthToStr(x.month)}"
|
|
6294
|
+
?disabled="${(x, c) => !c.parentContext.parentContext.parent._isMonthInValidRange(
|
|
5753
6295
|
x.month
|
|
5754
6296
|
)}"
|
|
5755
|
-
|
|
6297
|
+
@click="${(x, c) => c.parentContext.parentContext.parent._onMonthClick(
|
|
5756
6298
|
x.month
|
|
5757
6299
|
)}"
|
|
5758
|
-
|
|
6300
|
+
@focus="${(x, c) => c.parentContext.parentContext.parent._onMonthFocus(
|
|
5759
6301
|
x.month
|
|
5760
6302
|
)}"
|
|
5761
|
-
|
|
6303
|
+
@keydown="${(x, c) => c.parentContext.parentContext.parent._onMonthKeydown(
|
|
5762
6304
|
x.month,
|
|
5763
6305
|
c.event
|
|
5764
6306
|
)}"
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
6307
|
+
>
|
|
6308
|
+
${(x) => x.label}
|
|
6309
|
+
</button>
|
|
6310
|
+
</span>
|
|
6311
|
+
`
|
|
5770
6312
|
)}
|
|
5771
|
-
|
|
5772
|
-
|
|
6313
|
+
</div>
|
|
6314
|
+
`
|
|
5773
6315
|
)}
|
|
5774
|
-
|
|
6316
|
+
</div>`;
|
|
5775
6317
|
}
|
|
5776
|
-
const
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
return html`<div class="base" @keydown="${(x, { event }) => x._onBaseKeyDown(event)}">
|
|
5781
|
-
<${textFieldTag} id="text-field"
|
|
5782
|
-
${ref("_textFieldEl")}
|
|
5783
|
-
class="control"
|
|
5784
|
-
label="${(x) => x.label}"
|
|
5785
|
-
helper-text="${(x) => x.helperText}"
|
|
5786
|
-
error-text="${(x) => x.errorValidationMessage}"
|
|
5787
|
-
placeholder="${(x) => x._textFieldPlaceholder}"
|
|
5788
|
-
size="${(x) => x._textFieldSize}"
|
|
5789
|
-
current-value="${(x) => x._presentationValue}"
|
|
5790
|
-
?disabled="${(x) => x.disabled}"
|
|
5791
|
-
?readonly="${(x) => x.readOnly}"
|
|
5792
|
-
@input="${(x, c) => x._onTextFieldInput(c.event)}"
|
|
5793
|
-
@change="${(x) => x._onTextFieldChange()}"
|
|
5794
|
-
>
|
|
5795
|
-
<slot
|
|
5796
|
-
slot="${(x) => x._helperTextSlottedContent?.length ? "helper-text" : void 0}"
|
|
5797
|
-
name="helper-text"
|
|
5798
|
-
${slotted("_helperTextSlottedContent")}
|
|
5799
|
-
></slot>
|
|
5800
|
-
<${buttonTag}
|
|
5801
|
-
id="calendar-button"
|
|
5802
|
-
${ref("_calendarButtonEl")}
|
|
5803
|
-
slot="action-items"
|
|
5804
|
-
size="condensed"
|
|
5805
|
-
icon="calendar-line"
|
|
5806
|
-
appearance="ghost"
|
|
5807
|
-
?disabled="${(x) => x.disabled || x.readOnly}"
|
|
5808
|
-
aria-label="${(x) => x._calendarButtonLabel}"
|
|
5809
|
-
@click="${(x) => x._onCalendarButtonClick()}"
|
|
5810
|
-
></${buttonTag}>
|
|
5811
|
-
</${textFieldTag}>
|
|
5812
|
-
<${popupTag}
|
|
5813
|
-
?open="${(x) => x._popupOpen}"
|
|
5814
|
-
:anchor="${(x) => x._textFieldEl}"
|
|
5815
|
-
placement="bottom-start"
|
|
5816
|
-
class="popup">
|
|
5817
|
-
<div class="dialog" role="dialog" ${ref(
|
|
5818
|
-
"_dialogEl"
|
|
5819
|
-
)} aria-modal="true" aria-label="${(x) => x.locale.datePicker.chooseDateLabel}">
|
|
5820
|
-
<div class="segments">
|
|
5821
|
-
${repeat(
|
|
6318
|
+
const CalendarPickerTemplate = (context) => {
|
|
6319
|
+
return html`
|
|
6320
|
+
<div class="segments">
|
|
6321
|
+
${repeat(
|
|
5822
6322
|
(x) => x._segments,
|
|
5823
6323
|
html` <div class="segment">
|
|
5824
|
-
|
|
5825
|
-
|
|
6324
|
+
${renderDialogHeader(context)}
|
|
6325
|
+
${when(
|
|
5826
6326
|
(x) => x.type === "month-picker",
|
|
5827
6327
|
html`${renderMonthPickerGrid(context)}`
|
|
5828
6328
|
)}
|
|
5829
|
-
|
|
6329
|
+
${when(
|
|
5830
6330
|
(x) => x.type === "calendar",
|
|
5831
6331
|
html`${renderCalendarGrid(context)}`
|
|
5832
6332
|
)}
|
|
5833
|
-
|
|
6333
|
+
</div>`
|
|
5834
6334
|
)}
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
<${buttonTag}
|
|
5838
|
-
tabindex="3"
|
|
5839
|
-
class="vwc-button"
|
|
5840
|
-
size="condensed"
|
|
5841
|
-
label="${(x) => x.locale.datePicker.clearLabel}"
|
|
5842
|
-
@click="${(x) => x._onClearClick()},
|
|
5843
|
-
${(x) => x.$emit("clear-click")}"
|
|
5844
|
-
></${buttonTag}>
|
|
5845
|
-
<${buttonTag}
|
|
5846
|
-
tabindex="3"
|
|
5847
|
-
class="vwc-button"
|
|
5848
|
-
size="condensed"
|
|
5849
|
-
appearance="filled"
|
|
5850
|
-
label="${(x) => x.locale.datePicker.okLabel}"
|
|
5851
|
-
@click="${(x) => x._onOkClick()}"
|
|
5852
|
-
></${buttonTag}>
|
|
5853
|
-
</div>
|
|
5854
|
-
</div>
|
|
5855
|
-
</${popupTag}>
|
|
5856
|
-
</div>`;
|
|
5857
|
-
};
|
|
5858
|
-
|
|
5859
|
-
const getWeekdays = (locale) => {
|
|
5860
|
-
const firstDayOfWeek = locale.firstDayOfWeek;
|
|
5861
|
-
const localeWeekdayToNative = (day) => (day + firstDayOfWeek) % 7;
|
|
5862
|
-
const days = [];
|
|
5863
|
-
for (let i = 0; i < 7; i++) {
|
|
5864
|
-
days.push({
|
|
5865
|
-
name: locale.weekdays.name[localeWeekdayToNative(i)],
|
|
5866
|
-
shortName: locale.weekdays.shorthand[localeWeekdayToNative(i)]
|
|
5867
|
-
});
|
|
5868
|
-
}
|
|
5869
|
-
return days;
|
|
5870
|
-
};
|
|
5871
|
-
const gridDate = (date, isOutsideMonth2) => ({
|
|
5872
|
-
date: formatDateStr(date),
|
|
5873
|
-
label: `${date.getDate()}`,
|
|
5874
|
-
isOutsideMonth: isOutsideMonth2
|
|
5875
|
-
});
|
|
5876
|
-
function isOutsideMonth(dayIndexInMonth, daysInMonth) {
|
|
5877
|
-
return dayIndexInMonth < 0 || dayIndexInMonth >= daysInMonth;
|
|
5878
|
-
}
|
|
5879
|
-
const buildDateGrid = ({ month, year }, getDay) => {
|
|
5880
|
-
const grid = [];
|
|
5881
|
-
const firstDay = new Date(year, month, 1);
|
|
5882
|
-
const lastDay = new Date(year, month + 1, 0);
|
|
5883
|
-
const firstDayInWeek = getDay(firstDay);
|
|
5884
|
-
const daysInMonth = lastDay.getDate();
|
|
5885
|
-
const daysOutsideMonthInLastWeek = 7 - getDay(lastDay);
|
|
5886
|
-
const totalDaysInCalendar = daysInMonth + firstDayInWeek + daysOutsideMonthInLastWeek;
|
|
5887
|
-
let week = [];
|
|
5888
|
-
for (let i = 0; i < totalDaysInCalendar; i++) {
|
|
5889
|
-
const dayIndexInMonth = i - firstDayInWeek;
|
|
5890
|
-
week.push(
|
|
5891
|
-
gridDate(
|
|
5892
|
-
addDays$1(firstDay, dayIndexInMonth),
|
|
5893
|
-
isOutsideMonth(dayIndexInMonth, daysInMonth)
|
|
5894
|
-
)
|
|
5895
|
-
);
|
|
5896
|
-
if (week.length === 7) {
|
|
5897
|
-
grid.push(week);
|
|
5898
|
-
week = [];
|
|
5899
|
-
}
|
|
5900
|
-
}
|
|
5901
|
-
return grid;
|
|
5902
|
-
};
|
|
5903
|
-
const buildCalendarGrid = (month, locale) => {
|
|
5904
|
-
const { firstDayOfWeek } = locale;
|
|
5905
|
-
const getShiftedDay = (date) => (date.getDay() - firstDayOfWeek + 7) % 7;
|
|
5906
|
-
return {
|
|
5907
|
-
weekdays: getWeekdays(locale),
|
|
5908
|
-
grid: buildDateGrid(month, getShiftedDay)
|
|
5909
|
-
};
|
|
5910
|
-
};
|
|
5911
|
-
|
|
5912
|
-
const MonthsPerRow = 4;
|
|
5913
|
-
const buildMonthPickerGrid = (year, locale) => {
|
|
5914
|
-
const grid = [];
|
|
5915
|
-
let row = [];
|
|
5916
|
-
for (let i = 0; i < 12; i++) {
|
|
5917
|
-
const month = { month: i, year };
|
|
5918
|
-
row.push({
|
|
5919
|
-
label: locale.months.shorthand[i],
|
|
5920
|
-
monthName: locale.months.name[i],
|
|
5921
|
-
month
|
|
5922
|
-
});
|
|
5923
|
-
if (row.length === MonthsPerRow) {
|
|
5924
|
-
grid.push(row);
|
|
5925
|
-
row = [];
|
|
5926
|
-
}
|
|
5927
|
-
}
|
|
5928
|
-
return grid;
|
|
5929
|
-
};
|
|
5930
|
-
|
|
5931
|
-
const yearOfDate = (dateStr) => {
|
|
5932
|
-
const date = parseDateStr(dateStr);
|
|
5933
|
-
return date.getFullYear();
|
|
5934
|
-
};
|
|
5935
|
-
|
|
5936
|
-
class _DatePickerBase extends VividElement {
|
|
5937
|
-
}
|
|
5938
|
-
class FormAssociatedDatePickerBase extends FormAssociated(
|
|
5939
|
-
_DatePickerBase
|
|
5940
|
-
) {
|
|
5941
|
-
constructor() {
|
|
5942
|
-
super(...arguments);
|
|
5943
|
-
this.proxy = document.createElement("input");
|
|
5944
|
-
}
|
|
5945
|
-
}
|
|
5946
|
-
|
|
5947
|
-
var __defProp = Object.defineProperty;
|
|
5948
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5949
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
5950
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5951
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
5952
|
-
if (decorator = decorators[i])
|
|
5953
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
5954
|
-
if (kind && result) __defProp(target, key, result);
|
|
5955
|
-
return result;
|
|
5956
|
-
};
|
|
5957
|
-
const ValidDateFilter = {
|
|
5958
|
-
fromView: (value) => {
|
|
5959
|
-
if (value && isValidDateStr(value)) {
|
|
5960
|
-
return value;
|
|
5961
|
-
}
|
|
5962
|
-
return "";
|
|
5963
|
-
},
|
|
5964
|
-
toView(value) {
|
|
5965
|
-
return value;
|
|
5966
|
-
}
|
|
5967
|
-
};
|
|
5968
|
-
class DatePickerBase extends FormAssociatedDatePickerBase {
|
|
5969
|
-
// --- Core ---
|
|
5970
|
-
constructor() {
|
|
5971
|
-
super();
|
|
5972
|
-
this.readOnly = false;
|
|
5973
|
-
this._selectedMonth = getCurrentMonth();
|
|
5974
|
-
/**
|
|
5975
|
-
* Today's date.
|
|
5976
|
-
* @internal
|
|
5977
|
-
*/
|
|
5978
|
-
this._currentDate = currentDateStr();
|
|
5979
|
-
/**
|
|
5980
|
-
* Today's month.
|
|
5981
|
-
* @internal
|
|
5982
|
-
*/
|
|
5983
|
-
this._currentMonth = getCurrentMonth();
|
|
5984
|
-
this.#onFocusIn = () => {
|
|
5985
|
-
this.$emit("focus", void 0, { bubbles: false });
|
|
5986
|
-
};
|
|
5987
|
-
this.#onFocusOut = () => {
|
|
5988
|
-
this.$emit("blur", void 0, { bubbles: false });
|
|
5989
|
-
};
|
|
5990
|
-
// Reformat the presentation value when the locale changes
|
|
5991
|
-
this.#localeChangeHandler = {
|
|
5992
|
-
handleChange: () => {
|
|
5993
|
-
this._updatePresentationValue();
|
|
5994
|
-
}
|
|
5995
|
-
};
|
|
5996
|
-
this._popupOpen = false;
|
|
5997
|
-
this.#dismissOnClickOutside = (event) => {
|
|
5998
|
-
if (!this._popupOpen) {
|
|
5999
|
-
return;
|
|
6000
|
-
}
|
|
6001
|
-
const path = event.composedPath();
|
|
6002
|
-
const elementsToIgnoreClicksOn = [this._dialogEl, this._calendarButtonEl];
|
|
6003
|
-
if (!elementsToIgnoreClicksOn.some((element) => path.includes(element))) {
|
|
6004
|
-
this._closePopup(false);
|
|
6005
|
-
}
|
|
6006
|
-
};
|
|
6007
|
-
this._presentationValue = "";
|
|
6008
|
-
this._numCalendars = 1;
|
|
6009
|
-
/**
|
|
6010
|
-
* @internal
|
|
6011
|
-
*/
|
|
6012
|
-
this._hideDatesOutsideMonth = false;
|
|
6013
|
-
this._lastFocussedDate = null;
|
|
6014
|
-
this._monthPickerYear = null;
|
|
6015
|
-
this._lastFocussedMonth = null;
|
|
6016
|
-
this.value = "";
|
|
6017
|
-
this.min = "";
|
|
6018
|
-
this.max = "";
|
|
6019
|
-
}
|
|
6020
|
-
/**
|
|
6021
|
-
* @internal
|
|
6022
|
-
*/
|
|
6023
|
-
minChanged(_, newMin) {
|
|
6024
|
-
if (this.proxy instanceof HTMLInputElement) {
|
|
6025
|
-
this.proxy.min = newMin;
|
|
6026
|
-
this.validate();
|
|
6027
|
-
}
|
|
6028
|
-
}
|
|
6029
|
-
/**
|
|
6030
|
-
* @internal
|
|
6031
|
-
*/
|
|
6032
|
-
maxChanged(_, newMax) {
|
|
6033
|
-
if (this.proxy instanceof HTMLInputElement) {
|
|
6034
|
-
this.proxy.max = newMax;
|
|
6035
|
-
this.validate();
|
|
6036
|
-
}
|
|
6037
|
-
}
|
|
6038
|
-
/**
|
|
6039
|
-
* @internal
|
|
6040
|
-
*/
|
|
6041
|
-
readOnlyChanged() {
|
|
6042
|
-
if (this.proxy instanceof HTMLInputElement) {
|
|
6043
|
-
this.proxy.readOnly = this.readOnly;
|
|
6044
|
-
this.validate();
|
|
6045
|
-
}
|
|
6046
|
-
}
|
|
6047
|
-
_adjustSelectedMonthToEnsureVisibilityOf(date) {
|
|
6048
|
-
const month = monthOfDate(date);
|
|
6049
|
-
const firstDisplayedMonth = this._selectedMonth;
|
|
6050
|
-
const lastDisplayedMonth = addMonths(
|
|
6051
|
-
this._selectedMonth,
|
|
6052
|
-
this._numCalendars - 1
|
|
6053
|
-
);
|
|
6054
|
-
if (compareMonths(month, firstDisplayedMonth) < 0) {
|
|
6055
|
-
this._selectedMonth = month;
|
|
6056
|
-
return true;
|
|
6057
|
-
} else if (compareMonths(month, lastDisplayedMonth) > 0) {
|
|
6058
|
-
this._selectedMonth = addMonths(month, 1 - this._numCalendars);
|
|
6059
|
-
return true;
|
|
6060
|
-
}
|
|
6061
|
-
return false;
|
|
6062
|
-
}
|
|
6063
|
-
/**
|
|
6064
|
-
* @internal
|
|
6065
|
-
*/
|
|
6066
|
-
_isDateInValidRange(date) {
|
|
6067
|
-
return (!this.min || compareDateStr(date, this.min) >= 0) && (!this.max || compareDateStr(date, this.max) <= 0);
|
|
6068
|
-
}
|
|
6069
|
-
#isMonthAfterValidRange(month) {
|
|
6070
|
-
return this.max && compareMonths(month, monthOfDate(this.max)) > 0;
|
|
6071
|
-
}
|
|
6072
|
-
#isMonthBeforeValidRange(month) {
|
|
6073
|
-
return this.min && compareMonths(month, monthOfDate(this.min)) < 0;
|
|
6074
|
-
}
|
|
6075
|
-
/**
|
|
6076
|
-
* @internal
|
|
6077
|
-
*/
|
|
6078
|
-
_isMonthInValidRange(month) {
|
|
6079
|
-
return !(this.#isMonthBeforeValidRange(month) || this.#isMonthAfterValidRange(month));
|
|
6080
|
-
}
|
|
6081
|
-
connectedCallback() {
|
|
6082
|
-
super.connectedCallback();
|
|
6083
|
-
document.addEventListener("click", this.#dismissOnClickOutside);
|
|
6084
|
-
this.addEventListener("focusin", this.#onFocusIn);
|
|
6085
|
-
this.addEventListener("focusout", this.#onFocusOut);
|
|
6086
|
-
this.#localeChangeObserver = Observable.binding(
|
|
6087
|
-
() => this.locale,
|
|
6088
|
-
this.#localeChangeHandler
|
|
6089
|
-
);
|
|
6090
|
-
this.#localeChangeObserver.observe(this, defaultExecutionContext);
|
|
6091
|
-
}
|
|
6092
|
-
disconnectedCallback() {
|
|
6093
|
-
super.disconnectedCallback();
|
|
6094
|
-
document.removeEventListener("click", this.#dismissOnClickOutside);
|
|
6095
|
-
this.removeEventListener("focusin", this.#onFocusIn);
|
|
6096
|
-
this.removeEventListener("focusout", this.#onFocusOut);
|
|
6097
|
-
this.#localeChangeObserver.disconnect();
|
|
6098
|
-
}
|
|
6099
|
-
#onFocusIn;
|
|
6100
|
-
#onFocusOut;
|
|
6101
|
-
/**
|
|
6102
|
-
* @internal
|
|
6103
|
-
*/
|
|
6104
|
-
validate() {
|
|
6105
|
-
if (this.proxy) {
|
|
6106
|
-
this.proxy.setCustomValidity(this._getCustomValidationError() ?? "");
|
|
6107
|
-
}
|
|
6108
|
-
super.validate(this._textFieldEl?.querySelector("input") ?? void 0);
|
|
6109
|
-
}
|
|
6110
|
-
#localeChangeHandler;
|
|
6111
|
-
#localeChangeObserver;
|
|
6112
|
-
#dismissOnClickOutside;
|
|
6113
|
-
#openPopupIfPossible() {
|
|
6114
|
-
if (!this.readOnly) {
|
|
6115
|
-
this._popupOpen = true;
|
|
6116
|
-
}
|
|
6117
|
-
}
|
|
6118
|
-
/**
|
|
6119
|
-
* @internal
|
|
6120
|
-
*/
|
|
6121
|
-
_closePopup(restoreFocusToTextField = true) {
|
|
6122
|
-
this._popupOpen = false;
|
|
6123
|
-
this._monthPickerYear = null;
|
|
6124
|
-
if (restoreFocusToTextField) {
|
|
6125
|
-
this._textFieldEl.focus();
|
|
6126
|
-
}
|
|
6127
|
-
}
|
|
6128
|
-
/**
|
|
6129
|
-
* On keydown anywhere in the date picker.
|
|
6130
|
-
* @internal
|
|
6131
|
-
*/
|
|
6132
|
-
_onBaseKeyDown(event) {
|
|
6133
|
-
if (this._popupOpen && handleEscapeKeyAndStopPropogation(event)) {
|
|
6134
|
-
this._closePopup();
|
|
6135
|
-
return false;
|
|
6136
|
-
}
|
|
6137
|
-
if (this._trappedFocus(
|
|
6138
|
-
event,
|
|
6139
|
-
() => this.shadowRoot.querySelectorAll(`
|
|
6140
|
-
.dialog .button:not(:disabled),
|
|
6141
|
-
.dialog .vwc-button:not(:disabled)
|
|
6142
|
-
`)
|
|
6143
|
-
)) {
|
|
6144
|
-
return false;
|
|
6145
|
-
}
|
|
6146
|
-
return true;
|
|
6147
|
-
}
|
|
6148
|
-
/**
|
|
6149
|
-
* @internal
|
|
6150
|
-
*/
|
|
6151
|
-
_presentationValueChanged() {
|
|
6152
|
-
this.dirtyValue = true;
|
|
6153
|
-
this.validate();
|
|
6154
|
-
}
|
|
6155
|
-
/**
|
|
6156
|
-
* @internal
|
|
6157
|
-
*/
|
|
6158
|
-
_onTextFieldInput(event) {
|
|
6159
|
-
const textField = event.currentTarget;
|
|
6160
|
-
this._presentationValue = textField.value;
|
|
6161
|
-
}
|
|
6162
|
-
/**
|
|
6163
|
-
* @internal
|
|
6164
|
-
*/
|
|
6165
|
-
_onCalendarButtonClick() {
|
|
6166
|
-
if (this._popupOpen) {
|
|
6167
|
-
this._closePopup();
|
|
6168
|
-
} else {
|
|
6169
|
-
this.#openPopupIfPossible();
|
|
6170
|
-
DOM.processUpdates();
|
|
6171
|
-
const tabbableDate = this._tabbableDate;
|
|
6172
|
-
if (tabbableDate)
|
|
6173
|
-
this.shadowRoot.querySelector(
|
|
6174
|
-
`[data-date="${tabbableDate}"]`
|
|
6175
|
-
).focus();
|
|
6176
|
-
}
|
|
6177
|
-
}
|
|
6178
|
-
// --- Dialog header ---
|
|
6179
|
-
/**
|
|
6180
|
-
* @internal
|
|
6181
|
-
*/
|
|
6182
|
-
_onTitleActionClick() {
|
|
6183
|
-
if (this._inMonthPicker) {
|
|
6184
|
-
this._monthPickerYear = null;
|
|
6185
|
-
} else {
|
|
6186
|
-
this._monthPickerYear = this._selectedMonth.year;
|
|
6187
|
-
}
|
|
6188
|
-
}
|
|
6189
|
-
get _isPrevYearDisabled() {
|
|
6190
|
-
const currentYear = this._inMonthPicker ? this._monthPickerYear : this._selectedMonth.year;
|
|
6191
|
-
const prevYear = currentYear - 1;
|
|
6192
|
-
return this.min && prevYear < yearOfDate(this.min);
|
|
6193
|
-
}
|
|
6194
|
-
/**
|
|
6195
|
-
* @internal
|
|
6196
|
-
*/
|
|
6197
|
-
_onPrevYearClick() {
|
|
6198
|
-
if (this._inMonthPicker) {
|
|
6199
|
-
this._monthPickerYear = this._monthPickerYear - 1;
|
|
6200
|
-
} else {
|
|
6201
|
-
this._selectedMonth = {
|
|
6202
|
-
year: this._selectedMonth.year - 1,
|
|
6203
|
-
month: this._selectedMonth.month
|
|
6204
|
-
};
|
|
6205
|
-
}
|
|
6206
|
-
}
|
|
6207
|
-
get _isNextYearDisabled() {
|
|
6208
|
-
const currentYear = this._inMonthPicker ? this._monthPickerYear : this._selectedMonth.year;
|
|
6209
|
-
const nextYear = currentYear + 1;
|
|
6210
|
-
return this.max && nextYear > yearOfDate(this.max);
|
|
6211
|
-
}
|
|
6212
|
-
/**
|
|
6213
|
-
* @internal
|
|
6214
|
-
*/
|
|
6215
|
-
_onNextYearClick() {
|
|
6216
|
-
if (this._inMonthPicker) {
|
|
6217
|
-
this._monthPickerYear = this._monthPickerYear + 1;
|
|
6218
|
-
} else {
|
|
6219
|
-
this._selectedMonth = {
|
|
6220
|
-
year: this._selectedMonth.year + 1,
|
|
6221
|
-
month: this._selectedMonth.month
|
|
6222
|
-
};
|
|
6223
|
-
}
|
|
6224
|
-
}
|
|
6225
|
-
/**
|
|
6226
|
-
* @internal
|
|
6227
|
-
*/
|
|
6228
|
-
get _isPrevMonthDisabled() {
|
|
6229
|
-
return this.#isMonthBeforeValidRange(addMonths(this._selectedMonth, -1));
|
|
6230
|
-
}
|
|
6231
|
-
/**
|
|
6232
|
-
* @internal
|
|
6233
|
-
*/
|
|
6234
|
-
_onPrevMonthClick() {
|
|
6235
|
-
this._selectedMonth = addMonths(this._selectedMonth, -1);
|
|
6236
|
-
}
|
|
6237
|
-
/**
|
|
6238
|
-
* @internal
|
|
6239
|
-
*/
|
|
6240
|
-
get _isNextMonthDisabled() {
|
|
6241
|
-
return this.#isMonthAfterValidRange(addMonths(this._selectedMonth, 1));
|
|
6242
|
-
}
|
|
6243
|
-
/**
|
|
6244
|
-
* @internal
|
|
6245
|
-
*/
|
|
6246
|
-
_onNextMonthClick() {
|
|
6247
|
-
this._selectedMonth = addMonths(this._selectedMonth, 1);
|
|
6248
|
-
}
|
|
6249
|
-
/**
|
|
6250
|
-
* @internal
|
|
6251
|
-
*/
|
|
6252
|
-
get _segments() {
|
|
6253
|
-
const segments = [];
|
|
6254
|
-
if (this._inMonthPicker) {
|
|
6255
|
-
segments.push({
|
|
6256
|
-
id: 0,
|
|
6257
|
-
type: "month-picker",
|
|
6258
|
-
title: `${this._monthPickerYear}`,
|
|
6259
|
-
titleClickable: true,
|
|
6260
|
-
prevYearButton: true,
|
|
6261
|
-
nextYearButton: true,
|
|
6262
|
-
months: buildMonthPickerGrid(
|
|
6263
|
-
this._monthPickerYear,
|
|
6264
|
-
this.locale.datePicker
|
|
6265
|
-
)
|
|
6266
|
-
});
|
|
6267
|
-
} else {
|
|
6268
|
-
for (let i = 0; i < this._numCalendars; i++) {
|
|
6269
|
-
const month = addMonths(this._selectedMonth, i);
|
|
6270
|
-
const isSingle = this._numCalendars === 1;
|
|
6271
|
-
const isFirst = i === 0;
|
|
6272
|
-
const isLast = i === this._numCalendars - 1;
|
|
6273
|
-
segments.push({
|
|
6274
|
-
id: i,
|
|
6275
|
-
type: "calendar",
|
|
6276
|
-
title: `${this.locale.datePicker.months.name[month.month]} ${month.year}`,
|
|
6277
|
-
titleClickable: isSingle,
|
|
6278
|
-
prevYearButton: isFirst && isSingle,
|
|
6279
|
-
prevMonthButton: isFirst,
|
|
6280
|
-
nextMonthButton: isLast,
|
|
6281
|
-
nextYearButton: isLast && isSingle,
|
|
6282
|
-
calendar: buildCalendarGrid(month, this.locale.datePicker)
|
|
6283
|
-
});
|
|
6284
|
-
}
|
|
6285
|
-
}
|
|
6286
|
-
return segments;
|
|
6287
|
-
}
|
|
6288
|
-
/**
|
|
6289
|
-
* @internal
|
|
6290
|
-
*/
|
|
6291
|
-
_isDateSelected(_) {
|
|
6292
|
-
return false;
|
|
6293
|
-
}
|
|
6294
|
-
/**
|
|
6295
|
-
* @internal
|
|
6296
|
-
*/
|
|
6297
|
-
_isDateInSelectedRange(_) {
|
|
6298
|
-
return false;
|
|
6299
|
-
}
|
|
6300
|
-
/**
|
|
6301
|
-
* @internal
|
|
6302
|
-
*/
|
|
6303
|
-
_isDateRangeStart(_) {
|
|
6304
|
-
return false;
|
|
6305
|
-
}
|
|
6306
|
-
/**
|
|
6307
|
-
* @internal
|
|
6308
|
-
*/
|
|
6309
|
-
_isDateRangeEnd(_) {
|
|
6310
|
-
return false;
|
|
6311
|
-
}
|
|
6312
|
-
/**
|
|
6313
|
-
* @internal
|
|
6314
|
-
*/
|
|
6315
|
-
_onDateMouseEnter(_) {
|
|
6316
|
-
}
|
|
6317
|
-
/**
|
|
6318
|
-
* @internal
|
|
6319
|
-
*/
|
|
6320
|
-
_onDateMouseLeave(_) {
|
|
6321
|
-
}
|
|
6322
|
-
/**
|
|
6323
|
-
* Handle keydown on a date in the calendar.
|
|
6324
|
-
* @internal
|
|
6325
|
-
*/
|
|
6326
|
-
_onDateKeydown(date, event) {
|
|
6327
|
-
let newDate = null;
|
|
6328
|
-
if (event.key === "ArrowUp") {
|
|
6329
|
-
newDate = addDays(date, -7);
|
|
6330
|
-
} else if (event.key === "ArrowDown") {
|
|
6331
|
-
newDate = addDays(date, 7);
|
|
6332
|
-
} else if (event.key === "ArrowLeft") {
|
|
6333
|
-
newDate = addDays(date, -1);
|
|
6334
|
-
} else if (event.key === "ArrowRight") {
|
|
6335
|
-
newDate = addDays(date, 1);
|
|
6336
|
-
}
|
|
6337
|
-
if (newDate && this._isDateInValidRange(newDate)) {
|
|
6338
|
-
if (this._adjustSelectedMonthToEnsureVisibilityOf(newDate)) {
|
|
6339
|
-
DOM.processUpdates();
|
|
6340
|
-
}
|
|
6341
|
-
this._dialogEl.querySelector(
|
|
6342
|
-
`[data-date="${newDate}"]`
|
|
6343
|
-
).focus();
|
|
6344
|
-
return false;
|
|
6345
|
-
}
|
|
6346
|
-
return true;
|
|
6347
|
-
}
|
|
6348
|
-
/**
|
|
6349
|
-
* @internal
|
|
6350
|
-
*/
|
|
6351
|
-
_onDateFocus(date) {
|
|
6352
|
-
this._lastFocussedDate = date;
|
|
6353
|
-
}
|
|
6354
|
-
get _tabbableDate() {
|
|
6355
|
-
const datesInSegments = this._segments.filter(
|
|
6356
|
-
(segment) => segment.type === "calendar"
|
|
6357
|
-
).flatMap((segment) => segment.calendar.grid.flat().map((d) => d.date));
|
|
6358
|
-
const candidates = [
|
|
6359
|
-
this._lastFocussedDate,
|
|
6360
|
-
...this._getSelectedDates(),
|
|
6361
|
-
currentDateStr(),
|
|
6362
|
-
...datesInSegments
|
|
6363
|
-
];
|
|
6364
|
-
const firstVisibleMonth = this._selectedMonth;
|
|
6365
|
-
const lastVisibleMonth = addMonths(
|
|
6366
|
-
this._selectedMonth,
|
|
6367
|
-
this._numCalendars - 1
|
|
6368
|
-
);
|
|
6369
|
-
return candidates.find(
|
|
6370
|
-
(date) => date && compareMonths(monthOfDate(date), firstVisibleMonth) >= 0 && compareMonths(monthOfDate(date), lastVisibleMonth) <= 0 && this._isDateInValidRange(date)
|
|
6371
|
-
) ?? null;
|
|
6372
|
-
}
|
|
6373
|
-
/**
|
|
6374
|
-
* @internal
|
|
6375
|
-
*/
|
|
6376
|
-
get _inMonthPicker() {
|
|
6377
|
-
return this._monthPickerYear !== null;
|
|
6378
|
-
}
|
|
6379
|
-
/**
|
|
6380
|
-
* Handle month selected in the month picker.
|
|
6381
|
-
* @internal
|
|
6382
|
-
*/
|
|
6383
|
-
_onMonthClick(month) {
|
|
6384
|
-
this._selectedMonth = month;
|
|
6385
|
-
this._monthPickerYear = null;
|
|
6386
|
-
}
|
|
6387
|
-
/**
|
|
6388
|
-
* Handle keydown on a month in the month picker.
|
|
6389
|
-
* @internal
|
|
6390
|
-
*/
|
|
6391
|
-
_onMonthKeydown(month, event) {
|
|
6392
|
-
let newMonth = null;
|
|
6393
|
-
if (event.key === "ArrowUp") {
|
|
6394
|
-
newMonth = addMonths(month, -4);
|
|
6395
|
-
} else if (event.key === "ArrowDown") {
|
|
6396
|
-
newMonth = addMonths(month, MonthsPerRow);
|
|
6397
|
-
} else if (event.key === "ArrowLeft") {
|
|
6398
|
-
newMonth = addMonths(month, -1);
|
|
6399
|
-
} else if (event.key === "ArrowRight") {
|
|
6400
|
-
newMonth = addMonths(month, 1);
|
|
6401
|
-
}
|
|
6402
|
-
if (newMonth && this._isMonthInValidRange(newMonth)) {
|
|
6403
|
-
if (newMonth.year !== this._monthPickerYear) {
|
|
6404
|
-
this._monthPickerYear = newMonth.year;
|
|
6405
|
-
DOM.processUpdates();
|
|
6406
|
-
}
|
|
6407
|
-
this._dialogEl.querySelector(
|
|
6408
|
-
`[data-month="${monthToStr(newMonth)}"]`
|
|
6409
|
-
).focus();
|
|
6410
|
-
return false;
|
|
6411
|
-
}
|
|
6412
|
-
return true;
|
|
6413
|
-
}
|
|
6414
|
-
/**
|
|
6415
|
-
* @internal
|
|
6416
|
-
*/
|
|
6417
|
-
_onMonthFocus(month) {
|
|
6418
|
-
this._lastFocussedMonth = month;
|
|
6419
|
-
}
|
|
6420
|
-
get _tabbableMonth() {
|
|
6421
|
-
const monthsInSegments = this._segments.filter(
|
|
6422
|
-
(segments) => segments.type === "month-picker"
|
|
6423
|
-
).flatMap((segment) => segment.months.flat().map((c) => c.month));
|
|
6424
|
-
const candidates = [
|
|
6425
|
-
this._lastFocussedMonth,
|
|
6426
|
-
this._selectedMonth,
|
|
6427
|
-
getCurrentMonth(),
|
|
6428
|
-
...monthsInSegments
|
|
6429
|
-
];
|
|
6430
|
-
return candidates.find(
|
|
6431
|
-
(month) => month && month.year === this._monthPickerYear && this._isMonthInValidRange(month)
|
|
6432
|
-
) ?? null;
|
|
6433
|
-
}
|
|
6434
|
-
// --- Dialog footer ---
|
|
6435
|
-
/**
|
|
6436
|
-
* @internal
|
|
6437
|
-
*/
|
|
6438
|
-
_onOkClick() {
|
|
6439
|
-
this._closePopup();
|
|
6440
|
-
}
|
|
6441
|
-
/**
|
|
6442
|
-
* @internal
|
|
6443
|
-
*/
|
|
6444
|
-
_onClearClick() {
|
|
6445
|
-
this._closePopup();
|
|
6446
|
-
}
|
|
6447
|
-
}
|
|
6448
|
-
__decorateClass([
|
|
6449
|
-
attr({ converter: ValidDateFilter })
|
|
6450
|
-
], DatePickerBase.prototype, "min", 2);
|
|
6451
|
-
__decorateClass([
|
|
6452
|
-
attr({ converter: ValidDateFilter })
|
|
6453
|
-
], DatePickerBase.prototype, "max", 2);
|
|
6454
|
-
__decorateClass([
|
|
6455
|
-
attr({ attribute: "value" })
|
|
6456
|
-
], DatePickerBase.prototype, "initialValue", 2);
|
|
6457
|
-
__decorateClass([
|
|
6458
|
-
attr({ attribute: "current-value" })
|
|
6459
|
-
], DatePickerBase.prototype, "currentValue", 2);
|
|
6460
|
-
__decorateClass([
|
|
6461
|
-
attr({ attribute: "readonly", mode: "boolean" })
|
|
6462
|
-
], DatePickerBase.prototype, "readOnly", 2);
|
|
6463
|
-
__decorateClass([
|
|
6464
|
-
observable
|
|
6465
|
-
], DatePickerBase.prototype, "_selectedMonth", 2);
|
|
6466
|
-
__decorateClass([
|
|
6467
|
-
observable
|
|
6468
|
-
], DatePickerBase.prototype, "_popupOpen", 2);
|
|
6469
|
-
__decorateClass([
|
|
6470
|
-
observable
|
|
6471
|
-
], DatePickerBase.prototype, "_presentationValue", 2);
|
|
6472
|
-
__decorateClass([
|
|
6473
|
-
volatile
|
|
6474
|
-
], DatePickerBase.prototype, "_isPrevYearDisabled", 1);
|
|
6475
|
-
__decorateClass([
|
|
6476
|
-
volatile
|
|
6477
|
-
], DatePickerBase.prototype, "_isNextYearDisabled", 1);
|
|
6478
|
-
__decorateClass([
|
|
6479
|
-
observable
|
|
6480
|
-
], DatePickerBase.prototype, "_numCalendars", 2);
|
|
6481
|
-
__decorateClass([
|
|
6482
|
-
observable
|
|
6483
|
-
], DatePickerBase.prototype, "_lastFocussedDate", 2);
|
|
6484
|
-
__decorateClass([
|
|
6485
|
-
volatile
|
|
6486
|
-
], DatePickerBase.prototype, "_tabbableDate", 1);
|
|
6487
|
-
__decorateClass([
|
|
6488
|
-
observable
|
|
6489
|
-
], DatePickerBase.prototype, "_monthPickerYear", 2);
|
|
6490
|
-
__decorateClass([
|
|
6491
|
-
observable
|
|
6492
|
-
], DatePickerBase.prototype, "_lastFocussedMonth", 2);
|
|
6493
|
-
__decorateClass([
|
|
6494
|
-
volatile
|
|
6495
|
-
], DatePickerBase.prototype, "_tabbableMonth", 1);
|
|
6496
|
-
applyMixinsWithObservables(
|
|
6497
|
-
DatePickerBase,
|
|
6498
|
-
Localized,
|
|
6499
|
-
FormElementHelperText,
|
|
6500
|
-
TrappedFocus
|
|
6501
|
-
);
|
|
6502
|
-
|
|
6503
|
-
const formatPresentationDate = (dateStr, locale) => {
|
|
6504
|
-
const date = parseDateStr(dateStr);
|
|
6505
|
-
return format(date, locale.dateFormat);
|
|
6506
|
-
};
|
|
6507
|
-
const parsePresentationDate = (presentationDate, locale) => {
|
|
6508
|
-
const date = parse(presentationDate, locale.dateFormat, /* @__PURE__ */ new Date());
|
|
6509
|
-
return formatDateStr(date);
|
|
6335
|
+
</div>
|
|
6336
|
+
`;
|
|
6510
6337
|
};
|
|
6511
6338
|
|
|
6512
|
-
export {
|
|
6339
|
+
export { CalendarPicker as C, MinMaxCalendarPicker as M, ValidDateFilter as V, CalendarPickerTemplate as a, compareDateStr as b, calendarStyles as c, currentDateStr as d, formatPresentationDate as f, isValidDateStr as i, parsePresentationDate as p };
|