@razorpay/blade 12.96.1 → 12.96.2
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/SearchInput/SearchInput.js +2 -1
- package/build/lib/native/components/Input/SearchInput/SearchInput.js.map +1 -1
- package/build/lib/native/components/Modal/ModalContext.js +6 -0
- package/build/lib/native/components/Modal/ModalContext.js.map +1 -0
- package/build/lib/web/development/_virtual/cloneDeep.js +1 -1
- package/build/lib/web/development/_virtual/cloneDeep3.js +1 -1
- package/build/lib/web/development/components/Input/SearchInput/SearchInput.js +3 -1
- package/build/lib/web/development/components/Input/SearchInput/SearchInput.js.map +1 -1
- package/build/lib/web/development/components/Modal/Modal.web.js +2 -1
- package/build/lib/web/development/components/Modal/Modal.web.js.map +1 -1
- package/build/lib/web/development/components/Modal/ModalContext.js +2 -1
- package/build/lib/web/development/components/Modal/ModalContext.js.map +1 -1
- package/build/lib/web/development/node_modules/es-toolkit/dist/compat/object/cloneDeep.js +1 -1
- package/build/lib/web/development/node_modules/es-toolkit/dist/compat/predicate/matches.js +2 -2
- package/build/lib/web/development/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.js +2 -2
- package/build/lib/web/development/node_modules/es-toolkit/dist/object/cloneDeep.js +1 -1
- package/build/lib/web/production/_virtual/cloneDeep.js +1 -1
- package/build/lib/web/production/_virtual/cloneDeep3.js +1 -1
- package/build/lib/web/production/components/Input/SearchInput/SearchInput.js +3 -1
- package/build/lib/web/production/components/Input/SearchInput/SearchInput.js.map +1 -1
- package/build/lib/web/production/components/Modal/Modal.web.js +2 -1
- package/build/lib/web/production/components/Modal/Modal.web.js.map +1 -1
- package/build/lib/web/production/components/Modal/ModalContext.js +2 -1
- package/build/lib/web/production/components/Modal/ModalContext.js.map +1 -1
- package/build/lib/web/production/node_modules/es-toolkit/dist/compat/object/cloneDeep.js +1 -1
- package/build/lib/web/production/node_modules/es-toolkit/dist/compat/predicate/matches.js +2 -2
- package/build/lib/web/production/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.js +2 -2
- package/build/lib/web/production/node_modules/es-toolkit/dist/object/cloneDeep.js +1 -1
- package/package.json +1 -1
|
@@ -468,8 +468,9 @@ import { InputDropdownButton } from '../../Dropdown/InputDropdownButton.native.j
|
|
|
468
468
|
import { Divider } from '../../Divider/Divider.js';
|
|
469
469
|
import { getComponentId } from '../../../utils/isValidAllowedChildren/isValidAllowedChildren.js';
|
|
470
470
|
import { TopNavOverlayThemeOverride } from '../../TopNav/TopNavOverlayThemeOverride.js';
|
|
471
|
+
import { useModalContext } from '../../Modal/ModalContext.js';
|
|
471
472
|
|
|
472
|
-
var _excluded=["label","accessibilityLabel","labelPosition","placeholder","defaultValue","name","value","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","labelSuffix","labelTrailing","helpText","onClearButtonClick","isLoading","autoCapitalize","autoFocus","testID","size","showSearchIcon","trailing"];var isReactNative=function isReactNative(_textInputRef){return getPlatformType()==='react-native';};var _SearchInput=function _SearchInput(_ref,ref){var label=_ref.label,accessibilityLabel=_ref.accessibilityLabel,_ref$labelPosition=_ref.labelPosition,labelPosition=_ref$labelPosition===void 0?'top':_ref$labelPosition,placeholder=_ref.placeholder,defaultValue=_ref.defaultValue,name=_ref.name,value=_ref.value,_onChange=_ref.onChange,_onClick=_ref.onClick,_onFocus=_ref.onFocus,_onBlur=_ref.onBlur,onSubmit=_ref.onSubmit,isDisabled=_ref.isDisabled,labelSuffix=_ref.labelSuffix,labelTrailing=_ref.labelTrailing,helpText=_ref.helpText,onClearButtonClick=_ref.onClearButtonClick,isLoading=_ref.isLoading,autoCapitalize=_ref.autoCapitalize,autoFocus=_ref.autoFocus,testID=_ref.testID,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,_ref$showSearchIcon=_ref.showSearchIcon,showSearchIcon=_ref$showSearchIcon===void 0?true:_ref$showSearchIcon,trailing=_ref.trailing,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(false),_useState4=_slicedToArray(_useState3,2),isTrailingDropDownOpen=_useState4[0],setIsTrailingDropDownOpen=_useState4[1];var _useDropdown=useDropdown(),triggererWrapperRef=_useDropdown.triggererWrapperRef,onTriggerKeydown=_useDropdown.onTriggerKeydown,onTriggerClick=_useDropdown.onTriggerClick,dropdownTriggerer=_useDropdown.dropdownTriggerer,closeParentDropDown=_useDropdown.close,isParentDropDownOpen=_useDropdown.isOpen;var isInsideDropdown=dropdownTriggerer==='SearchInput';var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),isSearchFocused=_useState6[0],setIsSearchFocused=_useState6[1];React__default.useEffect(function(){setShouldShowClearButton(Boolean(defaultValue!=null?defaultValue:value));},[defaultValue,value]);useEffect(function(){if(isParentDropDownOpen&&isTrailingDropDownOpen){setIsTrailingDropDownOpen(false);}},[closeParentDropDown,isParentDropDownOpen]);useEffect(function(){if(isTrailingDropDownOpen&&isParentDropDownOpen){closeParentDropDown();}},[setIsTrailingDropDownOpen,isTrailingDropDownOpen]);var trailingDropdown=trailing&&getComponentId(trailing)==='Dropdown'?trailing:null;var renderTrailingDropDown=function renderTrailingDropDown(){if(!trailingDropdown){return null;}return React__default.cloneElement(trailingDropdown,{selectionType:'single',isOpen:isTrailingDropDownOpen,height:'100%',onOpenChange:function onOpenChange(isOpen){setIsTrailingDropDownOpen(isOpen);},children:React__default.Children.map(trailingDropdown.props.children,function(child){if(child.type===InputDropdownButton){return React__default.cloneElement(child,{_isInsideSearchInput:true,size:size});}if(child.type===DropdownOverlay){return React__default.cloneElement(child,{referenceRef:triggererWrapperRef,_isNestedDropdown:true,defaultPlacement:'bottom-end'});}return child;})});};var renderClearButton=function renderClearButton(){return jsx(IconButton,{size:"medium",icon:CloseIcon,onClick:function onClick(){var _textInputRef$current;if(isEmpty(value)&&textInputRef.current){if(isReactNative(textInputRef.current)){textInputRef.current.clear();textInputRef.current.focus();}else if(textInputRef.current instanceof HTMLInputElement){textInputRef.current.value='';textInputRef.current.focus();}}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 renderInteractionElement=function renderInteractionElement(){if(isLoading){return jsx(Spinner,{accessibilityLabel:"Loading Content",color:"primary"});}if(shouldShowClearButton&&trailingDropdown){return jsxs(BaseBox,{display:"flex",gap:"spacing.3",children:[renderClearButton()," ",jsx(Divider,{orientation:"vertical"})]});}if(shouldShowClearButton){return renderClearButton();}return null;};var searchContent=jsx(BaseBox,{position:"relative",children:jsx(BaseInput,Object.assign({id:"searchinput",componentName:MetaConstants.SearchInput,ref:mergedRef,isDropdownTrigger:true,setInputWrapperRef:isInsideDropdown||isTrailingDropDownOpen?function(wrapperNode){triggererWrapperRef.current=wrapperNode;}:undefined,label:label,accessibilityLabel:accessibilityLabel,hideLabelText:!Boolean(label),labelPosition:labelPosition,labelSuffix:labelSuffix,labelTrailing:labelTrailing,placeholder:placeholder,defaultValue:defaultValue,value:value,name:name,onKeyDown:isInsideDropdown?onTriggerKeydown:undefined,onChange:function onChange(_ref2){var name=_ref2.name,value=_ref2.value;if(value!=null&&value.length){setShouldShowClearButton(true);}if(shouldShowClearButton&&!(value!=null&&value.length)){setShouldShowClearButton(false);}_onChange==null?void 0:_onChange({name:name,value:value});},onClick:function onClick(e){if(isDisabled)return;if(isInsideDropdown){onTriggerClick();}_onClick==null?void 0:_onClick(e);},onFocus:function onFocus(e){setIsSearchFocused(true);_onFocus==null?void 0:_onFocus(e);},onBlur:function onBlur(e){setIsSearchFocused(false);_onBlur==null?void 0:_onBlur(e);},onSubmit:onSubmit,isDisabled:isDisabled,leadingIcon:showSearchIcon?SearchIcon:undefined,trailingInteractionElement:renderInteractionElement(),trailingDropDown:renderTrailingDropDown(),helpText:helpText,autoFocus:autoFocus,testID:testID},getKeyboardAndAutocompleteProps({type:'search',autoCapitalize:autoCapitalize}),{size:size},rest))});return jsx(TopNavOverlayThemeOverride,{shouldOverrideTheme:isSearchFocused,children:searchContent});};var SearchInput=assignWithoutSideEffects(React__default.forwardRef(_SearchInput),{displayName:'SearchInput',componentId:dropdownComponentIds.triggers.SearchInput});
|
|
473
|
+
var _excluded=["label","accessibilityLabel","labelPosition","placeholder","defaultValue","name","value","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","labelSuffix","labelTrailing","helpText","onClearButtonClick","isLoading","autoCapitalize","autoFocus","testID","size","showSearchIcon","trailing"];var isReactNative=function isReactNative(_textInputRef){return getPlatformType()==='react-native';};var _SearchInput=function _SearchInput(_ref,ref){var label=_ref.label,accessibilityLabel=_ref.accessibilityLabel,_ref$labelPosition=_ref.labelPosition,labelPosition=_ref$labelPosition===void 0?'top':_ref$labelPosition,placeholder=_ref.placeholder,defaultValue=_ref.defaultValue,name=_ref.name,value=_ref.value,_onChange=_ref.onChange,_onClick=_ref.onClick,_onFocus=_ref.onFocus,_onBlur=_ref.onBlur,onSubmit=_ref.onSubmit,isDisabled=_ref.isDisabled,labelSuffix=_ref.labelSuffix,labelTrailing=_ref.labelTrailing,helpText=_ref.helpText,onClearButtonClick=_ref.onClearButtonClick,isLoading=_ref.isLoading,autoCapitalize=_ref.autoCapitalize,autoFocus=_ref.autoFocus,testID=_ref.testID,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,_ref$showSearchIcon=_ref.showSearchIcon,showSearchIcon=_ref$showSearchIcon===void 0?true:_ref$showSearchIcon,trailing=_ref.trailing,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(false),_useState4=_slicedToArray(_useState3,2),isTrailingDropDownOpen=_useState4[0],setIsTrailingDropDownOpen=_useState4[1];var _useDropdown=useDropdown(),triggererWrapperRef=_useDropdown.triggererWrapperRef,onTriggerKeydown=_useDropdown.onTriggerKeydown,onTriggerClick=_useDropdown.onTriggerClick,dropdownTriggerer=_useDropdown.dropdownTriggerer,closeParentDropDown=_useDropdown.close,isParentDropDownOpen=_useDropdown.isOpen;var isInsideDropdown=dropdownTriggerer==='SearchInput';var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),isSearchFocused=_useState6[0],setIsSearchFocused=_useState6[1];var modalContext=useModalContext();React__default.useEffect(function(){setShouldShowClearButton(Boolean(defaultValue!=null?defaultValue:value));},[defaultValue,value]);useEffect(function(){if(isParentDropDownOpen&&isTrailingDropDownOpen){setIsTrailingDropDownOpen(false);}},[closeParentDropDown,isParentDropDownOpen]);useEffect(function(){if(isTrailingDropDownOpen&&isParentDropDownOpen){closeParentDropDown();}},[setIsTrailingDropDownOpen,isTrailingDropDownOpen]);var trailingDropdown=trailing&&getComponentId(trailing)==='Dropdown'?trailing:null;var renderTrailingDropDown=function renderTrailingDropDown(){if(!trailingDropdown){return null;}return React__default.cloneElement(trailingDropdown,{selectionType:'single',isOpen:isTrailingDropDownOpen,height:'100%',onOpenChange:function onOpenChange(isOpen){setIsTrailingDropDownOpen(isOpen);},children:React__default.Children.map(trailingDropdown.props.children,function(child){if(child.type===InputDropdownButton){return React__default.cloneElement(child,{_isInsideSearchInput:true,size:size});}if(child.type===DropdownOverlay){return React__default.cloneElement(child,{referenceRef:triggererWrapperRef,_isNestedDropdown:true,defaultPlacement:'bottom-end'});}return child;})});};var renderClearButton=function renderClearButton(){return jsx(IconButton,{size:"medium",icon:CloseIcon,onClick:function onClick(){var _textInputRef$current;if(isEmpty(value)&&textInputRef.current){if(isReactNative(textInputRef.current)){textInputRef.current.clear();textInputRef.current.focus();}else if(textInputRef.current instanceof HTMLInputElement){textInputRef.current.value='';textInputRef.current.focus();}}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 renderInteractionElement=function renderInteractionElement(){if(isLoading){return jsx(Spinner,{accessibilityLabel:"Loading Content",color:"primary"});}if(shouldShowClearButton&&trailingDropdown){return jsxs(BaseBox,{display:"flex",gap:"spacing.3",children:[renderClearButton()," ",jsx(Divider,{orientation:"vertical"})]});}if(shouldShowClearButton){return renderClearButton();}return null;};var searchContent=jsx(BaseBox,{position:"relative",children:jsx(BaseInput,Object.assign({id:"searchinput",componentName:MetaConstants.SearchInput,ref:mergedRef,isDropdownTrigger:true,setInputWrapperRef:isInsideDropdown||isTrailingDropDownOpen?function(wrapperNode){triggererWrapperRef.current=wrapperNode;}:undefined,label:label,accessibilityLabel:accessibilityLabel,hideLabelText:!Boolean(label),labelPosition:labelPosition,labelSuffix:labelSuffix,labelTrailing:labelTrailing,placeholder:placeholder,defaultValue:defaultValue,value:value,name:name,onKeyDown:isInsideDropdown?onTriggerKeydown:undefined,onChange:function onChange(_ref2){var name=_ref2.name,value=_ref2.value;if(value!=null&&value.length){setShouldShowClearButton(true);}if(shouldShowClearButton&&!(value!=null&&value.length)){setShouldShowClearButton(false);}_onChange==null?void 0:_onChange({name:name,value:value});},onClick:function onClick(e){if(isDisabled)return;if(isInsideDropdown){onTriggerClick();}_onClick==null?void 0:_onClick(e);},onFocus:function onFocus(e){setIsSearchFocused(true);_onFocus==null?void 0:_onFocus(e);},onBlur:function onBlur(e){setIsSearchFocused(false);_onBlur==null?void 0:_onBlur(e);},onSubmit:onSubmit,isDisabled:isDisabled,leadingIcon:showSearchIcon?SearchIcon:undefined,trailingInteractionElement:renderInteractionElement(),trailingDropDown:renderTrailingDropDown(),helpText:helpText,autoFocus:autoFocus,testID:testID},getKeyboardAndAutocompleteProps({type:'search',autoCapitalize:autoCapitalize}),{size:size},rest))});return jsx(TopNavOverlayThemeOverride,{shouldOverrideTheme:modalContext.isInsideModal?true:isSearchFocused,children:searchContent});};var SearchInput=assignWithoutSideEffects(React__default.forwardRef(_SearchInput),{displayName:'SearchInput',componentId:dropdownComponentIds.triggers.SearchInput});
|
|
473
474
|
|
|
474
475
|
export { SearchInput };
|
|
475
476
|
//# sourceMappingURL=SearchInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.js","sources":["../../../../../../src/components/Input/SearchInput/SearchInput.tsx"],"sourcesContent":["import React, { useEffect, useState } 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 isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { CloseIcon, SearchIcon } from '~components/Icons';\nimport { IconButton } from '~components/Button/IconButton';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { MetaConstants } from '~utils/metaAttribute';\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 DataAnalyticsAttribute,\n} from '~utils/types';\nimport { dropdownComponentIds } from '~components/Dropdown/dropdownComponentIds';\nimport { useDropdown } from '~components/Dropdown/useDropdown';\nimport { DropdownOverlay, InputDropdownButton } from '~components/Dropdown';\nimport { Divider } from '~components/Divider';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { TopNavOverlayThemeOverride } from '~components/TopNav/TopNavOverlayThemeOverride';\n\ntype SearchInputCommonProps = Pick<\n BaseInputProps,\n | 'label'\n | 'accessibilityLabel'\n | 'labelPosition'\n | 'labelSuffix'\n | 'labelTrailing'\n | 'helpText'\n | 'placeholder'\n | 'defaultValue'\n | 'name'\n | 'onChange'\n | 'onFocus'\n | 'onBlur'\n | 'value'\n | 'isDisabled'\n | 'autoFocus'\n | 'onSubmit'\n | 'autoCapitalize'\n | 'testID'\n | 'onClick'\n | 'size'\n | keyof DataAnalyticsAttribute\n> & {\n /**\n * Event handler to handle the onClick event for clear button.\n */\n onClearButtonClick?: () => void;\n\n /**\n * Decides whether to show a loading spinner for the input field.\n */\n isLoading?: boolean;\n /**\n * Toggle the visibility of the search icon.\n *\n * @default true\n */\n showSearchIcon?: boolean;\n /**\n * Optional trailing to be shown at the end of the input.\n */\n trailing?: React.ReactNode;\n} & StyledPropsBlade;\n\n/*\n Mandatory accessibilityLabel prop when label is not provided\n*/\ntype SearchInputPropsWithA11yLabel = {\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 SearchInputPropsWithLabel = {\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 SearchInputProps = (SearchInputPropsWithA11yLabel | SearchInputPropsWithLabel) &\n SearchInputCommonProps;\n\n// need to do this to tell TS to infer type as SearchInput 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 _SearchInput: React.ForwardRefRenderFunction<BladeElementRef, SearchInputProps> = (\n {\n label,\n accessibilityLabel,\n labelPosition = 'top',\n placeholder,\n defaultValue,\n name,\n value,\n onChange,\n onClick,\n onFocus,\n onBlur,\n onSubmit,\n isDisabled,\n labelSuffix,\n labelTrailing,\n helpText,\n onClearButtonClick,\n isLoading,\n autoCapitalize,\n autoFocus,\n testID,\n size = 'medium',\n showSearchIcon = true,\n trailing,\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 [isTrailingDropDownOpen, setIsTrailingDropDownOpen] = useState(false);\n const {\n triggererWrapperRef,\n onTriggerKeydown,\n onTriggerClick,\n dropdownTriggerer,\n close: closeParentDropDown,\n isOpen: isParentDropDownOpen,\n } = useDropdown();\n const isInsideDropdown = dropdownTriggerer === 'SearchInput';\n\n const [isSearchFocused, setIsSearchFocused] = useState(false);\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(defaultValue ?? value));\n }, [defaultValue, value]);\n\n useEffect(() => {\n if (isParentDropDownOpen && isTrailingDropDownOpen) {\n setIsTrailingDropDownOpen(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [closeParentDropDown, isParentDropDownOpen]);\n\n useEffect(() => {\n if (isTrailingDropDownOpen && isParentDropDownOpen) {\n closeParentDropDown();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [setIsTrailingDropDownOpen, isTrailingDropDownOpen]);\n\n const trailingDropdown =\n trailing && getComponentId(trailing as React.ReactElement) === 'Dropdown' ? trailing : null;\n\n const renderTrailingDropDown = (): React.ReactElement | null => {\n if (!trailingDropdown) {\n return null;\n }\n return React.cloneElement(trailingDropdown as React.ReactElement, {\n selectionType: 'single',\n isOpen: isTrailingDropDownOpen,\n height: '100%',\n onOpenChange: (isOpen: boolean) => {\n setIsTrailingDropDownOpen(isOpen);\n },\n children: React.Children.map(\n (trailingDropdown as React.ReactElement).props.children,\n (child) => {\n if (child.type === InputDropdownButton) {\n return React.cloneElement(child, {\n _isInsideSearchInput: true,\n size,\n });\n }\n if (child.type === DropdownOverlay) {\n return React.cloneElement(child, {\n referenceRef: triggererWrapperRef,\n _isNestedDropdown: true,\n defaultPlacement: 'bottom-end',\n });\n }\n return child;\n },\n ),\n });\n };\n\n const renderClearButton = (): React.ReactElement => {\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(value) && 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\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\n const renderInteractionElement = (): ReactNode => {\n if (isLoading) {\n return <Spinner accessibilityLabel=\"Loading Content\" color=\"primary\" />;\n }\n\n if (shouldShowClearButton && trailingDropdown) {\n return (\n <BaseBox display=\"flex\" gap=\"spacing.3\">\n {renderClearButton()} <Divider orientation=\"vertical\" />\n </BaseBox>\n );\n }\n if (shouldShowClearButton) {\n return renderClearButton();\n }\n\n return null;\n };\n\n const searchContent = (\n <BaseBox position=\"relative\">\n <BaseInput\n id=\"searchinput\"\n componentName={MetaConstants.SearchInput}\n ref={mergedRef}\n isDropdownTrigger={true}\n setInputWrapperRef={\n isInsideDropdown || isTrailingDropDownOpen\n ? (wrapperNode) => {\n triggererWrapperRef.current = wrapperNode;\n }\n : undefined\n }\n label={label as string}\n accessibilityLabel={accessibilityLabel}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n labelSuffix={labelSuffix}\n labelTrailing={labelTrailing}\n placeholder={placeholder}\n defaultValue={defaultValue}\n value={value}\n name={name}\n onKeyDown={isInsideDropdown ? onTriggerKeydown : undefined}\n onChange={({ name, value }) => {\n if (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 onChange?.({ name, value });\n }}\n onClick={(e) => {\n if (isDisabled) return;\n if (isInsideDropdown) {\n onTriggerClick();\n }\n onClick?.(e);\n }}\n onFocus={(e) => {\n setIsSearchFocused(true);\n onFocus?.(e);\n }}\n onBlur={(e) => {\n setIsSearchFocused(false);\n onBlur?.(e);\n }}\n onSubmit={onSubmit}\n isDisabled={isDisabled}\n leadingIcon={showSearchIcon ? SearchIcon : undefined}\n trailingInteractionElement={renderInteractionElement()}\n trailingDropDown={renderTrailingDropDown()}\n helpText={helpText}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n {...getKeyboardAndAutocompleteProps({\n type: 'search',\n autoCapitalize,\n })}\n size={size}\n {...rest}\n />\n </BaseBox>\n );\n\n return (\n <TopNavOverlayThemeOverride shouldOverrideTheme={isSearchFocused}>\n {searchContent}\n </TopNavOverlayThemeOverride>\n );\n};\n\nconst SearchInput = assignWithoutSideEffects(React.forwardRef(_SearchInput), {\n displayName: 'SearchInput',\n componentId: dropdownComponentIds.triggers.SearchInput,\n});\n\nexport type { SearchInputProps };\nexport { SearchInput };\n"],"names":["isReactNative","_textInputRef","getPlatformType","_SearchInput","_ref","ref","label","accessibilityLabel","_ref$labelPosition","labelPosition","placeholder","defaultValue","name","value","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","labelSuffix","labelTrailing","helpText","onClearButtonClick","isLoading","autoCapitalize","autoFocus","testID","_ref$size","size","_ref$showSearchIcon","showSearchIcon","trailing","rest","_objectWithoutProperties","_excluded","textInputRef","React","useRef","mergedRef","useMergeRefs","_useState","useState","_useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useState3","_useState4","isTrailingDropDownOpen","setIsTrailingDropDownOpen","_useDropdown","useDropdown","triggererWrapperRef","onTriggerKeydown","onTriggerClick","dropdownTriggerer","closeParentDropDown","close","isParentDropDownOpen","isOpen","isInsideDropdown","_useState5","_useState6","isSearchFocused","setIsSearchFocused","useEffect","Boolean","trailingDropdown","getComponentId","renderTrailingDropDown","cloneElement","selectionType","height","onOpenChange","children","Children","map","props","child","type","InputDropdownButton","_isInsideSearchInput","DropdownOverlay","referenceRef","_isNestedDropdown","defaultPlacement","renderClearButton","_jsx","IconButton","icon","CloseIcon","_textInputRef$current","isEmpty","current","clear","focus","HTMLInputElement","renderInteractionElement","Spinner","color","_jsxs","BaseBox","display","gap","Divider","orientation","searchContent","position","BaseInput","Object","assign","id","componentName","MetaConstants","SearchInput","isDropdownTrigger","setInputWrapperRef","wrapperNode","undefined","hideLabelText","onKeyDown","_ref2","length","e","leadingIcon","SearchIcon","trailingInteractionElement","trailingDropDown","getKeyboardAndAutocompleteProps","TopNavOverlayThemeOverride","shouldOverrideTheme","assignWithoutSideEffects","forwardRef","displayName","componentId","dropdownComponentIds","triggers"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,SAAA,CAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,eAAA,CAAA,aAAA,CAAA,cAAA,CAAA,MAAA,CAAA,OAAA,CAAA,UAAA,CAAA,SAAA,CAAA,SAAA,CAAA,QAAA,CAAA,UAAA,CAAA,YAAA,CAAA,aAAA,CAAA,eAAA,CA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CACF3G,MAAM,CAAE,SAARA,MAAMA,CAAG2G,CAAC,CAAK,CACb3D,kBAAkB,CAAC,KAAK,CAAC,CACzBhD,OAAM,EAAA,IAAA,CAAA,KAAA,CAAA,CAANA,OAAM,CAAG2G,CAAC,CAAC,CACb,CAAE,CACF1G,QAAQ,CAAEA,QAAS,CACnBC,UAAU,CAAEA,UAAW,CACvB0G,WAAW,CAAE9F,cAAc,CAAG+F,UAAU,CAAGP,SAAU,CACrDQ,0BAA0B,CAAE7B,wBAAwB,EAAG,CACvD8B,gBAAgB,CAAE1D,sBAAsB,EAAG,CAC3ChD,QAAQ,CAAEA,QAAS,CAEnBI,SAAS,CAAEA,SAAU,CACrBC,MAAM,CAAEA,MAAO,EACXsG,+BAA+B,CAAC,CAClCjD,IAAI,CAAE,QAAQ,CACdvD,cAAc,CAAdA,cACF,CAAC,CAAC,CACFI,CAAAA,IAAI,CAAEA,IAAK,CAAA,CACPI,IAAI,CACT,CAAC,CACK,CACV,CAED,OACEuD,GAAA,CAAC0C,0BAA0B,CAAA,CAACC,mBAAmB,CAAEnE,eAAgB,CAAAW,QAAA,CAC9DgC,aAAa,CACY,CAAC,CAEjC,CAAC,CAEK,IAAAQ,WAAW,CAAGiB,wBAAwB,CAAC/F,cAAK,CAACgG,UAAU,CAAClI,YAAY,CAAC,CAAE,CAC3EmI,WAAW,CAAE,aAAa,CAC1BC,WAAW,CAAEC,oBAAoB,CAACC,QAAQ,CAACtB,WAC7C,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"SearchInput.js","sources":["../../../../../../src/components/Input/SearchInput/SearchInput.tsx"],"sourcesContent":["import React, { useEffect, useState } 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 isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { CloseIcon, SearchIcon } from '~components/Icons';\nimport { IconButton } from '~components/Button/IconButton';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { MetaConstants } from '~utils/metaAttribute';\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 DataAnalyticsAttribute,\n} from '~utils/types';\nimport { dropdownComponentIds } from '~components/Dropdown/dropdownComponentIds';\nimport { useDropdown } from '~components/Dropdown/useDropdown';\nimport { DropdownOverlay, InputDropdownButton } from '~components/Dropdown';\nimport { Divider } from '~components/Divider';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { TopNavOverlayThemeOverride } from '~components/TopNav/TopNavOverlayThemeOverride';\nimport { useModalContext } from '~components/Modal/ModalContext';\n\ntype SearchInputCommonProps = Pick<\n BaseInputProps,\n | 'label'\n | 'accessibilityLabel'\n | 'labelPosition'\n | 'labelSuffix'\n | 'labelTrailing'\n | 'helpText'\n | 'placeholder'\n | 'defaultValue'\n | 'name'\n | 'onChange'\n | 'onFocus'\n | 'onBlur'\n | 'value'\n | 'isDisabled'\n | 'autoFocus'\n | 'onSubmit'\n | 'autoCapitalize'\n | 'testID'\n | 'onClick'\n | 'size'\n | keyof DataAnalyticsAttribute\n> & {\n /**\n * Event handler to handle the onClick event for clear button.\n */\n onClearButtonClick?: () => void;\n\n /**\n * Decides whether to show a loading spinner for the input field.\n */\n isLoading?: boolean;\n /**\n * Toggle the visibility of the search icon.\n *\n * @default true\n */\n showSearchIcon?: boolean;\n /**\n * Optional trailing to be shown at the end of the input.\n */\n trailing?: React.ReactNode;\n} & StyledPropsBlade;\n\n/*\n Mandatory accessibilityLabel prop when label is not provided\n*/\ntype SearchInputPropsWithA11yLabel = {\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 SearchInputPropsWithLabel = {\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 SearchInputProps = (SearchInputPropsWithA11yLabel | SearchInputPropsWithLabel) &\n SearchInputCommonProps;\n\n// need to do this to tell TS to infer type as SearchInput 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 _SearchInput: React.ForwardRefRenderFunction<BladeElementRef, SearchInputProps> = (\n {\n label,\n accessibilityLabel,\n labelPosition = 'top',\n placeholder,\n defaultValue,\n name,\n value,\n onChange,\n onClick,\n onFocus,\n onBlur,\n onSubmit,\n isDisabled,\n labelSuffix,\n labelTrailing,\n helpText,\n onClearButtonClick,\n isLoading,\n autoCapitalize,\n autoFocus,\n testID,\n size = 'medium',\n showSearchIcon = true,\n trailing,\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 [isTrailingDropDownOpen, setIsTrailingDropDownOpen] = useState(false);\n const {\n triggererWrapperRef,\n onTriggerKeydown,\n onTriggerClick,\n dropdownTriggerer,\n close: closeParentDropDown,\n isOpen: isParentDropDownOpen,\n } = useDropdown();\n const isInsideDropdown = dropdownTriggerer === 'SearchInput';\n\n const [isSearchFocused, setIsSearchFocused] = useState(false);\n\n const modalContext = useModalContext();\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(defaultValue ?? value));\n }, [defaultValue, value]);\n\n useEffect(() => {\n if (isParentDropDownOpen && isTrailingDropDownOpen) {\n setIsTrailingDropDownOpen(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [closeParentDropDown, isParentDropDownOpen]);\n\n useEffect(() => {\n if (isTrailingDropDownOpen && isParentDropDownOpen) {\n closeParentDropDown();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [setIsTrailingDropDownOpen, isTrailingDropDownOpen]);\n\n const trailingDropdown =\n trailing && getComponentId(trailing as React.ReactElement) === 'Dropdown' ? trailing : null;\n\n const renderTrailingDropDown = (): React.ReactElement | null => {\n if (!trailingDropdown) {\n return null;\n }\n return React.cloneElement(trailingDropdown as React.ReactElement, {\n selectionType: 'single',\n isOpen: isTrailingDropDownOpen,\n height: '100%',\n onOpenChange: (isOpen: boolean) => {\n setIsTrailingDropDownOpen(isOpen);\n },\n children: React.Children.map(\n (trailingDropdown as React.ReactElement).props.children,\n (child) => {\n if (child.type === InputDropdownButton) {\n return React.cloneElement(child, {\n _isInsideSearchInput: true,\n size,\n });\n }\n if (child.type === DropdownOverlay) {\n return React.cloneElement(child, {\n referenceRef: triggererWrapperRef,\n _isNestedDropdown: true,\n defaultPlacement: 'bottom-end',\n });\n }\n return child;\n },\n ),\n });\n };\n\n const renderClearButton = (): React.ReactElement => {\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(value) && 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\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\n const renderInteractionElement = (): ReactNode => {\n if (isLoading) {\n return <Spinner accessibilityLabel=\"Loading Content\" color=\"primary\" />;\n }\n\n if (shouldShowClearButton && trailingDropdown) {\n return (\n <BaseBox display=\"flex\" gap=\"spacing.3\">\n {renderClearButton()} <Divider orientation=\"vertical\" />\n </BaseBox>\n );\n }\n if (shouldShowClearButton) {\n return renderClearButton();\n }\n\n return null;\n };\n\n const searchContent = (\n <BaseBox position=\"relative\">\n <BaseInput\n id=\"searchinput\"\n componentName={MetaConstants.SearchInput}\n ref={mergedRef}\n isDropdownTrigger={true}\n setInputWrapperRef={\n isInsideDropdown || isTrailingDropDownOpen\n ? (wrapperNode) => {\n triggererWrapperRef.current = wrapperNode;\n }\n : undefined\n }\n label={label as string}\n accessibilityLabel={accessibilityLabel}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n labelSuffix={labelSuffix}\n labelTrailing={labelTrailing}\n placeholder={placeholder}\n defaultValue={defaultValue}\n value={value}\n name={name}\n onKeyDown={isInsideDropdown ? onTriggerKeydown : undefined}\n onChange={({ name, value }) => {\n if (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 onChange?.({ name, value });\n }}\n onClick={(e) => {\n if (isDisabled) return;\n if (isInsideDropdown) {\n onTriggerClick();\n }\n onClick?.(e);\n }}\n onFocus={(e) => {\n setIsSearchFocused(true);\n onFocus?.(e);\n }}\n onBlur={(e) => {\n setIsSearchFocused(false);\n onBlur?.(e);\n }}\n onSubmit={onSubmit}\n isDisabled={isDisabled}\n leadingIcon={showSearchIcon ? SearchIcon : undefined}\n trailingInteractionElement={renderInteractionElement()}\n trailingDropDown={renderTrailingDropDown()}\n helpText={helpText}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n {...getKeyboardAndAutocompleteProps({\n type: 'search',\n autoCapitalize,\n })}\n size={size}\n {...rest}\n />\n </BaseBox>\n );\n\n return (\n <TopNavOverlayThemeOverride\n shouldOverrideTheme={modalContext.isInsideModal ? true : isSearchFocused}\n >\n {searchContent}\n </TopNavOverlayThemeOverride>\n );\n};\n\nconst SearchInput = assignWithoutSideEffects(React.forwardRef(_SearchInput), {\n displayName: 'SearchInput',\n componentId: dropdownComponentIds.triggers.SearchInput,\n});\n\nexport type { SearchInputProps };\nexport { SearchInput };\n"],"names":["isReactNative","_textInputRef","getPlatformType","_SearchInput","_ref","ref","label","accessibilityLabel","_ref$labelPosition","labelPosition","placeholder","defaultValue","name","value","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","labelSuffix","labelTrailing","helpText","onClearButtonClick","isLoading","autoCapitalize","autoFocus","testID","_ref$size","size","_ref$showSearchIcon","showSearchIcon","trailing","rest","_objectWithoutProperties","_excluded","textInputRef","React","useRef","mergedRef","useMergeRefs","_useState","useState","_useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useState3","_useState4","isTrailingDropDownOpen","setIsTrailingDropDownOpen","_useDropdown","useDropdown","triggererWrapperRef","onTriggerKeydown","onTriggerClick","dropdownTriggerer","closeParentDropDown","close","isParentDropDownOpen","isOpen","isInsideDropdown","_useState5","_useState6","isSearchFocused","setIsSearchFocused","modalContext","useModalContext","useEffect","Boolean","trailingDropdown","getComponentId","renderTrailingDropDown","cloneElement","selectionType","height","onOpenChange","children","Children","map","props","child","type","InputDropdownButton","_isInsideSearchInput","DropdownOverlay","referenceRef","_isNestedDropdown","defaultPlacement","renderClearButton","_jsx","IconButton","icon","CloseIcon","_textInputRef$current","isEmpty","current","clear","focus","HTMLInputElement","renderInteractionElement","Spinner","color","_jsxs","BaseBox","display","gap","Divider","orientation","searchContent","position","BaseInput","Object","assign","id","componentName","MetaConstants","SearchInput","isDropdownTrigger","setInputWrapperRef","wrapperNode","undefined","hideLabelText","onKeyDown","_ref2","length","e","leadingIcon","SearchIcon","trailingInteractionElement","trailingDropDown","getKeyboardAndAutocompleteProps","TopNavOverlayThemeOverride","shouldOverrideTheme","isInsideModal","assignWithoutSideEffects","forwardRef","displayName","componentId","dropdownComponentIds","triggers"],"mappings":";;;;;;;;;;;;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CjD,IAAI,CAAE,QAAQ,CACdzD,cAAc,CAAdA,cACF,CAAC,CAAC,CAAA,CACFI,IAAI,CAAEA,IAAK,CACPI,CAAAA,IAAI,CACT,CAAC,CACK,CACV,CAED,OACEyD,GAAA,CAAC0C,0BAA0B,CACzBC,CAAAA,mBAAmB,CAAEnE,YAAY,CAACoE,aAAa,CAAG,IAAI,CAAGtE,eAAgB,CAAAa,QAAA,CAExEgC,aAAa,CACY,CAAC,CAEjC,CAAC,CAEK,IAAAQ,WAAW,CAAGkB,wBAAwB,CAAClG,cAAK,CAACmG,UAAU,CAACrI,YAAY,CAAC,CAAE,CAC3EsI,WAAW,CAAE,aAAa,CAC1BC,WAAW,CAAEC,oBAAoB,CAACC,QAAQ,CAACvB,WAC7C,CAAC;;;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
var ModalContext=React__default.createContext({close:function close(){},isDismissible:true,defaultInitialFocusRef:{current:null},isOpen:false,isVisible:false,isInsideModal:false});var useModalContext=function useModalContext(){var state=React__default.useContext(ModalContext);return state;};
|
|
4
|
+
|
|
5
|
+
export { ModalContext, useModalContext };
|
|
6
|
+
//# sourceMappingURL=ModalContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContext.js","sources":["../../../../../src/components/Modal/ModalContext.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react';\n\ntype ModalContextProps = {\n /**\n * Indicates open state of Modal\n */\n isOpen: boolean;\n /**\n * Function to close the Modal\n */\n close?: () => void;\n /**\n * Whether the modal can be dismissed\n */\n isDismissible: boolean;\n /**\n * The element that will get focused when the Modal first opens\n */\n defaultInitialFocusRef: React.MutableRefObject<any>;\n /**\n * Indicates if the Modal is visible according to the usePresence hook\n */\n isVisible: boolean;\n /**\n * Indicates if the Modal is inside a Modal\n */\n isInsideModal: boolean;\n};\n\nconst ModalContext = React.createContext<ModalContextProps>({\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n close: () => {},\n isDismissible: true,\n defaultInitialFocusRef: { current: null },\n isOpen: false,\n isVisible: false,\n isInsideModal: false,\n});\n\nconst useModalContext = (): ModalContextProps => {\n const state = React.useContext(ModalContext);\n return state;\n};\n\nexport { ModalContext, useModalContext };\n"],"names":["ModalContext","React","createContext","close","isDismissible","defaultInitialFocusRef","current","isOpen","isVisible","isInsideModal","useModalContext","state","useContext"],"mappings":";;AA8BM,IAAAA,YAAY,CAAGC,cAAK,CAACC,aAAa,CAAoB,CAE1DC,KAAK,CAAE,SAAPA,KAAKA,EAAQ,EAAE,CACfC,aAAa,CAAE,IAAI,CACnBC,sBAAsB,CAAE,CAAEC,OAAO,CAAE,IAAK,CAAC,CACzCC,MAAM,CAAE,KAAK,CACbC,SAAS,CAAE,KAAK,CAChBC,aAAa,CAAE,KACjB,CAAC,EAEK,IAAAC,eAAe,CAAG,SAAlBA,eAAeA,EAA4B,CAC/C,IAAMC,KAAK,CAAGV,cAAK,CAACW,UAAU,CAACZ,YAAY,CAAC,CAC5C,OAAOW,KAAK,CACd;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import '../node_modules/es-toolkit/dist/
|
|
1
|
+
import '../node_modules/es-toolkit/dist/object/cloneDeep.js';
|
|
2
2
|
//# sourceMappingURL=cloneDeep.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import '../node_modules/es-toolkit/dist/object/cloneDeep.js';
|
|
1
|
+
import '../node_modules/es-toolkit/dist/compat/object/cloneDeep.js';
|
|
2
2
|
//# sourceMappingURL=cloneDeep3.js.map
|
|
@@ -19,6 +19,7 @@ import '../../Dropdown/index.js';
|
|
|
19
19
|
import '../../Divider/index.js';
|
|
20
20
|
import '../../../utils/isValidAllowedChildren/index.js';
|
|
21
21
|
import { TopNavOverlayThemeOverride } from '../../TopNav/TopNavOverlayThemeOverride.js';
|
|
22
|
+
import { useModalContext } from '../../Modal/ModalContext.js';
|
|
22
23
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
23
24
|
import { getPlatformType } from '../../../utils/getPlatformType/getPlatformType.js';
|
|
24
25
|
import { getComponentId } from '../../../utils/isValidAllowedChildren/isValidAllowedChildren.js';
|
|
@@ -93,6 +94,7 @@ var _SearchInput = function _SearchInput(_ref, ref) {
|
|
|
93
94
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
94
95
|
isSearchFocused = _useState6[0],
|
|
95
96
|
setIsSearchFocused = _useState6[1];
|
|
97
|
+
var modalContext = useModalContext();
|
|
96
98
|
React__default.useEffect(function () {
|
|
97
99
|
setShouldShowClearButton(Boolean(defaultValue !== null && defaultValue !== void 0 ? defaultValue : value));
|
|
98
100
|
}, [defaultValue, value]);
|
|
@@ -255,7 +257,7 @@ var _SearchInput = function _SearchInput(_ref, ref) {
|
|
|
255
257
|
}, rest))
|
|
256
258
|
});
|
|
257
259
|
return /*#__PURE__*/jsx(TopNavOverlayThemeOverride, {
|
|
258
|
-
shouldOverrideTheme: isSearchFocused,
|
|
260
|
+
shouldOverrideTheme: modalContext.isInsideModal ? true : isSearchFocused,
|
|
259
261
|
children: searchContent
|
|
260
262
|
});
|
|
261
263
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.js","sources":["../../../../../../../src/components/Input/SearchInput/SearchInput.tsx"],"sourcesContent":["import React, { useEffect, useState } 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 isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { CloseIcon, SearchIcon } from '~components/Icons';\nimport { IconButton } from '~components/Button/IconButton';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { MetaConstants } from '~utils/metaAttribute';\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 DataAnalyticsAttribute,\n} from '~utils/types';\nimport { dropdownComponentIds } from '~components/Dropdown/dropdownComponentIds';\nimport { useDropdown } from '~components/Dropdown/useDropdown';\nimport { DropdownOverlay, InputDropdownButton } from '~components/Dropdown';\nimport { Divider } from '~components/Divider';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { TopNavOverlayThemeOverride } from '~components/TopNav/TopNavOverlayThemeOverride';\n\ntype SearchInputCommonProps = Pick<\n BaseInputProps,\n | 'label'\n | 'accessibilityLabel'\n | 'labelPosition'\n | 'labelSuffix'\n | 'labelTrailing'\n | 'helpText'\n | 'placeholder'\n | 'defaultValue'\n | 'name'\n | 'onChange'\n | 'onFocus'\n | 'onBlur'\n | 'value'\n | 'isDisabled'\n | 'autoFocus'\n | 'onSubmit'\n | 'autoCapitalize'\n | 'testID'\n | 'onClick'\n | 'size'\n | keyof DataAnalyticsAttribute\n> & {\n /**\n * Event handler to handle the onClick event for clear button.\n */\n onClearButtonClick?: () => void;\n\n /**\n * Decides whether to show a loading spinner for the input field.\n */\n isLoading?: boolean;\n /**\n * Toggle the visibility of the search icon.\n *\n * @default true\n */\n showSearchIcon?: boolean;\n /**\n * Optional trailing to be shown at the end of the input.\n */\n trailing?: React.ReactNode;\n} & StyledPropsBlade;\n\n/*\n Mandatory accessibilityLabel prop when label is not provided\n*/\ntype SearchInputPropsWithA11yLabel = {\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 SearchInputPropsWithLabel = {\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 SearchInputProps = (SearchInputPropsWithA11yLabel | SearchInputPropsWithLabel) &\n SearchInputCommonProps;\n\n// need to do this to tell TS to infer type as SearchInput 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 _SearchInput: React.ForwardRefRenderFunction<BladeElementRef, SearchInputProps> = (\n {\n label,\n accessibilityLabel,\n labelPosition = 'top',\n placeholder,\n defaultValue,\n name,\n value,\n onChange,\n onClick,\n onFocus,\n onBlur,\n onSubmit,\n isDisabled,\n labelSuffix,\n labelTrailing,\n helpText,\n onClearButtonClick,\n isLoading,\n autoCapitalize,\n autoFocus,\n testID,\n size = 'medium',\n showSearchIcon = true,\n trailing,\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 [isTrailingDropDownOpen, setIsTrailingDropDownOpen] = useState(false);\n const {\n triggererWrapperRef,\n onTriggerKeydown,\n onTriggerClick,\n dropdownTriggerer,\n close: closeParentDropDown,\n isOpen: isParentDropDownOpen,\n } = useDropdown();\n const isInsideDropdown = dropdownTriggerer === 'SearchInput';\n\n const [isSearchFocused, setIsSearchFocused] = useState(false);\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(defaultValue ?? value));\n }, [defaultValue, value]);\n\n useEffect(() => {\n if (isParentDropDownOpen && isTrailingDropDownOpen) {\n setIsTrailingDropDownOpen(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [closeParentDropDown, isParentDropDownOpen]);\n\n useEffect(() => {\n if (isTrailingDropDownOpen && isParentDropDownOpen) {\n closeParentDropDown();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [setIsTrailingDropDownOpen, isTrailingDropDownOpen]);\n\n const trailingDropdown =\n trailing && getComponentId(trailing as React.ReactElement) === 'Dropdown' ? trailing : null;\n\n const renderTrailingDropDown = (): React.ReactElement | null => {\n if (!trailingDropdown) {\n return null;\n }\n return React.cloneElement(trailingDropdown as React.ReactElement, {\n selectionType: 'single',\n isOpen: isTrailingDropDownOpen,\n height: '100%',\n onOpenChange: (isOpen: boolean) => {\n setIsTrailingDropDownOpen(isOpen);\n },\n children: React.Children.map(\n (trailingDropdown as React.ReactElement).props.children,\n (child) => {\n if (child.type === InputDropdownButton) {\n return React.cloneElement(child, {\n _isInsideSearchInput: true,\n size,\n });\n }\n if (child.type === DropdownOverlay) {\n return React.cloneElement(child, {\n referenceRef: triggererWrapperRef,\n _isNestedDropdown: true,\n defaultPlacement: 'bottom-end',\n });\n }\n return child;\n },\n ),\n });\n };\n\n const renderClearButton = (): React.ReactElement => {\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(value) && 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\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\n const renderInteractionElement = (): ReactNode => {\n if (isLoading) {\n return <Spinner accessibilityLabel=\"Loading Content\" color=\"primary\" />;\n }\n\n if (shouldShowClearButton && trailingDropdown) {\n return (\n <BaseBox display=\"flex\" gap=\"spacing.3\">\n {renderClearButton()} <Divider orientation=\"vertical\" />\n </BaseBox>\n );\n }\n if (shouldShowClearButton) {\n return renderClearButton();\n }\n\n return null;\n };\n\n const searchContent = (\n <BaseBox position=\"relative\">\n <BaseInput\n id=\"searchinput\"\n componentName={MetaConstants.SearchInput}\n ref={mergedRef}\n isDropdownTrigger={true}\n setInputWrapperRef={\n isInsideDropdown || isTrailingDropDownOpen\n ? (wrapperNode) => {\n triggererWrapperRef.current = wrapperNode;\n }\n : undefined\n }\n label={label as string}\n accessibilityLabel={accessibilityLabel}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n labelSuffix={labelSuffix}\n labelTrailing={labelTrailing}\n placeholder={placeholder}\n defaultValue={defaultValue}\n value={value}\n name={name}\n onKeyDown={isInsideDropdown ? onTriggerKeydown : undefined}\n onChange={({ name, value }) => {\n if (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 onChange?.({ name, value });\n }}\n onClick={(e) => {\n if (isDisabled) return;\n if (isInsideDropdown) {\n onTriggerClick();\n }\n onClick?.(e);\n }}\n onFocus={(e) => {\n setIsSearchFocused(true);\n onFocus?.(e);\n }}\n onBlur={(e) => {\n setIsSearchFocused(false);\n onBlur?.(e);\n }}\n onSubmit={onSubmit}\n isDisabled={isDisabled}\n leadingIcon={showSearchIcon ? SearchIcon : undefined}\n trailingInteractionElement={renderInteractionElement()}\n trailingDropDown={renderTrailingDropDown()}\n helpText={helpText}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n {...getKeyboardAndAutocompleteProps({\n type: 'search',\n autoCapitalize,\n })}\n size={size}\n {...rest}\n />\n </BaseBox>\n );\n\n return (\n <TopNavOverlayThemeOverride shouldOverrideTheme={isSearchFocused}>\n {searchContent}\n </TopNavOverlayThemeOverride>\n );\n};\n\nconst SearchInput = assignWithoutSideEffects(React.forwardRef(_SearchInput), {\n displayName: 'SearchInput',\n componentId: dropdownComponentIds.triggers.SearchInput,\n});\n\nexport type { SearchInputProps };\nexport { SearchInput };\n"],"names":["isReactNative","_textInputRef","getPlatformType","_SearchInput","_ref","ref","label","accessibilityLabel","_ref$labelPosition","labelPosition","placeholder","defaultValue","name","value","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","labelSuffix","labelTrailing","helpText","onClearButtonClick","isLoading","autoCapitalize","autoFocus","testID","_ref$size","size","_ref$showSearchIcon","showSearchIcon","trailing","rest","_objectWithoutProperties","_excluded","textInputRef","React","useRef","mergedRef","useMergeRefs","_useState","useState","_useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useState3","_useState4","isTrailingDropDownOpen","setIsTrailingDropDownOpen","_useDropdown","useDropdown","triggererWrapperRef","onTriggerKeydown","onTriggerClick","dropdownTriggerer","closeParentDropDown","close","isParentDropDownOpen","isOpen","isInsideDropdown","_useState5","_useState6","isSearchFocused","setIsSearchFocused","useEffect","Boolean","trailingDropdown","getComponentId","renderTrailingDropDown","cloneElement","selectionType","height","onOpenChange","children","Children","map","props","child","type","InputDropdownButton","_isInsideSearchInput","DropdownOverlay","referenceRef","_isNestedDropdown","defaultPlacement","renderClearButton","_jsx","IconButton","icon","CloseIcon","_textInputRef$current","isEmpty","current","clear","focus","HTMLInputElement","renderInteractionElement","Spinner","color","_jsxs","BaseBox","display","gap","Divider","orientation","searchContent","position","BaseInput","_objectSpread","id","componentName","MetaConstants","SearchInput","isDropdownTrigger","setInputWrapperRef","wrapperNode","undefined","hideLabelText","onKeyDown","_ref2","length","e","leadingIcon","SearchIcon","trailingInteractionElement","trailingDropDown","getKeyboardAndAutocompleteProps","TopNavOverlayThemeOverride","shouldOverrideTheme","assignWithoutSideEffects","forwardRef","displayName","componentId","dropdownComponentIds","triggers"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGA;AACA;AACA,IAAMA,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,aAAmB,EAA4C;AACpF,EAAA,OAAOC,eAAe,EAAE,KAAK,cAAc,CAAA;AAC7C,CAAC,CAAA;AAED,IAAMC,YAA+E,GAAG,SAAlFA,YAA+EA,CAAAC,IAAA,EA4BnF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AACvByG,MAAAA,WAAW,EAAE7F,cAAc,GAAG8F,UAAU,GAAGP,SAAU;MACrDQ,0BAA0B,EAAE5B,wBAAwB,EAAG;MACvD6B,gBAAgB,EAAEzD,sBAAsB,EAAG;AAC3ChD,MAAAA,QAAQ,EAAEA,QAAAA;AACV;AAAA;AACAI,MAAAA,SAAS,EAAEA,SAAU;AACrBC,MAAAA,MAAM,EAAEA,MAAAA;AAAO,KAAA,EACXqG,+BAA+B,CAAC;AAClChD,MAAAA,IAAI,EAAE,QAAQ;AACdvD,MAAAA,cAAc,EAAdA,cAAAA;AACF,KAAC,CAAC,CAAA,EAAA,EAAA,EAAA;AACFI,MAAAA,IAAI,EAAEA,IAAAA;AAAK,KAAA,EACPI,IAAI,CACT,CAAA;AAAC,GACK,CACV,CAAA;EAED,oBACEuD,GAAA,CAACyC,0BAA0B,EAAA;AAACC,IAAAA,mBAAmB,EAAElE,eAAgB;AAAAW,IAAAA,QAAA,EAC9DgC,aAAAA;AAAa,GACY,CAAC,CAAA;AAEjC,CAAC,CAAA;AAEKO,IAAAA,WAAW,gBAAGiB,wBAAwB,cAAC9F,cAAK,CAAC+F,UAAU,CAACjI,YAAY,CAAC,EAAE;AAC3EkI,EAAAA,WAAW,EAAE,aAAa;AAC1BC,EAAAA,WAAW,EAAEC,oBAAoB,CAACC,QAAQ,CAACtB,WAAAA;AAC7C,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"SearchInput.js","sources":["../../../../../../../src/components/Input/SearchInput/SearchInput.tsx"],"sourcesContent":["import React, { useEffect, useState } 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 isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { CloseIcon, SearchIcon } from '~components/Icons';\nimport { IconButton } from '~components/Button/IconButton';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { MetaConstants } from '~utils/metaAttribute';\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 DataAnalyticsAttribute,\n} from '~utils/types';\nimport { dropdownComponentIds } from '~components/Dropdown/dropdownComponentIds';\nimport { useDropdown } from '~components/Dropdown/useDropdown';\nimport { DropdownOverlay, InputDropdownButton } from '~components/Dropdown';\nimport { Divider } from '~components/Divider';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { TopNavOverlayThemeOverride } from '~components/TopNav/TopNavOverlayThemeOverride';\nimport { useModalContext } from '~components/Modal/ModalContext';\n\ntype SearchInputCommonProps = Pick<\n BaseInputProps,\n | 'label'\n | 'accessibilityLabel'\n | 'labelPosition'\n | 'labelSuffix'\n | 'labelTrailing'\n | 'helpText'\n | 'placeholder'\n | 'defaultValue'\n | 'name'\n | 'onChange'\n | 'onFocus'\n | 'onBlur'\n | 'value'\n | 'isDisabled'\n | 'autoFocus'\n | 'onSubmit'\n | 'autoCapitalize'\n | 'testID'\n | 'onClick'\n | 'size'\n | keyof DataAnalyticsAttribute\n> & {\n /**\n * Event handler to handle the onClick event for clear button.\n */\n onClearButtonClick?: () => void;\n\n /**\n * Decides whether to show a loading spinner for the input field.\n */\n isLoading?: boolean;\n /**\n * Toggle the visibility of the search icon.\n *\n * @default true\n */\n showSearchIcon?: boolean;\n /**\n * Optional trailing to be shown at the end of the input.\n */\n trailing?: React.ReactNode;\n} & StyledPropsBlade;\n\n/*\n Mandatory accessibilityLabel prop when label is not provided\n*/\ntype SearchInputPropsWithA11yLabel = {\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 SearchInputPropsWithLabel = {\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 SearchInputProps = (SearchInputPropsWithA11yLabel | SearchInputPropsWithLabel) &\n SearchInputCommonProps;\n\n// need to do this to tell TS to infer type as SearchInput 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 _SearchInput: React.ForwardRefRenderFunction<BladeElementRef, SearchInputProps> = (\n {\n label,\n accessibilityLabel,\n labelPosition = 'top',\n placeholder,\n defaultValue,\n name,\n value,\n onChange,\n onClick,\n onFocus,\n onBlur,\n onSubmit,\n isDisabled,\n labelSuffix,\n labelTrailing,\n helpText,\n onClearButtonClick,\n isLoading,\n autoCapitalize,\n autoFocus,\n testID,\n size = 'medium',\n showSearchIcon = true,\n trailing,\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 [isTrailingDropDownOpen, setIsTrailingDropDownOpen] = useState(false);\n const {\n triggererWrapperRef,\n onTriggerKeydown,\n onTriggerClick,\n dropdownTriggerer,\n close: closeParentDropDown,\n isOpen: isParentDropDownOpen,\n } = useDropdown();\n const isInsideDropdown = dropdownTriggerer === 'SearchInput';\n\n const [isSearchFocused, setIsSearchFocused] = useState(false);\n\n const modalContext = useModalContext();\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(defaultValue ?? value));\n }, [defaultValue, value]);\n\n useEffect(() => {\n if (isParentDropDownOpen && isTrailingDropDownOpen) {\n setIsTrailingDropDownOpen(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [closeParentDropDown, isParentDropDownOpen]);\n\n useEffect(() => {\n if (isTrailingDropDownOpen && isParentDropDownOpen) {\n closeParentDropDown();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [setIsTrailingDropDownOpen, isTrailingDropDownOpen]);\n\n const trailingDropdown =\n trailing && getComponentId(trailing as React.ReactElement) === 'Dropdown' ? trailing : null;\n\n const renderTrailingDropDown = (): React.ReactElement | null => {\n if (!trailingDropdown) {\n return null;\n }\n return React.cloneElement(trailingDropdown as React.ReactElement, {\n selectionType: 'single',\n isOpen: isTrailingDropDownOpen,\n height: '100%',\n onOpenChange: (isOpen: boolean) => {\n setIsTrailingDropDownOpen(isOpen);\n },\n children: React.Children.map(\n (trailingDropdown as React.ReactElement).props.children,\n (child) => {\n if (child.type === InputDropdownButton) {\n return React.cloneElement(child, {\n _isInsideSearchInput: true,\n size,\n });\n }\n if (child.type === DropdownOverlay) {\n return React.cloneElement(child, {\n referenceRef: triggererWrapperRef,\n _isNestedDropdown: true,\n defaultPlacement: 'bottom-end',\n });\n }\n return child;\n },\n ),\n });\n };\n\n const renderClearButton = (): React.ReactElement => {\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(value) && 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\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\n const renderInteractionElement = (): ReactNode => {\n if (isLoading) {\n return <Spinner accessibilityLabel=\"Loading Content\" color=\"primary\" />;\n }\n\n if (shouldShowClearButton && trailingDropdown) {\n return (\n <BaseBox display=\"flex\" gap=\"spacing.3\">\n {renderClearButton()} <Divider orientation=\"vertical\" />\n </BaseBox>\n );\n }\n if (shouldShowClearButton) {\n return renderClearButton();\n }\n\n return null;\n };\n\n const searchContent = (\n <BaseBox position=\"relative\">\n <BaseInput\n id=\"searchinput\"\n componentName={MetaConstants.SearchInput}\n ref={mergedRef}\n isDropdownTrigger={true}\n setInputWrapperRef={\n isInsideDropdown || isTrailingDropDownOpen\n ? (wrapperNode) => {\n triggererWrapperRef.current = wrapperNode;\n }\n : undefined\n }\n label={label as string}\n accessibilityLabel={accessibilityLabel}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n labelSuffix={labelSuffix}\n labelTrailing={labelTrailing}\n placeholder={placeholder}\n defaultValue={defaultValue}\n value={value}\n name={name}\n onKeyDown={isInsideDropdown ? onTriggerKeydown : undefined}\n onChange={({ name, value }) => {\n if (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 onChange?.({ name, value });\n }}\n onClick={(e) => {\n if (isDisabled) return;\n if (isInsideDropdown) {\n onTriggerClick();\n }\n onClick?.(e);\n }}\n onFocus={(e) => {\n setIsSearchFocused(true);\n onFocus?.(e);\n }}\n onBlur={(e) => {\n setIsSearchFocused(false);\n onBlur?.(e);\n }}\n onSubmit={onSubmit}\n isDisabled={isDisabled}\n leadingIcon={showSearchIcon ? SearchIcon : undefined}\n trailingInteractionElement={renderInteractionElement()}\n trailingDropDown={renderTrailingDropDown()}\n helpText={helpText}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n {...getKeyboardAndAutocompleteProps({\n type: 'search',\n autoCapitalize,\n })}\n size={size}\n {...rest}\n />\n </BaseBox>\n );\n\n return (\n <TopNavOverlayThemeOverride\n shouldOverrideTheme={modalContext.isInsideModal ? true : isSearchFocused}\n >\n {searchContent}\n </TopNavOverlayThemeOverride>\n );\n};\n\nconst SearchInput = assignWithoutSideEffects(React.forwardRef(_SearchInput), {\n displayName: 'SearchInput',\n componentId: dropdownComponentIds.triggers.SearchInput,\n});\n\nexport type { SearchInputProps };\nexport { SearchInput };\n"],"names":["isReactNative","_textInputRef","getPlatformType","_SearchInput","_ref","ref","label","accessibilityLabel","_ref$labelPosition","labelPosition","placeholder","defaultValue","name","value","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","labelSuffix","labelTrailing","helpText","onClearButtonClick","isLoading","autoCapitalize","autoFocus","testID","_ref$size","size","_ref$showSearchIcon","showSearchIcon","trailing","rest","_objectWithoutProperties","_excluded","textInputRef","React","useRef","mergedRef","useMergeRefs","_useState","useState","_useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useState3","_useState4","isTrailingDropDownOpen","setIsTrailingDropDownOpen","_useDropdown","useDropdown","triggererWrapperRef","onTriggerKeydown","onTriggerClick","dropdownTriggerer","closeParentDropDown","close","isParentDropDownOpen","isOpen","isInsideDropdown","_useState5","_useState6","isSearchFocused","setIsSearchFocused","modalContext","useModalContext","useEffect","Boolean","trailingDropdown","getComponentId","renderTrailingDropDown","cloneElement","selectionType","height","onOpenChange","children","Children","map","props","child","type","InputDropdownButton","_isInsideSearchInput","DropdownOverlay","referenceRef","_isNestedDropdown","defaultPlacement","renderClearButton","_jsx","IconButton","icon","CloseIcon","_textInputRef$current","isEmpty","current","clear","focus","HTMLInputElement","renderInteractionElement","Spinner","color","_jsxs","BaseBox","display","gap","Divider","orientation","searchContent","position","BaseInput","_objectSpread","id","componentName","MetaConstants","SearchInput","isDropdownTrigger","setInputWrapperRef","wrapperNode","undefined","hideLabelText","onKeyDown","_ref2","length","e","leadingIcon","SearchIcon","trailingInteractionElement","trailingDropDown","getKeyboardAndAutocompleteProps","TopNavOverlayThemeOverride","shouldOverrideTheme","isInsideModal","assignWithoutSideEffects","forwardRef","displayName","componentId","dropdownComponentIds","triggers"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA;AACA;AACA,IAAM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
|
|
99
99
|
defaultInitialFocusRef: defaultInitialFocusRef,
|
|
100
|
-
isVisible: isVisible
|
|
100
|
+
isVisible: isVisible,
|
|
101
|
+
isInsideModal: true
|
|
101
102
|
};
|
|
102
103
|
}, [isOpen, onDismiss, isDismissible, defaultInitialFocusRef, isVisible]);
|
|
103
104
|
var handleKeyDown = function handleKeyDown(event) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.web.js","sources":["../../../../../../src/components/Modal/Modal.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect } from 'react';\nimport styled, { css } from 'styled-components';\nimport { FloatingFocusManager, FloatingPortal, useFloating } from '@floating-ui/react';\nimport usePresence from 'use-presence';\nimport { ModalHeader } from './ModalHeader';\nimport type { ModalHeaderProps } from './ModalHeader';\nimport { ModalFooter } from './ModalFooter';\nimport type { ModalFooterProps } from './ModalFooter';\nimport { ModalBody } from './ModalBody';\nimport type { ModalBodyProps } from './ModalBody';\nimport { ModalContext } from './ModalContext';\nimport { ModalBackdrop } from './ModalBackdrop';\nimport {\n modalBorderRadius,\n modalMaxHeight,\n modalMaxWidth,\n modalMinWidth,\n modalResponsiveScreenGap,\n modalMargin,\n} from './modalTokens';\nimport type { ModalProps } from './types';\nimport { castWebType, makeMotionTime, makeSize } from '~utils';\nimport { BaseBox } from '~components/Box/BaseBox';\nimport { useTheme } from '~components/BladeProvider';\nimport { Box } from '~components/Box';\nimport { MetaConstants, metaAttribute } from '~utils/metaAttribute';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { logger } from '~utils/logger';\nimport { componentZIndices } from '~utils/componentZIndices';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport { TopNavOverlayThemeOverride } from '~components/TopNav/TopNavOverlayThemeOverride';\n\nconst ModalContent = styled(BaseBox)<{ isVisible: boolean; size: NonNullable<ModalProps['size']> }>(\n ({ isVisible, theme, size }) => {\n const scale = isVisible ? 1 : 0.9;\n const transform = size !== 'full' ? `translate(-50%, -50%) scale(${scale})` : ``;\n\n return css`\n box-shadow: ${theme.elevation.highRaised};\n opacity: ${isVisible ? 1 : 0};\n position: fixed;\n transform: ${transform};\n transition-property: opacity, transform;\n transition-duration: ${castWebType(makeMotionTime(theme.motion.duration.moderate))};\n transition-timing-function: ${isVisible\n ? castWebType(theme.motion.easing.entrance)\n : castWebType(theme.motion.easing.exit)};\n\n ${size === 'full' &&\n css`\n top: ${makeSize(modalMargin[size])};\n left: ${makeSize(modalMargin[size])};\n right: ${makeSize(modalMargin[size])};\n bottom: ${makeSize(modalMargin[size])};\n `}\n `;\n },\n);\n\nconst Modal = ({\n isOpen = false,\n children,\n onDismiss,\n isDismissible = true,\n initialFocusRef,\n size = 'small',\n accessibilityLabel,\n zIndex = componentZIndices.modal,\n ...rest\n}: ModalProps): React.ReactElement => {\n const { theme, platform } = useTheme();\n const { isMounted, isVisible } = usePresence(isOpen, {\n transitionDuration: theme.motion.duration.moderate,\n initialEnter: true,\n });\n\n // Warn consumer if modal is opened on mobile\n useEffect(() => {\n if (__DEV__) {\n if (platform === 'onMobile') {\n logger({\n message: 'Modal is not supported on mobile devices. Please use BottomSheet instead.',\n moduleName: 'Modal',\n type: 'warn',\n });\n }\n }\n }, [platform]);\n\n // required by floating ui to handle focus\n const { refs, context } = useFloating({\n open: isMounted,\n });\n\n const defaultInitialFocusRef = React.useRef<any>(null);\n\n const modalContext = React.useMemo(\n () => ({\n isOpen,\n close: onDismiss,\n isDismissible,\n defaultInitialFocusRef,\n isVisible,\n }),\n [isOpen, onDismiss, isDismissible, defaultInitialFocusRef, isVisible],\n );\n\n const handleKeyDown = (event: React.KeyboardEvent): void => {\n // close modal on escape key press only if dismissible\n if (isDismissible && (event?.key === 'Escape' || event?.code === 'Escape')) {\n onDismiss?.();\n }\n };\n\n return (\n <FloatingPortal>\n <ModalContext.Provider value={modalContext}>\n {isMounted ? (\n <FloatingFocusManager\n returnFocus\n initialFocus={initialFocusRef ?? defaultInitialFocusRef}\n context={context}\n modal={true}\n >\n <TopNavOverlayThemeOverride>\n <Box zIndex={zIndex} position=\"fixed\" testID=\"modal-wrapper\">\n <ModalBackdrop />\n <ModalContent\n {...metaAttribute({\n name: MetaConstants.Modal,\n })}\n {...makeAccessible({\n role: 'dialog',\n modal: true,\n label: accessibilityLabel,\n })}\n {...makeAnalyticsAttribute(rest)}\n maxWidth={size === 'full' ? '100%' : makeSize(modalMaxWidth[size])}\n minWidth={makeSize(modalMinWidth)}\n maxHeight={modalMaxHeight[size]}\n width={\n size === 'full'\n ? `calc(100vw - ${makeSize(modalMargin[size] * 2)})`\n : `calc(100vw - ${makeSize(modalResponsiveScreenGap)})`\n }\n borderRadius={modalBorderRadius}\n backgroundColor=\"popup.background.gray.subtle\"\n display=\"flex\"\n flexDirection=\"column\"\n top=\"50%\"\n left=\"50%\"\n onKeyDown={handleKeyDown}\n isVisible={isVisible}\n size={size}\n ref={refs.setFloating}\n overflow=\"hidden\"\n >\n {children}\n </ModalContent>\n </Box>\n </TopNavOverlayThemeOverride>\n </FloatingFocusManager>\n ) : null}\n </ModalContext.Provider>\n </FloatingPortal>\n );\n};\n\nexport { Modal, ModalHeader, ModalFooter, ModalBody };\nexport type { ModalProps, ModalHeaderProps, ModalFooterProps, ModalBodyProps };\n"],"names":["ModalContent","styled","BaseBox","withConfig","displayName","componentId","_ref","isVisible","theme","size","scale","transform","concat","css","elevation","highRaised","castWebType","makeMotionTime","motion","duration","moderate","easing","entrance","exit","makeSize","modalMargin","Modal","_ref2","_ref2$isOpen","isOpen","children","onDismiss","_ref2$isDismissible","isDismissible","initialFocusRef","_ref2$size","accessibilityLabel","_ref2$zIndex","zIndex","componentZIndices","modal","rest","_objectWithoutProperties","_excluded","_useTheme","useTheme","platform","_usePresence","usePresence","transitionDuration","initialEnter","isMounted","useEffect","logger","message","moduleName","type","_useFloating","useFloating","open","refs","context","defaultInitialFocusRef","React","useRef","modalContext","useMemo","close","handleKeyDown","event","key","code","_jsx","FloatingPortal","ModalContext","Provider","value","FloatingFocusManager","returnFocus","initialFocus","TopNavOverlayThemeOverride","_jsxs","Box","position","testID","ModalBackdrop","_objectSpread","metaAttribute","name","MetaConstants","makeAccessible","role","label","makeAnalyticsAttribute","maxWidth","modalMaxWidth","minWidth","modalMinWidth","maxHeight","modalMaxHeight","width","modalResponsiveScreenGap","borderRadius","modalBorderRadius","backgroundColor","display","flexDirection","top","left","onKeyDown","ref","setFloating","overflow"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAMA,YAAY,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,wBAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAClC,CAAA,CAAA,UAAAC,IAAA,EAAgC;AAAA,EAAA,IAA7BC,SAAS,GAAAD,IAAA,CAATC,SAAS;IAAEC,KAAK,GAAAF,IAAA,CAALE,KAAK;IAAEC,IAAI,GAAAH,IAAA,CAAJG,IAAI,CAAA;AACvB,EAAA,IAAMC,KAAK,GAAGH,SAAS,GAAG,CAAC,GAAG,GAAG,CAAA;EACjC,IAAMI,SAAS,GAAGF,IAAI,KAAK,MAAM,GAAAG,8BAAAA,CAAAA,MAAA,CAAkCF,KAAK,EAAQ,GAAA,CAAA,GAAA,EAAA,CAAA;AAEhF,EAAA,OAAOG,GAAG,CACML,CAAAA,aAAAA,EAAAA,WAAAA,EAAAA,4BAAAA,EAAAA,6DAAAA,EAAAA,8BAAAA,EAAAA,GAAAA,EAAAA,EAAAA,CAAAA,EAAAA,KAAK,CAACM,SAAS,CAACC,UAAU,EAC7BR,SAAS,GAAG,CAAC,GAAG,CAAC,EAEfI,SAAS,EAECK,WAAW,CAACC,cAAc,CAACT,KAAK,CAACU,MAAM,CAACC,QAAQ,CAACC,QAAQ,CAAC,CAAC,EACpDb,SAAS,GACnCS,WAAW,CAACR,KAAK,CAACU,MAAM,CAACG,MAAM,CAACC,Q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QAAQ,EAAC,QAAQ;AAAAlF,cAAAA,QAAA,EAEhBA,QAAAA;AAAQ,aAAA,CACG,CAAC,CAAA;WACZ,CAAA;SACqB,CAAA;AAAC,OACT,CAAC,GACrB,IAAA;KACiB,CAAA;AAAC,GACV,CAAC,CAAA;AAErB;;;;"}
|
|
1
|
+
{"version":3,"file":"Modal.web.js","sources":["../../../../../../src/components/Modal/Modal.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect } from 'react';\nimport styled, { css } from 'styled-components';\nimport { FloatingFocusManager, FloatingPortal, useFloating } from '@floating-ui/react';\nimport usePresence from 'use-presence';\nimport { ModalHeader } from './ModalHeader';\nimport type { ModalHeaderProps } from './ModalHeader';\nimport { ModalFooter } from './ModalFooter';\nimport type { ModalFooterProps } from './ModalFooter';\nimport { ModalBody } from './ModalBody';\nimport type { ModalBodyProps } from './ModalBody';\nimport { ModalContext } from './ModalContext';\nimport { ModalBackdrop } from './ModalBackdrop';\nimport {\n modalBorderRadius,\n modalMaxHeight,\n modalMaxWidth,\n modalMinWidth,\n modalResponsiveScreenGap,\n modalMargin,\n} from './modalTokens';\nimport type { ModalProps } from './types';\nimport { castWebType, makeMotionTime, makeSize } from '~utils';\nimport { BaseBox } from '~components/Box/BaseBox';\nimport { useTheme } from '~components/BladeProvider';\nimport { Box } from '~components/Box';\nimport { MetaConstants, metaAttribute } from '~utils/metaAttribute';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { logger } from '~utils/logger';\nimport { componentZIndices } from '~utils/componentZIndices';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport { TopNavOverlayThemeOverride } from '~components/TopNav/TopNavOverlayThemeOverride';\n\nconst ModalContent = styled(BaseBox)<{ isVisible: boolean; size: NonNullable<ModalProps['size']> }>(\n ({ isVisible, theme, size }) => {\n const scale = isVisible ? 1 : 0.9;\n const transform = size !== 'full' ? `translate(-50%, -50%) scale(${scale})` : ``;\n\n return css`\n box-shadow: ${theme.elevation.highRaised};\n opacity: ${isVisible ? 1 : 0};\n position: fixed;\n transform: ${transform};\n transition-property: opacity, transform;\n transition-duration: ${castWebType(makeMotionTime(theme.motion.duration.moderate))};\n transition-timing-function: ${isVisible\n ? castWebType(theme.motion.easing.entrance)\n : castWebType(theme.motion.easing.exit)};\n\n ${size === 'full' &&\n css`\n top: ${makeSize(modalMargin[size])};\n left: ${makeSize(modalMargin[size])};\n right: ${makeSize(modalMargin[size])};\n bottom: ${makeSize(modalMargin[size])};\n `}\n `;\n },\n);\n\nconst Modal = ({\n isOpen = false,\n children,\n onDismiss,\n isDismissible = true,\n initialFocusRef,\n size = 'small',\n accessibilityLabel,\n zIndex = componentZIndices.modal,\n ...rest\n}: ModalProps): React.ReactElement => {\n const { theme, platform } = useTheme();\n const { isMounted, isVisible } = usePresence(isOpen, {\n transitionDuration: theme.motion.duration.moderate,\n initialEnter: true,\n });\n\n // Warn consumer if modal is opened on mobile\n useEffect(() => {\n if (__DEV__) {\n if (platform === 'onMobile') {\n logger({\n message: 'Modal is not supported on mobile devices. Please use BottomSheet instead.',\n moduleName: 'Modal',\n type: 'warn',\n });\n }\n }\n }, [platform]);\n\n // required by floating ui to handle focus\n const { refs, context } = useFloating({\n open: isMounted,\n });\n\n const defaultInitialFocusRef = React.useRef<any>(null);\n\n const modalContext = React.useMemo(\n () => ({\n isOpen,\n close: onDismiss,\n isDismissible,\n defaultInitialFocusRef,\n isVisible,\n isInsideModal: true,\n }),\n [isOpen, onDismiss, isDismissible, defaultInitialFocusRef, isVisible],\n );\n\n const handleKeyDown = (event: React.KeyboardEvent): void => {\n // close modal on escape key press only if dismissible\n if (isDismissible && (event?.key === 'Escape' || event?.code === 'Escape')) {\n onDismiss?.();\n }\n };\n\n return (\n <FloatingPortal>\n <ModalContext.Provider value={modalContext}>\n {isMounted ? (\n <FloatingFocusManager\n returnFocus\n initialFocus={initialFocusRef ?? defaultInitialFocusRef}\n context={context}\n modal={true}\n >\n <TopNavOverlayThemeOverride>\n <Box zIndex={zIndex} position=\"fixed\" testID=\"modal-wrapper\">\n <ModalBackdrop />\n <ModalContent\n {...metaAttribute({\n name: MetaConstants.Modal,\n })}\n {...makeAccessible({\n role: 'dialog',\n modal: true,\n label: accessibilityLabel,\n })}\n {...makeAnalyticsAttribute(rest)}\n maxWidth={size === 'full' ? '100%' : makeSize(modalMaxWidth[size])}\n minWidth={makeSize(modalMinWidth)}\n maxHeight={modalMaxHeight[size]}\n width={\n size === 'full'\n ? `calc(100vw - ${makeSize(modalMargin[size] * 2)})`\n : `calc(100vw - ${makeSize(modalResponsiveScreenGap)})`\n }\n borderRadius={modalBorderRadius}\n backgroundColor=\"popup.background.gray.subtle\"\n display=\"flex\"\n flexDirection=\"column\"\n top=\"50%\"\n left=\"50%\"\n onKeyDown={handleKeyDown}\n isVisible={isVisible}\n size={size}\n ref={refs.setFloating}\n overflow=\"hidden\"\n >\n {children}\n </ModalContent>\n </Box>\n </TopNavOverlayThemeOverride>\n </FloatingFocusManager>\n ) : null}\n </ModalContext.Provider>\n </FloatingPortal>\n );\n};\n\nexport { Modal, ModalHeader, ModalFooter, ModalBody };\nexport type { ModalProps, ModalHeaderProps, ModalFooterProps, ModalBodyProps };\n"],"names":["ModalContent","styled","BaseBox","withConfig","displayName","componentId","_ref","isVisible","theme","size","scale","transform","concat","css","elevation","highRaised","castWebType","makeMotionTime","motion","duration","moderate","easing","entrance","exit","makeSize","modalMargin","Modal","_ref2","_ref2$isOpen","isOpen","children","onDismiss","_ref2$isDismissible","isDismissible","initialFocusRef","_ref2$size","accessibilityLabel","_ref2$zIndex","zIndex","componentZIndices","modal","rest","_objectWithoutProperties","_excluded","_useTheme","useTheme","platform","_usePresence","usePresence","transitionDuration","initialEnter","isMounted","useEffect","logger","message","moduleName","type","_useFloating","useFloating","open","refs","context","defaultInitialFocusRef","React","useRef","modalContext","useMemo","close","isInsideModal","handleKeyDown","event","key","code","_jsx","FloatingPortal","ModalContext","Provider","value","FloatingFocusManager","returnFocus","initialFocus","TopNavOverlayThemeOverride","_jsxs","Box","position","testID","ModalBackdrop","_objectSpread","metaAttribute","name","MetaConstants","makeAccessible","role","label","makeAnalyticsAttribute","maxWidth","modalMaxWidth","minWidth","modalMinWidth","maxHeight","modalMaxHeight","width","modalResponsiveScreenGap","borderRadius","modalBorderRadius","backgroundColor","display","flexDirection","top","left","onKeyDown","ref","setFloating","overflow"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAMA,YAAY,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,wBAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAClC,CAAA,CAAA,UAAAC,IAAA,EAAgC;AAAA,EAAA,IAA7BC,SAAS,GAAAD,IAAA,CAATC,SAAS;IAAEC,KAAK,GAAAF,IAAA,CAALE,KAAK;IAAEC,IAAI,GAAAH,IAAA,CAAJG,IAAI,CAAA;AACvB,EAAA,IAAMC,KAAK,GAAGH,SAAS,GAAG,CAAC,GAAG,GAAG,CAAA;EACjC,IAAMI,SAAS,GAAGF,IAAI,KAAK,MAAM,GAAAG,8BAAAA,CAAAA,MAAA,CAAkCF,KAAK,EAAQ,GAAA,CAAA,GAAA,EAAA,CAAA;AAEhF,EAAA,OAAOG,GAAG,CACML,CAAAA,aAAAA,EAAAA,WAAAA,EAAAA,4BAAAA,EAAAA,6DAAAA,EAAAA,8BAAAA,EAAAA,GAAAA,EAAAA,EAAAA,CAAAA,EAAAA,KAAK,CAACM,SAAS,CAACC,UAAU,EAC7BR,SAAS,GAAG,CAAC,GAAG,CAAC,EAEfI,SAAS,EAECK,WAAW,CAACC,cAAc,CAACT,KAAK,CAACU,MAAM,CAACC,QAAQ,CAACC,QAAQ,CAAC,CAAC,EACpDb,SAAS,GACnCS,WAAW,CAACR,KAAK,CAACU,MAAM,CAACG,MAAM,CAACC,QAAQ,CAAC,GACzCN,WAAW,CAACR,KAAK,C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QAAQ,EAAC,QAAQ;AAAAnF,cAAAA,QAAA,EAEhBA,QAAAA;AAAQ,aAAA,CACG,CAAC,CAAA;WACZ,CAAA;SACqB,CAAA;AAAC,OACT,CAAC,GACrB,IAAA;KACiB,CAAA;AAAC,GACV,CAAC,CAAA;AAErB;;;;"}
|
|
@@ -9,7 +9,8 @@ var ModalContext = /*#__PURE__*/React__default.createContext({
|
|
|
9
9
|
current: null
|
|
10
10
|
},
|
|
11
11
|
isOpen: false,
|
|
12
|
-
isVisible: false
|
|
12
|
+
isVisible: false,
|
|
13
|
+
isInsideModal: false
|
|
13
14
|
});
|
|
14
15
|
var useModalContext = function useModalContext() {
|
|
15
16
|
var state = React__default.useContext(ModalContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalContext.js","sources":["../../../../../../src/components/Modal/ModalContext.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react';\n\ntype ModalContextProps = {\n /**\n * Indicates open state of Modal\n */\n isOpen: boolean;\n /**\n * Function to close the Modal\n */\n close?: () => void;\n /**\n * Whether the modal can be dismissed\n */\n isDismissible: boolean;\n /**\n * The element that will get focused when the Modal first opens\n */\n defaultInitialFocusRef: React.MutableRefObject<any>;\n /**\n * Indicates if the Modal is visible according to the usePresence hook\n */\n isVisible: boolean;\n};\n\nconst ModalContext = React.createContext<ModalContextProps>({\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n close: () => {},\n isDismissible: true,\n defaultInitialFocusRef: { current: null },\n isOpen: false,\n isVisible: false,\n});\n\nconst useModalContext = (): ModalContextProps => {\n const state = React.useContext(ModalContext);\n return state;\n};\n\nexport { ModalContext, useModalContext };\n"],"names":["ModalContext","React","createContext","close","isDismissible","defaultInitialFocusRef","current","isOpen","isVisible","useModalContext","state","useContext"],"mappings":";;AAAA;
|
|
1
|
+
{"version":3,"file":"ModalContext.js","sources":["../../../../../../src/components/Modal/ModalContext.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react';\n\ntype ModalContextProps = {\n /**\n * Indicates open state of Modal\n */\n isOpen: boolean;\n /**\n * Function to close the Modal\n */\n close?: () => void;\n /**\n * Whether the modal can be dismissed\n */\n isDismissible: boolean;\n /**\n * The element that will get focused when the Modal first opens\n */\n defaultInitialFocusRef: React.MutableRefObject<any>;\n /**\n * Indicates if the Modal is visible according to the usePresence hook\n */\n isVisible: boolean;\n /**\n * Indicates if the Modal is inside a Modal\n */\n isInsideModal: boolean;\n};\n\nconst ModalContext = React.createContext<ModalContextProps>({\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n close: () => {},\n isDismissible: true,\n defaultInitialFocusRef: { current: null },\n isOpen: false,\n isVisible: false,\n isInsideModal: false,\n});\n\nconst useModalContext = (): ModalContextProps => {\n const state = React.useContext(ModalContext);\n return state;\n};\n\nexport { ModalContext, useModalContext };\n"],"names":["ModalContext","React","createContext","close","isDismissible","defaultInitialFocusRef","current","isOpen","isVisible","isInsideModal","useModalContext","state","useContext"],"mappings":";;AAAA;AA8BA,IAAMA,YAAY,gBAAGC,cAAK,CAACC,aAAa,CAAoB;AAC1D;AACAC,EAAAA,KAAK,EAAE,SAAPA,KAAKA,GAAQ,EAAE;AACfC,EAAAA,aAAa,EAAE,IAAI;AACnBC,EAAAA,sBAAsB,EAAE;AAAEC,IAAAA,OAAO,EAAE,IAAA;GAAM;AACzCC,EAAAA,MAAM,EAAE,KAAK;AACbC,EAAAA,SAAS,EAAE,KAAK;AAChBC,EAAAA,aAAa,EAAE,KAAA;AACjB,CAAC,EAAC;AAEF,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,GAA4B;AAC/C,EAAA,IAAMC,KAAK,GAAGV,cAAK,CAACW,UAAU,CAACZ,YAAY,CAAC,CAAA;AAC5C,EAAA,OAAOW,KAAK,CAAA;AACd;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from '../../../../../_virtual/_commonjsHelpers.js';
|
|
2
|
-
import { __exports as cloneDeep$1 } from '../../../../../_virtual/
|
|
2
|
+
import { __exports as cloneDeep$1 } from '../../../../../_virtual/cloneDeep4.js';
|
|
3
3
|
import '../../../../../_virtual/cloneDeepWith.js';
|
|
4
4
|
import { __exports as cloneDeepWith } from '../../../../../_virtual/cloneDeepWith2.js';
|
|
5
5
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from '../../../../../_virtual/_commonjsHelpers.js';
|
|
2
2
|
import { __exports as matches$1 } from '../../../../../_virtual/matches2.js';
|
|
3
3
|
import '../../../../../_virtual/isMatch.js';
|
|
4
|
-
import '../../../../../_virtual/
|
|
4
|
+
import '../../../../../_virtual/cloneDeep.js';
|
|
5
5
|
import { __exports as isMatch } from '../../../../../_virtual/isMatch2.js';
|
|
6
|
-
import { __exports as cloneDeep } from '../../../../../_virtual/
|
|
6
|
+
import { __exports as cloneDeep } from '../../../../../_virtual/cloneDeep2.js';
|
|
7
7
|
|
|
8
8
|
(function (exports) {
|
|
9
9
|
'use strict';
|
package/build/lib/web/development/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.js
CHANGED
|
@@ -2,12 +2,12 @@ import { getDefaultExportFromCjs } from '../../../../../_virtual/_commonjsHelper
|
|
|
2
2
|
import { __exports as matchesProperty$1 } from '../../../../../_virtual/matchesProperty2.js';
|
|
3
3
|
import '../../../../../_virtual/isMatch.js';
|
|
4
4
|
import '../../../../../_virtual/toKey.js';
|
|
5
|
-
import '../../../../../_virtual/
|
|
5
|
+
import '../../../../../_virtual/cloneDeep3.js';
|
|
6
6
|
import '../../../../../_virtual/get.js';
|
|
7
7
|
import '../../../../../_virtual/has.js';
|
|
8
8
|
import { __exports as isMatch } from '../../../../../_virtual/isMatch2.js';
|
|
9
9
|
import { __exports as toKey } from '../../../../../_virtual/toKey2.js';
|
|
10
|
-
import { __exports as cloneDeep } from '../../../../../_virtual/
|
|
10
|
+
import { __exports as cloneDeep } from '../../../../../_virtual/cloneDeep4.js';
|
|
11
11
|
import { __exports as get } from '../../../../../_virtual/get2.js';
|
|
12
12
|
import { __exports as has } from '../../../../../_virtual/has2.js';
|
|
13
13
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from '../../../../_virtual/_commonjsHelpers.js';
|
|
2
|
-
import { __exports as cloneDeep$1 } from '../../../../_virtual/
|
|
2
|
+
import { __exports as cloneDeep$1 } from '../../../../_virtual/cloneDeep2.js';
|
|
3
3
|
import '../../../../_virtual/cloneDeepWith3.js';
|
|
4
4
|
import { __exports as cloneDeepWith } from '../../../../_virtual/cloneDeepWith4.js';
|
|
5
5
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import '../node_modules/es-toolkit/dist/object/cloneDeep.js';
|
|
1
|
+
import '../node_modules/es-toolkit/dist/compat/object/cloneDeep.js';
|
|
2
2
|
//# sourceMappingURL=cloneDeep.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import '../node_modules/es-toolkit/dist/
|
|
1
|
+
import '../node_modules/es-toolkit/dist/object/cloneDeep.js';
|
|
2
2
|
//# sourceMappingURL=cloneDeep3.js.map
|
|
@@ -19,6 +19,7 @@ import '../../Dropdown/index.js';
|
|
|
19
19
|
import '../../Divider/index.js';
|
|
20
20
|
import '../../../utils/isValidAllowedChildren/index.js';
|
|
21
21
|
import { TopNavOverlayThemeOverride } from '../../TopNav/TopNavOverlayThemeOverride.js';
|
|
22
|
+
import { useModalContext } from '../../Modal/ModalContext.js';
|
|
22
23
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
23
24
|
import { getPlatformType } from '../../../utils/getPlatformType/getPlatformType.js';
|
|
24
25
|
import { getComponentId } from '../../../utils/isValidAllowedChildren/isValidAllowedChildren.js';
|
|
@@ -93,6 +94,7 @@ var _SearchInput = function _SearchInput(_ref, ref) {
|
|
|
93
94
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
94
95
|
isSearchFocused = _useState6[0],
|
|
95
96
|
setIsSearchFocused = _useState6[1];
|
|
97
|
+
var modalContext = useModalContext();
|
|
96
98
|
React__default.useEffect(function () {
|
|
97
99
|
setShouldShowClearButton(Boolean(defaultValue !== null && defaultValue !== void 0 ? defaultValue : value));
|
|
98
100
|
}, [defaultValue, value]);
|
|
@@ -255,7 +257,7 @@ var _SearchInput = function _SearchInput(_ref, ref) {
|
|
|
255
257
|
}, rest))
|
|
256
258
|
});
|
|
257
259
|
return /*#__PURE__*/jsx(TopNavOverlayThemeOverride, {
|
|
258
|
-
shouldOverrideTheme: isSearchFocused,
|
|
260
|
+
shouldOverrideTheme: modalContext.isInsideModal ? true : isSearchFocused,
|
|
259
261
|
children: searchContent
|
|
260
262
|
});
|
|
261
263
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.js","sources":["../../../../../../../src/components/Input/SearchInput/SearchInput.tsx"],"sourcesContent":["import React, { useEffect, useState } 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 isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { CloseIcon, SearchIcon } from '~components/Icons';\nimport { IconButton } from '~components/Button/IconButton';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { MetaConstants } from '~utils/metaAttribute';\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 DataAnalyticsAttribute,\n} from '~utils/types';\nimport { dropdownComponentIds } from '~components/Dropdown/dropdownComponentIds';\nimport { useDropdown } from '~components/Dropdown/useDropdown';\nimport { DropdownOverlay, InputDropdownButton } from '~components/Dropdown';\nimport { Divider } from '~components/Divider';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { TopNavOverlayThemeOverride } from '~components/TopNav/TopNavOverlayThemeOverride';\n\ntype SearchInputCommonProps = Pick<\n BaseInputProps,\n | 'label'\n | 'accessibilityLabel'\n | 'labelPosition'\n | 'labelSuffix'\n | 'labelTrailing'\n | 'helpText'\n | 'placeholder'\n | 'defaultValue'\n | 'name'\n | 'onChange'\n | 'onFocus'\n | 'onBlur'\n | 'value'\n | 'isDisabled'\n | 'autoFocus'\n | 'onSubmit'\n | 'autoCapitalize'\n | 'testID'\n | 'onClick'\n | 'size'\n | keyof DataAnalyticsAttribute\n> & {\n /**\n * Event handler to handle the onClick event for clear button.\n */\n onClearButtonClick?: () => void;\n\n /**\n * Decides whether to show a loading spinner for the input field.\n */\n isLoading?: boolean;\n /**\n * Toggle the visibility of the search icon.\n *\n * @default true\n */\n showSearchIcon?: boolean;\n /**\n * Optional trailing to be shown at the end of the input.\n */\n trailing?: React.ReactNode;\n} & StyledPropsBlade;\n\n/*\n Mandatory accessibilityLabel prop when label is not provided\n*/\ntype SearchInputPropsWithA11yLabel = {\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 SearchInputPropsWithLabel = {\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 SearchInputProps = (SearchInputPropsWithA11yLabel | SearchInputPropsWithLabel) &\n SearchInputCommonProps;\n\n// need to do this to tell TS to infer type as SearchInput 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 _SearchInput: React.ForwardRefRenderFunction<BladeElementRef, SearchInputProps> = (\n {\n label,\n accessibilityLabel,\n labelPosition = 'top',\n placeholder,\n defaultValue,\n name,\n value,\n onChange,\n onClick,\n onFocus,\n onBlur,\n onSubmit,\n isDisabled,\n labelSuffix,\n labelTrailing,\n helpText,\n onClearButtonClick,\n isLoading,\n autoCapitalize,\n autoFocus,\n testID,\n size = 'medium',\n showSearchIcon = true,\n trailing,\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 [isTrailingDropDownOpen, setIsTrailingDropDownOpen] = useState(false);\n const {\n triggererWrapperRef,\n onTriggerKeydown,\n onTriggerClick,\n dropdownTriggerer,\n close: closeParentDropDown,\n isOpen: isParentDropDownOpen,\n } = useDropdown();\n const isInsideDropdown = dropdownTriggerer === 'SearchInput';\n\n const [isSearchFocused, setIsSearchFocused] = useState(false);\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(defaultValue ?? value));\n }, [defaultValue, value]);\n\n useEffect(() => {\n if (isParentDropDownOpen && isTrailingDropDownOpen) {\n setIsTrailingDropDownOpen(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [closeParentDropDown, isParentDropDownOpen]);\n\n useEffect(() => {\n if (isTrailingDropDownOpen && isParentDropDownOpen) {\n closeParentDropDown();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [setIsTrailingDropDownOpen, isTrailingDropDownOpen]);\n\n const trailingDropdown =\n trailing && getComponentId(trailing as React.ReactElement) === 'Dropdown' ? trailing : null;\n\n const renderTrailingDropDown = (): React.ReactElement | null => {\n if (!trailingDropdown) {\n return null;\n }\n return React.cloneElement(trailingDropdown as React.ReactElement, {\n selectionType: 'single',\n isOpen: isTrailingDropDownOpen,\n height: '100%',\n onOpenChange: (isOpen: boolean) => {\n setIsTrailingDropDownOpen(isOpen);\n },\n children: React.Children.map(\n (trailingDropdown as React.ReactElement).props.children,\n (child) => {\n if (child.type === InputDropdownButton) {\n return React.cloneElement(child, {\n _isInsideSearchInput: true,\n size,\n });\n }\n if (child.type === DropdownOverlay) {\n return React.cloneElement(child, {\n referenceRef: triggererWrapperRef,\n _isNestedDropdown: true,\n defaultPlacement: 'bottom-end',\n });\n }\n return child;\n },\n ),\n });\n };\n\n const renderClearButton = (): React.ReactElement => {\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(value) && 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\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\n const renderInteractionElement = (): ReactNode => {\n if (isLoading) {\n return <Spinner accessibilityLabel=\"Loading Content\" color=\"primary\" />;\n }\n\n if (shouldShowClearButton && trailingDropdown) {\n return (\n <BaseBox display=\"flex\" gap=\"spacing.3\">\n {renderClearButton()} <Divider orientation=\"vertical\" />\n </BaseBox>\n );\n }\n if (shouldShowClearButton) {\n return renderClearButton();\n }\n\n return null;\n };\n\n const searchContent = (\n <BaseBox position=\"relative\">\n <BaseInput\n id=\"searchinput\"\n componentName={MetaConstants.SearchInput}\n ref={mergedRef}\n isDropdownTrigger={true}\n setInputWrapperRef={\n isInsideDropdown || isTrailingDropDownOpen\n ? (wrapperNode) => {\n triggererWrapperRef.current = wrapperNode;\n }\n : undefined\n }\n label={label as string}\n accessibilityLabel={accessibilityLabel}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n labelSuffix={labelSuffix}\n labelTrailing={labelTrailing}\n placeholder={placeholder}\n defaultValue={defaultValue}\n value={value}\n name={name}\n onKeyDown={isInsideDropdown ? onTriggerKeydown : undefined}\n onChange={({ name, value }) => {\n if (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 onChange?.({ name, value });\n }}\n onClick={(e) => {\n if (isDisabled) return;\n if (isInsideDropdown) {\n onTriggerClick();\n }\n onClick?.(e);\n }}\n onFocus={(e) => {\n setIsSearchFocused(true);\n onFocus?.(e);\n }}\n onBlur={(e) => {\n setIsSearchFocused(false);\n onBlur?.(e);\n }}\n onSubmit={onSubmit}\n isDisabled={isDisabled}\n leadingIcon={showSearchIcon ? SearchIcon : undefined}\n trailingInteractionElement={renderInteractionElement()}\n trailingDropDown={renderTrailingDropDown()}\n helpText={helpText}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n {...getKeyboardAndAutocompleteProps({\n type: 'search',\n autoCapitalize,\n })}\n size={size}\n {...rest}\n />\n </BaseBox>\n );\n\n return (\n <TopNavOverlayThemeOverride shouldOverrideTheme={isSearchFocused}>\n {searchContent}\n </TopNavOverlayThemeOverride>\n );\n};\n\nconst SearchInput = assignWithoutSideEffects(React.forwardRef(_SearchInput), {\n displayName: 'SearchInput',\n componentId: dropdownComponentIds.triggers.SearchInput,\n});\n\nexport type { SearchInputProps };\nexport { SearchInput };\n"],"names":["isReactNative","_textInputRef","getPlatformType","_SearchInput","_ref","ref","label","accessibilityLabel","_ref$labelPosition","labelPosition","placeholder","defaultValue","name","value","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","labelSuffix","labelTrailing","helpText","onClearButtonClick","isLoading","autoCapitalize","autoFocus","testID","_ref$size","size","_ref$showSearchIcon","showSearchIcon","trailing","rest","_objectWithoutProperties","_excluded","textInputRef","React","useRef","mergedRef","useMergeRefs","_useState","useState","_useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useState3","_useState4","isTrailingDropDownOpen","setIsTrailingDropDownOpen","_useDropdown","useDropdown","triggererWrapperRef","onTriggerKeydown","onTriggerClick","dropdownTriggerer","closeParentDropDown","close","isParentDropDownOpen","isOpen","isInsideDropdown","_useState5","_useState6","isSearchFocused","setIsSearchFocused","useEffect","Boolean","trailingDropdown","getComponentId","renderTrailingDropDown","cloneElement","selectionType","height","onOpenChange","children","Children","map","props","child","type","InputDropdownButton","_isInsideSearchInput","DropdownOverlay","referenceRef","_isNestedDropdown","defaultPlacement","renderClearButton","_jsx","IconButton","icon","CloseIcon","_textInputRef$current","isEmpty","current","clear","focus","HTMLInputElement","renderInteractionElement","Spinner","color","_jsxs","BaseBox","display","gap","Divider","orientation","searchContent","position","BaseInput","_objectSpread","id","componentName","MetaConstants","SearchInput","isDropdownTrigger","setInputWrapperRef","wrapperNode","undefined","hideLabelText","onKeyDown","_ref2","length","e","leadingIcon","SearchIcon","trailingInteractionElement","trailingDropDown","getKeyboardAndAutocompleteProps","TopNavOverlayThemeOverride","shouldOverrideTheme","assignWithoutSideEffects","forwardRef","displayName","componentId","dropdownComponentIds","triggers"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGA;AACA;AACA,IAAMA,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,aAAmB,EAA4C;AACpF,EAAA,OAAOC,eAAe,EAAE,KAAK,cAAc,CAAA;AAC7C,CAAC,CAAA;AAED,IAAMC,YAA+E,GAAG,SAAlFA,YAA+EA,CAAAC,IAAA,EA4BnFC,GAAG,EACc;AAAA,EAAA,IA3BfC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,kBAAkB,GAAAH,IAAA,CAAlBG,kBAAkB;IAAAC,kBAAA,GAAAJ,IAAA,CAClBK,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,kBAAA;IACrBE,WAAW,GAAAN,IAAA,CAAXM,WAAW;IACXC,YAA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AA+B,CAAC;AAClChD,MAAAA,IAAI,EAAE,QAAQ;AACdvD,MAAAA,cAAc,EAAdA,cAAAA;AACF,KAAC,CAAC,CAAA,EAAA,EAAA,EAAA;AACFI,MAAAA,IAAI,EAAEA,IAAAA;AAAK,KAAA,EACPI,IAAI,CACT,CAAA;AAAC,GACK,CACV,CAAA;EAED,oBACEuD,GAAA,CAACyC,0BAA0B,EAAA;AAACC,IAAAA,mBAAmB,EAAElE,eAAgB;AAAAW,IAAAA,QAAA,EAC9DgC,aAAAA;AAAa,GACY,CAAC,CAAA;AAEjC,CAAC,CAAA;AAEKO,IAAAA,WAAW,gBAAGiB,wBAAwB,cAAC9F,cAAK,CAAC+F,UAAU,CAACjI,YAAY,CAAC,EAAE;AAC3EkI,EAAAA,WAAW,EAAE,aAAa;AAC1BC,EAAAA,WAAW,EAAEC,oBAAoB,CAACC,QAAQ,CAACtB,WAAAA;AAC7C,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"SearchInput.js","sources":["../../../../../../../src/components/Input/SearchInput/SearchInput.tsx"],"sourcesContent":["import React, { useEffect, useState } 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 isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { CloseIcon, SearchIcon } from '~components/Icons';\nimport { IconButton } from '~components/Button/IconButton';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { MetaConstants } from '~utils/metaAttribute';\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 DataAnalyticsAttribute,\n} from '~utils/types';\nimport { dropdownComponentIds } from '~components/Dropdown/dropdownComponentIds';\nimport { useDropdown } from '~components/Dropdown/useDropdown';\nimport { DropdownOverlay, InputDropdownButton } from '~components/Dropdown';\nimport { Divider } from '~components/Divider';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { TopNavOverlayThemeOverride } from '~components/TopNav/TopNavOverlayThemeOverride';\nimport { useModalContext } from '~components/Modal/ModalContext';\n\ntype SearchInputCommonProps = Pick<\n BaseInputProps,\n | 'label'\n | 'accessibilityLabel'\n | 'labelPosition'\n | 'labelSuffix'\n | 'labelTrailing'\n | 'helpText'\n | 'placeholder'\n | 'defaultValue'\n | 'name'\n | 'onChange'\n | 'onFocus'\n | 'onBlur'\n | 'value'\n | 'isDisabled'\n | 'autoFocus'\n | 'onSubmit'\n | 'autoCapitalize'\n | 'testID'\n | 'onClick'\n | 'size'\n | keyof DataAnalyticsAttribute\n> & {\n /**\n * Event handler to handle the onClick event for clear button.\n */\n onClearButtonClick?: () => void;\n\n /**\n * Decides whether to show a loading spinner for the input field.\n */\n isLoading?: boolean;\n /**\n * Toggle the visibility of the search icon.\n *\n * @default true\n */\n showSearchIcon?: boolean;\n /**\n * Optional trailing to be shown at the end of the input.\n */\n trailing?: React.ReactNode;\n} & StyledPropsBlade;\n\n/*\n Mandatory accessibilityLabel prop when label is not provided\n*/\ntype SearchInputPropsWithA11yLabel = {\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 SearchInputPropsWithLabel = {\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 SearchInputProps = (SearchInputPropsWithA11yLabel | SearchInputPropsWithLabel) &\n SearchInputCommonProps;\n\n// need to do this to tell TS to infer type as SearchInput 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 _SearchInput: React.ForwardRefRenderFunction<BladeElementRef, SearchInputProps> = (\n {\n label,\n accessibilityLabel,\n labelPosition = 'top',\n placeholder,\n defaultValue,\n name,\n value,\n onChange,\n onClick,\n onFocus,\n onBlur,\n onSubmit,\n isDisabled,\n labelSuffix,\n labelTrailing,\n helpText,\n onClearButtonClick,\n isLoading,\n autoCapitalize,\n autoFocus,\n testID,\n size = 'medium',\n showSearchIcon = true,\n trailing,\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 [isTrailingDropDownOpen, setIsTrailingDropDownOpen] = useState(false);\n const {\n triggererWrapperRef,\n onTriggerKeydown,\n onTriggerClick,\n dropdownTriggerer,\n close: closeParentDropDown,\n isOpen: isParentDropDownOpen,\n } = useDropdown();\n const isInsideDropdown = dropdownTriggerer === 'SearchInput';\n\n const [isSearchFocused, setIsSearchFocused] = useState(false);\n\n const modalContext = useModalContext();\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(defaultValue ?? value));\n }, [defaultValue, value]);\n\n useEffect(() => {\n if (isParentDropDownOpen && isTrailingDropDownOpen) {\n setIsTrailingDropDownOpen(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [closeParentDropDown, isParentDropDownOpen]);\n\n useEffect(() => {\n if (isTrailingDropDownOpen && isParentDropDownOpen) {\n closeParentDropDown();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [setIsTrailingDropDownOpen, isTrailingDropDownOpen]);\n\n const trailingDropdown =\n trailing && getComponentId(trailing as React.ReactElement) === 'Dropdown' ? trailing : null;\n\n const renderTrailingDropDown = (): React.ReactElement | null => {\n if (!trailingDropdown) {\n return null;\n }\n return React.cloneElement(trailingDropdown as React.ReactElement, {\n selectionType: 'single',\n isOpen: isTrailingDropDownOpen,\n height: '100%',\n onOpenChange: (isOpen: boolean) => {\n setIsTrailingDropDownOpen(isOpen);\n },\n children: React.Children.map(\n (trailingDropdown as React.ReactElement).props.children,\n (child) => {\n if (child.type === InputDropdownButton) {\n return React.cloneElement(child, {\n _isInsideSearchInput: true,\n size,\n });\n }\n if (child.type === DropdownOverlay) {\n return React.cloneElement(child, {\n referenceRef: triggererWrapperRef,\n _isNestedDropdown: true,\n defaultPlacement: 'bottom-end',\n });\n }\n return child;\n },\n ),\n });\n };\n\n const renderClearButton = (): React.ReactElement => {\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(value) && 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\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\n const renderInteractionElement = (): ReactNode => {\n if (isLoading) {\n return <Spinner accessibilityLabel=\"Loading Content\" color=\"primary\" />;\n }\n\n if (shouldShowClearButton && trailingDropdown) {\n return (\n <BaseBox display=\"flex\" gap=\"spacing.3\">\n {renderClearButton()} <Divider orientation=\"vertical\" />\n </BaseBox>\n );\n }\n if (shouldShowClearButton) {\n return renderClearButton();\n }\n\n return null;\n };\n\n const searchContent = (\n <BaseBox position=\"relative\">\n <BaseInput\n id=\"searchinput\"\n componentName={MetaConstants.SearchInput}\n ref={mergedRef}\n isDropdownTrigger={true}\n setInputWrapperRef={\n isInsideDropdown || isTrailingDropDownOpen\n ? (wrapperNode) => {\n triggererWrapperRef.current = wrapperNode;\n }\n : undefined\n }\n label={label as string}\n accessibilityLabel={accessibilityLabel}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n labelSuffix={labelSuffix}\n labelTrailing={labelTrailing}\n placeholder={placeholder}\n defaultValue={defaultValue}\n value={value}\n name={name}\n onKeyDown={isInsideDropdown ? onTriggerKeydown : undefined}\n onChange={({ name, value }) => {\n if (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 onChange?.({ name, value });\n }}\n onClick={(e) => {\n if (isDisabled) return;\n if (isInsideDropdown) {\n onTriggerClick();\n }\n onClick?.(e);\n }}\n onFocus={(e) => {\n setIsSearchFocused(true);\n onFocus?.(e);\n }}\n onBlur={(e) => {\n setIsSearchFocused(false);\n onBlur?.(e);\n }}\n onSubmit={onSubmit}\n isDisabled={isDisabled}\n leadingIcon={showSearchIcon ? SearchIcon : undefined}\n trailingInteractionElement={renderInteractionElement()}\n trailingDropDown={renderTrailingDropDown()}\n helpText={helpText}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n {...getKeyboardAndAutocompleteProps({\n type: 'search',\n autoCapitalize,\n })}\n size={size}\n {...rest}\n />\n </BaseBox>\n );\n\n return (\n <TopNavOverlayThemeOverride\n shouldOverrideTheme={modalContext.isInsideModal ? true : isSearchFocused}\n >\n {searchContent}\n </TopNavOverlayThemeOverride>\n );\n};\n\nconst SearchInput = assignWithoutSideEffects(React.forwardRef(_SearchInput), {\n displayName: 'SearchInput',\n componentId: dropdownComponentIds.triggers.SearchInput,\n});\n\nexport type { SearchInputProps };\nexport { SearchInput };\n"],"names":["isReactNative","_textInputRef","getPlatformType","_SearchInput","_ref","ref","label","accessibilityLabel","_ref$labelPosition","labelPosition","placeholder","defaultValue","name","value","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","labelSuffix","labelTrailing","helpText","onClearButtonClick","isLoading","autoCapitalize","autoFocus","testID","_ref$size","size","_ref$showSearchIcon","showSearchIcon","trailing","rest","_objectWithoutProperties","_excluded","textInputRef","React","useRef","mergedRef","useMergeRefs","_useState","useState","_useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useState3","_useState4","isTrailingDropDownOpen","setIsTrailingDropDownOpen","_useDropdown","useDropdown","triggererWrapperRef","onTriggerKeydown","onTriggerClick","dropdownTriggerer","closeParentDropDown","close","isParentDropDownOpen","isOpen","isInsideDropdown","_useState5","_useState6","isSearchFocused","setIsSearchFocused","modalContext","useModalContext","useEffect","Boolean","trailingDropdown","getComponentId","renderTrailingDropDown","cloneElement","selectionType","height","onOpenChange","children","Children","map","props","child","type","InputDropdownButton","_isInsideSearchInput","DropdownOverlay","referenceRef","_isNestedDropdown","defaultPlacement","renderClearButton","_jsx","IconButton","icon","CloseIcon","_textInputRef$current","isEmpty","current","clear","focus","HTMLInputElement","renderInteractionElement","Spinner","color","_jsxs","BaseBox","display","gap","Divider","orientation","searchContent","position","BaseInput","_objectSpread","id","componentName","MetaConstants","SearchInput","isDropdownTrigger","setInputWrapperRef","wrapperNode","undefined","hideLabelText","onKeyDown","_ref2","length","e","leadingIcon","SearchIcon","trailingInteractionElement","trailingDropDown","getKeyboardAndAutocompleteProps","TopNavOverlayThemeOverride","shouldOverrideTheme","isInsideModal","assignWithoutSideEffects","forwardRef","displayName","componentId","dropdownComponentIds","triggers"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA;AACA;AACA,IAAMA,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,aAAmB,EAA4C;AACpF,EAAA,OAAOC,eAAe,EAAE,KAAK,cAAc,CAAA;AAC7C,CAAC,CAAA;AAED,IAAMC,YAA+E,GAAG,SAAlFA,YAA+EA,CAAAC,IAAA,EA4BnFC,GAAG,EACc;AAAA,EAAA,IA3BfC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,kBAAkB,GAAAH,IAAA,CAAl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UAAU,GAAGP,SAAU;MACrDQ,0BAA0B,EAAE5B,wBAAwB,EAAG;MACvD6B,gBAAgB,EAAEzD,sBAAsB,EAAG;AAC3ClD,MAAAA,QAAQ,EAAEA,QAAAA;AACV;AAAA;AACAI,MAAAA,SAAS,EAAEA,SAAU;AACrBC,MAAAA,MAAM,EAAEA,MAAAA;AAAO,KAAA,EACXuG,+BAA+B,CAAC;AAClChD,MAAAA,IAAI,EAAE,QAAQ;AACdzD,MAAAA,cAAc,EAAdA,cAAAA;AACF,KAAC,CAAC,CAAA,EAAA,EAAA,EAAA;AACFI,MAAAA,IAAI,EAAEA,IAAAA;AAAK,KAAA,EACPI,IAAI,CACT,CAAA;AAAC,GACK,CACV,CAAA;EAED,oBACEyD,GAAA,CAACyC,0BAA0B,EAAA;AACzBC,IAAAA,mBAAmB,EAAElE,YAAY,CAACmE,aAAa,GAAG,IAAI,GAAGrE,eAAgB;AAAAa,IAAAA,QAAA,EAExEgC,aAAAA;AAAa,GACY,CAAC,CAAA;AAEjC,CAAC,CAAA;AAEKO,IAAAA,WAAW,gBAAGkB,wBAAwB,cAACjG,cAAK,CAACkG,UAAU,CAACpI,YAAY,CAAC,EAAE;AAC3EqI,EAAAA,WAAW,EAAE,aAAa;AAC1BC,EAAAA,WAAW,EAAEC,oBAAoB,CAACC,QAAQ,CAACvB,WAAAA;AAC7C,CAAC;;;;"}
|
|
@@ -97,7 +97,8 @@ var Modal = function Modal(_ref2) {
|
|
|
97
97
|
close: onDismiss,
|
|
98
98
|
isDismissible: isDismissible,
|
|
99
99
|
defaultInitialFocusRef: defaultInitialFocusRef,
|
|
100
|
-
isVisible: isVisible
|
|
100
|
+
isVisible: isVisible,
|
|
101
|
+
isInsideModal: true
|
|
101
102
|
};
|
|
102
103
|
}, [isOpen, onDismiss, isDismissible, defaultInitialFocusRef, isVisible]);
|
|
103
104
|
var handleKeyDown = function handleKeyDown(event) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.web.js","sources":["../../../../../../src/components/Modal/Modal.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect } from 'react';\nimport styled, { css } from 'styled-components';\nimport { FloatingFocusManager, FloatingPortal, useFloating } from '@floating-ui/react';\nimport usePresence from 'use-presence';\nimport { ModalHeader } from './ModalHeader';\nimport type { ModalHeaderProps } from './ModalHeader';\nimport { ModalFooter } from './ModalFooter';\nimport type { ModalFooterProps } from './ModalFooter';\nimport { ModalBody } from './ModalBody';\nimport type { ModalBodyProps } from './ModalBody';\nimport { ModalContext } from './ModalContext';\nimport { ModalBackdrop } from './ModalBackdrop';\nimport {\n modalBorderRadius,\n modalMaxHeight,\n modalMaxWidth,\n modalMinWidth,\n modalResponsiveScreenGap,\n modalMargin,\n} from './modalTokens';\nimport type { ModalProps } from './types';\nimport { castWebType, makeMotionTime, makeSize } from '~utils';\nimport { BaseBox } from '~components/Box/BaseBox';\nimport { useTheme } from '~components/BladeProvider';\nimport { Box } from '~components/Box';\nimport { MetaConstants, metaAttribute } from '~utils/metaAttribute';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { logger } from '~utils/logger';\nimport { componentZIndices } from '~utils/componentZIndices';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport { TopNavOverlayThemeOverride } from '~components/TopNav/TopNavOverlayThemeOverride';\n\nconst ModalContent = styled(BaseBox)<{ isVisible: boolean; size: NonNullable<ModalProps['size']> }>(\n ({ isVisible, theme, size }) => {\n const scale = isVisible ? 1 : 0.9;\n const transform = size !== 'full' ? `translate(-50%, -50%) scale(${scale})` : ``;\n\n return css`\n box-shadow: ${theme.elevation.highRaised};\n opacity: ${isVisible ? 1 : 0};\n position: fixed;\n transform: ${transform};\n transition-property: opacity, transform;\n transition-duration: ${castWebType(makeMotionTime(theme.motion.duration.moderate))};\n transition-timing-function: ${isVisible\n ? castWebType(theme.motion.easing.entrance)\n : castWebType(theme.motion.easing.exit)};\n\n ${size === 'full' &&\n css`\n top: ${makeSize(modalMargin[size])};\n left: ${makeSize(modalMargin[size])};\n right: ${makeSize(modalMargin[size])};\n bottom: ${makeSize(modalMargin[size])};\n `}\n `;\n },\n);\n\nconst Modal = ({\n isOpen = false,\n children,\n onDismiss,\n isDismissible = true,\n initialFocusRef,\n size = 'small',\n accessibilityLabel,\n zIndex = componentZIndices.modal,\n ...rest\n}: ModalProps): React.ReactElement => {\n const { theme, platform } = useTheme();\n const { isMounted, isVisible } = usePresence(isOpen, {\n transitionDuration: theme.motion.duration.moderate,\n initialEnter: true,\n });\n\n // Warn consumer if modal is opened on mobile\n useEffect(() => {\n if (__DEV__) {\n if (platform === 'onMobile') {\n logger({\n message: 'Modal is not supported on mobile devices. Please use BottomSheet instead.',\n moduleName: 'Modal',\n type: 'warn',\n });\n }\n }\n }, [platform]);\n\n // required by floating ui to handle focus\n const { refs, context } = useFloating({\n open: isMounted,\n });\n\n const defaultInitialFocusRef = React.useRef<any>(null);\n\n const modalContext = React.useMemo(\n () => ({\n isOpen,\n close: onDismiss,\n isDismissible,\n defaultInitialFocusRef,\n isVisible,\n }),\n [isOpen, onDismiss, isDismissible, defaultInitialFocusRef, isVisible],\n );\n\n const handleKeyDown = (event: React.KeyboardEvent): void => {\n // close modal on escape key press only if dismissible\n if (isDismissible && (event?.key === 'Escape' || event?.code === 'Escape')) {\n onDismiss?.();\n }\n };\n\n return (\n <FloatingPortal>\n <ModalContext.Provider value={modalContext}>\n {isMounted ? (\n <FloatingFocusManager\n returnFocus\n initialFocus={initialFocusRef ?? defaultInitialFocusRef}\n context={context}\n modal={true}\n >\n <TopNavOverlayThemeOverride>\n <Box zIndex={zIndex} position=\"fixed\" testID=\"modal-wrapper\">\n <ModalBackdrop />\n <ModalContent\n {...metaAttribute({\n name: MetaConstants.Modal,\n })}\n {...makeAccessible({\n role: 'dialog',\n modal: true,\n label: accessibilityLabel,\n })}\n {...makeAnalyticsAttribute(rest)}\n maxWidth={size === 'full' ? '100%' : makeSize(modalMaxWidth[size])}\n minWidth={makeSize(modalMinWidth)}\n maxHeight={modalMaxHeight[size]}\n width={\n size === 'full'\n ? `calc(100vw - ${makeSize(modalMargin[size] * 2)})`\n : `calc(100vw - ${makeSize(modalResponsiveScreenGap)})`\n }\n borderRadius={modalBorderRadius}\n backgroundColor=\"popup.background.gray.subtle\"\n display=\"flex\"\n flexDirection=\"column\"\n top=\"50%\"\n left=\"50%\"\n onKeyDown={handleKeyDown}\n isVisible={isVisible}\n size={size}\n ref={refs.setFloating}\n overflow=\"hidden\"\n >\n {children}\n </ModalContent>\n </Box>\n </TopNavOverlayThemeOverride>\n </FloatingFocusManager>\n ) : null}\n </ModalContext.Provider>\n </FloatingPortal>\n );\n};\n\nexport { Modal, ModalHeader, ModalFooter, ModalBody };\nexport type { ModalProps, ModalHeaderProps, ModalFooterProps, ModalBodyProps };\n"],"names":["ModalContent","styled","BaseBox","withConfig","displayName","componentId","_ref","isVisible","theme","size","scale","transform","concat","css","elevation","highRaised","castWebType","makeMotionTime","motion","duration","moderate","easing","entrance","exit","makeSize","modalMargin","Modal","_ref2","_ref2$isOpen","isOpen","children","onDismiss","_ref2$isDismissible","isDismissible","initialFocusRef","_ref2$size","accessibilityLabel","_ref2$zIndex","zIndex","componentZIndices","modal","rest","_objectWithoutProperties","_excluded","_useTheme","useTheme","platform","_usePresence","usePresence","transitionDuration","initialEnter","isMounted","useEffect","logger","message","moduleName","type","_useFloating","useFloating","open","refs","context","defaultInitialFocusRef","React","useRef","modalContext","useMemo","close","handleKeyDown","event","key","code","_jsx","FloatingPortal","ModalContext","Provider","value","FloatingFocusManager","returnFocus","initialFocus","TopNavOverlayThemeOverride","_jsxs","Box","position","testID","ModalBackdrop","_objectSpread","metaAttribute","name","MetaConstants","makeAccessible","role","label","makeAnalyticsAttribute","maxWidth","modalMaxWidth","minWidth","modalMinWidth","maxHeight","modalMaxHeight","width","modalResponsiveScreenGap","borderRadius","modalBorderRadius","backgroundColor","display","flexDirection","top","left","onKeyDown","ref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ACdnD,cAAAA,KAAK,EAAE,IAAI;AACXoD,cAAAA,KAAK,EAAExD,kBAAAA;AACT,aAAC,CAAC,CAAA,EACEyD,sBAAsB,CAACpD,IAAI,CAAC,CAAA,EAAA,EAAA,EAAA;AAChCqD,cAAAA,QAAQ,EAAErF,IAAI,KAAK,MAAM,GAAG,MAAM,GAAGe,QAAQ,CAACuE,aAAa,CAACtF,IAAI,CAAC,CAAE;AACnEuF,cAAAA,QAAQ,EAAExE,QAAQ,CAACyE,aAAa,CAAE;AAClCC,cAAAA,SAAS,EAAEC,cAAc,CAAC1F,IAAI,CAAE;cAChC2F,KAAK,EACH3F,IAAI,KAAK,MAAM,mBAAAG,MAAA,CACKY,QAAQ,CAACC,WAAW,CAAChB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAAG,GAAAA,CAAAA,GAAAA,eAAAA,CAAAA,MAAA,CAC/BY,QAAQ,CAAC6E,wBAAwB,CAAC,EACvD,GAAA,CAAA;AACDC,cAAAA,YAAY,EAAEC,iBAAkB;AAChCC,cAAAA,eAAe,EAAC,8BAA8B;AAC9CC,cAAAA,OAAO,EAAC,MAAM;AACdC,cAAAA,aAAa,EAAC,QAAQ;AACtBC,cAAAA,GAAG,EAAC,KAAK;AACTC,cAAAA,IAAI,EAAC,KAAK;AACVC,cAAAA,SAAS,EAAEzC,aAAc;AACzB7D,cAAAA,SAAS,EAAEA,SAAU;AACrBE,cAAAA,IAAI,EAAEA,IAAK;cACXqG,GAAG,EAAElD,IAAI,CAACmD,WAAY;AACtBC,cAAAA,QAAQ,EAAC,QAAQ;AAAAlF,cAAAA,QAAA,EAEhBA,QAAAA;AAAQ,aAAA,CACG,CAAC,CAAA;WACZ,CAAA;SACqB,CAAA;AAAC,OACT,CAAC,GACrB,IAAA;KACiB,CAAA;AAAC,GACV,CAAC,CAAA;AAErB;;;;"}
|
|
1
|
+
{"version":3,"file":"Modal.web.js","sources":["../../../../../../src/components/Modal/Modal.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect } from 'react';\nimport styled, { css } from 'styled-components';\nimport { FloatingFocusManager, FloatingPortal, useFloating } from '@floating-ui/react';\nimport usePresence from 'use-presence';\nimport { ModalHeader } from './ModalHeader';\nimport type { ModalHeaderProps } from './ModalHeader';\nimport { ModalFooter } from './ModalFooter';\nimport type { ModalFooterProps } from './ModalFooter';\nimport { ModalBody } from './ModalBody';\nimport type { ModalBodyProps } from './ModalBody';\nimport { ModalContext } from './ModalContext';\nimport { ModalBackdrop } from './ModalBackdrop';\nimport {\n modalBorderRadius,\n modalMaxHeight,\n modalMaxWidth,\n modalMinWidth,\n modalResponsiveScreenGap,\n modalMargin,\n} from './modalTokens';\nimport type { ModalProps } from './types';\nimport { castWebType, makeMotionTime, makeSize } from '~utils';\nimport { BaseBox } from '~components/Box/BaseBox';\nimport { useTheme } from '~components/BladeProvider';\nimport { Box } from '~components/Box';\nimport { MetaConstants, metaAttribute } from '~utils/metaAttribute';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { logger } from '~utils/logger';\nimport { componentZIndices } from '~utils/componentZIndices';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport { TopNavOverlayThemeOverride } from '~components/TopNav/TopNavOverlayThemeOverride';\n\nconst ModalContent = styled(BaseBox)<{ isVisible: boolean; size: NonNullable<ModalProps['size']> }>(\n ({ isVisible, theme, size }) => {\n const scale = isVisible ? 1 : 0.9;\n const transform = size !== 'full' ? `translate(-50%, -50%) scale(${scale})` : ``;\n\n return css`\n box-shadow: ${theme.elevation.highRaised};\n opacity: ${isVisible ? 1 : 0};\n position: fixed;\n transform: ${transform};\n transition-property: opacity, transform;\n transition-duration: ${castWebType(makeMotionTime(theme.motion.duration.moderate))};\n transition-timing-function: ${isVisible\n ? castWebType(theme.motion.easing.entrance)\n : castWebType(theme.motion.easing.exit)};\n\n ${size === 'full' &&\n css`\n top: ${makeSize(modalMargin[size])};\n left: ${makeSize(modalMargin[size])};\n right: ${makeSize(modalMargin[size])};\n bottom: ${makeSize(modalMargin[size])};\n `}\n `;\n },\n);\n\nconst Modal = ({\n isOpen = false,\n children,\n onDismiss,\n isDismissible = true,\n initialFocusRef,\n size = 'small',\n accessibilityLabel,\n zIndex = componentZIndices.modal,\n ...rest\n}: ModalProps): React.ReactElement => {\n const { theme, platform } = useTheme();\n const { isMounted, isVisible } = usePresence(isOpen, {\n transitionDuration: theme.motion.duration.moderate,\n initialEnter: true,\n });\n\n // Warn consumer if modal is opened on mobile\n useEffect(() => {\n if (__DEV__) {\n if (platform === 'onMobile') {\n logger({\n message: 'Modal is not supported on mobile devices. Please use BottomSheet instead.',\n moduleName: 'Modal',\n type: 'warn',\n });\n }\n }\n }, [platform]);\n\n // required by floating ui to handle focus\n const { refs, context } = useFloating({\n open: isMounted,\n });\n\n const defaultInitialFocusRef = React.useRef<any>(null);\n\n const modalContext = React.useMemo(\n () => ({\n isOpen,\n close: onDismiss,\n isDismissible,\n defaultInitialFocusRef,\n isVisible,\n isInsideModal: true,\n }),\n [isOpen, onDismiss, isDismissible, defaultInitialFocusRef, isVisible],\n );\n\n const handleKeyDown = (event: React.KeyboardEvent): void => {\n // close modal on escape key press only if dismissible\n if (isDismissible && (event?.key === 'Escape' || event?.code === 'Escape')) {\n onDismiss?.();\n }\n };\n\n return (\n <FloatingPortal>\n <ModalContext.Provider value={modalContext}>\n {isMounted ? (\n <FloatingFocusManager\n returnFocus\n initialFocus={initialFocusRef ?? defaultInitialFocusRef}\n context={context}\n modal={true}\n >\n <TopNavOverlayThemeOverride>\n <Box zIndex={zIndex} position=\"fixed\" testID=\"modal-wrapper\">\n <ModalBackdrop />\n <ModalContent\n {...metaAttribute({\n name: MetaConstants.Modal,\n })}\n {...makeAccessible({\n role: 'dialog',\n modal: true,\n label: accessibilityLabel,\n })}\n {...makeAnalyticsAttribute(rest)}\n maxWidth={size === 'full' ? '100%' : makeSize(modalMaxWidth[size])}\n minWidth={makeSize(modalMinWidth)}\n maxHeight={modalMaxHeight[size]}\n width={\n size === 'full'\n ? `calc(100vw - ${makeSize(modalMargin[size] * 2)})`\n : `calc(100vw - ${makeSize(modalResponsiveScreenGap)})`\n }\n borderRadius={modalBorderRadius}\n backgroundColor=\"popup.background.gray.subtle\"\n display=\"flex\"\n flexDirection=\"column\"\n top=\"50%\"\n left=\"50%\"\n onKeyDown={handleKeyDown}\n isVisible={isVisible}\n size={size}\n ref={refs.setFloating}\n overflow=\"hidden\"\n >\n {children}\n </ModalContent>\n </Box>\n </TopNavOverlayThemeOverride>\n </FloatingFocusManager>\n ) : null}\n </ModalContext.Provider>\n </FloatingPortal>\n );\n};\n\nexport { Modal, ModalHeader, ModalFooter, ModalBody };\nexport type { ModalProps, ModalHeaderProps, ModalFooterProps, ModalBodyProps };\n"],"names":["ModalContent","styled","BaseBox","withConfig","displayName","componentId","_ref","isVisible","theme","size","scale","transform","concat","css","elevation","highRaised","castWebType","makeMotionTime","motion","duration","moderate","easing","entrance","exit","makeSize","modalMargin","Modal","_ref2","_ref2$isOpen","isOpen","children","onDismiss","_ref2$isDismissible","isDismissible","initialFocusRef","_ref2$size","accessibilityLabel","_ref2$zIndex","zIndex","componentZIndices","modal","rest","_objectWithoutProperties","_excluded","_useTheme","useTheme","platform","_usePresence","usePresence","transitionDuration","initialEnter","isMounted","useEffect","logger","message","moduleName","type","_useFloating","useFloating","open","refs","context","defaultInitialFocusRef","React","useRef","modalContext","useMemo","close","isInsideModal","handleKeyDown","event","key","code","_jsx","FloatingPortal","ModalContext","Provider","value","FloatingFocusManager","returnFocus","initialFocus","TopNavOverlayThemeOverride","_jsxs","Box","position","testID","ModalBackdrop","_objectSpread","metaAttribute","name","MetaConstants","makeAccessible","role","label","makeAnalyticsAttribute","maxWidth","modalMaxWidth","minWidth","modalMinWidth","maxHeight","modalMaxHeight","width","modalResponsiveScreenGap","borderRadius","modalBorderRadius","backgroundColor","display","flexDirection","top","left","onKeyDown","ref","setFloating","overflow"],"mappings":";;;;;;;;;;;;;;;;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|
11
11
|
isOpen: false,
|
|
12
|
-
isVisible: false
|
|
12
|
+
isVisible: false,
|
|
13
|
+
isInsideModal: false
|
|
13
14
|
});
|
|
14
15
|
var useModalContext = function useModalContext() {
|
|
15
16
|
var state = React__default.useContext(ModalContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalContext.js","sources":["../../../../../../src/components/Modal/ModalContext.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react';\n\ntype ModalContextProps = {\n /**\n * Indicates open state of Modal\n */\n isOpen: boolean;\n /**\n * Function to close the Modal\n */\n close?: () => void;\n /**\n * Whether the modal can be dismissed\n */\n isDismissible: boolean;\n /**\n * The element that will get focused when the Modal first opens\n */\n defaultInitialFocusRef: React.MutableRefObject<any>;\n /**\n * Indicates if the Modal is visible according to the usePresence hook\n */\n isVisible: boolean;\n};\n\nconst ModalContext = React.createContext<ModalContextProps>({\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n close: () => {},\n isDismissible: true,\n defaultInitialFocusRef: { current: null },\n isOpen: false,\n isVisible: false,\n});\n\nconst useModalContext = (): ModalContextProps => {\n const state = React.useContext(ModalContext);\n return state;\n};\n\nexport { ModalContext, useModalContext };\n"],"names":["ModalContext","React","createContext","close","isDismissible","defaultInitialFocusRef","current","isOpen","isVisible","useModalContext","state","useContext"],"mappings":";;AAAA;
|
|
1
|
+
{"version":3,"file":"ModalContext.js","sources":["../../../../../../src/components/Modal/ModalContext.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react';\n\ntype ModalContextProps = {\n /**\n * Indicates open state of Modal\n */\n isOpen: boolean;\n /**\n * Function to close the Modal\n */\n close?: () => void;\n /**\n * Whether the modal can be dismissed\n */\n isDismissible: boolean;\n /**\n * The element that will get focused when the Modal first opens\n */\n defaultInitialFocusRef: React.MutableRefObject<any>;\n /**\n * Indicates if the Modal is visible according to the usePresence hook\n */\n isVisible: boolean;\n /**\n * Indicates if the Modal is inside a Modal\n */\n isInsideModal: boolean;\n};\n\nconst ModalContext = React.createContext<ModalContextProps>({\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n close: () => {},\n isDismissible: true,\n defaultInitialFocusRef: { current: null },\n isOpen: false,\n isVisible: false,\n isInsideModal: false,\n});\n\nconst useModalContext = (): ModalContextProps => {\n const state = React.useContext(ModalContext);\n return state;\n};\n\nexport { ModalContext, useModalContext };\n"],"names":["ModalContext","React","createContext","close","isDismissible","defaultInitialFocusRef","current","isOpen","isVisible","isInsideModal","useModalContext","state","useContext"],"mappings":";;AAAA;AA8BA,IAAMA,YAAY,gBAAGC,cAAK,CAACC,aAAa,CAAoB;AAC1D;AACAC,EAAAA,KAAK,EAAE,SAAPA,KAAKA,GAAQ,EAAE;AACfC,EAAAA,aAAa,EAAE,IAAI;AACnBC,EAAAA,sBAAsB,EAAE;AAAEC,IAAAA,OAAO,EAAE,IAAA;GAAM;AACzCC,EAAAA,MAAM,EAAE,KAAK;AACbC,EAAAA,SAAS,EAAE,KAAK;AAChBC,EAAAA,aAAa,EAAE,KAAA;AACjB,CAAC,EAAC;AAEF,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,GAA4B;AAC/C,EAAA,IAAMC,KAAK,GAAGV,cAAK,CAACW,UAAU,CAACZ,YAAY,CAAC,CAAA;AAC5C,EAAA,OAAOW,KAAK,CAAA;AACd;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from '../../../../../_virtual/_commonjsHelpers.js';
|
|
2
|
-
import { __exports as cloneDeep$1 } from '../../../../../_virtual/
|
|
2
|
+
import { __exports as cloneDeep$1 } from '../../../../../_virtual/cloneDeep2.js';
|
|
3
3
|
import '../../../../../_virtual/cloneDeepWith.js';
|
|
4
4
|
import { __exports as cloneDeepWith } from '../../../../../_virtual/cloneDeepWith2.js';
|
|
5
5
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from '../../../../../_virtual/_commonjsHelpers.js';
|
|
2
2
|
import { __exports as matches$1 } from '../../../../../_virtual/matches2.js';
|
|
3
3
|
import '../../../../../_virtual/isMatch.js';
|
|
4
|
-
import '../../../../../_virtual/
|
|
4
|
+
import '../../../../../_virtual/cloneDeep3.js';
|
|
5
5
|
import { __exports as isMatch } from '../../../../../_virtual/isMatch2.js';
|
|
6
|
-
import { __exports as cloneDeep } from '../../../../../_virtual/
|
|
6
|
+
import { __exports as cloneDeep } from '../../../../../_virtual/cloneDeep4.js';
|
|
7
7
|
|
|
8
8
|
(function (exports) {
|
|
9
9
|
'use strict';
|
package/build/lib/web/production/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.js
CHANGED
|
@@ -2,12 +2,12 @@ import { getDefaultExportFromCjs } from '../../../../../_virtual/_commonjsHelper
|
|
|
2
2
|
import { __exports as matchesProperty$1 } from '../../../../../_virtual/matchesProperty2.js';
|
|
3
3
|
import '../../../../../_virtual/isMatch.js';
|
|
4
4
|
import '../../../../../_virtual/toKey.js';
|
|
5
|
-
import '../../../../../_virtual/
|
|
5
|
+
import '../../../../../_virtual/cloneDeep.js';
|
|
6
6
|
import '../../../../../_virtual/get.js';
|
|
7
7
|
import '../../../../../_virtual/has.js';
|
|
8
8
|
import { __exports as isMatch } from '../../../../../_virtual/isMatch2.js';
|
|
9
9
|
import { __exports as toKey } from '../../../../../_virtual/toKey2.js';
|
|
10
|
-
import { __exports as cloneDeep } from '../../../../../_virtual/
|
|
10
|
+
import { __exports as cloneDeep } from '../../../../../_virtual/cloneDeep2.js';
|
|
11
11
|
import { __exports as get } from '../../../../../_virtual/get2.js';
|
|
12
12
|
import { __exports as has } from '../../../../../_virtual/has2.js';
|
|
13
13
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from '../../../../_virtual/_commonjsHelpers.js';
|
|
2
|
-
import { __exports as cloneDeep$1 } from '../../../../_virtual/
|
|
2
|
+
import { __exports as cloneDeep$1 } from '../../../../_virtual/cloneDeep4.js';
|
|
3
3
|
import '../../../../_virtual/cloneDeepWith3.js';
|
|
4
4
|
import { __exports as cloneDeepWith } from '../../../../_virtual/cloneDeepWith4.js';
|
|
5
5
|
|