@skbkontur/react-ui 6.1.4-05b51.0 → 6.1.4-ff219.0
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/components/Autocomplete/Autocomplete.js +3 -2
- package/components/Autocomplete/Autocomplete.js.map +1 -1
- package/components/FxInput/FxInput.js +2 -2
- package/components/FxInput/FxInput.js.map +1 -1
- package/components/Group/Group.js +2 -3
- package/components/Group/Group.js.map +1 -1
- package/components/Input/Input.d.ts +1 -1
- package/components/Input/Input.js.map +1 -1
- package/components/MaskedInput/MaskedInput.d.ts +2 -0
- package/components/MaskedInput/MaskedInput.js +6 -0
- package/components/MaskedInput/MaskedInput.js.map +1 -1
- package/components/MaskedInputV2/MaskedInputV2.d.ts +57 -0
- package/components/MaskedInputV2/MaskedInputV2.helpers.d.ts +9 -0
- package/components/MaskedInputV2/MaskedInputV2.helpers.js +17 -0
- package/components/MaskedInputV2/MaskedInputV2.helpers.js.map +1 -0
- package/components/MaskedInputV2/MaskedInputV2.js +234 -0
- package/components/MaskedInputV2/MaskedInputV2.js.map +1 -0
- package/{internal/TimeInput/TimeInput.styles.d.ts → components/MaskedInputV2/MaskedInputV2.styles.d.ts} +4 -3
- package/components/MaskedInputV2/MaskedInputV2.styles.js +19 -0
- package/components/MaskedInputV2/MaskedInputV2.styles.js.map +1 -0
- package/components/MaskedInputV2/index.d.ts +1 -0
- package/components/MaskedInputV2/index.js +2 -0
- package/components/MaskedInputV2/index.js.map +1 -0
- package/components/MaskedInputV2/internal/MaskOverlay.d.ts +19 -0
- package/components/MaskedInputV2/internal/MaskOverlay.js +54 -0
- package/components/MaskedInputV2/internal/MaskOverlay.js.map +1 -0
- package/components/MaskedInputV2/internal/MaskedCore.d.ts +8 -0
- package/components/MaskedInputV2/internal/MaskedCore.js +101 -0
- package/components/MaskedInputV2/internal/MaskedCore.js.map +1 -0
- package/components/MaskedInputV2/internal/MaskedCore.types.d.ts +30 -0
- package/components/MaskedInputV2/internal/MaskedCore.types.js +2 -0
- package/components/MaskedInputV2/internal/MaskedCore.types.js.map +1 -0
- package/components/MaskedInputV2/internal/MaskedInternal.styles.d.ts +15 -0
- package/components/MaskedInputV2/internal/MaskedInternal.styles.js +34 -0
- package/components/MaskedInputV2/internal/MaskedInternal.styles.js.map +1 -0
- package/components/MaskedInputV2/internal/buildSlotMap.d.ts +11 -0
- package/components/MaskedInputV2/internal/buildSlotMap.js +37 -0
- package/components/MaskedInputV2/internal/buildSlotMap.js.map +1 -0
- package/components/MaskedInputV2/internal/extractRaw.d.ts +10 -0
- package/components/MaskedInputV2/internal/extractRaw.js +16 -0
- package/components/MaskedInputV2/internal/extractRaw.js.map +1 -0
- package/components/MaskedInputV2/internal/findNearestRawLeft.d.ts +10 -0
- package/components/MaskedInputV2/internal/findNearestRawLeft.js +18 -0
- package/components/MaskedInputV2/internal/findNearestRawLeft.js.map +1 -0
- package/components/MaskedInputV2/internal/helpers.d.ts +5 -0
- package/components/MaskedInputV2/internal/helpers.js +6 -0
- package/components/MaskedInputV2/internal/helpers.js.map +1 -0
- package/components/MaskedInputV2/internal/maskedCoreClipboard.d.ts +25 -0
- package/components/MaskedInputV2/internal/maskedCoreClipboard.js +30 -0
- package/components/MaskedInputV2/internal/maskedCoreClipboard.js.map +1 -0
- package/components/MaskedInputV2/internal/maskedCoreDeletion.d.ts +28 -0
- package/components/MaskedInputV2/internal/maskedCoreDeletion.js +70 -0
- package/components/MaskedInputV2/internal/maskedCoreDeletion.js.map +1 -0
- package/components/MaskedInputV2/internal/maskedCoreInputChange.d.ts +35 -0
- package/components/MaskedInputV2/internal/maskedCoreInputChange.js +31 -0
- package/components/MaskedInputV2/internal/maskedCoreInputChange.js.map +1 -0
- package/components/MaskedInputV2/internal/maskedCoreNavigation.d.ts +13 -0
- package/components/MaskedInputV2/internal/maskedCoreNavigation.js +79 -0
- package/components/MaskedInputV2/internal/maskedCoreNavigation.js.map +1 -0
- package/components/MaskedInputV2/internal/stripMaskChars.d.ts +11 -0
- package/components/MaskedInputV2/internal/stripMaskChars.js +20 -0
- package/components/MaskedInputV2/internal/stripMaskChars.js.map +1 -0
- package/components/MaskedInputV2/internal/types.d.ts +74 -0
- package/components/MaskedInputV2/internal/types.js.map +1 -0
- package/components/MaskedInputV2/internal/useMaskEngine.d.ts +42 -0
- package/components/MaskedInputV2/internal/useMaskEngine.js +82 -0
- package/components/MaskedInputV2/internal/useMaskEngine.js.map +1 -0
- package/components/MaskedInputV2/internal/useMaskedCoreHandlers.d.ts +28 -0
- package/components/MaskedInputV2/internal/useMaskedCoreHandlers.js +190 -0
- package/components/MaskedInputV2/internal/useMaskedCoreHandlers.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/controls/html-input-mask-element.d.ts +16 -0
- package/components/MaskedInputV2/react-imask/imask/controls/html-input-mask-element.js +59 -0
- package/components/MaskedInputV2/react-imask/imask/controls/html-input-mask-element.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/controls/html-mask-element.d.ts +20 -0
- package/components/MaskedInputV2/react-imask/imask/controls/html-mask-element.js +106 -0
- package/components/MaskedInputV2/react-imask/imask/controls/html-mask-element.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/controls/input-history.d.ts +17 -0
- package/components/MaskedInputV2/react-imask/imask/controls/input-history.js +49 -0
- package/components/MaskedInputV2/react-imask/imask/controls/input-history.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/controls/input.d.ts +95 -0
- package/components/MaskedInputV2/react-imask/imask/controls/input.js +420 -0
- package/components/MaskedInputV2/react-imask/imask/controls/input.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/controls/mask-element.d.ts +30 -0
- package/components/MaskedInputV2/react-imask/imask/controls/mask-element.js +59 -0
- package/components/MaskedInputV2/react-imask/imask/controls/mask-element.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/core/action-details.d.ts +30 -0
- package/components/MaskedInputV2/react-imask/imask/core/action-details.js +100 -0
- package/components/MaskedInputV2/react-imask/imask/core/action-details.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/core/change-details.d.ts +20 -0
- package/components/MaskedInputV2/react-imask/imask/core/change-details.js +46 -0
- package/components/MaskedInputV2/react-imask/imask/core/change-details.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/core/continuous-tail-details.d.ts +21 -0
- package/components/MaskedInputV2/react-imask/imask/core/continuous-tail-details.js +52 -0
- package/components/MaskedInputV2/react-imask/imask/core/continuous-tail-details.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/core/holder.d.ts +34 -0
- package/components/MaskedInputV2/react-imask/imask/core/holder.js +38 -0
- package/components/MaskedInputV2/react-imask/imask/core/holder.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/core/tail-details.d.ts +20 -0
- package/components/MaskedInputV2/react-imask/imask/core/tail-details.js +2 -0
- package/components/MaskedInputV2/react-imask/imask/core/tail-details.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/core/utils.d.ts +24 -0
- package/components/MaskedInputV2/react-imask/imask/core/utils.js +100 -0
- package/components/MaskedInputV2/react-imask/imask/core/utils.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/imask.d.ts +5 -0
- package/components/MaskedInputV2/react-imask/imask/imask.js +7 -0
- package/components/MaskedInputV2/react-imask/imask/imask.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/index.d.ts +17 -0
- package/components/MaskedInputV2/react-imask/imask/index.js +16 -0
- package/components/MaskedInputV2/react-imask/imask/index.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/masked/base.d.ts +114 -0
- package/components/MaskedInputV2/react-imask/imask/masked/base.js +411 -0
- package/components/MaskedInputV2/react-imask/imask/masked/base.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/masked/factory.d.ts +62 -0
- package/components/MaskedInputV2/react-imask/imask/masked/factory.js +96 -0
- package/components/MaskedInputV2/react-imask/imask/masked/factory.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/masked/pattern.d.ts +101 -0
- package/components/MaskedInputV2/react-imask/imask/masked/pattern.js +543 -0
- package/components/MaskedInputV2/react-imask/imask/masked/pattern.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/block.d.ts +30 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/block.js +2 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/block.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/chunk-tail-details.d.ts +21 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/chunk-tail-details.js +180 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/chunk-tail-details.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/cursor.d.ts +31 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/cursor.js +163 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/cursor.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/fixed-definition.d.ts +42 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/fixed-definition.js +158 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/fixed-definition.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/input-definition.d.ts +56 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/input-definition.js +185 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/input-definition.js.map +1 -0
- package/components/MaskedInputV2/react-imask/imask/masked/regexp.d.ts +17 -0
- package/components/MaskedInputV2/react-imask/imask/masked/regexp.js +36 -0
- package/components/MaskedInputV2/react-imask/imask/masked/regexp.js.map +1 -0
- package/components/MaskedInputV2/react-imask/index.d.ts +3 -0
- package/components/MaskedInputV2/react-imask/index.js +4 -0
- package/components/MaskedInputV2/react-imask/index.js.map +1 -0
- package/components/MaskedInputV2/react-imask/input.d.ts +8 -0
- package/components/MaskedInputV2/react-imask/input.js +35 -0
- package/components/MaskedInputV2/react-imask/input.js.map +1 -0
- package/components/MaskedInputV2/react-imask/mixin.d.ts +31 -0
- package/components/MaskedInputV2/react-imask/mixin.js +246 -0
- package/components/MaskedInputV2/react-imask/mixin.js.map +1 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/internal/CustomComboBox/ComboBoxView.js +2 -2
- package/internal/CustomComboBox/ComboBoxView.js.map +1 -1
- package/internal/FeaturedMaskedInput/FeaturedMaskedInput.d.ts +4 -0
- package/internal/FeaturedMaskedInput/FeaturedMaskedInput.js +24 -0
- package/internal/FeaturedMaskedInput/FeaturedMaskedInput.js.map +1 -0
- package/internal/themes/BasicTheme.d.ts +0 -34
- package/internal/themes/BasicTheme.js +0 -96
- package/internal/themes/BasicTheme.js.map +1 -1
- package/lib/events/keyboard/KeyboardEventCodes.d.ts +2 -0
- package/lib/events/keyboard/KeyboardEventCodes.js +2 -0
- package/lib/events/keyboard/KeyboardEventCodes.js.map +1 -1
- package/lib/events/keyboard/KeyboardMapKeys.js +2 -0
- package/lib/events/keyboard/KeyboardMapKeys.js.map +1 -1
- package/lib/events/keyboard/identifiers.d.ts +2 -0
- package/lib/events/keyboard/identifiers.js +6 -0
- package/lib/events/keyboard/identifiers.js.map +1 -1
- package/lib/featureFlagsContext/ReactUIFeatureFlagsContext.d.ts +2 -0
- package/lib/featureFlagsContext/ReactUIFeatureFlagsContext.js +1 -0
- package/lib/featureFlagsContext/ReactUIFeatureFlagsContext.js.map +1 -1
- package/lib/locale/types.d.ts +0 -2
- package/lib/locale/types.js.map +1 -1
- package/lib/utils.d.ts +0 -2
- package/lib/utils.js +0 -1
- package/lib/utils.js.map +1 -1
- package/package.json +4 -9
- package/components/TimePicker/TimeClockIcon.d.ts +0 -3
- package/components/TimePicker/TimeClockIcon.js +0 -11
- package/components/TimePicker/TimeClockIcon.js.map +0 -1
- package/components/TimePicker/TimePicker.d.ts +0 -79
- package/components/TimePicker/TimePicker.js +0 -513
- package/components/TimePicker/TimePicker.js.map +0 -1
- package/components/TimePicker/TimePicker.styles.d.ts +0 -11
- package/components/TimePicker/TimePicker.styles.js +0 -36
- package/components/TimePicker/TimePicker.styles.js.map +0 -1
- package/components/TimePicker/TimePickerItems.d.ts +0 -17
- package/components/TimePicker/TimePickerItems.js +0 -80
- package/components/TimePicker/TimePickerItems.js.map +0 -1
- package/components/TimePicker/TimePickerMobilePopup.d.ts +0 -38
- package/components/TimePicker/TimePickerMobilePopup.js +0 -21
- package/components/TimePicker/TimePickerMobilePopup.js.map +0 -1
- package/components/TimePicker/TimePickerPopup.d.ts +0 -20
- package/components/TimePicker/TimePickerPopup.js +0 -18
- package/components/TimePicker/TimePickerPopup.js.map +0 -1
- package/components/TimePicker/helpers/TimePicker.constants.d.ts +0 -22
- package/components/TimePicker/helpers/TimePicker.constants.js +0 -31
- package/components/TimePicker/helpers/TimePicker.constants.js.map +0 -1
- package/components/TimePicker/helpers/TimePicker.editing.d.ts +0 -23
- package/components/TimePicker/helpers/TimePicker.editing.js +0 -101
- package/components/TimePicker/helpers/TimePicker.editing.js.map +0 -1
- package/components/TimePicker/helpers/TimePicker.layout.d.ts +0 -6
- package/components/TimePicker/helpers/TimePicker.layout.js +0 -49
- package/components/TimePicker/helpers/TimePicker.layout.js.map +0 -1
- package/components/TimePicker/helpers/TimePicker.selection.d.ts +0 -5
- package/components/TimePicker/helpers/TimePicker.selection.js +0 -23
- package/components/TimePicker/helpers/TimePicker.selection.js.map +0 -1
- package/components/TimePicker/helpers/TimePicker.shared.d.ts +0 -47
- package/components/TimePicker/helpers/TimePicker.shared.js +0 -70
- package/components/TimePicker/helpers/TimePicker.shared.js.map +0 -1
- package/components/TimePicker/helpers/TimePicker.value.d.ts +0 -30
- package/components/TimePicker/helpers/TimePicker.value.js +0 -96
- package/components/TimePicker/helpers/TimePicker.value.js.map +0 -1
- package/components/TimePicker/helpers/scrollSelectedItemIntoView.d.ts +0 -4
- package/components/TimePicker/helpers/scrollSelectedItemIntoView.js +0 -24
- package/components/TimePicker/helpers/scrollSelectedItemIntoView.js.map +0 -1
- package/components/TimePicker/helpers/validateTimePicker.d.ts +0 -8
- package/components/TimePicker/helpers/validateTimePicker.js +0 -16
- package/components/TimePicker/helpers/validateTimePicker.js.map +0 -1
- package/components/TimePicker/hooks/useTimePickerDropdown.d.ts +0 -17
- package/components/TimePicker/hooks/useTimePickerDropdown.js +0 -62
- package/components/TimePicker/hooks/useTimePickerDropdown.js.map +0 -1
- package/components/TimePicker/hooks/useTimePickerSelection.d.ts +0 -18
- package/components/TimePicker/hooks/useTimePickerSelection.js +0 -66
- package/components/TimePicker/hooks/useTimePickerSelection.js.map +0 -1
- package/components/TimePicker/hooks/useTimePickerValue.d.ts +0 -18
- package/components/TimePicker/hooks/useTimePickerValue.js +0 -59
- package/components/TimePicker/hooks/useTimePickerValue.js.map +0 -1
- package/components/TimePicker/index.d.ts +0 -2
- package/components/TimePicker/index.js +0 -2
- package/components/TimePicker/index.js.map +0 -1
- package/components/TimePicker/locale/index.d.ts +0 -4
- package/components/TimePicker/locale/index.js +0 -9
- package/components/TimePicker/locale/index.js.map +0 -1
- package/components/TimePicker/locale/locales/en.d.ts +0 -2
- package/components/TimePicker/locale/locales/en.js +0 -5
- package/components/TimePicker/locale/locales/en.js.map +0 -1
- package/components/TimePicker/locale/locales/ru.d.ts +0 -2
- package/components/TimePicker/locale/locales/ru.js +0 -5
- package/components/TimePicker/locale/locales/ru.js.map +0 -1
- package/components/TimePicker/locale/types.d.ts +0 -4
- package/components/TimePicker/locale/types.js.map +0 -1
- package/internal/NativeTimeInput/NativeTimeInput.d.ts +0 -16
- package/internal/NativeTimeInput/NativeTimeInput.js +0 -25
- package/internal/NativeTimeInput/NativeTimeInput.js.map +0 -1
- package/internal/NativeTimeInput/NativeTimeInput.styles.d.ts +0 -3
- package/internal/NativeTimeInput/NativeTimeInput.styles.js +0 -15
- package/internal/NativeTimeInput/NativeTimeInput.styles.js.map +0 -1
- package/internal/NativeTimeInput/NativeTimeInput.utils.d.ts +0 -7
- package/internal/NativeTimeInput/NativeTimeInput.utils.js +0 -28
- package/internal/NativeTimeInput/NativeTimeInput.utils.js.map +0 -1
- package/internal/NativeTimeInput/index.d.ts +0 -1
- package/internal/NativeTimeInput/index.js +0 -2
- package/internal/NativeTimeInput/index.js.map +0 -1
- package/internal/TimeInput/TimeFragments.d.ts +0 -15
- package/internal/TimeInput/TimeFragments.js +0 -72
- package/internal/TimeInput/TimeFragments.js.map +0 -1
- package/internal/TimeInput/TimeFragments.styles.d.ts +0 -12
- package/internal/TimeInput/TimeFragments.styles.js +0 -43
- package/internal/TimeInput/TimeFragments.styles.js.map +0 -1
- package/internal/TimeInput/TimeInput.d.ts +0 -22
- package/internal/TimeInput/TimeInput.js +0 -103
- package/internal/TimeInput/TimeInput.js.map +0 -1
- package/internal/TimeInput/TimeInput.styles.js +0 -21
- package/internal/TimeInput/TimeInput.styles.js.map +0 -1
- package/internal/TimeInput/index.d.ts +0 -1
- package/internal/TimeInput/index.js +0 -2
- package/internal/TimeInput/index.js.map +0 -1
- package/internal/icons2022/TimeClockIcon/TimeClockIcon16Light.d.ts +0 -2
- package/internal/icons2022/TimeClockIcon/TimeClockIcon16Light.js +0 -20
- package/internal/icons2022/TimeClockIcon/TimeClockIcon16Light.js.map +0 -1
- package/internal/icons2022/TimeClockIcon/TimeClockIcon20Light.d.ts +0 -2
- package/internal/icons2022/TimeClockIcon/TimeClockIcon20Light.js +0 -20
- package/internal/icons2022/TimeClockIcon/TimeClockIcon20Light.js.map +0 -1
- package/internal/icons2022/TimeClockIcon/TimeClockIcon24Regular.d.ts +0 -2
- package/internal/icons2022/TimeClockIcon/TimeClockIcon24Regular.js +0 -20
- package/internal/icons2022/TimeClockIcon/TimeClockIcon24Regular.js.map +0 -1
- /package/components/{TimePicker/locale → MaskedInputV2/internal}/types.js +0 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { ActionDetails } from '../core/action-details.js';
|
|
13
|
+
/* eslint-disable eqeqeq */
|
|
14
|
+
import { DIRECTION } from '../core/utils.js';
|
|
15
|
+
import { Masked } from '../masked/base.js';
|
|
16
|
+
import { createMask, maskedClass, } from '../masked/factory.js';
|
|
17
|
+
import { HTMLInputMaskElement } from './html-input-mask-element.js';
|
|
18
|
+
import { InputHistory } from './input-history.js';
|
|
19
|
+
import { MaskElement } from './mask-element.js';
|
|
20
|
+
/** Listens to element events and controls changes between element and {@link Masked} */
|
|
21
|
+
var InputMask = /** @class */ (function () {
|
|
22
|
+
function InputMask(el, opts) {
|
|
23
|
+
this.el = el instanceof MaskElement ? el : new HTMLInputMaskElement(el);
|
|
24
|
+
this.masked = createMask(opts);
|
|
25
|
+
this._listeners = {};
|
|
26
|
+
this._value = '';
|
|
27
|
+
this._unmaskedValue = '';
|
|
28
|
+
this._rawInputValue = '';
|
|
29
|
+
this.history = new InputHistory();
|
|
30
|
+
this._saveSelection = this._saveSelection.bind(this);
|
|
31
|
+
this._onInput = this._onInput.bind(this);
|
|
32
|
+
this._onChange = this._onChange.bind(this);
|
|
33
|
+
this._onDrop = this._onDrop.bind(this);
|
|
34
|
+
this._onFocus = this._onFocus.bind(this);
|
|
35
|
+
this._onClick = this._onClick.bind(this);
|
|
36
|
+
this._onUndo = this._onUndo.bind(this);
|
|
37
|
+
this._onRedo = this._onRedo.bind(this);
|
|
38
|
+
this.alignCursor = this.alignCursor.bind(this);
|
|
39
|
+
this.alignCursorFriendly = this.alignCursorFriendly.bind(this);
|
|
40
|
+
this._bindEvents();
|
|
41
|
+
// refresh
|
|
42
|
+
this.updateValue();
|
|
43
|
+
this._onChange();
|
|
44
|
+
}
|
|
45
|
+
InputMask.prototype.maskEquals = function (mask) {
|
|
46
|
+
var _a;
|
|
47
|
+
return mask == null || ((_a = this.masked) === null || _a === void 0 ? void 0 : _a.maskEquals(mask));
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(InputMask.prototype, "mask", {
|
|
50
|
+
/** Masked */
|
|
51
|
+
get: function () {
|
|
52
|
+
return this.masked.mask;
|
|
53
|
+
},
|
|
54
|
+
set: function (mask) {
|
|
55
|
+
if (this.maskEquals(mask)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!(mask instanceof Masked) && this.masked.constructor === maskedClass(mask)) {
|
|
59
|
+
this.masked.updateOptions({ mask: mask });
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
var masked = (mask instanceof Masked ? mask : createMask({ mask: mask }));
|
|
63
|
+
masked.unmaskedValue = this.masked.unmaskedValue;
|
|
64
|
+
this.masked = masked;
|
|
65
|
+
},
|
|
66
|
+
enumerable: false,
|
|
67
|
+
configurable: true
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(InputMask.prototype, "value", {
|
|
70
|
+
/** Raw value */
|
|
71
|
+
get: function () {
|
|
72
|
+
return this._value;
|
|
73
|
+
},
|
|
74
|
+
set: function (str) {
|
|
75
|
+
if (this.value === str) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.masked.value = str;
|
|
79
|
+
this.updateControl('auto');
|
|
80
|
+
},
|
|
81
|
+
enumerable: false,
|
|
82
|
+
configurable: true
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(InputMask.prototype, "unmaskedValue", {
|
|
85
|
+
/** Unmasked value */
|
|
86
|
+
get: function () {
|
|
87
|
+
return this._unmaskedValue;
|
|
88
|
+
},
|
|
89
|
+
set: function (str) {
|
|
90
|
+
if (this.unmaskedValue === str) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this.masked.unmaskedValue = str;
|
|
94
|
+
this.updateControl('auto');
|
|
95
|
+
},
|
|
96
|
+
enumerable: false,
|
|
97
|
+
configurable: true
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(InputMask.prototype, "rawInputValue", {
|
|
100
|
+
/** Raw input value */
|
|
101
|
+
get: function () {
|
|
102
|
+
return this._rawInputValue;
|
|
103
|
+
},
|
|
104
|
+
set: function (str) {
|
|
105
|
+
if (this.rawInputValue === str) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this.masked.rawInputValue = str;
|
|
109
|
+
this.updateControl();
|
|
110
|
+
this.alignCursor();
|
|
111
|
+
},
|
|
112
|
+
enumerable: false,
|
|
113
|
+
configurable: true
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(InputMask.prototype, "typedValue", {
|
|
116
|
+
/** Typed unmasked value */
|
|
117
|
+
get: function () {
|
|
118
|
+
return this.masked.typedValue;
|
|
119
|
+
},
|
|
120
|
+
set: function (val) {
|
|
121
|
+
if (this.masked.typedValueEquals(val)) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.masked.typedValue = val;
|
|
125
|
+
this.updateControl('auto');
|
|
126
|
+
},
|
|
127
|
+
enumerable: false,
|
|
128
|
+
configurable: true
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(InputMask.prototype, "displayValue", {
|
|
131
|
+
/** Display value */
|
|
132
|
+
get: function () {
|
|
133
|
+
return this.masked.displayValue;
|
|
134
|
+
},
|
|
135
|
+
enumerable: false,
|
|
136
|
+
configurable: true
|
|
137
|
+
});
|
|
138
|
+
/** Starts listening to element events */
|
|
139
|
+
InputMask.prototype._bindEvents = function () {
|
|
140
|
+
if (!this.el) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this.el.bindEvents({
|
|
144
|
+
selectionChange: this._saveSelection,
|
|
145
|
+
input: this._onInput,
|
|
146
|
+
drop: this._onDrop,
|
|
147
|
+
click: this._onClick,
|
|
148
|
+
focus: this._onFocus,
|
|
149
|
+
commit: this._onChange,
|
|
150
|
+
undo: this._onUndo,
|
|
151
|
+
redo: this._onRedo,
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
/** Stops listening to element events */
|
|
155
|
+
InputMask.prototype._unbindEvents = function () {
|
|
156
|
+
if (this.el) {
|
|
157
|
+
this.el.unbindEvents();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
/** Fires custom event */
|
|
161
|
+
InputMask.prototype._fireEvent = function (ev, e) {
|
|
162
|
+
var listeners = this._listeners[ev];
|
|
163
|
+
if (!listeners) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
listeners.forEach(function (l) { return l(e); });
|
|
167
|
+
};
|
|
168
|
+
Object.defineProperty(InputMask.prototype, "selectionStart", {
|
|
169
|
+
/** Current selection start */
|
|
170
|
+
get: function () {
|
|
171
|
+
if (!this.el) {
|
|
172
|
+
return 0;
|
|
173
|
+
}
|
|
174
|
+
return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
|
|
175
|
+
},
|
|
176
|
+
enumerable: false,
|
|
177
|
+
configurable: true
|
|
178
|
+
});
|
|
179
|
+
Object.defineProperty(InputMask.prototype, "cursorPos", {
|
|
180
|
+
/** Current cursor position */
|
|
181
|
+
get: function () {
|
|
182
|
+
if (!this.el) {
|
|
183
|
+
return 0;
|
|
184
|
+
}
|
|
185
|
+
return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
|
|
186
|
+
},
|
|
187
|
+
set: function (pos) {
|
|
188
|
+
if (!this.el || !this.el.isActive) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
this.el.select(pos, pos);
|
|
192
|
+
this._saveSelection();
|
|
193
|
+
},
|
|
194
|
+
enumerable: false,
|
|
195
|
+
configurable: true
|
|
196
|
+
});
|
|
197
|
+
/** Stores current selection */
|
|
198
|
+
InputMask.prototype._saveSelection = function ( /* ev */) {
|
|
199
|
+
if (!this.el) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (this.displayValue !== this.el.value) {
|
|
203
|
+
console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.');
|
|
204
|
+
}
|
|
205
|
+
this._selection = {
|
|
206
|
+
start: this.selectionStart,
|
|
207
|
+
end: this.cursorPos,
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
/** Syncronizes model value from view */
|
|
211
|
+
InputMask.prototype.updateValue = function () {
|
|
212
|
+
if (!this.el) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
this.masked.value = this.el.value;
|
|
216
|
+
this._value = this.masked.value;
|
|
217
|
+
this._unmaskedValue = this.masked.unmaskedValue;
|
|
218
|
+
this._rawInputValue = this.masked.rawInputValue;
|
|
219
|
+
};
|
|
220
|
+
/** Syncronizes view from model value, fires change events */
|
|
221
|
+
InputMask.prototype.updateControl = function (cursorPos) {
|
|
222
|
+
if (!this.el) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
var newUnmaskedValue = this.masked.unmaskedValue;
|
|
226
|
+
var newValue = this.masked.value;
|
|
227
|
+
var newRawInputValue = this.masked.rawInputValue;
|
|
228
|
+
var newDisplayValue = this.displayValue;
|
|
229
|
+
var isChanged = this.unmaskedValue !== newUnmaskedValue || this.value !== newValue || this._rawInputValue !== newRawInputValue;
|
|
230
|
+
this._unmaskedValue = newUnmaskedValue;
|
|
231
|
+
this._value = newValue;
|
|
232
|
+
this._rawInputValue = newRawInputValue;
|
|
233
|
+
if (this.el.value !== newDisplayValue) {
|
|
234
|
+
this.el.value = newDisplayValue;
|
|
235
|
+
}
|
|
236
|
+
if (cursorPos === 'auto') {
|
|
237
|
+
this.alignCursor();
|
|
238
|
+
}
|
|
239
|
+
else if (cursorPos != null) {
|
|
240
|
+
this.cursorPos = cursorPos;
|
|
241
|
+
}
|
|
242
|
+
if (isChanged) {
|
|
243
|
+
this._fireChangeEvents();
|
|
244
|
+
}
|
|
245
|
+
if (!this._historyChanging && (isChanged || this.history.isEmpty)) {
|
|
246
|
+
this.history.push({
|
|
247
|
+
unmaskedValue: newUnmaskedValue,
|
|
248
|
+
selection: { start: this.selectionStart, end: this.cursorPos },
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
/** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */
|
|
253
|
+
InputMask.prototype.updateOptions = function (opts) {
|
|
254
|
+
var _a = opts, mask = _a.mask, restOpts = __rest(_a, ["mask"]);
|
|
255
|
+
var updateMask = !this.maskEquals(mask);
|
|
256
|
+
// Union (MaskedPattern | MaskedRegExp): updateOptions принимает пересечение опций, TS не выводит; каст неизбежен
|
|
257
|
+
var updateOpts = this.masked.optionsIsChanged(restOpts);
|
|
258
|
+
if (updateMask) {
|
|
259
|
+
this.mask = mask;
|
|
260
|
+
}
|
|
261
|
+
if (updateOpts) {
|
|
262
|
+
this.masked.updateOptions(restOpts);
|
|
263
|
+
}
|
|
264
|
+
if (updateMask || updateOpts) {
|
|
265
|
+
this.updateControl();
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
/** Updates cursor */
|
|
269
|
+
InputMask.prototype.updateCursor = function (cursorPos) {
|
|
270
|
+
if (cursorPos == null) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
this.cursorPos = cursorPos;
|
|
274
|
+
// also queue change cursor for mobile browsers
|
|
275
|
+
this._delayUpdateCursor(cursorPos);
|
|
276
|
+
};
|
|
277
|
+
/** Delays cursor update to support mobile browsers */
|
|
278
|
+
InputMask.prototype._delayUpdateCursor = function (cursorPos) {
|
|
279
|
+
var _this = this;
|
|
280
|
+
this._abortUpdateCursor();
|
|
281
|
+
this._changingCursorPos = cursorPos;
|
|
282
|
+
this._cursorChanging = setTimeout(function () {
|
|
283
|
+
if (!_this.el) {
|
|
284
|
+
return;
|
|
285
|
+
} // if was destroyed
|
|
286
|
+
_this.cursorPos = _this._changingCursorPos;
|
|
287
|
+
_this._abortUpdateCursor();
|
|
288
|
+
}, 10);
|
|
289
|
+
};
|
|
290
|
+
/** Fires custom events */
|
|
291
|
+
InputMask.prototype._fireChangeEvents = function () {
|
|
292
|
+
this._fireEvent('accept', this._inputEvent);
|
|
293
|
+
if (this.masked.isComplete) {
|
|
294
|
+
this._fireEvent('complete', this._inputEvent);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
/** Aborts delayed cursor update */
|
|
298
|
+
InputMask.prototype._abortUpdateCursor = function () {
|
|
299
|
+
if (this._cursorChanging) {
|
|
300
|
+
clearTimeout(this._cursorChanging);
|
|
301
|
+
delete this._cursorChanging;
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
/** Aligns cursor to nearest available position */
|
|
305
|
+
InputMask.prototype.alignCursor = function () {
|
|
306
|
+
this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));
|
|
307
|
+
};
|
|
308
|
+
/** Aligns cursor only if selection is empty */
|
|
309
|
+
InputMask.prototype.alignCursorFriendly = function () {
|
|
310
|
+
if (this.selectionStart !== this.cursorPos) {
|
|
311
|
+
return;
|
|
312
|
+
} // skip if range is selected
|
|
313
|
+
this.alignCursor();
|
|
314
|
+
};
|
|
315
|
+
/** Adds listener on custom event */
|
|
316
|
+
InputMask.prototype.on = function (ev, handler) {
|
|
317
|
+
if (!this._listeners[ev]) {
|
|
318
|
+
this._listeners[ev] = [];
|
|
319
|
+
}
|
|
320
|
+
this._listeners[ev].push(handler);
|
|
321
|
+
return this;
|
|
322
|
+
};
|
|
323
|
+
/** Removes custom event listener */
|
|
324
|
+
InputMask.prototype.off = function (ev, handler) {
|
|
325
|
+
if (!this._listeners[ev]) {
|
|
326
|
+
return this;
|
|
327
|
+
}
|
|
328
|
+
if (!handler) {
|
|
329
|
+
delete this._listeners[ev];
|
|
330
|
+
return this;
|
|
331
|
+
}
|
|
332
|
+
var hIndex = this._listeners[ev].indexOf(handler);
|
|
333
|
+
if (hIndex >= 0) {
|
|
334
|
+
this._listeners[ev].splice(hIndex, 1);
|
|
335
|
+
}
|
|
336
|
+
return this;
|
|
337
|
+
};
|
|
338
|
+
/** Handles view input event */
|
|
339
|
+
InputMask.prototype._onInput = function (e) {
|
|
340
|
+
if (!this.el) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
this._inputEvent = e;
|
|
344
|
+
this._abortUpdateCursor();
|
|
345
|
+
var details = new ActionDetails({
|
|
346
|
+
// new state
|
|
347
|
+
value: this.el.value,
|
|
348
|
+
cursorPos: this.cursorPos,
|
|
349
|
+
// old state
|
|
350
|
+
oldValue: this.displayValue,
|
|
351
|
+
oldSelection: this._selection,
|
|
352
|
+
});
|
|
353
|
+
var oldRawValue = this.masked.rawInputValue;
|
|
354
|
+
var offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection, { input: true, raw: true }).offset;
|
|
355
|
+
// force align in remove direction only if no input chars were removed
|
|
356
|
+
// otherwise we still need to align with NONE (to get out from fixed symbols for instance)
|
|
357
|
+
var removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
|
|
358
|
+
var cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
|
|
359
|
+
if (removeDirection !== DIRECTION.NONE) {
|
|
360
|
+
cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
|
|
361
|
+
}
|
|
362
|
+
this.updateControl(cursorPos);
|
|
363
|
+
delete this._inputEvent;
|
|
364
|
+
};
|
|
365
|
+
/** Handles view change event and commits model value */
|
|
366
|
+
InputMask.prototype._onChange = function () {
|
|
367
|
+
if (!this.el) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (this.displayValue !== this.el.value) {
|
|
371
|
+
this.updateValue();
|
|
372
|
+
}
|
|
373
|
+
this.masked.doCommit();
|
|
374
|
+
this.updateControl();
|
|
375
|
+
this._saveSelection();
|
|
376
|
+
};
|
|
377
|
+
/** Handles view drop event, prevents by default */
|
|
378
|
+
InputMask.prototype._onDrop = function (ev) {
|
|
379
|
+
ev.preventDefault();
|
|
380
|
+
ev.stopPropagation();
|
|
381
|
+
};
|
|
382
|
+
/** Restore last selection on focus */
|
|
383
|
+
InputMask.prototype._onFocus = function () {
|
|
384
|
+
this.alignCursorFriendly();
|
|
385
|
+
};
|
|
386
|
+
/** Restore last selection on focus */
|
|
387
|
+
InputMask.prototype._onClick = function () {
|
|
388
|
+
this.alignCursorFriendly();
|
|
389
|
+
};
|
|
390
|
+
InputMask.prototype._onUndo = function () {
|
|
391
|
+
this._applyHistoryState(this.history.undo());
|
|
392
|
+
};
|
|
393
|
+
InputMask.prototype._onRedo = function () {
|
|
394
|
+
this._applyHistoryState(this.history.redo());
|
|
395
|
+
};
|
|
396
|
+
InputMask.prototype._applyHistoryState = function (state) {
|
|
397
|
+
if (!state || !this.el) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
this._historyChanging = true;
|
|
401
|
+
// При undo/redo программно меняем value, input не вызывается — _inputEvent пуст.
|
|
402
|
+
// Задаём синтетическое событие, чтобы родитель (MaskedInput) вызвал onValueChange и
|
|
403
|
+
// обновил state, иначе при blur value из props перезапишет откатанное значение.
|
|
404
|
+
this._inputEvent = new InputEvent('input', { bubbles: true, cancelable: false });
|
|
405
|
+
this.unmaskedValue = state.unmaskedValue;
|
|
406
|
+
this.el.select(state.selection.start, state.selection.end);
|
|
407
|
+
this._saveSelection();
|
|
408
|
+
delete this._inputEvent;
|
|
409
|
+
this._historyChanging = false;
|
|
410
|
+
};
|
|
411
|
+
/** Unbind view events and removes element reference */
|
|
412
|
+
InputMask.prototype.destroy = function () {
|
|
413
|
+
this._unbindEvents();
|
|
414
|
+
this._listeners = {};
|
|
415
|
+
this.el = null;
|
|
416
|
+
};
|
|
417
|
+
return InputMask;
|
|
418
|
+
}());
|
|
419
|
+
export { InputMask };
|
|
420
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["input.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,2BAA2B;AAC3B,OAAO,EAAE,SAAS,EAAkB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAsB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,UAAU,EAEV,WAAW,GAGZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAqB,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,YAAY,EAA0B,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhD,wFAAwF;AACxF;IAoBE,mBAAY,EAAoB,EAAE,IAAU;QAC1C,IAAI,CAAC,EAAE,GAAG,EAAE,YAAY,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC,EAAkB,CAAC,CAAC;QAExF,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAE/B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,EAAE,CAAC;QAElC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,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CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;QACzC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC3D,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC;QACxB,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;IAED,uDAAuD;IACvD,2BAAO,GAAP;QACE,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;IACjB,CAAC;IACH,gBAAC;AAAD,CAAC,AAxcD,IAwcC","sourcesContent":["import { ActionDetails } from '../core/action-details.js';\n/* eslint-disable eqeqeq */\nimport { DIRECTION, type Selection } from '../core/utils.js';\nimport { Masked, type MaskedOptions } from '../masked/base.js';\nimport {\n createMask,\n type UpdateOpts,\n maskedClass,\n type FactoryArg,\n type FactoryReturnMasked,\n} from '../masked/factory.js';\nimport { HTMLInputMaskElement, type InputElement } from './html-input-mask-element.js';\nimport { InputHistory, type InputHistoryState } from './input-history.js';\nimport { MaskElement } from './mask-element.js';\n\nexport type InputMaskElement = MaskElement | InputElement | HTMLElement;\n\nexport type InputMaskEventListener = (e?: InputEvent) => void;\n\n/** Listens to element events and controls changes between element and {@link Masked} */\nexport class InputMask<Opts extends FactoryArg = Record<string, unknown>> {\n /**\n View element. Set to null after destroy() to release the reference.\n */\n el!: MaskElement | null;\n\n /** Internal {@link Masked} model */\n masked!: FactoryReturnMasked<Opts>;\n\n _listeners!: Record<string, InputMaskEventListener[]>;\n _value!: string;\n _changingCursorPos!: number;\n _unmaskedValue!: string;\n _rawInputValue!: string;\n _selection!: Selection;\n _cursorChanging?: ReturnType<typeof setTimeout>;\n _historyChanging?: boolean;\n _inputEvent?: InputEvent;\n history!: InputHistory;\n\n constructor(el: InputMaskElement, opts: Opts) {\n this.el = el instanceof MaskElement ? el : new HTMLInputMaskElement(el as InputElement);\n\n this.masked = createMask(opts);\n\n this._listeners = {};\n this._value = '';\n this._unmaskedValue = '';\n this._rawInputValue = '';\n this.history = new InputHistory();\n\n this._saveSelection = this._saveSelection.bind(this);\n this._onInput = this._onInput.bind(this);\n this._onChange = this._onChange.bind(this);\n this._onDrop = this._onDrop.bind(this);\n this._onFocus = this._onFocus.bind(this);\n this._onClick = this._onClick.bind(this);\n this._onUndo = this._onUndo.bind(this);\n this._onRedo = this._onRedo.bind(this);\n this.alignCursor = this.alignCursor.bind(this);\n this.alignCursorFriendly = this.alignCursorFriendly.bind(this);\n\n this._bindEvents();\n\n // refresh\n this.updateValue();\n this._onChange();\n }\n\n maskEquals(mask: unknown): boolean {\n return mask == null || this.masked?.maskEquals(mask);\n }\n\n /** Masked */\n get mask(): FactoryReturnMasked<Opts>['mask'] {\n return this.masked.mask;\n }\n set mask(mask: unknown) {\n if (this.maskEquals(mask)) {\n return;\n }\n\n if (!(mask instanceof Masked) && this.masked.constructor === maskedClass(mask as Masked)) {\n this.masked.updateOptions({ mask } as Partial<MaskedOptions>);\n return;\n }\n\n const masked = (\n (mask as Masked) instanceof Masked ? mask : createMask({ mask } as Opts)\n ) as FactoryReturnMasked<Opts>;\n masked.unmaskedValue = this.masked.unmaskedValue;\n this.masked = masked;\n }\n\n /** Raw value */\n get value(): string {\n return this._value;\n }\n\n set value(str: string) {\n if (this.value === str) {\n return;\n }\n\n this.masked.value = str;\n this.updateControl('auto');\n }\n\n /** Unmasked value */\n get unmaskedValue(): string {\n return this._unmaskedValue;\n }\n\n set unmaskedValue(str: string) {\n if (this.unmaskedValue === str) {\n return;\n }\n\n this.masked.unmaskedValue = str;\n this.updateControl('auto');\n }\n\n /** Raw input value */\n get rawInputValue(): string {\n return this._rawInputValue;\n }\n\n set rawInputValue(str: string) {\n if (this.rawInputValue === str) {\n return;\n }\n\n this.masked.rawInputValue = str;\n this.updateControl();\n this.alignCursor();\n }\n\n /** Typed unmasked value */\n get typedValue(): FactoryReturnMasked<Opts>['typedValue'] {\n return this.masked.typedValue;\n }\n\n set typedValue(val: FactoryReturnMasked<Opts>['typedValue']) {\n if (this.masked.typedValueEquals(val)) {\n return;\n }\n\n this.masked.typedValue = val;\n this.updateControl('auto');\n }\n\n /** Display value */\n get displayValue(): string {\n return this.masked.displayValue;\n }\n\n /** Starts listening to element events */\n _bindEvents(): void {\n if (!this.el) {\n return;\n }\n this.el.bindEvents({\n selectionChange: this._saveSelection,\n input: this._onInput,\n drop: this._onDrop,\n click: this._onClick,\n focus: this._onFocus,\n commit: this._onChange,\n undo: this._onUndo,\n redo: this._onRedo,\n });\n }\n\n /** Stops listening to element events */\n _unbindEvents(): void {\n if (this.el) {\n this.el.unbindEvents();\n }\n }\n\n /** Fires custom event */\n _fireEvent(ev: string, e?: InputEvent): void {\n const listeners = this._listeners[ev];\n if (!listeners) {\n return;\n }\n\n listeners.forEach((l) => l(e));\n }\n\n /** Current selection start */\n get selectionStart(): number {\n if (!this.el) {\n return 0;\n }\n return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;\n }\n\n /** Current cursor position */\n get cursorPos(): number {\n if (!this.el) {\n return 0;\n }\n return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;\n }\n set cursorPos(pos: number) {\n if (!this.el || !this.el.isActive) {\n return;\n }\n\n this.el.select(pos, pos);\n this._saveSelection();\n }\n\n /** Stores current selection */\n _saveSelection(/* ev */): void {\n if (!this.el) {\n return;\n }\n if (this.displayValue !== this.el.value) {\n console.warn(\n 'Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.',\n );\n }\n this._selection = {\n start: this.selectionStart,\n end: this.cursorPos,\n };\n }\n\n /** Syncronizes model value from view */\n updateValue(): void {\n if (!this.el) {\n return;\n }\n this.masked.value = this.el.value;\n this._value = this.masked.value;\n this._unmaskedValue = this.masked.unmaskedValue;\n this._rawInputValue = this.masked.rawInputValue;\n }\n\n /** Syncronizes view from model value, fires change events */\n updateControl(cursorPos?: number | 'auto'): void {\n if (!this.el) {\n return;\n }\n const newUnmaskedValue = this.masked.unmaskedValue;\n const newValue = this.masked.value;\n const newRawInputValue = this.masked.rawInputValue;\n const newDisplayValue = this.displayValue;\n\n const isChanged =\n this.unmaskedValue !== newUnmaskedValue || this.value !== newValue || this._rawInputValue !== newRawInputValue;\n this._unmaskedValue = newUnmaskedValue;\n this._value = newValue;\n this._rawInputValue = newRawInputValue;\n\n if (this.el.value !== newDisplayValue) {\n this.el.value = newDisplayValue;\n }\n\n if (cursorPos === 'auto') {\n this.alignCursor();\n } else if (cursorPos != null) {\n this.cursorPos = cursorPos;\n }\n\n if (isChanged) {\n this._fireChangeEvents();\n }\n if (!this._historyChanging && (isChanged || this.history.isEmpty)) {\n this.history.push({\n unmaskedValue: newUnmaskedValue,\n selection: { start: this.selectionStart, end: this.cursorPos },\n });\n }\n }\n\n /** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */\n updateOptions(opts: UpdateOpts<Opts>): void {\n const { mask, ...restOpts } = opts as UpdateOpts<Opts> & { mask?: unknown };\n\n const updateMask = !this.maskEquals(mask);\n // Union (MaskedPattern | MaskedRegExp): updateOptions принимает пересечение опций, TS не выводит; каст неизбежен\n const updateOpts = this.masked.optionsIsChanged(restOpts as any);\n if (updateMask) {\n this.mask = mask;\n }\n if (updateOpts) {\n this.masked.updateOptions(restOpts as any);\n }\n\n if (updateMask || updateOpts) {\n this.updateControl();\n }\n }\n\n /** Updates cursor */\n updateCursor(cursorPos: number): void {\n if (cursorPos == null) {\n return;\n }\n this.cursorPos = cursorPos;\n\n // also queue change cursor for mobile browsers\n this._delayUpdateCursor(cursorPos);\n }\n\n /** Delays cursor update to support mobile browsers */\n _delayUpdateCursor(cursorPos: number): void {\n this._abortUpdateCursor();\n this._changingCursorPos = cursorPos;\n this._cursorChanging = setTimeout(() => {\n if (!this.el) {\n return;\n } // if was destroyed\n this.cursorPos = this._changingCursorPos;\n this._abortUpdateCursor();\n }, 10);\n }\n\n /** Fires custom events */\n _fireChangeEvents(): void {\n this._fireEvent('accept', this._inputEvent);\n if (this.masked.isComplete) {\n this._fireEvent('complete', this._inputEvent);\n }\n }\n\n /** Aborts delayed cursor update */\n _abortUpdateCursor(): void {\n if (this._cursorChanging) {\n clearTimeout(this._cursorChanging);\n delete this._cursorChanging;\n }\n }\n\n /** Aligns cursor to nearest available position */\n alignCursor(): void {\n this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));\n }\n\n /** Aligns cursor only if selection is empty */\n alignCursorFriendly(): void {\n if (this.selectionStart !== this.cursorPos) {\n return;\n } // skip if range is selected\n this.alignCursor();\n }\n\n /** Adds listener on custom event */\n on(ev: string, handler: InputMaskEventListener): this {\n if (!this._listeners[ev]) {\n this._listeners[ev] = [];\n }\n this._listeners[ev].push(handler);\n return this;\n }\n\n /** Removes custom event listener */\n off(ev: string, handler: InputMaskEventListener): this {\n if (!this._listeners[ev]) {\n return this;\n }\n if (!handler) {\n delete this._listeners[ev];\n return this;\n }\n const hIndex = this._listeners[ev].indexOf(handler);\n if (hIndex >= 0) {\n this._listeners[ev].splice(hIndex, 1);\n }\n return this;\n }\n\n /** Handles view input event */\n _onInput(e: InputEvent): void {\n if (!this.el) {\n return;\n }\n this._inputEvent = e;\n this._abortUpdateCursor();\n\n const details = new ActionDetails({\n // new state\n value: this.el.value,\n cursorPos: this.cursorPos,\n\n // old state\n oldValue: this.displayValue,\n oldSelection: this._selection,\n });\n\n const oldRawValue = this.masked.rawInputValue;\n\n const offset = this.masked.splice(\n details.startChangePos,\n details.removed.length,\n details.inserted,\n details.removeDirection,\n { input: true, raw: true },\n ).offset;\n\n // force align in remove direction only if no input chars were removed\n // otherwise we still need to align with NONE (to get out from fixed symbols for instance)\n const removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;\n\n let cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);\n if (removeDirection !== DIRECTION.NONE) {\n cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);\n }\n\n this.updateControl(cursorPos);\n delete this._inputEvent;\n }\n\n /** Handles view change event and commits model value */\n _onChange(): void {\n if (!this.el) {\n return;\n }\n if (this.displayValue !== this.el.value) {\n this.updateValue();\n }\n this.masked.doCommit();\n this.updateControl();\n this._saveSelection();\n }\n\n /** Handles view drop event, prevents by default */\n _onDrop(ev: Event): void {\n ev.preventDefault();\n ev.stopPropagation();\n }\n\n /** Restore last selection on focus */\n _onFocus(): void {\n this.alignCursorFriendly();\n }\n\n /** Restore last selection on focus */\n _onClick(): void {\n this.alignCursorFriendly();\n }\n\n _onUndo(): void {\n this._applyHistoryState(this.history.undo());\n }\n\n _onRedo(): void {\n this._applyHistoryState(this.history.redo());\n }\n\n _applyHistoryState(state: InputHistoryState | undefined): void {\n if (!state || !this.el) {\n return;\n }\n\n this._historyChanging = true;\n // При undo/redo программно меняем value, input не вызывается — _inputEvent пуст.\n // Задаём синтетическое событие, чтобы родитель (MaskedInput) вызвал onValueChange и\n // обновил state, иначе при blur value из props перезапишет откатанное значение.\n this._inputEvent = new InputEvent('input', { bubbles: true, cancelable: false });\n this.unmaskedValue = state.unmaskedValue;\n this.el.select(state.selection.start, state.selection.end);\n this._saveSelection();\n delete this._inputEvent;\n this._historyChanging = false;\n }\n\n /** Unbind view events and removes element reference */\n destroy(): void {\n this._unbindEvents();\n this._listeners = {};\n this.el = null;\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type ElementEvent = 'selectionChange' | 'input' | 'drop' | 'click' | 'focus' | 'commit';
|
|
2
|
+
export type EventHandlers = {
|
|
3
|
+
[key in ElementEvent]: (...args: any[]) => void;
|
|
4
|
+
} & {
|
|
5
|
+
undo?: (...args: any[]) => void;
|
|
6
|
+
redo?: (...args: any[]) => void;
|
|
7
|
+
};
|
|
8
|
+
/** Generic element API to use with mask */
|
|
9
|
+
export declare abstract class MaskElement {
|
|
10
|
+
/** */
|
|
11
|
+
abstract _unsafeSelectionStart: number | null;
|
|
12
|
+
/** */
|
|
13
|
+
abstract _unsafeSelectionEnd: number | null;
|
|
14
|
+
/** */
|
|
15
|
+
abstract value: string;
|
|
16
|
+
/** Safely returns selection start */
|
|
17
|
+
get selectionStart(): number;
|
|
18
|
+
/** Safely returns selection end */
|
|
19
|
+
get selectionEnd(): number;
|
|
20
|
+
/** Safely sets element selection */
|
|
21
|
+
select(start: number, end: number): void;
|
|
22
|
+
/** */
|
|
23
|
+
get isActive(): boolean;
|
|
24
|
+
/** */
|
|
25
|
+
abstract _unsafeSelect(start: number, end: number): void;
|
|
26
|
+
/** */
|
|
27
|
+
abstract bindEvents(handlers: EventHandlers): void;
|
|
28
|
+
/** */
|
|
29
|
+
abstract unbindEvents(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* eslint-disable eqeqeq */
|
|
2
|
+
/** Generic element API to use with mask */
|
|
3
|
+
var MaskElement = /** @class */ (function () {
|
|
4
|
+
function MaskElement() {
|
|
5
|
+
}
|
|
6
|
+
Object.defineProperty(MaskElement.prototype, "selectionStart", {
|
|
7
|
+
/** Safely returns selection start */
|
|
8
|
+
get: function () {
|
|
9
|
+
var start;
|
|
10
|
+
try {
|
|
11
|
+
start = this._unsafeSelectionStart;
|
|
12
|
+
}
|
|
13
|
+
catch (_a) {
|
|
14
|
+
/* empty */
|
|
15
|
+
}
|
|
16
|
+
return start != null ? start : this.value.length;
|
|
17
|
+
},
|
|
18
|
+
enumerable: false,
|
|
19
|
+
configurable: true
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(MaskElement.prototype, "selectionEnd", {
|
|
22
|
+
/** Safely returns selection end */
|
|
23
|
+
get: function () {
|
|
24
|
+
var end;
|
|
25
|
+
try {
|
|
26
|
+
end = this._unsafeSelectionEnd;
|
|
27
|
+
}
|
|
28
|
+
catch (_a) {
|
|
29
|
+
/* empty */
|
|
30
|
+
}
|
|
31
|
+
return end != null ? end : this.value.length;
|
|
32
|
+
},
|
|
33
|
+
enumerable: false,
|
|
34
|
+
configurable: true
|
|
35
|
+
});
|
|
36
|
+
/** Safely sets element selection */
|
|
37
|
+
MaskElement.prototype.select = function (start, end) {
|
|
38
|
+
if (start == null || end == null || (start === this.selectionStart && end === this.selectionEnd)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
this._unsafeSelect(start, end);
|
|
43
|
+
}
|
|
44
|
+
catch (_a) {
|
|
45
|
+
/* empty */
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(MaskElement.prototype, "isActive", {
|
|
49
|
+
/** */
|
|
50
|
+
get: function () {
|
|
51
|
+
return false;
|
|
52
|
+
},
|
|
53
|
+
enumerable: false,
|
|
54
|
+
configurable: true
|
|
55
|
+
});
|
|
56
|
+
return MaskElement;
|
|
57
|
+
}());
|
|
58
|
+
export { MaskElement };
|
|
59
|
+
//# sourceMappingURL=mask-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mask-element.js","sourceRoot":"","sources":["mask-element.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAS3B,4CAA4C;AAC5C;IAAA;IAuDA,CAAC;IA9CC,sBAAI,uCAAc;QADlB,qCAAqC;aACrC;YACE,IAAI,KAAK,CAAC;YACV,IAAI,CAAC;gBACH,KAAK,GAAG,IAAI,CAAC,qBAAqB,CAAC;YACrC,CAAC;YAAC,WAAM,CAAC;gBACP,WAAW;YACb,CAAC;YAED,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QACnD,CAAC;;;OAAA;IAGD,sBAAI,qCAAY;QADhB,mCAAmC;aACnC;YACE,IAAI,GAAG,CAAC;YACR,IAAI,CAAC;gBACH,GAAG,GAAG,IAAI,CAAC,mBAAmB,CAAC;YACjC,CAAC;YAAC,WAAM,CAAC;gBACP,WAAW;YACb,CAAC;YAED,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QAC/C,CAAC;;;OAAA;IAED,oCAAoC;IACpC,4BAAM,GAAN,UAAO,KAAa,EAAE,GAAW;QAC/B,IAAI,KAAK,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,cAAc,IAAI,GAAG,KAAK,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YACjG,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACjC,CAAC;QAAC,WAAM,CAAC;YACP,WAAW;QACb,CAAC;IACH,CAAC;IAGD,sBAAI,iCAAQ;QADZ,MAAM;aACN;YACE,OAAO,KAAK,CAAC;QACf,CAAC;;;OAAA;IAOH,kBAAC;AAAD,CAAC,AAvDD,IAuDC","sourcesContent":["/* eslint-disable eqeqeq */\n\nexport type ElementEvent = 'selectionChange' | 'input' | 'drop' | 'click' | 'focus' | 'commit';\n\nexport type EventHandlers = { [key in ElementEvent]: (...args: any[]) => void } & {\n undo?: (...args: any[]) => void;\n redo?: (...args: any[]) => void;\n};\n\n/** Generic element API to use with mask */\nexport abstract class MaskElement {\n /** */\n abstract _unsafeSelectionStart: number | null;\n /** */\n abstract _unsafeSelectionEnd: number | null;\n /** */\n abstract value: string;\n\n /** Safely returns selection start */\n get selectionStart(): number {\n let start;\n try {\n start = this._unsafeSelectionStart;\n } catch {\n /* empty */\n }\n\n return start != null ? start : this.value.length;\n }\n\n /** Safely returns selection end */\n get selectionEnd(): number {\n let end;\n try {\n end = this._unsafeSelectionEnd;\n } catch {\n /* empty */\n }\n\n return end != null ? end : this.value.length;\n }\n\n /** Safely sets element selection */\n select(start: number, end: number): void {\n if (start == null || end == null || (start === this.selectionStart && end === this.selectionEnd)) {\n return;\n }\n\n try {\n this._unsafeSelect(start, end);\n } catch {\n /* empty */\n }\n }\n\n /** */\n get isActive(): boolean {\n return false;\n }\n /** */\n abstract _unsafeSelect(start: number, end: number): void;\n /** */\n abstract bindEvents(handlers: EventHandlers): void;\n /** */\n abstract unbindEvents(): void;\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Direction, type Selection } from './utils.js';
|
|
2
|
+
export type ActionDetailsOptions = Pick<ActionDetails, 'value' | 'cursorPos' | 'oldValue' | 'oldSelection'>;
|
|
3
|
+
/** Provides details of changing input */
|
|
4
|
+
export declare class ActionDetails {
|
|
5
|
+
/** Current input value */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Current cursor position */
|
|
8
|
+
cursorPos: number;
|
|
9
|
+
/** Old input value */
|
|
10
|
+
oldValue: string;
|
|
11
|
+
/** Old selection */
|
|
12
|
+
oldSelection: Selection;
|
|
13
|
+
constructor(opts: ActionDetailsOptions);
|
|
14
|
+
/** Start changing position */
|
|
15
|
+
get startChangePos(): number;
|
|
16
|
+
/** Inserted symbols count */
|
|
17
|
+
get insertedCount(): number;
|
|
18
|
+
/** Inserted symbols */
|
|
19
|
+
get inserted(): string;
|
|
20
|
+
/** Removed symbols count */
|
|
21
|
+
get removedCount(): number;
|
|
22
|
+
/** Removed symbols */
|
|
23
|
+
get removed(): string;
|
|
24
|
+
/** Unchanged head symbols */
|
|
25
|
+
get head(): string;
|
|
26
|
+
/** Unchanged tail symbols */
|
|
27
|
+
get tail(): string;
|
|
28
|
+
/** Remove direction */
|
|
29
|
+
get removeDirection(): Direction;
|
|
30
|
+
}
|