@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
|
@@ -10,15 +10,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
10
10
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
11
11
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12
12
|
};
|
|
13
|
-
import { css, html, nothing } from
|
|
14
|
-
import { customElement, property, query, state } from
|
|
15
|
-
import { ifDefined } from
|
|
16
|
-
import { classMap } from
|
|
17
|
-
import Inputmask from
|
|
18
|
-
import { MoniElement, sharedStyles, fieldStyles } from
|
|
19
|
-
import { emitMoniEvent } from
|
|
20
|
-
import
|
|
21
|
-
import
|
|
13
|
+
import { css, html, nothing } from "lit";
|
|
14
|
+
import { customElement, property, query, state } from "lit/decorators.js";
|
|
15
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
16
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
17
|
+
import Inputmask from "inputmask";
|
|
18
|
+
import { MoniElement, sharedStyles, fieldStyles } from "./_base/index.js";
|
|
19
|
+
import { emitMoniEvent } from "../utils/event-emitter.js";
|
|
20
|
+
import "./moni-icon.js";
|
|
21
|
+
import "./moni-progress.js";
|
|
22
22
|
/**
|
|
23
23
|
* Componente Material Design 3 Text Field (Campo de texto).
|
|
24
24
|
*
|
|
@@ -78,72 +78,72 @@ let MoniTextField = class MoniTextField extends MoniElement {
|
|
|
78
78
|
* El nombre del input, enviado con los datos del formulario.
|
|
79
79
|
* @type {string}
|
|
80
80
|
*/
|
|
81
|
-
this.name =
|
|
81
|
+
this.name = "";
|
|
82
82
|
/**
|
|
83
83
|
* El texto de la etiqueta flotante.
|
|
84
84
|
* @type {string}
|
|
85
85
|
*/
|
|
86
|
-
this.label =
|
|
86
|
+
this.label = "";
|
|
87
87
|
/**
|
|
88
88
|
* Variante visual del campo de texto.
|
|
89
89
|
* @type {'filled' | 'outlined' | 'underlined'}
|
|
90
90
|
* @default 'filled'
|
|
91
91
|
*/
|
|
92
|
-
this.variant =
|
|
92
|
+
this.variant = "filled";
|
|
93
93
|
/**
|
|
94
94
|
* Define las dimensiones del campo de texto.
|
|
95
95
|
* @type {'small' | 'medium' | 'large' | 'extra'}
|
|
96
96
|
* @default 'medium'
|
|
97
97
|
*/
|
|
98
|
-
this.size =
|
|
98
|
+
this.size = "medium";
|
|
99
99
|
/**
|
|
100
100
|
* Forma del radio del borde (border-radius) del campo.
|
|
101
101
|
* @type {'round' | 'small-round' | 'no-round'}
|
|
102
102
|
* @default 'no-round'
|
|
103
103
|
*/
|
|
104
|
-
this.shape =
|
|
104
|
+
this.shape = "no-round";
|
|
105
105
|
/**
|
|
106
106
|
* El tipo de input HTML nativo.
|
|
107
107
|
* @type {'text' | 'password' | 'email' | 'number' | 'tel' | 'url' | 'search' | 'date' | 'time' | 'datetime-local' | 'month' | 'week' | 'color'}
|
|
108
108
|
* @default 'text'
|
|
109
109
|
*/
|
|
110
|
-
this.type =
|
|
110
|
+
this.type = "text";
|
|
111
111
|
/**
|
|
112
112
|
* Nombre del icono inicial (leading) (Material Symbols).
|
|
113
113
|
* @type {string}
|
|
114
114
|
*/
|
|
115
|
-
this.icon =
|
|
115
|
+
this.icon = "";
|
|
116
116
|
/**
|
|
117
117
|
* Nombre del icono final (trailing) (Material Symbols).
|
|
118
118
|
* @type {string}
|
|
119
119
|
*/
|
|
120
|
-
this.trailingIcon =
|
|
120
|
+
this.trailingIcon = "";
|
|
121
121
|
/**
|
|
122
122
|
* Prefijo de texto corto mostrado antes del valor del input.
|
|
123
123
|
* @type {string}
|
|
124
124
|
*/
|
|
125
|
-
this.prefix =
|
|
125
|
+
this.prefix = "";
|
|
126
126
|
/**
|
|
127
127
|
* Sufijo de texto corto mostrado después del valor del input.
|
|
128
128
|
* @type {string}
|
|
129
129
|
*/
|
|
130
|
-
this.suffix =
|
|
130
|
+
this.suffix = "";
|
|
131
131
|
/** Icono del botón interactivo ubicado al final del campo. */
|
|
132
|
-
this.suffixButtonIcon =
|
|
132
|
+
this.suffixButtonIcon = "";
|
|
133
133
|
/** Etiqueta accesible del botón suffix. */
|
|
134
|
-
this.suffixButtonLabel =
|
|
134
|
+
this.suffixButtonLabel = "Acción del campo";
|
|
135
135
|
this._hasSuffixSlot = false;
|
|
136
136
|
/**
|
|
137
137
|
* Texto de ayuda mostrado debajo del campo.
|
|
138
138
|
* @type {string}
|
|
139
139
|
*/
|
|
140
|
-
this.helper =
|
|
140
|
+
this.helper = "";
|
|
141
141
|
/**
|
|
142
142
|
* Texto de error mostrado debajo del campo cuando `error` es true.
|
|
143
143
|
* Sobrescribe el texto de ayuda.
|
|
144
144
|
* @type {string}
|
|
145
145
|
*/
|
|
146
|
-
this.errorText =
|
|
146
|
+
this.errorText = "";
|
|
147
147
|
/**
|
|
148
148
|
* Si es true, establece el campo en un estado de error.
|
|
149
149
|
* @type {boolean}
|
|
@@ -163,12 +163,12 @@ let MoniTextField = class MoniTextField extends MoniElement {
|
|
|
163
163
|
* El valor actual del input.
|
|
164
164
|
* @type {string}
|
|
165
165
|
*/
|
|
166
|
-
this.value =
|
|
166
|
+
this.value = "";
|
|
167
167
|
/**
|
|
168
168
|
* Texto de marcador de posición (placeholder) mostrado cuando el input está vacío y la etiqueta es flotante.
|
|
169
169
|
* @type {string}
|
|
170
170
|
*/
|
|
171
|
-
this.placeholder =
|
|
171
|
+
this.placeholder = "";
|
|
172
172
|
/*
|
|
173
173
|
* Restricciones nativas.
|
|
174
174
|
*
|
|
@@ -187,29 +187,29 @@ let MoniTextField = class MoniTextField extends MoniElement {
|
|
|
187
187
|
/** Impide editar el valor sin sacarlo del envío ni atenuarlo como `disabled`. */
|
|
188
188
|
this.readonly = false;
|
|
189
189
|
/** Pista de autocompletado del navegador, por ejemplo `email` o `current-password`. */
|
|
190
|
-
this.autocomplete =
|
|
190
|
+
this.autocomplete = "";
|
|
191
191
|
/** Teclado virtual a mostrar en móvil, por ejemplo `numeric` o `tel`. */
|
|
192
|
-
this.inputmode =
|
|
192
|
+
this.inputmode = "";
|
|
193
193
|
/** Máximo de caracteres aceptados. */
|
|
194
194
|
this.maxlength = null;
|
|
195
195
|
/** Mínimo de caracteres aceptados. */
|
|
196
196
|
this.minlength = null;
|
|
197
197
|
/** Valor mínimo para `number` y los tipos de fecha y hora. */
|
|
198
|
-
this.min =
|
|
198
|
+
this.min = "";
|
|
199
199
|
/** Valor máximo para `number` y los tipos de fecha y hora. */
|
|
200
|
-
this.max =
|
|
200
|
+
this.max = "";
|
|
201
201
|
/** Incremento para `number` y los tipos de fecha y hora. */
|
|
202
|
-
this.step =
|
|
202
|
+
this.step = "";
|
|
203
203
|
/** Expresión regular que debe cumplir el valor. */
|
|
204
|
-
this.pattern =
|
|
204
|
+
this.pattern = "";
|
|
205
205
|
/**
|
|
206
206
|
* Patrón Inputmask. Admite opcionales `[]`, grupos `()`, alternadores `|`,
|
|
207
207
|
* cuantificadores `{n,m}` y los tokens `9`, `a`, `*` y `K` (RUT).
|
|
208
208
|
* @example `99.999.999-K`
|
|
209
209
|
*/
|
|
210
|
-
this.mask =
|
|
210
|
+
this.mask = "";
|
|
211
211
|
/** Alias integrado de Inputmask, por ejemplo `email`, `datetime`, `numeric`, `currency` o `ip`. */
|
|
212
|
-
this.maskAlias =
|
|
212
|
+
this.maskAlias = "";
|
|
213
213
|
/** Opciones avanzadas de Inputmask. También acepta JSON mediante el atributo `mask-options`. */
|
|
214
214
|
this.maskOptions = {};
|
|
215
215
|
this._internals = this.attachInternals();
|
|
@@ -225,12 +225,12 @@ let MoniTextField = class MoniTextField extends MoniElement {
|
|
|
225
225
|
maskOption(nameOrOptions, noRemask = false) {
|
|
226
226
|
if (!this._maskInstance)
|
|
227
227
|
return undefined;
|
|
228
|
-
return typeof nameOrOptions ===
|
|
228
|
+
return typeof nameOrOptions === "string"
|
|
229
229
|
? this._maskInstance.option(nameOrOptions)
|
|
230
230
|
: this._maskInstance.option(nameOrOptions, noRemask);
|
|
231
231
|
}
|
|
232
232
|
getEmptyMask() {
|
|
233
|
-
return this._maskInstance?.getemptymask() ??
|
|
233
|
+
return this._maskInstance?.getemptymask() ?? "";
|
|
234
234
|
}
|
|
235
235
|
hasMaskedValue() {
|
|
236
236
|
return this._maskInstance?.hasMaskedValue() ?? false;
|
|
@@ -266,13 +266,13 @@ let MoniTextField = class MoniTextField extends MoniElement {
|
|
|
266
266
|
if (!this._input || (!this.mask && !this.maskAlias))
|
|
267
267
|
return;
|
|
268
268
|
const options = {
|
|
269
|
-
placeholder:
|
|
269
|
+
placeholder: "",
|
|
270
270
|
...this.maskOptions,
|
|
271
271
|
...(this.mask ? { mask: this.mask } : {}),
|
|
272
272
|
definitions: {
|
|
273
273
|
...(this.maskOptions.definitions ?? {}),
|
|
274
|
-
K: { validator:
|
|
275
|
-
}
|
|
274
|
+
K: { validator: "[0-9Kk]", casing: "upper" },
|
|
275
|
+
},
|
|
276
276
|
};
|
|
277
277
|
const inputmask = this.maskAlias
|
|
278
278
|
? new Inputmask(this.maskAlias, options)
|
|
@@ -294,17 +294,19 @@ let MoniTextField = class MoniTextField extends MoniElement {
|
|
|
294
294
|
*/
|
|
295
295
|
updated(changed) {
|
|
296
296
|
if (this._input) {
|
|
297
|
-
if (changed.has(
|
|
297
|
+
if (changed.has("mask") ||
|
|
298
|
+
changed.has("maskAlias") ||
|
|
299
|
+
changed.has("maskOptions")) {
|
|
298
300
|
this._configureMask();
|
|
299
301
|
}
|
|
300
|
-
if (changed.has(
|
|
302
|
+
if (changed.has("value")) {
|
|
301
303
|
this._input.value = this.value;
|
|
302
304
|
if (this._maskInstance && this.value !== this._input.value) {
|
|
303
305
|
this.value = this._input.value;
|
|
304
306
|
}
|
|
305
307
|
this._internals?.setFormValue?.(this.value);
|
|
306
308
|
}
|
|
307
|
-
if (changed.has(
|
|
309
|
+
if (changed.has("disabled"))
|
|
308
310
|
this._input.disabled = this.disabled;
|
|
309
311
|
}
|
|
310
312
|
this._syncValidity();
|
|
@@ -321,12 +323,12 @@ let MoniTextField = class MoniTextField extends MoniElement {
|
|
|
321
323
|
* el navegador tenga dónde mostrarlo y a dónde mover el foco.
|
|
322
324
|
*/
|
|
323
325
|
/**
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
326
|
+
* API de validación equivalente a la de un control nativo.
|
|
327
|
+
*
|
|
328
|
+
* Los elementos form-associated participan en la validación del formulario,
|
|
329
|
+
* pero no reciben estos miembros automáticamente: hay que exponerlos para que
|
|
330
|
+
* un `moni-text-field` se pueda interrogar igual que un `<input>`.
|
|
331
|
+
*/
|
|
330
332
|
get validity() {
|
|
331
333
|
return this._internals.validity;
|
|
332
334
|
}
|
|
@@ -350,15 +352,23 @@ let MoniTextField = class MoniTextField extends MoniElement {
|
|
|
350
352
|
// Al teclear, `value` no siempre cambia de referencia (máscaras), así que
|
|
351
353
|
// la validez se refresca aquí y no sólo desde `updated()`.
|
|
352
354
|
this._syncValidity();
|
|
353
|
-
emitMoniEvent(this,
|
|
354
|
-
detail: {
|
|
355
|
+
emitMoniEvent(this, "moni-input", {
|
|
356
|
+
detail: {
|
|
357
|
+
value: this.value,
|
|
358
|
+
unmaskedValue: this.unmaskedValue,
|
|
359
|
+
originalEvent: e,
|
|
360
|
+
},
|
|
355
361
|
});
|
|
356
362
|
}
|
|
357
363
|
_handleChange(e) {
|
|
358
364
|
const target = e.target;
|
|
359
365
|
this.value = target.value;
|
|
360
|
-
emitMoniEvent(this,
|
|
361
|
-
detail: {
|
|
366
|
+
emitMoniEvent(this, "moni-change", {
|
|
367
|
+
detail: {
|
|
368
|
+
value: this.value,
|
|
369
|
+
unmaskedValue: this.unmaskedValue,
|
|
370
|
+
originalEvent: e,
|
|
371
|
+
},
|
|
362
372
|
});
|
|
363
373
|
}
|
|
364
374
|
disconnectedCallback() {
|
|
@@ -369,50 +379,77 @@ let MoniTextField = class MoniTextField extends MoniElement {
|
|
|
369
379
|
_handleSuffixClick(event) {
|
|
370
380
|
if (this.disabled)
|
|
371
381
|
return;
|
|
372
|
-
this.dispatchEvent(new CustomEvent(
|
|
382
|
+
this.dispatchEvent(new CustomEvent("suffix-click", {
|
|
373
383
|
detail: { originalEvent: event },
|
|
374
384
|
bubbles: true,
|
|
375
|
-
composed: true
|
|
385
|
+
composed: true,
|
|
376
386
|
}));
|
|
377
387
|
}
|
|
378
388
|
_handleSuffixSlotChange(event) {
|
|
379
389
|
const slot = event.currentTarget;
|
|
380
390
|
this._hasSuffixSlot = slot.assignedElements({ flatten: true }).length > 0;
|
|
381
391
|
}
|
|
382
|
-
static { this.styles = [
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
392
|
+
static { this.styles = [
|
|
393
|
+
sharedStyles,
|
|
394
|
+
fieldStyles,
|
|
395
|
+
css `
|
|
396
|
+
.suffix-action {
|
|
397
|
+
position: absolute;
|
|
398
|
+
inset-inline-end: 0.5rem;
|
|
399
|
+
inset-block-start: calc(var(--_middle) - 1.25rem);
|
|
400
|
+
z-index: 3;
|
|
401
|
+
display: grid;
|
|
402
|
+
place-items: center;
|
|
403
|
+
inline-size: 2.5rem;
|
|
404
|
+
block-size: 2.5rem;
|
|
405
|
+
pointer-events: auto;
|
|
406
|
+
}
|
|
407
|
+
.suffix-action[hidden] {
|
|
408
|
+
display: none;
|
|
409
|
+
}
|
|
410
|
+
.suffix-button {
|
|
411
|
+
all: unset;
|
|
412
|
+
box-sizing: border-box;
|
|
413
|
+
display: grid;
|
|
414
|
+
place-items: center;
|
|
415
|
+
inline-size: 2.5rem;
|
|
416
|
+
block-size: 2.5rem;
|
|
417
|
+
border-radius: 50%;
|
|
418
|
+
color: var(--on-surface-variant);
|
|
419
|
+
cursor: pointer;
|
|
420
|
+
transition:
|
|
421
|
+
background-color 150ms ease,
|
|
422
|
+
transform 150ms ease;
|
|
423
|
+
}
|
|
424
|
+
.suffix-button:hover {
|
|
425
|
+
background: color-mix(in srgb, currentColor 8%, transparent);
|
|
426
|
+
}
|
|
427
|
+
.suffix-button:active {
|
|
428
|
+
background: color-mix(in srgb, currentColor 12%, transparent);
|
|
429
|
+
transform: scale(0.92);
|
|
430
|
+
}
|
|
431
|
+
.suffix-button:focus-visible {
|
|
432
|
+
outline: 0.125rem solid var(--primary);
|
|
433
|
+
outline-offset: 0.125rem;
|
|
434
|
+
}
|
|
435
|
+
.suffix-button:disabled {
|
|
436
|
+
opacity: 0.38;
|
|
437
|
+
cursor: default;
|
|
438
|
+
}
|
|
439
|
+
.suffix-button moni-icon {
|
|
440
|
+
--moni-icon-size: 1.5rem;
|
|
441
|
+
}
|
|
442
|
+
::slotted([slot="suffix"]) {
|
|
443
|
+
pointer-events: auto;
|
|
444
|
+
}
|
|
445
|
+
.field.suffix-action-field > input {
|
|
446
|
+
padding-inline-end: 3.5rem;
|
|
447
|
+
}
|
|
448
|
+
.field.suffix-action-field > input:focus {
|
|
449
|
+
padding-inline-end: 3.4375rem;
|
|
450
|
+
}
|
|
451
|
+
`,
|
|
452
|
+
]; }
|
|
416
453
|
/**
|
|
417
454
|
* Renderiza el campo de texto con animación de etiqueta flotante, iconos iniciales/finales, y texto de ayuda.
|
|
418
455
|
*
|
|
@@ -437,107 +474,114 @@ let MoniTextField = class MoniTextField extends MoniElement {
|
|
|
437
474
|
*/
|
|
438
475
|
render() {
|
|
439
476
|
const hasLeading = Boolean(this.icon) || Boolean(this.prefix);
|
|
440
|
-
const hasTrailing = Boolean(this.trailingIcon) ||
|
|
477
|
+
const hasTrailing = Boolean(this.trailingIcon) ||
|
|
478
|
+
Boolean(this.suffix) ||
|
|
479
|
+
Boolean(this.suffixButtonIcon) ||
|
|
480
|
+
this._hasSuffixSlot;
|
|
441
481
|
const isActive = Boolean(this.value) || Boolean(this.placeholder);
|
|
442
482
|
const fieldClasses = {
|
|
443
483
|
field: true,
|
|
444
484
|
label: Boolean(this.label),
|
|
445
|
-
fill: this.variant ===
|
|
446
|
-
border: this.variant ===
|
|
447
|
-
small: this.size ===
|
|
448
|
-
large: this.size ===
|
|
449
|
-
extra: this.size ===
|
|
485
|
+
fill: this.variant === "filled",
|
|
486
|
+
border: this.variant === "outlined",
|
|
487
|
+
small: this.size === "small",
|
|
488
|
+
large: this.size === "large",
|
|
489
|
+
extra: this.size === "extra",
|
|
450
490
|
prefix: hasLeading,
|
|
451
491
|
suffix: hasTrailing,
|
|
452
|
-
|
|
492
|
+
"suffix-action-field": Boolean(this.suffixButtonIcon) || this._hasSuffixSlot,
|
|
453
493
|
invalid: this.error,
|
|
454
|
-
round: this.shape ===
|
|
455
|
-
|
|
456
|
-
square: this.shape ===
|
|
494
|
+
round: this.shape === "round" && this.variant !== "underlined",
|
|
495
|
+
"small-round": this.shape === "small-round" && this.variant !== "underlined",
|
|
496
|
+
square: this.shape === "no-round",
|
|
457
497
|
};
|
|
458
|
-
const placeholder = this.placeholder || (this.label ?
|
|
498
|
+
const placeholder = this.placeholder || (this.label ? " " : "");
|
|
459
499
|
const leading = this.icon
|
|
460
|
-
? html `<i class="leading-icon" part="leading-icon"
|
|
461
|
-
|
|
462
|
-
|
|
500
|
+
? html `<i class="leading-icon" part="leading-icon"
|
|
501
|
+
><moni-icon name="${this.icon}"></moni-icon
|
|
502
|
+
></i>`
|
|
463
503
|
: this.prefix
|
|
464
|
-
? html `<span class="leading-icon" part="prefix"
|
|
465
|
-
>${this.prefix}</span
|
|
466
|
-
>`
|
|
504
|
+
? html `<span class="leading-icon" part="prefix">${this.prefix}</span>`
|
|
467
505
|
: nothing;
|
|
468
506
|
const trailing = this.loading
|
|
469
|
-
? html `<i class="trailing-icon" part="trailing-icon"
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
507
|
+
? html `<i class="trailing-icon" part="trailing-icon"
|
|
508
|
+
><moni-progress
|
|
509
|
+
variant="circular"
|
|
510
|
+
indeterminate
|
|
511
|
+
size="small"
|
|
512
|
+
style="inline-size: 1.25rem; block-size: 1.25rem; color: currentColor;"
|
|
513
|
+
></moni-progress
|
|
514
|
+
></i>`
|
|
477
515
|
: this.suffixButtonIcon
|
|
478
|
-
? html `<span class="suffix-action" part="suffix-action">
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
516
|
+
? html `<span class="suffix-action" part="suffix-action">
|
|
517
|
+
<button
|
|
518
|
+
type="button"
|
|
519
|
+
class="suffix-button"
|
|
520
|
+
part="suffix-button"
|
|
521
|
+
aria-label=${this.suffixButtonLabel}
|
|
522
|
+
?disabled=${this.disabled}
|
|
523
|
+
@click=${this._handleSuffixClick}
|
|
524
|
+
>
|
|
525
|
+
<moni-icon name=${this.suffixButtonIcon}></moni-icon>
|
|
526
|
+
</button>
|
|
527
|
+
</span>`
|
|
488
528
|
: this.trailingIcon
|
|
489
|
-
? html `<i class="trailing-icon" part="trailing-icon"
|
|
490
|
-
|
|
491
|
-
|
|
529
|
+
? html `<i class="trailing-icon" part="trailing-icon"
|
|
530
|
+
><moni-icon name="${this.trailingIcon}"></moni-icon
|
|
531
|
+
></i>`
|
|
492
532
|
: this.suffix
|
|
493
|
-
? html `<span class="trailing-icon" part="suffix"
|
|
494
|
-
|
|
495
|
-
|
|
533
|
+
? html `<span class="trailing-icon" part="suffix"
|
|
534
|
+
>${this.suffix}</span
|
|
535
|
+
>`
|
|
496
536
|
: nothing;
|
|
497
|
-
return html `<div class=${classMap(fieldClasses)} part="field">
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
? html `<label
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
: nothing}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
+
return html `<div class=${classMap(fieldClasses)} part="field">
|
|
538
|
+
${leading}
|
|
539
|
+
<input
|
|
540
|
+
id="input"
|
|
541
|
+
part="input"
|
|
542
|
+
type=${this.type}
|
|
543
|
+
placeholder=${placeholder}
|
|
544
|
+
?disabled=${this.disabled}
|
|
545
|
+
?required=${this.required}
|
|
546
|
+
?readonly=${this.readonly}
|
|
547
|
+
autocomplete=${ifDefined(this.autocomplete || undefined)}
|
|
548
|
+
inputmode=${ifDefined(this.inputmode || undefined)}
|
|
549
|
+
maxlength=${ifDefined(this.maxlength ?? undefined)}
|
|
550
|
+
minlength=${ifDefined(this.minlength ?? undefined)}
|
|
551
|
+
min=${ifDefined(this.min || undefined)}
|
|
552
|
+
max=${ifDefined(this.max || undefined)}
|
|
553
|
+
step=${ifDefined(this.step || undefined)}
|
|
554
|
+
pattern=${ifDefined(this.pattern || undefined)}
|
|
555
|
+
.value=${this.value}
|
|
556
|
+
name=${ifDefined(this.name || undefined)}
|
|
557
|
+
class=${isActive ? "active" : ""}
|
|
558
|
+
@input=${this._handleInput}
|
|
559
|
+
@change=${this._handleChange}
|
|
560
|
+
/>
|
|
561
|
+
${this.label
|
|
562
|
+
? html `<label
|
|
563
|
+
for="input"
|
|
564
|
+
part="label"
|
|
565
|
+
class=${classMap({ active: isActive })}
|
|
566
|
+
>${this.label}</label
|
|
567
|
+
>`
|
|
568
|
+
: nothing}
|
|
569
|
+
${trailing}
|
|
570
|
+
<span
|
|
571
|
+
class="suffix-action"
|
|
572
|
+
part="suffix-action"
|
|
573
|
+
?hidden=${Boolean(this.suffixButtonIcon) || !this._hasSuffixSlot}
|
|
574
|
+
>
|
|
575
|
+
<slot name="suffix" @slotchange=${this._handleSuffixSlotChange}></slot>
|
|
576
|
+
</span>
|
|
577
|
+
${this.error
|
|
578
|
+
? html `<output part="helper" class="invalid"
|
|
579
|
+
>${this.errorText || this.helper}</output
|
|
580
|
+
>`
|
|
537
581
|
: this.helper
|
|
538
582
|
? html `<output part="helper">${this.helper}</output>`
|
|
539
|
-
: nothing}
|
|
540
|
-
|
|
583
|
+
: nothing}
|
|
584
|
+
</div>`;
|
|
541
585
|
}
|
|
542
586
|
};
|
|
543
587
|
__decorate([
|
|
@@ -562,7 +606,7 @@ __decorate([
|
|
|
562
606
|
property({ reflect: true })
|
|
563
607
|
], MoniTextField.prototype, "icon", void 0);
|
|
564
608
|
__decorate([
|
|
565
|
-
property({ reflect: true, attribute:
|
|
609
|
+
property({ reflect: true, attribute: "trailing-icon" })
|
|
566
610
|
], MoniTextField.prototype, "trailingIcon", void 0);
|
|
567
611
|
__decorate([
|
|
568
612
|
property({ reflect: true })
|
|
@@ -571,10 +615,10 @@ __decorate([
|
|
|
571
615
|
property({ reflect: true })
|
|
572
616
|
], MoniTextField.prototype, "suffix", void 0);
|
|
573
617
|
__decorate([
|
|
574
|
-
property({ reflect: true, attribute:
|
|
618
|
+
property({ reflect: true, attribute: "suffix-button-icon" })
|
|
575
619
|
], MoniTextField.prototype, "suffixButtonIcon", void 0);
|
|
576
620
|
__decorate([
|
|
577
|
-
property({ reflect: true, attribute:
|
|
621
|
+
property({ reflect: true, attribute: "suffix-button-label" })
|
|
578
622
|
], MoniTextField.prototype, "suffixButtonLabel", void 0);
|
|
579
623
|
__decorate([
|
|
580
624
|
state()
|
|
@@ -583,7 +627,7 @@ __decorate([
|
|
|
583
627
|
property({ reflect: true })
|
|
584
628
|
], MoniTextField.prototype, "helper", void 0);
|
|
585
629
|
__decorate([
|
|
586
|
-
property({ reflect: true, attribute:
|
|
630
|
+
property({ reflect: true, attribute: "error-text" })
|
|
587
631
|
], MoniTextField.prototype, "errorText", void 0);
|
|
588
632
|
__decorate([
|
|
589
633
|
property({ type: Boolean, reflect: true })
|
|
@@ -634,11 +678,11 @@ __decorate([
|
|
|
634
678
|
property({ reflect: true })
|
|
635
679
|
], MoniTextField.prototype, "mask", void 0);
|
|
636
680
|
__decorate([
|
|
637
|
-
property({ reflect: true, attribute:
|
|
681
|
+
property({ reflect: true, attribute: "mask-alias" })
|
|
638
682
|
], MoniTextField.prototype, "maskAlias", void 0);
|
|
639
683
|
__decorate([
|
|
640
684
|
property({
|
|
641
|
-
attribute:
|
|
685
|
+
attribute: "mask-options",
|
|
642
686
|
converter: {
|
|
643
687
|
fromAttribute: (value) => {
|
|
644
688
|
if (!value)
|
|
@@ -650,15 +694,15 @@ __decorate([
|
|
|
650
694
|
return {};
|
|
651
695
|
}
|
|
652
696
|
},
|
|
653
|
-
toAttribute: (value) => JSON.stringify(value ?? {})
|
|
654
|
-
}
|
|
697
|
+
toAttribute: (value) => JSON.stringify(value ?? {}),
|
|
698
|
+
},
|
|
655
699
|
})
|
|
656
700
|
], MoniTextField.prototype, "maskOptions", void 0);
|
|
657
701
|
__decorate([
|
|
658
|
-
query(
|
|
702
|
+
query("input")
|
|
659
703
|
], MoniTextField.prototype, "_input", void 0);
|
|
660
704
|
MoniTextField = __decorate([
|
|
661
|
-
customElement(
|
|
705
|
+
customElement("moni-text-field")
|
|
662
706
|
], MoniTextField);
|
|
663
707
|
export { MoniTextField };
|
|
664
708
|
export default MoniTextField;
|