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,39 +1,39 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="inline-flex" role="radiogroup" :aria-label="ariaLabel">
|
|
3
|
-
<button
|
|
4
|
-
v-for="(option, index) in options"
|
|
5
|
-
:key="option.value"
|
|
6
|
-
type="button"
|
|
7
|
-
role="radio"
|
|
8
|
-
class="-ml-px h-[var(--ads-button-group-height)] border border-[var(--ads-button-group-border)] px-4 text-[length:var(--ads-button-group-font-size)] text-[var(--ads-text-primary)] first:ml-0 focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-brand)]"
|
|
9
|
-
:class="[
|
|
10
|
-
index === 0 ? 'rounded-l-[var(--ads-radius-xsm)]' : '',
|
|
11
|
-
index === options.length - 1 ? 'rounded-r-[var(--ads-radius-xsm)]' : '',
|
|
12
|
-
model === option.value ? 'z-[1] bg-[var(--ads-button-group-selected)] font-bold' : 'bg-[var(--ads-surface-card)] font-normal',
|
|
13
|
-
]"
|
|
14
|
-
:aria-checked="model === option.value"
|
|
15
|
-
@click="model = option.value"
|
|
16
|
-
>
|
|
17
|
-
{{ option.label }}
|
|
18
|
-
</button>
|
|
19
|
-
</div>
|
|
20
|
-
</template>
|
|
21
|
-
|
|
22
|
-
<script setup lang="ts">
|
|
23
|
-
export type AdsButtonGroupOption = {
|
|
24
|
-
value: string;
|
|
25
|
-
label: string;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
withDefaults(
|
|
29
|
-
defineProps<{
|
|
30
|
-
options: AdsButtonGroupOption[];
|
|
31
|
-
ariaLabel?: string;
|
|
32
|
-
}>(),
|
|
33
|
-
{
|
|
34
|
-
ariaLabel: "Grupo de botões",
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const model = defineModel<string>({ required: true });
|
|
39
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="inline-flex" role="radiogroup" :aria-label="ariaLabel">
|
|
3
|
+
<button
|
|
4
|
+
v-for="(option, index) in options"
|
|
5
|
+
:key="option.value"
|
|
6
|
+
type="button"
|
|
7
|
+
role="radio"
|
|
8
|
+
class="-ml-px h-[var(--ads-button-group-height)] border border-[var(--ads-button-group-border)] px-4 text-[length:var(--ads-button-group-font-size)] text-[var(--ads-text-primary)] first:ml-0 focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-brand)]"
|
|
9
|
+
:class="[
|
|
10
|
+
index === 0 ? 'rounded-l-[var(--ads-radius-xsm)]' : '',
|
|
11
|
+
index === options.length - 1 ? 'rounded-r-[var(--ads-radius-xsm)]' : '',
|
|
12
|
+
model === option.value ? 'z-[1] bg-[var(--ads-button-group-selected)] font-bold' : 'bg-[var(--ads-surface-card)] font-normal',
|
|
13
|
+
]"
|
|
14
|
+
:aria-checked="model === option.value"
|
|
15
|
+
@click="model = option.value"
|
|
16
|
+
>
|
|
17
|
+
{{ option.label }}
|
|
18
|
+
</button>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
export type AdsButtonGroupOption = {
|
|
24
|
+
value: string;
|
|
25
|
+
label: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
withDefaults(
|
|
29
|
+
defineProps<{
|
|
30
|
+
options: AdsButtonGroupOption[];
|
|
31
|
+
ariaLabel?: string;
|
|
32
|
+
}>(),
|
|
33
|
+
{
|
|
34
|
+
ariaLabel: "Grupo de botões",
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const model = defineModel<string>({ required: true });
|
|
39
|
+
</script>
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="flex w-[var(--ads-button-menu-width)] flex-col overflow-hidden rounded-[var(--ads-radius-xsm)] bg-[var(--ads-surface-card)] shadow-[var(--ads-shadow-level-1)]"
|
|
4
|
-
role="menu"
|
|
5
|
-
>
|
|
6
|
-
<button
|
|
7
|
-
v-for="option in options"
|
|
8
|
-
:key="option.value"
|
|
9
|
-
type="button"
|
|
10
|
-
role="menuitem"
|
|
11
|
-
class="flex flex-col border-b-[0.5px] border-[var(--ads-button-menu-border)] px-4 pt-2 pb-4 text-left last:border-b-0 hover:bg-ads-neutro-claro-20 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[var(--ads-text-brand)]"
|
|
12
|
-
@click="emit('select', option.value)"
|
|
13
|
-
>
|
|
14
|
-
<span class="flex h-10 items-center gap-2 px-4 text-[length:var(--ads-button-menu-title-size)] leading-[1.3] font-medium text-[var(--ads-button-menu-title)]">
|
|
15
|
-
<UIcon v-if="showIcons" :name="option.icon || 'i-lucide-sparkles'" class="size-4 shrink-0" />
|
|
16
|
-
{{ option.title }}
|
|
17
|
-
</span>
|
|
18
|
-
<span v-if="showSubtitles && option.subtitle" class="line-clamp-2 px-4 text-[length:var(--ads-button-menu-subtitle-size)] leading-[1.2] text-[var(--ads-button-menu-subtitle)]">
|
|
19
|
-
{{ option.subtitle }}
|
|
20
|
-
</span>
|
|
21
|
-
</button>
|
|
22
|
-
</div>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
|
-
<script setup lang="ts">
|
|
26
|
-
export type AdsButtonMenuOption = {
|
|
27
|
-
value: string;
|
|
28
|
-
title: string;
|
|
29
|
-
subtitle?: string;
|
|
30
|
-
icon?: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
withDefaults(
|
|
34
|
-
defineProps<{
|
|
35
|
-
options: AdsButtonMenuOption[];
|
|
36
|
-
showSubtitles?: boolean;
|
|
37
|
-
showIcons?: boolean;
|
|
38
|
-
}>(),
|
|
39
|
-
{
|
|
40
|
-
showSubtitles: true,
|
|
41
|
-
showIcons: true,
|
|
42
|
-
},
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const emit = defineEmits<{
|
|
46
|
-
select: [value: string];
|
|
47
|
-
}>();
|
|
48
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="flex w-[var(--ads-button-menu-width)] flex-col overflow-hidden rounded-[var(--ads-radius-xsm)] bg-[var(--ads-surface-card)] shadow-[var(--ads-shadow-level-1)]"
|
|
4
|
+
role="menu"
|
|
5
|
+
>
|
|
6
|
+
<button
|
|
7
|
+
v-for="option in options"
|
|
8
|
+
:key="option.value"
|
|
9
|
+
type="button"
|
|
10
|
+
role="menuitem"
|
|
11
|
+
class="flex flex-col border-b-[0.5px] border-[var(--ads-button-menu-border)] px-4 pt-2 pb-4 text-left last:border-b-0 hover:bg-ads-neutro-claro-20 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[var(--ads-text-brand)]"
|
|
12
|
+
@click="emit('select', option.value)"
|
|
13
|
+
>
|
|
14
|
+
<span class="flex h-10 items-center gap-2 px-4 text-[length:var(--ads-button-menu-title-size)] leading-[1.3] font-medium text-[var(--ads-button-menu-title)]">
|
|
15
|
+
<UIcon v-if="showIcons" :name="option.icon || 'i-lucide-sparkles'" class="size-4 shrink-0" />
|
|
16
|
+
{{ option.title }}
|
|
17
|
+
</span>
|
|
18
|
+
<span v-if="showSubtitles && option.subtitle" class="line-clamp-2 px-4 text-[length:var(--ads-button-menu-subtitle-size)] leading-[1.2] text-[var(--ads-button-menu-subtitle)]">
|
|
19
|
+
{{ option.subtitle }}
|
|
20
|
+
</span>
|
|
21
|
+
</button>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
export type AdsButtonMenuOption = {
|
|
27
|
+
value: string;
|
|
28
|
+
title: string;
|
|
29
|
+
subtitle?: string;
|
|
30
|
+
icon?: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
withDefaults(
|
|
34
|
+
defineProps<{
|
|
35
|
+
options: AdsButtonMenuOption[];
|
|
36
|
+
showSubtitles?: boolean;
|
|
37
|
+
showIcons?: boolean;
|
|
38
|
+
}>(),
|
|
39
|
+
{
|
|
40
|
+
showSubtitles: true,
|
|
41
|
+
showIcons: true,
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const emit = defineEmits<{
|
|
46
|
+
select: [value: string];
|
|
47
|
+
}>();
|
|
48
|
+
</script>
|
|
@@ -1,188 +1,188 @@
|
|
|
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 flex-col items-start gap-3 border p-[var(--ads-card-padding)] text-left transition-[background-color,border-color,box-shadow]"
|
|
8
|
-
:class="[radiusClass, surfaceClass]"
|
|
9
|
-
>
|
|
10
|
-
<!-- Cabeçalho -->
|
|
11
|
-
<div v-if="showHeader" class="flex w-full min-w-0 items-center gap-2">
|
|
12
|
-
<div class="min-w-0 flex-1">
|
|
13
|
-
<slot name="header">
|
|
14
|
-
<p :class="type === 'details' ? detailsTitleClass : containerTitleClass">{{ title }}</p>
|
|
15
|
-
</slot>
|
|
16
|
-
</div>
|
|
17
|
-
<AdsCardHint v-if="hint" :text="hint" />
|
|
18
|
-
<slot name="actions" />
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
<AdsCardPeriod v-if="period || (loading && periodLabel && type === 'container')" :label="periodLabel" :value="period" :loading="loading" :skeleton-width="110" />
|
|
22
|
-
|
|
23
|
-
<p v-if="description && !loading && !empty" class="text-[length:var(--ads-card-body-size)] leading-[1.4] text-[var(--ads-card-body)]">
|
|
24
|
-
{{ description }}
|
|
25
|
-
</p>
|
|
26
|
-
|
|
27
|
-
<!-- Vazio: mantém o cabeçalho e mostra o empty state -->
|
|
28
|
-
<div v-if="empty && !loading" class="flex w-full justify-center py-2">
|
|
29
|
-
<slot name="empty">
|
|
30
|
-
<AdsEmptyState small :title="emptyMessage" :subtitle="emptyDescription ?? ''" :show-actions="Boolean($slots['empty-actions'])">
|
|
31
|
-
<slot name="empty-actions" />
|
|
32
|
-
</AdsEmptyState>
|
|
33
|
-
</slot>
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<!-- Detalhes: lista de informações -->
|
|
37
|
-
<template v-else-if="type === 'details'">
|
|
38
|
-
<div v-if="loading" class="flex w-full flex-col items-start gap-3" aria-hidden="true">
|
|
39
|
-
<span
|
|
40
|
-
v-for="(width, index) in detailSkeletonWidths"
|
|
41
|
-
:key="index"
|
|
42
|
-
class="block h-3.5 max-w-full animate-pulse rounded-[var(--ads-radius-xsm)] bg-[var(--ads-loading-skeleton)] motion-reduce:animate-none"
|
|
43
|
-
:style="{ width: `${width}px` }"
|
|
44
|
-
/>
|
|
45
|
-
</div>
|
|
46
|
-
<dl v-else-if="rows.length" class="flex w-full flex-col items-start gap-3">
|
|
47
|
-
<div v-for="(row, index) in rows" :key="index" class="flex min-w-0 max-w-full items-center gap-1 text-[length:var(--ads-font-size-xxxs)] leading-[1.2] text-[var(--ads-text-secondary)]">
|
|
48
|
-
<UIcon v-if="row.icon" :name="row.icon" class="size-4 shrink-0" aria-hidden="true" />
|
|
49
|
-
<dt class="shrink-0 font-bold">{{ row.label }}</dt>
|
|
50
|
-
<dd class="min-w-0 truncate">{{ row.value }}</dd>
|
|
51
|
-
</div>
|
|
52
|
-
</dl>
|
|
53
|
-
<slot />
|
|
54
|
-
</template>
|
|
55
|
-
|
|
56
|
-
<!-- Container: conteúdo livre (gráfico, tabela, lista) -->
|
|
57
|
-
<template v-else>
|
|
58
|
-
<div v-if="loading" class="flex h-[200px] w-full items-center justify-center">
|
|
59
|
-
<AdsLoading variant="logo" />
|
|
60
|
-
</div>
|
|
61
|
-
<div v-else-if="$slots.default" class="w-full min-w-0 flex-1">
|
|
62
|
-
<slot />
|
|
63
|
-
</div>
|
|
64
|
-
</template>
|
|
65
|
-
|
|
66
|
-
<div v-if="(footerText || $slots.footer) && !loading && !empty" class="flex w-full flex-wrap items-start justify-between gap-3">
|
|
67
|
-
<slot name="footer">
|
|
68
|
-
<p class="text-[length:var(--ads-font-size-xxxs)] text-[var(--ads-text-secondary)]">{{ footerText }}</p>
|
|
69
|
-
</slot>
|
|
70
|
-
</div>
|
|
71
|
-
</component>
|
|
72
|
-
</template>
|
|
73
|
-
|
|
74
|
-
<script setup lang="ts">
|
|
75
|
-
import { computed, useSlots, type Component } from "vue";
|
|
76
|
-
import AdsCardHint from "./AdsCardHint.vue";
|
|
77
|
-
import AdsCardPeriod from "./AdsCardPeriod.vue";
|
|
78
|
-
import AdsEmptyState from "./AdsEmptyState.vue";
|
|
79
|
-
import AdsLoading from "./AdsLoading.vue";
|
|
80
|
-
|
|
81
|
-
export type AdsCardType = "container" | "details";
|
|
82
|
-
|
|
83
|
-
export interface AdsCardRow {
|
|
84
|
-
/** Ícone Lucide de 16px. */
|
|
85
|
-
icon?: string;
|
|
86
|
-
/** Rótulo em negrito, como "Criado em:". */
|
|
87
|
-
label: string;
|
|
88
|
-
value: string;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const props = withDefaults(
|
|
92
|
-
defineProps<{
|
|
93
|
-
/**
|
|
94
|
-
* container: título, período e conteúdo livre no slot padrão.
|
|
95
|
-
* details: título maior e lista de informações (rows).
|
|
96
|
-
*/
|
|
97
|
-
type?: AdsCardType;
|
|
98
|
-
/** O slot header substitui. */
|
|
99
|
-
title?: string;
|
|
100
|
-
/** Texto do ícone de informação ao lado do título. */
|
|
101
|
-
hint?: string;
|
|
102
|
-
/** Datas do período, como "01/12/2023 - 20/12/2023". */
|
|
103
|
-
period?: string;
|
|
104
|
-
periodLabel?: string;
|
|
105
|
-
/** Linhas do card Detalhes. */
|
|
106
|
-
rows?: AdsCardRow[];
|
|
107
|
-
/** Texto de apoio abaixo do cabeçalho. Só no código: o Figma não tem. */
|
|
108
|
-
description?: string;
|
|
109
|
-
/** Linha curta no rodapé. O slot footer substitui. Só no código: o Figma não tem. */
|
|
110
|
-
footerText?: string;
|
|
111
|
-
/**
|
|
112
|
-
* `button` quando o cartão é a própria ação. Também aceita um componente de link
|
|
113
|
-
* (como NuxtLink, com `to` passado direto no card): fica clicável como o botão.
|
|
114
|
-
*/
|
|
115
|
-
as?: "div" | "button" | Component;
|
|
116
|
-
disabled?: boolean;
|
|
117
|
-
/** Hover padrão dos cards clicáveis: borda cinza mais escura e sombra leve. false desliga. */
|
|
118
|
-
hoverable?: boolean;
|
|
119
|
-
/** Estado Selecionado: fundo azul claro, borda azul e sombra. */
|
|
120
|
-
selected?: boolean;
|
|
121
|
-
/** `md` (12px) é o do Figma; `sm` (8px) é só no código. */
|
|
122
|
-
radius?: "sm" | "md";
|
|
123
|
-
/** Estado Carregando: no container, o loader do Radar; no details, skeleton nas linhas. */
|
|
124
|
-
loading?: boolean;
|
|
125
|
-
/** Estado Vazio: mantém o cabeçalho e mostra o empty state. */
|
|
126
|
-
empty?: boolean;
|
|
127
|
-
emptyMessage?: string;
|
|
128
|
-
emptyDescription?: string;
|
|
129
|
-
}>(),
|
|
130
|
-
{
|
|
131
|
-
type: "container",
|
|
132
|
-
title: undefined,
|
|
133
|
-
hint: undefined,
|
|
134
|
-
period: undefined,
|
|
135
|
-
periodLabel: "Período:",
|
|
136
|
-
rows: () => [],
|
|
137
|
-
description: undefined,
|
|
138
|
-
footerText: undefined,
|
|
139
|
-
as: "div",
|
|
140
|
-
disabled: false,
|
|
141
|
-
hoverable: true,
|
|
142
|
-
selected: false,
|
|
143
|
-
radius: "md",
|
|
144
|
-
loading: false,
|
|
145
|
-
empty: false,
|
|
146
|
-
emptyMessage: "Sem dados no período",
|
|
147
|
-
emptyDescription: undefined,
|
|
148
|
-
},
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
const slots = useSlots();
|
|
152
|
-
|
|
153
|
-
const containerTitleClass = "text-[length:var(--ads-font-size-xs)] leading-[1.3] text-[var(--ads-card-title)]";
|
|
154
|
-
const detailsTitleClass = "text-[length:var(--ads-font-size-rg)] font-bold leading-[1.3] text-[var(--ads-card-title)]";
|
|
155
|
-
|
|
156
|
-
/** Larguras do skeleton do Figma; uma barra por linha. */
|
|
157
|
-
const SKELETON_WIDTHS = [200, 240, 160, 180, 260];
|
|
158
|
-
const detailSkeletonWidths = computed(() => {
|
|
159
|
-
const count = props.rows.length || SKELETON_WIDTHS.length;
|
|
160
|
-
return Array.from({ length: count }, (_, index) => SKELETON_WIDTHS[index % SKELETON_WIDTHS.length]);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
const showHeader = computed(() => Boolean(props.title || props.hint || slots.header || slots.actions));
|
|
164
|
-
|
|
165
|
-
const radiusClass = computed(() =>
|
|
166
|
-
props.radius === "sm" ? "rounded-[var(--ads-card-radius-sm)]" : "rounded-[var(--ads-card-radius)]",
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
const surfaceClass = computed(() => {
|
|
170
|
-
const classes = [
|
|
171
|
-
props.selected
|
|
172
|
-
? "border-[var(--ads-card-selected-border)] bg-[var(--ads-card-selected-background)] shadow-[var(--ads-shadow-level-1)]"
|
|
173
|
-
: "border-[var(--ads-card-border)] bg-[var(--ads-card-background)]",
|
|
174
|
-
];
|
|
175
|
-
|
|
176
|
-
if (props.as !== "div") {
|
|
177
|
-
classes.push(
|
|
178
|
-
"cursor-pointer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-border-focused)] disabled:cursor-not-allowed disabled:opacity-[var(--ads-card-disabled-opacity,0.5)] aria-disabled:cursor-not-allowed",
|
|
179
|
-
);
|
|
180
|
-
// Hover padrão de todos os cards clicáveis: neutro, borda cinza mais escura e sombra leve.
|
|
181
|
-
if (props.hoverable && !props.selected && !props.disabled) {
|
|
182
|
-
classes.push("hover:border-[var(--ads-card-hover-border)] hover:shadow-[var(--ads-shadow-level-1)]");
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return classes;
|
|
187
|
-
});
|
|
188
|
-
</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 flex-col items-start gap-3 border p-[var(--ads-card-padding)] text-left transition-[background-color,border-color,box-shadow]"
|
|
8
|
+
:class="[radiusClass, surfaceClass]"
|
|
9
|
+
>
|
|
10
|
+
<!-- Cabeçalho -->
|
|
11
|
+
<div v-if="showHeader" class="flex w-full min-w-0 items-center gap-2">
|
|
12
|
+
<div class="min-w-0 flex-1">
|
|
13
|
+
<slot name="header">
|
|
14
|
+
<p :class="type === 'details' ? detailsTitleClass : containerTitleClass">{{ title }}</p>
|
|
15
|
+
</slot>
|
|
16
|
+
</div>
|
|
17
|
+
<AdsCardHint v-if="hint" :text="hint" />
|
|
18
|
+
<slot name="actions" />
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<AdsCardPeriod v-if="period || (loading && periodLabel && type === 'container')" :label="periodLabel" :value="period" :loading="loading" :skeleton-width="110" />
|
|
22
|
+
|
|
23
|
+
<p v-if="description && !loading && !empty" class="text-[length:var(--ads-card-body-size)] leading-[1.4] text-[var(--ads-card-body)]">
|
|
24
|
+
{{ description }}
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
<!-- Vazio: mantém o cabeçalho e mostra o empty state -->
|
|
28
|
+
<div v-if="empty && !loading" class="flex w-full justify-center py-2">
|
|
29
|
+
<slot name="empty">
|
|
30
|
+
<AdsEmptyState small :title="emptyMessage" :subtitle="emptyDescription ?? ''" :show-actions="Boolean($slots['empty-actions'])">
|
|
31
|
+
<slot name="empty-actions" />
|
|
32
|
+
</AdsEmptyState>
|
|
33
|
+
</slot>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<!-- Detalhes: lista de informações -->
|
|
37
|
+
<template v-else-if="type === 'details'">
|
|
38
|
+
<div v-if="loading" class="flex w-full flex-col items-start gap-3" aria-hidden="true">
|
|
39
|
+
<span
|
|
40
|
+
v-for="(width, index) in detailSkeletonWidths"
|
|
41
|
+
:key="index"
|
|
42
|
+
class="block h-3.5 max-w-full animate-pulse rounded-[var(--ads-radius-xsm)] bg-[var(--ads-loading-skeleton)] motion-reduce:animate-none"
|
|
43
|
+
:style="{ width: `${width}px` }"
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
<dl v-else-if="rows.length" class="flex w-full flex-col items-start gap-3">
|
|
47
|
+
<div v-for="(row, index) in rows" :key="index" class="flex min-w-0 max-w-full items-center gap-1 text-[length:var(--ads-font-size-xxxs)] leading-[1.2] text-[var(--ads-text-secondary)]">
|
|
48
|
+
<UIcon v-if="row.icon" :name="row.icon" class="size-4 shrink-0" aria-hidden="true" />
|
|
49
|
+
<dt class="shrink-0 font-bold">{{ row.label }}</dt>
|
|
50
|
+
<dd class="min-w-0 truncate">{{ row.value }}</dd>
|
|
51
|
+
</div>
|
|
52
|
+
</dl>
|
|
53
|
+
<slot />
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<!-- Container: conteúdo livre (gráfico, tabela, lista) -->
|
|
57
|
+
<template v-else>
|
|
58
|
+
<div v-if="loading" class="flex h-[200px] w-full items-center justify-center">
|
|
59
|
+
<AdsLoading variant="logo" />
|
|
60
|
+
</div>
|
|
61
|
+
<div v-else-if="$slots.default" class="w-full min-w-0 flex-1">
|
|
62
|
+
<slot />
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<div v-if="(footerText || $slots.footer) && !loading && !empty" class="flex w-full flex-wrap items-start justify-between gap-3">
|
|
67
|
+
<slot name="footer">
|
|
68
|
+
<p class="text-[length:var(--ads-font-size-xxxs)] text-[var(--ads-text-secondary)]">{{ footerText }}</p>
|
|
69
|
+
</slot>
|
|
70
|
+
</div>
|
|
71
|
+
</component>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script setup lang="ts">
|
|
75
|
+
import { computed, useSlots, type Component } from "vue";
|
|
76
|
+
import AdsCardHint from "./AdsCardHint.vue";
|
|
77
|
+
import AdsCardPeriod from "./AdsCardPeriod.vue";
|
|
78
|
+
import AdsEmptyState from "./AdsEmptyState.vue";
|
|
79
|
+
import AdsLoading from "./AdsLoading.vue";
|
|
80
|
+
|
|
81
|
+
export type AdsCardType = "container" | "details";
|
|
82
|
+
|
|
83
|
+
export interface AdsCardRow {
|
|
84
|
+
/** Ícone Lucide de 16px. */
|
|
85
|
+
icon?: string;
|
|
86
|
+
/** Rótulo em negrito, como "Criado em:". */
|
|
87
|
+
label: string;
|
|
88
|
+
value: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const props = withDefaults(
|
|
92
|
+
defineProps<{
|
|
93
|
+
/**
|
|
94
|
+
* container: título, período e conteúdo livre no slot padrão.
|
|
95
|
+
* details: título maior e lista de informações (rows).
|
|
96
|
+
*/
|
|
97
|
+
type?: AdsCardType;
|
|
98
|
+
/** O slot header substitui. */
|
|
99
|
+
title?: string;
|
|
100
|
+
/** Texto do ícone de informação ao lado do título. */
|
|
101
|
+
hint?: string;
|
|
102
|
+
/** Datas do período, como "01/12/2023 - 20/12/2023". */
|
|
103
|
+
period?: string;
|
|
104
|
+
periodLabel?: string;
|
|
105
|
+
/** Linhas do card Detalhes. */
|
|
106
|
+
rows?: AdsCardRow[];
|
|
107
|
+
/** Texto de apoio abaixo do cabeçalho. Só no código: o Figma não tem. */
|
|
108
|
+
description?: string;
|
|
109
|
+
/** Linha curta no rodapé. O slot footer substitui. Só no código: o Figma não tem. */
|
|
110
|
+
footerText?: string;
|
|
111
|
+
/**
|
|
112
|
+
* `button` quando o cartão é a própria ação. Também aceita um componente de link
|
|
113
|
+
* (como NuxtLink, com `to` passado direto no card): fica clicável como o botão.
|
|
114
|
+
*/
|
|
115
|
+
as?: "div" | "button" | Component;
|
|
116
|
+
disabled?: boolean;
|
|
117
|
+
/** Hover padrão dos cards clicáveis: borda cinza mais escura e sombra leve. false desliga. */
|
|
118
|
+
hoverable?: boolean;
|
|
119
|
+
/** Estado Selecionado: fundo azul claro, borda azul e sombra. */
|
|
120
|
+
selected?: boolean;
|
|
121
|
+
/** `md` (12px) é o do Figma; `sm` (8px) é só no código. */
|
|
122
|
+
radius?: "sm" | "md";
|
|
123
|
+
/** Estado Carregando: no container, o loader do Radar; no details, skeleton nas linhas. */
|
|
124
|
+
loading?: boolean;
|
|
125
|
+
/** Estado Vazio: mantém o cabeçalho e mostra o empty state. */
|
|
126
|
+
empty?: boolean;
|
|
127
|
+
emptyMessage?: string;
|
|
128
|
+
emptyDescription?: string;
|
|
129
|
+
}>(),
|
|
130
|
+
{
|
|
131
|
+
type: "container",
|
|
132
|
+
title: undefined,
|
|
133
|
+
hint: undefined,
|
|
134
|
+
period: undefined,
|
|
135
|
+
periodLabel: "Período:",
|
|
136
|
+
rows: () => [],
|
|
137
|
+
description: undefined,
|
|
138
|
+
footerText: undefined,
|
|
139
|
+
as: "div",
|
|
140
|
+
disabled: false,
|
|
141
|
+
hoverable: true,
|
|
142
|
+
selected: false,
|
|
143
|
+
radius: "md",
|
|
144
|
+
loading: false,
|
|
145
|
+
empty: false,
|
|
146
|
+
emptyMessage: "Sem dados no período",
|
|
147
|
+
emptyDescription: undefined,
|
|
148
|
+
},
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const slots = useSlots();
|
|
152
|
+
|
|
153
|
+
const containerTitleClass = "text-[length:var(--ads-font-size-xs)] leading-[1.3] text-[var(--ads-card-title)]";
|
|
154
|
+
const detailsTitleClass = "text-[length:var(--ads-font-size-rg)] font-bold leading-[1.3] text-[var(--ads-card-title)]";
|
|
155
|
+
|
|
156
|
+
/** Larguras do skeleton do Figma; uma barra por linha. */
|
|
157
|
+
const SKELETON_WIDTHS = [200, 240, 160, 180, 260];
|
|
158
|
+
const detailSkeletonWidths = computed(() => {
|
|
159
|
+
const count = props.rows.length || SKELETON_WIDTHS.length;
|
|
160
|
+
return Array.from({ length: count }, (_, index) => SKELETON_WIDTHS[index % SKELETON_WIDTHS.length]);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const showHeader = computed(() => Boolean(props.title || props.hint || slots.header || slots.actions));
|
|
164
|
+
|
|
165
|
+
const radiusClass = computed(() =>
|
|
166
|
+
props.radius === "sm" ? "rounded-[var(--ads-card-radius-sm)]" : "rounded-[var(--ads-card-radius)]",
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
const surfaceClass = computed(() => {
|
|
170
|
+
const classes = [
|
|
171
|
+
props.selected
|
|
172
|
+
? "border-[var(--ads-card-selected-border)] bg-[var(--ads-card-selected-background)] shadow-[var(--ads-shadow-level-1)]"
|
|
173
|
+
: "border-[var(--ads-card-border)] bg-[var(--ads-card-background)]",
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
if (props.as !== "div") {
|
|
177
|
+
classes.push(
|
|
178
|
+
"cursor-pointer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-border-focused)] disabled:cursor-not-allowed disabled:opacity-[var(--ads-card-disabled-opacity,0.5)] aria-disabled:cursor-not-allowed",
|
|
179
|
+
);
|
|
180
|
+
// Hover padrão de todos os cards clicáveis: neutro, borda cinza mais escura e sombra leve.
|
|
181
|
+
if (props.hoverable && !props.selected && !props.disabled) {
|
|
182
|
+
classes.push("hover:border-[var(--ads-card-hover-border)] hover:shadow-[var(--ads-shadow-level-1)]");
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return classes;
|
|
187
|
+
});
|
|
188
|
+
</script>
|
|
@@ -1,22 +1,56 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
</
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<span class="inline-flex shrink-0" :class="align === 'end' ? 'order-last ml-auto' : undefined">
|
|
3
|
+
<AdsTooltip :description="text" :show-title="false" class="inline-flex">
|
|
4
|
+
<!-- span focável, e não button: o card inteiro pode ser um botão -->
|
|
5
|
+
<span
|
|
6
|
+
tabindex="0"
|
|
7
|
+
role="img"
|
|
8
|
+
class="inline-flex size-4 items-center justify-center rounded-[var(--ads-radius-circular)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-border-focused)]"
|
|
9
|
+
:class="colorClass"
|
|
10
|
+
:aria-label="text"
|
|
11
|
+
>
|
|
12
|
+
<UIcon :name="icon" class="size-4" aria-hidden="true" />
|
|
13
|
+
</span>
|
|
14
|
+
</AdsTooltip>
|
|
15
|
+
</span>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { computed } from "vue";
|
|
20
|
+
import AdsTooltip from "./AdsTooltip.vue";
|
|
21
|
+
|
|
22
|
+
/** Cor do ícone do balão. `secondary` é o cinza do Figma. */
|
|
23
|
+
export type AdsCardHintColor = "secondary" | "primary" | "brand" | "success" | "attention" | "warning" | "new" | "ai";
|
|
24
|
+
|
|
25
|
+
/** `start` fica junto do título. `end` encosta no fim da linha, à direita. */
|
|
26
|
+
export type AdsCardHintAlign = "start" | "end";
|
|
27
|
+
|
|
28
|
+
const props = withDefaults(
|
|
29
|
+
defineProps<{
|
|
30
|
+
/** Texto do balão. Também nomeia o ícone para leitor de tela. */
|
|
31
|
+
text: string;
|
|
32
|
+
/** Ícone Lucide. Padrão: informação. */
|
|
33
|
+
icon?: string;
|
|
34
|
+
color?: AdsCardHintColor;
|
|
35
|
+
align?: AdsCardHintAlign;
|
|
36
|
+
}>(),
|
|
37
|
+
{
|
|
38
|
+
icon: "i-lucide-info",
|
|
39
|
+
color: "secondary",
|
|
40
|
+
align: "start",
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const colorClasses: Record<AdsCardHintColor, string> = {
|
|
45
|
+
secondary: "text-[var(--ads-text-secondary)]",
|
|
46
|
+
primary: "text-[var(--ads-text-primary)]",
|
|
47
|
+
brand: "text-[var(--ads-text-brand)]",
|
|
48
|
+
success: "text-[var(--ads-status-success-800)]",
|
|
49
|
+
attention: "text-[var(--ads-status-attention-800)]",
|
|
50
|
+
warning: "text-[var(--ads-status-warning-800)]",
|
|
51
|
+
new: "text-[var(--ads-status-new-800)]",
|
|
52
|
+
ai: "text-[var(--ads-text-ai)]",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const colorClass = computed(() => colorClasses[props.color]);
|
|
56
|
+
</script>
|