knt-shared 1.4.6 → 1.4.7

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;
@@ -6871,12 +6877,23 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6871
6877
  const getBindValue = computed(() => {
6872
6878
  const propsData = unref(getProps);
6873
6879
  return {
6880
+ // Arco 原生属性完全透传
6881
+ defaultVisible: propsData.defaultVisible,
6882
+ title: propsData.title,
6874
6883
  width: fullscreenRef.value ? "100%" : propsData.width,
6875
- fullscreen: fullscreenRef.value,
6884
+ top: propsData.top,
6885
+ mask: propsData.mask,
6876
6886
  maskClosable: propsData.maskClosable,
6877
6887
  closable: propsData.closable,
6878
- unmountOnClose: propsData.unmountOnClose,
6888
+ okText: propsData.okText,
6889
+ cancelText: propsData.cancelText,
6890
+ okLoading: propsData.okLoading,
6891
+ okButtonProps: propsData.okButtonProps,
6892
+ cancelButtonProps: propsData.cancelButtonProps,
6893
+ fullscreen: fullscreenRef.value || propsData.fullscreen,
6879
6894
  alignCenter: propsData.alignCenter || propsData.centered,
6895
+ unmountOnClose: propsData.unmountOnClose,
6896
+ hideCancel: propsData.hideCancel,
6880
6897
  simple: propsData.simple,
6881
6898
  hideTitle: propsData.hideTitle,
6882
6899
  renderToBody: propsData.renderToBody,
@@ -6886,10 +6903,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6886
6903
  modalClass: propsData.modalClass,
6887
6904
  escToClose: propsData.escToClose,
6888
6905
  draggable: propsData.draggable,
6889
- mask: propsData.mask,
6890
- top: propsData.top,
6891
6906
  footer: propsData.footer === false ? false : void 0,
6892
- titleAlign: propsData.titleAlign
6907
+ titleAlign: propsData.titleAlign,
6908
+ // v2.24.0+ 新增属性
6909
+ maskAnimationName: propsData.maskAnimationName,
6910
+ modalAnimationName: propsData.modalAnimationName,
6911
+ // v2.31.0+ 新增属性
6912
+ bodyClass: propsData.bodyClass,
6913
+ bodyStyle: propsData.bodyStyle
6893
6914
  };
6894
6915
  });
6895
6916
  const getModalStyle = computed(() => {
@@ -6945,7 +6966,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6945
6966
  emit("update:visible", visible);
6946
6967
  emit("visible-change", visible);
6947
6968
  };
6948
- const handleOkInternal = async () => {
6969
+ const handleOkInternal = async (ev) => {
6949
6970
  const propsData = unref(getProps);
6950
6971
  if (confirmLoading.value || propsData.loading) {
6951
6972
  return;
@@ -6962,7 +6983,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6962
6983
  }
6963
6984
  });
6964
6985
  });
6965
- emit("ok");
6986
+ emit("ok", ev);
6966
6987
  handleVisibleChange(false);
6967
6988
  } catch (e) {
6968
6989
  } finally {
@@ -6975,7 +6996,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6975
6996
  try {
6976
6997
  const canClose = await propsData.closeFunc();
6977
6998
  if (canClose) {
6978
- emit("ok");
6999
+ emit("ok", ev);
6979
7000
  handleVisibleChange(false);
6980
7001
  }
6981
7002
  } finally {
@@ -6983,30 +7004,25 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6983
7004
  }
6984
7005
  return;
6985
7006
  }
6986
- emit("ok");
7007
+ emit("ok", ev);
6987
7008
  handleVisibleChange(false);
6988
7009
  };
6989
7010
  const handleOk = handleOkInternal;
6990
- const handleCancel = async () => {
7011
+ const handleCancel = async (ev) => {
6991
7012
  const propsData = unref(getProps);
6992
7013
  if (propsData.onBeforeCancel) {
6993
7014
  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");
7015
+ const result = propsData.onBeforeCancel();
7016
+ if (result === false) {
7017
+ return;
7018
+ }
7019
+ emit("cancel", ev);
7004
7020
  handleVisibleChange(false);
7005
7021
  } catch (e) {
7006
7022
  }
7007
7023
  return;
7008
7024
  }
7009
- emit("cancel");
7025
+ emit("cancel", ev);
7010
7026
  handleVisibleChange(false);
7011
7027
  };
7012
7028
  const handleFullscreen = () => {
@@ -7020,6 +7036,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
7020
7036
  };
7021
7037
  const closeModal = () => {
7022
7038
  handleVisibleChange(false);
7039
+ const propsData = unref(getProps);
7040
+ if (propsData.clearDataOnClose) {
7041
+ setTimeout(() => {
7042
+ clearData();
7043
+ }, 300);
7044
+ }
7023
7045
  };
7024
7046
  const changeOkLoading = (loading) => {
7025
7047
  confirmLoading.value = loading;
@@ -7031,13 +7053,19 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
7031
7053
  const getModalProps = () => {
7032
7054
  return { ...unref(getProps), visible: visibleRef.value };
7033
7055
  };
7056
+ const clearData = () => {
7057
+ propsRef.value = {};
7058
+ confirmLoading.value = false;
7059
+ modalLoading.value = false;
7060
+ };
7034
7061
  const modalMethods = {
7035
7062
  setModalProps,
7036
7063
  openModal,
7037
7064
  closeModal,
7038
7065
  changeOkLoading,
7039
7066
  changeLoading,
7040
- getModalProps
7067
+ getModalProps,
7068
+ clearData
7041
7069
  };
7042
7070
  __expose(modalMethods);
7043
7071
  watch(
@@ -7069,7 +7097,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
7069
7097
  visible: visibleRef.value,
7070
7098
  "onUpdate:visible": handleVisibleChange,
7071
7099
  onOk: unref(handleOk),
7072
- onCancel: handleCancel
7100
+ onCancel: handleCancel,
7101
+ onOpen: _cache[0] || (_cache[0] = ($event) => emit("open")),
7102
+ onClose: _cache[1] || (_cache[1] = ($event) => emit("close")),
7103
+ onBeforeOpen: _cache[2] || (_cache[2] = ($event) => emit("before-open")),
7104
+ onBeforeClose: _cache[3] || (_cache[3] = ($event) => emit("before-close"))
7073
7105
  }), createSlots({
7074
7106
  default: withCtx(() => [
7075
7107
  createVNode(_component_a_spin, {
@@ -7202,7 +7234,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
7202
7234
  };
7203
7235
  }
7204
7236
  });
7205
- const BasicModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-68fed17a"]]);
7237
+ const BasicModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-9c2dbbc8"]]);
7206
7238
  function useModal(props) {
7207
7239
  const modalRef = ref(null);
7208
7240
  const loadedRef = ref(false);
@@ -7249,13 +7281,37 @@ function useModal(props) {
7249
7281
  if (!modal) return false;
7250
7282
  return modal.getModalProps().visible || false;
7251
7283
  };
7284
+ const changeOkLoading = (loading) => {
7285
+ const modal = getModal();
7286
+ if (!modal) return;
7287
+ modal.changeOkLoading(loading);
7288
+ };
7289
+ const changeLoading = (loading) => {
7290
+ const modal = getModal();
7291
+ if (!modal) return;
7292
+ modal.changeLoading(loading);
7293
+ };
7294
+ const getModalProps = () => {
7295
+ const modal = getModal();
7296
+ if (!modal) return {};
7297
+ return modal.getModalProps();
7298
+ };
7299
+ const clearData = () => {
7300
+ const modal = getModal();
7301
+ if (!modal) return;
7302
+ modal.clearData();
7303
+ };
7252
7304
  return [
7253
7305
  register,
7254
7306
  {
7255
7307
  openModal,
7256
7308
  closeModal,
7257
7309
  setModalProps,
7258
- getVisible
7310
+ getVisible,
7311
+ changeOkLoading,
7312
+ changeLoading,
7313
+ getModalProps,
7314
+ clearData
7259
7315
  }
7260
7316
  ];
7261
7317
  }
@@ -7315,6 +7371,11 @@ function useModalInner(callbackFn) {
7315
7371
  if (!modal) return {};
7316
7372
  return modal.getModalProps();
7317
7373
  };
7374
+ const clearData = () => {
7375
+ const modal = getModal();
7376
+ if (!modal) return;
7377
+ modal.clearData();
7378
+ };
7318
7379
  onUnmounted(() => {
7319
7380
  modalRef.value = null;
7320
7381
  loadedRef.value = false;
@@ -7326,7 +7387,8 @@ function useModalInner(callbackFn) {
7326
7387
  changeOkLoading,
7327
7388
  changeLoading,
7328
7389
  setModalProps,
7329
- getModalProps
7390
+ getModalProps,
7391
+ clearData
7330
7392
  }
7331
7393
  ];
7332
7394
  }