v-nuxt-ui 0.2.18 → 0.2.21
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/dist/module.json +1 -1
- package/dist/runtime/components/button/Dropdown.d.vue.ts +6 -7
- package/dist/runtime/components/button/Dropdown.vue +15 -86
- package/dist/runtime/components/button/Dropdown.vue.d.ts +6 -7
- package/dist/runtime/components/sys/user/Table.vue +1 -5
- package/dist/runtime/components/table/query/where/Newer.vue +12 -21
- package/dist/runtime/components/table/query/where/index.vue +4 -3
- package/dist/runtime/components/table/query/where/simple/item/ColumnPicker.vue +12 -20
- package/dist/runtime/components/table/query/where/simple/item/OprPicker.vue +10 -16
- package/dist/runtime/composables/table/useTable.js +1 -0
- package/dist/runtime/composables/useEChart.js +10 -4
- package/dist/runtime/types/components/table/query/where.d.ts +1 -0
- package/package.json +2 -2
package/dist/module.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ListboxItem, ListboxProps } from '@nuxt/ui';
|
|
2
2
|
type __VLS_Props = {
|
|
3
|
-
|
|
4
|
-
multiple?:
|
|
5
|
-
enableFooterToolbar?: boolean;
|
|
3
|
+
items: ListboxItem[];
|
|
4
|
+
multiple?: ListboxProps['multiple'];
|
|
6
5
|
onOpen?: () => Promise<void>;
|
|
7
6
|
onSearch?: (searchTerm: string) => Promise<void>;
|
|
8
7
|
};
|
|
9
8
|
type __VLS_ModelProps = {
|
|
10
|
-
'modelValue'?: string | number | undefined |
|
|
9
|
+
'modelValue'?: string | number | undefined | (string | number)[];
|
|
11
10
|
};
|
|
12
11
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
13
12
|
declare var __VLS_8: {};
|
|
@@ -17,9 +16,9 @@ type __VLS_Slots = {} & {
|
|
|
17
16
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
18
17
|
focus: () => Promise<void>;
|
|
19
18
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
-
"update:modelValue": (value: string | number | (string | number)[] |
|
|
19
|
+
"update:modelValue": (value: string | number | (string | number)[] | undefined) => any;
|
|
21
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
22
|
-
"onUpdate:modelValue"?: ((value: string | number | (string | number)[] |
|
|
21
|
+
"onUpdate:modelValue"?: ((value: string | number | (string | number)[] | undefined) => any) | undefined;
|
|
23
22
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
23
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
25
24
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,59 +1,12 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {
|
|
2
|
+
import { ref, watch } from "vue";
|
|
3
3
|
const props = defineProps({
|
|
4
|
-
|
|
4
|
+
items: { type: Array, required: true },
|
|
5
5
|
multiple: { type: Boolean, required: false },
|
|
6
|
-
enableFooterToolbar: { type: Boolean, required: false },
|
|
7
6
|
onOpen: { type: Function, required: false },
|
|
8
7
|
onSearch: { type: Function, required: false }
|
|
9
8
|
});
|
|
10
9
|
const modelValue = defineModel("modelValue", { type: null, ...{ required: false } });
|
|
11
|
-
const commandPaletteModelValue = computed({
|
|
12
|
-
get() {
|
|
13
|
-
if (props.multiple) {
|
|
14
|
-
const values = [];
|
|
15
|
-
for (const group of props.groups) {
|
|
16
|
-
for (const item of group.items) {
|
|
17
|
-
if (Array.isArray(modelValue.value) && modelValue.value.includes(item.value)) {
|
|
18
|
-
values.push(item);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return values;
|
|
23
|
-
}
|
|
24
|
-
for (const group of props.groups) {
|
|
25
|
-
for (const item of group.items) {
|
|
26
|
-
if (item.value === modelValue.value) {
|
|
27
|
-
const newItem = { ...item };
|
|
28
|
-
delete newItem.onSelect;
|
|
29
|
-
return newItem;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return {};
|
|
34
|
-
},
|
|
35
|
-
set(newValue) {
|
|
36
|
-
if (props.multiple) {
|
|
37
|
-
modelValue.value = newValue.map((item) => item.value);
|
|
38
|
-
} else {
|
|
39
|
-
modelValue.value = newValue.value;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
const footerActions = [
|
|
44
|
-
{
|
|
45
|
-
label: "\u5168\u9009",
|
|
46
|
-
fn: () => modelValue.value = props.groups.flatMap((group) => group.items.map((item) => item.value))
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
label: "\u53CD\u9009",
|
|
50
|
-
fn: () => modelValue.value = props.groups.flatMap((group) => group.items.map((item) => item.value)).filter((value) => !(Array.isArray(modelValue.value) ? modelValue.value.includes(value) : modelValue.value === value))
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
label: "\u6E05\u7A7A",
|
|
54
|
-
fn: () => modelValue.value = []
|
|
55
|
-
}
|
|
56
|
-
];
|
|
57
10
|
const searchTerm = ref("");
|
|
58
11
|
const popoverOpen = ref(false);
|
|
59
12
|
watch(popoverOpen, async (newOpen) => {
|
|
@@ -82,46 +35,22 @@ defineExpose({
|
|
|
82
35
|
<slot />
|
|
83
36
|
|
|
84
37
|
<template #content>
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
:
|
|
88
|
-
|
|
38
|
+
<UListbox
|
|
39
|
+
v-model="modelValue"
|
|
40
|
+
v-model:search-term="searchTerm"
|
|
41
|
+
autofocus
|
|
89
42
|
size="sm"
|
|
90
|
-
|
|
91
|
-
:
|
|
92
|
-
|
|
93
|
-
|
|
43
|
+
value-key="value"
|
|
44
|
+
:filter="{
|
|
45
|
+
placeholder: '\u641C\u7D22...',
|
|
46
|
+
icon: 'i-lucide-search'
|
|
94
47
|
}"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
@update:model-value="(newValue) => {
|
|
98
|
-
commandPaletteModelValue = newValue;
|
|
99
|
-
if (!multiple) {
|
|
100
|
-
popoverOpen = false;
|
|
101
|
-
}
|
|
102
|
-
}"
|
|
103
|
-
@update:search-term="async (newSearchTerm) => {
|
|
104
|
-
searchTerm = newSearchTerm;
|
|
105
|
-
await onSearch?.(newSearchTerm);
|
|
48
|
+
:ui="{
|
|
49
|
+
root: 'ring-0'
|
|
106
50
|
}"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
<UFieldGroup class="flex items-center ml-auto">
|
|
111
|
-
<UButton
|
|
112
|
-
v-for="action in footerActions"
|
|
113
|
-
:key="action.label"
|
|
114
|
-
:label="action.label"
|
|
115
|
-
size="xs"
|
|
116
|
-
color="neutral"
|
|
117
|
-
variant="ghost"
|
|
118
|
-
class="text-muted font-normal"
|
|
119
|
-
@click="action.fn"
|
|
120
|
-
/>
|
|
121
|
-
</UFieldGroup>
|
|
122
|
-
</div>
|
|
123
|
-
</template>
|
|
124
|
-
</UCommandPalette>
|
|
51
|
+
:items="props.items"
|
|
52
|
+
:multiple="props.multiple"
|
|
53
|
+
/>
|
|
125
54
|
</template>
|
|
126
55
|
</UPopover>
|
|
127
56
|
</template>
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ListboxItem, ListboxProps } from '@nuxt/ui';
|
|
2
2
|
type __VLS_Props = {
|
|
3
|
-
|
|
4
|
-
multiple?:
|
|
5
|
-
enableFooterToolbar?: boolean;
|
|
3
|
+
items: ListboxItem[];
|
|
4
|
+
multiple?: ListboxProps['multiple'];
|
|
6
5
|
onOpen?: () => Promise<void>;
|
|
7
6
|
onSearch?: (searchTerm: string) => Promise<void>;
|
|
8
7
|
};
|
|
9
8
|
type __VLS_ModelProps = {
|
|
10
|
-
'modelValue'?: string | number | undefined |
|
|
9
|
+
'modelValue'?: string | number | undefined | (string | number)[];
|
|
11
10
|
};
|
|
12
11
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
13
12
|
declare var __VLS_8: {};
|
|
@@ -17,9 +16,9 @@ type __VLS_Slots = {} & {
|
|
|
17
16
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
18
17
|
focus: () => Promise<void>;
|
|
19
18
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
-
"update:modelValue": (value: string | number | (string | number)[] |
|
|
19
|
+
"update:modelValue": (value: string | number | (string | number)[] | undefined) => any;
|
|
21
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
22
|
-
"onUpdate:modelValue"?: ((value: string | number | (string | number)[] |
|
|
21
|
+
"onUpdate:modelValue"?: ((value: string | number | (string | number)[] | undefined) => any) | undefined;
|
|
23
22
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
23
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
25
24
|
declare const _default: typeof __VLS_export;
|
|
@@ -45,6 +45,7 @@ const columns = [
|
|
|
45
45
|
labelField: "name",
|
|
46
46
|
valueField: "id",
|
|
47
47
|
multiple: true,
|
|
48
|
+
initHide: false,
|
|
48
49
|
defaultOpr: "in"
|
|
49
50
|
}
|
|
50
51
|
},
|
|
@@ -191,11 +192,6 @@ const columns = [
|
|
|
191
192
|
:extra-order-query-options="[
|
|
192
193
|
{ field: 'createdAt', label: '\u521B\u5EFA\u65F6\u95F4', defaultOpr: 'desc' }
|
|
193
194
|
]"
|
|
194
|
-
:extra-where-query-init-values="{
|
|
195
|
-
items: [
|
|
196
|
-
{ field: 'isAdmin', opr: 'eq', value: false }
|
|
197
|
-
]
|
|
198
|
-
}"
|
|
199
195
|
@edit-row-from-modal="async (row) => await createModal.open({ model: row }).result"
|
|
200
196
|
/>
|
|
201
197
|
</template>
|
|
@@ -10,32 +10,23 @@ const props = defineProps({
|
|
|
10
10
|
});
|
|
11
11
|
const emit = defineEmits(["new"]);
|
|
12
12
|
const popoverOpen = ref(false);
|
|
13
|
-
const unselectedOptions = computed(() => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
label: column?.header || option?.label || field,
|
|
23
|
-
icon: tableWhereQueryItemIconMap.get(option?.type ?? "unknown") || "field",
|
|
24
|
-
onSelect: () => {
|
|
25
|
-
emit("new", field);
|
|
26
|
-
popoverOpen.value = false;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
})
|
|
13
|
+
const unselectedOptions = computed(() => props.unselectedFields.map((field) => {
|
|
14
|
+
const option = props.options.find((option2) => option2.field === field);
|
|
15
|
+
const column = props.bizColumns.find((column2) => column2["accessorKey"] === field);
|
|
16
|
+
return {
|
|
17
|
+
label: column?.header || option?.label || field,
|
|
18
|
+
icon: tableWhereQueryItemIconMap.get(option?.type ?? "unknown") || "field",
|
|
19
|
+
onSelect: () => {
|
|
20
|
+
emit("new", field);
|
|
21
|
+
popoverOpen.value = false;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
23
|
+
};
|
|
24
|
+
}));
|
|
34
25
|
</script>
|
|
35
26
|
|
|
36
27
|
<template>
|
|
37
28
|
<!-- NOTE: 自己实现DropdownMenu, 原生DropdownMenu的Focus有问题,会让查询字段打开的Popover关闭 -->
|
|
38
|
-
<ButtonDropdown :
|
|
29
|
+
<ButtonDropdown :items="unselectedOptions">
|
|
39
30
|
<UButton
|
|
40
31
|
label="新增"
|
|
41
32
|
:size="size"
|
|
@@ -6,6 +6,7 @@ import TableQueryWhereSimpleItem from "#v/components/table/query/where/simple/it
|
|
|
6
6
|
import TableQueryWhereNewer from "#v/components/table/query/where/Newer.vue";
|
|
7
7
|
const props = defineProps({
|
|
8
8
|
whereOptions: { type: Array, required: true },
|
|
9
|
+
extraWhereQueryInitValues: { type: Object, required: false },
|
|
9
10
|
defaultWhereQuery: { type: Object, required: false },
|
|
10
11
|
whereQuery: { type: null, required: true },
|
|
11
12
|
onUpdateWhereQuery: { type: Function, required: true },
|
|
@@ -66,9 +67,9 @@ const isWhereQueryEmpty = computed(() => {
|
|
|
66
67
|
return !props.whereQuery || Object.keys(props.whereQuery ?? {}).length === 0 || // 仅检查有对应option的item的值是否为空
|
|
67
68
|
(props.whereQuery?.items?.filter((query) => props.whereOptions.find((option) => option.field === query.field)).length ?? 0) === 0 && (props.whereQuery?.groups?.length ?? 0) === 0;
|
|
68
69
|
});
|
|
69
|
-
const
|
|
70
|
+
const whereQueryWithoutInitValues = computed(() => {
|
|
70
71
|
if (!props.whereQuery) return [];
|
|
71
|
-
const defaultKeys = props.
|
|
72
|
+
const defaultKeys = props.extraWhereQueryInitValues?.items?.map((query) => query.field) ?? [];
|
|
72
73
|
return props.whereQuery.items?.filter((query) => {
|
|
73
74
|
const field = query.field;
|
|
74
75
|
return !defaultKeys.includes(field);
|
|
@@ -92,7 +93,7 @@ defineExpose({ focusField });
|
|
|
92
93
|
<!-- key如果是field,那么field修改后,不能聚焦后面的组件,所以这里的key用idx代替 -->
|
|
93
94
|
<template v-if="!isWhereQueryEmpty">
|
|
94
95
|
<TableQueryWhereSimpleItem
|
|
95
|
-
v-for="(item, idx) in
|
|
96
|
+
v-for="(item, idx) in whereQueryWithoutInitValues"
|
|
96
97
|
:ref="(el) => setItemRef(item.field, el)"
|
|
97
98
|
:key="idx"
|
|
98
99
|
:where-query-item="item"
|
|
@@ -9,25 +9,17 @@ const props = defineProps({
|
|
|
9
9
|
focus: { type: Function, required: false }
|
|
10
10
|
});
|
|
11
11
|
const whereQueryItem = defineModel("whereQueryItem", { type: Object, ...{ required: true } });
|
|
12
|
-
const items = computed(() => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
nextTick(() => {
|
|
24
|
-
props.focus?.();
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}))
|
|
28
|
-
}
|
|
29
|
-
];
|
|
30
|
-
});
|
|
12
|
+
const items = computed(() => props.options.map((option) => ({
|
|
13
|
+
label: option.label,
|
|
14
|
+
value: option.field,
|
|
15
|
+
icon: tableWhereQueryItemIconMap.get(option.type) || "field",
|
|
16
|
+
onSelect: () => {
|
|
17
|
+
modelValue.value = option.field;
|
|
18
|
+
nextTick(() => {
|
|
19
|
+
props.focus?.();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
})));
|
|
31
23
|
const modelValue = computed({
|
|
32
24
|
get() {
|
|
33
25
|
return whereQueryItem.value.field;
|
|
@@ -53,7 +45,7 @@ const currentOption = computed(() => {
|
|
|
53
45
|
<template>
|
|
54
46
|
<ButtonDropdown
|
|
55
47
|
v-model="modelValue"
|
|
56
|
-
:
|
|
48
|
+
:items="items"
|
|
57
49
|
>
|
|
58
50
|
<UButton
|
|
59
51
|
:size="'sm'"
|
|
@@ -16,22 +16,16 @@ const items = computed(() => {
|
|
|
16
16
|
console.error("Cannot find field option or missing type for field:", whereQueryItem.value.field);
|
|
17
17
|
return [];
|
|
18
18
|
}
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
modelValue.value = option2.value;
|
|
28
|
-
nextTick(() => {
|
|
29
|
-
props.focus?.();
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}))
|
|
19
|
+
return useTableOpr().getOprNameOptionsByType(option.value.type).map((option2) => ({
|
|
20
|
+
label: option2.label,
|
|
21
|
+
value: option2.value,
|
|
22
|
+
onSelect: () => {
|
|
23
|
+
modelValue.value = option2.value;
|
|
24
|
+
nextTick(() => {
|
|
25
|
+
props.focus?.();
|
|
26
|
+
});
|
|
33
27
|
}
|
|
34
|
-
|
|
28
|
+
}));
|
|
35
29
|
});
|
|
36
30
|
const modelValue = computed({
|
|
37
31
|
get() {
|
|
@@ -55,7 +49,7 @@ const currentLabel = computed(() => {
|
|
|
55
49
|
<!-- NOTE: 自己实现DropdownMenu, 原生DropdownMenu的Focus有问题,会让查询字段打开的Popover关闭 -->
|
|
56
50
|
<ButtonDropdown
|
|
57
51
|
v-model="modelValue"
|
|
58
|
-
:
|
|
52
|
+
:items="items"
|
|
59
53
|
>
|
|
60
54
|
<UButton
|
|
61
55
|
size="sm"
|
|
@@ -254,6 +254,7 @@ export function useTable(props) {
|
|
|
254
254
|
}));
|
|
255
255
|
const tblWhereQueryProps = computed(() => ({
|
|
256
256
|
whereOptions: whereQueryOptions.value,
|
|
257
|
+
extraWhereQueryInitValues,
|
|
257
258
|
defaultWhereQuery: whereQueryInitValues.value,
|
|
258
259
|
whereQuery: whereQuery.value,
|
|
259
260
|
onUpdateWhereQuery: (query) => whereQuery.value = query,
|
|
@@ -241,12 +241,18 @@ const _useEChart = () => {
|
|
|
241
241
|
enableXAxis = true,
|
|
242
242
|
enableYAxis = true
|
|
243
243
|
} = config;
|
|
244
|
-
const
|
|
244
|
+
const hasXAxisOption = option?.xAxis !== void 0;
|
|
245
|
+
const hasYAxisOption = option?.yAxis !== void 0;
|
|
246
|
+
let commonOption = defu(
|
|
245
247
|
getCommonGridOption(),
|
|
246
|
-
getCommonLegendOption()
|
|
247
|
-
getCommonXAxisOption(enableXAxis),
|
|
248
|
-
getCommonYAxisOption(enableYAxis)
|
|
248
|
+
getCommonLegendOption()
|
|
249
249
|
);
|
|
250
|
+
if (enableXAxis || hasXAxisOption) {
|
|
251
|
+
commonOption = defu(commonOption, getCommonXAxisOption(enableXAxis));
|
|
252
|
+
}
|
|
253
|
+
if (enableYAxis || hasYAxisOption) {
|
|
254
|
+
commonOption = defu(commonOption, getCommonYAxisOption(enableYAxis));
|
|
255
|
+
}
|
|
250
256
|
const merged = defu(option, commonOption);
|
|
251
257
|
if (merged.xAxis && Array.isArray(merged.xAxis) && merged.xAxis.length > 1) {
|
|
252
258
|
const xAxisDefaults = getCommonXAxisOption(enableXAxis).xAxis;
|
|
@@ -5,6 +5,7 @@ export type WhereQueryOption<T> = {
|
|
|
5
5
|
} & WhereQueryColumnOption<T>;
|
|
6
6
|
export type WhereQueryProps<T> = {
|
|
7
7
|
whereOptions: WhereQueryOption<T>[];
|
|
8
|
+
extraWhereQueryInitValues?: WhereQuery<T>;
|
|
8
9
|
defaultWhereQuery?: WhereQuery<T>;
|
|
9
10
|
whereQuery: WhereQuery<T> | undefined;
|
|
10
11
|
onUpdateWhereQuery: (query: WhereQuery<T> | undefined) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "v-nuxt-ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"description": "Veken UI Component Library - Reusable Nuxt UI components, composables, and utilities for enterprise applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"style": "./dist/runtime/index.css",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@nuxt/eslint-config": "^1.15.2",
|
|
72
72
|
"@nuxt/fonts": "^0.12.1",
|
|
73
73
|
"@nuxt/module-builder": "^1.0.2",
|
|
74
|
-
"@nuxt/ui": "^4.
|
|
74
|
+
"@nuxt/ui": "^4.7.0",
|
|
75
75
|
"@nuxtjs/i18n": "^10.2.4",
|
|
76
76
|
"@nuxtjs/mdc": "^0.20.2",
|
|
77
77
|
"@tanstack/table-core": "^8.21.3",
|