@finema/core 3.16.1 → 3.16.3
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/module.mjs +1 -1
- package/dist/runtime/components/Table/Base.d.vue.ts +7 -2
- package/dist/runtime/components/Table/Base.vue +41 -16
- package/dist/runtime/components/Table/Base.vue.d.ts +7 -2
- package/dist/runtime/components/Table/index.d.vue.ts +1 -0
- package/dist/runtime/components/Table/index.vue +3 -1
- package/dist/runtime/components/Table/index.vue.d.ts +1 -0
- package/dist/runtime/composables/useTable.js +27 -9
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -5,10 +5,15 @@ type __VLS_Props = {
|
|
|
5
5
|
ui?: (typeof tableTheme)['slots'];
|
|
6
6
|
to?: string | ((row: any) => any);
|
|
7
7
|
target?: string | ((row: any) => string | undefined);
|
|
8
|
+
preserveQuery?: boolean;
|
|
8
9
|
};
|
|
9
|
-
declare var __VLS_25: {}, __VLS_32: {}, __VLS_34: {},
|
|
10
|
+
declare var __VLS_25: {}, __VLS_32: {}, __VLS_34: {}, __VLS_47: any, __VLS_48: {
|
|
11
|
+
row: any;
|
|
12
|
+
}, __VLS_57: any, __VLS_58: any;
|
|
10
13
|
type __VLS_Slots = {} & {
|
|
11
|
-
[K in NonNullable<typeof
|
|
14
|
+
[K in NonNullable<typeof __VLS_47>]?: (props: typeof __VLS_48) => any;
|
|
15
|
+
} & {
|
|
16
|
+
[K in NonNullable<typeof __VLS_57>]?: (props: typeof __VLS_58) => any;
|
|
12
17
|
} & {
|
|
13
18
|
loading?: (props: typeof __VLS_25) => any;
|
|
14
19
|
} & {
|
|
@@ -74,24 +74,29 @@
|
|
|
74
74
|
to && column.accessorKey !== 'actions' ? 'pointer-events-none relative z-10' : 'relative z-10'
|
|
75
75
|
"
|
|
76
76
|
>
|
|
77
|
-
<
|
|
78
|
-
:
|
|
77
|
+
<slot
|
|
78
|
+
:name="`${column.accessorKey}-cell`"
|
|
79
|
+
:row="row"
|
|
80
|
+
>
|
|
81
|
+
<component
|
|
82
|
+
:is="
|
|
79
83
|
column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]
|
|
80
84
|
"
|
|
81
|
-
|
|
85
|
+
v-if="
|
|
82
86
|
column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]
|
|
83
87
|
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
:value="transformValue(column, row)"
|
|
89
|
+
:column="column"
|
|
90
|
+
:row="row"
|
|
91
|
+
/>
|
|
92
|
+
<template v-else>
|
|
93
|
+
{{ transformValue(column, row) }}
|
|
94
|
+
</template>
|
|
95
|
+
</slot>
|
|
91
96
|
</div>
|
|
92
97
|
</template>
|
|
93
98
|
<template
|
|
94
|
-
v-for="
|
|
99
|
+
v-for="slotName in forwardedSlotNames"
|
|
95
100
|
:key="slotName"
|
|
96
101
|
#[slotName]="slotProps"
|
|
97
102
|
>
|
|
@@ -116,7 +121,7 @@
|
|
|
116
121
|
</template>
|
|
117
122
|
|
|
118
123
|
<script setup>
|
|
119
|
-
import { computed, ref } from "vue";
|
|
124
|
+
import { computed, ref, useSlots } from "vue";
|
|
120
125
|
import {
|
|
121
126
|
COLUMN_TYPES
|
|
122
127
|
} from "#core/components/Table/types";
|
|
@@ -124,6 +129,7 @@ import ColumnNumber from "#core/components/Table/ColumnNumber.vue";
|
|
|
124
129
|
import ColumnImage from "#core/components/Table/ColumnImage.vue";
|
|
125
130
|
import {
|
|
126
131
|
useAppConfig,
|
|
132
|
+
useRoute,
|
|
127
133
|
useUiConfig,
|
|
128
134
|
useWatchChange,
|
|
129
135
|
StringHelper
|
|
@@ -140,8 +146,14 @@ const props = defineProps({
|
|
|
140
146
|
options: { type: Object, required: true },
|
|
141
147
|
ui: { type: null, required: false },
|
|
142
148
|
to: { type: [String, Function], required: false },
|
|
143
|
-
target: { type: [String, Function], required: false }
|
|
149
|
+
target: { type: [String, Function], required: false },
|
|
150
|
+
preserveQuery: { type: Boolean, required: false }
|
|
144
151
|
});
|
|
152
|
+
const route = useRoute();
|
|
153
|
+
const slots = useSlots();
|
|
154
|
+
const forwardedSlotNames = computed(
|
|
155
|
+
() => Object.keys(slots).filter((name) => !name.endsWith("-cell"))
|
|
156
|
+
);
|
|
145
157
|
const columnTypeComponents = {
|
|
146
158
|
[COLUMN_TYPES.NUMBER]: ColumnNumber,
|
|
147
159
|
[COLUMN_TYPES.IMAGE]: ColumnImage,
|
|
@@ -171,10 +183,23 @@ const transformValue = (column, row) => {
|
|
|
171
183
|
return row.getValue(column.accessorKey);
|
|
172
184
|
};
|
|
173
185
|
const resolveTo = (rowOriginal) => {
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
const resolved = typeof props.to === "function" ? props.to(rowOriginal) : props.to;
|
|
187
|
+
if (!props.preserveQuery || !resolved) {
|
|
188
|
+
return resolved;
|
|
189
|
+
}
|
|
190
|
+
if (typeof resolved === "string") {
|
|
191
|
+
return {
|
|
192
|
+
path: resolved,
|
|
193
|
+
query: route.query
|
|
194
|
+
};
|
|
176
195
|
}
|
|
177
|
-
return
|
|
196
|
+
return {
|
|
197
|
+
...resolved,
|
|
198
|
+
query: {
|
|
199
|
+
...route.query,
|
|
200
|
+
...resolved.query || {}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
178
203
|
};
|
|
179
204
|
const resolveTarget = (rowOriginal) => {
|
|
180
205
|
if (typeof props.target === "function") {
|
|
@@ -5,10 +5,15 @@ type __VLS_Props = {
|
|
|
5
5
|
ui?: (typeof tableTheme)['slots'];
|
|
6
6
|
to?: string | ((row: any) => any);
|
|
7
7
|
target?: string | ((row: any) => string | undefined);
|
|
8
|
+
preserveQuery?: boolean;
|
|
8
9
|
};
|
|
9
|
-
declare var __VLS_25: {}, __VLS_32: {}, __VLS_34: {},
|
|
10
|
+
declare var __VLS_25: {}, __VLS_32: {}, __VLS_34: {}, __VLS_47: any, __VLS_48: {
|
|
11
|
+
row: any;
|
|
12
|
+
}, __VLS_57: any, __VLS_58: any;
|
|
10
13
|
type __VLS_Slots = {} & {
|
|
11
|
-
[K in NonNullable<typeof
|
|
14
|
+
[K in NonNullable<typeof __VLS_47>]?: (props: typeof __VLS_48) => any;
|
|
15
|
+
} & {
|
|
16
|
+
[K in NonNullable<typeof __VLS_57>]?: (props: typeof __VLS_58) => any;
|
|
12
17
|
} & {
|
|
13
18
|
loading?: (props: typeof __VLS_25) => any;
|
|
14
19
|
} & {
|
|
@@ -14,6 +14,7 @@ type __VLS_Props = {
|
|
|
14
14
|
};
|
|
15
15
|
to?: string | ((row: any) => any);
|
|
16
16
|
target?: string | ((row: any) => string | undefined);
|
|
17
|
+
preserveQuery?: boolean;
|
|
17
18
|
};
|
|
18
19
|
type __VLS_Slots = Slot;
|
|
19
20
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
:column-pinning="computedColumnPinning"
|
|
22
22
|
:to="to"
|
|
23
23
|
:target="target"
|
|
24
|
+
:preserve-query="preserveQuery"
|
|
24
25
|
@page-change="onPageChange"
|
|
25
26
|
@search="emits('search', q)"
|
|
26
27
|
@select="emits('select', $event)"
|
|
@@ -53,7 +54,8 @@ const props = defineProps({
|
|
|
53
54
|
right: []
|
|
54
55
|
}) },
|
|
55
56
|
to: { type: [String, Function], required: false },
|
|
56
|
-
target: { type: [String, Function], required: false }
|
|
57
|
+
target: { type: [String, Function], required: false },
|
|
58
|
+
preserveQuery: { type: Boolean, required: false }
|
|
57
59
|
});
|
|
58
60
|
defineSlots();
|
|
59
61
|
const tableContainer = ref();
|
|
@@ -14,6 +14,7 @@ type __VLS_Props = {
|
|
|
14
14
|
};
|
|
15
15
|
to?: string | ((row: any) => any);
|
|
16
16
|
target?: string | ((row: any) => string | undefined);
|
|
17
|
+
preserveQuery?: boolean;
|
|
17
18
|
};
|
|
18
19
|
type __VLS_Slots = Slot;
|
|
19
20
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
@@ -1,20 +1,38 @@
|
|
|
1
1
|
import { get } from "@vueuse/core";
|
|
2
2
|
import { computed, ObjectHelper } from "#imports";
|
|
3
3
|
export const useTable = (options) => computed(() => {
|
|
4
|
+
const {
|
|
5
|
+
repo,
|
|
6
|
+
columns,
|
|
7
|
+
transformItems,
|
|
8
|
+
options: nestedOptions,
|
|
9
|
+
...inlineOptions
|
|
10
|
+
} = options;
|
|
4
11
|
return createTableOptions(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
repo,
|
|
13
|
+
columns(),
|
|
14
|
+
{
|
|
15
|
+
...inlineOptions,
|
|
16
|
+
...typeof nestedOptions === "function" ? nestedOptions() : nestedOptions ?? {}
|
|
17
|
+
},
|
|
18
|
+
transformItems
|
|
9
19
|
);
|
|
10
20
|
});
|
|
11
21
|
export const useTableSimple = (options) => computed(() => {
|
|
22
|
+
const {
|
|
23
|
+
items,
|
|
24
|
+
status,
|
|
25
|
+
columns,
|
|
26
|
+
options: nestedOptions,
|
|
27
|
+
...inlineOptions
|
|
28
|
+
} = options;
|
|
12
29
|
return {
|
|
13
|
-
items:
|
|
14
|
-
columns:
|
|
15
|
-
rawData:
|
|
16
|
-
status:
|
|
17
|
-
...
|
|
30
|
+
items: items(),
|
|
31
|
+
columns: columns(),
|
|
32
|
+
rawData: items(),
|
|
33
|
+
status: status ? status() : ObjectHelper.createStatus(),
|
|
34
|
+
...inlineOptions,
|
|
35
|
+
...typeof nestedOptions === "function" ? nestedOptions() : nestedOptions ?? {}
|
|
18
36
|
};
|
|
19
37
|
});
|
|
20
38
|
export const createTableOptions = (repo, columns, options, transformItems) => {
|