@donglegeyu/company-ui 2.3.0 → 2.4.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.
@@ -37,6 +37,7 @@ var import_antd = require("antd");
37
37
  var import_IconGallery = __toESM(require("../IconGallery"));
38
38
  var import_IconParkGallery = __toESM(require("../IconParkGallery"));
39
39
  var import_icons = require("../SvgIcon/icons");
40
+ var import_all_icons = require("../SvgIcon/all-icons");
40
41
  var import_theme = require("../../theme");
41
42
  var import_index = require("./index.scss");
42
43
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -70,7 +71,7 @@ function IconExplorer() {
70
71
  },
71
72
  {
72
73
  key: "full",
73
- label: "图标库 Full (2662)",
74
+ label: `图标库 Full (${import_all_icons.allIconNames.length})`,
74
75
  forceRender: true,
75
76
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: "icon-full", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_IconParkGallery.default, {}) })
76
77
  }
@@ -117,7 +117,7 @@ function IconParkGallery() {
117
117
  return () => window.removeEventListener("iconpark:reveal", onReveal);
118
118
  }, [segments]);
119
119
  const handleCopy = (0, import_react.useCallback)(async (name) => {
120
- const code = `<SvgIcon href="${name}" size={16} />`;
120
+ const code = `<SvgIcon name="${name}" size={16} />`;
121
121
  try {
122
122
  await navigator.clipboard.writeText(code);
123
123
  import_basic_components.CompanyMessage.success(`已复制:${code}`);
@@ -128,7 +128,7 @@ function IconParkGallery() {
128
128
  if (loading) {
129
129
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-iconpark-gallery-loading", children: [
130
130
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { color: token.colorPrimary, fontSize: 24, marginBottom: 12 }, children: "○" }),
131
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { color: token.colorTextSecondary, fontSize: 14 }, children: "加载 2658 个图标中..." })
131
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { color: token.colorTextSecondary, fontSize: 14 }, children: "加载 2600+ 图标中..." })
132
132
  ] });
133
133
  }
134
134
  if (error || !data) {
@@ -147,12 +147,20 @@ function IconParkGallery() {
147
147
  style: { maxWidth: 360 }
148
148
  }
149
149
  ),
150
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
150
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
151
151
  "span",
152
152
  {
153
153
  className: "company-iconpark-gallery-hint",
154
154
  style: { color: token.colorTextQuaternary },
155
- children: "图标库基于 IconPark,运行时按需加载 sprite(约 2MB,浏览器缓存),适合图标选型与 IconSelect 场景。"
155
+ children: [
156
+ "图标库基于 IconPark,全量 2600+ 图标已编译进 JS 包,业务环境可直接",
157
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("code", { children: [
158
+ "<SvgIcon name=",
159
+ '"xxx"',
160
+ " />"
161
+ ] }),
162
+ " 渲染,无需网络加载。"
163
+ ]
156
164
  }
157
165
  )
158
166
  ] }),
@@ -15,8 +15,8 @@ export interface IconParkData {
15
15
  categories: IconParkCategory[];
16
16
  icons: IconParkMetaItem[];
17
17
  }
18
- export declare function useIconPark(spriteUrl?: string, metaUrl?: string): {
19
- data: IconParkData | null;
18
+ export declare function useIconPark(): {
19
+ data: IconParkData;
20
20
  loading: boolean;
21
- error: string | null;
21
+ error: null;
22
22
  };
@@ -22,66 +22,27 @@ __export(useIconPark_exports, {
22
22
  useIconPark: () => useIconPark
23
23
  });
24
24
  module.exports = __toCommonJS(useIconPark_exports);
25
- var import_react = require("react");
26
- var spriteLoadPromise = null;
27
- function useIconPark(spriteUrl = "/iconpark-sprite.svg", metaUrl = "/iconpark-meta.json") {
28
- const [data, setData] = (0, import_react.useState)(null);
29
- const [loading, setLoading] = (0, import_react.useState)(true);
30
- const [error, setError] = (0, import_react.useState)(null);
31
- const injectSprite = (0, import_react.useCallback)(async () => {
32
- if (document.getElementById("company-iconpark-sprite"))
33
- return true;
34
- if (spriteLoadPromise)
35
- return spriteLoadPromise;
36
- spriteLoadPromise = new Promise((resolvePromise) => {
37
- try {
38
- fetch(spriteUrl).then((res) => res.text()).then((text) => {
39
- const div = document.createElement("div");
40
- div.id = "company-iconpark-sprite";
41
- div.style.display = "none";
42
- div.innerHTML = text;
43
- document.body.insertBefore(div, document.body.firstChild);
44
- resolvePromise(true);
45
- }).catch(() => resolvePromise(false));
46
- } catch {
47
- resolvePromise(false);
48
- }
49
- });
50
- return spriteLoadPromise;
51
- }, [spriteUrl]);
52
- (0, import_react.useEffect)(() => {
53
- let cancelled = false;
54
- setLoading(true);
55
- Promise.all([
56
- injectSprite(),
57
- fetch(metaUrl).then((res) => res.json()).then((json) => {
58
- if (cancelled)
59
- return null;
60
- return json;
61
- })
62
- ]).then(([ok, json]) => {
63
- if (cancelled)
64
- return;
65
- if (!ok) {
66
- setError("图标 sprite 加载失败");
67
- }
68
- if (json) {
69
- setData(json);
70
- } else {
71
- setError("图标元数据加载失败");
72
- }
73
- }).catch((e) => {
74
- if (!cancelled)
75
- setError(String(e));
76
- }).finally(() => {
77
- if (!cancelled)
78
- setLoading(false);
79
- });
80
- return () => {
81
- cancelled = true;
82
- };
83
- }, [injectSprite, metaUrl]);
84
- return { data, loading, error };
25
+ var import_all_icons = require("../SvgIcon/all-icons");
26
+ var BUILTIN_DATA = (() => {
27
+ const categoryMap = /* @__PURE__ */ new Map();
28
+ for (const icon of import_all_icons.allIconEntries) {
29
+ const key = icon.category || "other";
30
+ if (!categoryMap.has(key)) {
31
+ categoryMap.set(key, {
32
+ key,
33
+ label: icon.categoryCN || icon.category || "其他",
34
+ en: icon.category
35
+ });
36
+ }
37
+ }
38
+ return {
39
+ count: import_all_icons.allIconEntries.length,
40
+ categories: Array.from(categoryMap.values()),
41
+ icons: import_all_icons.allIconEntries
42
+ };
43
+ })();
44
+ function useIconPark() {
45
+ return { data: BUILTIN_DATA, loading: false, error: null };
85
46
  }
86
47
  // Annotate the CommonJS export names for ESM import in node:
87
48
  0 && (module.exports = {
@@ -0,0 +1,19 @@
1
+ import type React from "react";
2
+ export interface AllIconDefinition {
3
+ name: string;
4
+ viewBox: string;
5
+ children: React.ReactNode;
6
+ title: string;
7
+ category: string;
8
+ categoryCN: string;
9
+ tag: string[];
10
+ }
11
+ export declare function getAllIconDefinition(name: string): AllIconDefinition | undefined;
12
+ export declare const allIconNames: string[];
13
+ export declare const allIconEntries: {
14
+ name: string;
15
+ title: string;
16
+ category: string;
17
+ categoryCN: string;
18
+ tag: string[];
19
+ }[];