@wgalleti/primevue-components 0.3.4
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/README.md +218 -0
- package/dist/components/crud/WCrudColumnRenderer.vue.d.ts +8 -0
- package/dist/components/crud/WCrudFormDialog.vue.d.ts +214 -0
- package/dist/components/crud/WCrudView.vue.d.ts +89 -0
- package/dist/components/form/WAutoCompleteFK.vue.d.ts +43 -0
- package/dist/components/form/WFormRenderer.vue.d.ts +41 -0
- package/dist/components/form/WMoneyInput.vue.d.ts +28 -0
- package/dist/components/form/WTransferList.vue.d.ts +25 -0
- package/dist/components/index.d.ts +18 -0
- package/dist/components/ui/WActionBar.vue.d.ts +27 -0
- package/dist/components/ui/WDetailHeader.vue.d.ts +29 -0
- package/dist/components/ui/WEmptyState.vue.d.ts +13 -0
- package/dist/components/ui/WFormSection.vue.d.ts +23 -0
- package/dist/components/ui/WInfoCard.vue.d.ts +11 -0
- package/dist/components/ui/WKpiCard.vue.d.ts +33 -0
- package/dist/components/ui/WKpiGrid.vue.d.ts +31 -0
- package/dist/components/ui/WPageHeader.vue.d.ts +27 -0
- package/dist/components/ui/WProgressFlow.vue.d.ts +33 -0
- package/dist/components/ui/WSectionHeader.vue.d.ts +25 -0
- package/dist/components/ui/WStatusTag.vue.d.ts +10 -0
- package/dist/composables/index.d.ts +6 -0
- package/dist/composables/useApi.d.ts +2 -0
- package/dist/composables/useApiError.d.ts +4 -0
- package/dist/composables/useAppConfirm.d.ts +4 -0
- package/dist/composables/useAppToast.d.ts +6 -0
- package/dist/composables/useCrudManager.d.ts +2 -0
- package/dist/composables/useFormatters.d.ts +19 -0
- package/dist/data-providers/axiosDataProvider.d.ts +3 -0
- package/dist/data-providers/index.d.ts +2 -0
- package/dist/data-providers/supabaseDataProvider.d.ts +54 -0
- package/dist/index.cjs +11 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +3287 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/primevue-components.css +1 -0
- package/dist/types/api.d.ts +60 -0
- package/dist/types/components/crud/WCrudColumnRenderer.vue.d.ts +8 -0
- package/dist/types/components/crud/WCrudFormDialog.vue.d.ts +49 -0
- package/dist/types/components/crud/WCrudView.vue.d.ts +103 -0
- package/dist/types/components/form/WAutoCompleteFK.vue.d.ts +43 -0
- package/dist/types/components/form/WFormRenderer.vue.d.ts +40 -0
- package/dist/types/components/form/WMoneyInput.vue.d.ts +28 -0
- package/dist/types/components/form/WTransferList.vue.d.ts +25 -0
- package/dist/types/components/index.d.ts +18 -0
- package/dist/types/components/ui/WActionBar.vue.d.ts +25 -0
- package/dist/types/components/ui/WDetailHeader.vue.d.ts +24 -0
- package/dist/types/components/ui/WEmptyState.vue.d.ts +13 -0
- package/dist/types/components/ui/WFormSection.vue.d.ts +19 -0
- package/dist/types/components/ui/WInfoCard.vue.d.ts +11 -0
- package/dist/types/components/ui/WKpiCard.vue.d.ts +32 -0
- package/dist/types/components/ui/WKpiGrid.vue.d.ts +26 -0
- package/dist/types/components/ui/WPageHeader.vue.d.ts +22 -0
- package/dist/types/components/ui/WProgressFlow.vue.d.ts +28 -0
- package/dist/types/components/ui/WSectionHeader.vue.d.ts +22 -0
- package/dist/types/components/ui/WStatusTag.vue.d.ts +10 -0
- package/dist/types/composables/index.d.ts +6 -0
- package/dist/types/composables/useApi.d.ts +2 -0
- package/dist/types/composables/useApiError.d.ts +4 -0
- package/dist/types/composables/useAppConfirm.d.ts +4 -0
- package/dist/types/composables/useAppToast.d.ts +6 -0
- package/dist/types/composables/useCrudManager.d.ts +2 -0
- package/dist/types/composables/useFormatters.d.ts +19 -0
- package/dist/types/crud.d.ts +184 -0
- package/dist/types/data-providers/axiosDataProvider.d.ts +3 -0
- package/dist/types/data-providers/index.d.ts +2 -0
- package/dist/types/data-providers/supabaseDataProvider.d.ts +54 -0
- package/dist/types/dataProvider.d.ts +28 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/plugin.d.ts +2 -0
- package/dist/types/types/api.d.ts +60 -0
- package/dist/types/types/crud.d.ts +184 -0
- package/dist/types/types/dataProvider.d.ts +28 -0
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types/types/plugin.d.ts +24 -0
- package/dist/types/utils/cep.d.ts +14 -0
- package/dist/types/utils/dates.d.ts +5 -0
- package/dist/types/utils/fieldMapper.d.ts +20 -0
- package/dist/types/utils/masks.d.ts +8 -0
- package/dist/utils/cep.d.ts +14 -0
- package/dist/utils/dates.d.ts +5 -0
- package/dist/utils/fieldMapper.d.ts +20 -0
- package/dist/utils/masks.d.ts +8 -0
- package/package.json +78 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
title: string;
|
|
3
|
+
subtitle?: string;
|
|
4
|
+
icon?: string;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {};
|
|
8
|
+
type __VLS_Slots = {} & {
|
|
9
|
+
icon?: (props: typeof __VLS_1) => any;
|
|
10
|
+
} & {
|
|
11
|
+
meta?: (props: typeof __VLS_3) => any;
|
|
12
|
+
} & {
|
|
13
|
+
actions?: (props: typeof __VLS_5) => any;
|
|
14
|
+
};
|
|
15
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
17
|
+
export default _default;
|
|
18
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
19
|
+
new (): {
|
|
20
|
+
$slots: S;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface StatusMapping {
|
|
2
|
+
label: string;
|
|
3
|
+
severity: string;
|
|
4
|
+
}
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
value: string;
|
|
7
|
+
map?: Record<string, StatusMapping>;
|
|
8
|
+
};
|
|
9
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { useCrudManager } from './useCrudManager';
|
|
2
|
+
export { useApi } from './useApi';
|
|
3
|
+
export { useAppToast } from './useAppToast';
|
|
4
|
+
export { useAppConfirm } from './useAppConfirm';
|
|
5
|
+
export { useApiError, extractApiError } from './useApiError';
|
|
6
|
+
export { useFormatters } from './useFormatters';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { parseDate, toDateString, toDateTimeString } from '@/utils/dates';
|
|
2
|
+
import { formatCpf, formatCnpj, formatCpfCnpj, formatTelefone, validateCpf, validateCnpj, validateCpfCnpj } from '@/utils/masks';
|
|
3
|
+
export declare function useFormatters(): {
|
|
4
|
+
formatCurrency: (value: number | null | undefined) => string;
|
|
5
|
+
formatNumber: (value: number | null | undefined, decimals?: number) => string;
|
|
6
|
+
formatDate: (value: string | Date | null | undefined, format?: string) => string;
|
|
7
|
+
formatDateTime: (value: string | Date | null | undefined) => string;
|
|
8
|
+
formatPercent: (value: number | null | undefined) => string;
|
|
9
|
+
formatCpf: typeof formatCpf;
|
|
10
|
+
formatCnpj: typeof formatCnpj;
|
|
11
|
+
formatCpfCnpj: typeof formatCpfCnpj;
|
|
12
|
+
formatTelefone: typeof formatTelefone;
|
|
13
|
+
validateCpf: typeof validateCpf;
|
|
14
|
+
validateCnpj: typeof validateCnpj;
|
|
15
|
+
validateCpfCnpj: typeof validateCpfCnpj;
|
|
16
|
+
parseDate: typeof parseDate;
|
|
17
|
+
toDateString: typeof toDateString;
|
|
18
|
+
toDateTimeString: typeof toDateTimeString;
|
|
19
|
+
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import { PaginationState, SortState } from './api';
|
|
3
|
+
export type ColumnType = 'text' | 'boolean' | 'date' | 'datetime' | 'number' | 'currency' | 'image' | 'custom';
|
|
4
|
+
export interface ColumnDef {
|
|
5
|
+
field: string;
|
|
6
|
+
header: string;
|
|
7
|
+
type?: ColumnType;
|
|
8
|
+
style?: string;
|
|
9
|
+
align?: 'left' | 'center' | 'right';
|
|
10
|
+
sortable?: boolean;
|
|
11
|
+
format?: (value: unknown, rowData?: Record<string, unknown>) => string;
|
|
12
|
+
visible?: boolean;
|
|
13
|
+
decimals?: number;
|
|
14
|
+
tagValue?: (value: unknown, rowData?: Record<string, unknown>) => string;
|
|
15
|
+
tagSeverity?: (value: unknown, rowData?: Record<string, unknown>) => string;
|
|
16
|
+
}
|
|
17
|
+
export type FieldType = 'text' | 'email' | 'password' | 'number' | 'currency' | 'date' | 'datetime' | 'select' | 'autocomplete' | 'fk' | 'switch' | 'textarea' | 'color' | 'cpf_cnpj' | 'mask' | 'image' | 'cep' | 'transfer';
|
|
18
|
+
export interface SelectOption {
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface FieldDef {
|
|
22
|
+
field: string;
|
|
23
|
+
label: string;
|
|
24
|
+
type?: FieldType;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
colSpan?: number;
|
|
27
|
+
defaultValue?: unknown | (() => unknown);
|
|
28
|
+
disabled?: boolean | ((formData: Record<string, unknown>, isEditing: boolean) => boolean);
|
|
29
|
+
disabledOnEdit?: boolean;
|
|
30
|
+
visible?: boolean | ((formData: Record<string, unknown>, isEditing: boolean) => boolean);
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
validate?: (value: unknown) => string | null;
|
|
33
|
+
autofocus?: boolean | 'create' | 'edit';
|
|
34
|
+
options?: SelectOption[] | Ref<SelectOption[]>;
|
|
35
|
+
optionLabel?: string;
|
|
36
|
+
optionValue?: string;
|
|
37
|
+
showClear?: boolean;
|
|
38
|
+
/** For 'transfer' fields — option keys to match against when searching
|
|
39
|
+
* (defaults to [optionLabel]). */
|
|
40
|
+
searchFields?: string[];
|
|
41
|
+
endpoint?: string;
|
|
42
|
+
endpointParams?: Record<string, string | number | boolean>;
|
|
43
|
+
crudFields?: FieldDef[];
|
|
44
|
+
crudColumns?: ColumnDef[];
|
|
45
|
+
min?: number;
|
|
46
|
+
max?: number;
|
|
47
|
+
minFractionDigits?: number;
|
|
48
|
+
maxFractionDigits?: number;
|
|
49
|
+
prefix?: string;
|
|
50
|
+
suffix?: string;
|
|
51
|
+
/** For 'currency' fields — render WMoneyInput (digit entry filled from the
|
|
52
|
+
* right, like a calculator/POS) instead of the default InputNumber. */
|
|
53
|
+
fillFromRight?: boolean;
|
|
54
|
+
/** Fixed decimal places for 'currency' fillFromRight mode (default: 2). */
|
|
55
|
+
decimals?: number;
|
|
56
|
+
dateFormat?: string;
|
|
57
|
+
hourFormat?: '12' | '24';
|
|
58
|
+
mask?: string;
|
|
59
|
+
rows?: number;
|
|
60
|
+
switchLabel?: string;
|
|
61
|
+
feedback?: boolean;
|
|
62
|
+
accept?: string;
|
|
63
|
+
/** For type 'cep' — maps ViaCEP response fields to form field names.
|
|
64
|
+
* Keys are ViaCEP response names (logradouro, bairro, localidade, uf, complemento).
|
|
65
|
+
* Values are the form field names to populate. Omit keys to skip fields. */
|
|
66
|
+
cepFields?: {
|
|
67
|
+
logradouro?: string;
|
|
68
|
+
bairro?: string;
|
|
69
|
+
localidade?: string;
|
|
70
|
+
uf?: string;
|
|
71
|
+
complemento?: string;
|
|
72
|
+
};
|
|
73
|
+
/** Optional visual grouping. Fields with the same group.id render together
|
|
74
|
+
* under a titled section. Ungrouped fields render in a default section at the top.
|
|
75
|
+
* `order` controls the display order of groups; defaults to the order of first occurrence. */
|
|
76
|
+
fieldGroup?: {
|
|
77
|
+
id: string;
|
|
78
|
+
title: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
order?: number;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export interface RowAction<T = Record<string, unknown>> {
|
|
84
|
+
action: string;
|
|
85
|
+
icon: string;
|
|
86
|
+
tooltip?: string;
|
|
87
|
+
severity?: 'secondary' | 'success' | 'info' | 'warn' | 'danger' | 'contrast';
|
|
88
|
+
visible?: (data: T) => boolean;
|
|
89
|
+
disabled?: (data: T) => boolean;
|
|
90
|
+
handler?: (data: T) => void;
|
|
91
|
+
}
|
|
92
|
+
export interface CrudLabels {
|
|
93
|
+
createTitle: string;
|
|
94
|
+
editTitle: string;
|
|
95
|
+
viewTitle?: string;
|
|
96
|
+
createButton: string;
|
|
97
|
+
saveButton: string;
|
|
98
|
+
updateButton: string;
|
|
99
|
+
cancelButton: string;
|
|
100
|
+
deleteConfirmTitle: string;
|
|
101
|
+
deleteConfirmMessage: string;
|
|
102
|
+
searchPlaceholder: string;
|
|
103
|
+
emptyMessage: string;
|
|
104
|
+
successCreate: string;
|
|
105
|
+
successUpdate: string;
|
|
106
|
+
successDelete: string;
|
|
107
|
+
}
|
|
108
|
+
export declare const DEFAULT_CRUD_LABELS: CrudLabels;
|
|
109
|
+
export interface KpiItem {
|
|
110
|
+
icon: string;
|
|
111
|
+
label: string;
|
|
112
|
+
value: string | number;
|
|
113
|
+
color?: string;
|
|
114
|
+
severity?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
|
|
115
|
+
hint?: string;
|
|
116
|
+
loading?: boolean;
|
|
117
|
+
trend?: {
|
|
118
|
+
value: string;
|
|
119
|
+
direction?: 'up' | 'down' | 'neutral';
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export interface CrudManagerConfig<T> {
|
|
123
|
+
endpoint: string;
|
|
124
|
+
columns: ColumnDef[];
|
|
125
|
+
form: FieldDef[];
|
|
126
|
+
pk?: string;
|
|
127
|
+
pageSize?: number;
|
|
128
|
+
searchDebounce?: number;
|
|
129
|
+
/** When editing, send only the changed fields (diff) instead of the whole
|
|
130
|
+
* record. Defaults to `true`. Set `false` to always send the full payload. */
|
|
131
|
+
partialUpdate?: boolean;
|
|
132
|
+
canCreate?: boolean;
|
|
133
|
+
canEdit?: boolean;
|
|
134
|
+
canDelete?: boolean;
|
|
135
|
+
rowActions?: RowAction<T>[];
|
|
136
|
+
filterParams?: () => Record<string, unknown>;
|
|
137
|
+
transformPayload?: (payload: Record<string, unknown>, isEditing: boolean) => Record<string, unknown>;
|
|
138
|
+
createDefaults?: () => Record<string, unknown>;
|
|
139
|
+
onAfterSave?: (data: T, isEditing: boolean) => void;
|
|
140
|
+
onAfterDelete?: (item: T) => void;
|
|
141
|
+
labels?: Partial<CrudLabels>;
|
|
142
|
+
}
|
|
143
|
+
export interface CrudManagerReturn<T> {
|
|
144
|
+
items: Ref<T[]>;
|
|
145
|
+
extras: Ref<Record<string, unknown>>;
|
|
146
|
+
loading: Ref<boolean>;
|
|
147
|
+
saving: Ref<boolean>;
|
|
148
|
+
search: Ref<string>;
|
|
149
|
+
dialogVisible: Ref<boolean>;
|
|
150
|
+
editingItem: Ref<T | null>;
|
|
151
|
+
formData: Record<string, unknown>;
|
|
152
|
+
pagination: PaginationState;
|
|
153
|
+
sort: SortState;
|
|
154
|
+
isEditing: ComputedRef<boolean>;
|
|
155
|
+
isViewing: ComputedRef<boolean>;
|
|
156
|
+
viewMode: Ref<boolean>;
|
|
157
|
+
dialogTitle: ComputedRef<string>;
|
|
158
|
+
isFirstPage: ComputedRef<boolean>;
|
|
159
|
+
isLastPage: ComputedRef<boolean>;
|
|
160
|
+
init(): Promise<void>;
|
|
161
|
+
fetchItems(params?: Record<string, unknown>): Promise<void>;
|
|
162
|
+
refresh(): Promise<void>;
|
|
163
|
+
setSearch(value: string): void;
|
|
164
|
+
onSearch(event: Event): void;
|
|
165
|
+
onPage(event: {
|
|
166
|
+
page: number;
|
|
167
|
+
rows: number;
|
|
168
|
+
}): void;
|
|
169
|
+
onSort(event: {
|
|
170
|
+
sortField?: string | null;
|
|
171
|
+
sortOrder?: 1 | -1 | 0 | null;
|
|
172
|
+
}): void;
|
|
173
|
+
openCreateDialog(): void;
|
|
174
|
+
openEditDialog(item: T): void;
|
|
175
|
+
openViewDialog(item: T): void;
|
|
176
|
+
save(): Promise<T | null>;
|
|
177
|
+
confirmDelete(item: T): void;
|
|
178
|
+
setFormField(field: string, value: unknown): void;
|
|
179
|
+
resetForm(): void;
|
|
180
|
+
goToPage(page: number): void;
|
|
181
|
+
firstPage(): void;
|
|
182
|
+
lastPage(): void;
|
|
183
|
+
config: CrudManagerConfig<T>;
|
|
184
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { DataProvider } from '@/types/dataProvider';
|
|
2
|
+
type SupabaseResult<T> = {
|
|
3
|
+
data: T | null;
|
|
4
|
+
error: {
|
|
5
|
+
message: string;
|
|
6
|
+
code?: string;
|
|
7
|
+
details?: string;
|
|
8
|
+
hint?: string;
|
|
9
|
+
} | null;
|
|
10
|
+
count?: number | null;
|
|
11
|
+
};
|
|
12
|
+
type SupabaseFilterBuilder<T> = PromiseLike<SupabaseResult<T>> & {
|
|
13
|
+
select(columns?: string, options?: {
|
|
14
|
+
count?: 'exact' | 'planned' | 'estimated';
|
|
15
|
+
}): SupabaseFilterBuilder<T>;
|
|
16
|
+
eq(column: string, value: unknown): SupabaseFilterBuilder<T>;
|
|
17
|
+
ilike(column: string, pattern: string): SupabaseFilterBuilder<T>;
|
|
18
|
+
or(filters: string): SupabaseFilterBuilder<T>;
|
|
19
|
+
order(column: string, options?: {
|
|
20
|
+
ascending?: boolean;
|
|
21
|
+
}): SupabaseFilterBuilder<T>;
|
|
22
|
+
range(from: number, to: number): SupabaseFilterBuilder<T>;
|
|
23
|
+
single(): Promise<SupabaseResult<T>>;
|
|
24
|
+
};
|
|
25
|
+
type SupabaseTable = {
|
|
26
|
+
select<T = unknown>(columns?: string, options?: {
|
|
27
|
+
count?: 'exact' | 'planned' | 'estimated';
|
|
28
|
+
}): SupabaseFilterBuilder<T>;
|
|
29
|
+
insert<T = unknown>(payload: unknown): SupabaseFilterBuilder<T>;
|
|
30
|
+
update<T = unknown>(payload: unknown): SupabaseFilterBuilder<T>;
|
|
31
|
+
delete<T = unknown>(): SupabaseFilterBuilder<T>;
|
|
32
|
+
};
|
|
33
|
+
export interface SupabaseDataProviderClient {
|
|
34
|
+
from(table: string): SupabaseTable;
|
|
35
|
+
}
|
|
36
|
+
export interface SupabaseResourceConfig {
|
|
37
|
+
table: string;
|
|
38
|
+
pk?: string;
|
|
39
|
+
select?: string;
|
|
40
|
+
searchFields?: string[];
|
|
41
|
+
defaultOrdering?: string;
|
|
42
|
+
defaultFilters?: Record<string, unknown>;
|
|
43
|
+
softDelete?: boolean | Record<string, unknown>;
|
|
44
|
+
mapListItem?: (item: Record<string, unknown>) => Record<string, unknown>;
|
|
45
|
+
mapPayload?: (payload: Record<string, unknown>, operation: 'create' | 'update') => Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
export interface CreateSupabaseDataProviderOptions {
|
|
48
|
+
client: SupabaseDataProviderClient;
|
|
49
|
+
resources?: Record<string, SupabaseResourceConfig | string>;
|
|
50
|
+
defaultSelect?: string;
|
|
51
|
+
allowedTables?: string[];
|
|
52
|
+
}
|
|
53
|
+
export declare function createSupabaseDataProvider(options: CreateSupabaseDataProviderOptions): DataProvider;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface DataProviderListParams {
|
|
2
|
+
page?: number;
|
|
3
|
+
page_size?: number;
|
|
4
|
+
search?: string;
|
|
5
|
+
ordering?: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface DataProviderListResponse<T = Record<string, unknown>> {
|
|
9
|
+
data: T[];
|
|
10
|
+
page: number;
|
|
11
|
+
page_size: number;
|
|
12
|
+
rows: number;
|
|
13
|
+
extras?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface DataProviderResponse<T = unknown> {
|
|
16
|
+
data: T;
|
|
17
|
+
}
|
|
18
|
+
export interface DataProviderRequestConfig {
|
|
19
|
+
params?: Record<string, unknown>;
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
export interface DataProvider {
|
|
23
|
+
list<T = Record<string, unknown>>(endpoint: string, params?: DataProviderListParams): Promise<DataProviderListResponse<T>>;
|
|
24
|
+
get<T = Record<string, unknown>>(endpoint: string, id: string | number, config?: DataProviderRequestConfig): Promise<DataProviderResponse<T>>;
|
|
25
|
+
create<T = Record<string, unknown>>(endpoint: string, payload: Record<string, unknown> | FormData, config?: DataProviderRequestConfig): Promise<DataProviderResponse<T>>;
|
|
26
|
+
update<T = Record<string, unknown>>(endpoint: string, id: string | number, payload: Record<string, unknown> | FormData, config?: DataProviderRequestConfig): Promise<DataProviderResponse<T>>;
|
|
27
|
+
delete(endpoint: string, id: string | number): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import './assets/crud.css';
|
|
2
|
+
export { WPrimeVuePlugin } from './plugin';
|
|
3
|
+
export { WCrudView, WCrudFormDialog, WCrudColumnRenderer, WAutoCompleteFK, WFormRenderer, WMoneyInput, WTransferList, WStatusTag, WPageHeader, WDetailHeader, WEmptyState, WInfoCard, WKpiCard, WKpiGrid, WSectionHeader, WFormSection, WActionBar, WProgressFlow, } from './components';
|
|
4
|
+
export { useCrudManager, useApi, useAppToast, useAppConfirm, useApiError, extractApiError, useFormatters, } from './composables';
|
|
5
|
+
export { createAxiosDataProvider, createSupabaseDataProvider, } from './data-providers';
|
|
6
|
+
export type { PaginatedResponse, PaginationState, SortState, UseApiOptions, UseApiReturn, ColumnDef, ColumnType, FieldDef, FieldType, SelectOption, RowAction, CrudLabels, KpiItem, CrudManagerConfig, CrudManagerReturn, WPluginOptions, WPluginConfig, DataProvider, DataProviderListParams, DataProviderListResponse, DataProviderRequestConfig, DataProviderResponse, } from './types';
|
|
7
|
+
export type { StatusMapping } from './components/ui/WStatusTag.vue';
|
|
8
|
+
export type { InfoField } from './components/ui/WInfoCard.vue';
|
|
9
|
+
export type { CreateSupabaseDataProviderOptions, SupabaseDataProviderClient, SupabaseResourceConfig, } from './data-providers';
|
|
10
|
+
export { DEFAULT_CRUD_LABELS, W_AXIOS_KEY, W_CONFIG_KEY, W_DATA_PROVIDER_KEY, } from './types';
|
|
11
|
+
export type { ApiFieldMeta } from './utils/fieldMapper';
|
|
12
|
+
export { mapApiFieldToFieldDef, mapApiFieldsToFieldDefs, mapApiFieldToColumnDef, mapApiFieldsToColumnDefs, } from './utils/fieldMapper';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Formato padrao de resposta paginada da API (DRF).
|
|
4
|
+
*/
|
|
5
|
+
export interface PaginatedResponse<T> {
|
|
6
|
+
data: T[];
|
|
7
|
+
page: number;
|
|
8
|
+
page_size: number;
|
|
9
|
+
rows: number;
|
|
10
|
+
extras?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Estado reativo de paginacao.
|
|
14
|
+
*/
|
|
15
|
+
export interface PaginationState {
|
|
16
|
+
page: number;
|
|
17
|
+
pageSize: number;
|
|
18
|
+
rows: number;
|
|
19
|
+
totalPages: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Estado de ordenacao server-side.
|
|
23
|
+
*/
|
|
24
|
+
export interface SortState {
|
|
25
|
+
field: string | null;
|
|
26
|
+
order: 1 | -1 | 0;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Opcoes do useApi composable.
|
|
30
|
+
*/
|
|
31
|
+
export interface UseApiOptions {
|
|
32
|
+
endpoint: string;
|
|
33
|
+
pageSize?: number;
|
|
34
|
+
searchDebounce?: number;
|
|
35
|
+
immediate?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Retorno do useApi composable.
|
|
39
|
+
*/
|
|
40
|
+
export interface UseApiReturn<T> {
|
|
41
|
+
items: Ref<T[]>;
|
|
42
|
+
loading: Ref<boolean>;
|
|
43
|
+
search: Ref<string>;
|
|
44
|
+
pagination: PaginationState;
|
|
45
|
+
extras: Ref<Record<string, unknown>>;
|
|
46
|
+
sort: SortState;
|
|
47
|
+
fetchItems(params?: Record<string, unknown>): Promise<void>;
|
|
48
|
+
refresh(): Promise<void>;
|
|
49
|
+
setSearch(value: string): void;
|
|
50
|
+
setFilter(key: string, value: unknown): void;
|
|
51
|
+
clearFilters(): void;
|
|
52
|
+
onPage(event: {
|
|
53
|
+
page: number;
|
|
54
|
+
rows: number;
|
|
55
|
+
}): void;
|
|
56
|
+
onSort(event: {
|
|
57
|
+
sortField: string;
|
|
58
|
+
sortOrder: 1 | -1 | 0;
|
|
59
|
+
}): void;
|
|
60
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import type { PaginationState, SortState } from './api';
|
|
3
|
+
export type ColumnType = 'text' | 'boolean' | 'date' | 'datetime' | 'number' | 'currency' | 'image' | 'custom';
|
|
4
|
+
export interface ColumnDef {
|
|
5
|
+
field: string;
|
|
6
|
+
header: string;
|
|
7
|
+
type?: ColumnType;
|
|
8
|
+
style?: string;
|
|
9
|
+
align?: 'left' | 'center' | 'right';
|
|
10
|
+
sortable?: boolean;
|
|
11
|
+
format?: (value: unknown, rowData?: Record<string, unknown>) => string;
|
|
12
|
+
visible?: boolean;
|
|
13
|
+
decimals?: number;
|
|
14
|
+
tagValue?: (value: unknown, rowData?: Record<string, unknown>) => string;
|
|
15
|
+
tagSeverity?: (value: unknown, rowData?: Record<string, unknown>) => string;
|
|
16
|
+
}
|
|
17
|
+
export type FieldType = 'text' | 'email' | 'password' | 'number' | 'currency' | 'date' | 'datetime' | 'select' | 'autocomplete' | 'fk' | 'switch' | 'textarea' | 'color' | 'cpf_cnpj' | 'mask' | 'image' | 'cep' | 'transfer';
|
|
18
|
+
export interface SelectOption {
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface FieldDef {
|
|
22
|
+
field: string;
|
|
23
|
+
label: string;
|
|
24
|
+
type?: FieldType;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
colSpan?: number;
|
|
27
|
+
defaultValue?: unknown | (() => unknown);
|
|
28
|
+
disabled?: boolean | ((formData: Record<string, unknown>, isEditing: boolean) => boolean);
|
|
29
|
+
disabledOnEdit?: boolean;
|
|
30
|
+
visible?: boolean | ((formData: Record<string, unknown>, isEditing: boolean) => boolean);
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
validate?: (value: unknown) => string | null;
|
|
33
|
+
autofocus?: boolean | 'create' | 'edit';
|
|
34
|
+
options?: SelectOption[] | Ref<SelectOption[]>;
|
|
35
|
+
optionLabel?: string;
|
|
36
|
+
optionValue?: string;
|
|
37
|
+
showClear?: boolean;
|
|
38
|
+
/** For 'transfer' fields — option keys to match against when searching
|
|
39
|
+
* (defaults to [optionLabel]). */
|
|
40
|
+
searchFields?: string[];
|
|
41
|
+
endpoint?: string;
|
|
42
|
+
endpointParams?: Record<string, string | number | boolean>;
|
|
43
|
+
crudFields?: FieldDef[];
|
|
44
|
+
crudColumns?: ColumnDef[];
|
|
45
|
+
min?: number;
|
|
46
|
+
max?: number;
|
|
47
|
+
minFractionDigits?: number;
|
|
48
|
+
maxFractionDigits?: number;
|
|
49
|
+
prefix?: string;
|
|
50
|
+
suffix?: string;
|
|
51
|
+
/** For 'currency' fields — render WMoneyInput (digit entry filled from the
|
|
52
|
+
* right, like a calculator/POS) instead of the default InputNumber. */
|
|
53
|
+
fillFromRight?: boolean;
|
|
54
|
+
/** Fixed decimal places for 'currency' fillFromRight mode (default: 2). */
|
|
55
|
+
decimals?: number;
|
|
56
|
+
dateFormat?: string;
|
|
57
|
+
hourFormat?: '12' | '24';
|
|
58
|
+
mask?: string;
|
|
59
|
+
rows?: number;
|
|
60
|
+
switchLabel?: string;
|
|
61
|
+
feedback?: boolean;
|
|
62
|
+
accept?: string;
|
|
63
|
+
/** For type 'cep' — maps ViaCEP response fields to form field names.
|
|
64
|
+
* Keys are ViaCEP response names (logradouro, bairro, localidade, uf, complemento).
|
|
65
|
+
* Values are the form field names to populate. Omit keys to skip fields. */
|
|
66
|
+
cepFields?: {
|
|
67
|
+
logradouro?: string;
|
|
68
|
+
bairro?: string;
|
|
69
|
+
localidade?: string;
|
|
70
|
+
uf?: string;
|
|
71
|
+
complemento?: string;
|
|
72
|
+
};
|
|
73
|
+
/** Optional visual grouping. Fields with the same group.id render together
|
|
74
|
+
* under a titled section. Ungrouped fields render in a default section at the top.
|
|
75
|
+
* `order` controls the display order of groups; defaults to the order of first occurrence. */
|
|
76
|
+
fieldGroup?: {
|
|
77
|
+
id: string;
|
|
78
|
+
title: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
order?: number;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export interface RowAction<T = Record<string, unknown>> {
|
|
84
|
+
action: string;
|
|
85
|
+
icon: string;
|
|
86
|
+
tooltip?: string;
|
|
87
|
+
severity?: 'secondary' | 'success' | 'info' | 'warn' | 'danger' | 'contrast';
|
|
88
|
+
visible?: (data: T) => boolean;
|
|
89
|
+
disabled?: (data: T) => boolean;
|
|
90
|
+
handler?: (data: T) => void;
|
|
91
|
+
}
|
|
92
|
+
export interface CrudLabels {
|
|
93
|
+
createTitle: string;
|
|
94
|
+
editTitle: string;
|
|
95
|
+
viewTitle?: string;
|
|
96
|
+
createButton: string;
|
|
97
|
+
saveButton: string;
|
|
98
|
+
updateButton: string;
|
|
99
|
+
cancelButton: string;
|
|
100
|
+
deleteConfirmTitle: string;
|
|
101
|
+
deleteConfirmMessage: string;
|
|
102
|
+
searchPlaceholder: string;
|
|
103
|
+
emptyMessage: string;
|
|
104
|
+
successCreate: string;
|
|
105
|
+
successUpdate: string;
|
|
106
|
+
successDelete: string;
|
|
107
|
+
}
|
|
108
|
+
export declare const DEFAULT_CRUD_LABELS: CrudLabels;
|
|
109
|
+
export interface KpiItem {
|
|
110
|
+
icon: string;
|
|
111
|
+
label: string;
|
|
112
|
+
value: string | number;
|
|
113
|
+
color?: string;
|
|
114
|
+
severity?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
|
|
115
|
+
hint?: string;
|
|
116
|
+
loading?: boolean;
|
|
117
|
+
trend?: {
|
|
118
|
+
value: string;
|
|
119
|
+
direction?: 'up' | 'down' | 'neutral';
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export interface CrudManagerConfig<T> {
|
|
123
|
+
endpoint: string;
|
|
124
|
+
columns: ColumnDef[];
|
|
125
|
+
form: FieldDef[];
|
|
126
|
+
pk?: string;
|
|
127
|
+
pageSize?: number;
|
|
128
|
+
searchDebounce?: number;
|
|
129
|
+
/** When editing, send only the changed fields (diff) instead of the whole
|
|
130
|
+
* record. Defaults to `true`. Set `false` to always send the full payload. */
|
|
131
|
+
partialUpdate?: boolean;
|
|
132
|
+
canCreate?: boolean;
|
|
133
|
+
canEdit?: boolean;
|
|
134
|
+
canDelete?: boolean;
|
|
135
|
+
rowActions?: RowAction<T>[];
|
|
136
|
+
filterParams?: () => Record<string, unknown>;
|
|
137
|
+
transformPayload?: (payload: Record<string, unknown>, isEditing: boolean) => Record<string, unknown>;
|
|
138
|
+
createDefaults?: () => Record<string, unknown>;
|
|
139
|
+
onAfterSave?: (data: T, isEditing: boolean) => void;
|
|
140
|
+
onAfterDelete?: (item: T) => void;
|
|
141
|
+
labels?: Partial<CrudLabels>;
|
|
142
|
+
}
|
|
143
|
+
export interface CrudManagerReturn<T> {
|
|
144
|
+
items: Ref<T[]>;
|
|
145
|
+
extras: Ref<Record<string, unknown>>;
|
|
146
|
+
loading: Ref<boolean>;
|
|
147
|
+
saving: Ref<boolean>;
|
|
148
|
+
search: Ref<string>;
|
|
149
|
+
dialogVisible: Ref<boolean>;
|
|
150
|
+
editingItem: Ref<T | null>;
|
|
151
|
+
formData: Record<string, unknown>;
|
|
152
|
+
pagination: PaginationState;
|
|
153
|
+
sort: SortState;
|
|
154
|
+
isEditing: ComputedRef<boolean>;
|
|
155
|
+
isViewing: ComputedRef<boolean>;
|
|
156
|
+
viewMode: Ref<boolean>;
|
|
157
|
+
dialogTitle: ComputedRef<string>;
|
|
158
|
+
isFirstPage: ComputedRef<boolean>;
|
|
159
|
+
isLastPage: ComputedRef<boolean>;
|
|
160
|
+
init(): Promise<void>;
|
|
161
|
+
fetchItems(params?: Record<string, unknown>): Promise<void>;
|
|
162
|
+
refresh(): Promise<void>;
|
|
163
|
+
setSearch(value: string): void;
|
|
164
|
+
onSearch(event: Event): void;
|
|
165
|
+
onPage(event: {
|
|
166
|
+
page: number;
|
|
167
|
+
rows: number;
|
|
168
|
+
}): void;
|
|
169
|
+
onSort(event: {
|
|
170
|
+
sortField?: string | null;
|
|
171
|
+
sortOrder?: 1 | -1 | 0 | null;
|
|
172
|
+
}): void;
|
|
173
|
+
openCreateDialog(): void;
|
|
174
|
+
openEditDialog(item: T): void;
|
|
175
|
+
openViewDialog(item: T): void;
|
|
176
|
+
save(): Promise<T | null>;
|
|
177
|
+
confirmDelete(item: T): void;
|
|
178
|
+
setFormField(field: string, value: unknown): void;
|
|
179
|
+
resetForm(): void;
|
|
180
|
+
goToPage(page: number): void;
|
|
181
|
+
firstPage(): void;
|
|
182
|
+
lastPage(): void;
|
|
183
|
+
config: CrudManagerConfig<T>;
|
|
184
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface DataProviderListParams {
|
|
2
|
+
page?: number;
|
|
3
|
+
page_size?: number;
|
|
4
|
+
search?: string;
|
|
5
|
+
ordering?: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface DataProviderListResponse<T = Record<string, unknown>> {
|
|
9
|
+
data: T[];
|
|
10
|
+
page: number;
|
|
11
|
+
page_size: number;
|
|
12
|
+
rows: number;
|
|
13
|
+
extras?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface DataProviderResponse<T = unknown> {
|
|
16
|
+
data: T;
|
|
17
|
+
}
|
|
18
|
+
export interface DataProviderRequestConfig {
|
|
19
|
+
params?: Record<string, unknown>;
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
export interface DataProvider {
|
|
23
|
+
list<T = Record<string, unknown>>(endpoint: string, params?: DataProviderListParams): Promise<DataProviderListResponse<T>>;
|
|
24
|
+
get<T = Record<string, unknown>>(endpoint: string, id: string | number, config?: DataProviderRequestConfig): Promise<DataProviderResponse<T>>;
|
|
25
|
+
create<T = Record<string, unknown>>(endpoint: string, payload: Record<string, unknown> | FormData, config?: DataProviderRequestConfig): Promise<DataProviderResponse<T>>;
|
|
26
|
+
update<T = Record<string, unknown>>(endpoint: string, id: string | number, payload: Record<string, unknown> | FormData, config?: DataProviderRequestConfig): Promise<DataProviderResponse<T>>;
|
|
27
|
+
delete(endpoint: string, id: string | number): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { PaginatedResponse, PaginationState, SortState, UseApiOptions, UseApiReturn, } from './api';
|
|
2
|
+
export type { ColumnDef, ColumnType, FieldDef, FieldType, SelectOption, RowAction, CrudLabels, KpiItem, CrudManagerConfig, CrudManagerReturn, } from './crud';
|
|
3
|
+
export { DEFAULT_CRUD_LABELS } from './crud';
|
|
4
|
+
export type { WPluginOptions, WPluginConfig } from './plugin';
|
|
5
|
+
export { W_AXIOS_KEY, W_CONFIG_KEY, W_DATA_PROVIDER_KEY } from './plugin';
|
|
6
|
+
export type { DataProvider, DataProviderListParams, DataProviderListResponse, DataProviderRequestConfig, DataProviderResponse, } from './dataProvider';
|