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.
Files changed (90) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +573 -577
  3. package/app/app.config.ts +25 -25
  4. package/app/assets/ads/checkbox-check.svg +5 -5
  5. package/app/assets/ads/checkbox-minus.svg +5 -5
  6. package/app/assets/brand/farmarcas.svg +6 -6
  7. package/app/assets/brand/radar-symbol.svg +9 -0
  8. package/app/assets/brand/radar.svg +9 -9
  9. package/app/assets/css/ads-colors.css +257 -246
  10. package/app/assets/css/component-tokens.css +367 -403
  11. package/app/assets/css/main.css +624 -617
  12. package/app/components/AdsBadge.vue +47 -48
  13. package/app/components/AdsBroadcast.vue +24 -45
  14. package/app/components/AdsButton.vue +539 -569
  15. package/app/components/AdsButtonGroup.vue +39 -39
  16. package/app/components/AdsButtonMenu.vue +48 -48
  17. package/app/components/AdsCard.vue +188 -117
  18. package/app/components/AdsCardHint.vue +22 -0
  19. package/app/components/AdsCardPeriod.vue +43 -0
  20. package/app/components/AdsCardVariation.vue +31 -0
  21. package/app/components/AdsCharttip.vue +78 -78
  22. package/app/components/AdsCheckbox.vue +77 -77
  23. package/app/components/AdsDatePicker.vue +492 -491
  24. package/app/components/AdsDropdownMenu.vue +30 -19
  25. package/app/components/AdsEmptyState.vue +58 -58
  26. package/app/components/AdsFeatureCard.vue +210 -219
  27. package/app/components/AdsFileCard.vue +98 -101
  28. package/app/components/AdsFooter.vue +25 -25
  29. package/app/components/AdsHeavyAccountCell.vue +59 -0
  30. package/app/components/AdsHeavyHeaderCell.vue +70 -0
  31. package/app/components/AdsHeavyTable.vue +135 -0
  32. package/app/components/AdsInput.vue +147 -147
  33. package/app/components/AdsLoading.vue +217 -109
  34. package/app/components/AdsMenuBar.vue +103 -103
  35. package/app/components/AdsMetricCard.vue +216 -119
  36. package/app/components/AdsModal.vue +157 -157
  37. package/app/components/AdsMonthPicker.vue +80 -80
  38. package/app/components/AdsNavbarApp.vue +67 -67
  39. package/app/components/AdsNavbarDesk.vue +62 -62
  40. package/app/components/AdsNotabilityPill.vue +24 -27
  41. package/app/components/AdsNumberInput.vue +173 -173
  42. package/app/components/AdsPagination.vue +91 -91
  43. package/app/components/AdsPanelCard.vue +99 -0
  44. package/app/components/AdsPill.vue +144 -92
  45. package/app/components/AdsProductTag.vue +61 -61
  46. package/app/components/AdsRadio.vue +70 -70
  47. package/app/components/AdsSearchInput.vue +122 -122
  48. package/app/components/AdsSegmentedTabs.vue +62 -28
  49. package/app/components/{AdsFilterSelect.vue → AdsSelect.vue} +266 -210
  50. package/app/components/AdsSelectItem.vue +128 -0
  51. package/app/components/AdsSelectPanel.vue +150 -0
  52. package/app/components/AdsSideMenu.vue +101 -101
  53. package/app/components/AdsSmalltip.vue +44 -44
  54. package/app/components/AdsStepper.vue +222 -0
  55. package/app/components/AdsSteptip.vue +101 -101
  56. package/app/components/AdsSwitch.vue +59 -59
  57. package/app/components/AdsTable.vue +161 -100
  58. package/app/components/AdsTableHeaderCell.vue +80 -0
  59. package/app/components/AdsTableSkeleton.vue +113 -0
  60. package/app/components/AdsTableToolbar.vue +44 -44
  61. package/app/components/AdsTabs.vue +51 -51
  62. package/app/components/AdsTextarea.vue +116 -116
  63. package/app/components/AdsToast.vue +183 -181
  64. package/app/components/AdsTooltip.vue +73 -73
  65. package/app/components/OverlayLoading.vue +173 -173
  66. package/app/components/ProgressBarLoading.vue +235 -256
  67. package/app/composables/useOverlayLoading.ts +66 -66
  68. package/app/constants/ads-color-swatches.ts +240 -239
  69. package/app/locale/pt-br.ts +6 -6
  70. package/app/plugins/ads-toast.client.ts +24 -24
  71. package/app/theme/ads-theme.ts +374 -370
  72. package/app/theme/ads-tokens.ts +391 -379
  73. package/app/theme/component-tokens.json +366 -402
  74. package/app/theme/component-tokens.ts +807 -815
  75. package/app/types/overlay-loading.types.ts +26 -26
  76. package/app/utils/ads-filter-select.ts +191 -172
  77. package/app/utils/ads-table.ts +395 -204
  78. package/app/utils/calendar-date.ts +163 -163
  79. package/app/utils/category-role.ts +45 -45
  80. package/app/utils/money.ts +77 -77
  81. package/app/utils/notability.ts +8 -8
  82. package/app/utils/parser.ts +134 -134
  83. package/app/utils/percentage.ts +54 -54
  84. package/nuxt.config.ts +31 -31
  85. package/package.json +1 -1
  86. package/app/components/AdsFarmarcasPill.vue +0 -74
  87. package/app/components/AdsFilterDropdown.vue +0 -174
  88. package/app/components/AdsFilterOption.vue +0 -74
  89. package/app/components/AdsListDropdown.vue +0 -44
  90. 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
- class="flex h-full min-w-0 flex-col gap-[var(--ads-metric-gap)] border p-[var(--ads-metric-padding)] text-left font-normal"
7
- :class="[radiusClass, surfaceClass]"
8
- >
9
- <div class="flex flex-col items-start gap-1">
10
- <div class="flex min-w-0 items-center gap-2">
11
- <p :class="labelClass">{{ title }}</p>
12
- <AdsTooltip v-if="hint" :description="hint" :show-title="false" class="shrink-0">
13
- <UIcon
14
- name="i-lucide-help-circle"
15
- size="xs"
16
- class="align-middle text-[var(--ads-border-icon-support)]"
17
- />
18
- </AdsTooltip>
19
- </div>
20
- <slot name="status" />
21
- </div>
22
-
23
- <div class="flex min-w-0 items-center gap-2">
24
- <p class="min-w-0" :class="empty ? emptyValueClass : valueClass">
25
- {{ value }}
26
- </p>
27
- <span
28
- v-if="!empty && slots.delta"
29
- class="inline-flex shrink-0 items-center gap-1"
30
- :class="deltaClass"
31
- >
32
- <slot name="delta" />
33
- </span>
34
- </div>
35
-
36
- <div
37
- v-if="caption || slots.footer"
38
- class="mt-auto flex items-end justify-between gap-2"
39
- >
40
- <p v-if="caption" :class="captionClass">{{ caption }}</p>
41
- <slot name="footer" />
42
- </div>
43
-
44
- <div v-if="slots.default" class="min-h-0 flex-1">
45
- <slot />
46
- </div>
47
- </component>
48
- </template>
49
-
50
- <script setup lang="ts">
51
- import { computed, useSlots } from "vue";
52
- import AdsTooltip from "./AdsTooltip.vue";
53
-
54
- /**
55
- * Número em destaque.
56
- * Rótulo: 14px, medium. Valor: 20px, bold. Variação: 14px, bold. Legenda: 12px, regular.
57
- */
58
- const labelClass =
59
- "text-[length:var(--ads-metric-label-size)] font-medium leading-[var(--ads-line-height-sm)] text-[var(--ads-metric-label)]";
60
- const valueClass =
61
- "text-[length:var(--ads-metric-value-size)] font-bold leading-[var(--ads-line-height-sm)] text-[var(--ads-metric-value)] tabular-nums";
62
- const emptyValueClass =
63
- "text-[length:var(--ads-font-size-xs)] font-medium leading-[var(--ads-line-height-sm)] text-[var(--ads-text-tertiary)]";
64
- const deltaClass =
65
- "text-[length:var(--ads-font-size-xxs)] font-bold leading-[var(--ads-line-height-sm)] tabular-nums";
66
- const captionClass =
67
- "text-[length:var(--ads-metric-caption-size)] font-normal leading-[var(--ads-line-height-md)] text-[var(--ads-metric-label)]";
68
-
69
- const props = withDefaults(
70
- defineProps<{
71
- /** Rótulo acima do número. */
72
- title: string;
73
- /** Número ou frase principal. */
74
- value: string;
75
- /** Texto do ícone de ajuda ao lado do rótulo. */
76
- hint?: string;
77
- /** Linha curta abaixo do número, como o valor atual. */
78
- caption?: string;
79
- /** Valor ausente: 16px medium, cor tertiary. */
80
- empty?: boolean;
81
- /** `button` quando o cartão é a própria ação. */
82
- as?: "div" | "button";
83
- disabled?: boolean;
84
- /** Realce de item escolhido, como um filtro ativo. */
85
- selected?: boolean;
86
- }>(),
87
- {
88
- hint: undefined,
89
- caption: undefined,
90
- empty: false,
91
- as: "div",
92
- disabled: false,
93
- selected: false,
94
- },
95
- );
96
-
97
- const slots = useSlots();
98
-
99
- const radiusClass = "rounded-[var(--ads-metric-radius)]";
100
-
101
- const surfaceClass = computed(() => {
102
- const classes = [
103
- props.selected
104
- ? "border-[var(--color-neutral-300)] bg-[var(--color-neutral-100)]"
105
- : "border-[var(--ads-metric-border)] bg-[var(--ads-metric-background)]",
106
- ];
107
-
108
- if (props.as === "button") {
109
- classes.push(
110
- "cursor-pointer transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-primary)] disabled:cursor-not-allowed disabled:opacity-50",
111
- );
112
- if (!props.selected && !props.disabled) {
113
- classes.push("hover:bg-[var(--color-neutral-100)]");
114
- }
115
- }
116
-
117
- return classes;
118
- });
119
- </script>
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>