@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.
Files changed (40) hide show
  1. package/ng-package.json +7 -0
  2. package/package.json +3 -16
  3. package/src/lib/components.module.ts +35 -0
  4. package/{lib/directives/tds-dropdown-value-accessor.d.ts → src/lib/directives/tds-dropdown-value-accessor.ts} +18 -5
  5. package/src/lib/directives/tds-radio-value-accessor.ts +29 -0
  6. package/src/lib/stencil-generated/angular-component-lib/utils.ts +65 -0
  7. package/src/lib/stencil-generated/boolean-value-accessor.ts +28 -0
  8. package/src/lib/stencil-generated/components.ts +2063 -0
  9. package/src/lib/stencil-generated/index.ts +87 -0
  10. package/src/lib/stencil-generated/number-value-accessor.ts +29 -0
  11. package/src/lib/stencil-generated/text-value-accessor.ts +24 -0
  12. package/src/lib/stencil-generated/value-accessor.ts +39 -0
  13. package/{public-api.d.ts → src/public-api.ts} +4 -0
  14. package/tsconfig.lib.json +14 -0
  15. package/tsconfig.lib.prod.json +10 -0
  16. package/tsconfig.spec.json +14 -0
  17. package/esm2022/lib/components.module.mjs +0 -58
  18. package/esm2022/lib/directives/tds-dropdown-value-accessor.mjs +0 -36
  19. package/esm2022/lib/directives/tds-radio-value-accessor.mjs +0 -41
  20. package/esm2022/lib/stencil-generated/angular-component-lib/utils.mjs +0 -59
  21. package/esm2022/lib/stencil-generated/boolean-value-accessor.mjs +0 -39
  22. package/esm2022/lib/stencil-generated/components.mjs +0 -2070
  23. package/esm2022/lib/stencil-generated/index.mjs +0 -86
  24. package/esm2022/lib/stencil-generated/number-value-accessor.mjs +0 -40
  25. package/esm2022/lib/stencil-generated/text-value-accessor.mjs +0 -35
  26. package/esm2022/lib/stencil-generated/value-accessor.mjs +0 -40
  27. package/esm2022/public-api.mjs +0 -12
  28. package/esm2022/scania-tegel-angular-17.mjs +0 -5
  29. package/fesm2022/scania-tegel-angular-17.mjs +0 -2399
  30. package/fesm2022/scania-tegel-angular-17.mjs.map +0 -1
  31. package/index.d.ts +0 -5
  32. package/lib/components.module.d.ts +0 -12
  33. package/lib/directives/tds-radio-value-accessor.d.ts +0 -13
  34. package/lib/stencil-generated/angular-component-lib/utils.d.ts +0 -9
  35. package/lib/stencil-generated/boolean-value-accessor.d.ts +0 -9
  36. package/lib/stencil-generated/components.d.ts +0 -1002
  37. package/lib/stencil-generated/index.d.ts +0 -2
  38. package/lib/stencil-generated/number-value-accessor.d.ts +0 -9
  39. package/lib/stencil-generated/text-value-accessor.d.ts +0 -8
  40. package/lib/stencil-generated/value-accessor.d.ts +0 -18
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/components",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scania/tegel-angular-17",
3
- "version": "1.27.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
- "module": "fesm2022/scania-tegel-angular-17.mjs",
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
- import * as i0 from "@angular/core";
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
- export declare class TdsDropdownValueAccessor extends ValueAccessor {
9
- static ɵfac: i0.ɵɵFactoryDeclaration<TdsDropdownValueAccessor, never>;
10
- static ɵdir: i0.ɵɵDirectiveDeclaration<TdsDropdownValueAccessor, "tds-dropdown", never, {}, {}, never, never, false, never>;
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
+ }