@kakadu/components 6.3.14 → 6.5.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.
@@ -0,0 +1,19 @@
1
+ import React, { type ChangeEvent, type HTMLProps, type ReactNode } from 'react';
2
+ import { type InputLabelControllerProperties } from './input';
3
+ export declare function CheckboxIcon({ value, className, }: {
4
+ readonly value?: boolean;
5
+ readonly className?: string;
6
+ }): React.JSX.Element;
7
+ export type TextCheckboxProperties<Type extends boolean = boolean> = Omit<HTMLProps<HTMLInputElement>, 'value' | 'checked' | 'children' | 'onChange'> & {
8
+ readonly label: ReactNode;
9
+ readonly value?: boolean;
10
+ readonly children?: ReactNode;
11
+ readonly onChange?: (value: Type, event: ChangeEvent<HTMLInputElement>) => void;
12
+ };
13
+ export declare function TextCheckbox<Type extends boolean = boolean>({ label, disabled, className, children, onChange, ...properties }: TextCheckboxProperties<Type>): React.JSX.Element;
14
+ export type CheckboxProperties<Type extends boolean = boolean> = Omit<InputLabelControllerProperties & HTMLProps<HTMLInputElement>, 'value' | 'checked' | 'children' | 'onChange'> & {
15
+ readonly value?: boolean;
16
+ readonly children: ReactNode;
17
+ readonly onChange?: (value: Type, event: ChangeEvent<HTMLInputElement>) => void;
18
+ };
19
+ export default function Checkbox<Type extends boolean = boolean>({ label, disabled, error, warning, information, footnote, className, children, onChange, ...properties }: CheckboxProperties<Type>): React.JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-BB_1_6y_.js"),o=require("react"),j=require("@kuma-ui/core"),_=require("../icons/icon.js"),F=require("../theme.js"),B=require("./input.js"),T=require("./aria-text.js"),R=require("./flex.js"),b=require("./text.js"),w=require("./hover-gradient.js"),z=require("./click-ripples.js");function N({value:a,className:t}){return e.jsxRuntimeExports.jsx("div",{"aria-hidden":!0,className:j.cx("kakadu-components-483027860",a&&"kakadu-components-347512941",t),children:a?e.jsxRuntimeExports.jsx("div",{"data-theme":"dark",className:"kakadu-components-3323194660",children:e.jsxRuntimeExports.jsx(_.default,{type:"check",size:14,fill:"#fff",className:_.iconShadowStyles})}):null})}function M({label:a,disabled:t,className:x,children:r,onChange:s,...k}){const{value:i,...f}=k,[c,m]=o.useState(!1),n=i??c;o.useEffect(()=>{m(!!i)},[i]);const d=o.useCallback(u=>{const{checked:l}=u.target;m(l),s==null||s(l,u)},[s]);return e.jsxRuntimeExports.jsxs("label",{className:j.cx("kakadu-components-1233932825",t&&"kakadu-components-2246117376",x),children:[e.jsxRuntimeExports.jsx("input",{...f,type:"checkbox",checked:n,disabled:t,className:T.ariaTextStyles,onChange:d}),e.jsxRuntimeExports.jsxs(R.default,{direction:"row",gap:.75,children:[e.jsxRuntimeExports.jsx(N,{value:n}),e.jsxRuntimeExports.jsxs(R.default,{fill:!0,gap:.25,children:[e.jsxRuntimeExports.jsx(b.Span,{className:j.cx(F.overflowProtectionStyles,"kakadu-components-3627383913",n&&"kakadu-components-572005680"),children:a}),r?e.jsxRuntimeExports.jsx(b.Footnote,{children:r}):null]})]})]})}function C({label:a,disabled:t,error:x,warning:r,information:s,footnote:k,className:i,children:f,onChange:c,...m}){const n=o.useId(),d=`${n}-error`,u=`${n}-warning`,l=`${n}-information`,p=!!x,h=!p&&!!r,q=!p&&!h&&!!s,V=p?d:h?u:q?l:void 0,{value:E,...g}=m,[$,y]=o.useState(!1),S=E??$;o.useEffect(()=>{y(!!E)},[E]);const P=o.useCallback(v=>{const{checked:I}=v.target;y(I),c==null||c(I,v)},[c]);return e.jsxRuntimeExports.jsxs(B.InputLabel,{label:a,error:x,errorId:d,warning:r,warningId:u,information:s,informationId:l,footnote:k,className:j.cx("kakadu-components-1233932825",t&&"kakadu-components-2246117376",i),children:[e.jsxRuntimeExports.jsx("input",{...g,type:"checkbox",checked:S,disabled:t,"aria-invalid":p,"data-warning":h,"data-information":q,"aria-describedby":V,className:T.ariaTextStyles,onChange:P}),e.jsxRuntimeExports.jsxs("div",{className:B.inputStyles,"aria-disabled":t?!0:void 0,children:[e.jsxRuntimeExports.jsxs(R.default,{direction:"row",gap:.75,className:"kakadu-components-1066891822",children:[e.jsxRuntimeExports.jsx(N,{value:S,className:"kakadu-components-3803487082"}),e.jsxRuntimeExports.jsx(b.Footnote,{className:"kakadu-components-4115080333",children:f})]}),t?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(w.default,{size:150,className:w.normalBlendStyles}),e.jsxRuntimeExports.jsx(z.default,{})]})]})]})}exports.CheckboxIcon=N;exports.TextCheckbox=M;exports.default=C;
@@ -0,0 +1,93 @@
1
+ import { j as e } from "../jsx-runtime-B4hRZ52C.mjs";
2
+ import { useId as T, useState as B, useEffect as w, useCallback as V } from "react";
3
+ import { cx as k } from "@kuma-ui/core";
4
+ import G, { iconShadowStyles as H } from "../icons/icon.mjs";
5
+ import { overflowProtectionStyles as L } from "../theme.mjs";
6
+ import { InputLabel as W, inputStyles as q } from "./input.mjs";
7
+ import { ariaTextStyles as g } from "./aria-text.mjs";
8
+ import N from "./flex.mjs";
9
+ import { Footnote as E, Span as A } from "./text.mjs";
10
+ import D, { normalBlendStyles as J } from "./hover-gradient.mjs";
11
+ import K from "./click-ripples.mjs";
12
+ function F({
13
+ value: t,
14
+ className: a
15
+ }) {
16
+ return /* @__PURE__ */ e.jsx("div", { "aria-hidden": !0, className: k("kakadu-components-483027860", t && "kakadu-components-347512941", a), children: t ? /* @__PURE__ */ e.jsx("div", { "data-theme": "dark", className: "kakadu-components-3323194660", children: /* @__PURE__ */ e.jsx(G, { type: "check", size: 14, fill: "#fff", className: H }) }) : null });
17
+ }
18
+ function se({
19
+ label: t,
20
+ disabled: a,
21
+ className: m,
22
+ children: c,
23
+ onChange: s,
24
+ ...x
25
+ }) {
26
+ const {
27
+ value: r,
28
+ ...f
29
+ } = x, [n, d] = B(!1), o = r ?? n;
30
+ w(() => {
31
+ d(!!r);
32
+ }, [r]);
33
+ const u = V((l) => {
34
+ const {
35
+ checked: i
36
+ } = l.target;
37
+ d(i), s == null || s(i, l);
38
+ }, [s]);
39
+ return /* @__PURE__ */ e.jsxs("label", { className: k("kakadu-components-1233932825", a && "kakadu-components-2246117376", m), children: [
40
+ /* @__PURE__ */ e.jsx("input", { ...f, type: "checkbox", checked: o, disabled: a, className: g, onChange: u }),
41
+ /* @__PURE__ */ e.jsxs(N, { direction: "row", gap: 0.75, children: [
42
+ /* @__PURE__ */ e.jsx(F, { value: o }),
43
+ /* @__PURE__ */ e.jsxs(N, { fill: !0, gap: 0.25, children: [
44
+ /* @__PURE__ */ e.jsx(A, { className: k(L, "kakadu-components-3627383913", o && "kakadu-components-572005680"), children: t }),
45
+ c ? /* @__PURE__ */ e.jsx(E, { children: c }) : null
46
+ ] })
47
+ ] })
48
+ ] });
49
+ }
50
+ function oe({
51
+ label: t,
52
+ disabled: a,
53
+ error: m,
54
+ warning: c,
55
+ information: s,
56
+ footnote: x,
57
+ className: r,
58
+ children: f,
59
+ onChange: n,
60
+ ...d
61
+ }) {
62
+ const o = T(), u = `${o}-error`, l = `${o}-warning`, i = `${o}-information`, p = !!m, h = !p && !!c, y = !p && !h && !!s, P = p ? u : h ? l : y ? i : void 0, {
63
+ value: j,
64
+ ...$
65
+ } = d, [z, I] = B(!1), v = j ?? z;
66
+ w(() => {
67
+ I(!!j);
68
+ }, [j]);
69
+ const R = V((b) => {
70
+ const {
71
+ checked: S
72
+ } = b.target;
73
+ I(S), n == null || n(S, b);
74
+ }, [n]);
75
+ return /* @__PURE__ */ e.jsxs(W, { label: t, error: m, errorId: u, warning: c, warningId: l, information: s, informationId: i, footnote: x, className: k("kakadu-components-1233932825", a && "kakadu-components-2246117376", r), children: [
76
+ /* @__PURE__ */ e.jsx("input", { ...$, type: "checkbox", checked: v, disabled: a, "aria-invalid": p, "data-warning": h, "data-information": y, "aria-describedby": P, className: g, onChange: R }),
77
+ /* @__PURE__ */ e.jsxs("div", { className: q, "aria-disabled": a ? !0 : void 0, children: [
78
+ /* @__PURE__ */ e.jsxs(N, { direction: "row", gap: 0.75, className: "kakadu-components-1066891822", children: [
79
+ /* @__PURE__ */ e.jsx(F, { value: v, className: "kakadu-components-3803487082" }),
80
+ /* @__PURE__ */ e.jsx(E, { className: "kakadu-components-4115080333", children: f })
81
+ ] }),
82
+ a ? null : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
83
+ /* @__PURE__ */ e.jsx(D, { size: 150, className: J }),
84
+ /* @__PURE__ */ e.jsx(K, {})
85
+ ] })
86
+ ] })
87
+ ] });
88
+ }
89
+ export {
90
+ F as CheckboxIcon,
91
+ se as TextCheckbox,
92
+ oe as default
93
+ };
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-BB_1_6y_.js"),t=require("react"),r=require("@kuma-ui/core"),Q=require("../utilities/copy-to-clipboard.js"),M=require("../theme.js"),me=require("../icons/sparkle.js"),de=require("./button-tooltip.js"),B=require("./text-button.js"),x=require("./text.js"),je=require("./collapsible.js"),X=require("./click-ripples.js"),Y=require("./hover-gradient.js"),ke=require("./notification.js"),fe="kakadu-components-922159086",he="kakadu-components-25448712",v="kakadu-components-3185985134",T="kakadu-components-4056037255",Z=r.cx(T,"kakadu-components-3245407458"),Ee=r.cx(T,"kakadu-components-1117160492"),Re=r.cx(T,"kakadu-components-821835704");function be({as:p,className:c,...m}){return e.jsxRuntimeExports.jsx(x.Span,{as:p??"span",...m,className:r.cx("kakadu-components-520991867",c)})}function ee({label:p,error:c,errorId:m,warning:l,warningId:h,information:i,informationId:S,footnote:a,attachments:C,className:d,children:j,...k}){const E=!!c,u=!!l,R=!!i,f=!!a;return e.jsxRuntimeExports.jsx("label",{...k,className:r.cx(fe,d),children:e.jsxRuntimeExports.jsxs("div",{className:"kakadu-components-3146929190",children:[e.jsxRuntimeExports.jsx(x.Span,{className:r.cx(M.overflowProtectionStyles,he),children:e.jsxRuntimeExports.jsx("span",{children:p})}),e.jsxRuntimeExports.jsxs("span",{className:"kakadu-components-3298764637",children:[j,f?e.jsxRuntimeExports.jsx(be,{className:"kakadu-components-613632806",children:a}):null,C]}),E||u||R?e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2927674627",children:E?e.jsxRuntimeExports.jsx(x.Paragraph,{id:m,className:Z,children:c instanceof Error?c.message:c}):u?e.jsxRuntimeExports.jsx(x.Paragraph,{id:h,className:Ee,children:l instanceof Error?l.message:l}):R?e.jsxRuntimeExports.jsx(x.Paragraph,{id:S,className:Re,children:i instanceof Error?i.message:i}):null}):null]})})}const ge=40,L="kakadu-components-4233741488";function ye({ref:p,type:c,label:m,error:l,warning:h,information:i,footnote:S,suggestion:a,attachments:C,actions:d=[],hasCopyButton:j,hasClearButton:k,isMultiline:E,onChange:u,children:R,className:f,...b}){const $=t.useRef(null),H=t.useRef(null),q=t.useRef(null),A=ke.useCreateNotification(),I=t.useId(),F=`${I}-error`,V=`${I}-warning`,O=`${I}-information`,{value:g,disabled:te}=b,[se,W]=t.useState(""),o=g??se,[ne,ae]=t.useState(),oe=c==="textarea"||!!E;t.useLayoutEffect(()=>{typeof o=="string"&&q.current&&ae(q.current.scrollHeight)},[o]);const P=t.useMemo(()=>typeof o=="string"?`${o} `.split(`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-BB_1_6y_.js"),t=require("react"),r=require("@kuma-ui/core"),Q=require("../utilities/copy-to-clipboard.js"),M=require("../theme.js"),me=require("../icons/sparkle.js"),de=require("./button-tooltip.js"),B=require("./text-button.js"),x=require("./text.js"),je=require("./collapsible.js"),X=require("./click-ripples.js"),Y=require("./hover-gradient.js"),ke=require("./notification.js"),fe="kakadu-components-922159086",he="kakadu-components-25448712",v="kakadu-components-3308836726",T="kakadu-components-4056037255",Z=r.cx(T,"kakadu-components-3245407458"),Ee=r.cx(T,"kakadu-components-1117160492"),Re=r.cx(T,"kakadu-components-821835704");function be({as:p,className:c,...m}){return e.jsxRuntimeExports.jsx(x.Span,{as:p??"span",...m,className:r.cx("kakadu-components-520991867",c)})}function ee({label:p,error:c,errorId:m,warning:l,warningId:h,information:i,informationId:S,footnote:a,attachments:C,className:d,children:j,...k}){const E=!!c,u=!!l,R=!!i,f=!!a;return e.jsxRuntimeExports.jsx("label",{...k,className:r.cx(fe,d),children:e.jsxRuntimeExports.jsxs("div",{className:"kakadu-components-3146929190",children:[e.jsxRuntimeExports.jsx(x.Span,{className:r.cx(M.overflowProtectionStyles,he),children:e.jsxRuntimeExports.jsx("span",{children:p})}),e.jsxRuntimeExports.jsxs("span",{className:"kakadu-components-3298764637",children:[j,f?e.jsxRuntimeExports.jsx(be,{className:"kakadu-components-613632806",children:a}):null,C]}),E||u||R?e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2927674627",children:E?e.jsxRuntimeExports.jsx(x.Paragraph,{id:m,className:Z,children:c instanceof Error?c.message:c}):u?e.jsxRuntimeExports.jsx(x.Paragraph,{id:h,className:Ee,children:l instanceof Error?l.message:l}):R?e.jsxRuntimeExports.jsx(x.Paragraph,{id:S,className:Re,children:i instanceof Error?i.message:i}):null}):null]})})}const ge=40,L="kakadu-components-4233741488";function ye({ref:p,type:c,label:m,error:l,warning:h,information:i,footnote:S,suggestion:a,attachments:C,actions:d=[],hasCopyButton:j,hasClearButton:k,isMultiline:E,onChange:u,children:R,className:f,...b}){const $=t.useRef(null),H=t.useRef(null),q=t.useRef(null),A=ke.useCreateNotification(),I=t.useId(),F=`${I}-error`,V=`${I}-warning`,O=`${I}-information`,{value:g,disabled:te}=b,[se,W]=t.useState(""),o=g??se,[ne,ae]=t.useState(),oe=c==="textarea"||!!E;t.useLayoutEffect(()=>{typeof o=="string"&&q.current&&ae(q.current.scrollHeight)},[o]);const P=t.useMemo(()=>typeof o=="string"?`${o} `.split(`
2
2
  `):[],[o]),re=t.useMemo(()=>P.length,[P]),y=!!l,_=!y&&!!h,w=!!i,z=y?F:_?V:w?O:void 0;t.useEffect(()=>{W(typeof g=="string"?g:"")},[g]);const D=t.useCallback(s=>{const{value:n}=s.target;W(n),u==null||u(n,s)},[u]),ce=t.useCallback(()=>{typeof o=="string"&&(Q.default(o),A({type:"success",children:"Copied to clipboard."}))},[o,A]),N=t.useCallback(s=>{var J;const n=H.current??$.current??void 0;if(n){const K=(J=Object.getOwnPropertyDescriptor(n instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value"))==null?void 0:J.set;if(K){K.call(n,s);const pe=new Event("input",{bubbles:!0});n.dispatchEvent(pe),n.focus();return}}throw new Error("Unable to set value.")},[]),le=t.useCallback(()=>{N("")},[N]),[ie,ue]=t.useState(""),G=!!a&&ie!==a,xe=t.useCallback(()=>{if(a){try{N(a)}catch{Q.default(a)}ue(a)}},[a,N]),U=t.useMemo(()=>d.length,[d]);return e.jsxRuntimeExports.jsxs(ee,{ref:p,label:m,error:l,errorId:F,warning:h,warningId:V,information:i,informationId:O,footnote:S,attachments:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(je.default,{isCollapsed:!G,children:G?e.jsxRuntimeExports.jsxs("button",{type:"button",className:r.cx(M.buttonResetStyles,M.overflowProtectionStyles,"kakadu-components-4141839293"),onClick:xe,children:[e.jsxRuntimeExports.jsx(de.default,{label:"Apply suggestion"}),e.jsxRuntimeExports.jsx(me.default,{width:13,height:13,className:"kakadu-components-1417828741"}),e.jsxRuntimeExports.jsx(x.Span,{className:"kakadu-components-1384720019",children:a}),e.jsxRuntimeExports.jsx(X.default,{className:"kakadu-components-2744733744"}),e.jsxRuntimeExports.jsx(Y.default,{})]}):null}),C]}),style:{"--button-padding":`calc(${ge*((j?1:0)+(k?1:0)+U)}px + 6px)`},children:[e.jsxRuntimeExports.jsxs("div",{className:"kakadu-components-3146929190",children:[oe?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("span",{ref:q,"aria-hidden":!0,className:r.cx(v,f,"kakadu-components-2033521835"),children:[P.map((s,n)=>e.jsxRuntimeExports.jsxs("span",{children:[s,re>1?e.jsxRuntimeExports.jsx("br",{}):null]},n))," "]}),e.jsxRuntimeExports.jsx("textarea",{...b,ref:H,rows:b.rows??1,"aria-invalid":y,"data-warning":_,"data-information":w,"aria-describedby":z,value:o,className:r.cx(v,f,"kakadu-components-2119524139"),style:{minHeight:ne},onChange:D})]}):e.jsxRuntimeExports.jsx("input",{...b,ref:$,type:c??"text",value:o,"aria-invalid":y,"data-warning":_,"data-information":w,"aria-describedby":z,className:r.cx(v,f),onChange:D}),te?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(X.default,{className:"kakadu-components-616311160"}),e.jsxRuntimeExports.jsx(Y.default,{className:"kakadu-components-1962999040"})]})]}),j||k||U>0?e.jsxRuntimeExports.jsxs("div",{className:"kakadu-components-131986363",children:[d.map((s,n)=>e.jsxRuntimeExports.jsx(B.default,{iconLeft:s.icon,label:s.label,tooltip:s.label,className:L,onClick:s.onClick},s.label+n)),j?e.jsxRuntimeExports.jsx(B.default,{iconLeft:"copy",label:"Copy",tooltip:"Copy",className:L,onClick:ce}):null,k?e.jsxRuntimeExports.jsx(B.default,{iconLeft:"times",label:"Clear",tooltip:"Clear",className:L,onClick:le}):null]}):null,R]})}exports.InputLabel=ee;exports.default=ye;exports.errorParagraph=Z;exports.inputStyles=v;
@@ -11,7 +11,7 @@ import ge from "./collapsible.mjs";
11
11
  import ee from "./click-ripples.mjs";
12
12
  import ne from "./hover-gradient.mjs";
13
13
  import { useCreateNotification as Ne } from "./notification.mjs";
14
- const ve = "kakadu-components-922159086", Ce = "kakadu-components-25448712", $ = "kakadu-components-3185985134", V = "kakadu-components-4056037255", Se = o(V, "kakadu-components-3245407458"), Ee = o(V, "kakadu-components-1117160492"), Ie = o(V, "kakadu-components-821835704");
14
+ const ve = "kakadu-components-922159086", Ce = "kakadu-components-25448712", $ = "kakadu-components-3308836726", V = "kakadu-components-4056037255", Se = o(V, "kakadu-components-3245407458"), Ee = o(V, "kakadu-components-1117160492"), Ie = o(V, "kakadu-components-821835704");
15
15
  function Be({
16
16
  as: d,
17
17
  className: l,
@@ -18,7 +18,8 @@ export type PopoverMenuItemProperties = {
18
18
  readonly iconLeft?: IconType;
19
19
  readonly iconRight?: IconType;
20
20
  readonly submenu?: ReturnType<typeof usePopoverMenu>;
21
- readonly shouldCloseOnClick?: boolean;
21
+ /** Close the current menu on click. If `all`, all menus including parent menus. */
22
+ readonly shouldCloseOnClick?: boolean | 'all';
22
23
  readonly decorators?: DecoratorType[];
23
24
  readonly className?: string;
24
25
  readonly onClick?: (event: MouseEvent<PopoverMenuItemElementType>) => void;
@@ -1 +1 @@
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
+ "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 K(){const{value:e,setValue:n}=A.default("isKeyboardNavigating");return c.useMemo(()=>({isKeyboardNavigating:e,setIsKeyboardNavigating:n}),[e,n])}const G="kakadu-components-949294122";function U({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:f}=R.usePopoverContext(),{isKeyboardNavigating:p}=K(),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&&(f==null||f(void 0,{all:s==="all"})))},[p,a,j,r,s,f]),x=!h&&!d||!!e||!!n,k=v!==void 0&&!e,q=c.useMemo(()=>t.jsxRuntimeExports.jsxs(V.default,{as:k?"a":"button",...E,"aria-disabled":k&&x?!0:void 0,type:k?void 0:"button",role:"menuitem",href:e?void 0:v,target:k?b:void 0,inert:k?x:void 0,disabled:k?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})]})]}),[k,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(C,{menu:r.popoverMenu,className:"kakadu-components-1861176543",children:q}):q})}function J(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(U,{...e})}function O({items:e}){const{isFocused:n}=R.usePopoverContext(),[l,m]=c.useState([]),{setIsKeyboardNavigating:u}=K(),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 f=p=>"disabled"in p&&p.disabled||"inert"in p&&p.inert;for(;f(d)&&a<r;)i=(i+j+r)%r,d=o[i],a+=1;d&&!f(d)&&(d.focus(),u(!0))}}})},[n,l,u]),t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:e.map((s,o)=>t.jsxRuntimeExports.jsx(J,{...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(O,{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 C({menu:e,className:n,children:l}){return t.jsxRuntimeExports.jsxs(R.PopoverContainer,{className:n,children:[l,e]})}exports.dangerPopoverMenuItemStyles=G;exports.default=C;exports.usePopoverMenu=W;
@@ -1,6 +1,6 @@
1
1
  import { j as n } from "../jsx-runtime-B4hRZ52C.mjs";
2
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";
3
+ import { useMemo as y, useState as V, useCallback as b, useEffect as B, useRef as C } 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";
@@ -8,13 +8,13 @@ import T from "../utilities/listeners.mjs";
8
8
  import G, { PopoverContainer as U, usePopover as q, usePopoverContext as K } from "./popover.mjs";
9
9
  import J from "./atom.mjs";
10
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";
11
+ import Q, { normalBlendStyles as W } from "./hover-gradient.mjs";
12
+ import X from "./click-ripples.mjs";
13
+ import Y from "./separator.mjs";
14
+ import Z from "./decorators.mjs";
15
15
  import S from "./spinner.mjs";
16
16
  import { SkeletonInstance as D } from "./skeleton.mjs";
17
- const Z = T((e) => {
17
+ const _ = T((e) => {
18
18
  window.addEventListener("keydown", e, {
19
19
  capture: !0
20
20
  });
@@ -34,7 +34,7 @@ function z() {
34
34
  }), [e, t]);
35
35
  }
36
36
  const he = "kakadu-components-949294122";
37
- function _({
37
+ function $({
38
38
  isLoading: e,
39
39
  isDisabled: t,
40
40
  label: u,
@@ -56,10 +56,12 @@ function _({
56
56
  close: k
57
57
  } = K(), {
58
58
  isKeyboardNavigating: m
59
- } = z(), I = B(!0), N = b(() => {
59
+ } = z(), I = C(!0), N = b(() => {
60
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()));
61
+ }, [i]), g = b((F) => {
62
+ !m && !I.current || i && (f == null || f(F), s ? s.show() : o && (k == null || k(void 0, {
63
+ all: o === "all"
64
+ })));
63
65
  }, [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
66
  /* @__PURE__ */ n.jsxs(A, { className: P("kakadu-components-1377252111", e ? "kakadu-components-2409458488" : l && "kakadu-components-532828420"), children: [
65
67
  p ? e ? /* @__PURE__ */ n.jsx(S, { size: 12 }) : /* @__PURE__ */ n.jsx(E, { width: 12, height: 12, type: p }) : null,
@@ -70,36 +72,36 @@ function _({
70
72
  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
71
73
  ] }),
72
74
  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 })
75
+ /* @__PURE__ */ n.jsx(X, { isActive: i, size: 100 }),
76
+ /* @__PURE__ */ n.jsx(Q, { isActive: i, size: 150, className: W })
75
77
  ] })
76
78
  ] }), [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 });
79
+ return /* @__PURE__ */ n.jsx(Z, { decorators: r, children: s ? /* @__PURE__ */ n.jsx(ne, { menu: s.popoverMenu, className: "kakadu-components-1861176543", children: M }) : M });
78
80
  }
79
- function $(e) {
81
+ function O(e) {
80
82
  if ("type" in e) {
81
83
  if (e.type === "separator")
82
- return /* @__PURE__ */ n.jsx(X, {});
84
+ return /* @__PURE__ */ n.jsx(Y, {});
83
85
  if (e.type === "group")
84
86
  return /* @__PURE__ */ n.jsx(A, { className: "kakadu-components-1499037363", children: e.label });
85
87
  }
86
- return /* @__PURE__ */ n.jsx(_, { ...e });
88
+ return /* @__PURE__ */ n.jsx($, { ...e });
87
89
  }
88
90
  function L({
89
91
  items: e
90
92
  }) {
91
93
  const {
92
94
  isFocused: t
93
- } = K(), [u, p] = F([]), {
95
+ } = K(), [u, p] = V([]), {
94
96
  setIsKeyboardNavigating: a
95
97
  } = z(), v = b((o) => {
96
98
  o && p((r) => r.includes(o) ? r : [...r, o]);
97
99
  }, []), w = b((o) => {
98
100
  t && (o.currentTarget.focus(), a(!1));
99
101
  }, [t, a]);
100
- return V(() => {
102
+ return B(() => {
101
103
  if (t)
102
- return Z((o) => {
104
+ return _((o) => {
103
105
  const r = u.filter((d) => d.isConnected), s = r.length;
104
106
  if (s === 0)
105
107
  return;
@@ -140,7 +142,7 @@ function L({
140
142
  }
141
143
  });
142
144
  }, [t, u, a]), /* @__PURE__ */ n.jsx(n.Fragment, { children: e.map((o, r) => /* @__PURE__ */ n.jsx(
143
- $,
145
+ O,
144
146
  {
145
147
  ...o,
146
148
  reference: v,
@@ -1,12 +1,15 @@
1
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
+ type PopoverCloseOptions = {
5
+ readonly all?: boolean;
6
+ };
4
7
  type PopoverProviderProperties<Data = any> = {
5
8
  isVisible: boolean;
6
9
  isPreparingFocus: boolean;
7
10
  isFocused: boolean;
8
11
  setInitialFocus?: (initialFocus?: InitialFocusElement) => void;
9
- close?: (data?: Data) => void;
12
+ close?: (data?: Data, options?: PopoverCloseOptions) => void;
10
13
  };
11
14
  export declare function usePopoverContext<Data = any>(): PopoverProviderProperties<Data>;
12
15
  export declare function PopoverContainer<Type extends AtomElementType = DefaultAtomElementType>({ as, className, ...properties }: AtomProperties<Type>): React.JSX.Element;
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../jsx-runtime-BB_1_6y_.js"),x=require("@kuma-ui/core"),e=require("react"),Y=require("../focus-trap-react-B7f3iC5h.js"),Z=require("../utilities/listeners.js"),T=require("./atom.js"),ee=Z.default(s=>{window.addEventListener("resize",s,{passive:!0})},s=>{window.removeEventListener("resize",s)}),H=e.createContext({isVisible:!1,isPreparingFocus:!1,isFocused:!1}),{Provider:te}=H;function U(){return e.useContext(H)}function se({as:s,className:n,...d}){return o.jsxRuntimeExports.jsx(T.default,{as:s??T.defaultAtomElementType,...d,className:x.cx("kakadu-components-2845019685",n)})}function ne({as:s,isVisible:n,label:d,shouldCloseOnOutsideClick:k=!0,shouldCloseOnEscapePress:c=!0,children:R,className:a,innerClassName:m,onClose:u,...h}){const{close:i}=U(),g=e.useRef(null),r=e.useRef(null),[j,p]=e.useState(!1),[b,E]=e.useState(!1),[L,G]=e.useState(!1),[l,P]=e.useState(!1),[J,I]=e.useState(!1),N=e.useCallback((t,f)=>{g.current=t??null,P(!1),f!=null&&f.all&&(i==null||i(void 0,f))},[i]),S=e.useRef(null),O=e.useCallback(t=>{t&&(S.current=t)},[]),K=e.useMemo(()=>({initialFocus:()=>S.current??void 0,onPostActivate(){var t;E(!0),p(!1),(t=S.current)==null||t.focus()},clickOutsideDeactivates:k,escapeDeactivates:c,onPostUnpause(){E(!0)},onPause(){E(!1)},onDeactivate(){I(!1),P(!1),E(!1)}}),[k,c]),[M,y]=e.useState(n??!1),Q=e.useMemo(()=>({isVisible:M,isPreparingFocus:j,isFocused:b,setInitialFocus:O,close:N}),[M,j,b,O,N]),[v,z]=e.useState("center");return e.useEffect(()=>{const t=r.current;if(t){const f=()=>{const D=t.offsetParent,q=D instanceof HTMLElement?D.getBoundingClientRect():null,V=t.getBoundingClientRect();if(!q){z("center");return}const C=16,_=window.innerWidth-C,A=q.left+q.width/2-V.width/2,B=A+V.width,W=A<C,$=B>_;let w="center";if(W&&$){const F=C-A;w=B-_>F?"right":"left"}else $?w="right":W&&(w="left");z(F=>F===w?F:w)};f();const X=ee(f);return()=>{X()}}},[]),e.useEffect(()=>{n&&(G(!0),y(!0))},[n]),e.useEffect(()=>{if(n){const t=setTimeout(()=>{P(!0)},100);return()=>{clearTimeout(t)}}P(!1)},[n]),e.useEffect(()=>{if(!l){I(!1),p(!1);return}p(!0);const t=window.requestAnimationFrame(()=>{I(!0)});return()=>{window.cancelAnimationFrame(t)}},[l]),e.useEffect(()=>{if(L&&!l){const t=setTimeout(()=>{y(!1),u==null||u(g.current??void 0)},370);return()=>{clearTimeout(t)}}},[L,l,u]),M?o.jsxRuntimeExports.jsx(T.default,{reference:r,as:s??T.defaultAtomElementType,role:"dialog","aria-hidden":!l&&!b,"aria-label":d??"Popover",...h,className:x.cx("kakadu-components-3920007758",v==="left"&&"kakadu-components-611400930",v==="right"&&"kakadu-components-944244368",l&&"kakadu-components-1399012551",a),children:o.jsxRuntimeExports.jsxs("div",{className:x.cx("kakadu-components-1118152266",l&&"kakadu-components-231244945"),children:[o.jsxRuntimeExports.jsx("div",{className:x.cx("kakadu-components-1951789226",v==="left"&&"kakadu-components-1495725644",v==="right"&&"kakadu-components-4235689197")}),o.jsxRuntimeExports.jsx(Y.focusTrapReactExports.FocusTrap,{active:J,focusTrapOptions:K,children:o.jsxRuntimeExports.jsxs("div",{className:x.cx("kakadu-components-2488426662",m),children:[o.jsxRuntimeExports.jsx(te,{value:Q,children:R}),o.jsxRuntimeExports.jsx("div",{className:x.cx("kakadu-components-3252390100",v==="left"&&"kakadu-components-3754561431",v==="right"&&"kakadu-components-2265262600")})]})})]})}):null}function oe(s,n){const[d,k]=e.useState(!1),[c,R]=e.useState(!1),a=e.useRef(void 0),m=e.useRef(void 0),u=e.useCallback(async()=>(m.current=void 0,k(!0),R(!0),new Promise(r=>{a.current=r})),[]),h=e.useCallback(r=>{m.current=r,R(!1)},[]),i=e.useCallback(r=>{var p;const j=r??m.current;m.current=void 0,(p=a.current)==null||p.call(a,j),a.current=void 0,k(!1),R(!1)},[]),g=e.useMemo(()=>d?o.jsxRuntimeExports.jsx(s,{...n,isVisible:c,onClose:i}):null,[d,s,n,c,i]);return e.useMemo(()=>({isVisible:c,show:u,close:h,popover:g}),[c,u,h,g])}exports.PopoverContainer=se;exports.default=ne;exports.usePopover=oe;exports.usePopoverContext=U;
@@ -1,156 +1,158 @@
1
1
  import { j as n } from "../jsx-runtime-B4hRZ52C.mjs";
2
- import { cx as p } from "@kuma-ui/core";
3
- import { createContext as te, useRef as P, useState as o, useCallback as R, useMemo as A, useEffect as F, useContext as se } from "react";
4
- import { f as ne } from "../focus-trap-react-Dr3BYLw6.mjs";
5
- import oe from "../utilities/listeners.mjs";
6
- import K, { defaultAtomElementType as Q } from "./atom.mjs";
7
- const re = oe((t) => {
2
+ import { cx as k } from "@kuma-ui/core";
3
+ import { createContext as se, useRef as R, useState as o, useCallback as P, useMemo as b, useEffect as F, useContext as ne } from "react";
4
+ import { f as oe } from "../focus-trap-react-Dr3BYLw6.mjs";
5
+ import re from "../utilities/listeners.mjs";
6
+ import Q, { defaultAtomElementType as X } from "./atom.mjs";
7
+ const ce = re((t) => {
8
8
  window.addEventListener("resize", t, {
9
9
  passive: !0
10
10
  });
11
11
  }, (t) => {
12
12
  window.removeEventListener("resize", t);
13
- }), X = te({
13
+ }), Y = se({
14
14
  isVisible: !1,
15
15
  isPreparingFocus: !1,
16
16
  isFocused: !1
17
17
  }), {
18
18
  Provider: ae
19
- } = X;
20
- function pe() {
21
- return se(X);
19
+ } = Y;
20
+ function ie() {
21
+ return ne(Y);
22
22
  }
23
- function ve({
23
+ function ke({
24
24
  as: t,
25
25
  className: s,
26
- ...l
26
+ ...d
27
27
  }) {
28
- return /* @__PURE__ */ n.jsx(K, { as: t ?? Q, ...l, className: p("kakadu-components-2845019685", s) });
28
+ return /* @__PURE__ */ n.jsx(Q, { as: t ?? X, ...d, className: k("kakadu-components-2845019685", s) });
29
29
  }
30
- function ke({
30
+ function we({
31
31
  as: t,
32
32
  isVisible: s,
33
- label: l,
34
- shouldCloseOnOutsideClick: v = !0,
35
- shouldCloseOnEscapePress: a = !0,
36
- children: k,
37
- className: c,
38
- innerClassName: f,
33
+ label: d,
34
+ shouldCloseOnOutsideClick: w = !0,
35
+ shouldCloseOnEscapePress: c = !0,
36
+ children: g,
37
+ className: a,
38
+ innerClassName: m,
39
39
  onClose: i,
40
40
  ...j
41
41
  }) {
42
- const w = P(null), g = P(null), [r, h] = o(!1), [d, I] = o(!1), [O, Y] = o(!1), [u, T] = o(!1), [Z, b] = o(!1), V = R((e) => {
43
- w.current = e, T(!1);
44
- }, []), E = P(null), y = R((e) => {
45
- e && (E.current = e);
46
- }, []), _ = A(() => ({
47
- initialFocus: () => E.current ?? void 0,
42
+ const {
43
+ close: u
44
+ } = ie(), h = R(null), r = R(null), [I, v] = o(!1), [E, T] = o(!1), [y, Z] = o(!1), [l, L] = o(!1), [_, N] = o(!1), B = P((e, f) => {
45
+ h.current = e ?? null, L(!1), f != null && f.all && (u == null || u(void 0, f));
46
+ }, [u]), z = R(null), C = P((e) => {
47
+ e && (z.current = e);
48
+ }, []), $ = b(() => ({
49
+ initialFocus: () => z.current ?? void 0,
48
50
  onPostActivate() {
49
51
  var e;
50
- I(!0), h(!1), (e = E.current) == null || e.focus();
52
+ T(!0), v(!1), (e = z.current) == null || e.focus();
51
53
  },
52
- clickOutsideDeactivates: v,
53
- escapeDeactivates: a,
54
+ clickOutsideDeactivates: w,
55
+ escapeDeactivates: c,
54
56
  onPostUnpause() {
55
- I(!0);
57
+ T(!0);
56
58
  },
57
59
  onPause() {
58
- I(!1);
60
+ T(!1);
59
61
  },
60
62
  onDeactivate() {
61
- b(!1), T(!1), I(!1);
63
+ N(!1), L(!1), T(!1);
62
64
  }
63
- }), [v, a]), [N, B] = o(s ?? !1), $ = A(() => ({
64
- isVisible: N,
65
- isPreparingFocus: r,
66
- isFocused: d,
67
- setInitialFocus: y,
68
- close: V
69
- }), [N, r, d, y, V]), [m, C] = o("center");
65
+ }), [w, c]), [D, W] = o(s ?? !1), ee = b(() => ({
66
+ isVisible: D,
67
+ isPreparingFocus: I,
68
+ isFocused: E,
69
+ setInitialFocus: C,
70
+ close: B
71
+ }), [D, I, E, C, B]), [p, q] = o("center");
70
72
  return F(() => {
71
- const e = g.current;
73
+ const e = r.current;
72
74
  if (e) {
73
- const W = () => {
74
- const q = e.offsetParent, z = q instanceof HTMLElement ? q.getBoundingClientRect() : null, H = e.getBoundingClientRect();
75
- if (!z) {
76
- C("center");
75
+ const f = () => {
76
+ const H = e.offsetParent, M = H instanceof HTMLElement ? H.getBoundingClientRect() : null, S = e.getBoundingClientRect();
77
+ if (!M) {
78
+ q("center");
77
79
  return;
78
80
  }
79
- const D = 16, S = window.innerWidth - D, M = z.left + z.width / 2 - H.width / 2, U = M + H.width, G = M < D, J = U > S;
81
+ const O = 16, U = window.innerWidth - O, V = M.left + M.width / 2 - S.width / 2, G = V + S.width, J = V < O, K = G > U;
80
82
  let x = "center";
81
- if (G && J) {
82
- const L = D - M;
83
- x = U - S > L ? "right" : "left";
84
- } else J ? x = "right" : G && (x = "left");
85
- C((L) => L === x ? L : x);
83
+ if (J && K) {
84
+ const A = O - V;
85
+ x = G - U > A ? "right" : "left";
86
+ } else K ? x = "right" : J && (x = "left");
87
+ q((A) => A === x ? A : x);
86
88
  };
87
- W();
88
- const ee = re(W);
89
+ f();
90
+ const te = ce(f);
89
91
  return () => {
90
- ee();
92
+ te();
91
93
  };
92
94
  }
93
95
  }, []), F(() => {
94
- s && (Y(!0), B(!0));
96
+ s && (Z(!0), W(!0));
95
97
  }, [s]), F(() => {
96
98
  if (s) {
97
99
  const e = setTimeout(() => {
98
- T(!0);
100
+ L(!0);
99
101
  }, 100);
100
102
  return () => {
101
103
  clearTimeout(e);
102
104
  };
103
105
  }
104
- T(!1);
106
+ L(!1);
105
107
  }, [s]), F(() => {
106
- if (!u) {
107
- b(!1), h(!1);
108
+ if (!l) {
109
+ N(!1), v(!1);
108
110
  return;
109
111
  }
110
- h(!0);
112
+ v(!0);
111
113
  const e = window.requestAnimationFrame(() => {
112
- b(!0);
114
+ N(!0);
113
115
  });
114
116
  return () => {
115
117
  window.cancelAnimationFrame(e);
116
118
  };
117
- }, [u]), F(() => {
118
- if (O && !u) {
119
+ }, [l]), F(() => {
120
+ if (y && !l) {
119
121
  const e = setTimeout(() => {
120
- B(!1), i == null || i(w.current ?? void 0);
122
+ W(!1), i == null || i(h.current ?? void 0);
121
123
  }, 370);
122
124
  return () => {
123
125
  clearTimeout(e);
124
126
  };
125
127
  }
126
- }, [O, u, i]), N ? /* @__PURE__ */ n.jsx(K, { reference: g, as: t ?? Q, role: "dialog", "aria-hidden": !u && !d, "aria-label": l ?? "Popover", ...j, className: p("kakadu-components-3920007758", m === "left" && "kakadu-components-611400930", m === "right" && "kakadu-components-944244368", u && "kakadu-components-1399012551", c), children: /* @__PURE__ */ n.jsxs("div", { className: p("kakadu-components-1118152266", u && "kakadu-components-231244945"), children: [
127
- /* @__PURE__ */ n.jsx("div", { className: p("kakadu-components-1951789226", m === "left" && "kakadu-components-1495725644", m === "right" && "kakadu-components-4235689197") }),
128
- /* @__PURE__ */ n.jsx(ne.FocusTrap, { active: Z, focusTrapOptions: _, children: /* @__PURE__ */ n.jsxs("div", { className: p("kakadu-components-2488426662", f), children: [
129
- /* @__PURE__ */ n.jsx(ae, { value: $, children: k }),
130
- /* @__PURE__ */ n.jsx("div", { className: p("kakadu-components-3252390100", m === "left" && "kakadu-components-3754561431", m === "right" && "kakadu-components-2265262600") })
128
+ }, [y, l, i]), D ? /* @__PURE__ */ n.jsx(Q, { reference: r, as: t ?? X, role: "dialog", "aria-hidden": !l && !E, "aria-label": d ?? "Popover", ...j, className: k("kakadu-components-3920007758", p === "left" && "kakadu-components-611400930", p === "right" && "kakadu-components-944244368", l && "kakadu-components-1399012551", a), children: /* @__PURE__ */ n.jsxs("div", { className: k("kakadu-components-1118152266", l && "kakadu-components-231244945"), children: [
129
+ /* @__PURE__ */ n.jsx("div", { className: k("kakadu-components-1951789226", p === "left" && "kakadu-components-1495725644", p === "right" && "kakadu-components-4235689197") }),
130
+ /* @__PURE__ */ n.jsx(oe.FocusTrap, { active: _, focusTrapOptions: $, children: /* @__PURE__ */ n.jsxs("div", { className: k("kakadu-components-2488426662", m), children: [
131
+ /* @__PURE__ */ n.jsx(ae, { value: ee, children: g }),
132
+ /* @__PURE__ */ n.jsx("div", { className: k("kakadu-components-3252390100", p === "left" && "kakadu-components-3754561431", p === "right" && "kakadu-components-2265262600") })
131
133
  ] }) })
132
134
  ] }) }) : null;
133
135
  }
134
- function we(t, s) {
135
- const [l, v] = o(!1), [a, k] = o(!1), c = P(void 0), f = P(void 0), i = R(async () => (f.current = void 0, v(!0), k(!0), new Promise((r) => {
136
- c.current = r;
137
- })), []), j = R((r) => {
138
- f.current = r, k(!1);
139
- }, []), w = R((r) => {
140
- var d;
141
- const h = r ?? f.current;
142
- f.current = void 0, (d = c.current) == null || d.call(c, h), c.current = void 0, v(!1), k(!1);
143
- }, []), g = A(() => l ? /* @__PURE__ */ n.jsx(t, { ...s, isVisible: a, onClose: w }) : null, [l, t, s, a, w]);
144
- return A(() => ({
145
- isVisible: a,
136
+ function ge(t, s) {
137
+ const [d, w] = o(!1), [c, g] = o(!1), a = R(void 0), m = R(void 0), i = P(async () => (m.current = void 0, w(!0), g(!0), new Promise((r) => {
138
+ a.current = r;
139
+ })), []), j = P((r) => {
140
+ m.current = r, g(!1);
141
+ }, []), u = P((r) => {
142
+ var v;
143
+ const I = r ?? m.current;
144
+ m.current = void 0, (v = a.current) == null || v.call(a, I), a.current = void 0, w(!1), g(!1);
145
+ }, []), h = b(() => d ? /* @__PURE__ */ n.jsx(t, { ...s, isVisible: c, onClose: u }) : null, [d, t, s, c, u]);
146
+ return b(() => ({
147
+ isVisible: c,
146
148
  show: i,
147
149
  close: j,
148
- popover: g
149
- }), [a, i, j, g]);
150
+ popover: h
151
+ }), [c, i, j, h]);
150
152
  }
151
153
  export {
152
- ve as PopoverContainer,
153
- ke as default,
154
- we as usePopover,
155
- pe as usePopoverContext
154
+ ke as PopoverContainer,
155
+ we as default,
156
+ ge as usePopover,
157
+ ie as usePopoverContext
156
158
  };