@robert-stackflow/oneui 0.5.1 → 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/CHANGELOG.md +0 -7
- package/README.md +45 -14
- package/components/AppShell.d.ts +6 -13
- package/components/AppShell.js +28 -17
- package/components/AppShell.module.css +251 -269
- package/components/AuthLayout.d.ts +8 -0
- package/components/AuthLayout.js +25 -0
- package/components/AuthLayout.module.css +36 -0
- package/components/Badge.d.ts +2 -2
- package/components/Badge.js +4 -2
- package/components/BarChart.d.ts +8 -0
- package/components/BarChart.js +37 -0
- package/components/BarChart.module.css +34 -0
- package/components/Button.d.ts +1 -1
- package/components/Button.module.css +3 -0
- package/components/ContributionCalendar.js +2 -2
- package/components/ContributionCalendar.module.css +3 -0
- package/components/CopyButton.d.ts +9 -0
- package/components/CopyButton.js +23 -0
- package/components/Layout.d.ts +81 -0
- package/components/Layout.js +271 -0
- package/components/Layout.module.css +66 -0
- package/components/Menu.d.ts +4 -1
- package/components/Menu.js +10 -4
- package/components/MultiSelect.d.ts +1 -2
- package/components/MultiSelect.js +13 -82
- package/components/MultiSelect.module.css +0 -6
- package/components/NumberInput.d.ts +1 -0
- package/components/NumberInput.js +4 -0
- package/components/NumberInput.module.css +11 -0
- package/components/Page.d.ts +7 -1
- package/components/Page.js +15 -8
- package/components/Page.module.css +1 -0
- package/components/Pagination.d.ts +2 -1
- package/components/Pagination.js +3 -2
- package/components/ResourceCard.d.ts +12 -0
- package/components/ResourceCard.js +24 -0
- package/components/ResourceCard.module.css +13 -0
- package/components/SidebarNavigation.d.ts +29 -0
- package/components/SidebarNavigation.js +139 -0
- package/components/SidebarNavigation.module.css +109 -0
- package/components/Table.module.css +2 -2
- package/components/TableMarkup.d.ts +23 -0
- package/components/TableMarkup.js +41 -0
- package/components/Tooltip.d.ts +2 -1
- package/components/Tooltip.js +3 -1
- package/components/index.d.ts +12 -2
- package/components/index.js +42 -1
- package/package.json +42 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.5.1 — 2026-10-29
|
|
4
|
-
|
|
5
|
-
- MultiSelect 新增 `onCreate`,标签模式在同一触发框内展示已选项,支持搜索创建、连续多选、错误重试,以及关闭后忽略异步创建结果。
|
|
6
|
-
- Page 支持可选 ReactNode 标题,可为无标题的内容区复用共享入场动画。
|
|
7
|
-
- AppShell 新增 `navigationGroups`,桌面侧栏与移动导航共享分组和分隔布局;保留原有扁平导航 API。
|
|
8
|
-
|
|
9
|
-
|
|
10
3
|
## 0.5.0 — 2026-10-29
|
|
11
4
|
|
|
12
5
|
- 新增 ActionSheet,复用 IconButton、Drawer 和 MenuItem;桌面使用紧凑底部面板,手机适配底部安全区域,支持禁用和危险操作。
|
package/README.md
CHANGED
|
@@ -7,14 +7,26 @@ React 组件、应用外壳和两套可互换的主题。无 Electron、React Ro
|
|
|
7
7
|
`ActionSheet` 使用带无障碍名称的更多图标按钮打开底部操作面板;`items` 支持 `label`、`icon`、`disabled`、`danger` 和 `action`。选择后先完成关闭和焦点恢复,再执行操作,可安全打开另一个弹窗。桌面为紧凑面板,手机贴合底部安全区域。
|
|
8
8
|
|
|
9
9
|
```tsx
|
|
10
|
-
<ActionSheet
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
<ActionSheet
|
|
11
|
+
label="图片操作 1"
|
|
12
|
+
title="图片操作"
|
|
13
|
+
items={[
|
|
14
|
+
{ label: "编辑图片", action: editPhoto },
|
|
15
|
+
{ label: "移除图片", danger: true, action: removePhoto },
|
|
16
|
+
]}
|
|
17
|
+
/>
|
|
14
18
|
```
|
|
15
19
|
|
|
16
20
|
横向 `FormField` 内包含 `Textarea` 时,标签自动靠上排列;手机仍使用纵向布局。`Drawer.onAfterClose` 可在关闭动画与焦点恢复完成后执行后续操作。
|
|
17
21
|
|
|
22
|
+
## 嵌套侧栏(0.6.0)
|
|
23
|
+
|
|
24
|
+
`AppShell.navigation` 支持多层 `children`。异步节点可传 `expandable: true`,通过 `content` 提供加载、空状态或重试操作。链接与展开按钮分离,保留新标签打开行为,展开按钮支持键盘和 `aria-expanded` / `aria-controls`。
|
|
25
|
+
|
|
26
|
+
`expandedIds` + `onExpandedChange` 提供受控展开;`defaultExpandedIds` 提供非受控初值。展开以稳定节点 ID 保存,刷新数据或整体折叠不丢失状态。宿主根据路由主动展开祖先,并自行决定何时请求子节点。桌面和手机抽屉共用状态;桌面整体折叠不会隐藏手机抽屉的节点文字。
|
|
27
|
+
|
|
28
|
+
可单独使用 `SidebarNavigation`,支持 `items`、`active`、`onNavigate`、`basePath`、`compact` 和相同的展开参数。原有扁平导航和导入路径保持兼容。
|
|
29
|
+
|
|
18
30
|
## 使用
|
|
19
31
|
|
|
20
32
|
```sh
|
|
@@ -22,9 +34,14 @@ npm install @robert-stackflow/oneui
|
|
|
22
34
|
```
|
|
23
35
|
|
|
24
36
|
```tsx
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
import {
|
|
38
|
+
ThemeProvider,
|
|
39
|
+
UIProvider,
|
|
40
|
+
ToastProvider,
|
|
41
|
+
Button,
|
|
42
|
+
} from "@robert-stackflow/oneui";
|
|
43
|
+
import "@robert-stackflow/oneui/styles/themes.css";
|
|
44
|
+
import "@robert-stackflow/oneui/styles/base.css";
|
|
28
45
|
|
|
29
46
|
export function App() {
|
|
30
47
|
return (
|
|
@@ -81,8 +98,14 @@ export function App() {
|
|
|
81
98
|
`Pagination` 的 `total` 是总条数,`pageSize` 是每页条数。`compact` 移除外层留白并在窄屏重排页码、统计和跳转,`size="small"` 使用当前主题的小尺寸控件;正常和紧凑模式均支持长页码列表换行。宿主可通过 `className` 调整外层位置。
|
|
82
99
|
|
|
83
100
|
```tsx
|
|
84
|
-
<Pagination
|
|
85
|
-
|
|
101
|
+
<Pagination
|
|
102
|
+
compact
|
|
103
|
+
size="small"
|
|
104
|
+
page={page}
|
|
105
|
+
pageSize={10}
|
|
106
|
+
total={records.total}
|
|
107
|
+
onPageChange={setPage}
|
|
108
|
+
/>
|
|
86
109
|
```
|
|
87
110
|
|
|
88
111
|
## 层级选择、补全与标签
|
|
@@ -99,9 +122,17 @@ export function App() {
|
|
|
99
122
|
`AppShell` 默认仍显示 OneUI 品牌和顶部栏。可通过 `brandName`、`brandIcon` 设置品牌,或用 `brand` 替换完整品牌内容;`homePath` 指定宿主内部首页,`basePath="/admin"` 为实际链接添加基础路径。`onNavigate` 收到未加基础路径的内部路径,适合 React Router basename;Ctrl/Cmd 点击和新标签页使用完整 href。`showHeader={false}` 保留移动端浮动导航按钮。`settingsItem` 和 `onCollapsedChange` 可省略。自定义完整品牌内容由宿主负责紧凑侧栏适配。
|
|
100
123
|
|
|
101
124
|
```tsx
|
|
102
|
-
<AppShell
|
|
103
|
-
|
|
104
|
-
|
|
125
|
+
<AppShell
|
|
126
|
+
brandName="Moment"
|
|
127
|
+
brandIcon={<Brand />}
|
|
128
|
+
homePath="/workbench"
|
|
129
|
+
basePath="/admin"
|
|
130
|
+
showHeader={false}
|
|
131
|
+
navigation={navigation}
|
|
132
|
+
active={active}
|
|
133
|
+
title={title}
|
|
134
|
+
onNavigate={navigate}
|
|
135
|
+
>
|
|
105
136
|
{children}
|
|
106
137
|
</AppShell>
|
|
107
138
|
```
|
|
@@ -112,9 +143,9 @@ export function App() {
|
|
|
112
143
|
// notifications.ts
|
|
113
144
|
export const notifications = createToaster();
|
|
114
145
|
export const notifyError = (error: Error) =>
|
|
115
|
-
notifications.notify(error.message, { tone:
|
|
146
|
+
notifications.notify(error.message, { tone: "error" });
|
|
116
147
|
// application root
|
|
117
|
-
<ToastProvider controller={notifications}>{children}</ToastProvider
|
|
148
|
+
<ToastProvider controller={notifications}>{children}</ToastProvider>;
|
|
118
149
|
```
|
|
119
150
|
|
|
120
151
|
`IconPicker valuePrefix="lucide:"` 将内置图标名转换为带前缀的存储值;`options` 可提供 `{ value, label, icon, keywords?, category? }` 自定义目录,选择后原样返回 value。自定义目录不加载内置图标资源,设置 options 时不应用 valuePrefix。`IconPickerProps`、`IconPickerOption` 可从根入口或组件子路径导入。
|
package/components/AppShell.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
path: string;
|
|
5
|
-
label: string;
|
|
6
|
-
icon: ReactNode;
|
|
7
|
-
}
|
|
2
|
+
import { type NavigationItem } from "./SidebarNavigation";
|
|
3
|
+
export type { NavigationItem } from "./SidebarNavigation";
|
|
8
4
|
export declare function ShellHeader({ title, collapsed, onToggle, onMenu, actions, windowControls, draggable, }: {
|
|
9
5
|
title: string;
|
|
10
6
|
collapsed?: boolean;
|
|
@@ -14,14 +10,8 @@ export declare function ShellHeader({ title, collapsed, onToggle, onMenu, action
|
|
|
14
10
|
windowControls?: ReactNode;
|
|
15
11
|
draggable?: boolean;
|
|
16
12
|
}): import("react").JSX.Element;
|
|
17
|
-
export interface NavigationGroup {
|
|
18
|
-
id: string;
|
|
19
|
-
label?: string;
|
|
20
|
-
items: readonly NavigationItem[];
|
|
21
|
-
}
|
|
22
13
|
export interface AppShellProps {
|
|
23
14
|
navigation: readonly NavigationItem[];
|
|
24
|
-
navigationGroups?: readonly NavigationGroup[];
|
|
25
15
|
settingsItem?: NavigationItem;
|
|
26
16
|
active: string;
|
|
27
17
|
title: string;
|
|
@@ -39,5 +29,8 @@ export interface AppShellProps {
|
|
|
39
29
|
homePath?: string;
|
|
40
30
|
basePath?: string;
|
|
41
31
|
showHeader?: boolean;
|
|
32
|
+
expandedIds?: readonly string[];
|
|
33
|
+
defaultExpandedIds?: readonly string[];
|
|
34
|
+
onExpandedChange?(ids: string[]): void;
|
|
42
35
|
}
|
|
43
|
-
export declare function AppShell({ navigation,
|
|
36
|
+
export declare function AppShell({ navigation, settingsItem, active, title, collapsed, onCollapsedChange, onNavigate, children, headerActions, sidebarFooter, windowControls, draggable, brandName, brandIcon, brand, homePath, basePath, showHeader, expandedIds, defaultExpandedIds, onExpandedChange, }: AppShellProps): import("react").JSX.Element;
|
package/components/AppShell.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { Layers2, Menu, PanelLeftClose, PanelLeftOpen } from "lucide-react";
|
|
8
8
|
import { Drawer } from "./Drawer.js";
|
|
9
9
|
import { IconButton } from "./IconButton.js";
|
|
10
|
+
import { SidebarNavigation } from "./SidebarNavigation.js";
|
|
10
11
|
import s from "./AppShell.module.css";
|
|
11
12
|
function ShellHeader({
|
|
12
13
|
title,
|
|
@@ -57,7 +58,6 @@ function ShellHeader({
|
|
|
57
58
|
}
|
|
58
59
|
function AppShell({
|
|
59
60
|
navigation,
|
|
60
|
-
navigationGroups,
|
|
61
61
|
settingsItem,
|
|
62
62
|
active,
|
|
63
63
|
title,
|
|
@@ -74,9 +74,18 @@ function AppShell({
|
|
|
74
74
|
brand,
|
|
75
75
|
homePath = "/",
|
|
76
76
|
basePath = "",
|
|
77
|
-
showHeader = true
|
|
77
|
+
showHeader = true,
|
|
78
|
+
expandedIds,
|
|
79
|
+
defaultExpandedIds = [],
|
|
80
|
+
onExpandedChange
|
|
78
81
|
}) {
|
|
79
82
|
const [mobile, setMobile] = useState(false);
|
|
83
|
+
const [internalExpanded, setInternalExpanded] = useState(defaultExpandedIds);
|
|
84
|
+
const expanded = expandedIds ?? internalExpanded;
|
|
85
|
+
const expand = (ids) => {
|
|
86
|
+
if (expandedIds === void 0) setInternalExpanded(ids);
|
|
87
|
+
onExpandedChange?.(ids);
|
|
88
|
+
};
|
|
80
89
|
const scroll = useRef(null);
|
|
81
90
|
const base = basePath.replace(/^\/+|\/+$/g, ""), href = (path) => (base ? "/" + base : "") + (path.startsWith("/") ? path : "/" + path);
|
|
82
91
|
const navigate = (event, path) => {
|
|
@@ -104,7 +113,7 @@ function AppShell({
|
|
|
104
113
|
},
|
|
105
114
|
n.id
|
|
106
115
|
);
|
|
107
|
-
const nav = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
116
|
+
const nav = (compact) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
108
117
|
/* @__PURE__ */ jsx(
|
|
109
118
|
"a",
|
|
110
119
|
{
|
|
@@ -118,19 +127,21 @@ function AppShell({
|
|
|
118
127
|
] })
|
|
119
128
|
}
|
|
120
129
|
),
|
|
121
|
-
/* @__PURE__ */ jsx("nav", { "aria-label": "\u4E3B\u5BFC\u822A", className: s.navigation, children:
|
|
122
|
-
|
|
130
|
+
/* @__PURE__ */ jsx("nav", { "aria-label": "\u4E3B\u5BFC\u822A", className: s.navigation, children: /* @__PURE__ */ jsx(
|
|
131
|
+
SidebarNavigation,
|
|
123
132
|
{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
items: navigation,
|
|
134
|
+
active,
|
|
135
|
+
basePath,
|
|
136
|
+
compact,
|
|
137
|
+
expandedIds: expanded,
|
|
138
|
+
onExpandedChange: expand,
|
|
139
|
+
onNavigate: (path) => {
|
|
140
|
+
onNavigate(path);
|
|
141
|
+
setMobile(false);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
) }),
|
|
134
145
|
(settingsItem || sidebarFooter) && /* @__PURE__ */ jsxs("div", { className: s.bottom, children: [
|
|
135
146
|
settingsItem && /* @__PURE__ */ jsx("nav", { "aria-label": "\u8BBE\u7F6E", className: s.navigation, children: item(settingsItem) }),
|
|
136
147
|
sidebarFooter
|
|
@@ -144,7 +155,7 @@ function AppShell({
|
|
|
144
155
|
"data-header": showHeader,
|
|
145
156
|
children: [
|
|
146
157
|
/* @__PURE__ */ jsx("a", { className: s.skip, href: "#main", children: "\u8DF3\u8F6C\u5230\u5185\u5BB9" }),
|
|
147
|
-
/* @__PURE__ */ jsx("aside", { className: s.sidebar, children: nav }),
|
|
158
|
+
/* @__PURE__ */ jsx("aside", { className: s.sidebar, children: nav(collapsed) }),
|
|
148
159
|
/* @__PURE__ */ jsx(
|
|
149
160
|
Drawer,
|
|
150
161
|
{
|
|
@@ -153,7 +164,7 @@ function AppShell({
|
|
|
153
164
|
open: mobile,
|
|
154
165
|
onClose: () => setMobile(false),
|
|
155
166
|
title: "\u5BFC\u822A",
|
|
156
|
-
children: /* @__PURE__ */ jsx("div", { className: s.mobileNav, children: nav })
|
|
167
|
+
children: /* @__PURE__ */ jsx("div", { className: s.mobileNav, children: nav(false) })
|
|
157
168
|
}
|
|
158
169
|
),
|
|
159
170
|
/* @__PURE__ */ jsxs("div", { className: s.workspace, children: [
|