wimui 0.61.0 → 0.62.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.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../overlay/Portal/Portal.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../overlay/FocusTrap/FocusTrap.cjs"),a=require("../../../i18n/generated/components.cjs"),o=require("../../../icon/search.cjs"),s=require("../../media/Icon/Icon.cjs"),c=require("../../_internal/BaseListItem/BaseListItem.cjs"),l=require("./command-palette.module.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("classnames");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p=(0,u.createContext)(void 0),m=()=>{let e=(0,u.useContext)(p);if(!e)throw Error(`CommandPalette sub-components must be used within a CommandPalette`);return e},h=({children:e,open:t,onOpenChange:n})=>{let[r,i]=(0,u.useState)(!1),[a,o]=(0,u.useState)(``),[s,c]=(0,u.useState)(0),[l,d]=(0,u.useState)(!1),m=(0,u.useRef)(0),h=t!==void 0,g=h?t:r,_=(0,u.useCallback)(e=>{h||i(e),n?.(e),e||(o(``),c(0))},[h,n]),v=(0,u.useCallback)(()=>{let e=m.current;return m.current+=1,e},[]),y=(0,u.useCallback)(()=>{--m.current},[]);m.current=0,(0,u.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),d(!0),_(!g)),e.key===`Escape`&&g&&_(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,_]);let b=u.default.useMemo(()=>({open:g,onOpenChange:_,search:a,setSearch:o,activeIndex:s,setActiveIndex:c,registerItem:v,unregisterItem:y,isKeyboardNavigating:l,setIsKeyboardNavigating:d}),[g,_,a,s,v,y,l]);return(0,f.jsx)(p.Provider,{value:b,children:e})},g=({children:e,asChild:t,className:n})=>{let{onOpenChange:r,setIsKeyboardNavigating:i}=m(),a=e=>{i(e.detail===0),r(!0)};return t&&u.default.isValidElement(e)?u.default.cloneElement(e,{onClick:t=>{e.props.onClick?.(t),a(t)},className:(0,d.default)(n,e.props.className)}):(0,f.jsx)(`button`,{className:(0,d.default)(l.default.trigger,n),onClick:a,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&i(!0)},children:e})},_=({children:e,className:o,"aria-label":s})=>{let{t:c}=t.useWimTranslation(a.componentsNs),{open:p,onOpenChange:h,activeIndex:g,setActiveIndex:_,isKeyboardNavigating:v,setIsKeyboardNavigating:y}=m(),b=(0,u.useRef)(null);return(0,f.jsx)(n.Portal,{children:(0,f.jsx)(r.Transition,{show:p,preset:`fade`,children:(0,f.jsx)(`div`,{role:`presentation`,className:l.default.overlay,onClick:e=>{e.target===e.currentTarget&&h(!1)},children:(0,f.jsx)(r.Transition,{show:p,preset:`scale`,children:(0,f.jsx)(i.FocusTrap,{active:p,children:(0,f.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":s??c(`command_palette.label`),className:(0,d.default)(`wim-command-palette`,l.default.content,o),onClick:e=>e.stopPropagation(),onMouseMove:e=>{if(!b.current){b.current={x:e.clientX,y:e.clientY};return}Math.sqrt((e.clientX-b.current.x)**2+(e.clientY-b.current.y)**2)>10&&y(!1),b.current={x:e.clientX,y:e.clientY}},"data-keyboard-nav":v,onKeyDown:e=>{y(!0);let t=e.currentTarget.querySelectorAll(`.${l.default.item}:not([aria-disabled="true"])`).length;t!==0&&(e.key===`ArrowDown`?(e.preventDefault(),_(e=>(e+1)%t)):e.key===`ArrowUp`?(e.preventDefault(),_(e=>(e-1+t)%t)):e.key===`Home`?(e.preventDefault(),_(0)):e.key===`End`?(e.preventDefault(),_(t-1)):e.key===`Enter`&&(e.preventDefault(),document.getElementById(`wim-command-palette-item-${g}`)?.click()))},children:e})})})})})})},v=({placeholder:e,value:t,onChange:n,rightSection:r})=>{let{search:i,setSearch:a,setActiveIndex:c,activeIndex:d}=m(),p=(0,u.useRef)(null);return(0,u.useEffect)(()=>{p.current?.focus()},[]),(0,f.jsxs)(`div`,{className:l.default.inputWrapper,children:[(0,f.jsx)(s.Icon,{component:o.default,size:`sm`}),(0,f.jsx)(`input`,{ref:p,className:l.default.input,placeholder:e,value:t??i,onChange:e=>{let t=e.target.value;a(t),c(0),n?.(t)},role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":!0,"aria-controls":`wim-command-palette-listbox`,"aria-activedescendant":`wim-command-palette-item-${d}`}),r&&(0,f.jsx)(`div`,{className:l.default.inputRight,children:r})]})},y=({children:e,"aria-label":n,"aria-labelledby":r})=>{let{t:i}=t.useWimTranslation(a.componentsNs);return(0,f.jsx)(`div`,{className:l.default.list,role:`listbox`,id:`wim-command-palette-listbox`,"aria-label":r?void 0:n??i(`command_palette.label`),"aria-labelledby":r,children:e})},b=({children:e,heading:t})=>{let n=u.default.useId();return(0,f.jsxs)(`div`,{className:l.default.group,role:`group`,"aria-labelledby":t?n:void 0,children:[t&&(0,f.jsx)(`div`,{id:n,className:l.default.groupHeading,"aria-hidden":`true`,children:t}),e]})},x=({children:e,onSelect:t,icon:n,shortcut:r,disabled:i})=>{let{activeIndex:a,setActiveIndex:o,registerItem:s,onOpenChange:d}=m(),[p]=(0,u.useState)(()=>s()),h=a===p;return(0,u.useEffect)(()=>{h&&!i&&document.getElementById(`wim-command-palette-item-${p}`)?.scrollIntoView({block:`nearest`})},[h,i,p]),(0,f.jsx)(c.BaseListItem,{role:`option`,id:`wim-command-palette-item-${p}`,"aria-selected":h,className:l.default.item,active:h,disabled:i,icon:n,rightSection:r&&(0,f.jsx)(`div`,{className:l.default.shortcut,children:r.map(e=>(0,f.jsx)(`kbd`,{className:l.default.kbd,children:e},e))}),onMouseEnter:()=>!i&&o(p),onClick:()=>{i||(t?.(),d(!1))},children:e})},S=({children:e})=>{let{t:n}=t.useWimTranslation(a.componentsNs),r=e??n(`command_palette.no_results`),{open:i,search:o}=m(),[s,c]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{if(i){let e=setTimeout(()=>{let e=document.querySelectorAll(`.${l.default.item}`);c(e.length===0)},0);return()=>clearTimeout(e)}},[i,o]),!i||!s?null:(0,f.jsx)(`div`,{className:l.default.empty,children:r})},C=({children:e})=>(0,f.jsx)(`div`,{className:l.default.footer,children:e});exports.CommandPalette=h,exports.CommandPaletteContent=_,exports.CommandPaletteEmpty=S,exports.CommandPaletteFooter=C,exports.CommandPaletteGroup=b,exports.CommandPaletteInput=v,exports.CommandPaletteItem=x,exports.CommandPaletteList=y,exports.CommandPaletteTrigger=g;
2
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../overlay/Portal/Portal.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../overlay/FocusTrap/FocusTrap.cjs"),a=require("../../../i18n/generated/components.cjs"),o=require("../../../icon/search.cjs"),s=require("../../media/Icon/Icon.cjs"),c=require("../../_internal/BaseListItem/BaseListItem.cjs"),l=require("./command-palette.module.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("classnames");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p=(0,u.createContext)(void 0),m=()=>{let e=(0,u.useContext)(p);if(!e)throw Error(`CommandPalette sub-components must be used within a CommandPalette`);return e},h=({children:e,open:t,onOpenChange:n})=>{let[r,i]=(0,u.useState)(!1),[a,o]=(0,u.useState)(``),[s,c]=(0,u.useState)(0),[l,d]=(0,u.useState)(!1),m=(0,u.useRef)(0),h=t!==void 0,g=h?t:r,_=(0,u.useCallback)(e=>{h||i(e),n?.(e),e||(o(``),c(0))},[h,n]),v=(0,u.useCallback)(()=>{let e=m.current;return m.current+=1,e},[]),y=(0,u.useCallback)(()=>{--m.current},[]);m.current=0,(0,u.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),d(!0),_(!g)),e.key===`Escape`&&g&&_(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,_]);let b=u.default.useMemo(()=>({open:g,onOpenChange:_,search:a,setSearch:o,activeIndex:s,setActiveIndex:c,registerItem:v,unregisterItem:y,isKeyboardNavigating:l,setIsKeyboardNavigating:d}),[g,_,a,s,v,y,l]);return(0,f.jsx)(p.Provider,{value:b,children:e})},g=({children:e,asChild:t,className:n})=>{let{onOpenChange:r,setIsKeyboardNavigating:i}=m(),a=e=>{i(e.detail===0),r(!0)};return t&&u.default.isValidElement(e)?u.default.cloneElement(e,{onClick:t=>{e.props.onClick?.(t),a(t)},className:(0,d.default)(n,e.props.className)}):(0,f.jsx)(`button`,{className:(0,d.default)(l.default.trigger,n),onClick:a,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&i(!0)},children:e})},_=({children:e,className:o,"aria-label":s,"aria-labelledby":c,"aria-describedby":p})=>{let{t:h}=t.useWimTranslation(a.componentsNs),{open:g,onOpenChange:_,activeIndex:v,setActiveIndex:y,isKeyboardNavigating:b,setIsKeyboardNavigating:x}=m(),S=(0,u.useRef)(null);return(0,f.jsx)(n.Portal,{children:(0,f.jsx)(r.Transition,{show:g,preset:`fade`,children:(0,f.jsx)(`div`,{role:`presentation`,className:l.default.overlay,onClick:e=>{e.target===e.currentTarget&&_(!1)},children:(0,f.jsx)(r.Transition,{show:g,preset:`scale`,children:(0,f.jsx)(i.FocusTrap,{active:g,children:(0,f.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":c?void 0:s??h(`command_palette.label`),"aria-labelledby":c,"aria-describedby":p,className:(0,d.default)(`wim-command-palette`,l.default.content,o),onClick:e=>e.stopPropagation(),onMouseMove:e=>{if(!S.current){S.current={x:e.clientX,y:e.clientY};return}Math.sqrt((e.clientX-S.current.x)**2+(e.clientY-S.current.y)**2)>10&&x(!1),S.current={x:e.clientX,y:e.clientY}},"data-keyboard-nav":b,onKeyDown:e=>{x(!0);let t=e.currentTarget.querySelectorAll(`.${l.default.item}:not([aria-disabled="true"])`).length;t!==0&&(e.key===`ArrowDown`?(e.preventDefault(),y(e=>(e+1)%t)):e.key===`ArrowUp`?(e.preventDefault(),y(e=>(e-1+t)%t)):e.key===`Home`?(e.preventDefault(),y(0)):e.key===`End`?(e.preventDefault(),y(t-1)):e.key===`Enter`&&(e.preventDefault(),document.getElementById(`wim-command-palette-item-${v}`)?.click()))},children:e})})})})})})},v=({placeholder:e,value:t,onChange:n,rightSection:r})=>{let{search:i,setSearch:a,setActiveIndex:c,activeIndex:d}=m(),p=(0,u.useRef)(null);return(0,u.useEffect)(()=>{p.current?.focus()},[]),(0,f.jsxs)(`div`,{className:l.default.inputWrapper,children:[(0,f.jsx)(s.Icon,{component:o.default,size:`sm`}),(0,f.jsx)(`input`,{ref:p,className:l.default.input,placeholder:e,value:t??i,onChange:e=>{let t=e.target.value;a(t),c(0),n?.(t)},role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":!0,"aria-controls":`wim-command-palette-listbox`,"aria-activedescendant":`wim-command-palette-item-${d}`}),r&&(0,f.jsx)(`div`,{className:l.default.inputRight,children:r})]})},y=({children:e,"aria-label":n,"aria-labelledby":r})=>{let{t:i}=t.useWimTranslation(a.componentsNs);return(0,f.jsx)(`div`,{className:l.default.list,role:`listbox`,id:`wim-command-palette-listbox`,"aria-label":r?void 0:n??i(`command_palette.label`),"aria-labelledby":r,children:e})},b=({children:e,heading:t})=>{let n=u.default.useId();return(0,f.jsxs)(`div`,{className:l.default.group,role:`group`,"aria-labelledby":t?n:void 0,children:[t&&(0,f.jsx)(`div`,{id:n,className:l.default.groupHeading,"aria-hidden":`true`,children:t}),e]})},x=({children:e,onSelect:t,icon:n,shortcut:r,disabled:i})=>{let{activeIndex:a,setActiveIndex:o,registerItem:s,onOpenChange:d}=m(),[p]=(0,u.useState)(()=>s()),h=a===p;return(0,u.useEffect)(()=>{h&&!i&&document.getElementById(`wim-command-palette-item-${p}`)?.scrollIntoView({block:`nearest`})},[h,i,p]),(0,f.jsx)(c.BaseListItem,{role:`option`,id:`wim-command-palette-item-${p}`,"aria-selected":h,className:l.default.item,active:h,disabled:i,icon:n,rightSection:r&&(0,f.jsx)(`div`,{className:l.default.shortcut,children:r.map(e=>(0,f.jsx)(`kbd`,{className:l.default.kbd,children:e},e))}),onMouseEnter:()=>!i&&o(p),onClick:()=>{i||(t?.(),d(!1))},children:e})},S=({children:e})=>{let{t:n}=t.useWimTranslation(a.componentsNs),r=e??n(`command_palette.no_results`),{open:i,search:o}=m(),[s,c]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{if(i){let e=setTimeout(()=>{let e=document.querySelectorAll(`.${l.default.item}`);c(e.length===0)},0);return()=>clearTimeout(e)}},[i,o]),!i||!s?null:(0,f.jsx)(`div`,{className:l.default.empty,children:r})},C=({children:e})=>(0,f.jsx)(`div`,{className:l.default.footer,children:e});exports.CommandPalette=h,exports.CommandPaletteContent=_,exports.CommandPaletteEmpty=S,exports.CommandPaletteFooter=C,exports.CommandPaletteGroup=b,exports.CommandPaletteInput=v,exports.CommandPaletteItem=x,exports.CommandPaletteList=y,exports.CommandPaletteTrigger=g;
@@ -29,8 +29,12 @@ export interface CommandPaletteContentProps {
29
29
  * (serious), and the palette has no heading to borrow one from.
30
30
  */
31
31
  "aria-label"?: string;
32
+ /** ID of the element that labels the dialog. Takes precedence over `aria-label` and the built-in name. */
33
+ "aria-labelledby"?: string;
34
+ /** ID of the element that describes the dialog. */
35
+ "aria-describedby"?: string;
32
36
  }
33
- export declare const CommandPaletteContent: ({ children, className, "aria-label": ariaLabel, }: CommandPaletteContentProps) => React.JSX.Element;
37
+ export declare const CommandPaletteContent: ({ children, className, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, }: CommandPaletteContentProps) => React.JSX.Element;
34
38
  export interface CommandPaletteInputProps {
35
39
  placeholder?: string;
36
40
  value?: string;
@@ -72,46 +72,48 @@ var y = u(void 0), b = () => {
72
72
  },
73
73
  children: e
74
74
  });
75
- }, C = ({ children: a, className: o, "aria-label": s }) => {
76
- let { t: l } = e(i), { open: u, onOpenChange: d, activeIndex: f, setActiveIndex: p, isKeyboardNavigating: h, setIsKeyboardNavigating: v } = b(), y = m(null);
75
+ }, C = ({ children: a, className: o, "aria-label": s, "aria-labelledby": l, "aria-describedby": u }) => {
76
+ let { t: d } = e(i), { open: f, onOpenChange: p, activeIndex: h, setActiveIndex: v, isKeyboardNavigating: y, setIsKeyboardNavigating: x } = b(), S = m(null);
77
77
  return /* @__PURE__ */ _(t, { children: /* @__PURE__ */ _(n, {
78
- show: u,
78
+ show: f,
79
79
  preset: "fade",
80
80
  children: /* @__PURE__ */ _("div", {
81
81
  role: "presentation",
82
82
  className: c.overlay,
83
83
  onClick: (e) => {
84
- e.target === e.currentTarget && d(!1);
84
+ e.target === e.currentTarget && p(!1);
85
85
  },
86
86
  children: /* @__PURE__ */ _(n, {
87
- show: u,
87
+ show: f,
88
88
  preset: "scale",
89
89
  children: /* @__PURE__ */ _(r, {
90
- active: u,
90
+ active: f,
91
91
  children: /* @__PURE__ */ _("div", {
92
92
  role: "dialog",
93
93
  "aria-modal": "true",
94
- "aria-label": s ?? l("command_palette.label"),
94
+ "aria-label": l ? void 0 : s ?? d("command_palette.label"),
95
+ "aria-labelledby": l,
96
+ "aria-describedby": u,
95
97
  className: g("wim-command-palette", c.content, o),
96
98
  onClick: (e) => e.stopPropagation(),
97
99
  onMouseMove: (e) => {
98
- if (!y.current) {
99
- y.current = {
100
+ if (!S.current) {
101
+ S.current = {
100
102
  x: e.clientX,
101
103
  y: e.clientY
102
104
  };
103
105
  return;
104
106
  }
105
- Math.sqrt((e.clientX - y.current.x) ** 2 + (e.clientY - y.current.y) ** 2) > 10 && v(!1), y.current = {
107
+ Math.sqrt((e.clientX - S.current.x) ** 2 + (e.clientY - S.current.y) ** 2) > 10 && x(!1), S.current = {
106
108
  x: e.clientX,
107
109
  y: e.clientY
108
110
  };
109
111
  },
110
- "data-keyboard-nav": h,
112
+ "data-keyboard-nav": y,
111
113
  onKeyDown: (e) => {
112
- v(!0);
114
+ x(!0);
113
115
  let t = e.currentTarget.querySelectorAll(`.${c.item}:not([aria-disabled="true"])`).length;
114
- t !== 0 && (e.key === "ArrowDown" ? (e.preventDefault(), p((e) => (e + 1) % t)) : e.key === "ArrowUp" ? (e.preventDefault(), p((e) => (e - 1 + t) % t)) : e.key === "Home" ? (e.preventDefault(), p(0)) : e.key === "End" ? (e.preventDefault(), p(t - 1)) : e.key === "Enter" && (e.preventDefault(), document.getElementById(`wim-command-palette-item-${f}`)?.click()));
116
+ t !== 0 && (e.key === "ArrowDown" ? (e.preventDefault(), v((e) => (e + 1) % t)) : e.key === "ArrowUp" ? (e.preventDefault(), v((e) => (e - 1 + t) % t)) : e.key === "Home" ? (e.preventDefault(), v(0)) : e.key === "End" ? (e.preventDefault(), v(t - 1)) : e.key === "Enter" && (e.preventDefault(), document.getElementById(`wim-command-palette-item-${h}`)?.click()));
115
117
  },
116
118
  children: a
117
119
  })
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## What this is
6
6
 
7
- **wimui** v0.61.0 — a React 19 component library: 228 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
7
+ **wimui** v0.62.0 — a React 19 component library: 228 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
8
8
 
9
9
  ## Install & required setup
10
10
 
package/dist/llms.txt CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## What this is
6
6
 
7
- **wimui** v0.61.0 — a React 19 component library: 228 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
7
+ **wimui** v0.62.0 — a React 19 component library: 228 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
8
8
 
9
9
  ## Install & required setup
10
10