From 9555490d86aa7fc76b1205c1aade0a2daa77de31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dudak?= Date: Tue, 19 Nov 2024 13:38:10 +0100 Subject: [PATCH] [docs] Add default value annotations to JSDocs (#833) --- docs/data/api/alert-dialog-root.json | 2 +- docs/data/api/dialog-root.json | 2 +- docs/data/api/menu-checkbox-item.json | 3 +++ docs/data/api/switch-root.json | 2 +- .../menu-checkbox-item.json | 5 ++++ .../api-docs/switch-root/switch-root.json | 2 +- .../generated/alert-dialog-root.json | 1 + docs/reference/generated/dialog-root.json | 1 + .../generated/menu-checkbox-item.json | 13 +++++++++ docs/reference/generated/switch-root.json | 3 ++- .../src/AlertDialog/Root/AlertDialogRoot.tsx | 2 ++ .../mui-base/src/Dialog/Root/DialogRoot.tsx | 4 ++- .../mui-base/src/Dialog/Root/useDialogRoot.ts | 2 ++ .../Menu/CheckboxItem/MenuCheckboxItem.tsx | 27 ++++++++++++++----- .../mui-base/src/Switch/Root/SwitchRoot.tsx | 4 ++- .../mui-base/src/Switch/Root/useSwitchRoot.ts | 4 ++- 16 files changed, 63 insertions(+), 14 deletions(-) diff --git a/docs/data/api/alert-dialog-root.json b/docs/data/api/alert-dialog-root.json index 8e3b7c6638..0d12c7da09 100644 --- a/docs/data/api/alert-dialog-root.json +++ b/docs/data/api/alert-dialog-root.json @@ -1,7 +1,7 @@ { "props": { "animated": { "type": { "name": "bool" }, "default": "true" }, - "defaultOpen": { "type": { "name": "bool" } }, + "defaultOpen": { "type": { "name": "bool" }, "default": "false" }, "onOpenChange": { "type": { "name": "func" } }, "open": { "type": { "name": "bool" } } }, diff --git a/docs/data/api/dialog-root.json b/docs/data/api/dialog-root.json index 3e8b87e708..4446f4c3ae 100644 --- a/docs/data/api/dialog-root.json +++ b/docs/data/api/dialog-root.json @@ -1,7 +1,7 @@ { "props": { "animated": { "type": { "name": "bool" }, "default": "true" }, - "defaultOpen": { "type": { "name": "bool" } }, + "defaultOpen": { "type": { "name": "bool" }, "default": "false" }, "dismissible": { "type": { "name": "bool" }, "default": "true" }, "modal": { "type": { "name": "bool" }, "default": "true" }, "onOpenChange": { "type": { "name": "func" } }, diff --git a/docs/data/api/menu-checkbox-item.json b/docs/data/api/menu-checkbox-item.json index 71f0dc291c..f94e6bdb46 100644 --- a/docs/data/api/menu-checkbox-item.json +++ b/docs/data/api/menu-checkbox-item.json @@ -1,9 +1,12 @@ { "props": { + "checked": { "type": { "name": "bool" } }, "closeOnClick": { "type": { "name": "bool" }, "default": "true" }, + "defaultChecked": { "type": { "name": "bool" }, "default": "false" }, "disabled": { "type": { "name": "bool" }, "default": "false" }, "id": { "type": { "name": "string" } }, "label": { "type": { "name": "string" } }, + "onCheckedChange": { "type": { "name": "func" } }, "onClick": { "type": { "name": "func" } } }, "name": "MenuCheckboxItem", diff --git a/docs/data/api/switch-root.json b/docs/data/api/switch-root.json index 125ef04119..98feb6280a 100644 --- a/docs/data/api/switch-root.json +++ b/docs/data/api/switch-root.json @@ -2,7 +2,7 @@ "props": { "checked": { "type": { "name": "bool" } }, "className": { "type": { "name": "union", "description": "func
| string" } }, - "defaultChecked": { "type": { "name": "bool" } }, + "defaultChecked": { "type": { "name": "bool" }, "default": "false" }, "disabled": { "type": { "name": "bool" }, "default": "false" }, "inputRef": { "type": { "name": "custom", "description": "ref" } }, "name": { "type": { "name": "string" } }, diff --git a/docs/data/translations/api-docs/menu-checkbox-item/menu-checkbox-item.json b/docs/data/translations/api-docs/menu-checkbox-item/menu-checkbox-item.json index 7c401d2eae..3fad08e5cd 100644 --- a/docs/data/translations/api-docs/menu-checkbox-item/menu-checkbox-item.json +++ b/docs/data/translations/api-docs/menu-checkbox-item/menu-checkbox-item.json @@ -1,14 +1,19 @@ { "componentDescription": "An unstyled checkbox menu item to be used within a Menu.", "propDescriptions": { + "checked": { "description": "If true, the checkbox is checked." }, "closeOnClick": { "description": "If true, the menu will close when the menu item is clicked." }, + "defaultChecked": { + "description": "The default checked state. Use when the component is uncontrolled." + }, "disabled": { "description": "If true, the menu item will be disabled." }, "id": { "description": "The id of the menu item." }, "label": { "description": "A text representation of the menu item's content. Used for keyboard text navigation matching." }, + "onCheckedChange": { "description": "Callback fired when the checked state is changed." }, "onClick": { "description": "The click handler for the menu item." } }, "classDescriptions": {} diff --git a/docs/data/translations/api-docs/switch-root/switch-root.json b/docs/data/translations/api-docs/switch-root/switch-root.json index 401676fbbc..8dc03b5a3b 100644 --- a/docs/data/translations/api-docs/switch-root/switch-root.json +++ b/docs/data/translations/api-docs/switch-root/switch-root.json @@ -6,7 +6,7 @@ "description": "Class names applied to the element or a function that returns them based on the component's state." }, "defaultChecked": { - "description": "The default checked state. Use when the component is not controlled." + "description": "The default checked state. Use when the component is uncontrolled." }, "disabled": { "description": "If true, the component is disabled and can't be interacted with." diff --git a/docs/reference/generated/alert-dialog-root.json b/docs/reference/generated/alert-dialog-root.json index 7e6420324b..1e06823d8b 100644 --- a/docs/reference/generated/alert-dialog-root.json +++ b/docs/reference/generated/alert-dialog-root.json @@ -9,6 +9,7 @@ }, "defaultOpen": { "type": "boolean", + "default": "false", "description": "Determines whether the dialog is initally open.\nThis is an uncontrolled equivalent of the `open` prop." }, "onOpenChange": { diff --git a/docs/reference/generated/dialog-root.json b/docs/reference/generated/dialog-root.json index af19098732..8ad82fc4d8 100644 --- a/docs/reference/generated/dialog-root.json +++ b/docs/reference/generated/dialog-root.json @@ -9,6 +9,7 @@ }, "defaultOpen": { "type": "boolean", + "default": "false", "description": "Determines whether the dialog is initally open.\nThis is an uncontrolled equivalent of the `open` prop." }, "dismissible": { diff --git a/docs/reference/generated/menu-checkbox-item.json b/docs/reference/generated/menu-checkbox-item.json index 8c0cde01b1..b16861866f 100644 --- a/docs/reference/generated/menu-checkbox-item.json +++ b/docs/reference/generated/menu-checkbox-item.json @@ -2,11 +2,20 @@ "name": "MenuCheckboxItem", "description": "An unstyled checkbox menu item to be used within a Menu.", "props": { + "checked": { + "type": "boolean", + "description": "If `true`, the checkbox is checked." + }, "closeOnClick": { "type": "boolean", "default": "true", "description": "If `true`, the menu will close when the menu item is clicked." }, + "defaultChecked": { + "type": "boolean", + "default": "false", + "description": "The default checked state. Use when the component is uncontrolled." + }, "disabled": { "type": "boolean", "default": "false", @@ -20,6 +29,10 @@ "type": "string", "description": "A text representation of the menu item's content.\nUsed for keyboard text navigation matching." }, + "onCheckedChange": { + "type": "function", + "description": "Callback fired when the checked state is changed." + }, "onClick": { "type": "(event) => void", "description": "The click handler for the menu item." diff --git a/docs/reference/generated/switch-root.json b/docs/reference/generated/switch-root.json index dc989c38c3..34408beef7 100644 --- a/docs/reference/generated/switch-root.json +++ b/docs/reference/generated/switch-root.json @@ -12,7 +12,8 @@ }, "defaultChecked": { "type": "boolean", - "description": "The default checked state. Use when the component is not controlled." + "default": "false", + "description": "The default checked state. Use when the component is uncontrolled." }, "disabled": { "type": "boolean", diff --git a/packages/mui-base/src/AlertDialog/Root/AlertDialogRoot.tsx b/packages/mui-base/src/AlertDialog/Root/AlertDialogRoot.tsx index 25477b7890..5601986dcd 100644 --- a/packages/mui-base/src/AlertDialog/Root/AlertDialogRoot.tsx +++ b/packages/mui-base/src/AlertDialog/Root/AlertDialogRoot.tsx @@ -67,6 +67,8 @@ AlertDialogRoot.propTypes /* remove-proptypes */ = { /** * Determines whether the dialog is initally open. * This is an uncontrolled equivalent of the `open` prop. + * + * @default false */ defaultOpen: PropTypes.bool, /** diff --git a/packages/mui-base/src/Dialog/Root/DialogRoot.tsx b/packages/mui-base/src/Dialog/Root/DialogRoot.tsx index 67106880be..f700e6f1c9 100644 --- a/packages/mui-base/src/Dialog/Root/DialogRoot.tsx +++ b/packages/mui-base/src/Dialog/Root/DialogRoot.tsx @@ -19,7 +19,7 @@ const DialogRoot = function DialogRoot(props: DialogRoot.Props) { const { animated = true, children, - defaultOpen, + defaultOpen = false, dismissible = true, modal = true, onOpenChange, @@ -73,6 +73,8 @@ DialogRoot.propTypes /* remove-proptypes */ = { /** * Determines whether the dialog is initally open. * This is an uncontrolled equivalent of the `open` prop. + * + * @default false */ defaultOpen: PropTypes.bool, /** diff --git a/packages/mui-base/src/Dialog/Root/useDialogRoot.ts b/packages/mui-base/src/Dialog/Root/useDialogRoot.ts index b23d2c2d8e..5605ca355d 100644 --- a/packages/mui-base/src/Dialog/Root/useDialogRoot.ts +++ b/packages/mui-base/src/Dialog/Root/useDialogRoot.ts @@ -170,6 +170,8 @@ export interface CommonParameters { /** * Determines whether the dialog is initally open. * This is an uncontrolled equivalent of the `open` prop. + * + * @default false */ defaultOpen?: boolean; /** diff --git a/packages/mui-base/src/Menu/CheckboxItem/MenuCheckboxItem.tsx b/packages/mui-base/src/Menu/CheckboxItem/MenuCheckboxItem.tsx index 7305bea6da..830487d5c9 100644 --- a/packages/mui-base/src/Menu/CheckboxItem/MenuCheckboxItem.tsx +++ b/packages/mui-base/src/Menu/CheckboxItem/MenuCheckboxItem.tsx @@ -73,7 +73,7 @@ InnerMenuCheckboxItem.propTypes /* remove-proptypes */ = { // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** - * @ignore + * If `true`, the checkbox is checked. */ checked: PropTypes.bool, /** @@ -91,7 +91,9 @@ InnerMenuCheckboxItem.propTypes /* remove-proptypes */ = { */ closeOnClick: PropTypes.bool, /** - * @ignore + * The default checked state. Use when the component is uncontrolled. + * + * @default false */ defaultChecked: PropTypes.bool, /** @@ -121,7 +123,7 @@ InnerMenuCheckboxItem.propTypes /* remove-proptypes */ = { on: PropTypes.func.isRequired, }).isRequired, /** - * @ignore + * Callback fired when the checked state is changed. */ onCheckedChange: PropTypes.func, /** @@ -211,8 +213,19 @@ namespace MenuCheckboxItem { }; export interface Props extends BaseUIComponentProps<'div', OwnerState> { + /** + * If `true`, the checkbox is checked. + */ checked?: boolean; + /** + * The default checked state. Use when the component is uncontrolled. + * + * @default false + */ defaultChecked?: boolean; + /** + * Callback fired when the checked state is changed. + */ onCheckedChange?: (checked: boolean, event: Event) => void; children?: React.ReactNode; /** @@ -248,7 +261,7 @@ MenuCheckboxItem.propTypes /* remove-proptypes */ = { // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** - * @ignore + * If `true`, the checkbox is checked. */ checked: PropTypes.bool, /** @@ -262,7 +275,9 @@ MenuCheckboxItem.propTypes /* remove-proptypes */ = { */ closeOnClick: PropTypes.bool, /** - * @ignore + * The default checked state. Use when the component is uncontrolled. + * + * @default false */ defaultChecked: PropTypes.bool, /** @@ -280,7 +295,7 @@ MenuCheckboxItem.propTypes /* remove-proptypes */ = { */ label: PropTypes.string, /** - * @ignore + * Callback fired when the checked state is changed. */ onCheckedChange: PropTypes.func, /** diff --git a/packages/mui-base/src/Switch/Root/SwitchRoot.tsx b/packages/mui-base/src/Switch/Root/SwitchRoot.tsx index 40831d0b5d..6966b26833 100644 --- a/packages/mui-base/src/Switch/Root/SwitchRoot.tsx +++ b/packages/mui-base/src/Switch/Root/SwitchRoot.tsx @@ -104,7 +104,9 @@ SwitchRoot.propTypes /* remove-proptypes */ = { */ className: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), /** - * The default checked state. Use when the component is not controlled. + * The default checked state. Use when the component is uncontrolled. + * + * @default false */ defaultChecked: PropTypes.bool, /** diff --git a/packages/mui-base/src/Switch/Root/useSwitchRoot.ts b/packages/mui-base/src/Switch/Root/useSwitchRoot.ts index 3dd896d081..8fbdf94fd4 100644 --- a/packages/mui-base/src/Switch/Root/useSwitchRoot.ts +++ b/packages/mui-base/src/Switch/Root/useSwitchRoot.ts @@ -154,7 +154,9 @@ export namespace useSwitchRoot { */ checked?: boolean; /** - * The default checked state. Use when the component is not controlled. + * The default checked state. Use when the component is uncontrolled. + * + * @default false */ defaultChecked?: boolean; /**