@syscore/ui-library 2.0.0-beta-publish-workflow-beta.11 → 2.0.0-beta-publish-workflow-beta.12
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/client/components/ui/button.tsx +3 -0
- package/client/components/ui/data-grid.tsx +258 -0
- package/client/components/ui/side-nav.tsx +162 -8
- package/client/components/ui/typography.tsx +4 -0
- package/client/global.css +168 -1
- package/client/ui/Button.stories.tsx +26 -0
- package/client/ui/DataGrid.stories.tsx +114 -0
- package/client/ui/SideNav.stories.tsx +39 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +21 -0
- package/dist/index.es.js +258 -3
- package/package.json +3 -1
|
@@ -146,6 +146,32 @@ export const UtilityGeneralTertiary: Story = {
|
|
|
146
146
|
),
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
+
export const UtilityDangerPrimary: Story = {
|
|
150
|
+
render: () => (
|
|
151
|
+
<div className="space-y-6">
|
|
152
|
+
<div>
|
|
153
|
+
<p className="text-sm text-gray-600 mb-2">Danger, primary — confirms a destructive action</p>
|
|
154
|
+
<Button variant="danger-primary" size="utility">
|
|
155
|
+
Delete
|
|
156
|
+
</Button>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
),
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const UtilityDangerSecondary: Story = {
|
|
163
|
+
render: () => (
|
|
164
|
+
<div className="space-y-6">
|
|
165
|
+
<div>
|
|
166
|
+
<p className="text-sm text-gray-600 mb-2">Danger, secondary — starts a destructive action</p>
|
|
167
|
+
<Button variant="danger-secondary" size="utility">
|
|
168
|
+
Delete
|
|
169
|
+
</Button>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
),
|
|
173
|
+
};
|
|
174
|
+
|
|
149
175
|
export const UtilityTransparentTertiary: Story = {
|
|
150
176
|
render: () => (
|
|
151
177
|
<div className="space-y-6">
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { DataGrid, type DataGridColumn, type DataGridSort } from "../components/ui/data-grid";
|
|
4
|
+
import { StatusPill } from "../components/ui/status-pill";
|
|
5
|
+
import { Input } from "../components/ui/input";
|
|
6
|
+
|
|
7
|
+
interface Role {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
scope: string;
|
|
11
|
+
permissions: number;
|
|
12
|
+
builtIn: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const ROLES: Role[] = [
|
|
16
|
+
{ id: 1, name: "platform.super_admin", scope: "platform", permissions: 5, builtIn: true },
|
|
17
|
+
{ id: 2, name: "platform.admin", scope: "platform", permissions: 2, builtIn: true },
|
|
18
|
+
{ id: 3, name: "platform.user", scope: "platform", permissions: 0, builtIn: true },
|
|
19
|
+
{ id: 4, name: "support.reader", scope: "platform", permissions: 1, builtIn: false },
|
|
20
|
+
{ id: 5, name: "org.manager", scope: "organization", permissions: 3, builtIn: false },
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const COLUMNS: DataGridColumn<Role>[] = [
|
|
24
|
+
{ key: "name", header: "Role", value: (r) => r.name, sortable: true, filter: true, flex: 2 },
|
|
25
|
+
{ key: "scope", header: "Applies to", value: (r) => r.scope, sortable: true, filter: true },
|
|
26
|
+
{ key: "permissions", header: "Permissions", value: (r) => r.permissions, sortable: true, align: "right", width: 140 },
|
|
27
|
+
{
|
|
28
|
+
key: "kind",
|
|
29
|
+
header: "Kind",
|
|
30
|
+
value: (r) => (r.builtIn ? "Built in" : "Custom"),
|
|
31
|
+
cell: (r) => (
|
|
32
|
+
<StatusPill appearance="chip" tone={r.builtIn ? "plain" : "info"}>
|
|
33
|
+
{r.builtIn ? "Built in" : "Custom"}
|
|
34
|
+
</StatusPill>
|
|
35
|
+
),
|
|
36
|
+
sortable: true,
|
|
37
|
+
width: 150,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const meta = {
|
|
42
|
+
title: "Components/DataGrid",
|
|
43
|
+
component: DataGrid,
|
|
44
|
+
tags: ["autodocs"],
|
|
45
|
+
args: { rows: ROLES, columns: COLUMNS as unknown as DataGridColumn<unknown>[] },
|
|
46
|
+
parameters: {
|
|
47
|
+
layout: "padded",
|
|
48
|
+
docs: {
|
|
49
|
+
description: {
|
|
50
|
+
component:
|
|
51
|
+
"An interactive table on AG Grid (community): sortable and resizable columns, filters, a quick search, " +
|
|
52
|
+
"custom cells, loading and empty states. It renders the rows it is given — paging stays with the screen. " +
|
|
53
|
+
"Leave `onSortChange` out and the grid sorts and filters the rows itself; pass `sort` and `onSortChange` " +
|
|
54
|
+
"when the server sorts and refetch in that order.",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
} satisfies Meta<typeof DataGrid>;
|
|
59
|
+
|
|
60
|
+
export default meta;
|
|
61
|
+
|
|
62
|
+
type Story = StoryObj<typeof meta>;
|
|
63
|
+
|
|
64
|
+
export const Default: Story = {
|
|
65
|
+
render: () => <DataGrid<Role> aria-label="Roles" rows={ROLES} columns={COLUMNS} getRowId={(r) => String(r.id)} />,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const WithQuickSearch: Story = {
|
|
69
|
+
render: () => {
|
|
70
|
+
const [search, setSearch] = React.useState("");
|
|
71
|
+
return (
|
|
72
|
+
<div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
|
|
73
|
+
<div style={{ maxWidth: 320 }}>
|
|
74
|
+
<Input aria-label="Search roles" placeholder="Search roles" value={search} onChange={(e) => setSearch(e.target.value)} />
|
|
75
|
+
</div>
|
|
76
|
+
<DataGrid<Role> aria-label="Roles" rows={ROLES} columns={COLUMNS} getRowId={(r) => String(r.id)} quickFilter={search} />
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const ServerSorted: Story = {
|
|
83
|
+
render: () => {
|
|
84
|
+
const [sort, setSort] = React.useState<DataGridSort | null>({ key: "name", direction: "asc" });
|
|
85
|
+
// Stands in for a refetch: the parent, not the grid, puts the rows in order.
|
|
86
|
+
const rows = React.useMemo(() => {
|
|
87
|
+
const key = (sort?.key ?? "name") as "name" | "scope" | "permissions";
|
|
88
|
+
const direction = sort?.direction === "desc" ? -1 : 1;
|
|
89
|
+
return [...ROLES].sort((a, b) => (a[key] > b[key] ? 1 : a[key] < b[key] ? -1 : 0) * direction);
|
|
90
|
+
}, [sort]);
|
|
91
|
+
return <DataGrid<Role> aria-label="Roles" rows={rows} columns={COLUMNS} sort={sort} onSortChange={setSort} getRowId={(r) => String(r.id)} />;
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const Loading: Story = {
|
|
96
|
+
render: () => <DataGrid<Role> aria-label="Roles" rows={[]} columns={COLUMNS} loading />,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const Empty: Story = {
|
|
100
|
+
render: () => <DataGrid<Role> aria-label="Roles" rows={[]} columns={COLUMNS} emptyText="No roles yet." />,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const AllVariants: Story = {
|
|
104
|
+
render: () => (
|
|
105
|
+
<div style={{ display: "flex", flexDirection: "column", gap: 32 }}>
|
|
106
|
+
<DataGrid<Role> aria-label="Roles" rows={ROLES} columns={COLUMNS} getRowId={(r) => String(r.id)} />
|
|
107
|
+
<DataGrid<Role> aria-label="No roles" rows={[]} columns={COLUMNS} emptyText="No roles yet." />
|
|
108
|
+
</div>
|
|
109
|
+
),
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const InteractiveDataGrid: Story = {
|
|
113
|
+
render: () => <DataGrid<Role> aria-label="Roles" rows={ROLES} columns={COLUMNS} getRowId={(r) => String(r.id)} onRowClick={() => undefined} />,
|
|
114
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
-
import { BarChart3, FileText, LayoutDashboard, Users } from "lucide-react";
|
|
4
|
-
import { SideNav, SideNavGroup, SideNavItem } from "../components/ui/side-nav";
|
|
3
|
+
import { BarChart3, FileText, LayoutDashboard, Shield, Users } from "lucide-react";
|
|
4
|
+
import { SideNav, SideNavBranch, SideNavGroup, SideNavItem } from "../components/ui/side-nav";
|
|
5
5
|
|
|
6
6
|
const meta = {
|
|
7
7
|
title: "Components/SideNav",
|
|
@@ -50,7 +50,44 @@ function Demo({ collapsed = false }: { collapsed?: boolean }) {
|
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
function FoldingDemo({ collapsed = false }: { collapsed?: boolean }) {
|
|
54
|
+
const [current, setCurrent] = React.useState("users");
|
|
55
|
+
const item = (id: string, label: string, icon?: React.ReactNode) => (
|
|
56
|
+
<SideNavItem icon={icon} active={current === id} onClick={() => setCurrent(id)}>
|
|
57
|
+
{label}
|
|
58
|
+
</SideNavItem>
|
|
59
|
+
);
|
|
60
|
+
return (
|
|
61
|
+
<div style={{ width: collapsed ? 72 : 260, padding: "24px 12px", background: "#fff" }}>
|
|
62
|
+
<SideNav aria-label="Sections" collapsed={collapsed}>
|
|
63
|
+
<SideNavGroup label="Billing" collapsible>
|
|
64
|
+
{item("invoices", "Invoices", <FileText />)}
|
|
65
|
+
{item("estimates", "Estimates", <BarChart3 />)}
|
|
66
|
+
</SideNavGroup>
|
|
67
|
+
<SideNavGroup label="Administration" collapsible>
|
|
68
|
+
<SideNavBranch
|
|
69
|
+
icon={<Users />}
|
|
70
|
+
label="Users & roles"
|
|
71
|
+
active={["users", "roles", "permissions"].includes(current)}
|
|
72
|
+
defaultOpen
|
|
73
|
+
onClick={() => setCurrent("users")}
|
|
74
|
+
>
|
|
75
|
+
{item("users", "Users")}
|
|
76
|
+
{item("roles", "Roles")}
|
|
77
|
+
{item("permissions", "Permissions")}
|
|
78
|
+
</SideNavBranch>
|
|
79
|
+
{item("audit", "Audit log", <Shield />)}
|
|
80
|
+
</SideNavGroup>
|
|
81
|
+
</SideNav>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
53
86
|
export const Default: Story = { render: () => <Demo /> };
|
|
87
|
+
|
|
88
|
+
export const FoldingGroupsAndBranch: Story = { render: () => <FoldingDemo /> };
|
|
89
|
+
|
|
90
|
+
export const FoldingCollapsedRail: Story = { render: () => <FoldingDemo collapsed /> };
|
|
54
91
|
export const Collapsed: Story = { render: () => <Demo collapsed /> };
|
|
55
92
|
|
|
56
93
|
export const AllVariants: Story = {
|