@wavemaker/react-runtime 11.14.2-rc.6311 → 11.15.0-1.246
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 +5 -7
- package/actions/login-action.js +7 -8
- package/actions/logout-action.js +5 -7
- package/actions/navigation-action.js +73 -18
- package/actions/notification-action.js +22 -8
- package/actions/timer-action.js +13 -15
- package/actions/toast.js +4 -2
- package/actions/toast.service.js +1 -2
- package/components/advanced/carousel/index.js +1 -1
- package/components/advanced/carousel/template.js +1 -1
- package/components/basic/anchor/index.js +31 -11
- package/components/basic/html/index.js +115 -24
- package/components/basic/icon/index.js +2 -1
- package/components/basic/iframe/index.js +2 -1
- package/components/basic/label/index.js +12 -9
- package/components/basic/message/index.js +12 -3
- package/components/basic/picture/index.js +11 -4
- package/components/basic/progress-bar/index.js +4 -1
- package/components/basic/progress-circle/index.js +34 -28
- package/components/basic/progress-circle/props.js +10 -2
- package/components/basic/richtexteditor/index.js +95 -94
- package/components/basic/search/index.js +401 -156
- package/components/basic/search/providers.js +126 -61
- package/components/basic/spinner/index.js +2 -1
- package/components/basic/tree/index.js +34 -34
- package/components/basic/tree/utils.js +10 -4
- package/components/chart/components/barColumnChart/index.js +36 -33
- package/components/chart/components/bubbleChart/index.js +35 -25
- package/components/chart/components/chartLegend/utils.js +2 -1
- package/components/chart/components/cumulativeLineChart/index.js +30 -26
- package/components/chart/components/lineAreaChart/index.js +50 -32
- package/components/chart/components/pieDonutChart/index.js +13 -4
- package/components/chart/hooks/useXAxisConfig.js +15 -8
- package/components/chart/index.js +223 -53
- package/components/chart/utils.js +12 -1
- package/components/constants.js +5 -2
- package/components/container/accordion/accordion-pane/index.js +17 -12
- package/components/container/accordion/index.js +9 -4
- package/components/container/alignment-utils.js +56 -1
- package/components/container/index.js +49 -20
- package/components/container/panel/components/panel-header/index.js +3 -4
- package/components/container/panel/index.js +15 -10
- package/components/container/repeat-template/index.js +33 -0
- package/components/container/tabs/index.js +83 -14
- package/components/container/tabs/tab-pane/index.js +33 -10
- package/components/container/tabs/utils.js +51 -0
- package/components/container/wizard/components/StepComponents.js +2 -1
- package/components/container/wizard/components/WizardStep.js +2 -1
- package/components/container/wizard/index.js +64 -35
- package/components/container/wizard/utils.js +46 -1
- package/components/container/wizard/wizard-step/index.js +11 -1
- package/components/data/card/card-content/index.js +1 -1
- package/components/data/form/base-form/index.js +985 -183
- package/components/data/form/base-form/props.js +3 -1
- package/components/data/form/base-form/utils.js +159 -1
- package/components/data/form/dynamic-fields/constant.js +53 -0
- package/components/data/form/dynamic-fields/index.js +10 -45
- package/components/data/form/dynamic-fields/utils.js +37 -2
- package/components/data/form/form-action/index.js +5 -4
- package/components/data/form/form-context.js +5 -1
- package/components/data/form/form-controller/utils.js +84 -0
- package/components/data/form/form-controller/validation-contrustor.js +402 -189
- package/components/data/form/form-controller/withFormController.js +191 -52
- package/components/data/form/form-field/base-field.js +67 -45
- package/components/data/form/form-field/index.js +28 -5
- package/components/data/form/form-header/index.js +3 -4
- package/components/data/form/index.js +20 -1
- package/components/data/list/components/ListDND.js +2 -1
- package/components/data/list/components/ListItem.js +6 -2
- package/components/data/list/components/ListItemWithTemplate.js +46 -2
- package/components/data/list/components/ListItems.js +17 -26
- package/components/data/list/components/ListPagination.js +3 -3
- package/components/data/list/components/StandardListItems.js +3 -4
- package/components/data/list/hooks/useListEffects.js +55 -14
- package/components/data/list/hooks/useListEventHandlers.js +3 -1
- package/components/data/list/hooks/useListState.js +3 -1
- package/components/data/list/hooks/usePaginatedGroupedData.js +18 -5
- package/components/data/list/index.js +74 -55
- package/components/data/list/utils/list-helpers.js +73 -35
- package/components/data/list/utils/list-widget-methods.js +138 -95
- package/components/data/live-filter/index.js +26 -15
- package/components/data/live-form/index.js +51 -18
- package/components/data/live-form/props.js +1 -1
- package/components/data/pagination/components/BasicPagination.js +71 -16
- package/components/data/pagination/components/PageSizeSelector.js +8 -3
- package/components/data/pagination/components/TotalRecords.js +1 -5
- package/components/data/pagination/hooks/usePagination.js +349 -66
- package/components/data/pagination/index.js +137 -19
- package/components/data/table/components/AddNewRow.js +5 -1
- package/components/data/table/components/EditableCell.js +2 -2
- package/components/data/table/components/RowCells.js +64 -0
- package/components/data/table/components/RowExpansionButton.js +2 -2
- package/components/data/table/components/SummaryCell.js +111 -0
- package/components/data/table/components/SummaryRow.js +54 -0
- package/components/data/table/components/SummaryRowFooter.js +46 -0
- package/components/data/table/components/TableBody.js +61 -59
- package/components/data/table/components/TableDataRow.js +109 -0
- package/components/data/table/components/TableFilters.js +225 -121
- package/components/data/table/components/TableHeader.js +291 -23
- package/components/data/table/components/TablePanelHeading.js +139 -8
- package/components/data/table/components/index.js +22 -1
- package/components/data/table/hooks/use-edited-rows.js +141 -0
- package/components/data/table/hooks/useCellState.js +5 -12
- package/components/data/table/hooks/useFormWidget.js +58 -52
- package/components/data/table/hooks/usePaginationState.js +45 -24
- package/components/data/table/hooks/usePanelStructure.js +4 -4
- package/components/data/table/hooks/useRowHandlers.js +39 -5
- package/components/data/table/hooks/useRowSelection.js +244 -50
- package/components/data/table/hooks/useServerSideSorting.js +81 -37
- package/components/data/table/hooks/useTableColumns.js +211 -118
- package/components/data/table/hooks/useTableData.js +54 -9
- package/components/data/table/hooks/useTableEdit.js +272 -97
- package/components/data/table/hooks/useTableEffects.js +31 -13
- package/components/data/table/hooks/useTableFilter.js +1 -1
- package/components/data/table/hooks/useTableInitialization.js +23 -22
- package/components/data/table/hooks/useTableState.js +11 -5
- package/components/data/table/hooks/useTableStateManager.js +140 -65
- package/components/data/table/index.js +637 -274
- package/components/data/table/live-table/index.js +54 -22
- package/components/data/table/table-action/index.js +1 -1
- package/components/data/table/table-group/index.js +26 -0
- package/components/data/table/table-row-action/index.js +32 -18
- package/components/data/table/utils/buildSelectionColumns.js +12 -21
- package/components/data/table/utils/columnBuilder.js +29 -14
- package/components/data/table/utils/columnProxy.js +68 -1
- package/components/data/table/utils/constants.js +6 -2
- package/components/data/table/utils/crud-handlers.js +68 -63
- package/components/data/table/utils/groupHeaderUtils.js +102 -0
- package/components/data/table/utils/index.js +210 -21
- package/components/data/table/utils/renderDisplayCell.js +6 -6
- package/components/data/table/utils/selectionUtils.js +25 -26
- package/components/data/table/utils/validation.js +1 -0
- package/components/data/utils/filter-field-util.js +3 -3
- package/components/dialogs/alert-dialog/index.js +1 -1
- package/components/dialogs/confirm-dialog/index.js +1 -1
- package/components/dialogs/dialog/index.js +4 -1
- package/components/dialogs/dialog-content/index.js +3 -1
- package/components/dialogs/dialog-header/index.js +2 -2
- package/components/dialogs/iframe-dialog/index.js +11 -5
- package/components/dialogs/index.js +1 -1
- package/components/dialogs/login-dialog/index.js +1 -1
- package/components/dialogs/page-dialog/index.js +1 -1
- package/components/form/button/index.js +33 -7
- package/components/input/calendar/index.js +18 -6
- package/components/input/chips/index.js +99 -28
- package/components/input/chips/utils.js +34 -4
- package/components/input/color-picker/index.js +74 -25
- package/components/input/composite/index.js +3 -3
- package/components/input/currency/index.js +35 -49
- package/components/input/default/checkbox/index.js +23 -28
- package/components/input/default/checkboxset/index.js +38 -18
- package/components/input/default/checkboxset/utils.js +30 -0
- package/components/input/default/radioset/index.js +36 -39
- package/components/input/default/switch/index.js +30 -13
- package/components/input/epoch/date/index.js +130 -69
- package/components/input/epoch/date/utils.js +94 -1
- package/components/input/epoch/datetime/index.js +72 -22
- package/components/input/epoch/datetime/utils.js +49 -10
- package/components/input/epoch/time/index.js +68 -19
- package/components/input/epoch/time/utils.js +62 -14
- package/components/input/fileupload/Utils.js +12 -7
- package/components/input/fileupload/components/MultiUpload.js +2 -6
- package/components/input/fileupload/components/SingleUpload.js +3 -7
- package/components/input/fileupload/index.js +6 -10
- package/components/input/fileupload/useFileUpload.js +16 -5
- package/components/input/number/index.js +158 -43
- package/components/input/rating/index.js +90 -7
- package/components/input/select/index.js +209 -72
- package/components/input/slider/index.js +84 -26
- package/components/input/text/index.js +38 -18
- package/components/input/text/util.js +283 -130
- package/components/input/textarea/index.js +13 -10
- package/components/input/upload/index.js +124 -0
- package/components/input/upload/props.js +5 -0
- package/components/input/util/index.js +11 -0
- package/components/navbar/index.js +51 -3
- package/components/navbar/nav/index.js +46 -16
- package/components/navbar/nav-item/index.js +11 -5
- package/components/navigation/menu/components/ListItems.js +3 -0
- package/components/navigation/menu/constants.js +2 -1
- package/components/navigation/menu/hooks/useHoverState.hook.js +48 -0
- package/components/navigation/menu/hooks/useKeyboardMovements.hook.js +37 -0
- package/components/navigation/menu/hooks/useTransformedDataset.hook.js +15 -0
- package/components/navigation/menu/index.js +326 -188
- package/components/navigation/menu/utils/action-task.js +14 -0
- package/components/navigation/menu/utils/role-filter.js +76 -0
- package/components/navigation/popover/index.js +105 -32
- package/components/page/partial-container/index.js +34 -5
- package/components/prefab/index.js +2 -4
- package/context/PrefabContext.js +10 -6
- package/context/WidgetProvider.js +30 -31
- package/core/app.service.js +1 -1
- package/core/constants/events.js +57 -1
- package/core/dialog.service.js +1 -2
- package/core/event-notifier.js +1 -2
- package/core/formatter/array-formatters.js +33 -0
- package/core/formatter/date-formatters.js +2 -4
- package/core/formatter/index.js +2 -1
- package/core/formatter/number-formatters.js +5 -10
- package/core/formatter/security-formatters.js +2 -4
- package/core/formatter/string-formatters.js +3 -6
- package/core/proxy-service.js +85 -13
- package/core/script-registry.js +108 -48
- package/core/util/common.js +4 -4
- package/core/util/compare.js +30 -0
- package/core/util/dom.js +8 -8
- package/core/util/index.js +16 -6
- package/core/util/safe-is-equal.js +156 -0
- package/core/util/security.js +1 -2
- package/core/util/utils.js +16 -7
- package/higherOrder/BaseApp.js +108 -65
- package/higherOrder/BaseDateTime.js +31 -13
- package/higherOrder/BasePage.js +268 -144
- package/higherOrder/BasePartial.js +1 -1
- package/higherOrder/BasePrefab.js +33 -15
- package/higherOrder/DataNav.js +99 -16
- package/higherOrder/helper.js +41 -3
- package/higherOrder/withBaseWrapper.js +41 -28
- package/hooks/useAuth.js +11 -5
- package/hooks/useHttp.js +280 -94
- package/mui-config/theme-provider.js +1 -1
- package/mui-config/theme.js +1 -1
- package/package-lock.json +840 -740
- package/package.json +8 -8
- package/store/bindActions/i18nActions.js +18 -0
- package/store/index.js +3 -1
- package/store/slices/appConfigSlice.js +2 -2
- package/store/slices/authSlice.js +31 -28
- package/store/slices/i18nSlice.js +2 -2
- package/store/slices/navigationSlice.js +35 -0
- package/store/viewport.service.js +255 -0
- package/utils/attr.js +35 -0
- package/utils/dataset-util.js +1 -2
- package/utils/form-state.util.js +43 -12
- package/utils/form-utils.js +47 -2
- package/utils/format-util.js +28 -13
- package/utils/page-params-util.js +33 -1
- package/utils/state-persistance.js +72 -13
- package/utils/transformedDataset-utils.js +35 -24
- package/variables/base-variable.js +12 -14
- package/variables/crud-variable.js +225 -0
- package/variables/live-variable.js +56 -20
- package/variables/metadata.service.js +123 -0
- package/variables/model-variable.js +21 -15
- package/variables/service-variable.js +88 -83
|
@@ -15,6 +15,7 @@ var lodash = _interopRequireWildcard(require("lodash-es"));
|
|
|
15
15
|
var _withBaseWrapper = require("@wavemaker/react-runtime/higherOrder/withBaseWrapper");
|
|
16
16
|
var _withFormController = _interopRequireDefault(require("@wavemaker/react-runtime/components/data/form/form-controller/withFormController"));
|
|
17
17
|
var _formatUtil = require("@wavemaker/react-runtime/utils/format-util");
|
|
18
|
+
var _util = require("../util");
|
|
18
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); }
|
|
19
20
|
var __jsx = _react["default"].createElement;
|
|
20
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; }
|
|
@@ -34,6 +35,14 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
34
35
|
autofocus = props.autofocus,
|
|
35
36
|
_props$datavalue = props.datavalue,
|
|
36
37
|
initialDataValue = _props$datavalue === void 0 ? null : _props$datavalue,
|
|
38
|
+
_props$maxDataValue = props.maxDataValue,
|
|
39
|
+
initialMaxDataValue = _props$maxDataValue === void 0 ? null : _props$maxDataValue,
|
|
40
|
+
_props$maxvalue = props.maxvalue,
|
|
41
|
+
initialMaxValue = _props$maxvalue === void 0 ? null : _props$maxvalue,
|
|
42
|
+
_props$maxdisplayValu = props.maxdisplayValue,
|
|
43
|
+
initialMaxDisplayValue = _props$maxdisplayValu === void 0 ? null : _props$maxdisplayValu,
|
|
44
|
+
_props$isMaxWidget = props.isMaxWidget,
|
|
45
|
+
isMaxWidget = _props$isMaxWidget === void 0 ? false : _props$isMaxWidget,
|
|
37
46
|
_props$styles = props.styles,
|
|
38
47
|
styles = _props$styles === void 0 ? {} : _props$styles,
|
|
39
48
|
className = props.className,
|
|
@@ -67,17 +76,20 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
67
76
|
var _useState = (0, _react.useState)(false),
|
|
68
77
|
showError = _useState[0],
|
|
69
78
|
setShowError = _useState[1];
|
|
70
|
-
|
|
79
|
+
// For max widgets: use max-prefixed properties (maxdatavalue, maxvalue)
|
|
80
|
+
// For regular widgets: use regular properties (datavalue)
|
|
81
|
+
var effectiveInitialValue = isMaxWidget ? initialMaxDataValue !== null && initialMaxDataValue !== undefined ? initialMaxDataValue : initialMaxValue !== null && initialMaxValue !== undefined ? initialMaxValue : null : initialDataValue !== null && initialDataValue !== undefined ? initialDataValue : null;
|
|
82
|
+
var _useState2 = (0, _react.useState)(effectiveInitialValue),
|
|
71
83
|
datavalue = _useState2[0],
|
|
72
84
|
setDatavalue = _useState2[1];
|
|
73
|
-
var _useState3 = (0, _react.useState)(
|
|
85
|
+
var _useState3 = (0, _react.useState)(effectiveInitialValue),
|
|
74
86
|
prevDatavalue = _useState3[0],
|
|
75
87
|
setPrevDatavalue = _useState3[1];
|
|
76
|
-
var _useState4 = (0, _react.useState)(
|
|
88
|
+
var _useState4 = (0, _react.useState)(effectiveInitialValue !== null ? effectiveInitialValue.toString() : ""),
|
|
77
89
|
internalValue = _useState4[0],
|
|
78
90
|
setInternalValue = _useState4[1];
|
|
79
91
|
// Add state to preserve the original string input when trailingzero is true
|
|
80
|
-
var _useState5 = (0, _react.useState)(
|
|
92
|
+
var _useState5 = (0, _react.useState)(effectiveInitialValue !== null ? effectiveInitialValue.toString() : ""),
|
|
81
93
|
rawInputValue = _useState5[0],
|
|
82
94
|
setRawInputValue = _useState5[1];
|
|
83
95
|
var _useState6 = (0, _react.useState)(false),
|
|
@@ -87,6 +99,16 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
87
99
|
isTouched = _useState7[0],
|
|
88
100
|
setIsTouched = _useState7[1];
|
|
89
101
|
var inputEl = (0, _react.useRef)(null);
|
|
102
|
+
var effectiveDecimalPlaces = (0, _react.useMemo)(function () {
|
|
103
|
+
if (decimalplaces > 0) return decimalplaces;
|
|
104
|
+
if (inputmode === "financial" && step && step < 1) {
|
|
105
|
+
var stepStr = step.toString();
|
|
106
|
+
if (stepStr.includes(".")) {
|
|
107
|
+
return stepStr.split(".")[1].length;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return decimalplaces;
|
|
111
|
+
}, [decimalplaces, inputmode, step]);
|
|
90
112
|
var displayError = error || isDirty && showError;
|
|
91
113
|
var validateNumber = (0, _react.useCallback)(function (value) {
|
|
92
114
|
return (0, _formatUtil.validateNumericValue)(value, required, minvalue, maxvalue, regexp);
|
|
@@ -94,6 +116,9 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
94
116
|
var debouncedUpdateValue = (0, _react.useCallback)(lodash.debounce(function (value) {
|
|
95
117
|
var validation = validateNumber(value);
|
|
96
118
|
setShowError(!validation.isValid);
|
|
119
|
+
if (prevDatavalue === value) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
97
122
|
if (onChange || listener !== null && listener !== void 0 && listener.onChange) {
|
|
98
123
|
var _listener$onChange;
|
|
99
124
|
var syntheticEvent = {
|
|
@@ -103,15 +128,33 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
103
128
|
},
|
|
104
129
|
currentTarget: inputEl.current
|
|
105
130
|
};
|
|
106
|
-
|
|
131
|
+
// For max widgets, use max-prefixed properties to avoid conflicts with regular widgets
|
|
132
|
+
var updatedWidgetData = isMaxWidget ? {
|
|
133
|
+
maxDataValue: value == null ? "" : value,
|
|
134
|
+
maxvalue: value == null ? "" : value,
|
|
135
|
+
maxdisplayValue: value == null ? "" : value.toString()
|
|
136
|
+
} : {
|
|
107
137
|
datavalue: value == null ? "" : value,
|
|
108
138
|
value: value == null ? "" : value,
|
|
109
139
|
displayValue: value == null ? "" : value.toString()
|
|
110
|
-
}
|
|
140
|
+
};
|
|
141
|
+
listener === null || listener === void 0 || (_listener$onChange = listener.onChange) === null || _listener$onChange === void 0 || _listener$onChange.call(listener, props.fieldName || name, updatedWidgetData, value, prevDatavalue);
|
|
111
142
|
if (onChange) {
|
|
112
|
-
|
|
143
|
+
// Create updated props object with new value
|
|
144
|
+
// For max widgets, use max-prefixed properties
|
|
145
|
+
var updatedProps = isMaxWidget ? _objectSpread(_objectSpread({}, props), {}, {
|
|
146
|
+
maxDataValue: value,
|
|
147
|
+
maxvalue: value,
|
|
148
|
+
maxdisplayValue: value == null ? "" : value.toString()
|
|
149
|
+
}) : _objectSpread(_objectSpread({}, props), {}, {
|
|
150
|
+
datavalue: value,
|
|
151
|
+
value: value,
|
|
152
|
+
displayValue: value == null ? "" : value.toString()
|
|
153
|
+
});
|
|
154
|
+
onChange(syntheticEvent, updatedProps, value, prevDatavalue);
|
|
113
155
|
}
|
|
114
156
|
}
|
|
157
|
+
setPrevDatavalue(value);
|
|
115
158
|
}, parseInt(updatedelay || "10"), {
|
|
116
159
|
leading: parseInt(updatedelay) === 0
|
|
117
160
|
}), [onChange, name, prevDatavalue, updatedelay, validateNumber]);
|
|
@@ -130,8 +173,7 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
130
173
|
};
|
|
131
174
|
}, [shortcutkey]);
|
|
132
175
|
var handleInputChange = function handleInputChange(event) {
|
|
133
|
-
var
|
|
134
|
-
var result = (0, _formatUtil.handleNumericInputChange)(event.target.value, inputmode, decimalplaces, setRawInputValue);
|
|
176
|
+
var result = (0, _formatUtil.handleNumericInputChange)(event.target.value, inputmode, effectiveDecimalPlaces, setRawInputValue);
|
|
135
177
|
if (result.newVal === null && event.target.value !== "") {
|
|
136
178
|
return; // Invalid input, don't update
|
|
137
179
|
}
|
|
@@ -140,13 +182,14 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
140
182
|
var validation = validateNumber(result.newVal);
|
|
141
183
|
setShowError(!validation.isValid);
|
|
142
184
|
if (updateon === "keypress") {
|
|
185
|
+
var _listener$Widgets;
|
|
143
186
|
debouncedUpdateValue(result.newVal);
|
|
187
|
+
onChange === null || onChange === void 0 || onChange(event, listener === null || listener === void 0 || (_listener$Widgets = listener.Widgets) === null || _listener$Widgets === void 0 ? void 0 : _listener$Widgets[name], result.newVal, prevDatavalue);
|
|
144
188
|
}
|
|
145
|
-
onChange === null || onChange === void 0 || onChange(event, listener === null || listener === void 0 || (_listener$Widgets = listener.Widgets) === null || _listener$Widgets === void 0 ? void 0 : _listener$Widgets[name], result.newVal, prevDatavalue);
|
|
146
189
|
};
|
|
147
190
|
var handleBlur = function handleBlur(e) {
|
|
148
191
|
var _listener$Widgets2;
|
|
149
|
-
var formattedValue = (0, _formatUtil.formatOnBlur)(datavalue, rawInputValue, trailingzero,
|
|
192
|
+
var formattedValue = (0, _formatUtil.formatOnBlur)(datavalue, rawInputValue, trailingzero, effectiveDecimalPlaces);
|
|
150
193
|
if (formattedValue) {
|
|
151
194
|
setInternalValue(formattedValue);
|
|
152
195
|
}
|
|
@@ -155,7 +198,7 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
155
198
|
}
|
|
156
199
|
onBlur === null || onBlur === void 0 || onBlur(e, listener === null || listener === void 0 || (_listener$Widgets2 = listener.Widgets) === null || _listener$Widgets2 === void 0 ? void 0 : _listener$Widgets2[name]);
|
|
157
200
|
var validation = validateNumber(datavalue);
|
|
158
|
-
if (!validation.isValid && required) {
|
|
201
|
+
if (!validation.isValid && (required || maxvalue || minvalue)) {
|
|
159
202
|
setIsDirty(true);
|
|
160
203
|
} else {
|
|
161
204
|
setIsDirty(false);
|
|
@@ -166,60 +209,132 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
166
209
|
setShowError(true);
|
|
167
210
|
}
|
|
168
211
|
};
|
|
212
|
+
var handleArrowPress = (0, _react.useCallback)(function (event, direction) {
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
if (readonly || disabled || !step || step === 0) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
var targetVal = event.target.value;
|
|
218
|
+
var currentValue = targetVal && !isNaN(Number.parseFloat(targetVal)) ? Number.parseFloat(targetVal) : datavalue;
|
|
219
|
+
var newValue = (0, _formatUtil.handleStepValue)(currentValue, direction, step, effectiveDecimalPlaces, minvalue, maxvalue);
|
|
220
|
+
var currentPrevValue = datavalue;
|
|
221
|
+
var cleanValue = newValue.toString();
|
|
222
|
+
setInternalValue(cleanValue);
|
|
223
|
+
setDatavalue(newValue);
|
|
224
|
+
setPrevDatavalue(currentPrevValue);
|
|
225
|
+
setRawInputValue(cleanValue);
|
|
226
|
+
var validation = validateNumber(newValue);
|
|
227
|
+
setShowError(!validation.isValid);
|
|
228
|
+
if (onChange || listener !== null && listener !== void 0 && listener.onChange) {
|
|
229
|
+
var _listener$onChange2;
|
|
230
|
+
var syntheticEvent = {
|
|
231
|
+
target: {
|
|
232
|
+
value: newValue.toString(),
|
|
233
|
+
name: name
|
|
234
|
+
},
|
|
235
|
+
currentTarget: inputEl.current
|
|
236
|
+
};
|
|
237
|
+
// For max widgets, use max-prefixed properties to avoid conflicts with regular widgets
|
|
238
|
+
var updatedWidgetData = isMaxWidget ? {
|
|
239
|
+
maxDataValue: newValue == null ? "" : newValue,
|
|
240
|
+
maxvalue: newValue == null ? "" : newValue,
|
|
241
|
+
maxdisplayValue: newValue == null ? "" : newValue.toString()
|
|
242
|
+
} : {
|
|
243
|
+
datavalue: newValue == null ? "" : newValue,
|
|
244
|
+
value: newValue == null ? "" : newValue,
|
|
245
|
+
displayValue: newValue == null ? "" : newValue.toString()
|
|
246
|
+
};
|
|
247
|
+
listener === null || listener === void 0 || (_listener$onChange2 = listener.onChange) === null || _listener$onChange2 === void 0 || _listener$onChange2.call(listener, props.fieldName || name, updatedWidgetData, newValue, currentPrevValue);
|
|
248
|
+
if (onChange) {
|
|
249
|
+
// Create updated props object with new datavalue and displayValue
|
|
250
|
+
var updatedProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
251
|
+
datavalue: newValue,
|
|
252
|
+
displayValue: newValue == null ? "" : newValue.toString()
|
|
253
|
+
});
|
|
254
|
+
onChange(syntheticEvent, updatedProps, newValue, currentPrevValue);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (updateon === "keypress") {
|
|
258
|
+
debouncedUpdateValue(newValue);
|
|
259
|
+
}
|
|
260
|
+
setPrevDatavalue(newValue);
|
|
261
|
+
}, [readonly, disabled, step, datavalue, minvalue, maxvalue, effectiveDecimalPlaces, validateNumber, onChange, name, props, listener, updateon, debouncedUpdateValue]);
|
|
169
262
|
var handleKeyDown = function handleKeyDown(e) {
|
|
170
|
-
var _listener$
|
|
263
|
+
var _listener$Widgets4;
|
|
264
|
+
if (step && step !== 0) {
|
|
265
|
+
if (e.key === "ArrowUp") {
|
|
266
|
+
handleArrowPress(e, "UP");
|
|
267
|
+
return;
|
|
268
|
+
} else if (e.key === "ArrowDown") {
|
|
269
|
+
handleArrowPress(e, "DOWN");
|
|
270
|
+
return;
|
|
271
|
+
} else {
|
|
272
|
+
var _listener$Widgets3;
|
|
273
|
+
onKeydown === null || onKeydown === void 0 || onKeydown(e, listener === null || listener === void 0 || (_listener$Widgets3 = listener.Widgets) === null || _listener$Widgets3 === void 0 ? void 0 : _listener$Widgets3[name]);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
171
276
|
if (e.key === "Enter") {
|
|
172
277
|
debouncedUpdateValue(datavalue);
|
|
173
278
|
}
|
|
174
|
-
onKeydown === null || onKeydown === void 0 || onKeydown(e, listener === null || listener === void 0 || (_listener$
|
|
279
|
+
onKeydown === null || onKeydown === void 0 || onKeydown(e, listener === null || listener === void 0 || (_listener$Widgets4 = listener.Widgets) === null || _listener$Widgets4 === void 0 ? void 0 : _listener$Widgets4[name]);
|
|
175
280
|
};
|
|
176
281
|
var handleKeyUp = function handleKeyUp(e) {
|
|
177
|
-
var _listener$
|
|
178
|
-
onKeyup === null || onKeyup === void 0 || onKeyup(e, listener === null || listener === void 0 || (_listener$
|
|
282
|
+
var _listener$Widgets5;
|
|
283
|
+
onKeyup === null || onKeyup === void 0 || onKeyup(e, listener === null || listener === void 0 || (_listener$Widgets5 = listener.Widgets) === null || _listener$Widgets5 === void 0 ? void 0 : _listener$Widgets5[name]);
|
|
179
284
|
};
|
|
180
285
|
var handleFocus = function handleFocus(e) {
|
|
181
|
-
var _listener$
|
|
182
|
-
onFocus === null || onFocus === void 0 || onFocus(e, listener === null || listener === void 0 || (_listener$
|
|
286
|
+
var _listener$Widgets6;
|
|
287
|
+
onFocus === null || onFocus === void 0 || onFocus(e, listener === null || listener === void 0 || (_listener$Widgets6 = listener.Widgets) === null || _listener$Widgets6 === void 0 ? void 0 : _listener$Widgets6[name]);
|
|
183
288
|
};
|
|
184
289
|
var handleClick = function handleClick(e) {
|
|
185
|
-
var _listener$
|
|
186
|
-
onClick === null || onClick === void 0 || onClick(e, listener === null || listener === void 0 || (_listener$
|
|
290
|
+
var _listener$Widgets7;
|
|
291
|
+
onClick === null || onClick === void 0 || onClick(e, listener === null || listener === void 0 || (_listener$Widgets7 = listener.Widgets) === null || _listener$Widgets7 === void 0 ? void 0 : _listener$Widgets7[name]);
|
|
187
292
|
};
|
|
188
293
|
var handleMouseEnter = function handleMouseEnter(e) {
|
|
189
|
-
var _listener$
|
|
294
|
+
var _listener$Widgets8;
|
|
190
295
|
setIsTouched(true);
|
|
191
|
-
onMouseEnter === null || onMouseEnter === void 0 || onMouseEnter(e, listener === null || listener === void 0 || (_listener$
|
|
296
|
+
onMouseEnter === null || onMouseEnter === void 0 || onMouseEnter(e, listener === null || listener === void 0 || (_listener$Widgets8 = listener.Widgets) === null || _listener$Widgets8 === void 0 ? void 0 : _listener$Widgets8[name]);
|
|
192
297
|
};
|
|
193
298
|
var handleMouseLeave = function handleMouseLeave(e) {
|
|
194
|
-
var _listener$
|
|
299
|
+
var _listener$Widgets9;
|
|
195
300
|
setIsTouched(false);
|
|
196
|
-
onMouseLeave === null || onMouseLeave === void 0 || onMouseLeave(e, listener === null || listener === void 0 || (_listener$
|
|
301
|
+
onMouseLeave === null || onMouseLeave === void 0 || onMouseLeave(e, listener === null || listener === void 0 || (_listener$Widgets9 = listener.Widgets) === null || _listener$Widgets9 === void 0 ? void 0 : _listener$Widgets9[name]);
|
|
197
302
|
};
|
|
198
303
|
var handleKeyPress = function handleKeyPress(e) {
|
|
199
|
-
var _listener$
|
|
200
|
-
onKeypress === null || onKeypress === void 0 || onKeypress(e, listener === null || listener === void 0 || (_listener$
|
|
304
|
+
var _listener$Widgets0;
|
|
305
|
+
onKeypress === null || onKeypress === void 0 || onKeypress(e, listener === null || listener === void 0 || (_listener$Widgets0 = listener.Widgets) === null || _listener$Widgets0 === void 0 ? void 0 : _listener$Widgets0[name]);
|
|
201
306
|
};
|
|
202
307
|
(0, _react.useEffect)(function () {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
308
|
+
// For max widgets: use max-prefixed properties (maxdatavalue, maxvalue)
|
|
309
|
+
// For regular widgets: use regular properties (datavalue)
|
|
310
|
+
var currentInitialValue = isMaxWidget ? initialMaxDataValue !== null && initialMaxDataValue !== undefined ? initialMaxDataValue : initialMaxValue !== null && initialMaxValue !== undefined ? initialMaxValue : null : initialDataValue !== null && initialDataValue !== undefined ? initialDataValue : null;
|
|
311
|
+
|
|
312
|
+
// Only update if the incoming value is different from current state
|
|
313
|
+
// Use a more robust comparison that handles null/undefined/empty string cases
|
|
314
|
+
var currentValue = datavalue !== null && datavalue !== undefined ? datavalue : null;
|
|
315
|
+
var newValue = currentInitialValue;
|
|
316
|
+
if (currentValue !== newValue) {
|
|
317
|
+
setDatavalue(newValue);
|
|
318
|
+
var cleanValue = newValue !== null ? newValue.toString() : "";
|
|
206
319
|
setInternalValue(cleanValue);
|
|
207
320
|
setRawInputValue(cleanValue);
|
|
208
|
-
setPrevDatavalue(
|
|
321
|
+
setPrevDatavalue(currentValue);
|
|
209
322
|
}
|
|
210
|
-
}, [initialDataValue]);
|
|
323
|
+
}, [initialDataValue, initialMaxDataValue, initialMaxValue, isMaxWidget]);
|
|
211
324
|
(0, _react.useEffect)(function () {
|
|
212
325
|
if (inputEl.current) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
326
|
+
var focus = function focus() {
|
|
327
|
+
var _inputEl$current2;
|
|
328
|
+
(_inputEl$current2 = inputEl.current) === null || _inputEl$current2 === void 0 || _inputEl$current2.focus();
|
|
329
|
+
};
|
|
330
|
+
if (listener !== null && listener !== void 0 && listener.Widgets[name]) {
|
|
331
|
+
listener.Widgets[name].focus = focus;
|
|
332
|
+
}
|
|
219
333
|
}
|
|
220
334
|
}, []);
|
|
221
|
-
var events = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(
|
|
222
|
-
onChange: handleInputChange
|
|
335
|
+
var events = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
336
|
+
onChange: handleInputChange,
|
|
337
|
+
onKeyDown: handleKeyDown
|
|
223
338
|
}, onMouseEnter ? {
|
|
224
339
|
onMouseEnter: handleMouseEnter
|
|
225
340
|
} : {}), onMouseLeave ? {
|
|
@@ -228,8 +343,6 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
228
343
|
onClick: handleClick
|
|
229
344
|
} : {}), onFocus ? {
|
|
230
345
|
onFocus: handleFocus
|
|
231
|
-
} : {}), onKeydown ? {
|
|
232
|
-
onKeyDown: handleKeyDown
|
|
233
346
|
} : {}), onKeyup ? {
|
|
234
347
|
onKeyUp: handleKeyUp
|
|
235
348
|
} : {}), onKeypress ? {
|
|
@@ -237,7 +350,9 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
237
350
|
} : {}), updateon === "blur" || onBlur ? {
|
|
238
351
|
onBlur: handleBlur
|
|
239
352
|
} : {});
|
|
353
|
+
var value = (0, _util.sanitizeInputValue)(internalValue);
|
|
240
354
|
return __jsx(_TextField["default"], (0, _extends2["default"])({}, events, {
|
|
355
|
+
hidden: props.hidden,
|
|
241
356
|
title: hint || "Number Input",
|
|
242
357
|
name: name,
|
|
243
358
|
inputRef: inputEl,
|
|
@@ -247,7 +362,7 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
247
362
|
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Enter number",
|
|
248
363
|
type: "text",
|
|
249
364
|
id: id || name,
|
|
250
|
-
value:
|
|
365
|
+
value: value,
|
|
251
366
|
error: displayError,
|
|
252
367
|
className: (0, _clsx["default"])("app-input-wrapper", isTouched ? "ng-touched" : "ng-untouched", displayError ? "ng-invalid" : "ng-valid"),
|
|
253
368
|
slotProps: {
|
|
@@ -286,7 +401,7 @@ var WmNumber = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
286
401
|
}, styles)
|
|
287
402
|
}));
|
|
288
403
|
}, function (prev, current) {
|
|
289
|
-
var keys = ["datavalue", "disabled", "required", "readonly", "placeholder", "maxchars", "tabindex", "shortcutkey", "autofocus", "arialabel", "inputmode", "trailingzero", "decimalplaces", "minvalue", "maxvalue", "className"];
|
|
404
|
+
var keys = ["datavalue", "maxDataValue", "isMaxWidget", "disabled", "required", "readonly", "placeholder", "maxchars", "tabindex", "shortcutkey", "autofocus", "arialabel", "inputmode", "trailingzero", "decimalplaces", "minvalue", "maxvalue", "className", "hidden", "show", "error"];
|
|
290
405
|
return keys.every(function (key) {
|
|
291
406
|
return prev[key] === current[key];
|
|
292
407
|
});
|
|
@@ -61,7 +61,8 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
61
61
|
datavalue = props.datavalue,
|
|
62
62
|
height = props.height,
|
|
63
63
|
dataset = props.dataset,
|
|
64
|
-
styles = props.styles
|
|
64
|
+
styles = props.styles,
|
|
65
|
+
listener = props.listener;
|
|
65
66
|
|
|
66
67
|
// State management
|
|
67
68
|
var _useState = (0, _react.useState)(0),
|
|
@@ -84,6 +85,7 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
84
85
|
setHover = _useState6[1];
|
|
85
86
|
var ratingsRef = (0, _react.useRef)(null);
|
|
86
87
|
var previousValue = (0, _react.useRef)(value);
|
|
88
|
+
var isInternalChange = (0, _react.useRef)(false); // Track internal changes to prevent double listener.onChange calls
|
|
87
89
|
|
|
88
90
|
// Helper functions
|
|
89
91
|
var setDatasetItems = (0, _react.useCallback)(function (items) {
|
|
@@ -95,8 +97,8 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
95
97
|
setCurrentCaption(text);
|
|
96
98
|
}, []);
|
|
97
99
|
var isStarActive = (0, _react.useCallback)(function (index) {
|
|
98
|
-
return index <=
|
|
99
|
-
}, [
|
|
100
|
+
return index <= datavalue;
|
|
101
|
+
}, [datavalue]);
|
|
100
102
|
var isStarHovered = (0, _react.useCallback)(function (index) {
|
|
101
103
|
return hoveredRatingValue !== null && index <= hoveredRatingValue;
|
|
102
104
|
}, [hoveredRatingValue]);
|
|
@@ -146,9 +148,18 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
146
148
|
updateCaptionElement(rate.label);
|
|
147
149
|
}, [readonly, updateCaptionElement]);
|
|
148
150
|
var handleRatingClick = (0, _react.useCallback)(function (rate) {
|
|
151
|
+
var _listener$onChange;
|
|
149
152
|
if (readonly) return;
|
|
150
153
|
var newRating = rate.index === selectedRatingValue ? 0 : rate.index;
|
|
154
|
+
|
|
155
|
+
// Mark this as an internal change to prevent duplicate listener.onChange from onDatavalueChange
|
|
156
|
+
isInternalChange.current = true;
|
|
151
157
|
setSelectedRatingValue(newRating);
|
|
158
|
+
listener === null || listener === void 0 || (_listener$onChange = listener.onChange) === null || _listener$onChange === void 0 || _listener$onChange.call(listener, name, {
|
|
159
|
+
prevDatavalue: previousValue.current,
|
|
160
|
+
_selectedRatingValue: newRating,
|
|
161
|
+
ratingsWidth: calculateRatingsWidth()
|
|
162
|
+
});
|
|
152
163
|
if (showcaptions) {
|
|
153
164
|
var selectedItem = newRating > 0 ? ratingItems.find(function (item) {
|
|
154
165
|
return item.index === newRating;
|
|
@@ -213,7 +224,7 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
213
224
|
var maxVal = Math.min(maxvalue || data.length, 10) || DEFAULT_MAX_VALUE;
|
|
214
225
|
|
|
215
226
|
// Use transformDataset utility to create the dataset
|
|
216
|
-
var transformedItems = (0, _transformedDatasetUtils.transformDataset)(data, datafield, displayfield, displaylabel, displayexpression, undefined, undefined);
|
|
227
|
+
var transformedItems = (0, _transformedDatasetUtils.transformDataset)(data, datafield, displayfield, displaylabel, displayexpression, undefined, undefined, undefined);
|
|
217
228
|
|
|
218
229
|
// If no data provided, create default numeric rating items
|
|
219
230
|
if (!data.length) {
|
|
@@ -227,6 +238,23 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
227
238
|
label: "".concat(maxVal - i)
|
|
228
239
|
};
|
|
229
240
|
});
|
|
241
|
+
} else {
|
|
242
|
+
// Limit transformed items to maxVal when dataset exists
|
|
243
|
+
// Sort first to ensure we keep items with lowest indices
|
|
244
|
+
transformedItems.sort(function (a, b) {
|
|
245
|
+
return a.index - b.index;
|
|
246
|
+
});
|
|
247
|
+
transformedItems = transformedItems.slice(0, maxVal);
|
|
248
|
+
|
|
249
|
+
// Convert 0-based indices to 1-based to match the isStarActive logic
|
|
250
|
+
// The isStarActive function expects 1-based indices where index <= selectedRatingValue
|
|
251
|
+
transformedItems = transformedItems.map(function (item, idx) {
|
|
252
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
253
|
+
index: idx + 1,
|
|
254
|
+
// Convert to 1-based index
|
|
255
|
+
key: idx + 1
|
|
256
|
+
});
|
|
257
|
+
});
|
|
230
258
|
}
|
|
231
259
|
|
|
232
260
|
// Sort items by index in descending order to maintain left-to-right star activation
|
|
@@ -234,7 +262,14 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
234
262
|
return b.index - a.index;
|
|
235
263
|
});
|
|
236
264
|
if (!(0, _lodashEs.isEqual)(transformedItems, ratingItems)) {
|
|
265
|
+
var _listener$onChange2, _listener$onChange3;
|
|
266
|
+
listener === null || listener === void 0 || (_listener$onChange2 = listener.onChange) === null || _listener$onChange2 === void 0 || _listener$onChange2.call(listener, props.fieldName || name, {
|
|
267
|
+
ratingItems: transformedItems
|
|
268
|
+
});
|
|
237
269
|
setRatingItems(transformedItems);
|
|
270
|
+
listener === null || listener === void 0 || (_listener$onChange3 = listener.onChange) === null || _listener$onChange3 === void 0 || _listener$onChange3.call(listener, name, {
|
|
271
|
+
ratingItems: transformedItems
|
|
272
|
+
});
|
|
238
273
|
if (!data.length || processedDataset.length > 0 && data === processedDataset) {
|
|
239
274
|
var currentDatasetItems = processedDataset.length > 0 ? processedDataset : datasetItems;
|
|
240
275
|
if (!(0, _lodashEs.isEqual)(transformedItems, currentDatasetItems)) {
|
|
@@ -243,7 +278,23 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
243
278
|
}
|
|
244
279
|
}
|
|
245
280
|
}, [datasetItems, processedDataset, maxvalue, datafield, displayexpression, setDatasetItems, ratingItems, displaylabel, displayfield]);
|
|
281
|
+
var calculateRatingsWidth = (0, _react.useCallback)(function (selectedDefaultRating) {
|
|
282
|
+
var selectedRating = selectedDefaultRating || selectedRatingValue;
|
|
283
|
+
var starWidth = 0.925;
|
|
284
|
+
var maxValue = maxvalue || datasetItems.length || DEFAULT_MAX_VALUE;
|
|
285
|
+
if (selectedRating <= maxValue && selectedRating >= 0) {
|
|
286
|
+
return selectedRating * starWidth + "em";
|
|
287
|
+
}
|
|
288
|
+
if (selectedRating > maxValue) {
|
|
289
|
+
return maxValue * starWidth + "em";
|
|
290
|
+
}
|
|
291
|
+
}, [selectedRatingValue, maxvalue, datasetItems]);
|
|
246
292
|
var onDatavalueChange = (0, _react.useCallback)(function (dataVal) {
|
|
293
|
+
// Skip ALL updates if this was triggered by an internal click (we already set state in handleRatingClick)
|
|
294
|
+
if (isInternalChange.current) {
|
|
295
|
+
isInternalChange.current = false; // Reset the flag
|
|
296
|
+
return; // Early return - skip all processing for internal changes
|
|
297
|
+
}
|
|
247
298
|
var effectiveDataset = processedDataset.length > 0 ? processedDataset : datasetItems;
|
|
248
299
|
if (!(0, _lodashEs.isEmpty)(effectiveDataset)) {
|
|
249
300
|
var selectedItem = effectiveDataset.find(function (item) {
|
|
@@ -264,18 +315,36 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
264
315
|
}
|
|
265
316
|
}
|
|
266
317
|
if (!selectedItem) {
|
|
318
|
+
var _listener$onChange4;
|
|
267
319
|
setSelectedRatingValue(0);
|
|
320
|
+
listener === null || listener === void 0 || (_listener$onChange4 = listener.onChange) === null || _listener$onChange4 === void 0 || _listener$onChange4.call(listener, props.fieldName || name, {
|
|
321
|
+
_selectedRatingValue: 0,
|
|
322
|
+
datavalue: 0
|
|
323
|
+
});
|
|
268
324
|
setCurrentCaption(caption || "");
|
|
269
325
|
updateCaptionElement(caption || "");
|
|
270
326
|
} else {
|
|
327
|
+
var _listener$onChange5;
|
|
271
328
|
setSelectedRatingValue(selectedItem.index);
|
|
329
|
+
listener === null || listener === void 0 || (_listener$onChange5 = listener.onChange) === null || _listener$onChange5 === void 0 || _listener$onChange5.call(listener, props.fieldName || name, {
|
|
330
|
+
selectedRatingValue: selectedItem.index,
|
|
331
|
+
_selectedRatingValue: selectedItem.index,
|
|
332
|
+
ratingsWidth: calculateRatingsWidth(selectedItem.index),
|
|
333
|
+
datavalue: selectedItem.index
|
|
334
|
+
});
|
|
272
335
|
setCurrentCaption(selectedItem.label);
|
|
273
336
|
updateCaptionElement(selectedItem.label);
|
|
274
337
|
}
|
|
275
338
|
} else {
|
|
276
339
|
if (!isNaN(Number(dataVal))) {
|
|
340
|
+
var _listener$onChange6;
|
|
277
341
|
var rating = Math.min(Math.max(parseFloat(dataVal), 0), maxvalue || DEFAULT_MAX_VALUE);
|
|
278
342
|
setSelectedRatingValue(rating);
|
|
343
|
+
listener === null || listener === void 0 || (_listener$onChange6 = listener.onChange) === null || _listener$onChange6 === void 0 || _listener$onChange6.call(listener, props.fieldName || name, {
|
|
344
|
+
_selectedRatingValue: rating,
|
|
345
|
+
ratingsWidth: calculateRatingsWidth(rating),
|
|
346
|
+
datavalue: rating
|
|
347
|
+
});
|
|
279
348
|
var _selectedItem = ratingItems.find(function (item) {
|
|
280
349
|
return item.index === rating;
|
|
281
350
|
});
|
|
@@ -287,7 +356,13 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
287
356
|
updateCaptionElement(caption || "");
|
|
288
357
|
}
|
|
289
358
|
} else {
|
|
359
|
+
var _listener$onChange7;
|
|
290
360
|
setSelectedRatingValue(0);
|
|
361
|
+
listener === null || listener === void 0 || (_listener$onChange7 = listener.onChange) === null || _listener$onChange7 === void 0 || _listener$onChange7.call(listener, props.fieldName || name, {
|
|
362
|
+
_selectedRatingValue: 0,
|
|
363
|
+
ratingsWidth: calculateRatingsWidth(),
|
|
364
|
+
datavalue: 0
|
|
365
|
+
});
|
|
291
366
|
setCurrentCaption(caption || "");
|
|
292
367
|
updateCaptionElement(caption || "");
|
|
293
368
|
}
|
|
@@ -302,9 +377,14 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
302
377
|
prepareRatingDataset();
|
|
303
378
|
}, [prepareRatingDataset]);
|
|
304
379
|
(0, _react.useEffect)(function () {
|
|
380
|
+
var _listener$onChange8;
|
|
305
381
|
if (datavalue !== undefined) {
|
|
306
382
|
onDatavalueChange(datavalue);
|
|
307
383
|
}
|
|
384
|
+
listener === null || listener === void 0 || (_listener$onChange8 = listener.onChange) === null || _listener$onChange8 === void 0 || _listener$onChange8.call(listener, props.fieldName || name, {
|
|
385
|
+
ratingEl: ratingsRef.current,
|
|
386
|
+
datavalue: datavalue
|
|
387
|
+
});
|
|
308
388
|
}, [datavalue]);
|
|
309
389
|
|
|
310
390
|
// Render methods
|
|
@@ -320,8 +400,10 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
320
400
|
enterNextDelay: 500
|
|
321
401
|
}, __jsx(_material.Box, {
|
|
322
402
|
component: "label",
|
|
323
|
-
onClick: function onClick() {
|
|
324
|
-
|
|
403
|
+
onClick: function onClick(e) {
|
|
404
|
+
e.preventDefault();
|
|
405
|
+
e.stopPropagation();
|
|
406
|
+
handleRatingClick(rate);
|
|
325
407
|
},
|
|
326
408
|
onMouseOver: function onMouseOver() {
|
|
327
409
|
return handleMouseOver(rate);
|
|
@@ -345,6 +427,7 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
345
427
|
setHover(!hover);
|
|
346
428
|
}
|
|
347
429
|
return __jsx(_material.Box, {
|
|
430
|
+
hidden: props.hidden,
|
|
348
431
|
sx: _objectSpread(_objectSpread({}, styles), {}, {
|
|
349
432
|
height: height,
|
|
350
433
|
width: width
|
|
@@ -362,7 +445,7 @@ var WmRating = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
362
445
|
className: "rating-style"
|
|
363
446
|
}, ratingItems.map(renderStar)), showcaptions && (selectedRatingValue !== 0 || hover) && __jsx("label", {
|
|
364
447
|
className: "caption"
|
|
365
|
-
}, currentCaption || caption || "")));
|
|
448
|
+
}, currentCaption || caption || (showcaptions ? datavalue : ""))));
|
|
366
449
|
});
|
|
367
450
|
WmRating.displayName = "WmRating";
|
|
368
451
|
var _default = exports["default"] = (0, _withBaseWrapper.withBaseWrapper)((0, _withFormController["default"])(WmRating));
|