@backstage/ui 0.18.0-next.2 → 0.18.0
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 +36 -0
- package/dist/components/Avatar/Avatar.esm.js +1 -1
- package/dist/components/Avatar/Avatar.esm.js.map +1 -1
- package/dist/components/Combobox/Combobox.esm.js +2 -0
- package/dist/components/Combobox/Combobox.esm.js.map +1 -1
- package/dist/components/Header/HeaderMetadataStatus.esm.js.map +1 -1
- package/dist/components/PluginHeader/PluginHeader.esm.js +6 -2
- package/dist/components/PluginHeader/PluginHeader.esm.js.map +1 -1
- package/dist/components/Table/hooks/getEffectivePageSize.esm.js +1 -1
- package/dist/components/Table/hooks/getEffectivePageSize.esm.js.map +1 -1
- package/dist/components/TablePagination/TablePagination.esm.js +5 -2
- package/dist/components/TablePagination/TablePagination.esm.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @backstage/ui
|
|
2
2
|
|
|
3
|
+
## 0.18.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d07e99e: Updated BUI links to use the hosting application's client-side router, including relative destinations and the application's configured router base path, while preserving native browser navigation where required.
|
|
8
|
+
|
|
9
|
+
**BREAKING**: Anchor-based components no longer accept the React Aria `render` prop. BUI now owns the underlying anchor so routing behavior remains consistent across application and plugin package versions.
|
|
10
|
+
|
|
11
|
+
ListRow, Tag, and table Row now retain client-side navigation when application and plugin packages load separate React Aria copies. Their existing modifier-key, target, download, and link-metadata behavior is unchanged.
|
|
12
|
+
|
|
13
|
+
**Migration:**
|
|
14
|
+
|
|
15
|
+
Remove `render` props from ButtonLink, ComboboxItem, Link, MenuItem, MenuListBoxItem, SearchAutocompleteItem, SelectItem, and Tab. BUI now selects and renders the appropriate anchor or router link automatically.
|
|
16
|
+
|
|
17
|
+
**Affected components:** ButtonLink, Card, ComboboxItem, Header, Link, ListRow, MenuItem, MenuListBoxItem, Row, SearchAutocompleteItem, SelectItem, Tab, Tag
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 736d84e: Use locale-insensitive Unicode casing for consistent string handling across environments.
|
|
22
|
+
|
|
23
|
+
**Affected components:** Avatar
|
|
24
|
+
|
|
25
|
+
- f914343: Prevent BUI styles from overriding document and native control line heights while preserving BUI component typography.
|
|
26
|
+
- 947c612: Fixed `TablePagination` page-size controls to stay synchronized with controlled values and handle empty option lists without crashing.
|
|
27
|
+
|
|
28
|
+
**Affected components:** `TablePagination`
|
|
29
|
+
|
|
30
|
+
- c435198: Fixed an issue where using `PluginHeader` with `FullPage` caused the page to be unexpectedly scrollable. The `--bui-header-height` CSS variable now correctly accounts for the header's `margin-bottom`, preventing the layout from overflowing the viewport.
|
|
31
|
+
- c0b26db: Open `Combobox` suggestions when the input receives focus by default.
|
|
32
|
+
|
|
33
|
+
**Affected components:** Combobox
|
|
34
|
+
|
|
35
|
+
- 0dd80f7: Fixed pagination state handling in `useTable`, including initial offsets, shrinking complete datasets, controlled loading transitions, valid zero and empty cursors, cached error recovery, immediately resolving reloads, and unnecessary reloads when controlled callback identities change.
|
|
36
|
+
|
|
37
|
+
**Affected components:** `useTable`
|
|
38
|
+
|
|
3
39
|
## 0.18.0-next.2
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
|
@@ -22,7 +22,7 @@ const Avatar = forwardRef((props, ref) => {
|
|
|
22
22
|
};
|
|
23
23
|
}, [src]);
|
|
24
24
|
const initialsCount = ["x-small", "small"].includes(size) ? 1 : 2;
|
|
25
|
-
const initials = name.split(" ").map((word) => word[0]).join("").
|
|
25
|
+
const initials = name.split(" ").map((word) => word[0]).join("").toUpperCase().slice(0, initialsCount);
|
|
26
26
|
return /* @__PURE__ */ jsx(
|
|
27
27
|
"div",
|
|
28
28
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.esm.js","sources":["../../../src/components/Avatar/Avatar.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 { forwardRef, useState, useEffect } from 'react';\nimport { AvatarProps } from './types';\nimport { useDefinition } from '../../hooks/useDefinition';\nimport { AvatarDefinition } from './definition';\n\n/**\n * Displays a user's profile image with an automatic fallback to their initials when the image fails to load.\n *\n * @public\n */\nexport const Avatar = forwardRef<HTMLDivElement, AvatarProps>((props, ref) => {\n const { ownProps, restProps, dataAttributes } = useDefinition(\n AvatarDefinition,\n props,\n );\n\n const { classes, size, src, name, purpose } = ownProps;\n\n const [imageStatus, setImageStatus] = useState<\n 'loading' | 'loaded' | 'error'\n >('loading');\n\n useEffect(() => {\n setImageStatus('loading');\n const img = new Image();\n img.onload = () => setImageStatus('loaded');\n img.onerror = () => setImageStatus('error');\n img.src = src;\n\n return () => {\n img.onload = null;\n img.onerror = null;\n };\n }, [src]);\n\n const initialsCount = ['x-small', 'small'].includes(size) ? 1 : 2;\n\n const initials = name\n .split(' ')\n .map(word => word[0])\n .join('')\n .
|
|
1
|
+
{"version":3,"file":"Avatar.esm.js","sources":["../../../src/components/Avatar/Avatar.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 { forwardRef, useState, useEffect } from 'react';\nimport { AvatarProps } from './types';\nimport { useDefinition } from '../../hooks/useDefinition';\nimport { AvatarDefinition } from './definition';\n\n/**\n * Displays a user's profile image with an automatic fallback to their initials when the image fails to load.\n *\n * @public\n */\nexport const Avatar = forwardRef<HTMLDivElement, AvatarProps>((props, ref) => {\n const { ownProps, restProps, dataAttributes } = useDefinition(\n AvatarDefinition,\n props,\n );\n\n const { classes, size, src, name, purpose } = ownProps;\n\n const [imageStatus, setImageStatus] = useState<\n 'loading' | 'loaded' | 'error'\n >('loading');\n\n useEffect(() => {\n setImageStatus('loading');\n const img = new Image();\n img.onload = () => setImageStatus('loaded');\n img.onerror = () => setImageStatus('error');\n img.src = src;\n\n return () => {\n img.onload = null;\n img.onerror = null;\n };\n }, [src]);\n\n const initialsCount = ['x-small', 'small'].includes(size) ? 1 : 2;\n\n const initials = name\n .split(' ')\n .map(word => word[0])\n .join('')\n .toUpperCase()\n .slice(0, initialsCount);\n\n return (\n <div\n ref={ref}\n role=\"img\"\n aria-label={purpose === 'informative' ? name : undefined}\n aria-hidden={purpose === 'decoration' ? true : undefined}\n className={classes.root}\n {...dataAttributes}\n {...restProps}\n >\n {imageStatus === 'loaded' ? (\n <img src={src} alt=\"\" className={classes.image} />\n ) : (\n <div aria-hidden=\"true\" className={classes.fallback}>\n {initials}\n </div>\n )}\n </div>\n );\n});\n\nAvatar.displayName = 'Avatar';\n"],"names":[],"mappings":";;;;;AA0BO,MAAM,MAAA,GAAS,UAAA,CAAwC,CAAC,KAAA,EAAO,GAAA,KAAQ;AAC5E,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAW,cAAA,EAAe,GAAI,aAAA;AAAA,IAC9C,gBAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,MAAM,EAAE,OAAA,EAAS,IAAA,EAAM,GAAA,EAAK,IAAA,EAAM,SAAQ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,IAAG,SAAA,EAAW,OAAA,CAAQ,KAAA,EAAO,CAAA,uBAE/C,KAAA,EAAA,EAAI,aAAA,EAAY,QAAO,SAAA,EAAW,OAAA,CAAQ,UACxC,QAAA,EAAA,QAAA,EACH;AAAA;AAAA,GAEJ;AAEJ,CAAC;AAED,MAAA,CAAO,WAAA,GAAc,QAAA;;;;"}
|
|
@@ -98,6 +98,7 @@ function ComboboxImpl(props, ref) {
|
|
|
98
98
|
inputValue,
|
|
99
99
|
defaultInputValue,
|
|
100
100
|
onInputChange,
|
|
101
|
+
menuTrigger = "focus",
|
|
101
102
|
...ariaProps
|
|
102
103
|
} = restProps;
|
|
103
104
|
const asyncComboboxProps = isDirectAsyncServer ? {
|
|
@@ -133,6 +134,7 @@ function ComboboxImpl(props, ref) {
|
|
|
133
134
|
ref,
|
|
134
135
|
...ariaProps,
|
|
135
136
|
...comboboxStateProps,
|
|
137
|
+
menuTrigger,
|
|
136
138
|
allowsEmptyCollection: true,
|
|
137
139
|
children: [
|
|
138
140
|
/* @__PURE__ */ jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.esm.js","sources":["../../../src/components/Combobox/Combobox.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 { forwardRef, useEffect } from 'react';\nimport { ComboBox as AriaComboBox } from 'react-aria-components';\nimport { useFilter } from 'react-aria';\nimport type {\n ComboboxAsyncItemsProps,\n ComboboxAsyncOptionsProps,\n ComboboxItemsProps,\n ComboboxListBoxOwnProps,\n ComboboxOptionsProps,\n ComboboxProps,\n ComboboxServerItem,\n ComboboxServerItemsProps,\n ComboboxServerOptionsProps,\n ComboboxStaticProps,\n} from './types';\nimport type { Key } from 'react-aria-components';\nimport type {\n AsyncListSource,\n CollectionItem,\n NormalizedOption,\n} from '../../types/selectableCollection';\nimport { useDefinition } from '../../hooks/useDefinition';\nimport { ComboboxDefinition } from './definition';\nimport { Popover } from '../Popover';\nimport { FieldLabel } from '../FieldLabel';\nimport { FieldError } from '../FieldError';\nimport { ComboboxInput } from './ComboboxInput';\nimport { ComboboxListBox } from './ComboboxListBox';\nimport {\n useCollectionAdapter,\n type CollectionAdapterResult,\n} from '../../hooks/useCollectionAdapter';\nimport {\n isAsyncListSource,\n resolveCollectionSource,\n} from '../../utils/selectableCollection';\nimport {\n getAsyncComboboxItemTextValue,\n useAsyncComboboxState,\n} from './useAsyncComboboxState';\n\ntype ComboboxRuntimeStateProps<T extends CollectionItem> = {\n value?: Key | T | null;\n defaultValue?: Key | T | null;\n onChange?: ((value: Key | null) => void) | ((value: T | null) => void);\n inputValue?: string;\n defaultInputValue?: string;\n onInputChange?: (value: string) => void;\n};\n\ntype ComboboxAriaStateProps = {\n value?: Key | null;\n defaultValue?: Key | null;\n onChange?: (value: Key | null) => void;\n inputValue?: string;\n defaultInputValue?: string;\n onInputChange?: (value: string) => void;\n};\n\ntype AsyncComboboxState = {\n value: Key | null;\n inputValue: string;\n onChange: (value: Key | null) => void;\n onInputChange: (value: string) => void;\n};\n\nfunction resolveComboboxStateProps<T extends CollectionItem>({\n runtimeState,\n asyncState,\n collection,\n hasSearch,\n}: {\n runtimeState: ComboboxRuntimeStateProps<T>;\n asyncState?: AsyncComboboxState;\n collection: CollectionAdapterResult<T>;\n hasSearch: boolean;\n}): ComboboxAriaStateProps {\n if (asyncState) {\n return asyncState;\n }\n\n const selectionProps = {\n value: runtimeState.value as Key | null | undefined,\n defaultValue: runtimeState.defaultValue as Key | null | undefined,\n onChange: runtimeState.onChange as\n | ((value: Key | null) => void)\n | undefined,\n };\n\n if (hasSearch) {\n return {\n ...selectionProps,\n inputValue: collection.inputValue,\n defaultInputValue: collection.defaultInputValue,\n onInputChange: collection.onInputChange,\n };\n }\n\n return {\n ...selectionProps,\n inputValue: runtimeState.inputValue,\n defaultInputValue: runtimeState.defaultInputValue,\n onInputChange: runtimeState.onInputChange,\n };\n}\n\n/**\n * A text input combined with a dropdown list of options. The user can type to filter\n * suggestions, navigate with the keyboard, and pick a value. With\n * `allowsCustomValue`, unmatched typed text can remain in the input without\n * selecting an option.\n *\n * @public\n */\nfunction ComboboxImpl<T extends CollectionItem = NormalizedOption>(\n props: ComboboxProps<T>,\n ref: React.ForwardedRef<HTMLDivElement>,\n) {\n const { contains } = useFilter({ sensitivity: 'base' });\n const { ownProps, restProps, dataAttributes } = useDefinition(\n ComboboxDefinition,\n props,\n );\n const {\n classes,\n label,\n description,\n options,\n items,\n children,\n dependencies,\n icon,\n placeholder,\n isRequired,\n secondaryLabel,\n search,\n loading,\n } = ownProps;\n\n const ariaLabel = restProps['aria-label'];\n const ariaLabelledBy = restProps['aria-labelledby'];\n\n useEffect(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n 'Combobox requires either a visible label, aria-label, or aria-labelledby for accessibility',\n );\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n const secondaryLabelText = secondaryLabel || (isRequired ? 'Required' : null);\n const collectionSource = resolveCollectionSource<T>({\n options,\n items: items as Iterable<T> | AsyncListSource<T> | undefined,\n });\n const collection = useCollectionAdapter({\n items: collectionSource.source,\n search,\n loading,\n retainSelectedItems: false,\n });\n const renderedItems = collectionSource.rendersItems\n ? collection.canonicalItems\n : undefined;\n const rootItems =\n renderedItems ??\n (collectionSource.options !== undefined && search !== undefined\n ? collection.canonicalItems\n : undefined);\n const searchProps = typeof search === 'object' ? search : undefined;\n const isDirectAsyncServer =\n searchProps?.mode === 'server' &&\n isAsyncListSource(collectionSource.source);\n const shouldDisableRootFilter =\n searchProps?.mode === 'server' || searchProps?.filter !== undefined;\n const {\n value,\n defaultValue,\n onChange,\n inputValue,\n defaultInputValue,\n onInputChange,\n ...ariaProps\n } = restProps as typeof restProps & ComboboxRuntimeStateProps<T>;\n const asyncComboboxProps = isDirectAsyncServer\n ? {\n source: collectionSource.source as AsyncListSource<T>,\n value: value as T | null | undefined,\n defaultValue: defaultValue as T | null | undefined,\n onChange: onChange as ((value: T | null) => void) | undefined,\n allowsCustomValue: restProps.allowsCustomValue,\n }\n : undefined;\n const asyncComboboxState = useAsyncComboboxState(asyncComboboxProps);\n const comboboxStateProps = resolveComboboxStateProps({\n runtimeState: {\n value,\n defaultValue,\n onChange,\n inputValue,\n defaultInputValue,\n onInputChange,\n },\n asyncState: asyncComboboxState,\n collection,\n hasSearch: search !== undefined,\n });\n const defaultFilter = shouldDisableRootFilter ? () => true : contains;\n const getItemTextValue =\n isDirectAsyncServer && items !== undefined\n ? getAsyncComboboxItemTextValue\n : undefined;\n\n return (\n <AriaComboBox<T>\n className={classes.root}\n defaultFilter={defaultFilter}\n items={rootItems}\n {...dataAttributes}\n ref={ref}\n {...ariaProps}\n {...comboboxStateProps}\n allowsEmptyCollection\n >\n <FieldLabel\n label={label}\n secondaryLabel={secondaryLabelText}\n description={description}\n descriptionSlot=\"description\"\n />\n <ComboboxInput icon={icon} placeholder={placeholder} />\n <FieldError />\n <Popover className={classes.popover} hideArrow {...dataAttributes}>\n <ComboboxListBox\n options={collectionSource.options}\n items={renderedItems}\n dependencies={dependencies}\n search={search as never}\n loading={collection.loading}\n isStale={collection.isStale}\n getItemTextValue={getItemTextValue}\n >\n {children as ComboboxListBoxOwnProps<T>['children']}\n </ComboboxListBox>\n </Popover>\n </AriaComboBox>\n );\n}\n\n/** @public */\nexport const Combobox = forwardRef(ComboboxImpl) as unknown as {\n (\n props: ComboboxOptionsProps & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n (\n props: ComboboxAsyncOptionsProps & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n <T extends { id: Key }>(\n props: ComboboxItemsProps<T> & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n <T extends { id: Key }>(\n props: ComboboxAsyncItemsProps<T> & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n (\n props: ComboboxStaticProps & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n (\n props: ComboboxServerOptionsProps & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n <T extends ComboboxServerItem>(\n props: ComboboxServerItemsProps<T> & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n displayName?: string;\n};\n\nCombobox.displayName = 'Combobox';\n"],"names":["AriaComboBox"],"mappings":";;;;;;;;;;;;;;;;;;AAkFA,SAAS,yBAAA,CAAoD;AAAA,EAC3D,YAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA,EAK2B;AACzB,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,OAAO,UAAA;AAAA,EACT;AAEA,EAAA,MAAM,cAAA,GAAiB;AAAA,IACrB,OAAO,YAAA,CAAa,KAAA;AAAA,IACpB,cAAc,YAAA,CAAa,YAAA;AAAA,IAC3B,UAAU,YAAA,CAAa;AAAA,GAGzB;AAEA,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,OAAO;AAAA,MACL,GAAG,cAAA;AAAA,MACH,YAAY,UAAA,CAAW,UAAA;AAAA,MACvB,mBAAmB,UAAA,CAAW,iBAAA;AAAA,MAC9B,eAAe,UAAA,CAAW;AAAA,KAC5B;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,cAAA;AAAA,IACH,YAAY,YAAA,CAAa,UAAA;AAAA,IACzB,mBAAmB,YAAA,CAAa,iBAAA;AAAA,IAChC,eAAe,YAAA,CAAa;AAAA,GAC9B;AACF;AAUA,SAAS,YAAA,CACP,OACA,GAAA,EACA;AACA,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,UAAU,EAAE,WAAA,EAAa,QAAQ,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,EAAO,SAAA;AAAA,MACN,GAAG,cAAA;AAAA,MACJ,GAAA;AAAA,MACC,GAAG,SAAA;AAAA,MACH,GAAG,kBAAA;AAAA,MACJ,qBAAA,EAAqB,IAAA;AAAA,MAErB,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,UAAA;AAAA,UAAA;AAAA,YACC,KAAA;AAAA,YACA,cAAA,EAAgB,kBAAA;AAAA,YAChB,WAAA;AAAA,YACA,eAAA,EAAgB;AAAA;AAAA,SAClB;AAAA,wBACA,GAAA,CAAC,aAAA,EAAA,EAAc,IAAA,EAAY,WAAA,EAA0B,CAAA;AAAA,4BACpD,UAAA,EAAA,EAAW,CAAA;AAAA,wBACZ,GAAA,CAAC,WAAQ,SAAA,EAAW,OAAA,CAAQ,SAAS,SAAA,EAAS,IAAA,EAAE,GAAG,cAAA,EACjD,QAAA,kBAAA,GAAA;AAAA,UAAC,eAAA;AAAA,UAAA;AAAA,YACC,SAAS,gBAAA,CAAiB,OAAA;AAAA,YAC1B,KAAA,EAAO,aAAA;AAAA,YACP,YAAA;AAAA,YACA,MAAA;AAAA,YACA,SAAS,UAAA,CAAW,OAAA;AAAA,YACpB,SAAS,UAAA,CAAW,OAAA;AAAA,YACpB,gBAAA;AAAA,YAEC;AAAA;AAAA,SACH,EACF;AAAA;AAAA;AAAA,GACF;AAEJ;AAGO,MAAM,QAAA,GAAW,WAAW,YAAY;AAyB/C,QAAA,CAAS,WAAA,GAAc,UAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"Combobox.esm.js","sources":["../../../src/components/Combobox/Combobox.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 { forwardRef, useEffect } from 'react';\nimport { ComboBox as AriaComboBox } from 'react-aria-components';\nimport { useFilter } from 'react-aria';\nimport type {\n ComboboxAsyncItemsProps,\n ComboboxAsyncOptionsProps,\n ComboboxItemsProps,\n ComboboxListBoxOwnProps,\n ComboboxOptionsProps,\n ComboboxProps,\n ComboboxServerItem,\n ComboboxServerItemsProps,\n ComboboxServerOptionsProps,\n ComboboxStaticProps,\n} from './types';\nimport type { Key } from 'react-aria-components';\nimport type {\n AsyncListSource,\n CollectionItem,\n NormalizedOption,\n} from '../../types/selectableCollection';\nimport { useDefinition } from '../../hooks/useDefinition';\nimport { ComboboxDefinition } from './definition';\nimport { Popover } from '../Popover';\nimport { FieldLabel } from '../FieldLabel';\nimport { FieldError } from '../FieldError';\nimport { ComboboxInput } from './ComboboxInput';\nimport { ComboboxListBox } from './ComboboxListBox';\nimport {\n useCollectionAdapter,\n type CollectionAdapterResult,\n} from '../../hooks/useCollectionAdapter';\nimport {\n isAsyncListSource,\n resolveCollectionSource,\n} from '../../utils/selectableCollection';\nimport {\n getAsyncComboboxItemTextValue,\n useAsyncComboboxState,\n} from './useAsyncComboboxState';\n\ntype ComboboxRuntimeStateProps<T extends CollectionItem> = {\n value?: Key | T | null;\n defaultValue?: Key | T | null;\n onChange?: ((value: Key | null) => void) | ((value: T | null) => void);\n inputValue?: string;\n defaultInputValue?: string;\n onInputChange?: (value: string) => void;\n};\n\ntype ComboboxAriaStateProps = {\n value?: Key | null;\n defaultValue?: Key | null;\n onChange?: (value: Key | null) => void;\n inputValue?: string;\n defaultInputValue?: string;\n onInputChange?: (value: string) => void;\n};\n\ntype AsyncComboboxState = {\n value: Key | null;\n inputValue: string;\n onChange: (value: Key | null) => void;\n onInputChange: (value: string) => void;\n};\n\nfunction resolveComboboxStateProps<T extends CollectionItem>({\n runtimeState,\n asyncState,\n collection,\n hasSearch,\n}: {\n runtimeState: ComboboxRuntimeStateProps<T>;\n asyncState?: AsyncComboboxState;\n collection: CollectionAdapterResult<T>;\n hasSearch: boolean;\n}): ComboboxAriaStateProps {\n if (asyncState) {\n return asyncState;\n }\n\n const selectionProps = {\n value: runtimeState.value as Key | null | undefined,\n defaultValue: runtimeState.defaultValue as Key | null | undefined,\n onChange: runtimeState.onChange as\n | ((value: Key | null) => void)\n | undefined,\n };\n\n if (hasSearch) {\n return {\n ...selectionProps,\n inputValue: collection.inputValue,\n defaultInputValue: collection.defaultInputValue,\n onInputChange: collection.onInputChange,\n };\n }\n\n return {\n ...selectionProps,\n inputValue: runtimeState.inputValue,\n defaultInputValue: runtimeState.defaultInputValue,\n onInputChange: runtimeState.onInputChange,\n };\n}\n\n/**\n * A text input combined with a dropdown list of options. The user can type to filter\n * suggestions, navigate with the keyboard, and pick a value. With\n * `allowsCustomValue`, unmatched typed text can remain in the input without\n * selecting an option. The suggestions open when the input receives focus by\n * default. Use `menuTrigger` to customize this behavior.\n *\n * @public\n */\nfunction ComboboxImpl<T extends CollectionItem = NormalizedOption>(\n props: ComboboxProps<T>,\n ref: React.ForwardedRef<HTMLDivElement>,\n) {\n const { contains } = useFilter({ sensitivity: 'base' });\n const { ownProps, restProps, dataAttributes } = useDefinition(\n ComboboxDefinition,\n props,\n );\n const {\n classes,\n label,\n description,\n options,\n items,\n children,\n dependencies,\n icon,\n placeholder,\n isRequired,\n secondaryLabel,\n search,\n loading,\n } = ownProps;\n\n const ariaLabel = restProps['aria-label'];\n const ariaLabelledBy = restProps['aria-labelledby'];\n\n useEffect(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n 'Combobox requires either a visible label, aria-label, or aria-labelledby for accessibility',\n );\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n const secondaryLabelText = secondaryLabel || (isRequired ? 'Required' : null);\n const collectionSource = resolveCollectionSource<T>({\n options,\n items: items as Iterable<T> | AsyncListSource<T> | undefined,\n });\n const collection = useCollectionAdapter({\n items: collectionSource.source,\n search,\n loading,\n retainSelectedItems: false,\n });\n const renderedItems = collectionSource.rendersItems\n ? collection.canonicalItems\n : undefined;\n const rootItems =\n renderedItems ??\n (collectionSource.options !== undefined && search !== undefined\n ? collection.canonicalItems\n : undefined);\n const searchProps = typeof search === 'object' ? search : undefined;\n const isDirectAsyncServer =\n searchProps?.mode === 'server' &&\n isAsyncListSource(collectionSource.source);\n const shouldDisableRootFilter =\n searchProps?.mode === 'server' || searchProps?.filter !== undefined;\n const {\n value,\n defaultValue,\n onChange,\n inputValue,\n defaultInputValue,\n onInputChange,\n menuTrigger = 'focus',\n ...ariaProps\n } = restProps as typeof restProps & ComboboxRuntimeStateProps<T>;\n const asyncComboboxProps = isDirectAsyncServer\n ? {\n source: collectionSource.source as AsyncListSource<T>,\n value: value as T | null | undefined,\n defaultValue: defaultValue as T | null | undefined,\n onChange: onChange as ((value: T | null) => void) | undefined,\n allowsCustomValue: restProps.allowsCustomValue,\n }\n : undefined;\n const asyncComboboxState = useAsyncComboboxState(asyncComboboxProps);\n const comboboxStateProps = resolveComboboxStateProps({\n runtimeState: {\n value,\n defaultValue,\n onChange,\n inputValue,\n defaultInputValue,\n onInputChange,\n },\n asyncState: asyncComboboxState,\n collection,\n hasSearch: search !== undefined,\n });\n const defaultFilter = shouldDisableRootFilter ? () => true : contains;\n const getItemTextValue =\n isDirectAsyncServer && items !== undefined\n ? getAsyncComboboxItemTextValue\n : undefined;\n\n return (\n <AriaComboBox<T>\n className={classes.root}\n defaultFilter={defaultFilter}\n items={rootItems}\n {...dataAttributes}\n ref={ref}\n {...ariaProps}\n {...comboboxStateProps}\n menuTrigger={menuTrigger}\n allowsEmptyCollection\n >\n <FieldLabel\n label={label}\n secondaryLabel={secondaryLabelText}\n description={description}\n descriptionSlot=\"description\"\n />\n <ComboboxInput icon={icon} placeholder={placeholder} />\n <FieldError />\n <Popover className={classes.popover} hideArrow {...dataAttributes}>\n <ComboboxListBox\n options={collectionSource.options}\n items={renderedItems}\n dependencies={dependencies}\n search={search as never}\n loading={collection.loading}\n isStale={collection.isStale}\n getItemTextValue={getItemTextValue}\n >\n {children as ComboboxListBoxOwnProps<T>['children']}\n </ComboboxListBox>\n </Popover>\n </AriaComboBox>\n );\n}\n\n/** @public */\nexport const Combobox = forwardRef(ComboboxImpl) as unknown as {\n (\n props: ComboboxOptionsProps & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n (\n props: ComboboxAsyncOptionsProps & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n <T extends { id: Key }>(\n props: ComboboxItemsProps<T> & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n <T extends { id: Key }>(\n props: ComboboxAsyncItemsProps<T> & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n (\n props: ComboboxStaticProps & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n (\n props: ComboboxServerOptionsProps & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n <T extends ComboboxServerItem>(\n props: ComboboxServerItemsProps<T> & React.RefAttributes<HTMLDivElement>,\n ): React.ReactElement;\n displayName?: string;\n};\n\nCombobox.displayName = 'Combobox';\n"],"names":["AriaComboBox"],"mappings":";;;;;;;;;;;;;;;;;;AAkFA,SAAS,yBAAA,CAAoD;AAAA,EAC3D,YAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA,EAK2B;AACzB,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,OAAO,UAAA;AAAA,EACT;AAEA,EAAA,MAAM,cAAA,GAAiB;AAAA,IACrB,OAAO,YAAA,CAAa,KAAA;AAAA,IACpB,cAAc,YAAA,CAAa,YAAA;AAAA,IAC3B,UAAU,YAAA,CAAa;AAAA,GAGzB;AAEA,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,OAAO;AAAA,MACL,GAAG,cAAA;AAAA,MACH,YAAY,UAAA,CAAW,UAAA;AAAA,MACvB,mBAAmB,UAAA,CAAW,iBAAA;AAA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,WAAW,YAAY;AAyB/C,QAAA,CAAS,WAAA,GAAc,UAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderMetadataStatus.esm.js","sources":["../../../src/components/Header/HeaderMetadataStatus.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 { HeaderMetadataStatusProps } from './types';\nimport { Text } from '../Text';\nimport { Link } from '../Link';\nimport styles from './HeaderMetadataStatus.module.css';\n\n/**\n * Displays a single status indicator as a
|
|
1
|
+
{"version":3,"file":"HeaderMetadataStatus.esm.js","sources":["../../../src/components/Header/HeaderMetadataStatus.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 { HeaderMetadataStatusProps } from './types';\nimport { Text } from '../Text';\nimport { Link } from '../Link';\nimport styles from './HeaderMetadataStatus.module.css';\n\n/**\n * Displays a single status indicator as a colored dot with a label inside a\n * Header metadata value. Optionally renders the label as a link when href is provided.\n *\n * @public\n */\nexport const HeaderMetadataStatus = ({\n label,\n color,\n href,\n}: HeaderMetadataStatusProps) => {\n return (\n <div className={styles.single}>\n <span\n aria-hidden=\"true\"\n className={`${styles.dot} ${styles[`dot-${color}`]}`}\n />\n <Text variant=\"body-medium\">\n {href ? (\n <Link href={href} standalone>\n {label}\n </Link>\n ) : (\n label\n )}\n </Text>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA2BO,MAAM,uBAAuB,CAAC;AAAA,EACnC,KAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA,KAAiC;AAC/B,EAAA,uBACE,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,MAAA,EACrB,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,aAAA,EAAY,MAAA;AAAA,QACZ,SAAA,EAAW,GAAG,MAAA,CAAO,GAAG,IAAI,MAAA,CAAO,CAAA,IAAA,EAAO,KAAK,CAAA,CAAE,CAAC,CAAA;AAAA;AAAA,KACpD;AAAA,oBACA,GAAA,CAAC,IAAA,EAAA,EAAK,OAAA,EAAQ,aAAA,EACX,QAAA,EAAA,IAAA,mBACC,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAY,UAAA,EAAU,IAAA,EACzB,QAAA,EAAA,KAAA,EACH,CAAA,GAEA,KAAA,EAEJ;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -58,14 +58,18 @@ const PluginHeader = (props) => {
|
|
|
58
58
|
`${height}px`
|
|
59
59
|
);
|
|
60
60
|
};
|
|
61
|
+
const getHeight = () => {
|
|
62
|
+
const marginBottom = parseFloat(window.getComputedStyle(el).marginBottom) || 0;
|
|
63
|
+
return el.offsetHeight + marginBottom;
|
|
64
|
+
};
|
|
61
65
|
const scheduleHeightUpdate = () => {
|
|
62
66
|
cancelScheduledUpdate();
|
|
63
67
|
animationFrameRef.current = requestAnimationFrame(() => {
|
|
64
68
|
animationFrameRef.current = void 0;
|
|
65
|
-
applyHeight(
|
|
69
|
+
applyHeight(getHeight());
|
|
66
70
|
});
|
|
67
71
|
};
|
|
68
|
-
applyHeight(
|
|
72
|
+
applyHeight(getHeight());
|
|
69
73
|
if (typeof ResizeObserver === "undefined") {
|
|
70
74
|
return () => {
|
|
71
75
|
cancelScheduledUpdate();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginHeader.esm.js","sources":["../../../src/components/PluginHeader/PluginHeader.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 { PluginHeaderProps } from './types';\nimport { Tabs, TabList, Tab } from '../Tabs';\nimport { useDefinition } from '../../hooks/useDefinition';\nimport { PluginHeaderDefinition } from './definition';\nimport { type NavigateOptions } from 'react-router-dom';\nimport { Children, useMemo, useRef } from 'react';\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { Box } from '../Box';\nimport { Link } from '../Link';\nimport { RiShapesLine } from '@remixicon/react';\nimport { Text } from '../Text';\nimport { VisuallyHidden } from '../VisuallyHidden';\nimport { PluginHeaderBreadcrumbs } from './PluginHeaderBreadcrumbs';\n\ndeclare module 'react-aria-components' {\n interface RouterConfig {\n routerOptions: NavigateOptions;\n }\n}\n\n/**\n * Renders a plugin header with icon, title, custom actions, and optional tabs.\n * Always participates in the background context system so descendants (e.g. buttons)\n * get the correct `data-on-bg` styling inside the toolbar and tabs.\n *\n * @public\n */\nexport const PluginHeader = (props: PluginHeaderProps) => {\n const { ownProps } = useDefinition(PluginHeaderDefinition, props);\n const {\n classes,\n tabs,\n icon,\n title,\n titleLink,\n breadcrumbs,\n customActions,\n onTabSelectionChange,\n } = ownProps;\n\n const hasTabs = tabs && tabs.length > 0;\n const hasBreadcrumbs = breadcrumbs && breadcrumbs.length > 0;\n const rootRef = useRef<HTMLDivElement>(null);\n const animationFrameRef = useRef<number | undefined>(undefined);\n const lastAppliedHeightRef = useRef<number | undefined>(undefined);\n\n const actionChildren = useMemo(() => {\n return Children.toArray(customActions);\n }, [customActions]);\n\n useIsomorphicLayoutEffect(() => {\n const el = rootRef.current;\n if (!el) {\n return undefined;\n }\n\n const cancelScheduledUpdate = () => {\n if (animationFrameRef.current === undefined) {\n return;\n }\n\n cancelAnimationFrame(animationFrameRef.current);\n animationFrameRef.current = undefined;\n };\n\n const applyHeight = (height: number) => {\n if (lastAppliedHeightRef.current === height) {\n return;\n }\n\n lastAppliedHeightRef.current = height;\n document.documentElement.style.setProperty(\n '--bui-header-height',\n `${height}px`,\n );\n };\n\n const scheduleHeightUpdate = () => {\n cancelScheduledUpdate();\n animationFrameRef.current = requestAnimationFrame(() => {\n animationFrameRef.current = undefined;\n applyHeight(el.offsetHeight);\n });\n };\n\n // Set height once immediately so the initial layout is correct.\n applyHeight(el.offsetHeight);\n\n // Observe for resize changes if ResizeObserver is available\n // (not present in Jest/jsdom by default)\n if (typeof ResizeObserver === 'undefined') {\n return () => {\n cancelScheduledUpdate();\n lastAppliedHeightRef.current = undefined;\n document.documentElement.style.removeProperty('--bui-header-height');\n };\n }\n\n const observer = new ResizeObserver(() => {\n scheduleHeightUpdate();\n });\n observer.observe(el);\n\n return () => {\n observer.disconnect();\n cancelScheduledUpdate();\n lastAppliedHeightRef.current = undefined;\n document.documentElement.style.removeProperty('--bui-header-height');\n };\n }, []);\n\n const titleText = title || 'Your plugin';\n\n return (\n <div ref={rootRef} className={classes.root}>\n <div className={classes.toolbar} data-has-tabs={hasTabs ? '' : undefined}>\n <div className={classes.toolbarContent}>\n <Box bg=\"neutral\" className={classes.toolbarIcon} aria-hidden=\"true\">\n {icon || <RiShapesLine />}\n </Box>\n {hasBreadcrumbs ? (\n <div className={classes.toolbarName}>\n <VisuallyHidden>\n <h1>{titleText}</h1>\n </VisuallyHidden>\n <PluginHeaderBreadcrumbs\n entries={breadcrumbs}\n className={classes.breadcrumbs}\n ellipsisClassName={classes.breadcrumbsEllipsis}\n />\n </div>\n ) : (\n <h1 className={classes.toolbarName}>\n {titleLink ? (\n <Link href={titleLink} standalone variant=\"body-medium\">\n {titleText}\n </Link>\n ) : (\n <Text as=\"span\" variant=\"body-medium\">\n {titleText}\n </Text>\n )}\n </h1>\n )}\n </div>\n <div className={classes.toolbarControls}>{actionChildren}</div>\n </div>\n {hasTabs && (\n <div className={classes.tabs}>\n <Tabs onSelectionChange={onTabSelectionChange}>\n <TabList>\n {tabs?.map(tab => (\n <Tab\n key={tab.id}\n id={tab.id}\n href={tab.href}\n matchStrategy={tab.matchStrategy}\n >\n {tab.label}\n </Tab>\n ))}\n </TabList>\n </Tabs>\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA2CO,MAAM,YAAA,GAAe,CAAC,KAAA,KAA6B;AACxD,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,aAAA,CAAc,wBAAwB,KAAK,CAAA;AAChE,EAAA,MAAM;AAAA,IACJ,OAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACF,GAAI,QAAA;AAEJ,EAAA,MAAM,OAAA,GAAU,IAAA,IAAQ,IAAA,CAAK,MAAA,GAAS,CAAA;AACtC,EAAA,MAAM,cAAA,GAAiB,WAAA,IAAe,WAAA,CAAY,MAAA,GAAS,CAAA;AAC3D,EAAA,MAAM,OAAA,GAAU,OAAuB,IAAI,CAAA;AAC3C,EAAA,MAAM,iBAAA,GAAoB,OAA2B,MAAS,CAAA;AAC9D,EAAA,MAAM,oBAAA,GAAuB,OAA2B,MAAS,CAAA;AAEjE,EAAA,MAAM,cAAA,GAAiB,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,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"PluginHeader.esm.js","sources":["../../../src/components/PluginHeader/PluginHeader.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 { PluginHeaderProps } from './types';\nimport { Tabs, TabList, Tab } from '../Tabs';\nimport { useDefinition } from '../../hooks/useDefinition';\nimport { PluginHeaderDefinition } from './definition';\nimport { type NavigateOptions } from 'react-router-dom';\nimport { Children, useMemo, useRef } from 'react';\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { Box } from '../Box';\nimport { Link } from '../Link';\nimport { RiShapesLine } from '@remixicon/react';\nimport { Text } from '../Text';\nimport { VisuallyHidden } from '../VisuallyHidden';\nimport { PluginHeaderBreadcrumbs } from './PluginHeaderBreadcrumbs';\n\ndeclare module 'react-aria-components' {\n interface RouterConfig {\n routerOptions: NavigateOptions;\n }\n}\n\n/**\n * Renders a plugin header with icon, title, custom actions, and optional tabs.\n * Always participates in the background context system so descendants (e.g. buttons)\n * get the correct `data-on-bg` styling inside the toolbar and tabs.\n *\n * @public\n */\nexport const PluginHeader = (props: PluginHeaderProps) => {\n const { ownProps } = useDefinition(PluginHeaderDefinition, props);\n const {\n classes,\n tabs,\n icon,\n title,\n titleLink,\n breadcrumbs,\n customActions,\n onTabSelectionChange,\n } = ownProps;\n\n const hasTabs = tabs && tabs.length > 0;\n const hasBreadcrumbs = breadcrumbs && breadcrumbs.length > 0;\n const rootRef = useRef<HTMLDivElement>(null);\n const animationFrameRef = useRef<number | undefined>(undefined);\n const lastAppliedHeightRef = useRef<number | undefined>(undefined);\n\n const actionChildren = useMemo(() => {\n return Children.toArray(customActions);\n }, [customActions]);\n\n useIsomorphicLayoutEffect(() => {\n const el = rootRef.current;\n if (!el) {\n return undefined;\n }\n\n const cancelScheduledUpdate = () => {\n if (animationFrameRef.current === undefined) {\n return;\n }\n\n cancelAnimationFrame(animationFrameRef.current);\n animationFrameRef.current = undefined;\n };\n\n const applyHeight = (height: number) => {\n if (lastAppliedHeightRef.current === height) {\n return;\n }\n\n lastAppliedHeightRef.current = height;\n document.documentElement.style.setProperty(\n '--bui-header-height',\n `${height}px`,\n );\n };\n\n const getHeight = () => {\n const marginBottom =\n parseFloat(window.getComputedStyle(el).marginBottom) || 0;\n return el.offsetHeight + marginBottom;\n };\n\n const scheduleHeightUpdate = () => {\n cancelScheduledUpdate();\n animationFrameRef.current = requestAnimationFrame(() => {\n animationFrameRef.current = undefined;\n applyHeight(getHeight());\n });\n };\n\n // Set height once immediately so the initial layout is correct.\n applyHeight(getHeight());\n\n // Observe for resize changes if ResizeObserver is available\n // (not present in Jest/jsdom by default)\n if (typeof ResizeObserver === 'undefined') {\n return () => {\n cancelScheduledUpdate();\n lastAppliedHeightRef.current = undefined;\n document.documentElement.style.removeProperty('--bui-header-height');\n };\n }\n\n const observer = new ResizeObserver(() => {\n scheduleHeightUpdate();\n });\n observer.observe(el);\n\n return () => {\n observer.disconnect();\n cancelScheduledUpdate();\n lastAppliedHeightRef.current = undefined;\n document.documentElement.style.removeProperty('--bui-header-height');\n };\n }, []);\n\n const titleText = title || 'Your plugin';\n\n return (\n <div ref={rootRef} className={classes.root}>\n <div className={classes.toolbar} data-has-tabs={hasTabs ? '' : undefined}>\n <div className={classes.toolbarContent}>\n <Box bg=\"neutral\" className={classes.toolbarIcon} aria-hidden=\"true\">\n {icon || <RiShapesLine />}\n </Box>\n {hasBreadcrumbs ? (\n <div className={classes.toolbarName}>\n <VisuallyHidden>\n <h1>{titleText}</h1>\n </VisuallyHidden>\n <PluginHeaderBreadcrumbs\n entries={breadcrumbs}\n className={classes.breadcrumbs}\n ellipsisClassName={classes.breadcrumbsEllipsis}\n />\n </div>\n ) : (\n <h1 className={classes.toolbarName}>\n {titleLink ? (\n <Link href={titleLink} standalone variant=\"body-medium\">\n {titleText}\n </Link>\n ) : (\n <Text as=\"span\" variant=\"body-medium\">\n {titleText}\n </Text>\n )}\n </h1>\n )}\n </div>\n <div className={classes.toolbarControls}>{actionChildren}</div>\n </div>\n {hasTabs && (\n <div className={classes.tabs}>\n <Tabs onSelectionChange={onTabSelectionChange}>\n <TabList>\n {tabs?.map(tab => (\n <Tab\n key={tab.id}\n id={tab.id}\n href={tab.href}\n matchStrategy={tab.matchStrategy}\n >\n {tab.label}\n </Tab>\n ))}\n </TabList>\n </Tabs>\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA2CO,MAAM,YAAA,GAAe,CAAC,KAAA,KAA6B;AACxD,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,aAAA,CAAc,wBAAwB,KAAK,CAAA;AAChE,EAAA,MAAM;AAAA,IACJ,OAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACF,GAAI,QAAA;AAEJ,EAAA,MAAM,OAAA,GAAU,IAAA,IAAQ,IAAA,CAAK,MAAA,GAAS,CAAA;AACtC,EAAA,MAAM,cAAA,GAAiB,WAAA,IAAe,WAAA,CAAY,MAAA,GAAS,CAAA;AAC3D,EAAA,MAAM,OAAA,GAAU,OAAuB,IAAI,CAAA;AAC3C,EAAA,MAAM,iBAAA,GAAoB,OAA2B,MAAS,CAAA;AAC9D,EAAA,MAAM,oBAAA,GAAuB,OAA2B,MAAS,CAAA;AAEjE,EAAA,MAAM,cAAA,GAAiB,QAAQ,MAAM;AACnC,IAAA,OAAO,QAAA,CAAS,QAAQ,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AElB,QAAA,EAAA,GAAA,CAAI;AAAA,OAAA;AAAA,MALA,GAAA,CAAI;AAAA,KAOZ,CAAA,EACH,CAAA,EACF,CAAA,EACF;AAAA,GAAA,EAEJ,CAAA;AAEJ;;;;"}
|
|
@@ -4,7 +4,7 @@ function getOptionValue(option) {
|
|
|
4
4
|
}
|
|
5
5
|
function getEffectivePageSize(paginationOptions) {
|
|
6
6
|
const { pageSize, pageSizeOptions } = paginationOptions;
|
|
7
|
-
if (!pageSizeOptions) {
|
|
7
|
+
if (!pageSizeOptions?.length) {
|
|
8
8
|
return pageSize ?? DEFAULT_PAGE_SIZE;
|
|
9
9
|
}
|
|
10
10
|
const firstValue = getOptionValue(pageSizeOptions[0]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEffectivePageSize.esm.js","sources":["../../../../src/components/Table/hooks/getEffectivePageSize.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 type { PageSizeOption } from '../../TablePagination/types';\nimport type { PaginationOptions } from './types';\n\nconst DEFAULT_PAGE_SIZE = 20;\n\nfunction getOptionValue(option: number | PageSizeOption): number {\n return typeof option === 'number' ? option : option.value;\n}\n\n/** @internal */\nexport function getEffectivePageSize(\n paginationOptions: PaginationOptions,\n): number {\n const { pageSize, pageSizeOptions } = paginationOptions;\n\n if (!pageSizeOptions) {\n return pageSize ?? DEFAULT_PAGE_SIZE;\n }\n\n const firstValue = getOptionValue(pageSizeOptions[0]);\n\n if (pageSize === undefined) {\n return firstValue;\n }\n\n const isValid = pageSizeOptions.some(opt => getOptionValue(opt) === pageSize);\n\n if (isValid) {\n return pageSize;\n }\n\n console.warn(\n `useTable: pageSize ${pageSize} is not in pageSizeOptions, using ${firstValue} instead`,\n );\n return firstValue;\n}\n"],"names":[],"mappings":"AAmBA,MAAM,iBAAA,GAAoB,EAAA;AAE1B,SAAS,eAAe,MAAA,EAAyC;AAC/D,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,GAAW,MAAA,GAAS,MAAA,CAAO,KAAA;AACtD;AAGO,SAAS,qBACd,iBAAA,EACQ;AACR,EAAA,MAAM,EAAE,QAAA,EAAU,eAAA,EAAgB,GAAI,iBAAA;AAEtC,EAAA,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"getEffectivePageSize.esm.js","sources":["../../../../src/components/Table/hooks/getEffectivePageSize.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 type { PageSizeOption } from '../../TablePagination/types';\nimport type { PaginationOptions } from './types';\n\nconst DEFAULT_PAGE_SIZE = 20;\n\nfunction getOptionValue(option: number | PageSizeOption): number {\n return typeof option === 'number' ? option : option.value;\n}\n\n/** @internal */\nexport function getEffectivePageSize(\n paginationOptions: PaginationOptions,\n): number {\n const { pageSize, pageSizeOptions } = paginationOptions;\n\n if (!pageSizeOptions?.length) {\n return pageSize ?? DEFAULT_PAGE_SIZE;\n }\n\n const firstValue = getOptionValue(pageSizeOptions[0]);\n\n if (pageSize === undefined) {\n return firstValue;\n }\n\n const isValid = pageSizeOptions.some(opt => getOptionValue(opt) === pageSize);\n\n if (isValid) {\n return pageSize;\n }\n\n console.warn(\n `useTable: pageSize ${pageSize} is not in pageSizeOptions, using ${firstValue} instead`,\n );\n return firstValue;\n}\n"],"names":[],"mappings":"AAmBA,MAAM,iBAAA,GAAoB,EAAA;AAE1B,SAAS,eAAe,MAAA,EAAyC;AAC/D,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,GAAW,MAAA,GAAS,MAAA,CAAO,KAAA;AACtD;AAGO,SAAS,qBACd,iBAAA,EACQ;AACR,EAAA,MAAM,EAAE,QAAA,EAAU,eAAA,EAAgB,GAAI,iBAAA;AAEtC,EAAA,IAAI,CAAC,iBAAiB,MAAA,EAAQ;AAC5B,IAAA,OAAO,QAAA,IAAY,iBAAA;AAAA,EACrB;AAEA,EAAA,MAAM,UAAA,GAAa,cAAA,CAAe,eAAA,CAAgB,CAAC,CAAC,CAAA;AAEpD,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,OAAO,UAAA;AAAA,EACT;AAEA,EAAA,MAAM,UAAU,eAAA,CAAgB,IAAA,CAAK,SAAO,cAAA,CAAe,GAAG,MAAM,QAAQ,CAAA;AAE5E,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,OAAO,QAAA;AAAA,EACT;AAEA,EAAA,OAAA,CAAQ,IAAA;AAAA,IACN,CAAA,mBAAA,EAAsB,QAAQ,CAAA,kCAAA,EAAqC,UAAU,CAAA,QAAA;AAAA,GAC/E;AACA,EAAA,OAAO,UAAA;AACT;;;;"}
|
|
@@ -54,6 +54,9 @@ function TablePagination(props) {
|
|
|
54
54
|
[pageSizeOptions]
|
|
55
55
|
);
|
|
56
56
|
const effectivePageSize = useMemo(() => {
|
|
57
|
+
if (pageSizeOptions.length === 0) {
|
|
58
|
+
return pageSize;
|
|
59
|
+
}
|
|
57
60
|
const isValid = pageSizeOptions.some(
|
|
58
61
|
(opt) => getOptionValue(opt) === pageSize
|
|
59
62
|
);
|
|
@@ -77,7 +80,7 @@ function TablePagination(props) {
|
|
|
77
80
|
label = `${fromCount} - ${toCount} of ${totalCount}`;
|
|
78
81
|
}
|
|
79
82
|
return /* @__PURE__ */ jsxs("div", { className: classes.root, children: [
|
|
80
|
-
/* @__PURE__ */ jsx("div", { className: classes.left, children: showPageSizeOptions && /* @__PURE__ */ jsx(
|
|
83
|
+
/* @__PURE__ */ jsx("div", { className: classes.left, children: showPageSizeOptions && normalizedOptions.length > 0 && /* @__PURE__ */ jsx(
|
|
81
84
|
Select,
|
|
82
85
|
{
|
|
83
86
|
name: "pageSize",
|
|
@@ -87,7 +90,7 @@ function TablePagination(props) {
|
|
|
87
90
|
label: opt.label,
|
|
88
91
|
value: String(opt.value)
|
|
89
92
|
})),
|
|
90
|
-
|
|
93
|
+
value: effectivePageSize.toString(),
|
|
91
94
|
onChange: (value) => {
|
|
92
95
|
const newPageSize = Number(value);
|
|
93
96
|
onPageSizeChange?.(newPageSize);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TablePagination.esm.js","sources":["../../../src/components/TablePagination/TablePagination.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 { useId } from 'react-aria';\nimport { Text } from '../Text';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { Select } from '../Select';\nimport type { TablePaginationProps, PageSizeOption } from './types';\nimport { useDefinition } from '../../hooks/useDefinition';\nimport { TablePaginationDefinition } from './definition';\nimport { RiArrowLeftSLine, RiArrowRightSLine } from '@remixicon/react';\nimport { useMemo } from 'react';\n\nfunction getOptionValue(option: number | PageSizeOption): number {\n return typeof option === 'number' ? option : option.value;\n}\n\nfunction isNumberArray(\n options: number[] | PageSizeOption[],\n): options is number[] {\n return options.length > 0 && typeof options[0] === 'number';\n}\n\nfunction normalizePageSizeOptions(\n options: number[] | PageSizeOption[],\n): PageSizeOption[] {\n if (isNumberArray(options)) {\n return options.map(value => ({\n label: `Show ${value} results`,\n value,\n }));\n }\n return options;\n}\n\n/**\n * Pagination controls for Table components with page navigation and size selection.\n *\n * @public\n */\nexport function TablePagination(props: TablePaginationProps) {\n const { ownProps } = useDefinition(TablePaginationDefinition, props);\n const {\n classes,\n pageSize,\n pageSizeOptions,\n offset,\n totalCount,\n hasNextPage,\n hasPreviousPage,\n onNextPage,\n onPreviousPage,\n onPageSizeChange,\n showPageSizeOptions,\n getLabel,\n showPaginationLabel,\n } = ownProps;\n\n const labelId = useId();\n const normalizedOptions = useMemo(\n () => normalizePageSizeOptions(pageSizeOptions),\n [pageSizeOptions],\n );\n\n const effectivePageSize = useMemo(() => {\n const isValid = pageSizeOptions.some(\n opt => getOptionValue(opt) === pageSize,\n );\n if (isValid) {\n return pageSize;\n }\n const firstValue = getOptionValue(pageSizeOptions[0]);\n console.warn(\n `TablePagination: pageSize ${pageSize} is not in pageSizeOptions, using ${firstValue} instead`,\n );\n return firstValue;\n }, [pageSize, pageSizeOptions]);\n\n const hasItems = totalCount !== undefined && totalCount !== 0;\n\n const showLabel = hasItems && showPaginationLabel !== false;\n\n let label = `${totalCount} items`;\n if (getLabel) {\n label = getLabel({ pageSize: effectivePageSize, offset, totalCount });\n } else if (offset !== undefined) {\n const fromCount = offset + 1;\n const toCount = Math.min(offset + effectivePageSize, totalCount ?? 0);\n label = `${fromCount} - ${toCount} of ${totalCount}`;\n }\n\n return (\n <div className={classes.root}>\n <div className={classes.left}>\n {showPageSizeOptions && (\n <Select\n name=\"pageSize\"\n size=\"small\"\n aria-label=\"Select table page size\"\n options={normalizedOptions.map(opt => ({\n label: opt.label,\n value: String(opt.value),\n }))}\n
|
|
1
|
+
{"version":3,"file":"TablePagination.esm.js","sources":["../../../src/components/TablePagination/TablePagination.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 { useId } from 'react-aria';\nimport { Text } from '../Text';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { Select } from '../Select';\nimport type { TablePaginationProps, PageSizeOption } from './types';\nimport { useDefinition } from '../../hooks/useDefinition';\nimport { TablePaginationDefinition } from './definition';\nimport { RiArrowLeftSLine, RiArrowRightSLine } from '@remixicon/react';\nimport { useMemo } from 'react';\n\nfunction getOptionValue(option: number | PageSizeOption): number {\n return typeof option === 'number' ? option : option.value;\n}\n\nfunction isNumberArray(\n options: number[] | PageSizeOption[],\n): options is number[] {\n return options.length > 0 && typeof options[0] === 'number';\n}\n\nfunction normalizePageSizeOptions(\n options: number[] | PageSizeOption[],\n): PageSizeOption[] {\n if (isNumberArray(options)) {\n return options.map(value => ({\n label: `Show ${value} results`,\n value,\n }));\n }\n return options;\n}\n\n/**\n * Pagination controls for Table components with page navigation and size selection.\n *\n * @public\n */\nexport function TablePagination(props: TablePaginationProps) {\n const { ownProps } = useDefinition(TablePaginationDefinition, props);\n const {\n classes,\n pageSize,\n pageSizeOptions,\n offset,\n totalCount,\n hasNextPage,\n hasPreviousPage,\n onNextPage,\n onPreviousPage,\n onPageSizeChange,\n showPageSizeOptions,\n getLabel,\n showPaginationLabel,\n } = ownProps;\n\n const labelId = useId();\n const normalizedOptions = useMemo(\n () => normalizePageSizeOptions(pageSizeOptions),\n [pageSizeOptions],\n );\n\n const effectivePageSize = useMemo(() => {\n if (pageSizeOptions.length === 0) {\n return pageSize;\n }\n const isValid = pageSizeOptions.some(\n opt => getOptionValue(opt) === pageSize,\n );\n if (isValid) {\n return pageSize;\n }\n const firstValue = getOptionValue(pageSizeOptions[0]);\n console.warn(\n `TablePagination: pageSize ${pageSize} is not in pageSizeOptions, using ${firstValue} instead`,\n );\n return firstValue;\n }, [pageSize, pageSizeOptions]);\n\n const hasItems = totalCount !== undefined && totalCount !== 0;\n\n const showLabel = hasItems && showPaginationLabel !== false;\n\n let label = `${totalCount} items`;\n if (getLabel) {\n label = getLabel({ pageSize: effectivePageSize, offset, totalCount });\n } else if (offset !== undefined) {\n const fromCount = offset + 1;\n const toCount = Math.min(offset + effectivePageSize, totalCount ?? 0);\n label = `${fromCount} - ${toCount} of ${totalCount}`;\n }\n\n return (\n <div className={classes.root}>\n <div className={classes.left}>\n {showPageSizeOptions && normalizedOptions.length > 0 && (\n <Select\n name=\"pageSize\"\n size=\"small\"\n aria-label=\"Select table page size\"\n options={normalizedOptions.map(opt => ({\n label: opt.label,\n value: String(opt.value),\n }))}\n value={effectivePageSize.toString()}\n onChange={value => {\n const newPageSize = Number(value);\n onPageSizeChange?.(newPageSize);\n }}\n className={classes.select}\n />\n )}\n </div>\n <div className={classes.right}>\n {showLabel && (\n <Text as=\"p\" variant=\"body-medium\" id={labelId}>\n {label}\n </Text>\n )}\n <ButtonIcon\n variant=\"secondary\"\n size=\"small\"\n onClick={onPreviousPage}\n isDisabled={!hasPreviousPage}\n icon={<RiArrowLeftSLine />}\n aria-label=\"Previous table page\"\n aria-describedby={showLabel ? labelId : undefined}\n />\n <ButtonIcon\n variant=\"secondary\"\n size=\"small\"\n onClick={onNextPage}\n isDisabled={!hasNextPage}\n icon={<RiArrowRightSLine />}\n aria-label=\"Next table page\"\n aria-describedby={showLabel ? labelId : undefined}\n />\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,SAAS,eAAe,MAAA,EAAyC;AAC/D,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,GAAW,MAAA,G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AAkB,YAAY,OAAA,GAAU;AAAA;AAAA;AAC1C,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1934,7 +1934,7 @@ declare const HeaderMetadataUsers: ({ users, }: {
|
|
|
1934
1934
|
}) => react_jsx_runtime.JSX.Element | null;
|
|
1935
1935
|
|
|
1936
1936
|
/**
|
|
1937
|
-
* Displays a single status indicator as a
|
|
1937
|
+
* Displays a single status indicator as a colored dot with a label inside a
|
|
1938
1938
|
* Header metadata value. Optionally renders the label as a link when href is provided.
|
|
1939
1939
|
*
|
|
1940
1940
|
* @public
|
|
@@ -2750,7 +2750,9 @@ interface PageSizeOption {
|
|
|
2750
2750
|
}
|
|
2751
2751
|
/** @public */
|
|
2752
2752
|
type TablePaginationOwnProps = {
|
|
2753
|
+
/** The controlled number of rows displayed per page. */
|
|
2753
2754
|
pageSize: number;
|
|
2755
|
+
/** Available page sizes. An empty array hides the page-size selector. */
|
|
2754
2756
|
pageSizeOptions?: number[] | PageSizeOption[];
|
|
2755
2757
|
offset?: number;
|
|
2756
2758
|
totalCount?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/ui",
|
|
3
|
-
"version": "0.18.0
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "web-library"
|
|
6
6
|
},
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"test": "backstage-cli package test"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@backstage/version-bridge": "1.0.12",
|
|
53
|
+
"@backstage/version-bridge": "^1.0.12",
|
|
54
54
|
"@braintree/sanitize-url": "^7.1.2",
|
|
55
55
|
"@internationalized/date": "^3.12.0",
|
|
56
56
|
"@remixicon/react": ">=4.6.0 <4.9.0",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"use-sync-external-store": "^1.4.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@backstage/cli": "0.36.6
|
|
67
|
-
"@backstage/core-components": "0.18.14
|
|
66
|
+
"@backstage/cli": "^0.36.6",
|
|
67
|
+
"@backstage/core-components": "^0.18.14",
|
|
68
68
|
"@storybook/react-vite": "^10.4.0",
|
|
69
69
|
"@testing-library/dom": "^10.0.0",
|
|
70
70
|
"@testing-library/jest-dom": "^6.0.0",
|