sprintify-ui 0.10.38 → 0.10.39

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.
@@ -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";
@@ -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";
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.10.38",
3
+ "version": "0.10.39",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "rimraf dist && vue-tsc && vite build",
@@ -615,44 +615,54 @@ const canDelete = (row: CollectionItem): boolean => {
615
615
  };
616
616
 
617
617
  function onDeleteClick(row: CollectionItem) {
618
- dialogs.push({
619
- title: props.deleteLabel ? props.deleteLabel : (t('sui.delete_record') + '?'),
620
- message: props.deleteMessage ? props.deleteMessage : t('sui.delete_record_description'),
621
- color: 'danger',
622
- closeOnOutsideClick: true,
623
- confirmText: t('sui.yes_delete'),
624
- onConfirm: () => onDelete(row),
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
- const onDelete = (row: CollectionItem) => {
636
+ async function onDelete(row: CollectionItem) {
629
637
  if (!props.deleteUrl) {
630
638
  return;
631
639
  }
632
640
 
633
- http
634
- .delete(props.deleteUrl(row))
635
- .then((response) => {
636
- if (response.data && response.data.message) {
637
- snackbars.push({
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.error'),
651
- text: error.response.data?.message ?? 'Unknown error',
652
- color: 'danger',
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
- <button
2
+ <BaseButton
3
3
  v-if="rowAction.action"
4
4
  type="button"
5
- class="btn btn-white border border-slate-300 shadow-sm"
6
- :class="{
7
- 'btn-xs px-1.5 py-1': size === 'sm',
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="rowAction.action ? rowAction.action(row) : null"
12
- >
13
- <BaseIcon
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
- class="btn btn-white border border-slate-300 shadow-sm"
26
- :class="{
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
- <BaseIcon
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
- class="btn btn-white border border-slate-300 shadow-sm hover:bg-slate-100"
46
- :class="{
47
- 'btn-xs px-1.5 py-1': size === 'sm',
48
- 'btn-sm px-2 py-1.5': size === 'md',
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>
@@ -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