@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
@@ -15,14 +15,12 @@
15
15
  </template>
16
16
 
17
17
  <script lang="ts" setup>
18
- import { markRaw } from 'vue';
18
+ import { computed } from 'vue';
19
19
 
20
- import { appendValidateSuggestion } from '@tmagic/design';
21
- import { type ContainerChangeEventData, defineFormConfig, MContainer } from '@tmagic/form';
20
+ import { type ContainerChangeEventData, MContainer } from '@tmagic/form';
22
21
  import type { StyleSchema } from '@tmagic/schema';
23
22
 
24
- import BackgroundPosition from '../components/BackgroundPosition.vue';
25
- import { BackgroundNoRepeat, BackgroundRepeat, BackgroundRepeatX, BackgroundRepeatY } from '../icons/background-repeat';
23
+ import { createBackgroundConfig } from '../configs';
26
24
 
27
25
  defineProps<{
28
26
  values: Partial<StyleSchema>;
@@ -39,105 +37,7 @@ const emit = defineEmits<{
39
37
  addDiffCount: [];
40
38
  }>();
41
39
 
42
- const formConfig = defineFormConfig([
43
- {
44
- name: 'backgroundColor',
45
- text: '背景色',
46
- labelWidth: '68px',
47
- type: 'data-source-field-select',
48
- fieldConfig: {
49
- type: 'colorPicker',
50
- },
51
- rules: [
52
- {
53
- typeMatch: true,
54
- message: appendValidateSuggestion('背景色应为字符串', '请参考以下示例值:"#000000"'),
55
- },
56
- ],
57
- },
58
- {
59
- name: 'backgroundImage',
60
- text: '背景图',
61
- labelWidth: '68px',
62
- type: 'data-source-field-select',
63
- fieldConfig: {
64
- type: 'img-upload',
65
- } as any,
66
- },
67
- {
68
- name: 'backgroundSize',
69
- text: '背景尺寸',
70
- type: 'radioGroup',
71
- childType: 'button',
72
- labelWidth: '68px',
73
- options: [
74
- { value: 'auto', text: '默认', tooltip: '默认 auto' },
75
- { value: 'contain', text: '等比填充', tooltip: '等比填充 contain' },
76
- { value: 'cover', text: '等比覆盖', tooltip: '等比覆盖 cover' },
77
- ],
78
- rules: [
79
- {
80
- typeMatch: false,
81
- },
82
- {
83
- validator: ({ value, callback }) => {
84
- if (value === '' || value === null || value === undefined) {
85
- return callback();
86
- }
87
-
88
- const keywords = ['auto', 'cover', 'contain', 'inherit', 'initial', 'revert', 'unset'];
89
- // 单值:关键字 或 长度/百分比
90
- const lengthPercent = /^-?\d+(\.\d+)?(px|em|rem|ex|ch|vw|vh|vmin|vmax|cm|mm|in|pt|pc|%)$/;
91
- const singleValue = (v: string) => keywords.includes(v) || lengthPercent.test(v);
92
-
93
- const str = String(value).trim();
94
- const parts = str.split(/\s+/);
95
-
96
- // cover / contain 不能与其他值组合
97
- if (parts.length > 1 && (parts.includes('cover') || parts.includes('contain'))) {
98
- return callback('cover/contain 不能与其他值组合');
99
- }
100
-
101
- // 多值最多两个
102
- if (parts.length > 2) {
103
- return callback('backgroundSize 最多支持两个值');
104
- }
105
-
106
- // 关键字 auto 在多值场景中允许与其他长度/百分比组合
107
- if (parts.every((part) => singleValue(part))) {
108
- return callback();
109
- }
110
-
111
- return callback('backgroundSize 值不合法');
112
- },
113
- },
114
- ],
115
- },
116
- {
117
- name: 'backgroundRepeat',
118
- text: '重复显示',
119
- type: 'radioGroup',
120
- childType: 'button',
121
- labelWidth: '68px',
122
- options: [
123
- { value: 'no-repeat', icon: markRaw(BackgroundNoRepeat), tooltip: '不重复 no-repeat' },
124
- { value: 'repeat-x', icon: markRaw(BackgroundRepeatX), tooltip: '水平方向重复 repeat-x' },
125
- { value: 'repeat-y', icon: markRaw(BackgroundRepeatY), tooltip: '垂直方向重复 repeat-y' },
126
- {
127
- value: 'repeat',
128
- icon: markRaw(BackgroundRepeat),
129
- tooltip: '垂直和水平方向重复 repeat',
130
- },
131
- ],
132
- },
133
- {
134
- name: 'backgroundPosition',
135
- text: '背景定位',
136
- type: 'component',
137
- component: BackgroundPosition,
138
- labelWidth: '68px',
139
- },
140
- ]);
40
+ const formConfig = computed(() => createBackgroundConfig());
141
41
 
142
42
  const change = (value: StyleSchema, eventData: ContainerChangeEventData) => {
143
43
  emit('change', value, eventData);
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <MContainer
3
3
  :prop="prop"
4
- :config="config"
4
+ :config="borderRadiusConfig"
5
5
  :model="values"
6
6
  :last-values="lastValues"
7
7
  :is-compare="isCompare"
@@ -22,10 +22,11 @@
22
22
  </template>
23
23
 
24
24
  <script lang="ts" setup>
25
- import { type ContainerChangeEventData, defineFormItem, MContainer } from '@tmagic/form';
25
+ import { type ContainerChangeEventData, MContainer } from '@tmagic/form';
26
26
  import type { StyleSchema } from '@tmagic/schema';
27
27
 
28
28
  import Border from '../components/Border.vue';
29
+ import { borderRadiusConfig } from '../configs';
29
30
 
30
31
  defineProps<{
31
32
  values: Partial<StyleSchema>;
@@ -41,16 +42,6 @@ const emit = defineEmits<{
41
42
  addDiffCount: [];
42
43
  }>();
43
44
 
44
- const config = defineFormItem({
45
- labelWidth: '68px',
46
- name: 'borderRadius',
47
- text: '圆角',
48
- type: 'data-source-field-select',
49
- fieldConfig: {
50
- type: 'text',
51
- },
52
- });
53
-
54
45
  const change = (value: StyleSchema, eventData: ContainerChangeEventData) => {
55
46
  emit('change', value, eventData);
56
47
  };
@@ -15,15 +15,14 @@
15
15
  </template>
16
16
 
17
17
  <script lang="ts" setup>
18
- import { markRaw } from 'vue';
18
+ import { computed } from 'vue';
19
19
 
20
- import { appendValidateSuggestion } from '@tmagic/design';
21
- import { type ContainerChangeEventData, defineFormConfig, MContainer } from '@tmagic/form';
20
+ import { type ContainerChangeEventData, MContainer } from '@tmagic/form';
22
21
  import type { StyleSchema } from '@tmagic/schema';
23
22
 
24
- import { validateDataSourceFieldSelectValue } from '@editor/utils/type-match-rules';
23
+ import { validateDataSourceFieldSelect } from '@editor/utils/type-match-rules';
25
24
 
26
- import { AlignCenter, AlignLeft, AlignRight } from '../icons/text-align';
25
+ import { createFontConfig } from '../configs';
27
26
 
28
27
  defineProps<{
29
28
  values: Partial<StyleSchema>;
@@ -39,125 +38,7 @@ const emit = defineEmits<{
39
38
  addDiffCount: [];
40
39
  }>();
41
40
 
42
- const formConfig = defineFormConfig([
43
- {
44
- type: 'row',
45
- items: [
46
- {
47
- labelWidth: '68px',
48
- name: 'fontSize',
49
- text: '字号',
50
- type: 'data-source-field-select',
51
- fieldConfig: {
52
- type: 'text',
53
- },
54
- rules: [
55
- {
56
- typeMatch: true,
57
- message: appendValidateSuggestion('字号应为字符串或数字', '请参考以下示例值:24 或 "24"'),
58
- },
59
- ],
60
- },
61
- {
62
- labelWidth: '68px',
63
- name: 'lineHeight',
64
- text: '行高',
65
- type: 'data-source-field-select',
66
- fieldConfig: {
67
- type: 'text',
68
- },
69
- },
70
- ],
71
- },
72
- {
73
- name: 'fontWeight',
74
- text: '字重',
75
- labelWidth: '68px',
76
- type: 'data-source-field-select',
77
- dataSourceFieldType: ['string', 'number'],
78
- fieldConfig: {
79
- type: 'select',
80
- allowCreate: true,
81
- options: ['normal', 'bold']
82
- .concat(
83
- Array(7)
84
- .fill(1)
85
- .map((x, i) => `${i + 1}00`),
86
- )
87
- .map((item) => ({
88
- value: item,
89
- text: item,
90
- })),
91
- },
92
- rules: [
93
- {
94
- typeMatch: false,
95
- },
96
- {
97
- validator: ({ value, callback }, { config, model, prop }, mForm) => {
98
- if (value === '' || value === null || value === undefined) {
99
- return callback();
100
- }
101
-
102
- const result = validateDataSourceFieldSelectValue(
103
- value,
104
- {
105
- fieldType: 'data-source-field-select',
106
- mForm,
107
- props: { config, model, prop },
108
- },
109
- {
110
- // 字重允许 string(含可创建项)与 number(如 700)
111
- validatePlainValue: (plainValue) => {
112
- if (typeof plainValue === 'string' || (typeof plainValue === 'number' && !Number.isNaN(plainValue))) {
113
- return undefined;
114
- }
115
- return '字重应为字符串或数字';
116
- },
117
- },
118
- );
119
-
120
- if (result && typeof (result as Promise<string | undefined>).then === 'function') {
121
- (result as Promise<string | undefined>).then(
122
- (error) => callback(error),
123
- (error) => callback(error),
124
- );
125
- return;
126
- }
127
-
128
- return callback(result);
129
- },
130
- },
131
- ],
132
- },
133
- {
134
- labelWidth: '68px',
135
- name: 'color',
136
- text: '颜色',
137
- type: 'data-source-field-select',
138
- fieldConfig: {
139
- type: 'colorPicker',
140
- },
141
- rules: [
142
- {
143
- typeMatch: true,
144
- message: appendValidateSuggestion('颜色应为字符串', '请参考以下示例值:"#000000"'),
145
- },
146
- ],
147
- },
148
- {
149
- name: 'textAlign',
150
- text: '对齐',
151
- type: 'radioGroup',
152
- childType: 'button',
153
- labelWidth: '68px',
154
- options: [
155
- { value: 'left', icon: markRaw(AlignLeft), tooltip: '左对齐 row', text: '左对齐' },
156
- { value: 'center', icon: markRaw(AlignCenter), tooltip: '居中对齐 center', text: '居中对齐' },
157
- { value: 'right', icon: markRaw(AlignRight), tooltip: '右对齐 right', text: '右对齐' },
158
- ],
159
- },
160
- ]);
41
+ const formConfig = computed(() => createFontConfig(validateDataSourceFieldSelect));
161
42
 
162
43
  const change = (value: StyleSchema, eventData: ContainerChangeEventData) => {
163
44
  emit('change', value, eventData);
@@ -24,35 +24,15 @@
24
24
  </template>
25
25
 
26
26
  <script lang="ts" setup>
27
- import { markRaw } from 'vue';
27
+ import { computed } from 'vue';
28
28
 
29
29
  import { useTheme } from '@tmagic/design';
30
30
  import type { ContainerChangeEventData } from '@tmagic/form';
31
- import { defineFormConfig, MContainer } from '@tmagic/form';
31
+ import { MContainer } from '@tmagic/form';
32
32
  import type { StyleSchema } from '@tmagic/schema';
33
33
 
34
34
  import Box from '../components/Box.vue';
35
- import {
36
- AlignItemsCenter,
37
- AlignItemsFlexEnd,
38
- AlignItemsFlexStart,
39
- AlignItemsSpaceAround,
40
- AlignItemsSpaceBetween,
41
- } from '../icons/align-items';
42
- import { DisplayBlock, DisplayFlex, DisplayInline, DisplayInlineBlock, DisplayNone } from '../icons/display';
43
- import {
44
- FlexDirectionColumn,
45
- FlexDirectionColumnReverse,
46
- FlexDirectionRow,
47
- FlexDirectionRowReverse,
48
- } from '../icons/flex-direction';
49
- import {
50
- JustifyContentCenter,
51
- JustifyContentFlexEnd,
52
- JustifyContentFlexStart,
53
- JustifyContentSpaceAround,
54
- JustifyContentSpaceBetween,
55
- } from '../icons/justify-content';
35
+ import { createLayoutConfig } from '../configs';
56
36
 
57
37
  const props = defineProps<{
58
38
  values: Partial<StyleSchema>;
@@ -71,202 +51,7 @@ const emit = defineEmits<{
71
51
 
72
52
  const displayTheme = useTheme(props);
73
53
 
74
- const formConfig = defineFormConfig([
75
- {
76
- name: 'display',
77
- text: '模式',
78
- type: 'radioGroup',
79
- childType: 'button',
80
- labelWidth: '90px',
81
- iconSize: '24px',
82
- options: [
83
- {
84
- value: 'inline',
85
- icon: markRaw(DisplayInline),
86
- tooltip: '内联布局 inline',
87
- },
88
- {
89
- value: 'flex',
90
- icon: markRaw(DisplayFlex),
91
- tooltip: '弹性布局 flex',
92
- },
93
- {
94
- value: 'block',
95
- icon: markRaw(DisplayBlock),
96
- tooltip: '块级布局 block',
97
- },
98
- {
99
- value: 'inline-block',
100
- icon: markRaw(DisplayInlineBlock),
101
- tooltip: '内联块布局 inline-block',
102
- },
103
- {
104
- value: 'none',
105
- icon: markRaw(DisplayNone),
106
- tooltip: '隐藏 none',
107
- },
108
- ],
109
- },
110
- {
111
- name: 'flexDirection',
112
- text: '主轴方向',
113
- type: 'radioGroup',
114
- childType: 'button',
115
- labelWidth: '90px',
116
- iconSize: '24px',
117
- options: [
118
- { value: 'row', icon: markRaw(FlexDirectionRow), tooltip: '水平方向 起点在左侧 row' },
119
- {
120
- value: 'row-reverse',
121
- icon: markRaw(FlexDirectionRowReverse),
122
- tooltip: '水平方向 起点在右侧 row-reverse',
123
- },
124
- {
125
- value: 'column',
126
- icon: markRaw(FlexDirectionColumn),
127
- tooltip: '垂直方向 起点在上沿 column',
128
- },
129
- {
130
- value: 'column-reverse',
131
- icon: markRaw(FlexDirectionColumnReverse),
132
- tooltip: '垂直方向 起点在下沿 column-reverse',
133
- },
134
- ],
135
- display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
136
- },
137
- {
138
- name: 'justifyContent',
139
- text: '主轴对齐',
140
- type: 'radioGroup',
141
- childType: 'button',
142
- labelWidth: '90px',
143
- iconSize: '24px',
144
- options: [
145
- { value: 'flex-start', icon: markRaw(JustifyContentFlexStart), tooltip: '左对齐 flex-start' },
146
- { value: 'flex-end', icon: markRaw(JustifyContentFlexEnd), tooltip: '右对齐 flex-end' },
147
- { value: 'center', icon: markRaw(JustifyContentCenter), tooltip: '居中 center' },
148
- {
149
- value: 'space-between',
150
- icon: markRaw(JustifyContentSpaceBetween),
151
- tooltip: '两端对齐 space-between',
152
- },
153
- {
154
- value: 'space-around',
155
- icon: markRaw(JustifyContentSpaceAround),
156
- tooltip: '横向平分 space-around',
157
- },
158
- ],
159
- display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
160
- },
161
- {
162
- name: 'alignItems',
163
- text: '辅轴对齐',
164
- type: 'radioGroup',
165
- childType: 'button',
166
- labelWidth: '90px',
167
- iconSize: '24px',
168
- options: [
169
- { value: 'flex-start', icon: markRaw(AlignItemsFlexStart), tooltip: '左对齐 flex-start' },
170
- { value: 'flex-end', icon: markRaw(AlignItemsFlexEnd), tooltip: '右对齐 flex-end' },
171
- { value: 'center', icon: markRaw(AlignItemsCenter), tooltip: '居中 center' },
172
- {
173
- value: 'space-between',
174
- icon: markRaw(AlignItemsSpaceBetween),
175
- tooltip: '两端对齐 space-between',
176
- },
177
- {
178
- value: 'space-around',
179
- icon: markRaw(AlignItemsSpaceAround),
180
- tooltip: '横向平分 space-around',
181
- },
182
- ],
183
- display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
184
- },
185
- {
186
- name: 'flexWrap',
187
- text: '换行',
188
- type: 'radioGroup',
189
- childType: displayTheme.value !== 'magic-admin' ? 'button' : 'default',
190
- labelWidth: '90px',
191
- iconSize: '24px',
192
- options: [
193
- { value: 'nowrap', text: '不换行', tooltip: '不换行 nowrap' },
194
- { value: 'wrap', text: '正换行', tooltip: '第一行在上方 wrap' },
195
- { value: 'wrap-reverse', text: '逆换行', tooltip: '第一行在下方 wrap-reverse' },
196
- ],
197
- display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
198
- },
199
- {
200
- type: 'row',
201
- items: [
202
- {
203
- name: 'width',
204
- text: '宽度(px)',
205
- labelWidth: '90px',
206
- type: 'data-source-field-select',
207
- fieldConfig: {
208
- type: 'text',
209
- },
210
- },
211
- ],
212
- },
213
- {
214
- type: 'row',
215
- items: [
216
- {
217
- name: 'height',
218
- text: '高度(px)',
219
- labelWidth: '90px',
220
- type: 'data-source-field-select',
221
- fieldConfig: {
222
- type: 'text',
223
- },
224
- },
225
- ],
226
- },
227
- {
228
- type: 'row',
229
- items: [
230
- {
231
- type: 'data-source-field-select',
232
- text: 'overflow',
233
- name: 'overflow',
234
- labelWidth: '90px',
235
- checkStrictly: false,
236
- dataSourceFieldType: ['string'],
237
- fieldConfig: {
238
- type: 'select',
239
- clearable: true,
240
- allowCreate: true,
241
- options: [
242
- { text: 'visible', value: 'visible' },
243
- { text: 'hidden', value: 'hidden' },
244
- { text: 'clip', value: 'clip' },
245
- { text: 'scroll', value: 'scroll' },
246
- { text: 'auto', value: 'auto' },
247
- { text: 'overlay', value: 'overlay' },
248
- { text: 'initial', value: 'initial' },
249
- ],
250
- },
251
- },
252
- ],
253
- },
254
- {
255
- type: 'row',
256
- items: [
257
- {
258
- type: 'data-source-field-select',
259
- text: '透明度(%)',
260
- name: 'opacity',
261
- labelWidth: '90px',
262
- dataSourceFieldType: ['string', 'number'],
263
- fieldConfig: {
264
- type: 'text',
265
- },
266
- },
267
- ],
268
- },
269
- ]);
54
+ const formConfig = computed(() => createLayoutConfig(displayTheme.value));
270
55
 
271
56
  const change = (value: string | StyleSchema, eventData: ContainerChangeEventData) => {
272
57
  emit('change', value, eventData);
@@ -15,10 +15,13 @@
15
15
  </template>
16
16
 
17
17
  <script lang="ts" setup>
18
- import { appendValidateSuggestion } from '@tmagic/design';
19
- import { type ContainerChangeEventData, defineFormConfig, MContainer } from '@tmagic/form';
18
+ import { computed } from 'vue';
19
+
20
+ import { type ContainerChangeEventData, MContainer } from '@tmagic/form';
20
21
  import type { StyleSchema } from '@tmagic/schema';
21
22
 
23
+ import { createPositionConfig } from '../configs';
24
+
22
25
  const props = defineProps<{
23
26
  values: Partial<StyleSchema>;
24
27
  lastValues?: Partial<StyleSchema>;
@@ -33,114 +36,7 @@ const emit = defineEmits<{
33
36
  addDiffCount: [];
34
37
  }>();
35
38
 
36
- const positionText: Record<string, string> = {
37
- static: '不定位',
38
- relative: '相对定位',
39
- absolute: '绝对定位',
40
- fixed: '固定定位',
41
- sticky: '粘性定位',
42
- };
43
-
44
- const formConfig = defineFormConfig([
45
- {
46
- name: 'position',
47
- text: '定位',
48
- labelWidth: '68px',
49
- type: 'data-source-field-select',
50
- fieldConfig: {
51
- type: 'select',
52
- options: Object.keys(positionText).map((item) => ({
53
- value: item,
54
- text: `${item}(${positionText[item]})`,
55
- })),
56
- },
57
- },
58
- {
59
- type: 'row',
60
- labelWidth: '68px',
61
- display: () => props.values.position !== 'static',
62
- items: [
63
- {
64
- name: 'left',
65
- type: 'data-source-field-select',
66
- text: 'left',
67
- fieldConfig: {
68
- type: 'text',
69
- },
70
- rules: [
71
- {
72
- typeMatch: true,
73
- message: appendValidateSuggestion('left 应为字符串', '请参考以下示例值:"10"'),
74
- },
75
- ],
76
- },
77
- {
78
- name: 'top',
79
- type: 'data-source-field-select',
80
- text: 'top',
81
- fieldConfig: {
82
- type: 'text',
83
- },
84
- rules: [
85
- {
86
- typeMatch: true,
87
- message: appendValidateSuggestion('top 应为字符串', '请参考以下示例值:"10"'),
88
- },
89
- ],
90
- },
91
- ],
92
- },
93
- {
94
- type: 'row',
95
- labelWidth: '68px',
96
- display: () => props.values.position !== 'static',
97
- items: [
98
- {
99
- name: 'right',
100
- type: 'data-source-field-select',
101
- text: 'right',
102
- fieldConfig: {
103
- type: 'text',
104
- },
105
- rules: [
106
- {
107
- typeMatch: true,
108
- message: appendValidateSuggestion('right 应为字符串', '请参考以下示例值:"10"'),
109
- },
110
- ],
111
- },
112
- {
113
- name: 'bottom',
114
- type: 'data-source-field-select',
115
- text: 'bottom',
116
- fieldConfig: {
117
- type: 'text',
118
- },
119
- rules: [
120
- {
121
- typeMatch: true,
122
- message: appendValidateSuggestion('bottom 应为字符串', '请参考以下示例值:"10"'),
123
- },
124
- ],
125
- },
126
- ],
127
- },
128
- {
129
- labelWidth: '68px',
130
- name: 'zIndex',
131
- text: 'zIndex',
132
- type: 'data-source-field-select',
133
- fieldConfig: {
134
- type: 'text',
135
- },
136
- rules: [
137
- {
138
- typeMatch: true,
139
- message: appendValidateSuggestion('zIndex 应为数字', '请参考以下示例值:10'),
140
- },
141
- ],
142
- },
143
- ]);
39
+ const formConfig = computed(() => createPositionConfig(props.values));
144
40
 
145
41
  const change = (value: string | StyleSchema, eventData: ContainerChangeEventData) => {
146
42
  emit('change', value, eventData);