ads-nuxt 0.4.0 → 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.
- package/LICENSE +21 -21
- package/README.md +574 -575
- package/app/app.config.ts +25 -25
- package/app/assets/ads/checkbox-check.svg +5 -5
- package/app/assets/ads/checkbox-minus.svg +5 -5
- package/app/assets/brand/farmarcas.svg +6 -6
- package/app/assets/brand/radar-symbol.svg +9 -9
- package/app/assets/brand/radar.svg +9 -9
- package/app/assets/css/ads-colors.css +257 -257
- package/app/assets/css/component-tokens.css +6 -2
- package/app/assets/css/main.css +585 -585
- package/app/components/AdsBadge.vue +47 -47
- package/app/components/AdsBroadcast.vue +24 -24
- package/app/components/AdsButton.vue +547 -547
- package/app/components/AdsButtonGroup.vue +39 -39
- package/app/components/AdsButtonMenu.vue +48 -48
- package/app/components/AdsCard.vue +188 -188
- package/app/components/AdsCardHint.vue +56 -22
- package/app/components/AdsCardPeriod.vue +43 -43
- package/app/components/AdsCardVariation.vue +31 -31
- package/app/components/AdsCharttip.vue +79 -79
- package/app/components/AdsDatePicker.vue +509 -509
- package/app/components/AdsDropdownMenu.vue +30 -30
- package/app/components/AdsEmptyState.vue +61 -61
- package/app/components/AdsFeatureCard.vue +292 -210
- package/app/components/AdsFileCard.vue +98 -98
- package/app/components/AdsFooter.vue +25 -25
- package/app/components/AdsHeavyAccountCell.vue +59 -59
- package/app/components/AdsHeavyHeaderCell.vue +70 -70
- package/app/components/AdsHeavyTable.vue +135 -139
- package/app/components/AdsInput.vue +148 -148
- package/app/components/AdsLoading.vue +217 -217
- package/app/components/AdsMenuBar.vue +110 -110
- package/app/components/AdsMetricCard.vue +226 -216
- package/app/components/AdsModal.vue +160 -160
- package/app/components/AdsMonthPicker.vue +80 -80
- package/app/components/AdsNavbarApp.vue +67 -67
- package/app/components/AdsNavbarDesk.vue +67 -67
- package/app/components/AdsNotabilityPill.vue +24 -24
- package/app/components/AdsNumberInput.vue +173 -173
- package/app/components/AdsPanelCard.vue +99 -99
- package/app/components/AdsPill.vue +144 -144
- package/app/components/AdsProductTag.vue +80 -80
- package/app/components/AdsSearchInput.vue +122 -122
- package/app/components/AdsSegmentedTabs.vue +62 -62
- package/app/components/AdsSelect.vue +283 -283
- package/app/components/AdsSelectItem.vue +128 -128
- package/app/components/AdsSelectPanel.vue +221 -221
- package/app/components/AdsSideMenu.vue +101 -101
- package/app/components/AdsSmalltip.vue +44 -44
- package/app/components/AdsStepper.vue +222 -222
- package/app/components/AdsTable.vue +172 -176
- package/app/components/AdsTableHeaderCell.vue +80 -80
- package/app/components/AdsTableSkeleton.vue +113 -113
- package/app/components/AdsTableToolbar.vue +44 -44
- package/app/components/AdsTabs.vue +51 -51
- package/app/components/AdsTextarea.vue +116 -116
- package/app/components/AdsToast.vue +184 -184
- package/app/components/AdsTooltip.vue +73 -73
- package/app/components/OverlayLoading.vue +2 -17
- package/app/components/ProgressBarLoading.vue +235 -235
- package/app/composables/useOverlayLoading.ts +88 -88
- package/app/constants/ads-color-swatches.ts +240 -240
- package/app/locale/pt-br.ts +6 -6
- package/app/plugins/ads-toast.client.ts +24 -24
- package/app/theme/ads-theme.ts +374 -374
- package/app/theme/ads-tokens.ts +391 -391
- package/app/theme/component-tokens.json +6 -2
- package/app/theme/component-tokens.ts +6 -2
- package/app/types/overlay-loading.types.ts +32 -35
- package/app/utils/ads-filter-select.ts +191 -191
- package/app/utils/ads-table.ts +416 -398
- package/app/utils/calendar-date.ts +163 -163
- package/app/utils/category-role.ts +45 -45
- package/app/utils/money.ts +77 -77
- package/app/utils/notability.ts +8 -8
- package/app/utils/parser.ts +134 -134
- package/app/utils/percentage.ts +54 -54
- package/nuxt.config.ts +31 -31
- package/package.json +57 -56
|
@@ -1,139 +1,135 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
AdsHeavyTable — Tabela financeira (Figma: "Heavy Table").
|
|
3
|
-
|
|
4
|
-
Baseada no UTable (via AdsTable) com:
|
|
5
|
-
- Cabeçalho em dois níveis (grupos de colunas via nested `columns`).
|
|
6
|
-
- Grupos de linhas em accordion expandir/recolher (_Fin Group):
|
|
7
|
-
passe `get-sub-rows`, `get-row-id` e `v-model:expanded`;
|
|
8
|
-
na primeira coluna, use `AdsHeavyAccountCell`.
|
|
9
|
-
- Títulos com ordenar e fixar via `AdsHeavyHeaderCell`.
|
|
10
|
-
- Larguras e divisórias de período via `adsHeavyColumn` e `adsHeavyAccountColumn()`.
|
|
11
|
-
- Cabeçalho fixo por padrão (`sticky="header"`).
|
|
12
|
-
- Tons de variação e projeção via `adsHeavyVariationClass()`.
|
|
13
|
-
|
|
14
|
-
Props não declaradas (column-pinning, get-row-id, get-sub-rows, v-model:expanded,
|
|
15
|
-
footer, row-class, etc.) são repassadas ao UTable via attrs fallthrough.
|
|
16
|
-
Para o botão de fixar funcionar, use `v-model:column-pinning`.
|
|
17
|
-
|
|
18
|
-
@example
|
|
19
|
-
```vue
|
|
20
|
-
<AdsHeavyTable
|
|
21
|
-
:data="rows"
|
|
22
|
-
:columns="cols"
|
|
23
|
-
:get-sub-rows="(row) => row.children"
|
|
24
|
-
:get-row-id="(row) => row.id"
|
|
25
|
-
v-model:expanded="expanded"
|
|
26
|
-
v-model:column-pinning="pinning"
|
|
27
|
-
class="max-h-96"
|
|
28
|
-
>
|
|
29
|
-
<template #name-cell="{ row }">
|
|
30
|
-
<AdsHeavyAccountCell :row="row" :label="row.original.name" />
|
|
31
|
-
</template>
|
|
32
|
-
</AdsHeavyTable>
|
|
33
|
-
```
|
|
34
|
-
-->
|
|
35
|
-
<template>
|
|
36
|
-
<AdsTable
|
|
37
|
-
:data="data"
|
|
38
|
-
:columns="columns"
|
|
39
|
-
:loading="loading"
|
|
40
|
-
:skeleton-rows="skeletonRows"
|
|
41
|
-
:skeleton-variant="skeletonVariant"
|
|
42
|
-
:skeleton-cell-size="adsHeavyCellSize(density)"
|
|
43
|
-
:sticky="sticky"
|
|
44
|
-
:virtualize="virtualize"
|
|
45
|
-
:framed="framed"
|
|
46
|
-
:density="density"
|
|
47
|
-
:striped="false"
|
|
48
|
-
:borders="borders"
|
|
49
|
-
:depth="false"
|
|
50
|
-
:pinned-edge="false"
|
|
51
|
-
:empty-label="emptyLabel"
|
|
52
|
-
:empty-icon="emptyIcon"
|
|
53
|
-
:loading-label="loadingLabel"
|
|
54
|
-
:ui="mergedUi"
|
|
55
|
-
v-bind="$attrs"
|
|
56
|
-
>
|
|
57
|
-
<template v-for="(_, name) in $slots" #[name]="slotProps">
|
|
58
|
-
<slot :name="name" v-bind="slotProps ?? {}" />
|
|
59
|
-
</template>
|
|
60
|
-
</AdsTable>
|
|
61
|
-
</template>
|
|
62
|
-
|
|
63
|
-
<script setup lang="ts" generic="T extends TableData">
|
|
64
|
-
import { computed } from "vue";
|
|
65
|
-
import type { TableColumn, TableData } from "@nuxt/ui";
|
|
66
|
-
import AdsTable from "./AdsTable.vue";
|
|
67
|
-
import type { AdsTableSkeletonVariant } from "./AdsTableSkeleton.vue";
|
|
68
|
-
import {
|
|
69
|
-
adsHeavyCellSize,
|
|
70
|
-
buildAdsHeavyTableUi,
|
|
71
|
-
|
|
72
|
-
type
|
|
73
|
-
type
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
return merged;
|
|
138
|
-
});
|
|
139
|
-
</script>
|
|
1
|
+
<!--
|
|
2
|
+
AdsHeavyTable — Tabela financeira (Figma: "Heavy Table").
|
|
3
|
+
|
|
4
|
+
Baseada no UTable (via AdsTable) com:
|
|
5
|
+
- Cabeçalho em dois níveis (grupos de colunas via nested `columns`).
|
|
6
|
+
- Grupos de linhas em accordion expandir/recolher (_Fin Group):
|
|
7
|
+
passe `get-sub-rows`, `get-row-id` e `v-model:expanded`;
|
|
8
|
+
na primeira coluna, use `AdsHeavyAccountCell`.
|
|
9
|
+
- Títulos com ordenar e fixar via `AdsHeavyHeaderCell`.
|
|
10
|
+
- Larguras e divisórias de período via `adsHeavyColumn` e `adsHeavyAccountColumn()`.
|
|
11
|
+
- Cabeçalho fixo por padrão (`sticky="header"`).
|
|
12
|
+
- Tons de variação e projeção via `adsHeavyVariationClass()`.
|
|
13
|
+
|
|
14
|
+
Props não declaradas (column-pinning, get-row-id, get-sub-rows, v-model:expanded,
|
|
15
|
+
footer, row-class, etc.) são repassadas ao UTable via attrs fallthrough.
|
|
16
|
+
Para o botão de fixar funcionar, use `v-model:column-pinning`.
|
|
17
|
+
|
|
18
|
+
@example
|
|
19
|
+
```vue
|
|
20
|
+
<AdsHeavyTable
|
|
21
|
+
:data="rows"
|
|
22
|
+
:columns="cols"
|
|
23
|
+
:get-sub-rows="(row) => row.children"
|
|
24
|
+
:get-row-id="(row) => row.id"
|
|
25
|
+
v-model:expanded="expanded"
|
|
26
|
+
v-model:column-pinning="pinning"
|
|
27
|
+
class="max-h-96"
|
|
28
|
+
>
|
|
29
|
+
<template #name-cell="{ row }">
|
|
30
|
+
<AdsHeavyAccountCell :row="row" :label="row.original.name" />
|
|
31
|
+
</template>
|
|
32
|
+
</AdsHeavyTable>
|
|
33
|
+
```
|
|
34
|
+
-->
|
|
35
|
+
<template>
|
|
36
|
+
<AdsTable
|
|
37
|
+
:data="data"
|
|
38
|
+
:columns="columns"
|
|
39
|
+
:loading="loading"
|
|
40
|
+
:skeleton-rows="skeletonRows"
|
|
41
|
+
:skeleton-variant="skeletonVariant"
|
|
42
|
+
:skeleton-cell-size="adsHeavyCellSize(density)"
|
|
43
|
+
:sticky="sticky"
|
|
44
|
+
:virtualize="virtualize"
|
|
45
|
+
:framed="framed"
|
|
46
|
+
:density="density"
|
|
47
|
+
:striped="false"
|
|
48
|
+
:borders="borders"
|
|
49
|
+
:depth="false"
|
|
50
|
+
:pinned-edge="false"
|
|
51
|
+
:empty-label="emptyLabel"
|
|
52
|
+
:empty-icon="emptyIcon"
|
|
53
|
+
:loading-label="loadingLabel"
|
|
54
|
+
:ui="mergedUi"
|
|
55
|
+
v-bind="$attrs"
|
|
56
|
+
>
|
|
57
|
+
<template v-for="(_, name) in $slots" #[name]="slotProps">
|
|
58
|
+
<slot :name="name" v-bind="slotProps ?? {}" />
|
|
59
|
+
</template>
|
|
60
|
+
</AdsTable>
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<script setup lang="ts" generic="T extends TableData">
|
|
64
|
+
import { computed } from "vue";
|
|
65
|
+
import type { TableColumn, TableData } from "@nuxt/ui";
|
|
66
|
+
import AdsTable from "./AdsTable.vue";
|
|
67
|
+
import type { AdsTableSkeletonVariant } from "./AdsTableSkeleton.vue";
|
|
68
|
+
import {
|
|
69
|
+
adsHeavyCellSize,
|
|
70
|
+
buildAdsHeavyTableUi,
|
|
71
|
+
mergeAdsTableUi,
|
|
72
|
+
type AdsTableBorders,
|
|
73
|
+
type AdsTableDensity,
|
|
74
|
+
type AdsTableUi,
|
|
75
|
+
} from "../utils/ads-table";
|
|
76
|
+
|
|
77
|
+
defineOptions({ inheritAttrs: false });
|
|
78
|
+
|
|
79
|
+
const props = withDefaults(
|
|
80
|
+
defineProps<{
|
|
81
|
+
data: T[];
|
|
82
|
+
columns: TableColumn<T>[];
|
|
83
|
+
/** md: padrão financeiro. sm: tabela compacta. */
|
|
84
|
+
density?: AdsTableDensity;
|
|
85
|
+
/** Borda e raio próprios. Dentro de AdsCard, false. */
|
|
86
|
+
framed?: boolean;
|
|
87
|
+
/** lines: só horizontal. grid: horizontal e vertical. */
|
|
88
|
+
borders?: AdsTableBorders;
|
|
89
|
+
loading?: boolean;
|
|
90
|
+
/** Número de linhas do skeleton de carregamento (1–8). */
|
|
91
|
+
skeletonRows?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Estilo do skeleton padrão.
|
|
94
|
+
* skeleton: barras de placeholder. logo: loader do Radar.
|
|
95
|
+
*/
|
|
96
|
+
skeletonVariant?: AdsTableSkeletonVariant;
|
|
97
|
+
/**
|
|
98
|
+
* Cabeçalho fixo quando a tabela tem altura máxima.
|
|
99
|
+
* Padrão: "header" — cabeçalho fica no topo ao rolar horizontalmente.
|
|
100
|
+
*/
|
|
101
|
+
sticky?: boolean | "header" | "footer";
|
|
102
|
+
/** Lista virtual para muitas linhas. Repassa ao AdsTable. */
|
|
103
|
+
virtualize?: boolean;
|
|
104
|
+
emptyLabel?: string;
|
|
105
|
+
emptyIcon?: string;
|
|
106
|
+
loadingLabel?: string;
|
|
107
|
+
/** Ajuste pontual de um slot; soma ao padrão. */
|
|
108
|
+
ui?: Partial<AdsTableUi>;
|
|
109
|
+
}>(),
|
|
110
|
+
{
|
|
111
|
+
density: "md",
|
|
112
|
+
framed: true,
|
|
113
|
+
borders: "lines",
|
|
114
|
+
loading: false,
|
|
115
|
+
skeletonRows: 5,
|
|
116
|
+
skeletonVariant: "skeleton",
|
|
117
|
+
sticky: "header",
|
|
118
|
+
virtualize: false,
|
|
119
|
+
emptyLabel: "Nenhum registro encontrado",
|
|
120
|
+
emptyIcon: "i-lucide-inbox",
|
|
121
|
+
loadingLabel: undefined,
|
|
122
|
+
ui: undefined,
|
|
123
|
+
},
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const mergedUi = computed((): AdsTableUi => {
|
|
127
|
+
const base = buildAdsHeavyTableUi({
|
|
128
|
+
density: props.density,
|
|
129
|
+
framed: props.framed,
|
|
130
|
+
borders: props.borders,
|
|
131
|
+
stickyHeader: props.sticky === true || props.sticky === "header",
|
|
132
|
+
});
|
|
133
|
+
return mergeAdsTableUi(base, props.ui);
|
|
134
|
+
});
|
|
135
|
+
</script>
|
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="flex w-full min-w-0 flex-col gap-0.5">
|
|
3
|
-
<div
|
|
4
|
-
v-if="label"
|
|
5
|
-
class="flex items-center gap-0.5 text-[length:var(--ads-input-label-size)] leading-[1.2]"
|
|
6
|
-
:class="supportClass"
|
|
7
|
-
>
|
|
8
|
-
<label :for="fieldId">{{ label }}</label>
|
|
9
|
-
<AdsTooltip v-if="info" :description="info" :show-title="false">
|
|
10
|
-
<span class="inline-flex">
|
|
11
|
-
<UIcon name="i-lucide-info" class="size-3 text-xs" />
|
|
12
|
-
</span>
|
|
13
|
-
</AdsTooltip>
|
|
14
|
-
</div>
|
|
15
|
-
|
|
16
|
-
<div
|
|
17
|
-
class="flex h-[var(--ads-input-height)] items-center transition-colors gap-[var(--ads-input-gap)] rounded-[var(--ads-input-radius)] px-[var(--ads-input-padding-x)]"
|
|
18
|
-
:class="fieldClass"
|
|
19
|
-
:data-state="visualState"
|
|
20
|
-
>
|
|
21
|
-
<input
|
|
22
|
-
:id="fieldId"
|
|
23
|
-
:value="displayValue"
|
|
24
|
-
:type="type"
|
|
25
|
-
class="min-w-0 flex-1 bg-transparent text-[length:var(--ads-input-font-size)] leading-[1.3] outline-none placeholder:text-current disabled:cursor-not-allowed"
|
|
26
|
-
:class="type === 'number' ? '[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none' : undefined"
|
|
27
|
-
:placeholder="placeholder"
|
|
28
|
-
:disabled="isDisabled"
|
|
29
|
-
:min="min"
|
|
30
|
-
:step="step"
|
|
31
|
-
:aria-invalid="error ? true : undefined"
|
|
32
|
-
:aria-describedby="supportText ? supportId : undefined"
|
|
33
|
-
@input="onInput"
|
|
34
|
-
@focus="emit('focus', $event)"
|
|
35
|
-
@blur="emit('blur', $event)"
|
|
36
|
-
>
|
|
37
|
-
<span v-if="suffix" class="shrink-0 text-[length:var(--ads-input-font-size)] leading-[1.3]">{{ suffix }}</span>
|
|
38
|
-
<UIcon v-if="icon" :name="icon" class="size-4 shrink-0 text-base" />
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
<p
|
|
42
|
-
v-if="supportText"
|
|
43
|
-
:id="supportId"
|
|
44
|
-
class="text-xs leading-[1.2]"
|
|
45
|
-
:class="supportClass"
|
|
46
|
-
>
|
|
47
|
-
{{ supportText }}
|
|
48
|
-
</p>
|
|
49
|
-
</div>
|
|
50
|
-
</template>
|
|
51
|
-
|
|
52
|
-
<script setup lang="ts">
|
|
53
|
-
import { computed, useId } from "vue";
|
|
54
|
-
import AdsTooltip from "./AdsTooltip.vue";
|
|
55
|
-
|
|
56
|
-
export type AdsInputState = "default" | "active" | "focus" | "error" | "disabled" | "ai";
|
|
57
|
-
|
|
58
|
-
const props = withDefaults(
|
|
59
|
-
defineProps<{
|
|
60
|
-
label?: string;
|
|
61
|
-
hint?: string;
|
|
62
|
-
error?: string;
|
|
63
|
-
info?: string;
|
|
64
|
-
placeholder?: string;
|
|
65
|
-
disabled?: boolean;
|
|
66
|
-
icon?: string;
|
|
67
|
-
type?: "text" | "number";
|
|
68
|
-
suffix?: string;
|
|
69
|
-
min?: string | number;
|
|
70
|
-
step?: string | number;
|
|
71
|
-
/** Estado congelado para a documentação. `null` segue o campo. */
|
|
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;
|
|
75
|
-
}>(),
|
|
76
|
-
{
|
|
77
|
-
label: "",
|
|
78
|
-
hint: "",
|
|
79
|
-
error: "",
|
|
80
|
-
info: "",
|
|
81
|
-
placeholder: "",
|
|
82
|
-
disabled: false,
|
|
83
|
-
icon: "",
|
|
84
|
-
type: "text",
|
|
85
|
-
suffix: "",
|
|
86
|
-
state: null,
|
|
87
|
-
aiSuggestion: false,
|
|
88
|
-
},
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const model = defineModel<string | number>({ default: "" });
|
|
92
|
-
|
|
93
|
-
const emit = defineEmits<{
|
|
94
|
-
focus: [event: FocusEvent];
|
|
95
|
-
blur: [event: FocusEvent];
|
|
96
|
-
}>();
|
|
97
|
-
|
|
98
|
-
const fieldId = useId();
|
|
99
|
-
const supportId = useId();
|
|
100
|
-
|
|
101
|
-
const displayValue = computed(() =>
|
|
102
|
-
model.value === undefined || model.value === null ? "" : String(model.value),
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
const onInput = (event: Event) => {
|
|
106
|
-
const value = (event.target as HTMLInputElement).value;
|
|
107
|
-
model.value = value;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const isDisabled = computed(() => props.disabled || props.state === "disabled");
|
|
111
|
-
|
|
112
|
-
const visualState = computed<AdsInputState>(() => {
|
|
113
|
-
if (isDisabled.value) return "disabled";
|
|
114
|
-
if (props.state) return props.state;
|
|
115
|
-
if (props.error) return "error";
|
|
116
|
-
if (props.aiSuggestion) return "ai";
|
|
117
|
-
return displayValue.value ? "active" : "default";
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const supportText = computed(() => props.error || props.hint);
|
|
121
|
-
const supportClass = computed(() =>
|
|
122
|
-
visualState.value === "disabled"
|
|
123
|
-
? "text-[var(--ads-input-disabled-text)]"
|
|
124
|
-
: "text-[var(--ads-text-secondary)]",
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const fieldClass = computed(() => {
|
|
128
|
-
const interactiveFocus = props.state === null && !isDisabled.value && !props.error;
|
|
129
|
-
const focus = interactiveFocus
|
|
130
|
-
? "hover:not-focus-within:border-[var(--ads-input-hover-border)] focus-within:border-(length:--ads-border-width-slim) focus-within:border-[var(--ads-input-focus-border)]"
|
|
131
|
-
: "";
|
|
132
|
-
|
|
133
|
-
if (visualState.value === "disabled") {
|
|
134
|
-
return "border border-[var(--ads-input-disabled-border)] bg-[var(--ads-input-disabled-background)] text-[var(--ads-input-disabled-text)]";
|
|
135
|
-
}
|
|
136
|
-
if (visualState.value === "error") {
|
|
137
|
-
return `border-(length:--ads-border-width-slim) border-[var(--ads-input-error-border)] bg-[var(--ads-input-background)] text-[var(--ads-input-text)] ${focus}`;
|
|
138
|
-
}
|
|
139
|
-
if (visualState.value === "focus") {
|
|
140
|
-
return "border-(length:--ads-border-width-slim) border-[var(--ads-input-focus-border)] bg-[var(--ads-input-background)] text-[var(--ads-input-text)]";
|
|
141
|
-
}
|
|
142
|
-
if (visualState.value === "ai") {
|
|
143
|
-
// Figma AI Mode: borda text/ai (#613dda), fundo surface/ai e texto secundário.
|
|
144
|
-
return `border border-[var(--ads-text-ai)] bg-[var(--ads-surface-ai)] text-[var(--ads-input-text)] ${focus}`;
|
|
145
|
-
}
|
|
146
|
-
return `border border-[var(--ads-input-border)] bg-[var(--ads-input-background)] text-[var(--ads-input-text)] ${focus}`;
|
|
147
|
-
});
|
|
148
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex w-full min-w-0 flex-col gap-0.5">
|
|
3
|
+
<div
|
|
4
|
+
v-if="label"
|
|
5
|
+
class="flex items-center gap-0.5 text-[length:var(--ads-input-label-size)] leading-[1.2]"
|
|
6
|
+
:class="supportClass"
|
|
7
|
+
>
|
|
8
|
+
<label :for="fieldId">{{ label }}</label>
|
|
9
|
+
<AdsTooltip v-if="info" :description="info" :show-title="false">
|
|
10
|
+
<span class="inline-flex">
|
|
11
|
+
<UIcon name="i-lucide-info" class="size-3 text-xs" />
|
|
12
|
+
</span>
|
|
13
|
+
</AdsTooltip>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
class="flex h-[var(--ads-input-height)] items-center transition-colors gap-[var(--ads-input-gap)] rounded-[var(--ads-input-radius)] px-[var(--ads-input-padding-x)]"
|
|
18
|
+
:class="fieldClass"
|
|
19
|
+
:data-state="visualState"
|
|
20
|
+
>
|
|
21
|
+
<input
|
|
22
|
+
:id="fieldId"
|
|
23
|
+
:value="displayValue"
|
|
24
|
+
:type="type"
|
|
25
|
+
class="min-w-0 flex-1 bg-transparent text-[length:var(--ads-input-font-size)] leading-[1.3] outline-none placeholder:text-current disabled:cursor-not-allowed"
|
|
26
|
+
:class="type === 'number' ? '[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none' : undefined"
|
|
27
|
+
:placeholder="placeholder"
|
|
28
|
+
:disabled="isDisabled"
|
|
29
|
+
:min="min"
|
|
30
|
+
:step="step"
|
|
31
|
+
:aria-invalid="error ? true : undefined"
|
|
32
|
+
:aria-describedby="supportText ? supportId : undefined"
|
|
33
|
+
@input="onInput"
|
|
34
|
+
@focus="emit('focus', $event)"
|
|
35
|
+
@blur="emit('blur', $event)"
|
|
36
|
+
>
|
|
37
|
+
<span v-if="suffix" class="shrink-0 text-[length:var(--ads-input-font-size)] leading-[1.3]">{{ suffix }}</span>
|
|
38
|
+
<UIcon v-if="icon" :name="icon" class="size-4 shrink-0 text-base" />
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<p
|
|
42
|
+
v-if="supportText"
|
|
43
|
+
:id="supportId"
|
|
44
|
+
class="text-xs leading-[1.2]"
|
|
45
|
+
:class="supportClass"
|
|
46
|
+
>
|
|
47
|
+
{{ supportText }}
|
|
48
|
+
</p>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script setup lang="ts">
|
|
53
|
+
import { computed, useId } from "vue";
|
|
54
|
+
import AdsTooltip from "./AdsTooltip.vue";
|
|
55
|
+
|
|
56
|
+
export type AdsInputState = "default" | "active" | "focus" | "error" | "disabled" | "ai";
|
|
57
|
+
|
|
58
|
+
const props = withDefaults(
|
|
59
|
+
defineProps<{
|
|
60
|
+
label?: string;
|
|
61
|
+
hint?: string;
|
|
62
|
+
error?: string;
|
|
63
|
+
info?: string;
|
|
64
|
+
placeholder?: string;
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
icon?: string;
|
|
67
|
+
type?: "text" | "number";
|
|
68
|
+
suffix?: string;
|
|
69
|
+
min?: string | number;
|
|
70
|
+
step?: string | number;
|
|
71
|
+
/** Estado congelado para a documentação. `null` segue o campo. */
|
|
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;
|
|
75
|
+
}>(),
|
|
76
|
+
{
|
|
77
|
+
label: "",
|
|
78
|
+
hint: "",
|
|
79
|
+
error: "",
|
|
80
|
+
info: "",
|
|
81
|
+
placeholder: "",
|
|
82
|
+
disabled: false,
|
|
83
|
+
icon: "",
|
|
84
|
+
type: "text",
|
|
85
|
+
suffix: "",
|
|
86
|
+
state: null,
|
|
87
|
+
aiSuggestion: false,
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const model = defineModel<string | number>({ default: "" });
|
|
92
|
+
|
|
93
|
+
const emit = defineEmits<{
|
|
94
|
+
focus: [event: FocusEvent];
|
|
95
|
+
blur: [event: FocusEvent];
|
|
96
|
+
}>();
|
|
97
|
+
|
|
98
|
+
const fieldId = useId();
|
|
99
|
+
const supportId = useId();
|
|
100
|
+
|
|
101
|
+
const displayValue = computed(() =>
|
|
102
|
+
model.value === undefined || model.value === null ? "" : String(model.value),
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const onInput = (event: Event) => {
|
|
106
|
+
const value = (event.target as HTMLInputElement).value;
|
|
107
|
+
model.value = value;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const isDisabled = computed(() => props.disabled || props.state === "disabled");
|
|
111
|
+
|
|
112
|
+
const visualState = computed<AdsInputState>(() => {
|
|
113
|
+
if (isDisabled.value) return "disabled";
|
|
114
|
+
if (props.state) return props.state;
|
|
115
|
+
if (props.error) return "error";
|
|
116
|
+
if (props.aiSuggestion) return "ai";
|
|
117
|
+
return displayValue.value ? "active" : "default";
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const supportText = computed(() => props.error || props.hint);
|
|
121
|
+
const supportClass = computed(() =>
|
|
122
|
+
visualState.value === "disabled"
|
|
123
|
+
? "text-[var(--ads-input-disabled-text)]"
|
|
124
|
+
: "text-[var(--ads-text-secondary)]",
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const fieldClass = computed(() => {
|
|
128
|
+
const interactiveFocus = props.state === null && !isDisabled.value && !props.error;
|
|
129
|
+
const focus = interactiveFocus
|
|
130
|
+
? "hover:not-focus-within:border-[var(--ads-input-hover-border)] focus-within:border-(length:--ads-border-width-slim) focus-within:border-[var(--ads-input-focus-border)]"
|
|
131
|
+
: "";
|
|
132
|
+
|
|
133
|
+
if (visualState.value === "disabled") {
|
|
134
|
+
return "border border-[var(--ads-input-disabled-border)] bg-[var(--ads-input-disabled-background)] text-[var(--ads-input-disabled-text)]";
|
|
135
|
+
}
|
|
136
|
+
if (visualState.value === "error") {
|
|
137
|
+
return `border-(length:--ads-border-width-slim) border-[var(--ads-input-error-border)] bg-[var(--ads-input-background)] text-[var(--ads-input-text)] ${focus}`;
|
|
138
|
+
}
|
|
139
|
+
if (visualState.value === "focus") {
|
|
140
|
+
return "border-(length:--ads-border-width-slim) border-[var(--ads-input-focus-border)] bg-[var(--ads-input-background)] text-[var(--ads-input-text)]";
|
|
141
|
+
}
|
|
142
|
+
if (visualState.value === "ai") {
|
|
143
|
+
// Figma AI Mode: borda text/ai (#613dda), fundo surface/ai e texto secundário.
|
|
144
|
+
return `border border-[var(--ads-text-ai)] bg-[var(--ads-surface-ai)] text-[var(--ads-input-text)] ${focus}`;
|
|
145
|
+
}
|
|
146
|
+
return `border border-[var(--ads-input-border)] bg-[var(--ads-input-background)] text-[var(--ads-input-text)] ${focus}`;
|
|
147
|
+
});
|
|
148
|
+
</script>
|