@fkui/vue 5.40.0 → 5.41.0

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.
@@ -2075,11 +2075,11 @@ function baseIsEqual$1(value, other, bitmask, customizer, stack) {
2075
2075
  }
2076
2076
  var _baseIsEqual = baseIsEqual$1;
2077
2077
  var baseIsEqual = _baseIsEqual;
2078
- function isEqual(value, other) {
2078
+ function isEqual$1(value, other) {
2079
2079
  return baseIsEqual(value, other);
2080
2080
  }
2081
- var isEqual_1 = isEqual;
2082
- const isEqual$1 = /* @__PURE__ */ getDefaultExportFromCjs(isEqual_1);
2081
+ var isEqual_1 = isEqual$1;
2082
+ const isEqual$2 = /* @__PURE__ */ getDefaultExportFromCjs(isEqual_1);
2083
2083
  function itemEquals(item1, item2, compareAttribute) {
2084
2084
  if (!logic.isSet(item1) || !logic.isSet(item2)) {
2085
2085
  return false;
@@ -3943,7 +3943,7 @@ const ValidationDirective = {
3943
3943
  logic.ValidationService.removeValidatorsFromElement(validatableElement);
3944
3944
  },
3945
3945
  updated(el, binding) {
3946
- if (!isEqual$1(binding.value, binding.oldValue)) {
3946
+ if (!isEqual$2(binding.value, binding.oldValue)) {
3947
3947
  registerValidators(el, binding);
3948
3948
  }
3949
3949
  },
@@ -5026,6 +5026,8 @@ function isTeleportDisabled(options) {
5026
5026
  disableTeleport = true;
5027
5027
  } else if (forceOverlay) {
5028
5028
  disableTeleport = false;
5029
+ } else if (placement === Placement.NotCalculated && !isMobileSize) {
5030
+ disableTeleport = false;
5029
5031
  }
5030
5032
  return disableTeleport;
5031
5033
  }
@@ -5114,25 +5116,38 @@ const _sfc_main$X = vue.defineComponent({
5114
5116
  default: true
5115
5117
  }
5116
5118
  },
5117
- emits: ["open", "close"],
5119
+ emits: [
5120
+ /**
5121
+ * Emitted when popup is visible and placement is fully calculated.
5122
+ */
5123
+ "open",
5124
+ /**
5125
+ * Emitted when clicked outside of popup.
5126
+ */
5127
+ "close"
5128
+ ],
5118
5129
  data() {
5119
5130
  return {
5120
5131
  teleportDisabled: false,
5121
5132
  placement: Placement.NotCalculated,
5122
- focus: null,
5123
- noCloseOnResize: false
5133
+ focus: null
5124
5134
  };
5125
5135
  },
5126
5136
  computed: {
5127
5137
  popupClasses() {
5138
+ const popupState = this.isInline ? ["popup--inline"] : ["popup--overlay"];
5139
+ return ["popup", ...popupState];
5140
+ },
5141
+ isInline() {
5128
5142
  let isInline = this.teleportDisabled || this.placement === Placement.Fallback;
5129
5143
  if (this.forceInline) {
5130
5144
  isInline = true;
5131
5145
  } else if (this.forceOverlay) {
5132
5146
  isInline = false;
5147
+ } else if (this.placement === Placement.NotCalculated && !this.isMobileSize()) {
5148
+ isInline = false;
5133
5149
  }
5134
- const popupState = isInline ? ["popup--inline"] : ["popup--overlay"];
5135
- return ["popup", ...popupState];
5150
+ return isInline;
5136
5151
  },
5137
5152
  forceInline() {
5138
5153
  return this.alwaysInline || this.inline === "always";
@@ -5165,19 +5180,22 @@ const _sfc_main$X = vue.defineComponent({
5165
5180
  setTimeout(() => {
5166
5181
  if (this.isOpen) {
5167
5182
  document.addEventListener("click", this.onDocumentClickHandler);
5168
- window.addEventListener("resize", this.onWindowResizeHandler);
5183
+ window.addEventListener("resize", this.onWindowResizeDebounced);
5169
5184
  }
5170
5185
  }, 0);
5171
5186
  } else {
5172
5187
  document.removeEventListener("click", this.onDocumentClickHandler);
5173
- window.removeEventListener("resize", this.onWindowResizeHandler);
5188
+ window.removeEventListener("resize", this.onWindowResizeDebounced);
5174
5189
  }
5175
5190
  }
5176
5191
  }
5177
5192
  },
5193
+ created() {
5194
+ this.onWindowResizeDebounced = logic.debounce(this.onWindowResize, 100).bind(this);
5195
+ },
5178
5196
  unmounted() {
5179
5197
  document.removeEventListener("click", this.onDocumentClickHandler);
5180
- window.removeEventListener("resize", this.onWindowResizeHandler);
5198
+ window.removeEventListener("resize", this.onWindowResizeDebounced);
5181
5199
  },
5182
5200
  methods: {
5183
5201
  async toggleIsOpen(isOpen) {
@@ -5190,8 +5208,13 @@ const _sfc_main$X = vue.defineComponent({
5190
5208
  return;
5191
5209
  }
5192
5210
  await this.$nextTick();
5193
- const popup = this.$refs["popup"];
5194
- const wrapper = this.$refs["wrapper"];
5211
+ await this.calculatePlacement();
5212
+ this.applyFocus();
5213
+ this.$emit("open");
5214
+ },
5215
+ async calculatePlacement() {
5216
+ const popup = getHTMLElementFromVueRef(this.$refs.popup);
5217
+ const wrapper = getHTMLElementFromVueRef(this.$refs.wrapper);
5195
5218
  const anchor = getElement(this.anchor);
5196
5219
  if (!anchor) {
5197
5220
  throw new Error("No anchor element found");
@@ -5213,13 +5236,12 @@ const _sfc_main$X = vue.defineComponent({
5213
5236
  if (useOverlay) {
5214
5237
  wrapper.style.left = `${result.x}px`;
5215
5238
  wrapper.style.top = `${result.y}px`;
5216
- this.applyFocus();
5217
- this.$emit("open");
5218
5239
  return;
5219
5240
  }
5220
5241
  }
5221
- this.noCloseOnResize = true;
5222
5242
  this.teleportDisabled = true;
5243
+ wrapper.style.removeProperty("left");
5244
+ wrapper.style.removeProperty("top");
5223
5245
  await new Promise((resolve) => setTimeout(resolve, 200));
5224
5246
  const scrollTarget = popup.closest(".scroll-target");
5225
5247
  const hasScrollTarget = scrollTarget !== null;
@@ -5233,23 +5255,22 @@ const _sfc_main$X = vue.defineComponent({
5233
5255
  top,
5234
5256
  behavior: "smooth"
5235
5257
  };
5236
- wrapper.style.removeProperty("left");
5237
- wrapper.style.removeProperty("top");
5238
5258
  if (hasScrollTarget) {
5239
5259
  scrollTarget.scrollTo(scrollOptions);
5240
5260
  } else {
5241
5261
  window.scrollTo(scrollOptions);
5242
5262
  }
5243
- this.noCloseOnResize = false;
5244
- this.applyFocus();
5245
- this.$emit("open");
5246
5263
  },
5247
5264
  applyFocus() {
5248
- if (this.setFocus) {
5249
- const wrapper = this.$refs["wrapper"];
5250
- const focusableElement = getFocusableElement(wrapper, this.focusElement);
5251
- this.focus = logic.pushFocus(focusableElement);
5265
+ if (!this.setFocus) {
5266
+ return;
5267
+ }
5268
+ const wrapper = this.$refs.wrapper;
5269
+ if (!wrapper) {
5270
+ return;
5252
5271
  }
5272
+ const focusableElement = getFocusableElement(wrapper, this.focusElement);
5273
+ this.focus = logic.pushFocus(focusableElement);
5253
5274
  },
5254
5275
  isMobileSize() {
5255
5276
  return window.innerWidth < MIN_DESKTOP_WIDTH;
@@ -5257,11 +5278,35 @@ const _sfc_main$X = vue.defineComponent({
5257
5278
  onDocumentClickHandler() {
5258
5279
  this.$emit("close");
5259
5280
  },
5260
- onWindowResizeHandler() {
5261
- if (this.noCloseOnResize) {
5281
+ onWindowResizeDebounced() {
5282
+ },
5283
+ async onWindowResize() {
5284
+ if (!this.isOpen) {
5262
5285
  return;
5263
5286
  }
5264
- this.$emit("close");
5287
+ if (this.forceInline) {
5288
+ return;
5289
+ }
5290
+ if (this.isInline && this.isMobileSize()) {
5291
+ return;
5292
+ }
5293
+ if (this.isInline) {
5294
+ this.placement = Placement.NotCalculated;
5295
+ this.teleportDisabled = false;
5296
+ await this.$nextTick();
5297
+ }
5298
+ await this.calculatePlacement();
5299
+ const {
5300
+ placement,
5301
+ forceInline,
5302
+ forceOverlay
5303
+ } = this;
5304
+ this.teleportDisabled = isTeleportDisabled({
5305
+ window,
5306
+ placement,
5307
+ forceInline,
5308
+ forceOverlay
5309
+ });
5265
5310
  },
5266
5311
  onPopupClickHandler(event) {
5267
5312
  event.stopPropagation();
@@ -5271,7 +5316,8 @@ const _sfc_main$X = vue.defineComponent({
5271
5316
  },
5272
5317
  onKeyTab(event) {
5273
5318
  if (this.keyboardTrap) {
5274
- logic.handleTab(event, this.$refs.wrapper);
5319
+ const wrapper = getHTMLElementFromVueRef(this.$refs.wrapper);
5320
+ logic.handleTab(event, wrapper);
5275
5321
  }
5276
5322
  }
5277
5323
  }
@@ -5597,6 +5643,12 @@ function useFieldset() {
5597
5643
  getFieldsetLabelText: vue.inject(injectionKeys.getFieldsetLabelText, () => void 0)
5598
5644
  };
5599
5645
  }
5646
+ function isEqual(a, b) {
5647
+ if (a.length !== b.length) {
5648
+ return false;
5649
+ }
5650
+ return a.every((_, i) => a[i] === b[i]);
5651
+ }
5600
5652
  const _sfc_main$V = vue.defineComponent({
5601
5653
  name: "FFieldset",
5602
5654
  components: {
@@ -5817,7 +5869,10 @@ const _sfc_main$V = vue.defineComponent({
5817
5869
  },
5818
5870
  async updateCheckboxChildren() {
5819
5871
  await this.$nextTick();
5820
- this.children = Array.from(this.$el.querySelectorAll('input[type="checkbox"]'));
5872
+ const checkboxes = Array.from(this.$el.querySelectorAll('input[type="checkbox"]'));
5873
+ if (!isEqual(this.children, checkboxes)) {
5874
+ this.children = checkboxes;
5875
+ }
5821
5876
  }
5822
5877
  }
5823
5878
  });
@@ -5976,7 +6031,7 @@ const _sfc_main$U = vue.defineComponent({
5976
6031
  attrs() {
5977
6032
  let checked;
5978
6033
  if (Array.isArray(this.modelValue)) {
5979
- checked = this.modelValue.findIndex((it) => isEqual$1(vue.toValue(it), vue.toValue(this.value))) >= 0;
6034
+ checked = this.modelValue.findIndex((it) => isEqual$2(vue.toValue(it), vue.toValue(this.value))) >= 0;
5980
6035
  } else {
5981
6036
  checked = this.value === this.modelValue;
5982
6037
  }
@@ -6010,7 +6065,7 @@ const _sfc_main$U = vue.defineComponent({
6010
6065
  emitVModelEvent(event) {
6011
6066
  let newModel;
6012
6067
  if (Array.isArray(this.modelValue)) {
6013
- newModel = [...this.modelValue].filter((it) => !isEqual$1(vue.toValue(it), vue.toValue(this.value)));
6068
+ newModel = [...this.modelValue].filter((it) => !isEqual$2(vue.toValue(it), vue.toValue(this.value)));
6014
6069
  if (this.modelValue.length <= newModel.length) {
6015
6070
  newModel.push(this.value);
6016
6071
  }
@@ -12891,8 +12946,11 @@ const _sfc_main$c = vue.defineComponent({
12891
12946
  }
12892
12947
  this.overflowIndex = foundOverflowIndex;
12893
12948
  if (!this.hasOverflow) {
12949
+ this.popupOpen = false;
12894
12950
  return;
12895
12951
  }
12952
+ const popupWasOpen = this.popupOpen;
12953
+ this.popupOpen = false;
12896
12954
  await this.$nextTick();
12897
12955
  const wrapper = getHTMLElementFromVueRef(this.$refs["popup-item"]);
12898
12956
  wrapper.style.left = "0";
@@ -12901,6 +12959,7 @@ const _sfc_main$c = vue.defineComponent({
12901
12959
  const wrapperRect = getAbsolutePosition(wrapper);
12902
12960
  const offset2 = wrapperRect.x - firstHiddenItemRect.x;
12903
12961
  wrapper.style.left = `-${offset2}px`;
12962
+ this.popupOpen = popupWasOpen;
12904
12963
  },
12905
12964
  onKeyUp(event) {
12906
12965
  if (preventKeys.includes(event.key)) {