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