@kakadu/components 3.15.3 → 3.15.5
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.
|
@@ -13,6 +13,7 @@ export type PopoverMenuItemProperties = {
|
|
|
13
13
|
readonly reference?: Ref<PopoverMenuItemElementType>;
|
|
14
14
|
readonly label: ReactNode;
|
|
15
15
|
readonly href?: string;
|
|
16
|
+
readonly target?: string;
|
|
16
17
|
readonly iconLeft?: IconType;
|
|
17
18
|
readonly iconRight?: IconType;
|
|
18
19
|
readonly submenu?: ReturnType<typeof usePopoverMenu>;
|
|
@@ -23,6 +24,7 @@ export type PopoverMenuItemProperties = {
|
|
|
23
24
|
readonly onMouseEnter?: (event: MouseEvent<PopoverMenuItemElementType>) => void;
|
|
24
25
|
};
|
|
25
26
|
export declare function usePopoverMenu(items: PopoverMenuItemProperties[]): {
|
|
27
|
+
isVisible: boolean;
|
|
26
28
|
show: () => Promise<void | undefined>;
|
|
27
29
|
close: (result?: void | undefined) => void;
|
|
28
30
|
popoverMenu: import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-BB_1_6y_.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-BB_1_6y_.js"),N=require("@kuma-ui/core"),i=require("react"),C=require("../theme.js"),w=require("../icons/icon.js"),v=require("./popover.js"),F=require("./atom.js"),q=require("./text.js"),M=require("./hover-gradient.js"),K=require("./click-ripples.js"),z=require("./separator.js"),A=require("./decorators.js"),P=require("./spinner.js"),D=require("./skeleton.js"),T=require("./aria-text.js"),R=new Set;function I(){const[t,s]=i.useState(!1),r=i.useCallback(u=>{s(u);for(const n of R)n(u)},[]);return i.useEffect(()=>{const u=n=>{s(n)};return R.add(u),()=>{R.delete(u)}},[]),i.useMemo(()=>({isKeyboardNavigating:t,setIsKeyboardNavigating:r}),[t,r])}const V="kakadu-components-949294122";function H({isLoading:t,label:s,iconLeft:r,iconRight:u,href:n,target:m,shouldCloseOnClick:E=!0,decorators:c=[],submenu:o,className:d,onClick:x,...l}){const{isVisible:j,isPreparingFocus:p,isFocused:a,close:k}=v.usePopoverContext(),{isKeyboardNavigating:f}=I(),h=i.useRef(!0),y=i.useCallback(()=>{h.current=a},[a]),b=i.useCallback(_=>{!f&&!h.current||a&&(x==null||x(_),o?o.show():E&&(k==null||k()))},[f,a,x,o,E,k]),g=i.useMemo(()=>e.jsxRuntimeExports.jsxs(F.default,{as:n&&!t?"a":"button",...l,type:n&&!t?void 0:"button",role:"menuitem",href:n,target:m,inert:!j&&!p||t,disabled:n?void 0:!j&&!p||t,className:N.cx(C.buttonResetStyles,"kakadu-components-1772835671",a&&"kakadu-components-3160069815",f?"kakadu-components-2254977234":a&&"kakadu-components-278139688",d),onClick:b,onPointerDownCapture:y,children:[e.jsxRuntimeExports.jsx(q.Span,{className:"kakadu-components-1109353535",children:t?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(T.default,{children:s}),r?e.jsxRuntimeExports.jsx(P.default,{size:12}):null,e.jsxRuntimeExports.jsx(D.SkeletonInstance,{height:"1em",width:"100%"}),u?e.jsxRuntimeExports.jsx(P.default,{size:12}):null]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[r?e.jsxRuntimeExports.jsx(w.default,{width:12,height:12,type:r}):null,e.jsxRuntimeExports.jsx("span",{className:"kakadu-components-4055589237",children:s}),u?e.jsxRuntimeExports.jsx(w.default,{width:12,height:12,type:u}):null]})}),f||t?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(K.default,{isActive:a,size:100}),e.jsxRuntimeExports.jsx(M.default,{isActive:a,size:150,className:M.normalBlendStyles})]})]}),[n,m,t,l,j,p,f,d,b,y,r,s,u,a]);return e.jsxRuntimeExports.jsx(A.default,{decorators:c,children:o?e.jsxRuntimeExports.jsx(S,{menu:o.popoverMenu,className:"kakadu-components-1861176543",children:g}):g})}function $(t){if("type"in t){if(t.type==="separator")return e.jsxRuntimeExports.jsx(z.default,{});if(t.type==="group")return e.jsxRuntimeExports.jsx(q.Span,{className:"kakadu-components-1499037363",children:t.label})}return e.jsxRuntimeExports.jsx(H,{...t})}function B({items:t}){const{isFocused:s}=v.usePopoverContext(),[r,u]=i.useState([]),{setIsKeyboardNavigating:n}=I(),m=i.useCallback(c=>{c&&u(o=>o.includes(c)?o:[...o,c])},[]),E=i.useCallback(c=>{s&&(c.currentTarget.focus(),n(!1))},[s,n]);return i.useEffect(()=>{if(!s)return;const c=o=>{const d=r.filter(a=>a.isConnected),x=d.length;if(x===0)return;let l;const j=document.activeElement;let p=j?d.indexOf(j):-1;switch(p===-1&&(p=0),o.key){case"ArrowDown":{l=(p+1)%x;break}case"ArrowUp":{l=(p-1+x)%x;break}case"Home":{l=0;break}case"End":{l=x-1;break}case"Tab":{n(!0);return}}if(l!==void 0){o.preventDefault(),o.stopPropagation();const a=d[l];a&&(a.focus(),n(!0))}};return window.addEventListener("keydown",c,{capture:!0}),()=>{window.removeEventListener("keydown",c,{capture:!0})}},[s,r,n]),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:t.map((c,o)=>e.jsxRuntimeExports.jsx($,{...c,reference:m,onMouseEnter:E},o))})}function G({items:t,...s}){return e.jsxRuntimeExports.jsx(v.default,{...s,as:"nav",role:"menu",innerClassName:"kakadu-components-3600436535",children:e.jsxRuntimeExports.jsx(B,{items:t})})}function O(t){const s=i.useMemo(()=>({items:t}),[t]),{isVisible:r,show:u,close:n,popover:m}=v.usePopover(G,s);return i.useMemo(()=>({isVisible:r,show:u,close:n,popoverMenu:m}),[r,u,n,m])}function S({menu:t,className:s,children:r}){return e.jsxRuntimeExports.jsxs(v.PopoverContainer,{className:s,children:[r,t]})}exports.dangerPopoverMenuItemStyles=V;exports.default=S;exports.usePopoverMenu=O;
|
|
@@ -1,126 +1,127 @@
|
|
|
1
1
|
import { j as e } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
-
import { cx as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { buttonResetStyles as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
2
|
+
import { cx as C } from "@kuma-ui/core";
|
|
3
|
+
import { useMemo as h, useState as M, useCallback as v, useEffect as S, useRef as D } from "react";
|
|
4
|
+
import { buttonResetStyles as z } from "../theme.mjs";
|
|
5
|
+
import b from "../icons/icon.mjs";
|
|
6
|
+
import H, { PopoverContainer as T, usePopover as V, usePopoverContext as E } from "./popover.mjs";
|
|
7
7
|
import R from "./atom.mjs";
|
|
8
|
-
import { Span as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { SkeletonInstance as
|
|
15
|
-
import
|
|
16
|
-
const
|
|
17
|
-
function
|
|
18
|
-
const [n, r] =
|
|
8
|
+
import { Span as F } from "./text.mjs";
|
|
9
|
+
import B, { normalBlendStyles as G } from "./hover-gradient.mjs";
|
|
10
|
+
import U from "./click-ripples.mjs";
|
|
11
|
+
import q from "./separator.mjs";
|
|
12
|
+
import J from "./decorators.mjs";
|
|
13
|
+
import N from "./spinner.mjs";
|
|
14
|
+
import { SkeletonInstance as O } from "./skeleton.mjs";
|
|
15
|
+
import Q from "./aria-text.mjs";
|
|
16
|
+
const w = /* @__PURE__ */ new Set();
|
|
17
|
+
function A() {
|
|
18
|
+
const [n, r] = M(!1), s = v((a) => {
|
|
19
19
|
r(a);
|
|
20
|
-
for (const t of
|
|
20
|
+
for (const t of w)
|
|
21
21
|
t(a);
|
|
22
22
|
}, []);
|
|
23
|
-
return
|
|
23
|
+
return S(() => {
|
|
24
24
|
const a = (t) => {
|
|
25
25
|
r(t);
|
|
26
26
|
};
|
|
27
|
-
return
|
|
28
|
-
|
|
27
|
+
return w.add(a), () => {
|
|
28
|
+
w.delete(a);
|
|
29
29
|
};
|
|
30
|
-
}, []),
|
|
30
|
+
}, []), h(() => ({
|
|
31
31
|
isKeyboardNavigating: n,
|
|
32
32
|
setIsKeyboardNavigating: s
|
|
33
33
|
}), [n, s]);
|
|
34
34
|
}
|
|
35
|
-
const
|
|
36
|
-
function
|
|
35
|
+
const de = "kakadu-components-949294122";
|
|
36
|
+
function W({
|
|
37
37
|
isLoading: n,
|
|
38
38
|
label: r,
|
|
39
39
|
iconLeft: s,
|
|
40
40
|
iconRight: a,
|
|
41
41
|
href: t,
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
target: p,
|
|
43
|
+
shouldCloseOnClick: k = !0,
|
|
44
|
+
decorators: c = [],
|
|
44
45
|
submenu: o,
|
|
45
|
-
className:
|
|
46
|
-
onClick:
|
|
47
|
-
...
|
|
46
|
+
className: d,
|
|
47
|
+
onClick: u,
|
|
48
|
+
...m
|
|
48
49
|
}) {
|
|
49
50
|
const {
|
|
50
|
-
isVisible:
|
|
51
|
-
isPreparingFocus:
|
|
51
|
+
isVisible: f,
|
|
52
|
+
isPreparingFocus: l,
|
|
52
53
|
isFocused: i,
|
|
53
|
-
close:
|
|
54
|
-
} =
|
|
55
|
-
isKeyboardNavigating:
|
|
56
|
-
} =
|
|
57
|
-
|
|
58
|
-
}, [i]),
|
|
59
|
-
!
|
|
60
|
-
}, [
|
|
61
|
-
/* @__PURE__ */ e.jsx(
|
|
62
|
-
/* @__PURE__ */ e.jsx(
|
|
63
|
-
s ? /* @__PURE__ */ e.jsx(
|
|
64
|
-
/* @__PURE__ */ e.jsx(
|
|
65
|
-
a ? /* @__PURE__ */ e.jsx(
|
|
54
|
+
close: j
|
|
55
|
+
} = E(), {
|
|
56
|
+
isKeyboardNavigating: x
|
|
57
|
+
} = A(), y = D(!0), g = v(() => {
|
|
58
|
+
y.current = i;
|
|
59
|
+
}, [i]), I = v((K) => {
|
|
60
|
+
!x && !y.current || i && (u == null || u(K), o ? o.show() : k && (j == null || j()));
|
|
61
|
+
}, [x, i, u, o, k, j]), P = h(() => /* @__PURE__ */ e.jsxs(R, { as: t && !n ? "a" : "button", ...m, type: t && !n ? void 0 : "button", role: "menuitem", href: t, target: p, inert: !f && !l || n, disabled: t ? void 0 : !f && !l || n, className: C(z, "kakadu-components-1772835671", i && "kakadu-components-3160069815", x ? "kakadu-components-2254977234" : i && "kakadu-components-278139688", d), onClick: I, onPointerDownCapture: g, children: [
|
|
62
|
+
/* @__PURE__ */ e.jsx(F, { className: "kakadu-components-1109353535", children: n ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
63
|
+
/* @__PURE__ */ e.jsx(Q, { children: r }),
|
|
64
|
+
s ? /* @__PURE__ */ e.jsx(N, { size: 12 }) : null,
|
|
65
|
+
/* @__PURE__ */ e.jsx(O, { height: "1em", width: "100%" }),
|
|
66
|
+
a ? /* @__PURE__ */ e.jsx(N, { size: 12 }) : null
|
|
66
67
|
] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
67
|
-
s ? /* @__PURE__ */ e.jsx(
|
|
68
|
+
s ? /* @__PURE__ */ e.jsx(b, { width: 12, height: 12, type: s }) : null,
|
|
68
69
|
/* @__PURE__ */ e.jsx("span", { className: "kakadu-components-4055589237", children: r }),
|
|
69
|
-
a ? /* @__PURE__ */ e.jsx(
|
|
70
|
+
a ? /* @__PURE__ */ e.jsx(b, { width: 12, height: 12, type: a }) : null
|
|
70
71
|
] }) }),
|
|
71
|
-
|
|
72
|
-
/* @__PURE__ */ e.jsx(
|
|
73
|
-
/* @__PURE__ */ e.jsx(
|
|
72
|
+
x || n ? null : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
73
|
+
/* @__PURE__ */ e.jsx(U, { isActive: i, size: 100 }),
|
|
74
|
+
/* @__PURE__ */ e.jsx(B, { isActive: i, size: 150, className: G })
|
|
74
75
|
] })
|
|
75
|
-
] }), [t, n,
|
|
76
|
-
return /* @__PURE__ */ e.jsx(
|
|
76
|
+
] }), [t, p, n, m, f, l, x, d, I, g, s, r, a, i]);
|
|
77
|
+
return /* @__PURE__ */ e.jsx(J, { decorators: c, children: o ? /* @__PURE__ */ e.jsx(_, { menu: o.popoverMenu, className: "kakadu-components-1861176543", children: P }) : P });
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
+
function X(n) {
|
|
79
80
|
if ("type" in n) {
|
|
80
81
|
if (n.type === "separator")
|
|
81
|
-
return /* @__PURE__ */ e.jsx(
|
|
82
|
+
return /* @__PURE__ */ e.jsx(q, {});
|
|
82
83
|
if (n.type === "group")
|
|
83
|
-
return /* @__PURE__ */ e.jsx(
|
|
84
|
+
return /* @__PURE__ */ e.jsx(F, { className: "kakadu-components-1499037363", children: n.label });
|
|
84
85
|
}
|
|
85
|
-
return /* @__PURE__ */ e.jsx(
|
|
86
|
+
return /* @__PURE__ */ e.jsx(W, { ...n });
|
|
86
87
|
}
|
|
87
|
-
function
|
|
88
|
+
function Y({
|
|
88
89
|
items: n
|
|
89
90
|
}) {
|
|
90
91
|
const {
|
|
91
92
|
isFocused: r
|
|
92
|
-
} =
|
|
93
|
+
} = E(), [s, a] = M([]), {
|
|
93
94
|
setIsKeyboardNavigating: t
|
|
94
|
-
} =
|
|
95
|
-
|
|
96
|
-
}, []),
|
|
97
|
-
r && (
|
|
95
|
+
} = A(), p = v((c) => {
|
|
96
|
+
c && a((o) => o.includes(c) ? o : [...o, c]);
|
|
97
|
+
}, []), k = v((c) => {
|
|
98
|
+
r && (c.currentTarget.focus(), t(!1));
|
|
98
99
|
}, [r, t]);
|
|
99
|
-
return
|
|
100
|
+
return S(() => {
|
|
100
101
|
if (!r)
|
|
101
102
|
return;
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
103
|
+
const c = (o) => {
|
|
104
|
+
const d = s.filter((i) => i.isConnected), u = d.length;
|
|
105
|
+
if (u === 0)
|
|
105
106
|
return;
|
|
106
|
-
let
|
|
107
|
-
const
|
|
108
|
-
let
|
|
109
|
-
switch (
|
|
107
|
+
let m;
|
|
108
|
+
const f = document.activeElement;
|
|
109
|
+
let l = f ? d.indexOf(f) : -1;
|
|
110
|
+
switch (l === -1 && (l = 0), o.key) {
|
|
110
111
|
case "ArrowDown": {
|
|
111
|
-
|
|
112
|
+
m = (l + 1) % u;
|
|
112
113
|
break;
|
|
113
114
|
}
|
|
114
115
|
case "ArrowUp": {
|
|
115
|
-
|
|
116
|
+
m = (l - 1 + u) % u;
|
|
116
117
|
break;
|
|
117
118
|
}
|
|
118
119
|
case "Home": {
|
|
119
|
-
|
|
120
|
+
m = 0;
|
|
120
121
|
break;
|
|
121
122
|
}
|
|
122
123
|
case "End": {
|
|
123
|
-
|
|
124
|
+
m = u - 1;
|
|
124
125
|
break;
|
|
125
126
|
}
|
|
126
127
|
case "Tab": {
|
|
@@ -128,61 +129,63 @@ function X({
|
|
|
128
129
|
return;
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
132
|
+
if (m !== void 0) {
|
|
133
|
+
o.preventDefault(), o.stopPropagation();
|
|
134
|
+
const i = d[m];
|
|
135
|
+
i && (i.focus(), t(!0));
|
|
135
136
|
}
|
|
136
137
|
};
|
|
137
|
-
return window.addEventListener("keydown",
|
|
138
|
+
return window.addEventListener("keydown", c, {
|
|
138
139
|
capture: !0
|
|
139
140
|
}), () => {
|
|
140
|
-
window.removeEventListener("keydown",
|
|
141
|
+
window.removeEventListener("keydown", c, {
|
|
141
142
|
capture: !0
|
|
142
143
|
});
|
|
143
144
|
};
|
|
144
|
-
}, [r, s, t]), /* @__PURE__ */ e.jsx(e.Fragment, { children: n.map((
|
|
145
|
-
|
|
145
|
+
}, [r, s, t]), /* @__PURE__ */ e.jsx(e.Fragment, { children: n.map((c, o) => /* @__PURE__ */ e.jsx(
|
|
146
|
+
X,
|
|
146
147
|
{
|
|
147
|
-
...
|
|
148
|
-
reference:
|
|
149
|
-
onMouseEnter:
|
|
148
|
+
...c,
|
|
149
|
+
reference: p,
|
|
150
|
+
onMouseEnter: k
|
|
150
151
|
},
|
|
151
|
-
|
|
152
|
+
o
|
|
152
153
|
)) });
|
|
153
154
|
}
|
|
154
|
-
function
|
|
155
|
+
function Z({
|
|
155
156
|
items: n,
|
|
156
157
|
...r
|
|
157
158
|
}) {
|
|
158
|
-
return /* @__PURE__ */ e.jsx(
|
|
159
|
+
return /* @__PURE__ */ e.jsx(H, { ...r, as: "nav", role: "menu", innerClassName: "kakadu-components-3600436535", children: /* @__PURE__ */ e.jsx(Y, { items: n }) });
|
|
159
160
|
}
|
|
160
|
-
function
|
|
161
|
-
const r =
|
|
161
|
+
function fe(n) {
|
|
162
|
+
const r = h(() => ({
|
|
162
163
|
items: n
|
|
163
164
|
}), [n]), {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
165
|
+
isVisible: s,
|
|
166
|
+
show: a,
|
|
167
|
+
close: t,
|
|
168
|
+
popover: p
|
|
169
|
+
} = V(Z, r);
|
|
170
|
+
return h(() => ({
|
|
171
|
+
isVisible: s,
|
|
172
|
+
show: a,
|
|
173
|
+
close: t,
|
|
174
|
+
popoverMenu: p
|
|
175
|
+
}), [s, a, t, p]);
|
|
173
176
|
}
|
|
174
|
-
function
|
|
177
|
+
function _({
|
|
175
178
|
menu: n,
|
|
176
179
|
className: r,
|
|
177
180
|
children: s
|
|
178
181
|
}) {
|
|
179
|
-
return /* @__PURE__ */ e.jsxs(
|
|
182
|
+
return /* @__PURE__ */ e.jsxs(T, { className: r, children: [
|
|
180
183
|
s,
|
|
181
184
|
n
|
|
182
185
|
] });
|
|
183
186
|
}
|
|
184
187
|
export {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
+
de as dangerPopoverMenuItemStyles,
|
|
189
|
+
_ as default,
|
|
190
|
+
fe as usePopoverMenu
|
|
188
191
|
};
|