@docsvision/material-ui-pickers 3.2.0-beta.9 → 3.2.1-beta.1

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.
Files changed (54) hide show
  1. package/DatePicker/DatePicker.d.ts +2 -2
  2. package/DatePicker/DatePicker.js +1 -1
  3. package/DatePicker/DatePickerToolbar.js +1 -1
  4. package/DateTimePicker/DateTimePicker.js +1 -1
  5. package/Picker/Picker.js +1 -1
  6. package/Picker/WrappedKeyboardPicker.js +4 -2
  7. package/Picker/WrappedPurePicker.js +4 -2
  8. package/README.md +1 -0
  9. package/Rifm/Rifm.d.ts +17 -0
  10. package/Rifm/Rifm.js +174 -0
  11. package/TimePicker/TimePicker.js +1 -1
  12. package/TimePicker/TimePickerToolbar.js +1 -1
  13. package/_helpers/text-field-helper.d.ts +2 -2
  14. package/_helpers/text-field-helper.js +62 -6
  15. package/_shared/KeyboardDateInput.js +27 -139
  16. package/_shared/ModalDialog.d.ts +2 -2
  17. package/_shared/ModalDialog.js +5 -3
  18. package/_shared/PickerToolbar.d.ts +1 -1
  19. package/_shared/PickerToolbar.js +7 -5
  20. package/_shared/PureDateInput.js +5 -3
  21. package/_shared/ToolbarButton.d.ts +2 -2
  22. package/_shared/ToolbarButton.js +4 -2
  23. package/_shared/ToolbarText.js +9 -7
  24. package/_shared/hooks/useKeyboardPickerState.js +5 -3
  25. package/_shared/hooks/useOpenState.js +1 -1
  26. package/_shared/hooks/usePickerState.js +9 -9
  27. package/constants/prop-types.js +2 -2
  28. package/dist/material-ui-pickers.esm.js +3626 -0
  29. package/dist/material-ui-pickers.esm.js.map +1 -0
  30. package/dist/material-ui-pickers.js +3651 -0
  31. package/dist/material-ui-pickers.js.map +1 -0
  32. package/dist/material-ui-pickers.umd.js +34161 -0
  33. package/dist/material-ui-pickers.umd.min.js +1 -0
  34. package/package.json +3 -4
  35. package/typings/BasePicker.d.ts +1 -1
  36. package/typings/overrides.d.ts +2 -2
  37. package/views/Calendar/Calendar.js +3 -2
  38. package/views/Calendar/CalendarHeader.d.ts +1 -1
  39. package/views/Calendar/Day.d.ts +1 -1
  40. package/views/Calendar/Day.js +5 -3
  41. package/views/Calendar/DayWrapper.js +4 -2
  42. package/views/Calendar/SlideTransition.d.ts +1 -1
  43. package/views/Clock/Clock.d.ts +1 -1
  44. package/views/Clock/ClockNumber.d.ts +1 -1
  45. package/views/Clock/ClockNumber.js +1 -1
  46. package/views/Clock/ClockPointer.d.ts +1 -1
  47. package/views/Month/Month.d.ts +1 -1
  48. package/views/Month/Month.js +5 -3
  49. package/views/Year/Year.d.ts +1 -1
  50. package/views/Year/Year.js +5 -3
  51. package/wrappers/InlineWrapper.d.ts +2 -0
  52. package/wrappers/InlineWrapper.js +5 -3
  53. package/wrappers/ModalWrapper.js +4 -2
  54. package/wrappers/Wrapper.js +4 -2
@@ -14,7 +14,7 @@ export interface BaseDatePickerProps extends OutterCalendarProps {
14
14
  minDate?: ParsableDate;
15
15
  /**
16
16
  * Max selectable date
17
- * @default Date(2100-01-01)
17
+ * @default Date(2200-01-01)
18
18
  */
19
19
  maxDate?: ParsableDate;
20
20
  /**
@@ -54,4 +54,4 @@ export declare type KeyboardDatePickerProps = WrappedKeyboardPickerProps & DateP
54
54
  export declare const DatePicker: import("react").FunctionComponent<DatePickerProps>;
55
55
  export declare const KeyboardDatePicker: import("react").FunctionComponent<import("../_helpers/text-field-helper").DateValidationProps & import("../_shared/hooks/useKeyboardPickerState").BaseKeyboardPickerProps & {
56
56
  variant?: "dialog" | "inline" | "static" | undefined;
57
- } & Pick<import("../wrappers/ModalWrapper").ModalWrapperProps<{}>, "okLabel" | "cancelLabel" | "clearLabel" | "todayLabel" | "clearable" | "showTodayButton" | "DialogProps"> & Pick<import("../wrappers/InlineWrapper").InlineWrapperProps<import("@material-ui/core/TextField").TextFieldProps>, "PopoverProps"> & Pick<import("../_shared/KeyboardDateInput").KeyboardDateInputProps, "children" | "ref" | "label" | "select" | "style" | "title" | "mask" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "innerRef" | "error" | "margin" | "disabled" | "key" | "autoFocus" | "name" | "type" | "fullWidth" | "autoComplete" | "required" | "rows" | "FormHelperTextProps" | "helperText" | "InputLabelProps" | "inputRef" | "multiline" | "rowsMax" | "SelectProps" | "InputProps" | "inputVariant" | "TextFieldComponent" | "showErrorOnBlur" | "KeyboardButtonProps" | "InputAdornmentProps" | "maskChar" | "refuse" | "keyboardIcon" | "rifmFormatter"> & DatePickerViewsProps>;
57
+ } & Pick<import("../wrappers/ModalWrapper").ModalWrapperProps<{}>, "okLabel" | "cancelLabel" | "clearLabel" | "todayLabel" | "clearable" | "showTodayButton" | "DialogProps"> & Pick<import("../wrappers/InlineWrapper").InlineWrapperProps<import("@material-ui/core/TextField").TextFieldProps>, "todayLabel" | "showTodayButton" | "PopoverProps"> & Pick<import("../_shared/KeyboardDateInput").KeyboardDateInputProps, "children" | "ref" | "label" | "select" | "style" | "title" | "mask" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "innerRef" | "error" | "name" | "margin" | "disabled" | "key" | "autoFocus" | "type" | "fullWidth" | "autoComplete" | "required" | "rows" | "hiddenLabel" | "FormHelperTextProps" | "helperText" | "InputLabelProps" | "inputRef" | "multiline" | "rowsMax" | "SelectProps" | "InputProps" | "inputVariant" | "TextFieldComponent" | "maskChar" | "showErrorOnBlur" | "KeyboardButtonProps" | "InputAdornmentProps" | "refuse" | "keyboardIcon" | "rifmFormatter"> & DatePickerViewsProps>;
@@ -17,7 +17,7 @@ var date_utils_1 = require("../_helpers/date-utils");
17
17
  var prop_types_1 = require("../constants/prop-types");
18
18
  var WrappedPurePicker_1 = require("../Picker/WrappedPurePicker");
19
19
  var WrappedKeyboardPicker_1 = require("../Picker/WrappedKeyboardPicker");
20
- var defaultProps = __assign({}, prop_types_1.datePickerDefaultProps, { openTo: 'date', views: ['year', 'date'], showActionsBar: false, todayLabel: 'TODAY' });
20
+ var defaultProps = __assign(__assign({}, prop_types_1.datePickerDefaultProps), { openTo: 'date', views: ['year', 'date'], showActionsBar: false, todayLabel: 'TODAY' });
21
21
  function useOptions(props) {
22
22
  var utils = useUtils_1.useUtils();
23
23
  return {
@@ -30,8 +30,8 @@ exports.useStyles = styles_1.makeStyles({
30
30
  },
31
31
  }, { name: 'MuiPickersDatePickerRoot' });
32
32
  exports.DatePickerToolbar = function (_a) {
33
- var date = _a.date, views = _a.views, setOpenView = _a.setOpenView, isLandscape = _a.isLandscape, openView = _a.openView;
34
33
  var _b, _c;
34
+ var date = _a.date, views = _a.views, setOpenView = _a.setOpenView, isLandscape = _a.isLandscape, openView = _a.openView;
35
35
  var utils = useUtils_1.useUtils();
36
36
  var classes = exports.useStyles();
37
37
  var isYearOnly = React.useMemo(function () { return date_utils_1.isYearOnlyView(views); }, [views]);
@@ -17,7 +17,7 @@ var text_field_helper_1 = require("../_helpers/text-field-helper");
17
17
  var prop_types_1 = require("../constants/prop-types");
18
18
  var WrappedPurePicker_1 = require("../Picker/WrappedPurePicker");
19
19
  var WrappedKeyboardPicker_1 = require("../Picker/WrappedKeyboardPicker");
20
- var defaultProps = __assign({}, prop_types_1.dateTimePickerDefaultProps, { showActionsBar: false, todayLabel: 'TODAY', wider: true, orientation: 'portrait', openTo: 'date', views: ['year', 'date', 'hours', 'minutes'] });
20
+ var defaultProps = __assign(__assign({}, prop_types_1.dateTimePickerDefaultProps), { showActionsBar: false, todayLabel: 'TODAY', wider: true, orientation: 'portrait', openTo: 'date', views: ['year', 'date', 'hours', 'minutes'] });
21
21
  function useOptions(props) {
22
22
  var utils = useUtils_1.useUtils();
23
23
  if (props.orientation !== 'portrait') {
package/Picker/Picker.js CHANGED
@@ -110,4 +110,4 @@ exports.Picker = function (props) {
110
110
  showTodayButton && (React.createElement(core_1.Button, { color: "primary", onClick: onSetToday, key: "today" }, todayLabel)),
111
111
  showShiftButtons && setShiftFunction && shiftButtons))));
112
112
  };
113
- exports.Picker.defaultProps = __assign({}, prop_types_1.datePickerDefaultProps, { views: Object.keys(viewsMap) });
113
+ exports.Picker.defaultProps = __assign(__assign({}, prop_types_1.datePickerDefaultProps), { views: Object.keys(viewsMap) });
@@ -15,8 +15,10 @@ var __rest = (this && this.__rest) || function (s, e) {
15
15
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
16
  t[p] = s[p];
17
17
  if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
19
- t[p[i]] = s[p[i]];
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
20
22
  return t;
21
23
  };
22
24
  var __importStar = (this && this.__importStar) || function (mod) {
@@ -15,8 +15,10 @@ var __rest = (this && this.__rest) || function (s, e) {
15
15
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
16
  t[p] = s[p];
17
17
  if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
19
- t[p[i]] = s[p[i]];
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
20
22
  return t;
21
23
  };
22
24
  var __importStar = (this && this.__importStar) || function (mod) {
package/README.md ADDED
@@ -0,0 +1 @@
1
+ Fork @material-ui/pickers that implements advanced features required for DocsVision WebClient. Original repository https://github.com/mui-org/material-ui-pickers
package/Rifm/Rifm.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ declare type Props = {
3
+ value: string;
4
+ maskChar: string;
5
+ onChange: (value: string) => void;
6
+ format: (str: string, oldValue: string, currentCaretPosition?: number) => string;
7
+ mask?: boolean;
8
+ replace?: (value: string) => string;
9
+ accept?: RegExp;
10
+ letterPosition?: number;
11
+ children: (value: {
12
+ value: string;
13
+ onChange: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>;
14
+ }) => any;
15
+ };
16
+ export declare const Rifm: (props: Props) => any;
17
+ export {};
package/Rifm/Rifm.js ADDED
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ var __importStar = (this && this.__importStar) || function (mod) {
3
+ if (mod && mod.__esModule) return mod;
4
+ var result = {};
5
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
+ result["default"] = mod;
7
+ return result;
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ var React = __importStar(require("react"));
11
+ exports.Rifm = function (props) {
12
+ var _a = React.useReducer(function (c) { return c + 1; }, 0), refresh = _a[1];
13
+ var valueRef = React.useRef(null);
14
+ var replace = props.replace, maskChar = props.maskChar;
15
+ var _b = React.useState({ value: '' }), previousValue = _b[0], setPreviousValue = _b[1];
16
+ var userValue = replace
17
+ ? replace(props.format(props.value, previousValue.value))
18
+ : props.format(props.value, previousValue.value);
19
+ var currentPreviousValue = previousValue.value;
20
+ // state of delete button see comments below about inputType support
21
+ var isDeleleteButtonDownRef = React.useRef(false);
22
+ var onChange = function (evt) {
23
+ var eventValue = evt.target.value;
24
+ var selectionStart = evt.target.selectionStart;
25
+ valueRef.current = [
26
+ eventValue,
27
+ evt.target,
28
+ eventValue.length > userValue.length,
29
+ isDeleleteButtonDownRef.current,
30
+ selectionStart,
31
+ userValue === props.format(eventValue, currentPreviousValue, selectionStart),
32
+ props.value,
33
+ ];
34
+ // The main trick is to update underlying input with non formatted value (= eventValue)
35
+ // that allows us to calculate right cursor position after formatting (see getCursorPosition)
36
+ // then we format new value and call props.onChange with masked/formatted value
37
+ // and finally we are able to set cursor position into right place
38
+ refresh(null);
39
+ };
40
+ // React prints warn on server in non production mode about useLayoutEffect usage
41
+ // in both cases it's noop
42
+ if (typeof window !== 'undefined') {
43
+ React.useLayoutEffect(function () {
44
+ if (valueRef.current == null)
45
+ return;
46
+ var _a = valueRef.current, eventValue = _a[0], input = _a[1], isSizeIncreaseOperation = _a[2], isDeleleteButtonDown = _a[3], selectionStart = _a[4],
47
+ // No operation means that value itself hasn't been changed, BTW cursor, selection etc can be changed
48
+ isNoOperation = _a[5], valueAtChange = _a[6];
49
+ valueRef.current = null;
50
+ // A calendar selection can replace the controlled value in the same React batch as an
51
+ // input event from the mask. In that case the event describes an obsolete value and must
52
+ // not overwrite the date selected in the calendar.
53
+ if (props.value !== valueAtChange) {
54
+ refresh(null);
55
+ return;
56
+ }
57
+ // this usually occurs on deleting special symbols like ' here 123'123.00
58
+ // in case of isDeleleteButtonDown cursor should move differently vs backspace
59
+ var deleteWasNoOp = isDeleleteButtonDown && isNoOperation;
60
+ // Create string from only accepted symbols
61
+ var clean = function (str) { return (str.match(props.accept || /\d|\w/g) || []).join(''); };
62
+ var valueBeforeSelectionStart = clean(eventValue.substr(0, input.selectionStart));
63
+ // trying to find cursor position in formatted value having knowledge about valueBeforeSelectionStart
64
+ // This works because we assume that format doesn't change the order of accepted symbols.
65
+ // Imagine we have formatter which adds ' symbol between numbers, and by default we refuse all non numeric symbols
66
+ // for example we had input = 1'2|'4 (| means cursor position) then user entered '3' symbol
67
+ // inputValue = 1'23'|4 so valueBeforeSelectionStart = 123 and formatted value = 1'2'3'4
68
+ // calling getCursorPosition("1'2'3'4") will give us position after 3, 1'2'3|'4
69
+ // so for formatting just this function to determine cursor position after formatting is enough
70
+ // with masking we need to do some additional checks see `mask` below
71
+ var getCursorPosition = function (val) {
72
+ var start = 0;
73
+ var cleanPos = 0;
74
+ for (var i = 0; i !== valueBeforeSelectionStart.length; ++i) {
75
+ var newPos = val.indexOf(valueBeforeSelectionStart[i], start) + 1;
76
+ var newCleanPos = clean(val).indexOf(valueBeforeSelectionStart[i], cleanPos) + 1;
77
+ // this skips position change if accepted symbols order was broken
78
+ // For example fixes edge case with fixed point numbers:
79
+ // You have '0|.00', then press 1, it becomes 01|.00 and after format 1.00, this breaks our assumption
80
+ // that order of accepted symbols is not changed after format,
81
+ // so here we don't update start position if other accepted symbols was inbetween current and new position
82
+ if (newCleanPos - cleanPos > 1) {
83
+ newPos = start;
84
+ newCleanPos = cleanPos;
85
+ }
86
+ cleanPos = Math.max(newCleanPos, cleanPos);
87
+ start = Math.max(start, newPos);
88
+ }
89
+ return start;
90
+ };
91
+ //let start = getCursorPosition(eventValue);
92
+ // // Masking part, for masks if size of mask is above some value
93
+ // // we need to replace symbols instead of do nothing as like in format
94
+ // if (props.mask === true && isSizeIncreaseOperation && !isNoOperation) {
95
+ // const c = clean(eventValue.substr(start))[0];
96
+ // start = eventValue.indexOf(c, start);
97
+ // eventValue = `${eventValue.substr(0, start)}${eventValue.substr(
98
+ // start + 1
99
+ // )}`;
100
+ // }
101
+ var formattedValue = props.format(eventValue, currentPreviousValue, selectionStart);
102
+ var replacedValue = replace ? replace(formattedValue) : formattedValue;
103
+ var start = getCursorPosition(formattedValue);
104
+ var inputCharPosition = start - 1;
105
+ if (inputCharPosition > -1) {
106
+ if (props.letterPosition &&
107
+ props.letterPosition > -1 &&
108
+ replacedValue[inputCharPosition].match(/[a-zA-Z]/) &&
109
+ (inputCharPosition < props.letterPosition || inputCharPosition > props.letterPosition + 1)) {
110
+ replacedValue = currentPreviousValue;
111
+ }
112
+ else if (props.letterPosition &&
113
+ props.letterPosition > -1 &&
114
+ replacedValue[inputCharPosition].match(/\d/) &&
115
+ (inputCharPosition >= props.letterPosition &&
116
+ inputCharPosition <= props.letterPosition + 1)) {
117
+ replacedValue = currentPreviousValue;
118
+ }
119
+ }
120
+ if (userValue === replacedValue) {
121
+ // if nothing changed for formatted value, just refresh so userValue will be used at render
122
+ refresh(null);
123
+ }
124
+ else {
125
+ props.onChange(replacedValue);
126
+ }
127
+ return function () {
128
+ // Visually improves working with masked values,
129
+ // like cursor jumping over refused symbols
130
+ // as an example date mask: was "5|1-24-3" then user pressed "6"
131
+ // it becomes "56-|12-43" with this code, and "56|-12-43" without
132
+ if (props.mask != null &&
133
+ (isSizeIncreaseOperation || (isDeleleteButtonDown && !deleteWasNoOp))) {
134
+ while (formattedValue[start] &&
135
+ clean(formattedValue[start]) === '' &&
136
+ formattedValue[start] != maskChar) {
137
+ start += 1;
138
+ }
139
+ }
140
+ //input.selectionStart = input.selectionEnd = start + (deleteWasNoOp ? 1 : 0);
141
+ };
142
+ });
143
+ }
144
+ React.useEffect(function () {
145
+ // until https://developer.mozilla.org/en-US/docs/Web/API/InputEvent/inputType will be supported
146
+ // by all major browsers (now supported by: +chrome, +safari, ?edge, !firefox)
147
+ // there is no way I found to distinguish in onChange
148
+ // backspace or delete was called in some situations
149
+ // firefox track https://bugzilla.mozilla.org/show_bug.cgi?id=1447239
150
+ var handleKeyDown = function (evt) {
151
+ if (evt.code === 'Delete') {
152
+ isDeleleteButtonDownRef.current = true;
153
+ }
154
+ };
155
+ var handleKeyUp = function (evt) {
156
+ if (evt.code === 'Delete') {
157
+ isDeleleteButtonDownRef.current = false;
158
+ }
159
+ };
160
+ document.addEventListener('keydown', handleKeyDown);
161
+ document.addEventListener('keyup', handleKeyUp);
162
+ return function () {
163
+ document.removeEventListener('keydown', handleKeyDown);
164
+ document.removeEventListener('keyup', handleKeyUp);
165
+ };
166
+ }, []);
167
+ var value = valueRef.current != null ? valueRef.current[0] : userValue;
168
+ // value = props.format(value, currentPreviousValue);
169
+ previousValue.value = value;
170
+ return props.children({
171
+ value: value,
172
+ onChange: onChange,
173
+ });
174
+ };
@@ -20,7 +20,7 @@ var prop_types_1 = require("../constants/prop-types");
20
20
  var text_field_helper_1 = require("../_helpers/text-field-helper");
21
21
  var WrappedPurePicker_1 = require("../Picker/WrappedPurePicker");
22
22
  var WrappedKeyboardPicker_1 = require("../Picker/WrappedKeyboardPicker");
23
- var defaultProps = __assign({}, prop_types_1.timePickerDefaultProps, { openTo: 'hours', views: ['hours', 'minutes'] });
23
+ var defaultProps = __assign(__assign({}, prop_types_1.timePickerDefaultProps), { openTo: 'hours', views: ['hours', 'minutes'] });
24
24
  function useOptions(props) {
25
25
  var utils = useUtils_1.useUtils();
26
26
  return {
@@ -73,8 +73,8 @@ function useMeridiemMode(date, ampm, onChange) {
73
73
  }
74
74
  exports.useMeridiemMode = useMeridiemMode;
75
75
  var TimePickerToolbar = function (_a) {
76
- var date = _a.date, views = _a.views, ampm = _a.ampm, openView = _a.openView, onChange = _a.onChange, isLandscape = _a.isLandscape, setOpenView = _a.setOpenView;
77
76
  var _b, _c, _d;
77
+ var date = _a.date, views = _a.views, ampm = _a.ampm, openView = _a.openView, onChange = _a.onChange, isLandscape = _a.isLandscape, setOpenView = _a.setOpenView;
78
78
  var utils = useUtils_1.useUtils();
79
79
  var theme = styles_1.useTheme();
80
80
  var classes = exports.useStyles();
@@ -23,10 +23,10 @@ export interface DateValidationProps extends BaseValidationProps {
23
23
  */
24
24
  maxDateMessage?: React.ReactNode;
25
25
  }
26
- export declare const validate: (value: ParsableDate, utils: IUtils<any>, { maxDate, minDate, disablePast, disableFuture, maxDateMessage, minDateMessage, invalidDateMessage, strictCompareDates, }: Pick<import("../DatePicker/DatePicker").DatePickerProps, "children" | "ref" | "label" | "select" | "style" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "variant" | "innerRef" | "error" | "margin" | "open" | "disabled" | "key" | "autoFocus" | "name" | "type" | "value" | "fullWidth" | "format" | "orientation" | "autoComplete" | "required" | "rows" | "onMonthChange" | "leftArrowIcon" | "rightArrowIcon" | "leftArrowButtonProps" | "rightArrowButtonProps" | "minDate" | "maxDate" | "disablePast" | "disableFuture" | "renderDay" | "allowKeyboardControl" | "shouldDisableDate" | "loadingIndicator" | "FormHelperTextProps" | "helperText" | "InputLabelProps" | "inputRef" | "multiline" | "rowsMax" | "SelectProps" | "InputProps" | "inputVariant" | "TextFieldComponent" | "onClose" | "onOpen" | "onAccept" | "okLabel" | "cancelLabel" | "clearLabel" | "todayLabel" | "clearable" | "showTodayButton" | "DialogProps" | "PopoverProps" | "autoOk" | "labelFunc" | "initialFocusedDate" | "invalidLabel" | "emptyLabel" | "disableToolbar" | "ToolbarComponent" | "showShiftButtons" | "setShiftFunction" | "shiftButtonValues" | "minDateMessage" | "maxDateMessage" | "invalidDateMessage" | "strictCompareDates" | "animateYearScrolling" | "onYearChange">) => import("react").ReactNode;
26
+ export declare const validate: (value: ParsableDate, utils: IUtils<any>, { maxDate, minDate, disablePast, disableFuture, maxDateMessage, minDateMessage, invalidDateMessage, strictCompareDates, }: Pick<import("../DatePicker/DatePicker").DatePickerProps, "children" | "ref" | "label" | "select" | "style" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "variant" | "innerRef" | "error" | "name" | "margin" | "open" | "disabled" | "key" | "autoFocus" | "type" | "value" | "fullWidth" | "format" | "orientation" | "autoComplete" | "required" | "rows" | "onMonthChange" | "leftArrowIcon" | "rightArrowIcon" | "leftArrowButtonProps" | "rightArrowButtonProps" | "minDate" | "maxDate" | "disablePast" | "disableFuture" | "renderDay" | "allowKeyboardControl" | "shouldDisableDate" | "loadingIndicator" | "hiddenLabel" | "FormHelperTextProps" | "helperText" | "InputLabelProps" | "inputRef" | "multiline" | "rowsMax" | "SelectProps" | "InputProps" | "inputVariant" | "TextFieldComponent" | "onClose" | "onOpen" | "onAccept" | "okLabel" | "cancelLabel" | "clearLabel" | "todayLabel" | "clearable" | "showTodayButton" | "DialogProps" | "PopoverProps" | "autoOk" | "labelFunc" | "initialFocusedDate" | "invalidLabel" | "emptyLabel" | "disableToolbar" | "ToolbarComponent" | "showShiftButtons" | "setShiftFunction" | "shiftButtonValues" | "minDateMessage" | "maxDateMessage" | "invalidDateMessage" | "strictCompareDates" | "animateYearScrolling" | "onYearChange">) => import("react").ReactNode;
27
27
  export declare function pick12hOr24hFormat(userFormat: string | undefined, ampm: boolean | undefined, formats: {
28
28
  '12h': string;
29
29
  '24h': string;
30
30
  }): string;
31
31
  export declare function makeMaskFromFormat(format: string, numberMaskChar: string): string;
32
- export declare const maskedDateFormatter: (mask: string, numberMaskChar: string, refuse: RegExp) => (value: string) => string;
32
+ export declare const maskedDateFormatter: (mask: string, numberMaskChar: string) => (value: string, oldValue: string, currentCaretPosition?: number | undefined) => string;
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ var replaceAt = function (str, index, replacement) {
4
+ replacement = replacement || '';
5
+ return str.substr(0, index) + replacement + str.substr(index + replacement.length);
6
+ };
3
7
  exports.getDisplayDate = function (value, format, utils, isEmpty, _a) {
4
8
  var invalidLabel = _a.invalidLabel, emptyLabel = _a.emptyLabel, labelFunc = _a.labelFunc;
5
9
  var date = utils.date(value);
@@ -64,18 +68,70 @@ function makeMaskFromFormat(format, numberMaskChar) {
64
68
  return format.replace(/[a-z]/gi, numberMaskChar);
65
69
  }
66
70
  exports.makeMaskFromFormat = makeMaskFromFormat;
67
- exports.maskedDateFormatter = function (mask, numberMaskChar, refuse) { return function (value) {
68
- if (value === '') {
71
+ exports.maskedDateFormatter = function (mask, numberMaskChar) { return function (value, oldValue, currentCaretPosition) {
72
+ var refuse = /[^\d\w_]+/gi;
73
+ if (!value || value === '') {
69
74
  return value;
70
75
  }
71
- var result = '';
72
- var parsed = value.replace(refuse, '');
76
+ if (!oldValue) {
77
+ oldValue = '';
78
+ }
79
+ if (value == oldValue) {
80
+ return value;
81
+ }
82
+ if (value.length < oldValue.length && currentCaretPosition != null) {
83
+ value =
84
+ value.slice(0, currentCaretPosition) +
85
+ '_' +
86
+ value.slice(currentCaretPosition, oldValue.length);
87
+ }
88
+ var refusedOldValue = oldValue.replace(refuse, '');
89
+ var refusedNewValue = value.replace(refuse, '');
90
+ var refusedMaskSymbols = mask.replace(refuse, '');
91
+ var minLength = refusedOldValue.length > refusedNewValue.length
92
+ ? refusedNewValue.length
93
+ : refusedOldValue.length;
94
+ var startPos = 0;
95
+ var endPosShift = 0;
96
+ while (startPos < minLength) {
97
+ if (refusedNewValue[startPos] == refusedOldValue[startPos]) {
98
+ startPos++;
99
+ }
100
+ else {
101
+ break;
102
+ }
103
+ }
104
+ while (endPosShift < minLength &&
105
+ startPos < refusedNewValue.length - endPosShift &&
106
+ startPos < refusedOldValue.length - endPosShift) {
107
+ if (refusedNewValue[refusedNewValue.length - endPosShift - 1] ==
108
+ refusedOldValue[refusedOldValue.length - endPosShift - 1]) {
109
+ endPosShift++;
110
+ }
111
+ else {
112
+ break;
113
+ }
114
+ }
115
+ var endStartPos = refusedNewValue.length - endPosShift;
116
+ endStartPos = endStartPos < startPos ? startPos : endStartPos;
117
+ var firstPart = refusedNewValue.slice(0, startPos);
118
+ var addedPart = refusedNewValue.slice(startPos, endStartPos);
119
+ var endPart = refusedNewValue.slice(endStartPos, refusedNewValue.length);
120
+ var maxSymbolsInEnd = refusedMaskSymbols.length - firstPart.length - addedPart.length;
121
+ while (maxSymbolsInEnd > endPart.length) {
122
+ addedPart += numberMaskChar;
123
+ maxSymbolsInEnd--;
124
+ }
125
+ var entireRefusedString = firstPart + addedPart + endPart.slice(endPart.length - maxSymbolsInEnd, endPart.length);
126
+ // Do nothing ?...
127
+ entireRefusedString = entireRefusedString.slice(0, refusedMaskSymbols.length);
73
128
  var i = 0;
74
129
  var n = 0;
130
+ var result = '';
75
131
  while (i < mask.length) {
76
132
  var maskChar = mask[i];
77
- if (maskChar === numberMaskChar && n < parsed.length) {
78
- var parsedChar = parsed[n];
133
+ if (maskChar === numberMaskChar && n < entireRefusedString.length) {
134
+ var parsedChar = entireRefusedString[n];
79
135
  result += parsedChar;
80
136
  n += 1;
81
137
  }