@telefonica/mistica 14.42.0 → 14.43.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.
Files changed (43) hide show
  1. package/css/mistica.css +1 -1
  2. package/dist/accordion.d.ts +0 -2
  3. package/dist/carousel.d.ts +5 -5
  4. package/dist/carousel.js +169 -153
  5. package/dist/cvv-field.js +85 -40
  6. package/dist/dialog.js +66 -65
  7. package/dist/feedback.css-mistica.js +14 -8
  8. package/dist/feedback.css.d.ts +2 -0
  9. package/dist/feedback.js +56 -49
  10. package/dist/index.d.ts +3 -1
  11. package/dist/index.js +4 -1
  12. package/dist/package-version.js +1 -1
  13. package/dist/popover.css-mistica.js +4 -43
  14. package/dist/popover.css.d.ts +1 -12
  15. package/dist/popover.d.ts +6 -2
  16. package/dist/popover.js +71 -226
  17. package/dist/select.js +176 -172
  18. package/dist/text.css-mistica.js +7 -7
  19. package/dist/text.css.d.ts +0 -1
  20. package/dist/text.js +24 -24
  21. package/dist/theme.d.ts +2 -1
  22. package/dist/theme.js +17 -13
  23. package/dist/tooltip.css-mistica.js +15 -6
  24. package/dist/tooltip.css.d.ts +3 -0
  25. package/dist/tooltip.d.ts +15 -1
  26. package/dist/tooltip.js +213 -140
  27. package/dist-es/carousel.js +193 -176
  28. package/dist-es/cvv-field.js +73 -69
  29. package/dist-es/dialog.js +126 -125
  30. package/dist-es/feedback.css-mistica.js +2 -2
  31. package/dist-es/feedback.js +90 -83
  32. package/dist-es/index.js +1734 -1734
  33. package/dist-es/package-version.js +1 -1
  34. package/dist-es/popover.css-mistica.js +2 -3
  35. package/dist-es/popover.js +75 -191
  36. package/dist-es/select.js +182 -178
  37. package/dist-es/style.css +1 -1
  38. package/dist-es/text.css-mistica.js +3 -3
  39. package/dist-es/text.js +32 -32
  40. package/dist-es/theme.js +16 -12
  41. package/dist-es/tooltip.css-mistica.js +2 -2
  42. package/dist-es/tooltip.js +234 -169
  43. package/package.json +4 -4
package/dist-es/select.js CHANGED
@@ -51,12 +51,12 @@ function _object_spread_props(target, source) {
51
51
  }
52
52
  return target;
53
53
  }
54
- import { jsxs as k, jsx as o, Fragment as Ae } from "react/jsx-runtime";
54
+ import { jsx as s, jsxs as k, Fragment as Ae } from "react/jsx-runtime";
55
55
  import * as n from "react";
56
- import C from "classnames";
56
+ import V from "classnames";
57
57
  import { useForm as _e } from "./form-context.js";
58
- import { useAriaId as ke, useTheme as Ce } from "./hooks.js";
59
- import { SPACE as ne, ENTER as re, ESC as Pe, TAB as Ve, UP as De, DOWN as Me } from "./utils/keys.js";
58
+ import { useAriaId as ke, useTheme as Ve } from "./hooks.js";
59
+ import { SPACE as ne, ENTER as re, ESC as Ce, TAB as Pe, UP as De, DOWN as Me } from "./utils/keys.js";
60
60
  import { FieldContainer as He, HelperText as Fe, Label as We } from "./text-field-components.js";
61
61
  import se from "./generated/mistica-icons/icon-chevron-down-regular.js";
62
62
  import { TextFieldBaseAutosuggest as Ge } from "./text-field-base.js";
@@ -68,11 +68,12 @@ import { selectVariants as qe, arrowDown as ze, selectContainerVariants as je, s
68
68
  import { inputWithLabel as ie, inputWithoutLabel as ce } from "./text-field-base.css-mistica.js";
69
69
  import { Portal as Qe } from "./portal.js";
70
70
  import { pxToRem as Ye, applyCssVars as et } from "./utils/css.js";
71
- const tt = (param)=>{
72
- let { id: le, label: w, helperText: ae, value: ue, onChangeValue: P, name: i, fullWidth: V, options: u, optional: D, disabled: fe, error: de, onBlur: M, autoFocus: q = !1, native: pe } = param;
71
+ import { ThemeVariant as tt } from "./theme-variant-context.js";
72
+ const nt = (param)=>{
73
+ let { id: ae, label: w, helperText: le, value: ue, onChangeValue: C, name: i, fullWidth: P, options: u, optional: D, disabled: fe, error: de, onBlur: M, autoFocus: q = !1, native: pe } = param;
73
74
  var te;
74
- const h = n.useRef(null), f = n.useRef(null), S = n.useRef(null), g = n.useRef(null), N = n.useRef(/* @__PURE__ */ new Map()), [me, he] = n.useState(!0), [d, Se] = n.useState(), [H, z] = n.useState(!1), [j, K] = n.useState(!1), [U, x] = n.useState(!1), [a, F] = n.useState({}), [T, W] = n.useState(), G = n.useRef(null), L = ke(le), { rawValues: ge, setRawValue: Z, setValue: $, formStatus: Te, formErrors: X, setFormError: ve, register: B } = _e(), { platformOverrides: J } = Ce(), Ee = pe || process.env.NODE_ENV === "test" && !process.env.SSR_TEST || Ze(J) || $e(J), v = fe || Te === "sending", R = de || !!X[i], Q = X[i] || ae, l = ue !== null && ue !== void 0 ? ue : ge[i], A = (e)=>{
75
- P == null || P(e), ve({
75
+ const h = n.useRef(null), f = n.useRef(null), S = n.useRef(null), g = n.useRef(null), N = n.useRef(/* @__PURE__ */ new Map()), [me, he] = n.useState(!0), [d, Se] = n.useState(), [H, z] = n.useState(!1), [j, K] = n.useState(!1), [U, x] = n.useState(!1), [l, F] = n.useState({}), [T, W] = n.useState(), G = n.useRef(null), L = ke(ae), { rawValues: ge, setRawValue: Z, setValue: $, formStatus: Te, formErrors: X, setFormError: ve, register: B } = _e(), { platformOverrides: J } = Ve(), Ie = pe || process.env.NODE_ENV === "test" && !process.env.SSR_TEST || Ze(J) || $e(J), v = fe || Te === "sending", R = de || !!X[i], Q = X[i] || le, a = ue !== null && ue !== void 0 ? ue : ge[i], A = (e)=>{
76
+ C == null || C(e), ve({
76
77
  name: i,
77
78
  error: ""
78
79
  }), Z({
@@ -82,30 +83,30 @@ const tt = (param)=>{
82
83
  name: i,
83
84
  value: e
84
85
  });
85
- }, E = (e)=>{
86
+ }, I = (e)=>{
86
87
  if (e) {
87
88
  if (S != null && S.current) {
88
- const s = S.current.getBoundingClientRect(), p = s.top, I = s.width, O = s.left, ye = s.height, b = p + ye, _ = Math.min(u.length, 8) * 48 + 16;
89
+ const o = S.current.getBoundingClientRect(), p = o.top, E = o.width, O = o.left, ye = o.height, b = p + ye, _ = Math.min(u.length, 8) * 48 + 16;
89
90
  if (b + _ + 12 > window.innerHeight) {
90
91
  const Ne = window.innerHeight - b;
91
92
  if (p > Ne) {
92
93
  const Re = p - _;
93
94
  F({
94
- minWidth: I,
95
+ minWidth: E,
95
96
  left: O,
96
97
  top: Math.max(Re, 12),
97
98
  maxHeight: Math.min(p - 12, _),
98
99
  transformOrigin: "center bottom"
99
100
  });
100
101
  } else F({
101
- minWidth: I,
102
+ minWidth: E,
102
103
  top: b,
103
104
  left: O,
104
105
  maxHeight: window.innerHeight - b - 12,
105
106
  transformOrigin: "center top"
106
107
  });
107
108
  } else F({
108
- minWidth: I,
109
+ minWidth: E,
109
110
  top: b,
110
111
  left: O,
111
112
  maxHeight: _,
@@ -114,36 +115,36 @@ const tt = (param)=>{
114
115
  }
115
116
  z(!0), requestAnimationFrame(()=>{
116
117
  G.current && g.current && "scrollTop" in g.current && (g.current.scrollTop = G.current), K(!0);
117
- }), W(d !== null && d !== void 0 ? d : l);
118
+ }), W(d !== null && d !== void 0 ? d : a);
118
119
  } else K(!1), z(!1), W(void 0);
119
120
  }, Y = (e)=>{
120
121
  var t;
121
- G.current = (t = g.current) == null ? void 0 : t.scrollTop, E(!1), A && typeof e == "string" && A(e), typeof l > "u" && Se(e);
122
- }, Ie = (e)=>{
122
+ G.current = (t = g.current) == null ? void 0 : t.scrollTop, I(!1), A && typeof e == "string" && A(e), typeof a > "u" && Se(e);
123
+ }, Ee = (e)=>{
123
124
  var r;
124
125
  const t = (r = g.current) == null ? void 0 : r.getBoundingClientRect();
125
126
  if (t && e && N.current.has(e)) {
126
- const c = N.current.get(e), s = c == null ? void 0 : c.getBoundingClientRect();
127
- if (s && s.top + s.height / 2 >= t.top + t.height) {
127
+ const c = N.current.get(e), o = c == null ? void 0 : c.getBoundingClientRect();
128
+ if (o && o.top + o.height / 2 >= t.top + t.height) {
128
129
  c == null || c.scrollIntoView();
129
130
  return;
130
131
  }
131
- s && s.top + s.height / 2 <= t.top && (c == null || c.scrollIntoView(!1));
132
+ o && o.top + o.height / 2 <= t.top && (c == null || c.scrollIntoView(!1));
132
133
  }
133
134
  }, we = f.current, xe = h.current;
134
135
  n.useEffect(()=>{
135
136
  Z({
136
137
  name: i,
137
- value: l
138
+ value: a
138
139
  }), $({
139
140
  name: i,
140
- value: l
141
+ value: a
141
142
  });
142
143
  }, [
143
144
  i,
144
145
  Z,
145
146
  $,
146
- l
147
+ a
147
148
  ]), n.useEffect(()=>(B(i, {
148
149
  input: h.current,
149
150
  focusableElement: f.current
@@ -162,33 +163,33 @@ const tt = (param)=>{
162
163
  ]), n.useEffect(()=>{
163
164
  const e = (r)=>{
164
165
  var p;
165
- const s = {
166
+ const o = {
166
167
  [De]: -1,
167
168
  [Me]: 1
168
169
  }[r.key];
169
- if (s) {
170
+ if (o) {
170
171
  m(r);
171
172
  var _ref;
172
- const I = (_ref = (p = u[u.findIndex((param)=>{
173
+ const E = (_ref = (p = u[u.findIndex((param)=>{
173
174
  let { value: O } = param;
174
175
  return O === T;
175
- }) + s]) == null ? void 0 : p.value) !== null && _ref !== void 0 ? _ref : T;
176
- W(I), Ie(I);
176
+ }) + o]) == null ? void 0 : p.value) !== null && _ref !== void 0 ? _ref : T;
177
+ W(E), Ee(E);
177
178
  }
178
179
  }, t = (r)=>{
179
180
  if (H) switch(r.key){
180
- case Ve:
181
+ case Pe:
181
182
  m(r);
182
183
  break;
183
- case Pe:
184
- E(!1);
184
+ case Ce:
185
+ I(!1);
185
186
  break;
186
187
  case re:
187
188
  case ne:
188
189
  m(r), u.findIndex((param)=>{
189
190
  let { value: c } = param;
190
191
  return c === T;
191
- }) !== -1 && T !== d && Y(T), E(!1);
192
+ }) !== -1 && T !== d && Y(T), I(!1);
192
193
  break;
193
194
  }
194
195
  j && e(r);
@@ -214,163 +215,166 @@ const tt = (param)=>{
214
215
  onFocus: ()=>x(!0),
215
216
  onBlur: ()=>x(!1),
216
217
  onClick: ()=>{
217
- E(!0), x(!0);
218
+ I(!0), x(!0);
218
219
  },
219
220
  onKeyDown: (e)=>{
220
- !H && (e.key === ne || e.key === re) && (m(e), E(!0));
221
+ !H && (e.key === ne || e.key === re) && (m(e), I(!0));
221
222
  }
222
223
  }, ee = Ye(20);
223
- var _ref, _a_transformOrigin;
224
- return Ee || me ? /* @__PURE__ */ k(He, {
225
- disabled: v,
226
- helperText: /* @__PURE__ */ o(Fe, {
227
- error: R,
228
- leftText: Q
229
- }),
230
- fieldRef: S,
231
- fullWidth: V,
232
- children: [
233
- w && /* @__PURE__ */ o(We, {
224
+ var _ref, _l_transformOrigin;
225
+ return /* @__PURE__ */ s(tt, {
226
+ isInverse: !1,
227
+ children: Ie || me ? /* @__PURE__ */ k(He, {
228
+ disabled: v,
229
+ helperText: /* @__PURE__ */ s(Fe, {
234
230
  error: R,
235
- forId: L,
236
- inputState: U ? "focused" : ((_ref = l !== null && l !== void 0 ? l : d) !== null && _ref !== void 0 ? _ref : (te = h.current) == null ? void 0 : te.value) ? "filled" : "default",
237
- optional: D,
238
- children: w
231
+ leftText: Q
239
232
  }),
240
- /* @__PURE__ */ k("select", {
241
- className: C(qe[v ? "disabled" : "default"], w ? ie : ce),
242
- id: L,
243
- "aria-invalid": !!R,
244
- value: l,
245
- required: !D,
246
- disabled: v,
247
- onChange: (e)=>{
248
- A && A(e.target.value);
249
- },
250
- onFocus: ()=>x(!0),
251
- onBlur: (e)=>{
252
- x(!1), M == null || M(e);
253
- },
254
- ref: (e)=>{
255
- [
256
- h,
257
- f
258
- ].forEach((t)=>{
259
- t.current = e;
260
- });
261
- },
262
- style: {
263
- // Override default browser opacity when disabled. This opacity also affects the label.
264
- // Without this fix, the label is invisible when disabled
265
- opacity: 1
266
- },
267
- children: [
268
- u.every((param)=>{
269
- let { value: e } = param;
270
- return !!e;
271
- }) && // if no "empty" option exists, insert a dummy empty option
272
- // this is needed to allow a native select with no selected option
273
- /* @__PURE__ */ o("option", {
274
- value: "",
275
- style: {
276
- display: "none"
277
- }
278
- }),
279
- u.map((param)=>{
280
- let { value: e, text: t } = param;
281
- return /* @__PURE__ */ o("option", {
282
- value: e,
283
- children: t
284
- }, e);
285
- })
286
- ]
287
- }),
288
- /* @__PURE__ */ o("div", {
289
- className: ze,
290
- "aria-hidden": !0,
291
- children: /* @__PURE__ */ o(se, {
292
- size: ee
293
- })
294
- })
295
- ]
296
- }) : /* @__PURE__ */ k(Ae, {
297
- children: [
298
- /* @__PURE__ */ k("div", _object_spread_props(_object_spread({
299
- className: je[V ? "fullWidth" : "default"],
300
- role: "button",
301
- "aria-haspopup": "listbox",
302
- ref: f
303
- }, !v && be), {
304
- children: [
305
- /* @__PURE__ */ o(Ge, {
306
- style: {
307
- visibility: "hidden"
308
- },
309
- fullWidth: V,
310
- endIcon: /* @__PURE__ */ o(se, {
311
- size: ee
312
- }),
313
- focus: U,
314
- label: w,
315
- value: l,
316
- shrinkLabel: !!(l || d),
317
- name: i,
318
- helperText: Q,
319
- required: !D,
320
- disabled: v,
321
- id: L,
322
- error: R,
323
- inputRef: h,
324
- fieldRef: S
325
- }),
326
- /* @__PURE__ */ o("div", {
327
- className: C(Ke[v ? "disabled" : "default"], w ? ie : ce),
328
- children: Oe(l !== null && l !== void 0 ? l : d)
329
- })
330
- ]
331
- })),
332
- H && /* @__PURE__ */ o(Le, {
333
- onPress: (e)=>{
334
- E(!1), m(e);
335
- },
336
- disableScroll: !0,
337
- children: /* @__PURE__ */ o(Qe, {
338
- children: /* @__PURE__ */ o("ul", {
339
- style: et({
340
- [y.top]: a.top ? `${a.top}px` : "",
341
- [y.left]: a.left ? `${a.left}px` : "",
342
- [y.maxHeight]: a.maxHeight ? `${a.maxHeight}px` : "",
343
- [y.minWidth]: a.minWidth ? `${a.minWidth}px` : "",
344
- [y.transformOrigin]: (_a_transformOrigin = a.transformOrigin) !== null && _a_transformOrigin !== void 0 ? _a_transformOrigin : ""
233
+ fieldRef: S,
234
+ fullWidth: P,
235
+ children: [
236
+ w && /* @__PURE__ */ s(We, {
237
+ error: R,
238
+ forId: L,
239
+ inputState: U ? "focused" : ((_ref = a !== null && a !== void 0 ? a : d) !== null && _ref !== void 0 ? _ref : (te = h.current) == null ? void 0 : te.value) ? "filled" : "default",
240
+ optional: D,
241
+ children: w
242
+ }),
243
+ /* @__PURE__ */ k("select", {
244
+ className: V(qe[v ? "disabled" : "default"], w ? ie : ce),
245
+ id: L,
246
+ "aria-invalid": !!R,
247
+ value: a,
248
+ required: !D,
249
+ disabled: v,
250
+ onChange: (e)=>{
251
+ A && A(e.target.value);
252
+ },
253
+ onFocus: ()=>x(!0),
254
+ onBlur: (e)=>{
255
+ x(!1), M == null || M(e);
256
+ },
257
+ ref: (e)=>{
258
+ [
259
+ h,
260
+ f
261
+ ].forEach((t)=>{
262
+ t.current = e;
263
+ });
264
+ },
265
+ style: {
266
+ // Override default browser opacity when disabled. This opacity also affects the label.
267
+ // Without this fix, the label is invisible when disabled
268
+ opacity: 1
269
+ },
270
+ children: [
271
+ u.every((param)=>{
272
+ let { value: e } = param;
273
+ return !!e;
274
+ }) && // if no "empty" option exists, insert a dummy empty option
275
+ // this is needed to allow a native select with no selected option
276
+ /* @__PURE__ */ s("option", {
277
+ value: "",
278
+ style: {
279
+ display: "none"
280
+ }
345
281
  }),
346
- onPointerDown: m,
347
- className: C(Ue, j ? oe.show : oe.hide),
348
- role: "listbox",
349
- ref: g,
350
- children: u.map((param)=>{
282
+ u.map((param)=>{
351
283
  let { value: e, text: t } = param;
352
- return /* @__PURE__ */ o("li", {
353
- role: "option",
354
- "aria-selected": e === (d !== null && d !== void 0 ? d : l),
355
- "data-value": e,
356
- className: C(Xe, {
357
- [Je]: e === T || e === (d !== null && d !== void 0 ? d : l)
358
- }),
359
- onPointerDown: m,
360
- onClick: ()=>Y(e),
361
- ref: (r)=>{
362
- r ? N.current.set(e, r) : N.current.delete(e);
363
- },
364
- children: /* @__PURE__ */ o(Be, {
365
- regular: !0,
366
- children: t
367
- })
284
+ return /* @__PURE__ */ s("option", {
285
+ value: e,
286
+ children: t
368
287
  }, e);
369
288
  })
289
+ ]
290
+ }),
291
+ /* @__PURE__ */ s("div", {
292
+ className: ze,
293
+ "aria-hidden": !0,
294
+ children: /* @__PURE__ */ s(se, {
295
+ size: ee
296
+ })
297
+ })
298
+ ]
299
+ }) : /* @__PURE__ */ k(Ae, {
300
+ children: [
301
+ /* @__PURE__ */ k("div", _object_spread_props(_object_spread({
302
+ className: je[P ? "fullWidth" : "default"],
303
+ role: "button",
304
+ "aria-haspopup": "listbox",
305
+ ref: f
306
+ }, !v && be), {
307
+ children: [
308
+ /* @__PURE__ */ s(Ge, {
309
+ style: {
310
+ visibility: "hidden"
311
+ },
312
+ fullWidth: P,
313
+ endIcon: /* @__PURE__ */ s(se, {
314
+ size: ee
315
+ }),
316
+ focus: U,
317
+ label: w,
318
+ value: a,
319
+ shrinkLabel: !!(a || d),
320
+ name: i,
321
+ helperText: Q,
322
+ required: !D,
323
+ disabled: v,
324
+ id: L,
325
+ error: R,
326
+ inputRef: h,
327
+ fieldRef: S
328
+ }),
329
+ /* @__PURE__ */ s("div", {
330
+ className: V(Ke[v ? "disabled" : "default"], w ? ie : ce),
331
+ children: Oe(a !== null && a !== void 0 ? a : d)
332
+ })
333
+ ]
334
+ })),
335
+ H && /* @__PURE__ */ s(Le, {
336
+ onPress: (e)=>{
337
+ I(!1), m(e);
338
+ },
339
+ disableScroll: !0,
340
+ children: /* @__PURE__ */ s(Qe, {
341
+ children: /* @__PURE__ */ s("ul", {
342
+ style: et({
343
+ [y.top]: l.top ? `${l.top}px` : "",
344
+ [y.left]: l.left ? `${l.left}px` : "",
345
+ [y.maxHeight]: l.maxHeight ? `${l.maxHeight}px` : "",
346
+ [y.minWidth]: l.minWidth ? `${l.minWidth}px` : "",
347
+ [y.transformOrigin]: (_l_transformOrigin = l.transformOrigin) !== null && _l_transformOrigin !== void 0 ? _l_transformOrigin : ""
348
+ }),
349
+ onPointerDown: m,
350
+ className: V(Ue, j ? oe.show : oe.hide),
351
+ role: "listbox",
352
+ ref: g,
353
+ children: u.map((param)=>{
354
+ let { value: e, text: t } = param;
355
+ return /* @__PURE__ */ s("li", {
356
+ role: "option",
357
+ "aria-selected": e === (d !== null && d !== void 0 ? d : a),
358
+ "data-value": e,
359
+ className: V(Xe, {
360
+ [Je]: e === T || e === (d !== null && d !== void 0 ? d : a)
361
+ }),
362
+ onPointerDown: m,
363
+ onClick: ()=>Y(e),
364
+ ref: (r)=>{
365
+ r ? N.current.set(e, r) : N.current.delete(e);
366
+ },
367
+ children: /* @__PURE__ */ s(Be, {
368
+ regular: !0,
369
+ children: t
370
+ })
371
+ }, e);
372
+ })
373
+ })
370
374
  })
371
375
  })
372
- })
373
- ]
376
+ ]
377
+ })
374
378
  });
375
- }, vt = tt;
376
- export { vt as default };
379
+ }, Et = nt;
380
+ export { Et as default };