@wavemaker/react-runtime 11.14.1-16.6404
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/actions/base-action.js +32 -0
- package/actions/login-action.js +53 -0
- package/actions/logout-action.js +41 -0
- package/actions/navigation-action.js +145 -0
- package/actions/notification-action.js +147 -0
- package/actions/timer-action.js +164 -0
- package/actions/toast-provider.js +111 -0
- package/actions/toast.js +115 -0
- package/actions/toast.service.js +94 -0
- package/actions/types/index.js +11 -0
- package/components/advanced/carousel/index.js +456 -0
- package/components/advanced/carousel/props.js +5 -0
- package/components/advanced/carousel/template.js +72 -0
- package/components/advanced/login/index.js +307 -0
- package/components/advanced/login/props.js +5 -0
- package/components/advanced/marquee/index.js +158 -0
- package/components/advanced/marquee/props.js +5 -0
- package/components/basic/anchor/index.js +239 -0
- package/components/basic/anchor/props.js +5 -0
- package/components/basic/audio/index.js +61 -0
- package/components/basic/html/index.js +158 -0
- package/components/basic/icon/index.js +85 -0
- package/components/basic/iframe/iframe.utils.js +10 -0
- package/components/basic/iframe/index.js +95 -0
- package/components/basic/label/index.js +139 -0
- package/components/basic/message/index.js +120 -0
- package/components/basic/message/props.js +5 -0
- package/components/basic/picture/index.js +117 -0
- package/components/basic/picture/props.js +5 -0
- package/components/basic/progress-bar/index.js +168 -0
- package/components/basic/progress-bar/props.js +18 -0
- package/components/basic/progress-circle/index.js +196 -0
- package/components/basic/progress-circle/props.js +16 -0
- package/components/basic/richtexteditor/index.js +533 -0
- package/components/basic/richtexteditor/props.js +5 -0
- package/components/basic/search/index.js +1023 -0
- package/components/basic/search/props.js +5 -0
- package/components/basic/search/providers.js +350 -0
- package/components/basic/spinner/index.js +202 -0
- package/components/basic/spinner/props.js +12 -0
- package/components/basic/tile/index.js +91 -0
- package/components/basic/tree/Components/TreeNodeComponent.js +142 -0
- package/components/basic/tree/index.js +503 -0
- package/components/basic/tree/props.js +5 -0
- package/components/basic/tree/utils.js +154 -0
- package/components/basic/video/index.js +85 -0
- package/components/basic/video/props.js +5 -0
- package/components/chart/components/barColumnChart/index.js +132 -0
- package/components/chart/components/barColumnChart/props.js +5 -0
- package/components/chart/components/bubbleChart/index.js +176 -0
- package/components/chart/components/bubbleChart/props.js +5 -0
- package/components/chart/components/chartLegend/components/ClassicLegendItem.js +39 -0
- package/components/chart/components/chartLegend/components/FuriousLegendItem.js +81 -0
- package/components/chart/components/chartLegend/index.js +69 -0
- package/components/chart/components/chartLegend/props.js +5 -0
- package/components/chart/components/chartLegend/utils.js +31 -0
- package/components/chart/components/chartTooltip/index.js +53 -0
- package/components/chart/components/chartTooltip/styles.js +37 -0
- package/components/chart/components/chartTooltip/utils.js +23 -0
- package/components/chart/components/cumulativeLineChart/index.js +113 -0
- package/components/chart/components/cumulativeLineChart/props.js +5 -0
- package/components/chart/components/cumulativeLineChart/utils.js +34 -0
- package/components/chart/components/index.js +40 -0
- package/components/chart/components/lineAreaChart/index.js +140 -0
- package/components/chart/components/lineAreaChart/props.js +5 -0
- package/components/chart/components/noDataMessage/index.js +27 -0
- package/components/chart/components/pieDonutChart/index.js +171 -0
- package/components/chart/components/pieDonutChart/props.js +5 -0
- package/components/chart/constant.js +72 -0
- package/components/chart/index.js +930 -0
- package/components/chart/props.js +5 -0
- package/components/chart/utils.js +691 -0
- package/components/common/AppSpinner.js +36 -0
- package/components/common/app-spinner.js +26 -0
- package/components/common/index.js +12 -0
- package/components/constants.js +1208 -0
- package/components/container/accordion/accordion-pane/index.js +108 -0
- package/components/container/accordion/accordion-pane/props.js +11 -0
- package/components/container/accordion/index.js +232 -0
- package/components/container/accordion/props.js +13 -0
- package/components/container/alignment-utils.js +183 -0
- package/components/container/index.js +188 -0
- package/components/container/layout-grid/grid-column/index.js +34 -0
- package/components/container/layout-grid/grid-row/index.js +24 -0
- package/components/container/layout-grid/index.js +33 -0
- package/components/container/linear-layout/index.js +72 -0
- package/components/container/linear-layout/linear-layout-item/index.js +43 -0
- package/components/container/panel/components/panel-header/index.js +144 -0
- package/components/container/panel/components/panel-header/props.js +5 -0
- package/components/container/panel/hooks.js +144 -0
- package/components/container/panel/index.js +286 -0
- package/components/container/panel/props.js +5 -0
- package/components/container/props.js +5 -0
- package/components/container/tabs/index.js +379 -0
- package/components/container/tabs/props.js +20 -0
- package/components/container/tabs/tab-pane/index.js +42 -0
- package/components/container/tabs/tab-pane/props.js +5 -0
- package/components/container/wizard/WizardContext.js +16 -0
- package/components/container/wizard/components/StepComponents.js +100 -0
- package/components/container/wizard/components/WizardStep.js +89 -0
- package/components/container/wizard/index.js +710 -0
- package/components/container/wizard/props.js +5 -0
- package/components/container/wizard/utils.js +133 -0
- package/components/container/wizard/wizard-action/index.js +22 -0
- package/components/container/wizard/wizard-step/index.js +94 -0
- package/components/data/card/card-actions/index.js +24 -0
- package/components/data/card/card-content/index.js +38 -0
- package/components/data/card/card-footer/index.js +24 -0
- package/components/data/card/index.js +246 -0
- package/components/data/card/props.js +5 -0
- package/components/data/form/base-form/constant.js +39 -0
- package/components/data/form/base-form/index.js +460 -0
- package/components/data/form/base-form/props.js +29 -0
- package/components/data/form/base-form/utils.js +42 -0
- package/components/data/form/dynamic-fields/index.js +196 -0
- package/components/data/form/dynamic-fields/props.js +5 -0
- package/components/data/form/dynamic-fields/utils.js +237 -0
- package/components/data/form/form-action/index.js +71 -0
- package/components/data/form/form-body/index.js +26 -0
- package/components/data/form/form-context.js +34 -0
- package/components/data/form/form-controller/props.js +19 -0
- package/components/data/form/form-controller/validation-contrustor.js +313 -0
- package/components/data/form/form-controller/withFormController.js +320 -0
- package/components/data/form/form-field/base-field.js +138 -0
- package/components/data/form/form-field/index.js +36 -0
- package/components/data/form/form-field/props.js +5 -0
- package/components/data/form/form-footer/index.js +26 -0
- package/components/data/form/form-header/index.js +56 -0
- package/components/data/form/index.js +39 -0
- package/components/data/form/props.js +5 -0
- package/components/data/list/components/GroupHeader.js +35 -0
- package/components/data/list/components/GroupedListItems.js +98 -0
- package/components/data/list/components/ListContainer.js +27 -0
- package/components/data/list/components/ListDND.js +241 -0
- package/components/data/list/components/ListHeader.js +59 -0
- package/components/data/list/components/ListItem.js +148 -0
- package/components/data/list/components/ListItemWithTemplate.js +59 -0
- package/components/data/list/components/ListItems.js +231 -0
- package/components/data/list/components/ListPagination.js +165 -0
- package/components/data/list/components/LoadMoreButton.js +39 -0
- package/components/data/list/components/NoDataMessage.js +22 -0
- package/components/data/list/components/StandardListItems.js +84 -0
- package/components/data/list/components/index.js +119 -0
- package/components/data/list/components/props.js +5 -0
- package/components/data/list/hooks/index.js +75 -0
- package/components/data/list/hooks/props.js +5 -0
- package/components/data/list/hooks/useCurrentPageItems.js +48 -0
- package/components/data/list/hooks/useGroupedData.js +37 -0
- package/components/data/list/hooks/useListData.js +60 -0
- package/components/data/list/hooks/useListEffects.js +285 -0
- package/components/data/list/hooks/useListEventHandlers.js +291 -0
- package/components/data/list/hooks/useListPagination.js +168 -0
- package/components/data/list/hooks/useListState.js +98 -0
- package/components/data/list/hooks/useListStateManager.js +195 -0
- package/components/data/list/hooks/usePaginatedGroupedData.js +121 -0
- package/components/data/list/index.js +611 -0
- package/components/data/list/props.js +5 -0
- package/components/data/list/templates/media-template.js +53 -0
- package/components/data/list/utils/constants.js +81 -0
- package/components/data/list/utils/list-helpers.js +173 -0
- package/components/data/list/utils/list-widget-methods.js +114 -0
- package/components/data/live-filter/index.js +279 -0
- package/components/data/live-filter/props.js +12 -0
- package/components/data/live-form/index.js +93 -0
- package/components/data/live-form/props.js +16 -0
- package/components/data/pagination/components/BasicPagination.js +77 -0
- package/components/data/pagination/components/ClassicPagination.js +191 -0
- package/components/data/pagination/components/InlinePagination.js +99 -0
- package/components/data/pagination/components/LoadingComponent.js +31 -0
- package/components/data/pagination/components/PageSizeSelector.js +175 -0
- package/components/data/pagination/components/PagerNavigation.js +105 -0
- package/components/data/pagination/components/TotalRecords.js +52 -0
- package/components/data/pagination/components/index.js +47 -0
- package/components/data/pagination/components/props.js +5 -0
- package/components/data/pagination/hooks/index.js +19 -0
- package/components/data/pagination/hooks/props.js +5 -0
- package/components/data/pagination/hooks/useNavigationSize.js +44 -0
- package/components/data/pagination/hooks/usePagination.js +796 -0
- package/components/data/pagination/index.js +322 -0
- package/components/data/table/components/AddNewRow.js +190 -0
- package/components/data/table/components/EditableCell.js +91 -0
- package/components/data/table/components/FieldValidationError.js +24 -0
- package/components/data/table/components/RowExpansionButton.js +74 -0
- package/components/data/table/components/TableBody.js +279 -0
- package/components/data/table/components/TableFilters.js +325 -0
- package/components/data/table/components/TableFooterActions.js +48 -0
- package/components/data/table/components/TableHeader.js +174 -0
- package/components/data/table/components/TablePanelHeading.js +68 -0
- package/components/data/table/components/index.js +74 -0
- package/components/data/table/hooks/index.js +219 -0
- package/components/data/table/hooks/useCellState.js +117 -0
- package/components/data/table/hooks/useDynamicColumns.js +85 -0
- package/components/data/table/hooks/useEditingState.js +47 -0
- package/components/data/table/hooks/useFormWidget.js +184 -0
- package/components/data/table/hooks/usePaginationState.js +60 -0
- package/components/data/table/hooks/usePanelStructure.js +40 -0
- package/components/data/table/hooks/useResponsiveColumns.js +34 -0
- package/components/data/table/hooks/useRowExpansion.js +110 -0
- package/components/data/table/hooks/useRowHandlers.js +38 -0
- package/components/data/table/hooks/useRowSelection.js +213 -0
- package/components/data/table/hooks/useServerSideSorting.js +165 -0
- package/components/data/table/hooks/useTableColumns.js +263 -0
- package/components/data/table/hooks/useTableData.js +154 -0
- package/components/data/table/hooks/useTableEdit.js +467 -0
- package/components/data/table/hooks/useTableEffects.js +139 -0
- package/components/data/table/hooks/useTableFilter.js +389 -0
- package/components/data/table/hooks/useTableInitialization.js +103 -0
- package/components/data/table/hooks/useTableState.js +69 -0
- package/components/data/table/hooks/useTableStateManager.js +558 -0
- package/components/data/table/index.js +1295 -0
- package/components/data/table/live-table/index.js +232 -0
- package/components/data/table/props.js +5 -0
- package/components/data/table/table-action/index.js +78 -0
- package/components/data/table/table-column/index.js +35 -0
- package/components/data/table/table-row/index.js +49 -0
- package/components/data/table/table-row-action/index.js +74 -0
- package/components/data/table/utils/buildSelectionColumns.js +173 -0
- package/components/data/table/utils/columnBuilder.js +209 -0
- package/components/data/table/utils/columnProxy.js +48 -0
- package/components/data/table/utils/columnWidthDistribution.js +98 -0
- package/components/data/table/utils/constants.js +80 -0
- package/components/data/table/utils/crud-handlers.js +518 -0
- package/components/data/table/utils/dynamic-columns.js +118 -0
- package/components/data/table/utils/index.js +607 -0
- package/components/data/table/utils/renderDisplayCell.js +183 -0
- package/components/data/table/utils/selectionUtils.js +166 -0
- package/components/data/table/utils/table-helpers.js +100 -0
- package/components/data/table/utils/validation.js +124 -0
- package/components/data/types.js +113 -0
- package/components/data/utils/field-data-utils.js +66 -0
- package/components/data/utils/filter-field-util.js +81 -0
- package/components/data/utils/index.js +216 -0
- package/components/dialogs/alert-dialog/index.js +80 -0
- package/components/dialogs/confirm-dialog/index.js +105 -0
- package/components/dialogs/dialog/index.js +56 -0
- package/components/dialogs/dialog-actions/index.js +18 -0
- package/components/dialogs/dialog-body/index.js +21 -0
- package/components/dialogs/dialog-content/index.js +30 -0
- package/components/dialogs/dialog-header/index.js +93 -0
- package/components/dialogs/iframe-dialog/index.js +114 -0
- package/components/dialogs/index.js +129 -0
- package/components/dialogs/login-dialog/index.js +369 -0
- package/components/dialogs/login-dialog/props.js +5 -0
- package/components/dialogs/page-dialog/index.js +96 -0
- package/components/dialogs/withDialogWrapper.js +108 -0
- package/components/form/button/index.js +216 -0
- package/components/form/button-group/index.js +60 -0
- package/components/input/calendar/index.js +546 -0
- package/components/input/calendar/props.js +5 -0
- package/components/input/calendar/utils.js +340 -0
- package/components/input/chips/SortableChip/index.js +115 -0
- package/components/input/chips/SortableChip/props.js +5 -0
- package/components/input/chips/index.js +488 -0
- package/components/input/chips/props.js +5 -0
- package/components/input/chips/utils.js +259 -0
- package/components/input/color-picker/index.js +678 -0
- package/components/input/color-picker/props.js +5 -0
- package/components/input/composite/index.js +137 -0
- package/components/input/currency/index.js +263 -0
- package/components/input/currency/props.js +5 -0
- package/components/input/default/checkbox/index.js +230 -0
- package/components/input/default/checkbox/props.js +5 -0
- package/components/input/default/checkboxset/index.js +476 -0
- package/components/input/default/checkboxset/props.js +5 -0
- package/components/input/default/radioset/index.js +379 -0
- package/components/input/default/radioset/props.js +5 -0
- package/components/input/default/switch/index.js +490 -0
- package/components/input/default/switch/prop.js +5 -0
- package/components/input/epoch/date/components/DatePickerPopover.js +220 -0
- package/components/input/epoch/date/index.js +520 -0
- package/components/input/epoch/date/props.js +5 -0
- package/components/input/epoch/date/styled.js +70 -0
- package/components/input/epoch/date/utils.js +108 -0
- package/components/input/epoch/datetime/index.js +656 -0
- package/components/input/epoch/datetime/props.js +5 -0
- package/components/input/epoch/datetime/styled.js +90 -0
- package/components/input/epoch/datetime/utils.js +244 -0
- package/components/input/epoch/time/index.js +412 -0
- package/components/input/epoch/time/props.js +5 -0
- package/components/input/epoch/time/utils.js +209 -0
- package/components/input/fileupload/Utils.js +134 -0
- package/components/input/fileupload/components/ListItems.js +140 -0
- package/components/input/fileupload/components/MultiUpload.js +85 -0
- package/components/input/fileupload/components/SingleUpload.js +65 -0
- package/components/input/fileupload/index.js +170 -0
- package/components/input/fileupload/props.js +5 -0
- package/components/input/fileupload/useFileUpload.js +400 -0
- package/components/input/number/index.js +295 -0
- package/components/input/number/props.js +5 -0
- package/components/input/rating/index.js +368 -0
- package/components/input/rating/props.js +5 -0
- package/components/input/select/index.js +344 -0
- package/components/input/select/props.js +5 -0
- package/components/input/slider/index.js +167 -0
- package/components/input/slider/props.js +5 -0
- package/components/input/text/index.js +434 -0
- package/components/input/text/props.js +5 -0
- package/components/input/text/util.js +179 -0
- package/components/input/textarea/index.js +347 -0
- package/components/input/textarea/props.js +5 -0
- package/components/layout/footer/index.js +30 -0
- package/components/layout/header/index.js +30 -0
- package/components/layout/leftnav/index.js +44 -0
- package/components/layout/rightnav/index.js +32 -0
- package/components/layout/topnav/index.js +34 -0
- package/components/navbar/index.js +41 -0
- package/components/navbar/nav/index.js +102 -0
- package/components/navbar/nav/props.js +5 -0
- package/components/navbar/nav-item/index.js +44 -0
- package/components/navigation/breadcrumb/index.js +56 -0
- package/components/navigation/breadcrumb/props.js +5 -0
- package/components/navigation/menu/components/ListItems.js +66 -0
- package/components/navigation/menu/constants.js +101 -0
- package/components/navigation/menu/index.js +807 -0
- package/components/navigation/menu/props.js +5 -0
- package/components/navigation/popover/index.js +209 -0
- package/components/navigation/popover/props.js +15 -0
- package/components/page/content/index.js +28 -0
- package/components/page/error-boundary/index.js +108 -0
- package/components/page/index.js +137 -0
- package/components/page/page-content/index.js +23 -0
- package/components/page/partial/index.js +36 -0
- package/components/page/partial-container/index.js +48 -0
- package/components/page/props.js +5 -0
- package/components/page/toast-container/index.js +33 -0
- package/components/prefab/container/index.js +46 -0
- package/components/prefab/index.js +67 -0
- package/context/AppContext.js +25 -0
- package/context/AppSpinnerProvider.js +43 -0
- package/context/LocalizationProvider.js +79 -0
- package/context/PrefabContext.js +66 -0
- package/context/WidgetProvider.js +187 -0
- package/core/app-config.js +1 -0
- package/core/app.service.js +357 -0
- package/core/appVariablesStore.js +20 -0
- package/core/appstore.js +88 -0
- package/core/constants/currency-constant.js +1071 -0
- package/core/constants/events.js +34 -0
- package/core/constants/index.js +27 -0
- package/core/dialog.service.js +76 -0
- package/core/event-notifier.js +151 -0
- package/core/formatter/date-formatters.js +222 -0
- package/core/formatter/index.js +131 -0
- package/core/formatter/number-formatters.js +142 -0
- package/core/formatter/security-formatters.js +323 -0
- package/core/formatter/string-formatters.js +52 -0
- package/core/formatter/types.js +18 -0
- package/core/formatters.js +24 -0
- package/core/proxy-service.js +412 -0
- package/core/script-registry.js +63 -0
- package/core/security.service.js +11 -0
- package/core/util/common.js +33 -0
- package/core/util/dom.js +107 -0
- package/core/util/index.js +136 -0
- package/core/util/security.js +184 -0
- package/core/util/utils.js +189 -0
- package/core/widget-observer.js +98 -0
- package/higherOrder/BaseApp.js +430 -0
- package/higherOrder/BaseAppProps.js +5 -0
- package/higherOrder/BaseDateTime.js +251 -0
- package/higherOrder/BasePage.js +715 -0
- package/higherOrder/BasePartial.js +124 -0
- package/higherOrder/BasePrefab.js +145 -0
- package/higherOrder/DataNav.js +377 -0
- package/higherOrder/helper.js +43 -0
- package/higherOrder/props.js +5 -0
- package/higherOrder/withBaseWrapper.js +183 -0
- package/hooks/useAccess.js +308 -0
- package/hooks/useAppConfig.js +42 -0
- package/hooks/useAuth.js +562 -0
- package/hooks/useDataSourceSubscription.js +125 -0
- package/hooks/useDebounce.js +76 -0
- package/hooks/useDeviceVisibility.js +49 -0
- package/hooks/useHttp.js +338 -0
- package/libs/index.js +20 -0
- package/mui-config/theme-provider.js +17 -0
- package/mui-config/theme.js +371 -0
- package/package-lock.json +10177 -0
- package/package.json +95 -0
- package/store/index.js +33 -0
- package/store/middleware/navigationMiddleware.js +48 -0
- package/store/slices/appConfigSlice.js +103 -0
- package/store/slices/authSlice.js +508 -0
- package/store/slices/i18nSlice.js +206 -0
- package/types/index.js +15 -0
- package/utils/dataset-util.js +174 -0
- package/utils/eval-expression.js +32 -0
- package/utils/form-state.util.js +140 -0
- package/utils/form-utils.js +187 -0
- package/utils/format-util.js +260 -0
- package/utils/page-params-util.js +24 -0
- package/utils/resource-url.js +27 -0
- package/utils/state-persistance.js +343 -0
- package/utils/style-utils.js +73 -0
- package/utils/transformedDataset-utils.js +633 -0
- package/utils/widget-cleanup-util.js +84 -0
- package/utils/widgets.js +99 -0
- package/variables/base-variable.js +173 -0
- package/variables/constants.js +27 -0
- package/variables/live-variable.js +166 -0
- package/variables/model-variable.js +77 -0
- package/variables/service-variable.js +307 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.BaseAppInitialState = void 0;
|
|
8
|
+
exports.importModule = importModule;
|
|
9
|
+
exports.mergeVariablesAndActions = void 0;
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _appstore = _interopRequireDefault(require("../core/appstore"));
|
|
12
|
+
var _util = require("../core/util");
|
|
13
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
14
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
+
var mergeVariablesAndActions = exports.mergeVariablesAndActions = function mergeVariablesAndActions(pageVariables) {
|
|
17
|
+
var appVars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
18
|
+
Variables: {},
|
|
19
|
+
Actions: {}
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
Variables: _objectSpread(_objectSpread({}, appVars.Variables), pageVariables.Variables),
|
|
23
|
+
Actions: _objectSpread(_objectSpread({}, appVars.Actions), pageVariables.Actions)
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
var BaseAppInitialState = exports.BaseAppInitialState = {
|
|
27
|
+
activePageName: "",
|
|
28
|
+
lastActivePage: "",
|
|
29
|
+
Variables: {},
|
|
30
|
+
Actions: {},
|
|
31
|
+
isAppReady: false,
|
|
32
|
+
getDependency: _appstore["default"].getDependency,
|
|
33
|
+
getCurrentMonth: _util.getCurrentMonth,
|
|
34
|
+
notification: null,
|
|
35
|
+
Common: {},
|
|
36
|
+
onPageReady: function onPageReady() {},
|
|
37
|
+
reload: _util.reload
|
|
38
|
+
};
|
|
39
|
+
function importModule(moduleName) {
|
|
40
|
+
if (moduleName === "moment") {
|
|
41
|
+
return _momentTimezone["default"];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.withBaseWrapper = exports["default"] = void 0;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
var _isEqual = _interopRequireDefault(require("lodash-es/isEqual"));
|
|
16
|
+
var _useDeviceVisibility2 = require("@wavemaker/react-runtime/hooks/useDeviceVisibility");
|
|
17
|
+
var _WidgetProvider = require("@wavemaker/react-runtime/context/WidgetProvider");
|
|
18
|
+
var _styleUtils = require("@wavemaker/react-runtime/utils/style-utils");
|
|
19
|
+
var _scriptRegistry = require("@wavemaker/react-runtime/core/script-registry");
|
|
20
|
+
var _excluded = ["show", "name", "deferload"];
|
|
21
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
22
|
+
var __jsx = _react["default"].createElement;
|
|
23
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
24
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
25
|
+
var withBaseWrapper = exports.withBaseWrapper = function withBaseWrapper(WrappedComponent) {
|
|
26
|
+
var WithBaseComponent = function WithBaseComponent(props) {
|
|
27
|
+
var _pageContext$Widgets, _mergedProps$show, _mergedProps$show2;
|
|
28
|
+
var _props$show = props.show,
|
|
29
|
+
show = _props$show === void 0 ? true : _props$show,
|
|
30
|
+
name = props.name,
|
|
31
|
+
_props$deferload = props.deferload,
|
|
32
|
+
deferload = _props$deferload === void 0 ? true : _props$deferload,
|
|
33
|
+
rest = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
34
|
+
|
|
35
|
+
// All hooks must be called before any early returns
|
|
36
|
+
var _useDeviceVisibility = (0, _useDeviceVisibility2.useDeviceVisibility)(props.showindevices || ["all"]),
|
|
37
|
+
isHidden = _useDeviceVisibility.isHidden;
|
|
38
|
+
var _usePageContext = (0, _WidgetProvider.usePageContext)(),
|
|
39
|
+
pageContext = _usePageContext.pageContext,
|
|
40
|
+
updateWidgetState = _usePageContext.updateWidgetState,
|
|
41
|
+
cleanup = _usePageContext.cleanup;
|
|
42
|
+
|
|
43
|
+
// Extract widget-id from component props
|
|
44
|
+
var componentWidgetId = (0, _react.useMemo)(function () {
|
|
45
|
+
return props === null || props === void 0 ? void 0 : props["data-widget-id"];
|
|
46
|
+
}, [props === null || props === void 0 ? void 0 : props["data-widget-id"]]);
|
|
47
|
+
var widgetFromContext = name ? pageContext === null || pageContext === void 0 || (_pageContext$Widgets = pageContext.Widgets) === null || _pageContext$Widgets === void 0 ? void 0 : _pageContext$Widgets[name] : undefined;
|
|
48
|
+
|
|
49
|
+
// Register widget in context (last wins - second component should win)
|
|
50
|
+
(0, _react.useEffect)(function () {
|
|
51
|
+
if (name && (props === null || props === void 0 ? void 0 : props.iswidget) !== "false" && pageContext !== null && pageContext !== void 0 && pageContext.Widgets) {
|
|
52
|
+
// Create registry entry with widget-id
|
|
53
|
+
var registryEntry = _objectSpread(_objectSpread({}, props), {}, {
|
|
54
|
+
"data-widget-id": componentWidgetId || undefined // Ensure widget-id is stored
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Last component with same name overwrites previous (LAST WINS)
|
|
58
|
+
pageContext.Widgets[name] = registryEntry;
|
|
59
|
+
}
|
|
60
|
+
}, [name, pageContext === null || pageContext === void 0 ? void 0 : pageContext.Widgets, componentWidgetId, props]);
|
|
61
|
+
|
|
62
|
+
// Compute merged props in a memoized way
|
|
63
|
+
var mergedProps = (0, _react.useMemo)(function () {
|
|
64
|
+
var _widget$datavalue;
|
|
65
|
+
if (!name || !(pageContext !== null && pageContext !== void 0 && pageContext.Widgets) || (props === null || props === void 0 ? void 0 : props.iswidget) === "false") {
|
|
66
|
+
return props;
|
|
67
|
+
}
|
|
68
|
+
var widget = widgetFromContext || {};
|
|
69
|
+
|
|
70
|
+
// Extract widget-id from context widget
|
|
71
|
+
var contextWidgetId = widget === null || widget === void 0 ? void 0 : widget["data-widget-id"];
|
|
72
|
+
|
|
73
|
+
// FIRST WINS: Only merge if this component's widget-id matches the context
|
|
74
|
+
// OR if no widget-id filtering is needed (backward compatibility)
|
|
75
|
+
var shouldMergeFromContext = !componentWidgetId || !contextWidgetId || componentWidgetId === contextWidgetId;
|
|
76
|
+
var mergedState = _objectSpread({}, props);
|
|
77
|
+
var datavalue = (_widget$datavalue = widget.datavalue) !== null && _widget$datavalue !== void 0 ? _widget$datavalue : props.datavalue;
|
|
78
|
+
if (shouldMergeFromContext && (0, _scriptRegistry.isWidgetOverridden)(name, componentWidgetId)) {
|
|
79
|
+
// Apply widget-id specific overridden properties from the registry
|
|
80
|
+
var widgetOverrides = (0, _scriptRegistry.getWidgetOverrides)(name, componentWidgetId);
|
|
81
|
+
Object.keys(widgetOverrides).forEach(function (key) {
|
|
82
|
+
mergedState[key] = widgetOverrides[key];
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Then handle other widget properties that are not overridden
|
|
86
|
+
Object.keys(widget).forEach(function (key) {
|
|
87
|
+
if (!(0, _scriptRegistry.isPropOverridden)(name, key, componentWidgetId)) {
|
|
88
|
+
mergedState[key] = props[key];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
} else if (shouldMergeFromContext) {
|
|
92
|
+
// For regular widgets (no widget-id or matching widget-id), merge with component props taking precedence
|
|
93
|
+
mergedState = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, widget), props), WrappedComponent.displayName === "WmFormField" && !props.value ? {
|
|
94
|
+
value: datavalue
|
|
95
|
+
} : {}), {}, {
|
|
96
|
+
datavalue: datavalue
|
|
97
|
+
});
|
|
98
|
+
} else {
|
|
99
|
+
// Widget-id mismatch: component stays independent with only its own props
|
|
100
|
+
mergedState = _objectSpread(_objectSpread(_objectSpread({}, props), WrappedComponent.displayName === "WmFormField" && !props.value ? {
|
|
101
|
+
value: datavalue
|
|
102
|
+
} : {}), {}, {
|
|
103
|
+
datavalue: datavalue
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return mergedState;
|
|
107
|
+
}, [props, widgetFromContext, componentWidgetId]);
|
|
108
|
+
var syncWithContext = (0, _react.useCallback)(function () {
|
|
109
|
+
if (name && pageContext !== null && pageContext !== void 0 && pageContext.Widgets && (props === null || props === void 0 ? void 0 : props.iswidget) !== "false" && !(props !== null && props !== void 0 && props.formfield)) {
|
|
110
|
+
var currentWidgetState = pageContext.Widgets[name] || {};
|
|
111
|
+
|
|
112
|
+
// Extract widget-id from context
|
|
113
|
+
var contextWidgetId = currentWidgetState === null || currentWidgetState === void 0 ? void 0 : currentWidgetState["data-widget-id"];
|
|
114
|
+
|
|
115
|
+
// Only sync if widget-ids match OR no widget-id filtering needed
|
|
116
|
+
var shouldSync = !componentWidgetId || !contextWidgetId || componentWidgetId === contextWidgetId;
|
|
117
|
+
if (shouldSync) {
|
|
118
|
+
// Skip comparing listener property
|
|
119
|
+
var stateForComparison = _objectSpread({}, currentWidgetState);
|
|
120
|
+
var propsForComparison = _objectSpread({}, mergedProps);
|
|
121
|
+
delete stateForComparison.listener;
|
|
122
|
+
delete propsForComparison.listener;
|
|
123
|
+
if (!(0, _isEqual["default"])(stateForComparison, propsForComparison)) {
|
|
124
|
+
updateWidgetState(name, mergedProps);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}, [pageContext === null || pageContext === void 0 ? void 0 : pageContext.Widgets, mergedProps, props, componentWidgetId]);
|
|
129
|
+
(0, _react.useEffect)(function () {
|
|
130
|
+
syncWithContext();
|
|
131
|
+
}, [syncWithContext]);
|
|
132
|
+
var computedStyles = (0, _react.useMemo)(function () {
|
|
133
|
+
// Ensure conditionalstyle is a valid CSS object or undefined
|
|
134
|
+
var conditionalStyleObj = (0, _typeof2["default"])(props.conditionalstyle) === "object" && props.conditionalstyle !== null ? (0, _styleUtils.sanitizeStyleObject)(props.conditionalstyle) : {};
|
|
135
|
+
var baseStyles = (0, _styleUtils.sanitizeStyleObject)(props.styles);
|
|
136
|
+
return _objectSpread(_objectSpread({}, baseStyles), conditionalStyleObj);
|
|
137
|
+
}, [props.styles, props.conditionalstyle]);
|
|
138
|
+
var computedClassName = (0, _react.useMemo)(function () {
|
|
139
|
+
return [props.className, props.conditionalclass, props.animation && "animated ".concat(props.animation)].filter(Boolean).join(" ");
|
|
140
|
+
}, [props.className, props.conditionalclass, props.animation]);
|
|
141
|
+
|
|
142
|
+
// Early returns after all hooks
|
|
143
|
+
if (isHidden) return null;
|
|
144
|
+
|
|
145
|
+
// Optimized deferload and show logic
|
|
146
|
+
var isDeferLoad = deferload === true;
|
|
147
|
+
var showValue = (mergedProps === null || mergedProps === void 0 || (_mergedProps$show = mergedProps.show) === null || _mergedProps$show === void 0 ? void 0 : _mergedProps$show.toString()) !== "false";
|
|
148
|
+
|
|
149
|
+
// Implement exact logic from requirements:
|
|
150
|
+
// show = false, deferload = undefined/false → render initial, not UI (hidden=true)
|
|
151
|
+
// show = false, deferload = true → don't render at all
|
|
152
|
+
// show = true, deferload = true → render in both
|
|
153
|
+
// show = true, deferload = false/undefined → render in UI
|
|
154
|
+
|
|
155
|
+
if (!showValue && isDeferLoad) {
|
|
156
|
+
// Case: show = false, deferload = true → don't render at all
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Case: show = false, deferload = false/undefined → render with hidden=true
|
|
161
|
+
var shouldHide = !showValue && !isDeferLoad;
|
|
162
|
+
var updateon = (props === null || props === void 0 ? void 0 : props.updateon) === "default" ? "keypress" : props === null || props === void 0 ? void 0 : props.updateon;
|
|
163
|
+
return __jsx(WrappedComponent, (0, _extends2["default"])({}, rest, mergedProps, updateon && {
|
|
164
|
+
updateon: updateon
|
|
165
|
+
}, shouldHide && {
|
|
166
|
+
hidden: true
|
|
167
|
+
}, deferload !== undefined && {
|
|
168
|
+
deferload: deferload.toString()
|
|
169
|
+
}, {
|
|
170
|
+
show: mergedProps === null || mergedProps === void 0 || (_mergedProps$show2 = mergedProps.show) === null || _mergedProps$show2 === void 0 ? void 0 : _mergedProps$show2.toString(),
|
|
171
|
+
name: name,
|
|
172
|
+
className: computedClassName,
|
|
173
|
+
styles: computedStyles
|
|
174
|
+
}, (props === null || props === void 0 ? void 0 : props.dataset) && {
|
|
175
|
+
dataset: props === null || props === void 0 ? void 0 : props.dataset
|
|
176
|
+
}));
|
|
177
|
+
};
|
|
178
|
+
WithBaseComponent.displayName = "WithBase(".concat(WrappedComponent.displayName || WrappedComponent.name || "Component", ")");
|
|
179
|
+
return /*#__PURE__*/_react["default"].memo(WithBaseComponent, function (prevProps, nextProps) {
|
|
180
|
+
return prevProps === nextProps;
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
var _default = exports["default"] = withBaseWrapper;
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useAccess = exports.preloadAccess = exports["default"] = exports.clearAccessCache = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _store = require("@wavemaker/react-runtime/store");
|
|
12
|
+
var _authSlice = require("../store/slices/authSlice");
|
|
13
|
+
// Global cache for access results to prevent duplicate checks
|
|
14
|
+
var accessCache = new Map();
|
|
15
|
+
var pendingChecks = new Map();
|
|
16
|
+
var useAccess = exports.useAccess = function useAccess(options) {
|
|
17
|
+
var componentName = options.componentName,
|
|
18
|
+
type = options.type,
|
|
19
|
+
_options$enabled = options.enabled,
|
|
20
|
+
enabled = _options$enabled === void 0 ? true : _options$enabled;
|
|
21
|
+
var dispatch = (0, _store.useAppDispatch)();
|
|
22
|
+
|
|
23
|
+
// Get security config from store
|
|
24
|
+
var isSecurityEnabled = (0, _store.useAppSelector)(function (state) {
|
|
25
|
+
var _state$auth$securityC;
|
|
26
|
+
return (_state$auth$securityC = state.auth.securityConfig) === null || _state$auth$securityC === void 0 ? void 0 : _state$auth$securityC.isSecurityEnabled;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Create a unique key for this component
|
|
30
|
+
var cacheKey = "".concat(type, "_").concat(componentName);
|
|
31
|
+
|
|
32
|
+
// Local state for this component
|
|
33
|
+
var _useState = (0, _react.useState)(function () {
|
|
34
|
+
var _cached$hasAccess, _cached$loading, _cached$error;
|
|
35
|
+
// Check if we already have cached result
|
|
36
|
+
var cached = accessCache.get(cacheKey);
|
|
37
|
+
|
|
38
|
+
// If security is disabled, default to access granted
|
|
39
|
+
var defaultAccess = !isSecurityEnabled ? true : false;
|
|
40
|
+
return {
|
|
41
|
+
hasAccess: (_cached$hasAccess = cached === null || cached === void 0 ? void 0 : cached.hasAccess) !== null && _cached$hasAccess !== void 0 ? _cached$hasAccess : defaultAccess,
|
|
42
|
+
loading: (_cached$loading = cached === null || cached === void 0 ? void 0 : cached.loading) !== null && _cached$loading !== void 0 ? _cached$loading : isSecurityEnabled ? true : false,
|
|
43
|
+
error: (_cached$error = cached === null || cached === void 0 ? void 0 : cached.error) !== null && _cached$error !== void 0 ? _cached$error : null
|
|
44
|
+
};
|
|
45
|
+
}),
|
|
46
|
+
localState = _useState[0],
|
|
47
|
+
setLocalState = _useState[1];
|
|
48
|
+
var mountedRef = (0, _react.useRef)(true);
|
|
49
|
+
var hasCheckedRef = (0, _react.useRef)(false);
|
|
50
|
+
|
|
51
|
+
// Memoized access check function
|
|
52
|
+
var checkComponentAccess = (0, _react.useCallback)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
53
|
+
var checkPromise, result;
|
|
54
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
55
|
+
while (1) switch (_context.prev = _context.next) {
|
|
56
|
+
case 0:
|
|
57
|
+
if (isSecurityEnabled) {
|
|
58
|
+
_context.next = 2;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
return _context.abrupt("return", true);
|
|
62
|
+
case 2:
|
|
63
|
+
if (enabled) {
|
|
64
|
+
_context.next = 4;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
return _context.abrupt("return", true);
|
|
68
|
+
case 4:
|
|
69
|
+
if (!pendingChecks.has(cacheKey)) {
|
|
70
|
+
_context.next = 6;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
return _context.abrupt("return", pendingChecks.get(cacheKey));
|
|
74
|
+
case 6:
|
|
75
|
+
// Create new access check promise
|
|
76
|
+
checkPromise = dispatch((0, _authSlice.checkAccess)({
|
|
77
|
+
name: componentName,
|
|
78
|
+
type: type
|
|
79
|
+
})).unwrap(); // Store the pending promise
|
|
80
|
+
pendingChecks.set(cacheKey, checkPromise);
|
|
81
|
+
_context.prev = 8;
|
|
82
|
+
_context.next = 11;
|
|
83
|
+
return checkPromise;
|
|
84
|
+
case 11:
|
|
85
|
+
result = _context.sent;
|
|
86
|
+
return _context.abrupt("return", result);
|
|
87
|
+
case 15:
|
|
88
|
+
_context.prev = 15;
|
|
89
|
+
_context.t0 = _context["catch"](8);
|
|
90
|
+
return _context.abrupt("return", false);
|
|
91
|
+
case 18:
|
|
92
|
+
_context.prev = 18;
|
|
93
|
+
// Remove from pending checks
|
|
94
|
+
pendingChecks["delete"](cacheKey);
|
|
95
|
+
return _context.finish(18);
|
|
96
|
+
case 21:
|
|
97
|
+
case "end":
|
|
98
|
+
return _context.stop();
|
|
99
|
+
}
|
|
100
|
+
}, _callee, null, [[8, 15, 18, 21]]);
|
|
101
|
+
})), [dispatch, componentName, type, isSecurityEnabled, enabled, cacheKey]);
|
|
102
|
+
|
|
103
|
+
// Effect to perform access check
|
|
104
|
+
(0, _react.useEffect)(function () {
|
|
105
|
+
// Don't check if component is unmounted
|
|
106
|
+
if (!mountedRef.current) return;
|
|
107
|
+
|
|
108
|
+
// Don't check multiple times
|
|
109
|
+
if (hasCheckedRef.current) return;
|
|
110
|
+
|
|
111
|
+
// Check if we already have valid cached result
|
|
112
|
+
var cached = accessCache.get(cacheKey);
|
|
113
|
+
if (cached && !cached.loading) {
|
|
114
|
+
setLocalState(cached);
|
|
115
|
+
hasCheckedRef.current = true;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Start access check
|
|
120
|
+
var performCheck = /*#__PURE__*/function () {
|
|
121
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
122
|
+
var loadingState, hasAccess, resultState, errorState;
|
|
123
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
124
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
125
|
+
case 0:
|
|
126
|
+
if (mountedRef.current) {
|
|
127
|
+
_context2.next = 2;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
return _context2.abrupt("return");
|
|
131
|
+
case 2:
|
|
132
|
+
// Update cache and local state to loading
|
|
133
|
+
loadingState = {
|
|
134
|
+
hasAccess: false,
|
|
135
|
+
loading: true,
|
|
136
|
+
error: null
|
|
137
|
+
};
|
|
138
|
+
accessCache.set(cacheKey, loadingState);
|
|
139
|
+
setLocalState(loadingState);
|
|
140
|
+
_context2.prev = 5;
|
|
141
|
+
_context2.next = 8;
|
|
142
|
+
return checkComponentAccess();
|
|
143
|
+
case 8:
|
|
144
|
+
hasAccess = _context2.sent;
|
|
145
|
+
if (mountedRef.current) {
|
|
146
|
+
_context2.next = 11;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
return _context2.abrupt("return");
|
|
150
|
+
case 11:
|
|
151
|
+
// Update cache and local state with result
|
|
152
|
+
resultState = {
|
|
153
|
+
hasAccess: hasAccess,
|
|
154
|
+
loading: false,
|
|
155
|
+
error: null
|
|
156
|
+
};
|
|
157
|
+
accessCache.set(cacheKey, resultState);
|
|
158
|
+
setLocalState(resultState);
|
|
159
|
+
hasCheckedRef.current = true;
|
|
160
|
+
_context2.next = 25;
|
|
161
|
+
break;
|
|
162
|
+
case 17:
|
|
163
|
+
_context2.prev = 17;
|
|
164
|
+
_context2.t0 = _context2["catch"](5);
|
|
165
|
+
if (mountedRef.current) {
|
|
166
|
+
_context2.next = 21;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
return _context2.abrupt("return");
|
|
170
|
+
case 21:
|
|
171
|
+
// Update cache and local state with error
|
|
172
|
+
errorState = {
|
|
173
|
+
hasAccess: false,
|
|
174
|
+
loading: false,
|
|
175
|
+
error: _context2.t0
|
|
176
|
+
};
|
|
177
|
+
accessCache.set(cacheKey, errorState);
|
|
178
|
+
setLocalState(errorState);
|
|
179
|
+
hasCheckedRef.current = true;
|
|
180
|
+
case 25:
|
|
181
|
+
case "end":
|
|
182
|
+
return _context2.stop();
|
|
183
|
+
}
|
|
184
|
+
}, _callee2, null, [[5, 17]]);
|
|
185
|
+
}));
|
|
186
|
+
return function performCheck() {
|
|
187
|
+
return _ref2.apply(this, arguments);
|
|
188
|
+
};
|
|
189
|
+
}();
|
|
190
|
+
performCheck();
|
|
191
|
+
}, [checkComponentAccess, cacheKey]);
|
|
192
|
+
|
|
193
|
+
// Cleanup on unmount
|
|
194
|
+
(0, _react.useEffect)(function () {
|
|
195
|
+
return function () {
|
|
196
|
+
mountedRef.current = false;
|
|
197
|
+
// Optionally clear cache entry on unmount to free memory
|
|
198
|
+
// accessCache.delete(cacheKey);
|
|
199
|
+
// pendingChecks.delete(cacheKey);
|
|
200
|
+
};
|
|
201
|
+
}, [cacheKey]);
|
|
202
|
+
|
|
203
|
+
// Retry function for manual retry
|
|
204
|
+
var retry = (0, _react.useCallback)(function () {
|
|
205
|
+
hasCheckedRef.current = false;
|
|
206
|
+
accessCache["delete"](cacheKey);
|
|
207
|
+
pendingChecks["delete"](cacheKey);
|
|
208
|
+
|
|
209
|
+
// Trigger re-check
|
|
210
|
+
var performCheck = /*#__PURE__*/function () {
|
|
211
|
+
var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
212
|
+
var loadingState, hasAccess, resultState, errorState;
|
|
213
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
214
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
215
|
+
case 0:
|
|
216
|
+
loadingState = {
|
|
217
|
+
hasAccess: false,
|
|
218
|
+
loading: true,
|
|
219
|
+
error: null
|
|
220
|
+
};
|
|
221
|
+
accessCache.set(cacheKey, loadingState);
|
|
222
|
+
setLocalState(loadingState);
|
|
223
|
+
_context3.prev = 3;
|
|
224
|
+
_context3.next = 6;
|
|
225
|
+
return checkComponentAccess();
|
|
226
|
+
case 6:
|
|
227
|
+
hasAccess = _context3.sent;
|
|
228
|
+
resultState = {
|
|
229
|
+
hasAccess: hasAccess,
|
|
230
|
+
loading: false,
|
|
231
|
+
error: null
|
|
232
|
+
};
|
|
233
|
+
accessCache.set(cacheKey, resultState);
|
|
234
|
+
setLocalState(resultState);
|
|
235
|
+
hasCheckedRef.current = true;
|
|
236
|
+
_context3.next = 19;
|
|
237
|
+
break;
|
|
238
|
+
case 13:
|
|
239
|
+
_context3.prev = 13;
|
|
240
|
+
_context3.t0 = _context3["catch"](3);
|
|
241
|
+
errorState = {
|
|
242
|
+
hasAccess: false,
|
|
243
|
+
loading: false,
|
|
244
|
+
error: _context3.t0
|
|
245
|
+
};
|
|
246
|
+
accessCache.set(cacheKey, errorState);
|
|
247
|
+
setLocalState(errorState);
|
|
248
|
+
hasCheckedRef.current = true;
|
|
249
|
+
case 19:
|
|
250
|
+
case "end":
|
|
251
|
+
return _context3.stop();
|
|
252
|
+
}
|
|
253
|
+
}, _callee3, null, [[3, 13]]);
|
|
254
|
+
}));
|
|
255
|
+
return function performCheck() {
|
|
256
|
+
return _ref3.apply(this, arguments);
|
|
257
|
+
};
|
|
258
|
+
}();
|
|
259
|
+
performCheck();
|
|
260
|
+
}, [checkComponentAccess, cacheKey]);
|
|
261
|
+
return {
|
|
262
|
+
hasAccess: localState.hasAccess,
|
|
263
|
+
loading: localState.loading,
|
|
264
|
+
error: localState.error,
|
|
265
|
+
retry: retry,
|
|
266
|
+
// Expose cache key for debugging
|
|
267
|
+
cacheKey: cacheKey
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
// Utility function to clear all access cache (useful for logout)
|
|
272
|
+
var clearAccessCache = exports.clearAccessCache = function clearAccessCache() {
|
|
273
|
+
accessCache.clear();
|
|
274
|
+
pendingChecks.clear();
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
// Utility function to preload access for multiple components
|
|
278
|
+
var preloadAccess = exports.preloadAccess = /*#__PURE__*/function () {
|
|
279
|
+
var _ref4 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(components, dispatch) {
|
|
280
|
+
var promises;
|
|
281
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
282
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
283
|
+
case 0:
|
|
284
|
+
promises = components.map(function (_ref5) {
|
|
285
|
+
var _accessCache$get;
|
|
286
|
+
var name = _ref5.name,
|
|
287
|
+
type = _ref5.type;
|
|
288
|
+
var cacheKey = "".concat(type, "_").concat(name);
|
|
289
|
+
if (!accessCache.has(cacheKey)) {
|
|
290
|
+
return dispatch((0, _authSlice.checkAccess)({
|
|
291
|
+
name: name,
|
|
292
|
+
type: type
|
|
293
|
+
})).unwrap();
|
|
294
|
+
}
|
|
295
|
+
return Promise.resolve((_accessCache$get = accessCache.get(cacheKey)) === null || _accessCache$get === void 0 ? void 0 : _accessCache$get.hasAccess);
|
|
296
|
+
});
|
|
297
|
+
return _context4.abrupt("return", Promise.allSettled(promises));
|
|
298
|
+
case 2:
|
|
299
|
+
case "end":
|
|
300
|
+
return _context4.stop();
|
|
301
|
+
}
|
|
302
|
+
}, _callee4);
|
|
303
|
+
}));
|
|
304
|
+
return function preloadAccess(_x, _x2) {
|
|
305
|
+
return _ref4.apply(this, arguments);
|
|
306
|
+
};
|
|
307
|
+
}();
|
|
308
|
+
var _default = exports["default"] = useAccess;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useAppConfig = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _store = require("../store");
|
|
11
|
+
var _appConfigSlice = require("@wavemaker/react-runtime/store/slices/appConfigSlice");
|
|
12
|
+
var useAppConfig = exports.useAppConfig = function useAppConfig() {
|
|
13
|
+
var dispatch = (0, _store.useAppDispatch)();
|
|
14
|
+
var getServiceDefinitionsData = /*#__PURE__*/function () {
|
|
15
|
+
var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(baseURL) {
|
|
16
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
17
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18
|
+
case 0:
|
|
19
|
+
if (baseURL) {
|
|
20
|
+
_context.next = 2;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
return _context.abrupt("return", Promise.resolve({}));
|
|
24
|
+
case 2:
|
|
25
|
+
_context.next = 4;
|
|
26
|
+
return dispatch((0, _appConfigSlice.getServiceDefinitions)(baseURL)).unwrap();
|
|
27
|
+
case 4:
|
|
28
|
+
return _context.abrupt("return", _context.sent);
|
|
29
|
+
case 5:
|
|
30
|
+
case "end":
|
|
31
|
+
return _context.stop();
|
|
32
|
+
}
|
|
33
|
+
}, _callee);
|
|
34
|
+
}));
|
|
35
|
+
return function getServiceDefinitionsData(_x) {
|
|
36
|
+
return _ref.apply(this, arguments);
|
|
37
|
+
};
|
|
38
|
+
}();
|
|
39
|
+
return {
|
|
40
|
+
getServiceDefinitionsData: getServiceDefinitionsData
|
|
41
|
+
};
|
|
42
|
+
};
|