wimui 0.5.2 → 0.6.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 (50) hide show
  1. package/dist/components/_internal/status-content.module.cjs +1 -1
  2. package/dist/components/_internal/status-content.module.js +1 -1
  3. package/dist/components/ai/ChatUI/ChatUI.cjs +1 -1
  4. package/dist/components/ai/ChatUI/ChatUI.js +80 -79
  5. package/dist/components/data-display/Calendar/Calendar.cjs +1 -1
  6. package/dist/components/data-display/Calendar/Calendar.js +88 -87
  7. package/dist/components/data-display/Card/card.module.cjs +1 -1
  8. package/dist/components/data-display/Card/card.module.js +15 -12
  9. package/dist/components/data-display/DataGrid/DataGrid.cjs +1 -1
  10. package/dist/components/data-display/DataGrid/DataGrid.d.ts +11 -4
  11. package/dist/components/data-display/DataGrid/DataGrid.js +52 -60
  12. package/dist/components/data-display/DataGrid/datagrid.module.cjs +1 -1
  13. package/dist/components/data-display/DataGrid/datagrid.module.js +15 -13
  14. package/dist/components/data-display/Kanban/Kanban.cjs +1 -1
  15. package/dist/components/data-display/Kanban/Kanban.js +87 -86
  16. package/dist/components/data-display/Table/Table.cjs +1 -1
  17. package/dist/components/data-display/Table/Table.d.ts +3 -2
  18. package/dist/components/data-display/Table/Table.js +1 -1
  19. package/dist/components/data-display/Table/table.module.cjs +1 -1
  20. package/dist/components/data-display/Table/table.module.js +28 -27
  21. package/dist/components/data-display/Tag/Tag.cjs +1 -1
  22. package/dist/components/data-display/Tag/Tag.js +34 -30
  23. package/dist/components/form/Button/button.module.cjs +1 -1
  24. package/dist/components/form/Button/button.module.js +2 -2
  25. package/dist/components/form/ImageCropper/ImageCropper.cjs +1 -1
  26. package/dist/components/form/ImageCropper/ImageCropper.js +1 -1
  27. package/dist/components/form/InlineEdit/InlineEdit.cjs +1 -1
  28. package/dist/components/form/InlineEdit/InlineEdit.js +31 -28
  29. package/dist/components/layout/Container/container.module.cjs +1 -1
  30. package/dist/components/layout/Container/container.module.js +1 -1
  31. package/dist/components/layout/Toolbar/toolbar.module.cjs +1 -1
  32. package/dist/components/layout/Toolbar/toolbar.module.js +4 -4
  33. package/dist/components/media/Audio/Audio.cjs +1 -1
  34. package/dist/components/media/Audio/Audio.js +66 -65
  35. package/dist/components/overlay/Dropdown/Dropdown.cjs +1 -1
  36. package/dist/components/overlay/Dropdown/Dropdown.js +106 -73
  37. package/dist/components/overlay/Dropdown/dropdown.module.cjs +1 -1
  38. package/dist/components/overlay/Dropdown/dropdown.module.js +3 -5
  39. package/dist/i18n/generated/keys.d.ts +1 -1
  40. package/dist/i18n/generated/resources.cjs +1 -1
  41. package/dist/i18n/generated/resources.js +44 -2
  42. package/dist/llms-full.txt +12 -4
  43. package/dist/llms.txt +3 -1
  44. package/dist/locales/en/common.json +12 -0
  45. package/dist/locales/ja/common.json +13 -1
  46. package/dist/locales/pt/common.json +13 -1
  47. package/dist/styles.css +1 -1
  48. package/dist/wimui.umd.css +1 -1
  49. package/dist/wimui.umd.js +2 -2
  50. package/package.json +27 -1
@@ -1,6 +1,7 @@
1
1
  "use client";
2
- import { useMediaLoader as e } from "../../../hooks/useMediaLoader.js";
3
- import { useAudioPlayer as t } from "./hooks/useAudioPlayer.js";
2
+ import { useWimTranslation as e } from "../../../i18n/useWimTranslation.js";
3
+ import { useMediaLoader as t } from "../../../hooks/useMediaLoader.js";
4
+ import { useAudioPlayer as ee } from "./hooks/useAudioPlayer.js";
4
5
  import { useAudioMetadata as n } from "./hooks/useAudioMetadata.js";
5
6
  import { AudioCustomControls as r } from "./components/AudioCustomControls.js";
6
7
  import i from "./audio.module.js";
@@ -8,40 +9,40 @@ import { useEffect as a, useMemo as o } from "react";
8
9
  import s from "classnames";
9
10
  import { jsx as c, jsxs as l } from "react/jsx-runtime";
10
11
  //#region src/components/media/Audio/Audio.tsx
11
- var u = ({ src: u, autoPlay: d = !1, loop: f = !1, muted: p = !1, controls: ee = !0, radius: m = "none", shadow: h = !1, border: te = !1, preload: g, caption: _, className: v, style: y, customControls: b = !1, visualizer: x = !1, showMetadata: S = !1, fadeIn: C = !1, fadeOut: ne = !1, crossfade: w = !1, playbackRate: T = !1, hotkeys: E = !1, presets: D = !1, sleepTimer: O = !1, loading: k = "lazy", demoDelay: A, labels: j = {}, tracks: M, ...N }) => {
12
- let { unknownTitle: P = "Unknown Title", unknownArtist: F = "Unknown Artist" } = j, I = o(() => u ? (Array.isArray(u) ? u : [u]).map((e) => typeof e == "string" ? { src: e } : e) : [], [u]), { containerRef: L, isLoaded: R, isIntersecting: re, notifyLoaded: z, shouldShowSkeleton: B } = e({
13
- loading: k,
14
- demoDelay: A,
15
- src: I[0]?.src
16
- }), V = t({
17
- playlist: I,
18
- loop: f,
19
- muted: p,
12
+ var u = ({ src: u, autoPlay: d = !1, loop: te = !1, muted: ne = !1, controls: f = !0, radius: p = "none", shadow: m = !1, border: h = !1, preload: g, caption: _, className: v, style: y, customControls: b = !1, visualizer: x = !1, showMetadata: S = !1, fadeIn: C = !1, fadeOut: w = !1, crossfade: T = !1, playbackRate: E = !1, hotkeys: D = !1, presets: O = !1, sleepTimer: k = !1, loading: A = "lazy", demoDelay: j, labels: M = {}, tracks: N, ...P }) => {
13
+ let { t: F } = e("common"), { unknownTitle: I = "Unknown Title", unknownArtist: L = "Unknown Artist" } = M, R = o(() => u ? (Array.isArray(u) ? u : [u]).map((e) => typeof e == "string" ? { src: e } : e) : [], [u]), { containerRef: re, isLoaded: z, isIntersecting: B, notifyLoaded: V, shouldShowSkeleton: H } = t({
14
+ loading: A,
15
+ demoDelay: j,
16
+ src: R[0]?.src
17
+ }), U = ee({
18
+ playlist: R,
19
+ loop: te,
20
+ muted: ne,
20
21
  fadeIn: C,
21
- fadeOut: ne,
22
- crossfade: w,
22
+ fadeOut: w,
23
+ crossfade: T,
23
24
  visualizer: x,
24
- hotkeys: E,
25
+ hotkeys: D,
25
26
  autoPlay: d
26
- }), { isPlaying: H, currentTrack: U, currentTrackIndex: W, activeAudioRef: G, nextAudioRef: K, canvasRef: q, handleTimeUpdate: J, handleEnded: Y, setDuration: X, playActivePlayer: ie } = V, { metaTitle: Z, metaArtist: Q, metaCover: $ } = n({
27
- currentTrack: U,
27
+ }), { isPlaying: W, currentTrack: G, currentTrackIndex: K, activeAudioRef: q, nextAudioRef: J, canvasRef: Y, handleTimeUpdate: X, handleEnded: ie, setDuration: ae, playActivePlayer: oe } = U, { metaTitle: Z, metaArtist: Q, metaCover: $ } = n({
28
+ currentTrack: G,
28
29
  showMetadata: S
29
30
  });
30
31
  a(() => {
31
- !U || !G.current || (G.current.src = U.src, (d || H) && ie());
32
- }, [W, U]);
33
- let ae = m === "none" ? null : i[`radius${m.charAt(0).toUpperCase() + m.slice(1)}`];
32
+ !G || !q.current || (q.current.src = G.src, (d || W) && oe());
33
+ }, [K, G]);
34
+ let se = p === "none" ? null : i[`radius${p.charAt(0).toUpperCase() + p.slice(1)}`];
34
35
  return /* @__PURE__ */ l("figure", {
35
36
  className: s("wim-audio", i.root, v),
36
37
  style: y,
37
38
  "data-testid": "audio-root",
38
39
  children: [/* @__PURE__ */ l("div", {
39
- ref: L,
40
- className: s(i.inner, ae, b && h && i.shadow, b && te && i.border, b && i.custom, x && b && i.hasVisualizer, C && i.fadeIn, C && R && i.isLoaded, B && i.loading),
40
+ ref: re,
41
+ className: s(i.inner, se, b && m && i.shadow, b && h && i.border, b && i.custom, x && b && i.hasVisualizer, C && i.fadeIn, C && z && i.isLoaded, H && i.loading),
41
42
  "data-testid": "audio-inner",
42
43
  children: [
43
44
  x && b && /* @__PURE__ */ c("canvas", {
44
- ref: q,
45
+ ref: Y,
45
46
  className: i.visualizerCanvas,
46
47
  "data-testid": "audio-canvas"
47
48
  }),
@@ -54,7 +55,7 @@ var u = ({ src: u, autoPlay: d = !1, loop: f = !1, muted: p = !1, controls: ee =
54
55
  "data-testid": "audio-metadata",
55
56
  children: [$ && /* @__PURE__ */ c("img", {
56
57
  src: $,
57
- alt: "Cover",
58
+ alt: F("a11y.cover_art"),
58
59
  className: i.cover,
59
60
  "data-testid": "audio-cover"
60
61
  }), /* @__PURE__ */ l("div", {
@@ -62,11 +63,11 @@ var u = ({ src: u, autoPlay: d = !1, loop: f = !1, muted: p = !1, controls: ee =
62
63
  children: [/* @__PURE__ */ c("div", {
63
64
  className: i.title,
64
65
  "data-testid": "audio-title",
65
- children: Z || P
66
+ children: Z || I
66
67
  }), /* @__PURE__ */ c("div", {
67
68
  className: i.artist,
68
69
  "data-testid": "audio-artist",
69
- children: Q || F
70
+ children: Q || L
70
71
  })]
71
72
  })]
72
73
  }),
@@ -75,32 +76,32 @@ var u = ({ src: u, autoPlay: d = !1, loop: f = !1, muted: p = !1, controls: ee =
75
76
  display: b ? "none" : "block",
76
77
  width: "100%"
77
78
  },
78
- children: [re && /* @__PURE__ */ c("audio", {
79
- ref: G,
80
- src: U?.src,
79
+ children: [B && /* @__PURE__ */ c("audio", {
80
+ ref: q,
81
+ src: G?.src,
81
82
  className: i.audio,
82
83
  "data-testid": "audio-active",
83
- loop: V.repeatMode === 1 && I.length === 1,
84
- muted: V.isMuted,
85
- controls: !b && ee,
84
+ loop: U.repeatMode === 1 && R.length === 1,
85
+ muted: U.isMuted,
86
+ controls: !b && f,
86
87
  preload: g,
87
88
  crossOrigin: "anonymous",
88
- onTimeUpdate: J,
89
- onEnded: Y,
90
- ...N,
89
+ onTimeUpdate: X,
90
+ onEnded: ie,
91
+ ...P,
91
92
  onLoadedMetadata: (e) => {
92
- X(e.currentTarget.duration), z(), N.onLoadedMetadata?.(e);
93
+ ae(e.currentTarget.duration), V(), P.onLoadedMetadata?.(e);
93
94
  },
94
95
  onLoadedData: (e) => {
95
- z(), N.onLoadedData?.(e);
96
+ V(), P.onLoadedData?.(e);
96
97
  },
97
98
  onCanPlay: (e) => {
98
- z(), N.onCanPlay?.(e);
99
+ V(), P.onCanPlay?.(e);
99
100
  },
100
- children: M?.map((e, t) => /* @__PURE__ */ c("track", { ...e }, t))
101
+ children: N?.map((e, t) => /* @__PURE__ */ c("track", { ...e }, t))
101
102
  }), /* @__PURE__ */ c("audio", {
102
- ref: K,
103
- muted: V.isMuted,
103
+ ref: J,
104
+ muted: U.isMuted,
104
105
  preload: "auto",
105
106
  crossOrigin: "anonymous",
106
107
  "data-testid": "audio-next"
@@ -108,31 +109,31 @@ var u = ({ src: u, autoPlay: d = !1, loop: f = !1, muted: p = !1, controls: ee =
108
109
  }),
109
110
  b && /* @__PURE__ */ c(r, {
110
111
  styles: i,
111
- isPlaying: H,
112
- currentTime: V.currentTime,
113
- duration: V.duration,
114
- volume: V.volume,
115
- isMuted: V.isMuted,
116
- repeatMode: V.repeatMode,
117
- shuffleMode: V.shuffleMode,
118
- currentPlaybackRate: V.currentPlaybackRate,
119
- isBassBoost: V.isBassBoost,
120
- remainingSleepTime: V.remainingSleepTime,
121
- playbackRate: T,
122
- presets: D,
123
- sleepTimer: O,
124
- setRepeatMode: V.setRepeatMode,
125
- setShuffleMode: V.setShuffleMode,
126
- setCurrentPlaybackRate: V.setCurrentPlaybackRate,
127
- setIsBassBoost: V.setIsBassBoost,
128
- setIsMuted: V.setIsMuted,
129
- togglePlay: V.togglePlay,
130
- handleSeek: V.handleSeek,
131
- handleVolumeChange: V.handleVolumeChange,
132
- playNext: V.playNext,
133
- toggleSleepTimer: V.toggleSleepTimer,
134
- formatTime: V.formatTime,
135
- labels: j
112
+ isPlaying: W,
113
+ currentTime: U.currentTime,
114
+ duration: U.duration,
115
+ volume: U.volume,
116
+ isMuted: U.isMuted,
117
+ repeatMode: U.repeatMode,
118
+ shuffleMode: U.shuffleMode,
119
+ currentPlaybackRate: U.currentPlaybackRate,
120
+ isBassBoost: U.isBassBoost,
121
+ remainingSleepTime: U.remainingSleepTime,
122
+ playbackRate: E,
123
+ presets: O,
124
+ sleepTimer: k,
125
+ setRepeatMode: U.setRepeatMode,
126
+ setShuffleMode: U.setShuffleMode,
127
+ setCurrentPlaybackRate: U.setCurrentPlaybackRate,
128
+ setIsBassBoost: U.setIsBassBoost,
129
+ setIsMuted: U.setIsMuted,
130
+ togglePlay: U.togglePlay,
131
+ handleSeek: U.handleSeek,
132
+ handleVolumeChange: U.handleVolumeChange,
133
+ playNext: U.playNext,
134
+ toggleSleepTimer: U.toggleSleepTimer,
135
+ formatTime: U.formatTime,
136
+ labels: M
136
137
  })
137
138
  ]
138
139
  }), _ && /* @__PURE__ */ c("figcaption", {
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../layout/Transition/Transition.cjs"),r=require("../../_internal/BaseListItem/BaseListItem.cjs"),i=require("../../_internal/mergeRefs.cjs"),a=require("./dropdown.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=o.default.createContext({isOpen:!1,toggle:()=>{},close:()=>{},menuId:``,triggerId:``,focusedIndex:-1,setFocusedIndex:()=>{},registerItem:()=>0,containerRef:{current:null}}),u=(0,o.forwardRef)(({children:e,className:n,asChild:r=!1,...u},d)=>{let[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(-1),g=(0,o.useRef)(null),_=(0,o.useRef)(0),v=i.mergeRefs(g,d);(0,o.useEffect)(()=>{_.current=0});let y=()=>{let e=_.current;return _.current+=1,e},b=(0,o.useId)(),x=`wim-dropdown-menu-${b}`,S=`wim-dropdown-trigger-${b}`,C=()=>{let e=!f;p(e),h(e?0:-1)},w=()=>{p(!1),h(-1)};(0,o.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&w()},t=e=>{e.key===`Escape`&&w()};return f&&(document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t)),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[f]);let T=e=>{if(!f)return;let t=Array.from(g.current?.querySelectorAll(`[role="menuitem"]:not([aria-disabled="true"])`)||[]);switch(e.key){case`ArrowDown`:e.preventDefault(),h(e=>e<t.length-1?e+1:0);break;case`ArrowUp`:e.preventDefault(),h(e=>e>0?e-1:t.length-1);break;case`Home`:e.preventDefault(),h(0);break;case`End`:e.preventDefault(),h(t.length-1);break;case`Tab`:w();break}};(0,o.useEffect)(()=>{f&&m>=0&&Array.from(g.current?.querySelectorAll(`[role="menuitem"]:not([aria-disabled="true"])`)||[])[m]?.focus()},[m,f]);let E=r?t.Root:`div`;return(0,c.jsx)(l.Provider,{value:{isOpen:f,toggle:C,close:w,menuId:x,triggerId:S,focusedIndex:m,setFocusedIndex:h,registerItem:y,containerRef:g},children:(0,c.jsx)(E,{...u,role:`none`,className:(0,s.default)(`wim-dropdown`,a.default.root,n),ref:v,onKeyDown:T,children:(0,c.jsx)(t.Slottable,{children:e})})})});u.displayName=`Dropdown`;var d=(0,o.forwardRef)(({children:e,className:n,asChild:r=!1,...i},u)=>{let{toggle:d,isOpen:f,menuId:p,triggerId:m}=o.default.useContext(l);return(0,c.jsx)(r?t.Root:`div`,{...i,ref:u,id:m,className:(0,s.default)(a.default.trigger,n),onClick:d,"aria-haspopup":`menu`,"aria-expanded":f,"aria-controls":f?p:void 0,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d())},children:(0,c.jsx)(t.Slottable,{children:e})})});d.displayName=`Dropdown.Trigger`;var f=(0,o.forwardRef)(({children:e,className:t,align:r=`left`,show:i,...u},d)=>{let{isOpen:f,menuId:p,triggerId:m}=o.default.useContext(l),h=r===`left`?a.default.alignLeft:a.default.alignRight;return(0,c.jsx)(n.Transition,{...u,ref:d,show:i===void 0?f:i,preset:`fade`,id:p,className:(0,s.default)(a.default.menu,h,t),role:`menu`,"aria-labelledby":m,children:e})});f.displayName=`Dropdown.Menu`;var p=(0,o.forwardRef)(({children:e,onClick:t,disabled:n=!1,className:i,...u},d)=>{let{close:f,focusedIndex:p,setFocusedIndex:m,registerItem:h}=o.default.useContext(l),[g]=(0,o.useState)(()=>h()),_=p===g,v=e=>{n||(e.stopPropagation(),t&&t(),f())};return(0,c.jsx)(r.BaseListItem,{...u,ref:d,className:(0,s.default)(a.default.item,i),onClick:v,onFocus:()=>m(g),disabled:n,role:`menuitem`,tabIndex:_?0:-1,onKeyDown:e=>{!n&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),v(e))},children:e})});p.displayName=`Dropdown.Item`;var m=(0,o.forwardRef)((e,t)=>(0,c.jsx)(u,{...e,ref:t}));m.displayName=`Dropdown`,m.Trigger=d,m.Menu=f,m.Item=p,exports.Dropdown=m,exports.default=m,exports.DropdownItem=p,exports.DropdownMenu=f,exports.DropdownTrigger=d;
2
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../layout/Transition/Transition.cjs"),r=require("../../_internal/BaseListItem/BaseListItem.cjs"),i=require("../../_internal/mergeRefs.cjs"),a=require("./dropdown.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime"),l=require("@floating-ui/react");var u=o.default.createContext({isOpen:!1,toggle:()=>{},close:()=>{},menuId:``,triggerId:``,focusedIndex:-1,setFocusedIndex:()=>{},registerItem:()=>0,containerRef:{current:null},setReference:()=>{},setFloating:()=>{},floatingStyles:{},floatingRef:{current:null},setAlign:()=>{}}),d=(0,o.forwardRef)(({children:e,className:n,asChild:r=!1,...d},f)=>{let[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(-1),_=(0,o.useRef)(null),v=(0,o.useRef)(0),[y,b]=(0,o.useState)(`left`),{refs:x,floatingStyles:S}=(0,l.useFloating)({open:p,placement:y===`right`?`bottom-end`:`bottom-start`,whileElementsMounted:l.autoUpdate,middleware:[(0,l.offset)(4),(0,l.flip)(),(0,l.shift)({padding:8})]}),C=i.mergeRefs(_,f);(0,o.useEffect)(()=>{v.current=0});let w=()=>{let e=v.current;return v.current+=1,e},T=(0,o.useId)(),E=`wim-dropdown-menu-${T}`,D=`wim-dropdown-trigger-${T}`,O=()=>{let e=!p;m(e),g(e?0:-1)},k=()=>{m(!1),g(-1)};(0,o.useEffect)(()=>{let e=e=>{let t=e.target,n=x.floating.current?.contains(t)??!1;_.current&&!_.current.contains(t)&&!n&&k()},t=e=>{e.key===`Escape`&&k()};return p&&(document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t)),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[p,x.floating]);let A=e=>{if(!p)return;let t=Array.from((x.floating.current??_.current)?.querySelectorAll(`[role="menuitem"]:not([aria-disabled="true"])`)||[]);switch(e.key){case`ArrowDown`:e.preventDefault(),g(e=>e<t.length-1?e+1:0);break;case`ArrowUp`:e.preventDefault(),g(e=>e>0?e-1:t.length-1);break;case`Home`:e.preventDefault(),g(0);break;case`End`:e.preventDefault(),g(t.length-1);break;case`Tab`:k();break}};(0,o.useEffect)(()=>{p&&h>=0&&Array.from((x.floating.current??_.current)?.querySelectorAll(`[role="menuitem"]:not([aria-disabled="true"])`)||[])[h]?.focus({preventScroll:!0})},[h,p,x.floating]);let j=r?t.Root:`div`;return(0,c.jsx)(u.Provider,{value:{isOpen:p,toggle:O,close:k,menuId:E,triggerId:D,focusedIndex:h,setFocusedIndex:g,registerItem:w,containerRef:_,setReference:x.setReference,setFloating:x.setFloating,floatingStyles:S,floatingRef:x.floating,setAlign:b},children:(0,c.jsx)(j,{...d,role:`none`,className:(0,s.default)(`wim-dropdown`,a.default.root,n),ref:C,onKeyDown:A,children:(0,c.jsx)(t.Slottable,{children:e})})})});d.displayName=`Dropdown`;var f=(0,o.forwardRef)(({children:e,className:n,asChild:r=!1,...l},d)=>{let{toggle:f,isOpen:p,menuId:m,triggerId:h,setReference:g}=o.default.useContext(u),_=r?t.Root:`div`,v=i.mergeRefs(g,d);return(0,c.jsx)(_,{...l,ref:v,id:h,className:(0,s.default)(a.default.trigger,n),onClick:f,"aria-haspopup":`menu`,"aria-expanded":p,"aria-controls":p?m:void 0,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f())},children:(0,c.jsx)(t.Slottable,{children:e})})});f.displayName=`Dropdown.Trigger`;var p=(0,o.forwardRef)(({children:e,className:t,align:r=`left`,show:d,style:f,...p},m)=>{let{isOpen:h,menuId:g,triggerId:_,setFloating:v,floatingStyles:y,setAlign:b}=o.default.useContext(u);(0,o.useEffect)(()=>{b(r)},[r,b]);let x=i.mergeRefs(v,m);return(0,c.jsx)(l.FloatingPortal,{children:(0,c.jsx)(n.Transition,{...p,ref:x,show:d===void 0?h:d,preset:`fade`,id:g,style:{...y,...f},className:(0,s.default)(a.default.menu,t),role:`menu`,"aria-labelledby":_,children:e})})});p.displayName=`Dropdown.Menu`;var m=(0,o.forwardRef)(({children:e,onClick:t,disabled:n=!1,className:i,...l},d)=>{let{close:f,focusedIndex:p,setFocusedIndex:m,registerItem:h}=o.default.useContext(u),[g]=(0,o.useState)(()=>h()),_=p===g,v=e=>{n||(e.stopPropagation(),t&&t(),f())};return(0,c.jsx)(r.BaseListItem,{...l,ref:d,className:(0,s.default)(a.default.item,i),onClick:v,onFocus:()=>m(g),disabled:n,role:`menuitem`,tabIndex:_?0:-1,onKeyDown:e=>{!n&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),v(e))},children:e})});m.displayName=`Dropdown.Item`;var h=(0,o.forwardRef)((e,t)=>(0,c.jsx)(d,{...e,ref:t}));h.displayName=`Dropdown`,h.Trigger=f,h.Menu=p,h.Item=m,exports.Dropdown=h,exports.default=h,exports.DropdownItem=m,exports.DropdownMenu=p,exports.DropdownTrigger=f;
@@ -7,8 +7,9 @@ import a from "./dropdown.module.js";
7
7
  import o, { forwardRef as s, useEffect as c, useId as l, useRef as u, useState as d } from "react";
8
8
  import f from "classnames";
9
9
  import { jsx as p } from "react/jsx-runtime";
10
+ import { FloatingPortal as m, autoUpdate as h, flip as g, offset as _, shift as v, useFloating as y } from "@floating-ui/react";
10
11
  //#region src/components/overlay/Dropdown/Dropdown.tsx
11
- var m = o.createContext({
12
+ var b = o.createContext({
12
13
  isOpen: !1,
13
14
  toggle: () => {},
14
15
  close: () => {},
@@ -17,138 +18,170 @@ var m = o.createContext({
17
18
  focusedIndex: -1,
18
19
  setFocusedIndex: () => {},
19
20
  registerItem: () => 0,
20
- containerRef: { current: null }
21
- }), h = s(({ children: n, className: r, asChild: o = !1, ...s }, h) => {
22
- let [g, _] = d(!1), [v, y] = d(-1), b = u(null), x = u(0), S = i(b, h);
21
+ containerRef: { current: null },
22
+ setReference: () => {},
23
+ setFloating: () => {},
24
+ floatingStyles: {},
25
+ floatingRef: { current: null },
26
+ setAlign: () => {}
27
+ }), x = s(({ children: n, className: r, asChild: o = !1, ...s }, m) => {
28
+ let [x, S] = d(!1), [C, w] = d(-1), T = u(null), E = u(0), [D, O] = d("left"), { refs: k, floatingStyles: A } = y({
29
+ open: x,
30
+ placement: D === "right" ? "bottom-end" : "bottom-start",
31
+ whileElementsMounted: h,
32
+ middleware: [
33
+ _(4),
34
+ g(),
35
+ v({ padding: 8 })
36
+ ]
37
+ }), j = i(T, m);
23
38
  c(() => {
24
- x.current = 0;
39
+ E.current = 0;
25
40
  });
26
- let C = () => {
27
- let e = x.current;
28
- return x.current += 1, e;
29
- }, w = l(), T = `wim-dropdown-menu-${w}`, E = `wim-dropdown-trigger-${w}`, D = () => {
30
- let e = !g;
31
- _(e), y(e ? 0 : -1);
32
- }, O = () => {
33
- _(!1), y(-1);
41
+ let M = () => {
42
+ let e = E.current;
43
+ return E.current += 1, e;
44
+ }, N = l(), P = `wim-dropdown-menu-${N}`, F = `wim-dropdown-trigger-${N}`, I = () => {
45
+ let e = !x;
46
+ S(e), w(e ? 0 : -1);
47
+ }, L = () => {
48
+ S(!1), w(-1);
34
49
  };
35
50
  c(() => {
36
51
  let e = (e) => {
37
- b.current && !b.current.contains(e.target) && O();
52
+ let t = e.target, n = k.floating.current?.contains(t) ?? !1;
53
+ T.current && !T.current.contains(t) && !n && L();
38
54
  }, t = (e) => {
39
- e.key === "Escape" && O();
55
+ e.key === "Escape" && L();
40
56
  };
41
- return g && (document.addEventListener("mousedown", e), document.addEventListener("keydown", t)), () => {
57
+ return x && (document.addEventListener("mousedown", e), document.addEventListener("keydown", t)), () => {
42
58
  document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
43
59
  };
44
- }, [g]);
45
- let k = (e) => {
46
- if (!g) return;
47
- let t = Array.from(b.current?.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"])") || []);
60
+ }, [x, k.floating]);
61
+ let R = (e) => {
62
+ if (!x) return;
63
+ let t = Array.from((k.floating.current ?? T.current)?.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"])") || []);
48
64
  switch (e.key) {
49
65
  case "ArrowDown":
50
- e.preventDefault(), y((e) => e < t.length - 1 ? e + 1 : 0);
66
+ e.preventDefault(), w((e) => e < t.length - 1 ? e + 1 : 0);
51
67
  break;
52
68
  case "ArrowUp":
53
- e.preventDefault(), y((e) => e > 0 ? e - 1 : t.length - 1);
69
+ e.preventDefault(), w((e) => e > 0 ? e - 1 : t.length - 1);
54
70
  break;
55
71
  case "Home":
56
- e.preventDefault(), y(0);
72
+ e.preventDefault(), w(0);
57
73
  break;
58
74
  case "End":
59
- e.preventDefault(), y(t.length - 1);
75
+ e.preventDefault(), w(t.length - 1);
60
76
  break;
61
77
  case "Tab":
62
- O();
78
+ L();
63
79
  break;
64
80
  }
65
81
  };
66
82
  c(() => {
67
- g && v >= 0 && Array.from(b.current?.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"])") || [])[v]?.focus();
68
- }, [v, g]);
69
- let A = o ? e : "div";
70
- return /* @__PURE__ */ p(m.Provider, {
83
+ x && C >= 0 && Array.from((k.floating.current ?? T.current)?.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"])") || [])[C]?.focus({ preventScroll: !0 });
84
+ }, [
85
+ C,
86
+ x,
87
+ k.floating
88
+ ]);
89
+ let z = o ? e : "div";
90
+ return /* @__PURE__ */ p(b.Provider, {
71
91
  value: {
72
- isOpen: g,
73
- toggle: D,
74
- close: O,
75
- menuId: T,
76
- triggerId: E,
77
- focusedIndex: v,
78
- setFocusedIndex: y,
79
- registerItem: C,
80
- containerRef: b
92
+ isOpen: x,
93
+ toggle: I,
94
+ close: L,
95
+ menuId: P,
96
+ triggerId: F,
97
+ focusedIndex: C,
98
+ setFocusedIndex: w,
99
+ registerItem: M,
100
+ containerRef: T,
101
+ setReference: k.setReference,
102
+ setFloating: k.setFloating,
103
+ floatingStyles: A,
104
+ floatingRef: k.floating,
105
+ setAlign: O
81
106
  },
82
- children: /* @__PURE__ */ p(A, {
107
+ children: /* @__PURE__ */ p(z, {
83
108
  ...s,
84
109
  role: "none",
85
110
  className: f("wim-dropdown", a.root, r),
86
- ref: S,
87
- onKeyDown: k,
111
+ ref: j,
112
+ onKeyDown: R,
88
113
  children: /* @__PURE__ */ p(t, { children: n })
89
114
  })
90
115
  });
91
116
  });
92
- h.displayName = "Dropdown";
93
- var g = s(({ children: n, className: r, asChild: i = !1, ...s }, c) => {
94
- let { toggle: l, isOpen: u, menuId: d, triggerId: h } = o.useContext(m);
95
- return /* @__PURE__ */ p(i ? e : "div", {
96
- ...s,
97
- ref: c,
117
+ x.displayName = "Dropdown";
118
+ var S = s(({ children: n, className: r, asChild: s = !1, ...c }, l) => {
119
+ let { toggle: u, isOpen: d, menuId: m, triggerId: h, setReference: g } = o.useContext(b), _ = s ? e : "div", v = i(g, l);
120
+ return /* @__PURE__ */ p(_, {
121
+ ...c,
122
+ ref: v,
98
123
  id: h,
99
124
  className: f(a.trigger, r),
100
- onClick: l,
125
+ onClick: u,
101
126
  "aria-haspopup": "menu",
102
- "aria-expanded": u,
103
- "aria-controls": u ? d : void 0,
127
+ "aria-expanded": d,
128
+ "aria-controls": d ? m : void 0,
104
129
  role: "button",
105
130
  tabIndex: 0,
106
131
  onKeyDown: (e) => {
107
- (e.key === "Enter" || e.key === " ") && (e.preventDefault(), l());
132
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), u());
108
133
  },
109
134
  children: /* @__PURE__ */ p(t, { children: n })
110
135
  });
111
136
  });
112
- g.displayName = "Dropdown.Trigger";
113
- var _ = s(({ children: e, className: t, align: r = "left", show: i, ...s }, c) => {
114
- let { isOpen: l, menuId: u, triggerId: d } = o.useContext(m), h = r === "left" ? a.alignLeft : a.alignRight;
115
- return /* @__PURE__ */ p(n, {
116
- ...s,
117
- ref: c,
118
- show: i === void 0 ? l : i,
137
+ S.displayName = "Dropdown.Trigger";
138
+ var C = s(({ children: e, className: t, align: r = "left", show: s, style: l, ...u }, d) => {
139
+ let { isOpen: h, menuId: g, triggerId: _, setFloating: v, floatingStyles: y, setAlign: x } = o.useContext(b);
140
+ c(() => {
141
+ x(r);
142
+ }, [r, x]);
143
+ let S = i(v, d);
144
+ return /* @__PURE__ */ p(m, { children: /* @__PURE__ */ p(n, {
145
+ ...u,
146
+ ref: S,
147
+ show: s === void 0 ? h : s,
119
148
  preset: "fade",
120
- id: u,
121
- className: f(a.menu, h, t),
149
+ id: g,
150
+ style: {
151
+ ...y,
152
+ ...l
153
+ },
154
+ className: f(a.menu, t),
122
155
  role: "menu",
123
- "aria-labelledby": d,
156
+ "aria-labelledby": _,
124
157
  children: e
125
- });
158
+ }) });
126
159
  });
127
- _.displayName = "Dropdown.Menu";
128
- var v = s(({ children: e, onClick: t, disabled: n = !1, className: i, ...s }, c) => {
129
- let { close: l, focusedIndex: u, setFocusedIndex: h, registerItem: g } = o.useContext(m), [_] = d(() => g()), v = u === _, y = (e) => {
160
+ C.displayName = "Dropdown.Menu";
161
+ var w = s(({ children: e, onClick: t, disabled: n = !1, className: i, ...s }, c) => {
162
+ let { close: l, focusedIndex: u, setFocusedIndex: m, registerItem: h } = o.useContext(b), [g] = d(() => h()), _ = u === g, v = (e) => {
130
163
  n || (e.stopPropagation(), t && t(), l());
131
164
  };
132
165
  return /* @__PURE__ */ p(r, {
133
166
  ...s,
134
167
  ref: c,
135
168
  className: f(a.item, i),
136
- onClick: y,
137
- onFocus: () => h(_),
169
+ onClick: v,
170
+ onFocus: () => m(g),
138
171
  disabled: n,
139
172
  role: "menuitem",
140
- tabIndex: v ? 0 : -1,
173
+ tabIndex: _ ? 0 : -1,
141
174
  onKeyDown: (e) => {
142
- !n && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), y(e));
175
+ !n && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), v(e));
143
176
  },
144
177
  children: e
145
178
  });
146
179
  });
147
- v.displayName = "Dropdown.Item";
148
- var y = s((e, t) => /* @__PURE__ */ p(h, {
180
+ w.displayName = "Dropdown.Item";
181
+ var T = s((e, t) => /* @__PURE__ */ p(x, {
149
182
  ...e,
150
183
  ref: t
151
184
  }));
152
- y.displayName = "Dropdown", y.Trigger = g, y.Menu = _, y.Item = v;
185
+ T.displayName = "Dropdown", T.Trigger = S, T.Menu = C, T.Item = w;
153
186
  //#endregion
154
- export { y as Dropdown, y as default, v as DropdownItem, _ as DropdownMenu, g as DropdownTrigger };
187
+ export { T as Dropdown, T as default, w as DropdownItem, C as DropdownMenu, S as DropdownTrigger };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var e=`_root_j9u27_2`,t=`_trigger_j9u27_6`,n=`_menu_j9u27_10`,r=`_alignLeft_j9u27_24`,i=`_alignRight_j9u27_27`,a=`_item_j9u27_30`,o={root:e,trigger:t,menu:n,alignLeft:r,alignRight:i,item:a};exports.alignLeft=r,exports.alignRight=i,exports.default=o,exports.item=a,exports.menu=n,exports.root=e,exports.trigger=t;
2
+ var e=`_root_s4522_3`,t=`_trigger_s4522_7`,n=`_menu_s4522_13`,r=`_item_s4522_25`,i={root:e,trigger:t,menu:n,item:r};exports.default=i,exports.item=r,exports.menu=n,exports.root=e,exports.trigger=t;
@@ -1,12 +1,10 @@
1
1
  "use client";
2
2
  //#region src/components/overlay/Dropdown/dropdown.module.scss
3
- var e = "_root_j9u27_2", t = "_trigger_j9u27_6", n = "_menu_j9u27_10", r = "_alignLeft_j9u27_24", i = "_alignRight_j9u27_27", a = "_item_j9u27_30", o = {
3
+ var e = "_root_s4522_3", t = "_trigger_s4522_7", n = "_menu_s4522_13", r = "_item_s4522_25", i = {
4
4
  root: e,
5
5
  trigger: t,
6
6
  menu: n,
7
- alignLeft: r,
8
- alignRight: i,
9
- item: a
7
+ item: r
10
8
  };
11
9
  //#endregion
12
- export { r as alignLeft, i as alignRight, o as default, a as item, n as menu, e as root, t as trigger };
10
+ export { i as default, r as item, n as menu, e as root, t as trigger };