Skip to content

Commit

Permalink
[docs] Add hooks API pages for MUI Base (#35828)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnajdova authored Feb 2, 2023
1 parent 2694045 commit 807f635
Show file tree
Hide file tree
Showing 89 changed files with 2,407 additions and 142 deletions.
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/select/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
product: base
title: Unstyled React Select components and hook
components: SelectUnstyled, MultiSelectUnstyled, OptionUnstyled, OptionGroupUnstyled
hooks: useSelect
githubLabel: 'component: select'
waiAria: https://www.w3.org/WAI/ARIA/apg/example-index/combobox/combobox-select-only.html
---
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,
};
};
Loading

0 comments on commit 807f635

Please sign in to comment.