Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@bento/box

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bento/box - npm Package Compare versions

Comparing version
0.2.0
to
0.2.1
+1
dist/index.d.cts.map
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;KAEY,QAAA,GAAW,UAAA,GAAa,QAAA,GAAW,IAAA;AAAA,UAE9B,UAAA;EAFL;;;;;;EASV,UAAA,EAAY,MAAA,SAAe,KAAA,CAAM,aAAA,CAAc,KAAA;IAAW,KAAA,EAAO,MAAA;EAAA;EAT/B;;;EAclC,MAAA,QAAc,MAAA,UAAgB,UAAA;EAZf;;;EAiBf,QAAA,QAAgB,QAAA;EAVW;;;EAe3B,MAAA;EAAA,CAEC,GAAA;AAAA;AAAA,UAGc,YAAA;EAVS;;;EAcxB,QAAA,EAAU,MAAA;EAxBiB;;;EA6B3B,SAAA;EA7BiE;;;EAkCjE,QAAA;AAAA;AAAA,UAGe,UAAA;EAtBf;;;EA0BA,GAAA,EAAK,UAAA,CAAW,KAAA;EArBD;;;EA0Bf,KAAA,EAAO,YAAA;AAAA;;;;;;AATT;;iBAmBgB,QAAA,CAAS,IAAA,GAAO,QAAA,GAAW,UAAA;;;;;;cAiD9B,GAAA,EAAG,KAAA,CAAA,OAAA,CAAA,UAAA;;;;;;UAOC,SAAA;EAlEI;AAUrB;;;EA6DE,KAAA,EAAO,MAAA;EA7DuB;;;EAkE9B,QAAA,EAAU,KAAA,CAAM,SAAA;AAAA;AAjBlB;;;;;;;;;AAOA;;;;;;;;;;;AAwCA;;;;;;;AA/CA,iBA+CgB,IAAA,CAAA;EAAO,KAAA;EAAO;AAAA,GAAY,SAAA,GAAY,KAAA,CAAM,YAAA"}
import React from "react";
//#region src/index.d.ts
type RootNode = ShadowRoot | Document | Node;
interface EnvContext<Props> {
/**
* Mapping of the components that should be replaced.
* Where the key if the unique identifier of the function
* and the value the component it should be replaced with.
*
*/
components: Record<string, React.ComponentType<Props> | {
props: Record<string, any>;
}>;
/**
* Get the window object for the rendering context.
*/
window: () => Window & typeof globalThis;
/**
* Get the document object for the rendering context.
*/
document: () => Document;
/**
* External sprite URL.
*/
sprite: string;
[key: string]: any;
}
interface SlotsContext {
/**
* Object where the keys are the namespaced slot names and the values are the slot components.
*/
assigned: Record<string, any>;
/**
* Ordered list of parent slot names that will be used as namespace.
*/
namespace: string[];
/**
* Indicator if a `components` override has been applied to the parent or current component.
*/
override: boolean;
}
interface BoxContext<Props> {
/**
* Setup a custom environment for the component.
*/
env: EnvContext<Props>;
/**
* Slots for the component.
*/
slots: SlotsContext;
}
/**
* Default values for the Box context.
*
* @param root - The root node of the component.
* @returns The default values for the Box context.
* @private
*/
declare function defaults(root?: RootNode): BoxContext<any>;
/**
* Box context for managing component environment and slots.
*
* @public
*/
declare const Box: React.Context<BoxContext<any>>;
/**
* Props for the Slot component.
*
* @public
*/
interface SlotProps {
/**
* Slots to assign and pass to children via Box context.
* These slots will be merged with any existing slots from parent context.
*/
slots: Record<string, any>;
/**
* Children to render with the slot context.
*/
children: React.ReactNode;
}
/**
* Slot component that handles Box context setup for passing slots to children.
* This component simplifies the pattern of merging slots into the Box context.
*
* @component
* @param props - The properties {@link SlotProps} passed to the Slot component.
*
* @example
* ```tsx
* import { Slot } from '@bento/box';
*
* function MyComponent({ children }) {
* const slots = {
* trigger: { onClick: handleClick },
* content: { role: 'dialog' }
* };
*
* return (
* <Slot slots={slots}>
* {children}
* </Slot>
* );
* }
* ```
*
* @public
*/
declare function Slot({
slots,
children
}: SlotProps): React.ReactElement;
//#endregion
export { Box, BoxContext, EnvContext, RootNode, Slot, SlotProps, SlotsContext, defaults };
//# sourceMappingURL=index.d.mts.map
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;KAEY,QAAA,GAAW,UAAA,GAAa,QAAA,GAAW,IAAA;AAAA,UAE9B,UAAA;EAFL;;;;;;EASV,UAAA,EAAY,MAAA,SAAe,KAAA,CAAM,aAAA,CAAc,KAAA;IAAW,KAAA,EAAO,MAAA;EAAA;EAT/B;;;EAclC,MAAA,QAAc,MAAA,UAAgB,UAAA;EAZf;;;EAiBf,QAAA,QAAgB,QAAA;EAVW;;;EAe3B,MAAA;EAAA,CAEC,GAAA;AAAA;AAAA,UAGc,YAAA;EAVS;;;EAcxB,QAAA,EAAU,MAAA;EAxBiB;;;EA6B3B,SAAA;EA7BiE;;;EAkCjE,QAAA;AAAA;AAAA,UAGe,UAAA;EAtBf;;;EA0BA,GAAA,EAAK,UAAA,CAAW,KAAA;EArBD;;;EA0Bf,KAAA,EAAO,YAAA;AAAA;;;;;;AATT;;iBAmBgB,QAAA,CAAS,IAAA,GAAO,QAAA,GAAW,UAAA;;;;;;cAiD9B,GAAA,EAAG,KAAA,CAAA,OAAA,CAAA,UAAA;;;;;;UAOC,SAAA;EAlEI;AAUrB;;;EA6DE,KAAA,EAAO,MAAA;EA7DuB;;;EAkE9B,QAAA,EAAU,KAAA,CAAM,SAAA;AAAA;AAjBlB;;;;;;;;;AAOA;;;;;;;;;;;AAwCA;;;;;;;AA/CA,iBA+CgB,IAAA,CAAA;EAAO,KAAA;EAAO;AAAA,GAAY,SAAA,GAAY,KAAA,CAAM,YAAA"}
import React, { createContext } from "react";
import { jsx } from "react/jsx-runtime";
//#region src/index.tsx
/**
* Default values for the Box context.
*
* @param root - The root node of the component.
* @returns The default values for the Box context.
* @private
*/
function defaults(root) {
/**
* Get the window object for the rendering context.
*
* @param root - The root node of the component.
* @returns The window object for the rendering context.
* @private
*/
/* v8 ignore next 4: This function is only called through the closure below */
function getWindow(root) {
if (root && "host" in root) return getWindow(root.host);
if (root && "defaultView" in root) return root.defaultView ?? window;
return root?.ownerDocument?.defaultView ?? window;
}
/**
* Get the document object for the rendering context.
*
* @param root - The root node of the component.
* @returns The document object for the rendering context.
* @private
*/
/* v8 ignore next 4: This function is only called through the closure below */
function getDocument(root) {
if (root && "nodeType" in root && root.nodeType === 9) return root;
if (root && "document" in root) return root.document;
return root?.ownerDocument ?? document;
}
return {
env: {
components: {},
sprite: "",
document: () => getDocument(root),
window: () => getWindow(root)
},
slots: {
override: false,
namespace: [],
assigned: {}
}
};
}
/**
* Box context for managing component environment and slots.
*
* @public
*/
const Box = createContext(defaults());
/**
* Slot component that handles Box context setup for passing slots to children.
* This component simplifies the pattern of merging slots into the Box context.
*
* @component
* @param props - The properties {@link SlotProps} passed to the Slot component.
*
* @example
* ```tsx
* import { Slot } from '@bento/box';
*
* function MyComponent({ children }) {
* const slots = {
* trigger: { onClick: handleClick },
* content: { role: 'dialog' }
* };
*
* return (
* <Slot slots={slots}>
* {children}
* </Slot>
* );
* }
* ```
*
* @public
*/
function Slot({ slots, children }) {
const ctx = React.useContext(Box);
const newContext = React.useMemo(function createContext() {
return {
env: { ...ctx.env },
slots: {
...ctx.slots,
assigned: {
...ctx.slots.assigned,
...slots
}
}
};
}, [ctx, slots]);
return /* @__PURE__ */ jsx(Box.Provider, {
value: newContext,
children
});
}
//#endregion
export { Box, Slot, defaults };
//# sourceMappingURL=index.mjs.map
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["import React, { createContext } from 'react';\n\nexport type RootNode = ShadowRoot | Document | Node;\n\nexport interface EnvContext<Props> {\n /**\n * Mapping of the components that should be replaced.\n * Where the key if the unique identifier of the function\n * and the value the component it should be replaced with.\n *\n */\n components: Record<string, React.ComponentType<Props> | { props: Record<string, any> }>;\n\n /**\n * Get the window object for the rendering context.\n */\n window: () => Window & typeof globalThis;\n\n /**\n * Get the document object for the rendering context.\n */\n document: () => Document;\n\n /**\n * External sprite URL.\n */\n sprite: string;\n\n [key: string]: any;\n}\n\nexport interface SlotsContext {\n /**\n * Object where the keys are the namespaced slot names and the values are the slot components.\n */\n assigned: Record<string, any>;\n\n /**\n * Ordered list of parent slot names that will be used as namespace.\n */\n namespace: string[];\n\n /**\n * Indicator if a `components` override has been applied to the parent or current component.\n */\n override: boolean;\n}\n\nexport interface BoxContext<Props> {\n /**\n * Setup a custom environment for the component.\n */\n env: EnvContext<Props>;\n\n /**\n * Slots for the component.\n */\n slots: SlotsContext;\n}\n\n/**\n * Default values for the Box context.\n *\n * @param root - The root node of the component.\n * @returns The default values for the Box context.\n * @private\n */\nexport function defaults(root?: RootNode): BoxContext<any> {\n /**\n * Get the window object for the rendering context.\n *\n * @param root - The root node of the component.\n * @returns The window object for the rendering context.\n * @private\n */\n /* v8 ignore next 4: This function is only called through the closure below */\n function getWindow(root: Node | ShadowRoot | Document | null | undefined): Window & typeof globalThis {\n if (root && 'host' in root) return getWindow(root.host);\n if (root && 'defaultView' in root) return root.defaultView ?? window;\n return root?.ownerDocument?.defaultView ?? window;\n }\n\n /**\n * Get the document object for the rendering context.\n *\n * @param root - The root node of the component.\n * @returns The document object for the rendering context.\n * @private\n */\n /* v8 ignore next 4: This function is only called through the closure below */\n function getDocument(root: Element | Window | Node | Document | null | undefined): Document {\n if (root && 'nodeType' in root && root.nodeType === 9) return root as Document;\n if (root && 'document' in root) return root.document;\n return root?.ownerDocument ?? document;\n }\n\n return {\n env: {\n components: {},\n sprite: '',\n document: () => getDocument(root),\n window: () => getWindow(root)\n },\n slots: {\n override: false,\n namespace: [],\n assigned: {}\n }\n };\n}\n\n/**\n * Box context for managing component environment and slots.\n *\n * @public\n */\nexport const Box = createContext<BoxContext<any>>(defaults());\n\n/**\n * Props for the Slot component.\n *\n * @public\n */\nexport interface SlotProps {\n /**\n * Slots to assign and pass to children via Box context.\n * These slots will be merged with any existing slots from parent context.\n */\n slots: Record<string, any>;\n\n /**\n * Children to render with the slot context.\n */\n children: React.ReactNode;\n}\n\n/**\n * Slot component that handles Box context setup for passing slots to children.\n * This component simplifies the pattern of merging slots into the Box context.\n *\n * @component\n * @param props - The properties {@link SlotProps} passed to the Slot component.\n *\n * @example\n * ```tsx\n * import { Slot } from '@bento/box';\n *\n * function MyComponent({ children }) {\n * const slots = {\n * trigger: { onClick: handleClick },\n * content: { role: 'dialog' }\n * };\n *\n * return (\n * <Slot slots={slots}>\n * {children}\n * </Slot>\n * );\n * }\n * ```\n *\n * @public\n */\nexport function Slot({ slots, children }: SlotProps): React.ReactElement {\n const ctx = React.useContext<BoxContext<any>>(Box);\n\n // Create new context with slots merged in\n const newContext: BoxContext<any> = React.useMemo(\n function createContext() {\n return {\n env: { ...ctx.env },\n slots: {\n ...ctx.slots,\n assigned: {\n ...ctx.slots.assigned,\n ...slots\n }\n }\n };\n },\n [ctx, slots]\n );\n\n return <Box.Provider value={newContext}>{children}</Box.Provider>;\n}\n"],"mappings":";;;;;;;;;;AAmEA,SAAgB,SAAS,MAAkC;;;;;;;;;CASzD,SAAS,UAAU,MAAmF;AACpG,MAAI,QAAQ,UAAU,KAAM,QAAO,UAAU,KAAK,KAAK;AACvD,MAAI,QAAQ,iBAAiB,KAAM,QAAO,KAAK,eAAe;AAC9D,SAAO,MAAM,eAAe,eAAe;;;;;;;;;;CAW7C,SAAS,YAAY,MAAuE;AAC1F,MAAI,QAAQ,cAAc,QAAQ,KAAK,aAAa,EAAG,QAAO;AAC9D,MAAI,QAAQ,cAAc,KAAM,QAAO,KAAK;AAC5C,SAAO,MAAM,iBAAiB;;AAGhC,QAAO;EACL,KAAK;GACH,YAAY,EAAE;GACd,QAAQ;GACR,gBAAgB,YAAY,KAAK;GACjC,cAAc,UAAU,KAAK;GAC9B;EACD,OAAO;GACL,UAAU;GACV,WAAW,EAAE;GACb,UAAU,EAAE;GACb;EACF;;;;;;;AAQH,MAAa,MAAM,cAA+B,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+C7D,SAAgB,KAAK,EAAE,OAAO,YAA2C;CACvE,MAAM,MAAM,MAAM,WAA4B,IAAI;CAGlD,MAAM,aAA8B,MAAM,QACxC,SAAS,gBAAgB;AACvB,SAAO;GACL,KAAK,EAAE,GAAG,IAAI,KAAK;GACnB,OAAO;IACL,GAAG,IAAI;IACP,UAAU;KACR,GAAG,IAAI,MAAM;KACb,GAAG;KACJ;IACF;GACF;IAEH,CAAC,KAAK,MAAM,CACb;AAED,QAAO,oBAAC,IAAI,UAAL;EAAc,OAAO;EAAa;EAAwB,CAAA"}
+125
-52

@@ -1,60 +0,133 @@

'use strict';
var React = require('react');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var React__default = /*#__PURE__*/_interopDefault(React);
// src/index.tsx
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
//#region \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
//#endregion
let react = require("react");
react = __toESM(react);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/index.tsx
/**
* Default values for the Box context.
*
* @param root - The root node of the component.
* @returns The default values for the Box context.
* @private
*/
function defaults(root) {
function getWindow(root2) {
if (root2 && "host" in root2) return getWindow(root2.host);
if (root2 && "defaultView" in root2) return root2.defaultView ?? window;
return root2?.ownerDocument?.defaultView ?? window;
}
function getDocument(root2) {
if (root2 && "nodeType" in root2 && root2.nodeType === 9) return root2;
if (root2 && "document" in root2) return root2.document;
return root2?.ownerDocument ?? document;
}
return {
env: {
components: {},
sprite: "",
document: () => getDocument(root),
window: () => getWindow(root)
},
slots: {
override: false,
namespace: [],
assigned: {}
}
};
/**
* Get the window object for the rendering context.
*
* @param root - The root node of the component.
* @returns The window object for the rendering context.
* @private
*/
/* v8 ignore next 4: This function is only called through the closure below */
function getWindow(root) {
if (root && "host" in root) return getWindow(root.host);
if (root && "defaultView" in root) return root.defaultView ?? window;
return root?.ownerDocument?.defaultView ?? window;
}
/**
* Get the document object for the rendering context.
*
* @param root - The root node of the component.
* @returns The document object for the rendering context.
* @private
*/
/* v8 ignore next 4: This function is only called through the closure below */
function getDocument(root) {
if (root && "nodeType" in root && root.nodeType === 9) return root;
if (root && "document" in root) return root.document;
return root?.ownerDocument ?? document;
}
return {
env: {
components: {},
sprite: "",
document: () => getDocument(root),
window: () => getWindow(root)
},
slots: {
override: false,
namespace: [],
assigned: {}
}
};
}
var Box = React.createContext(defaults());
/**
* Box context for managing component environment and slots.
*
* @public
*/
const Box = (0, react.createContext)(defaults());
/**
* Slot component that handles Box context setup for passing slots to children.
* This component simplifies the pattern of merging slots into the Box context.
*
* @component
* @param props - The properties {@link SlotProps} passed to the Slot component.
*
* @example
* ```tsx
* import { Slot } from '@bento/box';
*
* function MyComponent({ children }) {
* const slots = {
* trigger: { onClick: handleClick },
* content: { role: 'dialog' }
* };
*
* return (
* <Slot slots={slots}>
* {children}
* </Slot>
* );
* }
* ```
*
* @public
*/
function Slot({ slots, children }) {
const ctx = React__default.default.useContext(Box);
const newContext = React__default.default.useMemo(
function createContext2() {
return {
env: { ...ctx.env },
slots: {
...ctx.slots,
assigned: {
...ctx.slots.assigned,
...slots
}
}
};
},
[ctx, slots]
);
return /* @__PURE__ */ React__default.default.createElement(Box.Provider, { value: newContext }, children);
const ctx = react.default.useContext(Box);
const newContext = react.default.useMemo(function createContext() {
return {
env: { ...ctx.env },
slots: {
...ctx.slots,
assigned: {
...ctx.slots.assigned,
...slots
}
}
};
}, [ctx, slots]);
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Box.Provider, {
value: newContext,
children
});
}
//#endregion
exports.Box = Box;
exports.Slot = Slot;
exports.defaults = defaults;
//# sourceMappingURL=index.cjs.map
//# sourceMappingURL=index.cjs.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/index.tsx"],"names":["root","createContext","React"],"mappings":";;;;;;;;;AAmEO,SAAS,SAAS,IAAA,EAAkC;AAQzD,EAAA,SAAS,UAAUA,KAAAA,EAAmF;AACpG,IAAA,IAAIA,SAAQ,MAAA,IAAUA,KAAAA,EAAM,OAAO,SAAA,CAAUA,MAAK,IAAI,CAAA;AACtD,IAAA,IAAIA,KAAAA,IAAQ,aAAA,IAAiBA,KAAAA,EAAM,OAAOA,MAAK,WAAA,IAAe,MAAA;AAC9D,IAAA,OAAOA,KAAAA,EAAM,eAAe,WAAA,IAAe,MAAA;AAAA,EAC7C;AASA,EAAA,SAAS,YAAYA,KAAAA,EAAuE;AAC1F,IAAA,IAAIA,SAAQ,UAAA,IAAcA,KAAAA,IAAQA,KAAAA,CAAK,QAAA,KAAa,GAAG,OAAOA,KAAAA;AAC9D,IAAA,IAAIA,KAAAA,IAAQ,UAAA,IAAcA,KAAAA,EAAM,OAAOA,KAAAA,CAAK,QAAA;AAC5C,IAAA,OAAOA,OAAM,aAAA,IAAiB,QAAA;AAAA,EAChC;AAEA,EAAA,OAAO;AAAA,IACL,GAAA,EAAK;AAAA,MACH,YAAY,EAAC;AAAA,MACb,MAAA,EAAQ,EAAA;AAAA,MACR,QAAA,EAAU,MAAM,WAAA,CAAY,IAAI,CAAA;AAAA,MAChC,MAAA,EAAQ,MAAM,SAAA,CAAU,IAAI;AAAA,KAC9B;AAAA,IACA,KAAA,EAAO;AAAA,MACL,QAAA,EAAU,KAAA;AAAA,MACV,WAAW,EAAC;AAAA,MACZ,UAAU;AAAC;AACb,GACF;AACF;AAOO,IAAM,GAAA,GAAMC,mBAAA,CAA+B,QAAA,EAAU;AA+CrD,SAAS,IAAA,CAAK,EAAE,KAAA,EAAO,QAAA,EAAS,EAAkC;AACvE,EAAA,MAAM,GAAA,GAAMC,sBAAA,CAAM,UAAA,CAA4B,GAAG,CAAA;AAGjD,EAAA,MAAM,aAA8BA,sBAAA,CAAM,OAAA;AAAA,IACxC,SAASD,cAAAA,GAAgB;AACvB,MAAA,OAAO;AAAA,QACL,GAAA,EAAK,EAAE,GAAG,GAAA,CAAI,GAAA,EAAI;AAAA,QAClB,KAAA,EAAO;AAAA,UACL,GAAG,GAAA,CAAI,KAAA;AAAA,UACP,QAAA,EAAU;AAAA,YACR,GAAG,IAAI,KAAA,CAAM,QAAA;AAAA,YACb,GAAG;AAAA;AACL;AACF,OACF;AAAA,IACF,CAAA;AAAA,IACA,CAAC,KAAK,KAAK;AAAA,GACb;AAEA,EAAA,4DAAQ,GAAA,CAAI,QAAA,EAAJ,EAAa,KAAA,EAAO,cAAa,QAAS,CAAA;AACpD","file":"index.cjs","sourcesContent":["import React, { createContext } from 'react';\n\nexport type RootNode = ShadowRoot | Document | Node;\n\nexport interface EnvContext<Props> {\n /**\n * Mapping of the components that should be replaced.\n * Where the key if the unique identifier of the function\n * and the value the component it should be replaced with.\n *\n */\n components: Record<string, React.ComponentType<Props> | { props: Record<string, any> }>;\n\n /**\n * Get the window object for the rendering context.\n */\n window: () => Window & typeof globalThis;\n\n /**\n * Get the document object for the rendering context.\n */\n document: () => Document;\n\n /**\n * External sprite URL.\n */\n sprite: string;\n\n [key: string]: any;\n}\n\nexport interface SlotsContext {\n /**\n * Object where the keys are the namespaced slot names and the values are the slot components.\n */\n assigned: Record<string, any>;\n\n /**\n * Ordered list of parent slot names that will be used as namespace.\n */\n namespace: string[];\n\n /**\n * Indicator if a `components` override has been applied to the parent or current component.\n */\n override: boolean;\n}\n\nexport interface BoxContext<Props> {\n /**\n * Setup a custom environment for the component.\n */\n env: EnvContext<Props>;\n\n /**\n * Slots for the component.\n */\n slots: SlotsContext;\n}\n\n/**\n * Default values for the Box context.\n *\n * @param root - The root node of the component.\n * @returns The default values for the Box context.\n * @private\n */\nexport function defaults(root?: RootNode): BoxContext<any> {\n /**\n * Get the window object for the rendering context.\n *\n * @param root - The root node of the component.\n * @returns The window object for the rendering context.\n * @private\n */\n function getWindow(root: Node | ShadowRoot | Document | null | undefined): Window & typeof globalThis {\n if (root && 'host' in root) return getWindow(root.host);\n if (root && 'defaultView' in root) return root.defaultView ?? window;\n return root?.ownerDocument?.defaultView ?? window;\n }\n\n /**\n * Get the document object for the rendering context.\n *\n * @param root - The root node of the component.\n * @returns The document object for the rendering context.\n * @private\n */\n function getDocument(root: Element | Window | Node | Document | null | undefined): Document {\n if (root && 'nodeType' in root && root.nodeType === 9) return root as Document;\n if (root && 'document' in root) return root.document;\n return root?.ownerDocument ?? document;\n }\n\n return {\n env: {\n components: {},\n sprite: '',\n document: () => getDocument(root),\n window: () => getWindow(root)\n },\n slots: {\n override: false,\n namespace: [],\n assigned: {}\n }\n };\n}\n\n/**\n * Box context for managing component environment and slots.\n *\n * @public\n */\nexport const Box = createContext<BoxContext<any>>(defaults());\n\n/**\n * Props for the Slot component.\n *\n * @public\n */\nexport interface SlotProps {\n /**\n * Slots to assign and pass to children via Box context.\n * These slots will be merged with any existing slots from parent context.\n */\n slots: Record<string, any>;\n\n /**\n * Children to render with the slot context.\n */\n children: React.ReactNode;\n}\n\n/**\n * Slot component that handles Box context setup for passing slots to children.\n * This component simplifies the pattern of merging slots into the Box context.\n *\n * @component\n * @param props - The properties {@link SlotProps} passed to the Slot component.\n *\n * @example\n * ```tsx\n * import { Slot } from '@bento/box';\n *\n * function MyComponent({ children }) {\n * const slots = {\n * trigger: { onClick: handleClick },\n * content: { role: 'dialog' }\n * };\n *\n * return (\n * <Slot slots={slots}>\n * {children}\n * </Slot>\n * );\n * }\n * ```\n *\n * @public\n */\nexport function Slot({ slots, children }: SlotProps): React.ReactElement {\n const ctx = React.useContext<BoxContext<any>>(Box);\n\n // Create new context with slots merged in\n const newContext: BoxContext<any> = React.useMemo(\n function createContext() {\n return {\n env: { ...ctx.env },\n slots: {\n ...ctx.slots,\n assigned: {\n ...ctx.slots.assigned,\n ...slots\n }\n }\n };\n },\n [ctx, slots]\n );\n\n return <Box.Provider value={newContext}>{children}</Box.Provider>;\n}\n"]}
{"version":3,"file":"index.cjs","names":["React"],"sources":["../src/index.tsx"],"sourcesContent":["import React, { createContext } from 'react';\n\nexport type RootNode = ShadowRoot | Document | Node;\n\nexport interface EnvContext<Props> {\n /**\n * Mapping of the components that should be replaced.\n * Where the key if the unique identifier of the function\n * and the value the component it should be replaced with.\n *\n */\n components: Record<string, React.ComponentType<Props> | { props: Record<string, any> }>;\n\n /**\n * Get the window object for the rendering context.\n */\n window: () => Window & typeof globalThis;\n\n /**\n * Get the document object for the rendering context.\n */\n document: () => Document;\n\n /**\n * External sprite URL.\n */\n sprite: string;\n\n [key: string]: any;\n}\n\nexport interface SlotsContext {\n /**\n * Object where the keys are the namespaced slot names and the values are the slot components.\n */\n assigned: Record<string, any>;\n\n /**\n * Ordered list of parent slot names that will be used as namespace.\n */\n namespace: string[];\n\n /**\n * Indicator if a `components` override has been applied to the parent or current component.\n */\n override: boolean;\n}\n\nexport interface BoxContext<Props> {\n /**\n * Setup a custom environment for the component.\n */\n env: EnvContext<Props>;\n\n /**\n * Slots for the component.\n */\n slots: SlotsContext;\n}\n\n/**\n * Default values for the Box context.\n *\n * @param root - The root node of the component.\n * @returns The default values for the Box context.\n * @private\n */\nexport function defaults(root?: RootNode): BoxContext<any> {\n /**\n * Get the window object for the rendering context.\n *\n * @param root - The root node of the component.\n * @returns The window object for the rendering context.\n * @private\n */\n /* v8 ignore next 4: This function is only called through the closure below */\n function getWindow(root: Node | ShadowRoot | Document | null | undefined): Window & typeof globalThis {\n if (root && 'host' in root) return getWindow(root.host);\n if (root && 'defaultView' in root) return root.defaultView ?? window;\n return root?.ownerDocument?.defaultView ?? window;\n }\n\n /**\n * Get the document object for the rendering context.\n *\n * @param root - The root node of the component.\n * @returns The document object for the rendering context.\n * @private\n */\n /* v8 ignore next 4: This function is only called through the closure below */\n function getDocument(root: Element | Window | Node | Document | null | undefined): Document {\n if (root && 'nodeType' in root && root.nodeType === 9) return root as Document;\n if (root && 'document' in root) return root.document;\n return root?.ownerDocument ?? document;\n }\n\n return {\n env: {\n components: {},\n sprite: '',\n document: () => getDocument(root),\n window: () => getWindow(root)\n },\n slots: {\n override: false,\n namespace: [],\n assigned: {}\n }\n };\n}\n\n/**\n * Box context for managing component environment and slots.\n *\n * @public\n */\nexport const Box = createContext<BoxContext<any>>(defaults());\n\n/**\n * Props for the Slot component.\n *\n * @public\n */\nexport interface SlotProps {\n /**\n * Slots to assign and pass to children via Box context.\n * These slots will be merged with any existing slots from parent context.\n */\n slots: Record<string, any>;\n\n /**\n * Children to render with the slot context.\n */\n children: React.ReactNode;\n}\n\n/**\n * Slot component that handles Box context setup for passing slots to children.\n * This component simplifies the pattern of merging slots into the Box context.\n *\n * @component\n * @param props - The properties {@link SlotProps} passed to the Slot component.\n *\n * @example\n * ```tsx\n * import { Slot } from '@bento/box';\n *\n * function MyComponent({ children }) {\n * const slots = {\n * trigger: { onClick: handleClick },\n * content: { role: 'dialog' }\n * };\n *\n * return (\n * <Slot slots={slots}>\n * {children}\n * </Slot>\n * );\n * }\n * ```\n *\n * @public\n */\nexport function Slot({ slots, children }: SlotProps): React.ReactElement {\n const ctx = React.useContext<BoxContext<any>>(Box);\n\n // Create new context with slots merged in\n const newContext: BoxContext<any> = React.useMemo(\n function createContext() {\n return {\n env: { ...ctx.env },\n slots: {\n ...ctx.slots,\n assigned: {\n ...ctx.slots.assigned,\n ...slots\n }\n }\n };\n },\n [ctx, slots]\n );\n\n return <Box.Provider value={newContext}>{children}</Box.Provider>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,SAAgB,SAAS,MAAkC;;;;;;;;;CASzD,SAAS,UAAU,MAAmF;AACpG,MAAI,QAAQ,UAAU,KAAM,QAAO,UAAU,KAAK,KAAK;AACvD,MAAI,QAAQ,iBAAiB,KAAM,QAAO,KAAK,eAAe;AAC9D,SAAO,MAAM,eAAe,eAAe;;;;;;;;;;CAW7C,SAAS,YAAY,MAAuE;AAC1F,MAAI,QAAQ,cAAc,QAAQ,KAAK,aAAa,EAAG,QAAO;AAC9D,MAAI,QAAQ,cAAc,KAAM,QAAO,KAAK;AAC5C,SAAO,MAAM,iBAAiB;;AAGhC,QAAO;EACL,KAAK;GACH,YAAY,EAAE;GACd,QAAQ;GACR,gBAAgB,YAAY,KAAK;GACjC,cAAc,UAAU,KAAK;GAC9B;EACD,OAAO;GACL,UAAU;GACV,WAAW,EAAE;GACb,UAAU,EAAE;GACb;EACF;;;;;;;AAQH,MAAa,OAAA,GAAA,MAAA,eAAqC,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+C7D,SAAgB,KAAK,EAAE,OAAO,YAA2C;CACvE,MAAM,MAAMA,MAAAA,QAAM,WAA4B,IAAI;CAGlD,MAAM,aAA8BA,MAAAA,QAAM,QACxC,SAAS,gBAAgB;AACvB,SAAO;GACL,KAAK,EAAE,GAAG,IAAI,KAAK;GACnB,OAAO;IACL,GAAG,IAAI;IACP,UAAU;KACR,GAAG,IAAI,MAAM;KACb,GAAG;KACJ;IACF;GACF;IAEH,CAAC,KAAK,MAAM,CACb;AAED,QAAO,iBAAA,GAAA,kBAAA,KAAC,IAAI,UAAL;EAAc,OAAO;EAAa;EAAwB,CAAA"}

@@ -1,51 +0,52 @@

import React from 'react';
import React from "react";
//#region src/index.d.ts
type RootNode = ShadowRoot | Document | Node;
interface EnvContext<Props> {
/**
* Mapping of the components that should be replaced.
* Where the key if the unique identifier of the function
* and the value the component it should be replaced with.
*
*/
components: Record<string, React.ComponentType<Props> | {
props: Record<string, any>;
}>;
/**
* Get the window object for the rendering context.
*/
window: () => Window & typeof globalThis;
/**
* Get the document object for the rendering context.
*/
document: () => Document;
/**
* External sprite URL.
*/
sprite: string;
[key: string]: any;
/**
* Mapping of the components that should be replaced.
* Where the key if the unique identifier of the function
* and the value the component it should be replaced with.
*
*/
components: Record<string, React.ComponentType<Props> | {
props: Record<string, any>;
}>;
/**
* Get the window object for the rendering context.
*/
window: () => Window & typeof globalThis;
/**
* Get the document object for the rendering context.
*/
document: () => Document;
/**
* External sprite URL.
*/
sprite: string;
[key: string]: any;
}
interface SlotsContext {
/**
* Object where the keys are the namespaced slot names and the values are the slot components.
*/
assigned: Record<string, any>;
/**
* Ordered list of parent slot names that will be used as namespace.
*/
namespace: string[];
/**
* Indicator if a `components` override has been applied to the parent or current component.
*/
override: boolean;
/**
* Object where the keys are the namespaced slot names and the values are the slot components.
*/
assigned: Record<string, any>;
/**
* Ordered list of parent slot names that will be used as namespace.
*/
namespace: string[];
/**
* Indicator if a `components` override has been applied to the parent or current component.
*/
override: boolean;
}
interface BoxContext<Props> {
/**
* Setup a custom environment for the component.
*/
env: EnvContext<Props>;
/**
* Slots for the component.
*/
slots: SlotsContext;
/**
* Setup a custom environment for the component.
*/
env: EnvContext<Props>;
/**
* Slots for the component.
*/
slots: SlotsContext;
}

@@ -72,11 +73,11 @@ /**

interface SlotProps {
/**
* Slots to assign and pass to children via Box context.
* These slots will be merged with any existing slots from parent context.
*/
slots: Record<string, any>;
/**
* Children to render with the slot context.
*/
children: React.ReactNode;
/**
* Slots to assign and pass to children via Box context.
* These slots will be merged with any existing slots from parent context.
*/
slots: Record<string, any>;
/**
* Children to render with the slot context.
*/
children: React.ReactNode;
}

@@ -110,4 +111,8 @@ /**

*/
declare function Slot({ slots, children }: SlotProps): React.ReactElement;
export { Box, type BoxContext, type EnvContext, type RootNode, Slot, type SlotProps, type SlotsContext, defaults };
declare function Slot({
slots,
children
}: SlotProps): React.ReactElement;
//#endregion
export { Box, BoxContext, EnvContext, RootNode, Slot, SlotProps, SlotsContext, defaults };
//# sourceMappingURL=index.d.cts.map
{
"name": "@bento/box",
"version": "0.2.0",
"version": "0.2.1",
"description": "Shared context for Bento components",

@@ -9,8 +9,6 @@ "type": "module",

"scripts": {
"build": "tsup-node",
"dev": "tsup-node --watch",
"build": "tsdown",
"dev": "tsdown --watch",
"lint": "biome lint && tsc --noEmit",
"posttest": "npm run lint",
"prepublishOnly": "node ../../scripts/compile-readme.ts",
"pretest": "npm run build",
"prepublishOnly": "node ../../../scripts/compile-readme.ts",
"test": "vitest --run",

@@ -21,3 +19,3 @@ "test:watch": "vitest"

"type": "git",
"url": "git+https://github.com/godaddy/bento.git"
"url": "git+https://github.com/godaddy/antares.git"
},

@@ -34,5 +32,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/godaddy/bento/issues"
"url": "https://github.com/godaddy/antares/issues"
},
"homepage": "https://github.com/godaddy/bento#readme",
"homepage": "https://github.com/godaddy/antares#readme",
"files": [

@@ -43,2 +41,10 @@ "dist",

],
"devDependencies": {
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"tsdown": "^0.21.10",
"typescript": "^5.9.3",
"vitest": "^4.0.18",
"vitest-browser-react": "^2.1.0"
},
"peerDependencies": {

@@ -51,4 +57,4 @@ "react": "18.x || 19.x",

"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},

@@ -55,0 +61,0 @@ "require": {

@@ -76,2 +76,3 @@ import React, { createContext } from 'react';

*/
/* v8 ignore next 4: This function is only called through the closure below */
function getWindow(root: Node | ShadowRoot | Document | null | undefined): Window & typeof globalThis {

@@ -90,2 +91,3 @@ if (root && 'host' in root) return getWindow(root.host);

*/
/* v8 ignore next 4: This function is only called through the closure below */
function getDocument(root: Element | Window | Node | Document | null | undefined): Document {

@@ -92,0 +94,0 @@ if (root && 'nodeType' in root && root.nodeType === 9) return root as Document;

import React from 'react';
type RootNode = ShadowRoot | Document | Node;
interface EnvContext<Props> {
/**
* Mapping of the components that should be replaced.
* Where the key if the unique identifier of the function
* and the value the component it should be replaced with.
*
*/
components: Record<string, React.ComponentType<Props> | {
props: Record<string, any>;
}>;
/**
* Get the window object for the rendering context.
*/
window: () => Window & typeof globalThis;
/**
* Get the document object for the rendering context.
*/
document: () => Document;
/**
* External sprite URL.
*/
sprite: string;
[key: string]: any;
}
interface SlotsContext {
/**
* Object where the keys are the namespaced slot names and the values are the slot components.
*/
assigned: Record<string, any>;
/**
* Ordered list of parent slot names that will be used as namespace.
*/
namespace: string[];
/**
* Indicator if a `components` override has been applied to the parent or current component.
*/
override: boolean;
}
interface BoxContext<Props> {
/**
* Setup a custom environment for the component.
*/
env: EnvContext<Props>;
/**
* Slots for the component.
*/
slots: SlotsContext;
}
/**
* Default values for the Box context.
*
* @param root - The root node of the component.
* @returns The default values for the Box context.
* @private
*/
declare function defaults(root?: RootNode): BoxContext<any>;
/**
* Box context for managing component environment and slots.
*
* @public
*/
declare const Box: React.Context<BoxContext<any>>;
/**
* Props for the Slot component.
*
* @public
*/
interface SlotProps {
/**
* Slots to assign and pass to children via Box context.
* These slots will be merged with any existing slots from parent context.
*/
slots: Record<string, any>;
/**
* Children to render with the slot context.
*/
children: React.ReactNode;
}
/**
* Slot component that handles Box context setup for passing slots to children.
* This component simplifies the pattern of merging slots into the Box context.
*
* @component
* @param props - The properties {@link SlotProps} passed to the Slot component.
*
* @example
* ```tsx
* import { Slot } from '@bento/box';
*
* function MyComponent({ children }) {
* const slots = {
* trigger: { onClick: handleClick },
* content: { role: 'dialog' }
* };
*
* return (
* <Slot slots={slots}>
* {children}
* </Slot>
* );
* }
* ```
*
* @public
*/
declare function Slot({ slots, children }: SlotProps): React.ReactElement;
export { Box, type BoxContext, type EnvContext, type RootNode, Slot, type SlotProps, type SlotsContext, defaults };
import React, { createContext } from 'react';
// src/index.tsx
function defaults(root) {
function getWindow(root2) {
if (root2 && "host" in root2) return getWindow(root2.host);
if (root2 && "defaultView" in root2) return root2.defaultView ?? window;
return root2?.ownerDocument?.defaultView ?? window;
}
function getDocument(root2) {
if (root2 && "nodeType" in root2 && root2.nodeType === 9) return root2;
if (root2 && "document" in root2) return root2.document;
return root2?.ownerDocument ?? document;
}
return {
env: {
components: {},
sprite: "",
document: () => getDocument(root),
window: () => getWindow(root)
},
slots: {
override: false,
namespace: [],
assigned: {}
}
};
}
var Box = createContext(defaults());
function Slot({ slots, children }) {
const ctx = React.useContext(Box);
const newContext = React.useMemo(
function createContext2() {
return {
env: { ...ctx.env },
slots: {
...ctx.slots,
assigned: {
...ctx.slots.assigned,
...slots
}
}
};
},
[ctx, slots]
);
return /* @__PURE__ */ React.createElement(Box.Provider, { value: newContext }, children);
}
export { Box, Slot, defaults };
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map
{"version":3,"sources":["../src/index.tsx"],"names":["root","createContext"],"mappings":";;;AAmEO,SAAS,SAAS,IAAA,EAAkC;AAQzD,EAAA,SAAS,UAAUA,KAAAA,EAAmF;AACpG,IAAA,IAAIA,SAAQ,MAAA,IAAUA,KAAAA,EAAM,OAAO,SAAA,CAAUA,MAAK,IAAI,CAAA;AACtD,IAAA,IAAIA,KAAAA,IAAQ,aAAA,IAAiBA,KAAAA,EAAM,OAAOA,MAAK,WAAA,IAAe,MAAA;AAC9D,IAAA,OAAOA,KAAAA,EAAM,eAAe,WAAA,IAAe,MAAA;AAAA,EAC7C;AASA,EAAA,SAAS,YAAYA,KAAAA,EAAuE;AAC1F,IAAA,IAAIA,SAAQ,UAAA,IAAcA,KAAAA,IAAQA,KAAAA,CAAK,QAAA,KAAa,GAAG,OAAOA,KAAAA;AAC9D,IAAA,IAAIA,KAAAA,IAAQ,UAAA,IAAcA,KAAAA,EAAM,OAAOA,KAAAA,CAAK,QAAA;AAC5C,IAAA,OAAOA,OAAM,aAAA,IAAiB,QAAA;AAAA,EAChC;AAEA,EAAA,OAAO;AAAA,IACL,GAAA,EAAK;AAAA,MACH,YAAY,EAAC;AAAA,MACb,MAAA,EAAQ,EAAA;AAAA,MACR,QAAA,EAAU,MAAM,WAAA,CAAY,IAAI,CAAA;AAAA,MAChC,MAAA,EAAQ,MAAM,SAAA,CAAU,IAAI;AAAA,KAC9B;AAAA,IACA,KAAA,EAAO;AAAA,MACL,QAAA,EAAU,KAAA;AAAA,MACV,WAAW,EAAC;AAAA,MACZ,UAAU;AAAC;AACb,GACF;AACF;AAOO,IAAM,GAAA,GAAM,aAAA,CAA+B,QAAA,EAAU;AA+CrD,SAAS,IAAA,CAAK,EAAE,KAAA,EAAO,QAAA,EAAS,EAAkC;AACvE,EAAA,MAAM,GAAA,GAAM,KAAA,CAAM,UAAA,CAA4B,GAAG,CAAA;AAGjD,EAAA,MAAM,aAA8B,KAAA,CAAM,OAAA;AAAA,IACxC,SAASC,cAAAA,GAAgB;AACvB,MAAA,OAAO;AAAA,QACL,GAAA,EAAK,EAAE,GAAG,GAAA,CAAI,GAAA,EAAI;AAAA,QAClB,KAAA,EAAO;AAAA,UACL,GAAG,GAAA,CAAI,KAAA;AAAA,UACP,QAAA,EAAU;AAAA,YACR,GAAG,IAAI,KAAA,CAAM,QAAA;AAAA,YACb,GAAG;AAAA;AACL;AACF,OACF;AAAA,IACF,CAAA;AAAA,IACA,CAAC,KAAK,KAAK;AAAA,GACb;AAEA,EAAA,2CAAQ,GAAA,CAAI,QAAA,EAAJ,EAAa,KAAA,EAAO,cAAa,QAAS,CAAA;AACpD","file":"index.js","sourcesContent":["import React, { createContext } from 'react';\n\nexport type RootNode = ShadowRoot | Document | Node;\n\nexport interface EnvContext<Props> {\n /**\n * Mapping of the components that should be replaced.\n * Where the key if the unique identifier of the function\n * and the value the component it should be replaced with.\n *\n */\n components: Record<string, React.ComponentType<Props> | { props: Record<string, any> }>;\n\n /**\n * Get the window object for the rendering context.\n */\n window: () => Window & typeof globalThis;\n\n /**\n * Get the document object for the rendering context.\n */\n document: () => Document;\n\n /**\n * External sprite URL.\n */\n sprite: string;\n\n [key: string]: any;\n}\n\nexport interface SlotsContext {\n /**\n * Object where the keys are the namespaced slot names and the values are the slot components.\n */\n assigned: Record<string, any>;\n\n /**\n * Ordered list of parent slot names that will be used as namespace.\n */\n namespace: string[];\n\n /**\n * Indicator if a `components` override has been applied to the parent or current component.\n */\n override: boolean;\n}\n\nexport interface BoxContext<Props> {\n /**\n * Setup a custom environment for the component.\n */\n env: EnvContext<Props>;\n\n /**\n * Slots for the component.\n */\n slots: SlotsContext;\n}\n\n/**\n * Default values for the Box context.\n *\n * @param root - The root node of the component.\n * @returns The default values for the Box context.\n * @private\n */\nexport function defaults(root?: RootNode): BoxContext<any> {\n /**\n * Get the window object for the rendering context.\n *\n * @param root - The root node of the component.\n * @returns The window object for the rendering context.\n * @private\n */\n function getWindow(root: Node | ShadowRoot | Document | null | undefined): Window & typeof globalThis {\n if (root && 'host' in root) return getWindow(root.host);\n if (root && 'defaultView' in root) return root.defaultView ?? window;\n return root?.ownerDocument?.defaultView ?? window;\n }\n\n /**\n * Get the document object for the rendering context.\n *\n * @param root - The root node of the component.\n * @returns The document object for the rendering context.\n * @private\n */\n function getDocument(root: Element | Window | Node | Document | null | undefined): Document {\n if (root && 'nodeType' in root && root.nodeType === 9) return root as Document;\n if (root && 'document' in root) return root.document;\n return root?.ownerDocument ?? document;\n }\n\n return {\n env: {\n components: {},\n sprite: '',\n document: () => getDocument(root),\n window: () => getWindow(root)\n },\n slots: {\n override: false,\n namespace: [],\n assigned: {}\n }\n };\n}\n\n/**\n * Box context for managing component environment and slots.\n *\n * @public\n */\nexport const Box = createContext<BoxContext<any>>(defaults());\n\n/**\n * Props for the Slot component.\n *\n * @public\n */\nexport interface SlotProps {\n /**\n * Slots to assign and pass to children via Box context.\n * These slots will be merged with any existing slots from parent context.\n */\n slots: Record<string, any>;\n\n /**\n * Children to render with the slot context.\n */\n children: React.ReactNode;\n}\n\n/**\n * Slot component that handles Box context setup for passing slots to children.\n * This component simplifies the pattern of merging slots into the Box context.\n *\n * @component\n * @param props - The properties {@link SlotProps} passed to the Slot component.\n *\n * @example\n * ```tsx\n * import { Slot } from '@bento/box';\n *\n * function MyComponent({ children }) {\n * const slots = {\n * trigger: { onClick: handleClick },\n * content: { role: 'dialog' }\n * };\n *\n * return (\n * <Slot slots={slots}>\n * {children}\n * </Slot>\n * );\n * }\n * ```\n *\n * @public\n */\nexport function Slot({ slots, children }: SlotProps): React.ReactElement {\n const ctx = React.useContext<BoxContext<any>>(Box);\n\n // Create new context with slots merged in\n const newContext: BoxContext<any> = React.useMemo(\n function createContext() {\n return {\n env: { ...ctx.env },\n slots: {\n ...ctx.slots,\n assigned: {\n ...ctx.slots.assigned,\n ...slots\n }\n }\n };\n },\n [ctx, slots]\n );\n\n return <Box.Provider value={newContext}>{children}</Box.Provider>;\n}\n"]}