@ng-zen/cli 21.1.0 → 21.1.1-next.2
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 +20 -0
- package/README.md +27 -1
- package/package.json +1 -1
- package/schematics/collection.json +0 -5
- package/schematics/ng-add/icon-library/icon-libraries.js +11 -0
- package/schematics/ng-add/icon-library/icon-libraries.js.map +1 -0
- package/schematics/ng-add/icon-library/icon-libraries.ts +8 -0
- package/schematics/ng-add/icon-library/icon-library.js +25 -0
- package/schematics/ng-add/icon-library/icon-library.js.map +1 -0
- package/schematics/ng-add/icon-library/icon-library.ts +28 -0
- package/schematics/ng-add/icon-library/index.js +5 -0
- package/schematics/ng-add/icon-library/index.js.map +1 -0
- package/schematics/ng-add/icon-library/index.ts +1 -0
- package/schematics/ng-add/index.js +7 -3
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/index.ts +11 -4
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +7 -1
- package/schematics/ng-add/schema.ts +3 -0
- package/schematics/ui/files/alert/alert.stories.ts +12 -22
- package/schematics/ui/files/alert/alert.ts +1 -1
- package/schematics/ui/files/icon/icon.spec.ts +2 -1
- package/schematics/ui/files/icon/icon.stories.ts +16 -5
- package/schematics/ui/files/icon/icon.ts +55 -44
- package/schematics/ui/index.js +1 -4
- package/schematics/ui/index.js.map +1 -1
- package/schematics/ui/index.ts +2 -5
- package/schematics/dependency-manager/dependencies.constant.js +0 -11
- package/schematics/dependency-manager/dependencies.constant.js.map +0 -1
- package/schematics/dependency-manager/dependencies.constant.ts +0 -9
- package/schematics/dependency-manager/index.js +0 -24
- package/schematics/dependency-manager/index.js.map +0 -1
- package/schematics/dependency-manager/index.ts +0 -27
- package/schematics/dependency-manager/schema.json +0 -12
- package/schematics/dependency-manager/utils/get-dependencies.js +0 -26
- package/schematics/dependency-manager/utils/get-dependencies.js.map +0 -1
- package/schematics/dependency-manager/utils/get-dependencies.ts +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## [21.1.1-next.2](https://github.com/kstepien3/ng-zen/compare/v21.1.1-next.1...v21.1.1-next.2) (2026-02-24)
|
|
2
|
+
|
|
3
|
+
### 🛠️ Code Refactor
|
|
4
|
+
|
|
5
|
+
* **ng-add:** improve icon library installation ([#384](https://github.com/kstepien3/ng-zen/issues/384)) ([a0145de](https://github.com/kstepien3/ng-zen/commit/a0145deed42eb009a78f2dbef3873710a316215f))
|
|
6
|
+
|
|
7
|
+
### 📚 Documentation
|
|
8
|
+
|
|
9
|
+
* **icon:** update component description and usage guidance ([#385](https://github.com/kstepien3/ng-zen/issues/385)) ([eb329bd](https://github.com/kstepien3/ng-zen/commit/eb329bdcf7e383bf7a2a54a39f75be7257c4377f))
|
|
10
|
+
|
|
11
|
+
## [21.1.1-next.1](https://github.com/kstepien3/ng-zen/compare/v21.1.0...v21.1.1-next.1) (2026-02-23)
|
|
12
|
+
|
|
13
|
+
### 🐛 Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **icon:** support all SVG shapes and normalize attribute naming ([#380](https://github.com/kstepien3/ng-zen/issues/380)) ([56cf31f](https://github.com/kstepien3/ng-zen/commit/56cf31ffbd59ca427ddb2f284f264a110d63ad4e))
|
|
16
|
+
|
|
17
|
+
### 📚 Documentation
|
|
18
|
+
|
|
19
|
+
* **alert:** update example ([#382](https://github.com/kstepien3/ng-zen/issues/382)) ([3d29acb](https://github.com/kstepien3/ng-zen/commit/3d29acbd575d2a3eb3e5028f1abb9d0118918cc2))
|
|
20
|
+
|
|
1
21
|
## [21.1.0](https://github.com/kstepien3/ng-zen/compare/v21.0.0...v21.1.0) (2026-02-17)
|
|
2
22
|
|
|
3
23
|
### 🚀 New Features
|
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ Unlike traditional UI libraries that give you `<library-button>` black boxes, @n
|
|
|
60
60
|
|
|
61
61
|
1. [Quick Start](#-quick-start)
|
|
62
62
|
2. [Installation](#-installation)
|
|
63
|
-
3. [Available Elements](#-available-
|
|
63
|
+
3. [Available Elements](#-available-uis)
|
|
64
64
|
4. [Usage Examples](#-usage-examples)
|
|
65
65
|
5. [Perfect For](#-perfect-for)
|
|
66
66
|
6. [Advanced Features](#-advanced-features)
|
|
@@ -112,6 +112,32 @@ pnpm add -D @ng-zen/cli
|
|
|
112
112
|
pnpm add -D @ng-zen/cli@next
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
+
### Icon Library (Optional)
|
|
116
|
+
|
|
117
|
+
To use the `zen-icon` component, install an icon library:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Using HugeIcons (recommended)
|
|
121
|
+
pnpm add @hugeicons/core-free-icons
|
|
122
|
+
|
|
123
|
+
# Or use any other SVG icon library
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Then import icons and pass them to the component:
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
import { CheckmarkIcon } from '@hugeicons/core-free-icons';
|
|
130
|
+
import { ZenIcon } from '@ng-zen/cli';
|
|
131
|
+
|
|
132
|
+
@Component({
|
|
133
|
+
imports: [ZenIcon],
|
|
134
|
+
template: `
|
|
135
|
+
<zen-icon [icon]="CheckmarkIcon" />
|
|
136
|
+
`,
|
|
137
|
+
})
|
|
138
|
+
export class MyComponent {}
|
|
139
|
+
```
|
|
140
|
+
|
|
115
141
|
## 🧩 Available UIs
|
|
116
142
|
|
|
117
143
|
| Component | Description | Features |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-zen/cli",
|
|
3
|
-
"version": "21.1.
|
|
3
|
+
"version": "21.1.1-next.2",
|
|
4
4
|
"description": "Angular UI components generator – Zen UI Kit CLI for schematics-based creation of customizable components like avatar, button, checkbox, divider, form-control, icon, input, skeleton, switch, textarea with Storybook demos.",
|
|
5
5
|
"license": "BSD-2-Clause",
|
|
6
6
|
"private": false,
|
|
@@ -11,11 +11,6 @@
|
|
|
11
11
|
"factory": "./ui/index#uiGenerator",
|
|
12
12
|
"schema": "./ui/schema.json",
|
|
13
13
|
"aliases": ["c", "component", "components"]
|
|
14
|
-
},
|
|
15
|
-
"dependency-manager": {
|
|
16
|
-
"description": "Manage dependencies for selected elements",
|
|
17
|
-
"factory": "./dependency-manager/index#dependencyManager",
|
|
18
|
-
"schema": "./dependency-manager/schema.json"
|
|
19
14
|
}
|
|
20
15
|
}
|
|
21
16
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HugeiconsCoreFree = void 0;
|
|
4
|
+
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
|
5
|
+
exports.HugeiconsCoreFree = {
|
|
6
|
+
name: '@hugeicons/core-free-icons',
|
|
7
|
+
version: 'latest',
|
|
8
|
+
type: dependencies_1.NodeDependencyType.Default,
|
|
9
|
+
overwrite: false,
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=icon-libraries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-libraries.js","sourceRoot":"","sources":["../../../../../../src/schematics/ng-add/icon-library/icon-libraries.ts"],"names":[],"mappings":";;;AAAA,2EAA8F;AAEjF,QAAA,iBAAiB,GAAmB;IAC/C,IAAI,EAAE,4BAA4B;IAClC,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,iCAAkB,CAAC,OAAO;IAChC,SAAS,EAAE,KAAK;CACjB,CAAC","sourcesContent":["import { NodeDependency, NodeDependencyType } from '@schematics/angular/utility/dependencies';\n\nexport const HugeiconsCoreFree: NodeDependency = {\n name: '@hugeicons/core-free-icons',\n version: 'latest',\n type: NodeDependencyType.Default,\n overwrite: false,\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NodeDependency, NodeDependencyType } from '@schematics/angular/utility/dependencies';
|
|
2
|
+
|
|
3
|
+
export const HugeiconsCoreFree: NodeDependency = {
|
|
4
|
+
name: '@hugeicons/core-free-icons',
|
|
5
|
+
version: 'latest',
|
|
6
|
+
type: NodeDependencyType.Default,
|
|
7
|
+
overwrite: false,
|
|
8
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.installIconLibrary = installIconLibrary;
|
|
4
|
+
exports.logIconLibraryManualInstructions = logIconLibraryManualInstructions;
|
|
5
|
+
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
6
|
+
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
|
7
|
+
const icon_libraries_1 = require("./icon-libraries");
|
|
8
|
+
function installIconLibrary() {
|
|
9
|
+
return (tree, context) => {
|
|
10
|
+
context.logger.info('📦 Installing @hugeicons/core-free-icons...');
|
|
11
|
+
(0, dependencies_1.addPackageJsonDependency)(tree, icon_libraries_1.HugeiconsCoreFree);
|
|
12
|
+
context.addTask(new tasks_1.NodePackageInstallTask());
|
|
13
|
+
context.logger.info('✅ @hugeicons/core-free-icons has been added to your project.');
|
|
14
|
+
return tree;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function logIconLibraryManualInstructions() {
|
|
18
|
+
return (tree, context) => {
|
|
19
|
+
context.logger.info('To use <zen-icon>, install an SVG icon library (one-time setup):');
|
|
20
|
+
context.logger.info(' - Recommended: @hugeicons/core-free-icons');
|
|
21
|
+
context.logger.info(' - Or use any other SVG icon library and pass icons via the [icon] input.');
|
|
22
|
+
return tree;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=icon-library.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-library.js","sourceRoot":"","sources":["../../../../../../src/schematics/ng-add/icon-library/icon-library.ts"],"names":[],"mappings":";;AAMA,gDAWC;AAED,4EAQC;AA1BD,4DAA0E;AAC1E,2EAAoF;AAEpF,qDAAqD;AAErD,SAAgB,kBAAkB;IAChC,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;QAEnE,IAAA,uCAAwB,EAAC,IAAI,EAAE,kCAAiB,CAAC,CAAC;QAClD,OAAO,CAAC,OAAO,CAAC,IAAI,8BAAsB,EAAE,CAAC,CAAC;QAE9C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;QAEpF,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,gCAAgC;IAC9C,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,kEAAkE,CAAC,CAAC;QACxF,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;QACnE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAC;QAElG,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\nimport { addPackageJsonDependency } from '@schematics/angular/utility/dependencies';\n\nimport { HugeiconsCoreFree } from './icon-libraries';\n\nexport function installIconLibrary(): Rule {\n return (tree: Tree, context: SchematicContext) => {\n context.logger.info('📦 Installing @hugeicons/core-free-icons...');\n\n addPackageJsonDependency(tree, HugeiconsCoreFree);\n context.addTask(new NodePackageInstallTask());\n\n context.logger.info('✅ @hugeicons/core-free-icons has been added to your project.');\n\n return tree;\n };\n}\n\nexport function logIconLibraryManualInstructions(): Rule {\n return (tree: Tree, context: SchematicContext) => {\n context.logger.info('To use <zen-icon>, install an SVG icon library (one-time setup):');\n context.logger.info(' - Recommended: @hugeicons/core-free-icons');\n context.logger.info(' - Or use any other SVG icon library and pass icons via the [icon] input.');\n\n return tree;\n };\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
|
|
2
|
+
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
|
|
3
|
+
import { addPackageJsonDependency } from '@schematics/angular/utility/dependencies';
|
|
4
|
+
|
|
5
|
+
import { HugeiconsCoreFree } from './icon-libraries';
|
|
6
|
+
|
|
7
|
+
export function installIconLibrary(): Rule {
|
|
8
|
+
return (tree: Tree, context: SchematicContext) => {
|
|
9
|
+
context.logger.info('📦 Installing @hugeicons/core-free-icons...');
|
|
10
|
+
|
|
11
|
+
addPackageJsonDependency(tree, HugeiconsCoreFree);
|
|
12
|
+
context.addTask(new NodePackageInstallTask());
|
|
13
|
+
|
|
14
|
+
context.logger.info('✅ @hugeicons/core-free-icons has been added to your project.');
|
|
15
|
+
|
|
16
|
+
return tree;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function logIconLibraryManualInstructions(): Rule {
|
|
21
|
+
return (tree: Tree, context: SchematicContext) => {
|
|
22
|
+
context.logger.info('To use <zen-icon>, install an SVG icon library (one-time setup):');
|
|
23
|
+
context.logger.info(' - Recommended: @hugeicons/core-free-icons');
|
|
24
|
+
context.logger.info(' - Or use any other SVG icon library and pass icons via the [icon] input.');
|
|
25
|
+
|
|
26
|
+
return tree;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/schematics/ng-add/icon-library/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B","sourcesContent":["export * from './icon-library';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './icon-library';
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ngAdd = ngAdd;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const icon_library_1 = require("./icon-library");
|
|
5
|
+
function ngAdd(options) {
|
|
6
|
+
return (tree, context) => {
|
|
6
7
|
context.logger.info('🔧 Setting up ng-zen...');
|
|
7
|
-
|
|
8
|
+
if (options.installIconLibrary) {
|
|
9
|
+
return (0, icon_library_1.installIconLibrary)()(tree, context);
|
|
10
|
+
}
|
|
11
|
+
return (0, icon_library_1.logIconLibraryManualInstructions)()(tree, context);
|
|
8
12
|
};
|
|
9
13
|
}
|
|
10
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/index.ts"],"names":[],"mappings":";;AAKA,sBAUC;AAbD,iDAAsF;AAGtF,SAAgB,KAAK,CAAC,OAAe;IACnC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;QACvB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QAE/C,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;YAC/B,OAAO,IAAA,iCAAkB,GAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,IAAA,+CAAgC,GAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Rule } from '@angular-devkit/schematics';\n\nimport { installIconLibrary, logIconLibraryManualInstructions } from './icon-library';\nimport { Schema } from './schema';\n\nexport function ngAdd(options: Schema): Rule {\n return (tree, context) => {\n context.logger.info('🔧 Setting up ng-zen...');\n\n if (options.installIconLibrary) {\n return installIconLibrary()(tree, context);\n }\n\n return logIconLibraryManualInstructions()(tree, context);\n };\n}\n"]}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { Rule
|
|
1
|
+
import { Rule } from '@angular-devkit/schematics';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { installIconLibrary, logIconLibraryManualInstructions } from './icon-library';
|
|
4
|
+
import { Schema } from './schema';
|
|
5
|
+
|
|
6
|
+
export function ngAdd(options: Schema): Rule {
|
|
7
|
+
return (tree, context) => {
|
|
5
8
|
context.logger.info('🔧 Setting up ng-zen...');
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
if (options.installIconLibrary) {
|
|
11
|
+
return installIconLibrary()(tree, context);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return logIconLibraryManualInstructions()(tree, context);
|
|
8
15
|
};
|
|
9
16
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/schema.ts"],"names":[],"mappings":"","sourcesContent":["export interface Schema {\n installIconLibrary?: boolean;\n}\n"]}
|
|
@@ -3,5 +3,11 @@
|
|
|
3
3
|
"$id": "NgZenCliComponents",
|
|
4
4
|
"title": "Schema to create Zen UI library",
|
|
5
5
|
"type": "object",
|
|
6
|
-
"description": "Adds Zen CLI library and configure project 📦"
|
|
6
|
+
"description": "Adds Zen CLI library and configure project 📦",
|
|
7
|
+
"properties": {
|
|
8
|
+
"installIconLibrary": {
|
|
9
|
+
"type": "boolean",
|
|
10
|
+
"x-prompt": "Would you like to install @hugeicons/core-free-icons? This package provides the icon set for zen-icon component. You can also install it manually later."
|
|
11
|
+
}
|
|
12
|
+
}
|
|
7
13
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Notification02Icon } from '@hugeicons/core-free-icons';
|
|
2
2
|
import { Meta, moduleMetadata, StoryObj } from '@storybook/angular';
|
|
3
3
|
|
|
4
4
|
import { ZenIcon } from '../icon';
|
|
@@ -6,7 +6,6 @@ import { ZenAlert } from './alert';
|
|
|
6
6
|
|
|
7
7
|
interface StoryParams {
|
|
8
8
|
content: string;
|
|
9
|
-
icon: string;
|
|
10
9
|
title: string;
|
|
11
10
|
}
|
|
12
11
|
|
|
@@ -17,7 +16,6 @@ export default {
|
|
|
17
16
|
component: ZenAlert,
|
|
18
17
|
decorators: [moduleMetadata({ imports: [ZenIcon] })],
|
|
19
18
|
args: {
|
|
20
|
-
icon: 'Notification02Icon',
|
|
21
19
|
title: 'Alert Title',
|
|
22
20
|
content: 'This is an alert message',
|
|
23
21
|
},
|
|
@@ -31,16 +29,6 @@ export default {
|
|
|
31
29
|
},
|
|
32
30
|
},
|
|
33
31
|
},
|
|
34
|
-
icon: {
|
|
35
|
-
control: 'select',
|
|
36
|
-
options: Object.keys(icons),
|
|
37
|
-
table: {
|
|
38
|
-
category: 'story parameters',
|
|
39
|
-
type: {
|
|
40
|
-
summary: 'string',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
32
|
title: {
|
|
45
33
|
control: 'text',
|
|
46
34
|
table: {
|
|
@@ -51,15 +39,17 @@ export default {
|
|
|
51
39
|
},
|
|
52
40
|
},
|
|
53
41
|
},
|
|
54
|
-
render: ({ content,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
42
|
+
render: ({ content, title }) => {
|
|
43
|
+
return {
|
|
44
|
+
props: { Notification02Icon },
|
|
45
|
+
template: `
|
|
46
|
+
<zen-alert>
|
|
47
|
+
<zen-icon alert-icon [icon]="Notification02Icon" />
|
|
48
|
+
<h3 alert-title>${title}</h3>
|
|
49
|
+
${content}
|
|
50
|
+
</zen-alert>`,
|
|
51
|
+
};
|
|
52
|
+
},
|
|
63
53
|
} satisfies Meta<Options>;
|
|
64
54
|
|
|
65
55
|
type Story = StoryObj<Options>;
|
|
@@ -9,7 +9,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
|
9
9
|
*
|
|
10
10
|
* ```html
|
|
11
11
|
* <zen-alert>
|
|
12
|
-
* <zen-icon alert-icon icon="Notification02Icon" />
|
|
12
|
+
* <zen-icon alert-icon [icon]="Notification02Icon" />
|
|
13
13
|
* <h3 alert-title>Title</h3>
|
|
14
14
|
* content
|
|
15
15
|
* </zen-alert>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { provideZonelessChangeDetection } from '@angular/core';
|
|
2
2
|
import { TestBed } from '@angular/core/testing';
|
|
3
|
+
import { HomeIcon } from '@hugeicons/core-free-icons';
|
|
3
4
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
4
5
|
|
|
5
6
|
import { ZenIcon } from './icon';
|
|
@@ -15,7 +16,7 @@ describe('ZenIcon', () => {
|
|
|
15
16
|
it('should create', () => {
|
|
16
17
|
const fixture = TestBed.createComponent(ZenIcon);
|
|
17
18
|
const component = fixture.componentInstance;
|
|
18
|
-
fixture.componentRef.setInput('icon',
|
|
19
|
+
fixture.componentRef.setInput('icon', HomeIcon);
|
|
19
20
|
expect(component).toBeTruthy();
|
|
20
21
|
});
|
|
21
22
|
});
|
|
@@ -4,19 +4,30 @@ import { Meta, StoryObj } from '@storybook/angular';
|
|
|
4
4
|
import { ZenIcon } from './icon';
|
|
5
5
|
|
|
6
6
|
type Options = ZenIcon;
|
|
7
|
+
const iconKeys = Object.keys(icons) as (keyof typeof icons)[];
|
|
8
|
+
const iconMapping = icons as Record<string, unknown>;
|
|
9
|
+
const iconLabels = Object.fromEntries(iconKeys.map(k => [k as string, String(k).replace(/Icon$/, '')])) as Record<
|
|
10
|
+
string,
|
|
11
|
+
string
|
|
12
|
+
>;
|
|
13
|
+
|
|
14
|
+
console.log(iconKeys);
|
|
7
15
|
|
|
8
16
|
export default {
|
|
9
17
|
title: 'Ui/Icon',
|
|
10
18
|
component: ZenIcon,
|
|
11
19
|
argTypes: {
|
|
12
20
|
icon: {
|
|
13
|
-
control:
|
|
14
|
-
|
|
21
|
+
control: {
|
|
22
|
+
type: 'select',
|
|
23
|
+
labels: iconLabels,
|
|
24
|
+
},
|
|
25
|
+
options: iconKeys,
|
|
26
|
+
mapping: iconMapping,
|
|
15
27
|
table: {
|
|
16
|
-
type: { summary: '
|
|
28
|
+
type: { summary: 'IconSvgObject' },
|
|
17
29
|
category: 'inputs',
|
|
18
30
|
subcategory: 'required',
|
|
19
|
-
defaultValue: { summary: '' },
|
|
20
31
|
},
|
|
21
32
|
},
|
|
22
33
|
size: {
|
|
@@ -40,7 +51,7 @@ export default {
|
|
|
40
51
|
size: 24,
|
|
41
52
|
strokeWidth: 1.5,
|
|
42
53
|
absoluteStrokeWidth: false,
|
|
43
|
-
icon: 'Tree02Icon',
|
|
54
|
+
icon: 'Tree02Icon' as never,
|
|
44
55
|
},
|
|
45
56
|
} satisfies Meta<Options>;
|
|
46
57
|
|
|
@@ -1,55 +1,53 @@
|
|
|
1
|
-
import { booleanAttribute, ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
|
2
|
-
import
|
|
1
|
+
import { booleanAttribute, ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core';
|
|
2
|
+
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
d: string | number;
|
|
7
|
-
fill: string | number;
|
|
8
|
-
opacity: string | number;
|
|
9
|
-
fillRule: string | number;
|
|
10
|
-
strokeWidth?: number;
|
|
11
|
-
}
|
|
4
|
+
/** SVG icon data structure from HugeIcons library - an array of [tagName, attributes] tuples. */
|
|
5
|
+
export type IconSvgObject = readonly (readonly [string, Record<string, string | number>])[];
|
|
12
6
|
|
|
13
7
|
/**
|
|
14
|
-
*
|
|
8
|
+
* Reusable Angular component for rendering SVG icons from icon libraries.
|
|
9
|
+
*
|
|
10
|
+
* The component renders an icon by accepting an SVG definition object via the `[icon]` input.
|
|
11
|
+
* Size, stroke width, and color are configurable.
|
|
15
12
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* and its paths, providing a flexible and efficient way to use Hugeicons in an Angular application.
|
|
13
|
+
* Security note: the icon data is converted to HTML and trusted via `DomSanitizer.bypassSecurityTrustHtml`,
|
|
14
|
+
* so the provided icon object must come from a trusted source.
|
|
19
15
|
*
|
|
20
16
|
* @example
|
|
21
|
-
*
|
|
17
|
+
* ```html
|
|
18
|
+
* <zen-icon [icon]="SvgObject" />
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Compatible with libraries that export icons as `[tagName, attributes]` tuples.
|
|
22
|
+
* Tested with `@hugeicons/core-free-icons`.
|
|
22
23
|
*
|
|
23
|
-
* @
|
|
24
|
+
* @author Konrad Stępień
|
|
25
|
+
* @license {@link https://github.com/kstepien3/ng-zen/blob/master/LICENSE|BSD-2-Clause}
|
|
26
|
+
* @see [GitHub](https://github.com/kstepien3/ng-zen)
|
|
24
27
|
*/
|
|
25
28
|
@Component({
|
|
26
29
|
selector: 'zen-icon',
|
|
27
30
|
template: `
|
|
28
31
|
<svg
|
|
29
|
-
[attr.color]="color()"
|
|
30
32
|
[attr.height]="size()"
|
|
33
|
+
[attr.stroke-width]="calculatedStrokeWidth()"
|
|
31
34
|
[attr.viewBox]="'0 0 ' + BASE_SIZE + ' ' + BASE_SIZE"
|
|
32
35
|
[attr.width]="size()"
|
|
36
|
+
[innerHTML]="safeSvgContent()"
|
|
37
|
+
[style.color]="color()"
|
|
33
38
|
fill="none"
|
|
39
|
+
stroke="currentColor"
|
|
40
|
+
stroke-linecap="round"
|
|
41
|
+
stroke-linejoin="round"
|
|
34
42
|
xmlns="http://www.w3.org/2000/svg"
|
|
35
|
-
>
|
|
36
|
-
@for (path of paths(); track path) {
|
|
37
|
-
<path
|
|
38
|
-
[attr.d]="path.d"
|
|
39
|
-
[attr.fill-rule]="path.fillRule"
|
|
40
|
-
[attr.fill]="path.fill"
|
|
41
|
-
[attr.opacity]="path.opacity"
|
|
42
|
-
[attr.stroke-width]="path.strokeWidth"
|
|
43
|
-
stroke="currentColor"
|
|
44
|
-
/>
|
|
45
|
-
}
|
|
46
|
-
</svg>
|
|
43
|
+
></svg>
|
|
47
44
|
`,
|
|
45
|
+
styles: [':host { display: inline-flex; }'],
|
|
48
46
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
49
47
|
})
|
|
50
48
|
export class ZenIcon {
|
|
51
|
-
/**
|
|
52
|
-
readonly icon = input.required(
|
|
49
|
+
/** SVG object imported from HugeIcons library. */
|
|
50
|
+
readonly icon = input.required<IconSvgObject>();
|
|
53
51
|
/** Size of the icon in pixels. */
|
|
54
52
|
readonly size = input<number>(24);
|
|
55
53
|
/** Determines if stroke width scales with icon size. */
|
|
@@ -60,22 +58,35 @@ export class ZenIcon {
|
|
|
60
58
|
readonly color = input<string>('currentColor');
|
|
61
59
|
|
|
62
60
|
protected readonly BASE_SIZE = 24;
|
|
63
|
-
protected readonly paths = computed<Path[]>(() => this.updatePaths());
|
|
64
|
-
private readonly calculatedStrokeWidth = computed(() => this.calculateStrokeWidth());
|
|
65
61
|
|
|
66
|
-
private
|
|
67
|
-
return this.icon().map(([, attrs]) => ({
|
|
68
|
-
d: attrs['d'],
|
|
69
|
-
fill: attrs['fill'] ?? 'none',
|
|
70
|
-
opacity: attrs['opacity'],
|
|
71
|
-
fillRule: attrs['fillRule'],
|
|
72
|
-
strokeWidth: this.calculatedStrokeWidth(),
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
62
|
+
private readonly sanitizer = inject(DomSanitizer);
|
|
75
63
|
|
|
76
|
-
|
|
64
|
+
protected readonly calculatedStrokeWidth = computed(() => {
|
|
77
65
|
if (!this.absoluteStrokeWidth()) return this.strokeWidth();
|
|
78
|
-
|
|
79
66
|
return (this.strokeWidth() * this.BASE_SIZE) / this.size();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/** Converts icon data into a sanitized HTML string of SVG elements. */
|
|
70
|
+
protected readonly safeSvgContent = computed<SafeHtml>(() => {
|
|
71
|
+
const htmlString = this.icon()
|
|
72
|
+
.map(([tag, attrs]) => this.buildTag(tag, attrs))
|
|
73
|
+
.join('');
|
|
74
|
+
|
|
75
|
+
return this.sanitizer.bypassSecurityTrustHtml(htmlString);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/** Generates a single SVG element string (e.g., <path ...>) with its mapped attributes. */
|
|
79
|
+
private buildTag(tag: string, attrs: Record<string, string | number>): string {
|
|
80
|
+
const attributes = Object.entries(attrs)
|
|
81
|
+
.filter(([key]) => !['strokeWidth', 'stroke-width'].includes(key))
|
|
82
|
+
.map(([key, value]) => `${this.toKebabCase(key)}="${value}"`)
|
|
83
|
+
.join(' ');
|
|
84
|
+
|
|
85
|
+
return `<${tag} ${attributes} stroke-width="${this.calculatedStrokeWidth()}"></${tag}>`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Formats attribute names from camelCase (used in JS library) to a kebab-case for SVG compatibility. */
|
|
89
|
+
private toKebabCase(str: string): string {
|
|
90
|
+
return str.replaceAll(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
80
91
|
}
|
|
81
92
|
}
|
package/schematics/ui/index.js
CHANGED
|
@@ -18,10 +18,7 @@ function uiGenerator({ ui, project, ...options }) {
|
|
|
18
18
|
options.path = ((0, workspace_1.buildDefaultPath)(projectObj) + '/' + DEFAULT_GENERATION_PATH);
|
|
19
19
|
}
|
|
20
20
|
const workingDirectory = (0, core_1.normalize)((0, core_1.join)(options.currentDirectory, options.path));
|
|
21
|
-
return (0, schematics_1.chain)([
|
|
22
|
-
...(0, utils_1.applyFileTemplateUtil)(ui, { ...options, path: workingDirectory }),
|
|
23
|
-
(0, schematics_1.schematic)('dependency-manager', {}),
|
|
24
|
-
]);
|
|
21
|
+
return (0, schematics_1.chain)([...(0, utils_1.applyFileTemplateUtil)(ui, { ...options, path: workingDirectory })]);
|
|
25
22
|
};
|
|
26
23
|
}
|
|
27
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/schematics/ui/index.ts"],"names":[],"mappings":";;AASA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/schematics/ui/index.ts"],"names":[],"mappings":";;AASA,kCAkBC;AA3BD,+CAA6D;AAC7D,2DAA+D;AAC/D,qEAAuF;AAEvF,uCAAoD;AAGpD,MAAM,uBAAuB,GAAG,IAAI,CAAC,CAAC,aAAa;AAEnD,SAAgB,WAAW,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,OAAO,EAAa;IAChE,OAAO,KAAK,EAAE,IAAU,EAAE,EAAE;QAC1B,MAAM,SAAS,GAAG,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,WAAW,GAAG,OAAO,IAAK,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAY,CAAC;QAClF,MAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAEvD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,YAAY,WAAW,2BAA2B,CAAC,CAAC;QACtE,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,OAAO,CAAC,IAAI,GAAG,CAAC,IAAA,4BAAgB,EAAC,UAAU,CAAC,GAAG,GAAG,GAAG,uBAAuB,CAAS,CAAC;QACxF,CAAC;QAED,MAAM,gBAAgB,GAAG,IAAA,gBAAS,EAAC,IAAA,WAAI,EAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAEjF,OAAO,IAAA,kBAAK,EAAC,CAAC,GAAG,IAAA,6BAAqB,EAAC,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAAC;IACvF,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { join, normalize, Path } from '@angular-devkit/core';\nimport { chain, Rule, Tree } from '@angular-devkit/schematics';\nimport { buildDefaultPath, getWorkspace } from '@schematics/angular/utility/workspace';\n\nimport { applyFileTemplateUtil } from '../../utils';\nimport { Schema as UiOptions } from './schema';\n\nconst DEFAULT_GENERATION_PATH = 'ui'; // src/app/ui\n\nexport function uiGenerator({ ui, project, ...options }: UiOptions): Rule {\n return async (tree: Tree) => {\n const workspace = await getWorkspace(tree);\n const projectName = project || (workspace.extensions['defaultProject'] as string);\n const projectObj = workspace.projects.get(projectName);\n\n if (!projectObj) {\n throw new Error(`Project \"${projectName}\" not found in workspace.`);\n }\n\n if (options.path === undefined) {\n options.path = (buildDefaultPath(projectObj) + '/' + DEFAULT_GENERATION_PATH) as Path;\n }\n\n const workingDirectory = normalize(join(options.currentDirectory, options.path));\n\n return chain([...applyFileTemplateUtil(ui, { ...options, path: workingDirectory })]);\n };\n}\n"]}
|
package/schematics/ui/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join, normalize, Path } from '@angular-devkit/core';
|
|
2
|
-
import { chain, Rule,
|
|
2
|
+
import { chain, Rule, Tree } from '@angular-devkit/schematics';
|
|
3
3
|
import { buildDefaultPath, getWorkspace } from '@schematics/angular/utility/workspace';
|
|
4
4
|
|
|
5
5
|
import { applyFileTemplateUtil } from '../../utils';
|
|
@@ -23,9 +23,6 @@ export function uiGenerator({ ui, project, ...options }: UiOptions): Rule {
|
|
|
23
23
|
|
|
24
24
|
const workingDirectory = normalize(join(options.currentDirectory, options.path));
|
|
25
25
|
|
|
26
|
-
return chain([
|
|
27
|
-
...applyFileTemplateUtil(ui, { ...options, path: workingDirectory }),
|
|
28
|
-
schematic('dependency-manager', {}),
|
|
29
|
-
]);
|
|
26
|
+
return chain([...applyFileTemplateUtil(ui, { ...options, path: workingDirectory })]);
|
|
30
27
|
};
|
|
31
28
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEPENDENCIES_CONFIG = void 0;
|
|
4
|
-
exports.DEPENDENCIES_CONFIG = {
|
|
5
|
-
icon: {
|
|
6
|
-
dependencies: {
|
|
7
|
-
'@hugeicons/core-free-icons': 'latest',
|
|
8
|
-
},
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=dependencies.constant.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.constant.js","sourceRoot":"","sources":["../../../../../src/schematics/dependency-manager/dependencies.constant.ts"],"names":[],"mappings":";;;AAEa,QAAA,mBAAmB,GAAyB;IACvD,IAAI,EAAE;QACJ,YAAY,EAAE;YACZ,4BAA4B,EAAE,QAAQ;SACvC;KACF;CACF,CAAC","sourcesContent":["import { FilesConfig } from '../../types';\n\nexport const DEPENDENCIES_CONFIG: Partial<FilesConfig> = {\n icon: {\n dependencies: {\n '@hugeicons/core-free-icons': 'latest',\n },\n },\n};\n"]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dependencyManager = dependencyManager;
|
|
4
|
-
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
5
|
-
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
|
6
|
-
const selected_elements_1 = require("../../services/selected-elements");
|
|
7
|
-
const dependencies_constant_1 = require("./dependencies.constant");
|
|
8
|
-
const get_dependencies_1 = require("./utils/get-dependencies");
|
|
9
|
-
function dependencyManager() {
|
|
10
|
-
return (tree, context) => {
|
|
11
|
-
const dependenciesToInstall = (0, get_dependencies_1.getDependencies)(selected_elements_1.selectedElements, dependencies_constant_1.DEPENDENCIES_CONFIG);
|
|
12
|
-
if (!dependenciesToInstall.length) {
|
|
13
|
-
context.logger.info('✅ No dependencies to install for the selected elements.');
|
|
14
|
-
return tree;
|
|
15
|
-
}
|
|
16
|
-
context.logger.info(`📦 Installing ${dependenciesToInstall.length} dependencies...`);
|
|
17
|
-
for (const dependency of dependenciesToInstall) {
|
|
18
|
-
(0, dependencies_1.addPackageJsonDependency)(tree, dependency);
|
|
19
|
-
}
|
|
20
|
-
context.addTask(new tasks_1.NodePackageInstallTask());
|
|
21
|
-
return tree;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/schematics/dependency-manager/index.ts"],"names":[],"mappings":";;AAQA,8CAkBC;AAzBD,4DAA0E;AAC1E,2EAAoG;AAEpG,wEAAoE;AACpE,mEAA8D;AAC9D,+DAA2D;AAE3D,SAAgB,iBAAiB;IAC/B,OAAO,CAAC,IAAU,EAAE,OAAO,EAAE,EAAE;QAC7B,MAAM,qBAAqB,GAAqB,IAAA,kCAAe,EAAC,oCAAgB,EAAE,2CAAmB,CAAC,CAAC;QAEvG,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;YAC/E,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,qBAAqB,CAAC,MAAM,kBAAkB,CAAC,CAAC;QAErF,KAAK,MAAM,UAAU,IAAI,qBAAqB,EAAE,CAAC;YAC/C,IAAA,uCAAwB,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,CAAC,OAAO,CAAC,IAAI,8BAAsB,EAAE,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Rule, Tree } from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\nimport { addPackageJsonDependency, NodeDependency } from '@schematics/angular/utility/dependencies';\n\nimport { selectedElements } from '../../services/selected-elements';\nimport { DEPENDENCIES_CONFIG } from './dependencies.constant';\nimport { getDependencies } from './utils/get-dependencies';\n\nexport function dependencyManager(): Rule {\n return (tree: Tree, context) => {\n const dependenciesToInstall: NodeDependency[] = getDependencies(selectedElements, DEPENDENCIES_CONFIG);\n\n if (!dependenciesToInstall.length) {\n context.logger.info('✅ No dependencies to install for the selected elements.');\n return tree;\n }\n\n context.logger.info(`📦 Installing ${dependenciesToInstall.length} dependencies...`);\n\n for (const dependency of dependenciesToInstall) {\n addPackageJsonDependency(tree, dependency);\n }\n\n context.addTask(new NodePackageInstallTask());\n return tree;\n };\n}\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Rule, Tree } from '@angular-devkit/schematics';
|
|
2
|
-
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
|
|
3
|
-
import { addPackageJsonDependency, NodeDependency } from '@schematics/angular/utility/dependencies';
|
|
4
|
-
|
|
5
|
-
import { selectedElements } from '../../services/selected-elements';
|
|
6
|
-
import { DEPENDENCIES_CONFIG } from './dependencies.constant';
|
|
7
|
-
import { getDependencies } from './utils/get-dependencies';
|
|
8
|
-
|
|
9
|
-
export function dependencyManager(): Rule {
|
|
10
|
-
return (tree: Tree, context) => {
|
|
11
|
-
const dependenciesToInstall: NodeDependency[] = getDependencies(selectedElements, DEPENDENCIES_CONFIG);
|
|
12
|
-
|
|
13
|
-
if (!dependenciesToInstall.length) {
|
|
14
|
-
context.logger.info('✅ No dependencies to install for the selected elements.');
|
|
15
|
-
return tree;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
context.logger.info(`📦 Installing ${dependenciesToInstall.length} dependencies...`);
|
|
19
|
-
|
|
20
|
-
for (const dependency of dependenciesToInstall) {
|
|
21
|
-
addPackageJsonDependency(tree, dependency);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
context.addTask(new NodePackageInstallTask());
|
|
25
|
-
return tree;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "NgZenDependencyManager",
|
|
4
|
-
"title": "NgZen Dependency Manager",
|
|
5
|
-
"properties": {
|
|
6
|
-
"installation": {
|
|
7
|
-
"type": "boolean",
|
|
8
|
-
"x-prompt": "Some elements require additional packages. Would you like to install them?",
|
|
9
|
-
"description": "Determines whether the required additional npm packages for the selected elements should be installed automatically."
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDependencies = getDependencies;
|
|
4
|
-
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
|
5
|
-
function getDependencies(selectedElements, dependenciesConfig) {
|
|
6
|
-
const dependencies = [];
|
|
7
|
-
for (const component of selectedElements) {
|
|
8
|
-
if (!dependenciesConfig[component])
|
|
9
|
-
continue;
|
|
10
|
-
for (const type of Object.values(dependencies_1.NodeDependencyType)) {
|
|
11
|
-
const typeDeps = dependenciesConfig[component][type];
|
|
12
|
-
if (!typeDeps)
|
|
13
|
-
continue;
|
|
14
|
-
for (const [name, version] of Object.entries(typeDeps)) {
|
|
15
|
-
dependencies.push({
|
|
16
|
-
type,
|
|
17
|
-
name,
|
|
18
|
-
version,
|
|
19
|
-
overwrite: false,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return dependencies;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=get-dependencies.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-dependencies.js","sourceRoot":"","sources":["../../../../../../src/schematics/dependency-manager/utils/get-dependencies.ts"],"names":[],"mappings":";;AAKA,0CAyBC;AA9BD,2EAA8F;AAK9F,SAAgB,eAAe,CAC7B,gBAA0B,EAC1B,kBAAwC;IAExC,MAAM,YAAY,GAAqB,EAAE,CAAC;IAE1C,KAAK,MAAM,SAAS,IAAI,gBAAgB,EAAE,CAAC;QACzC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC;YAAE,SAAS;QAE7C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,iCAAkB,CAAC,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC;YACrD,IAAI,CAAC,QAAQ;gBAAE,SAAS;YAExB,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACvD,YAAY,CAAC,IAAI,CAAC;oBAChB,IAAI;oBACJ,IAAI;oBACJ,OAAO;oBACP,SAAS,EAAE,KAAK;iBACjB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { NodeDependency, NodeDependencyType } from '@schematics/angular/utility/dependencies';\n\nimport { FilesConfig } from '../../../types';\nimport { UiType } from '../../ui/schema';\n\nexport function getDependencies(\n selectedElements: UiType[],\n dependenciesConfig: Partial<FilesConfig>\n): NodeDependency[] {\n const dependencies: NodeDependency[] = [];\n\n for (const component of selectedElements) {\n if (!dependenciesConfig[component]) continue;\n\n for (const type of Object.values(NodeDependencyType)) {\n const typeDeps = dependenciesConfig[component][type];\n if (!typeDeps) continue;\n\n for (const [name, version] of Object.entries(typeDeps)) {\n dependencies.push({\n type,\n name,\n version,\n overwrite: false,\n });\n }\n }\n }\n\n return dependencies;\n}\n"]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { NodeDependency, NodeDependencyType } from '@schematics/angular/utility/dependencies';
|
|
2
|
-
|
|
3
|
-
import { FilesConfig } from '../../../types';
|
|
4
|
-
import { UiType } from '../../ui/schema';
|
|
5
|
-
|
|
6
|
-
export function getDependencies(
|
|
7
|
-
selectedElements: UiType[],
|
|
8
|
-
dependenciesConfig: Partial<FilesConfig>
|
|
9
|
-
): NodeDependency[] {
|
|
10
|
-
const dependencies: NodeDependency[] = [];
|
|
11
|
-
|
|
12
|
-
for (const component of selectedElements) {
|
|
13
|
-
if (!dependenciesConfig[component]) continue;
|
|
14
|
-
|
|
15
|
-
for (const type of Object.values(NodeDependencyType)) {
|
|
16
|
-
const typeDeps = dependenciesConfig[component][type];
|
|
17
|
-
if (!typeDeps) continue;
|
|
18
|
-
|
|
19
|
-
for (const [name, version] of Object.entries(typeDeps)) {
|
|
20
|
-
dependencies.push({
|
|
21
|
-
type,
|
|
22
|
-
name,
|
|
23
|
-
version,
|
|
24
|
-
overwrite: false,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return dependencies;
|
|
31
|
-
}
|