@vonage/vivid 3.52.0 → 3.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/accordion/index.cjs +1 -1
- package/accordion/index.js +1 -1
- package/accordion-item/index.cjs +1 -1
- package/accordion-item/index.js +1 -1
- package/alert/index.cjs +3 -3
- package/alert/index.js +3 -3
- package/appearance-ui/index.cjs +1 -1
- package/appearance-ui/index.js +1 -1
- package/audio-player/index.cjs +3 -3
- package/audio-player/index.js +3 -3
- package/avatar/index.cjs +1 -1
- package/avatar/index.js +1 -1
- package/badge/index.cjs +1 -1
- package/badge/index.js +1 -1
- package/banner/index.cjs +2 -2
- package/banner/index.js +2 -2
- package/breadcrumb-item/index.cjs +1 -1
- package/breadcrumb-item/index.js +1 -1
- package/button/index.cjs +2 -2
- package/button/index.js +2 -2
- package/card/index.cjs +2 -2
- package/card/index.js +2 -2
- package/checkbox/index.cjs +3 -2
- package/checkbox/index.js +3 -2
- package/combobox/index.cjs +5 -5
- package/combobox/index.js +5 -5
- package/custom-elements.json +1162 -99
- package/data-grid/index.cjs +1 -1
- package/data-grid/index.js +1 -1
- package/date-picker/index.cjs +7 -6
- package/date-picker/index.js +7 -6
- package/date-range-picker/index.cjs +7 -6
- package/date-range-picker/index.js +7 -6
- package/dial-pad/index.cjs +33 -0
- package/dial-pad/index.js +31 -0
- package/dialog/index.cjs +4 -4
- package/dialog/index.js +4 -4
- 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 +2 -2
- package/empty-state/index.js +2 -2
- package/fab/index.cjs +2 -2
- package/fab/index.js +2 -2
- package/file-picker/index.cjs +4 -3
- package/file-picker/index.js +4 -3
- package/header/index.cjs +2 -2
- package/header/index.js +2 -2
- package/icon/index.cjs +1 -1
- package/icon/index.js +1 -1
- package/index.cjs +132 -122
- package/index.js +46 -43
- package/layout/index.cjs +1 -1
- package/layout/index.js +1 -1
- package/lib/appearance-ui/appearance-ui.d.ts +1 -1
- package/lib/audio-player/audio-player.d.ts +4 -0
- package/lib/audio-player/locale.d.ts +2 -0
- package/lib/components.d.ts +2 -0
- package/lib/dial-pad/definition.d.ts +3 -0
- package/lib/dial-pad/dial-pad.d.ts +17 -0
- package/lib/dial-pad/dial-pad.template.d.ts +4 -0
- package/lib/dial-pad/locale.d.ts +18 -0
- package/lib/enums.d.ts +7 -0
- package/lib/menu/menu.d.ts +1 -0
- package/lib/nav-disclosure/nav-disclosure.d.ts +5 -0
- package/lib/text-anchor/definition.d.ts +1 -0
- package/lib/text-anchor/text-anchor.d.ts +5 -0
- package/lib/video-player/definition.d.ts +3 -0
- package/lib/video-player/locale.d.ts +1 -0
- package/lib/video-player/video-player.d.ts +17 -0
- package/lib/video-player/video-player.template.d.ts +4 -0
- package/lib/video-player/vivid-video-svg.d.ts +1 -0
- package/listbox/index.cjs +2 -2
- package/listbox/index.js +2 -2
- package/locales/en-GB.cjs +33 -1
- package/locales/en-GB.js +33 -1
- package/locales/en-US.cjs +201 -1
- package/locales/en-US.js +201 -1
- package/locales/ja-JP.cjs +200 -1
- package/locales/ja-JP.js +200 -1
- package/locales/zh-CN.cjs +202 -1
- package/locales/zh-CN.js +202 -1
- package/menu/index.cjs +6 -6
- package/menu/index.js +6 -6
- package/menu-item/index.cjs +2 -2
- package/menu-item/index.js +2 -2
- package/nav/index.cjs +1 -1
- package/nav/index.js +1 -1
- package/nav-disclosure/index.cjs +2 -2
- package/nav-disclosure/index.js +2 -2
- package/nav-item/index.cjs +2 -2
- package/nav-item/index.js +2 -2
- package/note/index.cjs +2 -2
- package/note/index.js +2 -2
- package/number-field/index.cjs +5 -4
- package/number-field/index.js +5 -4
- package/option/index.cjs +2 -2
- package/option/index.js +2 -2
- package/package.json +1 -1
- package/pagination/index.cjs +3 -3
- package/pagination/index.js +3 -3
- package/popup/index.cjs +4 -4
- package/popup/index.js +4 -4
- 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 +2 -2
- package/range-slider/index.js +2 -2
- package/select/index.cjs +7 -6
- package/select/index.js +7 -6
- package/selectable-box/index.cjs +5 -4
- package/selectable-box/index.js +5 -4
- package/shared/applyMixinsWithObservables.cjs +15 -0
- package/shared/applyMixinsWithObservables.js +13 -0
- package/shared/definition.cjs +1 -1
- package/shared/definition.js +1 -1
- package/shared/definition11.cjs +3 -3
- package/shared/definition11.js +3 -3
- package/shared/definition14.cjs +2 -2
- package/shared/definition14.js +2 -2
- package/shared/definition15.cjs +8 -9
- package/shared/definition15.js +8 -9
- package/shared/definition16.cjs +3 -3
- package/shared/definition16.js +3 -3
- package/shared/definition17.cjs +2 -2
- package/shared/definition17.js +3 -3
- package/shared/definition18.cjs +3 -3
- package/shared/definition18.js +3 -3
- package/shared/definition19.cjs +3 -3
- package/shared/definition19.js +3 -3
- package/shared/definition20.cjs +196 -224
- package/shared/definition20.js +191 -219
- package/shared/definition21.cjs +264 -67
- package/shared/definition21.js +263 -65
- package/shared/definition22.cjs +66 -57
- package/shared/definition22.js +64 -56
- package/shared/definition23.cjs +42 -76
- package/shared/definition23.js +41 -75
- package/shared/definition24.cjs +70 -2402
- package/shared/definition24.js +69 -2401
- package/shared/definition25.cjs +2402 -46
- package/shared/definition25.js +2401 -45
- package/shared/definition26.cjs +63 -30
- package/shared/definition26.js +62 -29
- package/shared/definition27.cjs +28 -56
- package/shared/definition27.js +27 -55
- package/shared/definition28.cjs +35 -881
- package/shared/definition28.js +34 -879
- package/shared/definition29.cjs +922 -60
- package/shared/definition29.js +922 -61
- package/shared/definition30.cjs +68 -86
- package/shared/definition30.js +67 -85
- package/shared/definition31.cjs +98 -21
- package/shared/definition31.js +98 -21
- package/shared/definition32.cjs +24 -12
- package/shared/definition32.js +23 -11
- package/shared/definition33.cjs +11 -50
- package/shared/definition33.js +10 -49
- package/shared/definition34.cjs +26 -515
- package/shared/definition34.js +26 -515
- package/shared/definition35.cjs +448 -194
- package/shared/definition35.js +448 -192
- package/shared/definition36.cjs +256 -202
- package/shared/definition36.js +253 -201
- package/shared/definition37.cjs +204 -65
- package/shared/definition37.js +203 -63
- package/shared/definition38.cjs +63 -57
- package/shared/definition38.js +60 -55
- package/shared/definition39.cjs +65 -432
- package/shared/definition39.js +64 -431
- package/shared/definition4.cjs +2 -2
- package/shared/definition4.js +2 -2
- package/shared/definition40.cjs +441 -34
- package/shared/definition40.js +438 -31
- package/shared/definition41.cjs +34 -576
- package/shared/definition41.js +33 -575
- package/shared/definition42.cjs +531 -654
- package/shared/definition42.js +531 -654
- package/shared/definition43.cjs +690 -114
- package/shared/definition43.js +689 -113
- package/shared/definition44.cjs +124 -79
- package/shared/definition44.js +122 -77
- package/shared/definition45.cjs +78 -520
- package/shared/definition45.js +77 -518
- package/shared/definition46.cjs +520 -119
- package/shared/definition46.js +518 -118
- package/shared/definition47.cjs +118 -135
- package/shared/definition47.js +117 -134
- package/shared/definition48.cjs +151 -19
- package/shared/definition48.js +150 -18
- package/shared/definition49.cjs +21 -84
- package/shared/definition49.js +20 -83
- package/shared/definition5.cjs +100 -19
- package/shared/definition5.js +100 -19
- package/shared/definition50.cjs +52 -505
- package/shared/definition50.js +51 -504
- package/shared/definition51.cjs +526 -28
- package/shared/definition51.js +525 -27
- package/shared/definition52.cjs +28 -123
- package/shared/definition52.js +26 -122
- package/shared/definition53.cjs +110 -309
- package/shared/definition53.js +110 -308
- package/shared/definition54.cjs +255 -271
- package/shared/definition54.js +255 -271
- package/shared/definition55.cjs +315 -776
- package/shared/definition55.js +314 -775
- package/shared/definition56.cjs +818 -107
- package/shared/definition56.js +817 -106
- package/shared/definition57.cjs +85 -55
- package/shared/definition57.js +84 -54
- package/shared/definition58.cjs +125 -72
- package/shared/definition58.js +124 -71
- package/shared/definition59.cjs +72 -285
- package/shared/definition59.js +73 -286
- package/shared/definition6.cjs +1 -1
- package/shared/definition6.js +1 -1
- package/shared/definition60.cjs +298 -39
- package/shared/definition60.js +297 -38
- package/shared/definition61.cjs +66044 -1687
- package/shared/definition61.js +66043 -1686
- package/shared/definition62.cjs +50 -0
- package/shared/definition62.js +46 -0
- package/shared/definition63.cjs +1828 -0
- package/shared/definition63.js +1824 -0
- package/shared/definition7.cjs +2 -2
- package/shared/definition7.js +2 -2
- package/shared/definition8.cjs +2 -2
- package/shared/definition8.js +2 -2
- package/shared/definition9.cjs +1 -1
- package/shared/definition9.js +1 -1
- package/shared/enums.cjs +9 -0
- package/shared/enums.js +9 -1
- package/shared/icon.cjs +20 -2
- package/shared/icon.js +21 -3
- package/shared/index2.cjs +73 -37
- package/shared/index2.js +73 -37
- package/shared/key-codes2.js +1 -1
- package/shared/listbox.cjs +1 -1
- package/shared/listbox.js +1 -1
- package/shared/localization/Locale.d.ts +4 -0
- package/shared/patterns/form-elements/form-elements.d.ts +2 -3
- package/shared/presentationDate.cjs +16 -5
- package/shared/presentationDate.js +16 -5
- package/shared/text-anchor.cjs +6 -0
- package/shared/text-anchor.js +6 -0
- package/shared/text-anchor.template.cjs +6 -1
- package/shared/text-anchor.template.js +6 -1
- package/shared/text-field.cjs +1 -1
- package/shared/text-field.js +1 -1
- package/shared/utils/applyMixinsWithObservables.d.ts +1 -0
- package/shared/utils/numberConverter.d.ts +2 -0
- 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 +2 -2
- package/split-button/index.js +2 -2
- 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 +2 -2
- package/switch/index.js +2 -2
- package/tab/index.cjs +2 -2
- package/tab/index.js +2 -2
- package/tab-panel/index.cjs +1 -1
- package/tab-panel/index.js +1 -1
- package/tabs/index.cjs +4 -4
- package/tabs/index.js +4 -4
- package/tag/index.cjs +2 -2
- package/tag/index.js +2 -2
- package/tag-group/index.cjs +1 -1
- package/tag-group/index.js +1 -1
- package/text-area/index.cjs +4 -3
- package/text-area/index.js +4 -3
- package/text-field/index.cjs +4 -3
- package/text-field/index.js +4 -3
- package/time-picker/index.cjs +8 -7
- package/time-picker/index.js +8 -7
- package/toggletip/index.cjs +5 -5
- package/toggletip/index.js +5 -5
- package/tooltip/index.cjs +5 -5
- package/tooltip/index.js +5 -5
- package/tree-item/index.cjs +2 -2
- package/tree-item/index.js +2 -2
- package/tree-view/index.cjs +1 -1
- package/tree-view/index.js +1 -1
- package/video-player/index.cjs +17 -0
- package/video-player/index.js +15 -0
- package/vivid.api.json +332 -0
package/shared/definition56.js
CHANGED
|
@@ -1,10 +1,218 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { F as FoundationElement, a as attr, D as DOM, n as nullableNumberConverter, o as observable, h as html, r as registerFactory } from './index.js';
|
|
2
|
+
import { T as TextField, a as textFieldRegistries } from './definition55.js';
|
|
3
|
+
import { P as Popup, p as popupRegistries } from './definition63.js';
|
|
4
|
+
import { B as Button, a as buttonRegistries } from './definition11.js';
|
|
5
|
+
import './affix.js';
|
|
6
|
+
import { e as errorText, f as formElements, a as FormElementHelperText } from './index2.js';
|
|
7
|
+
import { L as Localized } from './localized.js';
|
|
8
|
+
import { T as TrappedFocus } from './trapped-focus.js';
|
|
9
|
+
import { a as applyMixinsWithObservables } from './applyMixinsWithObservables.js';
|
|
10
|
+
import { F as FormAssociated } from './form-associated.js';
|
|
11
|
+
import { r as ref } from './ref.js';
|
|
12
|
+
import { s as slotted } from './slotted.js';
|
|
4
13
|
import { w as when } from './when.js';
|
|
14
|
+
import { r as repeat } from './repeat.js';
|
|
5
15
|
import { c as classNames } from './class-names.js';
|
|
6
16
|
|
|
7
|
-
const styles = ":host{display:
|
|
17
|
+
const styles = ":host{display:inline-block}.base,.control{inline-size:100%}.dialog{display:inline-flex;flex-direction:column}.dialog .footer{display:flex;align-items:center;justify-content:flex-end;padding:8px;border-top:1px solid var(--vvd-color-neutral-200);gap:8px}.time-pickers{display:flex;overflow:hidden;padding:4px;block-size:188px;gap:4px}.time-pickers .picker{position:relative;display:flex;overflow:hidden;flex-direction:column;padding:0;border-radius:4px;margin:0;gap:4px;inline-size:50px;list-style:none;scrollbar-width:thin}.time-pickers .picker:hover{overflow-y:auto}.time-pickers .picker:after{display:block;flex-shrink:0;block-size:156px;content:\"\"}.time-pickers .picker:focus-visible{--focus-stroke-gap-color: transparent;--focus-inset: -2px;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))}.time-pickers .item{display:flex;flex-shrink:0;align-items:center;justify-content:center;border-radius:4px;background-color:var(--_appearance-color-fill);block-size:28px;color:var(--_appearance-color-text);cursor:pointer;font:var(--vvd-typography-base);inline-size:50px}.time-pickers .item{--_connotation-color-primary: var(--vvd-time-picker-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-firm: var(--vvd-time-picker-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-faint: var(--vvd-time-picker-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-time-picker-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-dim: var(--vvd-time-picker-accent-dim, var(--vvd-color-neutral-200));--_connotation-color-pale: var(--vvd-time-picker-accent-pale, var(--vvd-color-neutral-300))}.time-pickers .item{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.time-pickers .item: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}.time-pickers .item: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}.time-pickers .item:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.time-pickers .item: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}.time-pickers .item: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}\n";
|
|
18
|
+
|
|
19
|
+
class _TimePicker extends FoundationElement {
|
|
20
|
+
}
|
|
21
|
+
class FormAssociatedTimePicker extends FormAssociated(_TimePicker) {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.proxy = document.createElement("input");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const isValidTimeStr = (timeStr) => {
|
|
29
|
+
const parts = timeStr.split(":");
|
|
30
|
+
if (parts.length !== 3) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const [hours, minutes, seconds] = parts;
|
|
34
|
+
if (hours.length !== 2 || minutes.length !== 2 || seconds.length !== 2) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const hoursNum = parseInt(hours, 10);
|
|
38
|
+
const minutesNum = parseInt(minutes, 10);
|
|
39
|
+
const secondsNum = parseInt(seconds, 10);
|
|
40
|
+
if (isNaN(hoursNum) || isNaN(minutesNum) || isNaN(secondsNum)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (hoursNum < 0 || hoursNum > 23) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (minutesNum < 0 || minutesNum > 59) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (secondsNum < 0 || secondsNum > 59) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
};
|
|
54
|
+
const parseTimePart = (partStr) => Number.parseInt(partStr, 10);
|
|
55
|
+
const formatTimePart = (part) => part.toString().padStart(2, "0");
|
|
56
|
+
const parseTimeStr = (timeStr) => {
|
|
57
|
+
const [hoursStr, minutesStr, secondsStr] = timeStr.split(":");
|
|
58
|
+
const hours = parseTimePart(hoursStr);
|
|
59
|
+
const minutes = parseTimePart(minutesStr);
|
|
60
|
+
const seconds = parseTimePart(secondsStr);
|
|
61
|
+
return {
|
|
62
|
+
hourStr: hoursStr,
|
|
63
|
+
hours,
|
|
64
|
+
minuteStr: minutesStr,
|
|
65
|
+
minutes,
|
|
66
|
+
secondStr: secondsStr,
|
|
67
|
+
seconds,
|
|
68
|
+
meridiem: hours < 12 ? "AM" : "PM"
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
const hoursAs12hClock = (hour) => hour % 12 || 12;
|
|
72
|
+
|
|
73
|
+
const formatPresentationTime = (timeStr, includeSeconds, use12HourClock) => {
|
|
74
|
+
const time = parseTimeStr(timeStr);
|
|
75
|
+
const hoursStr = formatTimePart(
|
|
76
|
+
use12HourClock ? hoursAs12hClock(time.hours) : time.hours
|
|
77
|
+
);
|
|
78
|
+
let result = `${hoursStr}:${time.minuteStr}`;
|
|
79
|
+
if (includeSeconds) {
|
|
80
|
+
result += `:${time.secondStr}`;
|
|
81
|
+
}
|
|
82
|
+
if (use12HourClock) {
|
|
83
|
+
result += ` ${time.meridiem}`;
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
};
|
|
87
|
+
const isDigit = (char) => char >= "0" && char <= "9";
|
|
88
|
+
const parsePresentationTime = (input, use12HourClock) => {
|
|
89
|
+
const cleanedInput = input.toLowerCase();
|
|
90
|
+
const numerals = [];
|
|
91
|
+
let meridiem;
|
|
92
|
+
for (let i = 0; i < cleanedInput.length; i++) {
|
|
93
|
+
const char = cleanedInput[i];
|
|
94
|
+
if (char === "a" && cleanedInput[i + 1] === "m") {
|
|
95
|
+
i++;
|
|
96
|
+
meridiem = "AM";
|
|
97
|
+
}
|
|
98
|
+
if (char === "p" && cleanedInput[i + 1] === "m") {
|
|
99
|
+
i++;
|
|
100
|
+
meridiem = "PM";
|
|
101
|
+
}
|
|
102
|
+
if (isDigit(char)) {
|
|
103
|
+
let numeral = char;
|
|
104
|
+
while (isDigit(cleanedInput[i + 1])) {
|
|
105
|
+
i++;
|
|
106
|
+
numeral += cleanedInput[i];
|
|
107
|
+
}
|
|
108
|
+
numerals.push(Number.parseInt(numeral, 10));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (numerals.length === 0 || numerals.length > 3) {
|
|
112
|
+
throw new Error("Invalid time format");
|
|
113
|
+
}
|
|
114
|
+
if (meridiem && (numerals[0] < 1 || numerals[0] > 12)) {
|
|
115
|
+
throw new Error("Invalid time format");
|
|
116
|
+
}
|
|
117
|
+
if (meridiem || use12HourClock) {
|
|
118
|
+
if (numerals[0] === 12) {
|
|
119
|
+
numerals[0] = 0;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (meridiem === "PM") {
|
|
123
|
+
numerals[0] = numerals[0] + 12;
|
|
124
|
+
}
|
|
125
|
+
const [hours, minutes = 0, seconds = 0] = numerals;
|
|
126
|
+
if (hours > 23 || minutes > 59 || seconds > 59) {
|
|
127
|
+
throw new Error("Invalid value");
|
|
128
|
+
}
|
|
129
|
+
return [hours, minutes, seconds].map(formatTimePart).join(":");
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const fallsIntoMeridiem = (meridiem, hour) => meridiem === "AM" && hour < 12 || meridiem === "PM" && hour >= 12;
|
|
133
|
+
const getHoursOptions = (min, max, forMeridiem) => {
|
|
134
|
+
const result = [];
|
|
135
|
+
const minHour = min ? parseTimeStr(min).hours : 0;
|
|
136
|
+
const maxHour = max ? parseTimeStr(max).hours : 23;
|
|
137
|
+
for (let i = minHour; i <= maxHour; i++) {
|
|
138
|
+
if (forMeridiem && !fallsIntoMeridiem(forMeridiem, i)) {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
result.push({
|
|
142
|
+
value: formatTimePart(i),
|
|
143
|
+
label: formatTimePart(forMeridiem ? hoursAs12hClock(i) : i)
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
};
|
|
148
|
+
const getMinutesOptions = (step, value, min, max) => {
|
|
149
|
+
const result = [];
|
|
150
|
+
let minMinute = 0;
|
|
151
|
+
let maxMinute = 59;
|
|
152
|
+
if (min) {
|
|
153
|
+
const { hourStr: minHourStr, minutes: minMinutes } = parseTimeStr(min);
|
|
154
|
+
if (value && parseTimeStr(value).hourStr === minHourStr) {
|
|
155
|
+
minMinute = minMinutes;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (max) {
|
|
159
|
+
const { hourStr: maxHourStr, minutes: maxMinutes } = parseTimeStr(max);
|
|
160
|
+
if (value && parseTimeStr(value).hourStr === maxHourStr) {
|
|
161
|
+
maxMinute = maxMinutes;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
for (let i = minMinute; i <= maxMinute; i += Math.max(1, step ?? 1)) {
|
|
165
|
+
const minutes = formatTimePart(i);
|
|
166
|
+
result.push({
|
|
167
|
+
value: minutes,
|
|
168
|
+
label: minutes
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
172
|
+
};
|
|
173
|
+
const getSecondsOptions = (step, value, min, max) => {
|
|
174
|
+
const result = [];
|
|
175
|
+
let minSecond = 0;
|
|
176
|
+
let maxSecond = 59;
|
|
177
|
+
if (min) {
|
|
178
|
+
const minTime = parseTimeStr(min);
|
|
179
|
+
if (value && (parseTimeStr(value).hourStr === minTime.hourStr && parseTimeStr(value).minuteStr) === minTime.minuteStr) {
|
|
180
|
+
minSecond = minTime.seconds;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (max) {
|
|
184
|
+
const maxTime = parseTimeStr(max);
|
|
185
|
+
if (value && (parseTimeStr(value).hourStr === maxTime.hourStr && parseTimeStr(value).minuteStr) === maxTime.minuteStr) {
|
|
186
|
+
maxSecond = maxTime.seconds;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (let i = minSecond; i <= maxSecond; i += Math.max(1, step)) {
|
|
190
|
+
const seconds = formatTimePart(i);
|
|
191
|
+
result.push({
|
|
192
|
+
value: seconds,
|
|
193
|
+
label: seconds
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return result;
|
|
197
|
+
};
|
|
198
|
+
const getMeridiesOptions = (min, max) => {
|
|
199
|
+
const result = [];
|
|
200
|
+
const hideAM = min ? parseTimeStr(min).meridiem === "PM" : false;
|
|
201
|
+
if (!hideAM) {
|
|
202
|
+
result.push({
|
|
203
|
+
value: "AM",
|
|
204
|
+
label: "AM"
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const hidePM = max ? parseTimeStr(max).meridiem === "AM" : false;
|
|
208
|
+
if (!hidePM) {
|
|
209
|
+
result.push({
|
|
210
|
+
value: "PM",
|
|
211
|
+
label: "PM"
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return result;
|
|
215
|
+
};
|
|
8
216
|
|
|
9
217
|
var __defProp = Object.defineProperty;
|
|
10
218
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -34,142 +242,645 @@ var __privateMethod = (obj, member, method) => {
|
|
|
34
242
|
__accessCheck(obj, member, "access private method");
|
|
35
243
|
return method;
|
|
36
244
|
};
|
|
37
|
-
var
|
|
38
|
-
|
|
245
|
+
var _getFocusableEls, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn, _onFocusIn, _onFocusOut, _dismissOnClickOutside, _openPopupIfPossible, openPopupIfPossible_fn, _scrollToItem, scrollToItem_fn;
|
|
246
|
+
const ValidTimeFilter = {
|
|
247
|
+
fromView: (value) => {
|
|
248
|
+
if (value && isValidTimeStr(value)) {
|
|
249
|
+
return value;
|
|
250
|
+
}
|
|
251
|
+
return "";
|
|
252
|
+
},
|
|
253
|
+
toView(value) {
|
|
254
|
+
return value;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
let TimePicker = class extends FormAssociatedTimePicker {
|
|
39
258
|
constructor() {
|
|
40
|
-
super(
|
|
41
|
-
__privateAdd(this,
|
|
42
|
-
__privateAdd(this,
|
|
43
|
-
__privateAdd(this,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.
|
|
47
|
-
this
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
259
|
+
super();
|
|
260
|
+
__privateAdd(this, _updateValueDueToUserInteraction);
|
|
261
|
+
__privateAdd(this, _openPopupIfPossible);
|
|
262
|
+
__privateAdd(this, _scrollToItem);
|
|
263
|
+
this.readOnly = false;
|
|
264
|
+
this.minutesStep = null;
|
|
265
|
+
this.secondsStep = null;
|
|
266
|
+
__privateAdd(this, _getFocusableEls, () => this.shadowRoot.querySelectorAll(`
|
|
267
|
+
.dialog [tabindex="0"],
|
|
268
|
+
.dialog .vwc-button:not(:disabled)
|
|
269
|
+
`));
|
|
270
|
+
__privateAdd(this, _onFocusIn, () => {
|
|
271
|
+
this.$emit("focus", void 0, { bubbles: false });
|
|
52
272
|
});
|
|
53
|
-
__privateAdd(this,
|
|
54
|
-
|
|
55
|
-
const clickedOnAnchor = this._anchorEl?.contains(e.target);
|
|
56
|
-
if (clickedOutside || clickedOnAnchor)
|
|
57
|
-
this.open = false;
|
|
273
|
+
__privateAdd(this, _onFocusOut, () => {
|
|
274
|
+
this.$emit("blur", void 0, { bubbles: false });
|
|
58
275
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
276
|
+
this._popupOpen = false;
|
|
277
|
+
__privateAdd(this, _dismissOnClickOutside, (event) => {
|
|
278
|
+
if (!this._popupOpen) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const path = event.composedPath();
|
|
282
|
+
const elementsToIgnoreClicksOn = [this._dialogEl, this._clockButtonEl];
|
|
283
|
+
if (!elementsToIgnoreClicksOn.some((element) => path.includes(element))) {
|
|
284
|
+
this._closePopup(false);
|
|
285
|
+
}
|
|
62
286
|
});
|
|
287
|
+
this._presentationValue = "";
|
|
288
|
+
this.value = "";
|
|
289
|
+
this.min = "";
|
|
290
|
+
this.max = "";
|
|
291
|
+
this.proxy.type = "time";
|
|
292
|
+
this.proxy.step = "1";
|
|
63
293
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.
|
|
294
|
+
/**
|
|
295
|
+
* @internal
|
|
296
|
+
*/
|
|
297
|
+
readOnlyChanged() {
|
|
298
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
299
|
+
this.proxy.readOnly = this.readOnly;
|
|
300
|
+
this.validate();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* @internal
|
|
305
|
+
*/
|
|
306
|
+
minChanged(_, newMin) {
|
|
307
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
308
|
+
this.proxy.min = newMin;
|
|
309
|
+
this.validate();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* @internal
|
|
314
|
+
*/
|
|
315
|
+
maxChanged(_, newMax) {
|
|
316
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
317
|
+
this.proxy.max = newMax;
|
|
318
|
+
this.validate();
|
|
71
319
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
320
|
+
}
|
|
321
|
+
// --- Core ---
|
|
322
|
+
/**
|
|
323
|
+
* @internal
|
|
324
|
+
*/
|
|
325
|
+
get _displaySeconds() {
|
|
326
|
+
return this.secondsStep !== null;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* @internal
|
|
330
|
+
*/
|
|
331
|
+
get _use12hClock() {
|
|
332
|
+
return this.clock ? this.clock === "12h" : this.locale.timePicker.defaultTo12HourClock;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* @internal
|
|
336
|
+
*/
|
|
337
|
+
valueChanged(previous, next) {
|
|
338
|
+
super.valueChanged(previous, next);
|
|
339
|
+
if (this.value) {
|
|
340
|
+
if (!isValidTimeStr(this.value)) {
|
|
341
|
+
this.value = "";
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
this._presentationValue = formatPresentationTime(
|
|
345
|
+
this.value,
|
|
346
|
+
this._displaySeconds,
|
|
347
|
+
this._use12hClock
|
|
348
|
+
);
|
|
349
|
+
} else {
|
|
350
|
+
this._presentationValue = "";
|
|
75
351
|
}
|
|
76
352
|
}
|
|
77
353
|
connectedCallback() {
|
|
78
354
|
super.connectedCallback();
|
|
79
|
-
|
|
355
|
+
document.addEventListener("click", __privateGet(this, _dismissOnClickOutside));
|
|
356
|
+
this.addEventListener("focusin", __privateGet(this, _onFocusIn));
|
|
357
|
+
this.addEventListener("focusout", __privateGet(this, _onFocusOut));
|
|
80
358
|
}
|
|
81
359
|
disconnectedCallback() {
|
|
82
360
|
super.disconnectedCallback();
|
|
83
|
-
|
|
361
|
+
document.removeEventListener("click", __privateGet(this, _dismissOnClickOutside));
|
|
362
|
+
this.removeEventListener("focusin", __privateGet(this, _onFocusIn));
|
|
363
|
+
this.removeEventListener("focusout", __privateGet(this, _onFocusOut));
|
|
84
364
|
}
|
|
85
365
|
/**
|
|
86
366
|
* @internal
|
|
87
367
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
368
|
+
_closePopup(restoreFocusToTextField = true) {
|
|
369
|
+
this._popupOpen = false;
|
|
370
|
+
if (restoreFocusToTextField) {
|
|
371
|
+
this._textFieldEl.focus();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* On keydown anywhere in the time picker.
|
|
376
|
+
* @internal
|
|
377
|
+
*/
|
|
378
|
+
_onBaseKeyDown(event) {
|
|
379
|
+
if (event.key === "Escape") {
|
|
380
|
+
this._closePopup();
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
if (this._trappedFocus(event, __privateGet(this, _getFocusableEls))) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* @internal
|
|
390
|
+
*/
|
|
391
|
+
_presentationValueChanged() {
|
|
392
|
+
this.dirtyValue = true;
|
|
393
|
+
this.validate();
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* @internal
|
|
397
|
+
*/
|
|
398
|
+
get _textFieldPlaceholder() {
|
|
399
|
+
let format = "hh:mm";
|
|
400
|
+
if (this._displaySeconds) {
|
|
401
|
+
format += ":ss";
|
|
402
|
+
}
|
|
403
|
+
if (this._use12hClock) {
|
|
404
|
+
format += " aa";
|
|
405
|
+
}
|
|
406
|
+
return format;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* @internal
|
|
410
|
+
*/
|
|
411
|
+
_onTextFieldInput(event) {
|
|
412
|
+
const textField = event.currentTarget;
|
|
413
|
+
this._presentationValue = textField.value;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* @internal
|
|
417
|
+
*/
|
|
418
|
+
_onTextFieldChange() {
|
|
419
|
+
if (this._presentationValue === "") {
|
|
420
|
+
__privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, "");
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
try {
|
|
424
|
+
__privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, parsePresentationTime(this._presentationValue, this._use12hClock));
|
|
425
|
+
} catch (_) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
// --- Clock button ---
|
|
430
|
+
/**
|
|
431
|
+
* @internal
|
|
432
|
+
*/
|
|
433
|
+
get _clockButtonLabel() {
|
|
434
|
+
if (this.value) {
|
|
435
|
+
return this.locale.timePicker.changeTimeLabel(
|
|
436
|
+
formatPresentationTime(
|
|
437
|
+
this.value,
|
|
438
|
+
this._displaySeconds,
|
|
439
|
+
this._use12hClock
|
|
440
|
+
)
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
return this.locale.timePicker.chooseTimeLabel;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* @internal
|
|
447
|
+
*/
|
|
448
|
+
_onClockButtonClick() {
|
|
449
|
+
if (this._popupOpen) {
|
|
450
|
+
this._closePopup();
|
|
451
|
+
} else {
|
|
452
|
+
__privateMethod(this, _openPopupIfPossible, openPopupIfPossible_fn).call(this);
|
|
453
|
+
DOM.processUpdates();
|
|
454
|
+
if (this._selectedHour) {
|
|
455
|
+
__privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, "hours", this._selectedHour, "start");
|
|
456
|
+
}
|
|
457
|
+
if (this._selectedMinute) {
|
|
458
|
+
__privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, "minutes", this._selectedMinute, "start");
|
|
459
|
+
}
|
|
460
|
+
if (this._displaySeconds && this._selectedSecond) {
|
|
461
|
+
__privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, "seconds", this._selectedSecond, "start");
|
|
462
|
+
}
|
|
463
|
+
if (this._use12hClock && this._selectedMeridiem) {
|
|
464
|
+
__privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, "meridies", this._selectedMeridiem, "start");
|
|
465
|
+
}
|
|
466
|
+
__privateGet(this, _getFocusableEls).call(this)[0].focus();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
// --- Pickers ---
|
|
470
|
+
/**
|
|
471
|
+
* @internal
|
|
472
|
+
*/
|
|
473
|
+
get _hours() {
|
|
474
|
+
return getHoursOptions(
|
|
475
|
+
this.min,
|
|
476
|
+
this.max,
|
|
477
|
+
this._use12hClock ? this._selectedMeridiem ?? this._meridies[0].value : void 0
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* @internal
|
|
482
|
+
*/
|
|
483
|
+
get _selectedHour() {
|
|
484
|
+
return this.value ? parseTimeStr(this.value).hourStr : void 0;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* @internal
|
|
488
|
+
*/
|
|
489
|
+
set _selectedHour(value) {
|
|
490
|
+
if (this.value) {
|
|
491
|
+
const { minuteStr, secondStr } = parseTimeStr(this.value);
|
|
492
|
+
this.value = `${value}:${minuteStr}:${secondStr}`;
|
|
493
|
+
} else {
|
|
494
|
+
this.value = `${value}:00:00`;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* @internal
|
|
499
|
+
*/
|
|
500
|
+
get _minutes() {
|
|
501
|
+
return getMinutesOptions(this.minutesStep, this.value, this.min, this.max);
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* @internal
|
|
505
|
+
*/
|
|
506
|
+
get _selectedMinute() {
|
|
507
|
+
return this.value ? parseTimeStr(this.value).minuteStr : void 0;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* @internal
|
|
511
|
+
*/
|
|
512
|
+
set _selectedMinute(value) {
|
|
513
|
+
if (this.value) {
|
|
514
|
+
const { hourStr, secondStr } = parseTimeStr(this.value);
|
|
515
|
+
this.value = `${hourStr}:${value}:${secondStr}`;
|
|
516
|
+
} else {
|
|
517
|
+
this.value = `00:${value}:00`;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* @internal
|
|
522
|
+
*/
|
|
523
|
+
get _seconds() {
|
|
524
|
+
return getSecondsOptions(this.secondsStep, this.value, this.min, this.max);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* @internal
|
|
528
|
+
*/
|
|
529
|
+
get _selectedSecond() {
|
|
530
|
+
return this.value ? parseTimeStr(this.value).secondStr : void 0;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* @internal
|
|
534
|
+
*/
|
|
535
|
+
set _selectedSecond(value) {
|
|
536
|
+
if (this.value) {
|
|
537
|
+
const { hourStr, minuteStr } = parseTimeStr(this.value);
|
|
538
|
+
this.value = `${hourStr}:${minuteStr}:${value}`;
|
|
539
|
+
} else {
|
|
540
|
+
this.value = `00:00:${value}`;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* @internal
|
|
545
|
+
*/
|
|
546
|
+
get _meridies() {
|
|
547
|
+
return getMeridiesOptions(this.min, this.max);
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* @internal
|
|
551
|
+
*/
|
|
552
|
+
get _selectedMeridiem() {
|
|
553
|
+
return this.value ? parseTimeStr(this.value).meridiem : void 0;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* @internal
|
|
557
|
+
*/
|
|
558
|
+
set _selectedMeridiem(value) {
|
|
559
|
+
if (this.value) {
|
|
560
|
+
const { hours, minuteStr, secondStr } = parseTimeStr(this.value);
|
|
561
|
+
let adjustedHours = hours;
|
|
562
|
+
if (value === "AM" && hours >= 12) {
|
|
563
|
+
adjustedHours -= 12;
|
|
564
|
+
} else if (value === "PM" && hours < 12) {
|
|
565
|
+
adjustedHours += 12;
|
|
566
|
+
}
|
|
567
|
+
this.value = `${formatTimePart(adjustedHours)}:${minuteStr}:${secondStr}`;
|
|
568
|
+
} else {
|
|
569
|
+
if (value === "AM") {
|
|
570
|
+
this.value = "00:00:00";
|
|
571
|
+
} else {
|
|
572
|
+
this.value = "12:00:00";
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* @internal
|
|
578
|
+
*/
|
|
579
|
+
_onPickerKeyDown(picker, options, selectedValue, setSelectedValue, event) {
|
|
580
|
+
const offset = {
|
|
581
|
+
ArrowUp: -1,
|
|
582
|
+
ArrowDown: 1
|
|
583
|
+
}[event.key];
|
|
584
|
+
if (offset) {
|
|
585
|
+
event.preventDefault();
|
|
586
|
+
const index = options.findIndex((h) => h.value === selectedValue);
|
|
587
|
+
const newRawIndex = index === -1 ? 0 : index + offset;
|
|
588
|
+
const newIndex = (newRawIndex + options.length) % options.length;
|
|
589
|
+
const newValue = options[newIndex].value;
|
|
590
|
+
setSelectedValue(newValue);
|
|
591
|
+
__privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, picker, newValue, "nearest");
|
|
592
|
+
__privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, this.value);
|
|
593
|
+
}
|
|
594
|
+
return true;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* @internal
|
|
598
|
+
*/
|
|
599
|
+
_onPickerItemClick(picker, setSelectedValue, value) {
|
|
600
|
+
setSelectedValue(value);
|
|
601
|
+
__privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, picker, value, "start");
|
|
602
|
+
__privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, this.value);
|
|
603
|
+
const nextPickerEl = this.shadowRoot.querySelector(
|
|
604
|
+
`#${picker} + .picker`
|
|
605
|
+
);
|
|
606
|
+
if (nextPickerEl) {
|
|
607
|
+
nextPickerEl.focus();
|
|
608
|
+
} else {
|
|
609
|
+
this._closePopup();
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
// --- Dialog footer ---
|
|
613
|
+
/**
|
|
614
|
+
* @internal
|
|
615
|
+
*/
|
|
616
|
+
_onOkClick() {
|
|
617
|
+
this._closePopup();
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* @internal
|
|
621
|
+
*/
|
|
622
|
+
_onClearClick() {
|
|
623
|
+
__privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, "");
|
|
624
|
+
this._closePopup();
|
|
625
|
+
}
|
|
626
|
+
// --- Validation ---
|
|
627
|
+
/**
|
|
628
|
+
* @internal
|
|
629
|
+
*/
|
|
630
|
+
validate() {
|
|
631
|
+
if (this.proxy) {
|
|
632
|
+
this.proxy.setCustomValidity(this._getCustomValidationError() ?? "");
|
|
633
|
+
}
|
|
634
|
+
super.validate(this._textFieldEl?.querySelector("input") ?? void 0);
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* @internal
|
|
638
|
+
*/
|
|
639
|
+
_getCustomValidationError() {
|
|
640
|
+
if (this._isPresentationValueInvalid()) {
|
|
641
|
+
return this.locale.timePicker.invalidTimeError;
|
|
642
|
+
}
|
|
643
|
+
return null;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* @internal
|
|
647
|
+
*/
|
|
648
|
+
_isPresentationValueInvalid() {
|
|
649
|
+
if (this._presentationValue === "") {
|
|
650
|
+
return false;
|
|
651
|
+
}
|
|
652
|
+
try {
|
|
653
|
+
parsePresentationTime(this._presentationValue, this._use12hClock);
|
|
654
|
+
return false;
|
|
655
|
+
} catch (_) {
|
|
656
|
+
return true;
|
|
657
|
+
}
|
|
93
658
|
}
|
|
94
659
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
102
|
-
_updateAnchor = new WeakSet();
|
|
103
|
-
updateAnchor_fn = function(a) {
|
|
104
|
-
a.setAttribute("aria-expanded", this.open.toString());
|
|
660
|
+
_getFocusableEls = new WeakMap();
|
|
661
|
+
_updateValueDueToUserInteraction = new WeakSet();
|
|
662
|
+
updateValueDueToUserInteraction_fn = function(newValue) {
|
|
663
|
+
this.value = newValue;
|
|
664
|
+
this.$emit("change");
|
|
665
|
+
this.$emit("input");
|
|
105
666
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
667
|
+
_onFocusIn = new WeakMap();
|
|
668
|
+
_onFocusOut = new WeakMap();
|
|
669
|
+
_dismissOnClickOutside = new WeakMap();
|
|
670
|
+
_openPopupIfPossible = new WeakSet();
|
|
671
|
+
openPopupIfPossible_fn = function() {
|
|
672
|
+
if (!this.readOnly) {
|
|
673
|
+
this._popupOpen = true;
|
|
674
|
+
}
|
|
111
675
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
676
|
+
_scrollToItem = new WeakSet();
|
|
677
|
+
scrollToItem_fn = function(picker, selectedValue, position) {
|
|
678
|
+
const element = this.shadowRoot.querySelector(
|
|
679
|
+
`#${picker}-${selectedValue}`
|
|
680
|
+
);
|
|
681
|
+
if (!element) {
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
const parent = element.parentElement;
|
|
685
|
+
switch (position) {
|
|
686
|
+
case "start":
|
|
687
|
+
parent.scrollTop = element.offsetTop;
|
|
688
|
+
break;
|
|
689
|
+
case "nearest":
|
|
690
|
+
if (element.offsetTop < parent.scrollTop) {
|
|
691
|
+
parent.scrollTop = element.offsetTop;
|
|
692
|
+
}
|
|
693
|
+
if (element.offsetTop + element.offsetHeight > parent.scrollTop + parent.offsetHeight) {
|
|
694
|
+
parent.scrollTop = element.offsetTop + element.offsetHeight - parent.offsetHeight;
|
|
695
|
+
}
|
|
696
|
+
break;
|
|
120
697
|
}
|
|
121
698
|
};
|
|
122
|
-
|
|
123
|
-
|
|
699
|
+
__decorateClass([
|
|
700
|
+
attr({ attribute: "readonly", mode: "boolean" })
|
|
701
|
+
], TimePicker.prototype, "readOnly", 2);
|
|
702
|
+
__decorateClass([
|
|
703
|
+
attr({ attribute: "minutes-step", converter: nullableNumberConverter })
|
|
704
|
+
], TimePicker.prototype, "minutesStep", 2);
|
|
705
|
+
__decorateClass([
|
|
706
|
+
attr({ attribute: "seconds-step", converter: nullableNumberConverter })
|
|
707
|
+
], TimePicker.prototype, "secondsStep", 2);
|
|
124
708
|
__decorateClass([
|
|
125
709
|
attr
|
|
126
|
-
],
|
|
710
|
+
], TimePicker.prototype, "clock", 2);
|
|
127
711
|
__decorateClass([
|
|
128
|
-
attr({
|
|
129
|
-
],
|
|
712
|
+
attr({ converter: ValidTimeFilter })
|
|
713
|
+
], TimePicker.prototype, "min", 2);
|
|
130
714
|
__decorateClass([
|
|
131
|
-
attr({
|
|
132
|
-
],
|
|
715
|
+
attr({ converter: ValidTimeFilter })
|
|
716
|
+
], TimePicker.prototype, "max", 2);
|
|
133
717
|
__decorateClass([
|
|
134
|
-
|
|
135
|
-
],
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
],
|
|
718
|
+
observable
|
|
719
|
+
], TimePicker.prototype, "_popupOpen", 2);
|
|
720
|
+
__decorateClass([
|
|
721
|
+
observable
|
|
722
|
+
], TimePicker.prototype, "_presentationValue", 2);
|
|
723
|
+
TimePicker = __decorateClass([
|
|
724
|
+
errorText,
|
|
725
|
+
formElements
|
|
726
|
+
], TimePicker);
|
|
727
|
+
applyMixinsWithObservables(
|
|
728
|
+
TimePicker,
|
|
729
|
+
Localized,
|
|
730
|
+
FormElementHelperText,
|
|
731
|
+
TrappedFocus
|
|
732
|
+
);
|
|
139
733
|
|
|
140
|
-
const
|
|
141
|
-
const ToggletipTemplate = (context) => {
|
|
142
|
-
const popup = context.tagFor(Popup);
|
|
143
|
-
const anchorSlotTemplate = anchorSlotTemplateFactory();
|
|
734
|
+
const renderPicker = (id, getLabel, getSelected, setSelected, getOptions) => {
|
|
144
735
|
return html`
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
class="
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
736
|
+
<ul
|
|
737
|
+
id="${id}"
|
|
738
|
+
class="picker"
|
|
739
|
+
role="listbox"
|
|
740
|
+
tabindex="0"
|
|
741
|
+
aria-label="${getLabel}"
|
|
742
|
+
aria-activedescendant="${(x) => getSelected(x) ? `${id}-${getSelected(x)}` : void 0}"
|
|
743
|
+
@keydown="${(x, c) => x._onPickerKeyDown(
|
|
744
|
+
id,
|
|
745
|
+
getOptions(x),
|
|
746
|
+
getSelected(x),
|
|
747
|
+
setSelected(x),
|
|
748
|
+
c.event
|
|
749
|
+
)}"
|
|
154
750
|
>
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
751
|
+
${repeat(
|
|
752
|
+
getOptions,
|
|
753
|
+
html`
|
|
754
|
+
<li
|
|
755
|
+
id="${(x) => `${id}-${x.value}`}"
|
|
756
|
+
class="${(x, c) => classNames("item", [
|
|
757
|
+
"selected",
|
|
758
|
+
getSelected(c.parent) === x.value
|
|
759
|
+
])}"
|
|
760
|
+
role="option"
|
|
761
|
+
aria-selected="${(x, c) => getSelected(c.parent) === x.value}"
|
|
762
|
+
@click="${(x, c) => c.parent._onPickerItemClick(id, setSelected(c.parent), x.value)}"
|
|
763
|
+
>
|
|
764
|
+
${(x) => x.label}
|
|
765
|
+
</li>
|
|
766
|
+
`
|
|
159
767
|
)}
|
|
160
|
-
|
|
161
|
-
<footer class="action-items"><slot name="action-items"></slot></footer>
|
|
162
|
-
</div>
|
|
163
|
-
</${popup}>
|
|
768
|
+
</ul>
|
|
164
769
|
`;
|
|
165
770
|
};
|
|
771
|
+
const TimePickerTemplate = (context, _) => {
|
|
772
|
+
const popupTag = context.tagFor(Popup);
|
|
773
|
+
const textFieldTag = context.tagFor(TextField);
|
|
774
|
+
const buttonTag = context.tagFor(Button);
|
|
775
|
+
return html`<div class="base" @keydown="${(x, { event }) => x._onBaseKeyDown(event)}">
|
|
776
|
+
<${textFieldTag} id="text-field"
|
|
777
|
+
${ref("_textFieldEl")}
|
|
778
|
+
class="control"
|
|
779
|
+
label="${(x) => x.label}"
|
|
780
|
+
helper-text="${(x) => x.helperText}"
|
|
781
|
+
error-text="${(x) => x.errorValidationMessage}"
|
|
782
|
+
placeholder="${(x) => x._textFieldPlaceholder}"
|
|
783
|
+
current-value="${(x) => x._presentationValue}"
|
|
784
|
+
?disabled="${(x) => x.disabled}"
|
|
785
|
+
?readonly="${(x) => x.readOnly}"
|
|
786
|
+
@input="${(x, c) => x._onTextFieldInput(c.event)}"
|
|
787
|
+
@change="${(x) => x._onTextFieldChange()}"
|
|
788
|
+
>
|
|
789
|
+
<slot
|
|
790
|
+
slot="${(x) => x._helperTextSlottedContent?.length ? "helper-text" : void 0}"
|
|
791
|
+
name="helper-text"
|
|
792
|
+
${slotted("_helperTextSlottedContent")}
|
|
793
|
+
></slot>
|
|
794
|
+
<${buttonTag}
|
|
795
|
+
id="clock-button"
|
|
796
|
+
${ref("_clockButtonEl")}
|
|
797
|
+
slot="action-items"
|
|
798
|
+
size="condensed"
|
|
799
|
+
icon="clock-line"
|
|
800
|
+
appearance="ghost"
|
|
801
|
+
?disabled="${(x) => x.disabled || x.readOnly}"
|
|
802
|
+
aria-label="${(x) => x._clockButtonLabel}"
|
|
803
|
+
@click="${(x) => x._onClockButtonClick()}"
|
|
804
|
+
></${buttonTag}>
|
|
805
|
+
</${textFieldTag}>
|
|
806
|
+
<${popupTag}
|
|
807
|
+
?open="${(x) => x._popupOpen}"
|
|
808
|
+
:anchor="${(x) => x._textFieldEl}"
|
|
809
|
+
placement="bottom-start"
|
|
810
|
+
class="popup">
|
|
811
|
+
<div class="dialog" role="dialog" ${ref(
|
|
812
|
+
"_dialogEl"
|
|
813
|
+
)} aria-modal="true" aria-label="${(x) => x.locale.timePicker.chooseTimeLabel}">
|
|
814
|
+
<div class="time-pickers">
|
|
815
|
+
${renderPicker(
|
|
816
|
+
"hours",
|
|
817
|
+
(x) => x.locale.timePicker.hoursLabel,
|
|
818
|
+
(x) => x._selectedHour,
|
|
819
|
+
(x) => (v) => x._selectedHour = v,
|
|
820
|
+
(x) => x._hours
|
|
821
|
+
)}
|
|
822
|
+
${renderPicker(
|
|
823
|
+
"minutes",
|
|
824
|
+
(x) => x.locale.timePicker.minutesLabel,
|
|
825
|
+
(x) => x._selectedMinute,
|
|
826
|
+
(x) => (v) => x._selectedMinute = v,
|
|
827
|
+
(x) => x._minutes
|
|
828
|
+
)}
|
|
829
|
+
${when(
|
|
830
|
+
(x) => x._displaySeconds,
|
|
831
|
+
renderPicker(
|
|
832
|
+
"seconds",
|
|
833
|
+
(x) => x.locale.timePicker.secondsLabel,
|
|
834
|
+
(x) => x._selectedSecond,
|
|
835
|
+
(x) => (v) => x._selectedSecond = v,
|
|
836
|
+
(x) => x._seconds
|
|
837
|
+
)
|
|
838
|
+
)}
|
|
839
|
+
${when(
|
|
840
|
+
(x) => x._use12hClock,
|
|
841
|
+
renderPicker(
|
|
842
|
+
"meridies",
|
|
843
|
+
(x) => x.locale.timePicker.meridiesLabel,
|
|
844
|
+
(x) => x._selectedMeridiem,
|
|
845
|
+
(x) => (v) => x._selectedMeridiem = v,
|
|
846
|
+
(x) => x._meridies
|
|
847
|
+
)
|
|
848
|
+
)}
|
|
849
|
+
</div>
|
|
850
|
+
<div class="footer">
|
|
851
|
+
<${buttonTag}
|
|
852
|
+
class="vwc-button"
|
|
853
|
+
size="condensed"
|
|
854
|
+
label="${(x) => x.locale.timePicker.clearLabel}"
|
|
855
|
+
@click="${(x) => x._onClearClick()}"
|
|
856
|
+
></${buttonTag}>
|
|
857
|
+
<${buttonTag}
|
|
858
|
+
class="vwc-button"
|
|
859
|
+
size="condensed"
|
|
860
|
+
appearance="filled"
|
|
861
|
+
label="${(x) => x.locale.timePicker.okLabel}"
|
|
862
|
+
@click="${(x) => x._onOkClick()}"
|
|
863
|
+
></${buttonTag}>
|
|
864
|
+
</div>
|
|
865
|
+
</div>
|
|
866
|
+
</${popupTag}>
|
|
867
|
+
</div>`;
|
|
868
|
+
};
|
|
166
869
|
|
|
167
|
-
const
|
|
168
|
-
baseName: "
|
|
169
|
-
template:
|
|
170
|
-
styles
|
|
870
|
+
const timePickerDefinition = TimePicker.compose({
|
|
871
|
+
baseName: "time-picker",
|
|
872
|
+
template: TimePickerTemplate,
|
|
873
|
+
styles,
|
|
874
|
+
shadowOptions: {
|
|
875
|
+
delegatesFocus: true
|
|
876
|
+
}
|
|
171
877
|
});
|
|
172
|
-
const
|
|
173
|
-
|
|
878
|
+
const timePickerRegistries = [
|
|
879
|
+
timePickerDefinition(),
|
|
880
|
+
...textFieldRegistries,
|
|
881
|
+
...popupRegistries,
|
|
882
|
+
...buttonRegistries
|
|
883
|
+
];
|
|
884
|
+
const registerTimePicker = registerFactory(timePickerRegistries);
|
|
174
885
|
|
|
175
|
-
export {
|
|
886
|
+
export { timePickerRegistries as a, registerTimePicker as r, timePickerDefinition as t };
|