@fluentui/web-components 2.5.3 → 2.5.4

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.json CHANGED
@@ -2,7 +2,52 @@
2
2
  "name": "@fluentui/web-components",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 16 Jun 2022 23:03:03 GMT",
5
+ "date": "Tue, 30 Aug 2022 07:41:19 GMT",
6
+ "tag": "@fluentui/web-components_v2.5.4",
7
+ "version": "2.5.4",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "chhol@microsoft.com",
12
+ "package": "@fluentui/web-components",
13
+ "commit": "9e86978c43db785ec3f40ee9e0bd35693e26189d",
14
+ "comment": "update FAST packages to resolve issues with form constraint validation on form associated elements"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Wed, 10 Aug 2022 07:37:33 GMT",
21
+ "tag": "@fluentui/web-components_v2.5.3",
22
+ "version": "2.5.3",
23
+ "comments": {
24
+ "none": [
25
+ {
26
+ "author": "martinhochel@microsoft.com",
27
+ "package": "@fluentui/web-components",
28
+ "commit": "5a44edc603012847bbe5cc7b29d65bb86c7fb8b2",
29
+ "comment": "chore: use only 1 instance of ts-node in monorepo"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Mon, 25 Jul 2022 07:36:55 GMT",
36
+ "tag": "@fluentui/web-components_v2.5.3",
37
+ "version": "2.5.3",
38
+ "comments": {
39
+ "none": [
40
+ {
41
+ "author": "martinhochel@microsoft.com",
42
+ "package": "@fluentui/web-components",
43
+ "commit": "5aa33cbb283143f8dda9a836faa1b69d94c1ca64",
44
+ "comment": "chore(storybook): remove deprecated --static-dir CLI flag usage"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "date": "Thu, 16 Jun 2022 23:03:44 GMT",
6
51
  "tag": "@fluentui/web-components_v2.5.3",
7
52
  "version": "2.5.3",
8
53
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,21 @@
1
1
  # Change Log - @fluentui/web-components
2
2
 
3
- This log was last generated on Thu, 16 Jun 2022 23:03:03 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 30 Aug 2022 07:41:19 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [2.5.4](https://github.com/microsoft/fluentui/tree/@fluentui/web-components_v2.5.4)
8
+
9
+ Tue, 30 Aug 2022 07:41:19 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/web-components_v2.5.3..@fluentui/web-components_v2.5.4)
11
+
12
+ ### Patches
13
+
14
+ - update FAST packages to resolve issues with form constraint validation on form associated elements ([PR #24557](https://github.com/microsoft/fluentui/pull/24557) by chhol@microsoft.com)
15
+
7
16
  ## [2.5.3](https://github.com/microsoft/fluentui/tree/@fluentui/web-components_v2.5.3)
8
17
 
9
- Thu, 16 Jun 2022 23:03:03 GMT
18
+ Thu, 16 Jun 2022 23:03:44 GMT
10
19
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/web-components_v2.5.2..@fluentui/web-components_v2.5.3)
11
20
 
12
21
  ### Patches
@@ -3861,37 +3861,54 @@ class RepeatBehavior {
3861
3861
  updateViews(splices) {
3862
3862
  const childContext = this.childContext;
3863
3863
  const views = this.views;
3864
- const totalRemoved = [];
3865
3864
  const bindView = this.bindView;
3866
- let removeDelta = 0;
3867
-
3868
- for (let i = 0, ii = splices.length; i < ii; ++i) {
3869
- const splice = splices[i];
3870
- const removed = splice.removed;
3871
- totalRemoved.push(...views.splice(splice.index + removeDelta, removed.length));
3872
- removeDelta -= splice.addedCount;
3873
- }
3874
-
3875
3865
  const items = this.items;
3876
3866
  const template = this.template;
3867
+ const recycle = this.options.recycle;
3868
+ const leftoverViews = [];
3869
+ let leftoverIndex = 0;
3870
+ let availableViews = 0;
3877
3871
 
3878
3872
  for (let i = 0, ii = splices.length; i < ii; ++i) {
3879
3873
  const splice = splices[i];
3874
+ const removed = splice.removed;
3875
+ let removeIndex = 0;
3880
3876
  let addIndex = splice.index;
3881
3877
  const end = addIndex + splice.addedCount;
3878
+ const removedViews = views.splice(splice.index, removed.length);
3879
+ availableViews = leftoverViews.length + removedViews.length;
3882
3880
 
3883
3881
  for (; addIndex < end; ++addIndex) {
3884
3882
  const neighbor = views[addIndex];
3885
3883
  const location = neighbor ? neighbor.firstChild : this.location;
3886
- const view = this.options.recycle && totalRemoved.length > 0 ? totalRemoved.shift() : template.create();
3884
+ let view;
3885
+
3886
+ if (recycle && availableViews > 0) {
3887
+ if (removeIndex <= availableViews && removedViews.length > 0) {
3888
+ view = removedViews[removeIndex];
3889
+ removeIndex++;
3890
+ } else {
3891
+ view = leftoverViews[leftoverIndex];
3892
+ leftoverIndex++;
3893
+ }
3894
+
3895
+ availableViews--;
3896
+ } else {
3897
+ view = template.create();
3898
+ }
3899
+
3887
3900
  views.splice(addIndex, 0, view);
3888
3901
  bindView(view, items, addIndex, childContext);
3889
3902
  view.insertBefore(location);
3890
3903
  }
3904
+
3905
+ if (removedViews[removeIndex]) {
3906
+ leftoverViews.push(...removedViews.slice(removeIndex));
3907
+ }
3891
3908
  }
3892
3909
 
3893
- for (let i = 0, ii = totalRemoved.length; i < ii; ++i) {
3894
- totalRemoved[i].dispose();
3910
+ for (let i = leftoverIndex, ii = leftoverViews.length; i < ii; ++i) {
3911
+ leftoverViews[i].dispose();
3895
3912
  }
3896
3913
 
3897
3914
  if (this.options.positioning) {
@@ -3913,7 +3930,7 @@ class RepeatBehavior {
3913
3930
  let views = this.views;
3914
3931
  let viewsLength = views.length;
3915
3932
 
3916
- if (itemsLength === 0 || templateChanged) {
3933
+ if (itemsLength === 0 || templateChanged || !this.options.recycle) {
3917
3934
  // all views need to be removed
3918
3935
  HTMLView.disposeContiguousBatch(views);
3919
3936
  viewsLength = 0;
@@ -4011,7 +4028,7 @@ class RepeatDirective extends HTMLDirective {
4011
4028
 
4012
4029
  function repeat(itemsBinding, templateOrTemplateBinding, options = defaultRepeatOptions) {
4013
4030
  const templateBinding = typeof templateOrTemplateBinding === "function" ? templateOrTemplateBinding : () => templateOrTemplateBinding;
4014
- return new RepeatDirective(itemsBinding, templateBinding, options);
4031
+ return new RepeatDirective(itemsBinding, templateBinding, Object.assign(Object.assign({}, defaultRepeatOptions), options));
4015
4032
  }
4016
4033
 
4017
4034
  /**
@@ -8450,15 +8467,12 @@ function FormAssociated(BaseCtor) {
8450
8467
  this.removeChild(this.proxy);
8451
8468
  (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.removeChild(this.proxySlot);
8452
8469
  }
8453
- /**
8454
- * Sets the validity of the custom element. By default this uses the proxy element to determine
8455
- * validity, but this can be extended or replaced in implementation.
8456
- */
8470
+ /** {@inheritDoc (FormAssociated:interface).validate} */
8457
8471
 
8458
8472
 
8459
- validate() {
8473
+ validate(anchor) {
8460
8474
  if (this.proxy instanceof HTMLElement) {
8461
- this.setValidity(this.proxy.validity, this.proxy.validationMessage);
8475
+ this.setValidity(this.proxy.validity, this.proxy.validationMessage, anchor);
8462
8476
  }
8463
8477
  }
8464
8478
  /**
@@ -8762,6 +8776,12 @@ class Button$1 extends FormAssociatedButton {
8762
8776
  next === "reset" && this.addEventListener("click", this.handleFormReset);
8763
8777
  previous === "reset" && this.removeEventListener("click", this.handleFormReset);
8764
8778
  }
8779
+ /** {@inheritDoc (FormAssociated:interface).validate} */
8780
+
8781
+
8782
+ validate() {
8783
+ super.validate(this.control);
8784
+ }
8765
8785
  /**
8766
8786
  * @internal
8767
8787
  */
@@ -10573,8 +10593,16 @@ class Checkbox extends FormAssociatedCheckbox {
10573
10593
  */
10574
10594
 
10575
10595
  this.keypressHandler = e => {
10596
+ if (this.readOnly) {
10597
+ return;
10598
+ }
10599
+
10576
10600
  switch (e.key) {
10577
10601
  case keySpace:
10602
+ if (this.indeterminate) {
10603
+ this.indeterminate = false;
10604
+ }
10605
+
10578
10606
  this.checked = !this.checked;
10579
10607
  break;
10580
10608
  }
@@ -10586,6 +10614,10 @@ class Checkbox extends FormAssociatedCheckbox {
10586
10614
 
10587
10615
  this.clickHandler = e => {
10588
10616
  if (!this.disabled && !this.readOnly) {
10617
+ if (this.indeterminate) {
10618
+ this.indeterminate = false;
10619
+ }
10620
+
10589
10621
  this.checked = !this.checked;
10590
10622
  }
10591
10623
  };
@@ -11587,6 +11619,12 @@ class Combobox$1 extends FormAssociatedCombobox {
11587
11619
  this.setDefaultSelectedOption();
11588
11620
  this.updateValue();
11589
11621
  }
11622
+ /** {@inheritDoc (FormAssociated:interface).validate} */
11623
+
11624
+
11625
+ validate() {
11626
+ super.validate(this.control);
11627
+ }
11590
11628
 
11591
11629
  get isAutocompleteInline() {
11592
11630
  return this.autocomplete === ComboboxAutocomplete.inline || this.isAutocompleteBoth;
@@ -11806,7 +11844,7 @@ class Combobox$1 extends FormAssociatedCombobox {
11806
11844
 
11807
11845
 
11808
11846
  focusoutHandler(e) {
11809
- this.updateValue();
11847
+ this.syncValue();
11810
11848
 
11811
11849
  if (!this.open) {
11812
11850
  return true;
@@ -11835,7 +11873,11 @@ class Combobox$1 extends FormAssociatedCombobox {
11835
11873
  this.filter = this.control.value;
11836
11874
  this.filterOptions();
11837
11875
 
11838
- if (e.inputType === "deleteContentBackward" || !this.filter.length) {
11876
+ if (!this.isAutocompleteInline) {
11877
+ this.selectedIndex = this.options.map(option => option.text).indexOf(this.control.value);
11878
+ }
11879
+
11880
+ if (e.inputType.includes("deleteContent") || !this.filter.length) {
11839
11881
  return true;
11840
11882
  }
11841
11883
 
@@ -11843,10 +11885,14 @@ class Combobox$1 extends FormAssociatedCombobox {
11843
11885
  this.open = true;
11844
11886
  }
11845
11887
 
11846
- if (this.isAutocompleteInline && this.filteredOptions.length) {
11847
- this.selectedOptions = [this.filteredOptions[0]];
11848
- this.selectedIndex = this.options.indexOf(this.firstSelectedOption);
11849
- this.setInlineSelection();
11888
+ if (this.isAutocompleteInline) {
11889
+ if (this.filteredOptions.length) {
11890
+ this.selectedOptions = [this.filteredOptions[0]];
11891
+ this.selectedIndex = this.options.indexOf(this.firstSelectedOption);
11892
+ this.setInlineSelection();
11893
+ } else {
11894
+ this.selectedIndex = -1;
11895
+ }
11850
11896
  }
11851
11897
 
11852
11898
  return;
@@ -11869,7 +11915,7 @@ class Combobox$1 extends FormAssociatedCombobox {
11869
11915
  switch (key) {
11870
11916
  case "Enter":
11871
11917
  {
11872
- this.updateValue(true);
11918
+ this.syncValue();
11873
11919
 
11874
11920
  if (this.isAutocompleteInline) {
11875
11921
  this.filter = this.value;
@@ -11900,7 +11946,7 @@ class Combobox$1 extends FormAssociatedCombobox {
11900
11946
 
11901
11947
  case "Tab":
11902
11948
  {
11903
- this.updateValue();
11949
+ this.setInputToSelection();
11904
11950
 
11905
11951
  if (!this.open) {
11906
11952
  return true;
@@ -11926,7 +11972,6 @@ class Combobox$1 extends FormAssociatedCombobox {
11926
11972
  }
11927
11973
 
11928
11974
  if (this.isAutocompleteInline) {
11929
- this.updateValue();
11930
11975
  this.setInlineSelection();
11931
11976
  }
11932
11977
 
@@ -12023,20 +12068,44 @@ class Combobox$1 extends FormAssociatedCombobox {
12023
12068
  }
12024
12069
  }
12025
12070
  /**
12026
- * Focus and select the content of the control based on the first selected option.
12071
+ * Focus and set the content of the control based on the first selected option.
12027
12072
  *
12028
- * @param start - The index for the starting range
12029
12073
  * @internal
12030
12074
  */
12031
12075
 
12032
12076
 
12033
- setInlineSelection() {
12077
+ setInputToSelection() {
12034
12078
  if (this.firstSelectedOption) {
12035
12079
  this.control.value = this.firstSelectedOption.text;
12036
12080
  this.control.focus();
12081
+ }
12082
+ }
12083
+ /**
12084
+ * Focus, set and select the content of the control based on the first selected option.
12085
+ *
12086
+ * @internal
12087
+ */
12088
+
12089
+
12090
+ setInlineSelection() {
12091
+ if (this.firstSelectedOption) {
12092
+ this.setInputToSelection();
12037
12093
  this.control.setSelectionRange(this.filter.length, this.control.value.length, "backward");
12038
12094
  }
12039
12095
  }
12096
+ /**
12097
+ * Determines if a value update should involve emitting a change event, then updates the value.
12098
+ *
12099
+ * @internal
12100
+ */
12101
+
12102
+
12103
+ syncValue() {
12104
+ var _a;
12105
+
12106
+ const newValue = this.selectedIndex > -1 ? (_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.text : this.control.value;
12107
+ this.updateValue(this.value !== newValue);
12108
+ }
12040
12109
  /**
12041
12110
  * Calculate and apply listbox positioning based on available viewport space.
12042
12111
  *
@@ -12100,6 +12169,7 @@ class Combobox$1 extends FormAssociatedCombobox {
12100
12169
 
12101
12170
  if (this.$fastController.isConnected) {
12102
12171
  this.value = ((_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.text) || this.control.value;
12172
+ this.control.value = this.value;
12103
12173
  }
12104
12174
 
12105
12175
  if (shouldEmit) {
@@ -15578,6 +15648,12 @@ class TextField$1 extends FormAssociatedTextField {
15578
15648
  handleChange() {
15579
15649
  this.$emit("change");
15580
15650
  }
15651
+ /** {@inheritDoc (FormAssociated:interface).validate} */
15652
+
15653
+
15654
+ validate() {
15655
+ super.validate(this.control);
15656
+ }
15581
15657
 
15582
15658
  }
15583
15659
 
@@ -15776,6 +15852,12 @@ class NumberField$1 extends FormAssociatedNumberField {
15776
15852
 
15777
15853
  this.isUserInput = false;
15778
15854
  }
15855
+ /** {@inheritDoc (FormAssociated:interface).validate} */
15856
+
15857
+
15858
+ validate() {
15859
+ super.validate(this.control);
15860
+ }
15779
15861
  /**
15780
15862
  * Sets the internal value to a valid number between the min and max properties
15781
15863
  * @param value - user input
@@ -16374,7 +16456,7 @@ class RadioGroup extends FoundationElement {
16374
16456
  valueChanged() {
16375
16457
  if (this.slottedRadioButtons) {
16376
16458
  this.slottedRadioButtons.forEach(radio => {
16377
- if (radio.getAttribute("value") === this.value) {
16459
+ if (radio.value === this.value) {
16378
16460
  radio.checked = true;
16379
16461
  this.selectedRadio = radio;
16380
16462
  }
@@ -16818,20 +16900,32 @@ class HorizontalScroll$1 extends FoundationElement {
16818
16900
 
16819
16901
  setStops() {
16820
16902
  this.updateScrollStops();
16821
- this.width = this.offsetWidth;
16903
+ const {
16904
+ scrollContainer: container
16905
+ } = this;
16906
+ const {
16907
+ scrollLeft
16908
+ } = container;
16909
+ const {
16910
+ width: containerWidth,
16911
+ left: containerLeft
16912
+ } = container.getBoundingClientRect();
16913
+ this.width = containerWidth;
16822
16914
  let lastStop = 0;
16823
- let stops = this.scrollItems.map(({
16824
- offsetLeft: left,
16825
- offsetWidth: width
16826
- }, index) => {
16827
- const right = left + width;
16915
+ let stops = this.scrollItems.map((item, index) => {
16916
+ const {
16917
+ left,
16918
+ width
16919
+ } = item.getBoundingClientRect();
16920
+ const leftPosition = Math.round(left + scrollLeft - containerLeft);
16921
+ const right = Math.round(leftPosition + width);
16828
16922
 
16829
16923
  if (this.isRtl) {
16830
16924
  return -right;
16831
16925
  }
16832
16926
 
16833
16927
  lastStop = right;
16834
- return index === 0 ? 0 : left;
16928
+ return index === 0 ? 0 : leftPosition;
16835
16929
  }).concat(lastStop);
16836
16930
  /* Fixes a FireFox bug where it doesn't scroll to the start */
16837
16931
 
@@ -16873,6 +16967,50 @@ class HorizontalScroll$1 extends FoundationElement {
16873
16967
  (_b = this.nextFlipperContainer) === null || _b === void 0 ? void 0 : _b.classList.toggle("disabled", Math.abs(position) + this.width >= lastStop);
16874
16968
  }
16875
16969
  }
16970
+ /**
16971
+ * Function that can scroll an item into view.
16972
+ * @param item - An item index, a scroll item or a child of one of the scroll items
16973
+ * @param padding - Padding of the viewport where the active item shouldn't be
16974
+ * @param rightPadding - Optional right padding. Uses the padding if not defined
16975
+ *
16976
+ * @public
16977
+ */
16978
+
16979
+
16980
+ scrollInView(item, padding = 0, rightPadding) {
16981
+ var _a;
16982
+
16983
+ if (typeof item !== "number" && item) {
16984
+ item = this.scrollItems.findIndex(scrollItem => scrollItem === item || scrollItem.contains(item));
16985
+ }
16986
+
16987
+ if (item !== undefined) {
16988
+ rightPadding = rightPadding !== null && rightPadding !== void 0 ? rightPadding : padding;
16989
+ const {
16990
+ scrollContainer: container,
16991
+ scrollStops,
16992
+ scrollItems: items
16993
+ } = this;
16994
+ const {
16995
+ scrollLeft
16996
+ } = this.scrollContainer;
16997
+ const {
16998
+ width: containerWidth
16999
+ } = container.getBoundingClientRect();
17000
+ const itemStart = scrollStops[item];
17001
+ const {
17002
+ width
17003
+ } = items[item].getBoundingClientRect();
17004
+ const itemEnd = itemStart + width;
17005
+ const isBefore = scrollLeft + padding > itemStart;
17006
+
17007
+ if (isBefore || scrollLeft + containerWidth - rightPadding < itemEnd) {
17008
+ const stops = [...scrollStops].sort((a, b) => isBefore ? b - a : a - b);
17009
+ const scrollTo = (_a = stops.find(position => isBefore ? position + padding < itemStart : position + containerWidth - (rightPadding !== null && rightPadding !== void 0 ? rightPadding : 0) > itemEnd)) !== null && _a !== void 0 ? _a : 0;
17010
+ this.scrollToPosition(scrollTo);
17011
+ }
17012
+ }
17013
+ }
16876
17014
  /**
16877
17015
  * Lets the user arrow left and right through the horizontal scroll
16878
17016
  * @param e - Keyboard event
@@ -16994,7 +17132,7 @@ class HorizontalScroll$1 extends FoundationElement {
16994
17132
  }
16995
17133
 
16996
17134
  this.resizeTimeout = setTimeout(() => {
16997
- this.width = this.offsetWidth;
17135
+ this.width = this.scrollContainer.offsetWidth;
16998
17136
  this.setFlippers();
16999
17137
  }, this.frameTime);
17000
17138
  }
@@ -17170,6 +17308,12 @@ class Search$1 extends FormAssociatedSearch {
17170
17308
  });
17171
17309
  }
17172
17310
  }
17311
+ /** {@inheritDoc (FormAssociated:interface).validate} */
17312
+
17313
+
17314
+ validate() {
17315
+ super.validate(this.control);
17316
+ }
17173
17317
  /**
17174
17318
  * Handles the internal control's `input` event
17175
17319
  * @internal
@@ -18050,7 +18194,7 @@ class SliderLabel extends FoundationElement {
18050
18194
  break;
18051
18195
 
18052
18196
  case "max":
18053
- this.sliderMinPosition = source.max;
18197
+ this.sliderMaxPosition = source.max;
18054
18198
  break;
18055
18199
 
18056
18200
  case "min":
@@ -19292,6 +19436,12 @@ class TextArea$1 extends FormAssociatedTextArea {
19292
19436
  handleChange() {
19293
19437
  this.$emit("change");
19294
19438
  }
19439
+ /** {@inheritDoc (FormAssociated:interface).validate} */
19440
+
19441
+
19442
+ validate() {
19443
+ super.validate(this.control);
19444
+ }
19295
19445
 
19296
19446
  }
19297
19447