@moni-labs/moni-ui 0.4.13 → 0.4.16
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.
- package/custom-elements.json +101 -81
- package/dist/browser/moni-ui.iife.min.js +1538 -1384
- package/dist/browser/moni-ui.iife.min.js.br +0 -0
- package/dist/browser/moni-ui.iife.min.js.gz +0 -0
- package/dist/browser/moni-ui.iife.min.js.map +1 -1
- package/dist/browser/moni-ui.min.js +2751 -2501
- package/dist/browser/moni-ui.min.js.br +0 -0
- package/dist/browser/moni-ui.min.js.gz +0 -0
- package/dist/browser/moni-ui.min.js.map +1 -1
- package/dist/cdn/chunks/{class-map-DsL1Jr2T.js → class-map-QyT9W7rZ.js} +1 -1
- package/dist/cdn/chunks/{decorate-DxJYS4gw.js → decorate-B7wZvwrn.js} +629 -543
- package/dist/cdn/chunks/if-defined-5hr_ccFw.js +1 -0
- package/dist/cdn/chunks/{live-D52JqeKf.js → live-Hm1Di_ND.js} +1 -1
- package/dist/cdn/components/moni-app-bar.js +1 -1
- package/dist/cdn/components/moni-badge.js +1 -1
- package/dist/cdn/components/moni-bottom-sheet.js +2 -1
- package/dist/cdn/components/moni-button-group.js +1 -1
- package/dist/cdn/components/moni-button-segment.js +1 -1
- package/dist/cdn/components/moni-button.js +1 -1
- package/dist/cdn/components/moni-card.js +1 -1
- package/dist/cdn/components/moni-carousel.js +1 -1
- package/dist/cdn/components/moni-checkbox.js +1 -1
- package/dist/cdn/components/moni-chip.js +1 -1
- package/dist/cdn/components/moni-color-field.js +1 -1
- package/dist/cdn/components/moni-context-menu.js +1 -1
- package/dist/cdn/components/moni-dialog.js +1 -1
- package/dist/cdn/components/moni-divider.js +1 -1
- package/dist/cdn/components/moni-expansion.js +1 -1
- package/dist/cdn/components/moni-fab-menu.js +1 -1
- package/dist/cdn/components/moni-fab.js +1 -1
- package/dist/cdn/components/moni-file-field.js +1 -1
- package/dist/cdn/components/moni-icon.js +1 -1
- package/dist/cdn/components/moni-list-item.js +1 -1
- package/dist/cdn/components/moni-list.js +1 -1
- package/dist/cdn/components/moni-loading-indicator.js +1 -1
- package/dist/cdn/components/moni-menu-item.js +1 -1
- package/dist/cdn/components/moni-menu.js +1 -1
- package/dist/cdn/components/moni-morph-modal.js +3 -2
- package/dist/cdn/components/moni-nav-item.js +1 -1
- package/dist/cdn/components/moni-nav.js +1 -1
- package/dist/cdn/components/moni-progress.js +1 -1
- package/dist/cdn/components/moni-radio.js +1 -1
- package/dist/cdn/components/moni-ripple.js +1 -1
- package/dist/cdn/components/moni-segmented-button.js +1 -1
- package/dist/cdn/components/moni-select-option.js +1 -1
- package/dist/cdn/components/moni-select.js +512 -473
- package/dist/cdn/components/moni-shape.js +1 -1
- package/dist/cdn/components/moni-side-sheet.js +1 -1
- package/dist/cdn/components/moni-slider.js +1 -1
- package/dist/cdn/components/moni-snackbar.js +1 -1
- package/dist/cdn/components/moni-split-button.js +1 -1
- package/dist/cdn/components/moni-step.js +1 -1
- package/dist/cdn/components/moni-stepper.js +1 -1
- package/dist/cdn/components/moni-switch.js +1 -1
- package/dist/cdn/components/moni-tab.js +1 -1
- package/dist/cdn/components/moni-tabs.js +1 -1
- package/dist/cdn/components/moni-text-field.js +122 -95
- package/dist/cdn/components/moni-textarea.js +52 -52
- package/dist/cdn/components/moni-time-picker.js +1 -1
- package/dist/cdn/components/moni-toolbar.js +1 -1
- package/dist/cdn/components/moni-tooltip.js +1 -1
- package/dist/cdn/components/moni-typography.js +1 -1
- package/dist/cdn/importmap.json +98 -98
- package/dist/components/_base/field-styles.d.ts.map +1 -1
- package/dist/components/_base/field-styles.js +662 -576
- package/dist/components/moni-bottom-sheet.d.ts +19 -5
- package/dist/components/moni-bottom-sheet.d.ts.map +1 -1
- package/dist/components/moni-bottom-sheet.js +111 -30
- package/dist/components/moni-morph-modal.d.ts +10 -0
- package/dist/components/moni-morph-modal.d.ts.map +1 -1
- package/dist/components/moni-morph-modal.js +323 -217
- package/dist/components/moni-select.d.ts +16 -16
- package/dist/components/moni-select.d.ts.map +1 -1
- package/dist/components/moni-select.js +797 -727
- package/dist/components/moni-text-field.d.ts +15 -15
- package/dist/components/moni-text-field.d.ts.map +1 -1
- package/dist/components/moni-text-field.js +224 -180
- package/dist/components/moni-textarea.d.ts +13 -13
- package/dist/components/moni-textarea.d.ts.map +1 -1
- package/dist/components/moni-textarea.js +127 -122
- package/docs/api.json +109 -89
- package/docs/assets/moni-color-field/shape--square.png +0 -0
- package/docs/assets/moni-file-field/shape--square.png +0 -0
- package/docs/assets/moni-morph-modal/autoHeight--false.png +0 -0
- package/docs/assets/moni-morph-modal/autoHeight--true.png +0 -0
- package/docs/components/bottom-sheet.md +2 -1
- package/docs/components/morph-modal.md +16 -7
- package/docs/components/select.md +74 -74
- package/docs/components/text-field.md +75 -66
- package/docs/components/textarea.md +51 -51
- package/docs/llms.txt +3 -3
- package/package.json +1 -1
- package/src/components/_base/field-styles.ts +723 -637
- package/src/components/moni-bottom-sheet.test.ts +331 -0
- package/src/components/moni-bottom-sheet.ts +117 -29
- package/src/components/moni-morph-modal.test.ts +490 -413
- package/src/components/moni-morph-modal.ts +2274 -2162
- package/src/components/moni-select.test.ts +489 -466
- package/src/components/moni-select.ts +1963 -1815
- package/src/components/moni-text-field.test.ts +366 -342
- package/src/components/moni-text-field.ts +717 -645
- package/src/components/moni-textarea.test.ts +201 -197
- package/src/components/moni-textarea.ts +476 -460
- package/dist/cdn/chunks/if-defined-DdzvcoI7.js +0 -1
|
@@ -1,197 +1,201 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from
|
|
2
|
-
import
|
|
3
|
-
import type { MoniTextarea } from
|
|
4
|
-
|
|
5
|
-
describe(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import "./moni-textarea.js";
|
|
3
|
+
import type { MoniTextarea } from "./moni-textarea.js";
|
|
4
|
+
|
|
5
|
+
describe("moni-textarea", () => {
|
|
6
|
+
let el: MoniTextarea;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
el = document.createElement("moni-textarea") as MoniTextarea;
|
|
10
|
+
document.body.appendChild(el);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
el.remove();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("renderiza un contenedor de campo (field wrapper) y un textarea", async () => {
|
|
18
|
+
await el.updateComplete;
|
|
19
|
+
const field = el.shadowRoot?.querySelector(".field");
|
|
20
|
+
const textarea = el.shadowRoot?.querySelector("textarea");
|
|
21
|
+
expect(field).toBeTruthy();
|
|
22
|
+
expect(textarea).toBeTruthy();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("renderiza un icono inicial (leading) cuando se establece el atributo icon", async () => {
|
|
26
|
+
el.icon = "edit";
|
|
27
|
+
await el.updateComplete;
|
|
28
|
+
const leading = el.shadowRoot?.querySelector(".leading-icon");
|
|
29
|
+
expect(leading).toBeTruthy();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("renderiza un icono final (trailing) cuando se establece el atributo trailing-icon", async () => {
|
|
33
|
+
el.setAttribute("trailing-icon", "send");
|
|
34
|
+
await el.updateComplete;
|
|
35
|
+
const trailing = el.shadowRoot?.querySelector(".trailing-icon");
|
|
36
|
+
expect(trailing).toBeTruthy();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("renderiza un texto prefijo cuando se establece el atributo prefix", async () => {
|
|
40
|
+
el.prefix = "~";
|
|
41
|
+
await el.updateComplete;
|
|
42
|
+
const leading = el.shadowRoot?.querySelector(".leading-icon");
|
|
43
|
+
expect(leading?.textContent?.trim()).toBe("~");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("renderiza un texto sufijo cuando se establece el atributo suffix", async () => {
|
|
47
|
+
el.suffix = "chars";
|
|
48
|
+
await el.updateComplete;
|
|
49
|
+
const trailing = el.shadowRoot?.querySelector(".trailing-icon");
|
|
50
|
+
expect(trailing?.textContent?.trim()).toBe("chars");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("muestra el indicador de carga cuando loading es true", async () => {
|
|
54
|
+
el.loading = true;
|
|
55
|
+
await el.updateComplete;
|
|
56
|
+
const trailing = el.shadowRoot?.querySelector(".trailing-icon");
|
|
57
|
+
const progress = trailing?.querySelector("moni-progress");
|
|
58
|
+
expect(progress).toBeTruthy();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("reenvía el atributo rows al textarea", async () => {
|
|
62
|
+
el.rows = 5;
|
|
63
|
+
await el.updateComplete;
|
|
64
|
+
const textarea = el.shadowRoot?.querySelector(
|
|
65
|
+
"textarea",
|
|
66
|
+
) as HTMLTextAreaElement;
|
|
67
|
+
expect(textarea.rows).toBe(5);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("reenvía value al textarea", async () => {
|
|
71
|
+
el.value = "multi\nline\ntext";
|
|
72
|
+
await el.updateComplete;
|
|
73
|
+
const textarea = el.shadowRoot?.querySelector(
|
|
74
|
+
"textarea",
|
|
75
|
+
) as HTMLTextAreaElement;
|
|
76
|
+
expect(textarea.value).toBe("multi\nline\ntext");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("agrega la clase active al textarea cuando se establece el valor", async () => {
|
|
80
|
+
el.value = "content";
|
|
81
|
+
await el.updateComplete;
|
|
82
|
+
const textarea = el.shadowRoot?.querySelector("textarea");
|
|
83
|
+
expect(textarea?.classList.contains("active")).toBe(true);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("aplica la clase square en el contenedor de campo para shape=no-round", async () => {
|
|
87
|
+
el.shape = "no-round";
|
|
88
|
+
await el.updateComplete;
|
|
89
|
+
const field = el.shadowRoot?.querySelector(".field");
|
|
90
|
+
expect(field?.classList.contains("square")).toBe(true);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("aplica la clase round en el contenedor de campo para shape=round", async () => {
|
|
94
|
+
el.shape = "round";
|
|
95
|
+
await el.updateComplete;
|
|
96
|
+
const field = el.shadowRoot?.querySelector(".field");
|
|
97
|
+
expect(field?.classList.contains("round")).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("aplica la clase small-round para un redondeado compacto", async () => {
|
|
101
|
+
el.shape = "small-round";
|
|
102
|
+
await el.updateComplete;
|
|
103
|
+
const field = el.shadowRoot?.querySelector(".field");
|
|
104
|
+
expect(field?.classList.contains("small-round")).toBe(true);
|
|
105
|
+
expect(field?.classList.contains("square")).toBe(false);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("no aplica la clase de forma (shape) en el contenedor de campo para shape=square", async () => {
|
|
109
|
+
el.shape = "square";
|
|
110
|
+
await el.updateComplete;
|
|
111
|
+
const field = el.shadowRoot?.querySelector(".field");
|
|
112
|
+
expect(field?.classList.contains("square")).toBe(false);
|
|
113
|
+
expect(field?.classList.contains("round")).toBe(false);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// ─── P3.3: maxlength + character counter ───
|
|
117
|
+
|
|
118
|
+
it("no renderiza un contador por defecto", async () => {
|
|
119
|
+
await el.updateComplete;
|
|
120
|
+
const counter = el.shadowRoot?.querySelector(".counter");
|
|
121
|
+
expect(counter).toBeFalsy();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("renderiza un contador cuando se establece maxlength", async () => {
|
|
125
|
+
el.maxlength = 100;
|
|
126
|
+
await el.updateComplete;
|
|
127
|
+
const counter = el.shadowRoot?.querySelector(".counter");
|
|
128
|
+
expect(counter).toBeTruthy();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("el contador muestra value.length / maxlength", async () => {
|
|
132
|
+
el.maxlength = 100;
|
|
133
|
+
el.value = "Hello";
|
|
134
|
+
await el.updateComplete;
|
|
135
|
+
const counter = el.shadowRoot?.querySelector(".counter");
|
|
136
|
+
expect(counter?.textContent?.trim()).toBe("5 / 100");
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("no-counter suprime el contador incluso cuando maxlength está establecido", async () => {
|
|
140
|
+
el.maxlength = 100;
|
|
141
|
+
el.noCounter = true;
|
|
142
|
+
await el.updateComplete;
|
|
143
|
+
const counter = el.shadowRoot?.querySelector(".counter");
|
|
144
|
+
expect(counter).toBeFalsy();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("reenvía maxlength al textarea interno como maxLength", async () => {
|
|
148
|
+
el.maxlength = 50;
|
|
149
|
+
await el.updateComplete;
|
|
150
|
+
const textarea = el.shadowRoot?.querySelector(
|
|
151
|
+
"textarea",
|
|
152
|
+
) as HTMLTextAreaElement;
|
|
153
|
+
expect(textarea.maxLength).toBe(50);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("sincroniza el valor al escribir", async () => {
|
|
157
|
+
await el.updateComplete;
|
|
158
|
+
const textarea = el.shadowRoot?.querySelector(
|
|
159
|
+
"textarea",
|
|
160
|
+
) as HTMLTextAreaElement;
|
|
161
|
+
textarea.value = "Texto escrito";
|
|
162
|
+
textarea.dispatchEvent(new Event("input"));
|
|
163
|
+
expect(el.value).toBe("Texto escrito");
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("activa autosize y expone max-rows", async () => {
|
|
167
|
+
el.autosize = true;
|
|
168
|
+
el.maxRows = 6;
|
|
169
|
+
await el.updateComplete;
|
|
170
|
+
expect(el.hasAttribute("autosize")).toBe(true);
|
|
171
|
+
expect(el.getAttribute("max-rows")).toBe("6");
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("retira la altura calculada al desactivar autosize", async () => {
|
|
175
|
+
el.autosize = true;
|
|
176
|
+
await el.updateComplete;
|
|
177
|
+
const textarea = el.shadowRoot?.querySelector(
|
|
178
|
+
"textarea",
|
|
179
|
+
) as HTMLTextAreaElement;
|
|
180
|
+
textarea.style.blockSize = "120px";
|
|
181
|
+
el.autosize = false;
|
|
182
|
+
await el.updateComplete;
|
|
183
|
+
expect(textarea.style.blockSize).toBe("");
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe("moni-textarea · nombre accesible", () => {
|
|
188
|
+
it("asocia la etiqueta con el textarea mediante for/id", async () => {
|
|
189
|
+
const el = document.createElement("moni-textarea") as MoniTextarea;
|
|
190
|
+
el.label = "Comentario";
|
|
191
|
+
document.body.appendChild(el);
|
|
192
|
+
await el.updateComplete;
|
|
193
|
+
|
|
194
|
+
const control = el.shadowRoot?.querySelector("textarea");
|
|
195
|
+
const label = el.shadowRoot?.querySelector("label");
|
|
196
|
+
expect(control?.id).toBe("input");
|
|
197
|
+
expect(label?.getAttribute("for")).toBe("input");
|
|
198
|
+
expect(control?.nextElementSibling).toBe(label);
|
|
199
|
+
el.remove();
|
|
200
|
+
});
|
|
201
|
+
});
|