Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
theme.keycloak.v2.admin.resources.assets.RoutableTabs-56121a9c.js.map Maven / Gradle / Ivy
Go to download
The user inferface to administrate the Keycloak server.
{"version":3,"file":"RoutableTabs-56121a9c.js","sources":["../../src/components/routable-tabs/RoutableTabs.tsx"],"sourcesContent":["import {\n TabProps,\n Tabs,\n TabsComponent,\n TabsProps,\n} from \"@patternfly/react-core\";\nimport {\n Children,\n isValidElement,\n JSXElementConstructor,\n ReactElement,\n} from \"react\";\nimport { Path, useHref, useLocation } from \"react-router-dom\";\n\n// TODO: Remove the custom 'children' props and type once the following issue has been resolved:\n// https://github.com/patternfly/patternfly-react/issues/6766\ntype ChildElement = ReactElement>;\ntype Child = ChildElement | boolean | null | undefined;\n\n// TODO: Figure out why we need to omit 'ref' from the props.\ntype RoutableTabsProps = {\n children: Child | Child[];\n defaultLocation?: Partial;\n} & Omit<\n TabsProps,\n \"ref\" | \"activeKey\" | \"defaultActiveKey\" | \"component\" | \"children\"\n>;\n\nexport const RoutableTabs = ({\n children,\n defaultLocation,\n ...otherProps\n}: RoutableTabsProps) => {\n const { pathname } = useLocation();\n\n // Extract event keys from children.\n const eventKeys = Children.toArray(children)\n .filter((child): child is ChildElement => isValidElement(child))\n .map((child) => child.props.eventKey.toString());\n\n // Determine if there is an exact match.\n const exactMatch = eventKeys.find(\n (eventKey) => eventKey === decodeURI(pathname)\n );\n\n // Determine which event keys at least partially match the current path, then sort them so the nearest match ends up on top.\n const nearestMatch = eventKeys\n .filter((eventKey) => pathname.includes(eventKey))\n .sort((a, b) => a.length - b.length)\n .pop();\n\n return (\n \n {children}\n \n );\n};\n\nexport const useRoutableTab = (to: Partial) => ({\n eventKey: to.pathname ?? \"\",\n href: useHref(to),\n});\n"],"names":["RoutableTabs","children","defaultLocation","otherProps","pathname","useLocation","eventKeys","Children","child","isValidElement","exactMatch","eventKey","nearestMatch","a","b","jsx","Tabs","TabsComponent","useRoutableTab","to","useHref"],"mappings":"6GA4BO,MAAMA,EAAe,CAAC,CAC3B,SAAAC,EACA,gBAAAC,EACA,GAAGC,CACL,IAAyB,CACjB,KAAA,CAAE,SAAAC,GAAaC,IAGfC,EAAYC,EAAAA,SAAS,QAAQN,CAAQ,EACxC,OAAQO,GAAiCC,EAAA,eAAeD,CAAK,CAAC,EAC9D,IAAKA,GAAUA,EAAM,MAAM,SAAS,UAAU,EAG3CE,EAAaJ,EAAU,KAC1BK,GAAaA,IAAa,UAAUP,CAAQ,CAAA,EAIzCQ,EAAeN,EAClB,OAAQK,GAAaP,EAAS,SAASO,CAAQ,CAAC,EAChD,KAAK,CAACE,EAAGC,IAAMD,EAAE,OAASC,EAAE,MAAM,EAClC,MAGD,OAAAC,EAAA,IAACC,EAAA,CACC,UACEN,GAAcE,GAAgBV,GAAiB,UAAYE,EAE7D,UAAWa,EAAc,IACzB,MAAO,CACL,QAAS,YACT,GAAI,UACJ,MAAO,UACT,EACC,GAAGd,EAEH,SAAAF,CAAA,CAAA,CAGP,EAEaiB,EAAkBC,IAAuB,CACpD,SAAUA,EAAG,UAAY,GACzB,KAAMC,EAAQD,CAAE,CAClB"}