diff --git a/change/@fluentui-web-components-b33ad15b-6464-430d-bea6-2eb220452375.json b/change/@fluentui-web-components-b33ad15b-6464-430d-bea6-2eb220452375.json new file mode 100644 index 0000000000000..784e7df785334 --- /dev/null +++ b/change/@fluentui-web-components-b33ad15b-6464-430d-bea6-2eb220452375.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "feat: update slider to use ElementInternals for form association", + "packageName": "@fluentui/web-components", + "email": "machi@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/web-components/docs/api-report.md b/packages/web-components/docs/api-report.md index 9c665172f4a7e..ad2a9f6c7d12a 100644 --- a/packages/web-components/docs/api-report.md +++ b/packages/web-components/docs/api-report.md @@ -6,7 +6,6 @@ /// -import type { Constructable } from '@microsoft/fast-element'; import { CSSDirective } from '@microsoft/fast-element'; import { Direction } from '@microsoft/fast-web-utilities'; import { ElementStyles } from '@microsoft/fast-element'; @@ -1999,6 +1998,23 @@ export class Drawer extends FASTElement { type: DrawerType; } +// Warning: (ae-missing-release-tag) "DrawerBody" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export class DrawerBody extends FASTElement { +} + +// @public (undocumented) +export const DrawerBodyDefinition: FASTElementDefinition; + +// @public +export const DrawerBodyStyles: ElementStyles; + +// Warning: (ae-missing-release-tag) "template" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const DrawerBodyTemplate: ElementViewTemplate; + // @public (undocumented) export const DrawerDefinition: FASTElementDefinition; @@ -2847,48 +2863,65 @@ export const shadow8 = "var(--shadow8)"; // @public export const shadow8Brand = "var(--shadow8Brand)"; -// Warning: (ae-forgotten-export) The symbol "FormAssociatedSlider" needs to be exported by the entry point index.d.ts -// // @public -export class Slider extends FormAssociatedSlider implements SliderConfiguration { +export class Slider extends FASTElement implements SliderConfiguration { + constructor(); // @internal calculateNewValue(rawValue: number): number; + checkValidity(): boolean; // @internal (undocumented) connectedCallback(): void; decrement(): void; // @internal (undocumented) direction: Direction; + disabled: boolean; + // (undocumented) + protected disabledChanged(): void; // @internal (undocumented) disconnectedCallback(): void; + // @internal + elementInternals: ElementInternals; + static formAssociated: boolean; + // @internal + formDisabledCallback(disabled: boolean): void; + // @internal + formResetCallback(): void; // (undocumented) - handleChange(source: any, propertyName: string): void; + handleChange(_: any, propertyName: string): void; // (undocumented) - handleMouseDown: (e: MouseEvent | null) => void; - handleThumbMouseDown: (event: MouseEvent | null) => void; + handlePointerDown: (event: PointerEvent | null) => void; + handleThumbPointerDown: (event: PointerEvent | null) => void; increment(): void; - // @internal (undocumented) initialValue: string; + // @internal + protected initialValueChanged(_: string, next: string): void; // @internal (undocumented) isDragging: boolean; // (undocumented) - keypressHandler: (e: KeyboardEvent) => void; - max: number; + keypressHandler: (event: KeyboardEvent) => void; + get labels(): ReadonlyArray; + max: string; // (undocumented) protected maxChanged(): void; - min: number; + min: string; // (undocumented) protected minChanged(): void; mode: SliderMode; - orientation: Orientation; + orientation?: Orientation; // (undocumented) - protected orientationChanged(): void; + protected orientationChanged(prev: string | undefined, next: string | undefined): void; // @internal (undocumented) position: string; - readOnly: boolean; - // (undocumented) - protected readOnlyChanged(): void; + reportValidity(): boolean; + setCustomValidity(message: string): void; + // @internal + setFormValue(value: File | string | FormData | null, state?: File | string | FormData | null): void; + // @internal + setValidity(flags?: Partial, message?: string, anchor?: HTMLElement): void; size?: SliderSize; - step: number | undefined; + // (undocumented) + protected sizeChanged(prev: string, next: string): void; + step: string; // (undocumented) protected stepChanged(): void; // @internal (undocumented) @@ -2907,11 +2940,16 @@ export class Slider extends FormAssociatedSlider implements SliderConfiguration trackMinWidth: number; // @internal (undocumented) trackWidth: number; + get validationMessage(): string; + get validity(): ValidityState; + get value(): string; + set value(value: string); get valueAsNumber(): number; set valueAsNumber(next: number); - // @internal (undocumented) - valueChanged(previous: string, next: string): void; - valueTextFormatter: (value: string) => string | null; + valueTextFormatter: (value: string) => string; + // (undocumented) + protected valueTextFormatterChanged(): void; + get willValidate(): boolean; } // @public (undocumented) @@ -2921,9 +2959,9 @@ export interface SliderConfiguration { // (undocumented) disabled?: boolean; // (undocumented) - max: number; + max?: string; // (undocumented) - min: number; + min?: string; // (undocumented) orientation?: SliderOrientation; } diff --git a/packages/web-components/src/slider/slider.options.ts b/packages/web-components/src/slider/slider.options.ts index b54abd3229f79..f97f798cde1d6 100644 --- a/packages/web-components/src/slider/slider.options.ts +++ b/packages/web-components/src/slider/slider.options.ts @@ -46,8 +46,8 @@ export type SliderMode = ValuesOf; * @public */ export interface SliderConfiguration { - max: number; - min: number; + max?: string; + min?: string; orientation?: SliderOrientation; direction?: Direction; disabled?: boolean; diff --git a/packages/web-components/src/slider/slider.spec.ts b/packages/web-components/src/slider/slider.spec.ts index 45e03a9a9d7d1..955b3f97c850d 100644 --- a/packages/web-components/src/slider/slider.spec.ts +++ b/packages/web-components/src/slider/slider.spec.ts @@ -23,125 +23,117 @@ test.describe('Slider', () => { await page.close(); }); - test('should set and retrieve the `size` property correctly', async () => { - await element.evaluate((node: Slider) => { - node.size = 'small'; - }); - - await expect(element).toHaveJSProperty('size', 'small'); - - await element.evaluate((node: Slider) => { - node.size = 'medium'; - }); - - await expect(element).toHaveJSProperty('size', 'medium'); - }); - // Foundation tests - test('should have a role of `slider`', async () => { + test('should have a default role of `slider`', async () => { await root.evaluate(node => { node.innerHTML = /* html */ ` - - `; + + `; }); - await expect(element).toHaveAttribute('role', 'slider'); + await expect(element).toHaveJSProperty('elementInternals.role', 'slider'); }); - test('should set a default `min` property of 0 when `min` is not provided', async () => { + test('should have default empty string values if `min`, `max`, and `step` attributes are not set', async () => { await root.evaluate(node => { node.innerHTML = /* html */ ` - - `; + + `; }); - await expect(element).toHaveJSProperty('min', 0); + await expect(element).toHaveJSProperty('min', ''); + await expect(element).toHaveJSProperty('max', ''); + await expect(element).toHaveJSProperty('step', ''); }); - test('should set a default `max` property of 10 when `max` is not provided', async () => { + test('should reference connected