@vonage/vivid 3.51.0 → 3.52.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 (261) hide show
  1. package/alert/index.cjs +1 -1
  2. package/alert/index.js +1 -1
  3. package/appearance-ui/index.cjs +19 -11
  4. package/appearance-ui/index.js +19 -11
  5. package/audio-player/index.cjs +2 -1
  6. package/audio-player/index.js +2 -1
  7. package/card/index.cjs +1 -1
  8. package/card/index.js +1 -1
  9. package/combobox/index.cjs +2 -5
  10. package/combobox/index.js +2 -5
  11. package/custom-elements.json +1357 -529
  12. package/date-picker/index.cjs +3 -6
  13. package/date-picker/index.js +3 -6
  14. package/date-range-picker/index.cjs +2 -5
  15. package/date-range-picker/index.js +2 -5
  16. package/dialog/index.cjs +1 -1
  17. package/dialog/index.js +1 -1
  18. package/elevation/index.cjs +1 -1
  19. package/elevation/index.js +1 -1
  20. package/file-picker/index.cjs +0 -2
  21. package/file-picker/index.js +0 -2
  22. package/header/index.cjs +1 -1
  23. package/header/index.js +1 -1
  24. package/index.cjs +60 -58
  25. package/index.js +22 -23
  26. package/lib/avatar/definition.d.ts +1 -1
  27. package/lib/button/button.d.ts +1 -0
  28. package/lib/button/definition.d.ts +1 -1
  29. package/lib/calendar-event/definition.d.ts +1 -1
  30. package/lib/components.d.ts +1 -0
  31. package/lib/layout/definition.d.ts +1 -1
  32. package/lib/menu-item/menu-item.d.ts +3 -0
  33. package/lib/range-slider/definition.d.ts +3 -0
  34. package/lib/range-slider/locale.d.ts +4 -0
  35. package/lib/range-slider/range-slider.d.ts +32 -0
  36. package/lib/range-slider/range-slider.form-associated.d.ts +10 -0
  37. package/lib/range-slider/range-slider.template.d.ts +4 -0
  38. package/lib/range-slider/utils/lerp.d.ts +2 -0
  39. package/lib/range-slider/utils/roundToStepValue.d.ts +1 -0
  40. package/lib/slider/slider.template.d.ts +1 -0
  41. package/lib/split-button/definition.d.ts +1 -1
  42. package/listbox/index.cjs +23 -22
  43. package/listbox/index.js +23 -22
  44. package/locales/en-GB.cjs +4 -0
  45. package/locales/en-GB.js +4 -0
  46. package/locales/en-US.cjs +4 -0
  47. package/locales/en-US.js +4 -0
  48. package/locales/ja-JP.cjs +5 -1
  49. package/locales/ja-JP.js +5 -1
  50. package/locales/zh-CN.cjs +4 -0
  51. package/locales/zh-CN.js +4 -0
  52. package/menu/index.cjs +3 -3
  53. package/menu/index.js +3 -3
  54. package/menu-item/index.cjs +2 -2
  55. package/menu-item/index.js +2 -2
  56. package/number-field/index.cjs +0 -2
  57. package/number-field/index.js +0 -2
  58. package/package.json +34 -34
  59. package/popup/index.cjs +2 -2
  60. package/popup/index.js +2 -2
  61. package/range-slider/index.cjs +22 -0
  62. package/range-slider/index.js +20 -0
  63. package/select/index.cjs +3 -3
  64. package/select/index.js +3 -3
  65. package/selectable-box/index.cjs +1 -1
  66. package/selectable-box/index.js +1 -1
  67. package/shared/Reflector.cjs +5 -1
  68. package/shared/Reflector.js +5 -1
  69. package/shared/affix.cjs +11 -4
  70. package/shared/affix.js +12 -4
  71. package/shared/anchored.cjs +8 -2
  72. package/shared/anchored.js +8 -2
  73. package/shared/definition.cjs +8 -3
  74. package/shared/definition.js +8 -3
  75. package/shared/definition10.cjs +5 -5
  76. package/shared/definition10.js +5 -5
  77. package/shared/definition11.cjs +75 -47
  78. package/shared/definition11.js +76 -48
  79. package/shared/definition12.cjs +12 -14
  80. package/shared/definition12.js +12 -14
  81. package/shared/definition13.cjs +118 -75
  82. package/shared/definition13.js +118 -75
  83. package/shared/definition14.cjs +33 -32
  84. package/shared/definition14.js +33 -32
  85. package/shared/definition15.cjs +20 -7
  86. package/shared/definition15.js +20 -7
  87. package/shared/definition16.cjs +37 -42
  88. package/shared/definition16.js +36 -41
  89. package/shared/definition17.cjs +125 -65
  90. package/shared/definition17.js +126 -66
  91. package/shared/definition18.cjs +30 -14
  92. package/shared/definition18.js +30 -14
  93. package/shared/definition19.cjs +116 -80
  94. package/shared/definition19.js +116 -80
  95. package/shared/definition2.cjs +10 -5
  96. package/shared/definition2.js +10 -5
  97. package/shared/definition20.cjs +16 -15
  98. package/shared/definition20.js +16 -15
  99. package/shared/definition21.cjs +6 -10
  100. package/shared/definition21.js +6 -10
  101. package/shared/definition22.cjs +14 -18
  102. package/shared/definition22.js +14 -18
  103. package/shared/definition23.cjs +34 -35
  104. package/shared/definition23.js +34 -35
  105. package/shared/definition24.cjs +116 -69
  106. package/shared/definition24.js +116 -69
  107. package/shared/definition25.cjs +2 -4
  108. package/shared/definition25.js +2 -4
  109. package/shared/definition26.cjs +9 -8
  110. package/shared/definition26.js +9 -8
  111. package/shared/definition27.cjs +7 -5
  112. package/shared/definition27.js +7 -5
  113. package/shared/definition28.cjs +209 -143
  114. package/shared/definition28.js +209 -143
  115. package/shared/definition29.cjs +10 -4
  116. package/shared/definition29.js +10 -4
  117. package/shared/definition3.cjs +7 -10
  118. package/shared/definition3.js +7 -10
  119. package/shared/definition30.cjs +7 -5
  120. package/shared/definition30.js +7 -5
  121. package/shared/definition31.cjs +2 -4
  122. package/shared/definition31.js +2 -4
  123. package/shared/definition32.cjs +1 -3
  124. package/shared/definition32.js +1 -3
  125. package/shared/definition33.cjs +7 -10
  126. package/shared/definition33.js +7 -10
  127. package/shared/definition34.cjs +76 -59
  128. package/shared/definition34.js +76 -59
  129. package/shared/definition35.cjs +19 -20
  130. package/shared/definition35.js +19 -20
  131. package/shared/definition36.cjs +30 -14
  132. package/shared/definition36.js +30 -14
  133. package/shared/definition37.cjs +33 -46
  134. package/shared/definition37.js +33 -46
  135. package/shared/definition38.cjs +31 -33
  136. package/shared/definition38.js +31 -33
  137. package/shared/definition39.cjs +13 -4
  138. package/shared/definition39.js +13 -4
  139. package/shared/definition4.cjs +23 -11
  140. package/shared/definition4.js +23 -11
  141. package/shared/definition40.cjs +19 -14
  142. package/shared/definition40.js +19 -14
  143. package/shared/definition41.cjs +534 -635
  144. package/shared/definition41.js +534 -635
  145. package/shared/definition42.cjs +674 -106
  146. package/shared/definition42.js +673 -105
  147. package/shared/definition43.cjs +122 -79
  148. package/shared/definition43.js +120 -77
  149. package/shared/definition44.cjs +72 -567
  150. package/shared/definition44.js +71 -565
  151. package/shared/definition45.cjs +520 -118
  152. package/shared/definition45.js +518 -117
  153. package/shared/definition46.cjs +117 -130
  154. package/shared/definition46.js +116 -129
  155. package/shared/definition47.cjs +152 -18
  156. package/shared/definition47.js +151 -17
  157. package/shared/definition48.cjs +20 -77
  158. package/shared/definition48.js +19 -76
  159. package/shared/definition49.cjs +52 -495
  160. package/shared/definition49.js +51 -494
  161. package/shared/definition5.cjs +20 -17
  162. package/shared/definition5.js +20 -17
  163. package/shared/definition50.cjs +525 -24
  164. package/shared/definition50.js +524 -23
  165. package/shared/definition51.cjs +28 -119
  166. package/shared/definition51.js +26 -118
  167. package/shared/definition52.cjs +113 -266
  168. package/shared/definition52.js +113 -265
  169. package/shared/definition53.cjs +285 -245
  170. package/shared/definition53.js +285 -245
  171. package/shared/definition54.cjs +285 -751
  172. package/shared/definition54.js +284 -750
  173. package/shared/definition55.cjs +828 -99
  174. package/shared/definition55.js +827 -98
  175. package/shared/definition56.cjs +126 -77
  176. package/shared/definition56.js +125 -76
  177. package/shared/definition57.cjs +125 -71
  178. package/shared/definition57.js +124 -70
  179. package/shared/definition58.cjs +73 -287
  180. package/shared/definition58.js +74 -288
  181. package/shared/definition59.cjs +298 -40
  182. package/shared/definition59.js +297 -39
  183. package/shared/definition6.cjs +3 -4
  184. package/shared/definition6.js +3 -4
  185. package/shared/definition60.cjs +24 -1784
  186. package/shared/definition60.js +23 -1783
  187. package/shared/definition61.cjs +1819 -11
  188. package/shared/definition61.js +1818 -11
  189. package/shared/definition7.cjs +6 -4
  190. package/shared/definition7.js +6 -4
  191. package/shared/definition8.cjs +25 -18
  192. package/shared/definition8.js +25 -18
  193. package/shared/definition9.cjs +6 -9
  194. package/shared/definition9.js +6 -9
  195. package/shared/icon.cjs +7 -2
  196. package/shared/icon.js +7 -2
  197. package/shared/index2.cjs +1 -1
  198. package/shared/index2.js +1 -1
  199. package/shared/key-codes2.cjs +8 -0
  200. package/shared/key-codes2.js +5 -1
  201. package/shared/localization/Locale.d.ts +2 -0
  202. package/shared/patterns/index.d.ts +0 -1
  203. package/shared/presentationDate.cjs +126 -78
  204. package/shared/presentationDate.js +126 -78
  205. package/shared/slider.template.cjs +71 -0
  206. package/shared/slider.template.js +67 -0
  207. package/shared/text-anchor.template.cjs +30 -35
  208. package/shared/text-anchor.template.js +30 -35
  209. package/shared/text-field.cjs +1 -1
  210. package/shared/text-field.js +1 -1
  211. package/side-drawer/index.cjs +1 -1
  212. package/side-drawer/index.js +1 -1
  213. package/slider/index.cjs +2 -1
  214. package/slider/index.js +2 -1
  215. package/split-button/index.cjs +1 -1
  216. package/split-button/index.js +1 -1
  217. package/styles/core/all.css +1 -1
  218. package/styles/core/theme.css +1 -1
  219. package/styles/core/typography.css +1 -1
  220. package/styles/fonts/spezia-variable.css +39 -13
  221. package/styles/tokens/theme-dark.css +4 -4
  222. package/styles/tokens/theme-light.css +4 -4
  223. package/styles/tokens/vivid-2-compat.css +4 -2
  224. package/switch/index.cjs +1 -1
  225. package/switch/index.js +1 -1
  226. package/tab/index.cjs +1 -1
  227. package/tab/index.js +1 -1
  228. package/tab-panel/index.cjs +1 -1
  229. package/tab-panel/index.js +1 -1
  230. package/tabs/index.cjs +3 -3
  231. package/tabs/index.js +3 -3
  232. package/tag/index.cjs +1 -1
  233. package/tag/index.js +1 -1
  234. package/tag-group/index.cjs +1 -1
  235. package/tag-group/index.js +1 -1
  236. package/text-area/index.cjs +1 -1
  237. package/text-area/index.js +1 -1
  238. package/text-field/index.cjs +1 -4
  239. package/text-field/index.js +1 -4
  240. package/time-picker/index.cjs +4 -7
  241. package/time-picker/index.js +4 -7
  242. package/toggletip/index.cjs +3 -3
  243. package/toggletip/index.js +3 -3
  244. package/tooltip/index.cjs +3 -3
  245. package/tooltip/index.js +3 -3
  246. package/tree-item/index.cjs +1 -1
  247. package/tree-item/index.js +1 -1
  248. package/tree-view/index.cjs +1 -1
  249. package/tree-view/index.js +1 -1
  250. package/vivid.api.json +117 -1
  251. package/focus/index.cjs +0 -7
  252. package/focus/index.js +0 -5
  253. package/lib/focus/definition.d.ts +0 -3
  254. package/lib/focus/focus.d.ts +0 -3
  255. package/lib/focus/focus.template.d.ts +0 -4
  256. package/lib/popup/popup.d.ts +0 -21
  257. package/shared/focus.cjs +0 -8
  258. package/shared/focus.js +0 -6
  259. package/shared/focus2.cjs +0 -11
  260. package/shared/focus2.js +0 -9
  261. package/shared/patterns/focus.d.ts +0 -3
@@ -1,217 +1,84 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- const definition$1 = require('./definition53.cjs');
5
- const definition = require('./definition60.cjs');
6
- const definition$2 = require('./definition11.cjs');
7
- require('./affix.cjs');
4
+ const definition = require('./definition26.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');
7
+ const Reflector = require('./Reflector.cjs');
8
+ const icon = require('./icon.cjs');
9
+ const textField = require('./text-field2.cjs');
12
10
  const applyMixins = require('./apply-mixins.cjs');
13
- const ref = require('./ref.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;flex-direction:column;padding:0;margin:0;border-radius:4px;gap:4px;inline-size:50px;list-style:none;overflow-x:hidden;overflow-y:hidden;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;background-color:var(--_appearance-color-fill);block-size:28px;border-radius:4px;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-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-primary);--_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-primary);--_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-primary);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.time-pickers .item:where(.selected,[aria-current]):where(:not(:disabled,.disabled)){--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.time-pickers .item:where(.selected,[aria-current]):where(:hover,.hover):where(:not(:disabled,.disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: var(--_connotation-color-pale);--_appearance-color-outline: transparent}.time-pickers .item:where(.selected,[aria-current]):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(use12HourClock ? hoursAs12hClock(time.hours) : time.hours);
77
- let result = `${hoursStr}:${time.minuteStr}`;
78
- if (includeSeconds) {
79
- result += `:${time.secondStr}`;
80
- }
81
- if (use12HourClock) {
82
- result += ` ${time.meridiem}`;
83
- }
84
- return result;
85
- };
86
- const isDigit = (char) => char >= "0" && char <= "9";
87
- const parsePresentationTime = (input, use12HourClock) => {
88
- const cleanedInput = input.toLowerCase();
89
- const numerals = [];
90
- let meridiem;
91
- for (let i = 0; i < cleanedInput.length; i++) {
92
- const char = cleanedInput[i];
93
- if (char === "a" && cleanedInput[i + 1] === "m") {
94
- i++;
95
- meridiem = "AM";
96
- }
97
- if (char === "p" && cleanedInput[i + 1] === "m") {
98
- i++;
99
- meridiem = "PM";
100
- }
101
- if (isDigit(char)) {
102
- let numeral = char;
103
- while (isDigit(cleanedInput[i + 1])) {
104
- i++;
105
- numeral += cleanedInput[i];
106
- }
107
- numerals.push(Number.parseInt(numeral, 10));
108
- }
109
- }
110
- if (numerals.length === 0 || numerals.length > 3) {
111
- throw new Error("Invalid time format");
112
- }
113
- if (meridiem && (numerals[0] < 1 || numerals[0] > 12)) {
114
- throw new Error("Invalid time format");
115
- }
116
- if (meridiem || use12HourClock) {
117
- if (numerals[0] === 12) {
118
- numerals[0] = 0;
119
- }
120
- }
121
- if (meridiem === "PM") {
122
- numerals[0] = numerals[0] + 12;
123
- }
124
- const [hours, minutes = 0, seconds = 0] = numerals;
125
- if (hours > 23 || minutes > 59 || seconds > 59) {
126
- throw new Error("Invalid value");
127
- }
128
- return [hours, minutes, seconds].map(formatTimePart).join(":");
129
- };
40
+ const byteToHex = [];
130
41
 
131
- const fallsIntoMeridiem = (meridiem, hour) => meridiem === "AM" && hour < 12 || meridiem === "PM" && hour >= 12;
132
- const getHoursOptions = (min, max, forMeridiem) => {
133
- const result = [];
134
- const minHour = min ? parseTimeStr(min).hours : 0;
135
- const maxHour = max ? parseTimeStr(max).hours : 23;
136
- for (let i = minHour; i <= maxHour; i++) {
137
- if (forMeridiem && !fallsIntoMeridiem(forMeridiem, i)) {
138
- continue;
139
- }
140
- result.push({
141
- value: formatTimePart(i),
142
- label: formatTimePart(forMeridiem ? hoursAs12hClock(i) : i)
143
- });
144
- }
145
- return result;
146
- };
147
- const getMinutesOptions = (step, value, min, max) => {
148
- const result = [];
149
- let minMinute = 0;
150
- let maxMinute = 59;
151
- if (min) {
152
- const { hourStr: minHourStr, minutes: minMinutes } = parseTimeStr(min);
153
- if (value && parseTimeStr(value).hourStr === minHourStr) {
154
- minMinute = minMinutes;
155
- }
156
- }
157
- if (max) {
158
- const { hourStr: maxHourStr, minutes: maxMinutes } = parseTimeStr(max);
159
- if (value && parseTimeStr(value).hourStr === maxHourStr) {
160
- maxMinute = maxMinutes;
161
- }
162
- }
163
- for (let i = minMinute; i <= maxMinute; i += Math.max(1, step ?? 1)) {
164
- const minutes = formatTimePart(i);
165
- result.push({
166
- value: minutes,
167
- label: minutes
168
- });
169
- }
170
- return result;
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
171
55
  };
172
- const getSecondsOptions = (step, value, min, max) => {
173
- const result = [];
174
- let minSecond = 0;
175
- let maxSecond = 59;
176
- if (min) {
177
- const minTime = parseTimeStr(min);
178
- if (value && (parseTimeStr(value).hourStr === minTime.hourStr && parseTimeStr(value).minuteStr) === minTime.minuteStr) {
179
- minSecond = minTime.seconds;
180
- }
56
+
57
+ function v4(options, buf, offset) {
58
+ if (native.randomUUID && !buf && !options) {
59
+ return native.randomUUID();
181
60
  }
182
- if (max) {
183
- const maxTime = parseTimeStr(max);
184
- if (value && (parseTimeStr(value).hourStr === maxTime.hourStr && parseTimeStr(value).minuteStr) === maxTime.minuteStr) {
185
- maxSecond = maxTime.seconds;
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];
186
73
  }
74
+
75
+ return buf;
187
76
  }
188
- for (let i = minSecond; i <= maxSecond; i += Math.max(1, step)) {
189
- const seconds = formatTimePart(i);
190
- result.push({
191
- value: seconds,
192
- label: seconds
193
- });
194
- }
195
- return result;
196
- };
197
- const getMeridiesOptions = (min, max) => {
198
- const result = [];
199
- const hideAM = min ? parseTimeStr(min).meridiem === "PM" : false;
200
- if (!hideAM) {
201
- result.push({
202
- value: "AM",
203
- label: "AM"
204
- });
205
- }
206
- const hidePM = max ? parseTimeStr(max).meridiem === "AM" : false;
207
- if (!hidePM) {
208
- result.push({
209
- value: "PM",
210
- label: "PM"
211
- });
212
- }
213
- return result;
214
- };
77
+
78
+ return unsafeStringify(rnds);
79
+ }
80
+
81
+ const generateRandomId = () => v4();
215
82
 
216
83
  var __defProp = Object.defineProperty;
217
84
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -224,601 +91,268 @@ var __decorateClass = (decorators, target, key, kind) => {
224
91
  __defProp(target, key, result);
225
92
  return result;
226
93
  };
227
- const ValidTimeFilter = {
228
- fromView: (value) => {
229
- if (value && isValidTimeStr(value)) {
230
- return value;
231
- }
232
- return "";
233
- },
234
- toView(value) {
235
- return value;
94
+ var __accessCheck = (obj, member, msg) => {
95
+ if (!member.has(obj))
96
+ throw TypeError("Cannot " + msg);
97
+ };
98
+ var __privateGet = (obj, member, getter) => {
99
+ __accessCheck(obj, member, "read from private field");
100
+ return getter ? getter.call(obj) : member.get(obj);
101
+ };
102
+ var __privateAdd = (obj, member, value) => {
103
+ if (member.has(obj))
104
+ throw TypeError("Cannot add the same private member more than once");
105
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
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
+ };
112
+ var __privateMethod = (obj, member, method) => {
113
+ __accessCheck(obj, member, "access private method");
114
+ return method;
115
+ };
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
+ ];
236
145
  }
237
146
  };
238
- let TimePicker = class extends FormAssociatedTimePicker {
147
+ exports.TextField = class TextField extends textField.TextField {
239
148
  constructor() {
240
- super();
241
- this.readOnly = false;
242
- this.minutesStep = null;
243
- this.secondsStep = null;
244
- this.#getFocusableEls = () => this.shadowRoot.querySelectorAll(`
245
- .dialog [tabindex="0"],
246
- .dialog .vwc-button:not(:disabled)
247
- `);
248
- this.#onFocusIn = () => {
249
- this.$emit("focus", void 0, { bubbles: false });
250
- };
251
- this.#onFocusOut = () => {
252
- this.$emit("blur", void 0, { bubbles: false });
253
- };
254
- this._popupOpen = false;
255
- this.#dismissOnClickOutside = (event) => {
256
- if (!this._popupOpen) {
257
- return;
258
- }
259
- const path = event.composedPath();
260
- const elementsToIgnoreClicksOn = [this._dialogEl, this._clockButtonEl];
261
- if (!elementsToIgnoreClicksOn.some((element) => path.includes(element))) {
262
- this._closePopup(false);
263
- }
264
- };
265
- this._presentationValue = "";
266
- this.value = "";
267
- this.min = "";
268
- this.max = "";
269
- this.proxy.type = "time";
270
- this.proxy.step = "1";
271
- }
272
- /**
273
- * @internal
274
- */
275
- readOnlyChanged() {
276
- if (this.proxy instanceof HTMLInputElement) {
277
- this.proxy.readOnly = this.readOnly;
278
- this.validate();
279
- }
280
- }
281
- /**
282
- * @internal
283
- */
284
- minChanged(_, newMin) {
285
- if (this.proxy instanceof HTMLInputElement) {
286
- this.proxy.min = newMin;
287
- this.validate();
288
- }
289
- }
290
- /**
291
- * @internal
292
- */
293
- maxChanged(_, newMax) {
294
- if (this.proxy instanceof HTMLInputElement) {
295
- this.proxy.max = newMax;
296
- this.validate();
297
- }
298
- }
299
- // --- Core ---
300
- /**
301
- * @internal
302
- */
303
- get _displaySeconds() {
304
- return this.secondsStep !== null;
305
- }
306
- /**
307
- * @internal
308
- */
309
- get _use12hClock() {
310
- 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);
311
156
  }
312
- #getFocusableEls;
313
157
  /**
314
158
  * @internal
315
159
  */
316
- valueChanged(previous, next) {
317
- super.valueChanged(previous, next);
318
- if (this.value) {
319
- if (!isValidTimeStr(this.value)) {
320
- this.value = "";
321
- return;
322
- }
323
- this._presentationValue = formatPresentationTime(
324
- this.value,
325
- this._displaySeconds,
326
- this._use12hClock
327
- );
328
- } else {
329
- this._presentationValue = "";
160
+ labelChanged() {
161
+ if (this._labelEl) {
162
+ __privateMethod(this, _handleLabelChange, handleLabelChange_fn).call(this, this._labelEl);
330
163
  }
331
164
  }
332
- #updateValueDueToUserInteraction(newValue) {
333
- this.value = newValue;
334
- this.$emit("change");
335
- this.$emit("input");
336
- }
337
165
  connectedCallback() {
338
166
  super.connectedCallback();
339
- document.addEventListener("click", this.#dismissOnClickOutside);
340
- this.addEventListener("focusin", this.#onFocusIn);
341
- this.addEventListener("focusout", this.#onFocusOut);
342
- }
343
- disconnectedCallback() {
344
- super.disconnectedCallback();
345
- document.removeEventListener("click", this.#dismissOnClickOutside);
346
- this.removeEventListener("focusin", this.#onFocusIn);
347
- this.removeEventListener("focusout", this.#onFocusOut);
348
- }
349
- #onFocusIn;
350
- #onFocusOut;
351
- #dismissOnClickOutside;
352
- #openPopupIfPossible() {
353
- if (!this.readOnly) {
354
- this._popupOpen = true;
355
- }
356
- }
357
- /**
358
- * @internal
359
- */
360
- _closePopup(restoreFocusToTextField = true) {
361
- this._popupOpen = false;
362
- if (restoreFocusToTextField) {
363
- this._textFieldEl.focus();
364
- }
365
- }
366
- /**
367
- * On keydown anywhere in the time picker.
368
- * @internal
369
- */
370
- _onBaseKeyDown(event) {
371
- if (event.key === "Escape") {
372
- this._closePopup();
373
- return false;
374
- }
375
- if (this._trappedFocus(event, this.#getFocusableEls)) {
376
- return false;
377
- }
378
- return true;
379
- }
380
- /**
381
- * @internal
382
- */
383
- _presentationValueChanged() {
384
- this.dirtyValue = true;
385
- this.validate();
386
- }
387
- /**
388
- * @internal
389
- */
390
- get _textFieldPlaceholder() {
391
- let format = "hh:mm";
392
- if (this._displaySeconds) {
393
- format += ":ss";
394
- }
395
- if (this._use12hClock) {
396
- format += " aa";
397
- }
398
- return format;
399
- }
400
- /**
401
- * @internal
402
- */
403
- _onTextFieldInput(event) {
404
- const textField = event.currentTarget;
405
- this._presentationValue = textField.value;
406
- }
407
- /**
408
- * @internal
409
- */
410
- _onTextFieldChange() {
411
- if (this._presentationValue === "") {
412
- this.#updateValueDueToUserInteraction("");
413
- return;
414
- }
415
- try {
416
- this.#updateValueDueToUserInteraction(
417
- parsePresentationTime(this._presentationValue, this._use12hClock)
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"
418
204
  );
419
- } catch (_) {
420
- return;
421
- }
422
- }
423
- // --- Clock button ---
424
- /**
425
- * @internal
426
- */
427
- get _clockButtonLabel() {
428
- if (this.value) {
429
- return this.locale.timePicker.changeTimeLabel(formatPresentationTime(this.value, this._displaySeconds, this._use12hClock));
430
- }
431
- return this.locale.timePicker.chooseTimeLabel;
432
- }
433
- /**
434
- * @internal
435
- */
436
- _onClockButtonClick() {
437
- if (this._popupOpen) {
438
- this._closePopup();
439
- } else {
440
- this.#openPopupIfPossible();
441
- index.DOM.processUpdates();
442
- if (this._selectedHour) {
443
- this.#scrollToItem("hours", this._selectedHour, "start");
444
- }
445
- if (this._selectedMinute) {
446
- this.#scrollToItem("minutes", this._selectedMinute, "start");
447
- }
448
- if (this._displaySeconds && this._selectedSecond) {
449
- this.#scrollToItem("seconds", this._selectedSecond, "start");
450
- }
451
- if (this._use12hClock && this._selectedMeridiem) {
452
- this.#scrollToItem("meridies", this._selectedMeridiem, "start");
453
- }
454
- this.#getFocusableEls()[0].focus();
455
- }
456
- }
457
- // --- Pickers ---
458
- /**
459
- * @internal
460
- */
461
- get _hours() {
462
- return getHoursOptions(this.min, this.max, this._use12hClock ? this._selectedMeridiem ?? this._meridies[0].value : void 0);
463
- }
464
- /**
465
- * @internal
466
- */
467
- get _selectedHour() {
468
- return this.value ? parseTimeStr(this.value).hourStr : void 0;
469
- }
470
- /**
471
- * @internal
472
- */
473
- set _selectedHour(value) {
474
- if (this.value) {
475
- const { minuteStr, secondStr } = parseTimeStr(this.value);
476
- this.value = `${value}:${minuteStr}:${secondStr}`;
477
- } else {
478
- 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);
479
225
  }
480
226
  }
481
- /**
482
- * @internal
483
- */
484
- get _minutes() {
485
- return getMinutesOptions(this.minutesStep, this.value, this.min, this.max);
486
- }
487
- /**
488
- * @internal
489
- */
490
- get _selectedMinute() {
491
- return this.value ? parseTimeStr(this.value).minuteStr : void 0;
492
- }
493
- /**
494
- * @internal
495
- */
496
- set _selectedMinute(value) {
497
- if (this.value) {
498
- const { hourStr, secondStr } = parseTimeStr(this.value);
499
- this.value = `${hourStr}:${value}:${secondStr}`;
500
- } else {
501
- this.value = `00:${value}:00`;
502
- }
503
- }
504
- /**
505
- * @internal
506
- */
507
- get _seconds() {
508
- return getSecondsOptions(this.secondsStep, this.value, this.min, this.max);
509
- }
510
- /**
511
- * @internal
512
- */
513
- get _selectedSecond() {
514
- return this.value ? parseTimeStr(this.value).secondStr : void 0;
515
- }
516
- /**
517
- * @internal
518
- */
519
- set _selectedSecond(value) {
520
- if (this.value) {
521
- const { hourStr, minuteStr } = parseTimeStr(this.value);
522
- this.value = `${hourStr}:${minuteStr}:${value}`;
523
- } else {
524
- this.value = `00:00:${value}`;
525
- }
526
- }
527
- /**
528
- * @internal
529
- */
530
- get _meridies() {
531
- return getMeridiesOptions(this.min, this.max);
532
- }
533
- /**
534
- * @internal
535
- */
536
- get _selectedMeridiem() {
537
- return this.value ? parseTimeStr(this.value).meridiem : void 0;
538
- }
539
- /**
540
- * @internal
541
- */
542
- set _selectedMeridiem(value) {
543
- if (this.value) {
544
- const { hours, minuteStr, secondStr } = parseTimeStr(this.value);
545
- let adjustedHours = hours;
546
- if (value === "AM" && hours >= 12) {
547
- adjustedHours -= 12;
548
- } else if (value === "PM" && hours < 12) {
549
- adjustedHours += 12;
550
- }
551
- this.value = `${formatTimePart(adjustedHours)}:${minuteStr}:${secondStr}`;
552
- } else {
553
- if (value === "AM") {
554
- this.value = "00:00:00";
555
- } else {
556
- this.value = "12:00:00";
557
- }
558
- }
559
- }
560
- /**
561
- * @internal
562
- */
563
- _onPickerKeyDown(picker, options, selectedValue, setSelectedValue, event) {
564
- const offset = {
565
- ArrowUp: -1,
566
- ArrowDown: 1
567
- }[event.key];
568
- if (offset) {
569
- event.preventDefault();
570
- const index = options.findIndex((h) => h.value === selectedValue);
571
- const newRawIndex = index === -1 ? 0 : index + offset;
572
- const newIndex = (newRawIndex + options.length) % options.length;
573
- const newValue = options[newIndex].value;
574
- setSelectedValue(newValue);
575
- this.#scrollToItem(picker, newValue, "nearest");
576
- this.#updateValueDueToUserInteraction(this.value);
577
- }
578
- return true;
579
- }
580
- #scrollToItem(picker, selectedValue, position) {
581
- const element = this.shadowRoot.querySelector(`#${picker}-${selectedValue}`);
582
- if (!element) {
583
- return;
584
- }
585
- const parent = element.parentElement;
586
- switch (position) {
587
- case "start":
588
- parent.scrollTop = element.offsetTop;
589
- break;
590
- case "nearest":
591
- if (element.offsetTop < parent.scrollTop) {
592
- parent.scrollTop = element.offsetTop;
593
- }
594
- if (element.offsetTop + element.offsetHeight > parent.scrollTop + parent.offsetHeight) {
595
- parent.scrollTop = element.offsetTop + element.offsetHeight - parent.offsetHeight;
596
- }
597
- break;
598
- }
599
- }
600
- /**
601
- * @internal
602
- */
603
- _onPickerItemClick(picker, setSelectedValue, value) {
604
- setSelectedValue(value);
605
- this.#scrollToItem(picker, value, "start");
606
- this.#updateValueDueToUserInteraction(this.value);
607
- const nextPickerEl = this.shadowRoot.querySelector(`#${picker} + .picker`);
608
- if (nextPickerEl) {
609
- nextPickerEl.focus();
610
- } else {
611
- this._closePopup();
612
- }
613
- }
614
- // --- Dialog footer ---
615
- /**
616
- * @internal
617
- */
618
- _onOkClick() {
619
- this._closePopup();
620
- }
621
- /**
622
- * @internal
623
- */
624
- _onClearClick() {
625
- this.#updateValueDueToUserInteraction("");
626
- this._closePopup();
627
- }
628
- // --- Validation ---
629
- /**
630
- * @internal
631
- */
632
- validate() {
633
- if (this.proxy) {
634
- this.proxy.setCustomValidity(this._getCustomValidationError() ?? "");
635
- }
636
- super.validate(this._textFieldEl?.querySelector("input") ?? void 0);
227
+ disconnectedCallback() {
228
+ super.disconnectedCallback();
229
+ __privateGet(this, _reflectToInput).destroy();
637
230
  }
638
- /**
639
- * @internal
640
- */
641
- _getCustomValidationError() {
642
- if (this._isPresentationValueInvalid()) {
643
- return this.locale.timePicker.invalidTimeError;
644
- }
645
- return null;
231
+ focus() {
232
+ this.control?.focus();
646
233
  }
647
- /**
648
- * @internal
649
- */
650
- _isPresentationValueInvalid() {
651
- if (this._presentationValue === "") {
652
- return false;
653
- }
654
- try {
655
- parsePresentationTime(this._presentationValue, this._use12hClock);
656
- return false;
657
- } catch (_) {
658
- return true;
234
+ };
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);
659
243
  }
660
244
  }
661
245
  };
662
- __decorateClass([
663
- index.attr({ attribute: "readonly", mode: "boolean" })
664
- ], TimePicker.prototype, "readOnly", 2);
665
- __decorateClass([
666
- index.attr({ attribute: "minutes-step", converter: index.nullableNumberConverter })
667
- ], TimePicker.prototype, "minutesStep", 2);
668
- __decorateClass([
669
- index.attr({ attribute: "seconds-step", converter: index.nullableNumberConverter })
670
- ], TimePicker.prototype, "secondsStep", 2);
246
+ _reflectToInput = new WeakMap();
671
247
  __decorateClass([
672
248
  index.attr
673
- ], TimePicker.prototype, "clock", 2);
249
+ ], exports.TextField.prototype, "appearance", 2);
674
250
  __decorateClass([
675
- index.attr({ converter: ValidTimeFilter })
676
- ], TimePicker.prototype, "min", 2);
251
+ index.attr
252
+ ], exports.TextField.prototype, "shape", 2);
677
253
  __decorateClass([
678
- index.attr({ converter: ValidTimeFilter })
679
- ], TimePicker.prototype, "max", 2);
254
+ index.attr
255
+ ], exports.TextField.prototype, "autoComplete", 2);
680
256
  __decorateClass([
681
257
  index.observable
682
- ], TimePicker.prototype, "_popupOpen", 2);
258
+ ], exports.TextField.prototype, "actionItemsSlottedContent", 2);
683
259
  __decorateClass([
684
260
  index.observable
685
- ], TimePicker.prototype, "_presentationValue", 2);
686
- TimePicker = __decorateClass([
261
+ ], exports.TextField.prototype, "leadingActionItemsSlottedContent", 2);
262
+ exports.TextField = __decorateClass([
687
263
  index$1.errorText,
688
264
  index$1.formElements
689
- ], TimePicker);
690
- applyMixins.applyMixins(TimePicker, localized.Localized, index$1.FormElementHelperText, trappedFocus.TrappedFocus);
265
+ ], exports.TextField);
266
+ applyMixins.applyMixins(
267
+ exports.TextField,
268
+ affix.AffixIcon,
269
+ index$1.FormElementCharCount,
270
+ index$1.FormElementHelperText,
271
+ index$1.FormElementSuccessText
272
+ );
691
273
 
692
- 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() {
693
303
  return index.html`
694
- <ul
695
- id="${id}"
696
- class="picker"
697
- role="listbox"
698
- tabindex="0"
699
- aria-label="${getLabel}"
700
- aria-activedescendant="${(x) => getSelected(x) ? `${id}-${getSelected(x)}` : void 0}"
701
- @keydown="${(x, c) => x._onPickerKeyDown(id, getOptions(x), getSelected(x), setSelected(x), c.event)}"
304
+ <span class="char-count"
305
+ >${(x) => x.value ? x.value.length : 0} / ${(x) => x.maxlength}</span
702
306
  >
703
- ${repeat.repeat(
704
- getOptions,
705
- index.html`
706
- <li
707
- id="${(x) => `${id}-${x.value}`}"
708
- class="${(x, c) => classNames.classNames("item", [
709
- "selected",
710
- getSelected(c.parent) === x.value
711
- ])}"
712
- role="option"
713
- aria-selected="${(x, c) => getSelected(c.parent) === x.value}"
714
- @click="${(x, c) => c.parent._onPickerItemClick(id, setSelected(c.parent), x.value)}"
715
- >
716
- ${(x) => x.label}
717
- </li>
718
- `
719
- )}
720
- </ul>
721
307
  `;
722
- };
723
- const TimePickerTemplate = (context, _) => {
724
- const popupTag = context.tagFor(definition.Popup);
725
- const textFieldTag = context.tagFor(definition$1.TextField);
726
- const buttonTag = context.tagFor(definition$2.Button);
727
- return index.html`<div class="base" @keydown="${(x, { event }) => x._onBaseKeyDown(event)}">
728
- <${textFieldTag} id="text-field"
729
- ${ref.ref("_textFieldEl")}
730
- class="control"
731
- label="${(x) => x.label}"
732
- helper-text="${(x) => x.helperText}"
733
- error-text="${(x) => x.errorValidationMessage}"
734
- placeholder="${(x) => x._textFieldPlaceholder}"
735
- current-value="${(x) => x._presentationValue}"
736
- ?disabled="${(x) => x.disabled}"
737
- ?readonly="${(x) => x.readOnly}"
738
- @input="${(x, c) => x._onTextFieldInput(c.event)}"
739
- @change="${(x) => x._onTextFieldChange()}"
740
- >
741
- <${buttonTag}
742
- id="clock-button"
743
- ${ref.ref("_clockButtonEl")}
744
- slot="action-items"
745
- size="condensed"
746
- icon="clock-line"
747
- appearance="ghost"
748
- ?disabled="${(x) => x.disabled || x.readOnly}"
749
- aria-label="${(x) => x._clockButtonLabel}"
750
- @click="${(x) => x._onClockButtonClick()}"
751
- ></${buttonTag}>
752
- </${textFieldTag}>
753
- <${popupTag}
754
- ?open="${(x) => x._popupOpen}"
755
- :anchor="${(x) => x._textFieldEl}"
756
- placement="bottom-start"
757
- class="popup">
758
- <div class="dialog" role="dialog" ${ref.ref(
759
- "_dialogEl"
760
- )} aria-modal="true" aria-label="${(x) => x.locale.timePicker.chooseTimeLabel}">
761
- <div class="time-pickers">
762
- ${renderPicker(
763
- "hours",
764
- (x) => x.locale.timePicker.hoursLabel,
765
- (x) => x._selectedHour,
766
- (x) => (v) => x._selectedHour = v,
767
- (x) => x._hours
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>
331
+ </div>
332
+ </div>
333
+ ${when.when(
334
+ (x) => !x.successText && !x.errorValidationMessage && x.helperText?.length,
335
+ index$1.getFeedbackTemplate("helper", context)
768
336
  )}
769
- ${renderPicker(
770
- "minutes",
771
- (x) => x.locale.timePicker.minutesLabel,
772
- (x) => x._selectedMinute,
773
- (x) => (v) => x._selectedMinute = v,
774
- (x) => x._minutes
337
+ ${when.when(
338
+ (x) => !x.successText && x.errorValidationMessage,
339
+ index$1.getFeedbackTemplate("error", context)
775
340
  )}
776
- ${when.when((x) => x._displaySeconds, renderPicker(
777
- "seconds",
778
- (x) => x.locale.timePicker.secondsLabel,
779
- (x) => x._selectedSecond,
780
- (x) => (v) => x._selectedSecond = v,
781
- (x) => x._seconds
782
- ))}
783
- ${when.when((x) => x._use12hClock, renderPicker(
784
- "meridies",
785
- (x) => x.locale.timePicker.meridiesLabel,
786
- (x) => x._selectedMeridiem,
787
- (x) => (v) => x._selectedMeridiem = v,
788
- (x) => x._meridies
789
- ))}
790
- </div>
791
- <div class="footer">
792
- <${buttonTag}
793
- class="vwc-button"
794
- size="condensed"
795
- label="${(x) => x.locale.timePicker.clearLabel}"
796
- @click="${(x) => x._onClearClick()}"
797
- ></${buttonTag}>
798
- <${buttonTag}
799
- class="vwc-button"
800
- size="condensed"
801
- appearance="filled"
802
- label="${(x) => x.locale.timePicker.okLabel}"
803
- @click="${(x) => x._onOkClick()}"
804
- ></${buttonTag}>
805
- </div>
806
- </div>
807
- </${popupTag}>
341
+ ${when.when((x) => x.successText, index$1.getFeedbackTemplate("success", context))}
808
342
  </div>`;
809
343
  };
810
344
 
811
- const timePickerDefinition = TimePicker.compose({
812
- baseName: "time-picker",
813
- template: TimePickerTemplate,
814
- styles,
345
+ const textFieldDefinition = exports.TextField.compose({
346
+ baseName: "text-field",
347
+ template: TextfieldTemplate,
348
+ styles: textField$1.styles,
815
349
  shadowOptions: {
816
350
  delegatesFocus: true
817
351
  }
818
352
  });
819
- const timePickerRegistries = [timePickerDefinition(), ...definition$1.textFieldRegistries, ...definition.popupRegistries, ...definition$2.buttonRegistries];
820
- const registerTimePicker = index.registerFactory(timePickerRegistries);
353
+ const textFieldRegistries = [textFieldDefinition(), ...definition.iconRegistries];
354
+ const registerTextField = index.registerFactory(textFieldRegistries);
821
355
 
822
- exports.registerTimePicker = registerTimePicker;
823
- exports.timePickerDefinition = timePickerDefinition;
824
- exports.timePickerRegistries = timePickerRegistries;
356
+ exports.registerTextField = registerTextField;
357
+ exports.textFieldDefinition = textFieldDefinition;
358
+ exports.textFieldRegistries = textFieldRegistries;