@wavemaker-ai/react-runtime 1.0.0-rc.309 → 1.0.0-rc.314
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/.npmignore +4 -0
- package/actions/base-action.js +12 -29
- package/actions/login-action.js +35 -52
- package/actions/logout-action.js +21 -38
- package/actions/navigation-action.js +251 -346
- package/actions/notification-action.js +121 -149
- package/actions/timer-action.js +95 -151
- package/actions/toast-provider.js +62 -76
- package/actions/toast.js +95 -91
- package/actions/toast.service.js +59 -79
- package/actions/types/index.js +6 -9
- package/components/advanced/carousel/index.js +358 -366
- package/components/advanced/carousel/props.js +0 -5
- package/components/advanced/carousel/template.js +102 -80
- package/components/advanced/login/index.js +227 -285
- package/components/advanced/login/props.js +0 -5
- package/components/advanced/marquee/index.js +169 -163
- package/components/advanced/marquee/props.js +0 -5
- package/components/basic/anchor/index.js +207 -187
- package/components/basic/anchor/props.js +0 -5
- package/components/basic/audio/index.js +110 -72
- package/components/basic/audio/props.js +0 -5
- package/components/basic/html/index.js +163 -203
- package/components/basic/html/props.js +0 -5
- package/components/basic/html/utils.js +30 -28
- package/components/basic/icon/index.js +98 -84
- package/components/basic/icon/props.js +0 -5
- package/components/basic/iframe/iframe.utils.js +7 -16
- package/components/basic/iframe/index.js +97 -103
- package/components/basic/iframe/props.js +0 -5
- package/components/basic/label/index.js +156 -134
- package/components/basic/label/props.js +0 -5
- package/components/basic/message/index.js +129 -113
- package/components/basic/message/props.js +0 -5
- package/components/basic/picture/index.js +156 -127
- package/components/basic/picture/props.js +0 -5
- package/components/basic/progress-bar/index.js +240 -176
- package/components/basic/progress-bar/props.js +5 -31
- package/components/basic/progress-circle/index.js +166 -183
- package/components/basic/progress-circle/props.js +14 -34
- package/components/basic/richtexteditor/index.js +430 -396
- package/components/basic/richtexteditor/props.js +0 -5
- package/components/basic/search/index.js +812 -931
- package/components/basic/search/props.js +0 -5
- package/components/basic/search/providers.js +233 -380
- package/components/basic/spinner/index.js +210 -200
- package/components/basic/spinner/props.js +4 -22
- package/components/basic/tile/index.js +73 -81
- package/components/basic/tile/props.js +0 -5
- package/components/basic/tree/Components/TreeNodeComponent.js +238 -170
- package/components/basic/tree/hooks/useTreePartialNodeApi.js +143 -135
- package/components/basic/tree/index.js +378 -454
- package/components/basic/tree/props.js +0 -5
- package/components/basic/tree/utils.js +129 -185
- package/components/basic/video/index.js +161 -107
- package/components/basic/video/props.js +0 -5
- package/components/chart/index.js +42 -50
- package/components/chart/props.js +31 -37
- package/components/chart/src/ChartRenderer.js +172 -154
- package/components/chart/src/chart.js +391 -213
- package/components/chart/src/chartStyles.generated.js +6 -14
- package/components/chart/src/chartUtils.js +228 -272
- package/components/chart/src/constants.d.ts +13 -0
- package/components/chart/src/constants.js +316 -90
- package/components/chart/src/d3Setup.js +11 -30
- package/components/chart/src/dataUtils.js +362 -446
- package/components/chart/src/formatUtils.js +47 -38
- package/components/chart/src/index.js +11 -19
- package/components/chart/src/nvd3Source.generated.js +5 -13
- package/components/chart/src/pieDonutResponsiveLayout.d.ts +5 -0
- package/components/chart/src/pieDonutResponsiveLayout.js +76 -96
- package/components/chart/src/types.js +0 -5
- package/components/common/AppSpinner.js +17 -33
- package/components/common/app-spinner.js +11 -22
- package/components/common/customTemplate/index.d.ts +3 -0
- package/components/common/customTemplate/index.js +6 -0
- package/components/common/customTemplate/props.d.ts +20 -0
- package/components/common/customTemplate/props.js +0 -0
- package/components/common/customTemplate/template.d.ts +3 -0
- package/components/common/customTemplate/template.js +27 -0
- package/components/common/customTemplate/useCustomTemplate.d.ts +8 -0
- package/components/common/customTemplate/useCustomTemplate.js +17 -0
- package/components/common/customTemplate/utils.d.ts +6 -0
- package/components/common/customTemplate/utils.js +12 -0
- package/components/common/index.js +4 -12
- package/components/constants.js +81 -77
- package/components/container/accordion/accordion-pane/index.js +105 -118
- package/components/container/accordion/accordion-pane/props.js +5 -21
- package/components/container/accordion/index.js +225 -243
- package/components/container/accordion/props.js +5 -16
- package/components/container/index.js +214 -150
- package/components/container/layout-grid/grid-column/index.js +68 -43
- package/components/container/layout-grid/grid-column/props.js +0 -5
- package/components/container/layout-grid/grid-row/index.js +12 -29
- package/components/container/layout-grid/grid-row/props.js +0 -5
- package/components/container/layout-grid/index.js +53 -38
- package/components/container/layout-grid/props.js +0 -5
- package/components/container/linear-layout/index.js +56 -60
- package/components/container/linear-layout/linear-layout-item/index.js +43 -47
- package/components/container/linear-layout/linear-layout-item/props.js +0 -5
- package/components/container/linear-layout/props.js +0 -5
- package/components/container/panel/components/panel-content/index.js +7 -16
- package/components/container/panel/components/panel-header/index.js +166 -146
- package/components/container/panel/components/panel-header/props.js +0 -5
- package/components/container/panel/hooks.js +76 -102
- package/components/container/panel/index.js +289 -252
- package/components/container/panel/props.js +0 -5
- package/components/container/props.js +0 -5
- package/components/container/repeat-template/index.js +65 -44
- package/components/container/repeat-template/props.js +0 -5
- package/components/container/tabs/index.js +517 -526
- package/components/container/tabs/props.js +5 -28
- package/components/container/tabs/tab-pane/index.js +105 -100
- package/components/container/tabs/tab-pane/props.js +0 -5
- package/components/container/tabs/utils.js +30 -35
- package/components/container/wizard/WizardContext.js +9 -11
- package/components/container/wizard/components/StepComponents.js +76 -99
- package/components/container/wizard/components/WizardStep.js +107 -85
- package/components/container/wizard/index.js +791 -921
- package/components/container/wizard/props.js +0 -5
- package/components/container/wizard/utils.js +97 -131
- package/components/container/wizard/wizard-action/index.js +41 -81
- package/components/container/wizard/wizard-step/index.js +140 -120
- package/components/data/card/card-actions/index.js +13 -31
- package/components/data/card/card-content/index.js +27 -36
- package/components/data/card/card-footer/index.js +13 -31
- package/components/data/card/index.js +192 -199
- package/components/data/card/props.js +0 -5
- package/components/data/form/base-form/constant.js +5 -8
- package/components/data/form/base-form/hooks/index.js +26 -77
- package/components/data/form/base-form/hooks/useFormDataSync.js +106 -212
- package/components/data/form/base-form/hooks/useFormOperations.js +109 -161
- package/components/data/form/base-form/hooks/useFormSubmission.js +220 -280
- package/components/data/form/base-form/hooks/useFormValidation.js +119 -168
- package/components/data/form/base-form/hooks/useParentFormRelationship.js +67 -103
- package/components/data/form/base-form/index.js +531 -646
- package/components/data/form/base-form/props.js +74 -151
- package/components/data/form/base-form/utils.js +210 -323
- package/components/data/form/dynamic-fields/constant.js +43 -53
- package/components/data/form/dynamic-fields/index.js +135 -144
- package/components/data/form/dynamic-fields/props.js +0 -5
- package/components/data/form/dynamic-fields/utils.js +99 -158
- package/components/data/form/form-action/index.js +107 -85
- package/components/data/form/form-body/index.js +52 -26
- package/components/data/form/form-context.js +43 -59
- package/components/data/form/form-controller/hooks/index.js +43 -57
- package/components/data/form/form-controller/props.js +5 -8
- package/components/data/form/form-controller/utils.js +54 -49
- package/components/data/form/form-controller/validation-contrustor.js +203 -426
- package/components/data/form/form-controller/withFormController.js +319 -269
- package/components/data/form/form-dynamic-section/index.js +47 -41
- package/components/data/form/form-dynamic-section/props.js +0 -5
- package/components/data/form/form-field/base-field.js +97 -109
- package/components/data/form/form-field/index.js +91 -82
- package/components/data/form/form-field/props.js +0 -5
- package/components/data/form/form-footer/index.js +52 -25
- package/components/data/form/form-header/index.js +61 -58
- package/components/data/form/index.js +95 -74
- package/components/data/form/props.js +0 -5
- package/components/data/list/components/GroupHeader.js +34 -33
- package/components/data/list/components/GroupedListItems.js +108 -104
- package/components/data/list/components/ListContainer.js +22 -27
- package/components/data/list/components/ListDND.js +193 -185
- package/components/data/list/components/ListHeader.js +32 -49
- package/components/data/list/components/ListItem.js +153 -146
- package/components/data/list/components/ListItemWithTemplate.js +87 -105
- package/components/data/list/components/ListItems.js +180 -194
- package/components/data/list/components/ListPagination.js +127 -153
- package/components/data/list/components/LoadMoreButton.js +25 -33
- package/components/data/list/components/NoDataMessage.js +9 -22
- package/components/data/list/components/StandardListItems.js +79 -85
- package/components/data/list/components/index.js +31 -119
- package/components/data/list/components/props.js +0 -5
- package/components/data/list/hooks/index.js +22 -75
- package/components/data/list/hooks/props.js +0 -5
- package/components/data/list/hooks/useCurrentPageItems.js +20 -38
- package/components/data/list/hooks/useGroupedData.js +19 -33
- package/components/data/list/hooks/useListData.js +17 -47
- package/components/data/list/hooks/useListEffects.js +168 -237
- package/components/data/list/hooks/useListEventHandlers.js +301 -285
- package/components/data/list/hooks/useListPagination.js +90 -136
- package/components/data/list/hooks/useListState.js +49 -91
- package/components/data/list/hooks/useListStateManager.js +104 -159
- package/components/data/list/hooks/usePaginatedGroupedData.js +74 -110
- package/components/data/list/index.d.ts +1 -0
- package/components/data/list/index.js +579 -621
- package/components/data/list/props.d.ts +4 -0
- package/components/data/list/props.js +0 -5
- package/components/data/list/templates/media-template.js +29 -50
- package/components/data/list/utils/constants.js +20 -32
- package/components/data/list/utils/list-helpers.d.ts +2 -1
- package/components/data/list/utils/list-helpers.js +71 -115
- package/components/data/list/utils/list-widget-methods.js +56 -76
- package/components/data/list/utils/widget-instance-utils.js +20 -57
- package/components/data/live-filter/index.js +219 -271
- package/components/data/live-filter/props.js +5 -12
- package/components/data/live-form/index.js +68 -91
- package/components/data/live-form/props.js +5 -12
- package/components/data/pagination/components/BasicPagination.js +124 -104
- package/components/data/pagination/components/ClassicPagination.js +167 -190
- package/components/data/pagination/components/InlinePagination.js +97 -98
- package/components/data/pagination/components/LoadingComponent.js +17 -30
- package/components/data/pagination/components/PageSizeSelector.js +176 -169
- package/components/data/pagination/components/PagerNavigation.js +84 -105
- package/components/data/pagination/components/TotalRecords.js +48 -47
- package/components/data/pagination/components/index.js +14 -47
- package/components/data/pagination/components/props.js +0 -5
- package/components/data/pagination/hooks/index.js +6 -19
- package/components/data/pagination/hooks/props.js +0 -5
- package/components/data/pagination/hooks/useNavigationSize.js +12 -21
- package/components/data/pagination/hooks/usePagination.js +702 -905
- package/components/data/pagination/index.js +336 -389
- package/components/data/table/components/AddNewRow.js +122 -154
- package/components/data/table/components/EditableCell.js +68 -75
- package/components/data/table/components/FieldValidationError.js +19 -20
- package/components/data/table/components/RowCells.js +97 -80
- package/components/data/table/components/RowExpansionButton.js +43 -39
- package/components/data/table/components/SummaryCell.js +54 -88
- package/components/data/table/components/SummaryRow.js +45 -52
- package/components/data/table/components/SummaryRowFooter.js +35 -42
- package/components/data/table/components/TableBody.js +222 -218
- package/components/data/table/components/TableDataRow.js +113 -106
- package/components/data/table/components/TableFilters.js +391 -390
- package/components/data/table/components/TableFooterActions.js +25 -32
- package/components/data/table/components/TableHeader.js +460 -435
- package/components/data/table/components/TablePanelHeading.js +157 -181
- package/components/data/table/components/index.js +27 -95
- package/components/data/table/hooks/index.js +21 -230
- package/components/data/table/hooks/use-edited-rows.js +59 -94
- package/components/data/table/hooks/useCellState.js +58 -83
- package/components/data/table/hooks/useCustomExpressionColumns.js +65 -86
- package/components/data/table/hooks/useDynamicColumns.js +59 -92
- package/components/data/table/hooks/useEditingState.js +30 -41
- package/components/data/table/hooks/useFormWidget.js +163 -172
- package/components/data/table/hooks/usePaginationState.js +67 -77
- package/components/data/table/hooks/usePanelStructure.js +47 -41
- package/components/data/table/hooks/useResponsiveColumns.js +14 -20
- package/components/data/table/hooks/useRowExpansion.js +131 -127
- package/components/data/table/hooks/useRowHandlers.js +56 -69
- package/components/data/table/hooks/useRowSelection.js +249 -329
- package/components/data/table/hooks/useServerSideSorting.js +109 -175
- package/components/data/table/hooks/useTableColumns.js +322 -331
- package/components/data/table/hooks/useTableData.js +111 -166
- package/components/data/table/hooks/useTableEdit.js +526 -564
- package/components/data/table/hooks/useTableEffects.js +60 -107
- package/components/data/table/hooks/useTableFilter.js +244 -237
- package/components/data/table/hooks/useTableInitialization.js +44 -76
- package/components/data/table/hooks/useTableState.js +39 -61
- package/components/data/table/hooks/useTableStateManager.js +295 -468
- package/components/data/table/index.js +1553 -1713
- package/components/data/table/live-table/index.js +157 -219
- package/components/data/table/props.js +0 -5
- package/components/data/table/table-action/index.js +97 -75
- package/components/data/table/table-column/index.js +48 -42
- package/components/data/table/table-group/index.js +7 -25
- package/components/data/table/table-row/index.js +63 -55
- package/components/data/table/table-row-action/index.js +102 -77
- package/components/data/table/utils/buildSelectionColumns.js +86 -137
- package/components/data/table/utils/columnBuilder.js +116 -158
- package/components/data/table/utils/columnProxy.js +48 -66
- package/components/data/table/utils/columnWidthDistribution.js +40 -64
- package/components/data/table/utils/constants.js +92 -40
- package/components/data/table/utils/crud-handlers.js +292 -473
- package/components/data/table/utils/dynamic-columns.js +99 -144
- package/components/data/table/utils/groupHeaderUtils.js +36 -61
- package/components/data/table/utils/index.d.ts +8 -5
- package/components/data/table/utils/index.js +419 -639
- package/components/data/table/utils/renderDisplayCell.js +127 -169
- package/components/data/table/utils/script-page-size-broadcast.js +17 -29
- package/components/data/table/utils/selectionUtils.js +59 -113
- package/components/data/table/utils/table-helpers.js +38 -74
- package/components/data/table/utils/validation.js +35 -78
- package/components/data/table/utils/widgetMapping.d.ts +5 -0
- package/components/data/table/utils/widgetMapping.js +41 -0
- package/components/data/types.js +112 -112
- package/components/data/utils/field-data-utils.js +38 -42
- package/components/data/utils/filter-field-util.js +42 -44
- package/components/data/utils/index.js +112 -111
- package/components/dialogs/alert-dialog/index.js +83 -78
- package/components/dialogs/alert-dialog/props.js +0 -5
- package/components/dialogs/confirm-dialog/index.js +102 -92
- package/components/dialogs/confirm-dialog/props.js +0 -5
- package/components/dialogs/dialog/index.js +93 -69
- package/components/dialogs/dialog/props.js +0 -5
- package/components/dialogs/dialog-actions/index.js +12 -26
- package/components/dialogs/dialog-actions/props.js +0 -5
- package/components/dialogs/dialog-body/index.js +13 -30
- package/components/dialogs/dialog-body/props.js +0 -5
- package/components/dialogs/dialog-content/index.js +48 -41
- package/components/dialogs/dialog-content/props.js +0 -5
- package/components/dialogs/dialog-header/index.js +88 -101
- package/components/dialogs/dialog-header/props.js +0 -5
- package/components/dialogs/iframe-dialog/index.js +136 -128
- package/components/dialogs/iframe-dialog/props.js +0 -5
- package/components/dialogs/index.js +104 -101
- package/components/dialogs/login-dialog/index.js +285 -347
- package/components/dialogs/login-dialog/props.js +0 -5
- package/components/dialogs/page-dialog/index.js +95 -86
- package/components/dialogs/page-dialog/props.js +0 -5
- package/components/dialogs/props.js +0 -5
- package/components/dialogs/withDialogWrapper.js +110 -83
- package/components/form/button/index.js +296 -245
- package/components/form/button/props.js +0 -5
- package/components/form/button-group/index.js +80 -69
- package/components/form/button-group/props.js +0 -5
- package/components/input/calendar/index.js +409 -362
- package/components/input/calendar/props.js +0 -5
- package/components/input/calendar/utils.js +164 -172
- package/components/input/chips/SortableChip/index.js +109 -100
- package/components/input/chips/SortableChip/props.js +0 -5
- package/components/input/chips/index.js +663 -570
- package/components/input/chips/props.js +0 -5
- package/components/input/chips/utils.js +131 -122
- package/components/input/color-picker/index.js +536 -594
- package/components/input/color-picker/props.js +0 -5
- package/components/input/composite/index.js +71 -110
- package/components/input/composite/props.js +0 -5
- package/components/input/currency/index.js +277 -224
- package/components/input/currency/props.js +0 -5
- package/components/input/default/checkbox/index.js +329 -250
- package/components/input/default/checkbox/props.js +0 -5
- package/components/input/default/checkboxset/index.d.ts +2 -0
- package/components/input/default/checkboxset/index.js +529 -446
- package/components/input/default/checkboxset/props.d.ts +4 -0
- package/components/input/default/checkboxset/props.js +0 -5
- package/components/input/default/checkboxset/utils.js +15 -25
- package/components/input/default/radioset/index.d.ts +2 -0
- package/components/input/default/radioset/index.js +409 -350
- package/components/input/default/radioset/props.d.ts +6 -0
- package/components/input/default/radioset/props.js +0 -5
- package/components/input/default/switch/index.js +494 -458
- package/components/input/default/switch/prop.js +0 -5
- package/components/input/epoch/date/components/DatePickerPopover.js +242 -193
- package/components/input/epoch/date/index.js +638 -518
- package/components/input/epoch/date/props.js +0 -5
- package/components/input/epoch/date/styled.js +61 -70
- package/components/input/epoch/date/utils.js +67 -115
- package/components/input/epoch/datetime/index.js +758 -695
- package/components/input/epoch/datetime/props.js +0 -5
- package/components/input/epoch/datetime/utils.js +121 -186
- package/components/input/epoch/time/index.js +441 -415
- package/components/input/epoch/time/props.js +0 -5
- package/components/input/epoch/time/utils.js +101 -112
- package/components/input/fileupload/Utils.js +70 -97
- package/components/input/fileupload/components/ListItems.js +132 -130
- package/components/input/fileupload/components/MultiUpload.js +80 -77
- package/components/input/fileupload/components/SingleUpload.js +57 -57
- package/components/input/fileupload/index.js +253 -178
- package/components/input/fileupload/props.js +0 -5
- package/components/input/fileupload/useFileUpload.js +209 -258
- package/components/input/number/index.js +434 -393
- package/components/input/number/props.js +0 -5
- package/components/input/rating/index.js +401 -394
- package/components/input/rating/props.js +0 -5
- package/components/input/select/index.js +408 -463
- package/components/input/select/props.js +0 -5
- package/components/input/slider/index.js +339 -332
- package/components/input/slider/props.js +0 -5
- package/components/input/text/index.d.ts +3 -3
- package/components/input/text/index.js +438 -475
- package/components/input/text/props.d.ts +1 -1
- package/components/input/text/props.js +0 -5
- package/components/input/text/util.js +82 -222
- package/components/input/textarea/index.js +322 -358
- package/components/input/textarea/props.js +0 -5
- package/components/input/upload/index.js +135 -131
- package/components/input/upload/props.js +0 -5
- package/components/input/util/index.js +9 -11
- package/components/layout/footer/index.js +12 -35
- package/components/layout/footer/props.js +0 -5
- package/components/layout/header/index.js +12 -38
- package/components/layout/header/props.js +0 -5
- package/components/layout/leftnav/index.js +38 -44
- package/components/layout/leftnav/props.js +0 -5
- package/components/layout/rightnav/index.js +12 -36
- package/components/layout/rightnav/props.js +0 -5
- package/components/layout/topnav/index.js +24 -38
- package/components/layout/topnav/props.js +0 -5
- package/components/navbar/index.js +119 -98
- package/components/navbar/nav/index.js +236 -232
- package/components/navbar/nav/props.js +0 -5
- package/components/navbar/nav-item/index.js +74 -65
- package/components/navbar/nav-item/props.js +0 -5
- package/components/navigation/breadcrumb/index.js +38 -61
- package/components/navigation/breadcrumb/props.js +0 -5
- package/components/navigation/menu/components/ListItems.js +76 -67
- package/components/navigation/menu/constants.js +27 -42
- package/components/navigation/menu/hooks/useHoverState.hook.js +20 -47
- package/components/navigation/menu/hooks/useKeyboardMovements.hook.js +34 -28
- package/components/navigation/menu/hooks/useTransformedDataset.hook.js +21 -14
- package/components/navigation/menu/index.js +911 -846
- package/components/navigation/menu/props.js +0 -5
- package/components/navigation/menu/utils/action-task.js +6 -9
- package/components/navigation/menu/utils/role-filter.js +41 -56
- package/components/navigation/popover/index.js +191 -205
- package/components/navigation/popover/props.js +5 -8
- package/components/page/content/index.js +9 -31
- package/components/page/content/props.js +0 -5
- package/components/page/error-boundary/index.js +115 -105
- package/components/page/error-boundary/props.js +0 -5
- package/components/page/index.js +84 -102
- package/components/page/page-content/index.js +21 -30
- package/components/page/page-content/props.js +0 -5
- package/components/page/partial/index.js +50 -45
- package/components/page/partial/props.js +0 -5
- package/components/page/partial-container/index.js +81 -107
- package/components/page/partial-container/props.d.ts +1 -1
- package/components/page/partial-container/props.js +0 -5
- package/components/page/props.js +0 -5
- package/components/page/toast-container/index.js +20 -41
- package/components/page/toast-container/props.js +0 -5
- package/components/prefab/container/index.js +60 -53
- package/components/prefab/container/props.js +0 -5
- package/components/prefab/index.js +76 -61
- package/components/prefab/props.js +0 -5
- package/context/AppContext.d.ts +1 -1
- package/context/AppContext.js +17 -18
- package/context/AppSpinnerProvider.js +19 -34
- package/context/LayoutProvider.js +54 -57
- package/context/LocalizationProvider.js +34 -49
- package/context/PrefabContext.js +68 -119
- package/context/WidgetProvider.js +160 -166
- package/core/app-config.js +0 -1
- package/core/app.service.js +200 -327
- package/core/appVariablesStore.js +10 -15
- package/core/appstore.js +37 -53
- package/core/constants/currency-constant.js +81 -83
- package/core/constants/events.js +34 -44
- package/core/constants/index.js +21 -31
- package/core/dialog.service.js +52 -72
- package/core/event-notifier.js +94 -131
- package/core/formatter/array-formatters.js +18 -32
- package/core/formatter/date-formatters.js +140 -204
- package/core/formatter/index.js +64 -117
- package/core/formatter/number-formatters.js +115 -159
- package/core/formatter/security-formatters.js +233 -283
- package/core/formatter/string-formatters.js +23 -45
- package/core/formatter/types.js +12 -18
- package/core/formatters.js +6 -24
- package/core/proxy-service.js +242 -306
- package/core/script-registry.js +87 -134
- package/core/security.service.js +8 -11
- package/core/util/compare.js +13 -25
- package/core/util/dom.js +32 -63
- package/core/util/index.d.ts +5 -0
- package/core/util/index.js +95 -95
- package/core/util/safe-is-equal.js +42 -94
- package/core/util/security.js +114 -153
- package/core/util/utils.d.ts +8 -1
- package/core/util/utils.js +124 -132
- package/core/widget-observer.js +34 -61
- package/higherOrder/BaseApp.js +327 -500
- package/higherOrder/BaseAppProps.js +0 -5
- package/higherOrder/BaseDateTime.js +277 -231
- package/higherOrder/BasePage.js +479 -735
- package/higherOrder/BasePartial.js +87 -114
- package/higherOrder/BasePrefab.js +190 -206
- package/higherOrder/DataNav.js +287 -302
- package/higherOrder/helper.js +62 -48
- package/higherOrder/props.js +0 -5
- package/higherOrder/withBaseWrapper.js +123 -168
- package/higherOrder/withStandalone.js +28 -26
- package/hooks/useAccess.js +113 -289
- package/hooks/useAppConfig.js +15 -40
- package/hooks/useAuth.js +256 -495
- package/hooks/useDataSourceSubscription.d.ts +3 -3
- package/hooks/useDataSourceSubscription.js +99 -109
- package/hooks/useDebounce.js +28 -56
- package/hooks/useDeviceVisibility.js +14 -23
- package/hooks/useHttp.d.ts +1 -0
- package/hooks/useHttp.js +318 -493
- package/libs/index.js +4 -13
- package/libs/prefab/index.js +6 -20
- package/mui-config/theme-provider.js +9 -17
- package/mui-config/theme.js +6 -9
- package/package-lock.json +822 -3191
- package/package.json +3 -19
- package/providers/AppProviders.js +21 -24
- package/runtime-dynamic/App.js +65 -93
- package/runtime-dynamic/app-initializer.js +207 -400
- package/runtime-dynamic/components/ErrorBoundary.js +59 -76
- package/runtime-dynamic/components/PageWrapper.js +23 -35
- package/runtime-dynamic/components/PrefabPreview.js +40 -69
- package/runtime-dynamic/components/partial-content.d.ts +2 -3
- package/runtime-dynamic/components/partial-content.js +66 -48
- package/runtime-dynamic/components/prefab-content.js +37 -30
- package/runtime-dynamic/components/use-dynamic-component.js +62 -150
- package/runtime-dynamic/factories/build-base-page-like-component.js +44 -58
- package/runtime-dynamic/factories/dynamic-component.d.ts +9 -0
- package/runtime-dynamic/factories/dynamic-component.js +83 -0
- package/runtime-dynamic/factories/prefab-factory.js +60 -81
- package/runtime-dynamic/factories/startup-info.js +12 -25
- package/runtime-dynamic/factories/utils.d.ts +1 -9
- package/runtime-dynamic/factories/utils.js +47 -130
- package/runtime-dynamic/index.js +56 -191
- package/runtime-dynamic/main.js +42 -70
- package/runtime-dynamic/preview-mode.js +14 -29
- package/runtime-dynamic/preview-navigation.js +21 -30
- package/runtime-dynamic/preview-path.d.ts +5 -0
- package/runtime-dynamic/preview-path.js +13 -0
- package/runtime-dynamic/preview-resource-base.js +15 -31
- package/runtime-dynamic/registry/component-registry.js +269 -334
- package/runtime-dynamic/registry/custom-widget-registry.js +11 -15
- package/runtime-dynamic/registry/index.js +24 -63
- package/runtime-dynamic/registry/store.d.ts +1 -0
- package/runtime-dynamic/registry/store.js +18 -23
- package/runtime-dynamic/routes.js +53 -81
- package/runtime-dynamic/services/app-extension-provider.js +17 -44
- package/runtime-dynamic/services/autolayout-inject.d.ts +4 -0
- package/runtime-dynamic/services/autolayout-inject.js +27 -0
- package/runtime-dynamic/services/cache.js +27 -33
- package/runtime-dynamic/services/compile-render.d.ts +9 -0
- package/runtime-dynamic/services/compile-render.js +142 -0
- package/runtime-dynamic/services/component-ref-provider.js +70 -124
- package/runtime-dynamic/services/css-scoping.js +27 -28
- package/runtime-dynamic/services/fragment-url.js +37 -50
- package/runtime-dynamic/services/index.js +48 -152
- package/runtime-dynamic/services/markup-transpiler.d.ts +2 -2
- package/runtime-dynamic/services/markup-transpiler.js +39 -231
- package/runtime-dynamic/services/prefab-resources.js +42 -130
- package/runtime-dynamic/services/resource-manager.d.ts +2 -1
- package/runtime-dynamic/services/resource-manager.js +32 -63
- package/runtime-dynamic/services/script-executor.js +50 -61
- package/runtime-dynamic/services/variable-factory.js +141 -184
- package/runtime-dynamic/services/variable-registry.js +69 -115
- package/runtime-dynamic/services/variable-transpiler.js +73 -103
- package/runtime-dynamic/shims/next-image.js +79 -50
- package/runtime-dynamic/shims/next-link.js +58 -32
- package/runtime-dynamic/shims/next-navigation.js +17 -34
- package/runtime-dynamic/utils/index.d.ts +2 -0
- package/runtime-dynamic/utils/index.js +22 -24
- package/store/bindActions/i18nActions.js +16 -18
- package/store/index.js +29 -35
- package/store/middleware/navigationMiddleware.js +25 -45
- package/store/middleware/pendingTabNavigationIntentMiddleware.js +20 -25
- package/store/slices/appConfigSlice.js +65 -94
- package/store/slices/authSlice.js +317 -471
- package/store/slices/i18nSlice.js +169 -168
- package/store/slices/navigationSlice.js +22 -20
- package/store/util/resolve-path.d.ts +1 -0
- package/store/util/resolve-path.js +7 -0
- package/store/viewport.service.js +150 -194
- package/types/index.js +10 -15
- package/utils/attr.js +198 -41
- package/utils/custom-expression/index.js +55 -151
- package/utils/custom-expression/parser.js +106 -182
- package/utils/dataset-util.js +113 -154
- package/utils/eval-expression.js +10 -19
- package/utils/form-state.util.js +60 -118
- package/utils/form-utils.js +49 -190
- package/utils/format-util.js +113 -184
- package/utils/layoutsize-util.js +11 -17
- package/utils/lib-error-skipper.js +54 -52
- package/utils/page-params-util.js +50 -40
- package/utils/pending-tab-navigation-intent.js +7 -17
- package/utils/resource-url.js +8 -19
- package/utils/state-persistance.js +136 -253
- package/utils/style-utils.d.ts +2 -0
- package/utils/style-utils.js +25 -74
- package/utils/transformedDataset-utils.js +353 -381
- package/utils/widget-cleanup-util.js +42 -74
- package/utils/widgets.js +19 -31
- package/variables/base-variable.js +117 -166
- package/variables/constants.js +5 -8
- package/variables/crud-variable.js +150 -181
- package/variables/live-variable.d.ts +1 -1
- package/variables/live-variable.js +140 -174
- package/variables/metadata.service.js +74 -116
- package/variables/model-variable.js +68 -78
- package/variables/service-variable.js +171 -285
- package/wm-namespace.js +11 -14
- package/components/chart/src/css.d.js +0 -1
- package/tsconfig.declaration.tsbuildinfo +0 -1
- package/types/global.d.js +0 -3
package/hooks/useAuth.js
CHANGED
|
@@ -1,416 +1,235 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return dispatch((0, _authSlice.logout)({
|
|
63
|
-
baseURL: baseURL
|
|
64
|
-
})).unwrap();
|
|
65
|
-
case 3:
|
|
66
|
-
logoutResponse = _context2.sent;
|
|
67
|
-
return _context2.abrupt("return", logoutResponse);
|
|
68
|
-
case 7:
|
|
69
|
-
_context2.prev = 7;
|
|
70
|
-
_context2.t0 = _context2["catch"](0);
|
|
71
|
-
return _context2.abrupt("return", _context2.t0);
|
|
72
|
-
case 10:
|
|
73
|
-
case "end":
|
|
74
|
-
return _context2.stop();
|
|
75
|
-
}
|
|
76
|
-
}, _callee2, null, [[0, 7]]);
|
|
77
|
-
}));
|
|
78
|
-
return function handleLogout(_x2) {
|
|
79
|
-
return _ref2.apply(this, arguments);
|
|
80
|
-
};
|
|
81
|
-
}();
|
|
82
|
-
var checkCanAccessPage = /*#__PURE__*/function () {
|
|
83
|
-
var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(pageName) {
|
|
84
|
-
var baseUrl;
|
|
85
|
-
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
86
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
87
|
-
case 0:
|
|
88
|
-
baseUrl = (securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.baseUrl) || "";
|
|
89
|
-
_context3.next = 3;
|
|
90
|
-
return dispatch((0, _authSlice.canAccessPage)({
|
|
91
|
-
pageName: pageName
|
|
92
|
-
})).unwrap();
|
|
93
|
-
case 3:
|
|
94
|
-
return _context3.abrupt("return", _context3.sent);
|
|
95
|
-
case 4:
|
|
96
|
-
case "end":
|
|
97
|
-
return _context3.stop();
|
|
98
|
-
}
|
|
99
|
-
}, _callee3);
|
|
100
|
-
}));
|
|
101
|
-
return function checkCanAccessPage(_x3) {
|
|
102
|
-
return _ref3.apply(this, arguments);
|
|
103
|
-
};
|
|
104
|
-
}();
|
|
105
|
-
var hasAccessToWidget = function hasAccessToWidget(widgetRoles) {
|
|
106
|
-
var widgetRolesArr = widgetRoles.split(",");
|
|
107
|
-
|
|
108
|
-
// Access the widget when 'Everyone' is chosen
|
|
109
|
-
if ((0, _includes["default"])(widgetRolesArr, _authSlice.USER_ROLE.EVERYONE)) {
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { useEffect, useState } from "react";
|
|
21
|
+
import { useAppDispatch, useAppSelector } from "../store";
|
|
22
|
+
import {
|
|
23
|
+
loadSecurityInfo,
|
|
24
|
+
login,
|
|
25
|
+
logout,
|
|
26
|
+
canAccessPage,
|
|
27
|
+
checkAccess,
|
|
28
|
+
USER_ROLE,
|
|
29
|
+
navigateToLandingPage,
|
|
30
|
+
setPageLoading
|
|
31
|
+
} from "../store/slices/authSlice";
|
|
32
|
+
import includes from "lodash-es/includes";
|
|
33
|
+
import { getServiceDefinitions } from "../store/slices/appConfigSlice";
|
|
34
|
+
const useAuth = () => {
|
|
35
|
+
const dispatch = useAppDispatch();
|
|
36
|
+
const { isLoggedIn, loggedInUser, securityConfig, isPageLoading, error } = useAppSelector(
|
|
37
|
+
(state) => state.auth
|
|
38
|
+
);
|
|
39
|
+
const handleLogin = async (options) => {
|
|
40
|
+
try {
|
|
41
|
+
const loginResponse = await dispatch(login(options)).unwrap();
|
|
42
|
+
return loginResponse;
|
|
43
|
+
} catch (error2) {
|
|
44
|
+
throw error2;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const handleLogout = async (baseURL) => {
|
|
48
|
+
try {
|
|
49
|
+
const logoutResponse = await dispatch(logout({ baseURL })).unwrap();
|
|
50
|
+
return logoutResponse;
|
|
51
|
+
} catch (error2) {
|
|
52
|
+
return error2;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const checkCanAccessPage = async (pageName) => {
|
|
56
|
+
const baseUrl = (securityConfig == null ? void 0 : securityConfig.baseUrl) || "";
|
|
57
|
+
return await dispatch(canAccessPage({ pageName })).unwrap();
|
|
58
|
+
};
|
|
59
|
+
const hasAccessToWidget = (widgetRoles) => {
|
|
60
|
+
const widgetRolesArr = widgetRoles.split(",");
|
|
61
|
+
if (includes(widgetRolesArr, USER_ROLE.EVERYONE)) {
|
|
110
62
|
return true;
|
|
111
63
|
}
|
|
112
|
-
|
|
113
|
-
// Access the widget when 'Anonymous' is chosen and user is not authenticated
|
|
114
|
-
if ((0, _includes["default"])(widgetRolesArr, _authSlice.USER_ROLE.ANONYMOUS) && !(loggedInUser !== null && loggedInUser !== void 0 && loggedInUser.isAuthenticated)) {
|
|
64
|
+
if (includes(widgetRolesArr, USER_ROLE.ANONYMOUS) && !(loggedInUser == null ? void 0 : loggedInUser.isAuthenticated)) {
|
|
115
65
|
return true;
|
|
116
66
|
}
|
|
117
|
-
|
|
118
|
-
// Access the widget when 'Only Authenticated Users' is chosen and user is authenticated
|
|
119
|
-
if ((0, _includes["default"])(widgetRolesArr, _authSlice.USER_ROLE.AUTHENTICATED) && loggedInUser !== null && loggedInUser !== void 0 && loggedInUser.isAuthenticated) {
|
|
67
|
+
if (includes(widgetRolesArr, USER_ROLE.AUTHENTICATED) && (loggedInUser == null ? void 0 : loggedInUser.isAuthenticated)) {
|
|
120
68
|
return true;
|
|
121
69
|
}
|
|
122
|
-
|
|
123
|
-
// Access the widget when widget role and logged in user role matches
|
|
124
|
-
return !!(loggedInUser !== null && loggedInUser !== void 0 && loggedInUser.isAuthenticated) && matchRoles(widgetRolesArr, (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.roles) || []);
|
|
70
|
+
return !!(loggedInUser == null ? void 0 : loggedInUser.isAuthenticated) && matchRoles(widgetRolesArr, (loggedInUser == null ? void 0 : loggedInUser.roles) || []);
|
|
125
71
|
};
|
|
126
|
-
|
|
127
|
-
return widgetRoles.some(
|
|
128
|
-
|
|
129
|
-
|
|
72
|
+
const matchRoles = (widgetRoles, userRoles) => {
|
|
73
|
+
return widgetRoles.some((role) => includes(userRoles, role));
|
|
74
|
+
};
|
|
75
|
+
const getLoggedInUserDetails = async (baseURL) => {
|
|
76
|
+
if (!baseURL) {
|
|
77
|
+
dispatch(setPageLoading(true));
|
|
78
|
+
await dispatch(getServiceDefinitions(baseURL)).unwrap();
|
|
79
|
+
dispatch(setPageLoading(false));
|
|
80
|
+
return Promise.resolve({});
|
|
81
|
+
}
|
|
82
|
+
return await dispatch(loadSecurityInfo(baseURL)).unwrap();
|
|
83
|
+
};
|
|
84
|
+
const authNavigateToLandingPage = async (options) => {
|
|
85
|
+
try {
|
|
86
|
+
await dispatch(navigateToLandingPage(options)).unwrap();
|
|
87
|
+
return true;
|
|
88
|
+
} catch (error2) {
|
|
89
|
+
return error2 || false;
|
|
90
|
+
}
|
|
130
91
|
};
|
|
131
|
-
var getLoggedInUserDetails = /*#__PURE__*/function () {
|
|
132
|
-
var _ref4 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(baseURL) {
|
|
133
|
-
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
134
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
135
|
-
case 0:
|
|
136
|
-
if (baseURL) {
|
|
137
|
-
_context4.next = 6;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
dispatch((0, _authSlice.setPageLoading)(true));
|
|
141
|
-
_context4.next = 4;
|
|
142
|
-
return dispatch((0, _appConfigSlice.getServiceDefinitions)(baseURL)).unwrap();
|
|
143
|
-
case 4:
|
|
144
|
-
dispatch((0, _authSlice.setPageLoading)(false));
|
|
145
|
-
return _context4.abrupt("return", Promise.resolve({}));
|
|
146
|
-
case 6:
|
|
147
|
-
_context4.next = 8;
|
|
148
|
-
return dispatch((0, _authSlice.loadSecurityInfo)(baseURL)).unwrap();
|
|
149
|
-
case 8:
|
|
150
|
-
return _context4.abrupt("return", _context4.sent);
|
|
151
|
-
case 9:
|
|
152
|
-
case "end":
|
|
153
|
-
return _context4.stop();
|
|
154
|
-
}
|
|
155
|
-
}, _callee4);
|
|
156
|
-
}));
|
|
157
|
-
return function getLoggedInUserDetails(_x4) {
|
|
158
|
-
return _ref4.apply(this, arguments);
|
|
159
|
-
};
|
|
160
|
-
}();
|
|
161
|
-
var authNavigateToLandingPage = /*#__PURE__*/function () {
|
|
162
|
-
var _ref5 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(options) {
|
|
163
|
-
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
164
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
165
|
-
case 0:
|
|
166
|
-
_context5.prev = 0;
|
|
167
|
-
_context5.next = 3;
|
|
168
|
-
return dispatch((0, _authSlice.navigateToLandingPage)(options)).unwrap();
|
|
169
|
-
case 3:
|
|
170
|
-
return _context5.abrupt("return", true);
|
|
171
|
-
case 6:
|
|
172
|
-
_context5.prev = 6;
|
|
173
|
-
_context5.t0 = _context5["catch"](0);
|
|
174
|
-
return _context5.abrupt("return", _context5.t0 || false);
|
|
175
|
-
case 9:
|
|
176
|
-
case "end":
|
|
177
|
-
return _context5.stop();
|
|
178
|
-
}
|
|
179
|
-
}, _callee5, null, [[0, 6]]);
|
|
180
|
-
}));
|
|
181
|
-
return function authNavigateToLandingPage(_x5) {
|
|
182
|
-
return _ref5.apply(this, arguments);
|
|
183
|
-
};
|
|
184
|
-
}();
|
|
185
92
|
return {
|
|
186
|
-
isLoggedIn
|
|
187
|
-
loggedInUser
|
|
188
|
-
securityConfig
|
|
189
|
-
isPageLoading
|
|
190
|
-
error
|
|
93
|
+
isLoggedIn,
|
|
94
|
+
loggedInUser,
|
|
95
|
+
securityConfig,
|
|
96
|
+
isPageLoading,
|
|
97
|
+
error,
|
|
191
98
|
login: handleLogin,
|
|
192
99
|
logout: handleLogout,
|
|
193
100
|
canAccessPage: checkCanAccessPage,
|
|
194
|
-
hasAccessToWidget
|
|
195
|
-
getLoggedInUserDetails
|
|
101
|
+
hasAccessToWidget,
|
|
102
|
+
getLoggedInUserDetails,
|
|
196
103
|
navigateToLandingPage: authNavigateToLandingPage
|
|
197
104
|
};
|
|
198
105
|
};
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
state = _useState[0],
|
|
211
|
-
setState = _useState[1];
|
|
212
|
-
var hasAccess = pageName === state.currentPage ? state.hasAccess : false;
|
|
213
|
-
var loading = pageName !== state.currentPage || state.loading;
|
|
214
|
-
(0, _react.useEffect)(function () {
|
|
215
|
-
// Set loading to true and hasAccess to false immediately for new page
|
|
106
|
+
const usePageAccess = (pageName) => {
|
|
107
|
+
const dispatch = useAppDispatch();
|
|
108
|
+
const { loggedInUser } = useAppSelector((state2) => state2.auth);
|
|
109
|
+
const [state, setState] = useState({
|
|
110
|
+
hasAccess: false,
|
|
111
|
+
loading: true,
|
|
112
|
+
currentPage: pageName
|
|
113
|
+
});
|
|
114
|
+
const hasAccess = pageName === state.currentPage ? state.hasAccess : false;
|
|
115
|
+
const loading = pageName !== state.currentPage || state.loading;
|
|
116
|
+
useEffect(() => {
|
|
216
117
|
if (pageName !== state.currentPage) {
|
|
217
|
-
setState(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
loading: true
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
var checkAccess = /*#__PURE__*/function () {
|
|
226
|
-
var _ref6 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
|
227
|
-
var access;
|
|
228
|
-
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
229
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
230
|
-
case 0:
|
|
231
|
-
_context6.prev = 0;
|
|
232
|
-
_context6.next = 3;
|
|
233
|
-
return dispatch((0, _authSlice.canAccessPage)({
|
|
234
|
-
pageName: pageName
|
|
235
|
-
})).unwrap();
|
|
236
|
-
case 3:
|
|
237
|
-
access = _context6.sent;
|
|
238
|
-
setState(function (prev) {
|
|
239
|
-
if (prev.currentPage !== pageName) return prev;
|
|
240
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
241
|
-
hasAccess: access,
|
|
242
|
-
loading: false
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
_context6.next = 11;
|
|
246
|
-
break;
|
|
247
|
-
case 7:
|
|
248
|
-
_context6.prev = 7;
|
|
249
|
-
_context6.t0 = _context6["catch"](0);
|
|
250
|
-
console.error("Error checking page access:", _context6.t0);
|
|
251
|
-
setState(function (prev) {
|
|
252
|
-
if (prev.currentPage !== pageName) return prev;
|
|
253
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
254
|
-
hasAccess: false,
|
|
255
|
-
loading: false
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
case 11:
|
|
259
|
-
case "end":
|
|
260
|
-
return _context6.stop();
|
|
261
|
-
}
|
|
262
|
-
}, _callee6, null, [[0, 7]]);
|
|
118
|
+
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
119
|
+
currentPage: pageName,
|
|
120
|
+
hasAccess: false,
|
|
121
|
+
loading: true
|
|
263
122
|
}));
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
123
|
+
}
|
|
124
|
+
const checkAccess2 = async () => {
|
|
125
|
+
try {
|
|
126
|
+
const access = await dispatch(canAccessPage({ pageName })).unwrap();
|
|
127
|
+
setState((prev) => {
|
|
128
|
+
if (prev.currentPage !== pageName) return prev;
|
|
129
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
130
|
+
hasAccess: access,
|
|
131
|
+
loading: false
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
} catch (error) {
|
|
135
|
+
console.error("Error checking page access:", error);
|
|
136
|
+
setState((prev) => {
|
|
137
|
+
if (prev.currentPage !== pageName) return prev;
|
|
138
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
139
|
+
hasAccess: false,
|
|
140
|
+
loading: false
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
checkAccess2();
|
|
269
146
|
}, [pageName, loggedInUser, dispatch]);
|
|
270
147
|
return {
|
|
271
|
-
hasAccess
|
|
272
|
-
loading
|
|
148
|
+
hasAccess,
|
|
149
|
+
loading
|
|
273
150
|
};
|
|
274
151
|
};
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
hasAccessToWidget = _useAuth.hasAccessToWidget;
|
|
152
|
+
const useWidgetAccess = (widgetRoles) => {
|
|
153
|
+
const { hasAccessToWidget } = useAuth();
|
|
278
154
|
return hasAccessToWidget(widgetRoles);
|
|
279
155
|
};
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}),
|
|
292
|
-
state = _useState2[0],
|
|
293
|
-
setState = _useState2[1];
|
|
294
|
-
var hasAccess = "".concat(type, "-").concat(name) === state.currentItem ? state.hasAccess : false;
|
|
295
|
-
var loading = "".concat(type, "-").concat(name) !== state.currentItem || state.loading;
|
|
296
|
-
(0, _react.useEffect)(function () {
|
|
297
|
-
// If name is empty, skip access check and mark as not loading
|
|
156
|
+
const useAccess = (name, type) => {
|
|
157
|
+
const dispatch = useAppDispatch();
|
|
158
|
+
const { loggedInUser, securityConfig } = useAppSelector((state2) => state2.auth);
|
|
159
|
+
const [state, setState] = useState({
|
|
160
|
+
hasAccess: false,
|
|
161
|
+
loading: true,
|
|
162
|
+
currentItem: `${type}-${name}`
|
|
163
|
+
});
|
|
164
|
+
const hasAccess = `${type}-${name}` === state.currentItem ? state.hasAccess : false;
|
|
165
|
+
const loading = `${type}-${name}` !== state.currentItem || state.loading;
|
|
166
|
+
useEffect(() => {
|
|
298
167
|
if (!name) {
|
|
299
|
-
setState(
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
});
|
|
306
|
-
});
|
|
168
|
+
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
169
|
+
currentItem: `${type}-${name}`,
|
|
170
|
+
hasAccess: true,
|
|
171
|
+
// Allow access when no name specified
|
|
172
|
+
loading: false
|
|
173
|
+
}));
|
|
307
174
|
return;
|
|
308
175
|
}
|
|
309
|
-
|
|
310
|
-
// Set loading to true and hasAccess to false immediately for new item
|
|
311
|
-
var currentItemKey = "".concat(type, "-").concat(name);
|
|
176
|
+
const currentItemKey = `${type}-${name}`;
|
|
312
177
|
if (currentItemKey !== state.currentItem) {
|
|
313
|
-
setState(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
loading: true
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
var checkItemAccess = /*#__PURE__*/function () {
|
|
322
|
-
var _ref7 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7() {
|
|
323
|
-
var access;
|
|
324
|
-
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
325
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
326
|
-
case 0:
|
|
327
|
-
_context7.prev = 0;
|
|
328
|
-
_context7.next = 3;
|
|
329
|
-
return dispatch((0, _authSlice.checkAccess)({
|
|
330
|
-
name: name,
|
|
331
|
-
type: type
|
|
332
|
-
})).unwrap();
|
|
333
|
-
case 3:
|
|
334
|
-
access = _context7.sent;
|
|
335
|
-
setState(function (prev) {
|
|
336
|
-
if (prev.currentItem !== currentItemKey) return prev;
|
|
337
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
338
|
-
hasAccess: access,
|
|
339
|
-
loading: false
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
_context7.next = 11;
|
|
343
|
-
break;
|
|
344
|
-
case 7:
|
|
345
|
-
_context7.prev = 7;
|
|
346
|
-
_context7.t0 = _context7["catch"](0);
|
|
347
|
-
console.error("Error checking ".concat(type.toLowerCase(), " access:"), _context7.t0);
|
|
348
|
-
setState(function (prev) {
|
|
349
|
-
if (prev.currentItem !== currentItemKey) return prev;
|
|
350
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
351
|
-
hasAccess: false,
|
|
352
|
-
loading: false
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
case 11:
|
|
356
|
-
case "end":
|
|
357
|
-
return _context7.stop();
|
|
358
|
-
}
|
|
359
|
-
}, _callee7, null, [[0, 7]]);
|
|
178
|
+
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
179
|
+
currentItem: currentItemKey,
|
|
180
|
+
hasAccess: false,
|
|
181
|
+
loading: true
|
|
360
182
|
}));
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
183
|
+
}
|
|
184
|
+
const checkItemAccess = async () => {
|
|
185
|
+
try {
|
|
186
|
+
const access = await dispatch(checkAccess({ name, type })).unwrap();
|
|
187
|
+
setState((prev) => {
|
|
188
|
+
if (prev.currentItem !== currentItemKey) return prev;
|
|
189
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
190
|
+
hasAccess: access,
|
|
191
|
+
loading: false
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error(`Error checking ${type.toLowerCase()} access:`, error);
|
|
196
|
+
setState((prev) => {
|
|
197
|
+
if (prev.currentItem !== currentItemKey) return prev;
|
|
198
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
199
|
+
hasAccess: false,
|
|
200
|
+
loading: false
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
};
|
|
365
205
|
checkItemAccess();
|
|
366
206
|
}, [name, type, loggedInUser, securityConfig, dispatch]);
|
|
367
207
|
return {
|
|
368
|
-
hasAccess
|
|
369
|
-
loading
|
|
208
|
+
hasAccess,
|
|
209
|
+
loading
|
|
370
210
|
};
|
|
371
211
|
};
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
* @param authState - Current auth state from Redux store
|
|
378
|
-
* @param appConfig - App configuration containing pages and partials
|
|
379
|
-
* @returns boolean indicating if access is granted
|
|
380
|
-
*/
|
|
381
|
-
var checkAccessSync = exports.checkAccessSync = function checkAccessSync(name, type, authState, appConfig) {
|
|
382
|
-
var _authState$loggedInUs, _authState$loggedInUs2, _authState$securityCo;
|
|
383
|
-
var userRoles = (authState === null || authState === void 0 || (_authState$loggedInUs = authState.loggedInUser) === null || _authState$loggedInUs === void 0 ? void 0 : _authState$loggedInUs.roles) || [];
|
|
384
|
-
var isAuthenticated = (authState === null || authState === void 0 || (_authState$loggedInUs2 = authState.loggedInUser) === null || _authState$loggedInUs2 === void 0 ? void 0 : _authState$loggedInUs2.isAuthenticated) || false;
|
|
385
|
-
var isSecurityEnabled = authState === null || authState === void 0 || (_authState$securityCo = authState.securityConfig) === null || _authState$securityCo === void 0 ? void 0 : _authState$securityCo.isSecurityEnabled;
|
|
386
|
-
|
|
387
|
-
// If security is not enabled, allow access to everything
|
|
212
|
+
const checkAccessSync = (name, type, authState, appConfig) => {
|
|
213
|
+
var _a, _b, _c;
|
|
214
|
+
const userRoles = ((_a = authState == null ? void 0 : authState.loggedInUser) == null ? void 0 : _a.roles) || [];
|
|
215
|
+
const isAuthenticated = ((_b = authState == null ? void 0 : authState.loggedInUser) == null ? void 0 : _b.isAuthenticated) || false;
|
|
216
|
+
const isSecurityEnabled = (_c = authState == null ? void 0 : authState.securityConfig) == null ? void 0 : _c.isSecurityEnabled;
|
|
388
217
|
if (!isSecurityEnabled) {
|
|
389
218
|
return true;
|
|
390
219
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
type: item.type
|
|
402
|
-
};
|
|
403
|
-
});
|
|
404
|
-
var config = serializableConfigs.find(function (item) {
|
|
405
|
-
return item.name.toLowerCase() === name.toLowerCase();
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
// If no config found, deny access for security
|
|
220
|
+
const configs = type === "PAGE" ? (appConfig == null ? void 0 : appConfig.pages) || [] : (appConfig == null ? void 0 : appConfig.partials) || [];
|
|
221
|
+
const serializableConfigs = configs.map((item) => ({
|
|
222
|
+
name: item.name,
|
|
223
|
+
permission: item.permission,
|
|
224
|
+
allowedRoles: item.allowedRoles,
|
|
225
|
+
type: item.type
|
|
226
|
+
}));
|
|
227
|
+
const config = serializableConfigs.find(
|
|
228
|
+
(item) => item.name.toLowerCase() === name.toLowerCase()
|
|
229
|
+
);
|
|
409
230
|
if (!config) {
|
|
410
231
|
return false;
|
|
411
232
|
}
|
|
412
|
-
|
|
413
|
-
// Check permission type
|
|
414
233
|
switch (config.permission) {
|
|
415
234
|
case "PermitAll":
|
|
416
235
|
return true;
|
|
@@ -420,149 +239,91 @@ var checkAccessSync = exports.checkAccessSync = function checkAccessSync(name, t
|
|
|
420
239
|
if (!isAuthenticated) {
|
|
421
240
|
return false;
|
|
422
241
|
}
|
|
423
|
-
|
|
424
|
-
// Check if user has any of the required roles
|
|
425
|
-
var allowedRoles = config.allowedRoles || [];
|
|
242
|
+
const allowedRoles = config.allowedRoles || [];
|
|
426
243
|
if (allowedRoles.length === 0) {
|
|
427
|
-
// If no roles specified but permission is Role, deny access
|
|
428
244
|
return false;
|
|
429
245
|
}
|
|
430
|
-
return allowedRoles.some(
|
|
431
|
-
return userRoles.includes(role);
|
|
432
|
-
});
|
|
246
|
+
return allowedRoles.some((role) => userRoles.includes(role));
|
|
433
247
|
default:
|
|
434
|
-
// Unknown permission type, deny access for security
|
|
435
248
|
return false;
|
|
436
249
|
}
|
|
437
250
|
};
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
setLoading(true);
|
|
457
|
-
setLoginError(null);
|
|
458
|
-
_context8.prev = 2;
|
|
459
|
-
_context8.next = 5;
|
|
460
|
-
return dispatch((0, _authSlice.login)(options)).unwrap();
|
|
461
|
-
case 5:
|
|
462
|
-
return _context8.abrupt("return", true);
|
|
463
|
-
case 8:
|
|
464
|
-
_context8.prev = 8;
|
|
465
|
-
_context8.t0 = _context8["catch"](2);
|
|
466
|
-
setLoginError(_context8.t0 instanceof Error ? _context8.t0.message : "Login failed");
|
|
467
|
-
return _context8.abrupt("return", false);
|
|
468
|
-
case 12:
|
|
469
|
-
_context8.prev = 12;
|
|
470
|
-
setLoading(false);
|
|
471
|
-
return _context8.finish(12);
|
|
472
|
-
case 15:
|
|
473
|
-
case "end":
|
|
474
|
-
return _context8.stop();
|
|
475
|
-
}
|
|
476
|
-
}, _callee8, null, [[2, 8, 12, 15]]);
|
|
477
|
-
}));
|
|
478
|
-
return function handleLogin(_x6) {
|
|
479
|
-
return _ref8.apply(this, arguments);
|
|
480
|
-
};
|
|
481
|
-
}();
|
|
251
|
+
const useLogin = () => {
|
|
252
|
+
const dispatch = useAppDispatch();
|
|
253
|
+
const { isLoggedIn, error } = useAppSelector((state) => state.auth);
|
|
254
|
+
const [loading, setLoading] = useState(false);
|
|
255
|
+
const [loginError, setLoginError] = useState(null);
|
|
256
|
+
const handleLogin = async (options) => {
|
|
257
|
+
setLoading(true);
|
|
258
|
+
setLoginError(null);
|
|
259
|
+
try {
|
|
260
|
+
await dispatch(login(options)).unwrap();
|
|
261
|
+
return true;
|
|
262
|
+
} catch (err) {
|
|
263
|
+
setLoginError(err instanceof Error ? err.message : "Login failed");
|
|
264
|
+
return false;
|
|
265
|
+
} finally {
|
|
266
|
+
setLoading(false);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
482
269
|
return {
|
|
483
|
-
loading
|
|
270
|
+
loading,
|
|
484
271
|
error: loginError || error,
|
|
485
|
-
isLoggedIn
|
|
486
|
-
handleLogin
|
|
487
|
-
clearError:
|
|
488
|
-
return setLoginError(null);
|
|
489
|
-
}
|
|
272
|
+
isLoggedIn,
|
|
273
|
+
handleLogin,
|
|
274
|
+
clearError: () => setLoginError(null)
|
|
490
275
|
};
|
|
491
276
|
};
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
return dispatch((0, _authSlice.logout)({
|
|
510
|
-
baseURL: baseURL
|
|
511
|
-
})).unwrap();
|
|
512
|
-
case 5:
|
|
513
|
-
return _context9.abrupt("return", true);
|
|
514
|
-
case 8:
|
|
515
|
-
_context9.prev = 8;
|
|
516
|
-
_context9.t0 = _context9["catch"](2);
|
|
517
|
-
setLogoutError(_context9.t0 instanceof Error ? _context9.t0.message : "Logout failed");
|
|
518
|
-
return _context9.abrupt("return", false);
|
|
519
|
-
case 12:
|
|
520
|
-
_context9.prev = 12;
|
|
521
|
-
setLoading(false);
|
|
522
|
-
return _context9.finish(12);
|
|
523
|
-
case 15:
|
|
524
|
-
case "end":
|
|
525
|
-
return _context9.stop();
|
|
526
|
-
}
|
|
527
|
-
}, _callee9, null, [[2, 8, 12, 15]]);
|
|
528
|
-
}));
|
|
529
|
-
return function handleLogout(_x7) {
|
|
530
|
-
return _ref9.apply(this, arguments);
|
|
531
|
-
};
|
|
532
|
-
}();
|
|
277
|
+
const useLogout = () => {
|
|
278
|
+
const dispatch = useAppDispatch();
|
|
279
|
+
const [loading, setLoading] = useState(false);
|
|
280
|
+
const [logoutError, setLogoutError] = useState(null);
|
|
281
|
+
const handleLogout = async (baseURL) => {
|
|
282
|
+
setLoading(true);
|
|
283
|
+
setLogoutError(null);
|
|
284
|
+
try {
|
|
285
|
+
await dispatch(logout({ baseURL })).unwrap();
|
|
286
|
+
return true;
|
|
287
|
+
} catch (err) {
|
|
288
|
+
setLogoutError(err instanceof Error ? err.message : "Logout failed");
|
|
289
|
+
return false;
|
|
290
|
+
} finally {
|
|
291
|
+
setLoading(false);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
533
294
|
return {
|
|
534
|
-
loading
|
|
295
|
+
loading,
|
|
535
296
|
error: logoutError,
|
|
536
|
-
handleLogout
|
|
537
|
-
clearError:
|
|
538
|
-
return setLogoutError(null);
|
|
539
|
-
}
|
|
297
|
+
handleLogout,
|
|
298
|
+
clearError: () => setLogoutError(null)
|
|
540
299
|
};
|
|
541
300
|
};
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
return state.auth;
|
|
545
|
-
}),
|
|
546
|
-
loggedInUser = _useAppSelector5.loggedInUser,
|
|
547
|
-
isLoggedIn = _useAppSelector5.isLoggedIn;
|
|
301
|
+
const useCurrentUser = () => {
|
|
302
|
+
const { loggedInUser, isLoggedIn } = useAppSelector((state) => state.auth);
|
|
548
303
|
return {
|
|
549
304
|
user: loggedInUser,
|
|
550
|
-
isLoggedIn
|
|
551
|
-
hasRole:
|
|
305
|
+
isLoggedIn,
|
|
306
|
+
hasRole: (role) => {
|
|
552
307
|
if (!loggedInUser || !loggedInUser.roles) return false;
|
|
553
308
|
return loggedInUser.roles.includes(role);
|
|
554
309
|
},
|
|
555
|
-
hasAnyRole:
|
|
310
|
+
hasAnyRole: (roles) => {
|
|
556
311
|
if (!loggedInUser || !loggedInUser.roles) return false;
|
|
557
|
-
return roles.some(
|
|
558
|
-
return loggedInUser.roles.includes(role);
|
|
559
|
-
});
|
|
312
|
+
return roles.some((role) => loggedInUser.roles.includes(role));
|
|
560
313
|
},
|
|
561
|
-
hasAllRoles:
|
|
314
|
+
hasAllRoles: (roles) => {
|
|
562
315
|
if (!loggedInUser || !loggedInUser.roles) return false;
|
|
563
|
-
return roles.every(
|
|
564
|
-
return loggedInUser.roles.includes(role);
|
|
565
|
-
});
|
|
316
|
+
return roles.every((role) => loggedInUser.roles.includes(role));
|
|
566
317
|
}
|
|
567
318
|
};
|
|
568
|
-
};
|
|
319
|
+
};
|
|
320
|
+
export {
|
|
321
|
+
checkAccessSync,
|
|
322
|
+
useAccess,
|
|
323
|
+
useAuth,
|
|
324
|
+
useCurrentUser,
|
|
325
|
+
useLogin,
|
|
326
|
+
useLogout,
|
|
327
|
+
usePageAccess,
|
|
328
|
+
useWidgetAccess
|
|
329
|
+
};
|