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