@fkui/vue 5.42.0 → 5.43.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.
@@ -3812,6 +3812,19 @@ const _sfc_main$1b = vue.defineComponent({
3812
3812
  validator(value) {
3813
3813
  return sizes.includes(value);
3814
3814
  }
3815
+ },
3816
+ /**
3817
+ * Default behavior is that the modal will restore focus to previous element once closed.
3818
+ * - "on" (default) - component will set focus both when opened and closed
3819
+ * - "off" - focus strategy disabled
3820
+ * - "open" - focus will only be applied once modal is opened
3821
+ */
3822
+ focus: {
3823
+ type: String,
3824
+ default: "on",
3825
+ validator(value) {
3826
+ return ["on", "off", "open"].includes(value);
3827
+ }
3815
3828
  }
3816
3829
  },
3817
3830
  emits: ["close"],
@@ -3864,8 +3877,12 @@ const _sfc_main$1b = vue.defineComponent({
3864
3877
  root.style.top = `-${scroll}px`;
3865
3878
  root.classList.add("modal__open");
3866
3879
  const focusElement2 = this.resolveFocusElement();
3867
- this.savedFocus = logic.pushFocus(focusElement2);
3868
- this.savedScroll = scroll;
3880
+ if (this.focus === "on") {
3881
+ this.savedFocus = logic.pushFocus(focusElement2);
3882
+ this.savedScroll = scroll;
3883
+ } else if (this.focus === "open") {
3884
+ logic.focus(focusElement2);
3885
+ }
3869
3886
  },
3870
3887
  /**
3871
3888
  * Prioritises what element to initially focus on in the following order:
@@ -3885,15 +3902,15 @@ const _sfc_main$1b = vue.defineComponent({
3885
3902
  return firstTabbableChildElement !== null && firstTabbableChildElement !== void 0 ? firstTabbableChildElement : contentElement;
3886
3903
  },
3887
3904
  restoreState() {
3888
- if (this.savedFocus) {
3889
- var _this$savedScroll;
3890
- const root = document.documentElement;
3891
- root.classList.remove("modal__open");
3892
- root.style.removeProperty("top");
3893
- root.scrollTop = (_this$savedScroll = this.savedScroll) !== null && _this$savedScroll !== void 0 ? _this$savedScroll : 0;
3905
+ var _this$savedScroll;
3906
+ const root = document.documentElement;
3907
+ root.classList.remove("modal__open");
3908
+ root.style.removeProperty("top");
3909
+ root.scrollTop = (_this$savedScroll = this.savedScroll) !== null && _this$savedScroll !== void 0 ? _this$savedScroll : 0;
3910
+ this.savedScroll = null;
3911
+ if (this.focus === "on" && this.savedFocus) {
3894
3912
  logic.popFocus(this.savedFocus);
3895
3913
  this.savedFocus = null;
3896
- this.savedScroll = null;
3897
3914
  }
3898
3915
  },
3899
3916
  onFocusFirst() {
@@ -4067,6 +4084,19 @@ const _sfc_main$1a = vue.defineComponent({
4067
4084
  default: () => {
4068
4085
  return defaultButtons;
4069
4086
  }
4087
+ },
4088
+ /**
4089
+ * Default behavior is that the modal will restore focus to previous element once closed.
4090
+ * - "on" (default) - component will set focus both when opened and closed
4091
+ * - "off" - focus strategy disabled
4092
+ * - "open" - focus will only be applied once modal is opened
4093
+ */
4094
+ focus: {
4095
+ type: String,
4096
+ default: "on",
4097
+ validator(value) {
4098
+ return ["on", "off", "open"].includes(value);
4099
+ }
4070
4100
  }
4071
4101
  },
4072
4102
  emits: ["close", ...defaultButtons.map((it) => {
@@ -4108,6 +4138,7 @@ function _sfc_render$_(_ctx, _cache, $props, $setup, $data, $options) {
4108
4138
  "aria-close-text": _ctx.ariaCloseText,
4109
4139
  type: "warning",
4110
4140
  size: _ctx.size,
4141
+ focus: _ctx.focus,
4111
4142
  onClose: _ctx.onClose
4112
4143
  }, {
4113
4144
  header: vue.withCtx(() => [vue.renderSlot(_ctx.$slots, "heading", {}, () => [vue.createTextVNode(vue.toDisplayString(_ctx.heading), 1)])]),
@@ -4121,7 +4152,7 @@ function _sfc_render$_(_ctx, _cache, $props, $setup, $data, $options) {
4121
4152
  }, [vue.createElementVNode("span", null, vue.toDisplayString(button.label), 1), _cache[0] || (_cache[0] = vue.createTextVNode()), button.screenreader ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_3$v, " " + vue.toDisplayString(button.screenreader), 1)) : vue.createCommentVNode("", true)], 10, _hoisted_2$D);
4122
4153
  }), 128))])]),
4123
4154
  _: 3
4124
- }, 8, ["fullscreen", "is-open", "aria-close-text", "size", "onClose"]);
4155
+ }, 8, ["fullscreen", "is-open", "aria-close-text", "size", "focus", "onClose"]);
4125
4156
  }
4126
4157
  const FConfirmModal = /* @__PURE__ */ _export_sfc(_sfc_main$1a, [["render", _sfc_render$_]]);
4127
4158
  const GAP = ["1x", "2x", "3x", "4x", "5x", "6x", "7x", "8x"];