@wavemaker/react-runtime 11.14.2-rc.6311 → 12.0.0-next.28533
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 +32 -10
- 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 +26 -9
- 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 +1 -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/tabs/index.js +92 -14
- package/components/container/tabs/tab-pane/index.js +15 -8
- 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 +991 -180
- 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 +54 -33
- 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 +23 -7
- 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 -51
- 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 +147 -70
- 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 +99 -26
- 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 +84 -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 +5 -0
- 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 +824 -724
- 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
|
@@ -12,6 +12,7 @@ var _material = require("@mui/material");
|
|
|
12
12
|
var _DatePicker = require("@mui/x-date-pickers/DatePicker");
|
|
13
13
|
var _TimePicker = require("@mui/x-date-pickers/TimePicker");
|
|
14
14
|
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
15
|
+
var _isEqual = _interopRequireDefault(require("lodash-es/isEqual"));
|
|
15
16
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
16
17
|
var _BaseDateTime = _interopRequireDefault(require("@wavemaker/react-runtime/higherOrder/BaseDateTime"));
|
|
17
18
|
var _withFormController = _interopRequireDefault(require("@wavemaker/react-runtime/components/data/form/form-controller/withFormController"));
|
|
@@ -23,7 +24,7 @@ var __jsx = _react["default"].createElement;
|
|
|
23
24
|
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; }
|
|
24
25
|
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; }
|
|
25
26
|
var DEFAULT_CLS = "app-datetime input-group";
|
|
26
|
-
var WmDateTime = exports.WmDateTime = function
|
|
27
|
+
var WmDateTime = exports.WmDateTime = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
27
28
|
var name = props.name,
|
|
28
29
|
_props$placeholder = props.placeholder,
|
|
29
30
|
placeholder = _props$placeholder === void 0 ? "Select Date Time" : _props$placeholder,
|
|
@@ -32,10 +33,7 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
32
33
|
tabindex = _props$tabindex === void 0 ? 0 : _props$tabindex,
|
|
33
34
|
shortcutkey = props.shortcutkey,
|
|
34
35
|
datavalue = props.datavalue,
|
|
35
|
-
|
|
36
|
-
datepattern = _props$datepattern === void 0 ? (0, _store.useAppSelector)(function (state) {
|
|
37
|
-
return "".concat(state.i18n.dateFormat, " ").concat(state.i18n.timeFormat) || "MMM d, y h:mm:ss a";
|
|
38
|
-
}) : _props$datepattern,
|
|
36
|
+
datepatternProp = props.datepattern,
|
|
39
37
|
_props$hourstep = props.hourstep,
|
|
40
38
|
hourstep = _props$hourstep === void 0 ? 1 : _props$hourstep,
|
|
41
39
|
_props$minutestep = props.minutestep,
|
|
@@ -84,7 +82,18 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
84
82
|
onBeforeload = props.onBeforeload,
|
|
85
83
|
listener = props.listener,
|
|
86
84
|
floatinglabel = props.floatinglabel,
|
|
87
|
-
styles = props.styles
|
|
85
|
+
styles = props.styles,
|
|
86
|
+
_props$showampmbutton = props.showampmbuttons,
|
|
87
|
+
showampmbuttons = _props$showampmbutton === void 0 ? false : _props$showampmbutton,
|
|
88
|
+
_props$validators = props.validators,
|
|
89
|
+
validators = _props$validators === void 0 ? [] : _props$validators,
|
|
90
|
+
validationmessage = props.validationmessage;
|
|
91
|
+
var defaultDateTimeFormat = (0, _store.useAppSelector)(function (state) {
|
|
92
|
+
return "".concat(state.i18n.dateFormat, " ").concat(state.i18n.timeFormat);
|
|
93
|
+
}) || "MMM d, y h:mm:ss a";
|
|
94
|
+
var datepattern = (0, _react.useMemo)(function () {
|
|
95
|
+
return datepatternProp !== null && datepatternProp !== void 0 ? datepatternProp : defaultDateTimeFormat;
|
|
96
|
+
}, [datepatternProp, defaultDateTimeFormat]);
|
|
88
97
|
|
|
89
98
|
// State management
|
|
90
99
|
var _useState = (0, _react.useState)(false),
|
|
@@ -117,7 +126,9 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
117
126
|
var _useState0 = (0, _react.useState)(true),
|
|
118
127
|
isCurrentMonth = _useState0[0],
|
|
119
128
|
setIsCurrentMonth = _useState0[1];
|
|
120
|
-
|
|
129
|
+
var _useState1 = (0, _react.useState)(""),
|
|
130
|
+
validationFailureMessage = _useState1[0],
|
|
131
|
+
setValidationFailureMessage = _useState1[1];
|
|
121
132
|
// Refs
|
|
122
133
|
var inputRef = (0, _react.useRef)(null);
|
|
123
134
|
var onBeforeloadExecutedRef = (0, _react.useRef)(false);
|
|
@@ -154,14 +165,21 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
154
165
|
// Validate date
|
|
155
166
|
var validateDateWithProps = (0, _react.useCallback)(function (date) {
|
|
156
167
|
if (!date) return true;
|
|
157
|
-
var validation = (0, _utils.validateDate)(date, minDateObj, maxDateObj, excludedDaysArray, excludedDatesArray);
|
|
168
|
+
var validation = (0, _utils.validateDate)(date, minDateObj, maxDateObj, excludedDaysArray, excludedDatesArray, validators, validationmessage);
|
|
158
169
|
setDateNotInRange(validation.isOutOfRange);
|
|
170
|
+
setValidationFailureMessage(validation.validationMessage);
|
|
171
|
+
setInvalidFormat(false);
|
|
172
|
+
setDateNotInRange(false);
|
|
159
173
|
return validation.isValid;
|
|
160
174
|
}, [minDateObj, maxDateObj, excludedDaysArray, excludedDatesArray]);
|
|
161
175
|
|
|
162
176
|
// Handle final date change
|
|
163
177
|
var handleFinalDateChange = (0, _react.useCallback)(function (date, event) {
|
|
164
178
|
if (!date) {
|
|
179
|
+
if (onChange && name && listener !== null && listener !== void 0 && listener.Widgets[name] && props.formfield) {
|
|
180
|
+
onChange(event, listener === null || listener === void 0 ? void 0 : listener.Widgets[name], "", displayValue, false);
|
|
181
|
+
}
|
|
182
|
+
setValidationFailureMessage("");
|
|
165
183
|
setLocalDateValue(null);
|
|
166
184
|
setDisplayValue("");
|
|
167
185
|
setInvalidFormat(false);
|
|
@@ -181,6 +199,9 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
181
199
|
return;
|
|
182
200
|
}
|
|
183
201
|
if (!validateDateWithProps(date)) {
|
|
202
|
+
if (onChange && name && listener !== null && listener !== void 0 && listener.Widgets[name] && props.formfield) {
|
|
203
|
+
onChange(event, listener === null || listener === void 0 ? void 0 : listener.Widgets[name], dateString, displayValue, false);
|
|
204
|
+
}
|
|
184
205
|
return;
|
|
185
206
|
}
|
|
186
207
|
var oldValue = displayValue;
|
|
@@ -309,6 +330,9 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
309
330
|
}
|
|
310
331
|
} else {
|
|
311
332
|
if (required) {
|
|
333
|
+
if (onChange && name && listener !== null && listener !== void 0 && listener.Widgets[name] && props.formfield) {
|
|
334
|
+
onChange(event, listener === null || listener === void 0 ? void 0 : listener.Widgets[name], value, displayValue, false);
|
|
335
|
+
}
|
|
312
336
|
setInvalidFormat(true);
|
|
313
337
|
}
|
|
314
338
|
}
|
|
@@ -420,12 +444,29 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
420
444
|
setIsCurrentDate(true);
|
|
421
445
|
(0, _utils.updateListener)(name, listener, display_time, formatDateWithPattern(currentTime, outputformat), props, undefined, "", formatDateWithPattern(currentTime, "timestamp"));
|
|
422
446
|
} else {
|
|
447
|
+
if (invalidFormat) return;
|
|
423
448
|
setIsCurrentDate(false);
|
|
424
449
|
var parsedDate = (0, _utils.parseDateValue)(datavalue, datepattern);
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
450
|
+
if (!parsedDate && datavalue) {
|
|
451
|
+
if (typeof datavalue === "string" || typeof datavalue === "number") {
|
|
452
|
+
setDisplayValue(String(datavalue));
|
|
453
|
+
}
|
|
454
|
+
setLocalDateValue(null);
|
|
455
|
+
} else {
|
|
456
|
+
if (datavalue == undefined) {
|
|
457
|
+
setLocalDateValue(null);
|
|
458
|
+
setDisplayValue("");
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
setLocalDateValue(parsedDate);
|
|
462
|
+
var formattedValue = formatDateWithPattern(parsedDate);
|
|
463
|
+
setDisplayValue(formattedValue);
|
|
464
|
+
var validationResult = (0, _utils.validateDate)(parsedDate, minDateObj, maxDateObj, excludedDaysArray, excludedDatesArray, validators, validationmessage);
|
|
465
|
+
if (validationResult && !validationResult.isValid) {
|
|
466
|
+
setValidationFailureMessage(validationResult.validationMessage || "");
|
|
467
|
+
}
|
|
468
|
+
(0, _utils.updateListener)(name, listener, formattedValue, formatDateWithPattern(parsedDate, outputformat), props, undefined, "", formatDateWithPattern(parsedDate, "timestamp"));
|
|
469
|
+
}
|
|
429
470
|
}
|
|
430
471
|
}, [datavalue, datepattern, formatDateWithPattern]);
|
|
431
472
|
(0, _react.useEffect)(function () {
|
|
@@ -453,11 +494,15 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
453
494
|
}
|
|
454
495
|
}, [autofocus]);
|
|
455
496
|
var timeViews = (0, _utils.getTimeViews)(datepattern);
|
|
497
|
+
var isDisabled = (0, _react.useMemo)(function () {
|
|
498
|
+
return readonly || disabled || isCurrentDate;
|
|
499
|
+
}, [readonly, disabled, isCurrentDate]);
|
|
456
500
|
return __jsx(_material.Box, {
|
|
457
501
|
style: styles,
|
|
458
502
|
ref: anchorRef,
|
|
459
503
|
className: (0, _clsx["default"])(DEFAULT_CLS, className === null || className === void 0 ? void 0 : className.replace("form-control", "")),
|
|
460
|
-
title: hint
|
|
504
|
+
title: hint,
|
|
505
|
+
hidden: props.hidden
|
|
461
506
|
}, __jsx(_material.TextField, {
|
|
462
507
|
disabled: disabled || readonly,
|
|
463
508
|
"aria-readonly": readonly,
|
|
@@ -495,8 +540,8 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
495
540
|
},
|
|
496
541
|
autoFocus: autofocus,
|
|
497
542
|
required: required,
|
|
498
|
-
error: invalidFormat || dateNotInRange,
|
|
499
|
-
helperText: invalidFormat ? "Invalid date format" : dateNotInRange ? "Date not in valid range" : "",
|
|
543
|
+
error: validationFailureMessage || invalidFormat || dateNotInRange,
|
|
544
|
+
helperText: validationFailureMessage || (invalidFormat ? validationmessage || "Invalid date format" : dateNotInRange ? validationmessage || "Date not in valid range" : ""),
|
|
500
545
|
InputProps: {
|
|
501
546
|
readOnly: isReadOnly,
|
|
502
547
|
placeholder: floatinglabel ? undefined : placeholder
|
|
@@ -544,7 +589,7 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
544
589
|
"aria-expanded": isDateOpen,
|
|
545
590
|
onClick: toggleDatePicker,
|
|
546
591
|
variant: "outlined",
|
|
547
|
-
disabled:
|
|
592
|
+
disabled: isDisabled
|
|
548
593
|
}, __jsx(_material.Box, {
|
|
549
594
|
component: "i",
|
|
550
595
|
className: "app-icon wm-sl-l sl-calendar",
|
|
@@ -559,7 +604,7 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
559
604
|
"aria-expanded": isTimeOpen,
|
|
560
605
|
onClick: toggleTimePicker,
|
|
561
606
|
variant: "outlined",
|
|
562
|
-
disabled:
|
|
607
|
+
disabled: isDisabled
|
|
563
608
|
}, __jsx(_material.Box, {
|
|
564
609
|
component: "i",
|
|
565
610
|
className: "app-icon wm-sl-l sl-time",
|
|
@@ -629,9 +674,7 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
629
674
|
onChange: function onChange(newValue) {
|
|
630
675
|
newValue && handleTimeSelection(newValue.toDate());
|
|
631
676
|
},
|
|
632
|
-
ampm: datepattern.includes("a") || datepattern.includes("A"),
|
|
633
|
-
minTime: minDateObj ? (0, _momentTimezone["default"])(minDateObj) : undefined,
|
|
634
|
-
maxTime: maxDateObj ? (0, _momentTimezone["default"])(maxDateObj) : undefined,
|
|
677
|
+
ampm: showampmbuttons && (datepattern.includes("a") || datepattern.includes("A")),
|
|
635
678
|
slotProps: {
|
|
636
679
|
textField: {
|
|
637
680
|
style: {
|
|
@@ -644,7 +687,7 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
644
687
|
sx: (0, _styled.timePickerSx)()
|
|
645
688
|
},
|
|
646
689
|
actionBar: {
|
|
647
|
-
actions: ["accept"
|
|
690
|
+
actions: ["accept"]
|
|
648
691
|
}
|
|
649
692
|
},
|
|
650
693
|
minutesStep: minutestep,
|
|
@@ -655,6 +698,13 @@ var WmDateTime = exports.WmDateTime = function WmDateTime(props) {
|
|
|
655
698
|
},
|
|
656
699
|
views: timeViews
|
|
657
700
|
}));
|
|
658
|
-
}
|
|
701
|
+
}, function (prev, next) {
|
|
702
|
+
var keys = ["datavalue", "datepattern", "placeholder", "hint", "tabindex", "shortcutkey", "hourstep", "minutestep", "outputformat", "required", "mindate", "maxdate", "excludedays", "excludedates", "showweeks", "autofocus", "readonly", "disabled", "selectfromothermonth", "todaybutton", "clearbutton", "adaptiveposition", "showdropdownon", "dataentrymode", "width", "arialabel", "className", "isValidDate", "formatValidation", "floatinglabel", "styles", "showampmbuttons", "hidden", "validators", "validationmessage"];
|
|
703
|
+
var p = prev;
|
|
704
|
+
var n = next;
|
|
705
|
+
return keys.every(function (key) {
|
|
706
|
+
return (0, _isEqual["default"])(p[key], n[key]);
|
|
707
|
+
});
|
|
708
|
+
});
|
|
659
709
|
WmDateTime.displayName = "WmDateTime";
|
|
660
710
|
var _default = exports["default"] = (0, _BaseDateTime["default"])((0, _withFormController["default"])(WmDateTime));
|
|
@@ -18,7 +18,9 @@ exports.shouldDisableDate = shouldDisableDate;
|
|
|
18
18
|
exports.updateListener = updateListener;
|
|
19
19
|
exports.validateDate = validateDate;
|
|
20
20
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
21
22
|
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
23
|
+
var _util = require("../../../../core/util");
|
|
22
24
|
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; }
|
|
23
25
|
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; }
|
|
24
26
|
// Utility to ensure a date has a time component (otherwise use current time)
|
|
@@ -34,12 +36,22 @@ function ensureTime(date) {
|
|
|
34
36
|
|
|
35
37
|
// Utility to map custom date patterns to moment.js patterns
|
|
36
38
|
function mapToMomentPattern(pattern) {
|
|
37
|
-
return pattern
|
|
39
|
+
return pattern
|
|
40
|
+
// Convert lowercase 'y' sequences (1-4 characters) to uppercase 'Y'
|
|
41
|
+
// This handles cases like "yyyy" or "yy" even when followed by word characters (e.g., "yyyyT")
|
|
42
|
+
.replace(/y{1,4}/g, function (match) {
|
|
43
|
+
return match.toUpperCase();
|
|
44
|
+
})
|
|
45
|
+
// Convert lowercase 'd' sequences (1-2 characters) to uppercase 'D'
|
|
46
|
+
// This handles cases like "dd" even when followed by word characters (e.g., "ddT")
|
|
47
|
+
.replace(/d{1,2}/g, function (match) {
|
|
48
|
+
return match.toUpperCase();
|
|
49
|
+
}).replace(/\bEEEE\b/g, "dddd").replace(/\bEEE\b/g, "ddd").replace(/\bMMMM\b/g, "MMMM").replace(/\bMMM\b/g, "MMM").replace(/\byyyy\b/g, "YYYY").replace(/\byy\b/g, "YY").replace(/\bdd\b/g, "DD").replace(/\bd\b/g, "D").replace(/\bMM\b/g, "MM").replace(/\bM\b/g, "M").replace(/\bHH\b/g, "HH").replace(/\bH\b/g, "H").replace(/\bhh\b/g, "hh").replace(/\bh\b/g, "h").replace(/\bmm\b/g, "mm").replace(/\bm\b/g, "m").replace(/\bss\b/g, "ss").replace(/\ba\b/g, "A").replace(/\bZ\b/g, "ZZ");
|
|
38
50
|
}
|
|
39
51
|
|
|
40
52
|
// Get timezone utility
|
|
41
53
|
function getTimezone() {
|
|
42
|
-
return
|
|
54
|
+
return (0, _util.getTimezone)();
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
// Width style helper
|
|
@@ -104,7 +116,7 @@ function formatDate(date, pattern, timezone) {
|
|
|
104
116
|
return date.toISOString();
|
|
105
117
|
}
|
|
106
118
|
try {
|
|
107
|
-
var momentPattern = mapToMomentPattern(pattern);
|
|
119
|
+
var momentPattern = mapToMomentPattern(pattern).replaceAll("y", "Y").replaceAll("d", "D").replaceAll("a", "A");
|
|
108
120
|
var tz = timezone || getTimezone();
|
|
109
121
|
return (0, _momentTimezone["default"])(date).tz(tz).format(momentPattern);
|
|
110
122
|
} catch (error) {
|
|
@@ -155,34 +167,57 @@ function parseDateValue(datavalue, datepattern) {
|
|
|
155
167
|
}
|
|
156
168
|
return null;
|
|
157
169
|
}
|
|
170
|
+
function getValidatorErrorMessage(validators, validatorType) {
|
|
171
|
+
if (!validators || validators.length === 0) return undefined;
|
|
172
|
+
var validator = validators.find(function (v) {
|
|
173
|
+
return (0, _typeof2["default"])(v) === "object" && v !== null && "type" in v && v.type === validatorType;
|
|
174
|
+
});
|
|
175
|
+
if (validator && (0, _typeof2["default"])(validator) === "object" && "errorMessage" in validator) {
|
|
176
|
+
var errorMessage = validator.errorMessage;
|
|
177
|
+
if (typeof errorMessage === "string") {
|
|
178
|
+
return errorMessage;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
158
183
|
|
|
159
184
|
// Validate date utility
|
|
160
185
|
function validateDate(date, minDateObj, maxDateObj, excludedDaysArray, excludedDatesArray) {
|
|
186
|
+
var validators = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
|
|
187
|
+
var validationmessage = arguments.length > 6 ? arguments[6] : undefined;
|
|
161
188
|
if (!date) return {
|
|
162
189
|
isValid: true,
|
|
163
190
|
isOutOfRange: false
|
|
164
191
|
};
|
|
165
|
-
|
|
166
192
|
// Check min/max date
|
|
167
193
|
if (minDateObj && (0, _momentTimezone["default"])(date).startOf("day").valueOf() < (0, _momentTimezone["default"])(minDateObj).startOf("day").valueOf()) {
|
|
194
|
+
var validatorMessage = getValidatorErrorMessage(validators, "mindate");
|
|
195
|
+
var errorMessage = validatorMessage || validationmessage || "Date is before minimum date";
|
|
168
196
|
return {
|
|
169
197
|
isValid: false,
|
|
170
|
-
isOutOfRange: true
|
|
198
|
+
isOutOfRange: true,
|
|
199
|
+
validationMessage: errorMessage
|
|
171
200
|
};
|
|
172
201
|
}
|
|
173
202
|
if (maxDateObj && (0, _momentTimezone["default"])(date).startOf("day").valueOf() > (0, _momentTimezone["default"])(maxDateObj).startOf("day").valueOf()) {
|
|
203
|
+
var _validatorMessage = getValidatorErrorMessage(validators, "maxdate");
|
|
204
|
+
var _errorMessage = _validatorMessage || validationmessage || "Date is after maximum date";
|
|
174
205
|
return {
|
|
175
206
|
isValid: false,
|
|
176
|
-
isOutOfRange: true
|
|
207
|
+
isOutOfRange: true,
|
|
208
|
+
validationMessage: _errorMessage
|
|
177
209
|
};
|
|
178
210
|
}
|
|
179
211
|
|
|
180
212
|
// Check excluded days
|
|
181
213
|
var day = date.getDay();
|
|
182
214
|
if (excludedDaysArray.includes(day)) {
|
|
215
|
+
var _validatorMessage2 = getValidatorErrorMessage(validators, "excludedays");
|
|
216
|
+
var _errorMessage2 = _validatorMessage2 || validationmessage || "Date is excluded";
|
|
183
217
|
return {
|
|
184
218
|
isValid: false,
|
|
185
|
-
isOutOfRange: true
|
|
219
|
+
isOutOfRange: true,
|
|
220
|
+
validationMessage: _errorMessage2
|
|
186
221
|
};
|
|
187
222
|
}
|
|
188
223
|
|
|
@@ -191,9 +226,12 @@ function validateDate(date, minDateObj, maxDateObj, excludedDaysArray, excludedD
|
|
|
191
226
|
if (excludedDatesArray.some(function (excludedDate) {
|
|
192
227
|
return (0, _momentTimezone["default"])(excludedDate).startOf("day").valueOf() === formattedDate;
|
|
193
228
|
})) {
|
|
229
|
+
var _validatorMessage3 = getValidatorErrorMessage(validators, "excludedates");
|
|
230
|
+
var _errorMessage3 = _validatorMessage3 || validationmessage || "Date is excluded";
|
|
194
231
|
return {
|
|
195
232
|
isValid: false,
|
|
196
|
-
isOutOfRange: true
|
|
233
|
+
isOutOfRange: true,
|
|
234
|
+
validationMessage: _errorMessage3
|
|
197
235
|
};
|
|
198
236
|
}
|
|
199
237
|
return {
|
|
@@ -228,15 +266,16 @@ function getTimeViews(datepattern) {
|
|
|
228
266
|
function updateListener(name, listener, dateString, outputValue, props, onChange, oldValue, timestampValue) {
|
|
229
267
|
var _listener$Widgets, _listener$Widgets2;
|
|
230
268
|
// Update listener widget display value
|
|
231
|
-
if (name && listener !== null && listener !== void 0 && (_listener$Widgets = listener.Widgets) !== null && _listener$Widgets !== void 0 && _listener$Widgets[name]) {
|
|
269
|
+
if (name && listener !== null && listener !== void 0 && (_listener$Widgets = listener.Widgets) !== null && _listener$Widgets !== void 0 && _listener$Widgets[name] && !props.fieldName) {
|
|
232
270
|
listener.Widgets[name].displayValue = dateString;
|
|
271
|
+
listener.Widgets[name].datavalue = outputValue;
|
|
233
272
|
}
|
|
234
273
|
if (onChange && name && listener !== null && listener !== void 0 && (_listener$Widgets2 = listener.Widgets) !== null && _listener$Widgets2 !== void 0 && _listener$Widgets2[name]) {
|
|
235
274
|
onChange({}, listener.Widgets[name], outputValue, listener.Widgets[name].datavalue);
|
|
236
275
|
}
|
|
237
276
|
// Update listener onChange
|
|
238
277
|
if (listener !== null && listener !== void 0 && listener.onChange) {
|
|
239
|
-
listener.onChange(
|
|
278
|
+
listener.onChange(props.fieldName || name, _objectSpread(_objectSpread({}, props), {}, {
|
|
240
279
|
datavalue: outputValue,
|
|
241
280
|
timestamp: timestampValue
|
|
242
281
|
}));
|
|
@@ -62,7 +62,12 @@ var WmTime = function WmTime(props) {
|
|
|
62
62
|
_onBlur = props.onBlur,
|
|
63
63
|
_onMouseEnter = props.onMouseEnter,
|
|
64
64
|
_onMouseLeave = props.onMouseLeave,
|
|
65
|
-
onBeforeload = props.onBeforeload
|
|
65
|
+
onBeforeload = props.onBeforeload,
|
|
66
|
+
_props$showampmbutton = props.showampmbuttons,
|
|
67
|
+
showampmbuttons = _props$showampmbutton === void 0 ? false : _props$showampmbutton,
|
|
68
|
+
_props$validators = props.validators,
|
|
69
|
+
validators = _props$validators === void 0 ? [] : _props$validators,
|
|
70
|
+
validationmessage = props.validationmessage;
|
|
66
71
|
|
|
67
72
|
// State
|
|
68
73
|
var _useState = (0, _react.useState)(null),
|
|
@@ -105,37 +110,62 @@ var WmTime = function WmTime(props) {
|
|
|
105
110
|
var handleTimeChange = (0, _react.useCallback)(function (newTime, event) {
|
|
106
111
|
var shouldClosePicker = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
107
112
|
if (!newTime) {
|
|
113
|
+
var oldValue = displayValue;
|
|
108
114
|
setInternalValue(null);
|
|
109
115
|
setDisplayValue("");
|
|
110
116
|
setValidationResult({
|
|
111
117
|
isValid: true
|
|
112
118
|
});
|
|
119
|
+
invokeOnChange === null || invokeOnChange === void 0 || invokeOnChange("", {
|
|
120
|
+
$event: event,
|
|
121
|
+
type: "change"
|
|
122
|
+
});
|
|
123
|
+
if (name && listener !== null && listener !== void 0 && listener.Widgets[name]) {
|
|
124
|
+
listener.Widgets[name].displayValue = "";
|
|
125
|
+
}
|
|
126
|
+
(0, _utils.updateListener)(name, listener, props, "", null, "");
|
|
127
|
+
if (onChange && name && listener !== null && listener !== void 0 && listener.Widgets[name]) {
|
|
128
|
+
onChange(event, listener === null || listener === void 0 ? void 0 : listener.Widgets[name], "", oldValue);
|
|
129
|
+
}
|
|
113
130
|
if (shouldClosePicker) setShowPicker === null || setShowPicker === void 0 || setShowPicker(false);
|
|
114
131
|
return;
|
|
115
132
|
}
|
|
116
|
-
var validation = (0, _utils.validateTimeRange)(newTime,
|
|
133
|
+
var validation = (0, _utils.validateTimeRange)(newTime, mintime, maxtime, validators, validationmessage);
|
|
117
134
|
setValidationResult(validation);
|
|
118
135
|
if (validation.isValid) {
|
|
119
136
|
setInternalValue((0, _momentTimezone["default"])(newTime));
|
|
120
137
|
var formattedValue = (0, _utils.formatDisplayTimeValue)(newTime, timepattern);
|
|
138
|
+
var outputFormattedValue = (0, _utils.formatDisplayTimeValue)(newTime, outputformat);
|
|
121
139
|
setDisplayValue(formattedValue);
|
|
122
|
-
invokeOnChange === null || invokeOnChange === void 0 || invokeOnChange(
|
|
140
|
+
invokeOnChange === null || invokeOnChange === void 0 || invokeOnChange(outputFormattedValue, {
|
|
123
141
|
$event: event,
|
|
124
142
|
type: "change"
|
|
125
143
|
});
|
|
126
144
|
if (name && listener !== null && listener !== void 0 && listener.Widgets[name]) {
|
|
127
145
|
listener.Widgets[name].displayValue = formattedValue;
|
|
128
146
|
}
|
|
129
|
-
(0, _utils.updateListener)(name, listener, props, formattedValue, (0, _utils.formatDisplayTimeValue)(newTime, "timestamp"),
|
|
147
|
+
(0, _utils.updateListener)(name, listener, props, formattedValue, (0, _utils.formatDisplayTimeValue)(newTime, "timestamp"), outputFormattedValue);
|
|
130
148
|
if (onChange && name && listener !== null && listener !== void 0 && listener.Widgets[name]) {
|
|
131
|
-
onChange(
|
|
149
|
+
onChange(event, name && (listener === null || listener === void 0 ? void 0 : listener.Widgets[name]), outputFormattedValue, displayValue);
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
var _formattedValue = (0, _utils.formatDisplayTimeValue)(newTime, timepattern);
|
|
153
|
+
if (onChange && name && listener !== null && listener !== void 0 && listener.Widgets[name] && props.formfield) {
|
|
154
|
+
onChange(event, name && (listener === null || listener === void 0 ? void 0 : listener.Widgets[name]), _formattedValue, displayValue, false);
|
|
132
155
|
}
|
|
133
156
|
}
|
|
134
157
|
if (shouldClosePicker) setShowPicker === null || setShowPicker === void 0 || setShowPicker(false);
|
|
135
|
-
}, [
|
|
158
|
+
}, [mintime, maxtime, validators, timepattern, outputformat, invokeOnChange, setShowPicker, name, listener, props, onChange, displayValue]);
|
|
136
159
|
var handlePickerAccept = (0, _react.useCallback)(function (value) {
|
|
137
160
|
if (value && value.isValid()) {
|
|
138
|
-
|
|
161
|
+
var changeEvent = (0, _utils.createWidgetEvent)({
|
|
162
|
+
type: "change",
|
|
163
|
+
name: name,
|
|
164
|
+
value: value,
|
|
165
|
+
anchor: anchorRef.current,
|
|
166
|
+
originalEvent: event
|
|
167
|
+
});
|
|
168
|
+
handleTimeChange(value.toDate(), changeEvent, true);
|
|
139
169
|
}
|
|
140
170
|
}, [handleTimeChange]);
|
|
141
171
|
var handlePickerClose = (0, _react.useCallback)(function () {
|
|
@@ -148,19 +178,25 @@ var WmTime = function WmTime(props) {
|
|
|
148
178
|
handleTimeChange(null, event, false);
|
|
149
179
|
return;
|
|
150
180
|
}
|
|
151
|
-
var formatValidation = (0, _utils.validateTimeFormat)(inputValue, timepattern, required);
|
|
181
|
+
var formatValidation = (0, _utils.validateTimeFormat)(inputValue, timepattern, required, validationmessage);
|
|
152
182
|
if (!formatValidation.isValid) {
|
|
153
183
|
setValidationResult(formatValidation);
|
|
184
|
+
if (onChange && name && listener !== null && listener !== void 0 && listener.Widgets[name] && props.formfield) {
|
|
185
|
+
onChange(event, listener === null || listener === void 0 ? void 0 : listener.Widgets[name], inputValue, displayValue, false);
|
|
186
|
+
}
|
|
154
187
|
setDisplayValue(inputValue);
|
|
155
188
|
return;
|
|
156
189
|
}
|
|
157
190
|
var parsedTime = (0, _utils.parseTimeValue)(inputValue, timepattern);
|
|
158
191
|
if (parsedTime && parsedTime.isValid()) {
|
|
159
|
-
var rangeValidation = (0, _utils.validateTimeRange)(parsedTime.toDate(),
|
|
192
|
+
var rangeValidation = (0, _utils.validateTimeRange)(parsedTime.toDate(), mintime, maxtime, validators, validationmessage);
|
|
160
193
|
setValidationResult(rangeValidation);
|
|
161
194
|
if (rangeValidation.isValid) {
|
|
162
195
|
handleTimeChange(parsedTime.toDate(), event, false);
|
|
163
196
|
} else {
|
|
197
|
+
if (onChange && name && listener !== null && listener !== void 0 && listener.Widgets[name] && props.formfield) {
|
|
198
|
+
onChange(event, listener === null || listener === void 0 ? void 0 : listener.Widgets[name], inputValue, displayValue, false);
|
|
199
|
+
}
|
|
164
200
|
setDisplayValue(inputValue);
|
|
165
201
|
}
|
|
166
202
|
} else {
|
|
@@ -168,7 +204,7 @@ var WmTime = function WmTime(props) {
|
|
|
168
204
|
setValidationResult({
|
|
169
205
|
isValid: false,
|
|
170
206
|
errorType: "format",
|
|
171
|
-
message: "Invalid time format. Expected: ".concat(timepattern)
|
|
207
|
+
message: validationmessage || "Invalid time format. Expected: ".concat(timepattern)
|
|
172
208
|
});
|
|
173
209
|
}
|
|
174
210
|
setDisplayValue(inputValue);
|
|
@@ -178,10 +214,10 @@ var WmTime = function WmTime(props) {
|
|
|
178
214
|
setValidationResult({
|
|
179
215
|
isValid: false,
|
|
180
216
|
errorType: "format",
|
|
181
|
-
message: "Error processing input"
|
|
217
|
+
message: validationmessage || "Error processing input"
|
|
182
218
|
});
|
|
183
219
|
}
|
|
184
|
-
}, [handleTimeChange, timepattern,
|
|
220
|
+
}, [handleTimeChange, timepattern, mintime, maxtime, validators, required, validationmessage]);
|
|
185
221
|
var handleClick = (0, _react.useCallback)(function (event) {
|
|
186
222
|
try {
|
|
187
223
|
if (disabled || readonly || isCurrentTime) return;
|
|
@@ -253,16 +289,20 @@ var WmTime = function WmTime(props) {
|
|
|
253
289
|
if (datavalue) {
|
|
254
290
|
var parsed;
|
|
255
291
|
if (typeof datavalue === "string" && /^\d+$/.test(datavalue)) {
|
|
256
|
-
parsed = (0, _momentTimezone["default"])(parseInt(datavalue, 10));
|
|
292
|
+
parsed = (0, _momentTimezone["default"])(parseInt(datavalue, 10), timepattern, true);
|
|
257
293
|
} else if (typeof datavalue === "number") {
|
|
258
294
|
parsed = (0, _momentTimezone["default"])(datavalue);
|
|
259
295
|
} else if (datavalue instanceof Date) {
|
|
260
296
|
parsed = (0, _momentTimezone["default"])(datavalue);
|
|
261
297
|
} else {
|
|
262
|
-
parsed = (0, _momentTimezone["default"])(datavalue, timepattern);
|
|
298
|
+
parsed = (0, _momentTimezone["default"])(datavalue, timepattern, true);
|
|
263
299
|
}
|
|
264
300
|
setInternalValue(parsed);
|
|
265
|
-
|
|
301
|
+
if (parsed.isValid()) {
|
|
302
|
+
setDisplayValue((0, _utils.formatDisplayTimeValue)(parsed, timepattern));
|
|
303
|
+
} else {
|
|
304
|
+
setDisplayValue(datavalue);
|
|
305
|
+
}
|
|
266
306
|
(0, _utils.updateListener)(name, listener, props, (0, _utils.formatDisplayTimeValue)(parsed, timepattern), (0, _utils.formatDisplayTimeValue)(parsed, "timestamp"), (0, _utils.formatDisplayTimeValue)(parsed, outputformat));
|
|
267
307
|
} else {
|
|
268
308
|
setInternalValue(null);
|
|
@@ -296,11 +336,16 @@ var WmTime = function WmTime(props) {
|
|
|
296
336
|
var _props$listener;
|
|
297
337
|
if (onBeforeload && name && (_props$listener = props.listener) !== null && _props$listener !== void 0 && (_props$listener = _props$listener.Widgets) !== null && _props$listener !== void 0 && _props$listener[name] && !onBeforeloadExecutedRef.current) {
|
|
298
338
|
var _props$listener2;
|
|
299
|
-
var
|
|
300
|
-
|
|
339
|
+
var beforeEvent = (0, _utils.createWidgetEvent)({
|
|
340
|
+
type: "beforeload",
|
|
341
|
+
name: name,
|
|
342
|
+
value: displayValue,
|
|
343
|
+
anchor: anchorRef.current
|
|
344
|
+
});
|
|
345
|
+
onBeforeload(beforeEvent, (_props$listener2 = props.listener) === null || _props$listener2 === void 0 || (_props$listener2 = _props$listener2.Widgets) === null || _props$listener2 === void 0 ? void 0 : _props$listener2[name]);
|
|
301
346
|
onBeforeloadExecutedRef.current = true;
|
|
302
347
|
}
|
|
303
|
-
}, [
|
|
348
|
+
}, []);
|
|
304
349
|
|
|
305
350
|
// Render the main TextField component
|
|
306
351
|
var renderTextField = (0, _react.useCallback)(function () {
|
|
@@ -377,6 +422,7 @@ var WmTime = function WmTime(props) {
|
|
|
377
422
|
var views = ["hours", "minutes"];
|
|
378
423
|
if (timeFormatOptions.hasSeconds) views.push("seconds");
|
|
379
424
|
return __jsx(_material.Box, {
|
|
425
|
+
hidden: props.hidden,
|
|
380
426
|
className: (0, _clsx["default"])(_utils.DEFAULT_CLASS, className)
|
|
381
427
|
}, renderTextField(), showPicker && __jsx(_xDatePickers.TimePicker, {
|
|
382
428
|
disableIgnoringDatePartForTimeValidation: true,
|
|
@@ -392,7 +438,7 @@ var WmTime = function WmTime(props) {
|
|
|
392
438
|
},
|
|
393
439
|
minTime: minTimeObj ? (0, _momentTimezone["default"])(minTimeObj) : undefined,
|
|
394
440
|
maxTime: maxTimeObj ? (0, _momentTimezone["default"])(maxTimeObj) : undefined,
|
|
395
|
-
ampm: timeFormatOptions.is12Hour,
|
|
441
|
+
ampm: timeFormatOptions.is12Hour && showampmbuttons,
|
|
396
442
|
views: views,
|
|
397
443
|
skipDisabled: true,
|
|
398
444
|
ampmInClock: timeFormatOptions.is12Hour,
|
|
@@ -405,6 +451,9 @@ var WmTime = function WmTime(props) {
|
|
|
405
451
|
anchorEl: anchorRef.current,
|
|
406
452
|
placement: "bottom-start",
|
|
407
453
|
sx: _utils.TIME_PICKER_STYLES
|
|
454
|
+
},
|
|
455
|
+
actionBar: {
|
|
456
|
+
actions: ["accept"]
|
|
408
457
|
}
|
|
409
458
|
}
|
|
410
459
|
}));
|