@baloise/angular-output-target 1.0.25 → 1.1.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 +42 -0
- package/dist/generate-angular-directives-file.js +2 -2
- package/dist/generate-angular-module.d.ts +5 -0
- package/dist/generate-angular-module.js +56 -0
- package/dist/index.cjs.js +66 -8
- package/dist/index.js +66 -8
- package/dist/output-angular.js +9 -6
- package/dist/types.d.ts +12 -0
- package/dist/utils.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,48 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [1.1.2](https://github.com/baloise/stencil-ds-output-targets/compare/@baloise/angular-output-target@1.1.1...@baloise/angular-output-target@1.1.2) (2022-02-10)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* **angular:** remove all component module ([dcf567d](https://github.com/baloise/stencil-ds-output-targets/commit/dcf567d597313a5b5bf1ec003ef9f7f25dd4bcad))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
## [1.1.1](https://github.com/baloise/stencil-ds-output-targets/compare/@baloise/angular-output-target@1.1.0...@baloise/angular-output-target@1.1.1) (2022-01-31)
|
18
|
+
|
19
|
+
|
20
|
+
### Bug Fixes
|
21
|
+
|
22
|
+
* **angular:** add common module ([6387334](https://github.com/baloise/stencil-ds-output-targets/commit/63873341511fe0dfe9490fda06bb785df3fc1404))
|
23
|
+
* **angular:** add common module ([10798bb](https://github.com/baloise/stencil-ds-output-targets/commit/10798bb22e435a87cf12d0ccd6d868ff0314f685))
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
# [1.1.0](https://github.com/baloise/stencil-ds-output-targets/compare/@baloise/angular-output-target@1.0.26...@baloise/angular-output-target@1.1.0) (2022-01-31)
|
30
|
+
|
31
|
+
|
32
|
+
### Features
|
33
|
+
|
34
|
+
* **angular:** add modules for each component ([e6a5cd2](https://github.com/baloise/stencil-ds-output-targets/commit/e6a5cd209dd0d61a4bcbc8855fae965b0ff6f815))
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
## [1.0.26](https://github.com/baloise/stencil-ds-output-targets/compare/@baloise/angular-output-target@1.0.25...@baloise/angular-output-target@1.0.26) (2022-01-24)
|
41
|
+
|
42
|
+
**Note:** Version bump only for package @baloise/angular-output-target
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
6
48
|
## [1.0.25](https://github.com/baloise/stencil-ds-output-targets/compare/@baloise/angular-output-target@1.0.24...@baloise/angular-output-target@1.0.25) (2022-01-08)
|
7
49
|
|
8
50
|
|
@@ -6,8 +6,8 @@ export function generateAngularDirectivesFile(compilerCtx, components, outputTar
|
|
6
6
|
}
|
7
7
|
const proxyPath = relativeImport(outputTarget.directivesArrayFile, outputTarget.directivesProxyFile, '.ts');
|
8
8
|
const directives = components
|
9
|
-
.map(
|
10
|
-
.map(
|
9
|
+
.map(cmpMeta => dashToPascalCase(cmpMeta.tagName))
|
10
|
+
.map(className => `d.${className}`)
|
11
11
|
.join(',\n ');
|
12
12
|
const c = `
|
13
13
|
import * as d from '${proxyPath}';
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { dashToPascalCase } from './utils';
|
2
|
+
export const createComponentModule = (groups = {}) => (cmpMeta) => {
|
3
|
+
const isPrivate = Object.values(groups)
|
4
|
+
.flat()
|
5
|
+
.map(o => o.components)
|
6
|
+
.flat()
|
7
|
+
.some(tag => tag === cmpMeta.tagName);
|
8
|
+
if (isPrivate) {
|
9
|
+
return '';
|
10
|
+
}
|
11
|
+
const tagNameAsPascal = dashToPascalCase(cmpMeta.tagName);
|
12
|
+
let cmpImports = [];
|
13
|
+
let cmpDefines = [];
|
14
|
+
if (groups[cmpMeta.tagName] && groups[cmpMeta.tagName].components) {
|
15
|
+
const children = groups[cmpMeta.tagName].components;
|
16
|
+
if (children) {
|
17
|
+
cmpImports = children.map(tag => `${dashToPascalCase(tag)}`);
|
18
|
+
cmpDefines = children.map(tag => ` define${dashToPascalCase(tag)}();`);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
let providers = [];
|
22
|
+
let providerImports = [];
|
23
|
+
if (groups[cmpMeta.tagName] && groups[cmpMeta.tagName].providers) {
|
24
|
+
const children = groups[cmpMeta.tagName].providers;
|
25
|
+
if (children) {
|
26
|
+
providerImports = children.map(p => `import { ${p.name} } from '../${p.import.replace('.ts', '')}'`);
|
27
|
+
providers = children.map(p => p.name);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
let declarations = [];
|
31
|
+
let declarationImports = [];
|
32
|
+
if (groups[cmpMeta.tagName] && groups[cmpMeta.tagName].declarations) {
|
33
|
+
const children = groups[cmpMeta.tagName].declarations;
|
34
|
+
if (children) {
|
35
|
+
declarationImports = children.map(p => `import { ${p.name} } from '../${p.import.replace('.ts', '')}'`);
|
36
|
+
declarations = children.map(p => p.name);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
const finalText = `
|
40
|
+
${providerImports.join('\n ')}
|
41
|
+
${declarationImports.join('\n ')}
|
42
|
+
|
43
|
+
@NgModule({
|
44
|
+
declarations: [${[tagNameAsPascal, ...cmpImports, ...declarations].join(', ')}],
|
45
|
+
exports: [${[tagNameAsPascal, ...cmpImports, ...declarations].join(', ')}],
|
46
|
+
providers: [${providers.join(', ')}],
|
47
|
+
imports: [CommonModule],
|
48
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
49
|
+
})
|
50
|
+
export class ${tagNameAsPascal}Module {
|
51
|
+
constructor() {
|
52
|
+
${[` define${tagNameAsPascal}();`, ...cmpDefines].join('\n')}
|
53
|
+
}
|
54
|
+
}`;
|
55
|
+
return finalText;
|
56
|
+
};
|
package/dist/index.cjs.js
CHANGED
@@ -15,7 +15,7 @@ const readFile = util.promisify(fs__default['default'].readFile);
|
|
15
15
|
const toLowerCase = (str) => str.toLowerCase();
|
16
16
|
const dashToPascalCase = (str) => toLowerCase(str)
|
17
17
|
.split('-')
|
18
|
-
.map(
|
18
|
+
.map(segment => segment.charAt(0).toUpperCase() + segment.slice(1))
|
19
19
|
.join('');
|
20
20
|
function sortBy(array, prop) {
|
21
21
|
return array.slice().sort((a, b) => {
|
@@ -167,8 +167,8 @@ function generateAngularDirectivesFile(compilerCtx, components, outputTarget) {
|
|
167
167
|
}
|
168
168
|
const proxyPath = relativeImport(outputTarget.directivesArrayFile, outputTarget.directivesProxyFile, '.ts');
|
169
169
|
const directives = components
|
170
|
-
.map(
|
171
|
-
.map(
|
170
|
+
.map(cmpMeta => dashToPascalCase(cmpMeta.tagName))
|
171
|
+
.map(className => `d.${className}`)
|
172
172
|
.join(',\n ');
|
173
173
|
const c = `
|
174
174
|
import * as d from '${proxyPath}';
|
@@ -235,6 +235,62 @@ const VALUE_ACCESSOR_EVENT = `<VALUE_ACCESSOR_EVENT>`;
|
|
235
235
|
const VALUE_ACCESSOR_TARGETATTR = '<VALUE_ACCESSOR_TARGETATTR>';
|
236
236
|
const VALUE_ACCESSOR_EVENTTARGETS = ` '(<VALUE_ACCESSOR_EVENT>)': 'handleChangeEvent($event.detail)'`;
|
237
237
|
|
238
|
+
const createComponentModule = (groups = {}) => (cmpMeta) => {
|
239
|
+
const isPrivate = Object.values(groups)
|
240
|
+
.flat()
|
241
|
+
.map(o => o.components)
|
242
|
+
.flat()
|
243
|
+
.some(tag => tag === cmpMeta.tagName);
|
244
|
+
if (isPrivate) {
|
245
|
+
return '';
|
246
|
+
}
|
247
|
+
const tagNameAsPascal = dashToPascalCase(cmpMeta.tagName);
|
248
|
+
let cmpImports = [];
|
249
|
+
let cmpDefines = [];
|
250
|
+
if (groups[cmpMeta.tagName] && groups[cmpMeta.tagName].components) {
|
251
|
+
const children = groups[cmpMeta.tagName].components;
|
252
|
+
if (children) {
|
253
|
+
cmpImports = children.map(tag => `${dashToPascalCase(tag)}`);
|
254
|
+
cmpDefines = children.map(tag => ` define${dashToPascalCase(tag)}();`);
|
255
|
+
}
|
256
|
+
}
|
257
|
+
let providers = [];
|
258
|
+
let providerImports = [];
|
259
|
+
if (groups[cmpMeta.tagName] && groups[cmpMeta.tagName].providers) {
|
260
|
+
const children = groups[cmpMeta.tagName].providers;
|
261
|
+
if (children) {
|
262
|
+
providerImports = children.map(p => `import { ${p.name} } from '../${p.import.replace('.ts', '')}'`);
|
263
|
+
providers = children.map(p => p.name);
|
264
|
+
}
|
265
|
+
}
|
266
|
+
let declarations = [];
|
267
|
+
let declarationImports = [];
|
268
|
+
if (groups[cmpMeta.tagName] && groups[cmpMeta.tagName].declarations) {
|
269
|
+
const children = groups[cmpMeta.tagName].declarations;
|
270
|
+
if (children) {
|
271
|
+
declarationImports = children.map(p => `import { ${p.name} } from '../${p.import.replace('.ts', '')}'`);
|
272
|
+
declarations = children.map(p => p.name);
|
273
|
+
}
|
274
|
+
}
|
275
|
+
const finalText = `
|
276
|
+
${providerImports.join('\n ')}
|
277
|
+
${declarationImports.join('\n ')}
|
278
|
+
|
279
|
+
@NgModule({
|
280
|
+
declarations: [${[tagNameAsPascal, ...cmpImports, ...declarations].join(', ')}],
|
281
|
+
exports: [${[tagNameAsPascal, ...cmpImports, ...declarations].join(', ')}],
|
282
|
+
providers: [${providers.join(', ')}],
|
283
|
+
imports: [CommonModule],
|
284
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
285
|
+
})
|
286
|
+
export class ${tagNameAsPascal}Module {
|
287
|
+
constructor() {
|
288
|
+
${[` define${tagNameAsPascal}();`, ...cmpDefines].join('\n')}
|
289
|
+
}
|
290
|
+
}`;
|
291
|
+
return finalText;
|
292
|
+
};
|
293
|
+
|
238
294
|
async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components, config) {
|
239
295
|
const filteredComponents = getFilteredComponents(outputTarget.excludeComponents, components);
|
240
296
|
const rootDir = config.rootDir;
|
@@ -248,7 +304,7 @@ async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components
|
|
248
304
|
]);
|
249
305
|
}
|
250
306
|
function getFilteredComponents(excludeComponents = [], cmps) {
|
251
|
-
return sortBy(cmps,
|
307
|
+
return sortBy(cmps, cmp => cmp.tagName).filter(c => !excludeComponents.includes(c.tagName) && !c.internal);
|
252
308
|
}
|
253
309
|
async function copyResources(config, outputTarget) {
|
254
310
|
if (!config.sys || !config.sys.copy || !config.sys.glob) {
|
@@ -271,17 +327,19 @@ function generateProxies(components, pkgData, outputTarget, rootDir) {
|
|
271
327
|
const componentsTypeFile = relativeImport(outputTarget.directivesProxyFile, dtsFilePath, '.d.ts');
|
272
328
|
const imports = `/* tslint:disable */
|
273
329
|
/* auto-generated angular directive proxies */
|
274
|
-
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, NgZone, EventEmitter } from '@angular/core';
|
330
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, NgZone, EventEmitter, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
331
|
+
import { CommonModule } from '@angular/common';
|
275
332
|
import { ProxyCmp, proxyOutputs } from './angular-component-lib/utils';\n`;
|
333
|
+
const componentImports = components.map(c => `import { defineCustomElement as define${dashToPascalCase(c.tagName)} } from '${normalizePath(outputTarget.componentCorePackage || '')}/dist/components/${c.tagName}';`);
|
276
334
|
const typeImports = !outputTarget.componentCorePackage
|
277
335
|
? `import { ${IMPORT_TYPES} } from '${normalizePath(componentsTypeFile)}';`
|
278
336
|
: `import { ${IMPORT_TYPES} } from '${normalizePath(outputTarget.componentCorePackage)}';`;
|
279
337
|
const final = [
|
280
338
|
imports,
|
281
339
|
typeImports,
|
282
|
-
|
283
|
-
|
284
|
-
|
340
|
+
componentImports.join('\n'),
|
341
|
+
components.map(createComponentDefinition(outputTarget.componentCorePackage)).join('\n'),
|
342
|
+
components.map(createComponentModule(outputTarget.componentGroups)).join('\n'),
|
285
343
|
];
|
286
344
|
return final.join('\n') + '\n';
|
287
345
|
}
|
package/dist/index.js
CHANGED
@@ -6,7 +6,7 @@ const readFile = promisify(fs.readFile);
|
|
6
6
|
const toLowerCase = (str) => str.toLowerCase();
|
7
7
|
const dashToPascalCase = (str) => toLowerCase(str)
|
8
8
|
.split('-')
|
9
|
-
.map(
|
9
|
+
.map(segment => segment.charAt(0).toUpperCase() + segment.slice(1))
|
10
10
|
.join('');
|
11
11
|
function sortBy(array, prop) {
|
12
12
|
return array.slice().sort((a, b) => {
|
@@ -158,8 +158,8 @@ function generateAngularDirectivesFile(compilerCtx, components, outputTarget) {
|
|
158
158
|
}
|
159
159
|
const proxyPath = relativeImport(outputTarget.directivesArrayFile, outputTarget.directivesProxyFile, '.ts');
|
160
160
|
const directives = components
|
161
|
-
.map(
|
162
|
-
.map(
|
161
|
+
.map(cmpMeta => dashToPascalCase(cmpMeta.tagName))
|
162
|
+
.map(className => `d.${className}`)
|
163
163
|
.join(',\n ');
|
164
164
|
const c = `
|
165
165
|
import * as d from '${proxyPath}';
|
@@ -226,6 +226,62 @@ const VALUE_ACCESSOR_EVENT = `<VALUE_ACCESSOR_EVENT>`;
|
|
226
226
|
const VALUE_ACCESSOR_TARGETATTR = '<VALUE_ACCESSOR_TARGETATTR>';
|
227
227
|
const VALUE_ACCESSOR_EVENTTARGETS = ` '(<VALUE_ACCESSOR_EVENT>)': 'handleChangeEvent($event.detail)'`;
|
228
228
|
|
229
|
+
const createComponentModule = (groups = {}) => (cmpMeta) => {
|
230
|
+
const isPrivate = Object.values(groups)
|
231
|
+
.flat()
|
232
|
+
.map(o => o.components)
|
233
|
+
.flat()
|
234
|
+
.some(tag => tag === cmpMeta.tagName);
|
235
|
+
if (isPrivate) {
|
236
|
+
return '';
|
237
|
+
}
|
238
|
+
const tagNameAsPascal = dashToPascalCase(cmpMeta.tagName);
|
239
|
+
let cmpImports = [];
|
240
|
+
let cmpDefines = [];
|
241
|
+
if (groups[cmpMeta.tagName] && groups[cmpMeta.tagName].components) {
|
242
|
+
const children = groups[cmpMeta.tagName].components;
|
243
|
+
if (children) {
|
244
|
+
cmpImports = children.map(tag => `${dashToPascalCase(tag)}`);
|
245
|
+
cmpDefines = children.map(tag => ` define${dashToPascalCase(tag)}();`);
|
246
|
+
}
|
247
|
+
}
|
248
|
+
let providers = [];
|
249
|
+
let providerImports = [];
|
250
|
+
if (groups[cmpMeta.tagName] && groups[cmpMeta.tagName].providers) {
|
251
|
+
const children = groups[cmpMeta.tagName].providers;
|
252
|
+
if (children) {
|
253
|
+
providerImports = children.map(p => `import { ${p.name} } from '../${p.import.replace('.ts', '')}'`);
|
254
|
+
providers = children.map(p => p.name);
|
255
|
+
}
|
256
|
+
}
|
257
|
+
let declarations = [];
|
258
|
+
let declarationImports = [];
|
259
|
+
if (groups[cmpMeta.tagName] && groups[cmpMeta.tagName].declarations) {
|
260
|
+
const children = groups[cmpMeta.tagName].declarations;
|
261
|
+
if (children) {
|
262
|
+
declarationImports = children.map(p => `import { ${p.name} } from '../${p.import.replace('.ts', '')}'`);
|
263
|
+
declarations = children.map(p => p.name);
|
264
|
+
}
|
265
|
+
}
|
266
|
+
const finalText = `
|
267
|
+
${providerImports.join('\n ')}
|
268
|
+
${declarationImports.join('\n ')}
|
269
|
+
|
270
|
+
@NgModule({
|
271
|
+
declarations: [${[tagNameAsPascal, ...cmpImports, ...declarations].join(', ')}],
|
272
|
+
exports: [${[tagNameAsPascal, ...cmpImports, ...declarations].join(', ')}],
|
273
|
+
providers: [${providers.join(', ')}],
|
274
|
+
imports: [CommonModule],
|
275
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
276
|
+
})
|
277
|
+
export class ${tagNameAsPascal}Module {
|
278
|
+
constructor() {
|
279
|
+
${[` define${tagNameAsPascal}();`, ...cmpDefines].join('\n')}
|
280
|
+
}
|
281
|
+
}`;
|
282
|
+
return finalText;
|
283
|
+
};
|
284
|
+
|
229
285
|
async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components, config) {
|
230
286
|
const filteredComponents = getFilteredComponents(outputTarget.excludeComponents, components);
|
231
287
|
const rootDir = config.rootDir;
|
@@ -239,7 +295,7 @@ async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components
|
|
239
295
|
]);
|
240
296
|
}
|
241
297
|
function getFilteredComponents(excludeComponents = [], cmps) {
|
242
|
-
return sortBy(cmps,
|
298
|
+
return sortBy(cmps, cmp => cmp.tagName).filter(c => !excludeComponents.includes(c.tagName) && !c.internal);
|
243
299
|
}
|
244
300
|
async function copyResources(config, outputTarget) {
|
245
301
|
if (!config.sys || !config.sys.copy || !config.sys.glob) {
|
@@ -262,17 +318,19 @@ function generateProxies(components, pkgData, outputTarget, rootDir) {
|
|
262
318
|
const componentsTypeFile = relativeImport(outputTarget.directivesProxyFile, dtsFilePath, '.d.ts');
|
263
319
|
const imports = `/* tslint:disable */
|
264
320
|
/* auto-generated angular directive proxies */
|
265
|
-
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, NgZone, EventEmitter } from '@angular/core';
|
321
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, NgZone, EventEmitter, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
322
|
+
import { CommonModule } from '@angular/common';
|
266
323
|
import { ProxyCmp, proxyOutputs } from './angular-component-lib/utils';\n`;
|
324
|
+
const componentImports = components.map(c => `import { defineCustomElement as define${dashToPascalCase(c.tagName)} } from '${normalizePath(outputTarget.componentCorePackage || '')}/dist/components/${c.tagName}';`);
|
267
325
|
const typeImports = !outputTarget.componentCorePackage
|
268
326
|
? `import { ${IMPORT_TYPES} } from '${normalizePath(componentsTypeFile)}';`
|
269
327
|
: `import { ${IMPORT_TYPES} } from '${normalizePath(outputTarget.componentCorePackage)}';`;
|
270
328
|
const final = [
|
271
329
|
imports,
|
272
330
|
typeImports,
|
273
|
-
|
274
|
-
|
275
|
-
|
331
|
+
componentImports.join('\n'),
|
332
|
+
components.map(createComponentDefinition(outputTarget.componentCorePackage)).join('\n'),
|
333
|
+
components.map(createComponentModule(outputTarget.componentGroups)).join('\n'),
|
276
334
|
];
|
277
335
|
return final.join('\n') + '\n';
|
278
336
|
}
|
package/dist/output-angular.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import path from 'path';
|
2
|
-
import { relativeImport, normalizePath, sortBy, readPackageJson } from './utils';
|
2
|
+
import { relativeImport, normalizePath, sortBy, readPackageJson, dashToPascalCase } from './utils';
|
3
3
|
import { createComponentDefinition } from './generate-angular-component';
|
4
4
|
import { generateAngularDirectivesFile } from './generate-angular-directives-file';
|
5
5
|
import generateValueAccessors from './generate-value-accessors';
|
6
|
+
import { createComponentModule } from './generate-angular-module';
|
6
7
|
export async function angularDirectiveProxyOutput(compilerCtx, outputTarget, components, config) {
|
7
8
|
const filteredComponents = getFilteredComponents(outputTarget.excludeComponents, components);
|
8
9
|
const rootDir = config.rootDir;
|
@@ -16,7 +17,7 @@ export async function angularDirectiveProxyOutput(compilerCtx, outputTarget, com
|
|
16
17
|
]);
|
17
18
|
}
|
18
19
|
function getFilteredComponents(excludeComponents = [], cmps) {
|
19
|
-
return sortBy(cmps,
|
20
|
+
return sortBy(cmps, cmp => cmp.tagName).filter(c => !excludeComponents.includes(c.tagName) && !c.internal);
|
20
21
|
}
|
21
22
|
async function copyResources(config, outputTarget) {
|
22
23
|
if (!config.sys || !config.sys.copy || !config.sys.glob) {
|
@@ -39,17 +40,19 @@ export function generateProxies(components, pkgData, outputTarget, rootDir) {
|
|
39
40
|
const componentsTypeFile = relativeImport(outputTarget.directivesProxyFile, dtsFilePath, '.d.ts');
|
40
41
|
const imports = `/* tslint:disable */
|
41
42
|
/* auto-generated angular directive proxies */
|
42
|
-
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, NgZone, EventEmitter } from '@angular/core';
|
43
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, NgZone, EventEmitter, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
44
|
+
import { CommonModule } from '@angular/common';
|
43
45
|
import { ProxyCmp, proxyOutputs } from './angular-component-lib/utils';\n`;
|
46
|
+
const componentImports = components.map(c => `import { defineCustomElement as define${dashToPascalCase(c.tagName)} } from '${normalizePath(outputTarget.componentCorePackage || '')}/dist/components/${c.tagName}';`);
|
44
47
|
const typeImports = !outputTarget.componentCorePackage
|
45
48
|
? `import { ${IMPORT_TYPES} } from '${normalizePath(componentsTypeFile)}';`
|
46
49
|
: `import { ${IMPORT_TYPES} } from '${normalizePath(outputTarget.componentCorePackage)}';`;
|
47
50
|
const final = [
|
48
51
|
imports,
|
49
52
|
typeImports,
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
+
componentImports.join('\n'),
|
54
|
+
components.map(createComponentDefinition(outputTarget.componentCorePackage, distTypesDir, rootDir)).join('\n'),
|
55
|
+
components.map(createComponentModule(outputTarget.componentGroups)).join('\n'),
|
53
56
|
];
|
54
57
|
return final.join('\n') + '\n';
|
55
58
|
}
|
package/dist/types.d.ts
CHANGED
@@ -5,6 +5,18 @@ export interface OutputTargetAngular {
|
|
5
5
|
directivesUtilsFile?: string;
|
6
6
|
valueAccessorConfigs?: ValueAccessorConfig[];
|
7
7
|
excludeComponents?: string[];
|
8
|
+
componentGroups?: {
|
9
|
+
[key: string]: ComponentGroup;
|
10
|
+
};
|
11
|
+
}
|
12
|
+
export interface ComponentGroup {
|
13
|
+
components?: string[];
|
14
|
+
providers?: ComponentProvider[];
|
15
|
+
declarations?: ComponentProvider[];
|
16
|
+
}
|
17
|
+
export interface ComponentProvider {
|
18
|
+
import: string;
|
19
|
+
name: string;
|
8
20
|
}
|
9
21
|
export declare type ValueAccessorTypes = 'text' | 'radio' | 'select' | 'number' | 'boolean';
|
10
22
|
export interface ValueAccessorConfig {
|
package/dist/utils.js
CHANGED
@@ -5,7 +5,7 @@ const readFile = promisify(fs.readFile);
|
|
5
5
|
export const toLowerCase = (str) => str.toLowerCase();
|
6
6
|
export const dashToPascalCase = (str) => toLowerCase(str)
|
7
7
|
.split('-')
|
8
|
-
.map(
|
8
|
+
.map(segment => segment.charAt(0).toUpperCase() + segment.slice(1))
|
9
9
|
.join('');
|
10
10
|
export function sortBy(array, prop) {
|
11
11
|
return array.slice().sort((a, b) => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@baloise/angular-output-target",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.1.2",
|
4
4
|
"description": "Angular output target for @stencil/core components.",
|
5
5
|
"main": "dist/index.cjs.js",
|
6
6
|
"module": "dist/index.js",
|
@@ -61,5 +61,5 @@
|
|
61
61
|
],
|
62
62
|
"testURL": "http://localhost"
|
63
63
|
},
|
64
|
-
"gitHead": "
|
64
|
+
"gitHead": "63e87696a264d54d246ac3dcf6cd0fea41f6fb59"
|
65
65
|
}
|