@rspress/core 2.0.11 → 2.0.12

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.
Files changed (63) hide show
  1. package/dist/0~execa.js +1 -1
  2. package/dist/8006.js +1 -1
  3. package/dist/8857.js +1 -1
  4. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +16 -17
  5. package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -6
  6. package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +1 -1
  7. package/dist/eject-theme/components/Tabs/index.tsx +48 -41
  8. package/dist/node/PluginDriver.js +1 -1
  9. package/dist/node/auto-nav-sidebar/index.js +1 -1
  10. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  11. package/dist/node/auto-nav-sidebar/normalize.d.ts +1 -1
  12. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  13. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  14. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  15. package/dist/node/initRsbuild.js +1 -1
  16. package/dist/node/mdx/rehypePlugins/transformers/add-title.js +3 -6
  17. package/dist/node/mdx/remarkPlugins/containerSyntax.d.ts +1 -1
  18. package/dist/node/mdx/remarkPlugins/image.d.ts +1 -1
  19. package/dist/node/mdx/remarkPlugins/image.js +1 -0
  20. package/dist/node/mdx/remarkPlugins/link.d.ts +1 -1
  21. package/dist/node/route/RoutePage.js +1 -1
  22. package/dist/node/route/RouteService.js +1 -1
  23. package/dist/node/route/extractPageData.js +1 -1
  24. package/dist/node/route/normalizeRoutePath.js +1 -1
  25. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +140 -140
  26. package/dist/node/runtimeModule/i18n.js +1 -1
  27. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  28. package/dist/node/runtimeModule/pageData/rsbuildPlugin.d.ts +1 -1
  29. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  30. package/dist/node/runtimeModule/searchHooks.js +1 -1
  31. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  32. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  33. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  34. package/dist/node/serve.js +1 -1
  35. package/dist/node/ssg/renderPages.js +1 -1
  36. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  37. package/dist/node/ssg/ssgEnv.js +1 -1
  38. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  39. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  40. package/dist/node/ssg-md/renderPage.js +1 -1
  41. package/dist/node/ssg-md/renderPages.js +1 -1
  42. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  43. package/dist/node/utils/checkLanguageParity.js +1 -1
  44. package/dist/node/utils/createHash.js +1 -1
  45. package/dist/node/utils/flattenMdxContent.js +1 -1
  46. package/dist/node/utils/getPageKey.js +1 -1
  47. package/dist/node/utils/reactAlias.js +1 -1
  48. package/dist/theme/components/DocContent/docComponents/a.d.ts +1 -1
  49. package/dist/theme/components/DocContent/docComponents/hr.d.ts +1 -1
  50. package/dist/theme/components/DocContent/docComponents/img.d.ts +1 -1
  51. package/dist/theme/components/DocContent/docComponents/index.d.ts +18 -18
  52. package/dist/theme/components/DocContent/docComponents/list.d.ts +3 -3
  53. package/dist/theme/components/DocContent/docComponents/paragraph.d.ts +3 -3
  54. package/dist/theme/components/DocContent/docComponents/table.d.ts +3 -3
  55. package/dist/theme/components/DocContent/docComponents/title.d.ts +6 -6
  56. package/dist/theme/components/Nav/hooks.d.ts +1 -1
  57. package/dist/theme/components/PackageManagerTabs/index.js +17 -17
  58. package/dist/theme/components/Search/SearchPanel.js +1 -2
  59. package/dist/theme/components/Sidebar/SidebarItem.js +1 -0
  60. package/dist/theme/components/Tabs/index.d.ts +8 -4
  61. package/dist/theme/components/Tabs/index.js +19 -19
  62. package/package.json +6 -6
  63. /package/dist/{5810.js → 2235.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { type ComponentProps } from 'react';
2
2
  export declare const Table: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, "ref"> & import("react").RefAttributes<HTMLTableElement>>;
3
- export declare const Tr: (props: ComponentProps<"tr">) => import("react/jsx-runtime").JSX.Element;
4
- export declare const Td: (props: ComponentProps<"td">) => import("react/jsx-runtime").JSX.Element;
5
- export declare const Th: (props: ComponentProps<"th">) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const Tr: (props: ComponentProps<'tr'>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const Td: (props: ComponentProps<'td'>) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const Th: (props: ComponentProps<'th'>) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import type React from 'react';
2
- export declare const H1: (props: React.ComponentProps<"h1">) => import("react/jsx-runtime").JSX.Element;
3
- export declare const H2: (props: React.ComponentProps<"h2">) => import("react/jsx-runtime").JSX.Element;
4
- export declare const H3: (props: React.ComponentProps<"h3">) => import("react/jsx-runtime").JSX.Element;
5
- export declare const H4: (props: React.ComponentProps<"h4">) => import("react/jsx-runtime").JSX.Element;
6
- export declare const H5: (props: React.ComponentProps<"h5">) => import("react/jsx-runtime").JSX.Element;
7
- export declare const H6: (props: React.ComponentProps<"h6">) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const H1: (props: React.ComponentProps<'h1'>) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const H2: (props: React.ComponentProps<'h2'>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const H3: (props: React.ComponentProps<'h3'>) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const H4: (props: React.ComponentProps<'h4'>) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const H5: (props: React.ComponentProps<'h5'>) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const H6: (props: React.ComponentProps<'h6'>) => import("react/jsx-runtime").JSX.Element;
@@ -7,8 +7,8 @@ export declare function useLangsMenu(): {
7
7
  }[];
8
8
  activeValue: string | undefined;
9
9
  } | {
10
- items: never[];
11
10
  activeValue?: undefined;
11
+ items: never[];
12
12
  };
13
13
  export declare function useVersionsMenu(): {
14
14
  items: {
@@ -117,26 +117,26 @@ function PackageManagerTabs({ command, exec, dlx, additionalTabs = [] }) {
117
117
  }, '');
118
118
  return /*#__PURE__*/ jsx(Tabs, {
119
119
  groupId: "package.manager",
120
- values: Object.entries(commandInfo).map(([key])=>/*#__PURE__*/ jsxs("div", {
121
- style: {
122
- display: 'flex',
123
- alignItems: 'center',
124
- fontSize: 15
125
- },
126
- children: [
127
- packageMangerToIcon[key],
128
- /*#__PURE__*/ jsx("span", {
129
- style: {
130
- marginLeft: 6,
131
- marginBottom: 2
132
- },
133
- children: key
134
- })
135
- ]
136
- }, key)),
137
120
  children: Object.entries(commandInfo).map(([key, value])=>{
138
121
  const [packageManager, command] = splitTo2Parts(value);
139
122
  return /*#__PURE__*/ jsx(Tab, {
123
+ label: /*#__PURE__*/ jsxs("div", {
124
+ style: {
125
+ display: 'flex',
126
+ alignItems: 'center',
127
+ fontSize: 15
128
+ },
129
+ children: [
130
+ packageMangerToIcon[key],
131
+ /*#__PURE__*/ jsx("span", {
132
+ style: {
133
+ marginLeft: 6,
134
+ marginBottom: 2
135
+ },
136
+ children: key
137
+ })
138
+ ]
139
+ }),
140
140
  children: /*#__PURE__*/ jsx(Pre, {
141
141
  lang: "bash",
142
142
  className: "shiki css-variables",
@@ -239,10 +239,8 @@ function SearchPanel({ focused, setFocused }) {
239
239
  children: renderSearchResultItem(currentSearchResult, query, isSearching)
240
240
  });
241
241
  }
242
- const tabValues = result.map((item)=>item.group);
243
242
  const renderKey = 'render';
244
243
  return /*#__PURE__*/ jsx(Tabs, {
245
- values: tabValues,
246
244
  className: "rp-search-panel__tabs",
247
245
  onChange: (index)=>{
248
246
  setResultTabIndex(index);
@@ -251,6 +249,7 @@ function SearchPanel({ focused, setFocused }) {
251
249
  keepDOM: false,
252
250
  ref: searchResultTabRef,
253
251
  children: result.map((item)=>/*#__PURE__*/ jsxs(Tab, {
252
+ label: item.group,
254
253
  children: [
255
254
  item.renderType === RenderType.Default && renderSearchResultItem(item.result, query, isSearching),
256
255
  item.renderType === RenderType.Custom && __rspack_external_virtual_search_hooks_9d01d01f[renderKey](item.result)
@@ -28,6 +28,7 @@ function SidebarItemRaw({ active, text, tag, link, context, className, left, rig
28
28
  ref: ref,
29
29
  children: [
30
30
  /*#__PURE__*/ jsx("span", {
31
+ className: "rp-doc",
31
32
  ...renderInlineMarkdown(text)
32
33
  }),
33
34
  left
@@ -1,16 +1,17 @@
1
1
  import { type ReactElement, type ReactNode } from 'react';
2
2
  import './index.scss';
3
3
  type TabItem = {
4
- label?: string | ReactNode;
4
+ label: ReactNode;
5
+ value: string;
5
6
  disabled?: boolean;
6
- content?: ReactNode;
7
7
  };
8
8
  export interface TabsProps {
9
- values?: ReactNode[] | ReadonlyArray<ReactNode> | TabItem[];
9
+ values?: ReadonlyArray<TabItem>;
10
10
  /**
11
11
  * @default 0
12
12
  */
13
13
  defaultIndex?: number;
14
+ defaultValue?: string;
14
15
  onChange?: (index: number) => void;
15
16
  children: ReactNode;
16
17
  /**
@@ -29,7 +30,10 @@ export interface TabsProps {
29
30
  contentItemClassName?: string;
30
31
  }
31
32
  export declare const Tabs: import("react").ForwardRefExoticComponent<TabsProps & import("react").RefAttributes<HTMLDivElement>>;
32
- export type TabProps = Pick<TabItem, 'label' | 'disabled'> & {
33
+ export type TabProps = {
34
+ label?: ReactNode;
35
+ value?: string;
36
+ disabled?: boolean;
33
37
  children: ReactNode;
34
38
  };
35
39
  export declare function Tab({ children }: TabProps): ReactElement;
@@ -3,18 +3,19 @@ import { useStorageValue } from "@rspress/core/theme";
3
3
  import clsx from "clsx";
4
4
  import { Children, forwardRef, isValidElement, useMemo, useState } from "react";
5
5
  import "./index.css";
6
- function getTabValuesFromChildren(children, defaultValues) {
7
- if (defaultValues?.every((item)=>isTabItem(item) && item.content)) return defaultValues;
8
- if (defaultValues && defaultValues.length > 0) return defaultValues.map((item, index)=>{
9
- if (isTabItem(item)) return item;
6
+ function getTabValuesFromChildren(children, values) {
7
+ if (values && values.length > 0) return values.map((item, index)=>{
8
+ const content = children.find((child)=>child.props?.value === item.value) ?? children[index];
10
9
  return {
11
- label: item,
12
- content: children[index]
10
+ ...item,
11
+ content
13
12
  };
14
13
  });
15
14
  return Children.map(children, (child, index)=>{
16
15
  if (/*#__PURE__*/ isValidElement(child)) return {
17
16
  label: child.props?.label || void 0,
17
+ value: child.props?.value,
18
+ disabled: child.props?.disabled,
18
19
  content: children[index]
19
20
  };
20
21
  return {
@@ -23,17 +24,13 @@ function getTabValuesFromChildren(children, defaultValues) {
23
24
  };
24
25
  });
25
26
  }
26
- function isTabItem(item) {
27
- if (item && 'object' == typeof item && 'label' in item) return true;
28
- return false;
29
- }
30
27
  const groupIdPrefix = 'rspress.tabs.';
31
28
  const Tabs = /*#__PURE__*/ forwardRef((props, ref)=>{
32
- const { values, defaultIndex, onChange, children: rawChildren, groupId, tabPosition = 'left', className, labelItemClassName, contentItemClassName, keepDOM = true } = props;
29
+ const { values, defaultIndex, defaultValue, onChange, children: rawChildren, groupId, tabPosition = 'left', className, labelItemClassName, contentItemClassName, keepDOM = true } = props;
33
30
  const children = Children.toArray(rawChildren).filter((child)=>!('string' == typeof child && '' === child.trim()) && /*#__PURE__*/ isValidElement(child));
34
31
  const tabValues = useMemo(()=>getTabValuesFromChildren(children, values), [
35
- values,
36
- children
32
+ children,
33
+ values
37
34
  ]);
38
35
  if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
39
36
  children: tabValues.map(({ label, content })=>/*#__PURE__*/ jsxs(Fragment, {
@@ -44,8 +41,10 @@ const Tabs = /*#__PURE__*/ forwardRef((props, ref)=>{
44
41
  ]
45
42
  }))
46
43
  });
47
- const [activeIndex, setActiveIndex] = useState(defaultIndex ?? 0);
48
- const [storageIndex, setStorageIndex] = useStorageValue(`${groupIdPrefix}${groupId}`, activeIndex.toString());
44
+ const defaultValueIndex = void 0 !== defaultValue ? tabValues.findIndex((item)=>item.value === defaultValue) : -1;
45
+ const initialActiveIndex = -1 === defaultValueIndex ? defaultIndex ?? 0 : defaultValueIndex;
46
+ const [activeIndex, setActiveIndex] = useState(initialActiveIndex);
47
+ const [storageIndex, setStorageIndex] = useStorageValue(`${groupIdPrefix}${groupId}`, initialActiveIndex.toString());
49
48
  const currentIndex = groupId ? Number(storageIndex) : activeIndex;
50
49
  return /*#__PURE__*/ jsxs("div", {
51
50
  className: clsx('rp-tabs', className),
@@ -56,23 +55,24 @@ const Tabs = /*#__PURE__*/ forwardRef((props, ref)=>{
56
55
  style: {
57
56
  justifyContent: 'center' === tabPosition ? 'center' : 'flex-start'
58
57
  },
59
- children: tabValues.map(({ label }, index)=>{
58
+ children: tabValues.map(({ label, value, disabled }, index)=>{
60
59
  const isActive = index === currentIndex;
61
60
  return /*#__PURE__*/ jsx("div", {
62
61
  className: clsx('rp-tabs__label__item', isActive ? 'rp-tabs__label__item--selected' : 'rp-tabs__label__item--not-selected', labelItemClassName),
63
62
  "data-index": index,
64
63
  onClick: ()=>{
64
+ if (disabled) return;
65
65
  onChange?.(index);
66
66
  if (groupId) setStorageIndex(index.toString());
67
67
  else setActiveIndex(index);
68
68
  },
69
69
  children: label
70
- }, 'string' == typeof label ? label : index);
70
+ }, value ?? index);
71
71
  })
72
72
  }) : null,
73
73
  /*#__PURE__*/ jsx("div", {
74
74
  className: "rp-tabs__content",
75
- children: tabValues.map(({ label, content }, index)=>{
75
+ children: tabValues.map(({ value, content }, index)=>{
76
76
  const isActive = index === currentIndex;
77
77
  if (!keepDOM && !isActive) return null;
78
78
  return /*#__PURE__*/ jsx("div", {
@@ -80,7 +80,7 @@ const Tabs = /*#__PURE__*/ forwardRef((props, ref)=>{
80
80
  "aria-hidden": !isActive,
81
81
  "data-index": index,
82
82
  children: content
83
- }, 'string' == typeof label ? label : index);
83
+ }, value ?? index);
84
84
  })
85
85
  })
86
86
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "2.0.11",
3
+ "version": "2.0.12",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -60,7 +60,7 @@
60
60
  "dependencies": {
61
61
  "@mdx-js/mdx": "^3.1.1",
62
62
  "@mdx-js/react": "^3.1.1",
63
- "@rsbuild/core": "^2.0.5",
63
+ "@rsbuild/core": "^2.0.6",
64
64
  "@rsbuild/plugin-react": "~2.0.0",
65
65
  "@shikijs/rehype": "^4.0.2",
66
66
  "@types/unist": "^3.0.3",
@@ -80,7 +80,7 @@
80
80
  "react-lazy-with-preload": "^2.2.1",
81
81
  "react-reconciler": "0.33.0",
82
82
  "react-render-to-markdown": "19.0.1",
83
- "react-router-dom": "^7.15.0",
83
+ "react-router-dom": "^7.15.1",
84
84
  "rehype-external-links": "^3.0.0",
85
85
  "rehype-raw": "^7.0.0",
86
86
  "remark-cjk-friendly": "^2.0.1",
@@ -95,13 +95,13 @@
95
95
  "unist-util-remove": "^4.0.0",
96
96
  "unist-util-visit": "^5.1.0",
97
97
  "unist-util-visit-children": "^3.0.0",
98
- "@rspress/shared": "2.0.11"
98
+ "@rspress/shared": "2.0.12"
99
99
  },
100
100
  "devDependencies": {
101
101
  "@microsoft/api-extractor": "^7.57.7",
102
102
  "@rsbuild/plugin-sass": "~1.5.2",
103
103
  "@rsbuild/plugin-svgr": "^2.0.2",
104
- "@rslib/core": "0.21.4",
104
+ "@rslib/core": "0.21.5",
105
105
  "@types/body-scroll-lock": "^3.1.2",
106
106
  "@types/hast": "^3.0.4",
107
107
  "@types/mdast": "^4.0.4",
@@ -127,7 +127,7 @@
127
127
  "tinyglobby": "^0.2.16",
128
128
  "tinypool": "^1.1.1",
129
129
  "ts-json-schema-generator": "^2.9.0",
130
- "typescript": "^5.8.2",
130
+ "typescript": "^6.0.3",
131
131
  "vfile": "^6.0.3",
132
132
  "@rspress/config": "1.0.0"
133
133
  },
File without changes