frontend-plus-react 0.1.8 → 0.1.9

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.
@@ -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
+ onEnterPress?: (rowIndex: number, columnKey: string, key: string) => 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
@@ -3454,6 +3454,7 @@ var MenuTablePage = () => {
3454
3454
  var MenuTablePage_default = MenuTablePage;
3455
3455
 
3456
3456
  // src/App.tsx
3457
+ import { Box as Box19 } from "@mui/material";
3457
3458
  import { jsx as jsx26, jsxs as jsxs17 } from "react/jsx-runtime";
3458
3459
  var LocationTracker = () => {
3459
3460
  const location = useLocation4();
@@ -3480,7 +3481,13 @@ function FrontendPlusReactRoutes({ myRoutes }) {
3480
3481
  Route,
3481
3482
  {
3482
3483
  path: `/wScreens/${screenName}`,
3483
- element: React11.createElement(wScreens[screenName], { screenName })
3484
+ element: React11.createElement(
3485
+ Box19,
3486
+ {
3487
+ sx: { pt: 3, pl: 4 }
3488
+ },
3489
+ React11.createElement(wScreens[screenName], { screenName })
3490
+ )
3484
3491
  },
3485
3492
  screenName
3486
3493
  )),
@@ -3488,7 +3495,7 @@ function FrontendPlusReactRoutes({ myRoutes }) {
3488
3495
  Route,
3489
3496
  {
3490
3497
  path: "/wScreens-fallback/:screenName",
3491
- element: /* @__PURE__ */ jsx26(FallbackWScreen, { screenName: ":screenName" })
3498
+ element: /* @__PURE__ */ jsx26(Box19, { sx: { p: 3 }, children: /* @__PURE__ */ jsx26(FallbackWScreen, { screenName: ":screenName" }) })
3492
3499
  }
3493
3500
  ),
3494
3501
  /* @__PURE__ */ jsx26(Route, { path: "*", element: /* @__PURE__ */ jsx26("div", { style: { marginTop: "20px", marginLeft: "10px" }, children: "404 - Recurso No Encontrado" }) })
@@ -3520,8 +3527,7 @@ var App = ({
3520
3527
  /* @__PURE__ */ jsx26(
3521
3528
  FrontendPlusReactRoutes,
3522
3529
  {
3523
- myRoutes,
3524
- allWScreens: myWScreens
3530
+ myRoutes
3525
3531
  }
3526
3532
  ),
3527
3533
  /* @__PURE__ */ jsx26(SessionExpiredMessage_default, {})