@vonage/vivid 3.0.0-next.5 → 3.0.0-next.52

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 (147) hide show
  1. package/README.md +135 -4
  2. package/accordion/index.js +2 -2
  3. package/accordion-item/index.js +26 -18
  4. package/action-group/index.js +49 -0
  5. package/badge/index.js +14 -18
  6. package/banner/index.js +20 -83
  7. package/breadcrumb/index.js +20 -16
  8. package/breadcrumb-item/index.js +14 -9
  9. package/button/index.js +28 -659
  10. package/calendar/index.js +37 -8
  11. package/calendar-event/index.js +117 -0
  12. package/card/index.js +134 -0
  13. package/checkbox/index.js +173 -0
  14. package/dialog/index.js +282 -0
  15. package/divider/index.js +88 -0
  16. package/elevation/index.js +4 -31
  17. package/fab/index.js +102 -0
  18. package/focus/index.js +20 -3
  19. package/header/index.js +68 -0
  20. package/icon/index.js +9 -3
  21. package/index.js +45 -20
  22. package/layout/index.js +4 -4
  23. package/lib/accordion-item/accordion-item.d.ts +2 -2
  24. package/lib/accordion-item/index.d.ts +2 -1
  25. package/lib/action-group/action-group.d.ts +10 -0
  26. package/lib/{sidenav-item/sidenav-item.template.d.ts → action-group/action-group.template.d.ts} +2 -2
  27. package/lib/{sidenav-item → action-group}/index.d.ts +1 -2
  28. package/lib/badge/badge.d.ts +6 -6
  29. package/lib/badge/index.d.ts +1 -1
  30. package/lib/banner/banner.d.ts +1 -1
  31. package/lib/banner/banner.template.d.ts +0 -2
  32. package/lib/banner/index.d.ts +1 -0
  33. package/lib/breadcrumb/breadcrumb.template.d.ts +4 -0
  34. package/lib/breadcrumb-item/breadcrumb-item.d.ts +1 -1
  35. package/lib/breadcrumb-item/index.d.ts +1 -0
  36. package/lib/button/button.d.ts +6 -5
  37. package/lib/button/index.d.ts +2 -19
  38. package/lib/calendar/calendar.d.ts +3 -1
  39. package/lib/calendar/index.d.ts +0 -1
  40. package/lib/calendar-event/calendar-event.d.ts +14 -0
  41. package/lib/calendar-event/calendar-event.template.d.ts +4 -0
  42. package/lib/calendar-event/index.d.ts +2 -0
  43. package/lib/card/card.d.ts +10 -0
  44. package/lib/{text/text.template.d.ts → card/card.template.d.ts} +2 -2
  45. package/lib/card/index.d.ts +4 -0
  46. package/lib/checkbox/checkbox.d.ts +5 -0
  47. package/lib/checkbox/checkbox.template.d.ts +4 -0
  48. package/lib/checkbox/index.d.ts +4 -0
  49. package/lib/components.d.ts +22 -10
  50. package/lib/dialog/dialog.d.ts +20 -0
  51. package/lib/dialog/dialog.template.d.ts +4 -0
  52. package/lib/dialog/index.d.ts +5 -0
  53. package/lib/divider/divider.d.ts +3 -0
  54. package/lib/divider/divider.template.d.ts +4 -0
  55. package/lib/divider/index.d.ts +2 -0
  56. package/lib/elevation/elevation.d.ts +1 -0
  57. package/lib/elevation/index.d.ts +1 -1
  58. package/lib/enums.d.ts +12 -6
  59. package/lib/fab/fab.d.ts +13 -0
  60. package/lib/fab/fab.template.d.ts +4 -0
  61. package/lib/fab/index.d.ts +4 -0
  62. package/lib/focus/index.d.ts +1 -1
  63. package/lib/header/header.d.ts +5 -0
  64. package/lib/header/header.template.d.ts +4 -0
  65. package/lib/header/index.d.ts +3 -0
  66. package/lib/icon/icon.d.ts +4 -3
  67. package/lib/layout/index.d.ts +1 -1
  68. package/lib/layout/layout.d.ts +3 -3
  69. package/lib/menu/index.d.ts +11 -0
  70. package/lib/menu/menu.d.ts +7 -0
  71. package/lib/menu/menu.template.d.ts +3 -0
  72. package/lib/nav/index.d.ts +2 -0
  73. package/lib/nav/nav.d.ts +3 -0
  74. package/lib/nav/nav.template.d.ts +4 -0
  75. package/lib/nav-disclosure/index.d.ts +4 -0
  76. package/lib/nav-disclosure/nav-disclosure.d.ts +10 -0
  77. package/lib/nav-disclosure/nav-disclosure.template.d.ts +4 -0
  78. package/lib/nav-item/index.d.ts +4 -0
  79. package/lib/{sidenav-item/sidenav-item.d.ts → nav-item/nav-item.d.ts} +2 -2
  80. package/lib/nav-item/nav-item.template.d.ts +4 -0
  81. package/lib/{text → note}/index.d.ts +1 -1
  82. package/lib/note/note.d.ts +10 -0
  83. package/lib/note/note.template.d.ts +5 -0
  84. package/lib/popup/index.d.ts +1 -1
  85. package/lib/popup/popup.d.ts +3 -15
  86. package/lib/progress/progress.d.ts +1 -1
  87. package/lib/progress-ring/progress-ring.d.ts +2 -1
  88. package/lib/side-drawer/index.d.ts +1 -1
  89. package/lib/side-drawer/side-drawer.d.ts +2 -7
  90. package/lib/side-drawer/side-drawer.template.d.ts +2 -2
  91. package/lib/text-anchor/text-anchor.d.ts +1 -1
  92. package/lib/text-field/index.d.ts +4 -0
  93. package/lib/text-field/text-field.d.ts +16 -0
  94. package/lib/text-field/text-field.template.d.ts +5 -0
  95. package/lib/tooltip/tooltip.d.ts +2 -4
  96. package/menu/index.js +661 -0
  97. package/nav/index.js +17 -0
  98. package/nav-disclosure/index.js +90 -0
  99. package/nav-item/index.js +43 -0
  100. package/note/index.js +68 -0
  101. package/package.json +48 -8
  102. package/popup/index.js +20 -2082
  103. package/progress/index.js +33 -24
  104. package/progress-ring/index.js +9 -3
  105. package/shared/anchor.js +8 -1
  106. package/shared/aria-global.js +3 -40
  107. package/shared/base-progress.js +5 -0
  108. package/shared/button.js +195 -0
  109. package/shared/calendar-event.js +26 -0
  110. package/shared/dialog-polyfill.esm.js +858 -0
  111. package/shared/enums.js +79 -0
  112. package/shared/es.object.assign.js +7 -6
  113. package/shared/export.js +972 -0
  114. package/shared/focus.js +5 -0
  115. package/shared/focus2.js +11 -0
  116. package/shared/form-associated.js +557 -0
  117. package/shared/icon.js +504 -508
  118. package/shared/index.js +79 -56
  119. package/shared/index2.js +26 -10
  120. package/shared/index3.js +2109 -0
  121. package/shared/iterators.js +61 -0
  122. package/shared/object-keys.js +13 -0
  123. package/shared/patterns/focus.d.ts +3 -0
  124. package/shared/patterns/form-elements.d.ts +22 -0
  125. package/shared/patterns/index.d.ts +1 -0
  126. package/shared/ref.js +41 -0
  127. package/shared/text-anchor.js +2 -11
  128. package/shared/text-anchor.template.js +5 -2
  129. package/shared/to-string.js +51 -0
  130. package/shared/web.dom-collections.iterator.js +61 -1074
  131. package/side-drawer/index.js +33 -51
  132. package/styles/fonts/SpeziaCompleteVariableItalicWeb.woff +0 -0
  133. package/styles/fonts/SpeziaCompleteVariableItalicWeb.woff2 +0 -0
  134. package/styles/fonts/SpeziaCompleteVariableUprightWeb.woff +0 -0
  135. package/styles/fonts/SpeziaCompleteVariableUprightWeb.woff2 +0 -0
  136. package/styles/fonts/SpeziaMonoCompleteVariableWeb.woff +0 -0
  137. package/styles/fonts/SpeziaMonoCompleteVariableWeb.woff2 +0 -0
  138. package/styles/fonts/spezia.css +12 -12
  139. package/styles/themes/dark.css +182 -176
  140. package/styles/themes/light.css +182 -176
  141. package/styles/typography/desktop.css +89 -0
  142. package/text-anchor/index.js +8 -1
  143. package/text-field/index.js +438 -0
  144. package/tooltip/index.js +19 -21
  145. package/lib/text/text.d.ts +0 -10
  146. package/sidenav-item/index.js +0 -38
  147. package/text/index.js +0 -45
@@ -0,0 +1,5 @@
1
+ import { F as FoundationElement } from './index.js';
2
+
3
+ class Focus extends FoundationElement {}
4
+
5
+ export { Focus as F };
@@ -0,0 +1,11 @@
1
+ import { F as Focus } from './focus.js';
2
+ import { h as html } from './index.js';
3
+
4
+ let _ = t => t,
5
+ _t;
6
+ const focusTemplateFactory = context => {
7
+ const focusTag = context.tagFor(Focus);
8
+ return html(_t || (_t = _`<${0} class="focus-indicator"></${0}>`), focusTag, focusTag);
9
+ };
10
+
11
+ export { focusTemplateFactory as f };
@@ -0,0 +1,557 @@
1
+ import { e as emptyArray, D as DOM, a as attr, o as observable, f as booleanConverter } from './index.js';
2
+
3
+ /**
4
+ * Key Code values
5
+ * @deprecated - KeyCodes are deprecated, use individual string key exports
6
+ */
7
+ var KeyCodes;
8
+ (function (KeyCodes) {
9
+ KeyCodes[KeyCodes["alt"] = 18] = "alt";
10
+ KeyCodes[KeyCodes["arrowDown"] = 40] = "arrowDown";
11
+ KeyCodes[KeyCodes["arrowLeft"] = 37] = "arrowLeft";
12
+ KeyCodes[KeyCodes["arrowRight"] = 39] = "arrowRight";
13
+ KeyCodes[KeyCodes["arrowUp"] = 38] = "arrowUp";
14
+ KeyCodes[KeyCodes["back"] = 8] = "back";
15
+ KeyCodes[KeyCodes["backSlash"] = 220] = "backSlash";
16
+ KeyCodes[KeyCodes["break"] = 19] = "break";
17
+ KeyCodes[KeyCodes["capsLock"] = 20] = "capsLock";
18
+ KeyCodes[KeyCodes["closeBracket"] = 221] = "closeBracket";
19
+ KeyCodes[KeyCodes["colon"] = 186] = "colon";
20
+ KeyCodes[KeyCodes["colon2"] = 59] = "colon2";
21
+ KeyCodes[KeyCodes["comma"] = 188] = "comma";
22
+ KeyCodes[KeyCodes["ctrl"] = 17] = "ctrl";
23
+ KeyCodes[KeyCodes["delete"] = 46] = "delete";
24
+ KeyCodes[KeyCodes["end"] = 35] = "end";
25
+ KeyCodes[KeyCodes["enter"] = 13] = "enter";
26
+ KeyCodes[KeyCodes["equals"] = 187] = "equals";
27
+ KeyCodes[KeyCodes["equals2"] = 61] = "equals2";
28
+ KeyCodes[KeyCodes["equals3"] = 107] = "equals3";
29
+ KeyCodes[KeyCodes["escape"] = 27] = "escape";
30
+ KeyCodes[KeyCodes["forwardSlash"] = 191] = "forwardSlash";
31
+ KeyCodes[KeyCodes["function1"] = 112] = "function1";
32
+ KeyCodes[KeyCodes["function10"] = 121] = "function10";
33
+ KeyCodes[KeyCodes["function11"] = 122] = "function11";
34
+ KeyCodes[KeyCodes["function12"] = 123] = "function12";
35
+ KeyCodes[KeyCodes["function2"] = 113] = "function2";
36
+ KeyCodes[KeyCodes["function3"] = 114] = "function3";
37
+ KeyCodes[KeyCodes["function4"] = 115] = "function4";
38
+ KeyCodes[KeyCodes["function5"] = 116] = "function5";
39
+ KeyCodes[KeyCodes["function6"] = 117] = "function6";
40
+ KeyCodes[KeyCodes["function7"] = 118] = "function7";
41
+ KeyCodes[KeyCodes["function8"] = 119] = "function8";
42
+ KeyCodes[KeyCodes["function9"] = 120] = "function9";
43
+ KeyCodes[KeyCodes["home"] = 36] = "home";
44
+ KeyCodes[KeyCodes["insert"] = 45] = "insert";
45
+ KeyCodes[KeyCodes["menu"] = 93] = "menu";
46
+ KeyCodes[KeyCodes["minus"] = 189] = "minus";
47
+ KeyCodes[KeyCodes["minus2"] = 109] = "minus2";
48
+ KeyCodes[KeyCodes["numLock"] = 144] = "numLock";
49
+ KeyCodes[KeyCodes["numPad0"] = 96] = "numPad0";
50
+ KeyCodes[KeyCodes["numPad1"] = 97] = "numPad1";
51
+ KeyCodes[KeyCodes["numPad2"] = 98] = "numPad2";
52
+ KeyCodes[KeyCodes["numPad3"] = 99] = "numPad3";
53
+ KeyCodes[KeyCodes["numPad4"] = 100] = "numPad4";
54
+ KeyCodes[KeyCodes["numPad5"] = 101] = "numPad5";
55
+ KeyCodes[KeyCodes["numPad6"] = 102] = "numPad6";
56
+ KeyCodes[KeyCodes["numPad7"] = 103] = "numPad7";
57
+ KeyCodes[KeyCodes["numPad8"] = 104] = "numPad8";
58
+ KeyCodes[KeyCodes["numPad9"] = 105] = "numPad9";
59
+ KeyCodes[KeyCodes["numPadDivide"] = 111] = "numPadDivide";
60
+ KeyCodes[KeyCodes["numPadDot"] = 110] = "numPadDot";
61
+ KeyCodes[KeyCodes["numPadMinus"] = 109] = "numPadMinus";
62
+ KeyCodes[KeyCodes["numPadMultiply"] = 106] = "numPadMultiply";
63
+ KeyCodes[KeyCodes["numPadPlus"] = 107] = "numPadPlus";
64
+ KeyCodes[KeyCodes["openBracket"] = 219] = "openBracket";
65
+ KeyCodes[KeyCodes["pageDown"] = 34] = "pageDown";
66
+ KeyCodes[KeyCodes["pageUp"] = 33] = "pageUp";
67
+ KeyCodes[KeyCodes["period"] = 190] = "period";
68
+ KeyCodes[KeyCodes["print"] = 44] = "print";
69
+ KeyCodes[KeyCodes["quote"] = 222] = "quote";
70
+ KeyCodes[KeyCodes["scrollLock"] = 145] = "scrollLock";
71
+ KeyCodes[KeyCodes["shift"] = 16] = "shift";
72
+ KeyCodes[KeyCodes["space"] = 32] = "space";
73
+ KeyCodes[KeyCodes["tab"] = 9] = "tab";
74
+ KeyCodes[KeyCodes["tilde"] = 192] = "tilde";
75
+ KeyCodes[KeyCodes["windowsLeft"] = 91] = "windowsLeft";
76
+ KeyCodes[KeyCodes["windowsOpera"] = 219] = "windowsOpera";
77
+ KeyCodes[KeyCodes["windowsRight"] = 92] = "windowsRight";
78
+ })(KeyCodes || (KeyCodes = {}));
79
+ /**
80
+ * String values for use with KeyboardEvent.key
81
+ */
82
+ const keyArrowDown = "ArrowDown";
83
+ const keyArrowLeft = "ArrowLeft";
84
+ const keyArrowRight = "ArrowRight";
85
+ const keyArrowUp = "ArrowUp";
86
+ const keyEnter = "Enter";
87
+ const keyEscape = "Escape";
88
+ const keyHome = "Home";
89
+ const keyEnd = "End";
90
+ const keySpace = " ";
91
+
92
+ const proxySlotName = "form-associated-proxy";
93
+ const ElementInternalsKey = "ElementInternals";
94
+ /**
95
+ * @alpha
96
+ */
97
+ const supportsElementInternals = ElementInternalsKey in window &&
98
+ "setFormValue" in window[ElementInternalsKey].prototype;
99
+ const InternalsMap = new WeakMap();
100
+ /**
101
+ * Base function for providing Custom Element Form Association.
102
+ *
103
+ * @alpha
104
+ */
105
+ function FormAssociated(BaseCtor) {
106
+ const C = class extends BaseCtor {
107
+ constructor(...args) {
108
+ super(...args);
109
+ /**
110
+ * Track whether the value has been changed from the initial value
111
+ */
112
+ this.dirtyValue = false;
113
+ /**
114
+ * Sets the element's disabled state. A disabled element will not be included during form submission.
115
+ *
116
+ * @remarks
117
+ * HTML Attribute: disabled
118
+ */
119
+ this.disabled = false;
120
+ /**
121
+ * These are events that are still fired by the proxy
122
+ * element based on user / programmatic interaction.
123
+ *
124
+ * The proxy implementation should be transparent to
125
+ * the app author, so block these events from emitting.
126
+ */
127
+ this.proxyEventsToBlock = ["change", "click"];
128
+ this.proxyInitialized = false;
129
+ this.required = false;
130
+ this.initialValue = this.initialValue || "";
131
+ if (!this.elementInternals) {
132
+ // When elementInternals is not supported, formResetCallback is
133
+ // bound to an event listener, so ensure the handler's `this`
134
+ // context is correct.
135
+ this.formResetCallback = this.formResetCallback.bind(this);
136
+ }
137
+ }
138
+ /**
139
+ * Must evaluate to true to enable elementInternals.
140
+ * Feature detects API support and resolve respectively
141
+ *
142
+ * @internal
143
+ */
144
+ static get formAssociated() {
145
+ return supportsElementInternals;
146
+ }
147
+ /**
148
+ * Returns the validity state of the element
149
+ *
150
+ * @alpha
151
+ */
152
+ get validity() {
153
+ return this.elementInternals
154
+ ? this.elementInternals.validity
155
+ : this.proxy.validity;
156
+ }
157
+ /**
158
+ * Retrieve a reference to the associated form.
159
+ * Returns null if not associated to any form.
160
+ *
161
+ * @alpha
162
+ */
163
+ get form() {
164
+ return this.elementInternals ? this.elementInternals.form : this.proxy.form;
165
+ }
166
+ /**
167
+ * Retrieve the localized validation message,
168
+ * or custom validation message if set.
169
+ *
170
+ * @alpha
171
+ */
172
+ get validationMessage() {
173
+ return this.elementInternals
174
+ ? this.elementInternals.validationMessage
175
+ : this.proxy.validationMessage;
176
+ }
177
+ /**
178
+ * Whether the element will be validated when the
179
+ * form is submitted
180
+ */
181
+ get willValidate() {
182
+ return this.elementInternals
183
+ ? this.elementInternals.willValidate
184
+ : this.proxy.willValidate;
185
+ }
186
+ /**
187
+ * A reference to all associated label elements
188
+ */
189
+ get labels() {
190
+ if (this.elementInternals) {
191
+ return Object.freeze(Array.from(this.elementInternals.labels));
192
+ }
193
+ else if (this.proxy instanceof HTMLElement &&
194
+ this.proxy.ownerDocument &&
195
+ this.id) {
196
+ // Labels associated by wrapping the element: <label><custom-element></custom-element></label>
197
+ const parentLabels = this.proxy.labels;
198
+ // Labels associated using the `for` attribute
199
+ const forLabels = Array.from(this.proxy.getRootNode().querySelectorAll(`[for='${this.id}']`));
200
+ const labels = parentLabels
201
+ ? forLabels.concat(Array.from(parentLabels))
202
+ : forLabels;
203
+ return Object.freeze(labels);
204
+ }
205
+ else {
206
+ return emptyArray;
207
+ }
208
+ }
209
+ /**
210
+ * Invoked when the `value` property changes
211
+ * @param previous - the previous value
212
+ * @param next - the new value
213
+ *
214
+ * @remarks
215
+ * If elements extending `FormAssociated` implement a `valueChanged` method
216
+ * They must be sure to invoke `super.valueChanged(previous, next)` to ensure
217
+ * proper functioning of `FormAssociated`
218
+ */
219
+ valueChanged(previous, next) {
220
+ this.dirtyValue = true;
221
+ if (this.proxy instanceof HTMLElement) {
222
+ this.proxy.value = this.value;
223
+ }
224
+ this.currentValue = this.value;
225
+ this.setFormValue(this.value);
226
+ this.validate();
227
+ }
228
+ currentValueChanged() {
229
+ this.value = this.currentValue;
230
+ }
231
+ /**
232
+ * Invoked when the `initialValue` property changes
233
+ *
234
+ * @param previous - the previous value
235
+ * @param next - the new value
236
+ *
237
+ * @remarks
238
+ * If elements extending `FormAssociated` implement a `initialValueChanged` method
239
+ * They must be sure to invoke `super.initialValueChanged(previous, next)` to ensure
240
+ * proper functioning of `FormAssociated`
241
+ */
242
+ initialValueChanged(previous, next) {
243
+ // If the value is clean and the component is connected to the DOM
244
+ // then set value equal to the attribute value.
245
+ if (!this.dirtyValue) {
246
+ this.value = this.initialValue;
247
+ this.dirtyValue = false;
248
+ }
249
+ }
250
+ /**
251
+ * Invoked when the `disabled` property changes
252
+ *
253
+ * @param previous - the previous value
254
+ * @param next - the new value
255
+ *
256
+ * @remarks
257
+ * If elements extending `FormAssociated` implement a `disabledChanged` method
258
+ * They must be sure to invoke `super.disabledChanged(previous, next)` to ensure
259
+ * proper functioning of `FormAssociated`
260
+ */
261
+ disabledChanged(previous, next) {
262
+ if (this.proxy instanceof HTMLElement) {
263
+ this.proxy.disabled = this.disabled;
264
+ }
265
+ DOM.queueUpdate(() => this.classList.toggle("disabled", this.disabled));
266
+ }
267
+ /**
268
+ * Invoked when the `name` property changes
269
+ *
270
+ * @param previous - the previous value
271
+ * @param next - the new value
272
+ *
273
+ * @remarks
274
+ * If elements extending `FormAssociated` implement a `nameChanged` method
275
+ * They must be sure to invoke `super.nameChanged(previous, next)` to ensure
276
+ * proper functioning of `FormAssociated`
277
+ */
278
+ nameChanged(previous, next) {
279
+ if (this.proxy instanceof HTMLElement) {
280
+ this.proxy.name = this.name;
281
+ }
282
+ }
283
+ /**
284
+ * Invoked when the `required` property changes
285
+ *
286
+ * @param previous - the previous value
287
+ * @param next - the new value
288
+ *
289
+ * @remarks
290
+ * If elements extending `FormAssociated` implement a `requiredChanged` method
291
+ * They must be sure to invoke `super.requiredChanged(previous, next)` to ensure
292
+ * proper functioning of `FormAssociated`
293
+ */
294
+ requiredChanged(prev, next) {
295
+ if (this.proxy instanceof HTMLElement) {
296
+ this.proxy.required = this.required;
297
+ }
298
+ DOM.queueUpdate(() => this.classList.toggle("required", this.required));
299
+ this.validate();
300
+ }
301
+ /**
302
+ * The element internals object. Will only exist
303
+ * in browsers supporting the attachInternals API
304
+ */
305
+ get elementInternals() {
306
+ if (!supportsElementInternals) {
307
+ return null;
308
+ }
309
+ let internals = InternalsMap.get(this);
310
+ if (!internals) {
311
+ internals = this.attachInternals();
312
+ InternalsMap.set(this, internals);
313
+ }
314
+ return internals;
315
+ }
316
+ /**
317
+ * @internal
318
+ */
319
+ connectedCallback() {
320
+ super.connectedCallback();
321
+ this.addEventListener("keypress", this._keypressHandler);
322
+ if (!this.value) {
323
+ this.value = this.initialValue;
324
+ this.dirtyValue = false;
325
+ }
326
+ if (!this.elementInternals) {
327
+ this.attachProxy();
328
+ if (this.form) {
329
+ this.form.addEventListener("reset", this.formResetCallback);
330
+ }
331
+ }
332
+ }
333
+ /**
334
+ * @internal
335
+ */
336
+ disconnectedCallback() {
337
+ this.proxyEventsToBlock.forEach(name => this.proxy.removeEventListener(name, this.stopPropagation));
338
+ if (!this.elementInternals && this.form) {
339
+ this.form.removeEventListener("reset", this.formResetCallback);
340
+ }
341
+ }
342
+ /**
343
+ * Return the current validity of the element.
344
+ */
345
+ checkValidity() {
346
+ return this.elementInternals
347
+ ? this.elementInternals.checkValidity()
348
+ : this.proxy.checkValidity();
349
+ }
350
+ /**
351
+ * Return the current validity of the element.
352
+ * If false, fires an invalid event at the element.
353
+ */
354
+ reportValidity() {
355
+ return this.elementInternals
356
+ ? this.elementInternals.reportValidity()
357
+ : this.proxy.reportValidity();
358
+ }
359
+ /**
360
+ * Set the validity of the control. In cases when the elementInternals object is not
361
+ * available (and the proxy element is used to report validity), this function will
362
+ * do nothing unless a message is provided, at which point the setCustomValidity method
363
+ * of the proxy element will be invoked with the provided message.
364
+ * @param flags - Validity flags
365
+ * @param message - Optional message to supply
366
+ * @param anchor - Optional element used by UA to display an interactive validation UI
367
+ */
368
+ setValidity(flags, message, anchor) {
369
+ if (this.elementInternals) {
370
+ this.elementInternals.setValidity(flags, message, anchor);
371
+ }
372
+ else if (typeof message === "string") {
373
+ this.proxy.setCustomValidity(message);
374
+ }
375
+ }
376
+ /**
377
+ * Invoked when a connected component's form or fieldset has its disabled
378
+ * state changed.
379
+ * @param disabled - the disabled value of the form / fieldset
380
+ */
381
+ formDisabledCallback(disabled) {
382
+ this.disabled = disabled;
383
+ }
384
+ formResetCallback() {
385
+ this.value = this.initialValue;
386
+ this.dirtyValue = false;
387
+ }
388
+ /**
389
+ * Attach the proxy element to the DOM
390
+ */
391
+ attachProxy() {
392
+ var _a;
393
+ if (!this.proxyInitialized) {
394
+ this.proxyInitialized = true;
395
+ this.proxy.style.display = "none";
396
+ this.proxyEventsToBlock.forEach(name => this.proxy.addEventListener(name, this.stopPropagation));
397
+ // These are typically mapped to the proxy during
398
+ // property change callbacks, but during initialization
399
+ // on the initial call of the callback, the proxy is
400
+ // still undefined. We should find a better way to address this.
401
+ this.proxy.disabled = this.disabled;
402
+ this.proxy.required = this.required;
403
+ if (typeof this.name === "string") {
404
+ this.proxy.name = this.name;
405
+ }
406
+ if (typeof this.value === "string") {
407
+ this.proxy.value = this.value;
408
+ }
409
+ this.proxy.setAttribute("slot", proxySlotName);
410
+ this.proxySlot = document.createElement("slot");
411
+ this.proxySlot.setAttribute("name", proxySlotName);
412
+ }
413
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.appendChild(this.proxySlot);
414
+ this.appendChild(this.proxy);
415
+ }
416
+ /**
417
+ * Detach the proxy element from the DOM
418
+ */
419
+ detachProxy() {
420
+ var _a;
421
+ this.removeChild(this.proxy);
422
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.removeChild(this.proxySlot);
423
+ }
424
+ /**
425
+ * Sets the validity of the custom element. By default this uses the proxy element to determine
426
+ * validity, but this can be extended or replaced in implementation.
427
+ */
428
+ validate() {
429
+ if (this.proxy instanceof HTMLElement) {
430
+ this.setValidity(this.proxy.validity, this.proxy.validationMessage);
431
+ }
432
+ }
433
+ /**
434
+ * Associates the provided value (and optional state) with the parent form.
435
+ * @param value - The value to set
436
+ * @param state - The state object provided to during session restores and when autofilling.
437
+ */
438
+ setFormValue(value, state) {
439
+ if (this.elementInternals) {
440
+ this.elementInternals.setFormValue(value, state || value);
441
+ }
442
+ }
443
+ _keypressHandler(e) {
444
+ switch (e.key) {
445
+ case keyEnter:
446
+ if (this.form instanceof HTMLFormElement) {
447
+ // Implicit submission
448
+ const defaultButton = this.form.querySelector("[type=submit]");
449
+ defaultButton === null || defaultButton === void 0 ? void 0 : defaultButton.click();
450
+ }
451
+ break;
452
+ }
453
+ }
454
+ /**
455
+ * Used to stop propagation of proxy element events
456
+ * @param e - Event object
457
+ */
458
+ stopPropagation(e) {
459
+ e.stopPropagation();
460
+ }
461
+ };
462
+ attr({ mode: "boolean" })(C.prototype, "disabled");
463
+ attr({ mode: "fromView", attribute: "value" })(C.prototype, "initialValue");
464
+ attr({ attribute: "current-value" })(C.prototype, "currentValue");
465
+ attr(C.prototype, "name");
466
+ attr({ mode: "boolean" })(C.prototype, "required");
467
+ observable(C.prototype, "value");
468
+ return C;
469
+ }
470
+ /**
471
+ * @alpha
472
+ */
473
+ function CheckableFormAssociated(BaseCtor) {
474
+ class C extends FormAssociated(BaseCtor) {
475
+ }
476
+ class D extends C {
477
+ constructor(...args) {
478
+ super(args);
479
+ /**
480
+ * Tracks whether the "checked" property has been changed.
481
+ * This is necessary to provide consistent behavior with
482
+ * normal input checkboxes
483
+ */
484
+ this.dirtyChecked = false;
485
+ /**
486
+ * Provides the default checkedness of the input element
487
+ * Passed down to proxy
488
+ *
489
+ * @public
490
+ * @remarks
491
+ * HTML Attribute: checked
492
+ */
493
+ this.checkedAttribute = false;
494
+ /**
495
+ * The checked state of the control.
496
+ *
497
+ * @public
498
+ */
499
+ this.checked = false;
500
+ // Re-initialize dirtyChecked because initialization of other values
501
+ // causes it to become true
502
+ this.dirtyChecked = false;
503
+ }
504
+ checkedAttributeChanged() {
505
+ this.defaultChecked = this.checkedAttribute;
506
+ }
507
+ /**
508
+ * @internal
509
+ */
510
+ defaultCheckedChanged() {
511
+ if (!this.dirtyChecked) {
512
+ // Setting this.checked will cause us to enter a dirty state,
513
+ // but if we are clean when defaultChecked is changed, we want to stay
514
+ // in a clean state, so reset this.dirtyChecked
515
+ this.checked = this.defaultChecked;
516
+ this.dirtyChecked = false;
517
+ }
518
+ }
519
+ checkedChanged(prev, next) {
520
+ if (!this.dirtyChecked) {
521
+ this.dirtyChecked = true;
522
+ }
523
+ this.currentChecked = this.checked;
524
+ this.updateForm();
525
+ if (this.proxy instanceof HTMLInputElement) {
526
+ this.proxy.checked = this.checked;
527
+ }
528
+ if (prev !== undefined) {
529
+ this.$emit("change");
530
+ }
531
+ this.validate();
532
+ }
533
+ currentCheckedChanged(prev, next) {
534
+ this.checked = this.currentChecked;
535
+ }
536
+ updateForm() {
537
+ const value = this.checked ? this.value : null;
538
+ this.setFormValue(value, value);
539
+ }
540
+ connectedCallback() {
541
+ super.connectedCallback();
542
+ this.updateForm();
543
+ }
544
+ formResetCallback() {
545
+ super.formResetCallback();
546
+ this.checked = !!this.checkedAttribute;
547
+ this.dirtyChecked = false;
548
+ }
549
+ }
550
+ attr({ attribute: "checked", mode: "boolean" })(D.prototype, "checkedAttribute");
551
+ attr({ attribute: "current-checked", converter: booleanConverter })(D.prototype, "currentChecked");
552
+ observable(D.prototype, "defaultChecked");
553
+ observable(D.prototype, "checked");
554
+ return D;
555
+ }
556
+
557
+ export { CheckableFormAssociated as C, FormAssociated as F, keyArrowLeft as a, keyArrowRight as b, keyEnter as c, keyHome as d, keyEnd as e, keyArrowUp as f, keyArrowDown as g, keyEscape as h, keySpace as k };