ads-nuxt 0.1.3 → 0.1.5

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,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";
@@ -32,10 +34,13 @@ const props = withDefaults(
32
34
  size?: "sm" | "md" | "lg";
33
35
  maximumDays?: number;
34
36
  class?: string;
37
+ /** O valor veio de uma sugestão de IA. Quem usa limpa a marca quando a pessoa edita. */
38
+ aiSuggestion?: boolean;
35
39
  }>(),
36
40
  {
37
41
  range: false,
38
42
  size: "md",
43
+ aiSuggestion: false,
39
44
  },
40
45
  );
41
46
 
@@ -148,9 +153,17 @@ const rangeFieldClass = computed(() => [
148
153
  "h-[var(--ads-date-height)] rounded-[var(--ads-date-radius)] px-[var(--ads-date-padding-x)] text-[length:var(--ads-date-font-size)] [font-weight:var(--ads-date-weight)] leading-[var(--ads-date-line-height)] text-[var(--ads-date-text)] bg-[var(--ads-date-background)] ring ring-inset ring-[var(--ads-date-border)]",
149
154
  "enabled:hover:ring-[var(--ads-date-hover-border)] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--ads-date-focus-border)]",
150
155
  "disabled:cursor-not-allowed disabled:opacity-75",
156
+ props.aiSuggestion && "bg-[var(--ads-button-ia-background)] ring-[var(--ads-button-ia-border)]",
151
157
  props.class,
152
158
  ]);
153
159
 
160
+ /** O tema do UInputDate usa `!`, então a sugestão de IA também precisa de `!` para vencer. */
161
+ const inputDateUi = computed(() =>
162
+ props.aiSuggestion
163
+ ? { base: "!bg-[var(--ads-button-ia-background)] !ring-[var(--ads-button-ia-border)]" }
164
+ : undefined,
165
+ );
166
+
154
167
  const popoverUi = { content: "w-auto max-w-none p-0" };
155
168
 
156
169
  /**
@@ -181,7 +194,8 @@ function monthTitle(date: CalendarDate) {
181
194
  return calendarMonthTitle(date, UI_LOCALE_CODE);
182
195
  }
183
196
 
184
- function onRangePlaceholderUpdate(value: CalendarDate) {
197
+ function onRangePlaceholderUpdate(placeholder: DateValue) {
198
+ const value = toCalendarDate(placeholder);
185
199
  const next = visibleMonthAfterPlaceholder(leftPlaceholder.value, value);
186
200
  if (next.compare(leftPlaceholder.value) !== 0) {
187
201
  leftPlaceholder.value = next;
@@ -215,7 +229,8 @@ function applyExternalModels() {
215
229
  }
216
230
  }
217
231
 
218
- function onCalendarModelUpdate(value: CalendarModel) {
232
+ function onCalendarModelUpdate(event: CalendarEventValue) {
233
+ const value = toCalendarModel(event);
219
234
  if (calendarRangesEqual(calendarModel.value, value)) return;
220
235
 
221
236
  syncingFromCalendar.value = true;
@@ -237,9 +252,10 @@ function resetDraftFromCommitted() {
237
252
  leftPlaceholder.value = anchor.set({ day: 1 });
238
253
  }
239
254
 
240
- function onDraftUpdate(value: CalendarDateRangeValue | undefined) {
255
+ function onDraftUpdate(value: CalendarEventValue) {
241
256
  if (ignoreDraftUpdates.value) return;
242
- draftRange.value = value;
257
+ const range = toCalendarModel(value);
258
+ draftRange.value = range && isCalendarDateRange(range) ? range : undefined;
243
259
  }
244
260
 
245
261
  function clearDraft() {
@@ -287,7 +303,8 @@ watch([modelValue, start, end, () => props.range], applyExternalModels, {
287
303
  immediate: true,
288
304
  });
289
305
 
290
- function isDateUnavailable(date: CalendarDate) {
306
+ function isDateUnavailable(value: DateValue) {
307
+ const date = toCalendarDate(value);
291
308
  if (minCalendarDate.value && date.compare(minCalendarDate.value) < 0) {
292
309
  return true;
293
310
  }
@@ -424,6 +441,7 @@ function isDateUnavailable(date: CalendarDate) {
424
441
  :model-value="calendarModel"
425
442
  :locale="UI_LOCALE_CODE"
426
443
  :size="size"
444
+ :ui="inputDateUi"
427
445
  :disabled="disabled"
428
446
  :readonly="readonly"
429
447
  :min-value="minCalendarDate"
@@ -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,
@@ -99,6 +100,8 @@ const props = withDefaults(
99
100
  searchPlaceholder?: string;
100
101
  /** O gatilho ocupa a largura do campo, como um select de formulário. */
101
102
  block?: boolean;
103
+ /** O valor veio de uma sugestão de IA. Quem usa limpa a marca quando a pessoa altera a seleção. */
104
+ aiSuggestion?: boolean;
102
105
  }>(),
103
106
  {
104
107
  placeholder: "Selecione",
@@ -111,6 +114,7 @@ const props = withDefaults(
111
114
  emptyLabel: "Nenhum resultado",
112
115
  searchPlaceholder: "Pesquisar",
113
116
  block: false,
117
+ aiSuggestion: false,
114
118
  },
115
119
  );
116
120
 
@@ -140,6 +144,7 @@ const fieldState = computed(() => {
140
144
  if (props.disabled) return "disabled";
141
145
  if (props.error) return "error";
142
146
  if (isOpen.value) return "open";
147
+ if (props.aiSuggestion) return "ai";
143
148
  if (hasValue.value) return "selected";
144
149
  return "default";
145
150
  });
@@ -154,6 +159,9 @@ const fieldClass = computed(() => {
154
159
  if (fieldState.value === "open") {
155
160
  return "border-(length:--ads-border-width-slim) border-[var(--ads-filter-focus-border)] bg-[var(--ads-filter-background)] text-[var(--ads-filter-text)]";
156
161
  }
162
+ if (fieldState.value === "ai") {
163
+ return "border border-[var(--ads-button-ia-border)] bg-[var(--ads-button-ia-background)] hover:border-[var(--ads-filter-hover-border)] text-[var(--ads-filter-text)]";
164
+ }
157
165
  if (fieldState.value === "selected") {
158
166
  return "border border-[var(--ads-filter-border)] hover:border-[var(--ads-filter-hover-border)] bg-ads-neutro-claro-20 text-[var(--ads-filter-text)]";
159
167
  }
@@ -162,7 +170,7 @@ const fieldClass = computed(() => {
162
170
 
163
171
  const chevronClass = computed(() => {
164
172
  if (fieldState.value === "disabled") return "text-ads-neutro-medio-60";
165
- if (fieldState.value === "selected") return "text-ads-neutro-escuro-500";
173
+ if (fieldState.value === "selected" || fieldState.value === "ai") return "text-ads-neutro-escuro-500";
166
174
  return "text-ads-neutro-medio-100";
167
175
  });
168
176
 
@@ -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
 
@@ -70,6 +70,8 @@ const props = withDefaults(
70
70
  step?: string | number;
71
71
  /** Estado congelado para a documentação. `null` segue o campo. */
72
72
  state?: AdsInputState | null;
73
+ /** O valor veio de uma sugestão de IA. Quem usa limpa a marca quando a pessoa edita. */
74
+ aiSuggestion?: boolean;
73
75
  }>(),
74
76
  {
75
77
  label: "",
@@ -82,6 +84,7 @@ const props = withDefaults(
82
84
  type: "text",
83
85
  suffix: "",
84
86
  state: null,
87
+ aiSuggestion: false,
85
88
  },
86
89
  );
87
90
 
@@ -110,6 +113,7 @@ const visualState = computed<AdsInputState>(() => {
110
113
  if (isDisabled.value) return "disabled";
111
114
  if (props.state) return props.state;
112
115
  if (props.error) return "error";
116
+ if (props.aiSuggestion) return "ai";
113
117
  return displayValue.value ? "active" : "default";
114
118
  });
115
119
 
@@ -136,7 +140,7 @@ const fieldClass = computed(() => {
136
140
  return "border-(length:--ads-border-width-slim) border-[var(--ads-input-focus-border)] bg-[var(--ads-input-background)] text-[var(--ads-input-text)]";
137
141
  }
138
142
  if (visualState.value === "ai") {
139
- return "border border-[#7358cc] bg-[#f3f0ff] text-[var(--ads-text-secondary)]";
143
+ return `border border-[var(--ads-button-ia-border)] bg-[var(--ads-button-ia-background)] text-[var(--ads-text-secondary)] ${focus}`;
140
144
  }
141
145
  return `border border-[var(--ads-input-border)] bg-[var(--ads-input-background)] text-[var(--ads-input-text)] ${focus}`;
142
146
  });
@@ -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,9 +72,9 @@
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
- export type AdsNumberInputState = "default" | "active" | "focus" | "error" | "disabled";
77
+ export type AdsNumberInputState = "default" | "active" | "focus" | "error" | "disabled" | "ai";
78
78
 
79
79
  const props = withDefaults(
80
80
  defineProps<{
@@ -89,6 +89,8 @@ const props = withDefaults(
89
89
  step?: string | number;
90
90
  /** Estado congelado para a documentação. `null` segue o campo. */
91
91
  state?: AdsNumberInputState | null;
92
+ /** O valor veio de uma sugestão de IA. Quem usa limpa a marca quando a pessoa edita. */
93
+ aiSuggestion?: boolean;
92
94
  }>(),
93
95
  {
94
96
  label: "",
@@ -99,6 +101,7 @@ const props = withDefaults(
99
101
  suffix: "",
100
102
  disabled: false,
101
103
  state: null,
104
+ aiSuggestion: false,
102
105
  },
103
106
  );
104
107
 
@@ -136,6 +139,7 @@ const visualState = computed<AdsNumberInputState>(() => {
136
139
  if (isDisabled.value) return "disabled";
137
140
  if (props.state) return props.state;
138
141
  if (props.error) return "error";
142
+ if (props.aiSuggestion) return "ai";
139
143
  return displayValue.value ? "active" : "default";
140
144
  });
141
145
 
@@ -161,6 +165,9 @@ const fieldClass = computed(() => {
161
165
  if (visualState.value === "focus") {
162
166
  return "border-(length:--ads-border-width-slim) border-[var(--ads-number-focus-border)] bg-[var(--ads-number-background)] text-[var(--ads-number-text)]";
163
167
  }
168
+ if (visualState.value === "ai") {
169
+ return `border border-[var(--ads-button-ia-border)] bg-[var(--ads-button-ia-background)] text-[var(--ads-number-text)] ${focus}`;
170
+ }
164
171
  return `border border-[var(--ads-number-border)] bg-[var(--ads-number-background)] text-[var(--ads-number-text)] ${focus}`;
165
172
  });
166
173
  </script>
@@ -40,7 +40,7 @@
40
40
  <script setup lang="ts">
41
41
  import { computed, useId } from "vue";
42
42
 
43
- export type AdsSearchInputState = "default" | "active" | "focus" | "disabled";
43
+ export type AdsSearchInputState = "default" | "active" | "focus" | "disabled" | "ai";
44
44
  export type AdsSearchInputSize = "md" | "sm";
45
45
 
46
46
  const props = withDefaults(
@@ -53,6 +53,8 @@ const props = withDefaults(
53
53
  size?: AdsSearchInputSize;
54
54
  /** Estado congelado para a documentação. `null` segue o campo. */
55
55
  state?: AdsSearchInputState | null;
56
+ /** O texto veio de uma sugestão de IA. Quem usa limpa a marca quando a pessoa edita. */
57
+ aiSuggestion?: boolean;
56
58
  }>(),
57
59
  {
58
60
  placeholder: "Pesquisar",
@@ -62,6 +64,7 @@ const props = withDefaults(
62
64
  icon: "i-lucide-search",
63
65
  size: "md",
64
66
  state: null,
67
+ aiSuggestion: false,
65
68
  },
66
69
  );
67
70
 
@@ -74,10 +77,13 @@ const isDisabled = computed(() => props.disabled || props.state === "disabled");
74
77
  const visualState = computed<AdsSearchInputState>(() => {
75
78
  if (isDisabled.value) return "disabled";
76
79
  if (props.state) return props.state;
80
+ if (props.aiSuggestion) return "ai";
77
81
  return model.value ? "active" : "default";
78
82
  });
79
83
 
80
- const showClear = computed(() => visualState.value === "active" || visualState.value === "focus");
84
+ const showClear = computed(
85
+ () => visualState.value === "active" || visualState.value === "focus" || visualState.value === "ai",
86
+ );
81
87
 
82
88
  const iconClass = computed(() =>
83
89
  props.size === "sm"
@@ -108,6 +114,9 @@ const fieldClass = computed(() => {
108
114
  if (visualState.value === "focus") {
109
115
  return `border-(length:--ads-border-width-slim) border-[var(--ads-search-focus-border)] bg-[var(--ads-search-background)] ${tone}`;
110
116
  }
117
+ if (visualState.value === "ai") {
118
+ return `border border-[var(--ads-button-ia-border)] bg-[var(--ads-button-ia-background)] ${tone} ${focus}`;
119
+ }
111
120
  return `border border-[var(--ads-search-border)] bg-[var(--ads-search-background)] ${tone} ${focus}`;
112
121
  });
113
122
  </script>
@@ -43,7 +43,7 @@
43
43
  <script setup lang="ts">
44
44
  import { computed, useId } from "vue";
45
45
 
46
- export type AdsTextareaState = "default" | "active" | "focus" | "error" | "disabled";
46
+ export type AdsTextareaState = "default" | "active" | "focus" | "error" | "disabled" | "ai";
47
47
 
48
48
  const props = withDefaults(
49
49
  defineProps<{
@@ -54,6 +54,8 @@ const props = withDefaults(
54
54
  disabled?: boolean;
55
55
  /** Estado congelado para a documentação. `null` segue o campo. */
56
56
  state?: AdsTextareaState | null;
57
+ /** O texto veio de uma sugestão de IA. Quem usa limpa a marca quando a pessoa edita. */
58
+ aiSuggestion?: boolean;
57
59
  }>(),
58
60
  {
59
61
  label: "",
@@ -62,6 +64,7 @@ const props = withDefaults(
62
64
  placeholder: "",
63
65
  disabled: false,
64
66
  state: null,
67
+ aiSuggestion: false,
65
68
  },
66
69
  );
67
70
 
@@ -76,6 +79,7 @@ const visualState = computed<AdsTextareaState>(() => {
76
79
  if (isDisabled.value) return "disabled";
77
80
  if (props.state) return props.state;
78
81
  if (props.error) return "error";
82
+ if (props.aiSuggestion) return "ai";
79
83
  return model.value ? "active" : "default";
80
84
  });
81
85
 
@@ -104,6 +108,9 @@ const fieldClass = computed(() => {
104
108
  const focus = interactiveFocus
105
109
  ? "hover:not-focus-within:border-[var(--ads-textarea-hover-border)] focus-within:border-(length:--ads-border-width-slim) focus-within:border-[var(--ads-textarea-focus-border)]"
106
110
  : "";
111
+ if (visualState.value === "ai") {
112
+ return `border border-[var(--ads-button-ia-border)] bg-[var(--ads-button-ia-background)] ${text} ${focus}`;
113
+ }
107
114
  return `border border-[var(--ads-textarea-border)] bg-[var(--ads-textarea-background)] ${text} ${focus}`;
108
115
  });
109
116
  </script>
@@ -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
 
@@ -94,7 +94,7 @@ export const componentTokenCatalog: readonly TokenComponent[] = [
94
94
  id: "input",
95
95
  section: "campo",
96
96
  label: "Campo",
97
- note: "Vale para o AdsInput. O estado de IA continua com a cor própria.",
97
+ note: "Vale para o AdsInput. O estado de IA usa os tokens do botão IA (--ads-button-ia-background e --ads-button-ia-border), também nos campos de busca e filtro.",
98
98
  fields: [
99
99
  length("--ads-input-height", "Altura", "Medida", "40px"),
100
100
  length("--ads-input-padding-x", "Padding horizontal", "Medida", "12px"),
@@ -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.3",
3
+ "version": "0.1.5",
4
4
  "license": "MIT",
5
5
  "description": "Alquimia Design System para Nuxt, construído sobre Nuxt UI",
6
6
  "repository": {
@@ -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>