@mui/docs 9.0.0-alpha.3 → 9.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApiPage/ApiWarningAlert.d.ts +10 -0
- package/ApiPage/ApiWarningAlert.js +22 -0
- package/ApiPage/definitions/classes.d.ts +18 -0
- package/ApiPage/definitions/classes.js +54 -0
- package/ApiPage/definitions/index.d.ts +4 -0
- package/ApiPage/definitions/index.js +4 -0
- package/ApiPage/definitions/properties.d.ts +58 -0
- package/ApiPage/definitions/properties.js +110 -0
- package/ApiPage/definitions/slots.d.ts +16 -0
- package/ApiPage/definitions/slots.js +39 -0
- package/ApiPage/definitions/types.d.ts +53 -0
- package/ApiPage/definitions/types.js +1 -0
- package/ApiPage/index.d.ts +2 -0
- package/ApiPage/index.js +2 -0
- package/ApiPage/list/ClassesList.d.ts +11 -0
- package/ApiPage/list/ClassesList.js +103 -0
- package/ApiPage/list/ExpandableApiItem.d.ts +18 -0
- package/ApiPage/list/ExpandableApiItem.js +241 -0
- package/ApiPage/list/PropertiesList.d.ts +7 -0
- package/ApiPage/list/PropertiesList.js +263 -0
- package/ApiPage/list/SlotsList.d.ts +7 -0
- package/ApiPage/list/SlotsList.js +93 -0
- package/ApiPage/list/index.d.ts +1 -0
- package/ApiPage/list/index.js +1 -0
- package/ApiPage/private.d.ts +3 -0
- package/ApiPage/private.js +3 -0
- package/ApiPage/sections/ClassesSection.d.ts +34 -0
- package/ApiPage/sections/ClassesSection.js +76 -0
- package/ApiPage/sections/PropertiesSection.d.ts +45 -0
- package/ApiPage/sections/PropertiesSection.js +59 -0
- package/ApiPage/sections/SlotsSection.d.ts +24 -0
- package/ApiPage/sections/SlotsSection.js +61 -0
- package/ApiPage/sections/ToggleDisplayOption.d.ts +17 -0
- package/ApiPage/sections/ToggleDisplayOption.js +158 -0
- package/ApiPage/sections/index.d.ts +4 -0
- package/ApiPage/sections/index.js +4 -0
- package/ApiPage/table/ClassesTable.d.ts +7 -0
- package/ApiPage/table/ClassesTable.js +116 -0
- package/ApiPage/table/PropertiesTable.d.ts +6 -0
- package/ApiPage/table/PropertiesTable.js +286 -0
- package/ApiPage/table/SlotsTable.d.ts +6 -0
- package/ApiPage/table/SlotsTable.js +126 -0
- package/ApiPage/table/StyledTableContainer.d.ts +1 -0
- package/ApiPage/table/StyledTableContainer.js +42 -0
- package/ApiPage/types.d.ts +11 -0
- package/ApiPage/types.js +1 -0
- package/CHANGELOG.md +224 -3
- package/DemoContext/DemoContext.d.ts +1 -1
- package/{AnalyticsProvider → DocsApp}/AnalyticsProvider.js +10 -6
- package/DocsApp/DocsApp.d.ts +79 -0
- package/DocsApp/DocsApp.js +105 -0
- package/{GoogleAnalytics → DocsApp}/GoogleAnalytics.js +4 -4
- package/DocsApp/StyledEngineProvider.d.ts +8 -0
- package/{StyledEngineProvider → DocsApp}/StyledEngineProvider.js +2 -8
- package/DocsApp/consoleBanner.d.ts +1 -0
- package/DocsApp/consoleBanner.js +18 -0
- package/DocsApp/createGetInitialProps.d.ts +30 -0
- package/DocsApp/createGetInitialProps.js +29 -0
- package/DocsApp/index.d.ts +5 -0
- package/DocsApp/index.js +4 -0
- package/DocsApp/loadDependencies.d.ts +1 -0
- package/DocsApp/loadDependencies.js +9 -0
- package/DocsApp/reportWebVitals.d.ts +13 -0
- package/DocsApp/reportWebVitals.js +22 -0
- package/DocsApp/serviceWorker.d.ts +1 -0
- package/DocsApp/serviceWorker.js +59 -0
- package/Document/Document.js +2 -2
- package/Document/getInitialProps.js +3 -5
- package/InfoCard/InfoCard.js +9 -5
- package/Link/SkipLink.js +1 -3
- package/NextNProgressBar/NextNProgressBar.js +0 -2
- package/PageContext/PageContext.d.ts +6 -5
- package/branding/BrandingCssVarsProvider.d.ts +9 -5
- package/branding/BrandingCssVarsProvider.js +1 -1
- package/branding/brandingTheme.js +82 -75
- package/codeStyling/codeStyling.d.ts +7 -10
- package/codeStyling/codeStyling.js +0 -4
- package/codeVariant/codeVariant.d.ts +7 -10
- package/codeVariant/codeVariant.js +0 -4
- package/constants/constants.d.ts +10 -10
- package/constants/index.d.ts +1 -1
- package/constants/index.js +1 -1
- package/package.json +35 -44
- package/utils/index.js +0 -1
- package/webpack/index.d.ts +17 -0
- package/webpack/index.js +1 -0
- package/AnalyticsProvider/index.d.ts +0 -1
- package/AnalyticsProvider/index.js +0 -1
- package/GoogleAnalytics/index.d.ts +0 -1
- package/GoogleAnalytics/index.js +0 -1
- package/StyledEngineProvider/StyledEngineProvider.d.ts +0 -9
- package/StyledEngineProvider/index.d.ts +0 -1
- package/StyledEngineProvider/index.js +0 -1
- package/createEmotionCache/index.d.ts +0 -1
- package/createEmotionCache/index.js +0 -1
- /package/{AnalyticsProvider → DocsApp}/AnalyticsProvider.d.ts +0 -0
- /package/{GoogleAnalytics → DocsApp}/GoogleAnalytics.d.ts +0 -0
- /package/{createEmotionCache → DocsApp}/createEmotionCache.d.ts +0 -0
- /package/{createEmotionCache → DocsApp}/createEmotionCache.js +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var _br;
|
|
2
|
+
/* eslint-disable react/no-danger */
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import Box from '@mui/material/Box';
|
|
5
|
+
import { SectionTitle } from "../../SectionTitle/index.js";
|
|
6
|
+
import { useTranslate } from "../../i18n/index.js";
|
|
7
|
+
import { ToggleDisplayOption, useApiPageOption } from "./ToggleDisplayOption.js";
|
|
8
|
+
import { getClassApiDefinitions } from "../definitions/classes.js";
|
|
9
|
+
import ClassesTable from "../table/ClassesTable.js";
|
|
10
|
+
import ClassesList from "../list/ClassesList.js";
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
export function ClassesSection(props) {
|
|
13
|
+
const {
|
|
14
|
+
classes,
|
|
15
|
+
componentClasses,
|
|
16
|
+
classDescriptions,
|
|
17
|
+
componentName,
|
|
18
|
+
spreadHint,
|
|
19
|
+
title = 'api-docs.classes',
|
|
20
|
+
titleHash = 'classes',
|
|
21
|
+
level = 'h2',
|
|
22
|
+
displayClassKeys,
|
|
23
|
+
styleOverridesLink,
|
|
24
|
+
defaultLayout,
|
|
25
|
+
layoutStorageKey
|
|
26
|
+
} = props;
|
|
27
|
+
const t = useTranslate();
|
|
28
|
+
const [displayOption, setDisplayOption] = useApiPageOption(layoutStorageKey, defaultLayout);
|
|
29
|
+
const formattedClasses = classes || getClassApiDefinitions({
|
|
30
|
+
componentClasses,
|
|
31
|
+
classDescriptions,
|
|
32
|
+
componentName
|
|
33
|
+
});
|
|
34
|
+
if (!formattedClasses || formattedClasses.length === 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
38
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
39
|
+
sx: {
|
|
40
|
+
display: 'flex',
|
|
41
|
+
alignItems: 'baseline',
|
|
42
|
+
mb: 1
|
|
43
|
+
},
|
|
44
|
+
children: [/*#__PURE__*/_jsx(SectionTitle, {
|
|
45
|
+
title: t(title),
|
|
46
|
+
hash: titleHash,
|
|
47
|
+
level: level
|
|
48
|
+
}), /*#__PURE__*/_jsx(ToggleDisplayOption, {
|
|
49
|
+
displayOption: displayOption,
|
|
50
|
+
setDisplayOption: setDisplayOption,
|
|
51
|
+
sectionType: "classes"
|
|
52
|
+
})]
|
|
53
|
+
}), spreadHint && /*#__PURE__*/_jsx("p", {
|
|
54
|
+
dangerouslySetInnerHTML: {
|
|
55
|
+
__html: spreadHint
|
|
56
|
+
}
|
|
57
|
+
}), displayOption === 'table' ? /*#__PURE__*/_jsx(ClassesTable, {
|
|
58
|
+
classes: formattedClasses,
|
|
59
|
+
displayClassKeys: displayClassKeys
|
|
60
|
+
}) : /*#__PURE__*/_jsx(ClassesList, {
|
|
61
|
+
classes: formattedClasses,
|
|
62
|
+
displayOption: displayOption,
|
|
63
|
+
displayClassKeys: displayClassKeys
|
|
64
|
+
}), styleOverridesLink && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
65
|
+
children: [_br || (_br = /*#__PURE__*/_jsx("br", {})), /*#__PURE__*/_jsx("p", {
|
|
66
|
+
dangerouslySetInnerHTML: {
|
|
67
|
+
__html: t('api-docs.overrideStyles')
|
|
68
|
+
}
|
|
69
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
70
|
+
dangerouslySetInnerHTML: {
|
|
71
|
+
__html: t('api-docs.overrideStylesStyledComponent').replace(/{{styleOverridesLink}}/, styleOverridesLink)
|
|
72
|
+
}
|
|
73
|
+
})]
|
|
74
|
+
})]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { PropsTableItem, PropsTranslations } from '@mui-internal/api-docs-builder';
|
|
2
|
+
import { type ApiDisplayLayout } from "./ToggleDisplayOption.js";
|
|
3
|
+
import { type SectionTitleProps } from "../../SectionTitle/index.js";
|
|
4
|
+
import { LayoutStorageKeys } from "../types.js";
|
|
5
|
+
import { PropertyDefinition } from "../definitions/index.js";
|
|
6
|
+
type PropertiesSectionProps = ({
|
|
7
|
+
properties: {
|
|
8
|
+
[name: string]: PropsTableItem & {
|
|
9
|
+
isProPlan?: true;
|
|
10
|
+
isPremiumPlan?: true;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
propertiesDescriptions: PropsTranslations['propDescriptions'];
|
|
14
|
+
componentName: string;
|
|
15
|
+
/**
|
|
16
|
+
* Add indicators that the properties is optional instead of showing it is required.
|
|
17
|
+
*/
|
|
18
|
+
showOptionalAbbr?: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
showOptionalAbbr?: undefined;
|
|
21
|
+
properties: PropertyDefinition[];
|
|
22
|
+
propertiesDescriptions?: undefined;
|
|
23
|
+
componentName?: undefined;
|
|
24
|
+
}) & {
|
|
25
|
+
spreadHint?: string;
|
|
26
|
+
defaultLayout: ApiDisplayLayout;
|
|
27
|
+
layoutStorageKey: LayoutStorageKeys['props'];
|
|
28
|
+
/**
|
|
29
|
+
* The translation key of the section title.
|
|
30
|
+
* @default 'api-docs.props'
|
|
31
|
+
*/
|
|
32
|
+
title?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The hash linking to the section title.
|
|
35
|
+
* @default 'props'
|
|
36
|
+
*/
|
|
37
|
+
titleHash?: SectionTitleProps['hash'];
|
|
38
|
+
/**
|
|
39
|
+
* The title level of the section.
|
|
40
|
+
* @default 'h2'
|
|
41
|
+
*/
|
|
42
|
+
level?: SectionTitleProps['level'];
|
|
43
|
+
};
|
|
44
|
+
export declare function PropertiesSection(props: PropertiesSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* eslint-disable react/no-danger */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import { useTranslate } from "../../i18n/index.js";
|
|
5
|
+
import { ToggleDisplayOption, useApiPageOption } from "./ToggleDisplayOption.js";
|
|
6
|
+
import { SectionTitle } from "../../SectionTitle/index.js";
|
|
7
|
+
import PropertiesTable from "../table/PropertiesTable.js";
|
|
8
|
+
import PropertiesList from "../list/PropertiesList.js";
|
|
9
|
+
import { getPropsApiDefinitions } from "../definitions/properties.js";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
export function PropertiesSection(props) {
|
|
12
|
+
const {
|
|
13
|
+
properties,
|
|
14
|
+
propertiesDescriptions,
|
|
15
|
+
componentName,
|
|
16
|
+
title = 'api-docs.props',
|
|
17
|
+
titleHash = 'props',
|
|
18
|
+
level = 'h2',
|
|
19
|
+
spreadHint,
|
|
20
|
+
defaultLayout,
|
|
21
|
+
layoutStorageKey,
|
|
22
|
+
showOptionalAbbr
|
|
23
|
+
} = props;
|
|
24
|
+
const t = useTranslate();
|
|
25
|
+
const [displayOption, setDisplayOption] = useApiPageOption(layoutStorageKey, defaultLayout);
|
|
26
|
+
const formattedProperties = Array.isArray(properties) ? properties : getPropsApiDefinitions({
|
|
27
|
+
properties,
|
|
28
|
+
propertiesDescriptions: propertiesDescriptions,
|
|
29
|
+
componentName: componentName,
|
|
30
|
+
showOptionalAbbr
|
|
31
|
+
});
|
|
32
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
33
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
34
|
+
sx: {
|
|
35
|
+
display: 'flex',
|
|
36
|
+
alignItems: 'baseline',
|
|
37
|
+
mb: 1
|
|
38
|
+
},
|
|
39
|
+
children: [/*#__PURE__*/_jsx(SectionTitle, {
|
|
40
|
+
title: t(title),
|
|
41
|
+
hash: titleHash,
|
|
42
|
+
level: level
|
|
43
|
+
}), /*#__PURE__*/_jsx(ToggleDisplayOption, {
|
|
44
|
+
displayOption: displayOption,
|
|
45
|
+
setDisplayOption: setDisplayOption,
|
|
46
|
+
sectionType: "props"
|
|
47
|
+
})]
|
|
48
|
+
}), spreadHint && /*#__PURE__*/_jsx("p", {
|
|
49
|
+
dangerouslySetInnerHTML: {
|
|
50
|
+
__html: spreadHint
|
|
51
|
+
}
|
|
52
|
+
}), displayOption === 'table' ? /*#__PURE__*/_jsx(PropertiesTable, {
|
|
53
|
+
properties: formattedProperties
|
|
54
|
+
}) : /*#__PURE__*/_jsx(PropertiesList, {
|
|
55
|
+
properties: formattedProperties,
|
|
56
|
+
displayOption: displayOption
|
|
57
|
+
})]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ComponentApiContent } from '@mui-internal/api-docs-builder';
|
|
2
|
+
import { SlotDefinition } from "../definitions/types.js";
|
|
3
|
+
import { type ApiDisplayLayout } from "./ToggleDisplayOption.js";
|
|
4
|
+
export type SlotsSectionProps = ({
|
|
5
|
+
slots: SlotDefinition[];
|
|
6
|
+
componentSlots?: undefined;
|
|
7
|
+
slotDescriptions?: undefined;
|
|
8
|
+
componentName?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
slots: undefined;
|
|
11
|
+
componentSlots: ComponentApiContent['slots'];
|
|
12
|
+
slotDescriptions: {
|
|
13
|
+
[key: string]: string;
|
|
14
|
+
};
|
|
15
|
+
componentName: string;
|
|
16
|
+
}) & {
|
|
17
|
+
title?: string;
|
|
18
|
+
titleHash?: string;
|
|
19
|
+
level?: 'h2' | 'h3' | 'h4';
|
|
20
|
+
defaultLayout: ApiDisplayLayout;
|
|
21
|
+
layoutStorageKey: string;
|
|
22
|
+
spreadHint?: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function SlotsSection(props: SlotsSectionProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* eslint-disable react/no-danger */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import { useTranslate } from "../../i18n/index.js";
|
|
5
|
+
import { SectionTitle } from "../../SectionTitle/index.js";
|
|
6
|
+
import SlotsList from "../list/SlotsList.js";
|
|
7
|
+
import SlotsTable from "../table/SlotsTable.js";
|
|
8
|
+
import { ToggleDisplayOption, useApiPageOption } from "./ToggleDisplayOption.js";
|
|
9
|
+
import { getSlotsApiDefinitions } from "../definitions/slots.js";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
export function SlotsSection(props) {
|
|
12
|
+
const {
|
|
13
|
+
slots,
|
|
14
|
+
componentSlots,
|
|
15
|
+
slotDescriptions,
|
|
16
|
+
componentName,
|
|
17
|
+
title = 'api-docs.slots',
|
|
18
|
+
titleHash = 'slots',
|
|
19
|
+
level = 'h2',
|
|
20
|
+
spreadHint,
|
|
21
|
+
defaultLayout,
|
|
22
|
+
layoutStorageKey
|
|
23
|
+
} = props;
|
|
24
|
+
const t = useTranslate();
|
|
25
|
+
const [displayOption, setDisplayOption] = useApiPageOption(layoutStorageKey, defaultLayout);
|
|
26
|
+
const formattedSlots = slots ?? getSlotsApiDefinitions({
|
|
27
|
+
componentSlots,
|
|
28
|
+
slotDescriptions,
|
|
29
|
+
componentName
|
|
30
|
+
});
|
|
31
|
+
if (!formattedSlots || formattedSlots.length === 0) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
35
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
36
|
+
sx: {
|
|
37
|
+
display: 'flex',
|
|
38
|
+
alignItems: 'baseline',
|
|
39
|
+
mb: 1
|
|
40
|
+
},
|
|
41
|
+
children: [/*#__PURE__*/_jsx(SectionTitle, {
|
|
42
|
+
title: t(title),
|
|
43
|
+
hash: titleHash,
|
|
44
|
+
level: level
|
|
45
|
+
}), /*#__PURE__*/_jsx(ToggleDisplayOption, {
|
|
46
|
+
displayOption: displayOption,
|
|
47
|
+
setDisplayOption: setDisplayOption,
|
|
48
|
+
sectionType: "slots"
|
|
49
|
+
})]
|
|
50
|
+
}), spreadHint && /*#__PURE__*/_jsx("p", {
|
|
51
|
+
dangerouslySetInnerHTML: {
|
|
52
|
+
__html: spreadHint
|
|
53
|
+
}
|
|
54
|
+
}), displayOption === 'table' ? /*#__PURE__*/_jsx(SlotsTable, {
|
|
55
|
+
slots: formattedSlots
|
|
56
|
+
}) : /*#__PURE__*/_jsx(SlotsList, {
|
|
57
|
+
slots: formattedSlots,
|
|
58
|
+
displayOption: displayOption
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type ApiDisplayLayout = 'collapsed' | 'expanded' | 'table';
|
|
2
|
+
export declare const DEFAULT_API_LAYOUT_STORAGE_KEYS: {
|
|
3
|
+
readonly slots: "apiPage_slots";
|
|
4
|
+
readonly props: "apiPage_props";
|
|
5
|
+
readonly classes: "apiPage_classes";
|
|
6
|
+
};
|
|
7
|
+
export declare function useApiPageOption(storageKey: string, defaultValue: ApiDisplayLayout): [ApiDisplayLayout, (newOption: ApiDisplayLayout) => void];
|
|
8
|
+
interface ToggleDisplayOptionProps {
|
|
9
|
+
displayOption: ApiDisplayLayout;
|
|
10
|
+
setDisplayOption: (newValue: ApiDisplayLayout) => void;
|
|
11
|
+
/**
|
|
12
|
+
* The type of section. This value is used to send correct event to Google Analytics.
|
|
13
|
+
*/
|
|
14
|
+
sectionType: 'classes' | 'props' | 'slots';
|
|
15
|
+
}
|
|
16
|
+
export declare function ToggleDisplayOption(props: ToggleDisplayOptionProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
var _ArrowDropDownRounded;
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import Button from '@mui/material/Button';
|
|
5
|
+
import Menu from '@mui/material/Menu';
|
|
6
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
7
|
+
import CheckIcon from '@mui/icons-material/Check';
|
|
8
|
+
import ArrowDropDownRoundedIcon from '@mui/icons-material/ArrowDropDownRounded';
|
|
9
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const options = ['collapsed', 'expanded', 'table'];
|
|
12
|
+
export const DEFAULT_API_LAYOUT_STORAGE_KEYS = {
|
|
13
|
+
slots: 'apiPage_slots',
|
|
14
|
+
props: 'apiPage_props',
|
|
15
|
+
classes: 'apiPage_classes'
|
|
16
|
+
};
|
|
17
|
+
let neverHydrated = true;
|
|
18
|
+
function getOption(storageKey, defaultValue) {
|
|
19
|
+
if (neverHydrated) {
|
|
20
|
+
return defaultValue;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const savedOption = localStorage.getItem(storageKey);
|
|
24
|
+
if (savedOption !== null && options.includes(savedOption)) {
|
|
25
|
+
return savedOption;
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return defaultValue;
|
|
29
|
+
}
|
|
30
|
+
return defaultValue;
|
|
31
|
+
}
|
|
32
|
+
export function useApiPageOption(storageKey, defaultValue) {
|
|
33
|
+
const [option, setOption] = React.useState(getOption(storageKey, defaultValue));
|
|
34
|
+
useEnhancedEffect(() => {
|
|
35
|
+
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- useEnhancedEffect uses useEffect under the hood
|
|
36
|
+
neverHydrated = false;
|
|
37
|
+
const newOption = getOption(storageKey, defaultValue);
|
|
38
|
+
setOption(newOption);
|
|
39
|
+
}, [storageKey, defaultValue]);
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
if (option !== defaultValue) {
|
|
42
|
+
const id = document.location.hash.slice(1);
|
|
43
|
+
const element = document.getElementById(id);
|
|
44
|
+
element?.scrollIntoView();
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}, [option, defaultValue]);
|
|
48
|
+
const updateOption = React.useCallback(newOption => {
|
|
49
|
+
try {
|
|
50
|
+
localStorage.setItem(storageKey, newOption);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
// Do nothing
|
|
53
|
+
}
|
|
54
|
+
setOption(newOption);
|
|
55
|
+
}, [storageKey]);
|
|
56
|
+
return [option, updateOption];
|
|
57
|
+
}
|
|
58
|
+
export function ToggleDisplayOption(props) {
|
|
59
|
+
const {
|
|
60
|
+
displayOption,
|
|
61
|
+
setDisplayOption,
|
|
62
|
+
sectionType
|
|
63
|
+
} = props;
|
|
64
|
+
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
65
|
+
const [open, setOpen] = React.useState(false);
|
|
66
|
+
const handleMenuClick = event => {
|
|
67
|
+
setAnchorEl(event.currentTarget);
|
|
68
|
+
setOpen(true);
|
|
69
|
+
};
|
|
70
|
+
const handleClose = () => {
|
|
71
|
+
setAnchorEl(null);
|
|
72
|
+
setOpen(false);
|
|
73
|
+
};
|
|
74
|
+
const handleMenuItemClick = newDisplayOption => {
|
|
75
|
+
setDisplayOption(newDisplayOption);
|
|
76
|
+
handleClose();
|
|
77
|
+
};
|
|
78
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
79
|
+
children: [/*#__PURE__*/_jsxs(Button, {
|
|
80
|
+
size: "small",
|
|
81
|
+
variant: "outlined",
|
|
82
|
+
color: "secondary",
|
|
83
|
+
id: "view-switching-button",
|
|
84
|
+
"aria-controls": open ? 'view-switching-button' : undefined,
|
|
85
|
+
"aria-haspopup": "true",
|
|
86
|
+
"aria-expanded": open ? 'true' : undefined,
|
|
87
|
+
onClick: handleMenuClick,
|
|
88
|
+
endIcon: _ArrowDropDownRounded || (_ArrowDropDownRounded = /*#__PURE__*/_jsx(ArrowDropDownRoundedIcon, {})),
|
|
89
|
+
sx: {
|
|
90
|
+
height: '1.875rem',
|
|
91
|
+
p: '6px 4px 6px 8px',
|
|
92
|
+
textTransform: 'capitalize'
|
|
93
|
+
},
|
|
94
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
95
|
+
component: "span",
|
|
96
|
+
sx: {
|
|
97
|
+
fontWeight: 'medium',
|
|
98
|
+
mr: 0.5
|
|
99
|
+
},
|
|
100
|
+
children: 'View:'
|
|
101
|
+
}), displayOption]
|
|
102
|
+
}), /*#__PURE__*/_jsxs(Menu, {
|
|
103
|
+
id: "view-options-menu",
|
|
104
|
+
anchorEl: anchorEl,
|
|
105
|
+
open: open,
|
|
106
|
+
onClose: handleClose,
|
|
107
|
+
sx: {
|
|
108
|
+
mt: 1,
|
|
109
|
+
'.MuiMenuItem-root': {
|
|
110
|
+
pl: 1
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
children: [/*#__PURE__*/_jsxs(MenuItem, {
|
|
114
|
+
value: "table",
|
|
115
|
+
onClick: () => handleMenuItemClick('table'),
|
|
116
|
+
selected: displayOption === 'table',
|
|
117
|
+
"data-ga-event-category": "layout",
|
|
118
|
+
"data-ga-event-action": sectionType,
|
|
119
|
+
"data-ga-event-label": "table",
|
|
120
|
+
children: ['Table', /*#__PURE__*/_jsx(CheckIcon, {
|
|
121
|
+
sx: {
|
|
122
|
+
fontSize: '0.85rem',
|
|
123
|
+
ml: 'auto',
|
|
124
|
+
opacity: displayOption === 'table' ? 1 : 0
|
|
125
|
+
}
|
|
126
|
+
})]
|
|
127
|
+
}), /*#__PURE__*/_jsxs(MenuItem, {
|
|
128
|
+
value: "expanded",
|
|
129
|
+
onClick: () => handleMenuItemClick('expanded'),
|
|
130
|
+
selected: displayOption === 'expanded',
|
|
131
|
+
"data-ga-event-category": "layout",
|
|
132
|
+
"data-ga-event-action": sectionType,
|
|
133
|
+
"data-ga-event-label": "expanded",
|
|
134
|
+
children: ['Expanded list', /*#__PURE__*/_jsx(CheckIcon, {
|
|
135
|
+
sx: {
|
|
136
|
+
fontSize: '0.85rem',
|
|
137
|
+
ml: 'auto',
|
|
138
|
+
opacity: displayOption === 'expanded' ? 1 : 0
|
|
139
|
+
}
|
|
140
|
+
})]
|
|
141
|
+
}), /*#__PURE__*/_jsxs(MenuItem, {
|
|
142
|
+
value: "collapsed",
|
|
143
|
+
onClick: () => handleMenuItemClick('collapsed'),
|
|
144
|
+
selected: displayOption === 'collapsed',
|
|
145
|
+
"data-ga-event-category": "layout",
|
|
146
|
+
"data-ga-event-action": sectionType,
|
|
147
|
+
"data-ga-event-label": "collapsed",
|
|
148
|
+
children: ['Collapsed list', /*#__PURE__*/_jsx(CheckIcon, {
|
|
149
|
+
sx: {
|
|
150
|
+
fontSize: '0.85rem',
|
|
151
|
+
ml: 'auto',
|
|
152
|
+
opacity: displayOption === 'collapsed' ? 1 : 0
|
|
153
|
+
}
|
|
154
|
+
})]
|
|
155
|
+
})]
|
|
156
|
+
})]
|
|
157
|
+
});
|
|
158
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ClassDefinition } from "../definitions/types.js";
|
|
2
|
+
interface ClassesTableProps {
|
|
3
|
+
classes: ClassDefinition[];
|
|
4
|
+
displayClassKeys?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export default function ClassesTable(props: ClassesTableProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var _th, _th2, _th3;
|
|
2
|
+
/* eslint-disable react/no-danger */
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { styled, alpha } from '@mui/material/styles';
|
|
5
|
+
import { brandingDarkTheme as darkTheme, brandingLightTheme as lightTheme } from "../../branding/index.js";
|
|
6
|
+
import { useTranslate } from "../../i18n/index.js";
|
|
7
|
+
import { StyledTableContainer } from "./StyledTableContainer.js";
|
|
8
|
+
import { ApiWarningAlert } from "../ApiWarningAlert.js";
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const StyledTable = styled('table')(({
|
|
11
|
+
theme
|
|
12
|
+
}) => ({
|
|
13
|
+
textAlign: 'left',
|
|
14
|
+
// Override docs/src/modules/components/MarkdownElement styles
|
|
15
|
+
'&&': {
|
|
16
|
+
display: 'table',
|
|
17
|
+
width: '100%'
|
|
18
|
+
},
|
|
19
|
+
'& .class-name': {
|
|
20
|
+
flexShrink: 0,
|
|
21
|
+
fontWeight: theme.typography.fontWeightSemiBold,
|
|
22
|
+
fontFamily: theme.typography.fontFamilyCode,
|
|
23
|
+
fontSize: theme.typography.pxToRem(13),
|
|
24
|
+
color: `var(--muidocs-palette-primary-600, ${lightTheme.palette.primary[600]})`
|
|
25
|
+
},
|
|
26
|
+
'& .class-key': {
|
|
27
|
+
...theme.typography.caption,
|
|
28
|
+
fontFamily: theme.typography.fontFamilyCode,
|
|
29
|
+
fontWeight: theme.typography.fontWeightRegular,
|
|
30
|
+
color: `var(--muidocs-palette-text-primary, ${lightTheme.palette.text.primary})`,
|
|
31
|
+
padding: '1px 4px',
|
|
32
|
+
borderRadius: 6,
|
|
33
|
+
border: '1px solid',
|
|
34
|
+
borderColor: alpha(darkTheme.palette.primary[100], 0.8),
|
|
35
|
+
backgroundColor: `var(--muidocs-palette-primary-50, ${lightTheme.palette.primary[50]})`
|
|
36
|
+
}
|
|
37
|
+
}), ({
|
|
38
|
+
theme
|
|
39
|
+
}) => ({
|
|
40
|
+
[`:where(${theme.vars ? '[data-mui-color-scheme="dark"]' : '.mode-dark'}) &`]: {
|
|
41
|
+
'& .class-name': {
|
|
42
|
+
color: `var(--muidocs-palette-primary-200, ${darkTheme.palette.primary[200]})`
|
|
43
|
+
},
|
|
44
|
+
'& .class-key': {
|
|
45
|
+
color: `var(--muidocs-palette-text-primary, ${darkTheme.palette.text.primary})`,
|
|
46
|
+
borderColor: alpha(darkTheme.palette.primary[400], 0.1),
|
|
47
|
+
backgroundColor: alpha(darkTheme.palette.primary[900], 0.4)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
export default function ClassesTable(props) {
|
|
52
|
+
const {
|
|
53
|
+
classes,
|
|
54
|
+
displayClassKeys
|
|
55
|
+
} = props;
|
|
56
|
+
const t = useTranslate();
|
|
57
|
+
return /*#__PURE__*/_jsx(StyledTableContainer, {
|
|
58
|
+
children: /*#__PURE__*/_jsxs(StyledTable, {
|
|
59
|
+
children: [/*#__PURE__*/_jsx("thead", {
|
|
60
|
+
children: /*#__PURE__*/_jsxs("tr", {
|
|
61
|
+
children: [_th || (_th = /*#__PURE__*/_jsx("th", {
|
|
62
|
+
children: 'Class name'
|
|
63
|
+
})), displayClassKeys && (_th2 || (_th2 = /*#__PURE__*/_jsx("th", {
|
|
64
|
+
children: 'Rule name'
|
|
65
|
+
}))), _th3 || (_th3 = /*#__PURE__*/_jsx("th", {
|
|
66
|
+
children: 'Description'
|
|
67
|
+
}))]
|
|
68
|
+
})
|
|
69
|
+
}), /*#__PURE__*/_jsx("tbody", {
|
|
70
|
+
children: classes.map(params => {
|
|
71
|
+
const {
|
|
72
|
+
className,
|
|
73
|
+
hash,
|
|
74
|
+
key,
|
|
75
|
+
description,
|
|
76
|
+
isGlobal,
|
|
77
|
+
isDeprecated,
|
|
78
|
+
deprecationInfo
|
|
79
|
+
} = params;
|
|
80
|
+
return /*#__PURE__*/_jsxs("tr", {
|
|
81
|
+
id: hash,
|
|
82
|
+
children: [/*#__PURE__*/_jsx("td", {
|
|
83
|
+
className: "algolia-lvl3",
|
|
84
|
+
children: /*#__PURE__*/_jsxs("span", {
|
|
85
|
+
className: "class-name",
|
|
86
|
+
children: [".", className]
|
|
87
|
+
})
|
|
88
|
+
}), displayClassKeys && /*#__PURE__*/_jsx("td", {
|
|
89
|
+
children: !isGlobal && /*#__PURE__*/_jsx("span", {
|
|
90
|
+
className: "class-key",
|
|
91
|
+
children: key
|
|
92
|
+
})
|
|
93
|
+
}), /*#__PURE__*/_jsxs("td", {
|
|
94
|
+
className: "algolia-content",
|
|
95
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
96
|
+
dangerouslySetInnerHTML: {
|
|
97
|
+
__html: description || ''
|
|
98
|
+
}
|
|
99
|
+
}), isDeprecated && /*#__PURE__*/_jsxs(ApiWarningAlert, {
|
|
100
|
+
children: [/*#__PURE__*/_jsx("b", {
|
|
101
|
+
children: t('api-docs.deprecated')
|
|
102
|
+
}), deprecationInfo && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
103
|
+
children: ['-', /*#__PURE__*/_jsx("span", {
|
|
104
|
+
dangerouslySetInnerHTML: {
|
|
105
|
+
__html: deprecationInfo
|
|
106
|
+
}
|
|
107
|
+
})]
|
|
108
|
+
})]
|
|
109
|
+
})]
|
|
110
|
+
})]
|
|
111
|
+
}, className);
|
|
112
|
+
})
|
|
113
|
+
})]
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
}
|