@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
@@ -11,25 +11,17 @@ function _export(target, all) {
11
11
  }
12
12
  _export(exports, {
13
13
  SheetRoot: function() {
14
- return M;
14
+ return f;
15
15
  },
16
16
  default: function() {
17
- return F;
17
+ return d;
18
18
  },
19
19
  showSheet: function() {
20
- return B;
20
+ return p;
21
21
  }
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
25
- const _sheet = require("./sheet.js");
26
- const _image = /*#__PURE__*/ _interop_require_default(require("./image.js"));
27
- const _hooks = require("./hooks.js");
28
- function _interop_require_default(obj) {
29
- return obj && obj.__esModule ? obj : {
30
- default: obj
31
- };
32
- }
33
25
  function _getRequireWildcardCache(nodeInterop) {
34
26
  if (typeof WeakMap !== "function") return null;
35
27
  var cacheBabelInterop = new WeakMap();
@@ -71,320 +63,54 @@ function _interop_require_wildcard(obj, nodeInterop) {
71
63
  }
72
64
  return newObj;
73
65
  }
74
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
75
- try {
76
- var info = gen[key](arg);
77
- var value = info.value;
78
- } catch (error) {
79
- reject(error);
80
- return;
81
- }
82
- if (info.done) {
83
- resolve(value);
84
- } else {
85
- Promise.resolve(value).then(_next, _throw);
86
- }
87
- }
88
- function _async_to_generator(fn) {
89
- return function() {
90
- var self = this, args = arguments;
91
- return new Promise(function(resolve, reject) {
92
- var gen = fn.apply(self, args);
93
- function _next(value) {
94
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
95
- }
96
- function _throw(err) {
97
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
98
- }
99
- _next(undefined);
100
- });
101
- };
102
- }
103
- function _define_property(obj, key, value) {
104
- if (key in obj) {
105
- Object.defineProperty(obj, key, {
106
- value: value,
107
- enumerable: true,
108
- configurable: true,
109
- writable: true
110
- });
111
- } else {
112
- obj[key] = value;
113
- }
114
- return obj;
115
- }
116
- function _object_spread(target) {
117
- for(var i = 1; i < arguments.length; i++){
118
- var source = arguments[i] != null ? arguments[i] : {};
119
- var ownKeys = Object.keys(source);
120
- if (typeof Object.getOwnPropertySymbols === "function") {
121
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
122
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
123
- }));
124
- }
125
- ownKeys.forEach(function(key) {
126
- _define_property(target, key, source[key]);
127
- });
128
- }
129
- return target;
130
- }
131
- function ownKeys(object, enumerableOnly) {
132
- var keys = Object.keys(object);
133
- if (Object.getOwnPropertySymbols) {
134
- var symbols = Object.getOwnPropertySymbols(object);
135
- if (enumerableOnly) {
136
- symbols = symbols.filter(function(sym) {
137
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
138
- });
139
- }
140
- keys.push.apply(keys, symbols);
141
- }
142
- return keys;
143
- }
144
- function _object_spread_props(target, source) {
145
- source = source != null ? source : {};
146
- if (Object.getOwnPropertyDescriptors) {
147
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
148
- } else {
149
- ownKeys(Object(source)).forEach(function(key) {
150
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
151
- });
152
- }
153
- return target;
154
- }
155
- let p = null, n = null, l = null;
156
- const d = (r)=>Array.isArray(r) ? r.length ? r.join(`
157
-
158
- `) : void 0 : r, L = (param)=>{
159
- let { title: r, subtitle: c, description: e, selectedId: s, items: t } = param;
160
- return l({
161
- title: r,
162
- subtitle: c,
163
- // TODO: add multiline support to native sheet
164
- description: d(e),
165
- content: [
166
- {
167
- type: "LIST",
168
- id: "list-0",
169
- listType: "SINGLE_SELECTION",
170
- autoSubmit: !0,
171
- selectedIds: typeof s == "string" ? [
172
- s
173
- ] : [],
174
- items: t
175
- }
176
- ]
177
- }).then((param)=>{
178
- let { action: o, result: a } = param;
179
- return o === "SUBMIT" ? {
180
- action: o,
181
- selectedId: a[0].selectedIds[0]
182
- } : {
183
- action: o,
184
- selectedId: null
185
- };
186
- });
187
- }, k = (param)=>{
188
- let { title: r, subtitle: c, description: e, items: s } = param;
189
- return l({
190
- title: r,
191
- subtitle: c,
192
- // TODO: add multiline support to native sheet
193
- description: d(e),
194
- content: [
195
- {
196
- type: "LIST",
197
- id: "list-0",
198
- listType: "ACTIONS",
199
- autoSubmit: !0,
200
- selectedIds: [],
201
- items: s
202
- }
203
- ]
204
- }).then((param)=>{
205
- let { action: t, result: o } = param;
206
- return t === "SUBMIT" ? {
207
- action: t,
208
- selectedId: o[0].selectedIds[0]
209
- } : {
210
- action: t,
211
- selectedId: null
212
- };
213
- });
214
- }, b = function() {
215
- var _ref = _async_to_generator(function*(param) {
216
- let { title: r, subtitle: c, description: e, items: s } = param;
217
- yield l({
218
- title: r,
219
- subtitle: c,
220
- // TODO: add multiline support to native sheet
221
- description: d(e),
222
- content: [
223
- {
224
- type: "LIST",
225
- id: "list-0",
226
- listType: "INFORMATIVE",
227
- autoSubmit: !1,
228
- selectedIds: [],
229
- items: s
230
- }
231
- ]
232
- });
233
- });
234
- return function b(_) {
235
- return _ref.apply(this, arguments);
236
- };
237
- }(), C = function() {
238
- var _ref = _async_to_generator(function*(param) {
239
- let { title: r, subtitle: c, description: e, button: s, secondaryButton: t, link: o } = param;
240
- return l({
241
- title: r,
242
- subtitle: c,
243
- // TODO: add multiline support to native sheet
244
- description: d(e),
245
- content: [
246
- {
247
- type: "BOTTOM_ACTIONS",
248
- id: "bottom-actions-0",
249
- button: s,
250
- secondaryButton: t,
251
- link: o
252
- }
253
- ]
254
- }).then((param)=>{
255
- let { action: a, result: i } = param;
256
- if (a === "SUBMIT") {
257
- const f = i.find((param)=>{
258
- let { id: T } = param;
259
- return T === "bottom-actions-0";
260
- }), I = f == null ? void 0 : f.selectedIds[0];
261
- if (I === "PRIMARY" || I === "SECONDARY" || I === "LINK") return {
262
- action: I
263
- };
264
- }
265
- return {
266
- action: "DISMISS"
267
- };
268
- });
269
- });
270
- return function C(_) {
271
- return _ref.apply(this, arguments);
272
- };
273
- }();
274
- let h = !1;
275
- const B = (r)=>{
276
- const c = ()=>{
277
- if (!p) return Promise.reject(new Error("Tried to show a Sheet but the SheetRoot component was not mounted"));
278
- if (h) return Promise.reject(new Error("Tried to show a Sheet but there is already one open"));
279
- h = !0, p(r);
280
- const e = new Promise((s)=>{
281
- n = s;
66
+ const h = /*#__PURE__*/ _react.lazy(()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require(/* webpackChunkName: "sheet-web" */ "./sheet-web.js"))));
67
+ let i = null, s = null, l = null, u = !1;
68
+ const p = (t)=>{
69
+ const o = ()=>{
70
+ if (!s) return Promise.reject(new Error("Tried to show a Sheet but the SheetRoot component was not mounted"));
71
+ if (u) return Promise.reject(new Error("Tried to show a Sheet but there is already one open"));
72
+ u = !0, s(t);
73
+ const n = new Promise((e)=>{
74
+ l = e;
282
75
  });
283
- return e.finally(()=>{
284
- h = !1;
285
- }), e;
76
+ return n.finally(()=>{
77
+ u = !1;
78
+ }), n;
286
79
  };
287
- if (l) {
288
- let e;
289
- const { type: s, props: t } = r;
290
- switch(s){
291
- case "INFO":
292
- e = b(t);
293
- break;
294
- case "ACTIONS_LIST":
295
- e = k(t);
296
- break;
297
- case "RADIO_LIST":
298
- e = L(t);
299
- break;
300
- case "ACTIONS":
301
- e = C(t);
302
- break;
303
- default:
304
- const o = s;
305
- throw new Error(`Unknown sheet type: ${o}`);
306
- }
307
- return e.catch((o)=>{
308
- if (o.code === "400") return c();
309
- throw o;
80
+ if (i) {
81
+ const n = i;
82
+ return Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require(/* webpackChunkName: "sheet-native" */ "./sheet-native.js"))).then((param)=>{
83
+ let { showNativeSheet: e } = param;
84
+ return e(n, t);
85
+ }).catch((e)=>{
86
+ if (e.code === "400") return o();
87
+ throw e;
310
88
  });
311
- } else return c();
312
- }, M = (r)=>{
313
- const { isDarkMode: c } = (0, _hooks.useTheme)(), [e, s] = _react.useState(null), t = _react.useRef(null);
314
- if (_react.useEffect(()=>{
315
- if (r.nativeImplementation) return l = r.nativeImplementation, ()=>{
316
- l = null;
89
+ } else return o();
90
+ }, f = (t)=>{
91
+ const [o, n] = _react.useState(null);
92
+ return _react.useEffect(()=>{
93
+ if (t.nativeImplementation) return i = t.nativeImplementation, ()=>{
94
+ i = null;
317
95
  };
318
96
  }, [
319
- r.nativeImplementation
320
- ]), _react.useEffect(()=>(p = (i)=>{
321
- t.current = null, s(i);
97
+ t.nativeImplementation
98
+ ]), _react.useEffect(()=>(s = (e)=>{
99
+ n(e);
322
100
  }, ()=>{
323
- p = null;
324
- }), []), !e) return null;
325
- const o = ()=>{
326
- switch(s(null), e.type){
327
- case "INFO":
328
- n == null || n(void 0);
329
- break;
330
- case "ACTIONS_LIST":
331
- t.current ? n == null || n({
332
- action: "SUBMIT",
333
- selectedId: t.current
334
- }) : n == null || n({
335
- action: "DISMISS"
336
- });
337
- break;
338
- case "RADIO_LIST":
339
- t.current ? n == null || n({
340
- action: "SUBMIT",
341
- selectedId: t.current
342
- }) : n == null || n({
343
- action: "DISMISS"
344
- });
345
- break;
346
- case "ACTIONS":
347
- t.current === "PRIMARY" || t.current === "SECONDARY" || t.current === "LINK" ? n == null || n({
348
- action: t.current
349
- }) : n == null || n({
350
- action: "DISMISS"
351
- });
352
- break;
353
- default:
354
- throw new Error(`Unknown sheet type: ${e.type}`);
355
- }
356
- }, a = (i)=>{
357
- t.current = i;
358
- };
359
- switch(e.type){
360
- case "INFO":
361
- return /* @__PURE__ */ (0, _jsxruntime.jsx)(_sheet.InfoSheet, _object_spread_props(_object_spread({}, e.props), {
362
- onClose: o
363
- }));
364
- case "ACTIONS_LIST":
365
- return /* @__PURE__ */ (0, _jsxruntime.jsx)(_sheet.ActionsListSheet, _object_spread_props(_object_spread({}, e.props), {
366
- onClose: o,
367
- onSelect: a
368
- }));
369
- case "RADIO_LIST":
370
- return /* @__PURE__ */ (0, _jsxruntime.jsx)(_sheet.RadioListSheet, _object_spread_props(_object_spread({}, e.props), {
371
- items: e.props.items.map((i)=>_object_spread_props(_object_spread({}, i), {
372
- asset: i.icon && /* @__PURE__ */ (0, _jsxruntime.jsx)(_image.default, {
373
- circular: !0,
374
- src: c && i.icon.urlDark ? i.icon.urlDark : i.icon.url,
375
- width: i.icon.size === "small" ? 24 : 40
376
- })
377
- })),
378
- onClose: o,
379
- onSelect: a
380
- }));
381
- case "ACTIONS":
382
- return /* @__PURE__ */ (0, _jsxruntime.jsx)(_sheet.ActionsSheet, _object_spread_props(_object_spread({}, e.props), {
383
- buttonLink: e.props.link,
384
- onClose: o,
385
- onPressButton: a
386
- }));
387
- default:
388
- throw new Error(`Unknown sheet type: ${e.type}`);
389
- }
390
- }, F = M;
101
+ s = null;
102
+ }), []), /* @__PURE__ */ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
103
+ children: [
104
+ t.children,
105
+ o && /* @__PURE__ */ (0, _jsxruntime.jsx)(_react.Suspense, {
106
+ fallback: null,
107
+ children: /* @__PURE__ */ (0, _jsxruntime.jsx)(h, {
108
+ sheetProps: o,
109
+ onResolve: (e)=>{
110
+ n(null), l == null || l(e);
111
+ }
112
+ })
113
+ })
114
+ ]
115
+ });
116
+ }, d = f;
@@ -0,0 +1,88 @@
1
+ export type NativeSheetImplementation = (typeof import('@tef-novum/webview-bridge'))['bottomSheet'];
2
+ import type { ExclusifyUnion, Id } from './utils/utility-types';
3
+ type InfoIcon = ExclusifyUnion<{
4
+ type: 'small' | 'regular';
5
+ url: string;
6
+ urlDark?: string;
7
+ } | {
8
+ type: 'bullet';
9
+ }>;
10
+ type SheetProps<T> = Id<{
11
+ title?: string;
12
+ subtitle?: string;
13
+ description?: string | Array<string>;
14
+ } & T>;
15
+ export type SheetPropsByType = {
16
+ RADIO_LIST: SheetProps<{
17
+ selectedId?: string;
18
+ items: Array<{
19
+ id: string;
20
+ title?: string;
21
+ description?: string;
22
+ icon?: {
23
+ size?: 'small' | 'large';
24
+ url: string;
25
+ urlDark?: string;
26
+ };
27
+ }>;
28
+ }>;
29
+ ACTIONS_LIST: SheetProps<{
30
+ items: Array<{
31
+ id: string;
32
+ title: string;
33
+ style?: 'normal' | 'destructive';
34
+ icon?: {
35
+ url: string;
36
+ urlDark?: string;
37
+ };
38
+ }>;
39
+ }>;
40
+ INFO: SheetProps<{
41
+ items: Array<{
42
+ id: string;
43
+ title: string;
44
+ description?: string;
45
+ icon: InfoIcon;
46
+ }>;
47
+ }>;
48
+ ACTIONS: SheetProps<{
49
+ button: {
50
+ text: string;
51
+ };
52
+ secondaryButton?: {
53
+ text: string;
54
+ };
55
+ link?: {
56
+ text: string;
57
+ withChevron?: boolean;
58
+ };
59
+ }>;
60
+ };
61
+ export type SheetType = keyof SheetPropsByType;
62
+ export type SheetResultByType = {
63
+ RADIO_LIST: {
64
+ action: 'SUBMIT';
65
+ selectedId: string;
66
+ } | {
67
+ action: 'DISMISS';
68
+ };
69
+ ACTIONS_LIST: {
70
+ action: 'SUBMIT';
71
+ selectedId: string;
72
+ } | {
73
+ action: 'DISMISS';
74
+ };
75
+ INFO: void;
76
+ ACTIONS: {
77
+ action: 'PRIMARY' | 'SECONDARY' | 'LINK' | 'DISMISS';
78
+ };
79
+ };
80
+ export type SheetTypeWithProps<T extends SheetType> = Id<{
81
+ type: T;
82
+ props: SheetPropsByType[T];
83
+ }>;
84
+ export type SheetTypeWithPropsUnion = {
85
+ [T in SheetType]: SheetTypeWithProps<T>;
86
+ }[SheetType];
87
+ export type SheetPromiseResolve = <T>(value: T extends SheetType ? SheetResultByType[T] : 'You must provide a type parameter') => void;
88
+ export {};
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { SheetPromiseResolve, SheetTypeWithPropsUnion } from './sheet-types';
3
+ type SheetWebProps = {
4
+ sheetProps: SheetTypeWithPropsUnion;
5
+ onResolve: SheetPromiseResolve;
6
+ };
7
+ declare const SheetWeb: ({ sheetProps, onResolve }: SheetWebProps) => JSX.Element;
8
+ export default SheetWeb;
@@ -0,0 +1,183 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "default", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return w;
10
+ }
11
+ });
12
+ const _jsxruntime = require("react/jsx-runtime");
13
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
14
+ const _hooks = require("./hooks.js");
15
+ const _image = /*#__PURE__*/ _interop_require_default(require("./image.js"));
16
+ function _interop_require_default(obj) {
17
+ return obj && obj.__esModule ? obj : {
18
+ default: obj
19
+ };
20
+ }
21
+ function _getRequireWildcardCache(nodeInterop) {
22
+ if (typeof WeakMap !== "function") return null;
23
+ var cacheBabelInterop = new WeakMap();
24
+ var cacheNodeInterop = new WeakMap();
25
+ return (_getRequireWildcardCache = function(nodeInterop) {
26
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
27
+ })(nodeInterop);
28
+ }
29
+ function _interop_require_wildcard(obj, nodeInterop) {
30
+ if (!nodeInterop && obj && obj.__esModule) {
31
+ return obj;
32
+ }
33
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
34
+ return {
35
+ default: obj
36
+ };
37
+ }
38
+ var cache = _getRequireWildcardCache(nodeInterop);
39
+ if (cache && cache.has(obj)) {
40
+ return cache.get(obj);
41
+ }
42
+ var newObj = {
43
+ __proto__: null
44
+ };
45
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
46
+ for(var key in obj){
47
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
48
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
49
+ if (desc && (desc.get || desc.set)) {
50
+ Object.defineProperty(newObj, key, desc);
51
+ } else {
52
+ newObj[key] = obj[key];
53
+ }
54
+ }
55
+ }
56
+ newObj.default = obj;
57
+ if (cache) {
58
+ cache.set(obj, newObj);
59
+ }
60
+ return newObj;
61
+ }
62
+ function _define_property(obj, key, value) {
63
+ if (key in obj) {
64
+ Object.defineProperty(obj, key, {
65
+ value: value,
66
+ enumerable: true,
67
+ configurable: true,
68
+ writable: true
69
+ });
70
+ } else {
71
+ obj[key] = value;
72
+ }
73
+ return obj;
74
+ }
75
+ function _object_spread(target) {
76
+ for(var i = 1; i < arguments.length; i++){
77
+ var source = arguments[i] != null ? arguments[i] : {};
78
+ var ownKeys = Object.keys(source);
79
+ if (typeof Object.getOwnPropertySymbols === "function") {
80
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
81
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
82
+ }));
83
+ }
84
+ ownKeys.forEach(function(key) {
85
+ _define_property(target, key, source[key]);
86
+ });
87
+ }
88
+ return target;
89
+ }
90
+ function ownKeys(object, enumerableOnly) {
91
+ var keys = Object.keys(object);
92
+ if (Object.getOwnPropertySymbols) {
93
+ var symbols = Object.getOwnPropertySymbols(object);
94
+ if (enumerableOnly) {
95
+ symbols = symbols.filter(function(sym) {
96
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
97
+ });
98
+ }
99
+ keys.push.apply(keys, symbols);
100
+ }
101
+ return keys;
102
+ }
103
+ function _object_spread_props(target, source) {
104
+ source = source != null ? source : {};
105
+ if (Object.getOwnPropertyDescriptors) {
106
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
107
+ } else {
108
+ ownKeys(Object(source)).forEach(function(key) {
109
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
110
+ });
111
+ }
112
+ return target;
113
+ }
114
+ const S = /*#__PURE__*/ _react.lazy(()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require(/* webpackChunkName: "sheet-actions" */ "./sheet-actions.js")))), I = /*#__PURE__*/ _react.lazy(()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require(/* webpackChunkName: "sheet-info" */ "./sheet-info.js")))), p = /*#__PURE__*/ _react.lazy(()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require(/* webpackChunkName: "sheet-action-list" */ "./sheet-actions-list.js")))), d = /*#__PURE__*/ _react.lazy(()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require(/* webpackChunkName: "sheet-radio-list" */ "./sheet-radio-list.js")))), w = (param)=>{
115
+ let { sheetProps: t, onResolve: e } = param;
116
+ const { isDarkMode: s } = (0, _hooks.useTheme)(), r = _react.useRef(null), i = (n)=>{
117
+ r.current = n;
118
+ }, a = ()=>{
119
+ if (!e) throw new Error("onResolve handler is not set");
120
+ switch(t.type){
121
+ case "INFO":
122
+ e(void 0);
123
+ break;
124
+ case "ACTIONS_LIST":
125
+ r.current ? e({
126
+ action: "SUBMIT",
127
+ selectedId: r.current
128
+ }) : e({
129
+ action: "DISMISS"
130
+ });
131
+ break;
132
+ case "RADIO_LIST":
133
+ r.current ? e({
134
+ action: "SUBMIT",
135
+ selectedId: r.current
136
+ }) : e({
137
+ action: "DISMISS"
138
+ });
139
+ break;
140
+ case "ACTIONS":
141
+ r.current === "PRIMARY" || r.current === "SECONDARY" || r.current === "LINK" ? e({
142
+ action: r.current
143
+ }) : e({
144
+ action: "DISMISS"
145
+ });
146
+ break;
147
+ default:
148
+ throw new Error(`Unknown sheet type: ${t.type}`);
149
+ }
150
+ r.current = null;
151
+ };
152
+ switch(t.type){
153
+ case "INFO":
154
+ return /* @__PURE__ */ (0, _jsxruntime.jsx)(I, _object_spread_props(_object_spread({}, t.props), {
155
+ onClose: a
156
+ }));
157
+ case "ACTIONS_LIST":
158
+ return /* @__PURE__ */ (0, _jsxruntime.jsx)(p, _object_spread_props(_object_spread({}, t.props), {
159
+ onClose: a,
160
+ onSelect: i
161
+ }));
162
+ case "RADIO_LIST":
163
+ return /* @__PURE__ */ (0, _jsxruntime.jsx)(d, _object_spread_props(_object_spread({}, t.props), {
164
+ items: t.props.items.map((n)=>_object_spread_props(_object_spread({}, n), {
165
+ asset: n.icon && /* @__PURE__ */ (0, _jsxruntime.jsx)(_image.default, {
166
+ circular: !0,
167
+ src: s && n.icon.urlDark ? n.icon.urlDark : n.icon.url,
168
+ width: n.icon.size === "small" ? 24 : 40
169
+ })
170
+ })),
171
+ onClose: a,
172
+ onSelect: i
173
+ }));
174
+ case "ACTIONS":
175
+ return /* @__PURE__ */ (0, _jsxruntime.jsx)(S, _object_spread_props(_object_spread({}, t.props), {
176
+ buttonLink: t.props.link,
177
+ onClose: a,
178
+ onPressButton: i
179
+ }));
180
+ default:
181
+ throw new Error(`Unknown sheet type: ${t.type}`);
182
+ }
183
+ };