labx-components 1.0.0 → 1.1.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.
Files changed (64) hide show
  1. package/angular-lib/ng-package.json +7 -0
  2. package/angular-lib/package.json +8 -0
  3. package/angular-lib/src/lib/angular-component-lib/utils.ts +65 -0
  4. package/angular-lib/src/lib/components.ts +94 -0
  5. package/{dist-angular/index.js → angular-lib/src/lib/index.ts} +5 -3
  6. package/angular-lib/src/lib/text-value-accessor.ts +24 -0
  7. package/angular-lib/src/lib/value-accessor.ts +39 -0
  8. package/angular-lib/src/public-api.ts +2 -0
  9. package/angular-lib/tsconfig.lib.json +24 -0
  10. package/dist/labx-components/index-DYSVGjqR.js +4585 -0
  11. package/dist/labx-components/index-DYSVGjqR.js.map +1 -0
  12. package/dist/labx-components/index.esm.js +18 -1
  13. package/dist/labx-components/index.esm.js.map +1 -0
  14. package/dist/labx-components/labx-button.entry.js +34 -0
  15. package/dist/labx-components/labx-button.entry.js.map +1 -0
  16. package/dist/labx-components/labx-components.css +67 -1
  17. package/dist/labx-components/labx-components.esm.js +50 -1
  18. package/dist/labx-components/labx-components.esm.js.map +1 -0
  19. package/dist/labx-components/labx-icon.entry.js +24 -0
  20. package/dist/labx-components/labx-icon.entry.js.map +1 -0
  21. package/dist/{esm/labx-button_3.entry.js → labx-components/labx-input.entry.js} +6 -49
  22. package/dist/labx-components/labx-input.entry.js.map +1 -0
  23. package/dist-angular/fesm2022/labx-components-angular.mjs +170 -0
  24. package/dist-angular/fesm2022/labx-components-angular.mjs.map +1 -0
  25. package/dist-angular/types/labx-components-angular.d.ts +46 -0
  26. package/dist-angular/types/labx-components-angular.d.ts.map +1 -0
  27. package/package.json +11 -7
  28. package/dist/cjs/index-eATbt1kz.js +0 -1519
  29. package/dist/cjs/index.cjs.js +0 -7
  30. package/dist/cjs/labx-button_3.cjs.entry.js +0 -104
  31. package/dist/cjs/labx-components.cjs.js +0 -24
  32. package/dist/cjs/loader.cjs.js +0 -12
  33. package/dist/collection/collection-manifest.json +0 -15
  34. package/dist/collection/components/labx-button/labx-button.css +0 -74
  35. package/dist/collection/components/labx-button/labx-button.js +0 -135
  36. package/dist/collection/components/labx-icon/labx-icon.css +0 -26
  37. package/dist/collection/components/labx-icon/labx-icon.js +0 -87
  38. package/dist/collection/components/labx-input/labx-input.css +0 -117
  39. package/dist/collection/components/labx-input/labx-input.js +0 -183
  40. package/dist/collection/index.js +0 -10
  41. package/dist/collection/utils/utils.js +0 -3
  42. package/dist/collection/utils/utils.unit.test.js +0 -16
  43. package/dist/components/index.js +0 -1
  44. package/dist/components/labx-button.js +0 -1
  45. package/dist/components/labx-icon.js +0 -1
  46. package/dist/components/labx-input.js +0 -1
  47. package/dist/components/p-Dv2D1yhm.js +0 -1
  48. package/dist/esm/index-ByAEYo1n.js +0 -1510
  49. package/dist/esm/index.js +0 -5
  50. package/dist/esm/labx-components.js +0 -20
  51. package/dist/esm/loader.js +0 -10
  52. package/dist/index.cjs.js +0 -1
  53. package/dist/index.js +0 -1
  54. package/dist/labx-components/p-42d69adf.entry.js +0 -1
  55. package/dist/labx-components/p-ByAEYo1n.js +0 -2
  56. package/dist-angular/angular-component-lib/utils.d.ts +0 -9
  57. package/dist-angular/angular-component-lib/utils.js +0 -58
  58. package/dist-angular/components.d.ts +0 -33
  59. package/dist-angular/components.js +0 -92
  60. package/dist-angular/index.d.ts +0 -2
  61. package/dist-angular/text-value-accessor.d.ts +0 -5
  62. package/dist-angular/text-value-accessor.js +0 -31
  63. package/dist-angular/value-accessor.d.ts +0 -15
  64. package/dist-angular/value-accessor.js +0 -44
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../node_modules/ng-packagr/ng-package.schema.json",
3
+ "lib": {
4
+ "entryFile": "src/public-api.ts"
5
+ },
6
+ "dest": "../dist-angular"
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "labx-components-angular",
3
+ "version": "1.0.1",
4
+ "peerDependencies": {
5
+ "@angular/common": "^19.0.0",
6
+ "@angular/core": "^19.0.0"
7
+ }
8
+ }
@@ -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,94 @@
1
+ /* tslint:disable */
2
+ /* auto-generated angular directive proxies */
3
+ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, Output, NgZone } from '@angular/core';
4
+
5
+ import { ProxyCmp } from './angular-component-lib/utils';
6
+
7
+ import type { Components } from 'labx-components/components';
8
+
9
+ import { defineCustomElement as defineLabxButton } from 'labx-components/components/labx-button.js';
10
+ import { defineCustomElement as defineLabxIcon } from 'labx-components/components/labx-icon.js';
11
+ import { defineCustomElement as defineLabxInput } from 'labx-components/components/labx-input.js';
12
+ @ProxyCmp({
13
+ defineCustomElementFn: defineLabxButton,
14
+ inputs: ['disabled', 'label', 'type', 'variant']
15
+ })
16
+ @Component({
17
+ selector: 'labx-button',
18
+ changeDetection: ChangeDetectionStrategy.OnPush,
19
+ template: '<ng-content></ng-content>',
20
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
21
+ inputs: ['disabled', 'label', 'type', 'variant'],
22
+ outputs: ['labxClick'],
23
+ })
24
+ export class LabxButton {
25
+ protected el: HTMLLabxButtonElement;
26
+ @Output() labxClick = new EventEmitter<CustomEvent<void>>();
27
+ constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
28
+ c.detach();
29
+ this.el = r.nativeElement;
30
+ }
31
+ }
32
+
33
+
34
+ export declare interface LabxButton extends Components.LabxButton {
35
+ /**
36
+ * Se emite cuando el botón es clickeado
37
+ */
38
+ labxClick: EventEmitter<CustomEvent<void>>;
39
+ }
40
+
41
+
42
+ @ProxyCmp({
43
+ defineCustomElementFn: defineLabxIcon,
44
+ inputs: ['filled', 'name', 'size']
45
+ })
46
+ @Component({
47
+ selector: 'labx-icon',
48
+ changeDetection: ChangeDetectionStrategy.OnPush,
49
+ template: '<ng-content></ng-content>',
50
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
51
+ inputs: ['filled', { name: 'name', required: true }, 'size'],
52
+ })
53
+ export class LabxIcon {
54
+ protected el: HTMLLabxIconElement;
55
+ constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
56
+ c.detach();
57
+ this.el = r.nativeElement;
58
+ }
59
+ }
60
+
61
+
62
+ export declare interface LabxIcon extends Components.LabxIcon {}
63
+
64
+
65
+ @ProxyCmp({
66
+ defineCustomElementFn: defineLabxInput,
67
+ inputs: ['disabled', 'error', 'label', 'type', 'value']
68
+ })
69
+ @Component({
70
+ selector: 'labx-input',
71
+ changeDetection: ChangeDetectionStrategy.OnPush,
72
+ template: '<ng-content></ng-content>',
73
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
74
+ inputs: ['disabled', 'error', 'label', 'type', 'value'],
75
+ outputs: ['labxChange'],
76
+ })
77
+ export class LabxInput {
78
+ protected el: HTMLLabxInputElement;
79
+ @Output() labxChange = new EventEmitter<CustomEvent<string>>();
80
+ constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
81
+ c.detach();
82
+ this.el = r.nativeElement;
83
+ }
84
+ }
85
+
86
+
87
+ export declare interface LabxInput extends Components.LabxInput {
88
+ /**
89
+ * Se emite cuando el valor cambia
90
+ */
91
+ labxChange: EventEmitter<CustomEvent<string>>;
92
+ }
93
+
94
+
@@ -1,6 +1,8 @@
1
+
1
2
  import * as d from './components';
3
+
2
4
  export const DIRECTIVES = [
3
- d.LabxButton,
4
- d.LabxIcon,
5
- d.LabxInput
5
+ d.LabxButton,
6
+ d.LabxIcon,
7
+ d.LabxInput
6
8
  ];
@@ -0,0 +1,24 @@
1
+ import { Directive, ElementRef, forwardRef } 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: 'labx-input',
9
+ host: {
10
+ '(labxChange)': 'handleChangeEvent($event.target?.["value"])'
11
+ },
12
+ providers: [
13
+ {
14
+ provide: NG_VALUE_ACCESSOR,
15
+ useExisting: forwardRef(() => 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,39 @@
1
+ import { Directive, ElementRef, HostListener } from '@angular/core';
2
+ import { ControlValueAccessor } from '@angular/forms';
3
+
4
+ @Directive({})
5
+ export class ValueAccessor implements ControlValueAccessor {
6
+
7
+ private onChange: (value: any) => void = () => {/**/};
8
+ private onTouched: () => void = () => {/**/};
9
+ protected lastValue: any;
10
+
11
+ constructor(protected el: ElementRef) {}
12
+
13
+ writeValue(value: any) {
14
+ this.el.nativeElement.value = this.lastValue = value == null ? '' : value;
15
+ }
16
+
17
+ handleChangeEvent(value: any) {
18
+ if (value !== this.lastValue) {
19
+ this.lastValue = value;
20
+ this.onChange(value);
21
+ }
22
+ }
23
+
24
+ @HostListener('focusout')
25
+ _handleBlurEvent() {
26
+ this.onTouched();
27
+ }
28
+
29
+ registerOnChange(fn: (value: any) => void) {
30
+ this.onChange = fn;
31
+ }
32
+ registerOnTouched(fn: () => void) {
33
+ this.onTouched = fn;
34
+ }
35
+
36
+ setDisabledState(isDisabled: boolean) {
37
+ this.el.nativeElement.disabled = isDisabled;
38
+ }
39
+ }
@@ -0,0 +1,2 @@
1
+ export * from './lib/components';
2
+ export * from './lib/index';
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
+ "moduleResolution": "bundler",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "inlineSources": true,
9
+ "experimentalDecorators": true,
10
+ "skipLibCheck": true,
11
+ "strict": false,
12
+ "useDefineForClassFields": false,
13
+ "baseUrl": ".",
14
+ "paths": {
15
+ "labx-components/components": ["../dist/components/index.js"],
16
+ "labx-components/components/*": ["../dist/components/*"]
17
+ }
18
+ },
19
+ "angularCompilerOptions": {
20
+ "compilationMode": "partial"
21
+ },
22
+ "include": ["src/**/*.ts", "../dist/types/components.d.ts"],
23
+ "exclude": ["**/*.spec.ts"]
24
+ }