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

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