knt-shared 1.4.6 → 1.4.8

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/dist/index.cjs.js CHANGED
@@ -6434,8 +6434,9 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
6434
6434
  "row-index": slotProps.rowIndex,
6435
6435
  value: vue.unref(getEditValue)(slotProps.record, col),
6436
6436
  error: vue.unref(getValidationError)(slotProps.record, col),
6437
+ "edit-config": props.editConfig,
6437
6438
  onChange: (val) => vue.unref(setEditValue)(slotProps.record, col, val)
6438
- }, null, 8, ["column", "record", "row-index", "value", "error", "onChange"])) : _ctx.$slots[col.dataIndex] ? vue.renderSlot(_ctx.$slots, col.dataIndex, vue.normalizeProps(vue.mergeProps({ key: 3 }, slotProps)), void 0, true) : col.customRender ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(renderCustomCell(col, slotProps)), { key: 4 })) : col.format ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 5 }, [
6439
+ }, null, 8, ["column", "record", "row-index", "value", "error", "edit-config", "onChange"])) : _ctx.$slots[col.dataIndex] ? vue.renderSlot(_ctx.$slots, col.dataIndex, vue.normalizeProps(vue.mergeProps({ key: 3 }, slotProps)), void 0, true) : col.customRender ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(renderCustomCell(col, slotProps)), { key: 4 })) : col.format ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 5 }, [
6439
6440
  vue.createTextVNode(vue.toDisplayString(col.format(
6440
6441
  slotProps.record[col.dataIndex],
6441
6442
  slotProps.record,
@@ -6460,7 +6461,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
6460
6461
  };
6461
6462
  }
6462
6463
  });
6463
- const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-efd7cfc7"]]);
6464
+ const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-eebe4c3c"]]);
6464
6465
  function useTable(options = {}) {
6465
6466
  const tableRef = vue.ref(null);
6466
6467
  const formRef = vue.ref(null);
@@ -6815,7 +6816,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
6815
6816
  visible: { type: Boolean, default: false },
6816
6817
  defaultVisible: { type: Boolean, default: false },
6817
6818
  title: {},
6818
- alignCenter: { type: Boolean },
6819
+ alignCenter: { type: Boolean, default: true },
6819
6820
  unmountOnClose: { type: Boolean },
6820
6821
  maskClosable: { type: Boolean, default: true },
6821
6822
  hideTitle: { type: Boolean },
@@ -6830,19 +6831,22 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
6830
6831
  fullscreen: { type: Boolean },
6831
6832
  width: { default: 520 },
6832
6833
  top: {},
6833
- renderToBody: { type: Boolean },
6834
+ renderToBody: { type: Boolean, default: true },
6834
6835
  popupContainer: {},
6835
6836
  maskStyle: {},
6836
6837
  modalStyle: {},
6837
6838
  modalClass: {},
6838
- popupAnimationName: {},
6839
6839
  mask: { type: Boolean, default: true },
6840
6840
  onBeforeOk: {},
6841
6841
  onBeforeCancel: {},
6842
- escToClose: { type: Boolean },
6842
+ escToClose: { type: Boolean, default: true },
6843
6843
  draggable: { type: Boolean, default: false },
6844
6844
  footer: { type: Boolean, default: true },
6845
6845
  titleAlign: { default: "center" },
6846
+ maskAnimationName: {},
6847
+ modalAnimationName: {},
6848
+ bodyClass: {},
6849
+ bodyStyle: { type: [Boolean, null, String, Object, Array] },
6846
6850
  height: {},
6847
6851
  minHeight: { default: 46 },
6848
6852
  useWrapper: { type: Boolean, default: true },
@@ -6856,9 +6860,11 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
6856
6860
  helpMessage: {},
6857
6861
  centered: { type: Boolean, default: false },
6858
6862
  closeFunc: {},
6859
- showFooter: { type: Boolean, default: true }
6863
+ showFooter: { type: Boolean, default: true },
6864
+ clearDataOnClose: { type: Boolean },
6865
+ _data: {}
6860
6866
  },
6861
- emits: ["register", "update:visible", "ok", "cancel", "visible-change"],
6867
+ emits: ["register", "update:visible", "ok", "cancel", "open", "close", "before-open", "before-close", "visible-change"],
6862
6868
  setup(__props, { expose: __expose, emit: __emit }) {
6863
6869
  const props = __props;
6864
6870
  const emit = __emit;
@@ -6870,28 +6876,65 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
6870
6876
  const getProps = vue.computed(() => {
6871
6877
  return { ...props, ...vue.unref(propsRef) };
6872
6878
  });
6879
+ const isValidClass = (value) => {
6880
+ if (value === void 0 || value === null) return false;
6881
+ return typeof value === "string" || Array.isArray(value);
6882
+ };
6883
+ const isValidStyle = (value) => {
6884
+ if (value === void 0 || value === null) return false;
6885
+ if (typeof value === "string") return true;
6886
+ if (Array.isArray(value)) return true;
6887
+ if (typeof value === "object" && !Array.isArray(value)) return true;
6888
+ return false;
6889
+ };
6890
+ const isValidButtonProps = (value) => {
6891
+ if (value === void 0 || value === null) return false;
6892
+ return typeof value === "object" && !Array.isArray(value);
6893
+ };
6894
+ const isValidPopupContainer = (value) => {
6895
+ if (value === void 0 || value === null) return false;
6896
+ return typeof value === "string" || value instanceof HTMLElement;
6897
+ };
6873
6898
  const getBindValue = vue.computed(() => {
6874
6899
  const propsData = vue.unref(getProps);
6875
6900
  return {
6901
+ // Arco 原生属性完全透传
6902
+ defaultVisible: propsData.defaultVisible,
6903
+ title: propsData.title,
6876
6904
  width: fullscreenRef.value ? "100%" : propsData.width,
6877
- fullscreen: fullscreenRef.value,
6905
+ top: propsData.top,
6906
+ mask: propsData.mask,
6878
6907
  maskClosable: propsData.maskClosable,
6879
6908
  closable: propsData.closable,
6880
- unmountOnClose: propsData.unmountOnClose,
6909
+ okText: propsData.okText,
6910
+ cancelText: propsData.cancelText,
6911
+ okLoading: propsData.okLoading,
6912
+ // 按钮属性需要类型检查
6913
+ okButtonProps: isValidButtonProps(propsData.okButtonProps) ? propsData.okButtonProps : void 0,
6914
+ cancelButtonProps: isValidButtonProps(propsData.cancelButtonProps) ? propsData.cancelButtonProps : void 0,
6915
+ fullscreen: fullscreenRef.value || propsData.fullscreen,
6881
6916
  alignCenter: propsData.alignCenter || propsData.centered,
6917
+ unmountOnClose: propsData.unmountOnClose,
6918
+ hideCancel: propsData.hideCancel,
6882
6919
  simple: propsData.simple,
6883
6920
  hideTitle: propsData.hideTitle,
6884
6921
  renderToBody: propsData.renderToBody,
6885
- popupContainer: propsData.popupContainer,
6886
- maskStyle: propsData.maskStyle,
6922
+ // popupContainer 需要类型检查
6923
+ popupContainer: isValidPopupContainer(propsData.popupContainer) ? propsData.popupContainer : void 0,
6924
+ // 样式属性需要类型检查
6925
+ maskStyle: isValidStyle(propsData.maskStyle) ? propsData.maskStyle : void 0,
6887
6926
  modalStyle: getModalStyle.value,
6888
- modalClass: propsData.modalClass,
6927
+ modalClass: isValidClass(propsData.modalClass) ? propsData.modalClass : void 0,
6889
6928
  escToClose: propsData.escToClose,
6890
6929
  draggable: propsData.draggable,
6891
- mask: propsData.mask,
6892
- top: propsData.top,
6893
6930
  footer: propsData.footer === false ? false : void 0,
6894
- titleAlign: propsData.titleAlign
6931
+ titleAlign: propsData.titleAlign,
6932
+ // v2.24.0+ 新增属性
6933
+ maskAnimationName: propsData.maskAnimationName,
6934
+ modalAnimationName: propsData.modalAnimationName,
6935
+ // v2.31.0+ 新增属性
6936
+ bodyClass: isValidClass(propsData.bodyClass) ? propsData.bodyClass : void 0,
6937
+ bodyStyle: isValidStyle(propsData.bodyStyle) ? propsData.bodyStyle : void 0
6895
6938
  };
6896
6939
  });
6897
6940
  const getModalStyle = vue.computed(() => {
@@ -6947,7 +6990,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
6947
6990
  emit("update:visible", visible);
6948
6991
  emit("visible-change", visible);
6949
6992
  };
6950
- const handleOkInternal = async () => {
6993
+ const handleOkInternal = async (ev) => {
6951
6994
  const propsData = vue.unref(getProps);
6952
6995
  if (confirmLoading.value || propsData.loading) {
6953
6996
  return;
@@ -6964,7 +7007,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
6964
7007
  }
6965
7008
  });
6966
7009
  });
6967
- emit("ok");
7010
+ emit("ok", ev);
6968
7011
  handleVisibleChange(false);
6969
7012
  } catch (e) {
6970
7013
  } finally {
@@ -6977,7 +7020,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
6977
7020
  try {
6978
7021
  const canClose = await propsData.closeFunc();
6979
7022
  if (canClose) {
6980
- emit("ok");
7023
+ emit("ok", ev);
6981
7024
  handleVisibleChange(false);
6982
7025
  }
6983
7026
  } finally {
@@ -6985,30 +7028,25 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
6985
7028
  }
6986
7029
  return;
6987
7030
  }
6988
- emit("ok");
7031
+ emit("ok", ev);
6989
7032
  handleVisibleChange(false);
6990
7033
  };
6991
7034
  const handleOk = handleOkInternal;
6992
- const handleCancel = async () => {
7035
+ const handleCancel = async (ev) => {
6993
7036
  const propsData = vue.unref(getProps);
6994
7037
  if (propsData.onBeforeCancel) {
6995
7038
  try {
6996
- await new Promise((resolve, reject) => {
6997
- propsData.onBeforeCancel((closed) => {
6998
- if (closed) {
6999
- resolve(true);
7000
- } else {
7001
- reject(false);
7002
- }
7003
- });
7004
- });
7005
- emit("cancel");
7039
+ const result = propsData.onBeforeCancel();
7040
+ if (result === false) {
7041
+ return;
7042
+ }
7043
+ emit("cancel", ev);
7006
7044
  handleVisibleChange(false);
7007
7045
  } catch (e) {
7008
7046
  }
7009
7047
  return;
7010
7048
  }
7011
- emit("cancel");
7049
+ emit("cancel", ev);
7012
7050
  handleVisibleChange(false);
7013
7051
  };
7014
7052
  const handleFullscreen = () => {
@@ -7022,6 +7060,12 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
7022
7060
  };
7023
7061
  const closeModal = () => {
7024
7062
  handleVisibleChange(false);
7063
+ const propsData = vue.unref(getProps);
7064
+ if (propsData.clearDataOnClose) {
7065
+ setTimeout(() => {
7066
+ clearData();
7067
+ }, 300);
7068
+ }
7025
7069
  };
7026
7070
  const changeOkLoading = (loading) => {
7027
7071
  confirmLoading.value = loading;
@@ -7033,13 +7077,19 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
7033
7077
  const getModalProps = () => {
7034
7078
  return { ...vue.unref(getProps), visible: visibleRef.value };
7035
7079
  };
7080
+ const clearData = () => {
7081
+ propsRef.value = {};
7082
+ confirmLoading.value = false;
7083
+ modalLoading.value = false;
7084
+ };
7036
7085
  const modalMethods = {
7037
7086
  setModalProps,
7038
7087
  openModal,
7039
7088
  closeModal,
7040
7089
  changeOkLoading,
7041
7090
  changeLoading,
7042
- getModalProps
7091
+ getModalProps,
7092
+ clearData
7043
7093
  };
7044
7094
  __expose(modalMethods);
7045
7095
  vue.watch(
@@ -7071,7 +7121,11 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
7071
7121
  visible: visibleRef.value,
7072
7122
  "onUpdate:visible": handleVisibleChange,
7073
7123
  onOk: vue.unref(handleOk),
7074
- onCancel: handleCancel
7124
+ onCancel: handleCancel,
7125
+ onOpen: _cache[0] || (_cache[0] = ($event) => emit("open")),
7126
+ onClose: _cache[1] || (_cache[1] = ($event) => emit("close")),
7127
+ onBeforeOpen: _cache[2] || (_cache[2] = ($event) => emit("before-open")),
7128
+ onBeforeClose: _cache[3] || (_cache[3] = ($event) => emit("before-close"))
7075
7129
  }), vue.createSlots({
7076
7130
  default: vue.withCtx(() => [
7077
7131
  vue.createVNode(_component_a_spin, {
@@ -7204,7 +7258,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
7204
7258
  };
7205
7259
  }
7206
7260
  });
7207
- const BasicModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-68fed17a"]]);
7261
+ const BasicModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-ce432825"]]);
7208
7262
  function useModal(props) {
7209
7263
  const modalRef = vue.ref(null);
7210
7264
  const loadedRef = vue.ref(false);
@@ -7251,13 +7305,37 @@ function useModal(props) {
7251
7305
  if (!modal) return false;
7252
7306
  return modal.getModalProps().visible || false;
7253
7307
  };
7308
+ const changeOkLoading = (loading) => {
7309
+ const modal = getModal();
7310
+ if (!modal) return;
7311
+ modal.changeOkLoading(loading);
7312
+ };
7313
+ const changeLoading = (loading) => {
7314
+ const modal = getModal();
7315
+ if (!modal) return;
7316
+ modal.changeLoading(loading);
7317
+ };
7318
+ const getModalProps = () => {
7319
+ const modal = getModal();
7320
+ if (!modal) return {};
7321
+ return modal.getModalProps();
7322
+ };
7323
+ const clearData = () => {
7324
+ const modal = getModal();
7325
+ if (!modal) return;
7326
+ modal.clearData();
7327
+ };
7254
7328
  return [
7255
7329
  register,
7256
7330
  {
7257
7331
  openModal,
7258
7332
  closeModal,
7259
7333
  setModalProps,
7260
- getVisible
7334
+ getVisible,
7335
+ changeOkLoading,
7336
+ changeLoading,
7337
+ getModalProps,
7338
+ clearData
7261
7339
  }
7262
7340
  ];
7263
7341
  }
@@ -7317,6 +7395,11 @@ function useModalInner(callbackFn) {
7317
7395
  if (!modal) return {};
7318
7396
  return modal.getModalProps();
7319
7397
  };
7398
+ const clearData = () => {
7399
+ const modal = getModal();
7400
+ if (!modal) return;
7401
+ modal.clearData();
7402
+ };
7320
7403
  vue.onUnmounted(() => {
7321
7404
  modalRef.value = null;
7322
7405
  loadedRef.value = false;
@@ -7328,7 +7411,8 @@ function useModalInner(callbackFn) {
7328
7411
  changeOkLoading,
7329
7412
  changeLoading,
7330
7413
  setModalProps,
7331
- getModalProps
7414
+ getModalProps,
7415
+ clearData
7332
7416
  }
7333
7417
  ];
7334
7418
  }