@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,40 +16,40 @@ import { MoniElement, sharedStyles } from './_base/index.js';
16
16
  import './moni-icon.js';
17
17
  import './moni-button.js';
18
18
  /**
19
- * Material Design 3 Time Picker component.
19
+ * Componente Material Design 3 Time Picker (Selector de hora).
20
20
  *
21
- * A highly interactive control that allows users to select a specific time.
22
- * It provides two distinct input modes:
23
- * 1. **Dial mode:** An interactive clock face where users can drag or click
24
- * to select hours and minutes.
25
- * 2. **Input mode:** Standard text inputs for precise keyboard entry.
21
+ * Un control altamente interactivo que permite a los usuarios seleccionar una hora específica.
22
+ * Proporciona dos modos de entrada distintos:
23
+ * 1. **Modo dial (analógico):** Una carátula de reloj interactiva donde los usuarios pueden arrastrar o hacer clic
24
+ * para seleccionar horas y minutos.
25
+ * 2. **Modo input (texto):** Entradas de texto estándar para una introducción precisa por teclado.
26
26
  *
27
- * **M3 spec reference:** `m3-docs/components/time-pickers/specs.md`
27
+ * **Referencia a la especificación M3:** `m3-docs/components/time-pickers/specs.md`
28
28
  *
29
- * **Time formats & modes:**
30
- * - The `value` property expects and always outputs a 24-hour formatted string
31
- * (`HH:MM`, e.g., `"14:30"`).
32
- * - Setting `use-24-hour` configures the visual presentation to use a 24-hour
33
- * clock dial (inner and outer rings) and removes the AM/PM toggle. Otherwise,
34
- * it uses a standard 12-hour dial with an AM/PM toggle.
29
+ * **Formatos de hora y modos:**
30
+ * - La propiedad `value` espera y siempre emite un string en formato de 24 horas
31
+ * (`HH:MM`, ej. `"14:30"`).
32
+ * - Establecer `use-24-hour` configura la presentación visual para usar un
33
+ * reloj de 24 horas (anillos interior y exterior) y elimina el selector AM/PM. De lo contrario,
34
+ * utiliza un dial estándar de 12 horas con un selector AM/PM.
35
35
  *
36
- * **Responsive design:**
37
- * The `orientation` attribute configures the layout. `vertical` stacks the
38
- * time display above the clock face, `horizontal` places them side-by-side,
39
- * and `auto` responds to the container/viewport width automatically.
36
+ * **Diseño responsivo:**
37
+ * El atributo `orientation` configura el diseño. `vertical` apila la
38
+ * visualización de la hora sobre la carátula del reloj, `horizontal` los coloca lado a lado,
39
+ * y `auto` responde automáticamente al ancho del contenedor/viewport.
40
40
  *
41
- * @fires change - Fired when the selected time changes interactively. The
42
- * `detail.value` contains the new time in `HH:MM` format.
43
- * @fires cancel - Fired when the 'Cancel' button is clicked.
44
- * @fires ok - Fired when the 'OK' button is clicked. The `detail.value`
45
- * contains the final confirmed time.
41
+ * @fires change - Se dispara cuando la hora seleccionada cambia interactivamente. El
42
+ * `detail.value` contiene la nueva hora en formato `HH:MM`.
43
+ * @fires cancel - Se dispara cuando se hace clic en el botón 'Cancelar'.
44
+ * @fires ok - Se dispara cuando se hace clic en el botón 'OK'. El `detail.value`
45
+ * contiene la hora final confirmada.
46
46
  *
47
47
  * @example
48
48
  * ```html
49
- * <!-- 12-hour format (AM/PM) -->
49
+ * <!-- Formato 12 horas (AM/PM) -->
50
50
  * <moni-time-picker value="14:30"></moni-time-picker>
51
51
  *
52
- * <!-- 24-hour format -->
52
+ * <!-- Formato 24 horas -->
53
53
  * <moni-time-picker use-24-hour value="14:30"></moni-time-picker>
54
54
  * ```
55
55
  */
@@ -66,11 +66,23 @@ let MoniTimePicker = class MoniTimePicker extends MoniElement {
66
66
  this.currentMinute = 0; // 0-59
67
67
  this.isDragging = false;
68
68
  }
69
+ /**
70
+ * Hook del ciclo de vida (Lit) previo al renderizado.
71
+ *
72
+ * Si la propiedad externa `value` o el modo `use24Hour` cambian (vía binding o atributo HTML),
73
+ * dispara el `parseValue()` de inmediato para mantener sincronizado el estado interno de
74
+ * horas y minutos (y recalcular AM/PM) antes de mutar el DOM real.
75
+ */
69
76
  willUpdate(changedProperties) {
70
77
  if (changedProperties.has('value') || changedProperties.has('use24Hour')) {
71
78
  this.parseValue();
72
79
  }
73
80
  }
81
+ /**
82
+ * Interpreta el string `value` (formato "HH:MM") y lo descompone en enteros para
83
+ * el estado interno. Automáticamente corrige valores fuera de rango y determina
84
+ * si estamos en AM o PM (cuando no se usa formato de 24 horas).
85
+ */
74
86
  parseValue() {
75
87
  const parts = this.value.split(':');
76
88
  let h = parseInt(parts[0], 10);
@@ -90,6 +102,11 @@ let MoniTimePicker = class MoniTimePicker extends MoniElement {
90
102
  }
91
103
  }
92
104
  }
105
+ /**
106
+ * Reconstruye el string `value` a partir del estado interno (`currentHour`, `currentMinute`).
107
+ * Formatea con ceros a la izquierda e incluye la lógica de conversión AM/PM a 24hrs
108
+ * para garantizar que el valor expuesto hacia afuera sea siempre un estándar ISO ("14:30").
109
+ */
93
110
  updateValue() {
94
111
  let h = this.currentHour;
95
112
  const m = this.currentMinute;
@@ -102,7 +119,7 @@ let MoniTimePicker = class MoniTimePicker extends MoniElement {
102
119
  if (h === 12)
103
120
  h = 0;
104
121
  else if (h > 12)
105
- h -= 12; // Adjust if out of bounds
122
+ h -= 12; // Ajuste por si quedó fuera de límites
106
123
  }
107
124
  }
108
125
  const formattedHour = String(h).padStart(2, '0');
@@ -114,17 +131,38 @@ let MoniTimePicker = class MoniTimePicker extends MoniElement {
114
131
  composed: true
115
132
  }));
116
133
  }
134
+ /**
135
+ * Alterna el modo de interacción visual entre el Reloj Analógico (dial)
136
+ * y el modo de Entrada de Texto manual (input).
137
+ */
117
138
  toggleMode() {
118
139
  this.mode = this.mode === 'dial' ? 'input' : 'dial';
119
140
  }
141
+ /**
142
+ * Define el nivel de selección activo ('hour' o 'minute').
143
+ * Cambia dinámicamente qué anillo o qué matemáticas (12 vs 60 items)
144
+ * utilizará el componente principal y el reloj.
145
+ */
120
146
  setSelection(type) {
121
147
  this.activeSelection = type;
122
148
  }
149
+ /**
150
+ * Cambia forzosamente el periodo del día ('AM' o 'PM') cuando el usuario
151
+ * presiona los conmutadores laterales (sólo visible en formato 12h).
152
+ * Inmediatamente propaga el cambio hacia `updateValue()` para recalcular
153
+ * y despachar la hora formateada.
154
+ */
123
155
  setPeriod(p) {
124
156
  this.period = p;
125
157
  this.updateValue();
126
158
  }
127
159
  // Clock Math and Interaction
160
+ /**
161
+ * Inicia el proceso de arrastre en la carátula del reloj (Pointer Down).
162
+ * Utiliza `setPointerCapture` nativo para asegurar que el movimiento (drag) siga
163
+ * siendo rastreado aunque el puntero del usuario salga físicamente del contenedor,
164
+ * garantizando una interacción "Touch" a prueba de errores.
165
+ */
128
166
  handleClockPointerDown(e) {
129
167
  if (!this.clockFaceEl)
130
168
  return;
@@ -133,37 +171,46 @@ let MoniTimePicker = class MoniTimePicker extends MoniElement {
133
171
  this.clockFaceEl.setPointerCapture(e.pointerId);
134
172
  this.handleClockPointerMove(e);
135
173
  }
174
+ /**
175
+ * Corazón matemático del reloj radial (Time Picker analógico).
176
+ * Convierte las coordenadas cartesianas del ratón/dedo en un ángulo polar (0-360º),
177
+ * y dependiendo si medimos horas o minutos, lo mapea al número correspondiente.
178
+ */
136
179
  handleClockPointerMove(e) {
137
180
  if (!this.isDragging || !this.clockFaceEl)
138
181
  return;
139
182
  const rect = this.clockFaceEl.getBoundingClientRect();
183
+ // Encontramos el centro geométrico absoluto del reloj
140
184
  const centerX = rect.left + rect.width / 2;
141
185
  const centerY = rect.top + rect.height / 2;
142
186
  const dx = e.clientX - centerX;
143
187
  const dy = e.clientY - centerY;
188
+ // Teorema de Pitágoras para saber a qué distancia del centro está apuntando el usuario
144
189
  const distance = Math.sqrt(dx * dx + dy * dy);
145
- // Calculate angle in degrees from 12 o'clock position (clockwise)
190
+ // Calculamos el ángulo en grados partiendo desde las 12 (sentido horario).
191
+ // Math.atan2 devuelve de -PI a PI, sumamos 90º para desfasar el origen arriba (eje Y).
146
192
  let angle = Math.atan2(dy, dx) * (180 / Math.PI) + 90;
147
193
  if (angle < 0)
148
194
  angle += 360;
149
195
  if (this.activeSelection === 'hour') {
150
196
  if (this.use24Hour) {
151
- // Outer circle for 13-00, inner circle for 1-12
197
+ // Reloj de 24 horas M3: Un círculo externo (13-00) y uno interno (1-12)
198
+ // El umbral (0.32) fue medido visualmente para coincidir con el diseño radial interno.
152
199
  const isInner = distance < rect.width * 0.32;
153
- let hour = Math.round(angle / 30) % 12;
200
+ let hour = Math.round(angle / 30) % 12; // 360 / 12 horas = 30 grados por hora
154
201
  if (hour === 0)
155
202
  hour = 12;
156
203
  if (isInner) {
157
- // Inner circle: 1 to 12
204
+ // Círculo interno: 1 a 12 (AM/PM)
158
205
  this.currentHour = hour;
159
206
  }
160
207
  else {
161
- // Outer circle: 13 to 00/24
208
+ // Círculo externo: 13 a 24 (donde las 24 = 0)
162
209
  this.currentHour = hour === 12 ? 0 : hour + 12;
163
210
  }
164
211
  }
165
212
  else {
166
- // 12-hour face: 1 to 12
213
+ // Reloj estándar de 12 horas: solo 1 a 12
167
214
  let hour = Math.round(angle / 30) % 12;
168
215
  if (hour === 0)
169
216
  hour = 12;
@@ -171,24 +218,36 @@ let MoniTimePicker = class MoniTimePicker extends MoniElement {
171
218
  }
172
219
  }
173
220
  else {
174
- // Minutes: 0 to 59
221
+ // Modo minutos: 360 / 60 minutos = 6 grados por minuto
175
222
  const minute = Math.round(angle / 6) % 60;
176
223
  this.currentMinute = minute;
177
224
  }
178
225
  this.updateValue();
179
226
  }
227
+ /**
228
+ * Finaliza la interacción de arrastre en la carátula del reloj (Pointer Up).
229
+ *
230
+ * Como heurística de usabilidad, si el usuario acaba de seleccionar la Hora,
231
+ * el componente espera 300ms y automáticamente transiciona a la vista de Minutos.
232
+ * Esto reduce los clics necesarios en interacciones de Time Pickers de un solo toque.
233
+ */
180
234
  handleClockPointerUp() {
181
235
  if (this.isDragging) {
182
236
  this.isDragging = false;
183
237
  this.clockFaceEl?.classList.remove('dragging');
184
238
  if (this.activeSelection === 'hour') {
185
- // Automatically switch to minute selection after choosing hour
239
+ // Cambiar automáticamente a la selección de minutos después de elegir la hora
186
240
  setTimeout(() => {
187
241
  this.activeSelection = 'minute';
188
242
  }, 300);
189
243
  }
190
244
  }
191
245
  }
246
+ /**
247
+ * Handler para entradas directas desde el `<input>` de horas (Modo 'input' texto).
248
+ * Implementa clamping (límites mínimos y máximos) para asegurar que el usuario
249
+ * nunca pueda introducir valores erróneos mayores a 23h o menores a 0h.
250
+ */
192
251
  handleHourInputChange(e) {
193
252
  const target = e.target;
194
253
  let val = parseInt(target.value, 10);
@@ -210,6 +269,10 @@ let MoniTimePicker = class MoniTimePicker extends MoniElement {
210
269
  }
211
270
  this.updateValue();
212
271
  }
272
+ /**
273
+ * Handler para entradas directas desde el `<input>` de minutos (Modo 'input' texto).
274
+ * Trunca cualquier input alfanumérico a enteros y realiza un clamp a 0-59.
275
+ */
213
276
  handleMinuteInputChange(e) {
214
277
  const target = e.target;
215
278
  let val = parseInt(target.value, 10);
@@ -596,6 +659,13 @@ let MoniTimePicker = class MoniTimePicker extends MoniElement {
596
659
  }
597
660
  `
598
661
  ]; }
662
+ /**
663
+ * Renderizador de la carátula circular (Dial Face).
664
+ *
665
+ * Utiliza trigonometría básica (`sin` y `cos`) para distribuir los números equitativamente
666
+ * a lo largo del perímetro del círculo en CSS absoluto. En formato 24h, renderiza
667
+ * dos anillos concéntricos manipulando el radio relativo (`50%` vs `32%`).
668
+ */
599
669
  renderDialClockFace() {
600
670
  const isHour = this.activeSelection === 'hour';
601
671
  let degrees = 0;
@@ -733,6 +803,30 @@ let MoniTimePicker = class MoniTimePicker extends MoniElement {
733
803
  </div>
734
804
  `;
735
805
  }
806
+ /**
807
+ * Renderiza el selector de hora (time picker) en modo `dial` o `input`.
808
+ *
809
+ * **Visualización 12 vs 24 horas:**
810
+ * `hourVal` convierte `currentHour` (0–23) al formato de visualización:
811
+ * - Modo 24 horas: string con ceros a la izquierda (ej. `'09'`, `'14'`).
812
+ * - Modo 12 horas: `0` → `12`, `13` → `1`, preservando la visualización AM/PM.
813
+ * `minuteVal` siempre tiene ceros a la izquierda para tener 2 dígitos.
814
+ *
815
+ * **Modo dial:**
816
+ * Renderiza una carátula de reloj DOM (HTML/CSS) con números distribuidos
817
+ * circularmente para cada hora/minuto. El sub-método `renderDialClockFace()`
818
+ * maneja la geometría y estilos que mueven la manecilla selectora mientras
819
+ * el usuario arrastra.
820
+ *
821
+ * **Modo input:**
822
+ * Renderiza dos elementos `<input type="number">` para la hora y el minuto con
823
+ * un selector AM/PM. El modo input es la alternativa (fallback) para accesibilidad
824
+ * y entornos no táctiles.
825
+ *
826
+ * **Alternador de modo:**
827
+ * Un icono de teclado cambia de modo `dial` a `input`; un icono de reloj
828
+ * cambia de vuelta.
829
+ */
736
830
  render() {
737
831
  const hourVal = !this.use24Hour
738
832
  ? String(this.currentHour > 12 ? this.currentHour - 12 : this.currentHour === 0 ? 12 : this.currentHour).padStart(2, '0')
@@ -6,52 +6,66 @@
6
6
  */
7
7
  import { MoniElement } from './_base/index.js';
8
8
  /**
9
- * Material Design 3 Top App Bar (Toolbar) component.
9
+ * Componente Material Design 3 Top App Bar (Barra de herramientas superior).
10
10
  *
11
- * Top app bars display information and actions at the top of a screen.
12
- * They are used for branding, screen titles, navigation, and actions.
11
+ * Las barras de aplicación superiores muestran información y acciones en la parte superior de una pantalla.
12
+ * Se utilizan para identidad de marca, títulos de pantalla, navegación y acciones.
13
13
  *
14
- * **M3 spec reference:** `m3-docs/components/top-app-bar/specs.md`
14
+ * **Referencia a la especificación M3:** `m3-docs/components/top-app-bar/specs.md`
15
15
  *
16
- * **Note:** This is the standard top-level toolbar. For bottom navigation
17
- * bars (often used on mobile), use `<moni-app-bar>`.
16
+ * **Nota:** Esta es la barra de herramientas estándar de nivel superior. Para barras de navegación
17
+ * inferiores (a menudo usadas en móviles), usa `<moni-app-bar>`.
18
18
  *
19
- * **Variants:**
20
- * - `standard` (default): A full-width bar (64dp height) that sits flush
21
- * against the top of the screen.
22
- * - `floating`: A detached bar with a 4dp margin and rounded 8dp corners,
23
- * appearing to float above the content.
19
+ * **Variantes:**
20
+ * - `standard` (por defecto): Una barra de ancho completo (altura de 64dp) que se asienta al ras
21
+ * contra la parte superior de la pantalla.
22
+ * - `floating`: Una barra separada con un margen de 4dp y esquinas redondeadas de 8dp,
23
+ * que parece flotar sobre el contenido.
24
24
  *
25
- * **Scroll behavior:**
26
- * When the `scroll` attribute is present, the toolbar visually responds to
27
- * scrolling by increasing its elevation (shadow) and dynamically shifting
28
- * its surface color to indicate depth over the scrolling content.
25
+ * **Comportamiento de desplazamiento (scroll):**
26
+ * Cuando el atributo `scroll` está presente, la barra de herramientas responde visualmente al
27
+ * desplazamiento aumentando su elevación (sombra) y cambiando dinámicamente
28
+ * su color de superficie para indicar profundidad sobre el contenido desplazado.
29
29
  *
30
30
  * @example
31
31
  * ```html
32
- * <!-- Standard toolbar with navigation and actions -->
33
- * <moni-toolbar title="Inbox">
32
+ * <!-- Barra de herramientas estándar con navegación y acciones -->
33
+ * <moni-toolbar title="Bandeja de entrada">
34
34
  * <moni-icon-button slot="leading" icon="menu"></moni-icon-button>
35
35
  * <moni-icon-button slot="trailing" icon="search"></moni-icon-button>
36
36
  * <moni-icon-button slot="trailing" icon="more_vert"></moni-icon-button>
37
37
  * </moni-toolbar>
38
38
  *
39
- * <!-- Floating toolbar with an attached FAB -->
40
- * <moni-toolbar type="floating" title="Notes">
39
+ * <!-- Barra de herramientas flotante con un FAB adjunto -->
40
+ * <moni-toolbar type="floating" title="Notas">
41
41
  * <moni-fab slot="action-button" icon="add"></moni-fab>
42
42
  * </moni-toolbar>
43
43
  * ```
44
44
  *
45
- * @slot default - The title text or center content.
46
- * @slot leading - Navigation icon/button placed on the far left.
47
- * @slot trailing - Action icons/buttons placed on the far right.
48
- * @slot action-button - A floating action button (FAB) anchored to the right side.
45
+ * @slot default - El texto del título o contenido central.
46
+ * @slot leading - Icono/botón de navegación colocado en el extremo izquierdo.
47
+ * @slot trailing - Iconos/botones de acción colocados en el extremo derecho.
48
+ * @slot action-button - Un botón de acción flotante (FAB) anclado al lado derecho.
49
49
  */
50
50
  export declare class MoniToolbar extends MoniElement {
51
51
  type: 'standard' | 'floating';
52
52
  scrolled: boolean;
53
53
  title: string;
54
54
  static styles: import("lit").CSSResult[];
55
+ /**
56
+ * Renderiza el diseño `<header>` de 3 zonas de la barra de herramientas.
57
+ *
58
+ * **Zonas:**
59
+ * - `.leading` — slot inicial para iconos de navegación o controles de migas de pan (breadcrumb).
60
+ * - `.title` — zona del título central; renderiza `this.title` como texto si el atributo
61
+ * está configurado, de lo contrario recurre al slot por defecto para contenido rico.
62
+ * - `.trailing` — slot final para iconos de acción (buscar, más, etc.).
63
+ *
64
+ * **Slot `action-button`:**
65
+ * Un slot nombrado separado, fuera del `<header>`, para un botón de acción flotante
66
+ * (FAB) o disparador de menú contextual que no debe participar en el diseño
67
+ * flex de la fila del título.
68
+ */
55
69
  render(): import("lit").TemplateResult<1>;
56
70
  }
57
71
  declare global {
@@ -1 +1 @@
1
- {"version":3,"file":"moni-toolbar.d.ts","sourceRoot":"","sources":["../../src/components/moni-toolbar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAgB,MAAM,kBAAkB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBACa,WAAY,SAAQ,WAAW;IAE3C,IAAI,EAAE,UAAU,GAAG,UAAU,CAAc;IAE3C,QAAQ,UAAS;IACY,KAAK,SAAM;IAExC,OAAgB,MAAM,4BA8DpB;IAEO,MAAM;CAcf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,cAAc,EAAE,WAAW,CAAC;KAC5B;CACD;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"moni-toolbar.d.ts","sourceRoot":"","sources":["../../src/components/moni-toolbar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAgB,MAAM,kBAAkB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBACa,WAAY,SAAQ,WAAW;IAE3C,IAAI,EAAE,UAAU,GAAG,UAAU,CAAc;IAE3C,QAAQ,UAAS;IACY,KAAK,SAAM;IAExC,OAAgB,MAAM,4BA8DpB;IAEF;;;;;;;;;;;;;OAaG;IACM,MAAM;CAcf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,cAAc,EAAE,WAAW,CAAC;KAC5B;CACD;AAED,eAAe,WAAW,CAAC"}
@@ -14,46 +14,46 @@ import { html, css } from 'lit';
14
14
  import { customElement, property } from 'lit/decorators.js';
15
15
  import { MoniElement, sharedStyles } from './_base/index.js';
16
16
  /**
17
- * Material Design 3 Top App Bar (Toolbar) component.
17
+ * Componente Material Design 3 Top App Bar (Barra de herramientas superior).
18
18
  *
19
- * Top app bars display information and actions at the top of a screen.
20
- * They are used for branding, screen titles, navigation, and actions.
19
+ * Las barras de aplicación superiores muestran información y acciones en la parte superior de una pantalla.
20
+ * Se utilizan para identidad de marca, títulos de pantalla, navegación y acciones.
21
21
  *
22
- * **M3 spec reference:** `m3-docs/components/top-app-bar/specs.md`
22
+ * **Referencia a la especificación M3:** `m3-docs/components/top-app-bar/specs.md`
23
23
  *
24
- * **Note:** This is the standard top-level toolbar. For bottom navigation
25
- * bars (often used on mobile), use `<moni-app-bar>`.
24
+ * **Nota:** Esta es la barra de herramientas estándar de nivel superior. Para barras de navegación
25
+ * inferiores (a menudo usadas en móviles), usa `<moni-app-bar>`.
26
26
  *
27
- * **Variants:**
28
- * - `standard` (default): A full-width bar (64dp height) that sits flush
29
- * against the top of the screen.
30
- * - `floating`: A detached bar with a 4dp margin and rounded 8dp corners,
31
- * appearing to float above the content.
27
+ * **Variantes:**
28
+ * - `standard` (por defecto): Una barra de ancho completo (altura de 64dp) que se asienta al ras
29
+ * contra la parte superior de la pantalla.
30
+ * - `floating`: Una barra separada con un margen de 4dp y esquinas redondeadas de 8dp,
31
+ * que parece flotar sobre el contenido.
32
32
  *
33
- * **Scroll behavior:**
34
- * When the `scroll` attribute is present, the toolbar visually responds to
35
- * scrolling by increasing its elevation (shadow) and dynamically shifting
36
- * its surface color to indicate depth over the scrolling content.
33
+ * **Comportamiento de desplazamiento (scroll):**
34
+ * Cuando el atributo `scroll` está presente, la barra de herramientas responde visualmente al
35
+ * desplazamiento aumentando su elevación (sombra) y cambiando dinámicamente
36
+ * su color de superficie para indicar profundidad sobre el contenido desplazado.
37
37
  *
38
38
  * @example
39
39
  * ```html
40
- * <!-- Standard toolbar with navigation and actions -->
41
- * <moni-toolbar title="Inbox">
40
+ * <!-- Barra de herramientas estándar con navegación y acciones -->
41
+ * <moni-toolbar title="Bandeja de entrada">
42
42
  * <moni-icon-button slot="leading" icon="menu"></moni-icon-button>
43
43
  * <moni-icon-button slot="trailing" icon="search"></moni-icon-button>
44
44
  * <moni-icon-button slot="trailing" icon="more_vert"></moni-icon-button>
45
45
  * </moni-toolbar>
46
46
  *
47
- * <!-- Floating toolbar with an attached FAB -->
48
- * <moni-toolbar type="floating" title="Notes">
47
+ * <!-- Barra de herramientas flotante con un FAB adjunto -->
48
+ * <moni-toolbar type="floating" title="Notas">
49
49
  * <moni-fab slot="action-button" icon="add"></moni-fab>
50
50
  * </moni-toolbar>
51
51
  * ```
52
52
  *
53
- * @slot default - The title text or center content.
54
- * @slot leading - Navigation icon/button placed on the far left.
55
- * @slot trailing - Action icons/buttons placed on the far right.
56
- * @slot action-button - A floating action button (FAB) anchored to the right side.
53
+ * @slot default - El texto del título o contenido central.
54
+ * @slot leading - Icono/botón de navegación colocado en el extremo izquierdo.
55
+ * @slot trailing - Iconos/botones de acción colocados en el extremo derecho.
56
+ * @slot action-button - Un botón de acción flotante (FAB) anclado al lado derecho.
57
57
  */
58
58
  let MoniToolbar = class MoniToolbar extends MoniElement {
59
59
  constructor() {
@@ -125,6 +125,20 @@ let MoniToolbar = class MoniToolbar extends MoniElement {
125
125
  }
126
126
  `
127
127
  ]; }
128
+ /**
129
+ * Renderiza el diseño `<header>` de 3 zonas de la barra de herramientas.
130
+ *
131
+ * **Zonas:**
132
+ * - `.leading` — slot inicial para iconos de navegación o controles de migas de pan (breadcrumb).
133
+ * - `.title` — zona del título central; renderiza `this.title` como texto si el atributo
134
+ * está configurado, de lo contrario recurre al slot por defecto para contenido rico.
135
+ * - `.trailing` — slot final para iconos de acción (buscar, más, etc.).
136
+ *
137
+ * **Slot `action-button`:**
138
+ * Un slot nombrado separado, fuera del `<header>`, para un botón de acción flotante
139
+ * (FAB) o disparador de menú contextual que no debe participar en el diseño
140
+ * flex de la fila del título.
141
+ */
128
142
  render() {
129
143
  return html `
130
144
  <header class="container" part="container">