@razorpay/blade 12.41.5 → 12.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/native/components/Accordion/AccordionItemHeader.js +6 -2
- package/build/lib/native/components/Accordion/AccordionItemHeader.js.map +1 -1
- package/build/lib/native/components/BaseHeaderFooter/BaseHeader.js +1 -1
- package/build/lib/native/components/BaseHeaderFooter/BaseHeader.js.map +1 -1
- package/build/lib/web/development/components/Accordion/AccordionItemHeader.js +42 -16
- package/build/lib/web/development/components/Accordion/AccordionItemHeader.js.map +1 -1
- package/build/lib/web/development/components/BaseHeaderFooter/BaseHeader.js +61 -22
- package/build/lib/web/development/components/BaseHeaderFooter/BaseHeader.js.map +1 -1
- package/build/lib/web/development/components/Carousel/Carousel.web.js +17 -9
- package/build/lib/web/development/components/Carousel/Carousel.web.js.map +1 -1
- package/build/lib/web/development/components/Carousel/CarouselItem.web.js +24 -8
- package/build/lib/web/development/components/Carousel/CarouselItem.web.js.map +1 -1
- package/build/lib/web/development/components/ListView/ListViewFilters.web.js +16 -8
- package/build/lib/web/development/components/ListView/ListViewFilters.web.js.map +1 -1
- package/build/lib/web/production/components/Accordion/AccordionItemHeader.js +42 -16
- package/build/lib/web/production/components/Accordion/AccordionItemHeader.js.map +1 -1
- package/build/lib/web/production/components/BaseHeaderFooter/BaseHeader.js +61 -22
- package/build/lib/web/production/components/BaseHeaderFooter/BaseHeader.js.map +1 -1
- package/build/lib/web/production/components/Carousel/Carousel.web.js +17 -9
- package/build/lib/web/production/components/Carousel/Carousel.web.js.map +1 -1
- package/build/lib/web/production/components/Carousel/CarouselItem.web.js +24 -8
- package/build/lib/web/production/components/Carousel/CarouselItem.web.js.map +1 -1
- package/build/lib/web/production/components/ListView/ListViewFilters.web.js +16 -8
- package/build/lib/web/production/components/ListView/ListViewFilters.web.js.map +1 -1
- package/build/types/components/index.d.ts +77 -11
- package/build/types/components/index.native.d.ts +65 -1
- package/package.json +1 -1
|
@@ -13,9 +13,13 @@ import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/a
|
|
|
13
13
|
import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.native.js';
|
|
14
14
|
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
15
15
|
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
16
|
-
import {
|
|
16
|
+
import { makeSize } from '../../utils/makeSize/makeSize.js';
|
|
17
|
+
import '../../tokens/global/typography.js';
|
|
18
|
+
import '../../tokens/global/motion.js';
|
|
19
|
+
import { size } from '../../tokens/global/size.js';
|
|
20
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
17
21
|
|
|
18
|
-
var _excluded=["title","subtitle","leading","children","trailing","titleSuffix"];var _AccordionItemHeader=function _AccordionItemHeader(_ref){var title=_ref.title,subtitle=_ref.subtitle,leading=_ref.leading,children=_ref.children,trailing=_ref.trailing,titleSuffix=_ref.titleSuffix,rest=_objectWithoutProperties(_ref,_excluded);var _useAccordion=useAccordion(),size=_useAccordion.size,showNumberPrefix=_useAccordion.showNumberPrefix,expandedIndex=_useAccordion.expandedIndex;var _useAccordionItemInde=useAccordionItemIndex(),index=_useAccordionItemInde.index,isDisabled=_useAccordionItemInde.isDisabled;var
|
|
22
|
+
var _excluded=["title","subtitle","leading","children","trailing","titleSuffix"];var getLeadingElementMaxHeightAndWidth=function getLeadingElementMaxHeightAndWidth(size$1){if(size$1==='large')return makeSize(size['32']);return makeSize(size['24']);};var _AccordionItemHeader=function _AccordionItemHeader(_ref){var _leading$type$name;var title=_ref.title,subtitle=_ref.subtitle,leading=_ref.leading,children=_ref.children,trailing=_ref.trailing,titleSuffix=_ref.titleSuffix,rest=_objectWithoutProperties(_ref,_excluded);var _useAccordion=useAccordion(),size=_useAccordion.size,showNumberPrefix=_useAccordion.showNumberPrefix,expandedIndex=_useAccordion.expandedIndex;var _useAccordionItemInde=useAccordionItemIndex(),index=_useAccordionItemInde.index,isDisabled=_useAccordionItemInde.isDisabled;var isLeadingIcon=React__default.isValidElement(leading)&&typeof leading.type==='function'&&((_leading$type$name=leading.type.name)==null?void 0:_leading$type$name.endsWith('Icon'));var isLeadingNumberOrIcon=React__default.useMemo(function(){if(showNumberPrefix&&typeof index==='number')return true;if(isLeadingIcon)return true;return false;},[showNumberPrefix,index,isLeadingIcon]);var shouldAlignHeaderItemsInCenter=Boolean(children||Boolean(leading)&&!isLeadingNumberOrIcon);var leadingElement=React__default.useMemo(function(){if(showNumberPrefix&&typeof index==='number'){return jsxs(Text,{size:size,weight:"semibold",marginTop:"-2px",as:"span",children:[index+1,"."]});}if(leading){return jsx(BaseBox,{marginRight:isLeadingIcon?'spacing.0':'spacing.3',marginTop:"spacing.1",maxHeight:getLeadingElementMaxHeightAndWidth(size),maxWidth:getLeadingElementMaxHeightAndWidth(size),overflow:"hidden",children:leading});}return null;},[showNumberPrefix,index,leading,size,isLeadingIcon]);return jsx(BaseBox,Object.assign({},metaAttribute({name:MetaConstants.AccordionItemHeader}),{flex:"1",children:jsx(BaseHeader,Object.assign({leading:leadingElement,title:title,subtitle:subtitle,trailing:trailing,titleSuffix:titleSuffix,isDisabled:isDisabled,showBackButton:false,showCloseButton:false,showDivider:expandedIndex===index,paddingX:"spacing.5",marginY:"spacing.5",size:size,alignItems:!subtitle&&!isLeadingNumberOrIcon?'center':'flex-start',dividerProps:{thickness:'thinner',marginX:'spacing.5'},trailingInteractionElement:jsx(CollapsibleChevronIcon,{color:isDisabled?'interactive.icon.gray.disabled':'interactive.icon.gray.muted',size:"large"}),shouldAlignLeadingAndTrailingElementsToCenter:shouldAlignHeaderItemsInCenter},makeAnalyticsAttribute(rest),{children:children}))}));};var AccordionItemHeader=assignWithoutSideEffects(_AccordionItemHeader,{componentId:componentIds.AccordionItemHeader});
|
|
19
23
|
|
|
20
24
|
export { AccordionItemHeader };
|
|
21
25
|
//# sourceMappingURL=AccordionItemHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionItemHeader.js","sources":["../../../../../src/components/Accordion/AccordionItemHeader.tsx"],"sourcesContent":["import React from 'react';\nimport { useAccordion, useAccordionItemIndex } from './AccordionContext';\nimport { componentIds } from './componentIds';\nimport type { BaseHeaderProps } from '~components/BaseHeaderFooter/BaseHeader';\nimport { BaseHeader } from '~components/BaseHeaderFooter/BaseHeader';\nimport { Text } from '~components/Typography';\nimport BaseBox from '~components/Box/BaseBox';\nimport { CollapsibleChevronIcon } from '~components/Collapsible/CollapsibleChevronIcon';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport type { DataAnalyticsAttribute } from '~utils/types';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\nconst _AccordionItemHeader = ({\n title,\n subtitle,\n leading,\n children,\n trailing,\n titleSuffix,\n ...rest\n}: Pick<\n BaseHeaderProps,\n 'title' | 'subtitle' | 'leading' | 'children' | 'trailing' | 'titleSuffix'\n> &\n DataAnalyticsAttribute): React.ReactElement => {\n const { size, showNumberPrefix, expandedIndex } = useAccordion();\n const { index, isDisabled } = useAccordionItemIndex();\n\n const isLeadingNumberOrIcon = React.useMemo(() => {\n // Check if leading is a number\n if (showNumberPrefix && typeof index === 'number') return true;\n\n // Check if leading is an Icon component (name ends with \"Icon\")\n if (
|
|
1
|
+
{"version":3,"file":"AccordionItemHeader.js","sources":["../../../../../src/components/Accordion/AccordionItemHeader.tsx"],"sourcesContent":["import React from 'react';\nimport { useAccordion, useAccordionItemIndex } from './AccordionContext';\nimport { componentIds } from './componentIds';\nimport type { BaseHeaderProps } from '~components/BaseHeaderFooter/BaseHeader';\nimport { BaseHeader } from '~components/BaseHeaderFooter/BaseHeader';\nimport { Text } from '~components/Typography';\nimport BaseBox from '~components/Box/BaseBox';\nimport { CollapsibleChevronIcon } from '~components/Collapsible/CollapsibleChevronIcon';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport type { DataAnalyticsAttribute } from '~utils/types';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport type { BoxProps } from '~components/Box';\nimport { makeSize } from '~utils/makeSize';\nimport { size as sizeToken } from '~tokens/global';\n\nconst getLeadingElementMaxHeightAndWidth = (\n size: BaseHeaderProps['size'],\n): BoxProps['maxHeight'] => {\n if (size === 'large') return makeSize(sizeToken['32']);\n return makeSize(sizeToken['24']);\n};\n\nconst _AccordionItemHeader = ({\n title,\n subtitle,\n leading,\n children,\n trailing,\n titleSuffix,\n ...rest\n}: Pick<\n BaseHeaderProps,\n 'title' | 'subtitle' | 'leading' | 'children' | 'trailing' | 'titleSuffix'\n> &\n DataAnalyticsAttribute): React.ReactElement => {\n const { size, showNumberPrefix, expandedIndex } = useAccordion();\n const { index, isDisabled } = useAccordionItemIndex();\n\n const isLeadingIcon =\n React.isValidElement(leading) &&\n typeof leading.type === 'function' &&\n leading.type.name?.endsWith('Icon');\n\n const isLeadingNumberOrIcon = React.useMemo(() => {\n // Check if leading is a number\n if (showNumberPrefix && typeof index === 'number') return true;\n\n // Check if leading is an Icon component (name ends with \"Icon\")\n if (isLeadingIcon) return true;\n\n return false;\n }, [showNumberPrefix, index, isLeadingIcon]);\n\n const shouldAlignHeaderItemsInCenter = Boolean(\n children || (Boolean(leading) && !isLeadingNumberOrIcon),\n );\n\n const leadingElement = React.useMemo(() => {\n if (showNumberPrefix && typeof index === 'number') {\n return (\n <Text size={size} weight=\"semibold\" marginTop=\"-2px\" as=\"span\">\n {index + 1}.\n </Text>\n );\n }\n if (leading) {\n return (\n <BaseBox\n marginRight={isLeadingIcon ? 'spacing.0' : 'spacing.3'}\n marginTop=\"spacing.1\"\n // So in design, we have set max height and width for the leading element, doing same here\n maxHeight={getLeadingElementMaxHeightAndWidth(size)}\n maxWidth={getLeadingElementMaxHeightAndWidth(size)}\n overflow=\"hidden\"\n >\n {leading}\n </BaseBox>\n );\n }\n return null;\n }, [showNumberPrefix, index, leading, size, isLeadingIcon]);\n\n return (\n <BaseBox {...metaAttribute({ name: MetaConstants.AccordionItemHeader })} flex=\"1\">\n <BaseHeader\n leading={leadingElement}\n title={title}\n subtitle={subtitle}\n trailing={trailing}\n titleSuffix={titleSuffix}\n isDisabled={isDisabled}\n showBackButton={false}\n showCloseButton={false}\n showDivider={expandedIndex === index}\n paddingX=\"spacing.5\"\n marginY=\"spacing.5\"\n size={size}\n alignItems={!subtitle && !isLeadingNumberOrIcon ? 'center' : 'flex-start'}\n dividerProps={{\n thickness: 'thinner',\n marginX: 'spacing.5',\n }}\n trailingInteractionElement={\n <CollapsibleChevronIcon\n color={isDisabled ? 'interactive.icon.gray.disabled' : 'interactive.icon.gray.muted'}\n size=\"large\"\n />\n }\n shouldAlignLeadingAndTrailingElementsToCenter={shouldAlignHeaderItemsInCenter}\n {...makeAnalyticsAttribute(rest)}\n >\n {children}\n </BaseHeader>\n </BaseBox>\n );\n};\n\nconst AccordionItemHeader = assignWithoutSideEffects(_AccordionItemHeader, {\n componentId: componentIds.AccordionItemHeader,\n});\n\nexport { AccordionItemHeader };\n"],"names":["getLeadingElementMaxHeightAndWidth","size","makeSize","sizeToken","_AccordionItemHeader","_ref","_leading$type$name","title","subtitle","leading","children","trailing","titleSuffix","rest","_objectWithoutProperties","_excluded","_useAccordion","useAccordion","showNumberPrefix","expandedIndex","_useAccordionItemInde","useAccordionItemIndex","index","isDisabled","isLeadingIcon","React","isValidElement","type","name","endsWith","isLeadingNumberOrIcon","useMemo","shouldAlignHeaderItemsInCenter","Boolean","leadingElement","_jsxs","Text","weight","marginTop","as","_jsx","BaseBox","marginRight","maxHeight","maxWidth","overflow","Object","assign","metaAttribute","MetaConstants","AccordionItemHeader","flex","BaseHeader","showBackButton","showCloseButton","showDivider","paddingX","marginY","alignItems","dividerProps","thickness","marginX","trailingInteractionElement","CollapsibleChevronIcon","color","shouldAlign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ils/assignWithoutSideEffects/a
|
|
|
31
31
|
import { getComponentId } from '../../utils/isValidAllowedChildren/isValidAllowedChildren.js';
|
|
32
32
|
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
33
33
|
|
|
34
|
-
var _excluded=["title","subtitle","leading","titleSuffix","trailing","showDivider","showBackButton","showCloseButton","onBackButtonClick","onCloseButtonClick","closeButtonRef","backButtonRef","testID","onClickCapture","onKeyDown","onKeyUp","onLostPointerCapture","onPointerCancel","onPointerDown","onPointerMove","onPointerUp","metaComponentName","paddingX","marginY","marginBottom","marginTop","size","isDisabled","children","trailingInteractionElement","backgroundImage","alignItems","dividerProps"];var commonCenterBoxProps={display:'flex',alignItems:'center',justifyContent:'center'};var centerBoxProps={xlarge:Object.assign({},commonCenterBoxProps,{height:'28px'}),large:Object.assign({},commonCenterBoxProps,{height:'28px'}),medium:Object.assign({},commonCenterBoxProps,{height:'20px'})};var absolutePositionedButton={position:'absolute',top:'spacing.0',right:'spacing.0'};var sizeTokensMapping={xlarge:{title:'small',type:'heading'},large:{title:'large',type:'text'},medium:{title:'medium',type:'text'}};var propRestrictionMap={large:{Button:{size:'xsmall',variant:'tertiary'},IconButton:{size:'large'},Badge:{size:'medium'},Link:{size:'medium'},Text:{size:'medium',variant:'body'},Amount:{type:'body',size:'medium'}},xlarge:{Button:{size:'xsmall',variant:'tertiary'},IconButton:{size:'large'},Badge:{size:'medium'},Link:{size:'medium'},Text:{size:'medium',variant:'body'},Amount:{type:'body',size:'medium'}},medium:{Button:{size:'xsmall',variant:'tertiary'},IconButton:{size:'large'},Badge:{size:'small'},Link:{size:'small'},Text:{size:'small',variant:'body'},Amount:{type:'body',size:'small'}}};var useTrailingRestriction=function useTrailingRestriction(_ref){var trailing=_ref.trailing,size=_ref.size;var _React$useState=React__default.useState(null),_React$useState2=_slicedToArray(_React$useState,2),validatedTrailingComponent=_React$useState2[0],setValidatedTrailingComponent=_React$useState2[1];React__default.useEffect(function(){if(React__default.isValidElement(trailing)){var trailingComponentType=getComponentId(trailing);var restrictedProps=propRestrictionMap[size][trailingComponentType];var allowedComponents=Object.keys(propRestrictionMap[size]);if(__DEV__){if(!restrictedProps){throwBladeError({message:`Only one of \`${allowedComponents.join(', ')}\` component is accepted as trailing`,moduleName:'Header'});}}var restrictedPropKeys=Object.keys(propRestrictionMap[size][trailingComponentType]);for(var prop of restrictedPropKeys){var _trailing$props;if(trailing!=null&&(_trailing$props=trailing.props)!=null&&_trailing$props.hasOwnProperty(prop)){logger({message:`Do not pass "${prop}" to "${trailingComponentType}" while inside Header trailing, because we override it.`,moduleName:'Header',type:'warn'});}}setValidatedTrailingComponent(React__default.cloneElement(trailing,restrictedProps));}},[trailing,size]);return validatedTrailingComponent;};var _BaseHeader=function _BaseHeader(_ref2){var title=_ref2.title,subtitle=_ref2.subtitle,leading=_ref2.leading,titleSuffix=_ref2.titleSuffix,trailing=_ref2.trailing,_ref2$showDivider=_ref2.showDivider,showDivider=_ref2$showDivider===void 0?true:_ref2$showDivider,_ref2$showBackButton=_ref2.showBackButton,showBackButton=_ref2$showBackButton===void 0?false:_ref2$showBackButton,_ref2$showCloseButton=_ref2.showCloseButton,showCloseButton=_ref2$showCloseButton===void 0?true:_ref2$showCloseButton,onBackButtonClick=_ref2.onBackButtonClick,onCloseButtonClick=_ref2.onCloseButtonClick,closeButtonRef=_ref2.closeButtonRef,backButtonRef=_ref2.backButtonRef,testID=_ref2.testID,onClickCapture=_ref2.onClickCapture,onKeyDown=_ref2.onKeyDown,onKeyUp=_ref2.onKeyUp,onLostPointerCapture=_ref2.onLostPointerCapture,onPointerCancel=_ref2.onPointerCancel,onPointerDown=_ref2.onPointerDown,onPointerMove=_ref2.onPointerMove,onPointerUp=_ref2.onPointerUp,metaComponentName=_ref2.metaComponentName,paddingX=_ref2.paddingX,marginY=_ref2.marginY,marginBottom=_ref2.marginBottom,marginTop=_ref2.marginTop,_ref2$size=_ref2.size,size$1=_ref2$size===void 0?'large':_ref2$size,isDisabled=_ref2.isDisabled,children=_ref2.children,trailingInteractionElement=_ref2.trailingInteractionElement,backgroundImage=_ref2.backgroundImage,_ref2$alignItems=_ref2.alignItems,alignItems=_ref2$alignItems===void 0?'flex-start':_ref2$alignItems,dividerProps=_ref2.dividerProps,rest=_objectWithoutProperties(_ref2,_excluded);var validatedTrailingComponent=useTrailingRestriction({trailing:trailing,size:size$1});var shouldWrapTitle=titleSuffix&&trailing&&showBackButton&&showCloseButton;var hasOnlyChildren=children&&!(title||subtitle||titleSuffix||leading);var webOnlyEventHandlers=isReactNative()?{}:{onClickCapture:onClickCapture,onKeyDown:onKeyDown,onKeyUp:onKeyUp,onLostPointerCapture:onLostPointerCapture,onPointerCancel:onPointerCancel,onPointerDown:onPointerDown,onPointerMove:onPointerMove,onPointerUp:onPointerUp};return jsxs(BaseBox,Object.assign({},metaAttribute({name:metaComponentName,testID:testID}),makeAnalyticsAttribute(rest),{backgroundImage:backgroundImage,children:[jsxs(BaseBox,Object.assign({marginY:marginY!=null?marginY:{base:'spacing.5',m:'spacing.6'},paddingX:paddingX!=null?paddingX:{base:'spacing.5',m:'spacing.6'},marginTop:marginTop,marginBottom:marginBottom,touchAction:"none"},webOnlyEventHandlers,{children:[jsxs(BaseBox,{position:"relative",display:"flex",flexDirection:"row",userSelect:"none",children:[showBackButton?jsx(BaseBox,{overflow:"visible",marginRight:"spacing.5",children:jsx(Box,Object.assign({},centerBoxProps[size$1],{children:jsx(IconButton,{ref:backButtonRef,size:"large",icon:ChevronLeftIcon,onClick:function onClick(){return onBackButtonClick==null?void 0:onBackButtonClick();},accessibilityLabel:"Back"})}))}):null,hasOnlyChildren?null:jsxs(BaseBox,{paddingRight:"spacing.5",marginRight:"auto",flex:"auto",display:"flex",flexDirection:"row",alignItems:alignItems,children:[
|
|
34
|
+
var _excluded=["title","subtitle","leading","titleSuffix","trailing","showDivider","showBackButton","showCloseButton","onBackButtonClick","onCloseButtonClick","closeButtonRef","backButtonRef","testID","onClickCapture","onKeyDown","onKeyUp","onLostPointerCapture","onPointerCancel","onPointerDown","onPointerMove","onPointerUp","metaComponentName","paddingX","marginY","marginBottom","marginTop","size","isDisabled","children","trailingInteractionElement","backgroundImage","alignItems","dividerProps","shouldAlignLeadingAndTrailingElementsToCenter"];var commonCenterBoxProps={display:'flex',alignItems:'center',justifyContent:'center'};var centerBoxProps={xlarge:Object.assign({},commonCenterBoxProps,{height:'28px'}),large:Object.assign({},commonCenterBoxProps,{height:'28px'}),medium:Object.assign({},commonCenterBoxProps,{height:'20px'})};var absolutePositionedButton={position:'absolute',top:'spacing.0',right:'spacing.0'};var sizeTokensMapping={xlarge:{title:'small',type:'heading'},large:{title:'large',type:'text'},medium:{title:'medium',type:'text'}};var propRestrictionMap={large:{Button:{size:'xsmall',variant:'tertiary'},IconButton:{size:'large'},Badge:{size:'medium'},Link:{size:'medium'},Text:{size:'medium',variant:'body'},Amount:{type:'body',size:'medium'}},xlarge:{Button:{size:'xsmall',variant:'tertiary'},IconButton:{size:'large'},Badge:{size:'medium'},Link:{size:'medium'},Text:{size:'medium',variant:'body'},Amount:{type:'body',size:'medium'}},medium:{Button:{size:'xsmall',variant:'tertiary'},IconButton:{size:'large'},Badge:{size:'small'},Link:{size:'small'},Text:{size:'small',variant:'body'},Amount:{type:'body',size:'small'}}};var useTrailingRestriction=function useTrailingRestriction(_ref){var trailing=_ref.trailing,size=_ref.size;var _React$useState=React__default.useState(null),_React$useState2=_slicedToArray(_React$useState,2),validatedTrailingComponent=_React$useState2[0],setValidatedTrailingComponent=_React$useState2[1];React__default.useEffect(function(){if(React__default.isValidElement(trailing)){var trailingComponentType=getComponentId(trailing);var restrictedProps=propRestrictionMap[size][trailingComponentType];var allowedComponents=Object.keys(propRestrictionMap[size]);if(__DEV__){if(!restrictedProps){throwBladeError({message:`Only one of \`${allowedComponents.join(', ')}\` component is accepted as trailing`,moduleName:'Header'});}}var restrictedPropKeys=Object.keys(propRestrictionMap[size][trailingComponentType]);for(var prop of restrictedPropKeys){var _trailing$props;if(trailing!=null&&(_trailing$props=trailing.props)!=null&&_trailing$props.hasOwnProperty(prop)){logger({message:`Do not pass "${prop}" to "${trailingComponentType}" while inside Header trailing, because we override it.`,moduleName:'Header',type:'warn'});}}setValidatedTrailingComponent(React__default.cloneElement(trailing,restrictedProps));}},[trailing,size]);return validatedTrailingComponent;};var _BaseHeader=function _BaseHeader(_ref2){var title=_ref2.title,subtitle=_ref2.subtitle,leading=_ref2.leading,titleSuffix=_ref2.titleSuffix,trailing=_ref2.trailing,_ref2$showDivider=_ref2.showDivider,showDivider=_ref2$showDivider===void 0?true:_ref2$showDivider,_ref2$showBackButton=_ref2.showBackButton,showBackButton=_ref2$showBackButton===void 0?false:_ref2$showBackButton,_ref2$showCloseButton=_ref2.showCloseButton,showCloseButton=_ref2$showCloseButton===void 0?true:_ref2$showCloseButton,onBackButtonClick=_ref2.onBackButtonClick,onCloseButtonClick=_ref2.onCloseButtonClick,closeButtonRef=_ref2.closeButtonRef,backButtonRef=_ref2.backButtonRef,testID=_ref2.testID,onClickCapture=_ref2.onClickCapture,onKeyDown=_ref2.onKeyDown,onKeyUp=_ref2.onKeyUp,onLostPointerCapture=_ref2.onLostPointerCapture,onPointerCancel=_ref2.onPointerCancel,onPointerDown=_ref2.onPointerDown,onPointerMove=_ref2.onPointerMove,onPointerUp=_ref2.onPointerUp,metaComponentName=_ref2.metaComponentName,paddingX=_ref2.paddingX,marginY=_ref2.marginY,marginBottom=_ref2.marginBottom,marginTop=_ref2.marginTop,_ref2$size=_ref2.size,size$1=_ref2$size===void 0?'large':_ref2$size,isDisabled=_ref2.isDisabled,children=_ref2.children,trailingInteractionElement=_ref2.trailingInteractionElement,backgroundImage=_ref2.backgroundImage,_ref2$alignItems=_ref2.alignItems,alignItems=_ref2$alignItems===void 0?'flex-start':_ref2$alignItems,dividerProps=_ref2.dividerProps,_ref2$shouldAlignLead=_ref2.shouldAlignLeadingAndTrailingElementsToCenter,shouldAlignLeadingAndTrailingElementsToCenter=_ref2$shouldAlignLead===void 0?false:_ref2$shouldAlignLead,rest=_objectWithoutProperties(_ref2,_excluded);var validatedTrailingComponent=useTrailingRestriction({trailing:trailing,size:size$1});var shouldWrapTitle=titleSuffix&&trailing&&showBackButton&&showCloseButton;var hasOnlyChildren=children&&!(title||subtitle||titleSuffix||leading);var webOnlyEventHandlers=isReactNative()?{}:{onClickCapture:onClickCapture,onKeyDown:onKeyDown,onKeyUp:onKeyUp,onLostPointerCapture:onLostPointerCapture,onPointerCancel:onPointerCancel,onPointerDown:onPointerDown,onPointerMove:onPointerMove,onPointerUp:onPointerUp};var renderTrailingInteractionElementWithChildren=function renderTrailingInteractionElementWithChildren(){if(trailingInteractionElement&&children){return jsx(Box,Object.assign({alignSelf:shouldAlignLeadingAndTrailingElementsToCenter?'center':'flex-start'},centerBoxProps[size$1],{children:trailingInteractionElement}));}return null;};var renderTrailingInteractionElementWithoutChildren=function renderTrailingInteractionElementWithoutChildren(){if(trailingInteractionElement&&!children){return jsx(Box,Object.assign({},centerBoxProps[size$1],{alignSelf:shouldAlignLeadingAndTrailingElementsToCenter?'center':undefined,children:trailingInteractionElement}));}return null;};var renderLeadingElement=function renderLeadingElement(){if(Boolean(leading)){return jsx(BaseBox,Object.assign({marginRight:"spacing.3"},centerBoxProps[size$1],{alignSelf:shouldAlignLeadingAndTrailingElementsToCenter?'center':undefined,children:leading}));}return null;};var renderTrailingElement=function renderTrailingElement(){if(shouldAlignLeadingAndTrailingElementsToCenter&&validatedTrailingComponent){return jsx(BaseBox,{marginRight:"spacing.5",display:"flex",alignItems:"center",justifyContent:"center",children:jsx(Box,Object.assign({},centerBoxProps[size$1],{children:validatedTrailingComponent}))});}if(validatedTrailingComponent){return jsx(BaseBox,{marginRight:"spacing.5",children:jsx(Box,Object.assign({},centerBoxProps[size$1],{children:validatedTrailingComponent}))});}return null;};return jsxs(BaseBox,Object.assign({},metaAttribute({name:metaComponentName,testID:testID}),makeAnalyticsAttribute(rest),{backgroundImage:backgroundImage,children:[jsxs(BaseBox,Object.assign({marginY:marginY!=null?marginY:{base:'spacing.5',m:'spacing.6'},paddingX:paddingX!=null?paddingX:{base:'spacing.5',m:'spacing.6'},marginTop:marginTop,marginBottom:marginBottom,touchAction:"none"},webOnlyEventHandlers,{children:[jsxs(BaseBox,{position:"relative",display:"flex",flexDirection:"row",userSelect:"none",children:[showBackButton?jsx(BaseBox,{overflow:"visible",marginRight:"spacing.5",children:jsx(Box,Object.assign({},centerBoxProps[size$1],{children:jsx(IconButton,{ref:backButtonRef,size:"large",icon:ChevronLeftIcon,onClick:function onClick(){return onBackButtonClick==null?void 0:onBackButtonClick();},accessibilityLabel:"Back"})}))}):null,hasOnlyChildren?null:jsxs(BaseBox,{paddingRight:"spacing.5",marginRight:"auto",flex:"auto",display:"flex",flexDirection:"row",alignItems:alignItems,children:[renderLeadingElement(),jsxs(BaseBox,{flex:"auto",children:[jsxs(BaseBox,{maxWidth:isReactNative()&&shouldWrapTitle?'100px':undefined,flexShrink:0,display:"flex",flexDirection:"row",children:[title?sizeTokensMapping[size$1].type==='heading'?jsx(Heading,{as:"h2",marginTop:makeSize(size['1']),size:sizeTokensMapping[size$1].title,weight:"semibold",color:isDisabled?'surface.text.gray.disabled':'surface.text.gray.normal',wordBreak:"break-word",children:title}):jsx(Text,{size:sizeTokensMapping[size$1].title,marginTop:makeSize(size['1']),weight:"semibold",color:isDisabled?'surface.text.gray.disabled':'surface.text.gray.normal',wordBreak:"break-word",children:title}):null,titleSuffix&&jsx(BaseBox,{marginLeft:"spacing.3",children:jsx(Box,Object.assign({},centerBoxProps[size$1],{children:titleSuffix}))})]}),subtitle?jsx(Text,{variant:"body",size:"small",weight:"regular",color:isDisabled?'surface.text.gray.disabled':'surface.text.gray.muted',children:subtitle}):null]})]}),renderTrailingElement(),showCloseButton?jsx(Box,Object.assign({},hasOnlyChildren?absolutePositionedButton:centerBoxProps[size$1],{children:jsx(IconButton,{ref:closeButtonRef,size:"large",icon:CloseIcon,accessibilityLabel:"Close",onClick:function onClick(){return onCloseButtonClick==null?void 0:onCloseButtonClick();}})})):null,renderTrailingInteractionElementWithoutChildren()]}),jsxs(BaseBox,{display:"flex",width:"100%",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[jsx(Box,{width:"100%",children:children}),renderTrailingInteractionElementWithChildren()]})]})),showDivider?jsx(Divider,Object.assign({},dividerProps)):null]}));};var BaseHeader=assignWithoutSideEffects(_BaseHeader,{componentId:'BaseHeader'});
|
|
35
35
|
|
|
36
36
|
export { BaseHeader };
|
|
37
37
|
//# sourceMappingURL=BaseHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseHeader.js","sources":["../../../../../src/components/BaseHeaderFooter/BaseHeader.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react';\nimport type { ReactDOMAttributes } from '@use-gesture/react/dist/declarations/src/types';\nimport { Divider } from '~components/Divider';\nimport type { DividerProps } from '~components/Divider';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Heading, Text } from '~components/Typography';\nimport { IconButton } from '~components/Button/IconButton';\nimport { ChevronLeftIcon, CloseIcon } from '~components/Icons';\nimport type { DataAnalyticsAttribute, TestID } from '~utils/types';\nimport type { BoxProps } from '~components/Box';\nimport { Box } from '~components/Box';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { isReactNative, makeSize } from '~utils';\nimport { metaAttribute } from '~utils/metaAttribute';\nimport { logger, throwBladeError } from '~utils/logger';\nimport { size as sizeToken } from '~tokens/global';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype BaseHeaderProps = {\n title?: string;\n subtitle?: string;\n /**\n * Leading part of the header placed at the left most side of the header\n */\n leading?: React.ReactNode;\n /**\n * Trailing part of the header placed at the right most side of the header\n */\n trailing?: React.ReactNode;\n /**\n * Placed adjacent to the title text\n */\n titleSuffix?: React.ReactNode;\n /**\n * @default true\n */\n showDivider?: boolean;\n /**\n * @default false\n */\n showBackButton?: boolean;\n\n /**\n * Slot for rendering any trailing interaction element into BaseHeader.\n *\n * E.g. Used in accordion to render CollapsibleChevronIcon\n */\n trailingInteractionElement?: React.ReactNode;\n\n /**\n * Decides size of the Header\n */\n size?: 'xlarge' | 'large' | 'medium';\n /**\n * @default true\n */\n showCloseButton?: boolean;\n\n /**\n * Disabled state of BaseHeader\n *\n * @default false\n */\n isDisabled?: boolean;\n\n paddingX?: BoxProps['paddingX'];\n marginY?: BoxProps['marginY'];\n marginTop?: BoxProps['marginTop'];\n marginBottom?: BoxProps['marginBottom'];\n alignItems?: BoxProps['alignItems'];\n dividerProps?: DividerProps;\n\n onCloseButtonClick?: () => void;\n onBackButtonClick?: () => void;\n closeButtonRef?: React.MutableRefObject<any>;\n backButtonRef?: React.MutableRefObject<any>;\n metaComponentName?: string;\n /**\n * inner child of BottomSheetHeader. Meant to be used for AutoComplete only\n */\n children?: React.ReactElement | React.ReactElement[];\n /**\n * Background image of the header\n *\n * You can use this for adding gradients.\n */\n backgroundImage?: BoxProps['backgroundImage'];\n} & Pick<\n ReactDOMAttributes,\n | 'onClickCapture'\n | 'onKeyDown'\n | 'onKeyUp'\n | 'onLostPointerCapture'\n | 'onPointerCancel'\n | 'onPointerDown'\n | 'onPointerMove'\n | 'onPointerUp'\n> &\n TestID &\n DataAnalyticsAttribute;\n\ntype TrailingComponents = 'Button' | 'Badge' | 'Link' | 'Text' | 'Amount';\n\nconst commonCenterBoxProps: BoxProps = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n};\n\nconst centerBoxProps: { xlarge: BoxProps; large: BoxProps; medium: BoxProps } = {\n xlarge: {\n ...commonCenterBoxProps,\n height: '28px',\n },\n large: {\n ...commonCenterBoxProps,\n // We want to align title, icon, titleSuffix, trailing, closeButton to baseline\n // But we also want to keep them center aligned to each other\n // So we add a virtual Box around these slots with 28px and center align them to that box\n // We have done similar thing in figma as well (which is where this 28px comes from)\n height: '28px',\n },\n medium: {\n ...commonCenterBoxProps,\n height: '20px',\n },\n};\n\nconst absolutePositionedButton = {\n position: 'absolute',\n top: 'spacing.0',\n right: 'spacing.0',\n} as const;\n\nconst sizeTokensMapping = {\n xlarge: {\n title: 'small',\n type: 'heading',\n },\n large: {\n title: 'large',\n type: 'text',\n },\n medium: {\n title: 'medium',\n type: 'text',\n },\n} as const;\n\n// prop restriction map for corresponding sub components\nconst propRestrictionMap = {\n large: {\n Button: {\n size: 'xsmall',\n variant: 'tertiary',\n },\n IconButton: {\n size: 'large',\n },\n Badge: {\n size: 'medium',\n },\n Link: {\n size: 'medium',\n },\n Text: {\n size: 'medium',\n variant: 'body',\n },\n Amount: {\n type: 'body',\n size: 'medium',\n },\n },\n xlarge: {\n Button: {\n size: 'xsmall',\n variant: 'tertiary',\n },\n IconButton: {\n size: 'large',\n },\n Badge: {\n size: 'medium',\n },\n Link: {\n size: 'medium',\n },\n Text: {\n size: 'medium',\n variant: 'body',\n },\n Amount: {\n type: 'body',\n size: 'medium',\n },\n },\n medium: {\n Button: {\n size: 'xsmall',\n variant: 'tertiary',\n },\n IconButton: {\n size: 'large',\n },\n Badge: {\n size: 'small',\n },\n Link: {\n size: 'small',\n },\n Text: {\n size: 'small',\n variant: 'body',\n },\n Amount: {\n type: 'body',\n size: 'small',\n },\n },\n} as const;\n\nconst useTrailingRestriction = ({\n trailing,\n size,\n}: {\n size: NonNullable<BaseHeaderProps['size']>;\n trailing: BaseHeaderProps['trailing'];\n}): React.ReactNode => {\n const [\n validatedTrailingComponent,\n setValidatedTrailingComponent,\n ] = React.useState<React.ReactElement | null>(null);\n\n // validate and restrict sub component props in trailing prop\n React.useEffect(() => {\n if (React.isValidElement(trailing)) {\n const trailingComponentType = getComponentId(trailing) as TrailingComponents;\n const restrictedProps = propRestrictionMap[size][trailingComponentType];\n\n const allowedComponents = Object.keys(propRestrictionMap[size]);\n if (__DEV__) {\n if (!restrictedProps) {\n throwBladeError({\n message: `Only one of \\`${allowedComponents.join(\n ', ',\n )}\\` component is accepted as trailing`,\n moduleName: 'Header',\n });\n }\n }\n\n const restrictedPropKeys = Object.keys(propRestrictionMap[size][trailingComponentType]);\n for (const prop of restrictedPropKeys) {\n if (trailing?.props?.hasOwnProperty(prop)) {\n logger({\n message: `Do not pass \"${prop}\" to \"${trailingComponentType}\" while inside Header trailing, because we override it.`,\n moduleName: 'Header',\n type: 'warn',\n });\n }\n }\n setValidatedTrailingComponent(\n React.cloneElement(trailing as React.ReactElement, restrictedProps),\n );\n }\n }, [trailing, size]);\n\n return validatedTrailingComponent;\n};\n\nconst _BaseHeader = ({\n title,\n subtitle,\n leading,\n titleSuffix,\n trailing,\n showDivider = true,\n showBackButton = false,\n showCloseButton = true,\n onBackButtonClick,\n onCloseButtonClick,\n closeButtonRef,\n backButtonRef,\n testID,\n onClickCapture,\n onKeyDown,\n onKeyUp,\n onLostPointerCapture,\n onPointerCancel,\n onPointerDown,\n onPointerMove,\n onPointerUp,\n metaComponentName,\n paddingX,\n marginY,\n marginBottom,\n marginTop,\n size = 'large',\n isDisabled,\n children,\n trailingInteractionElement,\n backgroundImage,\n alignItems = 'flex-start',\n dividerProps,\n ...rest\n}: BaseHeaderProps): React.ReactElement => {\n const validatedTrailingComponent = useTrailingRestriction({ trailing, size });\n const shouldWrapTitle = titleSuffix && trailing && showBackButton && showCloseButton;\n const hasOnlyChildren = children && !(title || subtitle || titleSuffix || leading);\n\n const webOnlyEventHandlers: Record<string, any> = isReactNative()\n ? {}\n : {\n onClickCapture,\n onKeyDown,\n onKeyUp,\n onLostPointerCapture,\n onPointerCancel,\n onPointerDown,\n onPointerMove,\n onPointerUp,\n };\n\n return (\n <BaseBox\n {...metaAttribute({ name: metaComponentName, testID })}\n {...makeAnalyticsAttribute(rest)}\n backgroundImage={backgroundImage}\n >\n <BaseBox\n marginY={marginY ?? { base: 'spacing.5', m: 'spacing.6' }}\n paddingX={paddingX ?? { base: 'spacing.5', m: 'spacing.6' }}\n marginTop={marginTop}\n marginBottom={marginBottom}\n touchAction=\"none\"\n {...webOnlyEventHandlers}\n >\n <BaseBox position=\"relative\" display=\"flex\" flexDirection=\"row\" userSelect=\"none\">\n {showBackButton ? (\n <BaseBox overflow=\"visible\" marginRight=\"spacing.5\">\n <Box {...centerBoxProps[size]}>\n <IconButton\n ref={backButtonRef}\n size=\"large\"\n icon={ChevronLeftIcon}\n onClick={() => onBackButtonClick?.()}\n accessibilityLabel=\"Back\"\n />\n </Box>\n </BaseBox>\n ) : null}\n {hasOnlyChildren ? null : (\n <BaseBox\n paddingRight=\"spacing.5\"\n marginRight=\"auto\"\n flex=\"auto\"\n display=\"flex\"\n flexDirection=\"row\"\n alignItems={alignItems}\n >\n {leading ? (\n <BaseBox marginRight=\"spacing.3\" {...centerBoxProps[size]}>\n {leading}\n </BaseBox>\n ) : null}\n <BaseBox flex=\"auto\">\n <BaseBox\n // Explicitly setting maxWidth in React Native because text is not being wrapped properly when multiple fix width components are rendered in header\n // In web, flex containers seem to work a expected\n // @todo: resolve this if we figure out some better solution later\n maxWidth={isReactNative() && shouldWrapTitle ? '100px' : undefined}\n flexShrink={0}\n display=\"flex\"\n flexDirection=\"row\"\n >\n {title ? (\n sizeTokensMapping[size].type === 'heading' ? (\n <Heading\n as=\"h2\"\n marginTop={makeSize(sizeToken['1'])}\n size={sizeTokensMapping[size].title}\n weight=\"semibold\"\n color={\n isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.normal'\n }\n wordBreak=\"break-word\"\n >\n {title}\n </Heading>\n ) : (\n <Text\n size={sizeTokensMapping[size].title}\n marginTop={makeSize(sizeToken['1'])}\n weight=\"semibold\"\n color={\n isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.normal'\n }\n wordBreak=\"break-word\"\n >\n {title}\n </Text>\n )\n ) : null}\n {titleSuffix && (\n <BaseBox marginLeft=\"spacing.3\">\n <Box {...centerBoxProps[size]}>{titleSuffix}</Box>\n </BaseBox>\n )}\n </BaseBox>\n {subtitle ? (\n <Text\n variant=\"body\"\n size=\"small\"\n weight=\"regular\"\n color={isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.muted'}\n >\n {subtitle}\n </Text>\n ) : null}\n </BaseBox>\n </BaseBox>\n )}\n {validatedTrailingComponent ? (\n <BaseBox marginRight=\"spacing.5\">\n <Box {...centerBoxProps[size]}>{validatedTrailingComponent}</Box>\n </BaseBox>\n ) : null}\n {showCloseButton ? (\n <Box {...(hasOnlyChildren ? absolutePositionedButton : centerBoxProps[size])}>\n <IconButton\n ref={closeButtonRef}\n size=\"large\"\n icon={CloseIcon}\n accessibilityLabel=\"Close\"\n onClick={() => onCloseButtonClick?.()}\n />\n </Box>\n ) : null}\n {trailingInteractionElement && !children ? (\n <Box {...centerBoxProps[size]}>{trailingInteractionElement}</Box>\n ) : null}\n </BaseBox>\n <BaseBox\n display=\"flex\"\n width=\"100%\"\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent=\"space-between\"\n >\n <Box width=\"100%\">{children}</Box>\n {trailingInteractionElement && children ? (\n <Box alignSelf=\"flex-start\" {...centerBoxProps[size]}>\n {trailingInteractionElement}\n </Box>\n ) : null}\n </BaseBox>\n </BaseBox>\n {showDivider ? <Divider {...dividerProps} /> : null}\n </BaseBox>\n );\n};\n\nconst BaseHeader = assignWithoutSideEffects(_BaseHeader, {\n componentId: 'BaseHeader',\n});\n\nexport type { BaseHeaderProps };\nexport { BaseHeader };\n"],"names":["commonCenterBoxProps","display","alignItems","justifyContent","centerBoxProps","xlarge","Object","assign","height","large","medium","absolutePositionedButton","position","top","right","sizeTokensMapping","title","type","propRestrictionMap","Button","size","variant","IconButton","Badge","Link","Text","Amount","useTrailingRestriction","_ref","trailing","_React$useState","React","useState","_React$useState2","_slicedToArray","validatedTrailingComponent","setValidatedTrailingComponent","useEffect","isValidElement","trailingComponentType","getComponentId","restrictedProps","allowedComponents","keys","__DEV__","throwBladeError","message","join","moduleName","restrictedPropKeys","prop","_trailing$props","props","hasOwnProperty","logger","cloneElement","_BaseHeader","_ref2","subtitle","leading","titleSuffix","_ref2$showDivider","showDivider","_ref2$showBackButton","showBackButton","_ref2$showCloseButton","showCloseButton","onBackButtonClick","onCloseButtonClick","closeButtonRef","backButtonRef","testID","onClickCapture","onKeyDown","onKeyUp","onLostPointerCapture","onPointerCancel","onPointerDown","onPointerMove","onPointerUp","metaComponentName","paddingX","marginY","marginBottom","marginTop","_ref2$size","isDisabled","children","trailingInteractionElement","backgroundImage","_ref2$alignItems","dividerProps","rest","_objectWithoutProperties","_excluded","shouldWrapTitle","hasOnlyChildren","webOnlyEventHandlers","isReactNative","_jsxs","BaseBox","metaAttribute","name","makeAnalyticsAttribute","base","m","touchAction","flexDirection","userSelect","_jsx","overflow","marginRight","Box","ref","icon","ChevronLeftIcon","onClick","accessibilityLabel","paddingRight","flex","maxWidth","undefined","flexShrink","Heading","as","makeSize","sizeToken","weight","color","wordBreak","marginLeft","CloseIcon","width","alignSelf","Divider","BaseHeader","assignWithoutSideEffects","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sfAyGA,IAAMA,oBAA8B,CAAG,CACrCC,OAAO,CAAE,MAAM,CACfC,UAAU,CAAE,QAAQ,CACpBC,cAAc,CAAE,QAClB,CAAC,CAED,IAAMC,cAAuE,CAAG,CAC9EC,MAAM,CAAAC,MAAA,CAAAC,MAAA,CAAA,EAAA,CACDP,oBAAoB,CACvBQ,CAAAA,MAAM,CAAE,MAAM,CACf,CAAA,CACDC,KAAK,CAAAH,MAAA,CAAAC,MAAA,CAAA,EAAA,CACAP,oBAAoB,CAKvBQ,CAAAA,MAAM,CAAE,MAAM,CACf,CAAA,CACDE,MAAM,CAAAJ,MAAA,CAAAC,MAAA,CAAA,EAAA,CACDP,oBAAoB,CACvBQ,CAAAA,MAAM,CAAE,MAAM,CAElB,CAAA,CAAC,CAED,IAAMG,wBAAwB,CAAG,CAC/BC,QAAQ,CAAE,UAAU,CACpBC,GAAG,CAAE,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AAA,CAACG,GAAG,CAACoB,CAAAA,KAAK,CAAC,MAAM,CAAA7C,QAAA,CAAEA,QAAQ,CAAM,CAAC,CACjCC,0BAA0B,EAAID,QAAQ,CACrCsB,GAAA,CAACG,GAAG,CAAA1G,MAAA,CAAAC,MAAA,CAAA,CAAC8H,SAAS,CAAC,YAAY,CAAKjI,CAAAA,cAAc,CAACgB,MAAI,CAAC,CAAAmE,CAAAA,QAAA,CACjDC,0BAA0B,CAAA,CACxB,CAAC,CACJ,IAAI,CACD,CAAA,CAAC,CACH,CAAA,CAAA,CAAC,CACT1B,WAAW,CAAG+C,GAAA,CAACyB,OAAO,CAAAhI,MAAA,CAAAC,MAAA,CAAA,EAAA,CAAKoF,YAAY,CAAG,CAAC,CAAG,IAAI,GAC5C,CAAC,CAEd,CAAC,CAEK,IAAA4C,UAAU,CAAGC,wBAAwB,CAAChF,WAAW,CAAE,CACvDiF,WAAW,CAAE,YACf,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"BaseHeader.js","sources":["../../../../../src/components/BaseHeaderFooter/BaseHeader.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react';\nimport type { ReactDOMAttributes } from '@use-gesture/react/dist/declarations/src/types';\nimport { Divider } from '~components/Divider';\nimport type { DividerProps } from '~components/Divider';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Heading, Text } from '~components/Typography';\nimport { IconButton } from '~components/Button/IconButton';\nimport { ChevronLeftIcon, CloseIcon } from '~components/Icons';\nimport type { DataAnalyticsAttribute, TestID } from '~utils/types';\nimport type { BoxProps } from '~components/Box';\nimport { Box } from '~components/Box';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { isReactNative, makeSize } from '~utils';\nimport { metaAttribute } from '~utils/metaAttribute';\nimport { logger, throwBladeError } from '~utils/logger';\nimport { size as sizeToken } from '~tokens/global';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype BaseHeaderProps = {\n title?: string;\n subtitle?: string;\n /**\n * Leading part of the header placed at the left most side of the header\n */\n leading?: React.ReactNode;\n /**\n * Trailing part of the header placed at the right most side of the header\n */\n trailing?: React.ReactNode;\n /**\n * Placed adjacent to the title text\n */\n titleSuffix?: React.ReactNode;\n /**\n * @default true\n */\n showDivider?: boolean;\n /**\n * @default false\n */\n showBackButton?: boolean;\n\n /**\n * Slot for rendering any trailing interaction element into BaseHeader.\n *\n * E.g. Used in accordion to render CollapsibleChevronIcon\n */\n trailingInteractionElement?: React.ReactNode;\n\n /**\n * Decides size of the Header\n */\n size?: 'xlarge' | 'large' | 'medium';\n /**\n * @default true\n */\n showCloseButton?: boolean;\n\n /**\n * Disabled state of BaseHeader\n *\n * @default false\n */\n isDisabled?: boolean;\n\n paddingX?: BoxProps['paddingX'];\n marginY?: BoxProps['marginY'];\n marginTop?: BoxProps['marginTop'];\n marginBottom?: BoxProps['marginBottom'];\n alignItems?: BoxProps['alignItems'];\n dividerProps?: DividerProps;\n\n onCloseButtonClick?: () => void;\n onBackButtonClick?: () => void;\n closeButtonRef?: React.MutableRefObject<any>;\n backButtonRef?: React.MutableRefObject<any>;\n metaComponentName?: string;\n /**\n * inner child of BottomSheetHeader. Meant to be used for AutoComplete only\n */\n children?: React.ReactElement | React.ReactElement[];\n /**\n * Background image of the header\n *\n * You can use this for adding gradients.\n */\n backgroundImage?: BoxProps['backgroundImage'];\n /**\n * So we add a wrapper with custom styles in elements like leading, trailing interaction elements and trailing.\n * this props allows you to control that.\n *\n * For example, in Accordion, we add a wrapper with flex to center the icon (in some cases)\n *\n * @default false\n */\n shouldAlignLeadingAndTrailingElementsToCenter?: boolean;\n} & Pick<\n ReactDOMAttributes,\n | 'onClickCapture'\n | 'onKeyDown'\n | 'onKeyUp'\n | 'onLostPointerCapture'\n | 'onPointerCancel'\n | 'onPointerDown'\n | 'onPointerMove'\n | 'onPointerUp'\n> &\n TestID &\n DataAnalyticsAttribute;\n\ntype TrailingComponents = 'Button' | 'Badge' | 'Link' | 'Text' | 'Amount';\n\nconst commonCenterBoxProps: BoxProps = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n};\n\nconst centerBoxProps: { xlarge: BoxProps; large: BoxProps; medium: BoxProps } = {\n xlarge: {\n ...commonCenterBoxProps,\n height: '28px',\n },\n large: {\n ...commonCenterBoxProps,\n // We want to align title, icon, titleSuffix, trailing, closeButton to baseline\n // But we also want to keep them center aligned to each other\n // So we add a virtual Box around these slots with 28px and center align them to that box\n // We have done similar thing in figma as well (which is where this 28px comes from)\n height: '28px',\n },\n medium: {\n ...commonCenterBoxProps,\n height: '20px',\n },\n};\n\nconst absolutePositionedButton = {\n position: 'absolute',\n top: 'spacing.0',\n right: 'spacing.0',\n} as const;\n\nconst sizeTokensMapping = {\n xlarge: {\n title: 'small',\n type: 'heading',\n },\n large: {\n title: 'large',\n type: 'text',\n },\n medium: {\n title: 'medium',\n type: 'text',\n },\n} as const;\n\n// prop restriction map for corresponding sub components\nconst propRestrictionMap = {\n large: {\n Button: {\n size: 'xsmall',\n variant: 'tertiary',\n },\n IconButton: {\n size: 'large',\n },\n Badge: {\n size: 'medium',\n },\n Link: {\n size: 'medium',\n },\n Text: {\n size: 'medium',\n variant: 'body',\n },\n Amount: {\n type: 'body',\n size: 'medium',\n },\n },\n xlarge: {\n Button: {\n size: 'xsmall',\n variant: 'tertiary',\n },\n IconButton: {\n size: 'large',\n },\n Badge: {\n size: 'medium',\n },\n Link: {\n size: 'medium',\n },\n Text: {\n size: 'medium',\n variant: 'body',\n },\n Amount: {\n type: 'body',\n size: 'medium',\n },\n },\n medium: {\n Button: {\n size: 'xsmall',\n variant: 'tertiary',\n },\n IconButton: {\n size: 'large',\n },\n Badge: {\n size: 'small',\n },\n Link: {\n size: 'small',\n },\n Text: {\n size: 'small',\n variant: 'body',\n },\n Amount: {\n type: 'body',\n size: 'small',\n },\n },\n} as const;\n\nconst useTrailingRestriction = ({\n trailing,\n size,\n}: {\n size: NonNullable<BaseHeaderProps['size']>;\n trailing: BaseHeaderProps['trailing'];\n}): React.ReactNode => {\n const [\n validatedTrailingComponent,\n setValidatedTrailingComponent,\n ] = React.useState<React.ReactElement | null>(null);\n\n // validate and restrict sub component props in trailing prop\n React.useEffect(() => {\n if (React.isValidElement(trailing)) {\n const trailingComponentType = getComponentId(trailing) as TrailingComponents;\n const restrictedProps = propRestrictionMap[size][trailingComponentType];\n\n const allowedComponents = Object.keys(propRestrictionMap[size]);\n if (__DEV__) {\n if (!restrictedProps) {\n throwBladeError({\n message: `Only one of \\`${allowedComponents.join(\n ', ',\n )}\\` component is accepted as trailing`,\n moduleName: 'Header',\n });\n }\n }\n\n const restrictedPropKeys = Object.keys(propRestrictionMap[size][trailingComponentType]);\n for (const prop of restrictedPropKeys) {\n if (trailing?.props?.hasOwnProperty(prop)) {\n logger({\n message: `Do not pass \"${prop}\" to \"${trailingComponentType}\" while inside Header trailing, because we override it.`,\n moduleName: 'Header',\n type: 'warn',\n });\n }\n }\n setValidatedTrailingComponent(\n React.cloneElement(trailing as React.ReactElement, restrictedProps),\n );\n }\n }, [trailing, size]);\n\n return validatedTrailingComponent;\n};\n\nconst _BaseHeader = ({\n title,\n subtitle,\n leading,\n titleSuffix,\n trailing,\n showDivider = true,\n showBackButton = false,\n showCloseButton = true,\n onBackButtonClick,\n onCloseButtonClick,\n closeButtonRef,\n backButtonRef,\n testID,\n onClickCapture,\n onKeyDown,\n onKeyUp,\n onLostPointerCapture,\n onPointerCancel,\n onPointerDown,\n onPointerMove,\n onPointerUp,\n metaComponentName,\n paddingX,\n marginY,\n marginBottom,\n marginTop,\n size = 'large',\n isDisabled,\n children,\n trailingInteractionElement,\n backgroundImage,\n alignItems = 'flex-start',\n dividerProps,\n shouldAlignLeadingAndTrailingElementsToCenter = false,\n ...rest\n}: BaseHeaderProps): React.ReactElement => {\n const validatedTrailingComponent = useTrailingRestriction({ trailing, size });\n const shouldWrapTitle = titleSuffix && trailing && showBackButton && showCloseButton;\n const hasOnlyChildren = children && !(title || subtitle || titleSuffix || leading);\n\n const webOnlyEventHandlers: Record<string, any> = isReactNative()\n ? {}\n : {\n onClickCapture,\n onKeyDown,\n onKeyUp,\n onLostPointerCapture,\n onPointerCancel,\n onPointerDown,\n onPointerMove,\n onPointerUp,\n };\n\n const renderTrailingInteractionElementWithChildren = (): React.ReactNode => {\n if (trailingInteractionElement && children) {\n return (\n <Box\n alignSelf={shouldAlignLeadingAndTrailingElementsToCenter ? 'center' : 'flex-start'}\n {...centerBoxProps[size]}\n >\n {trailingInteractionElement}\n </Box>\n );\n }\n return null;\n };\n\n const renderTrailingInteractionElementWithoutChildren = (): React.ReactNode => {\n if (trailingInteractionElement && !children) {\n return (\n <Box\n {...centerBoxProps[size]}\n alignSelf={shouldAlignLeadingAndTrailingElementsToCenter ? 'center' : undefined}\n >\n {trailingInteractionElement}\n </Box>\n );\n }\n return null;\n };\n\n const renderLeadingElement = (): React.ReactNode => {\n if (Boolean(leading)) {\n return (\n <BaseBox\n marginRight=\"spacing.3\"\n {...centerBoxProps[size]}\n alignSelf={shouldAlignLeadingAndTrailingElementsToCenter ? 'center' : undefined}\n >\n {leading}\n </BaseBox>\n );\n }\n return null;\n };\n\n const renderTrailingElement = (): React.ReactNode => {\n if (shouldAlignLeadingAndTrailingElementsToCenter && validatedTrailingComponent) {\n return (\n <BaseBox marginRight=\"spacing.5\" display=\"flex\" alignItems=\"center\" justifyContent=\"center\">\n <Box {...centerBoxProps[size]}>{validatedTrailingComponent}</Box>\n </BaseBox>\n );\n }\n if (validatedTrailingComponent) {\n return (\n <BaseBox marginRight=\"spacing.5\">\n <Box {...centerBoxProps[size]}>{validatedTrailingComponent}</Box>\n </BaseBox>\n );\n }\n return null;\n };\n\n return (\n <BaseBox\n {...metaAttribute({ name: metaComponentName, testID })}\n {...makeAnalyticsAttribute(rest)}\n backgroundImage={backgroundImage}\n >\n <BaseBox\n marginY={marginY ?? { base: 'spacing.5', m: 'spacing.6' }}\n paddingX={paddingX ?? { base: 'spacing.5', m: 'spacing.6' }}\n marginTop={marginTop}\n marginBottom={marginBottom}\n touchAction=\"none\"\n {...webOnlyEventHandlers}\n >\n <BaseBox position=\"relative\" display=\"flex\" flexDirection=\"row\" userSelect=\"none\">\n {showBackButton ? (\n <BaseBox overflow=\"visible\" marginRight=\"spacing.5\">\n <Box {...centerBoxProps[size]}>\n <IconButton\n ref={backButtonRef}\n size=\"large\"\n icon={ChevronLeftIcon}\n onClick={() => onBackButtonClick?.()}\n accessibilityLabel=\"Back\"\n />\n </Box>\n </BaseBox>\n ) : null}\n {hasOnlyChildren ? null : (\n <BaseBox\n paddingRight=\"spacing.5\"\n marginRight=\"auto\"\n flex=\"auto\"\n display=\"flex\"\n flexDirection=\"row\"\n alignItems={alignItems}\n >\n {renderLeadingElement()}\n <BaseBox flex=\"auto\">\n <BaseBox\n // Explicitly setting maxWidth in React Native because text is not being wrapped properly when multiple fix width components are rendered in header\n // In web, flex containers seem to work a expected\n // @todo: resolve this if we figure out some better solution later\n maxWidth={isReactNative() && shouldWrapTitle ? '100px' : undefined}\n flexShrink={0}\n display=\"flex\"\n flexDirection=\"row\"\n >\n {title ? (\n sizeTokensMapping[size].type === 'heading' ? (\n <Heading\n as=\"h2\"\n marginTop={makeSize(sizeToken['1'])}\n size={sizeTokensMapping[size].title}\n weight=\"semibold\"\n color={\n isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.normal'\n }\n wordBreak=\"break-word\"\n >\n {title}\n </Heading>\n ) : (\n <Text\n size={sizeTokensMapping[size].title}\n marginTop={makeSize(sizeToken['1'])}\n weight=\"semibold\"\n color={\n isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.normal'\n }\n wordBreak=\"break-word\"\n >\n {title}\n </Text>\n )\n ) : null}\n {titleSuffix && (\n <BaseBox marginLeft=\"spacing.3\">\n <Box {...centerBoxProps[size]}>{titleSuffix}</Box>\n </BaseBox>\n )}\n </BaseBox>\n {subtitle ? (\n <Text\n variant=\"body\"\n size=\"small\"\n weight=\"regular\"\n color={isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.muted'}\n >\n {subtitle}\n </Text>\n ) : null}\n </BaseBox>\n </BaseBox>\n )}\n {renderTrailingElement()}\n\n {showCloseButton ? (\n <Box {...(hasOnlyChildren ? absolutePositionedButton : centerBoxProps[size])}>\n <IconButton\n ref={closeButtonRef}\n size=\"large\"\n icon={CloseIcon}\n accessibilityLabel=\"Close\"\n onClick={() => onCloseButtonClick?.()}\n />\n </Box>\n ) : null}\n {renderTrailingInteractionElementWithoutChildren()}\n </BaseBox>\n <BaseBox\n display=\"flex\"\n width=\"100%\"\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent=\"space-between\"\n >\n <Box width=\"100%\">{children}</Box>\n {renderTrailingInteractionElementWithChildren()}\n </BaseBox>\n </BaseBox>\n {showDivider ? <Divider {...dividerProps} /> : null}\n </BaseBox>\n );\n};\n\nconst BaseHeader = assignWithoutSideEffects(_BaseHeader, {\n componentId: 'BaseHeader',\n});\n\nexport type { BaseHeaderProps };\nexport { BaseHeader };\n"],"names":["commonCenterBoxProps","display","alignItems","justifyContent","centerBoxProps","xlarge","Object","assign","height","large","medium","absolutePositionedButton","position","top","right","sizeTokensMapping","title","type","propRestrictionMap","Button","size","variant","IconButton","Badge","Link","Text","Amount","useTrailingRestriction","_ref","trailing","_React$useState","React","useState","_React$useState2","_slicedToArray","validatedTrailingComponent","setValidatedTrailingComponent","useEffect","isValidElement","trailingComponentType","getComponentId","restrictedProps","allowedComponents","keys","__DEV__","throwBladeError","message","join","moduleName","restrictedPropKeys","prop","_trailing$props","props","hasOwnProperty","logger","cloneElement","_BaseHeader","_ref2","subtitle","leading","titleSuffix","_ref2$showDivider","showDivider","_ref2$showBackButton","showBackButton","_ref2$showCloseButton","showCloseButton","onBackButtonClick","onCloseButtonClick","closeButtonRef","backButtonRef","testID","onClickCapture","onKeyDown","onKeyUp","onLostPointerCapture","onPointerCancel","onPointerDown","onPointerMove","onPointerUp","metaComponentName","paddingX","marginY","marginBottom","marginTop","_ref2$size","isDisabled","children","trailingInteractionElement","backgroundImage","_ref2$alignItems","dividerProps","_ref2$shouldAlignLead","shouldAlignLeadingAndTrailingElementsToCenter","rest","_objectWithoutProperties","_excluded","shouldWrapTitle","hasOnlyChildren","webOnlyEventHandlers","isReactNative","renderTrailingInteractionElementWithChildren","_jsx","Box","alignSelf","renderTrailingInteractionElementWithoutChildren","undefined","renderLeadingElement","Boolean","BaseBox","marginRight","renderTrailingElement","_jsxs","metaAttribute","name","makeAnalyticsAttribute","base","m","touchAction","flexDirection","userSelect","overflow","ref","icon","ChevronLeftIcon","onClick","accessibilityLabel","paddingRight","flex","maxWidth","flexShrink","Heading","as","makeSize","sizeToken","weight","color","wordBreak","marginLeft","CloseIcon","width","Divider","BaseHeader","assignWithoutSideEffects","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;siBAkHA,IAAMA,oBAA8B,CAAG,CACrCC,OAAO,CAAE,MAAM,CACfC,UAAU,CAAE,QAAQ,CACpBC,cAAc,CAAE,QAClB,CAAC,CAED,IAAMC,cAAuE,CAAG,CAC9EC,MAAM,CAAAC,MAAA,CAAAC,MAAA,CACDP,EAAAA,CAAAA,oBAAoB,CACvBQ,CAAAA,MAAM,CAAE,MAAM,CAAA,CACf,CACDC,KAAK,CAAAH,MAAA,CAAAC,MAAA,CACAP,EAAAA,CAAAA,oBAAoB,CAKvBQ,CAAAA,MAAM,CAAE,MAAM,EACf,CACDE,MAAM,CAAAJ,MAAA,CAAAC,MAAA,IACDP,oBAAoB,CAAA,CACvBQ,MAAM,CAAE,MAAM,CAAA,CAElB,CAAC,CAED,IAAMG,wBAAwB,CAAG,CAC/BC,QAAQ,CAAE,UAAU,CACpBC,GAAG,CAAE,WAAW,CAChBC,KAAK,CAAE,WACT,CAAU,CAEV,IAAMC,iBAAiB,CAAG,CACxBV,MAAM,CAAE,CACNW,KAAK,CAAE,O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AC,QAAQ,CACnBC,cAAc,CAAC,eAAe,CAAAoF,QAAA,CAAA,CAE9Be,GAAA,CAACC,GAAG,CAACqC,CAAAA,KAAK,CAAC,MAAM,CAAArD,QAAA,CAAEA,QAAQ,CAAM,CAAC,CACjCc,4CAA4C,EAAE,CACxC,CAAA,CAAC,CACH,CAAA,CAAA,CAAC,CACTvC,WAAW,CAAGwC,GAAA,CAACuC,OAAO,CAAAvI,MAAA,CAAAC,MAAA,IAAKoF,YAAY,CAAG,CAAC,CAAG,IAAI,CAAA,CAAA,CAC5C,CAAC,CAEd,CAAC,CAEK,IAAAmD,UAAU,CAAGC,wBAAwB,CAACvF,WAAW,CAAE,CACvDwF,WAAW,CAAE,YACf,CAAC;;;;"}
|
|
@@ -10,18 +10,27 @@ import { CollapsibleChevronIcon } from '../Collapsible/CollapsibleChevronIcon.we
|
|
|
10
10
|
import '../../utils/assignWithoutSideEffects/index.js';
|
|
11
11
|
import '../../utils/metaAttribute/index.js';
|
|
12
12
|
import '../../utils/makeAnalyticsAttribute/index.js';
|
|
13
|
-
import
|
|
13
|
+
import '../../utils/makeSize/index.js';
|
|
14
|
+
import '../../tokens/global/index.js';
|
|
15
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
16
|
+
import { makeSize } from '../../utils/makeSize/makeSize.js';
|
|
17
|
+
import { size } from '../../tokens/global/size.js';
|
|
18
|
+
import { Text } from '../Typography/Text/Text.js';
|
|
14
19
|
import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
|
|
15
20
|
import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
|
|
16
21
|
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
17
|
-
import { Text } from '../Typography/Text/Text.js';
|
|
18
22
|
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
19
23
|
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
20
24
|
|
|
21
25
|
var _excluded = ["title", "subtitle", "leading", "children", "trailing", "titleSuffix"];
|
|
22
26
|
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; }
|
|
23
27
|
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; }
|
|
28
|
+
var getLeadingElementMaxHeightAndWidth = function getLeadingElementMaxHeightAndWidth(size$1) {
|
|
29
|
+
if (size$1 === 'large') return makeSize(size['32']);
|
|
30
|
+
return makeSize(size['24']);
|
|
31
|
+
};
|
|
24
32
|
var _AccordionItemHeader = function _AccordionItemHeader(_ref) {
|
|
33
|
+
var _leading$type$name;
|
|
25
34
|
var title = _ref.title,
|
|
26
35
|
subtitle = _ref.subtitle,
|
|
27
36
|
leading = _ref.leading,
|
|
@@ -36,30 +45,46 @@ var _AccordionItemHeader = function _AccordionItemHeader(_ref) {
|
|
|
36
45
|
var _useAccordionItemInde = useAccordionItemIndex(),
|
|
37
46
|
index = _useAccordionItemInde.index,
|
|
38
47
|
isDisabled = _useAccordionItemInde.isDisabled;
|
|
48
|
+
var isLeadingIcon = /*#__PURE__*/React__default.isValidElement(leading) && typeof leading.type === 'function' && ((_leading$type$name = leading.type.name) === null || _leading$type$name === void 0 ? void 0 : _leading$type$name.endsWith('Icon'));
|
|
39
49
|
var isLeadingNumberOrIcon = React__default.useMemo(function () {
|
|
40
|
-
var _leading$type$name;
|
|
41
50
|
// Check if leading is a number
|
|
42
51
|
if (showNumberPrefix && typeof index === 'number') return true;
|
|
43
52
|
|
|
44
53
|
// Check if leading is an Icon component (name ends with "Icon")
|
|
45
|
-
if (
|
|
54
|
+
if (isLeadingIcon) return true;
|
|
46
55
|
return false;
|
|
47
|
-
}, [
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
children: /*#__PURE__*/jsx(BaseHeader, _objectSpread(_objectSpread({
|
|
53
|
-
leading: showNumberPrefix && typeof index === 'number' ?
|
|
54
|
-
/*#__PURE__*/
|
|
55
|
-
// we have to add -2px margin to align the number with title of BaseHeader
|
|
56
|
-
jsxs(Text, {
|
|
56
|
+
}, [showNumberPrefix, index, isLeadingIcon]);
|
|
57
|
+
var shouldAlignHeaderItemsInCenter = Boolean(children || Boolean(leading) && !isLeadingNumberOrIcon);
|
|
58
|
+
var leadingElement = React__default.useMemo(function () {
|
|
59
|
+
if (showNumberPrefix && typeof index === 'number') {
|
|
60
|
+
return /*#__PURE__*/jsxs(Text, {
|
|
57
61
|
size: size,
|
|
58
62
|
weight: "semibold",
|
|
59
63
|
marginTop: "-2px",
|
|
60
64
|
as: "span",
|
|
61
65
|
children: [index + 1, "."]
|
|
62
|
-
})
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (leading) {
|
|
69
|
+
return /*#__PURE__*/jsx(BaseBox, {
|
|
70
|
+
marginRight: isLeadingIcon ? 'spacing.0' : 'spacing.3',
|
|
71
|
+
marginTop: "spacing.1"
|
|
72
|
+
// So in design, we have set max height and width for the leading element, doing same here
|
|
73
|
+
,
|
|
74
|
+
maxHeight: getLeadingElementMaxHeightAndWidth(size),
|
|
75
|
+
maxWidth: getLeadingElementMaxHeightAndWidth(size),
|
|
76
|
+
overflow: "hidden",
|
|
77
|
+
children: leading
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}, [showNumberPrefix, index, leading, size, isLeadingIcon]);
|
|
82
|
+
return /*#__PURE__*/jsx(BaseBox, _objectSpread(_objectSpread({}, metaAttribute({
|
|
83
|
+
name: MetaConstants.AccordionItemHeader
|
|
84
|
+
})), {}, {
|
|
85
|
+
flex: "1",
|
|
86
|
+
children: /*#__PURE__*/jsx(BaseHeader, _objectSpread(_objectSpread({
|
|
87
|
+
leading: leadingElement,
|
|
63
88
|
title: title,
|
|
64
89
|
subtitle: subtitle,
|
|
65
90
|
trailing: trailing,
|
|
@@ -79,7 +104,8 @@ var _AccordionItemHeader = function _AccordionItemHeader(_ref) {
|
|
|
79
104
|
trailingInteractionElement: /*#__PURE__*/jsx(CollapsibleChevronIcon, {
|
|
80
105
|
color: isDisabled ? 'interactive.icon.gray.disabled' : 'interactive.icon.gray.muted',
|
|
81
106
|
size: "large"
|
|
82
|
-
})
|
|
107
|
+
}),
|
|
108
|
+
shouldAlignLeadingAndTrailingElementsToCenter: shouldAlignHeaderItemsInCenter
|
|
83
109
|
}, makeAnalyticsAttribute(rest)), {}, {
|
|
84
110
|
children: children
|
|
85
111
|
}))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionItemHeader.js","sources":["../../../../../../src/components/Accordion/AccordionItemHeader.tsx"],"sourcesContent":["import React from 'react';\nimport { useAccordion, useAccordionItemIndex } from './AccordionContext';\nimport { componentIds } from './componentIds';\nimport type { BaseHeaderProps } from '~components/BaseHeaderFooter/BaseHeader';\nimport { BaseHeader } from '~components/BaseHeaderFooter/BaseHeader';\nimport { Text } from '~components/Typography';\nimport BaseBox from '~components/Box/BaseBox';\nimport { CollapsibleChevronIcon } from '~components/Collapsible/CollapsibleChevronIcon';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport type { DataAnalyticsAttribute } from '~utils/types';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\nconst _AccordionItemHeader = ({\n title,\n subtitle,\n leading,\n children,\n trailing,\n titleSuffix,\n ...rest\n}: Pick<\n BaseHeaderProps,\n 'title' | 'subtitle' | 'leading' | 'children' | 'trailing' | 'titleSuffix'\n> &\n DataAnalyticsAttribute): React.ReactElement => {\n const { size, showNumberPrefix, expandedIndex } = useAccordion();\n const { index, isDisabled } = useAccordionItemIndex();\n\n const isLeadingNumberOrIcon = React.useMemo(() => {\n // Check if leading is a number\n if (showNumberPrefix && typeof index === 'number') return true;\n\n // Check if leading is an Icon component (name ends with \"Icon\")\n if (
|
|
1
|
+
{"version":3,"file":"AccordionItemHeader.js","sources":["../../../../../../src/components/Accordion/AccordionItemHeader.tsx"],"sourcesContent":["import React from 'react';\nimport { useAccordion, useAccordionItemIndex } from './AccordionContext';\nimport { componentIds } from './componentIds';\nimport type { BaseHeaderProps } from '~components/BaseHeaderFooter/BaseHeader';\nimport { BaseHeader } from '~components/BaseHeaderFooter/BaseHeader';\nimport { Text } from '~components/Typography';\nimport BaseBox from '~components/Box/BaseBox';\nimport { CollapsibleChevronIcon } from '~components/Collapsible/CollapsibleChevronIcon';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport type { DataAnalyticsAttribute } from '~utils/types';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport type { BoxProps } from '~components/Box';\nimport { makeSize } from '~utils/makeSize';\nimport { size as sizeToken } from '~tokens/global';\n\nconst getLeadingElementMaxHeightAndWidth = (\n size: BaseHeaderProps['size'],\n): BoxProps['maxHeight'] => {\n if (size === 'large') return makeSize(sizeToken['32']);\n return makeSize(sizeToken['24']);\n};\n\nconst _AccordionItemHeader = ({\n title,\n subtitle,\n leading,\n children,\n trailing,\n titleSuffix,\n ...rest\n}: Pick<\n BaseHeaderProps,\n 'title' | 'subtitle' | 'leading' | 'children' | 'trailing' | 'titleSuffix'\n> &\n DataAnalyticsAttribute): React.ReactElement => {\n const { size, showNumberPrefix, expandedIndex } = useAccordion();\n const { index, isDisabled } = useAccordionItemIndex();\n\n const isLeadingIcon =\n React.isValidElement(leading) &&\n typeof leading.type === 'function' &&\n leading.type.name?.endsWith('Icon');\n\n const isLeadingNumberOrIcon = React.useMemo(() => {\n // Check if leading is a number\n if (showNumberPrefix && typeof index === 'number') return true;\n\n // Check if leading is an Icon component (name ends with \"Icon\")\n if (isLeadingIcon) return true;\n\n return false;\n }, [showNumberPrefix, index, isLeadingIcon]);\n\n const shouldAlignHeaderItemsInCenter = Boolean(\n children || (Boolean(leading) && !isLeadingNumberOrIcon),\n );\n\n const leadingElement = React.useMemo(() => {\n if (showNumberPrefix && typeof index === 'number') {\n return (\n <Text size={size} weight=\"semibold\" marginTop=\"-2px\" as=\"span\">\n {index + 1}.\n </Text>\n );\n }\n if (leading) {\n return (\n <BaseBox\n marginRight={isLeadingIcon ? 'spacing.0' : 'spacing.3'}\n marginTop=\"spacing.1\"\n // So in design, we have set max height and width for the leading element, doing same here\n maxHeight={getLeadingElementMaxHeightAndWidth(size)}\n maxWidth={getLeadingElementMaxHeightAndWidth(size)}\n overflow=\"hidden\"\n >\n {leading}\n </BaseBox>\n );\n }\n return null;\n }, [showNumberPrefix, index, leading, size, isLeadingIcon]);\n\n return (\n <BaseBox {...metaAttribute({ name: MetaConstants.AccordionItemHeader })} flex=\"1\">\n <BaseHeader\n leading={leadingElement}\n title={title}\n subtitle={subtitle}\n trailing={trailing}\n titleSuffix={titleSuffix}\n isDisabled={isDisabled}\n showBackButton={false}\n showCloseButton={false}\n showDivider={expandedIndex === index}\n paddingX=\"spacing.5\"\n marginY=\"spacing.5\"\n size={size}\n alignItems={!subtitle && !isLeadingNumberOrIcon ? 'center' : 'flex-start'}\n dividerProps={{\n thickness: 'thinner',\n marginX: 'spacing.5',\n }}\n trailingInteractionElement={\n <CollapsibleChevronIcon\n color={isDisabled ? 'interactive.icon.gray.disabled' : 'interactive.icon.gray.muted'}\n size=\"large\"\n />\n }\n shouldAlignLeadingAndTrailingElementsToCenter={shouldAlignHeaderItemsInCenter}\n {...makeAnalyticsAttribute(rest)}\n >\n {children}\n </BaseHeader>\n </BaseBox>\n );\n};\n\nconst AccordionItemHeader = assignWithoutSideEffects(_AccordionItemHeader, {\n componentId: componentIds.AccordionItemHeader,\n});\n\nexport { AccordionItemHeader };\n"],"names":["getLeadingElementMaxHeightAndWidth","size","makeSize","sizeToken","_AccordionItemHeader","_ref","_leading$type$name","title","subtitle","leading","children","trailing","titleSuffix","rest","_objectWithoutProperties","_excluded","_useAccordion","useAccordion","showNumberPrefix","expandedIndex","_useAccordionItemInde","useAccordionItemIndex","index","isDisabled","isLeadingIcon","React","isValidElement","type","name","endsWith","isLeadingNumberOrIcon","useMemo","shouldAlignHeaderItemsInCenter","Boolean","leadingElement","_jsxs","Text","weight","marginTop","as","_jsx","BaseBox","marginRight","maxHeight","maxWidth","overflow","_objectSpread","metaAttribute","MetaConstants","AccordionItemHeader","flex","BaseHeader","showBackButton","showCloseButton","showDivider","paddingX","marginY","alignItems","dividerProps","thickness","marginX","trailingInteractionElement","CollapsibleChevronIcon","color","shouldAlignLeadingAndTrailingElementsToCenter","makeAnalyticsAttribute","assignWithoutSideEffects","componentId","componentIds"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAMA,kCAAkC,GAAG,SAArCA,kCAAkCA,CACtCC,MAA6B,EACH;EAC1B,IAAIA,MAAI,KAAK,OAAO,EAAE,OAAOC,QAAQ,CAACC,IAAS,CAAC,IAAI,CAAC,CAAC,CAAA;AACtD,EAAA,OAAOD,QAAQ,CAACC,IAAS,CAAC,IAAI,CAAC,CAAC,CAAA;AAClC,CAAC,CAAA;AAED,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAAC,IAAA,EAYuB;AAAA,EAAA,IAAAC,kBAAA,CAAA;AAAA,EAAA,IAX/CC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,OAAO,GAAAJ,IAAA,CAAPI,OAAO;IACPC,QAAQ,GAAAL,IAAA,CAARK,QAAQ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AA,KAAK,EAAEA,KAAM;AACbC,MAAAA,QAAQ,EAAEA,QAAS;AACnBG,MAAAA,QAAQ,EAAEA,QAAS;AACnBC,MAAAA,WAAW,EAAEA,WAAY;AACzBW,MAAAA,UAAU,EAAEA,UAAW;AACvB6B,MAAAA,cAAc,EAAE,KAAM;AACtBC,MAAAA,eAAe,EAAE,KAAM;MACvBC,WAAW,EAAEnC,aAAa,KAAKG,KAAM;AACrCiC,MAAAA,QAAQ,EAAC,WAAW;AACpBC,MAAAA,OAAO,EAAC,WAAW;AACnBvD,MAAAA,IAAI,EAAEA,IAAK;MACXwD,UAAU,EAAE,CAACjD,QAAQ,IAAI,CAACsB,qBAAqB,GAAG,QAAQ,GAAG,YAAa;AAC1E4B,MAAAA,YAAY,EAAE;AACZC,QAAAA,SAAS,EAAE,SAAS;AACpBC,QAAAA,OAAO,EAAE,WAAA;OACT;MACFC,0BAA0B,eACxBrB,GAAA,CAACsB,sBAAsB,EAAA;AACrBC,QAAAA,KAAK,EAAExC,UAAU,GAAG,gCAAgC,GAAG,6BAA8B;AACrFtB,QAAAA,IAAI,EAAC,OAAA;AAAO,OACb,CACF;AACD+D,MAAAA,6CAA6C,EAAEhC,8BAAAA;KAC3CiC,EAAAA,sBAAsB,CAACpD,IAAI,CAAC,CAAA,EAAA,EAAA,EAAA;AAAAH,MAAAA,QAAA,EAE/BA,QAAAA;KACS,CAAA,CAAA;AAAC,GAAA,CACN,CAAC,CAAA;AAEd,CAAC,CAAA;AAED,IAAMuC,mBAAmB,gBAAGiB,wBAAwB,CAAC9D,oBAAoB,EAAE;EACzE+D,WAAW,EAAEC,YAAY,CAACnB,mBAAAA;AAC5B,CAAC;;;;"}
|
|
@@ -15,14 +15,14 @@ import '../../utils/metaAttribute/index.js';
|
|
|
15
15
|
import '../../utils/logger/index.js';
|
|
16
16
|
import '../../tokens/global/index.js';
|
|
17
17
|
import '../../utils/makeAnalyticsAttribute/index.js';
|
|
18
|
-
import {
|
|
18
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
19
19
|
import { getComponentId } from '../../utils/isValidAllowedChildren/isValidAllowedChildren.js';
|
|
20
20
|
import { throwBladeError, logger } from '../../utils/logger/logger.js';
|
|
21
21
|
import { isReactNative } from '../../utils/platform/isReactNative.js';
|
|
22
|
+
import { Box } from '../Box/Box.js';
|
|
22
23
|
import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
|
|
23
24
|
import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
|
|
24
25
|
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
25
|
-
import { Box } from '../Box/Box.js';
|
|
26
26
|
import { IconButton } from '../Button/IconButton/IconButton.js';
|
|
27
27
|
import ChevronLeftIcon from '../Icons/ChevronLeftIcon/ChevronLeftIcon.js';
|
|
28
28
|
import { Heading } from '../Typography/Heading/Heading.js';
|
|
@@ -33,7 +33,7 @@ import CloseIcon from '../Icons/CloseIcon/CloseIcon.js';
|
|
|
33
33
|
import { Divider } from '../Divider/Divider.js';
|
|
34
34
|
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
35
35
|
|
|
36
|
-
var _excluded = ["title", "subtitle", "leading", "titleSuffix", "trailing", "showDivider", "showBackButton", "showCloseButton", "onBackButtonClick", "onCloseButtonClick", "closeButtonRef", "backButtonRef", "testID", "onClickCapture", "onKeyDown", "onKeyUp", "onLostPointerCapture", "onPointerCancel", "onPointerDown", "onPointerMove", "onPointerUp", "metaComponentName", "paddingX", "marginY", "marginBottom", "marginTop", "size", "isDisabled", "children", "trailingInteractionElement", "backgroundImage", "alignItems", "dividerProps"];
|
|
36
|
+
var _excluded = ["title", "subtitle", "leading", "titleSuffix", "trailing", "showDivider", "showBackButton", "showCloseButton", "onBackButtonClick", "onCloseButtonClick", "closeButtonRef", "backButtonRef", "testID", "onClickCapture", "onKeyDown", "onKeyUp", "onLostPointerCapture", "onPointerCancel", "onPointerDown", "onPointerMove", "onPointerUp", "metaComponentName", "paddingX", "marginY", "marginBottom", "marginTop", "size", "isDisabled", "children", "trailingInteractionElement", "backgroundImage", "alignItems", "dividerProps", "shouldAlignLeadingAndTrailingElementsToCenter"];
|
|
37
37
|
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; }
|
|
38
38
|
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; }
|
|
39
39
|
var commonCenterBoxProps = {
|
|
@@ -226,6 +226,8 @@ var _BaseHeader = function _BaseHeader(_ref2) {
|
|
|
226
226
|
_ref2$alignItems = _ref2.alignItems,
|
|
227
227
|
alignItems = _ref2$alignItems === void 0 ? 'flex-start' : _ref2$alignItems,
|
|
228
228
|
dividerProps = _ref2.dividerProps,
|
|
229
|
+
_ref2$shouldAlignLead = _ref2.shouldAlignLeadingAndTrailingElementsToCenter,
|
|
230
|
+
shouldAlignLeadingAndTrailingElementsToCenter = _ref2$shouldAlignLead === void 0 ? false : _ref2$shouldAlignLead,
|
|
229
231
|
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
230
232
|
var validatedTrailingComponent = useTrailingRestriction({
|
|
231
233
|
trailing: trailing,
|
|
@@ -243,6 +245,58 @@ var _BaseHeader = function _BaseHeader(_ref2) {
|
|
|
243
245
|
onPointerMove: onPointerMove,
|
|
244
246
|
onPointerUp: onPointerUp
|
|
245
247
|
};
|
|
248
|
+
var renderTrailingInteractionElementWithChildren = function renderTrailingInteractionElementWithChildren() {
|
|
249
|
+
if (trailingInteractionElement && children) {
|
|
250
|
+
return /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({
|
|
251
|
+
alignSelf: shouldAlignLeadingAndTrailingElementsToCenter ? 'center' : 'flex-start'
|
|
252
|
+
}, centerBoxProps[size$1]), {}, {
|
|
253
|
+
children: trailingInteractionElement
|
|
254
|
+
}));
|
|
255
|
+
}
|
|
256
|
+
return null;
|
|
257
|
+
};
|
|
258
|
+
var renderTrailingInteractionElementWithoutChildren = function renderTrailingInteractionElementWithoutChildren() {
|
|
259
|
+
if (trailingInteractionElement && !children) {
|
|
260
|
+
return /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps[size$1]), {}, {
|
|
261
|
+
alignSelf: shouldAlignLeadingAndTrailingElementsToCenter ? 'center' : undefined,
|
|
262
|
+
children: trailingInteractionElement
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
return null;
|
|
266
|
+
};
|
|
267
|
+
var renderLeadingElement = function renderLeadingElement() {
|
|
268
|
+
if (Boolean(leading)) {
|
|
269
|
+
return /*#__PURE__*/jsx(BaseBox, _objectSpread(_objectSpread({
|
|
270
|
+
marginRight: "spacing.3"
|
|
271
|
+
}, centerBoxProps[size$1]), {}, {
|
|
272
|
+
alignSelf: shouldAlignLeadingAndTrailingElementsToCenter ? 'center' : undefined,
|
|
273
|
+
children: leading
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
};
|
|
278
|
+
var renderTrailingElement = function renderTrailingElement() {
|
|
279
|
+
if (shouldAlignLeadingAndTrailingElementsToCenter && validatedTrailingComponent) {
|
|
280
|
+
return /*#__PURE__*/jsx(BaseBox, {
|
|
281
|
+
marginRight: "spacing.5",
|
|
282
|
+
display: "flex",
|
|
283
|
+
alignItems: "center",
|
|
284
|
+
justifyContent: "center",
|
|
285
|
+
children: /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps[size$1]), {}, {
|
|
286
|
+
children: validatedTrailingComponent
|
|
287
|
+
}))
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
if (validatedTrailingComponent) {
|
|
291
|
+
return /*#__PURE__*/jsx(BaseBox, {
|
|
292
|
+
marginRight: "spacing.5",
|
|
293
|
+
children: /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps[size$1]), {}, {
|
|
294
|
+
children: validatedTrailingComponent
|
|
295
|
+
}))
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
};
|
|
246
300
|
return /*#__PURE__*/jsxs(BaseBox, _objectSpread(_objectSpread(_objectSpread({}, metaAttribute({
|
|
247
301
|
name: metaComponentName,
|
|
248
302
|
testID: testID
|
|
@@ -287,11 +341,7 @@ var _BaseHeader = function _BaseHeader(_ref2) {
|
|
|
287
341
|
display: "flex",
|
|
288
342
|
flexDirection: "row",
|
|
289
343
|
alignItems: alignItems,
|
|
290
|
-
children: [
|
|
291
|
-
marginRight: "spacing.3"
|
|
292
|
-
}, centerBoxProps[size$1]), {}, {
|
|
293
|
-
children: leading
|
|
294
|
-
})) : null, /*#__PURE__*/jsxs(BaseBox, {
|
|
344
|
+
children: [renderLeadingElement(), /*#__PURE__*/jsxs(BaseBox, {
|
|
295
345
|
flex: "auto",
|
|
296
346
|
children: [/*#__PURE__*/jsxs(BaseBox
|
|
297
347
|
// Explicitly setting maxWidth in React Native because text is not being wrapped properly when multiple fix width components are rendered in header
|
|
@@ -331,12 +381,7 @@ var _BaseHeader = function _BaseHeader(_ref2) {
|
|
|
331
381
|
children: subtitle
|
|
332
382
|
}) : null]
|
|
333
383
|
})]
|
|
334
|
-
}),
|
|
335
|
-
marginRight: "spacing.5",
|
|
336
|
-
children: /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps[size$1]), {}, {
|
|
337
|
-
children: validatedTrailingComponent
|
|
338
|
-
}))
|
|
339
|
-
}) : null, showCloseButton ? /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, hasOnlyChildren ? absolutePositionedButton : centerBoxProps[size$1]), {}, {
|
|
384
|
+
}), renderTrailingElement(), showCloseButton ? /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, hasOnlyChildren ? absolutePositionedButton : centerBoxProps[size$1]), {}, {
|
|
340
385
|
children: /*#__PURE__*/jsx(IconButton, {
|
|
341
386
|
ref: closeButtonRef,
|
|
342
387
|
size: "large",
|
|
@@ -346,9 +391,7 @@ var _BaseHeader = function _BaseHeader(_ref2) {
|
|
|
346
391
|
return onCloseButtonClick === null || onCloseButtonClick === void 0 ? void 0 : onCloseButtonClick();
|
|
347
392
|
}
|
|
348
393
|
})
|
|
349
|
-
})) : null,
|
|
350
|
-
children: trailingInteractionElement
|
|
351
|
-
})) : null]
|
|
394
|
+
})) : null, renderTrailingInteractionElementWithoutChildren()]
|
|
352
395
|
}), /*#__PURE__*/jsxs(BaseBox, {
|
|
353
396
|
display: "flex",
|
|
354
397
|
width: "100%",
|
|
@@ -358,11 +401,7 @@ var _BaseHeader = function _BaseHeader(_ref2) {
|
|
|
358
401
|
children: [/*#__PURE__*/jsx(Box, {
|
|
359
402
|
width: "100%",
|
|
360
403
|
children: children
|
|
361
|
-
}),
|
|
362
|
-
alignSelf: "flex-start"
|
|
363
|
-
}, centerBoxProps[size$1]), {}, {
|
|
364
|
-
children: trailingInteractionElement
|
|
365
|
-
})) : null]
|
|
404
|
+
}), renderTrailingInteractionElementWithChildren()]
|
|
366
405
|
})]
|
|
367
406
|
})), showDivider ? /*#__PURE__*/jsx(Divider, _objectSpread({}, dividerProps)) : null]
|
|
368
407
|
}));
|