knt-shared 1.5.1 → 1.5.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"BasicTable.vue.d.ts","sourceRoot":"","sources":["../../../src/components/Table/BasicTable.vue"],"names":[],"mappings":"AA8TA;AAYA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAgBpD,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EAGf,qBAAqB,EAGtB,MAAM,SAAS,CAAC;AA0vCjB,iBAAS,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2gC+D,GAAG,wCAClB,GAAG;wBAEzC,GAAG;;;QACN,GAAG;EAGhC;AA+DD,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BA93Cc,SAAS,EAAE;mBAOlB;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC;;;;;+BAeT,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE;gCAMlB,MAAM,GAAG,MAAM;;0BAUf,OAAO,CAAC,qBAAqB,CAAC;;oBAI1C,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO;6BAGtB,WAAW,EAAE;;yBAIjB,OAAO,CAAC,eAAe,CAAC;0BAQ7B,OAAO;;kCAMO,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iFAu0C5D,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAAvG,wBAAwG;AACxG,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AAC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C,CAAC,EAAE,CAAC,IAAI;KAE1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QACxE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KACb,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AACN,KAAK,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC;AACxD,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAO;QAClD,MAAM,EAAE,CAAC,CAAC;KACT,CAAA;CAAE,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -6225,6 +6225,19 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
6225
6225
  }
6226
6226
  return (pagination.current - 1) * pagination.pageSize + rowIndex + 1;
6227
6227
  };
6228
+ const showConfirmModal = (action, record) => {
6229
+ webVue.Modal.confirm({
6230
+ title: action.popConfirm.title,
6231
+ content: action.popConfirm.content,
6232
+ okText: action.popConfirm.okText,
6233
+ cancelText: action.popConfirm.cancelText,
6234
+ onOk: () => {
6235
+ var _a, _b;
6236
+ return (_b = (_a = action.popConfirm).onConfirm) == null ? void 0 : _b.call(_a, record);
6237
+ },
6238
+ onCancel: action.popConfirm.onCancel
6239
+ });
6240
+ };
6228
6241
  const renderCustomCell = (col, slotProps) => {
6229
6242
  if (!col.customRender) return null;
6230
6243
  const result = col.customRender(slotProps);
@@ -6448,7 +6461,9 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
6448
6461
  };
6449
6462
  }
6450
6463
  if (!Array.isArray(result[listField])) {
6451
- console.warn(`API 响应格式警告:${listField} 字段不是数组,已转换为空数组`);
6464
+ console.warn(
6465
+ `API 响应格式警告:${listField} 字段不是数组,已转换为空数组`
6466
+ );
6452
6467
  }
6453
6468
  let data = Array.isArray(result[listField]) ? result[listField] : [];
6454
6469
  let total = typeof result[totalField] === "number" ? result[totalField] : data.length;
@@ -6858,25 +6873,25 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
6858
6873
  }, {
6859
6874
  content: vue.withCtx(() => [
6860
6875
  vue.createVNode(_component_a_doption, { value: "mini" }, {
6861
- default: vue.withCtx(() => [..._cache[3] || (_cache[3] = [
6876
+ default: vue.withCtx(() => [..._cache[2] || (_cache[2] = [
6862
6877
  vue.createTextVNode("紧凑", -1)
6863
6878
  ])]),
6864
6879
  _: 1
6865
6880
  }),
6866
6881
  vue.createVNode(_component_a_doption, { value: "small" }, {
6867
- default: vue.withCtx(() => [..._cache[4] || (_cache[4] = [
6882
+ default: vue.withCtx(() => [..._cache[3] || (_cache[3] = [
6868
6883
  vue.createTextVNode("偏小", -1)
6869
6884
  ])]),
6870
6885
  _: 1
6871
6886
  }),
6872
6887
  vue.createVNode(_component_a_doption, { value: "medium" }, {
6873
- default: vue.withCtx(() => [..._cache[5] || (_cache[5] = [
6888
+ default: vue.withCtx(() => [..._cache[4] || (_cache[4] = [
6874
6889
  vue.createTextVNode("默认", -1)
6875
6890
  ])]),
6876
6891
  _: 1
6877
6892
  }),
6878
6893
  vue.createVNode(_component_a_doption, { value: "large" }, {
6879
- default: vue.withCtx(() => [..._cache[6] || (_cache[6] = [
6894
+ default: vue.withCtx(() => [..._cache[5] || (_cache[5] = [
6880
6895
  vue.createTextVNode("宽松", -1)
6881
6896
  ])]),
6882
6897
  _: 1
@@ -7055,40 +7070,16 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
7055
7070
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, {
7056
7071
  key: action.label
7057
7072
  }, [
7058
- action.popConfirm ? (vue.openBlock(), vue.createBlock(_component_a_popconfirm, {
7073
+ action.popConfirm ? (vue.openBlock(), vue.createBlock(_component_a_doption, {
7059
7074
  key: 0,
7060
- content: action.popConfirm.title,
7061
- "ok-text": action.popConfirm.okText,
7062
- "cancel-text": action.popConfirm.cancelText,
7063
- position: "lt",
7064
- onOk: ($event) => {
7065
- var _a2, _b2;
7066
- return (_b2 = (_a2 = action.popConfirm).onConfirm) == null ? void 0 : _b2.call(_a2, slotProps.record);
7067
- },
7068
- onCancel: action.popConfirm.onCancel
7075
+ disabled: getActionDisabled(action, slotProps.record),
7076
+ onClick: () => showConfirmModal(action, slotProps.record)
7069
7077
  }, {
7070
7078
  default: vue.withCtx(() => [
7071
- vue.createVNode(_component_a_doption, {
7072
- disabled: getActionDisabled(action, slotProps.record),
7073
- onClick: _cache[2] || (_cache[2] = vue.withModifiers(() => {
7074
- }, ["stop"]))
7075
- }, vue.createSlots({
7076
- default: vue.withCtx(() => [
7077
- vue.createTextVNode(" " + vue.toDisplayString(action.label), 1)
7078
- ]),
7079
- _: 2
7080
- }, [
7081
- action.icon ? {
7082
- name: "icon",
7083
- fn: vue.withCtx(() => [
7084
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(action.icon)))
7085
- ]),
7086
- key: "0"
7087
- } : void 0
7088
- ]), 1032, ["disabled"])
7079
+ vue.createTextVNode(vue.toDisplayString(action.label), 1)
7089
7080
  ]),
7090
7081
  _: 2
7091
- }, 1032, ["content", "ok-text", "cancel-text", "onOk", "onCancel"])) : (vue.openBlock(), vue.createBlock(_component_a_doption, {
7082
+ }, 1032, ["disabled", "onClick"])) : (vue.openBlock(), vue.createBlock(_component_a_doption, {
7092
7083
  key: 1,
7093
7084
  disabled: getActionDisabled(action, slotProps.record),
7094
7085
  onClick: ($event) => handleActionClick(action, slotProps.record)
@@ -7156,7 +7147,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
7156
7147
  };
7157
7148
  }
7158
7149
  });
7159
- const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a9281777"]]);
7150
+ const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-e9508ce7"]]);
7160
7151
  function useTable(options = {}) {
7161
7152
  const tableRef = vue.ref(null);
7162
7153
  const formRef = vue.ref(null);
@@ -8676,6 +8667,44 @@ function arrayToMap(array, options) {
8676
8667
  });
8677
8668
  return map;
8678
8669
  }
8670
+ function transformTree(tree, transform, options) {
8671
+ if (!tree || !Array.isArray(tree) || tree.length === 0) {
8672
+ return [];
8673
+ }
8674
+ const { childrenField = "children" } = options || {};
8675
+ function transformNodes(nodes, level = 0, parent = null, parentPath = [], ancestors = []) {
8676
+ return nodes.map((node, index) => {
8677
+ const currentPath = [...parentPath, index];
8678
+ const children = node[childrenField];
8679
+ const hasChildren = children && Array.isArray(children) && children.length > 0;
8680
+ const context = {
8681
+ level,
8682
+ index,
8683
+ parent,
8684
+ path: currentPath,
8685
+ ancestors,
8686
+ isLeaf: !hasChildren
8687
+ };
8688
+ const transformedNode = transform(node, context);
8689
+ if (hasChildren) {
8690
+ const newAncestors = [...ancestors, node];
8691
+ const transformedChildren = transformNodes(
8692
+ children,
8693
+ level + 1,
8694
+ node,
8695
+ currentPath,
8696
+ newAncestors
8697
+ );
8698
+ return {
8699
+ ...transformedNode,
8700
+ [childrenField]: transformedChildren
8701
+ };
8702
+ }
8703
+ return transformedNode;
8704
+ });
8705
+ }
8706
+ return transformNodes(tree);
8707
+ }
8679
8708
  function isNullOrUnDef(value) {
8680
8709
  return value === null || value === void 0;
8681
8710
  }
@@ -8865,6 +8894,7 @@ exports.safeToString = safeToString;
8865
8894
  exports.throttle = throttle;
8866
8895
  exports.transFormUrlPath = transFormUrlPath;
8867
8896
  exports.transformBackUrl = transformBackUrl;
8897
+ exports.transformTree = transformTree;
8868
8898
  exports.transformUploadUrl = transformUploadUrl;
8869
8899
  exports.useApiRequest = useApiRequest;
8870
8900
  exports.useDebounce = useDebounce;