@fluentui/web-components 3.0.0-rc.11 → 3.0.0-rc.13

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 (33) hide show
  1. package/CHANGELOG.md +20 -2
  2. package/custom-elements.json +1091 -288
  3. package/dist/esm/accordion/accordion.d.ts +2 -1
  4. package/dist/esm/accordion/accordion.js +52 -49
  5. package/dist/esm/accordion/accordion.js.map +1 -1
  6. package/dist/esm/accordion-item/accordion-item.options.d.ts +11 -1
  7. package/dist/esm/accordion-item/accordion-item.options.js +12 -0
  8. package/dist/esm/accordion-item/accordion-item.options.js.map +1 -1
  9. package/dist/esm/index.d.ts +2 -2
  10. package/dist/esm/index.js +2 -2
  11. package/dist/esm/index.js.map +1 -1
  12. package/dist/esm/menu-list/index.d.ts +1 -0
  13. package/dist/esm/menu-list/index.js +1 -0
  14. package/dist/esm/menu-list/index.js.map +1 -1
  15. package/dist/esm/menu-list/menu-list.base.d.ts +76 -0
  16. package/dist/esm/menu-list/menu-list.base.js +251 -0
  17. package/dist/esm/menu-list/menu-list.base.js.map +1 -0
  18. package/dist/esm/menu-list/menu-list.d.ts +3 -70
  19. package/dist/esm/menu-list/menu-list.js +3 -244
  20. package/dist/esm/menu-list/menu-list.js.map +1 -1
  21. package/dist/esm/radio-group/index.d.ts +1 -0
  22. package/dist/esm/radio-group/index.js +1 -0
  23. package/dist/esm/radio-group/index.js.map +1 -1
  24. package/dist/esm/radio-group/radio-group.base.d.ts +285 -0
  25. package/dist/esm/radio-group/radio-group.base.js +497 -0
  26. package/dist/esm/radio-group/radio-group.base.js.map +1 -0
  27. package/dist/esm/radio-group/radio-group.d.ts +4 -280
  28. package/dist/esm/radio-group/radio-group.js +4 -491
  29. package/dist/esm/radio-group/radio-group.js.map +1 -1
  30. package/dist/web-components.d.ts +1847 -1828
  31. package/dist/web-components.js +95 -77
  32. package/dist/web-components.min.js +150 -150
  33. package/package.json +1 -1
@@ -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
- if (this.slottedAccordionItems.length === 0) {
4664
- return;
4665
- }
4666
- const children = Array.from(this.children);
4667
- this.removeItemListeners(children);
4668
- children.forEach(child => Observable.getNotifier(child).subscribe(this, "disabled"));
4669
- this.accordionItems = children.filter(child => !child.hasAttribute("disabled"));
4670
- this.accordionItems.forEach((item, index) => {
4671
- item.addEventListener("click", this.expandedChangedHandler);
4672
- Observable.getNotifier(item).subscribe(this, "expanded");
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 instanceof BaseAccordionItem) {
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 instanceof BaseAccordionItem && item.expanded) ?? this.accordionItems[0];
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
- if (this.accordionItems.length === 0) {
4767
- return;
4768
- }
4769
- const currentItems = Array.from(this.accordionItems);
4770
- this.activeItemIndex = currentItems.indexOf(expandedItem);
4771
- currentItems.forEach((item, index) => {
4772
- if (item instanceof BaseAccordionItem) {
4773
- if (this.activeItemIndex === index) {
4774
- item.expanded = true;
4775
- item.expandbutton.setAttribute("aria-disabled", "true");
4776
- } else {
4777
- item.expanded = false;
4778
- if (!item.hasAttribute("disabled")) {
4779
- item.expandbutton.removeAttribute("aria-disabled");
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++}`;
@@ -8923,7 +8937,7 @@ var __decorateClass$o = (decorators, target, key, kind) => {
8923
8937
  if (kind && result) __defProp$o(target, key, result);
8924
8938
  return result;
8925
8939
  };
8926
- const _MenuList = class _MenuList extends FASTElement {
8940
+ const _BaseMenuList = class _BaseMenuList extends FASTElement {
8927
8941
  constructor() {
8928
8942
  super();
8929
8943
  /**
@@ -9003,7 +9017,7 @@ const _MenuList = class _MenuList extends FASTElement {
9003
9017
  * check if the item is a menu item
9004
9018
  */
9005
9019
  this.isMenuItemElement = el => {
9006
- return isMenuItem(el) || isHTMLElement(el) && !!el.role && el.role in _MenuList.focusableElementRoles;
9020
+ return isMenuItem(el) || isHTMLElement(el) && !!el.role && el.role in _BaseMenuList.focusableElementRoles;
9007
9021
  };
9008
9022
  /**
9009
9023
  * check if the item is focusable
@@ -9099,7 +9113,7 @@ const _MenuList = class _MenuList extends FASTElement {
9099
9113
  });
9100
9114
  const filteredMenuListItems = this.menuItems?.filter(this.isMenuItemElement);
9101
9115
  const indent = filteredMenuListItems?.reduce((accum, current) => {
9102
- const elementValue = _MenuList.elementIndent(current);
9116
+ const elementValue = _BaseMenuList.elementIndent(current);
9103
9117
  return Math.max(accum, elementValue);
9104
9118
  }, 0);
9105
9119
  filteredMenuListItems?.forEach(item => {
@@ -9133,9 +9147,11 @@ const _MenuList = class _MenuList extends FASTElement {
9133
9147
  }
9134
9148
  }
9135
9149
  };
9136
- _MenuList.focusableElementRoles = MenuItemRole;
9137
- __decorateClass$o([observable], _MenuList.prototype, "items", 2);
9138
- let MenuList = _MenuList;
9150
+ _BaseMenuList.focusableElementRoles = MenuItemRole;
9151
+ __decorateClass$o([observable], _BaseMenuList.prototype, "items", 2);
9152
+ let BaseMenuList = _BaseMenuList;
9153
+
9154
+ class MenuList extends BaseMenuList {}
9139
9155
 
9140
9156
  const styles$j = css`
9141
9157
  ${display("flex")}
@@ -10018,7 +10034,7 @@ var __decorateClass$i = (decorators, target, key, kind) => {
10018
10034
  if (kind && result) __defProp$i(target, key, result);
10019
10035
  return result;
10020
10036
  };
10021
- class RadioGroup extends FASTElement {
10037
+ class BaseRadioGroup extends FASTElement {
10022
10038
  constructor() {
10023
10039
  super();
10024
10040
  /**
@@ -10474,23 +10490,25 @@ class RadioGroup extends FASTElement {
10474
10490
  *
10475
10491
  * @public
10476
10492
  */
10477
- RadioGroup.formAssociated = true;
10478
- __decorateClass$i([observable], RadioGroup.prototype, "checkedIndex", 2);
10493
+ BaseRadioGroup.formAssociated = true;
10494
+ __decorateClass$i([observable], BaseRadioGroup.prototype, "checkedIndex", 2);
10479
10495
  __decorateClass$i([attr({
10480
10496
  attribute: "disabled",
10481
10497
  mode: "boolean"
10482
- })], RadioGroup.prototype, "disabled", 2);
10498
+ })], BaseRadioGroup.prototype, "disabled", 2);
10483
10499
  __decorateClass$i([attr({
10484
10500
  attribute: "value",
10485
10501
  mode: "fromView"
10486
- })], RadioGroup.prototype, "initialValue", 2);
10487
- __decorateClass$i([attr], RadioGroup.prototype, "name", 2);
10488
- __decorateClass$i([attr], RadioGroup.prototype, "orientation", 2);
10489
- __decorateClass$i([observable], RadioGroup.prototype, "radios", 2);
10502
+ })], BaseRadioGroup.prototype, "initialValue", 2);
10503
+ __decorateClass$i([attr], BaseRadioGroup.prototype, "name", 2);
10504
+ __decorateClass$i([attr], BaseRadioGroup.prototype, "orientation", 2);
10505
+ __decorateClass$i([observable], BaseRadioGroup.prototype, "radios", 2);
10490
10506
  __decorateClass$i([attr({
10491
10507
  mode: "boolean"
10492
- })], RadioGroup.prototype, "required", 2);
10493
- __decorateClass$i([observable], RadioGroup.prototype, "slottedRadios", 2);
10508
+ })], BaseRadioGroup.prototype, "required", 2);
10509
+ __decorateClass$i([observable], BaseRadioGroup.prototype, "slottedRadios", 2);
10510
+
10511
+ class RadioGroup extends BaseRadioGroup {}
10494
10512
 
10495
10513
  const styles$e = css`
10496
10514
  ${display("flex")}