@kakadu/components 3.2.2 → 3.2.4
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/build/components/modal.d.ts +1 -0
- package/build/components/modal.js +1 -1
- package/build/components/modal.mjs +46 -43
- package/build/components/popover-menu.js +1 -1
- package/build/components/popover-menu.mjs +58 -57
- package/build/components/popover.js +1 -1
- package/build/components/popover.mjs +1 -1
- package/build/hooks/use-fetch.js +1 -1
- package/build/hooks/use-fetch.mjs +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { type DecoratorType } from './decorators';
|
|
|
3
3
|
type InitialFocusElement = HTMLElement | null;
|
|
4
4
|
type ModalProviderProperties<Data = any> = {
|
|
5
5
|
isVisible: boolean;
|
|
6
|
+
isInteractive: boolean;
|
|
6
7
|
setInitialFocus?: (initialFocus?: InitialFocusElement) => void;
|
|
7
8
|
close?: (data?: Data) => void;
|
|
8
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../jsx-runtime-BB_1_6y_.js"),e=require("react"),v=require("@kuma-ui/core"),P=require("react-dom"),$=require("../focus-trap-react-CcpTuiJi.js"),B=require("../icons/icon.js"),A=require("./text-button.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../jsx-runtime-BB_1_6y_.js"),e=require("react"),v=require("@kuma-ui/core"),P=require("react-dom"),$=require("../focus-trap-react-CcpTuiJi.js"),B=require("../icons/icon.js"),A=require("./text-button.js"),q=require("./decorators.js"),C=e.createContext({isVisible:!1,isInteractive:!1}),{Provider:D}=C;function y(){return e.useContext(C)}function z(){const{isInteractive:u,close:o}=y(),r=e.useCallback(()=>{o==null||o()},[o]);return n.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2566044647",children:n.jsxRuntimeExports.jsx(A.default,{iconLeft:B.IconType.times,label:"Close",disabled:!u,onClick:r})})}function G({root:u,outerDecorators:o=[],innerDecorators:r=[],label:x,maxWidth:c,className:m,isVisible:s,isFullWidth:l=!1,shouldCloseOnOutsideClick:i=!0,shouldCloseOnEscapePress:d=!0,showCloseButton:L=!0,onClose:k,children:S}){const E=e.useRef(null),R=e.useRef(null),[M,g]=e.useState(!1),[a,f]=e.useState(!1),b=e.useCallback(t=>{E.current=t,f(!1)},[]),j=e.useRef(null),h=e.useCallback(t=>{t&&(j.current=t)},[]),[I,w]=e.useState(s??!1),N=e.useMemo(()=>({isVisible:I,isInteractive:a,setInitialFocus:h,close:b}),[I,a,h,b]);e.useEffect(()=>{s&&(g(!0),w(!0))},[s]),e.useEffect(()=>{if(s){const t=setTimeout(()=>{f(!0)},100);return()=>{clearTimeout(t)}}f(!1)},[s]),e.useEffect(()=>{if(M&&!a){const t=setTimeout(()=>{k==null||k(E.current??void 0),w(!1)},370);return()=>{clearTimeout(t)}}},[M,a,k]),e.useEffect(()=>{const t=R.current;if(s&&i&&t){const p=F=>{t===F.target&&f(!1)};return t.addEventListener("click",p),()=>{t.removeEventListener("click",p)}}},[s,i]),e.useEffect(()=>{if(!s||!d)return;const t=p=>{p.key==="Escape"&&f(!1)};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[s,d]);const _=e.useMemo(()=>({initialFocus:()=>j.current??void 0,onActivate:()=>{var t;return(t=j.current)==null?void 0:t.focus()}}),[]),T=n.jsxRuntimeExports.jsx(q.default,{decorators:o,children:n.jsxRuntimeExports.jsx("div",{"aria-hidden":!a,style:{"--max-width":c?`${c}px`:void 0},className:v.cx("kakadu-components-4119461136",a&&"kakadu-components-2522346797",m),children:n.jsxRuntimeExports.jsx(q.default,{decorators:r,children:n.jsxRuntimeExports.jsx($.focusTrapReactExports.FocusTrap,{active:a,focusTrapOptions:_,children:n.jsxRuntimeExports.jsx("div",{ref:R,className:"kakadu-components-4011815997",children:n.jsxRuntimeExports.jsx("div",{role:"dialog","aria-modal":"true","aria-label":x??"Modal",className:v.cx("kakadu-components-3324483532",l&&"kakadu-components-3799971070",a&&"kakadu-components-968755580"),children:n.jsxRuntimeExports.jsxs(D,{value:N,children:[L?n.jsxRuntimeExports.jsx(z,{}):null,n.jsxRuntimeExports.jsx("div",{className:v.cx("kakadu-components-633990035",l&&"kakadu-components-171969824"),children:S})]})})})})})})});return u?P.createPortal(T,u):T}function H(u,o){const[r,x]=e.useState(!1),c=e.useRef(void 0),m=e.useCallback(async()=>(x(!0),new Promise(i=>{c.current=i})),[]),s=e.useCallback(i=>{var d;x(!1),(d=c.current)==null||d.call(c,i),c.current=void 0},[]),l=e.useMemo(()=>n.jsxRuntimeExports.jsx(u,{...o,isVisible:r,onClose:s}),[u,o,r,s]);return e.useMemo(()=>({isVisible:r,show:m,modal:l}),[r,m,l])}exports.default=G;exports.useModal=H;exports.useModalContext=y;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { j as n } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
-
import { createContext as q, useRef as j, useState as h, useCallback as m, useMemo as
|
|
3
|
-
import { cx as
|
|
2
|
+
import { createContext as q, useRef as j, useState as h, useCallback as m, useMemo as I, useEffect as f, useContext as z } from "react";
|
|
3
|
+
import { cx as T } from "@kuma-ui/core";
|
|
4
4
|
import { createPortal as G } from "react-dom";
|
|
5
5
|
import { f as H } from "../focus-trap-react-DYXrtbDH.mjs";
|
|
6
6
|
import { IconType as J } from "../icons/icon.mjs";
|
|
7
7
|
import K from "./text-button.mjs";
|
|
8
8
|
import g from "./decorators.mjs";
|
|
9
9
|
const C = q({
|
|
10
|
-
isVisible: !1
|
|
10
|
+
isVisible: !1,
|
|
11
|
+
isInteractive: !1
|
|
11
12
|
}), {
|
|
12
13
|
Provider: Q
|
|
13
14
|
} = C;
|
|
@@ -16,38 +17,40 @@ function U() {
|
|
|
16
17
|
}
|
|
17
18
|
function V() {
|
|
18
19
|
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
isInteractive: c,
|
|
21
|
+
close: s
|
|
22
|
+
} = U(), o = m(() => {
|
|
23
|
+
s == null || s();
|
|
24
|
+
}, [s]);
|
|
25
|
+
return /* @__PURE__ */ n.jsx("div", { className: "kakadu-components-2566044647", children: /* @__PURE__ */ n.jsx(K, { iconLeft: J.times, label: "Close", disabled: !c, onClick: o }) });
|
|
24
26
|
}
|
|
25
27
|
function ne({
|
|
26
|
-
root:
|
|
27
|
-
outerDecorators:
|
|
28
|
-
innerDecorators:
|
|
28
|
+
root: c,
|
|
29
|
+
outerDecorators: s = [],
|
|
30
|
+
innerDecorators: o = [],
|
|
29
31
|
label: k,
|
|
30
|
-
maxWidth:
|
|
32
|
+
maxWidth: r,
|
|
31
33
|
className: x,
|
|
32
34
|
isVisible: t,
|
|
33
35
|
isFullWidth: u = !1,
|
|
34
|
-
shouldCloseOnOutsideClick:
|
|
36
|
+
shouldCloseOnOutsideClick: i = !0,
|
|
35
37
|
shouldCloseOnEscapePress: l = !0,
|
|
36
38
|
showCloseButton: B = !0,
|
|
37
39
|
onClose: p,
|
|
38
40
|
children: P
|
|
39
41
|
}) {
|
|
40
|
-
const E = j(null), y = j(null), [L, A] = h(!1), [
|
|
42
|
+
const E = j(null), y = j(null), [L, A] = h(!1), [a, d] = h(!1), M = m((e) => {
|
|
41
43
|
E.current = e, d(!1);
|
|
42
|
-
}, []),
|
|
43
|
-
e && (
|
|
44
|
-
}, []), [
|
|
45
|
-
isVisible:
|
|
44
|
+
}, []), w = j(null), R = m((e) => {
|
|
45
|
+
e && (w.current = e);
|
|
46
|
+
}, []), [b, N] = h(t ?? !1), D = I(() => ({
|
|
47
|
+
isVisible: b,
|
|
48
|
+
isInteractive: a,
|
|
46
49
|
setInitialFocus: R,
|
|
47
50
|
close: M
|
|
48
|
-
}), [
|
|
51
|
+
}), [b, a, R, M]);
|
|
49
52
|
f(() => {
|
|
50
|
-
t && (A(!0),
|
|
53
|
+
t && (A(!0), N(!0));
|
|
51
54
|
}, [t]), f(() => {
|
|
52
55
|
if (t) {
|
|
53
56
|
const e = setTimeout(() => {
|
|
@@ -59,17 +62,17 @@ function ne({
|
|
|
59
62
|
}
|
|
60
63
|
d(!1);
|
|
61
64
|
}, [t]), f(() => {
|
|
62
|
-
if (L && !
|
|
65
|
+
if (L && !a) {
|
|
63
66
|
const e = setTimeout(() => {
|
|
64
|
-
p == null || p(E.current ?? void 0),
|
|
67
|
+
p == null || p(E.current ?? void 0), N(!1);
|
|
65
68
|
}, 370);
|
|
66
69
|
return () => {
|
|
67
70
|
clearTimeout(e);
|
|
68
71
|
};
|
|
69
72
|
}
|
|
70
|
-
}, [L,
|
|
73
|
+
}, [L, a, p]), f(() => {
|
|
71
74
|
const e = y.current;
|
|
72
|
-
if (t &&
|
|
75
|
+
if (t && i && e) {
|
|
73
76
|
const v = ($) => {
|
|
74
77
|
e === $.target && d(!1);
|
|
75
78
|
};
|
|
@@ -77,7 +80,7 @@ function ne({
|
|
|
77
80
|
e.removeEventListener("click", v);
|
|
78
81
|
};
|
|
79
82
|
}
|
|
80
|
-
}, [t,
|
|
83
|
+
}, [t, i]), f(() => {
|
|
81
84
|
if (!t || !l)
|
|
82
85
|
return;
|
|
83
86
|
const e = (v) => {
|
|
@@ -87,35 +90,35 @@ function ne({
|
|
|
87
90
|
window.removeEventListener("keydown", e);
|
|
88
91
|
};
|
|
89
92
|
}, [t, l]);
|
|
90
|
-
const S =
|
|
91
|
-
initialFocus: () =>
|
|
93
|
+
const S = I(() => ({
|
|
94
|
+
initialFocus: () => w.current ?? void 0,
|
|
92
95
|
onActivate: () => {
|
|
93
96
|
var e;
|
|
94
|
-
return (e =
|
|
97
|
+
return (e = w.current) == null ? void 0 : e.focus();
|
|
95
98
|
}
|
|
96
|
-
}), []), F = /* @__PURE__ */ n.jsx(g, { decorators:
|
|
97
|
-
"--max-width":
|
|
98
|
-
}, className:
|
|
99
|
+
}), []), F = /* @__PURE__ */ n.jsx(g, { decorators: s, children: /* @__PURE__ */ n.jsx("div", { "aria-hidden": !a, style: {
|
|
100
|
+
"--max-width": r ? `${r}px` : void 0
|
|
101
|
+
}, className: T("kakadu-components-4119461136", a && "kakadu-components-2522346797", x), children: /* @__PURE__ */ n.jsx(g, { decorators: o, children: /* @__PURE__ */ n.jsx(H.FocusTrap, { active: a, focusTrapOptions: S, children: /* @__PURE__ */ n.jsx("div", { ref: y, className: "kakadu-components-4011815997", children: /* @__PURE__ */ n.jsx("div", { role: "dialog", "aria-modal": "true", "aria-label": k ?? "Modal", className: T("kakadu-components-3324483532", u && "kakadu-components-3799971070", a && "kakadu-components-968755580"), children: /* @__PURE__ */ n.jsxs(Q, { value: D, children: [
|
|
99
102
|
B ? /* @__PURE__ */ n.jsx(V, {}) : null,
|
|
100
|
-
/* @__PURE__ */ n.jsx("div", { className:
|
|
103
|
+
/* @__PURE__ */ n.jsx("div", { className: T("kakadu-components-633990035", u && "kakadu-components-171969824"), children: P })
|
|
101
104
|
] }) }) }) }) }) }) });
|
|
102
|
-
return
|
|
105
|
+
return c ? G(F, c) : F;
|
|
103
106
|
}
|
|
104
|
-
function
|
|
105
|
-
const [
|
|
106
|
-
|
|
107
|
-
})), []), t = m((
|
|
107
|
+
function se(c, s) {
|
|
108
|
+
const [o, k] = h(!1), r = j(void 0), x = m(async () => (k(!0), new Promise((i) => {
|
|
109
|
+
r.current = i;
|
|
110
|
+
})), []), t = m((i) => {
|
|
108
111
|
var l;
|
|
109
|
-
k(!1), (l =
|
|
110
|
-
}, []), u =
|
|
111
|
-
return
|
|
112
|
-
isVisible:
|
|
112
|
+
k(!1), (l = r.current) == null || l.call(r, i), r.current = void 0;
|
|
113
|
+
}, []), u = I(() => /* @__PURE__ */ n.jsx(c, { ...s, isVisible: o, onClose: t }), [c, s, o, t]);
|
|
114
|
+
return I(() => ({
|
|
115
|
+
isVisible: o,
|
|
113
116
|
show: x,
|
|
114
117
|
modal: u
|
|
115
|
-
}), [
|
|
118
|
+
}), [o, x, u]);
|
|
116
119
|
}
|
|
117
120
|
export {
|
|
118
121
|
ne as default,
|
|
119
|
-
|
|
122
|
+
se as useModal,
|
|
120
123
|
U as useModalContext
|
|
121
124
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../jsx-runtime-BB_1_6y_.js"),M=require("@kuma-ui/core"),a=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../jsx-runtime-BB_1_6y_.js"),M=require("@kuma-ui/core"),a=require("react"),q=require("../theme.js"),R=require("../icons/icon.js"),f=require("./popover.js"),P=require("./atom.js"),h=require("./text.js"),g=require("./hover-gradient.js"),I=require("./click-ripples.js"),N=require("./separator.js"),S=require("./decorators.js"),E=new Set;function y(){const[e,n]=a.useState(!1),r=a.useCallback(s=>{n(s);for(const i of E)i(s)},[]);return a.useEffect(()=>{const s=i=>{n(i)};return E.add(s),()=>{E.delete(s)}},[]),a.useMemo(()=>({isKeyboardNavigating:e,setIsKeyboardNavigating:r}),[e,r])}function _({label:e,iconLeft:n,iconRight:r,href:s,shouldCloseOnClick:i=!0,decorators:v=[],submenu:x,className:u,onClick:o,...j}){const{isVisible:l,isFocused:c,close:p}=f.usePopoverContext(),{isKeyboardNavigating:d}=y(),m=a.useCallback(w=>{c&&(o==null||o(w),x?x.show():i&&(p==null||p()))},[c,o,x,i,p]),k=a.useMemo(()=>t.jsxRuntimeExports.jsxs(P.default,{as:s?"a":"button",...j,type:s?void 0:"button",role:"menuitem",href:s,disabled:s?void 0:!l,className:M.cx(q.buttonResetStyles,"kakadu-components-3114599304",d?"kakadu-components-4096376656":"kakadu-components-2554182777",u),onClick:m,children:[t.jsxRuntimeExports.jsxs(h.Span,{className:"kakadu-components-1109353535",children:[n?t.jsxRuntimeExports.jsx(R.default,{width:12,height:12,type:n}):null,t.jsxRuntimeExports.jsx("span",{className:"kakadu-components-913703148",children:e}),r?t.jsxRuntimeExports.jsx(R.default,{width:12,height:12,type:r}):null]}),d?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(g.default,{size:150,className:g.normalBlendStyles}),t.jsxRuntimeExports.jsx(I.default,{size:100})]})]}),[s,j,l,d,u,m,n,e,r]);return t.jsxRuntimeExports.jsx(S.default,{decorators:v,children:x?t.jsxRuntimeExports.jsx(b,{menu:x.popoverMenu,className:"kakadu-components-1861176543",children:k}):k})}function K(e){if("type"in e){if(e.type==="separator")return t.jsxRuntimeExports.jsx(N.default,{});if(e.type==="group")return t.jsxRuntimeExports.jsx(h.Span,{className:"kakadu-components-1499037363",children:e.label})}return t.jsxRuntimeExports.jsx(_,{...e})}function C({items:e}){const{isFocused:n}=f.usePopoverContext(),[r,s]=a.useState([]),{setIsKeyboardNavigating:i}=y(),v=a.useCallback(u=>{u&&s(o=>o.includes(u)?o:[...o,u])},[]),x=a.useCallback(u=>{n&&(u.currentTarget.focus(),i(!1))},[n,i]);return a.useEffect(()=>{if(!n)return;const u=o=>{const j=r.filter(m=>m.isConnected),l=j.length;if(l===0)return;let c;const p=document.activeElement;let d=p?j.indexOf(p):-1;switch(d===-1&&(d=0),o.key){case"ArrowDown":{c=(d+1)%l;break}case"ArrowUp":{c=(d-1+l)%l;break}case"Home":{c=0;break}case"End":{c=l-1;break}}if(c!==void 0){o.preventDefault(),o.stopPropagation();const m=j[c];m&&(m.focus(),i(!0))}};return window.addEventListener("keydown",u,{capture:!0}),()=>{window.removeEventListener("keydown",u,{capture:!0})}},[n,r,i]),t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:e.map((u,o)=>t.jsxRuntimeExports.jsx(K,{...u,reference:v,onMouseEnter:x},o))})}function F({items:e,...n}){return t.jsxRuntimeExports.jsx(f.default,{...n,as:"nav",role:"menu",innerClassName:"kakadu-components-3600436535",children:t.jsxRuntimeExports.jsx(C,{items:e})})}function z(e){const n=a.useMemo(()=>({items:e}),[e]),{show:r,popover:s}=f.usePopover(F,n);return a.useMemo(()=>({show:r,popoverMenu:s}),[r,s])}function b({menu:e,className:n,children:r}){return t.jsxRuntimeExports.jsxs(f.PopoverContainer,{className:n,children:[r,e]})}exports.default=b;exports.usePopoverMenu=z;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { j as n } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
-
import { cx as
|
|
3
|
-
import { useMemo as v, useState as
|
|
4
|
-
import { buttonResetStyles as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { Span as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
2
|
+
import { cx as M } from "@kuma-ui/core";
|
|
3
|
+
import { useMemo as v, useState as y, useCallback as x, useEffect as w } from "react";
|
|
4
|
+
import { buttonResetStyles as E } from "../theme.mjs";
|
|
5
|
+
import h from "../icons/icon.mjs";
|
|
6
|
+
import S, { PopoverContainer as K, usePopover as F, usePopoverContext as I } from "./popover.mjs";
|
|
7
|
+
import A from "./atom.mjs";
|
|
8
|
+
import { Span as b } from "./text.mjs";
|
|
9
|
+
import D, { normalBlendStyles as H } from "./hover-gradient.mjs";
|
|
10
|
+
import z from "./click-ripples.mjs";
|
|
11
|
+
import C from "./separator.mjs";
|
|
12
|
+
import L from "./decorators.mjs";
|
|
13
13
|
const j = /* @__PURE__ */ new Set();
|
|
14
14
|
function N() {
|
|
15
|
-
const [e, t] =
|
|
15
|
+
const [e, t] = y(!1), s = x((o) => {
|
|
16
16
|
t(o);
|
|
17
17
|
for (const i of j)
|
|
18
18
|
i(o);
|
|
19
19
|
}, []);
|
|
20
|
-
return
|
|
20
|
+
return w(() => {
|
|
21
21
|
const o = (i) => {
|
|
22
22
|
t(i);
|
|
23
23
|
};
|
|
@@ -29,76 +29,77 @@ function N() {
|
|
|
29
29
|
setIsKeyboardNavigating: s
|
|
30
30
|
}), [e, s]);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function R({
|
|
33
33
|
label: e,
|
|
34
34
|
iconLeft: t,
|
|
35
35
|
iconRight: s,
|
|
36
36
|
href: o,
|
|
37
37
|
shouldCloseOnClick: i = !0,
|
|
38
38
|
decorators: k = [],
|
|
39
|
-
submenu:
|
|
39
|
+
submenu: m,
|
|
40
40
|
className: a,
|
|
41
41
|
onClick: r,
|
|
42
|
-
...
|
|
42
|
+
...f
|
|
43
43
|
}) {
|
|
44
44
|
const {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
isVisible: u,
|
|
46
|
+
isFocused: c,
|
|
47
|
+
close: l
|
|
48
|
+
} = I(), {
|
|
49
|
+
isKeyboardNavigating: d
|
|
50
|
+
} = N(), p = x((P) => {
|
|
51
|
+
c && (r == null || r(P), m ? m.show() : i && (l == null || l()));
|
|
52
|
+
}, [c, r, m, i, l]), g = v(() => /* @__PURE__ */ n.jsxs(A, { as: o ? "a" : "button", ...f, type: o ? void 0 : "button", role: "menuitem", href: o, disabled: o ? void 0 : !u, className: M(E, "kakadu-components-3114599304", d ? "kakadu-components-4096376656" : "kakadu-components-2554182777", a), onClick: p, children: [
|
|
53
|
+
/* @__PURE__ */ n.jsxs(b, { className: "kakadu-components-1109353535", children: [
|
|
54
|
+
t ? /* @__PURE__ */ n.jsx(h, { width: 12, height: 12, type: t }) : null,
|
|
54
55
|
/* @__PURE__ */ n.jsx("span", { className: "kakadu-components-913703148", children: e }),
|
|
55
|
-
s ? /* @__PURE__ */ n.jsx(
|
|
56
|
+
s ? /* @__PURE__ */ n.jsx(h, { width: 12, height: 12, type: s }) : null
|
|
56
57
|
] }),
|
|
57
|
-
|
|
58
|
-
/* @__PURE__ */ n.jsx(
|
|
59
|
-
/* @__PURE__ */ n.jsx(
|
|
58
|
+
d ? null : /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
|
|
59
|
+
/* @__PURE__ */ n.jsx(D, { size: 150, className: H }),
|
|
60
|
+
/* @__PURE__ */ n.jsx(z, { size: 100 })
|
|
60
61
|
] })
|
|
61
|
-
] }), [f,
|
|
62
|
-
return /* @__PURE__ */ n.jsx(
|
|
62
|
+
] }), [o, f, u, d, a, p, t, e, s]);
|
|
63
|
+
return /* @__PURE__ */ n.jsx(L, { decorators: k, children: m ? /* @__PURE__ */ n.jsx(U, { menu: m.popoverMenu, className: "kakadu-components-1861176543", children: g }) : g });
|
|
63
64
|
}
|
|
64
|
-
function
|
|
65
|
+
function B(e) {
|
|
65
66
|
if ("type" in e) {
|
|
66
67
|
if (e.type === "separator")
|
|
67
|
-
return /* @__PURE__ */ n.jsx(
|
|
68
|
+
return /* @__PURE__ */ n.jsx(C, {});
|
|
68
69
|
if (e.type === "group")
|
|
69
|
-
return /* @__PURE__ */ n.jsx(
|
|
70
|
+
return /* @__PURE__ */ n.jsx(b, { className: "kakadu-components-1499037363", children: e.label });
|
|
70
71
|
}
|
|
71
|
-
return /* @__PURE__ */ n.jsx(
|
|
72
|
+
return /* @__PURE__ */ n.jsx(R, { ...e });
|
|
72
73
|
}
|
|
73
|
-
function
|
|
74
|
+
function G({
|
|
74
75
|
items: e
|
|
75
76
|
}) {
|
|
76
77
|
const {
|
|
77
78
|
isFocused: t
|
|
78
|
-
} =
|
|
79
|
+
} = I(), [s, o] = y([]), {
|
|
79
80
|
setIsKeyboardNavigating: i
|
|
80
81
|
} = N(), k = x((a) => {
|
|
81
82
|
a && o((r) => r.includes(a) ? r : [...r, a]);
|
|
82
|
-
}, []),
|
|
83
|
+
}, []), m = x((a) => {
|
|
83
84
|
t && (a.currentTarget.focus(), i(!1));
|
|
84
85
|
}, [t, i]);
|
|
85
|
-
return
|
|
86
|
+
return w(() => {
|
|
86
87
|
if (!t)
|
|
87
88
|
return;
|
|
88
89
|
const a = (r) => {
|
|
89
|
-
const
|
|
90
|
+
const f = s.filter((p) => p.isConnected), u = f.length;
|
|
90
91
|
if (u === 0)
|
|
91
92
|
return;
|
|
92
93
|
let c;
|
|
93
|
-
const
|
|
94
|
-
let
|
|
95
|
-
switch (
|
|
94
|
+
const l = document.activeElement;
|
|
95
|
+
let d = l ? f.indexOf(l) : -1;
|
|
96
|
+
switch (d === -1 && (d = 0), r.key) {
|
|
96
97
|
case "ArrowDown": {
|
|
97
|
-
c = (
|
|
98
|
+
c = (d + 1) % u;
|
|
98
99
|
break;
|
|
99
100
|
}
|
|
100
101
|
case "ArrowUp": {
|
|
101
|
-
c = (
|
|
102
|
+
c = (d - 1 + u) % u;
|
|
102
103
|
break;
|
|
103
104
|
}
|
|
104
105
|
case "Home": {
|
|
@@ -112,8 +113,8 @@ function B({
|
|
|
112
113
|
}
|
|
113
114
|
if (c !== void 0) {
|
|
114
115
|
r.preventDefault(), r.stopPropagation();
|
|
115
|
-
const
|
|
116
|
-
|
|
116
|
+
const p = f[c];
|
|
117
|
+
p && (p.focus(), i(!0));
|
|
117
118
|
}
|
|
118
119
|
};
|
|
119
120
|
return window.addEventListener("keydown", a, {
|
|
@@ -124,44 +125,44 @@ function B({
|
|
|
124
125
|
});
|
|
125
126
|
};
|
|
126
127
|
}, [t, s, i]), /* @__PURE__ */ n.jsx(n.Fragment, { children: e.map((a, r) => /* @__PURE__ */ n.jsx(
|
|
127
|
-
|
|
128
|
+
B,
|
|
128
129
|
{
|
|
129
130
|
...a,
|
|
130
131
|
reference: k,
|
|
131
|
-
onMouseEnter:
|
|
132
|
+
onMouseEnter: m
|
|
132
133
|
},
|
|
133
134
|
r
|
|
134
135
|
)) });
|
|
135
136
|
}
|
|
136
|
-
function
|
|
137
|
+
function T({
|
|
137
138
|
items: e,
|
|
138
139
|
...t
|
|
139
140
|
}) {
|
|
140
|
-
return /* @__PURE__ */ n.jsx(
|
|
141
|
+
return /* @__PURE__ */ n.jsx(S, { ...t, as: "nav", role: "menu", innerClassName: "kakadu-components-3600436535", children: /* @__PURE__ */ n.jsx(G, { items: e }) });
|
|
141
142
|
}
|
|
142
|
-
function
|
|
143
|
+
function ne(e) {
|
|
143
144
|
const t = v(() => ({
|
|
144
145
|
items: e
|
|
145
146
|
}), [e]), {
|
|
146
147
|
show: s,
|
|
147
148
|
popover: o
|
|
148
|
-
} =
|
|
149
|
+
} = F(T, t);
|
|
149
150
|
return v(() => ({
|
|
150
151
|
show: s,
|
|
151
152
|
popoverMenu: o
|
|
152
153
|
}), [s, o]);
|
|
153
154
|
}
|
|
154
|
-
function
|
|
155
|
+
function U({
|
|
155
156
|
menu: e,
|
|
156
157
|
className: t,
|
|
157
158
|
children: s
|
|
158
159
|
}) {
|
|
159
|
-
return /* @__PURE__ */ n.jsxs(
|
|
160
|
+
return /* @__PURE__ */ n.jsxs(K, { className: t, children: [
|
|
160
161
|
s,
|
|
161
162
|
e
|
|
162
163
|
] });
|
|
163
164
|
}
|
|
164
165
|
export {
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
U as default,
|
|
167
|
+
ne as usePopoverMenu
|
|
167
168
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../jsx-runtime-BB_1_6y_.js"),l=require("@kuma-ui/core"),e=require("react"),H=require("../focus-trap-react-CcpTuiJi.js"),g=require("./atom.js"),z=e.createContext({isVisible:!1,isFocused:!1}),{Provider:U}=z;function G(){return e.useContext(z)}function J({as:r,className:s,...o}){return n.jsxRuntimeExports.jsx(g.default,{as:r??g.defaultAtomElementType,...o,className:l.cx("kakadu-components-2845019685",s)})}function K({as:r,isVisible:s,label:o,shouldCloseOnOutsideClick:f=!0,shouldCloseOnEscapePress:c=!0,children:m,className:p,innerClassName:x,onClose:a,...v}){const b=e.useRef(null),F=e.useRef(null),[I,k]=e.useState(!1),[S,B]=e.useState(!1),[u,R]=e.useState(!1),C=e.useCallback(t=>{b.current=t,R(!1)},[]),j=e.useRef(null),M=e.useCallback(t=>{t&&(j.current=t)},[]),W=e.useMemo(()=>({initialFocus:()=>j.current??void 0,onActivate(){var t;(t=j.current)==null||t.focus()
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../jsx-runtime-BB_1_6y_.js"),l=require("@kuma-ui/core"),e=require("react"),H=require("../focus-trap-react-CcpTuiJi.js"),g=require("./atom.js"),z=e.createContext({isVisible:!1,isFocused:!1}),{Provider:U}=z;function G(){return e.useContext(z)}function J({as:r,className:s,...o}){return n.jsxRuntimeExports.jsx(g.default,{as:r??g.defaultAtomElementType,...o,className:l.cx("kakadu-components-2845019685",s)})}function K({as:r,isVisible:s,label:o,shouldCloseOnOutsideClick:f=!0,shouldCloseOnEscapePress:c=!0,children:m,className:p,innerClassName:x,onClose:a,...v}){const b=e.useRef(null),F=e.useRef(null),[I,k]=e.useState(!1),[S,B]=e.useState(!1),[u,R]=e.useState(!1),C=e.useCallback(t=>{b.current=t,R(!1)},[]),j=e.useRef(null),M=e.useCallback(t=>{t&&(j.current=t)},[]),W=e.useMemo(()=>({initialFocus:()=>j.current??void 0,onActivate(){var t;k(!0),(t=j.current)==null||t.focus()},clickOutsideDeactivates:f,escapeDeactivates:c,onUnpause(){k(!0)},onPause(){k(!1)},onDeactivate(){R(!1),k(!1)}}),[f,c]),[q,N]=e.useState(s??!1),$=e.useMemo(()=>({isVisible:q,isFocused:I,setInitialFocus:M,close:C}),[q,I,M,C]),[i,L]=e.useState("center");return e.useEffect(()=>{const t=F.current;if(t){const w=()=>{const O=t.offsetParent,E=O instanceof HTMLElement?O.getBoundingClientRect():null,y=t.getBoundingClientRect();if(!E){L("center");return}const P=16,D=window.innerWidth-P,T=E.left+E.width/2-y.width/2,V=T+y.width,A=T<P,_=V>D;let d="center";if(A&&_){const h=P-T;d=V-D>h?"right":"left"}else _?d="right":A&&(d="left");L(h=>h===d?h:d)};return w(),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w)}}},[]),e.useEffect(()=>{s&&(B(!0),N(!0))},[s]),e.useEffect(()=>{if(s){const t=setTimeout(()=>{R(!0)},100);return()=>{clearTimeout(t)}}R(!1)},[s]),e.useEffect(()=>{if(S&&!u){const t=setTimeout(()=>{a==null||a(b.current??void 0),N(!1)},370);return()=>{clearTimeout(t)}}},[S,u,a]),n.jsxRuntimeExports.jsx(g.default,{reference:F,as:r??g.defaultAtomElementType,role:"dialog","aria-hidden":!u,"aria-label":o??"Popover",...v,className:l.cx("kakadu-components-3920007758",i==="left"&&"kakadu-components-611400930",i==="right"&&"kakadu-components-944244368",u&&"kakadu-components-1399012551",p),children:n.jsxRuntimeExports.jsxs("div",{className:l.cx("kakadu-components-1118152266",u&&"kakadu-components-231244945"),children:[n.jsxRuntimeExports.jsx("div",{className:l.cx("kakadu-components-1951789226",i==="left"&&"kakadu-components-1495725644",i==="right"&&"kakadu-components-4235689197")}),n.jsxRuntimeExports.jsx(H.focusTrapReactExports.FocusTrap,{active:u,focusTrapOptions:W,children:n.jsxRuntimeExports.jsxs("div",{className:l.cx("kakadu-components-2488426662",x),children:[n.jsxRuntimeExports.jsx(U,{value:$,children:m}),n.jsxRuntimeExports.jsx("div",{className:l.cx("kakadu-components-3252390100",i==="left"&&"kakadu-components-3754561431",i==="right"&&"kakadu-components-2265262600")})]})})]})})}function Q(r,s){const[o,f]=e.useState(!1),c=e.useRef(void 0),m=e.useCallback(async()=>(f(!0),new Promise(a=>{c.current=a})),[]),p=e.useCallback(a=>{var v;f(!1),(v=c.current)==null||v.call(c,a),c.current=void 0},[]),x=e.useMemo(()=>n.jsxRuntimeExports.jsx(r,{...s,isVisible:o,onClose:p}),[r,s,o,p]);return e.useMemo(()=>({isVisible:o,show:m,popover:x}),[o,m,x])}exports.PopoverContainer=J;exports.default=K;exports.usePopover=Q;exports.usePopoverContext=G;
|
package/build/hooks/use-fetch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react"),b=new Map,C=new Map,y=new Map;function j(e,s){let t=y.get(e);return t||(t=new Set,y.set(e,t)),t.add(s),()=>{t==null||t.delete(s),t&&t.size===0&&y.delete(e)}}function q(e,s){C.set(e,{timestamp:Date.now(),response:s});const t=y.get(e);if(t)for(const r of t)r(s)}function L(e){const[s,t]=n.useState(!1),[r,l]=n.useState(),[d,h]=n.useState(),g=n.useCallback(async(v,o)=>{try{h(void 0),t(!0);const a=await fetch(v,o),u=e?await e(a):a;return l(u),u}catch(a){const u=a instanceof Error?a:new Error("Unknown error");throw h(u),u}finally{t(!1)}},[e]);return n.useMemo(()=>({isLoading:s,fetch:g,response:r,error:d}),[s,g,r,d])}function J(e){const s=n.useCallback(async t=>{const r=await t.json();return e?e(r):r},[e]);return L(s)}function p(e,s,t,r){const{cacheLifetime:l=1e3*60}=r??{},[d,h]=n.useState(0),[g,v]=n.useState(()=>!!e),o=n.useMemo(()=>e?JSON.stringify({url:e,options:s}):"",[e,s]),a=n.useCallback(()=>{if(!o)return;const c=C.get(o);if(c){if(Date.now()-c.timestamp>l){C.delete(o);return}return c.response}},[o,l]),[u,w]=n.useState(()=>a()),[M,m]=n.useState(),S=n.useMemo(()=>{var c;return((c=s==null?void 0:s.method)==null?void 0:c.toUpperCase())??"GET"},[s]);return n.useEffect(()=>{if(S!=="GET")return;const c=()=>{document.hidden||h(f=>f+1)};return document.addEventListener("visibilitychange",c),()=>{document.removeEventListener("visibilitychange",c)}},[S]),n.useEffect(()=>{if(!e||!o){w(void 0);return}const c=a();c===void 0?(w(void 0),m(void 0)):(w(c),m(void 0));const f=j(o,E=>{w(E),m(void 0)});return()=>{f()}},[e,o,a]),n.useEffect(()=>{if(!e||!o){v(!1);return}if(d<0)return;const c=S==="GET";if(c&&a()!==void 0){v(!1);return}let f=!0;m(void 0),v(!0);let E=c&&b.has(o)?b.get(o):void 0;if(!E){const i=fetch(e,s);b.set(o,i),i.then(()=>{b.delete(o)}),E=i}return E.then(async i=>{if(f){const F=t?await t(i):i;c&&q(o,F),w(F),m(void 0)}}).catch(i=>{f&&m(i)}).finally(()=>{f&&v(!1)}),()=>{f=!1}},[e,
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react"),b=new Map,C=new Map,y=new Map;function j(e,s){let t=y.get(e);return t||(t=new Set,y.set(e,t)),t.add(s),()=>{t==null||t.delete(s),t&&t.size===0&&y.delete(e)}}function q(e,s){C.set(e,{timestamp:Date.now(),response:s});const t=y.get(e);if(t)for(const r of t)r(s)}function L(e){const[s,t]=n.useState(!1),[r,l]=n.useState(),[d,h]=n.useState(),g=n.useCallback(async(v,o)=>{try{h(void 0),t(!0);const a=await fetch(v,o),u=e?await e(a):a;return l(u),u}catch(a){const u=a instanceof Error?a:new Error("Unknown error");throw h(u),u}finally{t(!1)}},[e]);return n.useMemo(()=>({isLoading:s,fetch:g,response:r,error:d}),[s,g,r,d])}function J(e){const s=n.useCallback(async t=>{const r=await t.json();return e?e(r):r},[e]);return L(s)}function p(e,s,t,r){const{cacheLifetime:l=1e3*60}=r??{},[d,h]=n.useState(0),[g,v]=n.useState(()=>!!e),o=n.useMemo(()=>e?JSON.stringify({url:e,options:s}):"",[e,s]),a=n.useCallback(()=>{if(!o)return;const c=C.get(o);if(c){if(Date.now()-c.timestamp>l){C.delete(o);return}return c.response}},[o,l]),[u,w]=n.useState(()=>a()),[M,m]=n.useState(),S=n.useMemo(()=>{var c;return((c=s==null?void 0:s.method)==null?void 0:c.toUpperCase())??"GET"},[s]);return n.useEffect(()=>{if(S!=="GET")return;const c=()=>{document.hidden||h(f=>f+1)};return document.addEventListener("visibilitychange",c),()=>{document.removeEventListener("visibilitychange",c)}},[S]),n.useEffect(()=>{if(!e||!o){w(void 0);return}const c=a();c===void 0?(w(void 0),m(void 0)):(w(c),m(void 0));const f=j(o,E=>{w(E),m(void 0)});return()=>{f()}},[e,o,a]),n.useEffect(()=>{if(!e||!o){v(!1);return}if(d<0)return;const c=S==="GET";if(c&&a()!==void 0){v(!1);return}let f=!0;m(void 0),v(!0);let E=c&&b.has(o)?b.get(o):void 0;if(!E){const i=fetch(e,s);b.set(o,i),i.then(()=>{b.delete(o)}),E=i}return E.then(async i=>{if(f){const F=t?await t(i):i;c&&q(o,F),w(F),m(void 0)}}).catch(i=>{f&&m(i)}).finally(()=>{f&&v(!1)}),()=>{f=!1}},[e,o,d,S,a,s,t]),n.useMemo(()=>({isLoading:g,response:u,error:M}),[g,u,M])}function k(e,s,t,r){const l=n.useCallback(async d=>{const h=await d.json();return t?t(h):h},[t]);return p(e,s,l,r)}exports.default=p;exports.useFetcher=L;exports.useJsonFetch=k;exports.useJsonFetcher=J;
|