@backstage/ui 0.17.2-next.0 → 0.18.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/analytics/useAnalytics.esm.js +5 -5
- package/dist/analytics/useAnalytics.esm.js.map +1 -1
- package/dist/components/Accordion/definition.esm.js +3 -1
- package/dist/components/Accordion/definition.esm.js.map +1 -1
- package/dist/components/Alert/definition.esm.js +3 -1
- package/dist/components/Alert/definition.esm.js.map +1 -1
- package/dist/components/Avatar/definition.esm.js +3 -1
- package/dist/components/Avatar/definition.esm.js.map +1 -1
- package/dist/components/Badge/definition.esm.js +3 -1
- package/dist/components/Badge/definition.esm.js.map +1 -1
- package/dist/components/Box/definition.esm.js +3 -1
- package/dist/components/Box/definition.esm.js.map +1 -1
- package/dist/components/Button/definition.esm.js +3 -1
- package/dist/components/Button/definition.esm.js.map +1 -1
- package/dist/components/ButtonIcon/definition.esm.js +3 -1
- package/dist/components/ButtonIcon/definition.esm.js.map +1 -1
- package/dist/components/ButtonLink/ButtonLink.esm.js +39 -23
- package/dist/components/ButtonLink/ButtonLink.esm.js.map +1 -1
- package/dist/components/ButtonLink/definition.esm.js +4 -1
- package/dist/components/ButtonLink/definition.esm.js.map +1 -1
- package/dist/components/Card/Card.esm.js +2 -1
- package/dist/components/Card/Card.esm.js.map +1 -1
- package/dist/components/Card/definition.esm.js +3 -1
- package/dist/components/Card/definition.esm.js.map +1 -1
- package/dist/components/Checkbox/definition.esm.js +3 -1
- package/dist/components/Checkbox/definition.esm.js.map +1 -1
- package/dist/components/CheckboxGroup/definition.esm.js +3 -1
- package/dist/components/CheckboxGroup/definition.esm.js.map +1 -1
- package/dist/components/Combobox/ComboboxItem.esm.js +37 -11
- package/dist/components/Combobox/ComboboxItem.esm.js.map +1 -1
- package/dist/components/Combobox/definition.esm.js +4 -1
- package/dist/components/Combobox/definition.esm.js.map +1 -1
- package/dist/components/Container/definition.esm.js +3 -1
- package/dist/components/Container/definition.esm.js.map +1 -1
- package/dist/components/DatePicker/definition.esm.js +3 -1
- package/dist/components/DatePicker/definition.esm.js.map +1 -1
- package/dist/components/DateRangePicker/definition.esm.js +3 -1
- package/dist/components/DateRangePicker/definition.esm.js.map +1 -1
- package/dist/components/Dialog/definition.esm.js +3 -1
- package/dist/components/Dialog/definition.esm.js.map +1 -1
- package/dist/components/FieldError/definition.esm.js +3 -1
- package/dist/components/FieldError/definition.esm.js.map +1 -1
- package/dist/components/FieldLabel/definition.esm.js +3 -1
- package/dist/components/FieldLabel/definition.esm.js.map +1 -1
- package/dist/components/Flex/definition.esm.js +3 -1
- package/dist/components/Flex/definition.esm.js.map +1 -1
- package/dist/components/FullPage/definition.esm.js +3 -1
- package/dist/components/FullPage/definition.esm.js.map +1 -1
- package/dist/components/Grid/definition.esm.js +3 -1
- package/dist/components/Grid/definition.esm.js.map +1 -1
- package/dist/components/Header/HeaderMetadataStatus.esm.js +3 -1
- package/dist/components/Header/HeaderMetadataStatus.esm.js.map +1 -1
- package/dist/components/Header/HeaderMetadataUsers.esm.js +3 -1
- package/dist/components/Header/HeaderMetadataUsers.esm.js.map +1 -1
- package/dist/components/Header/HeaderNav.esm.js +67 -24
- package/dist/components/Header/HeaderNav.esm.js.map +1 -1
- package/dist/components/Header/HeaderNavDefinition.esm.js +4 -1
- package/dist/components/Header/HeaderNavDefinition.esm.js.map +1 -1
- package/dist/components/Header/definition.esm.js +3 -1
- package/dist/components/Header/definition.esm.js.map +1 -1
- package/dist/components/Link/Link.esm.js +64 -23
- package/dist/components/Link/Link.esm.js.map +1 -1
- package/dist/components/Link/definition.esm.js +4 -1
- package/dist/components/Link/definition.esm.js.map +1 -1
- package/dist/components/List/List.esm.js +3 -2
- package/dist/components/List/List.esm.js.map +1 -1
- package/dist/components/List/definition.esm.js +3 -1
- package/dist/components/List/definition.esm.js.map +1 -1
- package/dist/components/Menu/Menu.esm.js +48 -14
- package/dist/components/Menu/Menu.esm.js.map +1 -1
- package/dist/components/Menu/definition.esm.js +5 -1
- package/dist/components/Menu/definition.esm.js.map +1 -1
- package/dist/components/NumberField/definition.esm.js +3 -1
- package/dist/components/NumberField/definition.esm.js.map +1 -1
- package/dist/components/PasswordField/definition.esm.js +3 -1
- package/dist/components/PasswordField/definition.esm.js.map +1 -1
- package/dist/components/PluginHeader/PluginHeaderBreadcrumbs.esm.js +3 -1
- package/dist/components/PluginHeader/PluginHeaderBreadcrumbs.esm.js.map +1 -1
- package/dist/components/PluginHeader/definition.esm.js +3 -1
- package/dist/components/PluginHeader/definition.esm.js.map +1 -1
- package/dist/components/Popover/definition.esm.js +3 -1
- package/dist/components/Popover/definition.esm.js.map +1 -1
- package/dist/components/RadioGroup/definition.esm.js +3 -1
- package/dist/components/RadioGroup/definition.esm.js.map +1 -1
- package/dist/components/SearchAutocomplete/SearchAutocomplete.esm.js +23 -5
- package/dist/components/SearchAutocomplete/SearchAutocomplete.esm.js.map +1 -1
- package/dist/components/SearchAutocomplete/definition.esm.js +4 -1
- package/dist/components/SearchAutocomplete/definition.esm.js.map +1 -1
- package/dist/components/SearchField/definition.esm.js +3 -1
- package/dist/components/SearchField/definition.esm.js.map +1 -1
- package/dist/components/Select/SelectItem.esm.js +17 -3
- package/dist/components/Select/SelectItem.esm.js.map +1 -1
- package/dist/components/Select/definition.esm.js +4 -1
- package/dist/components/Select/definition.esm.js.map +1 -1
- package/dist/components/Skeleton/definition.esm.js +3 -1
- package/dist/components/Skeleton/definition.esm.js.map +1 -1
- package/dist/components/Slider/definition.esm.js +3 -1
- package/dist/components/Slider/definition.esm.js.map +1 -1
- package/dist/components/Switch/definition.esm.js +3 -1
- package/dist/components/Switch/definition.esm.js.map +1 -1
- package/dist/components/Table/components/Row.esm.js +9 -9
- package/dist/components/Table/components/Row.esm.js.map +1 -1
- package/dist/components/Table/components/TableBodySkeleton.esm.js +3 -1
- package/dist/components/Table/components/TableBodySkeleton.esm.js.map +1 -1
- package/dist/components/Table/components/TableRoot.esm.js +3 -2
- package/dist/components/Table/components/TableRoot.esm.js.map +1 -1
- package/dist/components/Table/definition.esm.js +3 -2
- package/dist/components/Table/definition.esm.js.map +1 -1
- package/dist/components/TablePagination/TablePagination.esm.js +3 -1
- package/dist/components/TablePagination/TablePagination.esm.js.map +1 -1
- package/dist/components/TablePagination/definition.esm.js +3 -1
- package/dist/components/TablePagination/definition.esm.js.map +1 -1
- package/dist/components/Tabs/Tabs.esm.js +38 -15
- package/dist/components/Tabs/Tabs.esm.js.map +1 -1
- package/dist/components/Tabs/definition.esm.js +4 -1
- package/dist/components/Tabs/definition.esm.js.map +1 -1
- package/dist/components/TagGroup/TagGroup.esm.js +12 -12
- package/dist/components/TagGroup/TagGroup.esm.js.map +1 -1
- package/dist/components/TagGroup/definition.esm.js +3 -2
- package/dist/components/TagGroup/definition.esm.js.map +1 -1
- package/dist/components/Text/definition.esm.js +3 -1
- package/dist/components/Text/definition.esm.js.map +1 -1
- package/dist/components/TextAreaField/definition.esm.js +3 -1
- package/dist/components/TextAreaField/definition.esm.js.map +1 -1
- package/dist/components/TextField/definition.esm.js +3 -1
- package/dist/components/TextField/definition.esm.js.map +1 -1
- package/dist/components/ToggleButton/definition.esm.js +3 -1
- package/dist/components/ToggleButton/definition.esm.js.map +1 -1
- package/dist/components/ToggleButtonGroup/definition.esm.js +3 -1
- package/dist/components/ToggleButtonGroup/definition.esm.js.map +1 -1
- package/dist/components/Tooltip/definition.esm.js +3 -1
- package/dist/components/Tooltip/definition.esm.js.map +1 -1
- package/dist/components/VisuallyHidden/definition.esm.js +3 -1
- package/dist/components/VisuallyHidden/definition.esm.js.map +1 -1
- package/dist/hooks/useDefinition/useDefinition.esm.js +8 -13
- package/dist/hooks/useDefinition/useDefinition.esm.js.map +1 -1
- package/dist/hooks/useDefinition/useDefinitionNavigation.esm.js +50 -0
- package/dist/hooks/useDefinition/useDefinitionNavigation.esm.js.map +1 -0
- package/dist/index.d.ts +32 -8
- package/dist/navigation/BUIRoutingProvider.esm.js +44 -0
- package/dist/navigation/BUIRoutingProvider.esm.js.map +1 -0
- package/dist/navigation/useNavigation.esm.js +130 -0
- package/dist/navigation/useNavigation.esm.js.map +1 -0
- package/dist/navigation/useRouting.esm.js +27 -0
- package/dist/navigation/useRouting.esm.js.map +1 -0
- package/dist/provider/BUIContext.esm.js +6 -0
- package/dist/provider/BUIContext.esm.js.map +1 -0
- package/dist/provider/BUIProvider.esm.js +5 -13
- package/dist/provider/BUIProvider.esm.js.map +1 -1
- package/dist/utils/linkUtils.esm.js +6 -12
- package/dist/utils/linkUtils.esm.js.map +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.esm.js","sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useRef,\n useState,\n useMemo,\n Children,\n cloneElement,\n isValidElement,\n createContext,\n useContext,\n useEffect,\n useCallback,\n} from 'react';\nimport type { ReactNode } from 'react';\nimport type {\n TabsProps,\n TabListProps,\n TabPanelProps,\n TabsContextValue,\n TabProps,\n} from './types';\nimport { useLocation } from 'react-router-dom';\nimport { TabsIndicators } from './TabsIndicators';\nimport {\n Tabs as AriaTabs,\n TabList as AriaTabList,\n Tab as AriaTab,\n TabPanel as AriaTabPanel,\n TabProps as AriaTabProps,\n} from 'react-aria-components';\nimport { useDefinition } from '../../hooks/useDefinition';\nimport {\n TabsDefinition,\n TabListDefinition,\n TabDefinition,\n TabPanelDefinition,\n} from './definition';\nimport { isInternalLink } from '../../utils/linkUtils';\nimport { getNodeText } from '../../analytics/getNodeText';\n\nconst TabsContext = createContext<TabsContextValue | undefined>(undefined);\n\nconst useTabsContext = () => {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error('Tab components must be used within a Tabs component');\n }\n return context;\n};\n\ntype TabSelectionContextValue = {\n registerRoutedTab: (id: string) => void;\n unregisterRoutedTab: (id: string) => void;\n registerActiveTab: (id: string, segmentCount: number) => void;\n unregisterActiveTab: (id: string) => void;\n};\n\nconst TabSelectionContext = createContext<TabSelectionContextValue | null>(\n null,\n);\n\n/**\n * Strips query params and hash from a href, leaving only the pathname.\n * Tab matching always compares against location.pathname which never includes them.\n */\nconst hrefPathname = (href: string) => href.split('?')[0].split('#')[0];\n\n/**\n * Utility function to determine if a tab should be active based on the matching strategy.\n * This follows the pattern used in WorkaroundNavLink from the sidebar.\n */\nconst isTabActive = (\n tabHref: string,\n currentPathname: string,\n matchStrategy: 'exact' | 'prefix',\n): boolean => {\n const pathname = hrefPathname(tabHref);\n\n if (matchStrategy === 'exact') {\n return pathname === currentPathname;\n }\n\n // Prefix matching - similar to WorkaroundNavLink behavior\n if (pathname === currentPathname) {\n return true;\n }\n\n // Check if current path starts with tab href followed by a slash\n // This prevents /foo matching /foobar\n return currentPathname.startsWith(`${pathname}/`);\n};\n\n/**\n * A component that renders a list of tabs.\n *\n * @public\n */\nexport const Tabs = (props: TabsProps) => {\n const { ownProps, restProps } = useDefinition(TabsDefinition, props);\n const { classes, children } = ownProps;\n const tabsRef = useRef<HTMLDivElement>(null);\n const tabRefs = useRef<Map<string, HTMLDivElement>>(new Map());\n const [hoveredKey, setHoveredKey] = useState<string | null>(null);\n const prevHoveredKey = useRef<string | null>(null);\n\n // State for tracking routed tabs (tabs with hrefs)\n const [routedTabs, setRoutedTabs] = useState<Set<string>>(() => new Set());\n\n // State for tracking active tabs reported by TabRouteRegistration components\n const [activeTabs, setActiveTabs] = useState<Map<string, number>>(\n () => new Map(),\n );\n\n const setTabRef = (key: string, element: HTMLDivElement | null) => {\n if (element) {\n tabRefs.current.set(key, element);\n } else {\n tabRefs.current.delete(key);\n }\n };\n\n // Compute the selected tab based on active tabs with highest segment count\n const selectedTabId = useMemo(() => {\n // No routed tabs - let React Aria handle selection (uncontrolled mode)\n if (routedTabs.size === 0) {\n return undefined;\n }\n\n // Has routed tabs but none are active - use empty string for no selection\n // (React Aria has a bug with null that causes infinite loops)\n if (activeTabs.size === 0) {\n return '';\n }\n\n let selectedId: string | undefined;\n let maxSegments = -1;\n\n activeTabs.forEach((segmentCount, id) => {\n // Pick tab with highest segment count, first one wins on tie\n if (segmentCount > maxSegments) {\n maxSegments = segmentCount;\n selectedId = id;\n }\n });\n\n return selectedId;\n }, [routedTabs, activeTabs]);\n\n const registerRoutedTab = useCallback((id: string) => {\n setRoutedTabs(prev => new Set(prev).add(id));\n }, []);\n\n const unregisterRoutedTab = useCallback((id: string) => {\n setRoutedTabs(prev => {\n const next = new Set(prev);\n next.delete(id);\n return next;\n });\n }, []);\n\n const registerActiveTab = useCallback((id: string, segmentCount: number) => {\n setActiveTabs(prev => new Map(prev).set(id, segmentCount));\n }, []);\n\n const unregisterActiveTab = useCallback((id: string) => {\n setActiveTabs(prev => {\n const next = new Map(prev);\n next.delete(id);\n return next;\n });\n }, []);\n\n if (!children) return null;\n\n const tabsContextValue: TabsContextValue = {\n tabsRef,\n tabRefs,\n hoveredKey,\n prevHoveredKey,\n setHoveredKey,\n setTabRef,\n };\n\n const selectionContextValue: TabSelectionContextValue = useMemo(\n () => ({\n registerRoutedTab,\n unregisterRoutedTab,\n registerActiveTab,\n unregisterActiveTab,\n }),\n [\n registerRoutedTab,\n unregisterRoutedTab,\n registerActiveTab,\n unregisterActiveTab,\n ],\n );\n\n return (\n <TabsContext.Provider value={tabsContextValue}>\n <TabSelectionContext.Provider value={selectionContextValue}>\n <AriaTabs\n className={classes.root}\n keyboardActivation=\"manual\"\n selectedKey={selectedTabId}\n ref={tabsRef}\n {...restProps}\n >\n {children as ReactNode}\n </AriaTabs>\n </TabSelectionContext.Provider>\n </TabsContext.Provider>\n );\n};\n\n/**\n * A component that renders a list of tabs.\n *\n * @public\n */\nexport const TabList = (props: TabListProps) => {\n const { ownProps, restProps } = useDefinition(TabListDefinition, props);\n const { classes, children } = ownProps;\n const { setHoveredKey, tabRefs, tabsRef, hoveredKey, prevHoveredKey } =\n useTabsContext();\n\n const handleHover = (key: string | null) => {\n setHoveredKey(key);\n };\n\n // Clone children with additional props for hover and ref management\n const enhancedChildren = Children.map(children as ReactNode, child => {\n if (isValidElement(child)) {\n return cloneElement(child, {\n onHoverStart: () => handleHover(child.props.id as string),\n onHoverEnd: () => handleHover(null),\n } as Partial<AriaTabProps>);\n }\n return child;\n });\n\n return (\n <div className={classes.root}>\n <AriaTabList\n className={classes.tabList}\n aria-label=\"Toolbar tabs\"\n {...restProps}\n >\n {enhancedChildren}\n </AriaTabList>\n <TabsIndicators\n tabRefs={tabRefs}\n tabsRef={tabsRef}\n hoveredKey={hoveredKey}\n prevHoveredKey={prevHoveredKey}\n />\n </div>\n );\n};\n\n/**\n * Internal component for tabs with internal hrefs.\n * Handles routing registration and active tab tracking.\n * Separated to avoid conditional hook usage in Tab component.\n * @internal\n */\nfunction RoutedTabEffects({\n id,\n href,\n matchStrategy = 'exact',\n}: {\n id: string;\n href: string;\n matchStrategy?: 'exact' | 'prefix';\n}) {\n const selectionCtx = useContext(TabSelectionContext);\n const location = useLocation();\n\n // Register as a routed tab (for controlled vs uncontrolled mode)\n useEffect(() => {\n if (selectionCtx) {\n selectionCtx.registerRoutedTab(id);\n return () => selectionCtx.unregisterRoutedTab(id);\n }\n return undefined;\n }, [id, selectionCtx]);\n\n // Register as active tab when URL matches (for tab selection)\n const isActive = isTabActive(href, location.pathname, matchStrategy);\n const segmentCount = hrefPathname(href).split('/').filter(Boolean).length;\n\n useEffect(() => {\n if (isActive && selectionCtx) {\n selectionCtx.registerActiveTab(id, segmentCount);\n return () => selectionCtx.unregisterActiveTab(id);\n }\n return undefined;\n }, [isActive, id, segmentCount, selectionCtx]);\n\n return null;\n}\n\n/**\n * A component that renders a tab.\n *\n * @public\n */\nexport const Tab = (props: TabProps) => {\n const { ownProps, restProps, analytics } = useDefinition(\n TabDefinition,\n props,\n );\n const { classes, matchStrategy, href, id } = ownProps;\n const { setTabRef } = useTabsContext();\n\n const handlePress = () => {\n if (href) {\n const text =\n restProps['aria-label'] ??\n getNodeText(restProps.children) ??\n String(href);\n analytics.captureEvent('click', text, {\n attributes: { to: String(href) },\n });\n }\n };\n\n return (\n <>\n {isInternalLink(href) && (\n <RoutedTabEffects\n id={id as string}\n href={href}\n matchStrategy={matchStrategy}\n />\n )}\n <AriaTab\n id={id}\n className={classes.root}\n ref={el => setTabRef(id as string, el as HTMLDivElement)}\n href={href}\n {...restProps}\n onPress={e => {\n restProps.onPress?.(e);\n handlePress();\n }}\n />\n </>\n );\n};\n\n/**\n * A component that renders the content of a tab.\n *\n * @public\n */\nexport const TabPanel = (props: TabPanelProps) => {\n const { ownProps, restProps } = useDefinition(TabPanelDefinition, props);\n\n return <AriaTabPanel className={ownProps.classes.root} {...restProps} />;\n};\n"],"names":["AriaTabs","AriaTabList","AriaTab","AriaTabPanel"],"mappings":";;;;;;;;;;AAuDA,MAAM,WAAA,GAAc,cAA4C,MAAS,CAAA;AAEzE,MAAM,iBAAiB,MAAM;AAC3B,EAAA,MAAM,OAAA,GAAU,WAAW,WAAW,CAAA;AACtC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,EACvE;AACA,EAAA,OAAO,OAAA;AACT,CAAA;AASA,MAAM,mBAAA,GAAsB,aAAA;AAAA,EAC1B;AACF,CAAA;AAMA,MAAM,YAAA,GAAe,CAAC,IAAA,KAAiB,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA;AAMtE,MAAM,WAAA,GAAc,CAClB,O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ACJ,UAAU,YAAY,CAAA,IACtB,YAAY,SAAA,CAAU,QAAQ,CAAA,IAC9B,MAAA,CAAO,IAAI,CAAA;AACb,MAAA,SAAA,CAAU,YAAA,CAAa,SAAS,IAAA,EAAM;AAAA,QACpC,UAAA,EAAY,EAAE,EAAA,EAAI,MAAA,CAAO,IAAI,CAAA;AAAE,OAChC,CAAA;AAAA,IACH;AAAA,EACF,CAAA;AAEA,EAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,IAAA,cAAA,CAAe,IAAI,CAAA,oBAClB,GAAA;AAAA,MAAC,gBAAA;AAAA,MAAA;AAAA,QACC,EAAA;AAAA,QACA,IAAA;AAAA,QACA;AAAA;AAAA,KACF;AAAA,oBAEF,GAAA;AAAA,MAACC,KAAA;AAAA,MAAA;AAAA,QACC,EAAA;AAAA,QACA,WAAW,OAAA,CAAQ,IAAA;AAAA,QACnB,GAAA,EAAK,CAAA,EAAA,KAAM,SAAA,CAAU,EAAA,EAAc,EAAoB,CAAA;AAAA,QACvD,IAAA;AAAA,QACC,GAAG,SAAA;AAAA,QACJ,SAAS,CAAA,CAAA,KAAK;AACZ,UAAA,SAAA,CAAU,UAAU,CAAC,CAAA;AACrB,UAAA,WAAA,EAAY;AAAA,QACd;AAAA;AAAA;AACF,GAAA,EACF,CAAA;AAEJ;AAOO,MAAM,QAAA,GAAW,CAAC,KAAA,KAAyB;AAChD,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAU,GAAI,aAAA,CAAc,oBAAoB,KAAK,CAAA;AAEvE,EAAA,2BAAQC,UAAA,EAAA,EAAa,SAAA,EAAW,SAAS,OAAA,CAAQ,IAAA,EAAO,GAAG,SAAA,EAAW,CAAA;AACxE;;;;"}
|
|
1
|
+
{"version":3,"file":"Tabs.esm.js","sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useRef,\n useState,\n useMemo,\n Children,\n cloneElement,\n isValidElement,\n createContext,\n useContext,\n useEffect,\n useCallback,\n} from 'react';\nimport type { ReactNode } from 'react';\nimport type {\n TabsProps,\n TabListProps,\n TabPanelProps,\n TabsContextValue,\n TabProps,\n} from './types';\nimport { TabsIndicators } from './TabsIndicators';\nimport {\n Tabs as AriaTabs,\n TabList as AriaTabList,\n Tab as AriaTab,\n TabPanel as AriaTabPanel,\n TabProps as AriaTabProps,\n} from 'react-aria-components';\nimport {\n useDefinition,\n type UseDefinitionResult,\n} from '../../hooks/useDefinition';\nimport {\n TabsDefinition,\n TabListDefinition,\n TabDefinition,\n TabPanelDefinition,\n} from './definition';\nimport { getNodeText } from '../../analytics/getNodeText';\nimport { useRoutingIntegration } from '../../navigation/useRouting';\nimport {\n getReactAriaAnchorProps,\n type AnchorNavigation,\n} from '../../navigation/useNavigation';\n\nconst TabsContext = createContext<TabsContextValue | undefined>(undefined);\n\nconst useTabsContext = () => {\n const context = useContext(TabsContext);\n if (!context) {\n throw new Error('Tab components must be used within a Tabs component');\n }\n return context;\n};\n\ntype TabSelectionContextValue = {\n registerRoutedTab: (id: string) => void;\n unregisterRoutedTab: (id: string) => void;\n registerActiveTab: (id: string, segmentCount: number) => void;\n unregisterActiveTab: (id: string) => void;\n};\n\nconst TabSelectionContext = createContext<TabSelectionContextValue | null>(\n null,\n);\n\n/**\n * Strips query params and hash from a href, leaving only the pathname.\n * Tab matching always compares against location.pathname which never includes them.\n */\nconst hrefPathname = (href: string) => href.split('?')[0].split('#')[0];\n\n/**\n * Utility function to determine if a tab should be active based on the matching strategy.\n * This follows the pattern used in WorkaroundNavLink from the sidebar.\n */\nconst isTabActive = (\n tabHref: string,\n currentPathname: string,\n matchStrategy: 'exact' | 'prefix',\n): boolean => {\n const pathname = hrefPathname(tabHref);\n\n if (matchStrategy === 'exact') {\n return pathname === currentPathname;\n }\n\n // Prefix matching - similar to WorkaroundNavLink behavior\n if (pathname === currentPathname) {\n return true;\n }\n\n // Check if current path starts with tab href followed by a slash\n // This prevents /foo matching /foobar\n return currentPathname.startsWith(`${pathname}/`);\n};\n\n/**\n * A component that renders a list of tabs.\n *\n * @public\n */\nexport const Tabs = (props: TabsProps) => {\n const { ownProps, restProps } = useDefinition(TabsDefinition, props);\n const { classes, children } = ownProps;\n const tabsRef = useRef<HTMLDivElement>(null);\n const tabRefs = useRef<Map<string, HTMLDivElement>>(new Map());\n const [hoveredKey, setHoveredKey] = useState<string | null>(null);\n const prevHoveredKey = useRef<string | null>(null);\n\n // State for tracking routed tabs (tabs with hrefs)\n const [routedTabs, setRoutedTabs] = useState<Set<string>>(() => new Set());\n\n // State for tracking active tabs reported by TabRouteRegistration components\n const [activeTabs, setActiveTabs] = useState<Map<string, number>>(\n () => new Map(),\n );\n\n const setTabRef = (key: string, element: HTMLDivElement | null) => {\n if (element) {\n tabRefs.current.set(key, element);\n } else {\n tabRefs.current.delete(key);\n }\n };\n\n // Compute the selected tab based on active tabs with highest segment count\n const selectedTabId = useMemo(() => {\n // No routed tabs - let React Aria handle selection (uncontrolled mode)\n if (routedTabs.size === 0) {\n return undefined;\n }\n\n // Has routed tabs but none are active - use empty string for no selection\n // (React Aria has a bug with null that causes infinite loops)\n if (activeTabs.size === 0) {\n return '';\n }\n\n let selectedId: string | undefined;\n let maxSegments = -1;\n\n activeTabs.forEach((segmentCount, id) => {\n // Pick tab with highest segment count, first one wins on tie\n if (segmentCount > maxSegments) {\n maxSegments = segmentCount;\n selectedId = id;\n }\n });\n\n return selectedId;\n }, [routedTabs, activeTabs]);\n\n const registerRoutedTab = useCallback((id: string) => {\n setRoutedTabs(prev => new Set(prev).add(id));\n }, []);\n\n const unregisterRoutedTab = useCallback((id: string) => {\n setRoutedTabs(prev => {\n const next = new Set(prev);\n next.delete(id);\n return next;\n });\n }, []);\n\n const registerActiveTab = useCallback((id: string, segmentCount: number) => {\n setActiveTabs(prev => new Map(prev).set(id, segmentCount));\n }, []);\n\n const unregisterActiveTab = useCallback((id: string) => {\n setActiveTabs(prev => {\n const next = new Map(prev);\n next.delete(id);\n return next;\n });\n }, []);\n\n if (!children) return null;\n\n const tabsContextValue: TabsContextValue = {\n tabsRef,\n tabRefs,\n hoveredKey,\n prevHoveredKey,\n setHoveredKey,\n setTabRef,\n };\n\n const selectionContextValue: TabSelectionContextValue = useMemo(\n () => ({\n registerRoutedTab,\n unregisterRoutedTab,\n registerActiveTab,\n unregisterActiveTab,\n }),\n [\n registerRoutedTab,\n unregisterRoutedTab,\n registerActiveTab,\n unregisterActiveTab,\n ],\n );\n\n return (\n <TabsContext.Provider value={tabsContextValue}>\n <TabSelectionContext.Provider value={selectionContextValue}>\n <AriaTabs\n className={classes.root}\n keyboardActivation=\"manual\"\n selectedKey={selectedTabId}\n ref={tabsRef}\n {...restProps}\n >\n {children as ReactNode}\n </AriaTabs>\n </TabSelectionContext.Provider>\n </TabsContext.Provider>\n );\n};\n\n/**\n * A component that renders a list of tabs.\n *\n * @public\n */\nexport const TabList = (props: TabListProps) => {\n const { ownProps, restProps } = useDefinition(TabListDefinition, props);\n const { classes, children } = ownProps;\n const { setHoveredKey, tabRefs, tabsRef, hoveredKey, prevHoveredKey } =\n useTabsContext();\n\n const handleHover = (key: string | null) => {\n setHoveredKey(key);\n };\n\n // Clone children with additional props for hover and ref management\n const enhancedChildren = Children.map(children as ReactNode, child => {\n if (isValidElement(child)) {\n return cloneElement(child, {\n onHoverStart: () => handleHover(child.props.id as string),\n onHoverEnd: () => handleHover(null),\n } as Partial<AriaTabProps>);\n }\n return child;\n });\n\n return (\n <div className={classes.root}>\n <AriaTabList\n className={classes.tabList}\n aria-label=\"Toolbar tabs\"\n {...restProps}\n >\n {enhancedChildren}\n </AriaTabList>\n <TabsIndicators\n tabRefs={tabRefs}\n tabsRef={tabsRef}\n hoveredKey={hoveredKey}\n prevHoveredKey={prevHoveredKey}\n />\n </div>\n );\n};\n\n/**\n * Internal component for tabs with internal hrefs.\n * Handles routing registration and active tab tracking.\n * Separated to avoid conditional hook usage in Tab component.\n * @internal\n */\nfunction RoutedTabEffects({\n id,\n href,\n matchStrategy = 'exact',\n}: {\n id: string;\n href: string;\n matchStrategy?: 'exact' | 'prefix';\n}) {\n const selectionCtx = useContext(TabSelectionContext);\n const routing = useRoutingIntegration({ fallback: true });\n const location = routing.useLocation();\n const resolvedPath = routing.useResolvedPath(href);\n\n // Register as a routed tab (for controlled vs uncontrolled mode)\n useEffect(() => {\n if (selectionCtx) {\n selectionCtx.registerRoutedTab(id);\n return () => selectionCtx.unregisterRoutedTab(id);\n }\n return undefined;\n }, [id, selectionCtx]);\n\n // Register as active tab when URL matches (for tab selection)\n const isActive = isTabActive(\n resolvedPath.pathname,\n location.pathname,\n matchStrategy,\n );\n const segmentCount = resolvedPath.pathname.split('/').filter(Boolean).length;\n\n useEffect(() => {\n if (isActive && selectionCtx) {\n selectionCtx.registerActiveTab(id, segmentCount);\n return () => selectionCtx.unregisterActiveTab(id);\n }\n return undefined;\n }, [isActive, id, segmentCount, selectionCtx]);\n\n return null;\n}\n\ntype TabViewProps = {\n definitionResult: UseDefinitionResult<typeof TabDefinition, TabProps>;\n navigation: AnchorNavigation;\n};\n\nconst TabView = ({ definitionResult, navigation }: TabViewProps) => {\n const { ownProps, restProps, analytics } = definitionResult;\n const { classes, matchStrategy, id } = ownProps;\n const { href } = ownProps;\n const { setTabRef } = useTabsContext();\n const navigationProps = getReactAriaAnchorProps(navigation, {\n href,\n routerOptions: restProps.routerOptions,\n });\n\n const handlePress = () => {\n if (href) {\n const text =\n restProps['aria-label'] ??\n getNodeText(restProps.children) ??\n String(href);\n analytics.captureEvent('click', text, {\n attributes: { to: String(href) },\n });\n }\n };\n\n return (\n <>\n {navigation.canMatchRoute && href && (\n <RoutedTabEffects\n id={id as string}\n href={href}\n matchStrategy={matchStrategy}\n />\n )}\n <AriaTab\n id={id}\n className={classes.root}\n ref={el => setTabRef(id as string, el as HTMLDivElement)}\n {...restProps}\n {...navigationProps}\n onPress={e => {\n restProps.onPress?.(e);\n handlePress();\n }}\n />\n </>\n );\n};\n\n/**\n * A component that renders a tab.\n *\n * @public\n */\nexport const Tab = (props: TabProps) => {\n const definitionResult = useDefinition(TabDefinition, props);\n const Navigation = definitionResult.navigation;\n\n return (\n <Navigation\n props={{\n ...definitionResult.restProps,\n href: definitionResult.ownProps.href,\n }}\n view={TabView}\n viewProps={{ definitionResult }}\n />\n );\n};\n\n/**\n * A component that renders the content of a tab.\n *\n * @public\n */\nexport const TabPanel = (props: TabPanelProps) => {\n const { ownProps, restProps } = useDefinition(TabPanelDefinition, props);\n\n return <AriaTabPanel className={ownProps.classes.root} {...restProps} />;\n};\n"],"names":["AriaTabs","AriaTabList","AriaTab","AriaTabPanel"],"mappings":";;;;;;;;;;AA6DA,MAAM,WAAA,GAAc,cAA4C,MAAS,CAAA;AAEzE,MAAM,iBAAiB,MAAM;AAC3B,EAAA,MAAM,OAAA,GAAU,WAAW,WAAW,CAAA;AACtC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,EACvE;AACA,EAAA,OAAO,OAAA;AACT,CAAA;AASA,MAAM,mBAAA,GAAsB,aAAA;AAAA,EAC1B;AACF,CAAA;AAMA,MAAM,YAAA,GAAe,CAAC,IAAA,KAAiB,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA;AAMtE,MAAM,WAAA,GAAc,CAClB,OAAA,EACA,eAAA,EACA,aAAA,KACY;AACZ,EAAA,MAAM,QAAA,GAAW,aAA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,MAAM,aAAa,gBAAA,CAAiB,UAAA;AAEpC,EAAA,uBACE,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO;AAAA,QACL,GAAG,gBAAA,CAAiB,SAAA;AAAA,QACpB,IAAA,EAAM,iBAAiB,QAAA,CAAS;AAAA,OAClC;AAAA,MACA,IAAA,EAAM,OAAA;AAAA,MACN,SAAA,EAAW,EAAE,gBAAA;AAAiB;AAAA,GAChC;AAEJ;AAOO,MAAM,QAAA,GAAW,CAAC,KAAA,KAAyB;AAChD,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAU,GAAI,aAAA,CAAc,oBAAoB,KAAK,CAAA;AAEvE,EAAA,2BAAQC,UAAA,EAAA,EAAa,SAAA,EAAW,SAAS,OAAA,CAAQ,IAAA,EAAO,GAAG,SAAA,EAAW,CAAA;AACxE;;;;"}
|
|
@@ -3,8 +3,10 @@ import 'clsx';
|
|
|
3
3
|
import '../../hooks/useBreakpoint.esm.js';
|
|
4
4
|
import '../../hooks/useBg.esm.js';
|
|
5
5
|
import '../../hooks/useDefinition/helpers.esm.js';
|
|
6
|
-
import '
|
|
6
|
+
import 'react';
|
|
7
|
+
import '../../provider/BUIContext.esm.js';
|
|
7
8
|
import 'react-router-dom';
|
|
9
|
+
import '@backstage/version-bridge';
|
|
8
10
|
import { defineComponent } from '../../hooks/useDefinition/defineComponent.esm.js';
|
|
9
11
|
import styles from './Tabs.module.css.esm.js';
|
|
10
12
|
|
|
@@ -35,6 +37,7 @@ const TabDefinition = defineComponent()({
|
|
|
35
37
|
root: "bui-Tab"
|
|
36
38
|
},
|
|
37
39
|
analytics: true,
|
|
40
|
+
navigation: { type: "anchor" },
|
|
38
41
|
propDefs: {
|
|
39
42
|
className: {},
|
|
40
43
|
matchStrategy: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/Tabs/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type {\n TabsOwnProps,\n TabListOwnProps,\n TabOwnProps,\n TabPanelOwnProps,\n TabsIndicatorsOwnProps,\n} from './types';\nimport styles from './Tabs.module.css';\n\n/**\n * Component definition for Tabs\n * @public\n */\nexport const TabsDefinition = defineComponent<TabsOwnProps>()({\n styles,\n classNames: {\n root: 'bui-Tabs',\n },\n propDefs: {\n className: {},\n children: {},\n },\n});\n\n/** @internal */\nexport const TabListDefinition = defineComponent<TabListOwnProps>()({\n styles,\n classNames: {\n root: 'bui-TabListWrapper',\n tabList: 'bui-TabList',\n },\n propDefs: {\n className: {},\n children: {},\n },\n});\n\n/** @internal */\nexport const TabDefinition = defineComponent<TabOwnProps>()({\n styles,\n classNames: {\n root: 'bui-Tab',\n },\n analytics: true,\n propDefs: {\n className: {},\n matchStrategy: {},\n href: {},\n id: {},\n noTrack: {},\n },\n});\n\n/** @internal */\nexport const TabPanelDefinition = defineComponent<TabPanelOwnProps>()({\n styles,\n classNames: {\n root: 'bui-TabPanel',\n },\n propDefs: {\n className: {},\n },\n});\n\n/** @internal */\nexport const TabsIndicatorsDefinition =\n defineComponent<TabsIndicatorsOwnProps>()({\n styles,\n classNames: {\n root: 'bui-TabActive',\n hovered: 'bui-TabHovered',\n },\n propDefs: {\n tabRefs: {},\n tabsRef: {},\n hoveredKey: {},\n prevHoveredKey: {},\n },\n });\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/Tabs/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type {\n TabsOwnProps,\n TabListOwnProps,\n TabOwnProps,\n TabPanelOwnProps,\n TabsIndicatorsOwnProps,\n} from './types';\nimport styles from './Tabs.module.css';\n\n/**\n * Component definition for Tabs\n * @public\n */\nexport const TabsDefinition = defineComponent<TabsOwnProps>()({\n styles,\n classNames: {\n root: 'bui-Tabs',\n },\n propDefs: {\n className: {},\n children: {},\n },\n});\n\n/** @internal */\nexport const TabListDefinition = defineComponent<TabListOwnProps>()({\n styles,\n classNames: {\n root: 'bui-TabListWrapper',\n tabList: 'bui-TabList',\n },\n propDefs: {\n className: {},\n children: {},\n },\n});\n\n/** @internal */\nexport const TabDefinition = defineComponent<TabOwnProps>()({\n styles,\n classNames: {\n root: 'bui-Tab',\n },\n analytics: true,\n navigation: { type: 'anchor' },\n propDefs: {\n className: {},\n matchStrategy: {},\n href: {},\n id: {},\n noTrack: {},\n },\n});\n\n/** @internal */\nexport const TabPanelDefinition = defineComponent<TabPanelOwnProps>()({\n styles,\n classNames: {\n root: 'bui-TabPanel',\n },\n propDefs: {\n className: {},\n },\n});\n\n/** @internal */\nexport const TabsIndicatorsDefinition =\n defineComponent<TabsIndicatorsOwnProps>()({\n styles,\n classNames: {\n root: 'bui-TabActive',\n hovered: 'bui-TabHovered',\n },\n propDefs: {\n tabRefs: {},\n tabsRef: {},\n hoveredKey: {},\n prevHoveredKey: {},\n },\n });\n"],"names":[],"mappings":";;;;;;;;;;;;AA8BO,MAAM,cAAA,GAAiB,iBAA8B,CAA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'@remixicon/react';
|
|
|
5
5
|
import { useDefinition } from '../../hooks/useDefinition/useDefinition.esm.js';
|
|
6
6
|
import { TagDefinition, TagGroupDefinition } from './definition.esm.js';
|
|
7
7
|
import { getNodeText } from '../../analytics/getNodeText.esm.js';
|
|
8
|
+
import { BUIRoutingProvider } from '../../navigation/BUIRoutingProvider.esm.js';
|
|
8
9
|
|
|
9
10
|
const TagGroup = (props) => {
|
|
10
11
|
const { ownProps, restProps } = useDefinition(TagGroupDefinition, props);
|
|
11
12
|
const { classes, items, children, renderEmptyState } = ownProps;
|
|
12
|
-
return /* @__PURE__ */ jsx(TagGroup$1, { className: classes.root, ...restProps, children: /* @__PURE__ */ jsx(
|
|
13
|
+
return /* @__PURE__ */ jsx(BUIRoutingProvider, { children: /* @__PURE__ */ jsx(TagGroup$1, { className: classes.root, ...restProps, children: /* @__PURE__ */ jsx(
|
|
13
14
|
TagList,
|
|
14
15
|
{
|
|
15
16
|
className: classes.list,
|
|
@@ -17,20 +18,22 @@ const TagGroup = (props) => {
|
|
|
17
18
|
renderEmptyState,
|
|
18
19
|
children
|
|
19
20
|
}
|
|
20
|
-
) });
|
|
21
|
+
) }) });
|
|
21
22
|
};
|
|
22
23
|
const Tag = forwardRef((props, ref) => {
|
|
23
24
|
const { ownProps, restProps, dataAttributes, analytics } = useDefinition(
|
|
24
25
|
TagDefinition,
|
|
25
26
|
props
|
|
26
27
|
);
|
|
27
|
-
const { classes, children, icon
|
|
28
|
+
const { classes, children, icon } = ownProps;
|
|
29
|
+
const rawHref = restProps.href;
|
|
28
30
|
const textValue = typeof children === "string" ? children : void 0;
|
|
29
|
-
const handlePress = () => {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const handlePress = (e) => {
|
|
32
|
+
restProps.onPress?.(e);
|
|
33
|
+
if (rawHref) {
|
|
34
|
+
const text = restProps["aria-label"] ?? textValue ?? getNodeText(children) ?? String(rawHref);
|
|
32
35
|
analytics.captureEvent("click", text, {
|
|
33
|
-
attributes: { to: String(
|
|
36
|
+
attributes: { to: String(rawHref) }
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
};
|
|
@@ -40,13 +43,9 @@ const Tag = forwardRef((props, ref) => {
|
|
|
40
43
|
ref,
|
|
41
44
|
textValue,
|
|
42
45
|
className: classes.root,
|
|
43
|
-
href,
|
|
44
46
|
...dataAttributes,
|
|
45
47
|
...restProps,
|
|
46
|
-
onPress:
|
|
47
|
-
restProps.onPress?.(e);
|
|
48
|
-
handlePress();
|
|
49
|
-
},
|
|
48
|
+
onPress: handlePress,
|
|
50
49
|
children: ({ allowsRemoving }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
51
50
|
icon && /* @__PURE__ */ jsx("span", { className: classes.icon, children: icon }),
|
|
52
51
|
children,
|
|
@@ -55,6 +54,7 @@ const Tag = forwardRef((props, ref) => {
|
|
|
55
54
|
}
|
|
56
55
|
);
|
|
57
56
|
});
|
|
57
|
+
Tag.displayName = "Tag";
|
|
58
58
|
|
|
59
59
|
export { Tag, TagGroup };
|
|
60
60
|
//# sourceMappingURL=TagGroup.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagGroup.esm.js","sources":["../../../src/components/TagGroup/TagGroup.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TagProps, TagGroupProps } from './types';\nimport {\n TagGroup as ReactAriaTagGroup,\n TagList as ReactAriaTagList,\n Tag as ReactAriaTag,\n Button as ReactAriaButton,\n} from 'react-aria-components';\nimport { forwardRef, type ReactNode } from 'react';\nimport { RiCloseCircleLine } from '@remixicon/react';\nimport { useDefinition } from '../../hooks/useDefinition';\nimport { TagGroupDefinition, TagDefinition } from './definition';\nimport { getNodeText } from '../../analytics/getNodeText';\n\n/**\n * A component that renders a list of tags.\n *\n * @public\n */\nexport const TagGroup = <T extends object>(props: TagGroupProps<T>) => {\n const { ownProps, restProps } = useDefinition(TagGroupDefinition, props);\n const { classes, items, children, renderEmptyState } = ownProps;\n\n return (\n <ReactAriaTagGroup className={classes.root} {...restProps}>\n
|
|
1
|
+
{"version":3,"file":"TagGroup.esm.js","sources":["../../../src/components/TagGroup/TagGroup.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TagProps, TagGroupProps } from './types';\nimport {\n TagGroup as ReactAriaTagGroup,\n TagList as ReactAriaTagList,\n Tag as ReactAriaTag,\n Button as ReactAriaButton,\n} from 'react-aria-components';\nimport { forwardRef, type ReactNode } from 'react';\nimport { RiCloseCircleLine } from '@remixicon/react';\nimport { useDefinition } from '../../hooks/useDefinition';\nimport { TagGroupDefinition, TagDefinition } from './definition';\nimport { getNodeText } from '../../analytics/getNodeText';\nimport { BUIRoutingProvider } from '../../navigation/BUIRoutingProvider';\n\n/**\n * A component that renders a list of tags.\n *\n * @public\n */\nexport const TagGroup = <T extends object>(props: TagGroupProps<T>) => {\n const { ownProps, restProps } = useDefinition(TagGroupDefinition, props);\n const { classes, items, children, renderEmptyState } = ownProps;\n\n return (\n <BUIRoutingProvider>\n <ReactAriaTagGroup className={classes.root} {...restProps}>\n <ReactAriaTagList\n className={classes.list}\n items={items}\n renderEmptyState={renderEmptyState}\n >\n {children}\n </ReactAriaTagList>\n </ReactAriaTagGroup>\n </BUIRoutingProvider>\n );\n};\n\n/**\n * A component that renders a tag.\n *\n * @public\n */\nexport const Tag = forwardRef<HTMLDivElement, TagProps>((props, ref) => {\n const { ownProps, restProps, dataAttributes, analytics } = useDefinition(\n TagDefinition,\n props,\n );\n const { classes, children, icon } = ownProps;\n const rawHref = restProps.href;\n const textValue = typeof children === 'string' ? children : undefined;\n\n const handlePress: typeof restProps.onPress = e => {\n restProps.onPress?.(e);\n if (rawHref) {\n const text =\n (restProps as React.AriaAttributes)['aria-label'] ??\n textValue ??\n getNodeText(children) ??\n String(rawHref);\n analytics.captureEvent('click', text, {\n attributes: { to: String(rawHref) },\n });\n }\n };\n\n return (\n <ReactAriaTag\n ref={ref}\n textValue={textValue}\n className={classes.root}\n {...dataAttributes}\n {...restProps}\n onPress={handlePress}\n >\n {({ allowsRemoving }) => (\n <>\n {icon && <span className={classes.icon}>{icon}</span>}\n {children as ReactNode}\n {allowsRemoving && (\n <ReactAriaButton className={classes.removeButton} slot=\"remove\">\n <RiCloseCircleLine size={16} />\n </ReactAriaButton>\n )}\n </>\n )}\n </ReactAriaTag>\n );\n});\n\nTag.displayName = 'Tag';\n"],"names":["ReactAriaTagGroup","ReactAriaTagList","ReactAriaTag","ReactAriaButton"],"mappings":";;;;;;;;;AAmCO,MAAM,QAAA,GAAW,CAAmB,KAAA,KAA4B;AACrE,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAU,GAAI,aAAA,CAAc,oBAAoB,KAAK,CAAA;AACvE,EAAA,MAAM,EAAE,OAAA,EAAS,KAAA,EAAO,QAAA,EAAU,kBAAiB,GAAI,QAAA;AAEvD,EAAA,uBACE,GAAA,CAAC,sBACC,QAAA,kBAAA,GAAA,CAACA,UAAA,EAAA,EAAkB,WAAW,OAAA,CAAQ,IAAA,EAAO,GAAG,SAAA,EAC9C,QAAA,kBAAA,GAAA;AAAA,IAACC,OA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oBAAQ,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAW,OAAA,CAAQ,MAAO,QAAA,EAAA,IAAA,EAAK,CAAA;AAAA,QAC7C,QAAA;AAAA,QACA,cAAA,oBACC,GAAA,CAACC,MAAA,EAAA,EAAgB,SAAA,EAAW,OAAA,CAAQ,YAAA,EAAc,IAAA,EAAK,QAAA,EACrD,QAAA,kBAAA,GAAA,CAAC,iBAAA,EAAA,EAAkB,IAAA,EAAM,EAAA,EAAI,CAAA,EAC/B;AAAA,OAAA,EAEJ;AAAA;AAAA,GAEJ;AAEJ,CAAC;AAED,GAAA,CAAI,WAAA,GAAc,KAAA;;;;"}
|
|
@@ -3,8 +3,10 @@ import 'clsx';
|
|
|
3
3
|
import '../../hooks/useBreakpoint.esm.js';
|
|
4
4
|
import '../../hooks/useBg.esm.js';
|
|
5
5
|
import '../../hooks/useDefinition/helpers.esm.js';
|
|
6
|
-
import '
|
|
6
|
+
import 'react';
|
|
7
|
+
import '../../provider/BUIContext.esm.js';
|
|
7
8
|
import 'react-router-dom';
|
|
9
|
+
import '@backstage/version-bridge';
|
|
8
10
|
import { defineComponent } from '../../hooks/useDefinition/defineComponent.esm.js';
|
|
9
11
|
import styles from './TagGroup.module.css.esm.js';
|
|
10
12
|
|
|
@@ -33,7 +35,6 @@ const TagDefinition = defineComponent()({
|
|
|
33
35
|
noTrack: {},
|
|
34
36
|
icon: {},
|
|
35
37
|
size: { dataAttribute: true, default: "small" },
|
|
36
|
-
href: {},
|
|
37
38
|
children: {},
|
|
38
39
|
className: {}
|
|
39
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/TagGroup/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { TagGroupOwnProps, TagOwnProps } from './types';\nimport styles from './TagGroup.module.css';\n\n/**\n * Component definition for TagGroup\n * @public\n */\nexport const TagGroupDefinition = defineComponent<TagGroupOwnProps>()({\n styles,\n classNames: {\n root: 'bui-TagGroup',\n list: 'bui-TagList',\n },\n propDefs: {\n items: {},\n children: {},\n renderEmptyState: {},\n className: {},\n },\n});\n\n/** @internal */\nexport const TagDefinition = defineComponent<TagOwnProps>()({\n styles,\n classNames: {\n root: 'bui-Tag',\n icon: 'bui-TagIcon',\n removeButton: 'bui-TagRemoveButton',\n },\n analytics: true,\n propDefs: {\n noTrack: {},\n icon: {},\n size: { dataAttribute: true, default: 'small' },\n
|
|
1
|
+
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/TagGroup/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { TagGroupOwnProps, TagOwnProps } from './types';\nimport styles from './TagGroup.module.css';\n\n/**\n * Component definition for TagGroup\n * @public\n */\nexport const TagGroupDefinition = defineComponent<TagGroupOwnProps>()({\n styles,\n classNames: {\n root: 'bui-TagGroup',\n list: 'bui-TagList',\n },\n propDefs: {\n items: {},\n children: {},\n renderEmptyState: {},\n className: {},\n },\n});\n\n/** @internal */\nexport const TagDefinition = defineComponent<TagOwnProps>()({\n styles,\n classNames: {\n root: 'bui-Tag',\n icon: 'bui-TagIcon',\n removeButton: 'bui-TagRemoveButton',\n },\n analytics: true,\n propDefs: {\n noTrack: {},\n icon: {},\n size: { dataAttribute: true, default: 'small' },\n children: {},\n className: {},\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;;;AAwBO,MAAM,kBAAA,GAAqB,iBAAkC,CAAE;AAAA,EACpE,MAAA;AAAA,EACA,UAAA,EAAY;AAAA,IACV,IAAA,EAAM,cAAA;AAAA,IACN,IAAA,EAAM;AAAA,GACR;AAAA,EACA,QAAA,EAAU;AAAA,IACR,OAAO,EAAC;AAAA,IACR,UAAU,EAAC;AAAA,IACX,kBAAkB,EAAC;AAAA,IACnB,WAAW;AAAC;AAEhB,CAAC;AAGM,MAAM,aAAA,GAAgB,iBAA6B,CAAE;AAAA,EAC1D,MAAA;AAAA,EACA,UAAA,EAAY;AAAA,IACV,IAAA,EAAM,SAAA;AAAA,IACN,IAAA,EAAM,aAAA;AAAA,IACN,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,SAAA,EAAW,IAAA;AAAA,EACX,QAAA,EAAU;AAAA,IACR,SAAS,EAAC;AAAA,IACV,MAAM,EAAC;AAAA,IACP,IAAA,EAAM,EAAE,aAAA,EAAe,IAAA,EAAM,SAAS,OAAA,EAAQ;AAAA,IAC9C,UAAU,EAAC;AAAA,IACX,WAAW;AAAC;AAEhB,CAAC;;;;"}
|
|
@@ -3,8 +3,10 @@ import 'clsx';
|
|
|
3
3
|
import '../../hooks/useBreakpoint.esm.js';
|
|
4
4
|
import '../../hooks/useBg.esm.js';
|
|
5
5
|
import '../../hooks/useDefinition/helpers.esm.js';
|
|
6
|
-
import '
|
|
6
|
+
import 'react';
|
|
7
|
+
import '../../provider/BUIContext.esm.js';
|
|
7
8
|
import 'react-router-dom';
|
|
9
|
+
import '@backstage/version-bridge';
|
|
8
10
|
import { defineComponent } from '../../hooks/useDefinition/defineComponent.esm.js';
|
|
9
11
|
import styles from './Text.module.css.esm.js';
|
|
10
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/Text/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { TextOwnProps } from './types';\nimport styles from './Text.module.css';\n\n/**\n * Component definition for Text\n * @public\n */\nexport const TextDefinition = defineComponent<TextOwnProps>()({\n styles,\n classNames: {\n root: 'bui-Text',\n },\n propDefs: {\n as: { default: 'span' },\n variant: { dataAttribute: true, default: 'body-medium' },\n weight: { dataAttribute: true, default: 'regular' },\n color: { dataAttribute: true, default: 'primary' },\n truncate: { dataAttribute: true },\n className: {},\n },\n});\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/Text/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { TextOwnProps } from './types';\nimport styles from './Text.module.css';\n\n/**\n * Component definition for Text\n * @public\n */\nexport const TextDefinition = defineComponent<TextOwnProps>()({\n styles,\n classNames: {\n root: 'bui-Text',\n },\n propDefs: {\n as: { default: 'span' },\n variant: { dataAttribute: true, default: 'body-medium' },\n weight: { dataAttribute: true, default: 'regular' },\n color: { dataAttribute: true, default: 'primary' },\n truncate: { dataAttribute: true },\n className: {},\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;;;AAwBO,MAAM,cAAA,GAAiB,iBAA8B,CAAE;AAAA,EAC5D,MAAA;AAAA,EACA,UAAA,EAAY;AAAA,IACV,IAAA,EAAM;AAAA,GACR;AAAA,EACA,QAAA,EAAU;AAAA,IACR,EAAA,EAAI,EAAE,OAAA,EAAS,MAAA,EAAO;AAAA,IACtB,OAAA,EAAS,EAAE,aAAA,EAAe,IAAA,EAAM,SAAS,aAAA,EAAc;AAAA,IACvD,MAAA,EAAQ,EAAE,aAAA,EAAe,IAAA,EAAM,SAAS,SAAA,EAAU;AAAA,IAClD,KAAA,EAAO,EAAE,aAAA,EAAe,IAAA,EAAM,SAAS,SAAA,EAAU;AAAA,IACjD,QAAA,EAAU,EAAE,aAAA,EAAe,IAAA,EAAK;AAAA,IAChC,WAAW;AAAC;AAEhB,CAAC;;;;"}
|
|
@@ -3,8 +3,10 @@ import 'clsx';
|
|
|
3
3
|
import '../../hooks/useBreakpoint.esm.js';
|
|
4
4
|
import '../../hooks/useBg.esm.js';
|
|
5
5
|
import '../../hooks/useDefinition/helpers.esm.js';
|
|
6
|
-
import '
|
|
6
|
+
import 'react';
|
|
7
|
+
import '../../provider/BUIContext.esm.js';
|
|
7
8
|
import 'react-router-dom';
|
|
9
|
+
import '@backstage/version-bridge';
|
|
8
10
|
import { defineComponent } from '../../hooks/useDefinition/defineComponent.esm.js';
|
|
9
11
|
import styles from './TextAreaField.module.css.esm.js';
|
|
10
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/TextAreaField/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { TextAreaFieldOwnProps } from './types';\nimport styles from './TextAreaField.module.css';\n\n/**\n * Component definition for TextAreaField\n * @public\n */\nexport const TextAreaFieldDefinition = defineComponent<TextAreaFieldOwnProps>()(\n {\n styles,\n classNames: {\n root: 'bui-TextAreaField',\n textArea: 'bui-TextArea',\n },\n bg: 'consumer',\n propDefs: {\n size: { dataAttribute: true, default: 'small' },\n className: {},\n placeholder: {},\n rows: { default: 3 },\n label: {},\n description: {},\n secondaryLabel: {},\n },\n },\n);\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/TextAreaField/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { TextAreaFieldOwnProps } from './types';\nimport styles from './TextAreaField.module.css';\n\n/**\n * Component definition for TextAreaField\n * @public\n */\nexport const TextAreaFieldDefinition = defineComponent<TextAreaFieldOwnProps>()(\n {\n styles,\n classNames: {\n root: 'bui-TextAreaField',\n textArea: 'bui-TextArea',\n },\n bg: 'consumer',\n propDefs: {\n size: { dataAttribute: true, default: 'small' },\n className: {},\n placeholder: {},\n rows: { default: 3 },\n label: {},\n description: {},\n secondaryLabel: {},\n },\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;;AAwBO,MAAM,0BAA0B,eAAA,EAAuC;AAAA,EAC5E;AAAA,IACE,MAAA;AAAA,IACA,UAAA,EAAY;AAAA,MACV,IAAA,EAAM,mBAAA;AAAA,MACN,QAAA,EAAU;AAAA,KACZ;AAAA,IACA,EAAA,EAAI,UAAA;AAAA,IACJ,QAAA,EAAU;AAAA,MACR,IAAA,EAAM,EAAE,aAAA,EAAe,IAAA,EAAM,SAAS,OAAA,EAAQ;AAAA,MAC9C,WAAW,EAAC;AAAA,MACZ,aAAa,EAAC;AAAA,MACd,IAAA,EAAM,EAAE,OAAA,EAAS,CAAA,EAAE;AAAA,MACnB,OAAO,EAAC;AAAA,MACR,aAAa,EAAC;AAAA,MACd,gBAAgB;AAAC;AACnB;AAEJ;;;;"}
|
|
@@ -3,8 +3,10 @@ import 'clsx';
|
|
|
3
3
|
import '../../hooks/useBreakpoint.esm.js';
|
|
4
4
|
import '../../hooks/useBg.esm.js';
|
|
5
5
|
import '../../hooks/useDefinition/helpers.esm.js';
|
|
6
|
-
import '
|
|
6
|
+
import 'react';
|
|
7
|
+
import '../../provider/BUIContext.esm.js';
|
|
7
8
|
import 'react-router-dom';
|
|
9
|
+
import '@backstage/version-bridge';
|
|
8
10
|
import { defineComponent } from '../../hooks/useDefinition/defineComponent.esm.js';
|
|
9
11
|
import styles from './TextField.module.css.esm.js';
|
|
10
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/TextField/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { TextFieldOwnProps } from './types';\nimport styles from './TextField.module.css';\n\n/**\n * Component definition for TextField\n * @public\n */\nexport const TextFieldDefinition = defineComponent<TextFieldOwnProps>()({\n styles,\n classNames: {\n root: 'bui-TextField',\n inputWrapper: 'bui-InputWrapper',\n input: 'bui-Input',\n inputIcon: 'bui-InputIcon',\n inputAction: 'bui-InputAction',\n },\n bg: 'consumer',\n propDefs: {\n size: { dataAttribute: true, default: 'small' },\n className: {},\n icon: {},\n placeholder: {},\n label: {},\n description: {},\n secondaryLabel: {},\n },\n});\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/TextField/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { TextFieldOwnProps } from './types';\nimport styles from './TextField.module.css';\n\n/**\n * Component definition for TextField\n * @public\n */\nexport const TextFieldDefinition = defineComponent<TextFieldOwnProps>()({\n styles,\n classNames: {\n root: 'bui-TextField',\n inputWrapper: 'bui-InputWrapper',\n input: 'bui-Input',\n inputIcon: 'bui-InputIcon',\n inputAction: 'bui-InputAction',\n },\n bg: 'consumer',\n propDefs: {\n size: { dataAttribute: true, default: 'small' },\n className: {},\n icon: {},\n placeholder: {},\n label: {},\n description: {},\n secondaryLabel: {},\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;;;AAwBO,MAAM,mBAAA,GAAsB,iBAAmC,CAAE;AAAA,EACtE,MAAA;AAAA,EACA,UAAA,EAAY;AAAA,IACV,IAAA,EAAM,eAAA;AAAA,IACN,YAAA,EAAc,kBAAA;AAAA,IACd,KAAA,EAAO,WAAA;AAAA,IACP,SAAA,EAAW,eAAA;AAAA,IACX,WAAA,EAAa;AAAA,GACf;AAAA,EACA,EAAA,EAAI,UAAA;AAAA,EACJ,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,EAAE,aAAA,EAAe,IAAA,EAAM,SAAS,OAAA,EAAQ;AAAA,IAC9C,WAAW,EAAC;AAAA,IACZ,MAAM,EAAC;AAAA,IACP,aAAa,EAAC;AAAA,IACd,OAAO,EAAC;AAAA,IACR,aAAa,EAAC;AAAA,IACd,gBAAgB;AAAC;AAErB,CAAC;;;;"}
|
|
@@ -3,8 +3,10 @@ import 'clsx';
|
|
|
3
3
|
import '../../hooks/useBreakpoint.esm.js';
|
|
4
4
|
import '../../hooks/useBg.esm.js';
|
|
5
5
|
import '../../hooks/useDefinition/helpers.esm.js';
|
|
6
|
-
import '
|
|
6
|
+
import 'react';
|
|
7
|
+
import '../../provider/BUIContext.esm.js';
|
|
7
8
|
import 'react-router-dom';
|
|
9
|
+
import '@backstage/version-bridge';
|
|
8
10
|
import { defineComponent } from '../../hooks/useDefinition/defineComponent.esm.js';
|
|
9
11
|
import styles from './ToggleButton.module.css.esm.js';
|
|
10
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/ToggleButton/definition.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { ToggleButtonOwnProps } from './types';\nimport styles from './ToggleButton.module.css';\n\n/**\n * Component definition for ToggleButton\n * @public\n */\nexport const ToggleButtonDefinition = defineComponent<ToggleButtonOwnProps>()({\n styles,\n classNames: {\n root: 'bui-ToggleButton',\n content: 'bui-ToggleButtonContent',\n },\n propDefs: {\n size: { dataAttribute: true, default: 'small' },\n iconStart: {},\n iconEnd: {},\n children: {},\n className: {},\n },\n});\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/ToggleButton/definition.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { ToggleButtonOwnProps } from './types';\nimport styles from './ToggleButton.module.css';\n\n/**\n * Component definition for ToggleButton\n * @public\n */\nexport const ToggleButtonDefinition = defineComponent<ToggleButtonOwnProps>()({\n styles,\n classNames: {\n root: 'bui-ToggleButton',\n content: 'bui-ToggleButtonContent',\n },\n propDefs: {\n size: { dataAttribute: true, default: 'small' },\n iconStart: {},\n iconEnd: {},\n children: {},\n className: {},\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;;;AAwBO,MAAM,sBAAA,GAAyB,iBAAsC,CAAE;AAAA,EAC5E,MAAA;AAAA,EACA,UAAA,EAAY;AAAA,IACV,IAAA,EAAM,kBAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA,EACA,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,EAAE,aAAA,EAAe,IAAA,EAAM,SAAS,OAAA,EAAQ;AAAA,IAC9C,WAAW,EAAC;AAAA,IACZ,SAAS,EAAC;AAAA,IACV,UAAU,EAAC;AAAA,IACX,WAAW;AAAC;AAEhB,CAAC;;;;"}
|
|
@@ -3,8 +3,10 @@ import 'clsx';
|
|
|
3
3
|
import '../../hooks/useBreakpoint.esm.js';
|
|
4
4
|
import '../../hooks/useBg.esm.js';
|
|
5
5
|
import '../../hooks/useDefinition/helpers.esm.js';
|
|
6
|
-
import '
|
|
6
|
+
import 'react';
|
|
7
|
+
import '../../provider/BUIContext.esm.js';
|
|
7
8
|
import 'react-router-dom';
|
|
9
|
+
import '@backstage/version-bridge';
|
|
8
10
|
import { defineComponent } from '../../hooks/useDefinition/defineComponent.esm.js';
|
|
9
11
|
import styles from './ToggleButtonGroup.module.css.esm.js';
|
|
10
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/ToggleButtonGroup/definition.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { ToggleButtonGroupOwnProps } from './types';\nimport styles from './ToggleButtonGroup.module.css';\n\n/**\n * Component definition for ToggleButtonGroup\n * @public\n */\nexport const ToggleButtonGroupDefinition =\n defineComponent<ToggleButtonGroupOwnProps>()({\n styles,\n classNames: {\n root: 'bui-ToggleButtonGroup',\n },\n propDefs: {\n className: {},\n children: {},\n },\n });\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/ToggleButtonGroup/definition.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { ToggleButtonGroupOwnProps } from './types';\nimport styles from './ToggleButtonGroup.module.css';\n\n/**\n * Component definition for ToggleButtonGroup\n * @public\n */\nexport const ToggleButtonGroupDefinition =\n defineComponent<ToggleButtonGroupOwnProps>()({\n styles,\n classNames: {\n root: 'bui-ToggleButtonGroup',\n },\n propDefs: {\n className: {},\n children: {},\n },\n });\n"],"names":[],"mappings":";;;;;;;;;;;;AAwBO,MAAM,2BAAA,GACX,iBAA2C,CAAE;AAAA,EAC3C,MAAA;AAAA,EACA,UAAA,EAAY;AAAA,IACV,IAAA,EAAM;AAAA,GACR;AAAA,EACA,QAAA,EAAU;AAAA,IACR,WAAW,EAAC;AAAA,IACZ,UAAU;AAAC;AAEf,CAAC;;;;"}
|
|
@@ -3,8 +3,10 @@ import 'clsx';
|
|
|
3
3
|
import '../../hooks/useBreakpoint.esm.js';
|
|
4
4
|
import '../../hooks/useBg.esm.js';
|
|
5
5
|
import '../../hooks/useDefinition/helpers.esm.js';
|
|
6
|
-
import '
|
|
6
|
+
import 'react';
|
|
7
|
+
import '../../provider/BUIContext.esm.js';
|
|
7
8
|
import 'react-router-dom';
|
|
9
|
+
import '@backstage/version-bridge';
|
|
8
10
|
import { defineComponent } from '../../hooks/useDefinition/defineComponent.esm.js';
|
|
9
11
|
import styles from './Tooltip.module.css.esm.js';
|
|
10
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/Tooltip/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { TooltipOwnProps } from './types';\nimport styles from './Tooltip.module.css';\n\n/**\n * Component definition for Tooltip\n * @public\n */\nexport const TooltipDefinition = defineComponent<TooltipOwnProps>()({\n styles,\n classNames: {\n tooltip: 'bui-Tooltip',\n content: 'bui-TooltipContent',\n arrow: 'bui-TooltipArrow',\n },\n propDefs: {\n children: {},\n className: {},\n },\n});\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/Tooltip/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { TooltipOwnProps } from './types';\nimport styles from './Tooltip.module.css';\n\n/**\n * Component definition for Tooltip\n * @public\n */\nexport const TooltipDefinition = defineComponent<TooltipOwnProps>()({\n styles,\n classNames: {\n tooltip: 'bui-Tooltip',\n content: 'bui-TooltipContent',\n arrow: 'bui-TooltipArrow',\n },\n propDefs: {\n children: {},\n className: {},\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;;;AAwBO,MAAM,iBAAA,GAAoB,iBAAiC,CAAE;AAAA,EAClE,MAAA;AAAA,EACA,UAAA,EAAY;AAAA,IACV,OAAA,EAAS,aAAA;AAAA,IACT,OAAA,EAAS,oBAAA;AAAA,IACT,KAAA,EAAO;AAAA,GACT;AAAA,EACA,QAAA,EAAU;AAAA,IACR,UAAU,EAAC;AAAA,IACX,WAAW;AAAC;AAEhB,CAAC;;;;"}
|
|
@@ -3,8 +3,10 @@ import 'clsx';
|
|
|
3
3
|
import '../../hooks/useBreakpoint.esm.js';
|
|
4
4
|
import '../../hooks/useBg.esm.js';
|
|
5
5
|
import '../../hooks/useDefinition/helpers.esm.js';
|
|
6
|
-
import '
|
|
6
|
+
import 'react';
|
|
7
|
+
import '../../provider/BUIContext.esm.js';
|
|
7
8
|
import 'react-router-dom';
|
|
9
|
+
import '@backstage/version-bridge';
|
|
8
10
|
import { defineComponent } from '../../hooks/useDefinition/defineComponent.esm.js';
|
|
9
11
|
import styles from './VisuallyHidden.module.css.esm.js';
|
|
10
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/VisuallyHidden/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { VisuallyHiddenOwnProps } from './types';\nimport styles from './VisuallyHidden.module.css';\n\n/**\n * Component definition for VisuallyHidden\n * @public\n */\nexport const VisuallyHiddenDefinition =\n defineComponent<VisuallyHiddenOwnProps>()({\n styles,\n classNames: {\n root: 'bui-VisuallyHidden',\n },\n propDefs: {\n className: {},\n },\n });\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definition.esm.js","sources":["../../../src/components/VisuallyHidden/definition.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { defineComponent } from '../../hooks/useDefinition';\nimport type { VisuallyHiddenOwnProps } from './types';\nimport styles from './VisuallyHidden.module.css';\n\n/**\n * Component definition for VisuallyHidden\n * @public\n */\nexport const VisuallyHiddenDefinition =\n defineComponent<VisuallyHiddenOwnProps>()({\n styles,\n classNames: {\n root: 'bui-VisuallyHidden',\n },\n propDefs: {\n className: {},\n },\n });\n"],"names":[],"mappings":";;;;;;;;;;;;AAwBO,MAAM,wBAAA,GACX,iBAAwC,CAAE;AAAA,EACxC,MAAA;AAAA,EACA,UAAA,EAAY;AAAA,IACV,IAAA,EAAM;AAAA,GACR;AAAA,EACA,QAAA,EAAU;AAAA,IACR,WAAW;AAAC;AAEhB,CAAC;;;;"}
|
|
@@ -4,25 +4,19 @@ import { useBreakpoint } from '../useBreakpoint.esm.js';
|
|
|
4
4
|
import { useBgProvider, useBgConsumer, BgProvider } from '../useBg.esm.js';
|
|
5
5
|
import { resolveDefinitionProps, processUtilityProps } from './helpers.esm.js';
|
|
6
6
|
import { useAnalytics, noopTracker } from '../../analytics/useAnalytics.esm.js';
|
|
7
|
-
import {
|
|
8
|
-
import { isExternalLink } from '../../utils/linkUtils.esm.js';
|
|
7
|
+
import { useDefinitionNavigation } from './useDefinitionNavigation.esm.js';
|
|
9
8
|
|
|
10
9
|
function useDefinition(definition, props, options) {
|
|
11
10
|
const { breakpoint } = useBreakpoint();
|
|
12
|
-
let hrefResolvedProps = props;
|
|
13
|
-
const hasRouter = useInRouterContext();
|
|
14
|
-
if (hasRouter) {
|
|
15
|
-
const rawHref = props.href;
|
|
16
|
-
const resolved = useResolvedPath(rawHref ?? "");
|
|
17
|
-
if (rawHref !== void 0 && !isExternalLink(rawHref)) {
|
|
18
|
-
hrefResolvedProps = { ...props, href: createPath(resolved) };
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
11
|
const { ownPropsResolved, restProps } = resolveDefinitionProps(
|
|
22
12
|
definition,
|
|
23
|
-
|
|
13
|
+
props,
|
|
24
14
|
breakpoint
|
|
25
15
|
);
|
|
16
|
+
let navigation;
|
|
17
|
+
if (definition.navigation) {
|
|
18
|
+
navigation = useDefinitionNavigation(definition.navigation);
|
|
19
|
+
}
|
|
26
20
|
const dataAttributes = {};
|
|
27
21
|
for (const [key, config] of Object.entries(definition.propDefs)) {
|
|
28
22
|
const finalValue = ownPropsResolved[key];
|
|
@@ -79,7 +73,8 @@ function useDefinition(definition, props, options) {
|
|
|
79
73
|
restProps,
|
|
80
74
|
dataAttributes,
|
|
81
75
|
utilityStyle,
|
|
82
|
-
...definition.analytics ? { analytics } : {}
|
|
76
|
+
...definition.analytics ? { analytics } : {},
|
|
77
|
+
...definition.navigation ? { navigation } : {}
|
|
83
78
|
};
|
|
84
79
|
}
|
|
85
80
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDefinition.esm.js","sources":["../../../src/hooks/useDefinition/useDefinition.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ReactNode } from 'react';\nimport clsx from 'clsx';\nimport { useBreakpoint } from '../useBreakpoint';\nimport { useBgProvider, useBgConsumer, BgProvider } from '../useBg';\nimport { resolveDefinitionProps, processUtilityProps } from './helpers';\nimport { useAnalytics } from '../../analytics/useAnalytics';\nimport { noopTracker } from '../../analytics/useAnalytics';\nimport {
|
|
1
|
+
{"version":3,"file":"useDefinition.esm.js","sources":["../../../src/hooks/useDefinition/useDefinition.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ReactNode } from 'react';\nimport clsx from 'clsx';\nimport { useBreakpoint } from '../useBreakpoint';\nimport { useBgProvider, useBgConsumer, BgProvider } from '../useBg';\nimport { resolveDefinitionProps, processUtilityProps } from './helpers';\nimport { useAnalytics } from '../../analytics/useAnalytics';\nimport { noopTracker } from '../../analytics/useAnalytics';\nimport { useDefinitionNavigation } from './useDefinitionNavigation';\nimport type {\n ComponentConfig,\n UseDefinitionOptions,\n UseDefinitionResult,\n UtilityKeys,\n} from './types';\n\nexport function useDefinition<\n D extends ComponentConfig<any, any>,\n P extends Record<string, any>,\n>(\n definition: D,\n props: P,\n options?: UseDefinitionOptions<D>,\n): UseDefinitionResult<D, P> {\n const { breakpoint } = useBreakpoint();\n\n // Resolve all props centrally — applies responsive values and defaults\n const { ownPropsResolved, restProps } = resolveDefinitionProps(\n definition,\n props,\n breakpoint,\n );\n\n let navigation;\n if (definition.navigation) {\n // Component definitions are module constants, so this hook condition is\n // stable for the lifetime of the component.\n navigation = useDefinitionNavigation(definition.navigation);\n }\n\n const dataAttributes: Record<string, string | undefined> = {};\n\n for (const [key, config] of Object.entries(definition.propDefs)) {\n const finalValue = ownPropsResolved[key];\n\n if (finalValue !== undefined) {\n // Skip data-bg for bg prop when the provider path handles it\n if (key === 'bg' && definition.bg === 'provider') continue;\n\n if ((config as any).dataAttribute) {\n // eslint-disable-next-line no-restricted-syntax\n dataAttributes[`data-${key.toLowerCase()}`] = String(finalValue);\n }\n }\n }\n\n // Provider: resolve bg and provide context for children\n const providerBg = useBgProvider(\n definition.bg === 'provider' ? ownPropsResolved.bg : undefined,\n );\n\n // Consumer: read parent context bg\n const consumerBg = useBgConsumer();\n\n // Provider: set data-bg from the resolved provider bg\n if (definition.bg === 'provider' && providerBg.bg !== undefined) {\n dataAttributes['data-bg'] = String(providerBg.bg);\n }\n\n // Consumer: set data-on-bg from the parent context\n if (definition.bg === 'consumer' && consumerBg.bg !== undefined) {\n dataAttributes['data-on-bg'] = String(consumerBg.bg);\n }\n\n const { utilityClasses, utilityStyle } = processUtilityProps<UtilityKeys<D>>(\n props,\n (definition.utilityProps ?? []) as readonly UtilityKeys<D>[],\n );\n\n // Analytics: conditionally call useAnalytics based on definition flag\n let analytics = noopTracker;\n if (definition.analytics) {\n const tracker = useAnalytics();\n analytics = ownPropsResolved.noTrack ? noopTracker : tracker;\n }\n\n const utilityTarget =\n options?.utilityTarget !== undefined ? options.utilityTarget : 'root';\n const classNameTarget =\n options?.classNameTarget !== undefined ? options.classNameTarget : 'root';\n\n const classes: Record<string, string> = {};\n\n for (const [name, cssKey] of Object.entries(definition.classNames)) {\n classes[name] = clsx(\n cssKey as string,\n definition.styles[cssKey as keyof typeof definition.styles],\n utilityTarget === name && utilityClasses,\n classNameTarget === name && ownPropsResolved.className,\n );\n }\n\n let children: ReactNode | undefined;\n let childrenWithBgProvider: ReactNode | undefined;\n\n if (definition.bg === 'provider') {\n childrenWithBgProvider = providerBg.bg ? (\n <BgProvider bg={providerBg.bg}>{props.children}</BgProvider>\n ) : (\n props.children\n );\n } else {\n children = props.children;\n }\n\n return {\n ownProps: {\n classes,\n ...ownPropsResolved,\n ...(definition.bg === 'provider'\n ? { childrenWithBgProvider }\n : { children }),\n },\n restProps,\n dataAttributes,\n utilityStyle,\n ...(definition.analytics ? { analytics } : {}),\n ...(definition.navigation ? { navigation } : {}),\n } as unknown as UseDefinitionResult<D, P>;\n}\n"],"names":[],"mappings":";;;;;;;;AA+BO,SAAS,aAAA,CAId,UAAA,EACA,KAAA,EACA,OAAA,EAC2B;AAC3B,EAAA,MAAM,EAAE,UAAA,EAAW,GAAI,aAAA,EAAc;AAGrC,EAAA,MAAM,EAAE,gBAAA,EAAkB,SAAA,EAAU,GAAI,sBAAA;AAAA,IACtC,UAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,IAAI,UAAA;AACJ,EAAA,IAAI,WAAW,UAAA,EAAY;AAGzB,IAAA,UAAA,GAAa,uBAAA,CAAwB,WAAW,UAAU,CAAA;AAAA,EAC5D;AAEA,EAAA,MAAM,iBAAqD,EAAC;AAE5D,EAAA,KAAA,MAAW,CAAC,KAAK,MAAM,CAAA,IAAK,OAAO,OAAA,CAAQ,UAAA,CAAW,QAAQ,CAAA,EAAG;AAC/D,IAAA,MAAM,UAAA,GAAa,iBAAiB,GAAG,CAAA;AAEvC,IAAA,IAAI,eAAe,MAAA,EAAW;AAE5B,MAAA,IAAI,GAAA,KAAQ,IAAA,IAAQ,UAAA,CAAW,EAAA,KAAO,UAAA,EAAY;AAElD,MAAA,IAAK,OAAe,aAAA,EAAe;AAEjC,QAAA,cAAA,CAAe,QAAQ,GAAA,CAAI,WAAA,EAAa,CAAA,CAAE,CAAA,GAAI,OAAO,UAAU,CAAA;AAAA,MACjE;AAAA,IACF;AA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AA,CAAW,OAAO,MAAwC,CAAA;AAAA,MAC1D,kBAAkB,IAAA,IAAQ,cAAA;AAAA,MAC1B,eAAA,KAAoB,QAAQ,gBAAA,CAAiB;AAAA,KAC/C;AAAA,EACF;AAEA,EAAA,IAAI,QAAA;AACJ,EAAA,IAAI,sBAAA;AAEJ,EAAA,IAAI,UAAA,CAAW,OAAO,UAAA,EAAY;AAChC,IAAA,sBAAA,GAAyB,UAAA,CAAW,EAAA,mBAClC,GAAA,CAAC,UAAA,EAAA,EAAW,EAAA,EAAI,WAAW,EAAA,EAAK,QAAA,EAAA,KAAA,CAAM,QAAA,EAAS,CAAA,GAE/C,KAAA,CAAM,QAAA;AAAA,EAEV,CAAA,MAAO;AACL,IAAA,QAAA,GAAW,KAAA,CAAM,QAAA;AAAA,EACnB;AAEA,EAAA,OAAO;AAAA,IACL,QAAA,EAAU;AAAA,MACR,OAAA;AAAA,MACA,GAAG,gBAAA;AAAA,MACH,GAAI,WAAW,EAAA,KAAO,UAAA,GAClB,EAAE,sBAAA,EAAuB,GACzB,EAAE,QAAA;AAAS,KACjB;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA,YAAA;AAAA,IACA,GAAI,UAAA,CAAW,SAAA,GAAY,EAAE,SAAA,KAAc,EAAC;AAAA,IAC5C,GAAI,UAAA,CAAW,UAAA,GAAa,EAAE,UAAA,KAAe;AAAC,GAChD;AACF;;;;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useAnchorNavigation } from '../../navigation/useNavigation.esm.js';
|
|
3
|
+
import { useRoutingIntegration } from '../../navigation/useRouting.esm.js';
|
|
4
|
+
|
|
5
|
+
function NavigationView({
|
|
6
|
+
navigation,
|
|
7
|
+
view: View,
|
|
8
|
+
viewProps
|
|
9
|
+
}) {
|
|
10
|
+
const props = { ...viewProps, navigation };
|
|
11
|
+
return /* @__PURE__ */ jsx(View, { ...props });
|
|
12
|
+
}
|
|
13
|
+
function RoutedAnchorNavigation({
|
|
14
|
+
props,
|
|
15
|
+
view,
|
|
16
|
+
viewProps
|
|
17
|
+
}) {
|
|
18
|
+
const navigation = useAnchorNavigation(props);
|
|
19
|
+
return /* @__PURE__ */ jsx(NavigationView, { navigation, view, viewProps });
|
|
20
|
+
}
|
|
21
|
+
function NativeAnchorNavigation({
|
|
22
|
+
props,
|
|
23
|
+
view,
|
|
24
|
+
viewProps
|
|
25
|
+
}) {
|
|
26
|
+
let navigation = {
|
|
27
|
+
type: "none",
|
|
28
|
+
canMatchRoute: false
|
|
29
|
+
};
|
|
30
|
+
if (props.href) {
|
|
31
|
+
navigation = {
|
|
32
|
+
type: "native",
|
|
33
|
+
canMatchRoute: false,
|
|
34
|
+
ariaHref: props.href,
|
|
35
|
+
browserHref: props.href
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return /* @__PURE__ */ jsx(NavigationView, { navigation, view, viewProps });
|
|
39
|
+
}
|
|
40
|
+
function useDefinitionNavigation(_config) {
|
|
41
|
+
const routing = useRoutingIntegration({ fallback: true });
|
|
42
|
+
const inRouterContext = routing.useInRouterContext();
|
|
43
|
+
if (inRouterContext) {
|
|
44
|
+
return RoutedAnchorNavigation;
|
|
45
|
+
}
|
|
46
|
+
return NativeAnchorNavigation;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { useDefinitionNavigation };
|
|
50
|
+
//# sourceMappingURL=useDefinitionNavigation.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDefinitionNavigation.esm.js","sources":["../../../src/hooks/useDefinition/useDefinitionNavigation.tsx"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ComponentType, ReactElement } from 'react';\nimport {\n useAnchorNavigation,\n type AnchorNavigation,\n type NavigationProps,\n} from '../../navigation/useNavigation';\nimport { useRoutingIntegration } from '../../navigation/useRouting';\nimport type {\n DefinitionNavigationComponent,\n DefinitionNavigationConfig,\n} from './types';\n\ntype NavigationResolverProps<N, P extends object> = {\n props: NavigationProps;\n view: ComponentType<P & { navigation: N }>;\n viewProps: P;\n};\n\ntype AnchorNavigationProps<P extends object> = NavigationResolverProps<\n AnchorNavigation,\n P\n>;\n\nfunction NavigationView<N, P extends object>({\n navigation,\n view: View,\n viewProps,\n}: Omit<NavigationResolverProps<N, P>, 'props'> & {\n navigation: N;\n}): ReactElement {\n const props = { ...viewProps, navigation } as P & { navigation: N };\n return <View {...props} />;\n}\n\nfunction RoutedAnchorNavigation<P extends object>({\n props,\n view,\n viewProps,\n}: AnchorNavigationProps<P>): ReactElement {\n const navigation = useAnchorNavigation(props);\n return (\n <NavigationView navigation={navigation} view={view} viewProps={viewProps} />\n );\n}\n\nfunction NativeAnchorNavigation<P extends object>({\n props,\n view,\n viewProps,\n}: AnchorNavigationProps<P>): ReactElement {\n let navigation: AnchorNavigation = {\n type: 'none',\n canMatchRoute: false,\n };\n if (props.href) {\n navigation = {\n type: 'native',\n canMatchRoute: false,\n ariaHref: props.href,\n browserHref: props.href,\n };\n }\n\n return (\n <NavigationView navigation={navigation} view={view} viewProps={viewProps} />\n );\n}\n\n/**\n * Selects a resolver component so router-specific hooks only mount when a\n * React Router context is available. The resolver injects the normalized\n * navigation into the component view as an ordinary React prop.\n */\nexport function useDefinitionNavigation(\n _config: DefinitionNavigationConfig,\n): DefinitionNavigationComponent {\n const routing = useRoutingIntegration({ fallback: true });\n const inRouterContext = routing.useInRouterContext();\n\n if (inRouterContext) {\n return RoutedAnchorNavigation;\n }\n return NativeAnchorNavigation;\n}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