energy-components 2.6.0 → 2.7.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,11 +1,11 @@
1
- import { defineComponent as W, ref as _, computed as u, openBlock as b, createElementBlock as x, withModifiers as c, normalizeClass as k, createElementVNode as o, renderSlot as q, createVNode as L, toDisplayString as D, createCommentVNode as M } from "vue";
2
- import { g as z } from "./getInstance-GhoEcxLF.js";
3
- import { R as A } from "./icon-svg-CW3eQRcp.js";
4
- import { _ as U } from "./_plugin-vue_export-helper-CHgC5LLL.js";
5
- import './style/dragAndDrop.css';const V = ["id", "accept", "multiple", "disabled"], O = ["for"], P = { class: "rds-e-drag-and-drop__icon-wrapper" }, j = { class: "rds-e-drag-and-drop__text-container" }, G = { class: "rds-e-drag-and-drop__text" }, H = {
1
+ import { defineComponent as q, ref as x, computed as i, openBlock as y, createElementBlock as D, withModifiers as c, withKeys as w, normalizeClass as M, createElementVNode as o, renderSlot as z, createVNode as U, toDisplayString as g, createCommentVNode as V } from "vue";
2
+ import { g as K } from "./getInstance-GhoEcxLF.js";
3
+ import { R as O } from "./icon-svg-CW3eQRcp.js";
4
+ import { _ as P } from "./_plugin-vue_export-helper-CHgC5LLL.js";
5
+ import './style/dragAndDrop.css';const j = ["tabindex", "aria-disabled", "aria-label"], G = ["id", "accept", "multiple", "disabled"], H = ["for"], J = { class: "rds-e-drag-and-drop__icon-wrapper" }, Q = { class: "rds-e-drag-and-drop__icon-wrapper-text" }, X = { class: "rds-e-drag-and-drop__text-container" }, Y = { class: "rds-e-drag-and-drop__text" }, Z = {
6
6
  key: 0,
7
7
  class: "rds-e-drag-and-drop__detail"
8
- }, J = /* @__PURE__ */ W({
8
+ }, ee = /* @__PURE__ */ q({
9
9
  __name: "drag-and-drop",
10
10
  props: {
11
11
  /**
@@ -22,6 +22,13 @@ import './style/dragAndDrop.css';const V = ["id", "accept", "multiple", "disable
22
22
  type: String,
23
23
  default: ""
24
24
  },
25
+ /**
26
+ * Texto que se muestra en el botón para dispositivos móviles.
27
+ */
28
+ mobileButtonText: {
29
+ type: String,
30
+ default: "Añade tu archivo"
31
+ },
25
32
  /**
26
33
  * Indica si el componente está deshabilitado.
27
34
  */
@@ -95,78 +102,88 @@ import './style/dragAndDrop.css';const V = ["id", "accept", "multiple", "disable
95
102
  }
96
103
  },
97
104
  emits: ["filesSelected", "validationError", "fileReady"],
98
- setup(r, { emit: y }) {
99
- const t = r, f = y;
100
- let S = 0;
101
- const C = () => `rds-dd-file-${S++}`, n = _(null), i = _(!1), w = z(), g = u(() => t.id || `rds-drag-drop-${w}`), F = u(() => [
105
+ setup(r, { emit: S }) {
106
+ const e = r, p = S;
107
+ let T = 0;
108
+ const C = () => `rds-dd-file-${T++}`, n = x(null), u = x(!1), F = K(), m = i(() => e.id || `rds-drag-drop-${F}`), B = i(() => [
102
109
  "rds-e-drag-and-drop",
103
110
  {
104
- "rds-e-drag-and-drop--dragging": i.value && !t.disabled,
105
- "rds-e-drag-and-drop--disabled": t.disabled,
106
- "rds-e-drag-and-drop--full-width": t.fullWidth,
107
- "rds-e-drag-and-drop--error": t.error && !t.disabled
111
+ "rds-e-drag-and-drop--dragging": u.value && !e.disabled,
112
+ "rds-e-drag-and-drop--disabled": e.disabled,
113
+ "rds-e-drag-and-drop--full-width": e.fullWidth,
114
+ "rds-e-drag-and-drop--error": e.error && !e.disabled
108
115
  }
109
- ]), m = u(() => t.error && t.errorMessage ? t.errorMessage : t.detailText), I = u(() => t.showDetailText && (m.value || !t.error)), T = (e) => {
110
- if (!e || e.length === 0)
116
+ ]), I = i(() => e.disabled ? -1 : 0), E = i(() => e.label || e.mobileButtonText || "Añade tu archivo"), v = i(() => e.error && e.errorMessage ? e.errorMessage : e.detailText), $ = i(() => e.showDetailText && (v.value || !e.error)), A = (a) => {
117
+ if (!a || a.length === 0)
111
118
  return { valid: !1, message: "No se seleccionaron archivos." };
112
- if (!t.multiple && e.length > 1)
119
+ if (!e.multiple && a.length > 1)
113
120
  return { valid: !1, message: "Solo se permite seleccionar un archivo." };
114
- if (t.maxFiles !== null && t.maxFiles > 0 && e.length > t.maxFiles)
115
- return { valid: !1, message: `Se permite un máximo de ${t.maxFiles} archivos por selección.` };
116
- if (t.accept) {
117
- const a = t.accept.split(",").map((l) => l.trim().toLowerCase());
118
- for (let l = 0; l < e.length; l++) {
119
- const s = e[l], p = `.${s.name.split(".").pop()?.toLowerCase()}`, h = s.type.toLowerCase();
120
- if (!a.some((d) => d.startsWith(".") ? p === d : d.includes("/") ? d.endsWith("/*") ? h.startsWith(d.replace("/*", "")) : h === d : !1))
121
- return { valid: !1, message: `El tipo de archivo '${s.name}' no es válido. Permitidos: ${t.accept}` };
121
+ if (e.maxFiles !== null && e.maxFiles > 0 && a.length > e.maxFiles)
122
+ return { valid: !1, message: `Se permite un máximo de ${e.maxFiles} archivos por selección.` };
123
+ if (e.accept) {
124
+ const t = e.accept.split(",").map((l) => l.trim().toLowerCase());
125
+ for (let l = 0; l < a.length; l++) {
126
+ const d = a[l], f = `.${d.name.split(".").pop()?.toLowerCase()}`, _ = d.type.toLowerCase();
127
+ if (!t.some((s) => s.startsWith(".") ? f === s : s.includes("/") ? s.endsWith("/*") ? _.startsWith(s.replace("/*", "")) : _ === s : !1))
128
+ return { valid: !1, message: `El tipo de archivo '${d.name}' no es válido. Permitidos: ${e.accept}` };
122
129
  }
123
130
  }
124
131
  return { valid: !0 };
125
- }, v = (e) => {
126
- if (t.disabled) return;
127
- if (!e || e.length === 0) {
132
+ }, h = (a) => {
133
+ if (e.disabled) return;
134
+ if (!a || a.length === 0) {
128
135
  n.value && (n.value.value = "");
129
136
  return;
130
137
  }
131
- f("filesSelected", e);
132
- const a = T(e);
133
- if (a.valid) {
134
- for (let l = 0; l < e.length; l++) {
135
- const s = e[l], p = C();
136
- f("fileReady", {
137
- id: p,
138
- file: s,
139
- name: s.name,
140
- size: s.size
138
+ p("filesSelected", a);
139
+ const t = A(a);
140
+ if (t.valid) {
141
+ for (let l = 0; l < a.length; l++) {
142
+ const d = a[l], f = C();
143
+ p("fileReady", {
144
+ id: f,
145
+ file: d,
146
+ name: d.name,
147
+ size: d.size
141
148
  });
142
149
  }
143
150
  n.value && (n.value.value = "");
144
- } else a.message && (f("validationError", a.message), n.value && (n.value.value = ""));
145
- }, B = (e) => {
146
- const a = e.target;
147
- v(a.files);
148
- }, E = () => {
149
- t.disabled || (i.value = !0);
150
- }, $ = (e) => {
151
- t.disabled || (e.preventDefault(), i.value = !0);
152
- }, R = (e) => {
153
- const a = e.relatedTarget;
154
- (!e.currentTarget || !e.currentTarget.contains(a)) && (i.value = !1);
155
- }, N = (e) => {
156
- if (t.disabled) return;
157
- i.value = !1;
158
- const a = e.dataTransfer?.files;
159
- v(a || null);
151
+ } else t.message && (p("validationError", t.message), n.value && (n.value.value = ""));
152
+ }, R = (a) => {
153
+ const t = a.target;
154
+ h(t.files);
155
+ }, b = (a) => {
156
+ a.preventDefault(), e.disabled || n.value?.click();
157
+ }, k = () => {
158
+ e.disabled || (u.value = !0);
159
+ }, L = (a) => {
160
+ e.disabled || (a.preventDefault(), u.value = !0);
161
+ }, N = (a) => {
162
+ const t = a.relatedTarget;
163
+ (!a.currentTarget || !a.currentTarget.contains(t)) && (u.value = !1);
164
+ }, W = (a) => {
165
+ if (e.disabled) return;
166
+ u.value = !1;
167
+ const t = a.dataTransfer?.files;
168
+ h(t || null);
160
169
  };
161
- return (e, a) => (b(), x("div", {
162
- class: k(F.value),
163
- onDragenter: c(E, ["prevent"]),
164
- onDragover: c($, ["prevent"]),
165
- onDragleave: c(R, ["prevent"]),
166
- onDrop: c(N, ["prevent"])
170
+ return (a, t) => (y(), D("div", {
171
+ class: M(B.value),
172
+ tabindex: I.value,
173
+ role: "button",
174
+ "aria-disabled": r.disabled ? "true" : "false",
175
+ "aria-label": E.value,
176
+ onKeydown: [
177
+ w(b, ["enter"]),
178
+ w(b, ["space"])
179
+ ],
180
+ onDragenter: c(k, ["prevent"]),
181
+ onDragover: c(L, ["prevent"]),
182
+ onDragleave: c(N, ["prevent"]),
183
+ onDrop: c(W, ["prevent"])
167
184
  }, [
168
185
  o("input", {
169
- id: g.value,
186
+ id: m.value,
170
187
  ref_key: "fileInputRef",
171
188
  ref: n,
172
189
  type: "file",
@@ -174,29 +191,30 @@ import './style/dragAndDrop.css';const V = ["id", "accept", "multiple", "disable
174
191
  accept: r.accept,
175
192
  multiple: r.multiple,
176
193
  disabled: r.disabled,
177
- onChange: B
178
- }, null, 40, V),
194
+ onChange: R
195
+ }, null, 40, G),
179
196
  o("label", {
180
- for: g.value,
197
+ for: m.value,
181
198
  class: "rds-e-drag-and-drop__label"
182
199
  }, [
183
- q(e.$slots, "content", {}, () => [
184
- o("span", P, [
185
- L(A, {
200
+ z(a.$slots, "content", {}, () => [
201
+ o("span", J, [
202
+ U(O, {
186
203
  name: r.icon,
187
204
  class: "rds-e-drag-and-drop__icon",
188
205
  "aria-hidden": "true"
189
- }, null, 8, ["name"])
206
+ }, null, 8, ["name"]),
207
+ o("p", Q, g(r.mobileButtonText), 1)
190
208
  ]),
191
- o("div", j, [
192
- o("span", G, D(r.label), 1),
193
- I.value ? (b(), x("span", H, D(m.value), 1)) : M("", !0)
209
+ o("div", X, [
210
+ o("span", Y, g(r.label), 1),
211
+ $.value ? (y(), D("span", Z, g(v.value), 1)) : V("", !0)
194
212
  ])
195
213
  ], !0)
196
- ], 8, O)
197
- ], 34));
214
+ ], 8, H)
215
+ ], 42, j));
198
216
  }
199
- }), ee = /* @__PURE__ */ U(J, [["__scopeId", "data-v-3928ef06"]]);
217
+ }), de = /* @__PURE__ */ P(ee, [["__scopeId", "data-v-9dade050"]]);
200
218
  export {
201
- ee as default
219
+ de as default
202
220
  };