ads-nuxt 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +574 -574
  3. package/app/app.config.ts +25 -25
  4. package/app/assets/ads/checkbox-check.svg +5 -5
  5. package/app/assets/ads/checkbox-minus.svg +5 -5
  6. package/app/assets/brand/farmarcas.svg +6 -6
  7. package/app/assets/brand/radar-symbol.svg +9 -9
  8. package/app/assets/brand/radar.svg +9 -9
  9. package/app/assets/css/ads-colors.css +257 -257
  10. package/app/assets/css/main.css +585 -585
  11. package/app/components/AdsBadge.vue +47 -47
  12. package/app/components/AdsBroadcast.vue +24 -24
  13. package/app/components/AdsButton.vue +547 -547
  14. package/app/components/AdsButtonGroup.vue +39 -39
  15. package/app/components/AdsButtonMenu.vue +48 -48
  16. package/app/components/AdsCard.vue +188 -188
  17. package/app/components/AdsCardHint.vue +56 -56
  18. package/app/components/AdsCardPeriod.vue +43 -43
  19. package/app/components/AdsCardVariation.vue +31 -31
  20. package/app/components/AdsCharttip.vue +79 -79
  21. package/app/components/AdsDatePicker.vue +509 -509
  22. package/app/components/AdsDropdownMenu.vue +30 -30
  23. package/app/components/AdsEmptyState.vue +61 -61
  24. package/app/components/AdsFeatureCard.vue +292 -292
  25. package/app/components/AdsFileCard.vue +98 -98
  26. package/app/components/AdsFooter.vue +25 -25
  27. package/app/components/AdsHeavyAccountCell.vue +59 -59
  28. package/app/components/AdsHeavyHeaderCell.vue +70 -70
  29. package/app/components/AdsHeavyTable.vue +135 -135
  30. package/app/components/AdsInput.vue +148 -148
  31. package/app/components/AdsLoading.vue +217 -217
  32. package/app/components/AdsMenuBar.vue +110 -110
  33. package/app/components/AdsMetricCard.vue +226 -226
  34. package/app/components/AdsModal.vue +160 -160
  35. package/app/components/AdsMonthPicker.vue +80 -80
  36. package/app/components/AdsNavbarApp.vue +67 -67
  37. package/app/components/AdsNavbarDesk.vue +67 -67
  38. package/app/components/AdsNotabilityPill.vue +24 -24
  39. package/app/components/AdsNumberInput.vue +173 -173
  40. package/app/components/AdsPanelCard.vue +99 -99
  41. package/app/components/AdsPill.vue +144 -144
  42. package/app/components/AdsProductTag.vue +80 -80
  43. package/app/components/AdsSearchInput.vue +122 -122
  44. package/app/components/AdsSegmentedTabs.vue +62 -62
  45. package/app/components/AdsSelect.vue +283 -283
  46. package/app/components/AdsSelectItem.vue +128 -128
  47. package/app/components/AdsSelectPanel.vue +221 -221
  48. package/app/components/AdsSideMenu.vue +101 -101
  49. package/app/components/AdsSmalltip.vue +44 -44
  50. package/app/components/AdsStepper.vue +222 -222
  51. package/app/components/AdsTable.vue +172 -172
  52. package/app/components/AdsTableHeaderCell.vue +80 -80
  53. package/app/components/AdsTableSkeleton.vue +113 -113
  54. package/app/components/AdsTableToolbar.vue +44 -44
  55. package/app/components/AdsTabs.vue +51 -51
  56. package/app/components/AdsTextarea.vue +116 -116
  57. package/app/components/AdsToast.vue +184 -184
  58. package/app/components/AdsTooltip.vue +73 -73
  59. package/app/components/ProgressBarLoading.vue +235 -235
  60. package/app/composables/useOverlayLoading.ts +88 -88
  61. package/app/constants/ads-color-swatches.ts +240 -240
  62. package/app/locale/pt-br.ts +6 -6
  63. package/app/plugins/ads-toast.client.ts +24 -24
  64. package/app/theme/ads-theme.ts +374 -374
  65. package/app/theme/ads-tokens.ts +391 -391
  66. package/app/types/overlay-loading.types.ts +32 -32
  67. package/app/utils/ads-filter-select.ts +191 -191
  68. package/app/utils/ads-table.ts +416 -416
  69. package/app/utils/calendar-date.ts +163 -163
  70. package/app/utils/category-role.ts +45 -45
  71. package/app/utils/money.ts +77 -77
  72. package/app/utils/notability.ts +8 -8
  73. package/app/utils/parser.ts +134 -134
  74. package/app/utils/percentage.ts +54 -54
  75. package/nuxt.config.ts +31 -31
  76. package/package.json +57 -57
@@ -1,113 +1,113 @@
1
- <!--
2
- AdsTableSkeleton — Carregamento da tabela (Figma: "Table Skeleton").
3
-
4
- Sozinho, desenha a casca do Figma com cabeçalho. Com `columns`, desenha só as linhas: é como
5
- o AdsTable usa, no slot #loading, debaixo do cabeçalho real. As linhas entram na grade da
6
- tabela por `display: table-row`, então cada bloco alinha com a coluna de verdade.
7
- -->
8
- <template>
9
- <div :class="rootClass">
10
- <span class="sr-only" role="status">Carregando tabela</span>
11
-
12
- <div v-if="!columns" class="table w-full table-fixed" aria-hidden="true">
13
- <div class="table-row bg-neutral-200">
14
- <div
15
- v-for="cell in PRODUCT_CELLS"
16
- :key="cell.width"
17
- class="table-cell h-12 border-b border-[var(--ads-border-subtle)] px-4 align-middle"
18
- :class="cell.width"
19
- >
20
- <div class="rounded-[var(--ads-radius-xsm)] bg-[var(--color-ads-neutro-claro-40)]" :class="[cell.head, ALIGN[cell.align]]" />
21
- </div>
22
- </div>
23
- </div>
24
-
25
- <div v-if="variant === 'logo'" class="flex h-64 items-center justify-center">
26
- <AdsLoading variant="logo" size="md" />
27
- </div>
28
-
29
- <div v-else :class="columns ? 'contents' : 'table w-full table-fixed'" aria-hidden="true">
30
- <div v-for="row in skeletonRows" :key="row" class="table-row [&:last-child>*]:border-b-0">
31
- <div
32
- v-for="(cell, index) in cells"
33
- :key="index"
34
- class="table-cell border-b border-[var(--ads-border-subtle)] bg-[var(--ads-surface-card)] align-middle"
35
- :class="[columns ? cellClass : 'h-16 px-4', cell.width]"
36
- >
37
- <USkeleton class="bg-neutral-200" :class="[cell.block, ALIGN[cell.align]]" />
38
- </div>
39
- </div>
40
- </div>
41
- </div>
42
- </template>
43
-
44
- <script setup lang="ts">
45
- import { computed } from "vue";
46
- import AdsLoading from "./AdsLoading.vue";
47
-
48
- export type AdsTableSkeletonVariant = "skeleton" | "logo";
49
- export type AdsTableSkeletonAlign = "left" | "center" | "right";
50
-
51
- type SkeletonCell = { align: AdsTableSkeletonAlign; block: string; width?: string; head?: string };
52
-
53
- const ALIGN: Record<AdsTableSkeletonAlign, string> = { left: "", center: "mx-auto", right: "ml-auto" };
54
-
55
- const BLOCK = "rounded-[var(--ads-radius-xsm)]";
56
-
57
- /** Colunas do Figma: seleção, descrição, notabilidade e dois preços. */
58
- const PRODUCT_CELLS: (SkeletonCell & { width: string; head: string })[] = [
59
- { width: "w-14", head: "size-4", block: `size-4 ${BLOCK}`, align: "left" },
60
- { width: "w-80", head: "h-2.5 w-36", block: `h-3 w-54 ${BLOCK}`, align: "left" },
61
- { width: "w-45", head: "h-2.5 w-[74px]", block: "h-[13px] w-[110px] rounded-[var(--ads-radius-pill)]", align: "left" },
62
- { width: "w-35", head: "h-2.5 w-[54px]", block: `h-3 w-[59px] ${BLOCK}`, align: "right" },
63
- { width: "w-35", head: "h-2.5 w-[54px]", block: `h-3 w-[59px] ${BLOCK}`, align: "right" },
64
- ];
65
-
66
- const props = withDefaults(
67
- defineProps<{
68
- /**
69
- * Número de linhas do skeleton. Mínimo 1, máximo 8.
70
- * Corresponde a Linha 1 a Linha 8 do Figma.
71
- */
72
- rows?: number;
73
- /**
74
- * skeleton: barras de placeholder na grade da tabela.
75
- * logo: loader do Radar centralizado na área da tabela.
76
- */
77
- variant?: AdsTableSkeletonVariant;
78
- /** Alinhamento de cada coluna da tabela real. Sem cabeçalho próprio quando informado. */
79
- columns?: AdsTableSkeletonAlign[];
80
- /** Altura e respiro das células, iguais aos da linha de dados. Só com `columns`. */
81
- cellClass?: string;
82
- }>(),
83
- {
84
- rows: 4,
85
- variant: "skeleton",
86
- columns: undefined,
87
- cellClass: "h-16 px-4",
88
- },
89
- );
90
-
91
- const skeletonRows = computed(() => {
92
- const count = Math.min(8, Math.max(1, props.rows));
93
- return Array.from({ length: count }, (_, index) => index);
94
- });
95
-
96
- const inTableRows = computed(() => Boolean(props.columns) && props.variant === "skeleton");
97
-
98
- /** Sozinho, tem a casca da Table do Figma: borda neutra e raio de 12px. Dentro do AdsTable, a tabela já tem. */
99
- const rootClass = computed(() => {
100
- if (inTableRows.value) return "contents";
101
- if (props.columns) return "w-full bg-[var(--ads-surface-card)]";
102
- return "w-full overflow-hidden rounded-[var(--ads-radius-md)] border border-neutral-300 bg-[var(--ads-surface-card)]";
103
- });
104
-
105
- const cells = computed((): SkeletonCell[] =>
106
- props.columns
107
- ? props.columns.map((align, index) => ({
108
- align,
109
- block: `h-3 ${BLOCK} ${index === 0 ? "w-full max-w-54" : "w-3/5 max-w-30"}`,
110
- }))
111
- : PRODUCT_CELLS,
112
- );
113
- </script>
1
+ <!--
2
+ AdsTableSkeleton — Carregamento da tabela (Figma: "Table Skeleton").
3
+
4
+ Sozinho, desenha a casca do Figma com cabeçalho. Com `columns`, desenha só as linhas: é como
5
+ o AdsTable usa, no slot #loading, debaixo do cabeçalho real. As linhas entram na grade da
6
+ tabela por `display: table-row`, então cada bloco alinha com a coluna de verdade.
7
+ -->
8
+ <template>
9
+ <div :class="rootClass">
10
+ <span class="sr-only" role="status">Carregando tabela</span>
11
+
12
+ <div v-if="!columns" class="table w-full table-fixed" aria-hidden="true">
13
+ <div class="table-row bg-neutral-200">
14
+ <div
15
+ v-for="cell in PRODUCT_CELLS"
16
+ :key="cell.width"
17
+ class="table-cell h-12 border-b border-[var(--ads-border-subtle)] px-4 align-middle"
18
+ :class="cell.width"
19
+ >
20
+ <div class="rounded-[var(--ads-radius-xsm)] bg-[var(--color-ads-neutro-claro-40)]" :class="[cell.head, ALIGN[cell.align]]" />
21
+ </div>
22
+ </div>
23
+ </div>
24
+
25
+ <div v-if="variant === 'logo'" class="flex h-64 items-center justify-center">
26
+ <AdsLoading variant="logo" size="md" />
27
+ </div>
28
+
29
+ <div v-else :class="columns ? 'contents' : 'table w-full table-fixed'" aria-hidden="true">
30
+ <div v-for="row in skeletonRows" :key="row" class="table-row [&:last-child>*]:border-b-0">
31
+ <div
32
+ v-for="(cell, index) in cells"
33
+ :key="index"
34
+ class="table-cell border-b border-[var(--ads-border-subtle)] bg-[var(--ads-surface-card)] align-middle"
35
+ :class="[columns ? cellClass : 'h-16 px-4', cell.width]"
36
+ >
37
+ <USkeleton class="bg-neutral-200" :class="[cell.block, ALIGN[cell.align]]" />
38
+ </div>
39
+ </div>
40
+ </div>
41
+ </div>
42
+ </template>
43
+
44
+ <script setup lang="ts">
45
+ import { computed } from "vue";
46
+ import AdsLoading from "./AdsLoading.vue";
47
+
48
+ export type AdsTableSkeletonVariant = "skeleton" | "logo";
49
+ export type AdsTableSkeletonAlign = "left" | "center" | "right";
50
+
51
+ type SkeletonCell = { align: AdsTableSkeletonAlign; block: string; width?: string; head?: string };
52
+
53
+ const ALIGN: Record<AdsTableSkeletonAlign, string> = { left: "", center: "mx-auto", right: "ml-auto" };
54
+
55
+ const BLOCK = "rounded-[var(--ads-radius-xsm)]";
56
+
57
+ /** Colunas do Figma: seleção, descrição, notabilidade e dois preços. */
58
+ const PRODUCT_CELLS: (SkeletonCell & { width: string; head: string })[] = [
59
+ { width: "w-14", head: "size-4", block: `size-4 ${BLOCK}`, align: "left" },
60
+ { width: "w-80", head: "h-2.5 w-36", block: `h-3 w-54 ${BLOCK}`, align: "left" },
61
+ { width: "w-45", head: "h-2.5 w-[74px]", block: "h-[13px] w-[110px] rounded-[var(--ads-radius-pill)]", align: "left" },
62
+ { width: "w-35", head: "h-2.5 w-[54px]", block: `h-3 w-[59px] ${BLOCK}`, align: "right" },
63
+ { width: "w-35", head: "h-2.5 w-[54px]", block: `h-3 w-[59px] ${BLOCK}`, align: "right" },
64
+ ];
65
+
66
+ const props = withDefaults(
67
+ defineProps<{
68
+ /**
69
+ * Número de linhas do skeleton. Mínimo 1, máximo 8.
70
+ * Corresponde a Linha 1 a Linha 8 do Figma.
71
+ */
72
+ rows?: number;
73
+ /**
74
+ * skeleton: barras de placeholder na grade da tabela.
75
+ * logo: loader do Radar centralizado na área da tabela.
76
+ */
77
+ variant?: AdsTableSkeletonVariant;
78
+ /** Alinhamento de cada coluna da tabela real. Sem cabeçalho próprio quando informado. */
79
+ columns?: AdsTableSkeletonAlign[];
80
+ /** Altura e respiro das células, iguais aos da linha de dados. Só com `columns`. */
81
+ cellClass?: string;
82
+ }>(),
83
+ {
84
+ rows: 4,
85
+ variant: "skeleton",
86
+ columns: undefined,
87
+ cellClass: "h-16 px-4",
88
+ },
89
+ );
90
+
91
+ const skeletonRows = computed(() => {
92
+ const count = Math.min(8, Math.max(1, props.rows));
93
+ return Array.from({ length: count }, (_, index) => index);
94
+ });
95
+
96
+ const inTableRows = computed(() => Boolean(props.columns) && props.variant === "skeleton");
97
+
98
+ /** Sozinho, tem a casca da Table do Figma: borda neutra e raio de 12px. Dentro do AdsTable, a tabela já tem. */
99
+ const rootClass = computed(() => {
100
+ if (inTableRows.value) return "contents";
101
+ if (props.columns) return "w-full bg-[var(--ads-surface-card)]";
102
+ return "w-full overflow-hidden rounded-[var(--ads-radius-md)] border border-neutral-300 bg-[var(--ads-surface-card)]";
103
+ });
104
+
105
+ const cells = computed((): SkeletonCell[] =>
106
+ props.columns
107
+ ? props.columns.map((align, index) => ({
108
+ align,
109
+ block: `h-3 ${BLOCK} ${index === 0 ? "w-full max-w-54" : "w-3/5 max-w-30"}`,
110
+ }))
111
+ : PRODUCT_CELLS,
112
+ );
113
+ </script>
@@ -1,44 +1,44 @@
1
- <template>
2
- <div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
3
- <div v-if="title || description || $slots.title" class="min-w-0">
4
- <slot name="title">
5
- <p class="font-bold text-[var(--ads-text-primary)]">{{ title }}</p>
6
- <p v-if="description" class="mt-1 text-sm text-[var(--ads-text-secondary)]">{{ description }}</p>
7
- </slot>
8
- </div>
9
-
10
- <div class="flex min-w-0 flex-wrap items-center gap-3">
11
- <AdsSearchInput
12
- v-if="searchable"
13
- v-model="search"
14
- size="sm"
15
- class="w-full sm:w-64"
16
- :placeholder="searchPlaceholder"
17
- />
18
- <slot />
19
- </div>
20
- </div>
21
- </template>
22
-
23
- <script setup lang="ts">
24
- import AdsSearchInput from "./AdsSearchInput.vue";
25
-
26
- withDefaults(
27
- defineProps<{
28
- /** Título à esquerda. Sem título, a busca e os filtros ocupam a faixa. */
29
- title?: string;
30
- description?: string;
31
- /** Mostra o AdsSearchInput. O filtro entra no slot padrão, com AdsSelect. */
32
- searchable?: boolean;
33
- searchPlaceholder?: string;
34
- }>(),
35
- {
36
- title: "",
37
- description: "",
38
- searchable: true,
39
- searchPlaceholder: "Pesquisar",
40
- },
41
- );
42
-
43
- const search = defineModel<string>("search", { default: "" });
44
- </script>
1
+ <template>
2
+ <div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
3
+ <div v-if="title || description || $slots.title" class="min-w-0">
4
+ <slot name="title">
5
+ <p class="font-bold text-[var(--ads-text-primary)]">{{ title }}</p>
6
+ <p v-if="description" class="mt-1 text-sm text-[var(--ads-text-secondary)]">{{ description }}</p>
7
+ </slot>
8
+ </div>
9
+
10
+ <div class="flex min-w-0 flex-wrap items-center gap-3">
11
+ <AdsSearchInput
12
+ v-if="searchable"
13
+ v-model="search"
14
+ size="sm"
15
+ class="w-full sm:w-64"
16
+ :placeholder="searchPlaceholder"
17
+ />
18
+ <slot />
19
+ </div>
20
+ </div>
21
+ </template>
22
+
23
+ <script setup lang="ts">
24
+ import AdsSearchInput from "./AdsSearchInput.vue";
25
+
26
+ withDefaults(
27
+ defineProps<{
28
+ /** Título à esquerda. Sem título, a busca e os filtros ocupam a faixa. */
29
+ title?: string;
30
+ description?: string;
31
+ /** Mostra o AdsSearchInput. O filtro entra no slot padrão, com AdsSelect. */
32
+ searchable?: boolean;
33
+ searchPlaceholder?: string;
34
+ }>(),
35
+ {
36
+ title: "",
37
+ description: "",
38
+ searchable: true,
39
+ searchPlaceholder: "Pesquisar",
40
+ },
41
+ );
42
+
43
+ const search = defineModel<string>("search", { default: "" });
44
+ </script>
@@ -1,51 +1,51 @@
1
- <template>
2
- <UTabs
3
- v-model="model"
4
- variant="link"
5
- color="primary"
6
- :items="items"
7
- :content="content"
8
- :default-item="defaultItem"
9
- :ui="ui"
10
- >
11
- <template v-if="slots.trailing" #trailing="slotProps">
12
- <slot name="trailing" v-bind="slotProps" />
13
- </template>
14
- <template v-if="slots.content" #content="slotProps">
15
- <slot name="content" v-bind="slotProps" />
16
- </template>
17
- </UTabs>
18
- </template>
19
-
20
- <script setup lang="ts" generic="T extends string | number">
21
- import type { TabsItem } from "@nuxt/ui";
22
- import { computed, useSlots } from "vue";
23
- import { adsLinkTabsUi } from "../theme/ads-theme";
24
-
25
- const props = withDefaults(
26
- defineProps<{
27
- items: TabsItem[];
28
- /** `false` deixa só a faixa de abas, sem painel. */
29
- content?: boolean;
30
- defaultItem?: TabsItem;
31
- /** Classes extras na lista, como um recuo lateral. */
32
- listClass?: string;
33
- }>(),
34
- {
35
- content: true,
36
- defaultItem: undefined,
37
- listClass: "",
38
- },
39
- );
40
-
41
- const model = defineModel<T>();
42
- const slots = useSlots();
43
-
44
- const ui = computed(() => ({
45
- ...adsLinkTabsUi,
46
- root: [adsLinkTabsUi.root, props.content ? "flex-col gap-4" : ""]
47
- .filter(Boolean)
48
- .join(" "),
49
- list: [adsLinkTabsUi.list, props.listClass].filter(Boolean).join(" "),
50
- }));
51
- </script>
1
+ <template>
2
+ <UTabs
3
+ v-model="model"
4
+ variant="link"
5
+ color="primary"
6
+ :items="items"
7
+ :content="content"
8
+ :default-item="defaultItem"
9
+ :ui="ui"
10
+ >
11
+ <template v-if="slots.trailing" #trailing="slotProps">
12
+ <slot name="trailing" v-bind="slotProps" />
13
+ </template>
14
+ <template v-if="slots.content" #content="slotProps">
15
+ <slot name="content" v-bind="slotProps" />
16
+ </template>
17
+ </UTabs>
18
+ </template>
19
+
20
+ <script setup lang="ts" generic="T extends string | number">
21
+ import type { TabsItem } from "@nuxt/ui";
22
+ import { computed, useSlots } from "vue";
23
+ import { adsLinkTabsUi } from "../theme/ads-theme";
24
+
25
+ const props = withDefaults(
26
+ defineProps<{
27
+ items: TabsItem[];
28
+ /** `false` deixa só a faixa de abas, sem painel. */
29
+ content?: boolean;
30
+ defaultItem?: TabsItem;
31
+ /** Classes extras na lista, como um recuo lateral. */
32
+ listClass?: string;
33
+ }>(),
34
+ {
35
+ content: true,
36
+ defaultItem: undefined,
37
+ listClass: "",
38
+ },
39
+ );
40
+
41
+ const model = defineModel<T>();
42
+ const slots = useSlots();
43
+
44
+ const ui = computed(() => ({
45
+ ...adsLinkTabsUi,
46
+ root: [adsLinkTabsUi.root, props.content ? "flex-col gap-4" : ""]
47
+ .filter(Boolean)
48
+ .join(" "),
49
+ list: [adsLinkTabsUi.list, props.listClass].filter(Boolean).join(" "),
50
+ }));
51
+ </script>
@@ -1,116 +1,116 @@
1
- <template>
2
- <div class="flex w-full min-w-0 flex-col gap-0.5">
3
- <label
4
- v-if="label"
5
- :for="fieldId"
6
- class="text-[length:var(--ads-textarea-label-size)] leading-[1.2]"
7
- :class="supportClass"
8
- >
9
- {{ label }}
10
- </label>
11
-
12
- <div
13
- class="relative flex min-h-[var(--ads-textarea-min-height)] transition-colors rounded-[var(--ads-textarea-radius)]"
14
- :class="fieldClass"
15
- :data-state="visualState"
16
- >
17
- <textarea
18
- :id="fieldId"
19
- v-model="model"
20
- class="min-h-[calc(var(--ads-textarea-min-height)-24px)] w-full flex-1 resize-y bg-transparent p-[var(--ads-textarea-padding)] pe-8 text-[length:var(--ads-textarea-font-size)] leading-[1.3] outline-none placeholder:text-current disabled:cursor-not-allowed"
21
- :placeholder="placeholder"
22
- :disabled="isDisabled"
23
- :aria-invalid="error ? true : undefined"
24
- :aria-describedby="supportText ? supportId : undefined"
25
- />
26
- <UIcon
27
- name="i-lucide-move-diagonal-2"
28
- class="pointer-events-none absolute end-3 bottom-3 size-4 text-base text-ads-neutro-medio-60"
29
- />
30
- </div>
31
-
32
- <p
33
- v-if="supportText"
34
- :id="supportId"
35
- class="text-[length:var(--ads-textarea-label-size)] leading-[1.2]"
36
- :class="supportClass"
37
- >
38
- {{ supportText }}
39
- </p>
40
- </div>
41
- </template>
42
-
43
- <script setup lang="ts">
44
- import { computed, useId } from "vue";
45
-
46
- export type AdsTextareaState = "default" | "active" | "focus" | "error" | "disabled" | "ai";
47
-
48
- const props = withDefaults(
49
- defineProps<{
50
- label?: string;
51
- hint?: string;
52
- error?: string;
53
- placeholder?: string;
54
- disabled?: boolean;
55
- /** Estado congelado para a documentação. `null` segue o campo. */
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;
59
- }>(),
60
- {
61
- label: "",
62
- hint: "",
63
- error: "",
64
- placeholder: "",
65
- disabled: false,
66
- state: null,
67
- aiSuggestion: false,
68
- },
69
- );
70
-
71
- const model = defineModel<string>({ default: "" });
72
-
73
- const fieldId = useId();
74
- const supportId = useId();
75
-
76
- const isDisabled = computed(() => props.disabled || props.state === "disabled");
77
-
78
- const visualState = computed<AdsTextareaState>(() => {
79
- if (isDisabled.value) return "disabled";
80
- if (props.state) return props.state;
81
- if (props.error) return "error";
82
- if (props.aiSuggestion) return "ai";
83
- return model.value ? "active" : "default";
84
- });
85
-
86
- const supportText = computed(() => props.error || props.hint);
87
- const supportClass = computed(() =>
88
- visualState.value === "disabled"
89
- ? "text-[var(--ads-textarea-placeholder)]"
90
- : "text-[var(--ads-text-secondary)]",
91
- );
92
-
93
- const fieldClass = computed(() => {
94
- const interactiveFocus = props.state === null && !isDisabled.value && !props.error;
95
- const text = visualState.value === "default" || visualState.value === "disabled"
96
- ? "text-[var(--ads-textarea-placeholder)]"
97
- : "text-[var(--ads-textarea-text)]";
98
-
99
- if (visualState.value === "disabled") {
100
- return `border border-[var(--ads-textarea-disabled-border)] bg-[var(--ads-textarea-disabled-background)] ${text}`;
101
- }
102
- if (visualState.value === "error") {
103
- return `border-(length:--ads-border-width-slim) border-[var(--ads-textarea-error-border)] bg-[var(--ads-textarea-background)] ${text}`;
104
- }
105
- if (visualState.value === "focus") {
106
- return `border-(length:--ads-border-width-slim) border-[var(--ads-textarea-focus-border)] bg-[var(--ads-textarea-background)] ${text}`;
107
- }
108
- const focus = interactiveFocus
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)]"
110
- : "";
111
- if (visualState.value === "ai") {
112
- return `border border-[var(--ads-text-ai)] bg-[var(--ads-surface-ai)] text-[var(--ads-text-secondary)] ${focus}`;
113
- }
114
- return `border border-[var(--ads-textarea-border)] bg-[var(--ads-textarea-background)] ${text} ${focus}`;
115
- });
116
- </script>
1
+ <template>
2
+ <div class="flex w-full min-w-0 flex-col gap-0.5">
3
+ <label
4
+ v-if="label"
5
+ :for="fieldId"
6
+ class="text-[length:var(--ads-textarea-label-size)] leading-[1.2]"
7
+ :class="supportClass"
8
+ >
9
+ {{ label }}
10
+ </label>
11
+
12
+ <div
13
+ class="relative flex min-h-[var(--ads-textarea-min-height)] transition-colors rounded-[var(--ads-textarea-radius)]"
14
+ :class="fieldClass"
15
+ :data-state="visualState"
16
+ >
17
+ <textarea
18
+ :id="fieldId"
19
+ v-model="model"
20
+ class="min-h-[calc(var(--ads-textarea-min-height)-24px)] w-full flex-1 resize-y bg-transparent p-[var(--ads-textarea-padding)] pe-8 text-[length:var(--ads-textarea-font-size)] leading-[1.3] outline-none placeholder:text-current disabled:cursor-not-allowed"
21
+ :placeholder="placeholder"
22
+ :disabled="isDisabled"
23
+ :aria-invalid="error ? true : undefined"
24
+ :aria-describedby="supportText ? supportId : undefined"
25
+ />
26
+ <UIcon
27
+ name="i-lucide-move-diagonal-2"
28
+ class="pointer-events-none absolute end-3 bottom-3 size-4 text-base text-ads-neutro-medio-60"
29
+ />
30
+ </div>
31
+
32
+ <p
33
+ v-if="supportText"
34
+ :id="supportId"
35
+ class="text-[length:var(--ads-textarea-label-size)] leading-[1.2]"
36
+ :class="supportClass"
37
+ >
38
+ {{ supportText }}
39
+ </p>
40
+ </div>
41
+ </template>
42
+
43
+ <script setup lang="ts">
44
+ import { computed, useId } from "vue";
45
+
46
+ export type AdsTextareaState = "default" | "active" | "focus" | "error" | "disabled" | "ai";
47
+
48
+ const props = withDefaults(
49
+ defineProps<{
50
+ label?: string;
51
+ hint?: string;
52
+ error?: string;
53
+ placeholder?: string;
54
+ disabled?: boolean;
55
+ /** Estado congelado para a documentação. `null` segue o campo. */
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;
59
+ }>(),
60
+ {
61
+ label: "",
62
+ hint: "",
63
+ error: "",
64
+ placeholder: "",
65
+ disabled: false,
66
+ state: null,
67
+ aiSuggestion: false,
68
+ },
69
+ );
70
+
71
+ const model = defineModel<string>({ default: "" });
72
+
73
+ const fieldId = useId();
74
+ const supportId = useId();
75
+
76
+ const isDisabled = computed(() => props.disabled || props.state === "disabled");
77
+
78
+ const visualState = computed<AdsTextareaState>(() => {
79
+ if (isDisabled.value) return "disabled";
80
+ if (props.state) return props.state;
81
+ if (props.error) return "error";
82
+ if (props.aiSuggestion) return "ai";
83
+ return model.value ? "active" : "default";
84
+ });
85
+
86
+ const supportText = computed(() => props.error || props.hint);
87
+ const supportClass = computed(() =>
88
+ visualState.value === "disabled"
89
+ ? "text-[var(--ads-textarea-placeholder)]"
90
+ : "text-[var(--ads-text-secondary)]",
91
+ );
92
+
93
+ const fieldClass = computed(() => {
94
+ const interactiveFocus = props.state === null && !isDisabled.value && !props.error;
95
+ const text = visualState.value === "default" || visualState.value === "disabled"
96
+ ? "text-[var(--ads-textarea-placeholder)]"
97
+ : "text-[var(--ads-textarea-text)]";
98
+
99
+ if (visualState.value === "disabled") {
100
+ return `border border-[var(--ads-textarea-disabled-border)] bg-[var(--ads-textarea-disabled-background)] ${text}`;
101
+ }
102
+ if (visualState.value === "error") {
103
+ return `border-(length:--ads-border-width-slim) border-[var(--ads-textarea-error-border)] bg-[var(--ads-textarea-background)] ${text}`;
104
+ }
105
+ if (visualState.value === "focus") {
106
+ return `border-(length:--ads-border-width-slim) border-[var(--ads-textarea-focus-border)] bg-[var(--ads-textarea-background)] ${text}`;
107
+ }
108
+ const focus = interactiveFocus
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)]"
110
+ : "";
111
+ if (visualState.value === "ai") {
112
+ return `border border-[var(--ads-text-ai)] bg-[var(--ads-surface-ai)] text-[var(--ads-text-secondary)] ${focus}`;
113
+ }
114
+ return `border border-[var(--ads-textarea-border)] bg-[var(--ads-textarea-background)] ${text} ${focus}`;
115
+ });
116
+ </script>