ads-nuxt 0.2.0 → 0.4.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/README.md +6 -4
- package/app/assets/css/component-tokens.css +369 -367
- package/app/assets/css/main.css +26 -65
- package/app/components/AdsBadge.vue +3 -3
- package/app/components/AdsBroadcast.vue +1 -1
- package/app/components/AdsButton.vue +13 -5
- package/app/components/AdsButtonMenu.vue +2 -2
- package/app/components/AdsCharttip.vue +3 -2
- package/app/components/AdsCheckbox.vue +77 -77
- package/app/components/AdsDatePicker.vue +23 -6
- package/app/components/AdsEmptyState.vue +6 -3
- package/app/components/AdsHeavyTable.vue +4 -0
- package/app/components/AdsInput.vue +3 -2
- package/app/components/AdsMenuBar.vue +8 -1
- package/app/components/AdsMetricCard.vue +1 -1
- package/app/components/AdsModal.vue +7 -4
- package/app/components/AdsNavbarApp.vue +1 -1
- package/app/components/AdsNavbarDesk.vue +14 -9
- package/app/components/AdsNumberInput.vue +8 -8
- package/app/components/AdsPagination.vue +91 -91
- package/app/components/AdsPill.vue +1 -1
- package/app/components/AdsProductTag.vue +21 -2
- package/app/components/AdsRadio.vue +70 -70
- package/app/components/AdsSearchInput.vue +2 -2
- package/app/components/AdsSelect.vue +18 -1
- package/app/components/AdsSelectPanel.vue +103 -32
- package/app/components/AdsSteptip.vue +104 -101
- package/app/components/AdsSwitch.vue +59 -59
- package/app/components/AdsTable.vue +16 -1
- package/app/components/AdsTextarea.vue +2 -2
- package/app/components/AdsToast.vue +6 -5
- package/app/components/AdsTooltip.vue +2 -2
- package/app/components/OverlayLoading.vue +313 -173
- package/app/composables/useOverlayLoading.ts +31 -9
- package/app/theme/ads-theme.ts +1 -1
- package/app/theme/component-tokens.json +368 -366
- package/app/theme/component-tokens.ts +809 -807
- package/app/types/overlay-loading.types.ts +11 -2
- package/app/utils/ads-table.ts +3 -0
- package/package.json +56 -55
- package/app/assets/animations/Error.gif +0 -0
- package/app/assets/animations/Loading.gif +0 -0
- package/app/assets/animations/Search.gif +0 -0
- package/app/assets/animations/Success.gif +0 -0
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
para mostrar só a lista, AdsSelect com inline.
|
|
4
4
|
Seleção simples (radio) ou múltipla (checkbox), busca opcional no topo, "selecionar todos",
|
|
5
5
|
subtítulo, selo e itens desabilitados. A lista rola a partir de 320px.
|
|
6
|
+
A lista é virtualizada (@tanstack/vue-virtual): só as linhas visíveis são montadas,
|
|
7
|
+
então milhares de opções não travam a tela. Altura medida por linha, pois subtítulo e selo mudam a altura.
|
|
6
8
|
-->
|
|
7
9
|
<template>
|
|
8
10
|
<div
|
|
@@ -34,46 +36,69 @@
|
|
|
34
36
|
</UInput>
|
|
35
37
|
</div>
|
|
36
38
|
|
|
37
|
-
<p
|
|
38
|
-
v-if="groups.empty"
|
|
39
|
-
class="flex min-h-12 items-center p-4 text-sm leading-[1.3] text-[var(--ads-text-secondary)]"
|
|
40
|
-
>
|
|
41
|
-
{{ emptyLabel }}
|
|
42
|
-
</p>
|
|
43
|
-
|
|
44
39
|
<div
|
|
45
|
-
|
|
40
|
+
ref="scrollRef"
|
|
46
41
|
class="max-h-[var(--ads-select-panel-max-height)] overflow-y-auto overscroll-contain [scrollbar-color:var(--color-ads-neutro-claro-50)_transparent] [scrollbar-width:thin]"
|
|
47
42
|
:role="type === 'radio' ? 'listbox' : 'group'"
|
|
48
43
|
:aria-label="listLabel"
|
|
49
44
|
>
|
|
50
|
-
<
|
|
51
|
-
v-if="
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
45
|
+
<p
|
|
46
|
+
v-if="groups.empty"
|
|
47
|
+
class="flex min-h-12 items-center p-4 text-sm leading-[1.3] text-[var(--ads-text-secondary)]"
|
|
48
|
+
>
|
|
49
|
+
{{ emptyLabel }}
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
<div v-else class="relative w-full" :style="{ height: `${virtualizer.getTotalSize()}px` }">
|
|
53
|
+
<div
|
|
54
|
+
v-for="virtualRow in virtualizer.getVirtualItems()"
|
|
55
|
+
:key="virtualRow.key"
|
|
56
|
+
:ref="measureRow"
|
|
57
|
+
:data-index="virtualRow.index"
|
|
58
|
+
role="presentation"
|
|
59
|
+
class="absolute top-0 left-0 w-full"
|
|
60
|
+
:style="{ transform: `translateY(${virtualRow.start}px)` }"
|
|
61
|
+
>
|
|
62
|
+
<AdsSelectItem
|
|
63
|
+
v-if="!rowItems[virtualRow.index].option"
|
|
64
|
+
mode="checkbox"
|
|
65
|
+
:label="selectAllLabel"
|
|
66
|
+
:selected="checkState === 'all'"
|
|
67
|
+
:indeterminate="checkState === 'partial'"
|
|
68
|
+
:divider="rowItems.length > 1"
|
|
69
|
+
@select="onSelectAll"
|
|
70
|
+
/>
|
|
71
|
+
<AdsSelectItem
|
|
72
|
+
v-else
|
|
73
|
+
:mode="type"
|
|
74
|
+
:label="rowItems[virtualRow.index].option!.label"
|
|
75
|
+
:subtitle="rowItems[virtualRow.index].option!.subtitle"
|
|
76
|
+
:badge="rowItems[virtualRow.index].option!.badge"
|
|
77
|
+
:disabled="rowItems[virtualRow.index].option!.disabled"
|
|
78
|
+
:selected="isSelected(rowItems[virtualRow.index].option!.value)"
|
|
79
|
+
:divider="virtualRow.index < rowItems.length - 1"
|
|
80
|
+
@select="onSelect(rowItems[virtualRow.index].option!.value)"
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
71
84
|
</div>
|
|
85
|
+
|
|
86
|
+
<button
|
|
87
|
+
v-if="addText"
|
|
88
|
+
type="button"
|
|
89
|
+
class="flex min-h-12 w-full items-center gap-2 border-t border-[var(--ads-select-divider)] px-4 py-3 text-left text-sm leading-[1.3] font-bold text-[var(--ads-text-brand)] transition-colors hover:bg-[var(--ads-select-item-hover)] focus-visible:bg-[var(--ads-select-item-hover)] focus-visible:outline-none"
|
|
90
|
+
data-testid="select-add"
|
|
91
|
+
@click="emit('add', query.trim())"
|
|
92
|
+
>
|
|
93
|
+
<UIcon name="i-lucide-plus" class="size-4 shrink-0" aria-hidden="true" />
|
|
94
|
+
<span class="min-w-0 truncate">{{ addText }}</span>
|
|
95
|
+
</button>
|
|
72
96
|
</div>
|
|
73
97
|
</template>
|
|
74
98
|
|
|
75
99
|
<script setup lang="ts">
|
|
76
|
-
import { computed } from "vue";
|
|
100
|
+
import { computed, ref } from "vue";
|
|
101
|
+
import { useVirtualizer } from "@tanstack/vue-virtual";
|
|
77
102
|
import AdsSelectItem from "./AdsSelectItem.vue";
|
|
78
103
|
import {
|
|
79
104
|
groupFilterOptions,
|
|
@@ -98,6 +123,11 @@ const props = withDefaults(
|
|
|
98
123
|
listLabel?: string;
|
|
99
124
|
/** Largura do painel. Padrão: --ads-select-panel-width (320px). */
|
|
100
125
|
widthClass?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Ação de cadastrar no rodapé, com ícone de adicionar. `{query}` vira a busca atual.
|
|
128
|
+
* Sem valor, a ação não aparece.
|
|
129
|
+
*/
|
|
130
|
+
addLabel?: string;
|
|
101
131
|
}>(),
|
|
102
132
|
{
|
|
103
133
|
searchable: true,
|
|
@@ -112,7 +142,18 @@ const props = withDefaults(
|
|
|
112
142
|
|
|
113
143
|
const model = defineModel<string | string[]>({ required: true });
|
|
114
144
|
const query = defineModel<string>("query", { default: "" });
|
|
115
|
-
const emit = defineEmits<{
|
|
145
|
+
const emit = defineEmits<{
|
|
146
|
+
pick: [];
|
|
147
|
+
/** Ação de cadastrar. Recebe a busca atual, sem espaços nas pontas. */
|
|
148
|
+
add: [query: string];
|
|
149
|
+
}>();
|
|
150
|
+
|
|
151
|
+
/** Texto da ação: `{query}` recebe a busca; sem busca, o trecho some. */
|
|
152
|
+
const addText = computed(() => {
|
|
153
|
+
if (!props.addLabel) return "";
|
|
154
|
+
const text = props.addLabel.replaceAll("{query}", query.value.trim());
|
|
155
|
+
return text.replace(/\s+/g, " ").trim();
|
|
156
|
+
});
|
|
116
157
|
|
|
117
158
|
const groups = computed(() => groupFilterOptions(props.options, query.value));
|
|
118
159
|
/** Correspondência exata da busca vem primeiro. */
|
|
@@ -122,12 +163,42 @@ const enabledOptions = computed(() => props.options.filter((option) => !option.d
|
|
|
122
163
|
const selectedList = computed(() =>
|
|
123
164
|
Array.isArray(model.value) ? model.value : model.value ? [model.value] : [],
|
|
124
165
|
);
|
|
166
|
+
const selectedSet = computed(() => new Set(selectedList.value));
|
|
125
167
|
const checkState = computed(() => selectionCheckState(selectedList.value, enabledOptions.value));
|
|
126
168
|
const showSelectAll = computed(
|
|
127
169
|
() => props.type === "checkbox" && props.selectAll && query.value.trim() === "",
|
|
128
170
|
);
|
|
129
171
|
|
|
130
|
-
|
|
172
|
+
/** Linhas da lista virtual: "selecionar todos" (sem option) no começo, quando aparece. */
|
|
173
|
+
interface PanelRow {
|
|
174
|
+
key: string;
|
|
175
|
+
option?: FilterOption;
|
|
176
|
+
}
|
|
177
|
+
const rowItems = computed<PanelRow[]>(() => {
|
|
178
|
+
const list = rows.value.map((option) => ({ key: option.value, option }));
|
|
179
|
+
return showSelectAll.value ? [{ key: SELECT_ALL_KEY }, ...list] : list;
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const SELECT_ALL_KEY = "__select-all__";
|
|
183
|
+
/** Altura mínima de uma linha (min-h-12). A medida real corrige linhas com subtítulo ou selo. */
|
|
184
|
+
const ROW_ESTIMATE = 48;
|
|
185
|
+
|
|
186
|
+
const scrollRef = ref<HTMLElement | null>(null);
|
|
187
|
+
const virtualizer = useVirtualizer(
|
|
188
|
+
computed(() => ({
|
|
189
|
+
count: rowItems.value.length,
|
|
190
|
+
getScrollElement: () => scrollRef.value,
|
|
191
|
+
estimateSize: () => ROW_ESTIMATE,
|
|
192
|
+
overscan: 8,
|
|
193
|
+
getItemKey: (index: number) => rowItems.value[index]?.key ?? index,
|
|
194
|
+
})),
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
const measureRow = (el: unknown) => {
|
|
198
|
+
if (el instanceof HTMLElement) virtualizer.value.measureElement(el);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const isSelected = (value: string) => selectedSet.value.has(value);
|
|
131
202
|
|
|
132
203
|
const onSelect = (value: string) => {
|
|
133
204
|
if (props.type === "radio") {
|
|
@@ -1,101 +1,104 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<DefinePanel>
|
|
3
|
-
<div class="flex w-[var(--ads-steptip-width)] flex-col gap-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
</template>
|
|
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
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<DefinePanel>
|
|
3
|
+
<div class="flex w-[var(--ads-steptip-width)] flex-col gap-4 rounded-[var(--ads-tooltip-radius)] bg-[var(--ads-tooltip-bg)] p-4 text-[var(--ads-tooltip-title)] shadow-[var(--ads-shadow-level-1)]">
|
|
4
|
+
<!-- Figma 5722:8160: título↔descrição 4px; bloco de texto↔botões 16px. -->
|
|
5
|
+
<div class="flex flex-col gap-1">
|
|
6
|
+
<div class="flex items-start justify-between gap-3">
|
|
7
|
+
<p class="text-base leading-[1.3] font-bold">{{ title }}</p>
|
|
8
|
+
<p class="shrink-0 text-xs leading-[1.2] font-medium">{{ step }}/{{ totalSteps }}</p>
|
|
9
|
+
</div>
|
|
10
|
+
<p class="text-sm leading-[1.3]">{{ description }}</p>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="flex items-center justify-between gap-3 leading-[1.3]">
|
|
13
|
+
<button
|
|
14
|
+
type="button"
|
|
15
|
+
class="text-base text-[var(--ads-steptip-skip)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-tooltip-title)]"
|
|
16
|
+
@click="emit('skip')"
|
|
17
|
+
>
|
|
18
|
+
{{ skipLabel }}
|
|
19
|
+
</button>
|
|
20
|
+
<div class="flex items-center gap-3">
|
|
21
|
+
<button
|
|
22
|
+
v-if="step > 1"
|
|
23
|
+
type="button"
|
|
24
|
+
class="text-base font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-contrast)]"
|
|
25
|
+
@click="emit('back')"
|
|
26
|
+
>
|
|
27
|
+
{{ backLabel }}
|
|
28
|
+
</button>
|
|
29
|
+
<button
|
|
30
|
+
type="button"
|
|
31
|
+
class="text-base font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-contrast)]"
|
|
32
|
+
@click="step >= totalSteps ? emit('finish') : emit('next')"
|
|
33
|
+
>
|
|
34
|
+
{{ step >= totalSteps ? finishLabel : nextLabel }}
|
|
35
|
+
</button>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</DefinePanel>
|
|
40
|
+
|
|
41
|
+
<UTooltip
|
|
42
|
+
v-if="hasTrigger"
|
|
43
|
+
:delay-duration="delayDuration"
|
|
44
|
+
:content="{ side, align: 'center', sideOffset: 8 }"
|
|
45
|
+
:ui="tooltipUi"
|
|
46
|
+
>
|
|
47
|
+
<slot />
|
|
48
|
+
<template #content>
|
|
49
|
+
<ReusePanel />
|
|
50
|
+
</template>
|
|
51
|
+
</UTooltip>
|
|
52
|
+
<ReusePanel v-else />
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script setup lang="ts">
|
|
56
|
+
import { computed, useSlots } from "vue";
|
|
57
|
+
import { createReusableTemplate } from "@vueuse/core";
|
|
58
|
+
|
|
59
|
+
const [DefinePanel, ReusePanel] = createReusableTemplate();
|
|
60
|
+
|
|
61
|
+
const props = withDefaults(
|
|
62
|
+
defineProps<{
|
|
63
|
+
title?: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
step?: number;
|
|
66
|
+
totalSteps?: number;
|
|
67
|
+
skipLabel?: string;
|
|
68
|
+
backLabel?: string;
|
|
69
|
+
nextLabel?: string;
|
|
70
|
+
finishLabel?: string;
|
|
71
|
+
/** Lado do gatilho onde o passo abre. Só vale com slot. */
|
|
72
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
73
|
+
delayDuration?: number;
|
|
74
|
+
}>(),
|
|
75
|
+
{
|
|
76
|
+
title: "Título do passo",
|
|
77
|
+
description: "Texto que orienta a pessoa neste passo.",
|
|
78
|
+
step: 1,
|
|
79
|
+
totalSteps: 3,
|
|
80
|
+
skipLabel: "pular",
|
|
81
|
+
backLabel: "voltar",
|
|
82
|
+
nextLabel: "próximo",
|
|
83
|
+
finishLabel: "concluir",
|
|
84
|
+
side: "bottom",
|
|
85
|
+
delayDuration: 150,
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const emit = defineEmits<{
|
|
90
|
+
skip: [];
|
|
91
|
+
back: [];
|
|
92
|
+
next: [];
|
|
93
|
+
finish: [];
|
|
94
|
+
}>();
|
|
95
|
+
|
|
96
|
+
const slots = useSlots();
|
|
97
|
+
const hasTrigger = computed(() => Boolean(slots.default));
|
|
98
|
+
const side = computed(() => props.side);
|
|
99
|
+
|
|
100
|
+
/** O painel já tem fundo, raio e sombra: o conteúdo do UTooltip só posiciona. */
|
|
101
|
+
const tooltipUi = {
|
|
102
|
+
content: "z-[70] h-auto max-w-none rounded-none bg-transparent p-0 shadow-none ring-0",
|
|
103
|
+
};
|
|
104
|
+
</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-
|
|
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-ads-neutro-medio-70' : '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,9 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<UTable
|
|
3
|
+
:key="virtualize ? 'virtual' : 'static'"
|
|
3
4
|
:data="data"
|
|
4
5
|
:columns="columns"
|
|
5
6
|
:loading="loading"
|
|
6
7
|
:sticky="sticky"
|
|
8
|
+
:virtualize="virtualizeOptions"
|
|
7
9
|
:ui="tableUi"
|
|
8
10
|
>
|
|
9
11
|
<template v-if="!$slots.loading" #loading>
|
|
@@ -75,8 +77,13 @@ const props = withDefaults(
|
|
|
75
77
|
skeletonVariant?: AdsTableSkeletonVariant;
|
|
76
78
|
/** Altura e respiro da linha do skeleton, quando a tabela foge do padrão da densidade. */
|
|
77
79
|
skeletonCellSize?: string;
|
|
78
|
-
/** Cabeçalho (e rodapé) fixos
|
|
80
|
+
/** Cabeçalho (e rodapé) fixos. A tabela ganha altura máxima de 70vh; max-h na classe sobrescreve. */
|
|
79
81
|
sticky?: boolean | "header" | "footer";
|
|
82
|
+
/**
|
|
83
|
+
* Lista virtual: só as linhas visíveis são montadas. Use com muitas linhas (centenas ou mais).
|
|
84
|
+
* Precisa de rolagem própria (sticky ou max-h), senão a tabela inteira é montada.
|
|
85
|
+
*/
|
|
86
|
+
virtualize?: boolean;
|
|
80
87
|
/** Linha de 1px na borda da coluna fixa. */
|
|
81
88
|
pinnedEdge?: boolean;
|
|
82
89
|
emptyLabel?: string;
|
|
@@ -96,6 +103,7 @@ const props = withDefaults(
|
|
|
96
103
|
skeletonVariant: "skeleton",
|
|
97
104
|
skeletonCellSize: undefined,
|
|
98
105
|
sticky: false,
|
|
106
|
+
virtualize: false,
|
|
99
107
|
pinnedEdge: true,
|
|
100
108
|
emptyLabel: "Nenhum registro encontrado",
|
|
101
109
|
emptyIcon: "i-lucide-inbox",
|
|
@@ -128,6 +136,13 @@ const skeletonColumns = computed((): AdsTableSkeletonAlign[] => {
|
|
|
128
136
|
});
|
|
129
137
|
});
|
|
130
138
|
|
|
139
|
+
/** Altura estimada da linha pela densidade; a medida real corrige linhas com conteúdo maior. */
|
|
140
|
+
const virtualizeOptions = computed(() =>
|
|
141
|
+
props.virtualize
|
|
142
|
+
? { estimateSize: props.density === "md" ? 64 : 40, overscan: 12 }
|
|
143
|
+
: false,
|
|
144
|
+
);
|
|
145
|
+
|
|
131
146
|
const tableUi = computed(() => {
|
|
132
147
|
const base = buildAdsTableUi({
|
|
133
148
|
density: props.density,
|
|
@@ -86,7 +86,7 @@ const visualState = computed<AdsTextareaState>(() => {
|
|
|
86
86
|
const supportText = computed(() => props.error || props.hint);
|
|
87
87
|
const supportClass = computed(() =>
|
|
88
88
|
visualState.value === "disabled"
|
|
89
|
-
? "text-[var(--ads-
|
|
89
|
+
? "text-[var(--ads-textarea-placeholder)]"
|
|
90
90
|
: "text-[var(--ads-text-secondary)]",
|
|
91
91
|
);
|
|
92
92
|
|
|
@@ -109,7 +109,7 @@ const fieldClass = computed(() => {
|
|
|
109
109
|
? "hover:not-focus-within:border-[var(--ads-textarea-hover-border)] focus-within:border-(length:--ads-border-width-slim) focus-within:border-[var(--ads-textarea-focus-border)]"
|
|
110
110
|
: "";
|
|
111
111
|
if (visualState.value === "ai") {
|
|
112
|
-
return `border border-[var(--ads-
|
|
112
|
+
return `border border-[var(--ads-text-ai)] bg-[var(--ads-surface-ai)] text-[var(--ads-text-secondary)] ${focus}`;
|
|
113
113
|
}
|
|
114
114
|
return `border border-[var(--ads-textarea-border)] bg-[var(--ads-textarea-background)] ${text} ${focus}`;
|
|
115
115
|
});
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
</p>
|
|
47
47
|
<p
|
|
48
48
|
v-if="description"
|
|
49
|
-
class="
|
|
49
|
+
class="text-[length:var(--ads-toast-font-size)] leading-[1.3] text-[var(--ads-text-secondary)]"
|
|
50
|
+
:class="app ? 'mt-1' : 'mt-0.5'"
|
|
50
51
|
>
|
|
51
52
|
{{ description }}
|
|
52
53
|
</p>
|
|
@@ -55,12 +56,12 @@
|
|
|
55
56
|
</div>
|
|
56
57
|
<div
|
|
57
58
|
v-if="actionLabel || closable"
|
|
58
|
-
class="ml-auto flex shrink-0 items-center gap-
|
|
59
|
+
class="ml-auto flex shrink-0 items-center gap-[var(--ads-toast-gap)]"
|
|
59
60
|
>
|
|
60
61
|
<button
|
|
61
62
|
v-if="actionLabel"
|
|
62
63
|
type="button"
|
|
63
|
-
class="text-[length:var(--ads-toast-font-size)] [font-
|
|
64
|
+
class="text-[length:var(--ads-toast-font-size)] leading-[1.3] font-bold underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2"
|
|
64
65
|
:class="actionTextClass"
|
|
65
66
|
@click="emit('action')"
|
|
66
67
|
>
|
|
@@ -69,7 +70,7 @@
|
|
|
69
70
|
<button
|
|
70
71
|
v-if="closable"
|
|
71
72
|
type="button"
|
|
72
|
-
class="flex size-
|
|
73
|
+
class="flex size-[18px] shrink-0 items-center justify-center rounded-[var(--ads-radius-xsm)] text-[var(--ads-text-primary)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-primary)]"
|
|
73
74
|
aria-label="Fechar"
|
|
74
75
|
@click="emit('close')"
|
|
75
76
|
>
|
|
@@ -141,7 +142,7 @@ const iconClass = computed(() => {
|
|
|
141
142
|
const actionTextClass = computed(() => {
|
|
142
143
|
if (props.status === "success") return "text-[var(--ads-toast-success-icon)]";
|
|
143
144
|
if (props.status === "warning" || props.status === "attention") return "text-[var(--ads-toast-warning-icon)]";
|
|
144
|
-
if (props.status === "neutral") return "text-[var(--ads-
|
|
145
|
+
if (props.status === "neutral") return "text-[var(--ads-toast-neutral-icon)]";
|
|
145
146
|
if (props.status === "loading") return "text-[var(--ads-toast-primary-icon)]";
|
|
146
147
|
return "text-[var(--ads-toast-error-icon)]";
|
|
147
148
|
});
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
</UTooltip>
|
|
18
18
|
<div
|
|
19
19
|
v-else
|
|
20
|
-
class="flex max-w-[
|
|
20
|
+
class="flex max-w-[328px] flex-col gap-1 rounded-[var(--ads-tooltip-radius)] bg-[var(--ads-tooltip-bg)] p-[var(--ads-tooltip-padding-x)] text-[var(--ads-tooltip-title)] shadow-[var(--ads-shadow-level-1)]"
|
|
21
21
|
>
|
|
22
22
|
<p v-if="showTitle" class="text-[length:var(--ads-tooltip-title-size)] leading-[1.3] font-bold">{{ title }}</p>
|
|
23
23
|
<p v-if="showDescription" class="text-[length:var(--ads-tooltip-font-size)] leading-[1.3]">{{ description }}</p>
|
|
@@ -67,7 +67,7 @@ const side = computed(() => {
|
|
|
67
67
|
|
|
68
68
|
const tooltipUi = {
|
|
69
69
|
content:
|
|
70
|
-
"z-[70] h-auto max-w-[328px] rounded-[var(--ads-tooltip-radius)] bg-[var(--ads-tooltip-bg)]
|
|
70
|
+
"z-[70] h-auto max-w-[328px] rounded-[var(--ads-tooltip-radius)] bg-[var(--ads-tooltip-bg)] p-[var(--ads-tooltip-padding-x)] shadow-[var(--ads-shadow-level-1)] ring-0",
|
|
71
71
|
arrow: "fill-[var(--ads-tooltip-bg)]",
|
|
72
72
|
};
|
|
73
73
|
</script>
|