@wavemaker/react-runtime 11.14.1-rc.236
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 +10183 -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,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.setTimezone = exports.setTimeFormat = exports.setSelectedLocaleAndLoadBundle = exports.setDateFormat = exports.setCurrencyCode = exports.setAppLocale = exports.loadLocaleBundle = exports["default"] = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _toolkit = require("@reduxjs/toolkit");
|
|
11
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
12
|
+
var _toLower = _interopRequireDefault(require("lodash-es/toLower"));
|
|
13
|
+
var _map = _interopRequireDefault(require("lodash-es/map"));
|
|
14
|
+
var _lodashEs = require("lodash-es");
|
|
15
|
+
var _util = require("@wavemaker/react-runtime/core/util");
|
|
16
|
+
var _dom = require("@wavemaker/react-runtime/core/util/dom");
|
|
17
|
+
var _store = require("@wavemaker/react-runtime/store");
|
|
18
|
+
var _appstore = _interopRequireDefault(require("@wavemaker/react-runtime/core/appstore"));
|
|
19
|
+
var APP_LOCALE_ROOT_PATH = "/resources/i18n";
|
|
20
|
+
var RTL_LANGUAGE_CODES = ["ar", "ar-001", "ar-ae", "ar-bh", "ar-dz", "ar-eg", "ar-iq", "ar-jo", "ar-kw", "ar-lb", "ar-ly", "ar-ma", "ar-om", "ar-qa", "ar-sa", "ar-sd", "ar-sy", "ar-tn", "ar-ye", "arc", "bcc", "bqi", "ckb", "dv", "fa", "glk", "he", "ku", "mzn", "pnb", "ps", "sd", "ug", "ur", "yi"];
|
|
21
|
+
var initialState = {
|
|
22
|
+
selectedLocale: "",
|
|
23
|
+
defaultSupportedLocale: "en",
|
|
24
|
+
appLocale: {},
|
|
25
|
+
dateFormat: "MMM d, y",
|
|
26
|
+
timeFormat: "h:mm:ss a",
|
|
27
|
+
dateTimeFormat: "MMM d, y h:mm:ss a",
|
|
28
|
+
currencyCode: "USD",
|
|
29
|
+
timezone: "UTC",
|
|
30
|
+
isLoading: false,
|
|
31
|
+
error: null,
|
|
32
|
+
prefabMessages: {}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// check and change the direction
|
|
36
|
+
function updateLocaleDirection(locale) {
|
|
37
|
+
var direction = "ltr";
|
|
38
|
+
if (RTL_LANGUAGE_CODES.includes(locale)) {
|
|
39
|
+
direction = "rtl";
|
|
40
|
+
}
|
|
41
|
+
(0, _dom.setCSS)(document.body, "direction", direction);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Async thunk for loading locale bundle
|
|
45
|
+
var loadLocaleBundle = exports.loadLocaleBundle = (0, _toolkit.createAsyncThunk)("i18n/loadLocaleBundle", /*#__PURE__*/function () {
|
|
46
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(_, _ref) {
|
|
47
|
+
var rejectWithValue, appProperties, getAcceptedLanguages, _acceptLang, _defaultLanguage, preferBrowserLang, _supportedLang, _selectedDefaultLang, sessionLanguage, localLanguage, locale, url, path, response;
|
|
48
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
49
|
+
while (1) switch (_context.prev = _context.next) {
|
|
50
|
+
case 0:
|
|
51
|
+
getAcceptedLanguages = function _getAcceptedLanguages() {
|
|
52
|
+
var _languages;
|
|
53
|
+
var languages = decodeURIComponent(appProperties.preferredLanguage || "");
|
|
54
|
+
languages = (_languages = languages) === null || _languages === void 0 || (_languages = _languages.split(",")) === null || _languages === void 0 ? void 0 : _languages.map(function (locale) {
|
|
55
|
+
return locale === null || locale === void 0 ? void 0 : locale.split(";")[0];
|
|
56
|
+
});
|
|
57
|
+
return (0, _map["default"])(languages, _toLower["default"]);
|
|
58
|
+
};
|
|
59
|
+
rejectWithValue = _ref.rejectWithValue;
|
|
60
|
+
appProperties = _store.store.getState().info.appConfig.appProperties;
|
|
61
|
+
_acceptLang = getAcceptedLanguages();
|
|
62
|
+
_defaultLanguage = appProperties.defaultLanguage;
|
|
63
|
+
_acceptLang.push(_defaultLanguage);
|
|
64
|
+
|
|
65
|
+
// checks whether user preference is based on browser set languages or default language set in project
|
|
66
|
+
preferBrowserLang = appProperties.preferBrowserLang;
|
|
67
|
+
if (!preferBrowserLang) {
|
|
68
|
+
// when preferBrowserLang is not defined, set to its default value
|
|
69
|
+
preferBrowserLang = true;
|
|
70
|
+
} else {
|
|
71
|
+
// convert stringified boolean values recieved from BE to booleans
|
|
72
|
+
preferBrowserLang = preferBrowserLang === "true" || preferBrowserLang === true ? true : false;
|
|
73
|
+
}
|
|
74
|
+
_supportedLang = (Object === null || Object === void 0 ? void 0 : Object.keys(appProperties.supportedLanguages)) || [initialState.defaultSupportedLocale];
|
|
75
|
+
_selectedDefaultLang = preferBrowserLang ? undefined : _defaultLanguage;
|
|
76
|
+
sessionLanguage = (0, _util.getSessionStorageItem)("selectedLocale");
|
|
77
|
+
localLanguage = (0, _lodashEs.includes)(_supportedLang, sessionLanguage) && sessionLanguage;
|
|
78
|
+
locale = localLanguage || _selectedDefaultLang || (0, _lodashEs.intersection)(_acceptLang, _supportedLang)[0] || initialState.defaultSupportedLocale;
|
|
79
|
+
_context.prev = 13;
|
|
80
|
+
url = _store.store.getState().info.appConfig.url;
|
|
81
|
+
path = "".concat(url + APP_LOCALE_ROOT_PATH, "/").concat(locale, ".json");
|
|
82
|
+
_context.next = 18;
|
|
83
|
+
return _axios["default"].get(path);
|
|
84
|
+
case 18:
|
|
85
|
+
response = _context.sent;
|
|
86
|
+
// update session language
|
|
87
|
+
(0, _util.setSessionStorageItem)("selectedLocale", locale);
|
|
88
|
+
// change direction if required
|
|
89
|
+
updateLocaleDirection(locale);
|
|
90
|
+
_appstore["default"].set("i18nService", response.data);
|
|
91
|
+
return _context.abrupt("return", {
|
|
92
|
+
data: response.data,
|
|
93
|
+
locale: locale
|
|
94
|
+
});
|
|
95
|
+
case 25:
|
|
96
|
+
_context.prev = 25;
|
|
97
|
+
_context.t0 = _context["catch"](13);
|
|
98
|
+
console.warn("Error loading locale resource: ".concat(_context.t0));
|
|
99
|
+
return _context.abrupt("return", rejectWithValue("Failed to load locale bundle"));
|
|
100
|
+
case 29:
|
|
101
|
+
case "end":
|
|
102
|
+
return _context.stop();
|
|
103
|
+
}
|
|
104
|
+
}, _callee, null, [[13, 25]]);
|
|
105
|
+
}));
|
|
106
|
+
return function (_x, _x2) {
|
|
107
|
+
return _ref2.apply(this, arguments);
|
|
108
|
+
};
|
|
109
|
+
}());
|
|
110
|
+
|
|
111
|
+
// Async thunk to set locale and load locale bundle
|
|
112
|
+
var setSelectedLocaleAndLoadBundle = exports.setSelectedLocaleAndLoadBundle = (0, _toolkit.createAsyncThunk)("i18n/setSelectedLocaleAndLoadBundle", /*#__PURE__*/function () {
|
|
113
|
+
var _ref5 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(_ref3, _ref4) {
|
|
114
|
+
var locale, dispatch, getState, localeValue, appProperties, supportedLocales, currentLocale;
|
|
115
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
116
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
117
|
+
case 0:
|
|
118
|
+
locale = _ref3.locale;
|
|
119
|
+
dispatch = _ref4.dispatch, getState = _ref4.getState;
|
|
120
|
+
localeValue = (0, _lodashEs.isObject)(locale) ? locale.datavalue : locale;
|
|
121
|
+
appProperties = _store.store.getState().info.appConfig.appProperties;
|
|
122
|
+
supportedLocales = Object.keys(appProperties.supportedLanguages);
|
|
123
|
+
if ((0, _lodashEs.includes)(supportedLocales, localeValue)) {
|
|
124
|
+
_context2.next = 7;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
return _context2.abrupt("return", null);
|
|
128
|
+
case 7:
|
|
129
|
+
if (!(!localeValue || localeValue === getState().i18n.selectedLocale)) {
|
|
130
|
+
_context2.next = 9;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
return _context2.abrupt("return", null);
|
|
134
|
+
case 9:
|
|
135
|
+
currentLocale = (0, _util.getSessionStorageItem)("selectedLocale");
|
|
136
|
+
if (!(currentLocale === localeValue)) {
|
|
137
|
+
_context2.next = 12;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
return _context2.abrupt("return", null);
|
|
141
|
+
case 12:
|
|
142
|
+
// Update session storage with new locale
|
|
143
|
+
(0, _util.setSessionStorageItem)("selectedLocale", localeValue);
|
|
144
|
+
|
|
145
|
+
// Change direction if required
|
|
146
|
+
updateLocaleDirection(localeValue);
|
|
147
|
+
|
|
148
|
+
// Load the locale bundle
|
|
149
|
+
_context2.next = 16;
|
|
150
|
+
return dispatch(loadLocaleBundle());
|
|
151
|
+
case 16:
|
|
152
|
+
return _context2.abrupt("return", localeValue);
|
|
153
|
+
case 17:
|
|
154
|
+
case "end":
|
|
155
|
+
return _context2.stop();
|
|
156
|
+
}
|
|
157
|
+
}, _callee2);
|
|
158
|
+
}));
|
|
159
|
+
return function (_x3, _x4) {
|
|
160
|
+
return _ref5.apply(this, arguments);
|
|
161
|
+
};
|
|
162
|
+
}());
|
|
163
|
+
var i18nSlice = (0, _toolkit.createSlice)({
|
|
164
|
+
name: "i18n",
|
|
165
|
+
initialState: initialState,
|
|
166
|
+
reducers: {
|
|
167
|
+
setTimezone: function setTimezone(state, action) {
|
|
168
|
+
state.timezone = action.payload;
|
|
169
|
+
},
|
|
170
|
+
setAppLocale: function setAppLocale(state, action) {
|
|
171
|
+
state.appLocale = action.payload;
|
|
172
|
+
},
|
|
173
|
+
setDateFormat: function setDateFormat(state, action) {
|
|
174
|
+
state.dateFormat = action.payload;
|
|
175
|
+
state.dateTimeFormat = "".concat(action.payload, " ").concat(state.timeFormat);
|
|
176
|
+
},
|
|
177
|
+
setTimeFormat: function setTimeFormat(state, action) {
|
|
178
|
+
state.timeFormat = action.payload;
|
|
179
|
+
state.dateTimeFormat = "".concat(state.dateFormat, " ").concat(action.payload);
|
|
180
|
+
},
|
|
181
|
+
setCurrencyCode: function setCurrencyCode(state, action) {
|
|
182
|
+
state.currencyCode = action.payload;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
extraReducers: function extraReducers(builder) {
|
|
186
|
+
builder.addCase(loadLocaleBundle.fulfilled, function (state, action) {
|
|
187
|
+
var _action$payload$data$, _action$payload$data$2, _action$payload$data$3;
|
|
188
|
+
state.appLocale = action.payload.data.messages || {};
|
|
189
|
+
state.dateFormat = ((_action$payload$data$ = action.payload.data.formats) === null || _action$payload$data$ === void 0 ? void 0 : _action$payload$data$.date) || state.dateFormat;
|
|
190
|
+
state.timeFormat = ((_action$payload$data$2 = action.payload.data.formats) === null || _action$payload$data$2 === void 0 ? void 0 : _action$payload$data$2.time) || state.timeFormat;
|
|
191
|
+
state.currencyCode = ((_action$payload$data$3 = action.payload.data.formats) === null || _action$payload$data$3 === void 0 ? void 0 : _action$payload$data$3.currency) || state.currencyCode;
|
|
192
|
+
state.dateTimeFormat = "".concat(state.dateFormat, " ").concat(state.timeFormat);
|
|
193
|
+
state.prefabMessages = action.payload.data.prefabMessages || {};
|
|
194
|
+
state.selectedLocale = action.payload.locale || state.selectedLocale;
|
|
195
|
+
}).addCase(loadLocaleBundle.rejected, function (state, action) {
|
|
196
|
+
state.error = action.payload;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
var _i18nSlice$actions = i18nSlice.actions,
|
|
201
|
+
setTimezone = exports.setTimezone = _i18nSlice$actions.setTimezone,
|
|
202
|
+
setAppLocale = exports.setAppLocale = _i18nSlice$actions.setAppLocale,
|
|
203
|
+
setDateFormat = exports.setDateFormat = _i18nSlice$actions.setDateFormat,
|
|
204
|
+
setTimeFormat = exports.setTimeFormat = _i18nSlice$actions.setTimeFormat,
|
|
205
|
+
setCurrencyCode = exports.setCurrencyCode = _i18nSlice$actions.setCurrencyCode;
|
|
206
|
+
var _default = exports["default"] = i18nSlice.reducer;
|
package/types/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.VariableEvents = void 0;
|
|
7
|
+
// Adding index signature to PageContextState
|
|
8
|
+
// Enums and Types
|
|
9
|
+
var VariableEvents = exports.VariableEvents = /*#__PURE__*/function (VariableEvents) {
|
|
10
|
+
VariableEvents["BEFORE_INVOKE"] = "beforeInvoke";
|
|
11
|
+
VariableEvents["SUCCESS"] = "success";
|
|
12
|
+
VariableEvents["ERROR"] = "error";
|
|
13
|
+
VariableEvents["AFTER_INVOKE"] = "afterInvoke";
|
|
14
|
+
return VariableEvents;
|
|
15
|
+
}({});
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _lodashEs = require("lodash-es");
|
|
11
|
+
var DatasetUtil = exports["default"] = /*#__PURE__*/function () {
|
|
12
|
+
function DatasetUtil() {
|
|
13
|
+
(0, _classCallCheck2["default"])(this, DatasetUtil);
|
|
14
|
+
}
|
|
15
|
+
(0, _createClass2["default"])(DatasetUtil, null, [{
|
|
16
|
+
key: "isValidDataset",
|
|
17
|
+
value: function isValidDataset(dataSet, isList) {
|
|
18
|
+
if (!dataSet || isList && !(0, _lodashEs.isArray)(dataSet)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return dataSet;
|
|
22
|
+
}
|
|
23
|
+
}, {
|
|
24
|
+
key: "getValue",
|
|
25
|
+
value: function getValue(dataSet, key, index, isList) {
|
|
26
|
+
index = index || 0;
|
|
27
|
+
return isList ? dataSet[index][key] : dataSet[key];
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
key: "setValue",
|
|
31
|
+
value: function setValue(dataSet, key, value, isList) {
|
|
32
|
+
if (key && !isList) {
|
|
33
|
+
dataSet[key] = value;
|
|
34
|
+
}
|
|
35
|
+
return dataSet;
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
38
|
+
key: "getTargetNode",
|
|
39
|
+
value: function getTargetNode(dataSet, options) {
|
|
40
|
+
dataSet = options.parentIndex !== undefined ? dataSet[options.parentIndex] : dataSet;
|
|
41
|
+
return (0, _lodashEs.get)(dataSet, options.path);
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
key: "getItem",
|
|
45
|
+
value: function getItem(dataSet, index, isList) {
|
|
46
|
+
return isList ? dataSet[index] : dataSet;
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
key: "setItem",
|
|
50
|
+
value: function setItem(dataSet, i, value, options) {
|
|
51
|
+
var index;
|
|
52
|
+
if ((0, _lodashEs.isUndefined)(i) || !options.isList) {
|
|
53
|
+
return dataSet;
|
|
54
|
+
}
|
|
55
|
+
if ((0, _lodashEs.isObject)(i)) {
|
|
56
|
+
index = (0, _lodashEs.findIndex)(dataSet, i);
|
|
57
|
+
} else {
|
|
58
|
+
index = i;
|
|
59
|
+
}
|
|
60
|
+
if (options.path) {
|
|
61
|
+
var innerArray = DatasetUtil.getTargetNode(dataSet, options);
|
|
62
|
+
var innerElemindex = (0, _lodashEs.findIndex)(innerArray, i);
|
|
63
|
+
if (innerElemindex > -1) {
|
|
64
|
+
innerArray[innerElemindex] = value;
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
if (index > -1) {
|
|
68
|
+
dataSet[index] = value;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return dataSet;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* This method is to get target node options like path, parentIndex and isList
|
|
76
|
+
* Example: if we have parent dataset as object and we are performing operations on inner list then we have to set isList as true.
|
|
77
|
+
* So finding the target node type and updating the isList option.
|
|
78
|
+
*/
|
|
79
|
+
}, {
|
|
80
|
+
key: "getChildDetails",
|
|
81
|
+
value: function getChildDetails(dataSet, options, isList) {
|
|
82
|
+
var parentIndex, path;
|
|
83
|
+
if (options && options.path) {
|
|
84
|
+
path = options.path;
|
|
85
|
+
var targetNode;
|
|
86
|
+
if (isList) {
|
|
87
|
+
parentIndex = options.parentIndex || 0;
|
|
88
|
+
targetNode = (0, _lodashEs.get)(dataSet[parentIndex], options.path);
|
|
89
|
+
} else {
|
|
90
|
+
targetNode = (0, _lodashEs.get)(dataSet, options.path);
|
|
91
|
+
}
|
|
92
|
+
isList = targetNode ? (0, _lodashEs.isArray)(targetNode) ? true : false : true;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
path: path,
|
|
96
|
+
isList: isList,
|
|
97
|
+
parentIndex: parentIndex
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "addItem",
|
|
102
|
+
value: function addItem(dataSet, value, index, options) {
|
|
103
|
+
if ((0, _lodashEs.isUndefined)(value) || !options.isList) {
|
|
104
|
+
return dataSet;
|
|
105
|
+
}
|
|
106
|
+
if (options.path) {
|
|
107
|
+
var innerArray = DatasetUtil.getTargetNode(dataSet, options);
|
|
108
|
+
if (innerArray) {
|
|
109
|
+
// check for index sanity
|
|
110
|
+
index = index !== undefined ? index : innerArray.length;
|
|
111
|
+
innerArray.splice(index, 0, value);
|
|
112
|
+
} else {
|
|
113
|
+
options.parentIndex !== undefined ? (0, _lodashEs.set)(dataSet[options.parentIndex], options.path, [value]) : (0, _lodashEs.set)(dataSet, options.path, [value]);
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
index = index !== undefined ? index : dataSet.length;
|
|
117
|
+
dataSet.splice(index, 0, value);
|
|
118
|
+
}
|
|
119
|
+
return dataSet;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
* @param dataSet
|
|
125
|
+
* @param i, can be index value of the object/element in array
|
|
126
|
+
* or
|
|
127
|
+
* the whole object which needs to be removed
|
|
128
|
+
* @param exactMatch
|
|
129
|
+
* @returns {any}
|
|
130
|
+
*/
|
|
131
|
+
}, {
|
|
132
|
+
key: "removeItem",
|
|
133
|
+
value: function removeItem(dataSet, i, options) {
|
|
134
|
+
var index, exactMatch;
|
|
135
|
+
i = i !== undefined ? i : dataSet.length - 1;
|
|
136
|
+
if ((0, _lodashEs.isBoolean)(options)) {
|
|
137
|
+
exactMatch = options;
|
|
138
|
+
}
|
|
139
|
+
if ((0, _lodashEs.isObject)(options)) {
|
|
140
|
+
// @ts-ignore
|
|
141
|
+
exactMatch = options.exactMatch;
|
|
142
|
+
}
|
|
143
|
+
if ((0, _lodashEs.isObject)(i)) {
|
|
144
|
+
if (options.path) {
|
|
145
|
+
var innerArray = DatasetUtil.getTargetNode(dataSet, options);
|
|
146
|
+
var innerElemindex = (0, _lodashEs.findIndex)(innerArray, i);
|
|
147
|
+
if (innerElemindex > -1 && (!exactMatch || exactMatch && (0, _lodashEs.isEqual)(innerArray[innerElemindex], i))) {
|
|
148
|
+
innerArray.splice(innerElemindex, 1);
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
index = (0, _lodashEs.findIndex)(dataSet, i);
|
|
152
|
+
// When exactMatch property is set to true delete only when every property values are same*/
|
|
153
|
+
if (index > -1 && (!exactMatch || exactMatch && (0, _lodashEs.isEqual)(dataSet[index], i))) {
|
|
154
|
+
dataSet.splice(index, 1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
dataSet.splice(i, 1);
|
|
159
|
+
}
|
|
160
|
+
return dataSet;
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
key: "getValidDataset",
|
|
164
|
+
value: function getValidDataset(isList) {
|
|
165
|
+
return isList ? [] : {};
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "getCount",
|
|
169
|
+
value: function getCount(dataSet, isList) {
|
|
170
|
+
return isList ? dataSet.length : Object.keys(dataSet).length;
|
|
171
|
+
}
|
|
172
|
+
}]);
|
|
173
|
+
return DatasetUtil;
|
|
174
|
+
}();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.evalExp = void 0;
|
|
8
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
+
var _lodashEs = require("lodash-es");
|
|
10
|
+
var evalExp = exports.evalExp = function evalExp(obj, path) {
|
|
11
|
+
if (!obj || typeof path !== "string") {
|
|
12
|
+
console.warn("Invalid input: obj is null/undefined or path is not a string.");
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Convert indices to dot notation and split
|
|
17
|
+
var pathArray = path.replace(/\[(\w+)\]/g, ".$1").split(".");
|
|
18
|
+
|
|
19
|
+
// traverse the pathArray and check if the key exists or not
|
|
20
|
+
var item = pathArray.slice(1, pathArray.length).reduce(function (accumulator, currentKey) {
|
|
21
|
+
if (!accumulator) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
if ((0, _lodashEs.isArray)(accumulator)) {
|
|
25
|
+
return accumulator[parseInt(currentKey)];
|
|
26
|
+
} else if ((0, _typeof2["default"])(accumulator) === "object") {
|
|
27
|
+
return accumulator[currentKey];
|
|
28
|
+
}
|
|
29
|
+
return accumulator;
|
|
30
|
+
}, obj);
|
|
31
|
+
return item;
|
|
32
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.unregisterFormField = exports.shouldRegisterFormField = exports.registerFormFieldSafe = exports.registerFormField = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _get = _interopRequireDefault(require("lodash-es/get"));
|
|
10
|
+
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; }
|
|
11
|
+
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; } /**
|
|
12
|
+
* Form State Utility
|
|
13
|
+
*
|
|
14
|
+
* Handles form field registration and management within the widget context.
|
|
15
|
+
* This utility provides centralized logic for registering form fields and form widgets
|
|
16
|
+
* to their parent form context.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Interface for widget properties related to form field registration
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Interface for the context structure where form fields are registered
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a widget is a form field (not a formWidget wrapper)
|
|
28
|
+
* @param widgetName - The name of the widget
|
|
29
|
+
* @returns true if the widget is NOT a formWidget wrapper
|
|
30
|
+
*/
|
|
31
|
+
var isFormField = function isFormField(widgetName) {
|
|
32
|
+
return !(widgetName !== null && widgetName !== void 0 && widgetName.includes("formWidget"));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Checks if a widget should be registered as a form field
|
|
37
|
+
* @param widget - The widget object to check
|
|
38
|
+
* @returns true if the widget should be registered as a form field
|
|
39
|
+
*/
|
|
40
|
+
var shouldRegisterFormField = exports.shouldRegisterFormField = function shouldRegisterFormField(widget) {
|
|
41
|
+
var isField = (0, _get["default"])(widget, "field", "false") === "true";
|
|
42
|
+
var hasFormName = Boolean(widget.formName);
|
|
43
|
+
var isNotFormWidget = isFormField(widget.name);
|
|
44
|
+
return isField && hasFormName && isNotFormWidget;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Registers a form field widget with its parent form in the context
|
|
49
|
+
* This creates references in both formfields and formWidgets collections
|
|
50
|
+
*
|
|
51
|
+
* @param widgetsContext - The Widgets context object where forms are stored
|
|
52
|
+
* @param widget - The widget/proxy to register
|
|
53
|
+
* @param widgetProps - The widget properties containing form metadata
|
|
54
|
+
*/
|
|
55
|
+
var registerFormField = exports.registerFormField = function registerFormField(widgetsContext, widget, widgetProps) {
|
|
56
|
+
var formName = widgetProps === null || widgetProps === void 0 ? void 0 : widgetProps.formName;
|
|
57
|
+
if (!formName || !shouldRegisterFormField(widgetProps)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
var formKey = widgetProps.formKey || widgetProps.fieldName;
|
|
61
|
+
var fieldName = widgetProps.fieldName;
|
|
62
|
+
if (!formKey || !fieldName) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Ensure the form structure exists in the context
|
|
67
|
+
if (!widgetsContext[formName]) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
widgetsContext[formName].formfields = widgetsContext[formName].formfields || {};
|
|
71
|
+
widgetsContext[formName].formWidgets = widgetsContext[formName].formWidgets || {};
|
|
72
|
+
|
|
73
|
+
// Register the field using the formKey (primary key)
|
|
74
|
+
widgetsContext[formName].formfields[formKey] = widget;
|
|
75
|
+
|
|
76
|
+
// Register using fieldName for direct access
|
|
77
|
+
widgetsContext[formName].formWidgets[fieldName] = widget;
|
|
78
|
+
|
|
79
|
+
// Register formWidget variants (for form field wrapper components)
|
|
80
|
+
widgetsContext[formName].formfields["".concat(fieldName, "_formWidget")] = widget;
|
|
81
|
+
widgetsContext[formName].formWidgets["".concat(fieldName, "_formWidget")] = widget;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Ensures the form structure exists in the widgets context and registers a form field
|
|
86
|
+
* with safe object spreading to merge properties
|
|
87
|
+
*
|
|
88
|
+
* @param widgetsContext - The Widgets context object where forms are stored
|
|
89
|
+
* @param fieldProps - The field properties to register
|
|
90
|
+
*/
|
|
91
|
+
var registerFormFieldSafe = exports.registerFormFieldSafe = function registerFormFieldSafe(widgetsContext, fieldProps) {
|
|
92
|
+
var _widgetsContext$formN, _widgetsContext$formN2, _widgetsContext$formN3, _widgetsContext$formN4, _widgetsContext$formN5;
|
|
93
|
+
var formName = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.formName;
|
|
94
|
+
if (!formName || !shouldRegisterFormField(fieldProps)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
var formKey = fieldProps.formKey || fieldProps.fieldName;
|
|
98
|
+
var fieldName = fieldProps.fieldName;
|
|
99
|
+
if (!formKey || !fieldName) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ✅ Ensure all nested structures exist using nullish coalescing
|
|
104
|
+
(_widgetsContext$formN = widgetsContext[formName]) !== null && _widgetsContext$formN !== void 0 ? _widgetsContext$formN : widgetsContext[formName] = {};
|
|
105
|
+
(_widgetsContext$formN3 = (_widgetsContext$formN2 = widgetsContext[formName]).formfields) !== null && _widgetsContext$formN3 !== void 0 ? _widgetsContext$formN3 : _widgetsContext$formN2.formfields = {};
|
|
106
|
+
(_widgetsContext$formN5 = (_widgetsContext$formN4 = widgetsContext[formName]).formWidgets) !== null && _widgetsContext$formN5 !== void 0 ? _widgetsContext$formN5 : _widgetsContext$formN4.formWidgets = {};
|
|
107
|
+
|
|
108
|
+
// ✅ Only add if not already present
|
|
109
|
+
widgetsContext[formName].formfields[formKey] = _objectSpread({}, fieldProps);
|
|
110
|
+
widgetsContext[formName].formWidgets[fieldName] = _objectSpread({}, fieldProps);
|
|
111
|
+
widgetsContext[formName].formfields["".concat(fieldName, "_formWidget")] = _objectSpread({}, fieldProps);
|
|
112
|
+
widgetsContext[formName].formWidgets["".concat(fieldName, "_formWidget")] = _objectSpread({}, fieldProps);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Unregisters a form field from its parent form
|
|
117
|
+
*
|
|
118
|
+
* @param widgetsContext - The Widgets context object where forms are stored
|
|
119
|
+
* @param formName - The name of the parent form
|
|
120
|
+
* @param fieldName - The name of the field to unregister
|
|
121
|
+
* @param formKey - Optional form key (defaults to fieldName if not provided)
|
|
122
|
+
*/
|
|
123
|
+
var unregisterFormField = exports.unregisterFormField = function unregisterFormField(widgetsContext, formName, fieldName, formKey) {
|
|
124
|
+
if (!widgetsContext[formName]) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
var keyToRemove = formKey || fieldName;
|
|
128
|
+
|
|
129
|
+
// Remove from formfields
|
|
130
|
+
if (widgetsContext[formName].formfields) {
|
|
131
|
+
delete widgetsContext[formName].formfields[keyToRemove];
|
|
132
|
+
delete widgetsContext[formName].formfields["".concat(fieldName, "_formWidget")];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Remove from formWidgets
|
|
136
|
+
if (widgetsContext[formName].formWidgets) {
|
|
137
|
+
delete widgetsContext[formName].formWidgets[fieldName];
|
|
138
|
+
delete widgetsContext[formName].formWidgets["".concat(fieldName, "_formWidget")];
|
|
139
|
+
}
|
|
140
|
+
};
|