@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.
- package/css/mistica.css +1 -1
- package/css/reset.css +4 -0
- package/dist/package-version.js +1 -1
- package/dist/sheet-root.d.ts +1 -1
- package/dist/sheet-root.js +84 -78
- package/dist/sheet.d.ts +5 -5
- package/dist/sheet.js +101 -90
- package/dist-es/package-version.js +1 -1
- package/dist-es/sheet-root.js +87 -81
- package/dist-es/sheet.js +136 -125
- package/dist-es/style.css +1 -1
- package/package.json +1 -1
package/dist-es/sheet-root.js
CHANGED
|
@@ -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
|
|
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
|
|
86
|
+
import { useTheme as m } from "./hooks.js";
|
|
87
87
|
let p = null, n = null, l = null;
|
|
88
|
-
const
|
|
89
|
-
|
|
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:
|
|
93
|
+
title: r,
|
|
92
94
|
subtitle: c,
|
|
93
|
-
|
|
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
|
|
101
|
-
|
|
103
|
+
selectedIds: typeof s == "string" ? [
|
|
104
|
+
s
|
|
102
105
|
] : [],
|
|
103
106
|
items: t
|
|
104
107
|
}
|
|
105
108
|
]
|
|
106
109
|
}).then((param)=>{
|
|
107
|
-
let { action:
|
|
108
|
-
return
|
|
109
|
-
action:
|
|
110
|
-
selectedId:
|
|
110
|
+
let { action: o , result: a } = param;
|
|
111
|
+
return o === "SUBMIT" ? {
|
|
112
|
+
action: o,
|
|
113
|
+
selectedId: a[0].selectedIds[0]
|
|
111
114
|
} : {
|
|
112
|
-
action:
|
|
115
|
+
action: o,
|
|
113
116
|
selectedId: null
|
|
114
117
|
};
|
|
115
118
|
});
|
|
116
|
-
},
|
|
117
|
-
let { title:
|
|
119
|
+
}, k = (param)=>{
|
|
120
|
+
let { title: r , subtitle: c , description: e , items: s } = param;
|
|
118
121
|
return l({
|
|
119
|
-
title:
|
|
122
|
+
title: r,
|
|
120
123
|
subtitle: c,
|
|
121
|
-
|
|
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:
|
|
133
|
+
items: s
|
|
130
134
|
}
|
|
131
135
|
]
|
|
132
136
|
}).then((param)=>{
|
|
133
|
-
let { action: t , result:
|
|
137
|
+
let { action: t , result: o } = param;
|
|
134
138
|
return t === "SUBMIT" ? {
|
|
135
139
|
action: t,
|
|
136
|
-
selectedId:
|
|
140
|
+
selectedId: o[0].selectedIds[0]
|
|
137
141
|
} : {
|
|
138
142
|
action: t,
|
|
139
143
|
selectedId: null
|
|
140
144
|
};
|
|
141
145
|
});
|
|
142
|
-
},
|
|
146
|
+
}, b = function() {
|
|
143
147
|
var _ref = _async_to_generator(function*(param) {
|
|
144
|
-
let { title:
|
|
148
|
+
let { title: r , subtitle: c , description: e , items: s } = param;
|
|
145
149
|
yield l({
|
|
146
|
-
title:
|
|
150
|
+
title: r,
|
|
147
151
|
subtitle: c,
|
|
148
|
-
|
|
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:
|
|
161
|
+
items: s
|
|
157
162
|
}
|
|
158
163
|
]
|
|
159
164
|
});
|
|
160
165
|
});
|
|
161
|
-
return function
|
|
166
|
+
return function b(_) {
|
|
162
167
|
return _ref.apply(this, arguments);
|
|
163
168
|
};
|
|
164
|
-
}(),
|
|
169
|
+
}(), C = function() {
|
|
165
170
|
var _ref = _async_to_generator(function*(param) {
|
|
166
|
-
let { title:
|
|
171
|
+
let { title: r , subtitle: c , description: e , button: s , secondaryButton: t , link: o } = param;
|
|
167
172
|
return l({
|
|
168
|
-
title:
|
|
173
|
+
title: r,
|
|
169
174
|
subtitle: c,
|
|
170
|
-
|
|
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:
|
|
181
|
+
button: s,
|
|
176
182
|
secondaryButton: t,
|
|
177
|
-
link:
|
|
183
|
+
link: o
|
|
178
184
|
}
|
|
179
185
|
]
|
|
180
186
|
}).then((param)=>{
|
|
181
|
-
let { action:
|
|
182
|
-
if (
|
|
183
|
-
const
|
|
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 =
|
|
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
|
|
202
|
+
return function C(_) {
|
|
197
203
|
return _ref.apply(this, arguments);
|
|
198
204
|
};
|
|
199
205
|
}();
|
|
200
|
-
let
|
|
201
|
-
const
|
|
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 (
|
|
205
|
-
|
|
206
|
-
const e = new Promise((
|
|
207
|
-
n =
|
|
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
|
-
|
|
216
|
+
h = !1;
|
|
211
217
|
}), e;
|
|
212
218
|
};
|
|
213
219
|
if (l) {
|
|
214
220
|
let e;
|
|
215
|
-
const { type:
|
|
216
|
-
switch(
|
|
221
|
+
const { type: s , props: t } = r;
|
|
222
|
+
switch(s){
|
|
217
223
|
case "INFO":
|
|
218
|
-
e =
|
|
224
|
+
e = b(t);
|
|
219
225
|
break;
|
|
220
226
|
case "ACTIONS_LIST":
|
|
221
|
-
e =
|
|
227
|
+
e = k(t);
|
|
222
228
|
break;
|
|
223
229
|
case "RADIO_LIST":
|
|
224
|
-
e =
|
|
230
|
+
e = L(t);
|
|
225
231
|
break;
|
|
226
232
|
case "ACTIONS":
|
|
227
|
-
e =
|
|
233
|
+
e = C(t);
|
|
228
234
|
break;
|
|
229
235
|
default:
|
|
230
|
-
const
|
|
231
|
-
throw new Error(`Unknown sheet type: ${
|
|
236
|
+
const o = s;
|
|
237
|
+
throw new Error(`Unknown sheet type: ${o}`);
|
|
232
238
|
}
|
|
233
|
-
return e.catch((
|
|
234
|
-
if (
|
|
235
|
-
throw
|
|
239
|
+
return e.catch((o)=>{
|
|
240
|
+
if (o.code === "400") return c();
|
|
241
|
+
throw o;
|
|
236
242
|
});
|
|
237
243
|
} else return c();
|
|
238
|
-
},
|
|
239
|
-
const { isDarkMode: c } =
|
|
244
|
+
}, M = (r)=>{
|
|
245
|
+
const { isDarkMode: c } = m(), [e, s] = S.useState(null), t = S.useRef(null);
|
|
240
246
|
if (S.useEffect(()=>{
|
|
241
|
-
if (
|
|
247
|
+
if (r.nativeImplementation) return l = r.nativeImplementation, ()=>{
|
|
242
248
|
l = null;
|
|
243
249
|
};
|
|
244
250
|
}, [
|
|
245
|
-
|
|
246
|
-
]), S.useEffect(()=>(p = (
|
|
247
|
-
t.current = null,
|
|
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
|
|
252
|
-
switch(
|
|
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
|
-
},
|
|
283
|
-
t.current =
|
|
288
|
+
}, a = (i)=>{
|
|
289
|
+
t.current = i;
|
|
284
290
|
};
|
|
285
291
|
switch(e.type){
|
|
286
292
|
case "INFO":
|
|
287
|
-
return /* @__PURE__ */ u(
|
|
288
|
-
onClose:
|
|
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:
|
|
293
|
-
onSelect:
|
|
298
|
+
onClose: o,
|
|
299
|
+
onSelect: a
|
|
294
300
|
}));
|
|
295
301
|
case "RADIO_LIST":
|
|
296
|
-
return /* @__PURE__ */ u(
|
|
297
|
-
items: e.props.items.map((
|
|
298
|
-
asset:
|
|
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 &&
|
|
301
|
-
width:
|
|
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:
|
|
305
|
-
onSelect:
|
|
310
|
+
onClose: o,
|
|
311
|
+
onSelect: a
|
|
306
312
|
}));
|
|
307
313
|
case "ACTIONS":
|
|
308
|
-
return /* @__PURE__ */ u(
|
|
314
|
+
return /* @__PURE__ */ u(w, _object_spread_props(_object_spread({}, e.props), {
|
|
309
315
|
buttonLink: e.props.link,
|
|
310
|
-
onClose:
|
|
311
|
-
onPressButton:
|
|
316
|
+
onClose: o,
|
|
317
|
+
onPressButton: a
|
|
312
318
|
}));
|
|
313
319
|
default:
|
|
314
320
|
throw new Error(`Unknown sheet type: ${e.type}`);
|
|
315
321
|
}
|
|
316
|
-
},
|
|
317
|
-
export {
|
|
322
|
+
}, F = M;
|
|
323
|
+
export { M as SheetRoot, F as default, B as showSheet };
|