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] Add hooks API pages for MUI Base #35828

Merged
merged 30 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
30 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
085021e
Fix name typo in component
mnajdova Jan 30, 2023
be586f5
Fix the backtikcs on the descriptions
mnajdova Jan 31, 2023
09f5bba
Zeeshan's review
mnajdova Feb 1, 2023
031c354
Merge branch 'master' into docs/build-hooks-interfaces
mnajdova Feb 1, 2023
762d488
apply fix for default values
mnajdova Feb 1, 2023
d1ba785
Update docs/src/modules/components/PropertiesTable.js
mnajdova Feb 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
1 change: 1 addition & 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 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: 'API',
pathname: '/base/api',
icon: 'CodeIcon',
children: pagesApi,
Expand Down
15 changes: 15 additions & 0 deletions docs/data/base/pagesApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,19 @@ 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/api/use-button' },
{ 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' },
];
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>"
}
19 changes: 19 additions & 0 deletions docs/pages/base/api/use-badge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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-badge.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-badge', false, /use-badge.*.json$/);
const descriptions = mapApiPageTranslations(req);

return {
descriptions,
pageContent: jsonPageContent,
};
};
12 changes: 12 additions & 0 deletions docs/pages/base/api/use-badge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parameters": {
"badgeContent": { "type": { "name": "React.ReactNode", "description": "" } },
"invisible": { "type": { "name": "boolean", "description": "" } },
"max": { "type": { "name": "number", "description": "" } },
"showZero": { "type": { "name": "boolean", "description": "" } }
},
"returnValue": {},
"name": "useBadge",
"filename": "/packages/mui-base/src/BadgeUnstyled/useBadge.ts",
"demos": "<ul><li><a href=\"/base/react-badge/#hook\">Unstyled badge</a></li></ul>"
}
Loading