@tmagic/form 1.3.8 → 1.3.10

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.8",
2
+ "version": "1.3.10",
3
3
  "name": "@tmagic/form",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@element-plus/icons-vue": "^2.3.1",
35
- "@tmagic/design": "1.3.8",
36
- "@tmagic/utils": "1.3.8",
35
+ "@tmagic/design": "1.3.10",
36
+ "@tmagic/utils": "1.3.10",
37
37
  "lodash-es": "^4.17.21",
38
38
  "sortablejs": "^1.14.0",
39
39
  "vue": "^3.3.8"
@@ -212,7 +212,7 @@
212
212
  </template>
213
213
 
214
214
  <div style="text-align: center" v-if="config.expand && type !== 'fieldset'">
215
- <TMagicButton type="primary" size="small" :disabled="false" text @click="expandHandler">{{
215
+ <TMagicButton type="primary" size="small" :disabled="false" link @click="expandHandler">{{
216
216
  expand ? '收起配置' : '展开更多配置'
217
217
  }}</TMagicButton>
218
218
  </div>
@@ -312,6 +312,7 @@ const type = computed((): string => {
312
312
  });
313
313
  }
314
314
  if (type === 'form') return '';
315
+ if (type === 'container') return '';
315
316
  return type?.replace(/([A-Z])/g, '-$1').toLowerCase() || (items.value ? '' : 'text');
316
317
  });
317
318
 
@@ -1,24 +1,24 @@
1
1
  <template>
2
2
  <div class="m-fields-group-list-item">
3
3
  <div>
4
- <TMagicButton text :disabled="disabled" :icon="expand ? CaretBottom : CaretRight" @click="expandHandler">{{
4
+ <TMagicButton link :disabled="disabled" :icon="expand ? CaretBottom : CaretRight" @click="expandHandler">{{
5
5
  title
6
6
  }}</TMagicButton>
7
7
 
8
8
  <TMagicButton
9
9
  v-show="showDelete(parseInt(String(index)))"
10
10
  style="color: #f56c6c"
11
- text
11
+ link
12
12
  :icon="Delete"
13
13
  :disabled="disabled"
14
14
  @click="removeHandler"
15
15
  ></TMagicButton>
16
16
 
17
17
  <template v-if="movable()">
18
- <TMagicButton v-show="index !== 0" text :disabled="disabled" size="small" @click="changeOrder(-1)"
18
+ <TMagicButton v-show="index !== 0" link :disabled="disabled" size="small" @click="changeOrder(-1)"
19
19
  >上移<TMagicIcon><CaretTop /></TMagicIcon
20
20
  ></TMagicButton>
21
- <TMagicButton v-show="index !== length - 1" :disabled="disabled" text size="small" @click="changeOrder(1)"
21
+ <TMagicButton v-show="index !== length - 1" :disabled="disabled" link size="small" @click="changeOrder(1)"
22
22
  >下移<TMagicIcon><CaretBottom /></TMagicIcon
23
23
  ></TMagicButton>
24
24
  </template>
@@ -6,7 +6,7 @@
6
6
  >
7
7
  <template #header>
8
8
  <div style="width: 100%; display: flex; align-items: center">
9
- <TMagicButton style="padding: 0" text :icon="expand ? CaretBottom : CaretRight" @click="expand = !expand">
9
+ <TMagicButton style="padding: 0" link :icon="expand ? CaretBottom : CaretRight" @click="expand = !expand">
10
10
  </TMagicButton>
11
11
  <span v-if="config && config.extra" v-html="config.extra" class="m-form-tip"></span>
12
12
  <slot name="header">{{ filter(config.title) }}</slot>
@@ -1,182 +1,190 @@
1
1
  <template>
2
- <teleport to="body" :disabled="!isFullscreen">
3
- <div ref="mTable" class="m-fields-table" :class="{ 'm-fields-table-item-extra': config.itemExtra }">
4
- <span v-if="config.extra" style="color: rgba(0, 0, 0, 0.45)" v-html="config.extra"></span>
5
- <TMagicTooltip content="拖拽可排序" placement="left-start" :disabled="config.dropSort !== true">
6
- <TMagicTable
7
- v-if="model[modelName]"
8
- ref="tMagicTable"
9
- style="width: 100%"
10
- :row-key="config.rowKey || 'id'"
11
- :data="data"
12
- :lastData="lastData"
13
- :border="config.border"
14
- :max-height="config.maxHeight"
15
- :default-expand-all="true"
16
- :key="updateKey"
17
- @select="selectHandle"
18
- @sort-change="sortChange"
19
- >
20
- <TMagicTableColumn v-if="config.itemExtra" :fixed="'left'" width="30" type="expand">
21
- <template v-slot="scope">
22
- <span v-html="itemExtra(config.itemExtra, scope.$index)" class="m-form-tip"></span>
23
- </template>
24
- </TMagicTableColumn>
25
-
26
- <TMagicTableColumn
27
- label="操作"
28
- :width="config.operateColWidth || 55"
29
- align="center"
30
- :fixed="config.fixed === false ? undefined : 'left'"
2
+ <div class="m-fields-table-wrap">
3
+ <teleport to="body" :disabled="!isFullscreen">
4
+ <div ref="mTable" class="m-fields-table" :class="{ 'm-fields-table-item-extra': config.itemExtra }">
5
+ <span v-if="config.extra" style="color: rgba(0, 0, 0, 0.45)" v-html="config.extra"></span>
6
+ <TMagicTooltip content="拖拽可排序" placement="left-start" :disabled="config.dropSort !== true">
7
+ <TMagicTable
8
+ v-if="model[modelName]"
9
+ ref="tMagicTable"
10
+ style="width: 100%"
11
+ :row-key="config.rowKey || 'id'"
12
+ :data="data"
13
+ :lastData="lastData"
14
+ :border="config.border"
15
+ :max-height="config.maxHeight"
16
+ :default-expand-all="true"
17
+ :key="updateKey"
18
+ @select="selectHandle"
19
+ @sort-change="sortChange"
31
20
  >
32
- <template v-slot="scope">
33
- <slot name="operateCol" :scope="scope"></slot>
34
- <TMagicIcon
35
- v-show="showDelete(scope.$index + 1 + pagecontext * pagesize - 1)"
36
- class="m-table-delete-icon"
37
- @click="removeHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
38
- ><Delete
39
- /></TMagicIcon>
40
- </template>
41
- </TMagicTableColumn>
42
-
43
- <TMagicTableColumn v-if="sort && model[modelName] && model[modelName].length > 1" label="排序" width="60">
44
- <template v-slot="scope">
45
- <TMagicTooltip
46
- v-if="scope.$index + 1 + pagecontext * pagesize - 1 !== 0"
47
- content="点击上移,双击置顶"
48
- placement="top"
49
- >
50
- <TMagicButton
51
- plain
52
- size="small"
53
- type="primary"
54
- :icon="ArrowUp"
55
- :disabled="disabled"
56
- text
57
- @click="upHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
58
- @dblclick="topHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
59
- ></TMagicButton>
60
- </TMagicTooltip>
61
- <TMagicTooltip
62
- v-if="scope.$index + 1 + pagecontext * pagesize - 1 !== model[modelName].length - 1"
63
- content="点击下移,双击置底"
64
- placement="top"
65
- >
66
- <TMagicButton
67
- plain
68
- size="small"
69
- type="primary"
70
- :icon="ArrowDown"
71
- :disabled="disabled"
72
- text
73
- @click="downHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
74
- @dblclick="bottomHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
75
- ></TMagicButton>
76
- </TMagicTooltip>
77
- </template>
78
- </TMagicTableColumn>
79
-
80
- <TMagicTableColumn
81
- v-if="selection"
82
- align="center"
83
- header-align="center"
84
- type="selection"
85
- width="45"
86
- ></TMagicTableColumn>
87
-
88
- <TMagicTableColumn width="60" label="序号" v-if="showIndex && config.showIndex">
89
- <template v-slot="scope">{{ scope.$index + 1 + pagecontext * pagesize }}</template>
90
- </TMagicTableColumn>
21
+ <TMagicTableColumn v-if="config.itemExtra" :fixed="'left'" width="30" type="expand">
22
+ <template v-slot="scope">
23
+ <span v-html="itemExtra(config.itemExtra, scope.$index)" class="m-form-tip"></span>
24
+ </template>
25
+ </TMagicTableColumn>
91
26
 
92
- <template v-for="(column, index) in config.items">
93
27
  <TMagicTableColumn
94
- v-if="column.type !== 'hidden' && display(column.display)"
95
- :prop="column.name"
96
- :width="column.width"
97
- :label="column.label"
98
- :sortable="column.sortable"
99
- :sort-orders="['ascending', 'descending']"
100
- :key="column[mForm?.keyProp || '__key'] ?? index"
101
- :class-name="config.dropSort === true ? 'el-table__column--dropable' : ''"
28
+ label="操作"
29
+ :width="config.operateColWidth || 55"
30
+ align="center"
31
+ :fixed="config.fixed === false ? undefined : 'left'"
102
32
  >
103
- <template #default="scope">
104
- <Container
105
- v-if="scope.$index > -1"
106
- labelWidth="0"
107
- :disabled="disabled"
108
- :prop="getProp(scope.$index)"
109
- :rules="column.rules"
110
- :config="makeConfig(column, scope.row)"
111
- :model="scope.row"
112
- :lastValues="lastData[scope.$index]"
113
- :is-compare="isCompare"
114
- :size="size"
115
- @change="$emit('change', model[modelName])"
116
- @addDiffCount="onAddDiffCount()"
117
- ></Container>
33
+ <template v-slot="scope">
34
+ <slot name="operateCol" :scope="scope"></slot>
35
+ <TMagicIcon
36
+ v-show="showDelete(scope.$index + 1 + pagecontext * pagesize - 1)"
37
+ class="m-table-delete-icon"
38
+ @click="removeHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
39
+ ><Delete
40
+ /></TMagicIcon>
118
41
  </template>
119
42
  </TMagicTableColumn>
120
- </template>
121
- </TMagicTable>
122
- </TMagicTooltip>
123
- <slot></slot>
124
-
125
- <div style="display: flex; justify-content: space-between; margin: 10px 0">
126
- <TMagicButton v-if="addable" size="small" type="primary" :disabled="disabled" plain @click="newHandler()"
127
- >新增一行</TMagicButton
128
- >
129
-
130
- <div style="display: flex">
131
- <TMagicButton
132
- :icon="Grid"
133
- size="small"
134
- type="primary"
135
- @click="toggleMode"
136
- v-if="enableToggleMode && config.enableToggleMode !== false && !isFullscreen"
137
- >展开配置</TMagicButton
138
- >
139
- <TMagicButton
140
- :icon="FullScreen"
141
- size="small"
142
- type="primary"
143
- @click="toggleFullscreen"
144
- v-if="config.enableFullscreen !== false"
145
- >
146
- {{ isFullscreen ? '退出全屏' : '全屏编辑' }}
147
- </TMagicButton>
148
- <TMagicUpload
149
- v-if="importable"
150
- style="display: inline-block"
151
- ref="excelBtn"
152
- action="/noop"
153
- :disabled="disabled"
154
- :on-change="excelHandler"
155
- :auto-upload="false"
156
- >
157
- <TMagicButton size="small" type="success" :disabled="disabled" plain>导入EXCEL</TMagicButton>
158
- </TMagicUpload>
159
- <TMagicButton v-if="importable" size="small" type="warning" :disabled="disabled" plain @click="clearHandler()"
160
- >清空</TMagicButton
43
+
44
+ <TMagicTableColumn v-if="sort && model[modelName] && model[modelName].length > 1" label="排序" width="60">
45
+ <template v-slot="scope">
46
+ <TMagicTooltip
47
+ v-if="scope.$index + 1 + pagecontext * pagesize - 1 !== 0"
48
+ content="点击上移,双击置顶"
49
+ placement="top"
50
+ >
51
+ <TMagicButton
52
+ plain
53
+ size="small"
54
+ type="primary"
55
+ :icon="ArrowUp"
56
+ :disabled="disabled"
57
+ link
58
+ @click="upHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
59
+ @dblclick="topHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
60
+ ></TMagicButton>
61
+ </TMagicTooltip>
62
+ <TMagicTooltip
63
+ v-if="scope.$index + 1 + pagecontext * pagesize - 1 !== model[modelName].length - 1"
64
+ content="点击下移,双击置底"
65
+ placement="top"
66
+ >
67
+ <TMagicButton
68
+ plain
69
+ size="small"
70
+ type="primary"
71
+ :icon="ArrowDown"
72
+ :disabled="disabled"
73
+ link
74
+ @click="downHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
75
+ @dblclick="bottomHandler(scope.$index + 1 + pagecontext * pagesize - 1)"
76
+ ></TMagicButton>
77
+ </TMagicTooltip>
78
+ </template>
79
+ </TMagicTableColumn>
80
+
81
+ <TMagicTableColumn
82
+ v-if="selection"
83
+ align="center"
84
+ header-align="center"
85
+ type="selection"
86
+ width="45"
87
+ ></TMagicTableColumn>
88
+
89
+ <TMagicTableColumn width="60" label="序号" v-if="showIndex && config.showIndex">
90
+ <template v-slot="scope">{{ scope.$index + 1 + pagecontext * pagesize }}</template>
91
+ </TMagicTableColumn>
92
+
93
+ <template v-for="(column, index) in config.items">
94
+ <TMagicTableColumn
95
+ v-if="column.type !== 'hidden' && display(column.display)"
96
+ :prop="column.name"
97
+ :width="column.width"
98
+ :label="column.label"
99
+ :sortable="column.sortable"
100
+ :sort-orders="['ascending', 'descending']"
101
+ :key="column[mForm?.keyProp || '__key'] ?? index"
102
+ :class-name="config.dropSort === true ? 'el-table__column--dropable' : ''"
103
+ >
104
+ <template #default="scope">
105
+ <Container
106
+ v-if="scope.$index > -1"
107
+ labelWidth="0"
108
+ :disabled="disabled"
109
+ :prop="getProp(scope.$index)"
110
+ :rules="column.rules"
111
+ :config="makeConfig(column, scope.row)"
112
+ :model="scope.row"
113
+ :lastValues="lastData[scope.$index]"
114
+ :is-compare="isCompare"
115
+ :size="size"
116
+ @change="$emit('change', model[modelName])"
117
+ @addDiffCount="onAddDiffCount()"
118
+ ></Container>
119
+ </template>
120
+ </TMagicTableColumn>
121
+ </template>
122
+ </TMagicTable>
123
+ </TMagicTooltip>
124
+ <slot></slot>
125
+
126
+ <div style="display: flex; justify-content: space-between; margin: 10px 0">
127
+ <TMagicButton v-if="addable" size="small" type="primary" :disabled="disabled" plain @click="newHandler()"
128
+ >新增一行</TMagicButton
161
129
  >
130
+
131
+ <div style="display: flex">
132
+ <TMagicButton
133
+ :icon="Grid"
134
+ size="small"
135
+ type="primary"
136
+ @click="toggleMode"
137
+ v-if="enableToggleMode && config.enableToggleMode !== false && !isFullscreen"
138
+ >展开配置</TMagicButton
139
+ >
140
+ <TMagicButton
141
+ :icon="FullScreen"
142
+ size="small"
143
+ type="primary"
144
+ @click="toggleFullscreen"
145
+ v-if="config.enableFullscreen !== false"
146
+ >
147
+ {{ isFullscreen ? '退出全屏' : '全屏编辑' }}
148
+ </TMagicButton>
149
+ <TMagicUpload
150
+ v-if="importable"
151
+ style="display: inline-block"
152
+ ref="excelBtn"
153
+ action="/noop"
154
+ :disabled="disabled"
155
+ :on-change="excelHandler"
156
+ :auto-upload="false"
157
+ >
158
+ <TMagicButton size="small" type="success" :disabled="disabled" plain>导入EXCEL</TMagicButton>
159
+ </TMagicUpload>
160
+ <TMagicButton
161
+ v-if="importable"
162
+ size="small"
163
+ type="warning"
164
+ :disabled="disabled"
165
+ plain
166
+ @click="clearHandler()"
167
+ >清空</TMagicButton
168
+ >
169
+ </div>
162
170
  </div>
163
- </div>
164
171
 
165
- <div class="bottom" style="text-align: right" v-if="config.pagination">
166
- <TMagicPagination
167
- layout="total, sizes, prev, pager, next, jumper"
168
- :hide-on-single-page="model[modelName].length < pagesize"
169
- :current-page="pagecontext + 1"
170
- :page-sizes="[pagesize, 60, 120, 300]"
171
- :page-size="pagesize"
172
- :total="model[modelName].length"
173
- @size-change="handleSizeChange"
174
- @current-change="handleCurrentChange"
175
- >
176
- </TMagicPagination>
172
+ <div class="bottom" style="text-align: right" v-if="config.pagination">
173
+ <TMagicPagination
174
+ layout="total, sizes, prev, pager, next, jumper"
175
+ :hide-on-single-page="model[modelName].length < pagesize"
176
+ :current-page="pagecontext + 1"
177
+ :page-sizes="[pagesize, 60, 120, 300]"
178
+ :page-size="pagesize"
179
+ :total="model[modelName].length"
180
+ @size-change="handleSizeChange"
181
+ @current-change="handleCurrentChange"
182
+ >
183
+ </TMagicPagination>
184
+ </div>
177
185
  </div>
178
- </div>
179
- </teleport>
186
+ </teleport>
187
+ </div>
180
188
  </template>
181
189
 
182
190
  <script setup lang="ts">
@@ -194,6 +202,7 @@ import {
194
202
  TMagicTableColumn,
195
203
  TMagicTooltip,
196
204
  TMagicUpload,
205
+ useZIndex,
197
206
  } from '@tmagic/design';
198
207
  import { asyncLoadJs, sleep } from '@tmagic/utils';
199
208
 
@@ -238,6 +247,8 @@ const emit = defineEmits(['change', 'select', 'addDiffCount']);
238
247
  let timer: any | null = null;
239
248
  const mForm = inject<FormState | undefined>('mForm');
240
249
 
250
+ const { nextZIndex } = useZIndex();
251
+
241
252
  const tMagicTable = ref<InstanceType<typeof TMagicTable>>();
242
253
  const excelBtn = ref<InstanceType<typeof TMagicUpload>>();
243
254
  const mTable = ref<HTMLDivElement>();
@@ -612,11 +623,14 @@ const toggleMode = () => {
612
623
  };
613
624
 
614
625
  const toggleFullscreen = () => {
626
+ if (!mTable.value) return;
627
+
615
628
  if (isFullscreen.value) {
616
- mTable.value?.classList.remove('fixed');
629
+ mTable.value.classList.remove('fixed');
617
630
  isFullscreen.value = false;
618
631
  } else {
619
- mTable.value?.classList.add('fixed');
632
+ mTable.value.classList.add('fixed');
633
+ mTable.value.style.zIndex = `${nextZIndex()}`;
620
634
  isFullscreen.value = true;
621
635
  }
622
636
  };
@@ -2,7 +2,7 @@
2
2
  <a v-if="config.href && !disabled" target="_blank" :href="href" :style="config.css || {}">{{ displayText }}</a>
3
3
  <span v-else-if="config.href && disabled" :style="config.disabledCss || {}">{{ displayText }}</span>
4
4
  <div v-else class="m-fields-link">
5
- <TMagicButton :text="true" type="primary" @click="editHandler">点击编辑</TMagicButton>
5
+ <TMagicButton link type="primary" @click="editHandler">点击编辑</TMagicButton>
6
6
  <FormDialog
7
7
  ref="editor"
8
8
  :title="config.formTitle || '编辑扩展配置'"
@@ -1,32 +1,43 @@
1
1
  <template>
2
- <TMagicInput
3
- v-model="model[name]"
4
- clearable
5
- :size="size"
6
- :placeholder="config.placeholder"
7
- :disabled="disabled"
8
- @change="changeHandler"
9
- @input="inputHandler"
10
- @keyup="keyUpHandler($event)"
11
- >
12
- <template #append v-if="config.append">
13
- <span v-if="typeof config.append === 'string'">{{ config.append }}</span>
14
- <TMagicButton
15
- v-if="typeof config.append === 'object' && config.append.type === 'button'"
16
- style="color: #409eff"
2
+ <TMagicPopover :visible="popoverVisible" width="220px">
3
+ <template #reference>
4
+ <TMagicInput
5
+ v-model="model[name]"
6
+ clearable
17
7
  :size="size"
18
- @click.prevent="buttonClickHandler"
8
+ :placeholder="config.placeholder"
9
+ :disabled="disabled"
10
+ @change="changeHandler"
11
+ @input="inputHandler"
12
+ @keyup="keyUpHandler($event)"
19
13
  >
20
- {{ config.append.text }}
21
- </TMagicButton>
14
+ <template #append v-if="appendConfig">
15
+ <TMagicButton
16
+ v-if="appendConfig.type === 'button'"
17
+ style="color: #409eff"
18
+ :size="size"
19
+ @click.prevent="buttonClickHandler"
20
+ >
21
+ {{ appendConfig.text }}
22
+ </TMagicButton>
23
+ </template>
24
+ </TMagicInput>
22
25
  </template>
23
- </TMagicInput>
26
+
27
+ <div class="m-form-item__content">
28
+ <div class="m-form-validate__warning">输入内容前后有空格,是否移除空格?</div>
29
+ <div style="display: flex; justify-content: flex-end">
30
+ <TMagicButton type="text" size="small" @click="popoverVisible = false">保持原样</TMagicButton>
31
+ <TMagicButton type="primary" size="small" @click="confirmTrimHandler">移除空格</TMagicButton>
32
+ </div>
33
+ </div>
34
+ </TMagicPopover>
24
35
  </template>
25
36
 
26
37
  <script lang="ts" setup>
27
- import { inject } from 'vue';
38
+ import { computed, inject, ref } from 'vue';
28
39
 
29
- import { TMagicButton, TMagicInput } from '@tmagic/design';
40
+ import { TMagicButton, TMagicInput, TMagicPopover } from '@tmagic/design';
30
41
  import { isNumber } from '@tmagic/utils';
31
42
 
32
43
  import type { FieldProps, FormState, TextConfig } from '../schema';
@@ -47,20 +58,53 @@ useAddField(props.prop);
47
58
 
48
59
  const mForm = inject<FormState | undefined>('mForm');
49
60
 
61
+ const appendConfig = computed(() => {
62
+ if (typeof props.config.append === 'string') {
63
+ return {
64
+ text: props.config.append,
65
+ type: 'button',
66
+ handler: undefined,
67
+ };
68
+ }
69
+
70
+ if (props.config.append && typeof props.config.append === 'object') {
71
+ if (props.config.append.value === 0) {
72
+ return false;
73
+ }
74
+
75
+ return props.config.append;
76
+ }
77
+
78
+ return false;
79
+ });
80
+
81
+ const popoverVisible = ref(false);
82
+
83
+ const confirmTrimHandler = () => {
84
+ emit('change', props.model[props.name].trim() || '');
85
+ popoverVisible.value = false;
86
+ };
87
+
88
+ const checkWhiteSpace = (value: unknown) => {
89
+ if (typeof value === 'string' && !props.config.trim) {
90
+ popoverVisible.value = value.trim() !== value;
91
+ }
92
+ };
93
+
50
94
  const changeHandler = (value: string) => {
51
95
  emit('change', value);
52
96
  };
53
97
 
54
98
  const inputHandler = (v: string) => {
99
+ checkWhiteSpace(v);
55
100
  emit('input', v);
56
101
  mForm?.$emit('field-input', props.prop, v);
57
102
  };
58
103
 
59
104
  const buttonClickHandler = () => {
60
- if (typeof props.config.append === 'string') return;
61
-
62
- if (props.config.append?.handler) {
63
- props.config.append.handler(mForm, {
105
+ if (!appendConfig.value) return;
106
+ if (typeof appendConfig.value.handler === 'function') {
107
+ appendConfig.value.handler(mForm, {
64
108
  model: props.model,
65
109
  values: mForm?.values,
66
110
  });
package/src/index.ts CHANGED
@@ -49,6 +49,7 @@ import Timerange from './fields/Timerange.vue';
49
49
  import { setConfig } from './utils/config';
50
50
  import Form from './Form.vue';
51
51
  import FormDialog from './FormDialog.vue';
52
+ import type { FormConfig } from './schema';
52
53
 
53
54
  import './theme/index.scss';
54
55
 
@@ -88,6 +89,10 @@ export { default as MSelect } from './fields/Select.vue';
88
89
  export { default as MCascader } from './fields/Cascader.vue';
89
90
  export { default as MDynamicField } from './fields/DynamicField.vue';
90
91
 
92
+ export const createForm = function (config: FormConfig) {
93
+ return config;
94
+ };
95
+
91
96
  export interface InstallOptions {
92
97
  [key: string]: any;
93
98
  }
package/src/schema.ts CHANGED
@@ -320,8 +320,9 @@ export interface TextConfig extends FormItem, Input {
320
320
  | string
321
321
  | {
322
322
  text: string;
323
+ value?: 0 | 1;
323
324
  type: 'button';
324
- handler: (
325
+ handler?: (
325
326
  mForm: FormState | undefined,
326
327
  data: {
327
328
  model: any;
@@ -2,6 +2,7 @@
2
2
  @use "./form-drawer.scss";
3
3
  @use "./form.scss";
4
4
  @use "./date-time.scss";
5
+ @use "./text.scss";
5
6
  @use "./link.scss";
6
7
  @use "./fieldset.scss";
7
8
  @use "./group-list.scss";
@@ -1,3 +1,7 @@
1
+ .m-fields-table-wrap {
2
+ width: 100%;
3
+ }
4
+
1
5
  .m-fields-table {
2
6
  width: 100%;
3
7
  &.fixed {