@vonage/vivid 3.52.0 → 3.54.0

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