@vonage/vivid 3.32.0 → 3.34.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 (218) hide show
  1. package/accordion/index.js +5 -5
  2. package/accordion-item/index.js +4 -4
  3. package/action-group/index.js +1 -1
  4. package/alert/index.js +6 -6
  5. package/avatar/index.js +2 -2
  6. package/badge/index.js +2 -2
  7. package/banner/index.js +5 -5
  8. package/breadcrumb/index.js +1 -1
  9. package/breadcrumb-item/index.js +3 -3
  10. package/button/index.js +4 -4
  11. package/calendar/index.js +1 -1
  12. package/calendar-event/index.js +1 -1
  13. package/card/index.js +3 -3
  14. package/checkbox/index.js +5 -3
  15. package/combobox/index.js +8 -8
  16. package/custom-elements.json +246 -16
  17. package/data-grid/index.js +2 -2
  18. package/date-picker/index.js +9 -9
  19. package/dialog/index.js +6 -6
  20. package/divider/index.js +1 -1
  21. package/elevation/index.js +1 -1
  22. package/empty-state/index.js +2 -2
  23. package/fab/index.js +4 -4
  24. package/file-picker/index.js +5 -5
  25. package/focus/index.js +1 -1
  26. package/header/index.js +2 -2
  27. package/icon/index.js +1 -1
  28. package/index.js +59 -59
  29. package/layout/index.js +1 -1
  30. package/lib/calendar/calendar.d.ts +1 -1
  31. package/lib/date-picker/calendar/dateStr.d.ts +1 -0
  32. package/lib/date-picker/calendar/month.d.ts +1 -0
  33. package/lib/date-picker/calendar/year.d.ts +2 -0
  34. package/lib/date-picker/date-picker.d.ts +2 -0
  35. package/lib/icon/icon.d.ts +0 -1
  36. package/lib/listbox/listbox.d.ts +9 -1
  37. package/lib/text-field/text-field.d.ts +1 -0
  38. package/listbox/index.js +20 -16
  39. package/locales/en-GB.js +48 -14
  40. package/locales/en-US.js +48 -14
  41. package/locales/ja-JP.js +48 -14
  42. package/locales/zh-CN.js +48 -14
  43. package/menu/index.js +8 -8
  44. package/menu-item/index.js +4 -4
  45. package/nav/index.js +1 -1
  46. package/nav-disclosure/index.js +3 -3
  47. package/nav-item/index.js +3 -3
  48. package/note/index.js +2 -3
  49. package/number-field/index.js +6 -6
  50. package/option/index.js +3 -3
  51. package/package.json +2 -16
  52. package/pagination/index.js +5 -5
  53. package/popup/index.js +6 -6
  54. package/progress/index.js +1 -1
  55. package/progress-ring/index.js +1 -1
  56. package/radio/index.js +2 -2
  57. package/radio-group/index.js +1 -1
  58. package/select/index.js +8 -8
  59. package/shared/affix.js +25 -9
  60. package/shared/apply-mixins.js +1 -1
  61. package/shared/breadcrumb-item.js +5 -5
  62. package/shared/button.js +13 -13
  63. package/shared/calendar-event.js +36 -16
  64. package/shared/definition.js +133 -194
  65. package/shared/definition10.js +225 -40
  66. package/shared/definition11.js +36 -32
  67. package/shared/definition12.js +763 -98
  68. package/shared/definition13.js +125 -89
  69. package/shared/definition14.js +207 -27
  70. package/shared/definition15.js +710 -731
  71. package/shared/definition16.js +1289 -47
  72. package/shared/definition17.js +6113 -93
  73. package/shared/definition18.js +242 -164
  74. package/shared/definition19.js +47 -692
  75. package/shared/definition2.js +199 -117
  76. package/shared/definition20.js +59 -1671
  77. package/shared/definition21.js +95 -255
  78. package/shared/definition22.js +2218 -1167
  79. package/shared/definition23.js +61 -5784
  80. package/shared/definition24.js +28 -117
  81. package/shared/definition25.js +52 -66
  82. package/shared/definition26.js +391 -214
  83. package/shared/definition27.js +441 -34
  84. package/shared/definition28.js +85 -73
  85. package/shared/definition29.js +21 -2283
  86. package/shared/definition3.js +61 -24
  87. package/shared/definition30.js +13 -49
  88. package/shared/definition31.js +54 -39
  89. package/shared/definition32.js +413 -375
  90. package/shared/definition33.js +223 -304
  91. package/shared/definition34.js +197 -13
  92. package/shared/definition35.js +88 -73
  93. package/shared/definition36.js +75 -25
  94. package/shared/definition37.js +434 -34
  95. package/shared/definition38.js +32 -432
  96. package/shared/definition39.js +677 -187
  97. package/shared/definition4.js +157 -12
  98. package/shared/definition40.js +95 -48
  99. package/shared/definition41.js +577 -31
  100. package/shared/definition42.js +126 -424
  101. package/shared/definition43.js +114 -618
  102. package/shared/definition44.js +24 -80
  103. package/shared/definition45.js +71 -543
  104. package/shared/definition46.js +499 -92
  105. package/shared/definition47.js +19 -133
  106. package/shared/definition48.js +129 -52
  107. package/shared/definition49.js +281 -17
  108. package/shared/definition5.js +71 -36
  109. package/shared/definition50.js +153 -484
  110. package/shared/definition51.js +131 -98
  111. package/shared/definition52.js +131 -16
  112. package/shared/definition53.js +80 -264
  113. package/shared/definition54.js +293 -118
  114. package/shared/definition55.js +12 -117
  115. package/shared/definition56.js +39 -68
  116. package/shared/definition57.js +166 -288
  117. package/shared/definition6.js +56 -111
  118. package/shared/definition7.js +120 -195
  119. package/shared/definition8.js +58 -23
  120. package/shared/definition9.js +92 -66
  121. package/shared/focus.js +2 -1
  122. package/shared/focus2.js +1 -1
  123. package/shared/form-associated.js +2 -2
  124. package/shared/icon.js +48 -27
  125. package/shared/index.js +7 -27
  126. package/shared/index2.js +108 -80
  127. package/shared/key-codes.js +1 -1
  128. package/shared/listbox.js +88 -11
  129. package/shared/patterns/form-elements/form-elements.d.ts +4 -4
  130. package/shared/radio.js +23 -7
  131. package/shared/repeat.js +1 -1
  132. package/shared/text-anchor.js +21 -4
  133. package/shared/text-anchor.template.js +37 -40
  134. package/shared/text-field.js +2 -2
  135. package/shared/text-field2.js +15 -15
  136. package/shared/tree-item.js +12 -12
  137. package/side-drawer/index.js +1 -1
  138. package/slider/index.js +2 -2
  139. package/split-button/index.js +3 -3
  140. package/style.css +6097 -0
  141. package/styles/core/all.css +1 -1
  142. package/styles/core/theme.css +1 -1
  143. package/styles/core/typography.css +1 -1
  144. package/styles/tokens/theme-dark.css +4 -4
  145. package/styles/tokens/theme-light.css +4 -4
  146. package/styles/tokens/vivid-2-compat.css +1 -1
  147. package/switch/index.js +3 -3
  148. package/tab/index.js +3 -3
  149. package/tab-panel/index.js +1 -1
  150. package/tabs/index.js +5 -5
  151. package/tag/index.js +3 -3
  152. package/tag-group/index.js +1 -1
  153. package/text-anchor/index.js +1 -1
  154. package/text-area/index.js +3 -3
  155. package/text-field/index.js +3 -3
  156. package/toggletip/index.js +7 -7
  157. package/tooltip/index.js +7 -7
  158. package/tree-item/index.js +3 -3
  159. package/tree-view/index.js +1 -1
  160. package/lib/accordion/index.d.ts +0 -1
  161. package/lib/accordion-item/index.d.ts +0 -1
  162. package/lib/action-group/index.d.ts +0 -1
  163. package/lib/alert/index.d.ts +0 -1
  164. package/lib/avatar/index.d.ts +0 -1
  165. package/lib/badge/index.d.ts +0 -1
  166. package/lib/banner/index.d.ts +0 -1
  167. package/lib/breadcrumb/index.d.ts +0 -1
  168. package/lib/breadcrumb-item/index.d.ts +0 -1
  169. package/lib/button/index.d.ts +0 -1
  170. package/lib/calendar/index.d.ts +0 -1
  171. package/lib/calendar-event/index.d.ts +0 -1
  172. package/lib/card/index.d.ts +0 -1
  173. package/lib/checkbox/index.d.ts +0 -1
  174. package/lib/combobox/index.d.ts +0 -1
  175. package/lib/data-grid/index.d.ts +0 -1
  176. package/lib/date-picker/index.d.ts +0 -1
  177. package/lib/dialog/index.d.ts +0 -1
  178. package/lib/divider/index.d.ts +0 -1
  179. package/lib/elevation/index.d.ts +0 -1
  180. package/lib/empty-state/index.d.ts +0 -1
  181. package/lib/fab/index.d.ts +0 -1
  182. package/lib/file-picker/index.d.ts +0 -1
  183. package/lib/focus/index.d.ts +0 -1
  184. package/lib/header/index.d.ts +0 -1
  185. package/lib/icon/index.d.ts +0 -1
  186. package/lib/layout/index.d.ts +0 -1
  187. package/lib/listbox/index.d.ts +0 -1
  188. package/lib/menu/index.d.ts +0 -1
  189. package/lib/menu-item/index.d.ts +0 -1
  190. package/lib/nav/index.d.ts +0 -1
  191. package/lib/nav-disclosure/index.d.ts +0 -1
  192. package/lib/nav-item/index.d.ts +0 -1
  193. package/lib/note/index.d.ts +0 -1
  194. package/lib/number-field/index.d.ts +0 -1
  195. package/lib/option/index.d.ts +0 -1
  196. package/lib/pagination/index.d.ts +0 -1
  197. package/lib/popup/index.d.ts +0 -1
  198. package/lib/progress/index.d.ts +0 -1
  199. package/lib/progress-ring/index.d.ts +0 -1
  200. package/lib/radio/index.d.ts +0 -1
  201. package/lib/radio-group/index.d.ts +0 -1
  202. package/lib/select/index.d.ts +0 -1
  203. package/lib/side-drawer/index.d.ts +0 -1
  204. package/lib/slider/index.d.ts +0 -1
  205. package/lib/split-button/index.d.ts +0 -1
  206. package/lib/switch/index.d.ts +0 -1
  207. package/lib/tab/index.d.ts +0 -1
  208. package/lib/tab-panel/index.d.ts +0 -1
  209. package/lib/tabs/index.d.ts +0 -1
  210. package/lib/tag/index.d.ts +0 -1
  211. package/lib/tag-group/index.d.ts +0 -1
  212. package/lib/text-anchor/index.d.ts +0 -1
  213. package/lib/text-area/index.d.ts +0 -1
  214. package/lib/text-field/index.d.ts +0 -1
  215. package/lib/toggletip/index.d.ts +0 -1
  216. package/lib/tooltip/index.d.ts +0 -1
  217. package/lib/tree-item/index.d.ts +0 -1
  218. package/lib/tree-view/index.d.ts +0 -1
@@ -1,671 +1,167 @@
1
- import { D as DOM, O as Observable, _ as __decorate, a as attr, v as volatile, o as observable, b as __metadata, h as html, r as registerFactory } from './index.js';
2
- import { f as focusRegistries } from './definition4.js';
3
- import { P as Popup, p as popupRegistries } from './definition20.js';
4
- import { i as iconRegistries } from './definition3.js';
5
- import { L as ListboxOption, l as listboxOptionRegistries } from './definition21.js';
6
- import { A as AffixIconWithTrailing, a as affixIconTemplateFactory } from './affix.js';
7
- import './focus.js';
8
- import { e as errorText, f as formElements, F as FormElementSuccessText, a as FormElementHelperText, g as getFeedbackTemplate } from './index2.js';
9
- import { b as ListboxElement, L as Listbox, D as DelegatesARIAListbox, a as Listbox$1 } from './listbox.js';
10
- import { S as StartEnd } from './start-end.js';
11
- import { a as applyMixins } from './apply-mixins.js';
12
- import { F as FormAssociated } from './form-associated.js';
13
- import { S as SelectPosition } from './select.options.js';
14
- import { u as uniqueId } from './strings.js';
15
- import { g as keyTab, f as keyEscape, d as keyEnter, k as keyEnd, a as keyHome, e as keySpace, b as keyArrowDown, c as keyArrowUp } from './key-codes.js';
1
+ import { F as FoundationElement, _ as __decorate, a as attr, o as observable, h as html, r as registerFactory } from './index.js';
2
+ import { a as iconRegistries } from './definition24.js';
3
+ import { f as focusRegistries } from './definition55.js';
4
+ import { C as CheckableFormAssociated } from './form-associated.js';
5
+ import { a as keySpace, k as keyEnter } from './key-codes.js';
6
+ import './affix.js';
16
7
  import { f as focusTemplateFactory } from './focus2.js';
8
+ import './index2.js';
17
9
  import { w as when } from './when.js';
18
- import { r as ref } from './ref.js';
19
- import { s as slotted } from './slotted.js';
20
10
  import { c as classNames } from './class-names.js';
21
11
 
22
- class _Select extends ListboxElement {
12
+ class _Switch extends FoundationElement {
23
13
  }
24
14
  /**
25
- * A form-associated base class for the {@link @microsoft/fast-foundation#(Select:class)} component.
15
+ * A form-associated base class for the {@link @microsoft/fast-foundation#(Switch:class)} component.
26
16
  *
27
17
  * @internal
28
18
  */
29
- class FormAssociatedSelect extends FormAssociated(_Select) {
19
+ class FormAssociatedSwitch extends CheckableFormAssociated(_Switch) {
30
20
  constructor() {
31
21
  super(...arguments);
32
- this.proxy = document.createElement("select");
22
+ this.proxy = document.createElement("input");
33
23
  }
34
24
  }
35
25
 
36
26
  /**
37
- * A Select Custom HTML Element.
38
- * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#select | ARIA select }.
27
+ * A Switch Custom HTML Element.
28
+ * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#switch | ARIA switch }.
39
29
  *
40
- * @slot start - Content which can be provided before the button content
41
- * @slot end - Content which can be provided after the button content
42
- * @slot button-container - The element representing the select button
43
- * @slot selected-value - The selected value
44
- * @slot indicator - The visual indicator for the expand/collapse state of the button
45
- * @slot - The default slot for slotted options
46
- * @csspart control - The element representing the select invoking element
47
- * @csspart selected-value - The element wrapping the selected value
48
- * @csspart indicator - The element wrapping the visual indicator
49
- * @csspart listbox - The listbox element
50
- * @fires input - Fires a custom 'input' event when the value updates
51
- * @fires change - Fires a custom 'change' event when the value updates
30
+ * @slot - The deafult slot for the label
31
+ * @slot checked-message - The message when in a checked state
32
+ * @slot unchecked-message - The message when in an unchecked state
33
+ * @csspart label - The label
34
+ * @csspart switch - The element representing the switch, which wraps the indicator
35
+ * @csspart status-message - The wrapper for the status messages
36
+ * @csspart checked-message - The checked message
37
+ * @csspart unchecked-message - The unchecked message
38
+ * @fires change - Emits a custom change event when the checked state changes
52
39
  *
53
40
  * @public
54
41
  */
55
- class Select$1 extends FormAssociatedSelect {
42
+ let Switch$1 = class Switch extends FormAssociatedSwitch {
56
43
  constructor() {
57
- super(...arguments);
58
- /**
59
- * The open attribute.
60
- *
61
- * @public
62
- * @remarks
63
- * HTML Attribute: open
64
- */
65
- this.open = false;
66
- /**
67
- * Indicates the initial state of the position attribute.
68
- *
69
- * @internal
70
- */
71
- this.forcedPosition = false;
44
+ super();
72
45
  /**
73
- * The unique id for the internal listbox element.
46
+ * The element's value to be included in form submission when checked.
47
+ * Default to "on" to reach parity with input[type="checkbox"]
74
48
  *
75
49
  * @internal
76
50
  */
77
- this.listboxId = uniqueId("listbox-");
51
+ this.initialValue = "on";
78
52
  /**
79
- * The max height for the listbox when opened.
80
- *
81
53
  * @internal
82
54
  */
83
- this.maxHeight = 0;
84
- }
85
- /**
86
- * Sets focus and synchronizes ARIA attributes when the open property changes.
87
- *
88
- * @param prev - the previous open value
89
- * @param next - the current open value
90
- *
91
- * @internal
92
- */
93
- openChanged(prev, next) {
94
- if (!this.collapsible) {
95
- return;
96
- }
97
- if (this.open) {
98
- this.ariaControls = this.listboxId;
99
- this.ariaExpanded = "true";
100
- this.setPositioning();
101
- this.focusAndScrollOptionIntoView();
102
- this.indexWhenOpened = this.selectedIndex;
103
- // focus is directed to the element when `open` is changed programmatically
104
- DOM.queueUpdate(() => this.focus());
105
- return;
106
- }
107
- this.ariaControls = "";
108
- this.ariaExpanded = "false";
109
- }
110
- /**
111
- * The component is collapsible when in single-selection mode with no size attribute.
112
- *
113
- * @internal
114
- */
115
- get collapsible() {
116
- return !(this.multiple || typeof this.size === "number");
117
- }
118
- /**
119
- * The value property.
120
- *
121
- * @public
122
- */
123
- get value() {
124
- Observable.track(this, "value");
125
- return this._value;
126
- }
127
- set value(next) {
128
- var _a, _b, _c, _d, _e, _f, _g;
129
- const prev = `${this._value}`;
130
- if ((_a = this._options) === null || _a === void 0 ? void 0 : _a.length) {
131
- const selectedIndex = this._options.findIndex(el => el.value === next);
132
- const prevSelectedValue = (_c = (_b = this._options[this.selectedIndex]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : null;
133
- const nextSelectedValue = (_e = (_d = this._options[selectedIndex]) === null || _d === void 0 ? void 0 : _d.value) !== null && _e !== void 0 ? _e : null;
134
- if (selectedIndex === -1 || prevSelectedValue !== nextSelectedValue) {
135
- next = "";
136
- this.selectedIndex = selectedIndex;
137
- }
138
- next = (_g = (_f = this.firstSelectedOption) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : next;
139
- }
140
- if (prev !== next) {
141
- this._value = next;
142
- super.valueChanged(prev, next);
143
- Observable.notify(this, "value");
144
- this.updateDisplayValue();
145
- }
146
- }
147
- /**
148
- * Sets the value and display value to match the first selected option.
149
- *
150
- * @param shouldEmit - if true, the input and change events will be emitted
151
- *
152
- * @internal
153
- */
154
- updateValue(shouldEmit) {
155
- var _a, _b;
156
- if (this.$fastController.isConnected) {
157
- this.value = (_b = (_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "";
158
- }
159
- if (shouldEmit) {
160
- this.$emit("input");
161
- this.$emit("change", this, {
162
- bubbles: true,
163
- composed: undefined,
164
- });
165
- }
166
- }
167
- /**
168
- * Updates the proxy value when the selected index changes.
169
- *
170
- * @param prev - the previous selected index
171
- * @param next - the next selected index
172
- *
173
- * @internal
174
- */
175
- selectedIndexChanged(prev, next) {
176
- super.selectedIndexChanged(prev, next);
177
- this.updateValue();
178
- }
179
- positionChanged(prev, next) {
180
- this.positionAttribute = next;
181
- this.setPositioning();
182
- }
183
- /**
184
- * Calculate and apply listbox positioning based on available viewport space.
185
- *
186
- * @public
187
- */
188
- setPositioning() {
189
- const currentBox = this.getBoundingClientRect();
190
- const viewportHeight = window.innerHeight;
191
- const availableBottom = viewportHeight - currentBox.bottom;
192
- this.position = this.forcedPosition
193
- ? this.positionAttribute
194
- : currentBox.top > availableBottom
195
- ? SelectPosition.above
196
- : SelectPosition.below;
197
- this.positionAttribute = this.forcedPosition
198
- ? this.positionAttribute
199
- : this.position;
200
- this.maxHeight =
201
- this.position === SelectPosition.above ? ~~currentBox.top : ~~availableBottom;
202
- }
203
- /**
204
- * The value displayed on the button.
205
- *
206
- * @public
207
- */
208
- get displayValue() {
209
- var _a, _b;
210
- Observable.track(this, "displayValue");
211
- return (_b = (_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : "";
212
- }
213
- /**
214
- * Synchronize the `aria-disabled` property when the `disabled` property changes.
215
- *
216
- * @param prev - The previous disabled value
217
- * @param next - The next disabled value
218
- *
219
- * @internal
220
- */
221
- disabledChanged(prev, next) {
222
- if (super.disabledChanged) {
223
- super.disabledChanged(prev, next);
224
- }
225
- this.ariaDisabled = this.disabled ? "true" : "false";
226
- }
227
- /**
228
- * Reset the element to its first selectable option when its parent form is reset.
229
- *
230
- * @internal
231
- */
232
- formResetCallback() {
233
- this.setProxyOptions();
234
- // Call the base class's implementation setDefaultSelectedOption instead of the select's
235
- // override, in order to reset the selectedIndex without using the value property.
236
- super.setDefaultSelectedOption();
237
- if (this.selectedIndex === -1) {
238
- this.selectedIndex = 0;
239
- }
240
- }
241
- /**
242
- * Handle opening and closing the listbox when the select is clicked.
243
- *
244
- * @param e - the mouse event
245
- * @internal
246
- */
247
- clickHandler(e) {
248
- // do nothing if the select is disabled
249
- if (this.disabled) {
250
- return;
251
- }
252
- if (this.open) {
253
- const captured = e.target.closest(`option,[role=option]`);
254
- if (captured && captured.disabled) {
55
+ this.keypressHandler = (e) => {
56
+ if (this.readOnly) {
255
57
  return;
256
58
  }
257
- }
258
- super.clickHandler(e);
259
- this.open = this.collapsible && !this.open;
260
- if (!this.open && this.indexWhenOpened !== this.selectedIndex) {
261
- this.updateValue(true);
262
- }
263
- return true;
264
- }
265
- /**
266
- * Handles focus state when the element or its children lose focus.
267
- *
268
- * @param e - The focus event
269
- * @internal
270
- */
271
- focusoutHandler(e) {
272
- var _a;
273
- super.focusoutHandler(e);
274
- if (!this.open) {
275
- return true;
276
- }
277
- const focusTarget = e.relatedTarget;
278
- if (this.isSameNode(focusTarget)) {
279
- this.focus();
280
- return;
281
- }
282
- if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.includes(focusTarget))) {
283
- this.open = false;
284
- if (this.indexWhenOpened !== this.selectedIndex) {
285
- this.updateValue(true);
59
+ switch (e.key) {
60
+ case keyEnter:
61
+ case keySpace:
62
+ this.checked = !this.checked;
63
+ break;
286
64
  }
287
- }
288
- }
289
- /**
290
- * Updates the value when an option's value changes.
291
- *
292
- * @param source - the source object
293
- * @param propertyName - the property to evaluate
294
- *
295
- * @internal
296
- * @override
297
- */
298
- handleChange(source, propertyName) {
299
- super.handleChange(source, propertyName);
300
- if (propertyName === "value") {
301
- this.updateValue();
302
- }
303
- }
304
- /**
305
- * Synchronize the form-associated proxy and updates the value property of the element.
306
- *
307
- * @param prev - the previous collection of slotted option elements
308
- * @param next - the next collection of slotted option elements
309
- *
310
- * @internal
311
- */
312
- slottedOptionsChanged(prev, next) {
313
- this.options.forEach(o => {
314
- const notifier = Observable.getNotifier(o);
315
- notifier.unsubscribe(this, "value");
316
- });
317
- super.slottedOptionsChanged(prev, next);
318
- this.options.forEach(o => {
319
- const notifier = Observable.getNotifier(o);
320
- notifier.subscribe(this, "value");
321
- });
322
- this.setProxyOptions();
323
- this.updateValue();
324
- }
325
- /**
326
- * Prevents focus when size is set and a scrollbar is clicked.
327
- *
328
- * @param e - the mouse event object
329
- *
330
- * @override
331
- * @internal
332
- */
333
- mousedownHandler(e) {
334
- var _a;
335
- if (e.offsetX >= 0 && e.offsetX <= ((_a = this.listbox) === null || _a === void 0 ? void 0 : _a.scrollWidth)) {
336
- return super.mousedownHandler(e);
337
- }
338
- return this.collapsible;
339
- }
340
- /**
341
- * Sets the multiple property on the proxy element.
342
- *
343
- * @param prev - the previous multiple value
344
- * @param next - the current multiple value
345
- */
346
- multipleChanged(prev, next) {
347
- super.multipleChanged(prev, next);
348
- if (this.proxy) {
349
- this.proxy.multiple = next;
350
- }
351
- }
352
- /**
353
- * Updates the selectedness of each option when the list of selected options changes.
354
- *
355
- * @param prev - the previous list of selected options
356
- * @param next - the current list of selected options
357
- *
358
- * @override
359
- * @internal
360
- */
361
- selectedOptionsChanged(prev, next) {
362
- var _a;
363
- super.selectedOptionsChanged(prev, next);
364
- (_a = this.options) === null || _a === void 0 ? void 0 : _a.forEach((o, i) => {
365
- var _a;
366
- const proxyOption = (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.options.item(i);
367
- if (proxyOption) {
368
- proxyOption.selected = o.selected;
65
+ };
66
+ /**
67
+ * @internal
68
+ */
69
+ this.clickHandler = (e) => {
70
+ if (!this.disabled && !this.readOnly) {
71
+ this.checked = !this.checked;
369
72
  }
370
- });
73
+ };
74
+ this.proxy.setAttribute("type", "checkbox");
371
75
  }
372
- /**
373
- * Sets the selected index to match the first option with the selected attribute, or
374
- * the first selectable option.
375
- *
376
- * @override
377
- * @internal
378
- */
379
- setDefaultSelectedOption() {
380
- var _a;
381
- const options = (_a = this.options) !== null && _a !== void 0 ? _a : Array.from(this.children).filter(Listbox.slottedOptionFilter);
382
- const selectedIndex = options === null || options === void 0 ? void 0 : options.findIndex(el => el.hasAttribute("selected") || el.selected || el.value === this.value);
383
- if (selectedIndex !== -1) {
384
- this.selectedIndex = selectedIndex;
385
- return;
76
+ readOnlyChanged() {
77
+ if (this.proxy instanceof HTMLInputElement) {
78
+ this.proxy.readOnly = this.readOnly;
386
79
  }
387
- this.selectedIndex = 0;
80
+ this.readOnly
81
+ ? this.classList.add("readonly")
82
+ : this.classList.remove("readonly");
388
83
  }
389
84
  /**
390
- * Resets and fills the proxy to match the component's options.
391
- *
392
85
  * @internal
393
86
  */
394
- setProxyOptions() {
395
- if (this.proxy instanceof HTMLSelectElement && this.options) {
396
- this.proxy.options.length = 0;
397
- this.options.forEach(option => {
398
- const proxyOption = option.proxy ||
399
- (option instanceof HTMLOptionElement ? option.cloneNode() : null);
400
- if (proxyOption) {
401
- this.proxy.options.add(proxyOption);
402
- }
403
- });
404
- }
405
- }
406
- /**
407
- * Handle keyboard interaction for the select.
408
- *
409
- * @param e - the keyboard event
410
- * @internal
411
- */
412
- keydownHandler(e) {
413
- super.keydownHandler(e);
414
- const key = e.key || e.key.charCodeAt(0);
415
- switch (key) {
416
- case keySpace: {
417
- e.preventDefault();
418
- if (this.collapsible && this.typeAheadExpired) {
419
- this.open = !this.open;
420
- }
421
- break;
422
- }
423
- case keyHome:
424
- case keyEnd: {
425
- e.preventDefault();
426
- break;
427
- }
428
- case keyEnter: {
429
- e.preventDefault();
430
- this.open = !this.open;
431
- break;
432
- }
433
- case keyEscape: {
434
- if (this.collapsible && this.open) {
435
- e.preventDefault();
436
- this.open = false;
437
- }
438
- break;
439
- }
440
- case keyTab: {
441
- if (this.collapsible && this.open) {
442
- e.preventDefault();
443
- this.open = false;
444
- }
445
- return true;
446
- }
447
- }
448
- if (!this.open && this.indexWhenOpened !== this.selectedIndex) {
449
- this.updateValue(true);
450
- this.indexWhenOpened = this.selectedIndex;
451
- }
452
- return !(key === keyArrowDown || key === keyArrowUp);
453
- }
454
- connectedCallback() {
455
- super.connectedCallback();
456
- this.forcedPosition = !!this.positionAttribute;
457
- this.addEventListener("contentchange", this.updateDisplayValue);
458
- }
459
- disconnectedCallback() {
460
- this.removeEventListener("contentchange", this.updateDisplayValue);
461
- super.disconnectedCallback();
462
- }
463
- /**
464
- * Updates the proxy's size property when the size attribute changes.
465
- *
466
- * @param prev - the previous size
467
- * @param next - the current size
468
- *
469
- * @override
470
- * @internal
471
- */
472
- sizeChanged(prev, next) {
473
- super.sizeChanged(prev, next);
474
- if (this.proxy) {
475
- this.proxy.size = next;
476
- }
477
- }
478
- /**
479
- *
480
- * @internal
481
- */
482
- updateDisplayValue() {
483
- if (this.collapsible) {
484
- Observable.notify(this, "displayValue");
485
- }
87
+ checkedChanged(prev, next) {
88
+ super.checkedChanged(prev, next);
89
+ /**
90
+ * @deprecated - this behavior already exists in the template and should not exist in the class.
91
+ */
92
+ this.checked ? this.classList.add("checked") : this.classList.remove("checked");
486
93
  }
487
- }
488
- __decorate([
489
- attr({ attribute: "open", mode: "boolean" })
490
- ], Select$1.prototype, "open", void 0);
491
- __decorate([
492
- volatile
493
- ], Select$1.prototype, "collapsible", null);
494
- __decorate([
495
- observable
496
- ], Select$1.prototype, "control", void 0);
497
- __decorate([
498
- attr({ attribute: "position" })
499
- ], Select$1.prototype, "positionAttribute", void 0);
500
- __decorate([
501
- observable
502
- ], Select$1.prototype, "position", void 0);
94
+ };
503
95
  __decorate([
504
- observable
505
- ], Select$1.prototype, "maxHeight", void 0);
506
- /**
507
- * Includes ARIA states and properties relating to the ARIA select role.
508
- *
509
- * @public
510
- */
511
- class DelegatesARIASelect {
512
- }
96
+ attr({ attribute: "readonly", mode: "boolean" })
97
+ ], Switch$1.prototype, "readOnly", void 0);
513
98
  __decorate([
514
99
  observable
515
- ], DelegatesARIASelect.prototype, "ariaControls", void 0);
516
- applyMixins(DelegatesARIASelect, DelegatesARIAListbox);
517
- applyMixins(Select$1, StartEnd, DelegatesARIASelect);
100
+ ], Switch$1.prototype, "defaultSlottedNodes", void 0);
518
101
 
519
- var css_248z = "/**\n * Do not edit directly\n * Generated on Tue, 22 Aug 2023 13:37:39 GMT\n */\n@supports selector(:focus-visible) {\n :host(:focus-visible) {\n outline: none;\n }\n}\n:host {\n display: inline-flex;\n flex-direction: column;\n gap: 4px;\n --_low-ink-color: var(--vvd-color-neutral-600);\n}\n\n:host([disabled]) {\n --_low-ink-color: var(--vvd-color-neutral-400);\n}\n\n.label {\n color: var(--vvd-color-canvas-text);\n contain: inline-size;\n font: var(--vvd-typography-base);\n}\n\n.control {\n display: flex;\n align-items: center;\n justify-content: space-between;\n background-color: var(--_appearance-color-fill);\n block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2)));\n border-radius: var(--_select-control-border-radius);\n box-shadow: inset 0 0 0 1px var(--_appearance-color-outline);\n color: var(--_appearance-color-text);\n font: var(--vvd-typography-base);\n gap: 8px;\n padding-inline: 16px;\n transition: box-shadow 0.2s, background-color 0.2s;\n}\n.control {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--_connotation-color-backdrop);\n --_appearance-color-outline: var(--_connotation-color-intermediate);\n}\n.control.appearance-ghost {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.control:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--_connotation-color-backdrop);\n --_appearance-color-outline: var(--_connotation-color-firm);\n}\n.control:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)).appearance-ghost {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-faint);\n --_appearance-color-outline: transparent;\n}\n.control:where(:disabled, .disabled) {\n --_appearance-color-text: var(--vvd-color-neutral-300);\n --_appearance-color-fill: var(--vvd-color-neutral-100);\n --_appearance-color-outline: var(--vvd-color-neutral-300);\n}\n.control:where(:disabled, .disabled).appearance-ghost {\n --_appearance-color-text: var(--vvd-color-neutral-300);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.control:where(.readonly):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--vvd-color-neutral-200);\n --_appearance-color-outline: var(--vvd-color-neutral-400);\n}\n.control:where(.readonly):where(:not(:disabled, .disabled)).appearance-ghost {\n --_appearance-color-text: var(--vvd-color-neutral-600);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.control.connotation-success {\n /* @cssprop [--vvd-select-success-primary=var(--vvd-color-success-500)] */\n --_connotation-color-primary: var(--vvd-select-success-primary, var(--vvd-color-success-500));\n /* @cssprop [--vvd-select-success-backdrop=var(--vvd-color-success-50)] */\n --_connotation-color-backdrop: var(--vvd-select-success-backdrop, var(--vvd-color-success-50));\n /* @cssprop [--vvd-select-success-intermediate=var(--vvd-color-success-500)] */\n --_connotation-color-intermediate: var(--vvd-select-success-intermediate, var(--vvd-color-success-500));\n /* @cssprop [--vvd-select-success-firm=var(--vvd-color-success-600)] */\n --_connotation-color-firm: var(--vvd-select-success-firm, var(--vvd-color-success-600));\n}\n.control.connotation-alert {\n /* @cssprop [--vvd-select-alert-primary=var(--vvd-color-alert-500)] */\n --_connotation-color-primary: var(--vvd-select-alert-primary, var(--vvd-color-alert-500));\n /* @cssprop [--vvd-select-alert-backdrop=var(--vvd-color-alert-50)] */\n --_connotation-color-backdrop: var(--vvd-select-alert-backdrop, var(--vvd-color-alert-50));\n /* @cssprop [--vvd-select-alert-intermediate=var(--vvd-color-alert-500)] */\n --_connotation-color-intermediate: var(--vvd-select-alert-intermediate, var(--vvd-color-alert-500));\n /* @cssprop [--vvd-select-alert-firm=var(--vvd-color-alert-600)] */\n --_connotation-color-firm: var(--vvd-select-alert-firm, var(--vvd-color-alert-600));\n}\n.control:not(.connotation-success, .connotation-alert) {\n /* @cssprop [--vvd-select-accent-primary=var(--vvd-color-canvas-text)] */\n --_connotation-color-primary: var(--vvd-select-accent-primary, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-select-accent-backdrop=var(--vvd-color-canvas)] */\n --_connotation-color-backdrop: var(--vvd-select-accent-backdrop, var(--vvd-color-canvas));\n /* @cssprop [--vvd-select-accent-intermediate=var(--vvd-color-neutral-500)] */\n --_connotation-color-intermediate: var(--vvd-select-accent-intermediate, var(--vvd-color-neutral-500));\n /* @cssprop [--vvd-select-accent-firm=var(--vvd-color-canvas-text)] */\n --_connotation-color-firm: var(--vvd-select-accent-firm, var(--vvd-color-canvas-text));\n}\n.control-wrapper {\n position: relative;\n}\n.control:not(.disabled) {\n cursor: pointer;\n}\n.control.disabled {\n cursor: not-allowed;\n pointer-events: none;\n}\n.control:not(.shape-pill) {\n --_select-control-border-radius: 6px;\n}\n.control.shape-pill {\n --_select-control-border-radius: 24px;\n}\n\n.listbox {\n display: flex;\n max-height: var(--select-height, 408px);\n flex-direction: column;\n padding: 4px;\n gap: 2px;\n overflow-y: auto;\n}\n\n.icon {\n display: flex;\n flex-shrink: 0;\n}\n\n.selected-value {\n display: flex;\n overflow: hidden;\n flex-grow: 1;\n align-items: center;\n column-gap: 12px;\n white-space: nowrap;\n}\n.selected-value .text {\n overflow: hidden;\n max-inline-size: 100%;\n text-overflow: ellipsis;\n}\n.selected-value slot[name=icon] {\n flex: 0 0 20px;\n font-size: 20px;\n line-height: 1;\n}\n.control.has-meta .selected-value {\n padding-inline-end: 8px;\n}\n\n::part(popup-base) {\n inline-size: max-content;\n min-inline-size: var(--_select-fixed-width, 100%);\n}\n:host([multiple]) ::part(popup-base) {\n position: static;\n}\n\n.focus-indicator {\n --focus-stroke-gap-color: transparent;\n border-radius: var(--_select-control-border-radius);\n pointer-events: none;\n}\n:host(:not(:focus-visible)) .focus-indicator {\n display: none;\n}\n:host([multiple]) .focus-indicator {\n --_select-control-border-radius: 6px;\n}";
102
+ const styles = "/**\n * Do not edit directly\n * Generated on Mon, 04 Sep 2023 12:44:18 GMT\n */\n.control {\n display: inline-flex;\n gap: 8px;\n}\n.control.connotation-cta {\n /* @cssprop [--vvd-switch-cta-primary-text=var(--vvd-color-canvas)] */\n --_connotation-color-primary-text: var(--vvd-switch-cta-primary-text, var(--vvd-color-canvas));\n /* @cssprop [--vvd-switch-cta-primary=var(--vvd-color-cta-500)] */\n --_connotation-color-primary: var(--vvd-switch-cta-primary, var(--vvd-color-cta-500));\n /* @cssprop [--vvd-switch-cta-primary-increment=var(--vvd-color-cta-600)] */\n --_connotation-color-primary-increment: var(--vvd-switch-cta-primary-increment, var(--vvd-color-cta-600));\n /* @cssprop [--vvd-switch-cta-backdrop=var(--vvd-color-cta-50)] */\n --_connotation-color-backdrop: var(--vvd-switch-cta-backdrop, var(--vvd-color-cta-50));\n /* @cssprop [--vvd-switch-cta-firm=var(--vvd-color-cta-600)] */\n --_connotation-color-firm: var(--vvd-switch-cta-firm, var(--vvd-color-cta-600));\n /* @cssprop [--vvd-switch-cta-intermediate=var(--vvd-color-cta-500)] */\n --_connotation-color-intermediate: var(--vvd-switch-cta-intermediate, var(--vvd-color-cta-500));\n}\n.control.connotation-alert {\n /* @cssprop [--vvd-switch-alert-primary-text=var(--vvd-color-canvas)] */\n --_connotation-color-primary-text: var(--vvd-switch-alert-primary-text, var(--vvd-color-canvas));\n /* @cssprop [--vvd-switch-alert-primary=var(--vvd-color-alert-500)] */\n --_connotation-color-primary: var(--vvd-switch-alert-primary, var(--vvd-color-alert-500));\n /* @cssprop [--vvd-switch-alert-primary-increment=var(--vvd-color-alert-600)] */\n --_connotation-color-primary-increment: var(--vvd-switch-alert-primary-increment, var(--vvd-color-alert-600));\n /* @cssprop [--vvd-switch-alert-backdrop=var(--vvd-color-alert-50)] */\n --_connotation-color-backdrop: var(--vvd-switch-alert-backdrop, var(--vvd-color-alert-50));\n /* @cssprop [--vvd-switch-alert-firm=var(--vvd-color-alert-600)] */\n --_connotation-color-firm: var(--vvd-switch-alert-firm, var(--vvd-color-alert-600));\n /* @cssprop [--vvd-switch-alert-intermediate=var(--vvd-color-alert-500)] */\n --_connotation-color-intermediate: var(--vvd-switch-alert-intermediate, var(--vvd-color-alert-500));\n}\n.control.connotation-success {\n /* @cssprop [--vvd-switch-success-primary-text=var(--vvd-color-canvas)] */\n --_connotation-color-primary-text: var(--vvd-switch-success-primary-text, var(--vvd-color-canvas));\n /* @cssprop [--vvd-switch-success-primary=var(--vvd-color-success-500)] */\n --_connotation-color-primary: var(--vvd-switch-success-primary, var(--vvd-color-success-500));\n /* @cssprop [--vvd-switch-success-primary-increment=var(--vvd-color-success-600)] */\n --_connotation-color-primary-increment: var(--vvd-switch-success-primary-increment, var(--vvd-color-success-600));\n /* @cssprop [--vvd-switch-success-backdrop=var(--vvd-color-success-50)] */\n --_connotation-color-backdrop: var(--vvd-switch-success-backdrop, var(--vvd-color-success-50));\n /* @cssprop [--vvd-switch-success-firm=var(--vvd-color-success-600)] */\n --_connotation-color-firm: var(--vvd-switch-success-firm, var(--vvd-color-success-600));\n /* @cssprop [--vvd-switch-success-intermediate=var(--vvd-color-success-500)] */\n --_connotation-color-intermediate: var(--vvd-switch-success-intermediate, var(--vvd-color-success-500));\n}\n.control:not(.connotation-cta, .connotation-alert, .connotation-success) {\n /* @cssprop [--vvd-switch-accent-primary-text=var(--vvd-color-canvas)] */\n --_connotation-color-primary-text: var(--vvd-switch-accent-primary-text, var(--vvd-color-canvas));\n /* @cssprop [--vvd-switch-accent-primary=var(--vvd-color-canvas-text)] */\n --_connotation-color-primary: var(--vvd-switch-accent-primary, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-switch-accent-primary-increment=var(--vvd-color-neutral-800)] */\n --_connotation-color-primary-increment: var(--vvd-switch-accent-primary-increment, var(--vvd-color-neutral-800));\n /* @cssprop [--vvd-switch-accent-backdrop=var(--vvd-color-canvas)] */\n --_connotation-color-backdrop: var(--vvd-switch-accent-backdrop, var(--vvd-color-canvas));\n /* @cssprop [--vvd-switch-accent-firm=var(--vvd-color-canvas-text)] */\n --_connotation-color-firm: var(--vvd-switch-accent-firm, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-switch-accent-intermediate=var(--vvd-color-neutral-500)] */\n --_connotation-color-intermediate: var(--vvd-switch-accent-intermediate, var(--vvd-color-neutral-500));\n}\n.control {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--_connotation-color-backdrop);\n --_appearance-color-outline: var(--_connotation-color-intermediate);\n}\n.control.appearance-filled {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary);\n --_appearance-color-outline: transparent;\n}\n.control:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--_connotation-color-backdrop);\n --_appearance-color-outline: var(--_connotation-color-firm);\n}\n.control:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)).appearance-filled {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary-increment);\n --_appearance-color-outline: transparent;\n}\n.control:where(:disabled, .disabled) {\n --_appearance-color-text: var(--vvd-color-neutral-300);\n --_appearance-color-fill: var(--vvd-color-neutral-100);\n --_appearance-color-outline: var(--vvd-color-neutral-300);\n}\n.control:where(:disabled, .disabled).appearance-filled {\n --_appearance-color-text: var(--vvd-color-neutral-300);\n --_appearance-color-fill: var(--vvd-color-neutral-100);\n --_appearance-color-outline: transparent;\n}\n.control:where(.readonly):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--vvd-color-neutral-200);\n --_appearance-color-outline: var(--vvd-color-neutral-400);\n}\n.control:where(.readonly):where(:not(:disabled, .disabled)).appearance-filled {\n --_appearance-color-text: var(--vvd-color-neutral-800);\n --_appearance-color-fill: var(--vvd-color-neutral-200);\n --_appearance-color-outline: transparent;\n}\n@supports selector(:focus-visible) {\n .control:focus-visible {\n outline: none;\n }\n}\n@supports (user-select: none) {\n .control {\n user-select: none;\n }\n}\n.control:not(.disabled) {\n cursor: pointer;\n}\n.control.disabled {\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.switch {\n --_switch-inline-size: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20)) * 1.8);\n position: relative;\n display: flex;\n box-sizing: border-box;\n align-items: center;\n background-color: var(--_appearance-color-fill);\n block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20));\n border-radius: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20)) / .5);\n box-shadow: inset 0 0 0 1px var(--_appearance-color-outline);\n inline-size: var(--_switch-inline-size);\n transition: all 0.2s ease-in-out 0s;\n}\n\n.checked-indicator {\n --_switch-checked-indicator-size: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20)) / 1.6667);\n --_switch-gutter: calc(var(--_switch-checked-indicator-size) / 3);\n block-size: var(--_switch-checked-indicator-size);\n border-radius: inherit;\n inline-size: var(--_switch-checked-indicator-size);\n margin-inline-start: auto;\n transition: all 0.2s ease-in-out 0s;\n}\n.control.appearance-filled .checked-indicator {\n background-color: var(--vvd-color-neutral-100);\n}\n.control:not(.appearance-filled) .checked-indicator {\n background-color: var(--_appearance-color-outline);\n}\n.control:not(.checked) .checked-indicator {\n transform: translateX(calc(-1 * var(--_switch-inline-size) + var(--_switch-checked-indicator-size) + var(--_switch-gutter)));\n}\n.control.checked .checked-indicator {\n transform: translateX(calc(-1 * var(--_switch-gutter)));\n}\n\n.label {\n color: var(--vvd-color-canvas-text);\n cursor: pointer;\n font: var(--vvd-typography-base);\n}\n\n.focus-indicator {\n --focus-inset: -4px;\n --focus-stroke-gap-color: transparent;\n border-radius: 14px;\n}\n.control:not(:focus-visible) .focus-indicator {\n display: none;\n}";
520
103
 
521
- let Select = class Select extends Select$1 {
522
- constructor() {
523
- super(...arguments);
524
- this.fixedDropdown = false;
525
- this.placeholderOption = null;
526
- }
527
- connectedCallback() {
528
- super.connectedCallback();
529
- this._popup.anchor = this._anchor;
530
- }
531
- get displayValue() {
532
- var _a, _b, _c, _d, _e;
533
- Observable.track(this, 'displayValue');
534
- return (_e = (_d = (_b = (_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.getAttribute('label')) !== null && _b !== void 0 ? _b : (_c = this.firstSelectedOption) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : this.placeholder) !== null && _e !== void 0 ? _e : '';
535
- }
536
- setDefaultSelectedOption() {
537
- const options = Array.from(this.children).filter(Listbox$1.slottedOptionFilter);
538
- const selectedIndex = options.findIndex(el => el.hasAttribute('selected') || el.selected || el.value === this.value);
539
- if (selectedIndex === -1 && !this.placeholderOption) {
540
- this.selectedIndex = 0;
541
- return;
542
- }
543
- if (selectedIndex !== -1 || this.placeholder !== '') {
544
- this.selectedIndex = selectedIndex;
545
- return;
546
- }
547
- }
104
+ var __defProp = Object.defineProperty;
105
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
106
+ var __decorateClass = (decorators, target, key, kind) => {
107
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
108
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
109
+ if (decorator = decorators[i])
110
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
111
+ if (kind && result)
112
+ __defProp(target, key, result);
113
+ return result;
548
114
  };
549
- __decorate([attr, __metadata("design:type", String)], Select.prototype, "appearance", void 0);
550
- __decorate([attr, __metadata("design:type", String)], Select.prototype, "shape", void 0);
551
- __decorate([attr({
552
- mode: 'boolean',
553
- attribute: 'fixed-dropdown'
554
- }), __metadata("design:type", Object)], Select.prototype, "fixedDropdown", void 0);
555
- __decorate([attr, __metadata("design:type", Object)], Select.prototype, "placeholder", void 0);
556
- __decorate([observable, __metadata("design:type", Object)], Select.prototype, "placeholderOption", void 0);
557
- __decorate([observable, __metadata("design:type", Array)], Select.prototype, "metaSlottedContent", void 0);
558
- Select = __decorate([errorText, formElements], Select);
559
- applyMixins(Select, AffixIconWithTrailing, FormElementHelperText, FormElementSuccessText);
560
-
561
- const getStateClasses = ({
562
- shape,
563
- disabled,
564
- appearance,
565
- metaSlottedContent,
566
- errorValidationMessage,
567
- successText
568
- }) => classNames(['disabled', disabled], [`appearance-${appearance}`, Boolean(appearance)], [`shape-${shape}`, Boolean(shape)], ['has-meta', Boolean(metaSlottedContent === null || metaSlottedContent === void 0 ? void 0 : metaSlottedContent.length)], ['error connotation-alert', Boolean(errorValidationMessage)], ['success connotation-success', !!successText], ['has-meta', Boolean(metaSlottedContent === null || metaSlottedContent === void 0 ? void 0 : metaSlottedContent.length)]);
569
- function renderLabel() {
570
- return html`
571
- <label for="control" class="label">
572
- ${x => x.label}
573
- </label>`;
574
- }
575
- function renderPlaceholder(context) {
576
- const optionTag = context.tagFor(ListboxOption);
577
- return html`
578
- <${optionTag} ${ref('placeholderOption')}
579
- text="${x => x.placeholder}" hidden disabled>
580
- </${optionTag}>`;
115
+ class Switch extends Switch$1 {
581
116
  }
582
- function selectValue(context) {
583
- const affixIconTemplate = affixIconTemplateFactory(context, false);
584
- const focusTemplate = focusTemplateFactory(context);
585
- return html`
586
- <div class="control ${getStateClasses}" ${ref('_anchor')}
587
- id="control" ?disabled="${x => x.disabled}">
588
- <div class="selected-value">
589
- <slot name="icon">
590
- ${when(x => x.icon, html`${x => affixIconTemplate(x.icon)}`)}
591
- </slot>
592
- <span class="text">${x => x.displayValue}</span>
593
- <slot name="meta" ${slotted('metaSlottedContent')}></slot>
594
- </div>
595
- ${() => affixIconTemplate('chevron-down-line')}
596
- ${() => focusTemplate}
597
- </div>`;
598
- }
599
- function setFixedDropdownVarWidth(x) {
600
- return x.open && x.fixedDropdown ? `--_select-fixed-width: ${Math.round(x.getBoundingClientRect().width)}px` : null;
601
- }
602
- function renderControl(context) {
117
+ __decorateClass([
118
+ attr
119
+ ], Switch.prototype, "label", 2);
120
+ __decorateClass([
121
+ attr
122
+ ], Switch.prototype, "connotation", 2);
123
+
124
+ const getClasses = (_) => classNames(
125
+ "control",
126
+ ["appearance-filled", _.checked && !_.disabled && !_.readOnly],
127
+ ["checked", _.checked],
128
+ ["disabled", _.disabled],
129
+ ["readonly", _.readOnly],
130
+ [`connotation-${_.connotation}`, Boolean(_.checked) && Boolean(_.connotation)]
131
+ );
132
+ const SwitchTemplate = (context) => {
603
133
  const focusTemplate = focusTemplateFactory(context);
604
- const popupTag = context.tagFor(Popup);
605
134
  return html`
606
- ${when(x => x.label, renderLabel())}
607
- <div class="control-wrapper">
608
- ${when(x => !x.multiple, selectValue(context))}
609
- <${popupTag} class="popup" ${ref('_popup')}
610
- style="${setFixedDropdownVarWidth}"
611
- ?open="${x => x.collapsible ? x.open : true}"
612
- anchor="control"
613
- placement="bottom-start"
614
- strategy="${x => x.fixedDropdown ? null : 'absolute'}">
615
- <div class="listbox"
616
- id="${x => x.listboxId}"
617
- role="listbox"
618
- ?disabled="${x => x.disabled}"
619
- ?hidden="${x => x.collapsible ? !x.open : false}"
620
- ${ref('listbox')}>
621
- ${when(x => x.placeholder, renderPlaceholder(context))}
622
- ${when(x => x.multiple, focusTemplate)}
623
- <slot
624
- ${slotted({
625
- filter: Listbox$1.slottedOptionFilter,
626
- flatten: true,
627
- property: 'slottedOptions'
628
- })}>
629
- </slot>
630
- </div>
631
- </${popupTag}>
135
+ <div
136
+ class="${getClasses}"
137
+ role="switch"
138
+ aria-checked="${(x) => x.checked}"
139
+ aria-disabled="${(x) => x.disabled}"
140
+ aria-readonly="${(x) => x.readOnly}"
141
+ tabindex="${(x) => x.disabled ? null : 0}"
142
+ @keypress="${(x, c) => x.keypressHandler(c.event)}"
143
+ @click="${(x, c) => x.clickHandler(c.event)}"
144
+ >
145
+ <div class="switch">
146
+ <span class="checked-indicator"></span>
147
+ ${() => focusTemplate}
632
148
  </div>
633
- ${when(x => {
634
- var _a;
635
- return (_a = x.helperText) === null || _a === void 0 ? void 0 : _a.length;
636
- }, getFeedbackTemplate('helper', context))}
637
- ${when(x => !x.successText && x.errorValidationMessage, getFeedbackTemplate('error', context))}
638
- ${when(x => x.successText, getFeedbackTemplate('success', context))}
149
+ ${when((x) => x.label, html`<div class="label">
150
+ ${(x) => x.label}
151
+ </div>`)}
152
+ </div>
639
153
  `;
640
- }
641
- const SelectTemplate = context => {
642
- return html`
643
- <template class="base"
644
- aria-label="${x => x.ariaLabel ? x.ariaLabel : x.label}"
645
- aria-activedescendant="${x => x.ariaActiveDescendant}"
646
- aria-controls="${x => x.ariaControls}"
647
- aria-disabled="${x => x.ariaDisabled}"
648
- aria-expanded="${x => x.ariaExpanded}"
649
- aria-haspopup="${x => x.collapsible ? 'listbox' : null}"
650
- aria-multiselectable="${x => x.ariaMultiSelectable}"
651
- ?open="${x => x.open}"
652
- role="combobox"
653
- tabindex="${x => !x.disabled ? '0' : null}"
654
- @click="${(x, c) => x.clickHandler(c.event)}"
655
- @focusin="${(x, c) => x.focusinHandler(c.event)}"
656
- @focusout="${(x, c) => x.focusoutHandler(c.event)}"
657
- @keydown="${(x, c) => x.keydownHandler(c.event)}"
658
- @mousedown="${(x, c) => x.mousedownHandler(c.event)}">
659
- ${renderControl(context)}
660
- </template>`;
661
154
  };
662
155
 
663
- const selectDefinition = Select.compose({
664
- baseName: 'select',
665
- template: SelectTemplate,
666
- styles: css_248z
156
+ const switchDefinition = Switch.compose({
157
+ baseName: "switch",
158
+ template: SwitchTemplate,
159
+ styles,
160
+ shadowOptions: {
161
+ delegatesFocus: true
162
+ }
667
163
  });
668
- const selectRegistries = [selectDefinition(), ...focusRegistries, ...popupRegistries, ...iconRegistries, ...listboxOptionRegistries];
669
- const registerSelect = registerFactory(selectRegistries);
164
+ const switchRegistries = [switchDefinition(), ...iconRegistries, ...focusRegistries];
165
+ const registerSwitch = registerFactory(switchRegistries);
670
166
 
671
- export { selectRegistries as a, registerSelect as r, selectDefinition as s };
167
+ export { switchRegistries as a, registerSwitch as r, switchDefinition as s };