ads-nuxt 0.1.5 → 0.2.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.
- package/LICENSE +21 -21
- package/README.md +573 -577
- package/app/app.config.ts +25 -25
- package/app/assets/ads/checkbox-check.svg +5 -5
- package/app/assets/ads/checkbox-minus.svg +5 -5
- package/app/assets/brand/farmarcas.svg +6 -6
- package/app/assets/brand/radar-symbol.svg +9 -0
- package/app/assets/brand/radar.svg +9 -9
- package/app/assets/css/ads-colors.css +257 -246
- package/app/assets/css/component-tokens.css +367 -403
- package/app/assets/css/main.css +624 -617
- package/app/components/AdsBadge.vue +47 -48
- package/app/components/AdsBroadcast.vue +24 -45
- package/app/components/AdsButton.vue +539 -569
- package/app/components/AdsButtonGroup.vue +39 -39
- package/app/components/AdsButtonMenu.vue +48 -48
- package/app/components/AdsCard.vue +188 -117
- package/app/components/AdsCardHint.vue +22 -0
- package/app/components/AdsCardPeriod.vue +43 -0
- package/app/components/AdsCardVariation.vue +31 -0
- package/app/components/AdsCharttip.vue +78 -78
- package/app/components/AdsCheckbox.vue +77 -77
- package/app/components/AdsDatePicker.vue +492 -491
- package/app/components/AdsDropdownMenu.vue +30 -19
- package/app/components/AdsEmptyState.vue +58 -58
- package/app/components/AdsFeatureCard.vue +210 -219
- package/app/components/AdsFileCard.vue +98 -101
- package/app/components/AdsFooter.vue +25 -25
- package/app/components/AdsHeavyAccountCell.vue +59 -0
- package/app/components/AdsHeavyHeaderCell.vue +70 -0
- package/app/components/AdsHeavyTable.vue +135 -0
- package/app/components/AdsInput.vue +147 -147
- package/app/components/AdsLoading.vue +217 -109
- package/app/components/AdsMenuBar.vue +103 -103
- package/app/components/AdsMetricCard.vue +216 -119
- package/app/components/AdsModal.vue +157 -157
- package/app/components/AdsMonthPicker.vue +80 -80
- package/app/components/AdsNavbarApp.vue +67 -67
- package/app/components/AdsNavbarDesk.vue +62 -62
- package/app/components/AdsNotabilityPill.vue +24 -27
- package/app/components/AdsNumberInput.vue +173 -173
- package/app/components/AdsPagination.vue +91 -91
- package/app/components/AdsPanelCard.vue +99 -0
- package/app/components/AdsPill.vue +144 -92
- package/app/components/AdsProductTag.vue +61 -61
- package/app/components/AdsRadio.vue +70 -70
- package/app/components/AdsSearchInput.vue +122 -122
- package/app/components/AdsSegmentedTabs.vue +62 -28
- package/app/components/{AdsFilterSelect.vue → AdsSelect.vue} +266 -210
- package/app/components/AdsSelectItem.vue +128 -0
- package/app/components/AdsSelectPanel.vue +150 -0
- package/app/components/AdsSideMenu.vue +101 -101
- package/app/components/AdsSmalltip.vue +44 -44
- package/app/components/AdsStepper.vue +222 -0
- package/app/components/AdsSteptip.vue +101 -101
- package/app/components/AdsSwitch.vue +59 -59
- package/app/components/AdsTable.vue +161 -100
- package/app/components/AdsTableHeaderCell.vue +80 -0
- package/app/components/AdsTableSkeleton.vue +113 -0
- package/app/components/AdsTableToolbar.vue +44 -44
- package/app/components/AdsTabs.vue +51 -51
- package/app/components/AdsTextarea.vue +116 -116
- package/app/components/AdsToast.vue +183 -181
- package/app/components/AdsTooltip.vue +73 -73
- package/app/components/OverlayLoading.vue +173 -173
- package/app/components/ProgressBarLoading.vue +235 -256
- package/app/composables/useOverlayLoading.ts +66 -66
- package/app/constants/ads-color-swatches.ts +240 -239
- package/app/locale/pt-br.ts +6 -6
- package/app/plugins/ads-toast.client.ts +24 -24
- package/app/theme/ads-theme.ts +374 -370
- package/app/theme/ads-tokens.ts +391 -379
- package/app/theme/component-tokens.json +366 -402
- package/app/theme/component-tokens.ts +807 -815
- package/app/types/overlay-loading.types.ts +26 -26
- package/app/utils/ads-filter-select.ts +191 -172
- package/app/utils/ads-table.ts +395 -204
- package/app/utils/calendar-date.ts +163 -163
- package/app/utils/category-role.ts +45 -45
- package/app/utils/money.ts +77 -77
- package/app/utils/notability.ts +8 -8
- package/app/utils/parser.ts +134 -134
- package/app/utils/percentage.ts +54 -54
- package/nuxt.config.ts +31 -31
- package/package.json +1 -1
- package/app/components/AdsFarmarcasPill.vue +0 -74
- package/app/components/AdsFilterDropdown.vue +0 -174
- package/app/components/AdsFilterOption.vue +0 -74
- package/app/components/AdsListDropdown.vue +0 -44
- package/app/components/AdsMiniPill.vue +0 -40
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<nav
|
|
3
|
-
class="flex w-[var(--ads-menu-width)] flex-col items-center gap-[var(--ads-menu-gap)] bg-[var(--ads-surface-card)] px-0 py-[var(--ads-menu-padding-y)] shadow-[0_2px_4px_-1px_color-mix(in_srgb,var(--color-ads-neutro-medio-60)_75%,transparent)]"
|
|
4
|
-
aria-label="Menu principal"
|
|
5
|
-
>
|
|
6
|
-
<template v-for="item in items" :key="item.id">
|
|
7
|
-
<span
|
|
8
|
-
v-if="item.dividerBefore"
|
|
9
|
-
class="h-px w-12 bg-[var(--ads-menu-divider)]"
|
|
10
|
-
role="separator"
|
|
11
|
-
/>
|
|
12
|
-
<component
|
|
13
|
-
:is="item.to ? NuxtLink : 'button'"
|
|
14
|
-
v-bind="item.to ? { to: item.to } : { type: 'button' }"
|
|
15
|
-
class="flex w-full flex-col items-center gap-1 rounded-[var(--ads-radius-xsm)] px-1 py-0 text-center focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-brand)]"
|
|
16
|
-
:class="stateOf(item) === 'open' ? 'shadow-[inset_4px_0_0_var(--ads-text-brand)]' : ''"
|
|
17
|
-
:aria-current="stateOf(item) === 'regular' ? undefined : 'page'"
|
|
18
|
-
@click="onSelect(item.id)"
|
|
19
|
-
>
|
|
20
|
-
<span class="flex size-[var(--ads-menu-icon-box)] items-center justify-center rounded-[var(--ads-radius-xsm)] p-1">
|
|
21
|
-
<UIcon :name="item.icon" class="size-[var(--ads-menu-icon)]" :class="iconTone(item)" />
|
|
22
|
-
</span>
|
|
23
|
-
<span
|
|
24
|
-
class="max-w-full text-[length:var(--ads-menu-label-size)] font-bold leading-[1.2] whitespace-pre-line"
|
|
25
|
-
:class="labelTone(item)"
|
|
26
|
-
>{{ item.label }}</span>
|
|
27
|
-
</component>
|
|
28
|
-
</template>
|
|
29
|
-
</nav>
|
|
30
|
-
</template>
|
|
31
|
-
|
|
32
|
-
<script lang="ts">
|
|
33
|
-
import type { RouteLocationRaw } from "vue-router";
|
|
34
|
-
|
|
35
|
-
export type AdsMenuBarState = "regular" | "selected" | "open";
|
|
36
|
-
|
|
37
|
-
export type AdsMenuBarItem = {
|
|
38
|
-
id: string;
|
|
39
|
-
label: string;
|
|
40
|
-
icon: string;
|
|
41
|
-
to?: RouteLocationRaw;
|
|
42
|
-
dividerBefore?: boolean;
|
|
43
|
-
state?: AdsMenuBarState;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/** Ordem do Menu bar default no Figma. Home usa o mesmo tom dos demais (o frame default pinta o rótulo em dark/500). */
|
|
47
|
-
export const adsMenuBarItems: AdsMenuBarItem[] = [
|
|
48
|
-
{ id: "home", label: "Home", icon: "i-lucide-home" },
|
|
49
|
-
{ id: "gestao", label: "Gestão", icon: "i-lucide-folder-tree", dividerBefore: true },
|
|
50
|
-
{ id: "financas", label: "Finanças", icon: "i-lucide-hand-coins" },
|
|
51
|
-
{ id: "compras", label: "Compras", icon: "i-lucide-shopping-cart" },
|
|
52
|
-
{ id: "trade", label: "Trade", icon: "i-lucide-store" },
|
|
53
|
-
{ id: "marketing", label: "Marketing", icon: "i-lucide-megaphone" },
|
|
54
|
-
{ id: "capacitacao", label: "Capacitação", icon: "i-lucide-book-open" },
|
|
55
|
-
{ id: "relatorios", label: "Relatórios", icon: "i-lucide-bar-chart-big" },
|
|
56
|
-
{ id: "promocao", label: "Promoção", icon: "i-lucide-trophy" },
|
|
57
|
-
{ id: "encontro", label: "Encontro\nFarmarcas", icon: "i-lucide-contact" },
|
|
58
|
-
{ id: "campanhas", label: "Campanhas", icon: "i-lucide-goal", dividerBefore: false },
|
|
59
|
-
];
|
|
60
|
-
</script>
|
|
61
|
-
|
|
62
|
-
<script setup lang="ts">
|
|
63
|
-
import { NuxtLink } from "#components";
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const props = withDefaults(
|
|
68
|
-
defineProps<{
|
|
69
|
-
items?: AdsMenuBarItem[];
|
|
70
|
-
activeId?: string;
|
|
71
|
-
openId?: string;
|
|
72
|
-
}>(),
|
|
73
|
-
{
|
|
74
|
-
items: () => adsMenuBarItems,
|
|
75
|
-
activeId: "",
|
|
76
|
-
openId: "",
|
|
77
|
-
},
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
const emit = defineEmits<{
|
|
81
|
-
"update:activeId": [id: string];
|
|
82
|
-
select: [id: string];
|
|
83
|
-
}>();
|
|
84
|
-
|
|
85
|
-
const stateOf = (item: AdsMenuBarItem): AdsMenuBarState => {
|
|
86
|
-
if (item.state) return item.state;
|
|
87
|
-
if (props.openId === item.id) return "open";
|
|
88
|
-
if (props.activeId === item.id) return "selected";
|
|
89
|
-
return "regular";
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const iconTone = (item: AdsMenuBarItem) =>
|
|
93
|
-
stateOf(item) === "regular" ? "text-ads-neutro-escuro-500" : "text-[var(--ads-text-brand)]";
|
|
94
|
-
|
|
95
|
-
const labelTone = (item: AdsMenuBarItem) =>
|
|
96
|
-
stateOf(item) === "regular" ? "text-[var(--ads-text-secondary)]" : "text-[var(--ads-text-brand)]";
|
|
97
|
-
|
|
98
|
-
const onSelect = (id: string) => {
|
|
99
|
-
emit("update:activeId", id);
|
|
100
|
-
emit("select", id);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<nav
|
|
3
|
+
class="flex w-[var(--ads-menu-width)] flex-col items-center gap-[var(--ads-menu-gap)] bg-[var(--ads-surface-card)] px-0 py-[var(--ads-menu-padding-y)] shadow-[0_2px_4px_-1px_color-mix(in_srgb,var(--color-ads-neutro-medio-60)_75%,transparent)]"
|
|
4
|
+
aria-label="Menu principal"
|
|
5
|
+
>
|
|
6
|
+
<template v-for="item in items" :key="item.id">
|
|
7
|
+
<span
|
|
8
|
+
v-if="item.dividerBefore"
|
|
9
|
+
class="h-px w-12 bg-[var(--ads-menu-divider)]"
|
|
10
|
+
role="separator"
|
|
11
|
+
/>
|
|
12
|
+
<component
|
|
13
|
+
:is="item.to ? NuxtLink : 'button'"
|
|
14
|
+
v-bind="item.to ? { to: item.to } : { type: 'button' }"
|
|
15
|
+
class="flex w-full flex-col items-center gap-1 rounded-[var(--ads-radius-xsm)] px-1 py-0 text-center focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-brand)]"
|
|
16
|
+
:class="stateOf(item) === 'open' ? 'shadow-[inset_4px_0_0_var(--ads-text-brand)]' : ''"
|
|
17
|
+
:aria-current="stateOf(item) === 'regular' ? undefined : 'page'"
|
|
18
|
+
@click="onSelect(item.id)"
|
|
19
|
+
>
|
|
20
|
+
<span class="flex size-[var(--ads-menu-icon-box)] items-center justify-center rounded-[var(--ads-radius-xsm)] p-1">
|
|
21
|
+
<UIcon :name="item.icon" class="size-[var(--ads-menu-icon)]" :class="iconTone(item)" />
|
|
22
|
+
</span>
|
|
23
|
+
<span
|
|
24
|
+
class="max-w-full text-[length:var(--ads-menu-label-size)] font-bold leading-[1.2] whitespace-pre-line"
|
|
25
|
+
:class="labelTone(item)"
|
|
26
|
+
>{{ item.label }}</span>
|
|
27
|
+
</component>
|
|
28
|
+
</template>
|
|
29
|
+
</nav>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script lang="ts">
|
|
33
|
+
import type { RouteLocationRaw } from "vue-router";
|
|
34
|
+
|
|
35
|
+
export type AdsMenuBarState = "regular" | "selected" | "open";
|
|
36
|
+
|
|
37
|
+
export type AdsMenuBarItem = {
|
|
38
|
+
id: string;
|
|
39
|
+
label: string;
|
|
40
|
+
icon: string;
|
|
41
|
+
to?: RouteLocationRaw;
|
|
42
|
+
dividerBefore?: boolean;
|
|
43
|
+
state?: AdsMenuBarState;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** Ordem do Menu bar default no Figma. Home usa o mesmo tom dos demais (o frame default pinta o rótulo em dark/500). */
|
|
47
|
+
export const adsMenuBarItems: AdsMenuBarItem[] = [
|
|
48
|
+
{ id: "home", label: "Home", icon: "i-lucide-home" },
|
|
49
|
+
{ id: "gestao", label: "Gestão", icon: "i-lucide-folder-tree", dividerBefore: true },
|
|
50
|
+
{ id: "financas", label: "Finanças", icon: "i-lucide-hand-coins" },
|
|
51
|
+
{ id: "compras", label: "Compras", icon: "i-lucide-shopping-cart" },
|
|
52
|
+
{ id: "trade", label: "Trade", icon: "i-lucide-store" },
|
|
53
|
+
{ id: "marketing", label: "Marketing", icon: "i-lucide-megaphone" },
|
|
54
|
+
{ id: "capacitacao", label: "Capacitação", icon: "i-lucide-book-open" },
|
|
55
|
+
{ id: "relatorios", label: "Relatórios", icon: "i-lucide-bar-chart-big" },
|
|
56
|
+
{ id: "promocao", label: "Promoção", icon: "i-lucide-trophy" },
|
|
57
|
+
{ id: "encontro", label: "Encontro\nFarmarcas", icon: "i-lucide-contact" },
|
|
58
|
+
{ id: "campanhas", label: "Campanhas", icon: "i-lucide-goal", dividerBefore: false },
|
|
59
|
+
];
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts">
|
|
63
|
+
import { NuxtLink } from "#components";
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
const props = withDefaults(
|
|
68
|
+
defineProps<{
|
|
69
|
+
items?: AdsMenuBarItem[];
|
|
70
|
+
activeId?: string;
|
|
71
|
+
openId?: string;
|
|
72
|
+
}>(),
|
|
73
|
+
{
|
|
74
|
+
items: () => adsMenuBarItems,
|
|
75
|
+
activeId: "",
|
|
76
|
+
openId: "",
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const emit = defineEmits<{
|
|
81
|
+
"update:activeId": [id: string];
|
|
82
|
+
select: [id: string];
|
|
83
|
+
}>();
|
|
84
|
+
|
|
85
|
+
const stateOf = (item: AdsMenuBarItem): AdsMenuBarState => {
|
|
86
|
+
if (item.state) return item.state;
|
|
87
|
+
if (props.openId === item.id) return "open";
|
|
88
|
+
if (props.activeId === item.id) return "selected";
|
|
89
|
+
return "regular";
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const iconTone = (item: AdsMenuBarItem) =>
|
|
93
|
+
stateOf(item) === "regular" ? "text-ads-neutro-escuro-500" : "text-[var(--ads-text-brand)]";
|
|
94
|
+
|
|
95
|
+
const labelTone = (item: AdsMenuBarItem) =>
|
|
96
|
+
stateOf(item) === "regular" ? "text-[var(--ads-text-secondary)]" : "text-[var(--ads-text-brand)]";
|
|
97
|
+
|
|
98
|
+
const onSelect = (id: string) => {
|
|
99
|
+
emit("update:activeId", id);
|
|
100
|
+
emit("select", id);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
</script>
|
|
@@ -1,119 +1,216 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component
|
|
3
|
-
:is="as"
|
|
4
|
-
:type="as === 'button' ? 'button' : undefined"
|
|
5
|
-
:disabled="as === 'button' ? disabled : undefined"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
v-if="
|
|
38
|
-
class="
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="as"
|
|
4
|
+
:type="as === 'button' ? 'button' : undefined"
|
|
5
|
+
:disabled="as === 'button' ? disabled : undefined"
|
|
6
|
+
:aria-busy="loading || undefined"
|
|
7
|
+
class="flex h-full min-w-0 rounded-[var(--ads-metric-radius)] border p-[var(--ads-metric-padding)] text-left font-normal transition-[background-color,border-color,box-shadow]"
|
|
8
|
+
:class="[type === 'kpi' ? 'flex-row items-center gap-4' : 'flex-col items-start gap-3', surfaceClass]"
|
|
9
|
+
>
|
|
10
|
+
<!-- KPI: ícone grande à esquerda, título e valor à direita -->
|
|
11
|
+
<template v-if="type === 'kpi'">
|
|
12
|
+
<UIcon v-if="icon" :name="icon" class="size-6 shrink-0" :class="iconClass" aria-hidden="true" />
|
|
13
|
+
<div class="flex min-w-0 flex-1 flex-col items-start gap-2">
|
|
14
|
+
<div class="flex min-w-0 items-center gap-2">
|
|
15
|
+
<p :class="titleClass">{{ title }}</p>
|
|
16
|
+
<AdsCardHint v-if="hint" :text="hint" />
|
|
17
|
+
</div>
|
|
18
|
+
<span v-if="loading" :class="skeletonClass" class="h-5 w-[140px] rounded-[var(--ads-radius-xsm)]" aria-hidden="true" />
|
|
19
|
+
<div v-else-if="empty" class="flex min-w-0 items-center gap-2">
|
|
20
|
+
<span class="text-[length:var(--ads-font-size-rg)] font-bold leading-[1.3] text-[var(--ads-text-tertiary)]" aria-hidden="true">—</span>
|
|
21
|
+
<span :class="emptyMessageClass">{{ emptyMessage }}</span>
|
|
22
|
+
</div>
|
|
23
|
+
<div v-else class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">
|
|
24
|
+
<p class="text-[length:var(--ads-font-size-rg)] font-bold leading-[1.3] text-[var(--ads-text-secondary)] tabular-nums">{{ value }}</p>
|
|
25
|
+
<AdsCardVariation v-if="delta" :value="delta" :direction="deltaDirection" :tone="deltaTone" />
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<!-- Pendência: ícone pequeno e título em negrito; número grande com unidade -->
|
|
31
|
+
<template v-else-if="type === 'pending'">
|
|
32
|
+
<div class="flex w-full min-w-0 items-center gap-1">
|
|
33
|
+
<UIcon v-if="icon" :name="icon" class="size-4 shrink-0" :class="iconClass" aria-hidden="true" />
|
|
34
|
+
<p class="min-w-0 truncate font-bold" :class="titleClass">{{ title }}</p>
|
|
35
|
+
<AdsCardHint v-if="hint" :text="hint" />
|
|
36
|
+
</div>
|
|
37
|
+
<span v-if="loading" :class="skeletonClass" class="h-7 w-[72px] rounded-[var(--ads-radius-xsm)]" aria-hidden="true" />
|
|
38
|
+
<div v-else-if="empty" class="flex min-w-0 items-baseline gap-1">
|
|
39
|
+
<span class="text-[length:var(--ads-font-size-md)] font-bold leading-[1.3] text-[var(--ads-text-tertiary)]" aria-hidden="true">—</span>
|
|
40
|
+
<span :class="emptyMessageClass">{{ emptyMessage }}</span>
|
|
41
|
+
</div>
|
|
42
|
+
<p v-else class="flex min-w-0 flex-wrap items-baseline gap-1">
|
|
43
|
+
<span :class="bigValueClass">{{ value }}</span>
|
|
44
|
+
<span v-if="unit" class="text-[length:var(--ads-font-size-xxxs)] font-bold leading-[1.2] text-[var(--ads-text-secondary)]">{{ unit }}</span>
|
|
45
|
+
</p>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<!-- Métrica: período, valor com variação e comparativo -->
|
|
49
|
+
<template v-else>
|
|
50
|
+
<div class="flex w-full min-w-0 items-center gap-2">
|
|
51
|
+
<p class="min-w-0 flex-1" :class="titleClass">{{ title }}</p>
|
|
52
|
+
<AdsCardHint v-if="hint" :text="hint" />
|
|
53
|
+
<slot name="actions" />
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<AdsCardPeriod v-if="period || (loading && periodLabel)" :label="periodLabel" :value="period" :loading="loading" />
|
|
57
|
+
|
|
58
|
+
<div v-if="empty && !loading" class="flex w-full justify-center py-2">
|
|
59
|
+
<slot name="empty">
|
|
60
|
+
<AdsEmptyState small :title="emptyMessage" :subtitle="emptyDescription ?? ''" :show-actions="Boolean($slots['empty-actions'])">
|
|
61
|
+
<slot name="empty-actions" />
|
|
62
|
+
</AdsEmptyState>
|
|
63
|
+
</slot>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<template v-else>
|
|
67
|
+
<span v-if="loading" :class="skeletonClass" class="h-7 w-[110px] rounded-[var(--ads-radius-xsm)]" aria-hidden="true" />
|
|
68
|
+
<div v-else class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">
|
|
69
|
+
<UIcon v-if="valueIcon" :name="valueIcon" class="size-6 shrink-0 text-[var(--ads-text-primary)]" aria-hidden="true" />
|
|
70
|
+
<p :class="bigValueClass">{{ value }}</p>
|
|
71
|
+
<AdsCardVariation v-if="delta" :value="delta" :direction="deltaDirection" :tone="deltaTone" />
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<template v-if="comparisonLabel">
|
|
75
|
+
<hr v-if="divider && !comparisonInline" class="h-px w-full border-0 bg-[var(--ads-border-subtle)]" />
|
|
76
|
+
|
|
77
|
+
<div v-if="comparisonInline" class="flex w-full flex-wrap items-baseline gap-x-2 gap-y-1 text-[var(--ads-text-secondary)]">
|
|
78
|
+
<span class="text-[length:var(--ads-font-size-xxxs)] leading-[1.2]">{{ comparisonLabel }}</span>
|
|
79
|
+
<span v-if="loading" :class="skeletonClass" class="h-4 w-20 rounded-[var(--ads-radius-xsm)]" aria-hidden="true" />
|
|
80
|
+
<span v-else class="text-[length:var(--ads-font-size-xs)] leading-[1.3] tabular-nums">{{ comparisonValue }}</span>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<div v-else class="flex w-full flex-col items-start gap-2">
|
|
84
|
+
<AdsCardPeriod
|
|
85
|
+
:label="comparisonLabel"
|
|
86
|
+
:value="comparisonBadge"
|
|
87
|
+
tone="neutral"
|
|
88
|
+
:loading="loading && Boolean(comparisonBadge)"
|
|
89
|
+
:skeleton-width="80"
|
|
90
|
+
/>
|
|
91
|
+
<span v-if="loading" :class="skeletonClass" class="h-4 w-16 rounded-[var(--ads-radius-xsm)]" aria-hidden="true" />
|
|
92
|
+
<p v-else class="text-[length:var(--ads-font-size-xs)] leading-[1.3] text-[var(--ads-text-secondary)] tabular-nums">{{ comparisonValue }}</p>
|
|
93
|
+
</div>
|
|
94
|
+
</template>
|
|
95
|
+
</template>
|
|
96
|
+
</template>
|
|
97
|
+
</component>
|
|
98
|
+
</template>
|
|
99
|
+
|
|
100
|
+
<script setup lang="ts">
|
|
101
|
+
import { computed } from "vue";
|
|
102
|
+
import AdsCardHint from "./AdsCardHint.vue";
|
|
103
|
+
import AdsCardPeriod from "./AdsCardPeriod.vue";
|
|
104
|
+
import AdsCardVariation from "./AdsCardVariation.vue";
|
|
105
|
+
import type { AdsCardVariationDirection, AdsCardVariationTone } from "./AdsCardVariation.vue";
|
|
106
|
+
import AdsEmptyState from "./AdsEmptyState.vue";
|
|
107
|
+
|
|
108
|
+
export type AdsMetricCardType = "kpi" | "pending" | "metric";
|
|
109
|
+
|
|
110
|
+
const props = withDefaults(
|
|
111
|
+
defineProps<{
|
|
112
|
+
/**
|
|
113
|
+
* kpi: ícone grande, título e valor.
|
|
114
|
+
* pending: número em destaque com unidade, bom para cards selecionáveis.
|
|
115
|
+
* metric: período, valor com variação e comparativo.
|
|
116
|
+
*/
|
|
117
|
+
type?: AdsMetricCardType;
|
|
118
|
+
title: string;
|
|
119
|
+
/** Valor principal. */
|
|
120
|
+
value?: string;
|
|
121
|
+
/** Texto do ícone de informação ao lado do título. */
|
|
122
|
+
hint?: string;
|
|
123
|
+
/** Ícone Lucide: 24px no KPI, 16px na Pendência. */
|
|
124
|
+
icon?: string;
|
|
125
|
+
/** Unidade ao lado do número na Pendência, como "pendências". */
|
|
126
|
+
unit?: string;
|
|
127
|
+
/** Ícone de 24px antes do valor na Métrica. */
|
|
128
|
+
valueIcon?: string;
|
|
129
|
+
/** Variação ao lado do valor (KPI e Métrica), como "1,15%". */
|
|
130
|
+
delta?: string;
|
|
131
|
+
deltaDirection?: AdsCardVariationDirection;
|
|
132
|
+
/** positive quando a variação é boa; negative quando é ruim. */
|
|
133
|
+
deltaTone?: AdsCardVariationTone;
|
|
134
|
+
/** Datas do período (Métrica), como "01/12/2023 - 20/12/2023". */
|
|
135
|
+
period?: string;
|
|
136
|
+
periodLabel?: string;
|
|
137
|
+
/** Rótulo do comparativo (Métrica). Sem ele, o comparativo some. */
|
|
138
|
+
comparisonLabel?: string;
|
|
139
|
+
comparisonValue?: string;
|
|
140
|
+
/** Selo cinza ao lado do rótulo do comparativo, como "Set, Out e Nov". */
|
|
141
|
+
comparisonBadge?: string;
|
|
142
|
+
/** Rótulo e valor do comparativo na mesma linha, sem divisória. */
|
|
143
|
+
comparisonInline?: boolean;
|
|
144
|
+
/** Linha entre o valor e o comparativo empilhado. */
|
|
145
|
+
divider?: boolean;
|
|
146
|
+
/** Estado Selecionado: fundo azul claro, borda azul e sombra. */
|
|
147
|
+
selected?: boolean;
|
|
148
|
+
/** Estado Carregando: título e rótulos ficam; valores viram skeleton. */
|
|
149
|
+
loading?: boolean;
|
|
150
|
+
/** Estado Vazio. KPI e Pendência mostram "—" com a mensagem; Métrica mostra o empty state. */
|
|
151
|
+
empty?: boolean;
|
|
152
|
+
emptyMessage?: string;
|
|
153
|
+
/** Texto de apoio do empty state da Métrica. */
|
|
154
|
+
emptyDescription?: string;
|
|
155
|
+
/** `button` quando o cartão é a própria ação. */
|
|
156
|
+
as?: "div" | "button";
|
|
157
|
+
disabled?: boolean;
|
|
158
|
+
/** Hover padrão dos cards clicáveis: borda cinza mais escura e sombra leve. false desliga. */
|
|
159
|
+
hoverable?: boolean;
|
|
160
|
+
}>(),
|
|
161
|
+
{
|
|
162
|
+
type: "metric",
|
|
163
|
+
value: undefined,
|
|
164
|
+
hint: undefined,
|
|
165
|
+
icon: undefined,
|
|
166
|
+
unit: undefined,
|
|
167
|
+
valueIcon: undefined,
|
|
168
|
+
delta: undefined,
|
|
169
|
+
deltaDirection: "up",
|
|
170
|
+
deltaTone: "positive",
|
|
171
|
+
period: undefined,
|
|
172
|
+
periodLabel: "Período:",
|
|
173
|
+
comparisonLabel: undefined,
|
|
174
|
+
comparisonValue: undefined,
|
|
175
|
+
comparisonBadge: undefined,
|
|
176
|
+
comparisonInline: false,
|
|
177
|
+
divider: true,
|
|
178
|
+
selected: false,
|
|
179
|
+
loading: false,
|
|
180
|
+
empty: false,
|
|
181
|
+
emptyMessage: "Sem dados no período",
|
|
182
|
+
emptyDescription: undefined,
|
|
183
|
+
as: "div",
|
|
184
|
+
disabled: false,
|
|
185
|
+
hoverable: true,
|
|
186
|
+
},
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const titleClass = "text-[length:var(--ads-font-size-xs)] leading-[1.3] text-[var(--ads-metric-label)]";
|
|
190
|
+
const bigValueClass = "text-[length:var(--ads-font-size-md)] font-bold leading-[1.3] text-[var(--ads-metric-value)] tabular-nums";
|
|
191
|
+
const emptyMessageClass = "text-[length:var(--ads-font-size-xxxs)] leading-[1.2] text-[var(--ads-text-secondary)]";
|
|
192
|
+
const skeletonClass = "block animate-pulse bg-[var(--ads-loading-skeleton)] motion-reduce:animate-none";
|
|
193
|
+
|
|
194
|
+
const iconClass = computed(() =>
|
|
195
|
+
props.selected ? "text-[var(--ads-text-brand)]" : "text-[var(--ads-text-secondary)]",
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const surfaceClass = computed(() => {
|
|
199
|
+
const classes = [
|
|
200
|
+
props.selected
|
|
201
|
+
? "border-[var(--ads-card-selected-border)] bg-[var(--ads-card-selected-background)] shadow-[var(--ads-shadow-level-1)]"
|
|
202
|
+
: "border-[var(--ads-metric-border)] bg-[var(--ads-metric-background)]",
|
|
203
|
+
];
|
|
204
|
+
|
|
205
|
+
if (props.as === "button") {
|
|
206
|
+
classes.push(
|
|
207
|
+
"cursor-pointer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-border-focused)] disabled:cursor-not-allowed disabled:opacity-50",
|
|
208
|
+
);
|
|
209
|
+
if (props.hoverable && !props.selected && !props.disabled) {
|
|
210
|
+
classes.push("hover:border-[var(--ads-card-hover-border)] hover:shadow-[var(--ads-shadow-level-1)]");
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return classes;
|
|
215
|
+
});
|
|
216
|
+
</script>
|