{"version":3,"file":"index.mjs","sources":["../../src/fixed-hooks.ts","../../src/fixed.tsx","../../src/dynamic-hooks.ts","../../src/dynamic.tsx","../../src/use-size.ts","../../src/use-scroller.ts","../../src/utils.ts"],"sourcesContent":["import type { ListItemProps } from \"./types\";\n\nexport function useList<Item>({\n  items,\n  width,\n  height,\n  overscanBy = 2,\n  scrollTop,\n  itemHeight,\n  itemGap = 0,\n}: UseListOptions<Item>) {\n  const totalItemHeight = itemHeight + itemGap;\n  overscanBy = height * overscanBy;\n  let index = Math.floor(\n    Math.max(0, scrollTop - overscanBy / 2) / totalItemHeight\n  );\n  const stopIndex = Math.min(\n    items.length,\n    Math.ceil((scrollTop + overscanBy) / totalItemHeight)\n  );\n  const childProps: ListItemProps<Item>[] = [];\n\n  for (; index < stopIndex; index++) {\n    childProps.push({\n      index,\n      data: items[index],\n      width,\n      height,\n      style: {\n        position: \"absolute\",\n        width: \"100%\",\n        top: itemGap * index + index * itemHeight,\n        left: 0,\n      },\n    });\n  }\n\n  return childProps;\n}\n\nexport interface UseListOptions<Item> {\n  items: Item[];\n  width: number;\n  height: number;\n  itemHeight: number;\n  itemGap?: number;\n  overscanBy?: number;\n  scrollTop: number;\n}\n","import * as React from \"react\";\nimport { useList } from \"./fixed-hooks\";\nimport { getContainerStyle, defaultGetItemKey } from \"./utils\";\nimport type { ListPropsBase, ListItemProps } from \"./types\";\n\nexport function List<Item>({\n  items,\n  width,\n  height,\n  overscanBy = 2,\n  scrollTop,\n  itemHeight,\n  itemGap = 0,\n  as: Container = \"div\",\n  id,\n  className,\n  style,\n  role = \"list\",\n  tabIndex,\n  itemAs: WrapperComponent = \"div\",\n  itemKey = defaultGetItemKey,\n  isScrolling,\n  onRender,\n  innerRef,\n  render: RenderComponent,\n}: ListProps<Item>) {\n  const children: (\n    | ListItemProps<Item>\n    | React.ReactElement<ListItemProps<Item>>\n  )[] = useList({\n    items,\n    width,\n    height,\n    overscanBy,\n    scrollTop,\n    itemHeight,\n    itemGap,\n  });\n  const itemRole = role && role + \"item\";\n  const startIndex = children[0]\n    ? (children[0] as ListItemProps<Item>).index\n    : 0;\n  let stopIndex: number | undefined;\n  let i = 0;\n\n  for (; i < children.length; i++) {\n    const child = children[i] as ListItemProps<Item>;\n    stopIndex = child.index;\n    children[i] = (\n      <WrapperComponent\n        key={itemKey(child.data, child.index)}\n        role={itemRole}\n        style={child.style}\n      >\n        <RenderComponent\n          index={child.index}\n          data={child.data}\n          width={child.width}\n          height={child.height}\n        />\n      </WrapperComponent>\n    );\n  }\n\n  // Calls the onRender callback if the rendered indices changed\n  React.useEffect(() => {\n    if (typeof onRender === \"function\" && stopIndex !== void 0)\n      onRender(startIndex, stopIndex, items);\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [onRender, items, startIndex, stopIndex]);\n\n  const containerStyle = getContainerStyle(\n    isScrolling,\n    (itemHeight + itemGap) * items.length - itemGap\n  );\n\n  return (\n    <Container\n      id={id}\n      className={className}\n      style={\n        style !== void 0\n          ? Object.assign({}, containerStyle, style)\n          : containerStyle\n      }\n      role={role}\n      tabIndex={tabIndex}\n      ref={innerRef}\n      children={children}\n    />\n  );\n}\n\nexport interface ListProps<Item> extends ListPropsBase<Item> {\n  readonly itemHeight: number;\n  readonly render: React.ComponentType<ListRenderProps<Item>>;\n}\n\nexport interface ListRenderProps<Item> {\n  index: number;\n  data: Item;\n  width: number;\n  [prop: string]: any;\n}\n","import { useEffect, useState, useRef } from \"react\";\nimport useLayoutEffect from \"@react-hook/passive-layout-effect\";\nimport type { ListItemProps } from \"./types\";\n\nexport function useDynamicList<Item>({\n  items,\n  width,\n  height,\n  overscanBy = 2,\n  scrollTop,\n  itemHeightEstimate = 32,\n  positioner,\n}: UseDynamicListOptions<Item>) {\n  const itemCount = items.length;\n  const measuredCount = positioner.size();\n  overscanBy = height * overscanBy;\n  const childProps: ListItemProps<Item>[] = [];\n\n  positioner.range(\n    Math.max(0, scrollTop - overscanBy / 2),\n    scrollTop + overscanBy,\n    ({ height, top }, index) =>\n      childProps.push({\n        index,\n        data: items[index],\n        width,\n        height,\n        style: {\n          position: \"absolute\",\n          width: \"100%\",\n          top,\n          left: 0,\n        },\n      })\n  );\n\n  const currentHeight = positioner.height();\n  const needsFreshBatch =\n    currentHeight <= scrollTop + overscanBy && measuredCount < itemCount;\n\n  if (needsFreshBatch) {\n    const batchSize =\n      measuredCount +\n      Math.min(\n        itemCount - measuredCount,\n        Math.ceil((scrollTop + overscanBy - currentHeight) / itemHeightEstimate)\n      );\n\n    for (let index = measuredCount; index < batchSize; index++)\n      childProps.push({\n        index,\n        data: items[index],\n        width,\n        height: -1,\n        style: prerenderItemStyle,\n      });\n  }\n\n  return childProps;\n}\n\nexport interface UseDynamicListOptions<Item> {\n  positioner: Positioner;\n  items: Item[];\n  width: number;\n  height: number;\n  itemHeightEstimate?: number;\n  overscanBy?: number;\n  scrollTop: number;\n}\n\nconst prerenderItemStyle: React.CSSProperties = {\n  position: \"absolute\",\n  width: \"100%\",\n  zIndex: -1000,\n  visibility: \"hidden\",\n};\n\nexport const usePositioner = (\n  itemGap = 0,\n  deps: React.DependencyList = emptyArr\n) => {\n  const didMount = useRef(0);\n  const initPositioner = () => createPositioner(itemGap);\n  const [positioner, setPositioner] = useState(initPositioner);\n  // Create a new positioner when the dependencies change\n  useEffect(() => {\n    if (didMount.current) setPositioner(initPositioner());\n    didMount.current = 1;\n    // eslint-disable-next-line\n  }, deps);\n  // Sets a new item positioner if the row gutter changes\n  useLayoutEffect(() => {\n    if (didMount.current) {\n      const cacheSize = positioner.size();\n      const nextPositioner = initPositioner();\n      let index = 0;\n\n      for (; index < cacheSize; index++) {\n        const pos = positioner.get(index);\n        nextPositioner.set(index, pos !== void 0 ? pos.height : 0);\n      }\n\n      setPositioner(nextPositioner);\n      didMount.current = 1;\n    }\n    // eslint-disable-next-line\n  }, [itemGap]);\n\n  return positioner;\n};\n\nconst createPositioner = (itemGap = 0): Positioner => {\n  let listHeight = 0;\n  const tops: number[] = [];\n  const items: PositionerItem[] = [];\n\n  return {\n    set: (index, height = 0) => {\n      items[index] = { top: tops[index] = listHeight, height };\n      listHeight += height + itemGap;\n      return items[index];\n    },\n    // This only updates the items in the list that exist beyond the index\n    // whose dimesions changed\n    update: (index, height) => {\n      const updatedItem = items[index++];\n      const diff = height - updatedItem.height;\n      listHeight += diff;\n      updatedItem.height = height;\n\n      for (; index < items.length; ++index)\n        tops[index] = items[index].top += diff;\n    },\n    get: (index) => items[index],\n    remove: (index) => {\n      const removed = items.splice(index, 1)?.[0];\n      if (removed) {\n        tops.splice(index, 1);\n        const diff = removed.height + itemGap;\n        listHeight -= diff;\n\n        for (; index < items.length; index++) {\n          const item = items[index];\n          tops[index] = item.top -= diff;\n        }\n      }\n    },\n    est: (itemCount, defaultItemHeight) =>\n      itemCount === 0\n        ? 0\n        : itemCount === items.length\n        ? listHeight - itemGap\n        : listHeight +\n          Math.ceil(itemCount - items.length) * (defaultItemHeight + itemGap) -\n          itemGap,\n    range: (lo, hi, cb) => {\n      const count = items.length;\n      if (count > 0) {\n        let i = binarySearchGE(tops, lo);\n        for (; i < count; i++) {\n          const item = items[i];\n          if (item.top > hi) break;\n          cb(item, i);\n        }\n      }\n    },\n    height: () => listHeight,\n    size: () => tops.length,\n  };\n};\n\nexport interface Positioner {\n  set: (index: number, height: number) => PositionerItem;\n  update: (index: number, height: number) => void;\n  get: (index: number) => PositionerItem;\n  remove: (index: number) => void;\n  est: (itemCount: number, defaultItemHeight: number) => number;\n  range: (\n    lo: number,\n    hi: number,\n    cb: (item: PositionerItem, i: number) => void\n  ) => void;\n  height: () => number;\n  size: () => number;\n}\n\nexport interface PositionerItem {\n  top: number;\n  height: number;\n}\n\nconst emptyArr: [] = [];\n\nconst binarySearchGE = (a: number[], value: number, lo = 0) => {\n  let hi = a.length - 1;\n  let i = hi + 1;\n\n  while (lo <= hi) {\n    const m = (lo + hi) >>> 1;\n    const x = a[m];\n\n    if (x >= value) {\n      hi = m - 1;\n      i = m;\n    } else {\n      lo = m + 1;\n    }\n  }\n\n  return i;\n};\n","import * as React from \"react\";\nimport { useDynamicList, usePositioner } from \"./dynamic-hooks\";\nimport { getContainerStyle, defaultGetItemKey } from \"./utils\";\nimport type { ListPropsBase, ListItemProps } from \"./types\";\nimport type { Positioner } from \"./dynamic-hooks\";\n\nexport function useDynamicListItems<Item>({\n  items,\n  width,\n  height,\n  overscanBy = 2,\n  scrollTop,\n  itemHeightEstimate = 32,\n  positioner,\n  innerRef,\n  as: Container = \"div\",\n  id,\n  className,\n  style,\n  role = \"list\",\n  tabIndex,\n  itemAs: WrapperComponent = \"div\",\n  itemKey = defaultGetItemKey,\n  isScrolling,\n  onRender,\n  render: RenderComponent,\n}: UseDynamicListItemsOptions<Item>) {\n  const children: (\n    | ListItemProps<Item>\n    | React.ReactElement<ListItemProps<Item>>\n  )[] = useDynamicList({\n    items,\n    width,\n    height,\n    overscanBy,\n    scrollTop,\n    itemHeightEstimate,\n    positioner,\n  });\n  const forceUpdate_ = useForceUpdate();\n  const updating = React.useRef(false);\n  // batches calls to force update\n  updating.current = false;\n  const forceUpdate = () => {\n    if (!updating.current) {\n      updating.current = true;\n      forceUpdate_();\n    }\n  };\n  const itemRole = role && role + \"item\";\n  let needsFreshBatch = false;\n  let startIndex = 0;\n  let stopIndex: number | undefined;\n  let i = 0;\n\n  for (; i < children.length; i++) {\n    const child = children[i] as ListItemProps<Item>;\n    needsFreshBatch = needsFreshBatch || child.height === -1;\n\n    if (child.height !== -1) {\n      startIndex = stopIndex === void 0 ? child.index : startIndex;\n      stopIndex = child.index;\n    }\n\n    children[i] = (\n      <DynamicListItem\n        key={itemKey(child.data, child.index)}\n        role={itemRole}\n        style={child.style}\n        index={child.index}\n        data={child.data}\n        width={child.width}\n        height={child.height === -1 ? child.height : void 0}\n        as={WrapperComponent}\n        meas={forceUpdate}\n        pos={positioner}\n        render={RenderComponent}\n      />\n    ) as React.ReactElement<ListItemProps<Item>>;\n  }\n\n  // If we needed a fresh batch we should reload our components with the measured\n  // sizes\n  React.useEffect(() => {\n    if (needsFreshBatch) forceUpdate();\n    // eslint-disable-next-line\n  }, [needsFreshBatch]);\n  // Calls the onRender callback if the rendered indices changed\n  React.useEffect(() => {\n    if (typeof onRender === \"function\" && stopIndex !== void 0)\n      onRender(startIndex, stopIndex, items);\n    // Resets the container key for SSR hydration\n    didEverMount = \"1\";\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [onRender, items, startIndex, stopIndex]);\n\n  const containerStyle = getContainerStyle(\n    isScrolling,\n    positioner.est(items.length, itemHeightEstimate)\n  );\n\n  return (\n    <Container\n      id={id}\n      className={className}\n      style={\n        style !== void 0\n          ? Object.assign({}, containerStyle, style)\n          : containerStyle\n      }\n      role={role}\n      tabIndex={tabIndex}\n      ref={innerRef}\n      children={children}\n      key={didEverMount}\n    />\n  );\n}\n\nexport interface UseDynamicListItemsOptions<Item>\n  extends Omit<ListPropsBase<Item>, \"itemGap\"> {\n  readonly positioner: Positioner;\n  readonly itemHeightEstimate?: number;\n  readonly render: React.ComponentType<DynamicListRenderProps<Item>>;\n}\n\nexport function DynamicList<Item>(props: DynamicListProps<Item>) {\n  const positioner = usePositioner(props.itemGap);\n  return useDynamicListItems(Object.assign({ positioner }, props));\n}\n\nlet didEverMount = \"0\";\n\nexport interface DynamicListProps<Item> extends ListPropsBase<Item> {\n  readonly itemHeightEstimate?: number;\n  readonly render: React.ComponentType<DynamicListRenderProps<Item>>;\n}\n\nfunction DynamicListItem<Item>({\n  role,\n  style,\n  index,\n  data,\n  width,\n  height,\n  as: WrapperComponent,\n  meas,\n  pos,\n  render: RenderComponent,\n}: DynamicListItemProps<Item> & {\n  as: keyof JSX.IntrinsicElements | React.ComponentType<any>;\n}) {\n  const ref = React.useRef<HTMLElement | null>(null);\n  const measure = React.useCallback(() => {\n    const current = ref.current;\n    if (current) {\n      pos.update(index, current.offsetHeight);\n      meas();\n    }\n    // eslint-disable-next-line\n  }, [pos]);\n\n  return (\n    <WrapperComponent\n      role={role}\n      style={style}\n      ref={(el: HTMLElement | null) => {\n        if (el) {\n          ref.current = el.firstChild as HTMLElement;\n          pos.get(index) === void 0 && pos.set(index, el.offsetHeight);\n        }\n      }}\n    >\n      <RenderComponent\n        index={index}\n        data={data}\n        width={width}\n        height={height}\n        measure={measure}\n      />\n    </WrapperComponent>\n  );\n}\n\ninterface DynamicListItemProps<Item> {\n  as: DynamicListProps<Item>[\"itemAs\"];\n  role: string;\n  style: React.CSSProperties;\n  index: number;\n  data: Item;\n  width: number;\n  height: number | undefined;\n  render: React.ComponentType<DynamicListRenderProps<Item>>;\n  pos: Positioner;\n  meas: () => void;\n}\n\nexport interface DynamicListRenderProps<Item> {\n  index: number;\n  data: Item;\n  width: number;\n  height: number | undefined;\n  measure: () => void;\n  [prop: string]: any;\n}\n\nconst useForceUpdate = (): (() => void) => {\n  const setState = React.useState(emptyObj)[1];\n  return React.useRef(() => setState({})).current;\n};\n\nconst emptyObj = {};\n","import * as React from \"react\";\nimport useLayoutEffect from \"@react-hook/passive-layout-effect\";\nimport useEvent from \"@react-hook/event\";\n\nexport function useSize<T extends HTMLElement>(\n  ref: React.MutableRefObject<T | null>\n): { width: number; height: number } {\n  const getSize = () => {\n    const { current } = ref;\n    if (current) {\n      const computedStyle = getComputedStyle(current);\n      const float = parseFloat;\n      return {\n        width:\n          current.clientWidth -\n          float(computedStyle.paddingTop) -\n          float(computedStyle.paddingBottom),\n        height:\n          current.clientHeight -\n          float(computedStyle.paddingLeft) -\n          float(computedStyle.paddingRight),\n      };\n    }\n\n    return { width: 0, height: 0 };\n  };\n  const [size, setSize] = React.useState<{ width: number; height: number }>(\n    getSize\n  );\n\n  const handleResize = () => setSize(getSize());\n\n  useEvent(\n    typeof window !== \"undefined\" ? window : null,\n    \"resize\",\n    handleResize\n  );\n\n  useEvent(\n    typeof window !== \"undefined\" ? window : null,\n    \"orientationchange\",\n    handleResize\n  );\n\n  useLayoutEffect(() => {\n    setSize(getSize());\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  return size;\n}\n","import * as React from \"react\";\nimport useLayoutEffect from \"@react-hook/passive-layout-effect\";\nimport {\n  requestTimeout,\n  clearRequestTimeout,\n} from \"@essentials/request-timeout\";\nimport { useThrottle } from \"@react-hook/throttle\";\n\nexport function useScroller<T extends HTMLElement>(\n  ref: Window | React.MutableRefObject<T | null> | T | null,\n  options: UseScrollerOptions = {}\n): { scrollTop: number; isScrolling: boolean } {\n  const { offset = 0, fps = 12 } = options;\n  const current = ref && \"current\" in ref ? ref.current : ref;\n  const getScrollPos = () =>\n    !current\n      ? 0\n      : \"scrollTop\" in current\n      ? current.scrollTop\n      : current.pageYOffset || current.scrollY;\n  const [scrollTop, setScrollTop] = useThrottle(getScrollPos, fps);\n  const [isScrolling, setIsScrolling] = React.useState(false);\n\n  useLayoutEffect(() => {\n    if (current) {\n      let didUnmount = false;\n      let to: ReturnType<typeof requestTimeout> | undefined;\n      const clearTo = () => to && clearRequestTimeout(to);\n      const handleScroll = () => {\n        if (didUnmount) return;\n        setScrollTop(getScrollPos());\n        setIsScrolling(true);\n        clearTo();\n        to = requestTimeout(() => {\n          // This is here to prevent premature bail outs while maintaining high resolution\n          // unsets. Without it there will always bee a lot of unnecessary DOM writes to style.\n          setIsScrolling(false);\n        }, 1000 / fps);\n      };\n\n      current.addEventListener(\"scroll\", handleScroll);\n      return () => {\n        current.removeEventListener(\"scroll\", handleScroll);\n        clearTo();\n        didUnmount = true;\n      };\n    }\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [current, fps]);\n\n  return { scrollTop: Math.max(0, scrollTop - offset), isScrolling };\n}\n\nexport interface UseScrollerOptions {\n  offset?: number;\n  fps?: number;\n}\n","import memoizeOne from \"@essentials/memoize-one\";\n\nexport const getContainerStyle = memoizeOne(\n  (isScrolling: boolean | undefined, estimatedHeight: number) => ({\n    position: \"relative\",\n    width: \"100%\",\n    maxWidth: \"100%\",\n    height: Math.ceil(estimatedHeight),\n    maxHeight: Math.ceil(estimatedHeight),\n    willChange: isScrolling ? \"contents,height\" : void 0,\n    pointerEvents: isScrolling ? \"none\" : void 0,\n  })\n);\n\nexport const defaultGetItemKey = (_: any[], i: number): number => i;\n"],"names":["useList","items","width","height","overscanBy","scrollTop","itemHeight","itemGap","totalItemHeight","index","Math","floor","max","stopIndex","min","length","ceil","childProps","push","data","style","position","top","left","List","as","Container","id","className","role","tabIndex","itemAs","WrapperComponent","itemKey","defaultGetItemKey","isScrolling","onRender","innerRef","render","RenderComponent","children","itemRole","startIndex","i","child","__reactCreateElement__","key","React","containerStyle","getContainerStyle","Object","assign","ref","useDynamicList","itemHeightEstimate","positioner","itemCount","measuredCount","size","range","currentHeight","batchSize","prerenderItemStyle","useDynamicListItems","forceUpdate_","useForceUpdate","updating","current","forceUpdate","needsFreshBatch","DynamicListItem","meas","pos","didEverMount","est","DynamicList","props","usePositioner","measure","update","offsetHeight","el","firstChild","get","set","useSize","getSize","computedStyle","getComputedStyle","float","parseFloat","clientWidth","paddingTop","paddingBottom","clientHeight","paddingLeft","paddingRight","setSize","handleResize","useEvent","window","useLayoutEffect","useScroller","options","setIsScrolling","offset","fps","getScrollPos","pageYOffset","scrollY","setScrollTop","useThrottle","to","didUnmount","clearTo","clearRequestTimeout","handleScroll","requestTimeout","addEventListener","removeEventListener","memoizeOne","estimatedHeight","maxWidth","maxHeight","willChange","pointerEvents","_","zIndex","visibility","deps","emptyArr","didMount","useRef","initPositioner","createPositioner","_ref_0","useState","setPositioner","useEffect","cacheSize","nextPositioner","listHeight","tops","updatedItem","diff","remove","removed","splice","_items$splice","item","defaultItemHeight","lo","hi","cb","count","binarySearchGE","a","value","m","setState","emptyObj"],"mappings":"AAEO,SAASA,SAAcC,MAC5BA,EAD4BC,MAE5BA,EAF4BC,OAG5BA,EAH4BC,WAI5BA,EAAa,EAJeC,UAK5BA,EAL4BC,WAM5BA,EAN4BC,QAO5BA,EAAU,KAEJC,EAAkBF,EAAaC,EACrCH,GAAaD,UACTM,EAAQC,KAAKC,M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