@neatui/nuxt 1.5.2 → 1.5.4
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neatui/nuxt",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
4
4
|
"description": "NeatUI component library for Nuxt 3",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@nuxt/schema": "^3.0.0",
|
|
23
23
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
24
24
|
"@types/sortablejs": "^1.15.8",
|
|
25
|
-
"nuxt": "
|
|
25
|
+
"nuxt": ">=3.0.0",
|
|
26
26
|
"postcss-scss": "^4.0.9",
|
|
27
27
|
"rollup-plugin-scss": "^4.0.0",
|
|
28
28
|
"rollup-plugin-terser": "^7.0.2",
|
|
@@ -189,12 +189,17 @@
|
|
|
189
189
|
const processInput = (value: any) => {
|
|
190
190
|
let processedArray: any[] = [];
|
|
191
191
|
|
|
192
|
+
// 处理 null 或 undefined,转换为空字符串
|
|
193
|
+
if (value === null || value === undefined) {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
|
|
192
197
|
if (typeof value === 'string') {
|
|
193
198
|
state.originalType = 'string';
|
|
194
199
|
processedArray = value.trim() ? (value.includes(',') ? value.split(',').map((s: string) => s.trim()) : [value]) : [];
|
|
195
200
|
} else {
|
|
196
201
|
state.originalType = 'array';
|
|
197
|
-
processedArray = value
|
|
202
|
+
processedArray = Array.isArray(value) ? value : [];
|
|
198
203
|
}
|
|
199
204
|
|
|
200
205
|
// 过滤掉在options中不存在的值
|
|
@@ -240,7 +245,7 @@
|
|
|
240
245
|
};
|
|
241
246
|
// 选中
|
|
242
247
|
const select = (item: any) => {
|
|
243
|
-
const s = [...state.processedValue];
|
|
248
|
+
const s = [...(state.processedValue || [])];
|
|
244
249
|
// s?.indexOf(item) !== -1 ? s?.splice(s?.indexOf(item), 1) : s?.push(item);
|
|
245
250
|
if (s?.indexOf(item) !== -1) {
|
|
246
251
|
s?.splice(s?.indexOf(item), 1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<template v-for="(item, index) in $nodes" :key="
|
|
3
|
-
<div
|
|
4
|
-
<NodeLoader v-if="item.child" :nodes="item.child"
|
|
2
|
+
<template v-for="(item, index) in $nodes" :key="index">
|
|
3
|
+
<div :data-index="index" v-bind="item.attrs" v-on="item.$events" v-html="item.value"></div>
|
|
4
|
+
<NodeLoader v-if="item.child" :nodes="item.child" />
|
|
5
5
|
</template>
|
|
6
6
|
</template>
|
|
7
7
|
<script setup lang="ts">
|
|
@@ -9,34 +9,24 @@
|
|
|
9
9
|
import NodeLoader from './NodeLoader.vue';
|
|
10
10
|
|
|
11
11
|
interface NodeProps {
|
|
12
|
-
label?: string | ((data: any) => string);
|
|
13
|
-
field?: string | ((data: any) => string);
|
|
14
|
-
model?: string | ((data: any) => string);
|
|
15
12
|
attrs?: Record<string, any> | ((data: any) => Record<string, any>);
|
|
16
|
-
clear?: boolean | ((data: any) => boolean);
|
|
17
|
-
media?: string | ((data: any) => string);
|
|
18
13
|
value?: any | ((data: any) => any);
|
|
14
|
+
model?: string;
|
|
19
15
|
event?: Record<string, any> | ((data: any) => Record<string, any>);
|
|
20
16
|
child?: NodeProps[];
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
interface Props {
|
|
24
|
-
nodes: NodeProps[];
|
|
25
|
-
level?: number;
|
|
26
|
-
index?: number;
|
|
27
|
-
paths?: string;
|
|
20
|
+
nodes: NodeProps | NodeProps[];
|
|
28
21
|
}
|
|
29
22
|
const props = withDefaults(defineProps<Props>(), {
|
|
30
23
|
nodes: () => [],
|
|
31
|
-
level: 0,
|
|
32
|
-
index: 0,
|
|
33
|
-
paths: '',
|
|
34
24
|
});
|
|
35
25
|
|
|
36
26
|
const $nodes = computed(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const context = { node: item,
|
|
27
|
+
const nodeList = Array.isArray(props.nodes) ? props.nodes : [props.nodes];
|
|
28
|
+
return nodeList.map((item, index) => {
|
|
29
|
+
const context = { node: item, index } as const;
|
|
40
30
|
|
|
41
31
|
let attrs: any = item.attrs;
|
|
42
32
|
if (typeof attrs === 'function') {
|
|
@@ -75,11 +65,7 @@
|
|
|
75
65
|
}
|
|
76
66
|
}
|
|
77
67
|
|
|
78
|
-
return { ...item, index,
|
|
68
|
+
return { ...item, index, attrs, value, $events } as any;
|
|
79
69
|
});
|
|
80
70
|
});
|
|
81
|
-
|
|
82
|
-
const $level = computed(() => {
|
|
83
|
-
return props.level + 1;
|
|
84
|
-
});
|
|
85
71
|
</script>
|