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