{"version":3,"sources":["../../src/NavScroll/types.ts"],"sourcesContent":["/*\n * This work derives from the React Use Navscroll library\n * Released under the MIT license by Marco Liberati\n * Code: https://github.com/dej611/react-use-navscroll\n */\n\nimport { HTMLAttributes, RefObject } from 'react';\n\n/**\n * The returned object from the `onChange` passed function, with the current state of\n * `added` and `removed` element ids.\n */\nexport type ChangesType = {\n  added: string | null;\n  removed: string | null;\n};\n\n/**\n * The react-use-navscroll configuration object\n */\nexport type useNavScrollArgs = {\n  /**\n   * Function called every time an element becomes active.\n   * The changes object returned contains the \"added\" and \"removed\" id.\n   * */\n  onChange?: (changes: ChangesType) => void;\n  /**\n   * Pass an element as root to track a specific container, smaller than a viewport. Default is window (the whole viewport).\n   * */\n  root?: Element;\n  /**\n   * Moves the detection line by the amount of this offset, expressed in percentage. By default the value is 50 (center).\n   * */\n  offset?: number;\n  /**\n   * Declare if the detection should work vertically or horizontally. By default false (vertical)\n   */\n  isHorizontal?: boolean;\n};\n\n/**\n * The options object passed to the `register` function.\n */\nexport type RegisterOptions = {\n  /**\n   * Pass the string id of the parent element\n   */\n  parent?: string;\n  /**\n   * If the tracked element has already a reference, you can pass it and will be reused\n   */\n  ref?: RefObject<Element>;\n};\n\n/**\n * The attributes object to assign to the element to assign\n */\nexport type RegisteredAttributes<T extends Element> = {\n  id: HTMLAttributes<T>['id'];\n  ref: RefObject<T> | null;\n};\n\n/**\n * The object returned by the hook.\n */\nexport type useNavScrollResult = {\n  /**\n   * The function used to register the component into the tracking system.\n   * It returns the id already passed and the reference object.\n   * Note that only the reference value will be `null` in a SSR context.\n   */\n  register: <T extends Element>(id: string, options?: RegisterOptions) => RegisteredAttributes<T>;\n  /**\n   * Removes the given id from the tracking system.\n   */\n  unregister: (idToUnregister: string) => void;\n  /**\n   * A list of active ids (the full hierarchy).\n   */\n  activeIds: string[];\n  /**\n   * A convenience function to quickly check the active state for the given id\n   */\n  isActive: (id: string) => boolean;\n  /**\n   * A function to retrieve the reference of the current active element (only the last element, not the elements hierarchy).\n   */\n  getActiveRef: () => RefObject<Element> | null;\n  /**\n   * A list of active ids (the full hierarchy).\n   */\n  percentage: number;\n};\n\n// @private\nexport type TrackedElement = {\n  id: string;\n} & Required<Pick<RegisterOptions, 'ref'>> &\n  Pick<RegisterOptions, 'parent'>;\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["types_exports","__toCommonJS"]}