@wavemaker/react-runtime 11.14.1-15.6409
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/base-action.js +32 -0
- package/actions/login-action.js +53 -0
- package/actions/logout-action.js +41 -0
- package/actions/navigation-action.js +145 -0
- package/actions/notification-action.js +147 -0
- package/actions/timer-action.js +164 -0
- package/actions/toast-provider.js +111 -0
- package/actions/toast.js +115 -0
- package/actions/toast.service.js +94 -0
- package/actions/types/index.js +11 -0
- package/components/advanced/carousel/index.js +456 -0
- package/components/advanced/carousel/props.js +5 -0
- package/components/advanced/carousel/template.js +72 -0
- package/components/advanced/login/index.js +307 -0
- package/components/advanced/login/props.js +5 -0
- package/components/advanced/marquee/index.js +158 -0
- package/components/advanced/marquee/props.js +5 -0
- package/components/basic/anchor/index.js +239 -0
- package/components/basic/anchor/props.js +5 -0
- package/components/basic/audio/index.js +61 -0
- package/components/basic/html/index.js +158 -0
- package/components/basic/icon/index.js +85 -0
- package/components/basic/iframe/iframe.utils.js +10 -0
- package/components/basic/iframe/index.js +95 -0
- package/components/basic/label/index.js +139 -0
- package/components/basic/message/index.js +120 -0
- package/components/basic/message/props.js +5 -0
- package/components/basic/picture/index.js +117 -0
- package/components/basic/picture/props.js +5 -0
- package/components/basic/progress-bar/index.js +168 -0
- package/components/basic/progress-bar/props.js +18 -0
- package/components/basic/progress-circle/index.js +196 -0
- package/components/basic/progress-circle/props.js +16 -0
- package/components/basic/richtexteditor/index.js +533 -0
- package/components/basic/richtexteditor/props.js +5 -0
- package/components/basic/search/index.js +1023 -0
- package/components/basic/search/props.js +5 -0
- package/components/basic/search/providers.js +350 -0
- package/components/basic/spinner/index.js +202 -0
- package/components/basic/spinner/props.js +12 -0
- package/components/basic/tile/index.js +91 -0
- package/components/basic/tree/Components/TreeNodeComponent.js +142 -0
- package/components/basic/tree/index.js +503 -0
- package/components/basic/tree/props.js +5 -0
- package/components/basic/tree/utils.js +154 -0
- package/components/basic/video/index.js +85 -0
- package/components/basic/video/props.js +5 -0
- package/components/chart/components/barColumnChart/index.js +132 -0
- package/components/chart/components/barColumnChart/props.js +5 -0
- package/components/chart/components/bubbleChart/index.js +176 -0
- package/components/chart/components/bubbleChart/props.js +5 -0
- package/components/chart/components/chartLegend/components/ClassicLegendItem.js +39 -0
- package/components/chart/components/chartLegend/components/FuriousLegendItem.js +81 -0
- package/components/chart/components/chartLegend/index.js +69 -0
- package/components/chart/components/chartLegend/props.js +5 -0
- package/components/chart/components/chartLegend/utils.js +31 -0
- package/components/chart/components/chartTooltip/index.js +53 -0
- package/components/chart/components/chartTooltip/styles.js +37 -0
- package/components/chart/components/chartTooltip/utils.js +23 -0
- package/components/chart/components/cumulativeLineChart/index.js +113 -0
- package/components/chart/components/cumulativeLineChart/props.js +5 -0
- package/components/chart/components/cumulativeLineChart/utils.js +34 -0
- package/components/chart/components/index.js +40 -0
- package/components/chart/components/lineAreaChart/index.js +140 -0
- package/components/chart/components/lineAreaChart/props.js +5 -0
- package/components/chart/components/noDataMessage/index.js +27 -0
- package/components/chart/components/pieDonutChart/index.js +171 -0
- package/components/chart/components/pieDonutChart/props.js +5 -0
- package/components/chart/constant.js +72 -0
- package/components/chart/index.js +930 -0
- package/components/chart/props.js +5 -0
- package/components/chart/utils.js +691 -0
- package/components/common/AppSpinner.js +36 -0
- package/components/common/app-spinner.js +26 -0
- package/components/common/index.js +12 -0
- package/components/constants.js +1208 -0
- package/components/container/accordion/accordion-pane/index.js +108 -0
- package/components/container/accordion/accordion-pane/props.js +11 -0
- package/components/container/accordion/index.js +232 -0
- package/components/container/accordion/props.js +13 -0
- package/components/container/alignment-utils.js +183 -0
- package/components/container/index.js +188 -0
- package/components/container/layout-grid/grid-column/index.js +34 -0
- package/components/container/layout-grid/grid-row/index.js +24 -0
- package/components/container/layout-grid/index.js +33 -0
- package/components/container/linear-layout/index.js +72 -0
- package/components/container/linear-layout/linear-layout-item/index.js +43 -0
- package/components/container/panel/components/panel-header/index.js +144 -0
- package/components/container/panel/components/panel-header/props.js +5 -0
- package/components/container/panel/hooks.js +144 -0
- package/components/container/panel/index.js +286 -0
- package/components/container/panel/props.js +5 -0
- package/components/container/props.js +5 -0
- package/components/container/tabs/index.js +379 -0
- package/components/container/tabs/props.js +20 -0
- package/components/container/tabs/tab-pane/index.js +42 -0
- package/components/container/tabs/tab-pane/props.js +5 -0
- package/components/container/wizard/WizardContext.js +16 -0
- package/components/container/wizard/components/StepComponents.js +100 -0
- package/components/container/wizard/components/WizardStep.js +89 -0
- package/components/container/wizard/index.js +710 -0
- package/components/container/wizard/props.js +5 -0
- package/components/container/wizard/utils.js +133 -0
- package/components/container/wizard/wizard-action/index.js +22 -0
- package/components/container/wizard/wizard-step/index.js +94 -0
- package/components/data/card/card-actions/index.js +24 -0
- package/components/data/card/card-content/index.js +38 -0
- package/components/data/card/card-footer/index.js +24 -0
- package/components/data/card/index.js +246 -0
- package/components/data/card/props.js +5 -0
- package/components/data/form/base-form/constant.js +39 -0
- package/components/data/form/base-form/index.js +460 -0
- package/components/data/form/base-form/props.js +29 -0
- package/components/data/form/base-form/utils.js +42 -0
- package/components/data/form/dynamic-fields/index.js +196 -0
- package/components/data/form/dynamic-fields/props.js +5 -0
- package/components/data/form/dynamic-fields/utils.js +237 -0
- package/components/data/form/form-action/index.js +71 -0
- package/components/data/form/form-body/index.js +26 -0
- package/components/data/form/form-context.js +34 -0
- package/components/data/form/form-controller/props.js +19 -0
- package/components/data/form/form-controller/validation-contrustor.js +313 -0
- package/components/data/form/form-controller/withFormController.js +320 -0
- package/components/data/form/form-field/base-field.js +138 -0
- package/components/data/form/form-field/index.js +36 -0
- package/components/data/form/form-field/props.js +5 -0
- package/components/data/form/form-footer/index.js +26 -0
- package/components/data/form/form-header/index.js +56 -0
- package/components/data/form/index.js +39 -0
- package/components/data/form/props.js +5 -0
- package/components/data/list/components/GroupHeader.js +35 -0
- package/components/data/list/components/GroupedListItems.js +98 -0
- package/components/data/list/components/ListContainer.js +27 -0
- package/components/data/list/components/ListDND.js +241 -0
- package/components/data/list/components/ListHeader.js +59 -0
- package/components/data/list/components/ListItem.js +148 -0
- package/components/data/list/components/ListItemWithTemplate.js +59 -0
- package/components/data/list/components/ListItems.js +231 -0
- package/components/data/list/components/ListPagination.js +165 -0
- package/components/data/list/components/LoadMoreButton.js +39 -0
- package/components/data/list/components/NoDataMessage.js +22 -0
- package/components/data/list/components/StandardListItems.js +84 -0
- package/components/data/list/components/index.js +119 -0
- package/components/data/list/components/props.js +5 -0
- package/components/data/list/hooks/index.js +75 -0
- package/components/data/list/hooks/props.js +5 -0
- package/components/data/list/hooks/useCurrentPageItems.js +48 -0
- package/components/data/list/hooks/useGroupedData.js +37 -0
- package/components/data/list/hooks/useListData.js +60 -0
- package/components/data/list/hooks/useListEffects.js +285 -0
- package/components/data/list/hooks/useListEventHandlers.js +291 -0
- package/components/data/list/hooks/useListPagination.js +168 -0
- package/components/data/list/hooks/useListState.js +98 -0
- package/components/data/list/hooks/useListStateManager.js +195 -0
- package/components/data/list/hooks/usePaginatedGroupedData.js +121 -0
- package/components/data/list/index.js +611 -0
- package/components/data/list/props.js +5 -0
- package/components/data/list/templates/media-template.js +53 -0
- package/components/data/list/utils/constants.js +81 -0
- package/components/data/list/utils/list-helpers.js +173 -0
- package/components/data/list/utils/list-widget-methods.js +114 -0
- package/components/data/live-filter/index.js +279 -0
- package/components/data/live-filter/props.js +12 -0
- package/components/data/live-form/index.js +93 -0
- package/components/data/live-form/props.js +16 -0
- package/components/data/pagination/components/BasicPagination.js +77 -0
- package/components/data/pagination/components/ClassicPagination.js +191 -0
- package/components/data/pagination/components/InlinePagination.js +99 -0
- package/components/data/pagination/components/LoadingComponent.js +31 -0
- package/components/data/pagination/components/PageSizeSelector.js +175 -0
- package/components/data/pagination/components/PagerNavigation.js +105 -0
- package/components/data/pagination/components/TotalRecords.js +52 -0
- package/components/data/pagination/components/index.js +47 -0
- package/components/data/pagination/components/props.js +5 -0
- package/components/data/pagination/hooks/index.js +19 -0
- package/components/data/pagination/hooks/props.js +5 -0
- package/components/data/pagination/hooks/useNavigationSize.js +44 -0
- package/components/data/pagination/hooks/usePagination.js +796 -0
- package/components/data/pagination/index.js +322 -0
- package/components/data/table/components/AddNewRow.js +190 -0
- package/components/data/table/components/EditableCell.js +91 -0
- package/components/data/table/components/FieldValidationError.js +24 -0
- package/components/data/table/components/RowExpansionButton.js +74 -0
- package/components/data/table/components/TableBody.js +279 -0
- package/components/data/table/components/TableFilters.js +325 -0
- package/components/data/table/components/TableFooterActions.js +48 -0
- package/components/data/table/components/TableHeader.js +174 -0
- package/components/data/table/components/TablePanelHeading.js +68 -0
- package/components/data/table/components/index.js +74 -0
- package/components/data/table/hooks/index.js +219 -0
- package/components/data/table/hooks/useCellState.js +117 -0
- package/components/data/table/hooks/useDynamicColumns.js +85 -0
- package/components/data/table/hooks/useEditingState.js +47 -0
- package/components/data/table/hooks/useFormWidget.js +184 -0
- package/components/data/table/hooks/usePaginationState.js +60 -0
- package/components/data/table/hooks/usePanelStructure.js +40 -0
- package/components/data/table/hooks/useResponsiveColumns.js +34 -0
- package/components/data/table/hooks/useRowExpansion.js +110 -0
- package/components/data/table/hooks/useRowHandlers.js +38 -0
- package/components/data/table/hooks/useRowSelection.js +213 -0
- package/components/data/table/hooks/useServerSideSorting.js +165 -0
- package/components/data/table/hooks/useTableColumns.js +263 -0
- package/components/data/table/hooks/useTableData.js +154 -0
- package/components/data/table/hooks/useTableEdit.js +467 -0
- package/components/data/table/hooks/useTableEffects.js +139 -0
- package/components/data/table/hooks/useTableFilter.js +389 -0
- package/components/data/table/hooks/useTableInitialization.js +103 -0
- package/components/data/table/hooks/useTableState.js +69 -0
- package/components/data/table/hooks/useTableStateManager.js +558 -0
- package/components/data/table/index.js +1295 -0
- package/components/data/table/live-table/index.js +232 -0
- package/components/data/table/props.js +5 -0
- package/components/data/table/table-action/index.js +78 -0
- package/components/data/table/table-column/index.js +35 -0
- package/components/data/table/table-row/index.js +49 -0
- package/components/data/table/table-row-action/index.js +74 -0
- package/components/data/table/utils/buildSelectionColumns.js +173 -0
- package/components/data/table/utils/columnBuilder.js +209 -0
- package/components/data/table/utils/columnProxy.js +48 -0
- package/components/data/table/utils/columnWidthDistribution.js +98 -0
- package/components/data/table/utils/constants.js +80 -0
- package/components/data/table/utils/crud-handlers.js +518 -0
- package/components/data/table/utils/dynamic-columns.js +118 -0
- package/components/data/table/utils/index.js +607 -0
- package/components/data/table/utils/renderDisplayCell.js +183 -0
- package/components/data/table/utils/selectionUtils.js +166 -0
- package/components/data/table/utils/table-helpers.js +100 -0
- package/components/data/table/utils/validation.js +124 -0
- package/components/data/types.js +113 -0
- package/components/data/utils/field-data-utils.js +66 -0
- package/components/data/utils/filter-field-util.js +81 -0
- package/components/data/utils/index.js +216 -0
- package/components/dialogs/alert-dialog/index.js +80 -0
- package/components/dialogs/confirm-dialog/index.js +105 -0
- package/components/dialogs/dialog/index.js +56 -0
- package/components/dialogs/dialog-actions/index.js +18 -0
- package/components/dialogs/dialog-body/index.js +21 -0
- package/components/dialogs/dialog-content/index.js +30 -0
- package/components/dialogs/dialog-header/index.js +93 -0
- package/components/dialogs/iframe-dialog/index.js +114 -0
- package/components/dialogs/index.js +129 -0
- package/components/dialogs/login-dialog/index.js +369 -0
- package/components/dialogs/login-dialog/props.js +5 -0
- package/components/dialogs/page-dialog/index.js +96 -0
- package/components/dialogs/withDialogWrapper.js +108 -0
- package/components/form/button/index.js +216 -0
- package/components/form/button-group/index.js +60 -0
- package/components/input/calendar/index.js +546 -0
- package/components/input/calendar/props.js +5 -0
- package/components/input/calendar/utils.js +340 -0
- package/components/input/chips/SortableChip/index.js +115 -0
- package/components/input/chips/SortableChip/props.js +5 -0
- package/components/input/chips/index.js +488 -0
- package/components/input/chips/props.js +5 -0
- package/components/input/chips/utils.js +259 -0
- package/components/input/color-picker/index.js +678 -0
- package/components/input/color-picker/props.js +5 -0
- package/components/input/composite/index.js +137 -0
- package/components/input/currency/index.js +263 -0
- package/components/input/currency/props.js +5 -0
- package/components/input/default/checkbox/index.js +230 -0
- package/components/input/default/checkbox/props.js +5 -0
- package/components/input/default/checkboxset/index.js +476 -0
- package/components/input/default/checkboxset/props.js +5 -0
- package/components/input/default/radioset/index.js +379 -0
- package/components/input/default/radioset/props.js +5 -0
- package/components/input/default/switch/index.js +490 -0
- package/components/input/default/switch/prop.js +5 -0
- package/components/input/epoch/date/components/DatePickerPopover.js +220 -0
- package/components/input/epoch/date/index.js +520 -0
- package/components/input/epoch/date/props.js +5 -0
- package/components/input/epoch/date/styled.js +70 -0
- package/components/input/epoch/date/utils.js +108 -0
- package/components/input/epoch/datetime/index.js +656 -0
- package/components/input/epoch/datetime/props.js +5 -0
- package/components/input/epoch/datetime/styled.js +90 -0
- package/components/input/epoch/datetime/utils.js +244 -0
- package/components/input/epoch/time/index.js +412 -0
- package/components/input/epoch/time/props.js +5 -0
- package/components/input/epoch/time/utils.js +209 -0
- package/components/input/fileupload/Utils.js +134 -0
- package/components/input/fileupload/components/ListItems.js +140 -0
- package/components/input/fileupload/components/MultiUpload.js +85 -0
- package/components/input/fileupload/components/SingleUpload.js +65 -0
- package/components/input/fileupload/index.js +170 -0
- package/components/input/fileupload/props.js +5 -0
- package/components/input/fileupload/useFileUpload.js +400 -0
- package/components/input/number/index.js +295 -0
- package/components/input/number/props.js +5 -0
- package/components/input/rating/index.js +368 -0
- package/components/input/rating/props.js +5 -0
- package/components/input/select/index.js +344 -0
- package/components/input/select/props.js +5 -0
- package/components/input/slider/index.js +167 -0
- package/components/input/slider/props.js +5 -0
- package/components/input/text/index.js +434 -0
- package/components/input/text/props.js +5 -0
- package/components/input/text/util.js +179 -0
- package/components/input/textarea/index.js +347 -0
- package/components/input/textarea/props.js +5 -0
- package/components/layout/footer/index.js +30 -0
- package/components/layout/header/index.js +30 -0
- package/components/layout/leftnav/index.js +44 -0
- package/components/layout/rightnav/index.js +32 -0
- package/components/layout/topnav/index.js +34 -0
- package/components/navbar/index.js +41 -0
- package/components/navbar/nav/index.js +102 -0
- package/components/navbar/nav/props.js +5 -0
- package/components/navbar/nav-item/index.js +44 -0
- package/components/navigation/breadcrumb/index.js +56 -0
- package/components/navigation/breadcrumb/props.js +5 -0
- package/components/navigation/menu/components/ListItems.js +66 -0
- package/components/navigation/menu/constants.js +101 -0
- package/components/navigation/menu/index.js +807 -0
- package/components/navigation/menu/props.js +5 -0
- package/components/navigation/popover/index.js +209 -0
- package/components/navigation/popover/props.js +15 -0
- package/components/page/content/index.js +28 -0
- package/components/page/error-boundary/index.js +108 -0
- package/components/page/index.js +137 -0
- package/components/page/page-content/index.js +23 -0
- package/components/page/partial/index.js +36 -0
- package/components/page/partial-container/index.js +48 -0
- package/components/page/props.js +5 -0
- package/components/page/toast-container/index.js +33 -0
- package/components/prefab/container/index.js +46 -0
- package/components/prefab/index.js +67 -0
- package/context/AppContext.js +25 -0
- package/context/AppSpinnerProvider.js +43 -0
- package/context/LocalizationProvider.js +79 -0
- package/context/PrefabContext.js +66 -0
- package/context/WidgetProvider.js +187 -0
- package/core/app-config.js +1 -0
- package/core/app.service.js +357 -0
- package/core/appVariablesStore.js +20 -0
- package/core/appstore.js +88 -0
- package/core/constants/currency-constant.js +1071 -0
- package/core/constants/events.js +34 -0
- package/core/constants/index.js +27 -0
- package/core/dialog.service.js +76 -0
- package/core/event-notifier.js +151 -0
- package/core/formatter/date-formatters.js +222 -0
- package/core/formatter/index.js +131 -0
- package/core/formatter/number-formatters.js +142 -0
- package/core/formatter/security-formatters.js +323 -0
- package/core/formatter/string-formatters.js +52 -0
- package/core/formatter/types.js +18 -0
- package/core/formatters.js +24 -0
- package/core/proxy-service.js +412 -0
- package/core/script-registry.js +63 -0
- package/core/security.service.js +11 -0
- package/core/util/common.js +33 -0
- package/core/util/dom.js +107 -0
- package/core/util/index.js +136 -0
- package/core/util/security.js +184 -0
- package/core/util/utils.js +189 -0
- package/core/widget-observer.js +98 -0
- package/higherOrder/BaseApp.js +430 -0
- package/higherOrder/BaseAppProps.js +5 -0
- package/higherOrder/BaseDateTime.js +251 -0
- package/higherOrder/BasePage.js +715 -0
- package/higherOrder/BasePartial.js +124 -0
- package/higherOrder/BasePrefab.js +145 -0
- package/higherOrder/DataNav.js +377 -0
- package/higherOrder/helper.js +43 -0
- package/higherOrder/props.js +5 -0
- package/higherOrder/withBaseWrapper.js +183 -0
- package/hooks/useAccess.js +308 -0
- package/hooks/useAppConfig.js +42 -0
- package/hooks/useAuth.js +562 -0
- package/hooks/useDataSourceSubscription.js +125 -0
- package/hooks/useDebounce.js +76 -0
- package/hooks/useDeviceVisibility.js +49 -0
- package/hooks/useHttp.js +338 -0
- package/libs/index.js +20 -0
- package/mui-config/theme-provider.js +17 -0
- package/mui-config/theme.js +371 -0
- package/package-lock.json +10177 -0
- package/package.json +95 -0
- package/store/index.js +33 -0
- package/store/middleware/navigationMiddleware.js +48 -0
- package/store/slices/appConfigSlice.js +103 -0
- package/store/slices/authSlice.js +508 -0
- package/store/slices/i18nSlice.js +206 -0
- package/types/index.js +15 -0
- package/utils/dataset-util.js +174 -0
- package/utils/eval-expression.js +32 -0
- package/utils/form-state.util.js +140 -0
- package/utils/form-utils.js +187 -0
- package/utils/format-util.js +260 -0
- package/utils/page-params-util.js +24 -0
- package/utils/resource-url.js +27 -0
- package/utils/state-persistance.js +343 -0
- package/utils/style-utils.js +73 -0
- package/utils/transformedDataset-utils.js +633 -0
- package/utils/widget-cleanup-util.js +84 -0
- package/utils/widgets.js +99 -0
- package/variables/base-variable.js +173 -0
- package/variables/constants.js +27 -0
- package/variables/live-variable.js +166 -0
- package/variables/model-variable.js +77 -0
- package/variables/service-variable.js +307 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useToast = exports.ToastProvider = exports.ToastPortal = void 0;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
12
|
+
var _types = require("@wavemaker/react-runtime/actions/types");
|
|
13
|
+
var _toast = require("@wavemaker/react-runtime/actions/toast.service");
|
|
14
|
+
var _toast2 = _interopRequireDefault(require("@wavemaker/react-runtime/actions/toast"));
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
16
|
+
var __jsx = _react["default"].createElement;
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
19
|
+
// toast context
|
|
20
|
+
var ToastContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
21
|
+
|
|
22
|
+
// custom hook to use the toast context
|
|
23
|
+
var useToast = exports.useToast = function useToast() {
|
|
24
|
+
var context = (0, _react.useContext)(ToastContext);
|
|
25
|
+
if (!context) {
|
|
26
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
27
|
+
}
|
|
28
|
+
return context;
|
|
29
|
+
};
|
|
30
|
+
var ToastPortal = exports.ToastPortal = function ToastPortal(_ref) {
|
|
31
|
+
var toast = _ref.toast,
|
|
32
|
+
_onClose = _ref.onClose;
|
|
33
|
+
var containerRef = (0, _react.useRef)(null);
|
|
34
|
+
(0, _react.useEffect)(function () {
|
|
35
|
+
// Lazy initialization - only create the container if it doesn't exist
|
|
36
|
+
if (!containerRef.current) {
|
|
37
|
+
var element = document.getElementById(_types.TOAST_CONFIG.CONTAINER_ID);
|
|
38
|
+
if (!element) {
|
|
39
|
+
element = document.createElement("div");
|
|
40
|
+
element.id = _types.TOAST_CONFIG.CONTAINER_ID;
|
|
41
|
+
document.body.appendChild(element);
|
|
42
|
+
}
|
|
43
|
+
containerRef.current = element;
|
|
44
|
+
}
|
|
45
|
+
return function () {
|
|
46
|
+
if (containerRef.current && document.body.contains(containerRef.current)) {
|
|
47
|
+
document.body.removeChild(containerRef.current);
|
|
48
|
+
containerRef.current = null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
if (!toast) return null;
|
|
53
|
+
return containerRef.current ? /*#__PURE__*/_reactDom["default"].createPortal(__jsx(_toast2["default"], {
|
|
54
|
+
key: toast.id,
|
|
55
|
+
toast: toast,
|
|
56
|
+
onClose: function onClose() {
|
|
57
|
+
return _onClose(toast.id);
|
|
58
|
+
}
|
|
59
|
+
}), containerRef.current) : null;
|
|
60
|
+
};
|
|
61
|
+
var ToastProvider = exports.ToastProvider = function ToastProvider(_ref2) {
|
|
62
|
+
var children = _ref2.children;
|
|
63
|
+
var _useState = (0, _react.useState)(null),
|
|
64
|
+
toast = _useState[0],
|
|
65
|
+
setToast = _useState[1];
|
|
66
|
+
var showToast = function showToast(options) {
|
|
67
|
+
var id = "toast-".concat(Date.now(), "-").concat(Math.random().toString(36).substring(2, 9));
|
|
68
|
+
var newToast = _objectSpread(_objectSpread({}, options), {}, {
|
|
69
|
+
id: id
|
|
70
|
+
});
|
|
71
|
+
setToast(newToast);
|
|
72
|
+
var duration = typeof options.duration === "number" ? options.duration : options.type === "success" ? _types.TOAST_CONFIG.DEFAULT_DURATION : 0;
|
|
73
|
+
if (duration > 0) {
|
|
74
|
+
setTimeout(function () {
|
|
75
|
+
hideToast(id);
|
|
76
|
+
}, duration);
|
|
77
|
+
}
|
|
78
|
+
return id;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Hide toast function
|
|
82
|
+
var hideToast = function hideToast(id) {
|
|
83
|
+
if (typeof (toast === null || toast === void 0 ? void 0 : toast.onClose) === "function") {
|
|
84
|
+
toast.onClose();
|
|
85
|
+
}
|
|
86
|
+
setToast(null);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Hide all toasts function
|
|
90
|
+
var hideAllToasts = function hideAllToasts() {
|
|
91
|
+
if (typeof (toast === null || toast === void 0 ? void 0 : toast.onClose) === "function") {
|
|
92
|
+
toast.onClose();
|
|
93
|
+
}
|
|
94
|
+
setToast(null);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// Create context value with memoization
|
|
98
|
+
var contextValue = (0, _react.useMemo)(function () {
|
|
99
|
+
return {
|
|
100
|
+
showToast: showToast,
|
|
101
|
+
hideToast: hideToast,
|
|
102
|
+
hideAllToasts: hideAllToasts
|
|
103
|
+
};
|
|
104
|
+
}, []);
|
|
105
|
+
return __jsx(ToastContext.Provider, {
|
|
106
|
+
value: contextValue
|
|
107
|
+
}, __jsx(_toast.ToastInitializer, null, children, __jsx(ToastPortal, {
|
|
108
|
+
toast: toast,
|
|
109
|
+
onClose: hideToast
|
|
110
|
+
})));
|
|
111
|
+
};
|
package/actions/toast.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
12
|
+
var _clsx2 = _interopRequireDefault(require("clsx"));
|
|
13
|
+
var _Snackbar = _interopRequireDefault(require("@mui/material/Snackbar"));
|
|
14
|
+
var _toastContainer = _interopRequireDefault(require("@wavemaker/react-runtime/components/page/toast-container"));
|
|
15
|
+
var _types = require("@wavemaker/react-runtime/actions/types");
|
|
16
|
+
var __jsx = _react["default"].createElement;
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
19
|
+
var GET_POSITION = function GET_POSITION(position) {
|
|
20
|
+
var _position$split = position.split(" "),
|
|
21
|
+
_position$split2 = (0, _slicedToArray2["default"])(_position$split, 2),
|
|
22
|
+
vertical = _position$split2[0],
|
|
23
|
+
horizontal = _position$split2[1];
|
|
24
|
+
return {
|
|
25
|
+
vertical: vertical === "bottom" ? "bottom" : "top",
|
|
26
|
+
horizontal: horizontal === "right" ? "right" : horizontal === "left" ? "left" : "center"
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
var CustomToast = function CustomToast(_ref) {
|
|
30
|
+
var toast = _ref.toast,
|
|
31
|
+
onClose = _ref.onClose;
|
|
32
|
+
var text = toast.text,
|
|
33
|
+
_toast$type = toast.type,
|
|
34
|
+
type = _toast$type === void 0 ? "info" : _toast$type,
|
|
35
|
+
_toast$position = toast.position,
|
|
36
|
+
position = _toast$position === void 0 ? toast.placement || _types.TOAST_CONFIG.DEFAULT_POSITION : _toast$position,
|
|
37
|
+
onClick = toast.onClick;
|
|
38
|
+
var ispage = toast.content && (0, _typeof2["default"])(toast.content) === "object";
|
|
39
|
+
var handleClick = function handleClick(e) {
|
|
40
|
+
if (onClick) {
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
try {
|
|
43
|
+
onClick();
|
|
44
|
+
} catch (err) {
|
|
45
|
+
console.error("Error in toast onClick callback:", err);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
onClose();
|
|
49
|
+
};
|
|
50
|
+
var handleClose = function handleClose(event, reason) {
|
|
51
|
+
if (reason === "clickaway") return;
|
|
52
|
+
onClose && onClose();
|
|
53
|
+
};
|
|
54
|
+
var anchorOrigin = GET_POSITION(position);
|
|
55
|
+
if (ispage && toast.content !== undefined) {
|
|
56
|
+
return __jsx(_Snackbar["default"], {
|
|
57
|
+
open: true,
|
|
58
|
+
onClose: handleClose,
|
|
59
|
+
anchorOrigin: anchorOrigin,
|
|
60
|
+
message: null,
|
|
61
|
+
TransitionProps: {
|
|
62
|
+
appear: false,
|
|
63
|
+
style: {
|
|
64
|
+
transition: "ease-in-out 0.3s"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
onClick: handleClick
|
|
68
|
+
}, __jsx(_toastContainer["default"], {
|
|
69
|
+
component: toast.content.component
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
var positions = ["top center", "bottom center"];
|
|
73
|
+
return __jsx(_Snackbar["default"], {
|
|
74
|
+
open: true,
|
|
75
|
+
onClose: handleClose,
|
|
76
|
+
anchorOrigin: anchorOrigin,
|
|
77
|
+
autoHideDuration: toast.duration,
|
|
78
|
+
className: (0, _clsx2["default"])("toast-container", (0, _defineProperty2["default"])({}, "toast-".concat(position.replaceAll(" ", "-")), !positions.includes(position))),
|
|
79
|
+
disableWindowBlurListener: true,
|
|
80
|
+
message: __jsx("div", {
|
|
81
|
+
className: "toast-title"
|
|
82
|
+
}, type.toUpperCase(), __jsx("div", {
|
|
83
|
+
className: "toast-message"
|
|
84
|
+
}, text)),
|
|
85
|
+
TransitionProps: {
|
|
86
|
+
appear: false
|
|
87
|
+
},
|
|
88
|
+
onClick: handleClick,
|
|
89
|
+
sx: {
|
|
90
|
+
"& .MuiSnackbarContent-root": {
|
|
91
|
+
alignItems: "unset !important"
|
|
92
|
+
},
|
|
93
|
+
"& .MuiSnackbar-root": {
|
|
94
|
+
all: "unset !important"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
style: _objectSpread(_objectSpread({}, position === "top center" && {
|
|
98
|
+
top: "var(--wm-toast-position-top)"
|
|
99
|
+
}), position === "bottom center" && {
|
|
100
|
+
bottom: "var(--wm-toast-position-bottom)"
|
|
101
|
+
}),
|
|
102
|
+
ContentProps: {
|
|
103
|
+
sx: {
|
|
104
|
+
"& .MuiSnackbarContent-message": {
|
|
105
|
+
all: "unset"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
style: _objectSpread({}, position === "center center" && {
|
|
109
|
+
transform: "translateX(50%)"
|
|
110
|
+
}),
|
|
111
|
+
className: "toast toast-".concat(type, " ")
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
var _default = exports["default"] = CustomToast;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.toastService = exports.ToastInitializer = void 0;
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _toastProvider = require("./toast-provider");
|
|
14
|
+
var _ToastService;
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
16
|
+
var __jsx = _react["default"].createElement;
|
|
17
|
+
var ToastService = /*#__PURE__*/function () {
|
|
18
|
+
function ToastService() {
|
|
19
|
+
(0, _classCallCheck2["default"])(this, ToastService);
|
|
20
|
+
(0, _defineProperty2["default"])(this, "context", null);
|
|
21
|
+
(0, _defineProperty2["default"])(this, "activeToasts", new Map());
|
|
22
|
+
if (ToastService.instance) {
|
|
23
|
+
return ToastService.instance;
|
|
24
|
+
}
|
|
25
|
+
this.showToast = this.showToast.bind(this);
|
|
26
|
+
this.hideToast = this.hideToast.bind(this);
|
|
27
|
+
this.hideAllToasts = this.hideAllToasts.bind(this);
|
|
28
|
+
this.setContext = this.setContext.bind(this);
|
|
29
|
+
ToastService.instance = this;
|
|
30
|
+
}
|
|
31
|
+
(0, _createClass2["default"])(ToastService, [{
|
|
32
|
+
key: "setContext",
|
|
33
|
+
value: function setContext(context) {
|
|
34
|
+
this.context = context;
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "showToast",
|
|
38
|
+
value: function showToast(options) {
|
|
39
|
+
if (!this.context) {
|
|
40
|
+
console.warn("Toast service used before context is set. Make sure ToastProvider is mounted.");
|
|
41
|
+
return "error";
|
|
42
|
+
}
|
|
43
|
+
this.hideAllToasts();
|
|
44
|
+
var id = this.context.showToast(options);
|
|
45
|
+
|
|
46
|
+
// Track the toast
|
|
47
|
+
this.activeToasts.set(id, {
|
|
48
|
+
onClose: options.onClose
|
|
49
|
+
});
|
|
50
|
+
return id;
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "hideToast",
|
|
54
|
+
value: function hideToast(id) {
|
|
55
|
+
if (!this.context) return;
|
|
56
|
+
var toastData = this.activeToasts.get(id);
|
|
57
|
+
if (toastData) {
|
|
58
|
+
if (toastData.timeoutId) {
|
|
59
|
+
clearTimeout(toastData.timeoutId);
|
|
60
|
+
}
|
|
61
|
+
this.activeToasts["delete"](id);
|
|
62
|
+
}
|
|
63
|
+
this.context.hideToast(id);
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "hideAllToasts",
|
|
67
|
+
value: function hideAllToasts() {
|
|
68
|
+
if (!this.context) return;
|
|
69
|
+
this.activeToasts.forEach(function (data) {
|
|
70
|
+
if (data.timeoutId) {
|
|
71
|
+
clearTimeout(data.timeoutId);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
this.activeToasts.clear();
|
|
75
|
+
this.context.hideAllToasts();
|
|
76
|
+
}
|
|
77
|
+
}]);
|
|
78
|
+
return ToastService;
|
|
79
|
+
}(); // Create singleton instance
|
|
80
|
+
_ToastService = ToastService;
|
|
81
|
+
(0, _defineProperty2["default"])(ToastService, "instance", void 0);
|
|
82
|
+
var toastService = exports.toastService = new ToastService();
|
|
83
|
+
var ToastInitializer = exports.ToastInitializer = function ToastInitializer(_ref) {
|
|
84
|
+
var children = _ref.children;
|
|
85
|
+
var toast = (0, _toastProvider.useToast)();
|
|
86
|
+
(0, _react.useEffect)(function () {
|
|
87
|
+
toastService.setContext(toast);
|
|
88
|
+
return function () {
|
|
89
|
+
// Clear context reference
|
|
90
|
+
toastService.setContext(null);
|
|
91
|
+
};
|
|
92
|
+
}, [toast]);
|
|
93
|
+
return __jsx(_react["default"].Fragment, null, children);
|
|
94
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TOAST_CONFIG = void 0;
|
|
7
|
+
var TOAST_CONFIG = exports.TOAST_CONFIG = {
|
|
8
|
+
CONTAINER_ID: "mui-toast-container",
|
|
9
|
+
DEFAULT_DURATION: 3000,
|
|
10
|
+
DEFAULT_POSITION: "bottom right"
|
|
11
|
+
};
|