labx-components 0.1.3 → 1.0.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.
@@ -0,0 +1,9 @@
1
+ export declare const proxyInputs: (Cmp: any, inputs: string[]) => void;
2
+ export declare const proxyMethods: (Cmp: any, methods: string[]) => void;
3
+ export declare const proxyOutputs: (instance: any, el: any, events: string[]) => void;
4
+ export declare const defineCustomElement: (tagName: string, customElement: any) => void;
5
+ export declare function ProxyCmp(opts: {
6
+ defineCustomElementFn?: () => void;
7
+ inputs?: any;
8
+ methods?: any;
9
+ }): (cls: any) => any;
@@ -0,0 +1,58 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ import { fromEvent } from 'rxjs';
4
+ export const proxyInputs = (Cmp, inputs) => {
5
+ const Prototype = Cmp.prototype;
6
+ inputs.forEach((item) => {
7
+ Object.defineProperty(Prototype, item, {
8
+ get() {
9
+ return this.el[item];
10
+ },
11
+ set(val) {
12
+ this.z.runOutsideAngular(() => (this.el[item] = val));
13
+ },
14
+ /**
15
+ * In the event that proxyInputs is called
16
+ * multiple times re-defining these inputs
17
+ * will cause an error to be thrown. As a result
18
+ * we set configurable: true to indicate these
19
+ * properties can be changed.
20
+ */
21
+ configurable: true,
22
+ });
23
+ });
24
+ };
25
+ export const proxyMethods = (Cmp, methods) => {
26
+ const Prototype = Cmp.prototype;
27
+ methods.forEach((methodName) => {
28
+ Prototype[methodName] = function () {
29
+ const args = arguments;
30
+ return this.z.runOutsideAngular(() => this.el[methodName].apply(this.el, args));
31
+ };
32
+ });
33
+ };
34
+ export const proxyOutputs = (instance, el, events) => {
35
+ events.forEach((eventName) => (instance[eventName] = fromEvent(el, eventName)));
36
+ };
37
+ export const defineCustomElement = (tagName, customElement) => {
38
+ if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
39
+ customElements.define(tagName, customElement);
40
+ }
41
+ };
42
+ // tslint:disable-next-line: only-arrow-functions
43
+ export function ProxyCmp(opts) {
44
+ const decorator = function (cls) {
45
+ const { defineCustomElementFn, inputs, methods } = opts;
46
+ if (defineCustomElementFn !== undefined) {
47
+ defineCustomElementFn();
48
+ }
49
+ if (inputs) {
50
+ proxyInputs(cls, inputs);
51
+ }
52
+ if (methods) {
53
+ proxyMethods(cls, methods);
54
+ }
55
+ return cls;
56
+ };
57
+ return decorator;
58
+ }
@@ -0,0 +1,33 @@
1
+ import { ChangeDetectorRef, ElementRef, EventEmitter, NgZone } from '@angular/core';
2
+ import type { Components } from 'labx-components/components';
3
+ export declare class LabxButton {
4
+ protected z: NgZone;
5
+ protected el: HTMLLabxButtonElement;
6
+ labxClick: EventEmitter<CustomEvent<void>>;
7
+ constructor(c: ChangeDetectorRef, r: ElementRef, z: NgZone);
8
+ }
9
+ export declare interface LabxButton extends Components.LabxButton {
10
+ /**
11
+ * Se emite cuando el botón es clickeado
12
+ */
13
+ labxClick: EventEmitter<CustomEvent<void>>;
14
+ }
15
+ export declare class LabxIcon {
16
+ protected z: NgZone;
17
+ protected el: HTMLLabxIconElement;
18
+ constructor(c: ChangeDetectorRef, r: ElementRef, z: NgZone);
19
+ }
20
+ export declare interface LabxIcon extends Components.LabxIcon {
21
+ }
22
+ export declare class LabxInput {
23
+ protected z: NgZone;
24
+ protected el: HTMLLabxInputElement;
25
+ labxChange: EventEmitter<CustomEvent<string>>;
26
+ constructor(c: ChangeDetectorRef, r: ElementRef, z: NgZone);
27
+ }
28
+ export declare interface LabxInput extends Components.LabxInput {
29
+ /**
30
+ * Se emite cuando el valor cambia
31
+ */
32
+ labxChange: EventEmitter<CustomEvent<string>>;
33
+ }
@@ -0,0 +1,92 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ /* tslint:disable */
8
+ /* auto-generated angular directive proxies */
9
+ import { ChangeDetectionStrategy, Component, EventEmitter, Output } from '@angular/core';
10
+ import { ProxyCmp } from './angular-component-lib/utils';
11
+ import { defineCustomElement as defineLabxButton } from 'labx-components/components/labx-button.js';
12
+ import { defineCustomElement as defineLabxIcon } from 'labx-components/components/labx-icon.js';
13
+ import { defineCustomElement as defineLabxInput } from 'labx-components/components/labx-input.js';
14
+ let LabxButton = class LabxButton {
15
+ z;
16
+ el;
17
+ labxClick = new EventEmitter();
18
+ constructor(c, r, z) {
19
+ this.z = z;
20
+ c.detach();
21
+ this.el = r.nativeElement;
22
+ }
23
+ };
24
+ __decorate([
25
+ Output()
26
+ ], LabxButton.prototype, "labxClick", void 0);
27
+ LabxButton = __decorate([
28
+ ProxyCmp({
29
+ defineCustomElementFn: defineLabxButton,
30
+ inputs: ['disabled', 'label', 'type', 'variant']
31
+ }),
32
+ Component({
33
+ selector: 'labx-button',
34
+ changeDetection: ChangeDetectionStrategy.OnPush,
35
+ template: '<ng-content></ng-content>',
36
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
37
+ inputs: ['disabled', 'label', 'type', 'variant'],
38
+ outputs: ['labxClick'],
39
+ })
40
+ ], LabxButton);
41
+ export { LabxButton };
42
+ let LabxIcon = class LabxIcon {
43
+ z;
44
+ el;
45
+ constructor(c, r, z) {
46
+ this.z = z;
47
+ c.detach();
48
+ this.el = r.nativeElement;
49
+ }
50
+ };
51
+ LabxIcon = __decorate([
52
+ ProxyCmp({
53
+ defineCustomElementFn: defineLabxIcon,
54
+ inputs: ['filled', 'name', 'size']
55
+ }),
56
+ Component({
57
+ selector: 'labx-icon',
58
+ changeDetection: ChangeDetectionStrategy.OnPush,
59
+ template: '<ng-content></ng-content>',
60
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
61
+ inputs: ['filled', { name: 'name', required: true }, 'size'],
62
+ })
63
+ ], LabxIcon);
64
+ export { LabxIcon };
65
+ let LabxInput = class LabxInput {
66
+ z;
67
+ el;
68
+ labxChange = new EventEmitter();
69
+ constructor(c, r, z) {
70
+ this.z = z;
71
+ c.detach();
72
+ this.el = r.nativeElement;
73
+ }
74
+ };
75
+ __decorate([
76
+ Output()
77
+ ], LabxInput.prototype, "labxChange", void 0);
78
+ LabxInput = __decorate([
79
+ ProxyCmp({
80
+ defineCustomElementFn: defineLabxInput,
81
+ inputs: ['disabled', 'error', 'label', 'type', 'value']
82
+ }),
83
+ Component({
84
+ selector: 'labx-input',
85
+ changeDetection: ChangeDetectionStrategy.OnPush,
86
+ template: '<ng-content></ng-content>',
87
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
88
+ inputs: ['disabled', 'error', 'label', 'type', 'value'],
89
+ outputs: ['labxChange'],
90
+ })
91
+ ], LabxInput);
92
+ export { LabxInput };
@@ -0,0 +1,2 @@
1
+ import * as d from './components';
2
+ export declare const DIRECTIVES: (typeof d.LabxButton | typeof d.LabxIcon | typeof d.LabxInput)[];
@@ -0,0 +1,6 @@
1
+ import * as d from './components';
2
+ export const DIRECTIVES = [
3
+ d.LabxButton,
4
+ d.LabxIcon,
5
+ d.LabxInput
6
+ ];
@@ -0,0 +1,5 @@
1
+ import { ElementRef } from '@angular/core';
2
+ import { ValueAccessor } from './value-accessor';
3
+ export declare class TextValueAccessor extends ValueAccessor {
4
+ constructor(el: ElementRef);
5
+ }
@@ -0,0 +1,31 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Directive, forwardRef } from '@angular/core';
8
+ import { NG_VALUE_ACCESSOR } from '@angular/forms';
9
+ import { ValueAccessor } from './value-accessor';
10
+ let TextValueAccessor = class TextValueAccessor extends ValueAccessor {
11
+ constructor(el) {
12
+ super(el);
13
+ }
14
+ };
15
+ TextValueAccessor = __decorate([
16
+ Directive({
17
+ /* tslint:disable-next-line:directive-selector */
18
+ selector: 'labx-input',
19
+ host: {
20
+ '(labxChange)': 'handleChangeEvent($event.target?.["value"])'
21
+ },
22
+ providers: [
23
+ {
24
+ provide: NG_VALUE_ACCESSOR,
25
+ useExisting: forwardRef(() => TextValueAccessor),
26
+ multi: true
27
+ }
28
+ ]
29
+ })
30
+ ], TextValueAccessor);
31
+ export { TextValueAccessor };
@@ -0,0 +1,15 @@
1
+ import { ElementRef } from '@angular/core';
2
+ import { ControlValueAccessor } from '@angular/forms';
3
+ export declare class ValueAccessor implements ControlValueAccessor {
4
+ protected el: ElementRef;
5
+ private onChange;
6
+ private onTouched;
7
+ protected lastValue: any;
8
+ constructor(el: ElementRef);
9
+ writeValue(value: any): void;
10
+ handleChangeEvent(value: any): void;
11
+ _handleBlurEvent(): void;
12
+ registerOnChange(fn: (value: any) => void): void;
13
+ registerOnTouched(fn: () => void): void;
14
+ setDisabledState(isDisabled: boolean): void;
15
+ }
@@ -0,0 +1,44 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Directive, HostListener } from '@angular/core';
8
+ let ValueAccessor = class ValueAccessor {
9
+ el;
10
+ onChange = () => { };
11
+ onTouched = () => { };
12
+ lastValue;
13
+ constructor(el) {
14
+ this.el = el;
15
+ }
16
+ writeValue(value) {
17
+ this.el.nativeElement.value = this.lastValue = value == null ? '' : value;
18
+ }
19
+ handleChangeEvent(value) {
20
+ if (value !== this.lastValue) {
21
+ this.lastValue = value;
22
+ this.onChange(value);
23
+ }
24
+ }
25
+ _handleBlurEvent() {
26
+ this.onTouched();
27
+ }
28
+ registerOnChange(fn) {
29
+ this.onChange = fn;
30
+ }
31
+ registerOnTouched(fn) {
32
+ this.onTouched = fn;
33
+ }
34
+ setDisabledState(isDisabled) {
35
+ this.el.nativeElement.disabled = isDisabled;
36
+ }
37
+ };
38
+ __decorate([
39
+ HostListener('focusout')
40
+ ], ValueAccessor.prototype, "_handleBlurEvent", null);
41
+ ValueAccessor = __decorate([
42
+ Directive({})
43
+ ], ValueAccessor);
44
+ export { ValueAccessor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "labx-components",
3
- "version": "0.1.3",
3
+ "version": "1.0.0",
4
4
  "description": "Web Components library built with Stencil. Includes Angular wrappers and design tokens.",
5
5
  "author": "egarcia9543",
6
6
  "license": "MIT",
@@ -28,7 +28,8 @@
28
28
  "types": "./loader/index.d.ts"
29
29
  },
30
30
  "./angular": {
31
- "import": "./dist-angular/components.ts"
31
+ "import": "./dist-angular/components.js",
32
+ "types": "./dist-angular/components.d.ts"
32
33
  },
33
34
  "./components": {
34
35
  "import": "./dist/components/index.js",
@@ -45,18 +46,22 @@
45
46
  "dist-angular/"
46
47
  ],
47
48
  "scripts": {
48
- "build": "stencil build",
49
+ "build": "stencil build && tsc -p tsconfig.angular.json",
50
+ "build:angular": "tsc -p tsconfig.angular.json",
49
51
  "start": "stencil build --dev --watch --serve",
50
52
  "test": "stencil-test",
51
53
  "test:watch": "stencil-test --watch",
52
54
  "generate": "stencil generate"
53
55
  },
54
56
  "devDependencies": {
57
+ "@angular/core": "^18.2.14",
58
+ "@angular/forms": "^18.2.14",
55
59
  "@stencil/angular-output-target": "^1.3.0",
56
60
  "@stencil/core": "^4.27.1",
57
61
  "@stencil/vitest": "^1.8.3",
58
62
  "@types/node": "^22.13.5",
59
63
  "@vitest/browser-playwright": "^4.0.0",
64
+ "rxjs": "^7.8.2",
60
65
  "vitest": "^4.0.0"
61
66
  },
62
67
  "peerDependencies": {