All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.RoutableTabs-T8JTILEW.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
{"version":3,"file":"RoutableTabs-T8JTILEW.js","sources":["../../src/components/routable-tabs/RoutableTabs.tsx"],"sourcesContent":["import {\n  Tab,\n  TabProps,\n  Tabs,\n  TabsComponent,\n  TabsProps,\n} from \"@patternfly/react-core\";\nimport {\n  Children,\n  JSXElementConstructor,\n  PropsWithChildren,\n  ReactElement,\n  isValidElement,\n} from \"react\";\nimport {\n  Path,\n  generatePath,\n  matchPath,\n  useHref,\n  useLocation,\n  useParams,\n} from \"react-router-dom\";\nimport { useServerInfo } from \"../../context/server-info/ServerInfoProvider\";\nimport { PageHandler } from \"../../page/PageHandler\";\nimport { TAB_PROVIDER } from \"../../page/PageList\";\nimport useIsFeatureEnabled, { Feature } from \"../../utils/useIsFeatureEnabled\";\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  const params = useParams();\n  const { componentTypes } = useServerInfo();\n  const tabs = componentTypes?.[TAB_PROVIDER] || [];\n  const isFeatureEnabled = useIsFeatureEnabled();\n\n  const matchedTabs = tabs\n    .filter((tab) => matchPath({ path: tab.metadata.path }, pathname))\n    .map((t) => ({\n      ...t,\n      pathname: generatePath(t.metadata.path, {\n        ...params,\n        ...t.metadata.params,\n      }),\n    }));\n  // Extract all keys from matchedTabs\n  const matchedTabsKeys = matchedTabs.map((t) => t.pathname);\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  const allKeys = [...eventKeys, ...matchedTabsKeys];\n\n  // Determine if there is an exact match.\n  const exactMatch = allKeys.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 as any}\n      {isFeatureEnabled(Feature.DeclarativeUI) &&\n        matchedTabs.map((t) => (\n          \n            \n          \n        ))}\n    \n  );\n};\n\ntype DynamicTabProps = {\n  title: string;\n  eventKey: string;\n};\n\nconst DynamicTab = ({\n  children,\n  ...props\n}: PropsWithChildren) => {\n  const href = useHref(props.eventKey);\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","params","useParams","componentTypes","useServerInfo","tabs","TAB_PROVIDER","isFeatureEnabled","useIsFeatureEnabled","matchedTabs","tab","matchPath","t","generatePath","matchedTabsKeys","eventKeys","Children","child","isValidElement","exactMatch","eventKey","nearestMatch","b","jsxs","Tabs","TabsComponent","Feature","jsx","DynamicTab","PageHandler","props","href","useHref","Tab","useRoutableTab","to"],"mappings":"8VAyCO,MAAMA,EAAe,CAAC,CAC3B,SAAAC,EACA,gBAAAC,EACA,GAAGC,CACL,IAAyB,CACjB,KAAA,CAAE,SAAAC,GAAaC,IACfC,EAASC,IACT,CAAE,eAAAC,GAAmBC,IACrBC,EAAOF,IAAiBG,CAAY,GAAK,CAAA,EACzCC,EAAmBC,IAEnBC,EAAcJ,EACjB,OAAQK,GAAQC,EAAU,CAAE,KAAMD,EAAI,SAAS,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