@kakadu/components 6.1.1 → 6.3.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/build/components/aria-text.d.ts +2 -1
- package/build/components/box.d.ts +2 -1
- package/build/components/button-tooltip.d.ts +2 -1
- package/build/components/button.d.ts +3 -3
- package/build/components/button.js +1 -1
- package/build/components/button.mjs +27 -25
- package/build/components/card.d.ts +2 -2
- package/build/components/click-ripples.d.ts +2 -2
- package/build/components/click-ripples.js +1 -1
- package/build/components/click-ripples.mjs +50 -45
- package/build/components/collapsible.d.ts +2 -2
- package/build/components/combobox.d.ts +2 -2
- package/build/components/combobox.js +1 -1
- package/build/components/combobox.mjs +161 -159
- package/build/components/copy-icon-button.d.ts +2 -1
- package/build/components/datum.d.ts +2 -2
- package/build/components/dot.d.ts +2 -2
- package/build/components/flex.d.ts +2 -1
- package/build/components/footer.d.ts +2 -2
- package/build/components/gauge.d.ts +2 -1
- package/build/components/header.d.ts +2 -1
- package/build/components/hover-gradient.d.ts +2 -2
- package/build/components/hover-gradient.js +1 -1
- package/build/components/hover-gradient.mjs +48 -35
- package/build/components/icon-button.d.ts +2 -2
- package/build/components/input.d.ts +3 -3
- package/build/components/input.js +2 -2
- package/build/components/input.mjs +21 -21
- package/build/components/logos/akt-logo.d.ts +2 -2
- package/build/components/logos/amedia-logo.d.ts +2 -2
- package/build/components/logos/bankaxept-logo.d.ts +2 -2
- package/build/components/logos/bankid-logo.d.ts +2 -2
- package/build/components/logos/dnb-logo.d.ts +2 -2
- package/build/components/logos/entur-logo.d.ts +2 -2
- package/build/components/logos/gjensidige-logo.d.ts +2 -2
- package/build/components/logos/kakadu-academy-logo.d.ts +2 -2
- package/build/components/logos/kakadu-guide-icon.d.ts +2 -1
- package/build/components/logos/kakadu-guide-logo.d.ts +3 -3
- package/build/components/logos/kakadu-index-logo.d.ts +2 -2
- package/build/components/logos/kakadu-logo.d.ts +2 -2
- package/build/components/logos/kakadu-play-logo.d.ts +2 -2
- package/build/components/logos/kolumbus-logo.d.ts +2 -2
- package/build/components/logos/nordea-logo.d.ts +2 -2
- package/build/components/logos/norsk-tipping-logo.d.ts +2 -2
- package/build/components/logos/ruter-logo.d.ts +2 -2
- package/build/components/logos/senteret-for-et-aldersvennlig-norge-logo.d.ts +2 -2
- package/build/components/logos/sparebank1-logo.d.ts +2 -2
- package/build/components/logos/sparebanken-norge-logo.d.ts +2 -2
- package/build/components/logos/sto-logo.d.ts +2 -2
- package/build/components/logos/storebrand-logo.d.ts +2 -2
- package/build/components/modal.d.ts +6 -6
- package/build/components/modal.js +1 -1
- package/build/components/modal.mjs +86 -85
- package/build/components/moving-gradients.js +1 -1
- package/build/components/moving-gradients.mjs +80 -70
- package/build/components/moving-stars.js +1 -1
- package/build/components/moving-stars.mjs +77 -74
- package/build/components/notice.d.ts +2 -2
- package/build/components/notification.d.ts +8 -6
- package/build/components/notification.js +1 -1
- package/build/components/notification.mjs +87 -71
- package/build/components/popover-menu.d.ts +3 -3
- package/build/components/popover-menu.js +1 -1
- package/build/components/popover-menu.mjs +131 -129
- package/build/components/popover.d.ts +4 -4
- package/build/components/popover.js +1 -1
- package/build/components/popover.mjs +82 -73
- package/build/components/revealer.d.ts +2 -2
- package/build/components/select.d.ts +2 -2
- package/build/components/separator.d.ts +5 -5
- package/build/components/skeleton.d.ts +3 -2
- package/build/components/spinner.d.ts +3 -2
- package/build/components/text-button.d.ts +2 -2
- package/build/components/text.d.ts +9 -8
- package/build/components/theme-setter.d.ts +2 -2
- package/build/components/veil.d.ts +2 -1
- package/build/components/wrapper.d.ts +2 -2
- package/build/components.css +1 -1
- package/build/hooks/use-is-document-focused.js +1 -1
- package/build/hooks/use-is-document-focused.mjs +30 -14
- package/build/icons/anchor-down.d.ts +2 -2
- package/build/icons/anchor-up.d.ts +2 -2
- package/build/icons/arrow-down.d.ts +2 -2
- package/build/icons/arrow-left.d.ts +2 -2
- package/build/icons/arrow-right.d.ts +2 -2
- package/build/icons/arrow-up.d.ts +2 -2
- package/build/icons/caret-down.d.ts +2 -2
- package/build/icons/caret-left.d.ts +2 -2
- package/build/icons/caret-right.d.ts +2 -2
- package/build/icons/caret-up.d.ts +2 -2
- package/build/icons/check.d.ts +2 -2
- package/build/icons/chevron-down.d.ts +2 -2
- package/build/icons/chevron-left.d.ts +2 -2
- package/build/icons/chevron-right.d.ts +2 -2
- package/build/icons/chevron-up.d.ts +2 -2
- package/build/icons/chrome-browser-logo.d.ts +2 -2
- package/build/icons/cog.d.ts +2 -2
- package/build/icons/copy.d.ts +2 -2
- package/build/icons/document.d.ts +2 -2
- package/build/icons/dots.d.ts +2 -2
- package/build/icons/drag.d.ts +2 -2
- package/build/icons/edge-browser-logo.d.ts +2 -2
- package/build/icons/edit.d.ts +2 -2
- package/build/icons/exclamation-triangle.d.ts +2 -2
- package/build/icons/external.d.ts +2 -2
- package/build/icons/eye.d.ts +2 -2
- package/build/icons/icon.d.ts +2 -2
- package/build/icons/information.d.ts +2 -2
- package/build/icons/kakadu-guide-glyph.d.ts +2 -2
- package/build/icons/kakadu-guide-icon.d.ts +2 -2
- package/build/icons/menu.d.ts +2 -2
- package/build/icons/package.d.ts +2 -2
- package/build/icons/plus.d.ts +2 -2
- package/build/icons/select.d.ts +2 -2
- package/build/icons/share.d.ts +2 -2
- package/build/icons/sparkle.d.ts +2 -2
- package/build/icons/test.d.ts +2 -2
- package/build/icons/times.d.ts +2 -2
- package/build/icons/trash.d.ts +2 -2
- package/build/icons/trend-up.d.ts +2 -2
- package/build/index.d.ts +2 -0
- package/build/index.js +1 -1
- package/build/index.mjs +19 -17
- package/build/theme.d.ts +2 -1
- package/build/utilities/listeners.d.ts +5 -0
- package/build/utilities/listeners.js +1 -0
- package/build/utilities/listeners.mjs +16 -0
- package/package.json +16 -22
|
@@ -1,97 +1,113 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { cx as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { noticeTypes as
|
|
7
|
-
function
|
|
8
|
-
type:
|
|
9
|
-
icon:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { j as u } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
+
import { createContext as H, useState as d, useEffect as m, useRef as E, useCallback as k, useContext as L, useMemo as I } from "react";
|
|
3
|
+
import { cx as j } from "@kuma-ui/core";
|
|
4
|
+
import S from "../utilities/generate-random-id.mjs";
|
|
5
|
+
import V from "./notice.mjs";
|
|
6
|
+
import { noticeTypes as Q } from "./notice.mjs";
|
|
7
|
+
function B({
|
|
8
|
+
type: i,
|
|
9
|
+
icon: N,
|
|
10
|
+
id: a,
|
|
11
|
+
index: l,
|
|
12
|
+
shouldDismiss: s,
|
|
13
|
+
className: v,
|
|
14
|
+
children: T,
|
|
15
|
+
onDismiss: c,
|
|
16
|
+
...o
|
|
15
17
|
}) {
|
|
16
|
-
const [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const [e, r] = d(!1), [t, p] = d(!1), [n, x] = d(!1), h = l ?? 0, [b, g] = d(h);
|
|
19
|
+
m(() => {
|
|
20
|
+
if (s || t)
|
|
21
|
+
return;
|
|
22
|
+
const f = setTimeout(() => {
|
|
23
|
+
r(!0);
|
|
24
|
+
}, 100);
|
|
21
25
|
return () => {
|
|
22
|
-
clearTimeout(
|
|
26
|
+
clearTimeout(f);
|
|
23
27
|
};
|
|
28
|
+
}, [s, t]);
|
|
29
|
+
const C = E(0), w = E(0), y = k(() => {
|
|
30
|
+
x(!0);
|
|
31
|
+
}, []), P = k(() => {
|
|
32
|
+
x(!1);
|
|
24
33
|
}, []);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
v(!1);
|
|
29
|
-
}, []);
|
|
30
|
-
x(() => {
|
|
31
|
-
if (p) {
|
|
32
|
-
h.current += Date.now() - T.current;
|
|
34
|
+
return m(() => {
|
|
35
|
+
if (n) {
|
|
36
|
+
w.current += Date.now() - C.current;
|
|
33
37
|
return;
|
|
34
38
|
}
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
},
|
|
39
|
+
if (e) {
|
|
40
|
+
C.current = Date.now();
|
|
41
|
+
const f = 6e3 - w.current, R = setTimeout(() => {
|
|
42
|
+
r(!1), p(!0);
|
|
43
|
+
}, f);
|
|
40
44
|
return () => {
|
|
41
|
-
clearTimeout(
|
|
45
|
+
clearTimeout(R);
|
|
42
46
|
};
|
|
43
47
|
}
|
|
44
|
-
}, [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
}, [n, e]), m(() => {
|
|
49
|
+
s && !t && (r(!1), p(!0));
|
|
50
|
+
}, [s, t]), m(() => {
|
|
51
|
+
if (t && !e) {
|
|
52
|
+
const f = setTimeout(() => {
|
|
53
|
+
a && (c == null || c(a));
|
|
50
54
|
}, 300);
|
|
51
55
|
return () => {
|
|
52
|
-
clearTimeout(
|
|
56
|
+
clearTimeout(f);
|
|
53
57
|
};
|
|
54
58
|
}
|
|
55
|
-
}, [
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
}, [t, e, a, c]), m(() => {
|
|
60
|
+
n || g(h);
|
|
61
|
+
}, [n, h]), /* @__PURE__ */ u.jsx("div", { ...o, style: {
|
|
62
|
+
"--index": b
|
|
63
|
+
}, className: j("kakadu-components-1727618227", e && "kakadu-components-3003995416", v), children: /* @__PURE__ */ u.jsxs(V, { role: "status", "aria-live": "polite", "aria-atomic": "true", type: i, icon: N, className: j("kakadu-components-3951461646", e && "kakadu-components-2837603142"), onMouseEnter: y, onMouseLeave: P, children: [
|
|
64
|
+
T,
|
|
65
|
+
/* @__PURE__ */ u.jsx("div", { className: "kakadu-components-2751825161", children: /* @__PURE__ */ u.jsx("div", { className: j("kakadu-components-4050948330", n ? "kakadu-components-758522476" : "kakadu-components-3914681513") }) })
|
|
60
66
|
] }) });
|
|
61
67
|
}
|
|
62
|
-
const
|
|
68
|
+
const M = H({
|
|
63
69
|
createNotification() {
|
|
64
70
|
throw new Error("useCreateNotification must be used within a NotificationProvider");
|
|
65
71
|
}
|
|
66
72
|
});
|
|
67
|
-
function
|
|
73
|
+
function G() {
|
|
68
74
|
const {
|
|
69
|
-
createNotification:
|
|
70
|
-
} =
|
|
71
|
-
return
|
|
75
|
+
createNotification: i
|
|
76
|
+
} = L(M);
|
|
77
|
+
return i;
|
|
72
78
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
79
|
+
function J({
|
|
80
|
+
limit: i = 5,
|
|
81
|
+
children: N
|
|
75
82
|
}) {
|
|
76
|
-
const [
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
...
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
const [a, l] = d([]), s = k((o) => {
|
|
84
|
+
const e = S();
|
|
85
|
+
l((r) => {
|
|
86
|
+
const t = [...r, {
|
|
87
|
+
...o,
|
|
88
|
+
id: e
|
|
89
|
+
}];
|
|
90
|
+
if (t.length <= i)
|
|
91
|
+
return t;
|
|
92
|
+
const p = t.length - i;
|
|
93
|
+
return t.map((n, x) => x < p ? {
|
|
94
|
+
...n,
|
|
95
|
+
shouldDismiss: !0
|
|
96
|
+
} : n);
|
|
97
|
+
});
|
|
98
|
+
}, [i]), v = k((o) => {
|
|
99
|
+
l((e) => e.filter((r) => r.id !== o));
|
|
100
|
+
}, []), T = I(() => ({
|
|
101
|
+
createNotification: s
|
|
102
|
+
}), [s]), c = I(() => [...a].reverse(), [a]);
|
|
103
|
+
return /* @__PURE__ */ u.jsxs(M.Provider, { value: T, children: [
|
|
104
|
+
N,
|
|
105
|
+
c.map((o, e) => /* @__PURE__ */ u.jsx(B, { ...o, index: e, onDismiss: v }, o.id))
|
|
90
106
|
] });
|
|
91
107
|
}
|
|
92
108
|
export {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
109
|
+
J as NotificationProvider,
|
|
110
|
+
B as default,
|
|
111
|
+
Q as notificationTypes,
|
|
112
|
+
G as useCreateNotification
|
|
97
113
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type HTMLAttributeAnchorTarget, type MouseEvent, type ReactNode, type Ref } from 'react';
|
|
1
|
+
import React, { type HTMLAttributeAnchorTarget, type MouseEvent, type ReactNode, type Ref } from 'react';
|
|
2
2
|
import { type IconType } from '../icons/icon';
|
|
3
3
|
import { type DecoratorType } from './decorators';
|
|
4
4
|
export declare const dangerPopoverMenuItemStyles: string;
|
|
@@ -28,12 +28,12 @@ export declare function usePopoverMenu(items: PopoverMenuItemProperties[]): {
|
|
|
28
28
|
isVisible: boolean;
|
|
29
29
|
show: () => Promise<void | undefined>;
|
|
30
30
|
close: (result?: void | undefined) => void;
|
|
31
|
-
popoverMenu:
|
|
31
|
+
popoverMenu: React.JSX.Element | null;
|
|
32
32
|
};
|
|
33
33
|
export type PopoverMenuProperties = {
|
|
34
34
|
readonly menu: ReactNode;
|
|
35
35
|
readonly className?: string;
|
|
36
36
|
readonly children?: ReactNode;
|
|
37
37
|
};
|
|
38
|
-
export default function PopoverMenu({ menu, className, children, }: PopoverMenuProperties):
|
|
38
|
+
export default function PopoverMenu({ menu, className, children, }: PopoverMenuProperties): React.JSX.Element;
|
|
39
39
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../jsx-runtime-BB_1_6y_.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../jsx-runtime-BB_1_6y_.js"),y=require("@kuma-ui/core"),c=require("react"),z=require("../theme.js"),g=require("../icons/icon.js"),A=require("../hooks/use-synchronized-value.js"),F=require("../utilities/listeners.js"),R=require("./popover.js"),V=require("./atom.js"),S=require("./text.js"),I=require("./hover-gradient.js"),B=require("./click-ripples.js"),T=require("./separator.js"),H=require("./decorators.js"),N=require("./spinner.js"),_=require("./skeleton.js"),$=F.default(e=>{window.addEventListener("keydown",e,{capture:!0})},e=>{window.removeEventListener("keydown",e,{capture:!0})});function C(){const{value:e,setValue:n}=A.default("isKeyboardNavigating");return c.useMemo(()=>({isKeyboardNavigating:e,setIsKeyboardNavigating:n}),[e,n])}const G="kakadu-components-949294122";function O({isLoading:e,isDisabled:n,label:l,iconLeft:m,iconRight:u,href:v,target:b,shouldCloseOnClick:s=!0,decorators:o=[],submenu:r,className:i,onClick:j,...E}){const{isVisible:h,isPreparingFocus:d,isFocused:a,close:k}=R.usePopoverContext(),{isKeyboardNavigating:p}=C(),w=c.useRef(!0),M=c.useCallback(()=>{w.current=a},[a]),P=c.useCallback(D=>{!p&&!w.current||a&&(j==null||j(D),r?r.show():s&&(k==null||k()))},[p,a,j,r,s,k]),x=!h&&!d||!!e||!!n,f=v!==void 0&&!e,q=c.useMemo(()=>t.jsxRuntimeExports.jsxs(V.default,{as:f?"a":"button",...E,"aria-disabled":f&&x?!0:void 0,type:f?void 0:"button",role:"menuitem",href:e?void 0:v,target:f?b:void 0,inert:f?x:void 0,disabled:f?void 0:x,className:y.cx(z.buttonResetStyles,"kakadu-components-1772835671",a&&"kakadu-components-3160069815",p?"kakadu-components-2254977234":a&&!x&&"kakadu-components-278139688",x&&"kakadu-components-1879666195",i),onClick:x?void 0:P,onPointerDownCapture:x?void 0:M,children:[t.jsxRuntimeExports.jsxs(S.Span,{className:y.cx("kakadu-components-1377252111",e?"kakadu-components-2409458488":x&&"kakadu-components-532828420"),children:[m?e?t.jsxRuntimeExports.jsx(N.default,{size:12}):t.jsxRuntimeExports.jsx(g.default,{width:12,height:12,type:m}):null,t.jsxRuntimeExports.jsxs("span",{className:y.cx("kakadu-components-1590676894",e&&"kakadu-components-743909038"),children:[e?t.jsxRuntimeExports.jsx(_.SkeletonInstance,{"aria-hidden":!0,width:"100%",className:"kakadu-components-3950955262"}):null,t.jsxRuntimeExports.jsx("span",{className:e?"kakadu-components-543569100":void 0,children:l})]}),u?e?m?t.jsxRuntimeExports.jsx(_.SkeletonInstance,{width:12,height:12}):t.jsxRuntimeExports.jsx(N.default,{size:12}):t.jsxRuntimeExports.jsx(g.default,{width:12,height:12,type:u}):null]}),p||x?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(B.default,{isActive:a,size:100}),t.jsxRuntimeExports.jsx(I.default,{isActive:a,size:150,className:I.normalBlendStyles})]})]}),[f,E,x,v,e,b,i,a,p,P,M,m,l,u]);return t.jsxRuntimeExports.jsx(H.default,{decorators:o,children:r?t.jsxRuntimeExports.jsx(K,{menu:r.popoverMenu,className:"kakadu-components-1861176543",children:q}):q})}function U(e){if("type"in e){if(e.type==="separator")return t.jsxRuntimeExports.jsx(T.default,{});if(e.type==="group")return t.jsxRuntimeExports.jsx(S.Span,{className:"kakadu-components-1499037363",children:e.label})}return t.jsxRuntimeExports.jsx(O,{...e})}function J({items:e}){const{isFocused:n}=R.usePopoverContext(),[l,m]=c.useState([]),{setIsKeyboardNavigating:u}=C(),v=c.useCallback(s=>{s&&m(o=>o.includes(s)?o:[...o,s])},[]),b=c.useCallback(s=>{n&&(s.currentTarget.focus(),u(!1))},[n,u]);return c.useEffect(()=>{if(n)return $(s=>{const o=l.filter(d=>d.isConnected),r=o.length;if(r===0)return;let i,j=1;const E=document.activeElement;let h=E?o.indexOf(E):-1;switch(h===-1&&(h=0),s.key){case"ArrowUp":j=-1;case"ArrowDown":{i=(h+j+r)%r;break}case"Home":{i=0;break}case"End":{i=r-1,j=-1;break}case"Tab":{u(!0);return}}if(i!==void 0){s.preventDefault(),s.stopPropagation();let d=o[i];if(d){let a=0;const k=p=>"disabled"in p&&p.disabled||"inert"in p&&p.inert;for(;k(d)&&a<r;)i=(i+j+r)%r,d=o[i],a+=1;d&&!k(d)&&(d.focus(),u(!0))}}})},[n,l,u]),t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:e.map((s,o)=>t.jsxRuntimeExports.jsx(U,{...s,reference:v,onMouseEnter:b},o))})}function Q({items:e,...n}){return t.jsxRuntimeExports.jsx(R.default,{...n,as:"nav",role:"menu",innerClassName:"kakadu-components-3600436535",children:t.jsxRuntimeExports.jsx(J,{items:e})})}function W(e){const n=c.useMemo(()=>({items:e}),[e]),{isVisible:l,show:m,close:u,popover:v}=R.usePopover(Q,n);return c.useMemo(()=>({isVisible:l,show:m,close:u,popoverMenu:v}),[l,m,u,v])}function K({menu:e,className:n,children:l}){return t.jsxRuntimeExports.jsxs(R.PopoverContainer,{className:n,children:[l,e]})}exports.dangerPopoverMenuItemStyles=G;exports.default=K;exports.usePopoverMenu=W;
|
|
@@ -1,186 +1,188 @@
|
|
|
1
1
|
import { j as n } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
-
import { cx as
|
|
3
|
-
import { useMemo as
|
|
2
|
+
import { cx as P } from "@kuma-ui/core";
|
|
3
|
+
import { useMemo as y, useState as F, useCallback as b, useEffect as V, useRef as B } from "react";
|
|
4
4
|
import { buttonResetStyles as H } from "../theme.mjs";
|
|
5
5
|
import E from "../icons/icon.mjs";
|
|
6
6
|
import R from "../hooks/use-synchronized-value.mjs";
|
|
7
|
-
import T
|
|
8
|
-
import q from "./
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import Q from "./
|
|
12
|
-
import W from "./
|
|
13
|
-
import X from "./
|
|
7
|
+
import T from "../utilities/listeners.mjs";
|
|
8
|
+
import G, { PopoverContainer as U, usePopover as q, usePopoverContext as K } from "./popover.mjs";
|
|
9
|
+
import J from "./atom.mjs";
|
|
10
|
+
import { Span as A } from "./text.mjs";
|
|
11
|
+
import O, { normalBlendStyles as Q } from "./hover-gradient.mjs";
|
|
12
|
+
import W from "./click-ripples.mjs";
|
|
13
|
+
import X from "./separator.mjs";
|
|
14
|
+
import Y from "./decorators.mjs";
|
|
14
15
|
import S from "./spinner.mjs";
|
|
15
16
|
import { SkeletonInstance as D } from "./skeleton.mjs";
|
|
17
|
+
const Z = T((e) => {
|
|
18
|
+
window.addEventListener("keydown", e, {
|
|
19
|
+
capture: !0
|
|
20
|
+
});
|
|
21
|
+
}, (e) => {
|
|
22
|
+
window.removeEventListener("keydown", e, {
|
|
23
|
+
capture: !0
|
|
24
|
+
});
|
|
25
|
+
});
|
|
16
26
|
function z() {
|
|
17
27
|
const {
|
|
18
28
|
value: e,
|
|
19
|
-
setValue:
|
|
29
|
+
setValue: t
|
|
20
30
|
} = R("isKeyboardNavigating");
|
|
21
|
-
return
|
|
31
|
+
return y(() => ({
|
|
22
32
|
isKeyboardNavigating: e,
|
|
23
|
-
setIsKeyboardNavigating:
|
|
24
|
-
}), [e,
|
|
33
|
+
setIsKeyboardNavigating: t
|
|
34
|
+
}), [e, t]);
|
|
25
35
|
}
|
|
26
|
-
const
|
|
27
|
-
function
|
|
36
|
+
const he = "kakadu-components-949294122";
|
|
37
|
+
function _({
|
|
28
38
|
isLoading: e,
|
|
29
|
-
isDisabled:
|
|
30
|
-
label:
|
|
31
|
-
iconLeft:
|
|
39
|
+
isDisabled: t,
|
|
40
|
+
label: u,
|
|
41
|
+
iconLeft: p,
|
|
32
42
|
iconRight: a,
|
|
33
|
-
href:
|
|
43
|
+
href: v,
|
|
34
44
|
target: w,
|
|
35
|
-
shouldCloseOnClick:
|
|
36
|
-
decorators:
|
|
37
|
-
submenu:
|
|
38
|
-
className:
|
|
39
|
-
onClick:
|
|
40
|
-
...
|
|
45
|
+
shouldCloseOnClick: o = !0,
|
|
46
|
+
decorators: r = [],
|
|
47
|
+
submenu: s,
|
|
48
|
+
className: c,
|
|
49
|
+
onClick: f,
|
|
50
|
+
...h
|
|
41
51
|
}) {
|
|
42
52
|
const {
|
|
43
|
-
isVisible:
|
|
44
|
-
isPreparingFocus:
|
|
45
|
-
isFocused:
|
|
53
|
+
isVisible: j,
|
|
54
|
+
isPreparingFocus: d,
|
|
55
|
+
isFocused: i,
|
|
46
56
|
close: k
|
|
47
|
-
} =
|
|
48
|
-
isKeyboardNavigating:
|
|
49
|
-
} = z(),
|
|
50
|
-
|
|
51
|
-
}, [
|
|
52
|
-
!
|
|
53
|
-
}, [
|
|
54
|
-
/* @__PURE__ */ n.jsxs(
|
|
55
|
-
|
|
56
|
-
/* @__PURE__ */ n.jsxs("span", { className:
|
|
57
|
+
} = K(), {
|
|
58
|
+
isKeyboardNavigating: m
|
|
59
|
+
} = z(), I = B(!0), N = b(() => {
|
|
60
|
+
I.current = i;
|
|
61
|
+
}, [i]), g = b((C) => {
|
|
62
|
+
!m && !I.current || i && (f == null || f(C), s ? s.show() : o && (k == null || k()));
|
|
63
|
+
}, [m, i, f, s, o, k]), l = !j && !d || !!e || !!t, x = v !== void 0 && !e, M = y(() => /* @__PURE__ */ n.jsxs(J, { as: x ? "a" : "button", ...h, "aria-disabled": x && l ? !0 : void 0, type: x ? void 0 : "button", role: "menuitem", href: e ? void 0 : v, target: x ? w : void 0, inert: x ? l : void 0, disabled: x ? void 0 : l, className: P(H, "kakadu-components-1772835671", i && "kakadu-components-3160069815", m ? "kakadu-components-2254977234" : i && !l && "kakadu-components-278139688", l && "kakadu-components-1879666195", c), onClick: l ? void 0 : g, onPointerDownCapture: l ? void 0 : N, children: [
|
|
64
|
+
/* @__PURE__ */ n.jsxs(A, { className: P("kakadu-components-1377252111", e ? "kakadu-components-2409458488" : l && "kakadu-components-532828420"), children: [
|
|
65
|
+
p ? e ? /* @__PURE__ */ n.jsx(S, { size: 12 }) : /* @__PURE__ */ n.jsx(E, { width: 12, height: 12, type: p }) : null,
|
|
66
|
+
/* @__PURE__ */ n.jsxs("span", { className: P("kakadu-components-1590676894", e && "kakadu-components-743909038"), children: [
|
|
57
67
|
e ? /* @__PURE__ */ n.jsx(D, { "aria-hidden": !0, width: "100%", className: "kakadu-components-3950955262" }) : null,
|
|
58
|
-
/* @__PURE__ */ n.jsx("span", { className: e ? "kakadu-components-543569100" : void 0, children:
|
|
68
|
+
/* @__PURE__ */ n.jsx("span", { className: e ? "kakadu-components-543569100" : void 0, children: u })
|
|
59
69
|
] }),
|
|
60
|
-
a ? e ?
|
|
70
|
+
a ? e ? p ? /* @__PURE__ */ n.jsx(D, { width: 12, height: 12 }) : /* @__PURE__ */ n.jsx(S, { size: 12 }) : /* @__PURE__ */ n.jsx(E, { width: 12, height: 12, type: a }) : null
|
|
61
71
|
] }),
|
|
62
|
-
|
|
63
|
-
/* @__PURE__ */ n.jsx(
|
|
64
|
-
/* @__PURE__ */ n.jsx(
|
|
72
|
+
m || l ? null : /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
|
|
73
|
+
/* @__PURE__ */ n.jsx(W, { isActive: i, size: 100 }),
|
|
74
|
+
/* @__PURE__ */ n.jsx(O, { isActive: i, size: 150, className: Q })
|
|
65
75
|
] })
|
|
66
|
-
] }), [
|
|
67
|
-
return /* @__PURE__ */ n.jsx(
|
|
76
|
+
] }), [x, h, l, v, e, w, c, i, m, g, N, p, u, a]);
|
|
77
|
+
return /* @__PURE__ */ n.jsx(Y, { decorators: r, children: s ? /* @__PURE__ */ n.jsx(ne, { menu: s.popoverMenu, className: "kakadu-components-1861176543", children: M }) : M });
|
|
68
78
|
}
|
|
69
|
-
function
|
|
79
|
+
function $(e) {
|
|
70
80
|
if ("type" in e) {
|
|
71
81
|
if (e.type === "separator")
|
|
72
|
-
return /* @__PURE__ */ n.jsx(
|
|
82
|
+
return /* @__PURE__ */ n.jsx(X, {});
|
|
73
83
|
if (e.type === "group")
|
|
74
|
-
return /* @__PURE__ */ n.jsx(
|
|
84
|
+
return /* @__PURE__ */ n.jsx(A, { className: "kakadu-components-1499037363", children: e.label });
|
|
75
85
|
}
|
|
76
|
-
return /* @__PURE__ */ n.jsx(
|
|
86
|
+
return /* @__PURE__ */ n.jsx(_, { ...e });
|
|
77
87
|
}
|
|
78
|
-
function
|
|
88
|
+
function L({
|
|
79
89
|
items: e
|
|
80
90
|
}) {
|
|
81
91
|
const {
|
|
82
|
-
isFocused:
|
|
83
|
-
} =
|
|
92
|
+
isFocused: t
|
|
93
|
+
} = K(), [u, p] = F([]), {
|
|
84
94
|
setIsKeyboardNavigating: a
|
|
85
|
-
} = z(),
|
|
86
|
-
|
|
87
|
-
}, []), w =
|
|
88
|
-
|
|
89
|
-
}, [
|
|
95
|
+
} = z(), v = b((o) => {
|
|
96
|
+
o && p((r) => r.includes(o) ? r : [...r, o]);
|
|
97
|
+
}, []), w = b((o) => {
|
|
98
|
+
t && (o.currentTarget.focus(), a(!1));
|
|
99
|
+
}, [t, a]);
|
|
90
100
|
return V(() => {
|
|
91
|
-
if (
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (d === 0)
|
|
96
|
-
return;
|
|
97
|
-
let s, v = 1;
|
|
98
|
-
const y = document.activeElement;
|
|
99
|
-
let j = y ? u.indexOf(y) : -1;
|
|
100
|
-
switch (j === -1 && (j = 0), i.key) {
|
|
101
|
-
case "ArrowUp":
|
|
102
|
-
v = -1;
|
|
103
|
-
// eslint-disable-next-line no-fallthrough
|
|
104
|
-
case "ArrowDown": {
|
|
105
|
-
s = (j + v + d) % d;
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
case "Home": {
|
|
109
|
-
s = 0;
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
case "End": {
|
|
113
|
-
s = d - 1, v = -1;
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
case "Tab": {
|
|
117
|
-
a(!0);
|
|
101
|
+
if (t)
|
|
102
|
+
return Z((o) => {
|
|
103
|
+
const r = u.filter((d) => d.isConnected), s = r.length;
|
|
104
|
+
if (s === 0)
|
|
118
105
|
return;
|
|
106
|
+
let c, f = 1;
|
|
107
|
+
const h = document.activeElement;
|
|
108
|
+
let j = h ? r.indexOf(h) : -1;
|
|
109
|
+
switch (j === -1 && (j = 0), o.key) {
|
|
110
|
+
case "ArrowUp":
|
|
111
|
+
f = -1;
|
|
112
|
+
// eslint-disable-next-line no-fallthrough
|
|
113
|
+
case "ArrowDown": {
|
|
114
|
+
c = (j + f + s) % s;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case "Home": {
|
|
118
|
+
c = 0;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case "End": {
|
|
122
|
+
c = s - 1, f = -1;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case "Tab": {
|
|
126
|
+
a(!0);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
119
129
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
if (c !== void 0) {
|
|
131
|
+
o.preventDefault(), o.stopPropagation();
|
|
132
|
+
let d = r[c];
|
|
133
|
+
if (d) {
|
|
134
|
+
let i = 0;
|
|
135
|
+
const k = (m) => "disabled" in m && m.disabled || "inert" in m && m.inert;
|
|
136
|
+
for (; k(d) && i < s; )
|
|
137
|
+
c = (c + f + s) % s, d = r[c], i += 1;
|
|
138
|
+
d && !k(d) && (d.focus(), a(!0));
|
|
139
|
+
}
|
|
130
140
|
}
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
return window.addEventListener("keydown", r, {
|
|
134
|
-
capture: !0
|
|
135
|
-
}), () => {
|
|
136
|
-
window.removeEventListener("keydown", r, {
|
|
137
|
-
capture: !0
|
|
138
141
|
});
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
Z,
|
|
142
|
+
}, [t, u, a]), /* @__PURE__ */ n.jsx(n.Fragment, { children: e.map((o, r) => /* @__PURE__ */ n.jsx(
|
|
143
|
+
$,
|
|
142
144
|
{
|
|
143
|
-
...
|
|
144
|
-
reference:
|
|
145
|
+
...o,
|
|
146
|
+
reference: v,
|
|
145
147
|
onMouseEnter: w
|
|
146
148
|
},
|
|
147
|
-
|
|
149
|
+
r
|
|
148
150
|
)) });
|
|
149
151
|
}
|
|
150
|
-
function
|
|
152
|
+
function ee({
|
|
151
153
|
items: e,
|
|
152
|
-
...
|
|
154
|
+
...t
|
|
153
155
|
}) {
|
|
154
|
-
return /* @__PURE__ */ n.jsx(
|
|
156
|
+
return /* @__PURE__ */ n.jsx(G, { ...t, as: "nav", role: "menu", innerClassName: "kakadu-components-3600436535", children: /* @__PURE__ */ n.jsx(L, { items: e }) });
|
|
155
157
|
}
|
|
156
|
-
function
|
|
157
|
-
const
|
|
158
|
+
function je(e) {
|
|
159
|
+
const t = y(() => ({
|
|
158
160
|
items: e
|
|
159
161
|
}), [e]), {
|
|
160
|
-
isVisible:
|
|
161
|
-
show:
|
|
162
|
+
isVisible: u,
|
|
163
|
+
show: p,
|
|
162
164
|
close: a,
|
|
163
|
-
popover:
|
|
164
|
-
} =
|
|
165
|
-
return
|
|
166
|
-
isVisible:
|
|
167
|
-
show:
|
|
165
|
+
popover: v
|
|
166
|
+
} = q(ee, t);
|
|
167
|
+
return y(() => ({
|
|
168
|
+
isVisible: u,
|
|
169
|
+
show: p,
|
|
168
170
|
close: a,
|
|
169
|
-
popoverMenu:
|
|
170
|
-
}), [
|
|
171
|
+
popoverMenu: v
|
|
172
|
+
}), [u, p, a, v]);
|
|
171
173
|
}
|
|
172
|
-
function
|
|
174
|
+
function ne({
|
|
173
175
|
menu: e,
|
|
174
|
-
className:
|
|
175
|
-
children:
|
|
176
|
+
className: t,
|
|
177
|
+
children: u
|
|
176
178
|
}) {
|
|
177
|
-
return /* @__PURE__ */ n.jsxs(
|
|
178
|
-
|
|
179
|
+
return /* @__PURE__ */ n.jsxs(U, { className: t, children: [
|
|
180
|
+
u,
|
|
179
181
|
e
|
|
180
182
|
] });
|
|
181
183
|
}
|
|
182
184
|
export {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
he as dangerPopoverMenuItemStyles,
|
|
186
|
+
ne as default,
|
|
187
|
+
je as usePopoverMenu
|
|
186
188
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ComponentType } from 'react';
|
|
1
|
+
import React, { type ComponentType } from 'react';
|
|
2
2
|
import { type AtomElementType, type AtomProperties, type DefaultAtomElementType } from './atom';
|
|
3
3
|
type InitialFocusElement = HTMLElement | null;
|
|
4
4
|
type PopoverProviderProperties<Data = any> = {
|
|
@@ -9,7 +9,7 @@ type PopoverProviderProperties<Data = any> = {
|
|
|
9
9
|
close?: (data?: Data) => void;
|
|
10
10
|
};
|
|
11
11
|
export declare function usePopoverContext<Data = any>(): PopoverProviderProperties<Data>;
|
|
12
|
-
export declare function PopoverContainer<Type extends AtomElementType = DefaultAtomElementType>({ as, className, ...properties }: AtomProperties<Type>):
|
|
12
|
+
export declare function PopoverContainer<Type extends AtomElementType = DefaultAtomElementType>({ as, className, ...properties }: AtomProperties<Type>): React.JSX.Element;
|
|
13
13
|
export type PopoverProperties<Data = any, Type extends AtomElementType = DefaultAtomElementType> = AtomProperties<Type> & {
|
|
14
14
|
readonly innerClassName?: string;
|
|
15
15
|
readonly label?: string;
|
|
@@ -20,11 +20,11 @@ export type PopoverProperties<Data = any, Type extends AtomElementType = Default
|
|
|
20
20
|
readonly onClose?: (data?: Data) => void;
|
|
21
21
|
};
|
|
22
22
|
type PopoverBaseProperties<PopoverResult> = Omit<PopoverProperties<PopoverResult>, 'isVisible' | 'onClose'>;
|
|
23
|
-
export default function Popover<Data = any, Type extends AtomElementType = DefaultAtomElementType>({ as, isVisible, label, shouldCloseOnOutsideClick, shouldCloseOnEscapePress, children, className, innerClassName, onClose, ...properties }: PopoverProperties<Data, Type>):
|
|
23
|
+
export default function Popover<Data = any, Type extends AtomElementType = DefaultAtomElementType>({ as, isVisible, label, shouldCloseOnOutsideClick, shouldCloseOnEscapePress, children, className, innerClassName, onClose, ...properties }: PopoverProperties<Data, Type>): React.JSX.Element | null;
|
|
24
24
|
export declare function usePopover<PopoverResult, PopoverProperties = PopoverBaseProperties<PopoverResult>>(PopoverComponent: ComponentType<PopoverProperties>, properties?: PopoverProperties): {
|
|
25
25
|
isVisible: boolean;
|
|
26
26
|
show: () => Promise<PopoverResult | undefined>;
|
|
27
27
|
close: (result?: PopoverResult) => void;
|
|
28
|
-
popover:
|
|
28
|
+
popover: React.JSX.Element | null;
|
|
29
29
|
};
|
|
30
30
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../jsx-runtime-BB_1_6y_.js"),p=require("@kuma-ui/core"),e=require("react"),Q=require("../focus-trap-react-B7f3iC5h.js"),X=require("../utilities/listeners.js"),F=require("./atom.js"),Y=X.default(s=>{window.addEventListener("resize",s,{passive:!0})},s=>{window.removeEventListener("resize",s)}),$=e.createContext({isVisible:!1,isPreparingFocus:!1,isFocused:!1}),{Provider:Z}=$;function ee(){return e.useContext($)}function te({as:s,className:n,...l}){return o.jsxRuntimeExports.jsx(F.default,{as:s??F.defaultAtomElementType,...l,className:p.cx("kakadu-components-2845019685",n)})}function se({as:s,isVisible:n,label:l,shouldCloseOnOutsideClick:v=!0,shouldCloseOnEscapePress:c=!0,children:x,className:a,innerClassName:f,onClose:u,...h}){const k=e.useRef(null),R=e.useRef(null),[r,g]=e.useState(!1),[d,j]=e.useState(!1),[C,H]=e.useState(!1),[i,E]=e.useState(!1),[U,T]=e.useState(!1),A=e.useCallback(t=>{k.current=t,E(!1)},[]),b=e.useRef(null),L=e.useCallback(t=>{t&&(b.current=t)},[]),G=e.useMemo(()=>({initialFocus:()=>b.current??void 0,onPostActivate(){var t;j(!0),g(!1),(t=b.current)==null||t.focus()},clickOutsideDeactivates:v,escapeDeactivates:c,onPostUnpause(){j(!0)},onPause(){j(!1)},onDeactivate(){T(!1),E(!1),j(!1)}}),[v,c]),[I,N]=e.useState(n??!1),J=e.useMemo(()=>({isVisible:I,isPreparingFocus:r,isFocused:d,setInitialFocus:L,close:A}),[I,r,d,L,A]),[m,O]=e.useState("center");return e.useEffect(()=>{const t=R.current;if(t){const y=()=>{const z=t.offsetParent,S=z instanceof HTMLElement?z.getBoundingClientRect():null,D=t.getBoundingClientRect();if(!S){O("center");return}const M=16,V=window.innerWidth-M,q=S.left+S.width/2-D.width/2,_=q+D.width,B=q<M,W=_>V;let w="center";if(B&&W){const P=M-q;w=_-V>P?"right":"left"}else W?w="right":B&&(w="left");O(P=>P===w?P:w)};y();const K=Y(y);return()=>{K()}}},[]),e.useEffect(()=>{n&&(H(!0),N(!0))},[n]),e.useEffect(()=>{if(n){const t=setTimeout(()=>{E(!0)},100);return()=>{clearTimeout(t)}}E(!1)},[n]),e.useEffect(()=>{if(!i){T(!1),g(!1);return}g(!0);const t=window.requestAnimationFrame(()=>{T(!0)});return()=>{window.cancelAnimationFrame(t)}},[i]),e.useEffect(()=>{if(C&&!i){const t=setTimeout(()=>{N(!1),u==null||u(k.current??void 0)},370);return()=>{clearTimeout(t)}}},[C,i,u]),I?o.jsxRuntimeExports.jsx(F.default,{reference:R,as:s??F.defaultAtomElementType,role:"dialog","aria-hidden":!i&&!d,"aria-label":l??"Popover",...h,className:p.cx("kakadu-components-3920007758",m==="left"&&"kakadu-components-611400930",m==="right"&&"kakadu-components-944244368",i&&"kakadu-components-1399012551",a),children:o.jsxRuntimeExports.jsxs("div",{className:p.cx("kakadu-components-1118152266",i&&"kakadu-components-231244945"),children:[o.jsxRuntimeExports.jsx("div",{className:p.cx("kakadu-components-1951789226",m==="left"&&"kakadu-components-1495725644",m==="right"&&"kakadu-components-4235689197")}),o.jsxRuntimeExports.jsx(Q.focusTrapReactExports.FocusTrap,{active:U,focusTrapOptions:G,children:o.jsxRuntimeExports.jsxs("div",{className:p.cx("kakadu-components-2488426662",f),children:[o.jsxRuntimeExports.jsx(Z,{value:J,children:x}),o.jsxRuntimeExports.jsx("div",{className:p.cx("kakadu-components-3252390100",m==="left"&&"kakadu-components-3754561431",m==="right"&&"kakadu-components-2265262600")})]})})]})}):null}function ne(s,n){const[l,v]=e.useState(!1),[c,x]=e.useState(!1),a=e.useRef(void 0),f=e.useRef(void 0),u=e.useCallback(async()=>(f.current=void 0,v(!0),x(!0),new Promise(r=>{a.current=r})),[]),h=e.useCallback(r=>{f.current=r,x(!1)},[]),k=e.useCallback(r=>{var d;const g=r??f.current;f.current=void 0,(d=a.current)==null||d.call(a,g),a.current=void 0,v(!1),x(!1)},[]),R=e.useMemo(()=>l?o.jsxRuntimeExports.jsx(s,{...n,isVisible:c,onClose:k}):null,[l,s,n,c,k]);return e.useMemo(()=>({isVisible:c,show:u,close:h,popover:R}),[c,u,h,R])}exports.PopoverContainer=te;exports.default=se;exports.usePopover=ne;exports.usePopoverContext=ee;
|