ads-nuxt 0.4.0 → 0.4.2
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 +574 -575
- 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 -9
- package/app/assets/brand/radar.svg +9 -9
- package/app/assets/css/ads-colors.css +257 -257
- package/app/assets/css/component-tokens.css +6 -2
- package/app/assets/css/main.css +585 -585
- package/app/components/AdsBadge.vue +47 -47
- package/app/components/AdsBroadcast.vue +24 -24
- package/app/components/AdsButton.vue +547 -547
- package/app/components/AdsButtonGroup.vue +39 -39
- package/app/components/AdsButtonMenu.vue +48 -48
- package/app/components/AdsCard.vue +188 -188
- package/app/components/AdsCardHint.vue +56 -22
- package/app/components/AdsCardPeriod.vue +43 -43
- package/app/components/AdsCardVariation.vue +31 -31
- package/app/components/AdsCharttip.vue +79 -79
- package/app/components/AdsDatePicker.vue +509 -509
- package/app/components/AdsDropdownMenu.vue +30 -30
- package/app/components/AdsEmptyState.vue +61 -61
- package/app/components/AdsFeatureCard.vue +292 -210
- package/app/components/AdsFileCard.vue +98 -98
- package/app/components/AdsFooter.vue +25 -25
- package/app/components/AdsHeavyAccountCell.vue +59 -59
- package/app/components/AdsHeavyHeaderCell.vue +70 -70
- package/app/components/AdsHeavyTable.vue +135 -139
- package/app/components/AdsInput.vue +148 -148
- package/app/components/AdsLoading.vue +217 -217
- package/app/components/AdsMenuBar.vue +110 -110
- package/app/components/AdsMetricCard.vue +226 -216
- package/app/components/AdsModal.vue +160 -160
- package/app/components/AdsMonthPicker.vue +80 -80
- package/app/components/AdsNavbarApp.vue +67 -67
- package/app/components/AdsNavbarDesk.vue +67 -67
- package/app/components/AdsNotabilityPill.vue +24 -24
- package/app/components/AdsNumberInput.vue +173 -173
- package/app/components/AdsPanelCard.vue +99 -99
- package/app/components/AdsPill.vue +144 -144
- package/app/components/AdsProductTag.vue +80 -80
- package/app/components/AdsSearchInput.vue +122 -122
- package/app/components/AdsSegmentedTabs.vue +62 -62
- package/app/components/AdsSelect.vue +283 -283
- package/app/components/AdsSelectItem.vue +128 -128
- package/app/components/AdsSelectPanel.vue +221 -221
- package/app/components/AdsSideMenu.vue +101 -101
- package/app/components/AdsSmalltip.vue +44 -44
- package/app/components/AdsStepper.vue +222 -222
- package/app/components/AdsTable.vue +172 -176
- package/app/components/AdsTableHeaderCell.vue +80 -80
- package/app/components/AdsTableSkeleton.vue +113 -113
- 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 +184 -184
- package/app/components/AdsTooltip.vue +73 -73
- package/app/components/OverlayLoading.vue +2 -17
- package/app/components/ProgressBarLoading.vue +235 -235
- package/app/composables/useOverlayLoading.ts +88 -88
- package/app/constants/ads-color-swatches.ts +240 -240
- package/app/locale/pt-br.ts +6 -6
- package/app/plugins/ads-toast.client.ts +24 -24
- package/app/theme/ads-theme.ts +374 -374
- package/app/theme/ads-tokens.ts +391 -391
- package/app/theme/component-tokens.json +6 -2
- package/app/theme/component-tokens.ts +6 -2
- package/app/types/overlay-loading.types.ts +32 -35
- package/app/utils/ads-filter-select.ts +191 -191
- package/app/utils/ads-table.ts +416 -398
- 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 +57 -56
|
@@ -1,216 +1,226 @@
|
|
|
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, selected ? '!text-[var(--ads-text-brand)]' : '']">{{ 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 {
|
|
106
|
-
import
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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 w-full min-w-0 items-center gap-2">
|
|
15
|
+
<p :class="titleClass">{{ title }}</p>
|
|
16
|
+
<AdsCardHint v-if="hint" :text="hint" :icon="hintIcon" :color="hintColor" :align="hintAlign" />
|
|
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" :icon="hintIcon" :color="hintColor" :align="hintAlign" />
|
|
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, selected ? '!text-[var(--ads-text-brand)]' : '']">{{ 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" :icon="hintIcon" :color="hintColor" :align="hintAlign" />
|
|
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 { AdsCardHintAlign, AdsCardHintColor } from "./AdsCardHint.vue";
|
|
106
|
+
import type { AdsCardVariationDirection, AdsCardVariationTone } from "./AdsCardVariation.vue";
|
|
107
|
+
import AdsEmptyState from "./AdsEmptyState.vue";
|
|
108
|
+
|
|
109
|
+
export type AdsMetricCardType = "kpi" | "pending" | "metric";
|
|
110
|
+
|
|
111
|
+
const props = withDefaults(
|
|
112
|
+
defineProps<{
|
|
113
|
+
/**
|
|
114
|
+
* kpi: ícone grande, título e valor.
|
|
115
|
+
* pending: número em destaque com unidade, bom para cards selecionáveis.
|
|
116
|
+
* metric: período, valor com variação e comparativo.
|
|
117
|
+
*/
|
|
118
|
+
type?: AdsMetricCardType;
|
|
119
|
+
title: string;
|
|
120
|
+
/** Valor principal. */
|
|
121
|
+
value?: string;
|
|
122
|
+
/** Texto do balão do ícone ao lado do título. Sem ele, o ícone some. */
|
|
123
|
+
hint?: string;
|
|
124
|
+
/** Ícone Lucide do balão. Padrão: informação. */
|
|
125
|
+
hintIcon?: string;
|
|
126
|
+
/** Cor do ícone do balão. */
|
|
127
|
+
hintColor?: AdsCardHintColor;
|
|
128
|
+
/** `end` encosta o ícone no fim do card, à direita. */
|
|
129
|
+
hintAlign?: AdsCardHintAlign;
|
|
130
|
+
/** Ícone Lucide: 24px no KPI, 16px na Pendência. */
|
|
131
|
+
icon?: string;
|
|
132
|
+
/** Unidade ao lado do número na Pendência, como "pendências". */
|
|
133
|
+
unit?: string;
|
|
134
|
+
/** Ícone de 24px antes do valor na Métrica. */
|
|
135
|
+
valueIcon?: string;
|
|
136
|
+
/** Variação ao lado do valor (KPI e Métrica), como "1,15%". */
|
|
137
|
+
delta?: string;
|
|
138
|
+
deltaDirection?: AdsCardVariationDirection;
|
|
139
|
+
/** positive quando a variação é boa; negative quando é ruim. */
|
|
140
|
+
deltaTone?: AdsCardVariationTone;
|
|
141
|
+
/** Datas do período (Métrica), como "01/12/2023 - 20/12/2023". */
|
|
142
|
+
period?: string;
|
|
143
|
+
periodLabel?: string;
|
|
144
|
+
/** Rótulo do comparativo (Métrica). Sem ele, o comparativo some. */
|
|
145
|
+
comparisonLabel?: string;
|
|
146
|
+
comparisonValue?: string;
|
|
147
|
+
/** Selo cinza ao lado do rótulo do comparativo, como "Set, Out e Nov". */
|
|
148
|
+
comparisonBadge?: string;
|
|
149
|
+
/** Rótulo e valor do comparativo na mesma linha, sem divisória. */
|
|
150
|
+
comparisonInline?: boolean;
|
|
151
|
+
/** Linha entre o valor e o comparativo empilhado. */
|
|
152
|
+
divider?: boolean;
|
|
153
|
+
/** Estado Selecionado: fundo azul claro, borda azul e sombra. */
|
|
154
|
+
selected?: boolean;
|
|
155
|
+
/** Estado Carregando: título e rótulos ficam; valores viram skeleton. */
|
|
156
|
+
loading?: boolean;
|
|
157
|
+
/** Estado Vazio. KPI e Pendência mostram "—" com a mensagem; Métrica mostra o empty state. */
|
|
158
|
+
empty?: boolean;
|
|
159
|
+
emptyMessage?: string;
|
|
160
|
+
/** Texto de apoio do empty state da Métrica. */
|
|
161
|
+
emptyDescription?: string;
|
|
162
|
+
/** `button` quando o cartão é a própria ação. */
|
|
163
|
+
as?: "div" | "button";
|
|
164
|
+
disabled?: boolean;
|
|
165
|
+
/** Hover padrão dos cards clicáveis: borda cinza mais escura e sombra leve. false desliga. */
|
|
166
|
+
hoverable?: boolean;
|
|
167
|
+
}>(),
|
|
168
|
+
{
|
|
169
|
+
type: "metric",
|
|
170
|
+
value: undefined,
|
|
171
|
+
hint: undefined,
|
|
172
|
+
hintIcon: "i-lucide-info",
|
|
173
|
+
hintColor: "secondary",
|
|
174
|
+
hintAlign: "start",
|
|
175
|
+
icon: undefined,
|
|
176
|
+
unit: undefined,
|
|
177
|
+
valueIcon: undefined,
|
|
178
|
+
delta: undefined,
|
|
179
|
+
deltaDirection: "up",
|
|
180
|
+
deltaTone: "positive",
|
|
181
|
+
period: undefined,
|
|
182
|
+
periodLabel: "Período:",
|
|
183
|
+
comparisonLabel: undefined,
|
|
184
|
+
comparisonValue: undefined,
|
|
185
|
+
comparisonBadge: undefined,
|
|
186
|
+
comparisonInline: false,
|
|
187
|
+
divider: true,
|
|
188
|
+
selected: false,
|
|
189
|
+
loading: false,
|
|
190
|
+
empty: false,
|
|
191
|
+
emptyMessage: "Sem dados no período",
|
|
192
|
+
emptyDescription: undefined,
|
|
193
|
+
as: "div",
|
|
194
|
+
disabled: false,
|
|
195
|
+
hoverable: true,
|
|
196
|
+
},
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const titleClass = "text-[length:var(--ads-font-size-xs)] leading-[1.3] text-[var(--ads-metric-label)]";
|
|
200
|
+
const bigValueClass = "text-[length:var(--ads-font-size-md)] font-bold leading-[1.3] text-[var(--ads-metric-value)] tabular-nums";
|
|
201
|
+
const emptyMessageClass = "text-[length:var(--ads-font-size-xxxs)] leading-[1.2] text-[var(--ads-text-secondary)]";
|
|
202
|
+
const skeletonClass = "block animate-pulse bg-[var(--ads-loading-skeleton)] motion-reduce:animate-none";
|
|
203
|
+
|
|
204
|
+
const iconClass = computed(() =>
|
|
205
|
+
props.selected ? "text-[var(--ads-text-brand)]" : "text-[var(--ads-text-secondary)]",
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
const surfaceClass = computed(() => {
|
|
209
|
+
const classes = [
|
|
210
|
+
props.selected
|
|
211
|
+
? "border-[var(--ads-card-selected-border)] bg-[var(--ads-card-selected-background)] shadow-[var(--ads-shadow-level-1)]"
|
|
212
|
+
: "border-[var(--ads-metric-border)] bg-[var(--ads-metric-background)]",
|
|
213
|
+
];
|
|
214
|
+
|
|
215
|
+
if (props.as === "button") {
|
|
216
|
+
classes.push(
|
|
217
|
+
"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",
|
|
218
|
+
);
|
|
219
|
+
if (props.hoverable && !props.selected && !props.disabled) {
|
|
220
|
+
classes.push("hover:border-[var(--ads-card-hover-border)] hover:shadow-[var(--ads-shadow-level-1)]");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return classes;
|
|
225
|
+
});
|
|
226
|
+
</script>
|