@mbbiz/icon 0.1.5
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/README.md +133 -0
- package/angular/icon.component.d.ts +15 -0
- package/angular/icon.service.d.ts +10 -0
- package/angular/index.d.ts +3 -0
- package/angular/provide-icons.d.ts +3 -0
- package/fesm2022/mbbiz-icon-angular.mjs +98 -0
- package/fesm2022/mbbiz-icon-angular.mjs.map +1 -0
- package/fesm2022/mbbiz-icon.mjs +1106 -0
- package/fesm2022/mbbiz-icon.mjs.map +1 -0
- package/icons/abold_building.d.ts +2 -0
- package/icons/abold_cards.d.ts +2 -0
- package/icons/abold_cd.d.ts +2 -0
- package/icons/abold_chat.d.ts +2 -0
- package/icons/abold_coin_up.d.ts +2 -0
- package/icons/abold_credit.d.ts +2 -0
- package/icons/abold_documents.d.ts +2 -0
- package/icons/abold_error.d.ts +2 -0
- package/icons/abold_hierachy.d.ts +2 -0
- package/icons/abold_home.d.ts +2 -0
- package/icons/abold_info.d.ts +2 -0
- package/icons/abold_manage.d.ts +2 -0
- package/icons/abold_money.d.ts +2 -0
- package/icons/abold_money_up.d.ts +2 -0
- package/icons/abold_payment_transfer.d.ts +2 -0
- package/icons/abold_scf.d.ts +2 -0
- package/icons/abold_settings.d.ts +2 -0
- package/icons/abold_success.d.ts +2 -0
- package/icons/abold_wallet.d.ts +2 -0
- package/icons/abold_warning.d.ts +2 -0
- package/icons/action_close.d.ts +2 -0
- package/icons/action_edit.d.ts +2 -0
- package/icons/action_plus.d.ts +2 -0
- package/icons/action_search.d.ts +2 -0
- package/icons/alinear_add.d.ts +2 -0
- package/icons/alinear_add_card.d.ts +2 -0
- package/icons/alinear_add_paper.d.ts +2 -0
- package/icons/alinear_auto_bill.d.ts +2 -0
- package/icons/alinear_biometric.d.ts +2 -0
- package/icons/alinear_board_percentage.d.ts +2 -0
- package/icons/alinear_boat.d.ts +2 -0
- package/icons/alinear_book.d.ts +2 -0
- package/icons/alinear_book_address.d.ts +2 -0
- package/icons/alinear_building.d.ts +2 -0
- package/icons/alinear_calculator.d.ts +2 -0
- package/icons/alinear_calendar.d.ts +2 -0
- package/icons/alinear_cancel.d.ts +2 -0
- package/icons/alinear_card_dollar.d.ts +2 -0
- package/icons/alinear_card_focus.d.ts +2 -0
- package/icons/alinear_card_transfer.d.ts +2 -0
- package/icons/alinear_card_view.d.ts +2 -0
- package/icons/alinear_cards.d.ts +2 -0
- package/icons/alinear_cd.d.ts +2 -0
- package/icons/alinear_change_account.d.ts +2 -0
- package/icons/alinear_chat.d.ts +2 -0
- package/icons/alinear_clock.d.ts +2 -0
- package/icons/alinear_code.d.ts +2 -0
- package/icons/alinear_coin_up.d.ts +2 -0
- package/icons/alinear_contract_add.d.ts +2 -0
- package/icons/alinear_copy.d.ts +2 -0
- package/icons/alinear_credit.d.ts +2 -0
- package/icons/alinear_doc_download.d.ts +2 -0
- package/icons/alinear_doc_search.d.ts +2 -0
- package/icons/alinear_documents.d.ts +2 -0
- package/icons/alinear_down.d.ts +2 -0
- package/icons/alinear_download.d.ts +2 -0
- package/icons/alinear_duplicate_page.d.ts +2 -0
- package/icons/alinear_edit.d.ts +2 -0
- package/icons/alinear_electricity.d.ts +2 -0
- package/icons/alinear_email.d.ts +2 -0
- package/icons/alinear_exchange.d.ts +2 -0
- package/icons/alinear_expand.d.ts +2 -0
- package/icons/alinear_form_management.d.ts +2 -0
- package/icons/alinear_hand_money.d.ts +2 -0
- package/icons/alinear_hide.d.ts +2 -0
- package/icons/alinear_hierachy.d.ts +2 -0
- package/icons/alinear_home.d.ts +2 -0
- package/icons/alinear_info.d.ts +2 -0
- package/icons/alinear_insurance.d.ts +2 -0
- package/icons/alinear_jar.d.ts +2 -0
- package/icons/alinear_left.d.ts +2 -0
- package/icons/alinear_list.d.ts +2 -0
- package/icons/alinear_list_1.d.ts +2 -0
- package/icons/alinear_loans.d.ts +2 -0
- package/icons/alinear_lock.d.ts +2 -0
- package/icons/alinear_logout.d.ts +2 -0
- package/icons/alinear_manage.d.ts +2 -0
- package/icons/alinear_menu_1.d.ts +2 -0
- package/icons/alinear_menu_2.d.ts +2 -0
- package/icons/alinear_mission.d.ts +2 -0
- package/icons/alinear_mobile_time.d.ts +2 -0
- package/icons/alinear_money.d.ts +2 -0
- package/icons/alinear_money_code.d.ts +2 -0
- package/icons/alinear_money_exchange.d.ts +2 -0
- package/icons/alinear_money_up.d.ts +2 -0
- package/icons/alinear_notification.d.ts +2 -0
- package/icons/alinear_number.d.ts +2 -0
- package/icons/alinear_on_off.d.ts +2 -0
- package/icons/alinear_paper_cloud.d.ts +2 -0
- package/icons/alinear_payment_transfer.d.ts +2 -0
- package/icons/alinear_phone.d.ts +2 -0
- package/icons/alinear_phone_1.d.ts +2 -0
- package/icons/alinear_plane.d.ts +2 -0
- package/icons/alinear_plane_home.d.ts +2 -0
- package/icons/alinear_printer.d.ts +2 -0
- package/icons/alinear_profile.d.ts +2 -0
- package/icons/alinear_qr.d.ts +2 -0
- package/icons/alinear_quick_qr.d.ts +2 -0
- package/icons/alinear_receive.d.ts +2 -0
- package/icons/alinear_reverse_setting.d.ts +2 -0
- package/icons/alinear_right.d.ts +2 -0
- package/icons/alinear_scan_qr.d.ts +2 -0
- package/icons/alinear_scf.d.ts +2 -0
- package/icons/alinear_search.d.ts +2 -0
- package/icons/alinear_search_file.d.ts +2 -0
- package/icons/alinear_send.d.ts +2 -0
- package/icons/alinear_settings.d.ts +2 -0
- package/icons/alinear_shield.d.ts +2 -0
- package/icons/alinear_status.d.ts +2 -0
- package/icons/alinear_submit_feedback.d.ts +2 -0
- package/icons/alinear_top_up.d.ts +2 -0
- package/icons/alinear_transfer.d.ts +2 -0
- package/icons/alinear_transfer_account.d.ts +2 -0
- package/icons/alinear_trash.d.ts +2 -0
- package/icons/alinear_tv.d.ts +2 -0
- package/icons/alinear_up.d.ts +2 -0
- package/icons/alinear_update.d.ts +2 -0
- package/icons/alinear_upload.d.ts +2 -0
- package/icons/alinear_vault.d.ts +2 -0
- package/icons/alinear_visible.d.ts +2 -0
- package/icons/alinear_wallet.d.ts +2 -0
- package/icons/alinear_wallet_in.d.ts +2 -0
- package/icons/alinear_water.d.ts +2 -0
- package/icons/alinear_wifi.d.ts +2 -0
- package/icons/alinear_withdrawal.d.ts +2 -0
- package/icons/index.d.ts +131 -0
- package/icons/nav_arrow_right.d.ts +2 -0
- package/icons/nav_home.d.ts +2 -0
- package/index.d.ts +5 -0
- package/package.json +51 -0
- package/registry.d.ts +14 -0
- package/types.d.ts +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @mbbiz/icon
|
|
2
|
+
|
|
3
|
+
SVG icon library — **no IcoMoon, no Ant Design icons**.
|
|
4
|
+
|
|
5
|
+
Pipeline:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
icons/raw/*.svg → npm run icons:generate → src/icons/*.ts → <lib-icon>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @mbbiz/icon
|
|
15
|
+
# or link locally / git:
|
|
16
|
+
# npm install github:hieudeptrai1112/icon
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Add icons
|
|
20
|
+
|
|
21
|
+
1. Drop SVG into `icons/raw/` — naming: `ic-{domain}-{name}.svg`
|
|
22
|
+
- Example: `ic-nav-home.svg` → icon name `nav-home`
|
|
23
|
+
2. Run:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run icons:generate
|
|
27
|
+
npm run build
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Rules for SVG:
|
|
31
|
+
|
|
32
|
+
- Prefer `viewBox="0 0 24 24"`
|
|
33
|
+
- Use `currentColor` for stroke/fill (script rewrites hard-coded colors)
|
|
34
|
+
- Keep paths only — no filters/effects unless needed
|
|
35
|
+
|
|
36
|
+
## Usage (core)
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { registerIcons, NavHomeIcon, ActionPlusIcon, toSvgElement } from '@mbbiz/icon';
|
|
40
|
+
|
|
41
|
+
registerIcons(NavHomeIcon, ActionPlusIcon);
|
|
42
|
+
|
|
43
|
+
const html = toSvgElement(NavHomeIcon);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Register **only icons you need** — do not import `allIcons` in production apps.
|
|
47
|
+
|
|
48
|
+
## Usage (Angular)
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
// app.config.ts
|
|
52
|
+
import { provideIcons } from '@mbbiz/icon/angular';
|
|
53
|
+
import { NavHomeIcon, ActionSearchIcon } from '@mbbiz/icon';
|
|
54
|
+
|
|
55
|
+
export const appConfig = {
|
|
56
|
+
providers: [
|
|
57
|
+
provideIcons([NavHomeIcon, ActionSearchIcon]),
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<lib-icon name="nav-home" size="m" />
|
|
64
|
+
<lib-icon name="action-search" size="s" ariaLabel="Search" />
|
|
65
|
+
<lib-icon name="abold_error" size="m" color="#f53f3f" />
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Alias selector: `<mbbiz-icon>` also works.
|
|
69
|
+
|
|
70
|
+
### Icon size tokens (`iconsize/*`)
|
|
71
|
+
|
|
72
|
+
| Token | Prop `size` | px |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| `iconsize/xs` | `xs` | 16 |
|
|
75
|
+
| `iconsize/s` | `s` | 20 |
|
|
76
|
+
| `iconsize/m` | `m` (**default**) | 24 |
|
|
77
|
+
| `iconsize/l` | `l` | 28 |
|
|
78
|
+
| `iconsize/xl` | `xl` | 32 |
|
|
79
|
+
| `iconsize/2xl` | `2xl` | 40 |
|
|
80
|
+
|
|
81
|
+
Legacy aliases: `sm`→`xs`, `md`→`s`, `lg`→`m`.
|
|
82
|
+
|
|
83
|
+
### Color (same model as ng-zorro)
|
|
84
|
+
|
|
85
|
+
SVG paths use `currentColor`. The host sets CSS `color` via the `color` input (default `currentColor`) or by inheriting from a parent.
|
|
86
|
+
|
|
87
|
+
```html
|
|
88
|
+
<!-- Inherit from parent -->
|
|
89
|
+
<button style="color: #1677ff">
|
|
90
|
+
<lib-icon name="action-plus" size="s" />
|
|
91
|
+
Add
|
|
92
|
+
</button>
|
|
93
|
+
|
|
94
|
+
<!-- Explicit prop -->
|
|
95
|
+
<lib-icon name="abold_error" size="m" color="#f53f3f" />
|
|
96
|
+
<lib-icon name="abold_success" size="m" color="var(--semantic-color-success)" />
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```css
|
|
100
|
+
.icon-muted {
|
|
101
|
+
color: var(--semantic-color-text-secondary);
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Do **not** hard-code hex fills in raw SVG if the icon must recolor — the generate script rewrites non-`none`/`currentColor` fills to `currentColor`.
|
|
106
|
+
|
|
107
|
+
## Project layout
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
icons/raw/ # source of truth (SVG from Figma)
|
|
111
|
+
icons/manifest.json # generated metadata
|
|
112
|
+
scripts/generate.mjs
|
|
113
|
+
src/
|
|
114
|
+
types.ts
|
|
115
|
+
registry.ts
|
|
116
|
+
icons/ # generated definitions
|
|
117
|
+
angular/ # IconComponent + provideIcons
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Sample icons included
|
|
121
|
+
|
|
122
|
+
| Name | File |
|
|
123
|
+
|---|---|
|
|
124
|
+
| `nav-home` | `ic-nav-home.svg` |
|
|
125
|
+
| `nav-arrow-right` | `ic-nav-arrow-right.svg` |
|
|
126
|
+
| `action-plus` | `ic-action-plus.svg` |
|
|
127
|
+
| `action-close` | `ic-action-close.svg` |
|
|
128
|
+
| `action-search` | `ic-action-search.svg` |
|
|
129
|
+
| `action-edit` | `ic-action-edit.svg` |
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
MIT
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type IconSize } from '@mbbiz/icon';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class IconComponent {
|
|
4
|
+
readonly name: import("@angular/core").InputSignal<string>;
|
|
5
|
+
/** Token size: xs|s|m|l|xl|2xl (default m = 24px). Aliases sm→xs, md→s, lg→m. */
|
|
6
|
+
readonly size: import("@angular/core").InputSignal<IconSize>;
|
|
7
|
+
readonly color: import("@angular/core").InputSignal<string>;
|
|
8
|
+
readonly ariaLabel: import("@angular/core").InputSignal<string>;
|
|
9
|
+
private readonly sanitizer;
|
|
10
|
+
private readonly iconService;
|
|
11
|
+
protected readonly resolvedSize: import("@angular/core").Signal<import("@mbbiz/icon").IconSizeToken>;
|
|
12
|
+
protected readonly safeSvg: import("@angular/core").Signal<import("@angular/platform-browser").SafeHtml>;
|
|
13
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<IconComponent, never>;
|
|
14
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<IconComponent, "lib-icon, mbbiz-icon", never, { "name": { "alias": "name"; "required": true; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "color": { "alias": "color"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IconRegistry, type IconDefinition } from '@mbbiz/icon';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class IconService {
|
|
4
|
+
/** Shared registry (same as core defaultIconRegistry). */
|
|
5
|
+
readonly registry: IconRegistry;
|
|
6
|
+
register(...icons: IconDefinition[]): void;
|
|
7
|
+
get(name: string): IconDefinition | undefined;
|
|
8
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<IconService, never>;
|
|
9
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<IconService>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, input, inject, computed, ChangeDetectionStrategy, ViewEncapsulation, Component, makeEnvironmentProviders, APP_INITIALIZER } from '@angular/core';
|
|
3
|
+
import { DomSanitizer } from '@angular/platform-browser';
|
|
4
|
+
import { defaultIconRegistry, resolveIconSize, iconSizeToPx, toSvgElement } from '@mbbiz/icon';
|
|
5
|
+
|
|
6
|
+
class IconService {
|
|
7
|
+
/** Shared registry (same as core defaultIconRegistry). */
|
|
8
|
+
registry = defaultIconRegistry;
|
|
9
|
+
register(...icons) {
|
|
10
|
+
this.registry.register(...icons);
|
|
11
|
+
}
|
|
12
|
+
get(name) {
|
|
13
|
+
return this.registry.get(name);
|
|
14
|
+
}
|
|
15
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: IconService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
16
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: IconService, providedIn: 'root' });
|
|
17
|
+
}
|
|
18
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: IconService, decorators: [{
|
|
19
|
+
type: Injectable,
|
|
20
|
+
args: [{ providedIn: 'root' }]
|
|
21
|
+
}] });
|
|
22
|
+
|
|
23
|
+
class IconComponent {
|
|
24
|
+
name = input.required();
|
|
25
|
+
/** Token size: xs|s|m|l|xl|2xl (default m = 24px). Aliases sm→xs, md→s, lg→m. */
|
|
26
|
+
size = input('m');
|
|
27
|
+
color = input('currentColor');
|
|
28
|
+
ariaLabel = input(null);
|
|
29
|
+
sanitizer = inject(DomSanitizer);
|
|
30
|
+
iconService = inject(IconService, { optional: true });
|
|
31
|
+
resolvedSize = computed(() => resolveIconSize(this.size()));
|
|
32
|
+
safeSvg = computed(() => {
|
|
33
|
+
const registry = this.iconService?.registry ?? defaultIconRegistry;
|
|
34
|
+
const def = registry.get(this.name());
|
|
35
|
+
if (!def) {
|
|
36
|
+
console.warn(`[lib-icon] Unknown icon: "${this.name()}"`);
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
const px = iconSizeToPx(this.size());
|
|
40
|
+
const html = toSvgElement(def, {
|
|
41
|
+
width: String(px),
|
|
42
|
+
height: String(px),
|
|
43
|
+
});
|
|
44
|
+
return this.sanitizer.bypassSecurityTrustHtml(html);
|
|
45
|
+
});
|
|
46
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: IconComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
47
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.25", type: IconComponent, isStandalone: true, selector: "lib-icon, mbbiz-icon", inputs: { name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `<span
|
|
48
|
+
class="lib-icon"
|
|
49
|
+
[class.lib-icon--xs]="resolvedSize() === 'xs'"
|
|
50
|
+
[class.lib-icon--s]="resolvedSize() === 's'"
|
|
51
|
+
[class.lib-icon--m]="resolvedSize() === 'm'"
|
|
52
|
+
[class.lib-icon--l]="resolvedSize() === 'l'"
|
|
53
|
+
[class.lib-icon--xl]="resolvedSize() === 'xl'"
|
|
54
|
+
[class.lib-icon--2xl]="resolvedSize() === '2xl'"
|
|
55
|
+
[attr.role]="ariaLabel() ? 'img' : null"
|
|
56
|
+
[attr.aria-label]="ariaLabel()"
|
|
57
|
+
[attr.aria-hidden]="ariaLabel() ? null : 'true'"
|
|
58
|
+
[style.color]="color()"
|
|
59
|
+
[innerHTML]="safeSvg()"
|
|
60
|
+
></span>`, isInline: true, styles: [".lib-icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;line-height:0;color:inherit}.lib-icon svg{width:100%;height:100%;display:block}.lib-icon--xs{width:16px;height:16px}.lib-icon--s{width:20px;height:20px}.lib-icon--m{width:24px;height:24px}.lib-icon--l{width:28px;height:28px}.lib-icon--xl{width:32px;height:32px}.lib-icon--2xl{width:40px;height:40px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
61
|
+
}
|
|
62
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: IconComponent, decorators: [{
|
|
63
|
+
type: Component,
|
|
64
|
+
args: [{ selector: 'lib-icon, mbbiz-icon', standalone: true, template: `<span
|
|
65
|
+
class="lib-icon"
|
|
66
|
+
[class.lib-icon--xs]="resolvedSize() === 'xs'"
|
|
67
|
+
[class.lib-icon--s]="resolvedSize() === 's'"
|
|
68
|
+
[class.lib-icon--m]="resolvedSize() === 'm'"
|
|
69
|
+
[class.lib-icon--l]="resolvedSize() === 'l'"
|
|
70
|
+
[class.lib-icon--xl]="resolvedSize() === 'xl'"
|
|
71
|
+
[class.lib-icon--2xl]="resolvedSize() === '2xl'"
|
|
72
|
+
[attr.role]="ariaLabel() ? 'img' : null"
|
|
73
|
+
[attr.aria-label]="ariaLabel()"
|
|
74
|
+
[attr.aria-hidden]="ariaLabel() ? null : 'true'"
|
|
75
|
+
[style.color]="color()"
|
|
76
|
+
[innerHTML]="safeSvg()"
|
|
77
|
+
></span>`, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".lib-icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;line-height:0;color:inherit}.lib-icon svg{width:100%;height:100%;display:block}.lib-icon--xs{width:16px;height:16px}.lib-icon--s{width:20px;height:20px}.lib-icon--m{width:24px;height:24px}.lib-icon--l{width:28px;height:28px}.lib-icon--xl{width:32px;height:32px}.lib-icon--2xl{width:40px;height:40px}\n"] }]
|
|
78
|
+
}] });
|
|
79
|
+
|
|
80
|
+
function provideIcons(icons) {
|
|
81
|
+
return makeEnvironmentProviders([
|
|
82
|
+
{
|
|
83
|
+
provide: APP_INITIALIZER,
|
|
84
|
+
multi: true,
|
|
85
|
+
deps: [IconService],
|
|
86
|
+
useFactory: (svc) => () => {
|
|
87
|
+
svc.register(...icons);
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
]);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Generated bundle index. Do not edit.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
export { IconComponent, IconService, provideIcons };
|
|
98
|
+
//# sourceMappingURL=mbbiz-icon-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mbbiz-icon-angular.mjs","sources":["../../src/angular/icon.service.ts","../../src/angular/icon.component.ts","../../src/angular/provide-icons.ts","../../src/angular/mbbiz-icon-angular.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { IconRegistry, defaultIconRegistry, type IconDefinition } from '@mbbiz/icon';\n\n@Injectable({ providedIn: 'root' })\nexport class IconService {\n /** Shared registry (same as core defaultIconRegistry). */\n readonly registry: IconRegistry = defaultIconRegistry;\n\n register(...icons: IconDefinition[]): void {\n this.registry.register(...icons);\n }\n\n get(name: string): IconDefinition | undefined {\n return this.registry.get(name);\n }\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n ViewEncapsulation,\n computed,\n inject,\n input,\n} from '@angular/core';\nimport { DomSanitizer } from '@angular/platform-browser';\n\nimport {\n defaultIconRegistry,\n iconSizeToPx,\n resolveIconSize,\n toSvgElement,\n type IconSize,\n} from '@mbbiz/icon';\nimport { IconService } from './icon.service';\n\n@Component({\n selector: 'lib-icon, mbbiz-icon',\n standalone: true,\n template: `<span\n class=\"lib-icon\"\n [class.lib-icon--xs]=\"resolvedSize() === 'xs'\"\n [class.lib-icon--s]=\"resolvedSize() === 's'\"\n [class.lib-icon--m]=\"resolvedSize() === 'm'\"\n [class.lib-icon--l]=\"resolvedSize() === 'l'\"\n [class.lib-icon--xl]=\"resolvedSize() === 'xl'\"\n [class.lib-icon--2xl]=\"resolvedSize() === '2xl'\"\n [attr.role]=\"ariaLabel() ? 'img' : null\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-hidden]=\"ariaLabel() ? null : 'true'\"\n [style.color]=\"color()\"\n [innerHTML]=\"safeSvg()\"\n ></span>`,\n styles: [\n `\n .lib-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n line-height: 0;\n color: inherit;\n }\n .lib-icon svg {\n width: 100%;\n height: 100%;\n display: block;\n }\n .lib-icon--xs {\n width: 16px;\n height: 16px;\n }\n .lib-icon--s {\n width: 20px;\n height: 20px;\n }\n .lib-icon--m {\n width: 24px;\n height: 24px;\n }\n .lib-icon--l {\n width: 28px;\n height: 28px;\n }\n .lib-icon--xl {\n width: 32px;\n height: 32px;\n }\n .lib-icon--2xl {\n width: 40px;\n height: 40px;\n }\n `,\n ],\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class IconComponent {\n readonly name = input.required<string>();\n /** Token size: xs|s|m|l|xl|2xl (default m = 24px). Aliases sm→xs, md→s, lg→m. */\n readonly size = input<IconSize>('m');\n readonly color = input<string>('currentColor');\n readonly ariaLabel = input<string | null>(null);\n\n private readonly sanitizer = inject(DomSanitizer);\n private readonly iconService = inject(IconService, { optional: true });\n\n protected readonly resolvedSize = computed(() => resolveIconSize(this.size()));\n\n protected readonly safeSvg = computed(() => {\n const registry = this.iconService?.registry ?? defaultIconRegistry;\n const def = registry.get(this.name());\n if (!def) {\n console.warn(`[lib-icon] Unknown icon: \"${this.name()}\"`);\n return '';\n }\n\n const px = iconSizeToPx(this.size());\n const html = toSvgElement(def, {\n width: String(px),\n height: String(px),\n });\n return this.sanitizer.bypassSecurityTrustHtml(html);\n });\n}\n","import { APP_INITIALIZER, type EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\n\nimport { type IconDefinition } from '@mbbiz/icon';\nimport { IconService } from './icon.service';\n\nexport function provideIcons(icons: readonly IconDefinition[]): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: APP_INITIALIZER,\n multi: true,\n deps: [IconService],\n useFactory: (svc: IconService) => () => {\n svc.register(...icons);\n },\n },\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAKa,WAAW,CAAA;;IAEb,QAAQ,GAAiB,mBAAmB;IAErD,QAAQ,CAAC,GAAG,KAAuB,EAAA;QACjC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;IAClC;AAEA,IAAA,GAAG,CAAC,IAAY,EAAA;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;IAChC;wGAVW,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAX,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,cADE,MAAM,EAAA,CAAA;;4FACnB,WAAW,EAAA,UAAA,EAAA,CAAA;kBADvB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;MC4ErB,aAAa,CAAA;AACf,IAAA,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAU;;AAE/B,IAAA,IAAI,GAAG,KAAK,CAAW,GAAG,CAAC;AAC3B,IAAA,KAAK,GAAG,KAAK,CAAS,cAAc,CAAC;AACrC,IAAA,SAAS,GAAG,KAAK,CAAgB,IA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