frontend-plus-react 0.1.8 → 0.1.10
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/dist/index.cjs +118 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +200 -0
- package/dist/index.d.ts +200 -0
- package/dist/index.js +105 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import React$1, { ReactNode } from 'react';
|
|
2
|
+
import { FieldDefinition, TableDefinition, MenuInfoBase, ProcedureDef, AppConfigClientSetup, DetailTable } from 'backend-plus';
|
|
3
|
+
export { FieldDefinition, TableDefinition } from 'backend-plus';
|
|
4
|
+
import { Details } from 'express-useragent';
|
|
5
|
+
import { RenderCellProps, Column, RenderHeaderCellProps } from 'react-data-grid';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
interface WScreenProps {
|
|
9
|
+
screenName: string;
|
|
10
|
+
}
|
|
11
|
+
declare let wScreens: Record<string, React$1.FC<WScreenProps>>;
|
|
12
|
+
|
|
13
|
+
interface ClientSideProps extends RenderCellProps<any, any> {
|
|
14
|
+
fieldDefinition: FieldDefinition;
|
|
15
|
+
tableDefinition: TableDefinition;
|
|
16
|
+
primaryKey: string[];
|
|
17
|
+
}
|
|
18
|
+
declare let clientSides: Record<string, React$1.FC<ClientSideProps>>;
|
|
19
|
+
declare const extendClientSides: (newRenderers: Record<string, React$1.FC<ClientSideProps>>) => void;
|
|
20
|
+
|
|
21
|
+
interface ResultOkProps {
|
|
22
|
+
data: any;
|
|
23
|
+
}
|
|
24
|
+
type ResultComponentMap = {
|
|
25
|
+
[key: string]: React$1.FC<ResultOkProps>;
|
|
26
|
+
};
|
|
27
|
+
declare let resultsOk: ResultComponentMap;
|
|
28
|
+
|
|
29
|
+
interface FrontendPlusReactRoutesProps {
|
|
30
|
+
myRoutes?: React$1.ReactNode;
|
|
31
|
+
}
|
|
32
|
+
declare function FrontendPlusReactRoutes({ myRoutes }: FrontendPlusReactRoutesProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
interface AppProps {
|
|
34
|
+
myRoutes?: React$1.ReactNode;
|
|
35
|
+
myWScreens?: Record<string, React$1.FC<WScreenProps>>;
|
|
36
|
+
myClientSides?: Record<string, React$1.FC<ClientSideProps>>;
|
|
37
|
+
myResultsOk?: Record<string, React$1.FC<ResultOkProps>>;
|
|
38
|
+
}
|
|
39
|
+
declare const App: ({ myRoutes, myWScreens, myClientSides, myResultsOk }: AppProps) => react_jsx_runtime.JSX.Element;
|
|
40
|
+
|
|
41
|
+
interface GenericDataGridProps$1 {
|
|
42
|
+
}
|
|
43
|
+
interface FixedField {
|
|
44
|
+
fieldName: string;
|
|
45
|
+
value: any;
|
|
46
|
+
until?: any;
|
|
47
|
+
}
|
|
48
|
+
interface CellFeedback {
|
|
49
|
+
rowId: string;
|
|
50
|
+
columnKey: string;
|
|
51
|
+
type: 'success' | 'error';
|
|
52
|
+
message?: 'string';
|
|
53
|
+
}
|
|
54
|
+
interface ConfirmDialogProps {
|
|
55
|
+
open: boolean;
|
|
56
|
+
onClose: (confirm: boolean) => void;
|
|
57
|
+
title: string;
|
|
58
|
+
message: string;
|
|
59
|
+
}
|
|
60
|
+
interface InputRendererProps<R extends Record<string, any>, S> {
|
|
61
|
+
column: Column<R, S>;
|
|
62
|
+
row: R;
|
|
63
|
+
rowIdx: number;
|
|
64
|
+
onRowChange: (row: R, commitChanges?: boolean) => void;
|
|
65
|
+
onClose: (commitChanges?: boolean, shouldFocusCell?: boolean) => void;
|
|
66
|
+
tableDefinition: TableDefinition;
|
|
67
|
+
cellFeedback: CellFeedback | null;
|
|
68
|
+
setCellFeedback: (feedback: CellFeedback | null) => void;
|
|
69
|
+
onKeyPress?: (rowIndex: number, columnKey: string, event: React.KeyboardEvent) => void;
|
|
70
|
+
setTableData: React.Dispatch<React.SetStateAction<any[]>>;
|
|
71
|
+
setLocalCellChanges: React.Dispatch<React.SetStateAction<Map<string, Set<string>>>>;
|
|
72
|
+
localCellChanges: Map<string, Set<string>>;
|
|
73
|
+
primaryKey: string[];
|
|
74
|
+
}
|
|
75
|
+
interface FilterRendererProps<R extends Record<string, any>, S> {
|
|
76
|
+
column: Column<R, S>;
|
|
77
|
+
filters: Record<string, string>;
|
|
78
|
+
setFilters: React.Dispatch<React.SetStateAction<Record<string, string>>>;
|
|
79
|
+
}
|
|
80
|
+
interface GenericDataGridForDetailProps {
|
|
81
|
+
parentRow: any;
|
|
82
|
+
detailTableDefinition: DetailTable;
|
|
83
|
+
parentTableName: string;
|
|
84
|
+
}
|
|
85
|
+
interface SideMenuProps {
|
|
86
|
+
onMenuItemClick?: () => void;
|
|
87
|
+
}
|
|
88
|
+
interface MenuListItemProps {
|
|
89
|
+
item: MenuInfoBase;
|
|
90
|
+
level: number;
|
|
91
|
+
onMenuItemClick?: () => void;
|
|
92
|
+
}
|
|
93
|
+
interface CustomCellProps<R extends Record<string, any>, SR> extends RenderCellProps<R, SR> {
|
|
94
|
+
column: RenderCellProps<R, SR>['column'] & {
|
|
95
|
+
isPK?: boolean;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
interface CustomHeaderCellProps<R, SR> extends RenderHeaderCellProps<R, SR> {
|
|
99
|
+
column: RenderHeaderCellProps<R, SR>['column'] & {
|
|
100
|
+
isPK?: boolean;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
interface AppContextType {
|
|
104
|
+
isLoggedIn: boolean;
|
|
105
|
+
setIsLoggedIn: (loggedIn: boolean) => void;
|
|
106
|
+
checkSession: () => Promise<void>;
|
|
107
|
+
showSessionExpiredMessage: boolean;
|
|
108
|
+
setShowSessionExpiredMessage: (show: boolean) => void;
|
|
109
|
+
}
|
|
110
|
+
interface AppProviderProps {
|
|
111
|
+
children: ReactNode;
|
|
112
|
+
}
|
|
113
|
+
interface PrivateRouteProps {
|
|
114
|
+
children: ReactNode;
|
|
115
|
+
}
|
|
116
|
+
interface SnackbarState {
|
|
117
|
+
open: boolean;
|
|
118
|
+
message: string;
|
|
119
|
+
severity: 'success' | 'error' | 'info' | 'warning';
|
|
120
|
+
duration?: number | null;
|
|
121
|
+
}
|
|
122
|
+
interface SnackbarContextType {
|
|
123
|
+
showSnackbar: (message: string, severity: 'success' | 'error' | 'info' | 'warning', duration?: number | null) => void;
|
|
124
|
+
showSuccess: (message: string, duration?: number | null) => void;
|
|
125
|
+
showError: (message: string, duration?: number | null) => void;
|
|
126
|
+
showWarning: (message: string, duration?: number | null) => void;
|
|
127
|
+
showInfo: (message: string, duration?: number | null) => void;
|
|
128
|
+
}
|
|
129
|
+
interface SnackbarProviderProps {
|
|
130
|
+
children: ReactNode;
|
|
131
|
+
}
|
|
132
|
+
interface UseApiCallResult<T> {
|
|
133
|
+
callApi: (procedureName: string, params: Record<string, any>, opts?: {
|
|
134
|
+
reportOnSnackbar: boolean;
|
|
135
|
+
}) => Promise<T | undefined>;
|
|
136
|
+
loading: boolean;
|
|
137
|
+
error: Error | null;
|
|
138
|
+
}
|
|
139
|
+
interface ClientContextState {
|
|
140
|
+
menu: MenuInfoBase[];
|
|
141
|
+
procedure: {
|
|
142
|
+
[key: string]: ProcedureDef;
|
|
143
|
+
};
|
|
144
|
+
procedures: ProcedureDef[];
|
|
145
|
+
config: AppConfigClientSetup;
|
|
146
|
+
useragent: Details;
|
|
147
|
+
username: string;
|
|
148
|
+
status: 'idle' | 'loading' | 'succeeded' | 'failed';
|
|
149
|
+
error: string | null;
|
|
150
|
+
}
|
|
151
|
+
interface MenuUiState {
|
|
152
|
+
isDrawerOpen: boolean;
|
|
153
|
+
subMenuOpenStates: {
|
|
154
|
+
[key: string]: boolean;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
interface RouterState {
|
|
158
|
+
currentPath: string;
|
|
159
|
+
previousPath: string | null;
|
|
160
|
+
redirectPath: string | null;
|
|
161
|
+
}
|
|
162
|
+
interface FetchApiOptions extends RequestInit {
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
interface GenericDataGridProps {
|
|
166
|
+
tableName: string;
|
|
167
|
+
fixedFields?: FixedField[];
|
|
168
|
+
gridStyles?: React$1.CSSProperties;
|
|
169
|
+
}
|
|
170
|
+
declare const GenericDataGrid: React$1.FC<GenericDataGridProps>;
|
|
171
|
+
|
|
172
|
+
declare const ConfirmDialog: React.FC<ConfirmDialogProps>;
|
|
173
|
+
|
|
174
|
+
declare const MainLayout: React$1.FC;
|
|
175
|
+
|
|
176
|
+
declare const SnackbarProvider: React$1.FC<SnackbarProviderProps>;
|
|
177
|
+
declare const useSnackbar: () => SnackbarContextType;
|
|
178
|
+
|
|
179
|
+
declare const useApp: () => {
|
|
180
|
+
clientContext: ClientContextState;
|
|
181
|
+
isLoggedIn: boolean;
|
|
182
|
+
setIsLoggedIn: (loggedIn: boolean) => void;
|
|
183
|
+
checkSession: () => Promise<void>;
|
|
184
|
+
showSessionExpiredMessage: boolean;
|
|
185
|
+
setShowSessionExpiredMessage: (show: boolean) => void;
|
|
186
|
+
};
|
|
187
|
+
declare const AppProvider: React$1.FC<AppProviderProps>;
|
|
188
|
+
|
|
189
|
+
declare const useApiCall: <T = any>() => UseApiCallResult<T>;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Hook personalizado para manejar la lógica de cierre de sesión.
|
|
193
|
+
* Limpia el estado del frontend y realiza la petición al backend.
|
|
194
|
+
* @returns Una función 'logout' que, al ser llamada, cierra la sesión.
|
|
195
|
+
*/
|
|
196
|
+
declare const useLogout: () => () => Promise<void>;
|
|
197
|
+
|
|
198
|
+
declare const cambiarGuionesBajosPorEspacios: (texto: string) => string;
|
|
199
|
+
|
|
200
|
+
export { App, type AppContextType, type AppProps, AppProvider, type AppProviderProps, type CellFeedback, type ClientContextState, ConfirmDialog, type ConfirmDialogProps, type CustomCellProps, type CustomHeaderCellProps, type FetchApiOptions, type FilterRendererProps, type FixedField, FrontendPlusReactRoutes, GenericDataGrid, type GenericDataGridForDetailProps, type GenericDataGridProps$1 as GenericDataGridProps, type InputRendererProps, MainLayout, type MenuListItemProps, type MenuUiState, type PrivateRouteProps, type RouterState, type SideMenuProps, type SnackbarContextType, SnackbarProvider, type SnackbarProviderProps, type SnackbarState, type UseApiCallResult, cambiarGuionesBajosPorEspacios, clientSides, extendClientSides, resultsOk as resultComponents, useApiCall, useApp, useLogout, useSnackbar, wScreens };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import React$1, { ReactNode } from 'react';
|
|
2
|
+
import { FieldDefinition, TableDefinition, MenuInfoBase, ProcedureDef, AppConfigClientSetup, DetailTable } from 'backend-plus';
|
|
3
|
+
export { FieldDefinition, TableDefinition } from 'backend-plus';
|
|
4
|
+
import { Details } from 'express-useragent';
|
|
5
|
+
import { RenderCellProps, Column, RenderHeaderCellProps } from 'react-data-grid';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
interface WScreenProps {
|
|
9
|
+
screenName: string;
|
|
10
|
+
}
|
|
11
|
+
declare let wScreens: Record<string, React$1.FC<WScreenProps>>;
|
|
12
|
+
|
|
13
|
+
interface ClientSideProps extends RenderCellProps<any, any> {
|
|
14
|
+
fieldDefinition: FieldDefinition;
|
|
15
|
+
tableDefinition: TableDefinition;
|
|
16
|
+
primaryKey: string[];
|
|
17
|
+
}
|
|
18
|
+
declare let clientSides: Record<string, React$1.FC<ClientSideProps>>;
|
|
19
|
+
declare const extendClientSides: (newRenderers: Record<string, React$1.FC<ClientSideProps>>) => void;
|
|
20
|
+
|
|
21
|
+
interface ResultOkProps {
|
|
22
|
+
data: any;
|
|
23
|
+
}
|
|
24
|
+
type ResultComponentMap = {
|
|
25
|
+
[key: string]: React$1.FC<ResultOkProps>;
|
|
26
|
+
};
|
|
27
|
+
declare let resultsOk: ResultComponentMap;
|
|
28
|
+
|
|
29
|
+
interface FrontendPlusReactRoutesProps {
|
|
30
|
+
myRoutes?: React$1.ReactNode;
|
|
31
|
+
}
|
|
32
|
+
declare function FrontendPlusReactRoutes({ myRoutes }: FrontendPlusReactRoutesProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
interface AppProps {
|
|
34
|
+
myRoutes?: React$1.ReactNode;
|
|
35
|
+
myWScreens?: Record<string, React$1.FC<WScreenProps>>;
|
|
36
|
+
myClientSides?: Record<string, React$1.FC<ClientSideProps>>;
|
|
37
|
+
myResultsOk?: Record<string, React$1.FC<ResultOkProps>>;
|
|
38
|
+
}
|
|
39
|
+
declare const App: ({ myRoutes, myWScreens, myClientSides, myResultsOk }: AppProps) => react_jsx_runtime.JSX.Element;
|
|
40
|
+
|
|
41
|
+
interface GenericDataGridProps$1 {
|
|
42
|
+
}
|
|
43
|
+
interface FixedField {
|
|
44
|
+
fieldName: string;
|
|
45
|
+
value: any;
|
|
46
|
+
until?: any;
|
|
47
|
+
}
|
|
48
|
+
interface CellFeedback {
|
|
49
|
+
rowId: string;
|
|
50
|
+
columnKey: string;
|
|
51
|
+
type: 'success' | 'error';
|
|
52
|
+
message?: 'string';
|
|
53
|
+
}
|
|
54
|
+
interface ConfirmDialogProps {
|
|
55
|
+
open: boolean;
|
|
56
|
+
onClose: (confirm: boolean) => void;
|
|
57
|
+
title: string;
|
|
58
|
+
message: string;
|
|
59
|
+
}
|
|
60
|
+
interface InputRendererProps<R extends Record<string, any>, S> {
|
|
61
|
+
column: Column<R, S>;
|
|
62
|
+
row: R;
|
|
63
|
+
rowIdx: number;
|
|
64
|
+
onRowChange: (row: R, commitChanges?: boolean) => void;
|
|
65
|
+
onClose: (commitChanges?: boolean, shouldFocusCell?: boolean) => void;
|
|
66
|
+
tableDefinition: TableDefinition;
|
|
67
|
+
cellFeedback: CellFeedback | null;
|
|
68
|
+
setCellFeedback: (feedback: CellFeedback | null) => void;
|
|
69
|
+
onKeyPress?: (rowIndex: number, columnKey: string, event: React.KeyboardEvent) => void;
|
|
70
|
+
setTableData: React.Dispatch<React.SetStateAction<any[]>>;
|
|
71
|
+
setLocalCellChanges: React.Dispatch<React.SetStateAction<Map<string, Set<string>>>>;
|
|
72
|
+
localCellChanges: Map<string, Set<string>>;
|
|
73
|
+
primaryKey: string[];
|
|
74
|
+
}
|
|
75
|
+
interface FilterRendererProps<R extends Record<string, any>, S> {
|
|
76
|
+
column: Column<R, S>;
|
|
77
|
+
filters: Record<string, string>;
|
|
78
|
+
setFilters: React.Dispatch<React.SetStateAction<Record<string, string>>>;
|
|
79
|
+
}
|
|
80
|
+
interface GenericDataGridForDetailProps {
|
|
81
|
+
parentRow: any;
|
|
82
|
+
detailTableDefinition: DetailTable;
|
|
83
|
+
parentTableName: string;
|
|
84
|
+
}
|
|
85
|
+
interface SideMenuProps {
|
|
86
|
+
onMenuItemClick?: () => void;
|
|
87
|
+
}
|
|
88
|
+
interface MenuListItemProps {
|
|
89
|
+
item: MenuInfoBase;
|
|
90
|
+
level: number;
|
|
91
|
+
onMenuItemClick?: () => void;
|
|
92
|
+
}
|
|
93
|
+
interface CustomCellProps<R extends Record<string, any>, SR> extends RenderCellProps<R, SR> {
|
|
94
|
+
column: RenderCellProps<R, SR>['column'] & {
|
|
95
|
+
isPK?: boolean;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
interface CustomHeaderCellProps<R, SR> extends RenderHeaderCellProps<R, SR> {
|
|
99
|
+
column: RenderHeaderCellProps<R, SR>['column'] & {
|
|
100
|
+
isPK?: boolean;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
interface AppContextType {
|
|
104
|
+
isLoggedIn: boolean;
|
|
105
|
+
setIsLoggedIn: (loggedIn: boolean) => void;
|
|
106
|
+
checkSession: () => Promise<void>;
|
|
107
|
+
showSessionExpiredMessage: boolean;
|
|
108
|
+
setShowSessionExpiredMessage: (show: boolean) => void;
|
|
109
|
+
}
|
|
110
|
+
interface AppProviderProps {
|
|
111
|
+
children: ReactNode;
|
|
112
|
+
}
|
|
113
|
+
interface PrivateRouteProps {
|
|
114
|
+
children: ReactNode;
|
|
115
|
+
}
|
|
116
|
+
interface SnackbarState {
|
|
117
|
+
open: boolean;
|
|
118
|
+
message: string;
|
|
119
|
+
severity: 'success' | 'error' | 'info' | 'warning';
|
|
120
|
+
duration?: number | null;
|
|
121
|
+
}
|
|
122
|
+
interface SnackbarContextType {
|
|
123
|
+
showSnackbar: (message: string, severity: 'success' | 'error' | 'info' | 'warning', duration?: number | null) => void;
|
|
124
|
+
showSuccess: (message: string, duration?: number | null) => void;
|
|
125
|
+
showError: (message: string, duration?: number | null) => void;
|
|
126
|
+
showWarning: (message: string, duration?: number | null) => void;
|
|
127
|
+
showInfo: (message: string, duration?: number | null) => void;
|
|
128
|
+
}
|
|
129
|
+
interface SnackbarProviderProps {
|
|
130
|
+
children: ReactNode;
|
|
131
|
+
}
|
|
132
|
+
interface UseApiCallResult<T> {
|
|
133
|
+
callApi: (procedureName: string, params: Record<string, any>, opts?: {
|
|
134
|
+
reportOnSnackbar: boolean;
|
|
135
|
+
}) => Promise<T | undefined>;
|
|
136
|
+
loading: boolean;
|
|
137
|
+
error: Error | null;
|
|
138
|
+
}
|
|
139
|
+
interface ClientContextState {
|
|
140
|
+
menu: MenuInfoBase[];
|
|
141
|
+
procedure: {
|
|
142
|
+
[key: string]: ProcedureDef;
|
|
143
|
+
};
|
|
144
|
+
procedures: ProcedureDef[];
|
|
145
|
+
config: AppConfigClientSetup;
|
|
146
|
+
useragent: Details;
|
|
147
|
+
username: string;
|
|
148
|
+
status: 'idle' | 'loading' | 'succeeded' | 'failed';
|
|
149
|
+
error: string | null;
|
|
150
|
+
}
|
|
151
|
+
interface MenuUiState {
|
|
152
|
+
isDrawerOpen: boolean;
|
|
153
|
+
subMenuOpenStates: {
|
|
154
|
+
[key: string]: boolean;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
interface RouterState {
|
|
158
|
+
currentPath: string;
|
|
159
|
+
previousPath: string | null;
|
|
160
|
+
redirectPath: string | null;
|
|
161
|
+
}
|
|
162
|
+
interface FetchApiOptions extends RequestInit {
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
interface GenericDataGridProps {
|
|
166
|
+
tableName: string;
|
|
167
|
+
fixedFields?: FixedField[];
|
|
168
|
+
gridStyles?: React$1.CSSProperties;
|
|
169
|
+
}
|
|
170
|
+
declare const GenericDataGrid: React$1.FC<GenericDataGridProps>;
|
|
171
|
+
|
|
172
|
+
declare const ConfirmDialog: React.FC<ConfirmDialogProps>;
|
|
173
|
+
|
|
174
|
+
declare const MainLayout: React$1.FC;
|
|
175
|
+
|
|
176
|
+
declare const SnackbarProvider: React$1.FC<SnackbarProviderProps>;
|
|
177
|
+
declare const useSnackbar: () => SnackbarContextType;
|
|
178
|
+
|
|
179
|
+
declare const useApp: () => {
|
|
180
|
+
clientContext: ClientContextState;
|
|
181
|
+
isLoggedIn: boolean;
|
|
182
|
+
setIsLoggedIn: (loggedIn: boolean) => void;
|
|
183
|
+
checkSession: () => Promise<void>;
|
|
184
|
+
showSessionExpiredMessage: boolean;
|
|
185
|
+
setShowSessionExpiredMessage: (show: boolean) => void;
|
|
186
|
+
};
|
|
187
|
+
declare const AppProvider: React$1.FC<AppProviderProps>;
|
|
188
|
+
|
|
189
|
+
declare const useApiCall: <T = any>() => UseApiCallResult<T>;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Hook personalizado para manejar la lógica de cierre de sesión.
|
|
193
|
+
* Limpia el estado del frontend y realiza la petición al backend.
|
|
194
|
+
* @returns Una función 'logout' que, al ser llamada, cierra la sesión.
|
|
195
|
+
*/
|
|
196
|
+
declare const useLogout: () => () => Promise<void>;
|
|
197
|
+
|
|
198
|
+
declare const cambiarGuionesBajosPorEspacios: (texto: string) => string;
|
|
199
|
+
|
|
200
|
+
export { App, type AppContextType, type AppProps, AppProvider, type AppProviderProps, type CellFeedback, type ClientContextState, ConfirmDialog, type ConfirmDialogProps, type CustomCellProps, type CustomHeaderCellProps, type FetchApiOptions, type FilterRendererProps, type FixedField, FrontendPlusReactRoutes, GenericDataGrid, type GenericDataGridForDetailProps, type GenericDataGridProps$1 as GenericDataGridProps, type InputRendererProps, MainLayout, type MenuListItemProps, type MenuUiState, type PrivateRouteProps, type RouterState, type SideMenuProps, type SnackbarContextType, SnackbarProvider, type SnackbarProviderProps, type SnackbarState, type UseApiCallResult, cambiarGuionesBajosPorEspacios, clientSides, extendClientSides, resultsOk as resultComponents, useApiCall, useApp, useLogout, useSnackbar, wScreens };
|
package/dist/index.js
CHANGED
|
@@ -1384,7 +1384,7 @@ function InputRenderer({
|
|
|
1384
1384
|
onClose,
|
|
1385
1385
|
cellFeedback,
|
|
1386
1386
|
setCellFeedback,
|
|
1387
|
-
|
|
1387
|
+
onKeyPress,
|
|
1388
1388
|
setTableData,
|
|
1389
1389
|
setLocalCellChanges,
|
|
1390
1390
|
localCellChanges,
|
|
@@ -1536,14 +1536,13 @@ function InputRenderer({
|
|
|
1536
1536
|
initialRowId
|
|
1537
1537
|
]);
|
|
1538
1538
|
const handleKeyDown = useCallback3((event) => {
|
|
1539
|
-
if (["Enter", "Tab", "ArrowDown", "ArrowUp", "ArrowRight"].includes(event.key)) {
|
|
1539
|
+
if (["Enter", "Tab", "ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft"].includes(event.key)) {
|
|
1540
1540
|
handleCommit(editingValue, true, true);
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
onEnterPress(rowIdx, column.key, event.key);
|
|
1541
|
+
if (onKeyPress) {
|
|
1542
|
+
onKeyPress(rowIdx, column.key, event);
|
|
1544
1543
|
}
|
|
1545
1544
|
}
|
|
1546
|
-
}, [handleCommit, editingValue, column.key, rowIdx,
|
|
1545
|
+
}, [handleCommit, editingValue, column.key, rowIdx, onKeyPress]);
|
|
1547
1546
|
const handleBlur = useCallback3(() => {
|
|
1548
1547
|
handleCommit(editingValue, true, false);
|
|
1549
1548
|
}, [handleCommit, editingValue]);
|
|
@@ -1590,7 +1589,7 @@ var allColumnsEditCellRenderer = (props, allColumns) => {
|
|
|
1590
1589
|
setTableData,
|
|
1591
1590
|
cellFeedback,
|
|
1592
1591
|
setCellFeedback,
|
|
1593
|
-
|
|
1592
|
+
handleKeyPressInEditor,
|
|
1594
1593
|
localCellChanges,
|
|
1595
1594
|
setLocalCellChanges
|
|
1596
1595
|
} = defaultColumn;
|
|
@@ -1609,7 +1608,7 @@ var allColumnsEditCellRenderer = (props, allColumns) => {
|
|
|
1609
1608
|
tableDefinition,
|
|
1610
1609
|
setCellFeedback,
|
|
1611
1610
|
cellFeedback,
|
|
1612
|
-
|
|
1611
|
+
onKeyPress: (rowIndex, columnKey, event) => handleKeyPressInEditor(rowIndex, columnKey, event, allColumns),
|
|
1613
1612
|
setTableData,
|
|
1614
1613
|
setLocalCellChanges,
|
|
1615
1614
|
localCellChanges,
|
|
@@ -1882,22 +1881,27 @@ var GenericDataGrid = ({
|
|
|
1882
1881
|
}
|
|
1883
1882
|
return rows;
|
|
1884
1883
|
}, [tableData, filters, isFilterRowVisible]);
|
|
1885
|
-
const
|
|
1884
|
+
const handleKeyPressInEditor = useCallback4((rowIndex, columnKey, event, currentColumns) => {
|
|
1886
1885
|
if (dataGridRef.current && tableDefinition) {
|
|
1887
1886
|
const currentColumnIndex = currentColumns.findIndex((col) => col.key === columnKey);
|
|
1888
1887
|
const editableColumns = currentColumns.filter((col) => {
|
|
1889
1888
|
const fieldDefinition = tableDefinition.fields.find((f) => f.name === col.key);
|
|
1890
1889
|
return col.key !== "actionsColumn" && col.customType != "detail" && (fieldDefinition?.editable !== false && !fieldDefinition?.clientSide);
|
|
1891
1890
|
});
|
|
1891
|
+
const { key, currentTarget } = event;
|
|
1892
|
+
const input = currentTarget;
|
|
1892
1893
|
if (currentColumnIndex !== -1 && editableColumns.length > 0) {
|
|
1893
1894
|
const editableColumnKeys = editableColumns.map((col) => col.key);
|
|
1894
1895
|
let currentEditableColumnIndex = editableColumnKeys.indexOf(columnKey);
|
|
1895
|
-
|
|
1896
|
+
const calcularColumnaSiguienteYHacerFoco = () => {
|
|
1896
1897
|
let nextEditableColumnIndex = currentEditableColumnIndex + 1;
|
|
1897
1898
|
let nextRowIndex = rowIndex;
|
|
1898
1899
|
if (nextEditableColumnIndex >= editableColumns.length) {
|
|
1899
1900
|
nextEditableColumnIndex = 0;
|
|
1900
1901
|
nextRowIndex++;
|
|
1902
|
+
while (filteredRows[nextRowIndex] && filteredRows[nextRowIndex][DETAIL_ROW_INDICATOR]) {
|
|
1903
|
+
nextRowIndex++;
|
|
1904
|
+
}
|
|
1901
1905
|
if (nextRowIndex >= filteredRows.length) {
|
|
1902
1906
|
nextRowIndex = 0;
|
|
1903
1907
|
}
|
|
@@ -1905,6 +1909,71 @@ var GenericDataGrid = ({
|
|
|
1905
1909
|
const nextColumnKey = editableColumnKeys[nextEditableColumnIndex];
|
|
1906
1910
|
const nextColumnIndex = currentColumns.findIndex((col) => col.key === nextColumnKey);
|
|
1907
1911
|
dataGridRef.current?.selectCell({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor: true, shouldFocusCell: true });
|
|
1912
|
+
};
|
|
1913
|
+
const calcularColumnaAnteriorYHacerFoco = () => {
|
|
1914
|
+
let nextEditableColumnIndex = currentEditableColumnIndex - 1;
|
|
1915
|
+
let nextRowIndex = rowIndex;
|
|
1916
|
+
if (nextEditableColumnIndex <= 0) {
|
|
1917
|
+
nextEditableColumnIndex = 0;
|
|
1918
|
+
}
|
|
1919
|
+
const nextColumnKey = editableColumnKeys[nextEditableColumnIndex];
|
|
1920
|
+
const nextColumnIndex = currentColumns.findIndex((col) => col.key === nextColumnKey);
|
|
1921
|
+
dataGridRef.current?.selectCell({ rowIdx: nextRowIndex, idx: nextColumnIndex }, { enableEditor: true, shouldFocusCell: true });
|
|
1922
|
+
};
|
|
1923
|
+
const calcularFilaSiguienteYHacerFoco = () => {
|
|
1924
|
+
let nextRowIndex = rowIndex;
|
|
1925
|
+
nextRowIndex++;
|
|
1926
|
+
while (filteredRows[nextRowIndex] && filteredRows[nextRowIndex][DETAIL_ROW_INDICATOR]) {
|
|
1927
|
+
nextRowIndex++;
|
|
1928
|
+
}
|
|
1929
|
+
if (nextRowIndex >= filteredRows.length) {
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1932
|
+
dataGridRef.current?.selectCell({ rowIdx: nextRowIndex, idx: currentColumnIndex }, { enableEditor: true, shouldFocusCell: true });
|
|
1933
|
+
};
|
|
1934
|
+
const calcularFilaAnteriorYHacerFoco = () => {
|
|
1935
|
+
let nextRowIndex = rowIndex;
|
|
1936
|
+
nextRowIndex--;
|
|
1937
|
+
while (filteredRows[nextRowIndex] && filteredRows[nextRowIndex][DETAIL_ROW_INDICATOR]) {
|
|
1938
|
+
nextRowIndex--;
|
|
1939
|
+
}
|
|
1940
|
+
if (nextRowIndex < 0) {
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
1943
|
+
dataGridRef.current?.selectCell({ rowIdx: nextRowIndex, idx: currentColumnIndex }, { enableEditor: true, shouldFocusCell: true });
|
|
1944
|
+
};
|
|
1945
|
+
if (currentEditableColumnIndex !== -1) {
|
|
1946
|
+
switch (true) {
|
|
1947
|
+
case ["Enter", "Tab"].includes(key): {
|
|
1948
|
+
calcularColumnaSiguienteYHacerFoco();
|
|
1949
|
+
break;
|
|
1950
|
+
}
|
|
1951
|
+
case key == "ArrowRight": {
|
|
1952
|
+
const cursorPosition = input.selectionStart;
|
|
1953
|
+
const inputValueLength = input.value.length;
|
|
1954
|
+
if (cursorPosition === inputValueLength) {
|
|
1955
|
+
calcularColumnaSiguienteYHacerFoco();
|
|
1956
|
+
}
|
|
1957
|
+
break;
|
|
1958
|
+
}
|
|
1959
|
+
case key == "ArrowLeft": {
|
|
1960
|
+
const cursorPosition = input.selectionStart;
|
|
1961
|
+
if (cursorPosition === 0) {
|
|
1962
|
+
calcularColumnaAnteriorYHacerFoco();
|
|
1963
|
+
}
|
|
1964
|
+
break;
|
|
1965
|
+
}
|
|
1966
|
+
case key == "ArrowUp": {
|
|
1967
|
+
calcularFilaAnteriorYHacerFoco();
|
|
1968
|
+
break;
|
|
1969
|
+
}
|
|
1970
|
+
case key == "ArrowDown": {
|
|
1971
|
+
calcularFilaSiguienteYHacerFoco();
|
|
1972
|
+
break;
|
|
1973
|
+
}
|
|
1974
|
+
default:
|
|
1975
|
+
break;
|
|
1976
|
+
}
|
|
1908
1977
|
}
|
|
1909
1978
|
}
|
|
1910
1979
|
}
|
|
@@ -1937,7 +2006,7 @@ var GenericDataGrid = ({
|
|
|
1937
2006
|
resizable: true,
|
|
1938
2007
|
sortable: true,
|
|
1939
2008
|
editable: isFieldEditable,
|
|
1940
|
-
|
|
2009
|
+
handleKeyPressInEditor,
|
|
1941
2010
|
flexGrow: 1,
|
|
1942
2011
|
minWidth: 60,
|
|
1943
2012
|
renderHeaderCell: (props) => defaultColumnHeaderCellRenderer(props, fieldDef),
|
|
@@ -2020,7 +2089,7 @@ var GenericDataGrid = ({
|
|
|
2020
2089
|
theme.palette.error.light,
|
|
2021
2090
|
theme.palette.info.light,
|
|
2022
2091
|
theme.palette.action.selected,
|
|
2023
|
-
|
|
2092
|
+
handleKeyPressInEditor,
|
|
2024
2093
|
setTableData,
|
|
2025
2094
|
localCellChanges,
|
|
2026
2095
|
handleDeleteRow,
|
|
@@ -2041,16 +2110,24 @@ var GenericDataGrid = ({
|
|
|
2041
2110
|
});
|
|
2042
2111
|
};
|
|
2043
2112
|
const handleCellKeyDown = (args, event) => {
|
|
2044
|
-
if (["Tab", "
|
|
2113
|
+
if (["Enter", "Tab", "ArrowDown", "ArrowUp", "ArrowRight", "ArrowLeft"].includes(event.key)) {
|
|
2045
2114
|
event.preventGridDefault();
|
|
2046
2115
|
}
|
|
2047
2116
|
};
|
|
2048
|
-
const
|
|
2049
|
-
|
|
2050
|
-
|
|
2117
|
+
const handleCellMouseDown = useCallback4((_args, event) => {
|
|
2118
|
+
event.preventGridDefault();
|
|
2119
|
+
}, []);
|
|
2120
|
+
const handlCellDoubleClick = useCallback4((_args, event) => {
|
|
2121
|
+
event.preventGridDefault();
|
|
2122
|
+
}, []);
|
|
2123
|
+
const handleCellClick = useCallback4((args, _event) => {
|
|
2051
2124
|
const fieldDefinition = tableDefinition?.fields.find((f) => f.name === args.column.key);
|
|
2052
2125
|
const isFixedField = fixedFields?.some((f) => f.fieldName === args.column.key);
|
|
2053
2126
|
const isEditable = fieldDefinition?.editable !== false && !isFixedField;
|
|
2127
|
+
if (isEditable) {
|
|
2128
|
+
deselectAllOtherGrids(dataGridRef.current?.element);
|
|
2129
|
+
args.selectCell(true);
|
|
2130
|
+
}
|
|
2054
2131
|
console.log("Clicked column index:", args.column.idx);
|
|
2055
2132
|
console.log("Clicked row index:", args.rowIdx);
|
|
2056
2133
|
console.log("Is editable:", isEditable);
|
|
@@ -2124,6 +2201,8 @@ var GenericDataGrid = ({
|
|
|
2124
2201
|
topSummaryRows: isFilterRowVisible ? [{ id: "filterRow" }] : void 0,
|
|
2125
2202
|
summaryRowHeight: isFilterRowVisible ? 30 : 0,
|
|
2126
2203
|
renderers: { noRowsFallback: /* @__PURE__ */ jsx12(EmptyRowsRenderer, {}) },
|
|
2204
|
+
onCellMouseDown: handleCellMouseDown,
|
|
2205
|
+
onCellDoubleClick: handlCellDoubleClick,
|
|
2127
2206
|
onCellClick: handleCellClick,
|
|
2128
2207
|
onCellKeyDown: handleCellKeyDown
|
|
2129
2208
|
}
|
|
@@ -3454,6 +3533,7 @@ var MenuTablePage = () => {
|
|
|
3454
3533
|
var MenuTablePage_default = MenuTablePage;
|
|
3455
3534
|
|
|
3456
3535
|
// src/App.tsx
|
|
3536
|
+
import { Box as Box19 } from "@mui/material";
|
|
3457
3537
|
import { jsx as jsx26, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3458
3538
|
var LocationTracker = () => {
|
|
3459
3539
|
const location = useLocation4();
|
|
@@ -3480,7 +3560,13 @@ function FrontendPlusReactRoutes({ myRoutes }) {
|
|
|
3480
3560
|
Route,
|
|
3481
3561
|
{
|
|
3482
3562
|
path: `/wScreens/${screenName}`,
|
|
3483
|
-
element: React11.createElement(
|
|
3563
|
+
element: React11.createElement(
|
|
3564
|
+
Box19,
|
|
3565
|
+
{
|
|
3566
|
+
sx: { pt: 3, pl: 4 }
|
|
3567
|
+
},
|
|
3568
|
+
React11.createElement(wScreens[screenName], { screenName })
|
|
3569
|
+
)
|
|
3484
3570
|
},
|
|
3485
3571
|
screenName
|
|
3486
3572
|
)),
|
|
@@ -3488,7 +3574,7 @@ function FrontendPlusReactRoutes({ myRoutes }) {
|
|
|
3488
3574
|
Route,
|
|
3489
3575
|
{
|
|
3490
3576
|
path: "/wScreens-fallback/:screenName",
|
|
3491
|
-
element: /* @__PURE__ */ jsx26(FallbackWScreen, { screenName: ":screenName" })
|
|
3577
|
+
element: /* @__PURE__ */ jsx26(Box19, { sx: { p: 3 }, children: /* @__PURE__ */ jsx26(FallbackWScreen, { screenName: ":screenName" }) })
|
|
3492
3578
|
}
|
|
3493
3579
|
),
|
|
3494
3580
|
/* @__PURE__ */ jsx26(Route, { path: "*", element: /* @__PURE__ */ jsx26("div", { style: { marginTop: "20px", marginLeft: "10px" }, children: "404 - Recurso No Encontrado" }) })
|
|
@@ -3520,8 +3606,7 @@ var App = ({
|
|
|
3520
3606
|
/* @__PURE__ */ jsx26(
|
|
3521
3607
|
FrontendPlusReactRoutes,
|
|
3522
3608
|
{
|
|
3523
|
-
myRoutes
|
|
3524
|
-
allWScreens: myWScreens
|
|
3609
|
+
myRoutes
|
|
3525
3610
|
}
|
|
3526
3611
|
),
|
|
3527
3612
|
/* @__PURE__ */ jsx26(SessionExpiredMessage_default, {})
|