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.
Files changed (90) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +573 -577
  3. package/app/app.config.ts +25 -25
  4. package/app/assets/ads/checkbox-check.svg +5 -5
  5. package/app/assets/ads/checkbox-minus.svg +5 -5
  6. package/app/assets/brand/farmarcas.svg +6 -6
  7. package/app/assets/brand/radar-symbol.svg +9 -0
  8. package/app/assets/brand/radar.svg +9 -9
  9. package/app/assets/css/ads-colors.css +257 -246
  10. package/app/assets/css/component-tokens.css +367 -403
  11. package/app/assets/css/main.css +624 -617
  12. package/app/components/AdsBadge.vue +47 -48
  13. package/app/components/AdsBroadcast.vue +24 -45
  14. package/app/components/AdsButton.vue +539 -569
  15. package/app/components/AdsButtonGroup.vue +39 -39
  16. package/app/components/AdsButtonMenu.vue +48 -48
  17. package/app/components/AdsCard.vue +188 -117
  18. package/app/components/AdsCardHint.vue +22 -0
  19. package/app/components/AdsCardPeriod.vue +43 -0
  20. package/app/components/AdsCardVariation.vue +31 -0
  21. package/app/components/AdsCharttip.vue +78 -78
  22. package/app/components/AdsCheckbox.vue +77 -77
  23. package/app/components/AdsDatePicker.vue +492 -491
  24. package/app/components/AdsDropdownMenu.vue +30 -19
  25. package/app/components/AdsEmptyState.vue +58 -58
  26. package/app/components/AdsFeatureCard.vue +210 -219
  27. package/app/components/AdsFileCard.vue +98 -101
  28. package/app/components/AdsFooter.vue +25 -25
  29. package/app/components/AdsHeavyAccountCell.vue +59 -0
  30. package/app/components/AdsHeavyHeaderCell.vue +70 -0
  31. package/app/components/AdsHeavyTable.vue +135 -0
  32. package/app/components/AdsInput.vue +147 -147
  33. package/app/components/AdsLoading.vue +217 -109
  34. package/app/components/AdsMenuBar.vue +103 -103
  35. package/app/components/AdsMetricCard.vue +216 -119
  36. package/app/components/AdsModal.vue +157 -157
  37. package/app/components/AdsMonthPicker.vue +80 -80
  38. package/app/components/AdsNavbarApp.vue +67 -67
  39. package/app/components/AdsNavbarDesk.vue +62 -62
  40. package/app/components/AdsNotabilityPill.vue +24 -27
  41. package/app/components/AdsNumberInput.vue +173 -173
  42. package/app/components/AdsPagination.vue +91 -91
  43. package/app/components/AdsPanelCard.vue +99 -0
  44. package/app/components/AdsPill.vue +144 -92
  45. package/app/components/AdsProductTag.vue +61 -61
  46. package/app/components/AdsRadio.vue +70 -70
  47. package/app/components/AdsSearchInput.vue +122 -122
  48. package/app/components/AdsSegmentedTabs.vue +62 -28
  49. package/app/components/{AdsFilterSelect.vue → AdsSelect.vue} +266 -210
  50. package/app/components/AdsSelectItem.vue +128 -0
  51. package/app/components/AdsSelectPanel.vue +150 -0
  52. package/app/components/AdsSideMenu.vue +101 -101
  53. package/app/components/AdsSmalltip.vue +44 -44
  54. package/app/components/AdsStepper.vue +222 -0
  55. package/app/components/AdsSteptip.vue +101 -101
  56. package/app/components/AdsSwitch.vue +59 -59
  57. package/app/components/AdsTable.vue +161 -100
  58. package/app/components/AdsTableHeaderCell.vue +80 -0
  59. package/app/components/AdsTableSkeleton.vue +113 -0
  60. package/app/components/AdsTableToolbar.vue +44 -44
  61. package/app/components/AdsTabs.vue +51 -51
  62. package/app/components/AdsTextarea.vue +116 -116
  63. package/app/components/AdsToast.vue +183 -181
  64. package/app/components/AdsTooltip.vue +73 -73
  65. package/app/components/OverlayLoading.vue +173 -173
  66. package/app/components/ProgressBarLoading.vue +235 -256
  67. package/app/composables/useOverlayLoading.ts +66 -66
  68. package/app/constants/ads-color-swatches.ts +240 -239
  69. package/app/locale/pt-br.ts +6 -6
  70. package/app/plugins/ads-toast.client.ts +24 -24
  71. package/app/theme/ads-theme.ts +374 -370
  72. package/app/theme/ads-tokens.ts +391 -379
  73. package/app/theme/component-tokens.json +366 -402
  74. package/app/theme/component-tokens.ts +807 -815
  75. package/app/types/overlay-loading.types.ts +26 -26
  76. package/app/utils/ads-filter-select.ts +191 -172
  77. package/app/utils/ads-table.ts +395 -204
  78. package/app/utils/calendar-date.ts +163 -163
  79. package/app/utils/category-role.ts +45 -45
  80. package/app/utils/money.ts +77 -77
  81. package/app/utils/notability.ts +8 -8
  82. package/app/utils/parser.ts +134 -134
  83. package/app/utils/percentage.ts +54 -54
  84. package/nuxt.config.ts +31 -31
  85. package/package.json +1 -1
  86. package/app/components/AdsFarmarcasPill.vue +0 -74
  87. package/app/components/AdsFilterDropdown.vue +0 -174
  88. package/app/components/AdsFilterOption.vue +0 -74
  89. package/app/components/AdsListDropdown.vue +0 -44
  90. package/app/components/AdsMiniPill.vue +0 -40
@@ -1,210 +1,266 @@
1
- <template>
2
- <div class="flex w-full min-w-0 flex-col gap-0.5">
3
- <p
4
- v-if="label"
5
- :id="labelId"
6
- class="text-[length:var(--ads-filter-label-size)] leading-[1.2] text-[var(--ads-text-secondary)]"
7
- >
8
- {{ label }}
9
- </p>
10
-
11
- <UPopover
12
- v-model:open="isOpen"
13
- :portal="true"
14
- :content="{ align: 'start', side: 'bottom', sideOffset: 4 }"
15
- :ui="popoverUi"
16
- >
17
- <button
18
- type="button"
19
- 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"
20
- :class="[fieldClass, block ? 'w-full justify-between' : 'w-fit']"
21
- :disabled="disabled"
22
- :data-state="fieldState"
23
- :aria-haspopup="type === 'month' ? 'dialog' : 'listbox'"
24
- :aria-expanded="isOpen"
25
- :aria-invalid="error ? true : undefined"
26
- :aria-labelledby="label ? labelId : undefined"
27
- :aria-describedby="supportText ? supportId : undefined"
28
- >
29
- <AdsTooltip
30
- :description="triggerLabel"
31
- :show-title="false"
32
- :disabled="!triggerHasTooltip"
33
- align="start"
34
- >
35
- <span class="min-w-0 truncate text-left">{{ triggerLabel }}</span>
36
- </AdsTooltip>
37
- <UIcon name="i-lucide-chevron-down" class="size-4 shrink-0 text-base" :class="chevronClass" />
38
- </button>
39
-
40
- <template #content>
41
- <AdsMonthPicker
42
- v-if="type === 'month'"
43
- v-model="monthModel"
44
- @pick="isOpen = false"
45
- />
46
- <AdsFilterDropdown
47
- v-else
48
- v-model="model"
49
- v-model:query="query"
50
- :type="listType"
51
- :options="options"
52
- :searchable="showSearch"
53
- :select-all="showSelectAll"
54
- :select-all-label="selectAllLabel"
55
- :empty-label="emptyLabel"
56
- :search-placeholder="searchPlaceholder"
57
- :list-label="label || 'Opções'"
58
- @pick="isOpen = false"
59
- />
60
- </template>
61
- </UPopover>
62
-
63
- <p
64
- v-if="supportText"
65
- :id="supportId"
66
- class="text-[length:var(--ads-filter-label-size)] leading-[1.2] text-[var(--ads-text-secondary)]"
67
- >
68
- {{ supportText }}
69
- </p>
70
- </div>
71
- </template>
72
-
73
- <script setup lang="ts">
74
- import { computed, ref, useId, watch } from "vue";
75
- import AdsFilterDropdown from "./AdsFilterDropdown.vue";
76
- import AdsMonthPicker from "./AdsMonthPicker.vue";
77
- import AdsTooltip from "./AdsTooltip.vue";
78
- import {
79
- filterLabelNeedsTooltip,
80
- filterTriggerLabel,
81
- type AdsFilterOption,
82
- type AdsFilterType,
83
- } from "../utils/ads-filter-select";
84
-
85
- const props = withDefaults(
86
- defineProps<{
87
- type: AdsFilterType;
88
- label?: string;
89
- hint?: string;
90
- error?: string;
91
- placeholder?: string;
92
- disabled?: boolean;
93
- options?: AdsFilterOption[];
94
- /** `null` = padrão do tipo (checkbox busca e seleciona todos). */
95
- searchable?: boolean | null;
96
- selectAll?: boolean | null;
97
- selectAllLabel?: string;
98
- allSelectedLabel?: string;
99
- emptyLabel?: string;
100
- searchPlaceholder?: string;
101
- /** O gatilho ocupa a largura do campo, como um select de formulário. */
102
- block?: boolean;
103
- /** O valor veio de uma sugestão de IA. Quem usa limpa a marca quando a pessoa altera a seleção. */
104
- aiSuggestion?: boolean;
105
- }>(),
106
- {
107
- placeholder: "Selecione",
108
- disabled: false,
109
- options: () => [],
110
- searchable: null,
111
- selectAll: null,
112
- selectAllLabel: "Selecionar todos",
113
- allSelectedLabel: "Todos selecionados",
114
- emptyLabel: "Nenhum resultado",
115
- searchPlaceholder: "Pesquisar",
116
- block: false,
117
- aiSuggestion: false,
118
- },
119
- );
120
-
121
- const model = defineModel<string | string[]>({ required: true });
122
-
123
- const isOpen = ref(false);
124
- const query = ref("");
125
- const labelId = useId();
126
- const supportId = useId();
127
-
128
- const showSearch = computed(() =>
129
- props.searchable === null ? props.type === "checkbox" : props.searchable,
130
- );
131
- const showSelectAll = computed(() =>
132
- props.selectAll === null ? props.type === "checkbox" : props.selectAll,
133
- );
134
- const listType = computed(() => (props.type === "radio" ? "radio" : "checkbox"));
135
-
136
- const supportText = computed(() => props.error || props.hint || "");
137
-
138
- const hasValue = computed(() => {
139
- if (Array.isArray(model.value)) return model.value.length > 0;
140
- return model.value.length > 0;
141
- });
142
-
143
- const fieldState = computed(() => {
144
- if (props.disabled) return "disabled";
145
- if (props.error) return "error";
146
- if (isOpen.value) return "open";
147
- if (props.aiSuggestion) return "ai";
148
- if (hasValue.value) return "selected";
149
- return "default";
150
- });
151
-
152
- const fieldClass = computed(() => {
153
- if (fieldState.value === "disabled") {
154
- return "border border-[var(--ads-filter-disabled-border)] bg-[var(--ads-filter-disabled-background)] text-[var(--ads-filter-disabled-text)]";
155
- }
156
- if (fieldState.value === "error") {
157
- return "border-(length:--ads-border-width-slim) border-[var(--ads-filter-error-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
158
- }
159
- if (fieldState.value === "open") {
160
- return "border-(length:--ads-border-width-slim) border-[var(--ads-filter-focus-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
161
- }
162
- if (fieldState.value === "ai") {
163
- 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)]";
164
- }
165
- if (fieldState.value === "selected") {
166
- return "border border-[var(--ads-filter-border)] hover:border-[var(--ads-filter-hover-border)] bg-ads-neutro-claro-20 text-[var(--ads-filter-text)]";
167
- }
168
- return "border border-[var(--ads-filter-border)] hover:border-[var(--ads-filter-hover-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
169
- });
170
-
171
- const chevronClass = computed(() => {
172
- if (fieldState.value === "disabled") return "text-ads-neutro-medio-60";
173
- if (fieldState.value === "selected" || fieldState.value === "ai") return "text-ads-neutro-escuro-500";
174
- return "text-ads-neutro-medio-100";
175
- });
176
-
177
- const triggerLabel = computed(() =>
178
- filterTriggerLabel({
179
- type: props.type,
180
- value: model.value,
181
- options: props.options,
182
- placeholder: props.placeholder,
183
- allSelectedLabel: props.allSelectedLabel,
184
- }),
185
- );
186
-
187
- const triggerHasTooltip = computed(() => filterLabelNeedsTooltip(triggerLabel.value));
188
-
189
- const monthModel = computed({
190
- get: () => (typeof model.value === "string" ? model.value : ""),
191
- set: (value: string) => {
192
- model.value = value;
193
- },
194
- });
195
-
196
- watch(isOpen, (open) => {
197
- if (!open) query.value = "";
198
- });
199
-
200
- watch(
201
- () => props.disabled,
202
- (disabled) => {
203
- if (disabled) isOpen.value = false;
204
- },
205
- );
206
-
207
- const popoverUi = {
208
- content: "z-50 w-auto overflow-visible bg-transparent p-0 shadow-none ring-0",
209
- };
210
- </script>
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>