Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs][base] Show components & hooks API on the components page #35938

Merged
merged 101 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
f1fde60
[docs] Add hooks API pages
mnajdova Jan 14, 2023
e079c7c
more progress
mnajdova Jan 16, 2023
0ae093f
more fixes
mnajdova Jan 16, 2023
092f1de
link hooks in the component's API section
mnajdova Jan 16, 2023
6c1ee0e
fix default values
mnajdova Jan 17, 2023
1f69369
cleanup
mnajdova Jan 17, 2023
542ce9f
link other hooks on the unstyled component pages
mnajdova Jan 17, 2023
a9400c4
add annotation on the hooks
mnajdova Jan 17, 2023
7c2c19b
small fixes
mnajdova Jan 18, 2023
dc56c8e
Add return value generation logic & UseButtonReturnValue interface
mnajdova Jan 18, 2023
bd3d393
Fix useMenuItem ts issue
mnajdova Jan 18, 2023
7f56ce9
Fix UseButtonReturnValue
mnajdova Jan 18, 2023
a5e213b
Update docs/src/modules/components/AppNavDrawer.js
mnajdova Jan 18, 2023
ce67b74
yarn docs:api
mnajdova Jan 18, 2023
6f0c397
Merge branch 'docs/build-hooks-interfaces' of https://github.com/mnaj…
mnajdova Jan 18, 2023
4a38c6a
updated parseMarkdown tests
mnajdova Jan 18, 2023
aa31bd7
Improve the demos link to point to the hook section
mnajdova Jan 19, 2023
54e5e19
Resolve comments from backlog grooming
mnajdova Jan 21, 2023
a5c2670
Renamed inputParams to parameters, renamed returnValue hash to return…
mnajdova Jan 23, 2023
1406831
Show optional abbr for return value
mnajdova Jan 23, 2023
ebf4760
Extract the PropertiesTable in a standalone component
mnajdova Jan 23, 2023
516d805
Merge branch 'master' into docs/build-hooks-interfaces
mnajdova Jan 24, 2023
ae9aa4a
prettier
mnajdova Jan 24, 2023
00c387c
Renamed Sidebar Component API group to API
mnajdova Jan 24, 2023
9109535
[poc] API tabs in the components pages
mnajdova Jan 24, 2023
818db5f
Make all tabs working
mnajdova Jan 24, 2023
9df6d1f
link component API page to the correct tab
mnajdova Jan 25, 2023
5a681bb
prettier
mnajdova Jan 25, 2023
88662d2
React on query change if on the same page
mnajdova Jan 25, 2023
4dac374
Remove API from toc
mnajdova Jan 25, 2023
cbd8c4e
Place the tabs before the ad, make the tabs sticky in the header
mnajdova Jan 25, 2023
3285aec
Append query param on tab click
mnajdova Jan 25, 2023
65bac95
Update docs/src/modules/components/ComponentPageTabs.js
mnajdova Jan 25, 2023
0a2714f
Hide tabs, instead of re-rendering them, updated the JSdocs for the u…
mnajdova Jan 27, 2023
070c23e
Merge branch 'poc/hook-api-links' of https://github.com/mnajdova/mate…
mnajdova Jan 27, 2023
7375be5
Fix layout shift on ad
mnajdova Jan 27, 2023
1ac4320
Merge branch 'master' into poc/hook-api-links
mnajdova Feb 6, 2023
76db35d
merge conflicts
mnajdova Feb 6, 2023
aeddc79
Add components & demo tabs for the react-tabs page
mnajdova Feb 6, 2023
7b63565
Link API pages correctly
mnajdova Feb 7, 2023
2a0bc36
Improve the tab bars sticky position styles in all screen sizes
mnajdova Feb 8, 2023
8bd1a99
tabs in the header design tweaks + a couple of things more
danilo-leal Feb 10, 2023
2599f1d
fix chips bg color on dark mode
danilo-leal Feb 10, 2023
cdcd600
Merge branch 'master' into poc/hook-api-links
mnajdova Feb 10, 2023
aa9150a
fix scroll margin top
danilo-leal Feb 12, 2023
ff825b8
fix tabs width on mobile
danilo-leal Feb 12, 2023
e18b6a3
remove seemingly unnecessary heading padding
danilo-leal Feb 12, 2023
9f1b2d7
Merge branch 'poc/hook-api-links' of https://github.com/mnajdova/mate…
mnajdova Feb 13, 2023
0ace11c
Merge branch 'master' into poc/hook-api-links
mnajdova Feb 13, 2023
ac029ae
Fix import spacing
mnajdova Feb 14, 2023
85683d1
Merge branch 'master' into poc/hook-api-links
mnajdova Feb 28, 2023
698b744
add step in the yarn docs:api to update the react pages js files
mnajdova Feb 28, 2023
f3e1ae5
add static paths
mnajdova Mar 1, 2023
4e046d8
Try different export mapping
mnajdova Mar 1, 2023
a7eb62e
few changes
mnajdova Mar 2, 2023
dedd0b1
conflicting paths
mnajdova Mar 2, 2023
29284a3
Fix ssr on the demos page
mnajdova Mar 2, 2023
a1eca78
active page should always be the components page
mnajdova Mar 2, 2023
ab1e1e5
active page fix
mnajdova Mar 2, 2023
b70263f
Improve open in new tab/window scenarios
mnajdova Mar 2, 2023
dcb2a53
prettier
mnajdova Mar 2, 2023
a3c8c81
generate correct api pages, update pages for all components
mnajdova Mar 3, 2023
8178f97
add the tabs on all pages
mnajdova Mar 3, 2023
fb9aec4
Merge branch 'master' into poc/hook-api-links
mnajdova Mar 3, 2023
d288bf3
update docs:api
mnajdova Mar 3, 2023
9b124cf
merge conflict correctly resolved
mnajdova Mar 3, 2023
b1ae2ea
[docs] Hooks api tabs alternative links v2
mnajdova Mar 6, 2023
4597e20
make server side tab indicator styles closer to hydrated
mnajdova Mar 13, 2023
488ec78
Fix scroll
mnajdova Mar 13, 2023
a3ad0bf
remove transition between shallow links
mnajdova Mar 13, 2023
a821950
Resolve the last comments
mnajdova Mar 13, 2023
6de66ba
Update the build script to generate the new structure of the files, r…
mnajdova Mar 15, 2023
8615acc
fixed some lint issues
mnajdova Mar 15, 2023
cffb308
fix wrong import
mnajdova Mar 15, 2023
b525835
Update docs/src/modules/components/AppTableOfContents.js
mnajdova Mar 15, 2023
d3ec3c7
improve the API links
mnajdova Mar 15, 2023
bafed49
change the api links to plural
mnajdova Mar 15, 2023
25d6777
Fix error for active page
mnajdova Mar 15, 2023
cb7deb7
Update the JSDocs descriptions
mnajdova Mar 16, 2023
dfadb05
Fix wrong prop type definition
mnajdova Mar 16, 2023
f3bd253
prettier
mnajdova Mar 16, 2023
0a888e2
Update the buildApi script to not generate the old format of the api …
mnajdova Mar 16, 2023
9f1f788
still generate the json files
mnajdova Mar 16, 2023
7c4fbf8
fix lint issues & add test
mnajdova Mar 16, 2023
d9f1b10
Merge branch 'master' into poc/hook-api-links
mnajdova Mar 16, 2023
197c8a5
simplify index pages, use translations
mnajdova Mar 16, 2023
d275fed
improve the name of the method for generating pages
mnajdova Mar 16, 2023
2cab5f2
simplify the code in buildApiUtils
mnajdova Mar 16, 2023
b120b8c
Merge branch 'master' into poc/hook-api-links
mnajdova Mar 23, 2023
500982e
fix hooks import statement, remove description from API page
mnajdova Mar 23, 2023
2371cc5
remove unused var
mnajdova Mar 23, 2023
e852285
update test
mnajdova Mar 23, 2023
5bdd759
Jun's review
mnajdova Mar 24, 2023
87f3bc9
Resolve comments
mnajdova Mar 28, 2023
df7ff54
tweak divider styles
danilo-leal Mar 28, 2023
db913bd
last batch of design tweaks
danilo-leal Mar 28, 2023
9c8b350
one more detail
danilo-leal Mar 28, 2023
051e12b
Merge branch 'master' into poc/hook-api-links
mnajdova Mar 29, 2023
e4f723b
add useOption hook in the docs
mnajdova Mar 29, 2023
4ae86fe
add redirects
mnajdova Mar 29, 2023
1ddf6e8
Merge branch 'master' into poc/hook-api-links
mnajdova Mar 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/data/base/components/badge/badge.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
product: base
title: Unstyled React Badge component and hook
components: BadgeUnstyled
hooks: useBadge
githubLabel: 'component: badge'
---

Expand Down
3 changes: 3 additions & 0 deletions docs/data/base/components/button/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
product: base
title: Unstyled React Button component and hook
components: ButtonUnstyled
hooks: useButton
githubLabel: 'component: button'
waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/button/
---
Expand All @@ -10,6 +11,8 @@ waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/button/

<p class="description">Buttons let users take actions and make choices with a single tap.</p>

{{"component": "modules/components/ComponentPageTabs.js"}}

## Introduction

The Unstyled Button component replaces the native HTML `<button>` element, and offers expanded options for styling and accessibility.
Expand Down
1 change: 1 addition & 0 deletions docs/data/base/components/form-control/form-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
product: base
title: Unstyled React Form Control component and hook
components: FormControlUnstyled
hooks: useFormControlUnstyledContext
githubLabel: 'component: FormControl'
---

Expand Down
1 change: 1 addition & 0 deletions docs/data/base/components/input/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
product: base
title: Unstyled React Input component and hook
components: InputUnstyled
hooks: useInput
githubLabel: 'component: input'
---

Expand Down
1 change: 1 addition & 0 deletions docs/data/base/components/menu/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
product: base
title: Unstyled React Menu components and hooks
components: MenuUnstyled, MenuItemUnstyled
hooks: useMenu, useMenuItem
githubLabel: 'component: menu'
waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/menubutton/
---
Expand Down
1 change: 1 addition & 0 deletions docs/data/base/components/slider/slider.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
product: base
title: Unstyled React Slider component and hook
components: SliderUnstyled
hooks: useSlider
githubLabel: 'component: slider'
waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/slidertwothumb/
---
Expand Down
1 change: 1 addition & 0 deletions docs/data/base/components/snackbar/snackbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
product: base
title: Unstyled React Snackbar component and hook
components: SnackbarUnstyled
hooks: useSnackbar
githubLabel: 'component: snackbar'
---

Expand Down
1 change: 1 addition & 0 deletions docs/data/base/components/switch/switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
product: base
title: Unstyled React Switch component and hook
components: SwitchUnstyled
hooks: useSwitch
githubLabel: 'component: switch'
waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/switch/
---
Expand Down
1 change: 1 addition & 0 deletions docs/data/base/components/tabs/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
product: base
title: Unstyled React Tabs components
components: TabsUnstyled, TabUnstyled, TabPanelUnstyled, TabsListUnstyled
hooks: useTab, useTabPanel, useTabs, useTabsList
githubLabel: 'component: tabs'
waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/
---
Expand Down
2 changes: 1 addition & 1 deletion docs/data/base/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const pages = [
],
},
{
title: 'Component API',
title: 'APIs',
pathname: '/base/api',
icon: 'CodeIcon',
children: pagesApi,
Expand Down
25 changes: 24 additions & 1 deletion docs/data/base/pagesApi.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = [
{ pathname: '/base/api/badge-unstyled' },
{ pathname: '/base/api/button-unstyled' },
{
pathname: '/base/react-button',
query: { docsTab: 'component-api' },
title: 'ButtonUnstyled',
},
{ pathname: '/base/api/click-away-listener' },
{ pathname: '/base/api/focus-trap' },
{ pathname: '/base/api/form-control-unstyled' },
Expand All @@ -24,4 +28,23 @@ module.exports = [
{ pathname: '/base/api/tabs-unstyled' },
{ pathname: '/base/api/tab-unstyled' },
{ pathname: '/base/api/textarea-autosize' },
{ pathname: '/base/api/use-autocomplete' },
{ pathname: '/base/api/use-badge' },
{
pathname: '/base/react-button',
query: { docsTab: 'hook-api' },
title: 'useButton',
},
{ pathname: '/base/api/use-form-control-unstyled-context' },
{ pathname: '/base/api/use-input' },
{ pathname: '/base/api/use-menu' },
{ pathname: '/base/api/use-menu-item' },
{ pathname: '/base/api/use-select' },
{ pathname: '/base/api/use-slider' },
{ pathname: '/base/api/use-snackbar' },
{ pathname: '/base/api/use-switch' },
{ pathname: '/base/api/use-tab' },
{ pathname: '/base/api/use-tab-panel' },
{ pathname: '/base/api/use-tabs' },
{ pathname: '/base/api/use-tabs-list' },
];
3 changes: 1 addition & 2 deletions docs/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ function AppWrapper(props) {
pages = systemPages;
}

const { activePage, activePageParents } = findActivePage(pages, router.pathname);

const { activePage, activePageParents } = findActivePage(pages, router.pathname, router.query);
return { activePage, activePageParents, pages };
}, [product, router.pathname]);

Expand Down
23 changes: 23 additions & 0 deletions docs/pages/base/api/use-autocomplete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import HookApiPage from 'docs/src/modules/components/HookApiPage';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import jsonPageContent from './use-autocomplete.json';

export default function Page(props) {
const { descriptions, pageContent } = props;
return <HookApiPage descriptions={descriptions} pageContent={pageContent} />;
}

Page.getInitialProps = () => {
const req = require.context(
'docs/translations/api-docs/use-autocomplete',
false,
/use-autocomplete.*.json$/,
);
const descriptions = mapApiPageTranslations(req);

return {
descriptions,
pageContent: jsonPageContent,
};
};
237 changes: 237 additions & 0 deletions docs/pages/base/api/use-autocomplete.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
{
"parameters": {
"options": {
"type": { "name": "ReadonlyArray<T>", "description": "Array of options." },
"required": true
},
"autoComplete": {
"type": {
"name": "boolean",
"description": "If `true`, the portion of the selected suggestion that has not been typed by the user,\nknown as the completion string, appears inline after the input cursor in the textbox.\nThe inline completion string is visually highlighted and has a selected state."
},
"default": "false"
},
"autoHighlight": {
"type": {
"name": "boolean",
"description": "If `true`, the first option is automatically highlighted."
},
"default": "false"
},
"autoSelect": {
"type": {
"name": "boolean",
"description": "If `true`, the selected option becomes the value of the input\nwhen the Autocomplete loses focus unless the user chooses\na different option or changes the character string in the input."
},
"default": "false"
},
"blurOnSelect": {
"type": {
"name": "'touch' | 'mouse' | true | false",
"description": "Control if the input should be blurred when an option is selected:\n\n- `false` the input is not blurred.\n- `true` the input is always blurred.\n- `touch` the input is blurred after a touch event.\n- `mouse` the input is blurred after a mouse event."
},
"default": "false"
},
"clearOnBlur": {
"type": {
"name": "boolean",
"description": "If `true`, the input's text is cleared on blur if no value is selected.\n\nSet to `true` if you want to help the user enter a new value.\nSet to `false` if you want to help the user resume their search."
},
"default": "!props.freeSolo"
},
"clearOnEscape": {
"type": {
"name": "boolean",
"description": "If `true`, clear all values when the user presses escape and the popup is closed."
},
"default": "false"
},
"componentName": {
"type": {
"name": "string",
"description": "The component name that is using this hook. Used for warnings."
}
},
"defaultValue": {
"type": {
"name": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>",
"description": "The default value. Use when the component is not controlled."
},
"default": "props.multiple ? [] : null"
},
"disableClearable": {
"type": {
"name": "DisableClearable",
"description": "If `true`, the input can't be cleared."
},
"default": "false"
},
"disableCloseOnSelect": {
"type": {
"name": "boolean",
"description": "If `true`, the popup won't close when a value is selected."
},
"default": "false"
},
"disabled": {
"type": { "name": "boolean", "description": "If `true`, the component is disabled." },
"default": "false"
},
"disabledItemsFocusable": {
"type": {
"name": "boolean",
"description": "If `true`, will allow focus on disabled items."
},
"default": "false"
},
"disableListWrap": {
"type": {
"name": "boolean",
"description": "If `true`, the list box in the popup will not wrap focus."
},
"default": "false"
},
"filterOptions": {
"type": {
"name": "(options: T[], state: FilterOptionsState<T>) => T[]",
"description": "A function that determines the filtered options to be rendered on search."
}
},
"filterSelectedOptions": {
"type": {
"name": "boolean",
"description": "If `true`, hide the selected options from the list box."
},
"default": "false"
},
"freeSolo": {
"type": {
"name": "FreeSolo",
"description": "If `true`, the Autocomplete is free solo, meaning that the user input is not bound to provided options."
},
"default": "false"
},
"getOptionDisabled": {
"type": {
"name": "(option: T) => boolean",
"description": "Used to determine the disabled state for a given option."
}
},
"getOptionLabel": {
"type": {
"name": "(option: T | AutocompleteFreeSoloValueMapping<FreeSolo>) => string",
"description": "Used to determine the string value for a given option.\nIt's used to fill the input (and the list box options if `renderOption` is not provided).\n\nIf used in free solo mode, it must accept both the type of the options and a string."
},
"default": "(option) => option.label ?? option"
},
"groupBy": {
"type": {
"name": "(option: T) => string",
"description": "If provided, the options will be grouped under the returned string.\nThe groupBy value is also used as the text for group headings when `renderGroup` is not provided."
}
},
"handleHomeEndKeys": {
"type": {
"name": "boolean",
"description": "If `true`, the component handles the \"Home\" and \"End\" keys when the popup is open.\nIt should move focus to the first option and last option, respectively."
},
"default": "!props.freeSolo"
},
"id": {
"type": {
"name": "string",
"description": "This prop is used to help implement the accessibility logic.\nIf you don't provide an id it will fall back to a randomly generated one."
}
},
"includeInputInList": {
"type": {
"name": "boolean",
"description": "If `true`, the highlight can move to the input."
},
"default": "false"
},
"inputValue": { "type": { "name": "string", "description": "The input value." } },
"isOptionEqualToValue": {
"type": {
"name": "(option: T, value: T) => boolean",
"description": "Used to determine if the option represents the given value.\nUses strict equality by default.\n⚠️ Both arguments need to be handled, an option can only match with one value."
}
},
"multiple": {
"type": {
"name": "Multiple",
"description": "If `true`, `value` must be an array and the menu will support multiple selections."
},
"default": "false"
},
"onChange": {
"type": {
"name": "(event: React.SyntheticEvent, value: AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<T>) => void",
"description": "Callback fired when the value changes."
}
},
"onClose": {
"type": {
"name": "(event: React.SyntheticEvent, reason: AutocompleteCloseReason) => void",
"description": "Callback fired when the popup requests to be closed.\nUse in controlled mode (see open)."
}
},
"onHighlightChange": {
"type": {
"name": "(event: React.SyntheticEvent, option: T | null, reason: AutocompleteHighlightChangeReason) => void",
"description": "Callback fired when the highlight option changes."
}
},
"onInputChange": {
"type": {
"name": "(event: React.SyntheticEvent, value: string, reason: AutocompleteInputChangeReason) => void",
"description": "Callback fired when the input value changes."
}
},
"onOpen": {
"type": {
"name": "(event: React.SyntheticEvent) => void",
"description": "Callback fired when the popup requests to be opened.\nUse in controlled mode (see open)."
}
},
"open": { "type": { "name": "boolean", "description": "If `true`, the component is shown." } },
"openOnFocus": {
"type": {
"name": "boolean",
"description": "If `true`, the popup will open on input focus."
},
"default": "false"
},
"readOnly": {
"type": {
"name": "boolean",
"description": "If `true`, the component becomes readonly. It is also supported for multiple tags where the tag cannot be deleted."
},
"default": "false"
},
"selectOnFocus": {
"type": {
"name": "boolean",
"description": "If `true`, the input's text is selected on focus.\nIt helps the user clear the selected value."
},
"default": "!props.freeSolo"
},
"unstable_classNamePrefix": {
"type": { "name": "string", "description": "" },
"default": "'Mui'"
},
"unstable_isActiveElementInListbox": {
"type": { "name": "(listbox: React.RefObject<HTMLElement>) => boolean", "description": "" }
},
"value": {
"type": {
"name": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>",
"description": "The value of the autocomplete.\n\nThe value must have reference equality with the option in order to be selected.\nYou can customize the equality behavior with the `isOptionEqualToValue` prop."
}
}
},
"returnValue": {},
"name": "useAutocomplete",
"filename": "/packages/mui-base/src/AutocompleteUnstyled/useAutocomplete.js",
"demos": "<ul></ul>"
}