@hankchen/canvas-editor-react 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +157 -2
- package/dist/DropdownMenu-CCvv55NI.js +967 -0
- package/dist/PanelIcon-cQ-hx-Ky.js +87 -0
- package/dist/Tooltip-BAFJN0xP.js +815 -0
- package/dist/canvas/AlignFloatBar.d.ts +6 -0
- package/dist/canvas/CanvasSurface.d.ts +13 -0
- package/dist/canvas/ContextMenu.d.ts +14 -0
- package/dist/canvas/EditOverlayToolbar.d.ts +30 -0
- package/dist/canvas/FindBar.d.ts +13 -0
- package/dist/canvas/GuidesOverlay.d.ts +19 -0
- package/dist/canvas/Ruler.d.ts +32 -0
- package/dist/canvas/TextEditingOverlay.d.ts +22 -0
- package/dist/canvas/createBand.d.ts +6 -0
- package/dist/canvas/findHighlight.d.ts +12 -0
- package/dist/canvas/gizmo.d.ts +24 -0
- package/dist/canvas/guideSnap.d.ts +5 -0
- package/dist/canvas/index.d.ts +24 -0
- package/dist/canvas/resizeHandles.d.ts +3 -0
- package/dist/canvas/scheduler.d.ts +2 -0
- package/dist/canvas/useDpr.d.ts +9 -0
- package/dist/canvas/useFindSession.d.ts +12 -0
- package/dist/canvas/useTextEditing.d.ts +90 -0
- package/dist/canvas-jJ7OaUvZ.js +2171 -0
- package/dist/canvas.js +2 -0
- package/dist/chevron-down-D0_YGxvV.js +359 -0
- package/dist/createLucideIcon-CLd1sc0f.js +140 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +16 -0
- package/dist/layer-panel/LayerPanel.d.ts +6 -0
- package/dist/layer-panel/TemplateTableForm.d.ts +10 -0
- package/dist/layer-panel/addMenu.d.ts +68 -0
- package/dist/layer-panel/index.d.ts +11 -0
- package/dist/layer-panel/useLayerPanel.d.ts +12 -0
- package/dist/layer-panel-DIfOb40N.js +779 -0
- package/dist/layer-panel.js +2 -0
- package/dist/mergeKey--xr8gdWl.js +694 -0
- package/dist/property-panel/PropertyField.d.ts +39 -0
- package/dist/property-panel/PropertyPanel.d.ts +5 -0
- package/dist/property-panel/controlStyles.d.ts +17 -0
- package/dist/property-panel/controls.d.ts +42 -0
- package/dist/property-panel/fieldSchema.d.ts +142 -0
- package/dist/property-panel/fields/AlignField.d.ts +3 -0
- package/dist/property-panel/fields/AnchorDisclosureField.d.ts +3 -0
- package/dist/property-panel/fields/BooleanField.d.ts +3 -0
- package/dist/property-panel/fields/BorderField.d.ts +3 -0
- package/dist/property-panel/fields/BorderWidthInput.d.ts +9 -0
- package/dist/property-panel/fields/ColorField.d.ts +3 -0
- package/dist/property-panel/fields/FontField.d.ts +3 -0
- package/dist/property-panel/fields/ImageSrcField.d.ts +3 -0
- package/dist/property-panel/fields/NumberField.d.ts +3 -0
- package/dist/property-panel/fields/PaddingField.d.ts +3 -0
- package/dist/property-panel/fields/PairField.d.ts +3 -0
- package/dist/property-panel/fields/ResourceValueField.d.ts +3 -0
- package/dist/property-panel/fields/RowsPathField.d.ts +3 -0
- package/dist/property-panel/fields/SelectField.d.ts +3 -0
- package/dist/property-panel/fields/ShorthandModeButton.d.ts +7 -0
- package/dist/property-panel/fields/TextField.d.ts +3 -0
- package/dist/property-panel/fields/TextareaField.d.ts +3 -0
- package/dist/property-panel/fields/ValueTypeSegmented.d.ts +8 -0
- package/dist/property-panel/fields/index.d.ts +18 -0
- package/dist/property-panel/fields/intrinsicSize.d.ts +9 -0
- package/dist/property-panel/imageUpload.d.ts +11 -0
- package/dist/property-panel/index.d.ts +14 -0
- package/dist/property-panel/shorthand.d.ts +28 -0
- package/dist/property-panel/usePropertyPanel.d.ts +67 -0
- package/dist/property-panel/useShorthandMode.d.ts +17 -0
- package/dist/property-panel-DD45Myee.js +1861 -0
- package/dist/property-panel.js +3 -0
- package/dist/resourceTemplate-B4QRWGq7.js +33 -0
- package/dist/shared/DropdownMenu.d.ts +18 -0
- package/dist/shared/ExpressionCompletionPopup.d.ts +11 -0
- package/dist/shared/ExpressionPathPicker.d.ts +23 -0
- package/dist/shared/HelpDialog.d.ts +10 -0
- package/dist/shared/PanelIcon.d.ts +11 -0
- package/dist/shared/Tooltip.d.ts +11 -0
- package/dist/shared/completion.d.ts +73 -0
- package/dist/shared/completionAnchor.d.ts +28 -0
- package/dist/shared/editableTarget.d.ts +14 -0
- package/dist/shared/expressionContext.d.ts +22 -0
- package/dist/shared/fontPicker.d.ts +13 -0
- package/dist/shared/index.d.ts +42 -0
- package/dist/shared/mergeKey.d.ts +2 -0
- package/dist/shared/pathPickerModel.d.ts +24 -0
- package/dist/shared/popupPosition.d.ts +41 -0
- package/dist/shared/resourceTemplate.d.ts +7 -0
- package/dist/shared/rowsPathPickerSource.d.ts +15 -0
- package/dist/shared/shortcutsHelp.d.ts +30 -0
- package/dist/shared/uploadFile.d.ts +2 -0
- package/dist/shared/useCnTheme.d.ts +11 -0
- package/dist/shared/useDataSourceSchema.d.ts +10 -0
- package/dist/shared/useDoc.d.ts +2 -0
- package/dist/shared/useDocumentExchange.d.ts +21 -0
- package/dist/shared/useDropdownMenu.d.ts +163 -0
- package/dist/shared/useExpressionCompletion.d.ts +35 -0
- package/dist/shared/useExpressionDiagnostics.d.ts +29 -0
- package/dist/shared/useHistory.d.ts +6 -0
- package/dist/shared/useSelection.d.ts +2 -0
- package/dist/shared/useShortcuts.d.ts +2 -0
- package/dist/shared/useShortcutsHelp.d.ts +8 -0
- package/dist/shared/useTransientFeedback.d.ts +9 -0
- package/dist/shared/useViewport.d.ts +2 -0
- package/dist/shared-QI04Xk-a.js +236 -0
- package/dist/shared.js +9 -0
- package/dist/status-bar/StatusBar.d.ts +14 -0
- package/dist/status-bar/index.d.ts +9 -0
- package/dist/status-bar/layerGeometryLabel.d.ts +13 -0
- package/dist/status-bar/layerPathLabel.d.ts +2 -0
- package/dist/status-bar-Bt3TonDm.js +181 -0
- package/dist/status-bar.js +2 -0
- package/dist/style.css +2 -0
- package/dist/theme.css +420 -0
- package/dist/useDoc-B2LXNJV7.js +32 -0
- package/dist/useViewport-DXtOHYgJ.js +18 -0
- package/package.json +83 -3
|
@@ -0,0 +1,1861 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./chevron-down-D0_YGxvV.js";
|
|
2
|
+
import { a as f, i as p, o as m, t as h } from "./PanelIcon-cQ-hx-Ky.js";
|
|
3
|
+
import { c as g, l as _, n as v, s as y, t as b } from "./Tooltip-BAFJN0xP.js";
|
|
4
|
+
import { n as x, r as S, t as C } from "./resourceTemplate-B4QRWGq7.js";
|
|
5
|
+
import { a as w, c as ee, d as T, f as E, h as te, i as ne, m as D, o as re, p as ie, r as O, t as k } from "./mergeKey--xr8gdWl.js";
|
|
6
|
+
import { t as A } from "./createLucideIcon-CLd1sc0f.js";
|
|
7
|
+
import { createContext as j, useCallback as M, useContext as N, useEffect as P, useMemo as F, useRef as I, useState as L, useSyncExternalStore as ae } from "react";
|
|
8
|
+
import { Fragment as R, jsx as z, jsxs as B } from "react/jsx-runtime";
|
|
9
|
+
//#region ../canvas-editor/src/shared/resourceStatus.ts
|
|
10
|
+
function oe(e, t) {
|
|
11
|
+
if (e.type !== "ImageLayer") return !1;
|
|
12
|
+
if (e.expression !== null || e.src === null || r(e) <= 0 || n(e) <= 0) return !0;
|
|
13
|
+
if (t !== void 0) {
|
|
14
|
+
let n = t[e.src];
|
|
15
|
+
if (n !== void 0 && n !== "done") return !0;
|
|
16
|
+
}
|
|
17
|
+
return !1;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.84.0_@types+react@19.3.3_react@19.3.1/node_modules/lucide-react/dist/esm/icons/grid-2x2.mjs
|
|
21
|
+
var se = {
|
|
22
|
+
name: "grid-2x2",
|
|
23
|
+
size: 24,
|
|
24
|
+
node: [
|
|
25
|
+
["path", {
|
|
26
|
+
d: "M12 3v18",
|
|
27
|
+
key: "108xh3"
|
|
28
|
+
}],
|
|
29
|
+
["path", {
|
|
30
|
+
d: "M3 12h18",
|
|
31
|
+
key: "1i2n21"
|
|
32
|
+
}],
|
|
33
|
+
["rect", {
|
|
34
|
+
x: "3",
|
|
35
|
+
y: "3",
|
|
36
|
+
width: "18",
|
|
37
|
+
height: "18",
|
|
38
|
+
rx: "2",
|
|
39
|
+
key: "h1oib"
|
|
40
|
+
}]
|
|
41
|
+
],
|
|
42
|
+
aliases: ["grid-2-x-2"]
|
|
43
|
+
};
|
|
44
|
+
se.node;
|
|
45
|
+
var ce = A(se), le = {
|
|
46
|
+
name: "square-split-vertical",
|
|
47
|
+
size: 24,
|
|
48
|
+
node: [
|
|
49
|
+
["path", {
|
|
50
|
+
d: "M2 12h20",
|
|
51
|
+
key: "9i4pu4"
|
|
52
|
+
}],
|
|
53
|
+
["path", {
|
|
54
|
+
d: "M21 16v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-3",
|
|
55
|
+
key: "14rx03"
|
|
56
|
+
}],
|
|
57
|
+
["path", {
|
|
58
|
+
d: "M3 8V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v3",
|
|
59
|
+
key: "1haecz"
|
|
60
|
+
}]
|
|
61
|
+
],
|
|
62
|
+
aliases: ["split-square-vertical"]
|
|
63
|
+
};
|
|
64
|
+
le.node;
|
|
65
|
+
var ue = A(le), de = {
|
|
66
|
+
name: "square",
|
|
67
|
+
size: 24,
|
|
68
|
+
node: [["rect", {
|
|
69
|
+
width: "18",
|
|
70
|
+
height: "18",
|
|
71
|
+
x: "3",
|
|
72
|
+
y: "3",
|
|
73
|
+
rx: "2",
|
|
74
|
+
key: "afitv7"
|
|
75
|
+
}]]
|
|
76
|
+
};
|
|
77
|
+
de.node;
|
|
78
|
+
var fe = A(de), pe = "当前层内容未绘制,padding 不影响预览", V = {
|
|
79
|
+
title: "位置与尺寸",
|
|
80
|
+
fields: [
|
|
81
|
+
{
|
|
82
|
+
key: ["position"],
|
|
83
|
+
label: "位置",
|
|
84
|
+
control: "pair",
|
|
85
|
+
items: [{
|
|
86
|
+
key: ["x"],
|
|
87
|
+
label: "X",
|
|
88
|
+
control: "number",
|
|
89
|
+
integer: !0
|
|
90
|
+
}, {
|
|
91
|
+
key: ["y"],
|
|
92
|
+
label: "Y",
|
|
93
|
+
control: "number",
|
|
94
|
+
integer: !0
|
|
95
|
+
}]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
key: ["shape"],
|
|
99
|
+
label: "尺寸",
|
|
100
|
+
control: "pair",
|
|
101
|
+
items: [{
|
|
102
|
+
key: ["width"],
|
|
103
|
+
label: "宽",
|
|
104
|
+
control: "number",
|
|
105
|
+
integer: !0,
|
|
106
|
+
min: 0,
|
|
107
|
+
auto: {
|
|
108
|
+
key: ["autoWidth"],
|
|
109
|
+
placeholder: "自动"
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
key: ["height"],
|
|
113
|
+
label: "高",
|
|
114
|
+
control: "number",
|
|
115
|
+
integer: !0,
|
|
116
|
+
min: 0,
|
|
117
|
+
auto: { key: ["autoHeight"] }
|
|
118
|
+
}]
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
key: ["angle"],
|
|
122
|
+
label: "旋转角",
|
|
123
|
+
control: "number",
|
|
124
|
+
integer: !0,
|
|
125
|
+
visibleWhen: (e) => e.type === "TextLayer"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
key: ["position", "anchor"],
|
|
129
|
+
label: "锚点",
|
|
130
|
+
control: "anchor"
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
}, H = {
|
|
134
|
+
title: "对齐",
|
|
135
|
+
fields: [{
|
|
136
|
+
key: ["align", "horizontal"],
|
|
137
|
+
label: "水平",
|
|
138
|
+
control: "align",
|
|
139
|
+
domain: a
|
|
140
|
+
}, {
|
|
141
|
+
key: ["align", "vertical"],
|
|
142
|
+
label: "垂直",
|
|
143
|
+
control: "align",
|
|
144
|
+
domain: d
|
|
145
|
+
}]
|
|
146
|
+
}, U = {
|
|
147
|
+
title: "形状",
|
|
148
|
+
fields: [
|
|
149
|
+
{
|
|
150
|
+
key: ["shape", "backgroundColor"],
|
|
151
|
+
label: "背景色",
|
|
152
|
+
control: "color",
|
|
153
|
+
nullable: !0
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
key: ["shape", "lineHeight"],
|
|
157
|
+
label: "行高倍数",
|
|
158
|
+
control: "number",
|
|
159
|
+
step: .1,
|
|
160
|
+
min: 0,
|
|
161
|
+
visibleWhen: (e) => e.type === "TextLayer"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
key: ["shape", "padding"],
|
|
165
|
+
label: "内边距",
|
|
166
|
+
control: "padding",
|
|
167
|
+
title: "内边距作用于内容盒,不改变图层尺寸",
|
|
168
|
+
hint: (e, t) => oe(e, t) ? pe : null
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
key: ["shape", "border"],
|
|
172
|
+
label: "边框",
|
|
173
|
+
control: "border"
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
}, me = {
|
|
177
|
+
title: "文本",
|
|
178
|
+
fields: [
|
|
179
|
+
{
|
|
180
|
+
key: ["text"],
|
|
181
|
+
label: "内容",
|
|
182
|
+
control: "textarea",
|
|
183
|
+
data: !0
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
key: ["font"],
|
|
187
|
+
label: "字体",
|
|
188
|
+
control: "font"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
key: ["fontSize"],
|
|
192
|
+
label: "字号",
|
|
193
|
+
control: "number",
|
|
194
|
+
integer: !0,
|
|
195
|
+
min: 1
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
key: ["fontColor"],
|
|
199
|
+
label: "字色",
|
|
200
|
+
control: "color"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
key: ["autowrap"],
|
|
204
|
+
label: "自动换行",
|
|
205
|
+
control: "boolean"
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
}, he = "cover", ge = "contain", _e = "fill", ve = "tile", ye = "rect", be = "circle", xe = {
|
|
209
|
+
ImageLayer: [
|
|
210
|
+
V,
|
|
211
|
+
H,
|
|
212
|
+
U,
|
|
213
|
+
{
|
|
214
|
+
title: "图片",
|
|
215
|
+
fields: [
|
|
216
|
+
{
|
|
217
|
+
key: ["src"],
|
|
218
|
+
label: "资源地址",
|
|
219
|
+
control: "imageSrc",
|
|
220
|
+
data: !0,
|
|
221
|
+
resource: !0
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
key: ["fit"],
|
|
225
|
+
label: "适配",
|
|
226
|
+
control: "select",
|
|
227
|
+
domain: [
|
|
228
|
+
he,
|
|
229
|
+
ge,
|
|
230
|
+
_e,
|
|
231
|
+
ve
|
|
232
|
+
],
|
|
233
|
+
optionLabels: {
|
|
234
|
+
[he]: "铺满裁切",
|
|
235
|
+
[ge]: "完整显示",
|
|
236
|
+
[_e]: "拉伸铺满",
|
|
237
|
+
[ve]: "平铺"
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
key: ["clip"],
|
|
242
|
+
label: "裁剪形状",
|
|
243
|
+
control: "select",
|
|
244
|
+
domain: [ye, be],
|
|
245
|
+
optionLabels: {
|
|
246
|
+
[ye]: "矩形",
|
|
247
|
+
[be]: "圆形"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
],
|
|
253
|
+
TextLayer: [
|
|
254
|
+
V,
|
|
255
|
+
H,
|
|
256
|
+
U,
|
|
257
|
+
me
|
|
258
|
+
],
|
|
259
|
+
QrCodeLayer: [
|
|
260
|
+
V,
|
|
261
|
+
H,
|
|
262
|
+
U,
|
|
263
|
+
{
|
|
264
|
+
title: "二维码",
|
|
265
|
+
fields: [{
|
|
266
|
+
key: ["value"],
|
|
267
|
+
label: "内容",
|
|
268
|
+
control: "resourceValue",
|
|
269
|
+
data: !0,
|
|
270
|
+
resource: !0
|
|
271
|
+
}]
|
|
272
|
+
}
|
|
273
|
+
],
|
|
274
|
+
TableLayer: [
|
|
275
|
+
V,
|
|
276
|
+
H,
|
|
277
|
+
U,
|
|
278
|
+
{
|
|
279
|
+
title: "数据",
|
|
280
|
+
fields: [{
|
|
281
|
+
key: ["rowsPath"],
|
|
282
|
+
label: "取行路径",
|
|
283
|
+
control: "rowsPath",
|
|
284
|
+
visibleWhen: (e) => e.type === "TableLayer" && e.template !== null
|
|
285
|
+
}]
|
|
286
|
+
}
|
|
287
|
+
],
|
|
288
|
+
TableRowLayer: [
|
|
289
|
+
V,
|
|
290
|
+
H,
|
|
291
|
+
U
|
|
292
|
+
],
|
|
293
|
+
TableCellLayer: [
|
|
294
|
+
V,
|
|
295
|
+
H,
|
|
296
|
+
U
|
|
297
|
+
],
|
|
298
|
+
TableRowTemplate: [{
|
|
299
|
+
title: "行模板(行宽由表宽同步)",
|
|
300
|
+
fields: [{
|
|
301
|
+
key: ["shape", "height"],
|
|
302
|
+
label: "高",
|
|
303
|
+
control: "number",
|
|
304
|
+
integer: !0,
|
|
305
|
+
min: 0
|
|
306
|
+
}, {
|
|
307
|
+
key: ["shape", "autoHeight"],
|
|
308
|
+
label: "高自适应",
|
|
309
|
+
control: "boolean"
|
|
310
|
+
}]
|
|
311
|
+
}]
|
|
312
|
+
};
|
|
313
|
+
function Se(e) {
|
|
314
|
+
return xe[e] ?? [];
|
|
315
|
+
}
|
|
316
|
+
function Ce(e) {
|
|
317
|
+
if (e[e.length - 1] === "content") return p(e) ? "templateContent" : "content";
|
|
318
|
+
let t = e[e.length - 2];
|
|
319
|
+
return t === "rows" ? "row" : t === "cells" ? "cell" : "root";
|
|
320
|
+
}
|
|
321
|
+
var we = {
|
|
322
|
+
root: [],
|
|
323
|
+
cell: [],
|
|
324
|
+
row: ["shape.width", "shape.autoWidth"],
|
|
325
|
+
content: [
|
|
326
|
+
"shape.width",
|
|
327
|
+
"shape.autoWidth",
|
|
328
|
+
"shape.height",
|
|
329
|
+
"shape.autoHeight"
|
|
330
|
+
],
|
|
331
|
+
templateContent: ["shape.width", "shape.autoWidth"]
|
|
332
|
+
};
|
|
333
|
+
function W(e, t) {
|
|
334
|
+
return [...e.key, ...t.key];
|
|
335
|
+
}
|
|
336
|
+
function Te(e, t) {
|
|
337
|
+
let n = new Set(we[Ce(e)]), r = [];
|
|
338
|
+
for (let e of Se(t.type)) {
|
|
339
|
+
let i = [];
|
|
340
|
+
for (let r of e.fields) {
|
|
341
|
+
if (r.items) {
|
|
342
|
+
let e = r.items.filter((e) => !n.has(W(r, e).join(".")) && (!e.visibleWhen || e.visibleWhen(t)));
|
|
343
|
+
e.length > 0 && i.push({
|
|
344
|
+
...r,
|
|
345
|
+
items: e
|
|
346
|
+
});
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
n.has(r.key.join(".")) || (!r.visibleWhen || r.visibleWhen(t)) && i.push(r);
|
|
350
|
+
}
|
|
351
|
+
i.length > 0 && r.push({
|
|
352
|
+
title: e.title,
|
|
353
|
+
fields: i
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
return r;
|
|
357
|
+
}
|
|
358
|
+
var Ee = [{
|
|
359
|
+
title: "画布",
|
|
360
|
+
fields: [{
|
|
361
|
+
key: ["width"],
|
|
362
|
+
label: "宽",
|
|
363
|
+
control: "number",
|
|
364
|
+
integer: !0,
|
|
365
|
+
min: 1
|
|
366
|
+
}, {
|
|
367
|
+
key: ["height"],
|
|
368
|
+
label: "高",
|
|
369
|
+
control: "number",
|
|
370
|
+
integer: !0,
|
|
371
|
+
min: 1
|
|
372
|
+
}]
|
|
373
|
+
}, {
|
|
374
|
+
title: "背景",
|
|
375
|
+
fields: [{
|
|
376
|
+
key: ["background", "color"],
|
|
377
|
+
label: "背景色",
|
|
378
|
+
control: "color",
|
|
379
|
+
nullable: !0
|
|
380
|
+
}, {
|
|
381
|
+
key: ["background", "image"],
|
|
382
|
+
label: "背景图",
|
|
383
|
+
control: "imageSrc"
|
|
384
|
+
}]
|
|
385
|
+
}];
|
|
386
|
+
function De(e) {
|
|
387
|
+
return e === null ? null : e.background === null ? {
|
|
388
|
+
...e,
|
|
389
|
+
background: Oe
|
|
390
|
+
} : e;
|
|
391
|
+
}
|
|
392
|
+
var Oe = {
|
|
393
|
+
color: null,
|
|
394
|
+
image: null
|
|
395
|
+
};
|
|
396
|
+
function ke(e) {
|
|
397
|
+
return e.type === "ImageLayer" && (e.fit === void 0 || e.clip === void 0) ? {
|
|
398
|
+
...e,
|
|
399
|
+
...e.fit === void 0 ? { fit: "cover" } : {},
|
|
400
|
+
...e.clip === void 0 ? { clip: "rect" } : {}
|
|
401
|
+
} : e;
|
|
402
|
+
}
|
|
403
|
+
function G(e, t) {
|
|
404
|
+
let n = e;
|
|
405
|
+
for (let e = 0; e < t.length; e += 1) {
|
|
406
|
+
if (typeof n != "object" || !n) return { ok: !1 };
|
|
407
|
+
n = n[t[e]];
|
|
408
|
+
}
|
|
409
|
+
return n === void 0 ? { ok: !1 } : {
|
|
410
|
+
ok: !0,
|
|
411
|
+
value: n
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region src/property-panel/fields/AlignField.tsx
|
|
416
|
+
var Ae = {
|
|
417
|
+
[a.join(".")]: {
|
|
418
|
+
left: {
|
|
419
|
+
icon: o,
|
|
420
|
+
title: "左对齐"
|
|
421
|
+
},
|
|
422
|
+
center: {
|
|
423
|
+
icon: s,
|
|
424
|
+
title: "居中对齐"
|
|
425
|
+
},
|
|
426
|
+
right: {
|
|
427
|
+
icon: i,
|
|
428
|
+
title: "右对齐"
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
[d.join(".")]: {
|
|
432
|
+
top: {
|
|
433
|
+
icon: c,
|
|
434
|
+
title: "顶对齐"
|
|
435
|
+
},
|
|
436
|
+
center: {
|
|
437
|
+
icon: l,
|
|
438
|
+
title: "居中对齐"
|
|
439
|
+
},
|
|
440
|
+
bottom: {
|
|
441
|
+
icon: e,
|
|
442
|
+
title: "底对齐"
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
function je({ field: e, modelValue: t, className: n, onChange: r }) {
|
|
447
|
+
let i = typeof t == "string" ? t : "", a = e.domain ?? [], o = Ae[a.join(".")], s = a.map((t) => ({
|
|
448
|
+
value: t,
|
|
449
|
+
icon: o?.[t]?.icon,
|
|
450
|
+
title: o?.[t] === void 0 ? `${e.label}:${t}` : `${e.label}:${o[t].title}`
|
|
451
|
+
}));
|
|
452
|
+
function c(e) {
|
|
453
|
+
e !== i && r(e);
|
|
454
|
+
}
|
|
455
|
+
return /* @__PURE__ */ z("span", {
|
|
456
|
+
className: `cn-align flex h-7 min-w-0 flex-1 overflow-hidden rounded-md border border-cn-field-line bg-cn-field${n === void 0 ? "" : ` ${n}`}`,
|
|
457
|
+
role: "group",
|
|
458
|
+
"aria-label": e.label,
|
|
459
|
+
children: s.map((e, t) => /* @__PURE__ */ z(b, {
|
|
460
|
+
label: e.title,
|
|
461
|
+
className: "min-w-0 flex-1",
|
|
462
|
+
children: /* @__PURE__ */ z("button", {
|
|
463
|
+
type: "button",
|
|
464
|
+
className: `cn-align__option flex min-w-0 flex-1 items-center justify-center p-0 transition-colors duration-100 focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cn-accent/40 ${t > 0 ? "border-l border-cn-field-line" : ""} ${e.value === i ? "cn-align__option--active bg-cn-accent-soft text-cn-accent" : "text-cn-muted hover:text-cn-fg"}`,
|
|
465
|
+
"aria-pressed": e.value === i,
|
|
466
|
+
onClick: (t) => {
|
|
467
|
+
t.preventDefault(), c(e.value);
|
|
468
|
+
},
|
|
469
|
+
children: e.icon === void 0 ? /* @__PURE__ */ z("span", {
|
|
470
|
+
className: "truncate px-1 text-[10px] leading-none",
|
|
471
|
+
children: e.value
|
|
472
|
+
}) : /* @__PURE__ */ z(h, { icon: e.icon })
|
|
473
|
+
})
|
|
474
|
+
}, e.value))
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region src/property-panel/fields/AnchorDisclosureField.tsx
|
|
479
|
+
var Me = Array.from({ length: 9 }, (e, t) => ({
|
|
480
|
+
index: t,
|
|
481
|
+
cx: 4 + t % 3 * 8,
|
|
482
|
+
cy: 4 + Math.floor(t / 3) * 8
|
|
483
|
+
}));
|
|
484
|
+
function Ne({ field: e, modelValue: n, className: r, expanded: i, onToggle: a, onChange: o }) {
|
|
485
|
+
let s = n, c = (() => {
|
|
486
|
+
let e = s.includes("top") ? 0 : s.includes("bottom") ? 2 : 1, t = s.includes("left") ? 0 : s.includes("right") ? 2 : 1;
|
|
487
|
+
return e * 3 + t;
|
|
488
|
+
})();
|
|
489
|
+
return /* @__PURE__ */ B("span", {
|
|
490
|
+
className: `block${r === void 0 ? "" : ` ${r}`}`,
|
|
491
|
+
children: [/* @__PURE__ */ B("button", {
|
|
492
|
+
type: "button",
|
|
493
|
+
className: "cn-anchor-disclosure__header flex w-full items-center justify-between gap-2",
|
|
494
|
+
"aria-expanded": i === !0,
|
|
495
|
+
title: i === !0 ? "收起锚点" : `锚点:${s}(点击展开调整)`,
|
|
496
|
+
onClick: a,
|
|
497
|
+
children: [/* @__PURE__ */ z("span", {
|
|
498
|
+
className: "cn-prop-field__label shrink-0 select-none truncate text-[11px] leading-none text-cn-muted",
|
|
499
|
+
children: e.label
|
|
500
|
+
}), /* @__PURE__ */ B("span", {
|
|
501
|
+
className: "flex shrink-0 items-center gap-1.5",
|
|
502
|
+
children: [/* @__PURE__ */ z("svg", {
|
|
503
|
+
viewBox: "0 0 24 24",
|
|
504
|
+
className: "size-3.5",
|
|
505
|
+
"aria-hidden": "true",
|
|
506
|
+
children: Me.map((e) => /* @__PURE__ */ z("circle", {
|
|
507
|
+
cx: e.cx,
|
|
508
|
+
cy: e.cy,
|
|
509
|
+
r: e.index === c ? 3.2 : 2.2,
|
|
510
|
+
className: e.index === c ? "fill-cn-accent" : "fill-cn-muted/35"
|
|
511
|
+
}, e.index))
|
|
512
|
+
}), /* @__PURE__ */ z(h, {
|
|
513
|
+
icon: u,
|
|
514
|
+
className: `text-cn-muted transition-transform duration-150${i === !0 ? " rotate-180" : ""}`
|
|
515
|
+
})]
|
|
516
|
+
})]
|
|
517
|
+
}), i === !0 && /* @__PURE__ */ z("span", {
|
|
518
|
+
className: "mt-2 flex justify-end",
|
|
519
|
+
children: /* @__PURE__ */ z("span", {
|
|
520
|
+
className: "cn-anchor grid w-[66px] shrink-0 grid-cols-3 gap-[3px]",
|
|
521
|
+
role: "group",
|
|
522
|
+
"aria-label": "九宫锚点",
|
|
523
|
+
children: t.map((e) => /* @__PURE__ */ z("button", {
|
|
524
|
+
type: "button",
|
|
525
|
+
className: `cn-anchor__cell relative aspect-square min-w-0 rounded-[4px] border p-0 transition-colors duration-100 ${e === s ? "cn-anchor__cell--active border-cn-accent bg-cn-accent shadow-(--cn-accent-glow)" : "border-cn-field-line bg-cn-field hover:border-cn-muted/50"}`,
|
|
526
|
+
"aria-pressed": e === s,
|
|
527
|
+
title: e,
|
|
528
|
+
onClick: () => o(e)
|
|
529
|
+
}, e))
|
|
530
|
+
})
|
|
531
|
+
})]
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region src/property-panel/fields/BooleanField.tsx
|
|
536
|
+
function Pe({ field: e, modelValue: t, className: n, onChange: r }) {
|
|
537
|
+
let i = t === !0, a = I(null);
|
|
538
|
+
P(() => {
|
|
539
|
+
a.current !== null && (a.current.checked = i);
|
|
540
|
+
});
|
|
541
|
+
function o(e) {
|
|
542
|
+
r(e.target.checked);
|
|
543
|
+
}
|
|
544
|
+
return /* @__PURE__ */ B("label", {
|
|
545
|
+
className: `cn-bool relative inline-flex h-4 w-7 shrink-0 cursor-pointer items-center${n === void 0 ? "" : ` ${n}`}`,
|
|
546
|
+
children: [
|
|
547
|
+
/* @__PURE__ */ z("input", {
|
|
548
|
+
ref: a,
|
|
549
|
+
className: "cn-bool__input peer sr-only",
|
|
550
|
+
type: "checkbox",
|
|
551
|
+
defaultChecked: i,
|
|
552
|
+
"aria-label": e.label,
|
|
553
|
+
onChange: o
|
|
554
|
+
}),
|
|
555
|
+
/* @__PURE__ */ z("span", { className: "absolute inset-0 rounded-full border border-cn-field-line bg-cn-field transition-colors duration-150 peer-checked:border-cn-accent/60 peer-checked:bg-cn-accent/30 peer-focus-visible:ring-[3px] peer-focus-visible:ring-cn-accent/20" }),
|
|
556
|
+
/* @__PURE__ */ z("span", { className: "relative mx-0.5 size-3 rounded-full bg-cn-muted shadow-sm transition-transform duration-150 peer-checked:translate-x-3 peer-checked:bg-cn-accent" })
|
|
557
|
+
]
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
//#endregion
|
|
561
|
+
//#region src/property-panel/shorthand.ts
|
|
562
|
+
var Fe = {
|
|
563
|
+
1: [{
|
|
564
|
+
label: "四边",
|
|
565
|
+
rep: "top",
|
|
566
|
+
sides: [
|
|
567
|
+
"top",
|
|
568
|
+
"bottom",
|
|
569
|
+
"left",
|
|
570
|
+
"right"
|
|
571
|
+
]
|
|
572
|
+
}],
|
|
573
|
+
2: [{
|
|
574
|
+
label: "上下",
|
|
575
|
+
rep: "top",
|
|
576
|
+
sides: ["top", "bottom"]
|
|
577
|
+
}, {
|
|
578
|
+
label: "左右",
|
|
579
|
+
rep: "left",
|
|
580
|
+
sides: ["left", "right"]
|
|
581
|
+
}],
|
|
582
|
+
4: [
|
|
583
|
+
{
|
|
584
|
+
label: "上",
|
|
585
|
+
rep: "top",
|
|
586
|
+
sides: ["top"]
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
label: "下",
|
|
590
|
+
rep: "bottom",
|
|
591
|
+
sides: ["bottom"]
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
label: "左",
|
|
595
|
+
rep: "left",
|
|
596
|
+
sides: ["left"]
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
label: "右",
|
|
600
|
+
rep: "right",
|
|
601
|
+
sides: ["right"]
|
|
602
|
+
}
|
|
603
|
+
]
|
|
604
|
+
};
|
|
605
|
+
function Ie(e) {
|
|
606
|
+
return e === 1 ? 2 : e === 2 ? 4 : 1;
|
|
607
|
+
}
|
|
608
|
+
function Le(e) {
|
|
609
|
+
return e.top === e.bottom && e.bottom === e.left && e.left === e.right ? 1 : e.top === e.bottom && e.left === e.right ? 2 : 4;
|
|
610
|
+
}
|
|
611
|
+
function Re(e, t) {
|
|
612
|
+
if (t === 1) {
|
|
613
|
+
let { top: t } = e;
|
|
614
|
+
return {
|
|
615
|
+
top: t,
|
|
616
|
+
bottom: t,
|
|
617
|
+
left: t,
|
|
618
|
+
right: t
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
if (t === 2) {
|
|
622
|
+
let { top: t, left: n } = e;
|
|
623
|
+
return {
|
|
624
|
+
top: t,
|
|
625
|
+
bottom: t,
|
|
626
|
+
left: n,
|
|
627
|
+
right: n
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
return e;
|
|
631
|
+
}
|
|
632
|
+
function ze(e, t) {
|
|
633
|
+
return e.top === t.top && e.bottom === t.bottom && e.left === t.left && e.right === t.right;
|
|
634
|
+
}
|
|
635
|
+
function K(e, t) {
|
|
636
|
+
return e === null || t === null ? e === t : e.width === t.width && e.color === t.color;
|
|
637
|
+
}
|
|
638
|
+
function Be(e) {
|
|
639
|
+
let { top: t, bottom: n, left: r, right: i } = e;
|
|
640
|
+
return t === null && n === null && r === null && i === null || t !== null && K(t, n) && K(t, r) && K(t, i) ? 1 : K(t, n) && K(r, i) ? 2 : 4;
|
|
641
|
+
}
|
|
642
|
+
function Ve(e, t) {
|
|
643
|
+
let n = (e) => e === null ? null : { ...e };
|
|
644
|
+
if (t === 1) {
|
|
645
|
+
let t = n(e.top);
|
|
646
|
+
return {
|
|
647
|
+
top: t,
|
|
648
|
+
bottom: n(t),
|
|
649
|
+
left: n(t),
|
|
650
|
+
right: n(t)
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
if (t === 2) {
|
|
654
|
+
let t = n(e.top), r = n(e.left);
|
|
655
|
+
return {
|
|
656
|
+
top: t,
|
|
657
|
+
bottom: n(t),
|
|
658
|
+
left: r,
|
|
659
|
+
right: n(r)
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
return e;
|
|
663
|
+
}
|
|
664
|
+
function He(e, t) {
|
|
665
|
+
return K(e.top, t.top) && K(e.bottom, t.bottom) && K(e.left, t.left) && K(e.right, t.right);
|
|
666
|
+
}
|
|
667
|
+
//#endregion
|
|
668
|
+
//#region src/property-panel/useShorthandMode.ts
|
|
669
|
+
function Ue(e, t) {
|
|
670
|
+
let n = e(), [r, i] = L(null), a = I(n);
|
|
671
|
+
a.current !== n && (a.current = n, i(null));
|
|
672
|
+
let o = t(n), s = r ?? o;
|
|
673
|
+
function c() {
|
|
674
|
+
let e = s, t = Ie(e);
|
|
675
|
+
return i(t), {
|
|
676
|
+
from: e,
|
|
677
|
+
to: t
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
return {
|
|
681
|
+
mode: s,
|
|
682
|
+
cycle: c
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
//#endregion
|
|
686
|
+
//#region src/property-panel/controlStyles.ts
|
|
687
|
+
var q = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-field text-[11.5px] leading-none text-cn-fg outline-none transition-[border-color,box-shadow,background-color] duration-100 placeholder:text-cn-muted/60 hover:border-cn-muted/40 focus:border-cn-accent/70 focus:ring-[3px] focus:ring-cn-accent/15 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-cn-field-line", J = `${q} text-right font-mono tabular-nums`, We = q, Ge = "w-full flex-1 min-w-0 resize-y rounded-md border border-cn-field-line bg-cn-field px-2 py-1.5 text-[11.5px] leading-5 text-cn-fg outline-none transition-[border-color,box-shadow] duration-100 placeholder:text-cn-muted/60 hover:border-cn-muted/40 focus:border-cn-accent/70 focus:ring-[3px] focus:ring-cn-accent/15 disabled:cursor-not-allowed disabled:opacity-40", Ke = "size-7 shrink-0 cursor-pointer self-center rounded-md border border-cn-field-line bg-cn-field p-0.5 transition-colors hover:border-cn-muted/40 disabled:cursor-not-allowed disabled:opacity-40";
|
|
688
|
+
//#endregion
|
|
689
|
+
//#region src/property-panel/fields/BorderWidthInput.tsx
|
|
690
|
+
function qe({ value: e, label: t, onInput: n, onChange: r }) {
|
|
691
|
+
let [i, a] = L(e === null ? "" : String(e)), o = I(!1);
|
|
692
|
+
P(() => {
|
|
693
|
+
o.current || a(e === null ? "" : String(e));
|
|
694
|
+
}, [e]);
|
|
695
|
+
function s(e) {
|
|
696
|
+
return Math.max(0, Math.trunc(e));
|
|
697
|
+
}
|
|
698
|
+
function c(e) {
|
|
699
|
+
if (e.value.trim() === "") return null;
|
|
700
|
+
let t = Number(e.value);
|
|
701
|
+
return Number.isFinite(t) ? t : null;
|
|
702
|
+
}
|
|
703
|
+
function l(e) {
|
|
704
|
+
return e === null ? "" : String(e);
|
|
705
|
+
}
|
|
706
|
+
function u(e) {
|
|
707
|
+
a(e.target.value);
|
|
708
|
+
let t = c(e.target);
|
|
709
|
+
t !== null && n(s(t));
|
|
710
|
+
}
|
|
711
|
+
function d(t) {
|
|
712
|
+
o.current = !1;
|
|
713
|
+
let n = c(t.target);
|
|
714
|
+
if (n === null) {
|
|
715
|
+
a(l(e));
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
let i = s(n);
|
|
719
|
+
a(i === 0 ? "" : String(i)), r(i);
|
|
720
|
+
}
|
|
721
|
+
return /* @__PURE__ */ z("input", {
|
|
722
|
+
className: `cn-field cn-field--number min-w-0 flex-1 ${J}`,
|
|
723
|
+
type: "number",
|
|
724
|
+
"aria-label": t,
|
|
725
|
+
min: 0,
|
|
726
|
+
step: 1,
|
|
727
|
+
placeholder: "无边框",
|
|
728
|
+
title: "宽度归 0 即关闭该边",
|
|
729
|
+
value: i,
|
|
730
|
+
onChange: u,
|
|
731
|
+
onFocus: () => {
|
|
732
|
+
o.current = !0;
|
|
733
|
+
},
|
|
734
|
+
onBlur: d
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
//#endregion
|
|
738
|
+
//#region src/property-panel/fields/ShorthandModeButton.tsx
|
|
739
|
+
var Je = {
|
|
740
|
+
1: {
|
|
741
|
+
icon: fe,
|
|
742
|
+
title: "统一值"
|
|
743
|
+
},
|
|
744
|
+
2: {
|
|
745
|
+
icon: ue,
|
|
746
|
+
title: "上下/左右"
|
|
747
|
+
},
|
|
748
|
+
4: {
|
|
749
|
+
icon: ce,
|
|
750
|
+
title: "四边独立"
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
function Ye({ mode: e, label: t, onCycle: n }) {
|
|
754
|
+
let r = Je[e], i = `${t}:${r.title}(点击切换值模式)`;
|
|
755
|
+
return /* @__PURE__ */ z("button", {
|
|
756
|
+
type: "button",
|
|
757
|
+
className: "cn-props__mode-toggle shrink-0",
|
|
758
|
+
"aria-label": i,
|
|
759
|
+
title: i,
|
|
760
|
+
onClick: (e) => {
|
|
761
|
+
e.preventDefault(), n();
|
|
762
|
+
},
|
|
763
|
+
children: /* @__PURE__ */ z(h, {
|
|
764
|
+
icon: r.icon,
|
|
765
|
+
size: 12
|
|
766
|
+
})
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
//#endregion
|
|
770
|
+
//#region src/property-panel/fields/BorderField.tsx
|
|
771
|
+
var Xe = "#000000";
|
|
772
|
+
function Ze({ modelValue: e, className: t, onInput: n, onChange: r }) {
|
|
773
|
+
let i = e, { mode: a, cycle: o } = Ue(() => i, Be), s = Fe[a];
|
|
774
|
+
function c(e) {
|
|
775
|
+
return i[e.rep]?.width ?? null;
|
|
776
|
+
}
|
|
777
|
+
function l(e) {
|
|
778
|
+
return i[e.rep]?.color ?? Xe;
|
|
779
|
+
}
|
|
780
|
+
function u(e, t, a) {
|
|
781
|
+
let o = { ...i };
|
|
782
|
+
for (let n of e.sides) o[n] = t === null ? null : { ...t };
|
|
783
|
+
a ? r(o) : n(o);
|
|
784
|
+
}
|
|
785
|
+
function d(e, t, n) {
|
|
786
|
+
let r = i[e.rep]?.color ?? Xe;
|
|
787
|
+
u(e, t <= 0 ? null : {
|
|
788
|
+
width: t,
|
|
789
|
+
color: r
|
|
790
|
+
}, n);
|
|
791
|
+
}
|
|
792
|
+
function f(e, t, n) {
|
|
793
|
+
let r = i[e.rep];
|
|
794
|
+
if (r == null) return;
|
|
795
|
+
let a = t.target.value.trim();
|
|
796
|
+
a !== "" && u(e, {
|
|
797
|
+
width: r.width,
|
|
798
|
+
color: a
|
|
799
|
+
}, n);
|
|
800
|
+
}
|
|
801
|
+
function p() {
|
|
802
|
+
let { from: e, to: t } = o();
|
|
803
|
+
if (t < e) {
|
|
804
|
+
let e = Ve(i, t);
|
|
805
|
+
He(e, i) || r(e);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
return /* @__PURE__ */ B("span", {
|
|
809
|
+
className: `cn-border flex w-full min-w-0 items-center gap-1${t === void 0 ? "" : ` ${t}`}`,
|
|
810
|
+
children: [/* @__PURE__ */ z(Ye, {
|
|
811
|
+
mode: a,
|
|
812
|
+
label: "边框",
|
|
813
|
+
onCycle: p
|
|
814
|
+
}), /* @__PURE__ */ z("span", {
|
|
815
|
+
className: "grid min-w-0 flex-1 gap-1 grid-cols-1",
|
|
816
|
+
children: s.map((e) => /* @__PURE__ */ B("label", {
|
|
817
|
+
className: "flex items-center gap-1.5",
|
|
818
|
+
children: [
|
|
819
|
+
/* @__PURE__ */ z("span", {
|
|
820
|
+
className: "w-5 shrink-0 select-none text-[10px] leading-none text-cn-muted",
|
|
821
|
+
children: e.label
|
|
822
|
+
}),
|
|
823
|
+
/* @__PURE__ */ z(qe, {
|
|
824
|
+
value: c(e),
|
|
825
|
+
label: e.label,
|
|
826
|
+
onInput: (t) => d(e, t, !1),
|
|
827
|
+
onChange: (t) => d(e, t, !0)
|
|
828
|
+
}),
|
|
829
|
+
/* @__PURE__ */ z("input", {
|
|
830
|
+
className: "cn-border__color size-6 shrink-0 cursor-pointer self-center rounded-md border border-cn-field-line bg-cn-field p-0.5 transition-colors hover:border-cn-muted/40 disabled:cursor-not-allowed disabled:opacity-40",
|
|
831
|
+
type: "color",
|
|
832
|
+
title: "边框颜色",
|
|
833
|
+
value: l(e),
|
|
834
|
+
disabled: i[e.rep] === null,
|
|
835
|
+
onChange: (t) => f(e, t, !1),
|
|
836
|
+
onBlur: (t) => f(e, t, !0)
|
|
837
|
+
})
|
|
838
|
+
]
|
|
839
|
+
}, e.rep))
|
|
840
|
+
})]
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
//#endregion
|
|
844
|
+
//#region src/property-panel/fields/FontField.tsx
|
|
845
|
+
function Qe({ field: e, modelValue: t, className: n, onInput: r, onChange: i }) {
|
|
846
|
+
let a = typeof t == "string" ? t : "", o = O();
|
|
847
|
+
function s() {
|
|
848
|
+
if (o === null) return [];
|
|
849
|
+
let e = [{
|
|
850
|
+
label: "内置默认字体",
|
|
851
|
+
value: ""
|
|
852
|
+
}];
|
|
853
|
+
for (let t of o.entries) t.ref !== "" && e.push({
|
|
854
|
+
label: t.label,
|
|
855
|
+
value: t.ref
|
|
856
|
+
});
|
|
857
|
+
return a !== "" && !e.some((e) => e.value === a) && e.push({
|
|
858
|
+
label: `${c(a)}(清单外引用)`,
|
|
859
|
+
value: a
|
|
860
|
+
}), e;
|
|
861
|
+
}
|
|
862
|
+
function c(e) {
|
|
863
|
+
if (e.startsWith("data:")) return "自定义字体(内联)";
|
|
864
|
+
let t = e.split("/").pop();
|
|
865
|
+
return t !== void 0 && t !== "" ? t : e;
|
|
866
|
+
}
|
|
867
|
+
function l(e) {
|
|
868
|
+
i(e.target.value);
|
|
869
|
+
}
|
|
870
|
+
let u = I(!1);
|
|
871
|
+
function d(e) {
|
|
872
|
+
u.current || e.nativeEvent.isComposing === !0 || r(e.target.value);
|
|
873
|
+
}
|
|
874
|
+
function f() {
|
|
875
|
+
u.current = !0;
|
|
876
|
+
}
|
|
877
|
+
function p(e) {
|
|
878
|
+
u.current = !1, r(e.target.value);
|
|
879
|
+
}
|
|
880
|
+
function m(e) {
|
|
881
|
+
u.current = !1, i(e.target.value);
|
|
882
|
+
}
|
|
883
|
+
let [h, g] = L(!1), [_, v] = L(null), y = I(null);
|
|
884
|
+
function b() {
|
|
885
|
+
v(null), y.current?.click();
|
|
886
|
+
}
|
|
887
|
+
async function x(e) {
|
|
888
|
+
let t = e.target, n = t.files?.[0];
|
|
889
|
+
if (t.value = "", !(o === null || n === void 0 || h)) {
|
|
890
|
+
g(!0);
|
|
891
|
+
try {
|
|
892
|
+
i(await o.uploadFont(await D(n)));
|
|
893
|
+
} catch (e) {
|
|
894
|
+
v(e instanceof Error ? e.message : String(e));
|
|
895
|
+
} finally {
|
|
896
|
+
g(!1);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
return o === null ? /* @__PURE__ */ z("input", {
|
|
901
|
+
className: `cn-field ${We}${n === void 0 ? "" : ` ${n}`}`,
|
|
902
|
+
type: "text",
|
|
903
|
+
value: a,
|
|
904
|
+
"aria-label": e.label,
|
|
905
|
+
onChange: d,
|
|
906
|
+
onCompositionStart: f,
|
|
907
|
+
onCompositionEnd: p,
|
|
908
|
+
onBlur: m
|
|
909
|
+
}) : /* @__PURE__ */ B("div", {
|
|
910
|
+
className: `flex flex-1 items-center gap-1.5${n === void 0 ? "" : ` ${n}`}`,
|
|
911
|
+
children: [
|
|
912
|
+
/* @__PURE__ */ z("select", {
|
|
913
|
+
className: `cn-field cn-select ${q}`,
|
|
914
|
+
value: a,
|
|
915
|
+
onChange: l,
|
|
916
|
+
"aria-label": e.label,
|
|
917
|
+
children: s().map((e) => /* @__PURE__ */ z("option", {
|
|
918
|
+
value: e.value,
|
|
919
|
+
children: e.label
|
|
920
|
+
}, e.value))
|
|
921
|
+
}),
|
|
922
|
+
/* @__PURE__ */ z("input", {
|
|
923
|
+
ref: y,
|
|
924
|
+
type: "file",
|
|
925
|
+
className: "hidden",
|
|
926
|
+
accept: ".ttf,.otf,.woff,.woff2,font/ttf,font/otf,font/woff,font/woff2",
|
|
927
|
+
onChange: x
|
|
928
|
+
}),
|
|
929
|
+
o.canUpload && /* @__PURE__ */ z("button", {
|
|
930
|
+
type: "button",
|
|
931
|
+
className: "h-7 shrink-0 rounded-md border border-cn-field-line bg-cn-field px-2 text-[11px] leading-none text-cn-fg transition-colors duration-100 hover:border-cn-muted/40 disabled:cursor-not-allowed disabled:opacity-40",
|
|
932
|
+
disabled: h,
|
|
933
|
+
title: _ ?? "上传本机字体(加入清单后可选)",
|
|
934
|
+
"data-upload-error": _ ?? void 0,
|
|
935
|
+
onClick: b,
|
|
936
|
+
children: h ? "…" : _ === null ? "上传" : "!"
|
|
937
|
+
})
|
|
938
|
+
]
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
//#endregion
|
|
942
|
+
//#region src/property-panel/fields/ColorField.tsx
|
|
943
|
+
var $e = "#000000";
|
|
944
|
+
function Y(e) {
|
|
945
|
+
return e !== null && /^#[0-9a-fA-F]{6}$/.test(e) ? e : $e;
|
|
946
|
+
}
|
|
947
|
+
function et({ field: e, modelValue: t, className: n, onInput: r, onChange: i }) {
|
|
948
|
+
let a = typeof t == "string" ? t : null, [o, s] = L(a !== null), [c, l] = L(Y(a)), u = I(c);
|
|
949
|
+
u.current = c, P(() => {
|
|
950
|
+
s(a !== null), a !== null && l(Y(a));
|
|
951
|
+
}, [a]);
|
|
952
|
+
function d(e) {
|
|
953
|
+
let t = e.target.checked;
|
|
954
|
+
if (s(t), !t) {
|
|
955
|
+
i(null);
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
i(u.current);
|
|
959
|
+
}
|
|
960
|
+
function f(e) {
|
|
961
|
+
let t = e.target.value;
|
|
962
|
+
l(t), r(t);
|
|
963
|
+
}
|
|
964
|
+
function p(e) {
|
|
965
|
+
let t = e.target.value;
|
|
966
|
+
l(t), i(t);
|
|
967
|
+
}
|
|
968
|
+
function m(t) {
|
|
969
|
+
let n = t.target.value.trim();
|
|
970
|
+
if (n === "") {
|
|
971
|
+
e.nullable === !0 && i(null);
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
l(Y(n)), i(n);
|
|
975
|
+
}
|
|
976
|
+
let h = I(null), g = a ?? "";
|
|
977
|
+
return /* @__PURE__ */ B("span", {
|
|
978
|
+
className: `cn-color flex min-w-0 flex-1 items-center gap-1.5${n === void 0 ? "" : ` ${n}`}`,
|
|
979
|
+
children: [
|
|
980
|
+
e.nullable === !0 && /* @__PURE__ */ z("input", {
|
|
981
|
+
className: "cn-color__toggle size-3.5 shrink-0 cursor-pointer accent-cn-accent",
|
|
982
|
+
type: "checkbox",
|
|
983
|
+
title: "启用颜色",
|
|
984
|
+
checked: o,
|
|
985
|
+
onChange: d
|
|
986
|
+
}),
|
|
987
|
+
/* @__PURE__ */ z("input", {
|
|
988
|
+
className: `cn-color__swatch ${Ke}`,
|
|
989
|
+
type: "color",
|
|
990
|
+
value: c,
|
|
991
|
+
disabled: !o,
|
|
992
|
+
onChange: f,
|
|
993
|
+
onBlur: p
|
|
994
|
+
}),
|
|
995
|
+
/* @__PURE__ */ z("input", {
|
|
996
|
+
ref: h,
|
|
997
|
+
className: `cn-color__text min-w-0 flex-1 ${q}`,
|
|
998
|
+
type: "text",
|
|
999
|
+
defaultValue: g,
|
|
1000
|
+
disabled: !o,
|
|
1001
|
+
placeholder: "无",
|
|
1002
|
+
onBlur: m
|
|
1003
|
+
}, `${g}:${o ? "on" : "off"}`)
|
|
1004
|
+
]
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
//#endregion
|
|
1008
|
+
//#region src/property-panel/imageUpload.ts
|
|
1009
|
+
var X = j(null);
|
|
1010
|
+
function tt() {
|
|
1011
|
+
return N(X);
|
|
1012
|
+
}
|
|
1013
|
+
//#endregion
|
|
1014
|
+
//#region src/property-panel/fields/intrinsicSize.ts
|
|
1015
|
+
function nt(e, t) {
|
|
1016
|
+
let n = e, r = t;
|
|
1017
|
+
for (; r !== 0;) [n, r] = [r, n % r];
|
|
1018
|
+
let i = e / n, a = t / n;
|
|
1019
|
+
return Math.max(i, a) <= 32 ? `${i}:${a}` : `${Math.round(e / t * 100) / 100}:1`;
|
|
1020
|
+
}
|
|
1021
|
+
function rt(e, t) {
|
|
1022
|
+
return !Number.isFinite(e) || !Number.isFinite(t) || e <= 0 || t <= 0 ? null : `${e}×${t} · ${nt(e, t)}`;
|
|
1023
|
+
}
|
|
1024
|
+
//#endregion
|
|
1025
|
+
//#region src/property-panel/fields/TextField.tsx
|
|
1026
|
+
function Z({ field: e, modelValue: t, className: n, onInput: r, onChange: i }) {
|
|
1027
|
+
let a = I(!1), [o, s] = L(!1);
|
|
1028
|
+
function c(t) {
|
|
1029
|
+
return e.nonEmpty === !0 ? t.trim() === "" ? (s(!0), !0) : (s(!1), !1) : !1;
|
|
1030
|
+
}
|
|
1031
|
+
function l(e) {
|
|
1032
|
+
let t = e.target.value;
|
|
1033
|
+
a.current || e.nativeEvent.isComposing === !0 || c(t) || r(t);
|
|
1034
|
+
}
|
|
1035
|
+
function u() {
|
|
1036
|
+
a.current = !0;
|
|
1037
|
+
}
|
|
1038
|
+
function d(e) {
|
|
1039
|
+
a.current = !1;
|
|
1040
|
+
let t = e.target.value;
|
|
1041
|
+
c(t) || r(t);
|
|
1042
|
+
}
|
|
1043
|
+
function f(e) {
|
|
1044
|
+
a.current = !1;
|
|
1045
|
+
let t = e.target.value;
|
|
1046
|
+
c(t) || i(t);
|
|
1047
|
+
}
|
|
1048
|
+
return /* @__PURE__ */ z("input", {
|
|
1049
|
+
className: `cn-field ${We}${o ? " cn-field--invalid" : ""}${n === void 0 ? "" : ` ${n}`}`,
|
|
1050
|
+
type: "text",
|
|
1051
|
+
value: typeof t == "string" ? t : "",
|
|
1052
|
+
placeholder: e.placeholder,
|
|
1053
|
+
"aria-label": e.label,
|
|
1054
|
+
onChange: l,
|
|
1055
|
+
onCompositionStart: u,
|
|
1056
|
+
onCompositionEnd: d,
|
|
1057
|
+
onBlur: f
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
//#endregion
|
|
1061
|
+
//#region src/property-panel/fields/ResourceValueField.tsx
|
|
1062
|
+
function it({ field: e, modelValue: t, className: n, dataMode: r, source: i, disabled: a, onInput: o, onChange: s }) {
|
|
1063
|
+
let c = typeof t == "string" ? t : null, l = r === "expression", u = !l || c === null ? "" : x(c) ?? c;
|
|
1064
|
+
function d(e) {
|
|
1065
|
+
let t = C(e);
|
|
1066
|
+
o(t), s(t);
|
|
1067
|
+
}
|
|
1068
|
+
return l ? /* @__PURE__ */ z(v, {
|
|
1069
|
+
className: n,
|
|
1070
|
+
modelValue: u,
|
|
1071
|
+
source: i ?? null,
|
|
1072
|
+
disabled: a,
|
|
1073
|
+
ariaLabel: e.label,
|
|
1074
|
+
placeholder: "未选择字段",
|
|
1075
|
+
onPick: d
|
|
1076
|
+
}) : /* @__PURE__ */ z(Z, {
|
|
1077
|
+
field: e,
|
|
1078
|
+
className: n,
|
|
1079
|
+
modelValue: c ?? "",
|
|
1080
|
+
disabled: a,
|
|
1081
|
+
onInput: o,
|
|
1082
|
+
onChange: s,
|
|
1083
|
+
onSubCommit: () => void 0
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
//#endregion
|
|
1087
|
+
//#region src/property-panel/fields/ImageSrcField.tsx
|
|
1088
|
+
function at({ field: e, modelValue: t, className: n, dataMode: r, resourceStatus: i, source: a, disabled: o, onInput: s, onChange: c }) {
|
|
1089
|
+
let l = typeof t == "string" ? t : null, u = tt(), d = u !== null && u.canUpload && r !== "expression", f = typeof l == "string" && l !== "", p = i === "pending" ? "装载中" : i === "failed" ? "失败" : null, [m, h] = L(!1), [g, _] = L(null), v = I(null), [y, b] = L(null), x = y === null ? null : rt(y.width, y.height);
|
|
1090
|
+
P(() => {
|
|
1091
|
+
b(null);
|
|
1092
|
+
}, [l]);
|
|
1093
|
+
function S(e) {
|
|
1094
|
+
let t = e.target;
|
|
1095
|
+
b(t.naturalWidth > 0 && t.naturalHeight > 0 ? {
|
|
1096
|
+
width: t.naturalWidth,
|
|
1097
|
+
height: t.naturalHeight
|
|
1098
|
+
} : null);
|
|
1099
|
+
}
|
|
1100
|
+
function C() {
|
|
1101
|
+
_(null), v.current?.click();
|
|
1102
|
+
}
|
|
1103
|
+
async function w(e) {
|
|
1104
|
+
let t = e.target, n = t.files?.[0];
|
|
1105
|
+
if (t.value = "", !(u === null || n === void 0 || m)) {
|
|
1106
|
+
h(!0);
|
|
1107
|
+
try {
|
|
1108
|
+
let e = await u.uploadImage(await D(n));
|
|
1109
|
+
e !== null && c(e);
|
|
1110
|
+
} catch (e) {
|
|
1111
|
+
_(e instanceof Error ? e.message : String(e));
|
|
1112
|
+
} finally {
|
|
1113
|
+
h(!1);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
return d ? /* @__PURE__ */ B("div", {
|
|
1118
|
+
className: `flex flex-col gap-1.5${n === void 0 ? "" : ` ${n}`}`,
|
|
1119
|
+
children: [
|
|
1120
|
+
/* @__PURE__ */ B("button", {
|
|
1121
|
+
type: "button",
|
|
1122
|
+
className: "cn-imagesrc__thumb relative flex h-16 w-full items-center justify-center overflow-hidden rounded-md border border-dashed border-cn-field-line bg-cn-field/40 text-[11px] leading-none text-cn-muted transition-colors duration-100 hover:border-cn-muted/40 disabled:cursor-not-allowed disabled:opacity-40",
|
|
1123
|
+
disabled: m,
|
|
1124
|
+
title: g ?? (f ? "点击替换图片" : "点击上传图片"),
|
|
1125
|
+
"data-upload-error": g ?? void 0,
|
|
1126
|
+
onClick: C,
|
|
1127
|
+
children: [
|
|
1128
|
+
f && /* @__PURE__ */ z("img", {
|
|
1129
|
+
src: l ?? void 0,
|
|
1130
|
+
className: "absolute inset-0 size-full object-cover",
|
|
1131
|
+
alt: "",
|
|
1132
|
+
onLoad: S,
|
|
1133
|
+
onError: () => b(null)
|
|
1134
|
+
}),
|
|
1135
|
+
p !== null && /* @__PURE__ */ z("span", {
|
|
1136
|
+
className: `cn-imagesrc__status absolute right-1 top-1 rounded bg-cn-bg-elevated/90 px-1 py-0.5 text-[10px] leading-none ${i === "failed" ? "text-red-400" : "text-cn-muted"}`,
|
|
1137
|
+
"data-status": i,
|
|
1138
|
+
children: p
|
|
1139
|
+
}),
|
|
1140
|
+
!f && /* @__PURE__ */ z("span", {
|
|
1141
|
+
className: "relative",
|
|
1142
|
+
children: m ? "…" : g === null ? "点击上传图片" : "!"
|
|
1143
|
+
})
|
|
1144
|
+
]
|
|
1145
|
+
}),
|
|
1146
|
+
/* @__PURE__ */ z("input", {
|
|
1147
|
+
ref: v,
|
|
1148
|
+
type: "file",
|
|
1149
|
+
className: "hidden",
|
|
1150
|
+
accept: "image/*",
|
|
1151
|
+
onChange: w
|
|
1152
|
+
}),
|
|
1153
|
+
/* @__PURE__ */ B("div", {
|
|
1154
|
+
className: "flex items-center gap-1.5",
|
|
1155
|
+
children: [/* @__PURE__ */ z(Z, {
|
|
1156
|
+
field: e,
|
|
1157
|
+
className: n,
|
|
1158
|
+
modelValue: l ?? "",
|
|
1159
|
+
onInput: s,
|
|
1160
|
+
onChange: c,
|
|
1161
|
+
onSubCommit: () => void 0
|
|
1162
|
+
}), f && /* @__PURE__ */ z("button", {
|
|
1163
|
+
type: "button",
|
|
1164
|
+
className: "cn-imagesrc__clear h-7 shrink-0 rounded-md border border-cn-field-line bg-cn-field px-2 text-[11px] leading-none text-cn-fg transition-colors duration-100 hover:border-cn-muted/40",
|
|
1165
|
+
title: "清除图片(资源地址置空)",
|
|
1166
|
+
onClick: () => c(""),
|
|
1167
|
+
children: "清除"
|
|
1168
|
+
})]
|
|
1169
|
+
}),
|
|
1170
|
+
x !== null && /* @__PURE__ */ B("span", {
|
|
1171
|
+
className: "cn-imagesrc__intrinsic text-[11px] leading-4 text-cn-muted",
|
|
1172
|
+
children: ["源图 ", x]
|
|
1173
|
+
})
|
|
1174
|
+
]
|
|
1175
|
+
}) : r === "expression" ? /* @__PURE__ */ z(it, {
|
|
1176
|
+
field: e,
|
|
1177
|
+
className: n,
|
|
1178
|
+
modelValue: l,
|
|
1179
|
+
dataMode: "expression",
|
|
1180
|
+
source: a ?? null,
|
|
1181
|
+
disabled: o,
|
|
1182
|
+
onInput: s,
|
|
1183
|
+
onChange: c,
|
|
1184
|
+
onSubCommit: () => void 0
|
|
1185
|
+
}) : /* @__PURE__ */ z(Z, {
|
|
1186
|
+
field: e,
|
|
1187
|
+
className: n,
|
|
1188
|
+
modelValue: l ?? "",
|
|
1189
|
+
onInput: s,
|
|
1190
|
+
onChange: c,
|
|
1191
|
+
onSubCommit: () => void 0
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
//#endregion
|
|
1195
|
+
//#region src/property-panel/fields/NumberField.tsx
|
|
1196
|
+
function Q({ field: e, modelValue: t, className: n, onInput: r, onChange: i }) {
|
|
1197
|
+
let a = typeof t == "number" ? t : 0, [o, s] = L(String(a)), c = I(!1);
|
|
1198
|
+
P(() => {
|
|
1199
|
+
c.current || s(String(a));
|
|
1200
|
+
}, [a]);
|
|
1201
|
+
function l(t) {
|
|
1202
|
+
let n = e.integer === !0 ? Math.trunc(t) : t;
|
|
1203
|
+
return e.min !== void 0 && (n = Math.max(e.min, n)), e.max !== void 0 && (n = Math.min(e.max, n)), n;
|
|
1204
|
+
}
|
|
1205
|
+
function u(e) {
|
|
1206
|
+
if (e.value.trim() === "") return null;
|
|
1207
|
+
let t = Number(e.value);
|
|
1208
|
+
return Number.isFinite(t) ? t : null;
|
|
1209
|
+
}
|
|
1210
|
+
function d(e) {
|
|
1211
|
+
let t = e.target;
|
|
1212
|
+
s(t.value);
|
|
1213
|
+
let n = u(t);
|
|
1214
|
+
n !== null && r(l(n));
|
|
1215
|
+
}
|
|
1216
|
+
function f(e) {
|
|
1217
|
+
c.current = !1;
|
|
1218
|
+
let t = u(e.target);
|
|
1219
|
+
if (t === null) {
|
|
1220
|
+
s(String(a));
|
|
1221
|
+
return;
|
|
1222
|
+
}
|
|
1223
|
+
let n = l(t);
|
|
1224
|
+
s(String(n)), i(n);
|
|
1225
|
+
}
|
|
1226
|
+
return /* @__PURE__ */ z("input", {
|
|
1227
|
+
className: `cn-field cn-field--number ${J}${n === void 0 ? "" : ` ${n}`}`,
|
|
1228
|
+
value: o,
|
|
1229
|
+
onChange: d,
|
|
1230
|
+
onFocus: () => {
|
|
1231
|
+
c.current = !0;
|
|
1232
|
+
},
|
|
1233
|
+
onBlur: f,
|
|
1234
|
+
type: "number",
|
|
1235
|
+
"aria-label": e.label,
|
|
1236
|
+
min: e.min,
|
|
1237
|
+
max: e.max,
|
|
1238
|
+
step: e.step ?? (e.integer === !0 ? 1 : .1)
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
//#endregion
|
|
1242
|
+
//#region src/property-panel/fields/PaddingField.tsx
|
|
1243
|
+
function ot({ modelValue: e, className: t, onInput: n, onChange: r }) {
|
|
1244
|
+
let i = e, { mode: a, cycle: o } = Ue(() => i, Le), s = Fe[a];
|
|
1245
|
+
function c(e) {
|
|
1246
|
+
return {
|
|
1247
|
+
key: ["padding", e.rep],
|
|
1248
|
+
label: e.label,
|
|
1249
|
+
control: "number"
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1252
|
+
function l(e, t, a) {
|
|
1253
|
+
let o = { ...i };
|
|
1254
|
+
for (let n of e.sides) o[n] = t;
|
|
1255
|
+
a ? r(o) : n(o);
|
|
1256
|
+
}
|
|
1257
|
+
function u() {
|
|
1258
|
+
let { from: e, to: t } = o();
|
|
1259
|
+
if (t < e) {
|
|
1260
|
+
let e = Re(i, t);
|
|
1261
|
+
ze(e, i) || r(e);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
return /* @__PURE__ */ B("span", {
|
|
1265
|
+
className: `cn-padding flex w-full min-w-0 items-center gap-1.5${t === void 0 ? "" : ` ${t}`}`,
|
|
1266
|
+
children: [/* @__PURE__ */ z(Ye, {
|
|
1267
|
+
mode: a,
|
|
1268
|
+
label: "内边距",
|
|
1269
|
+
onCycle: u
|
|
1270
|
+
}), /* @__PURE__ */ z("span", {
|
|
1271
|
+
className: `grid min-w-0 flex-1 gap-1.5 ${a === 1 ? "grid-cols-1" : "grid-cols-2"}`,
|
|
1272
|
+
children: s.map((e) => /* @__PURE__ */ B("label", {
|
|
1273
|
+
className: "flex min-w-0 items-center gap-1.5",
|
|
1274
|
+
children: [/* @__PURE__ */ z("span", {
|
|
1275
|
+
className: "w-5 shrink-0 select-none text-[10px] leading-none text-cn-muted",
|
|
1276
|
+
children: e.label
|
|
1277
|
+
}), /* @__PURE__ */ z(Q, {
|
|
1278
|
+
field: c(e),
|
|
1279
|
+
modelValue: i[e.rep],
|
|
1280
|
+
onInput: (t) => l(e, t, !1),
|
|
1281
|
+
onChange: (t) => l(e, t, !0),
|
|
1282
|
+
onSubCommit: () => void 0
|
|
1283
|
+
})]
|
|
1284
|
+
}, e.rep))
|
|
1285
|
+
})]
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
//#endregion
|
|
1289
|
+
//#region src/property-panel/fields/PairField.tsx
|
|
1290
|
+
function st({ field: e, modelValue: t, className: n, displays: r, onSubCommit: i }) {
|
|
1291
|
+
let a = typeof t == "object" && t ? t : {}, o = e.items ?? [];
|
|
1292
|
+
function s(e) {
|
|
1293
|
+
if (e.auto === void 0) return !1;
|
|
1294
|
+
let t = G(a, e.auto.key);
|
|
1295
|
+
return t.ok && t.value === !0;
|
|
1296
|
+
}
|
|
1297
|
+
function c(t) {
|
|
1298
|
+
return {
|
|
1299
|
+
...t,
|
|
1300
|
+
key: W(e, t)
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
function l(t) {
|
|
1304
|
+
return {
|
|
1305
|
+
key: [...e.key, ...t.auto?.key ?? []],
|
|
1306
|
+
label: `${t.label}自适应`,
|
|
1307
|
+
control: "boolean"
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
function u(e, t, n) {
|
|
1311
|
+
i(c(e), t, n);
|
|
1312
|
+
}
|
|
1313
|
+
function d(e) {
|
|
1314
|
+
i(l(e), !s(e), !0);
|
|
1315
|
+
}
|
|
1316
|
+
function f(e) {
|
|
1317
|
+
let t = G(a, e.key);
|
|
1318
|
+
return t.ok && typeof t.value == "number" ? t.value : 0;
|
|
1319
|
+
}
|
|
1320
|
+
function p(t) {
|
|
1321
|
+
return r?.[W(e, t).join(".")];
|
|
1322
|
+
}
|
|
1323
|
+
function m(e) {
|
|
1324
|
+
let t = p(e);
|
|
1325
|
+
return t === void 0 ? "" : String(t.value);
|
|
1326
|
+
}
|
|
1327
|
+
function h(e) {
|
|
1328
|
+
return s(e) ? `${e.label}自适应:已开启(输入框禁用)` : `${e.label}自适应:开启后由内容决定,输入框禁用`;
|
|
1329
|
+
}
|
|
1330
|
+
function g(e) {
|
|
1331
|
+
let t = p(e);
|
|
1332
|
+
return t?.preview === !0 ? "模板子树:预览盒尺寸(随行实例变化,非文档声明值)" : t === void 0 ? `${e.label}自适应:已开启` : `${e.label}自适应:布局解析值(与画布选择框同源)`;
|
|
1333
|
+
}
|
|
1334
|
+
return /* @__PURE__ */ z("span", {
|
|
1335
|
+
className: `grid w-full min-w-0 grid-cols-2 gap-1${n === void 0 ? "" : ` ${n}`}`,
|
|
1336
|
+
children: o.map((e) => {
|
|
1337
|
+
let t = s(e), n = p(e);
|
|
1338
|
+
return /* @__PURE__ */ B("label", {
|
|
1339
|
+
className: "flex min-w-0 items-center gap-1",
|
|
1340
|
+
title: e.auto === void 0 ? e.label : void 0,
|
|
1341
|
+
children: [
|
|
1342
|
+
/* @__PURE__ */ z("span", {
|
|
1343
|
+
className: "w-3.5 shrink-0 select-none text-[10px] leading-none text-cn-muted",
|
|
1344
|
+
children: e.label
|
|
1345
|
+
}),
|
|
1346
|
+
e.auto !== void 0 && /* @__PURE__ */ z("button", {
|
|
1347
|
+
type: "button",
|
|
1348
|
+
className: `cn-props__auto-toggle shrink-0${t ? " cn-props__auto-toggle--active" : ""}`,
|
|
1349
|
+
"aria-pressed": t,
|
|
1350
|
+
title: h(e),
|
|
1351
|
+
onClick: (t) => {
|
|
1352
|
+
t.preventDefault(), d(e);
|
|
1353
|
+
},
|
|
1354
|
+
children: "自"
|
|
1355
|
+
}),
|
|
1356
|
+
t ? /* @__PURE__ */ z("input", {
|
|
1357
|
+
className: `cn-field cn-field--number min-w-0 flex-1 ${J}${n?.preview === !0 ? " cn-field--preview" : ""}`,
|
|
1358
|
+
type: "number",
|
|
1359
|
+
disabled: !0,
|
|
1360
|
+
readOnly: !0,
|
|
1361
|
+
"aria-label": e.label,
|
|
1362
|
+
value: m(e),
|
|
1363
|
+
placeholder: e.auto?.placeholder ?? "",
|
|
1364
|
+
title: g(e)
|
|
1365
|
+
}) : /* @__PURE__ */ z(Q, {
|
|
1366
|
+
field: e,
|
|
1367
|
+
modelValue: f(e),
|
|
1368
|
+
onInput: (t) => u(e, t, !1),
|
|
1369
|
+
onChange: (t) => u(e, t, !0),
|
|
1370
|
+
onSubCommit: i
|
|
1371
|
+
})
|
|
1372
|
+
]
|
|
1373
|
+
}, e.key.join("."));
|
|
1374
|
+
})
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
//#endregion
|
|
1378
|
+
//#region src/property-panel/fields/RowsPathField.tsx
|
|
1379
|
+
function ct({ field: e, modelValue: t, className: n, source: r, disabled: i, onInput: a, onChange: o }) {
|
|
1380
|
+
function s(e) {
|
|
1381
|
+
a(e), o(e);
|
|
1382
|
+
}
|
|
1383
|
+
return /* @__PURE__ */ z(v, {
|
|
1384
|
+
className: n,
|
|
1385
|
+
mode: "rowsPath",
|
|
1386
|
+
modelValue: typeof t == "string" ? t : "",
|
|
1387
|
+
source: r ?? null,
|
|
1388
|
+
disabled: i,
|
|
1389
|
+
ariaLabel: e.label,
|
|
1390
|
+
placeholder: "未选择行路径",
|
|
1391
|
+
onPick: s
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
//#endregion
|
|
1395
|
+
//#region src/property-panel/fields/SelectField.tsx
|
|
1396
|
+
function lt({ field: e, modelValue: t, className: n, onChange: r }) {
|
|
1397
|
+
function i(e) {
|
|
1398
|
+
r(e.target.value);
|
|
1399
|
+
}
|
|
1400
|
+
return /* @__PURE__ */ z("select", {
|
|
1401
|
+
className: `cn-select ${n ?? ""} h-7 w-full min-w-0 flex-1 cursor-pointer appearance-none rounded-md border border-cn-field-line bg-cn-field py-0 pl-2 pr-6 text-[11px] leading-none text-cn-fg outline-none transition-[border-color,box-shadow] duration-100 hover:border-cn-muted/40 focus:border-cn-accent/70 focus:ring-[3px] focus:ring-cn-accent/15 disabled:cursor-not-allowed disabled:opacity-40`,
|
|
1402
|
+
value: typeof t == "string" ? t : "",
|
|
1403
|
+
onChange: i,
|
|
1404
|
+
children: (e.domain ?? []).map((t) => /* @__PURE__ */ z("option", {
|
|
1405
|
+
value: t,
|
|
1406
|
+
children: e.optionLabels?.[t] ?? t
|
|
1407
|
+
}, t))
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
//#endregion
|
|
1411
|
+
//#region src/property-panel/fields/TextareaField.tsx
|
|
1412
|
+
function ut({ field: e, modelValue: t, disabled: n, className: r, onInput: i, onChange: a, controlRef: o }) {
|
|
1413
|
+
let s = I(!1);
|
|
1414
|
+
function c(e) {
|
|
1415
|
+
let t = e.target.value;
|
|
1416
|
+
s.current || e.nativeEvent.isComposing === !0 || i(t);
|
|
1417
|
+
}
|
|
1418
|
+
function l() {
|
|
1419
|
+
s.current = !0;
|
|
1420
|
+
}
|
|
1421
|
+
function u(e) {
|
|
1422
|
+
s.current = !1, i(e.target.value);
|
|
1423
|
+
}
|
|
1424
|
+
function d(e) {
|
|
1425
|
+
s.current = !1, a(e.target.value);
|
|
1426
|
+
}
|
|
1427
|
+
return /* @__PURE__ */ z("textarea", {
|
|
1428
|
+
ref: o,
|
|
1429
|
+
className: `cn-field ${Ge}${r === void 0 ? "" : ` ${r}`}`,
|
|
1430
|
+
rows: 3,
|
|
1431
|
+
value: typeof t == "string" ? t : "",
|
|
1432
|
+
disabled: n,
|
|
1433
|
+
"aria-label": e.label,
|
|
1434
|
+
onChange: c,
|
|
1435
|
+
onCompositionStart: l,
|
|
1436
|
+
onCompositionEnd: u,
|
|
1437
|
+
onBlur: d
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
//#endregion
|
|
1441
|
+
//#region src/property-panel/controls.tsx
|
|
1442
|
+
var dt = {
|
|
1443
|
+
number: Q,
|
|
1444
|
+
text: Z,
|
|
1445
|
+
textarea: ut,
|
|
1446
|
+
color: et,
|
|
1447
|
+
select: lt,
|
|
1448
|
+
boolean: Pe,
|
|
1449
|
+
pair: st,
|
|
1450
|
+
anchor: Ne,
|
|
1451
|
+
align: je,
|
|
1452
|
+
padding: ot,
|
|
1453
|
+
border: Ze,
|
|
1454
|
+
font: Qe,
|
|
1455
|
+
imageSrc: at,
|
|
1456
|
+
resourceValue: it,
|
|
1457
|
+
rowsPath: ct
|
|
1458
|
+
}, ft = (e) => e.scope === "doc", pt = (e) => e.scope === "ui" && e.branch === "anchorExpanded", mt = (e) => e.scope === "ui" && e.branch === "dataSourceSchema", ht = (e) => e.scope === "doc" || e.scope === "ui" && e.branch === "resourceStatuses", gt = (e) => e.scope === "doc" || e.scope === "ui" && e.branch === "editing";
|
|
1459
|
+
function $(e, t, n) {
|
|
1460
|
+
let r = M((t) => e.subscribe((e) => {
|
|
1461
|
+
n(e) && t();
|
|
1462
|
+
}), [e, n]), i = M(t, [e, t]);
|
|
1463
|
+
return ae(r, i);
|
|
1464
|
+
}
|
|
1465
|
+
function _t(e) {
|
|
1466
|
+
let t = $(e, () => e.store.doc, ft), n = $(e, () => e.store.ui.selection, M((t) => t.scope === "ui" && t.branch === "selection" ? (e.store.closeMerge(), !0) : t.scope === "doc", [e])), r = $(e, () => e.store.ui.anchorExpanded, pt), i = $(e, () => e.store.ui.dataSourceSchema, mt), a = $(e, () => e.store.ui.resourceStatuses, ht), o = $(e, () => e.store.ui.editing, gt), s = F(() => t !== null && n !== null ? m(t, n) : null, [t, n]), c = t, l = F(() => s !== null && n !== null ? Te(n, s) : t === null ? [] : Ee, [
|
|
1467
|
+
s,
|
|
1468
|
+
n,
|
|
1469
|
+
t
|
|
1470
|
+
]), u = F(() => n !== null && t !== null ? e.layerBoxAt(n) : null, [
|
|
1471
|
+
e,
|
|
1472
|
+
n,
|
|
1473
|
+
t
|
|
1474
|
+
]), d = F(() => i === null ? null : T(i, E(i, t, n)), [
|
|
1475
|
+
i,
|
|
1476
|
+
t,
|
|
1477
|
+
n
|
|
1478
|
+
]), p = F(() => _(t, n, i), [
|
|
1479
|
+
t,
|
|
1480
|
+
n,
|
|
1481
|
+
i
|
|
1482
|
+
]), h = F(() => y(p), [p]), v = F(() => {
|
|
1483
|
+
let e = s;
|
|
1484
|
+
return e === null || e.type !== "TableLayer" || e.template === null ? !1 : g(p, e.rowsPath);
|
|
1485
|
+
}, [s, p]), b = n?.includes("template") ?? !1, x = o !== null && n !== null && f(o.path, n), S = M((t) => {
|
|
1486
|
+
e.store.setAnchorExpanded(t);
|
|
1487
|
+
}, [e]), C = M((t) => {
|
|
1488
|
+
if (!t.data) return !1;
|
|
1489
|
+
let n = e.store.ui.editing, r = e.store.ui.selection;
|
|
1490
|
+
if (n !== null && r !== null && f(n.path, r)) return n?.expression === !0;
|
|
1491
|
+
let i = e.store.doc, a = r !== null && i !== null ? m(i, r) : null;
|
|
1492
|
+
return a !== null && "expression" in a && a.expression !== null;
|
|
1493
|
+
}, [e]), w = M((t, n, r) => {
|
|
1494
|
+
let i = e.store.doc;
|
|
1495
|
+
if (!i) return;
|
|
1496
|
+
let a = e.store.ui.selection;
|
|
1497
|
+
if (!a) {
|
|
1498
|
+
te(e, i, t, n, r);
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
let o = k(a, t.key);
|
|
1502
|
+
if (t.data) {
|
|
1503
|
+
if (C(t)) {
|
|
1504
|
+
let t = k(a, ["data", "expression"]);
|
|
1505
|
+
e.updateDataExpression(a, n, { mergeKey: t }), r && e.store.closeMerge(t);
|
|
1506
|
+
return;
|
|
1507
|
+
}
|
|
1508
|
+
e.updateData(a, n, { mergeKey: o }), r && e.store.closeMerge(o);
|
|
1509
|
+
return;
|
|
1510
|
+
}
|
|
1511
|
+
e.updateSpec(a, t.key, n, { mergeKey: o }), r && e.store.closeMerge(o);
|
|
1512
|
+
}, [e, C]), ee = M((t) => {
|
|
1513
|
+
let n = e.store.ui.selection;
|
|
1514
|
+
n && t.data && e.toggleDataMode(n);
|
|
1515
|
+
}, [e]);
|
|
1516
|
+
function te(e, t, n, r, i) {
|
|
1517
|
+
let a = n.key[0];
|
|
1518
|
+
if (a === "background") {
|
|
1519
|
+
vt(e, t, n, r, i);
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1522
|
+
if (a !== "width" && a !== "height" || typeof r != "number") return;
|
|
1523
|
+
let o = `canvas:${a}`;
|
|
1524
|
+
e.updateCanvasProp(a, r, { mergeKey: o }), i && e.store.closeMerge(o);
|
|
1525
|
+
}
|
|
1526
|
+
return {
|
|
1527
|
+
selection: n,
|
|
1528
|
+
layer: s,
|
|
1529
|
+
canvas: c,
|
|
1530
|
+
sections: l,
|
|
1531
|
+
layerBox: u,
|
|
1532
|
+
isPreviewBox: b,
|
|
1533
|
+
completionSource: d,
|
|
1534
|
+
rowsPathSource: h,
|
|
1535
|
+
rowsPathDrifted: v,
|
|
1536
|
+
resourceStatuses: a,
|
|
1537
|
+
anchorExpanded: r,
|
|
1538
|
+
contentLocked: x,
|
|
1539
|
+
editingSession: o,
|
|
1540
|
+
isDataMarked: C,
|
|
1541
|
+
commit: w,
|
|
1542
|
+
toggleDataMode: ee,
|
|
1543
|
+
setAnchorExpanded: S
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
function vt(e, t, n, r, i) {
|
|
1547
|
+
let a = n.key[1];
|
|
1548
|
+
if (a !== "color" && a !== "image") return;
|
|
1549
|
+
let o = t?.background ?? Oe, s = typeof r == "string" && r !== "" ? r : null, c = {
|
|
1550
|
+
...o,
|
|
1551
|
+
[a]: s
|
|
1552
|
+
}, l = `canvas:background.${a}`;
|
|
1553
|
+
e.updateCanvasProp("background", c, { mergeKey: l }), i && e.store.closeMerge(l);
|
|
1554
|
+
}
|
|
1555
|
+
//#endregion
|
|
1556
|
+
//#region src/property-panel/fields/ValueTypeSegmented.tsx
|
|
1557
|
+
var yt = [{
|
|
1558
|
+
value: "static",
|
|
1559
|
+
label: "静态",
|
|
1560
|
+
title: "静态值:输入的字面内容直接显示在画布上"
|
|
1561
|
+
}, {
|
|
1562
|
+
value: "expression",
|
|
1563
|
+
label: "表达式",
|
|
1564
|
+
title: "表达式值:内容为插值原文,画布显示解析镜像({{路径}} / {{$index}} / {{$root.*}})"
|
|
1565
|
+
}];
|
|
1566
|
+
function bt({ mode: e, disabled: t, onChange: n }) {
|
|
1567
|
+
function r(r) {
|
|
1568
|
+
t !== !0 && r !== e && n(r);
|
|
1569
|
+
}
|
|
1570
|
+
return /* @__PURE__ */ z("span", {
|
|
1571
|
+
className: `cn-valuetype flex h-7 shrink-0 items-stretch overflow-hidden rounded-md border border-cn-field-line bg-cn-field${t === !0 ? " opacity-60" : ""}`,
|
|
1572
|
+
role: "group",
|
|
1573
|
+
"aria-label": "取值方式",
|
|
1574
|
+
"aria-disabled": t === !0 ? "true" : void 0,
|
|
1575
|
+
children: yt.map((n, i) => /* @__PURE__ */ z("button", {
|
|
1576
|
+
type: "button",
|
|
1577
|
+
className: `cn-valuetype__option flex items-center justify-center p-0 px-1.5 text-[10px] leading-none transition-colors duration-100 focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cn-accent/40 ${i > 0 ? "border-l border-cn-field-line" : ""} ${n.value === e ? "cn-valuetype__option--active bg-cn-accent-soft text-cn-accent" : "text-cn-muted hover:text-cn-fg"}`,
|
|
1578
|
+
"aria-pressed": n.value === e,
|
|
1579
|
+
title: n.value === e ? n.title : `${n.title};点击切换`,
|
|
1580
|
+
"data-mode-static": n.value === "static" || void 0,
|
|
1581
|
+
"data-mode-expression": n.value === "expression" || void 0,
|
|
1582
|
+
disabled: t,
|
|
1583
|
+
onClick: (e) => {
|
|
1584
|
+
e.preventDefault(), r(n.value);
|
|
1585
|
+
},
|
|
1586
|
+
children: n.label
|
|
1587
|
+
}, n.value))
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
//#endregion
|
|
1591
|
+
//#region src/property-panel/PropertyField.tsx
|
|
1592
|
+
function xt(e) {
|
|
1593
|
+
let { field: t, value: n, dataMode: r, locked: i, completion: a, displays: o, hint: s, resourceStatus: c, drifted: l, onInput: u, onChange: d, onToggleMode: f, onSubCommit: p } = e, m = r === "expression", h = t.data === !0 && t.control === "textarea", g = t.control === "rowsPath", _ = t.resource === !0 || g, v = I(null), y = I(null), b = I(e);
|
|
1594
|
+
b.current = e;
|
|
1595
|
+
let x = ee({
|
|
1596
|
+
enabled: () => b.current.field.data === !0 && b.current.field.control === "textarea" && b.current.dataMode === "expression" && b.current.completion != null,
|
|
1597
|
+
pairing: () => b.current.dataMode === "expression" && b.current.field.control === "textarea",
|
|
1598
|
+
resolve: (e) => b.current.completion?.(e) ?? null,
|
|
1599
|
+
popupEl: () => y.current
|
|
1600
|
+
}), C = M((e) => {
|
|
1601
|
+
v.current = e, b.current.field.data === !0 && b.current.field.control === "textarea" && x.targetRef(e);
|
|
1602
|
+
}, [x.targetRef]), T = t.data === !0 && m && typeof n == "string" ? t.resource === !0 ? n === "" ? [] : S(n) : h ? te(n) : [] : [], E = T.length === 0 ? "" : t.resource === !0 ? re(a != null) : w(T), D = (t.resource === !0 ? m : g) && a == null && T.length === 0 ? ne : "", O = T.length > 0 || g && l === !0, k = t.control === "textarea";
|
|
1603
|
+
function A() {
|
|
1604
|
+
let e = T[0], t = v.current;
|
|
1605
|
+
e !== void 0 && t !== null && (t instanceof HTMLTextAreaElement || t instanceof HTMLInputElement) && (t.focus(), t.setSelectionRange(e.at.start, e.at.end));
|
|
1606
|
+
}
|
|
1607
|
+
let j = t.control === "pair" ? "cn-prop-field block" : "cn-prop-field grid grid-cols-[60px_minmax(0,1fr)] items-center gap-x-2 gap-y-1.5", N = t.data === !0 ? "col-span-2" : "";
|
|
1608
|
+
return /* @__PURE__ */ B(R, { children: [t.control === "pair" || t.control === "imageSrc" ? /* @__PURE__ */ B("div", {
|
|
1609
|
+
className: j,
|
|
1610
|
+
children: [/* @__PURE__ */ z(St, {
|
|
1611
|
+
field: t,
|
|
1612
|
+
value: n,
|
|
1613
|
+
dataMode: r,
|
|
1614
|
+
locked: i,
|
|
1615
|
+
completion: a,
|
|
1616
|
+
displays: o,
|
|
1617
|
+
resourceStatus: c,
|
|
1618
|
+
drifted: l,
|
|
1619
|
+
onInput: u,
|
|
1620
|
+
onChange: d,
|
|
1621
|
+
onToggleMode: f,
|
|
1622
|
+
onSubCommit: p,
|
|
1623
|
+
isExpression: m,
|
|
1624
|
+
wiresPathPicker: _,
|
|
1625
|
+
controlInvalid: O,
|
|
1626
|
+
controlClass: N,
|
|
1627
|
+
controlRef: C
|
|
1628
|
+
}), /* @__PURE__ */ z(Ct, {
|
|
1629
|
+
hint: s,
|
|
1630
|
+
expressionErrorHint: E,
|
|
1631
|
+
bindingGateHint: D,
|
|
1632
|
+
diagnosticLocatable: k,
|
|
1633
|
+
locateFirstError: A
|
|
1634
|
+
})]
|
|
1635
|
+
}) : /* @__PURE__ */ B("label", {
|
|
1636
|
+
className: j,
|
|
1637
|
+
children: [/* @__PURE__ */ z(St, {
|
|
1638
|
+
field: t,
|
|
1639
|
+
value: n,
|
|
1640
|
+
dataMode: r,
|
|
1641
|
+
locked: i,
|
|
1642
|
+
completion: a,
|
|
1643
|
+
displays: o,
|
|
1644
|
+
resourceStatus: c,
|
|
1645
|
+
drifted: l,
|
|
1646
|
+
onInput: u,
|
|
1647
|
+
onChange: d,
|
|
1648
|
+
onToggleMode: f,
|
|
1649
|
+
onSubCommit: p,
|
|
1650
|
+
isExpression: m,
|
|
1651
|
+
wiresPathPicker: _,
|
|
1652
|
+
controlInvalid: O,
|
|
1653
|
+
controlClass: N,
|
|
1654
|
+
controlRef: C
|
|
1655
|
+
}), /* @__PURE__ */ z(Ct, {
|
|
1656
|
+
hint: s,
|
|
1657
|
+
expressionErrorHint: E,
|
|
1658
|
+
bindingGateHint: D,
|
|
1659
|
+
diagnosticLocatable: k,
|
|
1660
|
+
locateFirstError: A
|
|
1661
|
+
})]
|
|
1662
|
+
}), h && /* @__PURE__ */ z(ie, {
|
|
1663
|
+
state: x.popup,
|
|
1664
|
+
onSelect: x.accept,
|
|
1665
|
+
rootRef: (e) => y.current = e
|
|
1666
|
+
})] });
|
|
1667
|
+
}
|
|
1668
|
+
function St({ field: e, value: t, dataMode: n, locked: r, completion: i, displays: a, resourceStatus: o, onInput: s, onChange: c, onToggleMode: l, onSubCommit: u, isExpression: d, wiresPathPicker: f, controlInvalid: p, controlClass: m, controlRef: h }) {
|
|
1669
|
+
let g = dt[e.control];
|
|
1670
|
+
return /* @__PURE__ */ B(R, { children: [
|
|
1671
|
+
e.control !== "pair" && /* @__PURE__ */ z("span", {
|
|
1672
|
+
className: "cn-prop-field__label shrink-0 select-none truncate text-[11px] leading-none text-cn-muted",
|
|
1673
|
+
title: e.title,
|
|
1674
|
+
children: e.label
|
|
1675
|
+
}),
|
|
1676
|
+
e.data === !0 && /* @__PURE__ */ z("span", {
|
|
1677
|
+
className: "justify-self-end",
|
|
1678
|
+
children: /* @__PURE__ */ z(bt, {
|
|
1679
|
+
mode: n ?? "static",
|
|
1680
|
+
disabled: r,
|
|
1681
|
+
onChange: () => l()
|
|
1682
|
+
})
|
|
1683
|
+
}),
|
|
1684
|
+
/* @__PURE__ */ z(g, {
|
|
1685
|
+
className: `cn-prop-field__control ${m}${d ? " cn-field--expression" : ""}${p ? " cn-field--invalid" : ""}`,
|
|
1686
|
+
field: e,
|
|
1687
|
+
modelValue: t,
|
|
1688
|
+
disabled: r,
|
|
1689
|
+
displays: e.control === "pair" ? a : void 0,
|
|
1690
|
+
dataMode: e.control === "imageSrc" || e.control === "resourceValue" ? n : void 0,
|
|
1691
|
+
source: f ? i ?? null : void 0,
|
|
1692
|
+
resourceStatus: e.control === "imageSrc" ? o : void 0,
|
|
1693
|
+
controlRef: h,
|
|
1694
|
+
onInput: s,
|
|
1695
|
+
onChange: c,
|
|
1696
|
+
onSubCommit: u
|
|
1697
|
+
})
|
|
1698
|
+
] });
|
|
1699
|
+
}
|
|
1700
|
+
function Ct({ hint: e, expressionErrorHint: t, bindingGateHint: n, diagnosticLocatable: r, locateFirstError: i }) {
|
|
1701
|
+
return /* @__PURE__ */ B(R, { children: [
|
|
1702
|
+
e !== void 0 && /* @__PURE__ */ z("span", {
|
|
1703
|
+
className: "cn-prop-field__hint col-span-2 block text-[11px] leading-4 text-cn-muted",
|
|
1704
|
+
children: e
|
|
1705
|
+
}),
|
|
1706
|
+
t !== "" && /* @__PURE__ */ z("span", {
|
|
1707
|
+
className: `cn-prop-field__hint cn-prop-field__hint--error col-span-2 block text-[11px] leading-4 text-cn-danger${r ? " cursor-pointer" : ""}`,
|
|
1708
|
+
title: r ? "点击选中出错片段" : void 0,
|
|
1709
|
+
onClick: i,
|
|
1710
|
+
children: t
|
|
1711
|
+
}),
|
|
1712
|
+
n !== "" && /* @__PURE__ */ z("span", {
|
|
1713
|
+
className: "cn-prop-field__hint col-span-2 block text-[11px] leading-4 text-cn-muted",
|
|
1714
|
+
children: n
|
|
1715
|
+
})
|
|
1716
|
+
] });
|
|
1717
|
+
}
|
|
1718
|
+
//#endregion
|
|
1719
|
+
//#region src/property-panel/PropertyPanel.tsx
|
|
1720
|
+
function wt({ editor: e }) {
|
|
1721
|
+
let t = _t(e);
|
|
1722
|
+
function n(e) {
|
|
1723
|
+
return e.control === "rowsPath" ? t.rowsPathSource : t.completionSource;
|
|
1724
|
+
}
|
|
1725
|
+
let r = F(() => {
|
|
1726
|
+
let e = t.layer === null ? t.selection === null ? De(t.canvas) : null : ke(t.layer);
|
|
1727
|
+
if (e === null) return [];
|
|
1728
|
+
let n = t.selection?.join(".") ?? "canvas", r = t.layer, i = t.resourceStatuses, a = [];
|
|
1729
|
+
for (let o of t.sections) {
|
|
1730
|
+
let s = [];
|
|
1731
|
+
for (let a of o.fields) {
|
|
1732
|
+
let o = G(e, a.key);
|
|
1733
|
+
if (!o.ok) continue;
|
|
1734
|
+
let c = t.contentLocked && a.data === !0;
|
|
1735
|
+
s.push({
|
|
1736
|
+
key: `${n}:${a.key.join(".")}`,
|
|
1737
|
+
field: a,
|
|
1738
|
+
value: o.value,
|
|
1739
|
+
dataMode: a.data === !0 ? t.isDataMarked(a) ? "expression" : "static" : void 0,
|
|
1740
|
+
locked: c,
|
|
1741
|
+
hint: c ? "内容编辑中:请在画布编辑框内修改,退出后此处更新" : a.hint !== void 0 && r !== null ? a.hint(r, i) ?? void 0 : void 0,
|
|
1742
|
+
resourceStatus: a.control === "imageSrc" && typeof o.value == "string" && o.value !== "" ? i[o.value] : void 0,
|
|
1743
|
+
drifted: a.control === "rowsPath" ? t.rowsPathDrifted : void 0
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
s.length > 0 && a.push({
|
|
1747
|
+
title: o.title,
|
|
1748
|
+
fields: s
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
return a;
|
|
1752
|
+
}, [
|
|
1753
|
+
t.layer,
|
|
1754
|
+
t.selection,
|
|
1755
|
+
t.canvas,
|
|
1756
|
+
t.sections,
|
|
1757
|
+
t.contentLocked,
|
|
1758
|
+
t.isDataMarked,
|
|
1759
|
+
t.resourceStatuses,
|
|
1760
|
+
t.rowsPathDrifted
|
|
1761
|
+
]), i = F(() => {
|
|
1762
|
+
let e = {}, n = t.layerBox, r = t.layer;
|
|
1763
|
+
if (n === null || r === null) return e;
|
|
1764
|
+
let i = /* @__PURE__ */ new Map();
|
|
1765
|
+
if (r.shape.autoWidth && i.set("autoWidth", Math.round(n.width * 100) / 100), r.shape.autoHeight && i.set("autoHeight", Math.round(n.height * 100) / 100), i.size === 0) return e;
|
|
1766
|
+
for (let n of t.sections) for (let r of n.fields) for (let n of r.items ?? []) {
|
|
1767
|
+
let a = n.auto === void 0 ? void 0 : i.get(n.auto.key.join("."));
|
|
1768
|
+
a !== void 0 && (e[W(r, n).join(".")] = {
|
|
1769
|
+
value: a,
|
|
1770
|
+
preview: t.isPreviewBox
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
return e;
|
|
1774
|
+
}, [
|
|
1775
|
+
t.layerBox,
|
|
1776
|
+
t.layer,
|
|
1777
|
+
t.sections,
|
|
1778
|
+
t.isPreviewBox
|
|
1779
|
+
]);
|
|
1780
|
+
function a() {
|
|
1781
|
+
t.setAnchorExpanded(!t.anchorExpanded);
|
|
1782
|
+
}
|
|
1783
|
+
let o = t.layer !== null, s = (() => {
|
|
1784
|
+
let e = t.layer;
|
|
1785
|
+
return e === null ? t.canvas === null ? "—" : "Canvas" : e.type;
|
|
1786
|
+
})();
|
|
1787
|
+
return /* @__PURE__ */ z("aside", {
|
|
1788
|
+
className: "cn-props flex w-[288px] shrink-0 flex-col overflow-y-auto rounded-xl border border-cn-line bg-cn-bg text-cn-fg shadow-(--cn-shadow-md)",
|
|
1789
|
+
children: /* @__PURE__ */ B(X.Provider, {
|
|
1790
|
+
value: {
|
|
1791
|
+
canUpload: e.canUpload,
|
|
1792
|
+
uploadImage: (t) => e.uploadImage(t)
|
|
1793
|
+
},
|
|
1794
|
+
children: [
|
|
1795
|
+
/* @__PURE__ */ z("header", {
|
|
1796
|
+
className: "sticky top-0 z-10 border-b border-cn-line bg-cn-bg-elevated/95 px-3.5 py-2.5 backdrop-blur-sm",
|
|
1797
|
+
children: /* @__PURE__ */ B("div", {
|
|
1798
|
+
className: "flex items-center gap-2",
|
|
1799
|
+
children: [/* @__PURE__ */ B("span", {
|
|
1800
|
+
className: "inline-flex items-center gap-1.5 rounded border border-cn-accent/25 bg-cn-accent-soft px-1.5 py-0.5 font-mono text-[10px] leading-4 text-cn-accent",
|
|
1801
|
+
children: [/* @__PURE__ */ z("i", {
|
|
1802
|
+
className: "size-1.5 rounded-full bg-cn-accent",
|
|
1803
|
+
"aria-hidden": "true"
|
|
1804
|
+
}), s]
|
|
1805
|
+
}), /* @__PURE__ */ z("span", {
|
|
1806
|
+
className: "text-[12px] font-medium tracking-wide text-cn-fg/90",
|
|
1807
|
+
children: o ? "图层属性" : "画布属性"
|
|
1808
|
+
})]
|
|
1809
|
+
})
|
|
1810
|
+
}),
|
|
1811
|
+
r.length === 0 && /* @__PURE__ */ z("p", {
|
|
1812
|
+
className: "mx-3.5 my-4 rounded-lg border border-dashed border-cn-line px-3 py-6 text-center text-[11px] leading-5 text-cn-muted",
|
|
1813
|
+
children: "打开文档后可编辑属性"
|
|
1814
|
+
}),
|
|
1815
|
+
r.map((e) => /* @__PURE__ */ B("section", {
|
|
1816
|
+
className: "cn-props__section border-b border-cn-line/70 px-3.5 py-3 last:border-b-0",
|
|
1817
|
+
children: [/* @__PURE__ */ z("h3", {
|
|
1818
|
+
className: "cn-props__section-title mb-2 text-[10px] font-semibold uppercase tracking-[0.16em] text-cn-muted",
|
|
1819
|
+
children: e.title
|
|
1820
|
+
}), /* @__PURE__ */ z("div", {
|
|
1821
|
+
className: "flex flex-col gap-2",
|
|
1822
|
+
children: e.fields.map((e) => /* @__PURE__ */ z(Tt, {
|
|
1823
|
+
item: e,
|
|
1824
|
+
panel: t,
|
|
1825
|
+
fieldCompletionSource: n,
|
|
1826
|
+
pairDisplays: i,
|
|
1827
|
+
toggleAnchorExpanded: a
|
|
1828
|
+
}, e.key))
|
|
1829
|
+
})]
|
|
1830
|
+
}, e.title))
|
|
1831
|
+
]
|
|
1832
|
+
})
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
function Tt({ item: e, panel: t, fieldCompletionSource: n, pairDisplays: r, toggleAnchorExpanded: i }) {
|
|
1836
|
+
return e.field.control === "anchor" ? /* @__PURE__ */ z(Ne, {
|
|
1837
|
+
field: e.field,
|
|
1838
|
+
modelValue: e.value,
|
|
1839
|
+
expanded: t.anchorExpanded,
|
|
1840
|
+
onToggle: i,
|
|
1841
|
+
onInput: () => void 0,
|
|
1842
|
+
onChange: (n) => t.commit(e.field, n, !0),
|
|
1843
|
+
onSubCommit: t.commit
|
|
1844
|
+
}) : /* @__PURE__ */ z(xt, {
|
|
1845
|
+
field: e.field,
|
|
1846
|
+
value: e.value,
|
|
1847
|
+
dataMode: e.dataMode,
|
|
1848
|
+
locked: e.locked,
|
|
1849
|
+
hint: e.hint,
|
|
1850
|
+
completion: n(e.field),
|
|
1851
|
+
displays: r,
|
|
1852
|
+
resourceStatus: e.resourceStatus,
|
|
1853
|
+
drifted: e.drifted,
|
|
1854
|
+
onInput: (n) => t.commit(e.field, n, !1),
|
|
1855
|
+
onChange: (n) => t.commit(e.field, n, !0),
|
|
1856
|
+
onToggleMode: () => t.toggleDataMode(e.field),
|
|
1857
|
+
onSubCommit: t.commit
|
|
1858
|
+
});
|
|
1859
|
+
}
|
|
1860
|
+
//#endregion
|
|
1861
|
+
export { X as a, xe as c, Ce as d, G as f, dt as i, Te as l, xt as n, tt as o, _t as r, Ee as s, wt as t, Se as u };
|