ads-nuxt 0.0.0-stage → 0.1.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 (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -3
  3. package/app/app.config.ts +25 -0
  4. package/app/assets/ads/checkbox-check.svg +5 -0
  5. package/app/assets/ads/checkbox-minus.svg +5 -0
  6. package/app/assets/animations/Error.gif +0 -0
  7. package/app/assets/animations/Loading.gif +0 -0
  8. package/app/assets/animations/Search.gif +0 -0
  9. package/app/assets/animations/Success.gif +0 -0
  10. package/app/assets/brand/farmarcas.svg +6 -0
  11. package/app/assets/brand/radar.svg +9 -0
  12. package/app/assets/css/ads-colors.css +246 -0
  13. package/app/assets/css/component-tokens.css +403 -0
  14. package/app/assets/css/main.css +617 -0
  15. package/app/components/AdsBadge.vue +48 -0
  16. package/app/components/AdsBroadcast.vue +45 -0
  17. package/app/components/AdsButton.vue +569 -0
  18. package/app/components/AdsButtonGroup.vue +39 -0
  19. package/app/components/AdsButtonMenu.vue +48 -0
  20. package/app/components/AdsCard.vue +117 -0
  21. package/app/components/AdsCharttip.vue +78 -0
  22. package/app/components/AdsCheckbox.vue +77 -0
  23. package/app/components/AdsDatePicker.vue +473 -0
  24. package/app/components/AdsDropdownMenu.vue +19 -0
  25. package/app/components/AdsEmptyState.vue +58 -0
  26. package/app/components/AdsFarmarcasPill.vue +74 -0
  27. package/app/components/AdsFeatureCard.vue +217 -0
  28. package/app/components/AdsFileCard.vue +101 -0
  29. package/app/components/AdsFilterDropdown.vue +174 -0
  30. package/app/components/AdsFilterOption.vue +72 -0
  31. package/app/components/AdsFilterSelect.vue +202 -0
  32. package/app/components/AdsFooter.vue +25 -0
  33. package/app/components/AdsInput.vue +143 -0
  34. package/app/components/AdsListDropdown.vue +44 -0
  35. package/app/components/AdsLoading.vue +109 -0
  36. package/app/components/AdsMenuBar.vue +103 -0
  37. package/app/components/AdsMetricCard.vue +119 -0
  38. package/app/components/AdsMiniPill.vue +40 -0
  39. package/app/components/AdsModal.vue +157 -0
  40. package/app/components/AdsMonthPicker.vue +80 -0
  41. package/app/components/AdsNavbarApp.vue +67 -0
  42. package/app/components/AdsNavbarDesk.vue +62 -0
  43. package/app/components/AdsNotabilityPill.vue +27 -0
  44. package/app/components/AdsNumberInput.vue +166 -0
  45. package/app/components/AdsPagination.vue +91 -0
  46. package/app/components/AdsPill.vue +92 -0
  47. package/app/components/AdsProductTag.vue +61 -0
  48. package/app/components/AdsRadio.vue +70 -0
  49. package/app/components/AdsSearchInput.vue +113 -0
  50. package/app/components/AdsSegmentedTabs.vue +28 -0
  51. package/app/components/AdsSideMenu.vue +101 -0
  52. package/app/components/AdsSmalltip.vue +44 -0
  53. package/app/components/AdsSteptip.vue +101 -0
  54. package/app/components/AdsSwitch.vue +59 -0
  55. package/app/components/AdsTable.vue +100 -0
  56. package/app/components/AdsTableToolbar.vue +44 -0
  57. package/app/components/AdsTabs.vue +51 -0
  58. package/app/components/AdsTextarea.vue +109 -0
  59. package/app/components/AdsToast.vue +181 -0
  60. package/app/components/AdsTooltip.vue +66 -0
  61. package/app/components/InvertedTooltip.vue +40 -0
  62. package/app/components/OverlayLoading.vue +173 -0
  63. package/app/components/ProgressBarLoading.vue +256 -0
  64. package/app/composables/useOverlayLoading.ts +66 -0
  65. package/app/constants/ads-color-swatches.ts +239 -0
  66. package/app/locale/pt-br.ts +6 -0
  67. package/app/plugins/ads-toast.client.ts +24 -0
  68. package/app/theme/ads-theme.ts +370 -0
  69. package/app/theme/ads-tokens.ts +379 -0
  70. package/app/theme/component-tokens.json +402 -0
  71. package/app/theme/component-tokens.ts +815 -0
  72. package/app/types/overlay-loading.types.ts +26 -0
  73. package/app/utils/ads-filter-select.ts +172 -0
  74. package/app/utils/ads-table.ts +204 -0
  75. package/app/utils/calendar-date.ts +128 -0
  76. package/app/utils/category-role.ts +45 -0
  77. package/app/utils/money.ts +77 -0
  78. package/app/utils/notability.ts +8 -0
  79. package/app/utils/parser.ts +134 -0
  80. package/app/utils/percentage.ts +54 -0
  81. package/nuxt.config.ts +32 -0
  82. package/package.json +46 -6
@@ -0,0 +1,217 @@
1
+ <template>
2
+ <component
3
+ :is="to ? NuxtLink : 'button'"
4
+ v-bind="rootAttrs"
5
+ class="group flex w-[var(--ads-feature-width)] max-w-full flex-col gap-[var(--ads-feature-gap)] rounded-[var(--ads-feature-radius)] border border-[var(--ads-feature-border)] bg-[var(--ads-feature-background)] p-[var(--ads-feature-padding)] text-left transition-colors duration-150 ease-out focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-feature-accent-hover)]"
6
+ :class="disabled ? 'cursor-not-allowed' : 'hover:border-[var(--ads-feature-accent-hover)] focus-visible:border-[var(--ads-feature-accent-hover)]'"
7
+ :style="accentStyle"
8
+ @click="onClick"
9
+ >
10
+ <span class="flex items-start gap-3">
11
+ <span
12
+ class="grid size-[var(--ads-feature-icon-box)] shrink-0 place-items-center rounded-[var(--ads-radius-sm)]"
13
+ :class="iconBoxClass"
14
+ >
15
+ <UIcon :name="icon" class="size-6" />
16
+ </span>
17
+ <span class="min-w-0 flex-1">
18
+ <span class="block text-[length:var(--ads-feature-title-size)] font-bold leading-[1.3]" :class="titleClass">
19
+ {{ title }}
20
+ </span>
21
+ <InvertedTooltip
22
+ :text="description"
23
+ :disabled="!isDescriptionTruncated"
24
+ >
25
+ <span
26
+ ref="descriptionEl"
27
+ class="mt-1 block line-clamp-2 text-[length:var(--ads-feature-body-size)] leading-relaxed"
28
+ :class="descriptionClass"
29
+ >
30
+ {{ description }}
31
+ </span>
32
+ </InvertedTooltip>
33
+ </span>
34
+ <UIcon
35
+ v-if="!disabled"
36
+ name="i-lucide-arrow-right"
37
+ class="size-5 shrink-0 text-[var(--ads-border-icon-support)] transition-colors duration-150 ease-out group-hover:text-[var(--ads-feature-accent-hover)] group-focus-visible:text-[var(--ads-feature-accent-hover)]"
38
+ />
39
+ </span>
40
+
41
+ <AdsPill
42
+ v-if="disabled"
43
+ class="mt-auto"
44
+ tone="secondary"
45
+ status="neutral"
46
+ label="Em breve"
47
+ />
48
+ <span v-else-if="hasFooter" class="mt-auto flex flex-wrap items-center gap-2">
49
+ <AdsPill
50
+ v-for="badge in badges"
51
+ :key="badge.label"
52
+ :tone="badge.tone ?? 'secondary'"
53
+ :status="badge.status ?? 'default'"
54
+ :label="badge.label"
55
+ />
56
+ <span
57
+ v-if="footerText"
58
+ class="inline-flex items-center gap-1 text-xs text-[var(--ads-text-secondary)]"
59
+ >
60
+ <UIcon v-if="footerIcon" :name="footerIcon" class="size-3.5" />
61
+ {{ footerText }}
62
+ </span>
63
+ </span>
64
+ </component>
65
+ </template>
66
+
67
+ <script setup lang="ts">
68
+ import { computed, nextTick, onMounted, ref, watch } from "vue";
69
+ import type { RouteLocationRaw } from "vue-router";
70
+ import { useResizeObserver } from "@vueuse/core";
71
+ import { NuxtLink } from "#components";
72
+ import AdsPill from "./AdsPill.vue";
73
+ import type { AdsPillStatus, AdsPillTone } from "./AdsPill.vue";
74
+ import InvertedTooltip from "./InvertedTooltip.vue";
75
+
76
+ export interface AdsFeatureCardBadge {
77
+ label: string;
78
+ tone?: AdsPillTone;
79
+ status?: AdsPillStatus;
80
+ }
81
+
82
+ /** Fundo e texto do AdsPill secondary. Primary segue o ícone do próprio card no catálogo. */
83
+ export type AdsFeatureCardColor =
84
+ | "primary"
85
+ | "success"
86
+ | "attention"
87
+ | "warning"
88
+ | "new"
89
+ | "blocked"
90
+ | "innovation";
91
+
92
+ const iconBoxByColor: Record<AdsFeatureCardColor, string> = {
93
+ primary: "bg-[var(--ads-button-secondary)] text-[var(--ads-text-brand)]",
94
+ success: "bg-[var(--ads-status-success-100)] text-[var(--ads-status-success-800)]",
95
+ attention: "bg-[var(--ads-status-attention-100)] text-[var(--ads-status-attention-800)]",
96
+ warning: "bg-[var(--ads-status-warning-100)] text-[var(--ads-status-warning-800)]",
97
+ new: "bg-[var(--ads-status-new-100)] text-[var(--ads-status-new-800)]",
98
+ blocked: "bg-[var(--ads-status-void-100)] text-[var(--ads-status-void-800)]",
99
+ innovation: "bg-[var(--ads-status-innovation-100)] text-[var(--ads-status-innovation-800)]",
100
+ };
101
+
102
+ /**
103
+ * Cor de acento usada NO HOVER para borda e seta (ambas a mesma cor).
104
+ * Em repouso: borda = --ads-feature-border (neutro), seta = --ads-border-icon-support (cinza).
105
+ */
106
+ const accentByColor: Record<AdsFeatureCardColor, string> = {
107
+ // Hover: borda e seta no passo 500 da mesma escala do card.
108
+ primary: "var(--color-primary-500)",
109
+ success: "var(--ads-status-success-500)",
110
+ attention: "var(--ads-status-attention-500)",
111
+ warning: "var(--ads-status-warning-500)",
112
+ new: "var(--ads-status-new-500)",
113
+ blocked: "var(--ads-status-void-500)",
114
+ innovation: "var(--ads-status-innovation-500)",
115
+ };
116
+
117
+ const props = withDefaults(
118
+ defineProps<{
119
+ title: string;
120
+ description: string;
121
+ icon: string;
122
+ /** Cor do ícone, da seta e da borda. Sem valor, fica na cor da marca. */
123
+ color?: AdsFeatureCardColor;
124
+ /** Vira link. Sem valor, continua botão. */
125
+ to?: RouteLocationRaw;
126
+ disabled?: boolean;
127
+ badges?: AdsFeatureCardBadge[];
128
+ footerIcon?: string;
129
+ footerText?: string;
130
+ }>(),
131
+ {
132
+ color: "primary",
133
+ to: undefined,
134
+ disabled: false,
135
+ badges: undefined,
136
+ footerIcon: undefined,
137
+ footerText: undefined,
138
+ },
139
+ );
140
+
141
+ const emit = defineEmits<{
142
+ click: [event: MouseEvent];
143
+ }>();
144
+
145
+ const hasFooter = computed(
146
+ () => (props.badges?.length ?? 0) > 0 || Boolean(props.footerText),
147
+ );
148
+
149
+ const descriptionEl = ref<HTMLElement | null>(null);
150
+ const isDescriptionTruncated = ref(false);
151
+
152
+ const syncDescriptionTruncation = () => {
153
+ const element = descriptionEl.value;
154
+ if (!element) {
155
+ isDescriptionTruncated.value = false;
156
+ return;
157
+ }
158
+ isDescriptionTruncated.value = element.scrollHeight - element.clientHeight > 1;
159
+ };
160
+
161
+ useResizeObserver(descriptionEl, syncDescriptionTruncation);
162
+
163
+ onMounted(() => {
164
+ void nextTick(syncDescriptionTruncation);
165
+ });
166
+
167
+ watch(
168
+ () => props.description,
169
+ () => {
170
+ void nextTick(syncDescriptionTruncation);
171
+ },
172
+ );
173
+
174
+ const rootAttrs = computed(() =>
175
+ props.to
176
+ ? {
177
+ to: props.to,
178
+ tabindex: props.disabled ? -1 : undefined,
179
+ "aria-disabled": props.disabled || undefined,
180
+ }
181
+ : {
182
+ type: "button" as const,
183
+ disabled: props.disabled,
184
+ },
185
+ );
186
+
187
+ const accentStyle = computed(() => {
188
+ if (props.disabled) {
189
+ return {};
190
+ }
191
+ return {
192
+ "--ads-feature-accent-hover": accentByColor[props.color],
193
+ };
194
+ });
195
+
196
+ const iconBoxClass = computed(() =>
197
+ props.disabled
198
+ ? "bg-[var(--ads-button-secondary-disabled)] text-[var(--ads-text-tertiary)]"
199
+ : iconBoxByColor[props.color],
200
+ );
201
+
202
+ const titleClass = computed(() =>
203
+ props.disabled ? "text-[var(--ads-text-tertiary)]" : "text-[var(--ads-feature-title)]",
204
+ );
205
+
206
+ const descriptionClass = computed(() =>
207
+ props.disabled ? "text-[var(--ads-text-tertiary)]" : "text-[var(--ads-feature-body)]",
208
+ );
209
+
210
+ const onClick = (event: MouseEvent) => {
211
+ if (!props.disabled) {
212
+ emit("click", event);
213
+ return;
214
+ }
215
+ event.preventDefault();
216
+ };
217
+ </script>
@@ -0,0 +1,101 @@
1
+ <template>
2
+ <div
3
+ class="flex min-h-[var(--ads-file-min-height)] flex-col justify-center gap-2 rounded-[var(--ads-file-radius)] border px-[var(--ads-file-padding-x)] py-[var(--ads-file-padding-y)]"
4
+ :class="surface.card"
5
+ :role="status === 'error' ? 'alert' : 'status'"
6
+ >
7
+ <p
8
+ v-if="message"
9
+ class="text-[length:var(--ads-file-title-size)] font-semibold leading-5"
10
+ :class="surface.message"
11
+ >
12
+ {{ message }}
13
+ </p>
14
+ <div class="flex items-center justify-between gap-3">
15
+ <div class="flex min-w-0 items-center gap-2">
16
+ <span
17
+ class="inline-flex size-[var(--ads-file-icon-box)] shrink-0 items-center justify-center rounded-[var(--ads-file-radius)]"
18
+ :class="surface.icon"
19
+ aria-hidden="true"
20
+ >
21
+ <UIcon :name="resolvedIcon" class="size-4" />
22
+ </span>
23
+ <div class="min-w-0">
24
+ <InvertedTooltip :text="name">
25
+ <p class="truncate text-[length:var(--ads-file-title-size)] font-semibold leading-5 text-[var(--ads-text-primary)]">
26
+ {{ name }}
27
+ </p>
28
+ </InvertedTooltip>
29
+ <p
30
+ v-if="detail"
31
+ class="text-[length:var(--ads-file-detail-size)] font-normal leading-4 text-[var(--ads-text-secondary)]"
32
+ >
33
+ {{ detail }}
34
+ </p>
35
+ </div>
36
+ </div>
37
+ <AdsButton
38
+ v-if="removable"
39
+ type="unfilled"
40
+ color="neutral"
41
+ size="sm"
42
+ icon="i-lucide-trash-2"
43
+ :aria-label="removeLabel"
44
+ @click="emit('remove')"
45
+ />
46
+ </div>
47
+ </div>
48
+ </template>
49
+
50
+ <script setup lang="ts">
51
+ import { computed } from "vue";
52
+ import AdsButton from "./AdsButton.vue";
53
+ import InvertedTooltip from "./InvertedTooltip.vue";
54
+
55
+ export type AdsFileCardStatus = "success" | "error";
56
+
57
+ const props = withDefaults(
58
+ defineProps<{
59
+ /** Nome do arquivo. */
60
+ name: string;
61
+ /** Linha de apoio, como o tamanho. */
62
+ detail?: string;
63
+ status?: AdsFileCardStatus;
64
+ /** Texto do problema, acima do arquivo. */
65
+ message?: string;
66
+ icon?: string;
67
+ removable?: boolean;
68
+ removeLabel?: string;
69
+ }>(),
70
+ {
71
+ detail: undefined,
72
+ status: "success",
73
+ message: undefined,
74
+ icon: undefined,
75
+ removable: false,
76
+ removeLabel: "Remover arquivo",
77
+ },
78
+ );
79
+
80
+ const emit = defineEmits<{
81
+ remove: [];
82
+ }>();
83
+
84
+ const surfaces: Record<AdsFileCardStatus, { card: string; icon: string; message: string; glyph: string }> = {
85
+ success: {
86
+ card: "border-[var(--ads-status-success-500)] bg-[color-mix(in_srgb,var(--ads-status-success-100)_var(--ads-opacity-light),transparent)]",
87
+ icon: "bg-[var(--ads-status-success-100)] text-[var(--ads-status-success-800)]",
88
+ message: "text-[var(--ads-status-success-800)]",
89
+ glyph: "i-lucide-cloud-check",
90
+ },
91
+ error: {
92
+ card: "border-[var(--ads-status-warning-500)] bg-[color-mix(in_srgb,var(--ads-status-warning-100)_var(--ads-opacity-light),transparent)]",
93
+ icon: "bg-[var(--ads-status-warning-100)] text-[var(--ads-status-warning-500)]",
94
+ message: "text-[var(--ads-status-warning-500)]",
95
+ glyph: "i-lucide-ban",
96
+ },
97
+ };
98
+
99
+ const surface = computed(() => surfaces[props.status]);
100
+ const resolvedIcon = computed(() => props.icon || surface.value.glyph);
101
+ </script>
@@ -0,0 +1,174 @@
1
+ <template>
2
+ <div
3
+ class="overflow-hidden rounded-[var(--ads-radius-sm)] border border-ads-neutro-claro-50 bg-[var(--ads-surface-card)] shadow-[var(--ads-shadow-level-1)]"
4
+ :class="widthClass"
5
+ >
6
+ <div v-if="searchable" class="px-4 pt-4 pb-2">
7
+ <UInput
8
+ v-model="query"
9
+ :placeholder="searchPlaceholder"
10
+ aria-label="Pesquisar opções"
11
+ icon="i-lucide-search"
12
+ color="neutral"
13
+ variant="outline"
14
+ size="md"
15
+ class="w-full"
16
+ :ui="searchFieldUi"
17
+ >
18
+ <template v-if="query" #trailing>
19
+ <button
20
+ type="button"
21
+ class="text-[var(--ads-text-secondary)]"
22
+ aria-label="Limpar busca"
23
+ @click="query = ''"
24
+ >
25
+ <UIcon name="i-lucide-x" class="size-4" />
26
+ </button>
27
+ </template>
28
+ </UInput>
29
+ </div>
30
+
31
+ <p
32
+ v-if="groups.empty"
33
+ class="flex h-16 items-center ps-6 text-sm leading-[1.3] text-[var(--ads-text-secondary)]"
34
+ >
35
+ {{ emptyLabel }}
36
+ </p>
37
+
38
+ <template v-else>
39
+ <div v-if="groups.exact.length">
40
+ <template v-for="(option, index) in groups.exact" :key="option.value">
41
+ <AdsFilterOption
42
+ :mode="type"
43
+ :label="option.label"
44
+ :selected="isSelected(option.value)"
45
+ @select="onSelect(option.value)"
46
+ />
47
+ <div
48
+ v-if="index < groups.exact.length - 1"
49
+ class="h-px bg-[var(--ads-button-secondary-disabled)]"
50
+ :class="dividerInsetClass"
51
+ role="presentation"
52
+ />
53
+ </template>
54
+ </div>
55
+
56
+ <div
57
+ v-if="showSelectAll || groups.matches.length"
58
+ class="overflow-y-auto overscroll-contain [scrollbar-color:var(--color-ads-neutro-claro-50)_transparent] [scrollbar-width:thin]"
59
+ :class="
60
+ groups.exact.length
61
+ ? 'max-h-[244px] border-t-[0.5px] border-[var(--ads-border-icon)]'
62
+ : 'max-h-[294px]'
63
+ "
64
+ >
65
+ <div :role="type === 'radio' ? 'listbox' : 'group'" :aria-label="listLabel">
66
+ <template v-if="showSelectAll">
67
+ <AdsFilterOption
68
+ mode="checkbox"
69
+ :label="selectAllLabel"
70
+ :selected="checkState === 'all'"
71
+ :indeterminate="checkState === 'partial'"
72
+ @select="onSelectAll"
73
+ />
74
+ <div
75
+ v-if="groups.matches.length"
76
+ class="h-px bg-[var(--ads-button-secondary-disabled)]"
77
+ :class="dividerInsetClass"
78
+ role="presentation"
79
+ />
80
+ </template>
81
+ <template v-for="(option, index) in groups.matches" :key="option.value">
82
+ <AdsFilterOption
83
+ :mode="type"
84
+ :label="option.label"
85
+ :selected="isSelected(option.value)"
86
+ @select="onSelect(option.value)"
87
+ />
88
+ <div
89
+ v-if="index < groups.matches.length - 1"
90
+ class="h-px bg-[var(--ads-button-secondary-disabled)]"
91
+ :class="dividerInsetClass"
92
+ role="presentation"
93
+ />
94
+ </template>
95
+ </div>
96
+ </div>
97
+ </template>
98
+ </div>
99
+ </template>
100
+
101
+ <script setup lang="ts">
102
+ import { computed } from "vue";
103
+ import AdsFilterOption from "./AdsFilterOption.vue";
104
+ import {
105
+ groupFilterOptions,
106
+ selectionCheckState,
107
+ toggleFilterValue,
108
+ toggleSelectAll,
109
+ type AdsFilterOption as FilterOption,
110
+ } from "../utils/ads-filter-select";
111
+
112
+ const props = withDefaults(
113
+ defineProps<{
114
+ type: "checkbox" | "radio";
115
+ options: FilterOption[];
116
+ searchable?: boolean;
117
+ selectAll?: boolean;
118
+ selectAllLabel?: string;
119
+ emptyLabel?: string;
120
+ searchPlaceholder?: string;
121
+ listLabel?: string;
122
+ widthClass?: string;
123
+ }>(),
124
+ {
125
+ searchable: true,
126
+ selectAll: true,
127
+ selectAllLabel: "Selecionar todos",
128
+ emptyLabel: "Nenhum resultado",
129
+ searchPlaceholder: "Pesquisar",
130
+ listLabel: "Opções",
131
+ widthClass: "w-[270px]",
132
+ },
133
+ );
134
+
135
+ const model = defineModel<string | string[]>({ required: true });
136
+ const query = defineModel<string>("query", { default: "" });
137
+ const emit = defineEmits<{ pick: [] }>();
138
+
139
+ const groups = computed(() => groupFilterOptions(props.options, query.value));
140
+ const selectedList = computed(() =>
141
+ Array.isArray(model.value) ? model.value : model.value ? [model.value] : [],
142
+ );
143
+ const checkState = computed(() =>
144
+ selectionCheckState(selectedList.value, props.options),
145
+ );
146
+ const showSelectAll = computed(
147
+ () => props.type === "checkbox" && props.selectAll && query.value.trim() === "",
148
+ );
149
+ /** O separador começa no mesmo eixo do conteúdo da opção: texto (rádio) ou caixa (checkbox). */
150
+ const dividerInsetClass = computed(() => (props.type === "checkbox" ? "mx-4" : "mx-6"));
151
+
152
+ const isSelected = (value: string) => selectedList.value.includes(value);
153
+
154
+ const onSelect = (value: string) => {
155
+ if (props.type === "radio") {
156
+ model.value = value;
157
+ emit("pick");
158
+ return;
159
+ }
160
+ model.value = toggleFilterValue(selectedList.value, value);
161
+ };
162
+
163
+ const onSelectAll = () => {
164
+ model.value = toggleSelectAll(selectedList.value, props.options);
165
+ };
166
+
167
+ /**
168
+ * Busca do painel ADS: pílula.
169
+ */
170
+ const searchFieldUi = {
171
+ base: "h-10 rounded-[var(--ads-radius-pill)] bg-[var(--ads-surface-card)] text-sm text-[var(--ads-text-secondary)] !outline-none ring-1 ring-inset ring-ads-neutro-claro-50 enabled:hover:ring-[var(--ads-filter-hover-border)] placeholder:text-[var(--ads-text-tertiary)] focus-visible:!outline-none focus-visible:ring-(length:--ads-border-width-slim) focus-visible:ring-[var(--ads-text-brand)]",
172
+ leadingIcon: "text-[var(--ads-text-tertiary)]",
173
+ };
174
+ </script>
@@ -0,0 +1,72 @@
1
+ <template>
2
+ <button
3
+ type="button"
4
+ class="flex h-[50px] w-full items-center gap-2 py-4 text-left hover:bg-neutral-100"
5
+ :class="mode === 'checkbox' ? 'ps-4' : 'ps-6'"
6
+ :role="mode === 'checkbox' ? 'checkbox' : 'option'"
7
+ :aria-checked="checkedState === undefined ? undefined : String(checkedState)"
8
+ :aria-selected="mode === 'radio' ? String(selected) : undefined"
9
+ @click="emit('select')"
10
+ >
11
+ <span
12
+ v-if="mode === 'checkbox'"
13
+ class="flex size-4 shrink-0 items-center justify-center rounded-[var(--ads-radius-xsm)] border-2 border-[var(--ads-text-brand)]"
14
+ :class="selected || indeterminate ? 'bg-[var(--ads-surface-brand)]' : 'bg-[var(--ads-surface-card)]'"
15
+ >
16
+ <UIcon
17
+ v-if="indeterminate"
18
+ name="i-lucide-minus"
19
+ class="size-3 text-[var(--ads-text-contrast)]"
20
+ />
21
+ <UIcon
22
+ v-else-if="selected"
23
+ name="i-lucide-check"
24
+ class="size-3 text-[var(--ads-text-contrast)]"
25
+ />
26
+ </span>
27
+ <InvertedTooltip
28
+ :text="label"
29
+ :disabled="!needsTooltip"
30
+ :content="{ side: 'bottom', align: 'start', sideOffset: 4 }"
31
+ >
32
+ <span
33
+ class="block min-w-0 truncate text-sm leading-[1.3] text-[var(--ads-text-secondary)]"
34
+ :class="mode === 'radio' && selected ? 'font-bold' : 'font-normal'"
35
+ >
36
+ {{ displayLabel }}
37
+ </span>
38
+ </InvertedTooltip>
39
+ </button>
40
+ </template>
41
+
42
+ <script setup lang="ts">
43
+ import { computed } from "vue";
44
+ import InvertedTooltip from "./InvertedTooltip.vue";
45
+ import {
46
+ filterLabelNeedsTooltip,
47
+ truncateFilterLabel,
48
+ } from "../utils/ads-filter-select";
49
+
50
+ const props = withDefaults(
51
+ defineProps<{
52
+ label: string;
53
+ mode: "checkbox" | "radio";
54
+ selected?: boolean;
55
+ indeterminate?: boolean;
56
+ }>(),
57
+ {
58
+ selected: false,
59
+ indeterminate: false,
60
+ },
61
+ );
62
+
63
+ const emit = defineEmits<{ select: [] }>();
64
+
65
+ const displayLabel = computed(() => truncateFilterLabel(props.label));
66
+ const needsTooltip = computed(() => filterLabelNeedsTooltip(props.label));
67
+ const checkedState = computed(() => {
68
+ if (props.mode !== "checkbox") return undefined;
69
+ if (props.indeterminate) return "mixed";
70
+ return props.selected;
71
+ });
72
+ </script>