@patternmode/stacksheet 1.4.0 → 2.0.3
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/SheetPanel/sheet-panel-focus.d.ts.map +1 -1
- package/dist/SheetParts/sheet-back.d.ts +1 -1
- package/dist/SheetParts/sheet-back.d.ts.map +1 -1
- package/dist/SheetParts/sheet-body.d.ts +1 -1
- package/dist/SheetParts/sheet-body.d.ts.map +1 -1
- package/dist/SheetParts/sheet-close.d.ts +1 -1
- package/dist/SheetParts/sheet-close.d.ts.map +1 -1
- package/dist/SheetParts/sheet-description.d.ts +1 -1
- package/dist/SheetParts/sheet-description.d.ts.map +1 -1
- package/dist/SheetParts/sheet-footer.d.ts +1 -1
- package/dist/SheetParts/sheet-footer.d.ts.map +1 -1
- package/dist/SheetParts/sheet-handle.d.ts +1 -1
- package/dist/SheetParts/sheet-handle.d.ts.map +1 -1
- package/dist/SheetParts/sheet-header.d.ts +1 -1
- package/dist/SheetParts/sheet-header.d.ts.map +1 -1
- package/dist/SheetParts/sheet-part-element.d.ts +13 -0
- package/dist/SheetParts/sheet-part-element.d.ts.map +1 -0
- package/dist/SheetParts/sheet-part-types.d.ts +3 -2
- package/dist/SheetParts/sheet-part-types.d.ts.map +1 -1
- package/dist/SheetParts/sheet-parts.d.ts +8 -8
- package/dist/SheetParts/sheet-title.d.ts +1 -1
- package/dist/SheetParts/sheet-title.d.ts.map +1 -1
- package/dist/index.mjs +143 -81
- package/dist/index.mjs.map +1 -1
- package/dist/render.d.ts +10 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/sheet-portal.d.ts +12 -0
- package/dist/sheet-portal.d.ts.map +1 -0
- package/dist/snap-points.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +5 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-panel-focus.d.ts","sourceRoot":"","sources":["../../src/SheetPanel/sheet-panel-focus.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"sheet-panel-focus.d.ts","sourceRoot":"","sources":["../../src/SheetPanel/sheet-panel-focus.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAkDlD,eAAO,MAAM,cAAc,GAAI,6CAK5B;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC3C,QAAQ,EAAE,SAAS,CAAC;CACrB,KAAG,SA2BH,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SheetOptionalContentPartProps } from "./sheet-part-types";
|
|
2
|
-
export declare const SheetBack: ({
|
|
2
|
+
export declare const SheetBack: ({ render, className, style, children, }: SheetOptionalContentPartProps) => import("react").JSX.Element | null;
|
|
3
3
|
//# sourceMappingURL=sheet-back.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-back.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-back.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAExE,eAAO,MAAM,SAAS,GAAI,
|
|
1
|
+
{"version":3,"file":"sheet-back.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-back.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAExE,eAAO,MAAM,SAAS,GAAI,yCAKvB,6BAA6B,uCAsB/B,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SheetPartProps } from "./sheet-part-types";
|
|
2
|
-
export declare const SheetBody: ({
|
|
2
|
+
export declare const SheetBody: ({ render, className, style, children }: SheetPartProps) => import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=sheet-body.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-body.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-body.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sheet-body.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-body.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AA2BzD,eAAO,MAAM,SAAS,GAAI,wCAAwC,cAAc,gCAyB/E,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SheetOptionalContentPartProps } from "./sheet-part-types";
|
|
2
|
-
export declare const SheetClose: ({
|
|
2
|
+
export declare const SheetClose: ({ render, className, style, children, }: SheetOptionalContentPartProps) => import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=sheet-close.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-close.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-close.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAExE,eAAO,MAAM,UAAU,GAAI,
|
|
1
|
+
{"version":3,"file":"sheet-close.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-close.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAExE,eAAO,MAAM,UAAU,GAAI,yCAKxB,6BAA6B,gCAmB/B,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SheetPartProps } from "./sheet-part-types";
|
|
2
|
-
export declare const SheetDescription: ({
|
|
2
|
+
export declare const SheetDescription: ({ render, className, style, children }: SheetPartProps) => import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=sheet-description.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-description.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-description.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,eAAO,MAAM,gBAAgB,GAAI,
|
|
1
|
+
{"version":3,"file":"sheet-description.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-description.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,eAAO,MAAM,gBAAgB,GAAI,wCAAwC,cAAc,gCAUtF,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SheetPartProps } from "./sheet-part-types";
|
|
2
|
-
export declare const SheetFooter: ({
|
|
2
|
+
export declare const SheetFooter: ({ render, className, style, children }: SheetPartProps) => import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=sheet-footer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-footer.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-footer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,eAAO,MAAM,WAAW,GAAI,
|
|
1
|
+
{"version":3,"file":"sheet-footer.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-footer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,eAAO,MAAM,WAAW,GAAI,wCAAwC,cAAc,gCASjF,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SheetOptionalContentPartProps } from "./sheet-part-types";
|
|
2
|
-
export declare const SheetHandle: ({
|
|
2
|
+
export declare const SheetHandle: ({ render, className, style, children, }: SheetOptionalContentPartProps) => import("react").JSX.Element | null;
|
|
3
3
|
//# sourceMappingURL=sheet-handle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-handle.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-handle.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAExE,eAAO,MAAM,WAAW,GAAI,
|
|
1
|
+
{"version":3,"file":"sheet-handle.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-handle.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAExE,eAAO,MAAM,WAAW,GAAI,yCAKzB,6BAA6B,uCA6B/B,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SheetPartProps } from "./sheet-part-types";
|
|
2
|
-
export declare const SheetHeader: ({
|
|
2
|
+
export declare const SheetHeader: ({ render, className, style, children }: SheetPartProps) => import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=sheet-header.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-header.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-header.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,eAAO,MAAM,WAAW,GAAI,
|
|
1
|
+
{"version":3,"file":"sheet-header.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-header.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,eAAO,MAAM,WAAW,GAAI,wCAAwC,cAAc,gCAWjF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import type { RenderProp } from "../render";
|
|
3
|
+
/**
|
|
4
|
+
* Renders a sheet part through `render` (or its default tag) via Base UI's
|
|
5
|
+
* `useRender`. Centralising the hook here lets each part early-return before
|
|
6
|
+
* constructing the element without tripping the Rules of Hooks.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SheetPartElement: ({ defaultTagName, props, render, }: {
|
|
9
|
+
defaultTagName: keyof JSX.IntrinsicElements;
|
|
10
|
+
props: Record<string, unknown>;
|
|
11
|
+
render: RenderProp | undefined;
|
|
12
|
+
}) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
|
+
//# sourceMappingURL=sheet-part-element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheet-part-element.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-part-element.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,oCAI9B;IACD,cAAc,EAAE,MAAM,GAAG,CAAC,iBAAiB,CAAC;IAC5C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC;CAChC,+FAAiD,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
import type { RenderProp } from "../render";
|
|
2
3
|
export interface SheetPartProps {
|
|
3
|
-
|
|
4
|
+
render?: RenderProp;
|
|
4
5
|
children: ReactNode;
|
|
5
6
|
className?: string;
|
|
6
7
|
style?: CSSProperties;
|
|
7
8
|
}
|
|
8
9
|
export interface SheetOptionalContentPartProps {
|
|
9
|
-
|
|
10
|
+
render?: RenderProp;
|
|
10
11
|
children?: ReactNode;
|
|
11
12
|
className?: string;
|
|
12
13
|
style?: CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-part-types.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-part-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,MAAM,WAAW,cAAc;IAC7B,
|
|
1
|
+
{"version":3,"file":"sheet-part-types.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-part-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,6BAA6B;IAC5C,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAC3D,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC;AAC5C,MAAM,MAAM,eAAe,GAAG,6BAA6B,CAAC;AAC5D,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC;AACnD,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC9C,MAAM,MAAM,gBAAgB,GAAG,6BAA6B,CAAC;AAC7D,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC9C,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC"}
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* `aria-labelledby` and `aria-describedby` via matching IDs.
|
|
9
9
|
*/
|
|
10
10
|
export declare const Sheet: {
|
|
11
|
-
readonly Back: ({
|
|
12
|
-
readonly Body: ({
|
|
13
|
-
readonly Close: ({
|
|
14
|
-
readonly Description: ({
|
|
15
|
-
readonly Footer: ({
|
|
16
|
-
readonly Handle: ({
|
|
17
|
-
readonly Header: ({
|
|
18
|
-
readonly Title: ({
|
|
11
|
+
readonly Back: ({ render, className, style, children, }: import("./sheet-part-types").SheetOptionalContentPartProps) => import("react").JSX.Element | null;
|
|
12
|
+
readonly Body: ({ render, className, style, children }: import("./sheet-part-types").SheetPartProps) => import("react").JSX.Element;
|
|
13
|
+
readonly Close: ({ render, className, style, children, }: import("./sheet-part-types").SheetOptionalContentPartProps) => import("react").JSX.Element;
|
|
14
|
+
readonly Description: ({ render, className, style, children }: import("./sheet-part-types").SheetPartProps) => import("react").JSX.Element;
|
|
15
|
+
readonly Footer: ({ render, className, style, children }: import("./sheet-part-types").SheetPartProps) => import("react").JSX.Element;
|
|
16
|
+
readonly Handle: ({ render, className, style, children, }: import("./sheet-part-types").SheetOptionalContentPartProps) => import("react").JSX.Element | null;
|
|
17
|
+
readonly Header: ({ render, className, style, children }: import("./sheet-part-types").SheetPartProps) => import("react").JSX.Element;
|
|
18
|
+
readonly Title: ({ render, className, style, children }: import("./sheet-part-types").SheetPartProps) => import("react").JSX.Element;
|
|
19
19
|
};
|
|
20
20
|
//# sourceMappingURL=sheet-parts.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SheetPartProps } from "./sheet-part-types";
|
|
2
|
-
export declare const SheetTitle: ({
|
|
2
|
+
export declare const SheetTitle: ({ render, className, style, children }: SheetPartProps) => import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=sheet-title.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-title.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-title.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,eAAO,MAAM,UAAU,GAAI,
|
|
1
|
+
{"version":3,"file":"sheet-title.d.ts","sourceRoot":"","sources":["../../src/SheetParts/sheet-title.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,eAAO,MAAM,UAAU,GAAI,wCAAwC,cAAc,gCAgBhF,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Portal } from "@radix-ui/react-portal";
|
|
3
2
|
import { createContext, use, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
3
|
import { createStore, useStore } from "zustand";
|
|
5
4
|
import { useShallow } from "zustand/react/shallow";
|
|
@@ -9,8 +8,10 @@ import { RemoveScroll } from "react-remove-scroll";
|
|
|
9
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
9
|
import { FocusTrap } from "focus-trap-react";
|
|
11
10
|
import { joinClassNames } from "@patternmode/system";
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
11
|
+
import { createPortal } from "react-dom";
|
|
12
|
+
import "@base-ui/react/merge-props";
|
|
13
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
14
|
+
import { ScrollArea } from "@base-ui/react/scroll-area";
|
|
14
15
|
//#region src/springs.ts
|
|
15
16
|
/** Strips the shared token's `type: "spring"` down to Stacksheet's numeric SpringConfig. */
|
|
16
17
|
const toSpringConfig = (spring) => ({
|
|
@@ -298,7 +299,7 @@ const useBodyScale = (config, isOpen, prefersReducedMotion) => {
|
|
|
298
299
|
};
|
|
299
300
|
//#endregion
|
|
300
301
|
//#region src/snap-points.ts
|
|
301
|
-
const SNAP_POINT_RE = /^(
|
|
302
|
+
const SNAP_POINT_RE = /^(\d+(?:\.\d+)?)(px|rem|em|vh|%)$/u;
|
|
302
303
|
const getRootFontSize = () => typeof document === "undefined" ? 16 : Number.parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
303
304
|
const resolveUnitPx = (value, unit, viewportHeight) => {
|
|
304
305
|
if (unit === "px") return value;
|
|
@@ -316,8 +317,8 @@ const resolveSnapPointPx = (point, viewportHeight) => {
|
|
|
316
317
|
if (typeof point === "number") return point <= 1 ? point * viewportHeight : point;
|
|
317
318
|
if (typeof point === "string") {
|
|
318
319
|
const match = SNAP_POINT_RE.exec(point);
|
|
319
|
-
const rawValue = match?.
|
|
320
|
-
const unit = match?.
|
|
320
|
+
const rawValue = match?.[1];
|
|
321
|
+
const unit = match?.[2];
|
|
321
322
|
if (rawValue === void 0 || unit === void 0) return 0;
|
|
322
323
|
return resolveUnitPx(Number.parseFloat(rawValue), unit, viewportHeight);
|
|
323
324
|
}
|
|
@@ -997,6 +998,10 @@ PanelInnerContent.displayName = "PanelInnerContent";
|
|
|
997
998
|
//#endregion
|
|
998
999
|
//#region src/SheetPanel/sheet-panel-focus.tsx
|
|
999
1000
|
const LAYERED_MODAL_SELECTORS = [
|
|
1001
|
+
"[role=\"dialog\"][data-open]",
|
|
1002
|
+
"[role=\"alertdialog\"][data-open]",
|
|
1003
|
+
"[data-base-ui-focus-guard]",
|
|
1004
|
+
"[data-slot=\"tag-selector-content\"]",
|
|
1000
1005
|
"[role=\"dialog\"][data-state=\"open\"]",
|
|
1001
1006
|
"[role=\"alertdialog\"][data-state=\"open\"]",
|
|
1002
1007
|
"[data-radix-popper-content-wrapper]",
|
|
@@ -1612,6 +1617,23 @@ const SheetRenderer = ({ store, config, sheets, componentMap, classNames: classN
|
|
|
1612
1617
|
});
|
|
1613
1618
|
};
|
|
1614
1619
|
//#endregion
|
|
1620
|
+
//#region src/sheet-portal.tsx
|
|
1621
|
+
/**
|
|
1622
|
+
* Minimal client-only portal into `document.body`. Replaces
|
|
1623
|
+
* `@radix-ui/react-portal` — Base UI ships no standalone portal primitive, and
|
|
1624
|
+
* the sheet renderer only ever runs on the client. Mounting is deferred to an
|
|
1625
|
+
* effect so server render and first client render agree (no hydration
|
|
1626
|
+
* mismatch).
|
|
1627
|
+
*/
|
|
1628
|
+
const SheetPortal = ({ children }) => {
|
|
1629
|
+
const [mounted, setMounted] = useState(false);
|
|
1630
|
+
useEffect(() => {
|
|
1631
|
+
setMounted(true);
|
|
1632
|
+
}, []);
|
|
1633
|
+
if (!mounted || typeof document === "undefined") return null;
|
|
1634
|
+
return createPortal(children, document.body);
|
|
1635
|
+
};
|
|
1636
|
+
//#endregion
|
|
1615
1637
|
//#region src/Store/store-args.ts
|
|
1616
1638
|
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
1617
1639
|
const toRecord = (value) => isRecord(value) ? value : {};
|
|
@@ -1933,18 +1955,15 @@ const createStacksheet = (config) => {
|
|
|
1933
1955
|
};
|
|
1934
1956
|
const StacksheetProvider = ({ sheets, children, classNames, layout, renderHeader }) => /* @__PURE__ */ jsxs(StoreContext.Provider, {
|
|
1935
1957
|
value: providerValue,
|
|
1936
|
-
children: [children, /* @__PURE__ */ jsx(
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
store
|
|
1946
|
-
})
|
|
1947
|
-
})]
|
|
1958
|
+
children: [children, /* @__PURE__ */ jsx(SheetPortal, { children: /* @__PURE__ */ jsx(SheetRenderer, {
|
|
1959
|
+
classNames,
|
|
1960
|
+
componentMap,
|
|
1961
|
+
config: resolved,
|
|
1962
|
+
layout,
|
|
1963
|
+
renderHeader,
|
|
1964
|
+
sheets,
|
|
1965
|
+
store
|
|
1966
|
+
}) })]
|
|
1948
1967
|
});
|
|
1949
1968
|
const useSheet = () => {
|
|
1950
1969
|
const { store: s } = useStoreContext();
|
|
@@ -1976,120 +1995,163 @@ const createStacksheet = (config) => {
|
|
|
1976
1995
|
};
|
|
1977
1996
|
};
|
|
1978
1997
|
//#endregion
|
|
1998
|
+
//#region src/SheetParts/sheet-part-element.tsx
|
|
1999
|
+
/**
|
|
2000
|
+
* Renders a sheet part through `render` (or its default tag) via Base UI's
|
|
2001
|
+
* `useRender`. Centralising the hook here lets each part early-return before
|
|
2002
|
+
* constructing the element without tripping the Rules of Hooks.
|
|
2003
|
+
*/
|
|
2004
|
+
const SheetPartElement = ({ defaultTagName, props, render }) => useRender({
|
|
2005
|
+
defaultTagName,
|
|
2006
|
+
props,
|
|
2007
|
+
render
|
|
2008
|
+
});
|
|
2009
|
+
//#endregion
|
|
1979
2010
|
//#region src/SheetParts/sheet-back.tsx
|
|
1980
|
-
const SheetBack = ({
|
|
2011
|
+
const SheetBack = ({ render, className, style, children }) => {
|
|
1981
2012
|
const { back, isNested } = useSheetPanel();
|
|
1982
2013
|
if (!isNested) return null;
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
2014
|
+
return /* @__PURE__ */ jsx(SheetPartElement, {
|
|
2015
|
+
defaultTagName: "button",
|
|
2016
|
+
props: {
|
|
2017
|
+
"aria-label": children === void 0 || children === null ? "Back" : void 0,
|
|
2018
|
+
children: children ?? /* @__PURE__ */ jsx(ArrowLeftIcon, {}),
|
|
2019
|
+
className: joinClassNames(render ? void 0 : "flex min-h-11 min-w-11 shrink-0 cursor-pointer items-center justify-center rounded-md border-none bg-transparent p-0 text-inherit opacity-60 transition-opacity duration-150 hover:opacity-100", className),
|
|
2020
|
+
onClick: back,
|
|
2021
|
+
style,
|
|
2022
|
+
type: render ? void 0 : "button"
|
|
2023
|
+
},
|
|
2024
|
+
render
|
|
1991
2025
|
});
|
|
1992
2026
|
};
|
|
1993
2027
|
//#endregion
|
|
1994
2028
|
//#region src/SheetParts/sheet-body.tsx
|
|
1995
|
-
const
|
|
1996
|
-
|
|
2029
|
+
const SheetBodyRendered = ({ render, className, style, children }) => useRender({
|
|
2030
|
+
props: {
|
|
2031
|
+
children,
|
|
1997
2032
|
className: joinClassNames("relative min-h-0 flex-1", className),
|
|
1998
2033
|
"data-stacksheet-no-drag": "",
|
|
2034
|
+
style
|
|
2035
|
+
},
|
|
2036
|
+
render
|
|
2037
|
+
});
|
|
2038
|
+
const SheetBody = ({ render, className, style, children }) => {
|
|
2039
|
+
if (render !== void 0) return /* @__PURE__ */ jsx(SheetBodyRendered, {
|
|
2040
|
+
className,
|
|
2041
|
+
render,
|
|
1999
2042
|
style,
|
|
2000
2043
|
children
|
|
2001
2044
|
});
|
|
2002
|
-
return /* @__PURE__ */ jsxs(Root, {
|
|
2045
|
+
return /* @__PURE__ */ jsxs(ScrollArea.Root, {
|
|
2003
2046
|
className: joinClassNames("relative flex min-h-0 flex-1 flex-col overflow-hidden", className),
|
|
2004
2047
|
"data-stacksheet-no-drag": "",
|
|
2005
2048
|
style,
|
|
2006
|
-
children: [/* @__PURE__ */ jsx(Viewport, {
|
|
2049
|
+
children: [/* @__PURE__ */ jsx(ScrollArea.Viewport, {
|
|
2007
2050
|
className: "min-h-0 w-full flex-1 overscroll-contain",
|
|
2008
2051
|
children
|
|
2009
|
-
}), /* @__PURE__ */ jsx(Scrollbar, {
|
|
2010
|
-
className: "flex w-2 touch-none select-none p-0.5",
|
|
2052
|
+
}), /* @__PURE__ */ jsx(ScrollArea.Scrollbar, {
|
|
2053
|
+
className: "flex w-2 touch-none select-none p-0.5 opacity-0 transition-opacity data-[hovering]:opacity-100 data-[scrolling]:opacity-100",
|
|
2011
2054
|
orientation: "vertical",
|
|
2012
|
-
children: /* @__PURE__ */ jsx(Thumb, { className: "relative flex-1 rounded bg-current/15" })
|
|
2055
|
+
children: /* @__PURE__ */ jsx(ScrollArea.Thumb, { className: "relative flex-1 rounded bg-current/15" })
|
|
2013
2056
|
})]
|
|
2014
2057
|
});
|
|
2015
2058
|
};
|
|
2016
2059
|
//#endregion
|
|
2017
2060
|
//#region src/SheetParts/sheet-close.tsx
|
|
2018
|
-
const SheetClose = ({
|
|
2061
|
+
const SheetClose = ({ render, className, style, children }) => {
|
|
2019
2062
|
const { close } = useSheetPanel();
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2063
|
+
return /* @__PURE__ */ jsx(SheetPartElement, {
|
|
2064
|
+
defaultTagName: "button",
|
|
2065
|
+
props: {
|
|
2066
|
+
"aria-label": children === void 0 || children === null ? "Close" : void 0,
|
|
2067
|
+
children: children ?? /* @__PURE__ */ jsx(XIcon, {}),
|
|
2068
|
+
className: joinClassNames(render ? void 0 : "absolute right-2 top-2 z-20 flex min-h-11 min-w-11 cursor-pointer items-center justify-center rounded-md border-none bg-transparent p-0 text-inherit opacity-50 transition-opacity duration-150 hover:opacity-100", className),
|
|
2069
|
+
onClick: close,
|
|
2070
|
+
style,
|
|
2071
|
+
type: render ? void 0 : "button"
|
|
2072
|
+
},
|
|
2073
|
+
render
|
|
2028
2074
|
});
|
|
2029
2075
|
};
|
|
2030
2076
|
//#endregion
|
|
2031
2077
|
//#region src/SheetParts/sheet-description.tsx
|
|
2032
|
-
const SheetDescription = ({
|
|
2078
|
+
const SheetDescription = ({ render, className, style, children }) => {
|
|
2033
2079
|
const { panelId, registerDescription } = useSheetPanel();
|
|
2034
2080
|
useEffect(() => registerDescription(), [registerDescription]);
|
|
2035
|
-
return /* @__PURE__ */ jsx(
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2081
|
+
return /* @__PURE__ */ jsx(SheetPartElement, {
|
|
2082
|
+
defaultTagName: "p",
|
|
2083
|
+
props: {
|
|
2084
|
+
children,
|
|
2085
|
+
className,
|
|
2086
|
+
id: `${panelId}-desc`,
|
|
2087
|
+
style
|
|
2088
|
+
},
|
|
2089
|
+
render
|
|
2040
2090
|
});
|
|
2041
2091
|
};
|
|
2042
2092
|
//#endregion
|
|
2043
2093
|
//#region src/SheetParts/sheet-footer.tsx
|
|
2044
|
-
const SheetFooter = ({
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2094
|
+
const SheetFooter = ({ render, className, style, children }) => {
|
|
2095
|
+
return /* @__PURE__ */ jsx(SheetPartElement, {
|
|
2096
|
+
defaultTagName: "footer",
|
|
2097
|
+
props: {
|
|
2098
|
+
children,
|
|
2099
|
+
className: joinClassNames(render ? "shrink-0" : "flex shrink-0 items-center gap-2 border-t px-6 py-3", className),
|
|
2100
|
+
style
|
|
2101
|
+
},
|
|
2102
|
+
render
|
|
2050
2103
|
});
|
|
2051
2104
|
};
|
|
2052
2105
|
//#endregion
|
|
2053
2106
|
//#region src/SheetParts/sheet-handle.tsx
|
|
2054
|
-
const SheetHandle = ({
|
|
2107
|
+
const SheetHandle = ({ render, className, style, children }) => {
|
|
2055
2108
|
const { close, back, isNested, side } = useSheetPanel();
|
|
2056
2109
|
if (side !== "bottom") return null;
|
|
2057
2110
|
const dismiss = isNested ? back : close;
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
"
|
|
2068
|
-
|
|
2069
|
-
|
|
2111
|
+
return /* @__PURE__ */ jsx(SheetPartElement, {
|
|
2112
|
+
defaultTagName: "button",
|
|
2113
|
+
props: {
|
|
2114
|
+
"aria-label": "Dismiss",
|
|
2115
|
+
children: children ?? /* @__PURE__ */ jsx("div", {
|
|
2116
|
+
"aria-hidden": "true",
|
|
2117
|
+
className: "h-1 w-9 rounded-sm bg-current/25"
|
|
2118
|
+
}),
|
|
2119
|
+
className: joinClassNames(render ? void 0 : "flex shrink-0 cursor-grab touch-none items-center justify-center border-none bg-transparent pt-4 pb-1 text-inherit", className),
|
|
2120
|
+
"data-stacksheet-handle": "",
|
|
2121
|
+
onClick: dismiss,
|
|
2122
|
+
style,
|
|
2123
|
+
type: render ? void 0 : "button"
|
|
2124
|
+
},
|
|
2125
|
+
render
|
|
2070
2126
|
});
|
|
2071
2127
|
};
|
|
2072
2128
|
//#endregion
|
|
2073
2129
|
//#region src/SheetParts/sheet-header.tsx
|
|
2074
|
-
const SheetHeader = ({
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2130
|
+
const SheetHeader = ({ render, className, style, children }) => {
|
|
2131
|
+
return /* @__PURE__ */ jsx(SheetPartElement, {
|
|
2132
|
+
defaultTagName: "header",
|
|
2133
|
+
props: {
|
|
2134
|
+
children,
|
|
2135
|
+
className: joinClassNames(render ? "shrink-0" : "flex shrink-0 items-center justify-between gap-3", className),
|
|
2136
|
+
style
|
|
2137
|
+
},
|
|
2138
|
+
render
|
|
2080
2139
|
});
|
|
2081
2140
|
};
|
|
2082
2141
|
//#endregion
|
|
2083
2142
|
//#region src/SheetParts/sheet-title.tsx
|
|
2084
|
-
const SheetTitle = ({
|
|
2143
|
+
const SheetTitle = ({ render, className, style, children }) => {
|
|
2085
2144
|
const { panelId, registerTitle } = useSheetPanel();
|
|
2086
2145
|
useEffect(() => registerTitle(), [registerTitle]);
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2146
|
+
return /* @__PURE__ */ jsx(SheetPartElement, {
|
|
2147
|
+
defaultTagName: "h2",
|
|
2148
|
+
props: {
|
|
2149
|
+
children,
|
|
2150
|
+
className: joinClassNames(render ? void 0 : "font-semibold text-sm", className),
|
|
2151
|
+
id: `${panelId}-title`,
|
|
2152
|
+
style
|
|
2153
|
+
},
|
|
2154
|
+
render
|
|
2093
2155
|
});
|
|
2094
2156
|
};
|
|
2095
2157
|
//#endregion
|