@moni-labs/moni-ui 0.3.1 → 0.3.2

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 (251) hide show
  1. package/custom-elements.json +5181 -1043
  2. package/dist/components/_base/moni-element.d.ts +16 -9
  3. package/dist/components/_base/moni-element.d.ts.map +1 -1
  4. package/dist/components/_base/moni-element.js +63 -9
  5. package/dist/components/index.js +2 -2
  6. package/dist/components/loading-shapes.d.ts +19 -0
  7. package/dist/components/loading-shapes.d.ts.map +1 -1
  8. package/dist/components/loading-shapes.js +19 -0
  9. package/dist/components/moni-app-bar.d.ts +72 -62
  10. package/dist/components/moni-app-bar.d.ts.map +1 -1
  11. package/dist/components/moni-app-bar.js +72 -62
  12. package/dist/components/moni-badge.d.ts +64 -65
  13. package/dist/components/moni-badge.d.ts.map +1 -1
  14. package/dist/components/moni-badge.js +64 -66
  15. package/dist/components/moni-bottom-sheet.d.ts +129 -61
  16. package/dist/components/moni-bottom-sheet.d.ts.map +1 -1
  17. package/dist/components/moni-bottom-sheet.js +217 -131
  18. package/dist/components/moni-button-group.d.ts +107 -29
  19. package/dist/components/moni-button-group.d.ts.map +1 -1
  20. package/dist/components/moni-button-group.js +107 -29
  21. package/dist/components/moni-button-segment.d.ts +53 -12
  22. package/dist/components/moni-button-segment.d.ts.map +1 -1
  23. package/dist/components/moni-button-segment.js +53 -12
  24. package/dist/components/moni-button.d.ts +116 -38
  25. package/dist/components/moni-button.d.ts.map +1 -1
  26. package/dist/components/moni-button.js +128 -38
  27. package/dist/components/moni-card.d.ts +68 -50
  28. package/dist/components/moni-card.d.ts.map +1 -1
  29. package/dist/components/moni-card.js +68 -50
  30. package/dist/components/moni-carousel.d.ts +471 -53
  31. package/dist/components/moni-carousel.d.ts.map +1 -1
  32. package/dist/components/moni-carousel.js +862 -264
  33. package/dist/components/moni-checkbox.d.ts +49 -46
  34. package/dist/components/moni-checkbox.d.ts.map +1 -1
  35. package/dist/components/moni-checkbox.js +55 -48
  36. package/dist/components/moni-chip.d.ts +100 -33
  37. package/dist/components/moni-chip.d.ts.map +1 -1
  38. package/dist/components/moni-chip.js +104 -34
  39. package/dist/components/moni-color-field.d.ts +99 -24
  40. package/dist/components/moni-color-field.d.ts.map +1 -1
  41. package/dist/components/moni-color-field.js +99 -24
  42. package/dist/components/moni-context-menu.d.ts +72 -26
  43. package/dist/components/moni-context-menu.d.ts.map +1 -1
  44. package/dist/components/moni-context-menu.js +76 -30
  45. package/dist/components/moni-dialog.d.ts +84 -59
  46. package/dist/components/moni-dialog.d.ts.map +1 -1
  47. package/dist/components/moni-dialog.js +105 -58
  48. package/dist/components/moni-divider.d.ts +39 -27
  49. package/dist/components/moni-divider.d.ts.map +1 -1
  50. package/dist/components/moni-divider.js +42 -30
  51. package/dist/components/moni-expansion.d.ts +32 -22
  52. package/dist/components/moni-expansion.d.ts.map +1 -1
  53. package/dist/components/moni-expansion.js +32 -22
  54. package/dist/components/moni-fab-menu.d.ts +61 -23
  55. package/dist/components/moni-fab-menu.d.ts.map +1 -1
  56. package/dist/components/moni-fab-menu.js +69 -31
  57. package/dist/components/moni-fab.d.ts +86 -28
  58. package/dist/components/moni-fab.d.ts.map +1 -1
  59. package/dist/components/moni-fab.js +92 -34
  60. package/dist/components/moni-file-field.d.ts +118 -30
  61. package/dist/components/moni-file-field.d.ts.map +1 -1
  62. package/dist/components/moni-file-field.js +118 -30
  63. package/dist/components/moni-icon.d.ts +40 -35
  64. package/dist/components/moni-icon.d.ts.map +1 -1
  65. package/dist/components/moni-icon.js +43 -38
  66. package/dist/components/moni-list-item.d.ts +46 -33
  67. package/dist/components/moni-list-item.d.ts.map +1 -1
  68. package/dist/components/moni-list-item.js +61 -41
  69. package/dist/components/moni-list.d.ts +30 -20
  70. package/dist/components/moni-list.d.ts.map +1 -1
  71. package/dist/components/moni-list.js +36 -21
  72. package/dist/components/moni-loading-indicator.d.ts +54 -22
  73. package/dist/components/moni-loading-indicator.d.ts.map +1 -1
  74. package/dist/components/moni-loading-indicator.js +54 -22
  75. package/dist/components/moni-menu-item.d.ts +23 -16
  76. package/dist/components/moni-menu-item.d.ts.map +1 -1
  77. package/dist/components/moni-menu-item.js +23 -16
  78. package/dist/components/moni-menu.d.ts +81 -28
  79. package/dist/components/moni-menu.d.ts.map +1 -1
  80. package/dist/components/moni-menu.js +81 -30
  81. package/dist/components/moni-morph-modal.d.ts +141 -0
  82. package/dist/components/moni-morph-modal.d.ts.map +1 -1
  83. package/dist/components/moni-morph-modal.js +295 -58
  84. package/dist/components/moni-nav-item.d.ts +59 -29
  85. package/dist/components/moni-nav-item.d.ts.map +1 -1
  86. package/dist/components/moni-nav-item.js +59 -29
  87. package/dist/components/moni-nav.d.ts +94 -35
  88. package/dist/components/moni-nav.d.ts.map +1 -1
  89. package/dist/components/moni-nav.js +94 -35
  90. package/dist/components/moni-progress.d.ts +99 -55
  91. package/dist/components/moni-progress.d.ts.map +1 -1
  92. package/dist/components/moni-progress.js +99 -55
  93. package/dist/components/moni-radio.d.ts +62 -50
  94. package/dist/components/moni-radio.d.ts.map +1 -1
  95. package/dist/components/moni-radio.js +65 -52
  96. package/dist/components/moni-ripple.d.ts +74 -59
  97. package/dist/components/moni-ripple.d.ts.map +1 -1
  98. package/dist/components/moni-ripple.js +74 -59
  99. package/dist/components/moni-segmented-button.d.ts +91 -16
  100. package/dist/components/moni-segmented-button.d.ts.map +1 -1
  101. package/dist/components/moni-segmented-button.js +94 -17
  102. package/dist/components/moni-select-option.d.ts +30 -23
  103. package/dist/components/moni-select-option.d.ts.map +1 -1
  104. package/dist/components/moni-select-option.js +30 -23
  105. package/dist/components/moni-select.d.ts +300 -35
  106. package/dist/components/moni-select.d.ts.map +1 -1
  107. package/dist/components/moni-select.js +323 -39
  108. package/dist/components/moni-side-sheet.d.ts +94 -32
  109. package/dist/components/moni-side-sheet.d.ts.map +1 -1
  110. package/dist/components/moni-side-sheet.js +94 -32
  111. package/dist/components/moni-slider.d.ts +152 -41
  112. package/dist/components/moni-slider.d.ts.map +1 -1
  113. package/dist/components/moni-slider.js +154 -42
  114. package/dist/components/moni-snackbar.d.ts +53 -43
  115. package/dist/components/moni-snackbar.d.ts.map +1 -1
  116. package/dist/components/moni-snackbar.js +53 -43
  117. package/dist/components/moni-split-button.d.ts +63 -18
  118. package/dist/components/moni-split-button.d.ts.map +1 -1
  119. package/dist/components/moni-split-button.js +63 -18
  120. package/dist/components/moni-step.d.ts +36 -24
  121. package/dist/components/moni-step.d.ts.map +1 -1
  122. package/dist/components/moni-step.js +41 -29
  123. package/dist/components/moni-stepper.d.ts +64 -27
  124. package/dist/components/moni-stepper.d.ts.map +1 -1
  125. package/dist/components/moni-stepper.js +72 -34
  126. package/dist/components/moni-switch.d.ts +57 -46
  127. package/dist/components/moni-switch.d.ts.map +1 -1
  128. package/dist/components/moni-switch.js +59 -47
  129. package/dist/components/moni-tab.d.ts +26 -18
  130. package/dist/components/moni-tab.d.ts.map +1 -1
  131. package/dist/components/moni-tab.js +29 -21
  132. package/dist/components/moni-tabs.d.ts +34 -28
  133. package/dist/components/moni-tabs.d.ts.map +1 -1
  134. package/dist/components/moni-tabs.js +34 -28
  135. package/dist/components/moni-text-field.d.ts +139 -29
  136. package/dist/components/moni-text-field.d.ts.map +1 -1
  137. package/dist/components/moni-text-field.js +157 -31
  138. package/dist/components/moni-textarea.d.ts +127 -29
  139. package/dist/components/moni-textarea.d.ts.map +1 -1
  140. package/dist/components/moni-textarea.js +131 -32
  141. package/dist/components/moni-time-picker.d.ts +114 -24
  142. package/dist/components/moni-time-picker.d.ts.map +1 -1
  143. package/dist/components/moni-time-picker.js +127 -33
  144. package/dist/components/moni-toolbar.d.ts +37 -23
  145. package/dist/components/moni-toolbar.d.ts.map +1 -1
  146. package/dist/components/moni-toolbar.js +37 -23
  147. package/dist/components/moni-tooltip.d.ts +100 -36
  148. package/dist/components/moni-tooltip.d.ts.map +1 -1
  149. package/dist/components/moni-tooltip.js +104 -40
  150. package/dist/components/moni-typography.d.ts +68 -30
  151. package/dist/components/moni-typography.d.ts.map +1 -1
  152. package/dist/components/moni-typography.js +70 -32
  153. package/dist/styles/tokens.css +7 -7
  154. package/dist/types/events.d.ts +17 -0
  155. package/dist/types/events.d.ts.map +1 -0
  156. package/dist/types/events.js +1 -0
  157. package/dist/utils/event-emitter.d.ts +13 -0
  158. package/dist/utils/event-emitter.d.ts.map +1 -0
  159. package/dist/utils/event-emitter.js +13 -0
  160. package/package.json +2 -1
  161. package/src/components/_base/moni-element.ts +73 -9
  162. package/src/components/index.ts +2 -2
  163. package/src/components/loading-shapes.ts +19 -0
  164. package/src/components/moni-app-bar.test.ts +10 -10
  165. package/src/components/moni-app-bar.ts +72 -62
  166. package/src/components/moni-badge.ts +64 -66
  167. package/src/components/moni-bottom-sheet.test.ts +39 -45
  168. package/src/components/moni-bottom-sheet.ts +222 -131
  169. package/src/components/moni-button-group.test.ts +14 -14
  170. package/src/components/moni-button-group.ts +107 -29
  171. package/src/components/moni-button-segment.ts +53 -12
  172. package/src/components/moni-button.test.ts +28 -26
  173. package/src/components/moni-button.ts +139 -39
  174. package/src/components/moni-card.test.ts +6 -6
  175. package/src/components/moni-card.ts +70 -50
  176. package/src/components/moni-carousel.test.ts +12 -12
  177. package/src/components/moni-carousel.ts +953 -290
  178. package/src/components/moni-checkbox.test.ts +7 -7
  179. package/src/components/moni-checkbox.ts +62 -48
  180. package/src/components/moni-chip.test.ts +17 -17
  181. package/src/components/moni-chip.ts +112 -34
  182. package/src/components/moni-color-field.test.ts +5 -5
  183. package/src/components/moni-color-field.ts +108 -24
  184. package/src/components/moni-context-menu.test.ts +11 -11
  185. package/src/components/moni-context-menu.ts +76 -30
  186. package/src/components/moni-dialog.ts +108 -59
  187. package/src/components/moni-divider.test.ts +4 -4
  188. package/src/components/moni-divider.ts +42 -30
  189. package/src/components/moni-expansion.ts +32 -22
  190. package/src/components/moni-fab-menu.test.ts +11 -11
  191. package/src/components/moni-fab-menu.ts +69 -31
  192. package/src/components/moni-fab.test.ts +16 -16
  193. package/src/components/moni-fab.ts +100 -34
  194. package/src/components/moni-file-field.test.ts +8 -8
  195. package/src/components/moni-file-field.ts +132 -30
  196. package/src/components/moni-icon.test.ts +11 -11
  197. package/src/components/moni-icon.ts +43 -38
  198. package/src/components/moni-list-item.test.ts +10 -10
  199. package/src/components/moni-list-item.ts +61 -41
  200. package/src/components/moni-list.ts +37 -21
  201. package/src/components/moni-loading-indicator.test.ts +3 -3
  202. package/src/components/moni-loading-indicator.ts +54 -22
  203. package/src/components/moni-menu-item.ts +23 -16
  204. package/src/components/moni-menu.test.ts +7 -7
  205. package/src/components/moni-menu.ts +87 -30
  206. package/src/components/moni-morph-modal.test.ts +18 -17
  207. package/src/components/moni-morph-modal.ts +327 -60
  208. package/src/components/moni-nav-item.ts +59 -29
  209. package/src/components/moni-nav.test.ts +11 -11
  210. package/src/components/moni-nav.ts +94 -35
  211. package/src/components/moni-progress.test.ts +9 -9
  212. package/src/components/moni-progress.ts +100 -56
  213. package/src/components/moni-radio.test.ts +8 -8
  214. package/src/components/moni-radio.ts +71 -51
  215. package/src/components/moni-ripple.ts +74 -59
  216. package/src/components/moni-segmented-button.test.ts +4 -4
  217. package/src/components/moni-segmented-button.ts +94 -17
  218. package/src/components/moni-select-option.ts +30 -23
  219. package/src/components/moni-select.test.ts +11 -11
  220. package/src/components/moni-select.ts +361 -50
  221. package/src/components/moni-side-sheet.test.ts +7 -7
  222. package/src/components/moni-side-sheet.ts +94 -32
  223. package/src/components/moni-slider.test.ts +7 -7
  224. package/src/components/moni-slider.ts +165 -42
  225. package/src/components/moni-snackbar.test.ts +8 -8
  226. package/src/components/moni-snackbar.ts +53 -43
  227. package/src/components/moni-split-button.ts +63 -18
  228. package/src/components/moni-step.test.ts +7 -7
  229. package/src/components/moni-step.ts +41 -29
  230. package/src/components/moni-stepper.test.ts +7 -7
  231. package/src/components/moni-stepper.ts +72 -34
  232. package/src/components/moni-switch.test.ts +12 -12
  233. package/src/components/moni-switch.ts +66 -47
  234. package/src/components/moni-tab.test.ts +5 -5
  235. package/src/components/moni-tab.ts +29 -21
  236. package/src/components/moni-tabs.ts +34 -28
  237. package/src/components/moni-text-field.test.ts +13 -13
  238. package/src/components/moni-text-field.ts +181 -30
  239. package/src/components/moni-textarea.test.ts +17 -17
  240. package/src/components/moni-textarea.ts +155 -31
  241. package/src/components/moni-time-picker.test.ts +5 -5
  242. package/src/components/moni-time-picker.ts +128 -33
  243. package/src/components/moni-toolbar.test.ts +8 -8
  244. package/src/components/moni-toolbar.ts +37 -23
  245. package/src/components/moni-tooltip.test.ts +15 -15
  246. package/src/components/moni-tooltip.ts +107 -40
  247. package/src/components/moni-typography.test.ts +10 -10
  248. package/src/components/moni-typography.ts +73 -32
  249. package/src/styles/tokens.css +7 -7
  250. package/src/types/events.ts +17 -0
  251. package/src/utils/event-emitter.ts +26 -0
@@ -15,90 +15,214 @@ import { customElement, property, query } from 'lit/decorators.js';
15
15
  import { ifDefined } from 'lit/directives/if-defined.js';
16
16
  import { classMap } from 'lit/directives/class-map.js';
17
17
  import { MoniElement, sharedStyles, fieldStyles } from './_base/index.js';
18
+ import { emitMoniEvent } from '../utils/event-emitter.js';
18
19
  import './moni-icon.js';
19
20
  import './moni-progress.js';
20
21
  /**
21
- * Material Design 3 Text Field component.
22
+ * Componente Material Design 3 Text Field (Campo de texto).
22
23
  *
23
- * A full-featured input field that wraps a native `<input>` inside the M3
24
- * field shell (`.field` class from `fieldStyles`). Supports floating labels,
25
- * filled and outlined variants, leading/trailing icons, helper text, and
26
- * error states.
24
+ * Un campo de entrada con todas las funciones que envuelve un `<input>` nativo dentro de la
25
+ * estructura de campo M3 (clase `.field` de `fieldStyles`). Soporta etiquetas flotantes,
26
+ * variantes llenas (filled) y contorneadas (outlined), iconos iniciales/finales (leading/trailing),
27
+ * texto de ayuda y estados de error.
27
28
  *
28
- * **M3 spec reference:** `m3-docs/components/text-fields/specs.md`
29
+ * **Referencia a la especificación M3:** `m3-docs/components/text-fields/specs.md`
29
30
  *
30
- * **Visual architecture:**
31
- * Uses `fieldStyles` for the complete CSS field shell. The field container
32
- * is a `<div class="field [modifiers]">` wrapping:
33
- * 1. Optional leading icon.
34
- * 2. Native `<input>` element.
35
- * 3. Floating `<label>` (when `label` is set).
36
- * 4. Optional trailing icon or loading spinner.
37
- * 5. `<output>` for helper/error text.
31
+ * **Arquitectura visual:**
32
+ * Utiliza `fieldStyles` para toda la estructura CSS del campo. El contenedor del campo
33
+ * es un `<div class="field [modifiers]">` que envuelve:
34
+ * 1. Icono inicial (leading) opcional.
35
+ * 2. Elemento `<input>` nativo.
36
+ * 3. `<label>` flotante (cuando se establece `label`).
37
+ * 4. Icono final (trailing) opcional o indicador de carga (spinner).
38
+ * 5. `<output>` para texto de ayuda/error.
38
39
  *
39
- * **Visual-only contract:**
40
- * This component does **not** listen to `@input` events to sync the `value`
41
- * attribute back from the underlying `<input>`. Consumers must either:
42
- * - Submit the native form (the `<input name>` participates in form submission).
43
- * - Listen to `change` or `input` events via standard DOM event handling.
44
- * - Use a framework binding (e.g. `bind:value` in Svelte, `v-model` in Vue).
40
+ * **Sincronización de eventos:**
41
+ * Emite `moni-input` en cada tipeo y `moni-change` al consolidar el valor (blur/enter).
42
+ * El valor interno del componente (`this.value`) se mantiene sincronizado automáticamente.
45
43
  *
46
44
  * @example
47
45
  * ```html
48
46
  * <moni-text-field
49
- * label="Email address"
47
+ * label="Dirección de correo"
50
48
  * type="email"
51
49
  * name="email"
52
50
  * icon="mail"
53
51
  * variant="outlined"
54
- * helper="We'll never share your email."
52
+ * helper="Nunca compartiremos tu correo."
55
53
  * ></moni-text-field>
56
54
  *
57
55
  * <moni-text-field
58
- * label="Amount"
56
+ * label="Monto"
59
57
  * type="number"
60
58
  * prefix="$"
61
59
  * error
62
- * error-text="Value must be positive"
60
+ * error-text="El valor debe ser positivo"
63
61
  * ></moni-text-field>
64
62
  * ```
65
63
  *
66
- * @csspart field - The outer `.field` div container.
67
- * @csspart input - The native `<input>` element.
68
- * @csspart label - The floating `<label>` element.
69
- * @csspart helper - The helper `<output>` element.
70
- * @csspart error-output - The error `<output>` element.
64
+ * @csspart field - El contenedor div `.field` exterior.
65
+ * @csspart input - El elemento `<input>` nativo.
66
+ * @csspart label - El elemento `<label>` flotante.
67
+ * @csspart helper - El elemento `<output>` de ayuda.
68
+ * @csspart error-output - El elemento `<output>` de error.
71
69
  */
72
70
  let MoniTextField = class MoniTextField extends MoniElement {
71
+ static { this.formAssociated = true; }
73
72
  constructor() {
74
- super(...arguments);
73
+ super();
74
+ /**
75
+ * El nombre del input, enviado con los datos del formulario.
76
+ * @type {string}
77
+ */
75
78
  this.name = '';
79
+ /**
80
+ * El texto de la etiqueta flotante.
81
+ * @type {string}
82
+ */
76
83
  this.label = '';
84
+ /**
85
+ * Variante visual del campo de texto.
86
+ * @type {'filled' | 'outlined'}
87
+ * @default 'filled'
88
+ */
77
89
  this.variant = 'filled';
90
+ /**
91
+ * Define las dimensiones del campo de texto.
92
+ * @type {'small' | 'medium' | 'large' | 'extra'}
93
+ * @default 'medium'
94
+ */
78
95
  this.size = 'medium';
96
+ /**
97
+ * Forma del radio del borde (border-radius) del campo.
98
+ * @type {'round' | 'square' | 'no-round'}
99
+ * @default 'no-round'
100
+ */
79
101
  this.shape = 'no-round';
102
+ /**
103
+ * El tipo de input HTML nativo.
104
+ * @type {'text' | 'password' | 'email' | 'number' | 'tel' | 'url' | 'search'}
105
+ * @default 'text'
106
+ */
80
107
  this.type = 'text';
108
+ /**
109
+ * Nombre del icono inicial (leading) (Material Symbols).
110
+ * @type {string}
111
+ */
81
112
  this.icon = '';
113
+ /**
114
+ * Nombre del icono final (trailing) (Material Symbols).
115
+ * @type {string}
116
+ */
82
117
  this.trailingIcon = '';
118
+ /**
119
+ * Prefijo de texto corto mostrado antes del valor del input.
120
+ * @type {string}
121
+ */
83
122
  this.prefix = '';
123
+ /**
124
+ * Sufijo de texto corto mostrado después del valor del input.
125
+ * @type {string}
126
+ */
84
127
  this.suffix = '';
128
+ /**
129
+ * Texto de ayuda mostrado debajo del campo.
130
+ * @type {string}
131
+ */
85
132
  this.helper = '';
133
+ /**
134
+ * Texto de error mostrado debajo del campo cuando `error` es true.
135
+ * Sobrescribe el texto de ayuda.
136
+ * @type {string}
137
+ */
86
138
  this.errorText = '';
139
+ /**
140
+ * Si es true, establece el campo en un estado de error.
141
+ * @type {boolean}
142
+ */
87
143
  this.error = false;
144
+ /**
145
+ * Si es true, muestra un indicador de carga (progreso lineal/circular) al final.
146
+ * @type {boolean}
147
+ */
88
148
  this.loading = false;
149
+ /**
150
+ * Deshabilita el campo de texto.
151
+ * @type {boolean}
152
+ */
89
153
  this.disabled = false;
154
+ /**
155
+ * El valor actual del input.
156
+ * @type {string}
157
+ */
90
158
  this.value = '';
159
+ /**
160
+ * Texto de marcador de posición (placeholder) mostrado cuando el input está vacío y la etiqueta es flotante.
161
+ * @type {string}
162
+ */
91
163
  this.placeholder = '';
164
+ this._internals = this.attachInternals();
92
165
  }
166
+ /**
167
+ * Sincroniza imperativamente las propiedades DOM del `<input>` nativo después de cada actualización reactiva.
168
+ *
169
+ * Las vinculaciones `?value` y `?disabled` de Lit establecen *atributos* HTML, no *propiedades* DOM.
170
+ * Para un `<input>`, el atributo `value` solo establece el valor *inicial*; la propiedad DOM
171
+ * `input.value` refleja el valor actual tecleado por el usuario. Después de una actualización reactiva que
172
+ * cambia `this.value` (ej. reinicio programático), debemos escribir directamente a la propiedad
173
+ * DOM para sobrescribir lo que el usuario ha tecleado. Esto también es crítico para los consumidores
174
+ * de React y Vue que mutan la propiedad del Custom Element directamente, omitiendo el flujo
175
+ * de atributos de Lit.
176
+ *
177
+ * @param changed - Mapa de los nombres de propiedades a sus valores anteriores que causaron esta actualización.
178
+ */
93
179
  updated(changed) {
94
180
  if (this._input) {
95
- if (changed.has('value'))
181
+ if (changed.has('value')) {
96
182
  this._input.value = this.value;
183
+ this._internals?.setFormValue?.(this.value);
184
+ }
97
185
  if (changed.has('disabled'))
98
186
  this._input.disabled = this.disabled;
99
187
  }
100
188
  }
189
+ _handleInput(e) {
190
+ const target = e.target;
191
+ this.value = target.value;
192
+ emitMoniEvent(this, 'moni-input', {
193
+ detail: { value: this.value, originalEvent: e }
194
+ });
195
+ }
196
+ _handleChange(e) {
197
+ const target = e.target;
198
+ this.value = target.value;
199
+ emitMoniEvent(this, 'moni-change', {
200
+ detail: { value: this.value, originalEvent: e }
201
+ });
202
+ }
101
203
  static { this.styles = [sharedStyles, fieldStyles]; }
204
+ /**
205
+ * Renderiza el campo de texto con animación de etiqueta flotante, iconos iniciales/finales, y texto de ayuda.
206
+ *
207
+ * **Composición de `fieldClasses`:**
208
+ * - `field` — siempre presente; diseño base del campo.
209
+ * - `label` — habilita el comportamiento de la etiqueta flotante vía CSS.
210
+ * - `fill` / `border` — variante filled vs outlined.
211
+ * - `small` / `large` / `extra` — modificador de tamaño.
212
+ * - `prefix` — desplaza la etiqueta cuando hay un icono inicial (leading) presente.
213
+ * - `suffix` — reserva espacio final (trailing) para el icono/texto de sufijo.
214
+ * - `invalid` — aplica colores de error cuando `error=true` o falla la validación nativa.
215
+ *
216
+ * **Flotación de la etiqueta (Label float):**
217
+ * `isActive` es true cuando `value` no está vacío o se establece un `placeholder`.
218
+ * Los selectores CSS `.field.label input:focus ~ label`, `.field.label.active label`
219
+ * flotan la etiqueta a la parte superior del borde del campo. Este componente
220
+ * establece `isActive` para evitar que la etiqueta colapse cuando un valor está preestablecido.
221
+ *
222
+ * **Zonas inicial / final (Leading / trailing):**
223
+ * `hasLeading` y `hasTrailing` añaden condicionalmente las clases CSS `prefix`/`suffix`
224
+ * y renderizan el icono o los elementos de texto de prefijo/sufijo.
225
+ */
102
226
  render() {
103
227
  const hasLeading = Boolean(this.icon) || Boolean(this.prefix);
104
228
  const hasTrailing = Boolean(this.trailingIcon) || Boolean(this.suffix);
@@ -155,6 +279,8 @@ let MoniTextField = class MoniTextField extends MoniElement {
155
279
  .value=${this.value}
156
280
  name=${ifDefined(this.name || undefined)}
157
281
  class=${isActive ? 'active' : ''}
282
+ @input=${this._handleInput}
283
+ @change=${this._handleChange}
158
284
  />
159
285
  ${this.label
160
286
  ? html `<label
@@ -8,74 +8,172 @@ import { MoniElement } from './_base/index.js';
8
8
  import './moni-icon.js';
9
9
  import './moni-progress.js';
10
10
  /**
11
- * Material Design 3 Textarea component.
11
+ * Componente Material Design 3 Textarea (Área de texto).
12
12
  *
13
- * A multi-line text input field designed for collecting longer amounts of text,
14
- * such as comments, descriptions, or messages.
13
+ * Un campo de entrada de texto multilínea diseñado para recolectar cantidades mayores de texto,
14
+ * como comentarios, descripciones o mensajes.
15
15
  *
16
- * **M3 spec reference:** `m3-docs/components/text-fields/specs.md`
16
+ * **Referencia a la especificación M3:** `m3-docs/components/text-fields/specs.md`
17
17
  *
18
- * **Visual architecture:**
19
- * It shares the exact same `.field` shell and styling engine as
20
- * `<moni-text-field>`, but internally renders a native `<textarea>` instead
21
- * of an `<input>`. This ensures visual consistency across all form elements
22
- * regarding floating labels, helper text, error states, and icons.
18
+ * **Arquitectura visual:**
19
+ * Comparte exactamente el mismo contenedor `.field` y motor de estilos que
20
+ * `<moni-text-field>`, pero internamente renderiza un `<textarea>` nativo en lugar
21
+ * de un `<input>`. Esto asegura la consistencia visual en todos los elementos del formulario
22
+ * en cuanto a etiquetas flotantes, texto de ayuda, estados de error e iconos.
23
23
  *
24
- * **Character Counter:**
25
- * If the `maxlength` attribute is set, the textarea automatically displays
26
- * a character counter (`{current length} / {maxlength}`) positioned at the
27
- * trailing edge of the supporting text area (bottom right). This can be
28
- * suppressed by setting the `no-counter` attribute.
24
+ * **Contador de caracteres:**
25
+ * Si se establece el atributo `maxlength`, el área de texto muestra automáticamente
26
+ * un contador de caracteres (`{longitud actual} / {maxlength}`) ubicado en el
27
+ * borde final (trailing) del área de texto de soporte (abajo a la derecha). Esto puede
28
+ * suprimirse estableciendo el atributo `no-counter`.
29
29
  *
30
- * **State management:**
31
- * This component is purely visual and presentational. It reflects attributes
32
- * down to the native textarea, but it does NOT attach internal `@input` or
33
- * `@change` listeners. Consumers should attach standard DOM listeners directly
34
- * to this element to capture user input, just as they would with a native
35
- * textarea.
30
+ * **Gestión del estado:**
31
+ * Este componente es puramente visual y representacional. Refleja los atributos
32
+ * hacia el textarea nativo, pero NO adjunta listeners internos para `@input` o
33
+ * `@change`. Los consumidores deben adjuntar listeners estándar del DOM directamente
34
+ * a este elemento para capturar la entrada del usuario, tal como lo harían con un
35
+ * textarea nativo.
36
36
  *
37
37
  * @example
38
38
  * ```html
39
- * <!-- Standard filled textarea -->
40
- * <moni-textarea label="Description" rows="4"></moni-textarea>
39
+ * <!-- Textarea llenado (filled) estándar -->
40
+ * <moni-textarea label="Descripción" rows="4"></moni-textarea>
41
41
  *
42
- * <!-- Outlined textarea with character counter -->
42
+ * <!-- Textarea contorneado (outlined) con contador de caracteres -->
43
43
  * <moni-textarea
44
44
  * variant="outlined"
45
- * label="Bio"
45
+ * label="Biografía"
46
46
  * maxlength="160"
47
47
  * ></moni-textarea>
48
48
  * ```
49
49
  *
50
- * @csspart field - The outer `.field` div container.
51
- * @csspart input - The native `<textarea>` element.
52
- * @csspart label - The floating `<label>` element.
53
- * @csspart helper - The helper/error text area.
54
- * @csspart counter - The character counter element.
50
+ * @csspart field - El contenedor div `.field` exterior.
51
+ * @csspart input - El elemento `<textarea>` nativo.
52
+ * @csspart label - El elemento `<label>` flotante.
53
+ * @csspart helper - El área de texto de ayuda/error.
54
+ * @csspart counter - El elemento contador de caracteres.
55
55
  */
56
56
  export declare class MoniTextarea extends MoniElement {
57
+ static formAssociated: boolean;
58
+ private _internals;
59
+ constructor();
60
+ /**
61
+ * El nombre del textarea, enviado con los datos del formulario.
62
+ * @type {string}
63
+ */
57
64
  name: string;
65
+ /**
66
+ * El texto de la etiqueta flotante.
67
+ * @type {string}
68
+ */
58
69
  label: string;
70
+ /**
71
+ * Variante visual del área de texto.
72
+ * @type {'filled' | 'outlined'}
73
+ * @default 'filled'
74
+ */
59
75
  variant: 'filled' | 'outlined';
76
+ /**
77
+ * Define las dimensiones del área de texto.
78
+ * @type {'small' | 'medium' | 'large' | 'extra'}
79
+ * @default 'medium'
80
+ */
60
81
  size: 'small' | 'medium' | 'large' | 'extra';
82
+ /**
83
+ * Forma del radio del borde (border-radius) del campo.
84
+ * @type {'round' | 'square' | 'no-round'}
85
+ * @default 'no-round'
86
+ */
61
87
  shape: 'round' | 'square' | 'no-round';
88
+ /**
89
+ * Nombre del icono inicial (leading) (Material Symbols).
90
+ * @type {string}
91
+ */
62
92
  icon: string;
93
+ /**
94
+ * Nombre del icono final (trailing) (Material Symbols).
95
+ * @type {string}
96
+ */
63
97
  trailingIcon: string;
98
+ /**
99
+ * Prefijo de texto corto mostrado antes del valor del input.
100
+ * @type {string}
101
+ */
64
102
  prefix: string;
103
+ /**
104
+ * Sufijo de texto corto mostrado después del valor del input.
105
+ * @type {string}
106
+ */
65
107
  suffix: string;
108
+ /**
109
+ * Número por defecto de líneas de texto visibles.
110
+ * @type {number}
111
+ * @default 3
112
+ */
66
113
  rows: number;
114
+ /**
115
+ * Número máximo de caracteres permitidos en el área de texto.
116
+ * También habilita la visualización del contador de caracteres a menos que `noCounter` sea true.
117
+ * @type {number | null}
118
+ */
67
119
  maxlength: number | null;
120
+ /**
121
+ * Oculta la visualización del contador de caracteres cuando se establece `maxlength`.
122
+ * @type {boolean}
123
+ */
68
124
  noCounter: boolean;
125
+ /**
126
+ * Si es true, muestra un indicador de carga (progreso circular) al final.
127
+ * @type {boolean}
128
+ */
69
129
  loading: boolean;
130
+ /**
131
+ * Deshabilita el área de texto.
132
+ * @type {boolean}
133
+ */
70
134
  disabled: boolean;
135
+ /**
136
+ * Texto de ayuda mostrado debajo del campo.
137
+ * @type {string}
138
+ */
71
139
  helper: string;
140
+ /**
141
+ * Texto de error mostrado debajo del campo cuando `error` es true.
142
+ * Sobrescribe el texto de ayuda.
143
+ * @type {string}
144
+ */
72
145
  errorText: string;
146
+ /**
147
+ * Si es true, establece el campo en un estado de error.
148
+ * @type {boolean}
149
+ */
73
150
  error: boolean;
151
+ /**
152
+ * El valor actual del área de texto.
153
+ * @type {string}
154
+ */
74
155
  value: string;
156
+ /**
157
+ * Texto de marcador de posición (placeholder) mostrado cuando el textarea está vacío y la etiqueta es flotante.
158
+ * @type {string}
159
+ */
75
160
  placeholder: string;
76
161
  private _input;
77
162
  updated(changed: Map<string, unknown>): void;
78
163
  static styles: import("lit").CSSResult[];
164
+ /**
165
+ * Renderiza el campo del área de texto con etiqueta, iconos de prefijo/sufijo y contador de caracteres.
166
+ *
167
+ * **Composición de `fieldClasses`:**
168
+ * Sigue la convención de nomenclatura field-styles. `prefix` se añade
169
+ * cuando el texto de `icon` o `prefix` está presente (desplaza el inicio en línea de la etiqueta).
170
+ * `suffix` se añade cuando `trailingIcon`, el texto `suffix` o `loading` es true.
171
+ *
172
+ * **Contador de caracteres:**
173
+ * `showCounter` es true cuando `maxlength > 0` y `noCounter` no está configurado.
174
+ * El contador muestra `${this.value.length} / ${this.maxlength}` y puede volverse rojo
175
+ * (vía CSS `invalid`) dependiendo de la validación.
176
+ */
79
177
  render(): import("lit").TemplateResult<1>;
80
178
  }
81
179
  declare global {
@@ -1 +1 @@
1
- {"version":3,"file":"moni-textarea.d.ts","sourceRoot":"","sources":["../../src/components/moni-textarea.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,WAAW,EAA6B,MAAM,kBAAkB,CAAC;AAC1E,OAAO,gBAAgB,CAAC;AACxB,OAAO,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,qBACa,YAAa,SAAQ,WAAW;IACf,IAAI,SAAM;IACV,KAAK,SAAM;IACX,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAY;IAEvE,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAY;IAExD,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAc;IACvB,IAAI,SAAM;IACkB,YAAY,SAAM;IAC9C,MAAM,SAAM;IACZ,MAAM,SAAM;IACE,IAAI,SAAK;IACT,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE3E,SAAS,UAAS;IAC0B,OAAO,UAAS;IAChB,QAAQ,UAAS;IAChC,MAAM,SAAM;IACa,SAAS,SAAM;IACzB,KAAK,UAAS;IAC7B,KAAK,SAAM;IACX,WAAW,SAAM;IAE3B,OAAO,CAAC,MAAM,CAAuB;IAE/C,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAU9C,OAAgB,MAAM,4BAA+B;IAE5C,MAAM;CAkGf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,YAAY,CAAC;KAC9B;CACD;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"moni-textarea.d.ts","sourceRoot":"","sources":["../../src/components/moni-textarea.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,WAAW,EAA6B,MAAM,kBAAkB,CAAC;AAC1E,OAAO,gBAAgB,CAAC;AACxB,OAAO,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,qBACa,YAAa,SAAQ,WAAW;IAC5C,MAAM,CAAC,cAAc,UAAQ;IAC7B,OAAO,CAAC,UAAU,CAAmB;;IAOrC;;;OAGG;IAC0B,IAAI,SAAM;IAEvC;;;OAGG;IAC0B,KAAK,SAAM;IAExC;;;;OAIG;IAC0B,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAY;IAEvE;;;;OAIG;IAEH,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAY;IAExD;;;;OAIG;IAEH,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAc;IAEpD;;;OAGG;IAC0B,IAAI,SAAM;IAEvC;;;OAGG;IACsD,YAAY,SAAM;IAE3E;;;OAGG;IAC0B,MAAM,SAAM;IAEzC;;;OAGG;IAC0B,MAAM,SAAM;IAEzC;;;;OAIG;IACwC,IAAI,SAAK;IAEpD;;;;OAIG;IACwC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE3E;;;OAGG;IAEH,SAAS,UAAS;IAElB;;;OAGG;IACyC,OAAO,UAAS;IAE5D;;;OAGG;IACyC,QAAQ,UAAS;IAE7D;;;OAGG;IAC0B,MAAM,SAAM;IAEzC;;;;OAIG;IACmD,SAAS,SAAM;IAErE;;;OAGG;IACyC,KAAK,UAAS;IAE1D;;;OAGG;IAC0B,KAAK,SAAM;IAExC;;;OAGG;IAC0B,WAAW,SAAM;IAE3B,OAAO,CAAC,MAAM,CAAuB;IAE/C,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAa9C,OAAgB,MAAM,4BAA+B;IAErD;;;;;;;;;;;;OAYG;IACM,MAAM;CAkGf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,YAAY,CAAC;KAC9B;CACD;AAED,eAAe,YAAY,CAAC"}