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