@telefonica/mistica 14.26.1 → 14.27.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.
- package/css/mistica.css +1 -1
- package/dist/button.d.ts +7 -1
- package/dist/button.js +78 -72
- package/dist/menu.js +41 -41
- package/dist/package-version.js +1 -1
- package/dist/touchable.d.ts +1 -0
- package/dist/touchable.js +8 -7
- package/dist-es/button.js +103 -97
- package/dist-es/menu.js +64 -64
- package/dist-es/package-version.js +1 -1
- package/dist-es/style.css +1 -1
- package/dist-es/touchable.js +19 -18
- package/package.json +1 -1
package/dist-es/button.js
CHANGED
|
@@ -78,10 +78,10 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
78
78
|
return target;
|
|
79
79
|
}
|
|
80
80
|
import { jsx as t, jsxs as C, Fragment as G } from "react/jsx-runtime";
|
|
81
|
-
import * as
|
|
81
|
+
import * as a from "react";
|
|
82
82
|
import k from "classnames";
|
|
83
83
|
import M from "./spinner.js";
|
|
84
|
-
import { BaseTouchable as
|
|
84
|
+
import { BaseTouchable as b } from "./touchable.js";
|
|
85
85
|
import { useIsInverseVariant as A } from "./theme-variant-context.js";
|
|
86
86
|
import { useForm as T } from "./form-context.js";
|
|
87
87
|
import { pxToRem as B } from "./utils/css.js";
|
|
@@ -91,34 +91,34 @@ import { getTextFromChildren as P } from "./utils/common.js";
|
|
|
91
91
|
import { useTrackingConfig as j, eventNames as O, eventCategories as D, eventActions as H } from "./utils/analytics.js";
|
|
92
92
|
import { useTheme as V } from "./hooks.js";
|
|
93
93
|
import { flattenChildren as Y } from "./skins/utils.js";
|
|
94
|
-
import { inverseVariants as $, variants as q, small as J, isLoading as F, textContent as Q, link as U, inverseLink as p, PADDING_X_LINK as
|
|
94
|
+
import { inverseVariants as $, variants as q, small as J, isLoading as F, textContent as Q, link as U, inverseLink as p, PADDING_X_LINK as x, PADDING_Y_LINK as R, textContentLink as ee, SMALL_SPINNER_SIZE as te, SPINNER_SIZE as ne, ICON_MARGIN_PX as E, CHEVRON_MARGIN_LEFT_LINK as ie, loadingFiller as re, X_SMALL_PADDING_PX as ae, X_PADDING_PX as oe, loadingContent as se, SMALL_ICON_SIZE as le, ICON_SIZE as ce } from "./button.css-mistica.js";
|
|
95
95
|
const N = (param)=>{
|
|
96
|
-
let { content: e , defaultIconSize:
|
|
97
|
-
const
|
|
98
|
-
let
|
|
96
|
+
let { content: e , defaultIconSize: r , renderText: n } = param;
|
|
97
|
+
const l = Y(e), f = l.length, d = [];
|
|
98
|
+
let c = [];
|
|
99
99
|
const g = ()=>{
|
|
100
|
-
d.push(/* @__PURE__ */ t(
|
|
101
|
-
children: n(
|
|
102
|
-
}, d.length)),
|
|
100
|
+
d.push(/* @__PURE__ */ t(a.Fragment, {
|
|
101
|
+
children: n(c)
|
|
102
|
+
}, d.length)), c = [];
|
|
103
103
|
};
|
|
104
|
-
return
|
|
105
|
-
const
|
|
106
|
-
if (/*#__PURE__*/
|
|
107
|
-
|
|
104
|
+
return l.forEach((u, m)=>{
|
|
105
|
+
const o = m === 0, s = m === f - 1;
|
|
106
|
+
if (/*#__PURE__*/ a.isValidElement(u)) {
|
|
107
|
+
c.length && g();
|
|
108
108
|
var _u_props_size;
|
|
109
|
-
const v = (_u_props_size = u.props.size) !== null && _u_props_size !== void 0 ? _u_props_size :
|
|
109
|
+
const v = (_u_props_size = u.props.size) !== null && _u_props_size !== void 0 ? _u_props_size : r;
|
|
110
110
|
d.push(/* @__PURE__ */ t("div", {
|
|
111
111
|
style: {
|
|
112
112
|
display: "flex",
|
|
113
113
|
alignItems: "center",
|
|
114
|
-
marginLeft:
|
|
114
|
+
marginLeft: o ? 0 : E,
|
|
115
115
|
marginRight: s ? 0 : E
|
|
116
116
|
},
|
|
117
|
-
children: /*#__PURE__*/
|
|
117
|
+
children: /*#__PURE__*/ a.cloneElement(u, {
|
|
118
118
|
size: B(v)
|
|
119
119
|
})
|
|
120
120
|
}, d.length));
|
|
121
|
-
} else
|
|
121
|
+
} else c.push(u), s && g();
|
|
122
122
|
}), d;
|
|
123
123
|
}, de = ()=>/* @__PURE__ */ t("svg", {
|
|
124
124
|
width: "0.5em",
|
|
@@ -129,8 +129,8 @@ const N = (param)=>{
|
|
|
129
129
|
fill: "currentColor"
|
|
130
130
|
})
|
|
131
131
|
}), z = (param)=>{
|
|
132
|
-
let { showSpinner: e , children:
|
|
133
|
-
const s = n ?
|
|
132
|
+
let { showSpinner: e , children: r , small: n , loadingText: l , shouldRenderSpinner: f , setShouldRenderSpinner: d , renderText: c , textContentStyle: g , StartIcon: u , EndIcon: m , withChevron: o } = param;
|
|
133
|
+
const s = n ? le : ce, i = B(n ? te : ne);
|
|
134
134
|
return /* @__PURE__ */ C(G, {
|
|
135
135
|
children: [
|
|
136
136
|
/* @__PURE__ */ C("div", {
|
|
@@ -149,11 +149,11 @@ const N = (param)=>{
|
|
|
149
149
|
})
|
|
150
150
|
}),
|
|
151
151
|
N({
|
|
152
|
-
content:
|
|
152
|
+
content: r,
|
|
153
153
|
defaultIconSize: s,
|
|
154
|
-
renderText:
|
|
154
|
+
renderText: c
|
|
155
155
|
}),
|
|
156
|
-
m && !
|
|
156
|
+
m && !o && /* @__PURE__ */ t("div", {
|
|
157
157
|
style: {
|
|
158
158
|
display: "flex",
|
|
159
159
|
alignItems: "center",
|
|
@@ -164,27 +164,27 @@ const N = (param)=>{
|
|
|
164
164
|
color: "currentColor"
|
|
165
165
|
})
|
|
166
166
|
}),
|
|
167
|
-
|
|
167
|
+
o && /* @__PURE__ */ t("div", {
|
|
168
168
|
style: {
|
|
169
169
|
display: "flex",
|
|
170
170
|
alignItems: "center",
|
|
171
|
-
marginLeft:
|
|
171
|
+
marginLeft: ie
|
|
172
172
|
},
|
|
173
173
|
children: /* @__PURE__ */ t(de, {})
|
|
174
174
|
})
|
|
175
175
|
]
|
|
176
176
|
}),
|
|
177
177
|
/* @__PURE__ */ t("div", {
|
|
178
|
-
className:
|
|
178
|
+
className: re,
|
|
179
179
|
"aria-hidden": !0,
|
|
180
|
-
style:
|
|
181
|
-
paddingLeft:
|
|
182
|
-
paddingRight: E + 2 * (n ?
|
|
180
|
+
style: l ? {
|
|
181
|
+
paddingLeft: i,
|
|
182
|
+
paddingRight: E + 2 * (n ? ae : oe)
|
|
183
183
|
} : void 0,
|
|
184
184
|
children: N({
|
|
185
|
-
content:
|
|
185
|
+
content: l,
|
|
186
186
|
defaultIconSize: s,
|
|
187
|
-
renderText:
|
|
187
|
+
renderText: c
|
|
188
188
|
})
|
|
189
189
|
}),
|
|
190
190
|
/* @__PURE__ */ C("div", {
|
|
@@ -195,40 +195,40 @@ const N = (param)=>{
|
|
|
195
195
|
},
|
|
196
196
|
children: [
|
|
197
197
|
f ? /* @__PURE__ */ t(M, {
|
|
198
|
-
rolePresentation: !!
|
|
198
|
+
rolePresentation: !!l,
|
|
199
199
|
color: "currentcolor",
|
|
200
200
|
delay: "0s",
|
|
201
|
-
size:
|
|
201
|
+
size: i
|
|
202
202
|
}) : /* @__PURE__ */ t("div", {
|
|
203
203
|
style: {
|
|
204
204
|
display: "inline-block",
|
|
205
|
-
width:
|
|
206
|
-
height:
|
|
205
|
+
width: i,
|
|
206
|
+
height: i
|
|
207
207
|
}
|
|
208
208
|
}),
|
|
209
|
-
|
|
209
|
+
l ? /* @__PURE__ */ t(K, {
|
|
210
210
|
paddingLeft: 8,
|
|
211
211
|
children: N({
|
|
212
|
-
content:
|
|
212
|
+
content: l,
|
|
213
213
|
defaultIconSize: s,
|
|
214
|
-
renderText:
|
|
214
|
+
renderText: c
|
|
215
215
|
})
|
|
216
216
|
}) : null
|
|
217
217
|
]
|
|
218
218
|
})
|
|
219
219
|
]
|
|
220
220
|
});
|
|
221
|
-
}, _ = /*#__PURE__*/
|
|
222
|
-
const { textPresets: n } = V(), { eventFormat:
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
}, _ = /*#__PURE__*/ a.forwardRef((e, r)=>{
|
|
222
|
+
const { textPresets: n } = V(), { eventFormat: l } = j(), { formStatus: f , formId: d } = T(), c = A(), { loadingText: g } = e, u = !!e.submit, m = f === "sending", [o, s] = a.useState(!1), i = e.showSpinner || m && u || o, [v, L] = a.useState(!!i);
|
|
223
|
+
a.useEffect(()=>{
|
|
224
|
+
i && !v && L(!0);
|
|
225
225
|
}, [
|
|
226
|
-
|
|
226
|
+
i,
|
|
227
227
|
v,
|
|
228
228
|
f
|
|
229
229
|
]);
|
|
230
230
|
var _e_trackingEvent;
|
|
231
|
-
const S = ()=>
|
|
231
|
+
const S = ()=>l === "google-analytics-4" ? {
|
|
232
232
|
name: O.userInteraction,
|
|
233
233
|
component_type: `${e.type}_button`,
|
|
234
234
|
component_copy: P(e.children)
|
|
@@ -236,86 +236,88 @@ const N = (param)=>{
|
|
|
236
236
|
category: D.userInteraction,
|
|
237
237
|
action: `${e.type}_button_tapped`,
|
|
238
238
|
label: P(e.children)
|
|
239
|
-
},
|
|
239
|
+
}, I = (y)=>e.small ? /* @__PURE__ */ t(X, {
|
|
240
240
|
size: 14,
|
|
241
241
|
lineHeight: 20,
|
|
242
242
|
weight: n.button.weight,
|
|
243
243
|
truncate: 1,
|
|
244
244
|
color: "inherit",
|
|
245
245
|
as: "div",
|
|
246
|
-
children:
|
|
246
|
+
children: y
|
|
247
247
|
}) : /* @__PURE__ */ t(Z, {
|
|
248
248
|
weight: n.button.weight,
|
|
249
249
|
truncate: 1,
|
|
250
250
|
color: "inherit",
|
|
251
251
|
as: "div",
|
|
252
|
-
children:
|
|
252
|
+
children: y
|
|
253
253
|
}), h = {
|
|
254
|
-
ref:
|
|
255
|
-
className: k(
|
|
254
|
+
ref: r,
|
|
255
|
+
className: k(c ? $[e.type] : q[e.type], e.className, {
|
|
256
256
|
[J]: e.small,
|
|
257
|
-
[F]:
|
|
257
|
+
[F]: i
|
|
258
258
|
}),
|
|
259
259
|
style: _object_spread({
|
|
260
260
|
cursor: e.fake ? "pointer" : void 0
|
|
261
261
|
}, e.style),
|
|
262
262
|
trackingEvent: (_e_trackingEvent = e.trackingEvent) !== null && _e_trackingEvent !== void 0 ? _e_trackingEvent : e.trackEvent ? S() : void 0,
|
|
263
263
|
dataAttributes: e.dataAttributes,
|
|
264
|
+
"aria-label": e["aria-label"],
|
|
264
265
|
"aria-controls": e["aria-controls"],
|
|
265
266
|
"aria-expanded": e["aria-expanded"],
|
|
267
|
+
"aria-haspopup": e["aria-haspopup"],
|
|
266
268
|
tabIndex: e.tabIndex,
|
|
267
269
|
children: z({
|
|
268
|
-
showSpinner:
|
|
270
|
+
showSpinner: i,
|
|
269
271
|
shouldRenderSpinner: v,
|
|
270
272
|
setShouldRenderSpinner: L,
|
|
271
273
|
children: e.children,
|
|
272
274
|
loadingText: g,
|
|
273
275
|
small: e.small,
|
|
274
|
-
renderText:
|
|
276
|
+
renderText: I,
|
|
275
277
|
textContentStyle: Q,
|
|
276
278
|
StartIcon: e.StartIcon,
|
|
277
279
|
EndIcon: e.EndIcon
|
|
278
280
|
}),
|
|
279
|
-
disabled: e.disabled ||
|
|
281
|
+
disabled: e.disabled || i || m,
|
|
280
282
|
role: "button"
|
|
281
283
|
};
|
|
282
284
|
if (process.env.NODE_ENV !== "production" && (e.to === "" || e.href === "")) throw Error("to or href props are empty strings");
|
|
283
|
-
if (e.fake) return /* @__PURE__ */ t(
|
|
285
|
+
if (e.fake) return /* @__PURE__ */ t(b, _object_spread_props(_object_spread({
|
|
284
286
|
maybe: !0
|
|
285
287
|
}, h), {
|
|
286
288
|
role: "presentation",
|
|
287
289
|
"aria-hidden": "true"
|
|
288
290
|
}));
|
|
289
|
-
if (e.submit) return /* @__PURE__ */ t(
|
|
291
|
+
if (e.submit) return /* @__PURE__ */ t(b, _object_spread({
|
|
290
292
|
type: "submit",
|
|
291
293
|
formId: d,
|
|
292
294
|
onPress: ()=>{}
|
|
293
295
|
}, h));
|
|
294
|
-
if (e.onPress) return /* @__PURE__ */ t(
|
|
295
|
-
onPress: (
|
|
296
|
-
const w = e.onPress(
|
|
296
|
+
if (e.onPress) return /* @__PURE__ */ t(b, _object_spread_props(_object_spread({}, h), {
|
|
297
|
+
onPress: (y)=>{
|
|
298
|
+
const w = e.onPress(y);
|
|
297
299
|
w && (s(!0), w.finally(()=>s(!1)));
|
|
298
300
|
}
|
|
299
301
|
}));
|
|
300
|
-
if (e.to || e.to === "") return /* @__PURE__ */ t(
|
|
302
|
+
if (e.to || e.to === "") return /* @__PURE__ */ t(b, _object_spread_props(_object_spread({}, h), {
|
|
301
303
|
to: e.to,
|
|
302
304
|
fullPageOnWebView: e.fullPageOnWebView
|
|
303
305
|
}));
|
|
304
|
-
if (e.href || e.href === "") return /* @__PURE__ */ t(
|
|
306
|
+
if (e.href || e.href === "") return /* @__PURE__ */ t(b, _object_spread_props(_object_spread({}, h), {
|
|
305
307
|
href: e.href,
|
|
306
308
|
newTab: e.newTab,
|
|
307
309
|
loadOnTop: e.loadOnTop
|
|
308
310
|
}));
|
|
309
311
|
if (process.env.NODE_ENV !== "production") throw Error("Bad button props");
|
|
310
312
|
return null;
|
|
311
|
-
}), Ne = /*#__PURE__*/
|
|
313
|
+
}), Ne = /*#__PURE__*/ a.forwardRef((e, r)=>{
|
|
312
314
|
var _e_withChevron;
|
|
313
|
-
const { formStatus: n } = T(),
|
|
314
|
-
|
|
315
|
-
|
|
315
|
+
const { formStatus: n } = T(), l = A(), { analytics: f , textPresets: d } = V(), { loadingText: c } = e, g = n === "sending", [u, m] = a.useState(!1), o = e.showSpinner || u, s = (_e_withChevron = e.withChevron) !== null && _e_withChevron !== void 0 ? _e_withChevron : !!e.href || !!e.to, [i, v] = a.useState(!!o);
|
|
316
|
+
a.useEffect(()=>{
|
|
317
|
+
o && !i && v(!0);
|
|
316
318
|
}, [
|
|
317
|
-
|
|
318
|
-
|
|
319
|
+
o,
|
|
320
|
+
i,
|
|
319
321
|
n
|
|
320
322
|
]);
|
|
321
323
|
var _e_trackingEvent;
|
|
@@ -332,32 +334,36 @@ const N = (param)=>{
|
|
|
332
334
|
truncate: 1,
|
|
333
335
|
color: "inherit",
|
|
334
336
|
children: h
|
|
335
|
-
}),
|
|
337
|
+
}), I = {
|
|
336
338
|
className: k(U, {
|
|
337
|
-
[p]:
|
|
338
|
-
[F]:
|
|
339
|
+
[p]: l,
|
|
340
|
+
[F]: o
|
|
339
341
|
}),
|
|
340
342
|
/**
|
|
341
343
|
* Setting bleed classes with style to override the margin:0 set by the Touchable component.
|
|
342
344
|
* If we set it using className, it may not work depending on the order in which the styles are applied.
|
|
343
345
|
*/ style: _object_spread({}, e.bleedLeft || e.aligned ? {
|
|
344
|
-
marginLeft: -
|
|
346
|
+
marginLeft: -x
|
|
345
347
|
} : void 0, e.bleedRight ? {
|
|
346
|
-
marginRight: -
|
|
348
|
+
marginRight: -x
|
|
347
349
|
} : void 0, e.bleedY ? {
|
|
348
|
-
marginTop: -
|
|
349
|
-
marginBottom: -
|
|
350
|
+
marginTop: -R,
|
|
351
|
+
marginBottom: -R
|
|
350
352
|
} : void 0),
|
|
351
353
|
trackingEvent: (_e_trackingEvent = e.trackingEvent) !== null && _e_trackingEvent !== void 0 ? _e_trackingEvent : e.trackEvent ? L() : void 0,
|
|
352
354
|
dataAttributes: _object_spread({
|
|
353
355
|
"component-name": "ButtonLink"
|
|
354
356
|
}, e.dataAttributes),
|
|
357
|
+
"aria-label": e["aria-label"],
|
|
358
|
+
"aria-controls": e["aria-controls"],
|
|
359
|
+
"aria-expanded": e["aria-expanded"],
|
|
360
|
+
"aria-haspopup": e["aria-haspopup"],
|
|
355
361
|
children: z({
|
|
356
|
-
showSpinner:
|
|
357
|
-
shouldRenderSpinner:
|
|
362
|
+
showSpinner: o,
|
|
363
|
+
shouldRenderSpinner: i,
|
|
358
364
|
setShouldRenderSpinner: v,
|
|
359
365
|
children: e.children,
|
|
360
|
-
loadingText:
|
|
366
|
+
loadingText: c,
|
|
361
367
|
small: !0,
|
|
362
368
|
renderText: S,
|
|
363
369
|
textContentStyle: ee,
|
|
@@ -365,66 +371,66 @@ const N = (param)=>{
|
|
|
365
371
|
EndIcon: e.EndIcon,
|
|
366
372
|
withChevron: s
|
|
367
373
|
}),
|
|
368
|
-
disabled: e.disabled ||
|
|
374
|
+
disabled: e.disabled || o || g
|
|
369
375
|
};
|
|
370
376
|
if (process.env.NODE_ENV !== "production" && (e.to === "" || e.href === "")) throw Error("to or href props are empty strings");
|
|
371
|
-
if (e.onPress) return /* @__PURE__ */ t(
|
|
372
|
-
ref:
|
|
373
|
-
},
|
|
377
|
+
if (e.onPress) return /* @__PURE__ */ t(b, _object_spread_props(_object_spread({
|
|
378
|
+
ref: r
|
|
379
|
+
}, I), {
|
|
374
380
|
onPress: (h)=>{
|
|
375
|
-
const
|
|
376
|
-
|
|
381
|
+
const y = e.onPress(h);
|
|
382
|
+
y && (m(!0), y.finally(()=>m(!1)));
|
|
377
383
|
}
|
|
378
384
|
}));
|
|
379
|
-
if (e.to || e.to === "") return /* @__PURE__ */ t(
|
|
380
|
-
ref:
|
|
381
|
-
},
|
|
385
|
+
if (e.to || e.to === "") return /* @__PURE__ */ t(b, _object_spread_props(_object_spread({
|
|
386
|
+
ref: r
|
|
387
|
+
}, I), {
|
|
382
388
|
to: e.to,
|
|
383
389
|
fullPageOnWebView: e.fullPageOnWebView
|
|
384
390
|
}));
|
|
385
|
-
if (e.href || e.href === "") return /* @__PURE__ */ t(
|
|
386
|
-
ref:
|
|
387
|
-
},
|
|
391
|
+
if (e.href || e.href === "") return /* @__PURE__ */ t(b, _object_spread_props(_object_spread({
|
|
392
|
+
ref: r
|
|
393
|
+
}, I), {
|
|
388
394
|
href: e.href,
|
|
389
395
|
newTab: e.newTab
|
|
390
396
|
}));
|
|
391
397
|
if (process.env.NODE_ENV !== "production") throw Error("Bad button props");
|
|
392
398
|
return null;
|
|
393
|
-
}), _e = /*#__PURE__*/
|
|
394
|
-
var { dataAttributes: e } = _param,
|
|
399
|
+
}), _e = /*#__PURE__*/ a.forwardRef((_param, n)=>/* @__PURE__ */ {
|
|
400
|
+
var { dataAttributes: e } = _param, r = _object_without_properties(_param, [
|
|
395
401
|
"dataAttributes"
|
|
396
402
|
]);
|
|
397
403
|
return t(_, _object_spread_props(_object_spread({
|
|
398
404
|
dataAttributes: _object_spread({
|
|
399
405
|
"component-name": "ButtonPrimary"
|
|
400
406
|
}, e)
|
|
401
|
-
},
|
|
407
|
+
}, r), {
|
|
402
408
|
ref: n,
|
|
403
409
|
type: "primary"
|
|
404
410
|
}));
|
|
405
|
-
}), we = /*#__PURE__*/
|
|
406
|
-
var { dataAttributes: e } = _param,
|
|
411
|
+
}), we = /*#__PURE__*/ a.forwardRef((_param, n)=>/* @__PURE__ */ {
|
|
412
|
+
var { dataAttributes: e } = _param, r = _object_without_properties(_param, [
|
|
407
413
|
"dataAttributes"
|
|
408
414
|
]);
|
|
409
415
|
return t(_, _object_spread_props(_object_spread({
|
|
410
416
|
dataAttributes: _object_spread({
|
|
411
417
|
"component-name": "ButtonSecondary"
|
|
412
418
|
}, e)
|
|
413
|
-
},
|
|
419
|
+
}, r), {
|
|
414
420
|
ref: n,
|
|
415
421
|
type: "secondary"
|
|
416
422
|
}));
|
|
417
|
-
}),
|
|
418
|
-
var { dataAttributes: e } = _param,
|
|
423
|
+
}), xe = /*#__PURE__*/ a.forwardRef((_param, n)=>/* @__PURE__ */ {
|
|
424
|
+
var { dataAttributes: e } = _param, r = _object_without_properties(_param, [
|
|
419
425
|
"dataAttributes"
|
|
420
426
|
]);
|
|
421
427
|
return t(_, _object_spread_props(_object_spread({
|
|
422
428
|
dataAttributes: _object_spread({
|
|
423
429
|
"component-name": "ButtonDanger"
|
|
424
430
|
}, e)
|
|
425
|
-
},
|
|
431
|
+
}, r), {
|
|
426
432
|
ref: n,
|
|
427
433
|
type: "danger"
|
|
428
434
|
}));
|
|
429
435
|
});
|
|
430
|
-
export {
|
|
436
|
+
export { xe as ButtonDanger, Ne as ButtonLink, _e as ButtonPrimary, we as ButtonSecondary };
|