@webitel/ui-sdk 26.8.52 → 26.8.53
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,5 +1,5 @@
|
|
|
1
1
|
import deepmerge from 'deepmerge';
|
|
2
|
-
import { computed, inject,
|
|
2
|
+
import { computed, inject, toRef } from 'vue';
|
|
3
3
|
import { useI18n } from 'vue-i18n';
|
|
4
4
|
|
|
5
5
|
import { EmptyCause } from '../../../enums/index';
|
|
@@ -9,6 +9,12 @@ import EmptyFiltersLight from '../_internals/assets/empty-filters-light.svg';
|
|
|
9
9
|
import EmptyTableDark from '../_internals/assets/empty-table-dark.svg';
|
|
10
10
|
import EmptyTableLight from '../_internals/assets/empty-table-light.svg';
|
|
11
11
|
|
|
12
|
+
type DeepPartial<T> = T extends object
|
|
13
|
+
? {
|
|
14
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
15
|
+
}
|
|
16
|
+
: T;
|
|
17
|
+
|
|
12
18
|
interface EmptyImageSet {
|
|
13
19
|
dark: string;
|
|
14
20
|
light: string;
|
|
@@ -41,9 +47,29 @@ export interface UseTableEmptySource {
|
|
|
41
47
|
isLoading?: Readable<boolean | undefined>;
|
|
42
48
|
}
|
|
43
49
|
|
|
50
|
+
type MaybeOverridesGetter =
|
|
51
|
+
| DeepPartial<EmptyStateConfig>
|
|
52
|
+
| Readable<DeepPartial<EmptyStateConfig>>
|
|
53
|
+
| (() => DeepPartial<EmptyStateConfig>);
|
|
54
|
+
|
|
55
|
+
const resolveOverrides = (
|
|
56
|
+
source: MaybeOverridesGetter,
|
|
57
|
+
): DeepPartial<EmptyStateConfig> => {
|
|
58
|
+
if (typeof source === 'function') return source();
|
|
59
|
+
if (source && typeof source === 'object' && 'value' in source) {
|
|
60
|
+
return source.value;
|
|
61
|
+
}
|
|
62
|
+
return source;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @param overrides plain object, ref, computed, or getter — use a reactive
|
|
67
|
+
* source (not a plain object literal) if any value inside depends on
|
|
68
|
+
* locale/dark mode, so it re-evaluates instead of freezing at first render
|
|
69
|
+
*/
|
|
44
70
|
export const useTableEmpty = (
|
|
45
71
|
{ dataList, filters, error, isLoading }: UseTableEmptySource = {},
|
|
46
|
-
overrides:
|
|
72
|
+
overrides: MaybeOverridesGetter = {},
|
|
47
73
|
) => {
|
|
48
74
|
const { t } = useI18n();
|
|
49
75
|
|
|
@@ -90,7 +116,13 @@ export const useTableEmpty = (
|
|
|
90
116
|
},
|
|
91
117
|
}));
|
|
92
118
|
|
|
93
|
-
const merged = computed(
|
|
119
|
+
const merged = computed<EmptyStateConfig>(
|
|
120
|
+
() =>
|
|
121
|
+
deepmerge(
|
|
122
|
+
defaults.value,
|
|
123
|
+
resolveOverrides(overrides),
|
|
124
|
+
) as EmptyStateConfig,
|
|
125
|
+
);
|
|
94
126
|
|
|
95
127
|
const darkMode = toRef(inject<boolean>('darkMode'));
|
|
96
128
|
|