@fluentui/web-components 2.5.15 → 2.5.17

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.
@@ -231,7 +231,7 @@ export declare const allComponents: {
231
231
  fluentTooltip: (overrideDefinition?: OverrideFoundationElementDefinition<FoundationElementDefinition> | undefined) => FoundationElementRegistry<FoundationElementDefinition, Tooltip>;
232
232
  fluentTreeView: (overrideDefinition?: OverrideFoundationElementDefinition<FoundationElementDefinition> | undefined) => FoundationElementRegistry<FoundationElementDefinition, typeof TreeView>;
233
233
  fluentTreeItem: (overrideDefinition?: OverrideFoundationElementDefinition<TreeItemOptions> | undefined) => FoundationElementRegistry<TreeItemOptions, Constructable<FoundationElement>>;
234
- register(container?: Container | undefined, ...rest: any[]): void;
234
+ register(container?: Container, ...rest: any[]): void;
235
235
  };
236
236
 
237
237
  /**
@@ -2719,14 +2719,12 @@ function intersect(start1, end1, start2, end2) {
2719
2719
  if (end1 < end2) {
2720
2720
  return end1 - start2; // Overlap
2721
2721
  }
2722
-
2723
2722
  return end2 - start2; // Contained
2724
2723
  }
2725
2724
  // Non-zero intersect, span2 first
2726
2725
  if (end2 < end1) {
2727
2726
  return end2 - start1; // Overlap
2728
2727
  }
2729
-
2730
2728
  return end1 - start1; // Contained
2731
2729
  }
2732
2730
  /**
@@ -2821,7 +2819,6 @@ function calcSplices(current, currentStart, currentEnd, old, oldStart, oldEnd) {
2821
2819
  // no default
2822
2820
  }
2823
2821
  }
2824
-
2825
2822
  if (splice !== void 0) {
2826
2823
  splices.push(splice);
2827
2824
  }
@@ -3113,16 +3110,30 @@ function ref(propertyName) {
3113
3110
  return new AttachedBehaviorHTMLDirective("fast-ref", RefBehavior, propertyName);
3114
3111
  }
3115
3112
 
3113
+ /**
3114
+ * Determines whether or not an object is a function.
3115
+ * @public
3116
+ */
3117
+ const isFunction = object => typeof object === "function";
3118
+
3119
+ const noTemplate = () => null;
3120
+ function normalizeBinding(value) {
3121
+ return value === undefined ? noTemplate : isFunction(value) ? value : () => value;
3122
+ }
3116
3123
  /**
3117
3124
  * A directive that enables basic conditional rendering in a template.
3118
3125
  * @param binding - The condition to test for rendering.
3119
3126
  * @param templateOrTemplateBinding - The template or a binding that gets
3120
3127
  * the template to render when the condition is true.
3128
+ * @param elseTemplateOrTemplateBinding - Optional template or binding that that
3129
+ * gets the template to render when the conditional is false.
3121
3130
  * @public
3122
3131
  */
3123
- function when(binding, templateOrTemplateBinding) {
3124
- const getTemplate = typeof templateOrTemplateBinding === "function" ? templateOrTemplateBinding : () => templateOrTemplateBinding;
3125
- return (source, context) => binding(source, context) ? getTemplate(source, context) : null;
3132
+ function when(binding, templateOrTemplateBinding, elseTemplateOrTemplateBinding) {
3133
+ const dataBinding = isFunction(binding) ? binding : () => binding;
3134
+ const templateBinding = normalizeBinding(templateOrTemplateBinding);
3135
+ const elseBinding = normalizeBinding(elseTemplateOrTemplateBinding);
3136
+ return (source, context) => dataBinding(source, context) ? templateBinding(source, context) : elseBinding(source, context);
3126
3137
  }
3127
3138
 
3128
3139
  const defaultRepeatOptions = Object.freeze({
@@ -4310,7 +4321,6 @@ class ContainerImpl {
4310
4321
  // Most likely cause is trying to register a plain object that does not have a
4311
4322
  // register method and is not a class constructor
4312
4323
  }
4313
-
4314
4324
  let current;
4315
4325
  let keys;
4316
4326
  let value;
@@ -4426,7 +4436,7 @@ class ContainerImpl {
4426
4436
  return resolver.resolve(current, this);
4427
4437
  }
4428
4438
  }
4429
- throw new Error(`Unable to resolve key: ${key}`);
4439
+ throw new Error(`Unable to resolve key: ${String(key)}`);
4430
4440
  }
4431
4441
  getAll(key, searchAncestors = false) {
4432
4442
  validateKey(key);
@@ -6936,6 +6946,7 @@ function FormAssociated(BaseCtor) {
6936
6946
  * @internal
6937
6947
  */
6938
6948
  disconnectedCallback() {
6949
+ super.disconnectedCallback();
6939
6950
  this.proxyEventsToBlock.forEach(name => this.proxy.removeEventListener(name, this.stopPropagation));
6940
6951
  if (!this.elementInternals && this.form) {
6941
6952
  this.form.removeEventListener("reset", this.formResetCallback);
@@ -8711,7 +8722,7 @@ const calendarTemplate = (context, definition) => {
8711
8722
  var _a;
8712
8723
  const today = new Date();
8713
8724
  const todayString = `${today.getMonth() + 1}-${today.getDate()}-${today.getFullYear()}`;
8714
- return html`<template>${startTemplate} ${definition.title instanceof Function ? definition.title(context, definition) : (_a = definition.title) !== null && _a !== void 0 ? _a : ""}<slot></slot>${when(x => x.readonly === false, interactiveCalendarGridTemplate(context, todayString))} ${when(x => x.readonly === true, noninteractiveCalendarTemplate(todayString))} ${endTemplate}</template>`;
8725
+ return html`<template>${startTemplate} ${definition.title instanceof Function ? definition.title(context, definition) : (_a = definition.title) !== null && _a !== void 0 ? _a : ""}<slot></slot>${when(x => x.readonly, noninteractiveCalendarTemplate(todayString), interactiveCalendarGridTemplate(context, todayString))} ${endTemplate}</template>`;
8715
8726
  };
8716
8727
 
8717
8728
  /**
@@ -13228,7 +13239,7 @@ const progressSegments = 44;
13228
13239
  * The template for the {@link @microsoft/fast-foundation#BaseProgress} component.
13229
13240
  * @public
13230
13241
  */
13231
- const progressRingTemplate = (context, definition) => html`<template role="progressbar" aria-valuenow="${x => x.value}" aria-valuemin="${x => x.min}" aria-valuemax="${x => x.max}" class="${x => x.paused ? "paused" : ""}">${when(x => typeof x.value === "number", html`<svg class="progress" part="progress" viewBox="0 0 16 16" slot="determinate"><circle class="background" part="background" cx="8px" cy="8px" r="7px"></circle><circle class="determinate" part="determinate" style="stroke-dasharray: ${x => progressSegments * x.percentComplete / 100}px ${progressSegments}px" cx="8px" cy="8px" r="7px"></circle></svg>`)} ${when(x => typeof x.value !== "number", html`<slot name="indeterminate" slot="indeterminate">${definition.indeterminateIndicator || ""}</slot>`)}</template>`;
13242
+ const progressRingTemplate = (context, definition) => html`<template role="progressbar" aria-valuenow="${x => x.value}" aria-valuemin="${x => x.min}" aria-valuemax="${x => x.max}" class="${x => x.paused ? "paused" : ""}">${when(x => typeof x.value === "number", html`<svg class="progress" part="progress" viewBox="0 0 16 16" slot="determinate"><circle class="background" part="background" cx="8px" cy="8px" r="7px"></circle><circle class="determinate" part="determinate" style="stroke-dasharray: ${x => progressSegments * x.percentComplete / 100}px ${progressSegments}px" cx="8px" cy="8px" r="7px"></circle></svg>`, html`<slot name="indeterminate" slot="indeterminate">${definition.indeterminateIndicator || ""}</slot>`)}</template>`;
13232
13243
 
13233
13244
  /**
13234
13245
  * An Progress HTML Element.
@@ -13298,7 +13309,7 @@ __decorate$1([observable], BaseProgress.prototype, "percentComplete", void 0);
13298
13309
  * The template for the {@link @microsoft/fast-foundation#BaseProgress} component.
13299
13310
  * @public
13300
13311
  */
13301
- const progressTemplate = (context, defintion) => html`<template role="progressbar" aria-valuenow="${x => x.value}" aria-valuemin="${x => x.min}" aria-valuemax="${x => x.max}" class="${x => x.paused ? "paused" : ""}">${when(x => typeof x.value === "number", html`<div class="progress" part="progress" slot="determinate"><div class="determinate" part="determinate" style="width: ${x => x.percentComplete}%"></div></div>`)} ${when(x => typeof x.value !== "number", html`<div class="progress" part="progress" slot="indeterminate"><slot class="indeterminate" name="indeterminate">${defintion.indeterminateIndicator1 || ""} ${defintion.indeterminateIndicator2 || ""}</slot></div>`)}</template>`;
13312
+ const progressTemplate = (context, defintion) => html`<template role="progressbar" aria-valuenow="${x => x.value}" aria-valuemin="${x => x.min}" aria-valuemax="${x => x.max}" class="${x => x.paused ? "paused" : ""}">${when(x => typeof x.value === "number", html`<div class="progress" part="progress" slot="determinate"><div class="determinate" part="determinate" style="width: ${x => x.percentComplete}%"></div></div>`, html`<div class="progress" part="progress" slot="indeterminate"><slot class="indeterminate" name="indeterminate">${defintion.indeterminateIndicator1 || ""} ${defintion.indeterminateIndicator2 || ""}</slot></div>`)}</template>`;
13302
13313
 
13303
13314
  /**
13304
13315
  * The template for the {@link @microsoft/fast-foundation#RadioGroup} component.
@@ -15638,8 +15649,11 @@ class Tabs extends FoundationElement {
15638
15649
  this.isDisabledElement = el => {
15639
15650
  return el.getAttribute("aria-disabled") === "true";
15640
15651
  };
15652
+ this.isHiddenElement = el => {
15653
+ return el.hasAttribute("hidden");
15654
+ };
15641
15655
  this.isFocusableElement = el => {
15642
- return !this.isDisabledElement(el);
15656
+ return !this.isDisabledElement(el) && !this.isHiddenElement(el);
15643
15657
  };
15644
15658
  this.setTabs = () => {
15645
15659
  const gridHorizontalProperty = "gridColumn";
@@ -15663,6 +15677,7 @@ class Tabs extends FoundationElement {
15663
15677
  tab.setAttribute("tabindex", isActiveTab ? "0" : "-1");
15664
15678
  if (isActiveTab) {
15665
15679
  this.activetab = tab;
15680
+ this.activeid = tabId;
15666
15681
  }
15667
15682
  }
15668
15683
  // If the original property isn't emptied out,
@@ -15882,9 +15897,14 @@ class Tabs extends FoundationElement {
15882
15897
  * This method allows the active index to be adjusted by numerical increments
15883
15898
  */
15884
15899
  adjust(adjustment) {
15885
- this.prevActiveTabIndex = this.activeTabIndex;
15886
- this.activeTabIndex = wrapInBounds(0, this.tabs.length - 1, this.activeTabIndex + adjustment);
15887
- this.setComponent();
15900
+ const focusableTabs = this.tabs.filter(t => this.isFocusableElement(t));
15901
+ const currentActiveTabIndex = focusableTabs.indexOf(this.activetab);
15902
+ const nextTabIndex = limit(0, focusableTabs.length - 1, currentActiveTabIndex + adjustment);
15903
+ // the index of the next focusable tab within the context of all available tabs
15904
+ const nextIndex = this.tabs.indexOf(focusableTabs[nextTabIndex]);
15905
+ if (nextIndex > -1) {
15906
+ this.moveToTabByIndex(this.tabs, nextIndex);
15907
+ }
15888
15908
  }
15889
15909
  focusTab() {
15890
15910
  this.tabs[this.activeTabIndex].focus();
@@ -16098,7 +16118,7 @@ const textFieldTemplate = (context, definition) => html`<template class=" ${x =>
16098
16118
  *
16099
16119
  * @public
16100
16120
  */
16101
- const toolbarTemplate = (context, definition) => html`<template aria-label="${x => x.ariaLabel}" aria-labelledby="${x => x.ariaLabelledby}" aria-orientation="${x => x.orientation}" orientation="${x => x.orientation}" role="toolbar" @click="${(x, c) => x.clickHandler(c.event)}" @focusin="${(x, c) => x.focusinHandler(c.event)}" @keydown="${(x, c) => x.keydownHandler(c.event)}" ${children({
16121
+ const toolbarTemplate = (context, definition) => html`<template aria-label="${x => x.ariaLabel}" aria-labelledby="${x => x.ariaLabelledby}" aria-orientation="${x => x.orientation}" orientation="${x => x.orientation}" role="toolbar" @mousedown="${(x, c) => x.mouseDownHandler(c.event)}" @focusin="${(x, c) => x.focusinHandler(c.event)}" @keydown="${(x, c) => x.keydownHandler(c.event)}" ${children({
16102
16122
  property: "childItems",
16103
16123
  attributeFilter: ["disabled", "hidden"],
16104
16124
  filter: elements(),
@@ -16195,9 +16215,9 @@ class Toolbar$1 extends FoundationElement {
16195
16215
  *
16196
16216
  * @internal
16197
16217
  */
16198
- clickHandler(e) {
16218
+ mouseDownHandler(e) {
16199
16219
  var _a;
16200
- const activeIndex = (_a = this.focusableElements) === null || _a === void 0 ? void 0 : _a.indexOf(e.target);
16220
+ const activeIndex = (_a = this.focusableElements) === null || _a === void 0 ? void 0 : _a.findIndex(x => x.contains(e.target));
16201
16221
  if (activeIndex > -1 && this.activeIndex !== activeIndex) {
16202
16222
  this.setFocusedElement(activeIndex);
16203
16223
  }
@@ -20597,11 +20617,10 @@ const dataGridStyles = dataGridStyles$1;
20597
20617
  */
20598
20618
  const swatchConverter = {
20599
20619
  toView(value) {
20600
- var _a;
20601
20620
  if (value === null || value === undefined) {
20602
20621
  return null;
20603
20622
  }
20604
- return (_a = value) === null || _a === void 0 ? void 0 : _a.toColorString();
20623
+ return value === null || value === void 0 ? void 0 : value.toColorString();
20605
20624
  },
20606
20625
  fromView(value) {
20607
20626
  if (value === null || value === undefined) {
@@ -20931,7 +20950,7 @@ const fluentDialog = Dialog.compose({
20931
20950
  const dialogStyles = dialogStyles$1;
20932
20951
 
20933
20952
  const dividerStyles$1 = (context, definition) => css`
20934
- ${display('block')} :host{box-sizing:content-box;height:0;border:none;border-top:calc(${strokeWidth} * 1px) solid ${neutralStrokeDividerRest}}`;
20953
+ ${display('block')} :host{box-sizing:content-box;height:0;border:none;border-top:calc(${strokeWidth} * 1px) solid ${neutralStrokeDividerRest}}:host([orientation="vertical"]){border:none;height:100%;margin:0 calc(${designUnit} * 1px);border-left:calc(${strokeWidth} * 1px) solid ${neutralStrokeDividerRest}}`;
20935
20954
 
20936
20955
  /**
20937
20956
  * The Fluent Divider Element. Implements {@link @microsoft/fast-foundation#Divider},
@@ -21704,7 +21723,7 @@ const textAreaStyles$1 = (context, definition) => css`
21704
21723
 
21705
21724
  ${inputStateStyles()}
21706
21725
 
21707
- :host{flex-direction:column;vertical-align:bottom}.control{height:calc((${heightNumber} * 2) * 1px);padding:calc(${designUnit} * 1.5px) calc(${designUnit} * 2px + 1px)}:host .control{resize:none}:host(.resize-both) .control{resize:both}:host(.resize-horizontal) .control{resize:horizontal}:host(.resize-vertical) .control{resize:vertical}`.withBehaviors(appearanceBehavior('outline', inputOutlineStyles(context, definition, logicalControlSelector$1)), appearanceBehavior('filled', inputFilledStyles(context, definition, logicalControlSelector$1)), forcedColorsStylesheetBehavior(inputForcedColorStyles(context, definition, logicalControlSelector$1)));
21726
+ :host{flex-direction:column;vertical-align:bottom}.control{height:calc((${heightNumber} * 2) * 1px);padding:calc(${designUnit} * 1.5px) calc(${designUnit} * 2px + 1px)}:host .control{resize:none}:host(.resize-both) .control{resize:both}:host(.resize-horizontal) .control{resize:horizontal}:host(.resize-vertical) .control{resize:vertical}:host([cols]){width:initial}:host([rows]) .control{height:initial}`.withBehaviors(appearanceBehavior('outline', inputOutlineStyles(context, definition, logicalControlSelector$1)), appearanceBehavior('filled', inputFilledStyles(context, definition, logicalControlSelector$1)), forcedColorsStylesheetBehavior(inputForcedColorStyles(context, definition, logicalControlSelector$1)));
21708
21727
 
21709
21728
  /**
21710
21729
  * The Fluent TextArea class