@fluentui/web-components 3.0.0-beta.90 → 3.0.0-beta.92
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.
- package/CHANGELOG.md +20 -2
- package/dist/dts/dropdown/dropdown.base.d.ts +39 -1
- package/dist/dts/tree-item/tree-item.base.d.ts +0 -18
- package/dist/esm/dropdown/dropdown.base.js +58 -4
- package/dist/esm/dropdown/dropdown.base.js.map +1 -1
- package/dist/esm/tree/tree.base.js +5 -9
- package/dist/esm/tree/tree.base.js.map +1 -1
- package/dist/esm/tree/tree.template.js +1 -1
- package/dist/esm/tree/tree.template.js.map +1 -1
- package/dist/esm/tree-item/tree-item.base.js +2 -31
- package/dist/esm/tree-item/tree-item.base.js.map +1 -1
- package/dist/esm/tree-item/tree-item.template.js +1 -3
- package/dist/esm/tree-item/tree-item.template.js.map +1 -1
- package/dist/web-components.d.ts +39 -19
- package/dist/web-components.js +65 -45
- package/dist/web-components.min.js +53 -53
- package/package.json +1 -1
- package/dist/dts/form-associated/form-associated.d.ts +0 -104
- package/dist/dts/slider/slider.form-associated.d.ts +0 -14
- package/dist/dts/switch/switch.form-associated.d.ts +0 -14
- package/dist/esm/form-associated/form-associated.js +0 -456
- package/dist/esm/form-associated/form-associated.js.map +0 -1
- package/dist/esm/slider/slider.form-associated.js +0 -14
- package/dist/esm/slider/slider.form-associated.js.map +0 -1
- package/dist/esm/switch/switch.form-associated.js +0 -14
- package/dist/esm/switch/switch.form-associated.js.map +0 -1
package/dist/web-components.js
CHANGED
|
@@ -7211,6 +7211,7 @@ const _BaseDropdown = class _BaseDropdown extends FASTElement {
|
|
|
7211
7211
|
this.enabledOptions.filter(x => x.defaultSelected).forEach((x, i) => {
|
|
7212
7212
|
x.selected = this.multiple || i === 0;
|
|
7213
7213
|
});
|
|
7214
|
+
this.setValidity();
|
|
7214
7215
|
});
|
|
7215
7216
|
}
|
|
7216
7217
|
}
|
|
@@ -7293,6 +7294,7 @@ const _BaseDropdown = class _BaseDropdown extends FASTElement {
|
|
|
7293
7294
|
}
|
|
7294
7295
|
this.selectOption(i);
|
|
7295
7296
|
});
|
|
7297
|
+
this.setValidity();
|
|
7296
7298
|
}
|
|
7297
7299
|
/**
|
|
7298
7300
|
* A reference to the first freeform option, if present.
|
|
@@ -7310,6 +7312,14 @@ const _BaseDropdown = class _BaseDropdown extends FASTElement {
|
|
|
7310
7312
|
get isCombobox() {
|
|
7311
7313
|
return this.type === DropdownType.combobox;
|
|
7312
7314
|
}
|
|
7315
|
+
/**
|
|
7316
|
+
* A reference to all associated label elements.
|
|
7317
|
+
*
|
|
7318
|
+
* @public
|
|
7319
|
+
*/
|
|
7320
|
+
get labels() {
|
|
7321
|
+
return Object.freeze(Array.from(this.elementInternals.labels));
|
|
7322
|
+
}
|
|
7313
7323
|
/**
|
|
7314
7324
|
* The collection of all child options.
|
|
7315
7325
|
*
|
|
@@ -7348,14 +7358,28 @@ const _BaseDropdown = class _BaseDropdown extends FASTElement {
|
|
|
7348
7358
|
if (this.elementInternals.validationMessage) {
|
|
7349
7359
|
return this.elementInternals.validationMessage;
|
|
7350
7360
|
}
|
|
7351
|
-
if (!this.
|
|
7361
|
+
if (!this._validationFallbackMessage) {
|
|
7352
7362
|
const validationMessageFallbackControl = document.createElement("input");
|
|
7353
7363
|
validationMessageFallbackControl.type = "radio";
|
|
7364
|
+
validationMessageFallbackControl.name = "validation-message-fallback";
|
|
7354
7365
|
validationMessageFallbackControl.required = true;
|
|
7355
7366
|
validationMessageFallbackControl.checked = false;
|
|
7356
|
-
this.
|
|
7367
|
+
this._validationFallbackMessage = validationMessageFallbackControl.validationMessage;
|
|
7368
|
+
}
|
|
7369
|
+
if (!this.disabled && this.required && this.listbox.selectedOptions.length === 0) {
|
|
7370
|
+
return this._validationFallbackMessage;
|
|
7357
7371
|
}
|
|
7358
|
-
return
|
|
7372
|
+
return "";
|
|
7373
|
+
}
|
|
7374
|
+
/**
|
|
7375
|
+
* The element's validity state.
|
|
7376
|
+
*
|
|
7377
|
+
* @public
|
|
7378
|
+
* @remarks
|
|
7379
|
+
* Reflects the {@link https://developer.mozilla.org/docs/Web/API/ElementInternals/validity | `ElementInternals.validity`} property.
|
|
7380
|
+
*/
|
|
7381
|
+
get validity() {
|
|
7382
|
+
return this.elementInternals.validity;
|
|
7359
7383
|
}
|
|
7360
7384
|
/**
|
|
7361
7385
|
* The current value of the selected option.
|
|
@@ -7373,6 +7397,16 @@ const _BaseDropdown = class _BaseDropdown extends FASTElement {
|
|
|
7373
7397
|
this.selectOption(this.enabledOptions.findIndex(x => x.value === next));
|
|
7374
7398
|
Observable.track(this, "value");
|
|
7375
7399
|
}
|
|
7400
|
+
/**
|
|
7401
|
+
* Determines if the control can be submitted for constraint validation.
|
|
7402
|
+
*
|
|
7403
|
+
* @public
|
|
7404
|
+
* @remarks
|
|
7405
|
+
* Reflects the {@link https://developer.mozilla.org/docs/Web/API/ElementInternals/willValidate | `ElementInternals.willValidate`} property.
|
|
7406
|
+
*/
|
|
7407
|
+
get willValidate() {
|
|
7408
|
+
return this.elementInternals.willValidate;
|
|
7409
|
+
}
|
|
7376
7410
|
/**
|
|
7377
7411
|
* Handles the change events for the dropdown.
|
|
7378
7412
|
*
|
|
@@ -7388,6 +7422,16 @@ const _BaseDropdown = class _BaseDropdown extends FASTElement {
|
|
|
7388
7422
|
this.selectOption(optionIndex, true);
|
|
7389
7423
|
return true;
|
|
7390
7424
|
}
|
|
7425
|
+
/**
|
|
7426
|
+
* Checks the validity of the element and returns the result.
|
|
7427
|
+
*
|
|
7428
|
+
* @public
|
|
7429
|
+
* @remarks
|
|
7430
|
+
* Reflects the {@link https://developer.mozilla.org/docs/Web/API/ElementInternals/checkValidity | `HTMLInputElement.checkValidity()`} method.
|
|
7431
|
+
*/
|
|
7432
|
+
checkValidity() {
|
|
7433
|
+
return this.elementInternals.checkValidity();
|
|
7434
|
+
}
|
|
7391
7435
|
/**
|
|
7392
7436
|
* Handles the click events for the dropdown.
|
|
7393
7437
|
*
|
|
@@ -7592,6 +7636,16 @@ const _BaseDropdown = class _BaseDropdown extends FASTElement {
|
|
|
7592
7636
|
}
|
|
7593
7637
|
return !isDropdownOption(e.target);
|
|
7594
7638
|
}
|
|
7639
|
+
/**
|
|
7640
|
+
* Reports the validity of the element.
|
|
7641
|
+
*
|
|
7642
|
+
* @public
|
|
7643
|
+
* @remarks
|
|
7644
|
+
* Reflects the {@link https://developer.mozilla.org/docs/Web/API/ElementInternals/reportValidity | `HTMLInputElement.reportValidity()`} method.
|
|
7645
|
+
*/
|
|
7646
|
+
reportValidity() {
|
|
7647
|
+
return this.elementInternals.reportValidity();
|
|
7648
|
+
}
|
|
7595
7649
|
/**
|
|
7596
7650
|
* Selects an option by index.
|
|
7597
7651
|
*
|
|
@@ -7626,7 +7680,7 @@ const _BaseDropdown = class _BaseDropdown extends FASTElement {
|
|
|
7626
7680
|
this.elementInternals.setValidity({
|
|
7627
7681
|
valueMissing,
|
|
7628
7682
|
...flags
|
|
7629
|
-
}, message ?? this.validationMessage, anchor ?? this.
|
|
7683
|
+
}, message ?? this.validationMessage, anchor ?? this.control);
|
|
7630
7684
|
}
|
|
7631
7685
|
}
|
|
7632
7686
|
/**
|
|
@@ -13219,7 +13273,7 @@ class BaseTree extends FASTElement {
|
|
|
13219
13273
|
* Updates current selected when slottedTreeItems changes
|
|
13220
13274
|
*/
|
|
13221
13275
|
updateCurrentSelected() {
|
|
13222
|
-
const selectedItem = this.querySelector(`[
|
|
13276
|
+
const selectedItem = this.querySelector(`[selected]`);
|
|
13223
13277
|
this.currentSelected = selectedItem;
|
|
13224
13278
|
if (this.currentFocused === null || !this.contains(this.currentFocused)) {
|
|
13225
13279
|
this.currentFocused = this.getValidFocusableItem();
|
|
@@ -13291,7 +13345,7 @@ class BaseTree extends FASTElement {
|
|
|
13291
13345
|
}
|
|
13292
13346
|
case keySpace:
|
|
13293
13347
|
{
|
|
13294
|
-
item.
|
|
13348
|
+
item.selected = true;
|
|
13295
13349
|
return;
|
|
13296
13350
|
}
|
|
13297
13351
|
}
|
|
@@ -13307,12 +13361,8 @@ class BaseTree extends FASTElement {
|
|
|
13307
13361
|
return;
|
|
13308
13362
|
}
|
|
13309
13363
|
if (e.target === this) {
|
|
13310
|
-
|
|
13311
|
-
|
|
13312
|
-
}
|
|
13313
|
-
if (this.currentFocused !== null) {
|
|
13314
|
-
this.currentFocused.focus();
|
|
13315
|
-
}
|
|
13364
|
+
this.currentFocused = this.getValidFocusableItem();
|
|
13365
|
+
this.currentFocused?.focus();
|
|
13316
13366
|
return;
|
|
13317
13367
|
}
|
|
13318
13368
|
if (this.contains(e.target)) {
|
|
@@ -13344,7 +13394,7 @@ class BaseTree extends FASTElement {
|
|
|
13344
13394
|
}
|
|
13345
13395
|
const item = e.target;
|
|
13346
13396
|
item.toggleExpansion();
|
|
13347
|
-
item.
|
|
13397
|
+
item.selected = true;
|
|
13348
13398
|
}
|
|
13349
13399
|
/**
|
|
13350
13400
|
* Handles the selected-changed events bubbling up
|
|
@@ -13539,6 +13589,7 @@ class BaseTreeItem extends FASTElement {
|
|
|
13539
13589
|
if (!this.childTreeItems?.length) {
|
|
13540
13590
|
return;
|
|
13541
13591
|
}
|
|
13592
|
+
this.expanded = Array.from(this.querySelectorAll("*")).some(el => isTreeItem(el) && el.selected);
|
|
13542
13593
|
this.childTreeItems.forEach(item => {
|
|
13543
13594
|
this.setIndent(item);
|
|
13544
13595
|
});
|
|
@@ -13550,29 +13601,6 @@ class BaseTreeItem extends FASTElement {
|
|
|
13550
13601
|
const indent = this.dataIndent ?? 0;
|
|
13551
13602
|
item.dataIndent = indent + 1;
|
|
13552
13603
|
}
|
|
13553
|
-
/**
|
|
13554
|
-
* Handle focus events
|
|
13555
|
-
*
|
|
13556
|
-
* @public
|
|
13557
|
-
*/
|
|
13558
|
-
focusHandler(e) {
|
|
13559
|
-
if (e.target === this ||
|
|
13560
|
-
// In case where the tree-item contains a focusable element, we should not set the tabindex to 0 when the focus is on its child focusable element,
|
|
13561
|
-
// so users can shift+tab to navigate to the tree-item from its child focusable element.
|
|
13562
|
-
this.contains(e.target)) {
|
|
13563
|
-
this.setAttribute("tabindex", "0");
|
|
13564
|
-
}
|
|
13565
|
-
}
|
|
13566
|
-
/**
|
|
13567
|
-
* Handle blur events
|
|
13568
|
-
*
|
|
13569
|
-
* @public
|
|
13570
|
-
*/
|
|
13571
|
-
blurHandler(e) {
|
|
13572
|
-
if (e.target === this) {
|
|
13573
|
-
this.setAttribute("tabindex", "-1");
|
|
13574
|
-
}
|
|
13575
|
-
}
|
|
13576
13604
|
/**
|
|
13577
13605
|
* Toggle the expansion state of the tree item
|
|
13578
13606
|
*
|
|
@@ -13583,14 +13611,6 @@ class BaseTreeItem extends FASTElement {
|
|
|
13583
13611
|
this.expanded = !this.expanded;
|
|
13584
13612
|
}
|
|
13585
13613
|
}
|
|
13586
|
-
/**
|
|
13587
|
-
* Toggle the single selection state of the tree item
|
|
13588
|
-
*
|
|
13589
|
-
* @public
|
|
13590
|
-
*/
|
|
13591
|
-
toggleSelection() {
|
|
13592
|
-
this.selected = !this.selected;
|
|
13593
|
-
}
|
|
13594
13614
|
/**
|
|
13595
13615
|
* Whether the tree is nested
|
|
13596
13616
|
* @internal
|
|
@@ -13677,7 +13697,7 @@ const styles = css`
|
|
|
13677
13697
|
${colorStrokeFocus2} inset}.positioning-region{display:flex;align-items:center;justify-content:space-between;cursor:pointer;height:${spacingVerticalXXXL};padding-inline-start:calc(var(--indent) * ${spacingHorizontalXXL});padding-inline-end:${spacingVerticalS};border-radius:${borderRadiusMedium};background-color:${colorSubtleBackground};color:${colorNeutralForeground2};gap:${spacingHorizontalXS}}@media (prefers-contrast:more){:host(:focus-visible) .positioning-region{outline:1px solid ${colorStrokeFocus2}}}.content{display:flex;align-items:center;gap:${spacingHorizontalXS}}.chevron{display:flex;align-items:center;flex-shrink:0;justify-content:center;width:${spacingHorizontalXXL};height:${spacingVerticalXXL};transition:transform ${durationFaster} ${curveEasyEaseMax};transform:rotate(0deg)}.chevron:dir(rtl){transform:rotate(180deg)}.aside{display:flex;align-items:center}.positioning-region:hover{background-color:${colorSubtleBackgroundHover};color:${colorNeutralForeground2Hover}}.positioning-region:active{background-color:${colorSubtleBackgroundPressed};color:${colorNeutralForeground2Pressed}}::slotted([slot='start']),::slotted([slot='end']),::slotted(:not([slot])){display:flex;align-items:center;min-width:0}::slotted([slot='start']){flex-shrink:0}::slotted(:not([slot])){padding-inline:${spacingHorizontalXXS}}.items{display:none}:host([expanded]) .items{display:block}:host([empty]) .chevron,:host([empty]) .items{visibility:hidden}:host([selected]) .positioning-region{background-color:${colorSubtleBackgroundSelected};color:${colorNeutralForeground2Selected}}:host([selected]) .content,:host([selected]) .chevron{color:${colorNeutralForeground3Selected}}:host([size='small']) .positioning-region{height:${spacingVerticalXXL};padding-inline-start:calc(var(--indent) * ${spacingHorizontalM})}:host([appearance='subtle-alpha']) .positioning-region:hover{background-color:${colorSubtleBackgroundLightAlphaHover}}:host([appearance='subtle-alpha']) .positioning-region:active{background-color:${colorSubtleBackgroundLightAlphaPressed}}:host([appearance='subtle-alpha'][selected]) .positioning-region{background-color:${colorSubtleBackgroundLightAlphaSelected};color:${colorNeutralForeground2Selected}}:host([appearance='transparent']) .positioning-region{background-color:${colorTransparentBackground}}:host([appearance='transparent']) .positioning-region:hover{background-color:${colorTransparentBackgroundHover}}:host([appearance='transparent']) .positioning-region:active{background-color:${colorTransparentBackgroundPressed}}:host([appearance='transparent'][selected]) .positioning-region{background-color:${colorTransparentBackgroundSelected};color:${colorNeutralForeground2Selected}}:host([expanded]) .chevron{transform:rotate(90deg)}`;
|
|
13678
13698
|
|
|
13679
13699
|
const chevronIcon = html`<svg width="12" height="12" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="M4.65 2.15a.5.5 0 000 .7L7.79 6 4.65 9.15a.5.5 0 10.7.7l3.5-3.5a.5.5 0 000-.7l-3.5-3.5a.5.5 0 00-.7 0z"></path></svg>`;
|
|
13680
|
-
const template = html`<template tabindex="
|
|
13700
|
+
const template = html`<template tabindex="${x => x.selected ? 0 : -1}" slot="${x => x.isNestedItem ? "item" : void 0}" ${children({
|
|
13681
13701
|
property: "childTreeItems",
|
|
13682
13702
|
filter: node => isTreeItem(node)
|
|
13683
13703
|
})}><div class="positioning-region" part="positioning-region"><div class="content" part="content"><span class="chevron" part="chevron"><slot name="chevron">${chevronIcon}</slot></span><slot name="start"></slot><slot></slot><slot name="end"></slot></div><div class="aside" part="aside"><slot name="aside"></slot></div></div><div role="group" class="items" part="items"><slot name="item"></slot></div></template>`;
|