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M;gBACL,SAAQ;gBACR,WAAW;gBACX,YAAY;gBACZ,kBAAkB;gBAClB,QAAQ;gBACR,aAAa;gBACb,SAAS;0BACT,cAAA,gBAAC;oBACC,WAAW;8BACX,cAAA,gBAAC,CAAA,GAAA,aAAQ;wBAAE,WAAW,CAAA,GAAA,yCAAU,EAAE,CAAA,GAAA,yCAAU;kCAC1C,cAAA,gBAAC,CAAA,GAAA,eAAO;4BACN,QAAQ;gCACN;oCAAC,CAAA,GAAA,kBAAU;oCAAG;wCACZ,OAAO;4CACL,CAAC,CAAA,GAAA,mBAAW,EAAE,EAAE,CAAC;wCACnB;oCACF;iCAAE;gCACF;oCAAC,CAAA,GAAA,yCAAa;oCAAG;wCAAC,MAAM;oCAItB;iCAAE;gCACJ;oCAAC,CAAA,GAAA,yCAAa;oCAAG;wCAAC,MAAM;oCAEtB;iCAAE;gCACJ;oCAAC,CAAA,GAAA,yCAAY;oCAAG;wCAAC,MAAM;oCAGrB;iCAAE;6BACL;sCACA;;;;;;;AAOf","sources":["packages/@react-spectrum/s2/src/ContextualHelp.tsx"],"sourcesContent":["import {ActionButton} from './ActionButton';\nimport {AriaLabelingProps, DOMProps, FocusableRef, FocusableRefValue} from '@react-types/shared';\nimport {ContentContext, FooterContext, HeadingContext} from './Content';\nimport {ContextValue, DEFAULT_SLOT, Provider, Dialog as RACDialog, TextContext} from 'react-aria-components';\nimport {createContext, forwardRef, ReactNode} from 'react';\nimport {dialogInner} from './Dialog';\nimport {DialogTrigger, DialogTriggerProps} from './DialogTrigger';\nimport {filterDOMProps, mergeProps, useLabels} from '@react-aria/utils';\nimport HelpIcon from '../s2wf-icons/S2_Icon_HelpCircle_20_N.svg';\nimport InfoIcon from '../s2wf-icons/S2_Icon_InfoCircle_20_N.svg';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {mergeStyles} from '../style/runtime';\nimport {Placement} from '@react-types/overlays';\nimport {Popover, PopoverDialogProps} from './Popover';\nimport {space, style} from '../style' with {type: 'macro'};\nimport {StyleProps} from './style-utils' with { type: 'macro' };\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface ContextualHelpStyleProps {\n /**\n * Indicates whether contents are informative or provides helpful guidance.\n *\n * @default 'help'\n */\n variant?: 'info' | 'help'\n}\nexport interface ContextualHelpProps extends\n Pick<DialogTriggerProps, 'isOpen' | 'defaultOpen' | 'onOpenChange'>,\n Pick<PopoverDialogProps, 'shouldFlip' | 'offset' | 'crossOffset' | 'placement' | 'containerPadding'>,\n ContextualHelpStyleProps, StyleProps, DOMProps, AriaLabelingProps {\n /**\n * The placement of the popover with respect to the action button.\n * @default 'bottom start'\n */\n placement?: Placement,\n /** Contents of the Contextual Help popover. */\n children: ReactNode,\n /**\n * The size of the ActionButton.\n *\n * @default 'XS'\n */\n size?: 'XS' | 'S'\n}\n\nconst wrappingDiv = style({\n minWidth: 268,\n width: 268,\n padding: 24,\n boxSizing: 'border-box',\n height: 'full'\n});\n\nexport const ContextualHelpContext = createContext<ContextValue<Partial<ContextualHelpProps>, FocusableRefValue<HTMLButtonElement>>>(null);\n\n/**\n * Contextual help shows a user extra information about the state of an adjacent component, or a total view.\n */\nexport const ContextualHelp = forwardRef(function ContextualHelp(props: ContextualHelpProps, ref: FocusableRef<HTMLButtonElement>) {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n [props, ref] = useSpectrumContextProps(props, ref, ContextualHelpContext);\n let {\n children,\n defaultOpen,\n containerPadding = 8,\n size = 'XS',\n crossOffset,\n isOpen,\n onOpenChange,\n placement = 'bottom start',\n shouldFlip,\n UNSAFE_className,\n UNSAFE_style,\n styles,\n variant = 'help'\n } = props;\n\n // In a FieldLabel we're getting the context's aria-labeledby, so we need to\n // manually set the aria-label after useLabels() to keep the order of label\n // then ContextualHelp variant\n let labelProps = useLabels(props);\n let label = stringFormatter.format(`contextualhelp.${variant}`);\n labelProps['aria-label'] = labelProps['aria-label'] ? labelProps['aria-label'] + ' ' + label : label;\n\n let buttonProps = filterDOMProps(props, {labelable: true});\n\n return (\n <DialogTrigger\n isOpen={isOpen}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}>\n <ActionButton\n slot={null}\n ref={ref}\n size={size}\n {...mergeProps(buttonProps, labelProps)}\n UNSAFE_style={UNSAFE_style}\n UNSAFE_className={UNSAFE_className}\n styles={styles}\n isQuiet>\n {variant === 'info' ? <InfoIcon /> : <HelpIcon />}\n </ActionButton>\n <Popover\n padding=\"none\"\n placement={placement}\n shouldFlip={shouldFlip}\n containerPadding={containerPadding}\n offset={8}\n crossOffset={crossOffset}\n hideArrow>\n <div\n className={wrappingDiv}>\n <RACDialog className={mergeStyles(dialogInner, style({borderRadius: 'none', margin: 'calc(self(paddingTop) * -1)', padding: 24}))}>\n <Provider\n values={[\n [TextContext, {\n slots: {\n [DEFAULT_SLOT]: {}\n }\n }],\n [HeadingContext, {styles: style({\n font: 'heading-xs',\n margin: 0,\n marginBottom: space(8) // This only makes it 10px on mobile and should be 12px\n })}],\n [ContentContext, {styles: style({\n font: 'body-sm'\n })}],\n [FooterContext, {styles: style({\n font: 'body-sm',\n marginTop: 16\n })}]\n ]}>\n {children}\n </Provider>\n </RACDialog>\n </div>\n </Popover>\n </DialogTrigger>\n );\n});\n"],"names":[],"version":3,"file":"ContextualHelp.mjs.map"}