@momoi-labs/kiso-react 0.32.0 → 0.33.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/app-shell.js +1 -1
- package/dist/console-shell.d.ts +27 -0
- package/dist/console-shell.js +28 -0
- package/dist/detail-page.d.ts +25 -0
- package/dist/detail-page.js +12 -0
- package/dist/form-page.d.ts +18 -0
- package/dist/form-page.js +12 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/list-page.d.ts +20 -0
- package/dist/list-page.js +13 -0
- package/dist/page-action.d.ts +12 -0
- package/dist/page-action.js +9 -0
- package/package.json +2 -2
package/dist/app-shell.js
CHANGED
|
@@ -83,7 +83,7 @@ function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationL
|
|
|
83
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" }) }));
|
|
84
84
|
const shellHeader = (_jsxs(Header, { variant: headerVariant, size: headerSize, "data-phone-only": header || barOnTop || (collapsible && togglePlacement === "header") ? undefined : "true", children: [menu, barOnTop
|
|
85
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] }));
|
|
86
|
+
: (phoneNavigation === "bottom" || shellLayout) && _jsx("div", { className: "app-shell-phone-brand", children: shellLayout && brandMark ? brandMark : brand }), phoneNavigation === "bottom" && primaryAction && _jsx("div", { className: "app-shell-phone-action", children: primaryAction }), togglePlacement === "header" && toggle, header] }));
|
|
87
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) => {
|
|
88
88
|
event.preventDefault();
|
|
89
89
|
menuRef.current?.focus();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { MouseEvent, ReactNode } from "react";
|
|
2
|
+
import { type ApplicationShellGroup } from "./app-shell.js";
|
|
3
|
+
type ConsoleCrumb = {
|
|
4
|
+
label: string;
|
|
5
|
+
href?: string;
|
|
6
|
+
onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
|
|
7
|
+
};
|
|
8
|
+
type ConsoleAccount = {
|
|
9
|
+
identity: ReactNode;
|
|
10
|
+
theme: string;
|
|
11
|
+
onThemeChange: (theme: string) => void;
|
|
12
|
+
onSignOut: () => void;
|
|
13
|
+
href?: string;
|
|
14
|
+
language?: ReactNode;
|
|
15
|
+
};
|
|
16
|
+
type ConsoleShellProps = {
|
|
17
|
+
brand: ReactNode;
|
|
18
|
+
brandMark: ReactNode;
|
|
19
|
+
navigation: readonly ApplicationShellGroup[];
|
|
20
|
+
navigationLabel?: string;
|
|
21
|
+
breadcrumb: readonly ConsoleCrumb[];
|
|
22
|
+
account: ConsoleAccount;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
};
|
|
25
|
+
declare function ConsoleShell({ brand, brandMark, navigation, navigationLabel, breadcrumb, account, children }: ConsoleShellProps): import("react").JSX.Element;
|
|
26
|
+
export { ConsoleShell };
|
|
27
|
+
export type { ConsoleAccount, ConsoleCrumb, ConsoleShellProps };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CircleUser, LogOut, UserRound } from "lucide-react";
|
|
4
|
+
import { ApplicationShell } from "./app-shell.js";
|
|
5
|
+
import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "./breadcrumb.js";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
8
|
+
import { ThemeSelector } from "./theme-selector.js";
|
|
9
|
+
function ConsoleBreadcrumb({ items }) {
|
|
10
|
+
return _jsx(Breadcrumb, { className: "app-shell-breadcrumb", children: _jsx(BreadcrumbList, { children: items.flatMap((item, index) => {
|
|
11
|
+
const last = index === items.length - 1;
|
|
12
|
+
const crumb = _jsx(BreadcrumbItem, { children: last
|
|
13
|
+
? _jsx(BreadcrumbPage, { children: item.label })
|
|
14
|
+
: item.href
|
|
15
|
+
? _jsx(BreadcrumbLink, { href: item.href, onClick: item.onClick, children: item.label })
|
|
16
|
+
: _jsx("span", { children: item.label }) }, `${index}-${item.label}`);
|
|
17
|
+
return last ? [crumb] : [crumb, _jsx(BreadcrumbSeparator, {}, `${index}-sep`)];
|
|
18
|
+
}) }) });
|
|
19
|
+
}
|
|
20
|
+
function ConsoleAccountMenu({ account }) {
|
|
21
|
+
return _jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "sm", className: "btn-icon", "aria-label": "Account", title: "Account", children: _jsx(CircleUser, { className: "icon", "aria-hidden": "true" }) }) }), _jsxs(PopoverContent, { align: "end", className: "app-shell-account", children: [_jsx("p", { className: "app-shell-account-identity", children: account.identity }), account.href
|
|
22
|
+
? _jsx(Button, { variant: "ghost", size: "sm", asChild: true, children: _jsxs("a", { href: account.href, children: [_jsx(UserRound, { className: "icon", "aria-hidden": "true" }), "Account"] }) })
|
|
23
|
+
: null, _jsx(ThemeSelector, { theme: account.theme, onChange: account.onThemeChange }), account.language, _jsxs(Button, { variant: "ghost", size: "sm", onClick: account.onSignOut, children: [_jsx(LogOut, { className: "icon", "aria-hidden": "true" }), "Sign out"] })] })] });
|
|
24
|
+
}
|
|
25
|
+
function ConsoleShell({ brand, brandMark, navigation, navigationLabel = "Primary", breadcrumb, account, children }) {
|
|
26
|
+
return _jsx(ApplicationShell, { collapsible: true, togglePlacement: "header", shellLayout: true, headerVariant: "default", brand: brand, brandMark: brandMark, navigation: navigation, navigationLabel: navigationLabel, header: _jsxs(_Fragment, { children: [_jsx(ConsoleBreadcrumb, { items: breadcrumb }), _jsx("div", { className: "grow" }), _jsx(ConsoleAccountMenu, { account: account })] }), children: _jsx("div", { className: "page", children: children }) });
|
|
27
|
+
}
|
|
28
|
+
export { ConsoleShell };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { PageWidth } from "./form-page.js";
|
|
3
|
+
import { type PageAction } from "./page-action.js";
|
|
4
|
+
type DetailTab = {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
empty?: {
|
|
8
|
+
title: string;
|
|
9
|
+
text?: string;
|
|
10
|
+
};
|
|
11
|
+
content?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
type DetailPageProps = {
|
|
14
|
+
title: string;
|
|
15
|
+
action?: PageAction;
|
|
16
|
+
tabs: readonly DetailTab[];
|
|
17
|
+
tabsLabel?: string;
|
|
18
|
+
value?: string;
|
|
19
|
+
onValueChange?: (value: string) => void;
|
|
20
|
+
fill?: boolean;
|
|
21
|
+
width?: PageWidth;
|
|
22
|
+
};
|
|
23
|
+
declare function DetailPage({ title, action, tabs, tabsLabel, value, onValueChange, fill, width }: DetailPageProps): import("react").JSX.Element;
|
|
24
|
+
export { DetailPage };
|
|
25
|
+
export type { DetailPageProps, DetailTab };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card } from "./card.js";
|
|
3
|
+
import { EmptyState, EmptyStateDescription, EmptyStateTitle } from "./empty-state.js";
|
|
4
|
+
import { PageActionButton } from "./page-action.js";
|
|
5
|
+
import { PageHeader, PageHeaderTitle } from "./page-header.js";
|
|
6
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./tabs.js";
|
|
7
|
+
function DetailPage({ title, action, tabs, tabsLabel = `${title} details`, value, onValueChange, fill = false, width = "full" }) {
|
|
8
|
+
return _jsxs(_Fragment, { children: [_jsx(PageHeader, { actions: action ? _jsx(PageActionButton, { action: action }) : undefined, children: _jsx(PageHeaderTitle, { children: title }) }), _jsx(Card, { className: "detail-tabs", "data-fill": fill ? undefined : "false", "data-width": width, children: _jsxs(Tabs, { defaultValue: tabs[0]?.value, value: value, onValueChange: onValueChange, children: [_jsx(TabsList, { "aria-label": tabsLabel, children: tabs.map(tab => _jsx(TabsTrigger, { value: tab.value, children: tab.label }, tab.value)) }), tabs.map(tab => _jsx(TabsContent, { value: tab.value, children: tab.empty
|
|
9
|
+
? _jsxs(EmptyState, { children: [_jsx(EmptyStateTitle, { children: tab.empty.title }), tab.empty.text ? _jsx(EmptyStateDescription, { children: tab.empty.text }) : null] })
|
|
10
|
+
: tab.content }, tab.value))] }) })] });
|
|
11
|
+
}
|
|
12
|
+
export { DetailPage };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FormEvent, ReactNode } from "react";
|
|
2
|
+
type PageWidth = "left" | "center" | "right" | "full";
|
|
3
|
+
type FormPageProps = {
|
|
4
|
+
title: string;
|
|
5
|
+
mode: "create" | "edit";
|
|
6
|
+
submitLabel: string;
|
|
7
|
+
onSubmit: (event: FormEvent<HTMLFormElement>) => void;
|
|
8
|
+
onCancel?: () => void;
|
|
9
|
+
onDiscard?: () => void;
|
|
10
|
+
dirty?: boolean;
|
|
11
|
+
message?: ReactNode;
|
|
12
|
+
failed?: boolean;
|
|
13
|
+
width?: PageWidth;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
};
|
|
16
|
+
declare function FormPage({ title, mode, submitLabel, onSubmit, onCancel, onDiscard, dirty, message, failed, width, children }: FormPageProps): import("react").JSX.Element;
|
|
17
|
+
export { FormPage };
|
|
18
|
+
export type { FormPageProps, PageWidth };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "./button.js";
|
|
3
|
+
import { Card } from "./card.js";
|
|
4
|
+
import { Form, FormActions } from "./form.js";
|
|
5
|
+
import { PageHeader, PageHeaderTitle } from "./page-header.js";
|
|
6
|
+
function FormPage({ title, mode, submitLabel, onSubmit, onCancel, onDiscard, dirty = false, message, failed = false, width = "left", children }) {
|
|
7
|
+
const tone = failed ? "danger" : dirty ? "warning" : "neutral";
|
|
8
|
+
return _jsxs(_Fragment, { children: [_jsx(PageHeader, { children: _jsx(PageHeaderTitle, { children: title }) }), _jsx(Card, { className: "form-page", "data-fill": "false", "data-width": width, children: _jsxs(Form, { onSubmit: onSubmit, "aria-label": title, children: [_jsx("div", { className: "form-body", children: children }), _jsxs(FormActions, { sticky: true, tone: tone, message: message, children: [mode === "create"
|
|
9
|
+
? _jsx(Button, { size: "sm", type: "button", onClick: onCancel, children: "Cancel" })
|
|
10
|
+
: dirty ? _jsx(Button, { size: "sm", type: "button", onClick: onDiscard, children: "Discard" }) : null, _jsx(Button, { size: "sm", type: "submit", variant: "primary", disabled: mode === "edit" && !dirty, children: submitLabel })] })] }) })] });
|
|
11
|
+
}
|
|
12
|
+
export { FormPage };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./brand-mark.js";
|
|
|
7
7
|
export * from "./breadcrumb.js";
|
|
8
8
|
export * from "./button.js";
|
|
9
9
|
export * from "./card.js";
|
|
10
|
+
export * from "./console-shell.js";
|
|
10
11
|
export * from "./panel-shadow.js";
|
|
11
12
|
export * from "./checkbox.js";
|
|
12
13
|
export * from "./chip-input.js";
|
|
@@ -23,6 +24,7 @@ export * from "./dropdown-menu.js";
|
|
|
23
24
|
export * from "./empty-state.js";
|
|
24
25
|
export * from "./form-field.js";
|
|
25
26
|
export * from "./form.js";
|
|
27
|
+
export * from "./form-page.js";
|
|
26
28
|
export * from "./header.js";
|
|
27
29
|
export * from "./input.js";
|
|
28
30
|
export * from "./password-input.js";
|
|
@@ -32,11 +34,13 @@ export * from "./link.js";
|
|
|
32
34
|
export * from "./log-view.js";
|
|
33
35
|
export * from "./navigation.js";
|
|
34
36
|
export * from "./page-header.js";
|
|
37
|
+
export * from "./list-page.js";
|
|
35
38
|
export * from "./pagination.js";
|
|
36
39
|
export * from "./popover.js";
|
|
37
40
|
export * from "./scope-switcher.js";
|
|
38
41
|
export * from "./search.js";
|
|
39
42
|
export * from "./select.js";
|
|
43
|
+
export * from "./detail-page.js";
|
|
40
44
|
export * from "./detail-select.js";
|
|
41
45
|
export * from "./media-preview.js";
|
|
42
46
|
export type { ChartFill, ChartLayout, ChartLegendPlacement, ChartLine, ChartStyle, ChartTreatment } from "./chart-style.js";
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./brand-mark.js";
|
|
|
8
8
|
export * from "./breadcrumb.js";
|
|
9
9
|
export * from "./button.js";
|
|
10
10
|
export * from "./card.js";
|
|
11
|
+
export * from "./console-shell.js";
|
|
11
12
|
export * from "./panel-shadow.js";
|
|
12
13
|
export * from "./checkbox.js";
|
|
13
14
|
export * from "./chip-input.js";
|
|
@@ -24,6 +25,7 @@ export * from "./dropdown-menu.js";
|
|
|
24
25
|
export * from "./empty-state.js";
|
|
25
26
|
export * from "./form-field.js";
|
|
26
27
|
export * from "./form.js";
|
|
28
|
+
export * from "./form-page.js";
|
|
27
29
|
export * from "./header.js";
|
|
28
30
|
export * from "./input.js";
|
|
29
31
|
export * from "./password-input.js";
|
|
@@ -33,11 +35,13 @@ export * from "./link.js";
|
|
|
33
35
|
export * from "./log-view.js";
|
|
34
36
|
export * from "./navigation.js";
|
|
35
37
|
export * from "./page-header.js";
|
|
38
|
+
export * from "./list-page.js";
|
|
36
39
|
export * from "./pagination.js";
|
|
37
40
|
export * from "./popover.js";
|
|
38
41
|
export * from "./scope-switcher.js";
|
|
39
42
|
export * from "./search.js";
|
|
40
43
|
export * from "./select.js";
|
|
44
|
+
export * from "./detail-page.js";
|
|
41
45
|
export * from "./detail-select.js";
|
|
42
46
|
export * from "./media-preview.js";
|
|
43
47
|
export * from "./separator.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { PageWidth } from "./form-page.js";
|
|
3
|
+
import { type PageAction } from "./page-action.js";
|
|
4
|
+
type ListPageProps = {
|
|
5
|
+
title: string;
|
|
6
|
+
action: PageAction;
|
|
7
|
+
state: "loading" | "empty" | "ready";
|
|
8
|
+
empty: {
|
|
9
|
+
title: string;
|
|
10
|
+
text?: string;
|
|
11
|
+
};
|
|
12
|
+
filters?: ReactNode;
|
|
13
|
+
count?: string;
|
|
14
|
+
fill?: boolean;
|
|
15
|
+
width?: PageWidth;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
declare function ListPage({ title, action, state, empty, filters, count, fill, width, children }: ListPageProps): import("react").JSX.Element;
|
|
19
|
+
export { ListPage };
|
|
20
|
+
export type { ListPageProps, PageAction };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card, CardContent } from "./card.js";
|
|
3
|
+
import { EmptyState, EmptyStateDescription, EmptyStateTitle } from "./empty-state.js";
|
|
4
|
+
import { PageActionButton } from "./page-action.js";
|
|
5
|
+
import { PageHeader, PageHeaderTitle } from "./page-header.js";
|
|
6
|
+
import { Skeleton } from "./skeleton.js";
|
|
7
|
+
import { Table, TableFrame } from "./table.js";
|
|
8
|
+
function ListPage({ title, action, state, empty, filters, count, fill = false, width = "full", children }) {
|
|
9
|
+
return _jsxs(_Fragment, { children: [_jsx(PageHeader, { actions: _jsx(PageActionButton, { action: action }), children: _jsx(PageHeaderTitle, { children: title }) }), state === "empty"
|
|
10
|
+
? _jsx(Card, { "data-width": width, children: _jsx(CardContent, { children: _jsxs(EmptyState, { children: [_jsx(EmptyStateTitle, { children: empty.title }), empty.text ? _jsx(EmptyStateDescription, { children: empty.text }) : null] }) }) })
|
|
11
|
+
: _jsxs(_Fragment, { children: [state === "ready" && filters ? _jsx("div", { "data-width": width, children: filters }) : null, _jsxs(TableFrame, { "data-fill": fill ? undefined : "false", "data-width": width, children: [_jsx(Table, { children: state === "loading" ? _jsx("tbody", { children: _jsx("tr", { children: _jsx("td", { children: _jsx(Skeleton, {}) }) }) }) : children }), state === "ready" && count ? _jsx("div", { className: "table-footer", children: _jsx("span", { children: count }) }) : null] })] })] });
|
|
12
|
+
}
|
|
13
|
+
export { ListPage };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type PageAction = {
|
|
3
|
+
label: string;
|
|
4
|
+
icon?: ReactNode;
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
href?: string;
|
|
7
|
+
};
|
|
8
|
+
declare function PageActionButton({ action }: {
|
|
9
|
+
action: PageAction;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
export { PageActionButton };
|
|
12
|
+
export type { PageAction };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "./button.js";
|
|
3
|
+
function PageActionButton({ action }) {
|
|
4
|
+
const content = _jsxs(_Fragment, { children: [action.icon, action.label] });
|
|
5
|
+
return action.href
|
|
6
|
+
? _jsx(Button, { size: "sm", variant: "primary", asChild: true, children: _jsx("a", { href: action.href, children: content }) })
|
|
7
|
+
: _jsx(Button, { size: "sm", variant: "primary", onClick: action.onClick, children: content });
|
|
8
|
+
}
|
|
9
|
+
export { PageActionButton };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momoi-labs/kiso-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.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.11.0",
|
|
36
36
|
"class-variance-authority": "0.7.1",
|
|
37
37
|
"clsx": "2.1.1",
|
|
38
38
|
"radix-ui": "1.6.7",
|