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