@vonage/vivid 3.52.0 → 3.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) 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/audio-player/index.cjs +3 -3
  9. package/audio-player/index.js +3 -3
  10. package/avatar/index.cjs +1 -1
  11. package/avatar/index.js +1 -1
  12. package/badge/index.cjs +1 -1
  13. package/badge/index.js +1 -1
  14. package/banner/index.cjs +2 -2
  15. package/banner/index.js +2 -2
  16. package/breadcrumb-item/index.cjs +1 -1
  17. package/breadcrumb-item/index.js +1 -1
  18. package/button/index.cjs +2 -2
  19. package/button/index.js +2 -2
  20. package/card/index.cjs +2 -2
  21. package/card/index.js +2 -2
  22. package/checkbox/index.cjs +3 -2
  23. package/checkbox/index.js +3 -2
  24. package/combobox/index.cjs +5 -5
  25. package/combobox/index.js +5 -5
  26. package/custom-elements.json +717 -4
  27. package/data-grid/index.cjs +1 -1
  28. package/data-grid/index.js +1 -1
  29. package/date-picker/index.cjs +7 -6
  30. package/date-picker/index.js +7 -6
  31. package/date-range-picker/index.cjs +7 -6
  32. package/date-range-picker/index.js +7 -6
  33. package/dial-pad/index.cjs +33 -0
  34. package/dial-pad/index.js +31 -0
  35. package/dialog/index.cjs +4 -4
  36. package/dialog/index.js +4 -4
  37. package/divider/index.cjs +1 -1
  38. package/divider/index.js +1 -1
  39. package/elevation/index.cjs +1 -1
  40. package/elevation/index.js +1 -1
  41. package/empty-state/index.cjs +2 -2
  42. package/empty-state/index.js +2 -2
  43. package/fab/index.cjs +2 -2
  44. package/fab/index.js +2 -2
  45. package/file-picker/index.cjs +4 -3
  46. package/file-picker/index.js +4 -3
  47. package/header/index.cjs +2 -2
  48. package/header/index.js +2 -2
  49. package/icon/index.cjs +1 -1
  50. package/icon/index.js +1 -1
  51. package/index.cjs +132 -122
  52. package/index.js +46 -43
  53. package/layout/index.cjs +1 -1
  54. package/layout/index.js +1 -1
  55. package/lib/components.d.ts +2 -0
  56. package/lib/dial-pad/definition.d.ts +3 -0
  57. package/lib/dial-pad/dial-pad.d.ts +14 -0
  58. package/lib/dial-pad/dial-pad.template.d.ts +4 -0
  59. package/lib/dial-pad/locale.d.ts +18 -0
  60. package/lib/enums.d.ts +6 -0
  61. package/lib/text-anchor/definition.d.ts +1 -0
  62. package/lib/text-anchor/text-anchor.d.ts +5 -0
  63. package/lib/video-player/definition.d.ts +3 -0
  64. package/lib/video-player/locale.d.ts +1 -0
  65. package/lib/video-player/video-player.d.ts +17 -0
  66. package/lib/video-player/video-player.template.d.ts +4 -0
  67. package/listbox/index.cjs +2 -2
  68. package/listbox/index.js +2 -2
  69. package/locales/en-GB.cjs +30 -0
  70. package/locales/en-GB.js +30 -0
  71. package/locales/en-US.cjs +198 -0
  72. package/locales/en-US.js +198 -0
  73. package/locales/ja-JP.cjs +197 -0
  74. package/locales/ja-JP.js +197 -0
  75. package/locales/zh-CN.cjs +199 -0
  76. package/locales/zh-CN.js +199 -0
  77. package/menu/index.cjs +6 -6
  78. package/menu/index.js +6 -6
  79. package/menu-item/index.cjs +2 -2
  80. package/menu-item/index.js +2 -2
  81. package/nav/index.cjs +1 -1
  82. package/nav/index.js +1 -1
  83. package/nav-disclosure/index.cjs +2 -2
  84. package/nav-disclosure/index.js +2 -2
  85. package/nav-item/index.cjs +2 -2
  86. package/nav-item/index.js +2 -2
  87. package/note/index.cjs +2 -2
  88. package/note/index.js +2 -2
  89. package/number-field/index.cjs +5 -4
  90. package/number-field/index.js +5 -4
  91. package/option/index.cjs +2 -2
  92. package/option/index.js +2 -2
  93. package/package.json +1 -1
  94. package/pagination/index.cjs +3 -3
  95. package/pagination/index.js +3 -3
  96. package/popup/index.cjs +4 -4
  97. package/popup/index.js +4 -4
  98. package/progress/index.cjs +1 -1
  99. package/progress/index.js +1 -1
  100. package/progress-ring/index.cjs +1 -1
  101. package/progress-ring/index.js +1 -1
  102. package/radio/index.cjs +1 -1
  103. package/radio/index.js +1 -1
  104. package/radio-group/index.cjs +1 -1
  105. package/radio-group/index.js +1 -1
  106. package/range-slider/index.cjs +2 -2
  107. package/range-slider/index.js +2 -2
  108. package/select/index.cjs +7 -6
  109. package/select/index.js +7 -6
  110. package/selectable-box/index.cjs +5 -4
  111. package/selectable-box/index.js +5 -4
  112. package/shared/applyMixinsWithObservables.cjs +15 -0
  113. package/shared/applyMixinsWithObservables.js +13 -0
  114. package/shared/definition.cjs +1 -1
  115. package/shared/definition.js +1 -1
  116. package/shared/definition11.cjs +3 -3
  117. package/shared/definition11.js +3 -3
  118. package/shared/definition14.cjs +2 -2
  119. package/shared/definition14.js +2 -2
  120. package/shared/definition15.cjs +8 -9
  121. package/shared/definition15.js +8 -9
  122. package/shared/definition16.cjs +3 -3
  123. package/shared/definition16.js +3 -3
  124. package/shared/definition17.cjs +2 -2
  125. package/shared/definition17.js +3 -3
  126. package/shared/definition18.cjs +3 -3
  127. package/shared/definition18.js +3 -3
  128. package/shared/definition19.cjs +3 -3
  129. package/shared/definition19.js +3 -3
  130. package/shared/definition20.cjs +186 -227
  131. package/shared/definition20.js +181 -222
  132. package/shared/definition21.cjs +264 -67
  133. package/shared/definition21.js +263 -65
  134. package/shared/definition22.cjs +66 -57
  135. package/shared/definition22.js +64 -56
  136. package/shared/definition23.cjs +42 -76
  137. package/shared/definition23.js +41 -75
  138. package/shared/definition24.cjs +70 -2402
  139. package/shared/definition24.js +69 -2401
  140. package/shared/definition25.cjs +2402 -46
  141. package/shared/definition25.js +2401 -45
  142. package/shared/definition26.cjs +63 -30
  143. package/shared/definition26.js +62 -29
  144. package/shared/definition27.cjs +28 -56
  145. package/shared/definition27.js +27 -55
  146. package/shared/definition28.cjs +35 -881
  147. package/shared/definition28.js +34 -879
  148. package/shared/definition29.cjs +893 -60
  149. package/shared/definition29.js +893 -61
  150. package/shared/definition30.cjs +68 -86
  151. package/shared/definition30.js +67 -85
  152. package/shared/definition31.cjs +86 -21
  153. package/shared/definition31.js +86 -21
  154. package/shared/definition32.cjs +24 -12
  155. package/shared/definition32.js +23 -11
  156. package/shared/definition33.cjs +11 -50
  157. package/shared/definition33.js +10 -49
  158. package/shared/definition34.cjs +26 -515
  159. package/shared/definition34.js +26 -515
  160. package/shared/definition35.cjs +448 -194
  161. package/shared/definition35.js +448 -192
  162. package/shared/definition36.cjs +256 -202
  163. package/shared/definition36.js +253 -201
  164. package/shared/definition37.cjs +204 -65
  165. package/shared/definition37.js +203 -63
  166. package/shared/definition38.cjs +63 -57
  167. package/shared/definition38.js +60 -55
  168. package/shared/definition39.cjs +65 -432
  169. package/shared/definition39.js +64 -431
  170. package/shared/definition4.cjs +2 -2
  171. package/shared/definition4.js +2 -2
  172. package/shared/definition40.cjs +441 -34
  173. package/shared/definition40.js +438 -31
  174. package/shared/definition41.cjs +34 -576
  175. package/shared/definition41.js +33 -575
  176. package/shared/definition42.cjs +531 -654
  177. package/shared/definition42.js +531 -654
  178. package/shared/definition43.cjs +690 -114
  179. package/shared/definition43.js +689 -113
  180. package/shared/definition44.cjs +124 -79
  181. package/shared/definition44.js +122 -77
  182. package/shared/definition45.cjs +78 -520
  183. package/shared/definition45.js +77 -518
  184. package/shared/definition46.cjs +520 -119
  185. package/shared/definition46.js +518 -118
  186. package/shared/definition47.cjs +118 -135
  187. package/shared/definition47.js +117 -134
  188. package/shared/definition48.cjs +151 -19
  189. package/shared/definition48.js +150 -18
  190. package/shared/definition49.cjs +21 -84
  191. package/shared/definition49.js +20 -83
  192. package/shared/definition5.cjs +1 -1
  193. package/shared/definition5.js +1 -1
  194. package/shared/definition50.cjs +52 -505
  195. package/shared/definition50.js +51 -504
  196. package/shared/definition51.cjs +526 -28
  197. package/shared/definition51.js +525 -27
  198. package/shared/definition52.cjs +28 -123
  199. package/shared/definition52.js +26 -122
  200. package/shared/definition53.cjs +110 -309
  201. package/shared/definition53.js +110 -308
  202. package/shared/definition54.cjs +255 -271
  203. package/shared/definition54.js +255 -271
  204. package/shared/definition55.cjs +262 -791
  205. package/shared/definition55.js +261 -790
  206. package/shared/definition56.cjs +818 -107
  207. package/shared/definition56.js +817 -106
  208. package/shared/definition57.cjs +85 -55
  209. package/shared/definition57.js +84 -54
  210. package/shared/definition58.cjs +125 -72
  211. package/shared/definition58.js +124 -71
  212. package/shared/definition59.cjs +72 -285
  213. package/shared/definition59.js +73 -286
  214. package/shared/definition6.cjs +1 -1
  215. package/shared/definition6.js +1 -1
  216. package/shared/definition60.cjs +298 -39
  217. package/shared/definition60.js +297 -38
  218. package/shared/definition61.cjs +65739 -1688
  219. package/shared/definition61.js +65738 -1687
  220. package/shared/definition62.cjs +50 -0
  221. package/shared/definition62.js +46 -0
  222. package/shared/definition63.cjs +1828 -0
  223. package/shared/definition63.js +1824 -0
  224. package/shared/definition7.cjs +2 -2
  225. package/shared/definition7.js +2 -2
  226. package/shared/definition8.cjs +2 -2
  227. package/shared/definition8.js +2 -2
  228. package/shared/definition9.cjs +1 -1
  229. package/shared/definition9.js +1 -1
  230. package/shared/enums.cjs +8 -0
  231. package/shared/enums.js +8 -1
  232. package/shared/index2.cjs +66 -37
  233. package/shared/index2.js +66 -37
  234. package/shared/key-codes2.js +1 -1
  235. package/shared/listbox.cjs +1 -1
  236. package/shared/listbox.js +1 -1
  237. package/shared/localization/Locale.d.ts +4 -0
  238. package/shared/patterns/form-elements/form-elements.d.ts +2 -3
  239. package/shared/presentationDate.cjs +16 -5
  240. package/shared/presentationDate.js +16 -5
  241. package/shared/text-anchor.cjs +6 -0
  242. package/shared/text-anchor.js +6 -0
  243. package/shared/text-anchor.template.cjs +6 -1
  244. package/shared/text-anchor.template.js +6 -1
  245. package/shared/text-field.cjs +1 -1
  246. package/shared/text-field.js +1 -1
  247. package/shared/utils/applyMixinsWithObservables.d.ts +1 -0
  248. package/side-drawer/index.cjs +1 -1
  249. package/side-drawer/index.js +1 -1
  250. package/slider/index.cjs +1 -1
  251. package/slider/index.js +1 -1
  252. package/split-button/index.cjs +2 -2
  253. package/split-button/index.js +2 -2
  254. package/style.css +1 -0
  255. package/styles/core/all.css +1 -1
  256. package/styles/core/theme.css +1 -1
  257. package/styles/core/typography.css +1 -1
  258. package/styles/tokens/theme-dark.css +4 -4
  259. package/styles/tokens/theme-light.css +4 -4
  260. package/styles/tokens/vivid-2-compat.css +1 -1
  261. package/switch/index.cjs +2 -2
  262. package/switch/index.js +2 -2
  263. package/tab/index.cjs +2 -2
  264. package/tab/index.js +2 -2
  265. package/tab-panel/index.cjs +1 -1
  266. package/tab-panel/index.js +1 -1
  267. package/tabs/index.cjs +4 -4
  268. package/tabs/index.js +4 -4
  269. package/tag/index.cjs +2 -2
  270. package/tag/index.js +2 -2
  271. package/tag-group/index.cjs +1 -1
  272. package/tag-group/index.js +1 -1
  273. package/text-area/index.cjs +4 -3
  274. package/text-area/index.js +4 -3
  275. package/text-field/index.cjs +4 -3
  276. package/text-field/index.js +4 -3
  277. package/time-picker/index.cjs +8 -7
  278. package/time-picker/index.js +8 -7
  279. package/toggletip/index.cjs +5 -5
  280. package/toggletip/index.js +5 -5
  281. package/tooltip/index.cjs +5 -5
  282. package/tooltip/index.js +5 -5
  283. package/tree-item/index.cjs +2 -2
  284. package/tree-item/index.js +2 -2
  285. package/tree-view/index.cjs +1 -1
  286. package/tree-view/index.js +1 -1
  287. package/video-player/index.cjs +17 -0
  288. package/video-player/index.js +15 -0
  289. package/vivid.api.json +311 -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,245 @@ 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;
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
+ /**
150
+ * @internal
151
+ */
152
+ this._labelEl = null;
153
+ __privateAdd(this, _reflectToInput, void 0);
332
154
  }
333
155
  /**
334
156
  * @internal
335
157
  */
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 = "";
158
+ labelChanged() {
159
+ if (this._labelEl) {
160
+ __privateMethod(this, _handleLabelChange, handleLabelChange_fn).call(this, this._labelEl);
350
161
  }
351
162
  }
352
163
  connectedCallback() {
353
164
  super.connectedCallback();
354
- document.addEventListener("click", __privateGet(this, _dismissOnClickOutside));
355
- this.addEventListener("focusin", __privateGet(this, _onFocusIn));
356
- this.addEventListener("focusout", __privateGet(this, _onFocusOut));
357
- }
358
- disconnectedCallback() {
359
- super.disconnectedCallback();
360
- document.removeEventListener("click", __privateGet(this, _dismissOnClickOutside));
361
- this.removeEventListener("focusin", __privateGet(this, _onFocusIn));
362
- this.removeEventListener("focusout", __privateGet(this, _onFocusOut));
363
- }
364
- /**
365
- * @internal
366
- */
367
- _closePopup(restoreFocusToTextField = true) {
368
- this._popupOpen = false;
369
- if (restoreFocusToTextField) {
370
- this._textFieldEl.focus();
371
- }
372
- }
373
- /**
374
- * On keydown anywhere in the time picker.
375
- * @internal
376
- */
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;
386
- }
387
- /**
388
- * @internal
389
- */
390
- _presentationValueChanged() {
391
- this.dirtyValue = true;
392
- this.validate();
393
- }
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
- )
165
+ if (!this.control) {
166
+ const uniqueId = this.id || generateRandomId();
167
+ const controlId = `vvd-text-field-control-${uniqueId}`;
168
+ const input = document.createElement("input");
169
+ input.slot = "_control";
170
+ input.id = controlId;
171
+ input.className = safariWorkaroundClassName;
172
+ this.control = input;
173
+ __privateSet(this, _reflectToInput, new Reflector(this, input));
174
+ __privateGet(this, _reflectToInput).booleanAttribute("autofocus", "autofocus");
175
+ __privateGet(this, _reflectToInput).booleanAttribute("disabled", "disabled");
176
+ __privateGet(this, _reflectToInput).booleanAttribute("readOnly", "readonly");
177
+ __privateGet(this, _reflectToInput).booleanAttribute("required", "required");
178
+ __privateGet(this, _reflectToInput).booleanAttribute("spellcheck", "spellcheck");
179
+ __privateGet(this, _reflectToInput).attribute("list", "list");
180
+ __privateGet(this, _reflectToInput).attribute("maxlength", "maxlength");
181
+ __privateGet(this, _reflectToInput).attribute("minlength", "minlength");
182
+ __privateGet(this, _reflectToInput).attribute("pattern", "pattern");
183
+ __privateGet(this, _reflectToInput).attribute("placeholder", "placeholder");
184
+ __privateGet(this, _reflectToInput).attribute("size", "size");
185
+ __privateGet(this, _reflectToInput).attribute("autoComplete", "autocomplete");
186
+ __privateGet(this, _reflectToInput).attribute("type", "type");
187
+ __privateGet(this, _reflectToInput).attribute("ariaAtomic", "aria-atomic");
188
+ __privateGet(this, _reflectToInput).attribute("ariaBusy", "aria-busy");
189
+ __privateGet(this, _reflectToInput).attribute("ariaCurrent", "aria-current");
190
+ __privateGet(this, _reflectToInput).attribute("ariaDetails", "aria-details");
191
+ __privateGet(this, _reflectToInput).attribute("ariaDisabled", "aria-disabled");
192
+ __privateGet(this, _reflectToInput).attribute("ariaHaspopup", "aria-haspopup");
193
+ __privateGet(this, _reflectToInput).attribute("ariaHidden", "aria-hidden");
194
+ __privateGet(this, _reflectToInput).attribute("ariaInvalid", "aria-invalid");
195
+ __privateGet(this, _reflectToInput).attribute("ariaKeyshortcuts", "aria-keyshortcuts");
196
+ __privateGet(this, _reflectToInput).attribute("ariaLabel", "aria-label");
197
+ __privateGet(this, _reflectToInput).attribute("ariaLive", "aria-live");
198
+ __privateGet(this, _reflectToInput).attribute("ariaRelevant", "aria-relevant");
199
+ __privateGet(this, _reflectToInput).attribute(
200
+ "ariaRoledescription",
201
+ "aria-roledescription"
440
202
  );
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`;
203
+ __privateGet(this, _reflectToInput).property("value", "value", true);
204
+ input.addEventListener("input", () => {
205
+ this.handleTextInput();
206
+ });
207
+ input.addEventListener("change", () => {
208
+ this.handleChange();
209
+ });
210
+ input.addEventListener("blur", () => {
211
+ this.$emit("blur", void 0, { bubbles: false });
212
+ });
213
+ input.addEventListener("focus", () => {
214
+ this.$emit("focus", void 0, { bubbles: false });
215
+ });
216
+ this.appendChild(input);
217
+ const label = document.createElement("label");
218
+ label.slot = "_label";
219
+ label.htmlFor = controlId;
220
+ this._labelEl = label;
221
+ __privateMethod(this, _handleLabelChange, handleLabelChange_fn).call(this, label);
222
+ installSafariWorkaroundStyle(this);
494
223
  }
495
224
  }
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}`;
540
- }
541
- }
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";
572
- }
573
- }
574
- }
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;
594
- }
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();
607
- } 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;
656
- }
225
+ disconnectedCallback() {
226
+ super.disconnectedCallback();
227
+ __privateGet(this, _reflectToInput).destroy();
657
228
  }
658
- };
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;
229
+ focus() {
230
+ this.control?.focus();
673
231
  }
674
232
  };
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;
233
+ _handleLabelChange = new WeakSet();
234
+ handleLabelChange_fn = function(labelEl) {
235
+ if (!this.label) {
236
+ labelEl.remove();
237
+ } else {
238
+ labelEl.textContent = this.label;
239
+ if (!labelEl.isConnected) {
240
+ this.appendChild(labelEl);
241
+ }
696
242
  }
697
243
  };
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);
244
+ _reflectToInput = new WeakMap();
707
245
  __decorateClass([
708
246
  attr
709
- ], TimePicker.prototype, "clock", 2);
247
+ ], TextField.prototype, "appearance", 2);
710
248
  __decorateClass([
711
- attr({ converter: ValidTimeFilter })
712
- ], TimePicker.prototype, "min", 2);
249
+ attr
250
+ ], TextField.prototype, "shape", 2);
713
251
  __decorateClass([
714
- attr({ converter: ValidTimeFilter })
715
- ], TimePicker.prototype, "max", 2);
252
+ attr
253
+ ], TextField.prototype, "autoComplete", 2);
716
254
  __decorateClass([
717
255
  observable
718
- ], TimePicker.prototype, "_popupOpen", 2);
256
+ ], TextField.prototype, "actionItemsSlottedContent", 2);
719
257
  __decorateClass([
720
258
  observable
721
- ], TimePicker.prototype, "_presentationValue", 2);
722
- TimePicker = __decorateClass([
259
+ ], TextField.prototype, "leadingActionItemsSlottedContent", 2);
260
+ TextField = __decorateClass([
723
261
  errorText,
724
262
  formElements
725
- ], TimePicker);
726
- applyMixins(TimePicker, Localized, FormElementHelperText, TrappedFocus);
263
+ ], TextField);
264
+ applyMixinsWithObservables(
265
+ TextField,
266
+ AffixIcon,
267
+ FormElementCharCount,
268
+ FormElementHelperText,
269
+ FormElementSuccessText
270
+ );
727
271
 
728
- const renderPicker = (id, getLabel, getSelected, setSelected, getOptions) => {
272
+ const getStateClasses = ({
273
+ errorValidationMessage,
274
+ disabled,
275
+ value,
276
+ readOnly,
277
+ placeholder,
278
+ appearance,
279
+ shape,
280
+ label,
281
+ successText,
282
+ actionItemsSlottedContent,
283
+ leadingActionItemsSlottedContent,
284
+ icon
285
+ }) => classNames(
286
+ ["error", Boolean(errorValidationMessage)],
287
+ ["disabled", disabled],
288
+ ["has-value", Boolean(value)],
289
+ ["readonly", readOnly],
290
+ ["placeholder", Boolean(placeholder)],
291
+ [`appearance-${appearance}`, Boolean(appearance)],
292
+ [`shape-${shape}`, Boolean(shape)],
293
+ ["no-label", !label],
294
+ ["has-icon", !!icon],
295
+ ["success", Boolean(successText)],
296
+ ["action-items", !!actionItemsSlottedContent?.length],
297
+ ["leading-action-items", !!leadingActionItemsSlottedContent?.length],
298
+ ["no-leading", !(leadingActionItemsSlottedContent?.length || icon)]
299
+ );
300
+ function renderCharCount() {
729
301
  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
- )}"
302
+ <span class="char-count"
303
+ >${(x) => x.value ? x.value.length : 0} / ${(x) => x.maxlength}</span
744
304
  >
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
305
  `;
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
- )}
838
- </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}>
853
- </div>
306
+ }
307
+ const TextfieldTemplate = (context) => {
308
+ const affixIconTemplate = affixIconTemplateFactory(context);
309
+ return html` <div class="base ${getStateClasses}">
310
+ ${when((x) => x.charCount && x.maxlength, renderCharCount())}
311
+ <slot class="label" name="_label"></slot>
312
+ <div class="fieldset">
313
+ <div class="leading-items-wrapper">
314
+ <slot
315
+ name="leading-action-items"
316
+ ${slotted("leadingActionItemsSlottedContent")}
317
+ ></slot>
318
+ ${(x) => affixIconTemplate(x.icon)}
319
+ </div>
320
+
321
+ <div class="wrapper">
322
+ <slot class="control" name="_control"></slot>
323
+ </div>
324
+ <div class="action-items-wrapper">
325
+ <slot
326
+ name="action-items"
327
+ ${slotted("actionItemsSlottedContent")}
328
+ ></slot>
854
329
  </div>
855
- </${popupTag}>
330
+ </div>
331
+ ${getFeedbackTemplate(context)}
856
332
  </div>`;
857
333
  };
858
334
 
859
- const timePickerDefinition = TimePicker.compose({
860
- baseName: "time-picker",
861
- template: TimePickerTemplate,
335
+ const textFieldDefinition = TextField.compose({
336
+ baseName: "text-field",
337
+ template: TextfieldTemplate,
862
338
  styles,
863
339
  shadowOptions: {
864
340
  delegatesFocus: true
865
341
  }
866
342
  });
867
- const timePickerRegistries = [
868
- timePickerDefinition(),
869
- ...textFieldRegistries,
870
- ...popupRegistries,
871
- ...buttonRegistries
872
- ];
873
- const registerTimePicker = registerFactory(timePickerRegistries);
343
+ const textFieldRegistries = [textFieldDefinition(), ...iconRegistries];
344
+ const registerTextField = registerFactory(textFieldRegistries);
874
345
 
875
- export { timePickerRegistries as a, registerTimePicker as r, timePickerDefinition as t };
346
+ export { TextField as T, textFieldRegistries as a, registerTextField as r, textFieldDefinition as t };