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.
- package/LICENSE +21 -21
- package/README.md +573 -577
- 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 -0
- package/app/assets/brand/radar.svg +9 -9
- package/app/assets/css/ads-colors.css +257 -246
- package/app/assets/css/component-tokens.css +367 -403
- package/app/assets/css/main.css +624 -617
- package/app/components/AdsBadge.vue +47 -48
- package/app/components/AdsBroadcast.vue +24 -45
- package/app/components/AdsButton.vue +539 -569
- package/app/components/AdsButtonGroup.vue +39 -39
- package/app/components/AdsButtonMenu.vue +48 -48
- package/app/components/AdsCard.vue +188 -117
- package/app/components/AdsCardHint.vue +22 -0
- package/app/components/AdsCardPeriod.vue +43 -0
- package/app/components/AdsCardVariation.vue +31 -0
- package/app/components/AdsCharttip.vue +78 -78
- package/app/components/AdsCheckbox.vue +77 -77
- package/app/components/AdsDatePicker.vue +492 -491
- package/app/components/AdsDropdownMenu.vue +30 -19
- package/app/components/AdsEmptyState.vue +58 -58
- package/app/components/AdsFeatureCard.vue +210 -219
- package/app/components/AdsFileCard.vue +98 -101
- package/app/components/AdsFooter.vue +25 -25
- package/app/components/AdsHeavyAccountCell.vue +59 -0
- package/app/components/AdsHeavyHeaderCell.vue +70 -0
- package/app/components/AdsHeavyTable.vue +135 -0
- package/app/components/AdsInput.vue +147 -147
- package/app/components/AdsLoading.vue +217 -109
- package/app/components/AdsMenuBar.vue +103 -103
- package/app/components/AdsMetricCard.vue +216 -119
- package/app/components/AdsModal.vue +157 -157
- package/app/components/AdsMonthPicker.vue +80 -80
- package/app/components/AdsNavbarApp.vue +67 -67
- package/app/components/AdsNavbarDesk.vue +62 -62
- package/app/components/AdsNotabilityPill.vue +24 -27
- package/app/components/AdsNumberInput.vue +173 -173
- package/app/components/AdsPagination.vue +91 -91
- package/app/components/AdsPanelCard.vue +99 -0
- package/app/components/AdsPill.vue +144 -92
- package/app/components/AdsProductTag.vue +61 -61
- package/app/components/AdsRadio.vue +70 -70
- package/app/components/AdsSearchInput.vue +122 -122
- package/app/components/AdsSegmentedTabs.vue +62 -28
- package/app/components/{AdsFilterSelect.vue → AdsSelect.vue} +266 -210
- package/app/components/AdsSelectItem.vue +128 -0
- package/app/components/AdsSelectPanel.vue +150 -0
- package/app/components/AdsSideMenu.vue +101 -101
- package/app/components/AdsSmalltip.vue +44 -44
- package/app/components/AdsStepper.vue +222 -0
- package/app/components/AdsSteptip.vue +101 -101
- package/app/components/AdsSwitch.vue +59 -59
- package/app/components/AdsTable.vue +161 -100
- package/app/components/AdsTableHeaderCell.vue +80 -0
- package/app/components/AdsTableSkeleton.vue +113 -0
- 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 +183 -181
- package/app/components/AdsTooltip.vue +73 -73
- package/app/components/OverlayLoading.vue +173 -173
- package/app/components/ProgressBarLoading.vue +235 -256
- package/app/composables/useOverlayLoading.ts +66 -66
- package/app/constants/ads-color-swatches.ts +240 -239
- package/app/locale/pt-br.ts +6 -6
- package/app/plugins/ads-toast.client.ts +24 -24
- package/app/theme/ads-theme.ts +374 -370
- package/app/theme/ads-tokens.ts +391 -379
- package/app/theme/component-tokens.json +366 -402
- package/app/theme/component-tokens.ts +807 -815
- package/app/types/overlay-loading.types.ts +26 -26
- package/app/utils/ads-filter-select.ts +191 -172
- package/app/utils/ads-table.ts +395 -204
- 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 +1 -1
- package/app/components/AdsFarmarcasPill.vue +0 -74
- package/app/components/AdsFilterDropdown.vue +0 -174
- package/app/components/AdsFilterOption.vue +0 -74
- package/app/components/AdsListDropdown.vue +0 -44
- package/app/components/AdsMiniPill.vue +0 -40
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<DefinePanel>
|
|
3
|
-
<div class="flex w-[var(--ads-steptip-width)] flex-col gap-3 rounded-[var(--ads-tooltip-radius)] bg-[var(--ads-tooltip-bg)] p-4 text-[var(--ads-tooltip-title)] shadow-[var(--ads-shadow-level-1)]">
|
|
4
|
-
<div class="flex items-start justify-between gap-3">
|
|
5
|
-
<p class="text-base leading-[1.3] font-bold">{{ title }}</p>
|
|
6
|
-
<p class="shrink-0 text-xs leading-[1.2] font-medium">{{ step }}/{{ totalSteps }}</p>
|
|
7
|
-
</div>
|
|
8
|
-
<p class="text-sm leading-[1.3]">{{ description }}</p>
|
|
9
|
-
<div class="flex items-center justify-between gap-3">
|
|
10
|
-
<button
|
|
11
|
-
type="button"
|
|
12
|
-
class="text-base text-[var(--ads-steptip-skip)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-tooltip-title)]"
|
|
13
|
-
@click="emit('skip')"
|
|
14
|
-
>
|
|
15
|
-
{{ skipLabel }}
|
|
16
|
-
</button>
|
|
17
|
-
<div class="flex items-center gap-3">
|
|
18
|
-
<button
|
|
19
|
-
v-if="step > 1"
|
|
20
|
-
type="button"
|
|
21
|
-
class="text-base font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-contrast)]"
|
|
22
|
-
@click="emit('back')"
|
|
23
|
-
>
|
|
24
|
-
{{ backLabel }}
|
|
25
|
-
</button>
|
|
26
|
-
<button
|
|
27
|
-
type="button"
|
|
28
|
-
class="text-base font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-contrast)]"
|
|
29
|
-
@click="step >= totalSteps ? emit('finish') : emit('next')"
|
|
30
|
-
>
|
|
31
|
-
{{ step >= totalSteps ? finishLabel : nextLabel }}
|
|
32
|
-
</button>
|
|
33
|
-
</div>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
</DefinePanel>
|
|
37
|
-
|
|
38
|
-
<UTooltip
|
|
39
|
-
v-if="hasTrigger"
|
|
40
|
-
:delay-duration="delayDuration"
|
|
41
|
-
:content="{ side, align: 'center', sideOffset: 8 }"
|
|
42
|
-
:ui="tooltipUi"
|
|
43
|
-
>
|
|
44
|
-
<slot />
|
|
45
|
-
<template #content>
|
|
46
|
-
<ReusePanel />
|
|
47
|
-
</template>
|
|
48
|
-
</UTooltip>
|
|
49
|
-
<ReusePanel v-else />
|
|
50
|
-
</template>
|
|
51
|
-
|
|
52
|
-
<script setup lang="ts">
|
|
53
|
-
import { computed, useSlots } from "vue";
|
|
54
|
-
import { createReusableTemplate } from "@vueuse/core";
|
|
55
|
-
|
|
56
|
-
const [DefinePanel, ReusePanel] = createReusableTemplate();
|
|
57
|
-
|
|
58
|
-
const props = withDefaults(
|
|
59
|
-
defineProps<{
|
|
60
|
-
title?: string;
|
|
61
|
-
description?: string;
|
|
62
|
-
step?: number;
|
|
63
|
-
totalSteps?: number;
|
|
64
|
-
skipLabel?: string;
|
|
65
|
-
backLabel?: string;
|
|
66
|
-
nextLabel?: string;
|
|
67
|
-
finishLabel?: string;
|
|
68
|
-
/** Lado do gatilho onde o passo abre. Só vale com slot. */
|
|
69
|
-
side?: "top" | "right" | "bottom" | "left";
|
|
70
|
-
delayDuration?: number;
|
|
71
|
-
}>(),
|
|
72
|
-
{
|
|
73
|
-
title: "Título do passo",
|
|
74
|
-
description: "Texto que orienta a pessoa neste passo.",
|
|
75
|
-
step: 1,
|
|
76
|
-
totalSteps: 3,
|
|
77
|
-
skipLabel: "pular",
|
|
78
|
-
backLabel: "voltar",
|
|
79
|
-
nextLabel: "próximo",
|
|
80
|
-
finishLabel: "concluir",
|
|
81
|
-
side: "bottom",
|
|
82
|
-
delayDuration: 150,
|
|
83
|
-
},
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
const emit = defineEmits<{
|
|
87
|
-
skip: [];
|
|
88
|
-
back: [];
|
|
89
|
-
next: [];
|
|
90
|
-
finish: [];
|
|
91
|
-
}>();
|
|
92
|
-
|
|
93
|
-
const slots = useSlots();
|
|
94
|
-
const hasTrigger = computed(() => Boolean(slots.default));
|
|
95
|
-
const side = computed(() => props.side);
|
|
96
|
-
|
|
97
|
-
/** O painel já tem fundo, raio e sombra: o conteúdo do UTooltip só posiciona. */
|
|
98
|
-
const tooltipUi = {
|
|
99
|
-
content: "z-[70] h-auto rounded-none bg-transparent p-0 shadow-none ring-0",
|
|
100
|
-
};
|
|
101
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<DefinePanel>
|
|
3
|
+
<div class="flex w-[var(--ads-steptip-width)] flex-col gap-3 rounded-[var(--ads-tooltip-radius)] bg-[var(--ads-tooltip-bg)] p-4 text-[var(--ads-tooltip-title)] shadow-[var(--ads-shadow-level-1)]">
|
|
4
|
+
<div class="flex items-start justify-between gap-3">
|
|
5
|
+
<p class="text-base leading-[1.3] font-bold">{{ title }}</p>
|
|
6
|
+
<p class="shrink-0 text-xs leading-[1.2] font-medium">{{ step }}/{{ totalSteps }}</p>
|
|
7
|
+
</div>
|
|
8
|
+
<p class="text-sm leading-[1.3]">{{ description }}</p>
|
|
9
|
+
<div class="flex items-center justify-between gap-3">
|
|
10
|
+
<button
|
|
11
|
+
type="button"
|
|
12
|
+
class="text-base text-[var(--ads-steptip-skip)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-tooltip-title)]"
|
|
13
|
+
@click="emit('skip')"
|
|
14
|
+
>
|
|
15
|
+
{{ skipLabel }}
|
|
16
|
+
</button>
|
|
17
|
+
<div class="flex items-center gap-3">
|
|
18
|
+
<button
|
|
19
|
+
v-if="step > 1"
|
|
20
|
+
type="button"
|
|
21
|
+
class="text-base font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-contrast)]"
|
|
22
|
+
@click="emit('back')"
|
|
23
|
+
>
|
|
24
|
+
{{ backLabel }}
|
|
25
|
+
</button>
|
|
26
|
+
<button
|
|
27
|
+
type="button"
|
|
28
|
+
class="text-base font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-contrast)]"
|
|
29
|
+
@click="step >= totalSteps ? emit('finish') : emit('next')"
|
|
30
|
+
>
|
|
31
|
+
{{ step >= totalSteps ? finishLabel : nextLabel }}
|
|
32
|
+
</button>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</DefinePanel>
|
|
37
|
+
|
|
38
|
+
<UTooltip
|
|
39
|
+
v-if="hasTrigger"
|
|
40
|
+
:delay-duration="delayDuration"
|
|
41
|
+
:content="{ side, align: 'center', sideOffset: 8 }"
|
|
42
|
+
:ui="tooltipUi"
|
|
43
|
+
>
|
|
44
|
+
<slot />
|
|
45
|
+
<template #content>
|
|
46
|
+
<ReusePanel />
|
|
47
|
+
</template>
|
|
48
|
+
</UTooltip>
|
|
49
|
+
<ReusePanel v-else />
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script setup lang="ts">
|
|
53
|
+
import { computed, useSlots } from "vue";
|
|
54
|
+
import { createReusableTemplate } from "@vueuse/core";
|
|
55
|
+
|
|
56
|
+
const [DefinePanel, ReusePanel] = createReusableTemplate();
|
|
57
|
+
|
|
58
|
+
const props = withDefaults(
|
|
59
|
+
defineProps<{
|
|
60
|
+
title?: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
step?: number;
|
|
63
|
+
totalSteps?: number;
|
|
64
|
+
skipLabel?: string;
|
|
65
|
+
backLabel?: string;
|
|
66
|
+
nextLabel?: string;
|
|
67
|
+
finishLabel?: string;
|
|
68
|
+
/** Lado do gatilho onde o passo abre. Só vale com slot. */
|
|
69
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
70
|
+
delayDuration?: number;
|
|
71
|
+
}>(),
|
|
72
|
+
{
|
|
73
|
+
title: "Título do passo",
|
|
74
|
+
description: "Texto que orienta a pessoa neste passo.",
|
|
75
|
+
step: 1,
|
|
76
|
+
totalSteps: 3,
|
|
77
|
+
skipLabel: "pular",
|
|
78
|
+
backLabel: "voltar",
|
|
79
|
+
nextLabel: "próximo",
|
|
80
|
+
finishLabel: "concluir",
|
|
81
|
+
side: "bottom",
|
|
82
|
+
delayDuration: 150,
|
|
83
|
+
},
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const emit = defineEmits<{
|
|
87
|
+
skip: [];
|
|
88
|
+
back: [];
|
|
89
|
+
next: [];
|
|
90
|
+
finish: [];
|
|
91
|
+
}>();
|
|
92
|
+
|
|
93
|
+
const slots = useSlots();
|
|
94
|
+
const hasTrigger = computed(() => Boolean(slots.default));
|
|
95
|
+
const side = computed(() => props.side);
|
|
96
|
+
|
|
97
|
+
/** O painel já tem fundo, raio e sombra: o conteúdo do UTooltip só posiciona. */
|
|
98
|
+
const tooltipUi = {
|
|
99
|
+
content: "z-[70] h-auto rounded-none bg-transparent p-0 shadow-none ring-0",
|
|
100
|
+
};
|
|
101
|
+
</script>
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<label
|
|
3
|
-
class="inline-flex items-center"
|
|
4
|
-
:class="[hasLabel ? 'gap-[var(--ads-switch-gap)]' : '', isDisabled ? 'cursor-not-allowed' : 'cursor-pointer']"
|
|
5
|
-
>
|
|
6
|
-
<span class="relative h-[var(--ads-switch-height)] w-[var(--ads-switch-width)] shrink-0">
|
|
7
|
-
<input
|
|
8
|
-
v-bind="attrs"
|
|
9
|
-
type="checkbox"
|
|
10
|
-
role="switch"
|
|
11
|
-
class="peer absolute inset-0 appearance-none rounded-[var(--ads-switch-radius)] bg-[var(--ads-switch-off)] transition-colors duration-150 ease-out checked:bg-[var(--ads-switch-on)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-brand)] disabled:cursor-not-allowed disabled:bg-[var(--ads-switch-disabled)] disabled:checked:bg-[var(--ads-switch-disabled-on)]"
|
|
12
|
-
:checked="model"
|
|
13
|
-
:disabled="isDisabled"
|
|
14
|
-
:aria-checked="model"
|
|
15
|
-
@change="onChange"
|
|
16
|
-
>
|
|
17
|
-
<span
|
|
18
|
-
class="pointer-events-none absolute top-[var(--ads-switch-inset)] left-0 size-[var(--ads-switch-thumb)] translate-x-[var(--ads-switch-inset)] rounded-full bg-[var(--ads-switch-thumb-color)] transition-transform duration-150 ease-out peer-checked:translate-x-[calc(var(--ads-switch-width)-var(--ads-switch-thumb)-var(--ads-switch-inset))]"
|
|
19
|
-
/>
|
|
20
|
-
</span>
|
|
21
|
-
<span
|
|
22
|
-
v-if="hasLabel"
|
|
23
|
-
class="text-[length:var(--ads-switch-label-size)] font-normal leading-[1.3]"
|
|
24
|
-
:class="isDisabled ? 'text-[var(--ads-text-tertiary)]' : 'text-[var(--ads-switch-label)]'"
|
|
25
|
-
>
|
|
26
|
-
<slot>{{ label }}</slot>
|
|
27
|
-
</span>
|
|
28
|
-
</label>
|
|
29
|
-
</template>
|
|
30
|
-
|
|
31
|
-
<script setup lang="ts">
|
|
32
|
-
import { computed, useAttrs, useSlots } from "vue";
|
|
33
|
-
|
|
34
|
-
defineOptions({ inheritAttrs: false });
|
|
35
|
-
|
|
36
|
-
const props = withDefaults(
|
|
37
|
-
defineProps<{
|
|
38
|
-
label?: string;
|
|
39
|
-
disabled?: boolean;
|
|
40
|
-
}>(),
|
|
41
|
-
{
|
|
42
|
-
label: "",
|
|
43
|
-
disabled: false,
|
|
44
|
-
},
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const model = defineModel<boolean>({ default: false });
|
|
48
|
-
const attrs = useAttrs();
|
|
49
|
-
const slots = useSlots();
|
|
50
|
-
|
|
51
|
-
const hasLabel = computed(() => props.label.length > 0 || Boolean(slots.default));
|
|
52
|
-
const isDisabled = computed(() => props.disabled);
|
|
53
|
-
|
|
54
|
-
const onChange = (event: Event) => {
|
|
55
|
-
const input = event.target;
|
|
56
|
-
if (!(input instanceof HTMLInputElement) || isDisabled.value) return;
|
|
57
|
-
model.value = input.checked;
|
|
58
|
-
};
|
|
59
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<label
|
|
3
|
+
class="inline-flex items-center"
|
|
4
|
+
:class="[hasLabel ? 'gap-[var(--ads-switch-gap)]' : '', isDisabled ? 'cursor-not-allowed' : 'cursor-pointer']"
|
|
5
|
+
>
|
|
6
|
+
<span class="relative h-[var(--ads-switch-height)] w-[var(--ads-switch-width)] shrink-0">
|
|
7
|
+
<input
|
|
8
|
+
v-bind="attrs"
|
|
9
|
+
type="checkbox"
|
|
10
|
+
role="switch"
|
|
11
|
+
class="peer absolute inset-0 appearance-none rounded-[var(--ads-switch-radius)] bg-[var(--ads-switch-off)] transition-colors duration-150 ease-out checked:bg-[var(--ads-switch-on)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-brand)] disabled:cursor-not-allowed disabled:bg-[var(--ads-switch-disabled)] disabled:checked:bg-[var(--ads-switch-disabled-on)]"
|
|
12
|
+
:checked="model"
|
|
13
|
+
:disabled="isDisabled"
|
|
14
|
+
:aria-checked="model"
|
|
15
|
+
@change="onChange"
|
|
16
|
+
>
|
|
17
|
+
<span
|
|
18
|
+
class="pointer-events-none absolute top-[var(--ads-switch-inset)] left-0 size-[var(--ads-switch-thumb)] translate-x-[var(--ads-switch-inset)] rounded-full bg-[var(--ads-switch-thumb-color)] transition-transform duration-150 ease-out peer-checked:translate-x-[calc(var(--ads-switch-width)-var(--ads-switch-thumb)-var(--ads-switch-inset))]"
|
|
19
|
+
/>
|
|
20
|
+
</span>
|
|
21
|
+
<span
|
|
22
|
+
v-if="hasLabel"
|
|
23
|
+
class="text-[length:var(--ads-switch-label-size)] font-normal leading-[1.3]"
|
|
24
|
+
:class="isDisabled ? 'text-[var(--ads-text-tertiary)]' : 'text-[var(--ads-switch-label)]'"
|
|
25
|
+
>
|
|
26
|
+
<slot>{{ label }}</slot>
|
|
27
|
+
</span>
|
|
28
|
+
</label>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script setup lang="ts">
|
|
32
|
+
import { computed, useAttrs, useSlots } from "vue";
|
|
33
|
+
|
|
34
|
+
defineOptions({ inheritAttrs: false });
|
|
35
|
+
|
|
36
|
+
const props = withDefaults(
|
|
37
|
+
defineProps<{
|
|
38
|
+
label?: string;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
}>(),
|
|
41
|
+
{
|
|
42
|
+
label: "",
|
|
43
|
+
disabled: false,
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const model = defineModel<boolean>({ default: false });
|
|
48
|
+
const attrs = useAttrs();
|
|
49
|
+
const slots = useSlots();
|
|
50
|
+
|
|
51
|
+
const hasLabel = computed(() => props.label.length > 0 || Boolean(slots.default));
|
|
52
|
+
const isDisabled = computed(() => props.disabled);
|
|
53
|
+
|
|
54
|
+
const onChange = (event: Event) => {
|
|
55
|
+
const input = event.target;
|
|
56
|
+
if (!(input instanceof HTMLInputElement) || isDisabled.value) return;
|
|
57
|
+
model.value = input.checked;
|
|
58
|
+
};
|
|
59
|
+
</script>
|
|
@@ -1,100 +1,161 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<UTable
|
|
3
|
-
:data="data"
|
|
4
|
-
:columns="columns"
|
|
5
|
-
:loading="loading"
|
|
6
|
-
:sticky="sticky"
|
|
7
|
-
:ui="tableUi"
|
|
8
|
-
>
|
|
9
|
-
<template v-if="!$slots.loading" #loading>
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<UTable
|
|
3
|
+
:data="data"
|
|
4
|
+
:columns="columns"
|
|
5
|
+
:loading="loading"
|
|
6
|
+
:sticky="sticky"
|
|
7
|
+
:ui="tableUi"
|
|
8
|
+
>
|
|
9
|
+
<template v-if="!$slots.loading" #loading>
|
|
10
|
+
<AdsTableSkeleton
|
|
11
|
+
:rows="skeletonRows"
|
|
12
|
+
:variant="skeletonVariant"
|
|
13
|
+
:columns="skeletonColumns"
|
|
14
|
+
:cell-class="skeletonCellSize ?? adsTableCellSize(density)"
|
|
15
|
+
/>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<template v-if="!$slots.empty" #empty>
|
|
19
|
+
<div class="flex flex-col items-center gap-2">
|
|
20
|
+
<UIcon
|
|
21
|
+
:name="emptyIcon"
|
|
22
|
+
class="size-6 text-[var(--ads-border-icon-support)]"
|
|
23
|
+
aria-hidden="true"
|
|
24
|
+
/>
|
|
25
|
+
<p class="text-sm text-[var(--ads-text-secondary)]">{{ emptyLabel }}</p>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<template v-for="(_, name) in $slots" #[name]="slotProps">
|
|
30
|
+
<slot :name="name" v-bind="slotProps ?? {}" />
|
|
31
|
+
</template>
|
|
32
|
+
</UTable>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup lang="ts" generic="T extends TableData">
|
|
36
|
+
import { computed, useAttrs, useSlots } from "vue";
|
|
37
|
+
import type { TableColumn, TableData } from "@nuxt/ui";
|
|
38
|
+
import AdsTableSkeleton, {
|
|
39
|
+
type AdsTableSkeletonAlign,
|
|
40
|
+
type AdsTableSkeletonVariant,
|
|
41
|
+
} from "./AdsTableSkeleton.vue";
|
|
42
|
+
import {
|
|
43
|
+
adsTableCellSize,
|
|
44
|
+
buildAdsTableUi,
|
|
45
|
+
type AdsTableBorders,
|
|
46
|
+
type AdsTableDensity,
|
|
47
|
+
type AdsTableUi,
|
|
48
|
+
} from "../utils/ads-table";
|
|
49
|
+
|
|
50
|
+
const props = withDefaults(
|
|
51
|
+
defineProps<{
|
|
52
|
+
data: T[];
|
|
53
|
+
columns: TableColumn<T>[];
|
|
54
|
+
/** md: lista e gestão. sm: grade de dados larga ou prévia. */
|
|
55
|
+
density?: AdsTableDensity;
|
|
56
|
+
/** Zebra só em grade numérica larga. */
|
|
57
|
+
striped?: boolean;
|
|
58
|
+
/** Borda e raio próprios. Dentro de AdsCard, false. */
|
|
59
|
+
framed?: boolean;
|
|
60
|
+
/** lines: só horizontal. grid: horizontal e vertical. */
|
|
61
|
+
borders?: AdsTableBorders;
|
|
62
|
+
/** Degradê por nível. A célula marca `data-depth` de 0 a 2. */
|
|
63
|
+
depth?: boolean;
|
|
64
|
+
loading?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Número de linhas do skeleton de carregamento (1–8).
|
|
67
|
+
* Passado para o AdsTableSkeleton no slot #loading padrão.
|
|
68
|
+
*/
|
|
69
|
+
skeletonRows?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Estilo do skeleton padrão.
|
|
72
|
+
* skeleton: barras de placeholder. logo: loader do Radar.
|
|
73
|
+
* Passado para AdsTableSkeleton; ignorado quando #loading é passado via slot.
|
|
74
|
+
*/
|
|
75
|
+
skeletonVariant?: AdsTableSkeletonVariant;
|
|
76
|
+
/** Altura e respiro da linha do skeleton, quando a tabela foge do padrão da densidade. */
|
|
77
|
+
skeletonCellSize?: string;
|
|
78
|
+
/** Cabeçalho (e rodapé) fixos quando a tabela tem altura máxima. */
|
|
79
|
+
sticky?: boolean | "header" | "footer";
|
|
80
|
+
/** Linha de 1px na borda da coluna fixa. */
|
|
81
|
+
pinnedEdge?: boolean;
|
|
82
|
+
emptyLabel?: string;
|
|
83
|
+
emptyIcon?: string;
|
|
84
|
+
loadingLabel?: string;
|
|
85
|
+
/** Ajuste pontual de um slot; soma ao padrão. */
|
|
86
|
+
ui?: Partial<AdsTableUi>;
|
|
87
|
+
}>(),
|
|
88
|
+
{
|
|
89
|
+
density: "md",
|
|
90
|
+
striped: false,
|
|
91
|
+
framed: true,
|
|
92
|
+
borders: "lines",
|
|
93
|
+
depth: false,
|
|
94
|
+
loading: false,
|
|
95
|
+
skeletonRows: 5,
|
|
96
|
+
skeletonVariant: "skeleton",
|
|
97
|
+
skeletonCellSize: undefined,
|
|
98
|
+
sticky: false,
|
|
99
|
+
pinnedEdge: true,
|
|
100
|
+
emptyLabel: "Nenhum registro encontrado",
|
|
101
|
+
emptyIcon: "i-lucide-inbox",
|
|
102
|
+
loadingLabel: undefined,
|
|
103
|
+
ui: undefined,
|
|
104
|
+
},
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const slots = useSlots();
|
|
108
|
+
const attrs = useAttrs();
|
|
109
|
+
|
|
110
|
+
const leafColumns = (columns: TableColumn<T>[]): TableColumn<T>[] =>
|
|
111
|
+
columns.flatMap((column) =>
|
|
112
|
+
"columns" in column && column.columns?.length ? leafColumns(column.columns) : [column],
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const columnKey = (column: TableColumn<T>) =>
|
|
116
|
+
column.id ?? ("accessorKey" in column ? String(column.accessorKey) : "");
|
|
117
|
+
|
|
118
|
+
/** Alinhamento das colunas visíveis, lido da mesma classe que alinha o dado. */
|
|
119
|
+
const skeletonColumns = computed((): AdsTableSkeletonAlign[] => {
|
|
120
|
+
const hidden = (attrs.columnVisibility ?? attrs["column-visibility"] ?? {}) as Record<string, boolean>;
|
|
121
|
+
return leafColumns(props.columns)
|
|
122
|
+
.filter((column) => hidden[columnKey(column)] !== false)
|
|
123
|
+
.map((column) => {
|
|
124
|
+
const td = column.meta?.class?.td;
|
|
125
|
+
if (typeof td !== "string") return "left";
|
|
126
|
+
if (/\btext-right\b/.test(td)) return "right";
|
|
127
|
+
return /\btext-center\b/.test(td) ? "center" : "left";
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const tableUi = computed(() => {
|
|
132
|
+
const base = buildAdsTableUi({
|
|
133
|
+
density: props.density,
|
|
134
|
+
striped: props.striped,
|
|
135
|
+
framed: props.framed,
|
|
136
|
+
borders: props.borders,
|
|
137
|
+
depth: props.depth,
|
|
138
|
+
stickyHeader: props.sticky === true || props.sticky === "header",
|
|
139
|
+
pinnedEdge: props.pinnedEdge,
|
|
140
|
+
});
|
|
141
|
+
if (!slots.expanded) {
|
|
142
|
+
// Árvore via getSubRows: o UTable sempre desenha a linha de detalhe da linha aberta.
|
|
143
|
+
base.tbody = `${base.tbody} [&>tr[data-slot=tr]:not([data-selectable])]:hidden`;
|
|
144
|
+
}
|
|
145
|
+
if (props.loading && !props.data.length) {
|
|
146
|
+
// O skeleton já indica a carga; a barra do UTable é para recarga com dados na tela.
|
|
147
|
+
base.thead = `${base.thead} after:hidden`;
|
|
148
|
+
if (!slots.loading && props.skeletonVariant === "skeleton") {
|
|
149
|
+
// Tira a linha e a célula do caminho para as linhas do skeleton entrarem na grade.
|
|
150
|
+
base.tbody = `${base.tbody} [&>tr:has(>[data-slot=loading])]:contents`;
|
|
151
|
+
base.loading = "contents";
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (!props.ui) return base;
|
|
155
|
+
const merged = { ...base };
|
|
156
|
+
for (const key of Object.keys(props.ui) as (keyof AdsTableUi)[]) {
|
|
157
|
+
merged[key] = `${base[key]} ${props.ui[key] ?? ""}`.trim();
|
|
158
|
+
}
|
|
159
|
+
return merged;
|
|
160
|
+
});
|
|
161
|
+
</script>
|
|
@@ -0,0 +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>
|