@radix-ui/react-slot 1.2.4 → 1.2.5-rc.1780278106635
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.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +68 -50
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +68 -50
- package/dist/index.mjs.map +3 -3
- package/package.json +2 -4
package/dist/index.d.mts
CHANGED
|
@@ -10,9 +10,14 @@ interface SlotProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
10
10
|
}
|
|
11
11
|
declare function createSlot(ownerName: string): React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<HTMLElement>>;
|
|
12
12
|
declare const Slot: React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<HTMLElement>>;
|
|
13
|
-
|
|
13
|
+
type SlottableChildrenProps = {
|
|
14
14
|
children: React.ReactNode;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
|
+
type SlottableRenderFnProps = {
|
|
17
|
+
child: React.ReactNode;
|
|
18
|
+
children: (slottable: React.ReactNode) => React.ReactNode;
|
|
19
|
+
};
|
|
20
|
+
type SlottableProps = SlottableRenderFnProps | SlottableChildrenProps;
|
|
16
21
|
interface SlottableComponent extends React.FC<SlottableProps> {
|
|
17
22
|
__radixId: symbol;
|
|
18
23
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,9 +10,14 @@ interface SlotProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
10
10
|
}
|
|
11
11
|
declare function createSlot(ownerName: string): React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<HTMLElement>>;
|
|
12
12
|
declare const Slot: React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<HTMLElement>>;
|
|
13
|
-
|
|
13
|
+
type SlottableChildrenProps = {
|
|
14
14
|
children: React.ReactNode;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
|
+
type SlottableRenderFnProps = {
|
|
17
|
+
child: React.ReactNode;
|
|
18
|
+
children: (slottable: React.ReactNode) => React.ReactNode;
|
|
19
|
+
};
|
|
20
|
+
type SlottableProps = SlottableRenderFnProps | SlottableChildrenProps;
|
|
16
21
|
interface SlottableComponent extends React.FC<SlottableProps> {
|
|
17
22
|
__radixId: symbol;
|
|
18
23
|
}
|
package/dist/index.js
CHANGED
|
@@ -41,77 +41,78 @@ module.exports = __toCommonJS(index_exports);
|
|
|
41
41
|
// src/slot.tsx
|
|
42
42
|
var React = __toESM(require("react"));
|
|
43
43
|
var import_react_compose_refs = require("@radix-ui/react-compose-refs");
|
|
44
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
-
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
46
|
-
var use = React[" use ".trim().toString()];
|
|
47
|
-
function isPromiseLike(value) {
|
|
48
|
-
return typeof value === "object" && value !== null && "then" in value;
|
|
49
|
-
}
|
|
50
|
-
function isLazyComponent(element) {
|
|
51
|
-
return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
|
|
52
|
-
}
|
|
53
44
|
// @__NO_SIDE_EFFECTS__
|
|
54
45
|
function createSlot(ownerName) {
|
|
55
|
-
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
56
46
|
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
57
47
|
let { children, ...slotProps } = props;
|
|
48
|
+
let slottableElement = null;
|
|
49
|
+
let hasSlottable = false;
|
|
50
|
+
const newChildren = [];
|
|
58
51
|
if (isLazyComponent(children) && typeof use === "function") {
|
|
59
52
|
children = use(children._payload);
|
|
60
53
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (child ===
|
|
67
|
-
|
|
68
|
-
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
69
|
-
} else {
|
|
70
|
-
return child;
|
|
54
|
+
React.Children.forEach(children, (maybeSlottable) => {
|
|
55
|
+
if (isSlottable(maybeSlottable)) {
|
|
56
|
+
hasSlottable = true;
|
|
57
|
+
const slottable = maybeSlottable;
|
|
58
|
+
let child = "child" in slottable.props ? slottable.props.child : slottable.props.children;
|
|
59
|
+
if (isLazyComponent(child) && typeof use === "function") {
|
|
60
|
+
child = use(child._payload);
|
|
71
61
|
}
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
slottableElement = getSlottableElementFromSlottable(slottable, child);
|
|
63
|
+
newChildren.push(slottableElement?.props?.children);
|
|
64
|
+
} else {
|
|
65
|
+
newChildren.push(maybeSlottable);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
if (slottableElement) {
|
|
69
|
+
slottableElement = React.cloneElement(slottableElement, void 0, newChildren);
|
|
70
|
+
} else if (
|
|
71
|
+
// A `Slottable` was found but it didn't resolve to a single element (e.g.
|
|
72
|
+
// it wrapped multiple elements, text, or a render-prop `child` that
|
|
73
|
+
// wasn't an element). Don't fall back to treating the `Slottable` wrapper
|
|
74
|
+
// itself as the slot target — throw a descriptive error below instead.
|
|
75
|
+
!hasSlottable && React.Children.count(children) === 1 && React.isValidElement(children)
|
|
76
|
+
) {
|
|
77
|
+
slottableElement = children;
|
|
78
|
+
}
|
|
79
|
+
if (!slottableElement) {
|
|
80
|
+
if (children || children === 0) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
hasSlottable ? createSlottableError(ownerName) : createSlotError(ownerName)
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return children;
|
|
86
|
+
}
|
|
87
|
+
const slottableElementRef = getElementRef(slottableElement);
|
|
88
|
+
const composedRefs = (0, import_react_compose_refs.composeRefs)(forwardedRef, slottableElementRef);
|
|
89
|
+
const mergedProps = mergeProps(slotProps, slottableElement.props ?? {});
|
|
90
|
+
if (slottableElement.type !== React.Fragment) {
|
|
91
|
+
mergedProps.ref = forwardedRef ? composedRefs : slottableElementRef;
|
|
74
92
|
}
|
|
75
|
-
return
|
|
93
|
+
return React.cloneElement(slottableElement, mergedProps);
|
|
76
94
|
});
|
|
77
95
|
Slot2.displayName = `${ownerName}.Slot`;
|
|
78
96
|
return Slot2;
|
|
79
97
|
}
|
|
80
98
|
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
81
|
-
|
|
82
|
-
function createSlotClone(ownerName) {
|
|
83
|
-
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
84
|
-
let { children, ...slotProps } = props;
|
|
85
|
-
if (isLazyComponent(children) && typeof use === "function") {
|
|
86
|
-
children = use(children._payload);
|
|
87
|
-
}
|
|
88
|
-
if (React.isValidElement(children)) {
|
|
89
|
-
const childrenRef = getElementRef(children);
|
|
90
|
-
const props2 = mergeProps(slotProps, children.props);
|
|
91
|
-
if (children.type !== React.Fragment) {
|
|
92
|
-
props2.ref = forwardedRef ? (0, import_react_compose_refs.composeRefs)(forwardedRef, childrenRef) : childrenRef;
|
|
93
|
-
}
|
|
94
|
-
return React.cloneElement(children, props2);
|
|
95
|
-
}
|
|
96
|
-
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
97
|
-
});
|
|
98
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
99
|
-
return SlotClone;
|
|
100
|
-
}
|
|
101
|
-
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
99
|
+
var SLOTTABLE_IDENTIFIER = Symbol.for("radix.slottable");
|
|
102
100
|
// @__NO_SIDE_EFFECTS__
|
|
103
101
|
function createSlottable(ownerName) {
|
|
104
|
-
const Slottable2 = (
|
|
105
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
106
|
-
};
|
|
102
|
+
const Slottable2 = (props) => "child" in props ? props.children(props.child) : props.children;
|
|
107
103
|
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
108
104
|
Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
|
|
109
105
|
return Slottable2;
|
|
110
106
|
}
|
|
111
107
|
var Slottable = /* @__PURE__ */ createSlottable("Slottable");
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
var getSlottableElementFromSlottable = (slottable, child) => {
|
|
109
|
+
if ("child" in slottable.props) {
|
|
110
|
+
const child2 = slottable.props.child;
|
|
111
|
+
if (!React.isValidElement(child2)) return null;
|
|
112
|
+
return React.cloneElement(child2, void 0, slottable.props.children(child2.props.children));
|
|
113
|
+
}
|
|
114
|
+
return React.isValidElement(child) ? child : null;
|
|
115
|
+
};
|
|
115
116
|
function mergeProps(slotProps, childProps) {
|
|
116
117
|
const overrideProps = { ...childProps };
|
|
117
118
|
for (const propName in childProps) {
|
|
@@ -149,4 +150,21 @@ function getElementRef(element) {
|
|
|
149
150
|
}
|
|
150
151
|
return element.props.ref || element.ref;
|
|
151
152
|
}
|
|
153
|
+
function isSlottable(child) {
|
|
154
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
155
|
+
}
|
|
156
|
+
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
157
|
+
function isLazyComponent(element) {
|
|
158
|
+
return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
|
|
159
|
+
}
|
|
160
|
+
function isPromiseLike(value) {
|
|
161
|
+
return typeof value === "object" && value !== null && "then" in value;
|
|
162
|
+
}
|
|
163
|
+
var createSlotError = (ownerName) => {
|
|
164
|
+
return `${ownerName} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`;
|
|
165
|
+
};
|
|
166
|
+
var createSlottableError = (ownerName) => {
|
|
167
|
+
return `${ownerName} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`;
|
|
168
|
+
};
|
|
169
|
+
var use = React[" use ".trim().toString()];
|
|
152
170
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/slot.tsx"],
|
|
4
|
-
"sourcesContent": ["export {\n Slot,\n Slottable,\n //\n Root,\n createSlot,\n createSlottable,\n} from './slot';\nexport type { SlotProps } from './slot';\n", "import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\ndeclare module 'react' {\n interface ReactElement {\n $$typeof?: symbol | string;\n }\n}\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,gCAA4B;
|
|
6
|
-
"names": ["Slot", "
|
|
4
|
+
"sourcesContent": ["export {\n Slot,\n Slottable,\n //\n Root,\n createSlot,\n createSlottable,\n} from './slot';\nexport type { SlotProps } from './slot';\n", "import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\ndeclare module 'react' {\n interface ReactElement {\n $$typeof?: symbol | string;\n }\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type Usable<T> = PromiseLike<T> | React.Context<T>;\n\ninterface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlot(ownerName: string) {\n const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n let { children, ...slotProps } = props;\n let slottableElement: React.ReactElement | null = null;\n let hasSlottable = false;\n const newChildren: React.ReactNode[] = [];\n\n if (isLazyComponent(children) && typeof use === 'function') {\n children = use(children._payload);\n }\n\n React.Children.forEach(children, (maybeSlottable) => {\n if (isSlottable(maybeSlottable)) {\n hasSlottable = true;\n const slottable = maybeSlottable;\n let child = 'child' in slottable.props ? slottable.props.child : slottable.props.children;\n\n if (isLazyComponent(child) && typeof use === 'function') {\n child = use(child._payload);\n }\n\n slottableElement = getSlottableElementFromSlottable(slottable, child);\n newChildren.push((slottableElement?.props as any)?.children);\n } else {\n newChildren.push(maybeSlottable);\n }\n });\n\n if (slottableElement) {\n slottableElement = React.cloneElement(slottableElement, undefined, newChildren);\n } else if (\n // A `Slottable` was found but it didn't resolve to a single element (e.g.\n // it wrapped multiple elements, text, or a render-prop `child` that\n // wasn't an element). Don't fall back to treating the `Slottable` wrapper\n // itself as the slot target \u2014 throw a descriptive error below instead.\n !hasSlottable &&\n React.Children.count(children) === 1 &&\n React.isValidElement(children)\n ) {\n slottableElement = children;\n }\n\n if (!slottableElement) {\n // Empty/falsy children (`null`, `undefined`, `false`, no children, etc.) are valid and\n // render nothing. Anything else is content we couldn't slot onto a single element, which\n // is a usage error, so we fail loudly with a clear message.\n if (children || children === 0) {\n throw new Error(\n hasSlottable ? createSlottableError(ownerName) : createSlotError(ownerName),\n );\n }\n return children;\n }\n\n const slottableElementRef = getElementRef(slottableElement);\n const composedRefs = composeRefs(forwardedRef, slottableElementRef);\n const mergedProps = mergeProps(slotProps, slottableElement.props ?? {});\n\n // do not pass ref to React.Fragment for React 19 compatibility\n if (slottableElement.type !== React.Fragment) {\n mergedProps.ref = forwardedRef ? composedRefs : slottableElementRef;\n }\n\n return React.cloneElement(slottableElement, mergedProps);\n });\n\n Slot.displayName = `${ownerName}.Slot`;\n return Slot;\n}\n\nconst Slot = createSlot('Slot');\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst SLOTTABLE_IDENTIFIER = Symbol.for('radix.slottable');\n\ntype SlottableChildrenProps = { children: React.ReactNode };\ntype SlottableRenderFnProps = {\n child: React.ReactNode;\n children: (slottable: React.ReactNode) => React.ReactNode;\n};\n\ntype SlottableProps = SlottableRenderFnProps | SlottableChildrenProps;\ninterface SlottableComponent extends React.FC<SlottableProps> {\n __radixId: symbol;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlottable(ownerName: string) {\n const Slottable: SlottableComponent = (props) =>\n 'child' in props ? props.children(props.child) : props.children;\n\n Slottable.displayName = `${ownerName}.Slottable`;\n Slottable.__radixId = SLOTTABLE_IDENTIFIER;\n return Slottable;\n}\n\nconst Slottable = createSlottable('Slottable');\n\n/* -------------------------------------------------------------------------------------------------\n * getSlottableElementFromSlottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst getSlottableElementFromSlottable = (slottable: SlottableElement, child: React.ReactNode) => {\n if ('child' in slottable.props) {\n const child = slottable.props.child;\n if (!React.isValidElement<React.PropsWithChildren>(child)) return null;\n return React.cloneElement(child, undefined, slottable.props.children(child.props.children));\n }\n\n return React.isValidElement(child) ? child : null;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * mergeProps\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 for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n // if the handler exists on both, we compose them\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args: unknown[]) => {\n const result = childPropValue(...args);\n slotPropValue(...args);\n return result;\n };\n }\n // but if it exists only on the slot, we use only this one\n else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\n/* -------------------------------------------------------------------------------------------------\n * getElementRef\n * -----------------------------------------------------------------------------------------------*/\n\n// Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`\n// After React 19 accessing `element.ref` does the opposite.\n// https://github.com/facebook/react/pull/28348\n//\n// Access the ref using the method that doesn't yield a warning.\nfunction getElementRef(element: React.ReactElement) {\n // React <=18 in DEV\n let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get;\n let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element as any).ref;\n }\n\n // React 19 in DEV\n getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;\n mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element.props as { ref?: React.Ref<unknown> }).ref;\n }\n\n // Not DEV\n return (element.props as { ref?: React.Ref<unknown> }).ref || (element as any).ref;\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype SlottableElement = React.ReactElement<SlottableProps, SlottableComponent>;\n\nfunction isSlottable(\n child: React.ReactNode,\n): child is React.ReactElement<SlottableProps, typeof Slottable> {\n return (\n React.isValidElement(child) &&\n typeof child.type === 'function' &&\n '__radixId' in child.type &&\n child.type.__radixId === SLOTTABLE_IDENTIFIER\n );\n}\n\nconst REACT_LAZY_TYPE = Symbol.for('react.lazy');\n\ninterface LazyReactElement extends React.ReactElement {\n $$typeof: typeof REACT_LAZY_TYPE;\n _payload: PromiseLike<Exclude<React.ReactNode, PromiseLike<any>>>;\n}\n\nfunction isLazyComponent(element: React.ReactNode): element is LazyReactElement {\n return (\n element != null &&\n typeof element === 'object' &&\n '$$typeof' in element &&\n element.$$typeof === REACT_LAZY_TYPE &&\n '_payload' in element &&\n isPromiseLike(element._payload)\n );\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return typeof value === 'object' && value !== null && 'then' in value;\n}\n\nconst createSlotError = (ownerName: string) => {\n return `${ownerName} failed to slot onto its children. Expected a single React element child or \\`Slottable\\`.`;\n};\n\nconst createSlottableError = (ownerName: string) => {\n return `${ownerName} failed to slot onto its \\`Slottable\\`. Expected \\`Slottable\\` to receive a single React element child.`;\n};\n\nconst use: typeof React.use | undefined = (React as any)[' use '.trim().toString()];\n\nexport {\n Slot,\n Slottable,\n //\n Slot as Root,\n};\nexport type {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AuB,CAAC,cAAsB;AAClD,SAAO,GAAG,SAAS;AACrB;AAEA,IAAM,MAAqC,MAAc,QAAQ,KAAK,EAAE,SAAS,CAAC;",
|
|
6
|
+
"names": ["Slot", "Slottable", "child"]
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,77 +1,78 @@
|
|
|
1
1
|
// src/slot.tsx
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
4
|
-
import { Fragment as Fragment2, jsx } from "react/jsx-runtime";
|
|
5
|
-
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
6
|
-
var use = React[" use ".trim().toString()];
|
|
7
|
-
function isPromiseLike(value) {
|
|
8
|
-
return typeof value === "object" && value !== null && "then" in value;
|
|
9
|
-
}
|
|
10
|
-
function isLazyComponent(element) {
|
|
11
|
-
return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
|
|
12
|
-
}
|
|
13
4
|
// @__NO_SIDE_EFFECTS__
|
|
14
5
|
function createSlot(ownerName) {
|
|
15
|
-
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
16
6
|
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
17
7
|
let { children, ...slotProps } = props;
|
|
8
|
+
let slottableElement = null;
|
|
9
|
+
let hasSlottable = false;
|
|
10
|
+
const newChildren = [];
|
|
18
11
|
if (isLazyComponent(children) && typeof use === "function") {
|
|
19
12
|
children = use(children._payload);
|
|
20
13
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (child ===
|
|
27
|
-
|
|
28
|
-
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
29
|
-
} else {
|
|
30
|
-
return child;
|
|
14
|
+
React.Children.forEach(children, (maybeSlottable) => {
|
|
15
|
+
if (isSlottable(maybeSlottable)) {
|
|
16
|
+
hasSlottable = true;
|
|
17
|
+
const slottable = maybeSlottable;
|
|
18
|
+
let child = "child" in slottable.props ? slottable.props.child : slottable.props.children;
|
|
19
|
+
if (isLazyComponent(child) && typeof use === "function") {
|
|
20
|
+
child = use(child._payload);
|
|
31
21
|
}
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
slottableElement = getSlottableElementFromSlottable(slottable, child);
|
|
23
|
+
newChildren.push(slottableElement?.props?.children);
|
|
24
|
+
} else {
|
|
25
|
+
newChildren.push(maybeSlottable);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
if (slottableElement) {
|
|
29
|
+
slottableElement = React.cloneElement(slottableElement, void 0, newChildren);
|
|
30
|
+
} else if (
|
|
31
|
+
// A `Slottable` was found but it didn't resolve to a single element (e.g.
|
|
32
|
+
// it wrapped multiple elements, text, or a render-prop `child` that
|
|
33
|
+
// wasn't an element). Don't fall back to treating the `Slottable` wrapper
|
|
34
|
+
// itself as the slot target — throw a descriptive error below instead.
|
|
35
|
+
!hasSlottable && React.Children.count(children) === 1 && React.isValidElement(children)
|
|
36
|
+
) {
|
|
37
|
+
slottableElement = children;
|
|
38
|
+
}
|
|
39
|
+
if (!slottableElement) {
|
|
40
|
+
if (children || children === 0) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
hasSlottable ? createSlottableError(ownerName) : createSlotError(ownerName)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return children;
|
|
46
|
+
}
|
|
47
|
+
const slottableElementRef = getElementRef(slottableElement);
|
|
48
|
+
const composedRefs = composeRefs(forwardedRef, slottableElementRef);
|
|
49
|
+
const mergedProps = mergeProps(slotProps, slottableElement.props ?? {});
|
|
50
|
+
if (slottableElement.type !== React.Fragment) {
|
|
51
|
+
mergedProps.ref = forwardedRef ? composedRefs : slottableElementRef;
|
|
34
52
|
}
|
|
35
|
-
return
|
|
53
|
+
return React.cloneElement(slottableElement, mergedProps);
|
|
36
54
|
});
|
|
37
55
|
Slot2.displayName = `${ownerName}.Slot`;
|
|
38
56
|
return Slot2;
|
|
39
57
|
}
|
|
40
58
|
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
41
|
-
|
|
42
|
-
function createSlotClone(ownerName) {
|
|
43
|
-
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
44
|
-
let { children, ...slotProps } = props;
|
|
45
|
-
if (isLazyComponent(children) && typeof use === "function") {
|
|
46
|
-
children = use(children._payload);
|
|
47
|
-
}
|
|
48
|
-
if (React.isValidElement(children)) {
|
|
49
|
-
const childrenRef = getElementRef(children);
|
|
50
|
-
const props2 = mergeProps(slotProps, children.props);
|
|
51
|
-
if (children.type !== React.Fragment) {
|
|
52
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
53
|
-
}
|
|
54
|
-
return React.cloneElement(children, props2);
|
|
55
|
-
}
|
|
56
|
-
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
57
|
-
});
|
|
58
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
59
|
-
return SlotClone;
|
|
60
|
-
}
|
|
61
|
-
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
59
|
+
var SLOTTABLE_IDENTIFIER = Symbol.for("radix.slottable");
|
|
62
60
|
// @__NO_SIDE_EFFECTS__
|
|
63
61
|
function createSlottable(ownerName) {
|
|
64
|
-
const Slottable2 = (
|
|
65
|
-
return /* @__PURE__ */ jsx(Fragment2, { children });
|
|
66
|
-
};
|
|
62
|
+
const Slottable2 = (props) => "child" in props ? props.children(props.child) : props.children;
|
|
67
63
|
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
68
64
|
Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
|
|
69
65
|
return Slottable2;
|
|
70
66
|
}
|
|
71
67
|
var Slottable = /* @__PURE__ */ createSlottable("Slottable");
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
var getSlottableElementFromSlottable = (slottable, child) => {
|
|
69
|
+
if ("child" in slottable.props) {
|
|
70
|
+
const child2 = slottable.props.child;
|
|
71
|
+
if (!React.isValidElement(child2)) return null;
|
|
72
|
+
return React.cloneElement(child2, void 0, slottable.props.children(child2.props.children));
|
|
73
|
+
}
|
|
74
|
+
return React.isValidElement(child) ? child : null;
|
|
75
|
+
};
|
|
75
76
|
function mergeProps(slotProps, childProps) {
|
|
76
77
|
const overrideProps = { ...childProps };
|
|
77
78
|
for (const propName in childProps) {
|
|
@@ -109,6 +110,23 @@ function getElementRef(element) {
|
|
|
109
110
|
}
|
|
110
111
|
return element.props.ref || element.ref;
|
|
111
112
|
}
|
|
113
|
+
function isSlottable(child) {
|
|
114
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
115
|
+
}
|
|
116
|
+
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
117
|
+
function isLazyComponent(element) {
|
|
118
|
+
return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
|
|
119
|
+
}
|
|
120
|
+
function isPromiseLike(value) {
|
|
121
|
+
return typeof value === "object" && value !== null && "then" in value;
|
|
122
|
+
}
|
|
123
|
+
var createSlotError = (ownerName) => {
|
|
124
|
+
return `${ownerName} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`;
|
|
125
|
+
};
|
|
126
|
+
var createSlottableError = (ownerName) => {
|
|
127
|
+
return `${ownerName} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`;
|
|
128
|
+
};
|
|
129
|
+
var use = React[" use ".trim().toString()];
|
|
112
130
|
export {
|
|
113
131
|
Slot as Root,
|
|
114
132
|
Slot,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/slot.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\ndeclare module 'react' {\n interface ReactElement {\n $$typeof?: symbol | string;\n }\n}\n\
|
|
5
|
-
"mappings": ";AAAA,YAAY,WAAW;AACvB,SAAS,mBAAmB;
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\ndeclare module 'react' {\n interface ReactElement {\n $$typeof?: symbol | string;\n }\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type Usable<T> = PromiseLike<T> | React.Context<T>;\n\ninterface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlot(ownerName: string) {\n const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n let { children, ...slotProps } = props;\n let slottableElement: React.ReactElement | null = null;\n let hasSlottable = false;\n const newChildren: React.ReactNode[] = [];\n\n if (isLazyComponent(children) && typeof use === 'function') {\n children = use(children._payload);\n }\n\n React.Children.forEach(children, (maybeSlottable) => {\n if (isSlottable(maybeSlottable)) {\n hasSlottable = true;\n const slottable = maybeSlottable;\n let child = 'child' in slottable.props ? slottable.props.child : slottable.props.children;\n\n if (isLazyComponent(child) && typeof use === 'function') {\n child = use(child._payload);\n }\n\n slottableElement = getSlottableElementFromSlottable(slottable, child);\n newChildren.push((slottableElement?.props as any)?.children);\n } else {\n newChildren.push(maybeSlottable);\n }\n });\n\n if (slottableElement) {\n slottableElement = React.cloneElement(slottableElement, undefined, newChildren);\n } else if (\n // A `Slottable` was found but it didn't resolve to a single element (e.g.\n // it wrapped multiple elements, text, or a render-prop `child` that\n // wasn't an element). Don't fall back to treating the `Slottable` wrapper\n // itself as the slot target \u2014 throw a descriptive error below instead.\n !hasSlottable &&\n React.Children.count(children) === 1 &&\n React.isValidElement(children)\n ) {\n slottableElement = children;\n }\n\n if (!slottableElement) {\n // Empty/falsy children (`null`, `undefined`, `false`, no children, etc.) are valid and\n // render nothing. Anything else is content we couldn't slot onto a single element, which\n // is a usage error, so we fail loudly with a clear message.\n if (children || children === 0) {\n throw new Error(\n hasSlottable ? createSlottableError(ownerName) : createSlotError(ownerName),\n );\n }\n return children;\n }\n\n const slottableElementRef = getElementRef(slottableElement);\n const composedRefs = composeRefs(forwardedRef, slottableElementRef);\n const mergedProps = mergeProps(slotProps, slottableElement.props ?? {});\n\n // do not pass ref to React.Fragment for React 19 compatibility\n if (slottableElement.type !== React.Fragment) {\n mergedProps.ref = forwardedRef ? composedRefs : slottableElementRef;\n }\n\n return React.cloneElement(slottableElement, mergedProps);\n });\n\n Slot.displayName = `${ownerName}.Slot`;\n return Slot;\n}\n\nconst Slot = createSlot('Slot');\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst SLOTTABLE_IDENTIFIER = Symbol.for('radix.slottable');\n\ntype SlottableChildrenProps = { children: React.ReactNode };\ntype SlottableRenderFnProps = {\n child: React.ReactNode;\n children: (slottable: React.ReactNode) => React.ReactNode;\n};\n\ntype SlottableProps = SlottableRenderFnProps | SlottableChildrenProps;\ninterface SlottableComponent extends React.FC<SlottableProps> {\n __radixId: symbol;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlottable(ownerName: string) {\n const Slottable: SlottableComponent = (props) =>\n 'child' in props ? props.children(props.child) : props.children;\n\n Slottable.displayName = `${ownerName}.Slottable`;\n Slottable.__radixId = SLOTTABLE_IDENTIFIER;\n return Slottable;\n}\n\nconst Slottable = createSlottable('Slottable');\n\n/* -------------------------------------------------------------------------------------------------\n * getSlottableElementFromSlottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst getSlottableElementFromSlottable = (slottable: SlottableElement, child: React.ReactNode) => {\n if ('child' in slottable.props) {\n const child = slottable.props.child;\n if (!React.isValidElement<React.PropsWithChildren>(child)) return null;\n return React.cloneElement(child, undefined, slottable.props.children(child.props.children));\n }\n\n return React.isValidElement(child) ? child : null;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * mergeProps\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 for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n // if the handler exists on both, we compose them\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args: unknown[]) => {\n const result = childPropValue(...args);\n slotPropValue(...args);\n return result;\n };\n }\n // but if it exists only on the slot, we use only this one\n else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\n/* -------------------------------------------------------------------------------------------------\n * getElementRef\n * -----------------------------------------------------------------------------------------------*/\n\n// Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`\n// After React 19 accessing `element.ref` does the opposite.\n// https://github.com/facebook/react/pull/28348\n//\n// Access the ref using the method that doesn't yield a warning.\nfunction getElementRef(element: React.ReactElement) {\n // React <=18 in DEV\n let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get;\n let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element as any).ref;\n }\n\n // React 19 in DEV\n getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;\n mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element.props as { ref?: React.Ref<unknown> }).ref;\n }\n\n // Not DEV\n return (element.props as { ref?: React.Ref<unknown> }).ref || (element as any).ref;\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype SlottableElement = React.ReactElement<SlottableProps, SlottableComponent>;\n\nfunction isSlottable(\n child: React.ReactNode,\n): child is React.ReactElement<SlottableProps, typeof Slottable> {\n return (\n React.isValidElement(child) &&\n typeof child.type === 'function' &&\n '__radixId' in child.type &&\n child.type.__radixId === SLOTTABLE_IDENTIFIER\n );\n}\n\nconst REACT_LAZY_TYPE = Symbol.for('react.lazy');\n\ninterface LazyReactElement extends React.ReactElement {\n $$typeof: typeof REACT_LAZY_TYPE;\n _payload: PromiseLike<Exclude<React.ReactNode, PromiseLike<any>>>;\n}\n\nfunction isLazyComponent(element: React.ReactNode): element is LazyReactElement {\n return (\n element != null &&\n typeof element === 'object' &&\n '$$typeof' in element &&\n element.$$typeof === REACT_LAZY_TYPE &&\n '_payload' in element &&\n isPromiseLike(element._payload)\n );\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return typeof value === 'object' && value !== null && 'then' in value;\n}\n\nconst createSlotError = (ownerName: string) => {\n return `${ownerName} failed to slot onto its children. Expected a single React element child or \\`Slottable\\`.`;\n};\n\nconst createSlottableError = (ownerName: string) => {\n return `${ownerName} failed to slot onto its \\`Slottable\\`. Expected \\`Slottable\\` to receive a single React element child.`;\n};\n\nconst use: typeof React.use | undefined = (React as any)[' use '.trim().toString()];\n\nexport {\n Slot,\n Slottable,\n //\n Slot as Root,\n};\nexport type { SlotProps };\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAY,WAAW;AACvB,SAAS,mBAAmB;AAAA;AAkBM,SAAS,WAAW,WAAmB;AACvE,QAAMA,QAAa,iBAAmC,CAAC,OAAO,iBAAiB;AAC7E,QAAI,EAAE,UAAU,GAAG,UAAU,IAAI;AACjC,QAAI,mBAA8C;AAClD,QAAI,eAAe;AACnB,UAAM,cAAiC,CAAC;AAExC,QAAI,gBAAgB,QAAQ,KAAK,OAAO,QAAQ,YAAY;AAC1D,iBAAW,IAAI,SAAS,QAAQ;AAAA,IA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SAAS,OAAO,yBAAyB,QAAQ,OAAO,KAAK,GAAG;AACpE,MAAI,UAAU,UAAU,oBAAoB,UAAU,OAAO;AAC7D,MAAI,SAAS;AACX,WAAQ,QAAgB;AAAA,EAC1B;AAGA,WAAS,OAAO,yBAAyB,SAAS,KAAK,GAAG;AAC1D,YAAU,UAAU,oBAAoB,UAAU,OAAO;AACzD,MAAI,SAAS;AACX,WAAQ,QAAQ,MAAuC;AAAA,EACzD;AAGA,SAAQ,QAAQ,MAAuC,OAAQ,QAAgB;AACjF;AAMA,SAAS,YACP,OAC+D;AAC/D,SACQ,qBAAe,KAAK,KAC1B,OAAO,MAAM,SAAS,cACtB,eAAe,MAAM,QACrB,MAAM,KAAK,cAAc;AAE7B;AAEA,IAAM,kBAAkB,OAAO,IAAI,YAAY;AAO/C,SAAS,gBAAgB,SAAuD;AAC9E,SACE,WAAW,QACX,OAAO,YAAY,YACnB,cAAc,WACd,QAAQ,aAAa,mBACrB,cAAc,WACd,cAAc,QAAQ,QAAQ;AAElC;AAEA,SAAS,cAAc,OAA+C;AACpE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AAClE;AAEA,IAAM,kBAAkB,CAAC,cAAsB;AAC7C,SAAO,GAAG,SAAS;AACrB;AAEA,IAAM,uBAAuB,CAAC,cAAsB;AAClD,SAAO,GAAG,SAAS;AACrB;AAEA,IAAM,MAAqC,MAAc,QAAQ,KAAK,EAAE,SAAS,CAAC;",
|
|
6
|
+
"names": ["Slot", "Slottable", "child"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-slot",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5-rc.1780278106635",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,11 +16,9 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@types/react": "^19.2.2",
|
|
18
18
|
"@types/react-dom": "^19.2.2",
|
|
19
|
-
"eslint": "^9.38.0",
|
|
20
19
|
"react": "^19.2.0",
|
|
21
20
|
"react-dom": "^19.2.0",
|
|
22
21
|
"typescript": "^5.9.3",
|
|
23
|
-
"@repo/eslint-config": "0.0.0",
|
|
24
22
|
"@repo/typescript-config": "0.0.0",
|
|
25
23
|
"@repo/builder": "0.0.0"
|
|
26
24
|
},
|
|
@@ -42,7 +40,7 @@
|
|
|
42
40
|
"url": "https://github.com/radix-ui/primitives/issues"
|
|
43
41
|
},
|
|
44
42
|
"scripts": {
|
|
45
|
-
"lint": "
|
|
43
|
+
"lint": "oxlint --max-warnings 0 src",
|
|
46
44
|
"clean": "rm -rf dist",
|
|
47
45
|
"reset": "rm -rf dist node_modules",
|
|
48
46
|
"typecheck": "tsc --noEmit",
|