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