@redocly/theme 0.46.4 → 0.46.5

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.
@@ -17,14 +17,16 @@ function ProductPicker() {
17
17
  const { currentProduct, products, setProduct } = (0, hooks_1.useProductPicker)();
18
18
  const { useTranslate } = (0, hooks_1.useThemeHooks)();
19
19
  const { translate } = useTranslate();
20
- const productComponents = products.map((product) => ({
21
- content: react_1.default.createElement(Product_1.Product, { product: product }),
22
- suffix: currentProduct === product && react_1.default.createElement(CheckmarkIcon_1.CheckmarkIcon, null),
23
- onAction: () => {
24
- setProduct(product);
25
- },
26
- active: product === currentProduct,
27
- }));
20
+ const productComponents = products.map((product) => {
21
+ return {
22
+ content: react_1.default.createElement(Product_1.Product, { product: product }),
23
+ suffix: product.slug === (currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.slug) && react_1.default.createElement(CheckmarkIcon_1.CheckmarkIcon, null),
24
+ onAction: () => {
25
+ setProduct(product);
26
+ },
27
+ active: product.slug === (currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.slug),
28
+ };
29
+ });
28
30
  return products.length ? (react_1.default.createElement(ProductDropdown, { withArrow: true, trigger: react_1.default.createElement(Button_1.Button, { variant: "ghost" }, currentProduct ? (react_1.default.createElement(Product_1.Product, { product: currentProduct })) : (react_1.default.createElement("span", { "data-translation-key": "navbar.products" }, translate('navbar.products', 'Products')))), triggerEvent: "hover" },
29
31
  react_1.default.createElement(DropdownMenu_1.DropdownMenu, { items: productComponents }))) : null;
30
32
  }
@@ -68,9 +68,11 @@ function SearchDialog({ onClose, className }) {
68
68
  }
69
69
  };
70
70
  const mapItem = (item, index) => {
71
+ var _a;
71
72
  let itemProduct;
72
73
  if (!product && item.document.product) {
73
- const resolvedProduct = products.find((product) => { var _a; return product.slug.match(`/${(_a = item.document.product) === null || _a === void 0 ? void 0 : _a.folder}/`); });
74
+ const folder = (_a = item.document.product) === null || _a === void 0 ? void 0 : _a.folder;
75
+ const resolvedProduct = products.find((product) => product.slug.match(`/${folder.startsWith('./') ? folder.slice(2) : folder}/`));
74
76
  itemProduct = resolvedProduct
75
77
  ? { name: resolvedProduct.name, icon: resolvedProduct.icon }
76
78
  : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.46.4",
3
+ "version": "0.46.5",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -79,7 +79,7 @@
79
79
  "timeago.js": "4.0.2",
80
80
  "i18next": "22.4.15",
81
81
  "nprogress": "0.2.0",
82
- "@redocly/config": "0.19.2"
82
+ "@redocly/config": "0.19.3"
83
83
  },
84
84
  "scripts": {
85
85
  "watch": "tsc -p tsconfig.build.json && (concurrently \"tsc -w -p tsconfig.build.json\" \"tsc-alias -w -p tsconfig.build.json\")",
@@ -14,14 +14,16 @@ export function ProductPicker(): JSX.Element | null {
14
14
  const { useTranslate } = useThemeHooks();
15
15
  const { translate } = useTranslate();
16
16
 
17
- const productComponents = products.map((product) => ({
18
- content: <Product product={product} />,
19
- suffix: currentProduct === product && <CheckmarkIcon />,
20
- onAction: () => {
21
- setProduct(product);
22
- },
23
- active: product === currentProduct,
24
- }));
17
+ const productComponents = products.map((product) => {
18
+ return {
19
+ content: <Product product={product} />,
20
+ suffix: product.slug === currentProduct?.slug && <CheckmarkIcon />,
21
+ onAction: () => {
22
+ setProduct(product);
23
+ },
24
+ active: product.slug === currentProduct?.slug,
25
+ };
26
+ });
25
27
 
26
28
  return products.length ? (
27
29
  <ProductDropdown
@@ -71,8 +71,9 @@ export function SearchDialog({ onClose, className }: SearchDialogProps): JSX.Ele
71
71
  const mapItem = (item: SearchItemData, index: number) => {
72
72
  let itemProduct;
73
73
  if (!product && item.document.product) {
74
+ const folder = item.document.product?.folder;
74
75
  const resolvedProduct = products.find((product) =>
75
- product.slug.match(`/${item.document.product?.folder}/`),
76
+ product.slug.match(`/${folder.startsWith('./') ? folder.slice(2) : folder}/`),
76
77
  );
77
78
  itemProduct = resolvedProduct
78
79
  ? { name: resolvedProduct.name, icon: resolvedProduct.icon }