@robert-stackflow/oneui 0.6.0 → 0.6.2

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 CHANGED
@@ -1,57 +1,83 @@
1
- # Changelog
2
-
3
- ## 0.5.0 — 2026-10-29
4
-
5
- - 新增 ActionSheet,复用 IconButton、Drawer 和 MenuItem;桌面使用紧凑底部面板,手机适配底部安全区域,支持禁用和危险操作。
6
- - Drawer 新增 `onAfterClose`,在关闭动画与焦点恢复完成后执行后续操作,避免操作面板与新弹窗重叠。
7
- - 横向 FormField 包含多行输入时,标签靠上对齐;单行控件和手机纵向布局保持原有排列。
8
-
9
- ## 0.4.2 — 2026-10-29
10
-
11
- - 图标、Emoji 和符号目录改用可被构建工具识别的异步 JSON 导入,修复 npm 包在 Vite 开发预打包后资源相对路径失效的问题;生产构建继续按需加载。
12
- - Card 新增 `description` 与无正文模式,标题和正文使用一致的横向间距,避免只含概览和操作时产生空白正文。
13
- - 独立 tarball 消费测试增加开发模式预打包下的三套完整目录加载验证。
14
-
15
- ## 0.4.1 — 2026-10-29
16
-
17
- - Dialog、Drawer 统一处理普通关闭和条件卸载后的焦点恢复,兼容 StrictMode、嵌套与替换弹窗,不抢夺其他弹窗的焦点。
18
- - 新增 `returnFocus` 引用,可为异步打开的弹窗明确指定关闭后返回的控件。
19
- - 修复 FormField 在卸载失焦时访问已清空引用的运行错误,避免 StrictMode 模拟清理触发额外失焦。
20
- - Pagination 新增 `compact`、`size="small"` 和 `className`;紧凑排列、尺寸及窄屏换行由组件管理,宿主不再依赖内部 DOM 覆盖样式。
21
- - 增加独立构建包的双主题、深浅色、1280/390/320px 焦点和分页交互验证。
22
-
23
- ## 0.4.0 — 2026-10-29
24
-
25
- - 新增 AccountItem、PasskeyItem、SessionItem,统一账户设备列表的图标、元数据、操作按钮和移动布局;业务与日期格式由宿主负责。
26
- - Form、FormGroup、FormField 支持 stacked / inline 两种排版,继承布局并可逐字段覆盖;窄屏自动改为上下排列。
27
- - 修复 FormField 空标签占位造成的控件垂直错位,RadioGroup 在 FormField 中不再重复显示标签。
28
- - NumberInput 新增 nullable 模式,清空返回 null,保留小数、范围、键盘与只读行为。
29
- - Dialog 在关闭动画期间保留最终内容,避免宿主清空选择时先显示空弹窗。
30
- - 两端共享示例新增设置表单与账户设备项目。
31
-
32
- ## 0.3.0 — 2026-10-28
33
-
34
- - AppShell 新增 brandName、brandIcon、brand、homePath、basePath 和 showHeader;支持无顶部栏的移动导航,可省略设置入口及侧栏折叠回调。普通点击向宿主传递内部路径,链接和新标签页使用完整基础路径。
35
- - 新增 createToaster 独立通知控制器,可由 React 组件外代码调用;ToastProvider 可接收 controller,保留原 useToast API 和单条通知替换行为。
36
- - IconPicker 支持 valuePrefix、自定义图标目录与 React 图标内容,保留存储 ID;统一字段、只读、禁用和表单值行为。
37
- - DatePicker 支持 timeZone、clearable、placeholder;指定时区影响今天/此刻及日历当天标记,输入的日历时间保持原值,不隐式转换为 UTC。
38
- - React/React DOM peer 范围调整为 ^19.2.0,独立消费验证覆盖 React 19.3.0 + TypeScript 5.9.3 和现有 React 19.3.1。
39
- - 两端示例增加前缀/自定义图标和指定时区日期示例;未迁移或修改 Moment 业务代码。
40
- - 修复极简深色导航选中文字过暗的问题。
41
-
42
- ## 0.2.0 — 2026-10-28
43
-
44
- - 新增 MessageDialog、ConfirmDialog、FormDialog 与统一 LoadingState,复用表单校验、异步提交、错误反馈和焦点管理。
45
- - TreeSelect 新增 category 图标、数量、层级连线样式;保留 tree 风格,支持父子联动多选。
46
- - 新增 TreeTable,复用 Table 列定义,支持受控展开、多级连线和键盘导航;列支持 align、width。
47
- - Combobox 新增 mode="input" 触发框补全;保留弹层搜索,支持异步加载、取消、创建与失败重试。
48
- - MultiSelect 新增 display="tags",与 TagInput 共用标签实现;保留摘要模式及选择限制。
49
- - 蓝白主题采用 Moment 对应色板、输入 hover 混色和深色参数;修复默认色板迁移与选择器分类栏底色。
50
- - 统一菜单项 1px 间距,修复快捷键右对齐、宿主 kbd 边框干扰、关闭的 Popover 被布局样式显示等问题。
51
- - 树选择器底部清空/完成操作使用独立的 8px 按钮间距。
52
- - 共享应用外壳与示例布局统一,修复图标尺寸、链接文字、动效示例、表单间距、弹层和移动布局。
53
- - 发布构建使用干净输出并检查包内引用;增加独立 tarball 消费项目的类型、生产与交互验证。
54
-
55
- ## 0.1.0 — 2026-10-28
56
-
57
- - 首次发布 React 组件、应用外壳、极简/蓝白主题与图标字符资源。
1
+ # Changelog
2
+
3
+ ## 0.6.2 — 2026-10-29
4
+
5
+ - Text 与 Heading 的多行省略明确恢复正常换行,避免继承表格的 nowrap 后长文本撑开列宽。
6
+ - 增加浅色、深色及窄屏下表格内两行截断的回归验证。
7
+
8
+ ## 0.6.1 — 2026-10-29
9
+
10
+ - 在 0.5.2 基础上保留可创建多选、分组导航及可选页面标题;新增嵌套侧栏、资源卡片、登录布局和页面标题组合。
11
+ - 复用现有 Card/Table 样式,提供布局基础组件、TableMarkup、CopyButton 与 BarChart;普通选择与可搜索选择分别沿用现有 Select/Combobox。
12
+ - Menu 支持自定义触发内容,NumberInput 支持单位,Button 支持文字链接;修复日历月份标签碰撞及表格圆角继承。
13
+ - 保留现有公开接口,并验证独立包消费、账户表单、弹窗、分组/嵌套导航及窄屏视觉基础。
14
+
15
+ ## 0.6.0 — 2026-10-29
16
+
17
+ - 发布了较早的组合组件候选;0.6.1 补齐 0.5.1 分组导航、多选创建及 0.5.2 CSS Modules 动画兼容修复。请使用 0.6.1。
18
+
19
+ ## 0.5.2 — 2026-10-29
20
+
21
+ - 将 Page、Dialog、Drawer、Button 的动画关键帧放回各自 CSS Module。
22
+
23
+ ## 0.5.1 — 2026-10-29
24
+
25
+ - MultiSelect 新增 `onCreate`,标签模式在同一触发框内展示已选项,支持搜索创建、连续多选、错误重试,以及关闭后忽略异步创建结果。
26
+ - Page 支持可选 ReactNode 标题,可为无标题的内容区复用共享入场动画。
27
+ - AppShell 新增 `navigationGroups`,桌面侧栏与移动导航共享分组和分隔布局;保留原有扁平导航 API。
28
+
29
+ ## 0.5.0 — 2026-10-29
30
+
31
+ - 新增 ActionSheet,复用 IconButton、Drawer 和 MenuItem;桌面使用紧凑底部面板,手机适配底部安全区域,支持禁用和危险操作。
32
+ - Drawer 新增 `onAfterClose`,在关闭动画与焦点恢复完成后执行后续操作,避免操作面板与新弹窗重叠。
33
+ - 横向 FormField 包含多行输入时,标签靠上对齐;单行控件和手机纵向布局保持原有排列。
34
+
35
+ ## 0.4.2 — 2026-10-29
36
+
37
+ - 图标、Emoji 和符号目录改用可被构建工具识别的异步 JSON 导入,修复 npm 包在 Vite 开发预打包后资源相对路径失效的问题;生产构建继续按需加载。
38
+ - Card 新增 `description` 与无正文模式,标题和正文使用一致的横向间距,避免只含概览和操作时产生空白正文。
39
+ - 独立 tarball 消费测试增加开发模式预打包下的三套完整目录加载验证。
40
+
41
+ ## 0.4.1 — 2026-10-29
42
+
43
+ - Dialog、Drawer 统一处理普通关闭和条件卸载后的焦点恢复,兼容 StrictMode、嵌套与替换弹窗,不抢夺其他弹窗的焦点。
44
+ - 新增 `returnFocus` 引用,可为异步打开的弹窗明确指定关闭后返回的控件。
45
+ - 修复 FormField 在卸载失焦时访问已清空引用的运行错误,避免 StrictMode 模拟清理触发额外失焦。
46
+ - Pagination 新增 `compact`、`size="small"` 和 `className`;紧凑排列、尺寸及窄屏换行由组件管理,宿主不再依赖内部 DOM 覆盖样式。
47
+ - 增加独立构建包的双主题、深浅色、1280/390/320px 焦点和分页交互验证。
48
+
49
+ ## 0.4.0 — 2026-10-29
50
+
51
+ - 新增 AccountItem、PasskeyItem、SessionItem,统一账户设备列表的图标、元数据、操作按钮和移动布局;业务与日期格式由宿主负责。
52
+ - Form、FormGroup、FormField 支持 stacked / inline 两种排版,继承布局并可逐字段覆盖;窄屏自动改为上下排列。
53
+ - 修复 FormField 空标签占位造成的控件垂直错位,RadioGroup 在 FormField 中不再重复显示标签。
54
+ - NumberInput 新增 nullable 模式,清空返回 null,保留小数、范围、键盘与只读行为。
55
+ - Dialog 在关闭动画期间保留最终内容,避免宿主清空选择时先显示空弹窗。
56
+ - 两端共享示例新增设置表单与账户设备项目。
57
+
58
+ ## 0.3.0 — 2026-10-28
59
+
60
+ - AppShell 新增 brandName、brandIcon、brand、homePath、basePath 和 showHeader;支持无顶部栏的移动导航,可省略设置入口及侧栏折叠回调。普通点击向宿主传递内部路径,链接和新标签页使用完整基础路径。
61
+ - 新增 createToaster 独立通知控制器,可由 React 组件外代码调用;ToastProvider 可接收 controller,保留原 useToast API 和单条通知替换行为。
62
+ - IconPicker 支持 valuePrefix、自定义图标目录与 React 图标内容,保留存储 ID;统一字段、只读、禁用和表单值行为。
63
+ - DatePicker 支持 timeZone、clearable、placeholder;指定时区影响今天/此刻及日历当天标记,输入的日历时间保持原值,不隐式转换为 UTC。
64
+ - React/React DOM peer 范围调整为 ^19.2.0,独立消费验证覆盖 React 19.3.0 + TypeScript 5.9.3 和现有 React 19.3.1。
65
+ - 两端示例增加前缀/自定义图标和指定时区日期示例;未迁移或修改 Moment 业务代码。
66
+ - 修复极简深色导航选中文字过暗的问题。
67
+
68
+ ## 0.2.0 — 2026-10-28
69
+
70
+ - 新增 MessageDialog、ConfirmDialog、FormDialog 与统一 LoadingState,复用表单校验、异步提交、错误反馈和焦点管理。
71
+ - TreeSelect 新增 category 图标、数量、层级连线样式;保留 tree 风格,支持父子联动多选。
72
+ - 新增 TreeTable,复用 Table 列定义,支持受控展开、多级连线和键盘导航;列支持 align、width。
73
+ - Combobox 新增 mode="input" 触发框补全;保留弹层搜索,支持异步加载、取消、创建与失败重试。
74
+ - MultiSelect 新增 display="tags",与 TagInput 共用标签实现;保留摘要模式及选择限制。
75
+ - 蓝白主题采用 Moment 对应色板、输入 hover 混色和深色参数;修复默认色板迁移与选择器分类栏底色。
76
+ - 统一菜单项 1px 间距,修复快捷键右对齐、宿主 kbd 边框干扰、关闭的 Popover 被布局样式显示等问题。
77
+ - 树选择器底部清空/完成操作使用独立的 8px 按钮间距。
78
+ - 共享应用外壳与示例布局统一,修复图标尺寸、链接文字、动效示例、表单间距、弹层和移动布局。
79
+ - 发布构建使用干净输出并检查包内引用;增加独立 tarball 消费项目的类型、生产与交互验证。
80
+
81
+ ## 0.1.0 — 2026-10-28
82
+
83
+ - 首次发布 React 组件、应用外壳、极简/蓝白主题与图标字符资源。
package/README.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  React 组件、应用外壳和两套可互换的主题。无 Electron、React Router、账户 API 或持久化存储依赖。
4
4
 
5
+ ## 标签创建与导航分组(0.5.1)
6
+
7
+ `MultiSelect display="tags"` 将可移除标签放在同一个触发框内;可选 `onCreate(label)` 返回新选项值(支持 Promise)。搜索结果中显示创建入口,成功后连续多选;错误可重试,关闭或卸载后不再应用异步结果。原有摘要模式和静态选项用法保持兼容。
8
+
9
+ ```tsx
10
+ <MultiSelect label="标签" display="tags" value={tags} options={options}
11
+ onChange={setTags} onCreate={name => name} />
12
+ ```
13
+
14
+ `AppShell.navigationGroups` 支持 `{id, label?, items}` 分组,主导航、标签或其他入口共享分隔与标题样式,桌面与移动抽屉一致;不传时沿用 `navigation`。`Page.title` 可省略或传 ReactNode,可在无标题内容区复用共享入场动画。
15
+
5
16
  ## 操作面板(0.5.0)
6
17
 
7
18
  `ActionSheet` 使用带无障碍名称的更多图标按钮打开底部操作面板;`items` 支持 `label`、`icon`、`disabled`、`danger` 和 `action`。选择后先完成关闭和焦点恢复,再执行操作,可安全打开另一个弹窗。桌面为紧凑面板,手机贴合底部安全区域。
@@ -167,3 +178,11 @@ Form / FormGroup / FormField 的 `layout` 支持 `stacked`(默认)与 `inlin
167
178
  NumberInput 使用 `nullable value={numberOrNull} onChange={setValue}` 允许留空,清空并提交时返回 null;默认数字 API 保持不变。
168
179
 
169
180
  AccountItem 接受标题、图标、描述、元数据及操作。PasskeyItem 和 SessionItem 封装通行密钥及登录会话布局,回调只通知宿主操作;不依赖账户接口或日期格式。
181
+
182
+ ## 0.6.0 应用组合
183
+
184
+ 新增嵌套 SidebarNavigation、ResourceCard、AuthLayout、PageHeading、TableMarkup、布局与文本基础组件、CopyButton 和 BarChart。Surface 复用 Card 的样式,TableMarkup 复用 Table 的样式,页面标题复用 Page。普通下拉继续使用 Select;带搜索的选择直接使用既有 Combobox,搜索栏使用 SearchField;数据概览使用 Statistic,键值详情使用 Descriptions,不增加另一套选择或统计样式。
185
+
186
+ 扩展 Menu 的自定义触发内容、NumberInput 单位、Pagination 汇总显隐、Badge 原生属性、Tooltip 禁用选项及 Button 文字链接。修复日历月份标签碰撞和宽度适配,表格容器继承外框圆角。既有导出与默认 API 保持兼容。
187
+
188
+ 验证:`npm run test:sidebar-navigation`、`npm run test:visual-foundations`、`npm run test:account-forms`、`npm run test:modal-pagination`、`npm run test:package`。新增回归覆盖 React 间距覆盖、正文颜色、表格圆角与文字按钮、现有 Combobox 键盘筛选、日期标签和窄屏溢出。
@@ -10,8 +10,14 @@ export declare function ShellHeader({ title, collapsed, onToggle, onMenu, action
10
10
  windowControls?: ReactNode;
11
11
  draggable?: boolean;
12
12
  }): import("react").JSX.Element;
13
+ export interface NavigationGroup {
14
+ id: string;
15
+ label?: string;
16
+ items: readonly NavigationItem[];
17
+ }
13
18
  export interface AppShellProps {
14
19
  navigation: readonly NavigationItem[];
20
+ navigationGroups?: readonly NavigationGroup[];
15
21
  settingsItem?: NavigationItem;
16
22
  active: string;
17
23
  title: string;
@@ -33,4 +39,4 @@ export interface AppShellProps {
33
39
  defaultExpandedIds?: readonly string[];
34
40
  onExpandedChange?(ids: string[]): void;
35
41
  }
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;
42
+ export declare function AppShell({ navigation, navigationGroups, 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;
@@ -58,6 +58,7 @@ function ShellHeader({
58
58
  }
59
59
  function AppShell({
60
60
  navigation,
61
+ navigationGroups,
61
62
  settingsItem,
62
63
  active,
63
64
  title,
@@ -113,6 +114,21 @@ function AppShell({
113
114
  },
114
115
  n.id
115
116
  );
117
+ const tree = (items, compact) => /* @__PURE__ */ jsx(
118
+ SidebarNavigation,
119
+ {
120
+ items,
121
+ active,
122
+ basePath,
123
+ compact,
124
+ expandedIds: expanded,
125
+ onExpandedChange: expand,
126
+ onNavigate: (path) => {
127
+ onNavigate(path);
128
+ setMobile(false);
129
+ }
130
+ }
131
+ );
116
132
  const nav = (compact) => /* @__PURE__ */ jsxs(Fragment, { children: [
117
133
  /* @__PURE__ */ jsx(
118
134
  "a",
@@ -127,21 +143,19 @@ function AppShell({
127
143
  ] })
128
144
  }
129
145
  ),
130
- /* @__PURE__ */ jsx("nav", { "aria-label": "\u4E3B\u5BFC\u822A", className: s.navigation, children: /* @__PURE__ */ jsx(
131
- SidebarNavigation,
146
+ /* @__PURE__ */ jsx("nav", { "aria-label": "\u4E3B\u5BFC\u822A", className: s.navigation, children: navigationGroups ? navigationGroups.map((group) => /* @__PURE__ */ jsxs(
147
+ "div",
132
148
  {
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
- ) }),
149
+ className: s.navigationGroup,
150
+ role: "group",
151
+ "aria-label": group.label,
152
+ children: [
153
+ group.label && /* @__PURE__ */ jsx("div", { className: s.groupLabel, children: group.label }),
154
+ tree(group.items, compact)
155
+ ]
156
+ },
157
+ group.id
158
+ )) : tree(navigation, compact) }),
145
159
  (settingsItem || sidebarFooter) && /* @__PURE__ */ jsxs("div", { className: s.bottom, children: [
146
160
  settingsItem && /* @__PURE__ */ jsx("nav", { "aria-label": "\u8BBE\u7F6E", className: s.navigation, children: item(settingsItem) }),
147
161
  sidebarFooter
@@ -249,3 +249,23 @@
249
249
  .header[data-window-controls="true"] {
250
250
  padding-right: 8px;
251
251
  }
252
+
253
+ .navigationGroup {
254
+ display: flex;
255
+ flex-direction: column;
256
+ gap: 4px;
257
+ }
258
+ .navigationGroup + .navigationGroup {
259
+ margin-top: 18px;
260
+ padding-top: 18px;
261
+ border-top: 1px solid var(--line);
262
+ }
263
+ .groupLabel {
264
+ color: var(--muted);
265
+ font-size: 11px;
266
+ padding: 0 12px 6px;
267
+ }
268
+
269
+ .shell[data-collapsed="true"] > .sidebar .groupLabel {
270
+ display: none;
271
+ }
@@ -57,9 +57,29 @@
57
57
  padding: 4px 9px;
58
58
  font-size: 11px;
59
59
  }
60
- .link {min-height:0;padding:0;border:0;border-radius:2px;background:transparent;box-shadow:none;color:var(--accent);font-size:13px;line-height:1.6;text-align:left;justify-content:flex-start;white-space:normal;}
61
- .link:hover:not(:disabled):not([aria-disabled="true"]) {background:transparent;color:var(--accent-hover,var(--accent));text-decoration:underline;text-underline-offset:3px;}
62
- .link .content {justify-content:flex-start;}
60
+ .link {
61
+ min-height: 0;
62
+ padding: 0;
63
+ border: 0;
64
+ border-radius: 2px;
65
+ background: transparent;
66
+ box-shadow: none;
67
+ color: var(--accent);
68
+ font-size: 13px;
69
+ line-height: 1.6;
70
+ text-align: left;
71
+ justify-content: flex-start;
72
+ white-space: normal;
73
+ }
74
+ .link:hover:not(:disabled):not([aria-disabled="true"]) {
75
+ background: transparent;
76
+ color: var(--accent-hover, var(--accent));
77
+ text-decoration: underline;
78
+ text-underline-offset: 3px;
79
+ }
80
+ .link .content {
81
+ justify-content: flex-start;
82
+ }
63
83
  .spin {
64
84
  animation: spin 1s linear infinite;
65
85
  }
@@ -89,3 +109,9 @@
89
109
  height: var(--button-icon-size, 16px);
90
110
  flex-shrink: 0;
91
111
  }
112
+
113
+ @keyframes spin {
114
+ to {
115
+ transform: rotate(360deg);
116
+ }
117
+ }
@@ -106,7 +106,10 @@ function ContributionCalendar({
106
106
  "div",
107
107
  {
108
108
  className: s.calendar,
109
- style: { "--calendar-color": color, "--calendar-weeks": model.weeks },
109
+ style: {
110
+ "--calendar-color": color,
111
+ "--calendar-weeks": model.weeks
112
+ },
110
113
  children: [
111
114
  /* @__PURE__ */ jsxs("header", { className: s.header, children: [
112
115
  /* @__PURE__ */ jsx("h3", { children: label }),
@@ -127,7 +130,9 @@ function ContributionCalendar({
127
130
  "aria-hidden": "true",
128
131
  children: [
129
132
  /* @__PURE__ */ jsx("span", {}),
130
- model.months.filter((month, index, months) => !months[index + 1] || months[index + 1].column - month.column >= 2).map((month) => /* @__PURE__ */ jsxs("span", { style: { gridColumn: month.column + 2 }, children: [
133
+ model.months.filter(
134
+ (month, index, months) => !months[index + 1] || months[index + 1].column - month.column >= 2
135
+ ).map((month) => /* @__PURE__ */ jsxs("span", { style: { gridColumn: month.column + 2 }, children: [
131
136
  month.month,
132
137
  "\u6708"
133
138
  ] }, month.key))
@@ -24,7 +24,11 @@
24
24
  color: var(--muted);
25
25
  }
26
26
  .scroll {
27
- --calendar-cell: clamp(9px, calc((100cqw - 32px) / var(--calendar-weeks) - var(--calendar-gap)), 13px);
27
+ --calendar-cell: clamp(
28
+ 9px,
29
+ calc((100cqw - 32px) / var(--calendar-weeks) - var(--calendar-gap)),
30
+ 13px
31
+ );
28
32
  overflow: auto;
29
33
  padding: 3px 2px 6px;
30
34
  }
@@ -86,3 +86,12 @@
86
86
  padding: 14px 18px;
87
87
  }
88
88
  }
89
+
90
+ @keyframes fade-in {
91
+ from {
92
+ opacity: 0;
93
+ }
94
+ to {
95
+ opacity: 1;
96
+ }
97
+ }
@@ -107,3 +107,12 @@
107
107
  padding: 12px 16px;
108
108
  }
109
109
  }
110
+
111
+ @keyframes fade-in {
112
+ from {
113
+ opacity: 0;
114
+ }
115
+ to {
116
+ opacity: 1;
117
+ }
118
+ }
@@ -171,6 +171,7 @@ function Text({
171
171
  display: "-webkit-box",
172
172
  WebkitLineClamp: lineClamp,
173
173
  WebkitBoxOrient: "vertical",
174
+ whiteSpace: "normal",
174
175
  overflow: "hidden"
175
176
  } : {},
176
177
  ...props.style
@@ -196,6 +197,7 @@ function Heading({
196
197
  display: "-webkit-box",
197
198
  WebkitLineClamp: lineClamp,
198
199
  WebkitBoxOrient: "vertical",
200
+ whiteSpace: "normal",
199
201
  overflow: "hidden"
200
202
  } : {},
201
203
  ...props.style
@@ -62,5 +62,21 @@
62
62
  overflow: auto;
63
63
  min-width: 0;
64
64
  }
65
- .interactive { text-decoration:none;color:inherit;transition:border-color var(--motion-hover),background var(--motion-hover); }.interactive:hover {border-color:var(--accent);background:var(--field);}
66
- .mark { background:var(--selected);color:var(--fg);border-radius:3px;padding:0 1px;font-weight:600; }
65
+ .interactive {
66
+ text-decoration: none;
67
+ color: inherit;
68
+ transition:
69
+ border-color var(--motion-hover),
70
+ background var(--motion-hover);
71
+ }
72
+ .interactive:hover {
73
+ border-color: var(--accent);
74
+ background: var(--field);
75
+ }
76
+ .mark {
77
+ background: var(--selected);
78
+ color: var(--fg);
79
+ border-radius: 3px;
80
+ padding: 0 1px;
81
+ font-weight: 600;
82
+ }
@@ -1,6 +1,6 @@
1
1
  import { type FieldOptions } from "./field";
2
2
  import type { SelectOption } from "./types";
3
- export declare function MultiSelect({ value, onChange, options, label, disabled, readOnly, required, name, id: controlId, error, hint, maxSelected, clearable, placeholder, display, ...aria }: FieldOptions & {
3
+ export declare function MultiSelect({ value, onChange, options, label, disabled, readOnly, required, name, id: controlId, error, hint, maxSelected, clearable, placeholder, display, onCreate, ...aria }: FieldOptions & {
4
4
  value: string[];
5
5
  onChange(value: string[]): void;
6
6
  options: SelectOption[];
@@ -10,4 +10,5 @@ export declare function MultiSelect({ value, onChange, options, label, disabled,
10
10
  clearable?: boolean;
11
11
  placeholder?: string;
12
12
  display?: "summary" | "tags";
13
+ onCreate?(label: string): string | void | Promise<string | void>;
13
14
  }): import("react").JSX.Element;
@@ -4,7 +4,7 @@ import { fieldTriggerProps, useFieldControl } from "./field.js";
4
4
  import { MenuItem } from "./MenuItem.js";
5
5
  import { SelectTrigger } from "./SelectTrigger.js";
6
6
  import { useEffect, useId, useRef, useState } from "react";
7
- import { Search } from "lucide-react";
7
+ import { Plus, Search } from "lucide-react";
8
8
  import { Popover } from "./Popover.js";
9
9
  import { usePopover } from "./usePopover.js";
10
10
  import { Button } from "./Button.js";
@@ -28,6 +28,7 @@ function MultiSelect({
28
28
  clearable = true,
29
29
  placeholder = "\u8BF7\u9009\u62E9",
30
30
  display = "summary",
31
+ onCreate,
31
32
  ...aria
32
33
  }) {
33
34
  const field = useFieldControl({
@@ -43,31 +44,78 @@ function MultiSelect({
43
44
  });
44
45
  const pop = usePopover(
45
46
  field.disabled || field.readOnly
46
- ), [query, setQuery] = useState(""), list = useRef(null), search = useRef(null), id = useId();
47
+ ), [query, setQuery] = useState(""), [created, setCreated] = useState([]), [creating, setCreating] = useState(false), [createError, setCreateError] = useState(""), generation = useRef(0), open = useRef(pop.open), selected = useRef(value), list = useRef(null), search = useRef(null), id = useId();
47
48
  const { disabled: triggerDisabled, ...tagField } = fieldTriggerProps(field);
48
- const reserveIcon = options.some((option) => !!option.icon);
49
- const filtered = options.filter(
49
+ open.current = pop.open;
50
+ selected.current = value;
51
+ const available = [
52
+ ...options,
53
+ ...created.filter(
54
+ (item) => !options.some((option) => option.value === item.value)
55
+ )
56
+ ];
57
+ const reserveIcon = available.some((option) => !!option.icon);
58
+ const filtered = available.filter(
50
59
  (item) => item.label.toLowerCase().includes(query.toLowerCase())
51
60
  );
52
61
  const toggle = (option) => {
53
- if (!field.disabled && !field.readOnly && !option.disabled && (value.includes(option.value) || value.length < maxSelected))
62
+ if (!creating && !field.disabled && !field.readOnly && !option.disabled && (value.includes(option.value) || value.length < maxSelected))
54
63
  onChange(
55
64
  value.includes(option.value) ? value.filter((v) => v !== option.value) : [...value, option.value]
56
65
  );
57
66
  };
67
+ const candidate = query.trim();
68
+ const canCreate = !!onCreate && !!candidate && !available.some(
69
+ (option) => option.label.toLowerCase() === candidate.toLowerCase()
70
+ );
71
+ const create = async () => {
72
+ if (!onCreate || !canCreate || creating || field.disabled || field.readOnly || value.length >= maxSelected)
73
+ return;
74
+ const revision = generation.current;
75
+ setCreating(true);
76
+ setCreateError("");
77
+ try {
78
+ const id2 = await onCreate(candidate) || candidate;
79
+ if (!open.current || revision !== generation.current) return;
80
+ setCreated(
81
+ (previous) => previous.some((option) => option.value === id2) ? previous : [...previous, { value: id2, label: candidate }]
82
+ );
83
+ if (!selected.current.includes(id2)) onChange([...selected.current, id2]);
84
+ setQuery("");
85
+ requestAnimationFrame(() => {
86
+ if (open.current) search.current?.focus();
87
+ });
88
+ } catch (failure) {
89
+ if (open.current && revision === generation.current)
90
+ setCreateError(
91
+ failure instanceof Error ? failure.message : "\u521B\u5EFA\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002"
92
+ );
93
+ } finally {
94
+ if (revision === generation.current) setCreating(false);
95
+ }
96
+ };
97
+ useEffect(
98
+ () => () => {
99
+ generation.current++;
100
+ },
101
+ []
102
+ );
58
103
  useEffect(() => {
104
+ generation.current++;
105
+ setCreating(false);
106
+ setCreateError("");
59
107
  if (pop.open) {
60
108
  setQuery("");
61
109
  search.current?.focus();
62
110
  }
63
111
  }, [pop.open]);
64
112
  const remove = (id2) => {
65
- if (field.disabled || field.readOnly || options.find((option) => option.value === id2)?.disabled)
113
+ if (creating || field.disabled || field.readOnly || available.find((option) => option.value === id2)?.disabled)
66
114
  return;
67
115
  onChange(value.filter((v) => v !== id2));
68
116
  pop.anchor.current?.focus();
69
117
  };
70
- const summary = value.length ? options.filter((item) => value.includes(item.value)).map((item) => item.label).slice(0, 2).join("\u3001") + (value.length > 2 ? ` +${value.length - 2}` : "") : placeholder;
118
+ const summary = value.length ? available.filter((item) => value.includes(item.value)).map((item) => item.label).slice(0, 2).join("\u3001") + (value.length > 2 ? ` +${value.length - 2}` : "") : placeholder;
71
119
  return /* @__PURE__ */ jsxs(Fragment, { children: [
72
120
  display === "tags" ? /* @__PURE__ */ jsxs(Fragment, { children: [
73
121
  /* @__PURE__ */ jsxs(
@@ -100,13 +148,13 @@ function MultiSelect({
100
148
  },
101
149
  children: [
102
150
  value.map((id2) => {
103
- const option = options.find((option2) => option2.value === id2);
151
+ const option = available.find((option2) => option2.value === id2);
104
152
  return /* @__PURE__ */ jsx(
105
153
  SelectionTag,
106
154
  {
107
155
  label: option?.label || id2,
108
156
  icon: option?.icon,
109
- disabled: field.disabled || option?.disabled,
157
+ disabled: field.disabled || creating || option?.disabled,
110
158
  onRemove: field.readOnly ? void 0 : () => remove(id2),
111
159
  removeLabel: "\u79FB\u9664 " + (option?.label || id2)
112
160
  },
@@ -163,7 +211,18 @@ function MultiSelect({
163
211
  "aria-label": `\u641C\u7D22${label}`,
164
212
  placeholder: "\u641C\u7D22\u9009\u9879\u2026",
165
213
  value: query,
166
- onChange: (e) => setQuery(e.target.value)
214
+ disabled: creating,
215
+ onChange: (e) => {
216
+ setQuery(e.target.value);
217
+ setCreateError("");
218
+ },
219
+ onKeyDown: (event) => {
220
+ if (event.key === "Enter" && canCreate) {
221
+ event.preventDefault();
222
+ event.stopPropagation();
223
+ void create();
224
+ }
225
+ }
167
226
  }
168
227
  )
169
228
  ] }),
@@ -188,12 +247,22 @@ function MultiSelect({
188
247
  selection: "checkbox",
189
248
  role: "option",
190
249
  "aria-selected": value.includes(option.value),
191
- disabled: option.disabled || !value.includes(option.value) && value.length >= maxSelected,
250
+ disabled: creating || option.disabled || !value.includes(option.value) && value.length >= maxSelected,
192
251
  onClick: () => toggle(option)
193
252
  },
194
253
  option.value
195
254
  )),
196
- !filtered.length && /* @__PURE__ */ jsx("p", { className: s.noResults, children: "\u6CA1\u6709\u5339\u914D\u7684\u9009\u9879" })
255
+ canCreate && /* @__PURE__ */ jsx(
256
+ MenuItem,
257
+ {
258
+ label: creating ? "\u6B63\u5728\u521B\u5EFA\u2026" : "\u521B\u5EFA\u201C" + candidate + "\u201D",
259
+ icon: /* @__PURE__ */ jsx(Plus, { size: 16 }),
260
+ disabled: creating || value.length >= maxSelected,
261
+ onClick: () => void create()
262
+ }
263
+ ),
264
+ !filtered.length && !canCreate && /* @__PURE__ */ jsx("p", { className: s.noResults, children: "\u6CA1\u6709\u5339\u914D\u7684\u9009\u9879" }),
265
+ createError && /* @__PURE__ */ jsx("p", { className: s.createError, role: "alert", children: createError })
197
266
  ]
198
267
  }
199
268
  ),
@@ -203,7 +272,7 @@ function MultiSelect({
203
272
  {
204
273
  variant: "ghost",
205
274
  size: "small",
206
- disabled: !value.length,
275
+ disabled: creating || !value.length,
207
276
  onClick: () => onChange([]),
208
277
  children: "\u6E05\u7A7A"
209
278
  }
@@ -97,3 +97,9 @@
97
97
  padding: 15px;
98
98
  text-align: center;
99
99
  }
100
+
101
+ .createError {
102
+ color: var(--danger);
103
+ padding: 8px 10px;
104
+ font-size: 12px;
105
+ }
@@ -1,12 +1,12 @@
1
1
  import type { ReactNode } from "react";
2
- export declare function PageHeading({ title, description, actions, titleExtra }: {
3
- title: string;
2
+ export declare function PageHeading({ title, description, actions, titleExtra, }: {
3
+ title?: ReactNode;
4
4
  description?: string;
5
5
  actions?: ReactNode;
6
6
  titleExtra?: ReactNode;
7
- }): import("react").JSX.Element;
7
+ }): import("react").JSX.Element | null;
8
8
  export declare function Page({ title, description, actions, children, }: {
9
- title: string;
9
+ title?: ReactNode;
10
10
  description?: string;
11
11
  actions?: ReactNode;
12
12
  children: ReactNode;
@@ -1,10 +1,16 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import s from "./Page.module.css";
3
- function PageHeading({ title, description, actions, titleExtra }) {
3
+ function PageHeading({
4
+ title,
5
+ description,
6
+ actions,
7
+ titleExtra
8
+ }) {
9
+ if (!title && !description && !actions && !titleExtra) return null;
4
10
  return /* @__PURE__ */ jsxs("header", { className: s.heading, children: [
5
11
  /* @__PURE__ */ jsxs("div", { children: [
6
12
  /* @__PURE__ */ jsxs("div", { className: s.title, children: [
7
- /* @__PURE__ */ jsx("h1", { children: title }),
13
+ title && /* @__PURE__ */ jsx("h1", { children: title }),
8
14
  titleExtra
9
15
  ] }),
10
16
  description && /* @__PURE__ */ jsx("p", { children: description })
@@ -20,7 +20,12 @@
20
20
  display: flex;
21
21
  gap: 8px;
22
22
  }
23
- .title { display:flex; align-items:center; flex-wrap:wrap; gap:12px; }
23
+ .title {
24
+ display: flex;
25
+ align-items: center;
26
+ flex-wrap: wrap;
27
+ gap: 12px;
28
+ }
24
29
 
25
30
  .heading h1 {
26
31
  font-size: var(--page-title-size);
@@ -43,3 +48,14 @@
43
48
  flex-wrap: wrap;
44
49
  }
45
50
  }
51
+
52
+ @keyframes page-enter {
53
+ from {
54
+ opacity: 0;
55
+ translate: 0 5px;
56
+ }
57
+ to {
58
+ opacity: 1;
59
+ translate: 0 0;
60
+ }
61
+ }
@@ -1,6 +1,6 @@
1
1
  import type { MouseEventHandler, ReactNode } from "react";
2
2
  /** A linked resource with a stable heading, status and compact facts. */
3
- export declare function ResourceCard({ title, icon, status, description, subtitle, metadata, href, onClick }: {
3
+ export declare function ResourceCard({ title, icon, status, description, subtitle, metadata, href, onClick, }: {
4
4
  title: string;
5
5
  icon: ReactNode;
6
6
  status?: ReactNode;
@@ -2,7 +2,16 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { ArrowUpRight } from "lucide-react";
3
3
  import card from "./Card.module.css";
4
4
  import s from "./ResourceCard.module.css";
5
- function ResourceCard({ title, icon, status, description, subtitle, metadata, href, onClick }) {
5
+ function ResourceCard({
6
+ title,
7
+ icon,
8
+ status,
9
+ description,
10
+ subtitle,
11
+ metadata,
12
+ href,
13
+ onClick
14
+ }) {
6
15
  return /* @__PURE__ */ jsxs("a", { href, onClick, className: `${card.card} ${s.card}`, children: [
7
16
  /* @__PURE__ */ jsxs("div", { className: s.header, children: [
8
17
  /* @__PURE__ */ jsx("span", { className: s.icon, children: icon }),
@@ -1,13 +1,98 @@
1
- .card {display:flex;flex-direction:column;padding:24px;color:var(--fg);text-decoration:none;transition:border-color var(--motion-hover),box-shadow var(--motion-hover);}
2
- .card:hover {border-color:color-mix(in srgb,var(--accent) 35%,var(--line));box-shadow:var(--shadow);}
3
- .header {display:flex;align-items:center;gap:12px;min-width:0;}
4
- .icon {width:40px;height:40px;flex:none;border-radius:var(--radius);display:grid;place-items:center;background:var(--selected);color:var(--accent);}
5
- .icon svg {width:20px;height:20px;}
6
- .heading {flex:1;min-width:0;}
7
- .heading h3 {font-size:15px;font-weight:600;color:var(--fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
8
- .heading p {font-size:12px;color:var(--muted);margin-top:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
9
- .description {font-size:13px;line-height:1.7;margin:18px 0 0;color:var(--muted);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}
10
- .footer {display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:auto;padding-top:20px;color:var(--muted);}
11
- .facts {display:flex;align-items:center;flex-wrap:wrap;gap:6px 14px;font-size:12px;}
12
- .facts > span + span {padding-left:14px;border-left:1px solid var(--line);}
13
- @media(max-width:600px){.card{padding:18px;}.header{gap:10px;}.facts{gap:6px 10px;}.facts > span + span{padding-left:10px;}}
1
+ .card {
2
+ display: flex;
3
+ flex-direction: column;
4
+ padding: 24px;
5
+ color: var(--fg);
6
+ text-decoration: none;
7
+ transition:
8
+ border-color var(--motion-hover),
9
+ box-shadow var(--motion-hover);
10
+ }
11
+ .card:hover {
12
+ border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
13
+ box-shadow: var(--shadow);
14
+ }
15
+ .header {
16
+ display: flex;
17
+ align-items: center;
18
+ gap: 12px;
19
+ min-width: 0;
20
+ }
21
+ .icon {
22
+ width: 40px;
23
+ height: 40px;
24
+ flex: none;
25
+ border-radius: var(--radius);
26
+ display: grid;
27
+ place-items: center;
28
+ background: var(--selected);
29
+ color: var(--accent);
30
+ }
31
+ .icon svg {
32
+ width: 20px;
33
+ height: 20px;
34
+ }
35
+ .heading {
36
+ flex: 1;
37
+ min-width: 0;
38
+ }
39
+ .heading h3 {
40
+ font-size: 15px;
41
+ font-weight: 600;
42
+ color: var(--fg);
43
+ overflow: hidden;
44
+ text-overflow: ellipsis;
45
+ white-space: nowrap;
46
+ }
47
+ .heading p {
48
+ font-size: 12px;
49
+ color: var(--muted);
50
+ margin-top: 3px;
51
+ overflow: hidden;
52
+ text-overflow: ellipsis;
53
+ white-space: nowrap;
54
+ }
55
+ .description {
56
+ font-size: 13px;
57
+ line-height: 1.7;
58
+ margin: 18px 0 0;
59
+ color: var(--muted);
60
+ display: -webkit-box;
61
+ -webkit-line-clamp: 2;
62
+ -webkit-box-orient: vertical;
63
+ overflow: hidden;
64
+ }
65
+ .footer {
66
+ display: flex;
67
+ align-items: center;
68
+ justify-content: space-between;
69
+ gap: 12px;
70
+ margin-top: auto;
71
+ padding-top: 20px;
72
+ color: var(--muted);
73
+ }
74
+ .facts {
75
+ display: flex;
76
+ align-items: center;
77
+ flex-wrap: wrap;
78
+ gap: 6px 14px;
79
+ font-size: 12px;
80
+ }
81
+ .facts > span + span {
82
+ padding-left: 14px;
83
+ border-left: 1px solid var(--line);
84
+ }
85
+ @media (max-width: 600px) {
86
+ .card {
87
+ padding: 18px;
88
+ }
89
+ .header {
90
+ gap: 10px;
91
+ }
92
+ .facts {
93
+ gap: 6px 10px;
94
+ }
95
+ .facts > span + span {
96
+ padding-left: 10px;
97
+ }
98
+ }
@@ -15,9 +15,15 @@
15
15
  border-radius: 8px;
16
16
  transition: background var(--motion-hover);
17
17
  }
18
- .row:hover { background:var(--hover); }
19
- .row:has(> a[aria-current="page"]) { background:var(--selected); }
20
- .row:has(> .disclosure) > a { padding-right:40px; }
18
+ .row:hover {
19
+ background: var(--hover);
20
+ }
21
+ .row:has(> a[aria-current="page"]) {
22
+ background: var(--selected);
23
+ }
24
+ .row:has(> .disclosure) > a {
25
+ padding-right: 40px;
26
+ }
21
27
  .row > a,
22
28
  .navigationButton {
23
29
  display: flex;
@@ -43,12 +49,16 @@
43
49
  .row > a > svg {
44
50
  flex-shrink: 0;
45
51
  }
46
- .row > a:hover { color:var(--fg); }
52
+ .row > a:hover {
53
+ color: var(--fg);
54
+ }
47
55
  .navigationButton:hover {
48
56
  color: var(--fg);
49
57
  background: var(--hover);
50
58
  }
51
- .row > a[aria-current="page"] { color:var(--navigation-active-color, var(--accent)); }
59
+ .row > a[aria-current="page"] {
60
+ color: var(--navigation-active-color, var(--accent));
61
+ }
52
62
  .navigationButton[aria-current="page"] {
53
63
  color: var(--navigation-active-color, var(--accent));
54
64
  background: var(--selected);
@@ -89,9 +99,20 @@
89
99
  .children {
90
100
  margin: 4px 0 4px 16px;
91
101
  }
92
- .children .row > a {min-height:36px;padding-block:7px;gap:9px;font-size:12px;}
93
- .row > a > svg {width:18px;height:18px;}
94
- .children .row > a > svg {width:16px;height:16px;}
102
+ .children .row > a {
103
+ min-height: 36px;
104
+ padding-block: 7px;
105
+ gap: 9px;
106
+ font-size: 12px;
107
+ }
108
+ .row > a > svg {
109
+ width: 18px;
110
+ height: 18px;
111
+ }
112
+ .children .row > a > svg {
113
+ width: 16px;
114
+ height: 16px;
115
+ }
95
116
  .children[hidden] {
96
117
  display: none;
97
118
  }
@@ -151,7 +151,7 @@ export { ThemeProvider } from "./ThemeProvider";
151
151
  export type { UITheme, ColorMode } from "./ThemeProvider";
152
152
  export { ThemeStylePicker } from "./ThemeStylePicker";
153
153
  export { AppShell, ShellHeader } from "./AppShell";
154
- export type { NavigationItem, AppShellProps } from "./AppShell";
154
+ export type { NavigationItem, NavigationGroup, AppShellProps, } from "./AppShell";
155
155
  export { SidebarNavigation } from "./SidebarNavigation";
156
156
  export type { SidebarNavigationProps } from "./SidebarNavigation";
157
157
  export { SettingsLayout, SettingsCard } from "./SettingsLayout";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robert-stackflow/oneui",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "OneUI React components, application shell and portable visual themes",
5
5
  "type": "module",
6
6
  "sideEffects": [