@moni-labs/moni-ui 0.3.0 → 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 +5230 -1007
  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 +484 -53
  31. package/dist/components/moni-carousel.d.ts.map +1 -1
  32. package/dist/components/moni-carousel.js +1024 -245
  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 +1129 -269
  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
@@ -16,74 +16,123 @@ import { MoniElement, sharedStyles } from './_base/index.js';
16
16
  import './moni-icon.js';
17
17
  import './moni-progress.js';
18
18
  /**
19
- * Material Design 3 Chip component.
19
+ * Componente Material Design 3 Chip.
20
20
  *
21
- * Chips are compact, interactive elements that represent actions, filters,
22
- * attributes, or user inputs. They are visual-only shellsthe consumer
23
- * owns all state management (selection, removal, active filter state).
21
+ * Los chips (fichas) son elementos compactos e interactivos que representan acciones, filtros,
22
+ * atributos o entradas de usuario. Son contenedores solo visualesel consumidor
23
+ * es dueño de todo el manejo del estado (selección, eliminación, estado de filtro activo).
24
24
  *
25
- * **M3 spec reference:** `m3-docs/components/chips/specs.md`
25
+ * **Referencia de la especificación M3:** `m3-docs/components/chips/specs.md`
26
26
  *
27
- * **Variants:**
28
- * - `assist` (default) — Smart or suggested actions. Uses `var(--outline)` border
29
- * to ensure 3:1 contrast per the M3 accessibility spec. Alias: `outlined`.
30
- * - `filter` — Filters for a content collection. Shows a leading checkmark when
31
- * `selected`. Alias: `fill`.
32
- * - `input` — Represents discrete user input (tags, tokens). Adds a trailing
33
- * remove icon when `removable`.
34
- * - `suggestion` — Product-generated suggestions. Outlined, no icons.
27
+ * **Variantes:**
28
+ * - `assist` (por defecto) — Acciones inteligentes o sugeridas. Usa borde `var(--outline)`
29
+ * para asegurar un contraste de 3:1 según la especificación de accesibilidad de M3. Alias: `outlined`.
30
+ * - `filter` — Filtros para una colección de contenido. Muestra una marca de verificación al principio cuando
31
+ * está `selected`. Alias: `fill`.
32
+ * - `input` — Representa una entrada de usuario discreta (etiquetas, tokens). Añade un icono de
33
+ * eliminación al final cuando es `removable`.
34
+ * - `suggestion` — Sugerencias generadas por el producto. Con contorno, sin iconos.
35
35
  *
36
- * **M3 measurements:**
37
- * - Default height: 32dp (`small` size = M3 spec baseline).
38
- * - Corner radius: 8dp.
39
- * - Icon size: 18dp.
40
- * - `medium` and `large` sizes are Moni extensions with larger touch targets.
36
+ * **Medidas M3:**
37
+ * - Altura por defecto: 32dp (tamaño `small` = línea base de la especificación M3).
38
+ * - Radio de esquina: 8dp.
39
+ * - Tamaño de icono: 18dp.
40
+ * - Los tamaños `medium` y `large` son extensiones de Moni con áreas táctiles más grandes.
41
41
  *
42
- * **Accessibility:**
43
- * `assist` and `suggestion` chips use `var(--outline)` for their stroke to
44
- * guarantee 3:1 contrast against the surface background at rest.
45
- * `filter` and `input` use `outline-variant` at rest but achieve contrast
46
- * through the `secondary-container` fill when selected.
42
+ * **Accesibilidad:**
43
+ * Los chips `assist` y `suggestion` usan `var(--outline)` para su trazo para
44
+ * garantizar un contraste de 3:1 contra el fondo de la superficie en reposo.
45
+ * `filter` e `input` usan `outline-variant` en reposo pero logran contraste
46
+ * a través del relleno `secondary-container` cuando se seleccionan.
47
47
  *
48
- * @fires remove - Bubbles and is composed. Fired when the trailing remove
49
- * icon is clicked on an `input` chip with `removable`.
48
+ * @fires remove - Burbujea y está compuesto. Se dispara cuando el icono de eliminación
49
+ * final se hace clic en un chip `input` con `removable`.
50
50
  *
51
51
  * @example
52
52
  * ```html
53
- * <!-- Filter chip with selected state -->
53
+ * <!-- Chip de filtro con estado seleccionado -->
54
54
  * <moni-chip variant="filter" selected>Technology</moni-chip>
55
55
  *
56
- * <!-- Input chip (tag/token) -->
56
+ * <!-- Chip de entrada (etiqueta/token) -->
57
57
  * <moni-chip variant="input" removable icon="label">TypeScript</moni-chip>
58
58
  *
59
- * <!-- Assist chip with icon -->
59
+ * <!-- Chip de asistencia con icono -->
60
60
  * <moni-chip icon="directions_car">Get directions</moni-chip>
61
61
  * ```
62
62
  *
63
- * @slot default - The chip label text.
64
- * @slot icon - Override for the leading icon (alternative to the `icon` attribute).
63
+ * @slot default - El texto de la etiqueta del chip.
64
+ * @slot icon - Anula el icono inicial (alternativa al atributo `icon`).
65
65
  *
66
- * @csspart chip - The inner `<button>` element.
67
- * @csspart label - The label `<span>` element.
66
+ * @csspart chip - El elemento interno `<button>`.
67
+ * @csspart label - El elemento `<span>` de la etiqueta.
68
68
  */
69
69
  let MoniChip = class MoniChip extends MoniElement {
70
70
  constructor() {
71
71
  super(...arguments);
72
+ /**
73
+ * Variante visual del chip.
74
+ * @type {'assist' | 'filter' | 'input' | 'suggestion' | 'outlined' | 'fill'}
75
+ * @default 'assist'
76
+ */
72
77
  this.variant = 'assist';
78
+ /**
79
+ * Define las dimensiones del chip.
80
+ * @type {'small' | 'medium' | 'large'}
81
+ * @default 'small'
82
+ */
73
83
  this.size = 'small';
84
+ /**
85
+ * Forma del radio del borde del chip.
86
+ * @type {'round' | 'no-round' | 'square' | 'circle' | 'left-round' | 'right-round' | 'top-round' | 'bottom-round'}
87
+ * @default 'round'
88
+ */
74
89
  this.shape = 'round';
90
+ /**
91
+ * Si es true, marca el chip como seleccionado (útil para chips de filtro).
92
+ * @type {boolean}
93
+ */
75
94
  this.selected = false;
95
+ /**
96
+ * Si es true, muestra un icono de cierre al final para permitir la eliminación.
97
+ * @type {boolean}
98
+ */
76
99
  this.removable = false;
100
+ /**
101
+ * Deshabilita el chip.
102
+ * @type {boolean}
103
+ */
77
104
  this.disabled = false;
105
+ /**
106
+ * Si es true, muestra un indicador de carga dentro del chip.
107
+ * @type {boolean}
108
+ */
78
109
  this.loading = false;
110
+ /**
111
+ * Nombre del icono inicial (Material Symbols).
112
+ * @type {string}
113
+ */
79
114
  this.icon = '';
80
115
  this._hasSlottedIcon = false;
81
116
  }
117
+ /**
118
+ * Manejador del slot interno de icono (Slot Change).
119
+ * Determina si el desarrollador proporcionó un icono dinámicamente vía Light DOM
120
+ * (`<moni-icon slot="icon">`), permitiendo que el componente ajuste
121
+ * sus márgenes internos (`padding`) y espaciados dinámicamente.
122
+ */
82
123
  _handleSlotChange(e) {
83
124
  const slot = e.target;
84
125
  this._hasSlottedIcon = slot.assignedNodes({ flatten: true }).length > 0;
85
126
  }
86
- /** Normalize legacy variant names to M3 spec. */
127
+ /**
128
+ * Manejador de clics en el icono de remover.
129
+ * Detiene la propagación para no disparar el clic del chip y emite un evento custom 'remove'.
130
+ */
131
+ _handleRemoveClick(e) {
132
+ e.stopPropagation();
133
+ this.dispatchEvent(new CustomEvent('remove', { bubbles: true, composed: true }));
134
+ }
135
+ /** Normaliza los nombres de variantes heredadas a la especificación M3. */
87
136
  get _variant() {
88
137
  if (this.variant === 'outlined')
89
138
  return 'assist';
@@ -273,6 +322,27 @@ let MoniChip = class MoniChip extends MoniElement {
273
322
  }
274
323
  `
275
324
  ]; }
325
+ /**
326
+ * Renderiza el elemento `<button>` del chip con su lista de clases calculada.
327
+ *
328
+ * **Normalización de variantes:**
329
+ * `_variant` mapea nombres de alias heredados (`'outlined'` → `'assist'`, `'fill'` → `'filter'`)
330
+ * a nombres de variantes canónicas de M3 antes de inyectarlos como clases CSS.
331
+ *
332
+ * **Ruta rápida de carga:**
333
+ * Cuando `loading=true`, se devuelve temprano un botón mínimo con solo un indicador de carga
334
+ * (sin slot de icono, sin etiqueta, sin botón de eliminación) con `aria-busy="true"`.
335
+ *
336
+ * **Lógica del botón de eliminación:**
337
+ * `showRemove` es `true` cuando:
338
+ * - `variant='input'` (Especificación M3: los chips de entrada siempre tienen un icono de cierre al final), o
339
+ * - `removable=true` se establece explícitamente.
340
+ *
341
+ * **Resolución de icono:**
342
+ * Si se establece el atributo `icon`, se renderiza un `<moni-icon>`. De lo contrario, se usa el
343
+ * slot nombrado `icon`, con `_hasSlottedIcon` rastreando si se proyectó contenido en el slot
344
+ * (usado para añadir condicionalmente los ajustes de relleno `has-icon`).
345
+ */
276
346
  render() {
277
347
  const variant = this._variant;
278
348
  const hasIcon = Boolean(this.icon) || this._hasSlottedIcon;
@@ -316,7 +386,7 @@ let MoniChip = class MoniChip extends MoniElement {
316
386
  @slotchange=${this._handleSlotChange}
317
387
  ></slot>`;
318
388
  const removeEl = showRemove
319
- ? html `<span class="remove" part="remove" aria-hidden="true"
389
+ ? html `<span class="remove" part="remove" aria-hidden="true" @click=${this._handleRemoveClick}
320
390
  ><moni-icon name="close"></moni-icon
321
391
  ></span>`
322
392
  : nothing;
@@ -6,60 +6,135 @@
6
6
  */
7
7
  import { MoniElement } from './_base/index.js';
8
8
  /**
9
- * Material Design 3 Color Field component.
9
+ * Componente Material Design 3 Color Field (Campo de Color).
10
10
  *
11
- * A specialized text field for color input that combines a native
12
- * `<input type="color">` with a read-only text display of the selected
13
- * hex value, wrapped in the standard M3 field shell.
11
+ * Un campo de texto especializado para la entrada de color que combina un
12
+ * `<input type="color">` nativo con una visualización de texto de solo lectura del
13
+ * valor hexadecimal seleccionado, envuelto en la carcasa estándar de campo M3.
14
14
  *
15
- * **Visual architecture:**
16
- * Extends the field styling pattern used by `<moni-text-field>`. The
17
- * leading icon slot is replaced by a circular color swatch (`.swatch`)
18
- * which is absolutely positioned over an invisible native color input.
19
- * Clicking the swatch opens the system color picker. The text input portion
20
- * displays the selected hex code and is strictly `readOnly`.
15
+ * **Arquitectura visual:**
16
+ * Extiende el patrón de estilo de campo usado por `<moni-text-field>`. El
17
+ * slot de icono inicial se reemplaza por una muestra de color circular (`.swatch`)
18
+ * que se posiciona absolutamente sobre una entrada de color nativa invisible.
19
+ * Al hacer clic en la muestra se abre el selector de color del sistema. La parte de entrada de texto
20
+ * muestra el código hexadecimal seleccionado y es estrictamente `readOnly`.
21
21
  *
22
- * **State syncing:**
23
- * The component listens to the native `change` event on the color input,
24
- * updates the `value` property, and re-dispatches a composed `'change'` event.
25
- * It does not listen to `input` (continuous drag in the color picker) to avoid
26
- * excessive event firing, but consumers can attach their own `input` listeners
27
- * directly to the element if live preview is needed.
22
+ * **Sincronización de estado:**
23
+ * El componente escucha el evento nativo `change` en la entrada de color,
24
+ * actualiza la propiedad `value`, y re-despacha un evento compuesto `'change'`.
25
+ * No escucha `input` (arrastre continuo en el selector de color) para evitar
26
+ * el disparo excesivo de eventos, pero los consumidores pueden adjuntar sus propios
27
+ * escuchas de `input` directamente al elemento si se necesita una vista previa en vivo.
28
28
  *
29
- * @fires change - Bubbles and is composed. Fired when the color picker closes
30
- * and the value is committed. Read `element.value`.
29
+ * @fires change - Burbujea y está compuesto. Se dispara cuando el selector de color se cierra
30
+ * y el valor se confirma. Leer `element.value`.
31
31
  *
32
32
  * @example
33
33
  * ```html
34
34
  * <moni-color-field
35
- * label="Theme Color"
35
+ * label="Color del Tema"
36
36
  * name="primaryColor"
37
37
  * value="#6750a4"
38
38
  * variant="outlined"
39
39
  * ></moni-color-field>
40
40
  * ```
41
41
  *
42
- * @csspart field - The outer `.field` div container.
43
- * @csspart swatch - The circular color preview element.
44
- * @csspart input-color - The native, visually hidden `<input type="color">`.
45
- * @csspart input-text - The native `<input type="text">` displaying the hex code.
46
- * @csspart label - The floating `<label>` element.
42
+ * @csspart field - El contenedor div exterior `.field`.
43
+ * @csspart swatch - El elemento de vista previa de color circular.
44
+ * @csspart input-color - El `<input type="color">` nativo, visualmente oculto.
45
+ * @csspart input-text - El `<input type="text">` nativo que muestra el código hexadecimal.
46
+ * @csspart label - El elemento flotante `<label>`.
47
47
  */
48
48
  export declare class MoniColorField extends MoniElement {
49
+ /**
50
+ * El nombre del input, enviado con los datos del formulario.
51
+ * @type {string}
52
+ */
49
53
  name: string;
54
+ /**
55
+ * El texto de la etiqueta flotante.
56
+ * @type {string}
57
+ */
50
58
  label: string;
59
+ /**
60
+ * Variante visual del campo de texto.
61
+ * @type {'filled' | 'outlined'}
62
+ * @default 'outlined'
63
+ */
51
64
  variant: 'filled' | 'outlined';
65
+ /**
66
+ * Define las dimensiones del campo de texto.
67
+ * @type {'small' | 'medium' | 'large' | 'extra'}
68
+ * @default 'medium'
69
+ */
52
70
  size: 'small' | 'medium' | 'large' | 'extra';
71
+ /**
72
+ * Forma del radio del borde del campo.
73
+ * @type {'round' | 'square' | 'no-round'}
74
+ * @default 'no-round'
75
+ */
53
76
  shape: 'round' | 'square' | 'no-round';
77
+ /**
78
+ * Deshabilita el campo de color.
79
+ * @type {boolean}
80
+ */
54
81
  disabled: boolean;
82
+ /**
83
+ * Texto de ayuda mostrado debajo del campo.
84
+ * @type {string}
85
+ */
55
86
  helper: string;
87
+ /**
88
+ * Texto de error mostrado debajo del campo cuando `error` es true.
89
+ * Sobrescribe el texto de ayuda.
90
+ * @type {string}
91
+ */
56
92
  errorText: string;
93
+ /**
94
+ * Si es true, establece el campo en un estado de error.
95
+ * @type {boolean}
96
+ */
57
97
  error: boolean;
98
+ /**
99
+ * El valor actual del color hexadecimal.
100
+ * @type {string}
101
+ * @default '#6750a4'
102
+ */
58
103
  value: string;
59
104
  private _colorInput;
60
105
  private _textInput;
106
+ /**
107
+ * Hook de ciclo de vida de Lit.
108
+ * Sincroniza manualmente el estado reactivo (`value`, `disabled`) con los
109
+ * elementos nativos del DOM subyacente. Se hace manualmente porque el input
110
+ * de tipo color no despacha eventos de forma natural si mutamos sus atributos.
111
+ */
61
112
  updated(changed: Map<string, unknown>): void;
62
113
  static styles: import("lit").CSSResult[];
114
+ /**
115
+ * Ensambla la estructura del Shadow DOM del campo de color.
116
+ *
117
+ * **Estrategia de input en capas:**
118
+ * Dos elementos `<input>` se apilan absolutamente:
119
+ * 1. `<input type="color">` (z-index: 2, opacidad: 0) — invisible pero
120
+ * clicable, abre el selector de color nativo del sistema operativo.
121
+ * 2. `<input type="text" readonly>` (z-index: 0) — visible, muestra el
122
+ * valor hexadecimal. `tabindex="-1"` en el input de color significa que
123
+ * solo el input de texto es alcanzable por teclado.
124
+ *
125
+ * El círculo `.swatch` (z-index: 1) está posicionado absolutamente en el
126
+ * borde inicial del input de texto y estilizado a través de `--_swatch: ${this.value}`,
127
+ * lo cual establece su `background-color` mediante CSS `var(--_swatch)`.
128
+ *
129
+ * **Composición de `fieldClasses`:**
130
+ * El mapa de clases sigue la convención de nomenclatura field-styles de BeerCSS:
131
+ * `field`, `label`, `fill`/`border` (variante), `small`/`large`/`extra` (tamaño),
132
+ * `prefix` (activa el cambio de padding inicial para la muestra), `invalid`, forma.
133
+ *
134
+ * **Renderizado condicional de etiqueta / ayuda:**
135
+ * Usa el centinela `nothing` de Lit para evitar renderizar nodos DOM vacíos cuando
136
+ * `label` o `helper` son cadenas vacías, previniendo saltos de diseño.
137
+ */
63
138
  render(): import("lit").TemplateResult<1>;
64
139
  }
65
140
  declare global {
@@ -1 +1 @@
1
- {"version":3,"file":"moni-color-field.d.ts","sourceRoot":"","sources":["../../src/components/moni-color-field.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,WAAW,EAA6B,MAAM,kBAAkB,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBACa,cAAe,SAAQ,WAAW;IACjB,IAAI,SAAM;IACV,KAAK,SAAM;IACX,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAc;IAEzE,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAY;IAExD,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAc;IACR,QAAQ,UAAS;IAChC,MAAM,SAAM;IACa,SAAS,SAAM;IACzB,KAAK,UAAS;IAC7B,KAAK,SAAa;IAEjB,OAAO,CAAC,WAAW,CAAoB;IACxC,OAAO,CAAC,UAAU,CAAoB;IAE1D,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAW9C,OAAgB,MAAM,4BA0BpB;IAEO,MAAM;CAuDf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,kBAAkB,EAAE,cAAc,CAAC;KACnC;CACD;AAED,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"moni-color-field.d.ts","sourceRoot":"","sources":["../../src/components/moni-color-field.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,WAAW,EAA6B,MAAM,kBAAkB,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBACa,cAAe,SAAQ,WAAW;IAC9C;;;OAGG;IAC0B,IAAI,SAAM;IAEvC;;;OAGG;IAC0B,KAAK,SAAM;IAExC;;;;OAIG;IAC0B,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAc;IAEzE;;;;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;IACyC,QAAQ,UAAS;IAE7D;;;OAGG;IAC0B,MAAM,SAAM;IAEzC;;;;OAIG;IACmD,SAAS,SAAM;IAErE;;;OAGG;IACyC,KAAK,UAAS;IAE1D;;;;OAIG;IAC0B,KAAK,SAAa;IAEjB,OAAO,CAAC,WAAW,CAAoB;IACxC,OAAO,CAAC,UAAU,CAAoB;IAEnE;;;;;OAKG;IACM,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAW9C,OAAgB,MAAM,4BA0BpB;IAEF;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACM,MAAM;CAuDf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,kBAAkB,EAAE,cAAc,CAAC;KACnC;CACD;AAED,eAAe,cAAc,CAAC"}
@@ -16,59 +16,110 @@ 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
18
  /**
19
- * Material Design 3 Color Field component.
19
+ * Componente Material Design 3 Color Field (Campo de Color).
20
20
  *
21
- * A specialized text field for color input that combines a native
22
- * `<input type="color">` with a read-only text display of the selected
23
- * hex value, wrapped in the standard M3 field shell.
21
+ * Un campo de texto especializado para la entrada de color que combina un
22
+ * `<input type="color">` nativo con una visualización de texto de solo lectura del
23
+ * valor hexadecimal seleccionado, envuelto en la carcasa estándar de campo M3.
24
24
  *
25
- * **Visual architecture:**
26
- * Extends the field styling pattern used by `<moni-text-field>`. The
27
- * leading icon slot is replaced by a circular color swatch (`.swatch`)
28
- * which is absolutely positioned over an invisible native color input.
29
- * Clicking the swatch opens the system color picker. The text input portion
30
- * displays the selected hex code and is strictly `readOnly`.
25
+ * **Arquitectura visual:**
26
+ * Extiende el patrón de estilo de campo usado por `<moni-text-field>`. El
27
+ * slot de icono inicial se reemplaza por una muestra de color circular (`.swatch`)
28
+ * que se posiciona absolutamente sobre una entrada de color nativa invisible.
29
+ * Al hacer clic en la muestra se abre el selector de color del sistema. La parte de entrada de texto
30
+ * muestra el código hexadecimal seleccionado y es estrictamente `readOnly`.
31
31
  *
32
- * **State syncing:**
33
- * The component listens to the native `change` event on the color input,
34
- * updates the `value` property, and re-dispatches a composed `'change'` event.
35
- * It does not listen to `input` (continuous drag in the color picker) to avoid
36
- * excessive event firing, but consumers can attach their own `input` listeners
37
- * directly to the element if live preview is needed.
32
+ * **Sincronización de estado:**
33
+ * El componente escucha el evento nativo `change` en la entrada de color,
34
+ * actualiza la propiedad `value`, y re-despacha un evento compuesto `'change'`.
35
+ * No escucha `input` (arrastre continuo en el selector de color) para evitar
36
+ * el disparo excesivo de eventos, pero los consumidores pueden adjuntar sus propios
37
+ * escuchas de `input` directamente al elemento si se necesita una vista previa en vivo.
38
38
  *
39
- * @fires change - Bubbles and is composed. Fired when the color picker closes
40
- * and the value is committed. Read `element.value`.
39
+ * @fires change - Burbujea y está compuesto. Se dispara cuando el selector de color se cierra
40
+ * y el valor se confirma. Leer `element.value`.
41
41
  *
42
42
  * @example
43
43
  * ```html
44
44
  * <moni-color-field
45
- * label="Theme Color"
45
+ * label="Color del Tema"
46
46
  * name="primaryColor"
47
47
  * value="#6750a4"
48
48
  * variant="outlined"
49
49
  * ></moni-color-field>
50
50
  * ```
51
51
  *
52
- * @csspart field - The outer `.field` div container.
53
- * @csspart swatch - The circular color preview element.
54
- * @csspart input-color - The native, visually hidden `<input type="color">`.
55
- * @csspart input-text - The native `<input type="text">` displaying the hex code.
56
- * @csspart label - The floating `<label>` element.
52
+ * @csspart field - El contenedor div exterior `.field`.
53
+ * @csspart swatch - El elemento de vista previa de color circular.
54
+ * @csspart input-color - El `<input type="color">` nativo, visualmente oculto.
55
+ * @csspart input-text - El `<input type="text">` nativo que muestra el código hexadecimal.
56
+ * @csspart label - El elemento flotante `<label>`.
57
57
  */
58
58
  let MoniColorField = class MoniColorField extends MoniElement {
59
59
  constructor() {
60
60
  super(...arguments);
61
+ /**
62
+ * El nombre del input, enviado con los datos del formulario.
63
+ * @type {string}
64
+ */
61
65
  this.name = '';
66
+ /**
67
+ * El texto de la etiqueta flotante.
68
+ * @type {string}
69
+ */
62
70
  this.label = '';
71
+ /**
72
+ * Variante visual del campo de texto.
73
+ * @type {'filled' | 'outlined'}
74
+ * @default 'outlined'
75
+ */
63
76
  this.variant = 'outlined';
77
+ /**
78
+ * Define las dimensiones del campo de texto.
79
+ * @type {'small' | 'medium' | 'large' | 'extra'}
80
+ * @default 'medium'
81
+ */
64
82
  this.size = 'medium';
83
+ /**
84
+ * Forma del radio del borde del campo.
85
+ * @type {'round' | 'square' | 'no-round'}
86
+ * @default 'no-round'
87
+ */
65
88
  this.shape = 'no-round';
89
+ /**
90
+ * Deshabilita el campo de color.
91
+ * @type {boolean}
92
+ */
66
93
  this.disabled = false;
94
+ /**
95
+ * Texto de ayuda mostrado debajo del campo.
96
+ * @type {string}
97
+ */
67
98
  this.helper = '';
99
+ /**
100
+ * Texto de error mostrado debajo del campo cuando `error` es true.
101
+ * Sobrescribe el texto de ayuda.
102
+ * @type {string}
103
+ */
68
104
  this.errorText = '';
105
+ /**
106
+ * Si es true, establece el campo en un estado de error.
107
+ * @type {boolean}
108
+ */
69
109
  this.error = false;
110
+ /**
111
+ * El valor actual del color hexadecimal.
112
+ * @type {string}
113
+ * @default '#6750a4'
114
+ */
70
115
  this.value = '#6750a4';
71
116
  }
117
+ /**
118
+ * Hook de ciclo de vida de Lit.
119
+ * Sincroniza manualmente el estado reactivo (`value`, `disabled`) con los
120
+ * elementos nativos del DOM subyacente. Se hace manualmente porque el input
121
+ * de tipo color no despacha eventos de forma natural si mutamos sus atributos.
122
+ */
72
123
  updated(changed) {
73
124
  if (changed.has('value')) {
74
125
  if (this._colorInput)
@@ -110,6 +161,30 @@ let MoniColorField = class MoniColorField extends MoniElement {
110
161
  }
111
162
  `
112
163
  ]; }
164
+ /**
165
+ * Ensambla la estructura del Shadow DOM del campo de color.
166
+ *
167
+ * **Estrategia de input en capas:**
168
+ * Dos elementos `<input>` se apilan absolutamente:
169
+ * 1. `<input type="color">` (z-index: 2, opacidad: 0) — invisible pero
170
+ * clicable, abre el selector de color nativo del sistema operativo.
171
+ * 2. `<input type="text" readonly>` (z-index: 0) — visible, muestra el
172
+ * valor hexadecimal. `tabindex="-1"` en el input de color significa que
173
+ * solo el input de texto es alcanzable por teclado.
174
+ *
175
+ * El círculo `.swatch` (z-index: 1) está posicionado absolutamente en el
176
+ * borde inicial del input de texto y estilizado a través de `--_swatch: ${this.value}`,
177
+ * lo cual establece su `background-color` mediante CSS `var(--_swatch)`.
178
+ *
179
+ * **Composición de `fieldClasses`:**
180
+ * El mapa de clases sigue la convención de nomenclatura field-styles de BeerCSS:
181
+ * `field`, `label`, `fill`/`border` (variante), `small`/`large`/`extra` (tamaño),
182
+ * `prefix` (activa el cambio de padding inicial para la muestra), `invalid`, forma.
183
+ *
184
+ * **Renderizado condicional de etiqueta / ayuda:**
185
+ * Usa el centinela `nothing` de Lit para evitar renderizar nodos DOM vacíos cuando
186
+ * `label` o `helper` son cadenas vacías, previniendo saltos de diseño.
187
+ */
113
188
  render() {
114
189
  const isActive = Boolean(this.value);
115
190
  const fieldClasses = {