ads-nuxt 0.5.1 → 0.6.1

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.
@@ -1,9 +1,13 @@
1
1
  <template>
2
2
  <span
3
- class="inline-flex shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full text-center leading-[1.2] whitespace-nowrap"
4
- :class="isBroadcast ? [broadcastSizeClass, broadcastSurface.shell] : [sizeClass, surfaceClass]"
3
+ class="inline-flex items-center whitespace-nowrap"
4
+ :class="isText
5
+ ? textClass
6
+ : isBroadcast
7
+ ? [broadcastSizeClass, broadcastSurface.shell, 'shrink-0 justify-center gap-1 overflow-hidden rounded-full text-center leading-[1.2]']
8
+ : [sizeClass, surfaceClass, 'shrink-0 justify-center gap-1 overflow-hidden rounded-full text-center leading-[1.2]']"
5
9
  >
6
- <!-- Broadcast: ponto na cor do status antes do texto -->
10
+ <!-- Broadcast: ponto na cor da pill antes do texto -->
7
11
  <span v-if="isBroadcast" class="flex size-3.5 shrink-0 items-center justify-center" aria-hidden="true">
8
12
  <span class="size-[var(--ads-broadcast-mark)] rounded-full" :class="broadcastSurface.mark" />
9
13
  </span>
@@ -11,7 +15,7 @@
11
15
  v-if="icon"
12
16
  :name="icon"
13
17
  class="shrink-0"
14
- :class="[iconSizeClass, iconClass]"
18
+ :class="[iconSizeClass, isText ? 'ads-icon-xxs' : '', iconClass]"
15
19
  aria-hidden="true"
16
20
  />
17
21
  {{ resolvedLabel }}
@@ -19,7 +23,7 @@
19
23
  v-if="trailingIcon"
20
24
  :name="trailingIcon"
21
25
  class="shrink-0"
22
- :class="iconSizeClass"
26
+ :class="[iconSizeClass, isText ? 'ads-icon-xxs' : '']"
23
27
  aria-hidden="true"
24
28
  />
25
29
  </span>
@@ -28,21 +32,26 @@
28
32
  <script setup lang="ts">
29
33
  import { computed } from "vue";
30
34
 
31
- export type AdsPillStatus = "default" | "success" | "attention" | "warning" | "new" | "blocked";
32
- export type AdsPillTone = "primary" | "secondary";
35
+ export type AdsPillColor = "default" | "success" | "attention" | "warning" | "new" | "blocked";
33
36
  export type AdsPillSize = "md" | "sm";
34
- /** default: pill sólida ou clara. broadcast: borda, ponto e texto na cor do status (warning ou success). */
35
- export type AdsPillVariant = "default" | "broadcast";
37
+ /** default: pill sólida. soft: pill clara. text: texto 14 regular, sem fundo. */
38
+ export type AdsPillVariant = "default" | "soft" | "text";
36
39
 
37
40
  const props = withDefaults(
38
41
  defineProps<{
39
42
  /**
40
- * broadcast: a pílula de transmissão (LIVE), com borda e ponto. Só tem as cores
41
- * warning e success; os outros status usam warning. Ignora tone e size.
43
+ * default é a pill sólida. soft é a variação clara.
44
+ * text: sem fundo, sem largura mínima, 14px regular.
45
+ * A cor é a do texto da `color`. Ignora size. O ícone, se houver, tem 16px.
42
46
  */
43
47
  variant?: AdsPillVariant;
44
- status?: AdsPillStatus;
45
- tone?: AdsPillTone;
48
+ /**
49
+ * Pílula de transmissão (LIVE): borda, ponto e texto na cor da `color`.
50
+ * Só warning e success; as outras cores usam warning. Ignora variant e size.
51
+ */
52
+ broadcast?: boolean;
53
+ /** Cor do estado: default, success, attention, warning, new ou blocked. */
54
+ color?: AdsPillColor;
46
55
  /** `md` = Pill normal (24px). `sm` = Small Pill (18px). Default `md`. */
47
56
  size?: AdsPillSize;
48
57
  label?: string;
@@ -54,15 +63,14 @@ const props = withDefaults(
54
63
  trailingIcon?: string;
55
64
  /**
56
65
  * Override avançado de fundo e texto (classes Tailwind).
57
- * Uso interno do atalho de domínio AdsNotabilityPill.
58
- * Em produção, prefira esses atalhos em vez desta prop.
66
+ * Em produção, prefira os atalhos de domínio em vez desta prop.
59
67
  */
60
68
  customSurface?: string;
61
69
  }>(),
62
70
  {
63
71
  variant: "default",
64
- status: "default",
65
- tone: "primary",
72
+ broadcast: false,
73
+ color: "default",
66
74
  size: "md",
67
75
  label: undefined,
68
76
  icon: undefined,
@@ -72,8 +80,8 @@ const props = withDefaults(
72
80
  },
73
81
  );
74
82
 
75
- const surfaces: Record<AdsPillTone, Record<AdsPillStatus, string>> = {
76
- primary: {
83
+ const surfaces: Record<Exclude<AdsPillVariant, "text">, Record<AdsPillColor, string>> = {
84
+ default: {
77
85
  default: "bg-[var(--ads-pill-primary-bg)] text-[var(--ads-pill-primary-text)]",
78
86
  success: "bg-[#15c57e] text-white",
79
87
  attention: "bg-[#e9a700] text-white",
@@ -81,7 +89,7 @@ const surfaces: Record<AdsPillTone, Record<AdsPillStatus, string>> = {
81
89
  new: "bg-[#05b4d8] text-white",
82
90
  blocked: "bg-[#0e1013] text-white",
83
91
  },
84
- secondary: {
92
+ soft: {
85
93
  default: "bg-[#e4f2ff] text-[#00389e]",
86
94
  success: "bg-[#c3ffe6] text-[#0e5a3b]",
87
95
  attention: "bg-[#ffe7b9] text-[#8f6600]",
@@ -91,17 +99,17 @@ const surfaces: Record<AdsPillTone, Record<AdsPillStatus, string>> = {
91
99
  },
92
100
  };
93
101
 
94
- const labels: Record<AdsPillTone, Record<AdsPillStatus, string>> = {
95
- primary: {
96
- default: "Primary",
102
+ const labels: Record<Exclude<AdsPillVariant, "text">, Record<AdsPillColor, string>> = {
103
+ default: {
104
+ default: "Default",
97
105
  success: "Success",
98
106
  attention: "Attention",
99
107
  warning: "Warning",
100
108
  new: "New!",
101
109
  blocked: "Blocked",
102
110
  },
103
- secondary: {
104
- default: "Secondary",
111
+ soft: {
112
+ default: "Soft",
105
113
  success: "Success",
106
114
  attention: "Attention",
107
115
  warning: "Warning",
@@ -117,9 +125,29 @@ const sizeClass = computed(() =>
117
125
  : "h-[var(--ads-pill-height)] px-[var(--ads-pill-padding-x)] py-1 text-[length:var(--ads-pill-font-size)] [font-weight:var(--ads-pill-weight)]",
118
126
  );
119
127
 
120
- const iconSizeClass = computed(() => (props.size === "sm" ? "size-3" : "size-3.5"));
128
+ /** Tinta de cada cor: a cor do texto da pill clara, sem o fundo. */
129
+ const textColors: Record<AdsPillColor, string> = {
130
+ default: "text-[var(--color-ads-radar-800)]",
131
+ success: "text-[var(--ads-status-success-800)]",
132
+ attention: "text-[var(--ads-status-attention-800)]",
133
+ warning: "text-[var(--ads-status-warning-800)]",
134
+ new: "text-[var(--ads-status-new-800)]",
135
+ blocked: "text-[var(--ads-status-void-800)]",
136
+ };
137
+
138
+ const textClass = computed(() => [
139
+ "gap-1 text-[length:var(--ads-font-size-xxs)] font-normal leading-[1.3]",
140
+ textColors[props.color],
141
+ ]);
142
+
143
+ const iconSizeClass = computed(() => {
144
+ if (props.variant === "text") return "size-[var(--ads-space-xxs)]";
145
+ return props.size === "sm" ? "size-3" : "size-3.5";
146
+ });
121
147
 
122
- const isBroadcast = computed(() => props.variant === "broadcast");
148
+ const isBroadcast = computed(() => props.broadcast);
149
+ const isText = computed(() => !isBroadcast.value && props.variant === "text");
150
+ const filledVariant = computed(() => (props.variant === "soft" ? "soft" : "default"));
123
151
 
124
152
  const broadcastSurfaces = {
125
153
  warning: {
@@ -132,13 +160,13 @@ const broadcastSurfaces = {
132
160
  },
133
161
  } as const;
134
162
 
135
- const broadcastSurface = computed(() => broadcastSurfaces[props.status === "success" ? "success" : "warning"]);
163
+ const broadcastSurface = computed(() => broadcastSurfaces[props.color === "success" ? "success" : "warning"]);
136
164
 
137
165
  const broadcastSizeClass =
138
166
  "h-[var(--ads-broadcast-height)] px-[var(--ads-broadcast-padding-x)] py-1 text-[length:var(--ads-broadcast-font-size)] font-bold";
139
167
 
140
- const surfaceClass = computed(() => props.customSurface ?? surfaces[props.tone][props.status]);
168
+ const surfaceClass = computed(() => props.customSurface ?? surfaces[filledVariant.value][props.color]);
141
169
  const resolvedLabel = computed(
142
- () => props.label ?? (isBroadcast.value ? "" : labels[props.tone][props.status]),
170
+ () => props.label ?? (isBroadcast.value ? "" : labels[filledVariant.value][props.color]),
143
171
  );
144
172
  </script>
@@ -1,13 +1,18 @@
1
1
  <template>
2
- <UTabs
3
- v-model="model"
4
- :items="items as TabsItem[]"
5
- :content="false"
6
- variant="pill"
7
- color="neutral"
8
- :ui="adsSegmentedTabsUi"
9
- :aria-label="ariaLabel"
2
+ <div
3
+ ref="scroller"
4
+ class="min-w-0 max-w-full [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden"
5
+ :class="overflows ? 'overflow-x-auto overscroll-x-contain' : ''"
10
6
  >
7
+ <UTabs
8
+ v-model="model"
9
+ :items="items as TabsItem[]"
10
+ :content="false"
11
+ variant="pill"
12
+ color="neutral"
13
+ :ui="adsSegmentedTabsUi"
14
+ :aria-label="ariaLabel"
15
+ >
11
16
  <!-- Rótulo e, abaixo, o subtítulo opcional. O ícone de 24px vem do próprio UTabs, à esquerda. -->
12
17
  <template #default="{ item }">
13
18
  <span>{{ item.label }}</span>
@@ -18,13 +23,15 @@
18
23
  {{ (item as AdsSegmentedTabsItem).subtitle }}
19
24
  </span>
20
25
  </template>
21
- </UTabs>
26
+ </UTabs>
27
+ </div>
22
28
  </template>
23
29
 
24
30
  <script setup lang="ts" generic="T extends string | number">
25
31
  import type { TabsItem } from "@nuxt/ui";
26
- import { watch } from "vue";
32
+ import { nextTick, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from "vue";
27
33
  import { adsSegmentedTabsUi } from "../theme/ads-theme";
34
+ import { bindTabWheel, revealActiveTab } from "./ads-tab-scroll";
28
35
 
29
36
  /** Estende TabsItem com `subtitle` opcional. O `icon` (24px, à esquerda) já vem do Nuxt UI. */
30
37
  export interface AdsSegmentedTabsItem extends Omit<TabsItem, "slot"> {
@@ -50,7 +57,7 @@ if (import.meta.dev) {
50
57
  (len) => {
51
58
  if (len > MAX_TABS) {
52
59
  console.warn(
53
- `[AdsSegmentedTabs] Limite de ${MAX_TABS} abas excedido (${len}). Acima desse limite o filtro pode ficar ilegível em telas menores.`,
60
+ `[AdsSegmentedTabs] Limite de ${MAX_TABS} abas excedido (${len}). A faixa rola na horizontal; prefira até ${MAX_TABS} abas.`,
54
61
  );
55
62
  }
56
63
  },
@@ -59,4 +66,41 @@ if (import.meta.dev) {
59
66
  }
60
67
 
61
68
  const model = defineModel<T>({ required: true });
69
+
70
+ const scroller = useTemplateRef<HTMLElement>("scroller");
71
+ /** Começa rolando para o SSR não estourar a página; o mount solta se a faixa cabe. */
72
+ const overflows = ref(true);
73
+ let unbindWheel: (() => void) | undefined;
74
+ let observer: ResizeObserver | undefined;
75
+
76
+ function syncOverflow() {
77
+ const el = scroller.value;
78
+ if (!el) return;
79
+ overflows.value = el.scrollWidth > el.clientWidth + 1;
80
+ }
81
+
82
+ function reveal() {
83
+ nextTick(() => {
84
+ syncOverflow();
85
+ nextTick(() => revealActiveTab(scroller.value));
86
+ });
87
+ }
88
+
89
+ onMounted(() => {
90
+ const el = scroller.value;
91
+ if (!el) return;
92
+ unbindWheel = bindTabWheel(el);
93
+ observer = new ResizeObserver(() => syncOverflow());
94
+ observer.observe(el);
95
+ if (el.firstElementChild) observer.observe(el.firstElementChild);
96
+ reveal();
97
+ });
98
+
99
+ onBeforeUnmount(() => {
100
+ unbindWheel?.();
101
+ observer?.disconnect();
102
+ });
103
+
104
+ watch(model, reveal);
105
+ watch(() => props.items, reveal);
62
106
  </script>
@@ -52,7 +52,7 @@
52
52
  <button
53
53
  v-else
54
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"
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)] font-normal leading-[1.3] normal-case 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
56
  :class="[fieldClass, block ? 'w-full justify-between' : 'w-fit']"
57
57
  :disabled="disabled"
58
58
  :data-state="fieldState"
@@ -68,7 +68,7 @@
68
68
  :disabled="!triggerHasTooltip"
69
69
  align="start"
70
70
  >
71
- <span class="min-w-0 truncate text-left">{{ triggerLabel }}</span>
71
+ <span class="min-w-0 truncate text-left font-normal normal-case" style="text-transform: none">{{ triggerLabel }}</span>
72
72
  </AdsTooltip>
73
73
  <UIcon name="i-lucide-chevron-down" class="size-4 shrink-0 text-base" :class="chevronClass" />
74
74
  </button>
@@ -1,7 +1,7 @@
1
1
  <!--
2
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.
3
+ Selecionado (simples e checkbox): título 14 bold em text/primary. O Figma pede esse negrito.
4
+ O texto não muda de caixa: marcar não deixa o rótulo em maiúscula.
5
5
  -->
6
6
  <template>
7
7
  <button
@@ -43,7 +43,7 @@
43
43
  wing="down"
44
44
  align="start"
45
45
  >
46
- <span class="block min-w-0 truncate text-sm leading-[1.3]" :class="titleClass">
46
+ <span class="block min-w-0 truncate text-sm leading-[1.3] normal-case" :class="titleClass" style="text-transform: none">
47
47
  {{ displayLabel }}
48
48
  </span>
49
49
  </AdsTooltip>
@@ -21,7 +21,7 @@
21
21
  class="size-[var(--ads-side-badge)] shrink-0 rounded-full bg-[var(--ads-funcional-opportunity-200)]"
22
22
  aria-hidden="true"
23
23
  />
24
- <AdsPill v-if="item.pill" size="sm" tone="secondary" status="new" :label="item.pill" />
24
+ <AdsPill v-if="item.pill" size="sm" variant="soft" color="new" :label="item.pill" />
25
25
  <UIcon
26
26
  v-if="item.children?.length"
27
27
  name="i-lucide-chevron-down"
@@ -40,7 +40,7 @@
40
40
  >
41
41
  <UIcon :name="child.icon || 'i-lucide-sun'" class="size-4 shrink-0 text-ads-neutro-escuro-500" />
42
42
  <span class="line-clamp-2 min-w-0 flex-1 text-xs font-bold leading-[1.2] text-[var(--ads-text-secondary)]">{{ child.label }}</span>
43
- <AdsPill v-if="child.pill" size="sm" tone="secondary" status="new" :label="child.pill" />
43
+ <AdsPill v-if="child.pill" size="sm" variant="soft" color="new" :label="child.pill" />
44
44
  </component>
45
45
  </template>
46
46
  </nav>
@@ -1,7 +1,12 @@
1
1
  <template>
2
- <nav :aria-label="ariaLabel">
3
- <!-- Stepper Simples: barras horizontais -->
4
- <div v-if="variant === 'simple'" class="flex items-start gap-4" role="list">
2
+ <nav :aria-label="ariaLabel" class="w-full min-w-0 max-w-full">
3
+ <!-- Stepper Simples: barras horizontais. A faixa rola se os rótulos não cabem. -->
4
+ <div
5
+ v-if="variant === 'simple'"
6
+ ref="scroller"
7
+ class="overflow-x-auto overscroll-x-contain p-1 [scrollbar-width:thin] [scrollbar-color:var(--ads-border-subtle)_transparent]"
8
+ >
9
+ <div class="flex w-max min-w-full items-start gap-4" role="list">
5
10
  <component
6
11
  :is="clickable ? 'button' : 'div'"
7
12
  v-for="(step, index) in steps"
@@ -11,7 +16,7 @@
11
16
  :aria-current="index === modelValue ? 'step' : undefined"
12
17
  :aria-label="step.label ? `${step.label} — ${stepAriaState(index)}` : `Passo ${index + 1} — ${stepAriaState(index)}`"
13
18
  :disabled="clickable ? index > modelValue && !allowForward : undefined"
14
- class="flex min-w-0 flex-1 flex-col items-start gap-2 rounded-[var(--ads-radius-sm)] text-left enabled:cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ads-border-focused)] focus-visible:ring-offset-2"
19
+ class="flex min-w-max flex-1 flex-col items-start gap-2 rounded-[var(--ads-radius-sm)] text-left enabled:cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ads-border-focused)] focus-visible:ring-offset-2"
15
20
  @click="onStepClick(index)"
16
21
  >
17
22
  <span
@@ -20,16 +25,17 @@
20
25
  />
21
26
  <span
22
27
  v-if="showLabels && step.label"
23
- class="w-full truncate text-[length:var(--ads-font-size-xxs)] leading-[1.3] transition-colors"
28
+ class="whitespace-nowrap text-[length:var(--ads-font-size-xxs)] leading-[1.3] transition-colors"
24
29
  :class="simpleLabelClass(index)"
25
30
  >
26
31
  {{ step.label }}
27
32
  </span>
28
33
  </component>
34
+ </div>
29
35
  </div>
30
36
 
31
37
  <!-- Stepper Visual vertical: círculo à esquerda, título e descrição à direita -->
32
- <div v-else-if="orientation === 'vertical'" class="flex flex-col items-start" role="list">
38
+ <div v-else-if="orientation === 'vertical'" class="flex w-full min-w-0 flex-col items-start" role="list">
33
39
  <component
34
40
  :is="clickable ? 'button' : 'div'"
35
41
  v-for="(step, index) in steps"
@@ -61,7 +67,7 @@
61
67
 
62
68
  <span
63
69
  v-if="showLabels && (step.label || step.description)"
64
- class="flex min-w-0 flex-1 flex-col gap-0.5 leading-[1.3]"
70
+ class="flex min-w-0 flex-1 flex-col gap-0.5 break-words leading-[1.3]"
65
71
  :class="{ 'pt-9': index > 0 }"
66
72
  >
67
73
  <span
@@ -82,8 +88,13 @@
82
88
  </component>
83
89
  </div>
84
90
 
85
- <!-- Stepper Visual: círculos com ícone ou número -->
86
- <div v-else class="flex items-start gap-2" role="list">
91
+ <!-- Stepper Visual: círculos com ícone ou número. A faixa rola se os passos não cabem. -->
92
+ <div
93
+ v-else
94
+ ref="scroller"
95
+ class="overflow-x-auto overscroll-x-contain p-1 [scrollbar-width:thin] [scrollbar-color:var(--ads-border-subtle)_transparent]"
96
+ >
97
+ <div class="flex w-max min-w-full items-start gap-2" role="list">
87
98
  <template v-for="(step, index) in steps" :key="index">
88
99
  <!-- Conector: centrado no círculo de 48px -->
89
100
  <span
@@ -139,10 +150,14 @@
139
150
  </component>
140
151
  </template>
141
152
  </div>
153
+ </div>
142
154
  </nav>
143
155
  </template>
144
156
 
145
157
  <script setup lang="ts">
158
+ import { nextTick, onBeforeUnmount, onMounted, useTemplateRef, watch } from "vue";
159
+ import { bindTabWheel } from "./ads-tab-scroll";
160
+
146
161
  export interface AdsStepperStep {
147
162
  /** Rótulo exibido abaixo da barra (Stepper Simples) ou do círculo (Stepper Visual). */
148
163
  label?: string;
@@ -184,6 +199,46 @@ const props = withDefaults(
184
199
 
185
200
  const modelValue = defineModel<number>({ default: 0 });
186
201
 
202
+ const scroller = useTemplateRef<HTMLElement>("scroller");
203
+ let unbindWheel: (() => void) | undefined;
204
+
205
+ function bindWheel() {
206
+ unbindWheel?.();
207
+ unbindWheel = scroller.value ? bindTabWheel(scroller.value) : undefined;
208
+ }
209
+
210
+ /** Traz o passo atual para a área visível quando a faixa está rolando. */
211
+ function revealCurrent() {
212
+ nextTick(() => {
213
+ const el = scroller.value;
214
+ const current = el?.querySelector<HTMLElement>('[aria-current="step"]');
215
+ if (!el || !current) return;
216
+ const box = el.getBoundingClientRect();
217
+ const step = current.getBoundingClientRect();
218
+ const styles = getComputedStyle(el);
219
+ const left = box.left + (Number.parseFloat(styles.paddingLeft) || 0);
220
+ const right = box.right - (Number.parseFloat(styles.paddingRight) || 0);
221
+ if (step.left < left) el.scrollLeft -= left - step.left;
222
+ else if (step.right > right) el.scrollLeft += step.right - right;
223
+ });
224
+ }
225
+
226
+ onMounted(() => {
227
+ bindWheel();
228
+ revealCurrent();
229
+ });
230
+
231
+ onBeforeUnmount(() => unbindWheel?.());
232
+
233
+ watch(modelValue, revealCurrent);
234
+ watch(
235
+ () => [props.variant, props.orientation, props.steps.length] as const,
236
+ () => nextTick(() => {
237
+ bindWheel();
238
+ revealCurrent();
239
+ }),
240
+ );
241
+
187
242
  const emit = defineEmits<{
188
243
  "update:modelValue": [step: number];
189
244
  }>();
@@ -154,6 +154,8 @@ const tableUi = computed(() => {
154
154
  stickyHeader: props.sticky === true || props.sticky === "header",
155
155
  pinnedEdge: props.pinnedEdge,
156
156
  });
157
+ // Marca para o CSS do AdsCard alinhar a primeira coluna. Fora do card, não faz nada.
158
+ base.root = `${base.root} ads-table`.trim();
157
159
  if (!slots.expanded) {
158
160
  // Árvore via getSubRows: o UTable sempre desenha a linha de detalhe da linha aberta.
159
161
  base.tbody = `${base.tbody} [&>tr[data-slot=tr]:not([data-selectable])]:hidden`;
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <UTabs
3
+ ref="tabs"
3
4
  v-model="model"
4
5
  variant="link"
5
6
  color="primary"
@@ -19,8 +20,9 @@
19
20
 
20
21
  <script setup lang="ts" generic="T extends string | number">
21
22
  import type { TabsItem } from "@nuxt/ui";
22
- import { computed, useSlots } from "vue";
23
+ import { computed, nextTick, onBeforeUnmount, onMounted, useSlots, useTemplateRef, watch } from "vue";
23
24
  import { adsLinkTabsUi } from "../theme/ads-theme";
25
+ import { bindTabWheel, revealActiveTab } from "./ads-tab-scroll";
24
26
 
25
27
  const props = withDefaults(
26
28
  defineProps<{
@@ -48,4 +50,22 @@ const ui = computed(() => ({
48
50
  .join(" "),
49
51
  list: [adsLinkTabsUi.list, props.listClass].filter(Boolean).join(" "),
50
52
  }));
53
+
54
+ const tabs = useTemplateRef<{ $el?: HTMLElement }>("tabs");
55
+ let unbindWheel: (() => void) | undefined;
56
+
57
+ function reveal() {
58
+ nextTick(() => revealActiveTab(tabs.value?.$el));
59
+ }
60
+
61
+ onMounted(() => {
62
+ const list = tabs.value?.$el?.querySelector<HTMLElement>('[role="tablist"]');
63
+ if (list) unbindWheel = bindTabWheel(list);
64
+ reveal();
65
+ });
66
+
67
+ onBeforeUnmount(() => unbindWheel?.());
68
+
69
+ watch(model, reveal);
70
+ watch(() => props.items, reveal);
51
71
  </script>
@@ -5,12 +5,18 @@
5
5
  role="status"
6
6
  >
7
7
  <div class="flex min-w-0 items-center gap-3">
8
- <UIcon
9
- :name="statusIcon"
10
- class="size-[var(--ads-toast-status-icon)] shrink-0"
11
- :class="[statusIconClass, status === 'loading' ? 'animate-spin' : '']"
12
- aria-hidden="true"
13
- />
8
+ <span
9
+ v-if="showIcon"
10
+ class="inline-flex shrink-0 items-center justify-center"
11
+ :style="statusIconBox"
12
+ >
13
+ <UIcon
14
+ :name="statusIcon"
15
+ class="ads-toast-icon size-full"
16
+ :class="[statusIconClass, status === 'loading' ? 'animate-spin' : '']"
17
+ aria-hidden="true"
18
+ />
19
+ </span>
14
20
  <div class="min-w-0">
15
21
  <p class="text-[length:var(--ads-toast-status-title-size)] leading-[1.3] font-bold">{{ title || resolvedMessage }}</p>
16
22
  <p v-if="subtitle" class="text-[length:var(--ads-toast-status-subtitle-size)] leading-[1.1]">{{ subtitle }}</p>
@@ -33,16 +39,35 @@
33
39
  role="status"
34
40
  >
35
41
  <div class="flex min-w-0 flex-1 basis-full items-start gap-2 sm:basis-auto">
36
- <UIcon
37
- :name="resolvedIcon"
38
- class="size-[var(--ads-toast-icon)] shrink-0"
39
- :class="iconClass"
40
- aria-hidden="true"
41
- />
42
+ <span
43
+ v-if="showIcon"
44
+ class="inline-flex shrink-0 items-center justify-center"
45
+ :style="bannerIconBox"
46
+ >
47
+ <UIcon
48
+ :name="resolvedIcon"
49
+ class="ads-toast-icon size-full"
50
+ :class="iconClass"
51
+ aria-hidden="true"
52
+ />
53
+ </span>
42
54
  <div class="min-w-0 flex-1">
43
55
  <slot>
44
56
  <p class="text-[length:var(--ads-toast-font-size)] [font-weight:var(--ads-toast-weight)] leading-[1.3] text-[var(--ads-toast-text)]">
45
- {{ resolvedMessage }}
57
+ {{ resolvedMessage }}<button
58
+ v-if="actionLabel"
59
+ type="button"
60
+ class="ms-1 inline-flex items-baseline gap-1 font-normal text-[var(--ads-text-brand)] underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-brand)]"
61
+ @click="emit('action')"
62
+ >
63
+ {{ actionLabel }}
64
+ <UIcon
65
+ v-if="actionIcon"
66
+ :name="actionIcon"
67
+ class="ads-icon-xxs size-[var(--ads-space-xxs)] shrink-0 self-center"
68
+ aria-hidden="true"
69
+ />
70
+ </button>
46
71
  </p>
47
72
  <p
48
73
  v-if="description"
@@ -54,21 +79,8 @@
54
79
  </slot>
55
80
  </div>
56
81
  </div>
57
- <div
58
- v-if="actionLabel || closable"
59
- class="ml-auto flex shrink-0 items-center gap-[var(--ads-toast-gap)]"
60
- >
61
- <button
62
- v-if="actionLabel"
63
- type="button"
64
- class="text-[length:var(--ads-toast-font-size)] leading-[1.3] font-bold underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2"
65
- :class="actionTextClass"
66
- @click="emit('action')"
67
- >
68
- {{ actionLabel }}
69
- </button>
82
+ <div v-if="closable" class="ml-auto flex shrink-0 items-center">
70
83
  <button
71
- v-if="closable"
72
84
  type="button"
73
85
  class="flex size-[18px] shrink-0 items-center justify-center rounded-[var(--ads-radius-xsm)] text-[var(--ads-text-primary)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ads-text-primary)]"
74
86
  aria-label="Fechar"
@@ -98,11 +110,17 @@ const props = withDefaults(
98
110
  description?: string;
99
111
  title?: string;
100
112
  subtitle?: string;
101
- icon?: string;
113
+ /**
114
+ * Ícone Lucide. Sem valor, segue o status.
115
+ * `false` tira o ícone do DOM, sem o vão do token.
116
+ */
117
+ icon?: string | false;
102
118
  /** Quando falso, o aviso permanece sem a ação de fechar. */
103
119
  closable?: boolean;
104
- /** Rótulo da ação em link. Sem valor, esconde o link. */
120
+ /** Rótulo da ação no fim da frase. Sem valor, esconde a ação. */
105
121
  actionLabel?: string;
122
+ /** Ícone Lucide da ação, como `i-lucide-arrow-up-right`. Sem valor, a ação é só texto. */
123
+ actionIcon?: string;
106
124
  }>(),
107
125
  {
108
126
  status: "error",
@@ -115,6 +133,7 @@ const props = withDefaults(
115
133
  icon: undefined,
116
134
  closable: true,
117
135
  actionLabel: undefined,
136
+ actionIcon: undefined,
118
137
  },
119
138
  );
120
139
 
@@ -139,16 +158,14 @@ const iconClass = computed(() => {
139
158
  return "text-[var(--ads-toast-error-icon)]";
140
159
  });
141
160
 
142
- const actionTextClass = computed(() => {
143
- if (props.status === "success") return "text-[var(--ads-toast-success-icon)]";
144
- if (props.status === "warning" || props.status === "attention") return "text-[var(--ads-toast-warning-icon)]";
145
- if (props.status === "neutral") return "text-[var(--ads-toast-neutral-icon)]";
146
- if (props.status === "loading") return "text-[var(--ads-toast-primary-icon)]";
147
- return "text-[var(--ads-toast-error-icon)]";
148
- });
161
+ const showIcon = computed(() => props.icon !== false);
162
+
163
+ /** Caixa do token. O CSS unlayered do Iconify não define o tamanho: a classe .ads-toast-icon ocupa a caixa. */
164
+ const bannerIconBox = { width: "var(--ads-toast-icon)", height: "var(--ads-toast-icon)", "--ads-toast-icon-size": "var(--ads-toast-icon)" };
165
+ const statusIconBox = { width: "var(--ads-toast-status-icon)", height: "var(--ads-toast-status-icon)", "--ads-toast-icon-size": "var(--ads-toast-status-icon)" };
149
166
 
150
167
  const resolvedIcon = computed(() => {
151
- if (props.icon) return props.icon;
168
+ if (typeof props.icon === "string" && props.icon) return props.icon;
152
169
  if (props.status === "success") return "i-lucide-circle-check";
153
170
  if (props.status === "warning") return "i-lucide-triangle-alert";
154
171
  if (props.status === "attention") return "i-lucide-circle-alert";