@robert-stackflow/oneui 0.6.34 → 0.6.35
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 +4 -0
- package/README.md +4 -0
- package/components/IconButton.d.ts +4 -2
- package/components/IconButton.js +15 -10
- package/components/IconButton.module.css +21 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 0.6.35
|
|
2
|
+
|
|
3
|
+
- Add an optional `IconButton text` slot for unified icon/text or count actions, sharing one hover, focus, pressed and click region without application styling. Preserve icon-only and disclosure variants.
|
|
4
|
+
|
|
1
5
|
## 0.6.34
|
|
2
6
|
|
|
3
7
|
- Close Lightbox on empty-space clicks while guarding image/control clicks and drag/pinch gestures. Return visible images with Hero motion; missing, offscreen, zoomed or failed origins fade out gently together with the black canvas.
|
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
React 组件、应用外壳和两套可互换的主题。无 Electron、React Router、账户 API 或持久化存储依赖。
|
|
4
4
|
|
|
5
|
+
## 图文操作按钮(0.6.35)
|
|
6
|
+
|
|
7
|
+
`<IconButton label="点赞 12" text={12}><Heart /></IconButton>` 将图标和文字/数字放在同一个按钮内,共享 hover、键盘焦点、按下与选中区域。`text="回复"` / `text="分享"` 使用相同布局;数字 0 也会显示。不要在按钮外再放计数文字。`label` 是完整可访问名称及提示,`text` 是可见内容;省略 `text` 时保留原图标按钮行为。loading 时文字保留,图标替换为 Spinner。
|
|
8
|
+
|
|
5
9
|
## 密码输入(0.6.29)
|
|
6
10
|
|
|
7
11
|
`PasswordField` 统一提供显示/隐藏密码操作,在 Edge 中隐藏重复的原生显示按钮。应用无需为该输入框覆盖浏览器伪元素样式。
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { ComponentPropsWithRef } from "react";
|
|
2
|
-
export declare function IconButton({ label, loading, children, variant, size, disclosure, ...props }: ComponentPropsWithRef<"button"> & {
|
|
1
|
+
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
export declare function IconButton({ label, loading, children, text, variant, size, disclosure, ...props }: ComponentPropsWithRef<"button"> & {
|
|
3
3
|
label: string;
|
|
4
4
|
loading?: boolean;
|
|
5
|
+
/** Visible text or count inside the same hover, focus and click target as the icon. */
|
|
6
|
+
text?: ReactNode;
|
|
5
7
|
variant?: "primary" | "secondary" | "ghost" | "danger";
|
|
6
8
|
size?: "small" | "normal";
|
|
7
9
|
/** Add a spaced disclosure chevron, driven by aria-expanded. */
|
package/components/IconButton.js
CHANGED
|
@@ -8,12 +8,13 @@ function IconButton({
|
|
|
8
8
|
label,
|
|
9
9
|
loading,
|
|
10
10
|
children,
|
|
11
|
+
text,
|
|
11
12
|
variant = "ghost",
|
|
12
13
|
size = "normal",
|
|
13
14
|
disclosure = false,
|
|
14
15
|
...props
|
|
15
16
|
}) {
|
|
16
|
-
return /* @__PURE__ */ jsx(Tooltip, { content: label, children: /* @__PURE__ */
|
|
17
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: label, children: /* @__PURE__ */ jsxs(
|
|
17
18
|
"button",
|
|
18
19
|
{
|
|
19
20
|
type: "button",
|
|
@@ -23,17 +24,21 @@ function IconButton({
|
|
|
23
24
|
"data-variant": variant,
|
|
24
25
|
"data-size": size,
|
|
25
26
|
"data-disclosure": disclosure || void 0,
|
|
27
|
+
"data-has-text": text !== void 0 && text !== null || void 0,
|
|
26
28
|
disabled: props.disabled || loading,
|
|
27
29
|
className: `${s.iconButton} ${props.className || ""}`,
|
|
28
|
-
children:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsxs("span", { className: s.icon, children: [
|
|
32
|
+
loading ? /* @__PURE__ */ jsx(Spinner, { decorative: true }) : children,
|
|
33
|
+
disclosure && /* @__PURE__ */ jsx(
|
|
34
|
+
DisclosureChevron,
|
|
35
|
+
{
|
|
36
|
+
expanded: props["aria-expanded"] === true || props["aria-expanded"] === "true"
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
] }),
|
|
40
|
+
text !== void 0 && text !== null && /* @__PURE__ */ jsx("span", { className: s.text, children: text })
|
|
41
|
+
]
|
|
37
42
|
}
|
|
38
43
|
) });
|
|
39
44
|
}
|
|
@@ -25,6 +25,27 @@
|
|
|
25
25
|
height: 30px;
|
|
26
26
|
min-width: 30px;
|
|
27
27
|
}
|
|
28
|
+
.iconButton[data-has-text] {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
width: auto;
|
|
33
|
+
gap: 6px;
|
|
34
|
+
padding-inline: 9px;
|
|
35
|
+
font-size: 13px;
|
|
36
|
+
line-height: 1.4;
|
|
37
|
+
}
|
|
38
|
+
.iconButton[data-has-text] .icon {
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
flex-shrink: 0;
|
|
43
|
+
gap: 3px;
|
|
44
|
+
}
|
|
45
|
+
.text {
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
font-variant-numeric: tabular-nums;
|
|
48
|
+
}
|
|
28
49
|
.iconButton[data-variant="primary"] {
|
|
29
50
|
background: var(--accent-fill, var(--accent));
|
|
30
51
|
color: var(--on-accent-fill, var(--on-accent));
|