adminforth 4.15.1 → 4.16.0
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.
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span v-bind="restAttrs" :class="rootClasses">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</span>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { computed, useAttrs } from 'vue';
|
|
9
|
+
import { type ClassNameValue } from 'tailwind-merge';
|
|
10
|
+
import { mergeClasses } from './classMerge';
|
|
11
|
+
|
|
12
|
+
export type BadgeVariant = 'default' | 'success' | 'warning' | 'danger' | 'accent' | 'muted';
|
|
13
|
+
|
|
14
|
+
defineOptions({ inheritAttrs: false });
|
|
15
|
+
|
|
16
|
+
const props = withDefaults(defineProps<{
|
|
17
|
+
variant?: BadgeVariant;
|
|
18
|
+
}>(), {
|
|
19
|
+
variant: 'default',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const VARIANT_CLASSES: Record<BadgeVariant, string> = {
|
|
23
|
+
default: 'bg-lightCardBackground text-lightListTableText border-lightCardBorder dark:bg-darkCardBackground dark:text-darkListTableText dark:border-darkCardBorder',
|
|
24
|
+
success: 'bg-lightSuccessSoft text-lightSuccess border-lightSuccessBorder dark:bg-darkSuccessSoft dark:text-darkSuccess dark:border-darkSuccessBorder',
|
|
25
|
+
warning: 'bg-lightWarningSoft text-lightWarning border-lightWarningBorder dark:bg-darkWarningSoft dark:text-darkWarning dark:border-darkWarningBorder',
|
|
26
|
+
danger: 'bg-lightDangerSoft text-lightDanger border-lightDangerBorder dark:bg-darkDangerSoft dark:text-darkDanger dark:border-darkDangerBorder',
|
|
27
|
+
accent: 'bg-lightPrimary/10 text-lightPrimary border-lightPrimary/30 dark:bg-darkPrimary/10 dark:text-darkPrimary dark:border-darkPrimary/30',
|
|
28
|
+
muted: 'bg-lightSecondaryDarken text-lightInputIconColor border-transparent dark:bg-darkSecondaryLighten dark:text-darkInputIconColor',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const attrs = useAttrs();
|
|
32
|
+
const restAttrs = computed(() => {
|
|
33
|
+
const { class: _class, ...rest } = attrs;
|
|
34
|
+
return rest;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const rootClasses = computed(() => mergeClasses(
|
|
38
|
+
'afcl-badge inline-flex items-center gap-1 whitespace-nowrap px-2 h-5 rounded-full border text-xs font-medium',
|
|
39
|
+
VARIANT_CLASSES[props.variant],
|
|
40
|
+
attrs.class as ClassNameValue,
|
|
41
|
+
));
|
|
42
|
+
</script>
|
|
@@ -22,6 +22,7 @@ export { default as Dialog } from './Dialog.vue';
|
|
|
22
22
|
export { default as DialogPanel } from './DialogPanel.vue';
|
|
23
23
|
export { default as MixedChart } from './MixedChart.vue';
|
|
24
24
|
export { default as CountryFlag } from './CountryFlag.vue';
|
|
25
|
+
export { default as Badge } from './Badge.vue';
|
|
25
26
|
export { default as JsonViewer } from './JsonViewer.vue';
|
|
26
27
|
export { default as Toggle } from './Toggle.vue';
|
|
27
28
|
export { default as DatePicker } from './DatePicker.vue';
|
|
@@ -58,27 +58,29 @@
|
|
|
58
58
|
</span>
|
|
59
59
|
|
|
60
60
|
<span v-else-if="column.type === 'boolean'">
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
<
|
|
61
|
+
<Badge v-if="record[column.name] === true" variant="success" class="af-true-value-icon me-2"><IconCheck class="w-3 h-3" aria-hidden="true" />{{ $t('Yes') }}</Badge>
|
|
62
|
+
<Badge v-else-if="record[column.name] === false" variant="muted" class="af-false-value-icon me-2">{{ $t('No') }}</Badge>
|
|
63
|
+
<Badge v-else class="me-2 border-dashed bg-transparent text-lightInputIconColor border-lightInputBorder dark:bg-transparent dark:text-darkInputIconColor dark:border-darkInputBorder">{{ $t('Unset') }}</Badge>
|
|
64
64
|
</span>
|
|
65
65
|
<span
|
|
66
66
|
v-else-if="column.type === 'json' && column.isArray?.enabled"
|
|
67
67
|
class="flex flex-wrap"
|
|
68
68
|
>
|
|
69
69
|
<template v-for="(arrayItem, arrayItemIndex) in record[column.name]">
|
|
70
|
-
<
|
|
70
|
+
<Badge
|
|
71
71
|
v-if="column.isArray.itemType === 'boolean' && arrayItem"
|
|
72
72
|
:key="`${column.name}-${arrayItemIndex}-true`"
|
|
73
|
-
|
|
73
|
+
variant="success"
|
|
74
|
+
class="af-true-value-icon me-2">
|
|
74
75
|
{{ $t('Yes') }}
|
|
75
|
-
</
|
|
76
|
-
<
|
|
76
|
+
</Badge>
|
|
77
|
+
<Badge
|
|
77
78
|
v-else-if="column.isArray.itemType === 'boolean'"
|
|
78
79
|
:key="`${column.name}-${arrayItemIndex}-false`"
|
|
79
|
-
|
|
80
|
+
variant="muted"
|
|
81
|
+
class="af-false-value-icon me-2">
|
|
80
82
|
{{ $t('No') }}
|
|
81
|
-
</
|
|
83
|
+
</Badge>
|
|
82
84
|
<span
|
|
83
85
|
v-else
|
|
84
86
|
:key="`${column.name}-${arrayItemIndex}`"
|
|
@@ -123,13 +125,10 @@ import { useRoute, useRouter } from 'vue-router';
|
|
|
123
125
|
import { computed } from 'vue';
|
|
124
126
|
import { IconCheck } from '@iconify-prerendered/vue-lucide';
|
|
125
127
|
import type { AdminForthResourceColumnCommon } from '@/types/Common';
|
|
126
|
-
import { JsonViewer } from '@/afcl';
|
|
128
|
+
import { JsonViewer, Badge } from '@/afcl';
|
|
127
129
|
|
|
128
130
|
import type { any } from 'zod';
|
|
129
131
|
|
|
130
|
-
const BADGE_CLASSES = 'inline-flex items-center whitespace-nowrap me-2 px-2 h-5 rounded-full border text-xs font-medium';
|
|
131
|
-
const TRUE_BADGE_CLASSES = 'bg-lightSuccessSoft text-lightSuccess border-lightSuccessBorder dark:bg-darkSuccessSoft dark:text-darkSuccess dark:border-darkSuccessBorder';
|
|
132
|
-
const FALSE_BADGE_CLASSES = 'bg-lightSecondaryDarken text-lightInputIconColor border-transparent dark:bg-darkSecondaryLighten dark:text-darkInputIconColor';
|
|
133
132
|
|
|
134
133
|
const route = useRoute();
|
|
135
134
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Badge v-if="value !== null" :variant="meta.variants?.[value]">{{ label }}</Badge>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { computed } from 'vue';
|
|
7
|
+
import Badge, { type BadgeVariant } from '@/afcl/Badge.vue';
|
|
8
|
+
import type { AdminForthResourceColumnCommon } from '@/types/Common';
|
|
9
|
+
|
|
10
|
+
const props = defineProps<{
|
|
11
|
+
column: AdminForthResourceColumnCommon;
|
|
12
|
+
record: Record<string, any>;
|
|
13
|
+
meta: { variants?: Record<string, BadgeVariant> };
|
|
14
|
+
}>();
|
|
15
|
+
|
|
16
|
+
const value = computed(() => props.record[props.column.name]);
|
|
17
|
+
const label = computed(() => props.column.enum!.find((item) => item.value === value.value)!.label);
|
|
18
|
+
</script>
|