@razorpay/blade 11.18.1 → 11.18.3

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.
@@ -38,7 +38,7 @@ var _excluded=["defaultChecked","validationState","isChecked","isDisabled","isIn
38
38
  <Checkbox value="apple">Apple</Checkbox>
39
39
  <Checkbox value="mango">Mango</Checkbox>
40
40
  </CheckboxGroup>
41
- `);}}var _validationState=validationState!=null?validationState:groupProps==null?void 0:groupProps.validationState;var _hasError=_validationState==='error';var _isDisabled=isDisabled!=null?isDisabled:groupProps==null?void 0:groupProps.isDisabled;var _isRequired=Boolean(isRequired||(groupProps==null?void 0:groupProps.isRequired)||(groupProps==null?void 0:groupProps.necessityIndicator)==='required');var _name=name!=null?name:groupProps==null?void 0:groupProps.name;var _isChecked=isChecked!=null?isChecked:groupProps==null?void 0:(_groupProps$state=groupProps.state)==null?void 0:_groupProps$state.isChecked(value);var _size=(_groupProps$size=groupProps.size)!=null?_groupProps$size:size;var _useTheme=useTheme(),theme=_useTheme.theme;var formHintSize={small:'medium',medium:'medium',large:'large'};var showSupportingText=validationState!=='error'&&helpText;var handleChange=function handleChange(_ref2){var isChecked=_ref2.isChecked,event=_ref2.event,value=_ref2.value;if(isChecked){var _groupProps$state2;groupProps==null?void 0:(_groupProps$state2=groupProps.state)==null?void 0:_groupProps$state2.addValue(value);}else {var _groupProps$state3;groupProps==null?void 0:(_groupProps$state3=groupProps.state)==null?void 0:_groupProps$state3.removeValue(value);}onChange==null?void 0:onChange({isChecked:isChecked,event:event,value:value});};var _useCheckbox=useCheckbox({defaultChecked:defaultChecked,isChecked:_isChecked,isIndeterminate:isIndeterminate,hasError:_hasError,hasHelperText:Boolean(showSupportingText),isDisabled:_isDisabled,isRequired:_isRequired,name:_name,value:value,onChange:handleChange}),state=_useCheckbox.state,ids=_useCheckbox.ids,inputProps=_useCheckbox.inputProps;var helpTextLeftSpacing=makeSize(checkboxSizes.icon[size].width+theme.spacing[3]);return jsxs(BaseBox,Object.assign({},metaAttribute({name:MetaConstants.Checkbox,testID:testID}),getStyledProps(styledProps),{children:[jsx(SelectorLabel,{componentName:MetaConstants.CheckboxLabel,inputProps:state.isReactNative?inputProps:{},children:jsxs(BaseBox,{display:"flex",flexDirection:"column",children:[jsxs(BaseBox,{display:"flex",flexDirection:"row",children:[jsx(SelectorInput,{hoverTokens:checkboxHoverTokens,isChecked:state.isChecked||Boolean(isIndeterminate),isDisabled:_isDisabled,hasError:_hasError,inputProps:inputProps,tabIndex:tabIndex,ref:ref}),jsx(CheckboxIcon,{size:_size,isChecked:state.isChecked,isIndeterminate:isIndeterminate,isDisabled:_isDisabled,isNegative:_hasError}),children?jsx(SelectorTitle,{size:_size,isDisabled:_isDisabled,children:children}):null]}),showSupportingText?jsx(BaseBox,{marginLeft:helpTextLeftSpacing,children:jsx(SelectorSupportText,{size:_size,id:ids==null?void 0:ids.helpTextId,children:helpText})}):null]})}),jsx(FormHint,{size:formHintSize[_size],errorText:errorText,errorTextId:ids==null?void 0:ids.errorTextId,type:validationState==='error'?'error':'help'})]}));};var Checkbox=assignWithoutSideEffects(React__default.forwardRef(_Checkbox),{displayName:'Checkbox'});
41
+ `);}}var _validationState=validationState!=null?validationState:groupProps==null?void 0:groupProps.validationState;var _hasError=_validationState==='error';var _isDisabled=isDisabled!=null?isDisabled:groupProps==null?void 0:groupProps.isDisabled;var _isRequired=Boolean(isRequired||(groupProps==null?void 0:groupProps.isRequired)||(groupProps==null?void 0:groupProps.necessityIndicator)==='required');var _name=name!=null?name:groupProps==null?void 0:groupProps.name;var _isChecked=isChecked!=null?isChecked:groupProps==null?void 0:(_groupProps$state=groupProps.state)==null?void 0:_groupProps$state.isChecked(value);var _size=(_groupProps$size=groupProps.size)!=null?_groupProps$size:size;var _useTheme=useTheme(),theme=_useTheme.theme;var formHintSize={small:'medium',medium:'medium',large:'large'};var showSupportingText=helpText;var handleChange=function handleChange(_ref2){var isChecked=_ref2.isChecked,event=_ref2.event,value=_ref2.value;if(isChecked){var _groupProps$state2;groupProps==null?void 0:(_groupProps$state2=groupProps.state)==null?void 0:_groupProps$state2.addValue(value);}else {var _groupProps$state3;groupProps==null?void 0:(_groupProps$state3=groupProps.state)==null?void 0:_groupProps$state3.removeValue(value);}onChange==null?void 0:onChange({isChecked:isChecked,event:event,value:value});};var _useCheckbox=useCheckbox({defaultChecked:defaultChecked,isChecked:_isChecked,isIndeterminate:isIndeterminate,hasError:_hasError,hasHelperText:Boolean(showSupportingText),isDisabled:_isDisabled,isRequired:_isRequired,name:_name,value:value,onChange:handleChange}),state=_useCheckbox.state,ids=_useCheckbox.ids,inputProps=_useCheckbox.inputProps;var helpTextLeftSpacing=makeSize(checkboxSizes.icon[size].width+theme.spacing[3]);return jsxs(BaseBox,Object.assign({},metaAttribute({name:MetaConstants.Checkbox,testID:testID}),getStyledProps(styledProps),{children:[jsx(SelectorLabel,{componentName:MetaConstants.CheckboxLabel,inputProps:state.isReactNative?inputProps:{},children:jsxs(BaseBox,{display:"flex",flexDirection:"column",children:[jsxs(BaseBox,{display:"flex",flexDirection:"row",children:[jsx(SelectorInput,{hoverTokens:checkboxHoverTokens,isChecked:state.isChecked||Boolean(isIndeterminate),isDisabled:_isDisabled,hasError:_hasError,inputProps:inputProps,tabIndex:tabIndex,ref:ref}),jsx(CheckboxIcon,{size:_size,isChecked:state.isChecked,isIndeterminate:isIndeterminate,isDisabled:_isDisabled,isNegative:_hasError}),children?jsx(SelectorTitle,{size:_size,isDisabled:_isDisabled,children:children}):null]}),showSupportingText?jsx(BaseBox,{marginLeft:helpTextLeftSpacing,children:jsx(SelectorSupportText,{size:_size,id:ids==null?void 0:ids.helpTextId,children:helpText})}):null]})}),jsx(FormHint,{size:formHintSize[_size],errorText:errorText,errorTextId:ids==null?void 0:ids.errorTextId,type:validationState==='error'?'error':'help'})]}));};var Checkbox=assignWithoutSideEffects(React__default.forwardRef(_Checkbox),{displayName:'Checkbox'});
42
42
 
43
43
  export { Checkbox };
44
44
  //# sourceMappingURL=Checkbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","sources":["../../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport { useCheckboxGroupContext } from './CheckboxGroup/CheckboxGroupContext';\nimport { CheckboxIcon } from './CheckboxIcon';\nimport { useCheckbox } from './useCheckbox';\nimport { checkboxHoverTokens, checkboxSizes } from './checkboxTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport isUndefined from '~utils/lodashButBetter/isUndefined';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport BaseBox from '~components/Box/BaseBox';\nimport { FormHint } from '~components/Form';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport type { BladeElementRef, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { throwBladeError } from '~utils/logger';\nimport { makeSize, useTheme } from '~utils';\n\ntype OnChange = ({\n isChecked,\n event,\n value,\n}: {\n isChecked: boolean;\n event?: React.ChangeEvent;\n value?: string;\n}) => void;\n\ntype CheckboxProps = {\n /**\n * If `true`, The checkbox will be checked. This also makes the checkbox controlled\n * Use `onChange` to update its value\n *\n * @default false\n */\n isChecked?: boolean;\n /**\n * If `true`, the checkbox will be initially checked. This also makes the checkbox uncontrolled\n *\n * @default false\n */\n defaultChecked?: boolean;\n /**\n * The callback invoked when the checked state of the `Checkbox` changes.\n */\n onChange?: OnChange;\n /**\n * Sets the label of the checkbox\n */\n children?: React.ReactNode;\n /**\n * Help text for the checkbox\n */\n helpText?: string;\n /**\n * Error text for the checkbox\n *\n * Renders when `validationState` is set to 'error'\n */\n errorText?: string;\n /**\n * If `true`, the checkbox will be indeterminate.\n * This does not modify the isChecked property.\n *\n * @default false\n */\n isIndeterminate?: boolean;\n /**\n * The name of the input field in a checkbox\n * (Useful for form submission).\n */\n name?: string;\n /**\n * The value to be used in the checkbox input.\n * This is the value that will be returned on form submission.\n */\n value?: string;\n /**\n * If `true`, the checkbox will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * If `true`, the checkbox input is marked as required,\n * and `required` attribute will be added\n *\n * @default false\n */\n isRequired?: boolean;\n /**\n * If `error`, the checkbox input is marked as invalid,\n * and `invalid` attribute will be added\n */\n validationState?: 'error' | 'none';\n /**\n * Size of the checkbox\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n /**\n * Sets the tab-index property on checkbox element\n *\n */\n tabIndex?: number;\n} & TestID &\n StyledPropsBlade;\n\nconst _Checkbox: React.ForwardRefRenderFunction<BladeElementRef, CheckboxProps> = (\n {\n defaultChecked,\n validationState,\n isChecked,\n isDisabled,\n isIndeterminate,\n isRequired,\n name,\n onChange,\n value,\n children,\n helpText,\n errorText,\n size = 'medium',\n tabIndex,\n testID,\n ...styledProps\n },\n ref,\n) => {\n const groupProps = useCheckboxGroupContext();\n\n // ban certain props in checkbox while inside group\n const hasValidationState = !isUndefined(validationState);\n const hasName = !isUndefined(name);\n const hasDefaultChecked = !isUndefined(defaultChecked);\n const hasIsChecked = !isUndefined(isChecked);\n const hasOnChange = !isUndefined(onChange);\n\n if (__DEV__) {\n if (\n (hasValidationState || hasName || hasDefaultChecked || hasIsChecked || hasOnChange) &&\n !isEmpty(groupProps)\n ) {\n const props = [\n hasValidationState ? 'validationState' : undefined,\n hasName ? 'name' : undefined,\n hasDefaultChecked ? 'defaultChecked' : undefined,\n hasIsChecked ? 'isChecked' : undefined,\n hasOnChange ? 'onChange' : undefined,\n ]\n .filter(Boolean)\n .join(',');\n\n throwBladeError({\n message: `Cannot set \\`${props}\\` on <Checkbox /> when it's inside <CheckboxGroup />, Please set it on the <CheckboxGroup /> itself`,\n moduleName: 'Checkbox',\n });\n }\n\n // mandate value prop when using inside group\n if (!value && !isEmpty(groupProps)) {\n throw new Error(\n `[Blade Checkbox]: <CheckboxGroup /> requires that you pass unique \"value\" prop to each <Checkbox />\n <CheckboxGroup>\n <Checkbox value=\"apple\">Apple</Checkbox>\n <Checkbox value=\"mango\">Mango</Checkbox>\n </CheckboxGroup>\n `,\n );\n }\n }\n\n const _validationState = validationState ?? groupProps?.validationState;\n const _hasError = _validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = Boolean(\n isRequired || groupProps?.isRequired || groupProps?.necessityIndicator === 'required',\n );\n const _name = name ?? groupProps?.name;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const _isChecked = isChecked ?? groupProps?.state?.isChecked(value!);\n const _size = groupProps.size ?? size;\n const { theme } = useTheme();\n const formHintSize = {\n small: 'medium',\n medium: 'medium',\n large: 'large',\n } as const;\n\n // only show error when the self validation is set to error\n // Since we don't want to show errorText inside the group\n const showSupportingText = validationState !== 'error' && helpText;\n\n const handleChange: OnChange = ({ isChecked, event, value }) => {\n if (isChecked) {\n groupProps?.state?.addValue(value!);\n } else {\n groupProps?.state?.removeValue(value!);\n }\n\n onChange?.({ isChecked, event, value });\n };\n\n const { state, ids, inputProps } = useCheckbox({\n defaultChecked,\n isChecked: _isChecked,\n isIndeterminate,\n hasError: _hasError,\n hasHelperText: Boolean(showSupportingText),\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name: _name,\n value,\n onChange: handleChange,\n });\n\n // Checkbox icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(checkboxSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox\n {...metaAttribute({ name: MetaConstants.Checkbox, testID })}\n {...getStyledProps(styledProps)}\n >\n <SelectorLabel\n componentName={MetaConstants.CheckboxLabel}\n inputProps={state.isReactNative ? inputProps : {}}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={checkboxHoverTokens}\n isChecked={state.isChecked || Boolean(isIndeterminate)}\n isDisabled={_isDisabled}\n hasError={_hasError}\n inputProps={inputProps}\n tabIndex={tabIndex}\n ref={ref}\n />\n <CheckboxIcon\n size={_size}\n isChecked={state.isChecked}\n isIndeterminate={isIndeterminate}\n isDisabled={_isDisabled}\n isNegative={_hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showSupportingText ? (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n ) : null}\n </BaseBox>\n </SelectorLabel>\n <FormHint\n size={formHintSize[_size]}\n errorText={errorText}\n errorTextId={ids?.errorTextId}\n type={validationState === 'error' ? 'error' : 'help'}\n />\n </BaseBox>\n );\n};\n\nconst Checkbox = assignWithoutSideEffects(React.forwardRef(_Checkbox), {\n displayName: 'Checkbox',\n});\n\nexport type { CheckboxProps };\nexport { Checkbox };\n"],"names":["_Checkbox","_ref","ref","_groupProps$state","_groupProps$size","defaultChecked","validationState","isChecked","isDisabled","isIndeterminate","isRequired","name","onChange","value","children","helpText","errorText","_ref$size","size","tabIndex","testID","styledProps","_objectWithoutProperties","_excluded","groupProps","useCheckboxGroupContext","hasValidationState","isUndefined","hasName","hasDefaultChecked","hasIsChecked","hasOnChange","__DEV__","isEmpty","props","undefined","filter","Boolean","join","throwBladeError","message","moduleName","Error","_validationState","_hasError","_isDisabled","_isRequired","necessityIndicator","_name","_isChecked","state","_size","_useTheme","useTheme","theme","formHintSize","small","medium","large","showSupportingText","handleChange","_ref2","event","_groupProps$state2","addValue","_groupProps$state3","removeValue","_useCheckbox","useCheckbox","hasError","hasHelperText","ids","inputProps","helpTextLeftSpacing","makeSize","checkboxSizes","icon","width","spacing","_jsxs","BaseBox","Object","assign","metaAttribute","MetaConstants","Checkbox","getStyledProps","_jsx","SelectorLabel","componentName","CheckboxLabel","isReactNative","display","flexDirection","SelectorInput","hoverTokens","checkboxHoverTokens","CheckboxIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","FormHint","errorTextId","type","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAA,SAAA,CAAA,CAAA,gBAAA,CAAA,iBAAA,CAAA,WAAA,CAAA,YAAA,CAAA,iBAAA,CAAA,YAAA,CAAA,MAAA,CAAA,UAAA,CAAA,OAAA,CAAA,UAAA,CAAA,UAAA,CAAA,WAAA,CAAA,MAAA,CAAA,UAAA,CAAA,QAAA,CAAA,CAgHA,IAAMA,SAAyE,CAAG,SAA5EA,SAAyEA,CAAAC,IAAA,CAmB7EC,GAAG,CACA,CAAAC,IAAAA,iBAAA,CAAAC,gBAAA,KAlBDC,cAAc,CAAAJ,IAAA,CAAdI,cAAc,CACdC,eAAe,CAAAL,IAAA,CAAfK,eAAe,CACfC,SAAS,CAAAN,IAAA,CAATM,SAAS,CACTC,UAAU,CAAAP,IAAA,CAAVO,UAAU,CACVC,eAAe,CAAAR,IAAA,CAAfQ,eAAe,CACfC,UAAU,CAAAT,IAAA,CAAVS,UAAU,CACVC,IAAI,CAAAV,IAAA,CAAJU,IAAI,CACJC,QAAQ,CAAAX,IAAA,CAARW,QAAQ,CACRC,KAAK,CAAAZ,IAAA,CAALY,KAAK,CACLC,QAAQ,CAAAb,IAAA,CAARa,QAAQ,CACRC,QAAQ,CAAAd,IAAA,CAARc,QAAQ,CACRC,SAAS,CAAAf,IAAA,CAATe,SAAS,CAAAC,SAAA,CAAAhB,IAAA,CACTiB,IAAI,CAAJA,IAAI,CAAAD,SAAA,GAAG,KAAA,CAAA,CAAA,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SAAU,CACvB,CAAC,CACD9B,QAAQ,CACPyE,GAAA,CAACY,aAAa,CAAA,CAACjF,IAAI,CAAEiC,KAAM,CAAC3C,UAAU,CAAEqC,WAAY,CAAA/B,QAAA,CACjDA,QAAQ,CACI,CAAC,CACd,IAAI,CAAA,CACD,CAAC,CACT6C,kBAAkB,CACjB4B,GAAA,CAACP,OAAO,CAAA,CAACoB,UAAU,CAAE3B,mBAAoB,CAAA3D,QAAA,CACvCyE,GAAA,CAACc,mBAAmB,CAAA,CAACnF,IAAI,CAAEiC,KAAM,CAACmD,EAAE,CAAE/B,GAAG,cAAHA,GAAG,CAAEgC,UAAW,CAAAzF,QAAA,CACnDC,QAAQ,CACU,CAAC,CACf,CAAC,CACR,IAAI,EACD,CAAC,CACG,CAAC,CAChBwE,GAAA,CAACiB,QAAQ,CACPtF,CAAAA,IAAI,CAAEqC,YAAY,CAACJ,KAAK,CAAE,CAC1BnC,SAAS,CAAEA,SAAU,CACrByF,WAAW,CAAElC,GAAG,EAAHA,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,GAAG,CAAEkC,WAAY,CAC9BC,IAAI,CAAEpG,eAAe,GAAK,OAAO,CAAG,OAAO,CAAG,MAAO,CACtD,CAAC,GACK,CAAC,CAEd,CAAC,CAEK,IAAA+E,QAAQ,CAAGsB,wBAAwB,CAACC,cAAK,CAACC,UAAU,CAAC7G,SAAS,CAAC,CAAE,CACrE8G,WAAW,CAAE,UACf,CAAC;;;;"}
1
+ {"version":3,"file":"Checkbox.js","sources":["../../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport { useCheckboxGroupContext } from './CheckboxGroup/CheckboxGroupContext';\nimport { CheckboxIcon } from './CheckboxIcon';\nimport { useCheckbox } from './useCheckbox';\nimport { checkboxHoverTokens, checkboxSizes } from './checkboxTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport isUndefined from '~utils/lodashButBetter/isUndefined';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport BaseBox from '~components/Box/BaseBox';\nimport { FormHint } from '~components/Form';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport type { BladeElementRef, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { throwBladeError } from '~utils/logger';\nimport { makeSize, useTheme } from '~utils';\n\ntype OnChange = ({\n isChecked,\n event,\n value,\n}: {\n isChecked: boolean;\n event?: React.ChangeEvent;\n value?: string;\n}) => void;\n\ntype CheckboxProps = {\n /**\n * If `true`, The checkbox will be checked. This also makes the checkbox controlled\n * Use `onChange` to update its value\n *\n * @default false\n */\n isChecked?: boolean;\n /**\n * If `true`, the checkbox will be initially checked. This also makes the checkbox uncontrolled\n *\n * @default false\n */\n defaultChecked?: boolean;\n /**\n * The callback invoked when the checked state of the `Checkbox` changes.\n */\n onChange?: OnChange;\n /**\n * Sets the label of the checkbox\n */\n children?: React.ReactNode;\n /**\n * Help text for the checkbox\n */\n helpText?: string;\n /**\n * Error text for the checkbox\n *\n * Renders when `validationState` is set to 'error'\n */\n errorText?: string;\n /**\n * If `true`, the checkbox will be indeterminate.\n * This does not modify the isChecked property.\n *\n * @default false\n */\n isIndeterminate?: boolean;\n /**\n * The name of the input field in a checkbox\n * (Useful for form submission).\n */\n name?: string;\n /**\n * The value to be used in the checkbox input.\n * This is the value that will be returned on form submission.\n */\n value?: string;\n /**\n * If `true`, the checkbox will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * If `true`, the checkbox input is marked as required,\n * and `required` attribute will be added\n *\n * @default false\n */\n isRequired?: boolean;\n /**\n * If `error`, the checkbox input is marked as invalid,\n * and `invalid` attribute will be added\n */\n validationState?: 'error' | 'none';\n /**\n * Size of the checkbox\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n /**\n * Sets the tab-index property on checkbox element\n *\n */\n tabIndex?: number;\n} & TestID &\n StyledPropsBlade;\n\nconst _Checkbox: React.ForwardRefRenderFunction<BladeElementRef, CheckboxProps> = (\n {\n defaultChecked,\n validationState,\n isChecked,\n isDisabled,\n isIndeterminate,\n isRequired,\n name,\n onChange,\n value,\n children,\n helpText,\n errorText,\n size = 'medium',\n tabIndex,\n testID,\n ...styledProps\n },\n ref,\n) => {\n const groupProps = useCheckboxGroupContext();\n\n // ban certain props in checkbox while inside group\n const hasValidationState = !isUndefined(validationState);\n const hasName = !isUndefined(name);\n const hasDefaultChecked = !isUndefined(defaultChecked);\n const hasIsChecked = !isUndefined(isChecked);\n const hasOnChange = !isUndefined(onChange);\n\n if (__DEV__) {\n if (\n (hasValidationState || hasName || hasDefaultChecked || hasIsChecked || hasOnChange) &&\n !isEmpty(groupProps)\n ) {\n const props = [\n hasValidationState ? 'validationState' : undefined,\n hasName ? 'name' : undefined,\n hasDefaultChecked ? 'defaultChecked' : undefined,\n hasIsChecked ? 'isChecked' : undefined,\n hasOnChange ? 'onChange' : undefined,\n ]\n .filter(Boolean)\n .join(',');\n\n throwBladeError({\n message: `Cannot set \\`${props}\\` on <Checkbox /> when it's inside <CheckboxGroup />, Please set it on the <CheckboxGroup /> itself`,\n moduleName: 'Checkbox',\n });\n }\n\n // mandate value prop when using inside group\n if (!value && !isEmpty(groupProps)) {\n throw new Error(\n `[Blade Checkbox]: <CheckboxGroup /> requires that you pass unique \"value\" prop to each <Checkbox />\n <CheckboxGroup>\n <Checkbox value=\"apple\">Apple</Checkbox>\n <Checkbox value=\"mango\">Mango</Checkbox>\n </CheckboxGroup>\n `,\n );\n }\n }\n\n const _validationState = validationState ?? groupProps?.validationState;\n const _hasError = _validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = Boolean(\n isRequired || groupProps?.isRequired || groupProps?.necessityIndicator === 'required',\n );\n const _name = name ?? groupProps?.name;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const _isChecked = isChecked ?? groupProps?.state?.isChecked(value!);\n const _size = groupProps.size ?? size;\n const { theme } = useTheme();\n const formHintSize = {\n small: 'medium',\n medium: 'medium',\n large: 'large',\n } as const;\n\n const showSupportingText = helpText;\n\n const handleChange: OnChange = ({ isChecked, event, value }) => {\n if (isChecked) {\n groupProps?.state?.addValue(value!);\n } else {\n groupProps?.state?.removeValue(value!);\n }\n\n onChange?.({ isChecked, event, value });\n };\n\n const { state, ids, inputProps } = useCheckbox({\n defaultChecked,\n isChecked: _isChecked,\n isIndeterminate,\n hasError: _hasError,\n hasHelperText: Boolean(showSupportingText),\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name: _name,\n value,\n onChange: handleChange,\n });\n\n // Checkbox icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(checkboxSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox\n {...metaAttribute({ name: MetaConstants.Checkbox, testID })}\n {...getStyledProps(styledProps)}\n >\n <SelectorLabel\n componentName={MetaConstants.CheckboxLabel}\n inputProps={state.isReactNative ? inputProps : {}}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={checkboxHoverTokens}\n isChecked={state.isChecked || Boolean(isIndeterminate)}\n isDisabled={_isDisabled}\n hasError={_hasError}\n inputProps={inputProps}\n tabIndex={tabIndex}\n ref={ref}\n />\n <CheckboxIcon\n size={_size}\n isChecked={state.isChecked}\n isIndeterminate={isIndeterminate}\n isDisabled={_isDisabled}\n isNegative={_hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showSupportingText ? (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n ) : null}\n </BaseBox>\n </SelectorLabel>\n <FormHint\n size={formHintSize[_size]}\n errorText={errorText}\n errorTextId={ids?.errorTextId}\n type={validationState === 'error' ? 'error' : 'help'}\n />\n </BaseBox>\n );\n};\n\nconst Checkbox = assignWithoutSideEffects(React.forwardRef(_Checkbox), {\n displayName: 'Checkbox',\n});\n\nexport type { CheckboxProps };\nexport { Checkbox };\n"],"names":["_Checkbox","_ref","ref","_groupProps$state","_groupProps$size","defaultChecked","validationState","isChecked","isDisabled","isIndeterminate","isRequired","name","onChange","value","children","helpText","errorText","_ref$size","size","tabIndex","testID","styledProps","_objectWithoutProperties","_excluded","groupProps","useCheckboxGroupContext","hasValidationState","isUndefined","hasName","hasDefaultChecked","hasIsChecked","hasOnChange","__DEV__","isEmpty","props","undefined","filter","Boolean","join","throwBladeError","message","moduleName","Error","_validationState","_hasError","_isDisabled","_isRequired","necessityIndicator","_name","_isChecked","state","_size","_useTheme","useTheme","theme","formHintSize","small","medium","large","showSupportingText","handleChange","_ref2","event","_groupProps$state2","addValue","_groupProps$state3","removeValue","_useCheckbox","useCheckbox","hasError","hasHelperText","ids","inputProps","helpTextLeftSpacing","makeSize","checkboxSizes","icon","width","spacing","_jsxs","BaseBox","Object","assign","metaAttribute","MetaConstants","Checkbox","getStyledProps","_jsx","SelectorLabel","componentName","CheckboxLabel","isReactNative","display","flexDirection","SelectorInput","hoverTokens","checkboxHoverTokens","CheckboxIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","FormHint","errorTextId","type","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAA,SAAA,CAAA,CAAA,gBAAA,CAAA,iBAAA,CAAA,WAAA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AAQ,CACU,CAAC,CACf,CAAC,CACR,IAAI,EACD,CAAC,CACG,CAAC,CAChBwE,GAAA,CAACiB,QAAQ,CACPtF,CAAAA,IAAI,CAAEqC,YAAY,CAACJ,KAAK,CAAE,CAC1BnC,SAAS,CAAEA,SAAU,CACrByF,WAAW,CAAElC,GAAG,EAAHA,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,GAAG,CAAEkC,WAAY,CAC9BC,IAAI,CAAEpG,eAAe,GAAK,OAAO,CAAG,OAAO,CAAG,MAAO,CACtD,CAAC,GACK,CAAC,CAEd,CAAC,CAEK,IAAA+E,QAAQ,CAAGsB,wBAAwB,CAACC,cAAK,CAACC,UAAU,CAAC7G,SAAS,CAAC,CAAE,CACrE8G,WAAW,CAAE,UACf,CAAC;;;;"}
@@ -24,7 +24,7 @@ import '@babel/runtime/helpers/defineProperty';
24
24
  import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
25
25
  import { jsx, jsxs } from 'react/jsx-runtime';
26
26
 
27
- var _excluded=["value","children","helpText","isDisabled","size","testID"];var _Radio=function _Radio(_ref,ref){var _groupProps$state,_groupProps$size;var value=_ref.value,children=_ref.children,helpText=_ref.helpText,isDisabled=_ref.isDisabled,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,testID=_ref.testID,styledProps=_objectWithoutProperties(_ref,_excluded);var _useTheme=useTheme(),theme=_useTheme.theme;var groupProps=useRadioGroupContext();var isInsideGroup=!isEmpty(groupProps);if(__DEV__){if(!isInsideGroup){throwBladeError({moduleName:'Radio',message:'Cannot use <Radio /> outside of <RadioGroup />'});}}var isChecked=groupProps==null?void 0:(_groupProps$state=groupProps.state)==null?void 0:_groupProps$state.isChecked(value);var defaultChecked=(groupProps==null?void 0:groupProps.defaultValue)===undefined?undefined:(groupProps==null?void 0:groupProps.defaultValue)===value;var validationState=groupProps==null?void 0:groupProps.validationState;var hasError=validationState==='error';var _isDisabled=isDisabled!=null?isDisabled:groupProps==null?void 0:groupProps.isDisabled;var _isRequired=(groupProps==null?void 0:groupProps.isRequired)||(groupProps==null?void 0:groupProps.necessityIndicator)==='required';var name=groupProps==null?void 0:groupProps.name;var showHelpText=!hasError&&helpText;var isReactNative=getPlatformType()==='react-native';var _size=(_groupProps$size=groupProps.size)!=null?_groupProps$size:size;var handleChange=function handleChange(_ref2){var isChecked=_ref2.isChecked,value=_ref2.value;if(isChecked){var _groupProps$state2;groupProps==null?void 0:(_groupProps$state2=groupProps.state)==null?void 0:_groupProps$state2.setValue(value);}else {var _groupProps$state3;groupProps==null?void 0:(_groupProps$state3=groupProps.state)==null?void 0:_groupProps$state3.removeValue();}};var _useRadio=useRadio({defaultChecked:defaultChecked,isChecked:isChecked,hasError:hasError,isDisabled:_isDisabled,isRequired:_isRequired,name:name,value:value,onChange:handleChange}),state=_useRadio.state,ids=_useRadio.ids,inputProps=_useRadio.inputProps;var helpTextLeftSpacing=makeSize(radioSizes.icon[size].width+theme.spacing[3]);return jsx(BaseBox,Object.assign({},getStyledProps(styledProps),{children:jsx(SelectorLabel,{componentName:MetaConstants.RadioLabel,inputProps:isReactNative?inputProps:{},testID:testID,children:jsxs(BaseBox,{display:"flex",flexDirection:"column",children:[jsxs(BaseBox,{display:"flex",alignItems:"center",flexDirection:"row",children:[jsx(SelectorInput,{hoverTokens:radioHoverTokens,isChecked:state.isChecked,isDisabled:_isDisabled,hasError:hasError,inputProps:inputProps,ref:ref}),jsx(RadioIcon,{size:_size,isChecked:state.isChecked,isDisabled:_isDisabled,isNegative:hasError}),children?jsx(SelectorTitle,{size:_size,isDisabled:_isDisabled,children:children}):null]}),showHelpText&&jsx(BaseBox,{marginLeft:helpTextLeftSpacing,children:jsx(SelectorSupportText,{size:_size,isNegative:true,id:ids==null?void 0:ids.helpTextId,children:helpText})})]})})}));};var Radio=assignWithoutSideEffects(React__default.forwardRef(_Radio),{displayName:'Radio'});
27
+ var _excluded=["value","children","helpText","isDisabled","size","testID"];var _Radio=function _Radio(_ref,ref){var _groupProps$state,_groupProps$size;var value=_ref.value,children=_ref.children,helpText=_ref.helpText,isDisabled=_ref.isDisabled,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,testID=_ref.testID,styledProps=_objectWithoutProperties(_ref,_excluded);var _useTheme=useTheme(),theme=_useTheme.theme;var groupProps=useRadioGroupContext();var isInsideGroup=!isEmpty(groupProps);if(__DEV__){if(!isInsideGroup){throwBladeError({moduleName:'Radio',message:'Cannot use <Radio /> outside of <RadioGroup />'});}}var isChecked=groupProps==null?void 0:(_groupProps$state=groupProps.state)==null?void 0:_groupProps$state.isChecked(value);var defaultChecked=(groupProps==null?void 0:groupProps.defaultValue)===undefined?undefined:(groupProps==null?void 0:groupProps.defaultValue)===value;var validationState=groupProps==null?void 0:groupProps.validationState;var hasError=validationState==='error';var _isDisabled=isDisabled!=null?isDisabled:groupProps==null?void 0:groupProps.isDisabled;var _isRequired=(groupProps==null?void 0:groupProps.isRequired)||(groupProps==null?void 0:groupProps.necessityIndicator)==='required';var name=groupProps==null?void 0:groupProps.name;var showHelpText=helpText;var isReactNative=getPlatformType()==='react-native';var _size=(_groupProps$size=groupProps.size)!=null?_groupProps$size:size;var handleChange=function handleChange(_ref2){var isChecked=_ref2.isChecked,value=_ref2.value;if(isChecked){var _groupProps$state2;groupProps==null?void 0:(_groupProps$state2=groupProps.state)==null?void 0:_groupProps$state2.setValue(value);}else {var _groupProps$state3;groupProps==null?void 0:(_groupProps$state3=groupProps.state)==null?void 0:_groupProps$state3.removeValue();}};var _useRadio=useRadio({defaultChecked:defaultChecked,isChecked:isChecked,hasError:hasError,isDisabled:_isDisabled,isRequired:_isRequired,name:name,value:value,onChange:handleChange}),state=_useRadio.state,ids=_useRadio.ids,inputProps=_useRadio.inputProps;var helpTextLeftSpacing=makeSize(radioSizes.icon[size].width+theme.spacing[3]);return jsx(BaseBox,Object.assign({},getStyledProps(styledProps),{children:jsx(SelectorLabel,{componentName:MetaConstants.RadioLabel,inputProps:isReactNative?inputProps:{},testID:testID,children:jsxs(BaseBox,{display:"flex",flexDirection:"column",children:[jsxs(BaseBox,{display:"flex",alignItems:"center",flexDirection:"row",children:[jsx(SelectorInput,{hoverTokens:radioHoverTokens,isChecked:state.isChecked,isDisabled:_isDisabled,hasError:hasError,inputProps:inputProps,ref:ref}),jsx(RadioIcon,{size:_size,isChecked:state.isChecked,isDisabled:_isDisabled,isNegative:hasError}),children?jsx(SelectorTitle,{size:_size,isDisabled:_isDisabled,children:children}):null]}),showHelpText&&jsx(BaseBox,{marginLeft:helpTextLeftSpacing,children:jsx(SelectorSupportText,{size:_size,id:ids==null?void 0:ids.helpTextId,children:helpText})})]})})}));};var Radio=assignWithoutSideEffects(React__default.forwardRef(_Radio),{displayName:'Radio'});
28
28
 
29
29
  export { Radio };
30
30
  //# sourceMappingURL=Radio.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.js","sources":["../../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport type { OnChange } from './useRadio';\nimport { useRadio } from './useRadio';\nimport { RadioIcon } from './RadioIcon/RadioIcon';\nimport { useRadioGroupContext } from './RadioGroup/RadioContext';\nimport { radioHoverTokens, radioSizes } from './radioTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport BaseBox from '~components/Box/BaseBox';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport type { BladeElementRef, StringChildrenType, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType, makeSize, useTheme } from '~utils';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { throwBladeError } from '~utils/logger';\n\ntype RadioProps = {\n /**\n * Sets the label text of the Radio\n */\n children?: StringChildrenType;\n /**\n * Help text for the Radio\n */\n helpText?: string;\n /**\n * The value to be used in the Radio input.\n * This is the value that will be returned on form submission.\n */\n value: string;\n /**\n * If `true`, the Radio will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Size of the radios\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n StyledPropsBlade;\n\nconst _Radio: React.ForwardRefRenderFunction<BladeElementRef, RadioProps> = (\n { value, children, helpText, isDisabled, size = 'medium', testID, ...styledProps },\n ref,\n) => {\n const { theme } = useTheme();\n const groupProps = useRadioGroupContext();\n const isInsideGroup = !isEmpty(groupProps);\n\n if (__DEV__) {\n if (!isInsideGroup) {\n throwBladeError({\n moduleName: 'Radio',\n message: 'Cannot use <Radio /> outside of <RadioGroup />',\n });\n }\n }\n\n const isChecked = groupProps?.state?.isChecked(value);\n const defaultChecked =\n groupProps?.defaultValue === undefined ? undefined : groupProps?.defaultValue === value;\n const validationState = groupProps?.validationState;\n const hasError = validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = groupProps?.isRequired || groupProps?.necessityIndicator === 'required';\n const name = groupProps?.name;\n const showHelpText = !hasError && helpText;\n const isReactNative = getPlatformType() === 'react-native';\n const _size = groupProps.size ?? size;\n\n const handleChange: OnChange = ({ isChecked, value }) => {\n if (isChecked) {\n groupProps?.state?.setValue(value!);\n } else {\n groupProps?.state?.removeValue();\n }\n };\n\n const { state, ids, inputProps } = useRadio({\n defaultChecked,\n isChecked,\n hasError,\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name,\n value,\n onChange: handleChange,\n });\n\n // radio icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(radioSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox {...getStyledProps(styledProps)}>\n <SelectorLabel\n componentName={MetaConstants.RadioLabel}\n inputProps={isReactNative ? inputProps : {}}\n testID={testID}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" alignItems=\"center\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={radioHoverTokens}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n hasError={hasError}\n inputProps={inputProps}\n ref={ref}\n />\n <RadioIcon\n size={_size}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n isNegative={hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showHelpText && (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} isNegative={true} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n )}\n </BaseBox>\n </SelectorLabel>\n </BaseBox>\n );\n};\n\nconst Radio = assignWithoutSideEffects(React.forwardRef(_Radio), { displayName: 'Radio' });\n\nexport type { RadioProps };\nexport { Radio };\n"],"names":["_Radio","_ref","ref","_groupProps$state","_groupProps$size","value","children","helpText","isDisabled","_ref$size","size","testID","styledProps","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","groupProps","useRadioGroupContext","isInsideGroup","isEmpty","__DEV__","throwBladeError","moduleName","message","isChecked","state","defaultChecked","defaultValue","undefined","validationState","hasError","_isDisabled","_isRequired","isRequired","necessityIndicator","name","showHelpText","isReactNative","getPlatformType","_size","handleChange","_ref2","_groupProps$state2","setValue","_groupProps$state3","removeValue","_useRadio","useRadio","onChange","ids","inputProps","helpTextLeftSpacing","makeSize","radioSizes","icon","width","spacing","_jsx","BaseBox","Object","assign","getStyledProps","SelectorLabel","componentName","MetaConstants","RadioLabel","_jsxs","display","flexDirection","alignItems","SelectorInput","hoverTokens","radioHoverTokens","RadioIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","Radio","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings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AA,CAC7DqD,CAAAA,GAAA,CAACa,aAAa,CAAA,CACZC,WAAW,CAAEC,gBAAiB,CAC9BhD,SAAS,CAAEC,KAAK,CAACD,SAAU,CAC3BlB,UAAU,CAAEyB,WAAY,CACxBD,QAAQ,CAAEA,QAAS,CACnBoB,UAAU,CAAEA,UAAW,CACvBlD,GAAG,CAAEA,GAAI,CACV,CAAC,CACFyD,GAAA,CAACgB,SAAS,CACRjE,CAAAA,IAAI,CAAE+B,KAAM,CACZf,SAAS,CAAEC,KAAK,CAACD,SAAU,CAC3BlB,UAAU,CAAEyB,WAAY,CACxB2C,UAAU,CAAE5C,QAAS,CACtB,CAAC,CACD1B,QAAQ,CACPqD,GAAA,CAACkB,aAAa,CAAA,CAACnE,IAAI,CAAE+B,KAAM,CAACjC,UAAU,CAAEyB,WAAY,CAAA3B,QAAA,CACjDA,QAAQ,CACI,CAAC,CACd,IAAI,CAAA,CACD,CAAC,CACTgC,YAAY,EACXqB,GAAA,CAACC,OAAO,CAAA,CAACkB,UAAU,CAAEzB,mBAAoB,CAAA/C,QAAA,CACvCqD,GAAA,CAACoB,mBAAmB,CAACrE,CAAAA,IAAI,CAAE+B,KAAM,CAACmC,UAAU,CAAE,IAAK,CAACI,EAAE,CAAE7B,GAAG,EAAA,IAAA,CAAA,KAAA,CAAA,CAAHA,GAAG,CAAE8B,UAAW,CAAA3E,QAAA,CACrEC,QAAQ,CACU,CAAC,CACf,CACV,EACM,CAAC,CACG,CAAC,CACT,CAAA,CAAC,CAEd,CAAC,CAEK,IAAA2E,KAAK,CAAGC,wBAAwB,CAACC,cAAK,CAACC,UAAU,CAACrF,MAAM,CAAC,CAAE,CAAEsF,WAAW,CAAE,OAAQ,CAAC;;;;"}
1
+ {"version":3,"file":"Radio.js","sources":["../../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport type { OnChange } from './useRadio';\nimport { useRadio } from './useRadio';\nimport { RadioIcon } from './RadioIcon/RadioIcon';\nimport { useRadioGroupContext } from './RadioGroup/RadioContext';\nimport { radioHoverTokens, radioSizes } from './radioTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport BaseBox from '~components/Box/BaseBox';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport type { BladeElementRef, StringChildrenType, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType, makeSize, useTheme } from '~utils';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { throwBladeError } from '~utils/logger';\n\ntype RadioProps = {\n /**\n * Sets the label text of the Radio\n */\n children?: StringChildrenType;\n /**\n * Help text for the Radio\n */\n helpText?: string;\n /**\n * The value to be used in the Radio input.\n * This is the value that will be returned on form submission.\n */\n value: string;\n /**\n * If `true`, the Radio will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Size of the radios\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n StyledPropsBlade;\n\nconst _Radio: React.ForwardRefRenderFunction<BladeElementRef, RadioProps> = (\n { value, children, helpText, isDisabled, size = 'medium', testID, ...styledProps },\n ref,\n) => {\n const { theme } = useTheme();\n const groupProps = useRadioGroupContext();\n const isInsideGroup = !isEmpty(groupProps);\n\n if (__DEV__) {\n if (!isInsideGroup) {\n throwBladeError({\n moduleName: 'Radio',\n message: 'Cannot use <Radio /> outside of <RadioGroup />',\n });\n }\n }\n\n const isChecked = groupProps?.state?.isChecked(value);\n const defaultChecked =\n groupProps?.defaultValue === undefined ? undefined : groupProps?.defaultValue === value;\n const validationState = groupProps?.validationState;\n const hasError = validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = groupProps?.isRequired || groupProps?.necessityIndicator === 'required';\n const name = groupProps?.name;\n const showHelpText = helpText;\n const isReactNative = getPlatformType() === 'react-native';\n const _size = groupProps.size ?? size;\n\n const handleChange: OnChange = ({ isChecked, value }) => {\n if (isChecked) {\n groupProps?.state?.setValue(value!);\n } else {\n groupProps?.state?.removeValue();\n }\n };\n\n const { state, ids, inputProps } = useRadio({\n defaultChecked,\n isChecked,\n hasError,\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name,\n value,\n onChange: handleChange,\n });\n\n // radio icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(radioSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox {...getStyledProps(styledProps)}>\n <SelectorLabel\n componentName={MetaConstants.RadioLabel}\n inputProps={isReactNative ? inputProps : {}}\n testID={testID}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" alignItems=\"center\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={radioHoverTokens}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n hasError={hasError}\n inputProps={inputProps}\n ref={ref}\n />\n <RadioIcon\n size={_size}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n isNegative={hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showHelpText && (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n )}\n </BaseBox>\n </SelectorLabel>\n </BaseBox>\n );\n};\n\nconst Radio = assignWithoutSideEffects(React.forwardRef(_Radio), { displayName: 'Radio' });\n\nexport type { RadioProps };\nexport { Radio };\n"],"names":["_Radio","_ref","ref","_groupProps$state","_groupProps$size","value","children","helpText","isDisabled","_ref$size","size","testID","styledProps","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","groupProps","useRadioGroupContext","isInsideGroup","isEmpty","__DEV__","throwBladeError","moduleName","message","isChecked","state","defaultChecked","defaultValue","undefined","validationState","hasError","_isDisabled","_isRequired","isRequired","necessityIndicator","name","showHelpText","isReactNative","getPlatformType","_size","handleChange","_ref2","_groupProps$state2","setValue","_groupProps$state3","removeValue","_useRadio","useRadio","onChange","ids","inputProps","helpTextLeftSpacing","makeSize","radioSizes","icon","width","spacing","_jsx","BaseBox","Object","assign","getStyledProps","SelectorLabel","componentName","MetaConstants","RadioLabel","_jsxs","display","flexDirection","alignItems","SelectorInput","hoverTokens","radioHoverTokens","RadioIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","Radio","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAA,SAAA,CAAA,CAAA,OAAA,CAAA,UAAA,CAAA,UAAA,CAAA,YAAA,CAAA,MAAA,CAAA,QAAA,CAAA,CAiDA,IAAMA,MAAmE,CAAG,SAAtEA,MAAmEA,CAAAC,IAAA,CAEvEC,GAAG,CACA,KAAAC,iBAAA,CAAAC,gBAAA,CAFD,IAAAC,KAAK,CAAAJ,IAAA,CAALI,KAAK,CAAEC,QAAQ,CAAAL,IAAA,CAARK,QAAQ,CAAEC,QAAQ,CAAAN,IAAA,CAARM,QAAQ,CAAEC,UAAU,CAAAP,IAAA,CAAVO,UAAU,CAAAC,SAAA,CAAAR,IAAA,CAAES,IAAI,CAAJA,IAAI,CAAAD,SAAA,GAAA,KAAA,CAAA,CAAG,QAAQ,CAAAA,SAAA,CAAEE,MAAM,CAAAV,IAAA,CAANU,MAAM,CAAKC,WAAW,CAAAC,wBAAA,CAAAZ,IAAA,CAAAa,SAAA,EAGhF,IAAAC,SAAA,CAAkBC,QAAQ,EAAE,CAApBC,KAAK,CAAAF,SAAA,CAALE,KAAK,C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AAAA,KAAAA,CAAAA,CAAAA,GAAG,CAAE8B,UAAW,CAAA3E,QAAA,CACnDC,QAAQ,CACU,CAAC,CACf,CACV,CAAA,CACM,CAAC,CACG,CAAC,EACT,CAAC,CAEd,CAAC,CAEK,IAAA2E,KAAK,CAAGC,wBAAwB,CAACC,cAAK,CAACC,UAAU,CAACrF,MAAM,CAAC,CAAE,CAAEsF,WAAW,CAAE,OAAQ,CAAC;;;;"}
@@ -89,10 +89,7 @@ var _Checkbox = function _Checkbox(_ref, ref) {
89
89
  medium: 'medium',
90
90
  large: 'large'
91
91
  };
92
-
93
- // only show error when the self validation is set to error
94
- // Since we don't want to show errorText inside the group
95
- var showSupportingText = validationState !== 'error' && helpText;
92
+ var showSupportingText = helpText;
96
93
  var handleChange = function handleChange(_ref2) {
97
94
  var isChecked = _ref2.isChecked,
98
95
  event = _ref2.event,
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","sources":["../../../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport { useCheckboxGroupContext } from './CheckboxGroup/CheckboxGroupContext';\nimport { CheckboxIcon } from './CheckboxIcon';\nimport { useCheckbox } from './useCheckbox';\nimport { checkboxHoverTokens, checkboxSizes } from './checkboxTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport isUndefined from '~utils/lodashButBetter/isUndefined';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport BaseBox from '~components/Box/BaseBox';\nimport { FormHint } from '~components/Form';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport type { BladeElementRef, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { throwBladeError } from '~utils/logger';\nimport { makeSize, useTheme } from '~utils';\n\ntype OnChange = ({\n isChecked,\n event,\n value,\n}: {\n isChecked: boolean;\n event?: React.ChangeEvent;\n value?: string;\n}) => void;\n\ntype CheckboxProps = {\n /**\n * If `true`, The checkbox will be checked. This also makes the checkbox controlled\n * Use `onChange` to update its value\n *\n * @default false\n */\n isChecked?: boolean;\n /**\n * If `true`, the checkbox will be initially checked. This also makes the checkbox uncontrolled\n *\n * @default false\n */\n defaultChecked?: boolean;\n /**\n * The callback invoked when the checked state of the `Checkbox` changes.\n */\n onChange?: OnChange;\n /**\n * Sets the label of the checkbox\n */\n children?: React.ReactNode;\n /**\n * Help text for the checkbox\n */\n helpText?: string;\n /**\n * Error text for the checkbox\n *\n * Renders when `validationState` is set to 'error'\n */\n errorText?: string;\n /**\n * If `true`, the checkbox will be indeterminate.\n * This does not modify the isChecked property.\n *\n * @default false\n */\n isIndeterminate?: boolean;\n /**\n * The name of the input field in a checkbox\n * (Useful for form submission).\n */\n name?: string;\n /**\n * The value to be used in the checkbox input.\n * This is the value that will be returned on form submission.\n */\n value?: string;\n /**\n * If `true`, the checkbox will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * If `true`, the checkbox input is marked as required,\n * and `required` attribute will be added\n *\n * @default false\n */\n isRequired?: boolean;\n /**\n * If `error`, the checkbox input is marked as invalid,\n * and `invalid` attribute will be added\n */\n validationState?: 'error' | 'none';\n /**\n * Size of the checkbox\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n /**\n * Sets the tab-index property on checkbox element\n *\n */\n tabIndex?: number;\n} & TestID &\n StyledPropsBlade;\n\nconst _Checkbox: React.ForwardRefRenderFunction<BladeElementRef, CheckboxProps> = (\n {\n defaultChecked,\n validationState,\n isChecked,\n isDisabled,\n isIndeterminate,\n isRequired,\n name,\n onChange,\n value,\n children,\n helpText,\n errorText,\n size = 'medium',\n tabIndex,\n testID,\n ...styledProps\n },\n ref,\n) => {\n const groupProps = useCheckboxGroupContext();\n\n // ban certain props in checkbox while inside group\n const hasValidationState = !isUndefined(validationState);\n const hasName = !isUndefined(name);\n const hasDefaultChecked = !isUndefined(defaultChecked);\n const hasIsChecked = !isUndefined(isChecked);\n const hasOnChange = !isUndefined(onChange);\n\n if (__DEV__) {\n if (\n (hasValidationState || hasName || hasDefaultChecked || hasIsChecked || hasOnChange) &&\n !isEmpty(groupProps)\n ) {\n const props = [\n hasValidationState ? 'validationState' : undefined,\n hasName ? 'name' : undefined,\n hasDefaultChecked ? 'defaultChecked' : undefined,\n hasIsChecked ? 'isChecked' : undefined,\n hasOnChange ? 'onChange' : undefined,\n ]\n .filter(Boolean)\n .join(',');\n\n throwBladeError({\n message: `Cannot set \\`${props}\\` on <Checkbox /> when it's inside <CheckboxGroup />, Please set it on the <CheckboxGroup /> itself`,\n moduleName: 'Checkbox',\n });\n }\n\n // mandate value prop when using inside group\n if (!value && !isEmpty(groupProps)) {\n throw new Error(\n `[Blade Checkbox]: <CheckboxGroup /> requires that you pass unique \"value\" prop to each <Checkbox />\n <CheckboxGroup>\n <Checkbox value=\"apple\">Apple</Checkbox>\n <Checkbox value=\"mango\">Mango</Checkbox>\n </CheckboxGroup>\n `,\n );\n }\n }\n\n const _validationState = validationState ?? groupProps?.validationState;\n const _hasError = _validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = Boolean(\n isRequired || groupProps?.isRequired || groupProps?.necessityIndicator === 'required',\n );\n const _name = name ?? groupProps?.name;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const _isChecked = isChecked ?? groupProps?.state?.isChecked(value!);\n const _size = groupProps.size ?? size;\n const { theme } = useTheme();\n const formHintSize = {\n small: 'medium',\n medium: 'medium',\n large: 'large',\n } as const;\n\n // only show error when the self validation is set to error\n // Since we don't want to show errorText inside the group\n const showSupportingText = validationState !== 'error' && helpText;\n\n const handleChange: OnChange = ({ isChecked, event, value }) => {\n if (isChecked) {\n groupProps?.state?.addValue(value!);\n } else {\n groupProps?.state?.removeValue(value!);\n }\n\n onChange?.({ isChecked, event, value });\n };\n\n const { state, ids, inputProps } = useCheckbox({\n defaultChecked,\n isChecked: _isChecked,\n isIndeterminate,\n hasError: _hasError,\n hasHelperText: Boolean(showSupportingText),\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name: _name,\n value,\n onChange: handleChange,\n });\n\n // Checkbox icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(checkboxSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox\n {...metaAttribute({ name: MetaConstants.Checkbox, testID })}\n {...getStyledProps(styledProps)}\n >\n <SelectorLabel\n componentName={MetaConstants.CheckboxLabel}\n inputProps={state.isReactNative ? inputProps : {}}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={checkboxHoverTokens}\n isChecked={state.isChecked || Boolean(isIndeterminate)}\n isDisabled={_isDisabled}\n hasError={_hasError}\n inputProps={inputProps}\n tabIndex={tabIndex}\n ref={ref}\n />\n <CheckboxIcon\n size={_size}\n isChecked={state.isChecked}\n isIndeterminate={isIndeterminate}\n isDisabled={_isDisabled}\n isNegative={_hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showSupportingText ? (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n ) : null}\n </BaseBox>\n </SelectorLabel>\n <FormHint\n size={formHintSize[_size]}\n errorText={errorText}\n errorTextId={ids?.errorTextId}\n type={validationState === 'error' ? 'error' : 'help'}\n />\n </BaseBox>\n );\n};\n\nconst Checkbox = assignWithoutSideEffects(React.forwardRef(_Checkbox), {\n displayName: 'Checkbox',\n});\n\nexport type { CheckboxProps };\nexport { Checkbox };\n"],"names":["_Checkbox","_ref","ref","_groupProps$state","_groupProps$size","defaultChecked","validationState","isChecked","isDisabled","isIndeterminate","isRequired","name","onChange","value","children","helpText","errorText","_ref$size","size","tabIndex","testID","styledProps","_objectWithoutProperties","_excluded","groupProps","useCheckboxGroupContext","hasValidationState","isUndefined","hasName","hasDefaultChecked","hasIsChecked","hasOnChange","isEmpty","props","undefined","filter","Boolean","join","throwBladeError","message","concat","moduleName","Error","_validationState","_hasError","_isDisabled","_isRequired","necessityIndicator","_name","_isChecked","state","_size","_useTheme","useTheme","theme","formHintSize","small","medium","large","showSupportingText","handleChange","_ref2","event","_groupProps$state2","addValue","_groupProps$state3","removeValue","_useCheckbox","useCheckbox","hasError","hasHelperText","ids","inputProps","helpTextLeftSpacing","makeSize","checkboxSizes","icon","width","spacing","_jsxs","BaseBox","_objectSpread","metaAttribute","MetaConstants","Checkbox","getStyledProps","_jsx","SelectorLabel","componentName","CheckboxLabel","isReactNative","display","flexDirection","SelectorInput","hoverTokens","checkboxHoverTokens","CheckboxIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","FormHint","errorTextId","type","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,IAAMA,SAAyE,GAAG,SAA5EA,SAAyEA,CAAAC,IAAA,EAmB7EC,GAAG,EACA;EAAA,IAAAC,iBAAA,EAAAC,gBAAA,CAAA;AAAA,EAAA,IAlBDC,cAAc,GAAAJ,IAAA,CAAdI,cAAc;IACdC,eAAe,GAAAL,IAAA,CAAfK,eAAe;IACfC,SAAS,GAAAN,IAAA,CAATM,SAAS;IACTC,UAAU,GAAAP,IAAA,CAAVO,UAAU;IACVC,eAAe,GAAAR,IAAA,CAAfQ,eAAe;IACfC,UAAU,GAAAT,IAAA,CAAVS,UAAU;IACVC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Ae,KAAK,OAAO,GAAG,OAAO,GAAG,MAAA;AAAO,KACtD,CAAC,CAAA;AAAA,GAAA,CACK,CAAC,CAAA;AAEd,CAAC,CAAA;AAEK8E,IAAAA,QAAQ,gBAAGsB,wBAAwB,eAACC,cAAK,CAACC,UAAU,CAAC5G,SAAS,CAAC,EAAE;AACrE6G,EAAAA,WAAW,EAAE,UAAA;AACf,CAAC;;;;"}
1
+ {"version":3,"file":"Checkbox.js","sources":["../../../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport { useCheckboxGroupContext } from './CheckboxGroup/CheckboxGroupContext';\nimport { CheckboxIcon } from './CheckboxIcon';\nimport { useCheckbox } from './useCheckbox';\nimport { checkboxHoverTokens, checkboxSizes } from './checkboxTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport isUndefined from '~utils/lodashButBetter/isUndefined';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport BaseBox from '~components/Box/BaseBox';\nimport { FormHint } from '~components/Form';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport type { BladeElementRef, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { throwBladeError } from '~utils/logger';\nimport { makeSize, useTheme } from '~utils';\n\ntype OnChange = ({\n isChecked,\n event,\n value,\n}: {\n isChecked: boolean;\n event?: React.ChangeEvent;\n value?: string;\n}) => void;\n\ntype CheckboxProps = {\n /**\n * If `true`, The checkbox will be checked. This also makes the checkbox controlled\n * Use `onChange` to update its value\n *\n * @default false\n */\n isChecked?: boolean;\n /**\n * If `true`, the checkbox will be initially checked. This also makes the checkbox uncontrolled\n *\n * @default false\n */\n defaultChecked?: boolean;\n /**\n * The callback invoked when the checked state of the `Checkbox` changes.\n */\n onChange?: OnChange;\n /**\n * Sets the label of the checkbox\n */\n children?: React.ReactNode;\n /**\n * Help text for the checkbox\n */\n helpText?: string;\n /**\n * Error text for the checkbox\n *\n * Renders when `validationState` is set to 'error'\n */\n errorText?: string;\n /**\n * If `true`, the checkbox will be indeterminate.\n * This does not modify the isChecked property.\n *\n * @default false\n */\n isIndeterminate?: boolean;\n /**\n * The name of the input field in a checkbox\n * (Useful for form submission).\n */\n name?: string;\n /**\n * The value to be used in the checkbox input.\n * This is the value that will be returned on form submission.\n */\n value?: string;\n /**\n * If `true`, the checkbox will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * If `true`, the checkbox input is marked as required,\n * and `required` attribute will be added\n *\n * @default false\n */\n isRequired?: boolean;\n /**\n * If `error`, the checkbox input is marked as invalid,\n * and `invalid` attribute will be added\n */\n validationState?: 'error' | 'none';\n /**\n * Size of the checkbox\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n /**\n * Sets the tab-index property on checkbox element\n *\n */\n tabIndex?: number;\n} & TestID &\n StyledPropsBlade;\n\nconst _Checkbox: React.ForwardRefRenderFunction<BladeElementRef, CheckboxProps> = (\n {\n defaultChecked,\n validationState,\n isChecked,\n isDisabled,\n isIndeterminate,\n isRequired,\n name,\n onChange,\n value,\n children,\n helpText,\n errorText,\n size = 'medium',\n tabIndex,\n testID,\n ...styledProps\n },\n ref,\n) => {\n const groupProps = useCheckboxGroupContext();\n\n // ban certain props in checkbox while inside group\n const hasValidationState = !isUndefined(validationState);\n const hasName = !isUndefined(name);\n const hasDefaultChecked = !isUndefined(defaultChecked);\n const hasIsChecked = !isUndefined(isChecked);\n const hasOnChange = !isUndefined(onChange);\n\n if (__DEV__) {\n if (\n (hasValidationState || hasName || hasDefaultChecked || hasIsChecked || hasOnChange) &&\n !isEmpty(groupProps)\n ) {\n const props = [\n hasValidationState ? 'validationState' : undefined,\n hasName ? 'name' : undefined,\n hasDefaultChecked ? 'defaultChecked' : undefined,\n hasIsChecked ? 'isChecked' : undefined,\n hasOnChange ? 'onChange' : undefined,\n ]\n .filter(Boolean)\n .join(',');\n\n throwBladeError({\n message: `Cannot set \\`${props}\\` on <Checkbox /> when it's inside <CheckboxGroup />, Please set it on the <CheckboxGroup /> itself`,\n moduleName: 'Checkbox',\n });\n }\n\n // mandate value prop when using inside group\n if (!value && !isEmpty(groupProps)) {\n throw new Error(\n `[Blade Checkbox]: <CheckboxGroup /> requires that you pass unique \"value\" prop to each <Checkbox />\n <CheckboxGroup>\n <Checkbox value=\"apple\">Apple</Checkbox>\n <Checkbox value=\"mango\">Mango</Checkbox>\n </CheckboxGroup>\n `,\n );\n }\n }\n\n const _validationState = validationState ?? groupProps?.validationState;\n const _hasError = _validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = Boolean(\n isRequired || groupProps?.isRequired || groupProps?.necessityIndicator === 'required',\n );\n const _name = name ?? groupProps?.name;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const _isChecked = isChecked ?? groupProps?.state?.isChecked(value!);\n const _size = groupProps.size ?? size;\n const { theme } = useTheme();\n const formHintSize = {\n small: 'medium',\n medium: 'medium',\n large: 'large',\n } as const;\n\n const showSupportingText = helpText;\n\n const handleChange: OnChange = ({ isChecked, event, value }) => {\n if (isChecked) {\n groupProps?.state?.addValue(value!);\n } else {\n groupProps?.state?.removeValue(value!);\n }\n\n onChange?.({ isChecked, event, value });\n };\n\n const { state, ids, inputProps } = useCheckbox({\n defaultChecked,\n isChecked: _isChecked,\n isIndeterminate,\n hasError: _hasError,\n hasHelperText: Boolean(showSupportingText),\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name: _name,\n value,\n onChange: handleChange,\n });\n\n // Checkbox icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(checkboxSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox\n {...metaAttribute({ name: MetaConstants.Checkbox, testID })}\n {...getStyledProps(styledProps)}\n >\n <SelectorLabel\n componentName={MetaConstants.CheckboxLabel}\n inputProps={state.isReactNative ? inputProps : {}}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={checkboxHoverTokens}\n isChecked={state.isChecked || Boolean(isIndeterminate)}\n isDisabled={_isDisabled}\n hasError={_hasError}\n inputProps={inputProps}\n tabIndex={tabIndex}\n ref={ref}\n />\n <CheckboxIcon\n size={_size}\n isChecked={state.isChecked}\n isIndeterminate={isIndeterminate}\n isDisabled={_isDisabled}\n isNegative={_hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showSupportingText ? (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n ) : null}\n </BaseBox>\n </SelectorLabel>\n <FormHint\n size={formHintSize[_size]}\n errorText={errorText}\n errorTextId={ids?.errorTextId}\n type={validationState === 'error' ? 'error' : 'help'}\n />\n </BaseBox>\n );\n};\n\nconst Checkbox = assignWithoutSideEffects(React.forwardRef(_Checkbox), {\n displayName: 'Checkbox',\n});\n\nexport type { CheckboxProps };\nexport { Checkbox };\n"],"names":["_Checkbox","_ref","ref","_groupProps$state","_groupProps$size","defaultChecked","validationState","isChecked","isDisabled","isIndeterminate","isRequired","name","onChange","value","children","helpText","errorText","_ref$size","size","tabIndex","testID","styledProps","_objectWithoutProperties","_excluded","groupProps","useCheckboxGroupContext","hasValidationState","isUndefined","hasName","hasDefaultChecked","hasIsChecked","hasOnChange","isEmpty","props","undefined","filter","Boolean","join","throwBladeError","message","concat","moduleName","Error","_validationState","_hasError","_isDisabled","_isRequired","necessityIndicator","_name","_isChecked","state","_size","_useTheme","useTheme","theme","formHintSize","small","medium","large","showSupportingText","handleChange","_ref2","event","_groupProps$state2","addValue","_groupProps$state3","removeValue","_useCheckbox","useCheckbox","hasError","hasHelperText","ids","inputProps","helpTextLeftSpacing","makeSize","checkboxSizes","icon","width","spacing","_jsxs","BaseBox","_objectSpread","metaAttribute","MetaConstants","Checkbox","getStyledProps","_jsx","SelectorLabel","componentName","CheckboxLabel","isReactNative","display","flexDirection","SelectorInput","hoverTokens","checkboxHoverTokens","CheckboxIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","FormHint","errorTextId","type","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,IAAMA,SAAyE,GAAG,SAA5EA,SAAyEA,CAAAC,IAAA,EAmB7EC,GAAG,EACA;EAAA,IAAAC,iBAAA,EAAAC,gBAAA,CAAA;AAAA,EAAA,IAlBDC,cAAc,GAAAJ,IAAA,CAAdI,cAAc;IACdC,eAAe,GAAAL,IAAA,CAAfK,eAAe;IACfC,SAAS,GAAAN,IAAA,CAATM,SAAS;IACTC,UAAU,GAAAP,IAAA,CAAVO,UAAU;IACVC,eAAe,GAAAR,IAAA,CAAfQ,eAAe;IACfC,UAAU,GAAAT,IAAA,CAAVS,UAAU;IACVC,IAAI,GAAAV,IAAA,CAAJU,IAAI;IACJC,QAAQ,GAAAX,IAAA,CAARW,QAAQ;IACRC,KAAK,GAAAZ,IAAA,CAALY,KAAK;IACLC,QAAQ,GAAAb,IAAA,CAARa,QAAQ;IACRC,QAAQ,GAAAd,IAAA,CAARc,QAAQ;IACRC,SAAS,GAAAf,IAAA,CAATe,SAAS;IAAAC,SAAA,GAAAhB,IAAA,CACTiB,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAAAA,SAAA;I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F,YAAAA,IAAI,EAAEiC,KAAM;AAAC3C,YAAAA,UAAU,EAAEqC,WAAY;AAAA/B,YAAAA,QAAA,EACjDA,QAAAA;WACY,CAAC,GACd,IAAI,CAAA;AAAA,SACD,CAAC,EACT6C,kBAAkB,gBACjB2B,GAAA,CAACN,OAAO,EAAA;AAACmB,UAAAA,UAAU,EAAE1B,mBAAoB;UAAA3D,QAAA,eACvCwE,GAAA,CAACc,mBAAmB,EAAA;AAAClF,YAAAA,IAAI,EAAEiC,KAAM;AAACkD,YAAAA,EAAE,EAAE9B,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAHA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,GAAG,CAAE+B,UAAW;AAAAxF,YAAAA,QAAA,EACnDC,QAAAA;WACkB,CAAA;SACd,CAAC,GACR,IAAI,CAAA;OACD,CAAA;AAAC,KACG,CAAC,eAChBuE,GAAA,CAACiB,QAAQ,EAAA;AACPrF,MAAAA,IAAI,EAAEqC,YAAY,CAACJ,KAAK,CAAE;AAC1BnC,MAAAA,SAAS,EAAEA,SAAU;AACrBwF,MAAAA,WAAW,EAAEjC,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAHA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,GAAG,CAAEiC,WAAY;AAC9BC,MAAAA,IAAI,EAAEnG,eAAe,KAAK,OAAO,GAAG,OAAO,GAAG,MAAA;AAAO,KACtD,CAAC,CAAA;AAAA,GAAA,CACK,CAAC,CAAA;AAEd,CAAC,CAAA;AAEK8E,IAAAA,QAAQ,gBAAGsB,wBAAwB,eAACC,cAAK,CAACC,UAAU,CAAC5G,SAAS,CAAC,EAAE;AACrE6G,EAAAA,WAAW,EAAE,UAAA;AACf,CAAC;;;;"}
@@ -20,7 +20,7 @@ import { BaseInput } from '../BaseInput/BaseInput.js';
20
20
  import { MetaConstants } from '../../../utils/metaAttribute/metaConstants.js';
21
21
  import { assignWithoutSideEffects } from '../../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
22
22
 
23
- var _excluded = ["defaultCountry", "country", "onCountryChange", "label", "labelPosition", "defaultValue", "value", "name", "onChange", "necessityIndicator", "isRequired", "isDisabled", "leadingIcon", "trailingIcon", "validationState", "errorText", "helpText", "successText", "size", "onClearButtonClick", "showCountrySelector", "showDialCode", "onClick", "onBlur", "onFocus", "accessibilityLabel", "autoFocus", "testID", "keyboardReturnKeyType", "autoCompleteSuggestionType", "allowedCountries"];
23
+ var _excluded = ["defaultCountry", "country", "onCountryChange", "label", "labelPosition", "defaultValue", "value", "name", "onChange", "necessityIndicator", "isRequired", "isDisabled", "leadingIcon", "trailingIcon", "validationState", "errorText", "helpText", "successText", "size", "onClearButtonClick", "showCountrySelector", "showDialCode", "onClick", "onBlur", "onFocus", "accessibilityLabel", "autoFocus", "testID", "keyboardReturnKeyType", "autoCompleteSuggestionType", "allowedCountries", "placeholder"];
24
24
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25
25
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
26
26
  var _PhoneNumberInput = function _PhoneNumberInput(_ref, ref) {
@@ -61,6 +61,7 @@ var _PhoneNumberInput = function _PhoneNumberInput(_ref, ref) {
61
61
  keyboardReturnKeyType = _ref$keyboardReturnKe === void 0 ? 'done' : _ref$keyboardReturnKe,
62
62
  autoCompleteSuggestionType = _ref.autoCompleteSuggestionType,
63
63
  allowedCountries = _ref.allowedCountries,
64
+ placeholder = _ref.placeholder,
64
65
  styledProps = _objectWithoutProperties(_ref, _excluded);
65
66
  var inputRef = React__default.useRef(null);
66
67
  var mergedRef = useMergeRefs(ref, inputRef);
@@ -167,7 +168,7 @@ var _PhoneNumberInput = function _PhoneNumberInput(_ref, ref) {
167
168
  defaultValue: defaultValue,
168
169
  value: value,
169
170
  name: name,
170
- placeholder: formatPhoneNumber('1234567890', selectedCountry),
171
+ placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : formatPhoneNumber('1234567890', selectedCountry),
171
172
  trailingIcon: trailingIcon,
172
173
  leadingIcon: leadingIcon,
173
174
  prefix: showDialCode ? getDialCodeByCountryCode(selectedCountry) : undefined,
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneNumberInput.web.js","sources":["../../../../../../../src/components/Input/PhoneNumberInput/PhoneNumberInput.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */\nimport type { CountryCodeType } from '@razorpay/i18nify-js';\nimport {\n formatPhoneNumber,\n getDialCodeByCountryCode,\n getFlagsForAllCountries,\n} from '@razorpay/i18nify-js';\nimport React from 'react';\nimport type { PhoneNumberInputProps } from './types';\nimport { countryNameFormatter, CountrySelector } from './CountrySelector';\nimport { BaseInput } from '~components/Input/BaseInput';\nimport { IconButton } from '~components/Button/IconButton';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { getKeyboardAndAutocompleteProps } from '~components/Input/BaseInput/utils';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { useMergeRefs } from '~utils/useMergeRefs';\nimport type { BladeElementRef } from '~utils/types';\nimport { CloseIcon } from '~components/Icons';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { useControllableState } from '~utils/useControllable';\n\nconst _PhoneNumberInput: React.ForwardRefRenderFunction<BladeElementRef, PhoneNumberInputProps> = (\n {\n defaultCountry = 'IN',\n country,\n onCountryChange,\n label,\n labelPosition,\n defaultValue,\n value,\n name,\n onChange,\n necessityIndicator,\n isRequired,\n isDisabled,\n leadingIcon,\n trailingIcon,\n validationState,\n errorText,\n helpText,\n successText,\n size = 'medium',\n onClearButtonClick,\n showCountrySelector = true,\n showDialCode = true,\n onClick,\n onBlur,\n onFocus,\n accessibilityLabel = 'Enter phone number',\n autoFocus,\n testID,\n keyboardReturnKeyType = 'done',\n autoCompleteSuggestionType,\n allowedCountries,\n ...styledProps\n },\n ref,\n): React.ReactElement => {\n const inputRef = React.useRef<HTMLInputElement | null>(null);\n const mergedRef = useMergeRefs(ref, inputRef);\n\n const inputWrapperRef = React.useRef<HTMLDivElement | null>(null);\n const [shouldShowClearButton, setShouldShowClearButton] = React.useState(false);\n const [selectedCountry, setSelectedCountry] = useControllableState<CountryCodeType>({\n defaultValue: defaultCountry as CountryCodeType,\n value: country,\n onChange: (country) => onCountryChange?.({ country }),\n });\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(defaultValue ?? value));\n }, [defaultValue, value]);\n\n const renderTrailingInteractionElement = (): React.ReactNode => {\n if (!shouldShowClearButton) return null;\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(value) && inputRef.current) {\n // when the input field is uncontrolled take the ref and clear the input and then call the onClearButtonClick function\n if (inputRef.current instanceof HTMLInputElement) {\n inputRef.current.value = '';\n inputRef.current.focus();\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 inputRef?.current?.focus();\n setShouldShowClearButton(false);\n }}\n isDisabled={isDisabled}\n accessibilityLabel=\"Clear Input Content\"\n />\n );\n };\n\n const flags = React.useMemo(() => getFlagsForAllCountries(), []);\n const countryData = React.useMemo(() => {\n if (allowedCountries) {\n return allowedCountries.map((countryCode) => {\n return {\n code: countryCode,\n name: countryNameFormatter.of(countryCode)!,\n };\n });\n }\n\n return (Object.keys(flags) as CountryCodeType[])\n .map((countryCode) => {\n return {\n code: countryCode,\n name: countryNameFormatter.of(countryCode)!,\n };\n })\n .sort((a, b) => a.name.localeCompare(b.name));\n }, [allowedCountries, flags]);\n\n const handleOnChange = ({\n name,\n value,\n selectedCountry,\n }: {\n name?: string;\n value?: string;\n selectedCountry: CountryCodeType;\n }): void => {\n onChange?.({\n name: name!,\n value: value!,\n phoneNumber: value ? formatPhoneNumber(value, selectedCountry) : undefined!,\n dialCode: getDialCodeByCountryCode(selectedCountry),\n country: selectedCountry,\n });\n };\n\n const onItemClick = ({ name }: { name: string }): void => {\n const selectedCountry = name as CountryCodeType;\n setSelectedCountry(() => selectedCountry);\n handleOnChange({\n selectedCountry,\n name: inputRef.current?.name,\n value: inputRef.current?.value,\n });\n inputRef.current?.focus();\n };\n\n return (\n <BaseInput\n setInputWrapperRef={(node) => {\n inputWrapperRef.current = node as HTMLInputElement;\n }}\n ref={mergedRef}\n id=\"phone-number-input\"\n componentName={MetaConstants.PhoneNumberInput}\n label={label as string}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n defaultValue={defaultValue}\n value={value}\n name={name}\n placeholder={formatPhoneNumber('1234567890', selectedCountry)}\n trailingIcon={trailingIcon}\n leadingIcon={leadingIcon}\n prefix={showDialCode ? getDialCodeByCountryCode(selectedCountry) : undefined}\n trailingInteractionElement={renderTrailingInteractionElement()}\n leadingInteractionElement={\n showCountrySelector ? (\n <CountrySelector\n size={size}\n countryData={countryData}\n flags={flags}\n inputWrapperRef={inputWrapperRef}\n isDisabled={isDisabled}\n selectedCountry={selectedCountry}\n onItemClick={onItemClick}\n />\n ) : null\n }\n onChange={({ name, value }) => {\n if (value?.length) {\n // show the clear button when the user starts typing in\n setShouldShowClearButton(true);\n }\n if (shouldShowClearButton && !value?.length) {\n // hide the clear button when the input field is empty\n setShouldShowClearButton(false);\n }\n handleOnChange({ name, value, selectedCountry });\n }}\n onClick={onClick}\n onFocus={onFocus}\n onBlur={onBlur}\n isDisabled={isDisabled}\n accessibilityLabel={accessibilityLabel}\n necessityIndicator={necessityIndicator}\n isRequired={isRequired}\n validationState={validationState}\n errorText={errorText}\n helpText={helpText}\n successText={successText}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n size={size}\n {...getKeyboardAndAutocompleteProps({\n type: 'number',\n keyboardReturnKeyType,\n autoCompleteSuggestionType,\n autoCapitalize: 'none',\n })}\n type=\"telephone\"\n {...styledProps}\n />\n );\n};\n\n/**\n * PhoneNumberInput is a component that allows users to input phone numbers.\n * It provides a country selector dropdown to select the country code.\n *\n * @example\n *\n * ```ts\n * <PhoneNumberInput />\n * ```\n */\nconst PhoneNumberInput = assignWithoutSideEffects(React.forwardRef(_PhoneNumberInput), {\n displayName: 'PhoneNumberInput',\n});\n\nexport { PhoneNumberInput };\n"],"names":["_PhoneNumberInput","_ref","ref","_ref$defaultCountry","defaultCountry","country","onCountryChange","label","labelPosition","defaultValue","value","name","onChange","necessityIndicator","isRequired","isDisabled","leadingIcon","trailingIcon","validationState","errorText","helpText","successText","_ref$size","size","onClearButtonClick","_ref$showCountrySelec","showCountrySelector","_ref$showDialCode","showDialCode","onClick","onBlur","onFocus","_ref$accessibilityLab","accessibilityLabel","autoFocus","testID","_ref$keyboardReturnKe","keyboardReturnKeyType","autoCompleteSuggestionType","allowedCountries","styledProps","_objectWithoutProperties","_excluded","inputRef","React","useRef","mergedRef","useMergeRefs","inputWrapperRef","_React$useState","useState","_React$useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useControllableState","useControllableState","_useControllableState2","selectedCountry","setSelectedCountry","useEffect","Boolean","renderTrailingInteractionElement","_jsx","IconButton","icon","CloseIcon","_inputRef$current","isEmpty","current","HTMLInputElement","focus","flags","useMemo","getFlagsForAllCountries","countryData","map","countryCode","code","countryNameFormatter","of","Object","keys","sort","a","b","localeCompare","handleOnChange","_ref2","phoneNumber","formatPhoneNumber","undefined","dialCode","getDialCodeByCountryCode","onItemClick","_ref3","_inputRef$current2","_inputRef$current3","_inputRef$current4","BaseInput","_objectSpread","setInputWrapperRef","node","id","componentName","MetaConstants","PhoneNumberInput","hideLabelText","placeholder","prefix","trailingInteractionElement","leadingInteractionElement","CountrySelector","_ref4","length","getKeyboardAndAutocompleteProps","type","autoCapitalize","assignWithoutSideEffects","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAMA,iBAAyF,GAAG,SAA5FA,iBAAyFA,CAAAC,IAAA,EAmC7FC,GAAG,EACoB;AAAA,EAAA,IAAAC,mBAAA,GAAAF,IAAA,CAlCrBG,cAAc;AAAdA,IAAAA,cAAc,GAAAD,mBAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,mBAAA;IACrBE,OAAO,GAAAJ,IAAA,CAAPI,OAAO;IACPC,eAAe,GAAAL,IAAA,CAAfK,eAAe;IACfC,KAAK,GAAAN,IAAA,CAALM,KAAK;IACLC,aAAa,GAAAP,IAAA,CAAbO,aAAa;IACbC,YAAY,GAAAR,IAAA,CAAZQ,YAAY;IACZC,KAAK,GAAAT,IAAA,CAALS,KAAK;IACLC,IAAI,GAAAV,IAAA,CAAJU,IAAI;IACJC,QAAQ,GAAAX,IAAA,CAARW,QAAQ;IACRC,kBAAkB,GAAAZ,IAAA,CAAlBY,kBAAkB;IAClBC,UAAU,GAAAb,IAAA,CAAVa,UAAU;IACVC,UAAU,GAAAd,IAAA,CAAVc,UAAU;IACVC,WAAW,GAAAf,IAAA,CAAXe,WAAW;IACXC,YAAY,GAAAhB,IAAA,CAAZgB,YAAY;IACZC,eAAe,GAAAjB,IAAA,CAAfiB,eAAe;IACfC,SAAS,GAAAlB,IAAA,CAATkB,SAAS;IACTC,QAAQ,GAAAnB,IAAA,CAARmB,QAAQ;IACRC,WAAW,GAAApB,IAAA,CAAXoB,WAAW;IAAAC,SAAA,GAAArB,IAAA,CACXsB,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAAAA,SAAA;IACfE,kBAAkB,GAAAvB,IAAA,CAAlBuB,kBAAkB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AI,EAAJA,IAAI;AAAED,QAAAA,KAAK,EAALA,KAAK;AAAEgD,QAAAA,eAAe,EAAfA,eAAAA;AAAgB,OAAC,CAAC,CAAA;KAChD;AACF7B,IAAAA,OAAO,EAAEA,OAAQ;AACjBE,IAAAA,OAAO,EAAEA,OAAQ;AACjBD,IAAAA,MAAM,EAAEA,MAAO;AACff,IAAAA,UAAU,EAAEA,UAAW;AACvBkB,IAAAA,kBAAkB,EAAEA,kBAAmB;AACvCpB,IAAAA,kBAAkB,EAAEA,kBAAmB;AACvCC,IAAAA,UAAU,EAAEA,UAAW;AACvBI,IAAAA,eAAe,EAAEA,eAAgB;AACjCC,IAAAA,SAAS,EAAEA,SAAU;AACrBC,IAAAA,QAAQ,EAAEA,QAAS;AACnBC,IAAAA,WAAW,EAAEA,WAAAA;AACb;AAAA;AACAa,IAAAA,SAAS,EAAEA,SAAU;AACrBC,IAAAA,MAAM,EAAEA,MAAO;AACfZ,IAAAA,IAAI,EAAEA,IAAAA;AAAK,GAAA,EACP4F,+BAA+B,CAAC;AAClCC,IAAAA,IAAI,EAAE,QAAQ;AACd/E,IAAAA,qBAAqB,EAArBA,qBAAqB;AACrBC,IAAAA,0BAA0B,EAA1BA,0BAA0B;AAC1B+E,IAAAA,cAAc,EAAE,MAAA;AAClB,GAAC,CAAC,CAAA,EAAA,EAAA,EAAA;AACFD,IAAAA,IAAI,EAAC,WAAA;GACD5E,EAAAA,WAAW,CAChB,CAAC,CAAA;AAEN,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACMkE,IAAAA,gBAAgB,gBAAGY,wBAAwB,eAAC1E,cAAK,CAAC2E,UAAU,CAACvH,iBAAiB,CAAC,EAAE;AACrFwH,EAAAA,WAAW,EAAE,kBAAA;AACf,CAAC;;;;"}
1
+ {"version":3,"file":"PhoneNumberInput.web.js","sources":["../../../../../../../src/components/Input/PhoneNumberInput/PhoneNumberInput.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */\nimport type { CountryCodeType } from '@razorpay/i18nify-js';\nimport {\n formatPhoneNumber,\n getDialCodeByCountryCode,\n getFlagsForAllCountries,\n} from '@razorpay/i18nify-js';\nimport React from 'react';\nimport type { PhoneNumberInputProps } from './types';\nimport { countryNameFormatter, CountrySelector } from './CountrySelector';\nimport { BaseInput } from '~components/Input/BaseInput';\nimport { IconButton } from '~components/Button/IconButton';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { getKeyboardAndAutocompleteProps } from '~components/Input/BaseInput/utils';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { useMergeRefs } from '~utils/useMergeRefs';\nimport type { BladeElementRef } from '~utils/types';\nimport { CloseIcon } from '~components/Icons';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { useControllableState } from '~utils/useControllable';\n\nconst _PhoneNumberInput: React.ForwardRefRenderFunction<BladeElementRef, PhoneNumberInputProps> = (\n {\n defaultCountry = 'IN',\n country,\n onCountryChange,\n label,\n labelPosition,\n defaultValue,\n value,\n name,\n onChange,\n necessityIndicator,\n isRequired,\n isDisabled,\n leadingIcon,\n trailingIcon,\n validationState,\n errorText,\n helpText,\n successText,\n size = 'medium',\n onClearButtonClick,\n showCountrySelector = true,\n showDialCode = true,\n onClick,\n onBlur,\n onFocus,\n accessibilityLabel = 'Enter phone number',\n autoFocus,\n testID,\n keyboardReturnKeyType = 'done',\n autoCompleteSuggestionType,\n allowedCountries,\n placeholder,\n ...styledProps\n },\n ref,\n): React.ReactElement => {\n const inputRef = React.useRef<HTMLInputElement | null>(null);\n const mergedRef = useMergeRefs(ref, inputRef);\n\n const inputWrapperRef = React.useRef<HTMLDivElement | null>(null);\n const [shouldShowClearButton, setShouldShowClearButton] = React.useState(false);\n const [selectedCountry, setSelectedCountry] = useControllableState<CountryCodeType>({\n defaultValue: defaultCountry as CountryCodeType,\n value: country,\n onChange: (country) => onCountryChange?.({ country }),\n });\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(defaultValue ?? value));\n }, [defaultValue, value]);\n\n const renderTrailingInteractionElement = (): React.ReactNode => {\n if (!shouldShowClearButton) return null;\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(value) && inputRef.current) {\n // when the input field is uncontrolled take the ref and clear the input and then call the onClearButtonClick function\n if (inputRef.current instanceof HTMLInputElement) {\n inputRef.current.value = '';\n inputRef.current.focus();\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 inputRef?.current?.focus();\n setShouldShowClearButton(false);\n }}\n isDisabled={isDisabled}\n accessibilityLabel=\"Clear Input Content\"\n />\n );\n };\n\n const flags = React.useMemo(() => getFlagsForAllCountries(), []);\n const countryData = React.useMemo(() => {\n if (allowedCountries) {\n return allowedCountries.map((countryCode) => {\n return {\n code: countryCode,\n name: countryNameFormatter.of(countryCode)!,\n };\n });\n }\n\n return (Object.keys(flags) as CountryCodeType[])\n .map((countryCode) => {\n return {\n code: countryCode,\n name: countryNameFormatter.of(countryCode)!,\n };\n })\n .sort((a, b) => a.name.localeCompare(b.name));\n }, [allowedCountries, flags]);\n\n const handleOnChange = ({\n name,\n value,\n selectedCountry,\n }: {\n name?: string;\n value?: string;\n selectedCountry: CountryCodeType;\n }): void => {\n onChange?.({\n name: name!,\n value: value!,\n phoneNumber: value ? formatPhoneNumber(value, selectedCountry) : undefined!,\n dialCode: getDialCodeByCountryCode(selectedCountry),\n country: selectedCountry,\n });\n };\n\n const onItemClick = ({ name }: { name: string }): void => {\n const selectedCountry = name as CountryCodeType;\n setSelectedCountry(() => selectedCountry);\n handleOnChange({\n selectedCountry,\n name: inputRef.current?.name,\n value: inputRef.current?.value,\n });\n inputRef.current?.focus();\n };\n\n return (\n <BaseInput\n setInputWrapperRef={(node) => {\n inputWrapperRef.current = node as HTMLInputElement;\n }}\n ref={mergedRef}\n id=\"phone-number-input\"\n componentName={MetaConstants.PhoneNumberInput}\n label={label as string}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n defaultValue={defaultValue}\n value={value}\n name={name}\n placeholder={placeholder ?? formatPhoneNumber('1234567890', selectedCountry)}\n trailingIcon={trailingIcon}\n leadingIcon={leadingIcon}\n prefix={showDialCode ? getDialCodeByCountryCode(selectedCountry) : undefined}\n trailingInteractionElement={renderTrailingInteractionElement()}\n leadingInteractionElement={\n showCountrySelector ? (\n <CountrySelector\n size={size}\n countryData={countryData}\n flags={flags}\n inputWrapperRef={inputWrapperRef}\n isDisabled={isDisabled}\n selectedCountry={selectedCountry}\n onItemClick={onItemClick}\n />\n ) : null\n }\n onChange={({ name, value }) => {\n if (value?.length) {\n // show the clear button when the user starts typing in\n setShouldShowClearButton(true);\n }\n if (shouldShowClearButton && !value?.length) {\n // hide the clear button when the input field is empty\n setShouldShowClearButton(false);\n }\n handleOnChange({ name, value, selectedCountry });\n }}\n onClick={onClick}\n onFocus={onFocus}\n onBlur={onBlur}\n isDisabled={isDisabled}\n accessibilityLabel={accessibilityLabel}\n necessityIndicator={necessityIndicator}\n isRequired={isRequired}\n validationState={validationState}\n errorText={errorText}\n helpText={helpText}\n successText={successText}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n size={size}\n {...getKeyboardAndAutocompleteProps({\n type: 'number',\n keyboardReturnKeyType,\n autoCompleteSuggestionType,\n autoCapitalize: 'none',\n })}\n type=\"telephone\"\n {...styledProps}\n />\n );\n};\n\n/**\n * PhoneNumberInput is a component that allows users to input phone numbers.\n * It provides a country selector dropdown to select the country code.\n *\n * @example\n *\n * ```ts\n * <PhoneNumberInput />\n * ```\n */\nconst PhoneNumberInput = assignWithoutSideEffects(React.forwardRef(_PhoneNumberInput), {\n displayName: 'PhoneNumberInput',\n});\n\nexport { PhoneNumberInput };\n"],"names":["_PhoneNumberInput","_ref","ref","_ref$defaultCountry","defaultCountry","country","onCountryChange","label","labelPosition","defaultValue","value","name","onChange","necessityIndicator","isRequired","isDisabled","leadingIcon","trailingIcon","validationState","errorText","helpText","successText","_ref$size","size","onClearButtonClick","_ref$showCountrySelec","showCountrySelector","_ref$showDialCode","showDialCode","onClick","onBlur","onFocus","_ref$accessibilityLab","accessibilityLabel","autoFocus","testID","_ref$keyboardReturnKe","keyboardReturnKeyType","autoCompleteSuggestionType","allowedCountries","placeholder","styledProps","_objectWithoutProperties","_excluded","inputRef","React","useRef","mergedRef","useMergeRefs","inputWrapperRef","_React$useState","useState","_React$useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useControllableState","useControllableState","_useControllableState2","selectedCountry","setSelectedCountry","useEffect","Boolean","renderTrailingInteractionElement","_jsx","IconButton","icon","CloseIcon","_inputRef$current","isEmpty","current","HTMLInputElement","focus","flags","useMemo","getFlagsForAllCountries","countryData","map","countryCode","code","countryNameFormatter","of","Object","keys","sort","a","b","localeCompare","handleOnChange","_ref2","phoneNumber","formatPhoneNumber","undefined","dialCode","getDialCodeByCountryCode","onItemClick","_ref3","_inputRef$current2","_inputRef$current3","_inputRef$current4","BaseInput","_objectSpread","setInputWrapperRef","node","id","componentName","MetaConstants","PhoneNumberInput","hideLabelText","prefix","trailingInteractionElement","leadingInteractionElement","CountrySelector","_ref4","length","getKeyboardAndAutocompleteProps","type","autoCapitalize","assignWithoutSideEffects","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAMA,iBAAyF,GAAG,SAA5FA,iBAAyFA,CAAAC,IAAA,EAoC7FC,GAAG,EACoB;AAAA,EAAA,IAAAC,mBAAA,GAAAF,IAAA,CAnCrBG,cAAc;AAAdA,IAAAA,cAAc,GAAAD,mBAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,mBAAA;IACrBE,OAAO,GAAAJ,IAAA,CAAPI,OAAO;IACPC,eAAe,GAAAL,IAAA,CAAfK,eAAe;IACfC,KAAK,GAAAN,IAAA,CAALM,KAAK;IACLC,aAAa,GAAAP,IAAA,C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EAAEA,SAAU;AACrBC,IAAAA,QAAQ,EAAEA,QAAS;AACnBC,IAAAA,WAAW,EAAEA,WAAAA;AACb;AAAA;AACAa,IAAAA,SAAS,EAAEA,SAAU;AACrBC,IAAAA,MAAM,EAAEA,MAAO;AACfZ,IAAAA,IAAI,EAAEA,IAAAA;AAAK,GAAA,EACP4F,+BAA+B,CAAC;AAClCC,IAAAA,IAAI,EAAE,QAAQ;AACd/E,IAAAA,qBAAqB,EAArBA,qBAAqB;AACrBC,IAAAA,0BAA0B,EAA1BA,0BAA0B;AAC1B+E,IAAAA,cAAc,EAAE,MAAA;AAClB,GAAC,CAAC,CAAA,EAAA,EAAA,EAAA;AACFD,IAAAA,IAAI,EAAC,WAAA;GACD3E,EAAAA,WAAW,CAChB,CAAC,CAAA;AAEN,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACMkE,IAAAA,gBAAgB,gBAAGW,wBAAwB,eAACzE,cAAK,CAAC0E,UAAU,CAACvH,iBAAiB,CAAC,EAAE;AACrFwH,EAAAA,WAAW,EAAE,kBAAA;AACf,CAAC;;;;"}
@@ -58,7 +58,7 @@ var _Radio = function _Radio(_ref, ref) {
58
58
  var _isDisabled = isDisabled !== null && isDisabled !== void 0 ? isDisabled : groupProps === null || groupProps === void 0 ? void 0 : groupProps.isDisabled;
59
59
  var _isRequired = (groupProps === null || groupProps === void 0 ? void 0 : groupProps.isRequired) || (groupProps === null || groupProps === void 0 ? void 0 : groupProps.necessityIndicator) === 'required';
60
60
  var name = groupProps === null || groupProps === void 0 ? void 0 : groupProps.name;
61
- var showHelpText = !hasError && helpText;
61
+ var showHelpText = helpText;
62
62
  var isReactNative = getPlatformType() === 'react-native';
63
63
  var _size = (_groupProps$size = groupProps.size) !== null && _groupProps$size !== void 0 ? _groupProps$size : size;
64
64
  var handleChange = function handleChange(_ref2) {
@@ -121,7 +121,6 @@ var _Radio = function _Radio(_ref, ref) {
121
121
  marginLeft: helpTextLeftSpacing,
122
122
  children: /*#__PURE__*/jsx(SelectorSupportText, {
123
123
  size: _size,
124
- isNegative: true,
125
124
  id: ids === null || ids === void 0 ? void 0 : ids.helpTextId,
126
125
  children: helpText
127
126
  })
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.js","sources":["../../../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport type { OnChange } from './useRadio';\nimport { useRadio } from './useRadio';\nimport { RadioIcon } from './RadioIcon/RadioIcon';\nimport { useRadioGroupContext } from './RadioGroup/RadioContext';\nimport { radioHoverTokens, radioSizes } from './radioTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport BaseBox from '~components/Box/BaseBox';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport type { BladeElementRef, StringChildrenType, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType, makeSize, useTheme } from '~utils';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { throwBladeError } from '~utils/logger';\n\ntype RadioProps = {\n /**\n * Sets the label text of the Radio\n */\n children?: StringChildrenType;\n /**\n * Help text for the Radio\n */\n helpText?: string;\n /**\n * The value to be used in the Radio input.\n * This is the value that will be returned on form submission.\n */\n value: string;\n /**\n * If `true`, the Radio will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Size of the radios\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n StyledPropsBlade;\n\nconst _Radio: React.ForwardRefRenderFunction<BladeElementRef, RadioProps> = (\n { value, children, helpText, isDisabled, size = 'medium', testID, ...styledProps },\n ref,\n) => {\n const { theme } = useTheme();\n const groupProps = useRadioGroupContext();\n const isInsideGroup = !isEmpty(groupProps);\n\n if (__DEV__) {\n if (!isInsideGroup) {\n throwBladeError({\n moduleName: 'Radio',\n message: 'Cannot use <Radio /> outside of <RadioGroup />',\n });\n }\n }\n\n const isChecked = groupProps?.state?.isChecked(value);\n const defaultChecked =\n groupProps?.defaultValue === undefined ? undefined : groupProps?.defaultValue === value;\n const validationState = groupProps?.validationState;\n const hasError = validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = groupProps?.isRequired || groupProps?.necessityIndicator === 'required';\n const name = groupProps?.name;\n const showHelpText = !hasError && helpText;\n const isReactNative = getPlatformType() === 'react-native';\n const _size = groupProps.size ?? size;\n\n const handleChange: OnChange = ({ isChecked, value }) => {\n if (isChecked) {\n groupProps?.state?.setValue(value!);\n } else {\n groupProps?.state?.removeValue();\n }\n };\n\n const { state, ids, inputProps } = useRadio({\n defaultChecked,\n isChecked,\n hasError,\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name,\n value,\n onChange: handleChange,\n });\n\n // radio icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(radioSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox {...getStyledProps(styledProps)}>\n <SelectorLabel\n componentName={MetaConstants.RadioLabel}\n inputProps={isReactNative ? inputProps : {}}\n testID={testID}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" alignItems=\"center\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={radioHoverTokens}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n hasError={hasError}\n inputProps={inputProps}\n ref={ref}\n />\n <RadioIcon\n size={_size}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n isNegative={hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showHelpText && (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} isNegative={true} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n )}\n </BaseBox>\n </SelectorLabel>\n </BaseBox>\n );\n};\n\nconst Radio = assignWithoutSideEffects(React.forwardRef(_Radio), { displayName: 'Radio' });\n\nexport type { RadioProps };\nexport { Radio };\n"],"names":["_Radio","_ref","ref","_groupProps$state","_groupProps$size","value","children","helpText","isDisabled","_ref$size","size","testID","styledProps","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","groupProps","useRadioGroupContext","isInsideGroup","isEmpty","throwBladeError","moduleName","message","isChecked","state","defaultChecked","defaultValue","undefined","validationState","hasError","_isDisabled","_isRequired","isRequired","necessityIndicator","name","showHelpText","isReactNative","getPlatformType","_size","handleChange","_ref2","_groupProps$state2","setValue","_groupProps$state3","removeValue","_useRadio","useRadio","onChange","ids","inputProps","helpTextLeftSpacing","makeSize","radioSizes","icon","width","spacing","_jsx","BaseBox","_objectSpread","getStyledProps","SelectorLabel","componentName","MetaConstants","RadioLabel","_jsxs","display","flexDirection","alignItems","SelectorInput","hoverTokens","radioHoverTokens","RadioIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","Radio","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAMA,MAAmE,GAAG,SAAtEA,MAAmEA,CAAAC,IAAA,EAEvEC,GAAG,EACA;EAAA,IAAAC,iBAAA,EAAAC,gBAAA,CAAA;AAAA,EAAA,IAFDC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IAAEC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;IAAEC,UAAU,GAAAP,IAAA,CAAVO,UAAU;IAAAC,SAAA,GAAAR,IAAA,CAAES,IAAI;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C,QAAA,eACvCoD,GAAA,CAACmB,mBAAmB,EAAA;AAACnE,YAAAA,IAAI,EAAE8B,KAAM;AAACkC,YAAAA,UAAU,EAAE,IAAK;AAACI,YAAAA,EAAE,EAAE5B,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAHA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,GAAG,CAAE6B,UAAW;AAAAzE,YAAAA,QAAA,EACrEC,QAAAA;WACkB,CAAA;AAAC,SACf,CACV,CAAA;OACM,CAAA;KACI,CAAA;AAAC,GAAA,CACT,CAAC,CAAA;AAEd,CAAC,CAAA;AAEKyE,IAAAA,KAAK,gBAAGC,wBAAwB,eAACC,cAAK,CAACC,UAAU,CAACnF,MAAM,CAAC,EAAE;AAAEoF,EAAAA,WAAW,EAAE,OAAA;AAAQ,CAAC;;;;"}
1
+ {"version":3,"file":"Radio.js","sources":["../../../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport type { OnChange } from './useRadio';\nimport { useRadio } from './useRadio';\nimport { RadioIcon } from './RadioIcon/RadioIcon';\nimport { useRadioGroupContext } from './RadioGroup/RadioContext';\nimport { radioHoverTokens, radioSizes } from './radioTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport BaseBox from '~components/Box/BaseBox';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport type { BladeElementRef, StringChildrenType, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType, makeSize, useTheme } from '~utils';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { throwBladeError } from '~utils/logger';\n\ntype RadioProps = {\n /**\n * Sets the label text of the Radio\n */\n children?: StringChildrenType;\n /**\n * Help text for the Radio\n */\n helpText?: string;\n /**\n * The value to be used in the Radio input.\n * This is the value that will be returned on form submission.\n */\n value: string;\n /**\n * If `true`, the Radio will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Size of the radios\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n StyledPropsBlade;\n\nconst _Radio: React.ForwardRefRenderFunction<BladeElementRef, RadioProps> = (\n { value, children, helpText, isDisabled, size = 'medium', testID, ...styledProps },\n ref,\n) => {\n const { theme } = useTheme();\n const groupProps = useRadioGroupContext();\n const isInsideGroup = !isEmpty(groupProps);\n\n if (__DEV__) {\n if (!isInsideGroup) {\n throwBladeError({\n moduleName: 'Radio',\n message: 'Cannot use <Radio /> outside of <RadioGroup />',\n });\n }\n }\n\n const isChecked = groupProps?.state?.isChecked(value);\n const defaultChecked =\n groupProps?.defaultValue === undefined ? undefined : groupProps?.defaultValue === value;\n const validationState = groupProps?.validationState;\n const hasError = validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = groupProps?.isRequired || groupProps?.necessityIndicator === 'required';\n const name = groupProps?.name;\n const showHelpText = helpText;\n const isReactNative = getPlatformType() === 'react-native';\n const _size = groupProps.size ?? size;\n\n const handleChange: OnChange = ({ isChecked, value }) => {\n if (isChecked) {\n groupProps?.state?.setValue(value!);\n } else {\n groupProps?.state?.removeValue();\n }\n };\n\n const { state, ids, inputProps } = useRadio({\n defaultChecked,\n isChecked,\n hasError,\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name,\n value,\n onChange: handleChange,\n });\n\n // radio icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(radioSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox {...getStyledProps(styledProps)}>\n <SelectorLabel\n componentName={MetaConstants.RadioLabel}\n inputProps={isReactNative ? inputProps : {}}\n testID={testID}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" alignItems=\"center\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={radioHoverTokens}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n hasError={hasError}\n inputProps={inputProps}\n ref={ref}\n />\n <RadioIcon\n size={_size}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n isNegative={hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showHelpText && (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n )}\n </BaseBox>\n </SelectorLabel>\n </BaseBox>\n );\n};\n\nconst Radio = assignWithoutSideEffects(React.forwardRef(_Radio), { displayName: 'Radio' });\n\nexport type { RadioProps };\nexport { Radio };\n"],"names":["_Radio","_ref","ref","_groupProps$state","_groupProps$size","value","children","helpText","isDisabled","_ref$size","size","testID","styledProps","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","groupProps","useRadioGroupContext","isInsideGroup","isEmpty","throwBladeError","moduleName","message","isChecked","state","defaultChecked","defaultValue","undefined","validationState","hasError","_isDisabled","_isRequired","isRequired","necessityIndicator","name","showHelpText","isReactNative","getPlatformType","_size","handleChange","_ref2","_groupProps$state2","setValue","_groupProps$state3","removeValue","_useRadio","useRadio","onChange","ids","inputProps","helpTextLeftSpacing","makeSize","radioSizes","icon","width","spacing","_jsx","BaseBox","_objectSpread","getStyledProps","SelectorLabel","componentName","MetaConstants","RadioLabel","_jsxs","display","flexDirection","alignItems","SelectorInput","hoverTokens","radioHoverTokens","RadioIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","Radio","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;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YAAAA,UAAU,EAAE3C,QAAAA;AAAS,WACtB,CAAC,EACDzB,QAAQ,gBACPoD,GAAA,CAACiB,aAAa,EAAA;AAACjE,YAAAA,IAAI,EAAE8B,KAAM;AAAChC,YAAAA,UAAU,EAAEwB,WAAY;AAAA1B,YAAAA,QAAA,EACjDA,QAAAA;WACY,CAAC,GACd,IAAI,CAAA;AAAA,SACD,CAAC,EACT+B,YAAY,iBACXqB,GAAA,CAACC,OAAO,EAAA;AAACiB,UAAAA,UAAU,EAAExB,mBAAoB;UAAA9C,QAAA,eACvCoD,GAAA,CAACmB,mBAAmB,EAAA;AAACnE,YAAAA,IAAI,EAAE8B,KAAM;AAACsC,YAAAA,EAAE,EAAE5B,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAHA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,GAAG,CAAE6B,UAAW;AAAAzE,YAAAA,QAAA,EACnDC,QAAAA;WACkB,CAAA;AAAC,SACf,CACV,CAAA;OACM,CAAA;KACI,CAAA;AAAC,GAAA,CACT,CAAC,CAAA;AAEd,CAAC,CAAA;AAEKyE,IAAAA,KAAK,gBAAGC,wBAAwB,eAACC,cAAK,CAACC,UAAU,CAACnF,MAAM,CAAC,EAAE;AAAEoF,EAAAA,WAAW,EAAE,OAAA;AAAQ,CAAC;;;;"}
@@ -89,10 +89,7 @@ var _Checkbox = function _Checkbox(_ref, ref) {
89
89
  medium: 'medium',
90
90
  large: 'large'
91
91
  };
92
-
93
- // only show error when the self validation is set to error
94
- // Since we don't want to show errorText inside the group
95
- var showSupportingText = validationState !== 'error' && helpText;
92
+ var showSupportingText = helpText;
96
93
  var handleChange = function handleChange(_ref2) {
97
94
  var isChecked = _ref2.isChecked,
98
95
  event = _ref2.event,
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","sources":["../../../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport { useCheckboxGroupContext } from './CheckboxGroup/CheckboxGroupContext';\nimport { CheckboxIcon } from './CheckboxIcon';\nimport { useCheckbox } from './useCheckbox';\nimport { checkboxHoverTokens, checkboxSizes } from './checkboxTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport isUndefined from '~utils/lodashButBetter/isUndefined';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport BaseBox from '~components/Box/BaseBox';\nimport { FormHint } from '~components/Form';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport type { BladeElementRef, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { throwBladeError } from '~utils/logger';\nimport { makeSize, useTheme } from '~utils';\n\ntype OnChange = ({\n isChecked,\n event,\n value,\n}: {\n isChecked: boolean;\n event?: React.ChangeEvent;\n value?: string;\n}) => void;\n\ntype CheckboxProps = {\n /**\n * If `true`, The checkbox will be checked. This also makes the checkbox controlled\n * Use `onChange` to update its value\n *\n * @default false\n */\n isChecked?: boolean;\n /**\n * If `true`, the checkbox will be initially checked. This also makes the checkbox uncontrolled\n *\n * @default false\n */\n defaultChecked?: boolean;\n /**\n * The callback invoked when the checked state of the `Checkbox` changes.\n */\n onChange?: OnChange;\n /**\n * Sets the label of the checkbox\n */\n children?: React.ReactNode;\n /**\n * Help text for the checkbox\n */\n helpText?: string;\n /**\n * Error text for the checkbox\n *\n * Renders when `validationState` is set to 'error'\n */\n errorText?: string;\n /**\n * If `true`, the checkbox will be indeterminate.\n * This does not modify the isChecked property.\n *\n * @default false\n */\n isIndeterminate?: boolean;\n /**\n * The name of the input field in a checkbox\n * (Useful for form submission).\n */\n name?: string;\n /**\n * The value to be used in the checkbox input.\n * This is the value that will be returned on form submission.\n */\n value?: string;\n /**\n * If `true`, the checkbox will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * If `true`, the checkbox input is marked as required,\n * and `required` attribute will be added\n *\n * @default false\n */\n isRequired?: boolean;\n /**\n * If `error`, the checkbox input is marked as invalid,\n * and `invalid` attribute will be added\n */\n validationState?: 'error' | 'none';\n /**\n * Size of the checkbox\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n /**\n * Sets the tab-index property on checkbox element\n *\n */\n tabIndex?: number;\n} & TestID &\n StyledPropsBlade;\n\nconst _Checkbox: React.ForwardRefRenderFunction<BladeElementRef, CheckboxProps> = (\n {\n defaultChecked,\n validationState,\n isChecked,\n isDisabled,\n isIndeterminate,\n isRequired,\n name,\n onChange,\n value,\n children,\n helpText,\n errorText,\n size = 'medium',\n tabIndex,\n testID,\n ...styledProps\n },\n ref,\n) => {\n const groupProps = useCheckboxGroupContext();\n\n // ban certain props in checkbox while inside group\n const hasValidationState = !isUndefined(validationState);\n const hasName = !isUndefined(name);\n const hasDefaultChecked = !isUndefined(defaultChecked);\n const hasIsChecked = !isUndefined(isChecked);\n const hasOnChange = !isUndefined(onChange);\n\n if (__DEV__) {\n if (\n (hasValidationState || hasName || hasDefaultChecked || hasIsChecked || hasOnChange) &&\n !isEmpty(groupProps)\n ) {\n const props = [\n hasValidationState ? 'validationState' : undefined,\n hasName ? 'name' : undefined,\n hasDefaultChecked ? 'defaultChecked' : undefined,\n hasIsChecked ? 'isChecked' : undefined,\n hasOnChange ? 'onChange' : undefined,\n ]\n .filter(Boolean)\n .join(',');\n\n throwBladeError({\n message: `Cannot set \\`${props}\\` on <Checkbox /> when it's inside <CheckboxGroup />, Please set it on the <CheckboxGroup /> itself`,\n moduleName: 'Checkbox',\n });\n }\n\n // mandate value prop when using inside group\n if (!value && !isEmpty(groupProps)) {\n throw new Error(\n `[Blade Checkbox]: <CheckboxGroup /> requires that you pass unique \"value\" prop to each <Checkbox />\n <CheckboxGroup>\n <Checkbox value=\"apple\">Apple</Checkbox>\n <Checkbox value=\"mango\">Mango</Checkbox>\n </CheckboxGroup>\n `,\n );\n }\n }\n\n const _validationState = validationState ?? groupProps?.validationState;\n const _hasError = _validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = Boolean(\n isRequired || groupProps?.isRequired || groupProps?.necessityIndicator === 'required',\n );\n const _name = name ?? groupProps?.name;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const _isChecked = isChecked ?? groupProps?.state?.isChecked(value!);\n const _size = groupProps.size ?? size;\n const { theme } = useTheme();\n const formHintSize = {\n small: 'medium',\n medium: 'medium',\n large: 'large',\n } as const;\n\n // only show error when the self validation is set to error\n // Since we don't want to show errorText inside the group\n const showSupportingText = validationState !== 'error' && helpText;\n\n const handleChange: OnChange = ({ isChecked, event, value }) => {\n if (isChecked) {\n groupProps?.state?.addValue(value!);\n } else {\n groupProps?.state?.removeValue(value!);\n }\n\n onChange?.({ isChecked, event, value });\n };\n\n const { state, ids, inputProps } = useCheckbox({\n defaultChecked,\n isChecked: _isChecked,\n isIndeterminate,\n hasError: _hasError,\n hasHelperText: Boolean(showSupportingText),\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name: _name,\n value,\n onChange: handleChange,\n });\n\n // Checkbox icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(checkboxSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox\n {...metaAttribute({ name: MetaConstants.Checkbox, testID })}\n {...getStyledProps(styledProps)}\n >\n <SelectorLabel\n componentName={MetaConstants.CheckboxLabel}\n inputProps={state.isReactNative ? inputProps : {}}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={checkboxHoverTokens}\n isChecked={state.isChecked || Boolean(isIndeterminate)}\n isDisabled={_isDisabled}\n hasError={_hasError}\n inputProps={inputProps}\n tabIndex={tabIndex}\n ref={ref}\n />\n <CheckboxIcon\n size={_size}\n isChecked={state.isChecked}\n isIndeterminate={isIndeterminate}\n isDisabled={_isDisabled}\n isNegative={_hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showSupportingText ? (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n ) : null}\n </BaseBox>\n </SelectorLabel>\n <FormHint\n size={formHintSize[_size]}\n errorText={errorText}\n errorTextId={ids?.errorTextId}\n type={validationState === 'error' ? 'error' : 'help'}\n />\n </BaseBox>\n );\n};\n\nconst Checkbox = assignWithoutSideEffects(React.forwardRef(_Checkbox), {\n displayName: 'Checkbox',\n});\n\nexport type { CheckboxProps };\nexport { Checkbox };\n"],"names":["_Checkbox","_ref","ref","_groupProps$state","_groupProps$size","defaultChecked","validationState","isChecked","isDisabled","isIndeterminate","isRequired","name","onChange","value","children","helpText","errorText","_ref$size","size","tabIndex","testID","styledProps","_objectWithoutProperties","_excluded","groupProps","useCheckboxGroupContext","hasValidationState","isUndefined","hasName","hasDefaultChecked","hasIsChecked","hasOnChange","isEmpty","props","undefined","filter","Boolean","join","throwBladeError","message","concat","moduleName","Error","_validationState","_hasError","_isDisabled","_isRequired","necessityIndicator","_name","_isChecked","state","_size","_useTheme","useTheme","theme","formHintSize","small","medium","large","showSupportingText","handleChange","_ref2","event","_groupProps$state2","addValue","_groupProps$state3","removeValue","_useCheckbox","useCheckbox","hasError","hasHelperText","ids","inputProps","helpTextLeftSpacing","makeSize","checkboxSizes","icon","width","spacing","_jsxs","BaseBox","_objectSpread","metaAttribute","MetaConstants","Checkbox","getStyledProps","_jsx","SelectorLabel","componentName","CheckboxLabel","isReactNative","display","flexDirection","SelectorInput","hoverTokens","checkboxHoverTokens","CheckboxIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","FormHint","errorTextId","type","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,IAAMA,SAAyE,GAAG,SAA5EA,SAAyEA,CAAAC,IAAA,EAmB7EC,GAAG,EACA;EAAA,IAAAC,iBAAA,EAAAC,gBAAA,CAAA;AAAA,EAAA,IAlBDC,cAAc,GAAAJ,IAAA,CAAdI,cAAc;IACdC,eAAe,GAAAL,IAAA,CAAfK,eAAe;IACfC,SAAS,GAAAN,IAAA,CAATM,SAAS;IACTC,UAAU,GAAAP,IAAA,CAAVO,UAAU;IACVC,eAAe,GAAAR,IAAA,CAAfQ,eAAe;IACfC,UAAU,GAAAT,IAAA,CAAVS,UAAU;IACVC,IAAI,GAAAV,IAAA,CAAJU,IAAI;IACJC,QAAQ,GAAAX,IAAA,CAARW,QAAQ;IACRC,KAAK,GAAAZ,IAAA,CAALY,KAAK;IACLC,QAAQ,GAAAb,IAAA,CAARa,QAAQ;IACRC,QAAQ,GAAAd,IAAA,CAARc,QAAQ;IACRC,SAAS,GAAAf,IAAA,CAATe,SAAS;IAAAC,SAAA,GAAAhB,IAAA,CACTiB,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAAAA,SAAA;IACfE,QAAQ,GAAAlB,IAAA,CAARkB,QAAQ;IACRC,MAAM,GAAAnB,IAAA,CAANmB,MAAM;AACHC,IAAAA,WAAW,GAAAC,wBAAA,CAAArB,IAAA,EAAAsB,SAAA,CAAA,CAAA;AAIhB,EAAA,IAAMC,UAAU,GAAGC,uBAAuB,EAAE,CAAA;;AAE5C;AACA,EAAA,IAAMC,kBAAkB,GAAG,CAACC,WAAW,CAACrB,eAAe,CAAC,CAAA;AACxD,EAAA,IAAMsB,OAAO,GAAG,CAACD,WAAW,CA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AAA,IAAI,EAAEiC,KAAM;AAACkD,YAAAA,EAAE,EAAE9B,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAHA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,GAAG,CAAE+B,UAAW;AAAAxF,YAAAA,QAAA,EACnDC,QAAAA;WACkB,CAAA;SACd,CAAC,GACR,IAAI,CAAA;OACD,CAAA;AAAC,KACG,CAAC,eAChBuE,GAAA,CAACiB,QAAQ,EAAA;AACPrF,MAAAA,IAAI,EAAEqC,YAAY,CAACJ,KAAK,CAAE;AAC1BnC,MAAAA,SAAS,EAAEA,SAAU;AACrBwF,MAAAA,WAAW,EAAEjC,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAHA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,GAAG,CAAEiC,WAAY;AAC9BC,MAAAA,IAAI,EAAEnG,eAAe,KAAK,OAAO,GAAG,OAAO,GAAG,MAAA;AAAO,KACtD,CAAC,CAAA;AAAA,GAAA,CACK,CAAC,CAAA;AAEd,CAAC,CAAA;AAEK8E,IAAAA,QAAQ,gBAAGsB,wBAAwB,eAACC,cAAK,CAACC,UAAU,CAAC5G,SAAS,CAAC,EAAE;AACrE6G,EAAAA,WAAW,EAAE,UAAA;AACf,CAAC;;;;"}
1
+ {"version":3,"file":"Checkbox.js","sources":["../../../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport { useCheckboxGroupContext } from './CheckboxGroup/CheckboxGroupContext';\nimport { CheckboxIcon } from './CheckboxIcon';\nimport { useCheckbox } from './useCheckbox';\nimport { checkboxHoverTokens, checkboxSizes } from './checkboxTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport isUndefined from '~utils/lodashButBetter/isUndefined';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport BaseBox from '~components/Box/BaseBox';\nimport { FormHint } from '~components/Form';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport type { BladeElementRef, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { throwBladeError } from '~utils/logger';\nimport { makeSize, useTheme } from '~utils';\n\ntype OnChange = ({\n isChecked,\n event,\n value,\n}: {\n isChecked: boolean;\n event?: React.ChangeEvent;\n value?: string;\n}) => void;\n\ntype CheckboxProps = {\n /**\n * If `true`, The checkbox will be checked. This also makes the checkbox controlled\n * Use `onChange` to update its value\n *\n * @default false\n */\n isChecked?: boolean;\n /**\n * If `true`, the checkbox will be initially checked. This also makes the checkbox uncontrolled\n *\n * @default false\n */\n defaultChecked?: boolean;\n /**\n * The callback invoked when the checked state of the `Checkbox` changes.\n */\n onChange?: OnChange;\n /**\n * Sets the label of the checkbox\n */\n children?: React.ReactNode;\n /**\n * Help text for the checkbox\n */\n helpText?: string;\n /**\n * Error text for the checkbox\n *\n * Renders when `validationState` is set to 'error'\n */\n errorText?: string;\n /**\n * If `true`, the checkbox will be indeterminate.\n * This does not modify the isChecked property.\n *\n * @default false\n */\n isIndeterminate?: boolean;\n /**\n * The name of the input field in a checkbox\n * (Useful for form submission).\n */\n name?: string;\n /**\n * The value to be used in the checkbox input.\n * This is the value that will be returned on form submission.\n */\n value?: string;\n /**\n * If `true`, the checkbox will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * If `true`, the checkbox input is marked as required,\n * and `required` attribute will be added\n *\n * @default false\n */\n isRequired?: boolean;\n /**\n * If `error`, the checkbox input is marked as invalid,\n * and `invalid` attribute will be added\n */\n validationState?: 'error' | 'none';\n /**\n * Size of the checkbox\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n /**\n * Sets the tab-index property on checkbox element\n *\n */\n tabIndex?: number;\n} & TestID &\n StyledPropsBlade;\n\nconst _Checkbox: React.ForwardRefRenderFunction<BladeElementRef, CheckboxProps> = (\n {\n defaultChecked,\n validationState,\n isChecked,\n isDisabled,\n isIndeterminate,\n isRequired,\n name,\n onChange,\n value,\n children,\n helpText,\n errorText,\n size = 'medium',\n tabIndex,\n testID,\n ...styledProps\n },\n ref,\n) => {\n const groupProps = useCheckboxGroupContext();\n\n // ban certain props in checkbox while inside group\n const hasValidationState = !isUndefined(validationState);\n const hasName = !isUndefined(name);\n const hasDefaultChecked = !isUndefined(defaultChecked);\n const hasIsChecked = !isUndefined(isChecked);\n const hasOnChange = !isUndefined(onChange);\n\n if (__DEV__) {\n if (\n (hasValidationState || hasName || hasDefaultChecked || hasIsChecked || hasOnChange) &&\n !isEmpty(groupProps)\n ) {\n const props = [\n hasValidationState ? 'validationState' : undefined,\n hasName ? 'name' : undefined,\n hasDefaultChecked ? 'defaultChecked' : undefined,\n hasIsChecked ? 'isChecked' : undefined,\n hasOnChange ? 'onChange' : undefined,\n ]\n .filter(Boolean)\n .join(',');\n\n throwBladeError({\n message: `Cannot set \\`${props}\\` on <Checkbox /> when it's inside <CheckboxGroup />, Please set it on the <CheckboxGroup /> itself`,\n moduleName: 'Checkbox',\n });\n }\n\n // mandate value prop when using inside group\n if (!value && !isEmpty(groupProps)) {\n throw new Error(\n `[Blade Checkbox]: <CheckboxGroup /> requires that you pass unique \"value\" prop to each <Checkbox />\n <CheckboxGroup>\n <Checkbox value=\"apple\">Apple</Checkbox>\n <Checkbox value=\"mango\">Mango</Checkbox>\n </CheckboxGroup>\n `,\n );\n }\n }\n\n const _validationState = validationState ?? groupProps?.validationState;\n const _hasError = _validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = Boolean(\n isRequired || groupProps?.isRequired || groupProps?.necessityIndicator === 'required',\n );\n const _name = name ?? groupProps?.name;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const _isChecked = isChecked ?? groupProps?.state?.isChecked(value!);\n const _size = groupProps.size ?? size;\n const { theme } = useTheme();\n const formHintSize = {\n small: 'medium',\n medium: 'medium',\n large: 'large',\n } as const;\n\n const showSupportingText = helpText;\n\n const handleChange: OnChange = ({ isChecked, event, value }) => {\n if (isChecked) {\n groupProps?.state?.addValue(value!);\n } else {\n groupProps?.state?.removeValue(value!);\n }\n\n onChange?.({ isChecked, event, value });\n };\n\n const { state, ids, inputProps } = useCheckbox({\n defaultChecked,\n isChecked: _isChecked,\n isIndeterminate,\n hasError: _hasError,\n hasHelperText: Boolean(showSupportingText),\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name: _name,\n value,\n onChange: handleChange,\n });\n\n // Checkbox icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(checkboxSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox\n {...metaAttribute({ name: MetaConstants.Checkbox, testID })}\n {...getStyledProps(styledProps)}\n >\n <SelectorLabel\n componentName={MetaConstants.CheckboxLabel}\n inputProps={state.isReactNative ? inputProps : {}}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={checkboxHoverTokens}\n isChecked={state.isChecked || Boolean(isIndeterminate)}\n isDisabled={_isDisabled}\n hasError={_hasError}\n inputProps={inputProps}\n tabIndex={tabIndex}\n ref={ref}\n />\n <CheckboxIcon\n size={_size}\n isChecked={state.isChecked}\n isIndeterminate={isIndeterminate}\n isDisabled={_isDisabled}\n isNegative={_hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showSupportingText ? (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n ) : null}\n </BaseBox>\n </SelectorLabel>\n <FormHint\n size={formHintSize[_size]}\n errorText={errorText}\n errorTextId={ids?.errorTextId}\n type={validationState === 'error' ? 'error' : 'help'}\n />\n </BaseBox>\n );\n};\n\nconst Checkbox = assignWithoutSideEffects(React.forwardRef(_Checkbox), {\n displayName: 'Checkbox',\n});\n\nexport type { CheckboxProps };\nexport { Checkbox };\n"],"names":["_Checkbox","_ref","ref","_groupProps$state","_groupProps$size","defaultChecked","validationState","isChecked","isDisabled","isIndeterminate","isRequired","name","onChange","value","children","helpText","errorText","_ref$size","size","tabIndex","testID","styledProps","_objectWithoutProperties","_excluded","groupProps","useCheckboxGroupContext","hasValidationState","isUndefined","hasName","hasDefaultChecked","hasIsChecked","hasOnChange","isEmpty","props","undefined","filter","Boolean","join","throwBladeError","message","concat","moduleName","Error","_validationState","_hasError","_isDisabled","_isRequired","necessityIndicator","_name","_isChecked","state","_size","_useTheme","useTheme","theme","formHintSize","small","medium","large","showSupportingText","handleChange","_ref2","event","_groupProps$state2","addValue","_groupProps$state3","removeValue","_useCheckbox","useCheckbox","hasError","hasHelperText","ids","inputProps","helpTextLeftSpacing","makeSize","checkboxSizes","icon","width","spacing","_jsxs","BaseBox","_objectSpread","metaAttribute","MetaConstants","Checkbox","getStyledProps","_jsx","SelectorLabel","componentName","CheckboxLabel","isReactNative","display","flexDirection","SelectorInput","hoverTokens","checkboxHoverTokens","CheckboxIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","FormHint","errorTextId","type","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,IAAMA,SAAyE,GAAG,SAA5EA,SAAyEA,CAAAC,IAAA,EAmB7EC,GAAG,EACA;EAAA,IAAAC,iBAAA,EAAAC,gBAAA,CAAA;AAAA,EAAA,IAlBDC,cAAc,GAAAJ,IAAA,CAAdI,cA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wF,MAAAA,WAAW,EAAEjC,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAHA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,GAAG,CAAEiC,WAAY;AAC9BC,MAAAA,IAAI,EAAEnG,eAAe,KAAK,OAAO,GAAG,OAAO,GAAG,MAAA;AAAO,KACtD,CAAC,CAAA;AAAA,GAAA,CACK,CAAC,CAAA;AAEd,CAAC,CAAA;AAEK8E,IAAAA,QAAQ,gBAAGsB,wBAAwB,eAACC,cAAK,CAACC,UAAU,CAAC5G,SAAS,CAAC,EAAE;AACrE6G,EAAAA,WAAW,EAAE,UAAA;AACf,CAAC;;;;"}
@@ -20,7 +20,7 @@ import { BaseInput } from '../BaseInput/BaseInput.js';
20
20
  import { MetaConstants } from '../../../utils/metaAttribute/metaConstants.js';
21
21
  import { assignWithoutSideEffects } from '../../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
22
22
 
23
- var _excluded = ["defaultCountry", "country", "onCountryChange", "label", "labelPosition", "defaultValue", "value", "name", "onChange", "necessityIndicator", "isRequired", "isDisabled", "leadingIcon", "trailingIcon", "validationState", "errorText", "helpText", "successText", "size", "onClearButtonClick", "showCountrySelector", "showDialCode", "onClick", "onBlur", "onFocus", "accessibilityLabel", "autoFocus", "testID", "keyboardReturnKeyType", "autoCompleteSuggestionType", "allowedCountries"];
23
+ var _excluded = ["defaultCountry", "country", "onCountryChange", "label", "labelPosition", "defaultValue", "value", "name", "onChange", "necessityIndicator", "isRequired", "isDisabled", "leadingIcon", "trailingIcon", "validationState", "errorText", "helpText", "successText", "size", "onClearButtonClick", "showCountrySelector", "showDialCode", "onClick", "onBlur", "onFocus", "accessibilityLabel", "autoFocus", "testID", "keyboardReturnKeyType", "autoCompleteSuggestionType", "allowedCountries", "placeholder"];
24
24
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25
25
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
26
26
  var _PhoneNumberInput = function _PhoneNumberInput(_ref, ref) {
@@ -61,6 +61,7 @@ var _PhoneNumberInput = function _PhoneNumberInput(_ref, ref) {
61
61
  keyboardReturnKeyType = _ref$keyboardReturnKe === void 0 ? 'done' : _ref$keyboardReturnKe,
62
62
  autoCompleteSuggestionType = _ref.autoCompleteSuggestionType,
63
63
  allowedCountries = _ref.allowedCountries,
64
+ placeholder = _ref.placeholder,
64
65
  styledProps = _objectWithoutProperties(_ref, _excluded);
65
66
  var inputRef = React__default.useRef(null);
66
67
  var mergedRef = useMergeRefs(ref, inputRef);
@@ -167,7 +168,7 @@ var _PhoneNumberInput = function _PhoneNumberInput(_ref, ref) {
167
168
  defaultValue: defaultValue,
168
169
  value: value,
169
170
  name: name,
170
- placeholder: formatPhoneNumber('1234567890', selectedCountry),
171
+ placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : formatPhoneNumber('1234567890', selectedCountry),
171
172
  trailingIcon: trailingIcon,
172
173
  leadingIcon: leadingIcon,
173
174
  prefix: showDialCode ? getDialCodeByCountryCode(selectedCountry) : undefined,
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneNumberInput.web.js","sources":["../../../../../../../src/components/Input/PhoneNumberInput/PhoneNumberInput.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */\nimport type { CountryCodeType } from '@razorpay/i18nify-js';\nimport {\n formatPhoneNumber,\n getDialCodeByCountryCode,\n getFlagsForAllCountries,\n} from '@razorpay/i18nify-js';\nimport React from 'react';\nimport type { PhoneNumberInputProps } from './types';\nimport { countryNameFormatter, CountrySelector } from './CountrySelector';\nimport { BaseInput } from '~components/Input/BaseInput';\nimport { IconButton } from '~components/Button/IconButton';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { getKeyboardAndAutocompleteProps } from '~components/Input/BaseInput/utils';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { useMergeRefs } from '~utils/useMergeRefs';\nimport type { BladeElementRef } from '~utils/types';\nimport { CloseIcon } from '~components/Icons';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { useControllableState } from '~utils/useControllable';\n\nconst _PhoneNumberInput: React.ForwardRefRenderFunction<BladeElementRef, PhoneNumberInputProps> = (\n {\n defaultCountry = 'IN',\n country,\n onCountryChange,\n label,\n labelPosition,\n defaultValue,\n value,\n name,\n onChange,\n necessityIndicator,\n isRequired,\n isDisabled,\n leadingIcon,\n trailingIcon,\n validationState,\n errorText,\n helpText,\n successText,\n size = 'medium',\n onClearButtonClick,\n showCountrySelector = true,\n showDialCode = true,\n onClick,\n onBlur,\n onFocus,\n accessibilityLabel = 'Enter phone number',\n autoFocus,\n testID,\n keyboardReturnKeyType = 'done',\n autoCompleteSuggestionType,\n allowedCountries,\n ...styledProps\n },\n ref,\n): React.ReactElement => {\n const inputRef = React.useRef<HTMLInputElement | null>(null);\n const mergedRef = useMergeRefs(ref, inputRef);\n\n const inputWrapperRef = React.useRef<HTMLDivElement | null>(null);\n const [shouldShowClearButton, setShouldShowClearButton] = React.useState(false);\n const [selectedCountry, setSelectedCountry] = useControllableState<CountryCodeType>({\n defaultValue: defaultCountry as CountryCodeType,\n value: country,\n onChange: (country) => onCountryChange?.({ country }),\n });\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(defaultValue ?? value));\n }, [defaultValue, value]);\n\n const renderTrailingInteractionElement = (): React.ReactNode => {\n if (!shouldShowClearButton) return null;\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(value) && inputRef.current) {\n // when the input field is uncontrolled take the ref and clear the input and then call the onClearButtonClick function\n if (inputRef.current instanceof HTMLInputElement) {\n inputRef.current.value = '';\n inputRef.current.focus();\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 inputRef?.current?.focus();\n setShouldShowClearButton(false);\n }}\n isDisabled={isDisabled}\n accessibilityLabel=\"Clear Input Content\"\n />\n );\n };\n\n const flags = React.useMemo(() => getFlagsForAllCountries(), []);\n const countryData = React.useMemo(() => {\n if (allowedCountries) {\n return allowedCountries.map((countryCode) => {\n return {\n code: countryCode,\n name: countryNameFormatter.of(countryCode)!,\n };\n });\n }\n\n return (Object.keys(flags) as CountryCodeType[])\n .map((countryCode) => {\n return {\n code: countryCode,\n name: countryNameFormatter.of(countryCode)!,\n };\n })\n .sort((a, b) => a.name.localeCompare(b.name));\n }, [allowedCountries, flags]);\n\n const handleOnChange = ({\n name,\n value,\n selectedCountry,\n }: {\n name?: string;\n value?: string;\n selectedCountry: CountryCodeType;\n }): void => {\n onChange?.({\n name: name!,\n value: value!,\n phoneNumber: value ? formatPhoneNumber(value, selectedCountry) : undefined!,\n dialCode: getDialCodeByCountryCode(selectedCountry),\n country: selectedCountry,\n });\n };\n\n const onItemClick = ({ name }: { name: string }): void => {\n const selectedCountry = name as CountryCodeType;\n setSelectedCountry(() => selectedCountry);\n handleOnChange({\n selectedCountry,\n name: inputRef.current?.name,\n value: inputRef.current?.value,\n });\n inputRef.current?.focus();\n };\n\n return (\n <BaseInput\n setInputWrapperRef={(node) => {\n inputWrapperRef.current = node as HTMLInputElement;\n }}\n ref={mergedRef}\n id=\"phone-number-input\"\n componentName={MetaConstants.PhoneNumberInput}\n label={label as string}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n defaultValue={defaultValue}\n value={value}\n name={name}\n placeholder={formatPhoneNumber('1234567890', selectedCountry)}\n trailingIcon={trailingIcon}\n leadingIcon={leadingIcon}\n prefix={showDialCode ? getDialCodeByCountryCode(selectedCountry) : undefined}\n trailingInteractionElement={renderTrailingInteractionElement()}\n leadingInteractionElement={\n showCountrySelector ? (\n <CountrySelector\n size={size}\n countryData={countryData}\n flags={flags}\n inputWrapperRef={inputWrapperRef}\n isDisabled={isDisabled}\n selectedCountry={selectedCountry}\n onItemClick={onItemClick}\n />\n ) : null\n }\n onChange={({ name, value }) => {\n if (value?.length) {\n // show the clear button when the user starts typing in\n setShouldShowClearButton(true);\n }\n if (shouldShowClearButton && !value?.length) {\n // hide the clear button when the input field is empty\n setShouldShowClearButton(false);\n }\n handleOnChange({ name, value, selectedCountry });\n }}\n onClick={onClick}\n onFocus={onFocus}\n onBlur={onBlur}\n isDisabled={isDisabled}\n accessibilityLabel={accessibilityLabel}\n necessityIndicator={necessityIndicator}\n isRequired={isRequired}\n validationState={validationState}\n errorText={errorText}\n helpText={helpText}\n successText={successText}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n size={size}\n {...getKeyboardAndAutocompleteProps({\n type: 'number',\n keyboardReturnKeyType,\n autoCompleteSuggestionType,\n autoCapitalize: 'none',\n })}\n type=\"telephone\"\n {...styledProps}\n />\n );\n};\n\n/**\n * PhoneNumberInput is a component that allows users to input phone numbers.\n * It provides a country selector dropdown to select the country code.\n *\n * @example\n *\n * ```ts\n * <PhoneNumberInput />\n * ```\n */\nconst PhoneNumberInput = assignWithoutSideEffects(React.forwardRef(_PhoneNumberInput), {\n displayName: 'PhoneNumberInput',\n});\n\nexport { PhoneNumberInput };\n"],"names":["_PhoneNumberInput","_ref","ref","_ref$defaultCountry","defaultCountry","country","onCountryChange","label","labelPosition","defaultValue","value","name","onChange","necessityIndicator","isRequired","isDisabled","leadingIcon","trailingIcon","validationState","errorText","helpText","successText","_ref$size","size","onClearButtonClick","_ref$showCountrySelec","showCountrySelector","_ref$showDialCode","showDialCode","onClick","onBlur","onFocus","_ref$accessibilityLab","accessibilityLabel","autoFocus","testID","_ref$keyboardReturnKe","keyboardReturnKeyType","autoCompleteSuggestionType","allowedCountries","styledProps","_objectWithoutProperties","_excluded","inputRef","React","useRef","mergedRef","useMergeRefs","inputWrapperRef","_React$useState","useState","_React$useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useControllableState","useControllableState","_useControllableState2","selectedCountry","setSelectedCountry","useEffect","Boolean","renderTrailingInteractionElement","_jsx","IconButton","icon","CloseIcon","_inputRef$current","isEmpty","current","HTMLInputElement","focus","flags","useMemo","getFlagsForAllCountries","countryData","map","countryCode","code","countryNameFormatter","of","Object","keys","sort","a","b","localeCompare","handleOnChange","_ref2","phoneNumber","formatPhoneNumber","undefined","dialCode","getDialCodeByCountryCode","onItemClick","_ref3","_inputRef$current2","_inputRef$current3","_inputRef$current4","BaseInput","_objectSpread","setInputWrapperRef","node","id","componentName","MetaConstants","PhoneNumberInput","hideLabelText","placeholder","prefix","trailingInteractionElement","leadingInteractionElement","CountrySelector","_ref4","length","getKeyboardAndAutocompleteProps","type","autoCapitalize","assignWithoutSideEffects","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAMA,iBAAyF,GAAG,SAA5FA,iBAAyFA,CAAAC,IAAA,EAmC7FC,GAAG,EACoB;AAAA,EAAA,IAAAC,mBAAA,GAAAF,IAAA,CAlCrBG,cAAc;AAAdA,IAAAA,cAAc,GAAAD,mBAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,mBAAA;IACrBE,OAAO,GAAAJ,IAAA,CAAPI,OAAO;IACPC,eAAe,GAAAL,IAAA,CAAfK,eAAe;IACfC,KAAK,GAAAN,IAAA,CAALM,KAAK;IACLC,aAAa,GAAAP,IAAA,CAAbO,aAAa;IACbC,YAAY,GAAAR,IAAA,CAAZQ,YAAY;IACZC,KAAK,GAAAT,IAAA,CAALS,KAAK;IACLC,IAAI,GAAAV,IAAA,CAAJU,IAAI;IACJC,QAAQ,GAAAX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ACd/E,IAAAA,qBAAqB,EAArBA,qBAAqB;AACrBC,IAAAA,0BAA0B,EAA1BA,0BAA0B;AAC1B+E,IAAAA,cAAc,EAAE,MAAA;AAClB,GAAC,CAAC,CAAA,EAAA,EAAA,EAAA;AACFD,IAAAA,IAAI,EAAC,WAAA;GACD5E,EAAAA,WAAW,CAChB,CAAC,CAAA;AAEN,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACMkE,IAAAA,gBAAgB,gBAAGY,wBAAwB,eAAC1E,cAAK,CAAC2E,UAAU,CAACvH,iBAAiB,CAAC,EAAE;AACrFwH,EAAAA,WAAW,EAAE,kBAAA;AACf,CAAC;;;;"}
1
+ {"version":3,"file":"PhoneNumberInput.web.js","sources":["../../../../../../../src/components/Input/PhoneNumberInput/PhoneNumberInput.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */\nimport type { CountryCodeType } from '@razorpay/i18nify-js';\nimport {\n formatPhoneNumber,\n getDialCodeByCountryCode,\n getFlagsForAllCountries,\n} from '@razorpay/i18nify-js';\nimport React from 'react';\nimport type { PhoneNumberInputProps } from './types';\nimport { countryNameFormatter, CountrySelector } from './CountrySelector';\nimport { BaseInput } from '~components/Input/BaseInput';\nimport { IconButton } from '~components/Button/IconButton';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { getKeyboardAndAutocompleteProps } from '~components/Input/BaseInput/utils';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { useMergeRefs } from '~utils/useMergeRefs';\nimport type { BladeElementRef } from '~utils/types';\nimport { CloseIcon } from '~components/Icons';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { useControllableState } from '~utils/useControllable';\n\nconst _PhoneNumberInput: React.ForwardRefRenderFunction<BladeElementRef, PhoneNumberInputProps> = (\n {\n defaultCountry = 'IN',\n country,\n onCountryChange,\n label,\n labelPosition,\n defaultValue,\n value,\n name,\n onChange,\n necessityIndicator,\n isRequired,\n isDisabled,\n leadingIcon,\n trailingIcon,\n validationState,\n errorText,\n helpText,\n successText,\n size = 'medium',\n onClearButtonClick,\n showCountrySelector = true,\n showDialCode = true,\n onClick,\n onBlur,\n onFocus,\n accessibilityLabel = 'Enter phone number',\n autoFocus,\n testID,\n keyboardReturnKeyType = 'done',\n autoCompleteSuggestionType,\n allowedCountries,\n placeholder,\n ...styledProps\n },\n ref,\n): React.ReactElement => {\n const inputRef = React.useRef<HTMLInputElement | null>(null);\n const mergedRef = useMergeRefs(ref, inputRef);\n\n const inputWrapperRef = React.useRef<HTMLDivElement | null>(null);\n const [shouldShowClearButton, setShouldShowClearButton] = React.useState(false);\n const [selectedCountry, setSelectedCountry] = useControllableState<CountryCodeType>({\n defaultValue: defaultCountry as CountryCodeType,\n value: country,\n onChange: (country) => onCountryChange?.({ country }),\n });\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(defaultValue ?? value));\n }, [defaultValue, value]);\n\n const renderTrailingInteractionElement = (): React.ReactNode => {\n if (!shouldShowClearButton) return null;\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(value) && inputRef.current) {\n // when the input field is uncontrolled take the ref and clear the input and then call the onClearButtonClick function\n if (inputRef.current instanceof HTMLInputElement) {\n inputRef.current.value = '';\n inputRef.current.focus();\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 inputRef?.current?.focus();\n setShouldShowClearButton(false);\n }}\n isDisabled={isDisabled}\n accessibilityLabel=\"Clear Input Content\"\n />\n );\n };\n\n const flags = React.useMemo(() => getFlagsForAllCountries(), []);\n const countryData = React.useMemo(() => {\n if (allowedCountries) {\n return allowedCountries.map((countryCode) => {\n return {\n code: countryCode,\n name: countryNameFormatter.of(countryCode)!,\n };\n });\n }\n\n return (Object.keys(flags) as CountryCodeType[])\n .map((countryCode) => {\n return {\n code: countryCode,\n name: countryNameFormatter.of(countryCode)!,\n };\n })\n .sort((a, b) => a.name.localeCompare(b.name));\n }, [allowedCountries, flags]);\n\n const handleOnChange = ({\n name,\n value,\n selectedCountry,\n }: {\n name?: string;\n value?: string;\n selectedCountry: CountryCodeType;\n }): void => {\n onChange?.({\n name: name!,\n value: value!,\n phoneNumber: value ? formatPhoneNumber(value, selectedCountry) : undefined!,\n dialCode: getDialCodeByCountryCode(selectedCountry),\n country: selectedCountry,\n });\n };\n\n const onItemClick = ({ name }: { name: string }): void => {\n const selectedCountry = name as CountryCodeType;\n setSelectedCountry(() => selectedCountry);\n handleOnChange({\n selectedCountry,\n name: inputRef.current?.name,\n value: inputRef.current?.value,\n });\n inputRef.current?.focus();\n };\n\n return (\n <BaseInput\n setInputWrapperRef={(node) => {\n inputWrapperRef.current = node as HTMLInputElement;\n }}\n ref={mergedRef}\n id=\"phone-number-input\"\n componentName={MetaConstants.PhoneNumberInput}\n label={label as string}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n defaultValue={defaultValue}\n value={value}\n name={name}\n placeholder={placeholder ?? formatPhoneNumber('1234567890', selectedCountry)}\n trailingIcon={trailingIcon}\n leadingIcon={leadingIcon}\n prefix={showDialCode ? getDialCodeByCountryCode(selectedCountry) : undefined}\n trailingInteractionElement={renderTrailingInteractionElement()}\n leadingInteractionElement={\n showCountrySelector ? (\n <CountrySelector\n size={size}\n countryData={countryData}\n flags={flags}\n inputWrapperRef={inputWrapperRef}\n isDisabled={isDisabled}\n selectedCountry={selectedCountry}\n onItemClick={onItemClick}\n />\n ) : null\n }\n onChange={({ name, value }) => {\n if (value?.length) {\n // show the clear button when the user starts typing in\n setShouldShowClearButton(true);\n }\n if (shouldShowClearButton && !value?.length) {\n // hide the clear button when the input field is empty\n setShouldShowClearButton(false);\n }\n handleOnChange({ name, value, selectedCountry });\n }}\n onClick={onClick}\n onFocus={onFocus}\n onBlur={onBlur}\n isDisabled={isDisabled}\n accessibilityLabel={accessibilityLabel}\n necessityIndicator={necessityIndicator}\n isRequired={isRequired}\n validationState={validationState}\n errorText={errorText}\n helpText={helpText}\n successText={successText}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n size={size}\n {...getKeyboardAndAutocompleteProps({\n type: 'number',\n keyboardReturnKeyType,\n autoCompleteSuggestionType,\n autoCapitalize: 'none',\n })}\n type=\"telephone\"\n {...styledProps}\n />\n );\n};\n\n/**\n * PhoneNumberInput is a component that allows users to input phone numbers.\n * It provides a country selector dropdown to select the country code.\n *\n * @example\n *\n * ```ts\n * <PhoneNumberInput />\n * ```\n */\nconst PhoneNumberInput = assignWithoutSideEffects(React.forwardRef(_PhoneNumberInput), {\n displayName: 'PhoneNumberInput',\n});\n\nexport { PhoneNumberInput };\n"],"names":["_PhoneNumberInput","_ref","ref","_ref$defaultCountry","defaultCountry","country","onCountryChange","label","labelPosition","defaultValue","value","name","onChange","necessityIndicator","isRequired","isDisabled","leadingIcon","trailingIcon","validationState","errorText","helpText","successText","_ref$size","size","onClearButtonClick","_ref$showCountrySelec","showCountrySelector","_ref$showDialCode","showDialCode","onClick","onBlur","onFocus","_ref$accessibilityLab","accessibilityLabel","autoFocus","testID","_ref$keyboardReturnKe","keyboardReturnKeyType","autoCompleteSuggestionType","allowedCountries","placeholder","styledProps","_objectWithoutProperties","_excluded","inputRef","React","useRef","mergedRef","useMergeRefs","inputWrapperRef","_React$useState","useState","_React$useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useControllableState","useControllableState","_useControllableState2","selectedCountry","setSelectedCountry","useEffect","Boolean","renderTrailingInteractionElement","_jsx","IconButton","icon","CloseIcon","_inputRef$current","isEmpty","current","HTMLInputElement","focus","flags","useMemo","getFlagsForAllCountries","countryData","map","countryCode","code","countryNameFormatter","of","Object","keys","sort","a","b","localeCompare","handleOnChange","_ref2","phoneNumber","formatPhoneNumber","undefined","dialCode","getDialCodeByCountryCode","onItemClick","_ref3","_inputRef$current2","_inputRef$current3","_inputRef$current4","BaseInput","_objectSpread","setInputWrapperRef","node","id","componentName","MetaConstants","PhoneNumberInput","hideLabelText","prefix","trailingInteractionElement","leadingInteractionElement","CountrySelector","_ref4","length","getKeyboardAndAutocompleteProps","type","autoCapitalize","assignWithoutSideEffects","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAMA,iBAAyF,GAAG,SAA5FA,iBAAyFA,CAAAC,IAAA,EAoC7FC,GAAG,EACoB;AAAA,EAAA,IAAAC,mBAAA,GAAAF,IAAA,CAnCrBG,cAAc;AAAdA,IAAAA,cAAc,GAAAD,mBAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,mBAAA;IACrBE,OAAO,GAAAJ,IAAA,CAAPI,OAAO;IACPC,eAAe,GAAAL,IAAA,CAAfK,eAAe;IACfC,KAAK,GAAAN,IAAA,CAALM,KAAK;IACLC,aAAa,GAAAP,IAAA,CAAbO,aAAa;IACbC,YAAY,GAAAR,IAAA,CAAZQ,YAAY;IACZC,KAAK,GAAAT,IAAA,CAALS,KAAK;IACLC,IAAI,GAAAV,IAAA,CAAJU,IAAI;IACJC,QAAQ,GAAAX,IAAA,CAARW,QAAQ;IACRC,kBAAkB,GAAAZ,IAAA,CAAlBY,kBAAkB;IAClBC,UAAU,GAAAb,IAAA,CAAVa,UAAU;IACVC,UAAU,GAAAd,IAAA,CAAVc,UAAU;IACVC,WAAW,GAAAf,IAAA,CAAXe,WAAW;IACXC,YAAY,GAAAhB,IAAA,CAAZgB,YAAY;IACZC,eAAe,GAAAjB,IAAA,CAAfiB,eAAe;IACfC,SAAS,GAAAlB,IAAA,CAATkB,SAAS;IACTC,QAAQ,GAAAnB,IAAA,CAARmB,QAAQ;IACRC,WAAW,GAAApB,IAAA,CAAXoB,WAAW;IAAAC,SAAA,GAAArB,IAAA,CACXsB,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAAAA,SAAA;IACfE,kBAAkB,GAAAvB,IAAA,CA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A;AACf,CAAC;;;;"}
@@ -58,7 +58,7 @@ var _Radio = function _Radio(_ref, ref) {
58
58
  var _isDisabled = isDisabled !== null && isDisabled !== void 0 ? isDisabled : groupProps === null || groupProps === void 0 ? void 0 : groupProps.isDisabled;
59
59
  var _isRequired = (groupProps === null || groupProps === void 0 ? void 0 : groupProps.isRequired) || (groupProps === null || groupProps === void 0 ? void 0 : groupProps.necessityIndicator) === 'required';
60
60
  var name = groupProps === null || groupProps === void 0 ? void 0 : groupProps.name;
61
- var showHelpText = !hasError && helpText;
61
+ var showHelpText = helpText;
62
62
  var isReactNative = getPlatformType() === 'react-native';
63
63
  var _size = (_groupProps$size = groupProps.size) !== null && _groupProps$size !== void 0 ? _groupProps$size : size;
64
64
  var handleChange = function handleChange(_ref2) {
@@ -121,7 +121,6 @@ var _Radio = function _Radio(_ref, ref) {
121
121
  marginLeft: helpTextLeftSpacing,
122
122
  children: /*#__PURE__*/jsx(SelectorSupportText, {
123
123
  size: _size,
124
- isNegative: true,
125
124
  id: ids === null || ids === void 0 ? void 0 : ids.helpTextId,
126
125
  children: helpText
127
126
  })
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.js","sources":["../../../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport type { OnChange } from './useRadio';\nimport { useRadio } from './useRadio';\nimport { RadioIcon } from './RadioIcon/RadioIcon';\nimport { useRadioGroupContext } from './RadioGroup/RadioContext';\nimport { radioHoverTokens, radioSizes } from './radioTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport BaseBox from '~components/Box/BaseBox';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport type { BladeElementRef, StringChildrenType, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType, makeSize, useTheme } from '~utils';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { throwBladeError } from '~utils/logger';\n\ntype RadioProps = {\n /**\n * Sets the label text of the Radio\n */\n children?: StringChildrenType;\n /**\n * Help text for the Radio\n */\n helpText?: string;\n /**\n * The value to be used in the Radio input.\n * This is the value that will be returned on form submission.\n */\n value: string;\n /**\n * If `true`, the Radio will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Size of the radios\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n StyledPropsBlade;\n\nconst _Radio: React.ForwardRefRenderFunction<BladeElementRef, RadioProps> = (\n { value, children, helpText, isDisabled, size = 'medium', testID, ...styledProps },\n ref,\n) => {\n const { theme } = useTheme();\n const groupProps = useRadioGroupContext();\n const isInsideGroup = !isEmpty(groupProps);\n\n if (__DEV__) {\n if (!isInsideGroup) {\n throwBladeError({\n moduleName: 'Radio',\n message: 'Cannot use <Radio /> outside of <RadioGroup />',\n });\n }\n }\n\n const isChecked = groupProps?.state?.isChecked(value);\n const defaultChecked =\n groupProps?.defaultValue === undefined ? undefined : groupProps?.defaultValue === value;\n const validationState = groupProps?.validationState;\n const hasError = validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = groupProps?.isRequired || groupProps?.necessityIndicator === 'required';\n const name = groupProps?.name;\n const showHelpText = !hasError && helpText;\n const isReactNative = getPlatformType() === 'react-native';\n const _size = groupProps.size ?? size;\n\n const handleChange: OnChange = ({ isChecked, value }) => {\n if (isChecked) {\n groupProps?.state?.setValue(value!);\n } else {\n groupProps?.state?.removeValue();\n }\n };\n\n const { state, ids, inputProps } = useRadio({\n defaultChecked,\n isChecked,\n hasError,\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name,\n value,\n onChange: handleChange,\n });\n\n // radio icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(radioSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox {...getStyledProps(styledProps)}>\n <SelectorLabel\n componentName={MetaConstants.RadioLabel}\n inputProps={isReactNative ? inputProps : {}}\n testID={testID}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" alignItems=\"center\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={radioHoverTokens}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n hasError={hasError}\n inputProps={inputProps}\n ref={ref}\n />\n <RadioIcon\n size={_size}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n isNegative={hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showHelpText && (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} isNegative={true} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n )}\n </BaseBox>\n </SelectorLabel>\n </BaseBox>\n );\n};\n\nconst Radio = assignWithoutSideEffects(React.forwardRef(_Radio), { displayName: 'Radio' });\n\nexport type { RadioProps };\nexport { Radio };\n"],"names":["_Radio","_ref","ref","_groupProps$state","_groupProps$size","value","children","helpText","isDisabled","_ref$size","size","testID","styledProps","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","groupProps","useRadioGroupContext","isInsideGroup","isEmpty","throwBladeError","moduleName","message","isChecked","state","defaultChecked","defaultValue","undefined","validationState","hasError","_isDisabled","_isRequired","isRequired","necessityIndicator","name","showHelpText","isReactNative","getPlatformType","_size","handleChange","_ref2","_groupProps$state2","setValue","_groupProps$state3","removeValue","_useRadio","useRadio","onChange","ids","inputProps","helpTextLeftSpacing","makeSize","radioSizes","icon","width","spacing","_jsx","BaseBox","_objectSpread","getStyledProps","SelectorLabel","componentName","MetaConstants","RadioLabel","_jsxs","display","flexDirection","alignItems","SelectorInput","hoverTokens","radioHoverTokens","RadioIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","Radio","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAMA,MAAmE,GAAG,SAAtEA,MAAmEA,CAAAC,IAAA,EAEvEC,GAAG,EACA;EAAA,IAAAC,iBAAA,EAAAC,gBAAA,CAAA;AAAA,EAAA,IAFDC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IAAEC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;IAAEC,UAAU,GAAAP,IAAA,CAAVO,UAAU;IAAAC,SAAA,GAAAR,IAAA,CAAES,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAAAA,SAAA;IAAEE,MAAM,GAAAV,IAAA,CAANU,MAAM;AAAKC,IAAAA,WAAW,GAAAC,wBAAA,CAAAZ,IAAA,EAAAa,SAAA,CAAA,CAAA;AAGhF,EAAA,IAAAC,SAAA,GAAkBC,QAAQ,EAAE;IAApBC,KAAK,GAAAF,SAAA,CAALE,KAAK,CAAA;AACb,EAAA,IAAMC,UAAU,GAAGC,oBAAoB,EAAE,CAAA;AACzC,EAAA,IAAMC,aAAa,GAAG,CAACC,OAAO,CAACH,UAAU,CAAC,CAAA;AAE1C,EAAA,IAAI,KAAO,EAAE;IACX,IAAI,CAACE,aAAa,EAAE;AAClBE,MAAAA,eAAe,CAAC;AACdC,QAAAA,UAAU,EAAE,OAAO;AACnBC,QAAAA,OAAO,EAAE,gDAAA;AACX,OAAC,CAAC,CAAA;AACJ,KAAA;AACF,GAAA;AAEA,EAAA,IAAMC,SAAS,GAAGP,UAAU,aAAVA,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,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,EAAEA,UAAW;AACvBjD,YAAAA,GAAG,EAAEA,GAAAA;AAAI,WACV,CAAC,eACFwD,GAAA,CAACe,SAAS,EAAA;AACR/D,YAAAA,IAAI,EAAE8B,KAAM;YACZf,SAAS,EAAEC,KAAK,CAACD,SAAU;AAC3BjB,YAAAA,UAAU,EAAEwB,WAAY;AACxB0C,YAAAA,UAAU,EAAE3C,QAAAA;AAAS,WACtB,CAAC,EACDzB,QAAQ,gBACPoD,GAAA,CAACiB,aAAa,EAAA;AAACjE,YAAAA,IAAI,EAAE8B,KAAM;AAAChC,YAAAA,UAAU,EAAEwB,WAAY;AAAA1B,YAAAA,QAAA,EACjDA,QAAAA;WACY,CAAC,GACd,IAAI,CAAA;AAAA,SACD,CAAC,EACT+B,YAAY,iBACXqB,GAAA,CAACC,OAAO,EAAA;AAACiB,UAAAA,UAAU,EAAExB,mBAAoB;UAAA9C,QAAA,eACvCoD,GAAA,CAACmB,mBAAmB,EAAA;AAACnE,YAAAA,IAAI,EAAE8B,KAAM;AAACkC,YAAAA,UAAU,EAAE,IAAK;AAACI,YAAAA,EAAE,EAAE5B,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAHA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,GAAG,CAAE6B,UAAW;AAAAzE,YAAAA,QAAA,EACrEC,QAAAA;WACkB,CAAA;AAAC,SACf,CACV,CAAA;OACM,CAAA;KACI,CAAA;AAAC,GAAA,CACT,CAAC,CAAA;AAEd,CAAC,CAAA;AAEKyE,IAAAA,KAAK,gBAAGC,wBAAwB,eAACC,cAAK,CAACC,UAAU,CAACnF,MAAM,CAAC,EAAE;AAAEoF,EAAAA,WAAW,EAAE,OAAA;AAAQ,CAAC;;;;"}
1
+ {"version":3,"file":"Radio.js","sources":["../../../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport type { OnChange } from './useRadio';\nimport { useRadio } from './useRadio';\nimport { RadioIcon } from './RadioIcon/RadioIcon';\nimport { useRadioGroupContext } from './RadioGroup/RadioContext';\nimport { radioHoverTokens, radioSizes } from './radioTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport BaseBox from '~components/Box/BaseBox';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport type { BladeElementRef, StringChildrenType, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType, makeSize, useTheme } from '~utils';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { throwBladeError } from '~utils/logger';\n\ntype RadioProps = {\n /**\n * Sets the label text of the Radio\n */\n children?: StringChildrenType;\n /**\n * Help text for the Radio\n */\n helpText?: string;\n /**\n * The value to be used in the Radio input.\n * This is the value that will be returned on form submission.\n */\n value: string;\n /**\n * If `true`, the Radio will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Size of the radios\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n StyledPropsBlade;\n\nconst _Radio: React.ForwardRefRenderFunction<BladeElementRef, RadioProps> = (\n { value, children, helpText, isDisabled, size = 'medium', testID, ...styledProps },\n ref,\n) => {\n const { theme } = useTheme();\n const groupProps = useRadioGroupContext();\n const isInsideGroup = !isEmpty(groupProps);\n\n if (__DEV__) {\n if (!isInsideGroup) {\n throwBladeError({\n moduleName: 'Radio',\n message: 'Cannot use <Radio /> outside of <RadioGroup />',\n });\n }\n }\n\n const isChecked = groupProps?.state?.isChecked(value);\n const defaultChecked =\n groupProps?.defaultValue === undefined ? undefined : groupProps?.defaultValue === value;\n const validationState = groupProps?.validationState;\n const hasError = validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = groupProps?.isRequired || groupProps?.necessityIndicator === 'required';\n const name = groupProps?.name;\n const showHelpText = helpText;\n const isReactNative = getPlatformType() === 'react-native';\n const _size = groupProps.size ?? size;\n\n const handleChange: OnChange = ({ isChecked, value }) => {\n if (isChecked) {\n groupProps?.state?.setValue(value!);\n } else {\n groupProps?.state?.removeValue();\n }\n };\n\n const { state, ids, inputProps } = useRadio({\n defaultChecked,\n isChecked,\n hasError,\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name,\n value,\n onChange: handleChange,\n });\n\n // radio icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(radioSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox {...getStyledProps(styledProps)}>\n <SelectorLabel\n componentName={MetaConstants.RadioLabel}\n inputProps={isReactNative ? inputProps : {}}\n testID={testID}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" alignItems=\"center\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={radioHoverTokens}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n hasError={hasError}\n inputProps={inputProps}\n ref={ref}\n />\n <RadioIcon\n size={_size}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n isNegative={hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showHelpText && (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n )}\n </BaseBox>\n </SelectorLabel>\n </BaseBox>\n );\n};\n\nconst Radio = assignWithoutSideEffects(React.forwardRef(_Radio), { displayName: 'Radio' });\n\nexport type { RadioProps };\nexport { Radio };\n"],"names":["_Radio","_ref","ref","_groupProps$state","_groupProps$size","value","children","helpText","isDisabled","_ref$size","size","testID","styledProps","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","groupProps","useRadioGroupContext","isInsideGroup","isEmpty","throwBladeError","moduleName","message","isChecked","state","defaultChecked","defaultValue","undefined","validationState","hasError","_isDisabled","_isRequired","isRequired","necessityIndicator","name","showHelpText","isReactNative","getPlatformType","_size","handleChange","_ref2","_groupProps$state2","setValue","_groupProps$state3","removeValue","_useRadio","useRadio","onChange","ids","inputProps","helpTextLeftSpacing","makeSize","radioSizes","icon","width","spacing","_jsx","BaseBox","_objectSpread","getStyledProps","SelectorLabel","componentName","MetaConstants","RadioLabel","_jsxs","display","flexDirection","alignItems","SelectorInput","hoverTokens","radioHoverTokens","RadioIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","Radio","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAMA,MAAmE,GAAG,SAAtEA,MAAmEA,CAAAC,IAAA,EAEvEC,GAAG,EACA;EAAA,IAAAC,iBAAA,EAAAC,gBAAA,CAAA;AAAA,EAAA,IAFDC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IAAEC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;IAAEC,UAAU,GAAAP,IAAA,CAAVO,UAAU;IAAAC,SAAA,GAAAR,IAAA,CAAES,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAAAA,SAAA;IAAEE,MAAM,GAAAV,IAAA,CAANU,MAAM;AAAKC,IAAAA,WAAW,GAAAC,wBAAA,CAAAZ,IAAA,EAAAa,SAAA,CAAA,CAAA;AAGhF,EAAA,IAAAC,SAAA,GAAkBC,QAAQ,EAAE;IAApBC,KAAK,GAAAF,SAAA,CAALE,KAAK,CAAA;AACb,EAAA,IAAMC,UAAU,GAAGC,oBAAoB,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AAEKyE,IAAAA,KAAK,gBAAGC,wBAAwB,eAACC,cAAK,CAACC,UAAU,CAACnF,MAAM,CAAC,EAAE;AAAEoF,EAAAA,WAAW,EAAE,OAAA;AAAQ,CAAC;;;;"}
@@ -7917,6 +7917,7 @@ declare const PhoneNumberInput: React__default.ForwardRefExoticComponent<Partial
7917
7917
  size?: "medium" | "large" | undefined;
7918
7918
  onBlur?: FormInputOnEvent | undefined;
7919
7919
  onFocus?: FormInputOnEvent | undefined;
7920
+ placeholder?: string | undefined;
7920
7921
  onClick?: FormInputOnEvent | undefined;
7921
7922
  defaultValue?: string | undefined;
7922
7923
  autoFocus?: boolean | undefined;
@@ -7954,7 +7955,7 @@ declare const PhoneNumberInput: React__default.ForwardRefExoticComponent<Partial
7954
7955
  onClearButtonClick?: (() => void) | undefined;
7955
7956
  } & React__default.RefAttributes<BladeElementRef>>;
7956
7957
 
7957
- type CommonProps = Pick<BaseInputProps, 'size' | 'label' | 'labelPosition' | 'name' | 'validationState' | 'errorText' | 'successText' | 'helpText' | 'defaultValue' | 'necessityIndicator' | 'isRequired' | 'isDisabled' | 'onFocus' | 'onBlur' | 'onClick' | 'leadingIcon' | 'trailingIcon' | 'accessibilityLabel' | 'autoFocus' | 'testID' | 'keyboardReturnKeyType' | 'autoCompleteSuggestionType'>;
7958
+ type CommonProps = Pick<BaseInputProps, 'size' | 'label' | 'labelPosition' | 'name' | 'validationState' | 'errorText' | 'successText' | 'helpText' | 'defaultValue' | 'necessityIndicator' | 'isRequired' | 'isDisabled' | 'onFocus' | 'onBlur' | 'onClick' | 'leadingIcon' | 'trailingIcon' | 'accessibilityLabel' | 'autoFocus' | 'testID' | 'keyboardReturnKeyType' | 'autoCompleteSuggestionType' | 'placeholder'>;
7958
7959
  type PhoneNumberInputProps = StyledPropsBlade & CommonProps & {
7959
7960
  /**
7960
7961
  * Default value of the input, Used to set the default value of input field when it's uncontrolled
@@ -6517,7 +6517,7 @@ type SearchInputPropsWithLabel = {
6517
6517
  type SearchInputProps = (SearchInputPropsWithA11yLabel | SearchInputPropsWithLabel) & SearchInputCommonProps;
6518
6518
  declare const SearchInput: React__default.ForwardRefExoticComponent<SearchInputProps & React__default.RefAttributes<BladeElementRef>>;
6519
6519
 
6520
- type CommonProps = Pick<BaseInputProps, 'size' | 'label' | 'labelPosition' | 'name' | 'validationState' | 'errorText' | 'successText' | 'helpText' | 'defaultValue' | 'necessityIndicator' | 'isRequired' | 'isDisabled' | 'onFocus' | 'onBlur' | 'onClick' | 'leadingIcon' | 'trailingIcon' | 'accessibilityLabel' | 'autoFocus' | 'testID' | 'keyboardReturnKeyType' | 'autoCompleteSuggestionType'>;
6520
+ type CommonProps = Pick<BaseInputProps, 'size' | 'label' | 'labelPosition' | 'name' | 'validationState' | 'errorText' | 'successText' | 'helpText' | 'defaultValue' | 'necessityIndicator' | 'isRequired' | 'isDisabled' | 'onFocus' | 'onBlur' | 'onClick' | 'leadingIcon' | 'trailingIcon' | 'accessibilityLabel' | 'autoFocus' | 'testID' | 'keyboardReturnKeyType' | 'autoCompleteSuggestionType' | 'placeholder'>;
6521
6521
  type PhoneNumberInputProps = StyledPropsBlade & CommonProps & {
6522
6522
  /**
6523
6523
  * Default value of the input, Used to set the default value of input field when it's uncontrolled
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@razorpay/blade",
3
3
  "description": "The Design System that powers Razorpay",
4
- "version": "11.18.1",
4
+ "version": "11.18.3",
5
5
  "license": "MIT",
6
6
  "engines": {
7
7
  "node": ">=18.12.1"