@webiny/admin-ui 6.4.6-beta.0 → 6.4.7-beta.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.
@@ -9,7 +9,7 @@ const SidebarContent = ({ className, children, ...props })=>{
9
9
  const { dir, onScroll, ...restProps } = props;
10
10
  return /*#__PURE__*/ react.createElement(ScrollArea, {
11
11
  "data-sidebar": "content",
12
- className: cn("flex text-neutral-primary min-h-0 flex-1 flex-col gap-2", className),
12
+ className: cn("flex text-neutral-primary min-h-0 flex-1 flex-col gap-2 [&_[data-radix-scroll-area-viewport]>div]:!block", className),
13
13
  ...restProps
14
14
  }, children);
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Sidebar/components/SidebarContent.js","sources":["../../../src/Sidebar/components/SidebarContent.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn } from \"~/utils.js\";\nimport { ScrollArea } from \"~/ScrollArea/index.js\";\nimport { useSidebar } from \"./SidebarProvider.js\";\n\nconst SidebarContent = ({ className, children, ...props }: React.ComponentProps<\"div\">) => {\n const { state } = useSidebar();\n const isExpanded = state === \"expanded\";\n\n if (isExpanded) {\n // Extract dir and onScroll props to avoid type conflicts with ScrollArea.\n // oxlint-disable-next-line typescript/no-unused-vars\n const { dir, onScroll, ...restProps } = props;\n return (\n <ScrollArea\n data-sidebar=\"content\"\n className={cn(\"flex text-neutral-primary min-h-0 flex-1 flex-col gap-2\", className)}\n {...restProps}\n >\n {children}\n </ScrollArea>\n );\n }\n\n return (\n <div\n {...props}\n data-sidebar=\"content\"\n className={cn(\n \"flex text-neutral-primary min-h-0 flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden group-data-[state=collapsed]:overflow-hidden\",\n className\n )}\n >\n {children}\n </div>\n );\n};\n\nexport { SidebarContent };\n"],"names":["SidebarContent","className","children","props","state","useSidebar","isExpanded","dir","onScroll","restProps","ScrollArea","cn"],"mappings":";;;;AAKA,MAAMA,iBAAiB,CAAC,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGC,OAAoC;IAClF,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAClB,MAAMC,aAAaF,AAAU,eAAVA;IAEnB,IAAIE,YAAY;QAGZ,MAAM,EAAEC,GAAG,EAAEC,QAAQ,EAAE,GAAGC,WAAW,GAAGN;QACxC,OAAO,WAAP,GACI,oBAACO,YAAUA;YACP,gBAAa;YACb,WAAWC,GAAG,2DAA2DV;YACxE,GAAGQ,SAAS;WAEZP;IAGb;IAEA,OAAO,WAAP,GACI,oBAAC;QACI,GAAGC,KAAK;QACT,gBAAa;QACb,WAAWQ,GACP,0IACAV;OAGHC;AAGb"}
1
+ {"version":3,"file":"Sidebar/components/SidebarContent.js","sources":["../../../src/Sidebar/components/SidebarContent.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn } from \"~/utils.js\";\nimport { ScrollArea } from \"~/ScrollArea/index.js\";\nimport { useSidebar } from \"./SidebarProvider.js\";\n\nconst SidebarContent = ({ className, children, ...props }: React.ComponentProps<\"div\">) => {\n const { state } = useSidebar();\n const isExpanded = state === \"expanded\";\n\n if (isExpanded) {\n // Extract dir and onScroll props to avoid type conflicts with ScrollArea.\n // oxlint-disable-next-line typescript/no-unused-vars\n const { dir, onScroll, ...restProps } = props;\n return (\n <ScrollArea\n data-sidebar=\"content\"\n className={cn(\n \"flex text-neutral-primary min-h-0 flex-1 flex-col gap-2 [&_[data-radix-scroll-area-viewport]>div]:!block\",\n className\n )}\n {...restProps}\n >\n {children}\n </ScrollArea>\n );\n }\n\n return (\n <div\n {...props}\n data-sidebar=\"content\"\n className={cn(\n \"flex text-neutral-primary min-h-0 flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden group-data-[state=collapsed]:overflow-hidden\",\n className\n )}\n >\n {children}\n </div>\n );\n};\n\nexport { SidebarContent };\n"],"names":["SidebarContent","className","children","props","state","useSidebar","isExpanded","dir","onScroll","restProps","ScrollArea","cn"],"mappings":";;;;AAKA,MAAMA,iBAAiB,CAAC,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGC,OAAoC;IAClF,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAClB,MAAMC,aAAaF,AAAU,eAAVA;IAEnB,IAAIE,YAAY;QAGZ,MAAM,EAAEC,GAAG,EAAEC,QAAQ,EAAE,GAAGC,WAAW,GAAGN;QACxC,OAAO,WAAP,GACI,oBAACO,YAAUA;YACP,gBAAa;YACb,WAAWC,GACP,4GACAV;YAEH,GAAGQ,SAAS;WAEZP;IAGb;IAEA,OAAO,WAAP,GACI,oBAAC;QACI,GAAGC,KAAK;QACT,gBAAa;QACb,WAAWQ,GACP,0IACAV;OAGHC;AAGb"}
@@ -56,7 +56,7 @@ const SidebarRoot = ({ side = "left", className, children, ...props })=>{
56
56
  ...props
57
57
  }, /*#__PURE__*/ react.createElement("div", {
58
58
  "data-sidebar": "sidebar",
59
- className: "flex h-full w-full py-xs flex-col"
59
+ className: "flex h-full w-full py-xs flex-col overflow-hidden"
60
60
  }, children)), /*#__PURE__*/ react.createElement("div", {
61
61
  "data-sidebar": "extra-hover-area",
62
62
  className: "absolute top-0 left-[theme(spacing.sidebar-collapsed)] h-full w-sm hidden group-data-[state=collapsed]:block"
@@ -1 +1 @@
1
- {"version":3,"file":"Sidebar/components/SidebarRoot.js","sources":["../../../src/Sidebar/components/SidebarRoot.tsx"],"sourcesContent":["import React, { useCallback, useRef } from \"react\";\nimport { cn, cva } from \"~/utils.js\";\nimport { useSidebar } from \"./SidebarProvider.js\";\n\ninterface SidebarRootProps extends React.ComponentProps<\"div\"> {\n side?: \"left\" | \"right\";\n}\n\nconst variants = cva(\"group peer block border-r-sm border-neutral-dimmed bg-neutral-light\", {\n variants: {\n pinned: {\n false: \"fixed top-0 z-sidebar \"\n }\n }\n});\n\nconst SidebarRoot = ({ side = \"left\", className, children, ...props }: SidebarRootProps) => {\n const { state, setExpanded, pinned, expanded } = useSidebar();\n\n const elementRef = useRef<HTMLDivElement>(null);\n\n // With this timeout, we prevent the sidebar glitching (quickly opening/closing) during mouse enter/leave events.\n const timeoutRef = useRef<number | null>(null);\n\n const onMouseEnter = useCallback<React.MouseEventHandler<HTMLDivElement>>(() => {\n // If the sidebar is pinned, we don't want to open the sidebar on mouse enter.\n if (pinned) {\n return;\n }\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n\n // Add delay before opening to prevent accidental openings\n timeoutRef.current = window.setTimeout(() => {\n // Only set expanded if it's not already expanded\n if (!expanded) {\n setExpanded(true);\n }\n }, 300);\n }, [pinned, setExpanded, expanded]);\n\n const onMouseLeave = useCallback<React.MouseEventHandler<HTMLDivElement>>(() => {\n // If the sidebar is pinned, we don't want to close the sidebar on mouse leave.\n if (pinned) {\n return;\n }\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n\n // With this timeout, we prevent the sidebar glitching (quickly opening/closing) during mouse enter/leave events.\n timeoutRef.current = window.setTimeout(() => {\n setExpanded(false);\n }, 300);\n }, [pinned, setExpanded]);\n\n return (\n <div\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n ref={elementRef}\n data-state={state}\n data-sidebar={\"root\"}\n data-side={side}\n className={variants({ pinned })}\n >\n <div\n className={cn(\n \"duration-175 relative h-svh w-sidebar-expanded bg-transparent transition-[width] ease-linear duration-175\",\n \"group-data-[side=right]:rotate-180\",\n \"group-data-[state=collapsed]:w-sidebar-collapsed\"\n )}\n />\n <div\n className={cn(\n \"duration-175 fixed inset-y-0 z-sidebar h-svh w-sidebar-expanded transition-[width] ease-linear md:flex\",\n side === \"left\" ? \"left-0\" : \"right-0\",\n \"group-data-[state=collapsed]:w-sidebar-collapsed group-data-[side=left]:border-r-px group-data-[side=right]:border-l-px\",\n className\n )}\n {...props}\n >\n <div data-sidebar=\"sidebar\" className=\"flex h-full w-full py-xs flex-col\">\n {children}\n </div>\n </div>\n\n <div\n data-sidebar={\"extra-hover-area\"}\n className={\n \"absolute top-0 left-[theme(spacing.sidebar-collapsed)] h-full w-sm hidden group-data-[state=collapsed]:block\"\n }\n />\n </div>\n );\n};\n\nexport { SidebarRoot, type SidebarRootProps };\n"],"names":["variants","cva","SidebarRoot","side","className","children","props","state","setExpanded","pinned","expanded","useSidebar","elementRef","useRef","timeoutRef","onMouseEnter","useCallback","window","onMouseLeave","cn"],"mappings":";;;AAQA,MAAMA,WAAWC,IAAI,uEAAuE;IACxF,UAAU;QACN,QAAQ;YACJ,OAAO;QACX;IACJ;AACJ;AAEA,MAAMC,cAAc,CAAC,EAAEC,OAAO,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGC,OAAyB;IACnF,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGC;IAEjD,MAAMC,aAAaC,OAAuB;IAG1C,MAAMC,aAAaD,OAAsB;IAEzC,MAAME,eAAeC,YAAqD;QAEtE,IAAIP,QACA;QAGJ,IAAIK,WAAW,OAAO,EAAE;YACpBG,OAAO,YAAY,CAACH,WAAW,OAAO;YACtCA,WAAW,OAAO,GAAG;QACzB;QAGAA,WAAW,OAAO,GAAGG,OAAO,UAAU,CAAC;YAEnC,IAAI,CAACP,UACDF,YAAY;QAEpB,GAAG;IACP,GAAG;QAACC;QAAQD;QAAaE;KAAS;IAElC,MAAMQ,eAAeF,YAAqD;QAEtE,IAAIP,QACA;QAGJ,IAAIK,WAAW,OAAO,EAAE;YACpBG,OAAO,YAAY,CAACH,WAAW,OAAO;YACtCA,WAAW,OAAO,GAAG;QACzB;QAGAA,WAAW,OAAO,GAAGG,OAAO,UAAU,CAAC;YACnCT,YAAY;QAChB,GAAG;IACP,GAAG;QAACC;QAAQD;KAAY;IAExB,OAAO,WAAP,GACI,oBAAC;QACG,cAAcO;QACd,cAAcG;QACd,KAAKN;QACL,cAAYL;QACZ,gBAAc;QACd,aAAWJ;QACX,WAAWH,SAAS;YAAES;QAAO;qBAE7B,oBAAC;QACG,WAAWU,GACP,6GACA,sCACA;sBAGR,oBAAC;QACG,WAAWA,GACP,0GACAhB,AAAS,WAATA,OAAkB,WAAW,WAC7B,2HACAC;QAEH,GAAGE,KAAK;qBAET,oBAAC;QAAI,gBAAa;QAAU,WAAU;OACjCD,YAAAA,WAAAA,GAIT,oBAAC;QACG,gBAAc;QACd,WACI;;AAKpB"}
1
+ {"version":3,"file":"Sidebar/components/SidebarRoot.js","sources":["../../../src/Sidebar/components/SidebarRoot.tsx"],"sourcesContent":["import React, { useCallback, useRef } from \"react\";\nimport { cn, cva } from \"~/utils.js\";\nimport { useSidebar } from \"./SidebarProvider.js\";\n\ninterface SidebarRootProps extends React.ComponentProps<\"div\"> {\n side?: \"left\" | \"right\";\n}\n\nconst variants = cva(\"group peer block border-r-sm border-neutral-dimmed bg-neutral-light\", {\n variants: {\n pinned: {\n false: \"fixed top-0 z-sidebar \"\n }\n }\n});\n\nconst SidebarRoot = ({ side = \"left\", className, children, ...props }: SidebarRootProps) => {\n const { state, setExpanded, pinned, expanded } = useSidebar();\n\n const elementRef = useRef<HTMLDivElement>(null);\n\n // With this timeout, we prevent the sidebar glitching (quickly opening/closing) during mouse enter/leave events.\n const timeoutRef = useRef<number | null>(null);\n\n const onMouseEnter = useCallback<React.MouseEventHandler<HTMLDivElement>>(() => {\n // If the sidebar is pinned, we don't want to open the sidebar on mouse enter.\n if (pinned) {\n return;\n }\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n\n // Add delay before opening to prevent accidental openings\n timeoutRef.current = window.setTimeout(() => {\n // Only set expanded if it's not already expanded\n if (!expanded) {\n setExpanded(true);\n }\n }, 300);\n }, [pinned, setExpanded, expanded]);\n\n const onMouseLeave = useCallback<React.MouseEventHandler<HTMLDivElement>>(() => {\n // If the sidebar is pinned, we don't want to close the sidebar on mouse leave.\n if (pinned) {\n return;\n }\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n\n // With this timeout, we prevent the sidebar glitching (quickly opening/closing) during mouse enter/leave events.\n timeoutRef.current = window.setTimeout(() => {\n setExpanded(false);\n }, 300);\n }, [pinned, setExpanded]);\n\n return (\n <div\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n ref={elementRef}\n data-state={state}\n data-sidebar={\"root\"}\n data-side={side}\n className={variants({ pinned })}\n >\n <div\n className={cn(\n \"duration-175 relative h-svh w-sidebar-expanded bg-transparent transition-[width] ease-linear duration-175\",\n \"group-data-[side=right]:rotate-180\",\n \"group-data-[state=collapsed]:w-sidebar-collapsed\"\n )}\n />\n <div\n className={cn(\n \"duration-175 fixed inset-y-0 z-sidebar h-svh w-sidebar-expanded transition-[width] ease-linear md:flex\",\n side === \"left\" ? \"left-0\" : \"right-0\",\n \"group-data-[state=collapsed]:w-sidebar-collapsed group-data-[side=left]:border-r-px group-data-[side=right]:border-l-px\",\n className\n )}\n {...props}\n >\n <div\n data-sidebar=\"sidebar\"\n className=\"flex h-full w-full py-xs flex-col overflow-hidden\"\n >\n {children}\n </div>\n </div>\n\n <div\n data-sidebar={\"extra-hover-area\"}\n className={\n \"absolute top-0 left-[theme(spacing.sidebar-collapsed)] h-full w-sm hidden group-data-[state=collapsed]:block\"\n }\n />\n </div>\n );\n};\n\nexport { SidebarRoot, type SidebarRootProps };\n"],"names":["variants","cva","SidebarRoot","side","className","children","props","state","setExpanded","pinned","expanded","useSidebar","elementRef","useRef","timeoutRef","onMouseEnter","useCallback","window","onMouseLeave","cn"],"mappings":";;;AAQA,MAAMA,WAAWC,IAAI,uEAAuE;IACxF,UAAU;QACN,QAAQ;YACJ,OAAO;QACX;IACJ;AACJ;AAEA,MAAMC,cAAc,CAAC,EAAEC,OAAO,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGC,OAAyB;IACnF,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGC;IAEjD,MAAMC,aAAaC,OAAuB;IAG1C,MAAMC,aAAaD,OAAsB;IAEzC,MAAME,eAAeC,YAAqD;QAEtE,IAAIP,QACA;QAGJ,IAAIK,WAAW,OAAO,EAAE;YACpBG,OAAO,YAAY,CAACH,WAAW,OAAO;YACtCA,WAAW,OAAO,GAAG;QACzB;QAGAA,WAAW,OAAO,GAAGG,OAAO,UAAU,CAAC;YAEnC,IAAI,CAACP,UACDF,YAAY;QAEpB,GAAG;IACP,GAAG;QAACC;QAAQD;QAAaE;KAAS;IAElC,MAAMQ,eAAeF,YAAqD;QAEtE,IAAIP,QACA;QAGJ,IAAIK,WAAW,OAAO,EAAE;YACpBG,OAAO,YAAY,CAACH,WAAW,OAAO;YACtCA,WAAW,OAAO,GAAG;QACzB;QAGAA,WAAW,OAAO,GAAGG,OAAO,UAAU,CAAC;YACnCT,YAAY;QAChB,GAAG;IACP,GAAG;QAACC;QAAQD;KAAY;IAExB,OAAO,WAAP,GACI,oBAAC;QACG,cAAcO;QACd,cAAcG;QACd,KAAKN;QACL,cAAYL;QACZ,gBAAc;QACd,aAAWJ;QACX,WAAWH,SAAS;YAAES;QAAO;qBAE7B,oBAAC;QACG,WAAWU,GACP,6GACA,sCACA;sBAGR,oBAAC;QACG,WAAWA,GACP,0GACAhB,AAAS,WAATA,OAAkB,WAAW,WAC7B,2HACAC;QAEH,GAAGE,KAAK;qBAET,oBAAC;QACG,gBAAa;QACb,WAAU;OAETD,YAAAA,WAAAA,GAIT,oBAAC;QACG,gBAAc;QACd,WACI;;AAKpB"}
@@ -1,5 +1,5 @@
1
1
  import react from "react";
2
- import { cva } from "../../../utils.js";
2
+ import { cn, cva } from "../../../utils.js";
3
3
  import { DivButton } from "./DivButton.js";
4
4
  import { SidebarMenuItemBadge } from "./SidebarMenuItemBadge.js";
5
5
  import { useAdminUi } from "../../../index.js";
@@ -35,25 +35,28 @@ const SidebarMenuSubButton = ({ onClick, variant, active, disabled, icon, pinned
35
35
  className: variants({
36
36
  variant,
37
37
  disabled,
38
- className
38
+ className: cn(className, action && "pr-xl")
39
39
  }),
40
40
  onClick
41
41
  };
42
+ const textContent = /*#__PURE__*/ react.createElement("span", {
43
+ className: "truncate"
44
+ }, text);
42
45
  const content = to ? /*#__PURE__*/ react.createElement(LinkComponent, {
43
46
  ...sharedProps,
44
47
  to: to,
45
48
  ...linkProps
46
- }, icon, text, badge && ("string" == typeof badge ? /*#__PURE__*/ react.createElement(SidebarMenuItemBadge, {
49
+ }, icon, textContent, badge && ("string" == typeof badge ? /*#__PURE__*/ react.createElement(SidebarMenuItemBadge, {
47
50
  text: badge
48
51
  }) : badge)) : /*#__PURE__*/ react.createElement(DivButton, {
49
52
  ...sharedProps,
50
53
  disabled: disabled,
51
54
  tabIndex: "group-label" === variant ? -1 : void 0
52
- }, icon, text, badge && ("string" == typeof badge ? /*#__PURE__*/ react.createElement(SidebarMenuItemBadge, {
55
+ }, icon, textContent, badge && ("string" == typeof badge ? /*#__PURE__*/ react.createElement(SidebarMenuItemBadge, {
53
56
  text: badge
54
57
  }) : badge));
55
58
  return /*#__PURE__*/ react.createElement("div", {
56
- className: "flex items-center w-full relative group/menu-sub-button"
59
+ className: "flex items-center w-full min-w-0 relative group/menu-sub-button"
57
60
  }, content, action && /*#__PURE__*/ react.createElement("div", {
58
61
  className: "absolute top-0 right-0 mr-sm h-full flex items-center"
59
62
  }, action));
@@ -1 +1 @@
1
- {"version":3,"file":"Sidebar/components/items/SidebarMenuSubButton.js","sources":["../../../../src/Sidebar/components/items/SidebarMenuSubButton.tsx"],"sourcesContent":["import React from \"react\";\nimport { cva } from \"~/utils.js\";\nimport type { SidebarMenuItemProps } from \"./SidebarMenuRootItem.js\";\nimport { DivButton } from \"./DivButton.js\";\nimport { SidebarMenuItemBadge } from \"./SidebarMenuItemBadge.js\";\nimport { DistributedOmit } from \"type-fest\";\nimport { useAdminUi } from \"~/index.js\";\n\nconst variants = cva(\n [\n \"flex w-full cursor-pointer items-center gap-sm\",\n \"text-md text-neutral-primary no-underline!\",\n \"rounded-md p-xs-plus pr-sm outline-none\",\n \"whitespace-nowrap overflow-hidden\",\n \"hover:bg-neutral-dark/5\",\n \"group-hover/menu-sub-button:bg-neutral-dark/5\",\n \"focus:bg-neutral-dark/5 focus:ring-none focus:ring-transparent\",\n \"data-[active=true]:bg-neutral-dark/5 data-[active=true]:font-semibold data-[active=true]:pointer-events-none\",\n \"group-data-[state=collapsed]:hidden\"\n ],\n {\n variants: {\n variant: {\n \"group-label\": [\n \"uppercase font-semibold text-neutral-muted! text-sm\",\n \"pt-md pb-xs-plus pointer-events-none\",\n \"hover:bg-transparent! group-hover/menu-sub-button:bg-transparent! focus:bg-transparent! cursor-default!\"\n ]\n },\n disabled: {\n true: \"pointer-events-none text-neutral-disabled!\"\n }\n }\n }\n);\n\ntype SidebarMenuSubButtonProps = DistributedOmit<SidebarMenuItemProps, \"children\">;\n\nconst SidebarMenuSubButton = ({\n onClick,\n variant,\n active,\n disabled,\n icon,\n\n // oxlint-disable-next-line\n pinnedIcon,\n\n action,\n text,\n badge,\n className,\n to,\n ...linkProps\n}: SidebarMenuSubButtonProps) => {\n const { linkComponent: LinkComponent } = useAdminUi();\n\n const sharedProps = {\n \"data-sidebar\": \"menu-sub-button\",\n \"data-active\": active,\n className: variants({ variant, disabled, className }),\n onClick\n };\n\n const content = to ? (\n <LinkComponent {...sharedProps} to={to} {...linkProps}>\n {icon}\n {text}\n {badge && (typeof badge === \"string\" ? <SidebarMenuItemBadge text={badge} /> : badge)}\n </LinkComponent>\n ) : (\n // We can't use the default button element here because the content of the button\n // can also contain a button, which is not allowed in HTML.\n <DivButton\n {...sharedProps}\n disabled={disabled}\n tabIndex={variant === \"group-label\" ? -1 : undefined}\n >\n {icon}\n {text}\n {badge && (typeof badge === \"string\" ? <SidebarMenuItemBadge text={badge} /> : badge)}\n </DivButton>\n );\n\n return (\n <div className={\"flex items-center w-full relative group/menu-sub-button\"}>\n {content}\n\n {action && (\n <div className=\"absolute top-0 right-0 mr-sm h-full flex items-center\">\n {action}\n </div>\n )}\n </div>\n );\n};\n\nexport { SidebarMenuSubButton };\n"],"names":["variants","cva","SidebarMenuSubButton","onClick","variant","active","disabled","icon","pinnedIcon","action","text","badge","className","to","linkProps","LinkComponent","useAdminUi","sharedProps","content","SidebarMenuItemBadge","DivButton","undefined"],"mappings":";;;;;AAQA,MAAMA,WAAWC,IACb;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH,EACD;IACI,UAAU;QACN,SAAS;YACL,eAAe;gBACX;gBACA;gBACA;aACH;QACL;QACA,UAAU;YACN,MAAM;QACV;IACJ;AACJ;AAKJ,MAAMC,uBAAuB,CAAC,EAC1BC,OAAO,EACPC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,IAAI,EAGJC,UAAU,EAEVC,MAAM,EACNC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,EAAE,EACF,GAAGC,WACqB;IACxB,MAAM,EAAE,eAAeC,aAAa,EAAE,GAAGC;IAEzC,MAAMC,cAAc;QAChB,gBAAgB;QAChB,eAAeZ;QACf,WAAWL,SAAS;YAAEI;YAASE;YAAUM;QAAU;QACnDT;IACJ;IAEA,MAAMe,UAAUL,KAAK,WAALA,GACZ,oBAACE,eAAAA;QAAe,GAAGE,WAAW;QAAE,IAAIJ;QAAK,GAAGC,SAAS;OAChDP,MACAG,MACAC,SAAU,CAAiB,YAAjB,OAAOA,QAAqB,WAAX,GAAW,oBAACQ,sBAAoBA;QAAC,MAAMR;SAAYA,KAAI,K,cAKvF,oBAACS,WAASA;QACL,GAAGH,WAAW;QACf,UAAUX;QACV,UAAUF,AAAY,kBAAZA,UAA4B,KAAKiB;OAE1Cd,MACAG,MACAC,SAAU,CAAiB,YAAjB,OAAOA,QAAqB,WAAX,GAAW,oBAACQ,sBAAoBA;QAAC,MAAMR;SAAYA,KAAI;IAI3F,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;OACXO,SAEAT,UAAU,WAAVA,GACG,oBAAC;QAAI,WAAU;OACVA;AAKrB"}
1
+ {"version":3,"file":"Sidebar/components/items/SidebarMenuSubButton.js","sources":["../../../../src/Sidebar/components/items/SidebarMenuSubButton.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn, cva } from \"~/utils.js\";\nimport type { SidebarMenuItemProps } from \"./SidebarMenuRootItem.js\";\nimport { DivButton } from \"./DivButton.js\";\nimport { SidebarMenuItemBadge } from \"./SidebarMenuItemBadge.js\";\nimport { DistributedOmit } from \"type-fest\";\nimport { useAdminUi } from \"~/index.js\";\n\nconst variants = cva(\n [\n \"flex w-full cursor-pointer items-center gap-sm\",\n \"text-md text-neutral-primary no-underline!\",\n \"rounded-md p-xs-plus pr-sm outline-none\",\n \"whitespace-nowrap overflow-hidden\",\n \"hover:bg-neutral-dark/5\",\n \"group-hover/menu-sub-button:bg-neutral-dark/5\",\n \"focus:bg-neutral-dark/5 focus:ring-none focus:ring-transparent\",\n \"data-[active=true]:bg-neutral-dark/5 data-[active=true]:font-semibold data-[active=true]:pointer-events-none\",\n \"group-data-[state=collapsed]:hidden\"\n ],\n {\n variants: {\n variant: {\n \"group-label\": [\n \"uppercase font-semibold text-neutral-muted! text-sm\",\n \"pt-md pb-xs-plus pointer-events-none\",\n \"hover:bg-transparent! group-hover/menu-sub-button:bg-transparent! focus:bg-transparent! cursor-default!\"\n ]\n },\n disabled: {\n true: \"pointer-events-none text-neutral-disabled!\"\n }\n }\n }\n);\n\ntype SidebarMenuSubButtonProps = DistributedOmit<SidebarMenuItemProps, \"children\">;\n\nconst SidebarMenuSubButton = ({\n onClick,\n variant,\n active,\n disabled,\n icon,\n\n // oxlint-disable-next-line\n pinnedIcon,\n\n action,\n text,\n badge,\n className,\n to,\n ...linkProps\n}: SidebarMenuSubButtonProps) => {\n const { linkComponent: LinkComponent } = useAdminUi();\n\n const sharedProps = {\n \"data-sidebar\": \"menu-sub-button\",\n \"data-active\": active,\n className: variants({ variant, disabled, className: cn(className, action && \"pr-xl\") }),\n onClick\n };\n\n const textContent = <span className=\"truncate\">{text}</span>;\n\n const content = to ? (\n <LinkComponent {...sharedProps} to={to} {...linkProps}>\n {icon}\n {textContent}\n {badge && (typeof badge === \"string\" ? <SidebarMenuItemBadge text={badge} /> : badge)}\n </LinkComponent>\n ) : (\n // We can't use the default button element here because the content of the button\n // can also contain a button, which is not allowed in HTML.\n <DivButton\n {...sharedProps}\n disabled={disabled}\n tabIndex={variant === \"group-label\" ? -1 : undefined}\n >\n {icon}\n {textContent}\n {badge && (typeof badge === \"string\" ? <SidebarMenuItemBadge text={badge} /> : badge)}\n </DivButton>\n );\n\n return (\n <div className={\"flex items-center w-full min-w-0 relative group/menu-sub-button\"}>\n {content}\n\n {action && (\n <div className=\"absolute top-0 right-0 mr-sm h-full flex items-center\">\n {action}\n </div>\n )}\n </div>\n );\n};\n\nexport { SidebarMenuSubButton };\n"],"names":["variants","cva","SidebarMenuSubButton","onClick","variant","active","disabled","icon","pinnedIcon","action","text","badge","className","to","linkProps","LinkComponent","useAdminUi","sharedProps","cn","textContent","content","SidebarMenuItemBadge","DivButton","undefined"],"mappings":";;;;;AAQA,MAAMA,WAAWC,IACb;IACI;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH,EACD;IACI,UAAU;QACN,SAAS;YACL,eAAe;gBACX;gBACA;gBACA;aACH;QACL;QACA,UAAU;YACN,MAAM;QACV;IACJ;AACJ;AAKJ,MAAMC,uBAAuB,CAAC,EAC1BC,OAAO,EACPC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,IAAI,EAGJC,UAAU,EAEVC,MAAM,EACNC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,EAAE,EACF,GAAGC,WACqB;IACxB,MAAM,EAAE,eAAeC,aAAa,EAAE,GAAGC;IAEzC,MAAMC,cAAc;QAChB,gBAAgB;QAChB,eAAeZ;QACf,WAAWL,SAAS;YAAEI;YAASE;YAAU,WAAWY,GAAGN,WAAWH,UAAU;QAAS;QACrFN;IACJ;IAEA,MAAMgB,cAAc,WAAdA,GAAc,oBAAC;QAAK,WAAU;OAAYT;IAEhD,MAAMU,UAAUP,KAAK,WAALA,GACZ,oBAACE,eAAAA;QAAe,GAAGE,WAAW;QAAE,IAAIJ;QAAK,GAAGC,SAAS;OAChDP,MACAY,aACAR,SAAU,CAAiB,YAAjB,OAAOA,QAAqB,WAAX,GAAW,oBAACU,sBAAoBA;QAAC,MAAMV;SAAYA,KAAI,K,cAKvF,oBAACW,WAASA;QACL,GAAGL,WAAW;QACf,UAAUX;QACV,UAAUF,AAAY,kBAAZA,UAA4B,KAAKmB;OAE1ChB,MACAY,aACAR,SAAU,CAAiB,YAAjB,OAAOA,QAAqB,WAAX,GAAW,oBAACU,sBAAoBA;QAAC,MAAMV;SAAYA,KAAI;IAI3F,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;OACXS,SAEAX,UAAU,WAAVA,GACG,oBAAC;QAAI,WAAU;OACVA;AAKrB"}
@@ -117,7 +117,7 @@ const SidebarMenuSubItem = ({ children, className, pinnable, action, collapsible
117
117
  className: "flex items-center gap-xs"
118
118
  }, pinAction, chevron) : chevron;
119
119
  if (!collapsible) return /*#__PURE__*/ react.createElement("div", {
120
- className: "flex items-center"
120
+ className: "flex items-center min-w-0"
121
121
  }, /*#__PURE__*/ react.createElement(SidebarMenuSubItemIndentation, {
122
122
  lvl: currentLevel,
123
123
  variant: buttonProps.variant
@@ -127,7 +127,7 @@ const SidebarMenuSubItem = ({ children, className, pinnable, action, collapsible
127
127
  open: isSectionExpanded,
128
128
  onOpenChange: toggleSectionExpanded
129
129
  }, /*#__PURE__*/ react.createElement("div", {
130
- className: "flex items-center"
130
+ className: "flex items-center min-w-0"
131
131
  }, /*#__PURE__*/ react.createElement(SidebarMenuSubItemIndentation, {
132
132
  lvl: currentLevel,
133
133
  variant: buttonProps.variant
@@ -153,7 +153,7 @@ const SidebarMenuSubItem = ({ children, className, pinnable, action, collapsible
153
153
  ]);
154
154
  return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement("li", {
155
155
  "data-sidebar": "menu-sub-item",
156
- className: cn("group/menu-sub-item relative flex", className)
156
+ className: cn("group/menu-sub-item relative flex min-w-0", className)
157
157
  }, sidebarMenuSubButton), children && !collapsible ? children : null);
158
158
  };
159
159
  export { SidebarMenuSubItem };
@@ -1 +1 @@
1
- {"version":3,"file":"Sidebar/components/items/SidebarMenuSubItem.js","sources":["../../../../src/Sidebar/components/items/SidebarMenuSubItem.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { cn } from \"~/utils.js\";\nimport { Collapsible } from \"radix-ui\";\nimport { SidebarMenuSubButton } from \"./SidebarMenuSubButton.js\";\nimport { SidebarMenuSubItemIndentation } from \"./SidebarMenuSubItemIndentation.js\";\nimport { SidebarMenuSub } from \"./SidebarMenuSub.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport { ReactComponent as KeyboardArrowRightIcon } from \"@webiny/icons/keyboard_arrow_down.svg\";\nimport { ReactComponent as PinIcon } from \"@webiny/icons/push_pin.svg\";\nimport { ReactComponent as UnPinIcon } from \"@webiny/icons/push_pin_off.svg\";\nimport { useSidebarMenu } from \"./SidebarMenuProvider.js\";\nimport { type SidebarMenuItemProps } from \"./SidebarMenuItem.js\";\nimport { useSidebar } from \"~/Sidebar/index.js\";\nimport { SidebarMenuItemAction } from \"./SidebarMenuItemAction.js\";\n\nconst SidebarMenuSubItem = ({\n children,\n className,\n pinnable,\n action,\n collapsible = true,\n ...buttonProps\n}: SidebarMenuItemProps) => {\n const { currentLevel, parentIcon } = useSidebarMenu();\n const sidebar = useSidebar();\n const [showChevron, setShowChevron] = useState(false);\n\n const menuItemId = useMemo(() => {\n return btoa(`sidebar-item-${currentLevel}-${buttonProps.text}`);\n }, [buttonProps.text, currentLevel]);\n\n const isSectionExpanded = useMemo(() => {\n return sidebar.isSectionExpanded(menuItemId);\n }, [sidebar.expandedSections]);\n\n const toggleSectionExpanded = useCallback(() => {\n sidebar.toggleSectionExpanded(menuItemId);\n }, [isSectionExpanded]);\n\n const isPinned = sidebar.isItemPinned(menuItemId);\n\n // Icon to use when this item is pinned\n const pinnedItemIcon = useMemo(() => {\n if (buttonProps.pinnedIcon) {\n return buttonProps.pinnedIcon;\n }\n\n return buttonProps.icon || parentIcon;\n }, [buttonProps.pinnedIcon, buttonProps.icon, parentIcon]);\n\n // Register when pinned, unregister when unpinned\n // Re-register when active state changes to keep pinned items in sync\n React.useEffect(() => {\n if (pinnable && isPinned) {\n sidebar.registerPinnedItem({\n id: menuItemId,\n text: buttonProps.text,\n icon: pinnedItemIcon,\n to: buttonProps.to,\n onClick: buttonProps.onClick,\n active: buttonProps.active\n });\n } else if (pinnable && !isPinned) {\n // Only unregister if this item is explicitly unpinned\n sidebar.unregisterPinnedItem(menuItemId);\n }\n }, [pinnable, isPinned, pinnedItemIcon, menuItemId, buttonProps.active]);\n\n const pinAction = useMemo(() => {\n if (!pinnable) {\n return action;\n }\n\n const handlePinClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n\n if (isPinned) {\n sidebar.unregisterPinnedItem(menuItemId);\n } else {\n sidebar.registerPinnedItem({\n id: menuItemId,\n text: buttonProps.text,\n icon: pinnedItemIcon,\n to: buttonProps.to,\n onClick: buttonProps.onClick,\n active: buttonProps.active\n });\n }\n\n sidebar.toggleItemPinned(menuItemId);\n };\n\n const pinButton = (\n <SidebarMenuItemAction\n element={isPinned ? <UnPinIcon /> : <PinIcon />}\n onClick={handlePinClick}\n showOnHover={true}\n />\n );\n\n // If there's a custom action, combine them\n // Don't modify the custom action - it should keep its original behavior\n if (action) {\n return (\n <div className=\"flex items-center gap-xs\">\n {pinButton}\n {action}\n </div>\n );\n }\n\n return pinButton;\n }, [pinnable, isPinned, pinnedItemIcon, action, sidebar, menuItemId]);\n\n useEffect(() => {\n if (sidebar.expanded) {\n const timer = setTimeout(() => {\n setShowChevron(true);\n }, 100);\n return () => clearTimeout(timer);\n }\n setShowChevron(false);\n return undefined;\n }, [sidebar.expanded]);\n\n const sidebarMenuSubButton = useMemo(() => {\n if (!children) {\n return (\n <>\n <SidebarMenuSubItemIndentation\n lvl={currentLevel}\n variant={buttonProps.variant}\n />\n <SidebarMenuSubButton {...buttonProps} action={pinAction} />\n </>\n );\n }\n\n const chevron = showChevron ? (\n <Icon\n label={\"Expand / Collapse\"}\n size={\"sm\"}\n className={\n \"ml-auto transition-transform duration-100 group-data-[state=open]/menu-sub-item-collapsible:rotate-180 group-data-[state=collapsed]:hidden\"\n }\n color={\"neutral-strong\"}\n data-sidebar={\"menu-item-expanded-indicator\"}\n icon={<KeyboardArrowRightIcon />}\n />\n ) : null;\n\n const collapsibleAction = pinnable ? (\n <div className=\"flex items-center gap-xs\">\n {pinAction}\n {chevron}\n </div>\n ) : (\n chevron\n );\n\n if (!collapsible) {\n return (\n <div className={\"flex items-center\"}>\n <SidebarMenuSubItemIndentation\n lvl={currentLevel}\n variant={buttonProps.variant}\n />\n <SidebarMenuSubButton {...buttonProps} />\n </div>\n );\n }\n\n return (\n <Collapsible.Root\n className=\"w-full group/menu-sub-item-collapsible\"\n open={isSectionExpanded}\n onOpenChange={toggleSectionExpanded}\n >\n <div className={\"flex items-center\"}>\n <SidebarMenuSubItemIndentation\n lvl={currentLevel}\n variant={buttonProps.variant}\n />\n <Collapsible.Trigger asChild>\n <SidebarMenuSubButton\n {...buttonProps}\n action={collapsibleAction}\n className={\n \"group-data-[state=open]/menu-sub-item-collapsible:font-semibold!\"\n }\n />\n </Collapsible.Trigger>\n </div>\n <Collapsible.Content>\n <SidebarMenuSub parentIcon={buttonProps.icon}>{children}</SidebarMenuSub>\n </Collapsible.Content>\n </Collapsible.Root>\n );\n }, [\n children,\n buttonProps,\n currentLevel,\n menuItemId,\n isSectionExpanded,\n toggleSectionExpanded,\n showChevron,\n pinnable,\n pinAction\n ]);\n\n return (\n <>\n <li\n data-sidebar=\"menu-sub-item\"\n className={cn(\"group/menu-sub-item relative flex\", className)}\n >\n {sidebarMenuSubButton}\n </li>\n {children && !collapsible ? children : null}\n </>\n );\n};\n\nexport { SidebarMenuSubItem };\n"],"names":["SidebarMenuSubItem","children","className","pinnable","action","collapsible","buttonProps","currentLevel","parentIcon","useSidebarMenu","sidebar","useSidebar","showChevron","setShowChevron","useState","menuItemId","useMemo","btoa","isSectionExpanded","toggleSectionExpanded","useCallback","isPinned","pinnedItemIcon","React","pinAction","handlePinClick","e","pinButton","SidebarMenuItemAction","UnPinIcon","PinIcon","useEffect","timer","setTimeout","clearTimeout","sidebarMenuSubButton","SidebarMenuSubItemIndentation","SidebarMenuSubButton","chevron","Icon","KeyboardArrowRightIcon","collapsibleAction","Collapsible","SidebarMenuSub","cn"],"mappings":";;;;;;;;;;;;;AAeA,MAAMA,qBAAqB,CAAC,EACxBC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,MAAM,EACNC,cAAc,IAAI,EAClB,GAAGC,aACgB;IACnB,MAAM,EAAEC,YAAY,EAAEC,UAAU,EAAE,GAAGC;IACrC,MAAMC,UAAUC;IAChB,MAAM,CAACC,aAAaC,eAAe,GAAGC,SAAS;IAE/C,MAAMC,aAAaC,QAAQ,IAChBC,KAAK,CAAC,aAAa,EAAEV,aAAa,CAAC,EAAED,YAAY,IAAI,EAAE,GAC/D;QAACA,YAAY,IAAI;QAAEC;KAAa;IAEnC,MAAMW,oBAAoBF,QAAQ,IACvBN,QAAQ,iBAAiB,CAACK,aAClC;QAACL,QAAQ,gBAAgB;KAAC;IAE7B,MAAMS,wBAAwBC,YAAY;QACtCV,QAAQ,qBAAqB,CAACK;IAClC,GAAG;QAACG;KAAkB;IAEtB,MAAMG,WAAWX,QAAQ,YAAY,CAACK;IAGtC,MAAMO,iBAAiBN,QAAQ;QAC3B,IAAIV,YAAY,UAAU,EACtB,OAAOA,YAAY,UAAU;QAGjC,OAAOA,YAAY,IAAI,IAAIE;IAC/B,GAAG;QAACF,YAAY,UAAU;QAAEA,YAAY,IAAI;QAAEE;KAAW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AAuBnB,QAAQ;QACjC,IAAI,CAACf,UACD,OAAO,WAAP,GACI,wDACI,oBAACmC,+BAA6BA;YAC1B,KAAK7B;YACL,SAASD,YAAY,OAAO;0BAEhC,oBAAC+B,sBAAoBA;YAAE,GAAG/B,WAAW;YAAE,QAAQkB;;QAK3D,MAAMc,UAAU1B,cAAc,WAAdA,GACZ,oBAAC2B,MAAIA;YACD,OAAO;YACP,MAAM;YACN,WACI;YAEJ,OAAO;YACP,gBAAc;YACd,oBAAM,oBAACC,gBAAsBA;aAEjC;QAEJ,MAAMC,oBAAoBtC,WAAW,WAAXA,GACtB,oBAAC;YAAI,WAAU;WACVqB,WACAc,WAGLA;QAGJ,IAAI,CAACjC,aACD,OAAO,WAAP,GACI,oBAAC;YAAI,WAAW;yBACZ,oBAAC+B,+BAA6BA;YAC1B,KAAK7B;YACL,SAASD,YAAY,OAAO;0BAEhC,oBAAC+B,sBAAyB/B;QAKtC,OAAO,WAAP,GACI,oBAACoC,YAAY,IAAI;YACb,WAAU;YACV,MAAMxB;YACN,cAAcC;yBAEd,oBAAC;YAAI,WAAW;yBACZ,oBAACiB,+BAA6BA;YAC1B,KAAK7B;YACL,SAASD,YAAY,OAAO;0BAEhC,oBAACoC,YAAY,OAAO;YAAC;yBACjB,oBAACL,sBAAoBA;YAChB,GAAG/B,WAAW;YACf,QAAQmC;YACR,WACI;4BAKhB,oBAACC,YAAY,OAAO,sBAChB,oBAACC,gBAAcA;YAAC,YAAYrC,YAAY,IAAI;WAAGL;IAI/D,GAAG;QACCA;QACAK;QACAC;QACAQ;QACAG;QACAC;QACAP;QACAT;QACAqB;KACH;IAED,OAAO,WAAP,GACI,wDACI,oBAAC;QACG,gBAAa;QACb,WAAWoB,GAAG,qCAAqC1C;OAElDiC,uBAEJlC,YAAY,CAACI,cAAcJ,WAAW;AAGnD"}
1
+ {"version":3,"file":"Sidebar/components/items/SidebarMenuSubItem.js","sources":["../../../../src/Sidebar/components/items/SidebarMenuSubItem.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { cn } from \"~/utils.js\";\nimport { Collapsible } from \"radix-ui\";\nimport { SidebarMenuSubButton } from \"./SidebarMenuSubButton.js\";\nimport { SidebarMenuSubItemIndentation } from \"./SidebarMenuSubItemIndentation.js\";\nimport { SidebarMenuSub } from \"./SidebarMenuSub.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport { ReactComponent as KeyboardArrowRightIcon } from \"@webiny/icons/keyboard_arrow_down.svg\";\nimport { ReactComponent as PinIcon } from \"@webiny/icons/push_pin.svg\";\nimport { ReactComponent as UnPinIcon } from \"@webiny/icons/push_pin_off.svg\";\nimport { useSidebarMenu } from \"./SidebarMenuProvider.js\";\nimport { type SidebarMenuItemProps } from \"./SidebarMenuItem.js\";\nimport { useSidebar } from \"~/Sidebar/index.js\";\nimport { SidebarMenuItemAction } from \"./SidebarMenuItemAction.js\";\n\nconst SidebarMenuSubItem = ({\n children,\n className,\n pinnable,\n action,\n collapsible = true,\n ...buttonProps\n}: SidebarMenuItemProps) => {\n const { currentLevel, parentIcon } = useSidebarMenu();\n const sidebar = useSidebar();\n const [showChevron, setShowChevron] = useState(false);\n\n const menuItemId = useMemo(() => {\n return btoa(`sidebar-item-${currentLevel}-${buttonProps.text}`);\n }, [buttonProps.text, currentLevel]);\n\n const isSectionExpanded = useMemo(() => {\n return sidebar.isSectionExpanded(menuItemId);\n }, [sidebar.expandedSections]);\n\n const toggleSectionExpanded = useCallback(() => {\n sidebar.toggleSectionExpanded(menuItemId);\n }, [isSectionExpanded]);\n\n const isPinned = sidebar.isItemPinned(menuItemId);\n\n // Icon to use when this item is pinned\n const pinnedItemIcon = useMemo(() => {\n if (buttonProps.pinnedIcon) {\n return buttonProps.pinnedIcon;\n }\n\n return buttonProps.icon || parentIcon;\n }, [buttonProps.pinnedIcon, buttonProps.icon, parentIcon]);\n\n // Register when pinned, unregister when unpinned\n // Re-register when active state changes to keep pinned items in sync\n React.useEffect(() => {\n if (pinnable && isPinned) {\n sidebar.registerPinnedItem({\n id: menuItemId,\n text: buttonProps.text,\n icon: pinnedItemIcon,\n to: buttonProps.to,\n onClick: buttonProps.onClick,\n active: buttonProps.active\n });\n } else if (pinnable && !isPinned) {\n // Only unregister if this item is explicitly unpinned\n sidebar.unregisterPinnedItem(menuItemId);\n }\n }, [pinnable, isPinned, pinnedItemIcon, menuItemId, buttonProps.active]);\n\n const pinAction = useMemo(() => {\n if (!pinnable) {\n return action;\n }\n\n const handlePinClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n\n if (isPinned) {\n sidebar.unregisterPinnedItem(menuItemId);\n } else {\n sidebar.registerPinnedItem({\n id: menuItemId,\n text: buttonProps.text,\n icon: pinnedItemIcon,\n to: buttonProps.to,\n onClick: buttonProps.onClick,\n active: buttonProps.active\n });\n }\n\n sidebar.toggleItemPinned(menuItemId);\n };\n\n const pinButton = (\n <SidebarMenuItemAction\n element={isPinned ? <UnPinIcon /> : <PinIcon />}\n onClick={handlePinClick}\n showOnHover={true}\n />\n );\n\n // If there's a custom action, combine them\n // Don't modify the custom action - it should keep its original behavior\n if (action) {\n return (\n <div className=\"flex items-center gap-xs\">\n {pinButton}\n {action}\n </div>\n );\n }\n\n return pinButton;\n }, [pinnable, isPinned, pinnedItemIcon, action, sidebar, menuItemId]);\n\n useEffect(() => {\n if (sidebar.expanded) {\n const timer = setTimeout(() => {\n setShowChevron(true);\n }, 100);\n return () => clearTimeout(timer);\n }\n setShowChevron(false);\n return undefined;\n }, [sidebar.expanded]);\n\n const sidebarMenuSubButton = useMemo(() => {\n if (!children) {\n return (\n <>\n <SidebarMenuSubItemIndentation\n lvl={currentLevel}\n variant={buttonProps.variant}\n />\n <SidebarMenuSubButton {...buttonProps} action={pinAction} />\n </>\n );\n }\n\n const chevron = showChevron ? (\n <Icon\n label={\"Expand / Collapse\"}\n size={\"sm\"}\n className={\n \"ml-auto transition-transform duration-100 group-data-[state=open]/menu-sub-item-collapsible:rotate-180 group-data-[state=collapsed]:hidden\"\n }\n color={\"neutral-strong\"}\n data-sidebar={\"menu-item-expanded-indicator\"}\n icon={<KeyboardArrowRightIcon />}\n />\n ) : null;\n\n const collapsibleAction = pinnable ? (\n <div className=\"flex items-center gap-xs\">\n {pinAction}\n {chevron}\n </div>\n ) : (\n chevron\n );\n\n if (!collapsible) {\n return (\n <div className={\"flex items-center min-w-0\"}>\n <SidebarMenuSubItemIndentation\n lvl={currentLevel}\n variant={buttonProps.variant}\n />\n <SidebarMenuSubButton {...buttonProps} />\n </div>\n );\n }\n\n return (\n <Collapsible.Root\n className=\"w-full group/menu-sub-item-collapsible\"\n open={isSectionExpanded}\n onOpenChange={toggleSectionExpanded}\n >\n <div className={\"flex items-center min-w-0\"}>\n <SidebarMenuSubItemIndentation\n lvl={currentLevel}\n variant={buttonProps.variant}\n />\n <Collapsible.Trigger asChild>\n <SidebarMenuSubButton\n {...buttonProps}\n action={collapsibleAction}\n className={\n \"group-data-[state=open]/menu-sub-item-collapsible:font-semibold!\"\n }\n />\n </Collapsible.Trigger>\n </div>\n <Collapsible.Content>\n <SidebarMenuSub parentIcon={buttonProps.icon}>{children}</SidebarMenuSub>\n </Collapsible.Content>\n </Collapsible.Root>\n );\n }, [\n children,\n buttonProps,\n currentLevel,\n menuItemId,\n isSectionExpanded,\n toggleSectionExpanded,\n showChevron,\n pinnable,\n pinAction\n ]);\n\n return (\n <>\n <li\n data-sidebar=\"menu-sub-item\"\n className={cn(\"group/menu-sub-item relative flex min-w-0\", className)}\n >\n {sidebarMenuSubButton}\n </li>\n {children && !collapsible ? children : null}\n </>\n );\n};\n\nexport { SidebarMenuSubItem };\n"],"names":["SidebarMenuSubItem","children","className","pinnable","action","collapsible","buttonProps","currentLevel","parentIcon","useSidebarMenu","sidebar","useSidebar","showChevron","setShowChevron","useState","menuItemId","useMemo","btoa","isSectionExpanded","toggleSectionExpanded","useCallback","isPinned","pinnedItemIcon","React","pinAction","handlePinClick","e","pinButton","SidebarMenuItemAction","UnPinIcon","PinIcon","useEffect","timer","setTimeout","clearTimeout","sidebarMenuSubButton","SidebarMenuSubItemIndentation","SidebarMenuSubButton","chevron","Icon","KeyboardArrowRightIcon","collapsibleAction","Collapsible","SidebarMenuSub","cn"],"mappings":";;;;;;;;;;;;;AAeA,MAAMA,qBAAqB,CAAC,EACxBC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,MAAM,EACNC,cAAc,IAAI,EAClB,GAAGC,aACgB;IACnB,MAAM,EAAEC,YAAY,EAAEC,UAAU,EAAE,GAAGC;IACrC,MAAMC,UAAUC;IAChB,MAAM,CAACC,aAAaC,eAAe,GAAGC,SAAS;IAE/C,MAAMC,aAAaC,QAAQ,IAChBC,KAAK,CAAC,aAAa,EAAEV,aAAa,CAAC,EAAED,YAAY,IAAI,EAAE,GAC/D;QAACA,YAAY,IAAI;QAAEC;KAAa;IAEnC,MAAMW,oBAAoBF,QAAQ,IACvBN,QAAQ,iBAAiB,CAACK,aAClC;QAACL,QAAQ,gBAAgB;KAAC;IAE7B,MAAMS,wBAAwBC,YAAY;QACtCV,QAAQ,qBAAqB,CAACK;IAClC,GAAG;QAACG;KAAkB;IAEtB,MAAMG,WAAWX,QAAQ,YAAY,CAACK;IAGtC,MAAMO,iBAAiBN,QAAQ;QAC3B,IAAIV,YAAY,UAAU,EACtB,OAAOA,YAAY,UAAU;QAGjC,OAAOA,YAAY,IAAI,IAAIE;IAC/B,GAAG;QAACF,YAAY,UAAU;QAAEA,YAAY,IAAI;QAAEE;KAAW;IAIzDe,MAAAA,SAAe,CAAC;QACZ,IAAIpB,YAAYkB,UACZX,QAAQ,kBAAkB,CAAC;YACvB,IAAIK;YACJ,MAAMT,YAAY,IAAI;YACtB,MAAMgB;YACN,IAAIhB,YAAY,EAAE;YAClB,SAASA,YAAY,OAAO;YAC5B,QAAQA,YAAY,MAAM;QAC9B;aACG,IAAIH,YAAY,CAACkB,UAEpBX,QAAQ,oBAAoB,CAACK;IAErC,GAAG;QAACZ;Q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BAAc;YACd,oBAAM,oBAACC,gBAAsBA;aAEjC;QAEJ,MAAMC,oBAAoBtC,WAAW,WAAXA,GACtB,oBAAC;YAAI,WAAU;WACVqB,WACAc,WAGLA;QAGJ,IAAI,CAACjC,aACD,OAAO,WAAP,GACI,oBAAC;YAAI,WAAW;yBACZ,oBAAC+B,+BAA6BA;YAC1B,KAAK7B;YACL,SAASD,YAAY,OAAO;0BAEhC,oBAAC+B,sBAAyB/B;QAKtC,OAAO,WAAP,GACI,oBAACoC,YAAY,IAAI;YACb,WAAU;YACV,MAAMxB;YACN,cAAcC;yBAEd,oBAAC;YAAI,WAAW;yBACZ,oBAACiB,+BAA6BA;YAC1B,KAAK7B;YACL,SAASD,YAAY,OAAO;0BAEhC,oBAACoC,YAAY,OAAO;YAAC;yBACjB,oBAACL,sBAAoBA;YAChB,GAAG/B,WAAW;YACf,QAAQmC;YACR,WACI;4BAKhB,oBAACC,YAAY,OAAO,sBAChB,oBAACC,gBAAcA;YAAC,YAAYrC,YAAY,IAAI;WAAGL;IAI/D,GAAG;QACCA;QACAK;QACAC;QACAQ;QACAG;QACAC;QACAP;QACAT;QACAqB;KACH;IAED,OAAO,WAAP,GACI,wDACI,oBAAC;QACG,gBAAa;QACb,WAAWoB,GAAG,6CAA6C1C;OAE1DiC,uBAEJlC,YAAY,CAACI,cAAcJ,WAAW;AAGnD"}
package/Tree/useTree.js CHANGED
@@ -41,7 +41,6 @@ const useTree = (props)=>{
41
41
  droppable: node.droppable,
42
42
  data: node.data
43
43
  }));
44
- await presenter.handleDrop(newNodeTree);
45
44
  if (props.onDrop) {
46
45
  const { dragSourceId, dropTargetId } = options;
47
46
  const newTreeDto = newNodeTree.map((node)=>NodeFormatter.toDto(node));
@@ -51,8 +50,13 @@ const useTree = (props)=>{
51
50
  dragSource: newTreeDto.find((node)=>node.id === String(options.dragSourceId)),
52
51
  dropTarget: newTreeDto.find((node)=>node.id === String(options.dropTargetId))
53
52
  };
54
- await props.onDrop(newTreeDto, dropOptions);
53
+ try {
54
+ await props.onDrop(newTreeDto, dropOptions);
55
+ } catch {
56
+ return;
57
+ }
55
58
  }
59
+ await presenter.handleDrop(newNodeTree);
56
60
  };
57
61
  const changeOpen = (newOpenIds)=>{
58
62
  if (props.onChangeOpen) {
@@ -1 +1 @@
1
- {"version":3,"file":"Tree/useTree.js","sources":["../../src/Tree/useTree.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport type { DropOptions as DndDropOptions, NodeModel } from \"@minoru/react-dnd-treeview\";\nimport { autorun } from \"mobx\";\nimport { TreePresenter, type TreePresenterInitParams } from \"./presenters/index.js\";\nimport type { TreeProps, DropOptions } from \"./Tree.js\";\nimport { Node, NodeFormatter } from \"./domains/index.js\";\n\nexport const useTree = <TData = Record<string, any>>(props: TreeProps<TData>) => {\n const params: TreePresenterInitParams = useMemo(() => {\n return {\n rootId: props.rootId,\n defaultOpenNodeIds: props.defaultOpenNodeIds,\n defaultLockedOpenNodeIds: props.defaultLockedOpenNodeIds,\n loadingNodeIds: props.loadingNodeIds\n };\n }, [\n props.rootId,\n props.defaultOpenNodeIds,\n props.defaultLockedOpenNodeIds,\n props.loadingNodeIds\n ]);\n\n const presenter = useMemo(() => {\n return new TreePresenter<TData>();\n }, []);\n\n const [vm, setVm] = useState(presenter.vm);\n\n useEffect(() => {\n presenter.init(params);\n }, [params, presenter]);\n\n useEffect(() => {\n presenter.initNodes(props.nodes);\n }, [props.nodes]);\n\n useEffect(() => {\n return autorun(() => {\n setVm(presenter.vm);\n });\n }, [presenter]);\n\n const handleDrop = async (newTree: NodeModel<TData>[], options: DndDropOptions) => {\n if (options.dragSourceId === options.dropTargetId) {\n // Drag source and drop target are the same, no action taken.\n return;\n }\n\n const newNodeTree = newTree.map(node => {\n return Node.create<TData>({\n id: String(node.id),\n label: node.text,\n parentId: String(node.parent),\n droppable: node.droppable,\n data: node.data as TData\n });\n });\n\n await presenter.handleDrop(newNodeTree);\n\n if (props.onDrop) {\n const { dragSourceId, dropTargetId } = options;\n\n const newTreeDto = newNodeTree.map(node => NodeFormatter.toDto<TData>(node));\n\n const dropOptions: DropOptions<TData> = {\n dragSourceId: String(dragSourceId),\n dropTargetId: String(dropTargetId),\n dragSource: newTreeDto.find(node => node.id === String(options.dragSourceId)),\n dropTarget: newTreeDto.find(node => node.id === String(options.dropTargetId))\n };\n\n await props.onDrop(newTreeDto, dropOptions);\n }\n };\n\n const changeOpen = (newOpenIds: NodeModel<TData>[\"id\"][]) => {\n if (props.onChangeOpen) {\n const newOpenNodes = vm.nodes\n .filter(node => newOpenIds.includes(node.id))\n .map(node =>\n NodeFormatter.toDto<TData>(\n Node.create<TData>({\n id: String(node.id),\n label: node.text,\n parentId: String(node.parent),\n droppable: node.droppable,\n data: node.data as TData\n })\n )\n );\n\n props.onChangeOpen(newOpenNodes);\n }\n };\n\n const canDrag = (node: NodeModel<TData> | undefined) => {\n if (!node) {\n return false;\n }\n\n const nodeDto = NodeFormatter.toDto<TData>(\n Node.create<TData>({\n id: String(node.id),\n parentId: String(node.parent),\n droppable: node.droppable,\n label: node.text,\n data: node.data as TData\n })\n );\n\n return props.canDrag ? props.canDrag(nodeDto) : true;\n };\n\n const canDrop = (tree: NodeModel<TData>[], options: DndDropOptions) => {\n if (props.canDrop) {\n const { dragSourceId, dropTargetId } = options;\n\n const nodeTree = tree.map(node => {\n return Node.create<TData>({\n id: String(node.id),\n label: node.text,\n parentId: String(node.parent),\n droppable: node.droppable,\n data: node.data as TData\n });\n });\n\n const nodeTreeDto = nodeTree.map(node => NodeFormatter.toDto<TData>(node));\n\n const dropOptions: DropOptions<TData> = {\n dragSourceId: String(dragSourceId),\n dropTargetId: String(dropTargetId),\n dragSource: nodeTreeDto.find(node => node.id === String(options.dragSourceId)),\n dropTarget: nodeTreeDto.find(node => node.id === String(options.dropTargetId))\n };\n\n return props.canDrop(nodeTreeDto, dropOptions);\n }\n\n return true;\n };\n\n const sort = (a: NodeModel<TData>, b: NodeModel<TData>): number => {\n if (typeof props.sort === \"function\") {\n const nodeTreeA = Node.create<TData>({\n id: String(a.id),\n label: a.text,\n parentId: String(a.parent),\n droppable: a.droppable,\n data: a.data\n });\n\n const nodeTreeB = Node.create<TData>({\n id: String(b.id),\n label: b.text,\n parentId: String(b.parent),\n droppable: b.droppable,\n data: b.data\n });\n\n return props.sort(\n NodeFormatter.toDto<TData>(nodeTreeA),\n NodeFormatter.toDto<TData>(nodeTreeB)\n );\n }\n\n return 0;\n };\n\n return { vm, handleDrop, changeOpen, canDrag, canDrop, sort };\n};\n"],"names":["useTree","props","params","useMemo","presenter","TreePresenter","vm","setVm","useState","useEffect","autorun","handleDrop","newTree","options","newNodeTree","node","Node","String","dragSourceId","dropTargetId","newTreeDto","NodeFormatter","dropOptions","changeOpen","newOpenIds","newOpenNodes","canDrag","nodeDto","canDrop","tree","nodeTree","nodeTreeDto","sort","a","b","nodeTreeA","nodeTreeB"],"mappings":";;;;AAOO,MAAMA,UAAU,CAA8BC;IACjD,MAAMC,SAAkCC,QAAQ,IACrC;YACH,QAAQF,MAAM,MAAM;YACpB,oBAAoBA,MAAM,kBAAkB;YAC5C,0BAA0BA,MAAM,wBAAwB;YACxD,gBAAgBA,MAAM,cAAc;QACxC,IACD;QACCA,MAAM,MAAM;QACZA,MAAM,kBAAkB;QACxBA,MAAM,wBAAwB;QAC9BA,MAAM,cAAc;KACvB;IAED,MAAMG,YAAYD,QAAQ,IACf,IAAIE,iBACZ,EAAE;IAEL,MAAM,CAACC,IAAIC,MAAM,GAAGC,SAASJ,UAAU,EAAE;IAEzCK,UAAU;QACNL,UAAU,IAAI,CAACF;IACnB,GAAG;QAACA;QAAQE;KAAU;IAEtBK,UAAU;QACNL,UAAU,SAAS,CAACH,MAAM,KAAK;IACnC,GAAG;QAACA,MAAM,KAAK;KAAC;IAEhBQ,UAAU,IACCC,QAAQ;YACXH,MAAMH,UAAU,EAAE;QACtB,IACD;QAACA;KAAU;IAEd,MAAMO,aAAa,OAAOC,SAA6BC;QACnD,IAAIA,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MAAM;gBACzB,WAAWA,EAAE,SAAS;gBACtB,MAAMA,EAAE,IAAI;YAChB;YAEA,MAAMG,YAAYpB,KAAK,MAAM,CAAQ;gBACjC,IAAIC,OAAOiB,EAAE,EAAE;gBACf,OAAOA,EAAE,IAAI;gBACb,UAAUjB,OAAOiB,EAAE,MAAM;gBACzB,WAAWA,EAAE,SAAS;gBACtB,MAAMA,EAAE,IAAI;YAChB;YAEA,OAAOjC,MAAM,IAAI,CACboB,cAAc,KAAK,CAAQc,YAC3Bd,cAAc,KAAK,CAAQe;QAEnC;QAEA,OAAO;IACX;IAEA,OAAO;QAAE9B;QAAIK;QAAYY;QAAYG;QAASE;QAASI;IAAK;AAChE"}
1
+ {"version":3,"file":"Tree/useTree.js","sources":["../../src/Tree/useTree.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport type { DropOptions as DndDropOptions, NodeModel } from \"@minoru/react-dnd-treeview\";\nimport { autorun } from \"mobx\";\nimport { TreePresenter, type TreePresenterInitParams } from \"./presenters/index.js\";\nimport type { TreeProps, DropOptions } from \"./Tree.js\";\nimport { Node, NodeFormatter } from \"./domains/index.js\";\n\nexport const useTree = <TData = Record<string, any>>(props: TreeProps<TData>) => {\n const params: TreePresenterInitParams = useMemo(() => {\n return {\n rootId: props.rootId,\n defaultOpenNodeIds: props.defaultOpenNodeIds,\n defaultLockedOpenNodeIds: props.defaultLockedOpenNodeIds,\n loadingNodeIds: props.loadingNodeIds\n };\n }, [\n props.rootId,\n props.defaultOpenNodeIds,\n props.defaultLockedOpenNodeIds,\n props.loadingNodeIds\n ]);\n\n const presenter = useMemo(() => {\n return new TreePresenter<TData>();\n }, []);\n\n const [vm, setVm] = useState(presenter.vm);\n\n useEffect(() => {\n presenter.init(params);\n }, [params, presenter]);\n\n useEffect(() => {\n presenter.initNodes(props.nodes);\n }, [props.nodes]);\n\n useEffect(() => {\n return autorun(() => {\n setVm(presenter.vm);\n });\n }, [presenter]);\n\n const handleDrop = async (newTree: NodeModel<TData>[], options: DndDropOptions) => {\n if (options.dragSourceId === options.dropTargetId) {\n // Drag source and drop target are the same, no action taken.\n return;\n }\n\n const newNodeTree = newTree.map(node => {\n return Node.create<TData>({\n id: String(node.id),\n label: node.text,\n parentId: String(node.parent),\n droppable: node.droppable,\n data: node.data as TData\n });\n });\n\n if (props.onDrop) {\n const { dragSourceId, dropTargetId } = options;\n\n const newTreeDto = newNodeTree.map(node => NodeFormatter.toDto<TData>(node));\n\n const dropOptions: DropOptions<TData> = {\n dragSourceId: String(dragSourceId),\n dropTargetId: String(dropTargetId),\n dragSource: newTreeDto.find(node => node.id === String(options.dragSourceId)),\n dropTarget: newTreeDto.find(node => node.id === String(options.dropTargetId))\n };\n\n try {\n await props.onDrop(newTreeDto, dropOptions);\n } catch {\n return;\n }\n }\n\n await presenter.handleDrop(newNodeTree);\n };\n\n const changeOpen = (newOpenIds: NodeModel<TData>[\"id\"][]) => {\n if (props.onChangeOpen) {\n const newOpenNodes = vm.nodes\n .filter(node => newOpenIds.includes(node.id))\n .map(node =>\n NodeFormatter.toDto<TData>(\n Node.create<TData>({\n id: String(node.id),\n label: node.text,\n parentId: String(node.parent),\n droppable: node.droppable,\n data: node.data as TData\n })\n )\n );\n\n props.onChangeOpen(newOpenNodes);\n }\n };\n\n const canDrag = (node: NodeModel<TData> | undefined) => {\n if (!node) {\n return false;\n }\n\n const nodeDto = NodeFormatter.toDto<TData>(\n Node.create<TData>({\n id: String(node.id),\n parentId: String(node.parent),\n droppable: node.droppable,\n label: node.text,\n data: node.data as TData\n })\n );\n\n return props.canDrag ? props.canDrag(nodeDto) : true;\n };\n\n const canDrop = (tree: NodeModel<TData>[], options: DndDropOptions) => {\n if (props.canDrop) {\n const { dragSourceId, dropTargetId } = options;\n\n const nodeTree = tree.map(node => {\n return Node.create<TData>({\n id: String(node.id),\n label: node.text,\n parentId: String(node.parent),\n droppable: node.droppable,\n data: node.data as TData\n });\n });\n\n const nodeTreeDto = nodeTree.map(node => NodeFormatter.toDto<TData>(node));\n\n const dropOptions: DropOptions<TData> = {\n dragSourceId: String(dragSourceId),\n dropTargetId: String(dropTargetId),\n dragSource: nodeTreeDto.find(node => node.id === String(options.dragSourceId)),\n dropTarget: nodeTreeDto.find(node => node.id === String(options.dropTargetId))\n };\n\n return props.canDrop(nodeTreeDto, dropOptions);\n }\n\n return true;\n };\n\n const sort = (a: NodeModel<TData>, b: NodeModel<TData>): number => {\n if (typeof props.sort === \"function\") {\n const nodeTreeA = Node.create<TData>({\n id: String(a.id),\n label: a.text,\n parentId: String(a.parent),\n droppable: a.droppable,\n data: a.data\n });\n\n const nodeTreeB = Node.create<TData>({\n id: String(b.id),\n label: b.text,\n parentId: String(b.parent),\n droppable: b.droppable,\n data: b.data\n });\n\n return props.sort(\n NodeFormatter.toDto<TData>(nodeTreeA),\n NodeFormatter.toDto<TData>(nodeTreeB)\n );\n }\n\n return 0;\n };\n\n return { vm, handleDrop, changeOpen, canDrag, canDrop, sort };\n};\n"],"names":["useTree","props","params","useMemo","presenter","TreePresenter","vm","setVm","useState","useEffect","autorun","handleDrop","newTree","options","newNodeTree","node","Node","String","dragSourceId","dropTargetId","newTreeDto","NodeFormatter","dropOptions","changeOpen","newOpenIds","newOpenNodes","canDrag","nodeDto","canDrop","tree","nodeTree","nodeTreeDto","sort","a","b","nodeTreeA","nodeTreeB"],"mappings":";;;;AAOO,MAAMA,UAAU,CAA8BC;IACjD,MAAMC,SAAkCC,QAAQ,IACrC;YACH,QAAQF,MAAM,MAAM;YACpB,oBAAoBA,MAAM,kBAAkB;YAC5C,0BAA0BA,MAAM,wBAAwB;YACxD,gBAAgBA,MAAM,cAAc;QACxC,IACD;QACCA,MAAM,MAAM;QACZA,MAAM,kBAAkB;QACxBA,MAAM,wBAAwB;QAC9BA,MAAM,cAAc;KACvB;IAED,MAAMG,YAAYD,QAAQ,IACf,IAAIE,iBACZ,EAAE;IAEL,MAAM,CAACC,IAAIC,MAAM,GAAGC,SAASJ,UAAU,EAAE;IAEzCK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AKE,OAAOJ,QAAQ,YAAY;YAChF;YAEA,OAAOZ,MAAM,OAAO,CAAC8B,aAAaT;QACtC;QAEA,OAAO;IACX;IAEA,MAAMU,OAAO,CAACC,GAAqBC;QAC/B,IAAI,AAAsB,cAAtB,OAAOjC,MAAM,IAAI,EAAiB;YAClC,MAAMkC,YAAYnB,KAAK,MAAM,CAAQ;gBACjC,IAAIC,OAAOgB,EAAE,EAAE;gBACf,OAAOA,EAAE,IAAI;gBACb,UAAUhB,OAAOgB,EAAE,MAAM;gBACzB,WAAWA,EAAE,SAAS;gBACtB,MAAMA,EAAE,IAAI;YAChB;YAEA,MAAMG,YAAYpB,KAAK,MAAM,CAAQ;gBACjC,IAAIC,OAAOiB,EAAE,EAAE;gBACf,OAAOA,EAAE,IAAI;gBACb,UAAUjB,OAAOiB,EAAE,MAAM;gBACzB,WAAWA,EAAE,SAAS;gBACtB,MAAMA,EAAE,IAAI;YAChB;YAEA,OAAOjC,MAAM,IAAI,CACboB,cAAc,KAAK,CAAQc,YAC3Bd,cAAc,KAAK,CAAQe;QAEnC;QAEA,OAAO;IACX;IAEA,OAAO;QAAE9B;QAAIK;QAAYY;QAAYG;QAASE;QAASI;IAAK;AAChE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/admin-ui",
3
- "version": "6.4.6-beta.0",
3
+ "version": "6.4.7-beta.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -19,9 +19,9 @@
19
19
  "@monaco-editor/react": "4.7.0",
20
20
  "@radix-ui/react-scroll-area": "1.2.14",
21
21
  "@tanstack/react-table": "8.21.3",
22
- "@webiny/icons": "6.4.6-beta.0",
23
- "@webiny/react-composition": "6.4.6-beta.0",
24
- "@webiny/utils": "6.4.6-beta.0",
22
+ "@webiny/icons": "6.4.7-beta.0",
23
+ "@webiny/react-composition": "6.4.7-beta.0",
24
+ "@webiny/utils": "6.4.7-beta.0",
25
25
  "bytes": "3.1.2",
26
26
  "class-variance-authority": "0.7.1",
27
27
  "clsx": "2.1.1",
@@ -56,8 +56,8 @@
56
56
  "@types/react-color": "3.0.13",
57
57
  "@types/react-custom-scrollbars": "4.0.13",
58
58
  "@types/react-virtualized": "9.22.3",
59
- "@webiny/build-tools": "6.4.6-beta.0",
60
- "@webiny/project": "6.4.6-beta.0",
59
+ "@webiny/build-tools": "6.4.7-beta.0",
60
+ "@webiny/project": "6.4.7-beta.0",
61
61
  "chalk": "5.6.2",
62
62
  "oxfmt": "0.58.0",
63
63
  "rimraf": "6.1.3",