ads-nuxt 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,22 +47,30 @@ O pacote é uma **Nuxt Layer**: ao estendê-lo, seu projeto recebe de uma vez os
47
47
  | Node.js | 20+ (recomendado 22) |
48
48
  | Nuxt | `^4.0.0` |
49
49
  | Vue | `^3.5.18` |
50
+ | `@nuxt/ui` | `^4.3.0` |
51
+ | `tailwindcss` | `^4.0.15` |
52
+ | `@nuxt/icon` | `^2.2.0` |
53
+ | `@nuxt/fonts` | `^0.12.1` ou `^0.14.0` |
54
+ | `@vueuse/nuxt` e `@vueuse/core` | `^14.0.0` |
55
+ | `@internationalized/date` | `^3.12.4` |
50
56
 
51
- `nuxt` e `vue` são *peer dependencies*. As demais (`@nuxt/ui`, `@nuxt/fonts`, `@nuxt/icon`, `@vueuse/nuxt`, `tailwindcss`, ícones Lucide) já vêm como dependências do pacote.
57
+ Todas são *peer dependencies*: ficam a cargo do seu projeto, que escolhe a versão. Assim o app não ganha uma segunda cópia do Nuxt UI nem do Tailwind. Se o projeto já usa o Nuxt UI v4, normalmente já tem quase tudo. Os ícones Lucide (`@iconify-json/lucide`) vêm como dependência do pacote.
52
58
 
53
59
  ## Instalação
54
60
 
55
61
  ```bash
56
62
  # pnpm
57
- pnpm add ads-nuxt
63
+ pnpm add ads-nuxt @nuxt/ui @nuxt/fonts @nuxt/icon @vueuse/core @vueuse/nuxt @internationalized/date tailwindcss
58
64
 
59
65
  # npm
60
- npm install ads-nuxt
66
+ npm install ads-nuxt @nuxt/ui @nuxt/fonts @nuxt/icon @vueuse/core @vueuse/nuxt @internationalized/date tailwindcss
61
67
 
62
68
  # yarn
63
- yarn add ads-nuxt
69
+ yarn add ads-nuxt @nuxt/ui @nuxt/fonts @nuxt/icon @vueuse/core @vueuse/nuxt @internationalized/date tailwindcss
64
70
  ```
65
71
 
72
+ Se algum desses pacotes já estiver no `package.json`, o comando só mantém a versão existente. Para conferir que não há cópia duplicada: `pnpm why @nuxt/ui` deve mostrar uma única versão.
73
+
66
74
  ### Skill para o agente de IA (opcional)
67
75
 
68
76
  O repositório traz a skill `ads-nuxt`, que ensina o agente do seu projeto (Cursor, Claude Code e outros) a usar o ADS: componentes, tokens, utilitários e armadilhas conhecidas.
@@ -526,9 +534,11 @@ Páginas do playground:
526
534
  ### Docker
527
535
 
528
536
  ```bash
529
- docker compose up
537
+ docker compose up --build
530
538
  ```
531
539
 
540
+ A imagem executa o build de produção do playground (`pnpm build`) e serve o resultado em `http://localhost:3010`. Não há hot reload no container: para desenvolver, use `pnpm dev`.
541
+
532
542
  ### Publicação
533
543
 
534
544
  O pacote publica apenas `app/` e `nuxt.config.ts` (campo `files`), com acesso público:
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { isEqualMonth, type CalendarDate } from "@internationalized/date";
2
+ import { isEqualMonth, toCalendarDate, type CalendarDate, type DateValue } from "@internationalized/date";
3
3
  import { computed, nextTick, ref, shallowRef, watch } from "vue";
4
4
  import AdsButton from "./AdsButton.vue";
5
5
  import { UI_LOCALE_CODE } from "../locale/pt-br";
@@ -16,7 +16,9 @@ import {
16
16
  isOutsideMaximumWindow,
17
17
  shiftVisibleMonth,
18
18
  visibleMonthAfterPlaceholder,
19
+ toCalendarModel,
19
20
  type CalendarDateRangeValue,
21
+ type CalendarEventValue,
20
22
  } from "../utils/calendar-date";
21
23
 
22
24
  const DATE_PLACEHOLDER = "dd/mm/aaaa";
@@ -181,7 +183,8 @@ function monthTitle(date: CalendarDate) {
181
183
  return calendarMonthTitle(date, UI_LOCALE_CODE);
182
184
  }
183
185
 
184
- function onRangePlaceholderUpdate(value: CalendarDate) {
186
+ function onRangePlaceholderUpdate(placeholder: DateValue) {
187
+ const value = toCalendarDate(placeholder);
185
188
  const next = visibleMonthAfterPlaceholder(leftPlaceholder.value, value);
186
189
  if (next.compare(leftPlaceholder.value) !== 0) {
187
190
  leftPlaceholder.value = next;
@@ -215,7 +218,8 @@ function applyExternalModels() {
215
218
  }
216
219
  }
217
220
 
218
- function onCalendarModelUpdate(value: CalendarModel) {
221
+ function onCalendarModelUpdate(event: CalendarEventValue) {
222
+ const value = toCalendarModel(event);
219
223
  if (calendarRangesEqual(calendarModel.value, value)) return;
220
224
 
221
225
  syncingFromCalendar.value = true;
@@ -237,9 +241,10 @@ function resetDraftFromCommitted() {
237
241
  leftPlaceholder.value = anchor.set({ day: 1 });
238
242
  }
239
243
 
240
- function onDraftUpdate(value: CalendarDateRangeValue | undefined) {
244
+ function onDraftUpdate(value: CalendarEventValue) {
241
245
  if (ignoreDraftUpdates.value) return;
242
- draftRange.value = value;
246
+ const range = toCalendarModel(value);
247
+ draftRange.value = range && isCalendarDateRange(range) ? range : undefined;
243
248
  }
244
249
 
245
250
  function clearDraft() {
@@ -287,7 +292,8 @@ watch([modelValue, start, end, () => props.range], applyExternalModels, {
287
292
  immediate: true,
288
293
  });
289
294
 
290
- function isDateUnavailable(date: CalendarDate) {
295
+ function isDateUnavailable(value: DateValue) {
296
+ const date = toCalendarDate(value);
291
297
  if (minCalendarDate.value && date.compare(minCalendarDate.value) < 0) {
292
298
  return true;
293
299
  }
@@ -18,9 +18,11 @@
18
18
  <span class="block text-[length:var(--ads-feature-title-size)] font-bold leading-[1.3]" :class="titleClass">
19
19
  {{ title }}
20
20
  </span>
21
- <InvertedTooltip
22
- :text="description"
21
+ <AdsTooltip
22
+ :description="description"
23
+ :show-title="false"
23
24
  :disabled="!isDescriptionTruncated"
25
+ align="start"
24
26
  >
25
27
  <span
26
28
  ref="descriptionEl"
@@ -29,7 +31,7 @@
29
31
  >
30
32
  {{ description }}
31
33
  </span>
32
- </InvertedTooltip>
34
+ </AdsTooltip>
33
35
  </span>
34
36
  <UIcon
35
37
  v-if="!disabled"
@@ -71,7 +73,7 @@ import { useResizeObserver } from "@vueuse/core";
71
73
  import { NuxtLink } from "#components";
72
74
  import AdsPill from "./AdsPill.vue";
73
75
  import type { AdsPillStatus, AdsPillTone } from "./AdsPill.vue";
74
- import InvertedTooltip from "./InvertedTooltip.vue";
76
+ import AdsTooltip from "./AdsTooltip.vue";
75
77
 
76
78
  export interface AdsFeatureCardBadge {
77
79
  label: string;
@@ -21,11 +21,11 @@
21
21
  <UIcon :name="resolvedIcon" class="size-4" />
22
22
  </span>
23
23
  <div class="min-w-0">
24
- <InvertedTooltip :text="name">
24
+ <AdsTooltip :description="name" :show-title="false" align="start">
25
25
  <p class="truncate text-[length:var(--ads-file-title-size)] font-semibold leading-5 text-[var(--ads-text-primary)]">
26
26
  {{ name }}
27
27
  </p>
28
- </InvertedTooltip>
28
+ </AdsTooltip>
29
29
  <p
30
30
  v-if="detail"
31
31
  class="text-[length:var(--ads-file-detail-size)] font-normal leading-4 text-[var(--ads-text-secondary)]"
@@ -50,7 +50,7 @@
50
50
  <script setup lang="ts">
51
51
  import { computed } from "vue";
52
52
  import AdsButton from "./AdsButton.vue";
53
- import InvertedTooltip from "./InvertedTooltip.vue";
53
+ import AdsTooltip from "./AdsTooltip.vue";
54
54
 
55
55
  export type AdsFileCardStatus = "success" | "error";
56
56
 
@@ -4,8 +4,8 @@
4
4
  class="flex h-[50px] w-full items-center gap-2 py-4 text-left hover:bg-neutral-100"
5
5
  :class="mode === 'checkbox' ? 'ps-4' : 'ps-6'"
6
6
  :role="mode === 'checkbox' ? 'checkbox' : 'option'"
7
- :aria-checked="checkedState === undefined ? undefined : String(checkedState)"
8
- :aria-selected="mode === 'radio' ? String(selected) : undefined"
7
+ :aria-checked="checkedState"
8
+ :aria-selected="mode === 'radio' ? selected : undefined"
9
9
  @click="emit('select')"
10
10
  >
11
11
  <span
@@ -24,10 +24,12 @@
24
24
  class="size-3 text-[var(--ads-text-contrast)]"
25
25
  />
26
26
  </span>
27
- <InvertedTooltip
28
- :text="label"
27
+ <AdsTooltip
28
+ :description="label"
29
+ :show-title="false"
29
30
  :disabled="!needsTooltip"
30
- :content="{ side: 'bottom', align: 'start', sideOffset: 4 }"
31
+ wing="down"
32
+ align="start"
31
33
  >
32
34
  <span
33
35
  class="block min-w-0 truncate text-sm leading-[1.3] text-[var(--ads-text-secondary)]"
@@ -35,13 +37,13 @@
35
37
  >
36
38
  {{ displayLabel }}
37
39
  </span>
38
- </InvertedTooltip>
40
+ </AdsTooltip>
39
41
  </button>
40
42
  </template>
41
43
 
42
44
  <script setup lang="ts">
43
45
  import { computed } from "vue";
44
- import InvertedTooltip from "./InvertedTooltip.vue";
46
+ import AdsTooltip from "./AdsTooltip.vue";
45
47
  import {
46
48
  filterLabelNeedsTooltip,
47
49
  truncateFilterLabel,
@@ -26,13 +26,14 @@
26
26
  :aria-labelledby="label ? labelId : undefined"
27
27
  :aria-describedby="supportText ? supportId : undefined"
28
28
  >
29
- <InvertedTooltip
30
- :text="triggerLabel"
29
+ <AdsTooltip
30
+ :description="triggerLabel"
31
+ :show-title="false"
31
32
  :disabled="!triggerHasTooltip"
32
- :content="{ side: 'top', align: 'start', sideOffset: 4 }"
33
+ align="start"
33
34
  >
34
35
  <span class="min-w-0 truncate text-left">{{ triggerLabel }}</span>
35
- </InvertedTooltip>
36
+ </AdsTooltip>
36
37
  <UIcon name="i-lucide-chevron-down" class="size-4 shrink-0 text-base" :class="chevronClass" />
37
38
  </button>
38
39
 
@@ -73,7 +74,7 @@
73
74
  import { computed, ref, useId, watch } from "vue";
74
75
  import AdsFilterDropdown from "./AdsFilterDropdown.vue";
75
76
  import AdsMonthPicker from "./AdsMonthPicker.vue";
76
- import InvertedTooltip from "./InvertedTooltip.vue";
77
+ import AdsTooltip from "./AdsTooltip.vue";
77
78
  import {
78
79
  filterLabelNeedsTooltip,
79
80
  filterTriggerLabel,
@@ -6,11 +6,11 @@
6
6
  :class="supportClass"
7
7
  >
8
8
  <label :for="fieldId">{{ label }}</label>
9
- <InvertedTooltip v-if="info" :text="info">
9
+ <AdsTooltip v-if="info" :description="info" :show-title="false">
10
10
  <span class="inline-flex">
11
11
  <UIcon name="i-lucide-info" class="size-3 text-xs" />
12
12
  </span>
13
- </InvertedTooltip>
13
+ </AdsTooltip>
14
14
  </div>
15
15
 
16
16
  <div
@@ -51,7 +51,7 @@
51
51
 
52
52
  <script setup lang="ts">
53
53
  import { computed, useId } from "vue";
54
- import InvertedTooltip from "./InvertedTooltip.vue";
54
+ import AdsTooltip from "./AdsTooltip.vue";
55
55
 
56
56
  export type AdsInputState = "default" | "active" | "focus" | "error" | "disabled" | "ai";
57
57
 
@@ -9,13 +9,13 @@
9
9
  <div class="flex flex-col items-start gap-1">
10
10
  <div class="flex min-w-0 items-center gap-2">
11
11
  <p :class="labelClass">{{ title }}</p>
12
- <InvertedTooltip v-if="hint" :text="hint" class="shrink-0">
12
+ <AdsTooltip v-if="hint" :description="hint" :show-title="false" class="shrink-0">
13
13
  <UIcon
14
14
  name="i-lucide-help-circle"
15
15
  size="xs"
16
16
  class="align-middle text-[var(--ads-border-icon-support)]"
17
17
  />
18
- </InvertedTooltip>
18
+ </AdsTooltip>
19
19
  </div>
20
20
  <slot name="status" />
21
21
  </div>
@@ -49,7 +49,7 @@
49
49
 
50
50
  <script setup lang="ts">
51
51
  import { computed, useSlots } from "vue";
52
- import InvertedTooltip from "./InvertedTooltip.vue";
52
+ import AdsTooltip from "./AdsTooltip.vue";
53
53
 
54
54
  /**
55
55
  * Número em destaque.
@@ -6,11 +6,11 @@
6
6
  :class="supportClass"
7
7
  >
8
8
  <label v-if="label" :for="fieldId">{{ label }}</label>
9
- <InvertedTooltip v-if="info" :text="info">
9
+ <AdsTooltip v-if="info" :description="info" :show-title="false">
10
10
  <span class="inline-flex">
11
11
  <UIcon name="i-lucide-info" class="size-3 text-xs" />
12
12
  </span>
13
- </InvertedTooltip>
13
+ </AdsTooltip>
14
14
  </div>
15
15
 
16
16
  <div
@@ -72,7 +72,7 @@
72
72
 
73
73
  <script setup lang="ts">
74
74
  import { computed, useId, useTemplateRef } from "vue";
75
- import InvertedTooltip from "./InvertedTooltip.vue";
75
+ import AdsTooltip from "./AdsTooltip.vue";
76
76
 
77
77
  export type AdsNumberInputState = "default" | "active" | "focus" | "error" | "disabled";
78
78
 
@@ -3,7 +3,8 @@
3
3
  v-if="hasTrigger"
4
4
  arrow
5
5
  :delay-duration="delayDuration"
6
- :content="{ side, align: 'center', sideOffset: 8 }"
6
+ :disabled="disabled"
7
+ :content="{ side, align, sideOffset: 8 }"
7
8
  :ui="tooltipUi"
8
9
  >
9
10
  <slot />
@@ -37,6 +38,10 @@ const props = withDefaults(
37
38
  /** Figma `Wing Position`. */
38
39
  wing?: Wing;
39
40
  delayDuration?: number;
41
+ /** Alinhamento do balão em relação ao gatilho. */
42
+ align?: "start" | "center" | "end";
43
+ /** Não abre o balão. Útil para texto que só aparece quando é cortado. */
44
+ disabled?: boolean;
40
45
  }>(),
41
46
  {
42
47
  title: "Título",
@@ -45,6 +50,8 @@ const props = withDefaults(
45
50
  showDescription: true,
46
51
  wing: "up",
47
52
  delayDuration: 150,
53
+ align: "center",
54
+ disabled: false,
48
55
  },
49
56
  );
50
57
 
@@ -124,7 +124,7 @@ export const adsTableColumn = {
124
124
  select: { class: { th: "w-px pe-0", td: "w-px pe-0" } },
125
125
  /** Ação da linha, sempre à direita. */
126
126
  action: { class: { th: "w-px", td: "w-px text-right" } },
127
- /** Texto longo que trunca com InvertedTooltip. */
127
+ /** Texto longo que trunca com AdsTooltip. */
128
128
  truncate: { class: { td: "max-w-72 truncate" } },
129
129
  } as const;
130
130
 
@@ -1,12 +1,47 @@
1
- import { CalendarDate, isEqualMonth, parseDate } from "@internationalized/date";
1
+ import {
2
+ CalendarDate,
3
+ isEqualMonth,
4
+ parseDate,
5
+ toCalendarDate,
6
+ type DateValue,
7
+ } from "@internationalized/date";
2
8
 
3
9
  const DATE_ONLY_REGEX = /^\d{4}-\d{2}-\d{2}$/;
4
10
 
11
+ /** Intervalo com início definido. O fim fica `undefined` enquanto o usuário escolhe. */
5
12
  export type CalendarDateRangeValue = {
6
13
  start: CalendarDate;
7
- end?: CalendarDate;
14
+ end: CalendarDate | undefined;
8
15
  };
9
16
 
17
+ /** Valor que o Nuxt UI (UCalendar, UInputDate) entrega nos eventos `update:model-value`. */
18
+ export type CalendarEventValue =
19
+ | DateValue
20
+ | { start: DateValue | undefined; end: DateValue | undefined }
21
+ | DateValue[]
22
+ | null
23
+ | undefined;
24
+
25
+ /** Converte o intervalo do Nuxt UI. Sem início, não há intervalo. */
26
+ export function toCalendarDateRange(
27
+ value: { start?: DateValue; end?: DateValue } | null | undefined,
28
+ ): CalendarDateRangeValue | undefined {
29
+ if (!value?.start) return undefined;
30
+ return {
31
+ start: toCalendarDate(value.start),
32
+ end: value.end ? toCalendarDate(value.end) : undefined,
33
+ };
34
+ }
35
+
36
+ /** Converte o valor emitido pelo Nuxt UI para data única ou intervalo. Lista de datas não é usada aqui. */
37
+ export function toCalendarModel(
38
+ value: CalendarEventValue,
39
+ ): CalendarDate | CalendarDateRangeValue | undefined {
40
+ if (!value || Array.isArray(value)) return undefined;
41
+ if ("start" in value) return toCalendarDateRange(value);
42
+ return toCalendarDate(value);
43
+ }
44
+
10
45
  export function dateStringToCalendarDate(
11
46
  value: string,
12
47
  ): CalendarDate | undefined {
@@ -26,7 +61,7 @@ export function dateStringsToCalendarRange(
26
61
  if (!startDate) return undefined;
27
62
 
28
63
  const endDate = dateStringToCalendarDate(end);
29
- if (!endDate) return { start: startDate };
64
+ if (!endDate) return { start: startDate, end: undefined };
30
65
 
31
66
  return { start: startDate, end: endDate };
32
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ads-nuxt",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "license": "MIT",
5
5
  "description": "Alquimia Design System para Nuxt, construído sobre Nuxt UI",
6
6
  "repository": {
@@ -26,21 +26,28 @@
26
26
  "skill:check": "node scripts/generate-skill-reference.mjs --check"
27
27
  },
28
28
  "dependencies": {
29
- "@iconify-json/lucide": "^1.2.104",
29
+ "@iconify-json/lucide": "^1.2.104"
30
+ },
31
+ "peerDependencies": {
30
32
  "@internationalized/date": "^3.12.4",
31
- "@nuxt/fonts": "^0.12.1",
33
+ "@nuxt/fonts": "^0.12.1 || ^0.14.0",
32
34
  "@nuxt/icon": "^2.2.0",
33
35
  "@nuxt/ui": "^4.3.0",
34
36
  "@vueuse/core": "^14.0.0",
35
37
  "@vueuse/nuxt": "^14.0.0",
36
- "tailwindcss": "^4.0.15"
37
- },
38
- "peerDependencies": {
39
38
  "nuxt": "^4.0.0",
39
+ "tailwindcss": "^4.0.15",
40
40
  "vue": "^3.5.18"
41
41
  },
42
42
  "devDependencies": {
43
+ "@internationalized/date": "^3.12.4",
44
+ "@nuxt/fonts": "^0.12.1",
45
+ "@nuxt/icon": "^2.2.0",
46
+ "@nuxt/ui": "^4.3.0",
47
+ "@vueuse/core": "^14.0.0",
48
+ "@vueuse/nuxt": "^14.0.0",
43
49
  "nuxt": "^4.0.0",
50
+ "tailwindcss": "^4.0.15",
44
51
  "typescript": "^5.6.3",
45
52
  "vue": "^3.5.18",
46
53
  "vue-router": "^4.5.0"
@@ -1,40 +0,0 @@
1
- <template>
2
- <UTooltip
3
- :text="text"
4
- arrow
5
- :delay-duration="delayDuration"
6
- :disabled="disabled || !text"
7
- :content="content"
8
- :ui="tooltipUi"
9
- >
10
- <slot />
11
- </UTooltip>
12
- </template>
13
-
14
- <script setup lang="ts">
15
- withDefaults(
16
- defineProps<{
17
- text: string;
18
- delayDuration?: number;
19
- disabled?: boolean;
20
- content?: {
21
- side?: "top" | "right" | "bottom" | "left";
22
- align?: "start" | "center" | "end";
23
- sideOffset?: number;
24
- };
25
- }>(),
26
- {
27
- delayDuration: 150,
28
- disabled: false,
29
- content: () => ({ side: "top", align: "start", sideOffset: 8 }),
30
- },
31
- );
32
-
33
- /** Tooltip padrão escuro do produto (`bg-inverted`). */
34
- const tooltipUi = {
35
- content:
36
- "z-[70] h-auto max-w-xs rounded-[var(--ads-tooltip-radius)] bg-[var(--ads-tooltip-bg)] px-[var(--ads-tooltip-padding-x)] py-[var(--ads-tooltip-padding-y)] text-[length:var(--ads-tooltip-font-size)] text-[var(--ads-tooltip-text)] shadow-lg ring-0",
37
- text: "whitespace-normal",
38
- arrow: "fill-[var(--ads-tooltip-bg)]",
39
- };
40
- </script>