{"version":3,"file":"time-picker-hooks.mjs","names":[],"sources":["../../../src/time-picker/time-picker-hooks.ts"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\nimport { useEffect, useState } from 'react';\n\nexport function useTimePickerPopover(openInitially: boolean) {\n  const [isPopoverOpen, setIsPopoverOpen] = useState(openInitially);\n  return { isPopoverOpen, setIsPopoverOpen };\n}\n\nexport function useKeyboardNavigation(\n  listRef: React.RefObject<HTMLUListElement | null | undefined>,\n  maxIndex: number,\n) {\n  const [focusedIndex, setFocusedIndex] = useState(0);\n\n  const handleArrowNavigation = (key: string) => {\n    if (key === 'ArrowDown') {\n      setFocusedIndex((prev) => (prev + 1) % maxIndex);\n    } else if (key === 'ArrowUp') {\n      setFocusedIndex((prev) => (prev - 1 + maxIndex) % maxIndex);\n    }\n  };\n\n  useEffect(() => {\n    listRef.current?.children[focusedIndex]?.scrollIntoView({\n      block: 'center',\n      inline: 'nearest',\n    });\n  }, [focusedIndex, listRef]);\n\n  return { focusedIndex, handleArrowNavigation, setFocusedIndex };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,qBAAqB,eAAwB;CAC3D,MAAM,CAAC,eAAe,oBAAoB,SAAS,aAAa;CAChE,OAAO;EAAE;EAAe;CAAiB;AAC3C;AAEA,SAAgB,sBACd,SACA,UACA;CACA,MAAM,CAAC,cAAc,mBAAmB,SAAS,CAAC;CAElD,MAAM,yBAAyB,QAAgB;EAC7C,IAAI,QAAQ,aACV,iBAAiB,UAAU,OAAO,KAAK,QAAQ;OAC1C,IAAI,QAAQ,WACjB,iBAAiB,UAAU,OAAO,IAAI,YAAY,QAAQ;CAE9D;CAEA,gBAAgB;;EACd,CAAA,mBAAA,QAAQ,aAAA,QAAA,qBAAA,KAAA,MAAA,mBAAA,iBAAS,SAAS,mBAAA,QAAA,qBAAA,KAAA,KAAA,iBAAe,eAAe;GACtD,OAAO;GACP,QAAQ;EACV,CAAC;CACH,GAAG,CAAC,cAAc,OAAO,CAAC;CAE1B,OAAO;EAAE;EAAc;EAAuB;CAAgB;AAChE"}