@telefonica/mistica 16.0.0 → 16.1.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 (152) hide show
  1. package/README.md +11 -9
  2. package/css/mistica.css +1 -1
  3. package/dist/box.d.ts +1 -0
  4. package/dist/box.js +12 -12
  5. package/dist/card.d.ts +14 -2
  6. package/dist/card.js +210 -206
  7. package/dist/credit-card-expiration-field.d.ts +1 -1
  8. package/dist/credit-card-expiration-field.js +53 -52
  9. package/dist/credit-card-number-field.d.ts +1 -1
  10. package/dist/credit-card-number-field.js +47 -45
  11. package/dist/cvv-field.d.ts +1 -1
  12. package/dist/cvv-field.js +38 -37
  13. package/dist/date-field.d.ts +1 -1
  14. package/dist/date-field.js +15 -13
  15. package/dist/date-time-field.d.ts +1 -1
  16. package/dist/date-time-field.js +13 -11
  17. package/dist/decimal-field.d.ts +1 -1
  18. package/dist/decimal-field.js +39 -38
  19. package/dist/email-field.d.ts +1 -1
  20. package/dist/email-field.js +21 -19
  21. package/dist/form-context.d.ts +7 -2
  22. package/dist/form-context.js +69 -62
  23. package/dist/form.d.ts +2 -1
  24. package/dist/form.js +94 -80
  25. package/dist/iban-field.d.ts +1 -1
  26. package/dist/iban-field.js +32 -30
  27. package/dist/index.d.ts +12 -3
  28. package/dist/index.js +19 -8
  29. package/dist/inline.d.ts +2 -1
  30. package/dist/inline.js +16 -15
  31. package/dist/integer-field.d.ts +1 -1
  32. package/dist/integer-field.js +30 -30
  33. package/dist/month-field.d.ts +1 -1
  34. package/dist/month-field.js +15 -13
  35. package/dist/package-version.js +1 -1
  36. package/dist/password-field.d.ts +1 -1
  37. package/dist/password-field.js +24 -22
  38. package/dist/phone-number-field.d.ts +4 -1
  39. package/dist/phone-number-field.js +84 -52
  40. package/dist/pin-field.js +21 -20
  41. package/dist/radio-button.d.ts +1 -0
  42. package/dist/radio-button.js +42 -41
  43. package/dist/rating.css-mistica.js +44 -0
  44. package/dist/rating.css.d.ts +11 -0
  45. package/dist/rating.css.ts.vanilla.css-mistica.js +11 -0
  46. package/dist/rating.d.ts +37 -0
  47. package/dist/rating.js +320 -0
  48. package/dist/search-field.d.ts +1 -0
  49. package/dist/search-field.js +18 -16
  50. package/dist/select.js +36 -33
  51. package/dist/sheet-action-row.css-mistica.js +13 -0
  52. package/dist/sheet-action-row.css.d.ts +1 -0
  53. package/dist/sheet-actions-list.d.ts +26 -0
  54. package/dist/sheet-actions-list.js +147 -0
  55. package/dist/sheet-actions.d.ts +23 -0
  56. package/dist/sheet-actions.js +175 -0
  57. package/dist/{sheet.css-mistica.js → sheet-common.css-mistica.js} +15 -21
  58. package/dist/{sheet.css.d.ts → sheet-common.css.d.ts} +0 -2
  59. package/dist/sheet-common.css.ts.vanilla.css-mistica.js +11 -0
  60. package/dist/sheet-common.d.ts +24 -0
  61. package/dist/sheet-common.js +429 -0
  62. package/dist/sheet-info.css-mistica.js +12 -0
  63. package/dist/sheet-info.css.d.ts +1 -0
  64. package/dist/sheet-info.d.ts +28 -0
  65. package/dist/sheet-info.js +156 -0
  66. package/dist/sheet-native.d.ts +2 -0
  67. package/dist/sheet-native.js +173 -0
  68. package/dist/sheet-radio-list.d.ts +22 -0
  69. package/dist/sheet-radio-list.js +143 -0
  70. package/dist/sheet-root.d.ts +4 -85
  71. package/dist/sheet-root.js +48 -322
  72. package/dist/sheet-types.d.ts +88 -0
  73. package/dist/sheet-web.d.ts +8 -0
  74. package/dist/sheet-web.js +183 -0
  75. package/dist/slider.js +40 -39
  76. package/dist/switch-component.js +18 -17
  77. package/dist/text-field-base.d.ts +3 -1
  78. package/dist/text-field-base.js +74 -66
  79. package/dist/text-field-components.css-mistica.js +14 -14
  80. package/dist/text-field-components.css.d.ts +2 -2
  81. package/dist/text-field-components.js +49 -39
  82. package/dist/text-field.d.ts +1 -0
  83. package/dist/text-field.js +24 -22
  84. package/dist/text-tokens.d.ts +14 -0
  85. package/dist/text-tokens.js +145 -89
  86. package/dist/theme-context-provider.js +6 -5
  87. package/dist/theme.d.ts +2 -0
  88. package/dist/utils/credit-card.d.ts +2 -2
  89. package/dist/utils/credit-card.js +1 -1
  90. package/dist/vivinho-loading-animation/in-lottie.json.js +544 -612
  91. package/dist/vivinho-loading-animation/out-lottie.json.js +828 -896
  92. package/dist/vivinho-loading-animation/pulse-lottie.json.js +798 -866
  93. package/dist/vivinho-loading-animation/wave-lottie.json.js +4303 -4409
  94. package/dist-es/box.js +18 -18
  95. package/dist-es/card.js +305 -301
  96. package/dist-es/credit-card-expiration-field.js +57 -56
  97. package/dist-es/credit-card-number-field.js +74 -72
  98. package/dist-es/cvv-field.js +82 -81
  99. package/dist-es/date-field.js +29 -27
  100. package/dist-es/date-time-field.js +29 -27
  101. package/dist-es/decimal-field.js +46 -45
  102. package/dist-es/email-field.js +26 -24
  103. package/dist-es/form-context.js +70 -63
  104. package/dist-es/form.js +102 -88
  105. package/dist-es/iban-field.js +35 -33
  106. package/dist-es/index.js +1822 -1817
  107. package/dist-es/inline.js +26 -25
  108. package/dist-es/integer-field.js +31 -31
  109. package/dist-es/month-field.js +28 -26
  110. package/dist-es/package-version.js +1 -1
  111. package/dist-es/password-field.js +37 -35
  112. package/dist-es/phone-number-field.js +92 -60
  113. package/dist-es/pin-field.js +32 -31
  114. package/dist-es/radio-button.js +42 -41
  115. package/dist-es/rating.css-mistica.js +6 -0
  116. package/dist-es/rating.css.ts.vanilla.css-mistica.js +2 -0
  117. package/dist-es/rating.js +257 -0
  118. package/dist-es/search-field.js +33 -31
  119. package/dist-es/select.js +49 -46
  120. package/dist-es/sheet-action-row.css-mistica.js +4 -0
  121. package/dist-es/sheet-actions-list.js +92 -0
  122. package/dist-es/sheet-actions.js +125 -0
  123. package/dist-es/sheet-common.css-mistica.js +4 -0
  124. package/dist-es/sheet-common.css.ts.vanilla.css-mistica.js +2 -0
  125. package/dist-es/sheet-common.js +366 -0
  126. package/dist-es/sheet-info.css-mistica.js +3 -0
  127. package/dist-es/sheet-info.js +101 -0
  128. package/dist-es/sheet-native.js +164 -0
  129. package/dist-es/sheet-radio-list.js +88 -0
  130. package/dist-es/sheet-root.js +50 -319
  131. package/dist-es/sheet-web.js +128 -0
  132. package/dist-es/slider.js +49 -48
  133. package/dist-es/style.css +1 -1
  134. package/dist-es/switch-component.js +27 -26
  135. package/dist-es/text-field-base.js +108 -100
  136. package/dist-es/text-field-components.css-mistica.js +2 -2
  137. package/dist-es/text-field-components.js +70 -60
  138. package/dist-es/text-field.js +33 -31
  139. package/dist-es/text-tokens.js +80 -45
  140. package/dist-es/theme-context-provider.js +20 -19
  141. package/dist-es/utils/credit-card.js +1 -1
  142. package/dist-es/vivinho-loading-animation/in-lottie.json.js +534 -599
  143. package/dist-es/vivinho-loading-animation/out-lottie.json.js +821 -886
  144. package/dist-es/vivinho-loading-animation/pulse-lottie.json.js +790 -855
  145. package/dist-es/vivinho-loading-animation/wave-lottie.json.js +4297 -4400
  146. package/package.json +4 -3
  147. package/dist/sheet.d.ts +0 -107
  148. package/dist/sheet.js +0 -642
  149. package/dist-es/sheet.css-mistica.js +0 -4
  150. package/dist-es/sheet.js +0 -567
  151. /package/dist/{sheet.css.ts.vanilla.css-mistica.js → sheet-action-row.css.ts.vanilla.css-mistica.js} +0 -0
  152. /package/dist-es/{sheet.css.ts.vanilla.css-mistica.js → sheet-action-row.css.ts.vanilla.css-mistica.js} +0 -0
@@ -54,9 +54,9 @@ function _object_spread_props(target, source) {
54
54
  import { jsxs as D, jsx as c } from "react/jsx-runtime";
55
55
  import H from "classnames";
56
56
  import * as a from "react";
57
- import N from "./inline.js";
58
- import { input as B } from "./text-field-base.css-mistica.js";
59
- import { fieldContainer as E, disabled as j, readOnlyField as O, focusedField as W, field as q, input as z, passwordInput as K, pinInputLineHeight as v, passwordDot as M } from "./pin-field.css-mistica.js";
57
+ import B from "./inline.js";
58
+ import { input as E } from "./text-field-base.css-mistica.js";
59
+ import { fieldContainer as L, disabled as j, readOnlyField as O, focusedField as W, field as q, input as z, passwordInput as K, pinInputLineHeight as h, passwordDot as M } from "./pin-field.css-mistica.js";
60
60
  import { useTheme as _ } from "./hooks.js";
61
61
  import G from "./screen-reader-only.js";
62
62
  import { IntegerInput as J } from "./integer-field.js";
@@ -67,13 +67,13 @@ import { flushSync as Z } from "react-dom";
67
67
  import { pinFieldInputLabel as x } from "./text-tokens.js";
68
68
  let C = !1;
69
69
  const ee = (param)=>{
70
- let { length: i = 6, hideCode: n = !1, readSms: d, disabled: h, readOnly: g, value: y, defaultValue: b, onChange: f, inputRef: R } = param;
70
+ let { length: i = 6, hideCode: n = !1, readSms: d, disabled: g, readOnly: y, value: F, defaultValue: b, onChange: f, inputRef: R } = param;
71
71
  var _ref;
72
- const { texts: S, t: k } = _(), [A, F] = a.useState((_ref = b == null ? void 0 : b.slice(0, i)) !== null && _ref !== void 0 ? _ref : ""), [w, P] = a.useState(void 0), l = a.useRef(Array.from({
72
+ const { texts: S, t: k } = _(), [A, I] = a.useState((_ref = b == null ? void 0 : b.slice(0, i)) !== null && _ref !== void 0 ? _ref : ""), [w, P] = a.useState(void 0), l = a.useRef(Array.from({
73
73
  length: i
74
- }, ()=>null)).current, u = typeof y < "u", r = u ? y : A, p = a.useCallback((s)=>{
74
+ }, ()=>null)).current, u = typeof F < "u", r = u ? F : A, p = a.useCallback((s)=>{
75
75
  if (s === r) return;
76
- u || F(s);
76
+ u || I(s);
77
77
  const e = l[0];
78
78
  e && (f == null || f(X(_object_spread({}, e), s)));
79
79
  }, [
@@ -116,30 +116,30 @@ const ee = (param)=>{
116
116
  i,
117
117
  d
118
118
  ]);
119
- const L = (s)=>(e)=>{
119
+ const N = (s)=>(e)=>{
120
120
  var V;
121
121
  const t = e.target.value;
122
122
  if (t === "") return;
123
123
  const o = r[s];
124
124
  let m = t;
125
125
  !o || o === t ? m = t : o === t[0] ? m = t.slice(1) : o === t[t.length - 1] && (m = t.slice(0, -1));
126
- let I = s, T = r;
126
+ let v = s, T = r;
127
127
  if (m.length >= 2) {
128
128
  const $ = m.slice(0, i - s);
129
- T = r.slice(0, s) + $, I = Math.min(s + $.length, i - 1);
130
- } else T = r.slice(0, s) + m + r.slice(s + 1), I = s + 1;
129
+ T = r.slice(0, s) + $, v = Math.min(s + $.length, i - 1);
130
+ } else T = r.slice(0, s) + m + r.slice(s + 1), v = s + 1;
131
131
  T !== r && (Z(()=>{
132
132
  p(T);
133
- }), I !== s && I <= i - 1 && ((V = l[I]) == null || V.focus()));
133
+ }), v !== s && v <= i - 1 && ((V = l[v]) == null || V.focus()));
134
134
  };
135
- return /* @__PURE__ */ c(N, {
135
+ return /* @__PURE__ */ c(B, {
136
136
  space: 8,
137
137
  children: Array.from({
138
138
  length: i
139
139
  }).map((s, e)=>/* @__PURE__ */ {
140
140
  var _r_e;
141
141
  return D("div", {
142
- className: g ? O : e === w ? W : q,
142
+ className: y ? O : e === w ? W : q,
143
143
  children: [
144
144
  /* @__PURE__ */ c(J, {
145
145
  "aria-label": (S.pinFieldInputLabel || k(x)).replace("1$s", String(e + 1)).replace("2$s", String(i)),
@@ -157,21 +157,21 @@ const ee = (param)=>{
157
157
  inputRef: (t)=>{
158
158
  l[e] = t, e === 0 && R(t);
159
159
  },
160
- className: H(B, z, {
160
+ className: H(E, z, {
161
161
  [K]: n
162
162
  }),
163
163
  style: {
164
- marginTop: `calc(${v} - 1px)`,
165
- marginBottom: `calc(${v} - 1px)`,
166
- lineHeight: v,
167
- fontSize: v,
168
- height: v
164
+ marginTop: `calc(${h} - 1px)`,
165
+ marginBottom: `calc(${h} - 1px)`,
166
+ lineHeight: h,
167
+ fontSize: h,
168
+ height: h
169
169
  },
170
- disabled: h,
171
- readOnly: g,
170
+ disabled: g,
171
+ readOnly: y,
172
172
  autoComplete: d ? "one-time-code" : void 0,
173
173
  value: (_r_e = r[e]) !== null && _r_e !== void 0 ? _r_e : "",
174
- onChange: L(e),
174
+ onChange: N(e),
175
175
  onKeyDown: (t)=>{
176
176
  switch(t.key){
177
177
  case "Backspace":
@@ -207,31 +207,32 @@ const ee = (param)=>{
207
207
  });
208
208
  }, te = (param)=>{
209
209
  let { length: i = 6, hideCode: n = !1, readSms: d = !n, // by default, don't read sms if the code is hidden (password input type)
210
- disabled: h, readOnly: g, name: y, value: b, defaultValue: f, helperText: R, error: S, onChangeValue: k, onChange: A, "aria-label": F, "aria-labelledby": w, dataAttributes: P } = param;
210
+ disabled: g, readOnly: y, name: F, value: b, defaultValue: f, helperText: R, error: S, onChangeValue: k, onChange: A, "aria-label": I, "aria-labelledby": w, dataAttributes: P } = param;
211
211
  const l = Q({
212
- name: y,
212
+ name: F,
213
+ label: I !== null && I !== void 0 ? I : "",
213
214
  value: b,
214
215
  defaultValue: f,
215
216
  processValue: (r)=>r,
216
217
  helperText: R,
217
218
  optional: !1,
218
219
  error: S,
219
- disabled: h,
220
+ disabled: g,
220
221
  onChangeValue: k,
221
222
  onChange: A
222
223
  }), u = a.useId();
223
224
  return /* @__PURE__ */ D("div", _object_spread_props(_object_spread({
224
225
  role: "group",
225
226
  "aria-labelledby": w !== null && w !== void 0 ? w : u,
226
- className: H(E, {
227
- [j]: h
227
+ className: H(L, {
228
+ [j]: g
228
229
  })
229
230
  }, U(P, "PinField")), {
230
231
  children: [
231
- F && !w && /* @__PURE__ */ c(G, {
232
+ I && !w && /* @__PURE__ */ c(G, {
232
233
  children: /* @__PURE__ */ c("div", {
233
234
  id: u,
234
- children: F
235
+ children: I
235
236
  })
236
237
  }),
237
238
  /* @__PURE__ */ c(ee, {
@@ -243,7 +244,7 @@ const ee = (param)=>{
243
244
  defaultValue: l.defaultValue,
244
245
  disabled: l.disabled,
245
246
  onChange: l.onChange,
246
- readOnly: g
247
+ readOnly: y
247
248
  }),
248
249
  /* @__PURE__ */ c(Y, {
249
250
  error: l.error,
@@ -97,33 +97,33 @@ const S = /*#__PURE__*/ i.createContext({
97
97
  selectNext: ()=>{},
98
98
  selectPrev: ()=>{}
99
99
  }), z = ()=>i.useContext(S), J = (_param)=>{
100
- var { value: t, id: s, dataAttributes: h, "aria-labelledby": R, "aria-label": x } = _param, f = _object_without_properties(_param, [
100
+ var { value: e, id: s, dataAttributes: h, "aria-labelledby": g, "aria-label": x } = _param, f = _object_without_properties(_param, [
101
101
  "value",
102
102
  "id",
103
103
  "dataAttributes",
104
104
  "aria-labelledby",
105
105
  "aria-label"
106
106
  ]);
107
- const { disabled: l, selectedValue: C, focusableValue: p, select: c, selectNext: g, selectPrev: y } = z(), r = i.useId(), m = R || r, V = i.useRef(null), d = t === C, o = p === t ? 0 : -1, { isIos: a } = F(), v = (e)=>{
108
- switch(e.key){
107
+ const { disabled: l, selectedValue: v, focusableValue: C, select: c, selectNext: p, selectPrev: y } = z(), r = i.useId(), b = g || r, V = i.useRef(null), d = e === v, o = C === e ? 0 : -1, { isIos: t } = F(), R = (a)=>{
108
+ switch(a.key){
109
109
  case w:
110
- c(t), e.preventDefault(), e.stopPropagation();
110
+ c(e), a.preventDefault(), a.stopPropagation();
111
111
  break;
112
112
  case T:
113
113
  case E:
114
- g(), e.preventDefault(), e.stopPropagation();
114
+ p(), a.preventDefault(), a.stopPropagation();
115
115
  break;
116
116
  case q:
117
117
  case B:
118
- y(), e.preventDefault(), e.stopPropagation();
118
+ y(), a.preventDefault(), a.stopPropagation();
119
119
  break;
120
120
  }
121
121
  }, u = /* @__PURE__ */ n("div", {
122
- className: P(a ? I.ios : I.default, {
123
- [K[a ? "ios" : "default"]]: d,
122
+ className: P(t ? I.ios : I.default, {
123
+ [K[t ? "ios" : "default"]]: d,
124
124
  [D]: l
125
125
  }),
126
- children: !a && /* @__PURE__ */ n("div", {
126
+ children: !t && /* @__PURE__ */ n("div", {
127
127
  className: P($, {
128
128
  [H]: d
129
129
  })
@@ -135,22 +135,22 @@ const S = /*#__PURE__*/ i.createContext({
135
135
  id: s,
136
136
  tabIndex: l ? void 0 : o,
137
137
  role: "radio",
138
- "data-value": t,
138
+ "data-value": e,
139
139
  "aria-checked": d,
140
140
  "aria-disabled": l,
141
141
  "aria-label": x,
142
- "aria-labelledby": x ? void 0 : m,
143
- onClick: (e)=>{
144
- e.stopPropagation(), l || c(t);
142
+ "aria-labelledby": x ? void 0 : b,
143
+ onClick: (a)=>{
144
+ a.stopPropagation(), l || c(e);
145
145
  },
146
- onKeyDown: l ? void 0 : v,
146
+ onKeyDown: l ? void 0 : R,
147
147
  className: l ? U : W
148
148
  }, N(h, "RadioButton")), {
149
149
  children: f.render ? f.render({
150
150
  controlElement: u,
151
151
  disabled: !!l,
152
152
  checked: d,
153
- labelId: m
153
+ labelId: b
154
154
  }) : /* @__PURE__ */ A(j, {
155
155
  space: 16,
156
156
  children: [
@@ -168,7 +168,7 @@ const S = /*#__PURE__*/ i.createContext({
168
168
  /* @__PURE__ */ n(k, {
169
169
  regular: !0,
170
170
  as: "div",
171
- id: m,
171
+ id: b,
172
172
  children: /* @__PURE__ */ n("span", {
173
173
  className: l ? D : "",
174
174
  children: f.children
@@ -177,35 +177,35 @@ const S = /*#__PURE__*/ i.createContext({
177
177
  ]
178
178
  })
179
179
  })));
180
- }, oe = (t)=>{
180
+ }, oe = (e)=>{
181
181
  var _ref;
182
- const { value: s, defaultValue: h, onChange: R, focusableRef: x, disabled: f } = G({
183
- name: t.name,
184
- value: t.value,
185
- defaultValue: t.defaultValue,
186
- onChange: t.onChange,
187
- disabled: t.disabled
188
- }), l = typeof s < "u", [C, p] = i.useState((_ref = s !== null && s !== void 0 ? s : h) !== null && _ref !== void 0 ? _ref : "");
182
+ const { value: s, defaultValue: h, onChange: g, focusableRef: x, disabled: f } = G({
183
+ name: e.name,
184
+ value: e.value,
185
+ defaultValue: e.defaultValue,
186
+ onChange: e.onChange,
187
+ disabled: e.disabled
188
+ }), l = typeof s < "u", [v, C] = i.useState((_ref = s !== null && s !== void 0 ? s : h) !== null && _ref !== void 0 ? _ref : "");
189
189
  i.useEffect(()=>{
190
- s !== void 0 && p(s);
190
+ s !== void 0 && C(s);
191
191
  }, [
192
192
  s
193
193
  ]);
194
194
  const c = (o)=>{
195
- l || p(o), R(o);
196
- }, [g, y] = i.useState(null), r = i.useRef(null), m = ()=>{
195
+ l || C(o), g(o);
196
+ }, [p, y] = i.useState(null), r = i.useRef(null), b = ()=>{
197
197
  if (r.current) {
198
- const o = r.current.querySelector("[role=radio][aria-checked=true]"), a = Array.from(r.current.querySelectorAll("[role=radio]"));
199
- if (a.length === 0) return;
200
- const u = ((o ? a.indexOf(o) : 0) + 1) % a.length, e = a[u], b = e.dataset.value;
201
- b && (e.focus(), c(b));
198
+ const o = r.current.querySelector("[role=radio][aria-checked=true]"), t = Array.from(r.current.querySelectorAll("[role=radio]"));
199
+ if (t.length === 0) return;
200
+ const u = ((o ? t.indexOf(o) : 0) + 1) % t.length, a = t[u], m = a.dataset.value;
201
+ m && (a.focus(), c(m));
202
202
  }
203
203
  }, V = ()=>{
204
204
  if (r.current) {
205
- const o = r.current.querySelector("[role=radio][aria-checked=true]"), a = Array.from(r.current.querySelectorAll("[role=radio]"));
206
- if (a.length === 0) return;
207
- const v = o ? a.indexOf(o) : 0, u = (a.length + v - 1) % a.length, e = a[u], b = e.dataset.value;
208
- b && (e.focus(), c(b));
205
+ const o = r.current.querySelector("[role=radio][aria-checked=true]"), t = Array.from(r.current.querySelectorAll("[role=radio]"));
206
+ if (t.length === 0) return;
207
+ const R = o ? t.indexOf(o) : 0, u = (t.length + R - 1) % t.length, a = t[u], m = a.dataset.value;
208
+ m && (a.focus(), c(m));
209
209
  }
210
210
  };
211
211
  i.useEffect(()=>{
@@ -216,22 +216,23 @@ const S = /*#__PURE__*/ i.createContext({
216
216
  }
217
217
  }, []);
218
218
  var _ref1;
219
- const d = (_ref1 = C !== null && C !== void 0 ? C : g) !== null && _ref1 !== void 0 ? _ref1 : null;
219
+ const d = (_ref1 = v !== null && v !== void 0 ? v : p) !== null && _ref1 !== void 0 ? _ref1 : null;
220
220
  return /* @__PURE__ */ n("div", _object_spread_props(_object_spread({
221
221
  ref: O(r, x),
222
222
  role: "radiogroup",
223
- "aria-labelledby": t["aria-labelledby"]
224
- }, N(t.dataAttributes, "RadioGroup")), {
223
+ "aria-label": e["aria-label"],
224
+ "aria-labelledby": e["aria-label"] ? void 0 : e["aria-labelledby"]
225
+ }, N(e.dataAttributes, "RadioGroup")), {
225
226
  children: /* @__PURE__ */ n(S.Provider, {
226
227
  value: {
227
228
  disabled: f,
228
- selectedValue: C !== null && C !== void 0 ? C : h,
229
+ selectedValue: v !== null && v !== void 0 ? v : h,
229
230
  focusableValue: d,
230
231
  select: c,
231
- selectNext: m,
232
+ selectNext: b,
232
233
  selectPrev: V
233
234
  },
234
- children: t.children
235
+ children: e.children
235
236
  })
236
237
  }));
237
238
  }, re = J;
@@ -0,0 +1,6 @@
1
+ import "./sprinkles.css.ts.vanilla.css-mistica.js";
2
+ import "./rating.css.ts.vanilla.css-mistica.js";
3
+ var a = "igrtie3 _1y2v1nfhk _1y2v1nfht _1y2v1nfhz", v = "igrtie9", e = "igrtiea", t = "igrtie8 _1y2v1nfhe", n = "_1y2v1nfhe", o = "igrtie6 _1y2v1nfhf", c = "igrtieb", f = "igrtiec", h = {
4
+ iconSize: "var(--igrtie0)"
5
+ };
6
+ export { a as IconWrapper, v as disabled, e as firstIcon, t as halfIconActive, n as halfIconContainer, o as halfIconInactive, c as lastIcon, f as touchable, h as vars };
@@ -0,0 +1,2 @@
1
+ const a = "";
2
+ export { a as default };
@@ -0,0 +1,257 @@
1
+ "use client";
2
+ function _define_property(obj, key, value) {
3
+ if (key in obj) {
4
+ Object.defineProperty(obj, key, {
5
+ value: value,
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true
9
+ });
10
+ } else {
11
+ obj[key] = value;
12
+ }
13
+ return obj;
14
+ }
15
+ function _object_spread(target) {
16
+ for(var i = 1; i < arguments.length; i++){
17
+ var source = arguments[i] != null ? arguments[i] : {};
18
+ var ownKeys = Object.keys(source);
19
+ if (typeof Object.getOwnPropertySymbols === "function") {
20
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
21
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
22
+ }));
23
+ }
24
+ ownKeys.forEach(function(key) {
25
+ _define_property(target, key, source[key]);
26
+ });
27
+ }
28
+ return target;
29
+ }
30
+ function _object_without_properties(source, excluded) {
31
+ if (source == null) return {};
32
+ var target = _object_without_properties_loose(source, excluded);
33
+ var key, i;
34
+ if (Object.getOwnPropertySymbols) {
35
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
36
+ for(i = 0; i < sourceSymbolKeys.length; i++){
37
+ key = sourceSymbolKeys[i];
38
+ if (excluded.indexOf(key) >= 0) continue;
39
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
40
+ target[key] = source[key];
41
+ }
42
+ }
43
+ return target;
44
+ }
45
+ function _object_without_properties_loose(source, excluded) {
46
+ if (source == null) return {};
47
+ var target = {};
48
+ var sourceKeys = Object.keys(source);
49
+ var key, i;
50
+ for(i = 0; i < sourceKeys.length; i++){
51
+ key = sourceKeys[i];
52
+ if (excluded.indexOf(key) >= 0) continue;
53
+ target[key] = source[key];
54
+ }
55
+ return target;
56
+ }
57
+ import { jsx as r, jsxs as k } from "react/jsx-runtime";
58
+ import * as T from "react";
59
+ import U from "./inline.js";
60
+ import { vars as c } from "./skins/skin-contract.css-mistica.js";
61
+ import { useThemeVariant as P } from "./theme-variant-context.js";
62
+ import { vars as W, touchable as J, disabled as K, firstIcon as X, lastIcon as Y, IconWrapper as z, halfIconContainer as x, halfIconInactive as oo, halfIconActive as to } from "./rating.css-mistica.js";
63
+ import ro from "classnames";
64
+ import { applyCssVars as ao } from "./utils/css.js";
65
+ import { isTouchableDevice as eo } from "./utils/environment.js";
66
+ import co, { RadioGroup as io } from "./radio-button.js";
67
+ import { isEqual as no } from "./utils/helpers.js";
68
+ import q from "./generated/mistica-icons/icon-star-filled.js";
69
+ import D from "./generated/mistica-icons/icon-star-regular.js";
70
+ import lo from "./generated/mistica-icons/icon-face-sad-filled.js";
71
+ import so from "./generated/mistica-icons/icon-face-sad-regular.js";
72
+ import mo from "./generated/mistica-icons/icon-face-slightly-sad-filled.js";
73
+ import Io from "./generated/mistica-icons/icon-face-slightly-sad-regular.js";
74
+ import vo from "./generated/mistica-icons/icon-face-neutral-filled.js";
75
+ import uo from "./generated/mistica-icons/icon-face-neutral-regular.js";
76
+ import po from "./generated/mistica-icons/icon-face-happy-filled.js";
77
+ import fo from "./generated/mistica-icons/icon-face-happy-regular.js";
78
+ import go from "./generated/mistica-icons/icon-face-super-happy-filled.js";
79
+ import bo from "./generated/mistica-icons/icon-face-super-happy-regular.js";
80
+ import { useTheme as ho } from "./hooks.js";
81
+ import { ratingVeryBadLabel as Ao, ratingBadLabel as Fo, ratingRegularLabel as Ro, ratingGoodLabel as So, ratingVeryGoodLabel as Lo, ratingQuantitativeLabel as No } from "./text-tokens.js";
82
+ const To = 32, _o = 16, yo = 5, Eo = {
83
+ ActiveIcon: q,
84
+ InactiveIcon: D,
85
+ color: c.colors.controlActivated
86
+ }, Co = {
87
+ ActiveIcon: q,
88
+ InactiveIcon: D,
89
+ color: c.colors.warning
90
+ }, V = [
91
+ {
92
+ ActiveIcon: lo,
93
+ InactiveIcon: so,
94
+ color: c.colors.errorHigh
95
+ },
96
+ {
97
+ ActiveIcon: mo,
98
+ InactiveIcon: Io,
99
+ color: c.colors.error
100
+ },
101
+ {
102
+ ActiveIcon: vo,
103
+ InactiveIcon: uo,
104
+ color: c.colors.warning
105
+ },
106
+ {
107
+ ActiveIcon: po,
108
+ InactiveIcon: fo,
109
+ color: c.colors.success
110
+ },
111
+ {
112
+ ActiveIcon: go,
113
+ InactiveIcon: bo,
114
+ color: c.colors.successHigh
115
+ }
116
+ ], Go = (param)=>{
117
+ let { value: i, defaultValue: e, iconsCount: I, onChangeValue: a } = param;
118
+ const n = i !== void 0, p = T.useCallback((l)=>l === void 0 ? 0 : Math.max(0, Math.min(I, l)), [
119
+ I
120
+ ]), [A, F] = T.useState(p(e)), R = (l)=>{
121
+ n || F(l), a == null || a(l);
122
+ };
123
+ return [
124
+ n ? p(i) : A,
125
+ R
126
+ ];
127
+ }, H = (param)=>{
128
+ let { icons: i = V, count: e = yo, icon: I = Eo, size: a = To, type: n = "quantitative", dataAttributes: p, onChangeValue: A, defaultValue: F, value: R, disabled: l, role: S, valueLabels: O, withHalfValue: Q, "aria-label": f, "aria-labelledby": L } = param;
129
+ const { texts: v, t: u } = ho(), $ = [
130
+ v.ratingVeryBadLabel || u(Ao),
131
+ v.ratingBadLabel || u(Fo),
132
+ v.ratingRegularLabel || u(Ro),
133
+ v.ratingGoodLabel || u(So),
134
+ v.ratingVeryGoodLabel || u(Lo)
135
+ ], B = Array.from({
136
+ length: e
137
+ }, (o, t)=>(v.ratingQuantitativeLabel || u(No)).replace("1$s", String(t + 1)).replace("2$s", String(e))), m = n === "qualitative" ? i : Array.from({
138
+ length: e
139
+ }, ()=>I), g = O !== null && O !== void 0 ? O : n === "qualitative" && no(m, V) ? $ : B, b = S === "radiogroup", _ = b ? 16 : a <= 16 ? 2 : a <= 24 ? 4 : 8, y = P(), [N, E] = T.useState(void 0), C = eo(), [s, M] = Go({
140
+ value: R,
141
+ defaultValue: F,
142
+ iconsCount: m.length,
143
+ onChangeValue: A
144
+ }), j = (o)=>N !== void 0 && !l ? n === "qualitative" && o === N || n === "quantitative" && o <= N ? "active" : "inactive" : n === "qualitative" ? o === s ? "active" : "inactive" : b ? o <= s ? "active" : "inactive" : Q ? o - 0.75 <= s && s < o - 0.25 ? "half" : o - 0.25 <= s ? "active" : "inactive" : o - 0.5 < s ? "active" : "inactive", w = (o, t)=>{
145
+ const d = y === "inverse" ? c.colors.inverse : m[t].color, h = y === "inverse" ? c.colors.inverse : b ? c.colors.control : m[0].color;
146
+ switch(j(t + 1)){
147
+ case "active":
148
+ return /* @__PURE__ */ r(o.ActiveIcon, {
149
+ size: a,
150
+ color: d
151
+ }, t);
152
+ case "inactive":
153
+ return /* @__PURE__ */ r(o.InactiveIcon, {
154
+ size: a,
155
+ color: h
156
+ }, t);
157
+ case "half":
158
+ default:
159
+ return /* @__PURE__ */ k("div", {
160
+ className: x,
161
+ children: [
162
+ /* @__PURE__ */ r("div", {
163
+ className: oo,
164
+ children: /* @__PURE__ */ r(o.InactiveIcon, {
165
+ size: a,
166
+ color: h
167
+ })
168
+ }),
169
+ /* @__PURE__ */ r("div", {
170
+ className: to,
171
+ children: /* @__PURE__ */ r(o.ActiveIcon, {
172
+ size: a,
173
+ color: d
174
+ })
175
+ })
176
+ ]
177
+ }, t);
178
+ }
179
+ }, G = (o, t)=>{
180
+ const d = w(o, t);
181
+ return b ? /* @__PURE__ */ r(co, {
182
+ "aria-label": g[t],
183
+ value: g[t],
184
+ render: (param)=>{
185
+ let { labelId: h, disabled: Z } = param;
186
+ return /* @__PURE__ */ r("div", {
187
+ id: h,
188
+ onMouseEnter: ()=>{
189
+ C || E(t + 1);
190
+ },
191
+ onMouseLeave: ()=>{
192
+ C || E(void 0);
193
+ },
194
+ style: ao({
195
+ [W.iconSize]: `${a}px`
196
+ }),
197
+ className: ro(J, {
198
+ [K]: Z,
199
+ [X]: t === 0,
200
+ [Y]: t === m.length - 1
201
+ }),
202
+ children: /* @__PURE__ */ r("div", {
203
+ className: z,
204
+ children: d
205
+ })
206
+ });
207
+ }
208
+ }, t) : d;
209
+ };
210
+ return S === "img" ? /* @__PURE__ */ r(U, {
211
+ space: _,
212
+ dataAttributes: p,
213
+ role: S,
214
+ "aria-label": f !== null && f !== void 0 ? f : L ? void 0 : `${s} de ${e}`,
215
+ "aria-labelledby": f ? void 0 : L,
216
+ children: m.map(G)
217
+ }) : /* @__PURE__ */ r(io, {
218
+ name: "info-rating",
219
+ "aria-label": f,
220
+ "aria-labelledby": f ? void 0 : L,
221
+ disabled: l,
222
+ onChange: (o)=>{
223
+ M(g.findIndex((t)=>t === o) + 1);
224
+ },
225
+ value: g[s - 1],
226
+ dataAttributes: p,
227
+ children: /* @__PURE__ */ r(U, {
228
+ space: _,
229
+ children: m.map(G)
230
+ })
231
+ });
232
+ }, rt = (_param)=>{
233
+ var { dataAttributes: i } = _param, e = _object_without_properties(_param, [
234
+ "dataAttributes"
235
+ ]);
236
+ return /* @__PURE__ */ r(H, _object_spread({
237
+ role: "radiogroup",
238
+ dataAttributes: _object_spread({
239
+ "component-name": "Rating"
240
+ }, i)
241
+ }, e));
242
+ }, at = (_param)=>{
243
+ var { dataAttributes: i, icon: e, size: I } = _param, a = _object_without_properties(_param, [
244
+ "dataAttributes",
245
+ "icon",
246
+ "size"
247
+ ]);
248
+ return /* @__PURE__ */ r(H, _object_spread({
249
+ size: I !== null && I !== void 0 ? I : _o,
250
+ icon: e !== null && e !== void 0 ? e : Co,
251
+ role: "img",
252
+ dataAttributes: _object_spread({
253
+ "component-name": "InfoRating"
254
+ }, i)
255
+ }, a));
256
+ };
257
+ export { at as InfoRating, rt as Rating };