wimui 0.47.10 → 0.49.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,85 +1,97 @@
1
1
  "use client";
2
2
  import { OverlayBase as e } from "../../_internal/OverlayBase.js";
3
3
  import t from "./bottom-sheet.module.js";
4
- import n, { createContext as r, useCallback as i, useContext as a, useState as o } from "react";
5
- import s from "classnames";
6
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
4
+ import n, { createContext as r, useCallback as i, useContext as a, useId as o, useState as s } from "react";
5
+ import c from "classnames";
6
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
7
7
  //#region src/components/overlay/BottomSheet/BottomSheet.tsx
8
- var u = r(void 0), d = () => {
9
- let e = a(u);
8
+ var d = r(void 0), f = () => {
9
+ let e = a(d);
10
10
  if (!e) throw Error("useBottomSheet must be used within a BottomSheet provider");
11
11
  return e;
12
- }, f = ({ children: e, open: t, defaultOpen: n = !1, onOpenChange: r }) => {
13
- let [a, s] = o(n), l = t !== void 0, d = l ? t : a, f = i((e) => {
14
- l || s(e), r?.(e);
15
- }, [l, r]);
16
- return /* @__PURE__ */ c(u.Provider, {
12
+ }, p = ({ children: e, open: t, defaultOpen: n = !1, onOpenChange: r }) => {
13
+ let [a, c] = s(n), u = t !== void 0, f = u ? t : a, p = i((e) => {
14
+ u || c(e), r?.(e);
15
+ }, [u, r]), m = o(), h = `wim-bottom-sheet-${m}-title`, g = `wim-bottom-sheet-${m}-description`;
16
+ return /* @__PURE__ */ l(d.Provider, {
17
17
  value: {
18
- open: d,
19
- onOpenChange: f
18
+ titleId: h,
19
+ descriptionId: g,
20
+ open: f,
21
+ onOpenChange: p
20
22
  },
21
23
  children: e
22
24
  });
23
- }, p = ({ children: e, asChild: t, className: r }) => {
24
- let { onOpenChange: i } = d(), a = () => {
25
+ }, m = ({ children: e, asChild: t, className: r }) => {
26
+ let { onOpenChange: i } = f(), a = () => {
25
27
  i(!0);
26
28
  };
27
29
  return t && n.isValidElement(e) ? n.cloneElement(e, {
28
30
  onClick: (t) => {
29
31
  e.props.onClick?.(t), a();
30
32
  },
31
- className: s(r, e.props.className)
32
- }) : /* @__PURE__ */ c("button", {
33
+ className: c(r, e.props.className)
34
+ }) : /* @__PURE__ */ l("button", {
33
35
  className: r,
34
36
  onClick: a,
35
37
  children: e
36
38
  });
37
- }, m = ({ children: e, className: t, asChild: r }) => {
38
- let { onOpenChange: i } = d(), a = () => {
39
+ }, h = ({ children: e, className: t, asChild: r }) => {
40
+ let { onOpenChange: i } = f(), a = () => {
39
41
  i(!1);
40
42
  };
41
43
  return r && n.isValidElement(e) ? n.cloneElement(e, {
42
44
  onClick: (t) => {
43
45
  e.props.onClick?.(t), a();
44
46
  },
45
- className: s(t, e.props.className)
46
- }) : /* @__PURE__ */ c("button", {
47
+ className: c(t, e.props.className)
48
+ }) : /* @__PURE__ */ l("button", {
47
49
  type: "button",
48
50
  className: t,
49
51
  onClick: a,
50
52
  children: e
51
53
  });
52
- }, h = ({ children: n, className: r }) => {
53
- let { open: i, onOpenChange: a } = d();
54
- return /* @__PURE__ */ l(e, {
54
+ }, g = ({ children: n, className: r }) => {
55
+ let { open: i, onOpenChange: a, titleId: o, descriptionId: s } = f();
56
+ return /* @__PURE__ */ u(e, {
55
57
  open: i,
56
58
  onOpenChange: a,
57
59
  overlayClassName: t.overlay,
58
- contentClassName: s("wim-bottom-sheet", t.content, r),
60
+ contentClassName: c("wim-bottom-sheet", t.content, r),
59
61
  transitionProps: { preset: "slide-bottom" },
60
- children: [/* @__PURE__ */ c("div", { className: t.handle }), n]
62
+ "aria-labelledby": o,
63
+ "aria-describedby": s,
64
+ children: [/* @__PURE__ */ l("div", { className: t.handle }), n]
61
65
  });
62
- }, g = ({ children: e, className: n }) => /* @__PURE__ */ c("div", {
63
- className: s(t.header, n),
66
+ }, _ = ({ children: e, className: n }) => /* @__PURE__ */ l("div", {
67
+ className: c(t.header, n),
64
68
  "data-testid": "bottom-sheet-header",
65
69
  children: e
66
- }), _ = ({ children: e, className: n }) => /* @__PURE__ */ c("div", {
67
- className: s(t.footer, n),
70
+ }), v = ({ children: e, className: n }) => /* @__PURE__ */ l("div", {
71
+ className: c(t.footer, n),
68
72
  "data-testid": "bottom-sheet-footer",
69
73
  children: e
70
- }), v = ({ children: e, className: n }) => /* @__PURE__ */ c("h2", {
71
- className: s(t.title, n),
72
- "data-testid": "bottom-sheet-title",
73
- children: e
74
- }), y = ({ children: e, className: n }) => /* @__PURE__ */ c("p", {
75
- className: s(t.description, n),
76
- "data-testid": "bottom-sheet-description",
77
- children: e
78
- }), b = ({ children: e, className: n }) => /* @__PURE__ */ c("div", {
79
- className: s(t.body, n),
74
+ }), y = ({ children: e, className: n }) => {
75
+ let { titleId: r } = f();
76
+ return /* @__PURE__ */ l("h2", {
77
+ id: r,
78
+ className: c(t.title, n),
79
+ "data-testid": "bottom-sheet-title",
80
+ children: e
81
+ });
82
+ }, b = ({ children: e, className: n }) => {
83
+ let { descriptionId: r } = f();
84
+ return /* @__PURE__ */ l("p", {
85
+ id: r,
86
+ className: c(t.description, n),
87
+ "data-testid": "bottom-sheet-description",
88
+ children: e
89
+ });
90
+ }, x = ({ children: e, className: n }) => /* @__PURE__ */ l("div", {
91
+ className: c(t.body, n),
80
92
  "data-testid": "bottom-sheet-body",
81
93
  children: e
82
- }), x = (e) => /* @__PURE__ */ c(f, { ...e });
83
- x.displayName = "BottomSheet", x.Trigger = p, x.Content = h, x.Header = g, x.Footer = _, x.Title = v, x.Description = y, x.Body = b, x.Close = m;
94
+ }), S = (e) => /* @__PURE__ */ l(p, { ...e });
95
+ S.displayName = "BottomSheet", S.Trigger = m, S.Content = g, S.Header = _, S.Footer = v, S.Title = y, S.Description = b, S.Body = x, S.Close = h;
84
96
  //#endregion
85
- export { x as BottomSheet, x as default, b as BottomSheetBody, m as BottomSheetClose, h as BottomSheetContent, y as BottomSheetDescription, _ as BottomSheetFooter, g as BottomSheetHeader, v as BottomSheetTitle, p as BottomSheetTrigger };
97
+ export { S as BottomSheet, S as default, x as BottomSheetBody, h as BottomSheetClose, g as BottomSheetContent, b as BottomSheetDescription, v as BottomSheetFooter, _ as BottomSheetHeader, y as BottomSheetTitle, m as BottomSheetTrigger };
@@ -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("../../../hooks/useMergedRef.cjs"),i=require("../../_internal/BaseListItem/BaseListItem.cjs"),a=require("./context-menu.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(null),d=({children:e,menu:i,className:d,disabled:f=!1,asChild:p=!1})=>{let[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(null),[v,y]=(0,o.useState)(!1),b=(0,o.useRef)([]),x=(0,o.useRef)(null),S=r.useMergedRef(x),{refs:C,floatingStyles:w,context:T}=(0,l.useFloating)({open:m,onOpenChange:e=>{h(e),e||(_(null),y(!1))},strategy:`fixed`,middleware:[(0,l.flip)(),(0,l.shift)({padding:10})],whileElementsMounted:l.autoUpdate}),E=(0,l.useDismiss)(T),D=(0,l.useRole)(T,{role:`menu`}),O=(0,l.useListNavigation)(T,{listRef:b,activeIndex:g,onNavigate:_,loop:!0}),{getFloatingProps:k,getItemProps:A}=(0,l.useInteractions)([E,D,O]),j=(e,t,n)=>{C.setReference({getBoundingClientRect(){return{width:0,height:0,x:e,y:t,top:t,left:e,right:e,bottom:t}}}),y(n),h(!0),_(0)},M=e=>{if(e.preventDefault(),f)return;let t=e.clientX===0&&e.clientY===0;j(e.clientX,e.clientY,t)},N=e=>{if(!f&&(e.key===`Enter`||e.key===` `)){e.preventDefault();let t=x.current?.getBoundingClientRect();t&&j(t.left+t.width/2,t.top+t.height/2,!0)}},P=()=>{h(!1)};return(0,c.jsxs)(p?t.Root:`div`,{ref:S,className:(0,s.default)(`wim-context-menu`,!p&&a.default.container,f&&a.default.disabled,d),onContextMenu:M,onKeyDown:N,tabIndex:f?-1:0,"data-testid":`context-menu-trigger`,children:[(0,c.jsx)(t.Slottable,{children:e}),(0,c.jsx)(l.FloatingPortal,{children:(0,c.jsx)(n.Transition,{show:m,preset:`fade`,children:(0,c.jsx)(l.FloatingFocusManager,{context:T,modal:!0,initialFocus:v?g??0:-1,children:(0,c.jsx)(`div`,{ref:C.setFloating,className:a.default.menu,style:w,...k({onClick:P,onKeyDown(e){e.key===`Escape`&&P()}}),children:(0,c.jsx)(u.Provider,{value:{activeIndex:g,getItemProps:A},children:(0,c.jsx)(l.FloatingList,{elementsRef:b,children:i})})})})})})]})},f=({children:e,onClick:t,disabled:n=!1,className:r,icon:d,danger:f=!1,asChild:p=!1})=>{let{ref:m,index:h}=(0,l.useListItem)(),g=(0,o.useContext)(u),_=()=>{n||t&&t()},v=g?g.getItemProps({index:h,onClick:()=>_(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_())}}):{},y={ref:m,className:(0,s.default)(a.default.item,r),disabled:n,danger:f,icon:d,role:`menuitem`,tabIndex:g?.activeIndex===h?0:-1,...v};return p?(0,c.jsx)(`li`,{role:`none`,children:(0,c.jsx)(i.BaseListItem,{asChild:!0,...y,children:e})}):(0,c.jsx)(i.BaseListItem,{...y,children:e})},p=({className:e})=>(0,c.jsx)(`div`,{className:(0,s.default)(a.default.divider,e),role:`separator`}),m=({children:e,title:t,className:n})=>{let r=o.default.useId();return(0,c.jsxs)(`div`,{role:`group`,"aria-labelledby":t?r:void 0,className:n,"data-testid":`context-menu-group`,children:[t&&(0,c.jsx)(`div`,{id:r,className:a.default.groupTitle,"data-testid":`context-menu-group-title`,"aria-hidden":`true`,children:t}),e]})},h=e=>(0,c.jsx)(d,{...e});h.displayName=`ContextMenu`,h.Item=f,h.Divider=p,h.Group=m,exports.ContextMenu=h,exports.default=h,exports.ContextMenuDivider=p,exports.ContextMenuGroup=m,exports.ContextMenuItem=f;
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("../../../hooks/useMergedRef.cjs"),i=require("../../_internal/BaseListItem/BaseListItem.cjs"),a=require("./context-menu.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(null),d=({children:e,menu:i,className:d,disabled:f=!1,asChild:p=!1})=>{let[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(null),[v,y]=(0,o.useState)(!1),b=(0,o.useRef)([]),x=(0,o.useRef)(null),S=r.useMergedRef(x),{refs:C,floatingStyles:w,context:T}=(0,l.useFloating)({open:m,onOpenChange:e=>{h(e),e||(_(null),y(!1))},strategy:`fixed`,middleware:[(0,l.flip)(),(0,l.shift)({padding:10})],whileElementsMounted:l.autoUpdate}),E=(0,l.useDismiss)(T),D=(0,l.useRole)(T,{role:`menu`}),O=(0,l.useListNavigation)(T,{listRef:b,activeIndex:g,onNavigate:_,loop:!0}),{getFloatingProps:k,getItemProps:A}=(0,l.useInteractions)([E,D,O]),j=(e,t,n)=>{C.setReference({getBoundingClientRect(){return{width:0,height:0,x:e,y:t,top:t,left:e,right:e,bottom:t}}}),y(n),h(!0),_(0)},M=e=>{if(e.preventDefault(),f)return;let t=e.clientX===0&&e.clientY===0;j(e.clientX,e.clientY,t)},N=e=>{if(!f&&(e.key===`Enter`||e.key===` `)){e.preventDefault();let t=x.current?.getBoundingClientRect();t&&j(t.left+t.width/2,t.top+t.height/2,!0)}},P=()=>{h(!1)};return(0,c.jsxs)(p?t.Root:`div`,{ref:S,className:(0,s.default)(`wim-context-menu`,!p&&a.default.container,f&&a.default.disabled,d),onContextMenu:M,onKeyDown:N,tabIndex:f?-1:0,"data-testid":`context-menu-trigger`,children:[(0,c.jsx)(t.Slottable,{children:e}),(0,c.jsx)(l.FloatingPortal,{preserveTabOrder:!1,children:(0,c.jsx)(n.Transition,{show:m,preset:`fade`,children:(0,c.jsx)(l.FloatingFocusManager,{context:T,modal:!1,guards:!1,initialFocus:v?g??0:-1,children:(0,c.jsx)(`div`,{ref:C.setFloating,className:a.default.menu,style:w,...k({onClick:P,onKeyDown(e){e.key===`Escape`&&P(),e.key===`Tab`&&(e.preventDefault(),P())}}),"aria-labelledby":void 0,children:(0,c.jsx)(u.Provider,{value:{activeIndex:g,getItemProps:A},children:(0,c.jsx)(l.FloatingList,{elementsRef:b,children:i})})})})})})]})},f=({children:e,onClick:t,disabled:n=!1,className:r,icon:d,danger:f=!1,asChild:p=!1})=>{let{ref:m,index:h}=(0,l.useListItem)(),g=(0,o.useContext)(u),_=()=>{n||t&&t()},v=g?g.getItemProps({index:h,onClick:()=>_(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_())}}):{},y={ref:m,className:(0,s.default)(a.default.item,r),disabled:n,danger:f,icon:d,role:`menuitem`,tabIndex:g?.activeIndex===h?0:-1,...v};return p?(0,c.jsx)(`li`,{role:`none`,children:(0,c.jsx)(i.BaseListItem,{asChild:!0,...y,children:e})}):(0,c.jsx)(i.BaseListItem,{...y,children:e})},p=({className:e})=>(0,c.jsx)(`div`,{className:(0,s.default)(a.default.divider,e),role:`separator`}),m=({children:e,title:t,className:n})=>{let r=o.default.useId();return(0,c.jsxs)(`div`,{role:`group`,"aria-labelledby":t?r:void 0,className:n,"data-testid":`context-menu-group`,children:[t&&(0,c.jsx)(`div`,{id:r,className:a.default.groupTitle,"data-testid":`context-menu-group-title`,"aria-hidden":`true`,children:t}),e]})},h=e=>(0,c.jsx)(d,{...e});h.displayName=`ContextMenu`,h.Item=f,h.Divider=p,h.Group=m,exports.ContextMenu=h,exports.default=h,exports.ContextMenuDivider=p,exports.ContextMenuGroup=m,exports.ContextMenuItem=f;
@@ -60,36 +60,41 @@ var T = o.createContext(null), E = ({ children: i, menu: o, className: s, disabl
60
60
  onKeyDown: K,
61
61
  tabIndex: S ? -1 : 0,
62
62
  "data-testid": "context-menu-trigger",
63
- children: [/* @__PURE__ */ d(t, { children: i }), /* @__PURE__ */ d(h, { children: /* @__PURE__ */ d(n, {
64
- show: D,
65
- preset: "fade",
66
- children: /* @__PURE__ */ d(p, {
67
- context: R,
68
- modal: !0,
69
- initialFocus: j ? k ?? 0 : -1,
70
- children: /* @__PURE__ */ d("div", {
71
- ref: I.setFloating,
72
- className: a.menu,
73
- style: L,
74
- ...H({
75
- onClick: q,
76
- onKeyDown(e) {
77
- e.key === "Escape" && q();
78
- }
79
- }),
80
- children: /* @__PURE__ */ d(T.Provider, {
81
- value: {
82
- activeIndex: k,
83
- getItemProps: U
84
- },
85
- children: /* @__PURE__ */ d(m, {
86
- elementsRef: N,
87
- children: o
63
+ children: [/* @__PURE__ */ d(t, { children: i }), /* @__PURE__ */ d(h, {
64
+ preserveTabOrder: !1,
65
+ children: /* @__PURE__ */ d(n, {
66
+ show: D,
67
+ preset: "fade",
68
+ children: /* @__PURE__ */ d(p, {
69
+ context: R,
70
+ modal: !1,
71
+ guards: !1,
72
+ initialFocus: j ? k ?? 0 : -1,
73
+ children: /* @__PURE__ */ d("div", {
74
+ ref: I.setFloating,
75
+ className: a.menu,
76
+ style: L,
77
+ ...H({
78
+ onClick: q,
79
+ onKeyDown(e) {
80
+ e.key === "Escape" && q(), e.key === "Tab" && (e.preventDefault(), q());
81
+ }
82
+ }),
83
+ "aria-labelledby": void 0,
84
+ children: /* @__PURE__ */ d(T.Provider, {
85
+ value: {
86
+ activeIndex: k,
87
+ getItemProps: U
88
+ },
89
+ children: /* @__PURE__ */ d(m, {
90
+ elementsRef: N,
91
+ children: o
92
+ })
88
93
  })
89
94
  })
90
95
  })
91
96
  })
92
- }) })]
97
+ })]
93
98
  });
94
99
  }, D = ({ children: e, onClick: t, disabled: n = !1, className: r, icon: o, danger: c = !1, asChild: l = !1 }) => {
95
100
  let { ref: f, index: p } = S(), m = s(T), h = () => {