@atmgrupomaggioli/iris-button 0.2.5 → 0.3.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 (43) hide show
  1. package/changelog.md +32 -0
  2. package/dist/cjs/index-D8dxP54K.js +1337 -0
  3. package/dist/cjs/index-D8dxP54K.js.map +1 -0
  4. package/dist/cjs/iris-button.cjs.entry.js +2412 -50
  5. package/dist/cjs/iris-button.cjs.entry.js.map +1 -1
  6. package/dist/cjs/iris-button.cjs.js +2 -2
  7. package/dist/cjs/iris-button.cjs.js.map +1 -1
  8. package/dist/cjs/iris-button.entry.cjs.js.map +1 -1
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/collection/collection-manifest.json +1 -1
  11. package/dist/collection/components/iris-button/iris-button.js +111 -55
  12. package/dist/collection/components/iris-button/iris-button.js.map +1 -1
  13. package/dist/components/index.js +47 -11
  14. package/dist/components/index.js.map +1 -1
  15. package/dist/components/iris-button.js +2411 -49
  16. package/dist/components/iris-button.js.map +1 -1
  17. package/dist/esm/index-Ca-CmCbL.js +1329 -0
  18. package/dist/esm/index-Ca-CmCbL.js.map +1 -0
  19. package/dist/esm/iris-button.entry.js +2412 -50
  20. package/dist/esm/iris-button.entry.js.map +1 -1
  21. package/dist/esm/iris-button.js +3 -3
  22. package/dist/esm/iris-button.js.map +1 -1
  23. package/dist/esm/loader.js +2 -2
  24. package/dist/iris-button/iris-button.css +10 -2
  25. package/dist/iris-button/iris-button.entry.esm.js.map +1 -1
  26. package/dist/iris-button/iris-button.esm.js +1 -1
  27. package/dist/iris-button/iris-button.esm.js.map +1 -1
  28. package/dist/iris-button/p-55d7ced4.entry.js +2 -0
  29. package/dist/iris-button/p-55d7ced4.entry.js.map +1 -0
  30. package/dist/iris-button/p-Ca-CmCbL.js +3 -0
  31. package/dist/iris-button/p-Ca-CmCbL.js.map +1 -0
  32. package/dist/types/components/iris-button/iris-button.d.ts +20 -7
  33. package/dist/types/components.d.ts +43 -10
  34. package/package.json +13 -9
  35. package/readme.md +22 -19
  36. package/dist/cjs/index-vCW2wQf6.js +0 -1299
  37. package/dist/cjs/index-vCW2wQf6.js.map +0 -1
  38. package/dist/esm/index-DScl31jK.js +0 -1291
  39. package/dist/esm/index-DScl31jK.js.map +0 -1
  40. package/dist/iris-button/p-DScl31jK.js +0 -3
  41. package/dist/iris-button/p-DScl31jK.js.map +0 -1
  42. package/dist/iris-button/p-fe0bfee6.entry.js +0 -2
  43. package/dist/iris-button/p-fe0bfee6.entry.js.map +0 -1
@@ -1,56 +1,97 @@
1
1
  import { h } from "@stencil/core";
2
2
  import { RequieredPropsUtils } from "@atmgrupomaggioli/iris-utils";
3
+ import { getGlobalComponentConfig } from "@atmgrupomaggioli/iris-globals";
4
+ /**
5
+ * Su función principal es comunicar información de manera rápida y visualmente efectiva.
6
+ *
7
+ * Algunos casos comunes de uso incluyen:
8
+ * - **Notificaciones interactivas**: Proporcionar una notificación visual, como el número de mensajes no leídos, junto con la capacidad de acceder rápidamente a esos mensajes al hacer click en el badge.
9
+ * - **Acciones rápidas**: Ofrecer accesos directos a acciones comunes o funciones importantes. Por ejemplo, un badge con botón podría representar el número de elementos en un carrito de compras, permitiendo al usuario abrir el carrito al hacer click en él.
10
+ * - **Estado y acciones combinadas**: Mostrar el estado actual de un elemento junto con opciones de acción relacionadas. Por ejemplo, un badge con botón podría indicar que hay una actualización disponible para descargar, y al hacer click en él, el usuario puede iniciar la descarga directamente.
11
+ */
3
12
  export class IrisButton {
4
- constructor() {
5
- /**
6
- * Indica el tipo de botón ayudando al usuario a explicar su funcionalidad.
7
- * Para ver más información al respecto, lea la documentación del componente.
8
- */
9
- this.color = 'primary';
10
- /**
11
- * Deshabilita el botón para que no pueda ser pulsado.
12
- */
13
- this.disabled = false;
14
- /**
15
- * Tipo de botón.
16
- */
17
- this.type = '';
18
- /**
19
- * Permite mostrar una animación de carga mientras se realiza alguna acción.
20
- * Al activarse esta opción, el botón se deshabilita.
21
- */
22
- this.loading = false;
23
- /**
24
- * Tamaño del botón.
25
- */
26
- this.size = 'medium';
27
- //#endregion
28
- //#region Handlers
29
- //FIXME: Cuando loading se pone en true, también debería mantenerse disabled en true hasta que termine. Ahora se pone disabled a false antes de tiempo y rompe el funcionamiento.
30
- /**
31
- * Método que se ejecuta al hacer clic y emite el evento.
32
- * @param ev
33
- */
34
- this.handleClick = (ev) => {
35
- // Evitamos que el evento burbujee.
36
- ev.stopPropagation();
37
- // Deshabilitamos el botón durante un segundo para que no sea pulsados repetidas veces.
38
- this.button.disabled = true;
39
- setTimeout(() => {
40
- if (!this.loading) {
41
- this.button.disabled = false;
42
- }
43
- }, 1000);
44
- // Lanzamos el evento.
45
- this.buttonClicked.emit(ev);
46
- };
47
- /**
48
- * Método que se ejecuta cuando se ha hecho focus en el botón.
49
- * @param ev
50
- */
51
- this.handleFocus = (ev) => {
52
- this.buttonFocused.emit(ev);
53
- };
13
+ //#region Props
14
+ /**
15
+ * Texto del botón.
16
+ */
17
+ label;
18
+ /**
19
+ * Indica el tipo de botón ayudando al usuario a explicar su funcionalidad.
20
+ * Para ver más información al respecto, lea la documentación del componente.
21
+ */
22
+ color = getGlobalComponentConfig('IrisButton')?.color || 'primary';
23
+ /**
24
+ * Icono del botón.
25
+ * Consulta todos los iconos disponibles en: https://fonts.google.com/icons
26
+ */
27
+ icon;
28
+ /**
29
+ * Deshabilita el botón para que no pueda ser pulsado.
30
+ */
31
+ disabled = getGlobalComponentConfig('IrisButton')?.disabled || false;
32
+ /**
33
+ * Tipo de botón.
34
+ */
35
+ type = getGlobalComponentConfig('IrisButton')?.type || '';
36
+ /**
37
+ * Permite mostrar una animación de carga mientras se realiza alguna acción.
38
+ * Al activarse esta opción, el botón se deshabilita.
39
+ */
40
+ loading = getGlobalComponentConfig('IrisButton')?.loading || false;
41
+ /**
42
+ * Tamaño del botón.
43
+ */
44
+ size = getGlobalComponentConfig('IrisButton')?.size || 'medium';
45
+ //#endregion
46
+ //#region Variables privadas
47
+ // Tag <button> del DOM.
48
+ button;
49
+ //#endregion
50
+ //#region Events
51
+ /**
52
+ * Evento del botón al ser pulsado.
53
+ */
54
+ buttonClicked;
55
+ /**
56
+ * Evento del botón al ser enfocado.
57
+ */
58
+ buttonFocused;
59
+ /**
60
+ * Evento lanzado cuando el componente está complementamente listo.
61
+ */
62
+ ready;
63
+ //#endregion
64
+ //#region Handlers
65
+ //FIXME: Cuando loading se pone en true, también debería mantenerse disabled en true hasta que termine. Ahora se pone disabled a false antes de tiempo y rompe el funcionamiento.
66
+ /**
67
+ * Método que se ejecuta al hacer clic y emite el evento.
68
+ * @param ev
69
+ */
70
+ handleClick = (ev) => {
71
+ // Evitamos que el evento burbujee.
72
+ ev.stopPropagation();
73
+ // Deshabilitamos el botón durante un segundo para que no sea pulsados repetidas veces.
74
+ this.button.disabled = true;
75
+ setTimeout(() => {
76
+ if (!this.loading) {
77
+ this.button.disabled = false;
78
+ }
79
+ }, 1000);
80
+ // Lanzamos el evento.
81
+ this.buttonClicked.emit(ev);
82
+ };
83
+ /**
84
+ * Método que se ejecuta cuando se ha hecho focus en el botón.
85
+ * @param ev
86
+ */
87
+ handleFocus = (ev) => {
88
+ this.buttonFocused.emit(ev);
89
+ };
90
+ //#endregion
91
+ //#region Ciclos de vida
92
+ componentDidLoad() {
93
+ // Emitimos el evento de que el control se ha cargado.
94
+ this.ready.emit();
54
95
  }
55
96
  //#endregion
56
97
  render() {
@@ -115,7 +156,7 @@ export class IrisButton {
115
156
  "getter": false,
116
157
  "setter": false,
117
158
  "reflect": false,
118
- "defaultValue": "'primary'"
159
+ "defaultValue": "getGlobalComponentConfig('IrisButton')?.color || 'primary'"
119
160
  },
120
161
  "icon": {
121
162
  "type": "string",
@@ -154,7 +195,7 @@ export class IrisButton {
154
195
  "getter": false,
155
196
  "setter": false,
156
197
  "reflect": false,
157
- "defaultValue": "false"
198
+ "defaultValue": "getGlobalComponentConfig('IrisButton')?.disabled || false"
158
199
  },
159
200
  "type": {
160
201
  "type": "string",
@@ -174,7 +215,7 @@ export class IrisButton {
174
215
  "getter": false,
175
216
  "setter": false,
176
217
  "reflect": false,
177
- "defaultValue": "''"
218
+ "defaultValue": "getGlobalComponentConfig('IrisButton')?.type || ''"
178
219
  },
179
220
  "loading": {
180
221
  "type": "boolean",
@@ -194,7 +235,7 @@ export class IrisButton {
194
235
  "getter": false,
195
236
  "setter": false,
196
237
  "reflect": false,
197
- "defaultValue": "false"
238
+ "defaultValue": "getGlobalComponentConfig('IrisButton')?.loading || false"
198
239
  },
199
240
  "size": {
200
241
  "type": "string",
@@ -214,7 +255,7 @@ export class IrisButton {
214
255
  "getter": false,
215
256
  "setter": false,
216
257
  "reflect": false,
217
- "defaultValue": "'medium'"
258
+ "defaultValue": "getGlobalComponentConfig('IrisButton')?.size || 'medium'"
218
259
  }
219
260
  };
220
261
  }
@@ -261,6 +302,21 @@ export class IrisButton {
261
302
  }
262
303
  }
263
304
  }
305
+ }, {
306
+ "method": "ready",
307
+ "name": "ready",
308
+ "bubbles": true,
309
+ "cancelable": true,
310
+ "composed": true,
311
+ "docs": {
312
+ "tags": [],
313
+ "text": "Evento lanzado cuando el componente est\u00E1 complementamente listo."
314
+ },
315
+ "complexType": {
316
+ "original": "void",
317
+ "resolved": "void",
318
+ "references": {}
319
+ }
264
320
  }];
265
321
  }
266
322
  }
@@ -1 +1 @@
1
- {"version":3,"file":"iris-button.js","sourceRoot":"","sources":["../../../src/components/iris-button/iris-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAOnE,MAAM,OAAO,UAAU;IALvB;QAaE;;;WAGG;QAEH,UAAK,GAA0D,SAAS,CAAC;QASzE;;WAEG;QAEH,aAAQ,GAAG,KAAK,CAAC;QAEjB;;WAEG;QAEH,SAAI,GAAwB,EAAE,CAAC;QAE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AAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,EAAuB,CAAC,EACpD,KAAK,EAAE,IAAI,CAAC,KAAK;YAGf,qCAAqC;YACrC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CACd,iBAAW,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,GAAc,CAC1D,CAAC,CAAC,CAAC,CACF,WAAK,KAAK,EAAC,SAAS;gBAClB,oBAAc,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAiB,CACzD,CACP;YAGD,oDAAoD;YACpD,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAEtD,CACV,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, Event, EventEmitter, h } from '@stencil/core';\nimport { RequieredPropsUtils } from '@atmgrupomaggioli/iris-utils';\n\n@Component({\n tag: 'iris-button',\n styleUrl: 'iris-button.scss',\n shadow: true,\n})\nexport class IrisButton {\n //#region Props\n\n /**\n * Texto del botón.\n */\n @Prop() label!: string;\n\n /**\n * Indica el tipo de botón ayudando al usuario a explicar su funcionalidad.\n * Para ver más información al respecto, lea la documentación del componente.\n */\n @Prop()\n color: 'primary' | 'success' | 'warning' | 'error' | 'basic' = 'primary';\n\n /**\n * Icono del botón.\n * Consulta todos los iconos disponibles en: https://fonts.google.com/icons\n */\n @Prop()\n icon!: string;\n\n /**\n * Deshabilita el botón para que no pueda ser pulsado.\n */\n @Prop()\n disabled = false;\n\n /**\n * Tipo de botón.\n */\n @Prop()\n type: '' | 'icon' | 'fab' = '';\n\n /**\n * Permite mostrar una animación de carga mientras se realiza alguna acción.\n * Al activarse esta opción, el botón se deshabilita.\n */\n @Prop()\n loading = false;\n\n /**\n * Tamaño del botón.\n */\n @Prop()\n size: 'small' | 'medium' | 'large' = 'medium';\n\n //#endregion\n\n //#region Variables privadas\n\n // Tag <button> del DOM.\n button!: HTMLButtonElement;\n\n //#endregion\n\n //#region Events\n\n /**\n * Evento del botón al ser pulsado.\n */\n @Event({ bubbles: false, composed: false }) buttonClicked: EventEmitter<Event>;\n\n /**\n * Evento del botón al ser enfocado.\n */\n @Event() buttonFocused: EventEmitter<Event>;\n\n //#endregion\n\n //#region Handlers\n\n //FIXME: Cuando loading se pone en true, también debería mantenerse disabled en true hasta que termine. Ahora se pone disabled a false antes de tiempo y rompe el funcionamiento.\n\n /**\n * Método que se ejecuta al hacer clic y emite el evento.\n * @param ev\n */\n handleClick = (ev: Event) => {\n // Evitamos que el evento burbujee.\n ev.stopPropagation();\n\n // Deshabilitamos el botón durante un segundo para que no sea pulsados repetidas veces.\n this.button.disabled = true;\n setTimeout(() => {\n if (!this.loading) {\n this.button.disabled = false;\n }\n }, 1000);\n\n // Lanzamos el evento.\n this.buttonClicked.emit(ev);\n };\n\n /**\n * Método que se ejecuta cuando se ha hecho focus en el botón.\n * @param ev\n */\n handleFocus = (ev: Event) => {\n this.buttonFocused.emit(ev);\n };\n\n //#endregion\n\n render() {\n // Validamos que todos los campos están rellenos.\n const requiredFiles: Record<string, any> = { label: this.label, icon: this.icon };\n if (!RequieredPropsUtils.check(requiredFiles)) return;\n\n return (\n <button\n class={`${this.size}`}\n color={this.color}\n type={this.type}\n onClick={this.handleClick}\n disabled={this.disabled || this.loading}\n onFocus={this.handleFocus}\n ref={(el) => (this.button = el as HTMLButtonElement)}\n title={this.label}\n >\n {\n // Comprobamos si se muestra cargando\n !this.loading ? (\n <iris-icon icon={this.icon} size={this.size}></iris-icon>\n ) : (\n <div class=\"loading\">\n <iris-loading size=\"small\" color={this.color}></iris-loading>\n </div>\n )\n }\n {\n // Solo añadimos el label para los botones normales.\n this.type == 'icon' || this.type == 'fab' ? '' : this.label\n }\n </button>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"iris-button.js","sourceRoot":"","sources":["../../../src/components/iris-button/iris-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE1E;;;;;;;GAOG;AAMH,MAAM,OAAO,UAAU;IACrB,eAAe;IAEf;;OAEG;IAEM,KAAK,CAAU;IAExB;;;OAGG;IAEM,KAAK,GACZ,wBAAwB,CAAC,YAAY,CAAC,EAAE,KAAK,IAAI,SAAS,CAAC;IAE7D;;;OAGG;IAEM,IAAI,CAAU;IAEvB;;OAEG;IAEM,QAAQ,GAAY,wBAAwB,CAAC,YAAY,CAAC,EAAE,QAAQ,IAAI,KAAK,CAAC;IAEvF;;OAEG;IAEM,IAAI,GAAwB,wBAAwB,CAAC,YAAY,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC;IAExF;;;OAGG;IAEM,OAAO,GAAY,wBAAwB,CAAC,YAAY,CAAC,EAAE,OAAO,IAAI,KAAK,CAAC;IAErF;;OAEG;IAEM,IAAI,GACX,wBAAwB,CAAC,YAAY,CAAC,EAAE,IAAI,IAAI,QAAQ,CAAC;IAE3D,YAAY;IAEZ,4BAA4B;IAE5B,wBAAwB;IACxB,MAAM,CAAqB;IAE3B,YAAY;IAEZ,gBAAgB;IAEhB;;OAEG;IACyC,aAAa,CAAsB;IAE/E;;OAEG;IACM,aAAa,CAAsB;IAE5C;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AAO,EAAE,IAAI,CAAC,WAAW,EACzB,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,EAAuB,CAAC,EACpD,KAAK,EAAE,IAAI,CAAC,KAAK;YAGf,qCAAqC;YACrC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CACd,iBAAW,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,GAAc,CAC1D,CAAC,CAAC,CAAC,CACF,WAAK,KAAK,EAAC,SAAS;gBAClB,oBAAc,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAiB,CACzD,CACP;YAGD,oDAAoD;YACpD,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAEtD,CACV,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, Event, EventEmitter, h } from '@stencil/core';\nimport { RequieredPropsUtils } from '@atmgrupomaggioli/iris-utils';\nimport { getGlobalComponentConfig } from '@atmgrupomaggioli/iris-globals';\n\n/**\n * Su función principal es comunicar información de manera rápida y visualmente efectiva.\n *\n * Algunos casos comunes de uso incluyen:\n * - **Notificaciones interactivas**: Proporcionar una notificación visual, como el número de mensajes no leídos, junto con la capacidad de acceder rápidamente a esos mensajes al hacer click en el badge.\n * - **Acciones rápidas**: Ofrecer accesos directos a acciones comunes o funciones importantes. Por ejemplo, un badge con botón podría representar el número de elementos en un carrito de compras, permitiendo al usuario abrir el carrito al hacer click en él.\n * - **Estado y acciones combinadas**: Mostrar el estado actual de un elemento junto con opciones de acción relacionadas. Por ejemplo, un badge con botón podría indicar que hay una actualización disponible para descargar, y al hacer click en él, el usuario puede iniciar la descarga directamente.\n */\n@Component({\n tag: 'iris-button',\n styleUrl: 'iris-button.scss',\n shadow: true,\n})\nexport class IrisButton {\n //#region Props\n\n /**\n * Texto del botón.\n */\n @Prop()\n readonly label!: string;\n\n /**\n * Indica el tipo de botón ayudando al usuario a explicar su funcionalidad.\n * Para ver más información al respecto, lea la documentación del componente.\n */\n @Prop()\n readonly color: 'primary' | 'success' | 'warning' | 'error' | 'basic' =\n getGlobalComponentConfig('IrisButton')?.color || 'primary';\n\n /**\n * Icono del botón.\n * Consulta todos los iconos disponibles en: https://fonts.google.com/icons\n */\n @Prop()\n readonly icon!: string;\n\n /**\n * Deshabilita el botón para que no pueda ser pulsado.\n */\n @Prop()\n readonly disabled: boolean = getGlobalComponentConfig('IrisButton')?.disabled || false;\n\n /**\n * Tipo de botón.\n */\n @Prop()\n readonly type: '' | 'icon' | 'fab' = getGlobalComponentConfig('IrisButton')?.type || '';\n\n /**\n * Permite mostrar una animación de carga mientras se realiza alguna acción.\n * Al activarse esta opción, el botón se deshabilita.\n */\n @Prop()\n readonly loading: boolean = getGlobalComponentConfig('IrisButton')?.loading || false;\n\n /**\n * Tamaño del botón.\n */\n @Prop()\n readonly size: 'small' | 'medium' | 'large' =\n getGlobalComponentConfig('IrisButton')?.size || 'medium';\n\n //#endregion\n\n //#region Variables privadas\n\n // Tag <button> del DOM.\n button!: HTMLButtonElement;\n\n //#endregion\n\n //#region Events\n\n /**\n * Evento del botón al ser pulsado.\n */\n @Event({ bubbles: false, composed: false }) buttonClicked: EventEmitter<Event>;\n\n /**\n * Evento del botón al ser enfocado.\n */\n @Event() buttonFocused: EventEmitter<Event>;\n\n /**\n * Evento lanzado cuando el componente está complementamente listo.\n */\n @Event() ready: EventEmitter<void>;\n\n //#endregion\n\n //#region Handlers\n\n //FIXME: Cuando loading se pone en true, también debería mantenerse disabled en true hasta que termine. Ahora se pone disabled a false antes de tiempo y rompe el funcionamiento.\n\n /**\n * Método que se ejecuta al hacer clic y emite el evento.\n * @param ev\n */\n handleClick = (ev: Event) => {\n // Evitamos que el evento burbujee.\n ev.stopPropagation();\n\n // Deshabilitamos el botón durante un segundo para que no sea pulsados repetidas veces.\n this.button.disabled = true;\n setTimeout(() => {\n if (!this.loading) {\n this.button.disabled = false;\n }\n }, 1000);\n\n // Lanzamos el evento.\n this.buttonClicked.emit(ev);\n };\n\n /**\n * Método que se ejecuta cuando se ha hecho focus en el botón.\n * @param ev\n */\n handleFocus = (ev: Event) => {\n this.buttonFocused.emit(ev);\n };\n\n //#endregion\n\n //#region Ciclos de vida\n\n componentDidLoad() {\n // Emitimos el evento de que el control se ha cargado.\n this.ready.emit();\n }\n\n //#endregion\n\n render() {\n // Validamos que todos los campos están rellenos.\n const requiredFiles: Record<string, any> = { label: this.label, icon: this.icon };\n if (!RequieredPropsUtils.check(requiredFiles)) return;\n\n return (\n <button\n class={`${this.size}`}\n color={this.color}\n type={this.type}\n onClick={this.handleClick}\n disabled={this.disabled || this.loading}\n onFocus={this.handleFocus}\n ref={(el) => (this.button = el as HTMLButtonElement)}\n title={this.label}\n >\n {\n // Comprobamos si se muestra cargando\n !this.loading ? (\n <iris-icon icon={this.icon} size={this.size}></iris-icon>\n ) : (\n <div class=\"loading\">\n <iris-loading size=\"small\" color={this.color}></iris-loading>\n </div>\n )\n }\n {\n // Solo añadimos el label para los botones normales.\n this.type == 'icon' || this.type == 'fab' ? '' : this.label\n }\n </button>\n );\n }\n}\n"]}