@momoi-labs/kiso-react 0.31.0 → 0.32.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/README.md +6 -1
- package/dist/app-shell.d.ts +3 -0
- package/dist/app-shell.js +16 -5
- package/dist/styles.css +3 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -162,7 +162,12 @@ names, the active destination, and keyboard focus. `defaultCollapsed` sets the
|
|
|
162
162
|
initial state; `collapsed` with `onCollapsedChange` lets the product control or
|
|
163
163
|
persist the preference. On narrow screens the navigation keeps its labels and
|
|
164
164
|
returns to the chosen state when the viewport widens. Existing appearance
|
|
165
|
-
settings apply to both states.
|
|
165
|
+
settings apply to both states. Pass `brandMark` to keep the brand's mark in
|
|
166
|
+
the rail as the expand control.
|
|
167
|
+
|
|
168
|
+
Add `shellLayout` to give the Header and the sidebar header one bar height,
|
|
169
|
+
start the brand at the brand inset, and move `primaryAction` below the bar.
|
|
170
|
+
With `headerVariant="floating"`, the brand moves into the floating Header.
|
|
166
171
|
|
|
167
172
|
PageHeader accepts `variant="editorial"` for a larger responsive title and
|
|
168
173
|
more space around the heading.
|
package/dist/app-shell.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ type ApplicationShellSharedProps = Omit<React.ComponentProps<typeof AppShell>, "
|
|
|
31
31
|
headerVariant?: React.ComponentProps<typeof Header>["variant"];
|
|
32
32
|
headerSize?: React.ComponentProps<typeof Header>["size"];
|
|
33
33
|
panel?: React.ReactNode;
|
|
34
|
+
shellLayout?: boolean;
|
|
34
35
|
children: React.ReactNode;
|
|
35
36
|
};
|
|
36
37
|
type ApplicationShellSidebarProps = ApplicationShellSharedProps & {
|
|
@@ -49,6 +50,7 @@ type ApplicationShellSidebarProps = ApplicationShellSharedProps & {
|
|
|
49
50
|
onDrawerOpenChange?: (open: boolean) => void;
|
|
50
51
|
/** Below 700px, "bottom" moves the destinations to a BottomNav. */
|
|
51
52
|
phoneNavigation?: "drawer" | "bottom";
|
|
53
|
+
brandMark?: React.ReactNode;
|
|
52
54
|
bottomNav?: never;
|
|
53
55
|
};
|
|
54
56
|
type ApplicationShellTopbarProps = ApplicationShellSharedProps & {
|
|
@@ -56,6 +58,7 @@ type ApplicationShellTopbarProps = ApplicationShellSharedProps & {
|
|
|
56
58
|
/** A BottomNav for phones, below 700px. */
|
|
57
59
|
bottomNav?: React.ReactNode;
|
|
58
60
|
phoneNavigation?: never;
|
|
61
|
+
brandMark?: never;
|
|
59
62
|
navigation?: never;
|
|
60
63
|
navigationLabel?: never;
|
|
61
64
|
footer?: never;
|
package/dist/app-shell.js
CHANGED
|
@@ -37,12 +37,15 @@ function ApplicationShellNavigation({ navigation, navigationLabel, collapsible =
|
|
|
37
37
|
}
|
|
38
38
|
function ApplicationShell(props) {
|
|
39
39
|
if (props.layout === "topbar") {
|
|
40
|
-
const { brand, primaryAction, header, headerVariant, headerSize, panel, bottomNav, children, layout: _layout, ...shellProps } = props;
|
|
41
|
-
return (_jsxs(AppShell, { ...shellProps, "data-layout": "topbar", children: [_jsxs(AppShellMain, { children: [_jsxs(Header, { variant: headerVariant, size: headerSize, children: [brand, primaryAction, header] }), children] }), panel, bottomNav] }));
|
|
40
|
+
const { brand, primaryAction, header, headerVariant, headerSize, panel, bottomNav, shellLayout, children, layout: _layout, ...shellProps } = props;
|
|
41
|
+
return (_jsxs(AppShell, { ...shellProps, "data-layout": "topbar", ...shellLayoutAttributes(shellLayout, headerSize), children: [_jsxs(AppShellMain, { children: [_jsxs(Header, { variant: headerVariant, size: headerSize, children: [brand, primaryAction, header] }), children] }), panel, bottomNav] }));
|
|
42
42
|
}
|
|
43
43
|
return _jsx(ApplicationShellSidebar, { ...props });
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function shellLayoutAttributes(shellLayout, headerSize) {
|
|
46
|
+
return shellLayout ? { "data-shell-layout": "true", "data-header-size": headerSize } : {};
|
|
47
|
+
}
|
|
48
|
+
function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationLabel = "Primary", footer, header, headerVariant, headerSize, panel, children, layout: _layout, collapsible = false, togglePlacement = "sidebar", collapsed, defaultCollapsed = false, onCollapsedChange, drawerOpen: controlledDrawer, onDrawerOpenChange, phoneNavigation = "drawer", brandMark, shellLayout, ...shellProps }) {
|
|
46
49
|
const [internalCollapsed, setInternalCollapsed] = React.useState(defaultCollapsed);
|
|
47
50
|
// Below 1024px the sidebar is not in the page; the same brand, action,
|
|
48
51
|
// navigation and footer open in a drawer from the header instead.
|
|
@@ -71,9 +74,17 @@ function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationL
|
|
|
71
74
|
setInternalCollapsed(next);
|
|
72
75
|
onCollapsedChange?.(next);
|
|
73
76
|
}
|
|
74
|
-
const
|
|
77
|
+
const railMark = collapsible && isCollapsed && brandMark && headerVariant !== "floating" ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "sidebar-rail-mark", "aria-hidden": "true", children: brandMark }), _jsx(PanelLeftOpen, { className: "icon sidebar-rail-open", "aria-hidden": "true" })] })) : null;
|
|
78
|
+
const toggle = collapsible ? (_jsx(Button, { ref: toggleRef, variant: "ghost", size: "sm", className: "sidebar-toggle btn-icon", "aria-controls": sidebarId, "aria-expanded": !isCollapsed, "aria-label": isCollapsed ? "Expand sidebar" : "Collapse sidebar", title: isCollapsed ? "Expand sidebar" : "Collapse sidebar", onClick: toggleSidebar, children: togglePlacement === "sidebar" && railMark ? railMark : isCollapsed ? _jsx(PanelLeftOpen, { className: "icon", "aria-hidden": "true" }) : _jsx(PanelLeftClose, { className: "icon", "aria-hidden": "true" }) })) : null;
|
|
79
|
+
const railButton = togglePlacement === "header" && railMark ? (_jsx(Button, { variant: "ghost", size: "sm", className: "sidebar-toggle btn-icon", "aria-controls": sidebarId, "aria-expanded": false, "aria-label": "Expand sidebar", title: "Expand sidebar", onClick: () => { toggleSidebar(); toggleRef.current?.focus(); }, children: railMark })) : null;
|
|
80
|
+
const action = shellLayout && primaryAction ? (_jsx("div", { className: cn("sidebar-actions", collapsible && "sidebar-expanded-content"), children: primaryAction })) : null;
|
|
81
|
+
const headerAction = shellLayout ? null : primaryAction;
|
|
82
|
+
const barOnTop = shellLayout && headerVariant === "floating";
|
|
75
83
|
const menu = (_jsx(Button, { ref: menuRef, variant: "ghost", size: "sm", className: "app-shell-menu btn-icon", "aria-expanded": drawerOpen, "aria-label": "Open navigation", title: "Navigation", onClick: () => setDrawerOpen(true), children: _jsx(Menu, { className: "icon", "aria-hidden": "true" }) }));
|
|
76
|
-
|
|
84
|
+
const shellHeader = (_jsxs(Header, { variant: headerVariant, size: headerSize, "data-phone-only": header || barOnTop || (collapsible && togglePlacement === "header") ? undefined : "true", children: [menu, barOnTop
|
|
85
|
+
? _jsx("div", { className: "app-shell-bar-brand", children: brand })
|
|
86
|
+
: (phoneNavigation === "bottom" || shellLayout) && _jsx("div", { className: "app-shell-phone-brand", children: brand }), phoneNavigation === "bottom" && primaryAction && _jsx("div", { className: "app-shell-phone-action", children: primaryAction }), togglePlacement === "header" && toggle, header] }));
|
|
87
|
+
return (_jsxs(AppShell, { ...shellProps, ...shellLayoutAttributes(shellLayout, headerSize), "data-phone-drawer": "true", "data-phone-navigation": phoneNavigation, children: [barOnTop && shellHeader, _jsxs(Sidebar, { ref: sidebarRef, id: sidebarId, collapsed: isCollapsed, children: [_jsx(SidebarHeader, { className: collapsible && (togglePlacement === "sidebar" || railButton) ? "sidebar-header-collapsible" : undefined, children: collapsible ? _jsxs(_Fragment, { children: [_jsxs("div", { className: "sidebar-expanded-content", children: [!barOnTop && brand, headerAction] }), togglePlacement === "sidebar" ? toggle : railButton] }) : _jsxs(_Fragment, { children: [!barOnTop && brand, headerAction] }) }), action, _jsx(SidebarBody, { children: _jsx(ApplicationShellNavigation, { navigation: navigation, navigationLabel: navigationLabel, collapsible: collapsible }) }), footer && _jsx(SidebarFooter, { className: collapsible ? "sidebar-expanded-content" : undefined, children: footer })] }), _jsxs(AppShellMain, { children: [!barOnTop && shellHeader, children] }), panel, _jsx(Drawer, { open: drawerOpen, onOpenChange: setDrawerOpen, children: _jsxs(DrawerContent, { placement: "side", className: "app-shell-drawer", onCloseAutoFocus: (event) => {
|
|
77
88
|
event.preventDefault();
|
|
78
89
|
menuRef.current?.focus();
|
|
79
90
|
}, children: [_jsxs(DrawerHeader, { children: [_jsx(VisuallyHidden.Root, { asChild: true, children: _jsx(DrawerTitle, { children: "Navigation" }) }), brand] }), _jsxs(DrawerBody, { onClick: (event) => {
|
package/dist/styles.css
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
@import "@momoi-labs/kiso/tokens.css";
|
|
3
3
|
@import "@momoi-labs/kiso/ui.css";
|
|
4
4
|
|
|
5
|
+
/* The row brings no outer padding; the host that places it sets the inset,
|
|
6
|
+
so in a header it fits the bar's height. */
|
|
5
7
|
.theme-row {
|
|
6
8
|
display: flex;
|
|
7
9
|
align-items: center;
|
|
8
10
|
justify-content: space-between;
|
|
9
11
|
gap: var(--spacing-sm);
|
|
10
|
-
padding: var(--spacing-sm);
|
|
11
12
|
}
|
|
13
|
+
.sidebar-footer .theme-row { padding-inline: var(--spacing-sm); } /* match .nav-item's inset */
|
|
12
14
|
.theme-buttons {
|
|
13
15
|
display: flex;
|
|
14
16
|
padding: var(--spacing-2xs);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momoi-labs/kiso-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "Kiso React components built with shadcn/ui and Radix",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"prepack": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@momoi-labs/kiso": "^1.
|
|
35
|
+
"@momoi-labs/kiso": "^1.10.0",
|
|
36
36
|
"class-variance-authority": "0.7.1",
|
|
37
37
|
"clsx": "2.1.1",
|
|
38
38
|
"radix-ui": "1.6.7",
|