@veltra/desktop 1.2.8 → 1.2.10

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.
Files changed (67) hide show
  1. package/dist/components/action/action-group.vue.d.ts +1 -1
  2. package/dist/components/auto-complete/auto-complete.vue.d.ts +2 -2
  3. package/dist/components/batch-edit/batch-edit-form.js +40 -74
  4. package/dist/components/batch-edit/batch-edit-form.js.map +1 -1
  5. package/dist/components/batch-edit/batch-edit-list.js +17 -29
  6. package/dist/components/batch-edit/batch-edit-list.js.map +1 -1
  7. package/dist/components/batch-edit/batch-edit.js +37 -60
  8. package/dist/components/batch-edit/batch-edit.js.map +1 -1
  9. package/dist/components/batch-edit/batch-edit.vue.d.ts +3 -14
  10. package/dist/components/batch-edit/di.js.map +1 -1
  11. package/dist/components/batch-edit/form-action-header.js +25 -0
  12. package/dist/components/batch-edit/form-action-header.js.map +1 -0
  13. package/dist/components/batch-edit/style2.css +0 -13
  14. package/dist/components/batch-edit/use-edit-state.js +44 -0
  15. package/dist/components/batch-edit/use-edit-state.js.map +1 -0
  16. package/dist/components/batch-edit/use-handlers.js +146 -0
  17. package/dist/components/batch-edit/use-handlers.js.map +1 -0
  18. package/dist/components/batch-edit/use-shortcut-key.js +44 -0
  19. package/dist/components/batch-edit/use-shortcut-key.js.map +1 -0
  20. package/dist/components/cascade/cascade.vue.d.ts +2 -2
  21. package/dist/components/date-picker/date-picker.vue.d.ts +2 -2
  22. package/dist/components/date-range-picker/date-range-picker.vue.d.ts +2 -2
  23. package/dist/components/form/form.js.map +1 -1
  24. package/dist/components/form/form.vue.d.ts +5 -1
  25. package/dist/components/form/form.vue_vue_type_script_setup_true_lang.js +8 -2
  26. package/dist/components/form/form.vue_vue_type_script_setup_true_lang.js.map +1 -1
  27. package/dist/components/form-item/form-item.js.map +1 -1
  28. package/dist/components/form-item/form-item.vue_vue_type_script_setup_true_lang.js +3 -2
  29. package/dist/components/form-item/form-item.vue_vue_type_script_setup_true_lang.js.map +1 -1
  30. package/dist/components/input/input.vue.d.ts +2 -2
  31. package/dist/components/multi-select/multi-select.vue.d.ts +2 -2
  32. package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +3 -3
  33. package/dist/components/number-input/number-input.vue.d.ts +2 -2
  34. package/dist/components/number-range-input/number-range-input.vue.d.ts +1 -1
  35. package/dist/components/password-input/password-input.vue.d.ts +1 -1
  36. package/dist/components/progress-nodes/progress-nodes.vue.d.ts +1 -1
  37. package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
  38. package/dist/components/select/select.vue.d.ts +2 -2
  39. package/dist/components/tabs/tabs-horizontal.vue.d.ts +2 -2
  40. package/dist/components/tabs/tabs-vertical.vue.d.ts +2 -2
  41. package/dist/components/tabs/tabs.vue.d.ts +2 -2
  42. package/dist/components/textarea/textarea.vue.d.ts +2 -2
  43. package/dist/components/tree/tree.vue.d.ts +1 -1
  44. package/dist/components/tree-select/tree-select.vue.d.ts +3 -3
  45. package/dist/components/watermark/watermark.vue.d.ts +1 -1
  46. package/dist/index.d.ts +4 -4
  47. package/dist/types/batch-edit.d.ts +38 -12
  48. package/dist/types/form.d.ts +4 -1
  49. package/dist/types/index.d.ts +3 -3
  50. package/package.json +6 -6
  51. package/src/components/batch-edit/batch-edit-form.vue +39 -79
  52. package/src/components/batch-edit/batch-edit-list.vue +13 -29
  53. package/src/components/batch-edit/batch-edit.vue +27 -92
  54. package/src/components/batch-edit/di.ts +6 -5
  55. package/src/components/batch-edit/form-action-header.ts +21 -0
  56. package/src/components/batch-edit/style.scss +0 -14
  57. package/src/components/batch-edit/use-dialog-effect.ts +21 -0
  58. package/src/components/batch-edit/use-edit-state.ts +61 -0
  59. package/src/components/batch-edit/use-handlers.ts +226 -0
  60. package/src/components/batch-edit/use-shortcut-key.ts +58 -0
  61. package/src/components/form/form.vue +10 -3
  62. package/src/components/form-item/form-item.vue +4 -2
  63. package/src/types/batch-edit.ts +43 -22
  64. package/src/types/form.ts +4 -0
  65. package/dist/components/batch-edit/use-edit.js +0 -231
  66. package/dist/components/batch-edit/use-edit.js.map +0 -1
  67. package/src/components/batch-edit/use-edit.ts +0 -365
@@ -7,9 +7,9 @@ type __VLS_Slots = {
7
7
  };
8
8
  declare const __VLS_base: import("vue").DefineComponent<ActionGroupProps, _ActionGroupExposed, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ActionGroupProps> & Readonly<{}>, {
9
9
  type: import("@veltra/utils").ColorType;
10
- max: number;
11
10
  size: "small" | "default" | "large";
12
11
  text: boolean;
12
+ max: number;
13
13
  circle: boolean;
14
14
  loading: boolean;
15
15
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -22,10 +22,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, _Auto
22
22
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
23
23
  onSelect?: ((value: string) => any) | undefined;
24
24
  }>, {
25
- placeholder: string;
26
- clearable: boolean;
27
25
  disabled: boolean;
28
26
  readonly: boolean;
27
+ placeholder: string;
28
+ clearable: boolean;
29
29
  allowCustom: boolean;
30
30
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
31
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -4,16 +4,18 @@ import form_default from "../form/form.js";
4
4
  import _sfc_main$3 from "../button/button.js";
5
5
  import _sfc_main$4 from "../kbd/kbd.js";
6
6
  import { BatchEditDIKey } from "./di.js";
7
- import { Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, inject, normalizeClass, normalizeProps, openBlock, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, toRef, unref, withCtx } from "vue";
7
+ import { FORM_ACTION_HEADER_MAP } from "./form-action-header.js";
8
+ import { Fragment, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, inject, normalizeClass, normalizeProps, openBlock, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, toRef, unref, withCtx } from "vue";
8
9
  import { bem } from "@veltra/utils";
9
- import { AddChild, Close, EditPen, Plus, View } from "@veltra/icons/normal";
10
+ import { Close } from "@veltra/icons/normal";
11
+ import { o } from "@cat-kit/core";
10
12
  //#region src/components/batch-edit/batch-edit-form.vue
11
13
  const _sfc_main = /* @__PURE__ */ defineComponent({
12
14
  name: "BatchEditForm",
13
15
  __name: "batch-edit-form",
14
16
  setup(__props, { expose: __expose }) {
15
17
  const batchEditCtx = inject(BatchEditDIKey);
16
- const { cls, props, state, insertIndexes, handleSave, handleClose, staticFeatures, dynamicFeatures } = batchEditCtx;
18
+ const { cls, props, state, handleClose, handleSave, staticFeatures, dynamicFeatures } = batchEditCtx;
17
19
  const focused = toRef(batchEditCtx, "focused");
18
20
  const formComponentRef = shallowRef();
19
21
  __expose({
@@ -22,58 +24,42 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
22
24
  clearValidate: () => formComponentRef.value?.clearValidate(),
23
25
  reset: () => formComponentRef.value?.reset()
24
26
  });
27
+ function handleFieldChange(field, value) {
28
+ if (state.row && props.quickEdit) o(state.row.data).set(field, value);
29
+ }
25
30
  const creatable = computed(() => {
26
- return state.type === "create" && (staticFeatures.value.has("create") || dynamicFeatures.value.create?.(state.row));
31
+ if (state.formActionType !== "create") return false;
32
+ return staticFeatures.value.has("create") || dynamicFeatures.value.create?.(state.row);
33
+ });
34
+ const creatableChild = computed(() => {
35
+ if (state.formActionType !== "createChild") return false;
36
+ return staticFeatures.value.has("createChild") || dynamicFeatures.value.createChild?.(state.row);
27
37
  });
28
38
  const updatable = computed(() => {
29
- return state.type === "update" && (staticFeatures.value.has("update") || dynamicFeatures.value.update?.(state.row));
39
+ if (state.formActionType !== "update") return false;
40
+ return staticFeatures.value.has("update") || dynamicFeatures.value.update?.(state.row);
30
41
  });
31
- const isQuick = computed(() => props.mode === "quick");
32
- const isNormal = computed(() => props.mode !== "quick");
33
- const isQuickUpdate = computed(() => isQuick.value && state.type === "update");
34
- const headerInfo = computed(() => {
35
- if (props.readonly) return {
36
- icon: View,
37
- title: "查看详情",
38
- chip: state.row ? `第 ${state.row.index + 1} 行` : void 0,
39
- tone: "view"
40
- };
41
- if (state.parentRow) return {
42
- icon: AddChild,
43
- title: "新增子级",
44
- chip: `归属于第 ${state.parentRow.index + 1} 行`,
45
- tone: "child"
46
- };
47
- if (state.type === "create") return {
48
- icon: Plus,
49
- title: "新增",
50
- tone: "create"
51
- };
52
- return {
53
- icon: EditPen,
54
- title: "编辑",
55
- chip: state.row ? `第 ${state.row.index + 1} 行` : void 0,
56
- tone: "update"
57
- };
42
+ const showSaveBtn = computed(() => {
43
+ if (props.readonly) return false;
44
+ if (props.quickEdit && state.formActionType === "update") return false;
45
+ return creatable.value || updatable.value || creatableChild.value;
58
46
  });
47
+ const headerInfo = computed(() => FORM_ACTION_HEADER_MAP[state.formActionType]);
59
48
  /** 通过 row 切换 / 类型切换驱动表单内容淡出淡入 */
60
49
  const bodyKey = computed(() => {
61
- return `${state.type}-${state.row?.uid ?? "create"}-${state.parentRow?.uid ?? "root"}`;
50
+ return `${state.formActionType}-${state.row?.uid ?? "create"}-${state.parentRow?.uid ?? "root"}`;
62
51
  });
63
52
  return (_ctx, _cache) => {
64
- return unref(state).visible && unref(props).model ? (openBlock(), createElementBlock("aside", {
53
+ return unref(state).formVisible && !!unref(props).model ? (openBlock(), createElementBlock("aside", {
65
54
  key: 0,
66
55
  class: normalizeClass(unref(cls).e("form"))
67
56
  }, [
68
57
  createElementVNode("header", { class: normalizeClass(unref(cls).e("form-header")) }, [
69
- createElementVNode("span", { class: normalizeClass([unref(cls).e("form-icon"), unref(bem).is(headerInfo.value.tone)]) }, [createVNode(unref(_sfc_main$1), null, {
58
+ createElementVNode("span", { class: normalizeClass([unref(cls).e("form-icon"), unref(bem).is(unref(state).formActionType)]) }, [createVNode(unref(_sfc_main$1), null, {
70
59
  default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(headerInfo.value.icon)))]),
71
60
  _: 1
72
61
  })], 2),
73
- createElementVNode("div", { class: normalizeClass(unref(cls).e("form-title")) }, [createElementVNode("h3", { class: normalizeClass(unref(cls).e("form-title-text")) }, toDisplayString(headerInfo.value.title), 3), headerInfo.value.chip ? (openBlock(), createElementBlock("span", {
74
- key: 0,
75
- class: normalizeClass(unref(cls).e("form-chip"))
76
- }, toDisplayString(headerInfo.value.chip), 3)) : createCommentVNode("v-if", true)], 2),
62
+ createElementVNode("div", { class: normalizeClass(unref(cls).e("form-title")) }, [createElementVNode("h3", { class: normalizeClass(unref(cls).e("form-title-text")) }, toDisplayString(headerInfo.value.title), 3)], 2),
77
63
  createVNode(unref(_sfc_main$3), {
78
64
  class: normalizeClass(unref(cls).e("form-close")),
79
65
  icon: unref(Close),
@@ -103,12 +89,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
103
89
  ref: formComponentRef,
104
90
  model: unref(props).model,
105
91
  readonly: unref(props).readonly,
106
- "label-width": unref(props).labelWidth
92
+ "label-width": unref(props).labelWidth,
93
+ "onField:change": handleFieldChange
107
94
  }, {
108
95
  default: withCtx(() => [renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
109
96
  row: unref(state).row,
110
97
  depth: unref(state).depth,
111
- indexes: unref(insertIndexes),
98
+ indexes: unref(state).indexPath,
112
99
  index: unref(state).row?.index
113
100
  })))]),
114
101
  _: 3
@@ -121,53 +108,32 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
121
108
  })]),
122
109
  _: 3
123
110
  }, 8, ["class"])),
124
- createElementVNode("footer", { class: normalizeClass(unref(cls).e("form-footer")) }, [unref(props).readonly ? (openBlock(), createElementBlock("span", {
125
- key: 0,
126
- class: normalizeClass(unref(cls).e("form-hint"))
127
- }, "只读模式", 2)) : isQuickUpdate.value ? (openBlock(), createElementBlock("span", {
128
- key: 1,
129
- class: normalizeClass(unref(cls).e("form-hint"))
130
- }, [_cache[3] || (_cache[3] = createTextVNode(" 实时编辑 ", -1)), createElementVNode("span", { class: normalizeClass({ [unref(bem).is("concealed")]: !focused.value }) }, [
131
- _cache[1] || (_cache[1] = createTextVNode(" · ", -1)),
132
- createVNode(unref(_sfc_main$4), null, {
133
- default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Esc", -1)])]),
111
+ createElementVNode("footer", { class: normalizeClass(unref(cls).e("form-footer")) }, [createElementVNode("span", { class: normalizeClass(unref(cls).e("form-hint")) }, [unref(props).readonly ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(" 只读模式 ")], 64)) : createCommentVNode("v-if", true), createElementVNode("span", { class: normalizeClass({ [unref(bem).is("concealed")]: !focused.value }) }, [
112
+ !(unref(state).formActionType === "update" && unref(props).quickEdit) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createVNode(unref(_sfc_main$4), null, {
113
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Ctrl + S", -1)])]),
134
114
  _: 1
135
- }),
136
- _cache[2] || (_cache[2] = createTextVNode(" 关闭", -1))
137
- ], 2)], 2)) : (openBlock(), createElementBlock("span", {
138
- key: 2,
139
- class: normalizeClass(unref(cls).e("form-hint"))
140
- }, [createElementVNode("span", { class: normalizeClass({ [unref(bem).is("concealed")]: !focused.value }) }, [
141
- createVNode(unref(_sfc_main$4), null, {
142
- default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("Ctrl + S", -1)])]),
143
- _: 1
144
- }),
145
- _cache[6] || (_cache[6] = createTextVNode(" 保存 · ", -1)),
115
+ }), _cache[1] || (_cache[1] = createTextVNode(" 保存 · ", -1))], 64)) : createCommentVNode("v-if", true),
146
116
  createVNode(unref(_sfc_main$4), null, {
147
- default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("Esc", -1)])]),
117
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("Esc", -1)])]),
148
118
  _: 1
149
119
  }),
150
- _cache[7] || (_cache[7] = createTextVNode(" 关闭 ", -1))
151
- ], 2)], 2)), createElementVNode("div", { class: normalizeClass(unref(cls).e("form-actions")) }, [createVNode(unref(_sfc_main$3), {
120
+ _cache[3] || (_cache[3] = createTextVNode(" 关闭 ", -1))
121
+ ], 2)], 2), createElementVNode("div", { class: normalizeClass(unref(cls).e("form-actions")) }, [createVNode(unref(_sfc_main$3), {
152
122
  text: "",
153
123
  loading: unref(state).loading,
154
124
  onClick: unref(handleClose)
155
125
  }, {
156
- default: withCtx(() => [..._cache[8] || (_cache[8] = [createTextVNode(" 取消 ", -1)])]),
126
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode(" 取消 ", -1)])]),
157
127
  _: 1
158
- }, 8, ["loading", "onClick"]), !unref(props).readonly && (isNormal.value && (creatable.value || updatable.value) || isQuick.value && creatable.value) ? (openBlock(), createBlock(unref(_sfc_main$3), {
128
+ }, 8, ["loading", "onClick"]), showSaveBtn.value ? (openBlock(), createBlock(unref(_sfc_main$3), {
159
129
  key: 0,
160
- type: unref(state).type === "create" ? "success" : "primary",
130
+ type: "primary",
161
131
  loading: unref(state).loading,
162
132
  onClick: unref(handleSave)
163
133
  }, {
164
- default: withCtx(() => [..._cache[9] || (_cache[9] = [createTextVNode(" 保存 ", -1)])]),
134
+ default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode(" 保存 ", -1)])]),
165
135
  _: 1
166
- }, 8, [
167
- "type",
168
- "loading",
169
- "onClick"
170
- ])) : createCommentVNode("v-if", true)], 2)], 2)
136
+ }, 8, ["loading", "onClick"])) : createCommentVNode("v-if", true)], 2)], 2)
171
137
  ], 2)) : createCommentVNode("v-if", true);
172
138
  };
173
139
  }
@@ -1 +1 @@
1
- {"version":3,"file":"batch-edit-form.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit-form.vue"],"sourcesContent":["<template>\n <aside :class=\"cls.e('form')\" v-if=\"state.visible && props.model\">\n <header :class=\"cls.e('form-header')\">\n <span :class=\"[cls.e('form-icon'), bem.is(headerInfo.tone)]\">\n <u-icon>\n <component :is=\"headerInfo.icon\" />\n </u-icon>\n </span>\n <div :class=\"cls.e('form-title')\">\n <h3 :class=\"cls.e('form-title-text')\">{{ headerInfo.title }}</h3>\n <span v-if=\"headerInfo.chip\" :class=\"cls.e('form-chip')\">\n {{ headerInfo.chip }}\n </span>\n </div>\n <u-button\n :class=\"cls.e('form-close')\"\n :icon=\"Close\"\n text\n circle\n size=\"small\"\n title=\"关闭\"\n @click=\"handleClose\"\n />\n </header>\n\n <u-scroll always :class=\"cls.e('form-body')\" :key=\"bodyKey\">\n <transition name=\"fade\" appear mode=\"out-in\">\n <u-form\n ref=\"formComponentRef\"\n :model=\"props.model\"\n :readonly=\"props.readonly\"\n :label-width=\"props.labelWidth\"\n >\n <slot\n v-bind=\"{\n row: state.row,\n depth: state.depth,\n indexes: insertIndexes,\n index: state.row?.index\n }\"\n />\n </u-form>\n </transition>\n </u-scroll>\n\n <footer :class=\"cls.e('form-footer')\">\n <span :class=\"cls.e('form-hint')\" v-if=\"props.readonly\">只读模式</span>\n <span :class=\"cls.e('form-hint')\" v-else-if=\"isQuickUpdate\">\n 实时编辑\n <span :class=\"{ [bem.is('concealed')]: !focused }\"> · <u-kbd>Esc</u-kbd> 关闭</span>\n </span>\n <span :class=\"cls.e('form-hint')\" v-else>\n <span :class=\"{ [bem.is('concealed')]: !focused }\">\n <u-kbd>Ctrl + S</u-kbd> 保存 · <u-kbd>Esc</u-kbd> 关闭\n </span>\n </span>\n\n <div :class=\"cls.e('form-actions')\">\n <u-button text :loading=\"state.loading\" @click=\"handleClose\"> 取消 </u-button>\n <u-button\n v-if=\"\n !props.readonly && ((isNormal && (creatable || updatable)) || (isQuick && creatable))\n \"\n :type=\"state.type === 'create' ? 'success' : 'primary'\"\n :loading=\"state.loading\"\n @click=\"handleSave\"\n >\n 保存\n </u-button>\n </div>\n </footer>\n </aside>\n</template>\n\n<script lang=\"ts\" setup>\nimport { AddChild, Close, EditPen, Plus, View } from '@veltra/icons/normal'\nimport { bem } from '@veltra/utils'\nimport { computed, inject, shallowRef, toRef, type Component } from 'vue'\n\nimport type { _FormExposed, FormExposed } from '../../types/form'\nimport { UButton } from '../button'\nimport { UForm } from '../form'\nimport { UIcon } from '../icon'\nimport { UKbd } from '../kbd'\nimport { UScroll } from '../scroll'\nimport { BatchEditDIKey } from './di'\n\ndefineOptions({ name: 'BatchEditForm' })\n\nconst batchEditCtx = inject(BatchEditDIKey)!\n\nconst {\n cls,\n props,\n state,\n insertIndexes,\n handleSave,\n handleClose,\n staticFeatures,\n dynamicFeatures\n} = batchEditCtx\n\nconst focused = toRef(batchEditCtx, 'focused')\n\nconst formComponentRef = shallowRef<FormExposed>()\n\ndefineExpose<_FormExposed>({\n el: toRef(() => formComponentRef.value?.el),\n validate: () => formComponentRef.value?.validate() ?? Promise.resolve(true),\n clearValidate: () => formComponentRef.value?.clearValidate(),\n reset: () => formComponentRef.value?.reset()\n})\n\nconst creatable = computed(() => {\n return (\n state.type === 'create' &&\n (staticFeatures.value.has('create') || dynamicFeatures.value.create?.(state.row))\n )\n})\n\nconst updatable = computed(() => {\n return (\n state.type === 'update' &&\n (staticFeatures.value.has('update') || dynamicFeatures.value.update?.(state.row))\n )\n})\n\nconst isQuick = computed(() => props.mode === 'quick')\nconst isNormal = computed(() => props.mode !== 'quick')\nconst isQuickUpdate = computed(() => isQuick.value && state.type === 'update')\n\ninterface HeaderInfo {\n icon: Component\n title: string\n chip?: string\n tone: 'create' | 'update' | 'view' | 'child'\n}\n\nconst headerInfo = computed<HeaderInfo>(() => {\n if (props.readonly) {\n return {\n icon: View,\n title: '查看详情',\n chip: state.row ? `第 ${state.row.index + 1} 行` : undefined,\n tone: 'view'\n }\n }\n if (state.parentRow) {\n return {\n icon: AddChild,\n title: '新增子级',\n chip: `归属于第 ${state.parentRow.index + 1} 行`,\n tone: 'child'\n }\n }\n if (state.type === 'create') {\n return { icon: Plus, title: '新增', tone: 'create' }\n }\n return {\n icon: EditPen,\n title: '编辑',\n chip: state.row ? `第 ${state.row.index + 1} 行` : undefined,\n tone: 'update'\n }\n})\n\n/** 通过 row 切换 / 类型切换驱动表单内容淡出淡入 */\nconst bodyKey = computed(() => {\n return `${state.type}-${state.row?.uid ?? 'create'}-${state.parentRow?.uid ?? 'root'}`\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;EAyFA,MAAM,eAAe,OAAO,cAAc;EAE1C,MAAM,EACJ,KACA,OACA,OACA,eACA,YACA,aACA,gBACA,oBACE;EAEJ,MAAM,UAAU,MAAM,cAAc,SAAS;EAE7C,MAAM,mBAAmB,WAAwB;EAEjD,SAA2B;GACzB,IAAI,YAAY,iBAAiB,OAAO,EAAE;GAC1C,gBAAgB,iBAAiB,OAAO,SAAS,KAAK,QAAQ,QAAQ,IAAI;GAC1E,qBAAqB,iBAAiB,OAAO,cAAc;GAC3D,aAAa,iBAAiB,OAAO,MAAM;EAC7C,CAAC;EAED,MAAM,YAAY,eAAe;GAC/B,OACE,MAAM,SAAS,aACd,eAAe,MAAM,IAAI,QAAQ,KAAK,gBAAgB,MAAM,SAAS,MAAM,GAAG;EAEnF,CAAC;EAED,MAAM,YAAY,eAAe;GAC/B,OACE,MAAM,SAAS,aACd,eAAe,MAAM,IAAI,QAAQ,KAAK,gBAAgB,MAAM,SAAS,MAAM,GAAG;EAEnF,CAAC;EAED,MAAM,UAAU,eAAe,MAAM,SAAS,OAAO;EACrD,MAAM,WAAW,eAAe,MAAM,SAAS,OAAO;EACtD,MAAM,gBAAgB,eAAe,QAAQ,SAAS,MAAM,SAAS,QAAQ;EAS7E,MAAM,aAAa,eAA2B;GAC5C,IAAI,MAAM,UACR,OAAO;IACL,MAAM;IACN,OAAO;IACP,MAAM,MAAM,MAAM,KAAK,MAAM,IAAI,QAAQ,EAAE,MAAM,KAAA;IACjD,MAAM;GACR;GAEF,IAAI,MAAM,WACR,OAAO;IACL,MAAM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"}
1
+ {"version":3,"file":"batch-edit-form.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit-form.vue"],"sourcesContent":["<template>\n <aside :class=\"cls.e('form')\" v-if=\"state.formVisible && !!props.model\">\n <header :class=\"cls.e('form-header')\">\n <span :class=\"[cls.e('form-icon'), bem.is(state.formActionType)]\">\n <u-icon>\n <component :is=\"headerInfo.icon\" />\n </u-icon>\n </span>\n <div :class=\"cls.e('form-title')\">\n <h3 :class=\"cls.e('form-title-text')\">{{ headerInfo.title }}</h3>\n </div>\n <u-button\n :class=\"cls.e('form-close')\"\n :icon=\"Close\"\n text\n circle\n size=\"small\"\n title=\"关闭\"\n @click=\"handleClose\"\n />\n </header>\n\n <u-scroll always :class=\"cls.e('form-body')\" :key=\"bodyKey\">\n <transition name=\"fade\" appear mode=\"out-in\">\n <u-form\n ref=\"formComponentRef\"\n :model=\"props.model\"\n :readonly=\"props.readonly\"\n :label-width=\"props.labelWidth\"\n @field:change=\"handleFieldChange\"\n >\n <slot\n v-bind=\"{\n row: state.row,\n depth: state.depth,\n indexes: state.indexPath,\n index: state.row?.index\n }\"\n />\n </u-form>\n </transition>\n </u-scroll>\n\n <footer :class=\"cls.e('form-footer')\">\n <span :class=\"cls.e('form-hint')\">\n <template v-if=\"props.readonly\"> 只读模式 </template>\n\n <span :class=\"{ [bem.is('concealed')]: !focused }\">\n <template v-if=\"!(state.formActionType === 'update' && props.quickEdit)\">\n <u-kbd>Ctrl + S</u-kbd> 保存 ·\n </template>\n <u-kbd>Esc</u-kbd> 关闭\n </span>\n </span>\n\n <div :class=\"cls.e('form-actions')\">\n <u-button text :loading=\"state.loading\" @click=\"handleClose\"> 取消 </u-button>\n <u-button v-if=\"showSaveBtn\" type=\"primary\" :loading=\"state.loading\" @click=\"handleSave\">\n 保存\n </u-button>\n </div>\n </footer>\n </aside>\n</template>\n\n<script lang=\"ts\" setup>\nimport { o } from '@cat-kit/core'\nimport { Close } from '@veltra/icons/normal'\nimport { bem } from '@veltra/utils'\nimport { computed, inject, shallowRef, toRef } from 'vue'\n\nimport type { _FormExposed, FormExposed } from '../../types/form'\nimport { UButton } from '../button'\nimport { UForm } from '../form'\nimport { UIcon } from '../icon'\nimport { UKbd } from '../kbd'\nimport { UScroll } from '../scroll'\nimport { BatchEditDIKey } from './di'\nimport { FORM_ACTION_HEADER_MAP } from './form-action-header'\n\ndefineOptions({ name: 'BatchEditForm' })\n\nconst batchEditCtx = inject(BatchEditDIKey)!\n\nconst { cls, props, state, handleClose, handleSave, staticFeatures, dynamicFeatures } = batchEditCtx\n\nconst focused = toRef(batchEditCtx, 'focused')\n\nconst formComponentRef = shallowRef<FormExposed>()\n\ndefineExpose<_FormExposed>({\n el: toRef(() => formComponentRef.value?.el),\n validate: () => formComponentRef.value?.validate() ?? Promise.resolve(true),\n clearValidate: () => formComponentRef.value?.clearValidate(),\n reset: () => formComponentRef.value?.reset()\n})\n\nfunction handleFieldChange(field: string, value: any) {\n if (state.row && props.quickEdit) {\n o(state.row.data).set(field, value)\n }\n}\n\nconst creatable = computed(() => {\n if (state.formActionType !== 'create') return false\n return staticFeatures.value.has('create') || dynamicFeatures.value.create?.(state.row)\n})\n\nconst creatableChild = computed(() => {\n if (state.formActionType !== 'createChild') return false\n return staticFeatures.value.has('createChild') || dynamicFeatures.value.createChild?.(state.row)\n})\n\nconst updatable = computed(() => {\n if (state.formActionType !== 'update') return false\n return staticFeatures.value.has('update') || dynamicFeatures.value.update?.(state.row)\n})\n\nconst showSaveBtn = computed(() => {\n if (props.readonly) return false\n if (props.quickEdit && state.formActionType === 'update') return false\n return creatable.value || updatable.value || creatableChild.value\n})\n\nconst headerInfo = computed(() => FORM_ACTION_HEADER_MAP[state.formActionType])\n\n/** 通过 row 切换 / 类型切换驱动表单内容淡出淡入 */\nconst bodyKey = computed(() => {\n return `${state.formActionType}-${state.row?.uid ?? 'create'}-${state.parentRow?.uid ?? 'root'}`\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;EAkFA,MAAM,eAA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GAAA;KAAlE,MAAA;KAAM,SAAS,MAAA,KAAA,EAAM;KAAU,SAAO,MAAA,WAAA;;4BAAiB,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAAJ,QAAI,EAAA,CAAA,EAAA,CAAA;;mCACjD,YAAA,SAAA,UAAA,GAAhB,YAEW,MAAA,WAAA,GAAA;;KAFkB,MAAK;KAAW,SAAS,MAAA,KAAA,EAAM;KAAU,SAAO,MAAA,UAAA;;4BAE7E,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAFyF,QAEzF,EAAA,CAAA,EAAA,CAAA"}
@@ -3,9 +3,8 @@ import _sfc_main$2 from "../table/table.js";
3
3
  import { BatchEditDIKey } from "./di.js";
4
4
  import _sfc_main$3 from "../action/action.js";
5
5
  import action_group_default from "../action/action-group.js";
6
- import { computed, createBlock, createCommentVNode, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeProps, normalizeClass, openBlock, toDisplayString, unref, withCtx, withModifiers } from "vue";
7
- import { bem } from "@veltra/utils";
8
- import { AddChild, Copy, Delete, InsertToNext, InsertToPrev, Plus } from "@veltra/icons/normal";
6
+ import { computed, createBlock, createCommentVNode, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeProps, normalizeClass, openBlock, unref, withCtx, withModifiers } from "vue";
7
+ import { AddChild, Delete, InsertToNext, InsertToPrev, Plus } from "@veltra/icons/normal";
9
8
  import { o } from "@cat-kit/core";
10
9
  //#region src/components/batch-edit/batch-edit-list.vue
11
10
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -13,7 +12,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
13
12
  __name: "batch-edit-list",
14
13
  props: { slots: {} },
15
14
  setup(__props) {
16
- const { cls, state, tableRef, props, emit, staticFeatures, dynamicFeatures, handleCreate, handleCopy, handleDelete, handleInsertToNext, handleInsertToPrev, handleInsertChild } = inject(BatchEditDIKey);
15
+ const { cls, state, props, emit, staticFeatures, dynamicFeatures, handleCreate, handleDelete, handleInsertToNext, handleInsertToPrev, handleInsertChild } = inject(BatchEditDIKey);
17
16
  const tableProps = computed(() => {
18
17
  return o(props).omit([
19
18
  "model",
@@ -36,8 +35,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
36
35
  "create",
37
36
  "delete",
38
37
  "createChild",
39
- "update",
40
- "copy"
38
+ "update"
41
39
  ])) return props.columns;
42
40
  return (props.columns ?? []).concat({
43
41
  name: "操作",
@@ -49,27 +47,27 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
49
47
  });
50
48
  });
51
49
  function handleUpdateCurrentRow(row) {
52
- if (allowed("update", row)) {
53
- if (row) state.type = "update";
54
- state.row = row;
55
- state.depth = row?.depth;
56
- }
50
+ if (allowed("update", row)) state.row = row;
57
51
  }
58
52
  function canDelete(row) {
59
53
  return !props.readonly && allowed("delete", row);
60
54
  }
55
+ const showCreateBtn = computed(() => {
56
+ if (props.readonly) return false;
57
+ const hasFeature = staticFeatures.value.has("create") || dynamicFeatures.value.create?.();
58
+ const createActionVisible = state.formActionType === "create" && state.formVisible;
59
+ return hasFeature && !createActionVisible;
60
+ });
61
61
  return (_ctx, _cache) => {
62
62
  return openBlock(), createBlock(unref(_sfc_main$2), mergeProps(tableProps.value, {
63
63
  slots: __props.slots,
64
- class: [unref(cls).e("table"), unref(bem).is("editing", unref(state).visible)],
64
+ class: [unref(cls).e("table")],
65
65
  columns: columns.value,
66
66
  "highlight-current": "",
67
67
  current: unref(state).row,
68
68
  "onUpdate:current": handleUpdateCurrentRow,
69
69
  "onUpdate:checked": _cache[1] || (_cache[1] = ($event) => unref(emit)("update:checked", $event)),
70
- "onUpdate:selected": _cache[2] || (_cache[2] = ($event) => unref(emit)("update:selected", $event)),
71
- ref_key: "tableRef",
72
- ref: tableRef
70
+ "onUpdate:selected": _cache[2] || (_cache[2] = ($event) => unref(emit)("update:selected", $event))
73
71
  }), createSlots({
74
72
  "column:__action__": withCtx(({ row }) => [createVNode(unref(action_group_default), {
75
73
  class: normalizeClass(unref(cls).e("row-actions")),
@@ -96,14 +94,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
96
94
  title: "添加子级",
97
95
  onRun: ($event) => unref(handleInsertChild)(row)
98
96
  }, null, 8, ["icon", "onRun"])) : createCommentVNode("v-if", true),
99
- allowed("copy", row) ? (openBlock(), createBlock(unref(_sfc_main$3), {
100
- key: 3,
101
- icon: unref(Copy),
102
- title: "复制此行",
103
- onRun: ($event) => unref(handleCopy)(row)
104
- }, null, 8, ["icon", "onRun"])) : createCommentVNode("v-if", true),
105
97
  canDelete(row) ? (openBlock(), createBlock(unref(_sfc_main$3), mergeProps({
106
- key: 4,
98
+ key: 3,
107
99
  icon: unref(Delete),
108
100
  type: "danger",
109
101
  title: "删除",
@@ -113,11 +105,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
113
105
  _: 2
114
106
  }, 1032, ["class"])]),
115
107
  _: 2
116
- }, [!unref(props).readonly ? {
117
- name: "empty",
118
- fn: withCtx(() => [_cache[3] || (_cache[3] = createTextVNode(toDisplayString(null), -1))]),
119
- key: "0"
120
- } : void 0, !unref(props).readonly && (unref(staticFeatures).has("create") || unref(dynamicFeatures).create?.()) && (unref(state).type === "create" && !unref(state).visible || unref(state).type === "update") ? {
108
+ }, [showCreateBtn.value ? {
121
109
  name: "append",
122
110
  fn: withCtx(() => [createElementVNode("div", { class: normalizeClass(unref(cls).e("add")) }, [createVNode(unref(_sfc_main$1), {
123
111
  class: normalizeClass(unref(cls).e("add-btn")),
@@ -127,7 +115,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
127
115
  plain: "",
128
116
  onClick: withModifiers(unref(handleCreate), ["stop"])
129
117
  }, {
130
- default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode(" 新增一行 ", -1)])]),
118
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode(" 新增一行 ", -1)])]),
131
119
  _: 1
132
120
  }, 8, [
133
121
  "class",
@@ -135,7 +123,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
135
123
  "loading",
136
124
  "onClick"
137
125
  ])], 2)]),
138
- key: "1"
126
+ key: "0"
139
127
  } : void 0]), 1040, [
140
128
  "slots",
141
129
  "class",
@@ -1 +1 @@
1
- {"version":3,"file":"batch-edit-list.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit-list.vue"],"sourcesContent":["<template>\n <u-table\n v-bind=\"tableProps\"\n :slots=\"slots\"\n :class=\"[cls.e('table'), bem.is('editing', state.visible)]\"\n :columns=\"columns\"\n highlight-current\n :current=\"state.row\"\n @update:current=\"handleUpdateCurrentRow\"\n @update:checked=\"emit('update:checked', $event)\"\n @update:selected=\"emit('update:selected', $event)\"\n ref=\"tableRef\"\n >\n <template #column:__action__=\"{ row }\">\n <u-action-group :class=\"cls.e('row-actions')\" :max=\"5\" @click.stop circle>\n <u-action\n v-if=\"allowed('create', row)\"\n :icon=\"InsertToPrev\"\n title=\"在上方插入\"\n @run=\"handleInsertToPrev(row)\"\n />\n <u-action\n v-if=\"allowed('create', row)\"\n :icon=\"InsertToNext\"\n title=\"在下方插入\"\n @run=\"handleInsertToNext(row)\"\n />\n <u-action\n v-if=\"!!props.tree && allowed('createChild', row)\"\n :icon=\"AddChild\"\n title=\"添加子级\"\n @run=\"handleInsertChild(row)\"\n />\n <u-action\n v-if=\"allowed('copy', row)\"\n :icon=\"Copy\"\n title=\"复制此行\"\n @run=\"handleCopy(row)\"\n />\n\n <u-action\n v-if=\"canDelete(row)\"\n :icon=\"Delete\"\n type=\"danger\"\n title=\"删除\"\n @run=\"handleDelete(row)\"\n v-bind=\"props.actionsProps?.delete\"\n />\n </u-action-group>\n </template>\n\n <template #empty v-if=\"!props.readonly\"> {{ null }} </template>\n\n <template\n #append\n v-if=\"\n !props.readonly &&\n (staticFeatures.has('create') || dynamicFeatures.create?.()) &&\n ((state.type === 'create' && !state.visible) || state.type === 'update')\n \"\n >\n <div :class=\"cls.e('add')\">\n <u-button\n :class=\"cls.e('add-btn')\"\n :icon=\"Plus\"\n :loading=\"state.loading\"\n type=\"primary\"\n plain\n @click.stop=\"handleCreate\"\n >\n 新增一行\n </u-button>\n </div>\n </template>\n </u-table>\n</template>\n\n<script setup lang=\"ts\">\nimport { o } from '@cat-kit/core'\nimport { AddChild, Copy, Delete, InsertToNext, InsertToPrev, Plus } from '@veltra/icons/normal'\nimport { bem } from '@veltra/utils'\nimport { computed, inject, type Slots } from 'vue'\n\nimport type { BatchEditFeature, TableRow } from '../../types'\nimport { UAction, UActionGroup } from '../action'\nimport { UButton } from '../button'\nimport { UTable } from '../table'\nimport { BatchEditDIKey } from './di'\n\ndefineOptions({ name: 'BatchEditList' })\n\ndefineProps<{ slots: Slots }>()\n\nconst {\n cls,\n state,\n tableRef,\n props,\n emit,\n staticFeatures,\n dynamicFeatures,\n handleCreate,\n handleCopy,\n handleDelete,\n handleInsertToNext,\n handleInsertToPrev,\n handleInsertChild\n} = inject(BatchEditDIKey)!\n\nconst tableProps = computed(() => {\n return o(props as Record<string, any>).omit([\n 'model',\n 'columns',\n 'cols',\n 'readonly',\n 'deleteMethod',\n 'saveMethod',\n 'features',\n 'mode',\n 'beforeCreate'\n ])\n})\n\nconst hasNot = (value: BatchEditFeature[]) => value.every((v) => !staticFeatures.value.has(v))\n\nconst allowed = (feature: BatchEditFeature, row?: TableRow) => {\n return staticFeatures.value.has(feature) || !!dynamicFeatures.value[feature]?.(row)\n}\n\nconst columns = computed(() => {\n if (props.readonly || hasNot(['create', 'delete', 'createChild', 'update', 'copy']))\n return props.columns\n\n return (props.columns ?? []).concat({\n name: '操作',\n key: '__action__',\n align: 'center',\n width: 180,\n fixed: 'right',\n resizable: false\n })\n})\n\nfunction handleUpdateCurrentRow(row?: TableRow) {\n if (allowed('update', row)) {\n if (row) {\n state.type = 'update'\n }\n state.row = row\n state.depth = row?.depth\n }\n}\n\nfunction canDelete(row: TableRow) {\n return !props.readonly && allowed('delete', row)\n}\n</script>\n"],"mappings":";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QAKhB,MAAA,KAAA,EAAM,WAAA;UAAnB;sBAAwC,CAAA,OAAA,OAAA,OAAA,KAAA,gBAAA,gBAAP,IAAI,GAAA,EAAA,EAAA,CAAA;;gBAI9B,MAAA,KAAA,EAAM,aAAqB,MAAA,cAAA,EAAe,IAAG,QAAA,KAAc,MAAA,eAAA,EAAgB,SAAM,OAAmB,MAAA,KAAA,EAAM,SAAI,YAAA,CAAkB,MAAA,KAAA,EAAM,WAAY,MAAA,KAAA,EAAM,SAAI,YAAA;UAD3K;sBAkBK,CAXN,mBAWM,OAAA,EAXA,OAAK,eAAE,MAAA,GAAA,EAAI,EAAC,KAAA,CAAA,EAAA,GAAA,CAChB,YASW,MAAA,WAAA,GAAA;KARR,OAAK,eAAE,MAAA,GAAA,EAAI,EAAC,SAAA,CAAA;KACZ,MAAM,MAAA,IAAA;KACN,SAAS,MAAA,KAAA,EAAM;KAChB,MAAK;KACL,OAAA;KACC,SAAK,cAAO,MAAA,YAAA,GAAY,CAAA,MAAA,CAAA;;4BAG3B,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAFC,UAED,EAAA,CAAA,EAAA,CAAA"}
1
+ {"version":3,"file":"batch-edit-list.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit-list.vue"],"sourcesContent":["<template>\n <u-table\n v-bind=\"tableProps\"\n :slots=\"slots\"\n :class=\"[cls.e('table')]\"\n :columns=\"columns\"\n highlight-current\n :current=\"state.row\"\n @update:current=\"handleUpdateCurrentRow\"\n @update:checked=\"emit('update:checked', $event)\"\n @update:selected=\"emit('update:selected', $event)\"\n >\n <template #column:__action__=\"{ row }\">\n <u-action-group :class=\"cls.e('row-actions')\" :max=\"5\" @click.stop circle>\n <u-action\n v-if=\"allowed('create', row)\"\n :icon=\"InsertToPrev\"\n title=\"在上方插入\"\n @run=\"handleInsertToPrev(row)\"\n />\n <u-action\n v-if=\"allowed('create', row)\"\n :icon=\"InsertToNext\"\n title=\"在下方插入\"\n @run=\"handleInsertToNext(row)\"\n />\n <u-action\n v-if=\"!!props.tree && allowed('createChild', row)\"\n :icon=\"AddChild\"\n title=\"添加子级\"\n @run=\"handleInsertChild(row)\"\n />\n <u-action\n v-if=\"canDelete(row)\"\n :icon=\"Delete\"\n type=\"danger\"\n title=\"删除\"\n @run=\"handleDelete(row)\"\n v-bind=\"props.actionsProps?.delete\"\n />\n </u-action-group>\n </template>\n\n <!-- 新增按钮 -->\n <template #append v-if=\"showCreateBtn\">\n <div :class=\"cls.e('add')\">\n <u-button\n :class=\"cls.e('add-btn')\"\n :icon=\"Plus\"\n :loading=\"state.loading\"\n type=\"primary\"\n plain\n @click.stop=\"handleCreate\"\n >\n 新增一行\n </u-button>\n </div>\n </template>\n </u-table>\n</template>\n\n<script setup lang=\"ts\">\nimport { o } from '@cat-kit/core'\nimport { AddChild, Delete, InsertToNext, InsertToPrev, Plus } from '@veltra/icons/normal'\nimport { computed, inject, type Slots } from 'vue'\n\nimport type { BatchEditFeature, TableRow } from '../../types'\nimport { UAction, UActionGroup } from '../action'\nimport { UButton } from '../button'\nimport { UTable } from '../table'\nimport { BatchEditDIKey } from './di'\n\ndefineOptions({ name: 'BatchEditList' })\n\ndefineProps<{ slots: Slots }>()\n\nconst {\n cls,\n state,\n props,\n emit,\n staticFeatures,\n dynamicFeatures,\n handleCreate,\n handleDelete,\n handleInsertToNext,\n handleInsertToPrev,\n handleInsertChild\n} = inject(BatchEditDIKey)!\n\nconst tableProps = computed(() => {\n return o(props as Record<string, any>).omit([\n 'model',\n 'columns',\n 'cols',\n 'readonly',\n 'deleteMethod',\n 'saveMethod',\n 'features',\n 'mode',\n 'beforeCreate'\n ])\n})\n\nconst hasNot = (value: BatchEditFeature[]) => value.every((v) => !staticFeatures.value.has(v))\n\nconst allowed = (feature: BatchEditFeature, row?: TableRow) => {\n return staticFeatures.value.has(feature) || !!dynamicFeatures.value[feature]?.(row)\n}\n\nconst columns = computed(() => {\n if (props.readonly || hasNot(['create', 'delete', 'createChild', 'update'])) return props.columns\n\n return (props.columns ?? []).concat({\n name: '操作',\n key: '__action__',\n align: 'center',\n width: 180,\n fixed: 'right',\n resizable: false\n })\n})\n\nfunction handleUpdateCurrentRow(row?: TableRow) {\n if (allowed('update', row)) {\n state.row = row\n }\n}\n\nfunction canDelete(row: TableRow) {\n return !props.readonly && allowed('delete', row)\n}\n\nconst showCreateBtn = computed(() => {\n if (props.readonly) return false\n\n const hasFeature = staticFeatures.value.has('create') || dynamicFeatures.value.create?.()\n const createActionVisible = state.formActionType === 'create' && state.formVisible\n return hasFeature && !createActionVisible\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;EA4EA,MAAM,EACJ,KACA,OACA,OACA,MACA,gBACA,iBACA,cACA,cACA,oBACA,oBACA,sBACE,OAAO,cAAc;EAEzB,MAAM,aAAa,eAAe;GAChC,OAAO,EAAE,KAA4B,EAAE,KAAK;IAC1C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF,CAAC;EACH,CAAC;EAED,MAAM,UAAU,UAA8B,MAAM,OAAO,MAAM,CAAC,eAAe,MAAM,IAAI,CAAC,CAAC;EAE7F,MAAM,WAAW,SAA2B,QAAmB;GAC7D,OAAO,eAAe,MAAM,IAAI,OAAO,KAAK,CAAC,CAAC,gBAAgB,MAAM,WAAW,GAAG;EACpF;EAEA,MAAM,UAAU,eAAe;GAC7B,IAAI,MAAM,YAAY,OAAO;IAAC;IAAU;IAAU;IAAe;GAAQ,CAAC,GAAG,OAAO,MAAM;GAE1F,QAAQ,MAAM,WAAW,CAAC,GAAG,OAAO;IAClC,MAAM;IACN,KAAK;IACL,OAAO;IACP,OAAO;IACP,OAAO;IACP,WAAW;GACb,CAAC;EACH,CAAC;EAED,SAAS,uBAAuB,KAAgB;GAC9C,IAAI,QAAQ,UAAU,GAAG,GACvB,MAAM,MAAM;EAEhB;EAEA,SAAS,UAAU,KAAe;GAChC,OAAO,CAAC,MAAM,YAAY,QAAQ,UAAU,GAAG;EACjD;EAEA,MAAM,gBAA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AA,EAAkB,GAAG;;MAGrB,UAAU,GAAG,KAAA,UAAA,GADrB,YAOE,MAAA,WAAA,GAPF,WAOE;;OALC,MAAM,MAAA,MAAA;OACP,MAAK;OACL,OAAM;OACL,QAAG,WAAE,MAAA,YAAA,EAAa,GAAG;SACd,MAAA,KAAA,EAAM,cAAc,MAAM,GAAA,MAAA,IAAA,CAAA,QAAA,OAAA,CAAA,KAAA,mBAAA,QAAA,IAAA;;;;;OAMhB,cAAA,QAAA;UAAb;sBAYH,CAXN,mBAWM,OAAA,EAXA,OAAK,eAAE,MAAA,GAAA,EAAI,EAAC,KAAA,CAAA,EAAA,GAAA,CAChB,YASW,MAAA,WAAA,GAAA;KARR,OAAK,eAAE,MAAA,GAAA,EAAI,EAAC,SAAA,CAAA;KACZ,MAAM,MAAA,IAAA;KACN,SAAS,MAAA,KAAA,EAAM;KAChB,MAAK;KACL,OAAA;KACC,SAAK,cAAO,MAAA,YAAA,GAAY,CAAA,MAAA,CAAA;;4BAG3B,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAFC,UAED,EAAA,CAAA,EAAA,CAAA"}
@@ -1,11 +1,12 @@
1
1
  import _sfc_main$1 from "../layout/layout.js";
2
- import { DialogDIKey } from "../dialog/di.js";
3
2
  import { BatchEditDIKey } from "./di.js";
4
3
  import _sfc_main$2 from "./batch-edit-form.js";
5
4
  import _sfc_main$3 from "./batch-edit-list.js";
6
- import { useEdit } from "./use-edit.js";
5
+ import { useEditState } from "./use-edit-state.js";
7
6
  import { useFeatures } from "./use-features.js";
8
- import { computed, createBlock, createCommentVNode, createVNode, defineComponent, guardReactiveProps, inject, normalizeClass, normalizeProps, openBlock, provide, renderSlot, shallowRef, unref, useSlots, watch, withCtx } from "vue";
7
+ import { useHandlers } from "./use-handlers.js";
8
+ import { useShortcutKey } from "./use-shortcut-key.js";
9
+ import { computed, createBlock, createCommentVNode, createVNode, defineComponent, guardReactiveProps, normalizeClass, normalizeProps, openBlock, provide, renderSlot, unref, useSlots, useTemplateRef, withCtx } from "vue";
9
10
  import { bem } from "@veltra/utils";
10
11
  //#region src/components/batch-edit/batch-edit.vue
11
12
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -16,7 +17,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16
17
  title: {},
17
18
  cols: { default: () => ["1fr", "420px"] },
18
19
  readonly: { type: Boolean },
19
- mode: { default: "normal" },
20
+ quickEdit: { type: Boolean },
20
21
  beforeCreate: {},
21
22
  labelWidth: {},
22
23
  deleteMethod: {},
@@ -59,91 +60,67 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
59
60
  const emit = __emit;
60
61
  const slots = useSlots();
61
62
  const cls = bem("batch-edit");
62
- const tableRef = shallowRef();
63
- const formRef = shallowRef();
64
- const focused = shallowRef(false);
63
+ const formRef = useTemplateRef("form");
64
+ const { state, resetState } = useEditState({
65
+ props,
66
+ formRef
67
+ });
65
68
  const { staticFeatures, dynamicFeatures } = useFeatures({ props });
66
- const editCtx = useEdit({
69
+ const handlers = useHandlers({
67
70
  props,
68
71
  emit,
72
+ state,
73
+ resetState,
69
74
  formRef
70
75
  });
71
- const { state, handleClose, handleSave } = editCtx;
76
+ const { handleFocusIn, handleFocusOut, handleKeydown, focused } = useShortcutKey({
77
+ props,
78
+ onSave: handlers.handleSave,
79
+ onClose: handlers.handleClose,
80
+ state
81
+ });
82
+ const cols = computed(() => {
83
+ return state.formVisible ? props.cols : void 0;
84
+ });
72
85
  provide(BatchEditDIKey, {
73
86
  cls,
74
87
  props,
75
88
  emit,
76
- tableRef,
89
+ state,
77
90
  staticFeatures,
78
91
  dynamicFeatures,
79
92
  focused,
80
- ...editCtx
81
- });
82
- const dialogCtx = inject(DialogDIKey, void 0);
83
- dialogCtx && watch(dialogCtx.visible, (visible) => {
84
- !visible && editCtx.handleClose();
85
- });
86
- const cols = computed(() => {
87
- return !!state.row || state.visible ? props.cols : void 0;
93
+ ...handlers
88
94
  });
89
- function handleFocusIn() {
90
- focused.value = true;
91
- }
92
- function handleFocusOut(e) {
93
- if (!e.currentTarget.contains(e.relatedTarget)) focused.value = false;
94
- }
95
- /**
96
- * 键盘快捷键(仅组件获焦时生效):
97
- * - Esc 关闭表单
98
- * - ⌘/Ctrl + S 保存(快速编辑模式下编辑行时除外)
99
- */
100
- function handleKeydown(e) {
101
- if (!focused.value) return;
102
- if (props.readonly && e.key !== "Escape") return;
103
- if (e.key === "Escape") {
104
- if (state.visible) {
105
- e.preventDefault();
106
- handleClose();
107
- }
108
- return;
109
- }
110
- if (!(e.metaKey || e.ctrlKey)) return;
111
- if (e.key.toLowerCase() === "s" && state.visible) {
112
- if (props.mode === "quick" && state.type === "update") return;
113
- e.preventDefault();
114
- handleSave();
115
- }
116
- }
117
95
  return (_ctx, _cache) => {
118
96
  return openBlock(), createBlock(unref(_sfc_main$1), {
119
97
  class: normalizeClass(unref(cls).b),
120
98
  cols: cols.value,
121
- rows: "minmax(0, 1fr)",
99
+ rows: "minmax(0, 1fr) ",
122
100
  gap: "8px",
123
101
  resizable: "",
124
102
  tabindex: "-1",
125
- onFocusin: handleFocusIn,
126
- onFocusout: handleFocusOut,
127
- onKeydownCapture: handleKeydown
103
+ onFocusin: unref(handleFocusIn),
104
+ onFocusout: unref(handleFocusOut),
105
+ onKeydownCapture: unref(handleKeydown)
128
106
  }, {
129
107
  default: withCtx(() => [
130
108
  createCommentVNode(" 编辑列表 "),
131
- createVNode(_sfc_main$3, {
132
- slots,
133
- ref_key: "tableRef",
134
- ref: tableRef
135
- }, null, 512),
109
+ createVNode(_sfc_main$3, { slots }),
136
110
  createCommentVNode(" 编辑表单 "),
137
- createVNode(_sfc_main$2, {
138
- ref_key: "formRef",
139
- ref: formRef
140
- }, {
111
+ createVNode(_sfc_main$2, { ref: "form" }, {
141
112
  default: withCtx((scoped) => [renderSlot(_ctx.$slots, "form", normalizeProps(guardReactiveProps(scoped)))]),
142
113
  _: 3
143
114
  }, 512)
144
115
  ]),
145
116
  _: 3
146
- }, 8, ["class", "cols"]);
117
+ }, 8, [
118
+ "class",
119
+ "cols",
120
+ "onFocusin",
121
+ "onFocusout",
122
+ "onKeydownCapture"
123
+ ]);
147
124
  };
148
125
  }
149
126
  });
@@ -1 +1 @@
1
- {"version":3,"file":"batch-edit.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit.vue"],"sourcesContent":["<template>\n <u-layout\n :class=\"cls.b\"\n :cols=\"cols\"\n rows=\"minmax(0, 1fr)\"\n gap=\"8px\"\n resizable\n tabindex=\"-1\"\n @focusin=\"handleFocusIn\"\n @focusout=\"handleFocusOut\"\n @keydown.capture=\"handleKeydown\"\n >\n <!-- 编辑列表 -->\n <BatchEditList :slots=\"slots\" ref=\"tableRef\" />\n\n <!-- 编辑表单 -->\n <BatchEditForm ref=\"formRef\" v-slot=\"scoped\">\n <slot name=\"form\" v-bind=\"scoped\" />\n </BatchEditForm>\n </u-layout>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { computed, inject, provide, shallowRef, watch } from 'vue'\n\nimport type {\n BatchEditEmits,\n BatchEditProps,\n TableColumnSlotsScope,\n TableExposed,\n TableRow\n} from '../../types'\nimport type { FormExposed } from '../../types/form'\nimport { DialogDIKey } from '../dialog/di'\nimport { ULayout } from '../layout'\nimport BatchEditForm from './batch-edit-form.vue'\nimport BatchEditList from './batch-edit-list.vue'\nimport { BatchEditDIKey } from './di'\nimport { useEdit } from './use-edit'\nimport { useFeatures } from './use-features'\n\ndefineOptions({ name: 'BatchEdit' })\n\nconst props = withDefaults(defineProps<BatchEditProps>(), {\n cols: () => ['1fr', '420px'],\n mode: 'normal'\n})\n\nconst emit = defineEmits<BatchEditEmits>()\n\nconst slots = defineSlots<\n {\n form?: (props: {\n /** 当前编辑的层级 */\n depth?: number\n /** 当前编辑的行 */\n row?: TableRow\n /** 当前编辑的行索引 */\n index?: number\n /** 操作的目标行索引路径 */\n indexes?: number[]\n }) => any\n\n header?: () => any\n } & Partial<{ [key: `column:${string}`]: (props: TableColumnSlotsScope) => any }>\n>()\n\nconst cls = bem('batch-edit')\n\nconst tableRef = shallowRef<TableExposed>()\nconst formRef = shallowRef<FormExposed>()\nconst focused = shallowRef(false)\n\nconst { staticFeatures, dynamicFeatures } = useFeatures({ props })\n\nconst editCtx = useEdit({ props, emit, formRef })\n\nconst { state, handleClose, handleSave } = editCtx\n\nprovide(BatchEditDIKey, {\n cls,\n props,\n emit,\n tableRef,\n staticFeatures,\n dynamicFeatures,\n focused,\n ...editCtx\n})\n\nconst dialogCtx = inject(DialogDIKey, undefined)\n\ndialogCtx &&\n watch(dialogCtx.visible, (visible) => {\n !visible && editCtx.handleClose()\n })\n\nconst cols = computed(() => {\n return !!state.row || state.visible ? props.cols : undefined\n})\n\nfunction handleFocusIn() {\n focused.value = true\n}\n\nfunction handleFocusOut(e: FocusEvent) {\n const root = e.currentTarget as HTMLElement\n if (!root.contains(e.relatedTarget as Node | null)) {\n focused.value = false\n }\n}\n\n/**\n * 键盘快捷键(仅组件获焦时生效):\n * - Esc 关闭表单\n * - ⌘/Ctrl + S 保存(快速编辑模式下编辑行时除外)\n */\nfunction handleKeydown(e: KeyboardEvent) {\n if (!focused.value) return\n if (props.readonly && e.key !== 'Escape') return\n\n if (e.key === 'Escape') {\n if (state.visible) {\n e.preventDefault()\n handleClose()\n }\n return\n }\n\n const meta = e.metaKey || e.ctrlKey\n if (!meta) return\n\n const key = e.key.toLowerCase()\n\n if (key === 's' && state.visible) {\n if (props.mode === 'quick' && state.type === 'update') return\n e.preventDefault()\n handleSave()\n }\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4CA,MAAM,QAAQ;EAKd,MAAM,OAAO;EAEb,MAAM,QAAQ,SAAA;EAiBd,MAAM,MAAM,IAAI,YAAY;EAE5B,MAAM,WAAW,WAAyB;EAC1C,MAAM,UAAU,WAAwB;EACxC,MAAM,UAAU,WAAW,KAAK;EAEhC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AElC,mBAAA,QAAA;KACA,YAEgB,aAAA;eAFG;MAAJ,KAAI;;wBAAkB,WAAM,CACzC,WAAoC,KAAA,QAAA,QAAA,eAAA,mBAAV,MAAM,CAAA,CAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"batch-edit.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit.vue"],"sourcesContent":["<template>\n <u-layout\n :class=\"cls.b\"\n :cols=\"cols\"\n rows=\"minmax(0, 1fr) \"\n gap=\"8px\"\n resizable\n tabindex=\"-1\"\n @focusin=\"handleFocusIn\"\n @focusout=\"handleFocusOut\"\n @keydown.capture=\"handleKeydown\"\n >\n <!-- 编辑列表 -->\n <BatchEditList :slots=\"slots\" />\n\n <!-- 编辑表单 -->\n <BatchEditForm ref=\"form\" v-slot=\"scoped\">\n <slot name=\"form\" v-bind=\"scoped\" />\n </BatchEditForm>\n </u-layout>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { computed, provide, useTemplateRef } from 'vue'\n\nimport type { BatchEditEmits, BatchEditProps, BatchEditSlots, FormExposed } from '../../types'\nimport { ULayout } from '../layout'\nimport BatchEditForm from './batch-edit-form.vue'\nimport BatchEditList from './batch-edit-list.vue'\nimport { BatchEditDIKey } from './di'\nimport { useEditState } from './use-edit-state'\nimport { useFeatures } from './use-features'\nimport { useHandlers } from './use-handlers'\nimport { useShortcutKey } from './use-shortcut-key'\n\ndefineOptions({ name: 'BatchEdit' })\n\nconst props = withDefaults(defineProps<BatchEditProps>(), { cols: () => ['1fr', '420px'] })\n\nconst emit = defineEmits<BatchEditEmits>()\n\nconst slots = defineSlots<BatchEditSlots>()\n\nconst cls = bem('batch-edit')\n\nconst formRef = useTemplateRef<FormExposed>('form')\n\nconst { state, resetState } = useEditState({ props, formRef })\n\nconst { staticFeatures, dynamicFeatures } = useFeatures({ props })\n\nconst handlers = useHandlers({ props, emit, state, resetState, formRef })\n\n// 快捷键处理\nconst { handleFocusIn, handleFocusOut, handleKeydown, focused } = useShortcutKey({\n props,\n onSave: handlers.handleSave,\n onClose: handlers.handleClose,\n state\n})\n\nconst cols = computed(() => {\n return state.formVisible ? props.cols : undefined\n})\n\nprovide(BatchEditDIKey, {\n cls,\n props,\n emit,\n state,\n staticFeatures,\n dynamicFeatures,\n focused,\n ...handlers\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCA,MAAM,QAAQ;EAEd,MAAM,OAAO;EAEb,MAAM,QAAQ,SAAA;EAEd,MAAM,MAAM,IAAI,YAAY;EAE5B,MAAM,UAAU,eAA4B,MAAM;EAElD,MAAM,EAAE,OAAO,eAAe,aAAa;GAAE;GAAO;EAAQ,CAAC;EAE7D,MAAM,EAAE,gBAAgB,oBAAoB,YAAY,EAAE,MAAM,CAAC;EAEjE,MAAM,WAAW,YAAY;GAAE;GAAO;GAAM;GAAO;GAAY;EAAQ,CAAC;EAGxE,MAAM,EAAE,eAAe,gBAAgB,eAAe,YAAY,eAAe;GAC/E;GACA,QAAQ,SAAS;GACjB,SAAS,SAAS;GAClB;EACF,CAAC;EAED,MAAM,OAAO,eAAe;GAC1B,OAAO,MAAM,cAAc,MAAM,OAAO,KAAA;EAC1C,CAAC;EAED,QAAQ,gBAAgB;GACtB;GACA;GACA;GACA;GACA;GACA;GACA;GACA,GAAG;EACL,CAAC;;uBA1EC,YAkBW,MAAA,WAAA,GAAA;IAjBR,OAAK,eAAE,MAAA,GAAA,EAAI,CAAC;IACZ,MAAM,KAAA;IACP,MAAK;IACL,KAAI;IACJ,WAAA;IACA,UAAS;IACR,WAAS,MAAA,aAAA;IACT,YAAU,MAAA,cAAA;sBACO,MAAA,aAAA;;2BAEL;KAAb,mBAAA,QAAA;KACA,YAAgC,aAAA,EAAT,MAAK,CAAA;KAE5B,mBAAA,QAAA;KACA,YAEgB,aAAA,EAFD,KAAI,OAAM,GAAA;wBAAS,WAAM,CACtC,WAAoC,KAAA,QAAA,QAAA,eAAA,mBAAV,MAAM,CAAA,CAAA,CAAA,CAAA"}
@@ -1,17 +1,7 @@
1
- import { TableColumn, TableColumnSlotsScope, TableRow } from "../../types/table.js";
2
- import { BatchEditMode, BatchEditProps } from "../../types/batch-edit.js";
1
+ import { TableColumn, TableRow } from "../../types/table.js";
2
+ import { BatchEditProps, BatchEditSlots } from "../../types/batch-edit.js";
3
3
  //#region src/components/batch-edit/batch-edit.vue.d.ts
4
- type __VLS_Slots = {
5
- form?: (props: {
6
- /** 当前编辑的层级 */depth?: number; /** 当前编辑的行 */
7
- row?: TableRow; /** 当前编辑的行索引 */
8
- index?: number; /** 操作的目标行索引路径 */
9
- indexes?: number[];
10
- }) => any;
11
- header?: () => any;
12
- } & Partial<{
13
- [key: `column:${string}`]: (props: TableColumnSlotsScope) => any;
14
- }>;
4
+ type __VLS_Slots = BatchEditSlots;
15
5
  declare const __VLS_base: import("vue").DefineComponent<BatchEditProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
16
6
  "update:selected": (value: Record<string, any> | undefined) => any;
17
7
  "update:checked": (value: Record<string, any>[]) => any;
@@ -32,7 +22,6 @@ declare const __VLS_base: import("vue").DefineComponent<BatchEditProps, {}, {},
32
22
  "onRow-click"?: ((row: TableRow, ev: MouseEvent) => any) | undefined;
33
23
  }>, {
34
24
  cols: string | [string, string];
35
- mode: BatchEditMode;
36
25
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
37
26
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
38
27
  declare const _default: typeof __VLS_export;