@fluentui/web-components 3.0.0-beta.39 → 3.0.0-beta.40

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 (77) hide show
  1. package/CHANGELOG.md +13 -2
  2. package/dist/dts/accordion/accordion.d.ts +35 -12
  3. package/dist/dts/accordion-item/accordion-item.d.ts +42 -14
  4. package/dist/dts/accordion-item/accordion-item.options.d.ts +2 -2
  5. package/dist/dts/accordion-item/index.d.ts +1 -1
  6. package/dist/dts/checkbox/checkbox.d.ts +98 -48
  7. package/dist/dts/field/field.d.ts +30 -1
  8. package/dist/dts/field/field.options.d.ts +2 -0
  9. package/dist/dts/index.d.ts +1 -1
  10. package/dist/dts/radio/index.d.ts +1 -1
  11. package/dist/dts/radio/radio.d.ts +38 -35
  12. package/dist/dts/radio/radio.options.d.ts +14 -0
  13. package/dist/dts/radio/radio.styles.d.ts +3 -1
  14. package/dist/dts/radio/radio.template.d.ts +13 -1
  15. package/dist/dts/radio-group/radio-group.d.ts +211 -49
  16. package/dist/dts/radio-group/radio-group.template.d.ts +1 -1
  17. package/dist/dts/styles/states/index.d.ts +20 -0
  18. package/dist/dts/switch/switch.d.ts +1 -0
  19. package/dist/dts/utils/root-active-element.d.ts +1 -0
  20. package/dist/esm/accordion/accordion.js +46 -85
  21. package/dist/esm/accordion/accordion.js.map +1 -1
  22. package/dist/esm/accordion-item/accordion-item.js +63 -19
  23. package/dist/esm/accordion-item/accordion-item.js.map +1 -1
  24. package/dist/esm/accordion-item/accordion-item.options.js +1 -1
  25. package/dist/esm/accordion-item/accordion-item.options.js.map +1 -1
  26. package/dist/esm/accordion-item/accordion-item.styles.js +41 -63
  27. package/dist/esm/accordion-item/accordion-item.styles.js.map +1 -1
  28. package/dist/esm/accordion-item/accordion-item.template.js +24 -43
  29. package/dist/esm/accordion-item/accordion-item.template.js.map +1 -1
  30. package/dist/esm/accordion-item/index.js +1 -1
  31. package/dist/esm/accordion-item/index.js.map +1 -1
  32. package/dist/esm/checkbox/checkbox.js +146 -97
  33. package/dist/esm/checkbox/checkbox.js.map +1 -1
  34. package/dist/esm/checkbox/checkbox.styles.js +1 -6
  35. package/dist/esm/checkbox/checkbox.styles.js.map +1 -1
  36. package/dist/esm/checkbox/checkbox.template.js.map +1 -1
  37. package/dist/esm/field/field.js +91 -29
  38. package/dist/esm/field/field.js.map +1 -1
  39. package/dist/esm/field/field.options.js.map +1 -1
  40. package/dist/esm/field/field.styles.js +31 -16
  41. package/dist/esm/field/field.styles.js.map +1 -1
  42. package/dist/esm/field/field.template.js +1 -1
  43. package/dist/esm/field/field.template.js.map +1 -1
  44. package/dist/esm/index.js +1 -1
  45. package/dist/esm/index.js.map +1 -1
  46. package/dist/esm/radio/radio.js +59 -72
  47. package/dist/esm/radio/radio.js.map +1 -1
  48. package/dist/esm/radio/radio.options.js +2 -0
  49. package/dist/esm/radio/radio.options.js.map +1 -0
  50. package/dist/esm/radio/radio.styles.js +95 -88
  51. package/dist/esm/radio/radio.styles.js.map +1 -1
  52. package/dist/esm/radio/radio.template.js +21 -24
  53. package/dist/esm/radio/radio.template.js.map +1 -1
  54. package/dist/esm/radio-group/radio-group.js +416 -313
  55. package/dist/esm/radio-group/radio-group.js.map +1 -1
  56. package/dist/esm/radio-group/radio-group.styles.js +26 -32
  57. package/dist/esm/radio-group/radio-group.styles.js.map +1 -1
  58. package/dist/esm/radio-group/radio-group.template.js +6 -21
  59. package/dist/esm/radio-group/radio-group.template.js.map +1 -1
  60. package/dist/esm/styles/states/index.js +20 -0
  61. package/dist/esm/styles/states/index.js.map +1 -1
  62. package/dist/esm/switch/switch.js +4 -0
  63. package/dist/esm/switch/switch.js.map +1 -1
  64. package/dist/esm/switch/switch.styles.js +3 -6
  65. package/dist/esm/switch/switch.styles.js.map +1 -1
  66. package/dist/esm/switch/switch.template.js.map +1 -1
  67. package/dist/esm/theme/set-theme.js +3 -6
  68. package/dist/esm/theme/set-theme.js.map +1 -1
  69. package/dist/esm/utils/root-active-element.js +9 -0
  70. package/dist/esm/utils/root-active-element.js.map +1 -0
  71. package/dist/web-components.d.ts +461 -181
  72. package/dist/web-components.js +1387 -1233
  73. package/dist/web-components.min.js +262 -258
  74. package/package.json +1 -1
  75. package/dist/dts/radio/radio.form-associated.d.ts +0 -14
  76. package/dist/esm/radio/radio.form-associated.js +0 -14
  77. package/dist/esm/radio/radio.form-associated.js.map +0 -1
@@ -1,58 +1,61 @@
1
- import type { StaticallyComposableHTML } from '../utils/template-helpers.js';
2
- import { FormAssociatedRadio } from './radio.form-associated.js';
3
- /**
4
- * @public
5
- */
6
- export type RadioControl = Pick<HTMLInputElement, 'checked' | 'disabled' | 'focus' | 'setAttribute' | 'getAttribute'>;
7
- /**
8
- * Radio configuration options
9
- * @public
10
- */
11
- export type RadioOptions = {
12
- checkedIndicator?: StaticallyComposableHTML<Radio>;
13
- };
1
+ import { BaseCheckbox } from '../checkbox/checkbox.js';
14
2
  /**
15
3
  * A Radio Custom HTML Element.
16
- * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#radio | ARIA radio }.
4
+ * Implements the {@link https://w3c.github.io/aria/#radio | ARIA `radio` role}.
17
5
  *
18
- * @slot checked-indicator - The checked indicator
19
- * @slot - The default slot for the label
20
- * @csspart control - The element representing the visual radio control
21
- * @csspart label - The label
6
+ * @slot checked-indicator - The checked indicator slot
22
7
  * @fires change - Emits a custom change event when the checked state changes
8
+ * @fires input - Emits a custom input event when the checked state changes
23
9
  *
24
10
  * @public
25
11
  */
26
- export declare class Radio extends FormAssociatedRadio implements RadioControl {
27
- /**
28
- * The name of the radio. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname | name attribute} for more info.
29
- */
30
- name: string;
12
+ export declare class Radio extends BaseCheckbox {
13
+ connectedCallback(): void;
14
+ constructor();
31
15
  /**
32
- * The element's value to be included in form submission when checked.
33
- * Default to "on" to reach parity with input[type="radio"]
16
+ * Toggles the disabled state when the user changes the `disabled` property.
34
17
  *
18
+ * @param prev - the previous value of the `disabled` property
19
+ * @param next - the current value of the `disabled` property
35
20
  * @internal
21
+ * @override
36
22
  */
37
- initialValue: string;
23
+ protected disabledChanged(prev: boolean | undefined, next: boolean | undefined): void;
38
24
  /**
25
+ * This method is a no-op for the radio component.
26
+ *
39
27
  * @internal
28
+ * @override
29
+ * @remarks
30
+ * To make a group of radio controls required, see {@link RadioGroup.required}.
40
31
  */
41
- defaultSlottedNodes: Node[];
42
- private get radioGroup();
32
+ protected requiredChanged(): void;
43
33
  /**
34
+ * This method is a no-op for the radio component.
35
+ *
44
36
  * @internal
37
+ * @override
38
+ * @remarks
39
+ * The radio form value is controlled by the `RadioGroup` component.
45
40
  */
46
- defaultCheckedChanged(): void;
47
- constructor();
41
+ setFormValue(): void;
48
42
  /**
43
+ * Sets the validity of the control.
44
+ *
49
45
  * @internal
46
+ * @override
47
+ * @remarks
48
+ * The radio component does not have a `required` attribute, so this method always sets the validity to `true`.
50
49
  */
51
- connectedCallback(): void;
52
- private isInsideRadioGroup;
50
+ setValidity(): void;
53
51
  /**
54
- * Handles key presses on the radio.
55
- * @beta
52
+ * Toggles the checked state of the control.
53
+ *
54
+ * @param force - Forces the element to be checked or unchecked
55
+ * @public
56
+ * @override
57
+ * @remarks
58
+ * The radio checked state is controlled by the `RadioGroup` component, so the `force` parameter defaults to `true`.
56
59
  */
57
- keypressHandler(e: KeyboardEvent): boolean | void;
60
+ toggleChecked(force?: boolean): void;
58
61
  }
@@ -0,0 +1,14 @@
1
+ import type { StaticallyComposableHTML } from '../utils/template-helpers.js';
2
+ import type { Radio } from './radio.js';
3
+ /**
4
+ * @public
5
+ */
6
+ export type RadioControl = Pick<HTMLInputElement, 'checked' | 'disabled' | 'focus' | 'setAttribute' | 'getAttribute'>;
7
+ /**
8
+ * Radio configuration options
9
+ * @public
10
+ */
11
+ export type RadioOptions = {
12
+ checkedIndicator?: StaticallyComposableHTML<Radio>;
13
+ };
14
+ export type { CheckboxSize as RadioSize } from '../checkbox/checkbox.options.js';
@@ -1,4 +1,6 @@
1
- /** Radio styles
1
+ /**
2
+ * Styles for the Radio component
3
+ *
2
4
  * @public
3
5
  */
4
6
  export declare const styles: import("@microsoft/fast-element").ElementStyles;
@@ -1,4 +1,16 @@
1
1
  import { ElementViewTemplate } from '@microsoft/fast-element';
2
- import type { Radio, RadioOptions } from './radio.js';
2
+ import type { Radio } from './radio.js';
3
+ import type { RadioOptions } from './radio.options.js';
4
+ /**
5
+ * Generates a template for the {@link (Radio:class)} component.
6
+ *
7
+ * @param options - Radio configuration options
8
+ * @public
9
+ */
3
10
  export declare function radioTemplate<T extends Radio>(options?: RadioOptions): ElementViewTemplate<T>;
11
+ /**
12
+ * Template for the Radio component
13
+ *
14
+ * @public
15
+ */
4
16
  export declare const template: ElementViewTemplate<Radio>;
@@ -1,104 +1,266 @@
1
1
  import { FASTElement } from '@microsoft/fast-element';
2
+ import { Radio } from '../radio/radio.js';
2
3
  import { RadioGroupOrientation } from './radio-group.options.js';
3
4
  /**
4
- * The base class used for constructing a fluent-radio-group custom element
5
+ * A Radio Group Custom HTML Element.
6
+ * Implements the {@link https://w3c.github.io/aria/#radiogroup | ARIA `radiogroup` role}.
7
+ *
5
8
  * @public
9
+ *
10
+ * @slot - The default slot for the radio group
6
11
  */
7
12
  export declare class RadioGroup extends FASTElement {
8
13
  /**
9
- * sets radio layout styles
14
+ * The index of the checked radio, scoped to the enabled radios.
15
+ *
16
+ * @internal
17
+ */
18
+ protected checkedIndex: number;
19
+ /**
20
+ * Sets the checked state of the nearest enabled radio when the `checkedIndex` changes.
21
+ *
22
+ * @param prev - the previous index
23
+ * @param next - the current index
24
+ * @internal
25
+ */
26
+ protected checkedIndexChanged(prev: number | undefined, next: number): void;
27
+ /**
28
+ * Indicates that the value has been changed by the user.
29
+ */
30
+ private dirtyState;
31
+ /**
32
+ * Disables the radio group and child radios.
10
33
  *
11
34
  * @public
12
35
  * @remarks
13
- * HTML Attribute: stacked
36
+ * HTML Attribute: `disabled`
37
+ */
38
+ disabled: boolean;
39
+ /**
40
+ * Sets the `disabled` attribute on all child radios when the `disabled` property changes.
41
+ *
42
+ * @param prev - the previous disabled value
43
+ * @param next - the current disabled value
44
+ * @internal
14
45
  */
15
- stacked: boolean;
46
+ protected disabledChanged(prev?: boolean, next?: boolean): void;
16
47
  /**
17
- * When true, the child radios will be immutable by user interaction. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly | readonly HTML attribute} for more information.
48
+ * The value of the checked radio.
49
+ *
18
50
  * @public
19
51
  * @remarks
20
- * HTML Attribute: readonly
52
+ * HTML Attribute: `value`
21
53
  */
22
- readOnly: boolean;
54
+ initialValue?: string;
23
55
  /**
24
- * Disables the radio group and child radios.
56
+ * Sets the matching radio to checked when the value changes. If no radio matches the value, no radio will be checked.
57
+ *
58
+ * @param prev - the previous value
59
+ * @param next - the current value
60
+ */
61
+ initialValueChanged(prev: string | undefined, next: string | undefined): void;
62
+ /**
63
+ * The name of the radio group.
25
64
  *
26
65
  * @public
27
66
  * @remarks
28
- * HTML Attribute: disabled
67
+ * HTML Attribute: `name`
29
68
  */
30
- disabled: boolean;
69
+ name: string;
70
+ /**
71
+ * Sets the `name` attribute on all child radios when the `name` property changes.
72
+ *
73
+ * @internal
74
+ */
75
+ protected nameChanged(prev: string | undefined, next: string | undefined): void;
31
76
  /**
32
- * The name of the radio group. Setting this value will set the name value
33
- * for all child radio elements.
77
+ * The orientation of the group.
34
78
  *
35
79
  * @public
36
80
  * @remarks
37
- * HTML Attribute: name
81
+ * HTML Attribute: `orientation`
38
82
  */
39
- name: string;
40
- protected nameChanged(): void;
83
+ orientation?: RadioGroupOrientation;
84
+ /**
85
+ * Sets the ariaOrientation attribute when the orientation changes.
86
+ *
87
+ * @param prev - the previous orientation
88
+ * @param next - the current orientation
89
+ * @internal
90
+ */
91
+ orientationChanged(prev: RadioGroupOrientation | undefined, next: RadioGroupOrientation | undefined): void;
92
+ /**
93
+ * The collection of all child radios.
94
+ *
95
+ * @public
96
+ */
97
+ radios: Radio[];
98
+ /**
99
+ * Updates the enabled radios collection when properties on the child radios change.
100
+ *
101
+ * @param prev - the previous radios
102
+ * @param next - the current radios
103
+ */
104
+ radiosChanged(prev: Radio[] | undefined, next: Radio[] | undefined): void;
105
+ /**
106
+ * Indicates whether the radio group is required.
107
+ *
108
+ * @public
109
+ * @remarks
110
+ * HTML Attribute: `required`
111
+ */
112
+ required: boolean;
113
+ /**
114
+ *
115
+ * @param prev - the previous required value
116
+ * @param next - the current required value
117
+ */
118
+ requiredChanged(prev: boolean, next: boolean): void;
119
+ /**
120
+ * The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
121
+ *
122
+ * @internal
123
+ */
124
+ elementInternals: ElementInternals;
125
+ /**
126
+ * A collection of child radios that are not disabled.
127
+ *
128
+ * @internal
129
+ */
130
+ get enabledRadios(): Radio[];
131
+ /**
132
+ * The form-associated flag.
133
+ * @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example | Form-associated custom elements}
134
+ *
135
+ * @public
136
+ */
137
+ static formAssociated: boolean;
138
+ /**
139
+ * The fallback validation message, taken from a native checkbox `<input>` element.
140
+ *
141
+ * @internal
142
+ */
143
+ private _validationFallbackMessage;
144
+ /**
145
+ * The validation message. Uses the browser's default validation message for native checkboxes if not otherwise
146
+ * specified (e.g., via `setCustomValidity`).
147
+ *
148
+ * @internal
149
+ */
150
+ get validationMessage(): string;
41
151
  /**
42
- * The value of the checked radio
152
+ * The element's validity state.
43
153
  *
44
154
  * @public
45
155
  * @remarks
46
- * HTML Attribute: value
156
+ * Reflects the {@link https://developer.mozilla.org/docs/Web/API/ElementInternals/validity | `ElementInternals.validity`} property.
157
+ */
158
+ get validity(): ValidityState;
159
+ /**
160
+ * The current value of the checked radio.
161
+ *
162
+ * @public
163
+ */
164
+ get value(): string | null;
165
+ set value(next: string | null);
166
+ /**
167
+ * Sets the checked state of all radios when any radio emits a `change` event.
168
+ *
169
+ * @param e - the change event
170
+ */
171
+ changeHandler(e: Event): boolean | void;
172
+ /**
173
+ * Checks the radio at the specified index.
174
+ *
175
+ * @param index - the index of the radio to check
176
+ * @internal
47
177
  */
48
- value: string;
49
- protected valueChanged(): void;
178
+ checkRadio(index?: number): void;
50
179
  /**
51
- * The orientation of the group
180
+ * Checks the validity of the element and returns the result.
52
181
  *
53
182
  * @public
54
183
  * @remarks
55
- * HTML Attribute: orientation
184
+ * Reflects the {@link https://developer.mozilla.org/docs/Web/API/ElementInternals/checkValidity | `HTMLInputElement.checkValidity()`} method.
56
185
  */
57
- orientation: RadioGroupOrientation;
58
- childItems: HTMLElement[];
186
+ checkValidity(): boolean;
59
187
  /**
188
+ * Handles click events for the radio group.
189
+ *
190
+ * @param e - the click event
191
+ * @internal
192
+ */
193
+ clickHandler(e: MouseEvent): boolean | void;
194
+ constructor();
195
+ /**
196
+ * Focuses the checked radio or the first enabled radio.
197
+ *
198
+ * @internal
199
+ */
200
+ focus(): void;
201
+ /**
202
+ * Enables tabbing through the radio group when the group receives focus.
203
+ *
204
+ * @param e - the focus event
205
+ * @internal
206
+ */
207
+ focusinHandler(e: FocusEvent): boolean | void;
208
+ /**
209
+ * Sets the tabindex of the radios based on the checked state when the radio group loses focus.
210
+ *
211
+ * @param e - the focusout event
60
212
  * @internal
61
213
  */
62
- slottedRadioButtons: HTMLElement[];
63
- protected slottedRadioButtonsChanged(oldValue: unknown, newValue: HTMLElement[]): void;
64
- private selectedRadio;
65
- private focusedRadio;
66
- private direction;
67
- private get parentToolbar();
68
- private get isInsideToolbar();
69
- private get isInsideFoundationToolbar();
214
+ focusoutHandler(e: FocusEvent): boolean | void;
215
+ formResetCallback(): void;
216
+ private getEnabledIndexInBounds;
70
217
  /**
218
+ * Handles keydown events for the radio group.
219
+ *
220
+ * @param e - the keyboard event
71
221
  * @internal
72
222
  */
73
- connectedCallback(): void;
74
- disconnectedCallback(): void;
75
- private setupRadioButtons;
76
- private radioChangeHandler;
77
- private moveToRadioByIndex;
78
- private moveRightOffGroup;
79
- private moveLeftOffGroup;
223
+ keydownHandler(e: KeyboardEvent): boolean | void;
224
+ /**
225
+ *
226
+ * @param e - the disabled event
227
+ */
228
+ disabledRadioHandler(e: CustomEvent): void;
80
229
  /**
230
+ * Reports the validity of the element.
231
+ *
232
+ * @public
233
+ * @remarks
234
+ * Reflects the {@link https://developer.mozilla.org/docs/Web/API/ElementInternals/reportValidity | `HTMLInputElement.reportValidity()`} method.
235
+ */
236
+ reportValidity(): boolean;
237
+ /**
238
+ * Resets the `tabIndex` for all child radios when the radio group loses focus.
239
+ *
81
240
  * @internal
82
241
  */
83
- focusOutHandler: (e: FocusEvent) => boolean | void;
242
+ private restrictFocus;
84
243
  /**
244
+ * Reflects the {@link https://developer.mozilla.org/docs/Web/API/ElementInternals/setFormValue | `ElementInternals.setFormValue()`} method.
245
+ *
85
246
  * @internal
86
247
  */
87
- handleDisabledClick: (e: MouseEvent) => void | boolean;
248
+ setFormValue(value: File | string | FormData | null, state?: File | string | FormData | null): void;
88
249
  /**
250
+ * Sets the validity of the element.
251
+ *
252
+ * @param flags - Validity flags to set.
253
+ * @param message - Optional message to supply. If not provided, the element's `validationMessage` will be used.
254
+ * @param anchor - Optional anchor to use for the validation message.
255
+ *
89
256
  * @internal
90
257
  */
91
- clickHandler: (e: MouseEvent) => void | boolean;
92
- private shouldMoveOffGroupToTheRight;
93
- private shouldMoveOffGroupToTheLeft;
94
- private checkFocusedRadio;
95
- private moveRight;
96
- private moveLeft;
258
+ setValidity(flags?: Partial<ValidityState>, message?: string, anchor?: HTMLElement): void;
97
259
  /**
98
- * keyboard handling per https://w3c.github.io/aria-practices/#for-radio-groups-not-contained-in-a-toolbar
99
- * navigation is different when there is an ancestor with role='toolbar'
260
+ * Updates the collection of child radios when the slot changes.
100
261
  *
262
+ * @param e - the slot change event
101
263
  * @internal
102
264
  */
103
- keydownHandler: (e: KeyboardEvent) => boolean | void;
265
+ slotchangeHandler(e: Event): void;
104
266
  }
@@ -1,4 +1,4 @@
1
- import type { ElementViewTemplate } from '@microsoft/fast-element';
1
+ import { ElementViewTemplate } from '@microsoft/fast-element';
2
2
  import type { RadioGroup } from './radio-group.js';
3
3
  export declare function radioGroupTemplate<T extends RadioGroup>(): ElementViewTemplate<T>;
4
4
  export declare const template: ElementViewTemplate<RadioGroup>;
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Selector for the `checked` state.
3
+ * @public
4
+ */
5
+ export declare const checkedState: import("@microsoft/fast-element").CSSDirective;
6
+ /**
7
+ * Selector for the `disabled` state.
8
+ * @public
9
+ */
10
+ export declare const disabledState: import("@microsoft/fast-element").CSSDirective;
1
11
  /**
2
12
  * Selector for the `filled-lighter` state.
3
13
  * @public
@@ -193,3 +203,13 @@ export declare const singleLineState: import("@microsoft/fast-element").CSSDirec
193
203
  * @public
194
204
  */
195
205
  export declare const multiLineState: import("@microsoft/fast-element").CSSDirective;
206
+ /**
207
+ * Selector for the `expanded` state.
208
+ * @public
209
+ */
210
+ export declare const expandedState: import("@microsoft/fast-element").CSSDirective;
211
+ /**
212
+ * Selector for the `block` state.
213
+ * @public
214
+ */
215
+ export declare const blockState: import("@microsoft/fast-element").CSSDirective;
@@ -4,4 +4,5 @@ export type SwitchOptions = {
4
4
  switch?: StaticallyComposableHTML<Switch>;
5
5
  };
6
6
  export declare class Switch extends BaseCheckbox {
7
+ constructor();
7
8
  }
@@ -0,0 +1 @@
1
+ export declare function getRootActiveElement(element: Element): Element | null;