@razorpay/blade 12.47.1 → 12.48.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/build/lib/native/components/Input/TextInput/TextInput.js +1 -1
- package/build/lib/native/components/Input/TextInput/TextInput.js.map +1 -1
- package/build/lib/native/components/Input/TextInput/useFormattedInput.js +1 -1
- package/build/lib/native/components/Input/TextInput/useFormattedInput.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/BaseDatePicker.web.js +162 -113
- package/build/lib/web/development/components/DatePicker/BaseDatePicker.web.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/CalendarFooter.web.js +1 -1
- package/build/lib/web/development/components/DatePicker/CalendarFooter.web.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/DateInput.web.js +202 -147
- package/build/lib/web/development/components/DatePicker/DateInput.web.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/QuickSelection/PresetContext.js +122 -0
- package/build/lib/web/development/components/DatePicker/QuickSelection/PresetContext.js.map +1 -0
- package/build/lib/web/development/components/DatePicker/QuickSelection/PresetDropdown.web.js +46 -0
- package/build/lib/web/development/components/DatePicker/QuickSelection/PresetDropdown.web.js.map +1 -0
- package/build/lib/web/development/components/DatePicker/QuickSelection/PresetSideBar.web.js +19 -19
- package/build/lib/web/development/components/DatePicker/QuickSelection/PresetSideBar.web.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/QuickSelection/utils.js +9 -0
- package/build/lib/web/development/components/DatePicker/QuickSelection/utils.js.map +1 -0
- package/build/lib/web/development/components/DatePicker/usePopup.js +10 -2
- package/build/lib/web/development/components/DatePicker/usePopup.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/utils.js +419 -1
- package/build/lib/web/development/components/DatePicker/utils.js.map +1 -1
- package/build/lib/web/development/components/Input/TextInput/TextInput.js +3 -1
- package/build/lib/web/development/components/Input/TextInput/TextInput.js.map +1 -1
- package/build/lib/web/development/components/Input/TextInput/useFormattedInput.js +21 -0
- package/build/lib/web/development/components/Input/TextInput/useFormattedInput.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/BaseDatePicker.web.js +162 -113
- package/build/lib/web/production/components/DatePicker/BaseDatePicker.web.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/CalendarFooter.web.js +1 -1
- package/build/lib/web/production/components/DatePicker/CalendarFooter.web.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/DateInput.web.js +202 -147
- package/build/lib/web/production/components/DatePicker/DateInput.web.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/QuickSelection/PresetContext.js +122 -0
- package/build/lib/web/production/components/DatePicker/QuickSelection/PresetContext.js.map +1 -0
- package/build/lib/web/production/components/DatePicker/QuickSelection/PresetDropdown.web.js +46 -0
- package/build/lib/web/production/components/DatePicker/QuickSelection/PresetDropdown.web.js.map +1 -0
- package/build/lib/web/production/components/DatePicker/QuickSelection/PresetSideBar.web.js +19 -19
- package/build/lib/web/production/components/DatePicker/QuickSelection/PresetSideBar.web.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/QuickSelection/utils.js +9 -0
- package/build/lib/web/production/components/DatePicker/QuickSelection/utils.js.map +1 -0
- package/build/lib/web/production/components/DatePicker/usePopup.js +10 -2
- package/build/lib/web/production/components/DatePicker/usePopup.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/utils.js +419 -1
- package/build/lib/web/production/components/DatePicker/utils.js.map +1 -1
- package/build/lib/web/production/components/Input/TextInput/TextInput.js +3 -1
- package/build/lib/web/production/components/Input/TextInput/TextInput.js.map +1 -1
- package/build/lib/web/production/components/Input/TextInput/useFormattedInput.js +21 -0
- package/build/lib/web/production/components/Input/TextInput/useFormattedInput.js.map +1 -1
- package/build/types/components/index.d.ts +10 -5
- package/build/types/components/index.native.d.ts +10 -5
- package/package.json +1 -1
|
@@ -417,7 +417,7 @@ import '../../Dropdown/DropdownHeaderFooter.js';
|
|
|
417
417
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
418
418
|
import { isIconComponent } from '../../../utils/isIconComponent/isIconComponent.js';
|
|
419
419
|
|
|
420
|
-
var _excluded=["label","accessibilityLabel","labelPosition","placeholder","type","defaultValue","name","value","maxCharacters","format","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","necessityIndicator","validationState","errorText","helpText","successText","isRequired","icon","prefix","showClearButton","onClearButtonClick","isLoading","suffix","autoFocus","keyboardReturnKeyType","autoCompleteSuggestionType","autoCapitalize","testID","size","leadingIcon","trailingIcon","isTaggedInput","tags","onTagChange","trailing","leading","labelSuffix","labelTrailing"];var isReactNative=function isReactNative(_textInputRef){return getPlatformType()==='react-native';};var _TextInput=function _TextInput(_ref,ref){var _ref4;var label=_ref.label,accessibilityLabel=_ref.accessibilityLabel,_ref$labelPosition=_ref.labelPosition,labelPosition=_ref$labelPosition===void 0?'top':_ref$labelPosition,placeholder=_ref.placeholder,_ref$type=_ref.type,type=_ref$type===void 0?'text':_ref$type,defaultValue=_ref.defaultValue,name=_ref.name,value=_ref.value,maxCharacters=_ref.maxCharacters,format=_ref.format,onChange=_ref.onChange,onClick=_ref.onClick,_onFocus=_ref.onFocus,_onBlur=_ref.onBlur,onSubmit=_ref.onSubmit,isDisabled=_ref.isDisabled,necessityIndicator=_ref.necessityIndicator,validationState=_ref.validationState,errorText=_ref.errorText,helpText=_ref.helpText,successText=_ref.successText,isRequired=_ref.isRequired,icon=_ref.icon,prefix=_ref.prefix,showClearButton=_ref.showClearButton,onClearButtonClick=_ref.onClearButtonClick,isLoading=_ref.isLoading,suffix=_ref.suffix,autoFocus=_ref.autoFocus,keyboardReturnKeyType=_ref.keyboardReturnKeyType,autoCompleteSuggestionType=_ref.autoCompleteSuggestionType,autoCapitalize=_ref.autoCapitalize,testID=_ref.testID,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,leadingIcon=_ref.leadingIcon,trailingIcon=_ref.trailingIcon,isTaggedInput=_ref.isTaggedInput,tags=_ref.tags,onTagChange=_ref.onTagChange,trailing=_ref.trailing,leading=_ref.leading,labelSuffix=_ref.labelSuffix,labelTrailing=_ref.labelTrailing,rest=_objectWithoutProperties(_ref,_excluded);var textInputRef=React__default.useRef(null);var mergedRef=useMergeRefs(ref,textInputRef);var _useState=useState(false),_useState2=_slicedToArray(_useState,2),shouldShowClearButton=_useState2[0],setShouldShowClearButton=_useState2[1];var _useState3=useState(autoFocus!=null?autoFocus:false),_useState4=_slicedToArray(_useState3,2),isInputFocussed=_useState4[0],setIsInputFocussed=_useState4[1];if(__DEV__){if(format){var hasAlphanumeric=/[a-zA-Z0-9]/.test(format);if(hasAlphanumeric){throw new Error(`[Blade: TextInput] Invalid format "${format}". Only # and special characters allowed, no letters/numbers.`);}}}var formattingResult=useFormattedInput({format:format,onChange:onChange,value:value,defaultValue:defaultValue});var inputValue=format?formattingResult.formattedValue:value;var effectiveMaxCharacters=format?formattingResult.maxLength:maxCharacters;var handleOnChange=React__default.useCallback(function(_ref2){var name=_ref2.name,inputValue=_ref2.value;if(format){formattingResult.handleChange({name:name,value:inputValue});}else {onChange==null?void 0:onChange({name:name,value:inputValue});}},[format,formattingResult.handleChange,onChange]);var _useTaggedInput=useTaggedInput({isTaggedInput:isTaggedInput,tags:tags,onTagChange:onTagChange,isDisabled:isDisabled,onChange:handleOnChange,name:name,value:inputValue,inputRef:textInputRef}),activeTagIndex=_useTaggedInput.activeTagIndex,setActiveTagIndex=_useTaggedInput.setActiveTagIndex,getTags=_useTaggedInput.getTags,handleTaggedInputKeydown=_useTaggedInput.handleTaggedInputKeydown,handleTaggedInputChange=_useTaggedInput.handleTaggedInputChange,handleTagsClear=_useTaggedInput.handleTagsClear;var _React$useState=React__default.useState(false),_React$useState2=_slicedToArray(_React$useState,2),isTrailingDropDownOpen=_React$useState2[0],setIsTrailingDropDownOpen=_React$useState2[1];var _React$useState3=React__default.useState(false),_React$useState4=_slicedToArray(_React$useState3,2),isLeadingDropDownOpen=_React$useState4[0],setIsLeadingDropDownOpen=_React$useState4[1];var textInputWrapperRef=useRef(null);useEffect(function(){if(isTrailingDropDownOpen&&isLeadingDropDownOpen){setIsLeadingDropDownOpen(false);}},[isTrailingDropDownOpen]);useEffect(function(){if(isLeadingDropDownOpen&&isTrailingDropDownOpen){setIsTrailingDropDownOpen(false);}},[isLeadingDropDownOpen]);var leadingDropDown=leading&&getComponentId(leading)==='Dropdown'?leading:null;var trailingDropdown=trailing&&getComponentId(trailing)==='Dropdown'?trailing:null;var _leadingIcon=isIconComponent(leading)?leading:undefined;var _trailingIcon=isIconComponent(trailing)?trailing:undefined;var hasLeadingInteractionElement=!_leadingIcon&&!leadingDropDown&&leading;var hasTrailingInteractionElement=!_trailingIcon&&!trailingDropdown&&trailing;var renderDropdown=function renderDropdown(dropdown,isOpen,setIsOpen,defaultPlacement){if(!dropdown){return null;}return React__default.cloneElement(dropdown,{selectionType:'single',isOpen:isOpen,onOpenChange:function onOpenChange(isOpen){setIsOpen(isOpen);},children:React__default.Children.map(dropdown.props.children,function(child){if(child.type===DropdownOverlay){return React__default.cloneElement(child,{referenceRef:textInputWrapperRef,_isNestedDropdown:true,defaultPlacement:defaultPlacement});}return child;})});};var renderLeadingDropDown=renderDropdown(leadingDropDown,isLeadingDropDownOpen,setIsLeadingDropDownOpen,'bottom-start');var renderTrailingDropDown=renderDropdown(trailingDropdown,isTrailingDropDownOpen,setIsTrailingDropDownOpen,'bottom-end');React__default.useEffect(function(){setShouldShowClearButton(Boolean(showClearButton&&(defaultValue!=null?defaultValue:inputValue)));},[showClearButton,defaultValue,inputValue]);var renderClearButton=function renderClearButton(){return jsx(IconButton,{size:"medium",icon:CloseIcon,onClick:function onClick(){var _textInputRef$current;if(isEmpty(inputValue)&&textInputRef.current){if(isReactNative(textInputRef.current)){textInputRef.current.clear();textInputRef.current.focus();}else if(textInputRef.current instanceof HTMLInputElement){textInputRef.current.value='';textInputRef.current.focus();}}handleTagsClear();onClearButtonClick==null?void 0:onClearButtonClick();textInputRef==null?void 0:(_textInputRef$current=textInputRef.current)==null?void 0:_textInputRef$current.focus();setShouldShowClearButton(false);},isDisabled:isDisabled,accessibilityLabel:"Clear Input Content"});};var hasTrailingDropDown=Boolean(trailingDropdown);var renderInteractionElement=function renderInteractionElement(){if(isLoading){return jsx(Spinner,{accessibilityLabel:"Loading Content",color:"primary"});}if(shouldShowClearButton&&hasTrailingDropDown){return jsxs(BaseBox,{display:"flex",gap:"spacing.3",children:[renderClearButton()," ",jsx(Divider,{orientation:"vertical"})]});}if(showClearButton&&hasTrailingInteractionElement){return jsxs(BaseBox,{display:"flex",gap:"spacing.3",children:[renderClearButton()," ",jsx(Divider,{orientation:"vertical"})," ",trailing]});}if(shouldShowClearButton){return renderClearButton();}if(hasTrailingInteractionElement){return trailing;}return null;};return jsx(BaseInput,Object.assign({id:"textinput",componentName:MetaConstants.TextInput,ref:mergedRef,setInputWrapperRef:function setInputWrapperRef(wrapperNode){textInputWrapperRef.current=wrapperNode;},label:label,labelSuffix:labelSuffix,labelTrailing:labelTrailing,accessibilityLabel:accessibilityLabel,hideLabelText:!Boolean(label),labelPosition:labelPosition,placeholder:placeholder,defaultValue:format?value!==undefined&&defaultValue!==undefined?defaultValue:undefined:defaultValue,value:format?inputValue:value,name:name,maxCharacters:effectiveMaxCharacters,isDropdownTrigger:isTaggedInput,tags:isTaggedInput?getTags({size:size}):undefined,showAllTags:isInputFocussed,maxTagRows:"single",activeTagIndex:activeTagIndex,setActiveTagIndex:setActiveTagIndex,leadingDropDown:renderLeadingDropDown,trailingDropDown:renderTrailingDropDown,leadingInteractionElement:hasLeadingInteractionElement?leading:null,onChange:function onChange(_ref3){var name=_ref3.name,value=_ref3.value;if(showClearButton&&value!=null&&value.length){setShouldShowClearButton(true);}if(shouldShowClearButton&&!(value!=null&&value.length)){setShouldShowClearButton(false);}handleTaggedInputChange({name:name,value:value});handleOnChange({name:name,value:value});},onClick:onClick,onFocus:function onFocus(e){setIsInputFocussed(true);_onFocus==null?void 0:_onFocus(e);},onBlur:function onBlur(e){setIsInputFocussed(false);_onBlur==null?void 0:_onBlur(e);},onKeyDown:function onKeyDown(e){handleTaggedInputKeydown(e);if(format){formattingResult.handleKeyDown(e.event);}},onSubmit:onSubmit,isDisabled:isDisabled,necessityIndicator:necessityIndicator,isRequired:isRequired,leadingIcon:(_ref4=_leadingIcon!=null?_leadingIcon:leadingIcon)!=null?_ref4:icon,prefix:prefix,trailingInteractionElement:renderInteractionElement(),trailingIcon:_trailingIcon!=null?_trailingIcon:trailingIcon,suffix:suffix,validationState:validationState,errorText:errorText,helpText:helpText,successText:successText,trailingFooterSlot:function trailingFooterSlot(value){var _value$length;return format?null:effectiveMaxCharacters?jsx(BaseBox,{marginTop:hintMarginTop[size],marginRight:"spacing.1",children:jsx(CharacterCounter,{currentCount:(_value$length=value==null?void 0:value.length)!=null?_value$length:0,maxCount:effectiveMaxCharacters,size:size})}):null;},autoFocus:autoFocus,testID:testID},getKeyboardAndAutocompleteProps({type:type,keyboardReturnKeyType:keyboardReturnKeyType,autoCompleteSuggestionType:autoCompleteSuggestionType,autoCapitalize:autoCapitalize}),{size:size},rest));};var TextInput=assignWithoutSideEffects(React__default.forwardRef(_TextInput),{displayName:'TextInput'});
|
|
420
|
+
var _excluded=["label","accessibilityLabel","labelPosition","placeholder","type","defaultValue","name","value","maxCharacters","format","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","necessityIndicator","validationState","errorText","helpText","successText","isRequired","icon","prefix","showClearButton","onClearButtonClick","isLoading","suffix","autoFocus","keyboardReturnKeyType","autoCompleteSuggestionType","autoCapitalize","testID","size","leadingIcon","trailingIcon","isTaggedInput","tags","onTagChange","trailing","leading","labelSuffix","labelTrailing","onKeyDown"];var isReactNative=function isReactNative(_textInputRef){return getPlatformType()==='react-native';};var _TextInput=function _TextInput(_ref,ref){var _ref4;var label=_ref.label,accessibilityLabel=_ref.accessibilityLabel,_ref$labelPosition=_ref.labelPosition,labelPosition=_ref$labelPosition===void 0?'top':_ref$labelPosition,placeholder=_ref.placeholder,_ref$type=_ref.type,type=_ref$type===void 0?'text':_ref$type,defaultValue=_ref.defaultValue,name=_ref.name,value=_ref.value,maxCharacters=_ref.maxCharacters,format=_ref.format,onChange=_ref.onChange,onClick=_ref.onClick,_onFocus=_ref.onFocus,_onBlur=_ref.onBlur,onSubmit=_ref.onSubmit,isDisabled=_ref.isDisabled,necessityIndicator=_ref.necessityIndicator,validationState=_ref.validationState,errorText=_ref.errorText,helpText=_ref.helpText,successText=_ref.successText,isRequired=_ref.isRequired,icon=_ref.icon,prefix=_ref.prefix,showClearButton=_ref.showClearButton,onClearButtonClick=_ref.onClearButtonClick,isLoading=_ref.isLoading,suffix=_ref.suffix,autoFocus=_ref.autoFocus,keyboardReturnKeyType=_ref.keyboardReturnKeyType,autoCompleteSuggestionType=_ref.autoCompleteSuggestionType,autoCapitalize=_ref.autoCapitalize,testID=_ref.testID,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,leadingIcon=_ref.leadingIcon,trailingIcon=_ref.trailingIcon,isTaggedInput=_ref.isTaggedInput,tags=_ref.tags,onTagChange=_ref.onTagChange,trailing=_ref.trailing,leading=_ref.leading,labelSuffix=_ref.labelSuffix,labelTrailing=_ref.labelTrailing,_onKeyDown=_ref.onKeyDown,rest=_objectWithoutProperties(_ref,_excluded);var textInputRef=React__default.useRef(null);var mergedRef=useMergeRefs(ref,textInputRef);var _useState=useState(false),_useState2=_slicedToArray(_useState,2),shouldShowClearButton=_useState2[0],setShouldShowClearButton=_useState2[1];var _useState3=useState(autoFocus!=null?autoFocus:false),_useState4=_slicedToArray(_useState3,2),isInputFocussed=_useState4[0],setIsInputFocussed=_useState4[1];if(__DEV__){if(format){var hasAlphanumeric=/[a-zA-Z0-9]/.test(format);if(hasAlphanumeric){throw new Error(`[Blade: TextInput] Invalid format "${format}". Only # and special characters allowed, no letters/numbers.`);}}}var formattingResult=useFormattedInput({format:format,onChange:onChange,value:value,defaultValue:defaultValue});var inputValue=format?formattingResult.formattedValue:value;var effectiveMaxCharacters=format?formattingResult.maxLength:maxCharacters;var handleOnChange=React__default.useCallback(function(_ref2){var name=_ref2.name,inputValue=_ref2.value;if(format){formattingResult.handleChange({name:name,value:inputValue});}else {onChange==null?void 0:onChange({name:name,value:inputValue});}},[format,formattingResult.handleChange,onChange]);var _useTaggedInput=useTaggedInput({isTaggedInput:isTaggedInput,tags:tags,onTagChange:onTagChange,isDisabled:isDisabled,onChange:handleOnChange,name:name,value:inputValue,inputRef:textInputRef}),activeTagIndex=_useTaggedInput.activeTagIndex,setActiveTagIndex=_useTaggedInput.setActiveTagIndex,getTags=_useTaggedInput.getTags,handleTaggedInputKeydown=_useTaggedInput.handleTaggedInputKeydown,handleTaggedInputChange=_useTaggedInput.handleTaggedInputChange,handleTagsClear=_useTaggedInput.handleTagsClear;var _React$useState=React__default.useState(false),_React$useState2=_slicedToArray(_React$useState,2),isTrailingDropDownOpen=_React$useState2[0],setIsTrailingDropDownOpen=_React$useState2[1];var _React$useState3=React__default.useState(false),_React$useState4=_slicedToArray(_React$useState3,2),isLeadingDropDownOpen=_React$useState4[0],setIsLeadingDropDownOpen=_React$useState4[1];var textInputWrapperRef=useRef(null);useEffect(function(){if(isTrailingDropDownOpen&&isLeadingDropDownOpen){setIsLeadingDropDownOpen(false);}},[isTrailingDropDownOpen]);useEffect(function(){if(isLeadingDropDownOpen&&isTrailingDropDownOpen){setIsTrailingDropDownOpen(false);}},[isLeadingDropDownOpen]);var leadingDropDown=leading&&getComponentId(leading)==='Dropdown'?leading:null;var trailingDropdown=trailing&&getComponentId(trailing)==='Dropdown'?trailing:null;var _leadingIcon=isIconComponent(leading)?leading:undefined;var _trailingIcon=isIconComponent(trailing)?trailing:undefined;var hasLeadingInteractionElement=!_leadingIcon&&!leadingDropDown&&leading;var hasTrailingInteractionElement=!_trailingIcon&&!trailingDropdown&&trailing;var renderDropdown=function renderDropdown(dropdown,isOpen,setIsOpen,defaultPlacement){if(!dropdown){return null;}return React__default.cloneElement(dropdown,{selectionType:'single',isOpen:isOpen,onOpenChange:function onOpenChange(isOpen){setIsOpen(isOpen);},children:React__default.Children.map(dropdown.props.children,function(child){if(child.type===DropdownOverlay){return React__default.cloneElement(child,{referenceRef:textInputWrapperRef,_isNestedDropdown:true,defaultPlacement:defaultPlacement});}return child;})});};var renderLeadingDropDown=renderDropdown(leadingDropDown,isLeadingDropDownOpen,setIsLeadingDropDownOpen,'bottom-start');var renderTrailingDropDown=renderDropdown(trailingDropdown,isTrailingDropDownOpen,setIsTrailingDropDownOpen,'bottom-end');React__default.useEffect(function(){setShouldShowClearButton(Boolean(showClearButton&&(defaultValue!=null?defaultValue:inputValue)));},[showClearButton,defaultValue,inputValue]);var renderClearButton=function renderClearButton(){return jsx(IconButton,{size:"medium",icon:CloseIcon,onClick:function onClick(){var _textInputRef$current;if(isEmpty(inputValue)&&textInputRef.current){if(isReactNative(textInputRef.current)){textInputRef.current.clear();textInputRef.current.focus();}else if(textInputRef.current instanceof HTMLInputElement){textInputRef.current.value='';textInputRef.current.focus();}}handleTagsClear();onClearButtonClick==null?void 0:onClearButtonClick();textInputRef==null?void 0:(_textInputRef$current=textInputRef.current)==null?void 0:_textInputRef$current.focus();setShouldShowClearButton(false);},isDisabled:isDisabled,accessibilityLabel:"Clear Input Content"});};var hasTrailingDropDown=Boolean(trailingDropdown);var renderInteractionElement=function renderInteractionElement(){if(isLoading){return jsx(Spinner,{accessibilityLabel:"Loading Content",color:"primary"});}if(shouldShowClearButton&&hasTrailingDropDown){return jsxs(BaseBox,{display:"flex",gap:"spacing.3",children:[renderClearButton()," ",jsx(Divider,{orientation:"vertical"})]});}if(showClearButton&&hasTrailingInteractionElement){return jsxs(BaseBox,{display:"flex",gap:"spacing.3",children:[renderClearButton()," ",jsx(Divider,{orientation:"vertical"})," ",trailing]});}if(shouldShowClearButton){return renderClearButton();}if(hasTrailingInteractionElement){return trailing;}return null;};return jsx(BaseInput,Object.assign({id:"textinput",componentName:MetaConstants.TextInput,ref:mergedRef,setInputWrapperRef:function setInputWrapperRef(wrapperNode){textInputWrapperRef.current=wrapperNode;},label:label,labelSuffix:labelSuffix,labelTrailing:labelTrailing,accessibilityLabel:accessibilityLabel,hideLabelText:!Boolean(label),labelPosition:labelPosition,placeholder:placeholder,defaultValue:format?value!==undefined&&defaultValue!==undefined?defaultValue:undefined:defaultValue,value:format?inputValue:value,name:name,maxCharacters:effectiveMaxCharacters,isDropdownTrigger:isTaggedInput,tags:isTaggedInput?getTags({size:size}):undefined,showAllTags:isInputFocussed,maxTagRows:"single",activeTagIndex:activeTagIndex,setActiveTagIndex:setActiveTagIndex,leadingDropDown:renderLeadingDropDown,trailingDropDown:renderTrailingDropDown,leadingInteractionElement:hasLeadingInteractionElement?leading:null,onChange:function onChange(_ref3){var name=_ref3.name,value=_ref3.value;if(showClearButton&&value!=null&&value.length){setShouldShowClearButton(true);}if(shouldShowClearButton&&!(value!=null&&value.length)){setShouldShowClearButton(false);}handleTaggedInputChange({name:name,value:value});handleOnChange({name:name,value:value});},onClick:onClick,onFocus:function onFocus(e){setIsInputFocussed(true);_onFocus==null?void 0:_onFocus(e);},onBlur:function onBlur(e){setIsInputFocussed(false);_onBlur==null?void 0:_onBlur(e);},onKeyDown:function onKeyDown(e){handleTaggedInputKeydown(e);_onKeyDown==null?void 0:_onKeyDown(e);if(format){formattingResult.handleKeyDown(e.event);}},onSubmit:onSubmit,isDisabled:isDisabled,necessityIndicator:necessityIndicator,isRequired:isRequired,leadingIcon:(_ref4=_leadingIcon!=null?_leadingIcon:leadingIcon)!=null?_ref4:icon,prefix:prefix,trailingInteractionElement:renderInteractionElement(),trailingIcon:_trailingIcon!=null?_trailingIcon:trailingIcon,suffix:suffix,validationState:validationState,errorText:errorText,helpText:helpText,successText:successText,trailingFooterSlot:function trailingFooterSlot(value){var _value$length;return format?null:effectiveMaxCharacters?jsx(BaseBox,{marginTop:hintMarginTop[size],marginRight:"spacing.1",children:jsx(CharacterCounter,{currentCount:(_value$length=value==null?void 0:value.length)!=null?_value$length:0,maxCount:effectiveMaxCharacters,size:size})}):null;},autoFocus:autoFocus,testID:testID},getKeyboardAndAutocompleteProps({type:type,keyboardReturnKeyType:keyboardReturnKeyType,autoCompleteSuggestionType:autoCompleteSuggestionType,autoCapitalize:autoCapitalize}),{size:size},rest));};var TextInput=assignWithoutSideEffects(React__default.forwardRef(_TextInput),{displayName:'TextInput'});
|
|
421
421
|
|
|
422
422
|
export { TextInput };
|
|
423
423
|
//# sourceMappingURL=TextInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.js","sources":["../../../../../../src/components/Input/TextInput/TextInput.tsx"],"sourcesContent":["import React, { useEffect, useState, useRef } from 'react';\nimport type { ReactElement, ReactNode } from 'react';\nimport type { TextInput as TextInputReactNative } from 'react-native';\nimport type { BaseInputProps } from '../BaseInput';\nimport { BaseInput } from '../BaseInput';\nimport { getKeyboardAndAutocompleteProps } from '../BaseInput/utils';\nimport type { TaggedInputProps } from '../BaseInput/useTaggedInput';\nimport { useTaggedInput } from '../BaseInput/useTaggedInput';\nimport { useFormattedInput } from './useFormattedInput';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport type { IconComponent } from '~components/Icons';\nimport { CloseIcon } from '~components/Icons';\nimport { IconButton } from '~components/Button/IconButton';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { CharacterCounter } from '~components/Form/CharacterCounter';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Spinner } from '~components/Spinner';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType } from '~utils';\nimport { useMergeRefs } from '~utils/useMergeRefs';\nimport type {\n BladeElementRef,\n BladeElementRefWithValue,\n ContainerElementType,\n DataAnalyticsAttribute,\n} from '~utils/types';\nimport { hintMarginTop } from '~components/Form/formTokens';\nimport { Divider } from '~components/Divider';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { DropdownOverlay } from '~components/Dropdown';\nimport type { FormInputOnEvent } from '~components/Form/FormTypes';\nimport { isIconComponent } from '~utils/isIconComponent';\n\n// Users should use PasswordInput for input type password\ntype Type = Exclude<BaseInputProps['type'], 'password'>;\n\ntype TextInputCommonProps = Pick<\n BaseInputProps,\n | 'label'\n | 'accessibilityLabel'\n | 'labelPosition'\n | 'labelSuffix'\n | 'labelTrailing'\n | 'necessityIndicator'\n | 'validationState'\n | 'helpText'\n | 'errorText'\n | 'successText'\n | 'placeholder'\n | 'defaultValue'\n | 'name'\n | 'onChange'\n | 'onFocus'\n | 'onBlur'\n | 'value'\n | 'isDisabled'\n | 'isRequired'\n | 'prefix'\n | 'suffix'\n | 'maxCharacters'\n | 'autoFocus'\n | 'keyboardReturnKeyType'\n | 'autoCompleteSuggestionType'\n | 'onSubmit'\n | 'autoCapitalize'\n | 'testID'\n | 'onClick'\n | 'size'\n | 'leadingIcon'\n | 'trailingButton'\n | 'trailingIcon'\n | 'textAlign'\n | keyof DataAnalyticsAttribute\n> & {\n /**\n * Decides whether to render a clear icon button\n */\n showClearButton?: boolean;\n\n /**\n * Event handler to handle the onClick event for clear button. Used when `showClearButton` is `true`\n */\n onClearButtonClick?: () => void;\n\n /**\n * Decides whether to show a loading spinner for the input field.\n */\n isLoading?: boolean;\n\n /**\n * Icon that will be rendered at the beginning of the input field\n * @deprecated Use `leading` instead. This prop will be removed in the next major version.\n */\n icon?: IconComponent;\n /**\n * Type of Input Field to be rendered. Use `PasswordInput` for type `password`\n *\n *\n * **Note on number type**\n *\n * `type=\"number\"` internally uses `inputMode=\"numeric\"` instead of HTML's `type=\"number\"` which also allows text characters.\n * If you have a usecase where you only want to support number input, you can handle it on validations end.\n *\n * Check out [Why the GOV.UK Design System team changed the input type for numbers](https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/) for reasoning\n *\n * @default text\n */\n type?: Type;\n /**\n *\n * Icon or React Element to be rendered at the end of the input field\n */\n trailing?: React.ReactElement | IconComponent;\n /**\n * Icon or React Element to be rendered at the beginning of the input field\n */\n leading?: React.ReactElement | IconComponent;\n /**\n * Format pattern where # represents input characters and other symbols act as delimiters\n * When provided, input will be automatically formatted and onChange will include rawValue\n *\n * **Note:**\n * 1. Format pattern should only contain # symbols and special characters as delimiters.\n * Alphanumeric characters (letters and numbers) are not allowed in the format pattern.\n * 2. When format is provided, user input is restricted to alphanumeric characters only.\n * Special characters and symbols will be filtered out automatically from user input.\n *\n * @example \"#### #### #### ####\" for card numbers\n * @example \"##/##\" for expiry dates\n * @example \"(###) ###-####\" for phone numbers\n */\n format?:\n | '#### #### #### ####'\n | '##/##'\n | '##/##/####'\n | '(###) ###-####'\n | '###-##-####'\n | '##:##'\n | '##:##:##'\n | '#### #### ####'\n | '###.###.###.###'\n | '## ## ####'\n | '##-###-##'\n // eslint-disable-next-line @typescript-eslint/ban-types\n | (string & {});\n} & TaggedInputProps &\n StyledPropsBlade;\n\n/*\n Mandatory accessibilityLabel prop when label is not provided\n*/\ntype TextInputPropsWithA11yLabel = {\n /**\n * Label to be shown for the input field\n */\n label?: undefined;\n /**\n * Accessibility label for the input\n */\n accessibilityLabel: string;\n};\n\n/*\n Optional accessibilityLabel prop when label is provided\n*/\ntype TextInputPropsWithLabel = {\n /**\n * Label to be shown for the input field\n */\n label: string;\n /**\n * Accessibility label for the input\n */\n accessibilityLabel?: string;\n};\n\ntype TextInputProps = (TextInputPropsWithA11yLabel | TextInputPropsWithLabel) &\n TextInputCommonProps;\n\n// need to do this to tell TS to infer type as TextInput of React Native and make it believe that `ref.current.clear()` exists\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isReactNative = (_textInputRef: any): _textInputRef is TextInputReactNative => {\n return getPlatformType() === 'react-native';\n};\n\nconst _TextInput: React.ForwardRefRenderFunction<BladeElementRef, TextInputProps> = (\n {\n label,\n accessibilityLabel,\n labelPosition = 'top',\n placeholder,\n type = 'text',\n defaultValue,\n name,\n value,\n maxCharacters,\n format,\n onChange,\n onClick,\n onFocus,\n onBlur,\n onSubmit,\n isDisabled,\n necessityIndicator,\n validationState,\n errorText,\n helpText,\n successText,\n isRequired,\n icon,\n prefix,\n showClearButton,\n onClearButtonClick,\n isLoading,\n suffix,\n autoFocus,\n keyboardReturnKeyType,\n autoCompleteSuggestionType,\n autoCapitalize,\n testID,\n size = 'medium',\n leadingIcon,\n trailingIcon,\n isTaggedInput,\n tags,\n onTagChange,\n trailing,\n leading,\n labelSuffix,\n labelTrailing,\n ...rest\n },\n ref,\n): ReactElement => {\n const textInputRef = React.useRef<BladeElementRefWithValue>(null);\n const mergedRef = useMergeRefs(ref, textInputRef);\n const [shouldShowClearButton, setShouldShowClearButton] = useState(false);\n const [isInputFocussed, setIsInputFocussed] = useState(autoFocus ?? false);\n\n if (__DEV__) {\n if (format) {\n const hasAlphanumeric = /[a-zA-Z0-9]/.test(format);\n if (hasAlphanumeric) {\n throw new Error(\n `[Blade: TextInput] Invalid format \"${format}\". Only # and special characters allowed, no letters/numbers.`,\n );\n }\n }\n }\n\n const formattingResult = useFormattedInput({\n format,\n onChange,\n value,\n defaultValue,\n });\n\n const inputValue = format ? formattingResult.formattedValue : value;\n const effectiveMaxCharacters = format ? formattingResult.maxLength : maxCharacters;\n\n const handleOnChange: FormInputOnEvent = React.useCallback(\n ({ name, value: inputValue }) => {\n if (format) {\n formattingResult.handleChange({ name, value: inputValue });\n } else {\n onChange?.({ name, value: inputValue });\n }\n },\n [format, formattingResult.handleChange, onChange],\n );\n\n const {\n activeTagIndex,\n setActiveTagIndex,\n getTags,\n handleTaggedInputKeydown,\n handleTaggedInputChange,\n handleTagsClear,\n } = useTaggedInput({\n isTaggedInput,\n tags,\n onTagChange,\n isDisabled,\n onChange: handleOnChange,\n name,\n value: inputValue,\n inputRef: textInputRef,\n });\n const [isTrailingDropDownOpen, setIsTrailingDropDownOpen] = React.useState(false);\n const [isLeadingDropDownOpen, setIsLeadingDropDownOpen] = React.useState(false);\n const textInputWrapperRef = useRef<ContainerElementType | null>(null);\n\n useEffect(() => {\n if (isTrailingDropDownOpen && isLeadingDropDownOpen) {\n setIsLeadingDropDownOpen(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isTrailingDropDownOpen]);\n\n useEffect(() => {\n if (isLeadingDropDownOpen && isTrailingDropDownOpen) {\n setIsTrailingDropDownOpen(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isLeadingDropDownOpen]);\n\n const leadingDropDown =\n leading && getComponentId(leading as React.ReactElement) === 'Dropdown' ? leading : null;\n\n const trailingDropdown =\n trailing && getComponentId(trailing as React.ReactElement) === 'Dropdown' ? trailing : null;\n // we need to look into name of component and check if it 's and icon or a dropdown\n const _leadingIcon: IconComponent | undefined = isIconComponent(leading)\n ? (leading as IconComponent)\n : undefined;\n\n const _trailingIcon: IconComponent | undefined = isIconComponent(trailing)\n ? (trailing as IconComponent)\n : undefined;\n const hasLeadingInteractionElement = !_leadingIcon && !leadingDropDown && leading;\n\n const hasTrailingInteractionElement = !_trailingIcon && !trailingDropdown && trailing;\n\n const renderDropdown = (\n dropdown: React.ReactElement,\n isOpen: boolean,\n setIsOpen: (isOpen: boolean) => void,\n defaultPlacement: 'bottom-start' | 'bottom-end',\n ): React.ReactElement | null => {\n if (!dropdown) {\n return null;\n }\n return React.cloneElement(dropdown, {\n selectionType: 'single',\n isOpen,\n onOpenChange: (isOpen: boolean) => {\n setIsOpen(isOpen);\n },\n children: React.Children.map(dropdown.props.children, (child) => {\n if (child.type === DropdownOverlay) {\n return React.cloneElement(child, {\n referenceRef: textInputWrapperRef,\n _isNestedDropdown: true,\n defaultPlacement,\n });\n }\n return child;\n }),\n });\n };\n\n const renderLeadingDropDown = renderDropdown(\n leadingDropDown as React.ReactElement,\n isLeadingDropDownOpen,\n setIsLeadingDropDownOpen,\n 'bottom-start',\n );\n const renderTrailingDropDown = renderDropdown(\n trailingDropdown as React.ReactElement,\n isTrailingDropDownOpen,\n setIsTrailingDropDownOpen,\n 'bottom-end',\n );\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(showClearButton && (defaultValue ?? inputValue)));\n }, [showClearButton, defaultValue, inputValue]);\n\n const renderClearButton = (): React.ReactElement => {\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(inputValue) && textInputRef.current) {\n // when the input field is uncontrolled take the ref and clear the input and then call the onClearButtonClick function\n if (isReactNative(textInputRef.current)) {\n textInputRef.current.clear();\n textInputRef.current.focus();\n } else if (textInputRef.current instanceof HTMLInputElement) {\n textInputRef.current.value = '';\n textInputRef.current.focus();\n }\n }\n handleTagsClear();\n // if the input field is controlled just call the click handler and the value change shall be left upto the consumer\n onClearButtonClick?.();\n textInputRef?.current?.focus();\n setShouldShowClearButton(false);\n }}\n isDisabled={isDisabled}\n accessibilityLabel=\"Clear Input Content\"\n />\n );\n };\n const hasTrailingDropDown = Boolean(trailingDropdown);\n\n const renderInteractionElement = (): ReactNode => {\n if (isLoading) {\n return <Spinner accessibilityLabel=\"Loading Content\" color=\"primary\" />;\n }\n\n if (shouldShowClearButton && hasTrailingDropDown) {\n return (\n <BaseBox display=\"flex\" gap=\"spacing.3\">\n {renderClearButton()} <Divider orientation=\"vertical\" />\n </BaseBox>\n );\n }\n\n if (showClearButton && hasTrailingInteractionElement) {\n return (\n <BaseBox display=\"flex\" gap=\"spacing.3\">\n {renderClearButton()} <Divider orientation=\"vertical\" /> {trailing as React.ReactElement}\n </BaseBox>\n );\n }\n\n if (shouldShowClearButton) {\n return renderClearButton();\n }\n\n if (hasTrailingInteractionElement) {\n return trailing as React.ReactElement;\n }\n return null;\n };\n return (\n <BaseInput\n id=\"textinput\"\n componentName={MetaConstants.TextInput}\n ref={mergedRef}\n setInputWrapperRef={(wrapperNode) => {\n textInputWrapperRef.current = wrapperNode;\n }}\n label={label as string}\n labelSuffix={labelSuffix}\n labelTrailing={labelTrailing}\n accessibilityLabel={accessibilityLabel}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n placeholder={placeholder}\n // CONTROLLED/UNCONTROLLED INPUT LOGIC:\n // For inputs WITHOUT format:\n // - Use standard React controlled/uncontrolled logic\n // - Controlled: user provides `value` prop → use `value` prop\n // - Uncontrolled: user provides `defaultValue` prop → use `defaultValue` prop\n //\n // For inputs WITH format:\n // - Formatting requires controlled mode to re-render and show formatted values\n // - Case 1: Only `value` provided → defaultValue: undefined, value: formattedValue (normal controlled)\n // - Case 2: Only `defaultValue` provided → defaultValue: undefined, value: formattedValue (convert to controlled)\n // - Case 3: Both `value` and `defaultValue` provided → defaultValue: defaultValue, value: formattedValue (let BaseInput detect conflict and throw error)\n //\n defaultValue={\n format\n ? value !== undefined && defaultValue !== undefined\n ? defaultValue\n : undefined\n : defaultValue\n }\n value={format ? inputValue : value}\n name={name}\n maxCharacters={effectiveMaxCharacters}\n isDropdownTrigger={isTaggedInput}\n tags={isTaggedInput ? getTags({ size }) : undefined}\n showAllTags={isInputFocussed}\n maxTagRows=\"single\"\n activeTagIndex={activeTagIndex}\n setActiveTagIndex={setActiveTagIndex}\n leadingDropDown={renderLeadingDropDown}\n trailingDropDown={renderTrailingDropDown}\n leadingInteractionElement={\n hasLeadingInteractionElement ? (leading as React.ReactElement) : null\n }\n onChange={({ name, value }: { name?: string; value?: string }) => {\n if (showClearButton && value?.length) {\n // show the clear button when the user starts typing in\n setShouldShowClearButton(true);\n }\n\n if (shouldShowClearButton && !value?.length) {\n // hide the clear button when the input field is empty\n setShouldShowClearButton(false);\n }\n\n handleTaggedInputChange({ name, value });\n handleOnChange({ name, value });\n }}\n onClick={onClick}\n onFocus={(e) => {\n setIsInputFocussed(true);\n onFocus?.(e);\n }}\n onBlur={(e) => {\n setIsInputFocussed(false);\n onBlur?.(e);\n }}\n onKeyDown={(e) => {\n handleTaggedInputKeydown(e);\n if (format) {\n formattingResult.handleKeyDown(e.event);\n }\n }}\n onSubmit={onSubmit}\n isDisabled={isDisabled}\n necessityIndicator={necessityIndicator}\n isRequired={isRequired}\n leadingIcon={_leadingIcon ?? leadingIcon ?? icon}\n prefix={prefix}\n trailingInteractionElement={renderInteractionElement()}\n trailingIcon={_trailingIcon ?? trailingIcon}\n suffix={suffix}\n validationState={validationState}\n errorText={errorText}\n helpText={helpText}\n successText={successText}\n trailingFooterSlot={(value) => {\n return format ? null : effectiveMaxCharacters ? (\n <BaseBox marginTop={hintMarginTop[size]} marginRight=\"spacing.1\">\n <CharacterCounter\n currentCount={value?.length ?? 0}\n maxCount={effectiveMaxCharacters}\n size={size}\n />\n </BaseBox>\n ) : null;\n }}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n {...getKeyboardAndAutocompleteProps({\n type,\n keyboardReturnKeyType,\n autoCompleteSuggestionType,\n autoCapitalize,\n })}\n size={size}\n {...rest}\n />\n );\n};\n\nconst TextInput = assignWithoutSideEffects(React.forwardRef(_TextInput), {\n displayName: 'TextInput',\n});\n\nexport type { TextInputProps };\nexport { TextInput };\n"],"names":["isReactNative","_textInputRef","getPlatformType","_TextInput","_ref","ref","_ref4","label","accessibilityLabel","_ref$labelPosition","labelPosition","placeholder","_ref$type","type","defaultValue","name","value","maxCharacters","format","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","necessityIndicator","validationState","errorText","helpText","successText","isRequired","icon","prefix","showClearButton","onClearButtonClick","isLoading","suffix","autoFocus","keyboardReturnKeyType","autoCompleteSuggestionType","autoCapitalize","testID","_ref$size","size","leadingIcon","trailingIcon","isTaggedInput","tags","onTagChange","trailing","leading","labelSuffix","labelTrailing","rest","_objectWithoutProperties","_excluded","textInputRef","React","useRef","mergedRef","useMergeRefs","_useState","useState","_useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useState3","_useState4","isInputFocussed","setIsInputFocussed","__DEV__","hasAlphanumeric","test","Error","formattingResult","useFormattedInput","inputValue","formattedValue","effectiveMaxCharacters","maxLength","handleOnChange","useCallback","_ref2","handleChange","_useTaggedInput","useTaggedInput","inputRef","activeTagIndex","setActiveTagIndex","getTags","handleTaggedInputKeydown","handleTaggedInputChange","handleTagsClear","_React$useState","_React$useState2","isTrailingDropDownOpen","setIsTrailingDropDownOpen","_React$useState3","_React$useState4","isLeadingDropDownOpen","setIsLeadingDropDownOpen","textInputWrapperRef","useEffect","leadingDropDown","getComponentId","trailingDropdown","_leadingIcon","isIconComponent","undefined","_trailingIcon","hasLeadingInteractionElement","hasTrailingInteractionElement","renderDropdown","dropdown","isOpen","setIsOpen","defaultPlacement","cloneElement","selectionType","onOpenChange","children","Children","map","props","child","DropdownOverlay","referenceRef","_isNestedDropdown","renderLeadingDropDown","renderTrailingDropDown","Boolean","renderClearButton","_jsx","IconButton","CloseIcon","_textInputRef$current","isEmpty","current","clear","focus","HTMLInputElement","hasTrailingDropDown","renderInteractionElement","Spinner","color","_jsxs","BaseBox","display","gap","Divider","orientation","BaseInput","Object","assign","id","componentName","MetaConstants","TextInput","setInputWrapperRef","wrapperNode","hideLabelText","isDropdownTrigger","showAllTags","maxTagRows","trailingDropDown","leadingInteractionElement","_ref3","length","e","onKeyDown","handleKeyDown","event","trailingInteractionElement","trailingFooterSlot","_value$length","marginTop","hintMarginTop","marginRight","CharacterCounter","currentCount","maxCount","getKeyboardAndAutocompleteProps","assignWithoutSideEffects","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAEA,SAAU,CACrBI,MAAM,CAAEA,MAAO,CAAA,CACX6I,+BAA+B,CAAC,CAClCzK,IAAI,CAAJA,IAAI,CACJyB,qBAAqB,CAArBA,qBAAqB,CACrBC,0BAA0B,CAA1BA,0BAA0B,CAC1BC,cAAc,CAAdA,cACF,CAAC,CAAC,CACFG,CAAAA,IAAI,CAAEA,IAAK,EACPU,IAAI,CACT,CAAC,CAEN,CAAC,CAEK,IAAAyG,SAAS,CAAGyB,wBAAwB,CAAC9H,cAAK,CAAC+H,UAAU,CAACrL,UAAU,CAAC,CAAE,CACvEsL,WAAW,CAAE,WACf,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"TextInput.js","sources":["../../../../../../src/components/Input/TextInput/TextInput.tsx"],"sourcesContent":["import React, { useEffect, useState, useRef } from 'react';\nimport type { ReactElement, ReactNode } from 'react';\nimport type { TextInput as TextInputReactNative } from 'react-native';\nimport type { BaseInputProps } from '../BaseInput';\nimport { BaseInput } from '../BaseInput';\nimport { getKeyboardAndAutocompleteProps } from '../BaseInput/utils';\nimport type { TaggedInputProps } from '../BaseInput/useTaggedInput';\nimport { useTaggedInput } from '../BaseInput/useTaggedInput';\nimport { useFormattedInput } from './useFormattedInput';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport type { IconComponent } from '~components/Icons';\nimport { CloseIcon } from '~components/Icons';\nimport { IconButton } from '~components/Button/IconButton';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { CharacterCounter } from '~components/Form/CharacterCounter';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Spinner } from '~components/Spinner';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType } from '~utils';\nimport { useMergeRefs } from '~utils/useMergeRefs';\nimport type {\n BladeElementRef,\n BladeElementRefWithValue,\n ContainerElementType,\n DataAnalyticsAttribute,\n} from '~utils/types';\nimport { hintMarginTop } from '~components/Form/formTokens';\nimport { Divider } from '~components/Divider';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { DropdownOverlay } from '~components/Dropdown';\nimport type { FormInputOnEvent } from '~components/Form/FormTypes';\nimport { isIconComponent } from '~utils/isIconComponent';\n\n// Users should use PasswordInput for input type password\ntype Type = Exclude<BaseInputProps['type'], 'password'>;\n\ntype TextInputCommonProps = Pick<\n BaseInputProps,\n | 'label'\n | 'accessibilityLabel'\n | 'labelPosition'\n | 'labelSuffix'\n | 'labelTrailing'\n | 'necessityIndicator'\n | 'validationState'\n | 'helpText'\n | 'errorText'\n | 'successText'\n | 'placeholder'\n | 'defaultValue'\n | 'name'\n | 'onChange'\n | 'onFocus'\n | 'onBlur'\n | 'value'\n | 'isDisabled'\n | 'isRequired'\n | 'prefix'\n | 'suffix'\n | 'maxCharacters'\n | 'autoFocus'\n | 'keyboardReturnKeyType'\n | 'autoCompleteSuggestionType'\n | 'onSubmit'\n | 'autoCapitalize'\n | 'testID'\n | 'onClick'\n | 'size'\n | 'leadingIcon'\n | 'trailingButton'\n | 'trailingIcon'\n | 'textAlign'\n | 'popupId'\n | 'isPopupExpanded'\n | 'hasPopup'\n | 'componentName'\n | 'onKeyDown'\n | keyof DataAnalyticsAttribute\n> & {\n /**\n * Decides whether to render a clear icon button\n */\n showClearButton?: boolean;\n\n /**\n * Event handler to handle the onClick event for clear button. Used when `showClearButton` is `true`\n */\n onClearButtonClick?: () => void;\n\n /**\n * Decides whether to show a loading spinner for the input field.\n */\n isLoading?: boolean;\n\n /**\n * Icon that will be rendered at the beginning of the input field\n * @deprecated Use `leading` instead. This prop will be removed in the next major version.\n */\n icon?: IconComponent;\n /**\n * Type of Input Field to be rendered. Use `PasswordInput` for type `password`\n *\n *\n * **Note on number type**\n *\n * `type=\"number\"` internally uses `inputMode=\"numeric\"` instead of HTML's `type=\"number\"` which also allows text characters.\n * If you have a usecase where you only want to support number input, you can handle it on validations end.\n *\n * Check out [Why the GOV.UK Design System team changed the input type for numbers](https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/) for reasoning\n *\n * @default text\n */\n type?: Type;\n /**\n *\n * Icon or React Element to be rendered at the end of the input field\n */\n trailing?: React.ReactElement | IconComponent;\n /**\n * Icon or React Element to be rendered at the beginning of the input field\n */\n leading?: React.ReactElement | IconComponent;\n /**\n * Format pattern where # represents input characters and other symbols act as delimiters\n * When provided, input will be automatically formatted and onChange will include rawValue\n *\n * **Note:**\n * 1. Format pattern should only contain # symbols and special characters as delimiters.\n * Alphanumeric characters (letters and numbers) are not allowed in the format pattern.\n * 2. When format is provided, user input is restricted to alphanumeric characters only.\n * Special characters and symbols will be filtered out automatically from user input.\n *\n * @example \"#### #### #### ####\" for card numbers\n * @example \"##/##\" for expiry dates\n * @example \"(###) ###-####\" for phone numbers\n */\n format?:\n | '#### #### #### ####'\n | '##/##'\n | '##/##/####'\n | '(###) ###-####'\n | '###-##-####'\n | '##:##'\n | '##:##:##'\n | '#### #### ####'\n | '###.###.###.###'\n | '## ## ####'\n | '##-###-##'\n // eslint-disable-next-line @typescript-eslint/ban-types\n | (string & {});\n} & TaggedInputProps &\n StyledPropsBlade;\n\n/*\n Mandatory accessibilityLabel prop when label is not provided\n*/\ntype TextInputPropsWithA11yLabel = {\n /**\n * Label to be shown for the input field\n */\n label?: undefined;\n /**\n * Accessibility label for the input\n */\n accessibilityLabel: string;\n};\n\n/*\n Optional accessibilityLabel prop when label is provided\n*/\ntype TextInputPropsWithLabel = {\n /**\n * Label to be shown for the input field\n */\n label: string;\n /**\n * Accessibility label for the input\n */\n accessibilityLabel?: string;\n};\n\ntype TextInputProps = (TextInputPropsWithA11yLabel | TextInputPropsWithLabel) &\n TextInputCommonProps;\n\n// need to do this to tell TS to infer type as TextInput of React Native and make it believe that `ref.current.clear()` exists\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isReactNative = (_textInputRef: any): _textInputRef is TextInputReactNative => {\n return getPlatformType() === 'react-native';\n};\n\nconst _TextInput: React.ForwardRefRenderFunction<BladeElementRef, TextInputProps> = (\n {\n label,\n accessibilityLabel,\n labelPosition = 'top',\n placeholder,\n type = 'text',\n defaultValue,\n name,\n value,\n maxCharacters,\n format,\n onChange,\n onClick,\n onFocus,\n onBlur,\n onSubmit,\n isDisabled,\n necessityIndicator,\n validationState,\n errorText,\n helpText,\n successText,\n isRequired,\n icon,\n prefix,\n showClearButton,\n onClearButtonClick,\n isLoading,\n suffix,\n autoFocus,\n keyboardReturnKeyType,\n autoCompleteSuggestionType,\n autoCapitalize,\n testID,\n size = 'medium',\n leadingIcon,\n trailingIcon,\n isTaggedInput,\n tags,\n onTagChange,\n trailing,\n leading,\n labelSuffix,\n labelTrailing,\n onKeyDown,\n ...rest\n },\n ref,\n): ReactElement => {\n const textInputRef = React.useRef<BladeElementRefWithValue>(null);\n const mergedRef = useMergeRefs(ref, textInputRef);\n const [shouldShowClearButton, setShouldShowClearButton] = useState(false);\n const [isInputFocussed, setIsInputFocussed] = useState(autoFocus ?? false);\n\n if (__DEV__) {\n if (format) {\n const hasAlphanumeric = /[a-zA-Z0-9]/.test(format);\n if (hasAlphanumeric) {\n throw new Error(\n `[Blade: TextInput] Invalid format \"${format}\". Only # and special characters allowed, no letters/numbers.`,\n );\n }\n }\n }\n\n const formattingResult = useFormattedInput({\n format,\n onChange,\n value,\n defaultValue,\n });\n\n const inputValue = format ? formattingResult.formattedValue : value;\n const effectiveMaxCharacters = format ? formattingResult.maxLength : maxCharacters;\n\n const handleOnChange: FormInputOnEvent = React.useCallback(\n ({ name, value: inputValue }) => {\n if (format) {\n formattingResult.handleChange({ name, value: inputValue });\n } else {\n onChange?.({ name, value: inputValue });\n }\n },\n [format, formattingResult.handleChange, onChange],\n );\n\n const {\n activeTagIndex,\n setActiveTagIndex,\n getTags,\n handleTaggedInputKeydown,\n handleTaggedInputChange,\n handleTagsClear,\n } = useTaggedInput({\n isTaggedInput,\n tags,\n onTagChange,\n isDisabled,\n onChange: handleOnChange,\n name,\n value: inputValue,\n inputRef: textInputRef,\n });\n const [isTrailingDropDownOpen, setIsTrailingDropDownOpen] = React.useState(false);\n const [isLeadingDropDownOpen, setIsLeadingDropDownOpen] = React.useState(false);\n const textInputWrapperRef = useRef<ContainerElementType | null>(null);\n\n useEffect(() => {\n if (isTrailingDropDownOpen && isLeadingDropDownOpen) {\n setIsLeadingDropDownOpen(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isTrailingDropDownOpen]);\n\n useEffect(() => {\n if (isLeadingDropDownOpen && isTrailingDropDownOpen) {\n setIsTrailingDropDownOpen(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isLeadingDropDownOpen]);\n\n const leadingDropDown =\n leading && getComponentId(leading as React.ReactElement) === 'Dropdown' ? leading : null;\n\n const trailingDropdown =\n trailing && getComponentId(trailing as React.ReactElement) === 'Dropdown' ? trailing : null;\n // we need to look into name of component and check if it 's and icon or a dropdown\n const _leadingIcon: IconComponent | undefined = isIconComponent(leading)\n ? (leading as IconComponent)\n : undefined;\n\n const _trailingIcon: IconComponent | undefined = isIconComponent(trailing)\n ? (trailing as IconComponent)\n : undefined;\n const hasLeadingInteractionElement = !_leadingIcon && !leadingDropDown && leading;\n\n const hasTrailingInteractionElement = !_trailingIcon && !trailingDropdown && trailing;\n\n const renderDropdown = (\n dropdown: React.ReactElement,\n isOpen: boolean,\n setIsOpen: (isOpen: boolean) => void,\n defaultPlacement: 'bottom-start' | 'bottom-end',\n ): React.ReactElement | null => {\n if (!dropdown) {\n return null;\n }\n return React.cloneElement(dropdown, {\n selectionType: 'single',\n isOpen,\n onOpenChange: (isOpen: boolean) => {\n setIsOpen(isOpen);\n },\n children: React.Children.map(dropdown.props.children, (child) => {\n if (child.type === DropdownOverlay) {\n return React.cloneElement(child, {\n referenceRef: textInputWrapperRef,\n _isNestedDropdown: true,\n defaultPlacement,\n });\n }\n return child;\n }),\n });\n };\n\n const renderLeadingDropDown = renderDropdown(\n leadingDropDown as React.ReactElement,\n isLeadingDropDownOpen,\n setIsLeadingDropDownOpen,\n 'bottom-start',\n );\n const renderTrailingDropDown = renderDropdown(\n trailingDropdown as React.ReactElement,\n isTrailingDropDownOpen,\n setIsTrailingDropDownOpen,\n 'bottom-end',\n );\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(showClearButton && (defaultValue ?? inputValue)));\n }, [showClearButton, defaultValue, inputValue]);\n\n const renderClearButton = (): React.ReactElement => {\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(inputValue) && textInputRef.current) {\n // when the input field is uncontrolled take the ref and clear the input and then call the onClearButtonClick function\n if (isReactNative(textInputRef.current)) {\n textInputRef.current.clear();\n textInputRef.current.focus();\n } else if (textInputRef.current instanceof HTMLInputElement) {\n textInputRef.current.value = '';\n textInputRef.current.focus();\n }\n }\n handleTagsClear();\n // if the input field is controlled just call the click handler and the value change shall be left upto the consumer\n onClearButtonClick?.();\n textInputRef?.current?.focus();\n setShouldShowClearButton(false);\n }}\n isDisabled={isDisabled}\n accessibilityLabel=\"Clear Input Content\"\n />\n );\n };\n const hasTrailingDropDown = Boolean(trailingDropdown);\n\n const renderInteractionElement = (): ReactNode => {\n if (isLoading) {\n return <Spinner accessibilityLabel=\"Loading Content\" color=\"primary\" />;\n }\n\n if (shouldShowClearButton && hasTrailingDropDown) {\n return (\n <BaseBox display=\"flex\" gap=\"spacing.3\">\n {renderClearButton()} <Divider orientation=\"vertical\" />\n </BaseBox>\n );\n }\n\n if (showClearButton && hasTrailingInteractionElement) {\n return (\n <BaseBox display=\"flex\" gap=\"spacing.3\">\n {renderClearButton()} <Divider orientation=\"vertical\" /> {trailing as React.ReactElement}\n </BaseBox>\n );\n }\n\n if (shouldShowClearButton) {\n return renderClearButton();\n }\n\n if (hasTrailingInteractionElement) {\n return trailing as React.ReactElement;\n }\n return null;\n };\n return (\n <BaseInput\n id=\"textinput\"\n componentName={MetaConstants.TextInput}\n ref={mergedRef}\n setInputWrapperRef={(wrapperNode) => {\n textInputWrapperRef.current = wrapperNode;\n }}\n label={label as string}\n labelSuffix={labelSuffix}\n labelTrailing={labelTrailing}\n accessibilityLabel={accessibilityLabel}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n placeholder={placeholder}\n // CONTROLLED/UNCONTROLLED INPUT LOGIC:\n // For inputs WITHOUT format:\n // - Use standard React controlled/uncontrolled logic\n // - Controlled: user provides `value` prop → use `value` prop\n // - Uncontrolled: user provides `defaultValue` prop → use `defaultValue` prop\n //\n // For inputs WITH format:\n // - Formatting requires controlled mode to re-render and show formatted values\n // - Case 1: Only `value` provided → defaultValue: undefined, value: formattedValue (normal controlled)\n // - Case 2: Only `defaultValue` provided → defaultValue: undefined, value: formattedValue (convert to controlled)\n // - Case 3: Both `value` and `defaultValue` provided → defaultValue: defaultValue, value: formattedValue (let BaseInput detect conflict and throw error)\n //\n defaultValue={\n format\n ? value !== undefined && defaultValue !== undefined\n ? defaultValue\n : undefined\n : defaultValue\n }\n value={format ? inputValue : value}\n name={name}\n maxCharacters={effectiveMaxCharacters}\n isDropdownTrigger={isTaggedInput}\n tags={isTaggedInput ? getTags({ size }) : undefined}\n showAllTags={isInputFocussed}\n maxTagRows=\"single\"\n activeTagIndex={activeTagIndex}\n setActiveTagIndex={setActiveTagIndex}\n leadingDropDown={renderLeadingDropDown}\n trailingDropDown={renderTrailingDropDown}\n leadingInteractionElement={\n hasLeadingInteractionElement ? (leading as React.ReactElement) : null\n }\n onChange={({ name, value }: { name?: string; value?: string }) => {\n if (showClearButton && value?.length) {\n // show the clear button when the user starts typing in\n setShouldShowClearButton(true);\n }\n\n if (shouldShowClearButton && !value?.length) {\n // hide the clear button when the input field is empty\n setShouldShowClearButton(false);\n }\n\n handleTaggedInputChange({ name, value });\n handleOnChange({ name, value });\n }}\n onClick={onClick}\n onFocus={(e) => {\n setIsInputFocussed(true);\n onFocus?.(e);\n }}\n onBlur={(e) => {\n setIsInputFocussed(false);\n onBlur?.(e);\n }}\n onKeyDown={(e) => {\n handleTaggedInputKeydown(e);\n onKeyDown?.(e);\n if (format) {\n formattingResult.handleKeyDown(e.event);\n }\n }}\n onSubmit={onSubmit}\n isDisabled={isDisabled}\n necessityIndicator={necessityIndicator}\n isRequired={isRequired}\n leadingIcon={_leadingIcon ?? leadingIcon ?? icon}\n prefix={prefix}\n trailingInteractionElement={renderInteractionElement()}\n trailingIcon={_trailingIcon ?? trailingIcon}\n suffix={suffix}\n validationState={validationState}\n errorText={errorText}\n helpText={helpText}\n successText={successText}\n trailingFooterSlot={(value) => {\n return format ? null : effectiveMaxCharacters ? (\n <BaseBox marginTop={hintMarginTop[size]} marginRight=\"spacing.1\">\n <CharacterCounter\n currentCount={value?.length ?? 0}\n maxCount={effectiveMaxCharacters}\n size={size}\n />\n </BaseBox>\n ) : null;\n }}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n {...getKeyboardAndAutocompleteProps({\n type,\n keyboardReturnKeyType,\n autoCompleteSuggestionType,\n autoCapitalize,\n })}\n size={size}\n {...rest}\n />\n );\n};\n\nconst TextInput = assignWithoutSideEffects(React.forwardRef(_TextInput), {\n displayName: 'TextInput',\n});\n\nexport type { TextInputProps };\nexport { TextInput };\n"],"names":["isReactNative","_textInputRef","getPlatformType","_TextInput","_ref","ref","_ref4","label","accessibilityLabel","_ref$labelPosition","labelPosition","placeholder","_ref$type","type","defaultValue","name","value","maxCharacters","format","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","necessityIndicator","validationState","errorText","helpText","successText","isRequired","icon","prefix","showClearButton","onClearButtonClick","isLoading","suffix","autoFocus","keyboardReturnKeyType","autoCompleteSuggestionType","autoCapitalize","testID","_ref$size","size","leadingIcon","trailingIcon","isTaggedInput","tags","onTagChange","trailing","leading","labelSuffix","labelTrailing","onKeyDown","rest","_objectWithoutProperties","_excluded","textInputRef","React","useRef","mergedRef","useMergeRefs","_useState","useState","_useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useState3","_useState4","isInputFocussed","setIsInputFocussed","__DEV__","hasAlphanumeric","test","Error","formattingResult","useFormattedInput","inputValue","formattedValue","effectiveMaxCharacters","maxLength","handleOnChange","useCallback","_ref2","handleChange","_useTaggedInput","useTaggedInput","inputRef","activeTagIndex","setActiveTagIndex","getTags","handleTaggedInputKeydown","handleTaggedInputChange","handleTagsClear","_React$useState","_React$useState2","isTrailingDropDownOpen","setIsTrailingDropDownOpen","_React$useState3","_React$useState4","isLeadingDropDownOpen","setIsLeadingDropDownOpen","textInputWrapperRef","useEffect","leadingDropDown","getComponentId","trailingDropdown","_leadingIcon","isIconComponent","undefined","_trailingIcon","hasLeadingInteractionElement","hasTrailingInteractionElement","renderDropdown","dropdown","isOpen","setIsOpen","defaultPlacement","cloneElement","selectionType","onOpenChange","children","Children","map","props","child","DropdownOverlay","referenceRef","_isNestedDropdown","renderLeadingDropDown","renderTrailingDropDown","Boolean","renderClearButton","_jsx","IconButton","CloseIcon","_textInputRef$current","isEmpty","current","clear","focus","HTMLInputElement","hasTrailingDropDown","renderInteractionElement","Spinner","color","_jsxs","BaseBox","display","gap","Divider","orientation","BaseInput","Object","assign","id","componentName","MetaConstants","TextInput","setInputWrapperRef","wrapperNode","hideLabelText","isDropdownTrigger","showAllTags","maxTagRows","trailingDropDown","leadingInteractionElement","_ref3","length","e","handleKeyDown","event","trailingInteractionElement","trailingFooterSlot","_value$length","marginTop","hintMarginTop","marginRight","CharacterCounter","currentCount","maxCount","getKeyboardAndAutocompleteProps","assignWithoutSideEffects","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAW,CAAAxD,QAAA,CAC9DY,GAAA,CAAC6C,gBAAgB,CAAA,CACfC,YAAY,CAAA,CAAAL,aAAA,CAAE/J,KAAK,EAALA,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,KAAK,CAAEyJ,MAAM,GAAAM,IAAAA,CAAAA,aAAA,CAAI,CAAE,CACjCM,QAAQ,CAAErG,sBAAuB,CACjCrC,IAAI,CAAEA,IAAK,CACZ,CAAC,CACK,CAAC,CACR,IAAI,CACV,CAAE,CAEFN,SAAS,CAAEA,SAAU,CACrBI,MAAM,CAAEA,MAAO,CACX6I,CAAAA,+BAA+B,CAAC,CAClCzK,IAAI,CAAJA,IAAI,CACJyB,qBAAqB,CAArBA,qBAAqB,CACrBC,0BAA0B,CAA1BA,0BAA0B,CAC1BC,cAAc,CAAdA,cACF,CAAC,CAAC,CACFG,CAAAA,IAAI,CAAEA,IAAK,EACPW,IAAI,CACT,CAAC,CAEN,CAAC,CAEK,IAAAyG,SAAS,CAAGwB,wBAAwB,CAAC7H,cAAK,CAAC8H,UAAU,CAACrL,UAAU,CAAC,CAAE,CACvEsL,WAAW,CAAE,WACf,CAAC;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import { useMemo, useState, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
|
|
4
|
-
var format=function format(value,pattern){if(!pattern)return value;var result='';var valueIndex=0;for(var i=0;i<pattern.length;i++){var patternChar=pattern[i];if(patternChar==='#'){if(valueIndex<value.length){result+=value[valueIndex];valueIndex++;}else {break;}}else {result+=patternChar;}}return result;};var stripPatternCharacters=function stripPatternCharacters(value){return value.replace(/[^\dA-z]/g,'');};var isUserCharacter=function isUserCharacter(character){return /[\dA-z]/.test(character);};var useFormattedInput=function useFormattedInput(_ref){var pattern=_ref.format,onChange=_ref.onChange,userValue=_ref.value,_ref$defaultValue=_ref.defaultValue,defaultValue=_ref$defaultValue===void 0?'':_ref$defaultValue;var initialValue=useMemo(function(){return format(userValue!=null?userValue:defaultValue,pattern!=null?pattern:'');},[userValue,defaultValue,pattern]);var _useState=useState(initialValue),_useState2=_slicedToArray(_useState,2),internalValue=_useState2[0],setInternalValue=_useState2[1];var inputRef=useRef(null);var infoRef=useRef({});var maxLength=useMemo(function(){return pattern==null?void 0:pattern.length;},[pattern]);useEffect(function(){if((userValue===''||userValue===undefined)&&defaultValue===''){var emptyFormatted=format('',pattern!=null?pattern:'');setInternalValue(emptyFormatted);}},[userValue,pattern]);useEffect(function(){var _infoRef$current=infoRef.current,cursorPosition=_infoRef$current.cursorPosition,endOfSection=_infoRef$current.endOfSection;if(endOfSection||cursorPosition===undefined)return;if(inputRef.current){inputRef.current.setSelectionRange(cursorPosition,cursorPosition);}},[internalValue]);var handleChange=useCallback(function(_ref2){var _inputRef$current$sel,_inputRef$current;var name=_ref2.name,inputValue=_ref2.value;if(!pattern){var cleanValue=inputValue!=null?inputValue:'';onChange==null?void 0:onChange({name:name,value:cleanValue});setInternalValue(cleanValue);return;}var currentValue=internalValue;var newInputValue=inputValue!=null?inputValue:'';var cursorPosition=(_inputRef$current$sel=(_inputRef$current=inputRef.current)==null?void 0:_inputRef$current.selectionStart)!=null?_inputRef$current$sel:0;var didDelete=newInputValue.length<currentValue.length;infoRef.current.cursorPosition=cursorPosition;var rawValue=stripPatternCharacters(newInputValue);if(didDelete){var _currentValue$cursorP;var deletedChar=(_currentValue$cursorP=currentValue[cursorPosition])!=null?_currentValue$cursorP:'';var deletedDelimiter=!isUserCharacter(deletedChar);if(deletedDelimiter){var beforeCursor=newInputValue.substring(0,cursorPosition);var afterCursor=newInputValue.substring(cursorPosition);var rawBefore=stripPatternCharacters(beforeCursor);var rawAfter=stripPatternCharacters(afterCursor);rawValue=rawBefore.slice(0,-1)+rawAfter;infoRef.current.cursorPosition=beforeCursor.replace(/([\d\w]+)[^\dA-z]+$/,'$1').length-1;}}var formattedValue=format(rawValue,pattern);infoRef.current.endOfSection=false;if(!didDelete){var nextChar=formattedValue[cursorPosition];var nextIsDelimiter=nextChar?!isUserCharacter(nextChar):false;var remainingText=formattedValue.substring(cursorPosition);var nextUserCharIndex=remainingText.search(/[\dA-z]/);var hasMoreUserChars=nextUserCharIndex!==-1;infoRef.current.endOfSection=nextIsDelimiter&&!hasMoreUserChars;if(nextIsDelimiter&&hasMoreUserChars){var _formattedValue;var prevChar=(_formattedValue=formattedValue[cursorPosition-1])!=null?_formattedValue:'';var prevIsDelimiter=!isUserCharacter(prevChar);if(prevIsDelimiter){infoRef.current.cursorPosition=cursorPosition+nextUserCharIndex+1;}}}onChange==null?void 0:onChange({name:name,value:formattedValue,rawValue:rawValue});setInternalValue(formattedValue);},[pattern,onChange,internalValue]);var handleKeyDown=useCallback(function(event){if(event.currentTarget&&inputRef.current!==event.currentTarget){inputRef.current=event.currentTarget;}},[]);return {formattedValue:internalValue,handleChange:handleChange,handleKeyDown:handleKeyDown,maxLength:maxLength};};
|
|
4
|
+
var format=function format(value,pattern){if(!pattern)return value;var result='';var valueIndex=0;for(var i=0;i<pattern.length;i++){var patternChar=pattern[i];if(patternChar==='#'){if(valueIndex<value.length){result+=value[valueIndex];valueIndex++;}else {break;}}else {result+=patternChar;}}return result;};var stripPatternCharacters=function stripPatternCharacters(value){return value.replace(/[^\dA-z]/g,'');};var isUserCharacter=function isUserCharacter(character){return /[\dA-z]/.test(character);};var useFormattedInput=function useFormattedInput(_ref){var pattern=_ref.format,onChange=_ref.onChange,userValue=_ref.value,_ref$defaultValue=_ref.defaultValue,defaultValue=_ref$defaultValue===void 0?'':_ref$defaultValue;var initialValue=useMemo(function(){return format(userValue!=null?userValue:defaultValue,pattern!=null?pattern:'');},[userValue,defaultValue,pattern]);var _useState=useState(initialValue),_useState2=_slicedToArray(_useState,2),internalValue=_useState2[0],setInternalValue=_useState2[1];var inputRef=useRef(null);var infoRef=useRef({});var maxLength=useMemo(function(){return pattern==null?void 0:pattern.length;},[pattern]);useEffect(function(){if((userValue===''||userValue===undefined)&&defaultValue===''){var emptyFormatted=format('',pattern!=null?pattern:'');setInternalValue(emptyFormatted);}if(userValue!==undefined&&userValue!==''&&pattern){var rawValue=stripPatternCharacters(userValue);var newFormatted=format(rawValue,pattern);if(newFormatted!==internalValue){setInternalValue(newFormatted);}}},[userValue,pattern]);useEffect(function(){var _infoRef$current=infoRef.current,cursorPosition=_infoRef$current.cursorPosition,endOfSection=_infoRef$current.endOfSection;if(endOfSection||cursorPosition===undefined)return;if(inputRef.current){inputRef.current.setSelectionRange(cursorPosition,cursorPosition);}},[internalValue]);var handleChange=useCallback(function(_ref2){var _inputRef$current$sel,_inputRef$current;var name=_ref2.name,inputValue=_ref2.value;if(!pattern){var cleanValue=inputValue!=null?inputValue:'';onChange==null?void 0:onChange({name:name,value:cleanValue});setInternalValue(cleanValue);return;}var currentValue=internalValue;var newInputValue=inputValue!=null?inputValue:'';var cursorPosition=(_inputRef$current$sel=(_inputRef$current=inputRef.current)==null?void 0:_inputRef$current.selectionStart)!=null?_inputRef$current$sel:0;var didDelete=newInputValue.length<currentValue.length;infoRef.current.cursorPosition=cursorPosition;var rawValue=stripPatternCharacters(newInputValue);if(didDelete){var _currentValue$cursorP;var deletedChar=(_currentValue$cursorP=currentValue[cursorPosition])!=null?_currentValue$cursorP:'';var deletedDelimiter=!isUserCharacter(deletedChar);if(deletedDelimiter){var beforeCursor=newInputValue.substring(0,cursorPosition);var afterCursor=newInputValue.substring(cursorPosition);var rawBefore=stripPatternCharacters(beforeCursor);var rawAfter=stripPatternCharacters(afterCursor);rawValue=rawBefore.slice(0,-1)+rawAfter;infoRef.current.cursorPosition=beforeCursor.replace(/([\d\w]+)[^\dA-z]+$/,'$1').length-1;}}var formattedValue=format(rawValue,pattern);infoRef.current.endOfSection=false;if(!didDelete){var nextChar=formattedValue[cursorPosition];var nextIsDelimiter=nextChar?!isUserCharacter(nextChar):false;var remainingText=formattedValue.substring(cursorPosition);var nextUserCharIndex=remainingText.search(/[\dA-z]/);var hasMoreUserChars=nextUserCharIndex!==-1;infoRef.current.endOfSection=nextIsDelimiter&&!hasMoreUserChars;if(nextIsDelimiter&&hasMoreUserChars){var _formattedValue;var prevChar=(_formattedValue=formattedValue[cursorPosition-1])!=null?_formattedValue:'';var prevIsDelimiter=!isUserCharacter(prevChar);if(prevIsDelimiter){infoRef.current.cursorPosition=cursorPosition+nextUserCharIndex+1;}else {var delimiterExistedBefore=currentValue[cursorPosition]===formattedValue[cursorPosition];if(delimiterExistedBefore){infoRef.current.cursorPosition=cursorPosition+1;}}}}onChange==null?void 0:onChange({name:name,value:formattedValue,rawValue:rawValue});setInternalValue(formattedValue);},[pattern,onChange,internalValue]);var handleKeyDown=useCallback(function(event){if(event.currentTarget&&inputRef.current!==event.currentTarget){inputRef.current=event.currentTarget;}},[]);return {formattedValue:internalValue,handleChange:handleChange,handleKeyDown:handleKeyDown,maxLength:maxLength};};
|
|
5
5
|
|
|
6
6
|
export { useFormattedInput };
|
|
7
7
|
//# sourceMappingURL=useFormattedInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormattedInput.js","sources":["../../../../../../src/components/Input/TextInput/useFormattedInput.ts"],"sourcesContent":["import type React from 'react';\nimport { useCallback, useRef, useState, useEffect, useMemo } from 'react';\nimport type { FormInputOnEvent } from '~components/Form/FormTypes';\n\n/**\n * Formats user input according to pattern. format(\"1234\", \"##/##\") → \"12/34\"\n */\nconst format = (value: string, pattern: string): string => {\n if (!pattern) return value;\n\n let result = '';\n let valueIndex = 0;\n\n for (let i = 0; i < pattern.length; i++) {\n const patternChar = pattern[i]; // \"#\" or \"/\"\n\n if (patternChar === '#') {\n if (valueIndex < value.length) {\n result += value[valueIndex]; // add \"1\" from \"1234\"\n valueIndex++;\n } else {\n break; // No more input chars, stop\n }\n } else {\n result += patternChar; // add \"/\" delimiter\n }\n }\n\n return result; // \"12/34\"\n};\n\n/**\n * Removes delimiters, keeps only user input. stripPatternCharacters(\"12/34\") → \"1234\"\n */\nconst stripPatternCharacters = (value: string): string => {\n return value.replace(/[^\\dA-z]/g, ''); // \"12/34\" → \"1234\" (removes \"/\")\n};\n\n/**\n * Checks if character is user input vs delimiter. isUserCharacter('1') → true, isUserCharacter('/') → false\n */\nconst isUserCharacter = (character: string): boolean => {\n return /[\\dA-z]/.test(character); // \"1\" → true, \"/\" → false\n};\n\ntype UseFormattedInputProps = {\n format?: string;\n onChange?: (params: { name?: string; value?: string; rawValue?: string }) => void;\n value?: string;\n defaultValue?: string;\n};\n\ntype UseFormattedInputReturn = {\n formattedValue: string;\n handleChange: FormInputOnEvent;\n handleKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n maxLength?: number;\n};\n\n/**\n * Hook for pattern-based input formatting with smart cursor positioning.\n * useFormattedInput({ format: \"##/##\" }) transforms \"1234\" → \"12/34\"\n */\nexport const useFormattedInput = ({\n format: pattern,\n onChange,\n value: userValue,\n defaultValue = '',\n}: UseFormattedInputProps): UseFormattedInputReturn => {\n const initialValue = useMemo(() => {\n return format(userValue ?? defaultValue, pattern ?? '');\n }, [userValue, defaultValue, pattern]);\n\n const [internalValue, setInternalValue] = useState(initialValue);\n const inputRef = useRef<HTMLInputElement | null>(null);\n const infoRef = useRef<{\n cursorPosition?: number;\n endOfSection?: boolean;\n }>({});\n\n const maxLength = useMemo(() => pattern?.length, [pattern]);\n\n // Reset internal state when parent clears value (form resets, external state changes)\n // Preserves format delimiters for visual guidance. Example: \"(###)\" → \"( )\" when cleared\n useEffect(() => {\n if ((userValue === '' || userValue === undefined) && defaultValue === '') {\n const emptyFormatted = format('', pattern ?? '');\n setInternalValue(emptyFormatted);\n }\n }, [userValue, pattern]);\n\n // Apply calculated cursor position after value updates\n useEffect(() => {\n const { cursorPosition, endOfSection } = infoRef.current;\n\n if (endOfSection || cursorPosition === undefined) return; // Skip if no position or end section\n\n if (inputRef.current) {\n inputRef.current.setSelectionRange(cursorPosition, cursorPosition);\n }\n }, [internalValue]);\n\n const handleChange: FormInputOnEvent = useCallback(\n ({ name, value: inputValue }) => {\n if (!pattern) {\n // No pattern = regular input\n const cleanValue = inputValue ?? '';\n onChange?.({ name, value: cleanValue });\n setInternalValue(cleanValue);\n return;\n }\n\n const currentValue = internalValue; // \"12/34\" (user wants to delete \"/\")\n const newInputValue = inputValue ?? ''; // \"1234\" (after deleting \"/\")\n const cursorPosition = inputRef.current?.selectionStart ?? 0; // 2 (cursor where \"/\" was)\n const didDelete = newInputValue.length < currentValue.length; // 4 < 5 → true\n\n infoRef.current.cursorPosition = cursorPosition;\n\n let rawValue = stripPatternCharacters(newInputValue); // \"1234\" → \"1234\"\n\n // Handle special case: user deleted a delimiter (like deleting \"/\" in \"12/|34\")\n if (didDelete) {\n const deletedChar = currentValue[cursorPosition] ?? ''; // \"12/34\"[2] → \"/\"\n const deletedDelimiter = !isUserCharacter(deletedChar); // \"/\" → true (is delimiter)\n\n if (deletedDelimiter) {\n // true (will execute for \"/\" deletion)\n const beforeCursor = newInputValue.substring(0, cursorPosition); // \"12\" (before cursor)\n const afterCursor = newInputValue.substring(cursorPosition); // \"34\" (after cursor)\n const rawBefore = stripPatternCharacters(beforeCursor); // \"12\" → \"12\"\n const rawAfter = stripPatternCharacters(afterCursor); // \"34\" → \"34\"\n\n rawValue = rawBefore.slice(0, -1) + rawAfter; // \"12\".slice(0,-1) + \"34\" → \"1\" + \"34\" → \"134\"\n\n // Removes trailing non-alphanumeric characters from the end of the string, preserving the last alphanumeric word before them.\n infoRef.current.cursorPosition =\n beforeCursor.replace(/([\\d\\w]+)[^\\dA-z]+$/, '$1').length - 1;\n }\n }\n\n const formattedValue = format(rawValue, pattern); // format(\"134\", \"##/##\") → \"13/4\"\n infoRef.current.endOfSection = false;\n\n // Handle cursor positioning when typing (not deleting)\n if (!didDelete) {\n // User types \"2\" in \"1|\" → becomes \"12|/\" → should jump to \"12/|\"\n const nextChar = formattedValue[cursorPosition]; // \"12/\"[2] → \"/\" (delimiter)\n const nextIsDelimiter = nextChar ? !isUserCharacter(nextChar) : false; // \"/\" → true\n\n const remainingText = formattedValue.substring(cursorPosition); // \"12/\".substring(2) → \"/\"\n const nextUserCharIndex = remainingText.search(/[\\dA-z]/); // \"/\".search() → -1 (no user chars)\n const hasMoreUserChars = nextUserCharIndex !== -1; // -1 !== -1 → false\n\n infoRef.current.endOfSection = nextIsDelimiter && !hasMoreUserChars; // true && false → false\n\n // Move cursor past auto-inserted delimiters for smooth typing\n if (nextIsDelimiter && hasMoreUserChars) {\n const prevChar = formattedValue[cursorPosition - 1] ?? '';\n const prevIsDelimiter = !isUserCharacter(prevChar);\n\n if (prevIsDelimiter) {\n infoRef.current.cursorPosition = cursorPosition + nextUserCharIndex + 1;\n }\n }\n }\n\n onChange?.({ name, value: formattedValue, rawValue });\n setInternalValue(formattedValue);\n },\n [pattern, onChange, internalValue],\n );\n\n const handleKeyDown = useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.currentTarget && inputRef.current !== event.currentTarget) {\n inputRef.current = event.currentTarget;\n }\n }, []);\n\n return {\n formattedValue: internalValue,\n handleChange,\n handleKeyDown,\n maxLength,\n };\n};\n"],"names":["format","value","pattern","result","valueIndex","i","length","patternChar","stripPatternCharacters","replace","isUserCharacter","character","test","useFormattedInput","_ref","onChange","userValue","_ref$defaultValue","defaultValue","initialValue","useMemo","_useState","useState","_useState2","_slicedToArray","internalValue","setInternalValue","inputRef","useRef","infoRef","maxLength","useEffect","undefined","emptyFormatted","_infoRef$current","current","cursorPosition","endOfSection","setSelectionRange","handleChange","useCallback","_ref2","_inputRef$current$sel","_inputRef$current","name","inputValue","cleanValue","currentValue","newInputValue","selectionStart","didDelete","rawValue","_currentValue$cursorP","deletedChar","deletedDelimiter","beforeCursor","substring","afterCursor","rawBefore","rawAfter","slice","formattedValue","nextChar","nextIsDelimiter","remainingText","nextUserCharIndex","search","hasMoreUserChars","_formattedValue","prevChar","prevIsDelimiter","handleKeyDown","event","currentTarget"],"mappings":";;;AAOA,IAAMA,MAAM,CAAG,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CAAI,EAAE,CACzD,IAAME,eAAe,CAAG,CAAC5D,eAAe,CAAC2D,QAAQ,CAAC,CAElD,GAAIC,eAAe,CAAE,CACnBzC,OAAO,CAACM,OAAO,CAACC,cAAc,CAAGA,cAAc,CAAG6B,iBAAiB,CAAG,CAAC,CACzE,CACF,CACF,CAEAlD,QAAQ,EAARA,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,QAAQ,CAAG,CAAE6B,IAAI,CAAJA,IAAI,CAAE3C,KAAK,CAAE4D,cAAc,CAAEV,QAAQ,CAARA,QAAS,CAAC,CAAC,CACrDzB,gBAAgB,CAACmC,cAAc,CAAC,CAClC,CAAC,CACD,CAAC3D,OAAO,CAAEa,QAAQ,CAAEU,aAAa,CACnC,CAAC,CAED,IAAM8C,aAAa,CAAG/B,WAAW,CAAC,SAACgC,KAA4C,CAAK,CAClF,GAAIA,KAAK,CAACC,aAAa,EAAI9C,QAAQ,CAACQ,OAAO,GAAKqC,KAAK,CAACC,aAAa,CAAE,CACnE9C,QAAQ,CAACQ,OAAO,CAAGqC,KAAK,CAACC,aAAa,CACxC,CACF,CAAC,CAAE,EAAE,CAAC,CAEN,OAAO,CACLZ,cAAc,CAAEpC,aAAa,CAC7Bc,YAAY,CAAZA,YAAY,CACZgC,aAAa,CAAbA,aAAa,CACbzC,SAAS,CAATA,SACF,CAAC,CACH;;;;"}
|
|
1
|
+
{"version":3,"file":"useFormattedInput.js","sources":["../../../../../../src/components/Input/TextInput/useFormattedInput.ts"],"sourcesContent":["import type React from 'react';\nimport { useCallback, useRef, useState, useEffect, useMemo } from 'react';\nimport type { FormInputOnEvent } from '~components/Form/FormTypes';\n\n/**\n * Formats user input according to pattern. format(\"1234\", \"##/##\") → \"12/34\"\n */\nconst format = (value: string, pattern: string): string => {\n if (!pattern) return value;\n\n let result = '';\n let valueIndex = 0;\n\n for (let i = 0; i < pattern.length; i++) {\n const patternChar = pattern[i]; // \"#\" or \"/\"\n\n if (patternChar === '#') {\n if (valueIndex < value.length) {\n result += value[valueIndex]; // add \"1\" from \"1234\"\n valueIndex++;\n } else {\n break; // No more input chars, stop\n }\n } else {\n result += patternChar; // add \"/\" delimiter\n }\n }\n\n return result; // \"12/34\"\n};\n\n/**\n * Removes delimiters, keeps only user input. stripPatternCharacters(\"12/34\") → \"1234\"\n */\nconst stripPatternCharacters = (value: string): string => {\n return value.replace(/[^\\dA-z]/g, ''); // \"12/34\" → \"1234\" (removes \"/\")\n};\n\n/**\n * Checks if character is user input vs delimiter. isUserCharacter('1') → true, isUserCharacter('/') → false\n */\nconst isUserCharacter = (character: string): boolean => {\n return /[\\dA-z]/.test(character); // \"1\" → true, \"/\" → false\n};\n\ntype UseFormattedInputProps = {\n format?: string;\n onChange?: (params: { name?: string; value?: string; rawValue?: string }) => void;\n value?: string;\n defaultValue?: string;\n};\n\ntype UseFormattedInputReturn = {\n formattedValue: string;\n handleChange: FormInputOnEvent;\n handleKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n maxLength?: number;\n};\n\n/**\n * Hook for pattern-based input formatting with smart cursor positioning.\n * useFormattedInput({ format: \"##/##\" }) transforms \"1234\" → \"12/34\"\n */\nexport const useFormattedInput = ({\n format: pattern,\n onChange,\n value: userValue,\n defaultValue = '',\n}: UseFormattedInputProps): UseFormattedInputReturn => {\n const initialValue = useMemo(() => {\n return format(userValue ?? defaultValue, pattern ?? '');\n }, [userValue, defaultValue, pattern]);\n\n const [internalValue, setInternalValue] = useState(initialValue);\n const inputRef = useRef<HTMLInputElement | null>(null);\n const infoRef = useRef<{\n cursorPosition?: number;\n endOfSection?: boolean;\n }>({});\n\n const maxLength = useMemo(() => pattern?.length, [pattern]);\n\n // Reset internal state when parent clears value (form resets, external state changes)\n // Preserves format delimiters for visual guidance. Example: \"(###)\" → \"( )\" when cleared\n useEffect(() => {\n if ((userValue === '' || userValue === undefined) && defaultValue === '') {\n const emptyFormatted = format('', pattern ?? '');\n setInternalValue(emptyFormatted);\n }\n // DATEPICKER FIX: Sync internal state when external value changes\n // This addresses the issue where DatePicker programmatically updates the value prop\n // (e.g., when user selects date from calendar), but the formatted input's internal\n // state doesn't update, causing the input to not reflect the new value.\n // Without this, only user typing and empty resets were handled.\n if (userValue !== undefined && userValue !== '' && pattern) {\n const rawValue = stripPatternCharacters(userValue);\n const newFormatted = format(rawValue, pattern);\n\n // Only update if the formatted value actually changed to avoid unnecessary re-renders\n if (newFormatted !== internalValue) {\n setInternalValue(newFormatted);\n }\n }\n }, [userValue, pattern]);\n\n // Apply calculated cursor position after value updates\n useEffect(() => {\n const { cursorPosition, endOfSection } = infoRef.current;\n\n if (endOfSection || cursorPosition === undefined) return; // Skip if no position or end section\n\n if (inputRef.current) {\n inputRef.current.setSelectionRange(cursorPosition, cursorPosition);\n }\n }, [internalValue]);\n\n const handleChange: FormInputOnEvent = useCallback(\n ({ name, value: inputValue }) => {\n if (!pattern) {\n // No pattern = regular input\n const cleanValue = inputValue ?? '';\n onChange?.({ name, value: cleanValue });\n setInternalValue(cleanValue);\n return;\n }\n\n const currentValue = internalValue; // \"12/34\" (user wants to delete \"/\")\n const newInputValue = inputValue ?? ''; // \"1234\" (after deleting \"/\")\n const cursorPosition = inputRef.current?.selectionStart ?? 0; // 2 (cursor where \"/\" was)\n const didDelete = newInputValue.length < currentValue.length; // 4 < 5 → true\n\n infoRef.current.cursorPosition = cursorPosition;\n\n let rawValue = stripPatternCharacters(newInputValue); // \"1234\" → \"1234\"\n\n // Handle special case: user deleted a delimiter (like deleting \"/\" in \"12/|34\")\n if (didDelete) {\n const deletedChar = currentValue[cursorPosition] ?? ''; // \"12/34\"[2] → \"/\"\n const deletedDelimiter = !isUserCharacter(deletedChar); // \"/\" → true (is delimiter)\n\n if (deletedDelimiter) {\n // true (will execute for \"/\" deletion)\n const beforeCursor = newInputValue.substring(0, cursorPosition); // \"12\" (before cursor)\n const afterCursor = newInputValue.substring(cursorPosition); // \"34\" (after cursor)\n const rawBefore = stripPatternCharacters(beforeCursor); // \"12\" → \"12\"\n const rawAfter = stripPatternCharacters(afterCursor); // \"34\" → \"34\"\n\n rawValue = rawBefore.slice(0, -1) + rawAfter; // \"12\".slice(0,-1) + \"34\" → \"1\" + \"34\" → \"134\"\n\n // Removes trailing non-alphanumeric characters from the end of the string, preserving the last alphanumeric word before them.\n infoRef.current.cursorPosition =\n beforeCursor.replace(/([\\d\\w]+)[^\\dA-z]+$/, '$1').length - 1;\n }\n }\n\n const formattedValue = format(rawValue, pattern); // format(\"134\", \"##/##\") → \"13/4\"\n infoRef.current.endOfSection = false;\n\n // Handle cursor positioning when typing (not deleting)\n if (!didDelete) {\n // User types \"2\" in \"1|\" → becomes \"12|/\" → should jump to \"12/|\"\n const nextChar = formattedValue[cursorPosition]; // \"12/\"[2] → \"/\" (delimiter)\n const nextIsDelimiter = nextChar ? !isUserCharacter(nextChar) : false; // \"/\" → true\n\n const remainingText = formattedValue.substring(cursorPosition); // \"12/\".substring(2) → \"/\"\n const nextUserCharIndex = remainingText.search(/[\\dA-z]/); // \"/\".search() → -1 (no user chars)\n const hasMoreUserChars = nextUserCharIndex !== -1; // -1 !== -1 → false\n\n infoRef.current.endOfSection = nextIsDelimiter && !hasMoreUserChars; // true && false → false\n\n // Move cursor past auto-inserted delimiters for smooth typing\n if (nextIsDelimiter && hasMoreUserChars) {\n const prevChar = formattedValue[cursorPosition - 1] ?? '';\n const prevIsDelimiter = !isUserCharacter(prevChar);\n\n if (prevIsDelimiter) {\n infoRef.current.cursorPosition = cursorPosition + nextUserCharIndex + 1;\n } else {\n // If we're at a delimiter after typing (not deleting), and there are more chars,\n // we probably need to move past it unless it's a brand new delimiter\n const delimiterExistedBefore =\n currentValue[cursorPosition] === formattedValue[cursorPosition];\n if (delimiterExistedBefore) {\n infoRef.current.cursorPosition = cursorPosition + 1;\n }\n }\n }\n }\n\n onChange?.({ name, value: formattedValue, rawValue });\n setInternalValue(formattedValue);\n },\n [pattern, onChange, internalValue],\n );\n\n const handleKeyDown = useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.currentTarget && inputRef.current !== event.currentTarget) {\n inputRef.current = event.currentTarget;\n }\n }, []);\n\n return {\n formattedValue: internalValue,\n handleChange,\n handleKeyDown,\n maxLength,\n };\n};\n"],"names":["format","value","pattern","result","valueIndex","i","length","patternChar","stripPatternCharacters","replace","isUserCharacter","character","test","useFormattedInput","_ref","onChange","userValue","_ref$defaultValue","defaultValue","initialValue","useMemo","_useState","useState","_useState2","_slicedToArray","internalValue","setInternalValue","inputRef","useRef","infoRef","maxLength","useEffect","undefined","emptyFormatted","rawValue","newFormatted","_infoRef$current","current","cursorPosition","endOfSection","setSelectionRange","handleChange","useCallback","_ref2","_inputRef$current$sel","_inputRef$current","name","inputValue","cleanValue","currentValue","newInputValue","selectionStart","didDelete","_currentValue$cursorP","deletedChar","deletedDelimiter","beforeCursor","substring","afterCursor","rawBefore","rawAfter","slice","formattedValue","nextChar","nextIsDelimiter","remainingText","nextUserCharIndex","search","hasMoreUserChars","_formattedValue","prevChar","prevIsDelimiter","delimiterExistedBefore","handleKeyDown","event","currentTarget"],"mappings":";;;AAOA,IAAMA,MAAM,CAAG,SAATA,MAAMA,CAAIC,KAAa,CAAEC,OAAe,CAAa,CACzD,GAAI,CAACA,OAAO,CAAE,OAAOD,KAAK,CAE1B,IAAIE,MAAM,CAAG,EAAE,CACf,IAAIC,UAAU,CAAG,CAAC,CAElB,IAAK,IAAIC,CAAC,CAAG,CAAC,CAAEA,CAAC,CAAGH,OAAO,CAACI,MAAM,CAAED,CAAC,EAAE,CAAE,CACvC,IAAME,WAAW,CAAGL,OAAO,CAACG,CAAC,CAAC,CAE9B,GAAIE,WAAW,GAAK,GAAG,CAAE,CACvB,GAAIH,UAAU,CAAGH,KAAK,CAACK,MAAM,CAAE,CAC7BH,MAAM,EAAIF,KAAK,CAACG,UAAU,CAAC,CAC3BA,UAAU,EAAE,CACd,CAAC,KAAM,CACL,MACF,CACF,CAAC,KAAM,CACLD,MAAM,EAAII,WAAW,CACvB,CACF,CAE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