@react-spectrum/utils 3.11.10 → 3.12.0

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.
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;AAcA,MAAM,8CAAU,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAoB;AACvD,8BAAQ,WAAW,GAAG;AAOf,SAAS,0CAAmB,KAA8B;IAC/D,IAAI,YACF,QAAQ,sBACR,kBAAkB,EACnB,GAAG;IACJ,qBACE,0DAAC,8BAAQ,QAAQ;QACf,OAAO;gCAAC;QAAkB;OACzB;AAGP;AAEO,SAAS,0CAAsB,WAAwB;IAC5D,IAAI,UAAU,OAAO,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,OAAO,GAAK,SAAS;IACpF,IAAI,oBAAoB,QAAQ,GAAG,CAAC,CAAC,GAAG,MAAM,GAAK,CAAC,YAAY,EAAE,MAAM,GAAG,CAAC;IAE5E,IAAI,qBAAqB,OAAO,WAAW,eAAe,OAAO,OAAO,UAAU,KAAK;IACvF,IAAI,uBAAuB;QACzB,IAAI,UAAU,EAAE;QAChB,IAAK,IAAI,KAAK,kBAAmB;YAC/B,IAAI,QAAQ,iBAAiB,CAAC,EAAE;YAChC,IAAI,OAAO,UAAU,CAAC,OAAO,OAAO,EAClC,QAAQ,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;QAE9B;QACA,QAAQ,IAAI,CAAC;QACb,OAAO;IACT;IAEA,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,qBAAO,EAAE,IACzC,qBACI,yBACA;YAAC;SAAO;IAGd,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,CAAC,oBACH;QAGF,IAAI,WAAW;YACb,MAAM,oBAAoB;YAE1B,cAAc,CAAA;gBACZ,IAAI,0BAA0B,MAAM,KAAK,kBAAkB,MAAM,IAC/D,0BAA0B,IAAI,CAAC,CAAC,YAAY,MAAQ,eAAe,iBAAiB,CAAC,IAAI,GACzF,OAAO;uBAAI;iBAAkB,EAAE,2CAA2C;gBAG5E,OAAO;YACT;QACF;QAEA,OAAO,gBAAgB,CAAC,UAAU;QAClC,OAAO;YACL,OAAO,mBAAmB,CAAC,UAAU;QACvC;IACF,uDAAuD;IACvD,GAAG;QAAC;KAAmB;IAEvB,yEAAyE;IACzE,wDAAwD;IACxD,IAAI,QAAQ,CAAA,GAAA,4BAAO;IACnB,OAAO,QAAQ;QAAC;KAAO,GAAG;AAC5B;AAEO,SAAS;IACd,OAAO,CAAA,GAAA,uBAAS,EAAE;AACpB","sources":["packages/@react-spectrum/utils/src/BreakpointProvider.tsx"],"sourcesContent":["import React, {ReactNode, useContext, useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\ninterface Breakpoints {\n S?: number,\n M?: number,\n L?: number,\n [custom: string]: number | undefined\n}\n\ninterface BreakpointContext {\n matchedBreakpoints: string[]\n}\n\nconst Context = React.createContext<BreakpointContext>(null);\nContext.displayName = 'BreakpointContext';\n\ninterface BreakpointProviderProps {\n children?: ReactNode,\n matchedBreakpoints: string[]\n}\n\nexport function BreakpointProvider(props: BreakpointProviderProps) {\n let {\n children,\n matchedBreakpoints\n } = props;\n return (\n <Context.Provider\n value={{matchedBreakpoints}} >\n {children}\n </Context.Provider>\n );\n}\n\nexport function useMatchedBreakpoints(breakpoints: Breakpoints): string[] {\n let entries = Object.entries(breakpoints).sort(([, valueA], [, valueB]) => valueB - valueA);\n let breakpointQueries = entries.map(([, value]) => `(min-width: ${value}px)`);\n\n let supportsMatchMedia = typeof window !== 'undefined' && typeof window.matchMedia === 'function';\n let getBreakpointHandler = () => {\n let matched = [];\n for (let i in breakpointQueries) {\n let query = breakpointQueries[i];\n if (window.matchMedia(query).matches) {\n matched.push(entries[i][0]);\n }\n }\n matched.push('base');\n return matched;\n };\n\n let [breakpoint, setBreakpoint] = useState(() =>\n supportsMatchMedia\n ? getBreakpointHandler()\n : ['base']\n );\n\n useEffect(() => {\n if (!supportsMatchMedia) {\n return;\n }\n\n let onResize = () => {\n const breakpointHandler = getBreakpointHandler();\n\n setBreakpoint(previousBreakpointHandler => {\n if (previousBreakpointHandler.length !== breakpointHandler.length ||\n previousBreakpointHandler.some((breakpoint, idx) => breakpoint !== breakpointHandler[idx])) {\n return [...breakpointHandler]; // Return a new array to force state change\n }\n\n return previousBreakpointHandler;\n });\n };\n\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('resize', onResize);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [supportsMatchMedia]);\n\n // If in SSR, the media query should never match. Once the page hydrates,\n // this will update and the real value will be returned.\n let isSSR = useIsSSR();\n return isSSR ? ['base'] : breakpoint;\n}\n\nexport function useBreakpoint(): BreakpointContext {\n return useContext(Context);\n}\n"],"names":[],"version":3,"file":"BreakpointProvider.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;AAcA,MAAM,8CAAU,CAAA,GAAA,sCAAI,EAAE,aAAa,CAA2B;AAC9D,8BAAQ,WAAW,GAAG;AAOf,SAAS,0CAAmB,KAA8B;IAC/D,IAAI,YACF,QAAQ,sBACR,kBAAkB,EACnB,GAAG;IACJ,qBACE,0DAAC,8BAAQ,QAAQ;QACf,OAAO;gCAAC;QAAkB;OACzB;AAGP;AAEO,SAAS,0CAAsB,WAAwB;IAC5D,IAAI,UAAU,OAAO,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,OAAO,GAAK,SAAU;IACrF,IAAI,oBAAoB,QAAQ,GAAG,CAAC,CAAC,GAAG,MAAM,GAAK,CAAC,YAAY,EAAE,MAAM,GAAG,CAAC;IAE5E,IAAI,qBAAqB,OAAO,WAAW,eAAe,OAAO,OAAO,UAAU,KAAK;IACvF,IAAI,uBAAuB;QACzB,IAAI,UAAoB,EAAE;QAC1B,IAAK,IAAI,KAAK,kBAAmB;YAC/B,IAAI,QAAQ,iBAAiB,CAAC,EAAE;YAChC,IAAI,OAAO,UAAU,CAAC,OAAO,OAAO,EAClC,QAAQ,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;QAE9B;QACA,QAAQ,IAAI,CAAC;QACb,OAAO;IACT;IAEA,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,qBAAO,EAAE,IACzC,qBACI,yBACA;YAAC;SAAO;IAGd,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,CAAC,oBACH;QAGF,IAAI,WAAW;YACb,MAAM,oBAAoB;YAE1B,cAAc,CAAA;gBACZ,IAAI,0BAA0B,MAAM,KAAK,kBAAkB,MAAM,IAC/D,0BAA0B,IAAI,CAAC,CAAC,YAAY,MAAQ,eAAe,iBAAiB,CAAC,IAAI,GACzF,OAAO;uBAAI;iBAAkB,EAAE,2CAA2C;gBAG5E,OAAO;YACT;QACF;QAEA,OAAO,gBAAgB,CAAC,UAAU;QAClC,OAAO;YACL,OAAO,mBAAmB,CAAC,UAAU;QACvC;IACF,uDAAuD;IACvD,GAAG;QAAC;KAAmB;IAEvB,yEAAyE;IACzE,wDAAwD;IACxD,IAAI,QAAQ,CAAA,GAAA,4BAAO;IACnB,OAAO,QAAQ;QAAC;KAAO,GAAG;AAC5B;AAEO,SAAS;IACd,OAAO,CAAA,GAAA,uBAAS,EAAE;AACpB","sources":["packages/@react-spectrum/utils/src/BreakpointProvider.tsx"],"sourcesContent":["import React, {ReactNode, useContext, useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\ninterface Breakpoints {\n S?: number,\n M?: number,\n L?: number,\n [custom: string]: number | undefined\n}\n\ninterface BreakpointContext {\n matchedBreakpoints: string[]\n}\n\nconst Context = React.createContext<BreakpointContext | null>(null);\nContext.displayName = 'BreakpointContext';\n\ninterface BreakpointProviderProps {\n children?: ReactNode,\n matchedBreakpoints: string[]\n}\n\nexport function BreakpointProvider(props: BreakpointProviderProps) {\n let {\n children,\n matchedBreakpoints\n } = props;\n return (\n <Context.Provider\n value={{matchedBreakpoints}} >\n {children}\n </Context.Provider>\n );\n}\n\nexport function useMatchedBreakpoints(breakpoints: Breakpoints): string[] {\n let entries = Object.entries(breakpoints).sort(([, valueA], [, valueB]) => valueB! - valueA!);\n let breakpointQueries = entries.map(([, value]) => `(min-width: ${value}px)`);\n\n let supportsMatchMedia = typeof window !== 'undefined' && typeof window.matchMedia === 'function';\n let getBreakpointHandler = () => {\n let matched: string[] = [];\n for (let i in breakpointQueries) {\n let query = breakpointQueries[i];\n if (window.matchMedia(query).matches) {\n matched.push(entries[i][0]);\n }\n }\n matched.push('base');\n return matched;\n };\n\n let [breakpoint, setBreakpoint] = useState(() =>\n supportsMatchMedia\n ? getBreakpointHandler()\n : ['base']\n );\n\n useEffect(() => {\n if (!supportsMatchMedia) {\n return;\n }\n\n let onResize = () => {\n const breakpointHandler = getBreakpointHandler();\n\n setBreakpoint(previousBreakpointHandler => {\n if (previousBreakpointHandler.length !== breakpointHandler.length ||\n previousBreakpointHandler.some((breakpoint, idx) => breakpoint !== breakpointHandler[idx])) {\n return [...breakpointHandler]; // Return a new array to force state change\n }\n\n return previousBreakpointHandler;\n });\n };\n\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('resize', onResize);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [supportsMatchMedia]);\n\n // If in SSR, the media query should never match. Once the page hydrates,\n // this will update and the real value will be returned.\n let isSSR = useIsSSR();\n return isSSR ? ['base'] : breakpoint;\n}\n\nexport function useBreakpoint() {\n return useContext(Context);\n}\n"],"names":[],"version":3,"file":"BreakpointProvider.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;AAcA,MAAM,8CAAU,CAAA,GAAA,YAAI,EAAE,aAAa,CAAoB;AACvD,8BAAQ,WAAW,GAAG;AAOf,SAAS,0CAAmB,KAA8B;IAC/D,IAAI,YACF,QAAQ,sBACR,kBAAkB,EACnB,GAAG;IACJ,qBACE,gCAAC,8BA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O,SAAS;IACd,OAAO,CAAA,GAAA,iBAAS,EAAE;AACpB","sources":["packages/@react-spectrum/utils/src/BreakpointProvider.tsx"],"sourcesContent":["import React, {ReactNode, useContext, useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\ninterface Breakpoints {\n S?: number,\n M?: number,\n L?: number,\n [custom: string]: number | undefined\n}\n\ninterface BreakpointContext {\n matchedBreakpoints: string[]\n}\n\nconst Context = React.createContext<BreakpointContext>(null);\nContext.displayName = 'BreakpointContext';\n\ninterface BreakpointProviderProps {\n children?: ReactNode,\n matchedBreakpoints: string[]\n}\n\nexport function BreakpointProvider(props: BreakpointProviderProps) {\n let {\n children,\n matchedBreakpoints\n } = props;\n return (\n <Context.Provider\n value={{matchedBreakpoints}} >\n {children}\n </Context.Provider>\n );\n}\n\nexport function useMatchedBreakpoints(breakpoints: Breakpoints): string[] {\n let entries = Object.entries(breakpoints).sort(([, valueA], [, valueB]) => valueB - valueA);\n let breakpointQueries = entries.map(([, value]) => `(min-width: ${value}px)`);\n\n let supportsMatchMedia = typeof window !== 'undefined' && typeof window.matchMedia === 'function';\n let getBreakpointHandler = () => {\n let matched = [];\n for (let i in breakpointQueries) {\n let query = breakpointQueries[i];\n if (window.matchMedia(query).matches) {\n matched.push(entries[i][0]);\n }\n }\n matched.push('base');\n return matched;\n };\n\n let [breakpoint, setBreakpoint] = useState(() =>\n supportsMatchMedia\n ? getBreakpointHandler()\n : ['base']\n );\n\n useEffect(() => {\n if (!supportsMatchMedia) {\n return;\n }\n\n let onResize = () => {\n const breakpointHandler = getBreakpointHandler();\n\n setBreakpoint(previousBreakpointHandler => {\n if (previousBreakpointHandler.length !== breakpointHandler.length ||\n previousBreakpointHandler.some((breakpoint, idx) => breakpoint !== breakpointHandler[idx])) {\n return [...breakpointHandler]; // Return a new array to force state change\n }\n\n return previousBreakpointHandler;\n });\n };\n\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('resize', onResize);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [supportsMatchMedia]);\n\n // If in SSR, the media query should never match. Once the page hydrates,\n // this will update and the real value will be returned.\n let isSSR = useIsSSR();\n return isSSR ? ['base'] : breakpoint;\n}\n\nexport function useBreakpoint(): BreakpointContext {\n return useContext(Context);\n}\n"],"names":[],"version":3,"file":"BreakpointProvider.module.js.map"}
1
+ {"mappings":";;;;;AAcA,MAAM,8CAAU,CAAA,GAAA,YAAI,EAAE,aAAa,CAA2B;AAC9D,8BAAQ,WAAW,GAAG;AAOf,SAAS,0CAAmB,KAA8B;IAC/D,IAAI,YACF,QAAQ,sBACR,kBAAkB,EACnB,GAAG;IACJ,qBACE,gCAAC,8BAAQ,QAAQ;QACf,OAAO;gCAAC;QAAkB;OACzB;AAGP;AAEO,SAAS,0CAAsB,WAAwB;IAC5D,IAAI,UAAU,OAAO,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,OAAO,GAAK,SAAU;IACrF,IAAI,oBAAoB,QAAQ,GAAG,CAAC,CAAC,GAAG,MAAM,GAAK,CAAC,YAAY,EAAE,MAAM,GAAG,CAAC;IAE5E,IAAI,qBAAqB,OAAO,WAAW,eAAe,OAAO,OAAO,UAAU,KAAK;IACvF,IAAI,uBAAuB;QACzB,IAAI,UAAoB,EAAE;QAC1B,IAAK,IAAI,KAAK,kBAAmB;YAC/B,IAAI,QAAQ,iBAAiB,CAAC,EAAE;YAChC,IAAI,OAAO,UAAU,CAAC,OAAO,OAAO,EAClC,QAAQ,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;QAE9B;QACA,QAAQ,IAAI,CAAC;QACb,OAAO;IACT;IAEA,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,eAAO,EAAE,IACzC,qBACI,yBACA;YAAC;SAAO;IAGd,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,CAAC,oBACH;QAGF,IAAI,WAAW;YACb,MAAM,oBAAoB;YAE1B,cAAc,CAAA;gBACZ,IAAI,0BAA0B,MAAM,KAAK,kBAAkB,MAAM,IAC/D,0BAA0B,IAAI,CAAC,CAAC,YAAY,MAAQ,eAAe,iBAAiB,CAAC,IAAI,GACzF,OAAO;uBAAI;iBAAkB,EAAE,2CAA2C;gBAG5E,OAAO;YACT;QACF;QAEA,OAAO,gBAAgB,CAAC,UAAU;QAClC,OAAO;YACL,OAAO,mBAAmB,CAAC,UAAU;QACvC;IACF,uDAAuD;IACvD,GAAG;QAAC;KAAmB;IAEvB,yEAAyE;IACzE,wDAAwD;IACxD,IAAI,QAAQ,CAAA,GAAA,eAAO;IACnB,OAAO,QAAQ;QAAC;KAAO,GAAG;AAC5B;AAEO,SAAS;IACd,OAAO,CAAA,GAAA,iBAAS,EAAE;AACpB","sources":["packages/@react-spectrum/utils/src/BreakpointProvider.tsx"],"sourcesContent":["import React, {ReactNode, useContext, useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\ninterface Breakpoints {\n S?: number,\n M?: number,\n L?: number,\n [custom: string]: number | undefined\n}\n\ninterface BreakpointContext {\n matchedBreakpoints: string[]\n}\n\nconst Context = React.createContext<BreakpointContext | null>(null);\nContext.displayName = 'BreakpointContext';\n\ninterface BreakpointProviderProps {\n children?: ReactNode,\n matchedBreakpoints: string[]\n}\n\nexport function BreakpointProvider(props: BreakpointProviderProps) {\n let {\n children,\n matchedBreakpoints\n } = props;\n return (\n <Context.Provider\n value={{matchedBreakpoints}} >\n {children}\n </Context.Provider>\n );\n}\n\nexport function useMatchedBreakpoints(breakpoints: Breakpoints): string[] {\n let entries = Object.entries(breakpoints).sort(([, valueA], [, valueB]) => valueB! - valueA!);\n let breakpointQueries = entries.map(([, value]) => `(min-width: ${value}px)`);\n\n let supportsMatchMedia = typeof window !== 'undefined' && typeof window.matchMedia === 'function';\n let getBreakpointHandler = () => {\n let matched: string[] = [];\n for (let i in breakpointQueries) {\n let query = breakpointQueries[i];\n if (window.matchMedia(query).matches) {\n matched.push(entries[i][0]);\n }\n }\n matched.push('base');\n return matched;\n };\n\n let [breakpoint, setBreakpoint] = useState(() =>\n supportsMatchMedia\n ? getBreakpointHandler()\n : ['base']\n );\n\n useEffect(() => {\n if (!supportsMatchMedia) {\n return;\n }\n\n let onResize = () => {\n const breakpointHandler = getBreakpointHandler();\n\n setBreakpoint(previousBreakpointHandler => {\n if (previousBreakpointHandler.length !== breakpointHandler.length ||\n previousBreakpointHandler.some((breakpoint, idx) => breakpoint !== breakpointHandler[idx])) {\n return [...breakpointHandler]; // Return a new array to force state change\n }\n\n return previousBreakpointHandler;\n });\n };\n\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('resize', onResize);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [supportsMatchMedia]);\n\n // If in SSR, the media query should never match. Once the page hydrates,\n // this will update and the real value will be returned.\n let isSSR = useIsSSR();\n return isSSR ? ['base'] : breakpoint;\n}\n\nexport function useBreakpoint() {\n return useContext(Context);\n}\n"],"names":[],"version":3,"file":"BreakpointProvider.module.js.map"}
@@ -29,6 +29,7 @@ $parcel$export(module.exports, "ClearSlots", () => $e81916440cf6fd84$export$ceb1
29
29
  let $e81916440cf6fd84$var$SlotContext = /*#__PURE__*/ (0, ($parcel$interopDefault($iTRw5$react))).createContext(null);
30
30
  function $e81916440cf6fd84$export$1e5c9e6e4e15efe3(props, defaultSlot) {
31
31
  let slot = props.slot || defaultSlot;
32
+ // @ts-ignore TODO why is slot an object and not just string or undefined?
32
33
  let { [slot]: slotProps = {} } = (0, $iTRw5$react.useContext)($e81916440cf6fd84$var$SlotContext) || {};
33
34
  return (0, $iTRw5$reactariautils.mergeProps)(props, (0, $iTRw5$reactariautils.mergeProps)(slotProps, {
34
35
  id: props.id
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AASD,IAAI,kDAAc,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAC;AAE/B,SAAS,0CAAgB,KAAwB,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a,YACtB,wBAAU,CAAA,GAAA,sCAAI,EAAE,YAAY,CAAC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW;IAC9D;IAEF,qBACE,0DAAC,kCAAY,QAAQ;QAAC,OAAO,CAAC;OAC3B;AAGP","sources":["packages/@react-spectrum/utils/src/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/utils';\nimport React, {useContext, useMemo} from 'react';\n\ninterface SlotProps {\n slot?: string\n}\n\nlet SlotContext = React.createContext(null);\n\nexport function useSlotProps<T>(props: T & {id?: string}, defaultSlot?: string): T {\n let slot = (props as SlotProps).slot || defaultSlot;\n let {[slot]: slotProps = {}} = useContext(SlotContext) || {};\n\n return mergeProps(props, mergeProps(slotProps, {id: props.id}));\n}\n\nexport function cssModuleToSlots(cssModule) {\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n let parentSlots = useContext(SlotContext) || {};\n let {slots = {}, children} = props;\n\n // Merge props for each slot from parent context and props\n let value = useMemo(() =>\n Object.keys(parentSlots)\n .concat(Object.keys(slots))\n .reduce((o, p) => ({\n ...o,\n [p]: mergeProps(parentSlots[p] || {}, slots[p] || {})}), {})\n , [parentSlots, slots]);\n\n return (\n <SlotContext.Provider value={value}>\n {children}\n </SlotContext.Provider>\n );\n}\n\nexport function ClearSlots(props) {\n let {children, ...otherProps} = props;\n let content = children;\n if (React.Children.toArray(children).length <= 1) {\n if (typeof children === 'function') { // 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 (\n <SlotContext.Provider value={{}}>\n {content}\n </SlotContext.Provider>\n );\n}\n"],"names":[],"version":3,"file":"Slots.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AASD,IAAI,kDAAc,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAY;AAE1C,SAAS,0CAAgB,KAAwB,EAAE,WAAoB;IAC5E,IAAI,OAAO,AAAC,MAAoB,IAAI,IAAI;IACxC,0EAA0E;IAC1E,IAAI,EAAC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,EAAC,GAAG,CAAA,GAAA,uBAAS,EAAE,sCAAgB,CAAC;IAE3D,OAAO,CAAA,GAAA,gCAAS,EAAE,OAAO,CAAA,GAAA,gCAAS,EAAE,WAAW;QAAC,IAAI,MAAM,EAAE;IAAA;AAC9D;AAEO,SAAS,0CAAiB,SAAS;IACxC,OAAO,OAAO,IAAI,CAAC,WAAW,MAAM,CAAC,CAAC,KAAK;QACzC,GAAG,CAAC,KAAK,GAAG;YAAC,kBAAkB,SAAS,CAAC,KAAK;QAAA;QAC9C,OAAO;IACT,GAAG,CAAC;AACN;AAEO,SAAS,0CAAa,KAAK;IAChC,uDAAuD;IACvD,IAAI,cAAc,CAAA,GAAA,uBAAS,EAAE,sCAAgB,CAAC;IAC9C,IAAI,SAAC,QAAQ,CAAC,aAAG,QAAQ,EAAC,GAAG;IAE7B,0DAA0D;IAC1D,IAAI,QAAQ,CAAA,GAAA,oBAAM,EAAE,IAClB,OAAO,IAAI,CAAC,aACT,MAAM,CAAC,OAAO,IAAI,CAAC,QACnB,MAAM,CAAC,CAAC,GAAG,IAAO,CAAA;gBACjB,GAAG,CAAC;gBACJ,CAAC,EAAE,EAAE,CAAA,GAAA,gCAAS,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,EAAE,IAAI,CAAC;YAAE,CAAA,GAAI,CAAC,IAC1D;QAAC;QAAa;KAAM;IAE1B,qBACE,0DAAC,kCAAY,QAAQ;QAAC,OAAO;OAC1B;AAGP;AAEO,SAAS,0CAAW,KAAK;IAC9B,IAAI,YAAC,QAAQ,EAAE,GAAG,YAAW,GAAG;IAChC,IAAI,UAAU;IACd,IAAI,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,MAAM,IAAI,GAC7C;QAAA,IAAI,OAAO,aAAa,YACtB,wBAAU,CAAA,GAAA,sCAAI,EAAE,YAAY,CAAC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW;IAC9D;IAEF,qBACE,0DAAC,kCAAY,QAAQ;QAAC,OAAO,CAAC;OAC3B;AAGP","sources":["packages/@react-spectrum/utils/src/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/utils';\nimport React, {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}));\n}\n\nexport function cssModuleToSlots(cssModule) {\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n let parentSlots = useContext(SlotContext) || {};\n let {slots = {}, children} = props;\n\n // Merge props for each slot from parent context and props\n let value = useMemo(() =>\n Object.keys(parentSlots)\n .concat(Object.keys(slots))\n .reduce((o, p) => ({\n ...o,\n [p]: mergeProps(parentSlots[p] || {}, slots[p] || {})}), {})\n , [parentSlots, slots]);\n\n return (\n <SlotContext.Provider value={value}>\n {children}\n </SlotContext.Provider>\n );\n}\n\nexport function ClearSlots(props) {\n let {children, ...otherProps} = props;\n let content = children;\n if (React.Children.toArray(children).length <= 1) {\n if (typeof children === 'function') { // 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 (\n <SlotContext.Provider value={{}}>\n {content}\n </SlotContext.Provider>\n );\n}\n"],"names":[],"version":3,"file":"Slots.main.js.map"}
package/dist/Slots.mjs CHANGED
@@ -16,6 +16,7 @@ import $doF98$react, {useContext as $doF98$useContext, useMemo as $doF98$useMemo
16
16
  let $59d09bcc83651bf9$var$SlotContext = /*#__PURE__*/ (0, $doF98$react).createContext(null);
17
17
  function $59d09bcc83651bf9$export$1e5c9e6e4e15efe3(props, defaultSlot) {
18
18
  let slot = props.slot || defaultSlot;
19
+ // @ts-ignore TODO why is slot an object and not just string or undefined?
19
20
  let { [slot]: slotProps = {} } = (0, $doF98$useContext)($59d09bcc83651bf9$var$SlotContext) || {};
20
21
  return (0, $doF98$mergeProps)(props, (0, $doF98$mergeProps)(slotProps, {
21
22
  id: props.id
@@ -16,6 +16,7 @@ import $doF98$react, {useContext as $doF98$useContext, useMemo as $doF98$useMemo
16
16
  let $59d09bcc83651bf9$var$SlotContext = /*#__PURE__*/ (0, $doF98$react).createContext(null);
17
17
  function $59d09bcc83651bf9$export$1e5c9e6e4e15efe3(props, defaultSlot) {
18
18
  let slot = props.slot || defaultSlot;
19
+ // @ts-ignore TODO why is slot an object and not just string or undefined?
19
20
  let { [slot]: slotProps = {} } = (0, $doF98$useContext)($59d09bcc83651bf9$var$SlotContext) || {};
20
21
  return (0, $doF98$mergeProps)(props, (0, $doF98$mergeProps)(slotProps, {
21
22
  id: props.id
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AASD,IAAI,kDAAc,CAAA,GAAA,YAAI,EAAE,aAAa,CAAC;AAE/B,SAAS,0CAAgB,KAAwB,EAAE,WAAoB;IAC5E,IAAI,OAAO,AAAC,MAAoB,IAAI,IAAI;IACxC,IAAI,EAAC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE,sCAAgB,CAAC;IAE3D,OAAO,CAAA,GAAA,iBAAS,EAAE,OAAO,CAAA,GAAA,iBAAS,EAAE,WAAW;QAAC,IAAI,MAAM,EAAE;IAAA;AAC9D;AAEO,SAAS,0CAAiB,SAAS;IACxC,OAAO,OAAO,IAAI,CAAC,WAAW,MAAM,CAAC,CAAC,KAAK;QACzC,GAAG,CAAC,KAAK,GAAG;YAAC,kBAAkB,SAAS,CAAC,KAAK;QAAA;QAC9C,OAAO;IACT,GAAG,CAAC;AACN;AAEO,SAAS,0CAAa,KAAK;IAChC,uDAAuD;IACvD,IAAI,cAAc,CAAA,GAAA,iBAAS,EAAE,sCAAgB,CAAC;IAC9C,IAAI,SAAC,QAAQ,CAAC,aAAG,QAAQ,EAAC,GAAG;IAE7B,0DAA0D;IAC1D,IAAI,QAAQ,CAAA,GAAA,cAAM,EAAE,IAClB,OAAO,IAAI,CAAC,aACT,MAAM,CAAC,OAAO,IAAI,CAAC,QACnB,MAAM,CAAC,CAAC,GAAG,IAAO,CAAA;gBACjB,GAAG,CAAC;gBACJ,CAAC,EAAE,EAAE,CAAA,GAAA,iBAAS,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,EAAE,IAAI,CAAC;YAAE,CAAA,GAAI,CAAC,IAC1D;QAAC;QAAa;KAAM;IAE1B,qBACE,gCAAC,kCAAY,QAAQ;QAAC,OAAO;OAC1B;AAGP;AAEO,SAAS,0CAAW,KAAK;IAC9B,IAAI,YAAC,QAAQ,EAAE,GAAG,YAAW,GAAG;IAChC,IAAI,UAAU;IACd,IAAI,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,MAAM,IAAI,GAC7C;QAAA,IAAI,OAAO,aAAa,YACtB,wBAAU,CAAA,GAAA,YAAI,EAAE,YAAY,CAAC,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW;IAC9D;IAEF,qBACE,gCAAC,kCAAY,QAAQ;QAAC,OAAO,CAAC;OAC3B;AAGP","sources":["packages/@react-spectrum/utils/src/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/utils';\nimport React, {useContext, useMemo} from 'react';\n\ninterface SlotProps {\n slot?: string\n}\n\nlet SlotContext = React.createContext(null);\n\nexport function useSlotProps<T>(props: T & {id?: string}, defaultSlot?: string): T {\n let slot = (props as SlotProps).slot || defaultSlot;\n let {[slot]: slotProps = {}} = useContext(SlotContext) || {};\n\n return mergeProps(props, mergeProps(slotProps, {id: props.id}));\n}\n\nexport function cssModuleToSlots(cssModule) {\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n let parentSlots = useContext(SlotContext) || {};\n let {slots = {}, children} = props;\n\n // Merge props for each slot from parent context and props\n let value = useMemo(() =>\n Object.keys(parentSlots)\n .concat(Object.keys(slots))\n .reduce((o, p) => ({\n ...o,\n [p]: mergeProps(parentSlots[p] || {}, slots[p] || {})}), {})\n , [parentSlots, slots]);\n\n return (\n <SlotContext.Provider value={value}>\n {children}\n </SlotContext.Provider>\n );\n}\n\nexport function ClearSlots(props) {\n let {children, ...otherProps} = props;\n let content = children;\n if (React.Children.toArray(children).length <= 1) {\n if (typeof children === 'function') { // 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 (\n <SlotContext.Provider value={{}}>\n {content}\n </SlotContext.Provider>\n );\n}\n"],"names":[],"version":3,"file":"Slots.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AASD,IAAI,kDAAc,CAAA,GAAA,YAAI,EAAE,aAAa,CAAY;AAE1C,SAAS,0CAAgB,KAAwB,EAAE,WAAoB;IAC5E,IAAI,OAAO,AAAC,MAAoB,IAAI,IAAI;IACxC,0EAA0E;IAC1E,IAAI,EAAC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE,sCAAgB,CAAC;IAE3D,OAAO,CAAA,GAAA,iBAAS,EAAE,OAAO,CAAA,GAAA,iBAAS,EAAE,WAAW;QAAC,IAAI,MAAM,EAAE;IAAA;AAC9D;AAEO,SAAS,0CAAiB,SAAS;IACxC,OAAO,OAAO,IAAI,CAAC,WAAW,MAAM,CAAC,CAAC,KAAK;QACzC,GAAG,CAAC,KAAK,GAAG;YAAC,kBAAkB,SAAS,CAAC,KAAK;QAAA;QAC9C,OAAO;IACT,GAAG,CAAC;AACN;AAEO,SAAS,0CAAa,KAAK;IAChC,uDAAuD;IACvD,IAAI,cAAc,CAAA,GAAA,iBAAS,EAAE,sCAAgB,CAAC;IAC9C,IAAI,SAAC,QAAQ,CAAC,aAAG,QAAQ,EAAC,GAAG;IAE7B,0DAA0D;IAC1D,IAAI,QAAQ,CAAA,GAAA,cAAM,EAAE,IAClB,OAAO,IAAI,CAAC,aACT,MAAM,CAAC,OAAO,IAAI,CAAC,QACnB,MAAM,CAAC,CAAC,GAAG,IAAO,CAAA;gBACjB,GAAG,CAAC;gBACJ,CAAC,EAAE,EAAE,CAAA,GAAA,iBAAS,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,EAAE,IAAI,CAAC;YAAE,CAAA,GAAI,CAAC,IAC1D;QAAC;QAAa;KAAM;IAE1B,qBACE,gCAAC,kCAAY,QAAQ;QAAC,OAAO;OAC1B;AAGP;AAEO,SAAS,0CAAW,KAAK;IAC9B,IAAI,YAAC,QAAQ,EAAE,GAAG,YAAW,GAAG;IAChC,IAAI,UAAU;IACd,IAAI,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,MAAM,IAAI,GAC7C;QAAA,IAAI,OAAO,aAAa,YACtB,wBAAU,CAAA,GAAA,YAAI,EAAE,YAAY,CAAC,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW;IAC9D;IAEF,qBACE,gCAAC,kCAAY,QAAQ;QAAC,OAAO,CAAC;OAC3B;AAGP","sources":["packages/@react-spectrum/utils/src/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/utils';\nimport React, {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}));\n}\n\nexport function cssModuleToSlots(cssModule) {\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n let parentSlots = useContext(SlotContext) || {};\n let {slots = {}, children} = props;\n\n // Merge props for each slot from parent context and props\n let value = useMemo(() =>\n Object.keys(parentSlots)\n .concat(Object.keys(slots))\n .reduce((o, p) => ({\n ...o,\n [p]: mergeProps(parentSlots[p] || {}, slots[p] || {})}), {})\n , [parentSlots, slots]);\n\n return (\n <SlotContext.Provider value={value}>\n {children}\n </SlotContext.Provider>\n );\n}\n\nexport function ClearSlots(props) {\n let {children, ...otherProps} = props;\n let content = children;\n if (React.Children.toArray(children).length <= 1) {\n if (typeof children === 'function') { // 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 (\n <SlotContext.Provider value={{}}>\n {content}\n </SlotContext.Provider>\n );\n}\n"],"names":[],"version":3,"file":"Slots.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAIM,IAAI,4CAA+B;AAEnC,SAAS;IACd,4CAA+B;IAC/B,QAAQ,IAAI,CACV;AAIJ;AAEO,SAAS,0CAAW,SAAkC,EAAE,GAAG,MAA0C;IAC1G,IAAI,UAAU,EAAE;IAChB,KAAK,IAAI,SAAS,OAAQ;QACxB,IAAI,OAAO,UAAU,YAAY,OAAO;YACtC,IAAI,SAAS,CAAC;YACd,IAAK,IAAI,OAAO,MAAO;gBACrB,IAAI,SAAS,CAAC,IAAI,EAChB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI;gBAGrC,IAAI,6CAAgC,CAAC,SAAS,CAAC,IAAI,EACjD,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;YAE5B;YAEA,QAAQ,IAAI,CAAC;QACf,OAAO,IAAI,OAAO,UAAU,UAAU;YACpC,IAAI,SAAS,CAAC,MAAM,EAClB,QAAQ,IAAI,CAAC,SAAS,CAAC,MAAM;YAG/B,IAAI,6CAAgC,CAAC,SAAS,CAAC,MAAM,EACnD,QAAQ,IAAI,CAAC;QAEjB,OACE,QAAQ,IAAI,CAAC;IAEjB;IAEA,OAAO,CAAA,GAAA,qCAAI,KAAK;AAClB","sources":["packages/@react-spectrum/utils/src/classNames.ts"],"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 _clsx from 'clsx';\n\nexport let shouldKeepSpectrumClassNames = false;\n\nexport function keepSpectrumClassNames() {\n shouldKeepSpectrumClassNames = true;\n console.warn(\n 'Legacy spectrum-prefixed class names enabled for backward compatibility. ' +\n 'We recommend replacing instances of CSS overrides targeting spectrum selectors ' +\n 'in your app with custom class names of your own, and disabling this flag.'\n );\n}\n\nexport function classNames(cssModule: {[key: string]: string}, ...values: Array<string | Object | undefined>): string {\n let classes = [];\n for (let value of values) {\n if (typeof value === 'object' && value) {\n let mapped = {};\n for (let key in value) {\n if (cssModule[key]) {\n mapped[cssModule[key]] = value[key];\n }\n\n if (shouldKeepSpectrumClassNames || !cssModule[key]) {\n mapped[key] = value[key];\n }\n }\n\n classes.push(mapped);\n } else if (typeof value === 'string') {\n if (cssModule[value]) {\n classes.push(cssModule[value]);\n }\n\n if (shouldKeepSpectrumClassNames || !cssModule[value]) {\n classes.push(value);\n }\n } else {\n classes.push(value);\n }\n }\n\n return _clsx(...classes);\n}\n"],"names":[],"version":3,"file":"classNames.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAIM,IAAI,4CAA+B;AAEnC,SAAS;IACd,4CAA+B;IAC/B,QAAQ,IAAI,CACV;AAIJ;AAEO,SAAS,0CAAW,SAAkC,EAAE,GAAG,MAA0C;IAC1G,IAAI,UAAiC,EAAE;IACvC,KAAK,IAAI,SAAS,OAAQ;QACxB,IAAI,OAAO,UAAU,YAAY,OAAO;YACtC,IAAI,SAAS,CAAC;YACd,IAAK,IAAI,OAAO,MAAO;gBACrB,IAAI,SAAS,CAAC,IAAI,EAChB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI;gBAGrC,IAAI,6CAAgC,CAAC,SAAS,CAAC,IAAI,EACjD,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;YAE5B;YAEA,QAAQ,IAAI,CAAC;QACf,OAAO,IAAI,OAAO,UAAU,UAAU;YACpC,IAAI,SAAS,CAAC,MAAM,EAClB,QAAQ,IAAI,CAAC,SAAS,CAAC,MAAM;YAG/B,IAAI,6CAAgC,CAAC,SAAS,CAAC,MAAM,EACnD,QAAQ,IAAI,CAAC;QAEjB,OACE,QAAQ,IAAI,CAAC;IAEjB;IAEA,OAAO,CAAA,GAAA,qCAAI,KAAK;AAClB","sources":["packages/@react-spectrum/utils/src/classNames.ts"],"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 _clsx from 'clsx';\n\nexport let shouldKeepSpectrumClassNames = false;\n\nexport function keepSpectrumClassNames() {\n shouldKeepSpectrumClassNames = true;\n console.warn(\n 'Legacy spectrum-prefixed class names enabled for backward compatibility. ' +\n 'We recommend replacing instances of CSS overrides targeting spectrum selectors ' +\n 'in your app with custom class names of your own, and disabling this flag.'\n );\n}\n\nexport function classNames(cssModule: {[key: string]: string}, ...values: Array<string | Object | undefined>): string {\n let classes: Array<{} | undefined> = [];\n for (let value of values) {\n if (typeof value === 'object' && value) {\n let mapped = {};\n for (let key in value) {\n if (cssModule[key]) {\n mapped[cssModule[key]] = value[key];\n }\n\n if (shouldKeepSpectrumClassNames || !cssModule[key]) {\n mapped[key] = value[key];\n }\n }\n\n classes.push(mapped);\n } else if (typeof value === 'string') {\n if (cssModule[value]) {\n classes.push(cssModule[value]);\n }\n\n if (shouldKeepSpectrumClassNames || !cssModule[value]) {\n classes.push(value);\n }\n } else {\n classes.push(value);\n }\n }\n\n return _clsx(...classes);\n}\n"],"names":[],"version":3,"file":"classNames.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAIM,IAAI,4CAA+B;AAEnC,SAAS;IACd,4CAA+B;IAC/B,QAAQ,IAAI,CACV;AAIJ;AAEO,SAAS,0CAAW,SAAkC,EAAE,GAAG,MAA0C;IAC1G,IAAI,UAAU,EAAE;IAChB,KAAK,IAAI,SAAS,OAAQ;QACxB,IAAI,OAAO,UAAU,YAAY,OAAO;YACtC,IAAI,SAAS,CAAC;YACd,IAAK,IAAI,OAAO,MAAO;gBACrB,IAAI,SAAS,CAAC,IAAI,EAChB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI;gBAGrC,IAAI,6CAAgC,CAAC,SAAS,CAAC,IAAI,EACjD,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;YAE5B;YAEA,QAAQ,IAAI,CAAC;QACf,OAAO,IAAI,OAAO,UAAU,UAAU;YACpC,IAAI,SAAS,CAAC,MAAM,EAClB,QAAQ,IAAI,CAAC,SAAS,CAAC,MAAM;YAG/B,IAAI,6CAAgC,CAAC,SAAS,CAAC,MAAM,EACnD,QAAQ,IAAI,CAAC;QAEjB,OACE,QAAQ,IAAI,CAAC;IAEjB;IAEA,OAAO,CAAA,GAAA,WAAI,KAAK;AAClB","sources":["packages/@react-spectrum/utils/src/classNames.ts"],"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 _clsx from 'clsx';\n\nexport let shouldKeepSpectrumClassNames = false;\n\nexport function keepSpectrumClassNames() {\n shouldKeepSpectrumClassNames = true;\n console.warn(\n 'Legacy spectrum-prefixed class names enabled for backward compatibility. ' +\n 'We recommend replacing instances of CSS overrides targeting spectrum selectors ' +\n 'in your app with custom class names of your own, and disabling this flag.'\n );\n}\n\nexport function classNames(cssModule: {[key: string]: string}, ...values: Array<string | Object | undefined>): string {\n let classes = [];\n for (let value of values) {\n if (typeof value === 'object' && value) {\n let mapped = {};\n for (let key in value) {\n if (cssModule[key]) {\n mapped[cssModule[key]] = value[key];\n }\n\n if (shouldKeepSpectrumClassNames || !cssModule[key]) {\n mapped[key] = value[key];\n }\n }\n\n classes.push(mapped);\n } else if (typeof value === 'string') {\n if (cssModule[value]) {\n classes.push(cssModule[value]);\n }\n\n if (shouldKeepSpectrumClassNames || !cssModule[value]) {\n classes.push(value);\n }\n } else {\n classes.push(value);\n }\n }\n\n return _clsx(...classes);\n}\n"],"names":[],"version":3,"file":"classNames.module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAIM,IAAI,4CAA+B;AAEnC,SAAS;IACd,4CAA+B;IAC/B,QAAQ,IAAI,CACV;AAIJ;AAEO,SAAS,0CAAW,SAAkC,EAAE,GAAG,MAA0C;IAC1G,IAAI,UAAiC,EAAE;IACvC,KAAK,IAAI,SAAS,OAAQ;QACxB,IAAI,OAAO,UAAU,YAAY,OAAO;YACtC,IAAI,SAAS,CAAC;YACd,IAAK,IAAI,OAAO,MAAO;gBACrB,IAAI,SAAS,CAAC,IAAI,EAChB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI;gBAGrC,IAAI,6CAAgC,CAAC,SAAS,CAAC,IAAI,EACjD,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;YAE5B;YAEA,QAAQ,IAAI,CAAC;QACf,OAAO,IAAI,OAAO,UAAU,UAAU;YACpC,IAAI,SAAS,CAAC,MAAM,EAClB,QAAQ,IAAI,CAAC,SAAS,CAAC,MAAM;YAG/B,IAAI,6CAAgC,CAAC,SAAS,CAAC,MAAM,EACnD,QAAQ,IAAI,CAAC;QAEjB,OACE,QAAQ,IAAI,CAAC;IAEjB;IAEA,OAAO,CAAA,GAAA,WAAI,KAAK;AAClB","sources":["packages/@react-spectrum/utils/src/classNames.ts"],"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 _clsx from 'clsx';\n\nexport let shouldKeepSpectrumClassNames = false;\n\nexport function keepSpectrumClassNames() {\n shouldKeepSpectrumClassNames = true;\n console.warn(\n 'Legacy spectrum-prefixed class names enabled for backward compatibility. ' +\n 'We recommend replacing instances of CSS overrides targeting spectrum selectors ' +\n 'in your app with custom class names of your own, and disabling this flag.'\n );\n}\n\nexport function classNames(cssModule: {[key: string]: string}, ...values: Array<string | Object | undefined>): string {\n let classes: Array<{} | undefined> = [];\n for (let value of values) {\n if (typeof value === 'object' && value) {\n let mapped = {};\n for (let key in value) {\n if (cssModule[key]) {\n mapped[cssModule[key]] = value[key];\n }\n\n if (shouldKeepSpectrumClassNames || !cssModule[key]) {\n mapped[key] = value[key];\n }\n }\n\n classes.push(mapped);\n } else if (typeof value === 'string') {\n if (cssModule[value]) {\n classes.push(cssModule[value]);\n }\n\n if (shouldKeepSpectrumClassNames || !cssModule[value]) {\n classes.push(value);\n }\n } else {\n classes.push(value);\n }\n }\n\n return _clsx(...classes);\n}\n"],"names":[],"version":3,"file":"classNames.module.js.map"}
@@ -374,8 +374,8 @@ function $d3b73be57066120b$export$abc24f5b99744ea6(value) {
374
374
  return `var(--spectrum-global-dimension-${value}, var(--spectrum-alias-${value}))`;
375
375
  }
376
376
  function $d3b73be57066120b$export$f348bec194f2e6b5(value, matchedBreakpoints) {
377
- value = $d3b73be57066120b$export$52dbfdbe1b2c3541(value, matchedBreakpoints);
378
- return $d3b73be57066120b$export$abc24f5b99744ea6(value);
377
+ let responsiveValue = $d3b73be57066120b$export$52dbfdbe1b2c3541(value, matchedBreakpoints);
378
+ if (responsiveValue != null) return $d3b73be57066120b$export$abc24f5b99744ea6(responsiveValue);
379
379
  }
380
380
  function $d3b73be57066120b$var$colorValue(value, type = 'default', version = 5) {
381
381
  if (version > 5) return `var(--spectrum-${value}, var(--spectrum-semantic-${value}-color-${type}))`;
@@ -1 +1 @@
1
- {"mappings":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IAAI,IAAI,GAAG,IAAI,mBAAmB,MAAM,EAAE,IAAK;YAClD,IAAI,aAAa,kBAAkB,CAAC,EAAE;YACtC,IAAI,IAAI,CAAC,WAAW,IAAI,MACtB,OAAO,IAAI,CAAC,WAAW;QAE3B;QACA,OAAO,AAAC,KAA2B,IAAI;IACzC;IACA,OAAO;AACT","sources":["packages/@react-spectrum/utils/src/styleProps.ts"],"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 {BackgroundColorValue, BorderColorValue, BorderRadiusValue, BorderSizeValue, ColorValue, ColorVersion, DimensionValue, Direction, Responsive, ResponsiveProp, StyleProps, ViewStyleProps} from '@react-types/shared';\nimport {CSSProperties, HTMLAttributes} from 'react';\nimport {useBreakpoint} from './BreakpointProvider';\nimport {useLocale} from '@react-aria/i18n';\n\ntype Breakpoint = 'base' | 'S' | 'M' | 'L' | string;\ntype StyleName = string | string[] | ((dir: Direction) => string);\ntype StyleHandler = (value: any, colorVersion?: number) => string;\nexport interface StyleHandlers {\n [key: string]: [StyleName, StyleHandler]\n}\n\nexport const baseStyleProps: StyleHandlers = {\n margin: ['margin', dimensionValue],\n marginStart: [rtl('marginLeft', 'marginRight'), dimensionValue],\n marginEnd: [rtl('marginRight', 'marginLeft'), dimensionValue],\n // marginLeft: ['marginLeft', dimensionValue],\n // marginRight: ['marginRight', dimensionValue],\n marginTop: ['marginTop', dimensionValue],\n marginBottom: ['marginBottom', dimensionValue],\n marginX: [['marginLeft', 'marginRight'], dimensionValue],\n marginY: [['marginTop', 'marginBottom'], dimensionValue],\n width: ['width', dimensionValue],\n height: ['height', dimensionValue],\n minWidth: ['minWidth', dimensionValue],\n minHeight: ['minHeight', dimensionValue],\n maxWidth: ['maxWidth', dimensionValue],\n maxHeight: ['maxHeight', dimensionValue],\n isHidden: ['display', hiddenValue],\n alignSelf: ['alignSelf', passthroughStyle],\n justifySelf: ['justifySelf', passthroughStyle],\n position: ['position', anyValue],\n zIndex: ['zIndex', anyValue],\n top: ['top', dimensionValue],\n bottom: ['bottom', dimensionValue],\n start: [rtl('left', 'right'), dimensionValue],\n end: [rtl('right', 'left'), dimensionValue],\n left: ['left', dimensionValue],\n right: ['right', dimensionValue],\n order: ['order', anyValue],\n flex: ['flex', flexValue],\n flexGrow: ['flexGrow', passthroughStyle],\n flexShrink: ['flexShrink', passthroughStyle],\n flexBasis: ['flexBasis', passthroughStyle],\n gridArea: ['gridArea', passthroughStyle],\n gridColumn: ['gridColumn', passthroughStyle],\n gridColumnEnd: ['gridColumnEnd', passthroughStyle],\n gridColumnStart: ['gridColumnStart', passthroughStyle],\n gridRow: ['gridRow', passthroughStyle],\n gridRowEnd: ['gridRowEnd', passthroughStyle],\n gridRowStart: ['gridRowStart', passthroughStyle]\n};\n\nexport const viewStyleProps: StyleHandlers = {\n ...baseStyleProps,\n backgroundColor: ['backgroundColor', backgroundColorValue],\n borderWidth: ['borderWidth', borderSizeValue],\n borderStartWidth: [rtl('borderLeftWidth', 'borderRightWidth'), borderSizeValue],\n borderEndWidth: [rtl('borderRightWidth', 'borderLeftWidth'), borderSizeValue],\n borderLeftWidth: ['borderLeftWidth', borderSizeValue],\n borderRightWidth: ['borderRightWidth', borderSizeValue],\n borderTopWidth: ['borderTopWidth', borderSizeValue],\n borderBottomWidth: ['borderBottomWidth', borderSizeValue],\n borderXWidth: [['borderLeftWidth', 'borderRightWidth'], borderSizeValue],\n borderYWidth: [['borderTopWidth', 'borderBottomWidth'], borderSizeValue],\n borderColor: ['borderColor', borderColorValue],\n borderStartColor: [rtl('borderLeftColor', 'borderRightColor'), borderColorValue],\n borderEndColor: [rtl('borderRightColor', 'borderLeftColor'), borderColorValue],\n borderLeftColor: ['borderLeftColor', borderColorValue],\n borderRightColor: ['borderRightColor', borderColorValue],\n borderTopColor: ['borderTopColor', borderColorValue],\n borderBottomColor: ['borderBottomColor', borderColorValue],\n borderXColor: [['borderLeftColor', 'borderRightColor'], borderColorValue],\n borderYColor: [['borderTopColor', 'borderBottomColor'], borderColorValue],\n borderRadius: ['borderRadius', borderRadiusValue],\n borderTopStartRadius: [rtl('borderTopLeftRadius', 'borderTopRightRadius'), borderRadiusValue],\n borderTopEndRadius: [rtl('borderTopRightRadius', 'borderTopLeftRadius'), borderRadiusValue],\n borderBottomStartRadius: [rtl('borderBottomLeftRadius', 'borderBottomRightRadius'), borderRadiusValue],\n borderBottomEndRadius: [rtl('borderBottomRightRadius', 'borderBottomLeftRadius'), borderRadiusValue],\n borderTopLeftRadius: ['borderTopLeftRadius', borderRadiusValue],\n borderTopRightRadius: ['borderTopRightRadius', borderRadiusValue],\n borderBottomLeftRadius: ['borderBottomLeftRadius', borderRadiusValue],\n borderBottomRightRadius: ['borderBottomRightRadius', borderRadiusValue],\n padding: ['padding', dimensionValue],\n paddingStart: [rtl('paddingLeft', 'paddingRight'), dimensionValue],\n paddingEnd: [rtl('paddingRight', 'paddingLeft'), dimensionValue],\n paddingLeft: ['paddingLeft', dimensionValue],\n paddingRight: ['paddingRight', dimensionValue],\n paddingTop: ['paddingTop', dimensionValue],\n paddingBottom: ['paddingBottom', dimensionValue],\n paddingX: [['paddingLeft', 'paddingRight'], dimensionValue],\n paddingY: [['paddingTop', 'paddingBottom'], dimensionValue],\n overflow: ['overflow', passthroughStyle]\n};\n\nconst borderStyleProps = {\n borderWidth: 'borderStyle',\n borderLeftWidth: 'borderLeftStyle',\n borderRightWidth: 'borderRightStyle',\n borderTopWidth: 'borderTopStyle',\n borderBottomWidth: 'borderBottomStyle'\n};\n\nfunction rtl(ltr: string, rtl: string) {\n return (direction: Direction) => (\n direction === 'rtl' ? rtl : ltr\n );\n}\n\nconst UNIT_RE = /(%|px|em|rem|vw|vh|auto|cm|mm|in|pt|pc|ex|ch|rem|vmin|vmax|fr)$/;\nconst FUNC_RE = /^\\s*\\w+\\(/;\nconst SPECTRUM_VARIABLE_RE = /(static-)?size-\\d+|single-line-(height|width)/g;\n\nexport function dimensionValue(value: DimensionValue) {\n if (typeof value === 'number') {\n return value + 'px';\n }\n\n if (!value) {\n return undefined;\n }\n\n if (UNIT_RE.test(value)) {\n return value;\n }\n\n if (FUNC_RE.test(value)) {\n return value.replace(SPECTRUM_VARIABLE_RE, 'var(--spectrum-global-dimension-$&, var(--spectrum-alias-$&))');\n }\n\n return `var(--spectrum-global-dimension-${value}, var(--spectrum-alias-${value}))`;\n}\n\nexport function responsiveDimensionValue(value: Responsive<DimensionValue>, matchedBreakpoints: Breakpoint[]) {\n value = getResponsiveProp(value, matchedBreakpoints);\n return dimensionValue(value);\n}\n\ntype ColorType = 'default' | 'background' | 'border' | 'icon' | 'status';\nfunction colorValue(value: ColorValue, type: ColorType = 'default', version = 5) {\n if (version > 5) {\n return `var(--spectrum-${value}, var(--spectrum-semantic-${value}-color-${type}))`;\n }\n\n return `var(--spectrum-legacy-color-${value}, var(--spectrum-global-color-${value}, var(--spectrum-semantic-${value}-color-${type})))`;\n}\n\nfunction backgroundColorValue(value: BackgroundColorValue, version = 5) {\n if (!value) {\n return undefined;\n }\n\n return `var(--spectrum-alias-background-color-${value}, ${colorValue(value as ColorValue, 'background', version)})`;\n}\n\nfunction borderColorValue(value: BorderColorValue, version = 5) {\n if (!value) {\n return undefined;\n }\n\n if (value === 'default') {\n return 'var(--spectrum-alias-border-color)';\n }\n\n return `var(--spectrum-alias-border-color-${value}, ${colorValue(value as ColorValue, 'border', version)})`;\n}\n\nfunction borderSizeValue(value?: BorderSizeValue | null) {\n return value && value !== 'none'\n ? `var(--spectrum-alias-border-size-${value})`\n : '0';\n}\n\nfunction borderRadiusValue(value: BorderRadiusValue) {\n if (!value) {\n return undefined;\n }\n\n return `var(--spectrum-alias-border-radius-${value})`;\n}\n\nfunction hiddenValue(value: boolean) {\n return value ? 'none' : undefined;\n}\n\nfunction anyValue(value: any) {\n return value;\n}\n\nfunction flexValue(value: boolean | number | string) {\n if (typeof value === 'boolean') {\n return value ? '1' : undefined;\n }\n\n return '' + value;\n}\n\nexport function convertStyleProps<C extends ColorVersion>(props: ViewStyleProps<C>, handlers: StyleHandlers, direction: Direction, matchedBreakpoints: Breakpoint[]) {\n let style: CSSProperties = {};\n for (let key in props) {\n let styleProp = handlers[key];\n if (!styleProp || props[key] == null) {\n continue;\n }\n\n let [name, convert] = styleProp;\n if (typeof name === 'function') {\n name = name(direction);\n }\n\n let prop = getResponsiveProp(props[key], matchedBreakpoints);\n let value = convert(prop, props.colorVersion);\n if (Array.isArray(name)) {\n for (let k of name) {\n style[k] = value;\n }\n } else {\n style[name] = value;\n }\n }\n\n for (let prop in borderStyleProps) {\n if (style[prop]) {\n style[borderStyleProps[prop]] = 'solid';\n style.boxSizing = 'border-box';\n }\n }\n\n return style;\n}\n\ntype StylePropsOptions = {\n matchedBreakpoints?: Breakpoint[]\n};\n\nexport function useStyleProps<T extends StyleProps>(\n props: T,\n handlers: StyleHandlers = baseStyleProps,\n options: StylePropsOptions = {}\n) {\n let {\n UNSAFE_className,\n UNSAFE_style,\n ...otherProps\n } = props;\n let breakpointProvider = useBreakpoint();\n let {direction} = useLocale();\n let {\n matchedBreakpoints = breakpointProvider?.matchedBreakpoints || ['base']\n } = options;\n let styles = convertStyleProps(props, handlers, direction, matchedBreakpoints);\n let style = {...UNSAFE_style, ...styles};\n\n // @ts-ignore\n if (otherProps.className) {\n console.warn(\n 'The className prop is unsafe and is unsupported in React Spectrum v3. ' +\n 'Please use style props with Spectrum variables, or UNSAFE_className if you absolutely must do something custom. ' +\n 'Note that this may break in future versions due to DOM structure changes.'\n );\n }\n\n // @ts-ignore\n if (otherProps.style) {\n console.warn(\n 'The style prop is unsafe and is unsupported in React Spectrum v3. ' +\n 'Please use style props with Spectrum variables, or UNSAFE_style if you absolutely must do something custom. ' +\n 'Note that this may break in future versions due to DOM structure changes.'\n );\n }\n\n let styleProps: HTMLAttributes<HTMLElement> = {\n style,\n className: UNSAFE_className\n };\n\n if (getResponsiveProp(props.isHidden, matchedBreakpoints)) {\n styleProps.hidden = true;\n }\n\n return {\n styleProps\n };\n}\n\nexport function passthroughStyle(value) {\n return value;\n}\n\nexport function getResponsiveProp<T>(prop: Responsive<T>, matchedBreakpoints: Breakpoint[]): T {\n if (prop && typeof prop === 'object' && !Array.isArray(prop)) {\n for (let i = 0; i < matchedBreakpoints.length; i++) {\n let breakpoint = matchedBreakpoints[i];\n if (prop[breakpoint] != null) {\n return prop[breakpoint];\n }\n }\n return (prop as ResponsiveProp<T>).base;\n }\n return prop as T;\n}\n"],"names":[],"version":3,"file":"styleProps.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAcM,MAAM,4CAAgC;IAC3C,QAAQ;QAAC;QAAU;KAAe;IAClC,aAAa;QAAC,0BAAI,cAAc;QAAgB;KAAe;IAC/D,WAAW;QAAC,0BAAI,eAAe;QAAe;KAAe;IAC7D,8CAA8C;IAC9C,gDAAgD;IAChD,WAAW;QAAC;QAAa;KAAe;IACxC,cAAc;QAAC;QAAgB;KAAe;IAC9C,SAAS;QAAC;YAAC;YAAc;SAAc;QAAE;KAAe;IACxD,SAAS;QAAC;YAAC;YAAa;SAAe;QAAE;KAAe;IACxD,OAAO;QAAC;QAAS;KAAe;IAChC,QAAQ;QAAC;QAAU;KAAe;IAClC,UAAU;QAAC;QAAY;KAAe;IACtC,WAAW;QAAC;QAAa;KAAe;IACxC,UAAU;QAAC;QAAY;KAAe;IACtC,WAAW;QAAC;QAAa;KAAe;IACxC,UAAU;QAAC;QAAW;KAAY;IAClC,WAAW;QAAC;QAAa;KAAiB;IAC1C,aAAa;QAAC;QAAe;KAAiB;IAC9C,UAAU;QAAC;QAAY;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,yCAAA,mBAAoB,kBAAkB,KAAI;QAAC;KAAO,EACxE,GAAG;IACJ,IAAI,SAAS,0CAAkB,OAAO,UAAU,WAAW;IAC3D,IAAI,QAAQ;QAAC,GAAG,YAAY;QAAE,GAAG,MAAM;IAAA;IAEvC,aAAa;IACb,IAAI,WAAW,SAAS,EACtB,QAAQ,IAAI,CACV;IAMJ,aAAa;IACb,IAAI,WAAW,KAAK,EAClB,QAAQ,IAAI,CACV;IAMJ,IAAI,aAA0C;eAC5C;QACA,WAAW;IACb;IAEA,IAAI,0CAAkB,MAAM,QAAQ,EAAE,qBACpC,WAAW,MAAM,GAAG;IAGtB,OAAO;oBACL;IACF;AACF;AAEO,SAAS,0CAAiB,KAAK;IACpC,OAAO;AACT;AAEO,SAAS,0CAAqB,IAAmB,EAAE,kBAAgC;IACxF,IAAI,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,OAAO,CAAC,OAAO;QAC5D,IAAK,IAAI,IAAI,GAAG,IAAI,mBAAmB,MAAM,EAAE,IAAK;YAClD,IAAI,aAAa,kBAAkB,CAAC,EAAE;YACtC,IAAI,IAAI,CAAC,WAAW,IAAI,MACtB,OAAO,IAAI,CAAC,WAAW;QAE3B;QACA,OAAO,AAAC,KAA2B,IAAI;IACzC;IACA,OAAO;AACT","sources":["packages/@react-spectrum/utils/src/styleProps.ts"],"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 {BackgroundColorValue, BorderColorValue, BorderRadiusValue, BorderSizeValue, ColorValue, ColorVersion, DimensionValue, Direction, Responsive, ResponsiveProp, StyleProps, ViewStyleProps} from '@react-types/shared';\nimport {CSSProperties, HTMLAttributes} from 'react';\nimport {useBreakpoint} from './BreakpointProvider';\nimport {useLocale} from '@react-aria/i18n';\n\ntype Breakpoint = 'base' | 'S' | 'M' | 'L' | string;\ntype StyleName = string | string[] | ((dir: Direction) => string);\ntype StyleHandler = (value: any, colorVersion?: number) => string | undefined;\nexport interface StyleHandlers {\n [key: string]: [StyleName, StyleHandler]\n}\n\nexport const baseStyleProps: StyleHandlers = {\n margin: ['margin', dimensionValue],\n marginStart: [rtl('marginLeft', 'marginRight'), dimensionValue],\n marginEnd: [rtl('marginRight', 'marginLeft'), dimensionValue],\n // marginLeft: ['marginLeft', dimensionValue],\n // marginRight: ['marginRight', dimensionValue],\n marginTop: ['marginTop', dimensionValue],\n marginBottom: ['marginBottom', dimensionValue],\n marginX: [['marginLeft', 'marginRight'], dimensionValue],\n marginY: [['marginTop', 'marginBottom'], dimensionValue],\n width: ['width', dimensionValue],\n height: ['height', dimensionValue],\n minWidth: ['minWidth', dimensionValue],\n minHeight: ['minHeight', dimensionValue],\n maxWidth: ['maxWidth', dimensionValue],\n maxHeight: ['maxHeight', dimensionValue],\n isHidden: ['display', hiddenValue],\n alignSelf: ['alignSelf', passthroughStyle],\n justifySelf: ['justifySelf', passthroughStyle],\n position: ['position', anyValue],\n zIndex: ['zIndex', anyValue],\n top: ['top', dimensionValue],\n bottom: ['bottom', dimensionValue],\n start: [rtl('left', 'right'), dimensionValue],\n end: [rtl('right', 'left'), dimensionValue],\n left: ['left', dimensionValue],\n right: ['right', dimensionValue],\n order: ['order', anyValue],\n flex: ['flex', flexValue],\n flexGrow: ['flexGrow', passthroughStyle],\n flexShrink: ['flexShrink', passthroughStyle],\n flexBasis: ['flexBasis', passthroughStyle],\n gridArea: ['gridArea', passthroughStyle],\n gridColumn: ['gridColumn', passthroughStyle],\n gridColumnEnd: ['gridColumnEnd', passthroughStyle],\n gridColumnStart: ['gridColumnStart', passthroughStyle],\n gridRow: ['gridRow', passthroughStyle],\n gridRowEnd: ['gridRowEnd', passthroughStyle],\n gridRowStart: ['gridRowStart', passthroughStyle]\n};\n\nexport const viewStyleProps: StyleHandlers = {\n ...baseStyleProps,\n backgroundColor: ['backgroundColor', backgroundColorValue],\n borderWidth: ['borderWidth', borderSizeValue],\n borderStartWidth: [rtl('borderLeftWidth', 'borderRightWidth'), borderSizeValue],\n borderEndWidth: [rtl('borderRightWidth', 'borderLeftWidth'), borderSizeValue],\n borderLeftWidth: ['borderLeftWidth', borderSizeValue],\n borderRightWidth: ['borderRightWidth', borderSizeValue],\n borderTopWidth: ['borderTopWidth', borderSizeValue],\n borderBottomWidth: ['borderBottomWidth', borderSizeValue],\n borderXWidth: [['borderLeftWidth', 'borderRightWidth'], borderSizeValue],\n borderYWidth: [['borderTopWidth', 'borderBottomWidth'], borderSizeValue],\n borderColor: ['borderColor', borderColorValue],\n borderStartColor: [rtl('borderLeftColor', 'borderRightColor'), borderColorValue],\n borderEndColor: [rtl('borderRightColor', 'borderLeftColor'), borderColorValue],\n borderLeftColor: ['borderLeftColor', borderColorValue],\n borderRightColor: ['borderRightColor', borderColorValue],\n borderTopColor: ['borderTopColor', borderColorValue],\n borderBottomColor: ['borderBottomColor', borderColorValue],\n borderXColor: [['borderLeftColor', 'borderRightColor'], borderColorValue],\n borderYColor: [['borderTopColor', 'borderBottomColor'], borderColorValue],\n borderRadius: ['borderRadius', borderRadiusValue],\n borderTopStartRadius: [rtl('borderTopLeftRadius', 'borderTopRightRadius'), borderRadiusValue],\n borderTopEndRadius: [rtl('borderTopRightRadius', 'borderTopLeftRadius'), borderRadiusValue],\n borderBottomStartRadius: [rtl('borderBottomLeftRadius', 'borderBottomRightRadius'), borderRadiusValue],\n borderBottomEndRadius: [rtl('borderBottomRightRadius', 'borderBottomLeftRadius'), borderRadiusValue],\n borderTopLeftRadius: ['borderTopLeftRadius', borderRadiusValue],\n borderTopRightRadius: ['borderTopRightRadius', borderRadiusValue],\n borderBottomLeftRadius: ['borderBottomLeftRadius', borderRadiusValue],\n borderBottomRightRadius: ['borderBottomRightRadius', borderRadiusValue],\n padding: ['padding', dimensionValue],\n paddingStart: [rtl('paddingLeft', 'paddingRight'), dimensionValue],\n paddingEnd: [rtl('paddingRight', 'paddingLeft'), dimensionValue],\n paddingLeft: ['paddingLeft', dimensionValue],\n paddingRight: ['paddingRight', dimensionValue],\n paddingTop: ['paddingTop', dimensionValue],\n paddingBottom: ['paddingBottom', dimensionValue],\n paddingX: [['paddingLeft', 'paddingRight'], dimensionValue],\n paddingY: [['paddingTop', 'paddingBottom'], dimensionValue],\n overflow: ['overflow', passthroughStyle]\n};\n\nconst borderStyleProps = {\n borderWidth: 'borderStyle',\n borderLeftWidth: 'borderLeftStyle',\n borderRightWidth: 'borderRightStyle',\n borderTopWidth: 'borderTopStyle',\n borderBottomWidth: 'borderBottomStyle'\n};\n\nfunction rtl(ltr: string, rtl: string) {\n return (direction: Direction) => (\n direction === 'rtl' ? rtl : ltr\n );\n}\n\nconst UNIT_RE = /(%|px|em|rem|vw|vh|auto|cm|mm|in|pt|pc|ex|ch|rem|vmin|vmax|fr)$/;\nconst FUNC_RE = /^\\s*\\w+\\(/;\nconst SPECTRUM_VARIABLE_RE = /(static-)?size-\\d+|single-line-(height|width)/g;\n\nexport function dimensionValue(value: DimensionValue) {\n if (typeof value === 'number') {\n return value + 'px';\n }\n\n if (!value) {\n return undefined;\n }\n\n if (UNIT_RE.test(value)) {\n return value;\n }\n\n if (FUNC_RE.test(value)) {\n return value.replace(SPECTRUM_VARIABLE_RE, 'var(--spectrum-global-dimension-$&, var(--spectrum-alias-$&))');\n }\n\n return `var(--spectrum-global-dimension-${value}, var(--spectrum-alias-${value}))`;\n}\n\nexport function responsiveDimensionValue(value: Responsive<DimensionValue>, matchedBreakpoints: Breakpoint[]) {\n let responsiveValue = getResponsiveProp(value, matchedBreakpoints);\n if (responsiveValue != null) {\n return dimensionValue(responsiveValue);\n }\n}\n\ntype ColorType = 'default' | 'background' | 'border' | 'icon' | 'status';\nfunction colorValue(value: ColorValue, type: ColorType = 'default', version = 5) {\n if (version > 5) {\n return `var(--spectrum-${value}, var(--spectrum-semantic-${value}-color-${type}))`;\n }\n\n return `var(--spectrum-legacy-color-${value}, var(--spectrum-global-color-${value}, var(--spectrum-semantic-${value}-color-${type})))`;\n}\n\nfunction backgroundColorValue(value: BackgroundColorValue, version = 5) {\n if (!value) {\n return undefined;\n }\n\n return `var(--spectrum-alias-background-color-${value}, ${colorValue(value as ColorValue, 'background', version)})`;\n}\n\nfunction borderColorValue(value: BorderColorValue, version = 5) {\n if (!value) {\n return undefined;\n }\n\n if (value === 'default') {\n return 'var(--spectrum-alias-border-color)';\n }\n\n return `var(--spectrum-alias-border-color-${value}, ${colorValue(value as ColorValue, 'border', version)})`;\n}\n\nfunction borderSizeValue(value?: BorderSizeValue | null) {\n return value && value !== 'none'\n ? `var(--spectrum-alias-border-size-${value})`\n : '0';\n}\n\nfunction borderRadiusValue(value: BorderRadiusValue) {\n if (!value) {\n return undefined;\n }\n\n return `var(--spectrum-alias-border-radius-${value})`;\n}\n\nfunction hiddenValue(value: boolean) {\n return value ? 'none' : undefined;\n}\n\nfunction anyValue(value: any) {\n return value;\n}\n\nfunction flexValue(value: boolean | number | string) {\n if (typeof value === 'boolean') {\n return value ? '1' : undefined;\n }\n\n return '' + value;\n}\n\nexport function convertStyleProps<C extends ColorVersion>(props: ViewStyleProps<C>, handlers: StyleHandlers, direction: Direction, matchedBreakpoints: Breakpoint[]) {\n let style: CSSProperties = {};\n for (let key in props) {\n let styleProp = handlers[key];\n if (!styleProp || props[key] == null) {\n continue;\n }\n\n let [name, convert] = styleProp;\n if (typeof name === 'function') {\n name = name(direction);\n }\n\n let prop = getResponsiveProp(props[key], matchedBreakpoints);\n let value = convert(prop, props.colorVersion);\n if (Array.isArray(name)) {\n for (let k of name) {\n style[k] = value;\n }\n } else {\n style[name] = value;\n }\n }\n\n for (let prop in borderStyleProps) {\n if (style[prop]) {\n style[borderStyleProps[prop]] = 'solid';\n style.boxSizing = 'border-box';\n }\n }\n\n return style;\n}\n\ntype StylePropsOptions = {\n matchedBreakpoints?: Breakpoint[]\n};\n\nexport function useStyleProps<T extends StyleProps>(\n props: T,\n handlers: StyleHandlers = baseStyleProps,\n options: StylePropsOptions = {}\n) {\n let {\n UNSAFE_className,\n UNSAFE_style,\n ...otherProps\n } = props;\n let breakpointProvider = useBreakpoint();\n let {direction} = useLocale();\n let {\n matchedBreakpoints = breakpointProvider?.matchedBreakpoints || ['base']\n } = options;\n let styles = convertStyleProps(props, handlers, direction, matchedBreakpoints);\n let style = {...UNSAFE_style, ...styles};\n\n // @ts-ignore\n if (otherProps.className) {\n console.warn(\n 'The className prop is unsafe and is unsupported in React Spectrum v3. ' +\n 'Please use style props with Spectrum variables, or UNSAFE_className if you absolutely must do something custom. ' +\n 'Note that this may break in future versions due to DOM structure changes.'\n );\n }\n\n // @ts-ignore\n if (otherProps.style) {\n console.warn(\n 'The style prop is unsafe and is unsupported in React Spectrum v3. ' +\n 'Please use style props with Spectrum variables, or UNSAFE_style if you absolutely must do something custom. ' +\n 'Note that this may break in future versions due to DOM structure changes.'\n );\n }\n\n let styleProps: HTMLAttributes<HTMLElement> = {\n style,\n className: UNSAFE_className\n };\n\n if (getResponsiveProp(props.isHidden, matchedBreakpoints)) {\n styleProps.hidden = true;\n }\n\n return {\n styleProps\n };\n}\n\nexport function passthroughStyle(value) {\n return value;\n}\n\nexport function getResponsiveProp<T>(prop: Responsive<T>, matchedBreakpoints: Breakpoint[]): T | undefined {\n if (prop && typeof prop === 'object' && !Array.isArray(prop)) {\n for (let i = 0; i < matchedBreakpoints.length; i++) {\n let breakpoint = matchedBreakpoints[i];\n if (prop[breakpoint] != null) {\n return prop[breakpoint];\n }\n }\n return (prop as ResponsiveProp<T>).base;\n }\n return prop as T;\n}\n"],"names":[],"version":3,"file":"styleProps.main.js.map"}
@@ -361,8 +361,8 @@ function $380ed8f3903c3931$export$abc24f5b99744ea6(value) {
361
361
  return `var(--spectrum-global-dimension-${value}, var(--spectrum-alias-${value}))`;
362
362
  }
363
363
  function $380ed8f3903c3931$export$f348bec194f2e6b5(value, matchedBreakpoints) {
364
- value = $380ed8f3903c3931$export$52dbfdbe1b2c3541(value, matchedBreakpoints);
365
- return $380ed8f3903c3931$export$abc24f5b99744ea6(value);
364
+ let responsiveValue = $380ed8f3903c3931$export$52dbfdbe1b2c3541(value, matchedBreakpoints);
365
+ if (responsiveValue != null) return $380ed8f3903c3931$export$abc24f5b99744ea6(responsiveValue);
366
366
  }
367
367
  function $380ed8f3903c3931$var$colorValue(value, type = 'default', version = 5) {
368
368
  if (version > 5) return `var(--spectrum-${value}, var(--spectrum-semantic-${value}-color-${type}))`;
@@ -361,8 +361,8 @@ function $380ed8f3903c3931$export$abc24f5b99744ea6(value) {
361
361
  return `var(--spectrum-global-dimension-${value}, var(--spectrum-alias-${value}))`;
362
362
  }
363
363
  function $380ed8f3903c3931$export$f348bec194f2e6b5(value, matchedBreakpoints) {
364
- value = $380ed8f3903c3931$export$52dbfdbe1b2c3541(value, matchedBreakpoints);
365
- return $380ed8f3903c3931$export$abc24f5b99744ea6(value);
364
+ let responsiveValue = $380ed8f3903c3931$export$52dbfdbe1b2c3541(value, matchedBreakpoints);
365
+ if (responsiveValue != null) return $380ed8f3903c3931$export$abc24f5b99744ea6(responsiveValue);
366
366
  }
367
367
  function $380ed8f3903c3931$var$colorValue(value, type = 'default', version = 5) {
368
368
  if (version > 5) return `var(--spectrum-${value}, var(--spectrum-semantic-${value}-color-${type}))`;
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAcM,MAAM,4CAAgC;IAC3C,QAAQ;QAAC;QAAU;KAAe;IAClC,aAAa;QAAC,0BAAI,cAAc;QAAgB;KAAe;IAC/D,WAAW;QAAC,0BAAI,eAAe;QAAe;KAAe;IAC7D,8CAA8C;IAC9C,gDAAgD;IAChD,WAAW;QAAC;QAAa;KAAe;IACxC,cAAc;QAAC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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 {BackgroundColorValue, BorderColorValue, BorderRadiusValue, BorderSizeValue, ColorValue, ColorVersion, DimensionValue, Direction, Responsive, ResponsiveProp, StyleProps, ViewStyleProps} from '@react-types/shared';\nimport {CSSProperties, HTMLAttributes} from 'react';\nimport {useBreakpoint} from './BreakpointProvider';\nimport {useLocale} from '@react-aria/i18n';\n\ntype Breakpoint = 'base' | 'S' | 'M' | 'L' | string;\ntype StyleName = string | string[] | ((dir: Direction) => string);\ntype StyleHandler = (value: any, colorVersion?: number) => string;\nexport interface StyleHandlers {\n [key: string]: [StyleName, StyleHandler]\n}\n\nexport const baseStyleProps: StyleHandlers = {\n margin: ['margin', dimensionValue],\n marginStart: [rtl('marginLeft', 'marginRight'), dimensionValue],\n marginEnd: [rtl('marginRight', 'marginLeft'), dimensionValue],\n // marginLeft: ['marginLeft', dimensionValue],\n // marginRight: ['marginRight', dimensionValue],\n marginTop: ['marginTop', dimensionValue],\n marginBottom: ['marginBottom', dimensionValue],\n marginX: [['marginLeft', 'marginRight'], dimensionValue],\n marginY: [['marginTop', 'marginBottom'], dimensionValue],\n width: ['width', dimensionValue],\n height: ['height', dimensionValue],\n minWidth: ['minWidth', dimensionValue],\n minHeight: ['minHeight', dimensionValue],\n maxWidth: ['maxWidth', dimensionValue],\n maxHeight: ['maxHeight', dimensionValue],\n isHidden: ['display', hiddenValue],\n alignSelf: ['alignSelf', passthroughStyle],\n justifySelf: ['justifySelf', passthroughStyle],\n position: ['position', anyValue],\n zIndex: ['zIndex', anyValue],\n top: ['top', dimensionValue],\n bottom: ['bottom', dimensionValue],\n start: [rtl('left', 'right'), dimensionValue],\n end: [rtl('right', 'left'), dimensionValue],\n left: ['left', dimensionValue],\n right: ['right', dimensionValue],\n order: ['order', anyValue],\n flex: ['flex', flexValue],\n flexGrow: ['flexGrow', passthroughStyle],\n flexShrink: ['flexShrink', passthroughStyle],\n flexBasis: ['flexBasis', passthroughStyle],\n gridArea: ['gridArea', passthroughStyle],\n gridColumn: ['gridColumn', passthroughStyle],\n gridColumnEnd: ['gridColumnEnd', passthroughStyle],\n gridColumnStart: ['gridColumnStart', passthroughStyle],\n gridRow: ['gridRow', passthroughStyle],\n gridRowEnd: ['gridRowEnd', passthroughStyle],\n gridRowStart: ['gridRowStart', passthroughStyle]\n};\n\nexport const viewStyleProps: StyleHandlers = {\n ...baseStyleProps,\n backgroundColor: ['backgroundColor', backgroundColorValue],\n borderWidth: ['borderWidth', borderSizeValue],\n borderStartWidth: [rtl('borderLeftWidth', 'borderRightWidth'), borderSizeValue],\n borderEndWidth: [rtl('borderRightWidth', 'borderLeftWidth'), borderSizeValue],\n borderLeftWidth: ['borderLeftWidth', borderSizeValue],\n borderRightWidth: ['borderRightWidth', borderSizeValue],\n borderTopWidth: ['borderTopWidth', borderSizeValue],\n borderBottomWidth: ['borderBottomWidth', borderSizeValue],\n borderXWidth: [['borderLeftWidth', 'borderRightWidth'], borderSizeValue],\n borderYWidth: [['borderTopWidth', 'borderBottomWidth'], borderSizeValue],\n borderColor: ['borderColor', borderColorValue],\n borderStartColor: [rtl('borderLeftColor', 'borderRightColor'), borderColorValue],\n borderEndColor: [rtl('borderRightColor', 'borderLeftColor'), borderColorValue],\n borderLeftColor: ['borderLeftColor', borderColorValue],\n borderRightColor: ['borderRightColor', borderColorValue],\n borderTopColor: ['borderTopColor', borderColorValue],\n borderBottomColor: ['borderBottomColor', borderColorValue],\n borderXColor: [['borderLeftColor', 'borderRightColor'], borderColorValue],\n borderYColor: [['borderTopColor', 'borderBottomColor'], borderColorValue],\n borderRadius: ['borderRadius', borderRadiusValue],\n borderTopStartRadius: [rtl('borderTopLeftRadius', 'borderTopRightRadius'), borderRadiusValue],\n borderTopEndRadius: [rtl('borderTopRightRadius', 'borderTopLeftRadius'), borderRadiusValue],\n borderBottomStartRadius: [rtl('borderBottomLeftRadius', 'borderBottomRightRadius'), borderRadiusValue],\n borderBottomEndRadius: [rtl('borderBottomRightRadius', 'borderBottomLeftRadius'), borderRadiusValue],\n borderTopLeftRadius: ['borderTopLeftRadius', borderRadiusValue],\n borderTopRightRadius: ['borderTopRightRadius', borderRadiusValue],\n borderBottomLeftRadius: ['borderBottomLeftRadius', borderRadiusValue],\n borderBottomRightRadius: ['borderBottomRightRadius', borderRadiusValue],\n padding: ['padding', dimensionValue],\n paddingStart: [rtl('paddingLeft', 'paddingRight'), dimensionValue],\n paddingEnd: [rtl('paddingRight', 'paddingLeft'), dimensionValue],\n paddingLeft: ['paddingLeft', dimensionValue],\n paddingRight: ['paddingRight', dimensionValue],\n paddingTop: ['paddingTop', dimensionValue],\n paddingBottom: ['paddingBottom', dimensionValue],\n paddingX: [['paddingLeft', 'paddingRight'], dimensionValue],\n paddingY: [['paddingTop', 'paddingBottom'], dimensionValue],\n overflow: ['overflow', passthroughStyle]\n};\n\nconst borderStyleProps = {\n borderWidth: 'borderStyle',\n borderLeftWidth: 'borderLeftStyle',\n borderRightWidth: 'borderRightStyle',\n borderTopWidth: 'borderTopStyle',\n borderBottomWidth: 'borderBottomStyle'\n};\n\nfunction rtl(ltr: string, rtl: string) {\n return (direction: Direction) => (\n direction === 'rtl' ? rtl : ltr\n );\n}\n\nconst UNIT_RE = /(%|px|em|rem|vw|vh|auto|cm|mm|in|pt|pc|ex|ch|rem|vmin|vmax|fr)$/;\nconst FUNC_RE = /^\\s*\\w+\\(/;\nconst SPECTRUM_VARIABLE_RE = /(static-)?size-\\d+|single-line-(height|width)/g;\n\nexport function dimensionValue(value: DimensionValue) {\n if (typeof value === 'number') {\n return value + 'px';\n }\n\n if (!value) {\n return undefined;\n }\n\n if (UNIT_RE.test(value)) {\n return value;\n }\n\n if (FUNC_RE.test(value)) {\n return value.replace(SPECTRUM_VARIABLE_RE, 'var(--spectrum-global-dimension-$&, var(--spectrum-alias-$&))');\n }\n\n return `var(--spectrum-global-dimension-${value}, var(--spectrum-alias-${value}))`;\n}\n\nexport function responsiveDimensionValue(value: Responsive<DimensionValue>, matchedBreakpoints: Breakpoint[]) {\n value = getResponsiveProp(value, matchedBreakpoints);\n return dimensionValue(value);\n}\n\ntype ColorType = 'default' | 'background' | 'border' | 'icon' | 'status';\nfunction colorValue(value: ColorValue, type: ColorType = 'default', version = 5) {\n if (version > 5) {\n return `var(--spectrum-${value}, var(--spectrum-semantic-${value}-color-${type}))`;\n }\n\n return `var(--spectrum-legacy-color-${value}, var(--spectrum-global-color-${value}, var(--spectrum-semantic-${value}-color-${type})))`;\n}\n\nfunction backgroundColorValue(value: BackgroundColorValue, version = 5) {\n if (!value) {\n return undefined;\n }\n\n return `var(--spectrum-alias-background-color-${value}, ${colorValue(value as ColorValue, 'background', version)})`;\n}\n\nfunction borderColorValue(value: BorderColorValue, version = 5) {\n if (!value) {\n return undefined;\n }\n\n if (value === 'default') {\n return 'var(--spectrum-alias-border-color)';\n }\n\n return `var(--spectrum-alias-border-color-${value}, ${colorValue(value as ColorValue, 'border', version)})`;\n}\n\nfunction borderSizeValue(value?: BorderSizeValue | null) {\n return value && value !== 'none'\n ? `var(--spectrum-alias-border-size-${value})`\n : '0';\n}\n\nfunction borderRadiusValue(value: BorderRadiusValue) {\n if (!value) {\n return undefined;\n }\n\n return `var(--spectrum-alias-border-radius-${value})`;\n}\n\nfunction hiddenValue(value: boolean) {\n return value ? 'none' : undefined;\n}\n\nfunction anyValue(value: any) {\n return value;\n}\n\nfunction flexValue(value: boolean | number | string) {\n if (typeof value === 'boolean') {\n return value ? '1' : undefined;\n }\n\n return '' + value;\n}\n\nexport function convertStyleProps<C extends ColorVersion>(props: ViewStyleProps<C>, handlers: StyleHandlers, direction: Direction, matchedBreakpoints: Breakpoint[]) {\n let style: CSSProperties = {};\n for (let key in props) {\n let styleProp = handlers[key];\n if (!styleProp || props[key] == null) {\n continue;\n }\n\n let [name, convert] = styleProp;\n if (typeof name === 'function') {\n name = name(direction);\n }\n\n let prop = getResponsiveProp(props[key], matchedBreakpoints);\n let value = convert(prop, props.colorVersion);\n if (Array.isArray(name)) {\n for (let k of name) {\n style[k] = value;\n }\n } else {\n style[name] = value;\n }\n }\n\n for (let prop in borderStyleProps) {\n if (style[prop]) {\n style[borderStyleProps[prop]] = 'solid';\n style.boxSizing = 'border-box';\n }\n }\n\n return style;\n}\n\ntype StylePropsOptions = {\n matchedBreakpoints?: Breakpoint[]\n};\n\nexport function useStyleProps<T extends StyleProps>(\n props: T,\n handlers: StyleHandlers = baseStyleProps,\n options: StylePropsOptions = {}\n) {\n let {\n UNSAFE_className,\n UNSAFE_style,\n ...otherProps\n } = props;\n let breakpointProvider = useBreakpoint();\n let {direction} = useLocale();\n let {\n matchedBreakpoints = breakpointProvider?.matchedBreakpoints || ['base']\n } = options;\n let styles = convertStyleProps(props, handlers, direction, matchedBreakpoints);\n let style = {...UNSAFE_style, ...styles};\n\n // @ts-ignore\n if (otherProps.className) {\n console.warn(\n 'The className prop is unsafe and is unsupported in React Spectrum v3. ' +\n 'Please use style props with Spectrum variables, or UNSAFE_className if you absolutely must do something custom. ' +\n 'Note that this may break in future versions due to DOM structure changes.'\n );\n }\n\n // @ts-ignore\n if (otherProps.style) {\n console.warn(\n 'The style prop is unsafe and is unsupported in React Spectrum v3. ' +\n 'Please use style props with Spectrum variables, or UNSAFE_style if you absolutely must do something custom. ' +\n 'Note that this may break in future versions due to DOM structure changes.'\n );\n }\n\n let styleProps: HTMLAttributes<HTMLElement> = {\n style,\n className: UNSAFE_className\n };\n\n if (getResponsiveProp(props.isHidden, matchedBreakpoints)) {\n styleProps.hidden = true;\n }\n\n return {\n styleProps\n };\n}\n\nexport function passthroughStyle(value) {\n return value;\n}\n\nexport function getResponsiveProp<T>(prop: Responsive<T>, matchedBreakpoints: Breakpoint[]): T {\n if (prop && typeof prop === 'object' && !Array.isArray(prop)) {\n for (let i = 0; i < matchedBreakpoints.length; i++) {\n let breakpoint = matchedBreakpoints[i];\n if (prop[breakpoint] != null) {\n return prop[breakpoint];\n }\n }\n return (prop as ResponsiveProp<T>).base;\n }\n return prop as T;\n}\n"],"names":[],"version":3,"file":"styleProps.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAcM,MAAM,4CAAgC;IAC3C,QAAQ;QAAC;QAAU;KAAe;IAClC,aAAa;QAAC,0BAAI,cAAc;QAAgB;KAAe;IAC/D,WAAW;QAAC,0BAAI,eAAe;QAAe;KAAe;IAC7D,8CAA8C;IAC9C,gDAAgD;IAChD,WAAW;QAAC;QAAa;KAAe;IACxC,cAAc;QAAC;QAAgB;KAAe;IAC9C,SAAS;QAAC;YAAC;YAAc;SAAc;QAAE;KAAe;IACxD,SAAS;QAAC;YAAC;YAAa;SAAe;QAAE;KAAe;IACxD,OAAO;QAAC;QAAS;KAAe;IAChC,QAAQ;QAAC;QAAU;KAAe;IAClC,UAAU;QAAC;QAAY;KAAe;IACtC,WAAW;QAAC;QAAa;KAAe;IACxC,UAAU;QAAC;QAAY;KAAe;IACtC,WAAW;QAAC;QAAa;KAAe;IACxC,UAAU;QAAC;QAAW;KAAY;IAClC,WAAW;QAAC;QAAa;KAAiB;IAC1C,aAAa;QAAC;QAAe;KAAiB;IAC9C,UAAU;QAAC;QAAY;KAAS;IAChC,QAAQ;QAAC;QAAU;KAAS;IAC5B,KAAK;QAAC;QAAO;KAAe;IAC5B,QAAQ;QAAC;QAAU;KAAe;IAClC,OAAO;QAAC,0BAAI,QAAQ;QAAU;KAAe;IAC7C,KAAK;QAAC,0BAAI,SAAS;QAAS;KAAe;IAC3C,MAAM;QAAC;QAAQ;KAAe;IAC9B,OAAO;QAAC;QAAS;KAAe;IAChC,OAAO;QAAC;QAAS;K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ACV;IAMJ,IAAI,aAA0C;eAC5C;QACA,WAAW;IACb;IAEA,IAAI,0CAAkB,MAAM,QAAQ,EAAE,qBACpC,WAAW,MAAM,GAAG;IAGtB,OAAO;oBACL;IACF;AACF;AAEO,SAAS,0CAAiB,KAAK;IACpC,OAAO;AACT;AAEO,SAAS,0CAAqB,IAAmB,EAAE,kBAAgC;IACxF,IAAI,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,OAAO,CAAC,OAAO;QAC5D,IAAK,IAAI,IAAI,GAAG,IAAI,mBAAmB,MAAM,EAAE,IAAK;YAClD,IAAI,aAAa,kBAAkB,CAAC,EAAE;YACtC,IAAI,IAAI,CAAC,WAAW,IAAI,MACtB,OAAO,IAAI,CAAC,WAAW;QAE3B;QACA,OAAO,AAAC,KAA2B,IAAI;IACzC;IACA,OAAO;AACT","sources":["packages/@react-spectrum/utils/src/styleProps.ts"],"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 {BackgroundColorValue, BorderColorValue, BorderRadiusValue, BorderSizeValue, ColorValue, ColorVersion, DimensionValue, Direction, Responsive, ResponsiveProp, StyleProps, ViewStyleProps} from '@react-types/shared';\nimport {CSSProperties, HTMLAttributes} from 'react';\nimport {useBreakpoint} from './BreakpointProvider';\nimport {useLocale} from '@react-aria/i18n';\n\ntype Breakpoint = 'base' | 'S' | 'M' | 'L' | string;\ntype StyleName = string | string[] | ((dir: Direction) => string);\ntype StyleHandler = (value: any, colorVersion?: number) => string | undefined;\nexport interface StyleHandlers {\n [key: string]: [StyleName, StyleHandler]\n}\n\nexport const baseStyleProps: StyleHandlers = {\n margin: ['margin', dimensionValue],\n marginStart: [rtl('marginLeft', 'marginRight'), dimensionValue],\n marginEnd: [rtl('marginRight', 'marginLeft'), dimensionValue],\n // marginLeft: ['marginLeft', dimensionValue],\n // marginRight: ['marginRight', dimensionValue],\n marginTop: ['marginTop', dimensionValue],\n marginBottom: ['marginBottom', dimensionValue],\n marginX: [['marginLeft', 'marginRight'], dimensionValue],\n marginY: [['marginTop', 'marginBottom'], dimensionValue],\n width: ['width', dimensionValue],\n height: ['height', dimensionValue],\n minWidth: ['minWidth', dimensionValue],\n minHeight: ['minHeight', dimensionValue],\n maxWidth: ['maxWidth', dimensionValue],\n maxHeight: ['maxHeight', dimensionValue],\n isHidden: ['display', hiddenValue],\n alignSelf: ['alignSelf', passthroughStyle],\n justifySelf: ['justifySelf', passthroughStyle],\n position: ['position', anyValue],\n zIndex: ['zIndex', anyValue],\n top: ['top', dimensionValue],\n bottom: ['bottom', dimensionValue],\n start: [rtl('left', 'right'), dimensionValue],\n end: [rtl('right', 'left'), dimensionValue],\n left: ['left', dimensionValue],\n right: ['right', dimensionValue],\n order: ['order', anyValue],\n flex: ['flex', flexValue],\n flexGrow: ['flexGrow', passthroughStyle],\n flexShrink: ['flexShrink', passthroughStyle],\n flexBasis: ['flexBasis', passthroughStyle],\n gridArea: ['gridArea', passthroughStyle],\n gridColumn: ['gridColumn', passthroughStyle],\n gridColumnEnd: ['gridColumnEnd', passthroughStyle],\n gridColumnStart: ['gridColumnStart', passthroughStyle],\n gridRow: ['gridRow', passthroughStyle],\n gridRowEnd: ['gridRowEnd', passthroughStyle],\n gridRowStart: ['gridRowStart', passthroughStyle]\n};\n\nexport const viewStyleProps: StyleHandlers = {\n ...baseStyleProps,\n backgroundColor: ['backgroundColor', backgroundColorValue],\n borderWidth: ['borderWidth', borderSizeValue],\n borderStartWidth: [rtl('borderLeftWidth', 'borderRightWidth'), borderSizeValue],\n borderEndWidth: [rtl('borderRightWidth', 'borderLeftWidth'), borderSizeValue],\n borderLeftWidth: ['borderLeftWidth', borderSizeValue],\n borderRightWidth: ['borderRightWidth', borderSizeValue],\n borderTopWidth: ['borderTopWidth', borderSizeValue],\n borderBottomWidth: ['borderBottomWidth', borderSizeValue],\n borderXWidth: [['borderLeftWidth', 'borderRightWidth'], borderSizeValue],\n borderYWidth: [['borderTopWidth', 'borderBottomWidth'], borderSizeValue],\n borderColor: ['borderColor', borderColorValue],\n borderStartColor: [rtl('borderLeftColor', 'borderRightColor'), borderColorValue],\n borderEndColor: [rtl('borderRightColor', 'borderLeftColor'), borderColorValue],\n borderLeftColor: ['borderLeftColor', borderColorValue],\n borderRightColor: ['borderRightColor', borderColorValue],\n borderTopColor: ['borderTopColor', borderColorValue],\n borderBottomColor: ['borderBottomColor', borderColorValue],\n borderXColor: [['borderLeftColor', 'borderRightColor'], borderColorValue],\n borderYColor: [['borderTopColor', 'borderBottomColor'], borderColorValue],\n borderRadius: ['borderRadius', borderRadiusValue],\n borderTopStartRadius: [rtl('borderTopLeftRadius', 'borderTopRightRadius'), borderRadiusValue],\n borderTopEndRadius: [rtl('borderTopRightRadius', 'borderTopLeftRadius'), borderRadiusValue],\n borderBottomStartRadius: [rtl('borderBottomLeftRadius', 'borderBottomRightRadius'), borderRadiusValue],\n borderBottomEndRadius: [rtl('borderBottomRightRadius', 'borderBottomLeftRadius'), borderRadiusValue],\n borderTopLeftRadius: ['borderTopLeftRadius', borderRadiusValue],\n borderTopRightRadius: ['borderTopRightRadius', borderRadiusValue],\n borderBottomLeftRadius: ['borderBottomLeftRadius', borderRadiusValue],\n borderBottomRightRadius: ['borderBottomRightRadius', borderRadiusValue],\n padding: ['padding', dimensionValue],\n paddingStart: [rtl('paddingLeft', 'paddingRight'), dimensionValue],\n paddingEnd: [rtl('paddingRight', 'paddingLeft'), dimensionValue],\n paddingLeft: ['paddingLeft', dimensionValue],\n paddingRight: ['paddingRight', dimensionValue],\n paddingTop: ['paddingTop', dimensionValue],\n paddingBottom: ['paddingBottom', dimensionValue],\n paddingX: [['paddingLeft', 'paddingRight'], dimensionValue],\n paddingY: [['paddingTop', 'paddingBottom'], dimensionValue],\n overflow: ['overflow', passthroughStyle]\n};\n\nconst borderStyleProps = {\n borderWidth: 'borderStyle',\n borderLeftWidth: 'borderLeftStyle',\n borderRightWidth: 'borderRightStyle',\n borderTopWidth: 'borderTopStyle',\n borderBottomWidth: 'borderBottomStyle'\n};\n\nfunction rtl(ltr: string, rtl: string) {\n return (direction: Direction) => (\n direction === 'rtl' ? rtl : ltr\n );\n}\n\nconst UNIT_RE = /(%|px|em|rem|vw|vh|auto|cm|mm|in|pt|pc|ex|ch|rem|vmin|vmax|fr)$/;\nconst FUNC_RE = /^\\s*\\w+\\(/;\nconst SPECTRUM_VARIABLE_RE = /(static-)?size-\\d+|single-line-(height|width)/g;\n\nexport function dimensionValue(value: DimensionValue) {\n if (typeof value === 'number') {\n return value + 'px';\n }\n\n if (!value) {\n return undefined;\n }\n\n if (UNIT_RE.test(value)) {\n return value;\n }\n\n if (FUNC_RE.test(value)) {\n return value.replace(SPECTRUM_VARIABLE_RE, 'var(--spectrum-global-dimension-$&, var(--spectrum-alias-$&))');\n }\n\n return `var(--spectrum-global-dimension-${value}, var(--spectrum-alias-${value}))`;\n}\n\nexport function responsiveDimensionValue(value: Responsive<DimensionValue>, matchedBreakpoints: Breakpoint[]) {\n let responsiveValue = getResponsiveProp(value, matchedBreakpoints);\n if (responsiveValue != null) {\n return dimensionValue(responsiveValue);\n }\n}\n\ntype ColorType = 'default' | 'background' | 'border' | 'icon' | 'status';\nfunction colorValue(value: ColorValue, type: ColorType = 'default', version = 5) {\n if (version > 5) {\n return `var(--spectrum-${value}, var(--spectrum-semantic-${value}-color-${type}))`;\n }\n\n return `var(--spectrum-legacy-color-${value}, var(--spectrum-global-color-${value}, var(--spectrum-semantic-${value}-color-${type})))`;\n}\n\nfunction backgroundColorValue(value: BackgroundColorValue, version = 5) {\n if (!value) {\n return undefined;\n }\n\n return `var(--spectrum-alias-background-color-${value}, ${colorValue(value as ColorValue, 'background', version)})`;\n}\n\nfunction borderColorValue(value: BorderColorValue, version = 5) {\n if (!value) {\n return undefined;\n }\n\n if (value === 'default') {\n return 'var(--spectrum-alias-border-color)';\n }\n\n return `var(--spectrum-alias-border-color-${value}, ${colorValue(value as ColorValue, 'border', version)})`;\n}\n\nfunction borderSizeValue(value?: BorderSizeValue | null) {\n return value && value !== 'none'\n ? `var(--spectrum-alias-border-size-${value})`\n : '0';\n}\n\nfunction borderRadiusValue(value: BorderRadiusValue) {\n if (!value) {\n return undefined;\n }\n\n return `var(--spectrum-alias-border-radius-${value})`;\n}\n\nfunction hiddenValue(value: boolean) {\n return value ? 'none' : undefined;\n}\n\nfunction anyValue(value: any) {\n return value;\n}\n\nfunction flexValue(value: boolean | number | string) {\n if (typeof value === 'boolean') {\n return value ? '1' : undefined;\n }\n\n return '' + value;\n}\n\nexport function convertStyleProps<C extends ColorVersion>(props: ViewStyleProps<C>, handlers: StyleHandlers, direction: Direction, matchedBreakpoints: Breakpoint[]) {\n let style: CSSProperties = {};\n for (let key in props) {\n let styleProp = handlers[key];\n if (!styleProp || props[key] == null) {\n continue;\n }\n\n let [name, convert] = styleProp;\n if (typeof name === 'function') {\n name = name(direction);\n }\n\n let prop = getResponsiveProp(props[key], matchedBreakpoints);\n let value = convert(prop, props.colorVersion);\n if (Array.isArray(name)) {\n for (let k of name) {\n style[k] = value;\n }\n } else {\n style[name] = value;\n }\n }\n\n for (let prop in borderStyleProps) {\n if (style[prop]) {\n style[borderStyleProps[prop]] = 'solid';\n style.boxSizing = 'border-box';\n }\n }\n\n return style;\n}\n\ntype StylePropsOptions = {\n matchedBreakpoints?: Breakpoint[]\n};\n\nexport function useStyleProps<T extends StyleProps>(\n props: T,\n handlers: StyleHandlers = baseStyleProps,\n options: StylePropsOptions = {}\n) {\n let {\n UNSAFE_className,\n UNSAFE_style,\n ...otherProps\n } = props;\n let breakpointProvider = useBreakpoint();\n let {direction} = useLocale();\n let {\n matchedBreakpoints = breakpointProvider?.matchedBreakpoints || ['base']\n } = options;\n let styles = convertStyleProps(props, handlers, direction, matchedBreakpoints);\n let style = {...UNSAFE_style, ...styles};\n\n // @ts-ignore\n if (otherProps.className) {\n console.warn(\n 'The className prop is unsafe and is unsupported in React Spectrum v3. ' +\n 'Please use style props with Spectrum variables, or UNSAFE_className if you absolutely must do something custom. ' +\n 'Note that this may break in future versions due to DOM structure changes.'\n );\n }\n\n // @ts-ignore\n if (otherProps.style) {\n console.warn(\n 'The style prop is unsafe and is unsupported in React Spectrum v3. ' +\n 'Please use style props with Spectrum variables, or UNSAFE_style if you absolutely must do something custom. ' +\n 'Note that this may break in future versions due to DOM structure changes.'\n );\n }\n\n let styleProps: HTMLAttributes<HTMLElement> = {\n style,\n className: UNSAFE_className\n };\n\n if (getResponsiveProp(props.isHidden, matchedBreakpoints)) {\n styleProps.hidden = true;\n }\n\n return {\n styleProps\n };\n}\n\nexport function passthroughStyle(value) {\n return value;\n}\n\nexport function getResponsiveProp<T>(prop: Responsive<T>, matchedBreakpoints: Breakpoint[]): T | undefined {\n if (prop && typeof prop === 'object' && !Array.isArray(prop)) {\n for (let i = 0; i < matchedBreakpoints.length; i++) {\n let breakpoint = matchedBreakpoints[i];\n if (prop[breakpoint] != null) {\n return prop[breakpoint];\n }\n }\n return (prop as ResponsiveProp<T>).base;\n }\n return prop as T;\n}\n"],"names":[],"version":3,"file":"styleProps.module.js.map"}
package/dist/types.d.ts CHANGED
@@ -15,17 +15,17 @@ interface BreakpointProviderProps {
15
15
  }
16
16
  export function BreakpointProvider(props: BreakpointProviderProps): React.JSX.Element;
17
17
  export function useMatchedBreakpoints(breakpoints: Breakpoints): string[];
18
- export function useBreakpoint(): BreakpointContext;
18
+ export function useBreakpoint(): BreakpointContext | null;
19
19
  type Breakpoint = 'base' | 'S' | 'M' | 'L' | string;
20
20
  type StyleName = string | string[] | ((dir: Direction) => string);
21
- type StyleHandler = (value: any, colorVersion?: number) => string;
21
+ type StyleHandler = (value: any, colorVersion?: number) => string | undefined;
22
22
  export interface StyleHandlers {
23
23
  [key: string]: [StyleName, StyleHandler];
24
24
  }
25
25
  export const baseStyleProps: StyleHandlers;
26
26
  export const viewStyleProps: StyleHandlers;
27
- export function dimensionValue(value: DimensionValue): string;
28
- export function responsiveDimensionValue(value: Responsive<DimensionValue>, matchedBreakpoints: Breakpoint[]): string;
27
+ export function dimensionValue(value: DimensionValue): string | undefined;
28
+ export function responsiveDimensionValue(value: Responsive<DimensionValue>, matchedBreakpoints: Breakpoint[]): string | undefined;
29
29
  export function convertStyleProps<C extends ColorVersion>(props: ViewStyleProps<C>, handlers: StyleHandlers, direction: Direction, matchedBreakpoints: Breakpoint[]): CSSProperties;
30
30
  type StylePropsOptions = {
31
31
  matchedBreakpoints?: Breakpoint[];
@@ -34,7 +34,7 @@ export function useStyleProps<T extends StyleProps>(props: T, handlers?: StyleHa
34
34
  styleProps: HTMLAttributes<HTMLElement>;
35
35
  };
36
36
  export function passthroughStyle(value: any): any;
37
- export function getResponsiveProp<T>(prop: Responsive<T>, matchedBreakpoints: Breakpoint[]): T;
37
+ export function getResponsiveProp<T>(prop: Responsive<T>, matchedBreakpoints: Breakpoint[]): T | undefined;
38
38
  export let shouldKeepSpectrumClassNames: boolean;
39
39
  export function keepSpectrumClassNames(): void;
40
40
  export function classNames(cssModule: {
@@ -1 +1 @@
1
- {"mappings":";;AAGA;IACE,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CACrC;AAED;IACE,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAC7B;AAKD;IACE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAC7B;AAED,mCAAmC,KAAK,EAAE,uBAAuB,qBAWhE;AAED,sCAAsC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,CAAC,EAAE,MAAM,GAAG,CAAC,CAKjF;AAED,iCAAiC,SAAS,KAAA,MAKzC;AAED,6BAA6B,KAAK,KAAA,qBAmBjC;AAED,2BAA2B,KAAK,KAAA,qBAa/B;ACrDD,4BAA4B,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,WAM5E;ACND,qCAAqC,OAAO,CAO3C;ACSD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC","sources":["packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/BreakpointProvider.tsx","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/styleProps.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/classNames.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/getWrappedElement.tsx","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/useMediaQuery.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/useDOMRef.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/Slots.tsx","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/useHasChild.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/useIsMobileDevice.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/index.ts","packages/@react-spectrum/utils/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,"/*\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\n/// <reference types=\"css-module-types\" />\n\nexport type {StyleHandlers} from './styleProps';\nexport {shouldKeepSpectrumClassNames, keepSpectrumClassNames, classNames} from './classNames';\nexport {getWrappedElement} from './getWrappedElement';\nexport {useMediaQuery} from './useMediaQuery';\nexport {createDOMRef, createFocusableRef, useDOMRef, useFocusableRef, unwrapDOMRef, useUnwrapDOMRef} from './useDOMRef';\nexport {\n baseStyleProps,\n viewStyleProps,\n dimensionValue,\n responsiveDimensionValue,\n convertStyleProps,\n useStyleProps,\n passthroughStyle,\n getResponsiveProp\n} from './styleProps';\nexport {useSlotProps, cssModuleToSlots, SlotProvider, ClearSlots} from './Slots';\nexport {useHasChild} from './useHasChild';\nexport {useIsMobileDevice} from './useIsMobileDevice';\nexport {useValueEffect} from '@react-aria/utils';\nexport {BreakpointProvider, useMatchedBreakpoints, useBreakpoint} from './BreakpointProvider';\nexport {useResizeObserver} from '@react-aria/utils';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;AAGA;IACE,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CACrC;AAED;IACE,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAC7B;AAKD;IACE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAC7B;AAED,mCAAmC,KAAK,EAAE,uBAAuB,qBAWhE;AAED,sCAAsC,WAAW,EAAE,WAAW,GAAG,MAAM,EAAE,CAoDxE;AAED,0DAEC;AC1ED,kBAAkB,MAAM,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC;AACpD,iBAAiB,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,SAAS,KAAK,MAAM,CAAC,CAAC;AAClE,oBAAoB,CAAC,KAAK,EAAE,G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ACSD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC","sources":["packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/BreakpointProvider.tsx","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/styleProps.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/classNames.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/getWrappedElement.tsx","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/useMediaQuery.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/useDOMRef.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/Slots.tsx","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/useHasChild.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/useIsMobileDevice.ts","packages/@react-spectrum/utils/src/packages/@react-spectrum/utils/src/index.ts","packages/@react-spectrum/utils/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,"/*\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\n/// <reference types=\"css-module-types\" />\n\nexport type {StyleHandlers} from './styleProps';\nexport {shouldKeepSpectrumClassNames, keepSpectrumClassNames, classNames} from './classNames';\nexport {getWrappedElement} from './getWrappedElement';\nexport {useMediaQuery} from './useMediaQuery';\nexport {createDOMRef, createFocusableRef, useDOMRef, useFocusableRef, unwrapDOMRef, useUnwrapDOMRef} from './useDOMRef';\nexport {\n baseStyleProps,\n viewStyleProps,\n dimensionValue,\n responsiveDimensionValue,\n convertStyleProps,\n useStyleProps,\n passthroughStyle,\n getResponsiveProp\n} from './styleProps';\nexport {useSlotProps, cssModuleToSlots, SlotProvider, ClearSlots} from './Slots';\nexport {useHasChild} from './useHasChild';\nexport {useIsMobileDevice} from './useIsMobileDevice';\nexport {useValueEffect} from '@react-aria/utils';\nexport {BreakpointProvider, useMatchedBreakpoints, useBreakpoint} from './BreakpointProvider';\nexport {useResizeObserver} from '@react-aria/utils';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-spectrum/utils",
3
- "version": "3.11.10",
3
+ "version": "3.12.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -24,18 +24,18 @@
24
24
  "url": "https://github.com/adobe/react-spectrum"
25
25
  },
26
26
  "dependencies": {
27
- "@react-aria/i18n": "^3.12.2",
28
- "@react-aria/ssr": "^3.9.5",
29
- "@react-aria/utils": "^3.25.2",
30
- "@react-types/shared": "^3.24.1",
27
+ "@react-aria/i18n": "^3.12.4",
28
+ "@react-aria/ssr": "^3.9.7",
29
+ "@react-aria/utils": "^3.26.0",
30
+ "@react-types/shared": "^3.26.0",
31
31
  "@swc/helpers": "^0.5.0",
32
32
  "clsx": "^2.0.0"
33
33
  },
34
34
  "peerDependencies": {
35
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
35
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "faf0e18467231422cb7a06eb92a74d04e271f1e8"
40
+ "gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
41
41
  }
@@ -12,7 +12,7 @@ interface BreakpointContext {
12
12
  matchedBreakpoints: string[]
13
13
  }
14
14
 
15
- const Context = React.createContext<BreakpointContext>(null);
15
+ const Context = React.createContext<BreakpointContext | null>(null);
16
16
  Context.displayName = 'BreakpointContext';
17
17
 
18
18
  interface BreakpointProviderProps {
@@ -34,12 +34,12 @@ export function BreakpointProvider(props: BreakpointProviderProps) {
34
34
  }
35
35
 
36
36
  export function useMatchedBreakpoints(breakpoints: Breakpoints): string[] {
37
- let entries = Object.entries(breakpoints).sort(([, valueA], [, valueB]) => valueB - valueA);
37
+ let entries = Object.entries(breakpoints).sort(([, valueA], [, valueB]) => valueB! - valueA!);
38
38
  let breakpointQueries = entries.map(([, value]) => `(min-width: ${value}px)`);
39
39
 
40
40
  let supportsMatchMedia = typeof window !== 'undefined' && typeof window.matchMedia === 'function';
41
41
  let getBreakpointHandler = () => {
42
- let matched = [];
42
+ let matched: string[] = [];
43
43
  for (let i in breakpointQueries) {
44
44
  let query = breakpointQueries[i];
45
45
  if (window.matchMedia(query).matches) {
@@ -87,6 +87,6 @@ export function useMatchedBreakpoints(breakpoints: Breakpoints): string[] {
87
87
  return isSSR ? ['base'] : breakpoint;
88
88
  }
89
89
 
90
- export function useBreakpoint(): BreakpointContext {
90
+ export function useBreakpoint() {
91
91
  return useContext(Context);
92
92
  }
package/src/Slots.tsx CHANGED
@@ -17,10 +17,11 @@ interface SlotProps {
17
17
  slot?: string
18
18
  }
19
19
 
20
- let SlotContext = React.createContext(null);
20
+ let SlotContext = React.createContext<{} | null>(null);
21
21
 
22
22
  export function useSlotProps<T>(props: T & {id?: string}, defaultSlot?: string): T {
23
23
  let slot = (props as SlotProps).slot || defaultSlot;
24
+ // @ts-ignore TODO why is slot an object and not just string or undefined?
24
25
  let {[slot]: slotProps = {}} = useContext(SlotContext) || {};
25
26
 
26
27
  return mergeProps(props, mergeProps(slotProps, {id: props.id}));
package/src/classNames.ts CHANGED
@@ -24,7 +24,7 @@ export function keepSpectrumClassNames() {
24
24
  }
25
25
 
26
26
  export function classNames(cssModule: {[key: string]: string}, ...values: Array<string | Object | undefined>): string {
27
- let classes = [];
27
+ let classes: Array<{} | undefined> = [];
28
28
  for (let value of values) {
29
29
  if (typeof value === 'object' && value) {
30
30
  let mapped = {};
package/src/styleProps.ts CHANGED
@@ -17,7 +17,7 @@ import {useLocale} from '@react-aria/i18n';
17
17
 
18
18
  type Breakpoint = 'base' | 'S' | 'M' | 'L' | string;
19
19
  type StyleName = string | string[] | ((dir: Direction) => string);
20
- type StyleHandler = (value: any, colorVersion?: number) => string;
20
+ type StyleHandler = (value: any, colorVersion?: number) => string | undefined;
21
21
  export interface StyleHandlers {
22
22
  [key: string]: [StyleName, StyleHandler]
23
23
  }
@@ -144,8 +144,10 @@ export function dimensionValue(value: DimensionValue) {
144
144
  }
145
145
 
146
146
  export function responsiveDimensionValue(value: Responsive<DimensionValue>, matchedBreakpoints: Breakpoint[]) {
147
- value = getResponsiveProp(value, matchedBreakpoints);
148
- return dimensionValue(value);
147
+ let responsiveValue = getResponsiveProp(value, matchedBreakpoints);
148
+ if (responsiveValue != null) {
149
+ return dimensionValue(responsiveValue);
150
+ }
149
151
  }
150
152
 
151
153
  type ColorType = 'default' | 'background' | 'border' | 'icon' | 'status';
@@ -299,7 +301,7 @@ export function passthroughStyle(value) {
299
301
  return value;
300
302
  }
301
303
 
302
- export function getResponsiveProp<T>(prop: Responsive<T>, matchedBreakpoints: Breakpoint[]): T {
304
+ export function getResponsiveProp<T>(prop: Responsive<T>, matchedBreakpoints: Breakpoint[]): T | undefined {
303
305
  if (prop && typeof prop === 'object' && !Array.isArray(prop)) {
304
306
  for (let i = 0; i < matchedBreakpoints.length; i++) {
305
307
  let breakpoint = matchedBreakpoints[i];