@heartlandone/vega-angular 1.3.0
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/.browserslistrc +16 -0
- package/.prettierrc.js +13 -0
- package/LICENSE +21 -0
- package/README.md +132 -0
- package/dist/LICENSE +21 -0
- package/dist/README.md +132 -0
- package/dist/esm2020/heartlandone-vega-angular.mjs +5 -0
- package/dist/esm2020/lib/components-module.mjs +24 -0
- package/dist/esm2020/lib/stencil-generated/angular-component-lib/utils.mjs +62 -0
- package/dist/esm2020/lib/stencil-generated/components.mjs +953 -0
- package/dist/esm2020/lib/stencil-generated/text-value-accessor.mjs +35 -0
- package/dist/esm2020/lib/stencil-generated/value-accessor.mjs +44 -0
- package/dist/esm2020/public-api.mjs +8 -0
- package/dist/fesm2015/heartlandone-vega-angular.mjs +1079 -0
- package/dist/fesm2015/heartlandone-vega-angular.mjs.map +1 -0
- package/dist/fesm2020/heartlandone-vega-angular.mjs +1079 -0
- package/dist/fesm2020/heartlandone-vega-angular.mjs.map +1 -0
- package/dist/heartlandone-vega-angular.d.ts +5 -0
- package/dist/lib/components-module.d.ts +10 -0
- package/dist/lib/stencil-generated/angular-component-lib/utils.d.ts +9 -0
- package/dist/lib/stencil-generated/components.d.ts +467 -0
- package/dist/lib/stencil-generated/text-value-accessor.d.ts +8 -0
- package/dist/lib/stencil-generated/value-accessor.d.ts +18 -0
- package/dist/package.json +40 -0
- package/dist/public-api.d.ts +4 -0
- package/karma.conf.js +44 -0
- package/ng-package.json +10 -0
- package/package.json +36 -0
- package/src/lib/components-module.ts +16 -0
- package/src/lib/stencil-generated/angular-component-lib/utils.ts +71 -0
- package/src/lib/stencil-generated/components.ts +1007 -0
- package/src/lib/stencil-generated/text-value-accessor.ts +24 -0
- package/src/lib/stencil-generated/value-accessor.ts +42 -0
- package/src/public-api.ts +7 -0
- package/src/scripts/stencil-post-build-script.js +59 -0
- package/src/test.ts +27 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Directive, ElementRef } from '@angular/core';
|
|
2
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
import { ValueAccessor } from './value-accessor';
|
|
5
|
+
|
|
6
|
+
@Directive({
|
|
7
|
+
/* tslint:disable-next-line:directive-selector */
|
|
8
|
+
selector: 'vega-input, vega-input-select',
|
|
9
|
+
host: {
|
|
10
|
+
'(vegaChange)': 'handleChangeEvent($event.target.value)'
|
|
11
|
+
},
|
|
12
|
+
providers: [
|
|
13
|
+
{
|
|
14
|
+
provide: NG_VALUE_ACCESSOR,
|
|
15
|
+
useExisting: TextValueAccessor,
|
|
16
|
+
multi: true
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
})
|
|
20
|
+
export class TextValueAccessor extends ValueAccessor {
|
|
21
|
+
constructor(el: ElementRef) {
|
|
22
|
+
super(el);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Directive, ElementRef, HostListener } from '@angular/core';
|
|
2
|
+
import { ControlValueAccessor } from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
@Directive({ selector: 'vega-value-accessor' })
|
|
5
|
+
export class ValueAccessor implements ControlValueAccessor {
|
|
6
|
+
private onChange: (value: any) => void = () => {
|
|
7
|
+
/**/
|
|
8
|
+
};
|
|
9
|
+
private onTouched: () => void = () => {
|
|
10
|
+
/**/
|
|
11
|
+
};
|
|
12
|
+
protected lastValue: any;
|
|
13
|
+
|
|
14
|
+
constructor(protected el: ElementRef) {}
|
|
15
|
+
|
|
16
|
+
writeValue(value: any) {
|
|
17
|
+
this.el.nativeElement.value = this.lastValue = value == null ? '' : value;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
handleChangeEvent(value: any) {
|
|
21
|
+
if (value !== this.lastValue) {
|
|
22
|
+
this.lastValue = value;
|
|
23
|
+
this.onChange(value);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@HostListener('focusout')
|
|
28
|
+
_handleBlurEvent() {
|
|
29
|
+
this.onTouched();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
registerOnChange(fn: (value: any) => void) {
|
|
33
|
+
this.onChange = fn;
|
|
34
|
+
}
|
|
35
|
+
registerOnTouched(fn: () => void) {
|
|
36
|
+
this.onTouched = fn;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setDisabledState(isDisabled: boolean) {
|
|
40
|
+
this.el.nativeElement.disabled = isDisabled;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
const { readFileSync, writeFileSync } = require('fs');
|
|
3
|
+
|
|
4
|
+
function updateStencilGeneratedComponents(updaters) {
|
|
5
|
+
// read file content
|
|
6
|
+
const STENCIL_GENERATED_COMPONENTS_PATH = 'src/lib/stencil-generated/components.ts';
|
|
7
|
+
let componentsContent = readFileSync(STENCIL_GENERATED_COMPONENTS_PATH, 'utf8');
|
|
8
|
+
|
|
9
|
+
updaters.forEach(updater => {
|
|
10
|
+
componentsContent = updater(componentsContent);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
writeFileSync(STENCIL_GENERATED_COMPONENTS_PATH, componentsContent);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function appendDefaultArrayExportInComponentsFile(componentsContent) {
|
|
17
|
+
// extract the name of export vega component classes
|
|
18
|
+
const exportedClass = Array.from(componentsContent.matchAll(/export class (Vega[a-zA-Z]+) {/g)).map(
|
|
19
|
+
matched => matched[1],
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// append default export statement to the original file
|
|
23
|
+
const exportDefaultStatement = `
|
|
24
|
+
export default [
|
|
25
|
+
${exportedClass.join(',\n ')},
|
|
26
|
+
];`;
|
|
27
|
+
return componentsContent + exportDefaultStatement;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function resolveEventPayloadImportPath(componentsContent) {
|
|
31
|
+
const EVENT_PAYLOAD_TYPE_TO_COMPONENT_TAG_MAP = new Map([
|
|
32
|
+
['VegaTableChangePropType', 'vega-table'],
|
|
33
|
+
['VegaTableRowClickPropType', 'vega-table'],
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
return componentsContent.replace(
|
|
37
|
+
/(import type { (.*) as .* } from )'@heartlandone\/vega'/g,
|
|
38
|
+
function (matched, group1, group2) {
|
|
39
|
+
const componentTag = EVENT_PAYLOAD_TYPE_TO_COMPONENT_TAG_MAP.get(group2);
|
|
40
|
+
return `${group1}'@heartlandone/vega/dist/types/components/${componentTag}/${componentTag}'`;
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function revertValueAccessorChangeByGit() {
|
|
46
|
+
// use git to reset the change in value-accessor made by stencil angular output,
|
|
47
|
+
// since it will make the directive annotation without any property which will causing compile error
|
|
48
|
+
execSync('git checkout -- src/lib/stencil-generated/value-accessor.ts');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function revertUtilsChange() {
|
|
52
|
+
execSync('git checkout -- src/lib/stencil-generated/angular-component-lib/utils.ts');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
updateStencilGeneratedComponents([appendDefaultArrayExportInComponentsFile, resolveEventPayloadImportPath]);
|
|
56
|
+
|
|
57
|
+
revertValueAccessorChangeByGit();
|
|
58
|
+
|
|
59
|
+
revertUtilsChange();
|
package/src/test.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
2
|
+
|
|
3
|
+
import 'zone.js';
|
|
4
|
+
import 'zone.js/testing';
|
|
5
|
+
import { getTestBed } from '@angular/core/testing';
|
|
6
|
+
import {
|
|
7
|
+
BrowserDynamicTestingModule,
|
|
8
|
+
platformBrowserDynamicTesting
|
|
9
|
+
} from '@angular/platform-browser-dynamic/testing';
|
|
10
|
+
|
|
11
|
+
declare const require: {
|
|
12
|
+
context(path: string, deep?: boolean, filter?: RegExp): {
|
|
13
|
+
<T>(id: string): T;
|
|
14
|
+
keys(): string[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// First, initialize the Angular testing environment.
|
|
19
|
+
getTestBed().initTestEnvironment(
|
|
20
|
+
BrowserDynamicTestingModule,
|
|
21
|
+
platformBrowserDynamicTesting(),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// Then we find all the tests.
|
|
25
|
+
const context = require.context('./', true, /\.spec\.ts$/);
|
|
26
|
+
// And load the modules.
|
|
27
|
+
context.keys().map(context);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
+
{
|
|
3
|
+
"extends": "../../tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "../../out-tsc/lib",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"inlineSources": true,
|
|
9
|
+
"types": []
|
|
10
|
+
},
|
|
11
|
+
"exclude": [
|
|
12
|
+
"src/test.ts",
|
|
13
|
+
"**/*.spec.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
+
{
|
|
3
|
+
"extends": "../../tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "../../out-tsc/spec",
|
|
6
|
+
"types": [
|
|
7
|
+
"jasmine"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src/test.ts"
|
|
12
|
+
],
|
|
13
|
+
"include": [
|
|
14
|
+
"**/*.spec.ts",
|
|
15
|
+
"**/*.d.ts"
|
|
16
|
+
]
|
|
17
|
+
}
|