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kCAAa;wBAAI;oBAAE;iBAAE;gBACxD;oBAAC,CAAA,GAAA,yCAAa;oBAAG;wBAAC,QAAQ,8BAAQ;kCAAC;wBAAI;oBAAE;iBAAE;gBAC3C;oBAAC,CAAA,GAAA,yCAAkB;oBAAG;wBAAC,MAAM,SAAS,MAAM,MAAM;wBAAK,QAAQ,mCAAa;yCAAC;kCAAa;0CAAM;0CAAc;wBAAY;oBAAE;iBAAE;gBAC9H;oBAAC,CAAA,GAAA,yCAAiB;oBAAG;wBAAC,QAAQ;oBAAW;iBAAE;aAC5C;sBACA;;;AAIT","sources":["packages/@react-spectrum/s2/src/IllustratedMessage.tsx"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ButtonGroupContext} from './ButtonGroup';\nimport {ContentContext, HeadingContext} from './Content';\nimport {ContextValue, Provider} from 'react-aria-components';\nimport {controlFont, getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {createContext, forwardRef, ReactNode} from 'react';\nimport {DOMProps, DOMRef, DOMRefValue} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {IllustrationContext} from './Icon';\nimport {style} from '../style' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\ninterface IllustratedMessageStyleProps {\n /**\n * The size of the IllustratedMessage.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L',\n /**\n * The direction that the IllustratedMessage should be laid out in.\n *\n * @default 'vertical'\n */\n orientation?: 'horizontal' | 'vertical'\n}\n\ninterface S2SpectrumIllustratedMessageProps extends DOMProps, UnsafeStyles, IllustratedMessageStyleProps {\n /** Spectrum-defined styles, returned by the `style()` macro. */\n styles?: StylesPropWithHeight,\n /** The content to display in the IllustratedMessage. */\n children: ReactNode\n}\n\nconst illustratedMessage = style<IllustratedMessageStyleProps & {isInDropZone?: boolean}>({\n display: 'grid',\n font: controlFont(),\n maxWidth: {\n orientation: {\n vertical: 380,\n horizontal: 528 // ask design about max width for horizontal because doesn't look great when L\n }\n },\n gridTemplateAreas: {\n orientation: {\n vertical: [\n ' . illustration . ',\n ' . . . ',\n 'heading heading heading',\n ' . . . ',\n 'content content content',\n ' . buttonGroup . '\n ],\n horizontal: [\n 'illustration . heading',\n 'illustration . . ',\n 'illustration . content',\n 'illustration . buttonGroup'\n ]\n }\n },\n gridTemplateRows: {\n orientation: {\n vertical: {\n default: ['min-content', 12, 'min-content', 4, 'min-content', 'min-content'],\n size: {\n L: ['min-content', 8, 'min-content', 4, 'min-content', 'min-content']\n }\n },\n horizontal: ['1fr', 4, '1fr']\n }\n },\n gridTemplateColumns: {\n orientation: {\n horizontal: ['1fr', 12, 'auto']\n }\n },\n justifyItems: {\n orientation: {\n vertical: 'center',\n horizontal: 'start'\n }\n },\n textAlign: {\n orientation: {\n vertical: 'center'\n }\n }\n}, getAllowedOverrides({height: true}));\n\nconst illustration = style<IllustratedMessageStyleProps & {isInDropZone?: boolean, isDropTarget?: boolean}>({\n gridArea: 'illustration',\n alignSelf: 'center',\n '--iconPrimary': {\n type: 'color',\n value: {\n default: 'neutral',\n isDropTarget: 'accent'\n }\n }\n});\n\nconst heading = style<IllustratedMessageStyleProps>({\n gridArea: 'heading',\n font: {\n size: {\n S: 'title',\n M: 'title-xl',\n L: 'title-2xl'\n }\n },\n alignSelf: 'end',\n margin: 0\n});\n\nconst content = style({\n font: {\n size: {\n S: 'body-xs',\n M: 'body-sm',\n L: 'body-sm'\n }\n },\n gridArea: 'content',\n alignSelf: 'start'\n});\n\nconst buttonGroup = style({\n gridArea: 'buttonGroup',\n marginTop: 16\n});\n\ninterface IllustratedMessageContextProps extends Partial<S2SpectrumIllustratedMessageProps> {\n isInDropZone?: boolean,\n isDropTarget?: boolean\n}\n\nexport const IllustratedMessageContext = createContext<ContextValue<Partial<IllustratedMessageContextProps>, DOMRefValue<HTMLDivElement>>>(null);\n\n/**\n * An IllustratedMessage displays an illustration and a message, usually\n * for an empty state or an error page.\n */\nexport const IllustratedMessage = /*#__PURE__*/ forwardRef(function IllustratedMessage(props: S2SpectrumIllustratedMessageProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, IllustratedMessageContext);\n let domRef = useDOMRef(ref);\n let {\n children,\n orientation = 'horizontal',\n size = 'M',\n UNSAFE_className = '',\n UNSAFE_style,\n isInDropZone = false,\n isDropTarget = false,\n ...otherProps\n } = props as IllustratedMessageContextProps;\n\n return (\n <div\n {...filterDOMProps(otherProps)}\n style={UNSAFE_style}\n className={UNSAFE_className + illustratedMessage({\n size: props.size || 'M',\n orientation: props.orientation || 'vertical'\n }, props.styles)}\n ref={domRef}>\n <Provider\n values={[\n [HeadingContext, {styles: heading({orientation, size})}],\n [ContentContext, {styles: content({size})}],\n [IllustrationContext, {size: size === 'L' ? 'L' : 'M', styles: illustration({orientation, size, isInDropZone, isDropTarget})}],\n [ButtonGroupContext, {styles: buttonGroup}]\n ]}>\n {children}\n </Provider>\n </div>\n );\n});\n"],"names":[],"version":3,"file":"IllustratedMessage.mjs.map"}