@archbase/template 3.0.22 → 3.0.25
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.
|
@@ -2,8 +2,11 @@ import { AlertVariant, ButtonVariant } from '@mantine/core';
|
|
|
2
2
|
import { default as React } from 'react';
|
|
3
3
|
import { ArchbaseDataSource } from '../../data/src';
|
|
4
4
|
import { ArchbaseTemplateSecurityProps } from './ArchbaseTemplateCommonTypes';
|
|
5
|
+
export type FormButtonsPosition = 'header' | 'footer' | 'both';
|
|
5
6
|
export interface ArchbaseFormTemplateProps<T, ID> extends ArchbaseTemplateSecurityProps {
|
|
6
7
|
title: string;
|
|
8
|
+
/** Subtítulo exibido abaixo do título no header */
|
|
9
|
+
subtitle?: string;
|
|
7
10
|
dataSource: ArchbaseDataSource<T, ID>;
|
|
8
11
|
variant?: ButtonVariant | AlertVariant | string;
|
|
9
12
|
/** Referência para o componente interno */
|
|
@@ -20,16 +23,47 @@ export interface ArchbaseFormTemplateProps<T, ID> extends ArchbaseTemplateSecuri
|
|
|
20
23
|
withBorder?: boolean;
|
|
21
24
|
children?: React.ReactNode | React.ReactNode[];
|
|
22
25
|
radius?: string | number | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Posição dos botões Save/Cancel.
|
|
28
|
+
* - 'header': No header à direita (padrão moderno)
|
|
29
|
+
* - 'footer': No rodapé (padrão legado)
|
|
30
|
+
* - 'both': Em ambos
|
|
31
|
+
* @default 'footer'
|
|
32
|
+
*/
|
|
33
|
+
buttonsPosition?: FormButtonsPosition;
|
|
34
|
+
/** Label do botão salvar */
|
|
35
|
+
saveLabel?: string;
|
|
36
|
+
/** Label do botão cancelar */
|
|
37
|
+
cancelLabel?: string;
|
|
38
|
+
/** Callback ao clicar no botão voltar (exibido no header) */
|
|
39
|
+
onBack?: () => void;
|
|
23
40
|
/** Alinhamento dos botões no footer: 'left' | 'center' | 'right' */
|
|
24
41
|
footerAlign?: 'left' | 'center' | 'right';
|
|
25
|
-
/** Conteúdo adicional a ser exibido no footer
|
|
42
|
+
/** Conteúdo adicional a ser exibido no footer */
|
|
26
43
|
footerContent?: React.ReactNode;
|
|
27
44
|
onSave?: (entityToSave: any) => void;
|
|
28
|
-
|
|
45
|
+
/** Callback de cancelar. Quando buttonsPosition inclui 'header', recebe closeForm. */
|
|
46
|
+
onCancel?: ((closeForm: () => void) => void) | (() => void);
|
|
29
47
|
onBeforeSave?: (entityToSave: T) => void;
|
|
30
48
|
onAfterSave?: (savedEntity: T) => void;
|
|
31
49
|
onBeforeCancel?: () => void;
|
|
32
50
|
onAfterCancel?: () => void;
|
|
33
51
|
onError?: (error: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Caminho da rota para o navigation listener (usado para fechar abas).
|
|
54
|
+
*/
|
|
55
|
+
routePath?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Callback chamado antes de fechar a aba.
|
|
58
|
+
* Retorne true para permitir o fechamento, false para cancelar.
|
|
59
|
+
*/
|
|
60
|
+
onBeforeClose?: () => boolean | void;
|
|
61
|
+
/**
|
|
62
|
+
* Hook de navigation listener (ex: useArchbaseNavigationListener de @archbase/admin).
|
|
63
|
+
* Assinatura: (id: string, onUserCloseRequest: () => void) => { closeAllowed: (payload?: any) => void }
|
|
64
|
+
*/
|
|
65
|
+
useNavigationListener?: (id: string, onUserCloseRequest: () => void) => {
|
|
66
|
+
closeAllowed: (payload?: any) => void;
|
|
67
|
+
};
|
|
34
68
|
}
|
|
35
|
-
export declare function ArchbaseFormTemplate<T extends object, ID>({ innerRef, title, isError, isCanceling, isSaving, error, clearError, autoCloseAlertError, width, height, withBorder, children, radius, variant, footerAlign, footerContent, dataSource, onSave, onCancel, onBeforeSave, onAfterSave, onBeforeCancel, onAfterCancel, onError, resourceName, resourceDescription, requiredPermissions, fallbackComponent, securityOptions, ...rest }: ArchbaseFormTemplateProps<T, ID>): import("react/jsx-runtime").JSX.Element;
|
|
69
|
+
export declare function ArchbaseFormTemplate<T extends object, ID>({ innerRef, title, subtitle, isError, isCanceling, isSaving, isLoading, error, clearError, autoCloseAlertError, width, height, withBorder, children, radius, variant, buttonsPosition, saveLabel, cancelLabel, onBack, footerAlign, footerContent, dataSource, onSave, onCancel, onBeforeSave, onAfterSave, onBeforeCancel, onAfterCancel, onError, routePath, onBeforeClose, useNavigationListener, resourceName, resourceDescription, requiredPermissions, fallbackComponent, securityOptions, ...rest }: ArchbaseFormTemplateProps<T, ID>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { AlertVariant, ButtonVariant } from '@mantine/core';
|
|
2
|
+
import { default as React, CSSProperties, ReactNode } from 'react';
|
|
3
|
+
import { ArchbaseDataSource } from '../../data/src';
|
|
4
|
+
import { ArchbaseTemplateSecurityProps } from './ArchbaseTemplateCommonTypes';
|
|
5
|
+
export interface TwoColumnFormTab {
|
|
6
|
+
/** Identificador único da tab */
|
|
7
|
+
value: string;
|
|
8
|
+
/** Label exibido na tab */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Ícone opcional para a tab */
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/** Conteúdo da tab */
|
|
13
|
+
content: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export interface TwoColumnFormHeaderAction {
|
|
16
|
+
/** Identificador único da ação */
|
|
17
|
+
id: string;
|
|
18
|
+
/** Label do botão */
|
|
19
|
+
label: string;
|
|
20
|
+
/** Ícone do botão */
|
|
21
|
+
icon?: ReactNode;
|
|
22
|
+
/** Cor do botão */
|
|
23
|
+
color?: string;
|
|
24
|
+
/** Variante do botão */
|
|
25
|
+
variant?: ButtonVariant;
|
|
26
|
+
/** Handler de clique */
|
|
27
|
+
onClick: () => void;
|
|
28
|
+
/** Desabilitar botão */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/** Loading state */
|
|
31
|
+
loading?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export type ButtonsPosition = 'header' | 'footer' | 'both';
|
|
34
|
+
export interface ArchbaseTwoColumnFormTemplateProps<T, ID> extends ArchbaseTemplateSecurityProps {
|
|
35
|
+
/** Título do formulário */
|
|
36
|
+
title: string;
|
|
37
|
+
/** Subtítulo (ex: "Last Update 28 April 2024 at 8:43 PM") */
|
|
38
|
+
subtitle?: string;
|
|
39
|
+
/** DataSource para o formulário */
|
|
40
|
+
dataSource: ArchbaseDataSource<T, ID>;
|
|
41
|
+
/** Variante de estilo */
|
|
42
|
+
variant?: ButtonVariant | AlertVariant | string;
|
|
43
|
+
/** Callback ao clicar no botão voltar */
|
|
44
|
+
onBack?: () => void;
|
|
45
|
+
/** Ações customizadas no header (além de Save/Cancel) */
|
|
46
|
+
headerActions?: TwoColumnFormHeaderAction[];
|
|
47
|
+
/** Mostrar botão de deletar no header */
|
|
48
|
+
showDeleteButton?: boolean;
|
|
49
|
+
/** Callback ao clicar em deletar */
|
|
50
|
+
onDelete?: () => void;
|
|
51
|
+
/** Label do botão salvar */
|
|
52
|
+
saveLabel?: string;
|
|
53
|
+
/** Label do botão cancelar */
|
|
54
|
+
cancelLabel?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Posição dos botões Save/Cancel.
|
|
57
|
+
* - 'header': No header (padrão moderno SaaS - recomendado)
|
|
58
|
+
* - 'footer': No rodapé (padrão tradicional)
|
|
59
|
+
* - 'both': Em ambos (para forms muito longos)
|
|
60
|
+
* @default 'header'
|
|
61
|
+
*/
|
|
62
|
+
buttonsPosition?: ButtonsPosition;
|
|
63
|
+
/** Conteúdo da coluna esquerda (mídia, galeria, etc) */
|
|
64
|
+
leftColumnContent?: ReactNode;
|
|
65
|
+
/** Largura da coluna esquerda (span do Grid, 1-12). Default: 6 */
|
|
66
|
+
leftColumnSpan?: number;
|
|
67
|
+
/** Esconder coluna esquerda */
|
|
68
|
+
hideLeftColumn?: boolean;
|
|
69
|
+
/** Título da seção do formulário */
|
|
70
|
+
formTitle?: string;
|
|
71
|
+
/** Subtítulo da seção do formulário */
|
|
72
|
+
formSubtitle?: string;
|
|
73
|
+
/** Badge de status (ex: "Status: Draft") */
|
|
74
|
+
statusBadge?: ReactNode;
|
|
75
|
+
/** Tabs do formulário (se não usar tabs, use children) */
|
|
76
|
+
tabs?: TwoColumnFormTab[];
|
|
77
|
+
/** Tab ativa inicial */
|
|
78
|
+
defaultTab?: string;
|
|
79
|
+
/** Variante das tabs */
|
|
80
|
+
tabsVariant?: 'default' | 'outline' | 'pills';
|
|
81
|
+
/** Conteúdo do formulário (quando não usa tabs) */
|
|
82
|
+
children?: ReactNode;
|
|
83
|
+
/** Largura total */
|
|
84
|
+
width?: number | string;
|
|
85
|
+
/** Altura total */
|
|
86
|
+
height?: number | string;
|
|
87
|
+
/** Borda */
|
|
88
|
+
withBorder?: boolean;
|
|
89
|
+
/** Raio das bordas */
|
|
90
|
+
radius?: string | number;
|
|
91
|
+
/** Estilo customizado */
|
|
92
|
+
style?: CSSProperties;
|
|
93
|
+
/** Referência interna */
|
|
94
|
+
innerRef?: React.RefObject<HTMLInputElement>;
|
|
95
|
+
/** Loading state */
|
|
96
|
+
isLoading?: boolean;
|
|
97
|
+
/** Cancelando */
|
|
98
|
+
isCanceling?: boolean;
|
|
99
|
+
/** Salvando */
|
|
100
|
+
isSaving?: boolean;
|
|
101
|
+
/** Estado de erro */
|
|
102
|
+
isError?: boolean;
|
|
103
|
+
/** Mensagem de erro */
|
|
104
|
+
error?: string;
|
|
105
|
+
/** Limpar erro */
|
|
106
|
+
clearError?: () => void;
|
|
107
|
+
/** Auto close do alerta de erro (ms) */
|
|
108
|
+
autoCloseAlertError?: number;
|
|
109
|
+
/** Callback customizado de salvar (sobrescreve comportamento padrão) */
|
|
110
|
+
onSave?: (entityToSave: T) => void;
|
|
111
|
+
/** Callback customizado de cancelar (sobrescreve comportamento padrão). Recebe closeForm para fechar o form/aba quando pronto. */
|
|
112
|
+
onCancel?: (closeForm: () => void) => void;
|
|
113
|
+
/** Callback antes de salvar */
|
|
114
|
+
onBeforeSave?: (entityToSave: T) => void;
|
|
115
|
+
/** Callback após salvar */
|
|
116
|
+
onAfterSave?: (savedEntity: T) => void;
|
|
117
|
+
/** Callback antes de cancelar */
|
|
118
|
+
onBeforeCancel?: () => void;
|
|
119
|
+
/** Callback após cancelar */
|
|
120
|
+
onAfterCancel?: () => void;
|
|
121
|
+
/** Callback de erro */
|
|
122
|
+
onError?: (error: string) => void;
|
|
123
|
+
/**
|
|
124
|
+
* Caminho da rota para o navigation listener (usado para fechar abas).
|
|
125
|
+
* Quando fornecido, integra com useArchbaseNavigationListener.
|
|
126
|
+
*/
|
|
127
|
+
routePath?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Callback chamado antes de fechar a aba.
|
|
130
|
+
* Retorne true para permitir o fechamento, false para cancelar.
|
|
131
|
+
*/
|
|
132
|
+
onBeforeClose?: () => boolean | void;
|
|
133
|
+
/**
|
|
134
|
+
* Hook de navigation listener (ex: useArchbaseNavigationListener de @archbase/admin).
|
|
135
|
+
* Quando fornecido, integra com o sistema de navegação por abas.
|
|
136
|
+
* Assinatura: (id: string, onUserCloseRequest: () => void) => { closeAllowed: (payload?: any) => void }
|
|
137
|
+
*/
|
|
138
|
+
useNavigationListener?: (id: string, onUserCloseRequest: () => void) => {
|
|
139
|
+
closeAllowed: (payload?: any) => void;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export declare function ArchbaseTwoColumnFormTemplate<T extends object, ID>({ title, subtitle, onBack, headerActions, showDeleteButton, onDelete, saveLabel, cancelLabel, buttonsPosition, leftColumnContent, leftColumnSpan, hideLeftColumn, formTitle, formSubtitle, statusBadge, tabs, defaultTab, tabsVariant, children, width, height, withBorder, radius, style, innerRef, isLoading, isCanceling, isSaving, isError, error, clearError, autoCloseAlertError, dataSource, variant, onSave, onCancel, onBeforeSave, onAfterSave, onBeforeCancel, onAfterCancel, onError, routePath, onBeforeClose, useNavigationListener, resourceName, resourceDescription, requiredPermissions, fallbackComponent, securityOptions, ...rest }: ArchbaseTwoColumnFormTemplateProps<T, ID>): import("react/jsx-runtime").JSX.Element;
|
|
143
|
+
interface FormSectionCardProps {
|
|
144
|
+
/** Título do card */
|
|
145
|
+
title: string;
|
|
146
|
+
/** Descrição/subtítulo */
|
|
147
|
+
description?: string;
|
|
148
|
+
/** Ícone de ação no header (ex: botão +) */
|
|
149
|
+
headerAction?: ReactNode;
|
|
150
|
+
/** Conteúdo do card */
|
|
151
|
+
children: ReactNode;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Card para seções auxiliares na coluna esquerda (Visibility, Related Items, etc)
|
|
155
|
+
*/
|
|
156
|
+
export declare function FormSectionCard({ title, description, headerAction, children }: FormSectionCardProps): import("react/jsx-runtime").JSX.Element;
|
|
157
|
+
interface ImageGalleryItem {
|
|
158
|
+
id: string;
|
|
159
|
+
url: string;
|
|
160
|
+
alt?: string;
|
|
161
|
+
isCover?: boolean;
|
|
162
|
+
}
|
|
163
|
+
interface FormImageGalleryProps {
|
|
164
|
+
/** Lista de imagens */
|
|
165
|
+
images: ImageGalleryItem[];
|
|
166
|
+
/** Callback ao clicar para adicionar imagem */
|
|
167
|
+
onAddImage?: () => void;
|
|
168
|
+
/** Callback ao remover imagem */
|
|
169
|
+
onRemoveImage?: (id: string) => void;
|
|
170
|
+
/** Callback ao definir como cover */
|
|
171
|
+
onSetCover?: (id: string) => void;
|
|
172
|
+
/** Máximo de imagens */
|
|
173
|
+
maxImages?: number;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Galeria de imagens para coluna esquerda (padrão do design)
|
|
177
|
+
*/
|
|
178
|
+
export declare function FormImageGallery({ images, onAddImage, onRemoveImage, onSetCover, maxImages }: FormImageGalleryProps): import("react/jsx-runtime").JSX.Element;
|
|
179
|
+
export {};
|
|
@@ -6,6 +6,7 @@ export * from './ArchbaseMasonryTemplate';
|
|
|
6
6
|
export * from './ArchbasePanelTemplate';
|
|
7
7
|
export * from './ArchbaseSpaceTemplate';
|
|
8
8
|
export * from './ArchbaseSearchTemplate';
|
|
9
|
+
export * from './ArchbaseTwoColumnFormTemplate';
|
|
9
10
|
export * from './ArchbaseLookupDataTemplate';
|
|
10
11
|
export * from './ArchbaseLookupDataTemplate.types';
|
|
11
12
|
export * from './ArchbaseTemplateCommonTypes';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archbase/template",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.25",
|
|
4
4
|
"description": "Template components for Archbase React v3 - High-level templates and layouts",
|
|
5
5
|
"author": "Edson Martins <edsonmartins2005@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
14
|
"import": "./dist/index.js",
|
|
15
15
|
"require": "./dist/index.js"
|
|
16
|
-
}
|
|
16
|
+
},
|
|
17
|
+
"./dist/index.css": "./dist/index.css"
|
|
17
18
|
},
|
|
18
19
|
"files": [
|
|
19
20
|
"dist",
|
|
@@ -29,18 +30,18 @@
|
|
|
29
30
|
"react-dom": "^18.3.0 || ^19.2.0"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
33
|
+
"@archbase/advanced": "3.0.25",
|
|
34
|
+
"@archbase/components": "3.0.25",
|
|
35
|
+
"@archbase/core": "3.0.25",
|
|
36
|
+
"@archbase/data": "3.0.25",
|
|
37
|
+
"@archbase/layout": "3.0.25",
|
|
38
|
+
"@archbase/security": "3.0.25",
|
|
39
|
+
"@archbase/security-ui": "3.0.25",
|
|
32
40
|
"@rehooks/component-size": "^1.0.3",
|
|
33
41
|
"dayjs": "^1.11.13",
|
|
34
42
|
"i18next": "^25.3.1",
|
|
35
43
|
"lodash": "^4.17.21",
|
|
36
|
-
"react-i18next": "^15.1.2"
|
|
37
|
-
"@archbase/advanced": "3.0.22",
|
|
38
|
-
"@archbase/components": "3.0.22",
|
|
39
|
-
"@archbase/core": "3.0.22",
|
|
40
|
-
"@archbase/data": "3.0.22",
|
|
41
|
-
"@archbase/layout": "3.0.22",
|
|
42
|
-
"@archbase/security": "3.0.22",
|
|
43
|
-
"@archbase/security-ui": "3.0.22"
|
|
44
|
+
"react-i18next": "^15.1.2"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/react": "^19.0.6",
|
|
Binary file
|