@plexui/ui 0.34.1 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/components/Alert/Alert.js +2 -2
- package/dist/es/components/Alert/Alert.js.map +1 -1
- package/dist/es/components/Alert/index.js.map +1 -1
- package/dist/es/components/Sidebar/Sidebar.js +61 -6
- package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/es/components/Sidebar/useSidebarContext.js +15 -16
- package/dist/es/components/Sidebar/useSidebarContext.js.map +1 -1
- package/dist/es/lib/phoneDrawer.js +207 -0
- package/dist/es/lib/phoneDrawer.js.map +1 -0
- package/dist/types/components/Alert/Alert.d.ts +8 -1
- package/dist/types/components/Alert/index.d.ts +1 -1
- package/dist/types/components/Sidebar/Sidebar.d.ts +11 -0
- package/dist/types/components/Sidebar/useSidebarContext.d.ts +14 -1
- package/dist/types/lib/phoneDrawer.d.ts +44 -0
- package/package.json +2 -2
|
@@ -8,7 +8,7 @@ import {} from "../../types.js";
|
|
|
8
8
|
import { CheckCircle, Info, Warning, X } from "../Icon/index.js";
|
|
9
9
|
import { Button } from "../Button/index.js";
|
|
10
10
|
import s from "@plexui/styles/components/Alert/Alert.module.css";
|
|
11
|
-
export const Alert = ({ color = "primary", variant = "outline", title, description, actions, actionsPlacement, indicator, className, actionsClassName, onDismiss, banner = false, ref, ...restProps }) => {
|
|
11
|
+
export const Alert = ({ color = "primary", variant = "outline", title, description, actions, actionsPlacement, mobileActions = "capsules", indicator, className, actionsClassName, onDismiss, banner = false, ref, ...restProps }) => {
|
|
12
12
|
const containerRef = useRef(null);
|
|
13
13
|
const actionsRef = useRef(null);
|
|
14
14
|
const [actionsAutoPlacement, setActionsAutoPlacement] = useState("end");
|
|
@@ -22,7 +22,7 @@ export const Alert = ({ color = "primary", variant = "outline", title, descripti
|
|
|
22
22
|
setActionsAutoPlacement(placement);
|
|
23
23
|
}
|
|
24
24
|
}, [containerWidth]);
|
|
25
|
-
return (_jsxs("div", { ref: mergeRefs([ref, containerRef]), className: clsx(s.Alert, className), "data-variant": variant, "data-color": color, role: color === "danger" ? "alert" : undefined, "data-actions-placement": actionsPlacement ?? actionsAutoPlacement, "data-banner": banner ? "" : undefined, ...restProps, children: [indicator === false ? null : (_jsx("div", { className: s.Indicator, children: indicator ?? _jsx(Indicator, { color: color }) })), _jsxs("div", { className: s.Content, children: [_jsxs("div", { className: s.Message, children: [title && _jsx("div", { className: s.Title, children: title }), description && _jsx("div", { className: s.Description, children: description })] }), (actions || onDismiss) && (_jsxs("div", { className: clsx(s.Actions, actionsClassName), ref: actionsRef, children: [actions, onDismiss && (_jsx(Button, { type: "button", onClick: onDismiss, color: color, variant: "soft", pill: true, className: s.DismissButton, children: "Dismiss" }))] }))] }), onDismiss && (_jsx(Button, { type: "button", onClick: onDismiss, color: "secondary", variant: "soft", size: "sm", uniform: true, pill: true, "aria-label": "Dismiss", className: s.CloseButton, children: _jsx(X, {}) }))] }));
|
|
25
|
+
return (_jsxs("div", { ref: mergeRefs([ref, containerRef]), className: clsx(s.Alert, className), "data-variant": variant, "data-color": color, role: color === "danger" ? "alert" : undefined, "data-actions-placement": actionsPlacement ?? actionsAutoPlacement, "data-banner": banner ? "" : undefined, "data-mobile-actions": mobileActions === "own" ? "own" : undefined, ...restProps, children: [indicator === false ? null : (_jsx("div", { className: s.Indicator, children: indicator ?? _jsx(Indicator, { color: color }) })), _jsxs("div", { className: s.Content, children: [_jsxs("div", { className: s.Message, children: [title && _jsx("div", { className: s.Title, children: title }), description && _jsx("div", { className: s.Description, children: description })] }), (actions || onDismiss) && (_jsxs("div", { className: clsx(s.Actions, actionsClassName), ref: actionsRef, children: [actions, onDismiss && (_jsx(Button, { type: "button", onClick: onDismiss, color: color, variant: "soft", pill: true, className: s.DismissButton, children: "Dismiss" }))] }))] }), onDismiss && (_jsx(Button, { type: "button", onClick: onDismiss, color: "secondary", variant: "soft", size: "sm", uniform: true, pill: true, "aria-label": "Dismiss", className: s.CloseButton, children: _jsx(X, {}) }))] }));
|
|
26
26
|
};
|
|
27
27
|
export const Indicator = ({ color }) => {
|
|
28
28
|
// Choose a default icon based on the color (which signals intention)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../../src/components/Alert/Alert.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA4B,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAsC,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,CAAC,MAAM,kDAAkD,CAAA;
|
|
1
|
+
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../../src/components/Alert/Alert.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA4B,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAsC,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAiDhE,MAAM,CAAC,MAAM,KAAK,GA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M,SAAS,GAAG,CAAC,EAAE,KAAK,EAAkC,EAAE,EAAE;IACrE,qEAAqE;IACrE,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,KAAC,OAAO,KAAG,CAAA;QACpB,KAAK,SAAS;YACZ,OAAO,KAAC,WAAW,KAAG,CAAA;QACxB;YACE,OAAO,KAAC,IAAI,KAAG,CAAA;IACnB,CAAC;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { type ReactNode, type Ref, useEffect, useRef, useState } from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport { useResizeObserver } from \"usehooks-ts\"\nimport { type SemanticColors, type Variants } from \"../../types\"\nimport { CheckCircle, Info, Warning, X } from \"../Icon\"\nimport { Button } from \"../Button\"\nimport s from \"@plexui/styles/components/Alert/Alert.module.css\"\n\nexport type AlertMobileActions = \"capsules\" | \"own\"\n\nexport type AlertProps = {\n /**\n * Color for the button\n * @default primary\n */\n color?: SemanticColors<\n \"primary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n >\n /**\n * Style variant for the Button\n * @default fill\n */\n variant?: Variants<\"solid\" | \"soft\" | \"outline\">\n /** Title displayed in the alert. */\n title?: ReactNode\n /** Description text displayed in the alert */\n description?: ReactNode\n /** Actions associated with the Alert. */\n actions?: ReactNode\n /** Sets the placement of `actions` always on the end or the bottom. Default behavior is automatic placement based on sizing. */\n actionsPlacement?: \"end\" | \"bottom\"\n /**\n * How the actions show at 767px and below: 50px capsules side by side, as the buttons of an iOS tip (TipKit), or\n * the buttons as given, at their own size, for an alert inside a block of buttons of its own.\n * @default \"capsules\"\n */\n mobileActions?: AlertMobileActions\n /** Optional override for the default indicator of the alert. When `false`, no indicator is shown. */\n indicator?: ReactNode | false\n /** Class applied to the alert container */\n className?: string\n /** Class applied to the actions container */\n actionsClassName?: string\n /** Callback when dismiss button is clicked. Shows dismiss button when provided. */\n onDismiss?: () => void\n /**\n * A full-width strip across the top or bottom of a page or panel (offline,\n * read-only, a new version): square corners and lines above and below only.\n * @default false\n */\n banner?: boolean\n /** Ref applied to the alert container */\n ref?: Ref<HTMLDivElement>\n}\n\nexport const Alert = ({\n color = \"primary\",\n variant = \"outline\",\n title,\n description,\n actions,\n actionsPlacement,\n mobileActions = \"capsules\",\n indicator,\n className,\n actionsClassName,\n onDismiss,\n banner = false,\n ref,\n ...restProps\n}: AlertProps) => {\n const containerRef = useRef<HTMLDivElement>(null)\n const actionsRef = useRef<HTMLDivElement>(null)\n const [actionsAutoPlacement, setActionsAutoPlacement] = useState<\"end\" | \"bottom\">(\"end\")\n // @ts-expect-error -- Type issue in usehooks-ts\n const { width: containerWidth } = useResizeObserver({ ref: containerRef })\n\n useEffect(() => {\n const actionsWidth = actionsRef.current?.clientWidth ?? 0\n\n if (actionsWidth && containerWidth) {\n // If actions are larger than a third of the container width, wrap them.\n const placement = actionsWidth > containerWidth / 3 ? \"bottom\" : \"end\"\n setActionsAutoPlacement(placement)\n }\n }, [containerWidth])\n\n return (\n <div\n ref={mergeRefs([ref, containerRef])}\n className={clsx(s.Alert, className)}\n data-variant={variant}\n data-color={color}\n role={color === \"danger\" ? \"alert\" : undefined}\n data-actions-placement={actionsPlacement ?? actionsAutoPlacement}\n data-banner={banner ? \"\" : undefined}\n data-mobile-actions={mobileActions === \"own\" ? \"own\" : undefined}\n {...restProps}\n >\n {indicator === false ? null : (\n <div className={s.Indicator}>{indicator ?? <Indicator color={color} />}</div>\n )}\n <div className={s.Content}>\n <div className={s.Message}>\n {title && <div className={s.Title}>{title}</div>}\n {description && <div className={s.Description}>{description}</div>}\n </div>\n {(actions || onDismiss) && (\n <div className={clsx(s.Actions, actionsClassName)} ref={actionsRef}>\n {actions}\n {onDismiss && (\n <Button type=\"button\" onClick={onDismiss} color={color} variant=\"soft\" pill className={s.DismissButton}>\n Dismiss\n </Button>\n )}\n </div>\n )}\n </div>\n {/* On a phone the alert is dismissed with a close button in its corner, as an iOS tip is */}\n {onDismiss && (\n <Button type=\"button\" onClick={onDismiss} color=\"secondary\" variant=\"soft\" size=\"sm\" uniform pill aria-label=\"Dismiss\" className={s.CloseButton}>\n <X />\n </Button>\n )}\n </div>\n )\n}\n\nexport const Indicator = ({ color }: { color: AlertProps[\"color\"] }) => {\n // Choose a default icon based on the color (which signals intention)\n switch (color) {\n case \"warning\":\n case \"caution\":\n case \"danger\":\n return <Warning />\n case \"success\":\n return <CheckCircle />\n default:\n return <Info />\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Alert/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Alert/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA4C,MAAM,SAAS,CAAA","sourcesContent":["export { Alert, type AlertMobileActions, type AlertProps } from \"./Alert\"\n"]}
|
|
@@ -66,12 +66,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
66
66
|
*/
|
|
67
67
|
import clsx from "clsx";
|
|
68
68
|
import { Slot } from "radix-ui";
|
|
69
|
-
import {
|
|
69
|
+
import { mergeRefs } from "react-merge-refs";
|
|
70
|
+
import { cloneElement, createContext, forwardRef, isValidElement, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, } from "react";
|
|
70
71
|
import { Button } from "../Button/index.js";
|
|
71
72
|
import { ChevronRightMd, Disclosure, Search as SearchIcon, Sidebar as SidebarIcon, SidebarMenuMobile, X } from "../Icon/index.js";
|
|
72
73
|
import { Input } from "../Input/index.js";
|
|
73
74
|
import { Tooltip } from "../Tooltip/index.js";
|
|
74
75
|
import s from "@plexui/styles/components/Sidebar/Sidebar.module.css";
|
|
76
|
+
import { attachDrawerSwipe, closeOnUnhandledEscape, drawerInitialFocus, loopDrawerFocus } from "../../lib/phoneDrawer.js";
|
|
75
77
|
import { SidebarProvider, useSidebar, } from "./useSidebarContext.js";
|
|
76
78
|
// Helper to filter out props that shouldn't be spread to the DOM (e.g. injected by MDX)
|
|
77
79
|
const cleanProps = (props) => {
|
|
@@ -80,7 +82,8 @@ const cleanProps = (props) => {
|
|
|
80
82
|
};
|
|
81
83
|
// Re-export provider and hook
|
|
82
84
|
export { SidebarProvider, useSidebar };
|
|
83
|
-
// Rows inside the mobile drawer end with a disclosure chevron (see the drawer list in the styles)
|
|
85
|
+
// Rows inside the mobile drawer end with a disclosure chevron (see the drawer list in the styles), unless the drawer
|
|
86
|
+
// leaves it out (`disclosure={false}`).
|
|
84
87
|
const SidebarDrawerContext = createContext(false);
|
|
85
88
|
/** The chevron of a drawer row that leads to another page. */
|
|
86
89
|
const MenuDisclosure = () => (_jsx("span", { className: s.MenuDisclosure, "aria-hidden": "true", children: _jsx(Disclosure, {}) }));
|
|
@@ -219,7 +222,11 @@ export const SidebarCardContent = forwardRef(({ className, ...props }, ref) => (
|
|
|
219
222
|
SidebarCardContent.displayName = "SidebarCardContent";
|
|
220
223
|
export const SidebarCardFooter = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: clsx(s.CardFooter, className), ...cleanProps(props) })));
|
|
221
224
|
SidebarCardFooter.displayName = "SidebarCardFooter";
|
|
222
|
-
export const SidebarInset = forwardRef(({ className, ...props }, ref) =>
|
|
225
|
+
export const SidebarInset = forwardRef(({ className, ...props }, ref) => {
|
|
226
|
+
const { isMobile, openMobile } = useSidebar();
|
|
227
|
+
// Behind the open phone drawer the page takes no focus or touch; `inert` of your own wins
|
|
228
|
+
return (_jsx("main", { ref: ref, className: clsx(s.Inset, className), inert: isMobile && openMobile ? true : undefined, ...cleanProps(props) }));
|
|
229
|
+
});
|
|
223
230
|
SidebarInset.displayName = "SidebarInset";
|
|
224
231
|
export const SidebarLayout = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: clsx(s.SidebarLayout, className), ...cleanProps(props) })));
|
|
225
232
|
SidebarLayout.displayName = "SidebarLayout";
|
|
@@ -249,9 +256,57 @@ export const SidebarMobileMenuButton = forwardRef(({ className, onClick, ...prop
|
|
|
249
256
|
}, "aria-label": openMobile ? "Close menu" : "Open menu", ...cleanProps(props), children: _jsxs("span", { className: s.MobileMenuIcon, children: [_jsx(SidebarMenuMobile, { className: s.MobileMenuGlyph, "data-glyph": "menu" }), _jsx(X, { className: s.MobileMenuGlyph, "data-glyph": "close" })] }) }));
|
|
250
257
|
});
|
|
251
258
|
SidebarMobileMenuButton.displayName = "SidebarMobileMenuButton";
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
259
|
+
/**
|
|
260
|
+
* The phone drawer: a modal dialog while it is open. Focus moves into it and Tab goes round its controls, the page
|
|
261
|
+
* behind is inert (SidebarInset), Escape inside it closes it after any layer over it has taken its own, and focus
|
|
262
|
+
* goes back to the control that opened it. A swipe in from the edge it slides from opens it and a swipe back closes
|
|
263
|
+
* it (lib/phoneDrawer).
|
|
264
|
+
*/
|
|
265
|
+
export const SidebarMobile = forwardRef(({ className, children, contained, disclosure = true, onKeyDown, ...props }, ref) => {
|
|
266
|
+
const { isMobile, openMobile, setOpenMobile } = useSidebar();
|
|
267
|
+
const drawerRef = useRef(null);
|
|
268
|
+
const state = useRef({ open: openMobile, isMobile, setOpenMobile });
|
|
269
|
+
state.current = { open: openMobile, isMobile, setOpenMobile };
|
|
270
|
+
// Focus moves in on open and back to what opened the drawer on close. A drawer that is not contained shows only
|
|
271
|
+
// at phone width, so going back to it from a wide window moves focus in again.
|
|
272
|
+
const shown = openMobile && (isMobile || Boolean(contained));
|
|
273
|
+
useEffect(() => {
|
|
274
|
+
const drawer = drawerRef.current;
|
|
275
|
+
if (!shown || !drawer)
|
|
276
|
+
return;
|
|
277
|
+
const trigger = document.activeElement;
|
|
278
|
+
if (!drawer.contains(document.activeElement))
|
|
279
|
+
drawerInitialFocus(drawer).focus({ preventScroll: true });
|
|
280
|
+
return () => {
|
|
281
|
+
const active = document.activeElement;
|
|
282
|
+
const lost = !active || active === document.body || drawer.contains(active);
|
|
283
|
+
if (lost && trigger instanceof HTMLElement && trigger.isConnected && !drawer.contains(trigger)) {
|
|
284
|
+
trigger.focus({ preventScroll: true });
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}, [shown]);
|
|
288
|
+
useEffect(() => {
|
|
289
|
+
const drawer = drawerRef.current;
|
|
290
|
+
const root = drawer?.closest("[data-mobile-menu]");
|
|
291
|
+
if (!drawer || !root)
|
|
292
|
+
return;
|
|
293
|
+
return attachDrawerSwipe({
|
|
294
|
+
root,
|
|
295
|
+
drawer,
|
|
296
|
+
isOpen: () => state.current.open,
|
|
297
|
+
setOpen: (open) => state.current.setOpenMobile(open),
|
|
298
|
+
enabled: () => state.current.isMobile,
|
|
299
|
+
});
|
|
300
|
+
}, []);
|
|
301
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: clsx(s.MobileBackdrop, contained && s.contained), onClick: () => setOpenMobile(false), "aria-hidden": "true" }), _jsx("div", { ref: mergeRefs([ref, drawerRef]), role: "dialog", "aria-modal": openMobile ? true : undefined, "aria-label": "Menu", tabIndex: -1, inert: openMobile ? undefined : true, className: clsx(s.MobileSidebar, contained && s.contained, className), onKeyDown: (event) => {
|
|
302
|
+
// Your handler runs first and can keep the drawer open with preventDefault()
|
|
303
|
+
onKeyDown?.(event);
|
|
304
|
+
const drawer = drawerRef.current;
|
|
305
|
+
if (!openMobile || !drawer)
|
|
306
|
+
return;
|
|
307
|
+
loopDrawerFocus(event.nativeEvent, drawer);
|
|
308
|
+
closeOnUnhandledEscape(event.nativeEvent, drawer, () => state.current.setOpenMobile(false));
|
|
309
|
+
}, ...cleanProps(props), children: _jsx(SidebarDrawerContext.Provider, { value: disclosure, children: children }) })] }));
|
|
255
310
|
});
|
|
256
311
|
SidebarMobile.displayName = "SidebarMobile";
|
|
257
312
|
export const SidebarMobileHeader = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: clsx(s.MobileHeader, className), ...cleanProps(props) })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.js","sourceRoot":"","sources":["../../../../src/components/Sidebar/Sidebar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EACL,YAAY,EACZ,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,eAAe,EACf,QAAQ,GAIT,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,IAAI,UAAU,EAAE,OAAO,IAAI,WAAW,EAAE,iBAAiB,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AACxH,OAAO,EAAE,KAAK,EAAmB,MAAM,UAAU,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,CAAC,MAAM,sDAAsD,CAAA;AACpE,OAAO,EACL,eAAe,EACf,UAAU,GAKX,MAAM,qBAAqB,CAAA;AAE5B,wFAAwF;AACxF,MAAM,UAAU,GAAG,CAAmB,KAAQ,EAA0B,EAAE;IACxE,MAAM,EAAE,aAAa,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,KAAwC,CAAA;IAC9E,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,8BAA8B;AAC9B,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,CAAA;AAGtC,mGAAmG;AACnG,MAAM,oBAAoB,GAAG,aAAa,CAAC,KAAK,CAA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C,CAAC,YAAY,EAAE,SAAS,CAAC,KAAM,UAAU,CAAC,KAAK,CAAC,GAAI,CACrF,CACF,CAAA;AACD,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAA;AAQvD,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CACpC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAChC,cAAK,SAAS,EAAE,CAAC,CAAC,KAAK,YACrB,KAAC,KAAK,IACJ,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,KAAC,UAAU,KAAG,KAC1B,UAAU,CAAC,KAAK,CAAC,GACrB,GACE,CACP,CACF,CAAA;AACD,YAAY,CAAC,WAAW,GAAG,cAAc,CAAA;AAQzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAC1C,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAChC,cAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,KAAM,UAAU,CAAC,KAAK,CAAC,GAAI,CACpF,CACF,CAAA;AACD,kBAAkB,CAAC,WAAW,GAAG,oBAAoB,CAAA","sourcesContent":["\"use client\"\n\n/**\n * Sidebar Component - Composable navigation sidebar\n *\n * API SPECIFICATION:\n *\n * SidebarProvider\n * - defaultOpen?: boolean (default: true)\n * - open?: boolean (controlled)\n * - onOpenChange?: (open: boolean) => void\n * - collapsible?: \"offcanvas\" | \"icon\" | \"none\" (default: \"offcanvas\")\n *\n * Sidebar\n * - side?: \"left\" | \"right\" (default: \"left\")\n * - variant?: \"sidebar\" | \"docs\" (default: \"sidebar\")\n *\n * SidebarHeader / SidebarContent / SidebarFooter\n * - Standard container props\n *\n * SidebarGroup\n * - defaultOpen?: boolean (default: true)\n * - open?: boolean (controlled)\n *\n * SidebarGroupLabel / SidebarGroupAction / SidebarGroupContent\n * - Standard container props\n *\n * SidebarMenu / SidebarMenuItem\n * - Standard container props\n *\n * SidebarMenuButton\n * - isActive?: boolean (default: false)\n * - size?: \"sm\" | \"md\" | \"lg\" (default: \"md\")\n * - tooltip?: string | ReactNode\n * - asChild?: boolean\n *\n * SidebarMenuAction / SidebarMenuBadge\n * - Standard container props\n *\n * SidebarMenuSkeleton\n * - showIcon?: boolean (default: true)\n *\n * SidebarMenuSub / SidebarMenuSubItem / SidebarMenuSubButton\n * - Same as parent menu components\n *\n * SidebarSeparator\n * - Standard separator props\n *\n * SidebarCard / SidebarCardHeader / SidebarCardContent / SidebarCardFooter\n * - variant?: \"default\" | \"elevated\"\n * - dismissible?: boolean\n * - onDismiss?: () => void\n *\n * SidebarInset\n * - Standard container for main content area\n *\n * SidebarTrigger\n * - Uses Button component internally\n * - Returns null when collapsible=\"none\"\n *\n * SidebarMobileMenuButton\n * - Mobile menu button: the SidebarMenuMobile icon turns into X\n *\n * SidebarInput\n * - shortcut?: string (keyboard shortcut display)\n */\n\nimport clsx from \"clsx\"\nimport { Slot } from \"radix-ui\"\nimport {\n cloneElement,\n createContext,\n forwardRef,\n isValidElement,\n useCallback,\n useContext,\n useLayoutEffect,\n useState,\n type ComponentProps,\n type PointerEvent,\n type ReactNode,\n} from \"react\"\n\nimport { Button } from \"../Button\"\nimport { ChevronRightMd, Disclosure, Search as SearchIcon, Sidebar as SidebarIcon, SidebarMenuMobile, X } from \"../Icon\"\nimport { Input, type InputProps } from \"../Input\"\nimport { Tooltip } from \"../Tooltip\"\nimport s from \"@plexui/styles/components/Sidebar/Sidebar.module.css\"\nimport {\n SidebarProvider,\n useSidebar,\n type SidebarCollapsible,\n type SidebarSide,\n type SidebarProviderVariant,\n type SidebarVariant,\n} from \"./useSidebarContext\"\n\n// Helper to filter out props that shouldn't be spread to the DOM (e.g. injected by MDX)\nconst cleanProps = <P extends object>(props: P): Omit<P, \"data-toggle\"> => {\n const { \"data-toggle\": _, ...rest } = props as P & { \"data-toggle\"?: unknown }\n return rest\n}\n\n// Re-export provider and hook\nexport { SidebarProvider, useSidebar }\nexport type { SidebarCollapsible, SidebarProviderVariant, SidebarSide, SidebarVariant }\n\n// Rows inside the mobile drawer end with a disclosure chevron (see the drawer list in the styles).\nconst SidebarDrawerContext = createContext(false)\n\n/** The chevron of a drawer row that leads to another page. */\nconst MenuDisclosure = () => (\n <span className={s.MenuDisclosure} aria-hidden=\"true\">\n <Disclosure />\n </span>\n)\n\n// =============================================\n// Sidebar Root\n// =============================================\n\nexport type SidebarProps = ComponentProps<\"aside\"> & {\n /**\n * The side the sidebar is on.\n * @default \"left\"\n */\n side?: SidebarSide\n /**\n * The visual variant of the sidebar.\n * @default \"sidebar\"\n */\n variant?: SidebarVariant\n}\n\nexport const Sidebar = forwardRef<HTMLElement, SidebarProps>(\n ({ side = \"left\", variant = \"sidebar\", className, children, ...props }, ref) => {\n const { collapsible, isMobile } = useSidebar()\n\n // Skip rendering sidebar on mobile for offcanvas mode\n if (isMobile && collapsible === \"offcanvas\") {\n return null\n }\n\n return (\n <aside\n ref={ref}\n data-side={side}\n data-variant={variant}\n className={clsx(s.Sidebar, className)}\n {...cleanProps(props)}\n >\n {children}\n </aside>\n )\n },\n)\nSidebar.displayName = \"Sidebar\"\n\n// =============================================\n// Sidebar Sections\n// =============================================\n\nexport type SidebarHeaderProps = ComponentProps<\"div\">\n\nexport const SidebarHeader = forwardRef<HTMLDivElement, SidebarHeaderProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.Header, className)} {...cleanProps(props)} />\n ),\n)\nSidebarHeader.displayName = \"SidebarHeader\"\n\nexport type SidebarContentProps = ComponentProps<\"div\">\n\nexport const SidebarContent = forwardRef<HTMLDivElement, SidebarContentProps>(\n ({ className, ...props }, ref) => {\n const [contentEl, setContentEl] = useState<HTMLDivElement | null>(null)\n const setRef = useCallback(\n (el: HTMLDivElement | null) => {\n setContentEl(el)\n if (typeof ref === \"function\") ref(el)\n else if (ref) (ref as { current: HTMLDivElement | null }).current = el\n },\n [ref],\n )\n\n useLayoutEffect(() => {\n if (!contentEl) return\n const sidebar = contentEl.parentElement\n if (!sidebar) return\n\n const update = () => {\n const hasOverflow = contentEl.scrollHeight > contentEl.clientHeight\n sidebar.setAttribute(\"data-content-scrollable\", hasOverflow ? \"true\" : \"false\")\n }\n update()\n const ro = new ResizeObserver(update)\n ro.observe(contentEl)\n return () => ro.disconnect()\n }, [contentEl])\n\n return <div ref={setRef} className={clsx(s.Content, className)} {...cleanProps(props)} />\n },\n)\nSidebarContent.displayName = \"SidebarContent\"\n\nexport type SidebarFooterProps = ComponentProps<\"div\">\n\nexport const SidebarFooter = forwardRef<HTMLDivElement, SidebarFooterProps>(\n ({ className, children, ...props }, ref) => (\n <div ref={ref} className={clsx(s.Footer, className)} {...cleanProps(props)}>\n <div className={s.FooterSeparator} />\n {children}\n </div>\n ),\n)\nSidebarFooter.displayName = \"SidebarFooter\"\n\nexport type SidebarRailProps = ComponentProps<\"div\">\n\nexport const SidebarRail = forwardRef<HTMLDivElement, SidebarRailProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.Rail, className)} {...cleanProps(props)} />\n ),\n)\nSidebarRail.displayName = \"SidebarRail\"\n\n// =============================================\n// Groups\n// =============================================\n\nexport type SidebarGroupProps = ComponentProps<\"div\"> & {\n /**\n * Whether the group is open initially. A closed group hides its `SidebarGroupContent`.\n * @default true\n */\n defaultOpen?: boolean\n /**\n * Controlled open state. The group has no toggle of its own: change `open` from your own control.\n */\n open?: boolean\n}\n\nexport const SidebarGroup = forwardRef<HTMLDivElement, SidebarGroupProps>(\n ({ defaultOpen = true, open: openProp, className, ...props }, ref) => {\n // The initial value only, like an uncontrolled input's defaultValue\n const [initialOpen] = useState(defaultOpen)\n const open = openProp ?? initialOpen\n\n return (\n <div\n ref={ref}\n data-state={open ? \"open\" : \"closed\"}\n className={clsx(s.Group, className)}\n {...cleanProps(props)}\n />\n )\n },\n)\nSidebarGroup.displayName = \"SidebarGroup\"\n\nexport type SidebarGroupLabelProps = ComponentProps<\"span\"> & {\n asChild?: boolean\n /**\n * Size variant for the label.\n * - \"sm\": Compact style for dashboard/settings sidebars\n * - \"lg\": Documentation style with larger text and more spacing\n * @default \"lg\"\n */\n size?: \"sm\" | \"lg\"\n}\n\nexport const SidebarGroupLabel = forwardRef<HTMLSpanElement, SidebarGroupLabelProps>(\n ({ asChild = false, size = \"lg\", className, ...props }, ref) => {\n const Comp = asChild ? Slot.Root : \"span\"\n return (\n <Comp\n ref={ref}\n data-size={size}\n className={clsx(s.GroupLabel, className)}\n {...cleanProps(props)}\n />\n )\n },\n)\nSidebarGroupLabel.displayName = \"SidebarGroupLabel\"\n\nexport type SidebarGroupActionProps = ComponentProps<\"div\">\n\nexport const SidebarGroupAction = forwardRef<HTMLDivElement, SidebarGroupActionProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.GroupAction, className)} {...cleanProps(props)} />\n ),\n)\nSidebarGroupAction.displayName = \"SidebarGroupAction\"\n\nexport type SidebarGroupContentProps = ComponentProps<\"div\">\n\nexport const SidebarGroupContent = forwardRef<HTMLDivElement, SidebarGroupContentProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.GroupContent, className)} {...cleanProps(props)} />\n ),\n)\nSidebarGroupContent.displayName = \"SidebarGroupContent\"\n\n// =============================================\n// Menu\n// =============================================\n\nexport type SidebarMenuProps = ComponentProps<\"ul\">\n\nexport const SidebarMenu = forwardRef<HTMLUListElement, SidebarMenuProps>(\n ({ className, ...props }, ref) => (\n <ul ref={ref} className={clsx(s.Menu, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenu.displayName = \"SidebarMenu\"\n\nexport type SidebarMenuItemProps = ComponentProps<\"li\"> & {\n expanded?: boolean\n}\n\nexport const SidebarMenuItem = forwardRef<HTMLLIElement, SidebarMenuItemProps>(\n ({ expanded, className, ...props }, ref) => (\n <li\n ref={ref}\n data-expanded={expanded ? \"true\" : undefined}\n className={clsx(s.MenuItem, className)}\n {...cleanProps(props)}\n />\n ),\n)\nSidebarMenuItem.displayName = \"SidebarMenuItem\"\n\n// =============================================\n// Menu Button\n// =============================================\n\nexport type SidebarMenuButtonProps = ComponentProps<\"button\"> & {\n /**\n * Whether the button is in an active/highlighted state.\n * @default false\n */\n isActive?: boolean\n /**\n * Optional tooltip to show when the sidebar is collapsed.\n */\n tooltip?: string | ReactNode\n /**\n * Whether to render the button as a custom element via Slot.\n * @default false\n */\n asChild?: boolean\n}\n\n// Shared by every row of the rail: moving to the next one shows its label at once.\nlet railLeftAt = 0\n\nexport const SidebarMenuButton = forwardRef<HTMLButtonElement, SidebarMenuButtonProps>(\n ({ isActive = false, tooltip, asChild = false, className, children, onPointerEnter, onPointerLeave, ...props }, ref) => {\n const { state, isMobile } = useSidebar()\n const inDrawer = useContext(SidebarDrawerContext)\n const [openDelay, setOpenDelay] = useState<number>()\n const Comp = asChild ? Slot.Root : \"button\"\n const disclosure = inDrawer ? <MenuDisclosure /> : null\n // With asChild the child element is the button, so the inner wrapper\n // goes inside it. Wrapping the child instead would make Slot merge the\n // button props onto the wrapper span.\n const content =\n asChild && isValidElement<{ children?: ReactNode }>(children) ? (\n cloneElement(\n children,\n undefined,\n <span className={s.MenuButtonInner}>{children.props.children}{disclosure}</span>,\n )\n ) : (\n <span className={s.MenuButtonInner}>{children}{disclosure}</span>\n )\n\n const button = (\n <Comp\n ref={ref}\n data-active={isActive ? \"true\" : \"false\"}\n aria-current={isActive ? \"page\" : undefined}\n className={clsx(s.MenuButton, className)}\n onPointerEnter={(event: PointerEvent<HTMLButtonElement>) => {\n onPointerEnter?.(event)\n if (tooltip) setOpenDelay(Date.now() - railLeftAt < 300 ? 0 : undefined)\n }}\n onPointerLeave={(event: PointerEvent<HTMLButtonElement>) => {\n onPointerLeave?.(event)\n if (tooltip) railLeftAt = Date.now()\n }}\n {...cleanProps(props)}\n >\n {content}\n </Comp>\n )\n\n // The tooltip shows when collapsed (icon mode) and not on mobile. It wraps\n // the row in every state, so the row stays mounted and its label can fade.\n if (tooltip) {\n return (\n <Tooltip content={state === \"collapsed\" && !isMobile ? tooltip : null} openDelay={openDelay} side=\"right\">\n {button}\n </Tooltip>\n )\n }\n\n return button\n },\n)\nSidebarMenuButton.displayName = \"SidebarMenuButton\"\n\n// =============================================\n// Menu Button Parts\n// =============================================\n\nexport type SidebarMenuButtonIconProps = ComponentProps<\"span\">\n\nexport const SidebarMenuButtonIcon = forwardRef<HTMLSpanElement, SidebarMenuButtonIconProps>(\n ({ className, ...props }, ref) => (\n <span ref={ref} className={clsx(s.MenuButtonIcon, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuButtonIcon.displayName = \"SidebarMenuButtonIcon\"\n\nexport type SidebarMenuButtonLabelProps = ComponentProps<\"span\"> & {\n shortLabel?: string\n}\n\nexport const SidebarMenuButtonLabel = forwardRef<HTMLSpanElement, SidebarMenuButtonLabelProps>(\n ({ shortLabel, className, children, ...props }, ref) => (\n <>\n <span\n ref={ref}\n data-long-label=\"true\"\n className={clsx(s.MenuButtonLabel, className)}\n {...cleanProps(props)}\n >\n {children}\n </span>\n {shortLabel && (\n <span data-short-label=\"true\" className={clsx(s.MenuButtonLabel, className)}>\n {shortLabel}\n </span>\n )}\n </>\n ),\n)\nSidebarMenuButtonLabel.displayName = \"SidebarMenuButtonLabel\"\n\n// =============================================\n// Menu Chevron (Expand/Collapse Toggle)\n// =============================================\n\nexport type SidebarMenuChevronProps = ComponentProps<\"span\">\n\nexport const SidebarMenuChevron = forwardRef<HTMLSpanElement, SidebarMenuChevronProps>(\n ({ className, ...props }, ref) => (\n <span ref={ref} className={clsx(s.MenuChevron, className)} {...cleanProps(props)}>\n <ChevronRightMd />\n </span>\n ),\n)\nSidebarMenuChevron.displayName = \"SidebarMenuChevron\"\n\n// =============================================\n// Menu Badge & Action\n// =============================================\n\nexport type SidebarMenuBadgeProps = ComponentProps<\"span\">\n\nexport const SidebarMenuBadge = forwardRef<HTMLSpanElement, SidebarMenuBadgeProps>(\n ({ className, ...props }, ref) => (\n <span ref={ref} className={clsx(s.MenuBadge, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuBadge.displayName = \"SidebarMenuBadge\"\n\nexport type SidebarMenuActionProps = ComponentProps<\"div\">\n\nexport const SidebarMenuAction = forwardRef<HTMLDivElement, SidebarMenuActionProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.MenuAction, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuAction.displayName = \"SidebarMenuAction\"\n\n// =============================================\n// Menu Skeleton\n// =============================================\n\nexport type SidebarMenuSkeletonProps = ComponentProps<\"div\"> & {\n showIcon?: boolean\n /** Width of the label skeleton (e.g., \"60%\", \"80%\", \"100px\") */\n labelWidth?: string\n}\n\nexport const SidebarMenuSkeleton = forwardRef<HTMLDivElement, SidebarMenuSkeletonProps>(\n ({ showIcon = true, labelWidth = \"60%\", className, ...props }, ref) => (\n <div\n ref={ref}\n data-skeleton\n className={clsx(s.MenuSkeleton, className)}\n {...cleanProps(props)}\n >\n {showIcon && <div className={s.MenuSkeletonIcon} />}\n <div className={s.MenuSkeletonLabel} style={{ width: labelWidth }} />\n </div>\n ),\n)\nSidebarMenuSkeleton.displayName = \"SidebarMenuSkeleton\"\n\n// =============================================\n// Submenu\n// =============================================\n\nexport type SidebarMenuSubProps = ComponentProps<\"ul\"> & {\n open?: boolean\n /**\n * When true, child items align with parent text that has icons.\n * This adjusts the padding so level 2 text aligns with level 1 text.\n */\n hasIcons?: boolean\n}\n\nexport const SidebarMenuSub = forwardRef<HTMLUListElement, SidebarMenuSubProps>(\n ({ open = true, hasIcons = false, className, ...props }, ref) => (\n <ul\n ref={ref}\n data-state={open ? \"open\" : \"closed\"}\n data-has-icons={hasIcons ? \"true\" : undefined}\n // Collapsed items are only hidden visually: keep them out of the tab order\n inert={open ? undefined : true}\n className={clsx(s.MenuSub, className)}\n {...cleanProps(props)}\n />\n ),\n)\nSidebarMenuSub.displayName = \"SidebarMenuSub\"\n\nexport type SidebarMenuSubItemProps = ComponentProps<\"li\">\n\nexport const SidebarMenuSubItem = forwardRef<HTMLLIElement, SidebarMenuSubItemProps>(\n ({ className, ...props }, ref) => (\n <li ref={ref} className={clsx(s.MenuSubItem, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuSubItem.displayName = \"SidebarMenuSubItem\"\n\nexport type SidebarMenuSubButtonProps = ComponentProps<\"button\"> & {\n isActive?: boolean\n asChild?: boolean\n /**\n * Indent level for nested items (0-3).\n * Each level adds 12px of left margin.\n * @default 0\n */\n indent?: 0 | 1 | 2 | 3\n}\n\nexport const SidebarMenuSubButton = forwardRef<HTMLButtonElement, SidebarMenuSubButtonProps>(\n ({ isActive = false, asChild = false, indent = 0, className, children, ...props }, ref) => {\n const inDrawer = useContext(SidebarDrawerContext)\n const Comp = asChild ? Slot.Root : \"button\"\n // In the drawer the disclosure follows the content, inside the child element with asChild\n const content = !inDrawer\n ? children\n : asChild && isValidElement<{ children?: ReactNode }>(children)\n ? cloneElement(children, undefined, <>{children.props.children}<MenuDisclosure /></>)\n : <>{children}<MenuDisclosure /></>\n return (\n <Comp\n ref={ref}\n data-active={isActive ? \"true\" : \"false\"}\n aria-current={isActive ? \"page\" : undefined}\n className={clsx(s.MenuSubButton, s[`indent${indent}`], className)}\n {...cleanProps(props)}\n >\n {content}\n </Comp>\n )\n },\n)\nSidebarMenuSubButton.displayName = \"SidebarMenuSubButton\"\n\n// =============================================\n// Separator\n// =============================================\n\nexport type SidebarSeparatorProps = ComponentProps<\"hr\">\n\nexport const SidebarSeparator = forwardRef<HTMLHRElement, SidebarSeparatorProps>(\n ({ className, ...props }, ref) => (\n <hr ref={ref} className={clsx(s.Separator, className)} {...cleanProps(props)} />\n ),\n)\nSidebarSeparator.displayName = \"SidebarSeparator\"\n\n// =============================================\n// Card\n// =============================================\n\nexport type SidebarCardProps = ComponentProps<\"div\"> & {\n variant?: \"default\" | \"elevated\"\n dismissible?: boolean\n onDismiss?: () => void\n}\n\nexport const SidebarCard = forwardRef<HTMLDivElement, SidebarCardProps>(\n ({ variant = \"default\", dismissible = false, onDismiss, className, children, ...props }, ref) => (\n <div\n ref={ref}\n data-variant={variant}\n className={clsx(s.Card, className)}\n {...cleanProps(props)}\n >\n {dismissible && (\n <Button\n uniform\n size=\"3xs\"\n variant=\"ghost\"\n color=\"secondary\"\n className={s.CardDismiss}\n onClick={onDismiss}\n aria-label=\"Dismiss\"\n >\n <X />\n </Button>\n )}\n {children}\n </div>\n ),\n)\nSidebarCard.displayName = \"SidebarCard\"\n\nexport type SidebarCardHeaderProps = ComponentProps<\"div\">\n\nexport const SidebarCardHeader = forwardRef<HTMLDivElement, SidebarCardHeaderProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardHeader, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardHeader.displayName = \"SidebarCardHeader\"\n\nexport type SidebarCardTitleProps = ComponentProps<\"div\">\n\nexport const SidebarCardTitle = forwardRef<HTMLDivElement, SidebarCardTitleProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardTitle, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardTitle.displayName = \"SidebarCardTitle\"\n\nexport type SidebarCardTitleLinkProps = ComponentProps<\"a\">\n\nexport const SidebarCardTitleLink = forwardRef<HTMLAnchorElement, SidebarCardTitleLinkProps>(\n ({ className, children, ...props }, ref) => (\n <a ref={ref} className={clsx(s.CardTitleLink, className)} {...cleanProps(props)}>\n {children}\n <ChevronRightMd className={s.CardTitleChevron} />\n </a>\n ),\n)\nSidebarCardTitleLink.displayName = \"SidebarCardTitleLink\"\n\nexport type SidebarCardContentProps = ComponentProps<\"div\">\n\nexport const SidebarCardContent = forwardRef<HTMLDivElement, SidebarCardContentProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardContent, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardContent.displayName = \"SidebarCardContent\"\n\nexport type SidebarCardFooterProps = ComponentProps<\"div\">\n\nexport const SidebarCardFooter = forwardRef<HTMLDivElement, SidebarCardFooterProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardFooter, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardFooter.displayName = \"SidebarCardFooter\"\n\n// =============================================\n// Inset (Main Content Area)\n// =============================================\n\nexport type SidebarInsetProps = ComponentProps<\"main\">\n\nexport const SidebarInset = forwardRef<HTMLElement, SidebarInsetProps>(\n ({ className, ...props }, ref) => (\n <main ref={ref} className={clsx(s.Inset, className)} {...cleanProps(props)} />\n ),\n)\nSidebarInset.displayName = \"SidebarInset\"\n\n// =============================================\n// Layout Container\n// =============================================\n\nexport type SidebarLayoutProps = ComponentProps<\"div\">\n\nexport const SidebarLayout = forwardRef<HTMLDivElement, SidebarLayoutProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.SidebarLayout, className)} {...cleanProps(props)} />\n ),\n)\nSidebarLayout.displayName = \"SidebarLayout\"\n\n// =============================================\n// Trigger (Collapse Button)\n// =============================================\n\nexport type SidebarTriggerProps = ComponentProps<\"button\"> & {\n children?: ReactNode\n}\n\nexport const SidebarTrigger = forwardRef<HTMLButtonElement, SidebarTriggerProps>(\n ({ className, children, onClick, ...props }, ref) => {\n const { state, collapsible, isMobile, toggleSidebar } = useSidebar()\n\n // Don't render if collapsible=\"none\" (text-only sidebars)\n if (collapsible === \"none\") {\n return null\n }\n\n // One icon for both states: the tooltip, not the icon, says what a press does\n const defaultIcon = <SidebarIcon />\n\n return (\n <button\n ref={ref}\n type=\"button\"\n className={clsx(s.Trigger, className)}\n onClick={(event) => {\n // The caller's handler runs first and can cancel the toggle\n onClick?.(event)\n if (!event.defaultPrevented) toggleSidebar()\n }}\n aria-label={\n isMobile ? \"Open menu\" : state === \"expanded\" ? \"Collapse sidebar\" : \"Expand sidebar\"\n }\n {...cleanProps(props)}\n >\n <span className={s.TriggerInner}>\n <span className={s.TriggerIcon}>{children ?? defaultIcon}</span>\n </span>\n </button>\n )\n },\n)\nSidebarTrigger.displayName = \"SidebarTrigger\"\n\n// =============================================\n// Mobile Menu Button (SidebarMenuMobile icon → X)\n// =============================================\n\nexport type SidebarMobileMenuButtonProps = ComponentProps<\"button\">\n\nexport const SidebarMobileMenuButton = forwardRef<HTMLButtonElement, SidebarMobileMenuButtonProps>(\n ({ className, onClick, ...props }, ref) => {\n const { openMobile, setOpenMobile } = useSidebar()\n\n return (\n <button\n ref={ref}\n type=\"button\"\n data-expanded={openMobile ? \"\" : undefined}\n className={clsx(s.MobileMenuButton, className)}\n onClick={(event) => {\n // The caller's handler runs first and can cancel the toggle\n onClick?.(event)\n if (!event.defaultPrevented) setOpenMobile(!openMobile)\n }}\n aria-label={openMobile ? \"Close menu\" : \"Open menu\"}\n {...cleanProps(props)}\n >\n <span className={s.MobileMenuIcon}>\n <SidebarMenuMobile className={s.MobileMenuGlyph} data-glyph=\"menu\" />\n <X className={s.MobileMenuGlyph} data-glyph=\"close\" />\n </span>\n </button>\n )\n },\n)\nSidebarMobileMenuButton.displayName = \"SidebarMobileMenuButton\"\n\n// =============================================\n// Mobile Sidebar\n// =============================================\n\nexport type SidebarMobileProps = ComponentProps<\"div\"> & {\n /** When true, drawer is positioned absolute instead of fixed (for contained demos) */\n contained?: boolean\n}\n\nexport const SidebarMobile = forwardRef<HTMLDivElement, SidebarMobileProps>(\n ({ className, children, contained, ...props }, ref) => {\n const { setOpenMobile } = useSidebar()\n\n return (\n <>\n {/* Backdrop */}\n <div\n className={clsx(s.MobileBackdrop, contained && s.contained)}\n onClick={() => setOpenMobile(false)}\n aria-hidden=\"true\"\n />\n\n {/* Drawer */}\n <div\n ref={ref}\n className={clsx(s.MobileSidebar, contained && s.contained, className)}\n {...cleanProps(props)}\n >\n <SidebarDrawerContext.Provider value>{children}</SidebarDrawerContext.Provider>\n </div>\n </>\n )\n },\n)\nSidebarMobile.displayName = \"SidebarMobile\"\n\nexport type SidebarMobileHeaderProps = ComponentProps<\"div\">\n\nexport const SidebarMobileHeader = forwardRef<HTMLDivElement, SidebarMobileHeaderProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.MobileHeader, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMobileHeader.displayName = \"SidebarMobileHeader\"\n\nexport type SidebarMobileFooterProps = ComponentProps<\"div\">\n\nexport const SidebarMobileFooter = forwardRef<HTMLDivElement, SidebarMobileFooterProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.MobileFooter, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMobileFooter.displayName = \"SidebarMobileFooter\"\n\n// =============================================\n// Input (Search)\n// =============================================\n\nexport type SidebarInputProps = InputProps\n\nexport const SidebarInput = forwardRef<HTMLInputElement, SidebarInputProps>(\n ({ className, ...props }, ref) => (\n <div className={s.Input}>\n <Input\n ref={ref}\n className={className}\n startAdornment={<SearchIcon />}\n {...cleanProps(props)}\n />\n </div>\n ),\n)\nSidebarInput.displayName = \"SidebarInput\"\n\n// =============================================\n// Footer Links\n// =============================================\n\nexport type SidebarFooterLinksProps = ComponentProps<\"div\">\n\nexport const SidebarFooterLinks = forwardRef<HTMLDivElement, SidebarFooterLinksProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.FooterLinks, className)} {...cleanProps(props)} />\n ),\n)\nSidebarFooterLinks.displayName = \"SidebarFooterLinks\"\n"]}
|
|
1
|
+
{"version":3,"file":"Sidebar.js","sourceRoot":"","sources":["../../../../src/components/Sidebar/Sidebar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA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,CACF,CAAA;AACD,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAA;AAQvD,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CACpC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAChC,cAAK,SAAS,EAAE,CAAC,CAAC,KAAK,YACrB,KAAC,KAAK,IACJ,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,KAAC,UAAU,KAAG,KAC1B,UAAU,CAAC,KAAK,CAAC,GACrB,GACE,CACP,CACF,CAAA;AACD,YAAY,CAAC,WAAW,GAAG,cAAc,CAAA;AAQzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAC1C,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAChC,cAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,KAAM,UAAU,CAAC,KAAK,CAAC,GAAI,CACpF,CACF,CAAA;AACD,kBAAkB,CAAC,WAAW,GAAG,oBAAoB,CAAA","sourcesContent":["\"use client\"\n\n/**\n * Sidebar Component - Composable navigation sidebar\n *\n * API SPECIFICATION:\n *\n * SidebarProvider\n * - defaultOpen?: boolean (default: true)\n * - open?: boolean (controlled)\n * - onOpenChange?: (open: boolean) => void\n * - collapsible?: \"offcanvas\" | \"icon\" | \"none\" (default: \"offcanvas\")\n *\n * Sidebar\n * - side?: \"left\" | \"right\" (default: \"left\")\n * - variant?: \"sidebar\" | \"docs\" (default: \"sidebar\")\n *\n * SidebarHeader / SidebarContent / SidebarFooter\n * - Standard container props\n *\n * SidebarGroup\n * - defaultOpen?: boolean (default: true)\n * - open?: boolean (controlled)\n *\n * SidebarGroupLabel / SidebarGroupAction / SidebarGroupContent\n * - Standard container props\n *\n * SidebarMenu / SidebarMenuItem\n * - Standard container props\n *\n * SidebarMenuButton\n * - isActive?: boolean (default: false)\n * - size?: \"sm\" | \"md\" | \"lg\" (default: \"md\")\n * - tooltip?: string | ReactNode\n * - asChild?: boolean\n *\n * SidebarMenuAction / SidebarMenuBadge\n * - Standard container props\n *\n * SidebarMenuSkeleton\n * - showIcon?: boolean (default: true)\n *\n * SidebarMenuSub / SidebarMenuSubItem / SidebarMenuSubButton\n * - Same as parent menu components\n *\n * SidebarSeparator\n * - Standard separator props\n *\n * SidebarCard / SidebarCardHeader / SidebarCardContent / SidebarCardFooter\n * - variant?: \"default\" | \"elevated\"\n * - dismissible?: boolean\n * - onDismiss?: () => void\n *\n * SidebarInset\n * - Standard container for main content area\n *\n * SidebarTrigger\n * - Uses Button component internally\n * - Returns null when collapsible=\"none\"\n *\n * SidebarMobileMenuButton\n * - Mobile menu button: the SidebarMenuMobile icon turns into X\n *\n * SidebarInput\n * - shortcut?: string (keyboard shortcut display)\n */\n\nimport clsx from \"clsx\"\nimport { Slot } from \"radix-ui\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport {\n cloneElement,\n createContext,\n forwardRef,\n isValidElement,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type ComponentProps,\n type PointerEvent,\n type ReactNode,\n} from \"react\"\n\nimport { Button } from \"../Button\"\nimport { ChevronRightMd, Disclosure, Search as SearchIcon, Sidebar as SidebarIcon, SidebarMenuMobile, X } from \"../Icon\"\nimport { Input, type InputProps } from \"../Input\"\nimport { Tooltip } from \"../Tooltip\"\nimport s from \"@plexui/styles/components/Sidebar/Sidebar.module.css\"\nimport { attachDrawerSwipe, closeOnUnhandledEscape, drawerInitialFocus, loopDrawerFocus } from \"../../lib/phoneDrawer\"\nimport {\n SidebarProvider,\n useSidebar,\n type SidebarCollapsible,\n type SidebarSide,\n type SidebarProviderVariant,\n type SidebarVariant,\n} from \"./useSidebarContext\"\n\n// Helper to filter out props that shouldn't be spread to the DOM (e.g. injected by MDX)\nconst cleanProps = <P extends object>(props: P): Omit<P, \"data-toggle\"> => {\n const { \"data-toggle\": _, ...rest } = props as P & { \"data-toggle\"?: unknown }\n return rest\n}\n\n// Re-export provider and hook\nexport { SidebarProvider, useSidebar }\nexport type { SidebarCollapsible, SidebarProviderVariant, SidebarSide, SidebarVariant }\n\n// Rows inside the mobile drawer end with a disclosure chevron (see the drawer list in the styles), unless the drawer\n// leaves it out (`disclosure={false}`).\nconst SidebarDrawerContext = createContext(false)\n\n/** The chevron of a drawer row that leads to another page. */\nconst MenuDisclosure = () => (\n <span className={s.MenuDisclosure} aria-hidden=\"true\">\n <Disclosure />\n </span>\n)\n\n// =============================================\n// Sidebar Root\n// =============================================\n\nexport type SidebarProps = ComponentProps<\"aside\"> & {\n /**\n * The side the sidebar is on.\n * @default \"left\"\n */\n side?: SidebarSide\n /**\n * The visual variant of the sidebar.\n * @default \"sidebar\"\n */\n variant?: SidebarVariant\n}\n\nexport const Sidebar = forwardRef<HTMLElement, SidebarProps>(\n ({ side = \"left\", variant = \"sidebar\", className, children, ...props }, ref) => {\n const { collapsible, isMobile } = useSidebar()\n\n // Skip rendering sidebar on mobile for offcanvas mode\n if (isMobile && collapsible === \"offcanvas\") {\n return null\n }\n\n return (\n <aside\n ref={ref}\n data-side={side}\n data-variant={variant}\n className={clsx(s.Sidebar, className)}\n {...cleanProps(props)}\n >\n {children}\n </aside>\n )\n },\n)\nSidebar.displayName = \"Sidebar\"\n\n// =============================================\n// Sidebar Sections\n// =============================================\n\nexport type SidebarHeaderProps = ComponentProps<\"div\">\n\nexport const SidebarHeader = forwardRef<HTMLDivElement, SidebarHeaderProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.Header, className)} {...cleanProps(props)} />\n ),\n)\nSidebarHeader.displayName = \"SidebarHeader\"\n\nexport type SidebarContentProps = ComponentProps<\"div\">\n\nexport const SidebarContent = forwardRef<HTMLDivElement, SidebarContentProps>(\n ({ className, ...props }, ref) => {\n const [contentEl, setContentEl] = useState<HTMLDivElement | null>(null)\n const setRef = useCallback(\n (el: HTMLDivElement | null) => {\n setContentEl(el)\n if (typeof ref === \"function\") ref(el)\n else if (ref) (ref as { current: HTMLDivElement | null }).current = el\n },\n [ref],\n )\n\n useLayoutEffect(() => {\n if (!contentEl) return\n const sidebar = contentEl.parentElement\n if (!sidebar) return\n\n const update = () => {\n const hasOverflow = contentEl.scrollHeight > contentEl.clientHeight\n sidebar.setAttribute(\"data-content-scrollable\", hasOverflow ? \"true\" : \"false\")\n }\n update()\n const ro = new ResizeObserver(update)\n ro.observe(contentEl)\n return () => ro.disconnect()\n }, [contentEl])\n\n return <div ref={setRef} className={clsx(s.Content, className)} {...cleanProps(props)} />\n },\n)\nSidebarContent.displayName = \"SidebarContent\"\n\nexport type SidebarFooterProps = ComponentProps<\"div\">\n\nexport const SidebarFooter = forwardRef<HTMLDivElement, SidebarFooterProps>(\n ({ className, children, ...props }, ref) => (\n <div ref={ref} className={clsx(s.Footer, className)} {...cleanProps(props)}>\n <div className={s.FooterSeparator} />\n {children}\n </div>\n ),\n)\nSidebarFooter.displayName = \"SidebarFooter\"\n\nexport type SidebarRailProps = ComponentProps<\"div\">\n\nexport const SidebarRail = forwardRef<HTMLDivElement, SidebarRailProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.Rail, className)} {...cleanProps(props)} />\n ),\n)\nSidebarRail.displayName = \"SidebarRail\"\n\n// =============================================\n// Groups\n// =============================================\n\nexport type SidebarGroupProps = ComponentProps<\"div\"> & {\n /**\n * Whether the group is open initially. A closed group hides its `SidebarGroupContent`.\n * @default true\n */\n defaultOpen?: boolean\n /**\n * Controlled open state. The group has no toggle of its own: change `open` from your own control.\n */\n open?: boolean\n}\n\nexport const SidebarGroup = forwardRef<HTMLDivElement, SidebarGroupProps>(\n ({ defaultOpen = true, open: openProp, className, ...props }, ref) => {\n // The initial value only, like an uncontrolled input's defaultValue\n const [initialOpen] = useState(defaultOpen)\n const open = openProp ?? initialOpen\n\n return (\n <div\n ref={ref}\n data-state={open ? \"open\" : \"closed\"}\n className={clsx(s.Group, className)}\n {...cleanProps(props)}\n />\n )\n },\n)\nSidebarGroup.displayName = \"SidebarGroup\"\n\nexport type SidebarGroupLabelProps = ComponentProps<\"span\"> & {\n asChild?: boolean\n /**\n * Size variant for the label.\n * - \"sm\": Compact style for dashboard/settings sidebars\n * - \"lg\": Documentation style with larger text and more spacing\n * @default \"lg\"\n */\n size?: \"sm\" | \"lg\"\n}\n\nexport const SidebarGroupLabel = forwardRef<HTMLSpanElement, SidebarGroupLabelProps>(\n ({ asChild = false, size = \"lg\", className, ...props }, ref) => {\n const Comp = asChild ? Slot.Root : \"span\"\n return (\n <Comp\n ref={ref}\n data-size={size}\n className={clsx(s.GroupLabel, className)}\n {...cleanProps(props)}\n />\n )\n },\n)\nSidebarGroupLabel.displayName = \"SidebarGroupLabel\"\n\nexport type SidebarGroupActionProps = ComponentProps<\"div\">\n\nexport const SidebarGroupAction = forwardRef<HTMLDivElement, SidebarGroupActionProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.GroupAction, className)} {...cleanProps(props)} />\n ),\n)\nSidebarGroupAction.displayName = \"SidebarGroupAction\"\n\nexport type SidebarGroupContentProps = ComponentProps<\"div\">\n\nexport const SidebarGroupContent = forwardRef<HTMLDivElement, SidebarGroupContentProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.GroupContent, className)} {...cleanProps(props)} />\n ),\n)\nSidebarGroupContent.displayName = \"SidebarGroupContent\"\n\n// =============================================\n// Menu\n// =============================================\n\nexport type SidebarMenuProps = ComponentProps<\"ul\">\n\nexport const SidebarMenu = forwardRef<HTMLUListElement, SidebarMenuProps>(\n ({ className, ...props }, ref) => (\n <ul ref={ref} className={clsx(s.Menu, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenu.displayName = \"SidebarMenu\"\n\nexport type SidebarMenuItemProps = ComponentProps<\"li\"> & {\n expanded?: boolean\n}\n\nexport const SidebarMenuItem = forwardRef<HTMLLIElement, SidebarMenuItemProps>(\n ({ expanded, className, ...props }, ref) => (\n <li\n ref={ref}\n data-expanded={expanded ? \"true\" : undefined}\n className={clsx(s.MenuItem, className)}\n {...cleanProps(props)}\n />\n ),\n)\nSidebarMenuItem.displayName = \"SidebarMenuItem\"\n\n// =============================================\n// Menu Button\n// =============================================\n\nexport type SidebarMenuButtonProps = ComponentProps<\"button\"> & {\n /**\n * Whether the button is in an active/highlighted state.\n * @default false\n */\n isActive?: boolean\n /**\n * Optional tooltip to show when the sidebar is collapsed.\n */\n tooltip?: string | ReactNode\n /**\n * Whether to render the button as a custom element via Slot.\n * @default false\n */\n asChild?: boolean\n}\n\n// Shared by every row of the rail: moving to the next one shows its label at once.\nlet railLeftAt = 0\n\nexport const SidebarMenuButton = forwardRef<HTMLButtonElement, SidebarMenuButtonProps>(\n ({ isActive = false, tooltip, asChild = false, className, children, onPointerEnter, onPointerLeave, ...props }, ref) => {\n const { state, isMobile } = useSidebar()\n const inDrawer = useContext(SidebarDrawerContext)\n const [openDelay, setOpenDelay] = useState<number>()\n const Comp = asChild ? Slot.Root : \"button\"\n const disclosure = inDrawer ? <MenuDisclosure /> : null\n // With asChild the child element is the button, so the inner wrapper\n // goes inside it. Wrapping the child instead would make Slot merge the\n // button props onto the wrapper span.\n const content =\n asChild && isValidElement<{ children?: ReactNode }>(children) ? (\n cloneElement(\n children,\n undefined,\n <span className={s.MenuButtonInner}>{children.props.children}{disclosure}</span>,\n )\n ) : (\n <span className={s.MenuButtonInner}>{children}{disclosure}</span>\n )\n\n const button = (\n <Comp\n ref={ref}\n data-active={isActive ? \"true\" : \"false\"}\n aria-current={isActive ? \"page\" : undefined}\n className={clsx(s.MenuButton, className)}\n onPointerEnter={(event: PointerEvent<HTMLButtonElement>) => {\n onPointerEnter?.(event)\n if (tooltip) setOpenDelay(Date.now() - railLeftAt < 300 ? 0 : undefined)\n }}\n onPointerLeave={(event: PointerEvent<HTMLButtonElement>) => {\n onPointerLeave?.(event)\n if (tooltip) railLeftAt = Date.now()\n }}\n {...cleanProps(props)}\n >\n {content}\n </Comp>\n )\n\n // The tooltip shows when collapsed (icon mode) and not on mobile. It wraps\n // the row in every state, so the row stays mounted and its label can fade.\n if (tooltip) {\n return (\n <Tooltip content={state === \"collapsed\" && !isMobile ? tooltip : null} openDelay={openDelay} side=\"right\">\n {button}\n </Tooltip>\n )\n }\n\n return button\n },\n)\nSidebarMenuButton.displayName = \"SidebarMenuButton\"\n\n// =============================================\n// Menu Button Parts\n// =============================================\n\nexport type SidebarMenuButtonIconProps = ComponentProps<\"span\">\n\nexport const SidebarMenuButtonIcon = forwardRef<HTMLSpanElement, SidebarMenuButtonIconProps>(\n ({ className, ...props }, ref) => (\n <span ref={ref} className={clsx(s.MenuButtonIcon, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuButtonIcon.displayName = \"SidebarMenuButtonIcon\"\n\nexport type SidebarMenuButtonLabelProps = ComponentProps<\"span\"> & {\n shortLabel?: string\n}\n\nexport const SidebarMenuButtonLabel = forwardRef<HTMLSpanElement, SidebarMenuButtonLabelProps>(\n ({ shortLabel, className, children, ...props }, ref) => (\n <>\n <span\n ref={ref}\n data-long-label=\"true\"\n className={clsx(s.MenuButtonLabel, className)}\n {...cleanProps(props)}\n >\n {children}\n </span>\n {shortLabel && (\n <span data-short-label=\"true\" className={clsx(s.MenuButtonLabel, className)}>\n {shortLabel}\n </span>\n )}\n </>\n ),\n)\nSidebarMenuButtonLabel.displayName = \"SidebarMenuButtonLabel\"\n\n// =============================================\n// Menu Chevron (Expand/Collapse Toggle)\n// =============================================\n\nexport type SidebarMenuChevronProps = ComponentProps<\"span\">\n\nexport const SidebarMenuChevron = forwardRef<HTMLSpanElement, SidebarMenuChevronProps>(\n ({ className, ...props }, ref) => (\n <span ref={ref} className={clsx(s.MenuChevron, className)} {...cleanProps(props)}>\n <ChevronRightMd />\n </span>\n ),\n)\nSidebarMenuChevron.displayName = \"SidebarMenuChevron\"\n\n// =============================================\n// Menu Badge & Action\n// =============================================\n\nexport type SidebarMenuBadgeProps = ComponentProps<\"span\">\n\nexport const SidebarMenuBadge = forwardRef<HTMLSpanElement, SidebarMenuBadgeProps>(\n ({ className, ...props }, ref) => (\n <span ref={ref} className={clsx(s.MenuBadge, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuBadge.displayName = \"SidebarMenuBadge\"\n\nexport type SidebarMenuActionProps = ComponentProps<\"div\">\n\nexport const SidebarMenuAction = forwardRef<HTMLDivElement, SidebarMenuActionProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.MenuAction, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuAction.displayName = \"SidebarMenuAction\"\n\n// =============================================\n// Menu Skeleton\n// =============================================\n\nexport type SidebarMenuSkeletonProps = ComponentProps<\"div\"> & {\n showIcon?: boolean\n /** Width of the label skeleton (e.g., \"60%\", \"80%\", \"100px\") */\n labelWidth?: string\n}\n\nexport const SidebarMenuSkeleton = forwardRef<HTMLDivElement, SidebarMenuSkeletonProps>(\n ({ showIcon = true, labelWidth = \"60%\", className, ...props }, ref) => (\n <div\n ref={ref}\n data-skeleton\n className={clsx(s.MenuSkeleton, className)}\n {...cleanProps(props)}\n >\n {showIcon && <div className={s.MenuSkeletonIcon} />}\n <div className={s.MenuSkeletonLabel} style={{ width: labelWidth }} />\n </div>\n ),\n)\nSidebarMenuSkeleton.displayName = \"SidebarMenuSkeleton\"\n\n// =============================================\n// Submenu\n// =============================================\n\nexport type SidebarMenuSubProps = ComponentProps<\"ul\"> & {\n open?: boolean\n /**\n * When true, child items align with parent text that has icons.\n * This adjusts the padding so level 2 text aligns with level 1 text.\n */\n hasIcons?: boolean\n}\n\nexport const SidebarMenuSub = forwardRef<HTMLUListElement, SidebarMenuSubProps>(\n ({ open = true, hasIcons = false, className, ...props }, ref) => (\n <ul\n ref={ref}\n data-state={open ? \"open\" : \"closed\"}\n data-has-icons={hasIcons ? \"true\" : undefined}\n // Collapsed items are only hidden visually: keep them out of the tab order\n inert={open ? undefined : true}\n className={clsx(s.MenuSub, className)}\n {...cleanProps(props)}\n />\n ),\n)\nSidebarMenuSub.displayName = \"SidebarMenuSub\"\n\nexport type SidebarMenuSubItemProps = ComponentProps<\"li\">\n\nexport const SidebarMenuSubItem = forwardRef<HTMLLIElement, SidebarMenuSubItemProps>(\n ({ className, ...props }, ref) => (\n <li ref={ref} className={clsx(s.MenuSubItem, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuSubItem.displayName = \"SidebarMenuSubItem\"\n\nexport type SidebarMenuSubButtonProps = ComponentProps<\"button\"> & {\n isActive?: boolean\n asChild?: boolean\n /**\n * Indent level for nested items (0-3).\n * Each level adds 12px of left margin.\n * @default 0\n */\n indent?: 0 | 1 | 2 | 3\n}\n\nexport const SidebarMenuSubButton = forwardRef<HTMLButtonElement, SidebarMenuSubButtonProps>(\n ({ isActive = false, asChild = false, indent = 0, className, children, ...props }, ref) => {\n const inDrawer = useContext(SidebarDrawerContext)\n const Comp = asChild ? Slot.Root : \"button\"\n // In the drawer the disclosure follows the content, inside the child element with asChild\n const content = !inDrawer\n ? children\n : asChild && isValidElement<{ children?: ReactNode }>(children)\n ? cloneElement(children, undefined, <>{children.props.children}<MenuDisclosure /></>)\n : <>{children}<MenuDisclosure /></>\n return (\n <Comp\n ref={ref}\n data-active={isActive ? \"true\" : \"false\"}\n aria-current={isActive ? \"page\" : undefined}\n className={clsx(s.MenuSubButton, s[`indent${indent}`], className)}\n {...cleanProps(props)}\n >\n {content}\n </Comp>\n )\n },\n)\nSidebarMenuSubButton.displayName = \"SidebarMenuSubButton\"\n\n// =============================================\n// Separator\n// =============================================\n\nexport type SidebarSeparatorProps = ComponentProps<\"hr\">\n\nexport const SidebarSeparator = forwardRef<HTMLHRElement, SidebarSeparatorProps>(\n ({ className, ...props }, ref) => (\n <hr ref={ref} className={clsx(s.Separator, className)} {...cleanProps(props)} />\n ),\n)\nSidebarSeparator.displayName = \"SidebarSeparator\"\n\n// =============================================\n// Card\n// =============================================\n\nexport type SidebarCardProps = ComponentProps<\"div\"> & {\n variant?: \"default\" | \"elevated\"\n dismissible?: boolean\n onDismiss?: () => void\n}\n\nexport const SidebarCard = forwardRef<HTMLDivElement, SidebarCardProps>(\n ({ variant = \"default\", dismissible = false, onDismiss, className, children, ...props }, ref) => (\n <div\n ref={ref}\n data-variant={variant}\n className={clsx(s.Card, className)}\n {...cleanProps(props)}\n >\n {dismissible && (\n <Button\n uniform\n size=\"3xs\"\n variant=\"ghost\"\n color=\"secondary\"\n className={s.CardDismiss}\n onClick={onDismiss}\n aria-label=\"Dismiss\"\n >\n <X />\n </Button>\n )}\n {children}\n </div>\n ),\n)\nSidebarCard.displayName = \"SidebarCard\"\n\nexport type SidebarCardHeaderProps = ComponentProps<\"div\">\n\nexport const SidebarCardHeader = forwardRef<HTMLDivElement, SidebarCardHeaderProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardHeader, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardHeader.displayName = \"SidebarCardHeader\"\n\nexport type SidebarCardTitleProps = ComponentProps<\"div\">\n\nexport const SidebarCardTitle = forwardRef<HTMLDivElement, SidebarCardTitleProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardTitle, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardTitle.displayName = \"SidebarCardTitle\"\n\nexport type SidebarCardTitleLinkProps = ComponentProps<\"a\">\n\nexport const SidebarCardTitleLink = forwardRef<HTMLAnchorElement, SidebarCardTitleLinkProps>(\n ({ className, children, ...props }, ref) => (\n <a ref={ref} className={clsx(s.CardTitleLink, className)} {...cleanProps(props)}>\n {children}\n <ChevronRightMd className={s.CardTitleChevron} />\n </a>\n ),\n)\nSidebarCardTitleLink.displayName = \"SidebarCardTitleLink\"\n\nexport type SidebarCardContentProps = ComponentProps<\"div\">\n\nexport const SidebarCardContent = forwardRef<HTMLDivElement, SidebarCardContentProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardContent, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardContent.displayName = \"SidebarCardContent\"\n\nexport type SidebarCardFooterProps = ComponentProps<\"div\">\n\nexport const SidebarCardFooter = forwardRef<HTMLDivElement, SidebarCardFooterProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardFooter, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardFooter.displayName = \"SidebarCardFooter\"\n\n// =============================================\n// Inset (Main Content Area)\n// =============================================\n\nexport type SidebarInsetProps = ComponentProps<\"main\">\n\nexport const SidebarInset = forwardRef<HTMLElement, SidebarInsetProps>(\n ({ className, ...props }, ref) => {\n const { isMobile, openMobile } = useSidebar()\n // Behind the open phone drawer the page takes no focus or touch; `inert` of your own wins\n return (\n <main\n ref={ref}\n className={clsx(s.Inset, className)}\n inert={isMobile && openMobile ? true : undefined}\n {...cleanProps(props)}\n />\n )\n },\n)\nSidebarInset.displayName = \"SidebarInset\"\n\n// =============================================\n// Layout Container\n// =============================================\n\nexport type SidebarLayoutProps = ComponentProps<\"div\">\n\nexport const SidebarLayout = forwardRef<HTMLDivElement, SidebarLayoutProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.SidebarLayout, className)} {...cleanProps(props)} />\n ),\n)\nSidebarLayout.displayName = \"SidebarLayout\"\n\n// =============================================\n// Trigger (Collapse Button)\n// =============================================\n\nexport type SidebarTriggerProps = ComponentProps<\"button\"> & {\n children?: ReactNode\n}\n\nexport const SidebarTrigger = forwardRef<HTMLButtonElement, SidebarTriggerProps>(\n ({ className, children, onClick, ...props }, ref) => {\n const { state, collapsible, isMobile, toggleSidebar } = useSidebar()\n\n // Don't render if collapsible=\"none\" (text-only sidebars)\n if (collapsible === \"none\") {\n return null\n }\n\n // One icon for both states: the tooltip, not the icon, says what a press does\n const defaultIcon = <SidebarIcon />\n\n return (\n <button\n ref={ref}\n type=\"button\"\n className={clsx(s.Trigger, className)}\n onClick={(event) => {\n // The caller's handler runs first and can cancel the toggle\n onClick?.(event)\n if (!event.defaultPrevented) toggleSidebar()\n }}\n aria-label={\n isMobile ? \"Open menu\" : state === \"expanded\" ? \"Collapse sidebar\" : \"Expand sidebar\"\n }\n {...cleanProps(props)}\n >\n <span className={s.TriggerInner}>\n <span className={s.TriggerIcon}>{children ?? defaultIcon}</span>\n </span>\n </button>\n )\n },\n)\nSidebarTrigger.displayName = \"SidebarTrigger\"\n\n// =============================================\n// Mobile Menu Button (SidebarMenuMobile icon → X)\n// =============================================\n\nexport type SidebarMobileMenuButtonProps = ComponentProps<\"button\">\n\nexport const SidebarMobileMenuButton = forwardRef<HTMLButtonElement, SidebarMobileMenuButtonProps>(\n ({ className, onClick, ...props }, ref) => {\n const { openMobile, setOpenMobile } = useSidebar()\n\n return (\n <button\n ref={ref}\n type=\"button\"\n data-expanded={openMobile ? \"\" : undefined}\n className={clsx(s.MobileMenuButton, className)}\n onClick={(event) => {\n // The caller's handler runs first and can cancel the toggle\n onClick?.(event)\n if (!event.defaultPrevented) setOpenMobile(!openMobile)\n }}\n aria-label={openMobile ? \"Close menu\" : \"Open menu\"}\n {...cleanProps(props)}\n >\n <span className={s.MobileMenuIcon}>\n <SidebarMenuMobile className={s.MobileMenuGlyph} data-glyph=\"menu\" />\n <X className={s.MobileMenuGlyph} data-glyph=\"close\" />\n </span>\n </button>\n )\n },\n)\nSidebarMobileMenuButton.displayName = \"SidebarMobileMenuButton\"\n\n// =============================================\n// Mobile Sidebar\n// =============================================\n\nexport type SidebarMobileProps = ComponentProps<\"div\"> & {\n /** When true, drawer is positioned absolute instead of fixed (for contained demos) */\n contained?: boolean\n /**\n * Rows that lead to another page end with a disclosure chevron, as in an iOS list. `false` leaves it out.\n * @default true\n */\n disclosure?: boolean\n}\n\n/**\n * The phone drawer: a modal dialog while it is open. Focus moves into it and Tab goes round its controls, the page\n * behind is inert (SidebarInset), Escape inside it closes it after any layer over it has taken its own, and focus\n * goes back to the control that opened it. A swipe in from the edge it slides from opens it and a swipe back closes\n * it (lib/phoneDrawer).\n */\nexport const SidebarMobile = forwardRef<HTMLDivElement, SidebarMobileProps>(\n ({ className, children, contained, disclosure = true, onKeyDown, ...props }, ref) => {\n const { isMobile, openMobile, setOpenMobile } = useSidebar()\n const drawerRef = useRef<HTMLDivElement>(null)\n const state = useRef({ open: openMobile, isMobile, setOpenMobile })\n state.current = { open: openMobile, isMobile, setOpenMobile }\n\n // Focus moves in on open and back to what opened the drawer on close. A drawer that is not contained shows only\n // at phone width, so going back to it from a wide window moves focus in again.\n const shown = openMobile && (isMobile || Boolean(contained))\n useEffect(() => {\n const drawer = drawerRef.current\n if (!shown || !drawer) return\n const trigger = document.activeElement\n if (!drawer.contains(document.activeElement)) drawerInitialFocus(drawer).focus({ preventScroll: true })\n return () => {\n const active = document.activeElement\n const lost = !active || active === document.body || drawer.contains(active)\n if (lost && trigger instanceof HTMLElement && trigger.isConnected && !drawer.contains(trigger)) {\n trigger.focus({ preventScroll: true })\n }\n }\n }, [shown])\n\n useEffect(() => {\n const drawer = drawerRef.current\n const root = drawer?.closest<HTMLElement>(\"[data-mobile-menu]\")\n if (!drawer || !root) return\n return attachDrawerSwipe({\n root,\n drawer,\n isOpen: () => state.current.open,\n setOpen: (open) => state.current.setOpenMobile(open),\n enabled: () => state.current.isMobile,\n })\n }, [])\n\n return (\n <>\n {/* Backdrop */}\n <div\n className={clsx(s.MobileBackdrop, contained && s.contained)}\n onClick={() => setOpenMobile(false)}\n aria-hidden=\"true\"\n />\n\n {/* Drawer */}\n <div\n ref={mergeRefs([ref, drawerRef])}\n role=\"dialog\"\n aria-modal={openMobile ? true : undefined}\n aria-label=\"Menu\"\n tabIndex={-1}\n inert={openMobile ? undefined : true}\n className={clsx(s.MobileSidebar, contained && s.contained, className)}\n onKeyDown={(event) => {\n // Your handler runs first and can keep the drawer open with preventDefault()\n onKeyDown?.(event)\n const drawer = drawerRef.current\n if (!openMobile || !drawer) return\n loopDrawerFocus(event.nativeEvent, drawer)\n closeOnUnhandledEscape(event.nativeEvent, drawer, () => state.current.setOpenMobile(false))\n }}\n {...cleanProps(props)}\n >\n <SidebarDrawerContext.Provider value={disclosure}>{children}</SidebarDrawerContext.Provider>\n </div>\n </>\n )\n },\n)\nSidebarMobile.displayName = \"SidebarMobile\"\n\nexport type SidebarMobileHeaderProps = ComponentProps<\"div\">\n\nexport const SidebarMobileHeader = forwardRef<HTMLDivElement, SidebarMobileHeaderProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.MobileHeader, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMobileHeader.displayName = \"SidebarMobileHeader\"\n\nexport type SidebarMobileFooterProps = ComponentProps<\"div\">\n\nexport const SidebarMobileFooter = forwardRef<HTMLDivElement, SidebarMobileFooterProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.MobileFooter, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMobileFooter.displayName = \"SidebarMobileFooter\"\n\n// =============================================\n// Input (Search)\n// =============================================\n\nexport type SidebarInputProps = InputProps\n\nexport const SidebarInput = forwardRef<HTMLInputElement, SidebarInputProps>(\n ({ className, ...props }, ref) => (\n <div className={s.Input}>\n <Input\n ref={ref}\n className={className}\n startAdornment={<SearchIcon />}\n {...cleanProps(props)}\n />\n </div>\n ),\n)\nSidebarInput.displayName = \"SidebarInput\"\n\n// =============================================\n// Footer Links\n// =============================================\n\nexport type SidebarFooterLinksProps = ComponentProps<\"div\">\n\nexport const SidebarFooterLinks = forwardRef<HTMLDivElement, SidebarFooterLinksProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.FooterLinks, className)} {...cleanProps(props)} />\n ),\n)\nSidebarFooterLinks.displayName = \"SidebarFooterLinks\"\n"]}
|
|
@@ -37,9 +37,19 @@ function useIsMobile() {
|
|
|
37
37
|
return useSyncExternalStore(subscribeToMobile, getMobileSnapshot, getServerMobileSnapshot);
|
|
38
38
|
}
|
|
39
39
|
// Provider component
|
|
40
|
-
export const SidebarProvider = ({ children, defaultOpen = true, open: openProp, onOpenChange: setOpenProp, collapsible = "offcanvas", variant = "sidebar", style, className, }) => {
|
|
40
|
+
export const SidebarProvider = ({ children, defaultOpen = true, open: openProp, onOpenChange: setOpenProp, openMobile: openMobileProp, defaultOpenMobile = false, onOpenMobileChange, collapsible = "offcanvas", variant = "sidebar", style, className, }) => {
|
|
41
41
|
const isMobile = useIsMobile();
|
|
42
|
-
|
|
42
|
+
// Controlled vs uncontrolled state for the phone drawer
|
|
43
|
+
const [_openMobile, _setOpenMobile] = useState(defaultOpenMobile);
|
|
44
|
+
const openMobile = openMobileProp ?? _openMobile;
|
|
45
|
+
const setOpenMobile = useCallback((value) => {
|
|
46
|
+
const next = typeof value === "function" ? value(openMobile) : value;
|
|
47
|
+
if (next === openMobile)
|
|
48
|
+
return;
|
|
49
|
+
if (openMobileProp === undefined)
|
|
50
|
+
_setOpenMobile(next);
|
|
51
|
+
onOpenMobileChange?.(next);
|
|
52
|
+
}, [openMobile, openMobileProp, onOpenMobileChange]);
|
|
43
53
|
// Controlled vs uncontrolled state for desktop
|
|
44
54
|
const [_open, _setOpen] = useState(defaultOpen);
|
|
45
55
|
const open = openProp ?? _open;
|
|
@@ -63,7 +73,7 @@ export const SidebarProvider = ({ children, defaultOpen = true, open: openProp,
|
|
|
63
73
|
else {
|
|
64
74
|
setOpen((prev) => !prev);
|
|
65
75
|
}
|
|
66
|
-
}, [isMobile, setOpen]);
|
|
76
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
67
77
|
// Keyboard shortcut: Cmd/Ctrl + B
|
|
68
78
|
useEffect(() => {
|
|
69
79
|
const handleKeyDown = (event) => {
|
|
@@ -86,18 +96,7 @@ export const SidebarProvider = ({ children, defaultOpen = true, open: openProp,
|
|
|
86
96
|
window.addEventListener("keydown", handleKeyDown);
|
|
87
97
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
88
98
|
}, [toggleSidebar, collapsible]);
|
|
89
|
-
//
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (!openMobile)
|
|
92
|
-
return;
|
|
93
|
-
const handleKeyDown = (event) => {
|
|
94
|
-
if (event.key === "Escape") {
|
|
95
|
-
setOpenMobile(false);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
99
|
-
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
100
|
-
}, [openMobile]);
|
|
99
|
+
// Escape closes the drawer from inside it (SidebarMobile), so a layer over it takes its own Escape first
|
|
101
100
|
// Derive state from open boolean
|
|
102
101
|
const state = open ? "expanded" : "collapsed";
|
|
103
102
|
// Context value
|
|
@@ -110,7 +109,7 @@ export const SidebarProvider = ({ children, defaultOpen = true, open: openProp,
|
|
|
110
109
|
isMobile,
|
|
111
110
|
collapsible,
|
|
112
111
|
toggleSidebar,
|
|
113
|
-
}), [state, open, setOpen, openMobile, isMobile, collapsible, toggleSidebar]);
|
|
112
|
+
}), [state, open, setOpen, openMobile, setOpenMobile, isMobile, collapsible, toggleSidebar]);
|
|
114
113
|
return (_jsx(SidebarContext.Provider, { value: contextValue, children: _jsx("div", { className: clsx(variant === "app" && s.App, className), style: {
|
|
115
114
|
"--sidebar-width": variant === "app" ? SIDEBAR_WIDTH_APP : SIDEBAR_WIDTH,
|
|
116
115
|
"--sidebar-width-mobile": SIDEBAR_WIDTH_MOBILE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSidebarContext.js","sourceRoot":"","sources":["../../../../src/components/Sidebar/useSidebarContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,QAAQ,EACR,oBAAoB,GAErB,MAAM,OAAO,CAAA;AACd,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,CAAC,MAAM,sDAAsD,CAAA;AAEpE,YAAY;AACZ,MAAM,mBAAmB,GAAG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K,EAAE,aAAa;IACpB,SAAS,EAAE,iBAAiB;IAC5B,YAAY,EAAE,oBAAoB;IAClC,UAAU,EAAE,kBAAkB;IAC9B,iBAAiB,EAAE,yBAAyB;IAC5C,iBAAiB;IACjB,WAAW,EAAE,mBAAmB;IAChC,cAAc,EAAE,sBAAsB;CAC9B,CAAA","sourcesContent":["\"use client\"\n\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\"\nimport clsx from \"clsx\"\nimport s from \"@plexui/styles/components/Sidebar/Sidebar.module.css\"\n\n// Constants\nconst SIDEBAR_COOKIE_NAME = \"sidebar:state\"\nconst SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7 // 7 days\nconst SIDEBAR_WIDTH = \"240px\"\nconst SIDEBAR_WIDTH_APP = \"260px\"\nconst SIDEBAR_WIDTH_MOBILE = \"288px\"\nconst SIDEBAR_WIDTH_ICON = \"64px\"\nconst SIDEBAR_KEYBOARD_SHORTCUT = \"b\"\nconst MOBILE_BREAKPOINT = 768\n\n// Types\nexport type SidebarState = \"expanded\" | \"collapsed\"\nexport type SidebarCollapsible = \"offcanvas\" | \"icon\" | \"none\"\nexport type SidebarSide = \"left\" | \"right\"\nexport type SidebarVariant = \"sidebar\" | \"docs\"\nexport type SidebarProviderVariant = \"sidebar\" | \"app\"\n\nexport type SidebarContextValue = {\n state: SidebarState\n open: boolean\n setOpen: (open: boolean) => void\n openMobile: boolean\n setOpenMobile: (open: boolean) => void\n isMobile: boolean\n collapsible: SidebarCollapsible\n toggleSidebar: () => void\n}\n\n// Context\nconst SidebarContext = createContext<SidebarContextValue | null>(null)\n\n// Hook to access sidebar context\nexport const useSidebar = (): SidebarContextValue => {\n const context = useContext(SidebarContext)\n\n if (!context) {\n throw new Error(\"useSidebar must be used within a SidebarProvider\")\n }\n\n return context\n}\n\n// Hook for mobile detection via matchMedia. Read during render, so a phone\n// gets the mobile layout on its first paint instead of one frame of the\n// desktop sidebar; the server (and hydration) renders the desktop layout.\nconst MOBILE_QUERY = `(max-width: ${MOBILE_BREAKPOINT - 1}px)`\n\nconst subscribeToMobile = (onChange: () => void) => {\n const mql = window.matchMedia(MOBILE_QUERY)\n mql.addEventListener(\"change\", onChange)\n return () => mql.removeEventListener(\"change\", onChange)\n}\n\nconst getMobileSnapshot = () => window.matchMedia(MOBILE_QUERY).matches\nconst getServerMobileSnapshot = () => false\n\nfunction useIsMobile(): boolean {\n return useSyncExternalStore(subscribeToMobile, getMobileSnapshot, getServerMobileSnapshot)\n}\n\n// Provider props\nexport type SidebarProviderProps = {\n children: ReactNode\n /**\n * Default open state (uncontrolled)\n * @default true\n */\n defaultOpen?: boolean\n /**\n * Controlled open state\n */\n open?: boolean\n /**\n * Callback when open state changes\n */\n onOpenChange?: (open: boolean) => void\n /**\n * Collapsible mode\n * @default \"offcanvas\"\n */\n collapsible?: SidebarCollapsible\n /**\n * \"app\" is the shell of a product: a quiet rail, pill rows and on a phone a drawer under the page.\n * @default \"sidebar\"\n */\n variant?: SidebarProviderVariant\n /**\n * Custom CSS properties for the sidebar\n */\n style?: React.CSSProperties\n /**\n * Additional class name\n */\n className?: string\n}\n\n// Provider component\nexport const SidebarProvider = ({\n children,\n defaultOpen = true,\n open: openProp,\n onOpenChange: setOpenProp,\n collapsible = \"offcanvas\",\n variant = \"sidebar\",\n style,\n className,\n}: SidebarProviderProps) => {\n const isMobile = useIsMobile()\n const [openMobile, setOpenMobile] = useState(false)\n\n // Controlled vs uncontrolled state for desktop\n const [_open, _setOpen] = useState(defaultOpen)\n const open = openProp ?? _open\n\n const setOpen = useCallback(\n (value: boolean | ((prev: boolean) => boolean)) => {\n const openState = typeof value === \"function\" ? value(open) : value\n\n // Controlled only when `open` is passed; onOpenChange alone is a notification\n if (openProp === undefined) {\n _setOpen(openState)\n }\n setOpenProp?.(openState)\n\n // Persist state in cookie for SSR\n if (typeof document !== \"undefined\") {\n document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`\n }\n },\n [setOpenProp, openProp, open],\n )\n\n // Toggle function that handles both mobile and desktop\n const toggleSidebar = useCallback(() => {\n if (isMobile) {\n setOpenMobile((prev) => !prev)\n } else {\n setOpen((prev) => !prev)\n }\n }, [isMobile, setOpen])\n\n // Keyboard shortcut: Cmd/Ctrl + B\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n // Skip if collapsible is \"none\"\n if (collapsible === \"none\") return\n\n // Don't trigger when focus is in an editable element (input, textarea, contenteditable)\n const target = event.target as HTMLElement | null\n if (target?.closest?.(\"input, textarea\") || target?.isContentEditable) return\n\n // Check for Cmd (Mac) or Ctrl (Windows/Linux) + B\n if (\n event.key === SIDEBAR_KEYBOARD_SHORTCUT &&\n (event.metaKey || event.ctrlKey) &&\n !event.altKey &&\n !event.shiftKey\n ) {\n event.preventDefault()\n toggleSidebar()\n }\n }\n\n window.addEventListener(\"keydown\", handleKeyDown)\n return () => window.removeEventListener(\"keydown\", handleKeyDown)\n }, [toggleSidebar, collapsible])\n\n // Close mobile menu on escape key\n useEffect(() => {\n if (!openMobile) return\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n setOpenMobile(false)\n }\n }\n\n window.addEventListener(\"keydown\", handleKeyDown)\n return () => window.removeEventListener(\"keydown\", handleKeyDown)\n }, [openMobile])\n\n // Derive state from open boolean\n const state: SidebarState = open ? \"expanded\" : \"collapsed\"\n\n // Context value\n const contextValue = useMemo<SidebarContextValue>(\n () => ({\n state,\n open,\n setOpen,\n openMobile,\n setOpenMobile,\n isMobile,\n collapsible,\n toggleSidebar,\n }),\n [state, open, setOpen, openMobile, isMobile, collapsible, toggleSidebar],\n )\n\n return (\n <SidebarContext.Provider value={contextValue}>\n <div\n className={clsx(variant === \"app\" && s.App, className)}\n style={\n {\n \"--sidebar-width\": variant === \"app\" ? SIDEBAR_WIDTH_APP : SIDEBAR_WIDTH,\n \"--sidebar-width-mobile\": SIDEBAR_WIDTH_MOBILE,\n \"--sidebar-width-icon\": SIDEBAR_WIDTH_ICON,\n ...style,\n } as React.CSSProperties\n }\n data-sidebar={state}\n data-mobile-menu={openMobile ? \"visible\" : \"hidden\"}\n data-collapsible={collapsible}\n >\n {children}\n </div>\n </SidebarContext.Provider>\n )\n}\n\n// Re-export constants for external use\nexport const SIDEBAR_CONSTANTS = {\n WIDTH: SIDEBAR_WIDTH,\n WIDTH_APP: SIDEBAR_WIDTH_APP,\n WIDTH_MOBILE: SIDEBAR_WIDTH_MOBILE,\n WIDTH_ICON: SIDEBAR_WIDTH_ICON,\n KEYBOARD_SHORTCUT: SIDEBAR_KEYBOARD_SHORTCUT,\n MOBILE_BREAKPOINT,\n COOKIE_NAME: SIDEBAR_COOKIE_NAME,\n COOKIE_MAX_AGE: SIDEBAR_COOKIE_MAX_AGE,\n} as const\n"]}
|
|
1
|
+
{"version":3,"file":"useSidebarContext.js","sourceRoot":"","sources":["../../../../src/components/Sidebar/useSidebarContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,QAAQ,EACR,oBAAoB,GAErB,MAAM,OAAO,CAAA;AACd,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,CAAC,MAAM,sDAAsD,CAAA;AAEpE,YAAY;AACZ,MAAM,mBAAmB,GAAG,eAAe,CAAA;AAC3C,MAAM,sBAAsB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA,CAAC,SAAS;AACzD,MAAM,aAAa,GAAG,OAAO,CAAA;AAC7B,MAAM,iBAAiB,GAAG,OAAO,CAAA;AACjC,MAAM,oBAAoB,GAAG,OAAO,CAAA;AACpC,MAAM,kBAAkB,GAAG,MAAM,CAAA;AACjC,MAAM,yBAAyB,GAAG,GAAG,CAAA;AACrC,MAAM,iBAAiB,GAAG,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AsB;CAC9B,CAAA","sourcesContent":["\"use client\"\n\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\"\nimport clsx from \"clsx\"\nimport s from \"@plexui/styles/components/Sidebar/Sidebar.module.css\"\n\n// Constants\nconst SIDEBAR_COOKIE_NAME = \"sidebar:state\"\nconst SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7 // 7 days\nconst SIDEBAR_WIDTH = \"240px\"\nconst SIDEBAR_WIDTH_APP = \"260px\"\nconst SIDEBAR_WIDTH_MOBILE = \"288px\"\nconst SIDEBAR_WIDTH_ICON = \"64px\"\nconst SIDEBAR_KEYBOARD_SHORTCUT = \"b\"\nconst MOBILE_BREAKPOINT = 768\n\n// Types\nexport type SidebarState = \"expanded\" | \"collapsed\"\nexport type SidebarCollapsible = \"offcanvas\" | \"icon\" | \"none\"\nexport type SidebarSide = \"left\" | \"right\"\nexport type SidebarVariant = \"sidebar\" | \"docs\"\nexport type SidebarProviderVariant = \"sidebar\" | \"app\"\n\nexport type SidebarContextValue = {\n state: SidebarState\n open: boolean\n setOpen: (open: boolean) => void\n openMobile: boolean\n setOpenMobile: (open: boolean) => void\n isMobile: boolean\n collapsible: SidebarCollapsible\n toggleSidebar: () => void\n}\n\n// Context\nconst SidebarContext = createContext<SidebarContextValue | null>(null)\n\n// Hook to access sidebar context\nexport const useSidebar = (): SidebarContextValue => {\n const context = useContext(SidebarContext)\n\n if (!context) {\n throw new Error(\"useSidebar must be used within a SidebarProvider\")\n }\n\n return context\n}\n\n// Hook for mobile detection via matchMedia. Read during render, so a phone\n// gets the mobile layout on its first paint instead of one frame of the\n// desktop sidebar; the server (and hydration) renders the desktop layout.\nconst MOBILE_QUERY = `(max-width: ${MOBILE_BREAKPOINT - 1}px)`\n\nconst subscribeToMobile = (onChange: () => void) => {\n const mql = window.matchMedia(MOBILE_QUERY)\n mql.addEventListener(\"change\", onChange)\n return () => mql.removeEventListener(\"change\", onChange)\n}\n\nconst getMobileSnapshot = () => window.matchMedia(MOBILE_QUERY).matches\nconst getServerMobileSnapshot = () => false\n\nfunction useIsMobile(): boolean {\n return useSyncExternalStore(subscribeToMobile, getMobileSnapshot, getServerMobileSnapshot)\n}\n\n// Provider props\nexport type SidebarProviderProps = {\n children: ReactNode\n /**\n * Default open state (uncontrolled)\n * @default true\n */\n defaultOpen?: boolean\n /**\n * Controlled open state\n */\n open?: boolean\n /**\n * Callback when open state changes\n */\n onOpenChange?: (open: boolean) => void\n /**\n * Controlled open state of the phone drawer (`SidebarMobile`)\n */\n openMobile?: boolean\n /**\n * Initial open state of the phone drawer (uncontrolled)\n * @default false\n */\n defaultOpenMobile?: boolean\n /**\n * Called when the phone drawer opens or closes: its menu button, its backdrop, Escape or a swipe\n */\n onOpenMobileChange?: (open: boolean) => void\n /**\n * Collapsible mode\n * @default \"offcanvas\"\n */\n collapsible?: SidebarCollapsible\n /**\n * \"app\" is the shell of a product: a quiet rail, pill rows and on a phone a drawer under the page.\n * @default \"sidebar\"\n */\n variant?: SidebarProviderVariant\n /**\n * Custom CSS properties for the sidebar\n */\n style?: React.CSSProperties\n /**\n * Additional class name\n */\n className?: string\n}\n\n// Provider component\nexport const SidebarProvider = ({\n children,\n defaultOpen = true,\n open: openProp,\n onOpenChange: setOpenProp,\n openMobile: openMobileProp,\n defaultOpenMobile = false,\n onOpenMobileChange,\n collapsible = \"offcanvas\",\n variant = \"sidebar\",\n style,\n className,\n}: SidebarProviderProps) => {\n const isMobile = useIsMobile()\n // Controlled vs uncontrolled state for the phone drawer\n const [_openMobile, _setOpenMobile] = useState(defaultOpenMobile)\n const openMobile = openMobileProp ?? _openMobile\n\n const setOpenMobile = useCallback(\n (value: boolean | ((prev: boolean) => boolean)) => {\n const next = typeof value === \"function\" ? value(openMobile) : value\n if (next === openMobile) return\n if (openMobileProp === undefined) _setOpenMobile(next)\n onOpenMobileChange?.(next)\n },\n [openMobile, openMobileProp, onOpenMobileChange],\n )\n\n // Controlled vs uncontrolled state for desktop\n const [_open, _setOpen] = useState(defaultOpen)\n const open = openProp ?? _open\n\n const setOpen = useCallback(\n (value: boolean | ((prev: boolean) => boolean)) => {\n const openState = typeof value === \"function\" ? value(open) : value\n\n // Controlled only when `open` is passed; onOpenChange alone is a notification\n if (openProp === undefined) {\n _setOpen(openState)\n }\n setOpenProp?.(openState)\n\n // Persist state in cookie for SSR\n if (typeof document !== \"undefined\") {\n document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`\n }\n },\n [setOpenProp, openProp, open],\n )\n\n // Toggle function that handles both mobile and desktop\n const toggleSidebar = useCallback(() => {\n if (isMobile) {\n setOpenMobile((prev) => !prev)\n } else {\n setOpen((prev) => !prev)\n }\n }, [isMobile, setOpen, setOpenMobile])\n\n // Keyboard shortcut: Cmd/Ctrl + B\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n // Skip if collapsible is \"none\"\n if (collapsible === \"none\") return\n\n // Don't trigger when focus is in an editable element (input, textarea, contenteditable)\n const target = event.target as HTMLElement | null\n if (target?.closest?.(\"input, textarea\") || target?.isContentEditable) return\n\n // Check for Cmd (Mac) or Ctrl (Windows/Linux) + B\n if (\n event.key === SIDEBAR_KEYBOARD_SHORTCUT &&\n (event.metaKey || event.ctrlKey) &&\n !event.altKey &&\n !event.shiftKey\n ) {\n event.preventDefault()\n toggleSidebar()\n }\n }\n\n window.addEventListener(\"keydown\", handleKeyDown)\n return () => window.removeEventListener(\"keydown\", handleKeyDown)\n }, [toggleSidebar, collapsible])\n\n // Escape closes the drawer from inside it (SidebarMobile), so a layer over it takes its own Escape first\n\n // Derive state from open boolean\n const state: SidebarState = open ? \"expanded\" : \"collapsed\"\n\n // Context value\n const contextValue = useMemo<SidebarContextValue>(\n () => ({\n state,\n open,\n setOpen,\n openMobile,\n setOpenMobile,\n isMobile,\n collapsible,\n toggleSidebar,\n }),\n [state, open, setOpen, openMobile, setOpenMobile, isMobile, collapsible, toggleSidebar],\n )\n\n return (\n <SidebarContext.Provider value={contextValue}>\n <div\n className={clsx(variant === \"app\" && s.App, className)}\n style={\n {\n \"--sidebar-width\": variant === \"app\" ? SIDEBAR_WIDTH_APP : SIDEBAR_WIDTH,\n \"--sidebar-width-mobile\": SIDEBAR_WIDTH_MOBILE,\n \"--sidebar-width-icon\": SIDEBAR_WIDTH_ICON,\n ...style,\n } as React.CSSProperties\n }\n data-sidebar={state}\n data-mobile-menu={openMobile ? \"visible\" : \"hidden\"}\n data-collapsible={collapsible}\n >\n {children}\n </div>\n </SidebarContext.Provider>\n )\n}\n\n// Re-export constants for external use\nexport const SIDEBAR_CONSTANTS = {\n WIDTH: SIDEBAR_WIDTH,\n WIDTH_APP: SIDEBAR_WIDTH_APP,\n WIDTH_MOBILE: SIDEBAR_WIDTH_MOBILE,\n WIDTH_ICON: SIDEBAR_WIDTH_ICON,\n KEYBOARD_SHORTCUT: SIDEBAR_KEYBOARD_SHORTCUT,\n MOBILE_BREAKPOINT,\n COOKIE_NAME: SIDEBAR_COOKIE_NAME,\n COOKIE_MAX_AGE: SIDEBAR_COOKIE_MAX_AGE,\n} as const\n"]}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The phone drawer of Sidebar, shared by React and Vue (one copy per package, kept identical by lib-sync).
|
|
3
|
+
*
|
|
4
|
+
* - It follows the finger: a swipe in from the edge it lives behind opens it, a swipe back toward that edge closes
|
|
5
|
+
* it, and either finishes on release by how far and how fast the finger went. The drawer says its edge in
|
|
6
|
+
* `--sidebar-drawer-edge` (`left` or `right`). While a finger drags it, the root carries `data-mobile-dragging`
|
|
7
|
+
* and `--sidebar-drawer-progress` (0 closed to 1 open), and the styles place the drawer by them.
|
|
8
|
+
* - While it is open, Tab goes round its controls (the page behind is inert), and Escape closes it once every other
|
|
9
|
+
* listener has had the key, so a menu or dialog over the drawer takes its own Escape first.
|
|
10
|
+
*/
|
|
11
|
+
/** How far in from its edge a swipe that opens the drawer may start */
|
|
12
|
+
export const DRAWER_EDGE_ZONE = 24;
|
|
13
|
+
/** How far a finger moves before the swipe is taken as horizontal or left to the page */
|
|
14
|
+
export const DRAWER_SWIPE_SLOP = 10;
|
|
15
|
+
/** A release faster than this, in px/ms, finishes the swipe in its direction whatever the distance */
|
|
16
|
+
export const DRAWER_SWIPE_VELOCITY = 0.3;
|
|
17
|
+
/** A finger held still this long, in ms, before it lifts lets go by distance alone */
|
|
18
|
+
export const DRAWER_SWIPE_HOLD = 100;
|
|
19
|
+
const edgeOf = (drawer) => getComputedStyle(drawer).getPropertyValue("--sidebar-drawer-edge").trim() === "left" ? "left" : "right";
|
|
20
|
+
/** The distance the drawer travels: its own width when it slides in beside the page, else its container's width */
|
|
21
|
+
const travelOf = (drawer, root, edge) => {
|
|
22
|
+
if (edge === "left")
|
|
23
|
+
return drawer.getBoundingClientRect().width || root.getBoundingClientRect().width;
|
|
24
|
+
const container = drawer.offsetParent instanceof HTMLElement ? drawer.offsetParent : null;
|
|
25
|
+
return container?.clientWidth || window.innerWidth;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A finger on a slider, on an element that takes horizontal touches itself (`touch-action` without `pan-x`, such
|
|
29
|
+
* as the Slider) or in a row that scrolls sideways moves that, not the drawer
|
|
30
|
+
*/
|
|
31
|
+
const ownsHorizontalSwipe = (target, root) => {
|
|
32
|
+
for (let node = target instanceof Element ? target : null; node && node !== root; node = node.parentElement) {
|
|
33
|
+
if ((node instanceof HTMLInputElement && node.type === "range") || node.getAttribute("role") === "slider")
|
|
34
|
+
return true;
|
|
35
|
+
const style = getComputedStyle(node);
|
|
36
|
+
if (/^(none|pan-y|pinch-zoom)/.test(style.touchAction) && !style.touchAction.includes("pan-x"))
|
|
37
|
+
return true;
|
|
38
|
+
if (node.scrollWidth > node.clientWidth && /auto|scroll/.test(style.overflowX))
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* A popover or menu open over the drawer (the Radix and Reka popper wrappers) keeps the touch: swiping the drawer
|
|
45
|
+
* away from under it would leave it open on an inert trigger. A modal dialog's overlay already covers the drawer.
|
|
46
|
+
*/
|
|
47
|
+
const layerOpen = (root) => root.ownerDocument.querySelector("[data-radix-popper-content-wrapper], [data-reka-popper-content-wrapper]") !== null;
|
|
48
|
+
/** Starts the gesture on `root`; returns the cleanup */
|
|
49
|
+
export function attachDrawerSwipe({ root, drawer, isOpen, setOpen, enabled = () => true }) {
|
|
50
|
+
let drag = null;
|
|
51
|
+
const setProgress = (progress) => {
|
|
52
|
+
root.style.setProperty("--sidebar-drawer-progress", String(progress));
|
|
53
|
+
};
|
|
54
|
+
const end = (commit, time = 0) => {
|
|
55
|
+
const current = drag;
|
|
56
|
+
drag = null;
|
|
57
|
+
if (!current || current.state !== "dragging")
|
|
58
|
+
return;
|
|
59
|
+
let next = current.open;
|
|
60
|
+
if (commit) {
|
|
61
|
+
// Velocity in the opening direction is positive; a finger that stopped before lifting has none
|
|
62
|
+
const velocity = time - current.lastTime > DRAWER_SWIPE_HOLD ? 0 : current.velocity;
|
|
63
|
+
const opening = current.edge === "left" ? velocity : -velocity;
|
|
64
|
+
next = opening > DRAWER_SWIPE_VELOCITY ? true : opening < -DRAWER_SWIPE_VELOCITY ? false : current.progress > 0.5;
|
|
65
|
+
}
|
|
66
|
+
if (next !== current.open)
|
|
67
|
+
setOpen(next);
|
|
68
|
+
// The drawer leaves the finger once the new state is on the page, so it animates from where it was let go
|
|
69
|
+
requestAnimationFrame(() => {
|
|
70
|
+
root.removeAttribute("data-mobile-dragging");
|
|
71
|
+
root.style.removeProperty("--sidebar-drawer-progress");
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
const onTouchStart = (event) => {
|
|
75
|
+
// A second finger cancels a swipe under way, and the drawer goes back to where it was
|
|
76
|
+
end(false);
|
|
77
|
+
if (event.touches.length !== 1 || !enabled() || layerOpen(root) || ownsHorizontalSwipe(event.target, root))
|
|
78
|
+
return;
|
|
79
|
+
const touch = event.touches[0];
|
|
80
|
+
const open = isOpen();
|
|
81
|
+
const edge = edgeOf(drawer);
|
|
82
|
+
if (!open) {
|
|
83
|
+
const bounds = root.getBoundingClientRect();
|
|
84
|
+
const fromEdge = edge === "left" ? touch.clientX - bounds.left : bounds.right - touch.clientX;
|
|
85
|
+
if (fromEdge < 0 || fromEdge > DRAWER_EDGE_ZONE)
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
drag = {
|
|
89
|
+
x: touch.clientX,
|
|
90
|
+
y: touch.clientY,
|
|
91
|
+
lastX: touch.clientX,
|
|
92
|
+
lastTime: event.timeStamp,
|
|
93
|
+
velocity: 0,
|
|
94
|
+
open,
|
|
95
|
+
edge,
|
|
96
|
+
travel: Math.max(1, travelOf(drawer, root, edge)),
|
|
97
|
+
state: "pending",
|
|
98
|
+
progress: open ? 1 : 0,
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
const onTouchMove = (event) => {
|
|
102
|
+
if (!drag || drag.state === "ignored")
|
|
103
|
+
return;
|
|
104
|
+
// A second finger put down outside the root shows only here
|
|
105
|
+
if (event.touches.length !== 1) {
|
|
106
|
+
end(false);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const touch = event.touches[0];
|
|
110
|
+
if (!touch)
|
|
111
|
+
return;
|
|
112
|
+
const dx = touch.clientX - drag.x;
|
|
113
|
+
const dy = touch.clientY - drag.y;
|
|
114
|
+
// Toward the open drawer is positive
|
|
115
|
+
const toward = drag.edge === "left" ? dx : -dx;
|
|
116
|
+
if (drag.state === "pending") {
|
|
117
|
+
if (Math.abs(dx) < DRAWER_SWIPE_SLOP && Math.abs(dy) < DRAWER_SWIPE_SLOP)
|
|
118
|
+
return;
|
|
119
|
+
const horizontal = Math.abs(dx) > Math.abs(dy);
|
|
120
|
+
if (!horizontal || (drag.open ? toward >= 0 : toward <= 0)) {
|
|
121
|
+
drag.state = "ignored";
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
drag.state = "dragging";
|
|
125
|
+
root.setAttribute("data-mobile-dragging", "");
|
|
126
|
+
}
|
|
127
|
+
if (event.cancelable)
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
const elapsed = event.timeStamp - drag.lastTime;
|
|
130
|
+
if (elapsed > 0)
|
|
131
|
+
drag.velocity = (touch.clientX - drag.lastX) / elapsed;
|
|
132
|
+
drag.lastX = touch.clientX;
|
|
133
|
+
drag.lastTime = event.timeStamp;
|
|
134
|
+
drag.progress = Math.min(1, Math.max(0, (drag.open ? 1 : 0) + toward / drag.travel));
|
|
135
|
+
setProgress(drag.progress);
|
|
136
|
+
};
|
|
137
|
+
// A finger lifted while another stays on the screen cancels the swipe
|
|
138
|
+
const onTouchEnd = (event) => end(event.touches.length === 0, event.timeStamp);
|
|
139
|
+
const onTouchCancel = () => end(false);
|
|
140
|
+
root.addEventListener("touchstart", onTouchStart, { passive: true });
|
|
141
|
+
root.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
142
|
+
root.addEventListener("touchend", onTouchEnd);
|
|
143
|
+
root.addEventListener("touchcancel", onTouchCancel);
|
|
144
|
+
return () => {
|
|
145
|
+
root.removeEventListener("touchstart", onTouchStart);
|
|
146
|
+
root.removeEventListener("touchmove", onTouchMove);
|
|
147
|
+
root.removeEventListener("touchend", onTouchEnd);
|
|
148
|
+
root.removeEventListener("touchcancel", onTouchCancel);
|
|
149
|
+
root.removeAttribute("data-mobile-dragging");
|
|
150
|
+
root.style.removeProperty("--sidebar-drawer-progress");
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const TABBABLE = 'a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), iframe, [contenteditable]:not([contenteditable="false"]), [tabindex]';
|
|
154
|
+
/** The controls Tab reaches in the drawer, in order: not disabled (a disabled fieldset too), not in a closed submenu, not hidden */
|
|
155
|
+
export const drawerTabbables = (drawer) => Array.from(drawer.querySelectorAll(TABBABLE)).filter((element) => element.tabIndex >= 0 &&
|
|
156
|
+
!element.matches(":disabled") &&
|
|
157
|
+
!element.closest("[inert], [hidden]") &&
|
|
158
|
+
(typeof element.checkVisibility !== "function" || element.checkVisibility({ visibilityProperty: true })));
|
|
159
|
+
/** The first control of the open drawer, or the drawer itself */
|
|
160
|
+
export const drawerInitialFocus = (drawer) => drawerTabbables(drawer)[0] ?? drawer;
|
|
161
|
+
/**
|
|
162
|
+
* Tab from the last control goes to the first and Shift+Tab from the first to the last, so focus stays in the open
|
|
163
|
+
* drawer. A layer over it in a portal (a menu, a dialog) keeps its own Tab.
|
|
164
|
+
*/
|
|
165
|
+
export function loopDrawerFocus(event, drawer) {
|
|
166
|
+
if (event.key !== "Tab" || event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey)
|
|
167
|
+
return;
|
|
168
|
+
if (!(event.target instanceof Node) || !drawer.contains(event.target))
|
|
169
|
+
return;
|
|
170
|
+
const items = drawerTabbables(drawer);
|
|
171
|
+
const active = drawer.ownerDocument.activeElement;
|
|
172
|
+
const first = items[0];
|
|
173
|
+
const last = items[items.length - 1];
|
|
174
|
+
if (!first || !last) {
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
drawer.focus({ preventScroll: true });
|
|
177
|
+
}
|
|
178
|
+
else if (event.shiftKey && (active === first || active === drawer)) {
|
|
179
|
+
event.preventDefault();
|
|
180
|
+
last.focus({ preventScroll: true });
|
|
181
|
+
}
|
|
182
|
+
else if (!event.shiftKey && active === last) {
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
first.focus({ preventScroll: true });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Escape pressed in the open drawer closes it when the key reaches the window unprevented: a menu, popover or dialog
|
|
189
|
+
* over the drawer has its listener on the way there and takes the key first, however it listens.
|
|
190
|
+
*/
|
|
191
|
+
export function closeOnUnhandledEscape(event, drawer, close) {
|
|
192
|
+
if (event.key !== "Escape" || event.defaultPrevented)
|
|
193
|
+
return;
|
|
194
|
+
const view = drawer.ownerDocument.defaultView;
|
|
195
|
+
if (!view)
|
|
196
|
+
return;
|
|
197
|
+
const afterOthers = (late) => {
|
|
198
|
+
view.removeEventListener("keydown", afterOthers);
|
|
199
|
+
// A listener that stopped the key on its way leaves this one to the next key, which only removes it
|
|
200
|
+
if (late !== event || event.defaultPrevented)
|
|
201
|
+
return;
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
close();
|
|
204
|
+
};
|
|
205
|
+
view.addEventListener("keydown", afterOthers);
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=phoneDrawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phoneDrawer.js","sourceRoot":"","sources":["../../../src/lib/phoneDrawer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,uEAAuE;AACvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAClC,yFAAyF;AACzF,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AACnC,sGAAsG;AACtG,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;AACxC,sFAAsF;AACtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AA0BpC,MAAM,MAAM,GAAG,CAAC,MAAmB,EAAoB,EAAE,CACvD,gBAAgB,CAAC,MAAM,CAAC,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAA;AAEzG,mHAAmH;AACnH,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAAE,IAAiB,EAAE,IAAsB,EAAE,EAAE;IAClF,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC,qBAAqB,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,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AAoB,EAAE,MAAmB,EAAE,KAAiB;IACjG,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,gBAAgB;QAAE,OAAM;IAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,CAAC,WAAW,CAAA;IAC7C,IAAI,CAAC,IAAI;QAAE,OAAM;IACjB,MAAM,WAAW,GAAG,CAAC,IAAW,EAAE,EAAE;QAClC,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;QAChD,oGAAoG;QACpG,IAAI,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,gBAAgB;YAAE,OAAM;QACpD,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,KAAK,EAAE,CAAA;IACT,CAAC,CAAA;IACD,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["/**\n * The phone drawer of Sidebar, shared by React and Vue (one copy per package, kept identical by lib-sync).\n *\n * - It follows the finger: a swipe in from the edge it lives behind opens it, a swipe back toward that edge closes\n * it, and either finishes on release by how far and how fast the finger went. The drawer says its edge in\n * `--sidebar-drawer-edge` (`left` or `right`). While a finger drags it, the root carries `data-mobile-dragging`\n * and `--sidebar-drawer-progress` (0 closed to 1 open), and the styles place the drawer by them.\n * - While it is open, Tab goes round its controls (the page behind is inert), and Escape closes it once every other\n * listener has had the key, so a menu or dialog over the drawer takes its own Escape first.\n */\n\n/** How far in from its edge a swipe that opens the drawer may start */\nexport const DRAWER_EDGE_ZONE = 24\n/** How far a finger moves before the swipe is taken as horizontal or left to the page */\nexport const DRAWER_SWIPE_SLOP = 10\n/** A release faster than this, in px/ms, finishes the swipe in its direction whatever the distance */\nexport const DRAWER_SWIPE_VELOCITY = 0.3\n/** A finger held still this long, in ms, before it lifts lets go by distance alone */\nexport const DRAWER_SWIPE_HOLD = 100\n\nexport type DrawerSwipeOptions = {\n /** The element that holds the drawer and the page, where the drag state is written */\n root: HTMLElement\n /** The drawer itself */\n drawer: HTMLElement\n isOpen: () => boolean\n setOpen: (open: boolean) => void\n /** False turns the gesture off (a wide layout) */\n enabled?: () => boolean\n}\n\ntype Drag = {\n x: number\n y: number\n lastX: number\n lastTime: number\n velocity: number\n open: boolean\n edge: \"left\" | \"right\"\n travel: number\n state: \"pending\" | \"dragging\" | \"ignored\"\n progress: number\n}\n\nconst edgeOf = (drawer: HTMLElement): \"left\" | \"right\" =>\n getComputedStyle(drawer).getPropertyValue(\"--sidebar-drawer-edge\").trim() === \"left\" ? \"left\" : \"right\"\n\n/** The distance the drawer travels: its own width when it slides in beside the page, else its container's width */\nconst travelOf = (drawer: HTMLElement, root: HTMLElement, edge: \"left\" | \"right\") => {\n if (edge === \"left\") return drawer.getBoundingClientRect().width || root.getBoundingClientRect().width\n const container = drawer.offsetParent instanceof HTMLElement ? drawer.offsetParent : null\n return container?.clientWidth || window.innerWidth\n}\n\n/**\n * A finger on a slider, on an element that takes horizontal touches itself (`touch-action` without `pan-x`, such\n * as the Slider) or in a row that scrolls sideways moves that, not the drawer\n */\nconst ownsHorizontalSwipe = (target: EventTarget | null, root: HTMLElement) => {\n for (let node = target instanceof Element ? target : null; node && node !== root; node = node.parentElement) {\n if ((node instanceof HTMLInputElement && node.type === \"range\") || node.getAttribute(\"role\") === \"slider\") return true\n const style = getComputedStyle(node)\n if (/^(none|pan-y|pinch-zoom)/.test(style.touchAction) && !style.touchAction.includes(\"pan-x\")) return true\n if (node.scrollWidth > node.clientWidth && /auto|scroll/.test(style.overflowX)) return true\n }\n return false\n}\n\n/**\n * A popover or menu open over the drawer (the Radix and Reka popper wrappers) keeps the touch: swiping the drawer\n * away from under it would leave it open on an inert trigger. A modal dialog's overlay already covers the drawer.\n */\nconst layerOpen = (root: HTMLElement) =>\n root.ownerDocument.querySelector(\"[data-radix-popper-content-wrapper], [data-reka-popper-content-wrapper]\") !== null\n\n/** Starts the gesture on `root`; returns the cleanup */\nexport function attachDrawerSwipe({ root, drawer, isOpen, setOpen, enabled = () => true }: DrawerSwipeOptions) {\n let drag: Drag | null = null\n\n const setProgress = (progress: number) => {\n root.style.setProperty(\"--sidebar-drawer-progress\", String(progress))\n }\n\n const end = (commit: boolean, time = 0) => {\n const current = drag\n drag = null\n if (!current || current.state !== \"dragging\") return\n let next = current.open\n if (commit) {\n // Velocity in the opening direction is positive; a finger that stopped before lifting has none\n const velocity = time - current.lastTime > DRAWER_SWIPE_HOLD ? 0 : current.velocity\n const opening = current.edge === \"left\" ? velocity : -velocity\n next = opening > DRAWER_SWIPE_VELOCITY ? true : opening < -DRAWER_SWIPE_VELOCITY ? false : current.progress > 0.5\n }\n if (next !== current.open) setOpen(next)\n // The drawer leaves the finger once the new state is on the page, so it animates from where it was let go\n requestAnimationFrame(() => {\n root.removeAttribute(\"data-mobile-dragging\")\n root.style.removeProperty(\"--sidebar-drawer-progress\")\n })\n }\n\n const onTouchStart = (event: TouchEvent) => {\n // A second finger cancels a swipe under way, and the drawer goes back to where it was\n end(false)\n if (event.touches.length !== 1 || !enabled() || layerOpen(root) || ownsHorizontalSwipe(event.target, root)) return\n const touch = event.touches[0]!\n const open = isOpen()\n const edge = edgeOf(drawer)\n if (!open) {\n const bounds = root.getBoundingClientRect()\n const fromEdge = edge === \"left\" ? touch.clientX - bounds.left : bounds.right - touch.clientX\n if (fromEdge < 0 || fromEdge > DRAWER_EDGE_ZONE) return\n }\n drag = {\n x: touch.clientX,\n y: touch.clientY,\n lastX: touch.clientX,\n lastTime: event.timeStamp,\n velocity: 0,\n open,\n edge,\n travel: Math.max(1, travelOf(drawer, root, edge)),\n state: \"pending\",\n progress: open ? 1 : 0,\n }\n }\n\n const onTouchMove = (event: TouchEvent) => {\n if (!drag || drag.state === \"ignored\") return\n // A second finger put down outside the root shows only here\n if (event.touches.length !== 1) {\n end(false)\n return\n }\n const touch = event.touches[0]\n if (!touch) return\n const dx = touch.clientX - drag.x\n const dy = touch.clientY - drag.y\n // Toward the open drawer is positive\n const toward = drag.edge === \"left\" ? dx : -dx\n if (drag.state === \"pending\") {\n if (Math.abs(dx) < DRAWER_SWIPE_SLOP && Math.abs(dy) < DRAWER_SWIPE_SLOP) return\n const horizontal = Math.abs(dx) > Math.abs(dy)\n if (!horizontal || (drag.open ? toward >= 0 : toward <= 0)) {\n drag.state = \"ignored\"\n return\n }\n drag.state = \"dragging\"\n root.setAttribute(\"data-mobile-dragging\", \"\")\n }\n if (event.cancelable) event.preventDefault()\n const elapsed = event.timeStamp - drag.lastTime\n if (elapsed > 0) drag.velocity = (touch.clientX - drag.lastX) / elapsed\n drag.lastX = touch.clientX\n drag.lastTime = event.timeStamp\n drag.progress = Math.min(1, Math.max(0, (drag.open ? 1 : 0) + toward / drag.travel))\n setProgress(drag.progress)\n }\n\n // A finger lifted while another stays on the screen cancels the swipe\n const onTouchEnd = (event: TouchEvent) => end(event.touches.length === 0, event.timeStamp)\n const onTouchCancel = () => end(false)\n\n root.addEventListener(\"touchstart\", onTouchStart, { passive: true })\n root.addEventListener(\"touchmove\", onTouchMove, { passive: false })\n root.addEventListener(\"touchend\", onTouchEnd)\n root.addEventListener(\"touchcancel\", onTouchCancel)\n return () => {\n root.removeEventListener(\"touchstart\", onTouchStart)\n root.removeEventListener(\"touchmove\", onTouchMove)\n root.removeEventListener(\"touchend\", onTouchEnd)\n root.removeEventListener(\"touchcancel\", onTouchCancel)\n root.removeAttribute(\"data-mobile-dragging\")\n root.style.removeProperty(\"--sidebar-drawer-progress\")\n }\n}\n\nconst TABBABLE =\n 'a[href], area[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), iframe, [contenteditable]:not([contenteditable=\"false\"]), [tabindex]'\n\n/** The controls Tab reaches in the drawer, in order: not disabled (a disabled fieldset too), not in a closed submenu, not hidden */\nexport const drawerTabbables = (drawer: HTMLElement) =>\n Array.from(drawer.querySelectorAll<HTMLElement>(TABBABLE)).filter(\n (element) =>\n element.tabIndex >= 0 &&\n !element.matches(\":disabled\") &&\n !element.closest(\"[inert], [hidden]\") &&\n (typeof element.checkVisibility !== \"function\" || element.checkVisibility({ visibilityProperty: true })),\n )\n\n/** The first control of the open drawer, or the drawer itself */\nexport const drawerInitialFocus = (drawer: HTMLElement) => drawerTabbables(drawer)[0] ?? drawer\n\n/**\n * Tab from the last control goes to the first and Shift+Tab from the first to the last, so focus stays in the open\n * drawer. A layer over it in a portal (a menu, a dialog) keeps its own Tab.\n */\nexport function loopDrawerFocus(event: KeyboardEvent, drawer: HTMLElement) {\n if (event.key !== \"Tab\" || event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return\n if (!(event.target instanceof Node) || !drawer.contains(event.target)) return\n const items = drawerTabbables(drawer)\n const active = drawer.ownerDocument.activeElement\n const first = items[0]\n const last = items[items.length - 1]\n if (!first || !last) {\n event.preventDefault()\n drawer.focus({ preventScroll: true })\n } else if (event.shiftKey && (active === first || active === drawer)) {\n event.preventDefault()\n last.focus({ preventScroll: true })\n } else if (!event.shiftKey && active === last) {\n event.preventDefault()\n first.focus({ preventScroll: true })\n }\n}\n\n/**\n * Escape pressed in the open drawer closes it when the key reaches the window unprevented: a menu, popover or dialog\n * over the drawer has its listener on the way there and takes the key first, however it listens.\n */\nexport function closeOnUnhandledEscape(event: KeyboardEvent, drawer: HTMLElement, close: () => void) {\n if (event.key !== \"Escape\" || event.defaultPrevented) return\n const view = drawer.ownerDocument.defaultView\n if (!view) return\n const afterOthers = (late: Event) => {\n view.removeEventListener(\"keydown\", afterOthers)\n // A listener that stopped the key on its way leaves this one to the next key, which only removes it\n if (late !== event || event.defaultPrevented) return\n event.preventDefault()\n close()\n }\n view.addEventListener(\"keydown\", afterOthers)\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ReactNode, type Ref } from "react";
|
|
2
2
|
import { type SemanticColors, type Variants } from "../../types.js";
|
|
3
|
+
export type AlertMobileActions = "capsules" | "own";
|
|
3
4
|
export type AlertProps = {
|
|
4
5
|
/**
|
|
5
6
|
* Color for the button
|
|
@@ -19,6 +20,12 @@ export type AlertProps = {
|
|
|
19
20
|
actions?: ReactNode;
|
|
20
21
|
/** Sets the placement of `actions` always on the end or the bottom. Default behavior is automatic placement based on sizing. */
|
|
21
22
|
actionsPlacement?: "end" | "bottom";
|
|
23
|
+
/**
|
|
24
|
+
* How the actions show at 767px and below: 50px capsules side by side, as the buttons of an iOS tip (TipKit), or
|
|
25
|
+
* the buttons as given, at their own size, for an alert inside a block of buttons of its own.
|
|
26
|
+
* @default "capsules"
|
|
27
|
+
*/
|
|
28
|
+
mobileActions?: AlertMobileActions;
|
|
22
29
|
/** Optional override for the default indicator of the alert. When `false`, no indicator is shown. */
|
|
23
30
|
indicator?: ReactNode | false;
|
|
24
31
|
/** Class applied to the alert container */
|
|
@@ -36,7 +43,7 @@ export type AlertProps = {
|
|
|
36
43
|
/** Ref applied to the alert container */
|
|
37
44
|
ref?: Ref<HTMLDivElement>;
|
|
38
45
|
};
|
|
39
|
-
export declare const Alert: ({ color, variant, title, description, actions, actionsPlacement, indicator, className, actionsClassName, onDismiss, banner, ref, ...restProps }: AlertProps) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare const Alert: ({ color, variant, title, description, actions, actionsPlacement, mobileActions, indicator, className, actionsClassName, onDismiss, banner, ref, ...restProps }: AlertProps) => import("react/jsx-runtime").JSX.Element;
|
|
40
47
|
export declare const Indicator: ({ color }: {
|
|
41
48
|
color: AlertProps["color"];
|
|
42
49
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Alert, type AlertProps } from "./Alert.js";
|
|
1
|
+
export { Alert, type AlertMobileActions, type AlertProps } from "./Alert.js";
|
|
@@ -145,7 +145,18 @@ export declare const SidebarMobileMenuButton: import("react").ForwardRefExoticCo
|
|
|
145
145
|
export type SidebarMobileProps = ComponentProps<"div"> & {
|
|
146
146
|
/** When true, drawer is positioned absolute instead of fixed (for contained demos) */
|
|
147
147
|
contained?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Rows that lead to another page end with a disclosure chevron, as in an iOS list. `false` leaves it out.
|
|
150
|
+
* @default true
|
|
151
|
+
*/
|
|
152
|
+
disclosure?: boolean;
|
|
148
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* The phone drawer: a modal dialog while it is open. Focus moves into it and Tab goes round its controls, the page
|
|
156
|
+
* behind is inert (SidebarInset), Escape inside it closes it after any layer over it has taken its own, and focus
|
|
157
|
+
* goes back to the control that opened it. A swipe in from the edge it slides from opens it and a swipe back closes
|
|
158
|
+
* it (lib/phoneDrawer).
|
|
159
|
+
*/
|
|
149
160
|
export declare const SidebarMobile: import("react").ForwardRefExoticComponent<Omit<SidebarMobileProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
150
161
|
export type SidebarMobileHeaderProps = ComponentProps<"div">;
|
|
151
162
|
export declare const SidebarMobileHeader: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -30,6 +30,19 @@ export type SidebarProviderProps = {
|
|
|
30
30
|
* Callback when open state changes
|
|
31
31
|
*/
|
|
32
32
|
onOpenChange?: (open: boolean) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Controlled open state of the phone drawer (`SidebarMobile`)
|
|
35
|
+
*/
|
|
36
|
+
openMobile?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Initial open state of the phone drawer (uncontrolled)
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
defaultOpenMobile?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Called when the phone drawer opens or closes: its menu button, its backdrop, Escape or a swipe
|
|
44
|
+
*/
|
|
45
|
+
onOpenMobileChange?: (open: boolean) => void;
|
|
33
46
|
/**
|
|
34
47
|
* Collapsible mode
|
|
35
48
|
* @default "offcanvas"
|
|
@@ -49,7 +62,7 @@ export type SidebarProviderProps = {
|
|
|
49
62
|
*/
|
|
50
63
|
className?: string;
|
|
51
64
|
};
|
|
52
|
-
export declare const SidebarProvider: ({ children, defaultOpen, open: openProp, onOpenChange: setOpenProp, collapsible, variant, style, className, }: SidebarProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
export declare const SidebarProvider: ({ children, defaultOpen, open: openProp, onOpenChange: setOpenProp, openMobile: openMobileProp, defaultOpenMobile, onOpenMobileChange, collapsible, variant, style, className, }: SidebarProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
53
66
|
export declare const SIDEBAR_CONSTANTS: {
|
|
54
67
|
readonly WIDTH: "240px";
|
|
55
68
|
readonly WIDTH_APP: "260px";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The phone drawer of Sidebar, shared by React and Vue (one copy per package, kept identical by lib-sync).
|
|
3
|
+
*
|
|
4
|
+
* - It follows the finger: a swipe in from the edge it lives behind opens it, a swipe back toward that edge closes
|
|
5
|
+
* it, and either finishes on release by how far and how fast the finger went. The drawer says its edge in
|
|
6
|
+
* `--sidebar-drawer-edge` (`left` or `right`). While a finger drags it, the root carries `data-mobile-dragging`
|
|
7
|
+
* and `--sidebar-drawer-progress` (0 closed to 1 open), and the styles place the drawer by them.
|
|
8
|
+
* - While it is open, Tab goes round its controls (the page behind is inert), and Escape closes it once every other
|
|
9
|
+
* listener has had the key, so a menu or dialog over the drawer takes its own Escape first.
|
|
10
|
+
*/
|
|
11
|
+
/** How far in from its edge a swipe that opens the drawer may start */
|
|
12
|
+
export declare const DRAWER_EDGE_ZONE = 24;
|
|
13
|
+
/** How far a finger moves before the swipe is taken as horizontal or left to the page */
|
|
14
|
+
export declare const DRAWER_SWIPE_SLOP = 10;
|
|
15
|
+
/** A release faster than this, in px/ms, finishes the swipe in its direction whatever the distance */
|
|
16
|
+
export declare const DRAWER_SWIPE_VELOCITY = 0.3;
|
|
17
|
+
/** A finger held still this long, in ms, before it lifts lets go by distance alone */
|
|
18
|
+
export declare const DRAWER_SWIPE_HOLD = 100;
|
|
19
|
+
export type DrawerSwipeOptions = {
|
|
20
|
+
/** The element that holds the drawer and the page, where the drag state is written */
|
|
21
|
+
root: HTMLElement;
|
|
22
|
+
/** The drawer itself */
|
|
23
|
+
drawer: HTMLElement;
|
|
24
|
+
isOpen: () => boolean;
|
|
25
|
+
setOpen: (open: boolean) => void;
|
|
26
|
+
/** False turns the gesture off (a wide layout) */
|
|
27
|
+
enabled?: () => boolean;
|
|
28
|
+
};
|
|
29
|
+
/** Starts the gesture on `root`; returns the cleanup */
|
|
30
|
+
export declare function attachDrawerSwipe({ root, drawer, isOpen, setOpen, enabled }: DrawerSwipeOptions): () => void;
|
|
31
|
+
/** The controls Tab reaches in the drawer, in order: not disabled (a disabled fieldset too), not in a closed submenu, not hidden */
|
|
32
|
+
export declare const drawerTabbables: (drawer: HTMLElement) => HTMLElement[];
|
|
33
|
+
/** The first control of the open drawer, or the drawer itself */
|
|
34
|
+
export declare const drawerInitialFocus: (drawer: HTMLElement) => HTMLElement;
|
|
35
|
+
/**
|
|
36
|
+
* Tab from the last control goes to the first and Shift+Tab from the first to the last, so focus stays in the open
|
|
37
|
+
* drawer. A layer over it in a portal (a menu, a dialog) keeps its own Tab.
|
|
38
|
+
*/
|
|
39
|
+
export declare function loopDrawerFocus(event: KeyboardEvent, drawer: HTMLElement): void;
|
|
40
|
+
/**
|
|
41
|
+
* Escape pressed in the open drawer closes it when the key reaches the window unprevented: a menu, popover or dialog
|
|
42
|
+
* over the drawer has its listener on the way there and takes the key first, however it listens.
|
|
43
|
+
*/
|
|
44
|
+
export declare function closeOnUnhandledEscape(event: KeyboardEvent, drawer: HTMLElement, close: () => void): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexui/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "Modern design system for building high-quality applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@maskito/core": "^5.2.2",
|
|
100
100
|
"@maskito/kit": "^5.2.2",
|
|
101
101
|
"@maskito/react": "^5.2.2",
|
|
102
|
-
"@plexui/styles": "^0.1.
|
|
102
|
+
"@plexui/styles": "^0.1.41",
|
|
103
103
|
"@radix-ui/react-dismissable-layer": "1.2.1",
|
|
104
104
|
"@radix-ui/react-focus-guards": "1.2.0",
|
|
105
105
|
"@radix-ui/react-focus-scope": "1.3.1",
|