UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

2 lines (1 loc) 868 B
var c=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var u=(o,t)=>{for(var n in t)c(o,n,{get:t[n],enumerable:!0})},I=(o,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of m(t))!f.call(o,e)&&e!==n&&c(o,e,{get:()=>t[e],enumerable:!(a=d(t,e))||a.enumerable});return o};var h=o=>I(c({},"__esModule",{value:!0}),o);var v={};u(v,{useActiveState:()=>p});module.exports=h(v);var r=require("../hooks/use-location"),i=require("./utils");function p(o,{locationMatchDepth:t,elementIdOffset:n}={locationMatchDepth:3,elementIdOffset:1}){const a=(0,r.useLocation)(),e=(0,i.getLocationId)(a);if(!e)return{isActive:!1};const l=(0,i.normalizeElementId)(e,{resultParts:t}),s=(0,i.normalizeElementId)(o,{trimLeadingParts:n});return{isActive:l===s}}0&&(module.exports={useActiveState});