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,176 +1,172 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<UTable
|
|
3
|
-
:key="virtualize ? 'virtual' : 'static'"
|
|
4
|
-
:data="data"
|
|
5
|
-
:columns="columns"
|
|
6
|
-
:loading="loading"
|
|
7
|
-
:sticky="sticky"
|
|
8
|
-
:virtualize="virtualizeOptions"
|
|
9
|
-
:ui="tableUi"
|
|
10
|
-
>
|
|
11
|
-
<template v-if="!$slots.loading" #loading>
|
|
12
|
-
<AdsTableSkeleton
|
|
13
|
-
:rows="skeletonRows"
|
|
14
|
-
:variant="skeletonVariant"
|
|
15
|
-
:columns="skeletonColumns"
|
|
16
|
-
:cell-class="skeletonCellSize ?? adsTableCellSize(density)"
|
|
17
|
-
/>
|
|
18
|
-
</template>
|
|
19
|
-
|
|
20
|
-
<template v-if="!$slots.empty" #empty>
|
|
21
|
-
<div class="flex flex-col items-center gap-2">
|
|
22
|
-
<UIcon
|
|
23
|
-
:name="emptyIcon"
|
|
24
|
-
class="size-6 text-[var(--ads-border-icon-support)]"
|
|
25
|
-
aria-hidden="true"
|
|
26
|
-
/>
|
|
27
|
-
<p class="text-sm text-[var(--ads-text-secondary)]">{{ emptyLabel }}</p>
|
|
28
|
-
</div>
|
|
29
|
-
</template>
|
|
30
|
-
|
|
31
|
-
<template v-for="(_, name) in $slots" #[name]="slotProps">
|
|
32
|
-
<slot :name="name" v-bind="slotProps ?? {}" />
|
|
33
|
-
</template>
|
|
34
|
-
</UTable>
|
|
35
|
-
</template>
|
|
36
|
-
|
|
37
|
-
<script setup lang="ts" generic="T extends TableData">
|
|
38
|
-
import { computed, useAttrs, useSlots } from "vue";
|
|
39
|
-
import type { TableColumn, TableData } from "@nuxt/ui";
|
|
40
|
-
import AdsTableSkeleton, {
|
|
41
|
-
type AdsTableSkeletonAlign,
|
|
42
|
-
type AdsTableSkeletonVariant,
|
|
43
|
-
} from "./AdsTableSkeleton.vue";
|
|
44
|
-
import {
|
|
45
|
-
adsTableCellSize,
|
|
46
|
-
buildAdsTableUi,
|
|
47
|
-
|
|
48
|
-
type
|
|
49
|
-
type
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
depth
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
*
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
*
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (
|
|
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
|
-
base.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
return merged;
|
|
175
|
-
});
|
|
176
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<UTable
|
|
3
|
+
:key="virtualize ? 'virtual' : 'static'"
|
|
4
|
+
:data="data"
|
|
5
|
+
:columns="columns"
|
|
6
|
+
:loading="loading"
|
|
7
|
+
:sticky="sticky"
|
|
8
|
+
:virtualize="virtualizeOptions"
|
|
9
|
+
:ui="tableUi"
|
|
10
|
+
>
|
|
11
|
+
<template v-if="!$slots.loading" #loading>
|
|
12
|
+
<AdsTableSkeleton
|
|
13
|
+
:rows="skeletonRows"
|
|
14
|
+
:variant="skeletonVariant"
|
|
15
|
+
:columns="skeletonColumns"
|
|
16
|
+
:cell-class="skeletonCellSize ?? adsTableCellSize(density)"
|
|
17
|
+
/>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<template v-if="!$slots.empty" #empty>
|
|
21
|
+
<div class="flex flex-col items-center gap-2">
|
|
22
|
+
<UIcon
|
|
23
|
+
:name="emptyIcon"
|
|
24
|
+
class="size-6 text-[var(--ads-border-icon-support)]"
|
|
25
|
+
aria-hidden="true"
|
|
26
|
+
/>
|
|
27
|
+
<p class="text-sm text-[var(--ads-text-secondary)]">{{ emptyLabel }}</p>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<template v-for="(_, name) in $slots" #[name]="slotProps">
|
|
32
|
+
<slot :name="name" v-bind="slotProps ?? {}" />
|
|
33
|
+
</template>
|
|
34
|
+
</UTable>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script setup lang="ts" generic="T extends TableData">
|
|
38
|
+
import { computed, useAttrs, useSlots } from "vue";
|
|
39
|
+
import type { TableColumn, TableData } from "@nuxt/ui";
|
|
40
|
+
import AdsTableSkeleton, {
|
|
41
|
+
type AdsTableSkeletonAlign,
|
|
42
|
+
type AdsTableSkeletonVariant,
|
|
43
|
+
} from "./AdsTableSkeleton.vue";
|
|
44
|
+
import {
|
|
45
|
+
adsTableCellSize,
|
|
46
|
+
buildAdsTableUi,
|
|
47
|
+
mergeAdsTableUi,
|
|
48
|
+
type AdsTableBorders,
|
|
49
|
+
type AdsTableDensity,
|
|
50
|
+
type AdsTableUi,
|
|
51
|
+
} from "../utils/ads-table";
|
|
52
|
+
|
|
53
|
+
const props = withDefaults(
|
|
54
|
+
defineProps<{
|
|
55
|
+
data: T[];
|
|
56
|
+
columns: TableColumn<T>[];
|
|
57
|
+
/** md: lista e gestão. sm: grade de dados larga ou prévia. */
|
|
58
|
+
density?: AdsTableDensity;
|
|
59
|
+
/** Zebra só em grade numérica larga. */
|
|
60
|
+
striped?: boolean;
|
|
61
|
+
/** Borda e raio próprios. Dentro de AdsCard, false. */
|
|
62
|
+
framed?: boolean;
|
|
63
|
+
/** lines: só horizontal. grid: horizontal e vertical. */
|
|
64
|
+
borders?: AdsTableBorders;
|
|
65
|
+
/** Degradê por nível. A célula marca `data-depth` de 0 a 2. */
|
|
66
|
+
depth?: boolean;
|
|
67
|
+
loading?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Número de linhas do skeleton de carregamento (1–8).
|
|
70
|
+
* Passado para o AdsTableSkeleton no slot #loading padrão.
|
|
71
|
+
*/
|
|
72
|
+
skeletonRows?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Estilo do skeleton padrão.
|
|
75
|
+
* skeleton: barras de placeholder. logo: loader do Radar.
|
|
76
|
+
* Passado para AdsTableSkeleton; ignorado quando #loading é passado via slot.
|
|
77
|
+
*/
|
|
78
|
+
skeletonVariant?: AdsTableSkeletonVariant;
|
|
79
|
+
/** Altura e respiro da linha do skeleton, quando a tabela foge do padrão da densidade. */
|
|
80
|
+
skeletonCellSize?: string;
|
|
81
|
+
/** Cabeçalho (e rodapé) fixos. A tabela ganha altura máxima de 70vh; max-h na classe sobrescreve. */
|
|
82
|
+
sticky?: boolean | "header" | "footer";
|
|
83
|
+
/**
|
|
84
|
+
* Lista virtual: só as linhas visíveis são montadas. Use com muitas linhas (centenas ou mais).
|
|
85
|
+
* Precisa de rolagem própria (sticky ou max-h), senão a tabela inteira é montada.
|
|
86
|
+
*/
|
|
87
|
+
virtualize?: boolean;
|
|
88
|
+
/** Linha de 1px na borda da coluna fixa. */
|
|
89
|
+
pinnedEdge?: boolean;
|
|
90
|
+
emptyLabel?: string;
|
|
91
|
+
emptyIcon?: string;
|
|
92
|
+
loadingLabel?: string;
|
|
93
|
+
/** Ajuste pontual de um slot; soma ao padrão. */
|
|
94
|
+
ui?: Partial<AdsTableUi>;
|
|
95
|
+
}>(),
|
|
96
|
+
{
|
|
97
|
+
density: "md",
|
|
98
|
+
striped: false,
|
|
99
|
+
framed: true,
|
|
100
|
+
borders: "lines",
|
|
101
|
+
depth: false,
|
|
102
|
+
loading: false,
|
|
103
|
+
skeletonRows: 5,
|
|
104
|
+
skeletonVariant: "skeleton",
|
|
105
|
+
skeletonCellSize: undefined,
|
|
106
|
+
sticky: false,
|
|
107
|
+
virtualize: false,
|
|
108
|
+
pinnedEdge: true,
|
|
109
|
+
emptyLabel: "Nenhum registro encontrado",
|
|
110
|
+
emptyIcon: "i-lucide-inbox",
|
|
111
|
+
loadingLabel: undefined,
|
|
112
|
+
ui: undefined,
|
|
113
|
+
},
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const slots = useSlots();
|
|
117
|
+
const attrs = useAttrs();
|
|
118
|
+
|
|
119
|
+
const leafColumns = (columns: TableColumn<T>[]): TableColumn<T>[] =>
|
|
120
|
+
columns.flatMap((column) =>
|
|
121
|
+
"columns" in column && column.columns?.length ? leafColumns(column.columns) : [column],
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const columnKey = (column: TableColumn<T>) =>
|
|
125
|
+
column.id ?? ("accessorKey" in column ? String(column.accessorKey) : "");
|
|
126
|
+
|
|
127
|
+
/** Alinhamento das colunas visíveis, lido da mesma classe que alinha o dado. */
|
|
128
|
+
const skeletonColumns = computed((): AdsTableSkeletonAlign[] => {
|
|
129
|
+
const hidden = (attrs.columnVisibility ?? attrs["column-visibility"] ?? {}) as Record<string, boolean>;
|
|
130
|
+
return leafColumns(props.columns)
|
|
131
|
+
.filter((column) => hidden[columnKey(column)] !== false)
|
|
132
|
+
.map((column) => {
|
|
133
|
+
const td = column.meta?.class?.td;
|
|
134
|
+
if (typeof td !== "string") return "left";
|
|
135
|
+
if (/\btext-right\b/.test(td)) return "right";
|
|
136
|
+
return /\btext-center\b/.test(td) ? "center" : "left";
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
/** Altura estimada da linha pela densidade; a medida real corrige linhas com conteúdo maior. */
|
|
141
|
+
const virtualizeOptions = computed(() =>
|
|
142
|
+
props.virtualize
|
|
143
|
+
? { estimateSize: props.density === "md" ? 64 : 40, overscan: 12 }
|
|
144
|
+
: false,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const tableUi = computed(() => {
|
|
148
|
+
const base = buildAdsTableUi({
|
|
149
|
+
density: props.density,
|
|
150
|
+
striped: props.striped,
|
|
151
|
+
framed: props.framed,
|
|
152
|
+
borders: props.borders,
|
|
153
|
+
depth: props.depth,
|
|
154
|
+
stickyHeader: props.sticky === true || props.sticky === "header",
|
|
155
|
+
pinnedEdge: props.pinnedEdge,
|
|
156
|
+
});
|
|
157
|
+
if (!slots.expanded) {
|
|
158
|
+
// Árvore via getSubRows: o UTable sempre desenha a linha de detalhe da linha aberta.
|
|
159
|
+
base.tbody = `${base.tbody} [&>tr[data-slot=tr]:not([data-selectable])]:hidden`;
|
|
160
|
+
}
|
|
161
|
+
if (props.loading && !props.data.length) {
|
|
162
|
+
// O skeleton já indica a carga; a barra do UTable é para recarga com dados na tela.
|
|
163
|
+
base.thead = `${base.thead} after:hidden`;
|
|
164
|
+
if (!slots.loading && props.skeletonVariant === "skeleton") {
|
|
165
|
+
// Tira a linha e a célula do caminho para as linhas do skeleton entrarem na grade.
|
|
166
|
+
base.tbody = `${base.tbody} [&>tr:has(>[data-slot=loading])]:contents`;
|
|
167
|
+
base.loading = "contents";
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return mergeAdsTableUi(base, props.ui);
|
|
171
|
+
});
|
|
172
|
+
</script>
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
AdsTableHeaderCell — Título de coluna da AdsTable (Figma: "_Table Header Cell").
|
|
3
|
-
|
|
4
|
-
Ordenar e fixar vêm desligados: ligue com `sortable` e `pinnable` quando a coluna permitir.
|
|
5
|
-
Fixar pede `v-model:column-pinning` na tabela.
|
|
6
|
-
|
|
7
|
-
@example
|
|
8
|
-
```ts
|
|
9
|
-
{ id: "store", header: ({ column }) => h(AdsTableHeaderCell, { column, label: "Loja", pinnable: true }) }
|
|
10
|
-
```
|
|
11
|
-
-->
|
|
12
|
-
<template>
|
|
13
|
-
<div class="flex items-center gap-2">
|
|
14
|
-
<div class="flex min-w-0 flex-1 items-center" :class="JUSTIFY[align]">
|
|
15
|
-
<button
|
|
16
|
-
v-if="canSort"
|
|
17
|
-
type="button"
|
|
18
|
-
class="flex items-center gap-1 rounded-[var(--ads-radius-xsm)] font-bold focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[var(--ads-button-primary)]"
|
|
19
|
-
:aria-label="`Ordenar por ${label}`"
|
|
20
|
-
@click="column?.toggleSorting()"
|
|
21
|
-
>
|
|
22
|
-
{{ label }}
|
|
23
|
-
<UIcon
|
|
24
|
-
:name="sortIcon"
|
|
25
|
-
class="size-4 shrink-0 text-[var(--ads-border-icon-support)]"
|
|
26
|
-
aria-hidden="true"
|
|
27
|
-
/>
|
|
28
|
-
</button>
|
|
29
|
-
<span v-else :class="{ 'sr-only': hideLabel }">{{ label }}</span>
|
|
30
|
-
</div>
|
|
31
|
-
<button
|
|
32
|
-
v-if="canPin"
|
|
33
|
-
type="button"
|
|
34
|
-
class="flex size-6 shrink-0 items-center justify-center rounded-[var(--ads-radius-xsm)] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[var(--ads-button-primary)]"
|
|
35
|
-
:aria-label="`${column?.getIsPinned() ? 'Soltar' : 'Fixar'} coluna ${label}`"
|
|
36
|
-
:aria-pressed="Boolean(column?.getIsPinned())"
|
|
37
|
-
@click="column?.pin(column.getIsPinned() ? false : pinSide)"
|
|
38
|
-
>
|
|
39
|
-
<UIcon
|
|
40
|
-
name="i-lucide-pin"
|
|
41
|
-
class="size-4"
|
|
42
|
-
:class="column?.getIsPinned() ? 'text-[var(--ads-text-brand)]' : 'text-[var(--ads-border-icon-support)]'"
|
|
43
|
-
aria-hidden="true"
|
|
44
|
-
/>
|
|
45
|
-
</button>
|
|
46
|
-
</div>
|
|
47
|
-
</template>
|
|
48
|
-
|
|
49
|
-
<script setup lang="ts">
|
|
50
|
-
import { computed } from "vue";
|
|
51
|
-
import type { AdsTableHeaderColumn } from "../utils/ads-table";
|
|
52
|
-
|
|
53
|
-
const JUSTIFY = { left: "justify-start", center: "justify-center", right: "justify-end" } as const;
|
|
54
|
-
const SORT_ICON = { asc: "i-lucide-arrow-up", desc: "i-lucide-arrow-down" } as const;
|
|
55
|
-
|
|
56
|
-
const props = withDefaults(
|
|
57
|
-
defineProps<{
|
|
58
|
-
label: string;
|
|
59
|
-
/** Coluna do TanStack, recebida na função `header`. */
|
|
60
|
-
column?: AdsTableHeaderColumn;
|
|
61
|
-
/** Acompanha o conteúdo: pills ao centro, ações à direita. */
|
|
62
|
-
align?: keyof typeof JUSTIFY;
|
|
63
|
-
sortable?: boolean;
|
|
64
|
-
pinnable?: boolean;
|
|
65
|
-
/** Lado em que o botão fixa a coluna: left no início, right no final da tabela. */
|
|
66
|
-
pinSide?: "left" | "right";
|
|
67
|
-
/** Mantém o título só para leitor de tela, como na coluna de ações. */
|
|
68
|
-
hideLabel?: boolean;
|
|
69
|
-
}>(),
|
|
70
|
-
{ column: undefined, align: "left", sortable: false, pinnable: false, pinSide: "left", hideLabel: false },
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const canSort = computed(() => props.sortable && props.column?.getCanSort());
|
|
74
|
-
const canPin = computed(() => props.pinnable && props.column?.getCanPin());
|
|
75
|
-
|
|
76
|
-
const sortIcon = computed(() => {
|
|
77
|
-
const sorted = props.column?.getIsSorted();
|
|
78
|
-
return sorted ? SORT_ICON[sorted] : "i-lucide-chevrons-up-down";
|
|
79
|
-
});
|
|
80
|
-
</script>
|
|
1
|
+
<!--
|
|
2
|
+
AdsTableHeaderCell — Título de coluna da AdsTable (Figma: "_Table Header Cell").
|
|
3
|
+
|
|
4
|
+
Ordenar e fixar vêm desligados: ligue com `sortable` e `pinnable` quando a coluna permitir.
|
|
5
|
+
Fixar pede `v-model:column-pinning` na tabela.
|
|
6
|
+
|
|
7
|
+
@example
|
|
8
|
+
```ts
|
|
9
|
+
{ id: "store", header: ({ column }) => h(AdsTableHeaderCell, { column, label: "Loja", pinnable: true }) }
|
|
10
|
+
```
|
|
11
|
+
-->
|
|
12
|
+
<template>
|
|
13
|
+
<div class="flex items-center gap-2">
|
|
14
|
+
<div class="flex min-w-0 flex-1 items-center" :class="JUSTIFY[align]">
|
|
15
|
+
<button
|
|
16
|
+
v-if="canSort"
|
|
17
|
+
type="button"
|
|
18
|
+
class="flex items-center gap-1 rounded-[var(--ads-radius-xsm)] font-bold focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[var(--ads-button-primary)]"
|
|
19
|
+
:aria-label="`Ordenar por ${label}`"
|
|
20
|
+
@click="column?.toggleSorting()"
|
|
21
|
+
>
|
|
22
|
+
{{ label }}
|
|
23
|
+
<UIcon
|
|
24
|
+
:name="sortIcon"
|
|
25
|
+
class="size-4 shrink-0 text-[var(--ads-border-icon-support)]"
|
|
26
|
+
aria-hidden="true"
|
|
27
|
+
/>
|
|
28
|
+
</button>
|
|
29
|
+
<span v-else :class="{ 'sr-only': hideLabel }">{{ label }}</span>
|
|
30
|
+
</div>
|
|
31
|
+
<button
|
|
32
|
+
v-if="canPin"
|
|
33
|
+
type="button"
|
|
34
|
+
class="flex size-6 shrink-0 items-center justify-center rounded-[var(--ads-radius-xsm)] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[var(--ads-button-primary)]"
|
|
35
|
+
:aria-label="`${column?.getIsPinned() ? 'Soltar' : 'Fixar'} coluna ${label}`"
|
|
36
|
+
:aria-pressed="Boolean(column?.getIsPinned())"
|
|
37
|
+
@click="column?.pin(column.getIsPinned() ? false : pinSide)"
|
|
38
|
+
>
|
|
39
|
+
<UIcon
|
|
40
|
+
name="i-lucide-pin"
|
|
41
|
+
class="size-4"
|
|
42
|
+
:class="column?.getIsPinned() ? 'text-[var(--ads-text-brand)]' : 'text-[var(--ads-border-icon-support)]'"
|
|
43
|
+
aria-hidden="true"
|
|
44
|
+
/>
|
|
45
|
+
</button>
|
|
46
|
+
</div>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<script setup lang="ts">
|
|
50
|
+
import { computed } from "vue";
|
|
51
|
+
import type { AdsTableHeaderColumn } from "../utils/ads-table";
|
|
52
|
+
|
|
53
|
+
const JUSTIFY = { left: "justify-start", center: "justify-center", right: "justify-end" } as const;
|
|
54
|
+
const SORT_ICON = { asc: "i-lucide-arrow-up", desc: "i-lucide-arrow-down" } as const;
|
|
55
|
+
|
|
56
|
+
const props = withDefaults(
|
|
57
|
+
defineProps<{
|
|
58
|
+
label: string;
|
|
59
|
+
/** Coluna do TanStack, recebida na função `header`. */
|
|
60
|
+
column?: AdsTableHeaderColumn;
|
|
61
|
+
/** Acompanha o conteúdo: pills ao centro, ações à direita. */
|
|
62
|
+
align?: keyof typeof JUSTIFY;
|
|
63
|
+
sortable?: boolean;
|
|
64
|
+
pinnable?: boolean;
|
|
65
|
+
/** Lado em que o botão fixa a coluna: left no início, right no final da tabela. */
|
|
66
|
+
pinSide?: "left" | "right";
|
|
67
|
+
/** Mantém o título só para leitor de tela, como na coluna de ações. */
|
|
68
|
+
hideLabel?: boolean;
|
|
69
|
+
}>(),
|
|
70
|
+
{ column: undefined, align: "left", sortable: false, pinnable: false, pinSide: "left", hideLabel: false },
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const canSort = computed(() => props.sortable && props.column?.getCanSort());
|
|
74
|
+
const canPin = computed(() => props.pinnable && props.column?.getCanPin());
|
|
75
|
+
|
|
76
|
+
const sortIcon = computed(() => {
|
|
77
|
+
const sorted = props.column?.getIsSorted();
|
|
78
|
+
return sorted ? SORT_ICON[sorted] : "i-lucide-chevrons-up-down";
|
|
79
|
+
});
|
|
80
|
+
</script>
|