ads-nuxt 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +574 -574
  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 -9
  8. package/app/assets/brand/radar.svg +9 -9
  9. package/app/assets/css/ads-colors.css +257 -257
  10. package/app/assets/css/main.css +585 -585
  11. package/app/components/AdsBadge.vue +47 -47
  12. package/app/components/AdsBroadcast.vue +24 -24
  13. package/app/components/AdsButton.vue +547 -547
  14. package/app/components/AdsButtonGroup.vue +39 -39
  15. package/app/components/AdsButtonMenu.vue +48 -48
  16. package/app/components/AdsCard.vue +188 -188
  17. package/app/components/AdsCardHint.vue +56 -56
  18. package/app/components/AdsCardPeriod.vue +43 -43
  19. package/app/components/AdsCardVariation.vue +31 -31
  20. package/app/components/AdsCharttip.vue +79 -79
  21. package/app/components/AdsDatePicker.vue +509 -509
  22. package/app/components/AdsDropdownMenu.vue +30 -30
  23. package/app/components/AdsEmptyState.vue +61 -61
  24. package/app/components/AdsFeatureCard.vue +292 -292
  25. package/app/components/AdsFileCard.vue +98 -98
  26. package/app/components/AdsFooter.vue +25 -25
  27. package/app/components/AdsHeavyAccountCell.vue +59 -59
  28. package/app/components/AdsHeavyHeaderCell.vue +70 -70
  29. package/app/components/AdsHeavyTable.vue +135 -135
  30. package/app/components/AdsInput.vue +148 -148
  31. package/app/components/AdsLoading.vue +217 -217
  32. package/app/components/AdsMenuBar.vue +110 -110
  33. package/app/components/AdsMetricCard.vue +226 -226
  34. package/app/components/AdsModal.vue +160 -160
  35. package/app/components/AdsMonthPicker.vue +80 -80
  36. package/app/components/AdsNavbarApp.vue +67 -67
  37. package/app/components/AdsNavbarDesk.vue +67 -67
  38. package/app/components/AdsNotabilityPill.vue +24 -24
  39. package/app/components/AdsNumberInput.vue +173 -173
  40. package/app/components/AdsPanelCard.vue +99 -99
  41. package/app/components/AdsPill.vue +144 -144
  42. package/app/components/AdsProductTag.vue +80 -80
  43. package/app/components/AdsSearchInput.vue +122 -122
  44. package/app/components/AdsSegmentedTabs.vue +62 -62
  45. package/app/components/AdsSelect.vue +283 -283
  46. package/app/components/AdsSelectItem.vue +128 -128
  47. package/app/components/AdsSelectPanel.vue +221 -221
  48. package/app/components/AdsSideMenu.vue +101 -101
  49. package/app/components/AdsSmalltip.vue +44 -44
  50. package/app/components/AdsStepper.vue +222 -222
  51. package/app/components/AdsTable.vue +172 -172
  52. package/app/components/AdsTableHeaderCell.vue +80 -80
  53. package/app/components/AdsTableSkeleton.vue +113 -113
  54. package/app/components/AdsTableToolbar.vue +44 -44
  55. package/app/components/AdsTabs.vue +51 -51
  56. package/app/components/AdsTextarea.vue +116 -116
  57. package/app/components/AdsToast.vue +184 -184
  58. package/app/components/AdsTooltip.vue +73 -73
  59. package/app/components/ProgressBarLoading.vue +235 -235
  60. package/app/composables/useOverlayLoading.ts +88 -88
  61. package/app/constants/ads-color-swatches.ts +240 -240
  62. package/app/locale/pt-br.ts +6 -6
  63. package/app/plugins/ads-toast.client.ts +24 -24
  64. package/app/theme/ads-theme.ts +374 -374
  65. package/app/theme/ads-tokens.ts +391 -391
  66. package/app/types/overlay-loading.types.ts +32 -32
  67. package/app/utils/ads-filter-select.ts +191 -191
  68. package/app/utils/ads-table.ts +416 -416
  69. package/app/utils/calendar-date.ts +163 -163
  70. package/app/utils/category-role.ts +45 -45
  71. package/app/utils/money.ts +77 -77
  72. package/app/utils/notability.ts +8 -8
  73. package/app/utils/parser.ts +134 -134
  74. package/app/utils/percentage.ts +54 -54
  75. package/nuxt.config.ts +31 -31
  76. package/package.json +57 -57
@@ -1,283 +1,283 @@
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
- :add-label="addLabel"
25
- @pick="emit('pick', model)"
26
- @add="onAdd"
27
- />
28
- </template>
29
-
30
- <div v-else class="flex min-w-0 flex-col gap-0.5" :class="block || !$slots.trigger ? 'w-full' : 'w-fit'">
31
- <p
32
- v-if="label"
33
- :id="labelId"
34
- class="text-[length:var(--ads-filter-label-size)] leading-[1.2] text-[var(--ads-text-secondary)]"
35
- >
36
- {{ label }}
37
- </p>
38
-
39
- <UPopover
40
- v-model:open="isOpen"
41
- :portal="true"
42
- :content="{ align: 'start', side: 'bottom', sideOffset: 4 }"
43
- :ui="popoverUi"
44
- >
45
- <slot
46
- v-if="$slots.trigger"
47
- name="trigger"
48
- :open="isOpen"
49
- :label="triggerLabel"
50
- :has-value="hasValue"
51
- />
52
- <button
53
- v-else
54
- type="button"
55
- 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"
56
- :class="[fieldClass, block ? 'w-full justify-between' : 'w-fit']"
57
- :disabled="disabled"
58
- :data-state="fieldState"
59
- :aria-haspopup="type === 'month' ? 'dialog' : 'listbox'"
60
- :aria-expanded="isOpen"
61
- :aria-invalid="error ? true : undefined"
62
- :aria-labelledby="label ? labelId : undefined"
63
- :aria-describedby="supportText ? supportId : undefined"
64
- >
65
- <AdsTooltip
66
- :description="triggerLabel"
67
- :show-title="false"
68
- :disabled="!triggerHasTooltip"
69
- align="start"
70
- >
71
- <span class="min-w-0 truncate text-left">{{ triggerLabel }}</span>
72
- </AdsTooltip>
73
- <UIcon name="i-lucide-chevron-down" class="size-4 shrink-0 text-base" :class="chevronClass" />
74
- </button>
75
-
76
- <template #content>
77
- <AdsMonthPicker
78
- v-if="type === 'month'"
79
- v-model="monthModel"
80
- @pick="onPick"
81
- />
82
- <AdsSelectPanel
83
- v-else
84
- v-model="model"
85
- v-model:query="query"
86
- :type="listType"
87
- :options="options"
88
- :searchable="showSearch"
89
- :select-all="showSelectAll"
90
- :select-all-label="selectAllLabel"
91
- :empty-label="emptyLabel"
92
- :search-placeholder="searchPlaceholder"
93
- :list-label="label || 'Opções'"
94
- :width-class="panelWidthClass"
95
- :add-label="addLabel"
96
- @pick="onPick"
97
- @add="onAdd"
98
- />
99
- </template>
100
- </UPopover>
101
-
102
- <p
103
- v-if="supportText"
104
- :id="supportId"
105
- class="text-[length:var(--ads-filter-label-size)] leading-[1.2] text-[var(--ads-text-secondary)]"
106
- >
107
- {{ supportText }}
108
- </p>
109
- </div>
110
- </template>
111
-
112
- <script setup lang="ts">
113
- import { computed, ref, useId, watch } from "vue";
114
- import AdsSelectPanel from "./AdsSelectPanel.vue";
115
- import AdsMonthPicker from "./AdsMonthPicker.vue";
116
- import AdsTooltip from "./AdsTooltip.vue";
117
- import {
118
- filterLabelNeedsTooltip,
119
- filterTriggerLabel,
120
- type AdsFilterOption,
121
- type AdsFilterType,
122
- } from "../utils/ads-filter-select";
123
-
124
- const props = withDefaults(
125
- defineProps<{
126
- type: AdsFilterType;
127
- label?: string;
128
- hint?: string;
129
- error?: string;
130
- placeholder?: string;
131
- disabled?: boolean;
132
- options?: AdsFilterOption[];
133
- /** `null` = padrão do tipo (checkbox busca e seleciona todos). */
134
- searchable?: boolean | null;
135
- selectAll?: boolean | null;
136
- selectAllLabel?: string;
137
- allSelectedLabel?: string;
138
- emptyLabel?: string;
139
- searchPlaceholder?: string;
140
- /** O gatilho ocupa a largura do campo, como um select de formulário. */
141
- block?: boolean;
142
- /** O valor veio de uma sugestão de IA. Quem usa limpa a marca quando a pessoa altera a seleção. */
143
- aiSuggestion?: boolean;
144
- /** Mostra só a lista, sem gatilho nem popover. */
145
- inline?: boolean;
146
- /** Largura da lista. Padrão: --ads-select-panel-width (320px). */
147
- panelWidthClass?: string;
148
- /**
149
- * Ação de cadastrar no rodapé da lista, com ícone de adicionar. `{query}` vira a busca atual,
150
- * ex.: "Cadastrar {query}". Sem valor, a ação não aparece.
151
- */
152
- addLabel?: string;
153
- }>(),
154
- {
155
- placeholder: "Selecione",
156
- disabled: false,
157
- options: () => [],
158
- searchable: null,
159
- selectAll: null,
160
- selectAllLabel: "Selecionar todos",
161
- allSelectedLabel: "Todos selecionados",
162
- emptyLabel: "Nenhum resultado",
163
- searchPlaceholder: "Pesquisar",
164
- block: false,
165
- aiSuggestion: false,
166
- inline: false,
167
- panelWidthClass: "w-[var(--ads-select-panel-width)] max-w-full",
168
- },
169
- );
170
-
171
- const model = defineModel<string | string[]>({ required: true });
172
-
173
- const emit = defineEmits<{
174
- /** Escolha feita: no radio e no month o popover fecha. */
175
- pick: [value: string | string[]];
176
- /** Ação de cadastrar. Recebe a busca atual. No popover, a lista fecha antes do evento. */
177
- add: [query: string];
178
- }>();
179
-
180
- defineSlots<{
181
- /** Gatilho próprio (botão, chip…). Recebe open, label e hasValue. */
182
- trigger?: (props: { open: boolean; label: string; hasValue: boolean }) => unknown;
183
- }>();
184
-
185
- const isOpen = ref(false);
186
- const query = ref("");
187
- const labelId = useId();
188
- const supportId = useId();
189
-
190
- const showSearch = computed(() =>
191
- props.searchable === null ? props.type === "checkbox" : props.searchable,
192
- );
193
- const showSelectAll = computed(() =>
194
- props.selectAll === null ? props.type === "checkbox" : props.selectAll,
195
- );
196
- const listType = computed(() => (props.type === "radio" ? "radio" : "checkbox"));
197
-
198
- const supportText = computed(() => props.error || props.hint || "");
199
-
200
- const hasValue = computed(() => {
201
- if (Array.isArray(model.value)) return model.value.length > 0;
202
- return model.value.length > 0;
203
- });
204
-
205
- const fieldState = computed(() => {
206
- if (props.disabled) return "disabled";
207
- if (props.error) return "error";
208
- if (isOpen.value) return "open";
209
- if (props.aiSuggestion) return "ai";
210
- if (hasValue.value) return "selected";
211
- return "default";
212
- });
213
-
214
- const fieldClass = computed(() => {
215
- if (fieldState.value === "disabled") {
216
- return "border border-[var(--ads-filter-disabled-border)] bg-[var(--ads-filter-disabled-background)] text-[var(--ads-filter-disabled-text)]";
217
- }
218
- if (fieldState.value === "error") {
219
- return "border-(length:--ads-border-width-slim) border-[var(--ads-filter-error-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
220
- }
221
- if (fieldState.value === "open") {
222
- return "border-(length:--ads-border-width-slim) border-[var(--ads-filter-focus-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
223
- }
224
- if (fieldState.value === "ai") {
225
- return "border border-[var(--ads-text-ai)] bg-[var(--ads-surface-ai)] hover:border-[var(--ads-filter-hover-border)] text-[var(--ads-filter-text)]";
226
- }
227
- if (fieldState.value === "selected") {
228
- return "border border-[var(--ads-filter-border)] hover:border-[var(--ads-filter-hover-border)] bg-ads-neutro-claro-20 text-[var(--ads-filter-text)]";
229
- }
230
- return "border border-[var(--ads-filter-border)] hover:border-[var(--ads-filter-hover-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
231
- });
232
-
233
- const chevronClass = computed(() => {
234
- if (fieldState.value === "disabled") return "text-ads-neutro-medio-60";
235
- if (fieldState.value === "selected" || fieldState.value === "ai") return "text-ads-neutro-escuro-500";
236
- return "text-ads-neutro-medio-100";
237
- });
238
-
239
- const triggerLabel = computed(() =>
240
- filterTriggerLabel({
241
- type: props.type,
242
- value: model.value,
243
- options: props.options,
244
- placeholder: props.placeholder,
245
- allSelectedLabel: props.allSelectedLabel,
246
- }),
247
- );
248
-
249
- const triggerHasTooltip = computed(() => filterLabelNeedsTooltip(triggerLabel.value));
250
-
251
- const monthModel = computed({
252
- get: () => (typeof model.value === "string" ? model.value : ""),
253
- set: (value: string) => {
254
- model.value = value;
255
- },
256
- });
257
-
258
- const onPick = () => {
259
- isOpen.value = false;
260
- emit("pick", model.value);
261
- };
262
-
263
- const onAdd = (text: string) => {
264
- // No popover, a lista fecha: o cadastro costuma abrir um formulário ou modal por cima.
265
- if (!props.inline) isOpen.value = false;
266
- emit("add", text);
267
- };
268
-
269
- watch(isOpen, (open) => {
270
- if (!open) query.value = "";
271
- });
272
-
273
- watch(
274
- () => props.disabled,
275
- (disabled) => {
276
- if (disabled) isOpen.value = false;
277
- },
278
- );
279
-
280
- const popoverUi = {
281
- content: "z-50 w-auto overflow-visible bg-transparent p-0 shadow-none ring-0",
282
- };
283
- </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
+ :add-label="addLabel"
25
+ @pick="emit('pick', model)"
26
+ @add="onAdd"
27
+ />
28
+ </template>
29
+
30
+ <div v-else class="flex min-w-0 flex-col gap-0.5" :class="block || !$slots.trigger ? 'w-full' : 'w-fit'">
31
+ <p
32
+ v-if="label"
33
+ :id="labelId"
34
+ class="text-[length:var(--ads-filter-label-size)] leading-[1.2] text-[var(--ads-text-secondary)]"
35
+ >
36
+ {{ label }}
37
+ </p>
38
+
39
+ <UPopover
40
+ v-model:open="isOpen"
41
+ :portal="true"
42
+ :content="{ align: 'start', side: 'bottom', sideOffset: 4 }"
43
+ :ui="popoverUi"
44
+ >
45
+ <slot
46
+ v-if="$slots.trigger"
47
+ name="trigger"
48
+ :open="isOpen"
49
+ :label="triggerLabel"
50
+ :has-value="hasValue"
51
+ />
52
+ <button
53
+ v-else
54
+ type="button"
55
+ 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"
56
+ :class="[fieldClass, block ? 'w-full justify-between' : 'w-fit']"
57
+ :disabled="disabled"
58
+ :data-state="fieldState"
59
+ :aria-haspopup="type === 'month' ? 'dialog' : 'listbox'"
60
+ :aria-expanded="isOpen"
61
+ :aria-invalid="error ? true : undefined"
62
+ :aria-labelledby="label ? labelId : undefined"
63
+ :aria-describedby="supportText ? supportId : undefined"
64
+ >
65
+ <AdsTooltip
66
+ :description="triggerLabel"
67
+ :show-title="false"
68
+ :disabled="!triggerHasTooltip"
69
+ align="start"
70
+ >
71
+ <span class="min-w-0 truncate text-left">{{ triggerLabel }}</span>
72
+ </AdsTooltip>
73
+ <UIcon name="i-lucide-chevron-down" class="size-4 shrink-0 text-base" :class="chevronClass" />
74
+ </button>
75
+
76
+ <template #content>
77
+ <AdsMonthPicker
78
+ v-if="type === 'month'"
79
+ v-model="monthModel"
80
+ @pick="onPick"
81
+ />
82
+ <AdsSelectPanel
83
+ v-else
84
+ v-model="model"
85
+ v-model:query="query"
86
+ :type="listType"
87
+ :options="options"
88
+ :searchable="showSearch"
89
+ :select-all="showSelectAll"
90
+ :select-all-label="selectAllLabel"
91
+ :empty-label="emptyLabel"
92
+ :search-placeholder="searchPlaceholder"
93
+ :list-label="label || 'Opções'"
94
+ :width-class="panelWidthClass"
95
+ :add-label="addLabel"
96
+ @pick="onPick"
97
+ @add="onAdd"
98
+ />
99
+ </template>
100
+ </UPopover>
101
+
102
+ <p
103
+ v-if="supportText"
104
+ :id="supportId"
105
+ class="text-[length:var(--ads-filter-label-size)] leading-[1.2] text-[var(--ads-text-secondary)]"
106
+ >
107
+ {{ supportText }}
108
+ </p>
109
+ </div>
110
+ </template>
111
+
112
+ <script setup lang="ts">
113
+ import { computed, ref, useId, watch } from "vue";
114
+ import AdsSelectPanel from "./AdsSelectPanel.vue";
115
+ import AdsMonthPicker from "./AdsMonthPicker.vue";
116
+ import AdsTooltip from "./AdsTooltip.vue";
117
+ import {
118
+ filterLabelNeedsTooltip,
119
+ filterTriggerLabel,
120
+ type AdsFilterOption,
121
+ type AdsFilterType,
122
+ } from "../utils/ads-filter-select";
123
+
124
+ const props = withDefaults(
125
+ defineProps<{
126
+ type: AdsFilterType;
127
+ label?: string;
128
+ hint?: string;
129
+ error?: string;
130
+ placeholder?: string;
131
+ disabled?: boolean;
132
+ options?: AdsFilterOption[];
133
+ /** `null` = padrão do tipo (checkbox busca e seleciona todos). */
134
+ searchable?: boolean | null;
135
+ selectAll?: boolean | null;
136
+ selectAllLabel?: string;
137
+ allSelectedLabel?: string;
138
+ emptyLabel?: string;
139
+ searchPlaceholder?: string;
140
+ /** O gatilho ocupa a largura do campo, como um select de formulário. */
141
+ block?: boolean;
142
+ /** O valor veio de uma sugestão de IA. Quem usa limpa a marca quando a pessoa altera a seleção. */
143
+ aiSuggestion?: boolean;
144
+ /** Mostra só a lista, sem gatilho nem popover. */
145
+ inline?: boolean;
146
+ /** Largura da lista. Padrão: --ads-select-panel-width (320px). */
147
+ panelWidthClass?: string;
148
+ /**
149
+ * Ação de cadastrar no rodapé da lista, com ícone de adicionar. `{query}` vira a busca atual,
150
+ * ex.: "Cadastrar {query}". Sem valor, a ação não aparece.
151
+ */
152
+ addLabel?: string;
153
+ }>(),
154
+ {
155
+ placeholder: "Selecione",
156
+ disabled: false,
157
+ options: () => [],
158
+ searchable: null,
159
+ selectAll: null,
160
+ selectAllLabel: "Selecionar todos",
161
+ allSelectedLabel: "Todos selecionados",
162
+ emptyLabel: "Nenhum resultado",
163
+ searchPlaceholder: "Pesquisar",
164
+ block: false,
165
+ aiSuggestion: false,
166
+ inline: false,
167
+ panelWidthClass: "w-[var(--ads-select-panel-width)] max-w-full",
168
+ },
169
+ );
170
+
171
+ const model = defineModel<string | string[]>({ required: true });
172
+
173
+ const emit = defineEmits<{
174
+ /** Escolha feita: no radio e no month o popover fecha. */
175
+ pick: [value: string | string[]];
176
+ /** Ação de cadastrar. Recebe a busca atual. No popover, a lista fecha antes do evento. */
177
+ add: [query: string];
178
+ }>();
179
+
180
+ defineSlots<{
181
+ /** Gatilho próprio (botão, chip…). Recebe open, label e hasValue. */
182
+ trigger?: (props: { open: boolean; label: string; hasValue: boolean }) => unknown;
183
+ }>();
184
+
185
+ const isOpen = ref(false);
186
+ const query = ref("");
187
+ const labelId = useId();
188
+ const supportId = useId();
189
+
190
+ const showSearch = computed(() =>
191
+ props.searchable === null ? props.type === "checkbox" : props.searchable,
192
+ );
193
+ const showSelectAll = computed(() =>
194
+ props.selectAll === null ? props.type === "checkbox" : props.selectAll,
195
+ );
196
+ const listType = computed(() => (props.type === "radio" ? "radio" : "checkbox"));
197
+
198
+ const supportText = computed(() => props.error || props.hint || "");
199
+
200
+ const hasValue = computed(() => {
201
+ if (Array.isArray(model.value)) return model.value.length > 0;
202
+ return model.value.length > 0;
203
+ });
204
+
205
+ const fieldState = computed(() => {
206
+ if (props.disabled) return "disabled";
207
+ if (props.error) return "error";
208
+ if (isOpen.value) return "open";
209
+ if (props.aiSuggestion) return "ai";
210
+ if (hasValue.value) return "selected";
211
+ return "default";
212
+ });
213
+
214
+ const fieldClass = computed(() => {
215
+ if (fieldState.value === "disabled") {
216
+ return "border border-[var(--ads-filter-disabled-border)] bg-[var(--ads-filter-disabled-background)] text-[var(--ads-filter-disabled-text)]";
217
+ }
218
+ if (fieldState.value === "error") {
219
+ return "border-(length:--ads-border-width-slim) border-[var(--ads-filter-error-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
220
+ }
221
+ if (fieldState.value === "open") {
222
+ return "border-(length:--ads-border-width-slim) border-[var(--ads-filter-focus-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
223
+ }
224
+ if (fieldState.value === "ai") {
225
+ return "border border-[var(--ads-text-ai)] bg-[var(--ads-surface-ai)] hover:border-[var(--ads-filter-hover-border)] text-[var(--ads-filter-text)]";
226
+ }
227
+ if (fieldState.value === "selected") {
228
+ return "border border-[var(--ads-filter-border)] hover:border-[var(--ads-filter-hover-border)] bg-ads-neutro-claro-20 text-[var(--ads-filter-text)]";
229
+ }
230
+ return "border border-[var(--ads-filter-border)] hover:border-[var(--ads-filter-hover-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
231
+ });
232
+
233
+ const chevronClass = computed(() => {
234
+ if (fieldState.value === "disabled") return "text-ads-neutro-medio-60";
235
+ if (fieldState.value === "selected" || fieldState.value === "ai") return "text-ads-neutro-escuro-500";
236
+ return "text-ads-neutro-medio-100";
237
+ });
238
+
239
+ const triggerLabel = computed(() =>
240
+ filterTriggerLabel({
241
+ type: props.type,
242
+ value: model.value,
243
+ options: props.options,
244
+ placeholder: props.placeholder,
245
+ allSelectedLabel: props.allSelectedLabel,
246
+ }),
247
+ );
248
+
249
+ const triggerHasTooltip = computed(() => filterLabelNeedsTooltip(triggerLabel.value));
250
+
251
+ const monthModel = computed({
252
+ get: () => (typeof model.value === "string" ? model.value : ""),
253
+ set: (value: string) => {
254
+ model.value = value;
255
+ },
256
+ });
257
+
258
+ const onPick = () => {
259
+ isOpen.value = false;
260
+ emit("pick", model.value);
261
+ };
262
+
263
+ const onAdd = (text: string) => {
264
+ // No popover, a lista fecha: o cadastro costuma abrir um formulário ou modal por cima.
265
+ if (!props.inline) isOpen.value = false;
266
+ emit("add", text);
267
+ };
268
+
269
+ watch(isOpen, (open) => {
270
+ if (!open) query.value = "";
271
+ });
272
+
273
+ watch(
274
+ () => props.disabled,
275
+ (disabled) => {
276
+ if (disabled) isOpen.value = false;
277
+ },
278
+ );
279
+
280
+ const popoverUi = {
281
+ content: "z-50 w-auto overflow-visible bg-transparent p-0 shadow-none ring-0",
282
+ };
283
+ </script>