@robert-stackflow/oneui 0.6.17 → 0.6.18

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,3 +1,7 @@
1
+ # 0.6.18
2
+
3
+ - Add Menu iconOnly triggers backed by the shared IconButton, preserving tooltip, focus restoration and keyboard menu interaction without a normal button border or minimum height.
4
+
1
5
  # 0.6.17
2
6
 
3
7
  - Prevent the animated SideBar selection highlight from expanding scrollable overflow while a preceding group collapses; preserve group and selection motion in both themes and color modes.
package/README.md CHANGED
@@ -253,3 +253,5 @@ AccountItem 接受标题、图标、描述、元数据及操作。PasskeyItem
253
253
  扩展 Menu 的自定义触发内容、NumberInput 单位、Pagination 汇总显隐、Badge 原生属性、Tooltip 禁用选项及 Button 文字链接。修复日历月份标签碰撞和宽度适配,表格容器继承外框圆角。既有导出与默认 API 保持兼容。
254
254
 
255
255
  验证:`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 键盘筛选、日期标签和窄屏溢出。
256
+
257
+ Menu 支持 iconOnly:`<Menu iconOnly label="更多操作" items={items} />` 复用 IconButton,默认显示更多图标;trigger 可替换图标,variant 可设置按钮类型。
@@ -1,9 +1,10 @@
1
1
  import { type ReactNode } from "react";
2
- export declare function Menu({ label, items, trigger, variant, className, }: {
2
+ export declare function Menu({ label, items, trigger, variant, className, iconOnly, }: {
3
3
  label: string;
4
4
  trigger?: ReactNode;
5
5
  variant?: "primary" | "secondary" | "ghost" | "danger";
6
6
  className?: string;
7
+ iconOnly?: boolean;
7
8
  items: {
8
9
  label: string;
9
10
  icon?: ReactNode;
@@ -1,7 +1,8 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useId } from "react";
3
- import { ChevronDown } from "lucide-react";
3
+ import { ChevronDown, MoreHorizontal } from "lucide-react";
4
4
  import { Button } from "./Button.js";
5
+ import { IconButton } from "./IconButton.js";
5
6
  import { MenuItem } from "./MenuItem.js";
6
7
  import { Popover } from "./Popover.js";
7
8
  import { usePopover } from "./usePopover.js";
@@ -9,34 +10,32 @@ function Menu({
9
10
  label,
10
11
  items,
11
12
  trigger,
12
- variant = "secondary",
13
- className
13
+ variant,
14
+ className,
15
+ iconOnly = false
14
16
  }) {
15
17
  const pop = usePopover(), id = useId();
16
- return /* @__PURE__ */ jsxs(Fragment, { children: [
17
- /* @__PURE__ */ jsx(
18
- Button,
19
- {
20
- variant,
21
- className,
22
- "aria-label": label,
23
- ref: pop.anchor,
24
- "aria-haspopup": "menu",
25
- "aria-expanded": pop.open,
26
- "aria-controls": id,
27
- onClick: pop.toggle,
28
- onKeyDown: (event) => {
29
- if (event.key === "ArrowDown" || event.key === "ArrowUp") {
30
- event.preventDefault();
31
- pop.show();
32
- }
33
- },
34
- children: trigger ?? /* @__PURE__ */ jsxs(Fragment, { children: [
35
- label,
36
- /* @__PURE__ */ jsx(ChevronDown, { size: 14 })
37
- ] })
18
+ const triggerProps = {
19
+ variant: variant ?? (iconOnly ? "ghost" : "secondary"),
20
+ className,
21
+ "aria-label": label,
22
+ ref: pop.anchor,
23
+ "aria-haspopup": "menu",
24
+ "aria-expanded": pop.open,
25
+ "aria-controls": id,
26
+ onClick: pop.toggle,
27
+ onKeyDown: (event) => {
28
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
29
+ event.preventDefault();
30
+ pop.show();
38
31
  }
39
- ),
32
+ }
33
+ };
34
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
35
+ iconOnly ? /* @__PURE__ */ jsx(IconButton, { ...triggerProps, label, children: trigger ?? /* @__PURE__ */ jsx(MoreHorizontal, { size: 18 }) }) : /* @__PURE__ */ jsx(Button, { ...triggerProps, children: trigger ?? /* @__PURE__ */ jsxs(Fragment, { children: [
36
+ label,
37
+ /* @__PURE__ */ jsx(ChevronDown, { size: 14 })
38
+ ] }) }),
40
39
  /* @__PURE__ */ jsx(
41
40
  Popover,
42
41
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robert-stackflow/oneui",
3
- "version": "0.6.17",
3
+ "version": "0.6.18",
4
4
  "description": "OneUI React components, application shell and portable visual themes",
5
5
  "type": "module",
6
6
  "sideEffects": [