@scania/tegel-angular-17 1.27.1 → 1.28.1
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/ng-package.json +7 -0
- package/package.json +3 -16
- package/src/lib/components.module.ts +35 -0
- package/{lib/directives/tds-dropdown-value-accessor.d.ts → src/lib/directives/tds-dropdown-value-accessor.ts} +18 -5
- package/src/lib/directives/tds-radio-value-accessor.ts +29 -0
- package/src/lib/stencil-generated/angular-component-lib/utils.ts +65 -0
- package/src/lib/stencil-generated/boolean-value-accessor.ts +28 -0
- package/src/lib/stencil-generated/components.ts +2063 -0
- package/src/lib/stencil-generated/index.ts +87 -0
- package/src/lib/stencil-generated/number-value-accessor.ts +29 -0
- package/src/lib/stencil-generated/text-value-accessor.ts +24 -0
- package/src/lib/stencil-generated/value-accessor.ts +39 -0
- package/{public-api.d.ts → src/public-api.ts} +4 -0
- package/tsconfig.lib.json +14 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
- package/esm2022/lib/components.module.mjs +0 -58
- package/esm2022/lib/directives/tds-dropdown-value-accessor.mjs +0 -36
- package/esm2022/lib/directives/tds-radio-value-accessor.mjs +0 -41
- package/esm2022/lib/stencil-generated/angular-component-lib/utils.mjs +0 -59
- package/esm2022/lib/stencil-generated/boolean-value-accessor.mjs +0 -39
- package/esm2022/lib/stencil-generated/components.mjs +0 -2070
- package/esm2022/lib/stencil-generated/index.mjs +0 -86
- package/esm2022/lib/stencil-generated/number-value-accessor.mjs +0 -40
- package/esm2022/lib/stencil-generated/text-value-accessor.mjs +0 -35
- package/esm2022/lib/stencil-generated/value-accessor.mjs +0 -40
- package/esm2022/public-api.mjs +0 -12
- package/esm2022/scania-tegel-angular-17.mjs +0 -5
- package/fesm2022/scania-tegel-angular-17.mjs +0 -2399
- package/fesm2022/scania-tegel-angular-17.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/components.module.d.ts +0 -12
- package/lib/directives/tds-radio-value-accessor.d.ts +0 -13
- package/lib/stencil-generated/angular-component-lib/utils.d.ts +0 -9
- package/lib/stencil-generated/boolean-value-accessor.d.ts +0 -9
- package/lib/stencil-generated/components.d.ts +0 -1002
- package/lib/stencil-generated/index.d.ts +0 -2
- package/lib/stencil-generated/number-value-accessor.d.ts +0 -9
- package/lib/stencil-generated/text-value-accessor.d.ts +0 -8
- package/lib/stencil-generated/value-accessor.d.ts +0 -18
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scania/tegel-angular-17",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.1",
|
|
4
4
|
"description": "Angular wrappers for Tegel package using Angular 17 and above",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@angular/common": ">=17.0.0",
|
|
@@ -10,18 +10,5 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"tslib": "^2.3.0"
|
|
12
12
|
},
|
|
13
|
-
"sideEffects": false
|
|
14
|
-
|
|
15
|
-
"typings": "index.d.ts",
|
|
16
|
-
"exports": {
|
|
17
|
-
"./package.json": {
|
|
18
|
-
"default": "./package.json"
|
|
19
|
-
},
|
|
20
|
-
".": {
|
|
21
|
-
"types": "./index.d.ts",
|
|
22
|
-
"esm2022": "./esm2022/scania-tegel-angular-17.mjs",
|
|
23
|
-
"esm": "./esm2022/scania-tegel-angular-17.mjs",
|
|
24
|
-
"default": "./fesm2022/scania-tegel-angular-17.mjs"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
13
|
+
"sideEffects": false
|
|
14
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { APP_INITIALIZER, NgModule } from '@angular/core';
|
|
2
|
+
import { defineCustomElements } from '@scania/tegel/loader';
|
|
3
|
+
import { DIRECTIVES } from './stencil-generated';
|
|
4
|
+
import { TextValueAccessor } from './stencil-generated/text-value-accessor';
|
|
5
|
+
import { BooleanValueAccessor } from './stencil-generated/boolean-value-accessor';
|
|
6
|
+
import { NumericValueAccessor } from './stencil-generated/number-value-accessor';
|
|
7
|
+
import { TdsRadioValueAccessor } from './directives/tds-radio-value-accessor';
|
|
8
|
+
import { TdsDropdownValueAccessor } from './directives/tds-dropdown-value-accessor';
|
|
9
|
+
|
|
10
|
+
@NgModule({
|
|
11
|
+
declarations: [
|
|
12
|
+
...DIRECTIVES,
|
|
13
|
+
BooleanValueAccessor,
|
|
14
|
+
NumericValueAccessor,
|
|
15
|
+
TextValueAccessor,
|
|
16
|
+
TdsRadioValueAccessor,
|
|
17
|
+
TdsDropdownValueAccessor,
|
|
18
|
+
],
|
|
19
|
+
exports: [
|
|
20
|
+
...DIRECTIVES,
|
|
21
|
+
BooleanValueAccessor,
|
|
22
|
+
NumericValueAccessor,
|
|
23
|
+
TextValueAccessor,
|
|
24
|
+
TdsRadioValueAccessor,
|
|
25
|
+
TdsDropdownValueAccessor,
|
|
26
|
+
],
|
|
27
|
+
providers: [
|
|
28
|
+
{
|
|
29
|
+
provide: APP_INITIALIZER,
|
|
30
|
+
useFactory: () => defineCustomElements,
|
|
31
|
+
multi: true,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
})
|
|
35
|
+
export class TegelModule {}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
+
import { Directive } from '@angular/core';
|
|
2
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
|
+
|
|
1
4
|
import { ValueAccessor } from '../stencil-generated/value-accessor';
|
|
2
|
-
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* A custom value accessor for the tds-dropdown. It extends the default ValueAccessor that is auto-generated by Stencil
|
|
5
8
|
* The tds-dropdown requires slightly different event handling since it doesn't act like any of the native inputs.
|
|
6
9
|
* The main difference between this value accessor and the other value accessors that are auto-generated by Stencil, is that this one handles `$event.detail.value` instead of `$event.target.value`.
|
|
7
10
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
@Directive({
|
|
12
|
+
selector: 'tds-dropdown',
|
|
13
|
+
host: {
|
|
14
|
+
'(tdsChange)': 'handleChangeEvent($event.detail.value)',
|
|
15
|
+
},
|
|
16
|
+
providers: [
|
|
17
|
+
{
|
|
18
|
+
provide: NG_VALUE_ACCESSOR,
|
|
19
|
+
useExisting: TdsDropdownValueAccessor,
|
|
20
|
+
multi: true,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
})
|
|
24
|
+
export class TdsDropdownValueAccessor extends ValueAccessor {}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Directive } from '@angular/core';
|
|
2
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
import { ValueAccessor } from '../stencil-generated/value-accessor';
|
|
5
|
+
/**
|
|
6
|
+
* A custom value accessor for the tds-radio-button and tds-chip of type radio. It extends the default ValueAccessor that is auto-generated by Stencil
|
|
7
|
+
* Stencil offers an autogenerated radio value accessor but does not currently work as expected.
|
|
8
|
+
* An issue was submitted to their repository: https://github.com/ionic-team/stencil-ds-output-targets/issues/434
|
|
9
|
+
* If the issue is ever fixed this value accessor can be replaced with the one auto-generated by Stencil.
|
|
10
|
+
*/
|
|
11
|
+
@Directive({
|
|
12
|
+
/* tslint:disable-next-line:directive-selector */
|
|
13
|
+
selector: 'tds-radio-button, tds-chip[type="radio"]',
|
|
14
|
+
host: {
|
|
15
|
+
'(tdsChange)': 'handleChangeEvent($event.target.value)',
|
|
16
|
+
},
|
|
17
|
+
providers: [
|
|
18
|
+
{
|
|
19
|
+
provide: NG_VALUE_ACCESSOR,
|
|
20
|
+
useExisting: TdsRadioValueAccessor,
|
|
21
|
+
multi: true,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
})
|
|
25
|
+
export class TdsRadioValueAccessor extends ValueAccessor {
|
|
26
|
+
writeValue(value: any) {
|
|
27
|
+
this.el.nativeElement.checked = value === this.el.nativeElement.value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
import { fromEvent } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
export const proxyInputs = (Cmp: any, inputs: string[]) => {
|
|
6
|
+
const Prototype = Cmp.prototype;
|
|
7
|
+
inputs.forEach((item) => {
|
|
8
|
+
Object.defineProperty(Prototype, item, {
|
|
9
|
+
get() {
|
|
10
|
+
return this.el[item];
|
|
11
|
+
},
|
|
12
|
+
set(val: any) {
|
|
13
|
+
this.z.runOutsideAngular(() => (this.el[item] = val));
|
|
14
|
+
},
|
|
15
|
+
/**
|
|
16
|
+
* In the event that proxyInputs is called
|
|
17
|
+
* multiple times re-defining these inputs
|
|
18
|
+
* will cause an error to be thrown. As a result
|
|
19
|
+
* we set configurable: true to indicate these
|
|
20
|
+
* properties can be changed.
|
|
21
|
+
*/
|
|
22
|
+
configurable: true,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const proxyMethods = (Cmp: any, methods: string[]) => {
|
|
28
|
+
const Prototype = Cmp.prototype;
|
|
29
|
+
methods.forEach((methodName) => {
|
|
30
|
+
Prototype[methodName] = function () {
|
|
31
|
+
const args = arguments;
|
|
32
|
+
return this.z.runOutsideAngular(() => this.el[methodName].apply(this.el, args));
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const proxyOutputs = (instance: any, el: any, events: string[]) => {
|
|
38
|
+
events.forEach((eventName) => (instance[eventName] = fromEvent(el, eventName)));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const defineCustomElement = (tagName: string, customElement: any) => {
|
|
42
|
+
if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
|
|
43
|
+
customElements.define(tagName, customElement);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// tslint:disable-next-line: only-arrow-functions
|
|
48
|
+
export function ProxyCmp(opts: { defineCustomElementFn?: () => void; inputs?: any; methods?: any }) {
|
|
49
|
+
const decorator = function (cls: any) {
|
|
50
|
+
const { defineCustomElementFn, inputs, methods } = opts;
|
|
51
|
+
|
|
52
|
+
if (defineCustomElementFn !== undefined) {
|
|
53
|
+
defineCustomElementFn();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (inputs) {
|
|
57
|
+
proxyInputs(cls, inputs);
|
|
58
|
+
}
|
|
59
|
+
if (methods) {
|
|
60
|
+
proxyMethods(cls, methods);
|
|
61
|
+
}
|
|
62
|
+
return cls;
|
|
63
|
+
};
|
|
64
|
+
return decorator;
|
|
65
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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: 'tds-checkbox, tds-chip[type="checkbox"], tds-toggle',
|
|
9
|
+
host: {
|
|
10
|
+
'(tdsChange)': 'handleChangeEvent($event.target.checked)',
|
|
11
|
+
'(tdsToggle)': 'handleChangeEvent($event.target.checked)'
|
|
12
|
+
},
|
|
13
|
+
providers: [
|
|
14
|
+
{
|
|
15
|
+
provide: NG_VALUE_ACCESSOR,
|
|
16
|
+
useExisting: BooleanValueAccessor,
|
|
17
|
+
multi: true
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
})
|
|
21
|
+
export class BooleanValueAccessor extends ValueAccessor {
|
|
22
|
+
constructor(el: ElementRef) {
|
|
23
|
+
super(el);
|
|
24
|
+
}
|
|
25
|
+
writeValue(value: any) {
|
|
26
|
+
this.el.nativeElement.checked = this.lastValue = value == null ? false : value;
|
|
27
|
+
}
|
|
28
|
+
}
|