@ai-matrx/icons 0.1.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.
- package/CHANGELOG.md +25 -0
- package/LICENSE +21 -0
- package/README.md +119 -0
- package/dist/index.cjs +581 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +178 -0
- package/dist/index.d.ts +178 -0
- package/dist/index.js +686 -0
- package/dist/index.js.map +1 -0
- package/package.json +88 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 — 2026-08-28
|
|
4
|
+
|
|
5
|
+
- Created the package, ported verbatim from the Matrx frontend icon system
|
|
6
|
+
(`IconResolver` + the lucide name-normalize / module-icon-validation / svg-registry
|
|
7
|
+
utilities): the curated ~140-icon static Lucide map, the validated dynamic
|
|
8
|
+
`import("lucide-react")` with a module-level cache, the `svg:` asset short-circuit to
|
|
9
|
+
an `<img>`, and the fallback-icon-while-loading behavior.
|
|
10
|
+
- Coupling inversions (the only behavior deltas vs. the original):
|
|
11
|
+
- `cn` is a tiny local class join — no tailwind-merge/clsx dependency.
|
|
12
|
+
- The SVG public-asset registry is injectable: ships empty; hosts call
|
|
13
|
+
`registerSvgIcons(map)` at startup (the previous hardcoded app registry moved to the
|
|
14
|
+
README as the host-registration example).
|
|
15
|
+
- `react-icons` became an OPTIONAL peer: the curated brand icons are lazy-imported on
|
|
16
|
+
first use and every path degrades to the fallback icon when the peer is absent —
|
|
17
|
+
which also means a brand icon's very first sync `getIconComponent` lookup falls back
|
|
18
|
+
until the lazy load completes.
|
|
19
|
+
- New host hooks: `extendStaticIcons(map)` to add zero-latency static hits, and the
|
|
20
|
+
static map itself is exported.
|
|
21
|
+
- Peers `react >= 18`, `lucide-react >= 0.400.0`, optional `react-icons >= 5`; zero
|
|
22
|
+
runtime dependencies. ESM + CommonJS with `"use client"` stamped on built chunks; the
|
|
23
|
+
release gate installs the packed tarball into an empty project (required peers only —
|
|
24
|
+
proving the no-react-icons degradation) and loads it through both `import` and
|
|
25
|
+
`require`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AI Matrix Engine
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# @ai-matrx/icons
|
|
2
|
+
|
|
3
|
+
Turn any icon **name** into a rendered component. One resolver, four sources, zero
|
|
4
|
+
flash-of-nothing:
|
|
5
|
+
|
|
6
|
+
- **A curated static map of ~140 hot Lucide icons** — a hit renders synchronously, no
|
|
7
|
+
dynamic-import latency. The map is exported (`staticLucideIconMap`) and extensible
|
|
8
|
+
(`extendStaticIcons`).
|
|
9
|
+
- **The full Lucide catalog via a validated dynamic `import("lucide-react")`** — resolved
|
|
10
|
+
once, cached at module level, with the export checked to actually be a renderable
|
|
11
|
+
component before it is ever rendered.
|
|
12
|
+
- **Curated brand icons from the optional `react-icons` peer** — lazy-imported on first
|
|
13
|
+
use; when `react-icons` is not installed the resolver degrades to the fallback icon
|
|
14
|
+
instead of failing.
|
|
15
|
+
- **Your own SVG assets via `svg:` ids** — an injectable registry maps
|
|
16
|
+
`svg:icons/Home` → `/icons/Home.svg` and renders an `<img>`; you register your app's
|
|
17
|
+
asset paths once at startup.
|
|
18
|
+
|
|
19
|
+
While a dynamic icon loads, the fallback icon (default `Zap`) renders in its place — the
|
|
20
|
+
layout never jumps and nothing flashes empty.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @ai-matrx/icons lucide-react
|
|
24
|
+
# optional, for the curated brand icons (FcGoogle, FaBrave, …):
|
|
25
|
+
npm install react-icons
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Peers: `react >= 18`, `lucide-react >= 0.400.0`, and optionally `react-icons >= 5`.
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { IconResolver, DynamicIcon, getIconComponent, renderIcon } from "@ai-matrx/icons";
|
|
34
|
+
|
|
35
|
+
// The unified component — static, dynamic, custom, and svg: names all work:
|
|
36
|
+
<IconResolver iconName="AlarmClock" className="h-4 w-4" />
|
|
37
|
+
|
|
38
|
+
// Color/size convenience wrapper (Tailwind color names or hex):
|
|
39
|
+
<DynamicIcon name="Home" color="blue" size={5} />
|
|
40
|
+
<DynamicIcon name="Home" color="#ff6600" size={5} />
|
|
41
|
+
|
|
42
|
+
// Synchronous lookup (static map + already-cached icons only; always returns a component):
|
|
43
|
+
const Icon = getIconComponent("Settings");
|
|
44
|
+
|
|
45
|
+
// Direct element render:
|
|
46
|
+
{renderIcon("Check", { className: "h-4 w-4" })}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Existence checks (never infer existence from `getIconComponent`, which always returns a
|
|
50
|
+
component): `isIconRegisteredSync(name)` for the synchronous registries,
|
|
51
|
+
`await isRegisteredOrLucideIconName(name)` for the full check including the Lucide catalog.
|
|
52
|
+
|
|
53
|
+
Name normalization for user-typed/pasted input: `collectLucideIconNameCandidates("alarm-clock")`
|
|
54
|
+
→ `["alarm-clock", "Alarm-clock", "AlarmClock"]`, and `extractLucideJsxIconName("<BugPlay />")`
|
|
55
|
+
→ `"BugPlay"` — validate candidates with `isRegisteredOrLucideIconName`.
|
|
56
|
+
|
|
57
|
+
Icon pickers: `getCuratedIconIdsForPicker()` returns the finite, sorted set of every
|
|
58
|
+
static Lucide name, curated brand id, and registered `svg:` id.
|
|
59
|
+
|
|
60
|
+
## Registering your app's SVG assets
|
|
61
|
+
|
|
62
|
+
The package ships with an **empty** `svg:` registry — register your public asset paths
|
|
63
|
+
once at startup (any module that runs before icons render):
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { registerSvgIcons } from "@ai-matrx/icons";
|
|
67
|
+
|
|
68
|
+
registerSvgIcons({
|
|
69
|
+
"icons/Home": "/icons/Home.svg",
|
|
70
|
+
"icons/brands/microsoft": "/icons/brands/microsoft.svg",
|
|
71
|
+
"icons/copy": "/icons/copy.svg",
|
|
72
|
+
"icons/hamburger": "/icons/hamburger.svg",
|
|
73
|
+
"icons/loading-circle": "/icons/loading-circle.svg",
|
|
74
|
+
"icons/logo": "/icons/logo.svg",
|
|
75
|
+
"icons/play": "/icons/play.svg",
|
|
76
|
+
"icons/share": "/icons/share.svg",
|
|
77
|
+
"icons/three-dots": "/icons/three-dots.svg",
|
|
78
|
+
"matrx/matrx-icon": "/matrx/matrx-icon.svg",
|
|
79
|
+
"matrx/matrx-icon-blue": "/matrx/matrx-icon-blue.svg",
|
|
80
|
+
"matrx/matrx-icon-cyan": "/matrx/matrx-icon-cyan.svg",
|
|
81
|
+
"matrx/matrx-icon-green": "/matrx/matrx-icon-green.svg",
|
|
82
|
+
"matrx/matrx-icon-indigo": "/matrx/matrx-icon-indigo.svg",
|
|
83
|
+
"matrx/matrx-icon-orange": "/matrx/matrx-icon-orange.svg",
|
|
84
|
+
"matrx/matrx-icon-pink": "/matrx/matrx-icon-pink.svg",
|
|
85
|
+
"matrx/matrx-icon-purple": "/matrx/matrx-icon-purple.svg",
|
|
86
|
+
"matrx/matrx-icon-slate": "/matrx/matrx-icon-slate.svg",
|
|
87
|
+
"matrx/matrx-icon-teal": "/matrx/matrx-icon-teal.svg",
|
|
88
|
+
"matrx/matrx-icon-yellow": "/matrx/matrx-icon-yellow.svg",
|
|
89
|
+
"matrx/matrx-imagen-logo-text": "/matrx/matrx-imagen-logo-text.svg",
|
|
90
|
+
"matrx/safari-pinned-tab": "/matrx/safari-pinned-tab.svg",
|
|
91
|
+
"dark-turbulence-noise": "/dark-turbulence-noise.svg",
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Then `<IconResolver iconName="svg:matrx/matrx-icon" size={24} />` renders
|
|
96
|
+
`<img src="/matrx/matrx-icon.svg" …>`. Calls merge, so features can register their own
|
|
97
|
+
ids independently. An unregistered `svg:` id falls back like any unknown name.
|
|
98
|
+
|
|
99
|
+
## Keeping your own hot icons synchronous
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { BrainCircuit } from "lucide-react";
|
|
103
|
+
import { extendStaticIcons } from "@ai-matrx/icons";
|
|
104
|
+
|
|
105
|
+
extendStaticIcons({ BrainCircuit }); // now a zero-latency static hit everywhere
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Design
|
|
109
|
+
|
|
110
|
+
- The static map + validated dynamic import + module cache + fallback-while-loading
|
|
111
|
+
architecture **is** the product; the curated hot set ships in the package.
|
|
112
|
+
- `react-icons` is optional by construction: it is only ever loaded lazily, and every
|
|
113
|
+
path degrades to the fallback icon when it is absent.
|
|
114
|
+
- Class names in helpers (`getTextColorClass`, `DynamicIcon` sizing) are Tailwind-shaped
|
|
115
|
+
strings; the package ships no CSS.
|
|
116
|
+
- ESM + CommonJS conditions with matching declarations, proven from the packed tarball,
|
|
117
|
+
`"use client"` stamped on every built chunk.
|
|
118
|
+
|
|
119
|
+
MIT © AI Matrx
|