@docusaurus/theme-classic 0.0.0-4622 → 0.0.0-4625

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.
@@ -7,8 +7,8 @@
7
7
  import React, {useMemo} from 'react';
8
8
  import {
9
9
  useThemeConfig,
10
- useTOCFilter,
11
10
  useTOCHighlight,
11
+ useFilteredAndTreeifiedTOC,
12
12
  } from '@docusaurus/theme-common'; // Recursive component rendering the toc tree
13
13
 
14
14
  /* eslint-disable jsx-a11y/control-has-associated-label */
@@ -56,7 +56,7 @@ export default function TOCItems({
56
56
  minHeadingLevelOption ?? themeConfig.tableOfContents.minHeadingLevel;
57
57
  const maxHeadingLevel =
58
58
  maxHeadingLevelOption ?? themeConfig.tableOfContents.maxHeadingLevel;
59
- const tocFiltered = useTOCFilter({
59
+ const tocTree = useFilteredAndTreeifiedTOC({
60
60
  toc,
61
61
  minHeadingLevel,
62
62
  maxHeadingLevel,
@@ -76,7 +76,7 @@ export default function TOCItems({
76
76
  useTOCHighlight(tocHighlightConfig);
77
77
  return (
78
78
  <TOCItemList
79
- toc={tocFiltered}
79
+ toc={tocTree}
80
80
  className={className}
81
81
  linkClassName={linkClassName}
82
82
  {...props}
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, {useState, useRef, memo} from 'react';
7
+ import React, {useState, useRef, useEffect, memo} from 'react';
8
8
  import {useThemeConfig} from '@docusaurus/theme-common';
9
9
  import useIsBrowser from '@docusaurus/useIsBrowser';
10
10
  import {translate} from '@docusaurus/Translate';
@@ -17,6 +17,9 @@ const ToggleComponent = memo(
17
17
  const [checked, setChecked] = useState(defaultChecked);
18
18
  const [focused, setFocused] = useState(false);
19
19
  const inputRef = useRef(null);
20
+ useEffect(() => {
21
+ setChecked(defaultChecked);
22
+ }, [defaultChecked]);
20
23
  return (
21
24
  <div
22
25
  className={clsx(styles.toggle, className, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-4622",
3
+ "version": "0.0.0-4625",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -21,15 +21,15 @@
21
21
  "format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
22
22
  },
23
23
  "dependencies": {
24
- "@docusaurus/core": "0.0.0-4622",
25
- "@docusaurus/plugin-content-blog": "0.0.0-4622",
26
- "@docusaurus/plugin-content-docs": "0.0.0-4622",
27
- "@docusaurus/plugin-content-pages": "0.0.0-4622",
28
- "@docusaurus/theme-common": "0.0.0-4622",
29
- "@docusaurus/theme-translations": "0.0.0-4622",
30
- "@docusaurus/utils": "0.0.0-4622",
31
- "@docusaurus/utils-common": "0.0.0-4622",
32
- "@docusaurus/utils-validation": "0.0.0-4622",
24
+ "@docusaurus/core": "0.0.0-4625",
25
+ "@docusaurus/plugin-content-blog": "0.0.0-4625",
26
+ "@docusaurus/plugin-content-docs": "0.0.0-4625",
27
+ "@docusaurus/plugin-content-pages": "0.0.0-4625",
28
+ "@docusaurus/theme-common": "0.0.0-4625",
29
+ "@docusaurus/theme-translations": "0.0.0-4625",
30
+ "@docusaurus/utils": "0.0.0-4625",
31
+ "@docusaurus/utils-common": "0.0.0-4625",
32
+ "@docusaurus/utils-validation": "0.0.0-4625",
33
33
  "@mdx-js/react": "^1.6.22",
34
34
  "clsx": "^1.1.1",
35
35
  "copy-text-to-clipboard": "^3.0.1",
@@ -42,8 +42,8 @@
42
42
  "rtlcss": "^3.3.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@docusaurus/module-type-aliases": "0.0.0-4622",
46
- "@docusaurus/types": "0.0.0-4622",
45
+ "@docusaurus/module-type-aliases": "0.0.0-4625",
46
+ "@docusaurus/types": "0.0.0-4625",
47
47
  "@types/mdx-js__react": "^1.5.5",
48
48
  "@types/prismjs": "^1.26.0",
49
49
  "@types/rtlcss": "^3.1.2",
@@ -59,5 +59,5 @@
59
59
  "engines": {
60
60
  "node": ">=14"
61
61
  },
62
- "gitHead": "88fa597b10a32d3f2e3cff963af8337e66f89a13"
62
+ "gitHead": "db97af5476fb6b852ff07b1147a8d5a10a102e10"
63
63
  }
@@ -7,12 +7,12 @@
7
7
 
8
8
  import React, {useMemo} from 'react';
9
9
  import type {Props} from '@theme/TOCItems';
10
- import type {TOCItem} from '@docusaurus/types';
11
10
  import {
12
11
  type TOCHighlightConfig,
12
+ type TOCTreeNode,
13
13
  useThemeConfig,
14
- useTOCFilter,
15
14
  useTOCHighlight,
15
+ useFilteredAndTreeifiedTOC,
16
16
  } from '@docusaurus/theme-common';
17
17
 
18
18
  // Recursive component rendering the toc tree
@@ -23,7 +23,7 @@ function TOCItemList({
23
23
  linkClassName,
24
24
  isChild,
25
25
  }: {
26
- readonly toc: readonly TOCItem[];
26
+ readonly toc: readonly TOCTreeNode[];
27
27
  readonly className: string;
28
28
  readonly linkClassName: string | null;
29
29
  readonly isChild?: boolean;
@@ -70,7 +70,11 @@ export default function TOCItems({
70
70
  const maxHeadingLevel =
71
71
  maxHeadingLevelOption ?? themeConfig.tableOfContents.maxHeadingLevel;
72
72
 
73
- const tocFiltered = useTOCFilter({toc, minHeadingLevel, maxHeadingLevel});
73
+ const tocTree = useFilteredAndTreeifiedTOC({
74
+ toc,
75
+ minHeadingLevel,
76
+ maxHeadingLevel,
77
+ });
74
78
 
75
79
  const tocHighlightConfig: TOCHighlightConfig | undefined = useMemo(() => {
76
80
  if (linkClassName && linkActiveClassName) {
@@ -87,7 +91,7 @@ export default function TOCItems({
87
91
 
88
92
  return (
89
93
  <TOCItemList
90
- toc={tocFiltered}
94
+ toc={tocTree}
91
95
  className={className}
92
96
  linkClassName={linkClassName}
93
97
  {...props}
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React, {useState, useRef, memo} from 'react';
8
+ import React, {useState, useRef, useEffect, memo} from 'react';
9
9
  import type {Props} from '@theme/Toggle';
10
10
  import {useThemeConfig, type ColorModeConfig} from '@docusaurus/theme-common';
11
11
  import useIsBrowser from '@docusaurus/useIsBrowser';
@@ -31,6 +31,10 @@ const ToggleComponent = memo(
31
31
  const [focused, setFocused] = useState(false);
32
32
  const inputRef = useRef<HTMLInputElement>(null);
33
33
 
34
+ useEffect(() => {
35
+ setChecked(defaultChecked);
36
+ }, [defaultChecked]);
37
+
34
38
  return (
35
39
  <div
36
40
  className={clsx(styles.toggle, className, {