@wavemaker/react-runtime 11.14.1-16.6404
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/base-action.js +32 -0
- package/actions/login-action.js +53 -0
- package/actions/logout-action.js +41 -0
- package/actions/navigation-action.js +145 -0
- package/actions/notification-action.js +147 -0
- package/actions/timer-action.js +164 -0
- package/actions/toast-provider.js +111 -0
- package/actions/toast.js +115 -0
- package/actions/toast.service.js +94 -0
- package/actions/types/index.js +11 -0
- package/components/advanced/carousel/index.js +456 -0
- package/components/advanced/carousel/props.js +5 -0
- package/components/advanced/carousel/template.js +72 -0
- package/components/advanced/login/index.js +307 -0
- package/components/advanced/login/props.js +5 -0
- package/components/advanced/marquee/index.js +158 -0
- package/components/advanced/marquee/props.js +5 -0
- package/components/basic/anchor/index.js +239 -0
- package/components/basic/anchor/props.js +5 -0
- package/components/basic/audio/index.js +61 -0
- package/components/basic/html/index.js +158 -0
- package/components/basic/icon/index.js +85 -0
- package/components/basic/iframe/iframe.utils.js +10 -0
- package/components/basic/iframe/index.js +95 -0
- package/components/basic/label/index.js +139 -0
- package/components/basic/message/index.js +120 -0
- package/components/basic/message/props.js +5 -0
- package/components/basic/picture/index.js +117 -0
- package/components/basic/picture/props.js +5 -0
- package/components/basic/progress-bar/index.js +168 -0
- package/components/basic/progress-bar/props.js +18 -0
- package/components/basic/progress-circle/index.js +196 -0
- package/components/basic/progress-circle/props.js +16 -0
- package/components/basic/richtexteditor/index.js +533 -0
- package/components/basic/richtexteditor/props.js +5 -0
- package/components/basic/search/index.js +1023 -0
- package/components/basic/search/props.js +5 -0
- package/components/basic/search/providers.js +350 -0
- package/components/basic/spinner/index.js +202 -0
- package/components/basic/spinner/props.js +12 -0
- package/components/basic/tile/index.js +91 -0
- package/components/basic/tree/Components/TreeNodeComponent.js +142 -0
- package/components/basic/tree/index.js +503 -0
- package/components/basic/tree/props.js +5 -0
- package/components/basic/tree/utils.js +154 -0
- package/components/basic/video/index.js +85 -0
- package/components/basic/video/props.js +5 -0
- package/components/chart/components/barColumnChart/index.js +132 -0
- package/components/chart/components/barColumnChart/props.js +5 -0
- package/components/chart/components/bubbleChart/index.js +176 -0
- package/components/chart/components/bubbleChart/props.js +5 -0
- package/components/chart/components/chartLegend/components/ClassicLegendItem.js +39 -0
- package/components/chart/components/chartLegend/components/FuriousLegendItem.js +81 -0
- package/components/chart/components/chartLegend/index.js +69 -0
- package/components/chart/components/chartLegend/props.js +5 -0
- package/components/chart/components/chartLegend/utils.js +31 -0
- package/components/chart/components/chartTooltip/index.js +53 -0
- package/components/chart/components/chartTooltip/styles.js +37 -0
- package/components/chart/components/chartTooltip/utils.js +23 -0
- package/components/chart/components/cumulativeLineChart/index.js +113 -0
- package/components/chart/components/cumulativeLineChart/props.js +5 -0
- package/components/chart/components/cumulativeLineChart/utils.js +34 -0
- package/components/chart/components/index.js +40 -0
- package/components/chart/components/lineAreaChart/index.js +140 -0
- package/components/chart/components/lineAreaChart/props.js +5 -0
- package/components/chart/components/noDataMessage/index.js +27 -0
- package/components/chart/components/pieDonutChart/index.js +171 -0
- package/components/chart/components/pieDonutChart/props.js +5 -0
- package/components/chart/constant.js +72 -0
- package/components/chart/index.js +930 -0
- package/components/chart/props.js +5 -0
- package/components/chart/utils.js +691 -0
- package/components/common/AppSpinner.js +36 -0
- package/components/common/app-spinner.js +26 -0
- package/components/common/index.js +12 -0
- package/components/constants.js +1208 -0
- package/components/container/accordion/accordion-pane/index.js +108 -0
- package/components/container/accordion/accordion-pane/props.js +11 -0
- package/components/container/accordion/index.js +232 -0
- package/components/container/accordion/props.js +13 -0
- package/components/container/alignment-utils.js +183 -0
- package/components/container/index.js +188 -0
- package/components/container/layout-grid/grid-column/index.js +34 -0
- package/components/container/layout-grid/grid-row/index.js +24 -0
- package/components/container/layout-grid/index.js +33 -0
- package/components/container/linear-layout/index.js +72 -0
- package/components/container/linear-layout/linear-layout-item/index.js +43 -0
- package/components/container/panel/components/panel-header/index.js +144 -0
- package/components/container/panel/components/panel-header/props.js +5 -0
- package/components/container/panel/hooks.js +144 -0
- package/components/container/panel/index.js +286 -0
- package/components/container/panel/props.js +5 -0
- package/components/container/props.js +5 -0
- package/components/container/tabs/index.js +379 -0
- package/components/container/tabs/props.js +20 -0
- package/components/container/tabs/tab-pane/index.js +42 -0
- package/components/container/tabs/tab-pane/props.js +5 -0
- package/components/container/wizard/WizardContext.js +16 -0
- package/components/container/wizard/components/StepComponents.js +100 -0
- package/components/container/wizard/components/WizardStep.js +89 -0
- package/components/container/wizard/index.js +710 -0
- package/components/container/wizard/props.js +5 -0
- package/components/container/wizard/utils.js +133 -0
- package/components/container/wizard/wizard-action/index.js +22 -0
- package/components/container/wizard/wizard-step/index.js +94 -0
- package/components/data/card/card-actions/index.js +24 -0
- package/components/data/card/card-content/index.js +38 -0
- package/components/data/card/card-footer/index.js +24 -0
- package/components/data/card/index.js +246 -0
- package/components/data/card/props.js +5 -0
- package/components/data/form/base-form/constant.js +39 -0
- package/components/data/form/base-form/index.js +460 -0
- package/components/data/form/base-form/props.js +29 -0
- package/components/data/form/base-form/utils.js +42 -0
- package/components/data/form/dynamic-fields/index.js +196 -0
- package/components/data/form/dynamic-fields/props.js +5 -0
- package/components/data/form/dynamic-fields/utils.js +237 -0
- package/components/data/form/form-action/index.js +71 -0
- package/components/data/form/form-body/index.js +26 -0
- package/components/data/form/form-context.js +34 -0
- package/components/data/form/form-controller/props.js +19 -0
- package/components/data/form/form-controller/validation-contrustor.js +313 -0
- package/components/data/form/form-controller/withFormController.js +320 -0
- package/components/data/form/form-field/base-field.js +138 -0
- package/components/data/form/form-field/index.js +36 -0
- package/components/data/form/form-field/props.js +5 -0
- package/components/data/form/form-footer/index.js +26 -0
- package/components/data/form/form-header/index.js +56 -0
- package/components/data/form/index.js +39 -0
- package/components/data/form/props.js +5 -0
- package/components/data/list/components/GroupHeader.js +35 -0
- package/components/data/list/components/GroupedListItems.js +98 -0
- package/components/data/list/components/ListContainer.js +27 -0
- package/components/data/list/components/ListDND.js +241 -0
- package/components/data/list/components/ListHeader.js +59 -0
- package/components/data/list/components/ListItem.js +148 -0
- package/components/data/list/components/ListItemWithTemplate.js +59 -0
- package/components/data/list/components/ListItems.js +231 -0
- package/components/data/list/components/ListPagination.js +165 -0
- package/components/data/list/components/LoadMoreButton.js +39 -0
- package/components/data/list/components/NoDataMessage.js +22 -0
- package/components/data/list/components/StandardListItems.js +84 -0
- package/components/data/list/components/index.js +119 -0
- package/components/data/list/components/props.js +5 -0
- package/components/data/list/hooks/index.js +75 -0
- package/components/data/list/hooks/props.js +5 -0
- package/components/data/list/hooks/useCurrentPageItems.js +48 -0
- package/components/data/list/hooks/useGroupedData.js +37 -0
- package/components/data/list/hooks/useListData.js +60 -0
- package/components/data/list/hooks/useListEffects.js +285 -0
- package/components/data/list/hooks/useListEventHandlers.js +291 -0
- package/components/data/list/hooks/useListPagination.js +168 -0
- package/components/data/list/hooks/useListState.js +98 -0
- package/components/data/list/hooks/useListStateManager.js +195 -0
- package/components/data/list/hooks/usePaginatedGroupedData.js +121 -0
- package/components/data/list/index.js +611 -0
- package/components/data/list/props.js +5 -0
- package/components/data/list/templates/media-template.js +53 -0
- package/components/data/list/utils/constants.js +81 -0
- package/components/data/list/utils/list-helpers.js +173 -0
- package/components/data/list/utils/list-widget-methods.js +114 -0
- package/components/data/live-filter/index.js +279 -0
- package/components/data/live-filter/props.js +12 -0
- package/components/data/live-form/index.js +93 -0
- package/components/data/live-form/props.js +16 -0
- package/components/data/pagination/components/BasicPagination.js +77 -0
- package/components/data/pagination/components/ClassicPagination.js +191 -0
- package/components/data/pagination/components/InlinePagination.js +99 -0
- package/components/data/pagination/components/LoadingComponent.js +31 -0
- package/components/data/pagination/components/PageSizeSelector.js +175 -0
- package/components/data/pagination/components/PagerNavigation.js +105 -0
- package/components/data/pagination/components/TotalRecords.js +52 -0
- package/components/data/pagination/components/index.js +47 -0
- package/components/data/pagination/components/props.js +5 -0
- package/components/data/pagination/hooks/index.js +19 -0
- package/components/data/pagination/hooks/props.js +5 -0
- package/components/data/pagination/hooks/useNavigationSize.js +44 -0
- package/components/data/pagination/hooks/usePagination.js +796 -0
- package/components/data/pagination/index.js +322 -0
- package/components/data/table/components/AddNewRow.js +190 -0
- package/components/data/table/components/EditableCell.js +91 -0
- package/components/data/table/components/FieldValidationError.js +24 -0
- package/components/data/table/components/RowExpansionButton.js +74 -0
- package/components/data/table/components/TableBody.js +279 -0
- package/components/data/table/components/TableFilters.js +325 -0
- package/components/data/table/components/TableFooterActions.js +48 -0
- package/components/data/table/components/TableHeader.js +174 -0
- package/components/data/table/components/TablePanelHeading.js +68 -0
- package/components/data/table/components/index.js +74 -0
- package/components/data/table/hooks/index.js +219 -0
- package/components/data/table/hooks/useCellState.js +117 -0
- package/components/data/table/hooks/useDynamicColumns.js +85 -0
- package/components/data/table/hooks/useEditingState.js +47 -0
- package/components/data/table/hooks/useFormWidget.js +184 -0
- package/components/data/table/hooks/usePaginationState.js +60 -0
- package/components/data/table/hooks/usePanelStructure.js +40 -0
- package/components/data/table/hooks/useResponsiveColumns.js +34 -0
- package/components/data/table/hooks/useRowExpansion.js +110 -0
- package/components/data/table/hooks/useRowHandlers.js +38 -0
- package/components/data/table/hooks/useRowSelection.js +213 -0
- package/components/data/table/hooks/useServerSideSorting.js +165 -0
- package/components/data/table/hooks/useTableColumns.js +263 -0
- package/components/data/table/hooks/useTableData.js +154 -0
- package/components/data/table/hooks/useTableEdit.js +467 -0
- package/components/data/table/hooks/useTableEffects.js +139 -0
- package/components/data/table/hooks/useTableFilter.js +389 -0
- package/components/data/table/hooks/useTableInitialization.js +103 -0
- package/components/data/table/hooks/useTableState.js +69 -0
- package/components/data/table/hooks/useTableStateManager.js +558 -0
- package/components/data/table/index.js +1295 -0
- package/components/data/table/live-table/index.js +232 -0
- package/components/data/table/props.js +5 -0
- package/components/data/table/table-action/index.js +78 -0
- package/components/data/table/table-column/index.js +35 -0
- package/components/data/table/table-row/index.js +49 -0
- package/components/data/table/table-row-action/index.js +74 -0
- package/components/data/table/utils/buildSelectionColumns.js +173 -0
- package/components/data/table/utils/columnBuilder.js +209 -0
- package/components/data/table/utils/columnProxy.js +48 -0
- package/components/data/table/utils/columnWidthDistribution.js +98 -0
- package/components/data/table/utils/constants.js +80 -0
- package/components/data/table/utils/crud-handlers.js +518 -0
- package/components/data/table/utils/dynamic-columns.js +118 -0
- package/components/data/table/utils/index.js +607 -0
- package/components/data/table/utils/renderDisplayCell.js +183 -0
- package/components/data/table/utils/selectionUtils.js +166 -0
- package/components/data/table/utils/table-helpers.js +100 -0
- package/components/data/table/utils/validation.js +124 -0
- package/components/data/types.js +113 -0
- package/components/data/utils/field-data-utils.js +66 -0
- package/components/data/utils/filter-field-util.js +81 -0
- package/components/data/utils/index.js +216 -0
- package/components/dialogs/alert-dialog/index.js +80 -0
- package/components/dialogs/confirm-dialog/index.js +105 -0
- package/components/dialogs/dialog/index.js +56 -0
- package/components/dialogs/dialog-actions/index.js +18 -0
- package/components/dialogs/dialog-body/index.js +21 -0
- package/components/dialogs/dialog-content/index.js +30 -0
- package/components/dialogs/dialog-header/index.js +93 -0
- package/components/dialogs/iframe-dialog/index.js +114 -0
- package/components/dialogs/index.js +129 -0
- package/components/dialogs/login-dialog/index.js +369 -0
- package/components/dialogs/login-dialog/props.js +5 -0
- package/components/dialogs/page-dialog/index.js +96 -0
- package/components/dialogs/withDialogWrapper.js +108 -0
- package/components/form/button/index.js +216 -0
- package/components/form/button-group/index.js +60 -0
- package/components/input/calendar/index.js +546 -0
- package/components/input/calendar/props.js +5 -0
- package/components/input/calendar/utils.js +340 -0
- package/components/input/chips/SortableChip/index.js +115 -0
- package/components/input/chips/SortableChip/props.js +5 -0
- package/components/input/chips/index.js +488 -0
- package/components/input/chips/props.js +5 -0
- package/components/input/chips/utils.js +259 -0
- package/components/input/color-picker/index.js +678 -0
- package/components/input/color-picker/props.js +5 -0
- package/components/input/composite/index.js +137 -0
- package/components/input/currency/index.js +263 -0
- package/components/input/currency/props.js +5 -0
- package/components/input/default/checkbox/index.js +230 -0
- package/components/input/default/checkbox/props.js +5 -0
- package/components/input/default/checkboxset/index.js +476 -0
- package/components/input/default/checkboxset/props.js +5 -0
- package/components/input/default/radioset/index.js +379 -0
- package/components/input/default/radioset/props.js +5 -0
- package/components/input/default/switch/index.js +490 -0
- package/components/input/default/switch/prop.js +5 -0
- package/components/input/epoch/date/components/DatePickerPopover.js +220 -0
- package/components/input/epoch/date/index.js +520 -0
- package/components/input/epoch/date/props.js +5 -0
- package/components/input/epoch/date/styled.js +70 -0
- package/components/input/epoch/date/utils.js +108 -0
- package/components/input/epoch/datetime/index.js +656 -0
- package/components/input/epoch/datetime/props.js +5 -0
- package/components/input/epoch/datetime/styled.js +90 -0
- package/components/input/epoch/datetime/utils.js +244 -0
- package/components/input/epoch/time/index.js +412 -0
- package/components/input/epoch/time/props.js +5 -0
- package/components/input/epoch/time/utils.js +209 -0
- package/components/input/fileupload/Utils.js +134 -0
- package/components/input/fileupload/components/ListItems.js +140 -0
- package/components/input/fileupload/components/MultiUpload.js +85 -0
- package/components/input/fileupload/components/SingleUpload.js +65 -0
- package/components/input/fileupload/index.js +170 -0
- package/components/input/fileupload/props.js +5 -0
- package/components/input/fileupload/useFileUpload.js +400 -0
- package/components/input/number/index.js +295 -0
- package/components/input/number/props.js +5 -0
- package/components/input/rating/index.js +368 -0
- package/components/input/rating/props.js +5 -0
- package/components/input/select/index.js +344 -0
- package/components/input/select/props.js +5 -0
- package/components/input/slider/index.js +167 -0
- package/components/input/slider/props.js +5 -0
- package/components/input/text/index.js +434 -0
- package/components/input/text/props.js +5 -0
- package/components/input/text/util.js +179 -0
- package/components/input/textarea/index.js +347 -0
- package/components/input/textarea/props.js +5 -0
- package/components/layout/footer/index.js +30 -0
- package/components/layout/header/index.js +30 -0
- package/components/layout/leftnav/index.js +44 -0
- package/components/layout/rightnav/index.js +32 -0
- package/components/layout/topnav/index.js +34 -0
- package/components/navbar/index.js +41 -0
- package/components/navbar/nav/index.js +102 -0
- package/components/navbar/nav/props.js +5 -0
- package/components/navbar/nav-item/index.js +44 -0
- package/components/navigation/breadcrumb/index.js +56 -0
- package/components/navigation/breadcrumb/props.js +5 -0
- package/components/navigation/menu/components/ListItems.js +66 -0
- package/components/navigation/menu/constants.js +101 -0
- package/components/navigation/menu/index.js +807 -0
- package/components/navigation/menu/props.js +5 -0
- package/components/navigation/popover/index.js +209 -0
- package/components/navigation/popover/props.js +15 -0
- package/components/page/content/index.js +28 -0
- package/components/page/error-boundary/index.js +108 -0
- package/components/page/index.js +137 -0
- package/components/page/page-content/index.js +23 -0
- package/components/page/partial/index.js +36 -0
- package/components/page/partial-container/index.js +48 -0
- package/components/page/props.js +5 -0
- package/components/page/toast-container/index.js +33 -0
- package/components/prefab/container/index.js +46 -0
- package/components/prefab/index.js +67 -0
- package/context/AppContext.js +25 -0
- package/context/AppSpinnerProvider.js +43 -0
- package/context/LocalizationProvider.js +79 -0
- package/context/PrefabContext.js +66 -0
- package/context/WidgetProvider.js +187 -0
- package/core/app-config.js +1 -0
- package/core/app.service.js +357 -0
- package/core/appVariablesStore.js +20 -0
- package/core/appstore.js +88 -0
- package/core/constants/currency-constant.js +1071 -0
- package/core/constants/events.js +34 -0
- package/core/constants/index.js +27 -0
- package/core/dialog.service.js +76 -0
- package/core/event-notifier.js +151 -0
- package/core/formatter/date-formatters.js +222 -0
- package/core/formatter/index.js +131 -0
- package/core/formatter/number-formatters.js +142 -0
- package/core/formatter/security-formatters.js +323 -0
- package/core/formatter/string-formatters.js +52 -0
- package/core/formatter/types.js +18 -0
- package/core/formatters.js +24 -0
- package/core/proxy-service.js +412 -0
- package/core/script-registry.js +63 -0
- package/core/security.service.js +11 -0
- package/core/util/common.js +33 -0
- package/core/util/dom.js +107 -0
- package/core/util/index.js +136 -0
- package/core/util/security.js +184 -0
- package/core/util/utils.js +189 -0
- package/core/widget-observer.js +98 -0
- package/higherOrder/BaseApp.js +430 -0
- package/higherOrder/BaseAppProps.js +5 -0
- package/higherOrder/BaseDateTime.js +251 -0
- package/higherOrder/BasePage.js +715 -0
- package/higherOrder/BasePartial.js +124 -0
- package/higherOrder/BasePrefab.js +145 -0
- package/higherOrder/DataNav.js +377 -0
- package/higherOrder/helper.js +43 -0
- package/higherOrder/props.js +5 -0
- package/higherOrder/withBaseWrapper.js +183 -0
- package/hooks/useAccess.js +308 -0
- package/hooks/useAppConfig.js +42 -0
- package/hooks/useAuth.js +562 -0
- package/hooks/useDataSourceSubscription.js +125 -0
- package/hooks/useDebounce.js +76 -0
- package/hooks/useDeviceVisibility.js +49 -0
- package/hooks/useHttp.js +338 -0
- package/libs/index.js +20 -0
- package/mui-config/theme-provider.js +17 -0
- package/mui-config/theme.js +371 -0
- package/package-lock.json +10177 -0
- package/package.json +95 -0
- package/store/index.js +33 -0
- package/store/middleware/navigationMiddleware.js +48 -0
- package/store/slices/appConfigSlice.js +103 -0
- package/store/slices/authSlice.js +508 -0
- package/store/slices/i18nSlice.js +206 -0
- package/types/index.js +15 -0
- package/utils/dataset-util.js +174 -0
- package/utils/eval-expression.js +32 -0
- package/utils/form-state.util.js +140 -0
- package/utils/form-utils.js +187 -0
- package/utils/format-util.js +260 -0
- package/utils/page-params-util.js +24 -0
- package/utils/resource-url.js +27 -0
- package/utils/state-persistance.js +343 -0
- package/utils/style-utils.js +73 -0
- package/utils/transformedDataset-utils.js +633 -0
- package/utils/widget-cleanup-util.js +84 -0
- package/utils/widgets.js +99 -0
- package/variables/base-variable.js +173 -0
- package/variables/constants.js +27 -0
- package/variables/live-variable.js +166 -0
- package/variables/model-variable.js +77 -0
- package/variables/service-variable.js +307 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useFileUpload = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _lodashEs = require("lodash-es");
|
|
12
|
+
var _constants = require("@wavemaker/react-runtime/components/constants");
|
|
13
|
+
var _Utils = require("./Utils");
|
|
14
|
+
var _eventNotifier = require("@wavemaker/react-runtime/core/event-notifier");
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
var useFileUpload = exports.useFileUpload = function useFileUpload(props) {
|
|
18
|
+
var _listener$appConfig;
|
|
19
|
+
var name = props.name,
|
|
20
|
+
_props$multiple = props.multiple,
|
|
21
|
+
multiple = _props$multiple === void 0 ? _constants.fileUploadConstants.DEFAULT_VALUES.MULTIPLE : _props$multiple,
|
|
22
|
+
_props$disabled = props.disabled,
|
|
23
|
+
disabled = _props$disabled === void 0 ? !_constants.fileUploadConstants.DEFAULT_VALUES.ENABLED : _props$disabled,
|
|
24
|
+
_props$contenttype = props.contenttype,
|
|
25
|
+
contenttype = _props$contenttype === void 0 ? "" : _props$contenttype,
|
|
26
|
+
maxfilesize = props.maxfilesize,
|
|
27
|
+
uploadpath = props.uploadpath,
|
|
28
|
+
datasource = props.datasource,
|
|
29
|
+
extensions = props.extensions,
|
|
30
|
+
filetype = props.filetype,
|
|
31
|
+
_props$readonly = props.readonly,
|
|
32
|
+
readonly = _props$readonly === void 0 ? false : _props$readonly,
|
|
33
|
+
deletedatasource = props.deletedatasource,
|
|
34
|
+
onError = props.onError,
|
|
35
|
+
onSelect = props.onSelect,
|
|
36
|
+
onBeforeselect = props.onBeforeselect,
|
|
37
|
+
onDelete = props.onDelete,
|
|
38
|
+
listener = props.listener;
|
|
39
|
+
var allowedFileUploadExtensions = listener === null || listener === void 0 || (_listener$appConfig = listener.appConfig) === null || _listener$appConfig === void 0 || (_listener$appConfig = _listener$appConfig.appProperties) === null || _listener$appConfig === void 0 ? void 0 : _listener$appConfig.allowedFileUploadExtensions;
|
|
40
|
+
var fileInputRef = (0, _react.useRef)(null);
|
|
41
|
+
|
|
42
|
+
// State for managing confirm dialog
|
|
43
|
+
var _useState = (0, _react.useState)(false),
|
|
44
|
+
confirmDialogOpen = _useState[0],
|
|
45
|
+
setConfirmDialogOpen = _useState[1];
|
|
46
|
+
var _useState2 = (0, _react.useState)({
|
|
47
|
+
title: "",
|
|
48
|
+
message: "",
|
|
49
|
+
oktext: "OK",
|
|
50
|
+
canceltext: "Cancel",
|
|
51
|
+
onOk: function onOk() {},
|
|
52
|
+
onCancel: function onCancel() {}
|
|
53
|
+
}),
|
|
54
|
+
confirmDialogProps = _useState2[0],
|
|
55
|
+
setConfirmDialogProps = _useState2[1];
|
|
56
|
+
|
|
57
|
+
// Function to show confirm dialog
|
|
58
|
+
var showConfirmDialog = function showConfirmDialog(props) {
|
|
59
|
+
setConfirmDialogProps({
|
|
60
|
+
title: props.title,
|
|
61
|
+
message: props.message,
|
|
62
|
+
oktext: props.oktext || "OK",
|
|
63
|
+
canceltext: props.canceltext || "Cancel",
|
|
64
|
+
onOk: props.onOk,
|
|
65
|
+
onCancel: props.onCancel || function () {}
|
|
66
|
+
});
|
|
67
|
+
setConfirmDialogOpen(true);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// Function to close confirm dialog
|
|
71
|
+
var closeConfirmDialog = function closeConfirmDialog() {
|
|
72
|
+
setConfirmDialogOpen(false);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Helper function to normalize extensions (handles both space and comma separated)
|
|
76
|
+
var normalizeExtensions = (0, _react.useCallback)(function (extensionString) {
|
|
77
|
+
if (!extensionString) return "";
|
|
78
|
+
|
|
79
|
+
// Split by both comma and space, then filter out empty strings
|
|
80
|
+
var extensions = extensionString.split(/[,\s]+/).filter(function (ext) {
|
|
81
|
+
return ext.trim();
|
|
82
|
+
});
|
|
83
|
+
return extensions.map(function (ext) {
|
|
84
|
+
var trimmedExt = ext.trim();
|
|
85
|
+
// Handle MIME type patterns (e.g., "image/*")
|
|
86
|
+
if (trimmedExt.includes("/")) {
|
|
87
|
+
return trimmedExt;
|
|
88
|
+
}
|
|
89
|
+
// Ensure extensions start with a dot
|
|
90
|
+
if (trimmedExt.startsWith(".")) {
|
|
91
|
+
return trimmedExt;
|
|
92
|
+
}
|
|
93
|
+
return ".".concat(trimmedExt);
|
|
94
|
+
}).join(",");
|
|
95
|
+
}, []);
|
|
96
|
+
var getChooseFilter = function getChooseFilter() {
|
|
97
|
+
var normalizedContenttype = normalizeExtensions(contenttype);
|
|
98
|
+
var normalizedExtensions = normalizeExtensions(extensions || "");
|
|
99
|
+
var normalizedFiletype = normalizeExtensions(filetype || "");
|
|
100
|
+
var defaultFilter = (0, _Utils.getDefaultChooseFilter)(DEFAULT_ALLOWED_EXTENSIONS);
|
|
101
|
+
return normalizedContenttype || normalizedExtensions || normalizedFiletype || defaultFilter;
|
|
102
|
+
};
|
|
103
|
+
var DEFAULT_ALLOWED_EXTENSIONS = (allowedFileUploadExtensions === null || allowedFileUploadExtensions === void 0 ? void 0 : allowedFileUploadExtensions.split(" ").map(function (item) {
|
|
104
|
+
return item.trim();
|
|
105
|
+
}).map(function (item) {
|
|
106
|
+
return item.endsWith("/*") ? item : ".".concat(item);
|
|
107
|
+
})) || [];
|
|
108
|
+
var _useState3 = (0, _react.useState)(function () {
|
|
109
|
+
return getChooseFilter();
|
|
110
|
+
}),
|
|
111
|
+
chooseFilter = _useState3[0],
|
|
112
|
+
setChooseFilter = _useState3[1];
|
|
113
|
+
var _useState4 = (0, _react.useState)(false),
|
|
114
|
+
highlightDropArea = _useState4[0],
|
|
115
|
+
setHighlightDropArea = _useState4[1];
|
|
116
|
+
var _useState5 = (0, _react.useState)([]),
|
|
117
|
+
uploadedFiles = _useState5[0],
|
|
118
|
+
setUploadedFiles = _useState5[1];
|
|
119
|
+
var _useState6 = (0, _react.useState)([]),
|
|
120
|
+
selectedFolders = _useState6[0],
|
|
121
|
+
setSelectedFolders = _useState6[1];
|
|
122
|
+
var invokeEventCallback = (0, _react.useCallback)(function (eventName, payload) {
|
|
123
|
+
var _listener$Widgets;
|
|
124
|
+
var eventHandler = listener === null || listener === void 0 || (_listener$Widgets = listener.Widgets) === null || _listener$Widgets === void 0 || (_listener$Widgets = _listener$Widgets[name]) === null || _listener$Widgets === void 0 ? void 0 : _listener$Widgets[eventName];
|
|
125
|
+
return eventHandler ? eventHandler(payload.$event, listener.Widgets[name], payload.files) || true : true;
|
|
126
|
+
}, [listener, name]);
|
|
127
|
+
var fileUploadProgress = function fileUploadProgress(progress) {
|
|
128
|
+
setUploadedFiles(function (prevFiles) {
|
|
129
|
+
return prevFiles.map(function (file) {
|
|
130
|
+
if (file.name === progress.fileName && file.uniqueId === progress.uniqueId) {
|
|
131
|
+
file.progress = progress.progress;
|
|
132
|
+
if (file.progress === 100) {
|
|
133
|
+
file.status = "success";
|
|
134
|
+
} else {
|
|
135
|
+
file.status = progress.status;
|
|
136
|
+
if (progress.errMsg) {
|
|
137
|
+
file.errMsg = progress.errMsg;
|
|
138
|
+
file.status = "error";
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return file;
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// Setup progress tracking with EventNotifier
|
|
148
|
+
(0, _react.useEffect)(function () {
|
|
149
|
+
if (datasource && datasource._progressObservable) {
|
|
150
|
+
datasource._progressObservable.subscribe(function (progress) {
|
|
151
|
+
fileUploadProgress(progress);
|
|
152
|
+
|
|
153
|
+
// Move notifyApp calls outside of setState to avoid render phase issues
|
|
154
|
+
if (progress.progress === 100) {
|
|
155
|
+
var _listener$App;
|
|
156
|
+
listener === null || listener === void 0 || (_listener$App = listener.App) === null || _listener$App === void 0 || _listener$App.notifyApp("File uploaded successfully", "Success");
|
|
157
|
+
} else if (progress.errMsg) {
|
|
158
|
+
var _listener$App2;
|
|
159
|
+
listener === null || listener === void 0 || (_listener$App2 = listener.App) === null || _listener$App2 === void 0 || _listener$App2.notifyApp("File upload failed", "Error");
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
return function () {
|
|
164
|
+
if (datasource && datasource !== null && datasource !== void 0 && datasource._progressObservable) {
|
|
165
|
+
var _datasource$_progress;
|
|
166
|
+
datasource === null || datasource === void 0 || (_datasource$_progress = datasource._progressObservable) === null || _datasource$_progress === void 0 || _datasource$_progress.unsubscribe();
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}, [invokeEventCallback]);
|
|
170
|
+
(0, _react.useEffect)(function () {
|
|
171
|
+
// Normalize extensions to handle both space and comma separated values
|
|
172
|
+
var selected = getChooseFilter();
|
|
173
|
+
setChooseFilter(selected);
|
|
174
|
+
}, [contenttype, extensions, filetype, normalizeExtensions, DEFAULT_ALLOWED_EXTENSIONS]);
|
|
175
|
+
(0, _react.useEffect)(function () {
|
|
176
|
+
var _ref, _ref2;
|
|
177
|
+
var selected = (_ref = (_ref2 = contenttype !== null && contenttype !== void 0 ? contenttype : extensions) !== null && _ref2 !== void 0 ? _ref2 : filetype) !== null && _ref !== void 0 ? _ref : (0, _Utils.getDefaultChooseFilter)(DEFAULT_ALLOWED_EXTENSIONS);
|
|
178
|
+
setChooseFilter(selected);
|
|
179
|
+
}, [contenttype, extensions, filetype]);
|
|
180
|
+
(0, _react.useEffect)(function () {
|
|
181
|
+
// Add event listeners for drag and drop
|
|
182
|
+
if (disabled || readonly) {
|
|
183
|
+
setHighlightDropArea(false);
|
|
184
|
+
window.removeEventListener("focus", disableDropZone);
|
|
185
|
+
} else {
|
|
186
|
+
document.addEventListener("dragover", dragOverCb);
|
|
187
|
+
document.addEventListener("drop", dropCb);
|
|
188
|
+
document.addEventListener("mouseleave", dropCb);
|
|
189
|
+
}
|
|
190
|
+
return function () {
|
|
191
|
+
document.removeEventListener("dragover", dragOverCb);
|
|
192
|
+
document.removeEventListener("drop", dropCb);
|
|
193
|
+
document.removeEventListener("mouseleave", dropCb);
|
|
194
|
+
};
|
|
195
|
+
}, [disabled, readonly]);
|
|
196
|
+
var dragOverCb = function dragOverCb(e) {
|
|
197
|
+
e.preventDefault();
|
|
198
|
+
var dropzone = document.getElementById("dropzone");
|
|
199
|
+
if (dropzone) {
|
|
200
|
+
dropzone.classList.add("highlight-drop-box");
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
var dropCb = function dropCb() {
|
|
204
|
+
var dropzone = document.getElementById("dropzone");
|
|
205
|
+
if (dropzone) {
|
|
206
|
+
dropzone.classList.remove("highlight-drop-box");
|
|
207
|
+
}
|
|
208
|
+
setHighlightDropArea(false);
|
|
209
|
+
};
|
|
210
|
+
var dragOverHandler = function dragOverHandler(e) {
|
|
211
|
+
e.preventDefault();
|
|
212
|
+
e.stopPropagation();
|
|
213
|
+
setHighlightDropArea(true);
|
|
214
|
+
};
|
|
215
|
+
var disableDropZone = function disableDropZone() {
|
|
216
|
+
setHighlightDropArea(false);
|
|
217
|
+
window.removeEventListener("focus", disableDropZone);
|
|
218
|
+
};
|
|
219
|
+
var onBeforeSelectEventCall = function onBeforeSelectEventCall($event, $files) {
|
|
220
|
+
var files = (0, _Utils.getValidFiles)($files, contenttype, extensions || "", filetype || "", chooseFilter, maxfilesize || "10", onError, listener);
|
|
221
|
+
if (!(0, _lodashEs.isEmpty)(files.errorFiles)) {
|
|
222
|
+
invokeEventCallback("error", {
|
|
223
|
+
$event: _objectSpread(_objectSpread({}, $event), {}, {
|
|
224
|
+
files: files.errorFiles
|
|
225
|
+
}),
|
|
226
|
+
files: files.errorFiles
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
if (files.validFiles.length) {
|
|
230
|
+
var beforeSelectVal = invokeEventCallback("beforeselect", {
|
|
231
|
+
$event: _objectSpread(_objectSpread({}, $event), {}, {
|
|
232
|
+
files: files.validFiles
|
|
233
|
+
}),
|
|
234
|
+
files: files.validFiles
|
|
235
|
+
});
|
|
236
|
+
if (beforeSelectVal !== false) {
|
|
237
|
+
var _fileInputRef$current;
|
|
238
|
+
var filesWithIds = files.validFiles.map(function (file) {
|
|
239
|
+
var fileWithId = file;
|
|
240
|
+
if (!fileWithId.name) {
|
|
241
|
+
fileWithId.name = file.name;
|
|
242
|
+
}
|
|
243
|
+
if (!fileWithId.size) {
|
|
244
|
+
fileWithId.size = file.size;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Add our custom properties
|
|
248
|
+
fileWithId.uniqueId = (0, _Utils.generateFileId)();
|
|
249
|
+
|
|
250
|
+
// Set initial status
|
|
251
|
+
if (datasource) {
|
|
252
|
+
fileWithId.status = "onProgress";
|
|
253
|
+
fileWithId.progress = 0;
|
|
254
|
+
} else {
|
|
255
|
+
fileWithId.status = "success";
|
|
256
|
+
}
|
|
257
|
+
return fileWithId;
|
|
258
|
+
});
|
|
259
|
+
if (datasource) {
|
|
260
|
+
datasource._progressObservable = (0, _eventNotifier.eventObserver)();
|
|
261
|
+
}
|
|
262
|
+
setUploadedFiles(function (prev) {
|
|
263
|
+
return multiple ? [].concat((0, _toConsumableArray2["default"])(prev), (0, _toConsumableArray2["default"])(filesWithIds)) : (0, _toConsumableArray2["default"])(filesWithIds);
|
|
264
|
+
});
|
|
265
|
+
datasource.dataBinding.files = filesWithIds;
|
|
266
|
+
datasource.dataSet = filesWithIds;
|
|
267
|
+
listener === null || listener === void 0 || listener.onChange(name, {
|
|
268
|
+
selectedFiles: filesWithIds
|
|
269
|
+
});
|
|
270
|
+
onSelect === null || onSelect === void 0 || onSelect($event, (_fileInputRef$current = fileInputRef.current) === null || _fileInputRef$current === void 0 || (_fileInputRef$current = _fileInputRef$current.files) === null || _fileInputRef$current === void 0 ? void 0 : _fileInputRef$current[0], filesWithIds);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
var onFileSelect = function onFileSelect(e) {
|
|
275
|
+
setSelectedFolders([]);
|
|
276
|
+
onBeforeSelectEventCall(e, e.target.files || []);
|
|
277
|
+
if (fileInputRef.current) {
|
|
278
|
+
fileInputRef.current.value = "";
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
var onFileDrop = function onFileDrop(e) {
|
|
282
|
+
e.preventDefault();
|
|
283
|
+
var listOfFiles = [];
|
|
284
|
+
setSelectedFolders([]);
|
|
285
|
+
var filesData = e.dataTransfer.items;
|
|
286
|
+
if (filesData.length > 0) {
|
|
287
|
+
var _loop = function _loop() {
|
|
288
|
+
var _webkitGetAsEntry, _ref3;
|
|
289
|
+
// Using explicit type assertion since webkitGetAsEntry is non-standard
|
|
290
|
+
var entry = (_webkitGetAsEntry = (_ref3 = filesData[i]).webkitGetAsEntry) === null || _webkitGetAsEntry === void 0 ? void 0 : _webkitGetAsEntry.call(_ref3);
|
|
291
|
+
if (entry && entry.isFile) {
|
|
292
|
+
var file = filesData[i].getAsFile();
|
|
293
|
+
if (file) listOfFiles.push(file);
|
|
294
|
+
} else if (entry && entry.isDirectory) {
|
|
295
|
+
var _file = filesData[i].getAsFile();
|
|
296
|
+
if (_file) setSelectedFolders(function (prev) {
|
|
297
|
+
return [].concat((0, _toConsumableArray2["default"])(prev), [_file]);
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
for (var i = 0; i < filesData.length; i++) {
|
|
302
|
+
_loop();
|
|
303
|
+
}
|
|
304
|
+
onBeforeSelectEventCall(e, listOfFiles);
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
var clearSelectedFile = function clearSelectedFile(file) {
|
|
308
|
+
// setSelectedFilesList((prev) => clearFile(prev as (File & FileUploadState)[], file));
|
|
309
|
+
setUploadedFiles(function (prev) {
|
|
310
|
+
return (0, _Utils.clearFile)(prev, file);
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
var triggerFileSelect = function triggerFileSelect() {
|
|
314
|
+
if (fileInputRef.current && !disabled && !readonly) {
|
|
315
|
+
fileInputRef.current.click();
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
var deleteFileProgress = function deleteFileProgress(file) {
|
|
319
|
+
deletedatasource._deleteFileObservable.subscribe(function (response) {
|
|
320
|
+
if (response.status === "success") {
|
|
321
|
+
setUploadedFiles(function (prev) {
|
|
322
|
+
return prev.filter(function (fileObj) {
|
|
323
|
+
return file !== fileObj;
|
|
324
|
+
}) || [];
|
|
325
|
+
});
|
|
326
|
+
setSelectedFolders(function (prev) {
|
|
327
|
+
return prev.filter(function (fileObj) {
|
|
328
|
+
return file !== fileObj;
|
|
329
|
+
}) || [];
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
};
|
|
334
|
+
var onFileDelete = function onFileDelete(e, file) {
|
|
335
|
+
if (!file || readonly) return;
|
|
336
|
+
var beforeDeleteVal = invokeEventCallback("beforedelete", {
|
|
337
|
+
$event: file
|
|
338
|
+
});
|
|
339
|
+
if (beforeDeleteVal !== false) {
|
|
340
|
+
showConfirmDialog({
|
|
341
|
+
title: "Delete file",
|
|
342
|
+
message: "Are you sure you want to delete this file?",
|
|
343
|
+
oktext: "Ok",
|
|
344
|
+
canceltext: "Cancel",
|
|
345
|
+
onOk: function onOk() {
|
|
346
|
+
try {
|
|
347
|
+
if (deletedatasource) {
|
|
348
|
+
var _file$_response, _fileInputRef$current2, _listener$App3;
|
|
349
|
+
deletedatasource._deleteFileObservable = (0, _eventNotifier.eventObserver)();
|
|
350
|
+
deleteFileProgress(file);
|
|
351
|
+
var fileName = ((_file$_response = file._response) === null || _file$_response === void 0 || (_file$_response = _file$_response[0]) === null || _file$_response === void 0 ? void 0 : _file$_response.fileName) || file.name;
|
|
352
|
+
deletedatasource.setInput("file", fileName);
|
|
353
|
+
onDelete === null || onDelete === void 0 || onDelete(e, (_fileInputRef$current2 = fileInputRef.current) === null || _fileInputRef$current2 === void 0 || (_fileInputRef$current2 = _fileInputRef$current2.files) === null || _fileInputRef$current2 === void 0 ? void 0 : _fileInputRef$current2[0], fileName);
|
|
354
|
+
listener && (listener === null || listener === void 0 || (_listener$App3 = listener.App) === null || _listener$App3 === void 0 ? void 0 : _listener$App3.notifyApp("File deleted successfully", "Success"));
|
|
355
|
+
}
|
|
356
|
+
} catch (error) {
|
|
357
|
+
var _listener$App4;
|
|
358
|
+
listener && (listener === null || listener === void 0 || (_listener$App4 = listener.App) === null || _listener$App4 === void 0 ? void 0 : _listener$App4.notifyApp("Service Call Failed", "Error"));
|
|
359
|
+
} finally {
|
|
360
|
+
closeConfirmDialog();
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
onCancel: function onCancel() {
|
|
364
|
+
closeConfirmDialog();
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
var handleBeforeSelect = (0, _react.useCallback)(function (event, widget, selectedFiles) {
|
|
370
|
+
onBeforeselect === null || onBeforeselect === void 0 || onBeforeselect(event, widget, selectedFiles);
|
|
371
|
+
}, [onBeforeselect]);
|
|
372
|
+
var handleError = (0, _react.useCallback)(function (event, widget, file) {
|
|
373
|
+
onError === null || onError === void 0 || onError(event, widget, file);
|
|
374
|
+
}, [onError]);
|
|
375
|
+
var events = _objectSpread(_objectSpread({}, onBeforeselect ? {
|
|
376
|
+
onBeforeselect: handleBeforeSelect
|
|
377
|
+
} : {}), onError ? {
|
|
378
|
+
onError: handleError
|
|
379
|
+
} : {});
|
|
380
|
+
return _objectSpread({
|
|
381
|
+
fileInputRef: fileInputRef,
|
|
382
|
+
chooseFilter: chooseFilter,
|
|
383
|
+
highlightDropArea: highlightDropArea,
|
|
384
|
+
uploadedFiles: uploadedFiles,
|
|
385
|
+
selectedFolders: selectedFolders,
|
|
386
|
+
setSelectedFolders: setSelectedFolders,
|
|
387
|
+
dragOverHandler: dragOverHandler,
|
|
388
|
+
onFileSelect: onFileSelect,
|
|
389
|
+
onFileDrop: onFileDrop,
|
|
390
|
+
setHighlightDropArea: setHighlightDropArea,
|
|
391
|
+
clearSelectedFile: clearSelectedFile,
|
|
392
|
+
triggerFileSelect: triggerFileSelect,
|
|
393
|
+
onFileDelete: onFileDelete,
|
|
394
|
+
// Confirm dialog state and functions
|
|
395
|
+
confirmDialogOpen: confirmDialogOpen,
|
|
396
|
+
confirmDialogProps: confirmDialogProps,
|
|
397
|
+
showConfirmDialog: showConfirmDialog,
|
|
398
|
+
closeConfirmDialog: closeConfirmDialog
|
|
399
|
+
}, events);
|
|
400
|
+
};
|