@robert-stackflow/oneui 0.4.1 → 0.4.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,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.2 — 2026-10-29
4
+
5
+ - 图标、Emoji 和符号目录改用可被构建工具识别的异步 JSON 导入,修复 npm 包在 Vite 开发预打包后资源相对路径失效的问题;生产构建继续按需加载。
6
+ - Card 新增 `description` 与无正文模式,标题和正文使用一致的横向间距,避免只含概览和操作时产生空白正文。
7
+ - 独立 tarball 消费测试增加开发模式预打包下的三套完整目录加载验证。
8
+
3
9
  ## 0.4.1 — 2026-10-29
4
10
 
5
11
  - Dialog、Drawer 统一处理普通关闭和条件卸载后的焦点恢复,兼容 StrictMode、嵌套与替换弹窗,不抢夺其他弹窗的焦点。
package/README.md CHANGED
@@ -57,6 +57,10 @@ export function App() {
57
57
 
58
58
  以上 API 从 0.2.0 起提供。
59
59
 
60
+ ## 概览卡片与内置目录(0.4.2)
61
+
62
+ `Card` 可通过 `title`、`description`、`action` 组合概览与操作;省略 `children` 时不会渲染空白正文。图标选择器不传 `options` 即使用库内置的完整目录;`valuePrefix="lucide:"` 可保留宿主保存值的前缀。图标、Emoji 和符号资源均由组件库按需加载,支持 Vite 的开发预打包与生产构建,宿主无需维护另一套选项或资源加载器。
63
+
60
64
  ## 弹窗焦点与分页(0.4.1)
61
65
 
62
66
  `Dialog` 和 `Drawer` 在普通关闭、条件卸载时都会恢复触发控件的焦点,支持 StrictMode 和嵌套弹窗。异步打开导致触发按钮在加载期间失焦时,可传入 `returnFocus={triggerRef}` 明确返回位置;已卸载、禁用或位于其他模态层之外的目标不会被聚焦。
@@ -1,8 +1,9 @@
1
1
  import type { ReactNode } from "react";
2
- export declare function Card({ title, action, children, className, onClick, }: {
2
+ export declare function Card({ title, description, action, children, className, onClick, }: {
3
3
  title?: string;
4
+ description?: ReactNode;
4
5
  action?: ReactNode;
5
- children: ReactNode;
6
+ children?: ReactNode;
6
7
  className?: string;
7
8
  onClick?(): void;
8
9
  }): import("react").JSX.Element;
@@ -2,27 +2,33 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import s from "./Card.module.css";
3
3
  function Card({
4
4
  title,
5
+ description,
5
6
  action,
6
7
  children,
7
8
  className = "",
8
9
  onClick
9
10
  }) {
11
+ const hasBody = children != null && children !== false;
12
+ const classes = `${s.card} ${!hasBody ? s.headerOnly : ""} ${className}`;
10
13
  const content = /* @__PURE__ */ jsxs(Fragment, { children: [
11
- (title || action) && /* @__PURE__ */ jsxs("header", { className: s.header, children: [
12
- /* @__PURE__ */ jsx("h2", { children: title }),
14
+ (title || description || action) && /* @__PURE__ */ jsxs("header", { className: s.header, children: [
15
+ /* @__PURE__ */ jsxs("div", { className: s.heading, children: [
16
+ title && /* @__PURE__ */ jsx("h2", { children: title }),
17
+ description && /* @__PURE__ */ jsx("div", { className: s.description, children: description })
18
+ ] }),
13
19
  action
14
20
  ] }),
15
- /* @__PURE__ */ jsx("div", { className: s.body, "data-card-body": true, children })
21
+ hasBody && /* @__PURE__ */ jsx("div", { className: s.body, "data-card-body": true, children })
16
22
  ] });
17
23
  return onClick ? /* @__PURE__ */ jsx(
18
24
  "button",
19
25
  {
20
26
  type: "button",
21
- className: `${s.card} ${s.interactive} ${className}`,
27
+ className: `${classes} ${s.interactive}`,
22
28
  onClick,
23
29
  children: content
24
30
  }
25
- ) : /* @__PURE__ */ jsx("section", { className: s.card + " " + className, children: content });
31
+ ) : /* @__PURE__ */ jsx("section", { className: classes, children: content });
26
32
  }
27
33
  export {
28
34
  Card
@@ -29,7 +29,24 @@
29
29
  align-items: center;
30
30
  justify-content: space-between;
31
31
  gap: 12px;
32
- padding: 20px 24px 0;
32
+ flex-wrap: wrap;
33
+ padding: 20px var(--card-space) 0;
34
+ }
35
+ .heading {
36
+ flex: 1;
37
+ min-width: 0;
38
+ }
39
+ .heading h2 {
40
+ color: var(--fg);
41
+ }
42
+ .description {
43
+ margin-top: 6px;
44
+ color: var(--muted);
45
+ font-size: 13px;
46
+ line-height: 1.65;
47
+ }
48
+ .headerOnly .header {
49
+ padding-bottom: var(--card-space);
33
50
  }
34
51
  .body {
35
52
  padding: var(--card-space);
@@ -44,4 +61,7 @@
44
61
  .body {
45
62
  padding: 18px;
46
63
  }
64
+ .headerOnly .header {
65
+ padding-bottom: 18px;
66
+ }
47
67
  }
@@ -1,14 +1,9 @@
1
1
  import { useEffect, useState } from "react";
2
- const emojiUrl = new URL("../assets/emoji.json", import.meta.url).href;
3
- const symbolsUrl = new URL("../assets/symbols.json", import.meta.url).href;
4
2
  import metadata from "../assets/character-metadata.json";
5
3
  const cache = {}, pending = {};
6
4
  const labels = metadata.groups, aliases = metadata.aliases;
7
5
  function load(kind) {
8
- return pending[kind] ||= fetch(kind === "emoji" ? emojiUrl : symbolsUrl).then((r) => {
9
- if (!r.ok) throw Error("\u5B57\u7B26\u52A0\u8F7D\u5931\u8D25");
10
- return r.json();
11
- }).then((rows) => {
6
+ return pending[kind] ||= (kind === "emoji" ? import("../assets/emoji.json") : import("../assets/symbols.json")).then(({ default: rows }) => rows).then((rows) => {
12
7
  const groups = /* @__PURE__ */ new Map();
13
8
  for (const [glyph, title, group, detail] of rows) {
14
9
  if (!glyph.trim()) continue;
@@ -1,12 +1,8 @@
1
1
  import { useEffect, useState } from "react";
2
- const url = new URL("../assets/icon-catalog.json", import.meta.url).href;
3
2
  let cache;
4
3
  let pending;
5
4
  function loadCatalog() {
6
- return pending ||= fetch(url).then((r) => {
7
- if (!r.ok) throw Error("\u56FE\u6807\u52A0\u8F7D\u5931\u8D25");
8
- return r.json();
9
- }).then((data) => cache = data).catch((e) => {
5
+ return pending ||= import("../assets/icon-catalog.json").then(({ default: data }) => cache = data).catch((e) => {
10
6
  pending = void 0;
11
7
  throw e;
12
8
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robert-stackflow/oneui",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "OneUI React components, application shell and portable visual themes",
5
5
  "type": "module",
6
6
  "sideEffects": [