@asaleh37/ui-base 1.1.6 → 1.1.8

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.d.ts CHANGED
@@ -1,7 +1,40 @@
1
+ import { Reducer } from '@reduxjs/toolkit';
2
+ import { IconProp } from '@fortawesome/fontawesome-svg-core';
3
+ import { TextFieldProps, SxProps } from '@mui/material';
1
4
  export * from '@mui/material';
2
5
  export * from 'zod';
3
6
  export { toast } from 'react-toastify';
4
7
  export { FontAwesomeIcon, FontAwesomeIconProps } from '@fortawesome/react-fontawesome';
8
+ import * as react from 'react';
9
+ import react__default from 'react';
10
+ import { GridColDef, GridRowSelectionModel, DataGridPremiumProps, GridToolbarProps, ToolbarPropsOverrides } from '@mui/x-data-grid-premium';
11
+ import { UseFormReturn } from 'react-hook-form';
12
+
13
+ interface SystemRoute {
14
+ path: string;
15
+ component: React.FC;
16
+ authority?: string;
17
+ }
18
+
19
+ type ExtendedTreeItemProps = {
20
+ icon: IconProp;
21
+ id: string;
22
+ label: string;
23
+ action?: "NAVIGATION";
24
+ authority?: string;
25
+ actionPayload?: {
26
+ path?: string;
27
+ parameters?: object;
28
+ };
29
+ children?: ExtendedTreeItemProps[];
30
+ };
31
+
32
+ interface StoreMetaData {
33
+ url: string;
34
+ data: Array<any>;
35
+ autoLoad: boolean;
36
+ authority?: string;
37
+ }
5
38
 
6
39
  type AppInfo = {
7
40
  documentTitle: string | null;
@@ -9,8 +42,439 @@ type AppInfo = {
9
42
  appName: string | null;
10
43
  appVersion: string | null;
11
44
  appLogo: any | null;
45
+ businessRoutes: Array<SystemRoute>;
46
+ businessNavigationItems: Array<ExtendedTreeItemProps>;
47
+ businessReduxReducers: {
48
+ [key: string]: Reducer<any>;
49
+ };
50
+ businessCommonStoresMetaData: {
51
+ [key: string]: StoreMetaData;
52
+ };
12
53
  };
13
54
 
14
55
  declare const BaseApp: React.FC<AppInfo>;
15
56
 
16
- export { BaseApp };
57
+ type TransferListProps = {
58
+ valueField: string;
59
+ displayField: string;
60
+ options: Array<any>;
61
+ selectedOptions: Array<any>;
62
+ setSelection: any;
63
+ };
64
+ declare const TransferList: react.FC<TransferListProps>;
65
+
66
+ interface WidgetProps {
67
+ widgetTitle?: string;
68
+ widgetType: "Line" | "Bar" | "Pie" | "Card" | "Gauge" | "Progress";
69
+ data: any;
70
+ valueField: string;
71
+ labelField: string;
72
+ }
73
+ interface SingleRecordWidgetProps {
74
+ widgetTitle?: string;
75
+ record: object;
76
+ valueField: string;
77
+ labelField: string;
78
+ }
79
+ interface DashboardProps {
80
+ dashboardTitle: string;
81
+ dashboardWidgets: Array<WidgetProps>;
82
+ }
83
+ declare const TemplateDashboard: React.FC<DashboardProps>;
84
+
85
+ declare const TemplateBarChart: React.FC<WidgetProps>;
86
+
87
+ declare const TemplateDataCard: React.FC<SingleRecordWidgetProps>;
88
+
89
+ declare const TemplateGauge: React.FC<SingleRecordWidgetProps>;
90
+
91
+ declare const TemplateLineChart: React.FC<WidgetProps>;
92
+
93
+ declare const TemplateLineProgress: react.FC<SingleRecordWidgetProps>;
94
+
95
+ declare const TemplatePieChart: React.FC<WidgetProps>;
96
+
97
+ interface CheckBoxProps {
98
+ value: any;
99
+ disabled?: boolean;
100
+ required?: boolean;
101
+ label: string;
102
+ checkedValue?: any;
103
+ unCheckedValue?: any;
104
+ onChangeCallBack: Function;
105
+ sx?: any;
106
+ }
107
+ declare const CheckBox: React.FC<CheckBoxProps>;
108
+
109
+ interface ComboBoxProps {
110
+ value: any;
111
+ onChangeCallBack: Function;
112
+ label: string;
113
+ disabled?: boolean;
114
+ required?: boolean;
115
+ options: Array<any>;
116
+ errorMessage?: any;
117
+ displayField: string;
118
+ valueField: string;
119
+ sx?: any;
120
+ }
121
+ declare const ComboBox: React.FC<ComboBoxProps>;
122
+
123
+ interface DatefieldProps {
124
+ value: string | null;
125
+ label: string;
126
+ disabled?: boolean;
127
+ required?: boolean;
128
+ sx?: any;
129
+ format?: string;
130
+ errorMessage?: any;
131
+ onChangeCallBack: Function;
132
+ [x: string | number | symbol]: unknown;
133
+ }
134
+ declare const Datefield: React.FC<DatefieldProps>;
135
+
136
+ interface DatetimeFieldProps {
137
+ value: string | null;
138
+ label: string;
139
+ disabled?: boolean;
140
+ required?: boolean;
141
+ format?: string;
142
+ sx?: any;
143
+ errorMessage?: any;
144
+ onChangeCallBack: Function;
145
+ [x: string | number | symbol]: unknown;
146
+ }
147
+ declare const DatetimeField: React.FC<DatetimeFieldProps>;
148
+
149
+ declare const TemplateTextField: React.FC<Omit<TextFieldProps, "outlined">>;
150
+
151
+ type ApiActions = {
152
+ reloadData: (params?: any) => Promise<void>;
153
+ saveRecord: (record: any) => Promise<any | null>;
154
+ loadRecordById: (recordId: any) => Promise<any>;
155
+ deleteRecordById: (recordId: any) => Promise<boolean>;
156
+ };
157
+
158
+ type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
159
+ type RecordAction = {
160
+ label?: string;
161
+ icon: IconProp;
162
+ isConfirmationRequired?: boolean;
163
+ confirmationMessage?: string;
164
+ authority?: string;
165
+ getActionIconStyleForRecord?: (record: any) => object;
166
+ isActionVisibleForRecord?: (record: any) => boolean;
167
+ isActionDisabledForRecord?: (record: any) => boolean;
168
+ actionFn: (data: any | Array<any>, recordIdsToProcessActionOn?: Array<any>) => Promise<void>;
169
+ preActionValidation?: (record: any) => boolean | Promise<boolean>;
170
+ postActionCallBack?: (record: any) => any | void;
171
+ gridActionProps?: {
172
+ showInMenu?: boolean;
173
+ multiRecord?: boolean;
174
+ };
175
+ formActionProps?: {
176
+ enabled?: boolean;
177
+ actionButtonVariant?: "text" | "outlined" | "contained";
178
+ actionButtonColor?: "inherit" | "primary" | "secondary" | "success" | "error" | "info" | "warning";
179
+ };
180
+ record?: any;
181
+ reloadData?: (parameters?: any) => Promise<void>;
182
+ recordsToProcessActionOn?: Array<any>;
183
+ recordIdsToProcessActionOn?: Array<any>;
184
+ };
185
+ type EditDeleteAction = {
186
+ isEnabled: boolean;
187
+ authority?: string;
188
+ isActionVisibleForRecord?: (record: any) => boolean;
189
+ isActionDisabledForRecord?: (record: any) => boolean;
190
+ preActionValidation?: (record: any) => boolean | Promise<boolean>;
191
+ postActionCallBack?: (record: any) => any | void;
192
+ gridActionProps?: {
193
+ showInMenu?: boolean;
194
+ };
195
+ formActionProps?: {
196
+ actionButtonVariant?: "text" | "outlined" | "contained";
197
+ actionButtonColor?: "inherit" | "primary" | "secondary" | "success" | "error" | "info" | "warning";
198
+ };
199
+ record?: any;
200
+ reloadData?: (parameters?: any) => Promise<void>;
201
+ };
202
+ type TemplateGridColumnProps = {
203
+ hidden?: boolean;
204
+ searchable?: boolean;
205
+ options?: Array<object>;
206
+ displayField?: string;
207
+ valueField?: string;
208
+ muiProps?: MakeOptional<GridColDef, "field">;
209
+ };
210
+ type TemplateGridColDef = GridColDef & {
211
+ hidden?: boolean;
212
+ searchable?: boolean;
213
+ options?: Array<object>;
214
+ displayField?: string;
215
+ valueField?: string;
216
+ };
217
+ type TemplateGridProps = {
218
+ formElements: Array<FormElementProps>;
219
+ gridStateKey?: string;
220
+ data: Array<any>;
221
+ setData: any;
222
+ keyColumnName?: any;
223
+ autoLoad?: boolean;
224
+ gridTitle: string;
225
+ girdIcon: IconProp;
226
+ editAction?: EditDeleteAction;
227
+ deleteAction?: EditDeleteAction;
228
+ rowActions?: Array<RecordAction>;
229
+ gridLoadParameters?: Array<FormElementProps>;
230
+ gridLoadParametersValues?: {
231
+ [key: string]: any;
232
+ };
233
+ setGridLoadParametersValues?: any;
234
+ tBar?: any;
235
+ disableDefaultAction?: boolean;
236
+ enableQuickSearch?: boolean;
237
+ enableExport?: boolean;
238
+ enableDensitySelector?: boolean;
239
+ hideInfoBar?: boolean;
240
+ hideBackButton?: boolean;
241
+ apiActions: ApiActions;
242
+ rowSelectionModel?: GridRowSelectionModel;
243
+ setRowSelectionModel?: any;
244
+ setSelectedRecord?: any;
245
+ setSelectedRecordIds?: any;
246
+ editMode: {
247
+ editMode: "none";
248
+ } | {
249
+ editMode: "row";
250
+ reloadAfterSave?: boolean;
251
+ } | {
252
+ editMode: "modal";
253
+ specs?: {
254
+ modalTitle?: string;
255
+ modalIcon?: IconProp;
256
+ modalHeight?: any;
257
+ modalWidth?: any;
258
+ modalMinHeight?: any;
259
+ modalMinWidth?: any;
260
+ formComponent?: React.FC<ModalFormProps>;
261
+ };
262
+ } | {
263
+ editMode: "form";
264
+ specs: {
265
+ formRoute: string;
266
+ };
267
+ };
268
+ muiProps?: MakeOptional<DataGridPremiumProps, "rows" | "columns">;
269
+ };
270
+ type ModalFormProps = {
271
+ recordIdToEdit?: any;
272
+ formCloseCallBk?: () => void;
273
+ };
274
+ type FormElementSize = {
275
+ lg?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
276
+ md?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
277
+ sm?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
278
+ };
279
+ type RecordFieldProps = {
280
+ fieldName: string;
281
+ fieldLabel: string;
282
+ fieldType: "text" | "number" | "date" | "datetime" | "combobox" | "checkbox";
283
+ required?: boolean;
284
+ disabled?: boolean;
285
+ hidden?: boolean;
286
+ dateFormat?: string;
287
+ options?: Array<any>;
288
+ optionValueField?: string;
289
+ optionDisplayField?: string;
290
+ checkedValue?: any;
291
+ unCheckedValue?: any;
292
+ gridProps?: TemplateGridColumnProps;
293
+ formProps?: {
294
+ fieldSize?: FormElementSize;
295
+ style?: SxProps;
296
+ onValueChangeCallBack?: (value: any, formManager: UseFormReturn, formActions?: FormActionProps, selectedRecord?: any) => void;
297
+ };
298
+ };
299
+ type FormElementGroupProps = {
300
+ style?: SxProps;
301
+ icon?: IconProp;
302
+ label?: string;
303
+ elements?: Array<FormElementProps>;
304
+ actions?: Array<RecordAction>;
305
+ formManager?: UseFormReturn;
306
+ formValues?: any;
307
+ formActions?: any;
308
+ hiddenFields: string[];
309
+ disabledFields: string[];
310
+ };
311
+ type FormElementFieldProps = {
312
+ fieldInfo: RecordFieldProps;
313
+ formManager?: UseFormReturn;
314
+ formValues?: any;
315
+ formActions?: any;
316
+ hiddenFields: string[];
317
+ disabledFields: string[];
318
+ };
319
+ type FormElementNodeProps = {
320
+ formManager?: UseFormReturn;
321
+ formValues: any;
322
+ formActions?: any;
323
+ };
324
+ type FormElementProps = {
325
+ type: "group";
326
+ props: FormElementGroupProps;
327
+ } | {
328
+ type: "field";
329
+ mode: "node";
330
+ node: React.FC<FormElementNodeProps>;
331
+ props?: RecordFieldProps;
332
+ } | {
333
+ type: "field";
334
+ mode: "props";
335
+ props: RecordFieldProps;
336
+ };
337
+ type FormActionProps = {
338
+ setFieldValue: (fieldName: string, fieldValue: any) => void;
339
+ hideField: (fieldName: string) => void;
340
+ showField: (fieldName: string) => void;
341
+ disableField: (fieldName: string) => void;
342
+ enableField: (fieldName: string) => void;
343
+ };
344
+ type TemplateFormProps = {
345
+ elements: Array<FormElementProps>;
346
+ findByIdParamName?: string;
347
+ recordIdToEdit?: any;
348
+ formRouteRecordIdParamName?: string;
349
+ actions?: Array<RecordAction>;
350
+ editAuthorityKey?: string;
351
+ apiActions: ApiActions;
352
+ preSaveValidation?: (record: any) => boolean | Promise<boolean>;
353
+ formSavedSuccessfullyCallBk?: (response: any) => void;
354
+ formCloseCallBk?: () => void;
355
+ saveButtonSpecs?: {
356
+ label?: string;
357
+ icon?: IconProp;
358
+ hidden?: boolean;
359
+ actionButtonVariant?: "text" | "outlined" | "contained";
360
+ actionButtonColor?: "inherit" | "primary" | "secondary" | "success" | "error" | "info" | "warning";
361
+ };
362
+ cancelButtonSpecs?: {
363
+ label?: string;
364
+ icon?: IconProp;
365
+ hidden?: boolean;
366
+ actionButtonVariant?: "text" | "outlined" | "contained";
367
+ actionButtonColor?: "inherit" | "primary" | "secondary" | "success" | "error" | "info" | "warning";
368
+ };
369
+ };
370
+ type TemplateGridTopBarProps = GridToolbarProps & ToolbarPropsOverrides & {
371
+ templateProps: TemplateGridProps;
372
+ handleCreateNewRecord?: () => void;
373
+ clearGridState: () => void;
374
+ };
375
+
376
+ declare const TemplateForm: react__default.FC<TemplateFormProps>;
377
+
378
+ declare const TemplateGrid: react__default.FC<TemplateGridProps>;
379
+
380
+ interface APIRequest {
381
+ endPointURI: string;
382
+ parameters?: any;
383
+ data?: any;
384
+ showMask?: Boolean;
385
+ loadingMessage?: string;
386
+ successCallBkFn?: Function;
387
+ failureCallBkFn?: Function;
388
+ }
389
+ declare const useAxios: () => {
390
+ handleGetRequest: (props?: APIRequest) => Promise<any>;
391
+ handlePostRequest: (props?: APIRequest) => Promise<any>;
392
+ handleDeleteRequest: (props?: APIRequest) => Promise<any>;
393
+ HandleDownloadHTTPPostPDF: (props?: APIRequest) => Promise<any>;
394
+ };
395
+
396
+ interface ConfirmationWindowProps {
397
+ title: string;
398
+ body: string;
399
+ onConfirmationCallBk: () => void;
400
+ }
401
+ declare const useConfirmationWindow: (props: ConfirmationWindowProps) => {
402
+ ConfirmationWindow: react.FC<{}>;
403
+ open: boolean;
404
+ setOpen: react.Dispatch<react.SetStateAction<boolean>>;
405
+ };
406
+
407
+ declare const useLoadingMask: () => {
408
+ show: (message?: string) => void;
409
+ hide: () => void;
410
+ };
411
+
412
+ declare const useIsMobile: (breakpoint?: number) => boolean;
413
+
414
+ interface OrganizationProps {
415
+ organizationCode?: string;
416
+ organizationName?: string;
417
+ }
418
+ interface UserProfileProps {
419
+ username?: string;
420
+ currentOrganizationCode?: string;
421
+ userOrganizations?: Array<OrganizationProps>;
422
+ employeeNumber?: string;
423
+ employeeName?: string;
424
+ divisionCode?: string;
425
+ divisionName?: string;
426
+ departmentCode?: string;
427
+ departmentName?: string;
428
+ rankCode?: string;
429
+ rankName?: string;
430
+ sectionCode?: string;
431
+ sectionName?: string;
432
+ subsectionCode?: string;
433
+ subsectionName?: string;
434
+ extNumber?: string;
435
+ mobileNumber?: string;
436
+ email?: string;
437
+ }
438
+ interface UserSessionProps {
439
+ value: {
440
+ isAuthenticated: boolean | null;
441
+ userProfile: UserProfileProps | null;
442
+ authorities: Array<{
443
+ authority: string;
444
+ }>;
445
+ };
446
+ }
447
+
448
+ declare const useSession: () => {
449
+ UserSession: UserSessionProps;
450
+ isUserAuthorized: (authorityCode: string) => boolean;
451
+ };
452
+
453
+ interface TemplateWindowProp {
454
+ height?: any;
455
+ width?: any;
456
+ minWidth?: any;
457
+ minHeight?: any;
458
+ windowIcon?: any;
459
+ windowTitle?: string;
460
+ onCloseCallBack?: any;
461
+ }
462
+ interface WindowProps {
463
+ children?: React.ReactNode;
464
+ }
465
+ declare const useWindow: (props: TemplateWindowProp) => {
466
+ windowState: boolean;
467
+ setWindowState: react.Dispatch<react.SetStateAction<boolean>>;
468
+ Window: react.FC<WindowProps>;
469
+ };
470
+
471
+ declare function hasDigitsOnly(str: string): boolean;
472
+ declare function isNumber(value: any): boolean;
473
+ declare function isNumeric(value: string): boolean;
474
+ declare function capitalizeFirstLetter(str: string): string;
475
+
476
+ declare const DATE_FORMAT = "YYYY-MM-DD";
477
+ declare const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
478
+
479
+ export { BaseApp, CheckBox, ComboBox, DATE_FORMAT, DATE_TIME_FORMAT, Datefield, DatetimeField, TemplateBarChart, TemplateDashboard, TemplateDataCard, TemplateForm, TemplateGauge, TemplateGrid, TemplateLineChart, TemplateLineProgress, TemplatePieChart, TemplateTextField, TransferList, capitalizeFirstLetter, hasDigitsOnly, isNumber, isNumeric, useAxios, useConfirmationWindow, useIsMobile, useLoadingMask, useSession, useWindow };
480
+ export type { DashboardProps, EditDeleteAction, FormActionProps, FormElementFieldProps, FormElementGroupProps, FormElementNodeProps, FormElementProps, FormElementSize, MakeOptional, ModalFormProps, RecordAction, RecordFieldProps, TemplateFormProps, TemplateGridColDef, TemplateGridColumnProps, TemplateGridProps, TemplateGridTopBarProps, TransferListProps };