@instincthub/react-ui 0.1.56 → 0.1.57

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.
@@ -169,14 +169,15 @@
169
169
  transition: transform 0.2s ease;
170
170
  }
171
171
 
172
- .ihub-action-dropdown-container:has(.ihub-action-dropdown-menu)
173
- .ihub-action-dropdown-icon {
172
+ .ihub-action-with-dropdown[aria-expanded="true"] .ihub-action-dropdown-icon {
174
173
  transform: rotate(180deg);
175
174
  }
176
175
 
176
+ /* Fixed, not absolute: the menu is portalled to <body> and positioned from
177
+ the trigger's bounding box, so no scrolling ancestor can clip it. The
178
+ coordinates are set inline by the component. */
177
179
  .ihub-action-dropdown-menu {
178
- position: absolute;
179
- top: calc(100% + 8px);
180
+ position: fixed;
180
181
  min-width: 160px;
181
182
  background: var(--White);
182
183
  border-radius: 5px;
@@ -188,17 +189,13 @@
188
189
  overflow-y: auto;
189
190
  }
190
191
 
191
- .ihub-action-dropdown-left {
192
- left: 0;
193
- }
194
-
195
- .ihub-action-dropdown-right {
196
- right: 0;
197
- }
198
-
192
+ /* Alignment is resolved in JS when the menu is positioned; these remain only
193
+ so existing markup keeps a stable hook. */
194
+ .ihub-action-dropdown-left,
195
+ .ihub-action-dropdown-right,
199
196
  .ihub-action-dropdown-center {
200
- left: 50%;
201
- transform: translateX(-50%);
197
+ right: auto;
198
+ transform: none;
202
199
  }
203
200
 
204
201
  .ihub-action-dropdown-item {
@@ -1,2 +1,2 @@
1
- import{slicedToArray as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as n,Fragment as o,jsx as e}from"react/jsx-runtime";import t from"react";import a from"next/link";var r=function(r){var c=r.label,d=r.onClick,l=r.href,s=r.variant,u=void 0===s?"primary":s,h=r.size,m=void 0===h?"medium":h,f=r.fullWidth,p=void 0!==f&&f,b=r.disabled,v=void 0!==b&&b,w=r.iconBefore,k=r.iconAfter,N=r.className,g=void 0===N?"":N,C=r.target,y=r.type,B=void 0===y?"button":y,L=r.animated,j=void 0!==L&&L,x=r.dropdown,P=void 0!==x&&x,E=r.dropdownItems,A=void 0===E?[]:E,W=r.dropdownPosition,_=void 0===W?"right":W,z=t.useState(!1),D=i(z,2),H=D[0],I=D[1],M=t.useRef(null);t.useEffect(function(){var i=function(i){M.current&&!M.current.contains(i.target)&&I(!1)};return H&&document.addEventListener("mousedown",i),function(){document.removeEventListener("mousedown",i)}},[H]);var R=["ihub-action","ihub-action-".concat(u),"ihub-action-".concat(m),p?"ihub-action-full-width":"",v?"ihub-action-disabled":"",j?"ihub-action-animated":"",P?"ihub-action-with-dropdown":"",g].filter(Boolean).join(" "),S=n(o,{children:[w&&e("span",{className:"ihub-action-icon-before",children:w}),e("span",{className:"ihub-action-label",children:c}),P&&e("span",{className:"ihub-action-dropdown-icon",children:e("svg",{width:"12",height:"7",viewBox:"0 0 12 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:"primary"===u?{color:"#fff"}:{},children:e("path",{d:"M1 1L6 6L11 1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),!P&&k&&e("span",{className:"ihub-action-icon-after",children:k})]}),T=H&&P&&A.length>0&&e("div",{className:"ihub-action-dropdown-menu ihub-action-dropdown-".concat(_),onClick:function(i){return i.stopPropagation()},children:A.map(function(i,t){var r=["ihub-action-dropdown-item",i.disabled?"ihub-action-dropdown-item-disabled":"",i.className||""].filter(Boolean).join(" "),c=n(o,{children:[i.iconBefore&&e("span",{className:"ihub-action-dropdown-item-icon",children:i.iconBefore}),e("span",{className:"ihub-action-dropdown-item-label",children:i.label})]});return i.href&&!i.disabled?e(a,{href:i.href,className:r,onClick:function(){i.onClick&&i.onClick(),I(!1)},children:c},t):e("button",{className:r,onClick:function(){!i.disabled&&i.onClick&&(i.onClick(),I(!1))},disabled:i.disabled,type:"button",children:c},t)})});return function(i){return P?n("div",{className:"ihub-action-dropdown-container",ref:M,children:[i,T]}):i}(!l||v||P?e("button",{type:B,className:R,onClick:P?function(i){P&&(i.preventDefault(),i.stopPropagation(),I(function(i){return!i}))}:d,disabled:v,children:S}):e(a,{href:l,className:R,target:C,onClick:d,children:S}))};export{r as default};
1
+ import{slicedToArray as n,objectSpread2 as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,Fragment as o,jsx as t}from"react/jsx-runtime";import r from"react";import{createPortal as a}from"react-dom";import d from"next/link";var c=function(c){var l=c.label,s=c.onClick,u=c.href,h=c.variant,m=void 0===h?"primary":h,f=c.size,p=void 0===f?"medium":f,b=c.fullWidth,v=void 0!==b&&b,w=c.disabled,g=void 0!==w&&w,k=c.iconBefore,N=c.iconAfter,C=c.className,y=void 0===C?"":C,L=c.target,x=c.type,B=void 0===x?"button":x,E=c.animated,j=void 0!==E&&E,M=c.dropdown,P=void 0!==M&&M,z=c.dropdownItems,R=void 0===z?[]:z,S=c.dropdownPosition,W=void 0===S?"right":S,A=r.useState(!1),H=n(A,2),_=H[0],D=H[1],I=r.useRef(null),T=r.useRef(null),q=r.useState({top:0,left:0}),F=n(q,2),G=F[0],J=F[1],K=r.useCallback(function(){var n=I.current;if(n){var e=n.getBoundingClientRect(),i=Math.min(40*R.length+8,300),o=Math.max(e.width,160),t=window.innerHeight-e.bottom<i&&e.top>i,r=e.left;"right"===W?r=e.right-o:"center"===W&&(r=e.left+e.width/2-o/2),J({top:t?e.top-i-8:e.bottom+8,left:Math.max(8,Math.min(r,window.innerWidth-o-8))})}},[R.length,W]);r.useEffect(function(){if(_){var n=function(n){var e,i,o=n.target;null!==(e=I.current)&&void 0!==e&&e.contains(o)||null!==(i=T.current)&&void 0!==i&&i.contains(o)||D(!1)},e=function(){return D(!1)};return document.addEventListener("mousedown",n),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),function(){document.removeEventListener("mousedown",n),window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}}},[_]);var O=["ihub-action","ihub-action-".concat(m),"ihub-action-".concat(p),v?"ihub-action-full-width":"",g?"ihub-action-disabled":"",j?"ihub-action-animated":"",P?"ihub-action-with-dropdown":"",y].filter(Boolean).join(" "),Q=i(o,{children:[k&&t("span",{className:"ihub-action-icon-before",children:k}),t("span",{className:"ihub-action-label",children:l}),P&&t("span",{className:"ihub-action-dropdown-icon",children:t("svg",{width:"12",height:"7",viewBox:"0 0 12 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:"primary"===m?{color:"#fff"}:{},children:t("path",{d:"M1 1L6 6L11 1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),!P&&N&&t("span",{className:"ihub-action-icon-after",children:N})]}),U=_&&P&&R.length>0&&t("div",{ref:T,className:"ihub-action-dropdown-menu ihub-action-dropdown-".concat(W),style:{top:G.top,left:G.left},onClick:function(n){return n.stopPropagation()},children:R.map(function(n,e){var r=["ihub-action-dropdown-item",n.disabled?"ihub-action-dropdown-item-disabled":"",n.className||""].filter(Boolean).join(" "),a=i(o,{children:[n.iconBefore&&t("span",{className:"ihub-action-dropdown-item-icon",children:n.iconBefore}),t("span",{className:"ihub-action-dropdown-item-label",children:n.label})]});return n.href&&!n.disabled?t(d,{href:n.href,className:r,onClick:function(){n.onClick&&n.onClick(),D(!1)},children:a},e):t("button",{className:r,onClick:function(){!n.disabled&&n.onClick&&(n.onClick(),D(!1))},disabled:n.disabled,type:"button",children:a},e)})});return function(n){return P?i("div",{className:"ihub-action-dropdown-container",ref:I,children:[n,U&&"undefined"!=typeof document&&a(U,document.body)]}):n}(!u||g||P?t("button",e(e({type:B,className:O,onClick:P?function(n){P&&(n.preventDefault(),n.stopPropagation(),_||K(),D(function(n){return!n}))}:s,disabled:g},P?{"aria-haspopup":"menu","aria-expanded":_}:{}),{},{children:Q})):t(d,{href:u,className:O,target:L,onClick:s,children:Q}))};export{c as default};
2
2
  //# sourceMappingURL=Action.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Action.js","sources":["../../../../src/components/ui/Action.tsx"],"sourcesContent":["import React from \"react\";\nimport Link from \"next/link\";\n\n/**\n * Defines the structure of a dropdown item\n */\nexport interface ActionDropdownItem {\n /** Text label to display for the dropdown item */\n label: string | React.ReactNode;\n /** Click handler function */\n onClick?: () => void;\n /** Link destination if the dropdown item is a link */\n href?: string;\n /** Icon to display before the label */\n iconBefore?: React.ReactNode;\n /** Whether the item is disabled */\n disabled?: boolean;\n /** Optional additional class names */\n className?: string;\n}\n\n/**\n * ActionProps interface defines all possible props for the Action component\n */\ninterface ActionProps {\n /** Text label to display in the action element */\n label: string | React.ReactNode;\n /** Click handler function */\n onClick?: () => void;\n /** Link destination if the action is a link */\n href?: string;\n /** Visual style variant */\n variant?: \"primary\" | \"secondary\" | \"outline\" | \"danger\" | \"text\";\n /** Size variation */\n size?: \"small\" | \"medium\" | \"large\";\n /** Whether the action should take up full width of container */\n fullWidth?: boolean;\n /** Whether the action is disabled */\n disabled?: boolean;\n /** Icon to display before the label */\n iconBefore?: React.ReactNode;\n /** Icon to display after the label */\n iconAfter?: React.ReactNode;\n /** Optional additional class names */\n className?: string;\n /** Target attribute for links */\n target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\";\n /** Type attribute for buttons */\n type?: \"button\" | \"submit\" | \"reset\";\n /** Whether to add animation effect */\n animated?: boolean;\n /** Whether to show a dropdown menu */\n dropdown?: boolean;\n /** Items to display in the dropdown menu */\n dropdownItems?: ActionDropdownItem[];\n /** Position of the dropdown menu */\n dropdownPosition?: \"left\" | \"right\" | \"center\";\n}\n\n/**\n * Action component\n * A versatile Action component that can be rendered as a button or link\n * with various styles, sizes, icon options, and dropdown functionality\n * @example\n * <Action\n * label=\"Click Me\"\n * onClick={() => alert('Action clicked!')}\n * variant=\"primary\"\n * size=\"medium\"\n * fullWidth={false}\n * disabled={false}\n * iconBefore={<Icon />}\n * />\n */\nconst Action: React.FC<ActionProps> = ({\n label,\n onClick,\n href,\n variant = \"primary\",\n size = \"medium\",\n fullWidth = false,\n disabled = false,\n iconBefore,\n iconAfter,\n className = \"\",\n target,\n type = \"button\",\n animated = false,\n dropdown = false,\n dropdownItems = [],\n dropdownPosition = \"right\",\n}) => {\n // State to manage dropdown visibility\n const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);\n const dropdownRef = React.useRef<HTMLDivElement>(null);\n\n // Handle opening/closing the dropdown\n const toggleDropdown = (e: React.MouseEvent) => {\n if (dropdown) {\n e.preventDefault();\n e.stopPropagation();\n setIsDropdownOpen((prev) => !prev);\n }\n };\n\n // Close dropdown when clicking outside\n React.useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (\n dropdownRef.current &&\n !dropdownRef.current.contains(event.target as Node)\n ) {\n setIsDropdownOpen(false);\n }\n };\n\n if (isDropdownOpen) {\n document.addEventListener(\"mousedown\", handleClickOutside);\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [isDropdownOpen]);\n\n // Construct class names based on props\n const baseClasses = [\n \"ihub-action\",\n `ihub-action-${variant}`,\n `ihub-action-${size}`,\n fullWidth ? \"ihub-action-full-width\" : \"\",\n disabled ? \"ihub-action-disabled\" : \"\",\n animated ? \"ihub-action-animated\" : \"\",\n dropdown ? \"ihub-action-with-dropdown\" : \"\",\n className,\n ]\n .filter(Boolean)\n .join(\" \");\n\n // Common content for both button and link\n const content = (\n <>\n {iconBefore && (\n <span className=\"ihub-action-icon-before\">{iconBefore}</span>\n )}\n <span className=\"ihub-action-label\">{label}</span>\n {dropdown && (\n <span className=\"ihub-action-dropdown-icon\">\n <svg\n width=\"12\"\n height=\"7\"\n viewBox=\"0 0 12 7\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n style={variant === \"primary\" ? { color: \"#fff\" } : {}}\n >\n <path\n d=\"M1 1L6 6L11 1\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </span>\n )}\n {!dropdown && iconAfter && (\n <span className=\"ihub-action-icon-after\">{iconAfter}</span>\n )}\n </>\n );\n\n // Dropdown menu\n const dropdownMenu = isDropdownOpen &&\n dropdown &&\n dropdownItems.length > 0 && (\n <div\n className={`ihub-action-dropdown-menu ihub-action-dropdown-${dropdownPosition}`}\n onClick={(e) => e.stopPropagation()}\n >\n {dropdownItems.map((item, index) => {\n const itemClasses = [\n \"ihub-action-dropdown-item\",\n item.disabled ? \"ihub-action-dropdown-item-disabled\" : \"\",\n item.className || \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n\n const itemContent = (\n <>\n {item.iconBefore && (\n <span className=\"ihub-action-dropdown-item-icon\">\n {item.iconBefore}\n </span>\n )}\n <span className=\"ihub-action-dropdown-item-label\">\n {item.label}\n </span>\n </>\n );\n\n if (item.href && !item.disabled) {\n return (\n <Link\n key={index}\n href={item.href}\n className={itemClasses}\n onClick={() => {\n if (item.onClick) item.onClick();\n setIsDropdownOpen(false);\n }}\n >\n {itemContent}\n </Link>\n );\n }\n\n return (\n <button\n key={index}\n className={itemClasses}\n onClick={() => {\n if (!item.disabled && item.onClick) {\n item.onClick();\n setIsDropdownOpen(false);\n }\n }}\n disabled={item.disabled}\n type=\"button\"\n >\n {itemContent}\n </button>\n );\n })}\n </div>\n );\n\n // Wrapper to contain both the action and dropdown\n const renderWithDropdown = (actionElement: React.ReactElement) => {\n if (!dropdown) return actionElement;\n\n return (\n <div className=\"ihub-action-dropdown-container\" ref={dropdownRef}>\n {actionElement}\n {dropdownMenu}\n </div>\n );\n };\n\n // Render the appropriate element\n const actionElement =\n href && !disabled && !dropdown ? (\n <Link\n href={href}\n className={baseClasses}\n target={target}\n onClick={onClick}\n >\n {content}\n </Link>\n ) : (\n <button\n type={type}\n className={baseClasses}\n onClick={dropdown ? toggleDropdown : onClick}\n disabled={disabled}\n >\n {content}\n </button>\n );\n\n return renderWithDropdown(actionElement);\n};\n\nexport default Action;\n"],"names":["Action","_ref","label","onClick","href","_ref$variant","variant","_ref$size","size","_ref$fullWidth","fullWidth","_ref$disabled","disabled","iconBefore","iconAfter","_ref$className","className","target","_ref$type","type","_ref$animated","animated","_ref$dropdown","dropdown","_ref$dropdownItems","dropdownItems","_ref$dropdownPosition","dropdownPosition","_React$useState","React","useState","_React$useState2","_slicedToArray","isDropdownOpen","setIsDropdownOpen","dropdownRef","useRef","useEffect","handleClickOutside","event","current","contains","document","addEventListener","removeEventListener","baseClasses","concat","filter","Boolean","join","content","_jsxs","_Fragment","children","_jsx","width","height","viewBox","fill","xmlns","style","color","d","stroke","strokeWidth","strokeLinecap","strokeLinejoin","dropdownMenu","length","e","stopPropagation","map","item","index","itemClasses","itemContent","Link","actionElement","ref","renderWithDropdown","preventDefault","prev"],"mappings":"6LA0EA,IAAMA,EAAgC,SAA1BC,GAiBP,IAhBHC,EAAKD,EAALC,MACAC,EAAOF,EAAPE,QACAC,EAAIH,EAAJG,KAAIC,EAAAJ,EACJK,QAAAA,OAAU,IAAHD,EAAG,UAASA,EAAAE,EAAAN,EACnBO,KAAAA,OAAO,IAAHD,EAAG,SAAQA,EAAAE,EAAAR,EACfS,UAAAA,OAAY,IAAHD,GAAQA,EAAAE,EAAAV,EACjBW,SAAAA,OAAW,IAAHD,GAAQA,EAChBE,EAAUZ,EAAVY,WACAC,EAASb,EAATa,UAASC,EAAAd,EACTe,UAAAA,OAAY,IAAHD,EAAG,GAAEA,EACdE,EAAMhB,EAANgB,OAAMC,EAAAjB,EACNkB,KAAAA,OAAO,IAAHD,EAAG,SAAQA,EAAAE,EAAAnB,EACfoB,SAAAA,OAAW,IAAHD,GAAQA,EAAAE,EAAArB,EAChBsB,SAAAA,OAAW,IAAHD,GAAQA,EAAAE,EAAAvB,EAChBwB,cAAAA,OAAgB,IAAHD,EAAG,GAAEA,EAAAE,EAAAzB,EAClB0B,iBAAAA,OAAmB,IAAHD,EAAG,QAAOA,EAG1BE,EAA4CC,EAAMC,UAAS,GAAMC,EAAAC,EAAAJ,EAAA,GAA1DK,EAAcF,EAAA,GAAEG,EAAiBH,EAAA,GAClCI,EAAcN,EA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CACGmB,EAAK3D,YACJyC,EAAA,OAAA,CAAMtC,UAAU,iCACbqC,SAAAmB,EAAK3D,aAGVyC,EAAA,OAAA,CAAMtC,UAAU,kCACbqC,SAAAmB,EAAKtE,WAKZ,OAAIsE,EAAKpE,OAASoE,EAAK5D,SAEnB0C,EAACsB,EAEC,CAAAxE,KAAMoE,EAAKpE,KACXY,UAAW0D,EACXvE,QAAS,WACHqE,EAAKrE,SAASqE,EAAKrE,UACvB+B,GAAkB,EACnB,WAEAyC,GARIF,GAcTnB,YAEEtC,UAAW0D,EACXvE,QAAS,YACFqE,EAAK5D,UAAY4D,EAAKrE,UACzBqE,EAAKrE,UACL+B,GAAkB,GAErB,EACDtB,SAAU4D,EAAK5D,SACfO,KAAK,kBAEJwD,GAXIF,OAoDjB,OAjC2B,SAACI,GAC1B,OAAKtD,EAGH4B,EAAA,MAAA,CAAKnC,UAAU,iCAAiC8D,IAAK3C,YAClD0C,EACAV,KALiBU,EAgCjBE,EApBL3E,GAASQ,GAAaW,EAUpB+B,YACEnC,KAAMA,EACNH,UAAW6B,EACX1C,QAASoB,EAxKQ,SAAC8C,GAClB9C,IACF8C,EAAEW,iBACFX,EAAEC,kBACFpC,EAAkB,SAAC+C,GAAI,OAAMA,MAoKU9E,EACrCS,SAAUA,EAAQyC,SAEjBH,IAfHI,EAACsB,EACC,CAAAxE,KAAMA,EACNY,UAAW6B,EACX5B,OAAQA,EACRd,QAASA,EAERkD,SAAAH,IAcT"}
1
+ {"version":3,"file":"Action.js","sources":["../../../../src/components/ui/Action.tsx"],"sourcesContent":["import React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport Link from \"next/link\";\n\n/**\n * Defines the structure of a dropdown item\n */\nexport interface ActionDropdownItem {\n /** Text label to display for the dropdown item */\n label: string | React.ReactNode;\n /** Click handler function */\n onClick?: () => void;\n /** Link destination if the dropdown item is a link */\n href?: string;\n /** Icon to display before the label */\n iconBefore?: React.ReactNode;\n /** Whether the item is disabled */\n disabled?: boolean;\n /** Optional additional class names */\n className?: string;\n}\n\n/**\n * ActionProps interface defines all possible props for the Action component\n */\ninterface ActionProps {\n /** Text label to display in the action element */\n label: string | React.ReactNode;\n /** Click handler function */\n onClick?: () => void;\n /** Link destination if the action is a link */\n href?: string;\n /** Visual style variant */\n variant?: \"primary\" | \"secondary\" | \"outline\" | \"danger\" | \"text\";\n /** Size variation */\n size?: \"small\" | \"medium\" | \"large\";\n /** Whether the action should take up full width of container */\n fullWidth?: boolean;\n /** Whether the action is disabled */\n disabled?: boolean;\n /** Icon to display before the label */\n iconBefore?: React.ReactNode;\n /** Icon to display after the label */\n iconAfter?: React.ReactNode;\n /** Optional additional class names */\n className?: string;\n /** Target attribute for links */\n target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\";\n /** Type attribute for buttons */\n type?: \"button\" | \"submit\" | \"reset\";\n /** Whether to add animation effect */\n animated?: boolean;\n /** Whether to show a dropdown menu */\n dropdown?: boolean;\n /** Items to display in the dropdown menu */\n dropdownItems?: ActionDropdownItem[];\n /** Position of the dropdown menu */\n dropdownPosition?: \"left\" | \"right\" | \"center\";\n}\n\n/**\n * Action component\n * A versatile Action component that can be rendered as a button or link\n * with various styles, sizes, icon options, and dropdown functionality\n * @example\n * <Action\n * label=\"Click Me\"\n * onClick={() => alert('Action clicked!')}\n * variant=\"primary\"\n * size=\"medium\"\n * fullWidth={false}\n * disabled={false}\n * iconBefore={<Icon />}\n * />\n */\nconst Action: React.FC<ActionProps> = ({\n label,\n onClick,\n href,\n variant = \"primary\",\n size = \"medium\",\n fullWidth = false,\n disabled = false,\n iconBefore,\n iconAfter,\n className = \"\",\n target,\n type = \"button\",\n animated = false,\n dropdown = false,\n dropdownItems = [],\n dropdownPosition = \"right\",\n}) => {\n // State to manage dropdown visibility\n const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);\n const dropdownRef = React.useRef<HTMLDivElement>(null);\n const menuRef = React.useRef<HTMLDivElement>(null);\n const [menuPosition, setMenuPosition] = React.useState<{\n top: number;\n left: number;\n }>({ top: 0, left: 0 });\n\n /**\n * Positions the menu from the trigger's bounding box.\n *\n * The menu is rendered into `document.body` rather than beside the trigger,\n * because an absolutely-positioned menu is clipped by any scrolling ancestor\n * — and the most common host for this component is a table row inside\n * `IHubTableServer`'s `.ihub-scroll-container` (`overflow: auto`), which is\n * only as tall as its rows. On a long table the menu had room and looked\n * fine; on a one-row table it was cut to a sliver. Filtering a table down to\n * a single result is exactly when someone reaches for that row's actions, so\n * the broken case was the common one.\n *\n * Flips above the trigger when there is not enough room below, and clamps to\n * the viewport horizontally.\n */\n const positionMenu = React.useCallback(() => {\n const trigger = dropdownRef.current;\n if (!trigger) return;\n\n const rect = trigger.getBoundingClientRect();\n const estimatedHeight = Math.min(dropdownItems.length * 40 + 8, 300);\n const menuWidth = Math.max(rect.width, 160);\n const openUpward =\n window.innerHeight - rect.bottom < estimatedHeight &&\n rect.top > estimatedHeight;\n\n let left = rect.left;\n if (dropdownPosition === \"right\") left = rect.right - menuWidth;\n else if (dropdownPosition === \"center\")\n left = rect.left + rect.width / 2 - menuWidth / 2;\n\n setMenuPosition({\n top: openUpward\n ? rect.top - estimatedHeight - 8\n : rect.bottom + 8,\n left: Math.max(8, Math.min(left, window.innerWidth - menuWidth - 8)),\n });\n }, [dropdownItems.length, dropdownPosition]);\n\n // Handle opening/closing the dropdown\n const toggleDropdown = (e: React.MouseEvent) => {\n if (dropdown) {\n e.preventDefault();\n e.stopPropagation();\n if (!isDropdownOpen) positionMenu();\n setIsDropdownOpen((prev) => !prev);\n }\n };\n\n // Close dropdown when clicking outside\n React.useEffect(() => {\n if (!isDropdownOpen) return;\n\n // Both refs are checked: the menu now lives outside the trigger's subtree,\n // so testing only the container would close it on its own menu items.\n const handleClickOutside = (event: MouseEvent) => {\n const target = event.target as Node;\n if (\n dropdownRef.current?.contains(target) ||\n menuRef.current?.contains(target)\n ) {\n return;\n }\n setIsDropdownOpen(false);\n };\n\n // Fixed coordinates go stale as soon as anything scrolls. Capture phase,\n // because the table's own scroll container never bubbles to window.\n const handleReflow = () => setIsDropdownOpen(false);\n\n document.addEventListener(\"mousedown\", handleClickOutside);\n window.addEventListener(\"scroll\", handleReflow, true);\n window.addEventListener(\"resize\", handleReflow);\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n window.removeEventListener(\"scroll\", handleReflow, true);\n window.removeEventListener(\"resize\", handleReflow);\n };\n }, [isDropdownOpen]);\n\n // Construct class names based on props\n const baseClasses = [\n \"ihub-action\",\n `ihub-action-${variant}`,\n `ihub-action-${size}`,\n fullWidth ? \"ihub-action-full-width\" : \"\",\n disabled ? \"ihub-action-disabled\" : \"\",\n animated ? \"ihub-action-animated\" : \"\",\n dropdown ? \"ihub-action-with-dropdown\" : \"\",\n className,\n ]\n .filter(Boolean)\n .join(\" \");\n\n // Common content for both button and link\n const content = (\n <>\n {iconBefore && (\n <span className=\"ihub-action-icon-before\">{iconBefore}</span>\n )}\n <span className=\"ihub-action-label\">{label}</span>\n {dropdown && (\n <span className=\"ihub-action-dropdown-icon\">\n <svg\n width=\"12\"\n height=\"7\"\n viewBox=\"0 0 12 7\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n style={variant === \"primary\" ? { color: \"#fff\" } : {}}\n >\n <path\n d=\"M1 1L6 6L11 1\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </span>\n )}\n {!dropdown && iconAfter && (\n <span className=\"ihub-action-icon-after\">{iconAfter}</span>\n )}\n </>\n );\n\n // Dropdown menu\n const dropdownMenu = isDropdownOpen &&\n dropdown &&\n dropdownItems.length > 0 && (\n <div\n ref={menuRef}\n className={`ihub-action-dropdown-menu ihub-action-dropdown-${dropdownPosition}`}\n style={{ top: menuPosition.top, left: menuPosition.left }}\n onClick={(e) => e.stopPropagation()}\n >\n {dropdownItems.map((item, index) => {\n const itemClasses = [\n \"ihub-action-dropdown-item\",\n item.disabled ? \"ihub-action-dropdown-item-disabled\" : \"\",\n item.className || \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n\n const itemContent = (\n <>\n {item.iconBefore && (\n <span className=\"ihub-action-dropdown-item-icon\">\n {item.iconBefore}\n </span>\n )}\n <span className=\"ihub-action-dropdown-item-label\">\n {item.label}\n </span>\n </>\n );\n\n if (item.href && !item.disabled) {\n return (\n <Link\n key={index}\n href={item.href}\n className={itemClasses}\n onClick={() => {\n if (item.onClick) item.onClick();\n setIsDropdownOpen(false);\n }}\n >\n {itemContent}\n </Link>\n );\n }\n\n return (\n <button\n key={index}\n className={itemClasses}\n onClick={() => {\n if (!item.disabled && item.onClick) {\n item.onClick();\n setIsDropdownOpen(false);\n }\n }}\n disabled={item.disabled}\n type=\"button\"\n >\n {itemContent}\n </button>\n );\n })}\n </div>\n );\n\n // Wrapper to contain both the action and dropdown\n const renderWithDropdown = (actionElement: React.ReactElement) => {\n if (!dropdown) return actionElement;\n\n return (\n <div className=\"ihub-action-dropdown-container\" ref={dropdownRef}>\n {actionElement}\n {dropdownMenu &&\n typeof document !== \"undefined\" &&\n createPortal(dropdownMenu, document.body)}\n </div>\n );\n };\n\n // Render the appropriate element\n const actionElement =\n href && !disabled && !dropdown ? (\n <Link\n href={href}\n className={baseClasses}\n target={target}\n onClick={onClick}\n >\n {content}\n </Link>\n ) : (\n <button\n type={type}\n className={baseClasses}\n onClick={dropdown ? toggleDropdown : onClick}\n disabled={disabled}\n {...(dropdown\n ? { \"aria-haspopup\": \"menu\" as const, \"aria-expanded\": isDropdownOpen }\n : {})}\n >\n {content}\n </button>\n );\n\n return renderWithDropdown(actionElement);\n};\n\nexport default Action;\n"],"names":["Action","_ref","label","onClick","href","_ref$variant","variant","_ref$size","size","_ref$fullWidth","fullWidth","_ref$disabled","disabled","iconBefore","iconAfter","_ref$className","className","target","_ref$type","type","_ref$animated","animated","_ref$dropdown","dropdown","_ref$dropdownItems","dropdownItems","_ref$dropdownPosition","dropdownPosition","_React$useState","React","useState","_React$useState2","_slicedToArray","isDropdownOpen","setIsDropdownOpen","dropdownRef","useRef","menuRef","_React$useState3","top","left","_React$useState4","menuPosition","setMenuPosition","positionMenu","useCallback","trigger","current","rect","getBoundingClientRect","estimatedHeight","Math","min","length","menuWidth","max","width","openUpward","window","innerHeight","bottom","right","innerWidth","useEffect","handleClickOutside","event","_dropdownRef$current","_menuRef$current","contains","handleReflow","document","addEventListener","removeEventListener","baseClasses","concat","filter","Boolean","join","content","_jsxs","_Fragment","children","_jsx","height","viewBox","fill","xmlns","style","color","d","stroke","strokeWidth","strokeLinecap","strokeLinejoin","dropdownMenu","ref","e","stopPropagation","map","item","index","itemClasses","itemContent","Link","actionElement","createPortal","body","renderWithDropdown","_objectSpread","preventDefault","prev"],"mappings":"yPA2EA,IAAMA,EAAgC,SAA1BC,GAiBP,IAhBHC,EAAKD,EAALC,MACAC,EAAOF,EAAPE,QACAC,EAAIH,EAAJG,KAAIC,EAAAJ,EACJK,QAAAA,OAAU,IAAHD,EAAG,UAASA,EAAAE,EAAAN,EACnBO,KAAAA,OAAO,IAAHD,EAAG,SAAQA,EAAAE,EAAAR,EACfS,UAAAA,OAAY,IAAHD,GAAQA,EAAAE,EAAAV,EACjBW,SAAAA,OAAW,IAAHD,GAAQA,EAChBE,EAAUZ,EAAVY,WACAC,EAASb,EAATa,UAASC,EAAAd,EACTe,UAAAA,OAAY,IAAHD,EAAG,GAAEA,EACdE,EAAMhB,EAANgB,OAAMC,EAAAjB,EACNkB,KAAAA,OAAO,IAAHD,EAAG,SAAQA,EAAAE,EAAAnB,EACfoB,SAAAA,OAAW,IAAHD,GAAQA,EAAAE,EAAArB,EAChBsB,SAAAA,OAAW,IAAHD,GAAQA,EAAAE,EAAAvB,EAChBwB,cAAAA,OAAgB,IAAHD,EAAG,GAAEA,EAAAE,EAAAzB,EAClB0B,iBAAAA,OAAmB,IAAHD,EAAG,QAAOA,EAG1BE,EAA4CC,EAAMC,UAAS,GAAMC,EAAAC,EAAAJ,EAAA,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