@tmagic/editor 1.8.0-beta.24 → 1.8.0-beta.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/es/Editor.vue_vue_type_script_setup_true_lang.js +10 -16
  2. package/dist/es/components/CodeParams.vue_vue_type_script_setup_true_lang.js +4 -4
  3. package/dist/es/components/CompareForm.vue_vue_type_script_setup_true_lang.js +5 -8
  4. package/dist/es/components/ViewForm.vue_vue_type_script_setup_true_lang.js +3 -5
  5. package/dist/es/fields/Code.vue_vue_type_script_setup_true_lang.js +3 -11
  6. package/dist/es/fields/CodeSelect.vue_vue_type_script_setup_true_lang.js +29 -124
  7. package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +5 -6
  8. package/dist/es/fields/CondOpSelect.vue_vue_type_script_setup_true_lang.js +3 -2
  9. package/dist/es/fields/DataSourceFieldSelect/FieldSelect.vue_vue_type_script_setup_true_lang.js +1 -1
  10. package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +7 -6
  11. package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +6 -10
  12. package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +5 -7
  13. package/dist/es/fields/DataSourceMethods.vue_vue_type_script_setup_true_lang.js +1 -4
  14. package/dist/es/fields/DataSourceMocks.vue_vue_type_script_setup_true_lang.js +4 -6
  15. package/dist/es/fields/DataSourceSelect.vue_vue_type_script_setup_true_lang.js +1 -1
  16. package/dist/es/fields/DisplayConds.vue_vue_type_script_setup_true_lang.js +9 -137
  17. package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +51 -326
  18. package/dist/es/fields/KeyValue.vue_vue_type_script_setup_true_lang.js +2 -4
  19. package/dist/es/fields/StyleSetter/components/Border.vue_vue_type_script_setup_true_lang.js +3 -34
  20. package/dist/es/fields/StyleSetter/configs.js +663 -0
  21. package/dist/es/fields/StyleSetter/pro/Background.vue_vue_type_script_setup_true_lang.js +5 -108
  22. package/dist/es/fields/StyleSetter/pro/Border.vue_vue_type_script_setup_true_lang.js +3 -9
  23. package/dist/es/fields/StyleSetter/pro/Font.vue_vue_type_script_setup_true_lang.js +6 -103
  24. package/dist/es/fields/StyleSetter/pro/Layout.vue_vue_type_script_setup_true_lang.js +5 -265
  25. package/dist/es/fields/StyleSetter/pro/Position.vue_vue_type_script_setup_true_lang.js +5 -85
  26. package/dist/es/fields/StyleSetter/pro/Transform.vue_vue_type_script_setup_true_lang.js +3 -22
  27. package/dist/es/fields/configs/codeSelect.js +98 -0
  28. package/dist/es/fields/configs/displayConds.js +158 -0
  29. package/dist/es/fields/configs/eventSelect.js +225 -0
  30. package/dist/es/fields/configs/stickyAddButton.js +20 -0
  31. package/dist/es/fields/headless-validation.js +139 -0
  32. package/dist/es/headless.js +2 -0
  33. package/dist/es/hooks/use-compare-form.js +6 -23
  34. package/dist/es/hooks/use-form-context.js +19 -0
  35. package/dist/es/index.js +3 -2
  36. package/dist/es/initService.js +17 -1
  37. package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js +1 -7
  38. package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +1 -11
  39. package/dist/es/layouts/history-list/useHistoryRevert.js +3 -11
  40. package/dist/es/layouts/props-panel/FormPanel.vue_vue_type_script_setup_true_lang.js +10 -23
  41. package/dist/es/layouts/props-panel/PropsPanel.vue_vue_type_script_setup_true_lang.js +3 -13
  42. package/dist/es/layouts/sidebar/code-block/CodeBlockListPanel.vue_vue_type_script_setup_true_lang.js +1 -1
  43. package/dist/es/layouts/sidebar/code-block/useContentMenu.js +1 -1
  44. package/dist/es/layouts/sidebar/data-source/DataSourceListPanel.vue_vue_type_script_setup_true_lang.js +1 -1
  45. package/dist/es/layouts/sidebar/data-source/useContentMenu.js +1 -1
  46. package/dist/es/plugin.js +33 -32
  47. package/dist/es/style.css +120 -60
  48. package/dist/es/utils/data-source/index.js +2 -1
  49. package/dist/es/utils/props.js +1 -4
  50. package/dist/es/utils/type-match-rules.js +23 -22
  51. package/dist/style.css +120 -60
  52. package/dist/themes/magic-admin.css +132 -67
  53. package/dist/tmagic-editor-headless.umd.cjs +10867 -0
  54. package/dist/tmagic-editor.umd.cjs +2151 -2034
  55. package/package.json +12 -7
  56. package/src/Editor.vue +12 -16
  57. package/src/components/CodeParams.vue +10 -4
  58. package/src/components/CompareForm.vue +4 -5
  59. package/src/components/ViewForm.vue +2 -3
  60. package/src/editorProps.ts +1 -2
  61. package/src/fields/Code.vue +2 -10
  62. package/src/fields/CodeSelect.vue +20 -116
  63. package/src/fields/CodeSelectCol.vue +3 -5
  64. package/src/fields/CondOpSelect.vue +3 -2
  65. package/src/fields/DataSourceFieldSelect/FieldSelect.vue +1 -1
  66. package/src/fields/DataSourceFieldSelect/Index.vue +7 -6
  67. package/src/fields/DataSourceFields.vue +0 -7
  68. package/src/fields/DataSourceMethodSelect.vue +2 -5
  69. package/src/fields/DataSourceMethods.vue +1 -6
  70. package/src/fields/DataSourceMocks.vue +1 -10
  71. package/src/fields/DataSourceSelect.vue +1 -1
  72. package/src/fields/DisplayConds.vue +17 -153
  73. package/src/fields/EventSelect.vue +28 -375
  74. package/src/fields/KeyValue.vue +3 -4
  75. package/src/fields/StyleSetter/components/Border.vue +4 -38
  76. package/src/fields/StyleSetter/configs.ts +690 -0
  77. package/src/fields/StyleSetter/pro/Background.vue +4 -104
  78. package/src/fields/StyleSetter/pro/Border.vue +3 -12
  79. package/src/fields/StyleSetter/pro/Font.vue +5 -124
  80. package/src/fields/StyleSetter/pro/Layout.vue +4 -219
  81. package/src/fields/StyleSetter/pro/Position.vue +6 -110
  82. package/src/fields/StyleSetter/pro/Transform.vue +4 -30
  83. package/src/fields/configs/codeSelect.ts +127 -0
  84. package/src/fields/configs/displayConds.ts +184 -0
  85. package/src/fields/configs/eventSelect.ts +309 -0
  86. package/src/fields/configs/stickyAddButton.ts +31 -0
  87. package/src/fields/headless-validation.ts +177 -0
  88. package/src/headless.ts +33 -0
  89. package/src/hooks/use-compare-form.ts +7 -25
  90. package/src/hooks/use-form-context.ts +40 -0
  91. package/src/index.ts +2 -0
  92. package/src/initService.ts +23 -1
  93. package/src/layouts/history-list/HistoryDiffDialog.vue +0 -10
  94. package/src/layouts/history-list/HistoryListPanel.vue +1 -13
  95. package/src/layouts/history-list/useHistoryRevert.ts +7 -13
  96. package/src/layouts/props-panel/FormPanel.vue +17 -28
  97. package/src/layouts/props-panel/PropsPanel.vue +1 -4
  98. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +1 -1
  99. package/src/layouts/sidebar/code-block/useContentMenu.ts +1 -1
  100. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +1 -1
  101. package/src/layouts/sidebar/data-source/useContentMenu.ts +1 -1
  102. package/src/plugin.ts +32 -33
  103. package/src/theme/code-block.scss +0 -37
  104. package/src/theme/display-conds.scss +4 -0
  105. package/src/theme/event.scss +22 -45
  106. package/src/theme/props-panel.scss +17 -3
  107. package/src/theme/themes/magic-admin/index.scss +12 -1
  108. package/src/type.ts +10 -29
  109. package/src/utils/data-source/index.ts +1 -0
  110. package/src/utils/props.ts +1 -4
  111. package/src/utils/type-match-rules.ts +37 -31
  112. package/types/headless.d.ts +18 -0
  113. package/types/index.d.ts +155 -180
@@ -0,0 +1,663 @@
1
+ import BackgroundPosition_default from "./components/BackgroundPosition.js";
2
+ import Center_default from "./icons/align-items/Center.js";
3
+ import FlexEnd_default from "./icons/align-items/FlexEnd.js";
4
+ import FlexStart_default from "./icons/align-items/FlexStart.js";
5
+ import SpaceAround_default from "./icons/align-items/SpaceAround.js";
6
+ import SpaceBetween_default from "./icons/align-items/SpaceBetween.js";
7
+ import Repeat_default from "./icons/background-repeat/Repeat.js";
8
+ import RepeatX_default from "./icons/background-repeat/RepeatX.js";
9
+ import RepeatY_default from "./icons/background-repeat/RepeatY.js";
10
+ import NoRepeat_default from "./icons/background-repeat/NoRepeat.js";
11
+ import Block_default from "./icons/display/Block.js";
12
+ import Flex_default from "./icons/display/Flex.js";
13
+ import Inline_default from "./icons/display/Inline.js";
14
+ import InlineBlock_default from "./icons/display/InlineBlock.js";
15
+ import None_default from "./icons/display/None.js";
16
+ import Column_default from "./icons/flex-direction/Column.js";
17
+ import ColumnReverse_default from "./icons/flex-direction/ColumnReverse.js";
18
+ import Row_default from "./icons/flex-direction/Row.js";
19
+ import RowReverse_default from "./icons/flex-direction/RowReverse.js";
20
+ import Center_default$1 from "./icons/justify-content/Center.js";
21
+ import FlexEnd_default$1 from "./icons/justify-content/FlexEnd.js";
22
+ import FlexStart_default$1 from "./icons/justify-content/FlexStart.js";
23
+ import SpaceAround_default$1 from "./icons/justify-content/SpaceAround.js";
24
+ import SpaceBetween_default$1 from "./icons/justify-content/SpaceBetween.js";
25
+ import Left_default from "./icons/text-align/Left.js";
26
+ import Center_default$2 from "./icons/text-align/Center.js";
27
+ import Right_default from "./icons/text-align/Right.js";
28
+ import { markRaw } from "vue";
29
+ import { appendValidateSuggestion } from "@tmagic/design/headless";
30
+ import { defineFormItem } from "@tmagic/form/headless";
31
+ //#region packages/editor/src/fields/StyleSetter/configs.ts
32
+ /**
33
+ * 「布局」面板配置。
34
+ *
35
+ * `theme` 需要由调用方从 `useTheme()` 解析后传入:magic-admin 主题下换行只能用普通
36
+ * radio,其余主题用 button。
37
+ */
38
+ var createLayoutConfig = (theme) => [
39
+ defineFormItem({
40
+ name: "display",
41
+ text: "模式",
42
+ type: "radioGroup",
43
+ childType: "button",
44
+ labelWidth: "90px",
45
+ iconSize: "24px",
46
+ options: [
47
+ {
48
+ value: "inline",
49
+ icon: markRaw(Inline_default),
50
+ tooltip: "内联布局 inline"
51
+ },
52
+ {
53
+ value: "flex",
54
+ icon: markRaw(Flex_default),
55
+ tooltip: "弹性布局 flex"
56
+ },
57
+ {
58
+ value: "block",
59
+ icon: markRaw(Block_default),
60
+ tooltip: "块级布局 block"
61
+ },
62
+ {
63
+ value: "inline-block",
64
+ icon: markRaw(InlineBlock_default),
65
+ tooltip: "内联块布局 inline-block"
66
+ },
67
+ {
68
+ value: "none",
69
+ icon: markRaw(None_default),
70
+ tooltip: "隐藏 none"
71
+ }
72
+ ]
73
+ }),
74
+ defineFormItem({
75
+ name: "flexDirection",
76
+ text: "主轴方向",
77
+ type: "radioGroup",
78
+ childType: "button",
79
+ labelWidth: "90px",
80
+ iconSize: "24px",
81
+ options: [
82
+ {
83
+ value: "row",
84
+ icon: markRaw(Row_default),
85
+ tooltip: "水平方向 起点在左侧 row"
86
+ },
87
+ {
88
+ value: "row-reverse",
89
+ icon: markRaw(RowReverse_default),
90
+ tooltip: "水平方向 起点在右侧 row-reverse"
91
+ },
92
+ {
93
+ value: "column",
94
+ icon: markRaw(Column_default),
95
+ tooltip: "垂直方向 起点在上沿 column"
96
+ },
97
+ {
98
+ value: "column-reverse",
99
+ icon: markRaw(ColumnReverse_default),
100
+ tooltip: "垂直方向 起点在下沿 column-reverse"
101
+ }
102
+ ],
103
+ display: (_mForm, { model }) => model.display === "flex"
104
+ }),
105
+ defineFormItem({
106
+ name: "justifyContent",
107
+ text: "主轴对齐",
108
+ type: "radioGroup",
109
+ childType: "button",
110
+ labelWidth: "90px",
111
+ iconSize: "24px",
112
+ options: [
113
+ {
114
+ value: "flex-start",
115
+ icon: markRaw(FlexStart_default$1),
116
+ tooltip: "左对齐 flex-start"
117
+ },
118
+ {
119
+ value: "flex-end",
120
+ icon: markRaw(FlexEnd_default$1),
121
+ tooltip: "右对齐 flex-end"
122
+ },
123
+ {
124
+ value: "center",
125
+ icon: markRaw(Center_default$1),
126
+ tooltip: "居中 center"
127
+ },
128
+ {
129
+ value: "space-between",
130
+ icon: markRaw(SpaceBetween_default$1),
131
+ tooltip: "两端对齐 space-between"
132
+ },
133
+ {
134
+ value: "space-around",
135
+ icon: markRaw(SpaceAround_default$1),
136
+ tooltip: "横向平分 space-around"
137
+ }
138
+ ],
139
+ display: (_mForm, { model }) => model.display === "flex"
140
+ }),
141
+ defineFormItem({
142
+ name: "alignItems",
143
+ text: "辅轴对齐",
144
+ type: "radioGroup",
145
+ childType: "button",
146
+ labelWidth: "90px",
147
+ iconSize: "24px",
148
+ options: [
149
+ {
150
+ value: "flex-start",
151
+ icon: markRaw(FlexStart_default),
152
+ tooltip: "左对齐 flex-start"
153
+ },
154
+ {
155
+ value: "flex-end",
156
+ icon: markRaw(FlexEnd_default),
157
+ tooltip: "右对齐 flex-end"
158
+ },
159
+ {
160
+ value: "center",
161
+ icon: markRaw(Center_default),
162
+ tooltip: "居中 center"
163
+ },
164
+ {
165
+ value: "space-between",
166
+ icon: markRaw(SpaceBetween_default),
167
+ tooltip: "两端对齐 space-between"
168
+ },
169
+ {
170
+ value: "space-around",
171
+ icon: markRaw(SpaceAround_default),
172
+ tooltip: "横向平分 space-around"
173
+ }
174
+ ],
175
+ display: (_mForm, { model }) => model.display === "flex"
176
+ }),
177
+ defineFormItem({
178
+ name: "flexWrap",
179
+ text: "换行",
180
+ type: "radioGroup",
181
+ childType: theme !== "magic-admin" ? "button" : "default",
182
+ labelWidth: "90px",
183
+ iconSize: "24px",
184
+ options: [
185
+ {
186
+ value: "nowrap",
187
+ text: "不换行",
188
+ tooltip: "不换行 nowrap"
189
+ },
190
+ {
191
+ value: "wrap",
192
+ text: "正换行",
193
+ tooltip: "第一行在上方 wrap"
194
+ },
195
+ {
196
+ value: "wrap-reverse",
197
+ text: "逆换行",
198
+ tooltip: "第一行在下方 wrap-reverse"
199
+ }
200
+ ],
201
+ display: (_mForm, { model }) => model.display === "flex"
202
+ }),
203
+ defineFormItem({
204
+ type: "row",
205
+ items: [{
206
+ name: "width",
207
+ text: "宽度(px)",
208
+ labelWidth: "90px",
209
+ type: "data-source-field-select",
210
+ fieldConfig: { type: "text" }
211
+ }]
212
+ }),
213
+ defineFormItem({
214
+ type: "row",
215
+ items: [{
216
+ name: "height",
217
+ text: "高度(px)",
218
+ labelWidth: "90px",
219
+ type: "data-source-field-select",
220
+ fieldConfig: { type: "text" }
221
+ }]
222
+ }),
223
+ defineFormItem({
224
+ type: "row",
225
+ items: [{
226
+ type: "data-source-field-select",
227
+ text: "overflow",
228
+ name: "overflow",
229
+ labelWidth: "90px",
230
+ checkStrictly: false,
231
+ dataSourceFieldType: ["string"],
232
+ fieldConfig: {
233
+ type: "select",
234
+ clearable: true,
235
+ allowCreate: true,
236
+ options: [
237
+ {
238
+ text: "visible",
239
+ value: "visible"
240
+ },
241
+ {
242
+ text: "hidden",
243
+ value: "hidden"
244
+ },
245
+ {
246
+ text: "clip",
247
+ value: "clip"
248
+ },
249
+ {
250
+ text: "scroll",
251
+ value: "scroll"
252
+ },
253
+ {
254
+ text: "auto",
255
+ value: "auto"
256
+ },
257
+ {
258
+ text: "overlay",
259
+ value: "overlay"
260
+ },
261
+ {
262
+ text: "initial",
263
+ value: "initial"
264
+ }
265
+ ]
266
+ }
267
+ }]
268
+ }),
269
+ defineFormItem({
270
+ type: "row",
271
+ items: [{
272
+ type: "data-source-field-select",
273
+ text: "透明度(%)",
274
+ name: "opacity",
275
+ labelWidth: "90px",
276
+ dataSourceFieldType: ["string", "number"],
277
+ fieldConfig: { type: "text" }
278
+ }]
279
+ })
280
+ ];
281
+ var positionText = {
282
+ static: "不定位",
283
+ relative: "相对定位",
284
+ absolute: "绝对定位",
285
+ fixed: "固定定位",
286
+ sticky: "粘性定位"
287
+ };
288
+ /**
289
+ * 「位置」面板配置。
290
+ *
291
+ * `values` 是当前 style 的 model:left/top/right/bottom 的 display 在求值时读取
292
+ * `values.position`,所以必须传入响应式对象本身,不能先解构。
293
+ */
294
+ var createPositionConfig = (values) => [
295
+ defineFormItem({
296
+ name: "position",
297
+ text: "定位",
298
+ labelWidth: "68px",
299
+ type: "data-source-field-select",
300
+ fieldConfig: {
301
+ type: "select",
302
+ options: Object.keys(positionText).map((item) => ({
303
+ value: item,
304
+ text: `${item}(${positionText[item]})`
305
+ }))
306
+ }
307
+ }),
308
+ defineFormItem({
309
+ type: "row",
310
+ labelWidth: "68px",
311
+ display: () => values.position !== "static",
312
+ items: [{
313
+ name: "left",
314
+ type: "data-source-field-select",
315
+ text: "left",
316
+ fieldConfig: { type: "text" },
317
+ rules: [{
318
+ typeMatch: true,
319
+ message: appendValidateSuggestion("left 应为字符串", "请参考以下示例值:\"10\"")
320
+ }]
321
+ }, {
322
+ name: "top",
323
+ type: "data-source-field-select",
324
+ text: "top",
325
+ fieldConfig: { type: "text" },
326
+ rules: [{
327
+ typeMatch: true,
328
+ message: appendValidateSuggestion("top 应为字符串", "请参考以下示例值:\"10\"")
329
+ }]
330
+ }]
331
+ }),
332
+ defineFormItem({
333
+ type: "row",
334
+ labelWidth: "68px",
335
+ display: () => values.position !== "static",
336
+ items: [{
337
+ name: "right",
338
+ type: "data-source-field-select",
339
+ text: "right",
340
+ fieldConfig: { type: "text" },
341
+ rules: [{
342
+ typeMatch: true,
343
+ message: appendValidateSuggestion("right 应为字符串", "请参考以下示例值:\"10\"")
344
+ }]
345
+ }, {
346
+ name: "bottom",
347
+ type: "data-source-field-select",
348
+ text: "bottom",
349
+ fieldConfig: { type: "text" },
350
+ rules: [{
351
+ typeMatch: true,
352
+ message: appendValidateSuggestion("bottom 应为字符串", "请参考以下示例值:\"10\"")
353
+ }]
354
+ }]
355
+ }),
356
+ defineFormItem({
357
+ labelWidth: "68px",
358
+ name: "zIndex",
359
+ text: "zIndex",
360
+ type: "data-source-field-select",
361
+ fieldConfig: { type: "text" },
362
+ rules: [{
363
+ typeMatch: true,
364
+ message: appendValidateSuggestion("zIndex 应为数字", "请参考以下示例值:10")
365
+ }]
366
+ })
367
+ ];
368
+ /**
369
+ * 「背景」面板配置。
370
+ *
371
+ * 校验文案由 `@tmagic/design` 的 `appendValidateSuggestion` 生成,必须延迟到调用时
372
+ * 才执行,不能在模块顶层求值:本模块会被大量组件间接引入,而 design 层在部分场景下
373
+ * 才可用。
374
+ */
375
+ var createBackgroundConfig = () => [
376
+ defineFormItem({
377
+ name: "backgroundColor",
378
+ text: "背景色",
379
+ labelWidth: "68px",
380
+ type: "data-source-field-select",
381
+ fieldConfig: { type: "colorPicker" },
382
+ rules: [{
383
+ typeMatch: true,
384
+ message: appendValidateSuggestion("背景色应为字符串", "请参考以下示例值:\"#000000\"")
385
+ }]
386
+ }),
387
+ defineFormItem({
388
+ name: "backgroundImage",
389
+ text: "背景图",
390
+ labelWidth: "68px",
391
+ type: "data-source-field-select",
392
+ fieldConfig: { type: "img-upload" }
393
+ }),
394
+ defineFormItem({
395
+ name: "backgroundSize",
396
+ text: "背景尺寸",
397
+ type: "radioGroup",
398
+ childType: "button",
399
+ labelWidth: "68px",
400
+ options: [
401
+ {
402
+ value: "auto",
403
+ text: "默认",
404
+ tooltip: "默认 auto"
405
+ },
406
+ {
407
+ value: "contain",
408
+ text: "等比填充",
409
+ tooltip: "等比填充 contain"
410
+ },
411
+ {
412
+ value: "cover",
413
+ text: "等比覆盖",
414
+ tooltip: "等比覆盖 cover"
415
+ }
416
+ ],
417
+ rules: [{ typeMatch: false }, { validator: ({ value, callback }) => {
418
+ if (value === "" || value === null || value === void 0) return callback();
419
+ const keywords = [
420
+ "auto",
421
+ "cover",
422
+ "contain",
423
+ "inherit",
424
+ "initial",
425
+ "revert",
426
+ "unset"
427
+ ];
428
+ const lengthPercent = /^-?\d+(\.\d+)?(px|em|rem|ex|ch|vw|vh|vmin|vmax|cm|mm|in|pt|pc|%)$/;
429
+ const singleValue = (v) => keywords.includes(v) || lengthPercent.test(v);
430
+ const parts = String(value).trim().split(/\s+/);
431
+ if (parts.length > 1 && (parts.includes("cover") || parts.includes("contain"))) return callback("cover/contain 不能与其他值组合");
432
+ if (parts.length > 2) return callback("backgroundSize 最多支持两个值");
433
+ if (parts.every((part) => singleValue(part))) return callback();
434
+ return callback("backgroundSize 值不合法");
435
+ } }]
436
+ }),
437
+ defineFormItem({
438
+ name: "backgroundRepeat",
439
+ text: "重复显示",
440
+ type: "radioGroup",
441
+ childType: "button",
442
+ labelWidth: "68px",
443
+ options: [
444
+ {
445
+ value: "no-repeat",
446
+ icon: markRaw(NoRepeat_default),
447
+ tooltip: "不重复 no-repeat"
448
+ },
449
+ {
450
+ value: "repeat-x",
451
+ icon: markRaw(RepeatX_default),
452
+ tooltip: "水平方向重复 repeat-x"
453
+ },
454
+ {
455
+ value: "repeat-y",
456
+ icon: markRaw(RepeatY_default),
457
+ tooltip: "垂直方向重复 repeat-y"
458
+ },
459
+ {
460
+ value: "repeat",
461
+ icon: markRaw(Repeat_default),
462
+ tooltip: "垂直和水平方向重复 repeat"
463
+ }
464
+ ]
465
+ }),
466
+ defineFormItem({
467
+ name: "backgroundPosition",
468
+ text: "背景定位",
469
+ type: "component",
470
+ component: BackgroundPosition_default,
471
+ labelWidth: "68px"
472
+ })
473
+ ];
474
+ /**
475
+ * 「文字」面板配置。
476
+ *
477
+ * 字重校验依赖编辑器服务(数据源/代码块),由调用方把 `type-match-rules` 的
478
+ * `validateDataSourceFieldSelect` 传进来:本模块只描述配置,不直接引用服务层,
479
+ * 否则会把整条服务依赖链拖进所有引用方。
480
+ */
481
+ var createFontConfig = (validateDataSourceField) => [
482
+ defineFormItem({
483
+ type: "row",
484
+ items: [{
485
+ labelWidth: "68px",
486
+ name: "fontSize",
487
+ text: "字号",
488
+ type: "data-source-field-select",
489
+ fieldConfig: { type: "text" },
490
+ rules: [{
491
+ typeMatch: true,
492
+ message: appendValidateSuggestion("字号应为字符串或数字", "请参考以下示例值:24 或 \"24\"")
493
+ }]
494
+ }, {
495
+ labelWidth: "68px",
496
+ name: "lineHeight",
497
+ text: "行高",
498
+ type: "data-source-field-select",
499
+ fieldConfig: { type: "text" }
500
+ }]
501
+ }),
502
+ defineFormItem({
503
+ name: "fontWeight",
504
+ text: "字重",
505
+ labelWidth: "68px",
506
+ type: "data-source-field-select",
507
+ dataSourceFieldType: ["string", "number"],
508
+ fieldConfig: {
509
+ type: "select",
510
+ allowCreate: true,
511
+ options: ["normal", "bold"].concat(Array(7).fill(1).map((x, i) => `${i + 1}00`)).map((item) => ({
512
+ value: item,
513
+ text: item
514
+ }))
515
+ },
516
+ rules: [{ typeMatch: false }, { validator: ({ value, callback }, { config, model, prop }, mForm) => {
517
+ if (value === "" || value === null || value === void 0) return callback();
518
+ const result = validateDataSourceField(value, {
519
+ fieldType: "data-source-field-select",
520
+ mForm,
521
+ props: {
522
+ config,
523
+ model,
524
+ prop
525
+ }
526
+ }, { validatePlainValue: (plainValue) => {
527
+ if (typeof plainValue === "string" || typeof plainValue === "number" && !Number.isNaN(plainValue)) return;
528
+ return "字重应为字符串或数字";
529
+ } });
530
+ if (result && typeof result.then === "function") {
531
+ result.then((error) => callback(error), (error) => callback(error));
532
+ return;
533
+ }
534
+ return callback(result);
535
+ } }]
536
+ }),
537
+ defineFormItem({
538
+ labelWidth: "68px",
539
+ name: "color",
540
+ text: "颜色",
541
+ type: "data-source-field-select",
542
+ fieldConfig: { type: "colorPicker" },
543
+ rules: [{
544
+ typeMatch: true,
545
+ message: appendValidateSuggestion("颜色应为字符串", "请参考以下示例值:\"#000000\"")
546
+ }]
547
+ }),
548
+ defineFormItem({
549
+ name: "textAlign",
550
+ text: "对齐",
551
+ type: "radioGroup",
552
+ childType: "button",
553
+ labelWidth: "68px",
554
+ options: [
555
+ {
556
+ value: "left",
557
+ icon: markRaw(Left_default),
558
+ tooltip: "左对齐 row",
559
+ text: "左对齐"
560
+ },
561
+ {
562
+ value: "center",
563
+ icon: markRaw(Center_default$2),
564
+ tooltip: "居中对齐 center",
565
+ text: "居中对齐"
566
+ },
567
+ {
568
+ value: "right",
569
+ icon: markRaw(Right_default),
570
+ tooltip: "右对齐 right",
571
+ text: "右对齐"
572
+ }
573
+ ]
574
+ })
575
+ ];
576
+ /** 「边框与圆角」面板中圆角部分的配置,边框四向配置见 `createBorderDirectionConfig`。 */
577
+ var borderRadiusConfig = defineFormItem({
578
+ labelWidth: "68px",
579
+ name: "borderRadius",
580
+ text: "圆角",
581
+ type: "data-source-field-select",
582
+ fieldConfig: { type: "text" }
583
+ });
584
+ /** 「变形」面板配置。 */
585
+ var transformConfig = defineFormItem({
586
+ name: "transform",
587
+ items: [{
588
+ name: "rotate",
589
+ text: "旋转角度",
590
+ labelWidth: "68px",
591
+ type: "data-source-field-select",
592
+ checkStrictly: false,
593
+ dataSourceFieldType: ["string", "number"],
594
+ fieldConfig: { type: "text" }
595
+ }, {
596
+ name: "scale",
597
+ text: "缩放",
598
+ labelWidth: "68px",
599
+ type: "data-source-field-select",
600
+ checkStrictly: false,
601
+ dataSourceFieldType: ["string", "number"],
602
+ fieldConfig: { type: "text" }
603
+ }]
604
+ });
605
+ /**
606
+ * 把 6 个样式面板里会向父表单注册 FormItem 的配置按 `Index.vue` 的面板顺序拼成一份。
607
+ *
608
+ * 给无渲染校验的嵌套配置用:组件侧仍按面板各自渲染,这份合成配置只描述「父表单上
609
+ * 实际会出现哪些字段」。以下两处与组件一致、不纳入:
610
+ * - Layout 里的 Box(margin/padding)是裸 input,没有 MContainer;
611
+ * - Border 子组件的四向边框 MContainer 没传 `:prop`(路径从父表单脱落,本轮不修)。
612
+ *
613
+ * `theme` 只影响 flexWrap 的 UI `childType`,不影响校验字段。
614
+ */
615
+ var createStyleSetterConfig = (values, theme, validateDataSourceField) => [
616
+ ...createLayoutConfig(theme),
617
+ ...createPositionConfig(values),
618
+ ...createBackgroundConfig(),
619
+ ...createFontConfig(validateDataSourceField),
620
+ borderRadiusConfig,
621
+ transformConfig
622
+ ];
623
+ /**
624
+ * 边框配置,按当前选中的方向拼字段名。
625
+ *
626
+ * `direction` 取 ''(四向) / 'Top' / 'Right' / 'Bottom' / 'Left',空串对应
627
+ * `borderWidth` 这类不带方向的字段。
628
+ */
629
+ var createBorderDirectionConfig = (direction) => defineFormItem({ items: [
630
+ {
631
+ name: `border${direction}Width`,
632
+ text: "边框宽度",
633
+ labelWidth: "68px",
634
+ type: "data-source-field-select",
635
+ fieldConfig: { type: "text" }
636
+ },
637
+ {
638
+ name: `border${direction}Color`,
639
+ text: "边框颜色",
640
+ labelWidth: "68px",
641
+ type: "data-source-field-select",
642
+ fieldConfig: { type: "colorPicker" }
643
+ },
644
+ {
645
+ name: `border${direction}Style`,
646
+ text: "边框样式",
647
+ labelWidth: "68px",
648
+ type: "data-source-field-select",
649
+ fieldConfig: {
650
+ type: "select",
651
+ options: [
652
+ "solid",
653
+ "dashed",
654
+ "dotted"
655
+ ].map((item) => ({
656
+ value: item,
657
+ text: item
658
+ }))
659
+ }
660
+ }
661
+ ] });
662
+ //#endregion
663
+ export { borderRadiusConfig, createBackgroundConfig, createBorderDirectionConfig, createFontConfig, createLayoutConfig, createPositionConfig, createStyleSetterConfig, transformConfig };