@momoi-labs/kiso-react 0.5.0 → 0.6.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 CHANGED
@@ -62,7 +62,8 @@ Data and structure
62
62
  - Sidebar, SidebarHeader, SidebarBody, SidebarFooter.
63
63
  - AppShell and AppShellMain, the low-level columns of a console.
64
64
  - ApplicationShell, the standard brand, navigation, header, footer, and page
65
- arrangement.
65
+ arrangement. Pass `layout="topbar"` for a single-surface frame with brand and
66
+ primary action in the top bar and no sidebar rail.
66
67
  - Split, Pane, and Splitter, a list-detail layout with a resizable divider.
67
68
  - LogView, LogViewLine, LogViewTime, and LogViewLevel.
68
69
  - Stat, StatHeader, StatLabel, StatValue, StatFoot, and StatDelta.
@@ -119,9 +120,11 @@ const notify = useToast();
119
120
  notify('error', `Could not stop ${app.name}`, details);
120
121
  ```
121
122
 
122
- ApplicationShell takes navigation groups as data. Destinations keep routing in
123
- the product through `{ href, active, onClick? }`; the package owns the repeated
124
- Sidebar, Navigation, Header, and main arrangement.
123
+ ApplicationShell takes navigation groups as data in the default sidebar layout.
124
+ Destinations keep routing in the product through `{ href, active, onClick? }`;
125
+ the package owns the repeated Sidebar, Navigation, Header, and main
126
+ arrangement. With `layout="topbar"`, omit navigation and footer: brand and
127
+ primary action move into Header beside the existing header slot.
125
128
 
126
129
  Navigation, Sidebar, and Link know nothing about routing. Mark the current
127
130
  destination with `active`, and pass `asChild` to render a router's own link
@@ -14,15 +14,25 @@ type ApplicationShellGroup = {
14
14
  destinations: readonly ApplicationShellDestination[];
15
15
  empty?: React.ReactNode;
16
16
  };
17
- type ApplicationShellProps = Omit<React.ComponentProps<typeof AppShell>, "children"> & {
17
+ type ApplicationShellSharedProps = Omit<React.ComponentProps<typeof AppShell>, "children"> & {
18
18
  brand: React.ReactNode;
19
19
  primaryAction?: React.ReactNode;
20
+ header?: React.ReactNode;
21
+ children: React.ReactNode;
22
+ };
23
+ type ApplicationShellSidebarProps = ApplicationShellSharedProps & {
24
+ layout?: "sidebar";
20
25
  navigation: readonly ApplicationShellGroup[];
21
26
  navigationLabel?: string;
22
27
  footer?: React.ReactNode;
23
- header?: React.ReactNode;
24
- children: React.ReactNode;
25
28
  };
26
- declare function ApplicationShell({ brand, primaryAction, navigation, navigationLabel, footer, header, children, ...props }: ApplicationShellProps): React.JSX.Element;
29
+ type ApplicationShellTopbarProps = ApplicationShellSharedProps & {
30
+ layout: "topbar";
31
+ navigation?: never;
32
+ navigationLabel?: never;
33
+ footer?: never;
34
+ };
35
+ type ApplicationShellProps = ApplicationShellSidebarProps | ApplicationShellTopbarProps;
36
+ declare function ApplicationShell(props: ApplicationShellProps): React.JSX.Element;
27
37
  export { AppShell, AppShellMain, ApplicationShell };
28
38
  export type { ApplicationShellDestination, ApplicationShellGroup, ApplicationShellProps, };
package/dist/app-shell.js CHANGED
@@ -11,12 +11,20 @@ function AppShell({ className, ...props }) {
11
11
  function AppShellMain({ className, ...props }) {
12
12
  return (_jsx("main", { "data-slot": "app-shell-main", className: cn("grow", className), ...props }));
13
13
  }
14
- function ApplicationShell({ brand, primaryAction, navigation, navigationLabel = "Primary", footer, header, children, ...props }) {
15
- return (_jsxs(AppShell, { ...props, children: [_jsxs(Sidebar, { children: [_jsxs(SidebarHeader, { children: [brand, primaryAction] }), _jsx(SidebarBody, { children: _jsx(Navigation, { "aria-label": navigationLabel, children: navigation.map((group, groupIndex) => (_jsx(NavigationGroup, { label: group.label, children: group.destinations.length > 0 ? (_jsx(NavigationList, { children: group.destinations.map((destination, destinationIndex) => (_jsx(NavigationItem, { children: _jsxs(NavigationLink, { href: destination.href, active: destination.active, onClick: (event) => {
16
- if (!destination.onClick)
17
- return;
18
- event.preventDefault();
19
- destination.onClick();
20
- }, children: [destination.leading, _jsx("span", { className: "grow truncate", children: destination.label }), destination.trailing] }) }, `${destination.href}-${destinationIndex}`))) })) : group.empty }, group.label ?? groupIndex))) }) }), footer && _jsx(SidebarFooter, { children: footer })] }), _jsxs(AppShellMain, { children: [header && _jsx(Header, { children: header }), children] })] }));
14
+ function ApplicationShellNavigation({ navigation, navigationLabel, }) {
15
+ return (_jsx(Navigation, { "aria-label": navigationLabel, children: navigation.map((group, groupIndex) => (_jsx(NavigationGroup, { label: group.label, children: group.destinations.length > 0 ? (_jsx(NavigationList, { children: group.destinations.map((destination, destinationIndex) => (_jsx(NavigationItem, { children: _jsxs(NavigationLink, { href: destination.href, active: destination.active, onClick: (event) => {
16
+ if (!destination.onClick)
17
+ return;
18
+ event.preventDefault();
19
+ destination.onClick();
20
+ }, children: [destination.leading, _jsx("span", { className: "grow truncate", children: destination.label }), destination.trailing] }) }, `${destination.href}-${destinationIndex}`))) })) : (group.empty) }, group.label ?? groupIndex))) }));
21
+ }
22
+ function ApplicationShell(props) {
23
+ if (props.layout === "topbar") {
24
+ const { brand, primaryAction, header, children, layout: _layout, ...shellProps } = props;
25
+ return (_jsx(AppShell, { ...shellProps, "data-layout": "topbar", children: _jsxs(AppShellMain, { children: [_jsxs(Header, { children: [brand, primaryAction, header] }), children] }) }));
26
+ }
27
+ const { brand, primaryAction, navigation, navigationLabel = "Primary", footer, header, children, layout: _layout, ...shellProps } = props;
28
+ return (_jsxs(AppShell, { ...shellProps, children: [_jsxs(Sidebar, { children: [_jsxs(SidebarHeader, { children: [brand, primaryAction] }), _jsx(SidebarBody, { children: _jsx(ApplicationShellNavigation, { navigation: navigation, navigationLabel: navigationLabel }) }), footer && _jsx(SidebarFooter, { children: footer })] }), _jsxs(AppShellMain, { children: [header && _jsx(Header, { children: header }), children] })] }));
21
29
  }
22
30
  export { AppShell, AppShellMain, ApplicationShell };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momoi-labs/kiso-react",
3
- "version": "0.5.0",
3
+ "version": "0.6.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": "^0.8.0",
35
+ "@momoi-labs/kiso": "^0.9.0",
36
36
  "class-variance-authority": "0.7.1",
37
37
  "clsx": "2.1.1",
38
38
  "radix-ui": "1.6.7",