ads-nuxt 0.1.4 → 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 -479
  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 -143
  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 -166
  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 -113
  48. package/app/components/AdsSegmentedTabs.vue +62 -28
  49. package/app/components/{AdsFilterSelect.vue → AdsSelect.vue} +266 -203
  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 -109
  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,19 +1,30 @@
1
- <template>
2
- <UDropdownMenu :items="items" :content="content" :ui="adsDropdownMenuUi">
3
- <slot />
4
- </UDropdownMenu>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import type { DropdownMenuItem } from "@nuxt/ui";
9
- import { adsDropdownMenuUi } from "../theme/ads-theme";
10
-
11
- defineProps<{
12
- items: DropdownMenuItem[] | DropdownMenuItem[][];
13
- content?: {
14
- side?: "top" | "right" | "bottom" | "left";
15
- align?: "start" | "center" | "end";
16
- sideOffset?: number;
17
- };
18
- }>();
19
- </script>
1
+ <!--
2
+ AdsDropdownMenu — menu de ações (UDropdownMenu com o tema ADS).
3
+ Para escolher valores (simples, múltipla, busca, subtítulo, selo), use o AdsSelect.
4
+ -->
5
+ <template>
6
+ <UDropdownMenu :items="items" :content="content" :ui="adsDropdownMenuUi">
7
+ <slot />
8
+ </UDropdownMenu>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import type { DropdownMenuItem } from "@nuxt/ui";
13
+ import { adsDropdownMenuUi } from "../theme/ads-theme";
14
+
15
+ withDefaults(
16
+ defineProps<{
17
+ /** Ações do menu. Grupos em arrays aninhados ganham separador. */
18
+ items?: DropdownMenuItem[] | DropdownMenuItem[][];
19
+ content?: {
20
+ side?: "top" | "right" | "bottom" | "left";
21
+ align?: "start" | "center" | "end";
22
+ sideOffset?: number;
23
+ };
24
+ }>(),
25
+ {
26
+ items: () => [],
27
+ content: undefined,
28
+ },
29
+ );
30
+ </script>
@@ -1,58 +1,58 @@
1
- <template>
2
- <div
3
- class="flex flex-col items-center text-center"
4
- :class="small ? 'gap-[var(--ads-empty-gap-sm)]' : 'gap-[var(--ads-empty-gap)]'"
5
- >
6
- <svg
7
- viewBox="0 0 24 24"
8
- fill="none"
9
- aria-hidden="true"
10
- class="text-[var(--ads-empty-icon-color)]"
11
- :class="small ? 'size-[var(--ads-empty-icon-sm)]' : 'size-[var(--ads-empty-icon)]'"
12
- >
13
- <circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.6" />
14
- <path d="M9 9l6 6M15 9l-6 6" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" />
15
- </svg>
16
- <div class="flex max-w-xs flex-col items-center gap-[var(--ads-empty-text-gap)]">
17
- <p
18
- class="font-bold leading-[1.3] text-[var(--ads-text-primary)]"
19
- :class="small ? 'text-[length:var(--ads-empty-title-size-sm)]' : 'text-[length:var(--ads-empty-title-size)]'"
20
- >
21
- {{ title }}
22
- </p>
23
- <p v-if="subtitle" class="text-[length:var(--ads-empty-subtitle-size)] leading-[1.2] text-[var(--ads-text-secondary)]">
24
- {{ subtitle }}
25
- </p>
26
- </div>
27
- <div v-if="showActions" class="flex flex-col items-center gap-2">
28
- <slot>
29
- <AdsButton :label="primaryLabel" leading trailing />
30
- <AdsButton type="unfilled" :label="secondaryLabel" leading trailing />
31
- </slot>
32
- </div>
33
- </div>
34
- </template>
35
-
36
- <script setup lang="ts">
37
- import AdsButton from "./AdsButton.vue";
38
-
39
- withDefaults(
40
- defineProps<{
41
- title?: string;
42
- subtitle?: string;
43
- /** Figma `Small=Yes`. */
44
- small?: boolean;
45
- showActions?: boolean;
46
- primaryLabel?: string;
47
- secondaryLabel?: string;
48
- }>(),
49
- {
50
- title: "Título do empty state",
51
- subtitle: "Coloque aqui um texto explicando e direcionando o usuário. Uso opcional.",
52
- small: false,
53
- showActions: true,
54
- primaryLabel: "Button Test",
55
- secondaryLabel: "Button Test",
56
- },
57
- );
58
- </script>
1
+ <template>
2
+ <div
3
+ class="flex flex-col items-center text-center"
4
+ :class="small ? 'gap-[var(--ads-empty-gap-sm)]' : 'gap-[var(--ads-empty-gap)]'"
5
+ >
6
+ <svg
7
+ viewBox="0 0 24 24"
8
+ fill="none"
9
+ aria-hidden="true"
10
+ class="text-[var(--ads-empty-icon-color)]"
11
+ :class="small ? 'size-[var(--ads-empty-icon-sm)]' : 'size-[var(--ads-empty-icon)]'"
12
+ >
13
+ <circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.6" />
14
+ <path d="M9 9l6 6M15 9l-6 6" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" />
15
+ </svg>
16
+ <div class="flex max-w-xs flex-col items-center gap-[var(--ads-empty-text-gap)]">
17
+ <p
18
+ class="font-bold leading-[1.3] text-[var(--ads-text-primary)]"
19
+ :class="small ? 'text-[length:var(--ads-empty-title-size-sm)]' : 'text-[length:var(--ads-empty-title-size)]'"
20
+ >
21
+ {{ title }}
22
+ </p>
23
+ <p v-if="subtitle" class="text-[length:var(--ads-empty-subtitle-size)] leading-[1.2] text-[var(--ads-text-secondary)]">
24
+ {{ subtitle }}
25
+ </p>
26
+ </div>
27
+ <div v-if="showActions" class="flex flex-col items-center gap-2">
28
+ <slot>
29
+ <AdsButton :label="primaryLabel" leading trailing />
30
+ <AdsButton type="unfilled" :label="secondaryLabel" leading trailing />
31
+ </slot>
32
+ </div>
33
+ </div>
34
+ </template>
35
+
36
+ <script setup lang="ts">
37
+ import AdsButton from "./AdsButton.vue";
38
+
39
+ withDefaults(
40
+ defineProps<{
41
+ title?: string;
42
+ subtitle?: string;
43
+ /** Figma `Small=Yes`. */
44
+ small?: boolean;
45
+ showActions?: boolean;
46
+ primaryLabel?: string;
47
+ secondaryLabel?: string;
48
+ }>(),
49
+ {
50
+ title: "Título do empty state",
51
+ subtitle: "Coloque aqui um texto explicando e direcionando o usuário. Uso opcional.",
52
+ small: false,
53
+ showActions: true,
54
+ primaryLabel: "Button Test",
55
+ secondaryLabel: "Button Test",
56
+ },
57
+ );
58
+ </script>
@@ -1,219 +1,210 @@
1
- <template>
2
- <component
3
- :is="to ? NuxtLink : 'button'"
4
- v-bind="rootAttrs"
5
- class="group flex w-[var(--ads-feature-width)] max-w-full flex-col gap-[var(--ads-feature-gap)] rounded-[var(--ads-feature-radius)] border border-[var(--ads-feature-border)] bg-[var(--ads-feature-background)] p-[var(--ads-feature-padding)] text-left transition-colors duration-150 ease-out focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-feature-accent-hover)]"
6
- :class="disabled ? 'cursor-not-allowed' : 'hover:border-[var(--ads-feature-accent-hover)] focus-visible:border-[var(--ads-feature-accent-hover)]'"
7
- :style="accentStyle"
8
- @click="onClick"
9
- >
10
- <span class="flex items-start gap-3">
11
- <span
12
- class="grid size-[var(--ads-feature-icon-box)] shrink-0 place-items-center rounded-[var(--ads-radius-sm)]"
13
- :class="iconBoxClass"
14
- >
15
- <UIcon :name="icon" class="size-6" />
16
- </span>
17
- <span class="min-w-0 flex-1">
18
- <span class="block text-[length:var(--ads-feature-title-size)] font-bold leading-[1.3]" :class="titleClass">
19
- {{ title }}
20
- </span>
21
- <AdsTooltip
22
- :description="description"
23
- :show-title="false"
24
- :disabled="!isDescriptionTruncated"
25
- align="start"
26
- >
27
- <span
28
- ref="descriptionEl"
29
- class="mt-1 block line-clamp-2 text-[length:var(--ads-feature-body-size)] leading-relaxed"
30
- :class="descriptionClass"
31
- >
32
- {{ description }}
33
- </span>
34
- </AdsTooltip>
35
- </span>
36
- <UIcon
37
- v-if="!disabled"
38
- name="i-lucide-arrow-right"
39
- class="size-5 shrink-0 text-[var(--ads-border-icon-support)] transition-colors duration-150 ease-out group-hover:text-[var(--ads-feature-accent-hover)] group-focus-visible:text-[var(--ads-feature-accent-hover)]"
40
- />
41
- </span>
42
-
43
- <AdsPill
44
- v-if="disabled"
45
- class="mt-auto"
46
- tone="secondary"
47
- status="neutral"
48
- label="Em breve"
49
- />
50
- <span v-else-if="hasFooter" class="mt-auto flex flex-wrap items-center gap-2">
51
- <AdsPill
52
- v-for="badge in badges"
53
- :key="badge.label"
54
- :tone="badge.tone ?? 'secondary'"
55
- :status="badge.status ?? 'default'"
56
- :label="badge.label"
57
- />
58
- <span
59
- v-if="footerText"
60
- class="inline-flex items-center gap-1 text-xs text-[var(--ads-text-secondary)]"
61
- >
62
- <UIcon v-if="footerIcon" :name="footerIcon" class="size-3.5" />
63
- {{ footerText }}
64
- </span>
65
- </span>
66
- </component>
67
- </template>
68
-
69
- <script setup lang="ts">
70
- import { computed, nextTick, onMounted, ref, watch } from "vue";
71
- import type { RouteLocationRaw } from "vue-router";
72
- import { useResizeObserver } from "@vueuse/core";
73
- import { NuxtLink } from "#components";
74
- import AdsPill from "./AdsPill.vue";
75
- import type { AdsPillStatus, AdsPillTone } from "./AdsPill.vue";
76
- import AdsTooltip from "./AdsTooltip.vue";
77
-
78
- export interface AdsFeatureCardBadge {
79
- label: string;
80
- tone?: AdsPillTone;
81
- status?: AdsPillStatus;
82
- }
83
-
84
- /** Fundo e texto do AdsPill secondary. Primary segue o ícone do próprio card no catálogo. */
85
- export type AdsFeatureCardColor =
86
- | "primary"
87
- | "success"
88
- | "attention"
89
- | "warning"
90
- | "new"
91
- | "blocked"
92
- | "innovation";
93
-
94
- const iconBoxByColor: Record<AdsFeatureCardColor, string> = {
95
- primary: "bg-[var(--ads-button-secondary)] text-[var(--ads-text-brand)]",
96
- success: "bg-[var(--ads-status-success-100)] text-[var(--ads-status-success-800)]",
97
- attention: "bg-[var(--ads-status-attention-100)] text-[var(--ads-status-attention-800)]",
98
- warning: "bg-[var(--ads-status-warning-100)] text-[var(--ads-status-warning-800)]",
99
- new: "bg-[var(--ads-status-new-100)] text-[var(--ads-status-new-800)]",
100
- blocked: "bg-[var(--ads-status-void-100)] text-[var(--ads-status-void-800)]",
101
- innovation: "bg-[var(--ads-status-innovation-100)] text-[var(--ads-status-innovation-800)]",
102
- };
103
-
104
- /**
105
- * Cor de acento usada NO HOVER para borda e seta (ambas a mesma cor).
106
- * Em repouso: borda = --ads-feature-border (neutro), seta = --ads-border-icon-support (cinza).
107
- */
108
- const accentByColor: Record<AdsFeatureCardColor, string> = {
109
- // Hover: borda e seta no passo 500 da mesma escala do card.
110
- primary: "var(--color-primary-500)",
111
- success: "var(--ads-status-success-500)",
112
- attention: "var(--ads-status-attention-500)",
113
- warning: "var(--ads-status-warning-500)",
114
- new: "var(--ads-status-new-500)",
115
- blocked: "var(--ads-status-void-500)",
116
- innovation: "var(--ads-status-innovation-500)",
117
- };
118
-
119
- const props = withDefaults(
120
- defineProps<{
121
- title: string;
122
- description: string;
123
- icon: string;
124
- /** Cor do ícone, da seta e da borda. Sem valor, fica na cor da marca. */
125
- color?: AdsFeatureCardColor;
126
- /** Vira link. Sem valor, continua botão. */
127
- to?: RouteLocationRaw;
128
- disabled?: boolean;
129
- badges?: AdsFeatureCardBadge[];
130
- footerIcon?: string;
131
- footerText?: string;
132
- }>(),
133
- {
134
- color: "primary",
135
- to: undefined,
136
- disabled: false,
137
- badges: undefined,
138
- footerIcon: undefined,
139
- footerText: undefined,
140
- },
141
- );
142
-
143
- const emit = defineEmits<{
144
- click: [event: MouseEvent];
145
- }>();
146
-
147
- const hasFooter = computed(
148
- () => (props.badges?.length ?? 0) > 0 || Boolean(props.footerText),
149
- );
150
-
151
- const descriptionEl = ref<HTMLElement | null>(null);
152
- const isDescriptionTruncated = ref(false);
153
-
154
- const syncDescriptionTruncation = () => {
155
- const element = descriptionEl.value;
156
- if (!element) {
157
- isDescriptionTruncated.value = false;
158
- return;
159
- }
160
- isDescriptionTruncated.value = element.scrollHeight - element.clientHeight > 1;
161
- };
162
-
163
- useResizeObserver(descriptionEl, syncDescriptionTruncation);
164
-
165
- onMounted(() => {
166
- void nextTick(syncDescriptionTruncation);
167
- });
168
-
169
- watch(
170
- () => props.description,
171
- () => {
172
- void nextTick(syncDescriptionTruncation);
173
- },
174
- );
175
-
176
- const rootAttrs = computed(() =>
177
- props.to
178
- ? {
179
- to: props.to,
180
- tabindex: props.disabled ? -1 : undefined,
181
- "aria-disabled": props.disabled || undefined,
182
- }
183
- : {
184
- type: "button" as const,
185
- disabled: props.disabled,
186
- },
187
- );
188
-
189
- const accentStyle = computed(() => {
190
- if (props.disabled) {
191
- return {};
192
- }
193
- return {
194
- "--ads-feature-accent-hover": accentByColor[props.color],
195
- };
196
- });
197
-
198
- const iconBoxClass = computed(() =>
199
- props.disabled
200
- ? "bg-[var(--ads-button-secondary-disabled)] text-[var(--ads-text-tertiary)]"
201
- : iconBoxByColor[props.color],
202
- );
203
-
204
- const titleClass = computed(() =>
205
- props.disabled ? "text-[var(--ads-text-tertiary)]" : "text-[var(--ads-feature-title)]",
206
- );
207
-
208
- const descriptionClass = computed(() =>
209
- props.disabled ? "text-[var(--ads-text-tertiary)]" : "text-[var(--ads-feature-body)]",
210
- );
211
-
212
- const onClick = (event: MouseEvent) => {
213
- if (!props.disabled) {
214
- emit("click", event);
215
- return;
216
- }
217
- event.preventDefault();
218
- };
219
- </script>
1
+ <!--
2
+ AdsFeatureCard — atalho de módulo sobre o AdsCard. A casca (borda, raio, fundo, hover, foco)
3
+ é a do AdsCard; aqui só muda o conteúdo: ícone, título, descrição, seta e rodapé.
4
+ -->
5
+ <template>
6
+ <AdsCard
7
+ :as="to ? NuxtLink : 'button'"
8
+ v-bind="rootAttrs"
9
+ :disabled="disabled"
10
+ :hoverable="hoverable"
11
+ class="group w-[var(--ads-feature-width)] max-w-full"
12
+ :style="cardStyle"
13
+ @click="onClick"
14
+ >
15
+ <span class="flex h-full w-full flex-col gap-[var(--ads-feature-gap)]">
16
+ <span class="flex items-start gap-3">
17
+ <span
18
+ class="grid size-[var(--ads-feature-icon-box)] shrink-0 place-items-center rounded-[var(--ads-radius-sm)]"
19
+ :class="iconBoxClass"
20
+ >
21
+ <UIcon :name="icon" class="size-6" />
22
+ </span>
23
+ <span class="min-w-0 flex-1">
24
+ <span class="block text-[length:var(--ads-feature-title-size)] font-bold leading-[1.3]" :class="titleClass">
25
+ {{ title }}
26
+ </span>
27
+ <AdsTooltip
28
+ :description="description"
29
+ :show-title="false"
30
+ :disabled="!isDescriptionTruncated"
31
+ align="start"
32
+ >
33
+ <span
34
+ ref="descriptionEl"
35
+ class="mt-1 block line-clamp-2 text-[length:var(--ads-feature-body-size)] leading-relaxed"
36
+ :class="descriptionClass"
37
+ >
38
+ {{ description }}
39
+ </span>
40
+ </AdsTooltip>
41
+ </span>
42
+ <UIcon
43
+ v-if="!disabled"
44
+ name="i-lucide-arrow-right"
45
+ class="size-5 shrink-0 text-[var(--ads-border-icon-support)] transition-colors duration-150 ease-out"
46
+ :class="{ 'group-hover:text-[var(--ads-text-secondary)] group-focus-visible:text-[var(--ads-text-secondary)]': hoverable }"
47
+ />
48
+ </span>
49
+
50
+ <AdsPill
51
+ v-if="disabled"
52
+ class="mt-auto self-start"
53
+ tone="secondary"
54
+ status="blocked"
55
+ label="Em breve"
56
+ />
57
+ <span v-else-if="hasFooter" class="mt-auto flex flex-wrap items-center gap-2">
58
+ <AdsPill
59
+ v-for="badge in badges"
60
+ :key="badge.label"
61
+ :tone="badge.tone ?? 'secondary'"
62
+ :status="badge.status ?? 'default'"
63
+ :label="badge.label"
64
+ />
65
+ <span
66
+ v-if="footerText"
67
+ class="inline-flex items-center gap-1 text-xs text-[var(--ads-text-secondary)]"
68
+ >
69
+ <UIcon v-if="footerIcon" :name="footerIcon" class="size-3.5" />
70
+ {{ footerText }}
71
+ </span>
72
+ </span>
73
+ </span>
74
+ </AdsCard>
75
+ </template>
76
+
77
+ <script setup lang="ts">
78
+ import { computed, nextTick, onMounted, ref, watch } from "vue";
79
+ import type { RouteLocationRaw } from "vue-router";
80
+ import { useResizeObserver } from "@vueuse/core";
81
+ import { NuxtLink } from "#components";
82
+ import AdsCard from "./AdsCard.vue";
83
+ import AdsPill from "./AdsPill.vue";
84
+ import type { AdsPillStatus, AdsPillTone } from "./AdsPill.vue";
85
+ import AdsTooltip from "./AdsTooltip.vue";
86
+
87
+ export interface AdsFeatureCardBadge {
88
+ label: string;
89
+ tone?: AdsPillTone;
90
+ status?: AdsPillStatus;
91
+ }
92
+
93
+ /** Fundo e texto do AdsPill secondary. Primary segue o ícone do próprio card no catálogo. */
94
+ export type AdsFeatureCardColor =
95
+ | "primary"
96
+ | "success"
97
+ | "attention"
98
+ | "warning"
99
+ | "new"
100
+ | "blocked"
101
+ | "ai";
102
+
103
+ const iconBoxByColor: Record<AdsFeatureCardColor, string> = {
104
+ primary: "bg-[var(--ads-button-secondary)] text-[var(--ads-text-brand)]",
105
+ success: "bg-[var(--ads-status-success-100)] text-[var(--ads-status-success-800)]",
106
+ attention: "bg-[var(--ads-status-attention-100)] text-[var(--ads-status-attention-800)]",
107
+ warning: "bg-[var(--ads-status-warning-100)] text-[var(--ads-status-warning-800)]",
108
+ new: "bg-[var(--ads-status-new-100)] text-[var(--ads-status-new-800)]",
109
+ blocked: "bg-[var(--ads-status-void-100)] text-[var(--ads-status-void-800)]",
110
+ ai: "bg-[var(--ads-surface-ai)] text-[var(--ads-text-ai)]",
111
+ };
112
+
113
+
114
+ const props = withDefaults(
115
+ defineProps<{
116
+ title: string;
117
+ description: string;
118
+ icon: string;
119
+ /** Cor da caixa do ícone. O hover é o padrão dos cards, igual para todas as cores. */
120
+ color?: AdsFeatureCardColor;
121
+ /** Vira link. Sem valor, continua botão. */
122
+ to?: RouteLocationRaw;
123
+ disabled?: boolean;
124
+ /** Hover padrão dos cards (borda e sombra neutras; a seta escurece). false desliga. */
125
+ hoverable?: boolean;
126
+ badges?: AdsFeatureCardBadge[];
127
+ footerIcon?: string;
128
+ footerText?: string;
129
+ }>(),
130
+ {
131
+ color: "primary",
132
+ to: undefined,
133
+ disabled: false,
134
+ hoverable: true,
135
+ badges: undefined,
136
+ footerIcon: undefined,
137
+ footerText: undefined,
138
+ },
139
+ );
140
+
141
+ const emit = defineEmits<{
142
+ click: [event: MouseEvent];
143
+ }>();
144
+
145
+ const hasFooter = computed(
146
+ () => (props.badges?.length ?? 0) > 0 || Boolean(props.footerText),
147
+ );
148
+
149
+ const descriptionEl = ref<HTMLElement | null>(null);
150
+ const isDescriptionTruncated = ref(false);
151
+
152
+ const syncDescriptionTruncation = () => {
153
+ const element = descriptionEl.value;
154
+ if (!element) {
155
+ isDescriptionTruncated.value = false;
156
+ return;
157
+ }
158
+ isDescriptionTruncated.value = element.scrollHeight - element.clientHeight > 1;
159
+ };
160
+
161
+ useResizeObserver(descriptionEl, syncDescriptionTruncation);
162
+
163
+ onMounted(() => {
164
+ void nextTick(syncDescriptionTruncation);
165
+ });
166
+
167
+ watch(
168
+ () => props.description,
169
+ () => {
170
+ void nextTick(syncDescriptionTruncation);
171
+ },
172
+ );
173
+
174
+ /** O link não tem disabled nativo: sai da ordem do Tab e avisa por aria-disabled. */
175
+ const rootAttrs = computed(() =>
176
+ props.to
177
+ ? { to: props.to, tabindex: props.disabled ? -1 : undefined, "aria-disabled": props.disabled || undefined }
178
+ : {},
179
+ );
180
+
181
+ /**
182
+ * A casca e o hover são os do AdsCard. Aqui só entra o desabilitado sem opacidade,
183
+ * porque o conteúdo já troca para as cores terciárias.
184
+ */
185
+ const cardStyle = computed(() => ({
186
+ "--ads-card-disabled-opacity": "1",
187
+ }));
188
+
189
+ const iconBoxClass = computed(() =>
190
+ props.disabled
191
+ ? "bg-[var(--ads-button-secondary-disabled)] text-[var(--ads-text-tertiary)]"
192
+ : iconBoxByColor[props.color],
193
+ );
194
+
195
+ const titleClass = computed(() =>
196
+ props.disabled ? "text-[var(--ads-text-tertiary)]" : "text-[var(--ads-feature-title)]",
197
+ );
198
+
199
+ const descriptionClass = computed(() =>
200
+ props.disabled ? "text-[var(--ads-text-tertiary)]" : "text-[var(--ads-feature-body)]",
201
+ );
202
+
203
+ const onClick = (event: MouseEvent) => {
204
+ if (!props.disabled) {
205
+ emit("click", event);
206
+ return;
207
+ }
208
+ event.preventDefault();
209
+ };
210
+ </script>