@vc-shell/framework 1.0.158 → 1.0.159
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/CHANGELOG.md +9 -0
- package/dist/framework.js +480 -474
- package/dist/shared/components/blade-navigation/components/vc-blade-navigation/vc-blade-navigation.vue.d.ts.map +1 -1
- package/dist/shared/modules/dynamic/composables/useFilterBuilder/index.d.ts +3 -17
- package/dist/shared/modules/dynamic/composables/useFilterBuilder/index.d.ts.map +1 -1
- package/dist/shared/modules/dynamic/pages/dynamic-blade-list.vue.d.ts.map +1 -1
- package/dist/shared/modules/dynamic/types/index.d.ts +3 -4
- package/dist/shared/modules/dynamic/types/index.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/shared/components/blade-navigation/components/vc-blade-navigation/vc-blade-navigation.vue +0 -5
- package/shared/modules/dynamic/composables/useFilterBuilder/index.ts +86 -83
- package/shared/modules/dynamic/pages/dynamic-blade-list.vue +1 -0
- package/shared/modules/dynamic/types/index.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vc-shell/framework",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.159",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/framework.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"whatwg-fetch": "^3.6.19"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@vc-shell/api-client-generator": "^1.0.
|
|
57
|
-
"@vc-shell/config-generator": "^1.0.
|
|
58
|
-
"@vc-shell/ts-config": "^1.0.
|
|
56
|
+
"@vc-shell/api-client-generator": "^1.0.159",
|
|
57
|
+
"@vc-shell/config-generator": "^1.0.159",
|
|
58
|
+
"@vc-shell/ts-config": "^1.0.159",
|
|
59
59
|
"@vitejs/plugin-vue": "^5.0.3",
|
|
60
60
|
"sass": "^1.69.6",
|
|
61
61
|
"typescript": "^5.3.3",
|
package/shared/components/blade-navigation/components/vc-blade-navigation/vc-blade-navigation.vue
CHANGED
|
@@ -44,11 +44,6 @@ const render = () => {
|
|
|
44
44
|
closable: index >= 1,
|
|
45
45
|
expandable: quantity.value > 1,
|
|
46
46
|
expanded: index === quantity.value - 1,
|
|
47
|
-
"onUpdate:expanded": (value: boolean) => {
|
|
48
|
-
if (value) {
|
|
49
|
-
closeBlade(index + 1);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
47
|
"onClose:blade": () => closeBlade(index),
|
|
53
48
|
"onParent:call": (args: IParentCallArgs) => {
|
|
54
49
|
const instance = blades.value?.[index - 1]?.props?.navigation?.instance.value;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import {
|
|
2
3
|
h,
|
|
3
4
|
ref,
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
ComputedRef,
|
|
14
15
|
readonly,
|
|
15
16
|
toValue,
|
|
17
|
+
Ref,
|
|
16
18
|
} from "vue";
|
|
17
19
|
import * as _ from "lodash-es";
|
|
18
20
|
import { Checkbox, InputField } from "../../components/factories";
|
|
@@ -20,14 +22,8 @@ import { AsyncAction } from "../../../../../core/composables";
|
|
|
20
22
|
import { VcButton, VcCol, VcContainer, VcRow } from "../../../../../ui/components";
|
|
21
23
|
import { createUnrefFn } from "@vueuse/core";
|
|
22
24
|
import { useI18n } from "vue-i18n";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
field: string;
|
|
26
|
-
component: string;
|
|
27
|
-
label?: string;
|
|
28
|
-
multiple?: boolean;
|
|
29
|
-
data?: { value: string; displayName: string }[];
|
|
30
|
-
}
|
|
25
|
+
import { FilterBase, FilterCheckbox, FilterDateInput } from "../../types";
|
|
26
|
+
import { onBeforeUnmount } from "vue";
|
|
31
27
|
|
|
32
28
|
interface Control {
|
|
33
29
|
title: string;
|
|
@@ -36,13 +32,6 @@ interface Control {
|
|
|
36
32
|
};
|
|
37
33
|
}
|
|
38
34
|
|
|
39
|
-
interface Data {
|
|
40
|
-
columns: {
|
|
41
|
-
title: string;
|
|
42
|
-
controls: RawControl[];
|
|
43
|
-
}[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
35
|
export interface UseFilterBuilder {
|
|
47
36
|
filterComponent: (slotMethods: { close: () => void }) =>
|
|
48
37
|
| VNode<
|
|
@@ -62,15 +51,16 @@ export interface UseFilterBuilder {
|
|
|
62
51
|
}
|
|
63
52
|
|
|
64
53
|
export default <Query>(args: {
|
|
65
|
-
data:
|
|
54
|
+
data: FilterBase | undefined;
|
|
66
55
|
query: MaybeRef<Query>;
|
|
67
56
|
load: AsyncAction<Query>;
|
|
57
|
+
scope: ComputedRef<Record<string, any>> | undefined;
|
|
68
58
|
}): UseFilterBuilder => {
|
|
69
59
|
const _search = args.load;
|
|
70
60
|
const _data = args.data;
|
|
71
61
|
|
|
72
62
|
const isFilterVisible = ref(true);
|
|
73
|
-
const filter: Record<string, unknown
|
|
63
|
+
const filter: Ref<Record<string, unknown>> = ref({});
|
|
74
64
|
const { t } = useI18n({ useScope: "global" });
|
|
75
65
|
|
|
76
66
|
const controls = ref<Control[]>([]);
|
|
@@ -86,7 +76,7 @@ export default <Query>(args: {
|
|
|
86
76
|
onMounted(() => createFilterControls());
|
|
87
77
|
|
|
88
78
|
function isItemSelected(value: string, field: string) {
|
|
89
|
-
const item = filter[field];
|
|
79
|
+
const item = filter.value[field];
|
|
90
80
|
if (Array.isArray(item) && typeof item !== "string") {
|
|
91
81
|
return item.some((x) => x === value);
|
|
92
82
|
} else {
|
|
@@ -96,13 +86,13 @@ export default <Query>(args: {
|
|
|
96
86
|
|
|
97
87
|
function selectFilterItem(e: boolean, value: string, field: string, multiple = true) {
|
|
98
88
|
if (multiple) {
|
|
99
|
-
filter[field] = e
|
|
100
|
-
? [...((filter[field] as string[]) || []), value]
|
|
101
|
-
: ((filter[field] as string[]) || []).filter((x) => x !== value);
|
|
89
|
+
filter.value[field] = e
|
|
90
|
+
? [...((filter.value[field] as string[]) || []), value]
|
|
91
|
+
: ((filter.value[field] as string[]) || []).filter((x) => x !== value);
|
|
102
92
|
|
|
103
|
-
if (!(filter[field] as string[]).length) filter[field] = undefined;
|
|
93
|
+
if (!(filter.value[field] as string[]).length) filter.value[field] = undefined;
|
|
104
94
|
} else {
|
|
105
|
-
filter[field] = e ? value : undefined;
|
|
95
|
+
filter.value[field] = e ? value : undefined;
|
|
106
96
|
}
|
|
107
97
|
}
|
|
108
98
|
|
|
@@ -116,7 +106,8 @@ export default <Query>(args: {
|
|
|
116
106
|
(obj, control) => {
|
|
117
107
|
if (control.component === "vc-checkbox") {
|
|
118
108
|
const filterData = control.data;
|
|
119
|
-
const
|
|
109
|
+
const filterDataFromScope = unref(args.scope)?.[filterData] ?? [];
|
|
110
|
+
const fields = createCheckboxFromData(filterDataFromScope, control);
|
|
120
111
|
|
|
121
112
|
if (fields) {
|
|
122
113
|
obj = fields;
|
|
@@ -138,18 +129,20 @@ export default <Query>(args: {
|
|
|
138
129
|
});
|
|
139
130
|
}
|
|
140
131
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
132
|
+
// TODO add to documentation support of dynamic data for filter
|
|
133
|
+
function createCheckboxFromData(data: MaybeRef<Record<string, string>[]>, control: FilterCheckbox) {
|
|
134
|
+
if (!(toValue(data) && toValue(data).length)) return;
|
|
135
|
+
return toValue(data).reduce(
|
|
144
136
|
(obj, currC) => {
|
|
145
|
-
obj[currC.
|
|
137
|
+
obj[currC[control.optionValue]] = Checkbox({
|
|
146
138
|
props: {
|
|
147
139
|
class: "tw-mb-2",
|
|
148
|
-
modelValue: computed(() => isItemSelected(currC.
|
|
149
|
-
"onUpdate:modelValue": (e: boolean) =>
|
|
140
|
+
modelValue: computed(() => isItemSelected(currC[control.optionValue], control.field)),
|
|
141
|
+
"onUpdate:modelValue": (e: boolean) =>
|
|
142
|
+
selectFilterItem(e, currC[control.optionValue], control.field, control.multiple),
|
|
150
143
|
},
|
|
151
144
|
slots: {
|
|
152
|
-
default: () =>
|
|
145
|
+
default: () => toValue(currC[control.optionLabel]),
|
|
153
146
|
},
|
|
154
147
|
});
|
|
155
148
|
|
|
@@ -159,14 +152,14 @@ export default <Query>(args: {
|
|
|
159
152
|
);
|
|
160
153
|
}
|
|
161
154
|
|
|
162
|
-
function createInput(control:
|
|
155
|
+
function createInput(control: FilterDateInput) {
|
|
163
156
|
return InputField({
|
|
164
157
|
props: {
|
|
165
158
|
type: "date",
|
|
166
159
|
class: "tw-mb-3",
|
|
167
160
|
label: toValue(computed(() => t(control.label ?? ""))),
|
|
168
|
-
modelValue: computed(() => filter[control.field]),
|
|
169
|
-
"onUpdate:modelValue": (e: unknown) => (filter[control.field] = e),
|
|
161
|
+
modelValue: computed(() => filter.value[control.field]),
|
|
162
|
+
"onUpdate:modelValue": (e: unknown) => (filter.value[control.field] = e),
|
|
170
163
|
},
|
|
171
164
|
});
|
|
172
165
|
}
|
|
@@ -175,10 +168,10 @@ export default <Query>(args: {
|
|
|
175
168
|
filterHandlerFn();
|
|
176
169
|
await _search({
|
|
177
170
|
...unref(args.query),
|
|
178
|
-
...filter,
|
|
171
|
+
...filter.value,
|
|
179
172
|
});
|
|
180
173
|
appliedFilter.value = {
|
|
181
|
-
...filter,
|
|
174
|
+
...filter.value,
|
|
182
175
|
};
|
|
183
176
|
}
|
|
184
177
|
|
|
@@ -189,62 +182,72 @@ export default <Query>(args: {
|
|
|
189
182
|
|
|
190
183
|
await _search({
|
|
191
184
|
...unref(args.query),
|
|
192
|
-
...filter,
|
|
185
|
+
...filter.value,
|
|
193
186
|
});
|
|
194
187
|
}
|
|
195
188
|
|
|
196
189
|
function render(slotMethods: { close: () => void }) {
|
|
197
190
|
if (_.isEmpty(controls.value)) return;
|
|
198
|
-
return h(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
191
|
+
return h(
|
|
192
|
+
VcContainer,
|
|
193
|
+
{
|
|
194
|
+
onVnodeBeforeMount: () => {
|
|
195
|
+
if (Object.keys(appliedFilter.value).length) {
|
|
196
|
+
filter.value = _.cloneDeep(appliedFilter.value);
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
() => [
|
|
201
|
+
h(VcRow, () =>
|
|
202
|
+
Object.values(controls.value).map(({ title, fields }) =>
|
|
203
|
+
h(VcCol, { class: "tw-p-2" }, () => [
|
|
204
|
+
h(
|
|
205
|
+
"div",
|
|
206
|
+
{ class: "tw-mb-4 tw-text-[#a1c0d4] tw-font-bold tw-text-[17px]" },
|
|
207
|
+
unref(computed(() => t(title))),
|
|
208
|
+
),
|
|
209
|
+
Object.values(fields).map((item) => {
|
|
210
|
+
if ("component" in item && item.component) {
|
|
211
|
+
return h(
|
|
212
|
+
item.component as Component,
|
|
213
|
+
{ ...item.props, class: item.props.class },
|
|
214
|
+
"slots" in item && item.slots ? { ...item.slots } : {},
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
}),
|
|
218
|
+
]),
|
|
219
|
+
),
|
|
217
220
|
),
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
),
|
|
240
|
-
|
|
221
|
+
h(VcRow, () =>
|
|
222
|
+
h(VcCol, { class: "tw-p-2" }, () =>
|
|
223
|
+
h("div", { class: "tw-flex tw-justify-end" }, [
|
|
224
|
+
h(
|
|
225
|
+
VcButton,
|
|
226
|
+
{
|
|
227
|
+
outline: true,
|
|
228
|
+
class: "tw-mr-4",
|
|
229
|
+
disabled: isDisabled(appliedFilter),
|
|
230
|
+
onClick: () => resetFilters(slotMethods.close),
|
|
231
|
+
},
|
|
232
|
+
() => t("COMPONENTS.FILTERS.RESET"),
|
|
233
|
+
),
|
|
234
|
+
h(
|
|
235
|
+
VcButton,
|
|
236
|
+
{
|
|
237
|
+
disabled: isDisabled(filter),
|
|
238
|
+
onClick: () => applyFilters(slotMethods.close),
|
|
239
|
+
},
|
|
240
|
+
() => t("COMPONENTS.FILTERS.APPLY"),
|
|
241
|
+
),
|
|
242
|
+
]),
|
|
243
|
+
),
|
|
241
244
|
),
|
|
242
|
-
|
|
243
|
-
|
|
245
|
+
],
|
|
246
|
+
);
|
|
244
247
|
}
|
|
245
248
|
|
|
246
249
|
async function reset() {
|
|
247
|
-
Object.keys(filter).forEach((key: string) => (filter[key] = undefined));
|
|
250
|
+
Object.keys(filter).forEach((key: string) => (filter.value[key] = undefined));
|
|
248
251
|
|
|
249
252
|
appliedFilter.value = {};
|
|
250
253
|
}
|
|
@@ -252,7 +255,7 @@ export default <Query>(args: {
|
|
|
252
255
|
return {
|
|
253
256
|
filterComponent: render,
|
|
254
257
|
activeFilterCount,
|
|
255
|
-
filter: readonly(filter),
|
|
258
|
+
filter: readonly(filter.value),
|
|
256
259
|
isFilterVisible: computed(() => isFilterVisible.value),
|
|
257
260
|
reset,
|
|
258
261
|
};
|
|
@@ -912,7 +912,9 @@ export type FilterCheckbox = {
|
|
|
912
912
|
id: string;
|
|
913
913
|
field: string;
|
|
914
914
|
multiple?: boolean;
|
|
915
|
-
data
|
|
915
|
+
data: string;
|
|
916
|
+
optionValue: string;
|
|
917
|
+
optionLabel: string;
|
|
916
918
|
component: CheckboxSchema["component"];
|
|
917
919
|
};
|
|
918
920
|
|