@kakadu/components 3.2.4 → 3.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../jsx-runtime-BB_1_6y_.js"),M=require("@kuma-ui/core"),a=require("react"),q=require("../theme.js"),R=require("../icons/icon.js"),f=require("./popover.js"),P=require("./atom.js"),h=require("./text.js"),g=require("./hover-gradient.js"),I=require("./click-ripples.js"),N=require("./separator.js"),S=require("./decorators.js"),E=new Set;function y(){const[e,n]=a.useState(!1),r=a.useCallback(s=>{n(s);for(const i of E)i(s)},[]);return a.useEffect(()=>{const s=i=>{n(i)};return E.add(s),()=>{E.delete(s)}},[]),a.useMemo(()=>({isKeyboardNavigating:e,setIsKeyboardNavigating:r}),[e,r])}function _({label:e,iconLeft:n,iconRight:r,href:s,shouldCloseOnClick:i=!0,decorators:v=[],submenu:x,className:u,onClick:o,...j}){const{isVisible:l,isFocused:c,close:p}=f.usePopoverContext(),{isKeyboardNavigating:d}=y(),m=a.useCallback(w=>{c&&(o==null||o(w),x?x.show():i&&(p==null||p()))},[c,o,x,i,p]),k=a.useMemo(()=>t.jsxRuntimeExports.jsxs(P.default,{as:s?"a":"button",...j,type:s?void 0:"button",role:"menuitem",href:s,disabled:s?void 0:!l,className:M.cx(q.buttonResetStyles,"kakadu-components-3114599304",d?"kakadu-components-4096376656":"kakadu-components-2554182777",u),onClick:m,children:[t.jsxRuntimeExports.jsxs(h.Span,{className:"kakadu-components-1109353535",children:[n?t.jsxRuntimeExports.jsx(R.default,{width:12,height:12,type:n}):null,t.jsxRuntimeExports.jsx("span",{className:"kakadu-components-913703148",children:e}),r?t.jsxRuntimeExports.jsx(R.default,{width:12,height:12,type:r}):null]}),d?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(g.default,{size:150,className:g.normalBlendStyles}),t.jsxRuntimeExports.jsx(I.default,{size:100})]})]}),[s,j,l,d,u,m,n,e,r]);return t.jsxRuntimeExports.jsx(S.default,{decorators:v,children:x?t.jsxRuntimeExports.jsx(b,{menu:x.popoverMenu,className:"kakadu-components-1861176543",children:k}):k})}function K(e){if("type"in e){if(e.type==="separator")return t.jsxRuntimeExports.jsx(N.default,{});if(e.type==="group")return t.jsxRuntimeExports.jsx(h.Span,{className:"kakadu-components-1499037363",children:e.label})}return t.jsxRuntimeExports.jsx(_,{...e})}function C({items:e}){const{isFocused:n}=f.usePopoverContext(),[r,s]=a.useState([]),{setIsKeyboardNavigating:i}=y(),v=a.useCallback(u=>{u&&s(o=>o.includes(u)?o:[...o,u])},[]),x=a.useCallback(u=>{n&&(u.currentTarget.focus(),i(!1))},[n,i]);return a.useEffect(()=>{if(!n)return;const u=o=>{const j=r.filter(m=>m.isConnected),l=j.length;if(l===0)return;let c;const p=document.activeElement;let d=p?j.indexOf(p):-1;switch(d===-1&&(d=0),o.key){case"ArrowDown":{c=(d+1)%l;break}case"ArrowUp":{c=(d-1+l)%l;break}case"Home":{c=0;break}case"End":{c=l-1;break}}if(c!==void 0){o.preventDefault(),o.stopPropagation();const m=j[c];m&&(m.focus(),i(!0))}};return window.addEventListener("keydown",u,{capture:!0}),()=>{window.removeEventListener("keydown",u,{capture:!0})}},[n,r,i]),t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:e.map((u,o)=>t.jsxRuntimeExports.jsx(K,{...u,reference:v,onMouseEnter:x},o))})}function F({items:e,...n}){return t.jsxRuntimeExports.jsx(f.default,{...n,as:"nav",role:"menu",innerClassName:"kakadu-components-3600436535",children:t.jsxRuntimeExports.jsx(C,{items:e})})}function z(e){const n=a.useMemo(()=>({items:e}),[e]),{show:r,popover:s}=f.usePopover(F,n);return a.useMemo(()=>({show:r,popoverMenu:s}),[r,s])}function b({menu:e,className:n,children:r}){return t.jsxRuntimeExports.jsxs(f.PopoverContainer,{className:n,children:[r,e]})}exports.default=b;exports.usePopoverMenu=z;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../jsx-runtime-BB_1_6y_.js"),M=require("@kuma-ui/core"),i=require("react"),q=require("../theme.js"),R=require("../icons/icon.js"),f=require("./popover.js"),P=require("./atom.js"),h=require("./text.js"),g=require("./hover-gradient.js"),I=require("./click-ripples.js"),N=require("./separator.js"),S=require("./decorators.js"),E=new Set;function y(){const[e,n]=i.useState(!1),r=i.useCallback(s=>{n(s);for(const a of E)a(s)},[]);return i.useEffect(()=>{const s=a=>{n(a)};return E.add(s),()=>{E.delete(s)}},[]),i.useMemo(()=>({isKeyboardNavigating:e,setIsKeyboardNavigating:r}),[e,r])}function _({label:e,iconLeft:n,iconRight:r,href:s,shouldCloseOnClick:a=!0,decorators:v=[],submenu:x,className:u,onClick:o,...j}){const{isVisible:l,isFocused:c,close:p}=f.usePopoverContext(),{isKeyboardNavigating:d}=y(),m=i.useCallback(w=>{c&&(o==null||o(w),x?x.show():a&&(p==null||p()))},[c,o,x,a,p]),k=i.useMemo(()=>t.jsxRuntimeExports.jsxs(P.default,{as:s?"a":"button",...j,type:s?void 0:"button",role:"menuitem",href:s,disabled:s?void 0:!l,className:M.cx(q.buttonResetStyles,"kakadu-components-3114599304",d?"kakadu-components-4096376656":"kakadu-components-2554182777",u),onClick:m,children:[t.jsxRuntimeExports.jsxs(h.Span,{className:"kakadu-components-1109353535",children:[n?t.jsxRuntimeExports.jsx(R.default,{width:12,height:12,type:n}):null,t.jsxRuntimeExports.jsx("span",{className:"kakadu-components-913703148",children:e}),r?t.jsxRuntimeExports.jsx(R.default,{width:12,height:12,type:r}):null]}),d?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(g.default,{size:150,className:g.normalBlendStyles}),t.jsxRuntimeExports.jsx(I.default,{size:100})]})]}),[s,j,l,d,u,m,n,e,r]);return t.jsxRuntimeExports.jsx(S.default,{decorators:v,children:x?t.jsxRuntimeExports.jsx(b,{menu:x.popoverMenu,className:"kakadu-components-1861176543",children:k}):k})}function K(e){if("type"in e){if(e.type==="separator")return t.jsxRuntimeExports.jsx(N.default,{});if(e.type==="group")return t.jsxRuntimeExports.jsx(h.Span,{className:"kakadu-components-1499037363",children:e.label})}return t.jsxRuntimeExports.jsx(_,{...e})}function C({items:e}){const{isFocused:n}=f.usePopoverContext(),[r,s]=i.useState([]),{setIsKeyboardNavigating:a}=y(),v=i.useCallback(u=>{u&&s(o=>o.includes(u)?o:[...o,u])},[]),x=i.useCallback(u=>{n&&(u.currentTarget.focus(),a(!1))},[n,a]);return i.useEffect(()=>{if(!n)return;const u=o=>{const j=r.filter(m=>m.isConnected),l=j.length;if(l===0)return;let c;const p=document.activeElement;let d=p?j.indexOf(p):-1;switch(d===-1&&(d=0),o.key){case"ArrowDown":{c=(d+1)%l;break}case"ArrowUp":{c=(d-1+l)%l;break}case"Home":{c=0;break}case"End":{c=l-1;break}case"Tab":{a(!0);return}}if(c!==void 0){o.preventDefault(),o.stopPropagation();const m=j[c];m&&(m.focus(),a(!0))}};return window.addEventListener("keydown",u,{capture:!0}),()=>{window.removeEventListener("keydown",u,{capture:!0})}},[n,r,a]),t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:e.map((u,o)=>t.jsxRuntimeExports.jsx(K,{...u,reference:v,onMouseEnter:x},o))})}function F({items:e,...n}){return t.jsxRuntimeExports.jsx(f.default,{...n,as:"nav",role:"menu",innerClassName:"kakadu-components-3600436535",children:t.jsxRuntimeExports.jsx(C,{items:e})})}function T(e){const n=i.useMemo(()=>({items:e}),[e]),{show:r,popover:s}=f.usePopover(F,n);return i.useMemo(()=>({show:r,popoverMenu:s}),[r,s])}function b({menu:e,className:n,children:r}){return t.jsxRuntimeExports.jsxs(f.PopoverContainer,{className:n,children:[r,e]})}exports.default=b;exports.usePopoverMenu=T;
@@ -3,9 +3,9 @@ import { cx as M } from "@kuma-ui/core";
3
3
  import { useMemo as v, useState as y, useCallback as x, useEffect as w } from "react";
4
4
  import { buttonResetStyles as E } from "../theme.mjs";
5
5
  import h from "../icons/icon.mjs";
6
- import S, { PopoverContainer as K, usePopover as F, usePopoverContext as I } from "./popover.mjs";
6
+ import S, { PopoverContainer as K, usePopover as F, usePopoverContext as b } from "./popover.mjs";
7
7
  import A from "./atom.mjs";
8
- import { Span as b } from "./text.mjs";
8
+ import { Span as I } from "./text.mjs";
9
9
  import D, { normalBlendStyles as H } from "./hover-gradient.mjs";
10
10
  import z from "./click-ripples.mjs";
11
11
  import C from "./separator.mjs";
@@ -45,12 +45,12 @@ function R({
45
45
  isVisible: u,
46
46
  isFocused: c,
47
47
  close: l
48
- } = I(), {
48
+ } = b(), {
49
49
  isKeyboardNavigating: d
50
50
  } = N(), p = x((P) => {
51
51
  c && (r == null || r(P), m ? m.show() : i && (l == null || l()));
52
52
  }, [c, r, m, i, l]), g = v(() => /* @__PURE__ */ n.jsxs(A, { as: o ? "a" : "button", ...f, type: o ? void 0 : "button", role: "menuitem", href: o, disabled: o ? void 0 : !u, className: M(E, "kakadu-components-3114599304", d ? "kakadu-components-4096376656" : "kakadu-components-2554182777", a), onClick: p, children: [
53
- /* @__PURE__ */ n.jsxs(b, { className: "kakadu-components-1109353535", children: [
53
+ /* @__PURE__ */ n.jsxs(I, { className: "kakadu-components-1109353535", children: [
54
54
  t ? /* @__PURE__ */ n.jsx(h, { width: 12, height: 12, type: t }) : null,
55
55
  /* @__PURE__ */ n.jsx("span", { className: "kakadu-components-913703148", children: e }),
56
56
  s ? /* @__PURE__ */ n.jsx(h, { width: 12, height: 12, type: s }) : null
@@ -62,21 +62,21 @@ function R({
62
62
  ] }), [o, f, u, d, a, p, t, e, s]);
63
63
  return /* @__PURE__ */ n.jsx(L, { decorators: k, children: m ? /* @__PURE__ */ n.jsx(U, { menu: m.popoverMenu, className: "kakadu-components-1861176543", children: g }) : g });
64
64
  }
65
- function B(e) {
65
+ function T(e) {
66
66
  if ("type" in e) {
67
67
  if (e.type === "separator")
68
68
  return /* @__PURE__ */ n.jsx(C, {});
69
69
  if (e.type === "group")
70
- return /* @__PURE__ */ n.jsx(b, { className: "kakadu-components-1499037363", children: e.label });
70
+ return /* @__PURE__ */ n.jsx(I, { className: "kakadu-components-1499037363", children: e.label });
71
71
  }
72
72
  return /* @__PURE__ */ n.jsx(R, { ...e });
73
73
  }
74
- function G({
74
+ function B({
75
75
  items: e
76
76
  }) {
77
77
  const {
78
78
  isFocused: t
79
- } = I(), [s, o] = y([]), {
79
+ } = b(), [s, o] = y([]), {
80
80
  setIsKeyboardNavigating: i
81
81
  } = N(), k = x((a) => {
82
82
  a && o((r) => r.includes(a) ? r : [...r, a]);
@@ -110,6 +110,10 @@ function G({
110
110
  c = u - 1;
111
111
  break;
112
112
  }
113
+ case "Tab": {
114
+ i(!0);
115
+ return;
116
+ }
113
117
  }
114
118
  if (c !== void 0) {
115
119
  r.preventDefault(), r.stopPropagation();
@@ -125,7 +129,7 @@ function G({
125
129
  });
126
130
  };
127
131
  }, [t, s, i]), /* @__PURE__ */ n.jsx(n.Fragment, { children: e.map((a, r) => /* @__PURE__ */ n.jsx(
128
- B,
132
+ T,
129
133
  {
130
134
  ...a,
131
135
  reference: k,
@@ -134,11 +138,11 @@ function G({
134
138
  r
135
139
  )) });
136
140
  }
137
- function T({
141
+ function G({
138
142
  items: e,
139
143
  ...t
140
144
  }) {
141
- return /* @__PURE__ */ n.jsx(S, { ...t, as: "nav", role: "menu", innerClassName: "kakadu-components-3600436535", children: /* @__PURE__ */ n.jsx(G, { items: e }) });
145
+ return /* @__PURE__ */ n.jsx(S, { ...t, as: "nav", role: "menu", innerClassName: "kakadu-components-3600436535", children: /* @__PURE__ */ n.jsx(B, { items: e }) });
142
146
  }
143
147
  function ne(e) {
144
148
  const t = v(() => ({
@@ -146,7 +150,7 @@ function ne(e) {
146
150
  }), [e]), {
147
151
  show: s,
148
152
  popover: o
149
- } = F(T, t);
153
+ } = F(G, t);
150
154
  return v(() => ({
151
155
  show: s,
152
156
  popoverMenu: o
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kakadu/components",
3
- "version": "3.2.4",
3
+ "version": "3.2.5",
4
4
  "description": "Kakadu components library",
5
5
  "license": "MIT",
6
6
  "main": "./build/index.js",