This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

View File

@@ -0,0 +1,64 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { type Dispatch, type SetStateAction, type ReactNode } from 'react';
/**
* This hook is a very thin wrapper around a `useState`.
*/
export declare function useCollapsible({ initialState, }: {
/** The initial state. Will be non-collapsed by default. */
initialState?: boolean | (() => boolean);
}): {
collapsed: boolean;
setCollapsed: Dispatch<SetStateAction<boolean>>;
toggleCollapsed: () => void;
};
type CollapsibleAnimationConfig = {
duration?: number;
easing?: string;
};
type CollapsibleElementType = React.ElementType<Pick<React.HTMLAttributes<unknown>, 'className' | 'onTransitionEnd' | 'style'>>;
type CollapsibleBaseProps = {
/** The actual DOM element to be used in the markup. */
as?: CollapsibleElementType;
/** Initial collapsed state. */
collapsed: boolean;
children: ReactNode;
/** Configuration of animation, like `duration` and `easing` */
animation?: CollapsibleAnimationConfig;
/**
* A callback fired when the collapse transition animation ends. Receives
* the **new** collapsed state: e.g. when
* expanding, `collapsed` will be `false`. You can use this for some "cleanup"
* like applying new styles when the container is fully expanded.
*/
onCollapseTransitionEnd?: (collapsed: boolean) => void;
/** Class name for the underlying DOM element. */
className?: string;
/**
* This is mostly useful for details/summary component where ssrStyle is not
* needed (as details are hidden natively) and can mess up with the browser's
* native behavior when JS fails to load or is disabled
*/
disableSSRStyle?: boolean;
};
type CollapsibleProps = CollapsibleBaseProps & {
/**
* Delay rendering of the content till first expansion. Marked as required to
* force us to think if content should be server-rendered or not. This has
* perf impact since it reduces html file sizes, but could undermine SEO.
* @see https://github.com/facebook/docusaurus/issues/4753
*/
lazy: boolean;
};
/**
* A headless component providing smooth and uniform collapsing behavior. The
* component will be invisible (zero height) when collapsed. Doesn't provide
* interactivity by itself: collapse state is toggled through props.
*/
export declare function Collapsible({ lazy, ...props }: CollapsibleProps): JSX.Element;
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Collapsible/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAMZ,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAOf;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,YAAY,GACb,EAAE;IACD,2DAA2D;IAC3D,YAAY,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;CAC1C,GAAG;IACF,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAChD,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B,CAYA;AAqCD,KAAK,0BAA0B,GAAG;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAoEF,KAAK,sBAAsB,GAAG,KAAK,CAAC,WAAW,CAC7C,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,iBAAiB,GAAG,OAAO,CAAC,CAC/E,CAAC;AAaF,KAAK,oBAAoB,GAAG;IAC1B,uDAAuD;IACvD,EAAE,CAAC,EAAE,sBAAsB,CAAC;IAC5B,+BAA+B;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,0BAA0B,CAAC;IACvC;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACvD,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAyDF,KAAK,gBAAgB,GAAG,oBAAoB,GAAG;IAC7C;;;;;OAKG;IACH,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAC,IAAI,EAAE,GAAG,KAAK,EAAC,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAG3E"}

View File

@@ -0,0 +1,157 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useState, useEffect, useRef, useCallback, } from 'react';
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
import useIsomorphicLayoutEffect from '@docusaurus/useIsomorphicLayoutEffect';
import { prefersReducedMotion } from '../../utils/accessibilityUtils';
const DefaultAnimationEasing = 'ease-in-out';
/**
* This hook is a very thin wrapper around a `useState`.
*/
export function useCollapsible({ initialState, }) {
const [collapsed, setCollapsed] = useState(initialState ?? false);
const toggleCollapsed = useCallback(() => {
setCollapsed((expanded) => !expanded);
}, []);
return {
collapsed,
setCollapsed,
toggleCollapsed,
};
}
const CollapsedStyles = {
display: 'none',
overflow: 'hidden',
height: '0px',
};
const ExpandedStyles = {
display: 'block',
overflow: 'visible',
height: 'auto',
};
function applyCollapsedStyle(el, collapsed) {
const collapsedStyles = collapsed ? CollapsedStyles : ExpandedStyles;
el.style.display = collapsedStyles.display;
el.style.overflow = collapsedStyles.overflow;
el.style.height = collapsedStyles.height;
}
/*
Lex111: Dynamic transition duration is used in Material design, this technique
is good for a large number of items.
https://material.io/archive/guidelines/motion/duration-easing.html#duration-easing-dynamic-durations
https://github.com/mui-org/material-ui/blob/e724d98eba018e55e1a684236a2037e24bcf050c/packages/material-ui/src/styles/createTransitions.js#L40-L43
*/
function getAutoHeightDuration(height) {
if (prefersReducedMotion()) {
// Not using 0 because it prevents onTransitionEnd to fire and bubble up :/
// See https://github.com/facebook/docusaurus/pull/8906
return 1;
}
const constant = height / 36;
return Math.round((4 + 15 * constant ** 0.25 + constant / 5) * 10);
}
function useCollapseAnimation({ collapsibleRef, collapsed, animation, }) {
const mounted = useRef(false);
useEffect(() => {
const el = collapsibleRef.current;
function getTransitionStyles() {
const height = el.scrollHeight;
const duration = animation?.duration ?? getAutoHeightDuration(height);
const easing = animation?.easing ?? DefaultAnimationEasing;
return {
transition: `height ${duration}ms ${easing}`,
height: `${height}px`,
};
}
function applyTransitionStyles() {
const transitionStyles = getTransitionStyles();
el.style.transition = transitionStyles.transition;
el.style.height = transitionStyles.height;
}
// On mount, we just apply styles, no animated transition
if (!mounted.current) {
applyCollapsedStyle(el, collapsed);
mounted.current = true;
return undefined;
}
el.style.willChange = 'height';
function startAnimation() {
const animationFrame = requestAnimationFrame(() => {
// When collapsing
if (collapsed) {
applyTransitionStyles();
requestAnimationFrame(() => {
el.style.height = CollapsedStyles.height;
el.style.overflow = CollapsedStyles.overflow;
});
}
// When expanding
else {
el.style.display = 'block';
requestAnimationFrame(() => {
applyTransitionStyles();
});
}
});
return () => cancelAnimationFrame(animationFrame);
}
return startAnimation();
}, [collapsibleRef, collapsed, animation]);
}
/**
* Prevent hydration layout shift before animations are handled imperatively
* with JS
*/
function getSSRStyle(collapsed) {
if (ExecutionEnvironment.canUseDOM) {
return undefined;
}
return collapsed ? CollapsedStyles : ExpandedStyles;
}
function CollapsibleBase({ as: As = 'div', collapsed, children, animation, onCollapseTransitionEnd, className, disableSSRStyle, }) {
const collapsibleRef = useRef(null);
useCollapseAnimation({ collapsibleRef, collapsed, animation });
return (<As
// @ts-expect-error: the "too complicated type" is produced from
// "CollapsibleElementType" being a huge union
ref={collapsibleRef} // Refs are contravariant, which is not expressible in TS
style={disableSSRStyle ? undefined : getSSRStyle(collapsed)} onTransitionEnd={(e) => {
if (e.propertyName !== 'height') {
return;
}
applyCollapsedStyle(collapsibleRef.current, collapsed);
onCollapseTransitionEnd?.(collapsed);
}} className={className}>
{children}
</As>);
}
function CollapsibleLazy({ collapsed, ...props }) {
const [mounted, setMounted] = useState(!collapsed);
// Updated in effect so that first expansion transition can work
const [lazyCollapsed, setLazyCollapsed] = useState(collapsed);
useIsomorphicLayoutEffect(() => {
if (!collapsed) {
setMounted(true);
}
}, [collapsed]);
useIsomorphicLayoutEffect(() => {
if (mounted) {
setLazyCollapsed(collapsed);
}
}, [mounted, collapsed]);
return mounted ? (<CollapsibleBase {...props} collapsed={lazyCollapsed}/>) : null;
}
/**
* A headless component providing smooth and uniform collapsing behavior. The
* component will be invisible (zero height) when collapsed. Doesn't provide
* interactivity by itself: collapse state is toggled through props.
*/
export function Collapsible({ lazy, ...props }) {
const Comp = lazy ? CollapsibleLazy : CollapsibleBase;
return <Comp {...props}/>;
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Collapsible/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,SAAS,EACT,MAAM,EACN,WAAW,GAKZ,MAAM,OAAO,CAAC;AACf,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,yBAAyB,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,EAC7B,YAAY,GAIb;IAKC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,YAAY,IAAI,KAAK,CAAC,CAAC;IAElE,MAAM,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE;QACvC,YAAY,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,SAAS;QACT,YAAY;QACZ,eAAe;KAChB,CAAC;AACJ,CAAC;AAED,MAAM,eA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K,EAAuB;IAClE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC;IACnD,gEAAgE;IAChE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAE9D,yBAAyB,CAAC,GAAG,EAAE;QAC7B,IAAI,CAAC,SAAS,EAAE;YACd,UAAU,CAAC,IAAI,CAAC,CAAC;SAClB;IACH,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,yBAAyB,CAAC,GAAG,EAAE;QAC7B,IAAI,OAAO,EAAE;YACX,gBAAgB,CAAC,SAAS,CAAC,CAAC;SAC7B;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;IAEzB,OAAO,OAAO,CAAC,CAAC,CAAC,CACf,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,EAAG,CACzD,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,EAAC,IAAI,EAAE,GAAG,KAAK,EAAmB;IAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC;IACtD,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AAC7B,CAAC"}

View File

@@ -0,0 +1,20 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { type ComponentProps, type ReactElement } from 'react';
export type DetailsProps = {
/**
* Summary is provided as props, optionally including the wrapping
* `<summary>` tag
*/
summary?: ReactElement | string;
} & ComponentProps<'details'>;
/**
* A mostly un-styled `<details>` element with smooth collapsing. Provides some
* very lightweight styles, but you should bring your UI.
*/
export declare function Details({ summary, children, ...props }: DetailsProps): JSX.Element;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Details/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAGZ,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,OAAO,CAAC;AAqBf,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;CACjC,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;AAE9B;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,CAsE5B"}

View File

@@ -0,0 +1,78 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useRef, useState, } from 'react';
import clsx from 'clsx';
import useBrokenLinks from '@docusaurus/useBrokenLinks';
import useIsBrowser from '@docusaurus/useIsBrowser';
import { useCollapsible, Collapsible } from '../Collapsible';
import styles from './styles.module.css';
function isInSummary(node) {
if (!node) {
return false;
}
return node.tagName === 'SUMMARY' || isInSummary(node.parentElement);
}
function hasParent(node, parent) {
if (!node) {
return false;
}
return node === parent || hasParent(node.parentElement, parent);
}
/**
* A mostly un-styled `<details>` element with smooth collapsing. Provides some
* very lightweight styles, but you should bring your UI.
*/
export function Details({ summary, children, ...props }) {
useBrokenLinks().collectAnchor(props.id);
const isBrowser = useIsBrowser();
const detailsRef = useRef(null);
const { collapsed, setCollapsed } = useCollapsible({
initialState: !props.open,
});
// Use a separate state for the actual details prop, because it must be set
// only after animation completes, otherwise close animations won't work
const [open, setOpen] = useState(props.open);
const summaryElement = React.isValidElement(summary) ? (summary) : (<summary>{summary ?? 'Details'}</summary>);
return (
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
<details {...props} ref={detailsRef} open={open} data-collapsed={collapsed} className={clsx(styles.details, isBrowser && styles.isBrowser, props.className)} onMouseDown={(e) => {
const target = e.target;
// Prevent a double-click to highlight summary text
if (isInSummary(target) && e.detail > 1) {
e.preventDefault();
}
}} onClick={(e) => {
e.stopPropagation(); // For isolation of multiple nested details/summary
const target = e.target;
const shouldToggle = isInSummary(target) && hasParent(target, detailsRef.current);
if (!shouldToggle) {
return;
}
e.preventDefault();
if (collapsed) {
setCollapsed(false);
setOpen(true);
}
else {
setCollapsed(true);
// Don't do this, it breaks close animation!
// setOpen(false);
}
}}>
{summaryElement}
<Collapsible lazy={false} // Content might matter for SEO in this case
collapsed={collapsed} disableSSRStyle // Allows component to work fine even with JS disabled!
onCollapseTransitionEnd={(newCollapsed) => {
setCollapsed(newCollapsed);
setOpen(!newCollapsed);
}}>
<div className={styles.collapsibleContent}>{children}</div>
</Collapsible>
</details>);
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Details/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAC;AACf,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,cAAc,MAAM,4BAA4B,CAAC;AACxD,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,cAAc,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3D,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC,SAAS,WAAW,CAAC,IAAwB;IAC3C,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,KAAK,CAAC;KACd;IACD,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,SAAS,CAAC,IAAwB,EAAE,M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 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/*
CSS variables, meant to be overridden by final theme
*/
.details {
--docusaurus-details-summary-arrow-size: 0.38rem;
--docusaurus-details-transition: transform 200ms ease;
--docusaurus-details-decoration-color: grey;
}
.details > summary {
position: relative;
cursor: pointer;
list-style: none;
padding-left: 1rem;
}
/* TODO: deprecation, need to remove this after Safari will support `::marker` */
.details > summary::-webkit-details-marker {
display: none;
}
.details > summary::before {
position: absolute;
top: 0.45rem;
left: 0;
/* CSS-only Arrow */
content: '';
border-width: var(--docusaurus-details-summary-arrow-size);
border-style: solid;
border-color: transparent transparent transparent
var(--docusaurus-details-decoration-color);
/* Arrow rotation anim */
transform: rotate(0deg);
transition: var(--docusaurus-details-transition);
transform-origin: calc(var(--docusaurus-details-summary-arrow-size) / 2) 50%;
}
/* When JS disabled/failed to load: we use the open property for arrow animation: */
.details[open]:not(.isBrowser) > summary::before,
/* When JS works: we use the data-attribute for arrow animation */
.details[data-collapsed='false'].isBrowser > summary::before {
transform: rotate(90deg);
}
.collapsibleContent {
margin-top: 1rem;
border-top: 1px solid var(--docusaurus-details-decoration-color);
padding-top: 1rem;
}
.collapsibleContent p:last-child {
margin-bottom: 0;
}
.details > summary > p:last-child {
margin-bottom: 0;
}

View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
declare const AllThemes: readonly ["light", "dark"];
type Theme = (typeof AllThemes)[number];
type RenderFn = ({ theme, className, }: {
theme: Theme;
className: string;
}) => React.ReactNode;
type Props = {
children: RenderFn;
className?: string;
};
/**
* Generic component to render anything themed in light/dark
* Note: it's preferable to use CSS for theming because this component
* will need to render all the variants during SSR to avoid a theme flash.
*
* Use this only when CSS customizations are not convenient or impossible.
* For example, rendering themed images or SVGs...
*
* @param className applied to all the variants
* @param children function to render a theme variant
* @constructor
*/
export default function ThemedComponent({ className, children, }: Props): JSX.Element;
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ThemedComponent/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,QAAA,MAAM,SAAS,4BAA6B,CAAC;AAE7C,KAAK,KAAK,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAExC,KAAK,QAAQ,GAAG,CAAC,EACf,KAAK,EACL,SAAS,GACV,EAAE;IACD,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,KAAK,KAAK,CAAC,SAAS,CAAC;AAEtB,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,SAAS,EACT,QAAQ,GACT,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CA8BrB"}

View File

@@ -0,0 +1,48 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import clsx from 'clsx';
import useIsBrowser from '@docusaurus/useIsBrowser';
import { useColorMode } from '../../contexts/colorMode';
import styles from './styles.module.css';
const AllThemes = ['light', 'dark'];
/**
* Generic component to render anything themed in light/dark
* Note: it's preferable to use CSS for theming because this component
* will need to render all the variants during SSR to avoid a theme flash.
*
* Use this only when CSS customizations are not convenient or impossible.
* For example, rendering themed images or SVGs...
*
* @param className applied to all the variants
* @param children function to render a theme variant
* @constructor
*/
export default function ThemedComponent({ className, children, }) {
const isBrowser = useIsBrowser();
const { colorMode } = useColorMode();
function getThemesToRender() {
if (isBrowser) {
return colorMode === 'dark' ? ['dark'] : ['light'];
}
// We need to render both components on the server / hydration to avoid:
// - a flash of wrong theme before hydration
// - React hydration mismatches
// See https://github.com/facebook/docusaurus/pull/3730
return ['light', 'dark'];
}
return (<>
{getThemesToRender().map((theme) => {
const themedElement = children({
theme,
className: clsx(className, styles.themedComponent, styles[`themedComponent--${theme}`]),
});
return <React.Fragment key={theme}>{themedElement}</React.Fragment>;
})}
</>);
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ThemedComponent/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAEtD,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,MAAM,CAAU,CAAC;AAiB7C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,SAAS,EACT,QAAQ,GACF;IACN,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,EAAC,SAAS,EAAC,GAAG,YAAY,EAAE,CAAC;IAEnC,SAAS,iBAAiB;QACxB,IAAI,SAAS,EAAE;YACb,OAAO,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SACpD;QACD,wEAAwE;QACxE,4CAA4C;QAC5C,+BAA+B;QAC/B,uDAAuD;QACvD,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,CACL,EACE;MAAA,CAAC,iBAAiB,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACjC,MAAM,aAAa,GAAG,QAAQ,CAAC;gBAC7B,KAAK;gBACL,SAAS,EAAE,IAAI,CACb,SAAS,EACT,MAAM,CAAC,eAAe,EACtB,MAAM,CAAC,oBAAoB,KAAK,EAAE,CAAC,CACpC;aACF,CAAC,CAAC;YACH,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtE,CAAC,CAAC,CACJ;IAAA,GAAG,CACJ,CAAC;AACJ,CAAC"}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
.themedComponent {
display: none;
}
[data-theme='light'] .themedComponent--light {
display: initial;
}
[data-theme='dark'] .themedComponent--dark {
display: initial;
}
/*
JS disabled??? Show light version by default => better than showing nothing
TODO bad, but we currently always show light mode when there's no data-theme
*/
html:not([data-theme]) .themedComponent--light {
display: initial;
}

View File

@@ -0,0 +1,22 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { type ReactNode } from 'react';
export declare const AnnouncementBarDismissStorageKey = "docusaurus.announcement.dismiss";
type ContextValue = {
/** Whether the announcement bar should be displayed. */
readonly isActive: boolean;
/**
* Callback fired when the user closes the announcement. Will be saved.
*/
readonly close: () => void;
};
export declare function AnnouncementBarProvider({ children, }: {
children: ReactNode;
}): JSX.Element;
export declare function useAnnouncementBar(): ContextValue;
export {};
//# sourceMappingURL=announcementBar.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"announcementBar.d.ts","sourceRoot":"","sources":["../../src/contexts/announcementBar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAMZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAMf,eAAO,MAAM,gCAAgC,oCACV,CAAC;AAapC,KAAK,YAAY,GAAG;IAClB,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;CAC5B,CAAC;AA8DF,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAGd;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAMjD"}

View File

@@ -0,0 +1,72 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useState, useEffect, useCallback, useMemo, useContext, } from 'react';
import useIsBrowser from '@docusaurus/useIsBrowser';
import { createStorageSlot } from '../utils/storageUtils';
import { ReactContextError } from '../utils/reactUtils';
import { useThemeConfig } from '../utils/useThemeConfig';
export const AnnouncementBarDismissStorageKey = 'docusaurus.announcement.dismiss';
const AnnouncementBarIdStorageKey = 'docusaurus.announcement.id';
const AnnouncementBarDismissStorage = createStorageSlot(AnnouncementBarDismissStorageKey);
const IdStorage = createStorageSlot(AnnouncementBarIdStorageKey);
const isDismissedInStorage = () => AnnouncementBarDismissStorage.get() === 'true';
const setDismissedInStorage = (bool) => AnnouncementBarDismissStorage.set(String(bool));
const Context = React.createContext(null);
function useContextValue() {
const { announcementBar } = useThemeConfig();
const isBrowser = useIsBrowser();
const [isClosed, setClosed] = useState(() => isBrowser
? // On client navigation: init with local storage value
isDismissedInStorage()
: // On server/hydration: always visible to prevent layout shifts (will be hidden with css if needed)
false);
// Update state after hydration
useEffect(() => {
setClosed(isDismissedInStorage());
}, []);
const handleClose = useCallback(() => {
setDismissedInStorage(true);
setClosed(true);
}, []);
useEffect(() => {
if (!announcementBar) {
return;
}
const { id } = announcementBar;
let viewedId = IdStorage.get();
// Retrocompatibility due to spelling mistake of default id
// see https://github.com/facebook/docusaurus/issues/3338
// cSpell:ignore annoucement
if (viewedId === 'annoucement-bar') {
viewedId = 'announcement-bar';
}
const isNewAnnouncement = id !== viewedId;
IdStorage.set(id);
if (isNewAnnouncement) {
setDismissedInStorage(false);
}
if (isNewAnnouncement || !isDismissedInStorage()) {
setClosed(false);
}
}, [announcementBar]);
return useMemo(() => ({
isActive: !!announcementBar && !isClosed,
close: handleClose,
}), [announcementBar, isClosed, handleClose]);
}
export function AnnouncementBarProvider({ children, }) {
const value = useContextValue();
return <Context.Provider value={value}>{children}</Context.Provider>;
}
export function useAnnouncementBar() {
const api = useContext(Context);
if (!api) {
throw new ReactContextError('AnnouncementBarProvider');
}
return api;
}
//# sourceMappingURL=announcementBar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"announcementBar.js","sourceRoot":"","sources":["../../src/contexts/announcementBar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,OAAO,EACP,UAAU,GAEX,MAAM,OAAO,CAAC;AACf,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAEvD,MAAM,CAAC,MAAM,gCAAgC,GAC3C,iCAAiC,CAAC;AACpC,MAAM,2BAA2B,GAAG,4BAA4B,CAAC;AAEjE,MAAM,6BAA6B,GAAG,iBAAiB,CACrD,gCAAgC,CACjC,CAAC;AACF,MAAM,SAAS,GAAG,iBAAiB,CAAC,2BAA2B,CAAC,CAAC;AAEjE,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAChC,6BAA6B,CAAC,GAAG,EAAE,KAAK,MAAM,CAAC;AACjD,MAAM,qBAAqB,GAAG,CAAC,IAAa,EAAE,EAAE,CAC9C,6BAA6B,CAAC,GAA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D,SAAS,CAAC,KAAK,CAAC,CAAC;SAClB;IACH,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAEtB,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,CAAC,CAAC,eAAe,IAAI,CAAC,QAAQ;QACxC,KAAK,EAAE,WAAW;KACnB,CAAC,EACF,CAAC,eAAe,EAAE,QAAQ,EAAE,WAAW,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,EACtC,QAAQ,GAGT;IACC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;KACxD;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}

View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { type ReactNode } from 'react';
import type { PropBlogPostContent } from '@docusaurus/plugin-content-blog';
/**
* The React context value returned by the `useBlogPost()` hook.
* It contains useful data related to the currently browsed blog post.
*/
export type BlogPostContextValue = Pick<PropBlogPostContent, 'metadata' | 'frontMatter' | 'assets' | 'toc'> & {
readonly isBlogPostPage: boolean;
};
/**
* This is a very thin layer around the `content` received from the MDX loader.
* It provides metadata about the blog post to the children tree.
*/
export declare function BlogPostProvider({ children, content, isBlogPostPage, }: {
children: ReactNode;
content: PropBlogPostContent;
isBlogPostPage?: boolean;
}): JSX.Element;
/**
* Returns the data of the currently browsed blog post. Gives access to
* front matter, metadata, TOC, etc.
* When swizzling a low-level component (e.g. the "Edit this page" link)
* and you need some extra metadata, you don't have to drill the props
* all the way through the component tree: simply use this hook instead.
*/
export declare function useBlogPost(): BlogPostContextValue;
//# sourceMappingURL=blogPost.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"blogPost.d.ts","sourceRoot":"","sources":["../../src/contexts/blogPost.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAU,KAAK,SAAS,EAAa,MAAM,OAAO,CAAC;AAGjE,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAEzE;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,mBAAmB,EACnB,UAAU,GAAG,aAAa,GAAG,QAAQ,GAAG,KAAK,CAC9C,GAAG;IACF,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC,CAAC;AA4BF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,OAAO,EACP,cAAsB,GACvB,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,GAAG,CAAC,OAAO,CAGd;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,oBAAoB,CAMlD"}

View File

@@ -0,0 +1,46 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useMemo, useContext } from 'react';
import { ReactContextError } from '../utils/reactUtils';
const Context = React.createContext(null);
/**
* Note: we don't use `PropBlogPostContent` as context value on purpose.
* Metadata is currently stored inside the MDX component, but we may want to
* change that in the future.
*/
function useContextValue({ content, isBlogPostPage, }) {
return useMemo(() => ({
metadata: content.metadata,
frontMatter: content.frontMatter,
assets: content.assets,
toc: content.toc,
isBlogPostPage,
}), [content, isBlogPostPage]);
}
/**
* This is a very thin layer around the `content` received from the MDX loader.
* It provides metadata about the blog post to the children tree.
*/
export function BlogPostProvider({ children, content, isBlogPostPage = false, }) {
const contextValue = useContextValue({ content, isBlogPostPage });
return <Context.Provider value={contextValue}>{children}</Context.Provider>;
}
/**
* Returns the data of the currently browsed blog post. Gives access to
* front matter, metadata, TOC, etc.
* When swizzling a low-level component (e.g. the "Edit this page" link)
* and you need some extra metadata, you don't have to drill the props
* all the way through the component tree: simply use this hook instead.
*/
export function useBlogPost() {
const blogPost = useContext(Context);
if (blogPost === null) {
throw new ReactContextError('BlogPostProvider');
}
return blogPost;
}
//# sourceMappingURL=blogPost.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"blogPost.js","sourceRoot":"","sources":["../../src/contexts/blogPost.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAAC,OAAO,EAAkB,UAAU,EAAC,MAAM,OAAO,CAAC;AACjE,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAetD,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAA8B,IAAI,CAAC,CAAC;AAEvE;;;;GAIG;AACH,SAAS,eAAe,CAAC,EACvB,OAAO,EACP,cAAc,GAIf;IACC,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,cAAc;KACf,CAAC,EACF,CAAC,OAAO,EAAE,cAAc,CAAC,CAC1B,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,QAAQ,EACR,OAAO,EACP,cAAc,GAAG,KAAK,GAKvB;IACC,MAAM,YAAY,GAAG,eAAe,CAAC,EAAC,OAAO,EAAE,cAAc,EAAC,CAAC,CAAC;IAChE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,QAAQ,KAAK,IAAI,EAAE;QACrB,MAAM,IAAI,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;KACjD;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}

View File

@@ -0,0 +1,27 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { type ReactNode } from 'react';
type ContextValue = {
/** Current color mode. */
readonly colorMode: ColorMode;
/** Set new color mode. */
readonly setColorMode: (colorMode: ColorMode) => void;
readonly isDarkTheme: boolean;
readonly setLightTheme: () => void;
readonly setDarkTheme: () => void;
};
declare const ColorModes: {
readonly light: "light";
readonly dark: "dark";
};
export type ColorMode = (typeof ColorModes)[keyof typeof ColorModes];
export declare function ColorModeProvider({ children, }: {
children: ReactNode;
}): JSX.Element;
export declare function useColorMode(): ContextValue;
export {};
//# sourceMappingURL=colorMode.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"colorMode.d.ts","sourceRoot":"","sources":["../../src/contexts/colorMode.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAMf,KAAK,YAAY,GAAG;IAClB,0BAA0B;IAC1B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,0BAA0B;IAC1B,QAAQ,CAAC,YAAY,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;IAGtD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,IAAI,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC;CACnC,CAAC;AAOF,QAAA,MAAM,UAAU;;;CAGN,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAwIrE,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAGd;AAED,wBAAgB,YAAY,IAAI,YAAY,CAS3C"}

View File

@@ -0,0 +1,132 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useState, useCallback, useEffect, useContext, useMemo, useRef, } from 'react';
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
import { ReactContextError } from '../utils/reactUtils';
import { createStorageSlot } from '../utils/storageUtils';
import { useThemeConfig } from '../utils/useThemeConfig';
const Context = React.createContext(undefined);
const ColorModeStorageKey = 'theme';
const ColorModeStorage = createStorageSlot(ColorModeStorageKey);
const ColorModes = {
light: 'light',
dark: 'dark',
};
// Ensure to always return a valid colorMode even if input is invalid
const coerceToColorMode = (colorMode) => colorMode === ColorModes.dark ? ColorModes.dark : ColorModes.light;
const getInitialColorMode = (defaultMode) => ExecutionEnvironment.canUseDOM
? coerceToColorMode(document.documentElement.getAttribute('data-theme'))
: coerceToColorMode(defaultMode);
const storeColorMode = (newColorMode) => {
ColorModeStorage.set(coerceToColorMode(newColorMode));
};
function useContextValue() {
const { colorMode: { defaultMode, disableSwitch, respectPrefersColorScheme }, } = useThemeConfig();
const [colorMode, setColorModeState] = useState(getInitialColorMode(defaultMode));
useEffect(() => {
// A site is deployed without disableSwitch
// => User visits the site and has a persisted value
// => Site later enabled disableSwitch
// => Clear the previously stored value to apply the site's setting
if (disableSwitch) {
ColorModeStorage.del();
}
}, [disableSwitch]);
const setColorMode = useCallback((newColorMode, options = {}) => {
const { persist = true } = options;
if (newColorMode) {
setColorModeState(newColorMode);
if (persist) {
storeColorMode(newColorMode);
}
}
else {
if (respectPrefersColorScheme) {
setColorModeState(window.matchMedia('(prefers-color-scheme: dark)').matches
? ColorModes.dark
: ColorModes.light);
}
else {
setColorModeState(defaultMode);
}
ColorModeStorage.del();
}
}, [respectPrefersColorScheme, defaultMode]);
useEffect(() => {
document.documentElement.setAttribute('data-theme', coerceToColorMode(colorMode));
}, [colorMode]);
useEffect(() => {
if (disableSwitch) {
return undefined;
}
const onChange = (e) => {
if (e.key !== ColorModeStorageKey) {
return;
}
const storedColorMode = ColorModeStorage.get();
if (storedColorMode !== null) {
setColorMode(coerceToColorMode(storedColorMode));
}
};
window.addEventListener('storage', onChange);
return () => window.removeEventListener('storage', onChange);
}, [disableSwitch, setColorMode]);
// PCS is coerced to light mode when printing, which causes the color mode to
// be reset to dark when exiting print mode, disregarding user settings. When
// the listener fires only because of a print/screen switch, we don't change
// color mode. See https://github.com/facebook/docusaurus/pull/6490
const previousMediaIsPrint = useRef(false);
useEffect(() => {
if (disableSwitch && !respectPrefersColorScheme) {
return undefined;
}
const mql = window.matchMedia('(prefers-color-scheme: dark)');
const onChange = () => {
if (window.matchMedia('print').matches || previousMediaIsPrint.current) {
previousMediaIsPrint.current = window.matchMedia('print').matches;
return;
}
setColorMode(null);
};
mql.addListener(onChange);
return () => mql.removeListener(onChange);
}, [setColorMode, disableSwitch, respectPrefersColorScheme]);
return useMemo(() => ({
colorMode,
setColorMode,
get isDarkTheme() {
if (process.env.NODE_ENV === 'development') {
console.error('`useColorMode().isDarkTheme` is deprecated. Please use `useColorMode().colorMode === "dark"` instead.');
}
return colorMode === ColorModes.dark;
},
setLightTheme() {
if (process.env.NODE_ENV === 'development') {
console.error('`useColorMode().setLightTheme` is deprecated. Please use `useColorMode().setColorMode("light")` instead.');
}
setColorMode(ColorModes.light);
},
setDarkTheme() {
if (process.env.NODE_ENV === 'development') {
console.error('`useColorMode().setDarkTheme` is deprecated. Please use `useColorMode().setColorMode("dark")` instead.');
}
setColorMode(ColorModes.dark);
},
}), [colorMode, setColorMode]);
}
export function ColorModeProvider({ children, }) {
const value = useContextValue();
return <Context.Provider value={value}>{children}</Context.Provider>;
}
export function useColorMode() {
const context = useContext(Context);
if (context == null) {
throw new ReactContextError('ColorModeProvider', 'Please see https://docusaurus.io/docs/api/themes/configuration#use-color-mode.');
}
return context;
}
//# sourceMappingURL=colorMode.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"colorMode.js","sourceRoot":"","sources":["../../src/contexts/colorMode.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EACV,OAAO,EACP,MAAM,GAEP,MAAM,OAAO,CAAC;AACf,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAcvD,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAA2B,SAAS,CAAC,CAAC;AAEzE,MAAM,mBAAmB,GAAG,OAAO,CAAC;AACpC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;AAEhE,MAAM,UAAU,GAAG;IACjB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACJ,CAAC;AAIX,qEAAqE;AACrE,MAAM,iBAAiB,GAAG,CAAC,SAAyB,EAAa,EAAE,CACjE,SAAS,KAAK,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;AAErE,MAAM,mBAAmB,GAAG,CAAC,WAAkC,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G,eAAe,EAAE,CAAC;IAChC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,OAAO,IAAI,IAAI,EAAE;QACnB,MAAM,IAAI,iBAAiB,CACzB,mBAAmB,EACnB,gFAAgF,CACjF,CAAC;KACH;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}

View File

@@ -0,0 +1,30 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { type ReactNode } from 'react';
import type { PropDocContent } from '@docusaurus/plugin-content-docs';
/**
* The React context value returned by the `useDoc()` hook.
* It contains useful data related to the currently browsed doc.
*/
export type DocContextValue = Pick<PropDocContent, 'metadata' | 'frontMatter' | 'toc' | 'assets' | 'contentTitle'>;
/**
* This is a very thin layer around the `content` received from the MDX loader.
* It provides metadata about the doc to the children tree.
*/
export declare function DocProvider({ children, content, }: {
children: ReactNode;
content: PropDocContent;
}): JSX.Element;
/**
* Returns the data of the currently browsed doc. Gives access to the doc's MDX
* Component, front matter, metadata, TOC, etc. When swizzling a low-level
* component (e.g. the "Edit this page" link) and you need some extra metadata,
* you don't have to drill the props all the way through the component tree:
* simply use this hook instead.
*/
export declare function useDoc(): DocContextValue;
//# sourceMappingURL=doc.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/contexts/doc.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAU,KAAK,SAAS,EAAa,MAAM,OAAO,CAAC;AAEjE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,cAAc,EACd,UAAU,GAAG,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,cAAc,CAC/D,CAAC;AAwBF;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,GAAG,CAAC,OAAO,CAGd;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,IAAI,eAAe,CAMxC"}

View File

@@ -0,0 +1,48 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useMemo, useContext } from 'react';
import { ReactContextError } from '../utils/reactUtils';
const Context = React.createContext(null);
/**
* Note: we don't use `PropDoc` as context value on purpose. Metadata is
* currently stored inside the MDX component, but we may want to change that in
* the future. This layer is a good opportunity to decouple storage from
* consuming API, potentially allowing us to provide metadata as both props and
* route context without duplicating the chunks in the future.
*/
function useContextValue(content) {
return useMemo(() => ({
metadata: content.metadata,
frontMatter: content.frontMatter,
assets: content.assets,
contentTitle: content.contentTitle,
toc: content.toc,
}), [content]);
}
/**
* This is a very thin layer around the `content` received from the MDX loader.
* It provides metadata about the doc to the children tree.
*/
export function DocProvider({ children, content, }) {
const contextValue = useContextValue(content);
return <Context.Provider value={contextValue}>{children}</Context.Provider>;
}
/**
* Returns the data of the currently browsed doc. Gives access to the doc's MDX
* Component, front matter, metadata, TOC, etc. When swizzling a low-level
* component (e.g. the "Edit this page" link) and you need some extra metadata,
* you don't have to drill the props all the way through the component tree:
* simply use this hook instead.
*/
export function useDoc() {
const doc = useContext(Context);
if (doc === null) {
throw new ReactContextError('DocProvider');
}
return doc;
}
//# sourceMappingURL=doc.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"doc.js","sourceRoot":"","sources":["../../src/contexts/doc.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAAC,OAAO,EAAkB,UAAU,EAAC,MAAM,OAAO,CAAC;AACjE,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAYtD,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAyB,IAAI,CAAC,CAAC;AAElE;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,OAAuB;IAC9C,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC,EACF,CAAC,OAAO,CAAC,CACV,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,QAAQ,EACR,OAAO,GAIR;IACC,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAC9C,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,MAAM;IACpB,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,GAAG,KAAK,IAAI,EAAE;QAChB,MAAM,IAAI,iBAAiB,CAAC,aAAa,CAAC,CAAC;KAC5C;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { type ReactNode } from 'react';
type ContextValue = {
/**
* The item that the user last opened, `null` when there's none open. On
* initial render, it will always be `null`, which doesn't necessarily mean
* there's no category open (can have 0, 1, or many being initially open).
*/
expandedItem: number | null;
/**
* Set the currently expanded item, when the user opens one. Set the value to
* `null` when the user closes an open category.
*/
setExpandedItem: (a: number | null) => void;
};
/**
* Should be used to wrap one sidebar category level. This provider syncs the
* expanded states of all sibling categories, and categories can choose to
* collapse itself if another one is expanded.
*/
export declare function DocSidebarItemsExpandedStateProvider({ children, }: {
children: ReactNode;
}): JSX.Element;
export declare function useDocSidebarItemsExpandedState(): ContextValue;
export {};
//# sourceMappingURL=docSidebarItemsExpandedState.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"docSidebarItemsExpandedState.d.ts","sourceRoot":"","sources":["../../src/contexts/docSidebarItemsExpandedState.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAC,KAAK,SAAS,EAAgC,MAAM,OAAO,CAAC;AAG3E,KAAK,YAAY,GAAG;IAClB;;;;OAIG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;OAGG;IACH,eAAe,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAC7C,CAAC;AAOF;;;;GAIG;AACH,wBAAgB,oCAAoC,CAAC,EACnD,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAQd;AAED,wBAAgB,+BAA+B,IAAI,YAAY,CAM9D"}

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useMemo, useState, useContext } from 'react';
import { ReactContextError } from '../utils/reactUtils';
const EmptyContext = Symbol('EmptyContext');
const Context = React.createContext(EmptyContext);
/**
* Should be used to wrap one sidebar category level. This provider syncs the
* expanded states of all sibling categories, and categories can choose to
* collapse itself if another one is expanded.
*/
export function DocSidebarItemsExpandedStateProvider({ children, }) {
const [expandedItem, setExpandedItem] = useState(null);
const contextValue = useMemo(() => ({ expandedItem, setExpandedItem }), [expandedItem]);
return <Context.Provider value={contextValue}>{children}</Context.Provider>;
}
export function useDocSidebarItemsExpandedState() {
const value = useContext(Context);
if (value === EmptyContext) {
throw new ReactContextError('DocSidebarItemsExpandedStateProvider');
}
return value;
}
//# sourceMappingURL=docSidebarItemsExpandedState.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"docSidebarItemsExpandedState.js","sourceRoot":"","sources":["../../src/contexts/docSidebarItemsExpandedState.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAAiB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAgBtD,MAAM,YAAY,GAAkB,MAAM,CAAC,cAAc,CAAC,CAAC;AAC3D,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CACjC,YAAY,CACb,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,oCAAoC,CAAC,EACnD,QAAQ,GAGT;IACC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IACtE,MAAM,YAAY,GAAG,OAAO,CAC1B,GAAG,EAAE,CAAC,CAAC,EAAC,YAAY,EAAE,eAAe,EAAC,CAAC,EACvC,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,KAAK,KAAK,YAAY,EAAE;QAC1B,MAAM,IAAI,iBAAiB,CAAC,sCAAsC,CAAC,CAAC;KACrE;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}

View File

@@ -0,0 +1,30 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { type ReactNode } from 'react';
import { type GlobalVersion } from '@docusaurus/plugin-content-docs/client';
/**
* This is a maybe-layer. If the docs plugin is not enabled, this provider is a
* simple pass-through.
*/
export declare function DocsPreferredVersionContextProvider({ children, }: {
children: ReactNode;
}): JSX.Element;
/**
* Returns a read-write interface to a plugin's preferred version. The
* "preferred version" is defined as the last version that the user visited.
* For example, if a user is using v3, even when v4 is later published, the user
* would still be browsing v3 docs when she opens the website next time. Note,
* the `preferredVersion` attribute will always be `null` before mount.
*/
export declare function useDocsPreferredVersion(pluginId?: string | undefined): {
preferredVersion: GlobalVersion | null;
savePreferredVersionName: (versionName: string) => void;
};
export declare function useDocsPreferredVersionByPluginId(): {
[pluginId: string]: GlobalVersion | null;
};
//# sourceMappingURL=docsPreferredVersion.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"docsPreferredVersion.d.ts","sourceRoot":"","sources":["../../src/contexts/docsPreferredVersion.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAMZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,wCAAwC,CAAC;AAsJhD;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,EAClD,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CASd;AAUD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,GAAE,MAAM,GAAG,SAA6B,GAC/C;IACD,gBAAgB,EAAE,aAAa,GAAG,IAAI,CAAC;IACvC,wBAAwB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACzD,CAmBA;AAED,wBAAgB,iCAAiC,IAAI;IACnD,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAAC;CAC1C,CAkBA"}

View File

@@ -0,0 +1,130 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useContext, useEffect, useMemo, useState, useCallback, } from 'react';
import { useAllDocsData, useDocsData, } from '@docusaurus/plugin-content-docs/client';
import { DEFAULT_PLUGIN_ID } from '@docusaurus/constants';
import { useThemeConfig, } from '../utils/useThemeConfig';
import { isDocsPluginEnabled } from '../utils/docsUtils';
import { ReactContextError } from '../utils/reactUtils';
import { createStorageSlot } from '../utils/storageUtils';
const storageKey = (pluginId) => `docs-preferred-version-${pluginId}`;
const DocsPreferredVersionStorage = {
save: (pluginId, persistence, versionName) => {
createStorageSlot(storageKey(pluginId), { persistence }).set(versionName);
},
read: (pluginId, persistence) => createStorageSlot(storageKey(pluginId), { persistence }).get(),
clear: (pluginId, persistence) => {
createStorageSlot(storageKey(pluginId), { persistence }).del();
},
};
/**
* Initial state is always null as we can't read local storage from node SSR
*/
const getInitialState = (pluginIds) => Object.fromEntries(pluginIds.map((id) => [id, { preferredVersionName: null }]));
/**
* Read storage for all docs plugins, assigning each doc plugin a preferred
* version (if found)
*/
function readStorageState({ pluginIds, versionPersistence, allDocsData, }) {
/**
* The storage value we read might be stale, and belong to a version that does
* not exist in the site anymore. In such case, we remove the storage value to
* avoid downstream errors.
*/
function restorePluginState(pluginId) {
const preferredVersionNameUnsafe = DocsPreferredVersionStorage.read(pluginId, versionPersistence);
const pluginData = allDocsData[pluginId];
const versionExists = pluginData.versions.some((version) => version.name === preferredVersionNameUnsafe);
if (versionExists) {
return { preferredVersionName: preferredVersionNameUnsafe };
}
DocsPreferredVersionStorage.clear(pluginId, versionPersistence);
return { preferredVersionName: null };
}
return Object.fromEntries(pluginIds.map((id) => [id, restorePluginState(id)]));
}
function useVersionPersistence() {
return useThemeConfig().docs.versionPersistence;
}
const Context = React.createContext(null);
function useContextValue() {
const allDocsData = useAllDocsData();
const versionPersistence = useVersionPersistence();
const pluginIds = useMemo(() => Object.keys(allDocsData), [allDocsData]);
// Initial state is empty, as we can't read browser storage in node/SSR
const [state, setState] = useState(() => getInitialState(pluginIds));
// On mount, we set the state read from browser storage
useEffect(() => {
setState(readStorageState({ allDocsData, versionPersistence, pluginIds }));
}, [allDocsData, versionPersistence, pluginIds]);
// The API that we expose to consumer hooks (memo for constant object)
const api = useMemo(() => {
function savePreferredVersion(pluginId, versionName) {
DocsPreferredVersionStorage.save(pluginId, versionPersistence, versionName);
setState((s) => ({
...s,
[pluginId]: { preferredVersionName: versionName },
}));
}
return {
savePreferredVersion,
};
}, [versionPersistence]);
return [state, api];
}
function DocsPreferredVersionContextProviderUnsafe({ children, }) {
const value = useContextValue();
return <Context.Provider value={value}>{children}</Context.Provider>;
}
/**
* This is a maybe-layer. If the docs plugin is not enabled, this provider is a
* simple pass-through.
*/
export function DocsPreferredVersionContextProvider({ children, }) {
if (isDocsPluginEnabled) {
return (<DocsPreferredVersionContextProviderUnsafe>
{children}
</DocsPreferredVersionContextProviderUnsafe>);
}
return <>{children}</>;
}
function useDocsPreferredVersionContext() {
const value = useContext(Context);
if (!value) {
throw new ReactContextError('DocsPreferredVersionContextProvider');
}
return value;
}
/**
* Returns a read-write interface to a plugin's preferred version. The
* "preferred version" is defined as the last version that the user visited.
* For example, if a user is using v3, even when v4 is later published, the user
* would still be browsing v3 docs when she opens the website next time. Note,
* the `preferredVersion` attribute will always be `null` before mount.
*/
export function useDocsPreferredVersion(pluginId = DEFAULT_PLUGIN_ID) {
const docsData = useDocsData(pluginId);
const [state, api] = useDocsPreferredVersionContext();
const { preferredVersionName } = state[pluginId];
const preferredVersion = docsData.versions.find((version) => version.name === preferredVersionName) ?? null;
const savePreferredVersionName = useCallback((versionName) => {
api.savePreferredVersion(pluginId, versionName);
}, [api, pluginId]);
return { preferredVersion, savePreferredVersionName };
}
export function useDocsPreferredVersionByPluginId() {
const allDocsData = useAllDocsData();
const [state] = useDocsPreferredVersionContext();
function getPluginIdPreferredVersion(pluginId) {
const docsData = allDocsData[pluginId];
const { preferredVersionName } = state[pluginId];
return (docsData.versions.find((version) => version.name === preferredVersionName) ?? null);
}
const pluginIds = Object.keys(allDocsData);
return Object.fromEntries(pluginIds.map((id) => [id, getPluginIdPreferredVersion(id)]));
}
//# sourceMappingURL=docsPreferredVersion.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"docsPreferredVersion.js","sourceRoot":"","sources":["../../src/contexts/docsPreferredVersion.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,UAAU,EACV,SAAS,EACT,OAAO,EACP,QAAQ,EACR,WAAW,GAEZ,MAAM,OAAO,CAAC;AACf,OAAO,EACL,cAAc,EACd,WAAW,GAGZ,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,cAAc,GAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAExD,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,0BAA0B,QAAQ,EAAE,CAAC;AAE9E,MAAM,2BAA2B,GAAG;IAClC,IAAI,EAAE,CACJ,QAAgB,EAChB,WAAmC,EACnC,WAAmB,EACb,EAAE;QACR,iBAAiB,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAC,WAAW,EAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,EAAE,CACJ,QAAgB,EAChB,WAAmC,EACpB,EAAE,CACjB,iBAAiB,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAC,WA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C,CAAC;IAClD,CAAC,EACD,CAAC,GAAG,EAAE,QAAQ,CAAC,CAChB,CAAC;IAEF,OAAO,EAAC,gBAAgB,EAAE,wBAAwB,EAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,iCAAiC;IAG/C,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,CAAC,KAAK,CAAC,GAAG,8BAA8B,EAAE,CAAC;IAEjD,SAAS,2BAA2B,CAAC,QAAgB;QACnD,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAE,CAAC;QACxC,MAAM,EAAC,oBAAoB,EAAC,GAAG,KAAK,CAAC,QAAQ,CAAE,CAAC;QAEhD,OAAO,CACL,QAAQ,CAAC,QAAQ,CAAC,IAAI,CACpB,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,oBAAoB,CACnD,IAAI,IAAI,CACV,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3C,OAAO,MAAM,CAAC,WAAW,CACvB,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,2BAA2B,CAAC,EAAE,CAAC,CAAC,CAAC,CAC7D,CAAC;AACJ,CAAC"}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { type ReactNode } from 'react';
import type { PropSidebar } from '@docusaurus/plugin-content-docs';
type ContextValue = {
name: string;
items: PropSidebar;
};
/**
* Provide the current sidebar to your children.
*/
export declare function DocsSidebarProvider({ children, name, items, }: {
children: ReactNode;
name: string | undefined;
items: PropSidebar | undefined;
}): JSX.Element;
/**
* Gets the sidebar that's currently displayed, or `null` if there isn't one
*/
export declare function useDocsSidebar(): ContextValue | null;
export {};
//# sourceMappingURL=docsSidebar.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"docsSidebar.d.ts","sourceRoot":"","sources":["../../src/contexts/docsSidebar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAsB,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAEjE,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,iCAAiC,CAAC;AAMjE,KAAK,YAAY,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAC,CAAC;AAMvD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,IAAI,EACJ,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;CAChC,GAAG,GAAG,CAAC,OAAO,CAMd;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,YAAY,GAAG,IAAI,CAMpD"}

View File

@@ -0,0 +1,30 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useMemo, useContext } from 'react';
import { ReactContextError } from '../utils/reactUtils';
// Using a Symbol because null is a valid context value (a doc with no sidebar)
// Inspired by https://github.com/jamiebuilds/unstated-next/blob/master/src/unstated-next.tsx
const EmptyContext = Symbol('EmptyContext');
const Context = React.createContext(EmptyContext);
/**
* Provide the current sidebar to your children.
*/
export function DocsSidebarProvider({ children, name, items, }) {
const stableValue = useMemo(() => (name && items ? { name, items } : null), [name, items]);
return <Context.Provider value={stableValue}>{children}</Context.Provider>;
}
/**
* Gets the sidebar that's currently displayed, or `null` if there isn't one
*/
export function useDocsSidebar() {
const value = useContext(Context);
if (value === EmptyContext) {
throw new ReactContextError('DocsSidebarProvider');
}
return value;
}
//# sourceMappingURL=docsSidebar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"docsSidebar.js","sourceRoot":"","sources":["../../src/contexts/docsSidebar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAAC,OAAO,EAAE,UAAU,EAAiB,MAAM,OAAO,CAAC;AACjE,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAGtD,+EAA+E;AAC/E,6FAA6F;AAC7F,MAAM,YAAY,GAAkB,MAAM,CAAC,cAAc,CAAC,CAAC;AAI3D,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CACjC,YAAY,CACb,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,QAAQ,EACR,IAAI,EACJ,KAAK,GAKN;IACC,MAAM,WAAW,GAAwB,OAAO,CAC9C,GAAG,EAAE,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,EAAC,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAC5C,CAAC,IAAI,EAAE,KAAK,CAAC,CACd,CAAC;IACF,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC7E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,KAAK,KAAK,YAAY,EAAE;QAC1B,MAAM,IAAI,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;KACpD;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}

View File

@@ -0,0 +1,20 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { type ReactNode } from 'react';
import type { PropVersionMetadata } from '@docusaurus/plugin-content-docs';
/**
* Provide the current version's metadata to your children.
*/
export declare function DocsVersionProvider({ children, version, }: {
children: ReactNode;
version: PropVersionMetadata | null;
}): JSX.Element;
/**
* Gets the version metadata of the current doc page.
*/
export declare function useDocsVersion(): PropVersionMetadata;
//# sourceMappingURL=docsVersion.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"docsVersion.d.ts","sourceRoot":"","sources":["../../src/contexts/docsVersion.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAC,KAAK,SAAS,EAAa,MAAM,OAAO,CAAC;AAExD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAIzE;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAC;CACrC,GAAG,GAAG,CAAC,OAAO,CAEd;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,mBAAmB,CAMpD"}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useContext } from 'react';
import { ReactContextError } from '../utils/reactUtils';
const Context = React.createContext(null);
/**
* Provide the current version's metadata to your children.
*/
export function DocsVersionProvider({ children, version, }) {
return <Context.Provider value={version}>{children}</Context.Provider>;
}
/**
* Gets the version metadata of the current doc page.
*/
export function useDocsVersion() {
const version = useContext(Context);
if (version === null) {
throw new ReactContextError('DocsVersionProvider');
}
return version;
}
//# sourceMappingURL=docsVersion.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"docsVersion.js","sourceRoot":"","sources":["../../src/contexts/docsVersion.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAAiB,UAAU,EAAC,MAAM,OAAO,CAAC;AACxD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAGtD,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAA6B,IAAI,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,QAAQ,EACR,OAAO,GAIR;IACC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,OAAO,KAAK,IAAI,EAAE;QACpB,MAAM,IAAI,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;KACpD;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { type ReactNode } from 'react';
type ContextValue = {
/**
* Mobile sidebar should be disabled in case it's empty, i.e. no secondary
* menu + no navbar items). If disabled, the toggle button should not be
* displayed at all.
*/
disabled: boolean;
/**
* Signals whether the actual sidebar should be displayed (contrary to
* `disabled` which is about the toggle button). Sidebar should not visible
* until user interaction to avoid SSR rendering.
*/
shouldRender: boolean;
/** The displayed state. Can be toggled with the `toggle` callback. */
shown: boolean;
/** Toggle the `shown` attribute. */
toggle: () => void;
};
export declare function NavbarMobileSidebarProvider({ children, }: {
children: ReactNode;
}): JSX.Element;
export declare function useNavbarMobileSidebar(): ContextValue;
export {};
//# sourceMappingURL=navbarMobileSidebar.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"navbarMobileSidebar.d.ts","sourceRoot":"","sources":["../../src/contexts/navbarMobileSidebar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAKZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAOf,KAAK,YAAY,GAAG;IAClB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB,sEAAsE;IACtE,KAAK,EAAE,OAAO,CAAC;IACf,oCAAoC;IACpC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AA8CF,wBAAgB,2BAA2B,CAAC,EAC1C,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAGd;AAED,wBAAgB,sBAAsB,IAAI,YAAY,CAMrD"}

View File

@@ -0,0 +1,56 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useCallback, useEffect, useState, useMemo, } from 'react';
import { useNavbarSecondaryMenuContent } from './navbarSecondaryMenu/content';
import { useWindowSize } from '../hooks/useWindowSize';
import { useHistoryPopHandler } from '../utils/historyUtils';
import { useThemeConfig } from '../utils/useThemeConfig';
import { ReactContextError } from '../utils/reactUtils';
const Context = React.createContext(undefined);
function useIsNavbarMobileSidebarDisabled() {
const secondaryMenuContent = useNavbarSecondaryMenuContent();
const { items } = useThemeConfig().navbar;
return items.length === 0 && !secondaryMenuContent.component;
}
function useContextValue() {
const disabled = useIsNavbarMobileSidebarDisabled();
const windowSize = useWindowSize();
const shouldRender = !disabled && windowSize === 'mobile';
const [shown, setShown] = useState(false);
// Close mobile sidebar on navigation pop
// Most likely firing when using the Android back button (but not only)
useHistoryPopHandler(() => {
if (shown) {
setShown(false);
// Prevent pop navigation; seems desirable enough
// See https://github.com/facebook/docusaurus/pull/5462#issuecomment-911699846
return false;
}
return undefined;
});
const toggle = useCallback(() => {
setShown((s) => !s);
}, []);
useEffect(() => {
if (windowSize === 'desktop') {
setShown(false);
}
}, [windowSize]);
return useMemo(() => ({ disabled, shouldRender, toggle, shown }), [disabled, shouldRender, toggle, shown]);
}
export function NavbarMobileSidebarProvider({ children, }) {
const value = useContextValue();
return <Context.Provider value={value}>{children}</Context.Provider>;
}
export function useNavbarMobileSidebar() {
const context = React.useContext(Context);
if (context === undefined) {
throw new ReactContextError('NavbarMobileSidebarProvider');
}
return context;
}
//# sourceMappingURL=navbarMobileSidebar.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"navbarMobileSidebar.js","sourceRoot":"","sources":["../../src/contexts/navbarMobileSidebar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,WAAW,EACX,SAAS,EACT,QAAQ,EACR,OAAO,GAER,MAAM,OAAO,CAAC;AACf,OAAO,EAAC,6BAA6B,EAAC,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAqBtD,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAA2B,SAAS,CAAC,CAAC;AAEzE,SAAS,gCAAgC;IACvC,MAAM,oBAAoB,GAAG,6BAA6B,EAAE,CAAC;IAC7D,MAAM,EAAC,KAAK,EAAC,GAAG,cAAc,EAAE,CAAC,MAAM,CAAC;IACxC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC;AAC/D,CAAC;AAED,SAAS,eAAe;IACtB,MAAM,QAAQ,GAAG,gCAAgC,EAAE,CAAC;IACpD,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IAEnC,MAAM,YAAY,GAAG,CAAC,QAAQ,IAAI,UAAU,KAAK,QAAQ,CAAC;IAE1D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE1C,yCAAyC;IACzC,uEAAuE;IACvE,oBAAoB,CAA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IT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { type ReactNode, type ComponentType } from 'react';
export type NavbarSecondaryMenuComponent<Props> = ComponentType<Props>;
/** @internal */
export type Content = {
component: NavbarSecondaryMenuComponent<object>;
props: object;
} | {
component: null;
props: null;
};
/** @internal */
export declare function NavbarSecondaryMenuContentProvider({ children, }: {
children: ReactNode;
}): JSX.Element;
/** @internal */
export declare function useNavbarSecondaryMenuContent(): Content;
/**
* This component renders nothing by itself, but it fills the placeholder in the
* generic secondary menu layout. This reduces coupling between the main layout
* and the specific page.
*
* This kind of feature is often called portal/teleport/gateway/outlet...
* Various unmaintained React libs exist. Most up-to-date one:
* https://github.com/gregberge/react-teleporter
* Not sure any of those is safe regarding concurrent mode.
*/
export declare function NavbarSecondaryMenuFiller<P extends object>({ component, props, }: {
component: NavbarSecondaryMenuComponent<P>;
props: P;
}): JSX.Element | null;
//# sourceMappingURL=content.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/contexts/navbarSecondaryMenu/content.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAIZ,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAUf,MAAM,MAAM,4BAA4B,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;AAEvE,gBAAgB;AAChB,MAAM,MAAM,OAAO,GACf;IACE,SAAS,EAAE,4BAA4B,CAAC,MAAM,CAAC,CAAC;IAChD,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IAAC,SAAS,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAC,CAAC;AASnC,gBAAgB;AAChB,wBAAgB,kCAAkC,CAAC,EACjD,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAMd;AAED,gBAAgB;AAChB,wBAAgB,6BAA6B,IAAI,OAAO,CAMvD;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,MAAM,EAAE,EAC1D,SAAS,EACT,KAAK,GACN,EAAE;IACD,SAAS,EAAE,4BAA4B,CAAC,CAAC,CAAC,CAAC;IAC3C,KAAK,EAAE,CAAC,CAAC;CACV,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAqBrB"}

View File

@@ -0,0 +1,50 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useState, useContext, useEffect, } from 'react';
import { ReactContextError, useShallowMemoObject } from '../../utils/reactUtils';
const Context = React.createContext(null);
/** @internal */
export function NavbarSecondaryMenuContentProvider({ children, }) {
const value = useState({ component: null, props: null });
return (
// @ts-expect-error: this context is hard to type
<Context.Provider value={value}>{children}</Context.Provider>);
}
/** @internal */
export function useNavbarSecondaryMenuContent() {
const value = useContext(Context);
if (!value) {
throw new ReactContextError('NavbarSecondaryMenuContentProvider');
}
return value[0];
}
/**
* This component renders nothing by itself, but it fills the placeholder in the
* generic secondary menu layout. This reduces coupling between the main layout
* and the specific page.
*
* This kind of feature is often called portal/teleport/gateway/outlet...
* Various unmaintained React libs exist. Most up-to-date one:
* https://github.com/gregberge/react-teleporter
* Not sure any of those is safe regarding concurrent mode.
*/
export function NavbarSecondaryMenuFiller({ component, props, }) {
const context = useContext(Context);
if (!context) {
throw new ReactContextError('NavbarSecondaryMenuContentProvider');
}
const [, setContent] = context;
// To avoid useless context re-renders, props are memoized shallowly
const memoizedProps = useShallowMemoObject(props);
useEffect(() => {
// @ts-expect-error: this context is hard to type
setContent({ component, props: memoizedProps });
}, [setContent, component, memoizedProps]);
useEffect(() => () => setContent({ component: null, props: null }), [setContent]);
return null;
}
//# sourceMappingURL=content.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/contexts/navbarSecondaryMenu/content.tsx"],"names":[],"mappings":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,SAAS,EAAE,KAAK,EAAE,aAAa,EAAC,CAAC,CAAC;IAChD,CAAC,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;IAE3C,SAAS,CACP,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,EAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC,EACtD,CAAC,UAAU,CAAC,CACb,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC"}

View File

@@ -0,0 +1,24 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { type ReactNode } from 'react';
/** @internal */
export declare function NavbarSecondaryMenuDisplayProvider({ children, }: {
children: ReactNode;
}): JSX.Element;
/** Wires the logic for rendering the mobile navbar secondary menu. */
export declare function useNavbarSecondaryMenu(): {
/** Whether secondary menu is displayed. */
shown: boolean;
/**
* Hide the secondary menu; fired either when hiding the entire sidebar, or
* when going back to the primary menu.
*/
hide: () => void;
/** The content returned from the current secondary menu filler. */
content: JSX.Element | undefined;
};
//# sourceMappingURL=display.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../../src/contexts/navbarSecondaryMenu/display.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAMZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AA6Cf,gBAAgB;AAChB,wBAAgB,kCAAkC,CAAC,EACjD,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAGd;AAUD,sEAAsE;AACtE,wBAAgB,sBAAsB,IAAI;IACxC,2CAA2C;IAC3C,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,mEAAmE;IACnE,OAAO,EAAE,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC;CAClC,CAaA"}

View File

@@ -0,0 +1,62 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { useState, useContext, useEffect, useMemo, useCallback, } from 'react';
import { ReactContextError, usePrevious } from '../../utils/reactUtils';
import { useNavbarMobileSidebar } from '../navbarMobileSidebar';
import { useNavbarSecondaryMenuContent } from './content';
const Context = React.createContext(null);
function useContextValue() {
const mobileSidebar = useNavbarMobileSidebar();
const content = useNavbarSecondaryMenuContent();
const [shown, setShown] = useState(false);
const hasContent = content.component !== null;
const previousHasContent = usePrevious(hasContent);
// When content is become available for the first time (set in useEffect)
// we set this content to be shown!
useEffect(() => {
const contentBecameAvailable = hasContent && !previousHasContent;
if (contentBecameAvailable) {
setShown(true);
}
}, [hasContent, previousHasContent]);
// On sidebar close, secondary menu is set to be shown on next re-opening
// (if any secondary menu content available)
useEffect(() => {
if (!hasContent) {
setShown(false);
return;
}
if (!mobileSidebar.shown) {
setShown(true);
}
}, [mobileSidebar.shown, hasContent]);
return useMemo(() => [shown, setShown], [shown]);
}
/** @internal */
export function NavbarSecondaryMenuDisplayProvider({ children, }) {
const value = useContextValue();
return <Context.Provider value={value}>{children}</Context.Provider>;
}
function renderElement(content) {
if (content.component) {
const Comp = content.component;
return <Comp {...content.props}/>;
}
return undefined;
}
/** Wires the logic for rendering the mobile navbar secondary menu. */
export function useNavbarSecondaryMenu() {
const value = useContext(Context);
if (!value) {
throw new ReactContextError('NavbarSecondaryMenuDisplayProvider');
}
const [shown, setShown] = value;
const hide = useCallback(() => setShown(false), [setShown]);
const content = useNavbarSecondaryMenuContent();
return useMemo(() => ({ shown, hide, content: renderElement(content) }), [hide, content, shown]);
}
//# sourceMappingURL=display.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"display.js","sourceRoot":"","sources":["../../../src/contexts/navbarSecondaryMenu/display.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;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iliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
body:not(.navigation-with-keyboard) *:not(input):focus {
outline: none;
}

View File

@@ -0,0 +1,27 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** Wires the logic for the back to top button. */
export declare function useBackToTopButton({ threshold, }: {
/**
* The minimum vertical scroll position, above which a scroll-up would not
* cause `shown` to become `true`. This is because BTT is only useful if the
* user is far down the page.
*/
threshold: number;
}): {
/**
* Whether the button should be displayed. We only show if the user has
* scrolled up and is on a vertical position greater than `threshold`.
*/
shown: boolean;
/**
* A (memoized) handle for starting the scroll, which you can directly plug
* into the props.
*/
scrollToTop: () => void;
};
//# sourceMappingURL=useBackToTopButton.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useBackToTopButton.d.ts","sourceRoot":"","sources":["../../src/hooks/useBackToTopButton.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,kDAAkD;AAClD,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,GACV,EAAE;IACD;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG;IACF;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAwCA"}

View File

@@ -0,0 +1,50 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { useRef, useState } from 'react';
import { useScrollPosition, useSmoothScrollTo } from '../utils/scrollUtils';
import { useLocationChange } from '../utils/useLocationChange';
/** Wires the logic for the back to top button. */
export function useBackToTopButton({ threshold, }) {
const [shown, setShown] = useState(false);
const isFocusedAnchor = useRef(false);
const { startScroll, cancelScroll } = useSmoothScrollTo();
useScrollPosition(({ scrollY: scrollTop }, lastPosition) => {
const lastScrollTop = lastPosition?.scrollY;
// Component is just being mounted. Not really a scroll event from the user.
// Ignore it.
if (!lastScrollTop) {
return;
}
if (isFocusedAnchor.current) {
// This scroll position change is triggered by navigating to an anchor.
// Ignore it.
isFocusedAnchor.current = false;
}
else if (scrollTop >= lastScrollTop) {
// The user has scrolled down to "fight against" the animation. Cancel any
// animation under progress.
cancelScroll();
setShown(false);
}
else if (scrollTop < threshold) {
// Scrolled to the minimum position; hide the button.
setShown(false);
}
else if (scrollTop + window.innerHeight <
document.documentElement.scrollHeight) {
setShown(true);
}
});
useLocationChange((locationChangeEvent) => {
if (locationChangeEvent.location.hash) {
isFocusedAnchor.current = true;
setShown(false);
}
});
return { shown, scrollToTop: () => startScroll(0) };
}
//# sourceMappingURL=useBackToTopButton.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useBackToTopButton.js","sourceRoot":"","sources":["../../src/hooks/useBackToTopButton.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvC,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAE7D,kDAAkD;AAClD,MAAM,UAAU,kBAAkB,CAAC,EACjC,SAAS,GAQV;IAYC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,EAAC,WAAW,EAAE,YAAY,EAAC,GAAG,iBAAiB,EAAE,CAAC;IAExD,iBAAiB,CAAC,CAAC,EAAC,OAAO,EAAE,SAAS,EAAC,EAAE,YAAY,EAAE,EAAE;QACvD,MAAM,aAAa,GAAG,YAAY,EAAE,OAAO,CAAC;QAC5C,4EAA4E;QAC5E,aAAa;QACb,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO;SACR;QACD,IAAI,eAAe,CAAC,OAAO,EAAE;YAC3B,uEAAuE;YACvE,aAAa;YACb,eAAe,CAAC,OAAO,GAAG,KAAK,CAAC;SACjC;aAAM,IAAI,SAAS,IAAI,aAAa,EAAE;YACrC,0EAA0E;YAC1E,4BAA4B;YAC5B,YAAY,EAAE,CAAC;YACf,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;aAAM,IAAI,SAAS,GAAG,SAAS,EAAE;YAChC,qDAAqD;YACrD,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;aAAM,IACL,SAAS,GAAG,MAAM,CAAC,WAAW;YAC9B,QAAQ,CAAC,eAAe,CAAC,YAAY,EACrC;YACA,QAAQ,CAAC,IAAI,CAAC,CAAC;SAChB;IACH,CAAC,CAAC,CAAC;IAEH,iBAAiB,CAAC,CAAC,mBAAmB,EAAE,EAAE;QACxC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,IAAI,EAAE;YACrC,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;YAC/B,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,EAAC,CAAC;AACpD,CAAC"}

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { RefObject } from 'react';
export declare function useCodeWordWrap(): {
readonly codeBlockRef: RefObject<HTMLPreElement>;
readonly isEnabled: boolean;
readonly isCodeScrollable: boolean;
readonly toggle: () => void;
};
//# sourceMappingURL=useCodeWordWrap.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useCodeWordWrap.d.ts","sourceRoot":"","sources":["../../src/hooks/useCodeWordWrap.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAgDrC,wBAAgB,eAAe,IAAI;IACjC,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACjD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;CAC7B,CA6CA"}

View File

@@ -0,0 +1,67 @@
import { useState, useCallback, useEffect, useRef } from 'react';
import { useMutationObserver } from './useMutationObserver';
// Callback fires when the "hidden" attribute of a tabpanel changes
// See https://github.com/facebook/docusaurus/pull/7485
function useTabBecameVisibleCallback(codeBlockRef, callback) {
const [hiddenTabElement, setHiddenTabElement] = useState();
const updateHiddenTabElement = useCallback(() => {
// No need to observe non-hidden tabs
// + we want to force a re-render when a tab becomes visible
setHiddenTabElement(codeBlockRef.current?.closest('[role=tabpanel][hidden]'));
}, [codeBlockRef, setHiddenTabElement]);
useEffect(() => {
updateHiddenTabElement();
}, [updateHiddenTabElement]);
useMutationObserver(hiddenTabElement, (mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'attributes' &&
mutation.attributeName === 'hidden') {
callback();
updateHiddenTabElement();
}
});
}, {
attributes: true,
characterData: false,
childList: false,
subtree: false,
});
}
export function useCodeWordWrap() {
const [isEnabled, setIsEnabled] = useState(false);
const [isCodeScrollable, setIsCodeScrollable] = useState(false);
const codeBlockRef = useRef(null);
const toggle = useCallback(() => {
const codeElement = codeBlockRef.current.querySelector('code');
if (isEnabled) {
codeElement.removeAttribute('style');
}
else {
codeElement.style.whiteSpace = 'pre-wrap';
// When code wrap is enabled, we want to avoid a scrollbar in any case
// Ensure that very very long words/strings/tokens still wrap
codeElement.style.overflowWrap = 'anywhere';
}
setIsEnabled((value) => !value);
}, [codeBlockRef, isEnabled]);
const updateCodeIsScrollable = useCallback(() => {
const { scrollWidth, clientWidth } = codeBlockRef.current;
const isScrollable = scrollWidth > clientWidth ||
codeBlockRef.current.querySelector('code').hasAttribute('style');
setIsCodeScrollable(isScrollable);
}, [codeBlockRef]);
useTabBecameVisibleCallback(codeBlockRef, updateCodeIsScrollable);
useEffect(() => {
updateCodeIsScrollable();
}, [isEnabled, updateCodeIsScrollable]);
useEffect(() => {
window.addEventListener('resize', updateCodeIsScrollable, {
passive: true,
});
return () => {
window.removeEventListener('resize', updateCodeIsScrollable);
};
}, [updateCodeIsScrollable]);
return { codeBlockRef, isEnabled, isCodeScrollable, toggle };
}
//# sourceMappingURL=useCodeWordWrap.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useCodeWordWrap.js","sourceRoot":"","sources":["../../src/hooks/useCodeWordWrap.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAE1D,mEAAmE;AACnE,uDAAuD;AACvD,SAAS,2BAA2B,CAClC,YAAuC,EACvC,QAAoB;IAEpB,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,EAErD,CAAC;IAEJ,MAAM,sBAAsB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9C,qCAAqC;QACrC,4DAA4D;QAC5D,mBAAmB,CACjB,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,yBAAyB,CAAC,CACzD,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAExC,SAAS,CAAC,GAAG,EAAE;QACb,sBAAsB,EAAE,CAAC;IAC3B,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAE7B,mBAAmB,CACjB,gBAAgB,EAChB,CAAC,SAA2B,EAAE,EAAE;QAC9B,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC7B,IACE,QAAQ,CAAC,IAAI,KAAK,YAAY;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AY,CAAC,OAAO,CAAC,CAAC;QACrE,mBAAmB,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,2BAA2B,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC;IAElE,SAAS,CAAC,GAAG,EAAE;QACb,sBAAsB,EAAE,CAAC;IAC3B,CAAC,EAAE,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC,CAAC;IAExC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,sBAAsB,EAAE;YACxD,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;QAC/D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAE7B,OAAO,EAAC,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAC,CAAC;AAC7D,CAAC"}

View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Wires the imperative logic of a hideable navbar.
* @param hideOnScroll If `false`, this hook is basically a no-op.
*/
export declare function useHideableNavbar(hideOnScroll: boolean): {
/** A ref to the navbar component. Plug this into the actual element. */
readonly navbarRef: (node: HTMLElement | null) => void;
/** If `false`, the navbar component should not be rendered. */
readonly isNavbarVisible: boolean;
};
//# sourceMappingURL=useHideableNavbar.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useHideableNavbar.d.ts","sourceRoot":"","sources":["../../src/hooks/useHideableNavbar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,OAAO,GAAG;IACxD,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,+DAA+D;IAC/D,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC,CA4DA"}

View File

@@ -0,0 +1,65 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { useState, useCallback, useRef } from 'react';
import { useLocationChange } from '../utils/useLocationChange';
import { useScrollPosition } from '../utils/scrollUtils';
/**
* Wires the imperative logic of a hideable navbar.
* @param hideOnScroll If `false`, this hook is basically a no-op.
*/
export function useHideableNavbar(hideOnScroll) {
const [isNavbarVisible, setIsNavbarVisible] = useState(hideOnScroll);
const isFocusedAnchor = useRef(false);
const navbarHeight = useRef(0);
const navbarRef = useCallback((node) => {
if (node !== null) {
navbarHeight.current = node.getBoundingClientRect().height;
}
}, []);
useScrollPosition(({ scrollY: scrollTop }, lastPosition) => {
if (!hideOnScroll) {
return;
}
// Needed mostly for handling rubber band scrolling.
// See https://github.com/facebook/docusaurus/pull/5721
if (scrollTop < navbarHeight.current) {
setIsNavbarVisible(true);
return;
}
if (isFocusedAnchor.current) {
isFocusedAnchor.current = false;
return;
}
const lastScrollTop = lastPosition?.scrollY;
const documentHeight = document.documentElement.scrollHeight - navbarHeight.current;
const windowHeight = window.innerHeight;
if (lastScrollTop && scrollTop >= lastScrollTop) {
setIsNavbarVisible(false);
}
else if (scrollTop + windowHeight < documentHeight) {
setIsNavbarVisible(true);
}
});
useLocationChange((locationChangeEvent) => {
if (!hideOnScroll) {
return;
}
// See https://github.com/facebook/docusaurus/pull/8059#issuecomment-1239639480
const currentHash = locationChangeEvent.location.hash;
const currentHashAnchor = currentHash
? document.getElementById(currentHash.substring(1))
: undefined;
if (currentHashAnchor) {
isFocusedAnchor.current = true;
setIsNavbarVisible(false);
return;
}
setIsNavbarVisible(true);
});
return { navbarRef, isNavbarVisible };
}
//# sourceMappingURL=useHideableNav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AY,CAAC,OAAO,CAAC;QAC/D,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC;QAExC,IAAI,aAAa,IAAI,SAAS,IAAI,aAAa,EAAE;YAC/C,kBAAkB,CAAC,KAAK,CAAC,CAAC;SAC3B;aAAM,IAAI,SAAS,GAAG,YAAY,GAAG,cAAc,EAAE;YACpD,kBAAkB,CAAC,IAAI,CAAC,CAAC;SAC1B;IACH,CAAC,CAAC,CAAC;IAEH,iBAAiB,CAAC,CAAC,mBAAmB,EAAE,EAAE;QACxC,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO;SACR;QAED,+EAA+E;QAC/E,MAAM,WAAW,GAAG,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC;QACtD,MAAM,iBAAiB,GAAG,WAAW;YACnC,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACnD,CAAC,CAAC,SAAS,CAAC;QAEd,IAAI,iBAAiB,EAAE;YACrB,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;YAC/B,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC1B,OAAO;SACR;QAED,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC;AACtC,CAAC"}

View File

@@ -0,0 +1,20 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import './styles.css';
export declare const keyboardFocusedClassName = "navigation-with-keyboard";
/**
* Side-effect that adds the `keyboardFocusedClassName` to the body element when
* the keyboard has been pressed, or removes it when the mouse is clicked.
*
* The presence of this class name signals that the user may be using keyboard
* for navigation, and the theme **must** add focus outline when this class name
* is present. (And optionally not if it's absent, for design purposes)
*
* Inspired by https://hackernoon.com/removing-that-ugly-focus-ring-and-keeping-it-too-6c8727fefcd2
*/
export declare function useKeyboardNavigation(): void;
//# sourceMappingURL=useKeyboardNavigation.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useKeyboardNavigation.d.ts","sourceRoot":"","sources":["../../src/hooks/useKeyboardNavigation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,cAAc,CAAC;AAEtB,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAEnE;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAqB5C"}

View File

@@ -0,0 +1,39 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { useEffect } from 'react';
import './styles.css';
export const keyboardFocusedClassName = 'navigation-with-keyboard';
/**
* Side-effect that adds the `keyboardFocusedClassName` to the body element when
* the keyboard has been pressed, or removes it when the mouse is clicked.
*
* The presence of this class name signals that the user may be using keyboard
* for navigation, and the theme **must** add focus outline when this class name
* is present. (And optionally not if it's absent, for design purposes)
*
* Inspired by https://hackernoon.com/removing-that-ugly-focus-ring-and-keeping-it-too-6c8727fefcd2
*/
export function useKeyboardNavigation() {
useEffect(() => {
function handleOutlineStyles(e) {
if (e.type === 'keydown' && e.key === 'Tab') {
document.body.classList.add(keyboardFocusedClassName);
}
if (e.type === 'mousedown') {
document.body.classList.remove(keyboardFocusedClassName);
}
}
document.addEventListener('keydown', handleOutlineStyles);
document.addEventListener('mousedown', handleOutlineStyles);
return () => {
document.body.classList.remove(keyboardFocusedClassName);
document.removeEventListener('keydown', handleOutlineStyles);
document.removeEventListener('mousedown', handleOutlineStyles);
};
}, []);
}
//# sourceMappingURL=useKeyboardNavigation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useKeyboardNavigation.js","sourceRoot":"","sources":["../../src/hooks/useKeyboardNavigation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAEhC,OAAO,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB;IACnC,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,mBAAmB,CAAC,CAA6B;YACxD,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,IAAK,CAAmB,CAAC,GAAG,KAAK,KAAK,EAAE;gBAC9D,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;aACvD;YAED,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,EAAE;gBAC1B,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;aAC1D;QACH,CAAC;QAED,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;QAC1D,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;QAE5D,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;YACzD,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;YAC7D,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;QACjE,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC"}

View File

@@ -0,0 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Side-effect that locks the document body's scroll throughout the lifetime of
* the containing component. e.g. when the mobile sidebar is expanded.
*/
export declare function useLockBodyScroll(lock?: boolean): void;
//# sourceMappingURL=useLockBodyScroll.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useLockBodyScroll.d.ts","sourceRoot":"","sources":["../../src/hooks/useLockBodyScroll.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,OAAc,GAAG,IAAI,CAO5D"}

View File

@@ -0,0 +1,20 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { useEffect } from 'react';
/**
* Side-effect that locks the document body's scroll throughout the lifetime of
* the containing component. e.g. when the mobile sidebar is expanded.
*/
export function useLockBodyScroll(lock = true) {
useEffect(() => {
document.body.style.overflow = lock ? 'hidden' : 'visible';
return () => {
document.body.style.overflow = 'visible';
};
}, [lock]);
}
//# sourceMappingURL=useLockBodyScroll.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useLockBodyScroll.js","sourceRoot":"","sources":["../../src/hooks/useLockBodyScroll.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAEhC;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB,IAAI;IACpD,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3D,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC3C,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACb,CAAC"}

View File

@@ -0,0 +1,4 @@
type Options = MutationObserverInit;
export declare function useMutationObserver(target: Element | undefined | null, callback: MutationCallback, options?: Options): void;
export {};
//# sourceMappingURL=useMutationObserver.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useMutationObserver.d.ts","sourceRoot":"","sources":["../../src/hooks/useMutationObserver.ts"],"names":[],"mappings":"AASA,KAAK,OAAO,GAAG,oBAAoB,CAAC;AASpC,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,EAClC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,GAAE,OAAwB,GAChC,IAAI,CAeN"}

View File

@@ -0,0 +1,29 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { useEffect } from 'react';
import { useEvent, useShallowMemoObject } from '../utils/reactUtils';
const DefaultOptions = {
attributes: true,
characterData: true,
childList: true,
subtree: true,
};
export function useMutationObserver(target, callback, options = DefaultOptions) {
const stableCallback = useEvent(callback);
// MutationObserver options are not nested much
// so this should be to memo options in 99%
// TODO handle options.attributeFilter array
const stableOptions = useShallowMemoObject(options);
useEffect(() => {
const observer = new MutationObserver(stableCallback);
if (target) {
observer.observe(target, stableOptions);
}
return () => observer.disconnect();
}, [target, stableCallback, stableOptions]);
}
//# sourceMappingURL=useMutationObserver.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useMutationObserver.js","sourceRoot":"","sources":["../../src/hooks/useMutationObserver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAChC,OAAO,EAAC,QAAQ,EAAE,oBAAoB,EAAC,MAAM,qBAAqB,CAAC;AAInE,MAAM,cAAc,GAAY;IAC9B,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,IAAI;IACnB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;CACd,CAAC;AAEF,MAAM,UAAU,mBAAmB,CACjC,MAAkC,EAClC,QAA0B,EAC1B,UAAmB,cAAc;IAEjC,MAAM,cAAc,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAE1C,+CAA+C;IAC/C,2CAA2C;IAC3C,4CAA4C;IAC5C,MAAM,aAAa,GAAY,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAE7D,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,cAAc,CAAC,CAAC;QACtD,IAAI,MAAM,EAAE;YACV,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;SACzC;QACD,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;AAC9C,CAAC"}

View File

@@ -0,0 +1,13 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { PrismTheme } from 'prism-react-renderer';
/**
* Returns a color-mode-dependent Prism theme: whatever the user specified in
* the config. Falls back to `palenight`.
*/
export declare function usePrismTheme(): PrismTheme;
//# sourceMappingURL=usePrismTheme.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"usePrismTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/usePrismTheme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAErD;;;GAGG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAQ1C"}

View File

@@ -0,0 +1,21 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { useColorMode } from '../contexts/colorMode';
import { useThemeConfig } from '../utils/useThemeConfig';
/**
* Returns a color-mode-dependent Prism theme: whatever the user specified in
* the config. Falls back to `palenight`.
*/
export function usePrismTheme() {
const { prism } = useThemeConfig();
const { colorMode } = useColorMode();
const lightModeTheme = prism.theme;
const darkModeTheme = prism.darkTheme || lightModeTheme;
const prismTheme = colorMode === 'dark' ? darkModeTheme : lightModeTheme;
return prismTheme;
}
//# sourceMappingURL=usePrismTheme.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"usePrismTheme.js","sourceRoot":"","sources":["../../src/hooks/usePrismTheme.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAGvD;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,EAAC,KAAK,EAAC,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,EAAC,SAAS,EAAC,GAAG,YAAY,EAAE,CAAC;IACnC,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC;IACnC,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,IAAI,cAAc,CAAC;IACxD,MAAM,UAAU,GAAG,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC;IAEzE,OAAO,UAAU,CAAC;AACpB,CAAC"}

View File

@@ -0,0 +1,15 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Permits to read/write the current search query string
*/
export declare function useSearchQueryString(): [string, (newValue: string) => void];
/**
* Permits to create links to the search page with the appropriate query string
*/
export declare function useSearchLinkCreator(): (searchValue: string) => string;
//# sourceMappingURL=useSearchPage.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useSearchPage.d.ts","sourceRoot":"","sources":["../../src/hooks/useSearchPage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC,CAE3E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,CAiBtE"}

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { useCallback } from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import { useQueryString } from '../utils/historyUtils';
const SEARCH_PARAM_QUERY = 'q';
/**
* Permits to read/write the current search query string
*/
export function useSearchQueryString() {
return useQueryString(SEARCH_PARAM_QUERY);
}
/**
* Permits to create links to the search page with the appropriate query string
*/
export function useSearchLinkCreator() {
const { siteConfig: { baseUrl, themeConfig }, } = useDocusaurusContext();
const { algolia: { searchPagePath }, } = themeConfig;
return useCallback((searchValue) =>
// Refer to https://github.com/facebook/docusaurus/pull/2838
// Note: if searchPagePath is falsy, useSearchPage() will not be called
`${baseUrl}${searchPagePath}?${SEARCH_PARAM_QUERY}=${encodeURIComponent(searchValue)}`, [baseUrl, searchPagePath]);
}
//# sourceMappingURL=useSearchPage.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useSearchPage.js","sourceRoot":"","sources":["../../src/hooks/useSearchPage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;AAClC,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAGrD,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,cAAc,CAAC,kBAAkB,CAAC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,EACJ,UAAU,EAAE,EAAC,OAAO,EAAE,WAAW,EAAC,GACnC,GAAG,oBAAoB,EAAE,CAAC;IAC3B,MAAM,EACJ,OAAO,EAAE,EAAC,cAAc,EAAC,GAC1B,GAAG,WAAiC,CAAC;IAEtC,OAAO,WAAW,CAChB,CAAC,WAAmB,EAAE,EAAE;IACtB,4DAA4D;IAC5D,uEAAuE;IACvE,GAAG,OAAO,GACR,cACF,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE,EAC7D,CAAC,OAAO,EAAE,cAAc,CAAC,CAC1B,CAAC;AACJ,CAAC"}

View File

@@ -0,0 +1,25 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export type TOCHighlightConfig = {
/** A class name that all TOC links share. */
linkClassName: string;
/** The class name applied to the active (highlighted) link. */
linkActiveClassName: string;
/**
* The minimum heading level that the TOC includes. Only headings that are in
* this range will be eligible as "active heading".
*/
minHeadingLevel: number;
/** @see {@link TOCHighlightConfig.minHeadingLevel} */
maxHeadingLevel: number;
};
/**
* Side-effect that applies the active class name to the TOC heading that the
* user is currently viewing. Disabled when `config` is undefined.
*/
export declare function useTOCHighlight(config: TOCHighlightConfig | undefined): void;
//# sourceMappingURL=useTOCHighlight.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useTOCHighlight.d.ts","sourceRoot":"","sources":["../../src/hooks/useTOCHighlight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA6GH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,6CAA6C;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAwD5E"}

View File

@@ -0,0 +1,130 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { useEffect, useRef } from 'react';
import { useThemeConfig } from '../utils/useThemeConfig';
// TODO make the hardcoded theme-classic classnames configurable (or add them
// to ThemeClassNames?)
/**
* If the anchor has no height and is just a "marker" in the DOM; we'll use the
* parent (normally the link text) rect boundaries instead
*/
function getVisibleBoundingClientRect(element) {
const rect = element.getBoundingClientRect();
const hasNoHeight = rect.top === rect.bottom;
if (hasNoHeight) {
return getVisibleBoundingClientRect(element.parentNode);
}
return rect;
}
/**
* Considering we divide viewport into 2 zones of each 50vh, this returns true
* if an element is in the first zone (i.e., appear in viewport, near the top)
*/
function isInViewportTopHalf(boundingRect) {
return boundingRect.top > 0 && boundingRect.bottom < window.innerHeight / 2;
}
function getAnchors({ minHeadingLevel, maxHeadingLevel, }) {
const selectors = [];
for (let i = minHeadingLevel; i <= maxHeadingLevel; i += 1) {
selectors.push(`h${i}.anchor`);
}
return Array.from(document.querySelectorAll(selectors.join()));
}
function getActiveAnchor(anchors, { anchorTopOffset, }) {
// Naming is hard: The "nextVisibleAnchor" is the first anchor that appear
// under the viewport top boundary. It does not mean this anchor is visible
// yet, but if user continues scrolling down, it will be the first to become
// visible
const nextVisibleAnchor = anchors.find((anchor) => {
const boundingRect = getVisibleBoundingClientRect(anchor);
return boundingRect.top >= anchorTopOffset;
});
if (nextVisibleAnchor) {
const boundingRect = getVisibleBoundingClientRect(nextVisibleAnchor);
// If anchor is in the top half of the viewport: it is the one we consider
// "active" (unless it's too close to the top and and soon to be scrolled
// outside viewport)
if (isInViewportTopHalf(boundingRect)) {
return nextVisibleAnchor;
}
// If anchor is in the bottom half of the viewport, or under the viewport,
// we consider the active anchor is the previous one. This is because the
// main text appearing in the user screen mostly belong to the previous
// anchor. Returns null for the first anchor, see
// https://github.com/facebook/docusaurus/issues/5318
return anchors[anchors.indexOf(nextVisibleAnchor) - 1] ?? null;
}
// No anchor under viewport top (i.e. we are at the bottom of the page),
// highlight the last anchor found
return anchors[anchors.length - 1] ?? null;
}
function getLinkAnchorValue(link) {
return decodeURIComponent(link.href.substring(link.href.indexOf('#') + 1));
}
function getLinks(linkClassName) {
return Array.from(document.getElementsByClassName(linkClassName));
}
function getNavbarHeight() {
// Not ideal to obtain actual height this way
// Using TS ! (not ?) because otherwise a bad selector would be un-noticed
return document.querySelector('.navbar').clientHeight;
}
function useAnchorTopOffsetRef() {
const anchorTopOffsetRef = useRef(0);
const { navbar: { hideOnScroll }, } = useThemeConfig();
useEffect(() => {
anchorTopOffsetRef.current = hideOnScroll ? 0 : getNavbarHeight();
}, [hideOnScroll]);
return anchorTopOffsetRef;
}
/**
* Side-effect that applies the active class name to the TOC heading that the
* user is currently viewing. Disabled when `config` is undefined.
*/
export function useTOCHighlight(config) {
const lastActiveLinkRef = useRef(undefined);
const anchorTopOffsetRef = useAnchorTopOffsetRef();
useEffect(() => {
if (!config) {
// No-op, highlighting is disabled
return () => { };
}
const { linkClassName, linkActiveClassName, minHeadingLevel, maxHeadingLevel, } = config;
function updateLinkActiveClass(link, active) {
if (active) {
if (lastActiveLinkRef.current && lastActiveLinkRef.current !== link) {
lastActiveLinkRef.current.classList.remove(linkActiveClassName);
}
link.classList.add(linkActiveClassName);
lastActiveLinkRef.current = link;
// link.scrollIntoView({block: 'nearest'});
}
else {
link.classList.remove(linkActiveClassName);
}
}
function updateActiveLink() {
const links = getLinks(linkClassName);
const anchors = getAnchors({ minHeadingLevel, maxHeadingLevel });
const activeAnchor = getActiveAnchor(anchors, {
anchorTopOffset: anchorTopOffsetRef.current,
});
const activeLink = links.find((link) => activeAnchor && activeAnchor.id === getLinkAnchorValue(link));
links.forEach((link) => {
updateLinkActiveClass(link, link === activeLink);
});
}
document.addEventListener('scroll', updateActiveLink);
document.addEventListener('resize', updateActiveLink);
updateActiveLink();
return () => {
document.removeEventListener('scroll', updateActiveLink);
document.removeEventListener('resize', updateActiveLink);
};
}, [config, anchorTopOffsetRef]);
}
//# sourceMappingURL=useTOCHighlight.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useTOCHighlight.js","sourceRoot":"","sources":["../../src/hooks/useTOCHighlight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAE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,CAC3B,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,IAAI,YAAY,CAAC,EAAE,KAAK,kBAAkB,CAAC,IAAI,CAAC,CACvE,CAAC;YAEF,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACrB,qBAAqB,CAAC,IAAI,EAAE,IAAI,KAAK,UAAU,CAAC,CAAC;YACnD,CAAC,CAAC,CAAC;QACL,CAAC;QAED,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QACtD,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAEtD,gBAAgB,EAAE,CAAC;QAEnB,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YACzD,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AACnC,CAAC"}

View File

@@ -0,0 +1,27 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
declare const windowSizes: {
readonly desktop: "desktop";
readonly mobile: "mobile";
readonly ssr: "ssr";
};
type WindowSize = keyof typeof windowSizes;
/**
* Gets the current window size as an enum value. We don't want it to return the
* actual width value, so that it only re-renders once a breakpoint is crossed.
*
* It may return `"ssr"`, which is very important to handle hydration FOUC or
* layout shifts. You have to handle it explicitly upfront. On the server, you
* may need to render BOTH the mobile/desktop elements (and hide one of them
* with mediaquery). We don't return `undefined` on purpose, to make it more
* explicit.
*/
export declare function useWindowSize({ desktopBreakpoint, }?: {
desktopBreakpoint?: number;
}): WindowSize;
export {};
//# sourceMappingURL=useWindowSize.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useWindowSize.d.ts","sourceRoot":"","sources":["../../src/hooks/useWindowSize.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,QAAA,MAAM,WAAW;;;;CAIP,CAAC;AAEX,KAAK,UAAU,GAAG,MAAM,OAAO,WAAW,CAAC;AAoB3C;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,EAC5B,iBAAqC,GACtC,GAAE;IACD,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,UAAU,CAuBlB"}

View File

@@ -0,0 +1,54 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { useEffect, useState } from 'react';
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
const windowSizes = {
desktop: 'desktop',
mobile: 'mobile',
ssr: 'ssr',
};
// Note: this value is also hardcoded in Infima
// Both JS and CSS must have the same value
// Updating this JS value alone is not enough
// See https://github.com/facebook/docusaurus/issues/9603
const DesktopBreakpoint = 996;
function getWindowSize(desktopBreakpoint) {
if (!ExecutionEnvironment.canUseDOM) {
throw new Error('getWindowSize() should only be called after React hydration');
}
return window.innerWidth > desktopBreakpoint
? windowSizes.desktop
: windowSizes.mobile;
}
/**
* Gets the current window size as an enum value. We don't want it to return the
* actual width value, so that it only re-renders once a breakpoint is crossed.
*
* It may return `"ssr"`, which is very important to handle hydration FOUC or
* layout shifts. You have to handle it explicitly upfront. On the server, you
* may need to render BOTH the mobile/desktop elements (and hide one of them
* with mediaquery). We don't return `undefined` on purpose, to make it more
* explicit.
*/
export function useWindowSize({ desktopBreakpoint = DesktopBreakpoint, } = {}) {
const [windowSize, setWindowSize] = useState(() =>
// super important to return a constant value to avoid hydration mismatch
// see https://github.com/facebook/docusaurus/issues/9379
'ssr');
useEffect(() => {
function updateWindowSize() {
setWindowSize(getWindowSize(desktopBreakpoint));
}
updateWindowSize();
window.addEventListener('resize', updateWindowSize);
return () => {
window.removeEventListener('resize', updateWindowSize);
};
}, [desktopBreakpoint]);
return windowSize;
}
//# sourceMappingURL=useWindowSize.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useWindowSize.js","sourceRoot":"","sources":["../../src/hooks/useWindowSize.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE1C,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAEpE,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,KAAK;CACF,CAAC;AAIX,+CAA+C;AAC/C,2CAA2C;AAC3C,6CAA6C;AAC7C,yDAAyD;AACzD,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,SAAS,aAAa,CAAC,iBAAyB;IAC9C,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE;QACnC,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;KACH;IAED,OAAO,MAAM,CAAC,UAAU,GAAG,iBAAiB;QAC1C,CAAC,CAAC,WAAW,CAAC,OAAO;QACrB,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC;AACzB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,iBAAiB,GAAG,iBAAiB,MAGnC,EAAE;IACJ,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAC1C,GAAG,EAAE;IACH,yEAAyE;IACzE,yDAAyD;IACzD,KAAK,CACR,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,gBAAgB;YACvB,aAAa,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAClD,CAAC;QAED,gBAAgB,EAAE,CAAC;QAEnB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAEpD,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QACzD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExB,OAAO,UAAU,CAAC;AACpB,CAAC"}

32
node_modules/@docusaurus/theme-common/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export { useThemeConfig, type ThemeConfig, type UserThemeConfig, type Navbar, type NavbarItem, type NavbarLogo, type MultiColumnFooter, type SimpleFooter, type Footer, type FooterLogo, type FooterLinkItem, type ColorModeConfig, } from './utils/useThemeConfig';
export { default as ThemedComponent } from './components/ThemedComponent';
export { createStorageSlot, useStorageSlot, listStorageKeys, } from './utils/storageUtils';
export { useContextualSearchFilters } from './utils/searchUtils';
export { useCurrentSidebarCategory, filterDocCardListItems, } from './utils/docsUtils';
export { usePluralForm } from './utils/usePluralForm';
export { useCollapsible, Collapsible } from './components/Collapsible';
export { ThemeClassNames } from './utils/ThemeClassNames';
export { prefersReducedMotion } from './utils/accessibilityUtils';
export { useEvent, usePrevious, composeProviders, ReactContextError, } from './utils/reactUtils';
export { PageMetadata, HtmlClassNameProvider } from './utils/metadataUtils';
export { useColorMode, type ColorMode } from './contexts/colorMode';
export { NavbarSecondaryMenuFiller, type NavbarSecondaryMenuComponent, } from './contexts/navbarSecondaryMenu/content';
export { useWindowSize } from './hooks/useWindowSize';
export { translateTagsPageTitle, listTagsByLetters, type TagLetterEntry, } from './utils/tagsUtils';
export { useSearchQueryString, useSearchLinkCreator, } from './hooks/useSearchPage';
export { isMultiColumnFooterLinks } from './utils/footerUtils';
export { isRegexpStringMatch } from './utils/regexpUtils';
export { duplicates, uniq } from './utils/jsUtils';
export { usePrismTheme } from './hooks/usePrismTheme';
export { useDocsPreferredVersion } from './contexts/docsPreferredVersion';
export { processAdmonitionProps } from './utils/admonitionUtils';
export { SkipToContentFallbackId, SkipToContentLink, } from './utils/skipToContentUtils';
export { UnlistedBannerTitle, UnlistedBannerMessage, UnlistedMetadata, } from './utils/unlistedUtils';
export { ErrorBoundaryTryAgainButton, ErrorBoundaryError, ErrorBoundaryErrorMessageFallback, ErrorCauseBoundary, } from './utils/errorBoundaryUtils';
//# sourceMappingURL=index.d.ts.map

Some files were not shown because too many files have changed in this diff Show More