@worm-print-platform/plugin-kit 1.6.0 → 1.6.1
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/README.md +1 -1
- package/dist/controls.cjs +15 -11
- package/dist/controls.d.cts +4 -1
- package/dist/controls.d.ts +4 -1
- package/dist/controls.js +15 -11
- package/dist/dom.d.cts +1 -1
- package/dist/dom.d.ts +1 -1
- package/dist/expression-editor.cjs +112 -95
- package/dist/expression-editor.d.cts +4 -1
- package/dist/expression-editor.d.ts +4 -1
- package/dist/expression-editor.js +112 -95
- package/dist/index.cjs +34 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +33 -1
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/controls.cjs
CHANGED
|
@@ -30,6 +30,7 @@ __export(color_picker_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(color_picker_exports);
|
|
32
32
|
var import_designer = require("@worm-print-platform/core/designer");
|
|
33
|
+
var import_i18n = require("@worm-print-platform/core/i18n");
|
|
33
34
|
|
|
34
35
|
// src/dom.ts
|
|
35
36
|
function h(tag, props = {}, children = []) {
|
|
@@ -131,7 +132,8 @@ function clamp01(number) {
|
|
|
131
132
|
return Math.min(1, Math.max(0, Number.isFinite(number) ? number : 0));
|
|
132
133
|
}
|
|
133
134
|
function colorPicker(opts) {
|
|
134
|
-
const
|
|
135
|
+
const tr = opts.translator ?? import_i18n.t;
|
|
136
|
+
const title = opts.title ?? tr("colorPicker.pickColor");
|
|
135
137
|
return h("button", {
|
|
136
138
|
type: "button",
|
|
137
139
|
class: `preset-color-trigger${opts.triggerClass ? ` ${opts.triggerClass}` : ""}`,
|
|
@@ -147,7 +149,7 @@ function colorPicker(opts) {
|
|
|
147
149
|
return;
|
|
148
150
|
}
|
|
149
151
|
closeColorPicker();
|
|
150
|
-
openPanel(btn, opts);
|
|
152
|
+
openPanel(btn, opts, tr);
|
|
151
153
|
}
|
|
152
154
|
}, [
|
|
153
155
|
h("span", {
|
|
@@ -164,12 +166,12 @@ function closeColorPicker() {
|
|
|
164
166
|
inst.trigger.setAttribute("aria-expanded", "false");
|
|
165
167
|
inst.panel.remove();
|
|
166
168
|
}
|
|
167
|
-
function openPanel(trigger, opts) {
|
|
169
|
+
function openPanel(trigger, opts, tr) {
|
|
168
170
|
const root = trigger.getRootNode();
|
|
169
171
|
const mount = root instanceof ShadowRoot ? root : document.body;
|
|
170
172
|
const inst = {
|
|
171
173
|
root,
|
|
172
|
-
title: opts.title ?? "
|
|
174
|
+
title: opts.title ?? tr("colorPicker.pickColor"),
|
|
173
175
|
trigger,
|
|
174
176
|
panel: null,
|
|
175
177
|
clearable: opts.clearable !== false,
|
|
@@ -186,6 +188,7 @@ function openPanel(trigger, opts) {
|
|
|
186
188
|
handle: null,
|
|
187
189
|
hueRange: null,
|
|
188
190
|
clearBtn: null,
|
|
191
|
+
translator: tr,
|
|
189
192
|
items: [],
|
|
190
193
|
teardowns: []
|
|
191
194
|
};
|
|
@@ -244,10 +247,11 @@ function pathOf(ev) {
|
|
|
244
247
|
return composed.length ? composed : [ev.target];
|
|
245
248
|
}
|
|
246
249
|
function buildPanel(inst) {
|
|
250
|
+
const tr = inst.translator;
|
|
247
251
|
return h("div", {
|
|
248
252
|
class: "preset-color-panel",
|
|
249
253
|
role: "dialog",
|
|
250
|
-
"aria-label": "
|
|
254
|
+
"aria-label": tr("colorPicker.pickColor"),
|
|
251
255
|
style: { position: "fixed" },
|
|
252
256
|
onPointerdown: (ev) => ev.stopPropagation()
|
|
253
257
|
}, [
|
|
@@ -258,13 +262,13 @@ function buildPanel(inst) {
|
|
|
258
262
|
type: "text",
|
|
259
263
|
maxlength: 7,
|
|
260
264
|
spellcheck: "false",
|
|
261
|
-
"aria-label": "
|
|
265
|
+
"aria-label": tr("colorPicker.hexValue"),
|
|
262
266
|
onInput: (ev) => onHexInput(inst, ev.target.value)
|
|
263
267
|
})
|
|
264
268
|
]),
|
|
265
269
|
h("div", {
|
|
266
270
|
class: "picker-area",
|
|
267
|
-
"aria-label": "
|
|
271
|
+
"aria-label": tr("colorPicker.customColor"),
|
|
268
272
|
tabindex: 0,
|
|
269
273
|
onPointerdown: (ev) => startAreaDrag(inst, ev),
|
|
270
274
|
onKeydown: (ev) => onAreaKeydown(inst, ev)
|
|
@@ -275,16 +279,16 @@ function buildPanel(inst) {
|
|
|
275
279
|
min: 0,
|
|
276
280
|
max: 360,
|
|
277
281
|
step: 1,
|
|
278
|
-
"aria-label": "
|
|
282
|
+
"aria-label": tr("colorPicker.hue"),
|
|
279
283
|
onInput: (ev) => onHueInput(inst, Number(ev.target.value)),
|
|
280
284
|
onChange: () => commitHsv(inst)
|
|
281
285
|
}),
|
|
282
286
|
h("div", { class: "picker-heading" }, [
|
|
283
|
-
h("span", { text: "
|
|
287
|
+
h("span", { text: tr("colorPicker.commonColors") }),
|
|
284
288
|
inst.clearable ? h("button", {
|
|
285
289
|
type: "button",
|
|
286
290
|
class: "picker-clear",
|
|
287
|
-
title: "
|
|
291
|
+
title: tr("colorPicker.clear"),
|
|
288
292
|
onClick: () => commitModel(inst, void 0)
|
|
289
293
|
}, [
|
|
290
294
|
h("svg", { viewBox: "0 0 16 16", width: 12, height: 12, "aria-hidden": "true" }, [
|
|
@@ -296,7 +300,7 @@ function buildPanel(inst) {
|
|
|
296
300
|
fill: "none"
|
|
297
301
|
})
|
|
298
302
|
]),
|
|
299
|
-
"
|
|
303
|
+
tr("colorPicker.clearShort")
|
|
300
304
|
]) : ""
|
|
301
305
|
].filter(Boolean)),
|
|
302
306
|
h("div", { class: "preset-color-grid" }, import_designer.PRESET_COLORS.map((color) => h("button", {
|
package/dist/controls.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/plugin-kit v1.6.
|
|
2
|
+
* @worm-print-platform/plugin-kit v1.6.1
|
|
3
3
|
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
4
|
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
6
|
*/
|
|
7
|
+
import { Translate } from '@worm-print-platform/core/i18n';
|
|
7
8
|
import { El } from './dom.cjs';
|
|
8
9
|
|
|
9
10
|
interface ColorPickerOptions {
|
|
@@ -17,6 +18,8 @@ interface ColorPickerOptions {
|
|
|
17
18
|
triggerClass?: string;
|
|
18
19
|
/** 选中回调;undefined 表示清除(Vue 3 轨 emit '' 的等价归一) */
|
|
19
20
|
onChange: (value: string | undefined) => void;
|
|
21
|
+
/** 面板文案 translator;缺省用 core 全局 locale。绘制期由宿主固化实例 translator 传入 */
|
|
22
|
+
translator?: Translate;
|
|
20
23
|
}
|
|
21
24
|
declare function parseHex(color: string): {
|
|
22
25
|
r: number;
|
package/dist/controls.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/plugin-kit v1.6.
|
|
2
|
+
* @worm-print-platform/plugin-kit v1.6.1
|
|
3
3
|
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
4
|
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
6
|
*/
|
|
7
|
+
import { Translate } from '@worm-print-platform/core/i18n';
|
|
7
8
|
import { El } from './dom.js';
|
|
8
9
|
|
|
9
10
|
interface ColorPickerOptions {
|
|
@@ -17,6 +18,8 @@ interface ColorPickerOptions {
|
|
|
17
18
|
triggerClass?: string;
|
|
18
19
|
/** 选中回调;undefined 表示清除(Vue 3 轨 emit '' 的等价归一) */
|
|
19
20
|
onChange: (value: string | undefined) => void;
|
|
21
|
+
/** 面板文案 translator;缺省用 core 全局 locale。绘制期由宿主固化实例 translator 传入 */
|
|
22
|
+
translator?: Translate;
|
|
20
23
|
}
|
|
21
24
|
declare function parseHex(color: string): {
|
|
22
25
|
r: number;
|
package/dist/controls.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
|
|
6
6
|
// src/color-picker.ts
|
|
7
7
|
import { PRESET_COLORS } from "@worm-print-platform/core/designer";
|
|
8
|
+
import { t as globalT } from "@worm-print-platform/core/i18n";
|
|
8
9
|
var active = null;
|
|
9
10
|
function parseHex(color) {
|
|
10
11
|
const match = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color.trim());
|
|
@@ -56,7 +57,8 @@ function clamp01(number) {
|
|
|
56
57
|
return Math.min(1, Math.max(0, Number.isFinite(number) ? number : 0));
|
|
57
58
|
}
|
|
58
59
|
function colorPicker(opts) {
|
|
59
|
-
const
|
|
60
|
+
const tr = opts.translator ?? globalT;
|
|
61
|
+
const title = opts.title ?? tr("colorPicker.pickColor");
|
|
60
62
|
return h("button", {
|
|
61
63
|
type: "button",
|
|
62
64
|
class: `preset-color-trigger${opts.triggerClass ? ` ${opts.triggerClass}` : ""}`,
|
|
@@ -72,7 +74,7 @@ function colorPicker(opts) {
|
|
|
72
74
|
return;
|
|
73
75
|
}
|
|
74
76
|
closeColorPicker();
|
|
75
|
-
openPanel(btn, opts);
|
|
77
|
+
openPanel(btn, opts, tr);
|
|
76
78
|
}
|
|
77
79
|
}, [
|
|
78
80
|
h("span", {
|
|
@@ -89,12 +91,12 @@ function closeColorPicker() {
|
|
|
89
91
|
inst.trigger.setAttribute("aria-expanded", "false");
|
|
90
92
|
inst.panel.remove();
|
|
91
93
|
}
|
|
92
|
-
function openPanel(trigger, opts) {
|
|
94
|
+
function openPanel(trigger, opts, tr) {
|
|
93
95
|
const root = trigger.getRootNode();
|
|
94
96
|
const mount = root instanceof ShadowRoot ? root : document.body;
|
|
95
97
|
const inst = {
|
|
96
98
|
root,
|
|
97
|
-
title: opts.title ?? "
|
|
99
|
+
title: opts.title ?? tr("colorPicker.pickColor"),
|
|
98
100
|
trigger,
|
|
99
101
|
panel: null,
|
|
100
102
|
clearable: opts.clearable !== false,
|
|
@@ -111,6 +113,7 @@ function openPanel(trigger, opts) {
|
|
|
111
113
|
handle: null,
|
|
112
114
|
hueRange: null,
|
|
113
115
|
clearBtn: null,
|
|
116
|
+
translator: tr,
|
|
114
117
|
items: [],
|
|
115
118
|
teardowns: []
|
|
116
119
|
};
|
|
@@ -169,10 +172,11 @@ function pathOf(ev) {
|
|
|
169
172
|
return composed.length ? composed : [ev.target];
|
|
170
173
|
}
|
|
171
174
|
function buildPanel(inst) {
|
|
175
|
+
const tr = inst.translator;
|
|
172
176
|
return h("div", {
|
|
173
177
|
class: "preset-color-panel",
|
|
174
178
|
role: "dialog",
|
|
175
|
-
"aria-label": "
|
|
179
|
+
"aria-label": tr("colorPicker.pickColor"),
|
|
176
180
|
style: { position: "fixed" },
|
|
177
181
|
onPointerdown: (ev) => ev.stopPropagation()
|
|
178
182
|
}, [
|
|
@@ -183,13 +187,13 @@ function buildPanel(inst) {
|
|
|
183
187
|
type: "text",
|
|
184
188
|
maxlength: 7,
|
|
185
189
|
spellcheck: "false",
|
|
186
|
-
"aria-label": "
|
|
190
|
+
"aria-label": tr("colorPicker.hexValue"),
|
|
187
191
|
onInput: (ev) => onHexInput(inst, ev.target.value)
|
|
188
192
|
})
|
|
189
193
|
]),
|
|
190
194
|
h("div", {
|
|
191
195
|
class: "picker-area",
|
|
192
|
-
"aria-label": "
|
|
196
|
+
"aria-label": tr("colorPicker.customColor"),
|
|
193
197
|
tabindex: 0,
|
|
194
198
|
onPointerdown: (ev) => startAreaDrag(inst, ev),
|
|
195
199
|
onKeydown: (ev) => onAreaKeydown(inst, ev)
|
|
@@ -200,16 +204,16 @@ function buildPanel(inst) {
|
|
|
200
204
|
min: 0,
|
|
201
205
|
max: 360,
|
|
202
206
|
step: 1,
|
|
203
|
-
"aria-label": "
|
|
207
|
+
"aria-label": tr("colorPicker.hue"),
|
|
204
208
|
onInput: (ev) => onHueInput(inst, Number(ev.target.value)),
|
|
205
209
|
onChange: () => commitHsv(inst)
|
|
206
210
|
}),
|
|
207
211
|
h("div", { class: "picker-heading" }, [
|
|
208
|
-
h("span", { text: "
|
|
212
|
+
h("span", { text: tr("colorPicker.commonColors") }),
|
|
209
213
|
inst.clearable ? h("button", {
|
|
210
214
|
type: "button",
|
|
211
215
|
class: "picker-clear",
|
|
212
|
-
title: "
|
|
216
|
+
title: tr("colorPicker.clear"),
|
|
213
217
|
onClick: () => commitModel(inst, void 0)
|
|
214
218
|
}, [
|
|
215
219
|
h("svg", { viewBox: "0 0 16 16", width: 12, height: 12, "aria-hidden": "true" }, [
|
|
@@ -221,7 +225,7 @@ function buildPanel(inst) {
|
|
|
221
225
|
fill: "none"
|
|
222
226
|
})
|
|
223
227
|
]),
|
|
224
|
-
"
|
|
228
|
+
tr("colorPicker.clearShort")
|
|
225
229
|
]) : ""
|
|
226
230
|
].filter(Boolean)),
|
|
227
231
|
h("div", { class: "preset-color-grid" }, PRESET_COLORS.map((color) => h("button", {
|
package/dist/dom.d.cts
CHANGED
package/dist/dom.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ __export(expression_editor_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(expression_editor_exports);
|
|
27
27
|
var import_designer = require("@worm-print-platform/core/designer");
|
|
28
|
+
var import_i18n = require("@worm-print-platform/core/i18n");
|
|
28
29
|
var import_core = require("@worm-print-platform/core");
|
|
29
30
|
|
|
30
31
|
// src/dom.ts
|
|
@@ -79,6 +80,7 @@ function clear(node) {
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
// src/expression-editor.ts
|
|
83
|
+
var tr = import_i18n.t;
|
|
82
84
|
var ICON_PATHS = {
|
|
83
85
|
Check: '<path d="M20 6 9 17l-5-5" />',
|
|
84
86
|
Copy: '<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />'
|
|
@@ -90,62 +92,76 @@ function normalizeFieldDisplay(v) {
|
|
|
90
92
|
const s = typeof v === "string" ? v.trim().toLowerCase() : "";
|
|
91
93
|
return s === "label" || s === "key" || s === "both" ? s : "both";
|
|
92
94
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
95
|
+
function getTabs() {
|
|
96
|
+
return [
|
|
97
|
+
{ key: "field", text: tr("expression.tabField") },
|
|
98
|
+
{ key: "variable", text: tr("expression.tabVariable") },
|
|
99
|
+
{ key: "function", text: tr("expression.tabFunction") }
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
function getPlaceholder() {
|
|
103
|
+
return {
|
|
104
|
+
field: tr("expression.placeholderField"),
|
|
105
|
+
variable: tr("expression.placeholderVariable"),
|
|
106
|
+
function: tr("expression.placeholderFunction")
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function getAggregateFunctions() {
|
|
110
|
+
return [
|
|
111
|
+
{ name: "SUM", label: tr("expression.fnSum"), template: "SUM()" },
|
|
112
|
+
{ name: "AVG", label: tr("expression.fnAvg"), template: "AVG()" },
|
|
113
|
+
{ name: "COUNT", label: tr("expression.fnCount"), template: "COUNT()" },
|
|
114
|
+
{ name: "MIN", label: tr("expression.fnMin"), template: "MIN()" },
|
|
115
|
+
{ name: "MAX", label: tr("expression.fnMax"), template: "MAX()" }
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
function getMathFunctions() {
|
|
119
|
+
return [
|
|
120
|
+
{ name: "ADD", label: tr("expression.fnAdd"), template: "ADD()" },
|
|
121
|
+
{ name: "SUB", label: tr("expression.fnSub"), template: "SUB()" },
|
|
122
|
+
{ name: "MUL", label: tr("expression.fnMul"), template: "MUL()" },
|
|
123
|
+
{ name: "DIV", label: tr("expression.fnDiv"), template: "DIV()" },
|
|
124
|
+
{ name: "ROUND", label: tr("expression.fnRound"), template: "ROUND()" },
|
|
125
|
+
{ name: "ROUNDUP", label: tr("expression.fnRoundUp"), template: "ROUNDUP()" },
|
|
126
|
+
{ name: "ROUNDDOWN", label: tr("expression.fnRoundDown"), template: "ROUNDDOWN()" },
|
|
127
|
+
{ name: "ROUNDBANK", label: tr("expression.fnRoundBank"), template: "ROUNDBANK()" }
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
function getFormatFunctions() {
|
|
131
|
+
return [
|
|
132
|
+
{ name: "MONEY", label: tr("expression.fnMoney"), template: "MONEY()" },
|
|
133
|
+
{ name: "DATE", label: tr("expression.fnDate"), template: "DATE()" },
|
|
134
|
+
{ name: "UPPER", label: tr("expression.fnUpper"), template: "UPPER()" },
|
|
135
|
+
{ name: "IF", label: tr("expression.fnIf"), template: "IF()" }
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
function getSystemVariables() {
|
|
139
|
+
return [
|
|
140
|
+
{ name: "pageIndex", label: tr("expression.varPageIndex"), template: "{pageIndex}" },
|
|
141
|
+
{ name: "totalPages", label: tr("expression.varTotalPages"), template: "{totalPages}" },
|
|
142
|
+
{ name: "printDate", label: tr("expression.varPrintDate"), template: "{printDate}" },
|
|
143
|
+
{ name: "printTime", label: tr("expression.varPrintTime"), template: "{printTime}" }
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
function getFuncGroups() {
|
|
147
|
+
return [
|
|
148
|
+
{ title: tr("expression.groupAggregate"), items: getAggregateFunctions() },
|
|
149
|
+
{ title: tr("expression.groupMath"), items: getMathFunctions() },
|
|
150
|
+
{ title: tr("expression.groupFormat"), items: getFormatFunctions() }
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
var EMPTY_PREVIEW_KEY = "expression.previewEmpty";
|
|
154
|
+
var NO_VALUE_PREVIEW_KEY = "expression.previewNoValue";
|
|
155
|
+
var ERROR_PREVIEW_KEY = "expression.previewError";
|
|
140
156
|
function previewText(expr, demoData) {
|
|
141
|
-
if (!expr.trim()) return
|
|
157
|
+
if (!expr.trim()) return tr(EMPTY_PREVIEW_KEY);
|
|
142
158
|
try {
|
|
143
159
|
const ctx = { ...import_designer.DEFAULT_DEMO_DATA, ...demoData ?? {}, ...(0, import_core.resolveSystemVariables)() };
|
|
144
160
|
const result = (0, import_designer.evaluateTemplate)(expr, ctx);
|
|
145
|
-
if (result === void 0 || result === null) return
|
|
161
|
+
if (result === void 0 || result === null) return tr(NO_VALUE_PREVIEW_KEY);
|
|
146
162
|
return String(result);
|
|
147
163
|
} catch {
|
|
148
|
-
return
|
|
164
|
+
return tr(ERROR_PREVIEW_KEY);
|
|
149
165
|
}
|
|
150
166
|
}
|
|
151
167
|
function matchKeyword(items, keyword) {
|
|
@@ -197,41 +213,42 @@ function helpCard(modifier, title, lines) {
|
|
|
197
213
|
}
|
|
198
214
|
function helpSection() {
|
|
199
215
|
return h("div", { class: "ee-help-section" }, [
|
|
200
|
-
h("div", { class: "ee-help-title", text: "
|
|
216
|
+
h("div", { class: "ee-help-title", text: tr("expression.k1") }),
|
|
201
217
|
h("div", { class: "ee-help-grid" }, [
|
|
202
|
-
helpCard("ee-help-field", "
|
|
203
|
-
"
|
|
204
|
-
"
|
|
205
|
-
"
|
|
206
|
-
"
|
|
207
|
-
"
|
|
208
|
-
"
|
|
209
|
-
"
|
|
218
|
+
helpCard("ee-help-field", tr("expression.k2"), [
|
|
219
|
+
tr("expression.k3"),
|
|
220
|
+
tr("expression.k4"),
|
|
221
|
+
tr("expression.k5"),
|
|
222
|
+
tr("expression.k6"),
|
|
223
|
+
tr("expression.k7"),
|
|
224
|
+
tr("expression.k8"),
|
|
225
|
+
tr("expression.k9")
|
|
210
226
|
]),
|
|
211
|
-
helpCard("ee-help-function", "
|
|
212
|
-
"
|
|
213
|
-
"
|
|
214
|
-
"
|
|
215
|
-
"
|
|
216
|
-
"
|
|
217
|
-
"
|
|
227
|
+
helpCard("ee-help-function", tr("expression.k10"), [
|
|
228
|
+
tr("expression.k11"),
|
|
229
|
+
tr("expression.k12"),
|
|
230
|
+
tr("expression.k13"),
|
|
231
|
+
tr("expression.k14"),
|
|
232
|
+
tr("expression.k15"),
|
|
233
|
+
tr("expression.k16")
|
|
218
234
|
]),
|
|
219
|
-
helpCard("ee-help-variable", "
|
|
220
|
-
"
|
|
221
|
-
"
|
|
222
|
-
"
|
|
235
|
+
helpCard("ee-help-variable", tr("expression.k17"), [
|
|
236
|
+
tr("expression.k18"),
|
|
237
|
+
tr("expression.k19"),
|
|
238
|
+
tr("expression.k20")
|
|
223
239
|
]),
|
|
224
|
-
helpCard("ee-help-conditional", "
|
|
225
|
-
"
|
|
226
|
-
"
|
|
227
|
-
"
|
|
228
|
-
|
|
229
|
-
"
|
|
240
|
+
helpCard("ee-help-conditional", tr("expression.k21"), [
|
|
241
|
+
tr("expression.k22"),
|
|
242
|
+
tr("expression.k23"),
|
|
243
|
+
tr("expression.k24"),
|
|
244
|
+
tr("expression.k25"),
|
|
245
|
+
tr("expression.k26")
|
|
230
246
|
])
|
|
231
247
|
])
|
|
232
248
|
]);
|
|
233
249
|
}
|
|
234
250
|
function renderExpressionEditor(opts, target) {
|
|
251
|
+
tr = opts.t ?? import_i18n.t;
|
|
235
252
|
const fieldDisplay = normalizeFieldDisplay(opts.fieldDisplay);
|
|
236
253
|
const state = {
|
|
237
254
|
activeTab: "field",
|
|
@@ -250,7 +267,7 @@ function renderExpressionEditor(opts, target) {
|
|
|
250
267
|
if (!el) return;
|
|
251
268
|
const text = previewText(state.expression, opts.demoData);
|
|
252
269
|
el.textContent = text;
|
|
253
|
-
el.classList.toggle("ee-preview-error", text ===
|
|
270
|
+
el.classList.toggle("ee-preview-error", text === tr(ERROR_PREVIEW_KEY));
|
|
254
271
|
};
|
|
255
272
|
const updateKeyHint = (root) => {
|
|
256
273
|
const el = query(root, ".ee-key-hint");
|
|
@@ -260,7 +277,7 @@ function renderExpressionEditor(opts, target) {
|
|
|
260
277
|
};
|
|
261
278
|
const listItems = () => {
|
|
262
279
|
if (state.activeTab === "variable") {
|
|
263
|
-
return matchKeyword(
|
|
280
|
+
return matchKeyword(getSystemVariables(), state.searchText).map((sv) => h("div", {
|
|
264
281
|
class: "ee-list-item",
|
|
265
282
|
onDblclick: (ev) => {
|
|
266
283
|
const { insideParens } = region(ev);
|
|
@@ -269,7 +286,7 @@ function renderExpressionEditor(opts, target) {
|
|
|
269
286
|
}, [itemInfo(sv.label, sv.template)]));
|
|
270
287
|
}
|
|
271
288
|
if (state.activeTab === "function") {
|
|
272
|
-
return
|
|
289
|
+
return getFuncGroups().map((group) => h("div", { class: "ee-func-group" }, [
|
|
273
290
|
h("div", { class: "ee-func-group-title", text: group.title }),
|
|
274
291
|
...matchKeyword(group.items, state.searchText).map((fn) => h("div", {
|
|
275
292
|
class: "ee-list-item",
|
|
@@ -282,7 +299,7 @@ function renderExpressionEditor(opts, target) {
|
|
|
282
299
|
]));
|
|
283
300
|
}
|
|
284
301
|
const groups = (0, import_designer.filterGroups)((0, import_designer.groupFields)(opts.fields ?? []), state.searchText);
|
|
285
|
-
if (!groups.length) return [h("p", { class: "pd-empty", text: "
|
|
302
|
+
if (!groups.length) return [h("p", { class: "pd-empty", text: tr("expression.k27") })];
|
|
286
303
|
const nodes = [];
|
|
287
304
|
for (const group of groups) {
|
|
288
305
|
if (group.key) {
|
|
@@ -317,7 +334,7 @@ function renderExpressionEditor(opts, target) {
|
|
|
317
334
|
type: "button",
|
|
318
335
|
class: `ee-copy-btn${state.copiedFieldKey === field.fieldKey ? " is-copied" : ""}`,
|
|
319
336
|
// 提示浮层由 print-designer 的 hover-tip 委托承担(容器白名单含 .pd-dialog-overlay)
|
|
320
|
-
"data-tip": state.copiedFieldKey === field.fieldKey ? "
|
|
337
|
+
"data-tip": state.copiedFieldKey === field.fieldKey ? tr("expression.k28") : `\u590D\u5236\u5B57\u6BB5\u540D\u300C${field.fieldLabel}\u300D`,
|
|
321
338
|
"aria-label": `\u590D\u5236\u5B57\u6BB5\u540D ${field.fieldLabel}`,
|
|
322
339
|
html: iconSvg(state.copiedFieldKey === field.fieldKey ? "Check" : "Copy", 13),
|
|
323
340
|
onClick: (ev) => {
|
|
@@ -333,10 +350,10 @@ function renderExpressionEditor(opts, target) {
|
|
|
333
350
|
};
|
|
334
351
|
const repaint = (root) => {
|
|
335
352
|
const tabs = Array.from(root.querySelectorAll(".ee-nav-tab"));
|
|
336
|
-
tabs.forEach((el, i) => el.classList.toggle("active",
|
|
353
|
+
tabs.forEach((el, i) => el.classList.toggle("active", getTabs()[i]?.key === state.activeTab));
|
|
337
354
|
const search = query(root, ".ee-content-search .pd-input");
|
|
338
355
|
if (search) {
|
|
339
|
-
const placeholder =
|
|
356
|
+
const placeholder = getPlaceholder()[state.activeTab];
|
|
340
357
|
if (search.placeholder !== placeholder) search.placeholder = placeholder;
|
|
341
358
|
if (search.value !== state.searchText) search.value = state.searchText;
|
|
342
359
|
}
|
|
@@ -399,12 +416,12 @@ function renderExpressionEditor(opts, target) {
|
|
|
399
416
|
opts.onClose();
|
|
400
417
|
};
|
|
401
418
|
const nav = h("div", { class: "ee-nav" }, [
|
|
402
|
-
h("div", { class: "ee-nav-title", text: "
|
|
403
|
-
h("div", { class: "ee-nav-tabs" },
|
|
419
|
+
h("div", { class: "ee-nav-title", text: tr("expression.k29") }),
|
|
420
|
+
h("div", { class: "ee-nav-tabs" }, getTabs().map((tab, i) => h("div", {
|
|
404
421
|
class: `ee-nav-tab${state.activeTab === tab.key ? " active" : ""}`,
|
|
405
422
|
text: tab.text,
|
|
406
423
|
onClick: (ev) => {
|
|
407
|
-
state.activeTab =
|
|
424
|
+
state.activeTab = getTabs()[i].key;
|
|
408
425
|
repaint(scope(ev));
|
|
409
426
|
}
|
|
410
427
|
})))
|
|
@@ -413,7 +430,7 @@ function renderExpressionEditor(opts, target) {
|
|
|
413
430
|
h("div", { class: "ee-content-search" }, [
|
|
414
431
|
h("input", {
|
|
415
432
|
class: "pd-input",
|
|
416
|
-
placeholder:
|
|
433
|
+
placeholder: getPlaceholder()[state.activeTab],
|
|
417
434
|
onInput: (ev) => {
|
|
418
435
|
state.searchText = ev.target.value;
|
|
419
436
|
repaint(scope(ev));
|
|
@@ -425,11 +442,11 @@ function renderExpressionEditor(opts, target) {
|
|
|
425
442
|
const initialPreview = previewText(state.expression, opts.demoData);
|
|
426
443
|
const editor = h("div", { class: "ee-editor" }, [
|
|
427
444
|
h("div", { class: "ee-editor-section" }, [
|
|
428
|
-
h("div", { class: "ee-editor-title", text: "
|
|
445
|
+
h("div", { class: "ee-editor-title", text: tr("expression.k30") }),
|
|
429
446
|
h("textarea", {
|
|
430
447
|
class: "ee-textarea",
|
|
431
448
|
rows: 6,
|
|
432
|
-
placeholder: "
|
|
449
|
+
placeholder: tr("expression.k31"),
|
|
433
450
|
text: state.expression,
|
|
434
451
|
onInput: (ev) => {
|
|
435
452
|
state.expression = ev.target.value;
|
|
@@ -445,9 +462,9 @@ function renderExpressionEditor(opts, target) {
|
|
|
445
462
|
})
|
|
446
463
|
]),
|
|
447
464
|
h("div", { class: "ee-editor-section" }, [
|
|
448
|
-
h("div", { class: "ee-editor-title", text: "
|
|
465
|
+
h("div", { class: "ee-editor-title", text: tr("expression.k32") }),
|
|
449
466
|
h("div", {
|
|
450
|
-
class: `ee-preview${initialPreview ===
|
|
467
|
+
class: `ee-preview${initialPreview === tr(ERROR_PREVIEW_KEY) ? " ee-preview-error" : ""}`,
|
|
451
468
|
text: initialPreview
|
|
452
469
|
})
|
|
453
470
|
]),
|
|
@@ -466,13 +483,13 @@ function renderExpressionEditor(opts, target) {
|
|
|
466
483
|
"aria-labelledby": "expression-editor-title"
|
|
467
484
|
}, [
|
|
468
485
|
h("header", { class: "pd-dialog-header" }, [
|
|
469
|
-
h("strong", { id: "expression-editor-title", text: "
|
|
470
|
-
h("button", { type: "button", class: "pd-close", "aria-label": "
|
|
486
|
+
h("strong", { id: "expression-editor-title", text: tr("expression.k33") }),
|
|
487
|
+
h("button", { type: "button", class: "pd-close", "aria-label": tr("expression.k34"), text: "\xD7", onClick: () => opts.onClose() })
|
|
471
488
|
]),
|
|
472
489
|
h("div", { class: "expression-editor" }, [nav, content, editor]),
|
|
473
490
|
h("footer", { class: "pd-dialog-footer" }, [
|
|
474
|
-
h("button", { type: "button", class: "pd-button", text: "
|
|
475
|
-
h("button", { type: "button", class: "pd-button primary", text: "
|
|
491
|
+
h("button", { type: "button", class: "pd-button", text: tr("expression.k35"), onClick: () => opts.onClose() }),
|
|
492
|
+
h("button", { type: "button", class: "pd-button primary", text: tr("expression.k36"), onClick: () => onConfirm() })
|
|
476
493
|
])
|
|
477
494
|
])
|
|
478
495
|
]);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/plugin-kit v1.6.
|
|
2
|
+
* @worm-print-platform/plugin-kit v1.6.1
|
|
3
3
|
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
4
|
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
6
|
*/
|
|
7
7
|
import { PrintBusinessField } from '@worm-print-platform/core/designer';
|
|
8
|
+
import { Translate } from '@worm-print-platform/core/i18n';
|
|
8
9
|
import { El } from './dom.cjs';
|
|
9
10
|
|
|
10
11
|
interface ExpressionEditorTarget {
|
|
@@ -27,6 +28,8 @@ interface ExpressionEditorOptions {
|
|
|
27
28
|
demoData?: Record<string, any>;
|
|
28
29
|
/** 字段行显示模式;缺省 / 非法值按 both(中文名 + key) */
|
|
29
30
|
fieldDisplay?: FieldDisplayMode;
|
|
31
|
+
/** 当前 locale 的翻译函数;缺省用全局 t */
|
|
32
|
+
t?: Translate;
|
|
30
33
|
/** 关闭弹窗 */
|
|
31
34
|
onClose: () => void;
|
|
32
35
|
/** 点确定:把最终表达式回写 */
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/plugin-kit v1.6.
|
|
2
|
+
* @worm-print-platform/plugin-kit v1.6.1
|
|
3
3
|
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
4
|
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
6
|
*/
|
|
7
7
|
import { PrintBusinessField } from '@worm-print-platform/core/designer';
|
|
8
|
+
import { Translate } from '@worm-print-platform/core/i18n';
|
|
8
9
|
import { El } from './dom.js';
|
|
9
10
|
|
|
10
11
|
interface ExpressionEditorTarget {
|
|
@@ -27,6 +28,8 @@ interface ExpressionEditorOptions {
|
|
|
27
28
|
demoData?: Record<string, any>;
|
|
28
29
|
/** 字段行显示模式;缺省 / 非法值按 both(中文名 + key) */
|
|
29
30
|
fieldDisplay?: FieldDisplayMode;
|
|
31
|
+
/** 当前 locale 的翻译函数;缺省用全局 t */
|
|
32
|
+
t?: Translate;
|
|
30
33
|
/** 关闭弹窗 */
|
|
31
34
|
onClose: () => void;
|
|
32
35
|
/** 点确定:把最终表达式回写 */
|
|
@@ -6,7 +6,9 @@ import {
|
|
|
6
6
|
|
|
7
7
|
// src/expression-editor.ts
|
|
8
8
|
import { DEFAULT_DEMO_DATA, copyTextToClipboard, evaluateTemplate, filterGroups, groupFields } from "@worm-print-platform/core/designer";
|
|
9
|
+
import { t as globalT } from "@worm-print-platform/core/i18n";
|
|
9
10
|
import { resolveSystemVariables } from "@worm-print-platform/core";
|
|
11
|
+
var tr = globalT;
|
|
10
12
|
var ICON_PATHS = {
|
|
11
13
|
Check: '<path d="M20 6 9 17l-5-5" />',
|
|
12
14
|
Copy: '<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />'
|
|
@@ -18,62 +20,76 @@ function normalizeFieldDisplay(v) {
|
|
|
18
20
|
const s = typeof v === "string" ? v.trim().toLowerCase() : "";
|
|
19
21
|
return s === "label" || s === "key" || s === "both" ? s : "both";
|
|
20
22
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
23
|
+
function getTabs() {
|
|
24
|
+
return [
|
|
25
|
+
{ key: "field", text: tr("expression.tabField") },
|
|
26
|
+
{ key: "variable", text: tr("expression.tabVariable") },
|
|
27
|
+
{ key: "function", text: tr("expression.tabFunction") }
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
function getPlaceholder() {
|
|
31
|
+
return {
|
|
32
|
+
field: tr("expression.placeholderField"),
|
|
33
|
+
variable: tr("expression.placeholderVariable"),
|
|
34
|
+
function: tr("expression.placeholderFunction")
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function getAggregateFunctions() {
|
|
38
|
+
return [
|
|
39
|
+
{ name: "SUM", label: tr("expression.fnSum"), template: "SUM()" },
|
|
40
|
+
{ name: "AVG", label: tr("expression.fnAvg"), template: "AVG()" },
|
|
41
|
+
{ name: "COUNT", label: tr("expression.fnCount"), template: "COUNT()" },
|
|
42
|
+
{ name: "MIN", label: tr("expression.fnMin"), template: "MIN()" },
|
|
43
|
+
{ name: "MAX", label: tr("expression.fnMax"), template: "MAX()" }
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
function getMathFunctions() {
|
|
47
|
+
return [
|
|
48
|
+
{ name: "ADD", label: tr("expression.fnAdd"), template: "ADD()" },
|
|
49
|
+
{ name: "SUB", label: tr("expression.fnSub"), template: "SUB()" },
|
|
50
|
+
{ name: "MUL", label: tr("expression.fnMul"), template: "MUL()" },
|
|
51
|
+
{ name: "DIV", label: tr("expression.fnDiv"), template: "DIV()" },
|
|
52
|
+
{ name: "ROUND", label: tr("expression.fnRound"), template: "ROUND()" },
|
|
53
|
+
{ name: "ROUNDUP", label: tr("expression.fnRoundUp"), template: "ROUNDUP()" },
|
|
54
|
+
{ name: "ROUNDDOWN", label: tr("expression.fnRoundDown"), template: "ROUNDDOWN()" },
|
|
55
|
+
{ name: "ROUNDBANK", label: tr("expression.fnRoundBank"), template: "ROUNDBANK()" }
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
function getFormatFunctions() {
|
|
59
|
+
return [
|
|
60
|
+
{ name: "MONEY", label: tr("expression.fnMoney"), template: "MONEY()" },
|
|
61
|
+
{ name: "DATE", label: tr("expression.fnDate"), template: "DATE()" },
|
|
62
|
+
{ name: "UPPER", label: tr("expression.fnUpper"), template: "UPPER()" },
|
|
63
|
+
{ name: "IF", label: tr("expression.fnIf"), template: "IF()" }
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
function getSystemVariables() {
|
|
67
|
+
return [
|
|
68
|
+
{ name: "pageIndex", label: tr("expression.varPageIndex"), template: "{pageIndex}" },
|
|
69
|
+
{ name: "totalPages", label: tr("expression.varTotalPages"), template: "{totalPages}" },
|
|
70
|
+
{ name: "printDate", label: tr("expression.varPrintDate"), template: "{printDate}" },
|
|
71
|
+
{ name: "printTime", label: tr("expression.varPrintTime"), template: "{printTime}" }
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
function getFuncGroups() {
|
|
75
|
+
return [
|
|
76
|
+
{ title: tr("expression.groupAggregate"), items: getAggregateFunctions() },
|
|
77
|
+
{ title: tr("expression.groupMath"), items: getMathFunctions() },
|
|
78
|
+
{ title: tr("expression.groupFormat"), items: getFormatFunctions() }
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
var EMPTY_PREVIEW_KEY = "expression.previewEmpty";
|
|
82
|
+
var NO_VALUE_PREVIEW_KEY = "expression.previewNoValue";
|
|
83
|
+
var ERROR_PREVIEW_KEY = "expression.previewError";
|
|
68
84
|
function previewText(expr, demoData) {
|
|
69
|
-
if (!expr.trim()) return
|
|
85
|
+
if (!expr.trim()) return tr(EMPTY_PREVIEW_KEY);
|
|
70
86
|
try {
|
|
71
87
|
const ctx = { ...DEFAULT_DEMO_DATA, ...demoData ?? {}, ...resolveSystemVariables() };
|
|
72
88
|
const result = evaluateTemplate(expr, ctx);
|
|
73
|
-
if (result === void 0 || result === null) return
|
|
89
|
+
if (result === void 0 || result === null) return tr(NO_VALUE_PREVIEW_KEY);
|
|
74
90
|
return String(result);
|
|
75
91
|
} catch {
|
|
76
|
-
return
|
|
92
|
+
return tr(ERROR_PREVIEW_KEY);
|
|
77
93
|
}
|
|
78
94
|
}
|
|
79
95
|
function matchKeyword(items, keyword) {
|
|
@@ -125,41 +141,42 @@ function helpCard(modifier, title, lines) {
|
|
|
125
141
|
}
|
|
126
142
|
function helpSection() {
|
|
127
143
|
return h("div", { class: "ee-help-section" }, [
|
|
128
|
-
h("div", { class: "ee-help-title", text: "
|
|
144
|
+
h("div", { class: "ee-help-title", text: tr("expression.k1") }),
|
|
129
145
|
h("div", { class: "ee-help-grid" }, [
|
|
130
|
-
helpCard("ee-help-field", "
|
|
131
|
-
"
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
"
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
"
|
|
146
|
+
helpCard("ee-help-field", tr("expression.k2"), [
|
|
147
|
+
tr("expression.k3"),
|
|
148
|
+
tr("expression.k4"),
|
|
149
|
+
tr("expression.k5"),
|
|
150
|
+
tr("expression.k6"),
|
|
151
|
+
tr("expression.k7"),
|
|
152
|
+
tr("expression.k8"),
|
|
153
|
+
tr("expression.k9")
|
|
138
154
|
]),
|
|
139
|
-
helpCard("ee-help-function", "
|
|
140
|
-
"
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
155
|
+
helpCard("ee-help-function", tr("expression.k10"), [
|
|
156
|
+
tr("expression.k11"),
|
|
157
|
+
tr("expression.k12"),
|
|
158
|
+
tr("expression.k13"),
|
|
159
|
+
tr("expression.k14"),
|
|
160
|
+
tr("expression.k15"),
|
|
161
|
+
tr("expression.k16")
|
|
146
162
|
]),
|
|
147
|
-
helpCard("ee-help-variable", "
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"
|
|
163
|
+
helpCard("ee-help-variable", tr("expression.k17"), [
|
|
164
|
+
tr("expression.k18"),
|
|
165
|
+
tr("expression.k19"),
|
|
166
|
+
tr("expression.k20")
|
|
151
167
|
]),
|
|
152
|
-
helpCard("ee-help-conditional", "
|
|
153
|
-
"
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
|
|
157
|
-
"
|
|
168
|
+
helpCard("ee-help-conditional", tr("expression.k21"), [
|
|
169
|
+
tr("expression.k22"),
|
|
170
|
+
tr("expression.k23"),
|
|
171
|
+
tr("expression.k24"),
|
|
172
|
+
tr("expression.k25"),
|
|
173
|
+
tr("expression.k26")
|
|
158
174
|
])
|
|
159
175
|
])
|
|
160
176
|
]);
|
|
161
177
|
}
|
|
162
178
|
function renderExpressionEditor(opts, target) {
|
|
179
|
+
tr = opts.t ?? globalT;
|
|
163
180
|
const fieldDisplay = normalizeFieldDisplay(opts.fieldDisplay);
|
|
164
181
|
const state = {
|
|
165
182
|
activeTab: "field",
|
|
@@ -178,7 +195,7 @@ function renderExpressionEditor(opts, target) {
|
|
|
178
195
|
if (!el) return;
|
|
179
196
|
const text = previewText(state.expression, opts.demoData);
|
|
180
197
|
el.textContent = text;
|
|
181
|
-
el.classList.toggle("ee-preview-error", text ===
|
|
198
|
+
el.classList.toggle("ee-preview-error", text === tr(ERROR_PREVIEW_KEY));
|
|
182
199
|
};
|
|
183
200
|
const updateKeyHint = (root) => {
|
|
184
201
|
const el = query(root, ".ee-key-hint");
|
|
@@ -188,7 +205,7 @@ function renderExpressionEditor(opts, target) {
|
|
|
188
205
|
};
|
|
189
206
|
const listItems = () => {
|
|
190
207
|
if (state.activeTab === "variable") {
|
|
191
|
-
return matchKeyword(
|
|
208
|
+
return matchKeyword(getSystemVariables(), state.searchText).map((sv) => h("div", {
|
|
192
209
|
class: "ee-list-item",
|
|
193
210
|
onDblclick: (ev) => {
|
|
194
211
|
const { insideParens } = region(ev);
|
|
@@ -197,7 +214,7 @@ function renderExpressionEditor(opts, target) {
|
|
|
197
214
|
}, [itemInfo(sv.label, sv.template)]));
|
|
198
215
|
}
|
|
199
216
|
if (state.activeTab === "function") {
|
|
200
|
-
return
|
|
217
|
+
return getFuncGroups().map((group) => h("div", { class: "ee-func-group" }, [
|
|
201
218
|
h("div", { class: "ee-func-group-title", text: group.title }),
|
|
202
219
|
...matchKeyword(group.items, state.searchText).map((fn) => h("div", {
|
|
203
220
|
class: "ee-list-item",
|
|
@@ -210,7 +227,7 @@ function renderExpressionEditor(opts, target) {
|
|
|
210
227
|
]));
|
|
211
228
|
}
|
|
212
229
|
const groups = filterGroups(groupFields(opts.fields ?? []), state.searchText);
|
|
213
|
-
if (!groups.length) return [h("p", { class: "pd-empty", text: "
|
|
230
|
+
if (!groups.length) return [h("p", { class: "pd-empty", text: tr("expression.k27") })];
|
|
214
231
|
const nodes = [];
|
|
215
232
|
for (const group of groups) {
|
|
216
233
|
if (group.key) {
|
|
@@ -245,7 +262,7 @@ function renderExpressionEditor(opts, target) {
|
|
|
245
262
|
type: "button",
|
|
246
263
|
class: `ee-copy-btn${state.copiedFieldKey === field.fieldKey ? " is-copied" : ""}`,
|
|
247
264
|
// 提示浮层由 print-designer 的 hover-tip 委托承担(容器白名单含 .pd-dialog-overlay)
|
|
248
|
-
"data-tip": state.copiedFieldKey === field.fieldKey ? "
|
|
265
|
+
"data-tip": state.copiedFieldKey === field.fieldKey ? tr("expression.k28") : `\u590D\u5236\u5B57\u6BB5\u540D\u300C${field.fieldLabel}\u300D`,
|
|
249
266
|
"aria-label": `\u590D\u5236\u5B57\u6BB5\u540D ${field.fieldLabel}`,
|
|
250
267
|
html: iconSvg(state.copiedFieldKey === field.fieldKey ? "Check" : "Copy", 13),
|
|
251
268
|
onClick: (ev) => {
|
|
@@ -261,10 +278,10 @@ function renderExpressionEditor(opts, target) {
|
|
|
261
278
|
};
|
|
262
279
|
const repaint = (root) => {
|
|
263
280
|
const tabs = Array.from(root.querySelectorAll(".ee-nav-tab"));
|
|
264
|
-
tabs.forEach((el, i) => el.classList.toggle("active",
|
|
281
|
+
tabs.forEach((el, i) => el.classList.toggle("active", getTabs()[i]?.key === state.activeTab));
|
|
265
282
|
const search = query(root, ".ee-content-search .pd-input");
|
|
266
283
|
if (search) {
|
|
267
|
-
const placeholder =
|
|
284
|
+
const placeholder = getPlaceholder()[state.activeTab];
|
|
268
285
|
if (search.placeholder !== placeholder) search.placeholder = placeholder;
|
|
269
286
|
if (search.value !== state.searchText) search.value = state.searchText;
|
|
270
287
|
}
|
|
@@ -327,12 +344,12 @@ function renderExpressionEditor(opts, target) {
|
|
|
327
344
|
opts.onClose();
|
|
328
345
|
};
|
|
329
346
|
const nav = h("div", { class: "ee-nav" }, [
|
|
330
|
-
h("div", { class: "ee-nav-title", text: "
|
|
331
|
-
h("div", { class: "ee-nav-tabs" },
|
|
347
|
+
h("div", { class: "ee-nav-title", text: tr("expression.k29") }),
|
|
348
|
+
h("div", { class: "ee-nav-tabs" }, getTabs().map((tab, i) => h("div", {
|
|
332
349
|
class: `ee-nav-tab${state.activeTab === tab.key ? " active" : ""}`,
|
|
333
350
|
text: tab.text,
|
|
334
351
|
onClick: (ev) => {
|
|
335
|
-
state.activeTab =
|
|
352
|
+
state.activeTab = getTabs()[i].key;
|
|
336
353
|
repaint(scope(ev));
|
|
337
354
|
}
|
|
338
355
|
})))
|
|
@@ -341,7 +358,7 @@ function renderExpressionEditor(opts, target) {
|
|
|
341
358
|
h("div", { class: "ee-content-search" }, [
|
|
342
359
|
h("input", {
|
|
343
360
|
class: "pd-input",
|
|
344
|
-
placeholder:
|
|
361
|
+
placeholder: getPlaceholder()[state.activeTab],
|
|
345
362
|
onInput: (ev) => {
|
|
346
363
|
state.searchText = ev.target.value;
|
|
347
364
|
repaint(scope(ev));
|
|
@@ -353,11 +370,11 @@ function renderExpressionEditor(opts, target) {
|
|
|
353
370
|
const initialPreview = previewText(state.expression, opts.demoData);
|
|
354
371
|
const editor = h("div", { class: "ee-editor" }, [
|
|
355
372
|
h("div", { class: "ee-editor-section" }, [
|
|
356
|
-
h("div", { class: "ee-editor-title", text: "
|
|
373
|
+
h("div", { class: "ee-editor-title", text: tr("expression.k30") }),
|
|
357
374
|
h("textarea", {
|
|
358
375
|
class: "ee-textarea",
|
|
359
376
|
rows: 6,
|
|
360
|
-
placeholder: "
|
|
377
|
+
placeholder: tr("expression.k31"),
|
|
361
378
|
text: state.expression,
|
|
362
379
|
onInput: (ev) => {
|
|
363
380
|
state.expression = ev.target.value;
|
|
@@ -373,9 +390,9 @@ function renderExpressionEditor(opts, target) {
|
|
|
373
390
|
})
|
|
374
391
|
]),
|
|
375
392
|
h("div", { class: "ee-editor-section" }, [
|
|
376
|
-
h("div", { class: "ee-editor-title", text: "
|
|
393
|
+
h("div", { class: "ee-editor-title", text: tr("expression.k32") }),
|
|
377
394
|
h("div", {
|
|
378
|
-
class: `ee-preview${initialPreview ===
|
|
395
|
+
class: `ee-preview${initialPreview === tr(ERROR_PREVIEW_KEY) ? " ee-preview-error" : ""}`,
|
|
379
396
|
text: initialPreview
|
|
380
397
|
})
|
|
381
398
|
]),
|
|
@@ -394,13 +411,13 @@ function renderExpressionEditor(opts, target) {
|
|
|
394
411
|
"aria-labelledby": "expression-editor-title"
|
|
395
412
|
}, [
|
|
396
413
|
h("header", { class: "pd-dialog-header" }, [
|
|
397
|
-
h("strong", { id: "expression-editor-title", text: "
|
|
398
|
-
h("button", { type: "button", class: "pd-close", "aria-label": "
|
|
414
|
+
h("strong", { id: "expression-editor-title", text: tr("expression.k33") }),
|
|
415
|
+
h("button", { type: "button", class: "pd-close", "aria-label": tr("expression.k34"), text: "\xD7", onClick: () => opts.onClose() })
|
|
399
416
|
]),
|
|
400
417
|
h("div", { class: "expression-editor" }, [nav, content, editor]),
|
|
401
418
|
h("footer", { class: "pd-dialog-footer" }, [
|
|
402
|
-
h("button", { type: "button", class: "pd-button", text: "
|
|
403
|
-
h("button", { type: "button", class: "pd-button primary", text: "
|
|
419
|
+
h("button", { type: "button", class: "pd-button", text: tr("expression.k35"), onClick: () => opts.onClose() }),
|
|
420
|
+
h("button", { type: "button", class: "pd-button primary", text: tr("expression.k36"), onClick: () => onConfirm() })
|
|
404
421
|
])
|
|
405
422
|
])
|
|
406
423
|
]);
|
package/dist/index.cjs
CHANGED
|
@@ -27,12 +27,14 @@ __export(src_exports, {
|
|
|
27
27
|
getElementUIEntries: () => getElementUIEntries,
|
|
28
28
|
getElementUITypes: () => getElementUITypes,
|
|
29
29
|
getElementUIs: () => getElementUIs,
|
|
30
|
+
getMissingKeys: () => import_i18n2.getMissingKeys,
|
|
30
31
|
registerElementUI: () => registerElementUI,
|
|
31
32
|
subscribeElementUIRegistry: () => subscribeElementUIRegistry
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(src_exports);
|
|
34
35
|
|
|
35
36
|
// src/registry.ts
|
|
37
|
+
var import_i18n = require("@worm-print-platform/core/i18n");
|
|
36
38
|
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("worm-print-platform.element-ui-registry.v1");
|
|
37
39
|
var host = globalThis;
|
|
38
40
|
function state() {
|
|
@@ -66,6 +68,22 @@ function assertElementUI(ui) {
|
|
|
66
68
|
if (ui.renderProperty !== void 0 && typeof ui.renderProperty !== "function") {
|
|
67
69
|
throw new Error(`registerElementUI: ${ui.types.join(",")} \u7684 renderProperty \u5FC5\u987B\u662F\u51FD\u6570`);
|
|
68
70
|
}
|
|
71
|
+
if (ui.locales !== void 0) {
|
|
72
|
+
if (typeof ui.locales !== "object" || ui.locales === null) {
|
|
73
|
+
throw new Error("registerElementUI: locales \u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
74
|
+
}
|
|
75
|
+
const prefix = `${ui.i18nId ?? ui.types[0]}.`;
|
|
76
|
+
for (const messages of Object.values(ui.locales)) {
|
|
77
|
+
if (typeof messages !== "object" || messages === null) {
|
|
78
|
+
throw new Error("registerElementUI: locales \u7684\u6BCF\u4E2A\u8BED\u8A00\u5305\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
79
|
+
}
|
|
80
|
+
for (const key of Object.keys(messages)) {
|
|
81
|
+
if (!key.startsWith(prefix)) {
|
|
82
|
+
throw new Error(`registerElementUI: \u8BED\u8A00\u5305\u952E\u5FC5\u987B\u4EE5 "${prefix}" \u5F00\u5934\uFF0C\u6536\u5230 "${key}"`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
69
87
|
}
|
|
70
88
|
function defineElementUI(ui) {
|
|
71
89
|
assertElementUI(ui);
|
|
@@ -75,9 +93,12 @@ function registerElementUI(ui) {
|
|
|
75
93
|
assertElementUI(ui);
|
|
76
94
|
const s = state();
|
|
77
95
|
const seq = s.nextSeq++;
|
|
78
|
-
|
|
96
|
+
const pluginId = ui.i18nId ?? ui.types[0];
|
|
97
|
+
const disposeLocales = ui.locales ? Object.entries(ui.locales).map(([locale, messages]) => (0, import_i18n.registerPluginMessages)(locale, pluginId, messages)) : [];
|
|
98
|
+
for (const type of ui.types) s.entries.set(type, { ui, seq, disposeLocales });
|
|
79
99
|
notify();
|
|
80
100
|
return () => {
|
|
101
|
+
for (const dispose of disposeLocales) dispose();
|
|
81
102
|
let removed = false;
|
|
82
103
|
for (const type of ui.types) {
|
|
83
104
|
const current = s.entries.get(type);
|
|
@@ -120,12 +141,23 @@ function subscribeElementUIRegistry(listener) {
|
|
|
120
141
|
function clearElementUIs() {
|
|
121
142
|
const s = state();
|
|
122
143
|
if (s.entries.size === 0 && s.listeners.size === 0) return;
|
|
144
|
+
const disposed = /* @__PURE__ */ new Set();
|
|
145
|
+
for (const entry of s.entries.values()) {
|
|
146
|
+
for (const dispose of entry.disposeLocales ?? []) {
|
|
147
|
+
if (disposed.has(dispose)) continue;
|
|
148
|
+
disposed.add(dispose);
|
|
149
|
+
dispose();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
123
152
|
s.entries.clear();
|
|
124
153
|
notify();
|
|
125
154
|
}
|
|
126
155
|
|
|
127
156
|
// src/toolbar-overflow-key.ts
|
|
128
157
|
var TOOLBAR_OVERFLOW_KEY = /* @__PURE__ */ Symbol.for("worm-print-platform.toolbar-overflow.v1");
|
|
158
|
+
|
|
159
|
+
// src/index.ts
|
|
160
|
+
var import_i18n2 = require("@worm-print-platform/core/i18n");
|
|
129
161
|
// Annotate the CommonJS export names for ESM import in node:
|
|
130
162
|
0 && (module.exports = {
|
|
131
163
|
TOOLBAR_OVERFLOW_KEY,
|
|
@@ -135,6 +167,7 @@ var TOOLBAR_OVERFLOW_KEY = /* @__PURE__ */ Symbol.for("worm-print-platform.toolb
|
|
|
135
167
|
getElementUIEntries,
|
|
136
168
|
getElementUITypes,
|
|
137
169
|
getElementUIs,
|
|
170
|
+
getMissingKeys,
|
|
138
171
|
registerElementUI,
|
|
139
172
|
subscribeElementUIRegistry
|
|
140
173
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/plugin-kit v1.6.
|
|
2
|
+
* @worm-print-platform/plugin-kit v1.6.1
|
|
3
3
|
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
4
|
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
6
|
*/
|
|
7
7
|
import { RuntimeElement, PrintBusinessField, ElementOptions } from '@worm-print-platform/core/designer';
|
|
8
|
+
import { Translate } from '@worm-print-platform/core/i18n';
|
|
9
|
+
export { Translate, getMissingKeys } from '@worm-print-platform/core/i18n';
|
|
8
10
|
|
|
9
11
|
/** 插件产出的可视内容:HTML 字符串或真实 DOM 节点 */
|
|
10
12
|
type ElementUINode = string | Node;
|
|
@@ -21,6 +23,8 @@ interface ElementUICanvasContext {
|
|
|
21
23
|
data?: readonly Record<string, unknown>[];
|
|
22
24
|
/** 设计态为 true;宿主未来做只读预览时可传 false */
|
|
23
25
|
designMode?: boolean;
|
|
26
|
+
/** 当前 locale 的翻译函数;缺省用全局 t */
|
|
27
|
+
t?: Translate;
|
|
24
28
|
}
|
|
25
29
|
/**
|
|
26
30
|
* 属性台「自定义属性」渲染上下文。
|
|
@@ -40,6 +44,8 @@ interface ElementUIPropertyContext {
|
|
|
40
44
|
update(partial: Partial<ElementOptions>): void;
|
|
41
45
|
/** 仅请求宿主重绘,不写数据、不记历史(面板内部态变化用) */
|
|
42
46
|
repaint(): void;
|
|
47
|
+
/** 当前 locale 的翻译函数;缺省用全局 t */
|
|
48
|
+
t?: Translate;
|
|
43
49
|
}
|
|
44
50
|
/**
|
|
45
51
|
* 一份插件设计器 UI,可覆盖同一插件的多个元素类型。
|
|
@@ -60,6 +66,10 @@ interface ElementUI {
|
|
|
60
66
|
readonly searchKeywords?: readonly string[];
|
|
61
67
|
/** 宿主注入到自身样式作用域:common 注入 Shadow DOM,canvas 注入 document.head */
|
|
62
68
|
readonly styles?: string;
|
|
69
|
+
/** 语言包键前缀(插件 id);缺省取 types[0] */
|
|
70
|
+
readonly i18nId?: string;
|
|
71
|
+
/** 按 locale 提供的语言包;注册时合并进 core 引擎的插件层 */
|
|
72
|
+
readonly locales?: Record<string, Record<string, string>>;
|
|
63
73
|
}
|
|
64
74
|
/** 类型→UI 的解析视图(供宿主遍历注册态) */
|
|
65
75
|
interface ElementUIEntry {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/plugin-kit v1.6.
|
|
2
|
+
* @worm-print-platform/plugin-kit v1.6.1
|
|
3
3
|
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
4
|
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
6
|
*/
|
|
7
7
|
import { RuntimeElement, PrintBusinessField, ElementOptions } from '@worm-print-platform/core/designer';
|
|
8
|
+
import { Translate } from '@worm-print-platform/core/i18n';
|
|
9
|
+
export { Translate, getMissingKeys } from '@worm-print-platform/core/i18n';
|
|
8
10
|
|
|
9
11
|
/** 插件产出的可视内容:HTML 字符串或真实 DOM 节点 */
|
|
10
12
|
type ElementUINode = string | Node;
|
|
@@ -21,6 +23,8 @@ interface ElementUICanvasContext {
|
|
|
21
23
|
data?: readonly Record<string, unknown>[];
|
|
22
24
|
/** 设计态为 true;宿主未来做只读预览时可传 false */
|
|
23
25
|
designMode?: boolean;
|
|
26
|
+
/** 当前 locale 的翻译函数;缺省用全局 t */
|
|
27
|
+
t?: Translate;
|
|
24
28
|
}
|
|
25
29
|
/**
|
|
26
30
|
* 属性台「自定义属性」渲染上下文。
|
|
@@ -40,6 +44,8 @@ interface ElementUIPropertyContext {
|
|
|
40
44
|
update(partial: Partial<ElementOptions>): void;
|
|
41
45
|
/** 仅请求宿主重绘,不写数据、不记历史(面板内部态变化用) */
|
|
42
46
|
repaint(): void;
|
|
47
|
+
/** 当前 locale 的翻译函数;缺省用全局 t */
|
|
48
|
+
t?: Translate;
|
|
43
49
|
}
|
|
44
50
|
/**
|
|
45
51
|
* 一份插件设计器 UI,可覆盖同一插件的多个元素类型。
|
|
@@ -60,6 +66,10 @@ interface ElementUI {
|
|
|
60
66
|
readonly searchKeywords?: readonly string[];
|
|
61
67
|
/** 宿主注入到自身样式作用域:common 注入 Shadow DOM,canvas 注入 document.head */
|
|
62
68
|
readonly styles?: string;
|
|
69
|
+
/** 语言包键前缀(插件 id);缺省取 types[0] */
|
|
70
|
+
readonly i18nId?: string;
|
|
71
|
+
/** 按 locale 提供的语言包;注册时合并进 core 引擎的插件层 */
|
|
72
|
+
readonly locales?: Record<string, Record<string, string>>;
|
|
63
73
|
}
|
|
64
74
|
/** 类型→UI 的解析视图(供宿主遍历注册态) */
|
|
65
75
|
interface ElementUIEntry {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/registry.ts
|
|
2
|
+
import { registerPluginMessages } from "@worm-print-platform/core/i18n";
|
|
2
3
|
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("worm-print-platform.element-ui-registry.v1");
|
|
3
4
|
var host = globalThis;
|
|
4
5
|
function state() {
|
|
@@ -32,6 +33,22 @@ function assertElementUI(ui) {
|
|
|
32
33
|
if (ui.renderProperty !== void 0 && typeof ui.renderProperty !== "function") {
|
|
33
34
|
throw new Error(`registerElementUI: ${ui.types.join(",")} \u7684 renderProperty \u5FC5\u987B\u662F\u51FD\u6570`);
|
|
34
35
|
}
|
|
36
|
+
if (ui.locales !== void 0) {
|
|
37
|
+
if (typeof ui.locales !== "object" || ui.locales === null) {
|
|
38
|
+
throw new Error("registerElementUI: locales \u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
39
|
+
}
|
|
40
|
+
const prefix = `${ui.i18nId ?? ui.types[0]}.`;
|
|
41
|
+
for (const messages of Object.values(ui.locales)) {
|
|
42
|
+
if (typeof messages !== "object" || messages === null) {
|
|
43
|
+
throw new Error("registerElementUI: locales \u7684\u6BCF\u4E2A\u8BED\u8A00\u5305\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
44
|
+
}
|
|
45
|
+
for (const key of Object.keys(messages)) {
|
|
46
|
+
if (!key.startsWith(prefix)) {
|
|
47
|
+
throw new Error(`registerElementUI: \u8BED\u8A00\u5305\u952E\u5FC5\u987B\u4EE5 "${prefix}" \u5F00\u5934\uFF0C\u6536\u5230 "${key}"`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
35
52
|
}
|
|
36
53
|
function defineElementUI(ui) {
|
|
37
54
|
assertElementUI(ui);
|
|
@@ -41,9 +58,12 @@ function registerElementUI(ui) {
|
|
|
41
58
|
assertElementUI(ui);
|
|
42
59
|
const s = state();
|
|
43
60
|
const seq = s.nextSeq++;
|
|
44
|
-
|
|
61
|
+
const pluginId = ui.i18nId ?? ui.types[0];
|
|
62
|
+
const disposeLocales = ui.locales ? Object.entries(ui.locales).map(([locale, messages]) => registerPluginMessages(locale, pluginId, messages)) : [];
|
|
63
|
+
for (const type of ui.types) s.entries.set(type, { ui, seq, disposeLocales });
|
|
45
64
|
notify();
|
|
46
65
|
return () => {
|
|
66
|
+
for (const dispose of disposeLocales) dispose();
|
|
47
67
|
let removed = false;
|
|
48
68
|
for (const type of ui.types) {
|
|
49
69
|
const current = s.entries.get(type);
|
|
@@ -86,12 +106,23 @@ function subscribeElementUIRegistry(listener) {
|
|
|
86
106
|
function clearElementUIs() {
|
|
87
107
|
const s = state();
|
|
88
108
|
if (s.entries.size === 0 && s.listeners.size === 0) return;
|
|
109
|
+
const disposed = /* @__PURE__ */ new Set();
|
|
110
|
+
for (const entry of s.entries.values()) {
|
|
111
|
+
for (const dispose of entry.disposeLocales ?? []) {
|
|
112
|
+
if (disposed.has(dispose)) continue;
|
|
113
|
+
disposed.add(dispose);
|
|
114
|
+
dispose();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
89
117
|
s.entries.clear();
|
|
90
118
|
notify();
|
|
91
119
|
}
|
|
92
120
|
|
|
93
121
|
// src/toolbar-overflow-key.ts
|
|
94
122
|
var TOOLBAR_OVERFLOW_KEY = /* @__PURE__ */ Symbol.for("worm-print-platform.toolbar-overflow.v1");
|
|
123
|
+
|
|
124
|
+
// src/index.ts
|
|
125
|
+
import { getMissingKeys } from "@worm-print-platform/core/i18n";
|
|
95
126
|
export {
|
|
96
127
|
TOOLBAR_OVERFLOW_KEY,
|
|
97
128
|
clearElementUIs,
|
|
@@ -100,6 +131,7 @@ export {
|
|
|
100
131
|
getElementUIEntries,
|
|
101
132
|
getElementUITypes,
|
|
102
133
|
getElementUIs,
|
|
134
|
+
getMissingKeys,
|
|
103
135
|
registerElementUI,
|
|
104
136
|
subscribeElementUIRegistry
|
|
105
137
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@worm-print-platform/plugin-kit",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "打印模板自定义元素的框架无关设计器 UI 契约与注册表:插件写一份 DOM 渲染能力,canvas(原生)与 /vue3(门面)同时消费",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"test:watch": "vitest"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@worm-print-platform/core": "^1.6.
|
|
54
|
+
"@worm-print-platform/core": "^1.6.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"happy-dom": "^20.10.6",
|