@veltra/desktop 1.7.17 → 1.7.19
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/batch-edit/batch-edit-form.js +6 -1
- package/dist/components/batch-edit/batch-edit-form.js.map +1 -1
- package/dist/components/batch-edit/batch-edit-list.js +45 -27
- package/dist/components/batch-edit/batch-edit-list.js.map +1 -1
- package/dist/components/batch-edit/batch-edit.js +2 -2
- package/dist/components/batch-edit/batch-edit.js.map +1 -1
- package/dist/components/batch-edit/di.js.map +1 -1
- package/dist/components/batch-edit/use-edit-state.js +14 -10
- package/dist/components/batch-edit/use-edit-state.js.map +1 -1
- package/dist/components/batch-edit/use-handlers.js +1 -0
- package/dist/components/batch-edit/use-handlers.js.map +1 -1
- package/dist/components/dialog/style2.css +1 -1
- package/dist/components/expression-editor/core/chip.js +1 -15
- package/dist/components/expression-editor/core/chip.js.map +1 -1
- package/dist/components/expression-editor/core/editor.js +0 -18
- package/dist/components/expression-editor/core/editor.js.map +1 -1
- package/dist/components/expression-editor/expression-editor.js +0 -4
- package/dist/components/expression-editor/expression-editor.js.map +1 -1
- package/dist/components/expression-editor/style2.css +0 -23
- package/dist/index.d.ts +2 -2
- package/dist/types/batch-edit.d.ts +0 -3
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/batch-edit/__test__/batch-edit.test.ts +165 -38
- package/src/components/batch-edit/batch-edit-form.vue +7 -1
- package/src/components/batch-edit/batch-edit-list.vue +53 -22
- package/src/components/batch-edit/batch-edit.vue +2 -1
- package/src/components/batch-edit/di.ts +2 -0
- package/src/components/batch-edit/use-edit-state.ts +25 -32
- package/src/components/batch-edit/use-handlers.ts +2 -0
- package/src/components/dialog/style.scss +2 -1
- package/src/components/expression-editor/__test__/chip.test.ts +3 -14
- package/src/components/expression-editor/core/chip.ts +3 -29
- package/src/components/expression-editor/core/editor.ts +0 -21
- package/src/components/expression-editor/expression-editor.vue +0 -4
- package/src/components/expression-editor/style.scss +0 -29
- package/src/types/batch-edit.ts +0 -4
|
@@ -8,18 +8,15 @@ export interface ChipDeps {
|
|
|
8
8
|
|
|
9
9
|
export interface ChipFactoryOptions extends ChipDeps {
|
|
10
10
|
/**
|
|
11
|
-
* 当用户点击 chip
|
|
11
|
+
* 当用户点击 chip 主体时回调,由调用方决定如何打开重选面板。
|
|
12
12
|
* 收到的 chipEl 当前在 DOM 中的位置即为重选锚点。
|
|
13
13
|
*/
|
|
14
14
|
onReselect: (chipEl: HTMLElement) => void
|
|
15
|
-
/** 当用户点击 × 时回调,调用方应将该 chip 从模型 / DOM 中移除。 */
|
|
16
|
-
onRemove: (chipEl: HTMLElement) => void
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
const CHIP_DATA_SEG = 'var'
|
|
20
18
|
const CHIP_VALUE_ATTR = 'data-value'
|
|
21
19
|
const CHIP_TYPE_ATTR = 'data-var-type'
|
|
22
|
-
const CHIP_CLOSE_ATTR = 'data-chip-close'
|
|
23
20
|
|
|
24
21
|
/** 判断一个 DOM 节点是否为 chip 元素(var 段渲染体) */
|
|
25
22
|
export function isChipElement(node: Node | null): node is HTMLElement {
|
|
@@ -30,12 +27,6 @@ export function isChipElement(node: Node | null): node is HTMLElement {
|
|
|
30
27
|
)
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
/** 判断点击目标是否落在 × 删除区。 */
|
|
34
|
-
function isCloseTarget(target: EventTarget | null): boolean {
|
|
35
|
-
if (!(target instanceof Element)) return false
|
|
36
|
-
return !!target.closest(`[${CHIP_CLOSE_ATTR}]`)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
30
|
/** 从给定 segment 创建一个 chip 元素(var 段渲染体)。 */
|
|
40
31
|
export function createChip(
|
|
41
32
|
segment: Extract<Segment, { kind: 'var' }>,
|
|
@@ -55,25 +46,13 @@ export function createChip(
|
|
|
55
46
|
label.className = cls.e('chip-label')
|
|
56
47
|
label.textContent = segment.type ? `${segment.label} (${segment.type})` : segment.label
|
|
57
48
|
|
|
58
|
-
const close = document.createElement('span')
|
|
59
|
-
close.className = cls.e('chip-close')
|
|
60
|
-
close.setAttribute(CHIP_CLOSE_ATTR, 'true')
|
|
61
|
-
close.setAttribute('aria-label', '删除')
|
|
62
|
-
close.setAttribute('role', 'button')
|
|
63
|
-
close.textContent = '×'
|
|
64
|
-
|
|
65
49
|
chip.appendChild(label)
|
|
66
|
-
chip.appendChild(close)
|
|
67
50
|
|
|
68
51
|
chip.addEventListener('mousedown', (e) => {
|
|
69
52
|
e.preventDefault()
|
|
70
53
|
// 阻止冒泡:避免宿主弹框(如 dialog)的 mousedown 层级提升逻辑把 chip 打开的重选面板盖住
|
|
71
54
|
e.stopPropagation()
|
|
72
|
-
|
|
73
|
-
opts.onRemove(chip)
|
|
74
|
-
} else {
|
|
75
|
-
opts.onReselect(chip)
|
|
76
|
-
}
|
|
55
|
+
opts.onReselect(chip)
|
|
77
56
|
})
|
|
78
57
|
|
|
79
58
|
return chip
|
|
@@ -95,9 +74,4 @@ export function setChipFocused(el: HTMLElement, focused: boolean): void {
|
|
|
95
74
|
}
|
|
96
75
|
|
|
97
76
|
/** 测试支持:暴露用于 DOM 选择器的属性常量。 */
|
|
98
|
-
export const ChipAttrs = {
|
|
99
|
-
seg: 'data-seg',
|
|
100
|
-
value: CHIP_VALUE_ATTR,
|
|
101
|
-
type: CHIP_TYPE_ATTR,
|
|
102
|
-
close: CHIP_CLOSE_ATTR
|
|
103
|
-
} as const
|
|
77
|
+
export const ChipAttrs = { seg: 'data-seg', value: CHIP_VALUE_ATTR, type: CHIP_TYPE_ATTR } as const
|
|
@@ -28,8 +28,6 @@ export interface EditorOptions {
|
|
|
28
28
|
onSelectionChange?: (info: { offset: number | null }) => void
|
|
29
29
|
/** 用户点击某个 chip 的主体(重选) */
|
|
30
30
|
onChipReselect?: (info: { chipEl: HTMLElement; segIndex: number; chipOffset: number }) => void
|
|
31
|
-
/** 用户点击某个 chip 的 ×(删除) */
|
|
32
|
-
onChipRemove?: (info: { chipEl: HTMLElement; segIndex: number }) => void
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
export interface EditorAPI {
|
|
@@ -50,8 +48,6 @@ export interface EditorAPI {
|
|
|
50
48
|
* 调用方通常在 mention 选中时用:start = `@` 起点、end = 当前光标。
|
|
51
49
|
*/
|
|
52
50
|
replaceRangeWithVar(start: number, end: number, variable: EditorVariableInfo): void
|
|
53
|
-
/** 移除指定段下标对应的 var chip(必须是 var 段)。 */
|
|
54
|
-
removeVarAt(segIndex: number): void
|
|
55
51
|
/** 替换指定段下标对应的 var chip 为新变量(必须是 var 段)。 */
|
|
56
52
|
replaceVarAt(segIndex: number, variable: EditorVariableInfo): void
|
|
57
53
|
/** 卸载所有事件监听(不会销毁 container DOM) */
|
|
@@ -85,11 +81,6 @@ export function createEditor(opts: EditorOptions): EditorAPI {
|
|
|
85
81
|
const { segIndex, chipOffset } = locateChip(chipEl)
|
|
86
82
|
if (segIndex < 0) return
|
|
87
83
|
opts.onChipReselect?.({ chipEl, segIndex, chipOffset })
|
|
88
|
-
},
|
|
89
|
-
onRemove: (chipEl) => {
|
|
90
|
-
const { segIndex } = locateChip(chipEl)
|
|
91
|
-
if (segIndex < 0) return
|
|
92
|
-
opts.onChipRemove?.({ chipEl, segIndex })
|
|
93
84
|
}
|
|
94
85
|
})
|
|
95
86
|
}
|
|
@@ -412,17 +403,6 @@ export function createEditor(opts: EditorOptions): EditorAPI {
|
|
|
412
403
|
render(a + variable.value.length + 2) // 光标定到 chip 之后
|
|
413
404
|
}
|
|
414
405
|
|
|
415
|
-
function removeVarAt(segIndex: number) {
|
|
416
|
-
const target = doc[segIndex]
|
|
417
|
-
if (!target || target.kind !== 'var') return
|
|
418
|
-
const before = doc.slice(0, segIndex)
|
|
419
|
-
const after = doc.slice(segIndex + 1)
|
|
420
|
-
const caretOffset = sliceLength(before)
|
|
421
|
-
const next = normalize([...before, ...after])
|
|
422
|
-
emitChange(next)
|
|
423
|
-
render(caretOffset)
|
|
424
|
-
}
|
|
425
|
-
|
|
426
406
|
function replaceVarAt(segIndex: number, variable: EditorVariableInfo) {
|
|
427
407
|
const target = doc[segIndex]
|
|
428
408
|
if (!target || target.kind !== 'var') return
|
|
@@ -499,7 +479,6 @@ export function createEditor(opts: EditorOptions): EditorAPI {
|
|
|
499
479
|
getCaretOffset,
|
|
500
480
|
setCaretOffset: setCaret,
|
|
501
481
|
replaceRangeWithVar,
|
|
502
|
-
removeVarAt,
|
|
503
482
|
replaceVarAt,
|
|
504
483
|
rerender: () => render(),
|
|
505
484
|
dispose: () => {
|
|
@@ -135,10 +135,6 @@ onMounted(() => {
|
|
|
135
135
|
pickerFilter.value = ''
|
|
136
136
|
pickerTriggerDom.value = chipEl
|
|
137
137
|
reselectingSegIdx.value = segIndex
|
|
138
|
-
},
|
|
139
|
-
onChipRemove: ({ segIndex }) => {
|
|
140
|
-
if (disabled.value || readonly.value) return
|
|
141
|
-
editor.removeVarAt(segIndex)
|
|
142
138
|
}
|
|
143
139
|
})
|
|
144
140
|
editorRef.value = editor
|
|
@@ -105,12 +105,6 @@ $root-name: expression-editor;
|
|
|
105
105
|
fn.use-var(color, primary, light-7)
|
|
106
106
|
);
|
|
107
107
|
box-shadow: 0 1px 4px fn.use-var(shadow, color);
|
|
108
|
-
|
|
109
|
-
#{fn.bem($root-name, chip-close)} {
|
|
110
|
-
opacity: 1;
|
|
111
|
-
max-width: 14px;
|
|
112
|
-
margin-left: 2px;
|
|
113
|
-
}
|
|
114
108
|
}
|
|
115
109
|
|
|
116
110
|
&.is-focused {
|
|
@@ -122,29 +116,6 @@ $root-name: expression-editor;
|
|
|
122
116
|
pointer-events: none;
|
|
123
117
|
}
|
|
124
118
|
|
|
125
|
-
@include m.e(chip-close) {
|
|
126
|
-
display: inline-flex;
|
|
127
|
-
align-items: center;
|
|
128
|
-
justify-content: center;
|
|
129
|
-
width: 14px;
|
|
130
|
-
max-width: 0;
|
|
131
|
-
margin-left: 0;
|
|
132
|
-
overflow: hidden;
|
|
133
|
-
font-size: 14px;
|
|
134
|
-
line-height: 1;
|
|
135
|
-
color: fn.use-var(color, primary);
|
|
136
|
-
opacity: 0;
|
|
137
|
-
transition:
|
|
138
|
-
opacity 0.12s ease,
|
|
139
|
-
max-width 0.12s ease,
|
|
140
|
-
margin-left 0.12s ease;
|
|
141
|
-
cursor: pointer;
|
|
142
|
-
|
|
143
|
-
&:hover {
|
|
144
|
-
transform: scale(1.1);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
119
|
// ─── 变量选择面板 ──────────────────────────────────────────
|
|
149
120
|
@include m.e(picker) {
|
|
150
121
|
min-width: 220px;
|
package/src/types/batch-edit.ts
CHANGED
|
@@ -8,8 +8,6 @@ export interface BatchEditColumn extends TableColumn {}
|
|
|
8
8
|
|
|
9
9
|
export type BatchEditFeature = 'create' | 'update' | 'delete' | 'view' | 'createChild'
|
|
10
10
|
|
|
11
|
-
export type BatchEditFormStatus = 'hidden'
|
|
12
|
-
|
|
13
11
|
/** 批量编辑状态 */
|
|
14
12
|
export interface BatchEditStates {
|
|
15
13
|
/** 层级 */
|
|
@@ -35,8 +33,6 @@ export interface BatchEditProps extends TableProps {
|
|
|
35
33
|
* @description 与右侧 UForm 绑定的 reactive 对象
|
|
36
34
|
*/
|
|
37
35
|
model?: Record<string, any>
|
|
38
|
-
/** 表格标题 */
|
|
39
|
-
title?: string
|
|
40
36
|
/**
|
|
41
37
|
* 列的宽度定义
|
|
42
38
|
*/
|