@fluentui/web-components 3.0.0-rc.11 → 3.0.0-rc.12
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 +11 -2
- package/custom-elements.json +116 -116
- package/dist/esm/accordion/accordion.d.ts +2 -1
- package/dist/esm/accordion/accordion.js +52 -49
- package/dist/esm/accordion/accordion.js.map +1 -1
- package/dist/esm/accordion-item/accordion-item.options.d.ts +11 -1
- package/dist/esm/accordion-item/accordion-item.options.js +12 -0
- package/dist/esm/accordion-item/accordion-item.options.js.map +1 -1
- package/dist/web-components.d.ts +2 -1
- package/dist/web-components.js +75 -61
- package/dist/web-components.min.js +150 -150
- package/package.json +1 -1
package/dist/web-components.js
CHANGED
|
@@ -4636,6 +4636,38 @@ const definition$F = AccordionItem.compose({
|
|
|
4636
4636
|
|
|
4637
4637
|
definition$F.define(FluentDesignSystem.registry);
|
|
4638
4638
|
|
|
4639
|
+
function requestIdleCallback(callback, options) {
|
|
4640
|
+
if ("requestIdleCallback" in globalThis) {
|
|
4641
|
+
return globalThis.requestIdleCallback(callback, options);
|
|
4642
|
+
}
|
|
4643
|
+
const start = Date.now();
|
|
4644
|
+
return setTimeout(() => {
|
|
4645
|
+
callback({
|
|
4646
|
+
didTimeout: options?.timeout ? Date.now() - start >= options.timeout : false,
|
|
4647
|
+
timeRemaining: () => 0
|
|
4648
|
+
});
|
|
4649
|
+
}, 1);
|
|
4650
|
+
}
|
|
4651
|
+
function waitForConnectedDescendants(target, callback, options) {
|
|
4652
|
+
const shallow = options?.shallow ?? false;
|
|
4653
|
+
const timeout = options?.timeout ?? 50;
|
|
4654
|
+
const selector = `${shallow ? ":scope > " : ""}:not(:defined)`;
|
|
4655
|
+
const scheduleCheck = deadline => {
|
|
4656
|
+
if (target.querySelector(selector) === null || deadline && deadline.timeRemaining() <= 0) {
|
|
4657
|
+
requestAnimationFrame(callback);
|
|
4658
|
+
return;
|
|
4659
|
+
}
|
|
4660
|
+
requestIdleCallback(scheduleCheck, {
|
|
4661
|
+
timeout
|
|
4662
|
+
});
|
|
4663
|
+
};
|
|
4664
|
+
scheduleCheck();
|
|
4665
|
+
}
|
|
4666
|
+
|
|
4667
|
+
function isAccordionItem(element, tagName = "-accordion-item") {
|
|
4668
|
+
return isCustomElement(tagName)(element);
|
|
4669
|
+
}
|
|
4670
|
+
|
|
4639
4671
|
const AccordionExpandMode = {
|
|
4640
4672
|
single: "single",
|
|
4641
4673
|
multi: "multi"
|
|
@@ -4652,7 +4684,6 @@ var __decorateClass$M = (decorators, target, key, kind) => {
|
|
|
4652
4684
|
class Accordion extends FASTElement {
|
|
4653
4685
|
constructor() {
|
|
4654
4686
|
super(...arguments);
|
|
4655
|
-
this.expandmode = AccordionExpandMode.multi;
|
|
4656
4687
|
this.activeItemIndex = 0;
|
|
4657
4688
|
/**
|
|
4658
4689
|
* Resets event listeners and sets the `accordionItems` property
|
|
@@ -4660,21 +4691,23 @@ class Accordion extends FASTElement {
|
|
|
4660
4691
|
* @returns {void}
|
|
4661
4692
|
*/
|
|
4662
4693
|
this.setItems = () => {
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4694
|
+
waitForConnectedDescendants(this, () => {
|
|
4695
|
+
if (this.slottedAccordionItems.length === 0) {
|
|
4696
|
+
return;
|
|
4697
|
+
}
|
|
4698
|
+
const children = Array.from(this.children);
|
|
4699
|
+
this.removeItemListeners(children);
|
|
4700
|
+
children.forEach(child => Observable.getNotifier(child).subscribe(this, "disabled"));
|
|
4701
|
+
this.accordionItems = children.filter(child => !child.hasAttribute("disabled"));
|
|
4702
|
+
this.accordionItems.forEach((item, index) => {
|
|
4703
|
+
item.addEventListener("click", this.expandedChangedHandler);
|
|
4704
|
+
Observable.getNotifier(item).subscribe(this, "expanded");
|
|
4705
|
+
});
|
|
4706
|
+
if (this.isSingleExpandMode()) {
|
|
4707
|
+
const expandedItem = this.findExpandedItem();
|
|
4708
|
+
this.setSingleExpandMode(expandedItem);
|
|
4709
|
+
}
|
|
4673
4710
|
});
|
|
4674
|
-
if (this.isSingleExpandMode()) {
|
|
4675
|
-
const expandedItem = this.findExpandedItem();
|
|
4676
|
-
this.setSingleExpandMode(expandedItem);
|
|
4677
|
-
}
|
|
4678
4711
|
};
|
|
4679
4712
|
/**
|
|
4680
4713
|
* Removes event listeners from the previous accordion items
|
|
@@ -4694,7 +4727,7 @@ class Accordion extends FASTElement {
|
|
|
4694
4727
|
*/
|
|
4695
4728
|
this.expandedChangedHandler = evt => {
|
|
4696
4729
|
const item = evt.target;
|
|
4697
|
-
if (item
|
|
4730
|
+
if (isAccordionItem(item)) {
|
|
4698
4731
|
if (!this.isSingleExpandMode()) {
|
|
4699
4732
|
item.expanded = !item.expanded;
|
|
4700
4733
|
this.activeItemIndex = this.accordionItems.indexOf(item);
|
|
@@ -4745,10 +4778,10 @@ class Accordion extends FASTElement {
|
|
|
4745
4778
|
* @returns {void}
|
|
4746
4779
|
*/
|
|
4747
4780
|
findExpandedItem() {
|
|
4748
|
-
if (this.accordionItems.length === 0) {
|
|
4781
|
+
if (!this.accordionItems || this.accordionItems?.length === 0) {
|
|
4749
4782
|
return null;
|
|
4750
4783
|
}
|
|
4751
|
-
return this.accordionItems.find(item => item
|
|
4784
|
+
return this.accordionItems.find(item => isAccordionItem(item) && item.expanded) ?? this.accordionItems[0];
|
|
4752
4785
|
}
|
|
4753
4786
|
/**
|
|
4754
4787
|
* Checks if the accordion is in single expand mode
|
|
@@ -4763,23 +4796,32 @@ class Accordion extends FASTElement {
|
|
|
4763
4796
|
* @returns {void}
|
|
4764
4797
|
*/
|
|
4765
4798
|
setSingleExpandMode(expandedItem) {
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
if (
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
item.
|
|
4799
|
+
requestAnimationFrame(() => {
|
|
4800
|
+
if (this.accordionItems.length === 0) {
|
|
4801
|
+
return;
|
|
4802
|
+
}
|
|
4803
|
+
const currentItems = Array.from(this.accordionItems);
|
|
4804
|
+
this.activeItemIndex = currentItems.indexOf(expandedItem);
|
|
4805
|
+
currentItems.forEach((item, index) => {
|
|
4806
|
+
if (isAccordionItem(item)) {
|
|
4807
|
+
if (this.activeItemIndex === index) {
|
|
4808
|
+
item.expanded = true;
|
|
4809
|
+
item.expandbutton.setAttribute("aria-disabled", "true");
|
|
4810
|
+
} else {
|
|
4811
|
+
item.expanded = false;
|
|
4812
|
+
if (!item.hasAttribute("disabled")) {
|
|
4813
|
+
item.expandbutton.removeAttribute("aria-disabled");
|
|
4814
|
+
}
|
|
4780
4815
|
}
|
|
4781
4816
|
}
|
|
4782
|
-
}
|
|
4817
|
+
});
|
|
4818
|
+
});
|
|
4819
|
+
}
|
|
4820
|
+
connectedCallback() {
|
|
4821
|
+
super.connectedCallback();
|
|
4822
|
+
requestAnimationFrame(() => {
|
|
4823
|
+
this.expandmode = this.expandmode || AccordionExpandMode.multi;
|
|
4824
|
+
this.setItems();
|
|
4783
4825
|
});
|
|
4784
4826
|
}
|
|
4785
4827
|
}
|
|
@@ -7229,34 +7271,6 @@ function getLanguage(rootNode) {
|
|
|
7229
7271
|
return rootNode.closest("[lang]")?.lang ?? "en";
|
|
7230
7272
|
}
|
|
7231
7273
|
|
|
7232
|
-
function requestIdleCallback(callback, options) {
|
|
7233
|
-
if ("requestIdleCallback" in globalThis) {
|
|
7234
|
-
return globalThis.requestIdleCallback(callback, options);
|
|
7235
|
-
}
|
|
7236
|
-
const start = Date.now();
|
|
7237
|
-
return setTimeout(() => {
|
|
7238
|
-
callback({
|
|
7239
|
-
didTimeout: options?.timeout ? Date.now() - start >= options.timeout : false,
|
|
7240
|
-
timeRemaining: () => 0
|
|
7241
|
-
});
|
|
7242
|
-
}, 1);
|
|
7243
|
-
}
|
|
7244
|
-
function waitForConnectedDescendants(target, callback, options) {
|
|
7245
|
-
const shallow = options?.shallow ?? false;
|
|
7246
|
-
const timeout = options?.timeout ?? 50;
|
|
7247
|
-
const selector = `${shallow ? ":scope > " : ""}:not(:defined)`;
|
|
7248
|
-
const scheduleCheck = deadline => {
|
|
7249
|
-
if (target.querySelector(selector) === null || deadline && deadline.timeRemaining() <= 0) {
|
|
7250
|
-
requestAnimationFrame(callback);
|
|
7251
|
-
return;
|
|
7252
|
-
}
|
|
7253
|
-
requestIdleCallback(scheduleCheck, {
|
|
7254
|
-
timeout
|
|
7255
|
-
});
|
|
7256
|
-
};
|
|
7257
|
-
scheduleCheck();
|
|
7258
|
-
}
|
|
7259
|
-
|
|
7260
7274
|
let uniqueIdCounter = 0;
|
|
7261
7275
|
function uniqueId(prefix = "id-") {
|
|
7262
7276
|
const str = `${prefix}${uniqueIdCounter++}`;
|