@elliemae/ds-form 3.1.0-next.18 → 3.1.0-next.20
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/dist/cjs/FormItem/props.js +3 -1
- package/dist/cjs/FormItem/props.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/DateInputMask.js +0 -36
- package/dist/cjs/InputMask/mask_types/DateInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/DateTimeInputMask.js +0 -36
- package/dist/cjs/InputMask/mask_types/DateTimeInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/DictionaryInputMask.js +0 -39
- package/dist/cjs/InputMask/mask_types/DictionaryInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/NumberInputMask.js +0 -48
- package/dist/cjs/InputMask/mask_types/NumberInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/PhoneInputMask.js +0 -36
- package/dist/cjs/InputMask/mask_types/PhoneInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/PhoneInternationalInputMask.js +0 -36
- package/dist/cjs/InputMask/mask_types/PhoneInternationalInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/SsnInputMask.js +0 -36
- package/dist/cjs/InputMask/mask_types/SsnInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/UsZipCodeInputMask.js +0 -36
- package/dist/cjs/InputMask/mask_types/UsZipCodeInputMask.js.map +2 -2
- package/dist/cjs/InputMask/mask_types/ZipCodeSearchInputMask.js +0 -36
- package/dist/cjs/InputMask/mask_types/ZipCodeSearchInputMask.js.map +2 -2
- package/dist/cjs/InputMask/props.js +2 -1
- package/dist/cjs/InputMask/props.js.map +2 -2
- package/dist/cjs/InputProtected/props.js +4 -2
- package/dist/cjs/InputProtected/props.js.map +2 -2
- package/dist/cjs/Radio/DSRadio.js +6 -4
- package/dist/cjs/Radio/DSRadio.js.map +2 -2
- package/dist/esm/FormItem/props.js +3 -1
- package/dist/esm/FormItem/props.js.map +2 -2
- package/dist/esm/InputMask/mask_types/DateInputMask.js +0 -36
- package/dist/esm/InputMask/mask_types/DateInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/DateTimeInputMask.js +0 -36
- package/dist/esm/InputMask/mask_types/DateTimeInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/DictionaryInputMask.js +0 -39
- package/dist/esm/InputMask/mask_types/DictionaryInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/NumberInputMask.js +0 -48
- package/dist/esm/InputMask/mask_types/NumberInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/PhoneInputMask.js +0 -36
- package/dist/esm/InputMask/mask_types/PhoneInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/PhoneInternationalInputMask.js +0 -36
- package/dist/esm/InputMask/mask_types/PhoneInternationalInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/SsnInputMask.js +0 -36
- package/dist/esm/InputMask/mask_types/SsnInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/UsZipCodeInputMask.js +0 -36
- package/dist/esm/InputMask/mask_types/UsZipCodeInputMask.js.map +2 -2
- package/dist/esm/InputMask/mask_types/ZipCodeSearchInputMask.js +0 -36
- package/dist/esm/InputMask/mask_types/ZipCodeSearchInputMask.js.map +2 -2
- package/dist/esm/InputMask/props.js +2 -1
- package/dist/esm/InputMask/props.js.map +2 -2
- package/dist/esm/InputProtected/props.js +4 -2
- package/dist/esm/InputProtected/props.js.map +2 -2
- package/dist/esm/Radio/DSRadio.js +6 -4
- package/dist/esm/Radio/DSRadio.js.map +2 -2
- package/package.json +12 -12
|
@@ -63,7 +63,9 @@ const props = {
|
|
|
63
63
|
onKeyUp: import_ds_utilities.PropTypes.func.description("on key up event handler"),
|
|
64
64
|
mask: import_ds_utilities.PropTypes.oneOfType([
|
|
65
65
|
import_ds_utilities.PropTypes.string,
|
|
66
|
-
import_ds_utilities.PropTypes.func
|
|
66
|
+
import_ds_utilities.PropTypes.func,
|
|
67
|
+
import_ds_utilities.PropTypes.object,
|
|
68
|
+
import_ds_utilities.PropTypes.array
|
|
67
69
|
]).description("mask for input mask component"),
|
|
68
70
|
useSubfix: import_ds_utilities.PropTypes.string.description("add suffix to input"),
|
|
69
71
|
suffix: import_ds_utilities.PropTypes.string.description("suffix for input"),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/FormItem/props.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { PropTypes } from '@elliemae/ds-utilities';\nimport { FORMITEM_LAYOUT_VARIANTS } from './variants';\n\nexport const props = {\n /** props to inject to form item layout wrapper */\n containerProps: PropTypes.object.description('props to inject to form item layout wrapper'),\n /** disableTooltip */\n disableTooltip: PropTypes.bool\n .description('Whether to show a tooltip or not when text does not fit')\n .defaultValue(true),\n /** position label on the left */\n leftLabel: PropTypes.bool.description('position label on the left'),\n /** turn on floating label */\n floatingLabel: PropTypes.bool.description('turn on floating label'),\n /** id for form item layout */\n id: PropTypes.string.description('id for form item layout'),\n /** html name prop for form tags */\n name: PropTypes.string.description('html name prop for form tags'),\n /** form item layout element value */\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).description(\n 'form item layout element value',\n ),\n /** Any input component */\n inputComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.element]).description('Any input component'),\n /** isShowElipsisActive */\n /** isShowElipsisActive */\n isShowElipsisActive: PropTypes.bool\n .description('Wheter to enable the ellipsis and tooltip functionality or not')\n .defaultValue(true),\n /** Label component */\n labelComponent: PropTypes.func.description('Label component'),\n /** feedback component to embed on form item */\n feedbackComponent: PropTypes.func.description('feedback component to embed on form item'),\n /** label text */\n labelText: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).description('label text'),\n /** error state */\n hasError: PropTypes.bool.description('error state'),\n /** add fit content to form container */\n fitContent: PropTypes.bool.description(\n 'Adds fit content css property to the main container, making the layout width adapt to the input component',\n ),\n /** validation state */\n validationState: PropTypes.oneOf(['success', 'error', 'warning']).description('validation state'),\n /** validation message */\n validationMessage: PropTypes.string.description('validation message'),\n /** feedback message */\n feedbackMessage: PropTypes.string.description('feedback message'),\n /** read only form item */\n readOnly: PropTypes.bool.description('read only form item'),\n /** focused state */\n focused: PropTypes.bool.description('focused state'),\n /** input type */\n type: PropTypes.string.description('input type'),\n /** auto focus input */\n autoFocus: PropTypes.bool.description('auto focus input'),\n /** disabled state */\n disabled: PropTypes.bool.description('disabled state'),\n /** on change handler */\n onChange: PropTypes.func.description('on change handler'),\n /** on blur handler */\n onBlur: PropTypes.func.description('on blur handler'),\n /** extra input props to inject */\n extraInputProps: PropTypes.object.description('extra input props to inject'),\n /** extra content */\n extraContent: PropTypes.element.description('extra content'),\n /** left addon for form item */\n leftAddon: PropTypes.element.description('left addon for form item'),\n /** right addon for form item */\n rightAddon: PropTypes.element.description('right addon for form item'),\n /** add required mark */\n required: PropTypes.bool.description('add required mark'),\n /** add optional mark */\n optional: PropTypes.bool.description('add optional mark'),\n /** on focus handler */\n onFocus: PropTypes.func.description('on focus handler'),\n /** on paste handler */\n onPaste: PropTypes.func.description('on paste handler'),\n /** add truncation and ellipsis */\n truncateText: PropTypes.bool.description('add truncation and ellipsis'),\n /** on key up event handler */\n onKeyUp: PropTypes.func.description('on key up event handler'),\n /** mask for input mask component */\n mask: PropTypes.oneOfType([\n // PropTypes.oneOf(maskTypes),\n PropTypes.string,\n PropTypes.func,\n ]).description('mask for input mask component'),\n /** add suffix to input */\n useSubfix: PropTypes.string.description('add suffix to input'),\n /** suffix for input */\n suffix: PropTypes.string.description('suffix for input'),\n /** form item layout type */\n variant: PropTypes.oneOf([\n FORMITEM_LAYOUT_VARIANTS.DEFAULT,\n FORMITEM_LAYOUT_VARIANTS.FOCUS,\n FORMITEM_LAYOUT_VARIANTS.ACTIVE,\n FORMITEM_LAYOUT_VARIANTS.DISABLED,\n FORMITEM_LAYOUT_VARIANTS.READ_ONLY,\n FORMITEM_LAYOUT_VARIANTS.OPTIONAL,\n ]).description('form item layout type'),\n withHighlight: PropTypes.bool.description('adds highlight style to the input component'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,0BAA0B;AAC1B,sBAAyC;AAElC,MAAM,QAAQ;AAAA,EAEnB,gBAAgB,8BAAU,OAAO,YAAY,6CAA6C;AAAA,EAE1F,gBAAgB,8BAAU,KACvB,YAAY,yDAAyD,EACrE,aAAa,IAAI;AAAA,EAEpB,WAAW,8BAAU,KAAK,YAAY,4BAA4B;AAAA,EAElE,eAAe,8BAAU,KAAK,YAAY,wBAAwB;AAAA,EAElE,IAAI,8BAAU,OAAO,YAAY,yBAAyB;AAAA,EAE1D,MAAM,8BAAU,OAAO,YAAY,8BAA8B;AAAA,EAEjE,OAAO,8BAAU,UAAU,CAAC,8BAAU,QAAQ,8BAAU,QAAQ,8BAAU,MAAM,CAAC,EAAE,YACjF,gCACF;AAAA,EAEA,gBAAgB,8BAAU,UAAU,CAAC,8BAAU,MAAM,8BAAU,OAAO,CAAC,EAAE,YAAY,qBAAqB;AAAA,EAG1G,qBAAqB,8BAAU,KAC5B,YAAY,gEAAgE,EAC5E,aAAa,IAAI;AAAA,EAEpB,gBAAgB,8BAAU,KAAK,YAAY,iBAAiB;AAAA,EAE5D,mBAAmB,8BAAU,KAAK,YAAY,0CAA0C;AAAA,EAExF,WAAW,8BAAU,UAAU,CAAC,8BAAU,QAAQ,8BAAU,OAAO,CAAC,EAAE,YAAY,YAAY;AAAA,EAE9F,UAAU,8BAAU,KAAK,YAAY,aAAa;AAAA,EAElD,YAAY,8BAAU,KAAK,YACzB,2GACF;AAAA,EAEA,iBAAiB,8BAAU,MAAM,CAAC,WAAW,SAAS,SAAS,CAAC,EAAE,YAAY,kBAAkB;AAAA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B,yCAAyB;AAAA,EAC3B,CAAC,EAAE,YAAY,uBAAuB;AAAA,EACtC,eAAe,8BAAU,KAAK,YAAY,6CAA6C;AACzF;",
|
|
4
|
+
"sourcesContent": ["import { PropTypes } from '@elliemae/ds-utilities';\nimport { FORMITEM_LAYOUT_VARIANTS } from './variants';\n\nexport const props = {\n /** props to inject to form item layout wrapper */\n containerProps: PropTypes.object.description('props to inject to form item layout wrapper'),\n /** disableTooltip */\n disableTooltip: PropTypes.bool\n .description('Whether to show a tooltip or not when text does not fit')\n .defaultValue(true),\n /** position label on the left */\n leftLabel: PropTypes.bool.description('position label on the left'),\n /** turn on floating label */\n floatingLabel: PropTypes.bool.description('turn on floating label'),\n /** id for form item layout */\n id: PropTypes.string.description('id for form item layout'),\n /** html name prop for form tags */\n name: PropTypes.string.description('html name prop for form tags'),\n /** form item layout element value */\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).description(\n 'form item layout element value',\n ),\n /** Any input component */\n inputComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.element]).description('Any input component'),\n /** isShowElipsisActive */\n /** isShowElipsisActive */\n isShowElipsisActive: PropTypes.bool\n .description('Wheter to enable the ellipsis and tooltip functionality or not')\n .defaultValue(true),\n /** Label component */\n labelComponent: PropTypes.func.description('Label component'),\n /** feedback component to embed on form item */\n feedbackComponent: PropTypes.func.description('feedback component to embed on form item'),\n /** label text */\n labelText: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).description('label text'),\n /** error state */\n hasError: PropTypes.bool.description('error state'),\n /** add fit content to form container */\n fitContent: PropTypes.bool.description(\n 'Adds fit content css property to the main container, making the layout width adapt to the input component',\n ),\n /** validation state */\n validationState: PropTypes.oneOf(['success', 'error', 'warning']).description('validation state'),\n /** validation message */\n validationMessage: PropTypes.string.description('validation message'),\n /** feedback message */\n feedbackMessage: PropTypes.string.description('feedback message'),\n /** read only form item */\n readOnly: PropTypes.bool.description('read only form item'),\n /** focused state */\n focused: PropTypes.bool.description('focused state'),\n /** input type */\n type: PropTypes.string.description('input type'),\n /** auto focus input */\n autoFocus: PropTypes.bool.description('auto focus input'),\n /** disabled state */\n disabled: PropTypes.bool.description('disabled state'),\n /** on change handler */\n onChange: PropTypes.func.description('on change handler'),\n /** on blur handler */\n onBlur: PropTypes.func.description('on blur handler'),\n /** extra input props to inject */\n extraInputProps: PropTypes.object.description('extra input props to inject'),\n /** extra content */\n extraContent: PropTypes.element.description('extra content'),\n /** left addon for form item */\n leftAddon: PropTypes.element.description('left addon for form item'),\n /** right addon for form item */\n rightAddon: PropTypes.element.description('right addon for form item'),\n /** add required mark */\n required: PropTypes.bool.description('add required mark'),\n /** add optional mark */\n optional: PropTypes.bool.description('add optional mark'),\n /** on focus handler */\n onFocus: PropTypes.func.description('on focus handler'),\n /** on paste handler */\n onPaste: PropTypes.func.description('on paste handler'),\n /** add truncation and ellipsis */\n truncateText: PropTypes.bool.description('add truncation and ellipsis'),\n /** on key up event handler */\n onKeyUp: PropTypes.func.description('on key up event handler'),\n /** mask for input mask component */\n mask: PropTypes.oneOfType([\n // PropTypes.oneOf(maskTypes),\n PropTypes.string,\n PropTypes.func,\n PropTypes.object,\n PropTypes.array,\n ]).description('mask for input mask component'),\n /** add suffix to input */\n useSubfix: PropTypes.string.description('add suffix to input'),\n /** suffix for input */\n suffix: PropTypes.string.description('suffix for input'),\n /** form item layout type */\n variant: PropTypes.oneOf([\n FORMITEM_LAYOUT_VARIANTS.DEFAULT,\n FORMITEM_LAYOUT_VARIANTS.FOCUS,\n FORMITEM_LAYOUT_VARIANTS.ACTIVE,\n FORMITEM_LAYOUT_VARIANTS.DISABLED,\n FORMITEM_LAYOUT_VARIANTS.READ_ONLY,\n FORMITEM_LAYOUT_VARIANTS.OPTIONAL,\n ]).description('form item layout type'),\n withHighlight: PropTypes.bool.description('adds highlight style to the input component'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;A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|
|
55
55
|
module.exports = __toCommonJS(DateInputMask_exports);
|
|
56
56
|
var React = __toESM(require("react"));
|
|
57
57
|
var import_react = __toESM(require("react"));
|
|
58
|
-
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
59
58
|
var import_TextBox = require("../../TextBox");
|
|
60
59
|
var import_setCaretPosition = require("../utils/setCaretPosition");
|
|
61
60
|
const conformValue = (rawValue, cursorPos, lastkeycode) => {
|
|
@@ -231,40 +230,5 @@ const DateInputMask = (_a) => {
|
|
|
231
230
|
value: maskedValue
|
|
232
231
|
}));
|
|
233
232
|
};
|
|
234
|
-
DateInputMask.propTypes = {
|
|
235
|
-
focus: import_ds_utilities.PropTypes.bool,
|
|
236
|
-
setFocus: import_ds_utilities.PropTypes.func,
|
|
237
|
-
setRawMask: import_ds_utilities.PropTypes.func,
|
|
238
|
-
cursorPosition: import_ds_utilities.PropTypes.shape({ current: import_ds_utilities.PropTypes.number }),
|
|
239
|
-
setCursorPosition: import_ds_utilities.PropTypes.func,
|
|
240
|
-
lastkey: import_ds_utilities.PropTypes.shape({ code: import_ds_utilities.PropTypes.number, key: import_ds_utilities.PropTypes.string }),
|
|
241
|
-
setLastkey: import_ds_utilities.PropTypes.func,
|
|
242
|
-
setRawValue: import_ds_utilities.PropTypes.func,
|
|
243
|
-
style: import_ds_utilities.PropTypes.object,
|
|
244
|
-
disabled: import_ds_utilities.PropTypes.bool,
|
|
245
|
-
className: import_ds_utilities.PropTypes.string,
|
|
246
|
-
name: import_ds_utilities.PropTypes.string,
|
|
247
|
-
maxLength: import_ds_utilities.PropTypes.number,
|
|
248
|
-
minLength: import_ds_utilities.PropTypes.number,
|
|
249
|
-
fluidWidth: import_ds_utilities.PropTypes.bool,
|
|
250
|
-
placeholder: import_ds_utilities.PropTypes.string,
|
|
251
|
-
value: import_ds_utilities.PropTypes.string,
|
|
252
|
-
onChange: import_ds_utilities.PropTypes.func,
|
|
253
|
-
onKeyDown: import_ds_utilities.PropTypes.func,
|
|
254
|
-
leftComponent: import_ds_utilities.PropTypes.element,
|
|
255
|
-
rightComponent: import_ds_utilities.PropTypes.element,
|
|
256
|
-
onFocus: import_ds_utilities.PropTypes.func,
|
|
257
|
-
onBlur: import_ds_utilities.PropTypes.func,
|
|
258
|
-
onPaste: import_ds_utilities.PropTypes.func,
|
|
259
|
-
onKeyUp: import_ds_utilities.PropTypes.func,
|
|
260
|
-
hasError: import_ds_utilities.PropTypes.bool,
|
|
261
|
-
readOnly: import_ds_utilities.PropTypes.bool,
|
|
262
|
-
onClick: import_ds_utilities.PropTypes.func,
|
|
263
|
-
clearable: import_ds_utilities.PropTypes.bool,
|
|
264
|
-
type: import_ds_utilities.PropTypes.string,
|
|
265
|
-
innerRef: import_ds_utilities.PropTypes.any,
|
|
266
|
-
mask: import_ds_utilities.PropTypes.any,
|
|
267
|
-
placeholderChar: import_ds_utilities.PropTypes.string
|
|
268
|
-
};
|
|
269
233
|
var DateInputMask_default = DateInputMask;
|
|
270
234
|
//# sourceMappingURL=DateInputMask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/InputMask/mask_types/DateInputMask.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { PropTypes } from '@elliemae/ds-utilities';\nimport { DSTextBox } from '../../TextBox';\nimport { TCharsToAdd } from '../types';\nimport { setCaretPosition } from '../utils/setCaretPosition';\n\nconst conformValue = (\n rawValue: string,\n cursorPos: number,\n lastkeycode: number,\n) => {\n const nextMaskedValue = rawValue\n .split('')\n .filter((char) => char >= '0' && char <= '9')\n .slice(0, 8);\n\n let maskedPos = 0;\n for (let i = 0; i < cursorPos; i += 1) {\n if (nextMaskedValue[maskedPos] === rawValue[i]) maskedPos += 1;\n }\n\n // list of [string to add, position to add]\n const charactersToAdd: TCharsToAdd = [\n ['/', 2],\n ['/', 5],\n ];\n\n charactersToAdd.forEach(([chars, pos]) => {\n if (nextMaskedValue.length > pos) {\n nextMaskedValue.splice(pos, 0, chars);\n if (maskedPos >= pos) maskedPos += chars.length;\n }\n });\n\n if (lastkeycode !== 8 && maskedPos < nextMaskedValue.length) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos) maskedPos += chars.length;\n });\n } else if (lastkeycode === 8 && maskedPos) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos + 1) maskedPos -= chars.length;\n });\n }\n\n return { nextMaskedValue: nextMaskedValue.join(''), maskedPos };\n};\n\nconst DateInputMask = ({\n focus,\n setFocus,\n setRawMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n style,\n disabled,\n className,\n name,\n maxLength,\n minLength,\n fluidWidth,\n placeholder,\n onKeyDown,\n onClick,\n onChange,\n onFocus,\n onBlur,\n onPaste,\n onKeyUp,\n hasError,\n readOnly,\n type,\n innerRef,\n clearable = false,\n leftComponent,\n rightComponent,\n value,\n ...rest\n}) => {\n const inputRef = useRef();\n const [maskedValue, setMaskedValue] = useState(value);\n\n const conform = useCallback(\n ({ rawValue, cursorPos, lastkeycode, shouldUpdateCursorPos = true }) => {\n const { nextMaskedValue, maskedPos } = conformValue(\n rawValue,\n cursorPos,\n lastkeycode,\n );\n const event = {\n target: {\n value: nextMaskedValue,\n originalValue: rawValue,\n },\n };\n if (onChange && nextMaskedValue !== maskedValue) onChange(event);\n\n setMaskedValue(nextMaskedValue);\n setRawValue(nextMaskedValue);\n\n if (shouldUpdateCursorPos) setCursorPosition({ current: maskedPos });\n },\n [maskedValue, onChange],\n );\n\n const handleOnChange = useCallback(\n (e) => {\n const { value: rawValue, selectionEnd } = e.target;\n setRawMask(rawValue);\n setRawValue(rawValue);\n setCursorPosition({ current: selectionEnd });\n setFocus(true);\n },\n [setRawMask, setRawValue, setCursorPosition, setFocus, lastkey.code],\n );\n\n useLayoutEffect(() => {\n if (focus) setCaretPosition(inputRef.current, cursorPosition.current);\n }, [focus, cursorPosition]);\n\n useLayoutEffect(() => {\n // if the value changes, then re-conform the mask\n conform({\n rawValue: value,\n cursorPos: cursorPosition.current,\n lastkeycode: lastkey.code,\n shouldUpdateCursorPos: focus,\n });\n }, [focus, value, cursorPosition.current]);\n\n const handleKeyDown = useCallback(\n (e) => {\n e.stopPropagation();\n setLastkey({ key: e.key, code: e.keyCode });\n onKeyDown(e);\n },\n [onKeyDown],\n );\n\n const handleBlur = useCallback(\n (e) => {\n setFocus(false);\n onBlur(e);\n },\n [onBlur],\n );\n\n return (\n <DSTextBox\n {...rest}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n innerRef={(ref) => {\n inputRef.current = ref;\n if (innerRef) innerRef(ref);\n }}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={handleBlur}\n onChange={handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={maskedValue}\n />\n );\n};\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAsE;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { PropTypes } from '@elliemae/ds-utilities';\nimport { DSTextBox } from '../../TextBox';\nimport { TCharsToAdd } from '../types';\nimport { setCaretPosition } from '../utils/setCaretPosition';\n\nconst conformValue = (\n rawValue: string,\n cursorPos: number,\n lastkeycode: number,\n) => {\n const nextMaskedValue = rawValue\n .split('')\n .filter((char) => char >= '0' && char <= '9')\n .slice(0, 8);\n\n let maskedPos = 0;\n for (let i = 0; i < cursorPos; i += 1) {\n if (nextMaskedValue[maskedPos] === rawValue[i]) maskedPos += 1;\n }\n\n // list of [string to add, position to add]\n const charactersToAdd: TCharsToAdd = [\n ['/', 2],\n ['/', 5],\n ];\n\n charactersToAdd.forEach(([chars, pos]) => {\n if (nextMaskedValue.length > pos) {\n nextMaskedValue.splice(pos, 0, chars);\n if (maskedPos >= pos) maskedPos += chars.length;\n }\n });\n\n if (lastkeycode !== 8 && maskedPos < nextMaskedValue.length) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos) maskedPos += chars.length;\n });\n } else if (lastkeycode === 8 && maskedPos) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos + 1) maskedPos -= chars.length;\n });\n }\n\n return { nextMaskedValue: nextMaskedValue.join(''), maskedPos };\n};\n\nconst DateInputMask = ({\n focus,\n setFocus,\n setRawMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n style,\n disabled,\n className,\n name,\n maxLength,\n minLength,\n fluidWidth,\n placeholder,\n onKeyDown,\n onClick,\n onChange,\n onFocus,\n onBlur,\n onPaste,\n onKeyUp,\n hasError,\n readOnly,\n type,\n innerRef,\n clearable = false,\n leftComponent,\n rightComponent,\n value,\n ...rest\n}) => {\n const inputRef = useRef();\n const [maskedValue, setMaskedValue] = useState(value);\n\n const conform = useCallback(\n ({ rawValue, cursorPos, lastkeycode, shouldUpdateCursorPos = true }) => {\n const { nextMaskedValue, maskedPos } = conformValue(\n rawValue,\n cursorPos,\n lastkeycode,\n );\n const event = {\n target: {\n value: nextMaskedValue,\n originalValue: rawValue,\n },\n };\n if (onChange && nextMaskedValue !== maskedValue) onChange(event);\n\n setMaskedValue(nextMaskedValue);\n setRawValue(nextMaskedValue);\n\n if (shouldUpdateCursorPos) setCursorPosition({ current: maskedPos });\n },\n [maskedValue, onChange],\n );\n\n const handleOnChange = useCallback(\n (e) => {\n const { value: rawValue, selectionEnd } = e.target;\n setRawMask(rawValue);\n setRawValue(rawValue);\n setCursorPosition({ current: selectionEnd });\n setFocus(true);\n },\n [setRawMask, setRawValue, setCursorPosition, setFocus, lastkey.code],\n );\n\n useLayoutEffect(() => {\n if (focus) setCaretPosition(inputRef.current, cursorPosition.current);\n }, [focus, cursorPosition]);\n\n useLayoutEffect(() => {\n // if the value changes, then re-conform the mask\n conform({\n rawValue: value,\n cursorPos: cursorPosition.current,\n lastkeycode: lastkey.code,\n shouldUpdateCursorPos: focus,\n });\n }, [focus, value, cursorPosition.current]);\n\n const handleKeyDown = useCallback(\n (e) => {\n e.stopPropagation();\n setLastkey({ key: e.key, code: e.keyCode });\n onKeyDown(e);\n },\n [onKeyDown],\n );\n\n const handleBlur = useCallback(\n (e) => {\n setFocus(false);\n onBlur(e);\n },\n [onBlur],\n );\n\n return (\n <DSTextBox\n {...rest}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n innerRef={(ref) => {\n inputRef.current = ref;\n if (innerRef) innerRef(ref);\n }}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={handleBlur}\n onChange={handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={maskedValue}\n />\n );\n};\n\nexport { DateInputMask };\nexport default DateInputMask;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAsE;AAEtE,qBAA0B;AAE1B,8BAAiC;AAEjC,MAAM,eAAe,CACnB,UACA,W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G,CAAC,OAAO,cAAc,CAAC;AAE1B,oCAAgB,MAAM;AAEpB,YAAQ;AAAA,MACN,UAAU;AAAA,MACV,WAAW,eAAe;AAAA,MAC1B,aAAa,QAAQ;AAAA,MACrB,uBAAuB;AAAA,IACzB,CAAC;AAAA,EACH,GAAG,CAAC,OAAO,OAAO,eAAe,OAAO,CAAC;AAEzC,QAAM,gBAAgB,8BACpB,CAAC,MAAM;AACL,MAAE,gBAAgB;AAClB,eAAW,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,QAAQ,CAAC;AAC1C,cAAU,CAAC;AAAA,EACb,GACA,CAAC,SAAS,CACZ;AAEA,QAAM,aAAa,8BACjB,CAAC,MAAM;AACL,aAAS,KAAK;AACd,WAAO,CAAC;AAAA,EACV,GACA,CAAC,MAAM,CACT;AAEA,SACE,mDAAC,2DACK,OADL;AAAA,IAEC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC,QAAQ;AACjB,eAAS,UAAU;AACnB,UAAI;AAAU,iBAAS,GAAG;AAAA,IAC5B;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACT;AAEJ;AAGA,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -55,7 +55,6 @@ __export(DateTimeInputMask_exports, {
|
|
|
55
55
|
module.exports = __toCommonJS(DateTimeInputMask_exports);
|
|
56
56
|
var React = __toESM(require("react"));
|
|
57
57
|
var import_react = __toESM(require("react"));
|
|
58
|
-
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
59
58
|
var import_TextBox = require("../../TextBox");
|
|
60
59
|
var import_setCaretPosition = require("../utils/setCaretPosition");
|
|
61
60
|
const conformValue = (rawValue, cursorPos, lastkeycode) => {
|
|
@@ -237,40 +236,5 @@ const DateTimeInputMask = (_a) => {
|
|
|
237
236
|
value: maskedValue
|
|
238
237
|
}));
|
|
239
238
|
};
|
|
240
|
-
DateTimeInputMask.propTypes = {
|
|
241
|
-
focus: import_ds_utilities.PropTypes.bool,
|
|
242
|
-
setFocus: import_ds_utilities.PropTypes.func,
|
|
243
|
-
setRawMask: import_ds_utilities.PropTypes.func,
|
|
244
|
-
cursorPosition: import_ds_utilities.PropTypes.shape({ current: import_ds_utilities.PropTypes.number }),
|
|
245
|
-
setCursorPosition: import_ds_utilities.PropTypes.func,
|
|
246
|
-
lastkey: import_ds_utilities.PropTypes.shape({ code: import_ds_utilities.PropTypes.number, key: import_ds_utilities.PropTypes.string }),
|
|
247
|
-
setLastkey: import_ds_utilities.PropTypes.func,
|
|
248
|
-
setRawValue: import_ds_utilities.PropTypes.func,
|
|
249
|
-
style: import_ds_utilities.PropTypes.object,
|
|
250
|
-
disabled: import_ds_utilities.PropTypes.bool,
|
|
251
|
-
className: import_ds_utilities.PropTypes.string,
|
|
252
|
-
name: import_ds_utilities.PropTypes.string,
|
|
253
|
-
maxLength: import_ds_utilities.PropTypes.number,
|
|
254
|
-
minLength: import_ds_utilities.PropTypes.number,
|
|
255
|
-
fluidWidth: import_ds_utilities.PropTypes.bool,
|
|
256
|
-
placeholder: import_ds_utilities.PropTypes.string,
|
|
257
|
-
value: import_ds_utilities.PropTypes.string,
|
|
258
|
-
onChange: import_ds_utilities.PropTypes.func,
|
|
259
|
-
onKeyDown: import_ds_utilities.PropTypes.func,
|
|
260
|
-
leftComponent: import_ds_utilities.PropTypes.element,
|
|
261
|
-
rightComponent: import_ds_utilities.PropTypes.element,
|
|
262
|
-
onFocus: import_ds_utilities.PropTypes.func,
|
|
263
|
-
onBlur: import_ds_utilities.PropTypes.func,
|
|
264
|
-
onPaste: import_ds_utilities.PropTypes.func,
|
|
265
|
-
onKeyUp: import_ds_utilities.PropTypes.func,
|
|
266
|
-
hasError: import_ds_utilities.PropTypes.bool,
|
|
267
|
-
readOnly: import_ds_utilities.PropTypes.bool,
|
|
268
|
-
onClick: import_ds_utilities.PropTypes.func,
|
|
269
|
-
clearable: import_ds_utilities.PropTypes.bool,
|
|
270
|
-
type: import_ds_utilities.PropTypes.string,
|
|
271
|
-
innerRef: import_ds_utilities.PropTypes.any,
|
|
272
|
-
mask: import_ds_utilities.PropTypes.any,
|
|
273
|
-
placeholderChar: import_ds_utilities.PropTypes.string
|
|
274
|
-
};
|
|
275
239
|
var DateTimeInputMask_default = DateTimeInputMask;
|
|
276
240
|
//# sourceMappingURL=DateTimeInputMask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/InputMask/mask_types/DateTimeInputMask.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { PropTypes } from '@elliemae/ds-utilities';\nimport { DSTextBox } from '../../TextBox';\nimport { TCharsToAdd } from '../types';\nimport { setCaretPosition } from '../utils/setCaretPosition';\n\nconst conformValue = (\n rawValue: string,\n cursorPos: number,\n lastkeycode: number,\n) => {\n const nextMaskedValue = rawValue\n .split('')\n .filter((char) => char >= '0' && char <= '9')\n .slice(0, 12);\n\n while (nextMaskedValue.length > 8 && !nextMaskedValue[8].match(/[0-2]/))\n nextMaskedValue.splice(8, 1);\n while (nextMaskedValue.length > 10 && !nextMaskedValue[10].match(/[0-5]/))\n nextMaskedValue.splice(10, 1);\n\n let maskedPos = 0;\n for (let i = 0; i < cursorPos; i += 1) {\n if (nextMaskedValue[maskedPos] === rawValue[i]) maskedPos += 1;\n }\n\n // list of [string to add, position to add]\n const charactersToAdd: TCharsToAdd = [\n ['/', 2],\n ['/', 5],\n [' ', 10],\n [':', 13],\n ];\n\n charactersToAdd.forEach(([chars, pos]) => {\n if (nextMaskedValue.length > pos) {\n nextMaskedValue.splice(pos, 0, chars);\n if (maskedPos >= pos) maskedPos += chars.length;\n }\n });\n\n if (lastkeycode !== 8 && maskedPos < nextMaskedValue.length) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos) maskedPos += chars.length;\n });\n } else if (lastkeycode === 8 && maskedPos) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos + 1) maskedPos -= chars.length;\n });\n }\n\n return { nextMaskedValue: nextMaskedValue.join(''), maskedPos };\n};\n\nconst DateTimeInputMask = ({\n focus,\n setFocus,\n setRawMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n style,\n disabled,\n className,\n name,\n maxLength,\n minLength,\n fluidWidth,\n placeholder,\n onKeyDown,\n onClick,\n onChange,\n onFocus,\n onBlur,\n onPaste,\n onKeyUp,\n hasError,\n readOnly,\n type,\n innerRef,\n clearable = false,\n leftComponent,\n rightComponent,\n value,\n ...rest\n}) => {\n const inputRef = useRef();\n const [maskedValue, setMaskedValue] = useState(value);\n\n const conform = useCallback(\n ({ rawValue, cursorPos, lastkeycode, shouldUpdateCursorPos = true }) => {\n const { nextMaskedValue, maskedPos } = conformValue(\n rawValue,\n cursorPos,\n lastkeycode,\n );\n const event = {\n target: {\n value: nextMaskedValue,\n originalValue: rawValue,\n },\n };\n if (onChange && nextMaskedValue !== maskedValue) onChange(event);\n\n setMaskedValue(nextMaskedValue);\n setRawValue(nextMaskedValue);\n\n if (shouldUpdateCursorPos) setCursorPosition({ current: maskedPos });\n },\n [maskedValue, onChange],\n );\n\n const handleOnChange = useCallback(\n (e) => {\n const { value: rawValue, selectionEnd } = e.target;\n setRawMask(rawValue);\n setRawValue(rawValue);\n setCursorPosition({ current: selectionEnd });\n setFocus(true);\n },\n [setRawMask, setRawValue, setCursorPosition, setFocus, lastkey.code],\n );\n\n useLayoutEffect(() => {\n if (focus) setCaretPosition(inputRef.current, cursorPosition.current);\n }, [focus, cursorPosition]);\n\n useLayoutEffect(() => {\n // if the value changes, then re-conform the mask\n conform({\n rawValue: value,\n cursorPos: cursorPosition.current,\n lastkeycode: lastkey.code,\n shouldUpdateCursorPos: focus,\n });\n }, [focus, value, cursorPosition.current]);\n\n const handleKeyDown = useCallback(\n (e) => {\n e.stopPropagation();\n setLastkey({ key: e.key, code: e.keyCode });\n onKeyDown(e);\n },\n [onKeyDown],\n );\n\n const handleBlur = useCallback(\n (e) => {\n setFocus(false);\n onBlur(e);\n },\n [onBlur],\n );\n\n return (\n <DSTextBox\n {...rest}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n innerRef={(ref) => {\n inputRef.current = ref;\n if (innerRef) innerRef(ref);\n }}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={handleBlur}\n onChange={handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={maskedValue}\n />\n );\n};\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,mBAAsE;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { PropTypes } from '@elliemae/ds-utilities';\nimport { DSTextBox } from '../../TextBox';\nimport { TCharsToAdd } from '../types';\nimport { setCaretPosition } from '../utils/setCaretPosition';\n\nconst conformValue = (\n rawValue: string,\n cursorPos: number,\n lastkeycode: number,\n) => {\n const nextMaskedValue = rawValue\n .split('')\n .filter((char) => char >= '0' && char <= '9')\n .slice(0, 12);\n\n while (nextMaskedValue.length > 8 && !nextMaskedValue[8].match(/[0-2]/))\n nextMaskedValue.splice(8, 1);\n while (nextMaskedValue.length > 10 && !nextMaskedValue[10].match(/[0-5]/))\n nextMaskedValue.splice(10, 1);\n\n let maskedPos = 0;\n for (let i = 0; i < cursorPos; i += 1) {\n if (nextMaskedValue[maskedPos] === rawValue[i]) maskedPos += 1;\n }\n\n // list of [string to add, position to add]\n const charactersToAdd: TCharsToAdd = [\n ['/', 2],\n ['/', 5],\n [' ', 10],\n [':', 13],\n ];\n\n charactersToAdd.forEach(([chars, pos]) => {\n if (nextMaskedValue.length > pos) {\n nextMaskedValue.splice(pos, 0, chars);\n if (maskedPos >= pos) maskedPos += chars.length;\n }\n });\n\n if (lastkeycode !== 8 && maskedPos < nextMaskedValue.length) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos) maskedPos += chars.length;\n });\n } else if (lastkeycode === 8 && maskedPos) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos + 1) maskedPos -= chars.length;\n });\n }\n\n return { nextMaskedValue: nextMaskedValue.join(''), maskedPos };\n};\n\nconst DateTimeInputMask = ({\n focus,\n setFocus,\n setRawMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n style,\n disabled,\n className,\n name,\n maxLength,\n minLength,\n fluidWidth,\n placeholder,\n onKeyDown,\n onClick,\n onChange,\n onFocus,\n onBlur,\n onPaste,\n onKeyUp,\n hasError,\n readOnly,\n type,\n innerRef,\n clearable = false,\n leftComponent,\n rightComponent,\n value,\n ...rest\n}) => {\n const inputRef = useRef();\n const [maskedValue, setMaskedValue] = useState(value);\n\n const conform = useCallback(\n ({ rawValue, cursorPos, lastkeycode, shouldUpdateCursorPos = true }) => {\n const { nextMaskedValue, maskedPos } = conformValue(\n rawValue,\n cursorPos,\n lastkeycode,\n );\n const event = {\n target: {\n value: nextMaskedValue,\n originalValue: rawValue,\n },\n };\n if (onChange && nextMaskedValue !== maskedValue) onChange(event);\n\n setMaskedValue(nextMaskedValue);\n setRawValue(nextMaskedValue);\n\n if (shouldUpdateCursorPos) setCursorPosition({ current: maskedPos });\n },\n [maskedValue, onChange],\n );\n\n const handleOnChange = useCallback(\n (e) => {\n const { value: rawValue, selectionEnd } = e.target;\n setRawMask(rawValue);\n setRawValue(rawValue);\n setCursorPosition({ current: selectionEnd });\n setFocus(true);\n },\n [setRawMask, setRawValue, setCursorPosition, setFocus, lastkey.code],\n );\n\n useLayoutEffect(() => {\n if (focus) setCaretPosition(inputRef.current, cursorPosition.current);\n }, [focus, cursorPosition]);\n\n useLayoutEffect(() => {\n // if the value changes, then re-conform the mask\n conform({\n rawValue: value,\n cursorPos: cursorPosition.current,\n lastkeycode: lastkey.code,\n shouldUpdateCursorPos: focus,\n });\n }, [focus, value, cursorPosition.current]);\n\n const handleKeyDown = useCallback(\n (e) => {\n e.stopPropagation();\n setLastkey({ key: e.key, code: e.keyCode });\n onKeyDown(e);\n },\n [onKeyDown],\n );\n\n const handleBlur = useCallback(\n (e) => {\n setFocus(false);\n onBlur(e);\n },\n [onBlur],\n );\n\n return (\n <DSTextBox\n {...rest}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n innerRef={(ref) => {\n inputRef.current = ref;\n if (innerRef) innerRef(ref);\n }}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={handleBlur}\n onChange={handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={maskedValue}\n />\n );\n};\n\nexport { DateTimeInputMask };\nexport default DateTimeInputMask;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
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A,IACV;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACT;AAEJ;AAGA,IAAO,4BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -55,7 +55,6 @@ __export(DictionaryInputMask_exports, {
|
|
|
55
55
|
module.exports = __toCommonJS(DictionaryInputMask_exports);
|
|
56
56
|
var React = __toESM(require("react"));
|
|
57
57
|
var import_react = __toESM(require("react"));
|
|
58
|
-
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
59
58
|
var import_TextBox = require("../../TextBox");
|
|
60
59
|
var import_setCaretPosition = require("../utils/setCaretPosition");
|
|
61
60
|
const startsWith = (a, b, ignoreCase) => {
|
|
@@ -225,43 +224,5 @@ const DictionaryInputMask = (_a) => {
|
|
|
225
224
|
value: maskedValue
|
|
226
225
|
}));
|
|
227
226
|
};
|
|
228
|
-
DictionaryInputMask.propTypes = {
|
|
229
|
-
focus: import_ds_utilities.PropTypes.bool,
|
|
230
|
-
setFocus: import_ds_utilities.PropTypes.func,
|
|
231
|
-
setRawMask: import_ds_utilities.PropTypes.func,
|
|
232
|
-
cursorPosition: import_ds_utilities.PropTypes.shape({ current: import_ds_utilities.PropTypes.number }),
|
|
233
|
-
setCursorPosition: import_ds_utilities.PropTypes.func,
|
|
234
|
-
lastkey: import_ds_utilities.PropTypes.shape({ code: import_ds_utilities.PropTypes.number, key: import_ds_utilities.PropTypes.string }),
|
|
235
|
-
setLastkey: import_ds_utilities.PropTypes.func,
|
|
236
|
-
setRawValue: import_ds_utilities.PropTypes.func,
|
|
237
|
-
allowedWords: import_ds_utilities.PropTypes.arrayOf(import_ds_utilities.PropTypes.string),
|
|
238
|
-
ignoreCase: import_ds_utilities.PropTypes.bool,
|
|
239
|
-
autoFocus: import_ds_utilities.PropTypes.bool,
|
|
240
|
-
style: import_ds_utilities.PropTypes.object,
|
|
241
|
-
disabled: import_ds_utilities.PropTypes.bool,
|
|
242
|
-
className: import_ds_utilities.PropTypes.string,
|
|
243
|
-
name: import_ds_utilities.PropTypes.string,
|
|
244
|
-
maxLength: import_ds_utilities.PropTypes.number,
|
|
245
|
-
minLength: import_ds_utilities.PropTypes.number,
|
|
246
|
-
fluidWidth: import_ds_utilities.PropTypes.bool,
|
|
247
|
-
placeholder: import_ds_utilities.PropTypes.string,
|
|
248
|
-
value: import_ds_utilities.PropTypes.string,
|
|
249
|
-
onChange: import_ds_utilities.PropTypes.func,
|
|
250
|
-
onKeyDown: import_ds_utilities.PropTypes.func,
|
|
251
|
-
leftComponent: import_ds_utilities.PropTypes.element,
|
|
252
|
-
rightComponent: import_ds_utilities.PropTypes.element,
|
|
253
|
-
onFocus: import_ds_utilities.PropTypes.func,
|
|
254
|
-
onBlur: import_ds_utilities.PropTypes.func,
|
|
255
|
-
onPaste: import_ds_utilities.PropTypes.func,
|
|
256
|
-
onKeyUp: import_ds_utilities.PropTypes.func,
|
|
257
|
-
hasError: import_ds_utilities.PropTypes.bool,
|
|
258
|
-
readOnly: import_ds_utilities.PropTypes.bool,
|
|
259
|
-
onClick: import_ds_utilities.PropTypes.func,
|
|
260
|
-
clearable: import_ds_utilities.PropTypes.bool,
|
|
261
|
-
type: import_ds_utilities.PropTypes.string,
|
|
262
|
-
innerRef: import_ds_utilities.PropTypes.any,
|
|
263
|
-
mask: import_ds_utilities.PropTypes.any,
|
|
264
|
-
placeholderChar: import_ds_utilities.PropTypes.string
|
|
265
|
-
};
|
|
266
227
|
var DictionaryInputMask_default = DictionaryInputMask;
|
|
267
228
|
//# sourceMappingURL=DictionaryInputMask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/InputMask/mask_types/DictionaryInputMask.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable no-loop-func */\n/* eslint-disable max-params */\n/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { PropTypes } from '@elliemae/ds-utilities';\nimport { DSTextBox } from '../../TextBox';\nimport { setCaretPosition } from '../utils/setCaretPosition';\n\nconst startsWith = (a: string, b: string, ignoreCase: boolean): boolean => {\n if (ignoreCase) {\n a = a.toLowerCase();\n b = b.toLowerCase();\n }\n return a.startsWith(b);\n};\n\nconst conformValue = (\n rawValue: string,\n cursorPos: number,\n lastkeycode: number,\n allowedWords: string[],\n ignoreCase: boolean,\n) => {\n let nextMaskedValue = '';\n let currentPosibleWords = allowedWords;\n for (let i = 0; i < rawValue.length; i += 1) {\n const matchingWords = currentPosibleWords.filter((word) =>\n startsWith(word, nextMaskedValue + rawValue[i], ignoreCase),\n );\n if (matchingWords.length) {\n nextMaskedValue += rawValue[i];\n currentPosibleWords = matchingWords;\n }\n }\n\n return { nextMaskedValue, maskedPos: cursorPos };\n};\n\nconst DictionaryInputMask = ({\n focus,\n setFocus,\n setRawMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n allowedWords,\n ignoreCase = true,\n autoFocus,\n style,\n disabled,\n className,\n name,\n maxLength,\n minLength,\n fluidWidth,\n placeholder,\n onKeyDown,\n onClick,\n onChange,\n onFocus,\n onBlur,\n onPaste,\n onKeyUp,\n hasError,\n readOnly,\n type,\n innerRef,\n clearable = false,\n leftComponent,\n rightComponent,\n value,\n ...rest\n}) => {\n const inputRef = useRef();\n const [maskedValue, setMaskedValue] = useState(value);\n\n const conform = useCallback(\n ({ rawValue, cursorPos, lastkeycode, shouldUpdateCursorPos = true }) => {\n const { nextMaskedValue, maskedPos } = conformValue(\n rawValue,\n cursorPos,\n lastkeycode,\n allowedWords,\n ignoreCase,\n );\n const event = {\n target: {\n value: nextMaskedValue,\n originalValue: rawValue,\n },\n };\n if (onChange && nextMaskedValue !== maskedValue) onChange(event);\n\n setMaskedValue(nextMaskedValue);\n setRawValue(nextMaskedValue);\n\n if (shouldUpdateCursorPos) setCursorPosition({ current: maskedPos });\n },\n [maskedValue, onChange],\n );\n\n const handleOnChange = useCallback(\n (e) => {\n const { value: rawValue, selectionEnd } = e.target;\n setRawMask(rawValue);\n setRawValue(rawValue);\n setCursorPosition({ current: selectionEnd });\n setFocus(true);\n },\n [setRawMask, setRawValue, setCursorPosition, setFocus, lastkey.code],\n );\n\n useLayoutEffect(() => {\n if (focus) setCaretPosition(inputRef.current, cursorPosition.current);\n }, [focus, cursorPosition]);\n\n useLayoutEffect(() => {\n // if the value changes, then re-conform the mask\n conform({\n rawValue: value,\n cursorPos: cursorPosition.current,\n lastkeycode: lastkey.code,\n shouldUpdateCursorPos: focus,\n });\n }, [focus, value, cursorPosition.current]);\n\n const handleKeyDown = useCallback(\n (e) => {\n e.stopPropagation();\n setLastkey({ key: e.key, code: e.keyCode });\n onKeyDown(e);\n },\n [onKeyDown],\n );\n\n const handleBlur = useCallback(\n (e) => {\n setFocus(false);\n onBlur(e);\n },\n [onBlur],\n );\n\n return (\n <DSTextBox\n {...rest}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n innerRef={(ref) => {\n inputRef.current = ref;\n if (innerRef) innerRef(ref);\n }}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={handleBlur}\n onChange={handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={maskedValue}\n />\n );\n};\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAsE;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-loop-func */\n/* eslint-disable max-params */\n/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { PropTypes } from '@elliemae/ds-utilities';\nimport { DSTextBox } from '../../TextBox';\nimport { setCaretPosition } from '../utils/setCaretPosition';\n\nconst startsWith = (a: string, b: string, ignoreCase: boolean): boolean => {\n if (ignoreCase) {\n a = a.toLowerCase();\n b = b.toLowerCase();\n }\n return a.startsWith(b);\n};\n\nconst conformValue = (\n rawValue: string,\n cursorPos: number,\n lastkeycode: number,\n allowedWords: string[],\n ignoreCase: boolean,\n) => {\n let nextMaskedValue = '';\n let currentPosibleWords = allowedWords;\n for (let i = 0; i < rawValue.length; i += 1) {\n const matchingWords = currentPosibleWords.filter((word) =>\n startsWith(word, nextMaskedValue + rawValue[i], ignoreCase),\n );\n if (matchingWords.length) {\n nextMaskedValue += rawValue[i];\n currentPosibleWords = matchingWords;\n }\n }\n\n return { nextMaskedValue, maskedPos: cursorPos };\n};\n\nconst DictionaryInputMask = ({\n focus,\n setFocus,\n setRawMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n allowedWords,\n ignoreCase = true,\n autoFocus,\n style,\n disabled,\n className,\n name,\n maxLength,\n minLength,\n fluidWidth,\n placeholder,\n onKeyDown,\n onClick,\n onChange,\n onFocus,\n onBlur,\n onPaste,\n onKeyUp,\n hasError,\n readOnly,\n type,\n innerRef,\n clearable = false,\n leftComponent,\n rightComponent,\n value,\n ...rest\n}) => {\n const inputRef = useRef();\n const [maskedValue, setMaskedValue] = useState(value);\n\n const conform = useCallback(\n ({ rawValue, cursorPos, lastkeycode, shouldUpdateCursorPos = true }) => {\n const { nextMaskedValue, maskedPos } = conformValue(\n rawValue,\n cursorPos,\n lastkeycode,\n allowedWords,\n ignoreCase,\n );\n const event = {\n target: {\n value: nextMaskedValue,\n originalValue: rawValue,\n },\n };\n if (onChange && nextMaskedValue !== maskedValue) onChange(event);\n\n setMaskedValue(nextMaskedValue);\n setRawValue(nextMaskedValue);\n\n if (shouldUpdateCursorPos) setCursorPosition({ current: maskedPos });\n },\n [maskedValue, onChange],\n );\n\n const handleOnChange = useCallback(\n (e) => {\n const { value: rawValue, selectionEnd } = e.target;\n setRawMask(rawValue);\n setRawValue(rawValue);\n setCursorPosition({ current: selectionEnd });\n setFocus(true);\n },\n [setRawMask, setRawValue, setCursorPosition, setFocus, lastkey.code],\n );\n\n useLayoutEffect(() => {\n if (focus) setCaretPosition(inputRef.current, cursorPosition.current);\n }, [focus, cursorPosition]);\n\n useLayoutEffect(() => {\n // if the value changes, then re-conform the mask\n conform({\n rawValue: value,\n cursorPos: cursorPosition.current,\n lastkeycode: lastkey.code,\n shouldUpdateCursorPos: focus,\n });\n }, [focus, value, cursorPosition.current]);\n\n const handleKeyDown = useCallback(\n (e) => {\n e.stopPropagation();\n setLastkey({ key: e.key, code: e.keyCode });\n onKeyDown(e);\n },\n [onKeyDown],\n );\n\n const handleBlur = useCallback(\n (e) => {\n setFocus(false);\n onBlur(e);\n },\n [onBlur],\n );\n\n return (\n <DSTextBox\n {...rest}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n innerRef={(ref) => {\n inputRef.current = ref;\n if (innerRef) innerRef(ref);\n }}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={handleBlur}\n onChange={handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={maskedValue}\n />\n );\n};\n\nexport { DictionaryInputMask };\nexport default DictionaryInputMask;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAC,OAAO,OAAO,eAAe,OAAO,CAAC;AAEzC,QAAM,gBAAgB,8BACpB,CAAC,MAAM;AACL,MAAE,gBAAgB;AAClB,eAAW,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,QAAQ,CAAC;AAC1C,cAAU,CAAC;AAAA,EACb,GACA,CAAC,SAAS,CACZ;AAEA,QAAM,aAAa,8BACjB,CAAC,MAAM;AACL,aAAS,KAAK;AACd,WAAO,CAAC;AAAA,EACV,GACA,CAAC,MAAM,CACT;AAEA,SACE,mDAAC,2DACK,OADL;AAAA,IAEC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC,QAAQ;AACjB,eAAS,UAAU;AACnB,UAAI;AAAU,iBAAS,GAAG;AAAA,IAC5B;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACT;AAEJ;AAGA,IAAO,8BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -55,7 +55,6 @@ __export(NumberInputMask_exports, {
|
|
|
55
55
|
module.exports = __toCommonJS(NumberInputMask_exports);
|
|
56
56
|
var React = __toESM(require("react"));
|
|
57
57
|
var import_react = __toESM(require("react"));
|
|
58
|
-
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
59
58
|
var import_TextBox = require("../../TextBox");
|
|
60
59
|
var import_setCaretPosition = require("../utils/setCaretPosition");
|
|
61
60
|
const addThousandsSeparator = (n, thousandsSeparatorSymbol) => n.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSeparatorSymbol);
|
|
@@ -335,52 +334,5 @@ const NumberInputMask = (_a) => {
|
|
|
335
334
|
value: maskedValue
|
|
336
335
|
}));
|
|
337
336
|
};
|
|
338
|
-
NumberInputMask.propTypes = {
|
|
339
|
-
focus: import_ds_utilities.PropTypes.bool,
|
|
340
|
-
setFocus: import_ds_utilities.PropTypes.func,
|
|
341
|
-
setRawMask: import_ds_utilities.PropTypes.func,
|
|
342
|
-
cursorPosition: import_ds_utilities.PropTypes.shape({ current: import_ds_utilities.PropTypes.number }),
|
|
343
|
-
setCursorPosition: import_ds_utilities.PropTypes.func,
|
|
344
|
-
lastkey: import_ds_utilities.PropTypes.shape({ code: import_ds_utilities.PropTypes.number, key: import_ds_utilities.PropTypes.string }),
|
|
345
|
-
setLastkey: import_ds_utilities.PropTypes.func,
|
|
346
|
-
setRawValue: import_ds_utilities.PropTypes.func,
|
|
347
|
-
allowDecimal: import_ds_utilities.PropTypes.bool,
|
|
348
|
-
allowLeadingZeroes: import_ds_utilities.PropTypes.bool,
|
|
349
|
-
allowNegative: import_ds_utilities.PropTypes.bool,
|
|
350
|
-
autoFocus: import_ds_utilities.PropTypes.bool,
|
|
351
|
-
className: import_ds_utilities.PropTypes.string,
|
|
352
|
-
clearable: import_ds_utilities.PropTypes.bool,
|
|
353
|
-
decimalLimit: import_ds_utilities.PropTypes.number,
|
|
354
|
-
decimalSymbol: import_ds_utilities.PropTypes.string,
|
|
355
|
-
disabled: import_ds_utilities.PropTypes.bool,
|
|
356
|
-
fluidWidth: import_ds_utilities.PropTypes.bool,
|
|
357
|
-
hasError: import_ds_utilities.PropTypes.bool,
|
|
358
|
-
includeThousandsSeparator: import_ds_utilities.PropTypes.bool,
|
|
359
|
-
innerRef: import_ds_utilities.PropTypes.any,
|
|
360
|
-
integerLimit: import_ds_utilities.PropTypes.number,
|
|
361
|
-
leftComponent: import_ds_utilities.PropTypes.element,
|
|
362
|
-
mask: import_ds_utilities.PropTypes.any,
|
|
363
|
-
maxLength: import_ds_utilities.PropTypes.number,
|
|
364
|
-
minLength: import_ds_utilities.PropTypes.number,
|
|
365
|
-
name: import_ds_utilities.PropTypes.string,
|
|
366
|
-
onBlur: import_ds_utilities.PropTypes.func,
|
|
367
|
-
onChange: import_ds_utilities.PropTypes.func,
|
|
368
|
-
onClick: import_ds_utilities.PropTypes.func,
|
|
369
|
-
onFocus: import_ds_utilities.PropTypes.func,
|
|
370
|
-
onKeyDown: import_ds_utilities.PropTypes.func,
|
|
371
|
-
onKeyUp: import_ds_utilities.PropTypes.func,
|
|
372
|
-
onPaste: import_ds_utilities.PropTypes.func,
|
|
373
|
-
placeholder: import_ds_utilities.PropTypes.string,
|
|
374
|
-
placeholderChar: import_ds_utilities.PropTypes.string,
|
|
375
|
-
prefix: import_ds_utilities.PropTypes.string,
|
|
376
|
-
readOnly: import_ds_utilities.PropTypes.bool,
|
|
377
|
-
requireDecimal: import_ds_utilities.PropTypes.bool,
|
|
378
|
-
rightComponent: import_ds_utilities.PropTypes.element,
|
|
379
|
-
style: import_ds_utilities.PropTypes.object,
|
|
380
|
-
suffix: import_ds_utilities.PropTypes.string,
|
|
381
|
-
thousandsSeparatorSymbol: import_ds_utilities.PropTypes.string,
|
|
382
|
-
type: import_ds_utilities.PropTypes.string,
|
|
383
|
-
value: import_ds_utilities.PropTypes.string
|
|
384
|
-
};
|
|
385
337
|
var NumberInputMask_default = NumberInputMask;
|
|
386
338
|
//# sourceMappingURL=NumberInputMask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/InputMask/mask_types/NumberInputMask.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-params */\n/* eslint-disable max-statements */\n/* eslint-disable max-lines */\n/* eslint-disable complexity */\n\nimport React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { PropTypes } from '@elliemae/ds-utilities';\nimport { DSTextBox } from '../../TextBox';\nimport { setCaretPosition } from '../utils/setCaretPosition';\n\n// http://stackoverflow.com/a/10899795/604296\nconst addThousandsSeparator = (n, thousandsSeparatorSymbol) =>\n n.replace(/\\B(?=(\\d{3})+(?!\\d))/g, thousandsSeparatorSymbol);\n\nconst conformValue = (\n prevRawValue,\n prevCursorPos,\n lastkeycode,\n {\n prefix,\n suffix,\n includeThousandsSeparator,\n thousandsSeparatorSymbol,\n allowDecimal,\n decimalSymbol,\n decimalLimit,\n requireDecimal,\n allowNegative,\n allowLeadingZeroes,\n integerLimit,\n shouldCompleteDecimals,\n },\n) => {\n const prefixIndex = prevRawValue.indexOf(prefix);\n const suffixIndex = prevRawValue.lastIndexOf(suffix);\n const negativeIndex = prevRawValue.indexOf('-');\n\n const cursorPos = prevCursorPos - (prefixIndex === -1 ? 0 : prefixIndex + prefix.length);\n\n const rawValue = prevRawValue.substring(\n prefixIndex === -1 ? 0 : prefixIndex + prefix.length,\n suffixIndex === -1 ? prevRawValue.length : suffixIndex,\n );\n\n const filteredRawValue = rawValue\n .split('')\n .filter((char) => (char >= '0' && char <= '9') || char === decimalSymbol || char === '-');\n\n let isNegative = allowNegative && negativeIndex !== -1 && (prefixIndex === -1 || negativeIndex < prefixIndex);\n\n let integer = '';\n let decimal = '';\n let foundDecimalSymbol = false;\n\n const integerFits = () => integerLimit === null || integer.length < integerLimit;\n const decimalFits = () => decimalLimit === null || decimal.length < decimalLimit;\n\n filteredRawValue.forEach((char) => {\n if (allowDecimal && !foundDecimalSymbol && char === decimalSymbol) {\n foundDecimalSymbol = true;\n } else if (allowNegative && !integer.length && !foundDecimalSymbol && char === '-') {\n isNegative = true;\n } else if (char >= '0' && char <= '9') {\n if (!foundDecimalSymbol && integerFits()) {\n integer += char;\n } else if (foundDecimalSymbol && decimalFits()) {\n decimal += char;\n }\n }\n });\n\n if (requireDecimal) foundDecimalSymbol = true;\n if (!requireDecimal && !decimal?.length && lastkeycode === 8) {\n foundDecimalSymbol = false;\n }\n if (!integer && !decimal) foundDecimalSymbol = false;\n\n if (foundDecimalSymbol && !integer && decimal) {\n integer = '0';\n }\n\n if (!allowLeadingZeroes) {\n while (integer.length > 1 && integer[0] === '0') integer = integer.substring(1);\n }\n\n let nextMaskedValue = includeThousandsSeparator ? addThousandsSeparator(integer, thousandsSeparatorSymbol) : integer;\n nextMaskedValue += foundDecimalSymbol ? decimalSymbol : '';\n\n if (shouldCompleteDecimals) while (decimal.length !== decimalLimit) decimal += '0';\n\n nextMaskedValue += decimal;\n\n let maskedPos = 0;\n for (let i = 0; i < cursorPos; i += 1) {\n if (nextMaskedValue[maskedPos] === thousandsSeparatorSymbol) maskedPos += 1;\n if (nextMaskedValue[maskedPos] === rawValue[i]) maskedPos += 1;\n }\n if (nextMaskedValue.length || isNegative) {\n nextMaskedValue = prefix + nextMaskedValue;\n maskedPos += prefix.length;\n\n if (isNegative) {\n if (lastkeycode !== 8 || nextMaskedValue !== prefix) nextMaskedValue = `-${nextMaskedValue}`;\n maskedPos += 1;\n }\n\n nextMaskedValue += suffix;\n }\n\n if (lastkeycode !== 8 && maskedPos < nextMaskedValue.length) {\n if (nextMaskedValue[maskedPos] === decimalSymbol && integer.length === integerLimit) {\n maskedPos += 1;\n } else if (nextMaskedValue[maskedPos] === thousandsSeparatorSymbol) {\n maskedPos += 1;\n }\n }\n\n return {\n nextMaskedValue,\n maskedPos: Math.min(maskedPos, nextMaskedValue.length - suffix.length),\n };\n};\n\nconst NumberInputMask = ({\n focus,\n setFocus,\n setRawMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n allowDecimal,\n allowLeadingZeroes,\n allowNegative,\n autoFocus,\n className,\n clearable = false,\n decimalLimit,\n decimalSymbol,\n disabled,\n fluidWidth,\n hasError,\n includeThousandsSeparator,\n innerRef,\n integerLimit,\n leftComponent,\n maxLength,\n minLength,\n name,\n onBlur,\n onChange,\n onClick,\n onFocus,\n onKeyDown,\n onKeyUp,\n onPaste,\n placeholder,\n prefix,\n readOnly,\n requireDecimal,\n rightComponent,\n style,\n suffix,\n thousandsSeparatorSymbol,\n type,\n value,\n ...rest\n}) => {\n const inputRef = useRef();\n const [maskedValue, setMaskedValue] = useState(value);\n\n const conform = useCallback(\n ({ rawValue, cursorPos, lastkeycode, shouldUpdateCursorPos = true, shouldCompleteDecimals = false }) => {\n const { nextMaskedValue, maskedPos } = conformValue(rawValue, cursorPos, lastkeycode, {\n prefix,\n suffix,\n includeThousandsSeparator,\n thousandsSeparatorSymbol,\n allowDecimal,\n decimalSymbol,\n decimalLimit,\n requireDecimal,\n allowNegative,\n allowLeadingZeroes,\n integerLimit,\n shouldCompleteDecimals,\n });\n const event = {\n target: {\n value: nextMaskedValue,\n originalValue: rawValue,\n },\n };\n if (onChange && nextMaskedValue !== maskedValue) onChange(event);\n\n setMaskedValue(nextMaskedValue);\n setRawValue(nextMaskedValue);\n\n if (shouldUpdateCursorPos) setCursorPosition({ current: maskedPos });\n },\n [maskedValue, onChange],\n );\n\n const handleOnChange = useCallback(\n (e) => {\n const { value: rawValue, selectionEnd } = e.target;\n setRawMask(rawValue);\n setRawValue(rawValue);\n setCursorPosition({ current: selectionEnd });\n setFocus(true);\n },\n [setRawMask, setRawValue, setCursorPosition, setFocus, lastkey.code],\n );\n\n useLayoutEffect(() => {\n if (focus) setCaretPosition(inputRef.current, cursorPosition.current);\n }, [focus, cursorPosition]);\n\n useLayoutEffect(() => {\n // if the value changes, then re-conform the mask\n conform({\n rawValue: value,\n cursorPos: cursorPosition.current,\n lastkeycode: lastkey.code,\n shouldUpdateCursorPos: focus,\n });\n }, [focus, value, cursorPosition.current]);\n\n const handleKeyDown = useCallback(\n (e) => {\n e.stopPropagation();\n setLastkey({ key: e.key, code: e.keyCode });\n onKeyDown(e);\n },\n [onKeyDown],\n );\n\n const handleBlur = useCallback(\n (e) => {\n setFocus(false);\n onBlur(e);\n if (requireDecimal && maskedValue !== '') {\n conform({\n rawValue: maskedValue,\n cursorPos: 0,\n lastkey: 0,\n shouldUpdateCursorPos: 0,\n shouldCompleteDecimals: true,\n });\n }\n },\n [maskedValue, requireDecimal, suffix, decimalLimit, onBlur],\n );\n\n return (\n <DSTextBox\n {...rest}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n innerRef={(ref) => {\n inputRef.current = ref;\n if (innerRef) innerRef(ref);\n }}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={handleBlur}\n onChange={handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={maskedValue}\n />\n );\n};\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,mBAAsE;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-params */\n/* eslint-disable max-statements */\n/* eslint-disable max-lines */\n/* eslint-disable complexity */\n\nimport React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { PropTypes } from '@elliemae/ds-utilities';\nimport { DSTextBox } from '../../TextBox';\nimport { setCaretPosition } from '../utils/setCaretPosition';\n\n// http://stackoverflow.com/a/10899795/604296\nconst addThousandsSeparator = (n, thousandsSeparatorSymbol) =>\n n.replace(/\\B(?=(\\d{3})+(?!\\d))/g, thousandsSeparatorSymbol);\n\nconst conformValue = (\n prevRawValue,\n prevCursorPos,\n lastkeycode,\n {\n prefix,\n suffix,\n includeThousandsSeparator,\n thousandsSeparatorSymbol,\n allowDecimal,\n decimalSymbol,\n decimalLimit,\n requireDecimal,\n allowNegative,\n allowLeadingZeroes,\n integerLimit,\n shouldCompleteDecimals,\n },\n) => {\n const prefixIndex = prevRawValue.indexOf(prefix);\n const suffixIndex = prevRawValue.lastIndexOf(suffix);\n const negativeIndex = prevRawValue.indexOf('-');\n\n const cursorPos = prevCursorPos - (prefixIndex === -1 ? 0 : prefixIndex + prefix.length);\n\n const rawValue = prevRawValue.substring(\n prefixIndex === -1 ? 0 : prefixIndex + prefix.length,\n suffixIndex === -1 ? prevRawValue.length : suffixIndex,\n );\n\n const filteredRawValue = rawValue\n .split('')\n .filter((char) => (char >= '0' && char <= '9') || char === decimalSymbol || char === '-');\n\n let isNegative = allowNegative && negativeIndex !== -1 && (prefixIndex === -1 || negativeIndex < prefixIndex);\n\n let integer = '';\n let decimal = '';\n let foundDecimalSymbol = false;\n\n const integerFits = () => integerLimit === null || integer.length < integerLimit;\n const decimalFits = () => decimalLimit === null || decimal.length < decimalLimit;\n\n filteredRawValue.forEach((char) => {\n if (allowDecimal && !foundDecimalSymbol && char === decimalSymbol) {\n foundDecimalSymbol = true;\n } else if (allowNegative && !integer.length && !foundDecimalSymbol && char === '-') {\n isNegative = true;\n } else if (char >= '0' && char <= '9') {\n if (!foundDecimalSymbol && integerFits()) {\n integer += char;\n } else if (foundDecimalSymbol && decimalFits()) {\n decimal += char;\n }\n }\n });\n\n if (requireDecimal) foundDecimalSymbol = true;\n if (!requireDecimal && !decimal?.length && lastkeycode === 8) {\n foundDecimalSymbol = false;\n }\n if (!integer && !decimal) foundDecimalSymbol = false;\n\n if (foundDecimalSymbol && !integer && decimal) {\n integer = '0';\n }\n\n if (!allowLeadingZeroes) {\n while (integer.length > 1 && integer[0] === '0') integer = integer.substring(1);\n }\n\n let nextMaskedValue = includeThousandsSeparator ? addThousandsSeparator(integer, thousandsSeparatorSymbol) : integer;\n nextMaskedValue += foundDecimalSymbol ? decimalSymbol : '';\n\n if (shouldCompleteDecimals) while (decimal.length !== decimalLimit) decimal += '0';\n\n nextMaskedValue += decimal;\n\n let maskedPos = 0;\n for (let i = 0; i < cursorPos; i += 1) {\n if (nextMaskedValue[maskedPos] === thousandsSeparatorSymbol) maskedPos += 1;\n if (nextMaskedValue[maskedPos] === rawValue[i]) maskedPos += 1;\n }\n if (nextMaskedValue.length || isNegative) {\n nextMaskedValue = prefix + nextMaskedValue;\n maskedPos += prefix.length;\n\n if (isNegative) {\n if (lastkeycode !== 8 || nextMaskedValue !== prefix) nextMaskedValue = `-${nextMaskedValue}`;\n maskedPos += 1;\n }\n\n nextMaskedValue += suffix;\n }\n\n if (lastkeycode !== 8 && maskedPos < nextMaskedValue.length) {\n if (nextMaskedValue[maskedPos] === decimalSymbol && integer.length === integerLimit) {\n maskedPos += 1;\n } else if (nextMaskedValue[maskedPos] === thousandsSeparatorSymbol) {\n maskedPos += 1;\n }\n }\n\n return {\n nextMaskedValue,\n maskedPos: Math.min(maskedPos, nextMaskedValue.length - suffix.length),\n };\n};\n\nconst NumberInputMask = ({\n focus,\n setFocus,\n setRawMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n allowDecimal,\n allowLeadingZeroes,\n allowNegative,\n autoFocus,\n className,\n clearable = false,\n decimalLimit,\n decimalSymbol,\n disabled,\n fluidWidth,\n hasError,\n includeThousandsSeparator,\n innerRef,\n integerLimit,\n leftComponent,\n maxLength,\n minLength,\n name,\n onBlur,\n onChange,\n onClick,\n onFocus,\n onKeyDown,\n onKeyUp,\n onPaste,\n placeholder,\n prefix,\n readOnly,\n requireDecimal,\n rightComponent,\n style,\n suffix,\n thousandsSeparatorSymbol,\n type,\n value,\n ...rest\n}) => {\n const inputRef = useRef();\n const [maskedValue, setMaskedValue] = useState(value);\n\n const conform = useCallback(\n ({ rawValue, cursorPos, lastkeycode, shouldUpdateCursorPos = true, shouldCompleteDecimals = false }) => {\n const { nextMaskedValue, maskedPos } = conformValue(rawValue, cursorPos, lastkeycode, {\n prefix,\n suffix,\n includeThousandsSeparator,\n thousandsSeparatorSymbol,\n allowDecimal,\n decimalSymbol,\n decimalLimit,\n requireDecimal,\n allowNegative,\n allowLeadingZeroes,\n integerLimit,\n shouldCompleteDecimals,\n });\n const event = {\n target: {\n value: nextMaskedValue,\n originalValue: rawValue,\n },\n };\n if (onChange && nextMaskedValue !== maskedValue) onChange(event);\n\n setMaskedValue(nextMaskedValue);\n setRawValue(nextMaskedValue);\n\n if (shouldUpdateCursorPos) setCursorPosition({ current: maskedPos });\n },\n [maskedValue, onChange],\n );\n\n const handleOnChange = useCallback(\n (e) => {\n const { value: rawValue, selectionEnd } = e.target;\n setRawMask(rawValue);\n setRawValue(rawValue);\n setCursorPosition({ current: selectionEnd });\n setFocus(true);\n },\n [setRawMask, setRawValue, setCursorPosition, setFocus, lastkey.code],\n );\n\n useLayoutEffect(() => {\n if (focus) setCaretPosition(inputRef.current, cursorPosition.current);\n }, [focus, cursorPosition]);\n\n useLayoutEffect(() => {\n // if the value changes, then re-conform the mask\n conform({\n rawValue: value,\n cursorPos: cursorPosition.current,\n lastkeycode: lastkey.code,\n shouldUpdateCursorPos: focus,\n });\n }, [focus, value, cursorPosition.current]);\n\n const handleKeyDown = useCallback(\n (e) => {\n e.stopPropagation();\n setLastkey({ key: e.key, code: e.keyCode });\n onKeyDown(e);\n },\n [onKeyDown],\n );\n\n const handleBlur = useCallback(\n (e) => {\n setFocus(false);\n onBlur(e);\n if (requireDecimal && maskedValue !== '') {\n conform({\n rawValue: maskedValue,\n cursorPos: 0,\n lastkey: 0,\n shouldUpdateCursorPos: 0,\n shouldCompleteDecimals: true,\n });\n }\n },\n [maskedValue, requireDecimal, suffix, decimalLimit, onBlur],\n );\n\n return (\n <DSTextBox\n {...rest}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n innerRef={(ref) => {\n inputRef.current = ref;\n if (innerRef) innerRef(ref);\n }}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={handleBlur}\n onChange={handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={maskedValue}\n />\n );\n};\n\nexport { N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,EAAE,KAAK,MAAM,EAAE,QAAQ,CAAC;AAC1C,cAAU,CAAC;AAAA,EACb,GACA,CAAC,SAAS,CACZ;AAEA,QAAM,aAAa,8BACjB,CAAC,MAAM;AACL,aAAS,KAAK;AACd,WAAO,CAAC;AACR,QAAI,kBAAkB,gBAAgB,IAAI;AACxC,cAAQ;AAAA,QACN,UAAU;AAAA,QACV,WAAW;AAAA,QACX,SAAS;AAAA,QACT,uBAAuB;AAAA,QACvB,wBAAwB;AAAA,MAC1B,CAAC;AAAA,IACH;AAAA,EACF,GACA,CAAC,aAAa,gBAAgB,QAAQ,cAAc,MAAM,CAC5D;AAEA,SACE,mDAAC,2DACK,OADL;AAAA,IAEC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC,QAAQ;AACjB,eAAS,UAAU;AACnB,UAAI;AAAU,iBAAS,GAAG;AAAA,IAC5B;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACT;AAEJ;AAGA,IAAO,0BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -55,7 +55,6 @@ __export(PhoneInputMask_exports, {
|
|
|
55
55
|
module.exports = __toCommonJS(PhoneInputMask_exports);
|
|
56
56
|
var React = __toESM(require("react"));
|
|
57
57
|
var import_react = __toESM(require("react"));
|
|
58
|
-
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
59
58
|
var import_TextBox = require("../../TextBox");
|
|
60
59
|
var import_setCaretPosition = require("../utils/setCaretPosition");
|
|
61
60
|
const conformValue = (rawValue, cursorPos, lastkeycode) => {
|
|
@@ -235,40 +234,5 @@ const PhoneInputMask = (_a) => {
|
|
|
235
234
|
value: maskedValue
|
|
236
235
|
}));
|
|
237
236
|
};
|
|
238
|
-
PhoneInputMask.propTypes = {
|
|
239
|
-
focus: import_ds_utilities.PropTypes.bool,
|
|
240
|
-
setFocus: import_ds_utilities.PropTypes.func,
|
|
241
|
-
setRawMask: import_ds_utilities.PropTypes.func,
|
|
242
|
-
cursorPosition: import_ds_utilities.PropTypes.shape({ current: import_ds_utilities.PropTypes.number }),
|
|
243
|
-
setCursorPosition: import_ds_utilities.PropTypes.func,
|
|
244
|
-
lastkey: import_ds_utilities.PropTypes.shape({ code: import_ds_utilities.PropTypes.number, key: import_ds_utilities.PropTypes.string }),
|
|
245
|
-
setLastkey: import_ds_utilities.PropTypes.func,
|
|
246
|
-
setRawValue: import_ds_utilities.PropTypes.func,
|
|
247
|
-
style: import_ds_utilities.PropTypes.object,
|
|
248
|
-
disabled: import_ds_utilities.PropTypes.bool,
|
|
249
|
-
className: import_ds_utilities.PropTypes.string,
|
|
250
|
-
name: import_ds_utilities.PropTypes.string,
|
|
251
|
-
maxLength: import_ds_utilities.PropTypes.number,
|
|
252
|
-
minLength: import_ds_utilities.PropTypes.number,
|
|
253
|
-
fluidWidth: import_ds_utilities.PropTypes.bool,
|
|
254
|
-
placeholder: import_ds_utilities.PropTypes.string,
|
|
255
|
-
value: import_ds_utilities.PropTypes.string,
|
|
256
|
-
onChange: import_ds_utilities.PropTypes.func,
|
|
257
|
-
onKeyDown: import_ds_utilities.PropTypes.func,
|
|
258
|
-
leftComponent: import_ds_utilities.PropTypes.element,
|
|
259
|
-
rightComponent: import_ds_utilities.PropTypes.element,
|
|
260
|
-
onFocus: import_ds_utilities.PropTypes.func,
|
|
261
|
-
onBlur: import_ds_utilities.PropTypes.func,
|
|
262
|
-
onPaste: import_ds_utilities.PropTypes.func,
|
|
263
|
-
onKeyUp: import_ds_utilities.PropTypes.func,
|
|
264
|
-
hasError: import_ds_utilities.PropTypes.bool,
|
|
265
|
-
readOnly: import_ds_utilities.PropTypes.bool,
|
|
266
|
-
onClick: import_ds_utilities.PropTypes.func,
|
|
267
|
-
clearable: import_ds_utilities.PropTypes.bool,
|
|
268
|
-
type: import_ds_utilities.PropTypes.string,
|
|
269
|
-
innerRef: import_ds_utilities.PropTypes.any,
|
|
270
|
-
mask: import_ds_utilities.PropTypes.any,
|
|
271
|
-
placeholderChar: import_ds_utilities.PropTypes.string
|
|
272
|
-
};
|
|
273
237
|
var PhoneInputMask_default = PhoneInputMask;
|
|
274
238
|
//# sourceMappingURL=PhoneInputMask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/InputMask/mask_types/PhoneInputMask.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { PropTypes } from '@elliemae/ds-utilities';\nimport { DSTextBox } from '../../TextBox';\nimport { TCharsToAdd } from '../types';\nimport { setCaretPosition } from '../utils/setCaretPosition';\n\nconst conformValue = (rawValue, cursorPos, lastkeycode) => {\n let nextMaskedValue = rawValue\n .split('')\n .filter((char) => char >= '0' && char <= '9');\n\n while (nextMaskedValue.length && nextMaskedValue[0] === '0')\n nextMaskedValue.splice(0, 1);\n\n nextMaskedValue = nextMaskedValue.slice(0, 10);\n\n let maskedPos = 0;\n for (let i = 0; i < cursorPos; i += 1) {\n if (nextMaskedValue[maskedPos] === rawValue[i]) maskedPos += 1;\n }\n\n // list of [string to add, position to add]\nconst charactersToAdd: TCharsToAdd = [\n ['(', 0],\n [') ', 4],\n ['-', 9],\n ];\n\n charactersToAdd.forEach(([chars, pos]) => {\n if (nextMaskedValue.length > pos) {\n nextMaskedValue.splice(pos, 0, ...chars);\n if (maskedPos >= pos) maskedPos += chars.length;\n }\n });\n\n if (lastkeycode !== 8 && maskedPos < nextMaskedValue.length) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos) maskedPos += chars.length;\n });\n } else if (lastkeycode === 8 && maskedPos) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos + 1) maskedPos -= chars.length;\n });\n }\n return { nextMaskedValue: nextMaskedValue.join(''), maskedPos };\n};\n\nconst PhoneInputMask = ({\n focus,\n setFocus,\n setRawMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n style,\n disabled,\n className,\n name,\n maxLength,\n minLength,\n fluidWidth,\n placeholder,\n onKeyDown,\n onClick,\n onChange,\n onFocus,\n onBlur,\n onPaste,\n onKeyUp,\n hasError,\n readOnly,\n type,\n innerRef,\n clearable = false,\n leftComponent,\n rightComponent,\n value,\n ...rest\n}) => {\n const inputRef = useRef();\n const [maskedValue, setMaskedValue] = useState(value);\n\n const conform = useCallback(\n ({ rawValue, cursorPos, lastkeycode, shouldUpdateCursorPos = true }) => {\n const { nextMaskedValue, maskedPos } = conformValue(\n rawValue,\n cursorPos,\n lastkeycode,\n );\n const event = {\n target: {\n value: nextMaskedValue,\n originalValue: rawValue,\n },\n };\n if (onChange && nextMaskedValue !== maskedValue) onChange(event);\n\n setMaskedValue(nextMaskedValue);\n setRawValue(nextMaskedValue);\n\n if (shouldUpdateCursorPos) setCursorPosition({ current: maskedPos });\n },\n [maskedValue, onChange],\n );\n\n const handleOnChange = useCallback(\n (e) => {\n const { value: rawValue, selectionEnd } = e.target;\n setRawMask(rawValue);\n setRawValue(rawValue);\n setCursorPosition({ current: selectionEnd });\n setFocus(true);\n },\n [setRawMask, setRawValue, setCursorPosition, setFocus, lastkey.code],\n );\n\n useLayoutEffect(() => {\n if (focus) setCaretPosition(inputRef.current, cursorPosition.current);\n }, [focus, cursorPosition]);\n\n useLayoutEffect(() => {\n // if the value changes, then re-conform the mask\n conform({\n rawValue: value,\n cursorPos: cursorPosition.current,\n lastkeycode: lastkey.code,\n shouldUpdateCursorPos: focus,\n });\n }, [focus, value, cursorPosition.current]);\n\n const handleKeyDown = useCallback(\n (e) => {\n e.stopPropagation();\n setLastkey({ key: e.key, code: e.keyCode });\n onKeyDown(e);\n },\n [onKeyDown],\n );\n\n const handleBlur = useCallback(\n (e) => {\n setFocus(false);\n onBlur(e);\n },\n [onBlur],\n );\n\n return (\n <DSTextBox\n {...rest}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n innerRef={(ref) => {\n inputRef.current = ref;\n if (innerRef) innerRef(ref);\n }}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={handleBlur}\n onChange={handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={maskedValue}\n />\n );\n};\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAsE;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React, { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { PropTypes } from '@elliemae/ds-utilities';\nimport { DSTextBox } from '../../TextBox';\nimport { TCharsToAdd } from '../types';\nimport { setCaretPosition } from '../utils/setCaretPosition';\n\nconst conformValue = (rawValue, cursorPos, lastkeycode) => {\n let nextMaskedValue = rawValue\n .split('')\n .filter((char) => char >= '0' && char <= '9');\n\n while (nextMaskedValue.length && nextMaskedValue[0] === '0')\n nextMaskedValue.splice(0, 1);\n\n nextMaskedValue = nextMaskedValue.slice(0, 10);\n\n let maskedPos = 0;\n for (let i = 0; i < cursorPos; i += 1) {\n if (nextMaskedValue[maskedPos] === rawValue[i]) maskedPos += 1;\n }\n\n // list of [string to add, position to add]\nconst charactersToAdd: TCharsToAdd = [\n ['(', 0],\n [') ', 4],\n ['-', 9],\n ];\n\n charactersToAdd.forEach(([chars, pos]) => {\n if (nextMaskedValue.length > pos) {\n nextMaskedValue.splice(pos, 0, ...chars);\n if (maskedPos >= pos) maskedPos += chars.length;\n }\n });\n\n if (lastkeycode !== 8 && maskedPos < nextMaskedValue.length) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos) maskedPos += chars.length;\n });\n } else if (lastkeycode === 8 && maskedPos) {\n charactersToAdd.forEach(([chars, pos]) => {\n if (maskedPos === pos + 1) maskedPos -= chars.length;\n });\n }\n return { nextMaskedValue: nextMaskedValue.join(''), maskedPos };\n};\n\nconst PhoneInputMask = ({\n focus,\n setFocus,\n setRawMask,\n cursorPosition,\n setCursorPosition,\n lastkey,\n setLastkey,\n setRawValue,\n style,\n disabled,\n className,\n name,\n maxLength,\n minLength,\n fluidWidth,\n placeholder,\n onKeyDown,\n onClick,\n onChange,\n onFocus,\n onBlur,\n onPaste,\n onKeyUp,\n hasError,\n readOnly,\n type,\n innerRef,\n clearable = false,\n leftComponent,\n rightComponent,\n value,\n ...rest\n}) => {\n const inputRef = useRef();\n const [maskedValue, setMaskedValue] = useState(value);\n\n const conform = useCallback(\n ({ rawValue, cursorPos, lastkeycode, shouldUpdateCursorPos = true }) => {\n const { nextMaskedValue, maskedPos } = conformValue(\n rawValue,\n cursorPos,\n lastkeycode,\n );\n const event = {\n target: {\n value: nextMaskedValue,\n originalValue: rawValue,\n },\n };\n if (onChange && nextMaskedValue !== maskedValue) onChange(event);\n\n setMaskedValue(nextMaskedValue);\n setRawValue(nextMaskedValue);\n\n if (shouldUpdateCursorPos) setCursorPosition({ current: maskedPos });\n },\n [maskedValue, onChange],\n );\n\n const handleOnChange = useCallback(\n (e) => {\n const { value: rawValue, selectionEnd } = e.target;\n setRawMask(rawValue);\n setRawValue(rawValue);\n setCursorPosition({ current: selectionEnd });\n setFocus(true);\n },\n [setRawMask, setRawValue, setCursorPosition, setFocus, lastkey.code],\n );\n\n useLayoutEffect(() => {\n if (focus) setCaretPosition(inputRef.current, cursorPosition.current);\n }, [focus, cursorPosition]);\n\n useLayoutEffect(() => {\n // if the value changes, then re-conform the mask\n conform({\n rawValue: value,\n cursorPos: cursorPosition.current,\n lastkeycode: lastkey.code,\n shouldUpdateCursorPos: focus,\n });\n }, [focus, value, cursorPosition.current]);\n\n const handleKeyDown = useCallback(\n (e) => {\n e.stopPropagation();\n setLastkey({ key: e.key, code: e.keyCode });\n onKeyDown(e);\n },\n [onKeyDown],\n );\n\n const handleBlur = useCallback(\n (e) => {\n setFocus(false);\n onBlur(e);\n },\n [onBlur],\n );\n\n return (\n <DSTextBox\n {...rest}\n className={className}\n clearable={clearable}\n disabled={disabled}\n fluidWidth={fluidWidth}\n hasError={hasError}\n innerRef={(ref) => {\n inputRef.current = ref;\n if (innerRef) innerRef(ref);\n }}\n isActive={focus}\n leftComponent={leftComponent}\n maxLength={maxLength}\n minLength={minLength}\n name={name}\n onBlur={handleBlur}\n onChange={handleOnChange}\n onClick={onClick}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onPaste={onPaste}\n placeholder={placeholder}\n readOnly={readOnly}\n rightComponent={rightComponent}\n style={style}\n type={type}\n value={maskedValue}\n />\n );\n};\n\nexport { PhoneInputMask };\nexport default PhoneInputMask;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAsE;AAEtE,qBAA0B;AAE1B,8BAAiC;AAEjC,MAAM,eAAe,CAAC,UAAU,WAAW,gBAAgB;AACzD,MAAI,kBAAkB,SACnB,MAAM,EAAE,EACR,OAAO,CAAC,SAAS,QAAQ,OAAO,QAAQ,GAAG;AAE9C,SAAO,gBAAgB,UAAU,gBA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