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,210 +1,266 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
v-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
1
|
+
<!--
|
|
2
|
+
AdsSelect — o único componente de seleção do ADS (Figma: Select + Super dropdown + _Dropdown Item).
|
|
3
|
+
type: checkbox (múltipla), radio (simples) ou month (calendário de mês).
|
|
4
|
+
Gatilho: o campo do Figma por padrão; #trigger troca por um elemento próprio; inline mostra só a lista.
|
|
5
|
+
Opções aceitam subtitle, badge e disabled.
|
|
6
|
+
-->
|
|
7
|
+
<template>
|
|
8
|
+
<!-- Só a lista, sem gatilho (antigo List Dropdown / painel) -->
|
|
9
|
+
<template v-if="inline">
|
|
10
|
+
<AdsMonthPicker v-if="type === 'month'" v-model="monthModel" />
|
|
11
|
+
<AdsSelectPanel
|
|
12
|
+
v-else
|
|
13
|
+
v-model="model"
|
|
14
|
+
v-model:query="query"
|
|
15
|
+
:type="listType"
|
|
16
|
+
:options="options"
|
|
17
|
+
:searchable="showSearch"
|
|
18
|
+
:select-all="showSelectAll"
|
|
19
|
+
:select-all-label="selectAllLabel"
|
|
20
|
+
:empty-label="emptyLabel"
|
|
21
|
+
:search-placeholder="searchPlaceholder"
|
|
22
|
+
:list-label="label || 'Opções'"
|
|
23
|
+
:width-class="panelWidthClass"
|
|
24
|
+
@pick="emit('pick', model)"
|
|
25
|
+
/>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<div v-else class="flex min-w-0 flex-col gap-0.5" :class="block || !$slots.trigger ? 'w-full' : 'w-fit'">
|
|
29
|
+
<p
|
|
30
|
+
v-if="label"
|
|
31
|
+
:id="labelId"
|
|
32
|
+
class="text-[length:var(--ads-filter-label-size)] leading-[1.2] text-[var(--ads-text-secondary)]"
|
|
33
|
+
>
|
|
34
|
+
{{ label }}
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
<UPopover
|
|
38
|
+
v-model:open="isOpen"
|
|
39
|
+
:portal="true"
|
|
40
|
+
:content="{ align: 'start', side: 'bottom', sideOffset: 4 }"
|
|
41
|
+
:ui="popoverUi"
|
|
42
|
+
>
|
|
43
|
+
<slot
|
|
44
|
+
v-if="$slots.trigger"
|
|
45
|
+
name="trigger"
|
|
46
|
+
:open="isOpen"
|
|
47
|
+
:label="triggerLabel"
|
|
48
|
+
:has-value="hasValue"
|
|
49
|
+
/>
|
|
50
|
+
<button
|
|
51
|
+
v-else
|
|
52
|
+
type="button"
|
|
53
|
+
class="flex h-[var(--ads-filter-height)] max-w-full items-center gap-0.5 rounded-[var(--ads-filter-radius)] px-[var(--ads-filter-padding-x)] text-[length:var(--ads-filter-font-size)] leading-[1.3] transition-colors focus-visible:border-(length:--ads-border-width-slim) focus-visible:border-[var(--ads-filter-focus-border)] focus-visible:outline-none disabled:cursor-not-allowed"
|
|
54
|
+
:class="[fieldClass, block ? 'w-full justify-between' : 'w-fit']"
|
|
55
|
+
:disabled="disabled"
|
|
56
|
+
:data-state="fieldState"
|
|
57
|
+
:aria-haspopup="type === 'month' ? 'dialog' : 'listbox'"
|
|
58
|
+
:aria-expanded="isOpen"
|
|
59
|
+
:aria-invalid="error ? true : undefined"
|
|
60
|
+
:aria-labelledby="label ? labelId : undefined"
|
|
61
|
+
:aria-describedby="supportText ? supportId : undefined"
|
|
62
|
+
>
|
|
63
|
+
<AdsTooltip
|
|
64
|
+
:description="triggerLabel"
|
|
65
|
+
:show-title="false"
|
|
66
|
+
:disabled="!triggerHasTooltip"
|
|
67
|
+
align="start"
|
|
68
|
+
>
|
|
69
|
+
<span class="min-w-0 truncate text-left">{{ triggerLabel }}</span>
|
|
70
|
+
</AdsTooltip>
|
|
71
|
+
<UIcon name="i-lucide-chevron-down" class="size-4 shrink-0 text-base" :class="chevronClass" />
|
|
72
|
+
</button>
|
|
73
|
+
|
|
74
|
+
<template #content>
|
|
75
|
+
<AdsMonthPicker
|
|
76
|
+
v-if="type === 'month'"
|
|
77
|
+
v-model="monthModel"
|
|
78
|
+
@pick="onPick"
|
|
79
|
+
/>
|
|
80
|
+
<AdsSelectPanel
|
|
81
|
+
v-else
|
|
82
|
+
v-model="model"
|
|
83
|
+
v-model:query="query"
|
|
84
|
+
:type="listType"
|
|
85
|
+
:options="options"
|
|
86
|
+
:searchable="showSearch"
|
|
87
|
+
:select-all="showSelectAll"
|
|
88
|
+
:select-all-label="selectAllLabel"
|
|
89
|
+
:empty-label="emptyLabel"
|
|
90
|
+
:search-placeholder="searchPlaceholder"
|
|
91
|
+
:list-label="label || 'Opções'"
|
|
92
|
+
:width-class="panelWidthClass"
|
|
93
|
+
@pick="onPick"
|
|
94
|
+
/>
|
|
95
|
+
</template>
|
|
96
|
+
</UPopover>
|
|
97
|
+
|
|
98
|
+
<p
|
|
99
|
+
v-if="supportText"
|
|
100
|
+
:id="supportId"
|
|
101
|
+
class="text-[length:var(--ads-filter-label-size)] leading-[1.2] text-[var(--ads-text-secondary)]"
|
|
102
|
+
>
|
|
103
|
+
{{ supportText }}
|
|
104
|
+
</p>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
|
|
108
|
+
<script setup lang="ts">
|
|
109
|
+
import { computed, ref, useId, watch } from "vue";
|
|
110
|
+
import AdsSelectPanel from "./AdsSelectPanel.vue";
|
|
111
|
+
import AdsMonthPicker from "./AdsMonthPicker.vue";
|
|
112
|
+
import AdsTooltip from "./AdsTooltip.vue";
|
|
113
|
+
import {
|
|
114
|
+
filterLabelNeedsTooltip,
|
|
115
|
+
filterTriggerLabel,
|
|
116
|
+
type AdsFilterOption,
|
|
117
|
+
type AdsFilterType,
|
|
118
|
+
} from "../utils/ads-filter-select";
|
|
119
|
+
|
|
120
|
+
const props = withDefaults(
|
|
121
|
+
defineProps<{
|
|
122
|
+
type: AdsFilterType;
|
|
123
|
+
label?: string;
|
|
124
|
+
hint?: string;
|
|
125
|
+
error?: string;
|
|
126
|
+
placeholder?: string;
|
|
127
|
+
disabled?: boolean;
|
|
128
|
+
options?: AdsFilterOption[];
|
|
129
|
+
/** `null` = padrão do tipo (checkbox busca e seleciona todos). */
|
|
130
|
+
searchable?: boolean | null;
|
|
131
|
+
selectAll?: boolean | null;
|
|
132
|
+
selectAllLabel?: string;
|
|
133
|
+
allSelectedLabel?: string;
|
|
134
|
+
emptyLabel?: string;
|
|
135
|
+
searchPlaceholder?: string;
|
|
136
|
+
/** O gatilho ocupa a largura do campo, como um select de formulário. */
|
|
137
|
+
block?: boolean;
|
|
138
|
+
/** O valor veio de uma sugestão de IA. Quem usa limpa a marca quando a pessoa altera a seleção. */
|
|
139
|
+
aiSuggestion?: boolean;
|
|
140
|
+
/** Mostra só a lista, sem gatilho nem popover. */
|
|
141
|
+
inline?: boolean;
|
|
142
|
+
/** Largura da lista. Padrão: --ads-select-panel-width (320px). */
|
|
143
|
+
panelWidthClass?: string;
|
|
144
|
+
}>(),
|
|
145
|
+
{
|
|
146
|
+
placeholder: "Selecione",
|
|
147
|
+
disabled: false,
|
|
148
|
+
options: () => [],
|
|
149
|
+
searchable: null,
|
|
150
|
+
selectAll: null,
|
|
151
|
+
selectAllLabel: "Selecionar todos",
|
|
152
|
+
allSelectedLabel: "Todos selecionados",
|
|
153
|
+
emptyLabel: "Nenhum resultado",
|
|
154
|
+
searchPlaceholder: "Pesquisar",
|
|
155
|
+
block: false,
|
|
156
|
+
aiSuggestion: false,
|
|
157
|
+
inline: false,
|
|
158
|
+
panelWidthClass: "w-[var(--ads-select-panel-width)] max-w-full",
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const model = defineModel<string | string[]>({ required: true });
|
|
163
|
+
|
|
164
|
+
const emit = defineEmits<{
|
|
165
|
+
/** Escolha feita: no radio e no month o popover fecha. */
|
|
166
|
+
pick: [value: string | string[]];
|
|
167
|
+
}>();
|
|
168
|
+
|
|
169
|
+
defineSlots<{
|
|
170
|
+
/** Gatilho próprio (botão, chip…). Recebe open, label e hasValue. */
|
|
171
|
+
trigger?: (props: { open: boolean; label: string; hasValue: boolean }) => unknown;
|
|
172
|
+
}>();
|
|
173
|
+
|
|
174
|
+
const isOpen = ref(false);
|
|
175
|
+
const query = ref("");
|
|
176
|
+
const labelId = useId();
|
|
177
|
+
const supportId = useId();
|
|
178
|
+
|
|
179
|
+
const showSearch = computed(() =>
|
|
180
|
+
props.searchable === null ? props.type === "checkbox" : props.searchable,
|
|
181
|
+
);
|
|
182
|
+
const showSelectAll = computed(() =>
|
|
183
|
+
props.selectAll === null ? props.type === "checkbox" : props.selectAll,
|
|
184
|
+
);
|
|
185
|
+
const listType = computed(() => (props.type === "radio" ? "radio" : "checkbox"));
|
|
186
|
+
|
|
187
|
+
const supportText = computed(() => props.error || props.hint || "");
|
|
188
|
+
|
|
189
|
+
const hasValue = computed(() => {
|
|
190
|
+
if (Array.isArray(model.value)) return model.value.length > 0;
|
|
191
|
+
return model.value.length > 0;
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const fieldState = computed(() => {
|
|
195
|
+
if (props.disabled) return "disabled";
|
|
196
|
+
if (props.error) return "error";
|
|
197
|
+
if (isOpen.value) return "open";
|
|
198
|
+
if (props.aiSuggestion) return "ai";
|
|
199
|
+
if (hasValue.value) return "selected";
|
|
200
|
+
return "default";
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
const fieldClass = computed(() => {
|
|
204
|
+
if (fieldState.value === "disabled") {
|
|
205
|
+
return "border border-[var(--ads-filter-disabled-border)] bg-[var(--ads-filter-disabled-background)] text-[var(--ads-filter-disabled-text)]";
|
|
206
|
+
}
|
|
207
|
+
if (fieldState.value === "error") {
|
|
208
|
+
return "border-(length:--ads-border-width-slim) border-[var(--ads-filter-error-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
|
|
209
|
+
}
|
|
210
|
+
if (fieldState.value === "open") {
|
|
211
|
+
return "border-(length:--ads-border-width-slim) border-[var(--ads-filter-focus-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
|
|
212
|
+
}
|
|
213
|
+
if (fieldState.value === "ai") {
|
|
214
|
+
return "border border-[var(--ads-button-ia-border)] bg-[var(--ads-button-ia-background)] hover:border-[var(--ads-filter-hover-border)] text-[var(--ads-filter-text)]";
|
|
215
|
+
}
|
|
216
|
+
if (fieldState.value === "selected") {
|
|
217
|
+
return "border border-[var(--ads-filter-border)] hover:border-[var(--ads-filter-hover-border)] bg-ads-neutro-claro-20 text-[var(--ads-filter-text)]";
|
|
218
|
+
}
|
|
219
|
+
return "border border-[var(--ads-filter-border)] hover:border-[var(--ads-filter-hover-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
const chevronClass = computed(() => {
|
|
223
|
+
if (fieldState.value === "disabled") return "text-ads-neutro-medio-60";
|
|
224
|
+
if (fieldState.value === "selected" || fieldState.value === "ai") return "text-ads-neutro-escuro-500";
|
|
225
|
+
return "text-ads-neutro-medio-100";
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const triggerLabel = computed(() =>
|
|
229
|
+
filterTriggerLabel({
|
|
230
|
+
type: props.type,
|
|
231
|
+
value: model.value,
|
|
232
|
+
options: props.options,
|
|
233
|
+
placeholder: props.placeholder,
|
|
234
|
+
allSelectedLabel: props.allSelectedLabel,
|
|
235
|
+
}),
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
const triggerHasTooltip = computed(() => filterLabelNeedsTooltip(triggerLabel.value));
|
|
239
|
+
|
|
240
|
+
const monthModel = computed({
|
|
241
|
+
get: () => (typeof model.value === "string" ? model.value : ""),
|
|
242
|
+
set: (value: string) => {
|
|
243
|
+
model.value = value;
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
const onPick = () => {
|
|
248
|
+
isOpen.value = false;
|
|
249
|
+
emit("pick", model.value);
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
watch(isOpen, (open) => {
|
|
253
|
+
if (!open) query.value = "";
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
watch(
|
|
257
|
+
() => props.disabled,
|
|
258
|
+
(disabled) => {
|
|
259
|
+
if (disabled) isOpen.value = false;
|
|
260
|
+
},
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
const popoverUi = {
|
|
264
|
+
content: "z-50 w-auto overflow-visible bg-transparent p-0 shadow-none ring-0",
|
|
265
|
+
};
|
|
266
|
+
</script>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
AdsSelectItem — item da lista (Figma: _Dropdown Item). Peça interna do AdsSelect.
|
|
3
|
+
Seleção simples: selecionado ganha fundo azul claro e título em negrito.
|
|
4
|
+
Checkbox: caixa azul à esquerda; selecionado deixa o título em negrito.
|
|
5
|
+
-->
|
|
6
|
+
<template>
|
|
7
|
+
<button
|
|
8
|
+
type="button"
|
|
9
|
+
class="relative flex min-h-12 w-full items-center gap-3 p-[var(--ads-select-item-padding)] text-left transition-colors focus-visible:outline-none"
|
|
10
|
+
:class="[surfaceClass, divider ? dividerClass : '']"
|
|
11
|
+
:disabled="disabled"
|
|
12
|
+
:role="mode === 'checkbox' ? 'checkbox' : 'option'"
|
|
13
|
+
:aria-checked="checkedState"
|
|
14
|
+
:aria-selected="mode === 'radio' ? selected : undefined"
|
|
15
|
+
@click="emit('select')"
|
|
16
|
+
>
|
|
17
|
+
<span
|
|
18
|
+
v-if="mode === 'checkbox'"
|
|
19
|
+
class="flex size-4 shrink-0 items-center justify-center rounded-[var(--ads-radius-xsm)] border-2 border-[var(--ads-text-brand)]"
|
|
20
|
+
:class="[
|
|
21
|
+
selected || indeterminate ? 'bg-[var(--ads-surface-brand)]' : 'bg-[var(--ads-surface-card)]',
|
|
22
|
+
{ 'opacity-40': disabled },
|
|
23
|
+
]"
|
|
24
|
+
aria-hidden="true"
|
|
25
|
+
>
|
|
26
|
+
<UIcon v-if="indeterminate" name="i-lucide-minus" class="size-3 text-[var(--ads-text-contrast)]" />
|
|
27
|
+
<UIcon v-else-if="selected" name="i-lucide-check" class="size-3 text-[var(--ads-text-contrast)]" />
|
|
28
|
+
</span>
|
|
29
|
+
|
|
30
|
+
<span class="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
31
|
+
<span
|
|
32
|
+
v-if="badge"
|
|
33
|
+
class="flex items-center gap-1 text-[length:var(--ads-font-size-xxxs)] font-bold leading-[1.2]"
|
|
34
|
+
:class="badgeClass"
|
|
35
|
+
>
|
|
36
|
+
<UIcon v-if="badgeIcon" :name="badgeIcon" class="size-3 shrink-0" aria-hidden="true" />
|
|
37
|
+
{{ badge.label }}
|
|
38
|
+
</span>
|
|
39
|
+
<AdsTooltip
|
|
40
|
+
:description="label"
|
|
41
|
+
:show-title="false"
|
|
42
|
+
:disabled="!needsTooltip"
|
|
43
|
+
wing="down"
|
|
44
|
+
align="start"
|
|
45
|
+
>
|
|
46
|
+
<span class="block min-w-0 truncate text-sm leading-[1.3]" :class="titleClass">
|
|
47
|
+
{{ displayLabel }}
|
|
48
|
+
</span>
|
|
49
|
+
</AdsTooltip>
|
|
50
|
+
<span
|
|
51
|
+
v-if="subtitle"
|
|
52
|
+
class="block min-w-0 truncate text-sm font-normal leading-[1.3]"
|
|
53
|
+
:class="disabled ? 'text-[var(--ads-text-tertiary)]' : 'text-[var(--ads-text-secondary)]'"
|
|
54
|
+
>
|
|
55
|
+
{{ subtitle }}
|
|
56
|
+
</span>
|
|
57
|
+
</span>
|
|
58
|
+
</button>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<script setup lang="ts">
|
|
62
|
+
import { computed } from "vue";
|
|
63
|
+
import AdsTooltip from "./AdsTooltip.vue";
|
|
64
|
+
import {
|
|
65
|
+
filterLabelNeedsTooltip,
|
|
66
|
+
truncateFilterLabel,
|
|
67
|
+
type AdsFilterOptionBadge,
|
|
68
|
+
} from "../utils/ads-filter-select";
|
|
69
|
+
|
|
70
|
+
const props = withDefaults(
|
|
71
|
+
defineProps<{
|
|
72
|
+
label: string;
|
|
73
|
+
/** radio: seleção simples. checkbox: seleção múltipla. */
|
|
74
|
+
mode: "checkbox" | "radio";
|
|
75
|
+
selected?: boolean;
|
|
76
|
+
indeterminate?: boolean;
|
|
77
|
+
disabled?: boolean;
|
|
78
|
+
/** Linha de apoio abaixo do título. */
|
|
79
|
+
subtitle?: string;
|
|
80
|
+
/** Texto curto acima do título, como "Novo!" (brand) ou "Sugestão Inteligente" (ai). */
|
|
81
|
+
badge?: AdsFilterOptionBadge;
|
|
82
|
+
/** Linha de 1px embaixo. O painel desliga no último item. */
|
|
83
|
+
divider?: boolean;
|
|
84
|
+
}>(),
|
|
85
|
+
{
|
|
86
|
+
selected: false,
|
|
87
|
+
indeterminate: false,
|
|
88
|
+
disabled: false,
|
|
89
|
+
subtitle: undefined,
|
|
90
|
+
badge: undefined,
|
|
91
|
+
divider: true,
|
|
92
|
+
},
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const emit = defineEmits<{ select: [] }>();
|
|
96
|
+
|
|
97
|
+
const displayLabel = computed(() => truncateFilterLabel(props.label));
|
|
98
|
+
const needsTooltip = computed(() => filterLabelNeedsTooltip(props.label));
|
|
99
|
+
|
|
100
|
+
const checkedState = computed(() => {
|
|
101
|
+
if (props.mode !== "checkbox") return undefined;
|
|
102
|
+
if (props.indeterminate) return "mixed";
|
|
103
|
+
return props.selected;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const dividerClass =
|
|
107
|
+
"after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-[var(--ads-select-divider)]";
|
|
108
|
+
|
|
109
|
+
const surfaceClass = computed(() => {
|
|
110
|
+
if (props.disabled) return "cursor-not-allowed bg-[var(--ads-surface-card)]";
|
|
111
|
+
if (props.mode === "radio" && props.selected) return "bg-[var(--ads-select-item-selected)]";
|
|
112
|
+
return "bg-[var(--ads-surface-card)] hover:bg-[var(--ads-select-item-hover)] focus-visible:bg-[var(--ads-select-item-hover)]";
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const titleClass = computed(() => {
|
|
116
|
+
if (props.disabled) return "font-medium text-[var(--ads-text-tertiary)]";
|
|
117
|
+
if (props.selected) return "font-bold text-[var(--ads-text-primary)]";
|
|
118
|
+
return "font-medium text-[var(--ads-text-secondary)]";
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const badgeClass = computed(() => {
|
|
122
|
+
if (props.disabled) return "text-[var(--ads-text-tertiary)]";
|
|
123
|
+
return props.badge?.tone === "ai" ? "text-[var(--ads-select-badge-ai)]" : "text-[var(--ads-select-badge)]";
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/** Selo de IA usa sparkles quando não vem ícone. */
|
|
127
|
+
const badgeIcon = computed(() => props.badge?.icon ?? (props.badge?.tone === "ai" ? "i-lucide-sparkles" : undefined));
|
|
128
|
+
</script>
|