@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,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createWidgetCleanup = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
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
|
+
/**
|
|
13
|
+
* Configuration for the widget cleanup utility
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a debounced widget cleanup utility function
|
|
18
|
+
* This eliminates code duplication between WidgetProvider and BasePage
|
|
19
|
+
*
|
|
20
|
+
* @param config - Configuration object for the cleanup utility
|
|
21
|
+
* @returns Object containing cleanup function and cleanupRef
|
|
22
|
+
*/
|
|
23
|
+
var createWidgetCleanup = exports.createWidgetCleanup = function createWidgetCleanup(config) {
|
|
24
|
+
var setPageContext = config.setPageContext,
|
|
25
|
+
proxyRef = config.proxyRef,
|
|
26
|
+
_config$debounceDelay = config.debounceDelay,
|
|
27
|
+
debounceDelay = _config$debounceDelay === void 0 ? 100 : _config$debounceDelay;
|
|
28
|
+
var cleanupRef = new Set();
|
|
29
|
+
var timeoutId = null;
|
|
30
|
+
|
|
31
|
+
// Debounced cleanup function that processes accumulated widget names
|
|
32
|
+
var performCleanup = function performCleanup() {
|
|
33
|
+
if (timeoutId) {
|
|
34
|
+
clearTimeout(timeoutId);
|
|
35
|
+
}
|
|
36
|
+
timeoutId = setTimeout(function () {
|
|
37
|
+
if (cleanupRef.size === 0) return;
|
|
38
|
+
setPageContext(function (currentContext) {
|
|
39
|
+
var newContext = _objectSpread({}, currentContext);
|
|
40
|
+
var widgetsToClean = (0, _toConsumableArray2["default"])(cleanupRef);
|
|
41
|
+
widgetsToClean.forEach(function (name) {
|
|
42
|
+
if (newContext.Widgets && newContext.Widgets[name]) {
|
|
43
|
+
var _proxyRef$current;
|
|
44
|
+
delete newContext.Widgets[name];
|
|
45
|
+
|
|
46
|
+
// Delete from proxy if available
|
|
47
|
+
if (proxyRef !== null && proxyRef !== void 0 && (_proxyRef$current = proxyRef.current) !== null && _proxyRef$current !== void 0 && _proxyRef$current.Widgets) {
|
|
48
|
+
delete proxyRef.current.Widgets[name];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
cleanupRef.clear();
|
|
53
|
+
return newContext;
|
|
54
|
+
});
|
|
55
|
+
timeoutId = null;
|
|
56
|
+
}, debounceDelay);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Cleanup function to be called when a widget needs to be removed
|
|
61
|
+
* @param name - Name of the widget to cleanup
|
|
62
|
+
*/
|
|
63
|
+
var cleanup = function cleanup(name) {
|
|
64
|
+
// Accumulate widget names to be cleaned up
|
|
65
|
+
cleanupRef.add(name);
|
|
66
|
+
// Trigger debounced cleanup
|
|
67
|
+
performCleanup();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Cancel any pending cleanup operations
|
|
72
|
+
*/
|
|
73
|
+
var cancel = function cancel() {
|
|
74
|
+
if (timeoutId) {
|
|
75
|
+
clearTimeout(timeoutId);
|
|
76
|
+
timeoutId = null;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
cleanup: cleanup,
|
|
81
|
+
cleanupRef: cleanupRef,
|
|
82
|
+
cancel: cancel
|
|
83
|
+
};
|
|
84
|
+
};
|
package/utils/widgets.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getObjValueByKey = exports.getEvaluatedData = exports.checkIsCustomPipeExpression = void 0;
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
8
|
+
var getObjValueByKey = exports.getObjValueByKey = function getObjValueByKey(obj, strKey) {
|
|
9
|
+
if (!strKey || !obj) {
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
return (0, _lodashEs.get)(obj, strKey);
|
|
13
|
+
};
|
|
14
|
+
var checkIsCustomPipeExpression = exports.checkIsCustomPipeExpression = function checkIsCustomPipeExpression(exp) {
|
|
15
|
+
var customRegEx = /(custom(\s*:))/g;
|
|
16
|
+
var matches = exp.match(customRegEx);
|
|
17
|
+
return matches && matches.length;
|
|
18
|
+
};
|
|
19
|
+
var getEvaluatedData = exports.getEvaluatedData = function getEvaluatedData(dataObj, options, context) {
|
|
20
|
+
var displayExpr = options.expression;
|
|
21
|
+
if (displayExpr) {
|
|
22
|
+
if (typeof displayExpr !== "function") {
|
|
23
|
+
return dataObj[displayExpr];
|
|
24
|
+
}
|
|
25
|
+
return displayExpr(dataObj);
|
|
26
|
+
}
|
|
27
|
+
var expressionValue = "";
|
|
28
|
+
var field = options.field || "",
|
|
29
|
+
expr = options.expression,
|
|
30
|
+
bindExpr = options.bindExpression;
|
|
31
|
+
if (bindExpr) {
|
|
32
|
+
expressionValue = bindExpr.replace("bind:", "");
|
|
33
|
+
if (checkIsCustomPipeExpression(expressionValue)) {
|
|
34
|
+
expressionValue = expressionValue + ": __1";
|
|
35
|
+
}
|
|
36
|
+
expressionValue = getUpdatedExpr(expressionValue);
|
|
37
|
+
} else {
|
|
38
|
+
expressionValue = expr ? expr : field;
|
|
39
|
+
}
|
|
40
|
+
if (!bindExpr && !expr) {
|
|
41
|
+
if (typeof field === "function") {
|
|
42
|
+
return field(dataObj);
|
|
43
|
+
}
|
|
44
|
+
return (0, _lodashEs.get)(dataObj, field);
|
|
45
|
+
}
|
|
46
|
+
return expressionValue(context, Object.assign({}, dataObj, {
|
|
47
|
+
__1: dataObj
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
50
|
+
var getUpdatedExpr = function getUpdatedExpr(expr) {
|
|
51
|
+
var updated = "",
|
|
52
|
+
ch,
|
|
53
|
+
next,
|
|
54
|
+
i,
|
|
55
|
+
j,
|
|
56
|
+
matchCh,
|
|
57
|
+
matchCount,
|
|
58
|
+
isQuotedStr,
|
|
59
|
+
subStr,
|
|
60
|
+
isQuotedStrEvaluated;
|
|
61
|
+
expr = expr.replace(/\$\[data\[\$i\]/g, "$[__1");
|
|
62
|
+
for (i = 0; i < expr.length; i++) {
|
|
63
|
+
ch = expr[i];
|
|
64
|
+
next = expr[i + 1];
|
|
65
|
+
if (ch === "$" && next === "[") {
|
|
66
|
+
matchCount = 1;
|
|
67
|
+
isQuotedStrEvaluated = false;
|
|
68
|
+
isQuotedStr = false;
|
|
69
|
+
for (j = i + 2; j < expr.length; j++) {
|
|
70
|
+
matchCh = expr[j];
|
|
71
|
+
if (matchCh === " ") {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (!isQuotedStrEvaluated) {
|
|
75
|
+
isQuotedStr = expr[j] === '"' || expr[j] === "'";
|
|
76
|
+
isQuotedStrEvaluated = true;
|
|
77
|
+
}
|
|
78
|
+
if (matchCh === "[") {
|
|
79
|
+
matchCount++;
|
|
80
|
+
} else if (matchCh === "]") {
|
|
81
|
+
matchCount--;
|
|
82
|
+
}
|
|
83
|
+
if (!matchCount) {
|
|
84
|
+
subStr = expr.substring(i + 2, j);
|
|
85
|
+
if (isQuotedStr) {
|
|
86
|
+
updated += "__1[" + subStr + "]";
|
|
87
|
+
} else {
|
|
88
|
+
updated += subStr;
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
i = j;
|
|
94
|
+
} else {
|
|
95
|
+
updated += ch;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return updated;
|
|
99
|
+
};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.VariableEvents = exports.BaseVariable = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
var _datasetUtil = _interopRequireDefault(require("@wavemaker/react-runtime/utils/dataset-util"));
|
|
16
|
+
var _eventNotifier = _interopRequireDefault(require("@wavemaker/react-runtime/core/event-notifier"));
|
|
17
|
+
var _lodashEs = require("lodash-es");
|
|
18
|
+
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2["default"])(t); if (r) { var s = (0, _getPrototypeOf2["default"])(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2["default"])(this, e); }; }
|
|
19
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
20
|
+
var VariableEvents = exports.VariableEvents = /*#__PURE__*/function (VariableEvents) {
|
|
21
|
+
VariableEvents["BEFORE_INVOKE"] = "beforeInvoke";
|
|
22
|
+
VariableEvents["SUCCESS"] = "success";
|
|
23
|
+
VariableEvents["ERROR"] = "error";
|
|
24
|
+
VariableEvents["AFTER_INVOKE"] = "afterInvoke";
|
|
25
|
+
return VariableEvents;
|
|
26
|
+
}({});
|
|
27
|
+
var BaseVariable = exports.BaseVariable = /*#__PURE__*/function (_EventNotifier) {
|
|
28
|
+
(0, _inherits2["default"])(BaseVariable, _EventNotifier);
|
|
29
|
+
var _super = _createSuper(BaseVariable);
|
|
30
|
+
function BaseVariable(config) {
|
|
31
|
+
var _this;
|
|
32
|
+
(0, _classCallCheck2["default"])(this, BaseVariable);
|
|
33
|
+
_this = _super.call(this);
|
|
34
|
+
_this.config = config;
|
|
35
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "name", "");
|
|
36
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "params", {});
|
|
37
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "dataSet", {});
|
|
38
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "isList", void 0);
|
|
39
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "twoWayBinding", void 0);
|
|
40
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "isExecuting", false);
|
|
41
|
+
_this.name = config.name;
|
|
42
|
+
_this.isList = config.isList;
|
|
43
|
+
_this.twoWayBinding = config.twoWayBinding;
|
|
44
|
+
_this.dataSet = _this.isList ? [] : _this.dataSet;
|
|
45
|
+
_this.subscribe(VariableEvents.BEFORE_INVOKE, function () {
|
|
46
|
+
_this.isExecuting = true;
|
|
47
|
+
console.info("Before Invoking variable ".concat(_this.name));
|
|
48
|
+
});
|
|
49
|
+
_this.subscribe(VariableEvents.AFTER_INVOKE, function () {
|
|
50
|
+
_this.isExecuting = false;
|
|
51
|
+
console.info("After Invoking variable ".concat(_this.name));
|
|
52
|
+
});
|
|
53
|
+
return _this;
|
|
54
|
+
}
|
|
55
|
+
(0, _createClass2["default"])(BaseVariable, [{
|
|
56
|
+
key: "invoke",
|
|
57
|
+
value: function invoke(params, onSuccess, onError) {
|
|
58
|
+
if (!params) {
|
|
59
|
+
this.params = this.config.paramProvider();
|
|
60
|
+
} else {
|
|
61
|
+
this.params = params;
|
|
62
|
+
}
|
|
63
|
+
return Promise.resolve(this);
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "doNext",
|
|
67
|
+
value: function doNext() {
|
|
68
|
+
return Promise.reject(this);
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
key: "invokeOnParamChange",
|
|
72
|
+
value: function invokeOnParamChange() {
|
|
73
|
+
var last = this.params;
|
|
74
|
+
var latest = this.config.paramProvider();
|
|
75
|
+
if (!(0, _lodashEs.isEqual)(last, latest)) {
|
|
76
|
+
return this.invoke(latest);
|
|
77
|
+
}
|
|
78
|
+
return Promise.resolve(this);
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "getData",
|
|
82
|
+
value: function getData() {
|
|
83
|
+
return this.dataSet;
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "setData",
|
|
87
|
+
value: function setData(dataSet) {
|
|
88
|
+
if (_datasetUtil["default"].isValidDataset(dataSet, this.isList)) {
|
|
89
|
+
this.dataSet = dataSet;
|
|
90
|
+
}
|
|
91
|
+
return this.dataSet;
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
key: "getValue",
|
|
95
|
+
value: function getValue(key, index) {
|
|
96
|
+
return _datasetUtil["default"].getValue(this.dataSet, key, index, this.isList);
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
key: "setValue",
|
|
100
|
+
value: function setValue(key, value) {
|
|
101
|
+
return _datasetUtil["default"].setValue(this.dataSet, key, value, this.isList);
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
key: "getItem",
|
|
105
|
+
value: function getItem(index) {
|
|
106
|
+
return _datasetUtil["default"].getItem(this.dataSet, index, this.isList);
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "setItem",
|
|
110
|
+
value: function setItem(index, value, options) {
|
|
111
|
+
options = _datasetUtil["default"].getChildDetails(this.dataSet, options, this.isList);
|
|
112
|
+
return _datasetUtil["default"].setItem(this.dataSet, index, value, options);
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "addItem",
|
|
116
|
+
value: function addItem(value, options) {
|
|
117
|
+
var index;
|
|
118
|
+
if ((0, _lodashEs.isNumber)(options)) {
|
|
119
|
+
index = options;
|
|
120
|
+
}
|
|
121
|
+
if ((0, _lodashEs.isObject)(options)) {
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
index = options.index;
|
|
124
|
+
}
|
|
125
|
+
options = _datasetUtil["default"].getChildDetails(this.dataSet, options, this.isList);
|
|
126
|
+
return _datasetUtil["default"].addItem(this.dataSet, value, index, options);
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "removeItem",
|
|
130
|
+
value: function removeItem(index, options) {
|
|
131
|
+
var exactMatch, parentIndex;
|
|
132
|
+
if (options) {
|
|
133
|
+
if ((0, _lodashEs.isBoolean)(options)) {
|
|
134
|
+
exactMatch = options;
|
|
135
|
+
}
|
|
136
|
+
if ((0, _lodashEs.isObject)(options)) {
|
|
137
|
+
// @ts-ignore
|
|
138
|
+
exactMatch = options.exactMatch;
|
|
139
|
+
if (this.isList) {
|
|
140
|
+
// @ts-ignore
|
|
141
|
+
parentIndex = options.parentIndex || 0;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return _datasetUtil["default"].removeItem(this.dataSet, index, {
|
|
146
|
+
exactMatch: exactMatch,
|
|
147
|
+
path: (0, _lodashEs.get)(options, "path"),
|
|
148
|
+
parentIndex: parentIndex
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "clearData",
|
|
153
|
+
value: function clearData() {
|
|
154
|
+
this.dataSet = _datasetUtil["default"].getValidDataset(this.isList);
|
|
155
|
+
return this.dataSet;
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
key: "getCount",
|
|
159
|
+
value: function getCount() {
|
|
160
|
+
return _datasetUtil["default"].getCount(this.dataSet, this.isList);
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
key: "pause",
|
|
164
|
+
value: function pause() {}
|
|
165
|
+
}, {
|
|
166
|
+
key: "resume",
|
|
167
|
+
value: function resume() {}
|
|
168
|
+
}, {
|
|
169
|
+
key: "destroy",
|
|
170
|
+
value: function destroy() {}
|
|
171
|
+
}]);
|
|
172
|
+
return BaseVariable;
|
|
173
|
+
}(_eventNotifier["default"]);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WS_CONSTANTS = void 0;
|
|
7
|
+
var WS_CONSTANTS = exports.WS_CONSTANTS = {
|
|
8
|
+
NON_BODY_HTTP_METHODS: ["GET", "HEAD"],
|
|
9
|
+
NON_DATA_AXIOS_METHODS: ["GET", "DELETE", "HEAD", "OPTIONS"],
|
|
10
|
+
CONTENT_TYPES: {
|
|
11
|
+
FORM_URL_ENCODED: "application/x-www-form-urlencoded",
|
|
12
|
+
MULTIPART_FORMDATA: "multipart/form-data",
|
|
13
|
+
OCTET_STREAM: "application/octet-stream"
|
|
14
|
+
},
|
|
15
|
+
REST_SERVICE: {
|
|
16
|
+
ERR_TYPE: {
|
|
17
|
+
METADATA_MISSING: "metadata_missing",
|
|
18
|
+
CRUD_OPERATION_MISSING: "crud_operation_missing",
|
|
19
|
+
USER_UNAUTHORISED: "user_unauthorised"
|
|
20
|
+
},
|
|
21
|
+
ERR_MSG: {
|
|
22
|
+
METADATA_MISSING: 'Metadata missing for "$variable"',
|
|
23
|
+
USER_UNAUTHORISED: "Unauthorized User",
|
|
24
|
+
CRUD_OPERATION_MISSING: 'Operation "$operation" not allowed for "$variable"'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
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 _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
12
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
var _baseVariable = require("./base-variable");
|
|
17
|
+
var _lodashEs = require("lodash-es");
|
|
18
|
+
var _variables = require("@wavemaker/variables");
|
|
19
|
+
var _useHttp = _interopRequireDefault(require("@wavemaker/react-runtime/hooks/useHttp"));
|
|
20
|
+
var _util = require("@wavemaker/react-runtime/core/util");
|
|
21
|
+
var _formatters = _interopRequireDefault(require("@wavemaker/react-runtime/core/formatters"));
|
|
22
|
+
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2["default"])(t); if (r) { var s = (0, _getPrototypeOf2["default"])(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2["default"])(this, e); }; }
|
|
23
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } // @ts-ignore
|
|
24
|
+
var _LiveVariableEvents = /*#__PURE__*/function (_LiveVariableEvents) {
|
|
25
|
+
_LiveVariableEvents["BEFORE_INVOKE"] = "beforeInvoke";
|
|
26
|
+
return _LiveVariableEvents;
|
|
27
|
+
}(_LiveVariableEvents || {});
|
|
28
|
+
var LiveVariable = /*#__PURE__*/function (_LiveVariable3) {
|
|
29
|
+
(0, _inherits2["default"])(LiveVariable, _LiveVariable3);
|
|
30
|
+
var _super = _createSuper(LiveVariable);
|
|
31
|
+
function LiveVariable(config) {
|
|
32
|
+
var _this;
|
|
33
|
+
(0, _classCallCheck2["default"])(this, LiveVariable);
|
|
34
|
+
var variableConfig = {
|
|
35
|
+
name: config.name,
|
|
36
|
+
dataSet: config.paramProvider(),
|
|
37
|
+
inputFields: config.paramProvider(),
|
|
38
|
+
filterExpressions: config.filterExpressions,
|
|
39
|
+
filterFields: config.paramProvider(),
|
|
40
|
+
isList: config.isList,
|
|
41
|
+
maxResults: config.maxResults,
|
|
42
|
+
_context: config._context,
|
|
43
|
+
operation: config.operation,
|
|
44
|
+
type: config.type,
|
|
45
|
+
autoUpdate: config.autoUpdate,
|
|
46
|
+
liveSource: config.liveSource,
|
|
47
|
+
orderBy: config.orderBy,
|
|
48
|
+
category: config.category,
|
|
49
|
+
properties: config.properties,
|
|
50
|
+
propertiesMap: config.propertiesMap,
|
|
51
|
+
tableName: config.tableName,
|
|
52
|
+
tableType: config.tableType,
|
|
53
|
+
relatedTables: config.relatedTables,
|
|
54
|
+
httpClientService: _useHttp["default"],
|
|
55
|
+
inFlightBehavior: config.inFlightBehavior,
|
|
56
|
+
_id: config._id,
|
|
57
|
+
onSuccess: function onSuccess(context, args) {
|
|
58
|
+
_this.notify(_baseVariable.VariableEvents.AFTER_INVOKE, [args.variable, args.data, args.options]);
|
|
59
|
+
_this.notify(_baseVariable.VariableEvents.SUCCESS, [args.variable, args.data, args.options]);
|
|
60
|
+
return config.onSuccess && config.onSuccess(args.variable, args.data, args.options);
|
|
61
|
+
},
|
|
62
|
+
onCanUpdate: function onCanUpdate(context, args) {
|
|
63
|
+
return config.onCanUpdate && config.onCanUpdate(args.variable, args.data, args.options);
|
|
64
|
+
},
|
|
65
|
+
onBeforeUpdate: function onBeforeUpdate(context, args) {
|
|
66
|
+
return config.onBeforeUpdate && config.onBeforeUpdate(args.variable, args.dataFilter || args.inputData, args.options);
|
|
67
|
+
},
|
|
68
|
+
onResult: function onResult(context, args) {
|
|
69
|
+
_this.notify(_baseVariable.VariableEvents.AFTER_INVOKE, [args.variable, args.data, args.options]);
|
|
70
|
+
return config.onResult && config.onResult(args.variable, args.data, args.options);
|
|
71
|
+
},
|
|
72
|
+
onBeforeDatasetReady: function onBeforeDatasetReady(context, args) {
|
|
73
|
+
return config.onBeforeDatasetReady && config.onBeforeDatasetReady(args.variable, args.data, args.options);
|
|
74
|
+
},
|
|
75
|
+
onError: function onError(context, args) {
|
|
76
|
+
_this.notify(_baseVariable.VariableEvents.AFTER_INVOKE, [args.variable, args.data, args.options]);
|
|
77
|
+
_this.notify(_baseVariable.VariableEvents.ERROR, [args.variable, args.data, args.options]);
|
|
78
|
+
return config.onError && config.onError(args.variable, args.data, args.options);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
_this = _super.call(this, variableConfig);
|
|
82
|
+
_this.config = config;
|
|
83
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "params", {});
|
|
84
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "filters", {});
|
|
85
|
+
_this.dateFormatter = _formatters["default"].get("toDate");
|
|
86
|
+
_this.init();
|
|
87
|
+
return _this;
|
|
88
|
+
}
|
|
89
|
+
(0, _createClass2["default"])(LiveVariable, [{
|
|
90
|
+
key: "setFilterExpValue",
|
|
91
|
+
value: function setFilterExpValue(filter) {
|
|
92
|
+
var _this$filterExpressio;
|
|
93
|
+
(_this$filterExpressio = this.filterExpressions) === null || _this$filterExpressio === void 0 || _this$filterExpressio.rules.forEach(function (r) {
|
|
94
|
+
r.value = filter[r.target];
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "invokeOnParamChange",
|
|
99
|
+
value: function invokeOnParamChange() {
|
|
100
|
+
var _this2 = this;
|
|
101
|
+
var last = this.params;
|
|
102
|
+
var latest = this.config.paramProvider();
|
|
103
|
+
if (this.config.operation === "read") {
|
|
104
|
+
var lastFilter = this.filters;
|
|
105
|
+
var latestFilter = this.config.filterProvider && this.config.filterProvider();
|
|
106
|
+
if (!(0, _lodashEs.isEqual)(lastFilter, latestFilter)) {
|
|
107
|
+
this.setFilterExpValue(latestFilter);
|
|
108
|
+
if (this.autoUpdate && !(0, _lodashEs.isEmpty)(latestFilter) && (0, _lodashEs.isFunction)(this.update)) {
|
|
109
|
+
this.filters = latestFilter;
|
|
110
|
+
this.invoke();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (!(0, _lodashEs.isEqual)(last, latest)) {
|
|
115
|
+
if (this.config.operation === "read") {
|
|
116
|
+
(0, _lodashEs.forEach)(latest, function (val, key) {
|
|
117
|
+
_this2.filterFields[key] = {
|
|
118
|
+
value: val
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
this.inputFields = latest;
|
|
123
|
+
}
|
|
124
|
+
/* if auto-update set for the variable with read operation only, get its data */
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
if (this.autoUpdate && !(0, _lodashEs.isUndefined)(latest) && (0, _lodashEs.isFunction)(this[this.config.operation + "Record"])) {
|
|
127
|
+
this.invoke();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return Promise.resolve(this);
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "listRecords",
|
|
134
|
+
value: function listRecords(options, onSuccess, onError) {
|
|
135
|
+
this.notify(_baseVariable.VariableEvents.BEFORE_INVOKE, [this]);
|
|
136
|
+
this.filters = this.config.filterProvider && this.config.filterProvider();
|
|
137
|
+
if (options) {
|
|
138
|
+
this.filters = (0, _util.deepCopy)({}, this.filters, options.filterFields ? options.filterFields : options);
|
|
139
|
+
}
|
|
140
|
+
options = options || {};
|
|
141
|
+
options.filterFields = this.filters;
|
|
142
|
+
this.setFilterExpValue(this.filters);
|
|
143
|
+
return (0, _get2["default"])((0, _getPrototypeOf2["default"])(LiveVariable.prototype), "listRecords", this).call(this, options, onSuccess, onError);
|
|
144
|
+
}
|
|
145
|
+
}, {
|
|
146
|
+
key: "updateRecord",
|
|
147
|
+
value: function updateRecord(options, success, error) {
|
|
148
|
+
this.notify(_baseVariable.VariableEvents.BEFORE_INVOKE, [this]);
|
|
149
|
+
return (0, _get2["default"])((0, _getPrototypeOf2["default"])(LiveVariable.prototype), "updateRecord", this).call(this, options, success, error);
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "insertRecord",
|
|
153
|
+
value: function insertRecord(options, success, error) {
|
|
154
|
+
this.notify(_baseVariable.VariableEvents.BEFORE_INVOKE, [this]);
|
|
155
|
+
return (0, _get2["default"])((0, _getPrototypeOf2["default"])(LiveVariable.prototype), "insertRecord", this).call(this, options, success, error);
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
key: "deleteRecord",
|
|
159
|
+
value: function deleteRecord(options, success, error) {
|
|
160
|
+
this.notify(_baseVariable.VariableEvents.BEFORE_INVOKE, [this]);
|
|
161
|
+
return (0, _get2["default"])((0, _getPrototypeOf2["default"])(LiveVariable.prototype), "deleteRecord", this).call(this, options, success, error);
|
|
162
|
+
}
|
|
163
|
+
}]);
|
|
164
|
+
return LiveVariable;
|
|
165
|
+
}(_variables.LiveVariable);
|
|
166
|
+
var _default = exports["default"] = LiveVariable;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ModelVariable = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
12
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
var _lodashEs = require("lodash-es");
|
|
17
|
+
var _baseVariable = require("./base-variable");
|
|
18
|
+
var _variables = require("@wavemaker/variables");
|
|
19
|
+
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2["default"])(t); if (r) { var s = (0, _getPrototypeOf2["default"])(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2["default"])(this, e); }; }
|
|
20
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
21
|
+
var ModelVariable = exports.ModelVariable = /*#__PURE__*/function (_ModelVariable3) {
|
|
22
|
+
(0, _inherits2["default"])(ModelVariable, _ModelVariable3);
|
|
23
|
+
var _super = _createSuper(ModelVariable);
|
|
24
|
+
function ModelVariable(config) {
|
|
25
|
+
var _this;
|
|
26
|
+
(0, _classCallCheck2["default"])(this, ModelVariable);
|
|
27
|
+
// Initialize with empty dataset first
|
|
28
|
+
var variable = {
|
|
29
|
+
name: config.name,
|
|
30
|
+
dataSet: config.paramProvider() || {
|
|
31
|
+
dataValue: ""
|
|
32
|
+
},
|
|
33
|
+
// Default empty value
|
|
34
|
+
isList: config.isList,
|
|
35
|
+
twoWayBinding: config.twoWayBinding
|
|
36
|
+
};
|
|
37
|
+
_this = _super.call(this, variable);
|
|
38
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "config", void 0);
|
|
39
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "lastParams", void 0);
|
|
40
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "dataSet", void 0);
|
|
41
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "initialized", false);
|
|
42
|
+
_this.config = config;
|
|
43
|
+
_this.invoke();
|
|
44
|
+
return _this;
|
|
45
|
+
}
|
|
46
|
+
(0, _createClass2["default"])(ModelVariable, [{
|
|
47
|
+
key: "invoke",
|
|
48
|
+
value: function invoke(params, onSuccess, onError) {
|
|
49
|
+
var result;
|
|
50
|
+
try {
|
|
51
|
+
this.dataSet = this.config.paramProvider();
|
|
52
|
+
this.notify(_baseVariable.VariableEvents.BEFORE_INVOKE, [this, this.dataSet]);
|
|
53
|
+
result = (0, _get2["default"])((0, _getPrototypeOf2["default"])(ModelVariable.prototype), "execute", this).call(this, params, function () {});
|
|
54
|
+
this.config.onSuccess && this.config.onSuccess(this, this.dataSet);
|
|
55
|
+
onSuccess && onSuccess(this, this.dataSet);
|
|
56
|
+
this.notify(_baseVariable.VariableEvents.SUCCESS, [this, this.dataSet]);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
this.config.onError && this.config.onError(this, this.dataSet);
|
|
59
|
+
onError && onError(this, this.dataSet);
|
|
60
|
+
this.notify(_baseVariable.VariableEvents.ERROR, [this, this.dataSet]);
|
|
61
|
+
}
|
|
62
|
+
this.notify(_baseVariable.VariableEvents.AFTER_INVOKE, [this, this.dataSet]);
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "invokeOnParamChange",
|
|
67
|
+
value: function invokeOnParamChange() {
|
|
68
|
+
var latest = this.config.paramProvider();
|
|
69
|
+
if (!(0, _lodashEs.isEqual)(this.lastParams, latest)) {
|
|
70
|
+
this.invoke();
|
|
71
|
+
this.lastParams = (0, _lodashEs.clone)(latest);
|
|
72
|
+
}
|
|
73
|
+
return Promise.resolve(this);
|
|
74
|
+
}
|
|
75
|
+
}]);
|
|
76
|
+
return ModelVariable;
|
|
77
|
+
}(_variables.ModelVariable);
|