@veltra/desktop 1.0.12 → 1.0.14
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/components/action/action-group.js +110 -3
- package/dist/components/action/action-group.js.map +1 -1
- package/dist/components/action/action-group.vue.d.ts +16 -3
- package/dist/components/action/action.js +26 -13
- package/dist/components/action/action.js.map +1 -1
- package/dist/components/action/action.vue.d.ts +1 -1
- package/dist/components/action/style.js +2 -1
- package/dist/components/action/style2.css +35 -7
- package/dist/components/auto-complete/auto-complete.vue.d.ts +2 -2
- package/dist/components/batch-edit/batch-edit-form.js +106 -42
- package/dist/components/batch-edit/batch-edit-form.js.map +1 -1
- package/dist/components/batch-edit/batch-edit-list.js +84 -47
- package/dist/components/batch-edit/batch-edit-list.js.map +1 -1
- package/dist/components/batch-edit/batch-edit.js +42 -10
- package/dist/components/batch-edit/batch-edit.js.map +1 -1
- package/dist/components/batch-edit/style.js +2 -4
- package/dist/components/batch-edit/style2.css +202 -30
- package/dist/components/batch-edit/use-edit.js +45 -9
- package/dist/components/batch-edit/use-edit.js.map +1 -1
- package/dist/components/cascade/cascade.js +3 -1
- package/dist/components/cascade/cascade.js.map +1 -1
- package/dist/components/cascade/cascade.vue.d.ts +3 -3
- package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
- package/dist/components/checkbox-group/checkbox-group.vue.d.ts +2 -2
- package/dist/components/code-editor/code-editor.js +145 -49
- package/dist/components/code-editor/code-editor.js.map +1 -1
- package/dist/components/code-editor/code-editor.vue.d.ts +2 -0
- package/dist/components/code-editor/style2.css +87 -19
- package/dist/components/collapse/collapse.js.map +1 -1
- package/dist/components/collapse/collapse.vue.d.ts +2 -10
- package/dist/components/date-picker/date-picker.vue.d.ts +2 -2
- package/dist/components/date-range-picker/date-range-picker.vue.d.ts +2 -2
- package/dist/components/dialog/dialog.js +6 -2
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/dialog/style2.css +2 -3
- package/dist/components/drawer/drawer.vue.d.ts +2 -2
- package/dist/components/expression-editor/components/path-preview.js +27 -0
- package/dist/components/expression-editor/components/path-preview.js.map +1 -0
- package/dist/components/expression-editor/components/variable-picker.js +199 -153
- package/dist/components/expression-editor/components/variable-picker.js.map +1 -1
- package/dist/components/expression-editor/core/chip.js +54 -0
- package/dist/components/expression-editor/core/chip.js.map +1 -0
- package/dist/components/expression-editor/core/editor.js +424 -0
- package/dist/components/expression-editor/core/editor.js.map +1 -0
- package/dist/components/expression-editor/core/mention.js +91 -0
- package/dist/components/expression-editor/core/mention.js.map +1 -0
- package/dist/components/expression-editor/core/model.js +64 -0
- package/dist/components/expression-editor/core/model.js.map +1 -0
- package/dist/components/expression-editor/di.js +4 -10
- package/dist/components/expression-editor/di.js.map +1 -1
- package/dist/components/expression-editor/expression-editor.js +168 -114
- package/dist/components/expression-editor/expression-editor.js.map +1 -1
- package/dist/components/expression-editor/expression-editor.vue.d.ts +2 -1
- package/dist/components/expression-editor/style.js +0 -2
- package/dist/components/expression-editor/style2.css +145 -219
- package/dist/components/index.js +54 -54
- package/dist/components/input/input.vue.d.ts +2 -2
- package/dist/components/layout/layout.js +12 -11
- package/dist/components/layout/layout.js.map +1 -1
- package/dist/components/multi-select/multi-select.vue.d.ts +3 -3
- package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +3 -3
- package/dist/components/number/number.vue.d.ts +1 -1
- package/dist/components/number-input/number-input.js +4 -4
- package/dist/components/number-input/number-input.js.map +1 -1
- package/dist/components/number-input/number-input.vue.d.ts +2 -2
- package/dist/components/number-range-input/number-range-input.vue.d.ts +1 -1
- package/dist/components/password-input/password-input.vue.d.ts +1 -1
- package/dist/components/progress-nodes/progress-nodes.vue.d.ts +2 -2
- package/dist/components/radio-group/radio-group.vue.d.ts +2 -2
- package/dist/components/rich-text-editor/rich-text-editor.js +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
- package/dist/components/rich-text-editor/toolbar.js +2 -2
- package/dist/components/select/select.vue.d.ts +2 -2
- package/dist/components/table/use-table.js +16 -0
- package/dist/components/table/use-table.js.map +1 -1
- package/dist/components/tabs/tabs-horizontal.vue.d.ts +2 -2
- package/dist/components/tabs/tabs-vertical.vue.d.ts +2 -2
- package/dist/components/tabs/tabs.vue.d.ts +2 -2
- package/dist/components/textarea/textarea.vue.d.ts +2 -2
- package/dist/components/tree/style2.css +18 -12
- package/dist/components/tree/tree-node.js +7 -4
- package/dist/components/tree/tree-node.js.map +1 -1
- package/dist/components/tree-select/tree-select.vue.d.ts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +83 -83
- package/dist/style.js +3 -3
- package/dist/types/action.d.ts +38 -4
- package/dist/types/cascade.d.ts +2 -3
- package/dist/types/code-editor.d.ts +9 -2
- package/dist/types/collapse.d.ts +6 -5
- package/dist/types/expression-editor.d.ts +9 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +11 -12
- package/src/components/action/action-group.vue +126 -56
- package/src/components/action/action.vue +35 -12
- package/src/components/action/style.scss +46 -10
- package/src/components/action/style.ts +2 -1
- package/src/components/batch-edit/batch-edit-form.vue +121 -45
- package/src/components/batch-edit/batch-edit-list.vue +56 -39
- package/src/components/batch-edit/batch-edit.vue +57 -6
- package/src/components/batch-edit/style.scss +251 -37
- package/src/components/batch-edit/style.ts +5 -8
- package/src/components/batch-edit/use-edit.ts +58 -11
- package/src/components/cascade/cascade.vue +3 -1
- package/src/components/code-editor/code-editor.vue +198 -63
- package/src/components/code-editor/style.scss +110 -12
- package/src/components/collapse/collapse.vue +5 -24
- package/src/components/dialog/dialog.vue +6 -2
- package/src/components/dialog/style.scss +4 -4
- package/src/components/expression-editor/__test__/chip.test.ts +86 -0
- package/src/components/expression-editor/__test__/mention.test.ts +122 -0
- package/src/components/expression-editor/__test__/model.test.ts +127 -0
- package/src/components/expression-editor/components/path-preview.vue +32 -0
- package/src/components/expression-editor/components/variable-picker.vue +224 -219
- package/src/components/expression-editor/core/chip.ts +101 -0
- package/src/components/expression-editor/core/editor.ts +513 -0
- package/src/components/expression-editor/core/mention.ts +121 -0
- package/src/components/expression-editor/core/model.ts +109 -0
- package/src/components/expression-editor/di.ts +4 -32
- package/src/components/expression-editor/expression-editor.vue +184 -151
- package/src/components/expression-editor/style.scss +148 -220
- package/src/components/expression-editor/style.ts +0 -2
- package/src/components/layout/layout.vue +17 -19
- package/src/components/number-input/number-input.vue +4 -4
- package/src/components/table/use-table.ts +16 -0
- package/src/components/tree/style.scss +30 -33
- package/src/components/tree/tree-node.vue +4 -2
- package/src/types/action.ts +42 -4
- package/src/types/cascade.ts +4 -3
- package/src/types/code-editor.ts +9 -2
- package/src/types/collapse.ts +6 -6
- package/src/types/expression-editor.ts +9 -0
- package/dist/components/action/action-group.vue_vue_type_script_setup_true_lang.js +0 -65
- package/dist/components/action/action-group.vue_vue_type_script_setup_true_lang.js.map +0 -1
- package/dist/components/expression-editor/constants.js +0 -9
- package/dist/components/expression-editor/constants.js.map +0 -1
- package/dist/components/expression-editor/internal/editor-runtime/create-runtime.js +0 -47
- package/dist/components/expression-editor/internal/editor-runtime/create-runtime.js.map +0 -1
- package/dist/components/expression-editor/internal/editor-runtime/model-sync.js +0 -49
- package/dist/components/expression-editor/internal/editor-runtime/model-sync.js.map +0 -1
- package/dist/components/expression-editor/internal/features/commands/register-command-packs.js +0 -215
- package/dist/components/expression-editor/internal/features/commands/register-command-packs.js.map +0 -1
- package/dist/components/expression-editor/internal/features/drag-drop/drag-drop-service.js +0 -33
- package/dist/components/expression-editor/internal/features/drag-drop/drag-drop-service.js.map +0 -1
- package/dist/components/expression-editor/internal/features/insertion/insertion-service.js +0 -33
- package/dist/components/expression-editor/internal/features/insertion/insertion-service.js.map +0 -1
- package/dist/components/expression-editor/nodes/variable-node.js +0 -94
- package/dist/components/expression-editor/nodes/variable-node.js.map +0 -1
- package/dist/components/expression-editor/parser.js +0 -32
- package/dist/components/expression-editor/parser.js.map +0 -1
- package/dist/components/expression-editor/plain-text.js +0 -19
- package/dist/components/expression-editor/plain-text.js.map +0 -1
- package/dist/components/expression-editor/use-context.js +0 -69
- package/dist/components/expression-editor/use-context.js.map +0 -1
- package/dist/components/expression-editor/use-decorators.js +0 -27
- package/dist/components/expression-editor/use-decorators.js.map +0 -1
- package/dist/components/expression-editor/use-expression-drag-drop.js +0 -275
- package/dist/components/expression-editor/use-expression-drag-drop.js.map +0 -1
- package/src/components/batch-edit/batch-edit-new.vue +0 -168
- package/src/components/batch-edit/style-new.scss +0 -35
- package/src/components/batch-edit/use-edit-new.ts +0 -68
- package/src/components/batch-edit/use-tip.ts +0 -47
- package/src/components/expression-editor/__test__/architecture-boundaries.test.ts +0 -103
- package/src/components/expression-editor/__test__/architecture-compatibility.test.ts +0 -52
- package/src/components/expression-editor/__test__/drag-drop.test.ts +0 -171
- package/src/components/expression-editor/__test__/parser.test.ts +0 -62
- package/src/components/expression-editor/constants.ts +0 -6
- package/src/components/expression-editor/internal/contracts/editor-runtime.ts +0 -11
- package/src/components/expression-editor/internal/editor-runtime/create-runtime.ts +0 -64
- package/src/components/expression-editor/internal/editor-runtime/index.ts +0 -1
- package/src/components/expression-editor/internal/editor-runtime/model-sync.ts +0 -68
- package/src/components/expression-editor/internal/features/commands/register-command-packs.ts +0 -517
- package/src/components/expression-editor/internal/features/drag-drop/drag-drop-service.ts +0 -51
- package/src/components/expression-editor/internal/features/insertion/insertion-service.ts +0 -56
- package/src/components/expression-editor/nodes/variable-node.tsx +0 -118
- package/src/components/expression-editor/parser.ts +0 -46
- package/src/components/expression-editor/plain-text.ts +0 -25
- package/src/components/expression-editor/plan.md +0 -22
- package/src/components/expression-editor/use-context.ts +0 -134
- package/src/components/expression-editor/use-decorators.tsx +0 -29
- package/src/components/expression-editor/use-editor.ts +0 -12
- package/src/components/expression-editor/use-expression-drag-drop.ts +0 -396
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import _sfc_main$1 from "../
|
|
1
|
+
import _sfc_main$1 from "../icon/icon.js";
|
|
2
2
|
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
|
-
import
|
|
6
|
-
import {
|
|
5
|
+
import _sfc_main$4 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";
|
|
7
8
|
import { o } from "@cat-kit/core";
|
|
8
|
-
import {
|
|
9
|
+
import { Delete, EditPen, Plus, View } from "@veltra/icons/normal";
|
|
9
10
|
//#region src/components/batch-edit/batch-edit-list.vue
|
|
11
|
+
const _hoisted_1 = ["disabled"];
|
|
10
12
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
11
13
|
name: "BatchEditList",
|
|
12
14
|
__name: "batch-edit-list",
|
|
13
15
|
props: { slots: {} },
|
|
14
16
|
setup(__props) {
|
|
15
|
-
const { cls, state, tableRef, props, emit, staticFeatures, dynamicFeatures, handleCreate, handleDelete, handleInsertToNext, handleInsertToPrev, handleInsertChild } = inject(BatchEditDIKey);
|
|
17
|
+
const { cls, state, tableRef, props, emit, staticFeatures, dynamicFeatures, handleCreate, handleEdit, handleCopy, handleDelete, handleInsertToNext, handleInsertToPrev, handleInsertChild } = inject(BatchEditDIKey);
|
|
16
18
|
const tableProps = computed(() => {
|
|
17
19
|
return o(props).omit([
|
|
18
20
|
"model",
|
|
@@ -25,92 +27,127 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
25
27
|
]);
|
|
26
28
|
});
|
|
27
29
|
const hasNot = (value) => value.every((v) => !staticFeatures.value.has(v));
|
|
30
|
+
const allowed = (feature, row) => {
|
|
31
|
+
return staticFeatures.value.has(feature) || !!dynamicFeatures.value[feature]?.(row);
|
|
32
|
+
};
|
|
28
33
|
const columns = computed(() => {
|
|
29
34
|
if (props.readonly || hasNot([
|
|
30
35
|
"create",
|
|
31
36
|
"delete",
|
|
32
|
-
"createChild"
|
|
37
|
+
"createChild",
|
|
38
|
+
"update",
|
|
39
|
+
"copy"
|
|
33
40
|
])) return props.columns;
|
|
34
41
|
return (props.columns ?? []).concat({
|
|
35
42
|
name: "操作",
|
|
36
43
|
key: "__action__",
|
|
37
44
|
align: "center",
|
|
38
|
-
width:
|
|
45
|
+
width: 132,
|
|
39
46
|
fixed: "right",
|
|
40
47
|
resizable: false
|
|
41
48
|
});
|
|
42
49
|
});
|
|
43
50
|
function handleUpdateCurrentRow(row) {
|
|
44
|
-
if (
|
|
51
|
+
if (allowed("update", row)) {
|
|
45
52
|
state.row = row;
|
|
46
53
|
state.depth = row?.depth;
|
|
47
54
|
}
|
|
48
55
|
}
|
|
56
|
+
function canEdit(row) {
|
|
57
|
+
return !props.readonly ? allowed("update", row) : true;
|
|
58
|
+
}
|
|
59
|
+
function canDelete(row) {
|
|
60
|
+
return !props.readonly && allowed("delete", row);
|
|
61
|
+
}
|
|
49
62
|
return (_ctx, _cache) => {
|
|
50
63
|
return openBlock(), createBlock(unref(_sfc_main$2), mergeProps(tableProps.value, {
|
|
51
64
|
slots: __props.slots,
|
|
52
|
-
class: unref(cls).e("table"),
|
|
65
|
+
class: [unref(cls).e("table"), unref(bem).is("editing", unref(state).visible)],
|
|
53
66
|
columns: columns.value,
|
|
54
67
|
"highlight-current": "",
|
|
55
68
|
"current-row": unref(state).row,
|
|
56
69
|
"onUpdate:current": handleUpdateCurrentRow,
|
|
57
|
-
"onUpdate:checked": _cache[
|
|
58
|
-
"onUpdate:selected": _cache[
|
|
70
|
+
"onUpdate:checked": _cache[2] || (_cache[2] = ($event) => unref(emit)("update:checked", $event)),
|
|
71
|
+
"onUpdate:selected": _cache[3] || (_cache[3] = ($event) => unref(emit)("update:selected", $event)),
|
|
59
72
|
ref_key: "tableRef",
|
|
60
73
|
ref: tableRef
|
|
61
74
|
}), createSlots({
|
|
62
|
-
"column:__action__": withCtx(({ row }) => [createVNode(unref(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
"column:__action__": withCtx(({ row }) => [createVNode(unref(_sfc_main$4), {
|
|
76
|
+
class: normalizeClass(unref(cls).e("row-actions")),
|
|
77
|
+
hover: "",
|
|
78
|
+
circle: "",
|
|
79
|
+
max: 3,
|
|
80
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => {}, ["stop"]))
|
|
66
81
|
}, {
|
|
67
82
|
default: withCtx(() => [
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
icon: unref(
|
|
71
|
-
title: "
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
icon
|
|
75
|
-
title
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
canEdit(row) ? (openBlock(), createBlock(unref(_sfc_main$3), mergeProps({
|
|
84
|
+
key: 0,
|
|
85
|
+
icon: unref(props).readonly ? unref(View) : unref(EditPen),
|
|
86
|
+
title: unref(props).readonly ? "查看" : "编辑",
|
|
87
|
+
onRun: ($event) => unref(handleEdit)(row)
|
|
88
|
+
}, unref(props).actionsProps?.update), null, 16, [
|
|
89
|
+
"icon",
|
|
90
|
+
"title",
|
|
91
|
+
"onRun"
|
|
92
|
+
])) : createCommentVNode("v-if", true),
|
|
93
|
+
canDelete(row) ? (openBlock(), createBlock(unref(_sfc_main$3), mergeProps({
|
|
78
94
|
key: 1,
|
|
79
|
-
onRun: ($event) => unref(handleInsertChild)(row),
|
|
80
|
-
icon: unref(AddChild),
|
|
81
|
-
title: "添加子项"
|
|
82
|
-
}, unref(props).actionsProps?.createChild), null, 16, ["onRun", "icon"])) : createCommentVNode("v-if", true),
|
|
83
|
-
unref(staticFeatures).has("delete") || unref(dynamicFeatures).delete?.(row) ? (openBlock(), createBlock(unref(_sfc_main$3), mergeProps({
|
|
84
|
-
key: 2,
|
|
85
95
|
icon: unref(Delete),
|
|
86
96
|
type: "danger",
|
|
87
97
|
title: "删除",
|
|
88
98
|
onRun: ($event) => unref(handleDelete)(row)
|
|
89
|
-
}, unref(props).actionsProps?.delete), null, 16, ["icon", "onRun"])) : createCommentVNode("v-if", true)
|
|
99
|
+
}, unref(props).actionsProps?.delete), null, 16, ["icon", "onRun"])) : createCommentVNode("v-if", true),
|
|
100
|
+
allowed("create", row) ? (openBlock(), createBlock(unref(_sfc_main$3), {
|
|
101
|
+
key: 2,
|
|
102
|
+
"in-dropdown": "",
|
|
103
|
+
onRun: ($event) => unref(handleInsertToPrev)(row)
|
|
104
|
+
}, {
|
|
105
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode(" 在上方插入 ", -1)])]),
|
|
106
|
+
_: 1
|
|
107
|
+
}, 8, ["onRun"])) : createCommentVNode("v-if", true),
|
|
108
|
+
allowed("create", row) ? (openBlock(), createBlock(unref(_sfc_main$3), {
|
|
109
|
+
key: 3,
|
|
110
|
+
"in-dropdown": "",
|
|
111
|
+
onRun: ($event) => unref(handleInsertToNext)(row)
|
|
112
|
+
}, {
|
|
113
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode(" 在下方插入 ", -1)])]),
|
|
114
|
+
_: 1
|
|
115
|
+
}, 8, ["onRun"])) : createCommentVNode("v-if", true),
|
|
116
|
+
!!unref(props).tree && allowed("createChild", row) ? (openBlock(), createBlock(unref(_sfc_main$3), {
|
|
117
|
+
key: 4,
|
|
118
|
+
"in-dropdown": "",
|
|
119
|
+
onRun: ($event) => unref(handleInsertChild)(row)
|
|
120
|
+
}, {
|
|
121
|
+
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode(" 添加子级 ", -1)])]),
|
|
122
|
+
_: 1
|
|
123
|
+
}, 8, ["onRun"])) : createCommentVNode("v-if", true),
|
|
124
|
+
allowed("copy", row) ? (openBlock(), createBlock(unref(_sfc_main$3), {
|
|
125
|
+
key: 5,
|
|
126
|
+
"in-dropdown": "",
|
|
127
|
+
onRun: ($event) => unref(handleCopy)(row)
|
|
128
|
+
}, {
|
|
129
|
+
default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode(" 复制此行 ", -1)])]),
|
|
130
|
+
_: 1
|
|
131
|
+
}, 8, ["onRun"])) : createCommentVNode("v-if", true)
|
|
90
132
|
]),
|
|
91
133
|
_: 2
|
|
92
|
-
}, 1032, ["
|
|
134
|
+
}, 1032, ["class"])]),
|
|
93
135
|
_: 2
|
|
94
136
|
}, [!unref(props).readonly ? {
|
|
95
137
|
name: "empty",
|
|
96
|
-
fn: withCtx(() => [_cache[
|
|
138
|
+
fn: withCtx(() => [_cache[8] || (_cache[8] = createTextVNode(toDisplayString(null), -1))]),
|
|
97
139
|
key: "0"
|
|
98
140
|
} : void 0, !unref(props).readonly && (unref(staticFeatures).has("create") || unref(dynamicFeatures).create?.()) && (unref(state).type === "create" && !unref(state).visible || unref(state).type === "update") ? {
|
|
99
141
|
name: "append",
|
|
100
|
-
fn: withCtx(() => [createElementVNode("div", { class: normalizeClass(unref(cls).e("add")) }, [
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
default: withCtx(() => [..._cache[4] || (_cache[4] = [createElementVNode("span", { style: {
|
|
108
|
-
"position": "sticky",
|
|
109
|
-
"left": "50%",
|
|
110
|
-
"transform": "translateX(-50%)"
|
|
111
|
-
} }, " 新增 ", -1)])]),
|
|
142
|
+
fn: withCtx(() => [createElementVNode("div", { class: normalizeClass(unref(cls).e("add")) }, [createElementVNode("button", {
|
|
143
|
+
type: "button",
|
|
144
|
+
class: normalizeClass([unref(cls).e("add-btn"), unref(bem).is("loading", unref(state).loading)]),
|
|
145
|
+
disabled: unref(state).loading,
|
|
146
|
+
onClick: _cache[1] || (_cache[1] = withModifiers((...args) => unref(handleCreate) && unref(handleCreate)(...args), ["stop"]))
|
|
147
|
+
}, [createVNode(unref(_sfc_main$1), { class: normalizeClass(unref(cls).e("add-icon")) }, {
|
|
148
|
+
default: withCtx(() => [createVNode(unref(Plus))]),
|
|
112
149
|
_: 1
|
|
113
|
-
},
|
|
150
|
+
}, 8, ["class"]), createElementVNode("span", { class: normalizeClass(unref(cls).e("add-label")) }, "新增一行", 2)], 10, _hoisted_1)], 2)]),
|
|
114
151
|
key: "1"
|
|
115
152
|
} : void 0]), 1040, [
|
|
116
153
|
"slots",
|
|
@@ -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')\"\n :columns=\"columns\"\n highlight-current\n :current-row=\"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
|
|
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-row=\"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')\" hover circle :max=\"3\" @click.stop>\n <u-action\n v-if=\"canEdit(row)\"\n :icon=\"props.readonly ? View : EditPen\"\n :title=\"props.readonly ? '查看' : '编辑'\"\n @run=\"handleEdit(row)\"\n v-bind=\"props.actionsProps?.update\"\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\n <u-action v-if=\"allowed('create', row)\" in-dropdown @run=\"handleInsertToPrev(row)\">\n 在上方插入\n </u-action>\n <u-action v-if=\"allowed('create', row)\" in-dropdown @run=\"handleInsertToNext(row)\">\n 在下方插入\n </u-action>\n <u-action\n v-if=\"!!props.tree && allowed('createChild', row)\"\n in-dropdown\n @run=\"handleInsertChild(row)\"\n >\n 添加子级\n </u-action>\n <u-action v-if=\"allowed('copy', row)\" in-dropdown @run=\"handleCopy(row)\">\n 复制此行\n </u-action>\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 <button\n type=\"button\"\n :class=\"[cls.e('add-btn'), bem.is('loading', state.loading)]\"\n :disabled=\"state.loading\"\n @click.stop=\"handleCreate\"\n >\n <u-icon :class=\"cls.e('add-icon')\">\n <Plus />\n </u-icon>\n <span :class=\"cls.e('add-label')\">新增一行</span>\n </button>\n </div>\n </template>\n </u-table>\n</template>\n\n<script setup lang=\"ts\">\nimport { o } from '@cat-kit/core'\nimport { Delete, EditPen, Plus, View } 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 { UIcon } from '../icon'\nimport { UTable } from '../table'\nimport { BatchEditDIKey } from './di'\n\ndefineOptions({\n name: 'BatchEditList'\n})\n\ndefineProps<{\n slots: Slots\n}>()\n\nconst {\n cls,\n state,\n tableRef,\n props,\n emit,\n staticFeatures,\n dynamicFeatures,\n handleCreate,\n handleEdit,\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 ])\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: 132,\n fixed: 'right',\n resizable: false\n })\n})\n\nfunction handleUpdateCurrentRow(row?: TableRow) {\n if (allowed('update', row)) {\n state.row = row\n state.depth = row?.depth\n }\n}\n\nfunction canEdit(row: TableRow) {\n return !props.readonly ? allowed('update', row) : true\n}\n\nfunction canDelete(row: TableRow) {\n return !props.readonly && allowed('delete', row)\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;EAkGA,MAAM,EACJ,KACA,OACA,UACA,OACA,MACA,gBACA,iBACA,cACA,YACA,YACA,cACA,oBACA,oBACA,sBACE,OAAO,eAAe;EAE1B,MAAM,aAAa,eAAe;AAChC,UAAO,EAAE,MAA6B,CAAC,KAAK;IAC1C;IACA;IACA;IACA;IACA;IACA;IACA;IACD,CAAA;IACF;EAED,MAAM,UAAU,UAA8B,MAAM,OAAO,MAAM,CAAC,eAAe,MAAM,IAAI,EAAE,CAAA;EAE7F,MAAM,WAAW,SAA2B,QAAmB;AAC7D,UAAO,eAAe,MAAM,IAAI,QAAQ,IAAI,CAAC,CAAC,gBAAgB,MAAM,WAAW,IAAG;;EAGpF,MAAM,UAAU,eAAe;AAC7B,OAAI,MAAM,YAAY,OAAO;IAAC;IAAU;IAAU;IAAe;IAAU;IAAO,CAAC,CACjF,QAAO,MAAM;AAEf,WAAQ,MAAM,WAAW,EAAE,EAAE,OAAO;IAClC,MAAM;IACN,KAAK;IACL,OAAO;IACP,OAAO;IACP,OAAO;IACP,WAAW;IACZ,CAAA;IACF;EAED,SAAS,uB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AA,OAAA,OAAA,OAAA,KAAA,gBAAA,gBAAP,KAAI,EAAA,GAAA,EAAA,CAAA;;gBAI9B,MAAA,MAAK,CAAC,aAAqB,MAAA,eAAc,CAAC,IAAG,SAAA,IAAc,MAAA,gBAAe,CAAC,UAAM,MAAmB,MAAA,MAAK,CAAC,SAAI,YAAA,CAAkB,MAAA,MAAK,CAAC,WAAY,MAAA,MAAK,CAAC,SAAI,YAAA;UAD3K;sBAmBK,CAZN,mBAYM,OAAA,EAZA,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,MAAA,CAAA,EAAA,EAAA,CAChB,mBAUS,UAAA;KATP,MAAK;KACJ,OAAK,eAAA,CAAG,MAAA,IAAG,CAAC,EAAC,UAAA,EAAa,MAAA,IAAG,CAAC,GAAE,WAAY,MAAA,MAAK,CAAC,QAAO,CAAA,CAAA;KACzD,UAAU,MAAA,MAAK,CAAC;KAChB,SAAK,OAAA,OAAA,OAAA,KAAA,eAAA,GAAA,SAAO,MAAA,aAAA,IAAA,MAAA,aAAA,CAAA,GAAA,KAAY,EAAA,CAAA,OAAA,CAAA;QAEzB,YAES,MAAA,YAAA,EAAA,EAFA,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,WAAA,CAAA,EAAA,EAAA;4BACX,CAAR,YAAQ,MAAA,KAAA,CAAA,CAAA,CAAA;;sBAEV,mBAA6C,QAAA,EAAtC,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,YAAA,CAAA,EAAA,EAAe,QAAI,EAAA,CAAA,EAAA,IAAA,WAAA,CAAA,EAAA,EAAA,CAAA,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { BatchEditDIKey } from "./di.js";
|
|
|
4
4
|
import _sfc_main$2 from "./batch-edit-form.js";
|
|
5
5
|
import _sfc_main$3 from "./batch-edit-list.js";
|
|
6
6
|
import { useEdit } from "./use-edit.js";
|
|
7
|
-
import { computed, createBlock, createCommentVNode, createVNode, defineComponent, guardReactiveProps, inject, normalizeClass, normalizeProps, openBlock, provide, renderSlot, shallowRef, unref, useSlots, watch, withCtx
|
|
7
|
+
import { computed, createBlock, createCommentVNode, createVNode, defineComponent, guardReactiveProps, inject, normalizeClass, normalizeProps, openBlock, provide, renderSlot, shallowRef, unref, useSlots, watch, withCtx } from "vue";
|
|
8
8
|
import { bem } from "@veltra/utils";
|
|
9
9
|
//#region src/components/batch-edit/batch-edit.vue
|
|
10
10
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -13,7 +13,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
13
13
|
props: {
|
|
14
14
|
model: {},
|
|
15
15
|
title: {},
|
|
16
|
-
cols: { default: () => ["1fr", "
|
|
16
|
+
cols: { default: () => ["1fr", "420px"] },
|
|
17
17
|
readonly: { type: Boolean },
|
|
18
18
|
labelWidth: {},
|
|
19
19
|
deleteMethod: {},
|
|
@@ -66,7 +66,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
66
66
|
]);
|
|
67
67
|
if (!features) return defaultFeatures;
|
|
68
68
|
Object.entries(features).forEach(([key, value]) => {
|
|
69
|
-
|
|
69
|
+
const k = key;
|
|
70
|
+
if (typeof value === "function" || value === false) defaultFeatures.delete(k);
|
|
71
|
+
else if (value === true) defaultFeatures.add(k);
|
|
70
72
|
});
|
|
71
73
|
return defaultFeatures;
|
|
72
74
|
});
|
|
@@ -88,7 +90,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
88
90
|
emit,
|
|
89
91
|
tableRef
|
|
90
92
|
});
|
|
91
|
-
const { state, handleClose } = editCtx;
|
|
93
|
+
const { state, handleClose, handleSave, handleDelete, handleCreate } = editCtx;
|
|
92
94
|
provide(BatchEditDIKey, {
|
|
93
95
|
cls,
|
|
94
96
|
props,
|
|
@@ -105,6 +107,39 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
105
107
|
const cols = computed(() => {
|
|
106
108
|
return !!state.row || state.visible ? props.cols : void 0;
|
|
107
109
|
});
|
|
110
|
+
/**
|
|
111
|
+
* 键盘快捷键:
|
|
112
|
+
* - Esc 关闭表单
|
|
113
|
+
* - ⌘/Ctrl + S 保存
|
|
114
|
+
* - ⌘/Ctrl + Backspace 删除当前编辑行
|
|
115
|
+
* - ⌘/Ctrl + N 新增(仅在不在表单中时)
|
|
116
|
+
*/
|
|
117
|
+
function handleKeydown(e) {
|
|
118
|
+
if (props.readonly && e.key !== "Escape") return;
|
|
119
|
+
if (e.key === "Escape") {
|
|
120
|
+
if (state.visible) {
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
handleClose();
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (!(e.metaKey || e.ctrlKey)) return;
|
|
127
|
+
const key = e.key.toLowerCase();
|
|
128
|
+
if (key === "s" && state.visible) {
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
handleSave();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (e.key === "Backspace" && state.row && state.type === "update") {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
handleDelete(state.row);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (key === "n" && !state.visible) {
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
handleCreate();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
108
143
|
return (_ctx, _cache) => {
|
|
109
144
|
return openBlock(), createBlock(unref(_sfc_main$1), {
|
|
110
145
|
class: normalizeClass(unref(cls).b),
|
|
@@ -112,7 +147,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
112
147
|
rows: "100%",
|
|
113
148
|
gap: "8px",
|
|
114
149
|
resizable: "",
|
|
115
|
-
|
|
150
|
+
onKeydown: handleKeydown,
|
|
151
|
+
tabindex: "-1"
|
|
116
152
|
}, {
|
|
117
153
|
default: withCtx(() => [
|
|
118
154
|
createCommentVNode(" 编辑列表 "),
|
|
@@ -124,11 +160,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
124
160
|
})
|
|
125
161
|
]),
|
|
126
162
|
_: 3
|
|
127
|
-
}, 8, [
|
|
128
|
-
"class",
|
|
129
|
-
"cols",
|
|
130
|
-
"onKeyup"
|
|
131
|
-
]);
|
|
163
|
+
}, 8, ["class", "cols"]);
|
|
132
164
|
};
|
|
133
165
|
}
|
|
134
166
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-edit.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit.vue"],"sourcesContent":["<template>\n <u-layout
|
|
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=\"100%\"\n gap=\"8px\"\n resizable\n @keydown=\"handleKeydown\"\n tabindex=\"-1\"\n >\n <!-- 编辑列表 -->\n <BatchEditList :slots=\"slots\" />\n\n <!-- 编辑表单 -->\n <BatchEditForm v-slot=\"scoped\">\n <!-- @vue-ignore -->\n <slot name=\"form\" v-bind=\"scoped\" />\n </BatchEditForm>\n </u-layout>\n</template>\n\n<script lang=\"ts\" setup generic=\"Model extends FormModel\">\nimport { bem } from '@veltra/utils'\nimport { computed, inject, provide, shallowRef, watch } from 'vue'\n\nimport type {\n BatchEditEmits,\n BatchEditFeature,\n BatchEditProps,\n TableColumnSlotsScope,\n TableExposed,\n TableRow\n} from '../../types'\nimport { DialogDIKey } from '../dialog/di'\nimport type { FormModel } from '../form'\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'\n\ndefineOptions({ name: 'BatchEdit' })\n\nconst props = withDefaults(defineProps<BatchEditProps<Model>>(), {\n cols: () => ['1fr', '420px'],\n mode: 'normal'\n})\n\nconst emit = defineEmits<BatchEditEmits>()\n\nconst staticFeatures = computed(() => {\n const { features } = props\n\n if (Array.isArray(features)) {\n return new Set(features)\n }\n\n const defaultFeatures = new Set<BatchEditFeature>(['create', 'delete', 'update', 'createChild'])\n\n if (!features) {\n return defaultFeatures\n }\n\n // 函数与 false 的特性视为关闭;显式 true 视为开启(即便不在默认集合内)\n Object.entries(features).forEach(([key, value]) => {\n const k = key as BatchEditFeature\n if (typeof value === 'function' || value === false) {\n defaultFeatures.delete(k)\n } else if (value === true) {\n defaultFeatures.add(k)\n }\n })\n return defaultFeatures\n})\n\nconst dynamicFeatures = computed<\n Record<BatchEditFeature, ((row?: TableRow) => boolean) | undefined>\n>(() => {\n const { features } = props\n if (!Array.isArray(features) && typeof features === 'object') {\n const ret = Object.entries(features)\n .filter(([_, value]) => {\n return typeof value === 'function'\n })\n .reduce(\n (acc, [key, value]) => {\n acc[key] = value\n return acc\n },\n {} as Record<BatchEditFeature, (row?: TableRow) => boolean>\n )\n return ret\n }\n\n return {} as Record<BatchEditFeature, ((row?: TableRow) => boolean) | undefined>\n})\n\nconst slots = defineSlots<\n {\n form?: (props: {\n /** 表单数据 */\n data: Model['data']\n /** 表单模型 */\n model: Model\n /** 当前编辑的层级 */\n depth?: number\n /** 当前编辑的行 */\n row?: TableRow\n /** 当前编辑的行索引 */\n index?: number\n /** 操作的目标行索引路径 */\n indexes?: number[]\n }) => any\n\n header?: () => any\n } & Partial<{\n [key: `column:${string}`]: (props: TableColumnSlotsScope) => any\n }>\n>()\n\nconst cls = bem('batch-edit')\n\nconst tableRef = shallowRef<TableExposed>()\n\nconst editCtx = useEdit({ props, emit, tableRef })\n\nconst { state, handleClose, handleSave, handleDelete, handleCreate } = editCtx\n\nprovide(BatchEditDIKey, {\n cls,\n props,\n emit,\n tableRef,\n staticFeatures,\n dynamicFeatures,\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\n/**\n * 键盘快捷键:\n * - Esc 关闭表单\n * - ⌘/Ctrl + S 保存\n * - ⌘/Ctrl + Backspace 删除当前编辑行\n * - ⌘/Ctrl + N 新增(仅在不在表单中时)\n */\nfunction handleKeydown(e: KeyboardEvent) {\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 e.preventDefault()\n handleSave()\n return\n }\n\n if (e.key === 'Backspace' && state.row && state.type === 'update') {\n e.preventDefault()\n handleDelete(state.row)\n return\n }\n\n if (key === 'n' && !state.visible) {\n e.preventDefault()\n handleCreate()\n }\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,QAAQ;EAKd,MAAM,OAAO;EAEb,MAAM,iBAAiB,eAAe;GACpC,MAAM,EAAE,aAAa;AAErB,OAAI,MAAM,QAAQ,SAAS,CACzB,QAAO,IAAI,IAAI,SAAQ;GAGzB,MAAM,kBAAkB,IAAI,IAAsB;IAAC;IAAU;IAAU;IAAU;IAAc,CAAA;AAE/F,OAAI,CAAC,SACH,QAAO;AAIT,UAAO,QAAQ,SAAS,CAAC,SAAS,CAAC,KAAK,WAAW;IACjD,MAAM,IAAI;AACV,QAAI,OAAO,UAAU,cAAc,UAAU,MAC3C,iBAAgB,OAAO,EAAC;aACf,UAAU,KACnB,iBAAgB,IAAI,EAAC;KAExB;AACD,UAAO;IACR;EAED,MAAM,kBAAkB,eAEhB;GACN,MAAM,EAAE,aAAa;AACrB,OAAI,CAAC,MAAM,QAAQ,SAAS,IAAI,OAAO,aAAa,SAYlD,QAXY,OAAO,QAAQ,SAAQ,CAChC,QAAQ,CAAC,GAAG,WAAW;AACtB,WAAO,OAAO,UAAU;KACzB,CACA,QACE,KAAK,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S;;2BAEI;KAAb,mBAAA,SAAa;KACb,YAAgC,aAAA,EAAT,OAAK,CAAA;KAE5B,mBAAA,SAAa;KACb,YAGgB,aAAA,MAAA;wBAHO,WAAM,CAC3B,mBAAA,gBAAoB,EACpB,WAAoC,KAAA,QAAA,QAAA,eAAA,mBAAV,OAAM,CAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
+
import "../icon/style.js";
|
|
1
2
|
import "../button/style.js";
|
|
2
|
-
import "../tip/style.js";
|
|
3
3
|
import "../action/style.js";
|
|
4
4
|
import "../scroll/style.js";
|
|
5
|
-
import "../layout/style.js";
|
|
6
5
|
import "../form/style.js";
|
|
7
|
-
import "../
|
|
6
|
+
import "../layout/style.js";
|
|
8
7
|
import "../table/style.js";
|
|
9
|
-
import "../card/style.js";
|
|
10
8
|
import "./style2.css";
|
|
11
9
|
import "@veltra/directives/ripple/style.js";
|
|
12
10
|
import "@veltra/styles/anime/fade.scss";
|
|
@@ -15,51 +15,223 @@
|
|
|
15
15
|
* --u-height-small: 24px;
|
|
16
16
|
*/
|
|
17
17
|
/** 暗色:data-theme 与系统偏好,与 UITheme.injectBuiltInThemes 选择器策略一致 */
|
|
18
|
-
@keyframes blink {
|
|
19
|
-
0% {
|
|
20
|
-
opacity: 0.3;
|
|
21
|
-
}
|
|
22
|
-
100% {
|
|
23
|
-
opacity: 1;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
18
|
.u-batch-edit {
|
|
19
|
+
position: relative;
|
|
27
20
|
overflow: hidden;
|
|
28
21
|
border-radius: var(--u-radius-default);
|
|
29
22
|
}
|
|
30
|
-
.u-batch-edit__table
|
|
23
|
+
.u-batch-edit__table {
|
|
31
24
|
flex-grow: 1;
|
|
32
25
|
}
|
|
33
|
-
.u-batch-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
.u-batch-edit .u-table__row:hover .u-action-group.is-hover,
|
|
27
|
+
.u-batch-edit .u-table__row.is-current .u-action-group.is-hover {
|
|
28
|
+
opacity: 1;
|
|
29
|
+
background-color: color-mix(in srgb, var(--u-bg-color-top) 70%, transparent);
|
|
30
|
+
backdrop-filter: blur(8px);
|
|
31
|
+
-webkit-backdrop-filter: blur(8px);
|
|
32
|
+
box-shadow: 0 1px 4px color-mix(in srgb, var(--u-shadow-color) 35%, transparent);
|
|
33
|
+
}
|
|
34
|
+
.u-batch-edit__add {
|
|
35
|
+
position: sticky;
|
|
36
|
+
left: 0;
|
|
37
|
+
bottom: 0;
|
|
38
|
+
z-index: 1;
|
|
39
|
+
padding: 8px 12px;
|
|
40
|
+
background-color: var(--u-bg-color-top);
|
|
41
|
+
}
|
|
42
|
+
.u-batch-edit__add-btn {
|
|
43
|
+
--add-color: var(--u-color-primary);
|
|
44
|
+
--add-border: color-mix(in srgb, var(--u-color-primary) 60%, transparent);
|
|
45
|
+
--add-bg: color-mix(in srgb, var(--u-color-primary) 5%, transparent);
|
|
46
|
+
position: sticky;
|
|
47
|
+
left: 12px;
|
|
48
|
+
height: 36px;
|
|
49
|
+
min-width: 220px;
|
|
50
|
+
max-width: 320px;
|
|
51
|
+
display: inline-flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
gap: 6px;
|
|
55
|
+
padding: 0 20px;
|
|
56
|
+
background: var(--add-bg);
|
|
57
|
+
border: 1px dashed var(--add-border);
|
|
58
|
+
border-radius: var(--u-radius-default);
|
|
59
|
+
color: var(--add-color);
|
|
60
|
+
font-size: var(--u-font-size-main-default);
|
|
61
|
+
font-weight: 500;
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
|
|
64
|
+
font-family: inherit;
|
|
65
|
+
}
|
|
66
|
+
.u-batch-edit__add-btn:hover:not(:disabled) {
|
|
67
|
+
--add-border: var(--u-color-primary);
|
|
68
|
+
--add-bg: var(--u-color-primary-light-9);
|
|
69
|
+
border-style: solid;
|
|
70
|
+
}
|
|
71
|
+
.u-batch-edit__add-btn:active:not(:disabled) {
|
|
72
|
+
transform: translateY(1px);
|
|
73
|
+
}
|
|
74
|
+
.u-batch-edit__add-btn:disabled {
|
|
75
|
+
cursor: not-allowed;
|
|
76
|
+
opacity: 0.55;
|
|
77
|
+
}
|
|
78
|
+
.u-batch-edit__add-btn.is-loading {
|
|
79
|
+
pointer-events: none;
|
|
80
|
+
}
|
|
81
|
+
.u-batch-edit__add-icon {
|
|
82
|
+
font-size: 16px;
|
|
83
|
+
display: inline-flex;
|
|
84
|
+
transition: transform 0.18s ease;
|
|
85
|
+
}
|
|
86
|
+
.u-batch-edit .u-batch-edit__add-btn:hover .u-batch-edit__add-icon {
|
|
87
|
+
transform: rotate(90deg);
|
|
88
|
+
}
|
|
89
|
+
.u-batch-edit__add-label {
|
|
90
|
+
line-height: 1;
|
|
36
91
|
}
|
|
37
92
|
.u-batch-edit__form {
|
|
93
|
+
--u-batch-edit-form-radius: var(--u-radius-large);
|
|
94
|
+
--u-batch-edit-form-padding: 16px;
|
|
95
|
+
display: flex;
|
|
96
|
+
flex-direction: column;
|
|
38
97
|
background-color: var(--u-bg-color-top);
|
|
98
|
+
border-radius: var(--u-batch-edit-form-radius);
|
|
99
|
+
box-shadow: 0 1px 2px color-mix(in srgb, var(--u-shadow-color) 40%, transparent), 0 12px 32px -16px color-mix(in srgb, var(--u-shadow-color) 50%, transparent);
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
isolation: isolate;
|
|
102
|
+
min-height: 0;
|
|
39
103
|
}
|
|
40
|
-
.u-batch-edit__form
|
|
41
|
-
|
|
104
|
+
.u-batch-edit__form::before {
|
|
105
|
+
content: "";
|
|
106
|
+
position: absolute;
|
|
107
|
+
top: 0;
|
|
108
|
+
left: 0;
|
|
109
|
+
right: 0;
|
|
110
|
+
height: 3px;
|
|
111
|
+
background: linear-gradient(90deg, var(--u-color-primary) 0%, color-mix(in srgb, var(--u-color-primary) 50%, transparent) 100%);
|
|
112
|
+
opacity: 0.7;
|
|
113
|
+
z-index: 1;
|
|
42
114
|
}
|
|
43
|
-
.u-batch-
|
|
44
|
-
|
|
115
|
+
.u-batch-edit__form-header {
|
|
116
|
+
display: flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
gap: 10px;
|
|
119
|
+
padding: 8px 14px;
|
|
120
|
+
border-bottom: 1px solid var(--u-border-color);
|
|
121
|
+
flex-shrink: 0;
|
|
45
122
|
}
|
|
46
|
-
.u-batch-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
123
|
+
.u-batch-edit__form-icon {
|
|
124
|
+
--tone-color: var(--u-color-primary);
|
|
125
|
+
--tone-bg: var(--u-color-primary-light-9);
|
|
126
|
+
width: 30px;
|
|
127
|
+
height: 30px;
|
|
128
|
+
border-radius: var(--u-radius-default);
|
|
129
|
+
display: inline-flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
flex-shrink: 0;
|
|
133
|
+
color: var(--tone-color);
|
|
134
|
+
background-color: var(--tone-bg);
|
|
135
|
+
font-size: 16px;
|
|
136
|
+
transition: color 0.2s ease, background-color 0.2s ease;
|
|
137
|
+
}
|
|
138
|
+
.u-batch-edit__form-icon.is-create {
|
|
139
|
+
--tone-color: var(--u-color-success);
|
|
140
|
+
--tone-bg: var(--u-color-success-light-9);
|
|
141
|
+
}
|
|
142
|
+
.u-batch-edit__form-icon.is-child {
|
|
143
|
+
--tone-color: var(--u-color-warning);
|
|
144
|
+
--tone-bg: var(--u-color-warning-light-9);
|
|
51
145
|
}
|
|
52
|
-
.u-batch-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
display: block;
|
|
146
|
+
.u-batch-edit__form-icon.is-view {
|
|
147
|
+
--tone-color: var(--u-text-color-second);
|
|
148
|
+
--tone-bg: var(--u-bg-color-hover);
|
|
56
149
|
}
|
|
57
|
-
.u-batch-
|
|
150
|
+
.u-batch-edit__form-title {
|
|
151
|
+
flex: 1 1 auto;
|
|
152
|
+
min-width: 0;
|
|
153
|
+
display: flex;
|
|
154
|
+
flex-direction: column;
|
|
155
|
+
gap: 2px;
|
|
156
|
+
}
|
|
157
|
+
.u-batch-edit__form-title-text {
|
|
158
|
+
margin: 0;
|
|
159
|
+
font-size: var(--u-font-size-title-default);
|
|
160
|
+
font-weight: 600;
|
|
161
|
+
color: var(--u-text-color-title);
|
|
162
|
+
line-height: 1.25;
|
|
163
|
+
}
|
|
164
|
+
.u-batch-edit__form-chip {
|
|
165
|
+
display: inline-block;
|
|
166
|
+
align-self: flex-start;
|
|
167
|
+
padding: 1px 8px;
|
|
168
|
+
font-size: 12px;
|
|
169
|
+
line-height: 18px;
|
|
170
|
+
border-radius: 999px;
|
|
171
|
+
background-color: var(--u-bg-color-hover);
|
|
172
|
+
color: var(--u-text-color-second);
|
|
173
|
+
white-space: nowrap;
|
|
174
|
+
overflow: hidden;
|
|
175
|
+
text-overflow: ellipsis;
|
|
176
|
+
max-width: 100%;
|
|
177
|
+
}
|
|
178
|
+
.u-batch-edit__form-close {
|
|
179
|
+
flex-shrink: 0;
|
|
180
|
+
align-self: flex-start;
|
|
181
|
+
}
|
|
182
|
+
.u-batch-edit__form-body {
|
|
183
|
+
flex: 1 1 auto;
|
|
184
|
+
min-height: 0;
|
|
185
|
+
}
|
|
186
|
+
.u-batch-edit__form-body .u-form__body {
|
|
187
|
+
padding: 10px var(--u-batch-edit-form-padding) 4px;
|
|
188
|
+
}
|
|
189
|
+
.u-batch-edit__form-footer {
|
|
58
190
|
display: flex;
|
|
59
|
-
justify-content: space-between;
|
|
60
191
|
align-items: center;
|
|
61
|
-
|
|
192
|
+
justify-content: space-between;
|
|
193
|
+
gap: 12px;
|
|
194
|
+
padding: 6px 12px;
|
|
195
|
+
border-top: 1px solid var(--u-border-color);
|
|
196
|
+
background-color: var(--u-bg-color-top);
|
|
197
|
+
flex-shrink: 0;
|
|
198
|
+
}
|
|
199
|
+
.u-batch-edit__form-hint {
|
|
200
|
+
font-size: 12px;
|
|
201
|
+
color: var(--u-text-color-placeholder);
|
|
202
|
+
flex: 1 1 auto;
|
|
203
|
+
min-width: 0;
|
|
204
|
+
overflow: hidden;
|
|
205
|
+
text-overflow: ellipsis;
|
|
206
|
+
white-space: nowrap;
|
|
207
|
+
}
|
|
208
|
+
.u-batch-edit__form-hint > kbd {
|
|
209
|
+
display: inline-block;
|
|
210
|
+
min-width: 18px;
|
|
211
|
+
padding: 1px 5px;
|
|
212
|
+
margin: 0 1px;
|
|
213
|
+
font-size: 11px;
|
|
214
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
215
|
+
color: var(--u-text-color-second);
|
|
216
|
+
background-color: var(--u-bg-color-hover);
|
|
217
|
+
border: 1px solid var(--u-border-color);
|
|
218
|
+
border-radius: 4px;
|
|
219
|
+
line-height: 1;
|
|
220
|
+
vertical-align: 1px;
|
|
221
|
+
}
|
|
222
|
+
.u-batch-edit__form-actions {
|
|
223
|
+
display: flex;
|
|
224
|
+
gap: 8px;
|
|
225
|
+
flex-shrink: 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.batch-edit-panel-enter-active,
|
|
229
|
+
.batch-edit-panel-leave-active {
|
|
230
|
+
transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.24s ease;
|
|
62
231
|
}
|
|
63
|
-
|
|
64
|
-
|
|
232
|
+
|
|
233
|
+
.batch-edit-panel-enter-from,
|
|
234
|
+
.batch-edit-panel-leave-to {
|
|
235
|
+
transform: translateX(16px) scale(0.985);
|
|
236
|
+
opacity: 0;
|
|
65
237
|
}
|