@vonage/vivid 3.0.0-next.3 → 3.0.0-next.32

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