@webitel/ui-sdk 25.10.29 → 25.10.31
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": "@webitel/ui-sdk",
|
|
3
|
-
"version": "25.10.
|
|
3
|
+
"version": "25.10.31",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"make-all": "npm version patch --git-tag-version false && npm run build && (npm run build:types || true) && (npm run lint:fix || true) && npm run publish-lib",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--wt-label-padding: var(--spacing-2xs) var(--spacing-xs);
|
|
3
3
|
|
|
4
|
-
--wt-label-color: var(--
|
|
5
|
-
--wt-label-error-color: var(--
|
|
6
|
-
--wt-label-disabled-color: var(--
|
|
4
|
+
--wt-label-color: var(--p-form-field-color);
|
|
5
|
+
--wt-label-error-color: var(--p-error-color);
|
|
6
|
+
--wt-label-disabled-color: var(--p-form-field-disabled-color);
|
|
7
7
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import applyTransform, { notify } from '@webitel/ui-sdk/api/transformers/index';
|
|
2
|
+
import { computed, Ref, ref } from 'vue';
|
|
3
|
+
import { useRoute } from 'vue-router';
|
|
4
|
+
|
|
5
|
+
import CSVExport from '../CSVExport';
|
|
6
|
+
|
|
7
|
+
export type CSVRow = Record<string, any>;
|
|
8
|
+
|
|
9
|
+
export type FetchMethod = (params: Record<string, any>) => Promise<{
|
|
10
|
+
items: CSVRow[];
|
|
11
|
+
next: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
|
|
14
|
+
interface CSVExportOptions {
|
|
15
|
+
filename?: string;
|
|
16
|
+
delimiter?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const CSV_EXPORT_BATCH_SIZE = 5000;
|
|
20
|
+
|
|
21
|
+
export function useCSVExport({ selected }: { selected: Ref<number[]> }) {
|
|
22
|
+
const CSVExportInstance = ref<null | InstanceType<typeof CSVExport>>(null);
|
|
23
|
+
const route = useRoute();
|
|
24
|
+
|
|
25
|
+
const CSVDownloadProgress = computed(() =>
|
|
26
|
+
CSVExportInstance.value
|
|
27
|
+
? CSVExportInstance.value.downloadProgress.count
|
|
28
|
+
: 0,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const isCSVLoading = computed(() => !!CSVDownloadProgress.value);
|
|
32
|
+
|
|
33
|
+
const isAnySelected = computed(() => !!selected.value.length);
|
|
34
|
+
|
|
35
|
+
function initCSVExport(
|
|
36
|
+
fetchMethod: FetchMethod,
|
|
37
|
+
options: CSVExportOptions = {},
|
|
38
|
+
) {
|
|
39
|
+
CSVExportInstance.value = new CSVExport(fetchMethod, options);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function exportCSV(exportParams?: Record<string, any>) {
|
|
43
|
+
const routeQuery = route.query;
|
|
44
|
+
const params = {
|
|
45
|
+
...(exportParams || routeQuery),
|
|
46
|
+
size: CSV_EXPORT_BATCH_SIZE,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (isAnySelected.value) {
|
|
50
|
+
params.id = selected.value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
await CSVExportInstance.value?.export(params);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
throw applyTransform(err, [notify]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
CSVExportInstance,
|
|
62
|
+
|
|
63
|
+
CSVDownloadProgress,
|
|
64
|
+
isCSVLoading,
|
|
65
|
+
isAnySelected,
|
|
66
|
+
|
|
67
|
+
initCSVExport,
|
|
68
|
+
exportCSV,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import CSVExport from '../CSVExport';
|
|
3
|
+
export type CSVRow = Record<string, any>;
|
|
4
|
+
export type FetchMethod = (params: Record<string, any>) => Promise<{
|
|
5
|
+
items: CSVRow[];
|
|
6
|
+
next: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
interface CSVExportOptions {
|
|
9
|
+
filename?: string;
|
|
10
|
+
delimiter?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function useCSVExport({ selected }: {
|
|
13
|
+
selected: Ref<number[]>;
|
|
14
|
+
}): {
|
|
15
|
+
CSVExportInstance: Ref<{
|
|
16
|
+
filename: string;
|
|
17
|
+
fetchMethod: any;
|
|
18
|
+
downloadProgress: {
|
|
19
|
+
count: number;
|
|
20
|
+
};
|
|
21
|
+
delimiter: any;
|
|
22
|
+
resetProgress: () => void;
|
|
23
|
+
zippingProgress: {
|
|
24
|
+
percent: number;
|
|
25
|
+
};
|
|
26
|
+
save: (csv: any) => void;
|
|
27
|
+
stringify: (params?: {}) => Promise<string>;
|
|
28
|
+
export: (params: any) => Promise<void>;
|
|
29
|
+
}, CSVExport | {
|
|
30
|
+
filename: string;
|
|
31
|
+
fetchMethod: any;
|
|
32
|
+
downloadProgress: {
|
|
33
|
+
count: number;
|
|
34
|
+
};
|
|
35
|
+
delimiter: any;
|
|
36
|
+
resetProgress: () => void;
|
|
37
|
+
zippingProgress: {
|
|
38
|
+
percent: number;
|
|
39
|
+
};
|
|
40
|
+
save: (csv: any) => void;
|
|
41
|
+
stringify: (params?: {}) => Promise<string>;
|
|
42
|
+
export: (params: any) => Promise<void>;
|
|
43
|
+
}>;
|
|
44
|
+
CSVDownloadProgress: import("vue").ComputedRef<number>;
|
|
45
|
+
isCSVLoading: import("vue").ComputedRef<boolean>;
|
|
46
|
+
isAnySelected: import("vue").ComputedRef<boolean>;
|
|
47
|
+
initCSVExport: (fetchMethod: FetchMethod, options?: CSVExportOptions) => void;
|
|
48
|
+
exportCSV: (exportParams?: Record<string, any>) => Promise<void>;
|
|
49
|
+
};
|
|
50
|
+
export {};
|