@progress/kendo-angular-schematics 11.0.0-develop.79
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/LICENSE.md +11 -0
- package/NOTICE.txt +654 -0
- package/collection.json +53 -0
- package/package.json +33 -0
- package/src/charts/categorical/files/data.d.ts +5 -0
- package/src/charts/categorical/files/data.js +29 -0
- package/src/charts/categorical/files/data.js.map +1 -0
- package/src/charts/categorical/files/data.ts +25 -0
- package/src/charts/categorical/files/html/__name@dasherize__/__name@dasherize__.component.html +46 -0
- package/src/charts/categorical/files/html/__name@dasherize__/__name@dasherize__.component.ts +25 -0
- package/src/charts/categorical/files/inline/__name@dasherize__/__name@dasherize__.component.ts +69 -0
- package/src/charts/categorical/index.d.ts +7 -0
- package/src/charts/categorical/index.js +124 -0
- package/src/charts/categorical/index.js.map +1 -0
- package/src/charts/categorical/schema.d.ts +92 -0
- package/src/charts/categorical/schema.js +54 -0
- package/src/charts/categorical/schema.js.map +1 -0
- package/src/charts/categorical/schema.json +253 -0
- package/src/charts/circular/files/data.d.ts +5 -0
- package/src/charts/circular/files/data.js +15 -0
- package/src/charts/circular/files/data.js.map +1 -0
- package/src/charts/circular/files/data.ts +11 -0
- package/src/charts/circular/files/html/__name@dasherize__/__name@dasherize__.component.html +27 -0
- package/src/charts/circular/files/html/__name@dasherize__/__name@dasherize__.component.ts +23 -0
- package/src/charts/circular/files/inline/__name@dasherize__/__name@dasherize__.component.ts +52 -0
- package/src/charts/circular/index.d.ts +7 -0
- package/src/charts/circular/index.js +50 -0
- package/src/charts/circular/index.js.map +1 -0
- package/src/charts/circular/schema.d.ts +31 -0
- package/src/charts/circular/schema.js +7 -0
- package/src/charts/circular/schema.js.map +1 -0
- package/src/charts/circular/schema.json +175 -0
- package/src/charts/scatter/files/data.d.ts +5 -0
- package/src/charts/scatter/files/data.js +25 -0
- package/src/charts/scatter/files/data.js.map +1 -0
- package/src/charts/scatter/files/data.ts +21 -0
- package/src/charts/scatter/files/html/__name@dasherize__/__name@dasherize__.component.html +35 -0
- package/src/charts/scatter/files/html/__name@dasherize__/__name@dasherize__.component.ts +21 -0
- package/src/charts/scatter/files/inline/__name@dasherize__/__name@dasherize__.component.ts +58 -0
- package/src/charts/scatter/index.d.ts +7 -0
- package/src/charts/scatter/index.js +50 -0
- package/src/charts/scatter/index.js.map +1 -0
- package/src/charts/scatter/schema.d.ts +32 -0
- package/src/charts/scatter/schema.js +7 -0
- package/src/charts/scatter/schema.js.map +1 -0
- package/src/charts/scatter/schema.json +209 -0
- package/src/charts/stock/files/data.d.ts +5 -0
- package/src/charts/stock/files/data.js +418 -0
- package/src/charts/stock/files/data.js.map +1 -0
- package/src/charts/stock/files/data.ts +414 -0
- package/src/charts/stock/files/html/__name@dasherize__/__name@dasherize__.component.html +57 -0
- package/src/charts/stock/files/html/__name@dasherize__/__name@dasherize__.component.ts +23 -0
- package/src/charts/stock/files/inline/__name@dasherize__/__name@dasherize__.component.ts +83 -0
- package/src/charts/stock/index.d.ts +7 -0
- package/src/charts/stock/index.js +50 -0
- package/src/charts/stock/index.js.map +1 -0
- package/src/charts/stock/schema.d.ts +36 -0
- package/src/charts/stock/schema.js +7 -0
- package/src/charts/stock/schema.js.map +1 -0
- package/src/charts/stock/schema.json +285 -0
- package/src/component/files/__full-path__/__name@folder-name__/__name@dasherize__.component.__styleext__ +0 -0
- package/src/component/files/__full-path__/__name@folder-name__/__name@dasherize__.component.html +1 -0
- package/src/component/files/__full-path__/__name@folder-name__/__name@dasherize__.component.ts +23 -0
- package/src/component/index.d.ts +6 -0
- package/src/component/index.js +18 -0
- package/src/component/index.js.map +1 -0
- package/src/component/schema.d.ts +66 -0
- package/src/component/schema.js +7 -0
- package/src/component/schema.js.map +1 -0
- package/src/component/schema.json +96 -0
- package/src/grid/files/data.d.ts +5 -0
- package/src/grid/files/data.js +1241 -0
- package/src/grid/files/data.js.map +1 -0
- package/src/grid/files/data.ts +1237 -0
- package/src/grid/files/html/__name@dasherize__/__name@dasherize__.component.html +48 -0
- package/src/grid/files/html/__name@dasherize__/__name@dasherize__.component.ts +29 -0
- package/src/grid/files/inline/__name@dasherize__/__name@dasherize__.component.ts +79 -0
- package/src/grid/index.d.ts +7 -0
- package/src/grid/index.js +84 -0
- package/src/grid/index.js.map +1 -0
- package/src/grid/schema.d.ts +44 -0
- package/src/grid/schema.js +28 -0
- package/src/grid/schema.js.map +1 -0
- package/src/grid/schema.json +168 -0
- package/src/ngAdd/index.d.ts +7 -0
- package/src/ngAdd/index.js +143 -0
- package/src/ngAdd/index.js.map +1 -0
- package/src/ngAdd/schema.d.ts +61 -0
- package/src/ngAdd/schema.js +7 -0
- package/src/ngAdd/schema.js.map +1 -0
- package/src/ngAdd/schema.json +70 -0
- package/src/ngAdd/theming.d.ts +8 -0
- package/src/ngAdd/theming.js +79 -0
- package/src/ngAdd/theming.js.map +1 -0
- package/src/rules/index.d.ts +11 -0
- package/src/rules/index.js +80 -0
- package/src/rules/index.js.map +1 -0
- package/src/scheduler/files/events-utc.d.ts +5 -0
- package/src/scheduler/files/events-utc.js +846 -0
- package/src/scheduler/files/events-utc.js.map +1 -0
- package/src/scheduler/files/events-utc.ts +842 -0
- package/src/scheduler/files/html/__name@dasherize__/__name@dasherize__.component.html +29 -0
- package/src/scheduler/files/html/__name@dasherize__/__name@dasherize__.component.ts +17 -0
- package/src/scheduler/files/inline/__name@dasherize__/__name@dasherize__.component.ts +48 -0
- package/src/scheduler/index.d.ts +7 -0
- package/src/scheduler/index.js +47 -0
- package/src/scheduler/index.js.map +1 -0
- package/src/scheduler/schema.d.ts +16 -0
- package/src/scheduler/schema.js +7 -0
- package/src/scheduler/schema.js.map +1 -0
- package/src/scheduler/schema.json +78 -0
- package/src/utils/ast-utils.d.ts +34 -0
- package/src/utils/ast-utils.js +206 -0
- package/src/utils/ast-utils.js.map +1 -0
- package/src/utils/bootstrap-module.d.ts +9 -0
- package/src/utils/bootstrap-module.js +54 -0
- package/src/utils/bootstrap-module.js.map +1 -0
- package/src/utils/find-module.d.ts +25 -0
- package/src/utils/find-module.js +91 -0
- package/src/utils/find-module.js.map +1 -0
- package/src/utils/index.d.ts +16 -0
- package/src/utils/index.js +74 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/test/create-app-module.d.ts +6 -0
- package/src/utils/test/create-app-module.js +24 -0
- package/src/utils/test/create-app-module.js.map +1 -0
- package/src/utils/test/create-cli-config.d.ts +6 -0
- package/src/utils/test/create-cli-config.js +121 -0
- package/src/utils/test/create-cli-config.js.map +1 -0
- package/src/utils/test/create-main-bootstrap.d.ts +6 -0
- package/src/utils/test/create-main-bootstrap.js +26 -0
- package/src/utils/test/create-main-bootstrap.js.map +1 -0
- package/src/utils/test/create-package-json.d.ts +6 -0
- package/src/utils/test/create-package-json.js +20 -0
- package/src/utils/test/create-package-json.js.map +1 -0
- package/src/utils/test/index.d.ts +8 -0
- package/src/utils/test/index.js +12 -0
- package/src/utils/test/index.js.map +1 -0
- package/src/utils/workspace.d.ts +16 -0
- package/src/utils/workspace.js +58 -0
- package/src/utils/workspace.js.map +1 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<kendo-grid <% if (paging || sorting || filtering || grouping) {%>
|
|
2
|
+
[kendoGridBinding]="gridData"<% } else {%>[data]="gridData"<% } %><% if (editing === 'inline') {%>
|
|
3
|
+
[kendoGridReactiveEditing]="createFormGroup"<% }%><% if (editing === 'incell') {%>
|
|
4
|
+
[kendoGridInCellEditing]="createFormGroup"<% }%><% if (filtering){%>
|
|
5
|
+
[filterable]="true"<% }%><% if (grouping) {%>
|
|
6
|
+
[groupable]="true"<% } %><% if (paging) {%>
|
|
7
|
+
[pageable]="true"<% } %><% if (sorting) {%>
|
|
8
|
+
[sortable]="true"<% } %><% if (resizing) {%>
|
|
9
|
+
[resizable]="true"<% } %><% if (reordering) {%>
|
|
10
|
+
[reorderable]="true"<% } %><% if (columnMenu) {%>
|
|
11
|
+
[columnMenu]="true"<% } %><% if (navigable) {%>
|
|
12
|
+
[navigable]="true"<% } %><% if (height) {%>
|
|
13
|
+
[height]="<%=height%>"<% } %><% if (paging) {%>
|
|
14
|
+
[pageSize]="pageSize"><% } %>><% if (columns.length) {%><% for (let column of columns) {%>
|
|
15
|
+
<kendo-grid-column<% if (column.field) {%>
|
|
16
|
+
field="<%=column.field%>"<% } %><% if (column.title) {%>
|
|
17
|
+
title="<%=column.title%>"<% } %><% if (column.hidden) {%>
|
|
18
|
+
[hidden]="<%=column.hidden%>"<% } %><% if (column.locked) {%>
|
|
19
|
+
[locked]="<%=column.locked%>"<% } %><% if (column.sticky) {%>
|
|
20
|
+
[sticky]="<%=column.sticky%>"<% } %><% if (column.width) {%>
|
|
21
|
+
[width]="<%=column.width%>"<% } %><% if (column.columnMenu) {%>
|
|
22
|
+
[columnMenu]="<%=column.columnMenu%>"<% } %><% if (column.editable) {%>
|
|
23
|
+
[editable]="<%=column.editable%>"><% } %>></kendo-grid-column><% } %><% } %><% if (editing === 'inline') {%>
|
|
24
|
+
<kendo-grid-command-column title="Command" [width]="220">
|
|
25
|
+
<ng-template kendoGridCellTemplate let-formGroup="formGroup" let-isNew="isNew">
|
|
26
|
+
<button kendoGridEditCommand [primary]="true">Edit</button>
|
|
27
|
+
<button kendoGridRemoveCommand>Remove</button>
|
|
28
|
+
<button kendoGridSaveCommand [disabled]="formGroup?.invalid">
|
|
29
|
+
{{ isNew ? "Add" : "Update" }}
|
|
30
|
+
</button>
|
|
31
|
+
<button kendoGridCancelCommand>
|
|
32
|
+
{{ isNew ? "Discard changes" : "Cancel" }}
|
|
33
|
+
</button>
|
|
34
|
+
</ng-template>
|
|
35
|
+
</kendo-grid-command-column><% } %><% if (editing === 'incell') {%>
|
|
36
|
+
<kendo-grid-command-column title="command" [width]="220">
|
|
37
|
+
<ng-template kendoGridCellTemplate let-formGroup="formGroup" let-isNew="isNew">
|
|
38
|
+
<button kendoGridRemoveCommand>Remove</button>
|
|
39
|
+
<button kendoGridSaveCommand [disabled]="formGroup?.invalid">
|
|
40
|
+
Add
|
|
41
|
+
</button>
|
|
42
|
+
<button kendoGridCancelCommand>Discard</button>
|
|
43
|
+
</ng-template>
|
|
44
|
+
</kendo-grid-command-column><% } %><% if (editing === 'incell' || editing === 'inline') {%>
|
|
45
|
+
<ng-template kendoGridToolbarTemplate>
|
|
46
|
+
<button kendoGridAddCommand>Add new</button>
|
|
47
|
+
</ng-template><% } %>
|
|
48
|
+
</kendo-grid>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Component } from '@angular/core';<% if (dataPath) {%>
|
|
6
|
+
import { <%= dataName %> } from '<%= dataPath %>'; <% } %><% if (dataSource === "Example") {%>
|
|
7
|
+
import { products } from './data'; <% } %><% if (dataSource === "Mock Data") {%>
|
|
8
|
+
import data from './data';<% } %><% if (editing) {%>
|
|
9
|
+
import { FormBuilder, FormGroup } from '@angular/forms';
|
|
10
|
+
import { CreateFormGroupArgs } from '@progress/kendo-angular-grid';<% } %>
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: '<%= dasherize(name) %>-component',
|
|
14
|
+
templateUrl: './<%= dasherize(name) %>.component.html',
|
|
15
|
+
<% if (inlineStyle) {%> styleUrls: ['./<%= dasherize(name) %>.component.css']<% } else {%>styles: [``]<% } %>
|
|
16
|
+
})
|
|
17
|
+
export class <%= classify(name) %>Component {
|
|
18
|
+
public gridData: any[] = <% if (dataSource === "Example") { %>products<% } else if (dataSource === "Mock Data") { %>data<% } else if (dataName) { %><%=dataName%><% } else { %>products<%} %>;<% if (paging) { %>
|
|
19
|
+
public pageSize: number = <%=pageSize%>;<% } %><% if (editing) {%>
|
|
20
|
+
|
|
21
|
+
constructor(private formBuilder: FormBuilder) { }
|
|
22
|
+
|
|
23
|
+
public createFormGroup = (args: CreateFormGroupArgs): FormGroup => {
|
|
24
|
+
// TODO: Implement default item factory.
|
|
25
|
+
const item = args.isNew ? Object.keys(this.gridData[0]).reduce((acc, curr) => (acc as any)[curr] = null || acc, {}) : args.dataItem;
|
|
26
|
+
|
|
27
|
+
return this.formBuilder.group(item);
|
|
28
|
+
};<% } %>
|
|
29
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Component } from '@angular/core';<% if (dataPath) {%>
|
|
6
|
+
import { <%= dataName %> } from '<%= dataPath %>'; <% } %><% if (dataSource === "Example") {%>
|
|
7
|
+
import { products } from './data'; <% } %><% if (dataSource === "Mock Data") {%>
|
|
8
|
+
import data from './data';<% } %><% if (editing === 'inline' || editing === 'incell') {%>
|
|
9
|
+
import { FormBuilder, FormGroup } from '@angular/forms';
|
|
10
|
+
import { CreateFormGroupArgs } from '@progress/kendo-angular-grid';<% } %>
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: '<%= dasherize(name) %>-component',
|
|
14
|
+
template: `
|
|
15
|
+
<kendo-grid <% if (paging || sorting || filtering || grouping) {%>
|
|
16
|
+
[kendoGridBinding]="gridData"<% } else {%>[data]="gridData"<% } %><% if (editing === 'inline') {%>
|
|
17
|
+
[kendoGridReactiveEditing]="createFormGroup"<% }%><% if (editing === 'incell') {%>
|
|
18
|
+
[kendoGridInCellEditing]="createFormGroup"<% }%><% if (filtering){%>
|
|
19
|
+
[filterable]="true"<% }%><% if (grouping) {%>
|
|
20
|
+
[groupable]="true"<% } %><% if (paging) {%>
|
|
21
|
+
[pageable]="true"<% } %><% if (sorting) {%>
|
|
22
|
+
[sortable]="true"<% } %><% if (resizing) {%>
|
|
23
|
+
[resizable]="true"<% } %><% if (reordering) {%>
|
|
24
|
+
[reorderable]="true"<% } %><% if (columnMenu) {%>
|
|
25
|
+
[columnMenu]="true"<% } %><% if (navigable) {%>
|
|
26
|
+
[navigable]="true"<% } %><% if (height) {%>
|
|
27
|
+
[height]="<%=height%>"<% } %><% if (paging) {%>
|
|
28
|
+
[pageSize]="pageSize"><% } %>><% if (columns.length) {%><% for (let column of columns) {%>
|
|
29
|
+
<kendo-grid-column<% if (column.field) {%>
|
|
30
|
+
field="<%=column.field%>"<% } %><% if (column.title) {%>
|
|
31
|
+
title="<%=column.title%>"<% } %><% if (column.hidden) {%>
|
|
32
|
+
[hidden]="<%=column.hidden%>"<% } %><% if (column.locked) {%>
|
|
33
|
+
[locked]="<%=column.locked%>"<% } %><% if (column.sticky) {%>
|
|
34
|
+
[sticky]="<%=column.sticky%>"<% } %><% if (column.width) {%>
|
|
35
|
+
[width]="<%=column.width%>"<% } %><% if (column.columnMenu) {%>
|
|
36
|
+
[columnMenu]="<%=column.columnMenu%>"<% } %><% if (column.editable) {%>
|
|
37
|
+
[editable]="<%=column.editable%>"><% } %>></kendo-grid-column><% } %><% } %><% if (editing === 'inline') {%>
|
|
38
|
+
<kendo-grid-command-column title="Command" [width]="220">
|
|
39
|
+
<ng-template kendoGridCellTemplate let-formGroup="formGroup" let-isNew="isNew">
|
|
40
|
+
<button kendoGridEditCommand [primary]="true">Edit</button>
|
|
41
|
+
<button kendoGridRemoveCommand>Remove</button>
|
|
42
|
+
<button kendoGridSaveCommand [disabled]="formGroup?.invalid">
|
|
43
|
+
{{ isNew ? "Add" : "Update" }}
|
|
44
|
+
</button>
|
|
45
|
+
<button kendoGridCancelCommand>
|
|
46
|
+
{{ isNew ? "Discard changes" : "Cancel" }}
|
|
47
|
+
</button>
|
|
48
|
+
</ng-template>
|
|
49
|
+
</kendo-grid-command-column><% } %><% if (editing === 'incell') {%>
|
|
50
|
+
<kendo-grid-command-column title="command" [width]="220">
|
|
51
|
+
<ng-template kendoGridCellTemplate let-formGroup="formGroup" let-isNew="isNew">
|
|
52
|
+
<button kendoGridRemoveCommand>Remove</button>
|
|
53
|
+
<button kendoGridSaveCommand [disabled]="formGroup?.invalid">
|
|
54
|
+
Add
|
|
55
|
+
</button>
|
|
56
|
+
<button kendoGridCancelCommand>Discard</button>
|
|
57
|
+
</ng-template>
|
|
58
|
+
</kendo-grid-command-column><% } %><% if (editing === 'incell' || editing === 'inline') {%>
|
|
59
|
+
<ng-template kendoGridToolbarTemplate>
|
|
60
|
+
<button kendoGridAddCommand>Add new</button>
|
|
61
|
+
</ng-template><% } %>
|
|
62
|
+
</kendo-grid>
|
|
63
|
+
`,<% if (inlineStyle) {%>
|
|
64
|
+
styles: [``]<% } else {%>
|
|
65
|
+
styleUrls: ['./<%= dasherize(name) %>.component.css']<% } %>
|
|
66
|
+
})
|
|
67
|
+
export class <%= classify(name) %>Component {
|
|
68
|
+
public gridData: any[] = <% if (dataSource === "Example") { %>products<% } else if (dataSource === "Mock Data") { %>data<% } else if (dataName) { %><%=dataName%><% } else { %>products<%} %>;<% if (paging) { %>
|
|
69
|
+
public pageSize: number = <%=pageSize%>;<% if (editing === 'inline' || editing === 'incell') {%>
|
|
70
|
+
|
|
71
|
+
constructor(private formBuilder: FormBuilder) { }
|
|
72
|
+
|
|
73
|
+
public createFormGroup = (args: CreateFormGroupArgs): FormGroup => {
|
|
74
|
+
// TODO: Implement default item factory.
|
|
75
|
+
const item = args.isNew ? Object.keys(this.gridData[0]).reduce((acc, curr) => (acc as any)[curr] = null || acc, {}) : args.dataItem;
|
|
76
|
+
|
|
77
|
+
return this.formBuilder.group(item);
|
|
78
|
+
};<% } %>
|
|
79
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Rule } from '@angular-devkit/schematics';
|
|
6
|
+
import { Schema } from './schema';
|
|
7
|
+
export declare function grid(_options: Schema): Rule;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
"use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.grid = void 0;
|
|
8
|
+
const core_1 = require("@angular-devkit/core");
|
|
9
|
+
const strings_1 = require("@angular-devkit/core/src/utils/strings");
|
|
10
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
const schema_1 = require("./schema");
|
|
13
|
+
const data_1 = require("./files/data");
|
|
14
|
+
const utils_1 = require("../utils");
|
|
15
|
+
const classify = core_1.strings.classify;
|
|
16
|
+
const arrayify = (args) => args.map(s => `'${s}'`).join(", ");
|
|
17
|
+
function grid(_options) {
|
|
18
|
+
return (_tree, _context) => {
|
|
19
|
+
_options.name = (0, path_1.basename)(_options.name);
|
|
20
|
+
const defaults = {
|
|
21
|
+
style: "css"
|
|
22
|
+
};
|
|
23
|
+
let path = (0, path_1.normalize)('/' + (0, path_1.dirname)((_options.path + '/' + _options.name)));
|
|
24
|
+
if (process.platform == "win32") {
|
|
25
|
+
path = path.replace(/\\/g, '/');
|
|
26
|
+
}
|
|
27
|
+
const parsedComplexOptions = (0, utils_1.parseComplexOptions)(['columns'], _options);
|
|
28
|
+
const overrides = {};
|
|
29
|
+
if (_options.dataSource == schema_1.DataSource.Example) {
|
|
30
|
+
// If the data source is "Example", use a predefined template for data and columns
|
|
31
|
+
overrides.columns = [
|
|
32
|
+
{ field: "ProductID", title: "ID" },
|
|
33
|
+
{ field: "ProductName", title: "Product Name" },
|
|
34
|
+
{ field: "UnitPrice", title: "Unit Price" }
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
const templateOptions = {
|
|
38
|
+
...defaults,
|
|
39
|
+
..._options,
|
|
40
|
+
...parsedComplexOptions,
|
|
41
|
+
...overrides,
|
|
42
|
+
classify,
|
|
43
|
+
dasherize: strings_1.dasherize,
|
|
44
|
+
arrayify
|
|
45
|
+
};
|
|
46
|
+
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(_options.inlineTemplate ? './files/inline' : './files/html'), [
|
|
47
|
+
(0, schematics_1.template)(templateOptions),
|
|
48
|
+
(0, schematics_1.move)(_options.path)
|
|
49
|
+
]);
|
|
50
|
+
const angularComponentOptions = {
|
|
51
|
+
path: _options.path,
|
|
52
|
+
name: _options.name,
|
|
53
|
+
inlineTemplate: _options.inlineTemplate,
|
|
54
|
+
inlineStyle: _options.inlineStyle,
|
|
55
|
+
skipTests: _options.skipTests,
|
|
56
|
+
style: templateOptions.style
|
|
57
|
+
};
|
|
58
|
+
if (_options.dataSource == schema_1.DataSource.Example) {
|
|
59
|
+
// Import the example datasource
|
|
60
|
+
_tree.create(`${_options.path}/${(0, strings_1.dasherize)(_options.name)}/data.ts`, data_1.productsSourceCode);
|
|
61
|
+
}
|
|
62
|
+
else if (_options.dataSource == schema_1.DataSource['Mock Data']) {
|
|
63
|
+
// Generate mocked data out of the column defitions
|
|
64
|
+
let dataSourceCode = `export const data = [{\n`;
|
|
65
|
+
for (let i = 0; i <= 15; i++) {
|
|
66
|
+
for (const column of parsedComplexOptions.columns) {
|
|
67
|
+
dataSourceCode += ` "${column.field}": "${column.title ?? column.field} ${i}",\n`;
|
|
68
|
+
}
|
|
69
|
+
if (i < 15) {
|
|
70
|
+
dataSourceCode += ` }, {\n`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
dataSourceCode += ` }];\n`;
|
|
74
|
+
dataSourceCode += `export default data;`;
|
|
75
|
+
_tree.create(`${_options.path}/${(0, strings_1.dasherize)(_options.name)}/data.ts`, dataSourceCode);
|
|
76
|
+
}
|
|
77
|
+
return (0, schematics_1.chain)([
|
|
78
|
+
(0, schematics_1.externalSchematic)('@schematics/angular', 'component', angularComponentOptions),
|
|
79
|
+
(0, schematics_1.mergeWith)(templateSource, schematics_1.MergeStrategy.Overwrite)
|
|
80
|
+
]);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
exports.grid = grid;
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/grid/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
export declare enum DataSource {
|
|
6
|
+
/**
|
|
7
|
+
* An example data source will be added to the project with predefined column definitions.
|
|
8
|
+
* The data and column definitions can not be modified.
|
|
9
|
+
*
|
|
10
|
+
* This is the default.
|
|
11
|
+
*/
|
|
12
|
+
"Example" = "Example",
|
|
13
|
+
/**
|
|
14
|
+
* The user is expected to provide column definitions.
|
|
15
|
+
* A mock data will be generated out of the column definitions.
|
|
16
|
+
*/
|
|
17
|
+
"Mock Data" = "Mock Data",
|
|
18
|
+
/**
|
|
19
|
+
* The user can specify a basic module to bind to and provide column definitions,
|
|
20
|
+
* but in general the user will have to author some code to connect the data.
|
|
21
|
+
*/
|
|
22
|
+
"Existing App Data" = "Existing App Data"
|
|
23
|
+
}
|
|
24
|
+
export interface Schema {
|
|
25
|
+
path?: string;
|
|
26
|
+
name: string;
|
|
27
|
+
inlineStyle: boolean;
|
|
28
|
+
inlineTemplate: boolean;
|
|
29
|
+
skipTests: boolean;
|
|
30
|
+
filtering?: boolean;
|
|
31
|
+
grouping?: boolean;
|
|
32
|
+
paging?: boolean;
|
|
33
|
+
sorting?: boolean;
|
|
34
|
+
resizing?: boolean;
|
|
35
|
+
reordering?: boolean;
|
|
36
|
+
columnMenu?: boolean;
|
|
37
|
+
navigable?: boolean;
|
|
38
|
+
pageSize?: number;
|
|
39
|
+
height?: number;
|
|
40
|
+
columns?: string;
|
|
41
|
+
dataSource: DataSource;
|
|
42
|
+
dataPath?: string;
|
|
43
|
+
dataName: string;
|
|
44
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
"use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DataSource = void 0;
|
|
8
|
+
var DataSource;
|
|
9
|
+
(function (DataSource) {
|
|
10
|
+
/**
|
|
11
|
+
* An example data source will be added to the project with predefined column definitions.
|
|
12
|
+
* The data and column definitions can not be modified.
|
|
13
|
+
*
|
|
14
|
+
* This is the default.
|
|
15
|
+
*/
|
|
16
|
+
DataSource["Example"] = "Example";
|
|
17
|
+
/**
|
|
18
|
+
* The user is expected to provide column definitions.
|
|
19
|
+
* A mock data will be generated out of the column definitions.
|
|
20
|
+
*/
|
|
21
|
+
DataSource["Mock Data"] = "Mock Data";
|
|
22
|
+
/**
|
|
23
|
+
* The user can specify a basic module to bind to and provide column definitions,
|
|
24
|
+
* but in general the user will have to author some code to connect the data.
|
|
25
|
+
*/
|
|
26
|
+
DataSource["Existing App Data"] = "Existing App Data";
|
|
27
|
+
})(DataSource = exports.DataSource || (exports.DataSource = {}));
|
|
28
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/grid/schema.ts"],"names":[],"mappings":";;;AACA,IAAY,UAoBX;AApBD,WAAY,UAAU;IACpB;;;;;OAKG;IACH,iCAAqB,CAAA;IAErB;;;OAGG;IACH,qCAAyB,CAAA;IAEzB;;;OAGG;IACH,qDAAyC,CAAA;AAC3C,CAAC,EApBW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAoBrB"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
{
|
|
2
|
+
"progress:name": "Grid",
|
|
3
|
+
"progress:description": "Generate new Kendo UI for Angular Grid page",
|
|
4
|
+
"$schema": "http://json-schema.org/schema",
|
|
5
|
+
"$id": "Schema",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"path": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"format": "path",
|
|
11
|
+
"progress:editorVisible": false
|
|
12
|
+
},
|
|
13
|
+
"name": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"$default": {
|
|
16
|
+
"$source": "argv",
|
|
17
|
+
"index": 0
|
|
18
|
+
},
|
|
19
|
+
"default": "GridPage"
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
"inlineTemplate": {
|
|
23
|
+
"progress:category": "Code Generation",
|
|
24
|
+
"progress:display-name": "Inline template",
|
|
25
|
+
"description": "Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.",
|
|
26
|
+
"type": "boolean",
|
|
27
|
+
"default": false,
|
|
28
|
+
"alias": "t"
|
|
29
|
+
},
|
|
30
|
+
"inlineStyle": {
|
|
31
|
+
"progress:category": "Code Generation",
|
|
32
|
+
"description": "Include styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file.",
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"default": false,
|
|
35
|
+
"alias": "s"
|
|
36
|
+
},
|
|
37
|
+
"skipTests": {
|
|
38
|
+
"progress:category": "Code Generation",
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"description": "Do not create \"spec.ts\" test files for the new component.",
|
|
41
|
+
"default": false
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
"editing": {
|
|
45
|
+
"progress:category": "Grid Features",
|
|
46
|
+
"description": "Configures the Grid for inline or incell editing.",
|
|
47
|
+
"type": "string",
|
|
48
|
+
"enum": ["none", "inline", "incell"],
|
|
49
|
+
"default": "none"
|
|
50
|
+
},
|
|
51
|
+
"filtering": {
|
|
52
|
+
"progress:category": "Grid Features",
|
|
53
|
+
"description": "Enables Grid filtering",
|
|
54
|
+
"type": "boolean",
|
|
55
|
+
"default": false
|
|
56
|
+
},
|
|
57
|
+
"grouping": {
|
|
58
|
+
"progress:category": "Grid Features",
|
|
59
|
+
"description": "Enables Grid grouping",
|
|
60
|
+
"type": "boolean",
|
|
61
|
+
"default": false
|
|
62
|
+
},
|
|
63
|
+
"paging": {
|
|
64
|
+
"progress:category": "Grid Features",
|
|
65
|
+
"description": "Enables Grid paging",
|
|
66
|
+
"type": "boolean",
|
|
67
|
+
"default": false
|
|
68
|
+
},
|
|
69
|
+
"sorting": {
|
|
70
|
+
"progress:category": "Grid Features",
|
|
71
|
+
"description": "Enables Grid sorting",
|
|
72
|
+
"type": "boolean",
|
|
73
|
+
"default": false
|
|
74
|
+
},
|
|
75
|
+
"resizing": {
|
|
76
|
+
"progress:category": "Grid Features",
|
|
77
|
+
"description": "Enables Grid resizing",
|
|
78
|
+
"type": "boolean",
|
|
79
|
+
"default": false
|
|
80
|
+
},
|
|
81
|
+
"reordering": {
|
|
82
|
+
"progress:category": "Grid Features",
|
|
83
|
+
"description": "Enables Grid reordering",
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
"default": false
|
|
86
|
+
},
|
|
87
|
+
"columnMenu": {
|
|
88
|
+
"progress:category": "Grid Features",
|
|
89
|
+
"description": "Enables Grid column menu",
|
|
90
|
+
"type": "boolean",
|
|
91
|
+
"default": false
|
|
92
|
+
},
|
|
93
|
+
"navigable": {
|
|
94
|
+
"progress:category": "Grid Features",
|
|
95
|
+
"description": "Makes the Grid navigable",
|
|
96
|
+
"type": "boolean",
|
|
97
|
+
"default": false
|
|
98
|
+
},
|
|
99
|
+
"pageSize": {
|
|
100
|
+
"progress:category": "Grid Features",
|
|
101
|
+
"description": "Sets the pageSize of a pageable Grid",
|
|
102
|
+
"type": "number",
|
|
103
|
+
"default": 3
|
|
104
|
+
},
|
|
105
|
+
"height": {
|
|
106
|
+
"progress:category": "Grid Features",
|
|
107
|
+
"description": "Sets the height of the Grid",
|
|
108
|
+
"type": "number",
|
|
109
|
+
"default": 300
|
|
110
|
+
},
|
|
111
|
+
"dataSource": {
|
|
112
|
+
"progress:category": "Data Source",
|
|
113
|
+
"description": "Select grid data source generation strategy",
|
|
114
|
+
"type": "string",
|
|
115
|
+
"default": "Example",
|
|
116
|
+
"enum": [ "Example", "Mock Data", "Existing App Data" ],
|
|
117
|
+
"progress:enum": [{
|
|
118
|
+
"name": "Example", "description": "An example data source will be added to the project, with predefined column definitions."
|
|
119
|
+
}, {
|
|
120
|
+
"name": "Mock Data", "description": "Specify column definitions, from which mock data will be generated and added to the project."
|
|
121
|
+
}, {
|
|
122
|
+
"name": "Existing App Data", "description": "Provide import path. If the data module does not exist in your project, you will have to generate it by hand."
|
|
123
|
+
}]
|
|
124
|
+
},
|
|
125
|
+
"dataPath": {
|
|
126
|
+
"progress:category": "Data Source",
|
|
127
|
+
"description": "Sets a path to the local data file",
|
|
128
|
+
"type": "string",
|
|
129
|
+
"progress:attributes": [
|
|
130
|
+
{ "type": "hideOnPropertyValue", "property": "dataSource", "values": [ "Example", "Mock Data" ] }
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
"dataName": {
|
|
134
|
+
"progress:category": "Data Source",
|
|
135
|
+
"description": "Sets a name to the local data property",
|
|
136
|
+
"type": "string",
|
|
137
|
+
"progress:attributes": [
|
|
138
|
+
{ "type": "hideOnPropertyValue", "property": "dataSource", "values": [ "Example", "Mock Data" ] }
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
"columns": {
|
|
142
|
+
"progress:category": "Data Source",
|
|
143
|
+
"progress:type": "array",
|
|
144
|
+
"hidden": true,
|
|
145
|
+
"description": "Specifies the columns in the Grid",
|
|
146
|
+
"type": "string",
|
|
147
|
+
"progress:attributes": [
|
|
148
|
+
{ "type": "hideOnPropertyValue", "property": "dataSource", "values": [ "Example" ] }
|
|
149
|
+
],
|
|
150
|
+
"items": {
|
|
151
|
+
"type": "object",
|
|
152
|
+
"properties": {
|
|
153
|
+
"field": {"type": "string"},
|
|
154
|
+
"title": {"type": "string"},
|
|
155
|
+
"hidden": {"type": "boolean"},
|
|
156
|
+
"locked": {"type": "boolean"},
|
|
157
|
+
"sticky": {"type": "boolean"},
|
|
158
|
+
"columnMenu": {"type": "boolean"},
|
|
159
|
+
"editable": {"type": "boolean"},
|
|
160
|
+
"width": {"type": "number"}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"required": [
|
|
166
|
+
"name"
|
|
167
|
+
]
|
|
168
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Rule } from '@angular-devkit/schematics';
|
|
6
|
+
import { Schema as RegisterSchema } from './schema';
|
|
7
|
+
export declare function ngAdd(options: RegisterSchema): Rule;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2022 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
"use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ngAdd = void 0;
|
|
8
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
9
|
+
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
10
|
+
const ts = require("typescript");
|
|
11
|
+
const rules_1 = require("../rules");
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
const theming_1 = require("./theming");
|
|
14
|
+
const readSource = (modulePath) => (tree) => {
|
|
15
|
+
const sourceText = (0, utils_1.fileContent)(tree, modulePath);
|
|
16
|
+
return ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
17
|
+
};
|
|
18
|
+
function updateNgModule(host, moduleToUpdate, data) {
|
|
19
|
+
const read = readSource(moduleToUpdate);
|
|
20
|
+
const changes = (0, utils_1.addImportToModule)({
|
|
21
|
+
source: read(host),
|
|
22
|
+
symbolName: data.import,
|
|
23
|
+
modulePath: data.from
|
|
24
|
+
});
|
|
25
|
+
(0, rules_1.applyChanges)(host, moduleToUpdate, changes);
|
|
26
|
+
if (data.export) {
|
|
27
|
+
const changes = (0, utils_1.addExportToModule)({
|
|
28
|
+
source: read(host),
|
|
29
|
+
symbolName: data.import,
|
|
30
|
+
modulePath: data.from
|
|
31
|
+
});
|
|
32
|
+
(0, rules_1.applyChanges)(host, moduleToUpdate, changes);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const runner = (deps, callback) => (...options) => deps.forEach(dep => {
|
|
36
|
+
if (!Object.hasOwnProperty.call(dep, 'condition') || dep.condition) {
|
|
37
|
+
callback(...options, dep);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
function importAllModules(options) {
|
|
41
|
+
return (host) => {
|
|
42
|
+
const moduleToUpdate = options.module;
|
|
43
|
+
if (!moduleToUpdate)
|
|
44
|
+
return host;
|
|
45
|
+
const dependencies = [
|
|
46
|
+
{
|
|
47
|
+
import: options.mainNgModule,
|
|
48
|
+
from: `@progress/kendo-angular-${options.package}`,
|
|
49
|
+
export: options.export
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
import: 'BrowserAnimationsModule',
|
|
53
|
+
from: '@angular/platform-browser/animations'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
from: 'hammerjs',
|
|
57
|
+
condition: options.importHammerjs
|
|
58
|
+
},
|
|
59
|
+
...options.dependencies
|
|
60
|
+
];
|
|
61
|
+
const run = runner(dependencies, updateNgModule);
|
|
62
|
+
run(host, moduleToUpdate);
|
|
63
|
+
return host;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function npmInstall(options) {
|
|
67
|
+
return (host, context) => {
|
|
68
|
+
if (options.skipInstall)
|
|
69
|
+
return;
|
|
70
|
+
const installTask = context.addTask(new tasks_1.NodePackageInstallTask());
|
|
71
|
+
if (needsLocalize(host)) {
|
|
72
|
+
context.addTask(new tasks_1.RunSchematicTask('@angular/localize', 'ng-add', { project: options.project }), [installTask]);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const progressDependencies = (json, importHammerjs) => {
|
|
77
|
+
const hammerRegEx = importHammerjs ? '|hammerjs' : '';
|
|
78
|
+
const validator = new RegExp(`^(@progress.*${hammerRegEx})$`);
|
|
79
|
+
return Object.entries(json.peerDependencies)
|
|
80
|
+
.filter(([k]) => validator.test(k))
|
|
81
|
+
.reduce((s, [k, v]) => (s[k] = v, s), {});
|
|
82
|
+
};
|
|
83
|
+
function getPackageVersion(tree, name) {
|
|
84
|
+
if (!tree.exists('package.json')) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const packageJson = JSON.parse((0, utils_1.fileContent)(tree, 'package.json'));
|
|
88
|
+
if (packageJson.dependencies && packageJson.dependencies[name]) {
|
|
89
|
+
return packageJson.dependencies[name];
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
function getAngularVersionString(tree) {
|
|
94
|
+
return getPackageVersion(tree, '@angular/core');
|
|
95
|
+
}
|
|
96
|
+
function getAngularMajorVersion(tree) {
|
|
97
|
+
const version = getAngularVersionString(tree);
|
|
98
|
+
if (!version) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const major = version.match(/(\d+)\./);
|
|
102
|
+
if (major !== null && major.length === 2) {
|
|
103
|
+
return parseInt(major[1], 10);
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
function needsLocalize(tree) {
|
|
108
|
+
const version = getAngularMajorVersion(tree);
|
|
109
|
+
return version >= 9 || version === null;
|
|
110
|
+
}
|
|
111
|
+
function registerInPackageJson(options) {
|
|
112
|
+
return (tree, context) => {
|
|
113
|
+
const fullPackageName = `kendo-angular-${options.package}`;
|
|
114
|
+
const content = (0, utils_1.fileContent)(tree, `node_modules/@progress/${fullPackageName}/package.json`);
|
|
115
|
+
const dependencies = {
|
|
116
|
+
...progressDependencies(JSON.parse(content), options.importHammerjs),
|
|
117
|
+
...options.peerDependencies
|
|
118
|
+
};
|
|
119
|
+
if (needsLocalize(tree)) {
|
|
120
|
+
dependencies['@angular/localize'] = getAngularVersionString(tree);
|
|
121
|
+
}
|
|
122
|
+
return (0, rules_1.addToPackageJson)({ dependencies })(tree, context);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function ngAdd(options) {
|
|
126
|
+
return (host, context) => {
|
|
127
|
+
const project = (0, utils_1.resolveProject)(host, options.project);
|
|
128
|
+
const targets = project.architect || project.targets;
|
|
129
|
+
const mainPath = targets.build.options.main;
|
|
130
|
+
options.module = (0, utils_1.getAppModulePath)(host, mainPath);
|
|
131
|
+
const toInstall = (0, schematics_1.chain)([
|
|
132
|
+
registerInPackageJson(options),
|
|
133
|
+
(0, theming_1.importTheme)(options),
|
|
134
|
+
npmInstall(options) //install as a last rule
|
|
135
|
+
]);
|
|
136
|
+
return (0, schematics_1.chain)([
|
|
137
|
+
importAllModules(options),
|
|
138
|
+
toInstall
|
|
139
|
+
])(host, context);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
exports.ngAdd = ngAdd;
|
|
143
|
+
//# sourceMappingURL=index.js.map
|