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