@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,137 @@
|
|
|
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.WmComposite = WmComposite;
|
|
9
|
+
exports["default"] = void 0;
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _clsx2 = _interopRequireDefault(require("clsx"));
|
|
13
|
+
var _withBaseWrapper = require("@wavemaker/react-runtime/higherOrder/withBaseWrapper");
|
|
14
|
+
var _label = _interopRequireDefault(require("@wavemaker/react-runtime/components/basic/label"));
|
|
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 DEFAULT_CLASS = "form-group app-composite-widget clearfix";
|
|
18
|
+
var CAPTION_POSITION = {
|
|
19
|
+
left: "caption-left",
|
|
20
|
+
right: "caption-right",
|
|
21
|
+
top: "caption-top",
|
|
22
|
+
floating: "caption-floating"
|
|
23
|
+
};
|
|
24
|
+
function WmComposite(props) {
|
|
25
|
+
var _clsx;
|
|
26
|
+
var children = props.children,
|
|
27
|
+
styles = props.styles,
|
|
28
|
+
className = props.className,
|
|
29
|
+
_props$captionpositio = props.captionposition,
|
|
30
|
+
captionposition = _props$captionpositio === void 0 ? "left" : _props$captionpositio,
|
|
31
|
+
id = props.id,
|
|
32
|
+
required = props.required;
|
|
33
|
+
var containerRef = (0, _react.useRef)(null);
|
|
34
|
+
var isFloating = captionposition === "floating";
|
|
35
|
+
|
|
36
|
+
// Utility: Check if input has a value
|
|
37
|
+
var hasInputValue = (0, _react.useCallback)(function (input) {
|
|
38
|
+
var _input$value;
|
|
39
|
+
return Boolean((_input$value = input.value) === null || _input$value === void 0 ? void 0 : _input$value.trim());
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
// Utility: Toggle float-active class
|
|
43
|
+
var toggleFloatActive = (0, _react.useCallback)(function (shouldFloat) {
|
|
44
|
+
if (!containerRef.current) return;
|
|
45
|
+
containerRef.current.classList.toggle("float-active", shouldFloat);
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
// Handle focus event - activate floating label and show placeholder
|
|
49
|
+
var handleFocus = (0, _react.useCallback)(function (event) {
|
|
50
|
+
if (!isFloating) return;
|
|
51
|
+
toggleFloatActive(true);
|
|
52
|
+
|
|
53
|
+
// Show placeholder on focus
|
|
54
|
+
var target = event.target;
|
|
55
|
+
var originalPlaceholder = target.getAttribute("data-original-placeholder");
|
|
56
|
+
if (originalPlaceholder) {
|
|
57
|
+
target.setAttribute("placeholder", originalPlaceholder);
|
|
58
|
+
}
|
|
59
|
+
}, [isFloating, toggleFloatActive]);
|
|
60
|
+
|
|
61
|
+
// Handle blur event - check if input has value
|
|
62
|
+
var handleBlur = (0, _react.useCallback)(function (event) {
|
|
63
|
+
if (!isFloating) return;
|
|
64
|
+
var target = event.target;
|
|
65
|
+
|
|
66
|
+
// Keep float-active if input has value, otherwise remove it
|
|
67
|
+
toggleFloatActive(hasInputValue(target));
|
|
68
|
+
|
|
69
|
+
// Always hide placeholder on blur
|
|
70
|
+
target.setAttribute("placeholder", "");
|
|
71
|
+
}, [isFloating, toggleFloatActive, hasInputValue]);
|
|
72
|
+
|
|
73
|
+
// Setup event listeners for floating label behavior
|
|
74
|
+
(0, _react.useEffect)(function () {
|
|
75
|
+
if (!isFloating || !containerRef.current) return;
|
|
76
|
+
var container = containerRef.current;
|
|
77
|
+
var INPUT_SELECTOR = "input, select, textarea";
|
|
78
|
+
var inputElements = container.querySelectorAll(INPUT_SELECTOR);
|
|
79
|
+
if (inputElements.length === 0) return;
|
|
80
|
+
|
|
81
|
+
// Initialize each input
|
|
82
|
+
inputElements.forEach(function (input) {
|
|
83
|
+
// Store and hide placeholder
|
|
84
|
+
var originalPlaceholder = input.getAttribute("placeholder");
|
|
85
|
+
if (originalPlaceholder) {
|
|
86
|
+
input.setAttribute("data-original-placeholder", originalPlaceholder);
|
|
87
|
+
input.setAttribute("placeholder", "");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Check initial value and set float state
|
|
91
|
+
if (hasInputValue(input)) {
|
|
92
|
+
toggleFloatActive(true);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Attach event listeners
|
|
96
|
+
input.addEventListener("focus", handleFocus);
|
|
97
|
+
input.addEventListener("blur", handleBlur);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Cleanup function
|
|
101
|
+
return function () {
|
|
102
|
+
inputElements.forEach(function (input) {
|
|
103
|
+
// Restore placeholder
|
|
104
|
+
var originalPlaceholder = input.getAttribute("data-original-placeholder");
|
|
105
|
+
if (originalPlaceholder) {
|
|
106
|
+
input.setAttribute("placeholder", originalPlaceholder);
|
|
107
|
+
input.removeAttribute("data-original-placeholder");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Remove event listeners
|
|
111
|
+
input.removeEventListener("focus", handleFocus);
|
|
112
|
+
input.removeEventListener("blur", handleBlur);
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
}, [isFloating, children, handleFocus, handleBlur, hasInputValue, toggleFloatActive]);
|
|
116
|
+
|
|
117
|
+
// Inject required prop into WmLabel children (memoized)
|
|
118
|
+
var childElements = _react["default"].useMemo(function () {
|
|
119
|
+
if (!required) return children;
|
|
120
|
+
return _react["default"].Children.map(children, function (child) {
|
|
121
|
+
if (/*#__PURE__*/_react["default"].isValidElement(child) && (child.type === _label["default"] || child.type.displayName === "WmLabel") && child.props.required === undefined) {
|
|
122
|
+
return /*#__PURE__*/_react["default"].cloneElement(child, {
|
|
123
|
+
required: required
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return child;
|
|
127
|
+
});
|
|
128
|
+
}, [children, required]);
|
|
129
|
+
return __jsx("div", {
|
|
130
|
+
ref: containerRef,
|
|
131
|
+
style: styles,
|
|
132
|
+
className: (0, _clsx2["default"])((_clsx = {}, (0, _defineProperty2["default"])(_clsx, DEFAULT_CLASS, true), (0, _defineProperty2["default"])(_clsx, className || "", Boolean(className)), _clsx), "".concat(CAPTION_POSITION[captionposition], " ").concat(required ? "required" : "")),
|
|
133
|
+
id: id
|
|
134
|
+
}, childElements);
|
|
135
|
+
}
|
|
136
|
+
WmComposite.displayName = "WmComposite";
|
|
137
|
+
var _default = exports["default"] = (0, _withBaseWrapper.withBaseWrapper)(WmComposite);
|
|
@@ -0,0 +1,263 @@
|
|
|
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["default"] = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _withBaseWrapper = require("@wavemaker/react-runtime/higherOrder/withBaseWrapper");
|
|
13
|
+
var _constants = require("@wavemaker/react-runtime/components/constants");
|
|
14
|
+
var _material = require("@mui/material");
|
|
15
|
+
var _input = require("@base-ui-components/react/input");
|
|
16
|
+
var _formatUtil = require("@wavemaker/react-runtime/utils/format-util");
|
|
17
|
+
var lodash = _interopRequireWildcard(require("lodash-es"));
|
|
18
|
+
var _withFormController = _interopRequireDefault(require("@wavemaker/react-runtime/components/data/form/form-controller/withFormController"));
|
|
19
|
+
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); }
|
|
20
|
+
var __jsx = _react["default"].createElement;
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
23
|
+
var WmCurrency = function WmCurrency(props) {
|
|
24
|
+
var _props$currency = props.currency,
|
|
25
|
+
currency = _props$currency === void 0 ? "USD" : _props$currency,
|
|
26
|
+
_props$datavalue = props.datavalue,
|
|
27
|
+
initialDataValue = _props$datavalue === void 0 ? null : _props$datavalue,
|
|
28
|
+
_props$disabled = props.disabled,
|
|
29
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
30
|
+
_props$readonly = props.readonly,
|
|
31
|
+
readonly = _props$readonly === void 0 ? false : _props$readonly,
|
|
32
|
+
_props$required = props.required,
|
|
33
|
+
required = _props$required === void 0 ? false : _props$required,
|
|
34
|
+
_props$placeholder = props.placeholder,
|
|
35
|
+
placeholder = _props$placeholder === void 0 ? "Enter value" : _props$placeholder,
|
|
36
|
+
_props$arialabel = props.arialabel,
|
|
37
|
+
arialabel = _props$arialabel === void 0 ? currency : _props$arialabel,
|
|
38
|
+
name = props.name,
|
|
39
|
+
_props$tabindex = props.tabindex,
|
|
40
|
+
tabindex = _props$tabindex === void 0 ? 0 : _props$tabindex,
|
|
41
|
+
shortcutkey = props.shortcutkey,
|
|
42
|
+
maxvalue = props.maxvalue,
|
|
43
|
+
minvalue = props.minvalue,
|
|
44
|
+
_props$step = props.step,
|
|
45
|
+
step = _props$step === void 0 ? 1 : _props$step,
|
|
46
|
+
textAlign = props.textAlign,
|
|
47
|
+
hint = props.hint,
|
|
48
|
+
_props$trailingzero = props.trailingzero,
|
|
49
|
+
trailingzero = _props$trailingzero === void 0 ? false : _props$trailingzero,
|
|
50
|
+
_props$inputmode = props.inputmode,
|
|
51
|
+
inputmode = _props$inputmode === void 0 ? "natural" : _props$inputmode,
|
|
52
|
+
_props$decimalplaces = props.decimalplaces,
|
|
53
|
+
decimalplaces = _props$decimalplaces === void 0 ? 0 : _props$decimalplaces,
|
|
54
|
+
updateon = props.updateon,
|
|
55
|
+
_props$updatedelay = props.updatedelay,
|
|
56
|
+
updatedelay = _props$updatedelay === void 0 ? "0" : _props$updatedelay,
|
|
57
|
+
onChange = props.onChange,
|
|
58
|
+
onBlur = props.onBlur,
|
|
59
|
+
onFocus = props.onFocus,
|
|
60
|
+
onClick = props.onClick,
|
|
61
|
+
onMouseEnter = props.onMouseEnter,
|
|
62
|
+
onMouseLeave = props.onMouseLeave,
|
|
63
|
+
onKeyDown = props.onKeyDown,
|
|
64
|
+
onEnter = props.onEnter,
|
|
65
|
+
className = props.className,
|
|
66
|
+
listener = props.listener,
|
|
67
|
+
styles = props.styles;
|
|
68
|
+
var _useState = (0, _react.useState)(initialDataValue),
|
|
69
|
+
datavalue = _useState[0],
|
|
70
|
+
setDatavalue = _useState[1];
|
|
71
|
+
var _useState2 = (0, _react.useState)(initialDataValue),
|
|
72
|
+
prevDatavalue = _useState2[0],
|
|
73
|
+
setPrevDatavalue = _useState2[1];
|
|
74
|
+
var _useState3 = (0, _react.useState)(initialDataValue !== null ? initialDataValue.toString() : ""),
|
|
75
|
+
internalValue = _useState3[0],
|
|
76
|
+
setInternalValue = _useState3[1];
|
|
77
|
+
// Add state to preserve the original string input when trailingzero is true
|
|
78
|
+
var _useState4 = (0, _react.useState)(initialDataValue !== null ? initialDataValue.toString() : ""),
|
|
79
|
+
rawInputValue = _useState4[0],
|
|
80
|
+
setRawInputValue = _useState4[1];
|
|
81
|
+
var _useState5 = (0, _react.useState)(false),
|
|
82
|
+
isTouched = _useState5[0],
|
|
83
|
+
setIsTouched = _useState5[1];
|
|
84
|
+
var inputEl = (0, _react.useRef)(null);
|
|
85
|
+
var _useState6 = (0, _react.useState)(false),
|
|
86
|
+
showError = _useState6[0],
|
|
87
|
+
setShowError = _useState6[1];
|
|
88
|
+
var _useState7 = (0, _react.useState)(false),
|
|
89
|
+
isDirty = _useState7[0],
|
|
90
|
+
setIsDirty = _useState7[1];
|
|
91
|
+
var currencyCode = currency || _constants.currencyConstants.appDefaultCurrency;
|
|
92
|
+
var currencySymbol = (0, _react.useMemo)(function () {
|
|
93
|
+
var _currencyConstants$CU;
|
|
94
|
+
return ((_currencyConstants$CU = _constants.currencyConstants.CURRENCY_INFO[currencyCode]) === null || _currencyConstants$CU === void 0 ? void 0 : _currencyConstants$CU.symbol) || "$";
|
|
95
|
+
}, [currencyCode]);
|
|
96
|
+
var htmlInputMode = decimalplaces > 0 ? "decimal" : "numeric";
|
|
97
|
+
var validateValue = (0, _react.useCallback)(function (value) {
|
|
98
|
+
return (0, _formatUtil.validateNumericValue)(value, required, minvalue, maxvalue);
|
|
99
|
+
}, [required, minvalue, maxvalue]);
|
|
100
|
+
var debouncedUpdateValue = (0, _react.useCallback)(lodash.debounce(function (value) {
|
|
101
|
+
var validation = validateValue(value);
|
|
102
|
+
setShowError(!validation.isValid);
|
|
103
|
+
if (validation.isValid && (onChange || listener !== null && listener !== void 0 && listener.onChange)) {
|
|
104
|
+
(0, _formatUtil.handleValidatedValueUpdate)(value, name, inputEl.current, onChange, listener, prevDatavalue, setPrevDatavalue, props);
|
|
105
|
+
}
|
|
106
|
+
}, parseInt(updatedelay || "10"), {
|
|
107
|
+
leading: parseInt(updatedelay) === 0
|
|
108
|
+
}), [validateValue, setShowError, onChange, listener, name, inputEl, prevDatavalue, setPrevDatavalue, updatedelay, props]);
|
|
109
|
+
var handleMouseEnter = (0, _react.useCallback)(function (event) {
|
|
110
|
+
onMouseEnter(event, props);
|
|
111
|
+
}, [onMouseEnter]);
|
|
112
|
+
var handleMouseLeave = (0, _react.useCallback)(function (event) {
|
|
113
|
+
onMouseLeave(event, props);
|
|
114
|
+
}, [onMouseLeave]);
|
|
115
|
+
var handleClick = (0, _react.useCallback)(function (event) {
|
|
116
|
+
onClick(event, props);
|
|
117
|
+
}, [onClick]);
|
|
118
|
+
var handleFocus = (0, _react.useCallback)(function (e) {
|
|
119
|
+
onFocus === null || onFocus === void 0 || onFocus(e);
|
|
120
|
+
}, [onFocus]);
|
|
121
|
+
var handleArrowPress = (0, _react.useCallback)(function (event, direction) {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
if (readonly || disabled || step === 0) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
var targetVal = event.target.value.replace(/,/g, "");
|
|
127
|
+
var currentValue = targetVal && !isNaN(Number.parseFloat(targetVal)) ? Number.parseFloat(targetVal) : datavalue;
|
|
128
|
+
var newValue = (0, _formatUtil.handleStepValue)(currentValue, direction, step, decimalplaces, minvalue, maxvalue);
|
|
129
|
+
var cleanValue = newValue.toString();
|
|
130
|
+
setInternalValue(cleanValue);
|
|
131
|
+
setDatavalue(newValue);
|
|
132
|
+
setRawInputValue(cleanValue);
|
|
133
|
+
if (onChange) {
|
|
134
|
+
var syntheticEvent = {
|
|
135
|
+
target: {
|
|
136
|
+
value: newValue.toString(),
|
|
137
|
+
name: name
|
|
138
|
+
},
|
|
139
|
+
currentTarget: inputEl.current
|
|
140
|
+
};
|
|
141
|
+
onChange(syntheticEvent, props, newValue, prevDatavalue);
|
|
142
|
+
}
|
|
143
|
+
var validation = validateValue(newValue);
|
|
144
|
+
setShowError(!validation.isValid);
|
|
145
|
+
if (updateon === "keypress") {
|
|
146
|
+
debouncedUpdateValue(newValue);
|
|
147
|
+
}
|
|
148
|
+
}, [readonly, disabled, step, datavalue, minvalue, maxvalue, decimalplaces, validateValue, onChange, name, props, prevDatavalue, debouncedUpdateValue]);
|
|
149
|
+
var handleKeyDown = (0, _react.useCallback)(function (event) {
|
|
150
|
+
if (event.key === "ArrowUp") {
|
|
151
|
+
handleArrowPress(event, "UP");
|
|
152
|
+
} else if (event.key === "ArrowDown") {
|
|
153
|
+
handleArrowPress(event, "DOWN");
|
|
154
|
+
} else if (event.key === "Enter" && onEnter) {
|
|
155
|
+
onEnter(event);
|
|
156
|
+
}
|
|
157
|
+
if (onKeyDown) {
|
|
158
|
+
onKeyDown(event);
|
|
159
|
+
}
|
|
160
|
+
}, [handleArrowPress, onEnter, onKeyDown]);
|
|
161
|
+
var handleInputChange = function handleInputChange(event) {
|
|
162
|
+
var result = (0, _formatUtil.handleNumericInputChange)(event.target.value, inputmode, decimalplaces, setRawInputValue);
|
|
163
|
+
if (result.newVal === null && event.target.value !== "") {
|
|
164
|
+
return; // Invalid input, don't update
|
|
165
|
+
}
|
|
166
|
+
if (onChange) {
|
|
167
|
+
var _result$newVal;
|
|
168
|
+
var syntheticEvent = {
|
|
169
|
+
target: {
|
|
170
|
+
value: ((_result$newVal = result.newVal) === null || _result$newVal === void 0 ? void 0 : _result$newVal.toString()) || "",
|
|
171
|
+
name: name
|
|
172
|
+
},
|
|
173
|
+
currentTarget: inputEl.current
|
|
174
|
+
};
|
|
175
|
+
onChange(syntheticEvent, props, result.newVal, prevDatavalue);
|
|
176
|
+
}
|
|
177
|
+
setInternalValue(result.inputValue);
|
|
178
|
+
setDatavalue(result.newVal);
|
|
179
|
+
var validation = validateValue(result.newVal);
|
|
180
|
+
setShowError(!validation.isValid);
|
|
181
|
+
if (updateon === "keypress") {
|
|
182
|
+
debouncedUpdateValue(result.newVal);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
var handleBlur = function handleBlur(e) {
|
|
186
|
+
var _listener$Widgets;
|
|
187
|
+
// Ensure proper formatting on blur
|
|
188
|
+
var formattedValue = (0, _formatUtil.formatOnBlur)(datavalue, rawInputValue, trailingzero, decimalplaces);
|
|
189
|
+
if (formattedValue) {
|
|
190
|
+
setInternalValue(formattedValue);
|
|
191
|
+
}
|
|
192
|
+
if (updateon === "blur") {
|
|
193
|
+
debouncedUpdateValue(datavalue);
|
|
194
|
+
}
|
|
195
|
+
onBlur === null || onBlur === void 0 || onBlur(e, listener === null || listener === void 0 || (_listener$Widgets = listener.Widgets) === null || _listener$Widgets === void 0 ? void 0 : _listener$Widgets[name]);
|
|
196
|
+
if (updateon === "blur" && onChange) {
|
|
197
|
+
var syntheticEvent = {
|
|
198
|
+
target: {
|
|
199
|
+
value: (datavalue === null || datavalue === void 0 ? void 0 : datavalue.toString()) || "",
|
|
200
|
+
name: name
|
|
201
|
+
},
|
|
202
|
+
currentTarget: inputEl.current
|
|
203
|
+
};
|
|
204
|
+
onChange(syntheticEvent, props, datavalue, prevDatavalue);
|
|
205
|
+
} else if (updateon === "blur") {
|
|
206
|
+
debouncedUpdateValue(datavalue);
|
|
207
|
+
}
|
|
208
|
+
var validation = validateValue(datavalue);
|
|
209
|
+
setIsTouched(true);
|
|
210
|
+
setIsDirty(!validation.isValid);
|
|
211
|
+
setShowError(!validation.isValid);
|
|
212
|
+
};
|
|
213
|
+
(0, _react.useEffect)(function () {
|
|
214
|
+
if (initialDataValue !== datavalue) {
|
|
215
|
+
setDatavalue(initialDataValue);
|
|
216
|
+
var cleanValue = initialDataValue !== null ? initialDataValue.toString() : "";
|
|
217
|
+
setInternalValue(cleanValue);
|
|
218
|
+
setRawInputValue(cleanValue);
|
|
219
|
+
setPrevDatavalue(datavalue);
|
|
220
|
+
}
|
|
221
|
+
}, [initialDataValue]);
|
|
222
|
+
var events = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, onClick ? {
|
|
223
|
+
onClick: handleClick
|
|
224
|
+
} : {}), onMouseEnter ? {
|
|
225
|
+
onMouseEnter: handleMouseEnter
|
|
226
|
+
} : {}), onMouseLeave ? {
|
|
227
|
+
onMouseLeave: handleMouseLeave
|
|
228
|
+
} : {}), onFocus ? {
|
|
229
|
+
onFocus: handleFocus
|
|
230
|
+
} : {});
|
|
231
|
+
return __jsx(_material.Box, {
|
|
232
|
+
component: "div",
|
|
233
|
+
className: "".concat(_constants.currencyConstants.DEFAULT_CLS, " ").concat(className || "", " ").concat(isTouched ? "ng-touched" : "ng-untouched", " ").concat(isDirty ? "ng-invalid" : ""),
|
|
234
|
+
inputMode: inputmode
|
|
235
|
+
}, __jsx(_material.Box, {
|
|
236
|
+
component: "span",
|
|
237
|
+
className: "input-group-addon"
|
|
238
|
+
}, currencySymbol), __jsx(_input.Input, (0, _extends2["default"])({
|
|
239
|
+
className: "form-control app-textbox app-currency-input app-input-wrapper ".concat(isTouched ? "ng-touched" : "ng-untouched", " ").concat(isDirty ? "ng-invalid" : ""),
|
|
240
|
+
value: internalValue,
|
|
241
|
+
name: name,
|
|
242
|
+
inputMode: htmlInputMode,
|
|
243
|
+
title: hint,
|
|
244
|
+
type: "text"
|
|
245
|
+
}, events, {
|
|
246
|
+
step: step,
|
|
247
|
+
min: minvalue,
|
|
248
|
+
max: maxvalue,
|
|
249
|
+
disabled: disabled,
|
|
250
|
+
readOnly: readonly,
|
|
251
|
+
required: required,
|
|
252
|
+
placeholder: placeholder,
|
|
253
|
+
"aria-label": arialabel,
|
|
254
|
+
tabIndex: tabindex,
|
|
255
|
+
accessKey: shortcutkey,
|
|
256
|
+
style: styles,
|
|
257
|
+
ref: inputEl,
|
|
258
|
+
onChange: handleInputChange,
|
|
259
|
+
onBlur: handleBlur,
|
|
260
|
+
onKeyDown: handleKeyDown
|
|
261
|
+
})));
|
|
262
|
+
};
|
|
263
|
+
var _default = exports["default"] = (0, _withBaseWrapper.withBaseWrapper)((0, _withFormController["default"])(/*#__PURE__*/_react["default"].memo(WmCurrency)));
|
|
@@ -0,0 +1,230 @@
|
|
|
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["default"] = exports.WmCheckbox = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _input = require("@base-ui-components/react/input");
|
|
15
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
16
|
+
var _withBaseWrapper = require("@wavemaker/react-runtime/higherOrder/withBaseWrapper");
|
|
17
|
+
var _withFormController = _interopRequireDefault(require("@wavemaker/react-runtime/components/data/form/form-controller/withFormController"));
|
|
18
|
+
var _excluded = ["caption", "checkedvalue", "uncheckedvalue", "datavalue", "disabled", "hint", "arialabel", "name", "readonly", "required", "shortcutkey", "show", "tabindex", "type", "onChange", "onBlur", "className", "listener", "onClick", "onFocus", "displayValue"];
|
|
19
|
+
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); }
|
|
20
|
+
var __jsx = _react["default"].createElement;
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
23
|
+
var DEFAULT_CLS = "app-checkbox checkbox";
|
|
24
|
+
var WmCheckbox = exports.WmCheckbox = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
25
|
+
var _props$caption = props.caption,
|
|
26
|
+
caption = _props$caption === void 0 ? " " : _props$caption,
|
|
27
|
+
_props$checkedvalue = props.checkedvalue,
|
|
28
|
+
checkedvalue = _props$checkedvalue === void 0 ? true : _props$checkedvalue,
|
|
29
|
+
_props$uncheckedvalue = props.uncheckedvalue,
|
|
30
|
+
uncheckedvalue = _props$uncheckedvalue === void 0 ? false : _props$uncheckedvalue,
|
|
31
|
+
_props$datavalue = props.datavalue,
|
|
32
|
+
datavalue = _props$datavalue === void 0 ? null : _props$datavalue,
|
|
33
|
+
_props$disabled = props.disabled,
|
|
34
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
35
|
+
hint = props.hint,
|
|
36
|
+
arialabel = props.arialabel,
|
|
37
|
+
name = props.name,
|
|
38
|
+
_props$readonly = props.readonly,
|
|
39
|
+
readonly = _props$readonly === void 0 ? false : _props$readonly,
|
|
40
|
+
_props$required = props.required,
|
|
41
|
+
required = _props$required === void 0 ? false : _props$required,
|
|
42
|
+
shortcutkey = props.shortcutkey,
|
|
43
|
+
_props$show = props.show,
|
|
44
|
+
show = _props$show === void 0 ? true : _props$show,
|
|
45
|
+
_props$tabindex = props.tabindex,
|
|
46
|
+
tabindex = _props$tabindex === void 0 ? 0 : _props$tabindex,
|
|
47
|
+
type = props.type,
|
|
48
|
+
onChange = props.onChange,
|
|
49
|
+
onBlur = props.onBlur,
|
|
50
|
+
className = props.className,
|
|
51
|
+
listener = props.listener,
|
|
52
|
+
onClick = props.onClick,
|
|
53
|
+
onFocus = props.onFocus,
|
|
54
|
+
displayValue = props.displayValue,
|
|
55
|
+
rest = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
56
|
+
var checkboxRef = (0, _react.useRef)(null);
|
|
57
|
+
var prevRefValue = (0, _react.useRef)(null);
|
|
58
|
+
var isInitialized = (0, _react.useRef)(false);
|
|
59
|
+
|
|
60
|
+
// Keep track of the actual value (not just boolean state)
|
|
61
|
+
var _React$useState = _react["default"].useState(function () {
|
|
62
|
+
// Initialize with null/undefined when datavalue is null/undefined
|
|
63
|
+
if (datavalue === null || datavalue === undefined) return null;
|
|
64
|
+
return datavalue === checkedvalue ? checkedvalue : uncheckedvalue;
|
|
65
|
+
}),
|
|
66
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
67
|
+
actualValue = _React$useState2[0],
|
|
68
|
+
setActualValue = _React$useState2[1];
|
|
69
|
+
|
|
70
|
+
// Determine if checkbox should be visually checked
|
|
71
|
+
var isChecked = (0, _react.useMemo)(function () {
|
|
72
|
+
// Only check if actualValue explicitly matches checkedvalue
|
|
73
|
+
return actualValue === checkedvalue;
|
|
74
|
+
}, [actualValue, checkedvalue]);
|
|
75
|
+
|
|
76
|
+
// Update actual value when datavalue prop changes
|
|
77
|
+
(0, _react.useEffect)(function () {
|
|
78
|
+
if (prevRefValue.current === datavalue || isInitialized.current) return;
|
|
79
|
+
if (datavalue === null || datavalue === undefined) {
|
|
80
|
+
setActualValue(null);
|
|
81
|
+
} else {
|
|
82
|
+
var newValue = datavalue === checkedvalue ? checkedvalue : uncheckedvalue;
|
|
83
|
+
setActualValue(newValue);
|
|
84
|
+
prevRefValue.current = datavalue;
|
|
85
|
+
isInitialized.current = true;
|
|
86
|
+
var event = {
|
|
87
|
+
target: {
|
|
88
|
+
checked: newValue
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
handleChange(event);
|
|
92
|
+
}
|
|
93
|
+
}, [datavalue]);
|
|
94
|
+
var handleChange = (0, _react.useCallback)(function (event) {
|
|
95
|
+
// Determine the new actual value based on checkbox state
|
|
96
|
+
var newValue = event.target.checked ? checkedvalue : uncheckedvalue;
|
|
97
|
+
|
|
98
|
+
// Update our internal state with the actual value
|
|
99
|
+
setActualValue(newValue);
|
|
100
|
+
if (listener !== null && listener !== void 0 && listener.onChange) {
|
|
101
|
+
listener.onChange(props.fieldName || name, {
|
|
102
|
+
datavalue: newValue // Pass the actual value, not boolean
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (listener !== null && listener !== void 0 && listener.Widgets[name]) {
|
|
106
|
+
// Store the actual value, not just boolean
|
|
107
|
+
listener.Widgets[name].displayValue = newValue;
|
|
108
|
+
}
|
|
109
|
+
if (onChange) {
|
|
110
|
+
// Pass the actual value in the onChange callback
|
|
111
|
+
onChange(event, listener === null || listener === void 0 ? void 0 : listener.Widgets[name], newValue, actualValue !== null && actualValue !== void 0 ? actualValue : uncheckedvalue);
|
|
112
|
+
}
|
|
113
|
+
}, [checkedvalue, uncheckedvalue, onChange, listener, name, actualValue]);
|
|
114
|
+
var handleBlur = (0, _react.useCallback)(function (event) {
|
|
115
|
+
onBlur === null || onBlur === void 0 || onBlur(event);
|
|
116
|
+
}, [onBlur]);
|
|
117
|
+
var handleFocus = (0, _react.useCallback)(function (event) {
|
|
118
|
+
onFocus === null || onFocus === void 0 || onFocus(event);
|
|
119
|
+
}, [onFocus]);
|
|
120
|
+
var handleKeyDown = (0, _react.useCallback)(function (event) {
|
|
121
|
+
if (disabled || readonly) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (event.key === "Enter") {
|
|
125
|
+
var _checkboxRef$current;
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
(_checkboxRef$current = checkboxRef.current) === null || _checkboxRef$current === void 0 || _checkboxRef$current.click();
|
|
128
|
+
}
|
|
129
|
+
}, []);
|
|
130
|
+
var handleClick = function handleClick(event) {
|
|
131
|
+
// Determine the new actual value based on checkbox state
|
|
132
|
+
if (disabled || readonly) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
var newValue = event.target.checked ? checkedvalue : uncheckedvalue;
|
|
136
|
+
if (listener !== null && listener !== void 0 && listener.Widgets[name]) {
|
|
137
|
+
// Store the actual value, not just boolean
|
|
138
|
+
listener.Widgets[name].displayValue = newValue;
|
|
139
|
+
}
|
|
140
|
+
if (listener !== null && listener !== void 0 && listener.onClick) {
|
|
141
|
+
listener.onClick(name, _objectSpread(_objectSpread({}, props), {}, {
|
|
142
|
+
datavalue: newValue // Pass the actual value
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
if (onClick) {
|
|
146
|
+
// Pass the actual value in the onClick callback
|
|
147
|
+
onClick(event, listener === null || listener === void 0 ? void 0 : listener.Widgets[name], newValue, actualValue);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
var checkboxClasses = [DEFAULT_CLS, type === "toggle" ? "app-toggle" : "", !isChecked ? "unchecked" : "", disabled || readonly ? "disabled" : "", required && caption ? "required" : "", className || ""].filter(Boolean).join(" ");
|
|
151
|
+
var handleMouseEnter = function handleMouseEnter(event) {
|
|
152
|
+
if (props.onMouseEnter) {
|
|
153
|
+
props.onMouseEnter(event, props, displayValue, actualValue);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var handleMouseLeave = function handleMouseLeave(event) {
|
|
157
|
+
if (props.onMouseLeave) {
|
|
158
|
+
props.onMouseLeave(event, props, displayValue, actualValue);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var events = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, props.onMouseEnter ? {
|
|
162
|
+
onMouseEnter: handleMouseEnter
|
|
163
|
+
} : {}), props.onMouseLeave ? {
|
|
164
|
+
onMouseLeave: handleMouseLeave
|
|
165
|
+
} : {}), props.onClick ? {
|
|
166
|
+
onClick: handleClick
|
|
167
|
+
} : {}), props.onFocus ? {
|
|
168
|
+
onFocus: handleFocus
|
|
169
|
+
} : {});
|
|
170
|
+
return __jsx("div", (0, _extends2["default"])({
|
|
171
|
+
className: checkboxClasses,
|
|
172
|
+
style: props.styles
|
|
173
|
+
}, name ? {
|
|
174
|
+
name: name
|
|
175
|
+
} : {}, caption ? {
|
|
176
|
+
caption: caption
|
|
177
|
+
} : {}, type === "toggle" ? {
|
|
178
|
+
type: "toggle"
|
|
179
|
+
} : {}), __jsx(_Box["default"], {
|
|
180
|
+
component: "label",
|
|
181
|
+
className: "wm-checkbox-label ".concat(!isChecked ? "unchecked" : "", " ").concat(disabled || readonly ? "disabled" : "", " ").concat(required && caption ? "required" : ""),
|
|
182
|
+
onKeyDown: handleKeyDown
|
|
183
|
+
}, __jsx(_input.Input, (0, _extends2["default"])({}, events, {
|
|
184
|
+
type: "checkbox",
|
|
185
|
+
ref: checkboxRef,
|
|
186
|
+
"aria-readonly": readonly,
|
|
187
|
+
checked: isChecked // Use the computed isChecked value
|
|
188
|
+
}, !readonly && !disabled ? {
|
|
189
|
+
onChange: handleChange,
|
|
190
|
+
onClick: handleClick
|
|
191
|
+
} : {}, {
|
|
192
|
+
onBlur: handleBlur,
|
|
193
|
+
disabled: disabled,
|
|
194
|
+
required: required,
|
|
195
|
+
name: name,
|
|
196
|
+
"aria-label": arialabel,
|
|
197
|
+
accessKey: shortcutkey,
|
|
198
|
+
tabIndex: tabindex,
|
|
199
|
+
title: hint,
|
|
200
|
+
className: "".concat(disabled || readonly ? "disabled" : "")
|
|
201
|
+
})), __jsx(_Box["default"], {
|
|
202
|
+
component: "span",
|
|
203
|
+
className: "caption",
|
|
204
|
+
dangerouslySetInnerHTML: {
|
|
205
|
+
__html: caption
|
|
206
|
+
}
|
|
207
|
+
}), __jsx(_Box["default"], {
|
|
208
|
+
component: "img",
|
|
209
|
+
alt: "Checkbox Image",
|
|
210
|
+
"aria-hidden": "true",
|
|
211
|
+
src: "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
|
|
212
|
+
className: "switch",
|
|
213
|
+
width: "auto",
|
|
214
|
+
height: "auto"
|
|
215
|
+
})), __jsx(_input.Input, {
|
|
216
|
+
type: "hidden",
|
|
217
|
+
className: "ng-hide model-holder",
|
|
218
|
+
"aria-hidden": "true",
|
|
219
|
+
tabIndex: -1,
|
|
220
|
+
disabled: disabled,
|
|
221
|
+
value: actualValue === null || actualValue === undefined ? "" : String(actualValue) // Handle null/undefined values
|
|
222
|
+
}));
|
|
223
|
+
}, function (prev, next) {
|
|
224
|
+
var keys = ["datavalue", "checkedvalue", "uncheckedvalue", "disabled", "readonly", "required", "shortcutkey", "show", "tabindex", "type", "className"];
|
|
225
|
+
return keys.every(function (key) {
|
|
226
|
+
return prev[key] === next[key];
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
WmCheckbox.displayName = "WmCheckbox";
|
|
230
|
+
var _default = exports["default"] = (0, _withFormController["default"])((0, _withBaseWrapper.withBaseWrapper)(WmCheckbox));
|