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