@lerianstudio/sindarian-ui 2.0.0-beta.8 → 2.0.0-beta.9
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/components/breadcrumb/index.d.ts.map +1 -1
- package/dist/components/breadcrumb/index.js +25 -1
- package/dist/components/card/account-card/index.js +5 -5
- package/dist/components/card/basic-card/index.d.ts.map +1 -1
- package/dist/components/card/basic-card/index.js +2 -2
- package/dist/components/card/entity-card/index.js +1 -1
- package/dist/components/entity-box/index.d.ts +18 -2
- package/dist/components/entity-box/index.d.ts.map +1 -1
- package/dist/components/entity-box/index.js +32 -4
- package/dist/components/form/password-field/index.d.ts +5 -1
- package/dist/components/form/password-field/index.d.ts.map +1 -1
- package/dist/components/form/password-field/index.js +2 -2
- package/dist/components/page-header/index.js +1 -1
- package/dist/components/table/id-table-cell.d.ts +5 -1
- package/dist/components/table/id-table-cell.d.ts.map +1 -1
- package/dist/components/table/id-table-cell.js +48 -6
- package/dist/components/ui/autocomplete/index.d.ts +24 -0
- package/dist/components/ui/autocomplete/index.d.ts.map +1 -1
- package/dist/components/ui/autocomplete/index.js +24 -0
- package/dist/components/ui/copy-field/index.d.ts.map +1 -1
- package/dist/components/ui/copy-field/index.js +1 -1
- package/dist/components/ui/sheet/index.d.ts.map +1 -1
- package/dist/components/ui/sheet/index.js +2 -2
- package/dist/components/ui/sidebar/index.d.ts +1 -0
- package/dist/components/ui/sidebar/index.d.ts.map +1 -1
- package/dist/components/ui/sidebar/index.js +1 -0
- package/dist/components/ui/sidebar/sidebar-expand-button.d.ts +1 -1
- package/dist/components/ui/sidebar/sidebar-expand-button.d.ts.map +1 -1
- package/dist/components/ui/sidebar/sidebar-expand-button.js +15 -1
- package/dist/components/ui/sidebar/sidebar-item.d.ts +1 -1
- package/dist/components/ui/sidebar/sidebar-item.d.ts.map +1 -1
- package/dist/components/ui/sidebar/sidebar-item.js +28 -4
- package/dist/components/ui/sidebar/sidebar-provider.d.ts +37 -0
- package/dist/components/ui/sidebar/sidebar-provider.d.ts.map +1 -1
- package/dist/components/ui/sidebar/sidebar-provider.js +125 -4
- package/dist/components/ui/sidebar/sidebar-root.d.ts +38 -1
- package/dist/components/ui/sidebar/sidebar-root.d.ts.map +1 -1
- package/dist/components/ui/sidebar/sidebar-root.js +100 -5
- package/dist/components/ui/sidebar/sidebar-trigger.d.ts +18 -0
- package/dist/components/ui/sidebar/sidebar-trigger.d.ts.map +1 -0
- package/dist/components/ui/sidebar/sidebar-trigger.js +30 -0
- package/dist/esm/components/breadcrumb/index.d.ts.map +1 -1
- package/dist/esm/components/breadcrumb/index.js +25 -1
- package/dist/esm/components/card/account-card/index.js +5 -5
- package/dist/esm/components/card/basic-card/index.d.ts.map +1 -1
- package/dist/esm/components/card/basic-card/index.js +2 -2
- package/dist/esm/components/card/entity-card/index.js +1 -1
- package/dist/esm/components/entity-box/index.d.ts +18 -2
- package/dist/esm/components/entity-box/index.d.ts.map +1 -1
- package/dist/esm/components/entity-box/index.js +29 -4
- package/dist/esm/components/form/password-field/index.d.ts +5 -1
- package/dist/esm/components/form/password-field/index.d.ts.map +1 -1
- package/dist/esm/components/form/password-field/index.js +2 -2
- package/dist/esm/components/page-header/index.js +1 -1
- package/dist/esm/components/table/id-table-cell.d.ts +5 -1
- package/dist/esm/components/table/id-table-cell.d.ts.map +1 -1
- package/dist/esm/components/table/id-table-cell.js +48 -3
- package/dist/esm/components/ui/autocomplete/index.d.ts +24 -0
- package/dist/esm/components/ui/autocomplete/index.d.ts.map +1 -1
- package/dist/esm/components/ui/autocomplete/index.js +24 -0
- package/dist/esm/components/ui/copy-field/index.d.ts.map +1 -1
- package/dist/esm/components/ui/copy-field/index.js +1 -1
- package/dist/esm/components/ui/sheet/index.d.ts.map +1 -1
- package/dist/esm/components/ui/sheet/index.js +2 -2
- package/dist/esm/components/ui/sidebar/index.d.ts +1 -0
- package/dist/esm/components/ui/sidebar/index.d.ts.map +1 -1
- package/dist/esm/components/ui/sidebar/index.js +1 -0
- package/dist/esm/components/ui/sidebar/sidebar-expand-button.d.ts +1 -1
- package/dist/esm/components/ui/sidebar/sidebar-expand-button.d.ts.map +1 -1
- package/dist/esm/components/ui/sidebar/sidebar-expand-button.js +15 -1
- package/dist/esm/components/ui/sidebar/sidebar-item.d.ts +1 -1
- package/dist/esm/components/ui/sidebar/sidebar-item.d.ts.map +1 -1
- package/dist/esm/components/ui/sidebar/sidebar-item.js +28 -4
- package/dist/esm/components/ui/sidebar/sidebar-provider.d.ts +37 -0
- package/dist/esm/components/ui/sidebar/sidebar-provider.d.ts.map +1 -1
- package/dist/esm/components/ui/sidebar/sidebar-provider.js +122 -1
- package/dist/esm/components/ui/sidebar/sidebar-root.d.ts +38 -1
- package/dist/esm/components/ui/sidebar/sidebar-root.d.ts.map +1 -1
- package/dist/esm/components/ui/sidebar/sidebar-root.js +102 -7
- package/dist/esm/components/ui/sidebar/sidebar-trigger.d.ts +18 -0
- package/dist/esm/components/ui/sidebar/sidebar-trigger.d.ts.map +1 -0
- package/dist/esm/components/ui/sidebar/sidebar-trigger.js +26 -0
- package/dist/globals.css +22 -0
- package/package.json +1 -1
|
@@ -7,14 +7,38 @@ const sidebar_item_button_1 = require("./sidebar-item-button");
|
|
|
7
7
|
const sidebar_item_icon_button_1 = require("./sidebar-item-icon-button");
|
|
8
8
|
const sidebar_provider_1 = require("./sidebar-provider");
|
|
9
9
|
const sidebar_router_1 = require("./sidebar-router");
|
|
10
|
-
const SidebarItem = ({ active, href, children: _children, ...props }) => {
|
|
10
|
+
const SidebarItem = ({ active, href, children: _children, onClick, ...props }) => {
|
|
11
11
|
const { usePathname } = (0, sidebar_router_1.useSidebarRouter)();
|
|
12
12
|
const pathname = usePathname();
|
|
13
|
-
const { isCollapsed } = (0, sidebar_provider_1.useSidebar)();
|
|
13
|
+
const { isCollapsed, isDrawer, setOpenMobile } = (0, sidebar_provider_1.useSidebar)();
|
|
14
14
|
const isActive = (href) => pathname === href;
|
|
15
|
+
/**
|
|
16
|
+
* ⛔ ACTIVATING A DESTINATION CLOSES THE DRAWER. It is the whole point of the
|
|
17
|
+
* drawer and it was the one interaction that left it open: Escape, the
|
|
18
|
+
* backdrop and the X all dismissed it, a navigation link did not.
|
|
19
|
+
*
|
|
20
|
+
* The overlay is modal, so `document.body` carries `pointer-events: none`
|
|
21
|
+
* while it is up, and a consumer's `SidebarItem` is a client-side `Link`
|
|
22
|
+
* under a provider that survives the route change — so the reader landed on
|
|
23
|
+
* the new page rendered INERT behind a drawer they had to dismiss a second
|
|
24
|
+
* time, on a phone.
|
|
25
|
+
*
|
|
26
|
+
* Here rather than in `SidebarRoot`, because this is the component that knows
|
|
27
|
+
* an activation happened; `SidebarBackButton` and every
|
|
28
|
+
* `SidebarItemCollapsibleContent` leaf render through it, so they are covered
|
|
29
|
+
* by construction. Guarded on `isDrawer` so an inline rail — where nothing is
|
|
30
|
+
* covering the page — behaves exactly as before, and the consumer's own
|
|
31
|
+
* handler still runs either way.
|
|
32
|
+
*/
|
|
33
|
+
const handleClick = (event) => {
|
|
34
|
+
onClick?.(event);
|
|
35
|
+
if (isDrawer) {
|
|
36
|
+
setOpenMobile(false);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
15
39
|
if (isCollapsed) {
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(sidebar_item_icon_button_1.SidebarItemIconButton, { "data-slot": "sidebar-item", href: href, active: isActive(href) || active, ...props }));
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(sidebar_item_icon_button_1.SidebarItemIconButton, { "data-slot": "sidebar-item", href: href, active: isActive(href) || active, onClick: handleClick, ...props }));
|
|
17
41
|
}
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)(sidebar_item_button_1.SidebarItemButton, { "data-slot": "sidebar-item", href: href, active: isActive(href) || active, ...props }));
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)(sidebar_item_button_1.SidebarItemButton, { "data-slot": "sidebar-item", href: href, active: isActive(href) || active, onClick: handleClick, ...props }));
|
|
19
43
|
};
|
|
20
44
|
exports.SidebarItem = SidebarItem;
|
|
@@ -1,12 +1,49 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The viewport below which the rail stops being a layout and becomes a drawer.
|
|
4
|
+
*
|
|
5
|
+
* 767px rather than 768px: this is the upper bound of `max-width`, so it is the
|
|
6
|
+
* complement of Tailwind's `md` breakpoint (`min-width: 768px`) and `md:hidden`
|
|
7
|
+
* on `SidebarTrigger` flips at exactly the same pixel the query does.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SIDEBAR_MOBILE_QUERY = "(max-width: 767px)";
|
|
2
10
|
export type SidebarContextProps = {
|
|
3
11
|
isCollapsed: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* True only inside a drawer that `SidebarRoot` is actually rendering, which
|
|
14
|
+
* needs `mobile="drawer"` as well as a narrow viewport. `SidebarRoot`
|
|
15
|
+
* re-provides the context for that subtree; nothing else sets it.
|
|
16
|
+
*/
|
|
17
|
+
isDrawer: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* True while the viewport is narrow enough for a drawer. Reported in BOTH
|
|
20
|
+
* modes, so a consumer still on `mobile="inline"` can build its own
|
|
21
|
+
* responsive behaviour from it.
|
|
22
|
+
*/
|
|
23
|
+
isMobile: boolean;
|
|
24
|
+
/** Whether the mobile drawer is showing. Meaningless while `isMobile` is false. */
|
|
25
|
+
openMobile: boolean;
|
|
26
|
+
setOpenMobile: (open: boolean) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Puts focus back on whatever opened the drawer. `SidebarRoot` calls it when
|
|
29
|
+
* the drawer closes; nothing else should need it.
|
|
30
|
+
*/
|
|
31
|
+
restoreDrawerFocus: () => void;
|
|
32
|
+
/** The drawer's DOM id, so `SidebarTrigger` can point `aria-controls` at it. */
|
|
33
|
+
sidebarId: string;
|
|
4
34
|
items: Record<string, boolean>;
|
|
5
35
|
setItems: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
|
|
6
36
|
getItemCollapsed: (key: string) => boolean;
|
|
7
37
|
setItemCollapsed: (key: string, value: boolean) => void;
|
|
8
38
|
toggleSidebar: () => void;
|
|
9
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Exported so `SidebarRoot` can re-provide it for the drawer's subtree. That
|
|
42
|
+
* subtree is the only place `isCollapsed` and `isDrawer` differ from the
|
|
43
|
+
* provider's own values, and scoping the override to it is what keeps a
|
|
44
|
+
* consumer on `mobile="inline"` seeing exactly today's rail.
|
|
45
|
+
*/
|
|
46
|
+
export declare const SidebarContext: React.Context<SidebarContextProps | undefined>;
|
|
10
47
|
export declare const useSidebar: () => SidebarContextProps;
|
|
11
48
|
export declare const SidebarProvider: ({ children }: React.PropsWithChildren) => React.JSX.Element;
|
|
12
49
|
//# sourceMappingURL=sidebar-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-provider.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/sidebar/sidebar-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,OAAO,CAAA;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACvE,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;IAC1C,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACvD,aAAa,EAAE,MAAM,IAAI,CAAA;CAC1B,CAAA;
|
|
1
|
+
{"version":3,"file":"sidebar-provider.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/sidebar/sidebar-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,uBAAuB,CAAA;AAUxD,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,OAAO,CAAA;IACpB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAA;IACjB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAA;IACjB,mFAAmF;IACnF,UAAU,EAAE,OAAO,CAAA;IACnB,aAAa,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,IAAI,CAAA;IAC9B,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACvE,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;IAC1C,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACvD,aAAa,EAAE,MAAM,IAAI,CAAA;CAC1B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,gDAEf,CAAA;AAEZ,eAAO,MAAM,UAAU,2BAMtB,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,cAAc,KAAK,CAAC,iBAAiB,sBAkKpE,CAAA"}
|
|
@@ -4,13 +4,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.SidebarProvider = exports.useSidebar = void 0;
|
|
7
|
+
exports.SidebarProvider = exports.useSidebar = exports.SidebarContext = exports.SIDEBAR_MOBILE_QUERY = void 0;
|
|
8
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
10
|
const storage_1 = require("../../../lib/storage");
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The viewport below which the rail stops being a layout and becomes a drawer.
|
|
13
|
+
*
|
|
14
|
+
* 767px rather than 768px: this is the upper bound of `max-width`, so it is the
|
|
15
|
+
* complement of Tailwind's `md` breakpoint (`min-width: 768px`) and `md:hidden`
|
|
16
|
+
* on `SidebarTrigger` flips at exactly the same pixel the query does.
|
|
17
|
+
*/
|
|
18
|
+
exports.SIDEBAR_MOBILE_QUERY = '(max-width: 767px)';
|
|
19
|
+
/**
|
|
20
|
+
* Where focus goes when the rail has to receive it. The rail's own content is
|
|
21
|
+
* links and buttons, so this is deliberately the short list rather than the
|
|
22
|
+
* full tabbable grammar: a `[tabindex]` sweep would have to exclude `-1`, and
|
|
23
|
+
* nothing in a sidebar carries one.
|
|
24
|
+
*/
|
|
25
|
+
const FOCUSABLE = 'a[href], button:not([disabled])';
|
|
26
|
+
/**
|
|
27
|
+
* Exported so `SidebarRoot` can re-provide it for the drawer's subtree. That
|
|
28
|
+
* subtree is the only place `isCollapsed` and `isDrawer` differ from the
|
|
29
|
+
* provider's own values, and scoping the override to it is what keeps a
|
|
30
|
+
* consumer on `mobile="inline"` seeing exactly today's rail.
|
|
31
|
+
*/
|
|
32
|
+
exports.SidebarContext = react_1.default.createContext(undefined);
|
|
12
33
|
const useSidebar = () => {
|
|
13
|
-
const context = react_1.default.useContext(SidebarContext);
|
|
34
|
+
const context = react_1.default.useContext(exports.SidebarContext);
|
|
14
35
|
if (!context) {
|
|
15
36
|
throw new Error('useSidebar must be used within a SidebarProvider');
|
|
16
37
|
}
|
|
@@ -21,6 +42,61 @@ const SidebarProvider = ({ children }) => {
|
|
|
21
42
|
const [hydrated, setHydrated] = react_1.default.useState(false);
|
|
22
43
|
const [collapsed, setCollapsed] = react_1.default.useState(false);
|
|
23
44
|
const [items, _setItems] = react_1.default.useState({});
|
|
45
|
+
const [isMobile, setIsMobile] = react_1.default.useState(false);
|
|
46
|
+
const [openMobile, _setOpenMobile] = react_1.default.useState(false);
|
|
47
|
+
const sidebarId = react_1.default.useId();
|
|
48
|
+
/**
|
|
49
|
+
* ⛔ RADIX CANNOT RESTORE THIS FOCUS BY ITSELF. `DialogContent` preventDefaults
|
|
50
|
+
* the focus scope's own restore and focuses `triggerRef.current` instead —
|
|
51
|
+
* the ref a `SheetTrigger` would have filled. The drawer is opened from this
|
|
52
|
+
* state rather than from a trigger inside the dialog, so that ref is null and
|
|
53
|
+
* closing dropped focus onto `<body>`: a keyboard reader who opened the
|
|
54
|
+
* navigation and pressed Escape was returned to the top of the document.
|
|
55
|
+
*
|
|
56
|
+
* Captured here rather than in `SidebarTrigger` so that a consumer opening
|
|
57
|
+
* the drawer from its own control gets the same behaviour.
|
|
58
|
+
*/
|
|
59
|
+
const opener = react_1.default.useRef(null);
|
|
60
|
+
const setOpenMobile = react_1.default.useCallback((open) => {
|
|
61
|
+
if (open && typeof document !== 'undefined') {
|
|
62
|
+
opener.current = document.activeElement;
|
|
63
|
+
}
|
|
64
|
+
_setOpenMobile(open);
|
|
65
|
+
}, []);
|
|
66
|
+
/**
|
|
67
|
+
* ⛔ THE VIEWPORT AT THE MOMENT FOCUS MOVES, NOT AT THE MOMENT IT OPENED.
|
|
68
|
+
*
|
|
69
|
+
* Radix calls `restoreDrawerFocus` from the focus scope's UNMOUNT handler,
|
|
70
|
+
* which is the last thing in the commit to touch focus — later than any
|
|
71
|
+
* effect in this provider, so the decision has to be made inside the handler
|
|
72
|
+
* rather than beside it. By then `isMobile` has already flipped.
|
|
73
|
+
*/
|
|
74
|
+
const isMobileRef = react_1.default.useRef(false);
|
|
75
|
+
isMobileRef.current = isMobile;
|
|
76
|
+
const restoreDrawerFocus = react_1.default.useCallback(() => {
|
|
77
|
+
// `isConnected`: the control that opened the drawer may itself have been
|
|
78
|
+
// unmounted by whatever the reader did inside it.
|
|
79
|
+
//
|
|
80
|
+
// ⛔ AND NOT AT ALL WHEN THE VIEWPORT IS THE ONE THAT DISMISSED IT. A
|
|
81
|
+
// tablet rotated from portrait to landscape with the navigation open
|
|
82
|
+
// crosses 768px, so the drawer is replaced by the rail and the opener is
|
|
83
|
+
// `SidebarTrigger` — which the same breakpoint just hid with `md:hidden`.
|
|
84
|
+
// `.focus()` on a `display: none` element is a silent no-op, and Radix's
|
|
85
|
+
// own restore is already `preventDefault()`ed, so focus fell to `<body>`
|
|
86
|
+
// and the reader lost their place (SC 2.4.3). Measured in Chromium at
|
|
87
|
+
// 390 → 1280: `{"rails":1,"triggerDisplay":"none","focus":"BODY:"}`.
|
|
88
|
+
if (isMobileRef.current && opener.current?.isConnected) {
|
|
89
|
+
opener.current.focus();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// The rail is what the drawer became, so that is where the reader goes.
|
|
93
|
+
// Below the breakpoint there is nothing here to find — a closed drawer
|
|
94
|
+
// leaves no navigation in the DOM — and focus stays where Radix left it.
|
|
95
|
+
document
|
|
96
|
+
.getElementById(sidebarId)
|
|
97
|
+
?.querySelector(FOCUSABLE)
|
|
98
|
+
?.focus();
|
|
99
|
+
}, [sidebarId]);
|
|
24
100
|
const toggleSidebar = () => setCollapsed((collapsed) => !collapsed);
|
|
25
101
|
const getItemCollapsed = (key) => {
|
|
26
102
|
return items[key] || false;
|
|
@@ -34,6 +110,37 @@ const SidebarProvider = ({ children }) => {
|
|
|
34
110
|
_setItems((0, storage_1.getStorageObject)('sidebar-items', {}));
|
|
35
111
|
setHydrated(true);
|
|
36
112
|
}, []);
|
|
113
|
+
/**
|
|
114
|
+
* ⚠️ FALSE UNTIL THE CLIENT SAYS OTHERWISE. There is no viewport on the
|
|
115
|
+
* server, so the first paint is always the rail and the drawer appears on
|
|
116
|
+
* hydration; starting from a guess would make the markup differ between the
|
|
117
|
+
* two renders. The `matchMedia` guard is the one `theme-provider.tsx` next
|
|
118
|
+
* door already carries: jsdom and some embedded runtimes ship without it, and
|
|
119
|
+
* a missing media API is a desktop, not a crash.
|
|
120
|
+
*/
|
|
121
|
+
react_1.default.useEffect(() => {
|
|
122
|
+
if (typeof window.matchMedia !== 'function') {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const media = window.matchMedia(exports.SIDEBAR_MOBILE_QUERY);
|
|
126
|
+
const sync = () => setIsMobile(media.matches);
|
|
127
|
+
sync();
|
|
128
|
+
media.addEventListener('change', sync);
|
|
129
|
+
return () => media.removeEventListener('change', sync);
|
|
130
|
+
}, []);
|
|
131
|
+
/**
|
|
132
|
+
* A drawer left open while the viewport grows back would keep an overlay and
|
|
133
|
+
* a focus trap over a layout that is already showing its rail, with nothing
|
|
134
|
+
* on screen to dismiss them.
|
|
135
|
+
*
|
|
136
|
+
* Where focus goes afterwards is `restoreDrawerFocus`'s decision, not this
|
|
137
|
+
* effect's: Radix's unmount handler runs later than anything here.
|
|
138
|
+
*/
|
|
139
|
+
react_1.default.useEffect(() => {
|
|
140
|
+
if (!isMobile) {
|
|
141
|
+
_setOpenMobile(false);
|
|
142
|
+
}
|
|
143
|
+
}, [isMobile]);
|
|
37
144
|
// Only persist to localStorage after hydration to avoid overwriting stored values
|
|
38
145
|
react_1.default.useEffect(() => {
|
|
39
146
|
if (!hydrated) {
|
|
@@ -47,8 +154,22 @@ const SidebarProvider = ({ children }) => {
|
|
|
47
154
|
}
|
|
48
155
|
localStorage.setItem('sidebar-items', JSON.stringify(items));
|
|
49
156
|
}, [items, hydrated]);
|
|
50
|
-
return ((0, jsx_runtime_1.jsx)(SidebarContext.Provider, { value: {
|
|
157
|
+
return ((0, jsx_runtime_1.jsx)(exports.SidebarContext.Provider, { value: {
|
|
158
|
+
/**
|
|
159
|
+
* ⚠️ A NARROW VIEWPORT DOES NOT TOUCH THIS. It used to be forced false
|
|
160
|
+
* whenever `isMobile`, which silently changed the rail for every
|
|
161
|
+
* consumer — including the ones that never asked for a drawer.
|
|
162
|
+
* `SidebarRoot` overrides it for the drawer's own subtree instead, so
|
|
163
|
+
* the stored preference reaches an inline rail unchanged at every
|
|
164
|
+
* viewport.
|
|
165
|
+
*/
|
|
51
166
|
isCollapsed: collapsed,
|
|
167
|
+
isDrawer: false,
|
|
168
|
+
isMobile,
|
|
169
|
+
openMobile,
|
|
170
|
+
setOpenMobile,
|
|
171
|
+
restoreDrawerFocus,
|
|
172
|
+
sidebarId,
|
|
52
173
|
items,
|
|
53
174
|
setItems: _setItems,
|
|
54
175
|
getItemCollapsed,
|
|
@@ -1,3 +1,40 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type SidebarRootProps = React.ComponentProps<'nav'> & {
|
|
3
|
+
/**
|
|
4
|
+
* What this rail becomes below 768px.
|
|
5
|
+
*
|
|
6
|
+
* - `'inline'` (default): nothing changes. The rail renders at every
|
|
7
|
+
* viewport exactly as it always has, and the reader's collapsed preference
|
|
8
|
+
* is untouched.
|
|
9
|
+
* - `'drawer'`: the inline rail is not rendered below the breakpoint and the
|
|
10
|
+
* navigation moves into an overlay drawer that `SidebarTrigger` opens.
|
|
11
|
+
*
|
|
12
|
+
* ⛔ THE DEFAULT IS NOT A TASTE, IT IS A CONSUMER-SAFETY RULE. `SidebarTrigger`
|
|
13
|
+
* is the only way back into the drawer and it must render inside
|
|
14
|
+
* `SidebarProvider`. A consumer that has not placed one yet — which is every
|
|
15
|
+
* consumer at the moment this shipped — would get a phone with NO navigation
|
|
16
|
+
* rather than a rail that takes 63% of it, and that is strictly worse. Opt in
|
|
17
|
+
* once there is somewhere to put the trigger.
|
|
18
|
+
*/
|
|
19
|
+
mobile?: 'inline' | 'drawer';
|
|
20
|
+
/**
|
|
21
|
+
* The drawer's accessible name. A dialog needs one, and it is read out when
|
|
22
|
+
* the drawer opens. Unused while `mobile` is `'inline'`.
|
|
23
|
+
*/
|
|
24
|
+
mobileTitle?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* ⛔ BELOW 768px A RAIL IS NOT A LAYOUT — once a consumer opts in.
|
|
28
|
+
*
|
|
29
|
+
* The widths above are a fixed share of a flex row, so at 390px the expanded
|
|
30
|
+
* rail took 63% of the screen and left the page 146px, and the only affordance
|
|
31
|
+
* — `SidebarExpandButton` — shrinks it to 72px, which is still 18% and still
|
|
32
|
+
* permanently on screen. There was nothing that removed it.
|
|
33
|
+
*
|
|
34
|
+
* With `mobile="drawer"` the rail is replaced below the breakpoint by an
|
|
35
|
+
* overlay drawer. Escape, the backdrop click, the focus trap and returning
|
|
36
|
+
* focus to whatever opened it are Radix Dialog's, through the kit's own
|
|
37
|
+
* `Sheet`; none of that is re-implemented here.
|
|
38
|
+
*/
|
|
39
|
+
export declare const SidebarRoot: ({ className, id, mobile, mobileTitle, ...props }: SidebarRootProps) => React.JSX.Element;
|
|
3
40
|
//# sourceMappingURL=sidebar-root.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-root.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/sidebar/sidebar-root.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"sidebar-root.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/sidebar/sidebar-root.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAqEzB,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG;IAC3D;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAI,kDAMzB,gBAAgB,sBA0GlB,CAAA"}
|
|
@@ -6,19 +6,114 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
const class_variance_authority_1 = require("class-variance-authority");
|
|
7
7
|
const sidebar_provider_1 = require("./sidebar-provider");
|
|
8
8
|
const utils_1 = require("../../../lib/utils");
|
|
9
|
+
const sheet_1 = require("../sheet");
|
|
10
|
+
/**
|
|
11
|
+
* ⛔ THE WIDTHS ARE TOKENS, NOT LITERALS.
|
|
12
|
+
*
|
|
13
|
+
* They were `w-[72px]` and `w-[244px]`, which a consumer could only override by
|
|
14
|
+
* winning a specificity argument with `cn`. `--sidebar-width` and
|
|
15
|
+
* `--sidebar-width-collapsed` are declared in `globals.css`, so the default
|
|
16
|
+
* still ships with the stylesheet, and a consumer re-points either one with
|
|
17
|
+
* `className="[--sidebar-width:280px]"` ON THE RAIL, which moves the rail and
|
|
18
|
+
* the mobile drawer together (see `liftWidthOverrides` below), or with a rule
|
|
19
|
+
* on `:root`/`html`.
|
|
20
|
+
*
|
|
21
|
+
* ⚠️ A DECLARATION ON A REACT-TREE ANCESTOR REACHES THE RAIL AND NOT THE
|
|
22
|
+
* DRAWER. Custom properties inherit down the DOM tree, and the drawer is
|
|
23
|
+
* portalled to `document.body`, so a layout wrapper is not an ancestor of it.
|
|
24
|
+
* `:root` is, which is why it is named above and a wrapper is not.
|
|
25
|
+
*/
|
|
9
26
|
const sidebarVariants = (0, class_variance_authority_1.cva)('group/sidebar shadow-sidebar relative flex flex-col transition-[width] duration-300 ease-in-out', {
|
|
10
27
|
variants: {
|
|
11
28
|
collapsed: {
|
|
12
|
-
true: 'w-[
|
|
13
|
-
false: 'w-[
|
|
29
|
+
true: 'w-[var(--sidebar-width-collapsed)]',
|
|
30
|
+
false: 'w-[var(--sidebar-width)]'
|
|
14
31
|
}
|
|
15
32
|
},
|
|
16
33
|
defaultVariants: {
|
|
17
34
|
collapsed: false
|
|
18
35
|
}
|
|
19
36
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Tailwind arbitrary-property classes that re-point the sidebar geometry, e.g.
|
|
39
|
+
* `[--sidebar-width:320px]` or `[--sidebar-width-collapsed:88px]`.
|
|
40
|
+
*
|
|
41
|
+
* ⚠️ ANCHORED TO A CLASS BOUNDARY, WHICH IS THE WHOLE POINT OF THE LOOKBEHIND.
|
|
42
|
+
* Unanchored it also matched the tail of `md:[--sidebar-width:320px]` and
|
|
43
|
+
* lifted it with the prefix stripped — an override a consumer scoped to
|
|
44
|
+
* ≥768px, applied unconditionally to the drawer that only exists below it.
|
|
45
|
+
*/
|
|
46
|
+
const WIDTH_OVERRIDE = /(?<=^|\s)\[--sidebar-width(?:-collapsed)?:[^\]]+\]/g;
|
|
47
|
+
/**
|
|
48
|
+
* ⛔ THE ONE PART OF THE CONSUMER'S className THAT HAS TO CROSS THE PORTAL.
|
|
49
|
+
*
|
|
50
|
+
* `SheetContent` mounts through `SheetPortal` into `document.body`, and custom
|
|
51
|
+
* properties inherit down the DOM tree rather than the React tree. So the
|
|
52
|
+
* documented override — a class on the rail — set `--sidebar-width` on an
|
|
53
|
+
* element the drawer is not a descendant of, and the whole className that DOES
|
|
54
|
+
* travel lands on the inner `<nav>`, which is BELOW the element that reads the
|
|
55
|
+
* variable. Measured in Chromium: rail 320px, drawer 244px. Following the
|
|
56
|
+
* instruction handed to product-console produced a 280px rail on desktop and a
|
|
57
|
+
* 244px drawer on a phone, silently.
|
|
58
|
+
*
|
|
59
|
+
* ⚠️ ONLY THE GEOMETRY TOKENS. The rest of a rail className is rail-shaped —
|
|
60
|
+
* `h-full`, and the `data-[collapsed=false]:min-w-70` all eight console
|
|
61
|
+
* sidebars pass — and putting that on the sheet would reinstate the
|
|
62
|
+
* 280px-inside-a-244px-sheet overflow from the other side.
|
|
63
|
+
*/
|
|
64
|
+
function liftWidthOverrides(className) {
|
|
65
|
+
return className?.match(WIDTH_OVERRIDE)?.join(' ');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* ⛔ BELOW 768px A RAIL IS NOT A LAYOUT — once a consumer opts in.
|
|
69
|
+
*
|
|
70
|
+
* The widths above are a fixed share of a flex row, so at 390px the expanded
|
|
71
|
+
* rail took 63% of the screen and left the page 146px, and the only affordance
|
|
72
|
+
* — `SidebarExpandButton` — shrinks it to 72px, which is still 18% and still
|
|
73
|
+
* permanently on screen. There was nothing that removed it.
|
|
74
|
+
*
|
|
75
|
+
* With `mobile="drawer"` the rail is replaced below the breakpoint by an
|
|
76
|
+
* overlay drawer. Escape, the backdrop click, the focus trap and returning
|
|
77
|
+
* focus to whatever opened it are Radix Dialog's, through the kit's own
|
|
78
|
+
* `Sheet`; none of that is re-implemented here.
|
|
79
|
+
*/
|
|
80
|
+
const SidebarRoot = ({ className, id, mobile = 'inline', mobileTitle = 'Navigation', ...props }) => {
|
|
81
|
+
const context = (0, sidebar_provider_1.useSidebar)();
|
|
82
|
+
const { isCollapsed, isMobile, openMobile, setOpenMobile, restoreDrawerFocus, sidebarId } = context;
|
|
83
|
+
if (!isMobile || mobile === 'inline') {
|
|
84
|
+
return ((0, jsx_runtime_1.jsx)("nav", { "data-slot": "sidebar-root", className: (0, utils_1.cn)(sidebarVariants({ collapsed: isCollapsed }), className), "data-collapsed": isCollapsed, ...props, id: mobile === 'drawer' ? sidebarId : id }));
|
|
85
|
+
}
|
|
86
|
+
return ((0, jsx_runtime_1.jsx)(sidebar_provider_1.SidebarContext.Provider, { value: { ...context, isCollapsed: false, isDrawer: true }, children: (0, jsx_runtime_1.jsx)(sheet_1.Sheet, { open: openMobile, onOpenChange: setOpenMobile, children: (0, jsx_runtime_1.jsxs)(sheet_1.SheetContent, { side: "left",
|
|
87
|
+
// The Sheet's own paddings are built for a form panel; a rail brings
|
|
88
|
+
// its own. `max-w-full` so a consumer widening `--sidebar-width` past
|
|
89
|
+
// the viewport still cannot push the drawer off screen. The lifted
|
|
90
|
+
// override goes LAST so it re-points the variable this element reads.
|
|
91
|
+
className: (0, utils_1.cn)('w-[var(--sidebar-width)] max-w-full gap-0 p-0', liftWidthOverrides(className)), "aria-describedby": undefined,
|
|
92
|
+
// ⛔ RADIX'S OWN RESTORE GOES NOWHERE HERE. `DialogContent`
|
|
93
|
+
// preventDefaults the focus scope's restore and focuses the ref a
|
|
94
|
+
// `SheetTrigger` would have filled; this drawer is opened from provider
|
|
95
|
+
// state, so that ref is null and closing dropped focus onto `<body>`.
|
|
96
|
+
// Running first means `composeEventHandlers` skips Radix's half.
|
|
97
|
+
onCloseAutoFocus: (event) => {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
restoreDrawerFocus();
|
|
100
|
+
}, children: [(0, jsx_runtime_1.jsx)(sheet_1.SheetTitle, { className: "sr-only", children: mobileTitle }), (0, jsx_runtime_1.jsx)("nav", { "data-slot": "sidebar-root", "data-mobile": "true",
|
|
101
|
+
/* ⛔ NO `data-collapsed` HERE. The consumer className is forwarded
|
|
102
|
+
verbatim, and all eight console sidebars pass
|
|
103
|
+
`data-[collapsed=false]:min-w-70`; stamping the attribute armed
|
|
104
|
+
it, giving the navigation a 280px min-width inside a 244px sheet.
|
|
105
|
+
`min-width` resolves after `max-width`, so the sheet could not
|
|
106
|
+
claw it back and the contents were 36px wider than the drawer.
|
|
107
|
+
`data-mobile` already names this surface and a drawer is never
|
|
108
|
+
collapsed, so the attribute had nothing left to say. */
|
|
109
|
+
className: (0, utils_1.cn)(sidebarVariants({ collapsed: false }), 'h-full w-full shadow-none', className), ...props,
|
|
110
|
+
/* ⛔ AFTER THE SPREAD, AND NOT THE CALLER'S. This is the target of
|
|
111
|
+
`SidebarTrigger`'s `aria-controls` and the handle the provider
|
|
112
|
+
uses to put focus back into the navigation when the viewport
|
|
113
|
+
grows. Spread first, a caller that set `id` replaced it and left
|
|
114
|
+
a dangling `aria-controls` — which axe reports as a CRITICAL
|
|
115
|
+
`aria-valid-attr-value` — and a focus restore that lands on
|
|
116
|
+
`<body>`. Both silent. */
|
|
117
|
+
id: sidebarId })] }) }) }));
|
|
23
118
|
};
|
|
24
119
|
exports.SidebarRoot = SidebarRoot;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconButton } from '../icon-button';
|
|
3
|
+
export type SidebarTriggerProps = React.ComponentProps<typeof IconButton>;
|
|
4
|
+
/**
|
|
5
|
+
* The control that opens the mobile drawer.
|
|
6
|
+
*
|
|
7
|
+
* `md:hidden` by default because above 768px the rail is already on screen and
|
|
8
|
+
* a second way to reach it is a second thing to explain; a consumer that wants
|
|
9
|
+
* it everywhere passes its own display class.
|
|
10
|
+
*
|
|
11
|
+
* ⚠️ `aria-controls` IS SET ONLY WHILE THE DRAWER EXISTS. Radix unmounts the
|
|
12
|
+
* dialog content when closed, and a reference to an element that is not in the
|
|
13
|
+
* DOM is what axe-core reports as a CRITICAL `aria-valid-attr-value` — the same
|
|
14
|
+
* defect the Autocomplete panel was repaired for (console-sdk#150). A toggle
|
|
15
|
+
* with `aria-expanded="false"` and no `aria-controls` is complete on its own.
|
|
16
|
+
*/
|
|
17
|
+
export declare const SidebarTrigger: ({ className, onClick, "aria-label": ariaLabel, ...props }: SidebarTriggerProps) => React.JSX.Element;
|
|
18
|
+
//# sourceMappingURL=sidebar-trigger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-trigger.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/sidebar/sidebar-trigger.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAG3C,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,CAAA;AAEzE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,2DAK5B,mBAAmB,sBAqBrB,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SidebarTrigger = void 0;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const lucide_react_1 = require("lucide-react");
|
|
7
|
+
const utils_1 = require("../../../lib/utils");
|
|
8
|
+
const icon_button_1 = require("../icon-button");
|
|
9
|
+
const sidebar_provider_1 = require("./sidebar-provider");
|
|
10
|
+
/**
|
|
11
|
+
* The control that opens the mobile drawer.
|
|
12
|
+
*
|
|
13
|
+
* `md:hidden` by default because above 768px the rail is already on screen and
|
|
14
|
+
* a second way to reach it is a second thing to explain; a consumer that wants
|
|
15
|
+
* it everywhere passes its own display class.
|
|
16
|
+
*
|
|
17
|
+
* ⚠️ `aria-controls` IS SET ONLY WHILE THE DRAWER EXISTS. Radix unmounts the
|
|
18
|
+
* dialog content when closed, and a reference to an element that is not in the
|
|
19
|
+
* DOM is what axe-core reports as a CRITICAL `aria-valid-attr-value` — the same
|
|
20
|
+
* defect the Autocomplete panel was repaired for (console-sdk#150). A toggle
|
|
21
|
+
* with `aria-expanded="false"` and no `aria-controls` is complete on its own.
|
|
22
|
+
*/
|
|
23
|
+
const SidebarTrigger = ({ className, onClick, 'aria-label': ariaLabel = 'Open navigation', ...props }) => {
|
|
24
|
+
const { openMobile, setOpenMobile, sidebarId } = (0, sidebar_provider_1.useSidebar)();
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(icon_button_1.IconButton, { type: "button", variant: "outline", "data-slot": "sidebar-trigger", "aria-label": ariaLabel, "aria-expanded": openMobile, "aria-controls": openMobile ? sidebarId : undefined, className: (0, utils_1.cn)('md:hidden', className), onClick: (event) => {
|
|
26
|
+
onClick?.(event);
|
|
27
|
+
setOpenMobile(!openMobile);
|
|
28
|
+
}, ...props, children: (0, jsx_runtime_1.jsx)(lucide_react_1.Menu, { "aria-hidden": true }) }));
|
|
29
|
+
};
|
|
30
|
+
exports.SidebarTrigger = SidebarTrigger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/breadcrumb/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAUzB,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,cAAc,EAAE,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,WAAW,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/breadcrumb/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAUzB,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,cAAc,EAAE,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,WAAW,eAAe,sBAmDpD,CAAA"}
|
|
@@ -2,5 +2,29 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Breadcrumb as BaseBreadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from '../../components/ui/breadcrumb/index.js';
|
|
4
4
|
export const Breadcrumb = ({ paths }) => {
|
|
5
|
-
|
|
5
|
+
const last = paths.length - 1;
|
|
6
|
+
return (_jsx(BaseBreadcrumb, { children: _jsx(BreadcrumbList, { children: paths.map((path, index) => {
|
|
7
|
+
/**
|
|
8
|
+
* ⛔ THE LAST CRUMB IS THE PAGE, whatever the caller passed.
|
|
9
|
+
*
|
|
10
|
+
* The page marker used to be a side effect of the caller omitting
|
|
11
|
+
* `href`, and nothing in `getBreadcrumbPaths` makes the last entry
|
|
12
|
+
* omit one. A trail whose final entry carried an href therefore had
|
|
13
|
+
* no `aria-current="page"` anywhere — a screen reader could not tell
|
|
14
|
+
* which of three links was the page being read — and the crumb was a
|
|
15
|
+
* live link back to the page the reader is already on.
|
|
16
|
+
*
|
|
17
|
+
* ⚠️ AND AN HREF-LESS ANCESTOR IS NOT A SWITCHED-OFF LINK. It used
|
|
18
|
+
* to reach `BreadcrumbPage` too, which hard-codes `role="link"
|
|
19
|
+
* aria-disabled="true"` — the right shape for the page you are ON,
|
|
20
|
+
* a destination that exists and simply is not navigable from here.
|
|
21
|
+
* An ancestor with no href is a grouping label: there is no page
|
|
22
|
+
* behind it, so "Settings, link, dimmed" told the reader a
|
|
23
|
+
* destination was unavailable to them rather than that it was never
|
|
24
|
+
* a destination, and inflated the link count of the trail. It is
|
|
25
|
+
* plain text now, and only the last crumb is the page.
|
|
26
|
+
*/
|
|
27
|
+
const isLast = index === last;
|
|
28
|
+
return (_jsxs(React.Fragment, { children: [_jsx(BreadcrumbItem, { children: path.href && !isLast ? (_jsx(BreadcrumbLink, { href: path.href, children: path.name })) : isLast ? (_jsx(BreadcrumbPage, { children: path.name })) : (_jsx("span", { className: "breadcrumb-page", children: path.name })) }), !isLast && _jsx(BreadcrumbSeparator, {})] }, index));
|
|
29
|
+
}) }) }));
|
|
6
30
|
};
|
|
@@ -23,7 +23,7 @@ export function AccountBalanceCardHeader({ className, ...props }) {
|
|
|
23
23
|
return (_jsx("div", { "data-slot": "account-balance-card-header", className: cn('flex flex-col', className), ...props }));
|
|
24
24
|
}
|
|
25
25
|
export function AccountBalanceCardTitle({ className, ...props }) {
|
|
26
|
-
return (_jsx("p", { "data-slot": "account-balance-card-title", className: cn('text-
|
|
26
|
+
return (_jsx("p", { "data-slot": "account-balance-card-title", className: cn('text-foreground text-lg font-bold', className), ...props }));
|
|
27
27
|
}
|
|
28
28
|
export function AccountBalanceCardDeleteButton({ className, ...props }) {
|
|
29
29
|
return (_jsx(IconButton, { variant: "outline", size: "small", rounded: true, "data-slot": "account-balance-card-delete-button", className: cn('absolute top-3 right-3', className), ...props, children: _jsx(Trash, { className: "text-muted-foreground h-4 w-4" }) }));
|
|
@@ -35,19 +35,19 @@ export function AccountBalanceCardLoading({ className, ...props }) {
|
|
|
35
35
|
return (_jsx(Skeleton, { "data-slot": "account-balance-card-loading", className: cn('bg-muted mt-3 h-3 w-full rounded-md', className), ...props }));
|
|
36
36
|
}
|
|
37
37
|
export function AccountBalanceCardEmpty({ className, ...props }) {
|
|
38
|
-
return (_jsx("p", { "data-slot": "account-balance-card-empty", className: cn('text-
|
|
38
|
+
return (_jsx("p", { "data-slot": "account-balance-card-empty", className: cn('text-muted-foreground mt-3 text-center text-sm font-normal', className), ...props }));
|
|
39
39
|
}
|
|
40
40
|
export function AccountBalanceCardInfo({ className, assetCode, value, children: _children, ref, ...props }) {
|
|
41
|
-
return (_jsxs("div", { ref: ref, "data-slot": "account-balance-card-info", className: cn('text-
|
|
41
|
+
return (_jsxs("div", { ref: ref, "data-slot": "account-balance-card-info", className: cn('text-muted-foreground mt-3 flex flex-row items-center justify-between text-sm font-normal', className), ...props, children: [_jsx("p", { children: assetCode }), _jsx("p", { children: value })] }));
|
|
42
42
|
}
|
|
43
43
|
export function AccountBalanceCardUpdateButton({ className: _className, loading, timestamp, loadingLabel = 'Updating...', updatedInLabel = 'Updated in', updatedLabel = 'Updated', onRefresh, children: _children, ref, ...props }) {
|
|
44
44
|
const _time = useTime({ interval: 1000 * 60 });
|
|
45
45
|
const updated = React.useMemo(() => {
|
|
46
46
|
return !dayjs(timestamp).isBefore(dayjs().subtract(1, 'minute'));
|
|
47
47
|
}, [_time, timestamp]);
|
|
48
|
-
return (_jsxs("div", { className: "mb-3 flex flex-row items-center justify-end gap-2", children: [_jsxs("p", { className: "text-
|
|
48
|
+
return (_jsxs("div", { className: "mb-3 flex flex-row items-center justify-end gap-2", children: [_jsxs("p", { className: "text-muted-foreground text-xs font-medium", children: [loading && loadingLabel, !loading && !updated && updatedInLabel, !loading && updated && updatedLabel] }), !loading && updated && (_jsx(CheckCircle2, { className: "text-system-success-h1a h-4 w-4" })), (!updated || loading) && (_jsx(Button, { ref: ref, variant: "link", "data-slot": "account-balance-card-update-button", className: "h-3 p-0", onClick: onRefresh, disabled: loading, ...props, children: _jsx(RefreshCw, { className: cn('size-4', { 'motion-safe:animate-spin': loading }) }) }))] }));
|
|
49
49
|
}
|
|
50
50
|
export function AccountBalanceCardTrigger({ className, openLabel, closeLabel, children: _children, ...props }) {
|
|
51
51
|
const { open } = React.useContext(AccountBalanceCardContext);
|
|
52
|
-
return (_jsx(CollapsibleTrigger, { asChild: true, children: _jsx(Button, { variant: "link", "data-slot": "account-balance-card-trigger", className: cn('text-
|
|
52
|
+
return (_jsx(CollapsibleTrigger, { asChild: true, children: _jsx(Button, { variant: "link", "data-slot": "account-balance-card-trigger", className: cn('text-muted-foreground h-4 p-0 text-xs', className), ...props, children: !open ? openLabel : closeLabel }) }));
|
|
53
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/card/basic-card/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,wBAAgB,SAAS,CAAC,EACxB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAO7B;AAED,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,qBAO5B;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/card/basic-card/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,wBAAgB,SAAS,CAAC,EACxB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAO7B;AAED,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,qBAO5B;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAU7B;AAED,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAE7B"}
|
|
@@ -4,10 +4,10 @@ export function BasicCard({ className, ...props }) {
|
|
|
4
4
|
return (_jsx("div", { className: cn('bg-card flex flex-col rounded-lg p-6', className), ...props }));
|
|
5
5
|
}
|
|
6
6
|
export function BasicCardTitle({ className, ...props }) {
|
|
7
|
-
return (_jsx("h2", { className: cn('text-
|
|
7
|
+
return (_jsx("h2", { className: cn('text-foreground mb-4 text-sm font-medium', className), ...props }));
|
|
8
8
|
}
|
|
9
9
|
export function BasicCardContent({ className, ...props }) {
|
|
10
|
-
return (_jsx("div", { className: cn('text-
|
|
10
|
+
return (_jsx("div", { className: cn('text-muted-foreground mb-6 text-sm font-medium', className), ...props }));
|
|
11
11
|
}
|
|
12
12
|
export function BasicCardAction({ className, ...props }) {
|
|
13
13
|
return _jsx("div", { className: cn('flex flex-col', className), ...props });
|
|
@@ -45,7 +45,7 @@ export function EntityCardDescription({ className, ...props }) {
|
|
|
45
45
|
return (_jsx("p", { "data-slot": "entity-card-description", className: cn('text-muted-foreground text-xs font-medium', className), ...props }));
|
|
46
46
|
}
|
|
47
47
|
export function EntityCardList({ className, ...props }) {
|
|
48
|
-
return (_jsx("ul", { "data-slot": "entity-card-list", className: cn('text-
|
|
48
|
+
return (_jsx("ul", { "data-slot": "entity-card-list", className: cn('text-muted-foreground mx-2 list-inside list-disc space-y-1 text-xs font-medium', className), ...props }));
|
|
49
49
|
}
|
|
50
50
|
export function EntityCardFooter({ className, children, ...props }) {
|
|
51
51
|
return (_jsxs("div", { "data-slot": "entity-card-footer", className: cn('text-muted-foreground flex flex-col gap-2 text-xs font-medium', className), ...props, children: [_jsx(Separator, {}), _jsx("div", { className: "[&>svg]:text-muted-foreground flex flex-row items-center gap-2 [&>svg]:size-4 [&>svg]:stroke-[1.5]", children: children })] }));
|
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CollapsibleContentProps, CollapsibleProps, CollapsibleTriggerProps } from '@radix-ui/react-collapsible';
|
|
3
3
|
declare function EntityBox({ className, children, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
|
|
4
|
-
declare function EntityBoxCollapsible({ className, ...props }: CollapsibleProps): React.JSX.Element;
|
|
5
|
-
|
|
4
|
+
declare function EntityBoxCollapsible({ className, open, defaultOpen, onOpenChange, ...props }: CollapsibleProps): React.JSX.Element;
|
|
5
|
+
export type EntityBoxCollapsibleTriggerProps = CollapsibleTriggerProps & {
|
|
6
|
+
/** Accessible name while the box is closed. */
|
|
7
|
+
expandLabel?: string;
|
|
8
|
+
/** Accessible name while the box is open. */
|
|
9
|
+
collapseLabel?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* ⛔ THIS TRIGGER HAS NO TEXT NODE. It is a `Settings2` glyph inside a Button,
|
|
13
|
+
* so without an `aria-label` a screen reader announced "button" and nothing
|
|
14
|
+
* else (SC 4.1.2) — and this is the control that opens the filter panel on
|
|
15
|
+
* every console list page.
|
|
16
|
+
*
|
|
17
|
+
* The name describes the ACTION and Radix's `aria-expanded` carries the state,
|
|
18
|
+
* so the two halves do not repeat each other. English defaults because no
|
|
19
|
+
* consumer passes a label today; a translated console overrides both.
|
|
20
|
+
*/
|
|
21
|
+
declare function EntityBoxCollapsibleTrigger({ expandLabel, collapseLabel, 'aria-label': ariaLabel, ...props }: EntityBoxCollapsibleTriggerProps): React.JSX.Element;
|
|
6
22
|
declare function EntityBoxCollapsibleContent({ children, ...props }: CollapsibleContentProps): React.JSX.Element;
|
|
7
23
|
export interface EntityBoxHeaderProps extends React.ComponentProps<'div'> {
|
|
8
24
|
title: string;
|