@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
@@ -0,0 +1,366 @@
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 ownKeys(object, enumerableOnly) {
31
+ var keys = Object.keys(object);
32
+ if (Object.getOwnPropertySymbols) {
33
+ var symbols = Object.getOwnPropertySymbols(object);
34
+ if (enumerableOnly) {
35
+ symbols = symbols.filter(function(sym) {
36
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
37
+ });
38
+ }
39
+ keys.push.apply(keys, symbols);
40
+ }
41
+ return keys;
42
+ }
43
+ function _object_spread_props(target, source) {
44
+ source = source != null ? source : {};
45
+ if (Object.getOwnPropertyDescriptors) {
46
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
47
+ } else {
48
+ ownKeys(Object(source)).forEach(function(key) {
49
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
50
+ });
51
+ }
52
+ return target;
53
+ }
54
+ function _object_without_properties(source, excluded) {
55
+ if (source == null) return {};
56
+ var target = _object_without_properties_loose(source, excluded);
57
+ var key, i;
58
+ if (Object.getOwnPropertySymbols) {
59
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
60
+ for(i = 0; i < sourceSymbolKeys.length; i++){
61
+ key = sourceSymbolKeys[i];
62
+ if (excluded.indexOf(key) >= 0) continue;
63
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
64
+ target[key] = source[key];
65
+ }
66
+ }
67
+ return target;
68
+ }
69
+ function _object_without_properties_loose(source, excluded) {
70
+ if (source == null) return {};
71
+ var target = {};
72
+ var sourceKeys = Object.keys(source);
73
+ var key, i;
74
+ for(i = 0; i < sourceKeys.length; i++){
75
+ key = sourceKeys[i];
76
+ if (excluded.indexOf(key) >= 0) continue;
77
+ target[key] = source[key];
78
+ }
79
+ return target;
80
+ }
81
+ import { jsx as e, jsxs as g, Fragment as L } from "react/jsx-runtime";
82
+ import T from "classnames";
83
+ import * as t from "react";
84
+ import { transitionDuration as k, overlay as w, closingOverlay as x, SheetContainer as A, closingSheet as M, Sheet as C, SheetContent as P, handleContainer as Y, handle as _, children as O, modalCloseButton as G, stickyTitle as j, bodyContent as F, stickyButtons as H } from "./sheet-common.css-mistica.js";
85
+ import V from "./focus-trap.js";
86
+ import { useTheme as $, useDisableBodyScroll as z, useIsInViewport as y, useScreenSize as K } from "./hooks.js";
87
+ import { useSetModalStateEffect as X } from "./modal-context-provider.js";
88
+ import { Portal as q } from "./portal.js";
89
+ import { Text5 as J, Text3 as Q, Text2 as D } from "./text.js";
90
+ import { vars as b } from "./skins/skin-contract.css-mistica.js";
91
+ import B from "./stack.js";
92
+ import E from "./box.js";
93
+ import I from "./divider.js";
94
+ import { getPrefixedDataAttributes as U, getScrollableParentElement as W } from "./utils/dom.js";
95
+ import Z from "./generated/mistica-icons/icon-close-regular.js";
96
+ import { InternalIconButton as ee } from "./icon-button.js";
97
+ import te from "./button-layout.js";
98
+ import { safeAreaInsetBottom as re } from "./utils/css.js";
99
+ import { MOBILE_SIDE_MARGIN as ne, TABLET_SIDE_MARGIN as oe, SMALL_DESKTOP_SIDE_MARGIN as se } from "./responsive-layout.css-mistica.js";
100
+ import { modalClose as ie } from "./text-tokens.js";
101
+ const ce = process.env.NODE_ENV === "test" ? 0 : k, N = (n)=>"touches" in n ? n.touches[0].clientY : n.clientY, ae = (param)=>{
102
+ let { closeModal: n } = param;
103
+ const [o, i] = t.useState(0), l = t.useRef(!1), m = t.useRef(0), v = t.useRef(0), r = t.useRef(0), c = t.useRef(0), { isDesktopOrBigger: d } = K(), a = t.useCallback((s)=>{
104
+ l.current = !0, m.current = 0, v.current = Date.now(), r.current = N(s);
105
+ }, []), f = t.useCallback(()=>{
106
+ l.current = !1, i(0);
107
+ }, []);
108
+ return t.useEffect(()=>{
109
+ if (d) return;
110
+ const s = (p)=>{
111
+ if (l.current) {
112
+ if (m.current < 3) {
113
+ m.current++;
114
+ return;
115
+ }
116
+ c.current = N(p), i(c.current - r.current);
117
+ }
118
+ }, h = ()=>{
119
+ if (!l.current) return;
120
+ const p = Date.now() - v.current, S = c.current - r.current, u = S / p;
121
+ l.current = !1, i(0), S > 50 && (c.current > window.innerHeight * 0.75 || u > 0.5) && n();
122
+ };
123
+ return document.addEventListener("touchmove", s), document.addEventListener("touchend", h), document.addEventListener("mousemove", s), document.addEventListener("mouseup", h), ()=>{
124
+ document.removeEventListener("touchmove", s), document.removeEventListener("touchend", h), document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", h);
125
+ };
126
+ }, [
127
+ n,
128
+ d
129
+ ]), d ? {} : {
130
+ onTouchStart: a,
131
+ onMouseDown: a,
132
+ style: o ? {
133
+ transform: `translateY(${o}px)`,
134
+ transition: "none"
135
+ } : void 0,
136
+ onScroll: f,
137
+ overlayStyle: o ? {
138
+ // decrease opacity when dragging down the sheet
139
+ opacity: 0.25 + 1 - o / (window.innerHeight - r.current),
140
+ transition: "none"
141
+ } : void 0
142
+ };
143
+ }, le = {
144
+ closed: {
145
+ open: "opening"
146
+ },
147
+ opening: {
148
+ close: "closed",
149
+ transitionEnd: "open"
150
+ },
151
+ open: {
152
+ close: "closing"
153
+ },
154
+ closing: {
155
+ transitionEnd: "closed"
156
+ }
157
+ }, de = (n, o)=>le[n][o] || n, ue = /*#__PURE__*/ t.forwardRef((param, l)=>{
158
+ let { onClose: n, children: o, dataAttributes: i } = param;
159
+ const { texts: m, t: v } = $(), [r, c] = t.useReducer(de, "closed"), d = t.useRef(!1), a = t.useId(), f = t.useCallback((u)=>{
160
+ u.target === u.currentTarget && c("transitionEnd");
161
+ }, []), s = ()=>{
162
+ r === "open" && c("close");
163
+ };
164
+ t.useEffect(()=>{
165
+ if (r === "opening" || r === "closing") {
166
+ const u = setTimeout(()=>{
167
+ c("transitionEnd");
168
+ }, ce);
169
+ return ()=>clearTimeout(u);
170
+ }
171
+ }, [
172
+ r
173
+ ]), t.useEffect(()=>{
174
+ r === "closed" ? d.current ? n == null || n() : c("open") : d.current = !0;
175
+ }, [
176
+ r,
177
+ n
178
+ ]);
179
+ const _ae = ae({
180
+ closeModal: s
181
+ }), { onScroll: h, overlayStyle: p } = _ae, S = _object_without_properties(_ae, [
182
+ "onScroll",
183
+ "overlayStyle"
184
+ ]);
185
+ return X(), z(r !== "closed"), r === "closed" ? null : /* @__PURE__ */ e(q, {
186
+ children: /* @__PURE__ */ g(V, {
187
+ children: [
188
+ /* @__PURE__ */ e("div", {
189
+ className: T(w, {
190
+ [x]: r === "closing"
191
+ }),
192
+ style: p,
193
+ onClick: s
194
+ }),
195
+ /* @__PURE__ */ e("div", _object_spread_props(_object_spread({
196
+ className: T(A, {
197
+ [M]: r === "closing"
198
+ }),
199
+ onTransitionEnd: f,
200
+ onAnimationEnd: f
201
+ }, S, U(i, "Sheet")), {
202
+ ref: l,
203
+ children: /* @__PURE__ */ e("div", {
204
+ className: C,
205
+ children: /* @__PURE__ */ g("div", {
206
+ className: P,
207
+ children: [
208
+ /* @__PURE__ */ e("div", {
209
+ className: Y,
210
+ children: /* @__PURE__ */ e("div", {
211
+ className: _
212
+ })
213
+ }),
214
+ /* @__PURE__ */ g("section", {
215
+ role: "dialog",
216
+ "aria-modal": "true",
217
+ "aria-labelledby": a,
218
+ onScroll: h,
219
+ className: O,
220
+ style: {
221
+ paddingBottom: re
222
+ },
223
+ children: [
224
+ typeof o == "function" ? o({
225
+ closeModal: s,
226
+ modalTitleId: a
227
+ }) : o,
228
+ /* @__PURE__ */ e("div", {
229
+ className: G,
230
+ children: /* @__PURE__ */ e(ee, {
231
+ onPress: s,
232
+ "aria-label": m.modalClose || v(ie),
233
+ Icon: Z,
234
+ bleedLeft: !0,
235
+ bleedRight: !0,
236
+ bleedY: !0
237
+ })
238
+ })
239
+ ]
240
+ })
241
+ ]
242
+ })
243
+ })
244
+ }))
245
+ ]
246
+ })
247
+ });
248
+ }), R = {
249
+ mobile: ne,
250
+ tablet: oe,
251
+ desktop: se
252
+ }, xe = (param)=>{
253
+ let { title: n, subtitle: o, description: i, modalTitleId: l, button: m, secondaryButton: v, link: r, children: c } = param;
254
+ const d = t.useRef(null), a = t.useRef(null), f = t.useRef(null);
255
+ t.useEffect(()=>{
256
+ a.current && (f.current = W(a.current));
257
+ }, []);
258
+ const s = !y(d, !0, {
259
+ root: f.current
260
+ }), h = !y(a, !0, {
261
+ rootMargin: "1px",
262
+ // bottomScrollSignal div has 0px height so we need a 1px margin to trigger the intersection observer
263
+ root: f.current
264
+ }), p = !!m || !!v || !!r;
265
+ return /* @__PURE__ */ g(L, {
266
+ children: [
267
+ /* @__PURE__ */ e("div", {
268
+ ref: d
269
+ }),
270
+ /* @__PURE__ */ g("div", {
271
+ className: j,
272
+ children: [
273
+ n ? /* @__PURE__ */ e(E, {
274
+ paddingBottom: 8,
275
+ paddingTop: {
276
+ mobile: 0,
277
+ desktop: 40
278
+ },
279
+ paddingX: R,
280
+ children: /* @__PURE__ */ e(J, {
281
+ as: "h2",
282
+ id: l,
283
+ truncate: !0,
284
+ children: n
285
+ })
286
+ }) : /* @__PURE__ */ e(E, {
287
+ paddingTop: {
288
+ mobile: 0,
289
+ desktop: 40
290
+ }
291
+ }),
292
+ s && /* @__PURE__ */ e(I, {})
293
+ ]
294
+ }),
295
+ /* @__PURE__ */ e("div", {
296
+ className: F,
297
+ children: /* @__PURE__ */ e(E, {
298
+ paddingBottom: p ? 0 : {
299
+ desktop: 40,
300
+ mobile: 0
301
+ },
302
+ paddingX: R,
303
+ children: /* @__PURE__ */ g(B, {
304
+ space: 8,
305
+ children: [
306
+ o || i ? /* @__PURE__ */ g(B, {
307
+ space: {
308
+ mobile: 8,
309
+ desktop: 16
310
+ },
311
+ children: [
312
+ o && /* @__PURE__ */ e(Q, {
313
+ as: "p",
314
+ regular: !0,
315
+ children: o
316
+ }),
317
+ i && (Array.isArray(i) ? /* @__PURE__ */ e(D, {
318
+ as: "div",
319
+ regular: !0,
320
+ color: b.colors.textSecondary,
321
+ children: i.map((S, u)=>/* @__PURE__ */ e("p", {
322
+ style: {
323
+ margin: 0,
324
+ marginBottom: u < i.length - 1 ? "1em" : void 0
325
+ },
326
+ children: S
327
+ }, u))
328
+ }) : /* @__PURE__ */ e(D, {
329
+ as: "p",
330
+ regular: !0,
331
+ color: b.colors.textSecondary,
332
+ children: i
333
+ }))
334
+ ]
335
+ }) : null,
336
+ c
337
+ ]
338
+ })
339
+ })
340
+ }),
341
+ p && /* @__PURE__ */ g("div", {
342
+ className: H,
343
+ children: [
344
+ h && /* @__PURE__ */ e(I, {}),
345
+ /* @__PURE__ */ e(E, {
346
+ paddingY: {
347
+ mobile: 16,
348
+ desktop: 40
349
+ },
350
+ paddingX: R,
351
+ children: /* @__PURE__ */ e(te, {
352
+ align: "full-width",
353
+ link: r,
354
+ primaryButton: m,
355
+ secondaryButton: v
356
+ })
357
+ })
358
+ ]
359
+ }),
360
+ /* @__PURE__ */ e("div", {
361
+ ref: a
362
+ })
363
+ ]
364
+ });
365
+ }, Ae = ue;
366
+ export { xe as SheetBody, Ae as default };
@@ -0,0 +1,3 @@
1
+ import "./sprinkles.css.ts.vanilla.css-mistica.js";
2
+ var f = "_1y2v1nfhk _1y2v1nfhz _1y2v1nfiw";
3
+ export { f as infoItemIcon };
@@ -0,0 +1,101 @@
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
+ import { jsx as r, jsxs as e } from "react/jsx-runtime";
31
+ import * as u from "react";
32
+ import I from "./inline.js";
33
+ import x from "./circle.js";
34
+ import y, { SheetBody as S } from "./sheet-common.js";
35
+ import { useTheme as g } from "./hooks.js";
36
+ import k from "./box.js";
37
+ import t from "./stack.js";
38
+ import { Text3 as b, Text2 as B } from "./text.js";
39
+ import { vars as c } from "./skins/skin-contract.css-mistica.js";
40
+ import { infoItemIcon as D } from "./sheet-info.css-mistica.js";
41
+ import T from "./image.js";
42
+ const j = /*#__PURE__*/ u.forwardRef((param, m)=>{
43
+ let { title: n, subtitle: i, description: l, items: a, onClose: s, dataAttributes: p } = param;
44
+ const { isDarkMode: d } = g();
45
+ return /* @__PURE__ */ r(y, {
46
+ onClose: s,
47
+ ref: m,
48
+ dataAttributes: _object_spread({
49
+ "component-name": "InfoSheet"
50
+ }, p),
51
+ children: (param)=>{
52
+ let { modalTitleId: f } = param;
53
+ return /* @__PURE__ */ r(S, {
54
+ title: n,
55
+ subtitle: i,
56
+ description: l,
57
+ modalTitleId: f,
58
+ children: /* @__PURE__ */ r(k, {
59
+ paddingBottom: 16,
60
+ children: /* @__PURE__ */ r(t, {
61
+ space: 16,
62
+ role: "list",
63
+ children: a.map((o, h)=>/* @__PURE__ */ e(I, {
64
+ space: 8,
65
+ children: [
66
+ /* @__PURE__ */ r("div", {
67
+ className: D,
68
+ children: o.icon.type === "bullet" ? /* @__PURE__ */ r(x, {
69
+ size: 8,
70
+ backgroundColor: c.colors.textPrimary
71
+ }) : o.icon.Icon ? /* @__PURE__ */ r(o.icon.Icon, {
72
+ size: o.icon.type === "small" ? 16 : 24
73
+ }) : /* @__PURE__ */ r(T, {
74
+ src: d && o.icon.urlDark ? o.icon.urlDark : o.icon.url,
75
+ width: o.icon.type === "small" ? 16 : 24,
76
+ height: o.icon.type === "small" ? 16 : 24
77
+ })
78
+ }),
79
+ /* @__PURE__ */ e(t, {
80
+ space: 2,
81
+ children: [
82
+ /* @__PURE__ */ r(b, {
83
+ regular: !0,
84
+ children: o.title
85
+ }),
86
+ o.description && /* @__PURE__ */ r(B, {
87
+ regular: !0,
88
+ color: c.colors.textSecondary,
89
+ children: o.description
90
+ })
91
+ ]
92
+ })
93
+ ]
94
+ }, o.id || h))
95
+ })
96
+ })
97
+ });
98
+ }
99
+ });
100
+ }), E = j;
101
+ export { E as default };
@@ -0,0 +1,164 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ const I = (e)=>Array.isArray(e) ? e.length ? e.join(`
31
+
32
+ `) : void 0 : e, a = (e, param)=>{
33
+ let { title: r, subtitle: t, description: n, selectedId: s, items: o } = param;
34
+ return e({
35
+ title: r,
36
+ subtitle: t,
37
+ // TODO: add multiline support to native sheet
38
+ description: I(n),
39
+ content: [
40
+ {
41
+ type: "LIST",
42
+ id: "list-0",
43
+ listType: "SINGLE_SELECTION",
44
+ autoSubmit: !0,
45
+ selectedIds: typeof s == "string" ? [
46
+ s
47
+ ] : [],
48
+ items: o
49
+ }
50
+ ]
51
+ }).then((param)=>{
52
+ let { action: i, result: d } = param;
53
+ return i === "SUBMIT" ? {
54
+ action: i,
55
+ selectedId: d[0].selectedIds[0]
56
+ } : {
57
+ action: i,
58
+ selectedId: null
59
+ };
60
+ });
61
+ }, T = (e, param)=>{
62
+ let { title: r, subtitle: t, description: n, items: s } = param;
63
+ return e({
64
+ title: r,
65
+ subtitle: t,
66
+ // TODO: add multiline support to native sheet
67
+ description: I(n),
68
+ content: [
69
+ {
70
+ type: "LIST",
71
+ id: "list-0",
72
+ listType: "ACTIONS",
73
+ autoSubmit: !0,
74
+ selectedIds: [],
75
+ items: s
76
+ }
77
+ ]
78
+ }).then((param)=>{
79
+ let { action: o, result: i } = param;
80
+ return o === "SUBMIT" ? {
81
+ action: o,
82
+ selectedId: i[0].selectedIds[0]
83
+ } : {
84
+ action: o,
85
+ selectedId: null
86
+ };
87
+ });
88
+ }, N = function() {
89
+ var _ref = _async_to_generator(function*(e, param) {
90
+ let { title: r, subtitle: t, description: n, items: s } = param;
91
+ yield e({
92
+ title: r,
93
+ subtitle: t,
94
+ // TODO: add multiline support to native sheet
95
+ description: I(n),
96
+ content: [
97
+ {
98
+ type: "LIST",
99
+ id: "list-0",
100
+ listType: "INFORMATIVE",
101
+ autoSubmit: !1,
102
+ selectedIds: [],
103
+ items: s
104
+ }
105
+ ]
106
+ });
107
+ });
108
+ return function N(e, _) {
109
+ return _ref.apply(this, arguments);
110
+ };
111
+ }(), p = (e, param)=>{
112
+ let { title: r, subtitle: t, description: n, button: s, secondaryButton: o, link: i } = param;
113
+ return e({
114
+ title: r,
115
+ subtitle: t,
116
+ // TODO: add multiline support to native sheet
117
+ description: I(n),
118
+ content: [
119
+ {
120
+ type: "BOTTOM_ACTIONS",
121
+ id: "bottom-actions-0",
122
+ button: s,
123
+ secondaryButton: o,
124
+ link: i
125
+ }
126
+ ]
127
+ }).then((param)=>{
128
+ let { action: d, result: l } = param;
129
+ if (d === "SUBMIT") {
130
+ const u = l.find((param)=>{
131
+ let { id: S } = param;
132
+ return S === "bottom-actions-0";
133
+ }), c = u == null ? void 0 : u.selectedIds[0];
134
+ if (c === "PRIMARY" || c === "SECONDARY" || c === "LINK") return {
135
+ action: c
136
+ };
137
+ }
138
+ return {
139
+ action: "DISMISS"
140
+ };
141
+ });
142
+ }, h = (e, r)=>{
143
+ let t;
144
+ const { type: n, props: s } = r;
145
+ switch(n){
146
+ case "INFO":
147
+ t = N(e, s);
148
+ break;
149
+ case "ACTIONS_LIST":
150
+ t = T(e, s);
151
+ break;
152
+ case "RADIO_LIST":
153
+ t = a(e, s);
154
+ break;
155
+ case "ACTIONS":
156
+ t = p(e, s);
157
+ break;
158
+ default:
159
+ const o = n;
160
+ throw new Error(`Unknown sheet type: ${o}`);
161
+ }
162
+ return t;
163
+ };
164
+ export { h as showNativeSheet };