@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/dist/index.js ADDED
@@ -0,0 +1,686 @@
1
+ "use client";
2
+
3
+ // src/static-icons.ts
4
+ import {
5
+ Zap,
6
+ Home,
7
+ User,
8
+ Settings,
9
+ Search,
10
+ Bell,
11
+ Menu,
12
+ X,
13
+ ChevronDown,
14
+ ChevronUp,
15
+ ChevronLeft,
16
+ ChevronRight,
17
+ Plus,
18
+ Minus,
19
+ Edit,
20
+ Trash,
21
+ Check,
22
+ AlertCircle,
23
+ Info,
24
+ HelpCircle,
25
+ Eye,
26
+ EyeOff,
27
+ Copy,
28
+ Download,
29
+ Upload,
30
+ Save,
31
+ MoreVertical,
32
+ MoreHorizontal,
33
+ Filter,
34
+ SortAsc,
35
+ SortDesc,
36
+ Calendar,
37
+ Clock,
38
+ Mail,
39
+ Phone,
40
+ MapPin,
41
+ Link,
42
+ ExternalLink,
43
+ File,
44
+ Folder,
45
+ Image,
46
+ Video,
47
+ Music,
48
+ FileText,
49
+ Database,
50
+ Cloud,
51
+ Server,
52
+ Code,
53
+ Terminal,
54
+ Globe,
55
+ Lock,
56
+ Unlock,
57
+ Shield,
58
+ Key,
59
+ LogIn,
60
+ LogOut,
61
+ UserPlus,
62
+ Users,
63
+ Star,
64
+ Heart,
65
+ Bookmark,
66
+ Share,
67
+ Send,
68
+ MessageSquare,
69
+ MessageCircle,
70
+ Hash,
71
+ AtSign,
72
+ Paperclip,
73
+ Mic,
74
+ Volume2,
75
+ Play,
76
+ Pause,
77
+ SkipForward,
78
+ SkipBack,
79
+ RefreshCw,
80
+ RotateCw,
81
+ Loader,
82
+ Loader2,
83
+ Circle,
84
+ Square,
85
+ Triangle,
86
+ Hexagon,
87
+ Package,
88
+ Box,
89
+ Archive,
90
+ Inbox,
91
+ Layers,
92
+ Layout,
93
+ Grid,
94
+ List,
95
+ Columns,
96
+ Sidebar,
97
+ Maximize,
98
+ Minimize,
99
+ ZoomIn,
100
+ ZoomOut,
101
+ Move,
102
+ Scissors,
103
+ Clipboard,
104
+ PieChart,
105
+ BarChart,
106
+ TrendingUp,
107
+ TrendingDown,
108
+ Activity,
109
+ Cpu,
110
+ HardDrive,
111
+ Wifi,
112
+ WifiOff,
113
+ Bluetooth,
114
+ Battery,
115
+ BatteryCharging,
116
+ Power,
117
+ Sun,
118
+ Moon,
119
+ CloudRain,
120
+ Droplet,
121
+ Wind,
122
+ Tag,
123
+ Tags,
124
+ Flag,
125
+ Award,
126
+ Gift,
127
+ ShoppingCart,
128
+ CreditCard,
129
+ DollarSign,
130
+ Percent,
131
+ Target,
132
+ Crosshair,
133
+ Navigation,
134
+ Compass,
135
+ Map,
136
+ Smile,
137
+ Frown,
138
+ Meh,
139
+ ThumbsUp,
140
+ ThumbsDown
141
+ } from "lucide-react";
142
+ var staticLucideIconMap = {
143
+ Zap,
144
+ Home,
145
+ User,
146
+ Settings,
147
+ Search,
148
+ Bell,
149
+ Menu,
150
+ X,
151
+ ChevronDown,
152
+ ChevronUp,
153
+ ChevronLeft,
154
+ ChevronRight,
155
+ Plus,
156
+ Minus,
157
+ Edit,
158
+ Trash,
159
+ Check,
160
+ AlertCircle,
161
+ Info,
162
+ HelpCircle,
163
+ Eye,
164
+ EyeOff,
165
+ Copy,
166
+ Download,
167
+ Upload,
168
+ Save,
169
+ MoreVertical,
170
+ MoreHorizontal,
171
+ Filter,
172
+ SortAsc,
173
+ SortDesc,
174
+ Calendar,
175
+ Clock,
176
+ Mail,
177
+ Phone,
178
+ MapPin,
179
+ Link,
180
+ ExternalLink,
181
+ File,
182
+ Folder,
183
+ Image,
184
+ Video,
185
+ Music,
186
+ FileText,
187
+ Database,
188
+ Cloud,
189
+ Server,
190
+ Code,
191
+ Terminal,
192
+ Globe,
193
+ Lock,
194
+ Unlock,
195
+ Shield,
196
+ Key,
197
+ LogIn,
198
+ LogOut,
199
+ UserPlus,
200
+ Users,
201
+ Star,
202
+ Heart,
203
+ Bookmark,
204
+ Share,
205
+ Send,
206
+ MessageSquare,
207
+ MessageCircle,
208
+ Hash,
209
+ AtSign,
210
+ Paperclip,
211
+ Mic,
212
+ Volume2,
213
+ Play,
214
+ Pause,
215
+ SkipForward,
216
+ SkipBack,
217
+ RefreshCw,
218
+ RotateCw,
219
+ Loader,
220
+ Loader2,
221
+ Circle,
222
+ Square,
223
+ Triangle,
224
+ Hexagon,
225
+ Package,
226
+ Box,
227
+ Archive,
228
+ Inbox,
229
+ Layers,
230
+ Layout,
231
+ Grid,
232
+ List,
233
+ Columns,
234
+ Sidebar,
235
+ Maximize,
236
+ Minimize,
237
+ ZoomIn,
238
+ ZoomOut,
239
+ Move,
240
+ Scissors,
241
+ Clipboard,
242
+ PieChart,
243
+ BarChart,
244
+ TrendingUp,
245
+ TrendingDown,
246
+ Activity,
247
+ Cpu,
248
+ HardDrive,
249
+ Wifi,
250
+ WifiOff,
251
+ Bluetooth,
252
+ Battery,
253
+ BatteryCharging,
254
+ Power,
255
+ Sun,
256
+ Moon,
257
+ CloudRain,
258
+ Droplet,
259
+ Wind,
260
+ Tag,
261
+ Tags,
262
+ Flag,
263
+ Award,
264
+ Gift,
265
+ ShoppingCart,
266
+ CreditCard,
267
+ DollarSign,
268
+ Percent,
269
+ Target,
270
+ Crosshair,
271
+ Navigation,
272
+ Compass,
273
+ Map,
274
+ Smile,
275
+ Frown,
276
+ Meh,
277
+ ThumbsUp,
278
+ ThumbsDown
279
+ };
280
+ function extendStaticIcons(map) {
281
+ Object.assign(staticLucideIconMap, map);
282
+ }
283
+
284
+ // src/custom-icons.ts
285
+ var CUSTOM_ICON_SOURCES = {
286
+ FaBrave: "fa6",
287
+ FcGoogle: "fc",
288
+ FcBrokenLink: "fc",
289
+ FcFilm: "fc",
290
+ FcDownload: "fc",
291
+ FcBiotech: "fc",
292
+ FcElectronics: "fc",
293
+ FcGraduationCap: "fc",
294
+ FcLibrary: "fc",
295
+ FcMusic: "fc",
296
+ FcParallelTasks: "fc",
297
+ FcSalesPerformance: "fc",
298
+ FcCalendar: "fc",
299
+ FcDocument: "fc",
300
+ FcEngineering: "fc",
301
+ FcDataProtection: "fc",
302
+ FcAssistant: "fc",
303
+ FcSms: "fc",
304
+ FcTodoList: "fc",
305
+ FcWikipedia: "fc",
306
+ FcCommandLine: "fc",
307
+ FcConferenceCall: "fc",
308
+ FcManager: "fc",
309
+ FcAreaChart: "fc",
310
+ FcMultipleInputs: "fc",
311
+ FcShipped: "fc",
312
+ FcBusinessContact: "fc",
313
+ FcAlphabeticalSortingAz: "fc",
314
+ FcAlphabeticalSortingZa: "fc",
315
+ FcFeedback: "fc",
316
+ FcBusiness: "fc",
317
+ FcSignature: "fc"
318
+ };
319
+ var customIconCache = {};
320
+ function isCustomIconName(name) {
321
+ return Object.prototype.hasOwnProperty.call(CUSTOM_ICON_SOURCES, name);
322
+ }
323
+ function listCustomIconNames() {
324
+ return Object.keys(CUSTOM_ICON_SOURCES);
325
+ }
326
+ async function loadCustomIcon(name) {
327
+ const cached = customIconCache[name];
328
+ if (cached) {
329
+ return cached;
330
+ }
331
+ const source = CUSTOM_ICON_SOURCES[name];
332
+ if (!source) {
333
+ return null;
334
+ }
335
+ try {
336
+ const mod = source === "fc" ? await import("react-icons/fc") : await import("react-icons/fa6");
337
+ const exported = mod[name];
338
+ if (typeof exported !== "function") {
339
+ return null;
340
+ }
341
+ const IconComponent = exported;
342
+ customIconCache[name] = IconComponent;
343
+ return IconComponent;
344
+ } catch {
345
+ return null;
346
+ }
347
+ }
348
+
349
+ // src/svg-registry.ts
350
+ var svgIconRegistry = {};
351
+ var SVG_PREFIX = "svg:";
352
+ function registerSvgIcons(map) {
353
+ for (const [rawId, path] of Object.entries(map)) {
354
+ const id = rawId.startsWith(SVG_PREFIX) ? rawId.slice(SVG_PREFIX.length).replace(/^\/+/, "") : rawId.replace(/^\/+/, "");
355
+ if (id && path) {
356
+ svgIconRegistry[id] = path;
357
+ }
358
+ }
359
+ }
360
+ function parseSvgIconPath(value) {
361
+ if (!value.startsWith(SVG_PREFIX)) {
362
+ return null;
363
+ }
364
+ const id = value.slice(SVG_PREFIX.length).replace(/^\/+/, "");
365
+ const path = svgIconRegistry[id];
366
+ return path ?? null;
367
+ }
368
+ function isSvgIconValue(value) {
369
+ if (!value || !value.startsWith(SVG_PREFIX)) {
370
+ return false;
371
+ }
372
+ const id = value.slice(SVG_PREFIX.length).replace(/^\/+/, "");
373
+ return Boolean(svgIconRegistry[id]);
374
+ }
375
+ function listSvgIconValues() {
376
+ return Object.keys(svgIconRegistry).map((id) => `${SVG_PREFIX}${id}`);
377
+ }
378
+
379
+ // src/lucide-name-normalize.ts
380
+ function extractLucideJsxIconName(raw) {
381
+ let s = raw.trim();
382
+ if (!s) return null;
383
+ if (s.startsWith("'") && s.endsWith("'") && s.length >= 2 || s.startsWith('"') && s.endsWith('"') && s.length >= 2) {
384
+ s = s.slice(1, -1).trim();
385
+ }
386
+ const m = s.match(/^<\s*([A-Za-z][A-Za-z0-9]*)(?:\s[^>]*)?\s*\/\s*>$/);
387
+ return m?.[1] ?? null;
388
+ }
389
+ function kebabCaseToLucidePascalCase(raw) {
390
+ const s = raw.trim();
391
+ if (!s.includes("-")) {
392
+ return s;
393
+ }
394
+ return s.split("-").filter(Boolean).map((seg) => seg.charAt(0).toUpperCase() + seg.slice(1).toLowerCase()).join("");
395
+ }
396
+ function collectLucideIconNameCandidates(raw) {
397
+ const t = raw.trim();
398
+ if (!t) {
399
+ return [];
400
+ }
401
+ const out = [];
402
+ const push = (s) => {
403
+ if (s && !out.includes(s)) {
404
+ out.push(s);
405
+ }
406
+ };
407
+ push(t);
408
+ if (t[0] === t[0].toLowerCase()) {
409
+ push(t.charAt(0).toUpperCase() + t.slice(1));
410
+ }
411
+ if (t.includes("-")) {
412
+ push(kebabCaseToLucidePascalCase(t));
413
+ const lower = t.toLowerCase();
414
+ if (lower !== t) {
415
+ push(kebabCaseToLucidePascalCase(lower));
416
+ }
417
+ }
418
+ return out;
419
+ }
420
+
421
+ // src/lucide-module-icon.ts
422
+ var LUCIDE_NAMESPACE_DENYLIST = /* @__PURE__ */ new Set(["default", "createLucideIcon"]);
423
+ function isLucideModuleIconExport(name, exported) {
424
+ if (!name || LUCIDE_NAMESPACE_DENYLIST.has(name)) return false;
425
+ if (exported == null) return false;
426
+ if (typeof exported === "function") return true;
427
+ if (typeof exported === "object" && "$$typeof" in exported) {
428
+ return true;
429
+ }
430
+ return false;
431
+ }
432
+
433
+ // src/resolver.tsx
434
+ import { useState, useEffect } from "react";
435
+
436
+ // src/cn.ts
437
+ function cn(...values) {
438
+ return values.filter(Boolean).join(" ").trim();
439
+ }
440
+
441
+ // src/resolver.tsx
442
+ import { jsx } from "react/jsx-runtime";
443
+ var dynamicIconCache = {};
444
+ function getCuratedIconIdsForPicker() {
445
+ const set = /* @__PURE__ */ new Set();
446
+ for (const k of Object.keys(staticLucideIconMap)) {
447
+ set.add(k);
448
+ }
449
+ for (const k of listCustomIconNames()) {
450
+ set.add(k);
451
+ }
452
+ for (const id of listSvgIconValues()) {
453
+ set.add(id);
454
+ }
455
+ return Array.from(set).sort(
456
+ (a, b) => a.localeCompare(b, void 0, { sensitivity: "base" })
457
+ );
458
+ }
459
+ function isIconRegisteredSync(iconName) {
460
+ if (!iconName || iconName.trim() === "") {
461
+ return false;
462
+ }
463
+ const name = iconName;
464
+ if (isCustomIconName(name)) return true;
465
+ if (staticLucideIconMap[name]) return true;
466
+ return Boolean(dynamicIconCache[name]);
467
+ }
468
+ async function isRegisteredOrLucideIconName(iconName) {
469
+ if (!iconName || iconName.trim() === "") {
470
+ return false;
471
+ }
472
+ if (isSvgIconValue(iconName)) {
473
+ return true;
474
+ }
475
+ if (isIconRegisteredSync(iconName)) {
476
+ return true;
477
+ }
478
+ try {
479
+ const iconModule = await import("lucide-react");
480
+ const Exported = iconModule[iconName];
481
+ return isLucideModuleIconExport(iconName, Exported);
482
+ } catch {
483
+ return false;
484
+ }
485
+ }
486
+ var IconResolver = ({
487
+ iconName,
488
+ className = "h-4 w-4",
489
+ size,
490
+ fallbackIcon = "Zap",
491
+ style
492
+ }) => {
493
+ const svgSrc = iconName ? parseSvgIconPath(iconName) : null;
494
+ const [DynamicIcon2, setDynamicIcon] = useState(null);
495
+ const [isLoading, setIsLoading] = useState(false);
496
+ useEffect(() => {
497
+ const loadIcon = async () => {
498
+ if (!iconName) {
499
+ setDynamicIcon(null);
500
+ setIsLoading(false);
501
+ return;
502
+ }
503
+ if (parseSvgIconPath(iconName)) {
504
+ setDynamicIcon(null);
505
+ setIsLoading(false);
506
+ return;
507
+ }
508
+ const cachedCustom = customIconCache[iconName];
509
+ if (cachedCustom) {
510
+ setDynamicIcon(() => cachedCustom);
511
+ return;
512
+ }
513
+ const staticIcon = staticLucideIconMap[iconName];
514
+ if (staticIcon) {
515
+ setDynamicIcon(() => staticIcon);
516
+ return;
517
+ }
518
+ const cachedDynamic = dynamicIconCache[iconName];
519
+ if (cachedDynamic) {
520
+ setDynamicIcon(() => cachedDynamic);
521
+ return;
522
+ }
523
+ if (isCustomIconName(iconName)) {
524
+ setIsLoading(true);
525
+ const loaded = await loadCustomIcon(iconName);
526
+ if (loaded) {
527
+ setDynamicIcon(() => loaded);
528
+ } else {
529
+ setDynamicIcon(() => staticLucideIconMap[fallbackIcon] || Zap);
530
+ }
531
+ setIsLoading(false);
532
+ return;
533
+ }
534
+ setIsLoading(true);
535
+ try {
536
+ const iconModule = await import("lucide-react");
537
+ const exported = iconModule[iconName];
538
+ if (isLucideModuleIconExport(iconName, exported)) {
539
+ const IconComponent2 = exported;
540
+ dynamicIconCache[iconName] = IconComponent2;
541
+ setDynamicIcon(() => IconComponent2);
542
+ } else {
543
+ setDynamicIcon(() => staticLucideIconMap[fallbackIcon] || Zap);
544
+ }
545
+ } catch (error) {
546
+ console.warn(`Failed to load icon: ${iconName}`, error);
547
+ setDynamicIcon(() => staticLucideIconMap[fallbackIcon] || Zap);
548
+ } finally {
549
+ setIsLoading(false);
550
+ }
551
+ };
552
+ loadIcon();
553
+ }, [iconName, fallbackIcon]);
554
+ if (svgSrc) {
555
+ return /* @__PURE__ */ jsx(
556
+ "img",
557
+ {
558
+ src: svgSrc,
559
+ alt: "",
560
+ className: cn("object-contain shrink-0", className),
561
+ width: size,
562
+ height: size,
563
+ style
564
+ }
565
+ );
566
+ }
567
+ const IconComponent = DynamicIcon2 || staticLucideIconMap[fallbackIcon] || Zap;
568
+ const iconProps = {
569
+ ...className !== void 0 ? { className } : {},
570
+ ...size !== void 0 ? { size } : {},
571
+ ...style !== void 0 ? { style } : {}
572
+ };
573
+ if (isLoading && !DynamicIcon2) {
574
+ const FallbackIcon = staticLucideIconMap[fallbackIcon] || Zap;
575
+ return /* @__PURE__ */ jsx(FallbackIcon, { ...iconProps });
576
+ }
577
+ return /* @__PURE__ */ jsx(IconComponent, { ...iconProps });
578
+ };
579
+ var resolver_default = IconResolver;
580
+ var getIconComponent = (iconName, fallbackIcon = "Zap") => {
581
+ if (!iconName) {
582
+ return staticLucideIconMap[fallbackIcon] || Zap;
583
+ }
584
+ const custom = customIconCache[iconName];
585
+ if (custom) {
586
+ return custom;
587
+ }
588
+ const staticIcon = staticLucideIconMap[iconName];
589
+ if (staticIcon) {
590
+ return staticIcon;
591
+ }
592
+ const dynamic = dynamicIconCache[iconName];
593
+ if (dynamic) {
594
+ return dynamic;
595
+ }
596
+ return staticLucideIconMap[fallbackIcon] || Zap;
597
+ };
598
+ var renderIcon = (iconName, props, fallbackIcon = "Zap") => {
599
+ const IconComponent = getIconComponent(iconName, fallbackIcon);
600
+ return /* @__PURE__ */ jsx(IconComponent, { ...props });
601
+ };
602
+ var isHexColor = (color) => {
603
+ return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color);
604
+ };
605
+ var getTextColorClass = (color) => {
606
+ if (!color) return "text-gray-600 dark:text-gray-400";
607
+ if (isHexColor(color)) return null;
608
+ const colorMap = {
609
+ gray: "text-gray-600 dark:text-gray-400",
610
+ rose: "text-rose-600 dark:text-rose-400",
611
+ blue: "text-blue-600 dark:text-blue-400",
612
+ amber: "text-amber-600 dark:text-amber-400",
613
+ cyan: "text-cyan-600 dark:text-cyan-400",
614
+ emerald: "text-emerald-600 dark:text-emerald-400",
615
+ fuchsia: "text-fuchsia-600 dark:text-fuchsia-400",
616
+ green: "text-green-600 dark:text-green-400",
617
+ indigo: "text-indigo-600 dark:text-indigo-400",
618
+ lime: "text-lime-600 dark:text-lime-400",
619
+ neutral: "text-neutral-600 dark:text-neutral-400",
620
+ orange: "text-orange-600 dark:text-orange-400",
621
+ pink: "text-pink-600 dark:text-pink-400",
622
+ purple: "text-purple-600 dark:text-purple-400",
623
+ red: "text-red-600 dark:text-red-400",
624
+ sky: "text-sky-600 dark:text-sky-400",
625
+ slate: "text-slate-600 dark:text-slate-400",
626
+ stone: "text-stone-600 dark:text-stone-400",
627
+ teal: "text-teal-600 dark:text-teal-400",
628
+ violet: "text-violet-600 dark:text-violet-400",
629
+ yellow: "text-yellow-600 dark:text-yellow-400",
630
+ zinc: "text-zinc-600 dark:text-zinc-400"
631
+ };
632
+ return colorMap[color.toLowerCase()] || "text-gray-600 dark:text-gray-400";
633
+ };
634
+ var getIconWithColorAndSize = (iconName, color = "gray", size = 4) => {
635
+ const IconComponent = getIconComponent(iconName);
636
+ const colorClass = getTextColorClass(color);
637
+ return /* @__PURE__ */ jsx(IconComponent, { className: `h-${size} w-${size} ${colorClass}` });
638
+ };
639
+ var DynamicIcon = ({
640
+ name,
641
+ color = "gray",
642
+ size = 4,
643
+ className,
644
+ fallbackIcon = "Zap"
645
+ }) => {
646
+ const isHex = color && isHexColor(color);
647
+ const colorClass = isHex ? null : getTextColorClass(color);
648
+ const sizeClass = `h-${size} w-${size}`;
649
+ const combinedClassName = [sizeClass, !isHex && colorClass, className].filter(Boolean).join(" ").trim();
650
+ const style = isHex ? { color } : void 0;
651
+ return /* @__PURE__ */ jsx(
652
+ IconResolver,
653
+ {
654
+ iconName: name,
655
+ className: combinedClassName,
656
+ fallbackIcon,
657
+ style
658
+ }
659
+ );
660
+ };
661
+ export {
662
+ DynamicIcon,
663
+ resolver_default as IconResolver,
664
+ collectLucideIconNameCandidates,
665
+ extendStaticIcons,
666
+ extractLucideJsxIconName,
667
+ getCuratedIconIdsForPicker,
668
+ getIconComponent,
669
+ getIconWithColorAndSize,
670
+ getTextColorClass,
671
+ isCustomIconName,
672
+ isHexColor,
673
+ isIconRegisteredSync,
674
+ isLucideModuleIconExport,
675
+ isRegisteredOrLucideIconName,
676
+ isSvgIconValue,
677
+ kebabCaseToLucidePascalCase,
678
+ listCustomIconNames,
679
+ listSvgIconValues,
680
+ loadCustomIcon,
681
+ parseSvgIconPath,
682
+ registerSvgIcons,
683
+ renderIcon,
684
+ staticLucideIconMap
685
+ };
686
+ //# sourceMappingURL=index.js.map