grantthomas-nuxt 1.0.10 → 1.0.11
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
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
2
|
+
export default _default;
|
|
3
|
+
type __VLS_WithSlots<T, S> = T & (new () => {
|
|
4
|
+
$slots: S;
|
|
5
|
+
});
|
|
6
|
+
declare const __VLS_component: import("vue").DefineComponent<{}, {
|
|
7
|
+
debounced: boolean;
|
|
8
|
+
path: string;
|
|
9
|
+
await: boolean;
|
|
10
|
+
listeners: unknown[];
|
|
11
|
+
customFilters?: Record<string, any> | undefined;
|
|
12
|
+
$props: any;
|
|
13
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
14
|
+
type __VLS_Slots = {
|
|
15
|
+
error?: ((props: {
|
|
16
|
+
errors: any;
|
|
17
|
+
}) => any) | undefined;
|
|
18
|
+
} & {
|
|
19
|
+
pending?: ((props: {}) => any) | undefined;
|
|
20
|
+
} & {
|
|
21
|
+
content?: ((props: {
|
|
22
|
+
count: any;
|
|
23
|
+
}) => any) | undefined;
|
|
24
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<script setup async>
|
|
2
|
+
import { useCrudApi } from "../composables/useCrudApi";
|
|
3
|
+
import { useListenerService } from "../composables/useListenerService";
|
|
4
|
+
import CrudErrorDisplay from "./CrudErrorDisplay.vue";
|
|
5
|
+
import { watch, onMounted, onBeforeUnmount, ref, computed } from "vue";
|
|
6
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
debounced: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
default: false
|
|
11
|
+
},
|
|
12
|
+
path: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
customFilters: {
|
|
17
|
+
type: Object,
|
|
18
|
+
required: false
|
|
19
|
+
},
|
|
20
|
+
await: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
required: false,
|
|
23
|
+
default: false
|
|
24
|
+
},
|
|
25
|
+
listeners: {
|
|
26
|
+
type: Array,
|
|
27
|
+
required: false,
|
|
28
|
+
default: () => []
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const {
|
|
32
|
+
getCount,
|
|
33
|
+
count,
|
|
34
|
+
countPending,
|
|
35
|
+
countErrors
|
|
36
|
+
} = useCrudApi(props.path);
|
|
37
|
+
const debouncedGetCount = useDebounceFn(getCount, 500);
|
|
38
|
+
const lastRequest = ref(null);
|
|
39
|
+
const setLastRequest = () => {
|
|
40
|
+
lastRequest.value = JSON.stringify({ customFilters: props.customFilters });
|
|
41
|
+
};
|
|
42
|
+
const hasCountErrors = computed(() => countErrors.value && Object.keys(countErrors.value).length > 0);
|
|
43
|
+
watch(() => props.customFilters, () => {
|
|
44
|
+
if (lastRequest.value === JSON.stringify({ customFilters: props.customFilters })) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (props.debounced) {
|
|
48
|
+
debouncedGetCount(props.customFilters);
|
|
49
|
+
} else {
|
|
50
|
+
getCount(props.customFilters);
|
|
51
|
+
}
|
|
52
|
+
setLastRequest();
|
|
53
|
+
}, { deep: true });
|
|
54
|
+
if (props.await) {
|
|
55
|
+
await getCount(props.customFilters);
|
|
56
|
+
} else {
|
|
57
|
+
getCount(props.customFilters);
|
|
58
|
+
}
|
|
59
|
+
setLastRequest();
|
|
60
|
+
const { addListener, removeLocalListenersWithEvent } = useListenerService();
|
|
61
|
+
onMounted(() => {
|
|
62
|
+
props.listeners.forEach((listener) => {
|
|
63
|
+
addListener(listener, (data) => {
|
|
64
|
+
getCount(props.customFilters);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
onBeforeUnmount(() => {
|
|
69
|
+
props.listeners.forEach((listener) => {
|
|
70
|
+
removeLocalListenersWithEvent(listener);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<template>
|
|
76
|
+
<div>
|
|
77
|
+
<slot v-if="hasCountErrors" name="error" :errors="countErrors">
|
|
78
|
+
<v-tooltip content-class="bg-white pa-3" location="bottom">
|
|
79
|
+
<template v-slot:activator="{ props: tooltipProps }">
|
|
80
|
+
<v-icon style="cursor: pointer;" color="error" size="24" v-bind="tooltipProps">mdi-alert-circle</v-icon>
|
|
81
|
+
</template>
|
|
82
|
+
<crud-error-display :errors="countErrors" />
|
|
83
|
+
</v-tooltip>
|
|
84
|
+
</slot>
|
|
85
|
+
<slot v-else-if="countPending" name="pending">
|
|
86
|
+
<v-progress-circular indeterminate color="primary"></v-progress-circular>
|
|
87
|
+
</slot>
|
|
88
|
+
<slot v-else name="content" :count="count">
|
|
89
|
+
{{ count }}
|
|
90
|
+
</slot>
|
|
91
|
+
</div>
|
|
92
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
2
|
+
export default _default;
|
|
3
|
+
type __VLS_WithSlots<T, S> = T & (new () => {
|
|
4
|
+
$slots: S;
|
|
5
|
+
});
|
|
6
|
+
declare const __VLS_component: import("vue").DefineComponent<{}, {
|
|
7
|
+
debounced: boolean;
|
|
8
|
+
path: string;
|
|
9
|
+
await: boolean;
|
|
10
|
+
listeners: unknown[];
|
|
11
|
+
customFilters?: Record<string, any> | undefined;
|
|
12
|
+
$props: any;
|
|
13
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
14
|
+
type __VLS_Slots = {
|
|
15
|
+
error?: ((props: {
|
|
16
|
+
errors: any;
|
|
17
|
+
}) => any) | undefined;
|
|
18
|
+
} & {
|
|
19
|
+
pending?: ((props: {}) => any) | undefined;
|
|
20
|
+
} & {
|
|
21
|
+
content?: ((props: {
|
|
22
|
+
count: any;
|
|
23
|
+
}) => any) | undefined;
|
|
24
|
+
};
|