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W,KAA6B;IACtD,IAAI,YAAC,QAAQ,EAAE,GAAG,YAAW,GAAG;IAEhC,MAAM,WAAW,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA,CAAC,CAAA,GAAI,EAAE;IAEvC,IAAI,UAAU;IACd,IAAI,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,MAAM,IAAI,GAC7C;QAAA,IAAI,OAAO,aAAa,YACtB,sGAAsG;QACtG,wBAAU,CAAA,GAAA,YAAI,EAAE,YAAY,CAAC,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW;IAC9D;IAEF,qBAAO,gCAAC,kCAAY,QAAQ;QAAC,OAAO;OAAW;AACjD","sources":["packages/@adobe/react-spectrum/src/utils/Slots.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 {mergeProps} from 'react-aria/mergeProps';\nimport React, {ReactNode, useContext, useMemo} from 'react';\n\ninterface SlotProps {\n  slot?: string;\n}\n\nlet SlotContext = React.createContext<{} | null>(null);\n\nexport function useSlotProps<T>(props: T & {id?: string}, defaultSlot?: string): T {\n  let slot = (props as SlotProps).slot || defaultSlot;\n  // @ts-ignore TODO why is slot an object and not just string or undefined?\n  let {[slot]: slotProps = {}} = useContext(SlotContext) || {};\n\n  return mergeProps(props, mergeProps(slotProps, {id: props.id})) as T;\n}\n\nexport function cssModuleToSlots(cssModule: {[cssmodule: string]: string}): {\n  [slot: string]: {UNSAFE_className: string};\n} {\n  return Object.keys(cssModule).reduce((acc, slot) => {\n    acc[slot] = {UNSAFE_className: cssModule[slot]};\n    return acc;\n  }, {});\n}\n\nexport function SlotProvider(props: {\n  slots?: {[slot: string]: object};\n  children?: ReactNode;\n}): ReactNode {\n  const emptyObj = useMemo(() => ({}), []);\n\n  let parentSlots = useContext(SlotContext) || emptyObj;\n  let {slots = emptyObj, children} = props;\n\n  // Merge props for each slot from parent context and props\n  let value = useMemo(\n    () =>\n      Object.keys(parentSlots)\n        .concat(Object.keys(slots))\n        .reduce(\n          (o, p) => ({\n            ...o,\n            [p]: mergeProps(parentSlots[p] || {}, slots[p] || {})\n          }),\n          {}\n        ),\n    [parentSlots, slots]\n  );\n\n  return <SlotContext.Provider value={value}>{children}</SlotContext.Provider>;\n}\n\nexport function ClearSlots(props: {children?: ReactNode}): ReactNode {\n  let {children, ...otherProps} = props;\n\n  const emptyObj = useMemo(() => ({}), []);\n\n  let content = children;\n  if (React.Children.toArray(children).length <= 1) {\n    if (typeof children === 'function') {\n      // need to know if the node is a string or something else that react can render that doesn't get props\n      content = React.cloneElement(React.Children.only(children), otherProps);\n    }\n  }\n  return <SlotContext.Provider value={emptyObj}>{content}</SlotContext.Provider>;\n}\n"],"names":[],"version":3,"file":"Slots.mjs.map"}