labx-components 0.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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/index-Dw9X5FBB.js +1519 -0
  3. package/dist/cjs/index.cjs.js +7 -0
  4. package/dist/cjs/labx-button_3.cjs.entry.js +104 -0
  5. package/dist/cjs/labx-components.cjs.js +24 -0
  6. package/dist/cjs/loader.cjs.js +12 -0
  7. package/dist/collection/collection-manifest.json +15 -0
  8. package/dist/collection/components/labx-button/labx-button.css +74 -0
  9. package/dist/collection/components/labx-button/labx-button.js +135 -0
  10. package/dist/collection/components/labx-icon/labx-icon.css +26 -0
  11. package/dist/collection/components/labx-icon/labx-icon.js +87 -0
  12. package/dist/collection/components/labx-input/labx-input.css +117 -0
  13. package/dist/collection/components/labx-input/labx-input.js +183 -0
  14. package/dist/collection/index.js +10 -0
  15. package/dist/collection/utils/utils.js +3 -0
  16. package/dist/collection/utils/utils.unit.test.js +16 -0
  17. package/dist/components/index.d.ts +35 -0
  18. package/dist/components/index.js +1 -0
  19. package/dist/components/labx-button.d.ts +11 -0
  20. package/dist/components/labx-button.js +1 -0
  21. package/dist/components/labx-icon.d.ts +11 -0
  22. package/dist/components/labx-icon.js +1 -0
  23. package/dist/components/labx-input.d.ts +11 -0
  24. package/dist/components/labx-input.js +1 -0
  25. package/dist/components/p-DEM5hG4h.js +1 -0
  26. package/dist/esm/index-dLjo-EBs.js +1510 -0
  27. package/dist/esm/index.js +5 -0
  28. package/dist/esm/labx-button_3.entry.js +100 -0
  29. package/dist/esm/labx-components.js +20 -0
  30. package/dist/esm/loader.js +10 -0
  31. package/dist/index.cjs.js +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/labx-components/index.esm.js +1 -0
  34. package/dist/labx-components/labx-components.css +1 -0
  35. package/dist/labx-components/labx-components.esm.js +1 -0
  36. package/dist/labx-components/p-956be281.entry.js +1 -0
  37. package/dist/labx-components/p-dLjo-EBs.js +2 -0
  38. package/dist/types/components/labx-button/labx-button.d.ts +15 -0
  39. package/dist/types/components/labx-icon/labx-icon.d.ts +9 -0
  40. package/dist/types/components/labx-input/labx-input.d.ts +24 -0
  41. package/dist/types/components.d.ts +237 -0
  42. package/dist/types/index.d.ts +11 -0
  43. package/dist/types/stencil-public-runtime.d.ts +1860 -0
  44. package/dist/types/utils/utils.d.ts +1 -0
  45. package/dist/types/utils/utils.unit.test.d.ts +1 -0
  46. package/dist-angular/angular-component-lib/utils.ts +65 -0
  47. package/dist-angular/components.ts +94 -0
  48. package/dist-angular/index.ts +8 -0
  49. package/dist-angular/text-value-accessor.ts +24 -0
  50. package/dist-angular/value-accessor.ts +39 -0
  51. package/loader/cdn.js +1 -0
  52. package/loader/index.cjs.js +1 -0
  53. package/loader/index.d.ts +24 -0
  54. package/loader/index.es2017.js +1 -0
  55. package/loader/index.js +2 -0
  56. package/package.json +57 -0
  57. package/readme.md +111 -0
@@ -0,0 +1 @@
1
+ export declare function format(first?: string, middle?: string, last?: string): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -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
+
@@ -0,0 +1,8 @@
1
+
2
+ import * as d from './components';
3
+
4
+ export const DIRECTIVES = [
5
+ d.LabxButton,
6
+ d.LabxIcon,
7
+ d.LabxInput
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
+ }
package/loader/cdn.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('../dist/cjs/loader.cjs.js');
@@ -0,0 +1 @@
1
+ module.exports = require('../dist/cjs/loader.cjs.js');
@@ -0,0 +1,24 @@
1
+ export * from '../dist/types/components';
2
+ export interface CustomElementsDefineOptions {
3
+ exclude?: string[];
4
+ resourcesUrl?: string;
5
+ syncQueue?: boolean;
6
+ jmp?: (c: Function) => any;
7
+ raf?: (c: FrameRequestCallback) => number;
8
+ ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
9
+ rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
10
+ }
11
+ export declare function defineCustomElements(win?: Window, opts?: CustomElementsDefineOptions): void;
12
+ /**
13
+ * @deprecated
14
+ */
15
+ export declare function applyPolyfills(): Promise<void>;
16
+
17
+ /**
18
+ * Used to specify a nonce value that corresponds with an application's CSP.
19
+ * When set, the nonce will be added to all dynamically created script and style tags at runtime.
20
+ * Alternatively, the nonce value can be set on a meta tag in the DOM head
21
+ * (<meta name="csp-nonce" content="{ nonce value here }" />) which
22
+ * will result in the same behavior.
23
+ */
24
+ export declare function setNonce(nonce: string): void;
@@ -0,0 +1 @@
1
+ export * from '../dist/esm/loader.js';
@@ -0,0 +1,2 @@
1
+ (function(){if("undefined"!==typeof window&&void 0!==window.Reflect&&void 0!==window.customElements){var a=HTMLElement;window.HTMLElement=function(){return Reflect.construct(a,[],this.constructor)};HTMLElement.prototype=a.prototype;HTMLElement.prototype.constructor=HTMLElement;Object.setPrototypeOf(HTMLElement,a)}})();
2
+ export * from '../dist/esm/loader.js';
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "labx-components",
3
+ "version": "0.1.0",
4
+ "description": "Web Components library built with Stencil. Includes Angular wrappers and design tokens.",
5
+ "author": "egarcia9543",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "stencil",
9
+ "web-components",
10
+ "angular",
11
+ "design-system",
12
+ "labx"
13
+ ],
14
+ "main": "dist/index.cjs.js",
15
+ "module": "dist/index.js",
16
+ "types": "dist/types/index.d.ts",
17
+ "collection": "dist/collection/collection-manifest.json",
18
+ "collection:main": "dist/collection/index.js",
19
+ "unpkg": "dist/labx-components/labx-components.esm.js",
20
+ "exports": {
21
+ ".": {
22
+ "import": "./dist/labx-components/labx-components.esm.js",
23
+ "require": "./dist/labx-components/labx-components.cjs.js"
24
+ },
25
+ "./loader": {
26
+ "import": "./loader/index.js",
27
+ "require": "./loader/index.cjs",
28
+ "types": "./loader/index.d.ts"
29
+ },
30
+ "./angular": {
31
+ "import": "./dist-angular/components.ts"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist/",
36
+ "loader/",
37
+ "dist-angular/"
38
+ ],
39
+ "scripts": {
40
+ "build": "stencil build",
41
+ "start": "stencil build --dev --watch --serve",
42
+ "test": "stencil-test",
43
+ "test:watch": "stencil-test --watch",
44
+ "generate": "stencil generate"
45
+ },
46
+ "devDependencies": {
47
+ "@stencil/angular-output-target": "^1.3.0",
48
+ "@stencil/core": "^4.27.1",
49
+ "@stencil/vitest": "^1.8.3",
50
+ "@types/node": "^22.13.5",
51
+ "@vitest/browser-playwright": "^4.0.0",
52
+ "vitest": "^4.0.0"
53
+ },
54
+ "peerDependencies": {
55
+ "@stencil/core": "^4.0.0"
56
+ }
57
+ }
package/readme.md ADDED
@@ -0,0 +1,111 @@
1
+ [![Built With Stencil](https://img.shields.io/badge/-Built%20With%20Stencil-16161d.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjIuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIgNTEyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI%2BCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI%2BCgkuc3Qwe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU%2BCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik00MjQuNywzNzMuOWMwLDM3LjYtNTUuMSw2OC42LTkyLjcsNjguNkgxODAuNGMtMzcuOSwwLTkyLjctMzAuNy05Mi43LTY4LjZ2LTMuNmgzMzYuOVYzNzMuOXoiLz4KPHBhdGggY2xhc3M9InN0MCIgZD0iTTQyNC43LDI5Mi4xSDE4MC40Yy0zNy42LDAtOTIuNy0zMS05Mi43LTY4LjZ2LTMuNkgzMzJjMzcuNiwwLDkyLjcsMzEsOTIuNyw2OC42VjI5Mi4xeiIvPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNNDI0LjcsMTQxLjdIODcuN3YtMy42YzAtMzcuNiw1NC44LTY4LjYsOTIuNy02OC42SDMzMmMzNy45LDAsOTIuNywzMC43LDkyLjcsNjguNlYxNDEuN3oiLz4KPC9zdmc%2BCg%3D%3D&colorA=16161d&style=flat-square)](https://stenciljs.com)
2
+
3
+ # Stencil Component Starter
4
+
5
+ > This is a starter project for building a standalone Web Components using Stencil.
6
+
7
+ Stencil is a compiler for building fast web apps using Web Components.
8
+
9
+ Stencil combines the best concepts of the most popular frontend frameworks into a compile-time rather than runtime tool. Stencil takes TypeScript, JSX, a tiny virtual DOM layer, efficient one-way data binding, an asynchronous rendering pipeline (similar to React Fiber), and lazy-loading out of the box, and generates 100% standards-based Web Components that run in any browser supporting the Custom Elements specification.
10
+
11
+ Stencil components are just Web Components, so they work in any major framework or with no framework at all.
12
+
13
+ ## Getting Started
14
+
15
+ To start building a new web component using Stencil, clone this repo to a new directory:
16
+
17
+ ```bash
18
+ git clone https://github.com/stenciljs/component-starter.git my-component
19
+ cd my-component
20
+ git remote rm origin
21
+ ```
22
+
23
+ and run:
24
+
25
+ ```bash
26
+ npm install
27
+ npm start
28
+ ```
29
+
30
+ To build the component for production, run:
31
+
32
+ ```bash
33
+ npm run build
34
+ ```
35
+
36
+ To run the unit tests for the components, run:
37
+
38
+ ```bash
39
+ npm test
40
+ ```
41
+
42
+ Need help? Check out our docs [here](https://stenciljs.com/docs/my-first-component).
43
+
44
+ ## Naming Components
45
+
46
+ When creating new component tags, we recommend _not_ using `stencil` in the component name (ex: `<stencil-datepicker>`). This is because the generated component has little to nothing to do with Stencil; it's just a web component!
47
+
48
+ Instead, use a prefix that fits your company or any name for a group of related components. For example, all of the [Ionic-generated](https://ionicframework.com/) web components use the prefix `ion`.
49
+
50
+ ## Using this component
51
+
52
+ There are two strategies we recommend for using web components built with Stencil.
53
+
54
+ The first step for all two of these strategies is to [publish to NPM](https://docs.npmjs.com/getting-started/publishing-npm-packages).
55
+
56
+ You can read more about these different approaches in the [Stencil docs](https://stenciljs.com/docs/publishing).
57
+
58
+ ### Lazy Loading
59
+
60
+ If your Stencil project is built with the [`dist`](https://stenciljs.com/docs/distribution) output target, you can import a small bootstrap script that registers all components and allows you to load individual component scripts lazily.
61
+
62
+ For example, given your Stencil project namespace is called `my-design-system`, to use `my-component` on any website, inject this into your HTML:
63
+
64
+ ```html
65
+ <script type="module" src="https://unpkg.com/my-design-system"></script>
66
+ <!--
67
+ To avoid unpkg.com redirects to the actual file, you can also directly import:
68
+ https://unpkg.com/foobar-design-system@0.0.1/dist/foobar-design-system/foobar-design-system.esm.js
69
+ -->
70
+ <my-component first="Stencil" middle="'Don't call me a framework'" last="JS"></my-component>
71
+ ```
72
+
73
+ This will only load the necessary scripts needed to render `<my-component />`. Once more components of this package are used, they will automatically be loaded lazily.
74
+
75
+ You can also import the script as part of your `node_modules` in your applications entry file:
76
+
77
+ ```tsx
78
+ import 'foobar-design-system/dist/foobar-design-system/foobar-design-system.esm.js';
79
+ ```
80
+
81
+ Check out this [Live Demo](https://stackblitz.com/edit/vitejs-vite-y6v26a?file=src%2Fmain.tsx).
82
+
83
+ ### Standalone
84
+
85
+ If you are using a Stencil component library with `dist-custom-elements`, we recommend importing Stencil components individually in those files where they are needed.
86
+
87
+ To export Stencil components as standalone components make sure you have the [`dist-custom-elements`](https://stenciljs.com/docs/custom-elements) output target defined in your `stencil.config.ts`.
88
+
89
+ For example, given you'd like to use `<my-component />` as part of a React component, you can import the component directly via:
90
+
91
+ ```tsx
92
+ import 'foobar-design-system/my-component';
93
+
94
+ function App() {
95
+ return (
96
+ <>
97
+ <div>
98
+ <my-component
99
+ first="Stencil"
100
+ middle="'Don't call me a framework'"
101
+ last="JS"
102
+ ></my-component>
103
+ </div>
104
+ </>
105
+ );
106
+ }
107
+
108
+ export default App;
109
+ ```
110
+
111
+ Check out this [Live Demo](https://stackblitz.com/edit/vitejs-vite-b6zuds?file=src%2FApp.tsx).