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