@neatui/nuxt 1.5.4 → 1.6.0

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.
@@ -1,399 +0,0 @@
1
- <template>
2
- <div class="form-loader n-sm-sub" :data-level="level" ui-row="">
3
- <template v-for="(node, i1) in $nodes" :key="i1">
4
- <div v-if="!node.clear" :key="i1" class="form-loader-item" :class="node.model[0] === 'Blank' ? 'form-loader-item-none n-no' : ''" :id="node._fid" :ui-col="node.media">
5
- <!-- 字段外部上面插入其它内容 -->
6
- <div class="flex-fixed" v-if="node.other && node.other.mt" v-bind="node.other.mt.attrs">
7
- <template v-for="(item, idx) in node?.other?.mt?.child || []">
8
- <div
9
- v-if="!item.clear"
10
- :key="idx"
11
- v-html="item.value"
12
- v-bind="item.attrs"
13
- v-on="event({ col: item, node, data: data[node.field], idx: i1, fun: { fAdd, fDel, _rows } })"
14
- ></div>
15
- </template>
16
- </div>
17
- <div class="flex-block" ui-flex="row lt">
18
- <!-- 字段外部左边插入其他内容 -->
19
- <div class="flex-fixed" v-if="node.other && node.other.ml" v-bind="node.other.ml.attrs">
20
- <template v-for="(item, idx) in node?.other?.ml?.child || []">
21
- <div
22
- v-if="!item.clear"
23
- :key="idx"
24
- v-html="item.value"
25
- v-bind="item.attrs"
26
- v-on="event({ col: item, node, data: data[node.field], idx: i1, fun: { fAdd, fDel, _rows } })"
27
- ></div>
28
- </template>
29
- </div>
30
- <!-- 字段主体 -->
31
- <div class="flex-block">
32
- <div
33
- :id="`form${index + '' ? '-' + index : ''}-field-${node.field || '*'}`"
34
- v-bind="node.attrs"
35
- v-on="event({ col: node, node, data, idx: i1, fun: { fAdd, fDel, _rows } })"
36
- :data-level="level"
37
- data-node="child"
38
- >
39
- <slot :name="node.field" :node="node" :data="data">
40
- <div
41
- v-if="node.label[0] !== '*'"
42
- :class="`form-loader-label ${node.vertical ? 'flex-block' : 'flex-fixed nr-sm'} o-ls nt-ss`"
43
- :style="labelcss(node)"
44
- ui-flex="row xm"
45
- >
46
- <slot v-if="slots.includes(`${node.field}-label`)" :name="`${node.field}-label`"></slot>
47
- <slot v-else name="every-label" :node="node" :data="data">
48
- <template v-if="node.label[0]">
49
- <h6 class="flex-block pr o-lm" style="padding-top: 2px" v-if="node.vertical" v-bind="node.label[1]">
50
- <template v-if="node.label[0] === '*'"></template>
51
- <template v-else>
52
- <b v-if="node.rules.some((v) => v.required)" class="co-risk">﹡</b><span>{{ node.label[0] }}</span>
53
- </template>
54
- </h6>
55
- <h6 v-else class="flex-block ar pr o-lm" style="padding-top: 2px" v-bind="node.label[1]">
56
- <template v-if="node.label[0] === '*'"></template>
57
- <template v-else>
58
- <b v-if="node.rules.some((v) => v.required)" class="co-risk">﹡</b><span>{{ node.label[0] }}</span>
59
- </template>
60
- </h6>
61
- </template>
62
- </slot>
63
- </div>
64
- <div class="flex-block" ui-flex="col xm">
65
- <!-- 字段内部上边插入其他内容 -->
66
- <div class="flex-fixed" v-if="node.other && node.other.nt" v-bind="node.other.nt.attrs">
67
- <template v-for="(item, idx) in node?.other?.nt?.child || []">
68
- <div
69
- v-if="!item.clear"
70
- :key="idx"
71
- v-html="item.value"
72
- v-bind="item.attrs"
73
- v-on="event({ col: item, node, data: data[node.field], idx: i1, fun: { fAdd, fDel, _rows } })"
74
- ></div>
75
- </template>
76
- </div>
77
- <div ui-flex="row lt">
78
- <!-- 字段内部左边插入其他内容 -->
79
- <div class="flex-fixed" v-if="node.other && node.other.nl" v-bind="node.other.nl.attrs">
80
- <template v-for="(item, idx) in node?.other?.nl?.child || []">
81
- <div
82
- v-if="!item.clear"
83
- :key="idx"
84
- v-html="item.value"
85
- v-bind="item.attrs"
86
- v-on="event({ col: item, node, data: data[node.field], idx: i1, fun: { fAdd, fDel, _rows } })"
87
- ></div>
88
- </template>
89
- </div>
90
- <div class="flex-block">
91
- <template v-if="node.array">
92
- <template v-if="isArray(node.array.lists)">
93
- <div v-if="data[node.field].length" class="form-loader-group-array flex-block n-sm-sub" ui-row="">
94
- <div v-for="(item, i2) in data[node.field]" :key="i2" class="form-loader-array-item full">
95
- <div class="flex-fixed" v-if="node.array.other && node.array.other.ml" v-bind="node.array.other.ml.attrs">
96
- <template v-if="node.array.other.mt.child && isArray(node.array.other.mt.child)">
97
- <div
98
- v-for="(item, idx) in node.array.other.mt.child"
99
- v-if="!item.clear"
100
- :key="idx"
101
- v-html="item.value"
102
- v-bind="item.attrs"
103
- v-on="event({ col: item, node, data: data[node.field], idx: i2, fun: { fAdd, fDel, _rows } })"
104
- ></div>
105
- </template>
106
- </div>
107
- <div class="full" ui-flex="row xt">
108
- <div class="flex-fixed" v-if="node.array.other && node.array.other.ml" v-bind="node.array.other.ml.attrs">
109
- <template v-if="node.array.other.ml.child && isArray(node.array.other.ml.child)">
110
- <div
111
- v-for="(item, idx) in node.array.other.ml.child"
112
- v-if="!item.clear"
113
- :key="idx"
114
- v-html="item.value"
115
- v-bind="item.attrs"
116
- v-on="event({ col: item, node, data: data[node.field], idx: i2, fun: { fAdd, fDel, _rows } })"
117
- ></div>
118
- </template>
119
- </div>
120
- <div class="flex-block" v-bind="node.array.attrs">
121
- <FormLoader
122
- v-model:form="node.array.lists"
123
- v-model:data="item"
124
- :parentNode="node"
125
- v-model:parent="data[node.field]"
126
- v-model:fulldata="data"
127
- :rows="rows"
128
- :level="level + 1"
129
- :index="i2"
130
- :debug="debug"
131
- :mode="mode"
132
- :interacted="interacted"
133
- :slots="slots"
134
- :globalLabelWidth="lw"
135
- :cache="cache"
136
- >
137
- <!-- 通用插槽 -->
138
- <template v-slot:every-label="slotprops"><slot name="every-label" v-bind="slotprops"></slot></template>
139
- <template v-slot:array-label="slotprops"><slot name="array-label" v-bind="slotprops"></slot></template>
140
- <template v-slot:child-label="slotprops"><slot name="child-label" v-bind="slotprops"></slot></template>
141
-
142
- <!-- Vue 3 支持动态插槽,不需要手动遍历 -->
143
- <template v-for="slotName in slots" :key="slotName" v-slot:[slotName]="slotprops">
144
- <slot :name="slotName" v-bind="slotprops"></slot>
145
- </template>
146
- </FormLoader>
147
- </div>
148
- <div class="flex-fixed" v-if="node.array.other && node.array.other.mr" v-bind="node.array.other.mr.attrs">
149
- <template v-for="(item, idx) in node?.array?.other?.mr?.child || []">
150
- <div
151
- v-if="!item.clear"
152
- :key="idx"
153
- v-html="item.value"
154
- v-bind="item.attrs"
155
- v-on="event({ col: item, node, data: data[node.field], idx: i2, fun: { fAdd, fDel, _rows } })"
156
- ></div>
157
- </template>
158
- </div>
159
- </div>
160
- <div class="flex-fixed" v-if="node.array.other && node.array.other.ml" v-bind="node.array.other.ml.attrs">
161
- <template v-if="node.array.other.mb.child && isArray(node.array.other.mb.child)">
162
- <div
163
- v-for="(item, idx) in node.array.other.mb.child"
164
- v-if="!item.clear"
165
- :key="idx"
166
- v-html="item.value"
167
- v-bind="item.attrs"
168
- v-on="event({ col: item, node, data: data[node.field], idx: i2, fun: { fAdd, fDel, _rows } })"
169
- ></div>
170
- </template>
171
- </div>
172
- </div>
173
- </div>
174
- </template>
175
- <div v-else v-html="err(`配置错误:Field: ${node.field} 配置了属性值 [array.lists] 必须是一个数组`)"></div>
176
- </template>
177
- <template v-else-if="node.child">
178
- <template v-if="isArray(node.child)">
179
- <FormLoader
180
- class="flex-block form-loader-group-child"
181
- v-model:form="node.child"
182
- v-model:data="form._data"
183
- v-model:fulldata="data"
184
- :rows="rows"
185
- :level="level + 1"
186
- :debug="debug"
187
- :mode="mode"
188
- :interacted="interacted"
189
- :slots="slots"
190
- :globalLabelWidth="lw"
191
- :cache="cache"
192
- >
193
- <!-- 通用插槽 -->
194
- <template v-slot:every-label="slotprops"><slot name="every-label" v-bind="slotprops"></slot></template>
195
- <template v-slot:array-label="slotprops"><slot name="array-label" v-bind="slotprops"></slot></template>
196
- <template v-slot:child-label="slotprops"><slot name="child-label" v-bind="slotprops"></slot></template>
197
-
198
- <template v-for="slotName in slots" :key="slotName" v-slot:[slotName]="slotprops">
199
- <slot :name="slotName" v-bind="slotprops"></slot>
200
- </template>
201
- </FormLoader>
202
- </template>
203
- <div v-else v-html="err(`配置错误:Field: ${node.field} 配置了属性值 [child] 必须是一个数组`)"></div>
204
- </template>
205
- <template v-else>
206
- <FormRender v-model:node="node" v-model:data="data" :interacted="interacted" :data-field="node.field" :mode="mode">
207
- <template v-slot:[`${node.field}-value`]="slotprops">
208
- <slot :name="`${node.field}-value`" v-bind="slotprops"></slot>
209
- </template>
210
- </FormRender>
211
- </template>
212
- </div>
213
- <!-- 字段内部右边插入其他内容 -->
214
- <div class="flex-fixed" v-if="node.other && node.other.nr" v-bind="node.other.nr.attrs">
215
- <template v-for="(item, idx) in node?.other?.nr?.child || []">
216
- <div
217
- v-if="!item.clear"
218
- :key="idx"
219
- v-html="item.value"
220
- v-bind="item.attrs"
221
- v-on="event({ col: item, parentNode, node, data: parent, idx: i1, index, fun: { fAdd, fDel, _rows } })"
222
- ></div>
223
- </template>
224
- </div>
225
- </div>
226
- <!-- 字段内部下边插入其他内容 -->
227
- <div class="flex-fixed" v-if="node.other && node.other.nb" v-bind="node.other.nb.attrs">
228
- <template v-for="(item, idx) in node?.other?.nb?.child || []">
229
- <div
230
- v-if="!item.clear"
231
- :key="idx"
232
- v-html="item.value"
233
- v-bind="item.attrs"
234
- v-on="event({ col: item, node, data: data[node.field], idx: i1, fun: { fAdd, fDel, _rows } })"
235
- ></div>
236
- </template>
237
- </div>
238
- </div>
239
- </slot>
240
- </div>
241
- </div>
242
- <!-- 字段外部右边插入其他内容 -->
243
- <div class="flex-fixed" v-if="node.other && node.other.mr && !node.other.mr.clear" v-bind="node.other.mr.attrs">
244
- <template v-for="(item, idx) in node?.other?.mr?.child || []">
245
- <div
246
- v-if="!item.clear"
247
- :key="idx"
248
- v-html="item.value"
249
- v-bind="item.attrs"
250
- v-on="event({ col: item, node, data: data[node.field], idx: i1, fun: { fAdd, fDel, _rows } })"
251
- ></div>
252
- </template>
253
- </div>
254
- </div>
255
- <!-- 字段外部下边插入其他内容 -->
256
- <div class="flex-fixed" v-if="node.other && node.other.mb" v-bind="node.other.mb.attrs">
257
- <template v-for="(item, idx) in node?.other?.mb?.child || []">
258
- <div
259
- v-if="!item.clear"
260
- :key="idx"
261
- v-html="item.value"
262
- v-bind="item.attrs"
263
- v-on="event({ col: item, node, data: data[node.field], idx: i1, fun: { fAdd, fDel, _rows } })"
264
- ></div>
265
- </template>
266
- </div>
267
- </div>
268
- </template>
269
- <div v-if="slots.submit" class="full-x" ui-flex="row lm">
270
- <div class="flex-fixed" :style="labelcss($nodes)">&nbsp;</div>
271
- <div class="flex-block"><slot name="submit"></slot></div>
272
- </div>
273
- </div>
274
- </template>
275
- <script setup lang="ts">
276
- import { computed, reactive, useSlots, withDefaults } from 'vue';
277
- import { deepcopy, isObject, isArray, isFunction } from '@fekit/utils';
278
-
279
- const slots = useSlots();
280
-
281
- interface NodeProps {
282
- label?: string | ((data: any) => string);
283
- field?: string | ((data: any) => string);
284
- model?: string | ((data: any) => string);
285
- attrs?: Record<string, any> | ((data: any) => Record<string, any>);
286
- rules?: Record<string, any> | ((data: any) => Record<string, any>);
287
- clear?: boolean | ((data: any) => boolean);
288
- media?: string | ((data: any) => string);
289
- }
290
-
291
- interface Props {
292
- form: NodeProps[];
293
- data: object;
294
- level?: number | ((data: any) => number);
295
- index?: number | ((data: any) => number);
296
- }
297
- const props = withDefaults(defineProps<Props>(), {
298
- node: () => [],
299
- data: () => ({}),
300
- level: 0,
301
- index: 0,
302
- });
303
-
304
- const state = reactive({
305
- globalLabelWidth: 0,
306
- lw: 0,
307
- });
308
-
309
- const $nodes = computed(() => {
310
- const _nodes = deepcopy(props.form);
311
- return _nodes.map((node: any) => {
312
- return node;
313
- });
314
- });
315
-
316
- const event = ({ col, node, data, idx = null, fun } = {}) => {
317
- const _event = { ...col.event } || {};
318
-
319
- // 代理交互
320
- if (col.proxy) {
321
- if (col.proxy === 'array-add-btn' && node.array) {
322
- if (node.array) {
323
- // 合并配置事件与代理事件
324
- if (fun.fAdd) {
325
- const _click = _event.click;
326
- _event.click = function (...args) {
327
- if (isFunction(_click)) {
328
- _click.apply(this, args);
329
- }
330
- fun.fAdd(node, data, idx);
331
- };
332
- }
333
- } else {
334
- console.warn('数组新增按钮代理`array-add-btn`需配置在`array`下');
335
- }
336
- }
337
- if (col.proxy === 'array-del-btn') {
338
- if (node.array) {
339
- // 合并配置事件与代理事件
340
- if (fun.fDel) {
341
- const _click = _event.click;
342
- _event.click = function (...args) {
343
- if (isFunction(_click)) {
344
- _click.apply(this, args);
345
- }
346
- fun.fDel(node, data, idx);
347
- };
348
- }
349
- } else {
350
- console.warn('数组删除按钮代理`array-del-btn`需配置在`array`下');
351
- }
352
- }
353
-
354
- if (col.proxy === 'array-add-sub' && node.array) {
355
- if (node.array) {
356
- console.log(784, node, data);
357
- // 合并配置事件与代理事件
358
- // if (fun.fAdd) {
359
- // const _click = _event.click;
360
- // _event.click = function(...args) {
361
- // if (isFunction(_click)) {
362
- // _click.apply(this, args);
363
- // }
364
- // fun.fAdd(node, data[node.field], idx);
365
- // };
366
- // }
367
- } else {
368
- console.warn('数组新增按钮代理`array-add-btn`需配置在`array`下');
369
- }
370
- }
371
- }
372
-
373
- if (isObject(_event)) {
374
- for (const key in _event) {
375
- const fun = _event[key];
376
- if (isFunction(fun)) {
377
- _event[key] = (...args) => {
378
- return fun({ node: col, data, idx, formloader: this }, ...args);
379
- };
380
- }
381
- }
382
- }
383
- return { ..._event };
384
- };
385
-
386
- const labelcss = (nodes: any) => {
387
- if (nodes.vertical) {
388
- // 竖向
389
- return ``;
390
- } else if (nodes.transverse) {
391
- // 横向不固定宽度
392
- return ``;
393
- } else {
394
- // 横向
395
- const _w = Math.max(state.globalLabelWidth, state.lw);
396
- return `width:${_w}em; max-width:50%;`;
397
- }
398
- };
399
- </script>
@@ -1,4 +0,0 @@
1
- <template>
2
- <div></div>
3
- </template>
4
- <script setup lang="ts"></script>