ngx-com 0.0.13 → 0.0.14
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.
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, computed, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { Injectable, inject, input, computed, ViewEncapsulation, ChangeDetectionStrategy, Component, makeEnvironmentProviders, ENVIRONMENT_INITIALIZER } from '@angular/core';
|
|
3
3
|
import * as i1 from 'lucide-angular';
|
|
4
|
-
import { LucideAngularModule
|
|
4
|
+
import { LucideAngularModule } from 'lucide-angular';
|
|
5
5
|
import { cva } from 'class-variance-authority';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Singleton registry for Lucide icons used by `com-icon`.
|
|
9
|
+
*
|
|
10
|
+
* Unlike lucide-angular's `LUCIDE_ICONS` token (which gets shadowed by child injectors),
|
|
11
|
+
* this registry lives at root and merges all icons registered via `provideComIcons()`.
|
|
12
|
+
*/
|
|
13
|
+
class ComIconRegistry {
|
|
14
|
+
icons = {};
|
|
15
|
+
/** Merges the given icons into the registry. */
|
|
16
|
+
register(icons) {
|
|
17
|
+
Object.assign(this.icons, icons);
|
|
18
|
+
}
|
|
19
|
+
/** Returns the icon data for the given PascalCase name, or `null` if not registered. */
|
|
20
|
+
get(name) {
|
|
21
|
+
return this.icons[name] ?? null;
|
|
22
|
+
}
|
|
23
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: ComIconRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
24
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: ComIconRegistry, providedIn: 'root' });
|
|
25
|
+
}
|
|
26
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: ComIconRegistry, decorators: [{
|
|
27
|
+
type: Injectable,
|
|
28
|
+
args: [{ providedIn: 'root' }]
|
|
29
|
+
}] });
|
|
30
|
+
|
|
7
31
|
const iconVariants = cva('inline-flex items-center justify-center shrink-0 align-middle', {
|
|
8
32
|
variants: {
|
|
9
33
|
color: {
|
|
@@ -39,6 +63,14 @@ const ICON_SIZE_PX = {
|
|
|
39
63
|
'2xl': 40,
|
|
40
64
|
};
|
|
41
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Converts a kebab-case or space-separated icon name to PascalCase.
|
|
68
|
+
*
|
|
69
|
+
* Uses the same regex as lucide-angular for consistency.
|
|
70
|
+
*/
|
|
71
|
+
function toPascalCase(str) {
|
|
72
|
+
return str.replace(/(\w)([a-z0-9]*)(_|-|\s*)/g, (_g0, g1, g2) => g1.toUpperCase() + g2.toLowerCase());
|
|
73
|
+
}
|
|
42
74
|
/**
|
|
43
75
|
* Icon component — renders Lucide icons with CVA-powered color and size variants.
|
|
44
76
|
*
|
|
@@ -76,6 +108,7 @@ const ICON_SIZE_PX = {
|
|
|
76
108
|
* ```
|
|
77
109
|
*/
|
|
78
110
|
class ComIcon {
|
|
111
|
+
registry = inject(ComIconRegistry);
|
|
79
112
|
/** Icon name in kebab-case (e.g. 'chevron-right'). Requires provideComIcons registration. */
|
|
80
113
|
name = input(...(ngDevMode ? [undefined, { debugName: "name" }] : []));
|
|
81
114
|
/** Direct Lucide icon reference. Takes precedence over `name`. */
|
|
@@ -90,23 +123,23 @@ class ComIcon {
|
|
|
90
123
|
absoluteStrokeWidth = input(false, ...(ngDevMode ? [{ debugName: "absoluteStrokeWidth" }] : []));
|
|
91
124
|
/** Applies aria-label and removes aria-hidden. Use for meaningful icons. */
|
|
92
125
|
ariaLabel = input(...(ngDevMode ? [undefined, { debugName: "ariaLabel" }] : []));
|
|
126
|
+
/** Resolves icon data from either `img` (direct ref) or `name` (registry lookup). */
|
|
127
|
+
resolvedIcon = computed(() => {
|
|
128
|
+
const imgData = this.img();
|
|
129
|
+
if (imgData)
|
|
130
|
+
return imgData;
|
|
131
|
+
const iconName = this.name();
|
|
132
|
+
if (iconName)
|
|
133
|
+
return this.registry.get(toPascalCase(iconName)) ?? undefined;
|
|
134
|
+
return undefined;
|
|
135
|
+
}, ...(ngDevMode ? [{ debugName: "resolvedIcon" }] : []));
|
|
93
136
|
sizeInPx = computed(() => ICON_SIZE_PX[this.size()], ...(ngDevMode ? [{ debugName: "sizeInPx" }] : []));
|
|
94
137
|
hostClasses = computed(() => iconVariants({ color: this.color(), size: this.size() }), ...(ngDevMode ? [{ debugName: "hostClasses" }] : []));
|
|
95
138
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: ComIcon, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
96
139
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: ComIcon, isStandalone: true, selector: "com-icon", inputs: { name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, img: { classPropertyName: "img", publicName: "img", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, strokeWidth: { classPropertyName: "strokeWidth", publicName: "strokeWidth", isSignal: true, isRequired: false, transformFunction: null }, absoluteStrokeWidth: { classPropertyName: "absoluteStrokeWidth", publicName: "absoluteStrokeWidth", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "hostClasses()" } }, ngImport: i0, template: `
|
|
97
|
-
@if (
|
|
140
|
+
@if (resolvedIcon(); as iconData) {
|
|
98
141
|
<lucide-icon
|
|
99
|
-
[img]="
|
|
100
|
-
[size]="sizeInPx()"
|
|
101
|
-
[strokeWidth]="strokeWidth()"
|
|
102
|
-
[absoluteStrokeWidth]="absoluteStrokeWidth()"
|
|
103
|
-
color="currentColor"
|
|
104
|
-
[attr.aria-label]="ariaLabel() ?? null"
|
|
105
|
-
[attr.aria-hidden]="ariaLabel() ? null : 'true'"
|
|
106
|
-
/>
|
|
107
|
-
} @else if (name(); as iconName) {
|
|
108
|
-
<lucide-icon
|
|
109
|
-
[name]="iconName"
|
|
142
|
+
[img]="iconData"
|
|
110
143
|
[size]="sizeInPx()"
|
|
111
144
|
[strokeWidth]="strokeWidth()"
|
|
112
145
|
[absoluteStrokeWidth]="absoluteStrokeWidth()"
|
|
@@ -122,19 +155,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
|
|
|
122
155
|
args: [{
|
|
123
156
|
selector: 'com-icon',
|
|
124
157
|
template: `
|
|
125
|
-
@if (
|
|
158
|
+
@if (resolvedIcon(); as iconData) {
|
|
126
159
|
<lucide-icon
|
|
127
|
-
[img]="
|
|
128
|
-
[size]="sizeInPx()"
|
|
129
|
-
[strokeWidth]="strokeWidth()"
|
|
130
|
-
[absoluteStrokeWidth]="absoluteStrokeWidth()"
|
|
131
|
-
color="currentColor"
|
|
132
|
-
[attr.aria-label]="ariaLabel() ?? null"
|
|
133
|
-
[attr.aria-hidden]="ariaLabel() ? null : 'true'"
|
|
134
|
-
/>
|
|
135
|
-
} @else if (name(); as iconName) {
|
|
136
|
-
<lucide-icon
|
|
137
|
-
[name]="iconName"
|
|
160
|
+
[img]="iconData"
|
|
138
161
|
[size]="sizeInPx()"
|
|
139
162
|
[strokeWidth]="strokeWidth()"
|
|
140
163
|
[absoluteStrokeWidth]="absoluteStrokeWidth()"
|
|
@@ -156,7 +179,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
|
|
|
156
179
|
/**
|
|
157
180
|
* Provides Lucide icons for use with `com-icon`.
|
|
158
181
|
*
|
|
159
|
-
*
|
|
182
|
+
* Icons are merged into a root-level registry, so multiple calls
|
|
183
|
+
* (e.g. at root and in lazy routes) accumulate rather than shadow.
|
|
160
184
|
*
|
|
161
185
|
* @example
|
|
162
186
|
* ```ts
|
|
@@ -170,14 +194,30 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
|
|
|
170
194
|
* ]
|
|
171
195
|
* };
|
|
172
196
|
* ```
|
|
197
|
+
*
|
|
198
|
+
* @example Lazy route adds more icons without losing root icons
|
|
199
|
+
* ```ts
|
|
200
|
+
* // feature.routes.ts
|
|
201
|
+
* export const routes: Routes = [{
|
|
202
|
+
* path: '',
|
|
203
|
+
* providers: [provideComIcons({ Settings, User })],
|
|
204
|
+
* component: FeatureComponent,
|
|
205
|
+
* }];
|
|
206
|
+
* ```
|
|
173
207
|
*/
|
|
174
208
|
function provideComIcons(icons) {
|
|
175
|
-
return
|
|
209
|
+
return makeEnvironmentProviders([
|
|
210
|
+
{
|
|
211
|
+
provide: ENVIRONMENT_INITIALIZER,
|
|
212
|
+
multi: true,
|
|
213
|
+
useValue: () => inject(ComIconRegistry).register(icons),
|
|
214
|
+
},
|
|
215
|
+
]);
|
|
176
216
|
}
|
|
177
217
|
|
|
178
218
|
/**
|
|
179
219
|
* Generated bundle index. Do not edit.
|
|
180
220
|
*/
|
|
181
221
|
|
|
182
|
-
export { ComIcon, ICON_SIZE_PX, iconVariants, provideComIcons };
|
|
222
|
+
export { ComIcon, ComIconRegistry, ICON_SIZE_PX, iconVariants, provideComIcons };
|
|
183
223
|
//# sourceMappingURL=ngx-com-components-icon.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-com-components-icon.mjs","sources":["../../../projects/com/components/icon/icon.variants.ts","../../../projects/com/components/icon/icon.component.ts","../../../projects/com/components/icon/icon.providers.ts","../../../projects/com/components/icon/ngx-com-components-icon.ts"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\n\nexport type IconColor = 'current' | 'primary' | 'accent' | 'warn' | 'success' | 'muted' | 'disabled';\nexport type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';\n\nexport const iconVariants: (props?: { color?: IconColor; size?: IconSize }) => string = cva(\n 'inline-flex items-center justify-center shrink-0 align-middle',\n {\n variants: {\n color: {\n current: '',\n primary: 'text-primary',\n accent: 'text-accent',\n warn: 'text-warn',\n success: 'text-success',\n muted: 'text-muted-foreground',\n disabled: 'text-disabled-foreground',\n },\n size: {\n xs: 'size-icon-xs',\n sm: 'size-icon-sm',\n md: 'size-icon-md',\n lg: 'size-icon-lg',\n xl: 'size-icon-xl',\n '2xl': 'size-icon-2xl',\n },\n },\n defaultVariants: {\n color: 'current',\n size: 'lg',\n },\n }\n);\n\n/** Pixel values matching the CSS tokens — passed to Lucide's numeric [size] prop */\nexport const ICON_SIZE_PX: Record<IconSize, number> = {\n xs: 12,\n sm: 16,\n md: 20,\n lg: 24,\n xl: 32,\n '2xl': 40,\n};\n\nexport type IconVariants = VariantProps<typeof iconVariants>;\n","import {\n ChangeDetectionStrategy,\n Component,\n computed,\n input,\n ViewEncapsulation,\n} from '@angular/core';\nimport type { InputSignal, Signal } from '@angular/core';\nimport { LucideAngularModule } from 'lucide-angular';\nimport type { LucideIconData } from 'lucide-angular';\nimport { iconVariants, ICON_SIZE_PX, type IconColor, type IconSize } from './icon.variants';\n\n/**\n * Icon component — renders Lucide icons with CVA-powered color and size variants.\n *\n * Icons inherit `currentColor` by default, making them automatically match\n * surrounding text. Use the `color` input for semantic color variants that\n * respond to theme changes.\n *\n * @tokens `--color-primary`, `--color-accent`, `--color-warn`, `--color-success`,\n * `--color-muted-foreground`, `--color-disabled-foreground`,\n * `--size-icon-xs`, `--size-icon-sm`, `--size-icon-md`,\n * `--size-icon-lg`, `--size-icon-xl`, `--size-icon-2xl`\n *\n * @example Basic usage (requires icon registration via provideComIcons)\n * ```html\n * <com-icon name=\"star\" />\n * <com-icon name=\"check\" color=\"success\" size=\"sm\" />\n * <com-icon name=\"alert-triangle\" color=\"warn\" />\n * ```\n *\n * @example Direct icon reference (no provider needed)\n * ```html\n * <com-icon [img]=\"StarIcon\" color=\"accent\" size=\"2xl\" />\n * ```\n *\n * @example Accessible icon (not decorative)\n * ```html\n * <com-icon name=\"check\" color=\"success\" ariaLabel=\"Task completed\" />\n * ```\n *\n * @example Inline with text (inherits parent color)\n * ```html\n * <span class=\"text-primary\">\n * <com-icon name=\"star\" size=\"sm\" /> Favorite\n * </span>\n * ```\n */\n@Component({\n selector: 'com-icon',\n template: `\n @if (img(); as imgData) {\n <lucide-icon\n [img]=\"imgData\"\n [size]=\"sizeInPx()\"\n [strokeWidth]=\"strokeWidth()\"\n [absoluteStrokeWidth]=\"absoluteStrokeWidth()\"\n color=\"currentColor\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-hidden]=\"ariaLabel() ? null : 'true'\"\n />\n } @else if (name(); as iconName) {\n <lucide-icon\n [name]=\"iconName\"\n [size]=\"sizeInPx()\"\n [strokeWidth]=\"strokeWidth()\"\n [absoluteStrokeWidth]=\"absoluteStrokeWidth()\"\n color=\"currentColor\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-hidden]=\"ariaLabel() ? null : 'true'\"\n />\n }\n `,\n host: {\n '[class]': 'hostClasses()',\n },\n imports: [LucideAngularModule],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n})\nexport class ComIcon {\n /** Icon name in kebab-case (e.g. 'chevron-right'). Requires provideComIcons registration. */\n readonly name: InputSignal<string | undefined> = input<string>();\n\n /** Direct Lucide icon reference. Takes precedence over `name`. */\n readonly img: InputSignal<LucideIconData | undefined> = input<LucideIconData>();\n\n /** Semantic color variant. Defaults to 'current' (inherits from parent). */\n readonly color: InputSignal<IconColor> = input<IconColor>('current');\n\n /** Size variant. Defaults to 'lg' (24px). */\n readonly size: InputSignal<IconSize> = input<IconSize>('lg');\n\n /** Stroke width. Defaults to 2. */\n readonly strokeWidth: InputSignal<number> = input<number>(2);\n\n /** When true, stroke width doesn't scale with icon size. */\n readonly absoluteStrokeWidth: InputSignal<boolean> = input<boolean>(false);\n\n /** Applies aria-label and removes aria-hidden. Use for meaningful icons. */\n readonly ariaLabel: InputSignal<string | undefined> = input<string>();\n\n protected readonly sizeInPx: Signal<number> = computed(() => ICON_SIZE_PX[this.size()]);\n protected readonly hostClasses: Signal<string> = computed(() =>\n iconVariants({ color: this.color(), size: this.size() })\n );\n}\n","import type { Provider } from '@angular/core';\nimport { LUCIDE_ICONS, LucideIconProvider } from 'lucide-angular';\nimport type { LucideIcons } from 'lucide-angular';\n\n/**\n * Provides Lucide icons for use with `com-icon`.\n *\n * Register icons in your application config to use them by name:\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { provideComIcons } from 'ngx-com/components/icon';\n * import { ChevronRight, Star, Check, AlertTriangle } from 'lucide-angular';\n *\n * export const appConfig = {\n * providers: [\n * provideComIcons({ ChevronRight, Star, Check, AlertTriangle })\n * ]\n * };\n * ```\n */\nexport function provideComIcons(icons: LucideIcons): Provider {\n return { provide: LUCIDE_ICONS, useValue: new LucideIconProvider(icons) };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAKO,MAAM,YAAY,GAA+D,GAAG,CACzF,+DAA+D,EAC/D;AACE,IAAA,QAAQ,EAAE;AACR,QAAA,KAAK,EAAE;AACL,YAAA,OAAO,EAAE,EAAE;AACX,YAAA,OAAO,EAAE,cAAc;AACvB,YAAA,MAAM,EAAE,aAAa;AACrB,YAAA,IAAI,EAAE,WAAW;AACjB,YAAA,OAAO,EAAE,cAAc;AACvB,YAAA,KAAK,EAAE,uBAAuB;AAC9B,YAAA,QAAQ,EAAE,0BAA0B;AACrC,SAAA;AACD,QAAA,IAAI,EAAE;AACJ,YAAA,EAAE,EAAE,cAAc;AAClB,YAAA,EAAE,EAAE,cAAc;AAClB,YAAA,EAAE,EAAE,cAAc;A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aAAa,EAAE,iBAAiB,CAAC,IAAI;AACtC,iBAAA;;;AC3ED;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,eAAe,CAAC,KAAkB,EAAA;AAChD,IAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE;AAC3E;;ACxBA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngx-com-components-icon.mjs","sources":["../../../projects/com/components/icon/icon.registry.ts","../../../projects/com/components/icon/icon.variants.ts","../../../projects/com/components/icon/icon.component.ts","../../../projects/com/components/icon/icon.providers.ts","../../../projects/com/components/icon/ngx-com-components-icon.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport type { LucideIconData, LucideIcons } from 'lucide-angular';\n\n/**\n * Singleton registry for Lucide icons used by `com-icon`.\n *\n * Unlike lucide-angular's `LUCIDE_ICONS` token (which gets shadowed by child injectors),\n * this registry lives at root and merges all icons registered via `provideComIcons()`.\n */\n@Injectable({ providedIn: 'root' })\nexport class ComIconRegistry {\n private readonly icons: LucideIcons = {};\n\n /** Merges the given icons into the registry. */\n register(icons: LucideIcons): void {\n Object.assign(this.icons, icons);\n }\n\n /** Returns the icon data for the given PascalCase name, or `null` if not registered. */\n get(name: string): LucideIconData | null {\n return (this.icons[name] as LucideIconData) ?? null;\n }\n}\n","import { cva, type VariantProps } from 'class-variance-authority';\n\nexport type IconColor = 'current' | 'primary' | 'accent' | 'warn' | 'success' | 'muted' | 'disabled';\nexport type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';\n\nexport const iconVariants: (props?: { color?: IconColor; size?: IconSize }) => string = cva(\n 'inline-flex items-center justify-center shrink-0 align-middle',\n {\n variants: {\n color: {\n current: '',\n primary: 'text-primary',\n accent: 'text-accent',\n warn: 'text-warn',\n success: 'text-success',\n muted: 'text-muted-foreground',\n disabled: 'text-disabled-foreground',\n },\n size: {\n xs: 'size-icon-xs',\n sm: 'size-icon-sm',\n md: 'size-icon-md',\n lg: 'size-icon-lg',\n xl: 'size-icon-xl',\n '2xl': 'size-icon-2xl',\n },\n },\n defaultVariants: {\n color: 'current',\n size: 'lg',\n },\n }\n);\n\n/** Pixel values matching the CSS tokens — passed to Lucide's numeric [size] prop */\nexport const ICON_SIZE_PX: Record<IconSize, number> = {\n xs: 12,\n sm: 16,\n md: 20,\n lg: 24,\n xl: 32,\n '2xl': 40,\n};\n\nexport type IconVariants = VariantProps<typeof iconVariants>;\n","import {\n ChangeDetectionStrategy,\n Component,\n computed,\n inject,\n input,\n ViewEncapsulation,\n} from '@angular/core';\nimport type { InputSignal, Signal } from '@angular/core';\nimport { LucideAngularModule } from 'lucide-angular';\nimport type { LucideIconData } from 'lucide-angular';\nimport { ComIconRegistry } from './icon.registry';\nimport { iconVariants, ICON_SIZE_PX, type IconColor, type IconSize } from './icon.variants';\n\n/**\n * Converts a kebab-case or space-separated icon name to PascalCase.\n *\n * Uses the same regex as lucide-angular for consistency.\n */\nfunction toPascalCase(str: string): string {\n return str.replace(/(\\w)([a-z0-9]*)(_|-|\\s*)/g, (_g0, g1: string, g2: string) =>\n g1.toUpperCase() + g2.toLowerCase()\n );\n}\n\n/**\n * Icon component — renders Lucide icons with CVA-powered color and size variants.\n *\n * Icons inherit `currentColor` by default, making them automatically match\n * surrounding text. Use the `color` input for semantic color variants that\n * respond to theme changes.\n *\n * @tokens `--color-primary`, `--color-accent`, `--color-warn`, `--color-success`,\n * `--color-muted-foreground`, `--color-disabled-foreground`,\n * `--size-icon-xs`, `--size-icon-sm`, `--size-icon-md`,\n * `--size-icon-lg`, `--size-icon-xl`, `--size-icon-2xl`\n *\n * @example Basic usage (requires icon registration via provideComIcons)\n * ```html\n * <com-icon name=\"star\" />\n * <com-icon name=\"check\" color=\"success\" size=\"sm\" />\n * <com-icon name=\"alert-triangle\" color=\"warn\" />\n * ```\n *\n * @example Direct icon reference (no provider needed)\n * ```html\n * <com-icon [img]=\"StarIcon\" color=\"accent\" size=\"2xl\" />\n * ```\n *\n * @example Accessible icon (not decorative)\n * ```html\n * <com-icon name=\"check\" color=\"success\" ariaLabel=\"Task completed\" />\n * ```\n *\n * @example Inline with text (inherits parent color)\n * ```html\n * <span class=\"text-primary\">\n * <com-icon name=\"star\" size=\"sm\" /> Favorite\n * </span>\n * ```\n */\n@Component({\n selector: 'com-icon',\n template: `\n @if (resolvedIcon(); as iconData) {\n <lucide-icon\n [img]=\"iconData\"\n [size]=\"sizeInPx()\"\n [strokeWidth]=\"strokeWidth()\"\n [absoluteStrokeWidth]=\"absoluteStrokeWidth()\"\n color=\"currentColor\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-hidden]=\"ariaLabel() ? null : 'true'\"\n />\n }\n `,\n host: {\n '[class]': 'hostClasses()',\n },\n imports: [LucideAngularModule],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n})\nexport class ComIcon {\n private readonly registry = inject(ComIconRegistry);\n\n /** Icon name in kebab-case (e.g. 'chevron-right'). Requires provideComIcons registration. */\n readonly name: InputSignal<string | undefined> = input<string>();\n\n /** Direct Lucide icon reference. Takes precedence over `name`. */\n readonly img: InputSignal<LucideIconData | undefined> = input<LucideIconData>();\n\n /** Semantic color variant. Defaults to 'current' (inherits from parent). */\n readonly color: InputSignal<IconColor> = input<IconColor>('current');\n\n /** Size variant. Defaults to 'lg' (24px). */\n readonly size: InputSignal<IconSize> = input<IconSize>('lg');\n\n /** Stroke width. Defaults to 2. */\n readonly strokeWidth: InputSignal<number> = input<number>(2);\n\n /** When true, stroke width doesn't scale with icon size. */\n readonly absoluteStrokeWidth: InputSignal<boolean> = input<boolean>(false);\n\n /** Applies aria-label and removes aria-hidden. Use for meaningful icons. */\n readonly ariaLabel: InputSignal<string | undefined> = input<string>();\n\n /** Resolves icon data from either `img` (direct ref) or `name` (registry lookup). */\n protected readonly resolvedIcon: Signal<LucideIconData | undefined> = computed(() => {\n const imgData = this.img();\n if (imgData) return imgData;\n\n const iconName = this.name();\n if (iconName) return this.registry.get(toPascalCase(iconName)) ?? undefined;\n\n return undefined;\n });\n\n protected readonly sizeInPx: Signal<number> = computed(() => ICON_SIZE_PX[this.size()]);\n protected readonly hostClasses: Signal<string> = computed(() =>\n iconVariants({ color: this.color(), size: this.size() })\n );\n}\n","import { ENVIRONMENT_INITIALIZER, inject, makeEnvironmentProviders } from '@angular/core';\nimport type { EnvironmentProviders } from '@angular/core';\nimport type { LucideIcons } from 'lucide-angular';\nimport { ComIconRegistry } from './icon.registry';\n\n/**\n * Provides Lucide icons for use with `com-icon`.\n *\n * Icons are merged into a root-level registry, so multiple calls\n * (e.g. at root and in lazy routes) accumulate rather than shadow.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { provideComIcons } from 'ngx-com/components/icon';\n * import { ChevronRight, Star, Check, AlertTriangle } from 'lucide-angular';\n *\n * export const appConfig = {\n * providers: [\n * provideComIcons({ ChevronRight, Star, Check, AlertTriangle })\n * ]\n * };\n * ```\n *\n * @example Lazy route adds more icons without losing root icons\n * ```ts\n * // feature.routes.ts\n * export const routes: Routes = [{\n * path: '',\n * providers: [provideComIcons({ Settings, User })],\n * component: FeatureComponent,\n * }];\n * ```\n */\nexport function provideComIcons(icons: LucideIcons): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useValue: () => inject(ComIconRegistry).register(icons),\n },\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAGA;;;;;AAKG;MAEU,eAAe,CAAA;IACT,KAAK,GAAgB,EAAE;;AAGxC,IAAA,QAAQ,CAAC,KAAkB,EAAA;QACzB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC;IAClC;;AAGA,IAAA,GAAG,CAAC,IAAY,EAAA;QACd,OAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAoB,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B,oBAAA,QAAQ,EAAE;;;;;;;;;;;;AAYT,EAAA,CAAA;AACD,oBAAA,IAAI,EAAE;AACJ,wBAAA,SAAS,EAAE,eAAe;AAC3B,qBAAA;oBACD,OAAO,EAAE,CAAC,mBAAmB,CAAC;oBAC9B,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,aAAa,EAAE,iBAAiB,CAAC,IAAI;AACtC,iBAAA;;;AC7ED;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AACG,SAAU,eAAe,CAAC,KAAkB,EAAA;AAChD,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA;AACE,YAAA,OAAO,EAAE,uBAAuB;AAChC,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,QAAQ,EAAE,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;AACxD,SAAA;AACF,KAAA,CAAC;AACJ;;AC1CA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-com",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/avs2001/ngx-com"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"peerDependencies": {
|
|
9
9
|
"@angular/common": "^21.0.0",
|
|
10
10
|
"@angular/core": "^21.0.0",
|
|
11
|
-
"@angular/cdk": "
|
|
11
|
+
"@angular/cdk": "^21.0.0",
|
|
12
12
|
"@angular/forms": "^21.0.0",
|
|
13
13
|
"@angular/router": "^21.0.0",
|
|
14
14
|
"rxjs": "~7.8.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InputSignal, Signal,
|
|
2
|
+
import { InputSignal, Signal, EnvironmentProviders } from '@angular/core';
|
|
3
3
|
import { LucideIconData, LucideIcons } from 'lucide-angular';
|
|
4
4
|
import { VariantProps } from 'class-variance-authority';
|
|
5
5
|
|
|
@@ -50,6 +50,7 @@ type IconVariants = VariantProps<typeof iconVariants>;
|
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
52
|
declare class ComIcon {
|
|
53
|
+
private readonly registry;
|
|
53
54
|
/** Icon name in kebab-case (e.g. 'chevron-right'). Requires provideComIcons registration. */
|
|
54
55
|
readonly name: InputSignal<string | undefined>;
|
|
55
56
|
/** Direct Lucide icon reference. Takes precedence over `name`. */
|
|
@@ -64,16 +65,35 @@ declare class ComIcon {
|
|
|
64
65
|
readonly absoluteStrokeWidth: InputSignal<boolean>;
|
|
65
66
|
/** Applies aria-label and removes aria-hidden. Use for meaningful icons. */
|
|
66
67
|
readonly ariaLabel: InputSignal<string | undefined>;
|
|
68
|
+
/** Resolves icon data from either `img` (direct ref) or `name` (registry lookup). */
|
|
69
|
+
protected readonly resolvedIcon: Signal<LucideIconData | undefined>;
|
|
67
70
|
protected readonly sizeInPx: Signal<number>;
|
|
68
71
|
protected readonly hostClasses: Signal<string>;
|
|
69
72
|
static ɵfac: i0.ɵɵFactoryDeclaration<ComIcon, never>;
|
|
70
73
|
static ɵcmp: i0.ɵɵComponentDeclaration<ComIcon, "com-icon", never, { "name": { "alias": "name"; "required": false; "isSignal": true; }; "img": { "alias": "img"; "required": false; "isSignal": true; }; "color": { "alias": "color"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "strokeWidth": { "alias": "strokeWidth"; "required": false; "isSignal": true; }; "absoluteStrokeWidth": { "alias": "absoluteStrokeWidth"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Singleton registry for Lucide icons used by `com-icon`.
|
|
78
|
+
*
|
|
79
|
+
* Unlike lucide-angular's `LUCIDE_ICONS` token (which gets shadowed by child injectors),
|
|
80
|
+
* this registry lives at root and merges all icons registered via `provideComIcons()`.
|
|
81
|
+
*/
|
|
82
|
+
declare class ComIconRegistry {
|
|
83
|
+
private readonly icons;
|
|
84
|
+
/** Merges the given icons into the registry. */
|
|
85
|
+
register(icons: LucideIcons): void;
|
|
86
|
+
/** Returns the icon data for the given PascalCase name, or `null` if not registered. */
|
|
87
|
+
get(name: string): LucideIconData | null;
|
|
88
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComIconRegistry, never>;
|
|
89
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ComIconRegistry>;
|
|
90
|
+
}
|
|
91
|
+
|
|
73
92
|
/**
|
|
74
93
|
* Provides Lucide icons for use with `com-icon`.
|
|
75
94
|
*
|
|
76
|
-
*
|
|
95
|
+
* Icons are merged into a root-level registry, so multiple calls
|
|
96
|
+
* (e.g. at root and in lazy routes) accumulate rather than shadow.
|
|
77
97
|
*
|
|
78
98
|
* @example
|
|
79
99
|
* ```ts
|
|
@@ -87,8 +107,18 @@ declare class ComIcon {
|
|
|
87
107
|
* ]
|
|
88
108
|
* };
|
|
89
109
|
* ```
|
|
110
|
+
*
|
|
111
|
+
* @example Lazy route adds more icons without losing root icons
|
|
112
|
+
* ```ts
|
|
113
|
+
* // feature.routes.ts
|
|
114
|
+
* export const routes: Routes = [{
|
|
115
|
+
* path: '',
|
|
116
|
+
* providers: [provideComIcons({ Settings, User })],
|
|
117
|
+
* component: FeatureComponent,
|
|
118
|
+
* }];
|
|
119
|
+
* ```
|
|
90
120
|
*/
|
|
91
|
-
declare function provideComIcons(icons: LucideIcons):
|
|
121
|
+
declare function provideComIcons(icons: LucideIcons): EnvironmentProviders;
|
|
92
122
|
|
|
93
|
-
export { ComIcon, ICON_SIZE_PX, iconVariants, provideComIcons };
|
|
123
|
+
export { ComIcon, ComIconRegistry, ICON_SIZE_PX, iconVariants, provideComIcons };
|
|
94
124
|
export type { IconColor, IconSize, IconVariants };
|