@vonage/vivid 3.52.0 → 3.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) 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 +1 -1
  9. package/appearance-ui/index.js +1 -1
  10. package/audio-player/index.cjs +3 -3
  11. package/audio-player/index.js +3 -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 -5
  27. package/combobox/index.js +5 -5
  28. package/custom-elements.json +1162 -99
  29. package/data-grid/index.cjs +1 -1
  30. package/data-grid/index.js +1 -1
  31. package/date-picker/index.cjs +7 -6
  32. package/date-picker/index.js +7 -6
  33. package/date-range-picker/index.cjs +7 -6
  34. package/date-range-picker/index.js +7 -6
  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 -3
  48. package/file-picker/index.js +4 -3
  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 +132 -122
  54. package/index.js +46 -43
  55. package/layout/index.cjs +1 -1
  56. package/layout/index.js +1 -1
  57. package/lib/appearance-ui/appearance-ui.d.ts +1 -1
  58. package/lib/audio-player/audio-player.d.ts +4 -0
  59. package/lib/audio-player/locale.d.ts +2 -0
  60. package/lib/components.d.ts +2 -0
  61. package/lib/dial-pad/definition.d.ts +3 -0
  62. package/lib/dial-pad/dial-pad.d.ts +17 -0
  63. package/lib/dial-pad/dial-pad.template.d.ts +4 -0
  64. package/lib/dial-pad/locale.d.ts +18 -0
  65. package/lib/enums.d.ts +7 -0
  66. package/lib/menu/menu.d.ts +1 -0
  67. package/lib/nav-disclosure/nav-disclosure.d.ts +5 -0
  68. package/lib/text-anchor/definition.d.ts +1 -0
  69. package/lib/text-anchor/text-anchor.d.ts +5 -0
  70. package/lib/video-player/definition.d.ts +3 -0
  71. package/lib/video-player/locale.d.ts +1 -0
  72. package/lib/video-player/video-player.d.ts +17 -0
  73. package/lib/video-player/video-player.template.d.ts +4 -0
  74. package/lib/video-player/vivid-video-svg.d.ts +1 -0
  75. package/listbox/index.cjs +2 -2
  76. package/listbox/index.js +2 -2
  77. package/locales/en-GB.cjs +33 -1
  78. package/locales/en-GB.js +33 -1
  79. package/locales/en-US.cjs +201 -1
  80. package/locales/en-US.js +201 -1
  81. package/locales/ja-JP.cjs +200 -1
  82. package/locales/ja-JP.js +200 -1
  83. package/locales/zh-CN.cjs +202 -1
  84. package/locales/zh-CN.js +202 -1
  85. package/menu/index.cjs +6 -6
  86. package/menu/index.js +6 -6
  87. package/menu-item/index.cjs +2 -2
  88. package/menu-item/index.js +2 -2
  89. package/nav/index.cjs +1 -1
  90. package/nav/index.js +1 -1
  91. package/nav-disclosure/index.cjs +2 -2
  92. package/nav-disclosure/index.js +2 -2
  93. package/nav-item/index.cjs +2 -2
  94. package/nav-item/index.js +2 -2
  95. package/note/index.cjs +2 -2
  96. package/note/index.js +2 -2
  97. package/number-field/index.cjs +5 -4
  98. package/number-field/index.js +5 -4
  99. package/option/index.cjs +2 -2
  100. package/option/index.js +2 -2
  101. package/package.json +1 -1
  102. package/pagination/index.cjs +3 -3
  103. package/pagination/index.js +3 -3
  104. package/popup/index.cjs +4 -4
  105. package/popup/index.js +4 -4
  106. package/progress/index.cjs +1 -1
  107. package/progress/index.js +1 -1
  108. package/progress-ring/index.cjs +1 -1
  109. package/progress-ring/index.js +1 -1
  110. package/radio/index.cjs +1 -1
  111. package/radio/index.js +1 -1
  112. package/radio-group/index.cjs +1 -1
  113. package/radio-group/index.js +1 -1
  114. package/range-slider/index.cjs +2 -2
  115. package/range-slider/index.js +2 -2
  116. package/select/index.cjs +7 -6
  117. package/select/index.js +7 -6
  118. package/selectable-box/index.cjs +5 -4
  119. package/selectable-box/index.js +5 -4
  120. package/shared/applyMixinsWithObservables.cjs +15 -0
  121. package/shared/applyMixinsWithObservables.js +13 -0
  122. package/shared/definition.cjs +1 -1
  123. package/shared/definition.js +1 -1
  124. package/shared/definition11.cjs +3 -3
  125. package/shared/definition11.js +3 -3
  126. package/shared/definition14.cjs +2 -2
  127. package/shared/definition14.js +2 -2
  128. package/shared/definition15.cjs +8 -9
  129. package/shared/definition15.js +8 -9
  130. package/shared/definition16.cjs +3 -3
  131. package/shared/definition16.js +3 -3
  132. package/shared/definition17.cjs +2 -2
  133. package/shared/definition17.js +3 -3
  134. package/shared/definition18.cjs +3 -3
  135. package/shared/definition18.js +3 -3
  136. package/shared/definition19.cjs +3 -3
  137. package/shared/definition19.js +3 -3
  138. package/shared/definition20.cjs +196 -224
  139. package/shared/definition20.js +191 -219
  140. package/shared/definition21.cjs +264 -67
  141. package/shared/definition21.js +263 -65
  142. package/shared/definition22.cjs +66 -57
  143. package/shared/definition22.js +64 -56
  144. package/shared/definition23.cjs +42 -76
  145. package/shared/definition23.js +41 -75
  146. package/shared/definition24.cjs +70 -2402
  147. package/shared/definition24.js +69 -2401
  148. package/shared/definition25.cjs +2402 -46
  149. package/shared/definition25.js +2401 -45
  150. package/shared/definition26.cjs +63 -30
  151. package/shared/definition26.js +62 -29
  152. package/shared/definition27.cjs +28 -56
  153. package/shared/definition27.js +27 -55
  154. package/shared/definition28.cjs +35 -881
  155. package/shared/definition28.js +34 -879
  156. package/shared/definition29.cjs +922 -60
  157. package/shared/definition29.js +922 -61
  158. package/shared/definition30.cjs +68 -86
  159. package/shared/definition30.js +67 -85
  160. package/shared/definition31.cjs +98 -21
  161. package/shared/definition31.js +98 -21
  162. package/shared/definition32.cjs +24 -12
  163. package/shared/definition32.js +23 -11
  164. package/shared/definition33.cjs +11 -50
  165. package/shared/definition33.js +10 -49
  166. package/shared/definition34.cjs +26 -515
  167. package/shared/definition34.js +26 -515
  168. package/shared/definition35.cjs +448 -194
  169. package/shared/definition35.js +448 -192
  170. package/shared/definition36.cjs +256 -202
  171. package/shared/definition36.js +253 -201
  172. package/shared/definition37.cjs +204 -65
  173. package/shared/definition37.js +203 -63
  174. package/shared/definition38.cjs +63 -57
  175. package/shared/definition38.js +60 -55
  176. package/shared/definition39.cjs +65 -432
  177. package/shared/definition39.js +64 -431
  178. package/shared/definition4.cjs +2 -2
  179. package/shared/definition4.js +2 -2
  180. package/shared/definition40.cjs +441 -34
  181. package/shared/definition40.js +438 -31
  182. package/shared/definition41.cjs +34 -576
  183. package/shared/definition41.js +33 -575
  184. package/shared/definition42.cjs +531 -654
  185. package/shared/definition42.js +531 -654
  186. package/shared/definition43.cjs +690 -114
  187. package/shared/definition43.js +689 -113
  188. package/shared/definition44.cjs +124 -79
  189. package/shared/definition44.js +122 -77
  190. package/shared/definition45.cjs +78 -520
  191. package/shared/definition45.js +77 -518
  192. package/shared/definition46.cjs +520 -119
  193. package/shared/definition46.js +518 -118
  194. package/shared/definition47.cjs +118 -135
  195. package/shared/definition47.js +117 -134
  196. package/shared/definition48.cjs +151 -19
  197. package/shared/definition48.js +150 -18
  198. package/shared/definition49.cjs +21 -84
  199. package/shared/definition49.js +20 -83
  200. package/shared/definition5.cjs +100 -19
  201. package/shared/definition5.js +100 -19
  202. package/shared/definition50.cjs +52 -505
  203. package/shared/definition50.js +51 -504
  204. package/shared/definition51.cjs +526 -28
  205. package/shared/definition51.js +525 -27
  206. package/shared/definition52.cjs +28 -123
  207. package/shared/definition52.js +26 -122
  208. package/shared/definition53.cjs +110 -309
  209. package/shared/definition53.js +110 -308
  210. package/shared/definition54.cjs +255 -271
  211. package/shared/definition54.js +255 -271
  212. package/shared/definition55.cjs +315 -776
  213. package/shared/definition55.js +314 -775
  214. package/shared/definition56.cjs +818 -107
  215. package/shared/definition56.js +817 -106
  216. package/shared/definition57.cjs +85 -55
  217. package/shared/definition57.js +84 -54
  218. package/shared/definition58.cjs +125 -72
  219. package/shared/definition58.js +124 -71
  220. package/shared/definition59.cjs +72 -285
  221. package/shared/definition59.js +73 -286
  222. package/shared/definition6.cjs +1 -1
  223. package/shared/definition6.js +1 -1
  224. package/shared/definition60.cjs +298 -39
  225. package/shared/definition60.js +297 -38
  226. package/shared/definition61.cjs +66044 -1687
  227. package/shared/definition61.js +66043 -1686
  228. package/shared/definition62.cjs +50 -0
  229. package/shared/definition62.js +46 -0
  230. package/shared/definition63.cjs +1828 -0
  231. package/shared/definition63.js +1824 -0
  232. package/shared/definition7.cjs +2 -2
  233. package/shared/definition7.js +2 -2
  234. package/shared/definition8.cjs +2 -2
  235. package/shared/definition8.js +2 -2
  236. package/shared/definition9.cjs +1 -1
  237. package/shared/definition9.js +1 -1
  238. package/shared/enums.cjs +9 -0
  239. package/shared/enums.js +9 -1
  240. package/shared/icon.cjs +20 -2
  241. package/shared/icon.js +21 -3
  242. package/shared/index2.cjs +73 -37
  243. package/shared/index2.js +73 -37
  244. package/shared/key-codes2.js +1 -1
  245. package/shared/listbox.cjs +1 -1
  246. package/shared/listbox.js +1 -1
  247. package/shared/localization/Locale.d.ts +4 -0
  248. package/shared/patterns/form-elements/form-elements.d.ts +2 -3
  249. package/shared/presentationDate.cjs +16 -5
  250. package/shared/presentationDate.js +16 -5
  251. package/shared/text-anchor.cjs +6 -0
  252. package/shared/text-anchor.js +6 -0
  253. package/shared/text-anchor.template.cjs +6 -1
  254. package/shared/text-anchor.template.js +6 -1
  255. package/shared/text-field.cjs +1 -1
  256. package/shared/text-field.js +1 -1
  257. package/shared/utils/applyMixinsWithObservables.d.ts +1 -0
  258. package/shared/utils/numberConverter.d.ts +2 -0
  259. package/side-drawer/index.cjs +1 -1
  260. package/side-drawer/index.js +1 -1
  261. package/slider/index.cjs +1 -1
  262. package/slider/index.js +1 -1
  263. package/split-button/index.cjs +2 -2
  264. package/split-button/index.js +2 -2
  265. package/styles/core/all.css +1 -1
  266. package/styles/core/theme.css +1 -1
  267. package/styles/core/typography.css +1 -1
  268. package/styles/tokens/theme-dark.css +4 -4
  269. package/styles/tokens/theme-light.css +4 -4
  270. package/styles/tokens/vivid-2-compat.css +1 -1
  271. package/switch/index.cjs +2 -2
  272. package/switch/index.js +2 -2
  273. package/tab/index.cjs +2 -2
  274. package/tab/index.js +2 -2
  275. package/tab-panel/index.cjs +1 -1
  276. package/tab-panel/index.js +1 -1
  277. package/tabs/index.cjs +4 -4
  278. package/tabs/index.js +4 -4
  279. package/tag/index.cjs +2 -2
  280. package/tag/index.js +2 -2
  281. package/tag-group/index.cjs +1 -1
  282. package/tag-group/index.js +1 -1
  283. package/text-area/index.cjs +4 -3
  284. package/text-area/index.js +4 -3
  285. package/text-field/index.cjs +4 -3
  286. package/text-field/index.js +4 -3
  287. package/time-picker/index.cjs +8 -7
  288. package/time-picker/index.js +8 -7
  289. package/toggletip/index.cjs +5 -5
  290. package/toggletip/index.js +5 -5
  291. package/tooltip/index.cjs +5 -5
  292. package/tooltip/index.js +5 -5
  293. package/tree-item/index.cjs +2 -2
  294. package/tree-item/index.js +2 -2
  295. package/tree-view/index.cjs +1 -1
  296. package/tree-view/index.js +1 -1
  297. package/video-player/index.cjs +17 -0
  298. package/video-player/index.js +15 -0
  299. package/vivid.api.json +332 -0
@@ -1,217 +1,82 @@
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 './definition54.js';
3
- import { P as Popup, p as popupRegistries } from './definition61.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 { F as FormAssociated } from './form-associated.js';
10
- import { a as applyMixins } from './apply-mixins.js';
11
- import { r as ref } from './ref.js';
1
+ import { a as attr, o as observable, h as html, r as registerFactory } from './index.js';
2
+ import { a as iconRegistries } from './definition27.js';
3
+ import { A as AffixIcon, a as affixIconTemplateFactory } from './affix.js';
4
+ import { e as errorText, f as formElements, F as FormElementSuccessText, a as FormElementHelperText, b as FormElementCharCount, g as getFeedbackTemplate } from './index2.js';
5
+ import { R as Reflector } from './Reflector.js';
6
+ import { a as applyMixinsWithObservables } from './applyMixinsWithObservables.js';
7
+ import { m as memoizeWith } from './icon.js';
8
+ import { T as TextField$1 } from './text-field2.js';
9
+ import { s as styles } from './text-field.js';
12
10
  import { w as when } from './when.js';
13
- import { r as repeat } from './repeat.js';
11
+ import { s as slotted } from './slotted.js';
14
12
  import { c as classNames } from './class-names.js';
15
13
 
16
- 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";
14
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
15
+ // require the crypto API and do not support built-in fallback to lower quality random number
16
+ // generators (like Math.random()).
17
+ let getRandomValues;
18
+ const rnds8 = new Uint8Array(16);
19
+ function rng() {
20
+ // lazy load so that environments that need to polyfill have a chance to do so
21
+ if (!getRandomValues) {
22
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
23
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
17
24
 
18
- class _TimePicker extends FoundationElement {
19
- }
20
- class FormAssociatedTimePicker extends FormAssociated(_TimePicker) {
21
- constructor() {
22
- super(...arguments);
23
- this.proxy = document.createElement("input");
25
+ if (!getRandomValues) {
26
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
27
+ }
24
28
  }
29
+
30
+ return getRandomValues(rnds8);
25
31
  }
26
32
 
27
- const isValidTimeStr = (timeStr) => {
28
- const parts = timeStr.split(":");
29
- if (parts.length !== 3) {
30
- return false;
31
- }
32
- const [hours, minutes, seconds] = parts;
33
- if (hours.length !== 2 || minutes.length !== 2 || seconds.length !== 2) {
34
- return false;
35
- }
36
- const hoursNum = parseInt(hours, 10);
37
- const minutesNum = parseInt(minutes, 10);
38
- const secondsNum = parseInt(seconds, 10);
39
- if (isNaN(hoursNum) || isNaN(minutesNum) || isNaN(secondsNum)) {
40
- return false;
41
- }
42
- if (hoursNum < 0 || hoursNum > 23) {
43
- return false;
44
- }
45
- if (minutesNum < 0 || minutesNum > 59) {
46
- return false;
47
- }
48
- if (secondsNum < 0 || secondsNum > 59) {
49
- return false;
50
- }
51
- return true;
52
- };
53
- const parseTimePart = (partStr) => Number.parseInt(partStr, 10);
54
- const formatTimePart = (part) => part.toString().padStart(2, "0");
55
- const parseTimeStr = (timeStr) => {
56
- const [hoursStr, minutesStr, secondsStr] = timeStr.split(":");
57
- const hours = parseTimePart(hoursStr);
58
- const minutes = parseTimePart(minutesStr);
59
- const seconds = parseTimePart(secondsStr);
60
- return {
61
- hourStr: hoursStr,
62
- hours,
63
- minuteStr: minutesStr,
64
- minutes,
65
- secondStr: secondsStr,
66
- seconds,
67
- meridiem: hours < 12 ? "AM" : "PM"
68
- };
69
- };
70
- const hoursAs12hClock = (hour) => hour % 12 || 12;
33
+ /**
34
+ * Convert array of 16 byte values to UUID string format of the form:
35
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
36
+ */
71
37
 
72
- const formatPresentationTime = (timeStr, includeSeconds, use12HourClock) => {
73
- const time = parseTimeStr(timeStr);
74
- const hoursStr = formatTimePart(
75
- use12HourClock ? hoursAs12hClock(time.hours) : time.hours
76
- );
77
- let result = `${hoursStr}:${time.minuteStr}`;
78
- if (includeSeconds) {
79
- result += `:${time.secondStr}`;
80
- }
81
- if (use12HourClock) {
82
- result += ` ${time.meridiem}`;
83
- }
84
- return result;
85
- };
86
- const isDigit = (char) => char >= "0" && char <= "9";
87
- const parsePresentationTime = (input, use12HourClock) => {
88
- const cleanedInput = input.toLowerCase();
89
- const numerals = [];
90
- let meridiem;
91
- for (let i = 0; i < cleanedInput.length; i++) {
92
- const char = cleanedInput[i];
93
- if (char === "a" && cleanedInput[i + 1] === "m") {
94
- i++;
95
- meridiem = "AM";
96
- }
97
- if (char === "p" && cleanedInput[i + 1] === "m") {
98
- i++;
99
- meridiem = "PM";
100
- }
101
- if (isDigit(char)) {
102
- let numeral = char;
103
- while (isDigit(cleanedInput[i + 1])) {
104
- i++;
105
- numeral += cleanedInput[i];
106
- }
107
- numerals.push(Number.parseInt(numeral, 10));
108
- }
109
- }
110
- if (numerals.length === 0 || numerals.length > 3) {
111
- throw new Error("Invalid time format");
112
- }
113
- if (meridiem && (numerals[0] < 1 || numerals[0] > 12)) {
114
- throw new Error("Invalid time format");
115
- }
116
- if (meridiem || use12HourClock) {
117
- if (numerals[0] === 12) {
118
- numerals[0] = 0;
119
- }
120
- }
121
- if (meridiem === "PM") {
122
- numerals[0] = numerals[0] + 12;
123
- }
124
- const [hours, minutes = 0, seconds = 0] = numerals;
125
- if (hours > 23 || minutes > 59 || seconds > 59) {
126
- throw new Error("Invalid value");
127
- }
128
- return [hours, minutes, seconds].map(formatTimePart).join(":");
129
- };
38
+ const byteToHex = [];
130
39
 
131
- const fallsIntoMeridiem = (meridiem, hour) => meridiem === "AM" && hour < 12 || meridiem === "PM" && hour >= 12;
132
- const getHoursOptions = (min, max, forMeridiem) => {
133
- const result = [];
134
- const minHour = min ? parseTimeStr(min).hours : 0;
135
- const maxHour = max ? parseTimeStr(max).hours : 23;
136
- for (let i = minHour; i <= maxHour; i++) {
137
- if (forMeridiem && !fallsIntoMeridiem(forMeridiem, i)) {
138
- continue;
139
- }
140
- result.push({
141
- value: formatTimePart(i),
142
- label: formatTimePart(forMeridiem ? hoursAs12hClock(i) : i)
143
- });
144
- }
145
- return result;
146
- };
147
- const getMinutesOptions = (step, value, min, max) => {
148
- const result = [];
149
- let minMinute = 0;
150
- let maxMinute = 59;
151
- if (min) {
152
- const { hourStr: minHourStr, minutes: minMinutes } = parseTimeStr(min);
153
- if (value && parseTimeStr(value).hourStr === minHourStr) {
154
- minMinute = minMinutes;
155
- }
156
- }
157
- if (max) {
158
- const { hourStr: maxHourStr, minutes: maxMinutes } = parseTimeStr(max);
159
- if (value && parseTimeStr(value).hourStr === maxHourStr) {
160
- maxMinute = maxMinutes;
161
- }
162
- }
163
- for (let i = minMinute; i <= maxMinute; i += Math.max(1, step ?? 1)) {
164
- const minutes = formatTimePart(i);
165
- result.push({
166
- value: minutes,
167
- label: minutes
168
- });
169
- }
170
- return result;
40
+ for (let i = 0; i < 256; ++i) {
41
+ byteToHex.push((i + 0x100).toString(16).slice(1));
42
+ }
43
+
44
+ function unsafeStringify(arr, offset = 0) {
45
+ // Note: Be careful editing this code! It's been tuned for performance
46
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
47
+ return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
48
+ }
49
+
50
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
51
+ const native = {
52
+ randomUUID
171
53
  };
172
- const getSecondsOptions = (step, value, min, max) => {
173
- const result = [];
174
- let minSecond = 0;
175
- let maxSecond = 59;
176
- if (min) {
177
- const minTime = parseTimeStr(min);
178
- if (value && (parseTimeStr(value).hourStr === minTime.hourStr && parseTimeStr(value).minuteStr) === minTime.minuteStr) {
179
- minSecond = minTime.seconds;
180
- }
54
+
55
+ function v4(options, buf, offset) {
56
+ if (native.randomUUID && !buf && !options) {
57
+ return native.randomUUID();
181
58
  }
182
- if (max) {
183
- const maxTime = parseTimeStr(max);
184
- if (value && (parseTimeStr(value).hourStr === maxTime.hourStr && parseTimeStr(value).minuteStr) === maxTime.minuteStr) {
185
- maxSecond = maxTime.seconds;
59
+
60
+ options = options || {};
61
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
62
+
63
+ rnds[6] = rnds[6] & 0x0f | 0x40;
64
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
65
+
66
+ if (buf) {
67
+ offset = offset || 0;
68
+
69
+ for (let i = 0; i < 16; ++i) {
70
+ buf[offset + i] = rnds[i];
186
71
  }
72
+
73
+ return buf;
187
74
  }
188
- for (let i = minSecond; i <= maxSecond; i += Math.max(1, step)) {
189
- const seconds = formatTimePart(i);
190
- result.push({
191
- value: seconds,
192
- label: seconds
193
- });
194
- }
195
- return result;
196
- };
197
- const getMeridiesOptions = (min, max) => {
198
- const result = [];
199
- const hideAM = min ? parseTimeStr(min).meridiem === "PM" : false;
200
- if (!hideAM) {
201
- result.push({
202
- value: "AM",
203
- label: "AM"
204
- });
205
- }
206
- const hidePM = max ? parseTimeStr(max).meridiem === "AM" : false;
207
- if (!hidePM) {
208
- result.push({
209
- value: "PM",
210
- label: "PM"
211
- });
212
- }
213
- return result;
214
- };
75
+
76
+ return unsafeStringify(rnds);
77
+ }
78
+
79
+ const generateRandomId = () => v4();
215
80
 
216
81
  var __defProp = Object.defineProperty;
217
82
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -237,639 +102,313 @@ var __privateAdd = (obj, member, value) => {
237
102
  throw TypeError("Cannot add the same private member more than once");
238
103
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
239
104
  };
105
+ var __privateSet = (obj, member, value, setter) => {
106
+ __accessCheck(obj, member, "write to private field");
107
+ setter ? setter.call(obj, value) : member.set(obj, value);
108
+ return value;
109
+ };
240
110
  var __privateMethod = (obj, member, method) => {
241
111
  __accessCheck(obj, member, "access private method");
242
112
  return method;
243
113
  };
244
- var _getFocusableEls, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn, _onFocusIn, _onFocusOut, _dismissOnClickOutside, _openPopupIfPossible, openPopupIfPossible_fn, _scrollToItem, scrollToItem_fn;
245
- const ValidTimeFilter = {
246
- fromView: (value) => {
247
- if (value && isValidTimeStr(value)) {
248
- return value;
249
- }
250
- return "";
251
- },
252
- toView(value) {
253
- return value;
114
+ var _handleLabelChange, handleLabelChange_fn, _reflectToInput, _helperTextMirrorEl, _helperTextSlotMutationObserver, _updateHelperTextMutationObserver, updateHelperTextMutationObserver_fn, _updateMirroredHelperText, updateMirroredHelperText_fn;
115
+ const safariWorkaroundClassName = "_vvd-3-text-field-safari-workaround";
116
+ const getSafariWorkaroundStyleSheet = memoizeWith(
117
+ () => "",
118
+ () => {
119
+ const styleSheet = new CSSStyleSheet();
120
+ const supportsReplaceSync = "replaceSync" in styleSheet;
121
+ if (supportsReplaceSync) {
122
+ styleSheet.replaceSync(`
123
+ .${safariWorkaroundClassName}::placeholder {
124
+ opacity: 1 !important;
125
+ -webkit-text-fill-color: var(--_low-ink-color) !important;
126
+ }`);
127
+ }
128
+ return styleSheet;
129
+ }
130
+ );
131
+ const installSafariWorkaroundStyle = (forElement) => {
132
+ const root = forElement.getRootNode();
133
+ const workaroundStyleSheet = getSafariWorkaroundStyleSheet();
134
+ const supportsAdoptedStyleSheets = "adoptedStyleSheets" in root;
135
+ if (!supportsAdoptedStyleSheets) {
136
+ return;
137
+ }
138
+ if (!root.adoptedStyleSheets.includes(workaroundStyleSheet)) {
139
+ root.adoptedStyleSheets = [
140
+ ...root.adoptedStyleSheets,
141
+ workaroundStyleSheet
142
+ ];
254
143
  }
255
144
  };
256
- let TimePicker = class extends FormAssociatedTimePicker {
145
+ let TextField = class extends TextField$1 {
257
146
  constructor() {
258
- super();
259
- __privateAdd(this, _updateValueDueToUserInteraction);
260
- __privateAdd(this, _openPopupIfPossible);
261
- __privateAdd(this, _scrollToItem);
262
- this.readOnly = false;
263
- this.minutesStep = null;
264
- this.secondsStep = null;
265
- __privateAdd(this, _getFocusableEls, () => this.shadowRoot.querySelectorAll(`
266
- .dialog [tabindex="0"],
267
- .dialog .vwc-button:not(:disabled)
268
- `));
269
- __privateAdd(this, _onFocusIn, () => {
270
- this.$emit("focus", void 0, { bubbles: false });
271
- });
272
- __privateAdd(this, _onFocusOut, () => {
273
- this.$emit("blur", void 0, { bubbles: false });
274
- });
275
- this._popupOpen = false;
276
- __privateAdd(this, _dismissOnClickOutside, (event) => {
277
- if (!this._popupOpen) {
278
- return;
279
- }
280
- const path = event.composedPath();
281
- const elementsToIgnoreClicksOn = [this._dialogEl, this._clockButtonEl];
282
- if (!elementsToIgnoreClicksOn.some((element) => path.includes(element))) {
283
- this._closePopup(false);
284
- }
285
- });
286
- this._presentationValue = "";
287
- this.value = "";
288
- this.min = "";
289
- this.max = "";
290
- this.proxy.type = "time";
291
- this.proxy.step = "1";
292
- }
293
- /**
294
- * @internal
295
- */
296
- readOnlyChanged() {
297
- if (this.proxy instanceof HTMLInputElement) {
298
- this.proxy.readOnly = this.readOnly;
299
- this.validate();
300
- }
301
- }
302
- /**
303
- * @internal
304
- */
305
- minChanged(_, newMin) {
306
- if (this.proxy instanceof HTMLInputElement) {
307
- this.proxy.min = newMin;
308
- this.validate();
309
- }
310
- }
311
- /**
312
- * @internal
313
- */
314
- maxChanged(_, newMax) {
315
- if (this.proxy instanceof HTMLInputElement) {
316
- this.proxy.max = newMax;
317
- this.validate();
318
- }
319
- }
320
- // --- Core ---
321
- /**
322
- * @internal
323
- */
324
- get _displaySeconds() {
325
- return this.secondsStep !== null;
326
- }
327
- /**
328
- * @internal
329
- */
330
- get _use12hClock() {
331
- return this.clock ? this.clock === "12h" : this.locale.timePicker.defaultTo12HourClock;
147
+ super(...arguments);
148
+ __privateAdd(this, _handleLabelChange);
149
+ __privateAdd(this, _updateHelperTextMutationObserver);
150
+ __privateAdd(this, _updateMirroredHelperText);
151
+ /**
152
+ * @internal
153
+ */
154
+ this._labelEl = null;
155
+ __privateAdd(this, _reflectToInput, void 0);
156
+ __privateAdd(this, _helperTextMirrorEl, void 0);
157
+ __privateAdd(this, _helperTextSlotMutationObserver, void 0);
332
158
  }
333
159
  /**
334
160
  * @internal
335
161
  */
336
- valueChanged(previous, next) {
337
- super.valueChanged(previous, next);
338
- if (this.value) {
339
- if (!isValidTimeStr(this.value)) {
340
- this.value = "";
341
- return;
342
- }
343
- this._presentationValue = formatPresentationTime(
344
- this.value,
345
- this._displaySeconds,
346
- this._use12hClock
347
- );
348
- } else {
349
- this._presentationValue = "";
162
+ labelChanged() {
163
+ if (this._labelEl) {
164
+ __privateMethod(this, _handleLabelChange, handleLabelChange_fn).call(this, this._labelEl);
350
165
  }
351
166
  }
352
167
  connectedCallback() {
353
168
  super.connectedCallback();
354
- document.addEventListener("click", __privateGet(this, _dismissOnClickOutside));
355
- this.addEventListener("focusin", __privateGet(this, _onFocusIn));
356
- this.addEventListener("focusout", __privateGet(this, _onFocusOut));
169
+ if (!this.control) {
170
+ const uniqueId = this.id || generateRandomId();
171
+ const controlId = `vvd-text-field-control-${uniqueId}`;
172
+ const helperTextId = `vvd-text-field-helper-text-${uniqueId}`;
173
+ const input = document.createElement("input");
174
+ input.slot = "_control";
175
+ input.id = controlId;
176
+ input.className = safariWorkaroundClassName;
177
+ this.control = input;
178
+ input.addEventListener("input", () => {
179
+ this.handleTextInput();
180
+ });
181
+ input.addEventListener("change", () => {
182
+ this.handleChange();
183
+ });
184
+ input.addEventListener("blur", () => {
185
+ this.$emit("blur", void 0, { bubbles: false });
186
+ });
187
+ input.addEventListener("focus", () => {
188
+ this.$emit("focus", void 0, { bubbles: false });
189
+ });
190
+ this.appendChild(input);
191
+ const label = document.createElement("label");
192
+ label.slot = "_label";
193
+ label.htmlFor = controlId;
194
+ this._labelEl = label;
195
+ __privateMethod(this, _handleLabelChange, handleLabelChange_fn).call(this, label);
196
+ __privateSet(this, _helperTextMirrorEl, document.createElement("div"));
197
+ __privateGet(this, _helperTextMirrorEl).id = helperTextId;
198
+ __privateGet(this, _helperTextMirrorEl).slot = "_mirrored-helper-text";
199
+ __privateMethod(this, _updateMirroredHelperText, updateMirroredHelperText_fn).call(this);
200
+ this.appendChild(__privateGet(this, _helperTextMirrorEl));
201
+ installSafariWorkaroundStyle(this);
202
+ }
203
+ __privateSet(this, _reflectToInput, new Reflector(this, this.control));
204
+ __privateGet(this, _reflectToInput).booleanAttribute("autofocus", "autofocus");
205
+ __privateGet(this, _reflectToInput).booleanAttribute("disabled", "disabled");
206
+ __privateGet(this, _reflectToInput).booleanAttribute("readOnly", "readonly");
207
+ __privateGet(this, _reflectToInput).booleanAttribute("required", "required");
208
+ __privateGet(this, _reflectToInput).booleanAttribute("spellcheck", "spellcheck");
209
+ __privateGet(this, _reflectToInput).attribute("list", "list");
210
+ __privateGet(this, _reflectToInput).attribute("maxlength", "maxlength");
211
+ __privateGet(this, _reflectToInput).attribute("minlength", "minlength");
212
+ __privateGet(this, _reflectToInput).attribute("pattern", "pattern");
213
+ __privateGet(this, _reflectToInput).attribute("placeholder", "placeholder");
214
+ __privateGet(this, _reflectToInput).attribute("size", "size");
215
+ __privateGet(this, _reflectToInput).attribute("autoComplete", "autocomplete");
216
+ __privateGet(this, _reflectToInput).attribute("type", "type");
217
+ __privateGet(this, _reflectToInput).attribute("ariaAtomic", "aria-atomic");
218
+ __privateGet(this, _reflectToInput).attribute("ariaBusy", "aria-busy");
219
+ __privateGet(this, _reflectToInput).attribute("ariaCurrent", "aria-current");
220
+ __privateGet(this, _reflectToInput).attribute("ariaDetails", "aria-details");
221
+ __privateGet(this, _reflectToInput).attribute("ariaDisabled", "aria-disabled");
222
+ __privateGet(this, _reflectToInput).attribute("ariaHaspopup", "aria-haspopup");
223
+ __privateGet(this, _reflectToInput).attribute("ariaHidden", "aria-hidden");
224
+ __privateGet(this, _reflectToInput).attribute("ariaInvalid", "aria-invalid");
225
+ __privateGet(this, _reflectToInput).attribute("ariaKeyshortcuts", "aria-keyshortcuts");
226
+ __privateGet(this, _reflectToInput).attribute("ariaLabel", "aria-label");
227
+ __privateGet(this, _reflectToInput).attribute("ariaLive", "aria-live");
228
+ __privateGet(this, _reflectToInput).attribute("ariaRelevant", "aria-relevant");
229
+ __privateGet(this, _reflectToInput).attribute(
230
+ "ariaRoledescription",
231
+ "aria-roledescription"
232
+ );
233
+ __privateGet(this, _reflectToInput).property("value", "value", true);
234
+ __privateMethod(this, _updateHelperTextMutationObserver, updateHelperTextMutationObserver_fn).call(this);
357
235
  }
358
236
  disconnectedCallback() {
359
237
  super.disconnectedCallback();
360
- document.removeEventListener("click", __privateGet(this, _dismissOnClickOutside));
361
- this.removeEventListener("focusin", __privateGet(this, _onFocusIn));
362
- this.removeEventListener("focusout", __privateGet(this, _onFocusOut));
238
+ __privateGet(this, _reflectToInput).destroy();
239
+ __privateSet(this, _reflectToInput, void 0);
240
+ __privateMethod(this, _updateHelperTextMutationObserver, updateHelperTextMutationObserver_fn).call(this);
363
241
  }
364
- /**
365
- * @internal
366
- */
367
- _closePopup(restoreFocusToTextField = true) {
368
- this._popupOpen = false;
369
- if (restoreFocusToTextField) {
370
- this._textFieldEl.focus();
371
- }
242
+ focus() {
243
+ this.control?.focus();
372
244
  }
373
245
  /**
374
- * On keydown anywhere in the time picker.
375
246
  * @internal
376
247
  */
377
- _onBaseKeyDown(event) {
378
- if (event.key === "Escape") {
379
- this._closePopup();
380
- return false;
381
- }
382
- if (this._trappedFocus(event, __privateGet(this, _getFocusableEls))) {
383
- return false;
384
- }
385
- return true;
248
+ helperTextChanged() {
249
+ __privateMethod(this, _updateMirroredHelperText, updateMirroredHelperText_fn).call(this);
386
250
  }
387
251
  /**
388
252
  * @internal
389
253
  */
390
- _presentationValueChanged() {
391
- this.dirtyValue = true;
392
- this.validate();
254
+ _helperTextSlottedContentChanged() {
255
+ __privateMethod(this, _updateMirroredHelperText, updateMirroredHelperText_fn).call(this);
256
+ __privateMethod(this, _updateHelperTextMutationObserver, updateHelperTextMutationObserver_fn).call(this);
393
257
  }
394
- /**
395
- * @internal
396
- */
397
- get _textFieldPlaceholder() {
398
- let format = "hh:mm";
399
- if (this._displaySeconds) {
400
- format += ":ss";
401
- }
402
- if (this._use12hClock) {
403
- format += " aa";
404
- }
405
- return format;
406
- }
407
- /**
408
- * @internal
409
- */
410
- _onTextFieldInput(event) {
411
- const textField = event.currentTarget;
412
- this._presentationValue = textField.value;
413
- }
414
- /**
415
- * @internal
416
- */
417
- _onTextFieldChange() {
418
- if (this._presentationValue === "") {
419
- __privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, "");
420
- return;
421
- }
422
- try {
423
- __privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, parsePresentationTime(this._presentationValue, this._use12hClock));
424
- } catch (_) {
425
- return;
426
- }
427
- }
428
- // --- Clock button ---
429
- /**
430
- * @internal
431
- */
432
- get _clockButtonLabel() {
433
- if (this.value) {
434
- return this.locale.timePicker.changeTimeLabel(
435
- formatPresentationTime(
436
- this.value,
437
- this._displaySeconds,
438
- this._use12hClock
439
- )
440
- );
441
- }
442
- return this.locale.timePicker.chooseTimeLabel;
443
- }
444
- /**
445
- * @internal
446
- */
447
- _onClockButtonClick() {
448
- if (this._popupOpen) {
449
- this._closePopup();
450
- } else {
451
- __privateMethod(this, _openPopupIfPossible, openPopupIfPossible_fn).call(this);
452
- DOM.processUpdates();
453
- if (this._selectedHour) {
454
- __privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, "hours", this._selectedHour, "start");
455
- }
456
- if (this._selectedMinute) {
457
- __privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, "minutes", this._selectedMinute, "start");
458
- }
459
- if (this._displaySeconds && this._selectedSecond) {
460
- __privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, "seconds", this._selectedSecond, "start");
461
- }
462
- if (this._use12hClock && this._selectedMeridiem) {
463
- __privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, "meridies", this._selectedMeridiem, "start");
464
- }
465
- __privateGet(this, _getFocusableEls).call(this)[0].focus();
466
- }
467
- }
468
- // --- Pickers ---
469
- /**
470
- * @internal
471
- */
472
- get _hours() {
473
- return getHoursOptions(
474
- this.min,
475
- this.max,
476
- this._use12hClock ? this._selectedMeridiem ?? this._meridies[0].value : void 0
477
- );
478
- }
479
- /**
480
- * @internal
481
- */
482
- get _selectedHour() {
483
- return this.value ? parseTimeStr(this.value).hourStr : void 0;
484
- }
485
- /**
486
- * @internal
487
- */
488
- set _selectedHour(value) {
489
- if (this.value) {
490
- const { minuteStr, secondStr } = parseTimeStr(this.value);
491
- this.value = `${value}:${minuteStr}:${secondStr}`;
492
- } else {
493
- this.value = `${value}:00:00`;
494
- }
495
- }
496
- /**
497
- * @internal
498
- */
499
- get _minutes() {
500
- return getMinutesOptions(this.minutesStep, this.value, this.min, this.max);
501
- }
502
- /**
503
- * @internal
504
- */
505
- get _selectedMinute() {
506
- return this.value ? parseTimeStr(this.value).minuteStr : void 0;
507
- }
508
- /**
509
- * @internal
510
- */
511
- set _selectedMinute(value) {
512
- if (this.value) {
513
- const { hourStr, secondStr } = parseTimeStr(this.value);
514
- this.value = `${hourStr}:${value}:${secondStr}`;
515
- } else {
516
- this.value = `00:${value}:00`;
517
- }
518
- }
519
- /**
520
- * @internal
521
- */
522
- get _seconds() {
523
- return getSecondsOptions(this.secondsStep, this.value, this.min, this.max);
524
- }
525
- /**
526
- * @internal
527
- */
528
- get _selectedSecond() {
529
- return this.value ? parseTimeStr(this.value).secondStr : void 0;
530
- }
531
- /**
532
- * @internal
533
- */
534
- set _selectedSecond(value) {
535
- if (this.value) {
536
- const { hourStr, minuteStr } = parseTimeStr(this.value);
537
- this.value = `${hourStr}:${minuteStr}:${value}`;
538
- } else {
539
- this.value = `00:00:${value}`;
258
+ };
259
+ _handleLabelChange = new WeakSet();
260
+ handleLabelChange_fn = function(labelEl) {
261
+ if (!this.label) {
262
+ labelEl.remove();
263
+ } else {
264
+ labelEl.textContent = this.label;
265
+ if (!labelEl.isConnected) {
266
+ this.appendChild(labelEl);
540
267
  }
541
268
  }
542
- /**
543
- * @internal
544
- */
545
- get _meridies() {
546
- return getMeridiesOptions(this.min, this.max);
547
- }
548
- /**
549
- * @internal
550
- */
551
- get _selectedMeridiem() {
552
- return this.value ? parseTimeStr(this.value).meridiem : void 0;
553
- }
554
- /**
555
- * @internal
556
- */
557
- set _selectedMeridiem(value) {
558
- if (this.value) {
559
- const { hours, minuteStr, secondStr } = parseTimeStr(this.value);
560
- let adjustedHours = hours;
561
- if (value === "AM" && hours >= 12) {
562
- adjustedHours -= 12;
563
- } else if (value === "PM" && hours < 12) {
564
- adjustedHours += 12;
565
- }
566
- this.value = `${formatTimePart(adjustedHours)}:${minuteStr}:${secondStr}`;
567
- } else {
568
- if (value === "AM") {
569
- this.value = "00:00:00";
570
- } else {
571
- this.value = "12:00:00";
269
+ };
270
+ _reflectToInput = new WeakMap();
271
+ _helperTextMirrorEl = new WeakMap();
272
+ _helperTextSlotMutationObserver = new WeakMap();
273
+ _updateHelperTextMutationObserver = new WeakSet();
274
+ updateHelperTextMutationObserver_fn = function() {
275
+ const usesHelperTextSlot = this._helperTextSlottedContent.length;
276
+ const shouldHaveMutationObserver = usesHelperTextSlot && this.isConnected;
277
+ if (shouldHaveMutationObserver && !__privateGet(this, _helperTextSlotMutationObserver)) {
278
+ __privateSet(this, _helperTextSlotMutationObserver, new MutationObserver((records) => {
279
+ if (records.some((record) => record.target !== __privateGet(this, _helperTextMirrorEl))) {
280
+ __privateMethod(this, _updateMirroredHelperText, updateMirroredHelperText_fn).call(this);
572
281
  }
573
- }
282
+ }));
283
+ __privateGet(this, _helperTextSlotMutationObserver).observe(this, {
284
+ subtree: true,
285
+ childList: true,
286
+ characterData: true
287
+ });
574
288
  }
575
- /**
576
- * @internal
577
- */
578
- _onPickerKeyDown(picker, options, selectedValue, setSelectedValue, event) {
579
- const offset = {
580
- ArrowUp: -1,
581
- ArrowDown: 1
582
- }[event.key];
583
- if (offset) {
584
- event.preventDefault();
585
- const index = options.findIndex((h) => h.value === selectedValue);
586
- const newRawIndex = index === -1 ? 0 : index + offset;
587
- const newIndex = (newRawIndex + options.length) % options.length;
588
- const newValue = options[newIndex].value;
589
- setSelectedValue(newValue);
590
- __privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, picker, newValue, "nearest");
591
- __privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, this.value);
592
- }
593
- return true;
289
+ if (!shouldHaveMutationObserver && __privateGet(this, _helperTextSlotMutationObserver)) {
290
+ __privateGet(this, _helperTextSlotMutationObserver).disconnect();
291
+ __privateSet(this, _helperTextSlotMutationObserver, void 0);
594
292
  }
595
- /**
596
- * @internal
597
- */
598
- _onPickerItemClick(picker, setSelectedValue, value) {
599
- setSelectedValue(value);
600
- __privateMethod(this, _scrollToItem, scrollToItem_fn).call(this, picker, value, "start");
601
- __privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, this.value);
602
- const nextPickerEl = this.shadowRoot.querySelector(
603
- `#${picker} + .picker`
604
- );
605
- if (nextPickerEl) {
606
- nextPickerEl.focus();
293
+ };
294
+ _updateMirroredHelperText = new WeakSet();
295
+ updateMirroredHelperText_fn = function() {
296
+ let helperText = this.helperText ?? "";
297
+ if (this._helperTextSlottedContent?.length) {
298
+ helperText = this._helperTextSlottedContent.map((node) => node.innerText).join(" ");
299
+ }
300
+ if (__privateGet(this, _helperTextMirrorEl)) {
301
+ __privateGet(this, _helperTextMirrorEl).textContent = helperText;
302
+ if (helperText) {
303
+ this.control.setAttribute(
304
+ "aria-describedby",
305
+ __privateGet(this, _helperTextMirrorEl).id
306
+ );
607
307
  } else {
608
- this._closePopup();
609
- }
610
- }
611
- // --- Dialog footer ---
612
- /**
613
- * @internal
614
- */
615
- _onOkClick() {
616
- this._closePopup();
617
- }
618
- /**
619
- * @internal
620
- */
621
- _onClearClick() {
622
- __privateMethod(this, _updateValueDueToUserInteraction, updateValueDueToUserInteraction_fn).call(this, "");
623
- this._closePopup();
624
- }
625
- // --- Validation ---
626
- /**
627
- * @internal
628
- */
629
- validate() {
630
- if (this.proxy) {
631
- this.proxy.setCustomValidity(this._getCustomValidationError() ?? "");
632
- }
633
- super.validate(this._textFieldEl?.querySelector("input") ?? void 0);
634
- }
635
- /**
636
- * @internal
637
- */
638
- _getCustomValidationError() {
639
- if (this._isPresentationValueInvalid()) {
640
- return this.locale.timePicker.invalidTimeError;
641
- }
642
- return null;
643
- }
644
- /**
645
- * @internal
646
- */
647
- _isPresentationValueInvalid() {
648
- if (this._presentationValue === "") {
649
- return false;
650
- }
651
- try {
652
- parsePresentationTime(this._presentationValue, this._use12hClock);
653
- return false;
654
- } catch (_) {
655
- return true;
308
+ this.control.removeAttribute("aria-describedby");
656
309
  }
657
310
  }
658
311
  };
659
- _getFocusableEls = new WeakMap();
660
- _updateValueDueToUserInteraction = new WeakSet();
661
- updateValueDueToUserInteraction_fn = function(newValue) {
662
- this.value = newValue;
663
- this.$emit("change");
664
- this.$emit("input");
665
- };
666
- _onFocusIn = new WeakMap();
667
- _onFocusOut = new WeakMap();
668
- _dismissOnClickOutside = new WeakMap();
669
- _openPopupIfPossible = new WeakSet();
670
- openPopupIfPossible_fn = function() {
671
- if (!this.readOnly) {
672
- this._popupOpen = true;
673
- }
674
- };
675
- _scrollToItem = new WeakSet();
676
- scrollToItem_fn = function(picker, selectedValue, position) {
677
- const element = this.shadowRoot.querySelector(
678
- `#${picker}-${selectedValue}`
679
- );
680
- if (!element) {
681
- return;
682
- }
683
- const parent = element.parentElement;
684
- switch (position) {
685
- case "start":
686
- parent.scrollTop = element.offsetTop;
687
- break;
688
- case "nearest":
689
- if (element.offsetTop < parent.scrollTop) {
690
- parent.scrollTop = element.offsetTop;
691
- }
692
- if (element.offsetTop + element.offsetHeight > parent.scrollTop + parent.offsetHeight) {
693
- parent.scrollTop = element.offsetTop + element.offsetHeight - parent.offsetHeight;
694
- }
695
- break;
696
- }
697
- };
698
- __decorateClass([
699
- attr({ attribute: "readonly", mode: "boolean" })
700
- ], TimePicker.prototype, "readOnly", 2);
701
- __decorateClass([
702
- attr({ attribute: "minutes-step", converter: nullableNumberConverter })
703
- ], TimePicker.prototype, "minutesStep", 2);
704
- __decorateClass([
705
- attr({ attribute: "seconds-step", converter: nullableNumberConverter })
706
- ], TimePicker.prototype, "secondsStep", 2);
707
312
  __decorateClass([
708
313
  attr
709
- ], TimePicker.prototype, "clock", 2);
314
+ ], TextField.prototype, "appearance", 2);
710
315
  __decorateClass([
711
- attr({ converter: ValidTimeFilter })
712
- ], TimePicker.prototype, "min", 2);
316
+ attr
317
+ ], TextField.prototype, "shape", 2);
713
318
  __decorateClass([
714
- attr({ converter: ValidTimeFilter })
715
- ], TimePicker.prototype, "max", 2);
319
+ attr
320
+ ], TextField.prototype, "autoComplete", 2);
716
321
  __decorateClass([
717
322
  observable
718
- ], TimePicker.prototype, "_popupOpen", 2);
323
+ ], TextField.prototype, "actionItemsSlottedContent", 2);
719
324
  __decorateClass([
720
325
  observable
721
- ], TimePicker.prototype, "_presentationValue", 2);
722
- TimePicker = __decorateClass([
326
+ ], TextField.prototype, "leadingActionItemsSlottedContent", 2);
327
+ TextField = __decorateClass([
723
328
  errorText,
724
329
  formElements
725
- ], TimePicker);
726
- applyMixins(TimePicker, Localized, FormElementHelperText, TrappedFocus);
330
+ ], TextField);
331
+ applyMixinsWithObservables(
332
+ TextField,
333
+ AffixIcon,
334
+ FormElementCharCount,
335
+ FormElementHelperText,
336
+ FormElementSuccessText
337
+ );
727
338
 
728
- const renderPicker = (id, getLabel, getSelected, setSelected, getOptions) => {
339
+ const getStateClasses = ({
340
+ errorValidationMessage,
341
+ disabled,
342
+ value,
343
+ readOnly,
344
+ placeholder,
345
+ appearance,
346
+ shape,
347
+ label,
348
+ successText,
349
+ actionItemsSlottedContent,
350
+ leadingActionItemsSlottedContent,
351
+ icon
352
+ }) => classNames(
353
+ ["error", Boolean(errorValidationMessage)],
354
+ ["disabled", disabled],
355
+ ["has-value", Boolean(value)],
356
+ ["readonly", readOnly],
357
+ ["placeholder", Boolean(placeholder)],
358
+ [`appearance-${appearance}`, Boolean(appearance)],
359
+ [`shape-${shape}`, Boolean(shape)],
360
+ ["no-label", !label],
361
+ ["has-icon", !!icon],
362
+ ["success", Boolean(successText)],
363
+ ["action-items", !!actionItemsSlottedContent?.length],
364
+ ["leading-action-items", !!leadingActionItemsSlottedContent?.length],
365
+ ["no-leading", !(leadingActionItemsSlottedContent?.length || icon)]
366
+ );
367
+ function renderCharCount() {
729
368
  return html`
730
- <ul
731
- id="${id}"
732
- class="picker"
733
- role="listbox"
734
- tabindex="0"
735
- aria-label="${getLabel}"
736
- aria-activedescendant="${(x) => getSelected(x) ? `${id}-${getSelected(x)}` : void 0}"
737
- @keydown="${(x, c) => x._onPickerKeyDown(
738
- id,
739
- getOptions(x),
740
- getSelected(x),
741
- setSelected(x),
742
- c.event
743
- )}"
369
+ <span class="char-count"
370
+ >${(x) => x.value ? x.value.length : 0} / ${(x) => x.maxlength}</span
744
371
  >
745
- ${repeat(
746
- getOptions,
747
- html`
748
- <li
749
- id="${(x) => `${id}-${x.value}`}"
750
- class="${(x, c) => classNames("item", [
751
- "selected",
752
- getSelected(c.parent) === x.value
753
- ])}"
754
- role="option"
755
- aria-selected="${(x, c) => getSelected(c.parent) === x.value}"
756
- @click="${(x, c) => c.parent._onPickerItemClick(id, setSelected(c.parent), x.value)}"
757
- >
758
- ${(x) => x.label}
759
- </li>
760
- `
761
- )}
762
- </ul>
763
372
  `;
764
- };
765
- const TimePickerTemplate = (context, _) => {
766
- const popupTag = context.tagFor(Popup);
767
- const textFieldTag = context.tagFor(TextField);
768
- const buttonTag = context.tagFor(Button);
769
- return html`<div class="base" @keydown="${(x, { event }) => x._onBaseKeyDown(event)}">
770
- <${textFieldTag} id="text-field"
771
- ${ref("_textFieldEl")}
772
- class="control"
773
- label="${(x) => x.label}"
774
- helper-text="${(x) => x.helperText}"
775
- error-text="${(x) => x.errorValidationMessage}"
776
- placeholder="${(x) => x._textFieldPlaceholder}"
777
- current-value="${(x) => x._presentationValue}"
778
- ?disabled="${(x) => x.disabled}"
779
- ?readonly="${(x) => x.readOnly}"
780
- @input="${(x, c) => x._onTextFieldInput(c.event)}"
781
- @change="${(x) => x._onTextFieldChange()}"
782
- >
783
- <${buttonTag}
784
- id="clock-button"
785
- ${ref("_clockButtonEl")}
786
- slot="action-items"
787
- size="condensed"
788
- icon="clock-line"
789
- appearance="ghost"
790
- ?disabled="${(x) => x.disabled || x.readOnly}"
791
- aria-label="${(x) => x._clockButtonLabel}"
792
- @click="${(x) => x._onClockButtonClick()}"
793
- ></${buttonTag}>
794
- </${textFieldTag}>
795
- <${popupTag}
796
- ?open="${(x) => x._popupOpen}"
797
- :anchor="${(x) => x._textFieldEl}"
798
- placement="bottom-start"
799
- class="popup">
800
- <div class="dialog" role="dialog" ${ref(
801
- "_dialogEl"
802
- )} aria-modal="true" aria-label="${(x) => x.locale.timePicker.chooseTimeLabel}">
803
- <div class="time-pickers">
804
- ${renderPicker(
805
- "hours",
806
- (x) => x.locale.timePicker.hoursLabel,
807
- (x) => x._selectedHour,
808
- (x) => (v) => x._selectedHour = v,
809
- (x) => x._hours
810
- )}
811
- ${renderPicker(
812
- "minutes",
813
- (x) => x.locale.timePicker.minutesLabel,
814
- (x) => x._selectedMinute,
815
- (x) => (v) => x._selectedMinute = v,
816
- (x) => x._minutes
817
- )}
818
- ${when(
819
- (x) => x._displaySeconds,
820
- renderPicker(
821
- "seconds",
822
- (x) => x.locale.timePicker.secondsLabel,
823
- (x) => x._selectedSecond,
824
- (x) => (v) => x._selectedSecond = v,
825
- (x) => x._seconds
826
- )
827
- )}
828
- ${when(
829
- (x) => x._use12hClock,
830
- renderPicker(
831
- "meridies",
832
- (x) => x.locale.timePicker.meridiesLabel,
833
- (x) => x._selectedMeridiem,
834
- (x) => (v) => x._selectedMeridiem = v,
835
- (x) => x._meridies
836
- )
837
- )}
373
+ }
374
+ const TextfieldTemplate = (context) => {
375
+ const affixIconTemplate = affixIconTemplateFactory(context);
376
+ return html` <div class="base ${getStateClasses}">
377
+ ${when((x) => x.charCount && x.maxlength, renderCharCount())}
378
+ <slot class="label" name="_label"></slot>
379
+ <div class="fieldset">
380
+ <div class="leading-items-wrapper">
381
+ <slot
382
+ name="leading-action-items"
383
+ ${slotted("leadingActionItemsSlottedContent")}
384
+ ></slot>
385
+ ${(x) => affixIconTemplate(x.icon)}
386
+ </div>
387
+
388
+ <div class="wrapper">
389
+ <slot class="control" name="_control"></slot>
838
390
  </div>
839
- <div class="footer">
840
- <${buttonTag}
841
- class="vwc-button"
842
- size="condensed"
843
- label="${(x) => x.locale.timePicker.clearLabel}"
844
- @click="${(x) => x._onClearClick()}"
845
- ></${buttonTag}>
846
- <${buttonTag}
847
- class="vwc-button"
848
- size="condensed"
849
- appearance="filled"
850
- label="${(x) => x.locale.timePicker.okLabel}"
851
- @click="${(x) => x._onOkClick()}"
852
- ></${buttonTag}>
391
+ <div class="action-items-wrapper">
392
+ <slot
393
+ name="action-items"
394
+ ${slotted("actionItemsSlottedContent")}
395
+ ></slot>
853
396
  </div>
854
397
  </div>
855
- </${popupTag}>
856
- </div>`;
398
+ ${getFeedbackTemplate(context)}
399
+ </div>
400
+ <slot name="_mirrored-helper-text"></slot>`;
857
401
  };
858
402
 
859
- const timePickerDefinition = TimePicker.compose({
860
- baseName: "time-picker",
861
- template: TimePickerTemplate,
403
+ const textFieldDefinition = TextField.compose({
404
+ baseName: "text-field",
405
+ template: TextfieldTemplate,
862
406
  styles,
863
407
  shadowOptions: {
864
408
  delegatesFocus: true
865
409
  }
866
410
  });
867
- const timePickerRegistries = [
868
- timePickerDefinition(),
869
- ...textFieldRegistries,
870
- ...popupRegistries,
871
- ...buttonRegistries
872
- ];
873
- const registerTimePicker = registerFactory(timePickerRegistries);
411
+ const textFieldRegistries = [textFieldDefinition(), ...iconRegistries];
412
+ const registerTextField = registerFactory(textFieldRegistries);
874
413
 
875
- export { timePickerRegistries as a, registerTimePicker as r, timePickerDefinition as t };
414
+ export { TextField as T, textFieldRegistries as a, registerTextField as r, textFieldDefinition as t };