@skbkontur/react-ui 6.2.0-beta.0 → 6.2.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/CHANGELOG.md +78 -0
- package/components/Button/Button.classes.d.ts +8 -0
- package/components/Button/Button.classes.js +10 -0
- package/components/Button/Button.classes.js.map +1 -0
- package/components/Button/Button.mixins.js +1 -1
- package/components/Button/Button.mixins.js.map +1 -1
- package/components/Button/Button.styles.d.ts +2 -8
- package/components/Button/Button.styles.js +3 -9
- package/components/Button/Button.styles.js.map +1 -1
- package/components/Calendar/Calendar.d.ts +2 -8
- package/components/Calendar/Calendar.js +2 -7
- package/components/Calendar/Calendar.js.map +1 -1
- package/components/Calendar/CalendarDay.js +1 -1
- package/components/Calendar/CalendarDay.js.map +1 -1
- package/components/Calendar/MonthView.js +1 -1
- package/components/Calendar/MonthView.js.map +1 -1
- package/components/Calendar/MonthViewModel.js +1 -2
- package/components/Calendar/MonthViewModel.js.map +1 -1
- package/components/Calendar/tids.d.ts +7 -0
- package/components/Calendar/tids.js +8 -0
- package/components/Calendar/tids.js.map +1 -0
- package/components/Checkbox/Checkbox.d.ts +5 -0
- package/components/Checkbox/Checkbox.js +42 -21
- package/components/Checkbox/Checkbox.js.map +1 -1
- package/components/Checkbox/Checkbox.mixins.d.ts +2 -0
- package/components/Checkbox/Checkbox.mixins.js +6 -0
- package/components/Checkbox/Checkbox.mixins.js.map +1 -1
- package/components/Checkbox/Checkbox.styles.d.ts +7 -0
- package/components/Checkbox/Checkbox.styles.js +23 -2
- package/components/Checkbox/Checkbox.styles.js.map +1 -1
- package/components/CurrencyInput/CurrencyHelper.d.ts +1 -2
- package/components/CurrencyInput/CurrencyHelper.js +32 -28
- package/components/CurrencyInput/CurrencyHelper.js.map +1 -1
- package/components/CurrencyInput/CurrencyInputHelper.js +1 -1
- package/components/CurrencyInput/CurrencyInputHelper.js.map +1 -1
- package/components/DateInput/DateInput.js +4 -1
- package/components/DateInput/DateInput.js.map +1 -1
- package/components/FileUploader/FileUploaderFile.d.ts +1 -1
- package/components/FileUploader/FileUploaderFile.js +4 -2
- package/components/FileUploader/FileUploaderFile.js.map +1 -1
- package/components/FileUploader/locale/locales/en.js +1 -0
- package/components/FileUploader/locale/locales/en.js.map +1 -1
- package/components/FileUploader/locale/locales/ru.js +1 -0
- package/components/FileUploader/locale/locales/ru.js.map +1 -1
- package/components/FileUploader/locale/types.d.ts +1 -0
- package/components/FileUploader/locale/types.js.map +1 -1
- package/components/FxInput/FxInput.d.ts +1 -1
- 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 +4 -1
- package/components/Input/Input.js +4 -1
- package/components/Input/Input.js.map +1 -1
- package/components/MaskedInput/MaskedInput.d.ts +6 -2
- package/components/MaskedInput/MaskedInput.js +10 -126
- package/components/MaskedInput/MaskedInput.js.map +1 -1
- package/components/MaskedInput/MaskedInputLegacy.d.ts +3 -0
- package/components/MaskedInput/MaskedInputLegacy.js +142 -0
- package/components/MaskedInput/MaskedInputLegacy.js.map +1 -0
- package/components/MaskedInput/index.d.ts +1 -0
- package/components/MaskedInput/index.js +1 -0
- package/components/MaskedInput/index.js.map +1 -1
- package/components/MaskedInputV2/MaskedInputV2.d.ts +62 -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 +307 -0
- package/components/MaskedInputV2/MaskedInputV2.js.map +1 -0
- package/components/MaskedInputV2/MaskedInputV2.phone.d.ts +28 -0
- package/components/MaskedInputV2/MaskedInputV2.phone.js +38 -0
- package/components/MaskedInputV2/MaskedInputV2.phone.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 +2 -0
- package/components/MaskedInputV2/index.js +3 -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 +186 -0
- package/components/MaskedInputV2/internal/MaskedCore.js.map +1 -0
- package/components/MaskedInputV2/internal/MaskedCore.types.d.ts +37 -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/computeMaskAlignPadding.d.ts +6 -0
- package/components/MaskedInputV2/internal/computeMaskAlignPadding.js +47 -0
- package/components/MaskedInputV2/internal/computeMaskAlignPadding.js.map +1 -0
- package/components/MaskedInputV2/internal/computePasteMaskedCursor.d.ts +3 -0
- package/components/MaskedInputV2/internal/computePasteMaskedCursor.js +11 -0
- package/components/MaskedInputV2/internal/computePasteMaskedCursor.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 +8 -0
- package/components/MaskedInputV2/internal/helpers.js +9 -0
- package/components/MaskedInputV2/internal/helpers.js.map +1 -0
- package/components/MaskedInputV2/internal/maskedCoreClipboard.d.ts +37 -0
- package/components/MaskedInputV2/internal/maskedCoreClipboard.js +52 -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 +38 -0
- package/components/MaskedInputV2/internal/maskedCoreInputChange.js +49 -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/measureInputTextWidth.d.ts +2 -0
- package/components/MaskedInputV2/internal/measureInputTextWidth.js +30 -0
- package/components/MaskedInputV2/internal/measureInputTextWidth.js.map +1 -0
- package/components/MaskedInputV2/internal/setMaskInputSelectionRange.d.ts +2 -0
- package/components/MaskedInputV2/internal/setMaskInputSelectionRange.js +25 -0
- package/components/MaskedInputV2/internal/setMaskInputSelectionRange.js.map +1 -0
- package/components/MaskedInputV2/internal/showOverlay.d.ts +3 -0
- package/components/MaskedInputV2/internal/showOverlay.js +16 -0
- package/components/MaskedInputV2/internal/showOverlay.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/useInputOverflow.d.ts +4 -0
- package/components/MaskedInputV2/internal/useInputOverflow.js +34 -0
- package/components/MaskedInputV2/internal/useInputOverflow.js.map +1 -0
- package/components/MaskedInputV2/internal/useMaskAlignPadding.d.ts +2 -0
- package/components/MaskedInputV2/internal/useMaskAlignPadding.js +33 -0
- package/components/MaskedInputV2/internal/useMaskAlignPadding.js.map +1 -0
- package/components/MaskedInputV2/internal/useMaskEngine.d.ts +42 -0
- package/components/MaskedInputV2/internal/useMaskEngine.js +128 -0
- package/components/MaskedInputV2/internal/useMaskEngine.js.map +1 -0
- package/components/MaskedInputV2/internal/useMaskedCoreHandlers.d.ts +34 -0
- package/components/MaskedInputV2/internal/useMaskedCoreHandlers.js +335 -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/create.d.ts +14 -0
- package/components/MaskedInputV2/react-imask/imask/masked/create.js +11 -0
- package/components/MaskedInputV2/react-imask/imask/masked/create.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 +107 -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 +549 -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 +20 -0
- package/components/MaskedInputV2/react-imask/imask/masked/patterns/chunk-tail-details.js +182 -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/components/MenuItem/MenuItem.mixins.d.ts +1 -0
- package/components/MenuItem/MenuItem.mixins.js +6 -1
- package/components/MenuItem/MenuItem.mixins.js.map +1 -1
- package/components/MenuItem/MenuItem.styles.d.ts +2 -1
- package/components/MenuItem/MenuItem.styles.js +2 -7
- package/components/MenuItem/MenuItem.styles.js.map +1 -1
- package/components/MiniModal/MiniModal.d.ts +2 -16
- package/components/MiniModal/MiniModal.js +2 -16
- package/components/MiniModal/MiniModal.js.map +1 -1
- package/components/MiniModal/MiniModalBody.js +1 -1
- package/components/MiniModal/MiniModalBody.js.map +1 -1
- package/components/MiniModal/MiniModalFooter.js +1 -1
- package/components/MiniModal/MiniModalFooter.js.map +1 -1
- package/components/MiniModal/MiniModalHeader.js +1 -1
- package/components/MiniModal/MiniModalHeader.js.map +1 -1
- package/components/MiniModal/MiniModalIndent.js +1 -1
- package/components/MiniModal/MiniModalIndent.js.map +1 -1
- package/components/MiniModal/tids.d.ts +7 -0
- package/components/MiniModal/tids.js +8 -0
- package/components/MiniModal/tids.js.map +1 -0
- package/components/Modal/Modal.constants.d.ts +9 -0
- package/components/Modal/Modal.constants.js +10 -0
- package/components/Modal/Modal.constants.js.map +1 -0
- package/components/Modal/Modal.d.ts +2 -15
- package/components/Modal/Modal.js +2 -14
- package/components/Modal/Modal.js.map +1 -1
- package/components/Modal/ModalBody.js +1 -1
- package/components/Modal/ModalBody.js.map +1 -1
- package/components/Modal/ModalClose.js +1 -1
- package/components/Modal/ModalClose.js.map +1 -1
- package/components/PasswordInput/PasswordInput.js +13 -1
- package/components/PasswordInput/PasswordInput.js.map +1 -1
- package/components/Radio/Radio.d.ts +4 -0
- package/components/Radio/Radio.js +20 -1
- package/components/Radio/Radio.js.map +1 -1
- package/components/Radio/Radio.mixins.d.ts +2 -0
- package/components/Radio/Radio.mixins.js +6 -0
- package/components/Radio/Radio.mixins.js.map +1 -1
- package/components/Radio/Radio.styles.d.ts +6 -0
- package/components/Radio/Radio.styles.js +22 -4
- package/components/Radio/Radio.styles.js.map +1 -1
- package/components/Select/Select.d.ts +1 -0
- package/components/Select/Select.js +12 -2
- package/components/Select/Select.js.map +1 -1
- package/components/Switcher/Switcher.d.ts +3 -3
- package/components/Switcher/Switcher.js +1 -1
- package/components/Switcher/Switcher.js.map +1 -1
- package/components/Tabs/Tab.d.ts +4 -5
- package/components/Tabs/Tab.js +0 -1
- package/components/Tabs/Tab.js.map +1 -1
- package/components/Tabs/Tabs.d.ts +2 -2
- package/components/Tabs/Tabs.js +1 -1
- package/components/Tabs/Tabs.js.map +1 -1
- package/components/Toggle/Toggle.classes.d.ts +8 -0
- package/components/Toggle/Toggle.classes.js +10 -0
- package/components/Toggle/Toggle.classes.js.map +1 -0
- package/components/Toggle/Toggle.d.ts +5 -0
- package/components/Toggle/Toggle.js +46 -22
- package/components/Toggle/Toggle.js.map +1 -1
- package/components/Toggle/Toggle.mixins.d.ts +2 -0
- package/components/Toggle/Toggle.mixins.js +7 -1
- package/components/Toggle/Toggle.mixins.js.map +1 -1
- package/components/Toggle/Toggle.styles.d.ts +11 -8
- package/components/Toggle/Toggle.styles.js +32 -11
- package/components/Toggle/Toggle.styles.js.map +1 -1
- package/components/Token/Token.d.ts +1 -1
- package/components/Token/Token.js +1 -1
- package/components/Token/Token.js.map +1 -1
- package/components/TokenInput/TokenInput.d.ts +8 -4
- package/components/TokenInput/TokenInput.js +1 -2
- package/components/TokenInput/TokenInput.js.map +1 -1
- package/components/Tooltip/Tooltip.d.ts +2 -0
- package/components/Tooltip/Tooltip.js +25 -4
- package/components/Tooltip/Tooltip.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/index.js.map +1 -1
- package/internal/Menu/Menu.d.ts +5 -0
- package/internal/Menu/Menu.js +21 -0
- package/internal/Menu/Menu.js.map +1 -1
- package/internal/Popup/PopupPin.js +8 -6
- package/internal/Popup/PopupPin.js.map +1 -1
- package/internal/themes/BasicTheme.d.ts +194 -35
- package/internal/themes/BasicTheme.js +326 -97
- package/internal/themes/BasicTheme.js.map +1 -1
- package/internal/themes/DarkTheme6_0.js +1 -0
- package/internal/themes/DarkTheme6_0.js.map +1 -1
- package/lib/date/InternalDateValidator.js +1 -2
- package/lib/date/InternalDateValidator.js.map +1 -1
- package/lib/events/keyListener.js +6 -0
- package/lib/events/keyListener.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 +1 -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 +2 -3
- package/lib/utils.js +7 -5
- 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,49 @@
|
|
|
1
|
+
var InputHistory = /** @class */ (function () {
|
|
2
|
+
function InputHistory() {
|
|
3
|
+
this.states = [];
|
|
4
|
+
this.currentIndex = 0;
|
|
5
|
+
}
|
|
6
|
+
Object.defineProperty(InputHistory.prototype, "currentState", {
|
|
7
|
+
get: function () {
|
|
8
|
+
return this.states[this.currentIndex];
|
|
9
|
+
},
|
|
10
|
+
enumerable: false,
|
|
11
|
+
configurable: true
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(InputHistory.prototype, "isEmpty", {
|
|
14
|
+
get: function () {
|
|
15
|
+
return this.states.length === 0;
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
InputHistory.prototype.push = function (state) {
|
|
21
|
+
// if current index points before the last element then remove the future
|
|
22
|
+
if (this.currentIndex < this.states.length - 1) {
|
|
23
|
+
this.states.length = this.currentIndex + 1;
|
|
24
|
+
}
|
|
25
|
+
this.states.push(state);
|
|
26
|
+
if (this.states.length > InputHistory.MAX_LENGTH) {
|
|
27
|
+
this.states.shift();
|
|
28
|
+
}
|
|
29
|
+
this.currentIndex = this.states.length - 1;
|
|
30
|
+
};
|
|
31
|
+
InputHistory.prototype.go = function (steps) {
|
|
32
|
+
this.currentIndex = Math.min(Math.max(this.currentIndex + steps, 0), this.states.length - 1);
|
|
33
|
+
return this.currentState;
|
|
34
|
+
};
|
|
35
|
+
InputHistory.prototype.undo = function () {
|
|
36
|
+
return this.go(-1);
|
|
37
|
+
};
|
|
38
|
+
InputHistory.prototype.redo = function () {
|
|
39
|
+
return this.go(+1);
|
|
40
|
+
};
|
|
41
|
+
InputHistory.prototype.clear = function () {
|
|
42
|
+
this.states.length = 0;
|
|
43
|
+
this.currentIndex = 0;
|
|
44
|
+
};
|
|
45
|
+
InputHistory.MAX_LENGTH = 100;
|
|
46
|
+
return InputHistory;
|
|
47
|
+
}());
|
|
48
|
+
export { InputHistory };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,GAAJ;QACE,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IAED,2BAAI,GAAJ;QACE,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IAED,4BAAK,GAAL;QACE,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;IACxB,CAAC;IAxCM,uBAAU,GAAG,GAAG,AAAN,CAAO;IAyC1B,mBAAC;CAAA,AA1CD,IA0CC;SA1CY,YAAY","sourcesContent":["import { type Selection } from '../core/utils.js';\n\nexport interface InputHistoryState {\n unmaskedValue: string;\n selection: Selection;\n}\n\nexport class InputHistory {\n static MAX_LENGTH = 100;\n states: InputHistoryState[] = [];\n currentIndex = 0;\n\n get currentState(): InputHistoryState | undefined {\n return this.states[this.currentIndex];\n }\n\n get isEmpty(): boolean {\n return this.states.length === 0;\n }\n\n push(state: InputHistoryState): void {\n // if current index points before the last element then remove the future\n if (this.currentIndex < this.states.length - 1) {\n this.states.length = this.currentIndex + 1;\n }\n this.states.push(state);\n if (this.states.length > InputHistory.MAX_LENGTH) {\n this.states.shift();\n }\n this.currentIndex = this.states.length - 1;\n }\n\n go(steps: number): InputHistoryState | undefined {\n this.currentIndex = Math.min(Math.max(this.currentIndex + steps, 0), this.states.length - 1);\n return this.currentState;\n }\n\n undo(): InputHistoryState | undefined {\n return this.go(-1);\n }\n\n redo(): InputHistoryState | undefined {\n return this.go(+1);\n }\n\n clear(): void {\n this.states.length = 0;\n this.currentIndex = 0;\n }\n}\n"]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type Selection } from '../core/utils.js';
|
|
2
|
+
import { type UpdateOpts, type FactoryArg, type FactoryReturnMasked } from '../masked/create.js';
|
|
3
|
+
import { type InputElement } from './html-input-mask-element.js';
|
|
4
|
+
import { InputHistory, type InputHistoryState } from './input-history.js';
|
|
5
|
+
import { MaskElement } from './mask-element.js';
|
|
6
|
+
export type InputMaskElement = MaskElement | InputElement | HTMLElement;
|
|
7
|
+
export type InputMaskEventListener = (e?: InputEvent) => void;
|
|
8
|
+
/** Listens to element events and controls changes between element and {@link Masked} */
|
|
9
|
+
export declare class InputMask<Opts extends FactoryArg = Record<string, unknown>> {
|
|
10
|
+
/**
|
|
11
|
+
View element. Set to null after destroy() to release the reference.
|
|
12
|
+
*/
|
|
13
|
+
el: MaskElement | null;
|
|
14
|
+
/** Internal {@link Masked} model */
|
|
15
|
+
masked: FactoryReturnMasked<Opts>;
|
|
16
|
+
_listeners: Record<string, InputMaskEventListener[]>;
|
|
17
|
+
_value: string;
|
|
18
|
+
_changingCursorPos: number;
|
|
19
|
+
_unmaskedValue: string;
|
|
20
|
+
_rawInputValue: string;
|
|
21
|
+
_selection: Selection;
|
|
22
|
+
_cursorChanging?: ReturnType<typeof setTimeout>;
|
|
23
|
+
_historyChanging?: boolean;
|
|
24
|
+
_inputEvent?: InputEvent;
|
|
25
|
+
history: InputHistory;
|
|
26
|
+
constructor(el: InputMaskElement, opts: Opts);
|
|
27
|
+
maskEquals(mask: unknown): boolean;
|
|
28
|
+
/** Masked */
|
|
29
|
+
get mask(): FactoryReturnMasked<Opts>['mask'];
|
|
30
|
+
set mask(mask: unknown);
|
|
31
|
+
/** Raw value */
|
|
32
|
+
get value(): string;
|
|
33
|
+
set value(str: string);
|
|
34
|
+
/** Unmasked value */
|
|
35
|
+
get unmaskedValue(): string;
|
|
36
|
+
set unmaskedValue(str: string);
|
|
37
|
+
/** Raw input value */
|
|
38
|
+
get rawInputValue(): string;
|
|
39
|
+
set rawInputValue(str: string);
|
|
40
|
+
/** Typed unmasked value */
|
|
41
|
+
get typedValue(): FactoryReturnMasked<Opts>['typedValue'];
|
|
42
|
+
set typedValue(val: FactoryReturnMasked<Opts>['typedValue']);
|
|
43
|
+
/** Display value */
|
|
44
|
+
get displayValue(): string;
|
|
45
|
+
/** Starts listening to element events */
|
|
46
|
+
_bindEvents(): void;
|
|
47
|
+
/** Stops listening to element events */
|
|
48
|
+
_unbindEvents(): void;
|
|
49
|
+
/** Fires custom event */
|
|
50
|
+
_fireEvent(ev: string, e?: InputEvent): void;
|
|
51
|
+
/** Current selection start */
|
|
52
|
+
get selectionStart(): number;
|
|
53
|
+
/** Current cursor position */
|
|
54
|
+
get cursorPos(): number;
|
|
55
|
+
set cursorPos(pos: number);
|
|
56
|
+
/** Stores current selection */
|
|
57
|
+
_saveSelection(): void;
|
|
58
|
+
/** Syncronizes model value from view */
|
|
59
|
+
updateValue(): void;
|
|
60
|
+
/** Syncronizes view from model value, fires change events */
|
|
61
|
+
updateControl(cursorPos?: number | 'auto'): void;
|
|
62
|
+
/** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */
|
|
63
|
+
updateOptions(opts: UpdateOpts<Opts>): void;
|
|
64
|
+
/** Updates cursor */
|
|
65
|
+
updateCursor(cursorPos: number): void;
|
|
66
|
+
/** Delays cursor update to support mobile browsers */
|
|
67
|
+
_delayUpdateCursor(cursorPos: number): void;
|
|
68
|
+
/** Fires custom events */
|
|
69
|
+
_fireChangeEvents(): void;
|
|
70
|
+
/** Aborts delayed cursor update */
|
|
71
|
+
_abortUpdateCursor(): void;
|
|
72
|
+
/** Aligns cursor to nearest available position */
|
|
73
|
+
alignCursor(): void;
|
|
74
|
+
/** Aligns cursor only if selection is empty */
|
|
75
|
+
alignCursorFriendly(): void;
|
|
76
|
+
/** Adds listener on custom event */
|
|
77
|
+
on(ev: string, handler: InputMaskEventListener): this;
|
|
78
|
+
/** Removes custom event listener */
|
|
79
|
+
off(ev: string, handler: InputMaskEventListener): this;
|
|
80
|
+
/** Handles view input event */
|
|
81
|
+
_onInput(e: InputEvent): void;
|
|
82
|
+
/** Handles view change event and commits model value */
|
|
83
|
+
_onChange(): void;
|
|
84
|
+
/** Handles view drop event, prevents by default */
|
|
85
|
+
_onDrop(ev: Event): void;
|
|
86
|
+
/** Restore last selection on focus */
|
|
87
|
+
_onFocus(): void;
|
|
88
|
+
/** Restore last selection on focus */
|
|
89
|
+
_onClick(): void;
|
|
90
|
+
_onUndo(): void;
|
|
91
|
+
_onRedo(): void;
|
|
92
|
+
_applyHistoryState(state: InputHistoryState | undefined): void;
|
|
93
|
+
/** Unbind view events and removes element reference */
|
|
94
|
+
destroy(): void;
|
|
95
|
+
}
|
|
@@ -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/create.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,qBAAqB,CAAC;AAC7B,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,CA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AAC;IAED,sCAAkB,GAAlB,UAAmB,KAAoC;QACrD,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,iFAAiF;QACjF,oFAAoF;QACpF,gFAAgF;QAChF,IAAI,CAAC,WAAW,GAAG,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QACjF,IAAI,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/create.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
|
+
}
|