{"version":3,"sources":["../src/useOverflowItem.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useOverflowContext } from './overflowContext';\n\n/**\n * Registers an overflow item\n *\n * @internal\n * @param id - unique identifier for the item used by the overflow manager\n * @param priority - higher priority means the item overflows later\n * @param groupId - assigns the item to a group, group visibility can be watched\n * @param pinned - if true, the item will never overflow and will always be visible\n * @returns ref to assign to an intrinsic HTML element\n */\nexport function useOverflowItem<TElement extends HTMLElement>(\n  id: string,\n  priority?: number,\n  groupId?: string,\n  pinned?: boolean,\n): React.RefObject<TElement | null> {\n  const ref = React.useRef<TElement | null>(null);\n  const registerItem = useOverflowContext(v => v.registerItem);\n\n  useIsomorphicLayoutEffect(() => {\n    if (process.env.NODE_ENV !== 'production') {\n      if (typeof pinned !== 'undefined' && typeof priority !== 'undefined' && pinned) {\n        // eslint-disable-next-line no-console\n        console.error(\n          `useOverflowItem: Overflow item with id \"${id}\" has pinned=true and priority<0. ` +\n            `Pinned items are always visible and should not have defined priority.`,\n        );\n      }\n    }\n\n    if (ref.current) {\n      return registerItem({\n        element: ref.current,\n        id,\n        priority: priority ?? 0,\n        groupId,\n        pinned,\n      });\n    }\n  }, [id, priority, registerItem, groupId, pinned]);\n\n  return ref;\n}\n"],"names":["React","useIsomorphicLayoutEffect","useOverflowContext","useOverflowItem","id","priority","groupId","pinned","ref","useRef","registerItem","v","process","env","NODE_ENV","console","error","current","element"],"mappings":"AAAA;;;;;+BAgBgBG;;;;;;;iEAdO,QAAQ;gCACW,4BAA4B;iCACnC,uBAAoB;AAYhD,yBACLC,EAAU,EACVC,QAAiB,EACjBC,OAAgB,EAChBC,MAAgB;IAEhB,MAAMC,MAAMR,OAAMS,MAAM,CAAkB;IAC1C,MAAMC,eAAeR,uCAAAA,EAAmBS,CAAAA,IAAKA,EAAED,YAAY;QAE3DT,yCAAAA,EAA0B;QACxB,IAAIW,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,IAAI,OAAOP,WAAW,eAAe,OAAOF,aAAa,eAAeE,QAAQ;gBAC9E,sCAAsC;gBACtCQ,QAAQC,KAAK,CACX,CAAC,wCAAwC,EAAEZ,GAAG,kCAAkC,CAAC,GAC/E,CAAC,qEAAqE,CAAC;YAE7E;QACF;QAEA,IAAII,IAAIS,OAAO,EAAE;YACf,OAAOP,aAAa;gBAClBQ,SAASV,IAAIS,OAAO;gBACpBb;gBACAC,UAAUA,YAAY;gBACtBC;gBACAC;YACF;QACF;IACF,GAAG;QAACH;QAAIC;QAAUK;QAAcJ;QAASC;KAAO;IAEhD,OAAOC;AACT"}