@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/menu.js
CHANGED
|
@@ -51,15 +51,15 @@ function _object_spread_props(target, source) {
|
|
|
51
51
|
return target;
|
|
52
52
|
}
|
|
53
53
|
import { jsx as e, jsxs as C, Fragment as U } from "react/jsx-runtime";
|
|
54
|
-
import * as
|
|
54
|
+
import * as o from "react";
|
|
55
55
|
import ne from "classnames";
|
|
56
56
|
import { TAB as oe, ENTER as W, SPACE as G, ESC as se, UP as re, LEFT as ie, DOWN as K, RIGHT as ce } from "./utils/key-codes.js";
|
|
57
57
|
import { getPrefixedDataAttributes as le, cancelEvent as S } from "./utils/dom.js";
|
|
58
58
|
import ae from "./overlay.js";
|
|
59
|
-
import { menuItem as
|
|
59
|
+
import { menuItem as ue, menuItemEnabled as me, menuItemDisabled as de, menuItemHovered as fe, menuSectionDivider as pe, menuTransitionClasses as he, vars as b, itemContent as Y, iconContainer as j, menuContainer as ge } from "./menu.css-mistica.js";
|
|
60
60
|
import { useWindowSize as xe } from "./hooks.js";
|
|
61
|
-
import { Portal as
|
|
62
|
-
import { assignInlineVars as
|
|
61
|
+
import { Portal as be } from "./portal.js";
|
|
62
|
+
import { assignInlineVars as Ie } from "@vanilla-extract/dynamic";
|
|
63
63
|
import y from "./box.js";
|
|
64
64
|
import ve from "./inline.js";
|
|
65
65
|
import Me from "./touchable.js";
|
|
@@ -69,25 +69,25 @@ import Oe from "./divider.js";
|
|
|
69
69
|
import Te from "./checkbox.js";
|
|
70
70
|
import { CSSTransition as Se } from "react-transition-group";
|
|
71
71
|
import { combineRefs as Ce } from "./utils/common.js";
|
|
72
|
-
const Ee = 120, Q = /*#__PURE__*/
|
|
72
|
+
const Ee = 120, Q = /*#__PURE__*/ o.createContext({
|
|
73
73
|
focusedItem: null,
|
|
74
74
|
isMenuOpen: !1,
|
|
75
75
|
setFocusedItem: ()=>{},
|
|
76
76
|
closeMenu: ()=>{}
|
|
77
|
-
}), ke = ()=>
|
|
77
|
+
}), ke = ()=>o.useContext(Q), D = (r)=>r ? Array.from(r.querySelectorAll("[role=menuitem],[role=menuitemcheckbox]")) : [], Ne = (r, d)=>{
|
|
78
78
|
if (!d) return null;
|
|
79
79
|
const f = D(r).indexOf(d);
|
|
80
80
|
return f < 0 ? null : f;
|
|
81
81
|
}, je = (param)=>{
|
|
82
|
-
let { label: r , Icon: d , destructive: f , disabled:
|
|
83
|
-
const { focusedItem:
|
|
82
|
+
let { label: r , Icon: d , destructive: f , disabled: u , onPress: E , controlType: s , checked: p } = param;
|
|
83
|
+
const { focusedItem: n , setFocusedItem: v , closeMenu: i , isMenuOpen: k } = ke(), c = o.useRef(null), h = f ? q.colors.textLinkDanger : q.colors.neutralHigh, x = c == null ? void 0 : c.current, M = (x == null ? void 0 : x.closest("[role=menu]")) || null, m = Ne(M, x), l = ()=>s === "checkbox" ? /* @__PURE__ */ e(Te, {
|
|
84
84
|
ref: c,
|
|
85
85
|
name: r,
|
|
86
86
|
checked: p,
|
|
87
87
|
onChange: ()=>{
|
|
88
|
-
k &&
|
|
88
|
+
k && m !== null && (E(m), i());
|
|
89
89
|
},
|
|
90
|
-
disabled:
|
|
90
|
+
disabled: u,
|
|
91
91
|
role: "menuitemcheckbox",
|
|
92
92
|
render: (param)=>/* @__PURE__ */ {
|
|
93
93
|
let { controlElement: N } = param;
|
|
@@ -126,9 +126,9 @@ const Ee = 120, Q = /*#__PURE__*/ n.createContext({
|
|
|
126
126
|
}) : /* @__PURE__ */ e(Me, {
|
|
127
127
|
ref: c,
|
|
128
128
|
onPress: ()=>{
|
|
129
|
-
k &&
|
|
129
|
+
k && m !== null && (E(m), i());
|
|
130
130
|
},
|
|
131
|
-
disabled:
|
|
131
|
+
disabled: u,
|
|
132
132
|
role: "menuitem",
|
|
133
133
|
children: /* @__PURE__ */ e(y, {
|
|
134
134
|
paddingX: 8,
|
|
@@ -153,12 +153,12 @@ const Ee = 120, Q = /*#__PURE__*/ n.createContext({
|
|
|
153
153
|
})
|
|
154
154
|
});
|
|
155
155
|
return /* @__PURE__ */ e("div", {
|
|
156
|
-
className: ne(
|
|
157
|
-
[
|
|
158
|
-
[de]:
|
|
159
|
-
[fe]: !
|
|
156
|
+
className: ne(ue, {
|
|
157
|
+
[me]: !u,
|
|
158
|
+
[de]: u,
|
|
159
|
+
[fe]: !u && m !== null && n === m
|
|
160
160
|
}),
|
|
161
|
-
onMouseMove: ()=>v(
|
|
161
|
+
onMouseMove: ()=>v(u ? null : m),
|
|
162
162
|
onMouseLeave: ()=>v(null),
|
|
163
163
|
children: l()
|
|
164
164
|
});
|
|
@@ -175,75 +175,75 @@ const Ee = 120, Q = /*#__PURE__*/ n.createContext({
|
|
|
175
175
|
]
|
|
176
176
|
}) : /* @__PURE__ */ e(U, {});
|
|
177
177
|
}, V = 12, J = 8, qe = (param)=>{
|
|
178
|
-
let { renderTarget: r , renderMenu: d , width: f , position:
|
|
179
|
-
const [
|
|
180
|
-
|
|
181
|
-
const a =
|
|
182
|
-
if (!i || !a || !
|
|
183
|
-
const { top: t , right: O , left: g , bottom:
|
|
178
|
+
let { renderTarget: r , renderMenu: d , width: f , position: u = "left" , dataAttributes: E } = param;
|
|
179
|
+
const [s, p] = o.useState(!1), [n, v] = o.useState(null), [i, k] = o.useState(null), [c, h] = o.useState(null), [x, M] = o.useState(!1), m = o.useRef(null), [l, N] = o.useState(null), R = xe();
|
|
180
|
+
o.useEffect(()=>{
|
|
181
|
+
const a = n == null ? void 0 : n.getBoundingClientRect();
|
|
182
|
+
if (!i || !a || !s) return;
|
|
183
|
+
const { top: t , right: O , left: g , bottom: A } = a, T = i.scrollHeight, I = u === "left" ? g : void 0, F = u === "right" ? R.width - O : void 0, L = t - J, $ = A + J, H = R.height - $ - V, P = L - V, B = H > T, z = P > T, te = B || !z && H > P;
|
|
184
184
|
N(te ? {
|
|
185
|
-
left:
|
|
186
|
-
right:
|
|
185
|
+
left: I,
|
|
186
|
+
right: F,
|
|
187
187
|
top: `${$}px`,
|
|
188
188
|
bottom: "auto",
|
|
189
189
|
maxHeight: B ? void 0 : H,
|
|
190
190
|
transformOrigin: "center top"
|
|
191
191
|
} : {
|
|
192
|
-
left:
|
|
193
|
-
right:
|
|
192
|
+
left: I,
|
|
193
|
+
right: F,
|
|
194
194
|
top: "auto",
|
|
195
195
|
bottom: `${R.height - L}px`,
|
|
196
196
|
maxHeight: z ? void 0 : P,
|
|
197
197
|
transformOrigin: "center bottom"
|
|
198
198
|
});
|
|
199
199
|
}, [
|
|
200
|
-
|
|
201
|
-
o,
|
|
202
|
-
i,
|
|
200
|
+
u,
|
|
203
201
|
s,
|
|
202
|
+
i,
|
|
203
|
+
n,
|
|
204
204
|
f,
|
|
205
205
|
R
|
|
206
206
|
]);
|
|
207
|
-
const Z =
|
|
207
|
+
const Z = o.useMemo(()=>({
|
|
208
208
|
ref: v,
|
|
209
209
|
onPress: ()=>{
|
|
210
|
-
p(!
|
|
210
|
+
p(!s);
|
|
211
211
|
}
|
|
212
212
|
}), [
|
|
213
213
|
v,
|
|
214
|
-
|
|
214
|
+
s
|
|
215
215
|
]), ee = {
|
|
216
|
-
ref: Ce(k,
|
|
216
|
+
ref: Ce(k, m),
|
|
217
217
|
className: ge,
|
|
218
218
|
close: ()=>p(!1)
|
|
219
|
-
}, w =
|
|
219
|
+
}, w = o.useCallback(()=>{
|
|
220
220
|
const t = D(i).findIndex((O)=>!O.getAttribute("aria-disabled"));
|
|
221
221
|
h(t < 0 ? null : t);
|
|
222
222
|
}, [
|
|
223
223
|
i
|
|
224
|
-
]), _ =
|
|
224
|
+
]), _ = o.useCallback((a)=>{
|
|
225
225
|
var T;
|
|
226
226
|
const t = D(i);
|
|
227
227
|
a && t.reverse();
|
|
228
228
|
const O = c === null ? -1 : a ? t.length - 1 - c : c;
|
|
229
|
-
let g = t.findIndex((
|
|
230
|
-
g === -1 && (g = t.findIndex((
|
|
231
|
-
const
|
|
232
|
-
h(
|
|
229
|
+
let g = t.findIndex((I, F)=>!I.getAttribute("aria-disabled") && F > O);
|
|
230
|
+
g === -1 && (g = t.findIndex((I)=>!I.getAttribute("aria-disabled")));
|
|
231
|
+
const A = a && g !== -1 ? t.length - 1 - g : g;
|
|
232
|
+
h(A < 0 ? null : A), (T = t[g]) == null || T.focus();
|
|
233
233
|
}, [
|
|
234
234
|
c,
|
|
235
235
|
i
|
|
236
236
|
]);
|
|
237
|
-
return
|
|
238
|
-
|
|
237
|
+
return o.useEffect(()=>{
|
|
238
|
+
s ? x && i && (w(), M(!1)) : h(null);
|
|
239
239
|
}, [
|
|
240
|
-
|
|
240
|
+
s,
|
|
241
241
|
w,
|
|
242
242
|
x,
|
|
243
243
|
i
|
|
244
|
-
]),
|
|
244
|
+
]), o.useEffect(()=>{
|
|
245
245
|
const a = (t)=>{
|
|
246
|
-
if (
|
|
246
|
+
if (s) switch(t.keyCode){
|
|
247
247
|
case ce:
|
|
248
248
|
case K:
|
|
249
249
|
S(t), _();
|
|
@@ -269,55 +269,55 @@ const Ee = 120, Q = /*#__PURE__*/ n.createContext({
|
|
|
269
269
|
M(!0);
|
|
270
270
|
break;
|
|
271
271
|
case K:
|
|
272
|
-
|
|
272
|
+
n === document.activeElement && (M(!0), p(!0));
|
|
273
273
|
break;
|
|
274
274
|
}
|
|
275
275
|
};
|
|
276
276
|
return document.addEventListener("keydown", a, !1), ()=>{
|
|
277
277
|
document.removeEventListener("keydown", a, !1);
|
|
278
278
|
};
|
|
279
|
-
}),
|
|
280
|
-
|
|
279
|
+
}), o.useEffect(()=>{
|
|
280
|
+
n == null || n.setAttribute("aria-haspopup", "menu"), n == null || n.setAttribute("aria-expanded", String(s));
|
|
281
281
|
}, [
|
|
282
|
-
|
|
283
|
-
|
|
282
|
+
n,
|
|
283
|
+
s
|
|
284
284
|
]), /* @__PURE__ */ C("div", _object_spread_props(_object_spread({}, le(E, "Menu")), {
|
|
285
285
|
children: [
|
|
286
286
|
r(_object_spread_props(_object_spread({}, Z), {
|
|
287
|
-
isMenuOpen:
|
|
287
|
+
isMenuOpen: s
|
|
288
288
|
})),
|
|
289
|
-
/* @__PURE__ */ e(
|
|
289
|
+
/* @__PURE__ */ e(be, {
|
|
290
290
|
children: /* @__PURE__ */ e(Se, {
|
|
291
|
-
in:
|
|
292
|
-
nodeRef:
|
|
291
|
+
in: s,
|
|
292
|
+
nodeRef: m,
|
|
293
293
|
timeout: Ee,
|
|
294
294
|
classNames: he,
|
|
295
295
|
mountOnEnter: !0,
|
|
296
296
|
unmountOnExit: !0,
|
|
297
|
-
onExit: ()=>
|
|
297
|
+
onExit: ()=>n == null ? void 0 : n.focus(),
|
|
298
298
|
children: /* @__PURE__ */ e(ae, {
|
|
299
299
|
onPress: (a)=>{
|
|
300
300
|
S(a), p(!1);
|
|
301
301
|
},
|
|
302
302
|
disableScroll: !0,
|
|
303
303
|
children: /* @__PURE__ */ e("div", {
|
|
304
|
-
style: _object_spread({},
|
|
305
|
-
[
|
|
306
|
-
[
|
|
307
|
-
[
|
|
304
|
+
style: _object_spread({}, Ie(_object_spread({}, l ? _object_spread({
|
|
305
|
+
[b.top]: l.top,
|
|
306
|
+
[b.bottom]: l.bottom,
|
|
307
|
+
[b.transformOrigin]: l.transformOrigin
|
|
308
308
|
}, l.left !== void 0 && {
|
|
309
|
-
[
|
|
309
|
+
[b.left]: `${l.left}px`
|
|
310
310
|
}, l.right !== void 0 && {
|
|
311
|
-
[
|
|
311
|
+
[b.right]: `${l.right}px`
|
|
312
312
|
}, l.maxHeight !== void 0 && {
|
|
313
|
-
[
|
|
313
|
+
[b.maxHeight]: `${l.maxHeight}px`
|
|
314
314
|
}, f !== void 0 && {
|
|
315
|
-
[
|
|
315
|
+
[b.width]: f ? `${f}px` : ""
|
|
316
316
|
}) : {}))),
|
|
317
317
|
role: "menu",
|
|
318
318
|
children: /* @__PURE__ */ e(Q.Provider, {
|
|
319
319
|
value: {
|
|
320
|
-
isMenuOpen:
|
|
320
|
+
isMenuOpen: s,
|
|
321
321
|
focusedItem: c,
|
|
322
322
|
setFocusedItem: h,
|
|
323
323
|
closeMenu: ()=>p(!1)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const o = "14.
|
|
1
|
+
const o = "14.27.0";
|
|
2
2
|
export { o as PACKAGE_VERSION };
|