@telefonica/mistica 14.23.0 → 14.24.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.
@@ -10,13 +10,13 @@ function _export(target, all) {
10
10
  }
11
11
  _export(exports, {
12
12
  SheetRoot: function() {
13
- return C;
13
+ return M;
14
14
  },
15
15
  default: function() {
16
- return B;
16
+ return F;
17
17
  },
18
18
  showSheet: function() {
19
- return _;
19
+ return B;
20
20
  }
21
21
  });
22
22
  const _jsxruntime = require("react/jsx-runtime");
@@ -150,40 +150,44 @@ function _object_spread_props(target, source) {
150
150
  return target;
151
151
  }
152
152
  let p = null, n = null, l = null;
153
- const m = (param)=>{
154
- let { title: s , subtitle: c , description: e , selectedId: o , items: t } = param;
153
+ const d = (r)=>Array.isArray(r) ? r.length ? r.join(`
154
+
155
+ `) : void 0 : r, L = (param)=>{
156
+ let { title: r , subtitle: c , description: e , selectedId: s , items: t } = param;
155
157
  return l({
156
- title: s,
158
+ title: r,
157
159
  subtitle: c,
158
- description: e,
160
+ // TODO: add multiline support to native sheet
161
+ description: d(e),
159
162
  content: [
160
163
  {
161
164
  type: "LIST",
162
165
  id: "list-0",
163
166
  listType: "SINGLE_SELECTION",
164
167
  autoSubmit: !0,
165
- selectedIds: typeof o == "string" ? [
166
- o
168
+ selectedIds: typeof s == "string" ? [
169
+ s
167
170
  ] : [],
168
171
  items: t
169
172
  }
170
173
  ]
171
174
  }).then((param)=>{
172
- let { action: r , result: i } = param;
173
- return r === "SUBMIT" ? {
174
- action: r,
175
- selectedId: i[0].selectedIds[0]
175
+ let { action: o , result: a } = param;
176
+ return o === "SUBMIT" ? {
177
+ action: o,
178
+ selectedId: a[0].selectedIds[0]
176
179
  } : {
177
- action: r,
180
+ action: o,
178
181
  selectedId: null
179
182
  };
180
183
  });
181
- }, L = (param)=>{
182
- let { title: s , subtitle: c , description: e , items: o } = param;
184
+ }, k = (param)=>{
185
+ let { title: r , subtitle: c , description: e , items: s } = param;
183
186
  return l({
184
- title: s,
187
+ title: r,
185
188
  subtitle: c,
186
- description: e,
189
+ // TODO: add multiline support to native sheet
190
+ description: d(e),
187
191
  content: [
188
192
  {
189
193
  type: "LIST",
@@ -191,26 +195,27 @@ const m = (param)=>{
191
195
  listType: "ACTIONS",
192
196
  autoSubmit: !0,
193
197
  selectedIds: [],
194
- items: o
198
+ items: s
195
199
  }
196
200
  ]
197
201
  }).then((param)=>{
198
- let { action: t , result: r } = param;
202
+ let { action: t , result: o } = param;
199
203
  return t === "SUBMIT" ? {
200
204
  action: t,
201
- selectedId: r[0].selectedIds[0]
205
+ selectedId: o[0].selectedIds[0]
202
206
  } : {
203
207
  action: t,
204
208
  selectedId: null
205
209
  };
206
210
  });
207
- }, k = function() {
211
+ }, b = function() {
208
212
  var _ref = _async_to_generator(function*(param) {
209
- let { title: s , subtitle: c , description: e , items: o } = param;
213
+ let { title: r , subtitle: c , description: e , items: s } = param;
210
214
  yield l({
211
- title: s,
215
+ title: r,
212
216
  subtitle: c,
213
- description: e,
217
+ // TODO: add multiline support to native sheet
218
+ description: d(e),
214
219
  content: [
215
220
  {
216
221
  type: "LIST",
@@ -218,37 +223,38 @@ const m = (param)=>{
218
223
  listType: "INFORMATIVE",
219
224
  autoSubmit: !1,
220
225
  selectedIds: [],
221
- items: o
226
+ items: s
222
227
  }
223
228
  ]
224
229
  });
225
230
  });
226
- return function k(_) {
231
+ return function b(_) {
227
232
  return _ref.apply(this, arguments);
228
233
  };
229
- }(), b = function() {
234
+ }(), C = function() {
230
235
  var _ref = _async_to_generator(function*(param) {
231
- let { title: s , subtitle: c , description: e , button: o , secondaryButton: t , link: r } = param;
236
+ let { title: r , subtitle: c , description: e , button: s , secondaryButton: t , link: o } = param;
232
237
  return l({
233
- title: s,
238
+ title: r,
234
239
  subtitle: c,
235
- description: e,
240
+ // TODO: add multiline support to native sheet
241
+ description: d(e),
236
242
  content: [
237
243
  {
238
244
  type: "BOTTOM_ACTIONS",
239
245
  id: "bottom-actions-0",
240
- button: o,
246
+ button: s,
241
247
  secondaryButton: t,
242
- link: r
248
+ link: o
243
249
  }
244
250
  ]
245
251
  }).then((param)=>{
246
- let { action: i , result: a } = param;
247
- if (i === "SUBMIT") {
248
- const d = a.find((param)=>{
252
+ let { action: a , result: i } = param;
253
+ if (a === "SUBMIT") {
254
+ const f = i.find((param)=>{
249
255
  let { id: T } = param;
250
256
  return T === "bottom-actions-0";
251
- }), I = d == null ? void 0 : d.selectedIds[0];
257
+ }), I = f == null ? void 0 : f.selectedIds[0];
252
258
  if (I === "PRIMARY" || I === "SECONDARY" || I === "LINK") return {
253
259
  action: I
254
260
  };
@@ -258,63 +264,63 @@ const m = (param)=>{
258
264
  };
259
265
  });
260
266
  });
261
- return function b(_) {
267
+ return function C(_) {
262
268
  return _ref.apply(this, arguments);
263
269
  };
264
270
  }();
265
- let f = !1;
266
- const _ = (s)=>{
271
+ let h = !1;
272
+ const B = (r)=>{
267
273
  const c = ()=>{
268
274
  if (!p) return Promise.reject(new Error("Tried to show a Sheet but the SheetRoot component was not mounted"));
269
- if (f) return Promise.reject(new Error("Tried to show a Sheet but there is already one open"));
270
- f = !0, p(s);
271
- const e = new Promise((o)=>{
272
- n = o;
275
+ if (h) return Promise.reject(new Error("Tried to show a Sheet but there is already one open"));
276
+ h = !0, p(r);
277
+ const e = new Promise((s)=>{
278
+ n = s;
273
279
  });
274
280
  return e.finally(()=>{
275
- f = !1;
281
+ h = !1;
276
282
  }), e;
277
283
  };
278
284
  if (l) {
279
285
  let e;
280
- const { type: o , props: t } = s;
281
- switch(o){
286
+ const { type: s , props: t } = r;
287
+ switch(s){
282
288
  case "INFO":
283
- e = k(t);
289
+ e = b(t);
284
290
  break;
285
291
  case "ACTIONS_LIST":
286
- e = L(t);
292
+ e = k(t);
287
293
  break;
288
294
  case "RADIO_LIST":
289
- e = m(t);
295
+ e = L(t);
290
296
  break;
291
297
  case "ACTIONS":
292
- e = b(t);
298
+ e = C(t);
293
299
  break;
294
300
  default:
295
- const r = o;
296
- throw new Error(`Unknown sheet type: ${r}`);
301
+ const o = s;
302
+ throw new Error(`Unknown sheet type: ${o}`);
297
303
  }
298
- return e.catch((r)=>{
299
- if (r.code === "400") return c();
300
- throw r;
304
+ return e.catch((o)=>{
305
+ if (o.code === "400") return c();
306
+ throw o;
301
307
  });
302
308
  } else return c();
303
- }, C = (s)=>{
304
- const { isDarkMode: c } = (0, _hooks.useTheme)(), [e, o] = _react.useState(null), t = _react.useRef(null);
309
+ }, M = (r)=>{
310
+ const { isDarkMode: c } = (0, _hooks.useTheme)(), [e, s] = _react.useState(null), t = _react.useRef(null);
305
311
  if (_react.useEffect(()=>{
306
- if (s.nativeImplementation) return l = s.nativeImplementation, ()=>{
312
+ if (r.nativeImplementation) return l = r.nativeImplementation, ()=>{
307
313
  l = null;
308
314
  };
309
315
  }, [
310
- s.nativeImplementation
311
- ]), _react.useEffect(()=>(p = (a)=>{
312
- t.current = null, o(a);
316
+ r.nativeImplementation
317
+ ]), _react.useEffect(()=>(p = (i)=>{
318
+ t.current = null, s(i);
313
319
  }, ()=>{
314
320
  p = null;
315
321
  }), []), !e) return null;
316
- const r = ()=>{
317
- switch(o(null), e.type){
322
+ const o = ()=>{
323
+ switch(s(null), e.type){
318
324
  case "INFO":
319
325
  n == null || n(void 0);
320
326
  break;
@@ -344,38 +350,38 @@ const _ = (s)=>{
344
350
  default:
345
351
  throw new Error(`Unknown sheet type: ${e.type}`);
346
352
  }
347
- }, i = (a)=>{
348
- t.current = a;
353
+ }, a = (i)=>{
354
+ t.current = i;
349
355
  };
350
356
  switch(e.type){
351
357
  case "INFO":
352
358
  return /* @__PURE__ */ (0, _jsxruntime.jsx)(_sheet.InfoSheet, _object_spread_props(_object_spread({}, e.props), {
353
- onClose: r
359
+ onClose: o
354
360
  }));
355
361
  case "ACTIONS_LIST":
356
362
  return /* @__PURE__ */ (0, _jsxruntime.jsx)(_sheet.ActionsListSheet, _object_spread_props(_object_spread({}, e.props), {
357
- onClose: r,
358
- onSelect: i
363
+ onClose: o,
364
+ onSelect: a
359
365
  }));
360
366
  case "RADIO_LIST":
361
367
  return /* @__PURE__ */ (0, _jsxruntime.jsx)(_sheet.RadioListSheet, _object_spread_props(_object_spread({}, e.props), {
362
- items: e.props.items.map((a)=>_object_spread_props(_object_spread({}, a), {
363
- asset: a.icon && /* @__PURE__ */ (0, _jsxruntime.jsx)(_image.default, {
368
+ items: e.props.items.map((i)=>_object_spread_props(_object_spread({}, i), {
369
+ asset: i.icon && /* @__PURE__ */ (0, _jsxruntime.jsx)(_image.default, {
364
370
  circular: !0,
365
- src: c && a.icon.urlDark ? a.icon.urlDark : a.icon.url,
366
- width: a.icon.size === "small" ? 24 : 40
371
+ src: c && i.icon.urlDark ? i.icon.urlDark : i.icon.url,
372
+ width: i.icon.size === "small" ? 24 : 40
367
373
  })
368
374
  })),
369
- onClose: r,
370
- onSelect: i
375
+ onClose: o,
376
+ onSelect: a
371
377
  }));
372
378
  case "ACTIONS":
373
379
  return /* @__PURE__ */ (0, _jsxruntime.jsx)(_sheet.ActionsSheet, _object_spread_props(_object_spread({}, e.props), {
374
380
  buttonLink: e.props.link,
375
- onClose: r,
376
- onPressButton: i
381
+ onClose: o,
382
+ onPressButton: a
377
383
  }));
378
384
  default:
379
385
  throw new Error(`Unknown sheet type: ${e.type}`);
380
386
  }
381
- }, B = C;
387
+ }, F = M;
package/dist/sheet.d.ts CHANGED
@@ -14,7 +14,7 @@ declare const Sheet: React.ForwardRefExoticComponent<SheetProps & React.RefAttri
14
14
  type SheetBodyProps = {
15
15
  title?: string;
16
16
  subtitle?: string;
17
- description?: string;
17
+ description?: string | Array<string>;
18
18
  button?: RendersNullableElement<typeof ButtonPrimary>;
19
19
  secondaryButton?: RendersNullableElement<typeof ButtonSecondary>;
20
20
  link?: RendersNullableElement<typeof ButtonLink>;
@@ -25,7 +25,7 @@ export declare const SheetBody: ({ title, subtitle, description, modalTitleId, b
25
25
  type RadioListSheetProps = {
26
26
  title?: string;
27
27
  subtitle?: string;
28
- description?: string;
28
+ description?: string | Array<string>;
29
29
  items: Array<{
30
30
  id: string;
31
31
  title?: string;
@@ -44,7 +44,7 @@ export declare const RadioListSheet: React.ForwardRefExoticComponent<RadioListSh
44
44
  type ActionsListSheetProps = {
45
45
  title?: string;
46
46
  subtitle?: string;
47
- description?: string;
47
+ description?: string | Array<string>;
48
48
  items: Array<{
49
49
  id: string;
50
50
  title: string;
@@ -64,7 +64,7 @@ export declare const ActionsListSheet: React.ForwardRefExoticComponent<ActionsLi
64
64
  type InfoSheetProps = {
65
65
  title?: string;
66
66
  subtitle?: string;
67
- description?: string;
67
+ description?: string | Array<string>;
68
68
  items: Array<{
69
69
  id?: string;
70
70
  title: string;
@@ -93,7 +93,7 @@ type ButtonProps = {
93
93
  type ActionsSheetProps = {
94
94
  title?: string;
95
95
  subtitle?: string;
96
- description?: string;
96
+ description?: string | Array<string>;
97
97
  button: ButtonProps;
98
98
  secondaryButton?: ButtonProps;
99
99
  buttonLink?: ButtonProps & {