@dubium/icons 0.0.2-alpha.3 → 0.0.2-alpha.4

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.
Files changed (124) hide show
  1. package/README.md +286 -49
  2. package/dist/collection/AdjustmentsPlusIcon.d.ts +3 -0
  3. package/dist/collection/{Icon123Icon.js → AdjustmentsPlusIcon.js} +3 -3
  4. package/dist/collection/AdjustmentsQuestionIcon.d.ts +3 -0
  5. package/dist/collection/AdjustmentsQuestionIcon.js +18 -0
  6. package/dist/collection/AlarmPlusFilledIcon.d.ts +3 -0
  7. package/dist/collection/AlarmPlusFilledIcon.js +29 -0
  8. package/dist/collection/AlarmSnoozeFilledIcon.d.ts +3 -0
  9. package/dist/collection/AlarmSnoozeFilledIcon.js +29 -0
  10. package/dist/collection/{Icon360ViewIcon.d.ts → AlarmSnoozeIcon.d.ts} +2 -2
  11. package/dist/collection/{Icon360Icon.js → AlarmSnoozeIcon.js} +3 -3
  12. package/dist/collection/AlbumIcon.d.ts +3 -0
  13. package/dist/collection/{Icon24HoursIcon.js → AlbumIcon.js} +3 -3
  14. package/dist/collection/AlbumOffIcon.d.ts +3 -0
  15. package/dist/collection/AlbumOffIcon.js +18 -0
  16. package/dist/collection/AlertCircleFilledIcon.d.ts +3 -0
  17. package/dist/collection/AlertCircleFilledIcon.js +15 -0
  18. package/dist/collection/{Icon24HoursIcon.d.ts → AlertCircleIcon.d.ts} +2 -2
  19. package/dist/collection/{Icon2faIcon.js → AlertCircleIcon.js} +3 -3
  20. package/dist/collection/AlertHexagonIcon.d.ts +3 -0
  21. package/dist/collection/AlertHexagonIcon.js +18 -0
  22. package/dist/collection/AlignBoxBottomRightFilledIcon.d.ts +3 -0
  23. package/dist/collection/AlignBoxBottomRightFilledIcon.js +15 -0
  24. package/dist/collection/AlignBoxBottomRightIcon.d.ts +3 -0
  25. package/dist/collection/AlignBoxBottomRightIcon.js +18 -0
  26. package/dist/collection/AlignBoxCenterMiddleFilledIcon.d.ts +3 -0
  27. package/dist/collection/AlignBoxCenterMiddleFilledIcon.js +15 -0
  28. package/dist/collection/AlignBoxCenterMiddleIcon.d.ts +3 -0
  29. package/dist/collection/AlignBoxCenterMiddleIcon.js +18 -0
  30. package/dist/collection/AlignBoxLeftBottomFilledIcon.d.ts +3 -0
  31. package/dist/collection/AlignBoxLeftBottomFilledIcon.js +15 -0
  32. package/dist/collection/AlignBoxLeftBottomIcon.d.ts +3 -0
  33. package/dist/collection/AlignBoxLeftBottomIcon.js +18 -0
  34. package/dist/collection/AlignBoxLeftMiddleFilledIcon.d.ts +3 -0
  35. package/dist/collection/AlignBoxLeftMiddleFilledIcon.js +15 -0
  36. package/dist/collection/AlignBoxLeftMiddleIcon.d.ts +3 -0
  37. package/dist/collection/AlignBoxLeftMiddleIcon.js +18 -0
  38. package/dist/collection/index.d.ts +20 -7
  39. package/dist/collection/index.js +19 -6
  40. package/dist/collection/types.d.ts +17 -1
  41. package/dist/icon/Icon.container.d.ts +29 -0
  42. package/dist/icon/Icon.container.js +19 -0
  43. package/dist/icon/Icon.d.ts +5 -0
  44. package/dist/icon/Icon.js +20 -0
  45. package/dist/icon/Icon.types.d.ts +59 -0
  46. package/dist/icon/index.d.ts +13 -0
  47. package/dist/icon/index.js +2 -0
  48. package/dist/vite/icon/Icon.create.d.ts +35 -0
  49. package/dist/{spa → vite}/icon/Icon.create.js +1 -1
  50. package/dist/vite/icon/Icon.d.ts +66 -0
  51. package/dist/vite/icon/Icon.js +79 -0
  52. package/dist/vite/icon/Icon.types.d.ts +88 -0
  53. package/dist/vite/icon/index.d.ts +6 -0
  54. package/dist/vite/index.d.ts +10 -46
  55. package/dist/vite/index.js +6 -167
  56. package/dist/vite/plugin/index.d.ts +11 -0
  57. package/dist/vite/plugin/index.js +2 -0
  58. package/dist/vite/plugin/plugin.d.ts +41 -0
  59. package/dist/vite/plugin/plugin.js +105 -0
  60. package/dist/vite/plugin/plugin.types.d.ts +99 -0
  61. package/dist/vite/plugin/scanner/index.d.ts +9 -0
  62. package/dist/vite/plugin/scanner/scanner.imports.d.ts +5 -0
  63. package/dist/vite/plugin/scanner/scanner.imports.js +36 -0
  64. package/dist/vite/plugin/scanner/scanner.jsx.d.ts +24 -0
  65. package/dist/vite/plugin/scanner/scanner.jsx.js +58 -0
  66. package/dist/vite/plugin/scanner/scanner.lexical.d.ts +30 -0
  67. package/dist/vite/plugin/scanner/scanner.lexical.js +140 -0
  68. package/dist/vite/plugin/scanner/scanner.properties.d.ts +9 -0
  69. package/dist/vite/plugin/scanner/scanner.properties.js +78 -0
  70. package/dist/vite/plugin/scanner/scanner.regex.d.ts +21 -0
  71. package/dist/vite/plugin/scanner/scanner.regex.js +24 -0
  72. package/dist/vite/plugin/scanner/scanner.source.d.ts +18 -0
  73. package/dist/vite/plugin/scanner/scanner.source.js +23 -0
  74. package/dist/vite/plugin/scanner/scanner.types.d.ts +1 -0
  75. package/dist/vite/plugin/sources/index.d.ts +11 -0
  76. package/dist/vite/plugin/sources/sources.catalog.d.ts +17 -0
  77. package/dist/vite/plugin/sources/sources.catalog.js +19 -0
  78. package/dist/vite/plugin/sources/sources.files.d.ts +34 -0
  79. package/dist/vite/plugin/sources/sources.files.js +43 -0
  80. package/dist/vite/plugin/sources/sources.types.d.ts +1 -0
  81. package/dist/vite/plugin/sources/sources.validate.d.ts +13 -0
  82. package/dist/vite/plugin/sources/sources.validate.js +12 -0
  83. package/dist/vite/plugin/virtual/index.d.ts +9 -0
  84. package/dist/vite/plugin/virtual/virtual.constants.d.ts +15 -0
  85. package/dist/vite/plugin/virtual/virtual.constants.js +4 -0
  86. package/dist/vite/plugin/virtual/virtual.module.d.ts +23 -0
  87. package/dist/vite/plugin/virtual/virtual.module.js +27 -0
  88. package/dist/vite/provider/IconProvider.context.d.ts +14 -0
  89. package/dist/vite/provider/IconProvider.context.js +5 -0
  90. package/dist/{spa → vite}/provider/IconProvider.d.ts +3 -2
  91. package/dist/{spa → vite}/provider/IconProvider.js +1 -1
  92. package/dist/{spa → vite}/provider/index.d.ts +2 -2
  93. package/dist/{spa/provider/IconProvider.context.d.ts → vite/provider/useIconContext.d.ts} +4 -14
  94. package/dist/vite/provider/useIconContext.js +6 -0
  95. package/dist/vite/runtime/IconRuntime.registry.d.ts +54 -0
  96. package/dist/vite/runtime/IconRuntime.registry.js +58 -0
  97. package/dist/vite/runtime/index.d.ts +9 -0
  98. package/package.json +17 -17
  99. package/dist/collection/Icon123Icon.d.ts +0 -3
  100. package/dist/collection/Icon2faIcon.d.ts +0 -3
  101. package/dist/collection/Icon360Icon.d.ts +0 -3
  102. package/dist/collection/Icon360ViewIcon.js +0 -18
  103. package/dist/spa/icon/Icon.create.d.ts +0 -40
  104. package/dist/spa/icon/Icon.d.ts +0 -25
  105. package/dist/spa/icon/Icon.js +0 -58
  106. package/dist/spa/icon/Icon.registry.d.ts +0 -12
  107. package/dist/spa/icon/Icon.types.d.ts +0 -71
  108. package/dist/spa/icon/index.d.ts +0 -9
  109. package/dist/spa/index.d.ts +0 -8
  110. package/dist/spa/index.js +0 -5
  111. package/dist/spa/provider/IconProvider.context.js +0 -5
  112. package/dist/ssr/icon/Icon.container.d.ts +0 -26
  113. package/dist/ssr/icon/Icon.container.js +0 -23
  114. package/dist/ssr/icon/Icon.create.d.ts +0 -35
  115. package/dist/ssr/icon/Icon.create.js +0 -8
  116. package/dist/ssr/icon/Icon.d.ts +0 -6
  117. package/dist/ssr/icon/Icon.js +0 -27
  118. package/dist/ssr/icon/Icon.registry.d.ts +0 -12
  119. package/dist/ssr/icon/Icon.registry.js +0 -10
  120. package/dist/ssr/icon/Icon.types.d.ts +0 -97
  121. package/dist/ssr/icon/index.d.ts +0 -10
  122. package/dist/ssr/index.d.ts +0 -6
  123. package/dist/ssr/index.js +0 -4
  124. /package/dist/{spa → vite}/provider/IconProvider.types.d.ts +0 -0
@@ -0,0 +1,14 @@
1
+ import type { IIconContextValue } from "./IconProvider.types.js";
2
+ /**
3
+ * React-контекст для хранения реестра иконок.
4
+ *
5
+ * Используется компонентами `Icon` / `AppIcon` для получения кастомных иконок,
6
+ * переданных через `IconProvider`.
7
+ *
8
+ * @remarks
9
+ * - Значение по умолчанию содержит пустой реестр (`icons: {}`)
10
+ * - Без `IconProvider` доступны иконки из compile-time virtual registry
11
+ * (`virtual:@dubium/icons-registry`) и иконки, зарегистрированные
12
+ * в runtime registry
13
+ */
14
+ export declare const IconContext: import("react").Context<IIconContextValue<Readonly<Record<string, import("../index.js").TIconLoader>>>>;
@@ -0,0 +1,5 @@
1
+ import { createContext as e } from "react";
2
+ //#region src/icons/vite/provider/IconProvider.context.ts
3
+ var t = e({ icons: {} });
4
+ //#endregion
5
+ export { t as IconContext };
@@ -26,8 +26,9 @@ import type { IIconProviderProps } from "./IconProvider.types.js";
26
26
  * ```
27
27
  *
28
28
  * @remarks
29
- * - Не обязателен для использования встроенных (`defaultIcons`) иконок
30
- * - Обязателен для работы кастомных иконок
29
+ * - Не обязателен для иконок из `virtual:@dubium/icons-registry` (compile-time)
30
+ * и иконок, зарегистрированных в runtime registry
31
+ * - Обязателен для работы кастомных иконок приложения
31
32
  * - Использует `useMemo` для предотвращения лишних перерисовок
32
33
  * - Если `icons` не передан, используется пустой реестр
33
34
  */
@@ -1,7 +1,7 @@
1
1
  import { IconContext as e } from "./IconProvider.context.js";
2
2
  import { jsx as t } from "react/jsx-runtime";
3
3
  import { useMemo as n } from "react";
4
- //#region src/icons/spa/provider/IconProvider.tsx
4
+ //#region src/icons/vite/provider/IconProvider.tsx
5
5
  var r = ({ children: r, icons: i }) => {
6
6
  let a = n(() => ({ icons: i ?? {} }), [i]);
7
7
  return /* @__PURE__ */ t(e.Provider, {
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Публичный API модуля провайдера иконок для SPA (клиентский рендеринг).
2
+ * Публичный API модуля провайдера иконок для Vite.
3
3
  *
4
4
  * Экспортирует `IconProvider`, хук `useIconContext` и связанные типы.
5
5
  */
6
6
  export { IconProvider } from "./IconProvider.js";
7
- export { useIconContext } from "./IconProvider.context.js";
7
+ export { useIconContext } from "./useIconContext.js";
8
8
  export type { IIconContextValue, IIconProviderProps } from "./IconProvider.types.js";
@@ -1,16 +1,5 @@
1
- import type { TEmptyIconRegistry, TIconRegistry } from "../icon/index.js";
2
1
  import type { IIconContextValue } from "./IconProvider.types.js";
3
- /**
4
- * React-контекст для хранения реестра иконок.
5
- *
6
- * Используется компонентами `Icon` / `AppIcon` для получения кастомных иконок,
7
- * переданных через `IconProvider`.
8
- *
9
- * @remarks
10
- * - Значение по умолчанию содержит пустой реестр (`icons: {}`)
11
- * - Без `IconProvider` будут доступны только встроенные (`defaultIcons`) иконки
12
- */
13
- export declare const IconContext: import("react").Context<IIconContextValue<Readonly<Record<string, import("../index.js").TIconLoader>>>>;
2
+ import type { TEmptyIconRegistry, TIconRegistry } from "../icon/index.js";
14
3
  /**
15
4
  * Хук для доступа к `IconContext` с поддержкой типизации кастомных иконок.
16
5
  *
@@ -26,7 +15,8 @@ export declare const IconContext: import("react").Context<IIconContextValue<Read
26
15
  * @remarks
27
16
  * - Выполняет приведение типа (`type assertion`), так как TypeScript
28
17
  * не может автоматически вывести тип из `IconProvider`
29
- * - Используется внутри `Icon` для объединения:
30
- * `{ ...defaultIcons, ...icons }`
18
+ * - Используется внутри `Icon` для доступа к кастомным иконкам,
19
+ * которые имеют приоритет над `virtual:@dubium/icons-registry`
20
+ * и runtime registry
31
21
  */
32
22
  export declare const useIconContext: <TCustomIcons extends TIconRegistry = TEmptyIconRegistry>() => IIconContextValue<TCustomIcons>;
@@ -0,0 +1,6 @@
1
+ import { IconContext as e } from "./IconProvider.context.js";
2
+ import { useContext as t } from "react";
3
+ //#region src/icons/vite/provider/useIconContext.ts
4
+ var n = () => t(e);
5
+ //#endregion
6
+ export { n as useIconContext };
@@ -0,0 +1,54 @@
1
+ import type { TIconLoader, TIconRegistry } from "../icon/Icon.types.js";
2
+ /**
3
+ * Регистрирует ленивый реестр иконок конкретного приложения или микрофронтенда.
4
+ *
5
+ * @remarks
6
+ * Состояние реестра хранится на `globalThis` под символом `Symbol.for(...)`,
7
+ * поэтому Host и Remote в одной browser realm видят одну регистрацию даже при
8
+ * разных копиях пакета `@dubium/icons` в бандле.
9
+ *
10
+ * Повторная регистрация того же `owner` заменяет предыдущую.
11
+ * Cleanup от старой регистрации не может удалить более новую регистрацию.
12
+ *
13
+ * @param owner - Идентификатор владельца реестра
14
+ * @param icons - Реестр иконок с ленивыми загрузчиками
15
+ * @returns Функция отмены именно этой регистрации; повторный вызов безопасен
16
+ */
17
+ export declare const registerIcons: (owner: string, icons: TIconRegistry) => VoidFunction;
18
+ /**
19
+ * Удаляет текущую регистрацию владельца из runtime-реестра.
20
+ *
21
+ * @remarks
22
+ * Удаляет все иконки, зарегистрированные указанным владельцем, и уведомляет
23
+ * подписчиков об изменении реестра.
24
+ *
25
+ * @param owner - Идентификатор владельца реестра
26
+ * @returns `true`, если регистрация существовала и была удалена
27
+ */
28
+ export declare const removeIconOwner: (owner: string) => boolean;
29
+ /**
30
+ * Возвращает ленивый загрузчик иконки по имени.
31
+ *
32
+ * @remarks
33
+ * При совпадении имени у нескольких владельцев используется последняя регистрация.
34
+ *
35
+ * @param name - Имя иконки
36
+ * @returns Загрузчик иконки или `undefined`, если иконка не зарегистрирована
37
+ */
38
+ export declare const getRuntimeIconLoader: (name: string) => TIconLoader | undefined;
39
+ /**
40
+ * Возвращает текущую версию runtime-реестра иконок.
41
+ *
42
+ * @remarks
43
+ * Версия увеличивается при каждом изменении регистраций.
44
+ *
45
+ * @returns Текущая версия реестра
46
+ */
47
+ export declare const getRuntimeIconsVersion: () => number;
48
+ /**
49
+ * Подписывается на изменения runtime-реестра иконок.
50
+ *
51
+ * @param listener - Функция, вызываемая при каждом изменении реестра
52
+ * @returns Функция отписки
53
+ */
54
+ export declare const subscribeRuntimeIcons: (listener: VoidFunction) => VoidFunction;
@@ -0,0 +1,58 @@
1
+ //#region src/icons/vite/runtime/IconRuntime.registry.ts
2
+ var e = Symbol.for("@dubium/icons/runtime-registry"), t = () => ({
3
+ listeners: /* @__PURE__ */ new Set(),
4
+ owners: /* @__PURE__ */ new Map(),
5
+ registrations: /* @__PURE__ */ new Map(),
6
+ ownerTokens: /* @__PURE__ */ new Map(),
7
+ version: 0
8
+ }), n = () => {
9
+ let n = globalThis;
10
+ return n[e] ??= t(), n[e];
11
+ }, r = () => {
12
+ let e = n();
13
+ e.version += 1;
14
+ for (let t of e.listeners) t();
15
+ }, i = (e, t) => {
16
+ let r = n(), i = r.ownerTokens.get(e);
17
+ if (!i || t && i !== t) return !1;
18
+ let a = r.owners.get(e);
19
+ if (a) for (let t of a) {
20
+ let n = r.registrations.get(t);
21
+ if (!n) continue;
22
+ let a = n.get(e);
23
+ a && a.token === i && (n.delete(e), n.size === 0 && r.registrations.delete(t));
24
+ }
25
+ return r.owners.delete(e), r.ownerTokens.delete(e), !0;
26
+ }, a = (e, t) => {
27
+ let a = n();
28
+ i(e);
29
+ let o = Symbol(e), s = /* @__PURE__ */ new Set();
30
+ for (let [n, r] of Object.entries(t)) {
31
+ let t = a.registrations.get(n) ?? /* @__PURE__ */ new Map();
32
+ t.set(e, {
33
+ loader: r,
34
+ token: o
35
+ }), a.registrations.set(n, t), s.add(n);
36
+ }
37
+ a.owners.set(e, s), a.ownerTokens.set(e, o), r();
38
+ let c = !0;
39
+ return () => {
40
+ c && (c = !1, i(e, o) && r());
41
+ };
42
+ }, o = (e) => {
43
+ let t = i(e);
44
+ return t && r(), t;
45
+ }, s = (e) => {
46
+ let t = n().registrations.get(e);
47
+ if (!t) return;
48
+ let r;
49
+ for (let e of t.values()) r = e.loader;
50
+ return r;
51
+ }, c = () => n().version, l = (e) => {
52
+ let t = n();
53
+ return t.listeners.add(e), () => {
54
+ t.listeners.delete(e);
55
+ };
56
+ };
57
+ //#endregion
58
+ export { s as getRuntimeIconLoader, c as getRuntimeIconsVersion, a as registerIcons, o as removeIconOwner, l as subscribeRuntimeIcons };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Публичный API runtime-реестра иконок.
3
+ *
4
+ * @remarks
5
+ * Позволяет регистрировать иконки приложений и микрофронтендов (MF) в общем
6
+ * реестре на `globalThis`, читать загрузчики по имени и подписываться на
7
+ * изменения реестра. Подробности — в {@link IconRuntime.registry.ts}.
8
+ */
9
+ export { getRuntimeIconLoader, getRuntimeIconsVersion, registerIcons, removeIconOwner, subscribeRuntimeIcons, } from "./IconRuntime.registry.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dubium/icons",
3
- "version": "0.0.2-alpha.3",
3
+ "version": "0.0.2-alpha.4",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist"
@@ -8,13 +8,9 @@
8
8
  "type": "module",
9
9
  "sideEffects": false,
10
10
  "exports": {
11
- "./spa": {
12
- "types": "./dist/spa/index.d.ts",
13
- "import": "./dist/spa/index.js"
14
- },
15
- "./ssr": {
16
- "types": "./dist/ssr/index.d.ts",
17
- "import": "./dist/ssr/index.js"
11
+ "./icon": {
12
+ "types": "./dist/icon/index.d.ts",
13
+ "import": "./dist/icon/index.js"
18
14
  },
19
15
  "./icons": {
20
16
  "types": "./dist/collection/index.d.ts",
@@ -31,6 +27,10 @@
31
27
  "./vite": {
32
28
  "types": "./dist/vite/index.d.ts",
33
29
  "import": "./dist/vite/index.js"
30
+ },
31
+ "./vite/plugin": {
32
+ "types": "./dist/vite/plugin/index.d.ts",
33
+ "import": "./dist/vite/plugin/index.js"
34
34
  }
35
35
  },
36
36
  "scripts": {
@@ -47,22 +47,22 @@
47
47
  "typecheck": "tsc --noEmit"
48
48
  },
49
49
  "devDependencies": {
50
- "@types/node": "^24.13.3",
50
+ "@types/node": "^26.4.1",
51
51
  "@types/react": "^19.2.18",
52
- "@types/react-dom": "^19.2.4",
53
- "@vitejs/plugin-react": "^6.0.5",
54
- "oxfmt": "^0.63.0",
55
- "oxlint": "^1.78.0",
52
+ "@types/react-dom": "^19.2.7",
53
+ "@vitejs/plugin-react": "^6.1.1",
54
+ "oxfmt": "^0.66.0",
55
+ "oxlint": "^1.81.0",
56
56
  "oxlint-tsgolint": "^7.0.2001",
57
- "rollup-plugin-visualizer": "^7.0.1",
58
- "svgo": "^4.0.2",
57
+ "rollup-plugin-visualizer": "^7.1.1",
58
+ "svgo": "^4.1.0",
59
59
  "typescript": "~7.0.2",
60
- "vite": "^8.2.1"
60
+ "vite": "^8.2.2"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "react": "^18.0.0 || ^19.0.0",
64
64
  "react-dom": "^18.0.0 || ^19.0.0",
65
- "vite": "^8.0.0"
65
+ "vite": "^7.3.5 || ^8.0.16"
66
66
  },
67
67
  "peerDependenciesMeta": {
68
68
  "vite": {
@@ -1,3 +0,0 @@
1
- import type { IIconComponentProps } from "./types.js";
2
- export declare const Icon123Icon: ({ color, ...props }: IIconComponentProps) => import("react").JSX.Element;
3
- export default Icon123Icon;
@@ -1,3 +0,0 @@
1
- import type { IIconComponentProps } from "./types.js";
2
- export declare const Icon2faIcon: ({ color, ...props }: IIconComponentProps) => import("react").JSX.Element;
3
- export default Icon2faIcon;
@@ -1,3 +0,0 @@
1
- import type { IIconComponentProps } from "./types.js";
2
- export declare const Icon360Icon: ({ color, ...props }: IIconComponentProps) => import("react").JSX.Element;
3
- export default Icon360Icon;
@@ -1,18 +0,0 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- //#region src/icons/collection/Icon360ViewIcon.tsx
3
- var t = ({ color: t = "var(--icon-color, currentColor)", ...n }) => /* @__PURE__ */ e("svg", {
4
- ...n,
5
- fill: "none",
6
- viewBox: "0 0 24 24",
7
- width: "100%",
8
- height: "100%",
9
- children: /* @__PURE__ */ e("path", {
10
- stroke: t,
11
- strokeLinecap: "round",
12
- strokeLinejoin: "round",
13
- strokeWidth: "2",
14
- d: "M14 6a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-3M3 5h2.5A1.5 1.5 0 0 1 7 6.5v1A1.5 1.5 0 0 1 5.5 9m0 0H4m1.5 0A1.5 1.5 0 0 1 7 10.5v1A1.5 1.5 0 0 1 5.5 13H3m0 3c0 1.66 4.03 3 9 3s9-1.34 9-3m-4-9v4a2 2 0 0 0 4 0V7a2 2 0 1 0-4 0"
15
- })
16
- });
17
- //#endregion
18
- export { t as Icon360ViewIcon, t as default };
@@ -1,40 +0,0 @@
1
- import type { TEmptyIconRegistry, TIconRegistry } from "./Icon.types.js";
2
- import { type IconProps } from "./Icon.js";
3
- /**
4
- * Создаёт типизированную обёртку над компонентом `Icon`
5
- * с поддержкой автодополнения (autocomplete) для кастомных иконок.
6
- *
7
- * @typeParam TCustomIcons - Реестр кастомных иконок (обычно `typeof appIcons`)
8
- *
9
- * @returns Компонент иконки с типобезопасным пропом `name`,
10
- * включающим как встроенные (`defaultIcons`), так и кастомные иконки.
11
- *
12
- * @example
13
- * ```ts
14
- * const appIcons = {
15
- * User: () => import("./UserIcon"),
16
- * Settings: () => import("./SettingsIcon"),
17
- * } as const;
18
- *
19
- * type TAppIcons = typeof appIcons;
20
- *
21
- * const AppIcon = createIcon<TAppIcons>();
22
- * ```
23
- *
24
- * ```tsx
25
- * <IconProvider icons={appIcons}>
26
- * <AppIcon name="User" /> // ✅ autocomplete
27
- * <AppIcon name="Close" /> // ✅ из UIKit
28
- * <AppIcon name="Wrong" /> // ❌ ошибка TypeScript
29
- * </IconProvider>
30
- * ```
31
- *
32
- * @remarks
33
- * - Требует использования `IconProvider` для передачи реестра иконок в runtime
34
- * - Без `IconProvider` кастомные иконки не будут найдены
35
- * - Используется для улучшения DX (type safety + autocomplete)
36
- */
37
- export declare const createIcon: <TCustomIcons extends TIconRegistry = TEmptyIconRegistry>() => {
38
- (props: IconProps<TCustomIcons>): import("react").JSX.Element;
39
- displayName: string;
40
- };
@@ -1,25 +0,0 @@
1
- import { type MemoExoticComponent } from "react";
2
- import type { TEmptyIconRegistry, TIconName, TIconRegistry } from "./Icon.types.js";
3
- export interface IconProps<TCustomIcons extends TIconRegistry = TEmptyIconRegistry> {
4
- ariaLabel?: string;
5
- color?: string;
6
- secondaryColor?: string;
7
- deg?: number;
8
- height?: number;
9
- name: TIconName<TCustomIcons>;
10
- onClick?: VoidFunction;
11
- size?: number;
12
- width?: number;
13
- }
14
- /**
15
- * SPA-иконка с lazy loading.
16
- *
17
- * Встроенные loader-ы поступают из virtual:@dubium/icons-registry.
18
- * Этот virtual module создаёт @dubium/icons/vite на этапе сборки приложения
19
- * и помещает в него только статически используемые <Icon name="..." />.
20
- *
21
- * Пользовательский IconProvider имеет приоритет над встроенным registry.
22
- */
23
- declare const IconComponentBase: <TCustomIcons extends TIconRegistry = TEmptyIconRegistry>({ name, size, width: propWidth, height: propHeight, color, secondaryColor, deg, onClick: handleOnClick, ariaLabel, }: IconProps<TCustomIcons>) => import("react").JSX.Element;
24
- declare const MemoizedIcon: MemoExoticComponent<typeof IconComponentBase> & typeof IconComponentBase;
25
- export { MemoizedIcon as Icon };
@@ -1,58 +0,0 @@
1
- import { useIconContext as e } from "../provider/IconProvider.context.js";
2
- import { jsx as t } from "react/jsx-runtime";
3
- import { memo as n, useEffect as r, useMemo as i, useState as a } from "react";
4
- import { iconRegistry as o } from "virtual:@dubium/icons-registry";
5
- //#region src/icons/spa/icon/Icon.tsx
6
- var s = /* @__PURE__ */ new Map(), c = n(({ name: n, size: c = 24, width: l, height: u, color: d = "var(--icon-color, currentColor)", secondaryColor: f = "var(--icon-secondary-color, currentColor)", deg: p = 0, onClick: m, ariaLabel: h }) => {
7
- let { icons: g } = e(), _ = g[n] ?? o[String(n)], [v, y] = a(() => _ ? s.get(_) ?? null : null), [b, x] = a(!1), S = l ?? c, C = u ?? c, w = i(() => ({
8
- alignItems: "center",
9
- display: "inline-flex",
10
- height: C,
11
- justifyContent: "center",
12
- transform: `rotate(${p}deg)`,
13
- width: S
14
- }), [
15
- C,
16
- S,
17
- p
18
- ]);
19
- return r(() => {
20
- let e = !1, t = String(n), r = g[n] ?? o[t];
21
- if (!r) return x(!1), y(null), console.warn(`Иконка "${t}" не найдена в compile-time registry. Для динамического name добавьте её в dubiumIcons({ include: ["..."] }).`), () => {
22
- e = !0;
23
- };
24
- let i = s.get(r);
25
- return i ? (x(!1), y(() => i), () => {
26
- e = !0;
27
- }) : (x(!0), y(null), r().then((t) => {
28
- if (e) return;
29
- let n = t.default;
30
- s.set(r, n), y(() => n);
31
- }).catch((n) => {
32
- e || (console.error(`Ошибка загрузки иконки "${t}":`, n), y(null));
33
- }).finally(() => {
34
- e || x(!1);
35
- }), () => {
36
- e = !0;
37
- });
38
- }, [g, n]), b || !v ? /* @__PURE__ */ t("div", {
39
- "aria-hidden": "true",
40
- role: "img",
41
- style: {
42
- ...w,
43
- visibility: "hidden"
44
- }
45
- }) : /* @__PURE__ */ t("div", {
46
- "aria-label": h || String(n),
47
- onClick: m,
48
- role: "img",
49
- style: w,
50
- children: /* @__PURE__ */ t(v, {
51
- color: d,
52
- secondaryColor: f
53
- })
54
- });
55
- });
56
- c.displayName = "Icon";
57
- //#endregion
58
- export { c as Icon };
@@ -1,12 +0,0 @@
1
- /**
2
- * AUTO-GENERATED by scripts/sync-icons.mjs.
3
- * Source of truth: icons/source/*.svg.
4
- */
5
- export declare const defaultIcons: {
6
- readonly Icon123: () => Promise<typeof import("../../collection/Icon123Icon.js")>;
7
- readonly Icon24Hours: () => Promise<typeof import("../../collection/Icon24HoursIcon.js")>;
8
- readonly Icon2fa: () => Promise<typeof import("../../collection/Icon2faIcon.js")>;
9
- readonly Icon360: () => Promise<typeof import("../../collection/Icon360Icon.js")>;
10
- readonly Icon360View: () => Promise<typeof import("../../collection/Icon360ViewIcon.js")>;
11
- };
12
- export type TDefaultIconName = keyof typeof defaultIcons;
@@ -1,71 +0,0 @@
1
- import type { ComponentType } from "react";
2
- import type { IIconComponentProps } from "../../collection/types.js";
3
- import type { TDefaultIconName } from "./Icon.registry.js";
4
- /**
5
- * Тип "пустого" реестра иконок.
6
- *
7
- * Используется как значение по умолчанию в generic-параметрах,
8
- * чтобы избежать использования `{}` (который допускает любые значения).
9
- *
10
- * @remarks
11
- * Обеспечивает корректную типизацию без ослабления type safety.
12
- */
13
- export type TEmptyIconRegistry = Readonly<Record<never, never>>;
14
- /**
15
- * Тип React-компонента иконки.
16
- *
17
- * Каждая иконка должна быть функциональным компонентом,
18
- * принимающим `IIconComponentProps`.
19
- */
20
- export type TIcon = ComponentType<IIconComponentProps>;
21
- /**
22
- * Тип модуля, возвращаемого через динамический `import()`.
23
- *
24
- * @property default - React-компонент иконки
25
- */
26
- export type TIconModule = {
27
- default: TIcon;
28
- };
29
- /**
30
- * Тип функции-лоадера иконки.
31
- *
32
- * Используется для lazy loading (code splitting) через `import()`.
33
- *
34
- * @example
35
- * ```ts
36
- * const loader: TIconLoader = () => import("./CloseIcon");
37
- * ```
38
- */
39
- export type TIconLoader = () => Promise<TIconModule>;
40
- /**
41
- * Реестр иконок.
42
- *
43
- * Представляет собой словарь, где:
44
- * - ключ — имя иконки
45
- * - значение — функция загрузки (lazy import)
46
- *
47
- * @example
48
- * ```ts
49
- * const icons: TIconRegistry = {
50
- * Close: () => import("./CloseIcon"),
51
- * };
52
- * ```
53
- */
54
- export type TIconRegistry = Readonly<Record<string, TIconLoader>>;
55
- /**
56
- * Тип допустимых имён иконок.
57
- *
58
- * Объединяет:
59
- * - встроенные иконки (`TDefaultIconName`)
60
- * - кастомные иконки (`TCustomIcons`)
61
- *
62
- * @typeParam TCustomIcons - Реестр кастомных иконок
63
- *
64
- * @example
65
- * ```ts
66
- * type Name = TIconName<typeof appIcons>;
67
- * // "Close" | "User" | "Settings"
68
- * ```
69
- */
70
- export type TIconName<TCustomIcons extends TIconRegistry = TEmptyIconRegistry> = Extract<keyof TCustomIcons, string> | TDefaultIconName;
71
- export type { IIconComponentProps };
@@ -1,9 +0,0 @@
1
- /**
2
- * Публичный API модуля иконок для SPA (клиентский рендеринг).
3
- *
4
- * Экспортирует компонент `Icon`, фабрику `createIcon` и связанные типы
5
- * с поддержкой ленивой загрузки иконок через динамический `import()`.
6
- */
7
- export { Icon, type IconProps } from "./Icon.js";
8
- export { createIcon } from "./Icon.create.js";
9
- export type { IIconComponentProps, TEmptyIconRegistry, TIcon, TIconLoader, TIconModule, TIconName, TIconRegistry, } from "./Icon.types.js";
@@ -1,8 +0,0 @@
1
- /**
2
- * Публичный API пакета иконок для SPA (клиентский рендеринг).
3
- *
4
- * Позволяет лениво загружать иконки через динамический `import()`
5
- * с поддержкой code-splitting.
6
- */
7
- export { IconProvider, useIconContext, type IIconContextValue, type IIconProviderProps } from "./provider/index.js";
8
- export { Icon, createIcon, type IconProps, type IIconComponentProps, type TEmptyIconRegistry, type TIcon, type TIconLoader, type TIconModule, type TIconName, type TIconRegistry, } from "./icon/index.js";
package/dist/spa/index.js DELETED
@@ -1,5 +0,0 @@
1
- import { useIconContext as e } from "./provider/IconProvider.context.js";
2
- import { IconProvider as t } from "./provider/IconProvider.js";
3
- import { Icon as n } from "./icon/Icon.js";
4
- import { createIcon as r } from "./icon/Icon.create.js";
5
- export { n as Icon, t as IconProvider, r as createIcon, e as useIconContext };
@@ -1,5 +0,0 @@
1
- import { createContext as e, useContext as t } from "react";
2
- //#region src/icons/spa/provider/IconProvider.context.ts
3
- var n = e({ icons: {} }), r = () => t(n);
4
- //#endregion
5
- export { n as IconContext, r as useIconContext };
@@ -1,26 +0,0 @@
1
- import type { CSSProperties, ReactNode } from "react";
2
- /**
3
- * Свойства контейнера SSR/RSC-иконки.
4
- *
5
- * @property ariaLabel - Атрибут `aria-label` для доступности
6
- * @property children - Дочерние элементы (SVG иконки)
7
- * @property deg - Угол поворота в градусах
8
- * @property height - Высота контейнера (если нужен прямоугольник)
9
- * @property size - Размер контейнера (квадратный, по умолчанию 24)
10
- * @property style - Инлайн-стили контейнера
11
- * @property width - Ширина контейнера (если нужен прямоугольник)
12
- */
13
- export interface IconContainerProps {
14
- ariaLabel?: string;
15
- children: ReactNode;
16
- deg?: number;
17
- height?: number | string;
18
- size?: number | string;
19
- style?: CSSProperties;
20
- width?: number | string;
21
- }
22
- /**
23
- * Общий SSR/RSC-контейнер иконки.
24
- * Не использует hooks, context и client-only API.
25
- */
26
- export declare const IconContainer: ({ ariaLabel, children, deg, height, size, style, width, }: IconContainerProps) => import("react").JSX.Element;
@@ -1,23 +0,0 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- //#region src/icons/ssr/icon/Icon.container.tsx
3
- var t = ({ ariaLabel: t, children: n, deg: r = 0, height: i, size: a = 24, style: o, width: s }) => {
4
- let c = {
5
- display: "inline-flex",
6
- alignItems: "center",
7
- justifyContent: "center",
8
- flex: "0 0 auto",
9
- width: s ?? a,
10
- height: i ?? a,
11
- transform: `rotate(${r}deg)`,
12
- ...o
13
- };
14
- return /* @__PURE__ */ e("span", {
15
- "aria-hidden": !t || void 0,
16
- "aria-label": t,
17
- role: t ? "img" : void 0,
18
- style: c,
19
- children: n
20
- });
21
- };
22
- //#endregion
23
- export { t as IconContainer };