@fluentui/web-components 3.0.0-beta.41 → 3.0.0-beta.42

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 (58) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/dist/dts/slider/slider.d.ts +180 -35
  3. package/dist/dts/slider/slider.options.d.ts +2 -2
  4. package/dist/dts/slider/slider.template.d.ts +2 -2
  5. package/dist/dts/styles/states/index.d.ts +5 -0
  6. package/dist/dts/utils/converters.d.ts +17 -0
  7. package/dist/dts/utils/index.d.ts +1 -0
  8. package/dist/esm/accordion/accordion.js.map +1 -1
  9. package/dist/esm/accordion-item/accordion-item.js.map +1 -1
  10. package/dist/esm/anchor-button/anchor-button.js.map +1 -1
  11. package/dist/esm/avatar/avatar.js +2 -1
  12. package/dist/esm/avatar/avatar.js.map +1 -1
  13. package/dist/esm/badge/badge.js.map +1 -1
  14. package/dist/esm/button/button.js +2 -1
  15. package/dist/esm/button/button.js.map +1 -1
  16. package/dist/esm/checkbox/checkbox.js +2 -1
  17. package/dist/esm/checkbox/checkbox.js.map +1 -1
  18. package/dist/esm/counter-badge/counter-badge.js.map +1 -1
  19. package/dist/esm/dialog/dialog.js.map +1 -1
  20. package/dist/esm/dialog-body/dialog-body.js.map +1 -1
  21. package/dist/esm/divider/divider.js.map +1 -1
  22. package/dist/esm/drawer/drawer.js.map +1 -1
  23. package/dist/esm/field/field.js.map +1 -1
  24. package/dist/esm/image/image.js.map +1 -1
  25. package/dist/esm/label/label.js.map +1 -1
  26. package/dist/esm/link/link.js.map +1 -1
  27. package/dist/esm/menu/menu.js.map +1 -1
  28. package/dist/esm/menu-item/menu-item.js.map +1 -1
  29. package/dist/esm/menu-list/menu-list.js +2 -1
  30. package/dist/esm/menu-list/menu-list.js.map +1 -1
  31. package/dist/esm/message-bar/message-bar.js.map +1 -1
  32. package/dist/esm/patterns/aria-globals.js.map +1 -1
  33. package/dist/esm/progress-bar/progress-bar.js.map +1 -1
  34. package/dist/esm/radio-group/radio-group.js +2 -1
  35. package/dist/esm/radio-group/radio-group.js.map +1 -1
  36. package/dist/esm/rating-display/rating-display.js.map +1 -1
  37. package/dist/esm/slider/slider.js +442 -220
  38. package/dist/esm/slider/slider.js.map +1 -1
  39. package/dist/esm/slider/slider.styles.js +107 -132
  40. package/dist/esm/slider/slider.styles.js.map +1 -1
  41. package/dist/esm/slider/slider.template.js +11 -28
  42. package/dist/esm/slider/slider.template.js.map +1 -1
  43. package/dist/esm/spinner/spinner.js.map +1 -1
  44. package/dist/esm/styles/states/index.js +5 -0
  45. package/dist/esm/styles/states/index.js.map +1 -1
  46. package/dist/esm/tab/tab.js.map +1 -1
  47. package/dist/esm/tabs/tabs.js.map +1 -1
  48. package/dist/esm/text-input/text-input.js +2 -1
  49. package/dist/esm/text-input/text-input.js.map +1 -1
  50. package/dist/esm/toggle-button/toggle-button.js.map +1 -1
  51. package/dist/esm/utils/converters.js +26 -0
  52. package/dist/esm/utils/converters.js.map +1 -0
  53. package/dist/esm/utils/index.js +1 -0
  54. package/dist/esm/utils/index.js.map +1 -1
  55. package/dist/web-components.d.ts +181 -101
  56. package/dist/web-components.js +368 -502
  57. package/dist/web-components.min.js +198 -196
  58. package/package.json +1 -1
@@ -0,0 +1,26 @@
1
+ /**
2
+ * A {@link ValueConverter} that makes sure the attribute and property values
3
+ * are a string representation of a number, e.g. `'10'` instead of `10`.
4
+ *
5
+ * @remarks
6
+ * This converter allows any data type, but if the data is evaluated as `NaN`
7
+ * by `Number.isNaN()`, it’d be converted to an empty string. Otherwise, the
8
+ * converted value is a string of number.
9
+ *
10
+ * It is useful for somm custom element’s attributes and properties, e.g.
11
+ * `min`, `max`, `step` on an `<input type=range>`-like element, to align with
12
+ * the built-in HTML element behavior, those property values should be strings.
13
+ *
14
+ * @public
15
+ */
16
+ export const numberLikeStringConverter = {
17
+ fromView(value) {
18
+ const valueAsNumber = parseFloat(value);
19
+ return Number.isNaN(valueAsNumber) ? '' : valueAsNumber.toString();
20
+ },
21
+ toView(value) {
22
+ const valueAsNumber = parseFloat(value);
23
+ return Number.isNaN(valueAsNumber) ? undefined : valueAsNumber.toString();
24
+ },
25
+ };
26
+ //# sourceMappingURL=converters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converters.js","sourceRoot":"","sources":["../../../src/utils/converters.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAmB;IACvD,QAAQ,CAAC,KAAa;QACpB,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;IACrE,CAAC;IACD,MAAM,CAAC,KAAU;QACf,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;IAC5E,CAAC;CACF,CAAC"}
@@ -1,3 +1,4 @@
1
+ export * from './converters.js';
1
2
  export * from './direction.js';
2
3
  export * from './typings.js';
3
4
  export * from './template-helpers.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,gDAAgD,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,gDAAgD,CAAC"}
@@ -1,6 +1,5 @@
1
1
  /// <reference types="web" />
2
2
 
3
- import type { Constructable } from '@microsoft/fast-element';
4
3
  import { CSSDirective } from '@microsoft/fast-element';
5
4
  import { Direction } from '@microsoft/fast-web-utilities';
6
5
  import { ElementStyles } from '@microsoft/fast-element';
@@ -4142,13 +4141,6 @@ export declare const CompoundButtonStyles: ElementStyles;
4142
4141
  */
4143
4142
  export declare const CompoundButtonTemplate: ElementViewTemplate<CompoundButton>;
4144
4143
 
4145
- /**
4146
- * Combined type to describe a Constructable Form-Associated type.
4147
- *
4148
- * @beta
4149
- */
4150
- declare type ConstructableFormAssociated = Constructable<HTMLElement & FASTElement>;
4151
-
4152
4144
  /**
4153
4145
  * The base class used for constructing a fluent-badge custom element
4154
4146
  * @public
@@ -5237,57 +5229,6 @@ export declare const fontWeightSemibold = "var(--fontWeightSemibold)";
5237
5229
  */
5238
5230
  export declare const forcedColorsStylesheetBehavior: (styles: ElementStyles) => MatchMediaStyleSheetBehavior;
5239
5231
 
5240
- /**
5241
- * Base function for providing Custom Element Form Association.
5242
- *
5243
- * @beta
5244
- */
5245
- declare function FormAssociated<T extends ConstructableFormAssociated>(BaseCtor: T): T;
5246
-
5247
- /**
5248
- * Base class for providing Custom Element Form Association.
5249
- *
5250
- * @beta
5251
- */
5252
- declare interface FormAssociated extends Omit<ElementInternals, 'labels'> {
5253
- dirtyValue: boolean;
5254
- disabled: boolean;
5255
- readonly elementInternals: ElementInternals | null;
5256
- readonly formAssociated: boolean;
5257
- initialValue: string;
5258
- readonly labels: ReadonlyArray<Node[]>;
5259
- name: string;
5260
- required: boolean;
5261
- value: string;
5262
- currentValue: string;
5263
- attachProxy(): void;
5264
- detachProxy(): void;
5265
- disabledChanged?(previous: boolean, next: boolean): void;
5266
- formDisabledCallback?(disabled: boolean): void;
5267
- formResetCallback(): void;
5268
- initialValueChanged?(previous: string, next: string): void;
5269
- nameChanged?(previous: string, next: string): void;
5270
- requiredChanged(prev: boolean, next: boolean): void;
5271
- stopPropagation(e: Event): void;
5272
- /**
5273
- * Sets the validity of the custom element. By default this uses the proxy element to determine
5274
- * validity, but this can be extended or replaced in implementation.
5275
- *
5276
- * @param anchor - The anchor element to provide to ElementInternals.setValidity for surfacing the browser's constraint validation UI
5277
- */
5278
- validate(anchor?: HTMLElement): void;
5279
- valueChanged(previous: string, next: string): void;
5280
- }
5281
-
5282
- /**
5283
- * @beta
5284
- */
5285
- declare class FormAssociatedSlider extends FormAssociatedSlider_base {
5286
- proxy: HTMLInputElement;
5287
- }
5288
-
5289
- declare const FormAssociatedSlider_base: typeof _Slider;
5290
-
5291
5232
  /**
5292
5233
  * Determines the current localization direction of an element.
5293
5234
  *
@@ -7174,9 +7115,34 @@ export declare const shadow8Brand = "var(--shadow8Brand)";
7174
7115
 
7175
7116
  /**
7176
7117
  * The base class used for constructing a fluent-slider custom element
7118
+ *
7119
+ * @slot thumb - The slot for a custom thumb element.
7120
+ * @csspart thumb-container - The container element of the thumb.
7121
+ * @csspart track-container - The container element of the track.
7122
+ * @fire change - Fires a custom 'change' event when the value changes.
7123
+ *
7177
7124
  * @public
7178
7125
  */
7179
- export declare class Slider extends FormAssociatedSlider implements SliderConfiguration {
7126
+ export declare class Slider extends FASTElement implements SliderConfiguration {
7127
+ /**
7128
+ * The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
7129
+ *
7130
+ * @internal
7131
+ */
7132
+ elementInternals: ElementInternals;
7133
+ /**
7134
+ * The form-associated flag.
7135
+ * @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example | Form-associated custom elements}
7136
+ *
7137
+ * @public
7138
+ */
7139
+ static formAssociated: boolean;
7140
+ /**
7141
+ * A reference to all associated `<label>` elements.
7142
+ *
7143
+ * @public
7144
+ */
7145
+ get labels(): ReadonlyArray<Node>;
7180
7146
  /**
7181
7147
  * The size of the slider
7182
7148
  * @public
@@ -7184,7 +7150,8 @@ export declare class Slider extends FormAssociatedSlider implements SliderConfig
7184
7150
  * HTML Attribute: size
7185
7151
  */
7186
7152
  size?: SliderSize;
7187
- handleChange(source: any, propertyName: string): void;
7153
+ protected sizeChanged(prev: string, next: string): void;
7154
+ handleChange(_: any, propertyName: string): void;
7188
7155
  private stepStyles?;
7189
7156
  /**
7190
7157
  * Handles changes to step styling based on the step value
@@ -7192,14 +7159,110 @@ export declare class Slider extends FormAssociatedSlider implements SliderConfig
7192
7159
  */
7193
7160
  private handleStepStyles;
7194
7161
  /**
7195
- * When true, the control 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.
7162
+ * The initial value of the input.
7196
7163
  *
7197
7164
  * @public
7198
7165
  * @remarks
7199
- * HTML Attribute: readonly
7166
+ * HTML Attribute: `value`
7200
7167
  */
7201
- readOnly: boolean;
7202
- protected readOnlyChanged(): void;
7168
+ initialValue: string;
7169
+ /**
7170
+ * Sets the value of the input when the value attribute changes.
7171
+ *
7172
+ * @param prev - The previous value
7173
+ * @param next - The current value
7174
+ * @internal
7175
+ */
7176
+ protected initialValueChanged(_: string, next: string): void;
7177
+ /**
7178
+ * The element's validity state.
7179
+ *
7180
+ * @public
7181
+ * @remarks
7182
+ * Reflects the {@link https://developer.mozilla.org/docs/Web/API/ElementInternals/validity | `ElementInternals.validity`} property.
7183
+ */
7184
+ get validity(): ValidityState;
7185
+ /**
7186
+ * The element's validation message.
7187
+ *
7188
+ * @public
7189
+ * @remarks
7190
+ * Reflects the {@link https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validationMessage | `ElemenentInternals.validationMessage`} property.
7191
+ */
7192
+ get validationMessage(): string;
7193
+ /**
7194
+ * Whether the element is a candidate for its owning form's constraint validation.
7195
+ *
7196
+ * @public
7197
+ * @remarks
7198
+ * Reflects the {@link https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate | `ElemenentInternals.willValidate`} property.
7199
+ */
7200
+ get willValidate(): boolean;
7201
+ /**
7202
+ * Checks the element's validity.
7203
+ * @public
7204
+ * @remarks
7205
+ * Reflects the {@link https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/checkValidity | `ElemenentInternals.checkValidity`} method.
7206
+ */
7207
+ checkValidity(): boolean;
7208
+ /**
7209
+ * Reports the element's validity.
7210
+ * @public
7211
+ * @remarks
7212
+ * Reflects the {@link https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/reportValidity | `ElemenentInternals.reportValidity`} method.
7213
+ */
7214
+ reportValidity(): boolean;
7215
+ /**
7216
+ * Sets a custom validity message.
7217
+ * @public
7218
+ */
7219
+ setCustomValidity(message: string): void;
7220
+ /**
7221
+ * Sets the validity of the control.
7222
+ *
7223
+ * @param flags - Validity flags to set.
7224
+ * @param message - Optional message to supply. If not provided, the control's `validationMessage` will be used.
7225
+ * @param anchor - Optional anchor to use for the validation message.
7226
+ *
7227
+ * @internal
7228
+ */
7229
+ setValidity(flags?: Partial<ValidityState>, message?: string, anchor?: HTMLElement): void;
7230
+ /**
7231
+ * The internal value of the input.
7232
+ *
7233
+ * @internal
7234
+ */
7235
+ private _value;
7236
+ /**
7237
+ * The current value of the input.
7238
+ *
7239
+ * @public
7240
+ */
7241
+ get value(): string;
7242
+ set value(value: string);
7243
+ /**
7244
+ * Resets the form value to its initial value when the form is reset.
7245
+ *
7246
+ * @internal
7247
+ */
7248
+ formResetCallback(): void;
7249
+ /**
7250
+ * Disabled the component when its associated form is disabled.
7251
+ *
7252
+ * @internal
7253
+ *
7254
+ * @privateRemarks
7255
+ * DO NOT change the `disabled` property or attribute here, because if the
7256
+ * `disabled` attribute is present, reenabling an ancestor `<fieldset>`
7257
+ * element will not reenabling this component.
7258
+ */
7259
+ formDisabledCallback(disabled: boolean): void;
7260
+ /**
7261
+ * Reflects the {@link https://developer.mozilla.org/docs/Web/API/ElementInternals/setFormValue | `ElementInternals.setFormValue()`} method.
7262
+ *
7263
+ * @internal
7264
+ */
7265
+ setFormValue(value: File | string | FormData | null, state?: File | string | FormData | null): void;
7203
7266
  /**
7204
7267
  * @internal
7205
7268
  */
@@ -7252,35 +7315,50 @@ export declare class Slider extends FormAssociatedSlider implements SliderConfig
7252
7315
  get valueAsNumber(): number;
7253
7316
  set valueAsNumber(next: number);
7254
7317
  /**
7255
- * Custom function that generates a string for the component's "aria-valuetext" attribute based on the current value.
7318
+ * Custom function that generates a string for the component's "ariaValueText" on element internals based on the current value.
7256
7319
  *
7257
7320
  * @public
7258
7321
  */
7259
- valueTextFormatter: (value: string) => string | null;
7322
+ valueTextFormatter: (value: string) => string;
7323
+ protected valueTextFormatterChanged(): void;
7260
7324
  /**
7261
- * @internal
7325
+ * The element's disabled state.
7326
+ * @public
7327
+ * @remarks
7328
+ * HTML Attribute: `disabled`
7262
7329
  */
7263
- valueChanged(previous: string, next: string): void;
7330
+ disabled: boolean;
7331
+ protected disabledChanged(): void;
7264
7332
  /**
7265
7333
  * The minimum allowed value.
7266
7334
  *
7267
- * @defaultValue - 0
7268
7335
  * @public
7269
7336
  * @remarks
7270
7337
  * HTML Attribute: min
7271
7338
  */
7272
- min: number;
7339
+ min: string;
7273
7340
  protected minChanged(): void;
7341
+ /**
7342
+ * Returns the min property or the default value
7343
+ *
7344
+ * @internal
7345
+ */
7346
+ private get minAsNumber();
7274
7347
  /**
7275
7348
  * The maximum allowed value.
7276
7349
  *
7277
- * @defaultValue - 10
7278
7350
  * @public
7279
7351
  * @remarks
7280
7352
  * HTML Attribute: max
7281
7353
  */
7282
- max: number;
7354
+ max: string;
7283
7355
  protected maxChanged(): void;
7356
+ /**
7357
+ * Returns the max property or the default value
7358
+ *
7359
+ * @internal
7360
+ */
7361
+ private get maxAsNumber();
7284
7362
  /**
7285
7363
  * Value to increment or decrement via arrow keys, mouse click or drag.
7286
7364
  *
@@ -7288,17 +7366,30 @@ export declare class Slider extends FormAssociatedSlider implements SliderConfig
7288
7366
  * @remarks
7289
7367
  * HTML Attribute: step
7290
7368
  */
7291
- step: number | undefined;
7369
+ step: string;
7292
7370
  protected stepChanged(): void;
7371
+ /**
7372
+ * Returns the step property as a number.
7373
+ *
7374
+ * @internal
7375
+ */
7376
+ private get stepAsNumber();
7293
7377
  /**
7294
7378
  * The orientation of the slider.
7295
7379
  *
7296
7380
  * @public
7297
7381
  * @remarks
7298
7382
  * HTML Attribute: orientation
7383
+ *
7384
+ * @privateRemarks
7385
+ * When checking the value of `this.orientation`, always compare it to
7386
+ * `Orientation.vertical`, never to `Orientation.horizontal`, it’s because
7387
+ * this property is optional, so it could be `undefined`. So any
7388
+ * orientation-related behavior should consider horizontal as default, and
7389
+ * apply different behavior when it’s vertical.
7299
7390
  */
7300
- orientation: Orientation;
7301
- protected orientationChanged(): void;
7391
+ orientation?: Orientation;
7392
+ protected orientationChanged(prev: string | undefined, next: string | undefined): void;
7302
7393
  /**
7303
7394
  * The selection mode.
7304
7395
  *
@@ -7307,6 +7398,7 @@ export declare class Slider extends FormAssociatedSlider implements SliderConfig
7307
7398
  * HTML Attribute: mode
7308
7399
  */
7309
7400
  mode: SliderMode;
7401
+ constructor();
7310
7402
  /**
7311
7403
  * @internal
7312
7404
  */
@@ -7327,19 +7419,13 @@ export declare class Slider extends FormAssociatedSlider implements SliderConfig
7327
7419
  * @public
7328
7420
  */
7329
7421
  decrement(): void;
7330
- keypressHandler: (e: KeyboardEvent) => void;
7331
- /**
7332
- * Gets the actual step value for the slider
7333
- *
7334
- */
7335
- private get stepValue();
7422
+ keypressHandler: (event: KeyboardEvent) => void;
7336
7423
  /**
7337
7424
  * Places the thumb based on the current value
7338
7425
  *
7339
- * @public
7340
7426
  * @param direction - writing mode
7341
7427
  */
7342
- private setThumbPositionForOrientation;
7428
+ private setSliderPosition;
7343
7429
  /**
7344
7430
  * Update the step multiplier used to ensure rounding errors from steps that
7345
7431
  * are not whole numbers
@@ -7347,21 +7433,17 @@ export declare class Slider extends FormAssociatedSlider implements SliderConfig
7347
7433
  private updateStepMultiplier;
7348
7434
  private setupTrackConstraints;
7349
7435
  private setupListeners;
7350
- /**
7351
- * @internal
7352
- */
7353
- initialValue: string;
7354
7436
  private get midpoint();
7355
7437
  private setupDefaultValue;
7356
7438
  /**
7357
7439
  * Handle mouse moves during a thumb drag operation
7358
7440
  * If the event handler is null it removes the events
7359
7441
  */
7360
- handleThumbMouseDown: (event: MouseEvent | null) => void;
7442
+ handleThumbPointerDown: (event: PointerEvent | null) => void;
7361
7443
  /**
7362
7444
  * Handle mouse moves during a thumb drag operation
7363
7445
  */
7364
- private handleMouseMove;
7446
+ private handlePointerMove;
7365
7447
  /**
7366
7448
  * Calculate the new value based on the given raw pixel value.
7367
7449
  *
@@ -7374,28 +7456,26 @@ export declare class Slider extends FormAssociatedSlider implements SliderConfig
7374
7456
  /**
7375
7457
  * Handle a window mouse up during a drag operation
7376
7458
  */
7377
- private handleWindowMouseUp;
7459
+ private handleWindowPointerUp;
7378
7460
  private stopDragging;
7379
7461
  /**
7380
7462
  *
7381
- * @param e - MouseEvent or null. If there is no event handler it will remove the events
7463
+ * @param event - PointerEvent or null. If there is no event handler it will remove the events
7382
7464
  */
7383
- handleMouseDown: (e: MouseEvent | null) => void;
7465
+ handlePointerDown: (event: PointerEvent | null) => void;
7384
7466
  private convertToConstrainedValue;
7385
- }
7386
-
7387
- declare class _Slider extends FASTElement {
7388
- }
7389
-
7390
- declare interface _Slider extends FormAssociated {
7467
+ /**
7468
+ * Makes sure the side effects of set up when the disabled state changes.
7469
+ */
7470
+ private setDisabledSideEffect;
7391
7471
  }
7392
7472
 
7393
7473
  /**
7394
7474
  * @public
7395
7475
  */
7396
7476
  export declare interface SliderConfiguration {
7397
- max: number;
7398
- min: number;
7477
+ max?: string;
7478
+ min?: string;
7399
7479
  orientation?: SliderOrientation;
7400
7480
  direction?: Direction;
7401
7481
  disabled?: boolean;