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,32 +1,32 @@
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
+ 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
+ };