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