@radix-ui/react-slot 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.module.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import * as React from "react";
|
|
|
2
2
|
type SlotProps = {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
};
|
|
5
|
-
export const Slot: React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<
|
|
5
|
+
export const Slot: React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<HTMLElement>>;
|
|
6
6
|
export const Slottable: ({ children }: {
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
}) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>;
|
|
9
|
-
export const Root: React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<
|
|
9
|
+
export const Root: React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<HTMLElement>>;
|
|
10
10
|
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"A;AAQA,iBAAiB;IAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;CAAE,CAAC;AAE/C,OAAA,MAAM,
|
|
1
|
+
{"mappings":"A;AAQA,iBAAiB;IAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;CAAE,CAAC;AAE/C,OAAA,MAAM,mFA2BJ,CAAC;AA4BH,OAAA,MAAM;cAAuC,MAAM,SAAS;oJAE3D,CAAC;AAwBF,OAAA,MAAM,mFAAW,CAAC","sources":["./packages/react/slot/src/packages/react/slot/src/Slot.tsx","./packages/react/slot/src/packages/react/slot/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"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IACrBQ,EAAWlB,EAAWU,EAAMb,OAC/BU,IAAKY,EAAYrB,EAAeY,EAAcH,OAEhD,QAGNQ,EAAUD,YAAc,YAMxB,MAAMD,EAAY,EAAGd,SAAAA,KACZA,EAOT,SAASmB,EAAWlB,EAAqBoB,GAEvC,MAAMC,EAAgB,IAAKD,GAG3B,IAAK,MAAME,KAAYF,EAAY,CACjC,MAAMG,EAAgBvB,EAAUsB,GAC1BE,EAAiBJ,EAAWE,GAChB,WAAWG,KAAKH,KAGhCD,EAAcC,GAAYI,EAAqBF,EAAgBD,IAInE,MAAO,IAAKvB,KAAcqB,uBAG5B,MAAMM,EAAOjC","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/slot/src/Slot.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\ntype SlotProps = { children: React.ReactNode };\n\nconst Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const childLength = React.Children.count(children);\n\n if (childLength === 1) {\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n );\n }\n\n return (\n <>\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.type === Slottable) {\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {child.props.children}\n </SlotClone>\n );\n }\n\n return child;\n })}\n </>\n );\n});\n\nSlot.displayName = 'Slot';\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ntype SlotCloneProps = { children: React.ReactNode };\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const child = React.Children.only(children);\n\n return React.isValidElement(child)\n ? React.cloneElement(child, {\n ...mergeProps(slotProps, child.props),\n ref: composeRefs(forwardedRef, (child as any).ref),\n })\n : null;\n});\n\nSlotClone.displayName = 'SlotClone';\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst Slottable = ({ children }: { children: React.ReactNode }) => {\n return children as React.ReactElement;\n};\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>;\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n // all child props should override\n const overrideProps = { ...childProps };\n\n // if it's a handler, modify the override by composing the base handler\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n const isHandler = /^on[A-Z]/.test(propName);\n\n if (isHandler) {\n overrideProps[propName] = composeEventHandlers(childPropValue, slotPropValue);\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\nconst Root = Slot;\n\nexport {\n Slot,\n Slottable,\n //\n Root,\n};\n"],"names":["dest","source","a","Object","keys","forEach","key","defineProperty","enumerable","get","__esModule","default","Slot","React","forwardRef","props","forwardedRef","children","slotProps","Children","count","_react","createElement","$bd3c7a2329cce5affa12c89d44fd473$var$SlotClone","_babelRuntimeHelpersExtends","ref","Fragment","map","child","isValidElement","type","Slottable","displayName","SlotClone","only","cloneElement","mergeProps","composeRefs","childProps","overrideProps","propName","slotPropValue","childPropValue","test","composeEventHandlers","Root"],"version":3,"file":"index.js.map"}
|
package/dist/index.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"uMAUA,MAAMA,kBAAOC,EAAMC,
|
|
1
|
+
{"mappings":"uMAUA,MAAMA,kBAAOC,EAAMC,YAAmC,CAACC,EAAOC,KAC5D,MAAMC,SAAEA,KAAaC,GAAcH,EAGnC,OAAoB,IAFAF,EAAMM,SAASC,MAAMH,gBAIrCI,EAAAC,cAACC,EAADC,EAAA,GAAeN,EAAf,CAA0BO,IAAKT,IAC5BC,gBAMLI,EAAAC,cAAAD,EAAAK,SAAA,KACGb,EAAMM,SAASQ,IAAIV,GAAWW,gBACzBf,EAAMgB,eAAeD,IAAUA,EAAME,OAASC,uBAE9CV,EAAAC,cAACC,EAADC,EAAA,GAAeN,EAAf,CAA0BO,IAAKT,IAC5BY,EAAMb,MAAME,UAKZW,QAMfhB,KAAKoB,YAAc,OAQnB,MAAMC,eAAYpB,EAAMC,YAAgC,CAACC,EAAOC,KAC9D,MAAMC,SAAEA,KAAaC,GAAcH,EAC7Ba,EAAQf,EAAMM,SAASe,KAAKjB,gBAElC,OAAOJ,EAAMgB,eAAeD,gBACxBf,EAAMsB,aAAaP,EAAO,IACrBQ,EAAWlB,EAAWU,EAAMb,OAC/BU,IAAKY,EAAYrB,EAAeY,EAAcH,OAEhD,QAGNQ,EAAUD,YAAc,mBAMxB,MAAMD,UAAY,EAAGd,SAAAA,KACZA,EAOT,SAASmB,EAAWlB,EAAqBoB,GAEvC,MAAMC,EAAgB,IAAKD,GAG3B,IAAK,MAAME,KAAYF,EAAY,CACjC,MAAMG,EAAgBvB,EAAUsB,GAC1BE,EAAiBJ,EAAWE,GAChB,WAAWG,KAAKH,KAGhCD,EAAcC,GAAYI,EAAqBF,EAAgBD,IAInE,MAAO,IAAKvB,KAAcqB,UAG5B,MAAMM,KAAOjC","sources":["./packages/react/slot/src/Slot.tsx"],"sourcesContent":["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\ntype SlotProps = { children: React.ReactNode };\n\nconst Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const childLength = React.Children.count(children);\n\n if (childLength === 1) {\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n );\n }\n\n return (\n <>\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.type === Slottable) {\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {child.props.children}\n </SlotClone>\n );\n }\n\n return child;\n })}\n </>\n );\n});\n\nSlot.displayName = 'Slot';\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ntype SlotCloneProps = { children: React.ReactNode };\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const child = React.Children.only(children);\n\n return React.isValidElement(child)\n ? React.cloneElement(child, {\n ...mergeProps(slotProps, child.props),\n ref: composeRefs(forwardedRef, (child as any).ref),\n })\n : null;\n});\n\nSlotClone.displayName = 'SlotClone';\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst Slottable = ({ children }: { children: React.ReactNode }) => {\n return children as React.ReactElement;\n};\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>;\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n // all child props should override\n const overrideProps = { ...childProps };\n\n // if it's a handler, modify the override by composing the base handler\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n const isHandler = /^on[A-Z]/.test(propName);\n\n if (isHandler) {\n overrideProps[propName] = composeEventHandlers(childPropValue, slotPropValue);\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\nconst Root = Slot;\n\nexport {\n Slot,\n Slottable,\n //\n Root,\n};\n"],"names":["Slot","React","forwardRef","props","forwardedRef","children","slotProps","Children","count","_react","createElement","$d34e8c328cb3dd19ab7a2f6eafa6ad$var$SlotClone","_babelRuntimeHelpersEsmExtends","ref","Fragment","map","child","isValidElement","type","Slottable","displayName","SlotClone","only","cloneElement","mergeProps","composeRefs","childProps","overrideProps","propName","slotPropValue","childPropValue","test","composeEventHandlers","Root"],"version":3,"file":"index.module.js.map"}
|