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