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.
Files changed (80) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +574 -575
  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/component-tokens.css +6 -2
  11. package/app/assets/css/main.css +585 -585
  12. package/app/components/AdsBadge.vue +47 -47
  13. package/app/components/AdsBroadcast.vue +24 -24
  14. package/app/components/AdsButton.vue +547 -547
  15. package/app/components/AdsButtonGroup.vue +39 -39
  16. package/app/components/AdsButtonMenu.vue +48 -48
  17. package/app/components/AdsCard.vue +188 -188
  18. package/app/components/AdsCardHint.vue +56 -22
  19. package/app/components/AdsCardPeriod.vue +43 -43
  20. package/app/components/AdsCardVariation.vue +31 -31
  21. package/app/components/AdsCharttip.vue +79 -79
  22. package/app/components/AdsDatePicker.vue +509 -509
  23. package/app/components/AdsDropdownMenu.vue +30 -30
  24. package/app/components/AdsEmptyState.vue +61 -61
  25. package/app/components/AdsFeatureCard.vue +292 -210
  26. package/app/components/AdsFileCard.vue +98 -98
  27. package/app/components/AdsFooter.vue +25 -25
  28. package/app/components/AdsHeavyAccountCell.vue +59 -59
  29. package/app/components/AdsHeavyHeaderCell.vue +70 -70
  30. package/app/components/AdsHeavyTable.vue +135 -139
  31. package/app/components/AdsInput.vue +148 -148
  32. package/app/components/AdsLoading.vue +217 -217
  33. package/app/components/AdsMenuBar.vue +110 -110
  34. package/app/components/AdsMetricCard.vue +226 -216
  35. package/app/components/AdsModal.vue +160 -160
  36. package/app/components/AdsMonthPicker.vue +80 -80
  37. package/app/components/AdsNavbarApp.vue +67 -67
  38. package/app/components/AdsNavbarDesk.vue +67 -67
  39. package/app/components/AdsNotabilityPill.vue +24 -24
  40. package/app/components/AdsNumberInput.vue +173 -173
  41. package/app/components/AdsPanelCard.vue +99 -99
  42. package/app/components/AdsPill.vue +144 -144
  43. package/app/components/AdsProductTag.vue +80 -80
  44. package/app/components/AdsSearchInput.vue +122 -122
  45. package/app/components/AdsSegmentedTabs.vue +62 -62
  46. package/app/components/AdsSelect.vue +283 -283
  47. package/app/components/AdsSelectItem.vue +128 -128
  48. package/app/components/AdsSelectPanel.vue +221 -221
  49. package/app/components/AdsSideMenu.vue +101 -101
  50. package/app/components/AdsSmalltip.vue +44 -44
  51. package/app/components/AdsStepper.vue +222 -222
  52. package/app/components/AdsTable.vue +172 -176
  53. package/app/components/AdsTableHeaderCell.vue +80 -80
  54. package/app/components/AdsTableSkeleton.vue +113 -113
  55. package/app/components/AdsTableToolbar.vue +44 -44
  56. package/app/components/AdsTabs.vue +51 -51
  57. package/app/components/AdsTextarea.vue +116 -116
  58. package/app/components/AdsToast.vue +184 -184
  59. package/app/components/AdsTooltip.vue +73 -73
  60. package/app/components/OverlayLoading.vue +2 -17
  61. package/app/components/ProgressBarLoading.vue +235 -235
  62. package/app/composables/useOverlayLoading.ts +88 -88
  63. package/app/constants/ads-color-swatches.ts +240 -240
  64. package/app/locale/pt-br.ts +6 -6
  65. package/app/plugins/ads-toast.client.ts +24 -24
  66. package/app/theme/ads-theme.ts +374 -374
  67. package/app/theme/ads-tokens.ts +391 -391
  68. package/app/theme/component-tokens.json +6 -2
  69. package/app/theme/component-tokens.ts +6 -2
  70. package/app/types/overlay-loading.types.ts +32 -35
  71. package/app/utils/ads-filter-select.ts +191 -191
  72. package/app/utils/ads-table.ts +416 -398
  73. package/app/utils/calendar-date.ts +163 -163
  74. package/app/utils/category-role.ts +45 -45
  75. package/app/utils/money.ts +77 -77
  76. package/app/utils/notability.ts +8 -8
  77. package/app/utils/parser.ts +134 -134
  78. package/app/utils/percentage.ts +54 -54
  79. package/nuxt.config.ts +31 -31
  80. package/package.json +57 -56
@@ -280,13 +280,17 @@
280
280
  "--ads-modal-border": "#c1c7d0",
281
281
  "--ads-modal-title": "#061938",
282
282
  "--ads-modal-body": "#505f79",
283
- "--ads-feature-width": "396px",
284
- "--ads-feature-gap": "16px",
283
+ "--ads-feature-width": "390px",
284
+ "--ads-feature-padding": "24px",
285
+ "--ads-feature-gap": "24px",
285
286
  "--ads-feature-icon-box": "48px",
286
287
  "--ads-feature-title-size": "16px",
287
288
  "--ads-feature-body-size": "14px",
288
289
  "--ads-feature-title": "#061938",
289
290
  "--ads-feature-body": "#505f79",
291
+ "--ads-feature-accent-blue": "#d9eaff",
292
+ "--ads-feature-accent-green": "#e8f8ef",
293
+ "--ads-feature-accent-green-icon": "#16a34a",
290
294
  "--ads-card-padding": "16px",
291
295
  "--ads-card-radius": "12px",
292
296
  "--ads-card-radius-sm": "8px",
@@ -531,13 +531,17 @@ export const componentTokenCatalog: readonly TokenComponent[] = [
531
531
  catalog: "feature-card",
532
532
  label: "Feature card",
533
533
  fields: [
534
- length("--ads-feature-width", "Largura", "Medida", "396px"),
535
- length("--ads-feature-gap", "Espaço", "Medida", "16px"),
534
+ length("--ads-feature-width", "Largura", "Medida", "390px"),
535
+ length("--ads-feature-padding", "Padding", "Medida", "24px"),
536
+ length("--ads-feature-gap", "Espaço", "Medida", "24px"),
536
537
  length("--ads-feature-icon-box", "Caixa do ícone", "Medida", "48px"),
537
538
  length("--ads-feature-title-size", "Fonte do título", "Medida", "16px"),
538
539
  length("--ads-feature-body-size", "Fonte do texto", "Medida", "14px"),
539
540
  color("--ads-feature-title", "Título", "Cores", "#061938"),
540
541
  color("--ads-feature-body", "Texto", "Cores", "#505f79"),
542
+ color("--ads-feature-accent-blue", "Fundo azul", "Pílula", "#d9eaff"),
543
+ color("--ads-feature-accent-green", "Fundo verde", "Pílula", "#e8f8ef"),
544
+ color("--ads-feature-accent-green-icon", "Ícone verde", "Pílula", "#16a34a"),
541
545
  ],
542
546
  },
543
547
  {
@@ -1,35 +1,32 @@
1
- export type OverlayVariant =
2
- | "loading"
3
- | "success"
4
- | "error"
5
- | "search"
6
- | "info"
7
- | "warning";
8
-
9
- /** loading e search bloqueiam a tela até o processo terminar; os demais podem ser fechados. */
10
- export type OverlayClosableVariant = "info" | "success" | "error" | "warning";
11
-
12
- export interface OverlayLoadingOptions {
13
- title?: string;
14
- description?: string;
15
- hint?: string;
16
- showProgress?: boolean;
17
- progress?: number;
18
- variant?: OverlayVariant;
19
- iconSrc?: string;
20
- actionLabel?: string;
21
- /** Ícone Lucide do botão de ação. Sem valor: refresh-cw no erro, nenhum nos demais. */
22
- actionIcon?: string;
23
- onAction?: () => void;
24
- /** Segunda ação, em botão unfilled ao lado da primeira (ex.: "Fechar" junto de "Tentar novamente"). */
25
- secondaryActionLabel?: string;
26
- secondaryActionIcon?: string;
27
- /** Sem valor, a ação secundária fecha o overlay. */
28
- onSecondaryAction?: () => void;
29
- onUserClose?: () => void;
30
- closableVariants?: OverlayClosableVariant[];
31
- }
32
-
33
- export interface OverlayLoadingProps extends OverlayLoadingOptions {
34
- isVisible: boolean;
35
- }
1
+ export type OverlayVariant =
2
+ | "loading"
3
+ | "success"
4
+ | "error"
5
+ | "search"
6
+ | "info"
7
+ | "warning";
8
+
9
+ export interface OverlayLoadingOptions {
10
+ title?: string;
11
+ description?: string;
12
+ hint?: string;
13
+ showProgress?: boolean;
14
+ progress?: number;
15
+ variant?: OverlayVariant;
16
+ iconSrc?: string;
17
+ actionLabel?: string;
18
+ /** Ícone Lucide do botão de ação. Sem valor: refresh-cw no erro, nenhum nos demais. */
19
+ actionIcon?: string;
20
+ onAction?: () => void;
21
+ /** Segunda ação, em botão unfilled ao lado da primeira (ex.: "Fechar" junto de "Tentar novamente"). */
22
+ secondaryActionLabel?: string;
23
+ secondaryActionIcon?: string;
24
+ /** Sem valor, a ação secundária fecha o overlay. */
25
+ onSecondaryAction?: () => void;
26
+ /** Disparado quando uma ação de fechar é acionada. */
27
+ onUserClose?: () => void;
28
+ }
29
+
30
+ export interface OverlayLoadingProps extends OverlayLoadingOptions {
31
+ isVisible: boolean;
32
+ }
@@ -1,191 +1,191 @@
1
- /** Reticências a partir deste tamanho. A tooltip só entra quando o rótulo passa daqui. */
2
- export const ADS_FILTER_LABEL_LIMIT = 22;
3
-
4
- export const ADS_FILTER_MONTHS = [
5
- { short: "Jan", full: "Janeiro" },
6
- { short: "Fev", full: "Fevereiro" },
7
- { short: "Mar", full: "Março" },
8
- { short: "Abr", full: "Abril" },
9
- { short: "Mai", full: "Maio" },
10
- { short: "Jun", full: "Junho" },
11
- { short: "Jul", full: "Julho" },
12
- { short: "Ago", full: "Agosto" },
13
- { short: "Set", full: "Setembro" },
14
- { short: "Out", full: "Outubro" },
15
- { short: "Nov", full: "Novembro" },
16
- { short: "Dez", full: "Dezembro" },
17
- ] as const;
18
-
19
- /** Texto curto acima do título da opção, como "Novo!" ou "Sugestão Inteligente". */
20
- export interface AdsFilterOptionBadge {
21
- label: string;
22
- /** brand (azul, padrão) ou ai (roxo, com sparkles se não houver ícone). */
23
- tone?: "brand" | "ai";
24
- /** Ícone Lucide de 12px antes do texto. */
25
- icon?: string;
26
- }
27
-
28
- export interface AdsFilterOption {
29
- value: string;
30
- label: string;
31
- /** Linha de apoio abaixo do título. Também entra na busca. */
32
- subtitle?: string;
33
- badge?: AdsFilterOptionBadge;
34
- disabled?: boolean;
35
- }
36
-
37
- export const toAdsFilterOptions = (
38
- items: readonly {
39
- id?: string;
40
- value?: string;
41
- name?: string;
42
- label?: string;
43
- }[],
44
- ): AdsFilterOption[] =>
45
- items.map((item) => ({
46
- value: item.value ?? item.id ?? "",
47
- label: item.label ?? item.name ?? "",
48
- }));
49
-
50
- export type AdsFilterType = "checkbox" | "radio" | "month";
51
-
52
- /** Nomes do AdsSelect. */
53
- export type AdsSelectOption = AdsFilterOption;
54
- export type AdsSelectOptionBadge = AdsFilterOptionBadge;
55
- export type AdsSelectType = AdsFilterType;
56
- export type AdsFilterCheckState = "all" | "none" | "partial";
57
-
58
- const MONTH_VALUE = /^(\d{4})-(\d{2})$/;
59
-
60
- export const truncateFilterLabel = (
61
- label: string,
62
- limit = ADS_FILTER_LABEL_LIMIT,
63
- ): string => {
64
- if (label.length <= limit) return label;
65
- return `${label.slice(0, limit)}...`;
66
- };
67
-
68
- export const filterLabelNeedsTooltip = (
69
- label: string,
70
- limit = ADS_FILTER_LABEL_LIMIT,
71
- ): boolean => label.length > limit;
72
-
73
- export const normalizeFilterQuery = (query: string): string =>
74
- query.trim().toLocaleLowerCase("pt-BR");
75
-
76
- export const groupFilterOptions = (
77
- options: readonly AdsFilterOption[],
78
- query: string,
79
- ): { exact: AdsFilterOption[]; matches: AdsFilterOption[]; empty: boolean } => {
80
- const normalized = normalizeFilterQuery(query);
81
- if (!normalized) {
82
- return { exact: [], matches: [...options], empty: false };
83
- }
84
-
85
- const exact: AdsFilterOption[] = [];
86
- const matches: AdsFilterOption[] = [];
87
- for (const option of options) {
88
- const label = option.label.toLocaleLowerCase("pt-BR");
89
- const subtitle = option.subtitle?.toLocaleLowerCase("pt-BR") ?? "";
90
- if (label === normalized) exact.push(option);
91
- else if (label.includes(normalized) || subtitle.includes(normalized)) matches.push(option);
92
- }
93
-
94
- return {
95
- exact,
96
- matches,
97
- empty: exact.length === 0 && matches.length === 0,
98
- };
99
- };
100
-
101
- export const selectionCheckState = (
102
- selected: readonly string[],
103
- options: readonly AdsFilterOption[],
104
- ): AdsFilterCheckState => {
105
- if (options.length === 0) return "none";
106
-
107
- const selectedSet = new Set(selected);
108
- let count = 0;
109
- for (const option of options) {
110
- if (selectedSet.has(option.value)) count += 1;
111
- }
112
-
113
- if (count === 0) return "none";
114
- if (count === options.length) return "all";
115
- return "partial";
116
- };
117
-
118
- export const toggleFilterValue = (
119
- selected: readonly string[],
120
- value: string,
121
- ): string[] =>
122
- selected.includes(value)
123
- ? selected.filter((item) => item !== value)
124
- : [...selected, value];
125
-
126
- export const toggleSelectAll = (
127
- selected: readonly string[],
128
- options: readonly AdsFilterOption[],
129
- ): string[] => {
130
- if (selectionCheckState(selected, options) === "all") return [];
131
- return options.map((option) => option.value);
132
- };
133
-
134
- export const parseMonthValue = (
135
- value: string,
136
- ): { year: number; monthIndex: number } | null => {
137
- const match = MONTH_VALUE.exec(value);
138
- if (!match) return null;
139
-
140
- const year = Number(match[1]);
141
- const month = Number(match[2]);
142
- if (month < 1 || month > 12) return null;
143
- return { year, monthIndex: month - 1 };
144
- };
145
-
146
- export const formatMonthValue = (year: number, monthIndex: number): string =>
147
- `${year}-${String(monthIndex + 1).padStart(2, "0")}`;
148
-
149
- export const monthTriggerLabel = (value: string, placeholder: string): string => {
150
- const parsed = parseMonthValue(value);
151
- if (!parsed) return placeholder;
152
- return ADS_FILTER_MONTHS[parsed.monthIndex]?.full ?? placeholder;
153
- };
154
-
155
- const selectedCountLabel = (count: number): string =>
156
- count === 1 ? "1 selecionado" : `${count} selecionados`;
157
-
158
- export const filterTriggerLabel = (params: {
159
- type: AdsFilterType;
160
- value: string | readonly string[];
161
- options: readonly AdsFilterOption[];
162
- placeholder: string;
163
- allSelectedLabel: string;
164
- }): string => {
165
- if (params.type === "month") {
166
- const current = typeof params.value === "string" ? params.value : "";
167
- return monthTriggerLabel(current, params.placeholder);
168
- }
169
-
170
- if (params.type === "radio") {
171
- const current = typeof params.value === "string" ? params.value : "";
172
- if (!current) return params.placeholder;
173
- return (
174
- params.options.find((option) => option.value === current)?.label ??
175
- params.placeholder
176
- );
177
- }
178
-
179
- const selected = Array.isArray(params.value) ? [...params.value] : [];
180
- if (selectionCheckState(selected, params.options) === "all") {
181
- return params.allSelectedLabel;
182
- }
183
- if (selected.length === 0) return params.placeholder;
184
- if (selected.length === 1) {
185
- return (
186
- params.options.find((option) => option.value === selected[0])?.label ??
187
- selectedCountLabel(1)
188
- );
189
- }
190
- return selectedCountLabel(selected.length);
191
- };
1
+ /** Reticências a partir deste tamanho. A tooltip só entra quando o rótulo passa daqui. */
2
+ export const ADS_FILTER_LABEL_LIMIT = 22;
3
+
4
+ export const ADS_FILTER_MONTHS = [
5
+ { short: "Jan", full: "Janeiro" },
6
+ { short: "Fev", full: "Fevereiro" },
7
+ { short: "Mar", full: "Março" },
8
+ { short: "Abr", full: "Abril" },
9
+ { short: "Mai", full: "Maio" },
10
+ { short: "Jun", full: "Junho" },
11
+ { short: "Jul", full: "Julho" },
12
+ { short: "Ago", full: "Agosto" },
13
+ { short: "Set", full: "Setembro" },
14
+ { short: "Out", full: "Outubro" },
15
+ { short: "Nov", full: "Novembro" },
16
+ { short: "Dez", full: "Dezembro" },
17
+ ] as const;
18
+
19
+ /** Texto curto acima do título da opção, como "Novo!" ou "Sugestão Inteligente". */
20
+ export interface AdsFilterOptionBadge {
21
+ label: string;
22
+ /** brand (azul, padrão) ou ai (roxo, com sparkles se não houver ícone). */
23
+ tone?: "brand" | "ai";
24
+ /** Ícone Lucide de 12px antes do texto. */
25
+ icon?: string;
26
+ }
27
+
28
+ export interface AdsFilterOption {
29
+ value: string;
30
+ label: string;
31
+ /** Linha de apoio abaixo do título. Também entra na busca. */
32
+ subtitle?: string;
33
+ badge?: AdsFilterOptionBadge;
34
+ disabled?: boolean;
35
+ }
36
+
37
+ export const toAdsFilterOptions = (
38
+ items: readonly {
39
+ id?: string;
40
+ value?: string;
41
+ name?: string;
42
+ label?: string;
43
+ }[],
44
+ ): AdsFilterOption[] =>
45
+ items.map((item) => ({
46
+ value: item.value ?? item.id ?? "",
47
+ label: item.label ?? item.name ?? "",
48
+ }));
49
+
50
+ export type AdsFilterType = "checkbox" | "radio" | "month";
51
+
52
+ /** Nomes do AdsSelect. */
53
+ export type AdsSelectOption = AdsFilterOption;
54
+ export type AdsSelectOptionBadge = AdsFilterOptionBadge;
55
+ export type AdsSelectType = AdsFilterType;
56
+ export type AdsFilterCheckState = "all" | "none" | "partial";
57
+
58
+ const MONTH_VALUE = /^(\d{4})-(\d{2})$/;
59
+
60
+ export const truncateFilterLabel = (
61
+ label: string,
62
+ limit = ADS_FILTER_LABEL_LIMIT,
63
+ ): string => {
64
+ if (label.length <= limit) return label;
65
+ return `${label.slice(0, limit)}...`;
66
+ };
67
+
68
+ export const filterLabelNeedsTooltip = (
69
+ label: string,
70
+ limit = ADS_FILTER_LABEL_LIMIT,
71
+ ): boolean => label.length > limit;
72
+
73
+ export const normalizeFilterQuery = (query: string): string =>
74
+ query.trim().toLocaleLowerCase("pt-BR");
75
+
76
+ export const groupFilterOptions = (
77
+ options: readonly AdsFilterOption[],
78
+ query: string,
79
+ ): { exact: AdsFilterOption[]; matches: AdsFilterOption[]; empty: boolean } => {
80
+ const normalized = normalizeFilterQuery(query);
81
+ if (!normalized) {
82
+ return { exact: [], matches: [...options], empty: false };
83
+ }
84
+
85
+ const exact: AdsFilterOption[] = [];
86
+ const matches: AdsFilterOption[] = [];
87
+ for (const option of options) {
88
+ const label = option.label.toLocaleLowerCase("pt-BR");
89
+ const subtitle = option.subtitle?.toLocaleLowerCase("pt-BR") ?? "";
90
+ if (label === normalized) exact.push(option);
91
+ else if (label.includes(normalized) || subtitle.includes(normalized)) matches.push(option);
92
+ }
93
+
94
+ return {
95
+ exact,
96
+ matches,
97
+ empty: exact.length === 0 && matches.length === 0,
98
+ };
99
+ };
100
+
101
+ export const selectionCheckState = (
102
+ selected: readonly string[],
103
+ options: readonly AdsFilterOption[],
104
+ ): AdsFilterCheckState => {
105
+ if (options.length === 0) return "none";
106
+
107
+ const selectedSet = new Set(selected);
108
+ let count = 0;
109
+ for (const option of options) {
110
+ if (selectedSet.has(option.value)) count += 1;
111
+ }
112
+
113
+ if (count === 0) return "none";
114
+ if (count === options.length) return "all";
115
+ return "partial";
116
+ };
117
+
118
+ export const toggleFilterValue = (
119
+ selected: readonly string[],
120
+ value: string,
121
+ ): string[] =>
122
+ selected.includes(value)
123
+ ? selected.filter((item) => item !== value)
124
+ : [...selected, value];
125
+
126
+ export const toggleSelectAll = (
127
+ selected: readonly string[],
128
+ options: readonly AdsFilterOption[],
129
+ ): string[] => {
130
+ if (selectionCheckState(selected, options) === "all") return [];
131
+ return options.map((option) => option.value);
132
+ };
133
+
134
+ export const parseMonthValue = (
135
+ value: string,
136
+ ): { year: number; monthIndex: number } | null => {
137
+ const match = MONTH_VALUE.exec(value);
138
+ if (!match) return null;
139
+
140
+ const year = Number(match[1]);
141
+ const month = Number(match[2]);
142
+ if (month < 1 || month > 12) return null;
143
+ return { year, monthIndex: month - 1 };
144
+ };
145
+
146
+ export const formatMonthValue = (year: number, monthIndex: number): string =>
147
+ `${year}-${String(monthIndex + 1).padStart(2, "0")}`;
148
+
149
+ export const monthTriggerLabel = (value: string, placeholder: string): string => {
150
+ const parsed = parseMonthValue(value);
151
+ if (!parsed) return placeholder;
152
+ return ADS_FILTER_MONTHS[parsed.monthIndex]?.full ?? placeholder;
153
+ };
154
+
155
+ const selectedCountLabel = (count: number): string =>
156
+ count === 1 ? "1 selecionado" : `${count} selecionados`;
157
+
158
+ export const filterTriggerLabel = (params: {
159
+ type: AdsFilterType;
160
+ value: string | readonly string[];
161
+ options: readonly AdsFilterOption[];
162
+ placeholder: string;
163
+ allSelectedLabel: string;
164
+ }): string => {
165
+ if (params.type === "month") {
166
+ const current = typeof params.value === "string" ? params.value : "";
167
+ return monthTriggerLabel(current, params.placeholder);
168
+ }
169
+
170
+ if (params.type === "radio") {
171
+ const current = typeof params.value === "string" ? params.value : "";
172
+ if (!current) return params.placeholder;
173
+ return (
174
+ params.options.find((option) => option.value === current)?.label ??
175
+ params.placeholder
176
+ );
177
+ }
178
+
179
+ const selected = Array.isArray(params.value) ? [...params.value] : [];
180
+ if (selectionCheckState(selected, params.options) === "all") {
181
+ return params.allSelectedLabel;
182
+ }
183
+ if (selected.length === 0) return params.placeholder;
184
+ if (selected.length === 1) {
185
+ return (
186
+ params.options.find((option) => option.value === selected[0])?.label ??
187
+ selectedCountLabel(1)
188
+ );
189
+ }
190
+ return selectedCountLabel(selected.length);
191
+ };