sprintify-ui 0.10.38 → 0.10.40
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/sprintify-ui.es.js +2700 -2703
- package/dist/types/components/BaseDataIterator.vue.d.ts +3 -3
- package/dist/types/components/BaseDataTable.vue.d.ts +11 -35
- package/dist/types/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/BaseDataIterator.vue +12 -1
- package/src/components/BaseDataTable.vue +38 -28
- package/src/components/BaseDataTableRowAction.vue +44 -52
- package/src/types/index.ts +1 -1
|
@@ -263,7 +263,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<import("vu
|
|
|
263
263
|
filter?: Record<string, any> | undefined;
|
|
264
264
|
};
|
|
265
265
|
updateQuery: (newQuery: DataTableQuery) => void;
|
|
266
|
-
updateQueryValue: (key: string, value: any) => void;
|
|
266
|
+
updateQueryValue: (key: string | DataTableQuery, value: any) => void;
|
|
267
267
|
updateQueryValueDebounce: import("lodash").DebouncedFunc<(key: string, value: any) => void>;
|
|
268
268
|
}) => any) & ((props: {
|
|
269
269
|
query: {
|
|
@@ -274,7 +274,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<import("vu
|
|
|
274
274
|
filter?: Record<string, any> | undefined;
|
|
275
275
|
};
|
|
276
276
|
updateQuery: (newQuery: DataTableQuery) => void;
|
|
277
|
-
updateQueryValue: (key: string, value: any) => void;
|
|
277
|
+
updateQueryValue: (key: string | DataTableQuery, value: any) => void;
|
|
278
278
|
updateQueryValueDebounce: import("lodash").DebouncedFunc<(key: string, value: any) => void>;
|
|
279
279
|
}) => any) & ((props: {
|
|
280
280
|
query: {
|
|
@@ -285,7 +285,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<import("vu
|
|
|
285
285
|
filter?: Record<string, any> | undefined;
|
|
286
286
|
};
|
|
287
287
|
updateQuery: (newQuery: DataTableQuery) => void;
|
|
288
|
-
updateQueryValue: (key: string, value: any) => void;
|
|
288
|
+
updateQueryValue: (key: string | DataTableQuery, value: any) => void;
|
|
289
289
|
updateQueryValueDebounce: import("lodash").DebouncedFunc<(key: string, value: any) => void>;
|
|
290
290
|
}) => any)) | undefined;
|
|
291
291
|
default?: ((props: {
|
|
@@ -246,13 +246,7 @@ declare const table: import("vue").Ref<({
|
|
|
246
246
|
};
|
|
247
247
|
$forceUpdate: () => void;
|
|
248
248
|
$nextTick: typeof import("vue").nextTick;
|
|
249
|
-
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import("@vue/reactivity").OnCleanup]) => any : (
|
|
250
|
-
/**
|
|
251
|
-
* Checked rows array
|
|
252
|
-
*/
|
|
253
|
-
... /**
|
|
254
|
-
* Checked rows array
|
|
255
|
-
*/args: [any, any, import("@vue/reactivity").OnCleanup]) => any, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
|
|
249
|
+
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import("@vue/reactivity").OnCleanup]) => any : (...args: [any, any, import("@vue/reactivity").OnCleanup]) => any, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
|
|
256
250
|
} & Readonly<{
|
|
257
251
|
data: import("@/types").Row[];
|
|
258
252
|
size: "xs" | "sm" | "md" | "lg" | "xl";
|
|
@@ -626,13 +620,7 @@ declare const table: import("vue").Ref<({
|
|
|
626
620
|
};
|
|
627
621
|
$forceUpdate: () => void;
|
|
628
622
|
$nextTick: typeof import("vue").nextTick;
|
|
629
|
-
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import("@vue/reactivity").OnCleanup]) => any : (
|
|
630
|
-
/**
|
|
631
|
-
* Checked rows array
|
|
632
|
-
*/
|
|
633
|
-
... /**
|
|
634
|
-
* Checked rows array
|
|
635
|
-
*/args: [any, any, import("@vue/reactivity").OnCleanup]) => any, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
|
|
623
|
+
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import("@vue/reactivity").OnCleanup]) => any : (...args: [any, any, import("@vue/reactivity").OnCleanup]) => any, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
|
|
636
624
|
} & Readonly<{
|
|
637
625
|
data: import("@/types").Row[];
|
|
638
626
|
size: "xs" | "sm" | "md" | "lg" | "xl";
|
|
@@ -959,13 +947,7 @@ declare const dataIteratorRef: import("vue").Ref<({
|
|
|
959
947
|
};
|
|
960
948
|
$forceUpdate: () => void;
|
|
961
949
|
$nextTick: typeof import("vue").nextTick;
|
|
962
|
-
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import("@vue/reactivity").OnCleanup]) => any : (
|
|
963
|
-
/**
|
|
964
|
-
* Checked rows array
|
|
965
|
-
*/
|
|
966
|
-
... /**
|
|
967
|
-
* Checked rows array
|
|
968
|
-
*/args: [any, any, import("@vue/reactivity").OnCleanup]) => any, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
|
|
950
|
+
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import("@vue/reactivity").OnCleanup]) => any : (...args: [any, any, import("@vue/reactivity").OnCleanup]) => any, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
|
|
969
951
|
} & Readonly<{
|
|
970
952
|
search: (items: Collection, search: string | null) => Collection;
|
|
971
953
|
size: "xs" | "sm" | "md" | "lg" | "xl";
|
|
@@ -1071,7 +1053,7 @@ declare const dataIteratorRef: import("vue").Ref<({
|
|
|
1071
1053
|
filter?: Record<string, any> | undefined;
|
|
1072
1054
|
};
|
|
1073
1055
|
updateQuery: (newQuery: DataTableQuery) => void;
|
|
1074
|
-
updateQueryValue: (key: string, value: any) => void;
|
|
1056
|
+
updateQueryValue: (key: string | DataTableQuery, value: any) => void;
|
|
1075
1057
|
updateQueryValueDebounce: import("lodash").DebouncedFunc<(key: string, value: any) => void>;
|
|
1076
1058
|
}) => any) & ((props: {
|
|
1077
1059
|
query: {
|
|
@@ -1082,7 +1064,7 @@ declare const dataIteratorRef: import("vue").Ref<({
|
|
|
1082
1064
|
filter?: Record<string, any> | undefined;
|
|
1083
1065
|
};
|
|
1084
1066
|
updateQuery: (newQuery: DataTableQuery) => void;
|
|
1085
|
-
updateQueryValue: (key: string, value: any) => void;
|
|
1067
|
+
updateQueryValue: (key: string | DataTableQuery, value: any) => void;
|
|
1086
1068
|
updateQueryValueDebounce: import("lodash").DebouncedFunc<(key: string, value: any) => void>;
|
|
1087
1069
|
}) => any) & ((props: {
|
|
1088
1070
|
query: {
|
|
@@ -1093,7 +1075,7 @@ declare const dataIteratorRef: import("vue").Ref<({
|
|
|
1093
1075
|
filter?: Record<string, any> | undefined;
|
|
1094
1076
|
};
|
|
1095
1077
|
updateQuery: (newQuery: DataTableQuery) => void;
|
|
1096
|
-
updateQueryValue: (key: string, value: any) => void;
|
|
1078
|
+
updateQueryValue: (key: string | DataTableQuery, value: any) => void;
|
|
1097
1079
|
updateQueryValueDebounce: import("lodash").DebouncedFunc<(key: string, value: any) => void>;
|
|
1098
1080
|
}) => any)) | undefined;
|
|
1099
1081
|
default?: ((props: {
|
|
@@ -1307,13 +1289,7 @@ declare const dataIteratorRef: import("vue").Ref<({
|
|
|
1307
1289
|
};
|
|
1308
1290
|
$forceUpdate: () => void;
|
|
1309
1291
|
$nextTick: typeof import("vue").nextTick;
|
|
1310
|
-
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import("@vue/reactivity").OnCleanup]) => any : (
|
|
1311
|
-
/**
|
|
1312
|
-
* Checked rows array
|
|
1313
|
-
*/
|
|
1314
|
-
... /**
|
|
1315
|
-
* Checked rows array
|
|
1316
|
-
*/args: [any, any, import("@vue/reactivity").OnCleanup]) => any, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
|
|
1292
|
+
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import("@vue/reactivity").OnCleanup]) => any : (...args: [any, any, import("@vue/reactivity").OnCleanup]) => any, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
|
|
1317
1293
|
} & Readonly<{
|
|
1318
1294
|
search: (items: Collection, search: string | null) => Collection;
|
|
1319
1295
|
size: "xs" | "sm" | "md" | "lg" | "xl";
|
|
@@ -1419,7 +1395,7 @@ declare const dataIteratorRef: import("vue").Ref<({
|
|
|
1419
1395
|
filter?: Record<string, any> | undefined;
|
|
1420
1396
|
};
|
|
1421
1397
|
updateQuery: (newQuery: DataTableQuery) => void;
|
|
1422
|
-
updateQueryValue: (key: string, value: any) => void;
|
|
1398
|
+
updateQueryValue: (key: string | DataTableQuery, value: any) => void;
|
|
1423
1399
|
updateQueryValueDebounce: import("lodash").DebouncedFunc<(key: string, value: any) => void>;
|
|
1424
1400
|
}) => any) & ((props: {
|
|
1425
1401
|
query: {
|
|
@@ -1430,7 +1406,7 @@ declare const dataIteratorRef: import("vue").Ref<({
|
|
|
1430
1406
|
filter?: Record<string, any> | undefined;
|
|
1431
1407
|
};
|
|
1432
1408
|
updateQuery: (newQuery: DataTableQuery) => void;
|
|
1433
|
-
updateQueryValue: (key: string, value: any) => void;
|
|
1409
|
+
updateQueryValue: (key: string | DataTableQuery, value: any) => void;
|
|
1434
1410
|
updateQueryValueDebounce: import("lodash").DebouncedFunc<(key: string, value: any) => void>;
|
|
1435
1411
|
}) => any) & ((props: {
|
|
1436
1412
|
query: {
|
|
@@ -1441,7 +1417,7 @@ declare const dataIteratorRef: import("vue").Ref<({
|
|
|
1441
1417
|
filter?: Record<string, any> | undefined;
|
|
1442
1418
|
};
|
|
1443
1419
|
updateQuery: (newQuery: DataTableQuery) => void;
|
|
1444
|
-
updateQueryValue: (key: string, value: any) => void;
|
|
1420
|
+
updateQueryValue: (key: string | DataTableQuery, value: any) => void;
|
|
1445
1421
|
updateQueryValueDebounce: import("lodash").DebouncedFunc<(key: string, value: any) => void>;
|
|
1446
1422
|
}) => any)) | undefined;
|
|
1447
1423
|
default?: ((props: {
|
|
@@ -1527,7 +1503,7 @@ declare var __VLS_28: {
|
|
|
1527
1503
|
filter?: Record<string, any> | undefined;
|
|
1528
1504
|
};
|
|
1529
1505
|
updateQuery: (newQuery: DataTableQuery) => void;
|
|
1530
|
-
updateQueryValue: (key: string, value: any) => void;
|
|
1506
|
+
updateQueryValue: (key: string | DataTableQuery, value: any) => void;
|
|
1531
1507
|
updateQueryValueDebounce: import("lodash").DebouncedFunc<(key: string, value: any) => void>;
|
|
1532
1508
|
}, __VLS_57: {
|
|
1533
1509
|
paginationMetadata: import("@/types").PaginationMetadata | null;
|
|
@@ -129,7 +129,7 @@ export interface DialogOptions {
|
|
|
129
129
|
confirmText?: string;
|
|
130
130
|
cancelText?: string;
|
|
131
131
|
closeOnOutsideClick?: boolean;
|
|
132
|
-
onConfirm?: (input?: string) => void;
|
|
132
|
+
onConfirm?: (input?: string) => Promise<void> | void;
|
|
133
133
|
onCancel?: () => void;
|
|
134
134
|
}
|
|
135
135
|
export interface Dialog {
|
package/package.json
CHANGED
|
@@ -450,7 +450,18 @@ watch(
|
|
|
450
450
|
|--------------------------------------------------------------------------
|
|
451
451
|
*/
|
|
452
452
|
|
|
453
|
-
function updateFilterQueryValue(key: string, value: any) {
|
|
453
|
+
function updateFilterQueryValue(key: string | DataTableQuery, value: any) {
|
|
454
|
+
|
|
455
|
+
if (typeof key === 'object') {
|
|
456
|
+
// If the key is an object, merge it into the query
|
|
457
|
+
let newQuery = cloneDeep(query.value);
|
|
458
|
+
newQuery = merge(newQuery, key);
|
|
459
|
+
newQuery = set(newQuery, 'page', 1);
|
|
460
|
+
|
|
461
|
+
updateQuery(newQuery);
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
|
|
454
465
|
let newQuery = cloneDeep(query.value);
|
|
455
466
|
newQuery = set(newQuery, key, value);
|
|
456
467
|
newQuery = set(newQuery, 'page', 1);
|
|
@@ -615,44 +615,54 @@ const canDelete = (row: CollectionItem): boolean => {
|
|
|
615
615
|
};
|
|
616
616
|
|
|
617
617
|
function onDeleteClick(row: CollectionItem) {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
618
|
+
return new Promise<void>((resolve) => {
|
|
619
|
+
dialogs.push({
|
|
620
|
+
title: props.deleteLabel ? props.deleteLabel : (t('sui.delete_record') + '?'),
|
|
621
|
+
message: props.deleteMessage ? props.deleteMessage : t('sui.delete_record_description'),
|
|
622
|
+
color: 'danger',
|
|
623
|
+
closeOnOutsideClick: true,
|
|
624
|
+
confirmText: t('sui.yes_delete'),
|
|
625
|
+
onConfirm: async () => {
|
|
626
|
+
await onDelete(row),
|
|
627
|
+
resolve();
|
|
628
|
+
},
|
|
629
|
+
onCancel: () => {
|
|
630
|
+
resolve();
|
|
631
|
+
},
|
|
632
|
+
});
|
|
625
633
|
});
|
|
626
634
|
}
|
|
627
635
|
|
|
628
|
-
|
|
636
|
+
async function onDelete(row: CollectionItem) {
|
|
629
637
|
if (!props.deleteUrl) {
|
|
630
638
|
return;
|
|
631
639
|
}
|
|
632
640
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
.
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
title: t('sui.success'),
|
|
639
|
-
text: response.data.message,
|
|
640
|
-
color: 'success',
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
emit('delete', row);
|
|
644
|
-
|
|
645
|
-
// Refetch even if URL is the same
|
|
646
|
-
fetch();
|
|
647
|
-
})
|
|
648
|
-
.catch((error) => {
|
|
641
|
+
try {
|
|
642
|
+
|
|
643
|
+
const response = await http.delete(props.deleteUrl(row));
|
|
644
|
+
|
|
645
|
+
if (response.data && response.data.message) {
|
|
649
646
|
snackbars.push({
|
|
650
|
-
title: t('sui.
|
|
651
|
-
text:
|
|
652
|
-
color: '
|
|
647
|
+
title: t('sui.success'),
|
|
648
|
+
text: response.data.message,
|
|
649
|
+
color: 'success',
|
|
653
650
|
});
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
emit('delete', row);
|
|
654
|
+
|
|
655
|
+
// Refetch even if URL is the same
|
|
656
|
+
fetch();
|
|
657
|
+
|
|
658
|
+
} catch (error: any) {
|
|
659
|
+
snackbars.push({
|
|
660
|
+
title: t('sui.error'),
|
|
661
|
+
text: error.response.data?.message ?? 'Unknown error',
|
|
662
|
+
color: 'danger',
|
|
654
663
|
});
|
|
655
|
-
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
656
666
|
|
|
657
667
|
const componentStorageKey = 'base_data_table.';
|
|
658
668
|
const settingsStorage = config.settingsStorage;
|
|
@@ -1,70 +1,39 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<BaseButton
|
|
3
3
|
v-if="rowAction.action"
|
|
4
4
|
type="button"
|
|
5
|
-
|
|
6
|
-
:
|
|
7
|
-
|
|
8
|
-
'btn-sm px-2 py-1.5': size === 'md',
|
|
9
|
-
}"
|
|
5
|
+
:loading="loading"
|
|
6
|
+
:size="sizeInternal"
|
|
7
|
+
:icon="rowAction.icon"
|
|
10
8
|
:disabled="rowAction.disabled && rowAction.disabled(row)"
|
|
11
|
-
@click="
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
:icon="rowAction.icon"
|
|
15
|
-
class="text-slate-500"
|
|
16
|
-
:class="{
|
|
17
|
-
'h-3 w-3': size === 'sm',
|
|
18
|
-
}"
|
|
19
|
-
/>
|
|
20
|
-
</button>
|
|
21
|
-
<component
|
|
22
|
-
:is="(rowAction.disabled && rowAction.disabled(row)) ? 'span' : 'a'"
|
|
9
|
+
@click="completeAction()"
|
|
10
|
+
/>
|
|
11
|
+
<BaseButton
|
|
23
12
|
v-else-if="rowAction.href"
|
|
13
|
+
:as="(rowAction.disabled && rowAction.disabled(row)) ? 'span' : 'a'"
|
|
24
14
|
:href="rowAction.href(row)"
|
|
25
|
-
|
|
26
|
-
:
|
|
27
|
-
'btn-xs px-1.5 py-1': size === 'sm',
|
|
28
|
-
'btn-sm px-2 py-1.5': size === 'md',
|
|
29
|
-
'opacity-50 cursor-not-allowed': rowAction.disabled && rowAction.disabled(row),
|
|
30
|
-
}"
|
|
15
|
+
:size="sizeInternal"
|
|
16
|
+
:icon="rowAction.icon"
|
|
31
17
|
:disabled="rowAction.disabled && rowAction.disabled(row)"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
:icon="rowAction.icon"
|
|
35
|
-
class="text-slate-500"
|
|
36
|
-
:class="{
|
|
37
|
-
'h-3 w-3': size === 'sm',
|
|
38
|
-
}"
|
|
39
|
-
/>
|
|
40
|
-
</component>
|
|
41
|
-
<component
|
|
42
|
-
:is="(rowAction.disabled && rowAction.disabled(row)) ? 'span' : 'router-link'"
|
|
18
|
+
/>
|
|
19
|
+
<BaseButton
|
|
43
20
|
v-else-if="rowAction.to"
|
|
21
|
+
:as="(rowAction.disabled && rowAction.disabled(row)) ? 'span' : 'router-link'"
|
|
44
22
|
:to="rowAction.to(row)"
|
|
45
|
-
|
|
46
|
-
:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
'opacity-50 cursor-not-allowed': rowAction.disabled && rowAction.disabled(row),
|
|
50
|
-
}"
|
|
51
|
-
>
|
|
52
|
-
<BaseIcon
|
|
53
|
-
:icon="rowAction.icon"
|
|
54
|
-
class="text-slate-500"
|
|
55
|
-
:class="{
|
|
56
|
-
'h-3 w-3': size === 'sm',
|
|
57
|
-
}"
|
|
58
|
-
/>
|
|
59
|
-
</component>
|
|
23
|
+
:size="sizeInternal"
|
|
24
|
+
:icon="rowAction.icon"
|
|
25
|
+
:disabled="rowAction.disabled && rowAction.disabled(row)"
|
|
26
|
+
/>
|
|
60
27
|
</template>
|
|
61
28
|
|
|
62
29
|
<script lang="ts" setup>
|
|
63
30
|
import { CollectionItem, RowAction } from '@/types';
|
|
64
|
-
import { BaseIcon } from '.';
|
|
65
31
|
import { Size } from '@/utils/sizes';
|
|
32
|
+
import BaseButton from './BaseButton.vue';
|
|
33
|
+
|
|
34
|
+
const loading = ref(false);
|
|
66
35
|
|
|
67
|
-
withDefaults(defineProps<{
|
|
36
|
+
const props = withDefaults(defineProps<{
|
|
68
37
|
row: CollectionItem;
|
|
69
38
|
rowAction: RowAction;
|
|
70
39
|
size?: Size,
|
|
@@ -72,4 +41,27 @@ withDefaults(defineProps<{
|
|
|
72
41
|
size: 'md',
|
|
73
42
|
});
|
|
74
43
|
|
|
44
|
+
const sizeInternal = computed(() => {
|
|
45
|
+
if (props.size === 'md') {
|
|
46
|
+
return 'sm';
|
|
47
|
+
} else if (props.size === 'sm') {
|
|
48
|
+
return 'xs';
|
|
49
|
+
}
|
|
50
|
+
return 'sm';
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
async function completeAction() {
|
|
54
|
+
if (props.rowAction.action) {
|
|
55
|
+
loading.value = true;
|
|
56
|
+
try {
|
|
57
|
+
await props.rowAction.action(props.row);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error('Error executing row action:', error);
|
|
60
|
+
} finally {
|
|
61
|
+
loading.value = false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
75
67
|
</script>
|
package/src/types/index.ts
CHANGED
|
@@ -161,7 +161,7 @@ export interface DialogOptions {
|
|
|
161
161
|
confirmText?: string;
|
|
162
162
|
cancelText?: string;
|
|
163
163
|
closeOnOutsideClick?: boolean;
|
|
164
|
-
onConfirm?: (input?: string) => void;
|
|
164
|
+
onConfirm?: (input?: string) => Promise<void> | void;
|
|
165
165
|
onCancel?: () => void;
|
|
166
166
|
}
|
|
167
167
|
|