@telefonica/mistica 14.23.1 → 14.24.1

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.
@@ -81,44 +81,48 @@ function _object_spread_props(target, source) {
81
81
  }
82
82
  import { jsx as u } from "react/jsx-runtime";
83
83
  import * as S from "react";
84
- import { ActionsSheet as h, RadioListSheet as w, ActionsListSheet as N, InfoSheet as y } from "./sheet.js";
84
+ import { ActionsSheet as w, RadioListSheet as y, ActionsListSheet as N, InfoSheet as A } from "./sheet.js";
85
85
  import O from "./image.js";
86
- import { useTheme as A } from "./hooks.js";
86
+ import { useTheme as m } from "./hooks.js";
87
87
  let p = null, n = null, l = null;
88
- const m = (param)=>{
89
- let { title: s , subtitle: c , description: e , selectedId: o , items: t } = param;
88
+ const d = (r)=>Array.isArray(r) ? r.length ? r.join(`
89
+
90
+ `) : void 0 : r, L = (param)=>{
91
+ let { title: r , subtitle: c , description: e , selectedId: s , items: t } = param;
90
92
  return l({
91
- title: s,
93
+ title: r,
92
94
  subtitle: c,
93
- description: e,
95
+ // TODO: add multiline support to native sheet
96
+ description: d(e),
94
97
  content: [
95
98
  {
96
99
  type: "LIST",
97
100
  id: "list-0",
98
101
  listType: "SINGLE_SELECTION",
99
102
  autoSubmit: !0,
100
- selectedIds: typeof o == "string" ? [
101
- o
103
+ selectedIds: typeof s == "string" ? [
104
+ s
102
105
  ] : [],
103
106
  items: t
104
107
  }
105
108
  ]
106
109
  }).then((param)=>{
107
- let { action: r , result: i } = param;
108
- return r === "SUBMIT" ? {
109
- action: r,
110
- selectedId: i[0].selectedIds[0]
110
+ let { action: o , result: a } = param;
111
+ return o === "SUBMIT" ? {
112
+ action: o,
113
+ selectedId: a[0].selectedIds[0]
111
114
  } : {
112
- action: r,
115
+ action: o,
113
116
  selectedId: null
114
117
  };
115
118
  });
116
- }, L = (param)=>{
117
- let { title: s , subtitle: c , description: e , items: o } = param;
119
+ }, k = (param)=>{
120
+ let { title: r , subtitle: c , description: e , items: s } = param;
118
121
  return l({
119
- title: s,
122
+ title: r,
120
123
  subtitle: c,
121
- description: e,
124
+ // TODO: add multiline support to native sheet
125
+ description: d(e),
122
126
  content: [
123
127
  {
124
128
  type: "LIST",
@@ -126,26 +130,27 @@ const m = (param)=>{
126
130
  listType: "ACTIONS",
127
131
  autoSubmit: !0,
128
132
  selectedIds: [],
129
- items: o
133
+ items: s
130
134
  }
131
135
  ]
132
136
  }).then((param)=>{
133
- let { action: t , result: r } = param;
137
+ let { action: t , result: o } = param;
134
138
  return t === "SUBMIT" ? {
135
139
  action: t,
136
- selectedId: r[0].selectedIds[0]
140
+ selectedId: o[0].selectedIds[0]
137
141
  } : {
138
142
  action: t,
139
143
  selectedId: null
140
144
  };
141
145
  });
142
- }, k = function() {
146
+ }, b = function() {
143
147
  var _ref = _async_to_generator(function*(param) {
144
- let { title: s , subtitle: c , description: e , items: o } = param;
148
+ let { title: r , subtitle: c , description: e , items: s } = param;
145
149
  yield l({
146
- title: s,
150
+ title: r,
147
151
  subtitle: c,
148
- description: e,
152
+ // TODO: add multiline support to native sheet
153
+ description: d(e),
149
154
  content: [
150
155
  {
151
156
  type: "LIST",
@@ -153,37 +158,38 @@ const m = (param)=>{
153
158
  listType: "INFORMATIVE",
154
159
  autoSubmit: !1,
155
160
  selectedIds: [],
156
- items: o
161
+ items: s
157
162
  }
158
163
  ]
159
164
  });
160
165
  });
161
- return function k(_) {
166
+ return function b(_) {
162
167
  return _ref.apply(this, arguments);
163
168
  };
164
- }(), b = function() {
169
+ }(), C = function() {
165
170
  var _ref = _async_to_generator(function*(param) {
166
- let { title: s , subtitle: c , description: e , button: o , secondaryButton: t , link: r } = param;
171
+ let { title: r , subtitle: c , description: e , button: s , secondaryButton: t , link: o } = param;
167
172
  return l({
168
- title: s,
173
+ title: r,
169
174
  subtitle: c,
170
- description: e,
175
+ // TODO: add multiline support to native sheet
176
+ description: d(e),
171
177
  content: [
172
178
  {
173
179
  type: "BOTTOM_ACTIONS",
174
180
  id: "bottom-actions-0",
175
- button: o,
181
+ button: s,
176
182
  secondaryButton: t,
177
- link: r
183
+ link: o
178
184
  }
179
185
  ]
180
186
  }).then((param)=>{
181
- let { action: i , result: a } = param;
182
- if (i === "SUBMIT") {
183
- const d = a.find((param)=>{
187
+ let { action: a , result: i } = param;
188
+ if (a === "SUBMIT") {
189
+ const f = i.find((param)=>{
184
190
  let { id: T } = param;
185
191
  return T === "bottom-actions-0";
186
- }), I = d == null ? void 0 : d.selectedIds[0];
192
+ }), I = f == null ? void 0 : f.selectedIds[0];
187
193
  if (I === "PRIMARY" || I === "SECONDARY" || I === "LINK") return {
188
194
  action: I
189
195
  };
@@ -193,63 +199,63 @@ const m = (param)=>{
193
199
  };
194
200
  });
195
201
  });
196
- return function b(_) {
202
+ return function C(_) {
197
203
  return _ref.apply(this, arguments);
198
204
  };
199
205
  }();
200
- let f = !1;
201
- const _ = (s)=>{
206
+ let h = !1;
207
+ const B = (r)=>{
202
208
  const c = ()=>{
203
209
  if (!p) return Promise.reject(new Error("Tried to show a Sheet but the SheetRoot component was not mounted"));
204
- if (f) return Promise.reject(new Error("Tried to show a Sheet but there is already one open"));
205
- f = !0, p(s);
206
- const e = new Promise((o)=>{
207
- n = o;
210
+ if (h) return Promise.reject(new Error("Tried to show a Sheet but there is already one open"));
211
+ h = !0, p(r);
212
+ const e = new Promise((s)=>{
213
+ n = s;
208
214
  });
209
215
  return e.finally(()=>{
210
- f = !1;
216
+ h = !1;
211
217
  }), e;
212
218
  };
213
219
  if (l) {
214
220
  let e;
215
- const { type: o , props: t } = s;
216
- switch(o){
221
+ const { type: s , props: t } = r;
222
+ switch(s){
217
223
  case "INFO":
218
- e = k(t);
224
+ e = b(t);
219
225
  break;
220
226
  case "ACTIONS_LIST":
221
- e = L(t);
227
+ e = k(t);
222
228
  break;
223
229
  case "RADIO_LIST":
224
- e = m(t);
230
+ e = L(t);
225
231
  break;
226
232
  case "ACTIONS":
227
- e = b(t);
233
+ e = C(t);
228
234
  break;
229
235
  default:
230
- const r = o;
231
- throw new Error(`Unknown sheet type: ${r}`);
236
+ const o = s;
237
+ throw new Error(`Unknown sheet type: ${o}`);
232
238
  }
233
- return e.catch((r)=>{
234
- if (r.code === "400") return c();
235
- throw r;
239
+ return e.catch((o)=>{
240
+ if (o.code === "400") return c();
241
+ throw o;
236
242
  });
237
243
  } else return c();
238
- }, C = (s)=>{
239
- const { isDarkMode: c } = A(), [e, o] = S.useState(null), t = S.useRef(null);
244
+ }, M = (r)=>{
245
+ const { isDarkMode: c } = m(), [e, s] = S.useState(null), t = S.useRef(null);
240
246
  if (S.useEffect(()=>{
241
- if (s.nativeImplementation) return l = s.nativeImplementation, ()=>{
247
+ if (r.nativeImplementation) return l = r.nativeImplementation, ()=>{
242
248
  l = null;
243
249
  };
244
250
  }, [
245
- s.nativeImplementation
246
- ]), S.useEffect(()=>(p = (a)=>{
247
- t.current = null, o(a);
251
+ r.nativeImplementation
252
+ ]), S.useEffect(()=>(p = (i)=>{
253
+ t.current = null, s(i);
248
254
  }, ()=>{
249
255
  p = null;
250
256
  }), []), !e) return null;
251
- const r = ()=>{
252
- switch(o(null), e.type){
257
+ const o = ()=>{
258
+ switch(s(null), e.type){
253
259
  case "INFO":
254
260
  n == null || n(void 0);
255
261
  break;
@@ -279,39 +285,39 @@ const _ = (s)=>{
279
285
  default:
280
286
  throw new Error(`Unknown sheet type: ${e.type}`);
281
287
  }
282
- }, i = (a)=>{
283
- t.current = a;
288
+ }, a = (i)=>{
289
+ t.current = i;
284
290
  };
285
291
  switch(e.type){
286
292
  case "INFO":
287
- return /* @__PURE__ */ u(y, _object_spread_props(_object_spread({}, e.props), {
288
- onClose: r
293
+ return /* @__PURE__ */ u(A, _object_spread_props(_object_spread({}, e.props), {
294
+ onClose: o
289
295
  }));
290
296
  case "ACTIONS_LIST":
291
297
  return /* @__PURE__ */ u(N, _object_spread_props(_object_spread({}, e.props), {
292
- onClose: r,
293
- onSelect: i
298
+ onClose: o,
299
+ onSelect: a
294
300
  }));
295
301
  case "RADIO_LIST":
296
- return /* @__PURE__ */ u(w, _object_spread_props(_object_spread({}, e.props), {
297
- items: e.props.items.map((a)=>_object_spread_props(_object_spread({}, a), {
298
- asset: a.icon && /* @__PURE__ */ u(O, {
302
+ return /* @__PURE__ */ u(y, _object_spread_props(_object_spread({}, e.props), {
303
+ items: e.props.items.map((i)=>_object_spread_props(_object_spread({}, i), {
304
+ asset: i.icon && /* @__PURE__ */ u(O, {
299
305
  circular: !0,
300
- src: c && a.icon.urlDark ? a.icon.urlDark : a.icon.url,
301
- width: a.icon.size === "small" ? 24 : 40
306
+ src: c && i.icon.urlDark ? i.icon.urlDark : i.icon.url,
307
+ width: i.icon.size === "small" ? 24 : 40
302
308
  })
303
309
  })),
304
- onClose: r,
305
- onSelect: i
310
+ onClose: o,
311
+ onSelect: a
306
312
  }));
307
313
  case "ACTIONS":
308
- return /* @__PURE__ */ u(h, _object_spread_props(_object_spread({}, e.props), {
314
+ return /* @__PURE__ */ u(w, _object_spread_props(_object_spread({}, e.props), {
309
315
  buttonLink: e.props.link,
310
- onClose: r,
311
- onPressButton: i
316
+ onClose: o,
317
+ onPressButton: a
312
318
  }));
313
319
  default:
314
320
  throw new Error(`Unknown sheet type: ${e.type}`);
315
321
  }
316
- }, B = C;
317
- export { C as SheetRoot, B as default, _ as showSheet };
322
+ }, F = M;
323
+ export { M as SheetRoot, F as default, B as showSheet };