@skbkontur/react-ui 6.1.4 → 6.1.6-00fed.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 +11 -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/FileUploader/FileUploaderFile.d.ts +1 -1
- package/components/FileUploader/FileUploaderFile.js +1 -1
- package/components/FileUploader/FileUploaderFile.js.map +1 -1
- package/components/FxInput/FxInput.d.ts +1 -1
- package/components/FxInput/FxInput.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/components/MaskedInputV2/MaskedInputV2.styles.d.ts +7 -0
- 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 +2 -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/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.mixins.js +1 -1
- package/components/Toggle/Toggle.mixins.js.map +1 -1
- package/components/Toggle/Toggle.styles.d.ts +2 -8
- package/components/Toggle/Toggle.styles.js +3 -9
- 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 +1 -1
- package/components/TokenInput/TokenInput.js +1 -1
- package/components/TokenInput/TokenInput.js.map +1 -1
- package/lib/date/InternalDateValidator.js +1 -2
- package/lib/date/InternalDateValidator.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/package.json +4 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maskedCoreInputChange.js","sourceRoot":"","sources":["maskedCoreInputChange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AA6B/D,IAAM,YAAY,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAW,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAA+B;IAC5D,IAAA,YAAY,GAA8D,MAAM,aAApE,EAAE,SAAS,GAAmD,MAAM,UAAzD,EAAE,UAAU,GAAuC,MAAM,WAA7C,EAAE,UAAU,GAA2B,MAAM,WAAjC,EAAE,YAAY,GAAa,MAAM,aAAnB,EAAE,MAAM,GAAK,MAAM,OAAX,CAAY;IACjF,IAAA,KAAK,GAAK,MAAM,MAAX,CAAY;IAEzB,IAAM,OAAO,GAAG,IAAI,aAAa,CAAC;QAChC,KAAK,EAAE,YAAY;QACnB,SAAS,WAAA;QACT,QAAQ,EAAE,UAAU;QACpB,YAAY,cAAA;KACb,CAAC,CAAC;IAEH,IAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC;IAC/B,IAAM,WAAW,GAAG,K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AAS,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;IAED,OAAO;QACL,MAAM,QAAA;QACN,SAAS,EAAE,YAAY;QACvB,QAAQ,EAAE,MAAM,KAAK,UAAU;KAChC,CAAC;AACJ,CAAC","sourcesContent":["import { ActionDetails } from '../react-imask/imask/core/action-details.js';\nimport { DIRECTION } from '../react-imask/imask/core/utils.js';\nimport type { MaskEngine } from './types.js';\n\n/** Параметры обработки нативного `change` от `<input>`. */\nexport interface MaskedInputChangeParams {\n /** Черновик value, который браузер записал в input. */\n browserDraft: string;\n /** Позиция курсора после изменения. */\n cursorPos: number;\n /** Текущее typedValue из MaskState. */\n typedValue: string;\n /** Текущее raw-значение (источник истины). */\n currentRaw: string;\n /** Предыдущее выделение до изменения. */\n oldSelection: { start: number; end: number };\n /** IMask-движок. */\n engine: Pick<MaskEngine, 'imask'>;\n}\n\n/** Результат применения пользовательского ввода через IMask. */\nexport interface MaskedInputChangeResult {\n /** Новое raw после splice. */\n newRaw: string;\n /** Позиция курсора, которую нужно установить. */\n cursorPos: number;\n /** `true`, если символ не был принят (raw не изменился). */\n rejected: boolean;\n}\n\nconst SPLICE_FLAGS = { input: true, raw: true } as const;\n\n/**\n * Применяет пользовательский ввод к IMask через `splice` и вычисляет новый raw с позицией курсора.\n *\n * Если вставка совпала с литералом маски (`7` в `7 999`) и raw не изменился,\n * повторяет splice в ближайшем input-слоте справа.\n *\n * @param params — состояние input до/после изменения.\n * @returns новое raw, позицию курсора и флаг отклонённого ввода.\n */\nexport function applyMaskedInputChange(params: MaskedInputChangeParams): MaskedInputChangeResult {\n const { browserDraft, cursorPos, typedValue, currentRaw, oldSelection, engine } = params;\n const { imask } = engine;\n\n const details = new ActionDetails({\n value: browserDraft,\n cursorPos,\n oldValue: typedValue,\n oldSelection,\n });\n\n const savedState = imask.state;\n const oldRawValue = imask.unmaskedValue;\n let spliceStart = details.startChangePos;\n\n let spliceResult = imask.splice(\n spliceStart,\n details.removed.length,\n details.inserted,\n details.removeDirection,\n SPLICE_FLAGS,\n );\n\n let newRaw = imask.rawInputValue;\n\n // Литерал вроде ведущей `7` в `7 999` может поглотить кейстрек без изменения raw.\n // Тогда пробуем вставить тот же символ в ближайший input-слот справа.\n if (newRaw === currentRaw && details.inserted.length === 1 && details.removed.length === 0) {\n imask.state = savedState;\n const inputPos = imask.nearestInputPos(details.startChangePos, DIRECTION.RIGHT);\n if (inputPos !== details.startChangePos) {\n spliceStart = inputPos;\n spliceResult = imask.splice(inputPos, 0, details.inserted, details.removeDirection, SPLICE_FLAGS);\n newRaw = imask.rawInputValue;\n }\n }\n\n const removeDirection = oldRawValue === imask.unmaskedValue ? details.removeDirection : DIRECTION.NONE;\n\n let newCursorPos = imask.nearestInputPos(spliceStart + spliceResult.offset, removeDirection);\n if (removeDirection !== DIRECTION.NONE) {\n newCursorPos = imask.nearestInputPos(newCursorPos, DIRECTION.NONE);\n }\n\n return {\n newRaw,\n cursorPos: newCursorPos,\n rejected: newRaw === currentRaw,\n };\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
type SelectionDirection = 'forward' | 'backward' | 'none';
|
|
3
|
+
/**
|
|
4
|
+
* Вычисляет новое выделение при навигации стрелками, Home/End и Ctrl/Alt+стрелками.
|
|
5
|
+
* Логика перенесена из FixedIMaskInput v1.
|
|
6
|
+
*
|
|
7
|
+
* @param e — keyboard event.
|
|
8
|
+
* @param maxPos — максимальная позиция курсора (typedLength).
|
|
9
|
+
* @param el — DOM input с текущим selection.
|
|
10
|
+
* @returns кортеж `[start, end, direction]` для `setSelectionRange`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function calcNavigationSelection(e: React.KeyboardEvent<HTMLInputElement>, maxPos: number, el: HTMLInputElement | null): [number, number, SelectionDirection];
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { isKeyArrowHorizontal, isKeyArrowLeft, isKeyArrowUp, isKeyHome, isModShift, isShortcutJumpCaret, someKeys, } from '../../../lib/events/keyboard/identifiers.js';
|
|
11
|
+
/**
|
|
12
|
+
* Вычисляет новое выделение при навигации стрелками, Home/End и Ctrl/Alt+стрелками.
|
|
13
|
+
* Логика перенесена из FixedIMaskInput v1.
|
|
14
|
+
*
|
|
15
|
+
* @param e — keyboard event.
|
|
16
|
+
* @param maxPos — максимальная позиция курсора (typedLength).
|
|
17
|
+
* @param el — DOM input с текущим selection.
|
|
18
|
+
* @returns кортеж `[start, end, direction]` для `setSelectionRange`.
|
|
19
|
+
*/
|
|
20
|
+
export function calcNavigationSelection(e, maxPos, el) {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
if (!el) {
|
|
23
|
+
return [0, 0, 'none'];
|
|
24
|
+
}
|
|
25
|
+
var start = (_a = el.selectionStart) !== null && _a !== void 0 ? _a : 0;
|
|
26
|
+
var end = (_b = el.selectionEnd) !== null && _b !== void 0 ? _b : 0;
|
|
27
|
+
var direction = ((_c = el.selectionDirection) !== null && _c !== void 0 ? _c : 'none');
|
|
28
|
+
var isSelectionMode = isModShift()(e);
|
|
29
|
+
var tail = start !== end && direction === 'backward' ? end : start;
|
|
30
|
+
var head = start !== end && direction === 'backward' ? start : end;
|
|
31
|
+
var headDirection = someKeys(isKeyArrowLeft, isKeyArrowUp, isKeyHome)(e) ? 'left' : 'right';
|
|
32
|
+
var step = isKeyArrowHorizontal(e) ? 1 : Infinity;
|
|
33
|
+
var increment = headDirection === 'left' ? -step : step;
|
|
34
|
+
var normalized = function (v) { return Math.min(maxPos, Math.max(0, v)); };
|
|
35
|
+
if (isShortcutJumpCaret(e)) {
|
|
36
|
+
head = jumpCaret(head, headDirection, el.value, maxPos);
|
|
37
|
+
}
|
|
38
|
+
else if (head !== tail && !isSelectionMode && isKeyArrowHorizontal(e)) {
|
|
39
|
+
head = headDirection === 'right' ? Math.max(tail, head) : Math.min(tail, head);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
head = head + increment;
|
|
43
|
+
}
|
|
44
|
+
if (isSelectionMode) {
|
|
45
|
+
var s = Math.min(tail, head);
|
|
46
|
+
var e2 = Math.max(tail, head);
|
|
47
|
+
return [normalized(s), normalized(e2), e2 === head ? 'forward' : 'backward'];
|
|
48
|
+
}
|
|
49
|
+
tail = head;
|
|
50
|
+
return [normalized(tail), normalized(head), 'none'];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Перемещает курсор к началу/концу следующего «слова» при Ctrl/Alt+стрелка.
|
|
54
|
+
*
|
|
55
|
+
* @param prev — текущая позиция курсора.
|
|
56
|
+
* @param headDirection — направление прыжка.
|
|
57
|
+
* @param value — текущее value input.
|
|
58
|
+
* @param maxPos — верхняя граница позиции курсора.
|
|
59
|
+
*/
|
|
60
|
+
function jumpCaret(prev, headDirection, value, maxPos) {
|
|
61
|
+
var _a;
|
|
62
|
+
// CODE-1 fix: используем .source вместо .valueOf() — иначе "/" попадает в символы слова
|
|
63
|
+
var word = /а-яa-z0-9_/.source;
|
|
64
|
+
var wordRegExp = new RegExp("([".concat(word, "])+[\\s]*|([^").concat(word, "])+"), 'gi');
|
|
65
|
+
var normalized = function (v) { return Math.min(maxPos, Math.max(0, v)); };
|
|
66
|
+
var next = headDirection === 'right' ? prev : 0;
|
|
67
|
+
(_a = value.match(wordRegExp)) === null || _a === void 0 ? void 0 : _a.reduce(function (s, a) {
|
|
68
|
+
var pos = a.length + (s.slice(-1)[0] || 0);
|
|
69
|
+
if (headDirection === 'right' && next === prev && next < pos) {
|
|
70
|
+
next = normalized(pos);
|
|
71
|
+
}
|
|
72
|
+
else if (headDirection === 'left' && prev > pos) {
|
|
73
|
+
next = normalized(pos);
|
|
74
|
+
}
|
|
75
|
+
return __spreadArray(__spreadArray([], s, true), [pos], false);
|
|
76
|
+
}, []);
|
|
77
|
+
return next;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=maskedCoreNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maskedCoreNavigation.js","sourceRoot":"","sources":["maskedCoreNavigation.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,QAAQ,GACT,MAAM,6CAA6C,CAAC;AAKrD;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CACrC,CAAwC,EACxC,MAAc,EACd,EAA2B;;IAE3B,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC;IAED,IAAM,KAAK,GAAG,MAAA,EAAE,CAAC,cAAc,mCAAI,CAAC,CAAC;IACrC,IAAM,GAAG,GAAG,MAAA,EAAE,CAAC,YAAY,mCAAI,CAAC,CAAC;IACjC,IAAM,SAAS,GAAG,CAAC,MAAA,EAAE,CAAC,kBAAkB,mCAAI,MAAM,CAAuB,CAAC;IAE1E,IAAM,eAAe,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;IACxC,IAAI,IAAI,GAAG,KAAK,KAAK,GAAG,IAAI,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,IAAI,IAAI,GAAG,KAAK,KAAK,GAAG,IAAI,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IAEnE,IAAM,aAAa,GAAkB,QAAQ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CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;QACD,uCAAW,CAAC,UAAE,GAAG,UAAE;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type React from 'react';\n\nimport {\n isKeyArrowHorizontal,\n isKeyArrowLeft,\n isKeyArrowUp,\n isKeyHome,\n isModShift,\n isShortcutJumpCaret,\n someKeys,\n} from '../../../lib/events/keyboard/identifiers.js';\n\ntype HeadDirection = 'left' | 'right';\ntype SelectionDirection = 'forward' | 'backward' | 'none';\n\n/**\n * Вычисляет новое выделение при навигации стрелками, Home/End и Ctrl/Alt+стрелками.\n * Логика перенесена из FixedIMaskInput v1.\n *\n * @param e — keyboard event.\n * @param maxPos — максимальная позиция курсора (typedLength).\n * @param el — DOM input с текущим selection.\n * @returns кортеж `[start, end, direction]` для `setSelectionRange`.\n */\nexport function calcNavigationSelection(\n e: React.KeyboardEvent<HTMLInputElement>,\n maxPos: number,\n el: HTMLInputElement | null,\n): [number, number, SelectionDirection] {\n if (!el) {\n return [0, 0, 'none'];\n }\n\n const start = el.selectionStart ?? 0;\n const end = el.selectionEnd ?? 0;\n const direction = (el.selectionDirection ?? 'none') as SelectionDirection;\n\n const isSelectionMode = isModShift()(e);\n let tail = start !== end && direction === 'backward' ? end : start;\n let head = start !== end && direction === 'backward' ? start : end;\n\n const headDirection: HeadDirection = someKeys(isKeyArrowLeft, isKeyArrowUp, isKeyHome)(e) ? 'left' : 'right';\n const step = isKeyArrowHorizontal(e) ? 1 : Infinity;\n const increment = headDirection === 'left' ? -step : step;\n\n const normalized = (v: number) => Math.min(maxPos, Math.max(0, v));\n\n if (isShortcutJumpCaret(e)) {\n head = jumpCaret(head, headDirection, el.value, maxPos);\n } else if (head !== tail && !isSelectionMode && isKeyArrowHorizontal(e)) {\n head = headDirection === 'right' ? Math.max(tail, head) : Math.min(tail, head);\n } else {\n head = head + increment;\n }\n\n if (isSelectionMode) {\n const s = Math.min(tail, head);\n const e2 = Math.max(tail, head);\n return [normalized(s), normalized(e2), e2 === head ? 'forward' : 'backward'];\n }\n\n tail = head;\n return [normalized(tail), normalized(head), 'none'];\n}\n\n/**\n * Перемещает курсор к началу/концу следующего «слова» при Ctrl/Alt+стрелка.\n *\n * @param prev — текущая позиция курсора.\n * @param headDirection — направление прыжка.\n * @param value — текущее value input.\n * @param maxPos — верхняя граница позиции курсора.\n */\nfunction jumpCaret(prev: number, headDirection: HeadDirection, value: string, maxPos: number): number {\n // CODE-1 fix: используем .source вместо .valueOf() — иначе \"/\" попадает в символы слова\n const word = /а-яa-z0-9_/.source;\n const wordRegExp = new RegExp(`([${word}])+[\\\\s]*|([^${word}])+`, 'gi');\n const normalized = (v: number) => Math.min(maxPos, Math.max(0, v));\n\n let next = headDirection === 'right' ? prev : 0;\n value.match(wordRegExp)?.reduce<number[]>((s, a) => {\n const pos = a.length + (s.slice(-1)[0] || 0);\n if (headDirection === 'right' && next === prev && next < pos) {\n next = normalized(pos);\n } else if (headDirection === 'left' && prev > pos) {\n next = normalized(pos);\n }\n return [...s, pos];\n }, []);\n\n return next;\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getOwnerGlobalObject, isBrowser } from '../../../lib/globalObject.js';
|
|
2
|
+
/** Ширина текста в стиле input (для overflow и center/right align). */
|
|
3
|
+
export function measureInputTextWidth(input, text) {
|
|
4
|
+
if (!text) {
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
var globalObject = getOwnerGlobalObject(input);
|
|
8
|
+
if (!isBrowser(globalObject)) {
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
11
|
+
var style = globalObject.getComputedStyle(input);
|
|
12
|
+
var probe = globalObject.document.createElement('span');
|
|
13
|
+
probe.textContent = text;
|
|
14
|
+
probe.style.cssText = [
|
|
15
|
+
'position:absolute',
|
|
16
|
+
'visibility:hidden',
|
|
17
|
+
'white-space:pre',
|
|
18
|
+
'pointer-events:none',
|
|
19
|
+
"font:".concat(style.font),
|
|
20
|
+
"letter-spacing:".concat(style.letterSpacing),
|
|
21
|
+
"text-transform:".concat(style.textTransform),
|
|
22
|
+
"font-variant-numeric:".concat(style.fontVariantNumeric),
|
|
23
|
+
"font-feature-settings:".concat(style.fontFeatureSettings),
|
|
24
|
+
].join(';');
|
|
25
|
+
globalObject.document.body.appendChild(probe);
|
|
26
|
+
var width = probe.getBoundingClientRect().width;
|
|
27
|
+
probe.remove();
|
|
28
|
+
return width;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=measureInputTextWidth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measureInputTextWidth.js","sourceRoot":"","sources":["measureInputTextWidth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE/E,uEAAuE;AACvE,MAAM,UAAU,qBAAqB,CAAC,KAAuB,EAAE,IAAY;IACzE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAM,YAAY,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACjD,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAM,KAAK,GAAG,YAAY,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACnD,IAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1D,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG;QACpB,mBAAmB;QACnB,mBAAmB;QACnB,iBAAiB;QACjB,qBAAqB;QACrB,eAAQ,KAAK,CAAC,IAAI,CAAE;QACpB,yBAAkB,KAAK,CAAC,aAAa,CAAE;QACvC,yBAAkB,KAAK,CAAC,aAAa,CAAE;QACvC,+BAAwB,KAAK,CAAC,kBAAkB,CAAE;QAClD,gCAAyB,KAAK,CAAC,mBAAmB,CAAE;KACrD,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACZ,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAE9C,IAAM,KAAK,GAAG,KAAK,CAAC,qBAAqB,EAAE,CAAC,KAAK,CAAC;IAClD,KAAK,CAAC,MAAM,EAAE,CAAC;IAEf,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { getOwnerGlobalObject, isBrowser } from '../../../lib/globalObject.js';\n\n/** Ширина текста в стиле input (для overflow и center/right align). */\nexport function measureInputTextWidth(input: HTMLInputElement, text: string): number {\n if (!text) {\n return 0;\n }\n\n const globalObject = getOwnerGlobalObject(input);\n if (!isBrowser(globalObject)) {\n return 0;\n }\n\n const style = globalObject.getComputedStyle(input);\n const probe = globalObject.document.createElement('span');\n probe.textContent = text;\n probe.style.cssText = [\n 'position:absolute',\n 'visibility:hidden',\n 'white-space:pre',\n 'pointer-events:none',\n `font:${style.font}`,\n `letter-spacing:${style.letterSpacing}`,\n `text-transform:${style.textTransform}`,\n `font-variant-numeric:${style.fontVariantNumeric}`,\n `font-feature-settings:${style.fontFeatureSettings}`,\n ].join(';');\n globalObject.document.body.appendChild(probe);\n\n const width = probe.getBoundingClientRect().width;\n probe.remove();\n\n return width;\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { selectionAllowedTypes } from '../../Input/Input.js';
|
|
2
|
+
function normalizeInputType(type) {
|
|
3
|
+
return type.trim();
|
|
4
|
+
}
|
|
5
|
+
export function isMaskInputSelectionAllowed(input) {
|
|
6
|
+
return selectionAllowedTypes.includes(normalizeInputType(input.type || 'text'));
|
|
7
|
+
}
|
|
8
|
+
export function setMaskInputSelectionRange(input, start, end, direction) {
|
|
9
|
+
if (end === void 0) { end = start; }
|
|
10
|
+
if (!input || !isMaskInputSelectionAllowed(input)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
if (direction) {
|
|
15
|
+
input.setSelectionRange(start, end, direction);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
input.setSelectionRange(start, end);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (_a) {
|
|
22
|
+
// InvalidStateError для input-типов без selection API
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=setMaskInputSelectionRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setMaskInputSelectionRange.js","sourceRoot":"","sources":["setMaskInputSelectionRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAkB,MAAM,sBAAsB,CAAC;AAE7E,SAAS,kBAAkB,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,IAAI,EAAe,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,KAAuB;IACjE,OAAO,qBAAqB,CAAC,QAAQ,CAAC,kBAAkB,CAAC,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,KAA0C,EAC1C,KAAa,EACb,GAAmB,EACnB,SAA2C;IAD3C,oBAAA,EAAA,WAAmB;IAGnB,IAAI,CAAC,KAAK,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,IAAI,SAAS,EAAE,CAAC;YACd,KAAK,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAAC,WAAM,CAAC;QACP,sDAAsD;IACxD,CAAC;AACH,CAAC","sourcesContent":["import { selectionAllowedTypes, type InputType } from '../../Input/Input.js';\n\nfunction normalizeInputType(type: string): InputType {\n return type.trim() as InputType;\n}\n\nexport function isMaskInputSelectionAllowed(input: HTMLInputElement): boolean {\n return selectionAllowedTypes.includes(normalizeInputType(input.type || 'text'));\n}\n\nexport function setMaskInputSelectionRange(\n input: HTMLInputElement | null | undefined,\n start: number,\n end: number = start,\n direction?: 'forward' | 'backward' | 'none',\n): void {\n if (!input || !isMaskInputSelectionAllowed(input)) {\n return;\n }\n\n try {\n if (direction) {\n input.setSelectionRange(start, end, direction);\n } else {\n input.setSelectionRange(start, end);\n }\n } catch {\n // InvalidStateError для input-типов без selection API\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function hasMaskPart(maskState) {
|
|
2
|
+
return maskState.displayValue.length > maskState.typedValue.length;
|
|
3
|
+
}
|
|
4
|
+
export function getShowOverlay(maskState, focused, overflows) {
|
|
5
|
+
if (overflows === void 0) { overflows = false; }
|
|
6
|
+
if (overflows) {
|
|
7
|
+
// При переполнении скрываем overlay только для полностью введённого значения:
|
|
8
|
+
// иначе overlay не совпадает с прокруткой input. Декоративная часть маски
|
|
9
|
+
// (плейсхолдеры) всегда рисуется через overlay, а не через value input.
|
|
10
|
+
return hasMaskPart(maskState);
|
|
11
|
+
}
|
|
12
|
+
// Полностью введённое значение (без декоративной части маски) рисуем нативным
|
|
13
|
+
// текстом input — иначе overlay с overflow:hidden обрезает конец при горизонтальном скролле.
|
|
14
|
+
return hasMaskPart(maskState);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=showOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"showOverlay.js","sourceRoot":"","sources":["showOverlay.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,WAAW,CAAC,SAAoB;IAC9C,OAAO,SAAS,CAAC,YAAY,CAAC,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,SAAoB,EAAE,OAAgB,EAAE,SAAiB;IAAjB,0BAAA,EAAA,iBAAiB;IACtF,IAAI,SAAS,EAAE,CAAC;QACd,8EAA8E;QAC9E,0EAA0E;QAC1E,wEAAwE;QACxE,OAAO,WAAW,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,8EAA8E;IAC9E,6FAA6F;IAC7F,OAAO,WAAW,CAAC,SAAS,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import type { MaskState } from './types.js';\n\nexport function hasMaskPart(maskState: MaskState): boolean {\n return maskState.displayValue.length > maskState.typedValue.length;\n}\n\nexport function getShowOverlay(maskState: MaskState, focused: boolean, overflows = false): boolean {\n if (overflows) {\n // При переполнении скрываем overlay только для полностью введённого значения:\n // иначе overlay не совпадает с прокруткой input. Декоративная часть маски\n // (плейсхолдеры) всегда рисуется через overlay, а не через value input.\n return hasMaskPart(maskState);\n }\n\n // Полностью введённое значение (без декоративной части маски) рисуем нативным\n // текстом input — иначе overlay с overflow:hidden обрезает конец при горизонтальном скролле.\n return hasMaskPart(maskState);\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SlotMap } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Из выделенного диапазона displayValue убирает фиксированные символы маски,
|
|
4
|
+
* оставляя только пользовательские символы.
|
|
5
|
+
*
|
|
6
|
+
* @param selected — подстрока displayValue.
|
|
7
|
+
* @param slotMap — карта соответствия позиций маски и raw-слотов.
|
|
8
|
+
* @param startOffset — позиция начала выделения в displayValue.
|
|
9
|
+
* @returns строка без литералов маски.
|
|
10
|
+
*/
|
|
11
|
+
export declare function stripMaskChars(selected: string, slotMap: SlotMap, startOffset: number): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Из выделенного диапазона displayValue убирает фиксированные символы маски,
|
|
3
|
+
* оставляя только пользовательские символы.
|
|
4
|
+
*
|
|
5
|
+
* @param selected — подстрока displayValue.
|
|
6
|
+
* @param slotMap — карта соответствия позиций маски и raw-слотов.
|
|
7
|
+
* @param startOffset — позиция начала выделения в displayValue.
|
|
8
|
+
* @returns строка без литералов маски.
|
|
9
|
+
*/
|
|
10
|
+
export function stripMaskChars(selected, slotMap, startOffset) {
|
|
11
|
+
var result = '';
|
|
12
|
+
for (var i = 0; i < selected.length; i++) {
|
|
13
|
+
var maskedPos = startOffset + i;
|
|
14
|
+
if (slotMap.maskedToRaw[maskedPos] !== null && slotMap.maskedToRaw[maskedPos] !== undefined) {
|
|
15
|
+
result += selected[i];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=stripMaskChars.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripMaskChars.js","sourceRoot":"","sources":["stripMaskChars.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB,EAAE,OAAgB,EAAE,WAAmB;IACpF,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,IAAM,SAAS,GAAG,WAAW,GAAG,CAAC,CAAC;QAClC,IAAI,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;YAC5F,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { SlotMap } from './types.js';\n\n/**\n * Из выделенного диапазона displayValue убирает фиксированные символы маски,\n * оставляя только пользовательские символы.\n *\n * @param selected — подстрока displayValue.\n * @param slotMap — карта соответствия позиций маски и raw-слотов.\n * @param startOffset — позиция начала выделения в displayValue.\n * @returns строка без литералов маски.\n */\nexport function stripMaskChars(selected: string, slotMap: SlotMap, startOffset: number): string {\n let result = '';\n for (let i = 0; i < selected.length; i++) {\n const maskedPos = startOffset + i;\n if (slotMap.maskedToRaw[maskedPos] !== null && slotMap.maskedToRaw[maskedPos] !== undefined) {\n result += selected[i];\n }\n }\n return result;\n}\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { MaskedPattern } from '../react-imask/imask/index.js';
|
|
2
|
+
export interface MaskEngine {
|
|
3
|
+
compute(raw: string, focused: boolean): MaskState;
|
|
4
|
+
applyPaste(currentRaw: string, rawCursorPos: number, pasted: string): PasteResult;
|
|
5
|
+
slotMap: SlotMap;
|
|
6
|
+
imask: MaskedPattern;
|
|
7
|
+
}
|
|
8
|
+
export interface PasteResult {
|
|
9
|
+
raw: string;
|
|
10
|
+
overflow: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface MaskState {
|
|
13
|
+
/**
|
|
14
|
+
* Значение для <input value=...>.
|
|
15
|
+
* focused=true, alwaysShowMask=false: "12__" (с плейсхолдерами)
|
|
16
|
+
* focused=false, alwaysShowMask=false: "12" (lazy, без плейсхолдеров)
|
|
17
|
+
* alwaysShowMask=true: "12__" всегда
|
|
18
|
+
*/
|
|
19
|
+
displayValue: string;
|
|
20
|
+
/**
|
|
21
|
+
* Подстрока displayValue от начала до конца последнего введённого символа
|
|
22
|
+
* (включая разделители маски внутри введённой части).
|
|
23
|
+
*
|
|
24
|
+
* mask="99.99", typed="12": displayValue="12.34" (нет — мы в данном примере typed="1234")
|
|
25
|
+
* mask="99.99", typed="12": displayValue="12.__", typedValue="12." ^^^
|
|
26
|
+
*/
|
|
27
|
+
typedValue: string;
|
|
28
|
+
/**
|
|
29
|
+
* Длина typedValue в символах.
|
|
30
|
+
* typedValue="12." → typedLength=3
|
|
31
|
+
*/
|
|
32
|
+
typedLength: number;
|
|
33
|
+
/**
|
|
34
|
+
* Значение для onValueChange.
|
|
35
|
+
* unmask=false: imask.value ("12.")
|
|
36
|
+
* unmask=true: imask.unmaskedValue ("12")
|
|
37
|
+
*/
|
|
38
|
+
outputValue: string;
|
|
39
|
+
/**
|
|
40
|
+
* Маска заполнена полностью.
|
|
41
|
+
*/
|
|
42
|
+
isComplete: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Количество принятых IMask пользовательских символов.
|
|
45
|
+
* raw="12345" для mask="999" → acceptedLength=3 ("123").
|
|
46
|
+
*/
|
|
47
|
+
acceptedLength: number;
|
|
48
|
+
}
|
|
49
|
+
export interface HistoryState {
|
|
50
|
+
raw: string;
|
|
51
|
+
cursorPos: number;
|
|
52
|
+
}
|
|
53
|
+
export interface SlotMap {
|
|
54
|
+
/**
|
|
55
|
+
* Позиции пользовательских слотов в displayValue (при lazy=false, все плейсхолдеры видны).
|
|
56
|
+
* mask="99.99" → userSlots=[0, 1, 3, 4]
|
|
57
|
+
* displayValue="_._._" (пустое поле, alwaysShowMask)
|
|
58
|
+
*/
|
|
59
|
+
userSlots: number[];
|
|
60
|
+
/**
|
|
61
|
+
* maskedToRaw[maskedPos] → rawPos | null
|
|
62
|
+
* null означает: позиция принадлежит фиксированному символу маски.
|
|
63
|
+
*
|
|
64
|
+
* mask="99.99": displayValue="_._._"
|
|
65
|
+
* maskedToRaw = [0, 1, null, 2, 3]
|
|
66
|
+
*/
|
|
67
|
+
maskedToRaw: Array<number | null>;
|
|
68
|
+
/**
|
|
69
|
+
* rawToMasked[rawPos] → maskedPos
|
|
70
|
+
* Обратный maskedToRaw, только для пользовательских позиций.
|
|
71
|
+
* mask="99.99": rawToMasked = [0, 1, 3, 4]
|
|
72
|
+
*/
|
|
73
|
+
rawToMasked: number[];
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import type { MaskedPattern } from '../react-imask/imask/index.js';\n\nexport interface MaskEngine {\n compute(raw: string, focused: boolean): MaskState;\n applyPaste(currentRaw: string, rawCursorPos: number, pasted: string): PasteResult;\n slotMap: SlotMap;\n imask: MaskedPattern;\n}\n\nexport interface PasteResult {\n raw: string;\n overflow: boolean;\n}\n\nexport interface MaskState {\n /**\n * Значение для <input value=...>.\n * focused=true, alwaysShowMask=false: \"12__\" (с плейсхолдерами)\n * focused=false, alwaysShowMask=false: \"12\" (lazy, без плейсхолдеров)\n * alwaysShowMask=true: \"12__\" всегда\n */\n displayValue: string;\n\n /**\n * Подстрока displayValue от начала до конца последнего введённого символа\n * (включая разделители маски внутри введённой части).\n *\n * mask=\"99.99\", typed=\"12\": displayValue=\"12.34\" (нет — мы в данном примере typed=\"1234\")\n * mask=\"99.99\", typed=\"12\": displayValue=\"12.__\", typedValue=\"12.\" ^^^\n */\n typedValue: string;\n\n /**\n * Длина typedValue в символах.\n * typedValue=\"12.\" → typedLength=3\n */\n typedLength: number;\n\n /**\n * Значение для onValueChange.\n * unmask=false: imask.value (\"12.\")\n * unmask=true: imask.unmaskedValue (\"12\")\n */\n outputValue: string;\n\n /**\n * Маска заполнена полностью.\n */\n isComplete: boolean;\n\n /**\n * Количество принятых IMask пользовательских символов.\n * raw=\"12345\" для mask=\"999\" → acceptedLength=3 (\"123\").\n */\n acceptedLength: number;\n}\n\nexport interface HistoryState {\n raw: string;\n cursorPos: number;\n}\n\nexport interface SlotMap {\n /**\n * Позиции пользовательских слотов в displayValue (при lazy=false, все плейсхолдеры видны).\n * mask=\"99.99\" → userSlots=[0, 1, 3, 4]\n * displayValue=\"_._._\" (пустое поле, alwaysShowMask)\n */\n userSlots: number[];\n\n /**\n * maskedToRaw[maskedPos] → rawPos | null\n * null означает: позиция принадлежит фиксированному символу маски.\n *\n * mask=\"99.99\": displayValue=\"_._._\"\n * maskedToRaw = [0, 1, null, 2, 3]\n */\n maskedToRaw: Array<number | null>;\n\n /**\n * rawToMasked[rawPos] → maskedPos\n * Обратный maskedToRaw, только для пользовательских позиций.\n * mask=\"99.99\": rawToMasked = [0, 1, 3, 4]\n */\n rawToMasked: number[];\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export declare function isInputTextOverflowing(input: HTMLInputElement, displayValue: string): boolean;
|
|
3
|
+
/** Горизонтальное переполнение текста внутри input. */
|
|
4
|
+
export declare function useInputOverflow(inputRef: React.RefObject<HTMLInputElement | null>, displayValue: string, remeasureKey: unknown): boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { measureInputTextWidth } from './measureInputTextWidth.js';
|
|
3
|
+
export function isInputTextOverflowing(input, displayValue) {
|
|
4
|
+
if (input.scrollWidth > input.clientWidth) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
var text = input.value || displayValue;
|
|
8
|
+
return measureInputTextWidth(input, text) > input.clientWidth;
|
|
9
|
+
}
|
|
10
|
+
/** Горизонтальное переполнение текста внутри input. */
|
|
11
|
+
export function useInputOverflow(inputRef, displayValue, remeasureKey) {
|
|
12
|
+
var _a = useState(false), overflow = _a[0], setOverflow = _a[1];
|
|
13
|
+
useLayoutEffect(function () {
|
|
14
|
+
var input = inputRef.current;
|
|
15
|
+
if (!input) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
var measure = function () {
|
|
19
|
+
setOverflow(function (prev) {
|
|
20
|
+
var next = isInputTextOverflowing(input, displayValue);
|
|
21
|
+
return prev === next ? prev : next;
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
measure();
|
|
25
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
var observer = new ResizeObserver(measure);
|
|
29
|
+
observer.observe(input);
|
|
30
|
+
return function () { return observer.disconnect(); };
|
|
31
|
+
}, [displayValue, inputRef, remeasureKey]);
|
|
32
|
+
return overflow;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingUR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AC,CAAC;QAC7C,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAExB,OAAO,cAAM,OAAA,QAAQ,CAAC,UAAU,EAAE,EAArB,CAAqB,CAAC;IACrC,CAAC,EAAE,CAAC,YAAY,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IAE3C,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type React from 'react';\nimport { useLayoutEffect, useState } from 'react';\n\nimport { measureInputTextWidth } from './measureInputTextWidth.js';\n\nexport function isInputTextOverflowing(input: HTMLInputElement, displayValue: string): boolean {\n if (input.scrollWidth > input.clientWidth) {\n return true;\n }\n\n const text = input.value || displayValue;\n return measureInputTextWidth(input, text) > input.clientWidth;\n}\n\n/** Горизонтальное переполнение текста внутри input. */\nexport function useInputOverflow(\n inputRef: React.RefObject<HTMLInputElement | null>,\n displayValue: string,\n remeasureKey: unknown,\n): boolean {\n const [overflow, setOverflow] = useState(false);\n\n useLayoutEffect(() => {\n const input = inputRef.current;\n if (!input) {\n return;\n }\n\n const measure = () => {\n setOverflow((prev) => {\n const next = isInputTextOverflowing(input, displayValue);\n return prev === next ? prev : next;\n });\n };\n\n measure();\n\n if (typeof ResizeObserver === 'undefined') {\n return;\n }\n\n const observer = new ResizeObserver(measure);\n observer.observe(input);\n\n return () => observer.disconnect();\n }, [displayValue, inputRef, remeasureKey]);\n\n return overflow;\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export declare function useMaskAlignPadding(inputRef: React.RefObject<HTMLInputElement | null>, overlayRef: React.RefObject<HTMLElement | null>, displayValue: string, textAlign: React.CSSProperties['textAlign'] | undefined, enabled: boolean): number;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { computeMaskAlignPadding, needsMaskAlignPadding } from './computeMaskAlignPadding.js';
|
|
3
|
+
export function useMaskAlignPadding(inputRef, overlayRef, displayValue, textAlign, enabled) {
|
|
4
|
+
var _a = useState(0), paddingLeft = _a[0], setPaddingLeft = _a[1];
|
|
5
|
+
useLayoutEffect(function () {
|
|
6
|
+
if (!enabled || !needsMaskAlignPadding(textAlign)) {
|
|
7
|
+
setPaddingLeft(0);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
var input = inputRef.current;
|
|
11
|
+
if (!input) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
var update = function () {
|
|
15
|
+
setPaddingLeft(function (prev) {
|
|
16
|
+
var next = computeMaskAlignPadding(input, displayValue, textAlign, overlayRef.current);
|
|
17
|
+
return prev === next ? prev : next;
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
update();
|
|
21
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
var observer = new ResizeObserver(update);
|
|
25
|
+
observer.observe(input);
|
|
26
|
+
if (overlayRef.current) {
|
|
27
|
+
observer.observe(overlayRef.current);
|
|
28
|
+
}
|
|
29
|
+
return function () { return observer.disconnect(); };
|
|
30
|
+
}, [displayValue, enabled, inputRef, overlayRef, textAlign]);
|
|
31
|
+
return paddingLeft;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=useMaskAlignPadding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMaskAlignPadding.js","sourceRoot":"","sources":["useMaskAlignPadding.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE9F,MAAM,UAAU,mBAAmB,CACjC,QAAkD,EAClD,UAA+C,EAC/C,YAAoB,EACpB,SAAuD,EACvD,OAAgB;IAEV,IAAA,KAAgC,QAAQ,CAAC,CAAC,CAAC,EAA1C,WAAW,QAAA,EAAE,cAAc,QAAe,CAAC;IAElD,eAAe,CAAC;QACd,IAAI,CAAC,OAAO,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,EAAE,CAAC;YAClD,cAAc,CAAC,CAAC,CAAC,CAAC;YAClB,OAAO;QACT,CAAC;QAED,IAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO;QACT,CAAC;QAED,IAAM,MAAM,GAAG;YACb,cAAc,CAAC,UAAC,IAAI;gBAClB,IAAM,IAAI,GAAG,uBAAuB,CAAC,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;gBACzF,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,EAAE,CAAC;QAET,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE,CAAC;YAC1C,OAAO;QACT,CAAC;QAED,IAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QAC5C,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACxB,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YACvB,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,cAAM,OAAA,QAAQ,CAAC,UAAU,EAAE,EAArB,CAAqB,CAAC;IACrC,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;IAE7D,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import type React from 'react';\nimport { useLayoutEffect, useState } from 'react';\n\nimport { computeMaskAlignPadding, needsMaskAlignPadding } from './computeMaskAlignPadding.js';\n\nexport function useMaskAlignPadding(\n inputRef: React.RefObject<HTMLInputElement | null>,\n overlayRef: React.RefObject<HTMLElement | null>,\n displayValue: string,\n textAlign: React.CSSProperties['textAlign'] | undefined,\n enabled: boolean,\n): number {\n const [paddingLeft, setPaddingLeft] = useState(0);\n\n useLayoutEffect(() => {\n if (!enabled || !needsMaskAlignPadding(textAlign)) {\n setPaddingLeft(0);\n return;\n }\n\n const input = inputRef.current;\n if (!input) {\n return;\n }\n\n const update = () => {\n setPaddingLeft((prev) => {\n const next = computeMaskAlignPadding(input, displayValue, textAlign, overlayRef.current);\n return prev === next ? prev : next;\n });\n };\n\n update();\n\n if (typeof ResizeObserver === 'undefined') {\n return;\n }\n\n const observer = new ResizeObserver(update);\n observer.observe(input);\n if (overlayRef.current) {\n observer.observe(overlayRef.current);\n }\n\n return () => observer.disconnect();\n }, [displayValue, enabled, inputRef, overlayRef, textAlign]);\n\n return paddingLeft;\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { MaskedPattern, MaskedPatternOptions } from '../react-imask/imask/index.js';
|
|
2
|
+
import type { IMaskInputProps } from '../react-imask/index.js';
|
|
3
|
+
import type { MaskState, SlotMap } from './types.js';
|
|
4
|
+
export interface MaskEngine {
|
|
5
|
+
/**
|
|
6
|
+
* Применить raw-ввод, получить MaskState.
|
|
7
|
+
* Чистая функция (без побочных эффектов на внешний стейт).
|
|
8
|
+
*/
|
|
9
|
+
compute(raw: string, focused: boolean): MaskState;
|
|
10
|
+
/**
|
|
11
|
+
* Применить вставку с учётом текущего курсора.
|
|
12
|
+
* Возвращает новый raw и флаг переполнения.
|
|
13
|
+
*/
|
|
14
|
+
applyPaste(currentRaw: string, rawCursorPos: number, pasted: string): PasteResult;
|
|
15
|
+
/** Карта слотов. Пересчитывается только при смене маски. */
|
|
16
|
+
slotMap: SlotMap;
|
|
17
|
+
/** Доступ к IMask-инстансу для edge cases (imaskProps escape hatch). */
|
|
18
|
+
imask: MaskedPattern;
|
|
19
|
+
}
|
|
20
|
+
interface PasteResult {
|
|
21
|
+
raw: string;
|
|
22
|
+
overflow: boolean;
|
|
23
|
+
}
|
|
24
|
+
export type MaskEager = NonNullable<MaskedPatternOptions['eager']>;
|
|
25
|
+
/** Пропсы хука {@link useMaskEngine}. */
|
|
26
|
+
interface UseMaskEngineProps {
|
|
27
|
+
mask: string;
|
|
28
|
+
maskChar?: string;
|
|
29
|
+
formatChars?: Record<string, string>;
|
|
30
|
+
unmask: boolean;
|
|
31
|
+
alwaysShowMask: boolean;
|
|
32
|
+
imaskProps?: IMaskInputProps<HTMLInputElement>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Создаёт headless IMask-движок для MaskedInputV2.
|
|
36
|
+
* IMask используется как калькулятор состояния, без привязки к DOM.
|
|
37
|
+
*
|
|
38
|
+
* @param props — настройки маски и поведения отображения.
|
|
39
|
+
* @returns объект {@link MaskEngine} с методами `compute`, `applyPaste`, `slotMap` и `imask`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function useMaskEngine(props: UseMaskEngineProps): MaskEngine;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import { useMemo } from 'react';
|
|
22
|
+
import { getDefinitions, getMaskChar } from '../MaskedInputV2.helpers.js';
|
|
23
|
+
import { createMask } from '../react-imask/imask/masked/create.js';
|
|
24
|
+
import { buildSlotMap, extractRaw } from './helpers.js';
|
|
25
|
+
var IMASK_DEFAULT_PATTERN_TOKENS = new Set(['a', '*']);
|
|
26
|
+
/**
|
|
27
|
+
* В IMask `a`, `*` и `0` имеют встроенные определения. В API MaskedInput
|
|
28
|
+
* `formatChars` — полный словарь токенов, поэтому незаданные в нём встроенные
|
|
29
|
+
* токены должны оставаться литералами маски.
|
|
30
|
+
*
|
|
31
|
+
* Кастомные definitions из imaskProps — escape hatch, поэтому они также
|
|
32
|
+
* сохраняют символ токеном.
|
|
33
|
+
*
|
|
34
|
+
* `0` всегда был литералом в MaskedInput и обрабатывается отдельно ниже.
|
|
35
|
+
*/
|
|
36
|
+
function normalizeMask(mask, formatChars, imaskDefinitions) {
|
|
37
|
+
var _a;
|
|
38
|
+
if (!formatChars) {
|
|
39
|
+
return mask.replace(/0/g, '{\\0}');
|
|
40
|
+
}
|
|
41
|
+
var definitionTokens = new Set(__spreadArray(__spreadArray([], Object.keys(formatChars), true), Object.keys(imaskDefinitions !== null && imaskDefinitions !== void 0 ? imaskDefinitions : {}), true));
|
|
42
|
+
var normalizedMask = '';
|
|
43
|
+
for (var index = 0; index < mask.length; index++) {
|
|
44
|
+
var char = mask[index];
|
|
45
|
+
// Не экранируем символ, уже экранированный пользователем.
|
|
46
|
+
if (char === '\\') {
|
|
47
|
+
normalizedMask += char + ((_a = mask[index + 1]) !== null && _a !== void 0 ? _a : '');
|
|
48
|
+
index++;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (IMASK_DEFAULT_PATTERN_TOKENS.has(char) && !definitionTokens.has(char)) {
|
|
52
|
+
normalizedMask += "\\".concat(char);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
normalizedMask += char;
|
|
56
|
+
}
|
|
57
|
+
return normalizedMask.replace(/0/g, '{\\0}');
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Создаёт headless IMask-движок для MaskedInputV2.
|
|
61
|
+
* IMask используется как калькулятор состояния, без привязки к DOM.
|
|
62
|
+
*
|
|
63
|
+
* @param props — настройки маски и поведения отображения.
|
|
64
|
+
* @returns объект {@link MaskEngine} с методами `compute`, `applyPaste`, `slotMap` и `imask`.
|
|
65
|
+
*/
|
|
66
|
+
export function useMaskEngine(props) {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
var mask = (_a = props.mask) !== null && _a !== void 0 ? _a : '';
|
|
69
|
+
var _c = (_b = props.imaskProps) !== null && _b !== void 0 ? _b : {}, imaskDefinitions = _c.definitions, eager = _c.eager;
|
|
70
|
+
var normalizedMask = normalizeMask(mask, props.formatChars, imaskDefinitions);
|
|
71
|
+
var imask = useMemo(function () {
|
|
72
|
+
return createMask(__assign({ mask: normalizedMask, placeholderChar: getMaskChar(props.maskChar), definitions: getDefinitions(props.formatChars), eager: eager !== null && eager !== void 0 ? eager : 'append', overwrite: 'shift', lazy: true }, props.imaskProps));
|
|
73
|
+
}, [normalizedMask, props.imaskProps, props.maskChar, eager, JSON.stringify(props.formatChars)]);
|
|
74
|
+
// SlotMap пересчитывается при смене маски
|
|
75
|
+
var slotMap = useMemo(function () { return buildSlotMap(imask); }, [imask]);
|
|
76
|
+
function compute(raw, focused) {
|
|
77
|
+
var lazy = !props.alwaysShowMask && !focused;
|
|
78
|
+
var eagerAppend = imask.eager === 'append' || imask.eager === true;
|
|
79
|
+
// raw — только пользовательские слоты. resolve({ input: true }) съел бы цифру,
|
|
80
|
+
// совпадающую с литералом маски (`7` в `7 999` / первая `7` после `+7`).
|
|
81
|
+
imask.updateOptions({ lazy: true });
|
|
82
|
+
imask.rawInputValue = raw;
|
|
83
|
+
// raw-флаг не триггерит eager trailing (это делал flags.input) — добираем вручную.
|
|
84
|
+
if (eagerAppend && raw) {
|
|
85
|
+
imask._appendEager();
|
|
86
|
+
}
|
|
87
|
+
if (focused && !raw && eagerAppend) {
|
|
88
|
+
imask._appendEager();
|
|
89
|
+
}
|
|
90
|
+
var lazyValue = imask.value;
|
|
91
|
+
var displayValue = lazyValue;
|
|
92
|
+
var typedValue = lazyValue;
|
|
93
|
+
if (!lazy) {
|
|
94
|
+
imask.updateOptions({ lazy: false });
|
|
95
|
+
imask.rawInputValue = raw;
|
|
96
|
+
if (eagerAppend && raw) {
|
|
97
|
+
imask._appendEager();
|
|
98
|
+
}
|
|
99
|
+
displayValue = imask.displayValue;
|
|
100
|
+
}
|
|
101
|
+
var unmaskedValue = raw === '' ? '' : imask.unmaskedValue;
|
|
102
|
+
var maskedValue = raw === '' ? '' : lazyValue;
|
|
103
|
+
return {
|
|
104
|
+
displayValue: displayValue,
|
|
105
|
+
typedValue: typedValue,
|
|
106
|
+
typedLength: typedValue.length,
|
|
107
|
+
outputValue: props.unmask ? unmaskedValue : maskedValue,
|
|
108
|
+
isComplete: imask.isComplete,
|
|
109
|
+
acceptedLength: imask.unmaskedValue.length,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function applyPaste(currentRaw, rawCursorPos, pasted) {
|
|
113
|
+
var before = currentRaw.slice(0, rawCursorPos);
|
|
114
|
+
var after = currentRaw.slice(rawCursorPos);
|
|
115
|
+
// Уже «сырые» цифры (в т.ч. после normalizeRussianPhonePaste) нельзя прогонять через
|
|
116
|
+
// extractRaw/.value (input:true): ведущая 7 съестся литералом `+7` / `7 …`.
|
|
117
|
+
var pastedRaw = /^\d+$/.test(pasted) ? pasted : extractRaw(pasted, { imask: imask });
|
|
118
|
+
var candidate = before + pastedRaw + after;
|
|
119
|
+
imask.rawInputValue = candidate;
|
|
120
|
+
var accepted = imask.rawInputValue;
|
|
121
|
+
return {
|
|
122
|
+
raw: accepted,
|
|
123
|
+
overflow: accepted.length < candidate.length,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return { compute: compute, applyPaste: applyPaste, slotMap: slotMap, imask: imask };
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=useMaskEngine.js.map
|