energy-components 2.5.1 → 2.6.0

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.
@@ -1,4 +1,4 @@
1
- import { defineComponent as de, ref as y, useSlots as ce, computed as o, watch as L, onMounted as fe, onBeforeUnmount as pe, openBlock as r, createElementBlock as h, normalizeClass as x, createElementVNode as g, renderSlot as b, createBlock as E, createCommentVNode as d, mergeProps as O, toHandlers as U, createTextVNode as W, toDisplayString as N, withModifiers as q, createVNode as H } from "vue";
1
+ import { defineComponent as de, ref as y, useSlots as ce, computed as i, watch as L, onMounted as fe, onBeforeUnmount as pe, openBlock as o, createElementBlock as h, normalizeClass as _, createElementVNode as g, renderSlot as b, createBlock as E, createCommentVNode as d, mergeProps as O, toHandlers as U, createTextVNode as W, toDisplayString as N, withModifiers as q, createVNode as H } from "vue";
2
2
  import { g as me } from "./getInstance-GhoEcxLF.js";
3
3
  import { R as G, s as ve } from "./icon-svg-CW3eQRcp.js";
4
4
  import F from "./actionButton.es.js";
@@ -6,10 +6,10 @@ import { _ as ye } from "./_plugin-vue_export-helper-CHgC5LLL.js";
6
6
  import './style/textField.css';const he = { class: "rds-e-textfield__input-container" }, ge = {
7
7
  key: 0,
8
8
  class: "rds-e-textfield__prefix"
9
- }, _e = ["data-value"], xe = ["id", "type", "maxlength", "minlength", "disabled", "value", "autocomplete", "readonly", "name", "required", "inputmode", "pattern", "min", "max", "step", "enterkeyhint", "spellcheck", "autocapitalize", "aria-invalid", "aria-describedby"], be = {
9
+ }, xe = ["data-value"], _e = ["id", "type", "maxlength", "minlength", "disabled", "value", "autocomplete", "readonly", "tabindex", "name", "required", "inputmode", "pattern", "min", "max", "step", "enterkeyhint", "spellcheck", "autocapitalize", "aria-invalid", "aria-describedby"], be = {
10
10
  key: 1,
11
11
  class: "rds-e-textfield__suffix"
12
- }, we = ["for"], Se = {
12
+ }, Se = ["for"], we = {
13
13
  key: 1,
14
14
  class: "rds-e-textfield__icon rds-e-textfield__icon--right"
15
15
  }, ke = ["aria-label"], Ve = {
@@ -82,12 +82,30 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
82
82
  default: !1
83
83
  },
84
84
  /**
85
- * Indica si el campo de entrada es de solo lectura o no.
85
+ * Estado semántico de solo lectura. Añade el atributo HTML `readonly` al input, lo que
86
+ * impide la edición y lo anuncia a los lectores de pantalla como "solo lectura".
87
+ *
88
+ * **No cambia el aspecto visual del campo.** Si además se necesita el estilo visual
89
+ * (fondo gris, sin iconos, cursor texto), activa también `readonlyStyle`.
90
+ * Ambas props son independientes y pueden usarse juntas o por separado.
86
91
  */
87
92
  readonly: {
88
93
  type: Boolean,
89
94
  default: !1
90
95
  },
96
+ /**
97
+ * Estilo visual de solo lectura: fondo gris, borde por defecto, cursor texto y sin iconos
98
+ * ni elementos accionables. El campo parece no editable visualmente.
99
+ *
100
+ * **No añade el atributo HTML `readonly`** ni semántica de accesibilidad.
101
+ * Para bloquear la edición funcionalmente y anunciarlo a lectores de pantalla,
102
+ * activa también `:readonly="true"`.
103
+ * Ambas props son independientes y pueden usarse juntas o por separado.
104
+ */
105
+ readonlyStyle: {
106
+ type: Boolean,
107
+ default: !1
108
+ },
91
109
  /**
92
110
  * Número máximo de caracteres permitidos en el campo de entrada.
93
111
  * Si no se especifica, el componente no establecerá atributo maxlength (sin límite impuesto por la librería).
@@ -96,7 +114,7 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
96
114
  maxLength: {
97
115
  type: Number,
98
116
  required: !1,
99
- validator: (i) => i == null ? !0 : typeof i != "number" || Number.isNaN(i) ? (console.info("El valor de maxLength debe ser un número"), !1) : i < 0 ? (console.info("El valor de maxLength no puede ser menor a 0"), !1) : !0
117
+ validator: (n) => n == null ? !0 : typeof n != "number" || Number.isNaN(n) ? (console.info("El valor de maxLength debe ser un número"), !1) : n < 0 ? (console.info("El valor de maxLength no puede ser menor a 0"), !1) : !0
100
118
  },
101
119
  /**
102
120
  * Número mínimo de caracteres permitidos en el campo de entrada.
@@ -105,7 +123,7 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
105
123
  minLength: {
106
124
  type: Number,
107
125
  required: !1,
108
- validator: (i) => i == null ? !0 : typeof i != "number" || Number.isNaN(i) ? (console.info("El valor de minLength debe ser un número"), !1) : i < 0 ? (console.info("El valor de minLength no puede ser menor a 0"), !1) : !0
126
+ validator: (n) => n == null ? !0 : typeof n != "number" || Number.isNaN(n) ? (console.info("El valor de minLength debe ser un número"), !1) : n < 0 ? (console.info("El valor de minLength no puede ser menor a 0"), !1) : !0
109
127
  },
110
128
  /**
111
129
  * Tipo del input HTML. Por defecto 'text'.
@@ -114,9 +132,9 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
114
132
  type: {
115
133
  type: String,
116
134
  default: "text",
117
- validator: (i) => {
118
- const c = ["text", "number", "password", "email", "tel", "url"], f = c.includes(i);
119
- return f || console.warn(`[RDSTextfield]: El valor de la prop 'type' debe ser uno de: ${c.join(", ")}. Valor recibido: ${i}`), f;
135
+ validator: (n) => {
136
+ const c = ["text", "number", "password", "email", "tel", "url"], f = c.includes(n);
137
+ return f || console.warn(`[RDSTextfield]: El valor de la prop 'type' debe ser uno de: ${c.join(", ")}. Valor recibido: ${n}`), f;
120
138
  }
121
139
  },
122
140
  /**
@@ -192,9 +210,9 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
192
210
  autocomplete: {
193
211
  type: String,
194
212
  default: "off",
195
- validator: (i, c) => {
213
+ validator: (n, c) => {
196
214
  const f = ["new-password", "current-password", "off"];
197
- return (c.password || c.type === "password") && !f.includes(i) ? (console.info(`[RDSTextfield]: El valor de autocomplete para un campo de contraseña debe ser uno de los siguientes: ${f.join(", ")}`), !1) : !0;
215
+ return (c.password || c.type === "password") && !f.includes(n) ? (console.info(`[RDSTextfield]: El valor de autocomplete para un campo de contraseña debe ser uno de los siguientes: ${f.join(", ")}`), !1) : !0;
198
216
  }
199
217
  },
200
218
  /** Atributos adicionales del input */
@@ -243,6 +261,11 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
243
261
  type: Boolean,
244
262
  required: !1
245
263
  },
264
+ /** Índice de tabulación del input nativo. */
265
+ inputTabindex: {
266
+ type: [String, Number],
267
+ required: !1
268
+ },
246
269
  /** Control de capitalización automática del navegador en inputs text. */
247
270
  autocapitalize: {
248
271
  type: String,
@@ -250,17 +273,17 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
250
273
  }
251
274
  },
252
275
  emits: ["update:modelValue", "clear", "keydown", "keyup", "keypress", "change"],
253
- setup(i, { expose: c, emit: f }) {
254
- const e = i, p = f, a = y(null), m = y(!1), u = y(!1), w = y(!1), S = y(!1), J = me(), _ = y(""), n = y(!1), $ = ce(), B = o(() => !!e.prefix || !!$.prefix), T = o(() => !!e.suffix || !!$.suffix), C = () => {
276
+ setup(n, { expose: c, emit: f }) {
277
+ const e = n, p = f, a = y(null), m = y(!1), u = y(!1), S = y(!1), w = y(!1), J = me(), x = y(""), r = y(!1), $ = ce(), B = i(() => !!e.prefix || !!$.prefix), T = i(() => !!e.suffix || !!$.suffix), C = () => {
255
278
  if (a.value)
256
279
  if (e.type === "number") {
257
280
  const t = a.value, l = t.value !== "" || t.selectionStart !== null && t.selectionStart > 0 || t.validity.badInput;
258
- n.value = l;
281
+ r.value = l;
259
282
  } else
260
- n.value = a.value.value !== "";
283
+ r.value = a.value.value !== "";
261
284
  }, Q = () => {
262
- !e.disabled && !e.readonly && a.value && a.value.focus();
263
- }, I = o(() => e.id !== void 0 && e.id !== null ? String(e.id) : `text-field-${J}`), D = o(() => e.helper || e.error ? `${I.value}-helper` : void 0), v = o(() => e.password || e.type === "password"), X = o(() => v.value ? m.value ? "text" : "password" : ["text", "number", "password", "email", "tel", "url"].includes(e.type) ? e.type : "text"), Y = o(() => e.autocomplete), Z = o(() => {
285
+ !e.disabled && !e.readonly && !e.readonlyStyle && a.value && a.value.focus();
286
+ }, I = i(() => e.id !== void 0 && e.id !== null ? String(e.id) : `text-field-${J}`), D = i(() => e.helper || e.error ? `${I.value}-helper` : void 0), v = i(() => e.password || e.type === "password"), X = i(() => v.value ? m.value ? "text" : "password" : ["text", "number", "password", "email", "tel", "url"].includes(e.type) ? e.type : "text"), Y = i(() => e.autocomplete), Z = i(() => {
264
287
  const t = e.modelValue === null || e.modelValue === void 0 ? "" : String(e.modelValue);
265
288
  return v.value && !m.value ? "•".repeat(t.length) : t;
266
289
  }), ee = (t) => {
@@ -268,9 +291,9 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
268
291
  let k = l.value;
269
292
  if (e.type === "number") {
270
293
  const V = l.value !== "" || l.selectionStart !== null && l.selectionStart > 0 || l.validity.badInput;
271
- n.value = V;
294
+ r.value = V;
272
295
  } else
273
- n.value = l.value !== "";
296
+ r.value = l.value !== "";
274
297
  if (e.type === "number") {
275
298
  if (l.value.trim() === "")
276
299
  k = null;
@@ -278,37 +301,37 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
278
301
  const V = Number.parseFloat(l.value);
279
302
  k = Number.isNaN(V) ? l.value : V;
280
303
  }
281
- j === "" && !l.validity.badInput && (n.value = !1);
304
+ j === "" && !l.validity.badInput && (r.value = !1);
282
305
  } else l.value === "" && e.modelValue === null && (k = null);
283
306
  p("update:modelValue", k), C();
284
307
  }, te = () => {
285
- S.value = !0;
308
+ w.value = !0;
286
309
  }, R = () => {
287
310
  const t = a.value?.value.trim() || "";
288
- n.value = t !== "", u.value = !1, w.value = !1, S.value = !1, t === "" && (_.value = ""), C();
311
+ r.value = t !== "", u.value = !1, S.value = !1, w.value = !1, t === "" && (x.value = ""), C();
289
312
  }, z = () => {
290
- u.value = !0, w.value = !S.value, S.value = !1;
313
+ u.value = !0, S.value = !w.value, w.value = !1;
291
314
  }, le = (t) => {
292
315
  p("keydown", t);
293
316
  }, ae = (t) => {
294
317
  p("keyup", t);
295
- }, ie = (t) => {
318
+ }, ne = (t) => {
296
319
  p("keypress", t);
297
- }, oe = (t) => {
320
+ }, ie = (t) => {
298
321
  p("change", t);
299
- }, ne = o(() => {
322
+ }, re = i(() => {
300
323
  const t = [];
301
- _.value && t.push(_.value);
324
+ x.value && t.push(x.value);
302
325
  const l = e.modelValue !== null && String(e.modelValue).trim().length > 0;
303
- return (B.value || T.value || l || n.value || u.value) && t.push("rds-e-textfield--filled"), e.error && t.push("rds-e-textfield--error"), e.disabled && t.push("rds-e-textfield--disabled"), e.fullWidth && t.push("rds-e-textfield--full-width"), e.compact && t.push("rds-e-textfield--compact"), u.value && t.push("rds-e-textfield--focused"), e.readonly && t.push("rds-e-textfield--readonly"), t.join(" ");
326
+ return (B.value || T.value || l || r.value || u.value) && t.push("rds-e-textfield--filled"), e.error && t.push("rds-e-textfield--error"), e.disabled && t.push("rds-e-textfield--disabled"), e.fullWidth && t.push("rds-e-textfield--full-width"), e.compact && t.push("rds-e-textfield--compact"), u.value && t.push("rds-e-textfield--focused"), e.readonly && t.push("rds-e-textfield--readonly"), e.readonlyStyle && t.push("rds-e-textfield--readonly-style"), t.join(" ");
304
327
  });
305
328
  L(
306
329
  () => e.modelValue,
307
330
  (t) => {
308
- t !== null && String(t).length > 0 && (_.value = ""), (t === "" || t === null) && !u.value && (n.value = !1);
331
+ t !== null && String(t).length > 0 && (x.value = ""), (t === "" || t === null) && !u.value && (r.value = !1);
309
332
  }
310
333
  );
311
- const s = o(() => {
334
+ const s = i(() => {
312
335
  const t = {
313
336
  name: e.icon,
314
337
  class: "",
@@ -349,7 +372,7 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
349
372
  }, K = (t) => {
350
373
  const l = a.value;
351
374
  if (!l) return;
352
- l.matches(":-webkit-autofill") && t.animationName.startsWith("onAutoFillStart") && l.value.trim().length > 0 && (_.value = "rds-e-textfield--filled", n.value = !0);
375
+ l.matches(":-webkit-autofill") && t.animationName.startsWith("onAutoFillStart") && l.value.trim().length > 0 && (x.value = "rds-e-textfield--filled", r.value = !0);
353
376
  };
354
377
  fe(() => {
355
378
  a.value && (a.value.addEventListener("animationstart", K), C());
@@ -363,54 +386,54 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
363
386
  a.value && (a.value.blur(), R());
364
387
  }
365
388
  });
366
- const re = () => {
389
+ const oe = () => {
367
390
  m.value = !m.value;
368
391
  }, se = () => {
369
392
  const t = e.type === "number";
370
- p("update:modelValue", t ? null : ""), a.value && (a.value.value = ""), u.value = !1, n.value = !1, a.value && a.value.blur(), p("clear");
393
+ p("update:modelValue", t ? null : ""), a.value && (a.value.value = ""), u.value = !1, r.value = !1, a.value && a.value.blur(), p("clear");
371
394
  }, M = (t) => {
372
395
  (t.key === "Enter" || t.key === " ") && t.currentTarget?.click();
373
- }, ue = o(() => m.value ? "Ocultar contraseña" : "Mostrar contraseña");
396
+ }, ue = i(() => m.value ? "Ocultar contraseña" : "Mostrar contraseña");
374
397
  return L(
375
398
  () => e.password,
376
399
  (t) => {
377
400
  t && console.warn('[RDSTextfield]: Deprecado `password`. Usa type="password" + toggleVisibility. Esta prop será eliminada en próximas versiones.');
378
401
  },
379
402
  { immediate: !0 }
380
- ), (t, l) => (r(), h("div", {
381
- class: x(["rds-e-textfield", ne.value])
403
+ ), (t, l) => (o(), h("div", {
404
+ class: _(["rds-e-textfield", re.value])
382
405
  }, [
383
406
  g("div", {
384
- class: x(["rds-e-textfield__container", {
385
- "rds-e-textfield__container--keyboard-focus": w.value,
386
- "rds-e-textfield__container--active": u.value && !w.value
407
+ class: _(["rds-e-textfield__container", {
408
+ "rds-e-textfield__container--keyboard-focus": S.value,
409
+ "rds-e-textfield__container--active": u.value && !S.value
387
410
  }]),
388
411
  onMousedown: te
389
412
  }, [
390
- B.value ? d("", !0) : b(t.$slots, "left-icon", { key: 0 }, () => [
391
- e.loading ? (r(), E(G, {
413
+ !B.value && !e.readonlyStyle ? b(t.$slots, "left-icon", { key: 0 }, () => [
414
+ e.loading ? (o(), E(G, {
392
415
  key: 0,
393
416
  name: "loading",
394
417
  class: "rds-e-textfield__icon--loading"
395
418
  })) : d("", !0),
396
- s.value.left.name && A(s.value.left.name) && !i.loading ? (r(), E(G, O({
419
+ s.value.left.name && A(s.value.left.name) && !n.loading ? (o(), E(G, O({
397
420
  key: 1,
398
421
  class: ["rds-e-textfield__icon rds-e-textfield__icon--left", { "rds-e-textfield__icon--hidden": u.value }],
399
422
  "aria-hidden": "true"
400
423
  }, s.value.left, U(s.value.left.events)), null, 16, ["class"])) : d("", !0)
401
- ], !0),
424
+ ], !0) : d("", !0),
402
425
  g("div", he, [
403
426
  g("div", {
404
427
  class: "rds-e-textfield__input-wrapper",
405
428
  onClick: Q
406
429
  }, [
407
- B.value ? (r(), h("span", ge, [
430
+ B.value ? (o(), h("span", ge, [
408
431
  b(t.$slots, "prefix", {}, () => [
409
432
  W(N(e.prefix), 1)
410
433
  ], !0)
411
434
  ])) : d("", !0),
412
435
  g("div", {
413
- class: x(["rds-e-textfield__input-sizer", { "rds-e-textfield__input-sizer--grow": !T.value }]),
436
+ class: _(["rds-e-textfield__input-sizer", { "rds-e-textfield__input-sizer--grow": !T.value }]),
414
437
  "data-value": Z.value
415
438
  }, [
416
439
  g("input", {
@@ -425,6 +448,7 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
425
448
  value: e.modelValue === null ? "" : e.modelValue,
426
449
  autocomplete: Y.value,
427
450
  readonly: e.readonly,
451
+ tabindex: e.inputTabindex,
428
452
  name: e.name,
429
453
  required: e.required,
430
454
  inputmode: e.inputmode,
@@ -442,11 +466,11 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
442
466
  onFocus: z,
443
467
  onKeydown: le,
444
468
  onKeyup: ae,
445
- onKeypress: ie,
446
- onChange: oe
447
- }, null, 40, xe)
448
- ], 10, _e),
449
- T.value ? (r(), h("span", be, [
469
+ onKeypress: ne,
470
+ onChange: ie
471
+ }, null, 40, _e)
472
+ ], 10, xe),
473
+ T.value ? (o(), h("span", be, [
450
474
  b(t.$slots, "suffix", {}, () => [
451
475
  W(N(e.suffix), 1)
452
476
  ], !0)
@@ -454,17 +478,17 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
454
478
  ]),
455
479
  g("label", {
456
480
  for: I.value,
457
- class: x(["rds-e-textfield__label", e.disabled ? "rds-e-textfield__label--disabled" : ""])
458
- }, N(e.label), 11, we)
481
+ class: _(["rds-e-textfield__label", e.disabled ? "rds-e-textfield__label--disabled" : ""])
482
+ }, N(e.label), 11, Se)
459
483
  ]),
460
- v.value && e.toggleVisibility || e.clearable || s.value.right.name || t.$slots["right-icon"] ? (r(), h("span", Se, [
484
+ !e.readonlyStyle && (v.value && e.toggleVisibility || e.clearable || s.value.right.name || t.$slots["right-icon"]) ? (o(), h("span", we, [
461
485
  b(t.$slots, "right-icon", {}, () => [
462
- v.value && e.toggleVisibility ? (r(), h("button", {
486
+ v.value && e.toggleVisibility ? (o(), h("button", {
463
487
  key: 0,
464
488
  type: "button",
465
489
  class: "rds-e-textfield__icon rds-e-textfield__icon--right rds-e-textfield__icon--password",
466
490
  "aria-label": ue.value,
467
- onClick: q(re, ["stop"]),
491
+ onClick: q(oe, ["stop"]),
468
492
  onKeydown: q(M, ["stop", "prevent"])
469
493
  }, [
470
494
  H(F, {
@@ -472,7 +496,7 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
472
496
  variant: "ghost",
473
497
  small: ""
474
498
  }, null, 8, ["icon"])
475
- ], 40, ke)) : e.clearable ? (r(), h("button", {
499
+ ], 40, ke)) : e.clearable ? (o(), h("button", {
476
500
  key: 1,
477
501
  type: "button",
478
502
  class: "rds-e-textfield__icon rds-e-textfield__icon--right rds-e-textfield__icon--clear",
@@ -485,7 +509,7 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
485
509
  variant: "ghost",
486
510
  small: ""
487
511
  })
488
- ], 32)) : s.value.right.name && A(s.value.right.name) ? (r(), E(F, O({
512
+ ], 32)) : s.value.right.name && A(s.value.right.name) ? (o(), E(F, O({
489
513
  key: 2,
490
514
  icon: s.value.right.name,
491
515
  variant: "ghost",
@@ -494,17 +518,17 @@ import './style/textField.css';const he = { class: "rds-e-textfield__input-conta
494
518
  ], !0)
495
519
  ])) : d("", !0)
496
520
  ], 34),
497
- e.helper || e.error ? (r(), h("div", Ve, [
521
+ e.helper || e.error ? (o(), h("div", Ve, [
498
522
  b(t.$slots, "helper-text", {}, () => [
499
523
  g("span", {
500
524
  id: D.value,
501
- class: x(e.error ? "rds-e-textfield__helper--error" : "")
525
+ class: _(e.error ? "rds-e-textfield__helper--error" : "")
502
526
  }, N(e.helperText), 11, Ne)
503
527
  ], !0)
504
528
  ])) : d("", !0)
505
529
  ], 2));
506
530
  }
507
- }), Ee = /* @__PURE__ */ ye(qe, [["__scopeId", "data-v-5c6648f7"]]);
531
+ }), Ee = /* @__PURE__ */ ye(qe, [["__scopeId", "data-v-193ba6dd"]]);
508
532
  export {
509
533
  Ee as default
510
534
  };