Skip to content

Commit

Permalink
Updated apidoc for headless development
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrogenous committed Jan 5, 2024
1 parent cd158f0 commit 78d2c79
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 61 deletions.
132 changes: 76 additions & 56 deletions components/doc/common/apidoc/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -13680,6 +13680,14 @@
"default": "true",
"description": "Specifies if pressing escape key should hide the dialog."
},
{
"name": "content",
"optional": false,
"readonly": false,
"type": "ReactNode | Function",
"default": "",
"description": "Specifies a custom content for the dialog. For more complex markup, use the \"content\" slot instead."
},
{
"name": "contentClassName",
"optional": true,
Expand Down Expand Up @@ -13987,19 +13995,6 @@
"returnType": "void",
"description": "Callback to execute when action is confirmed."
},
{
"name": "content",
"parameters": [
{
"name": "props",
"optional": false,
"type": "ContentProps",
"description": "The values of dialog."
}
],
"returnType": "ReactNode",
"description": "Specifies a custom content for the dialog. For more complex markup, use the \"content\" slot instead."
},
{
"name": "onClick",
"parameters": [
Expand Down Expand Up @@ -14480,6 +14475,14 @@
"default": "true",
"description": "Specifies if pressing escape key should hide the popup."
},
{
"name": "content",
"optional": false,
"readonly": false,
"type": "ReactNode | Function",
"default": "",
"description": "Specifies a custom content for the dialog. For more complex markup, use the \"content\" slot instead."
},
{
"name": "dismissable",
"optional": true,
Expand Down Expand Up @@ -14611,19 +14614,6 @@
"returnType": "void",
"description": "Callback to execute when action is confirmed."
},
{
"name": "content",
"parameters": [
{
"name": "props",
"optional": false,
"type": "ContentProps",
"description": "The values of dialog."
}
],
"returnType": "ReactNode",
"description": "Specifies a custom content for the dialog. For more complex markup, use the \"content\" slot instead."
},
{
"name": "onHide",
"parameters": [
Expand Down Expand Up @@ -14863,26 +14853,30 @@
"name": "acceptBtnRef",
"optional": false,
"readonly": false,
"type": "RefObject<HTMLButtonElement>"
"type": "RefObject<HTMLButtonElement>",
"description": "Reference for the accept button. Used to focus the element and execute the action."
},
{
"name": "rejectBtnRef",
"optional": false,
"readonly": false,
"type": "RefObject<HTMLButtonElement>"
"type": "RefObject<HTMLButtonElement>",
"description": "Reference for the reject button. Used to focus the element and execute the action."
},
{
"name": "message",
"optional": false,
"readonly": false,
"type": "ReactNode"
"type": "ReactNode",
"description": "Message value of confirm popup."
}
],
"callbacks": [
{
"name": "hide",
"parameters": [],
"returnType": "void"
"returnType": "void",
"description": "Hide action of confirm popup."
}
]
},
Expand Down Expand Up @@ -21021,6 +21015,14 @@
"default": "true",
"description": "Specifies if pressing escape key should hide the dialog."
},
{
"name": "content",
"optional": false,
"readonly": false,
"type": "ReactNode | Function",
"default": "",
"description": "Specifies a custom content for the dialog. For more complex markup, use the \"content\" slot instead."
},
{
"name": "contentClassName",
"optional": true,
Expand Down Expand Up @@ -21274,19 +21276,6 @@
"callbacks": {
"description": "Defines callbacks that determine the behavior of the component based on a given condition or report the actions that the component takes.",
"values": [
{
"name": "content",
"parameters": [
{
"name": "props",
"optional": false,
"type": "ContentProps",
"description": "The values of dialog."
}
],
"returnType": "ReactNode",
"description": "Specifies a custom content for the dialog. For more complex markup, use the \"content\" slot instead."
},
{
"name": "onClick",
"parameters": [
Expand Down Expand Up @@ -42404,6 +42393,14 @@
"default": "true",
"description": "Specifies if pressing escape key should hide the sidebar."
},
{
"name": "content",
"optional": false,
"readonly": false,
"type": "ReactNode | Function",
"default": "",
"description": "Specifies a custom content for the sidebar. For more complex markup, use the \"content\" slot instead."
},
{
"name": "dismissable",
"optional": true,
Expand Down Expand Up @@ -42642,6 +42639,34 @@
}
],
"callbacks": []
},
"ContentProps": {
"description": "Defines current content values and refs for headless development.",
"relatedProp": "content",
"props": [
{
"name": "closeIconRef",
"optional": false,
"readonly": false,
"type": "RefObject<HTMLElement | HTMLButtonElement>",
"description": "Allows you to specify the close button of the sidebar."
}
],
"callbacks": [
{
"name": "hide",
"parameters": [
{
"name": "event",
"optional": false,
"type": "SyntheticEvent<Element, Event>",
"description": "Used to get the event of the element."
}
],
"returnType": "void",
"description": "Callback for hiding the sidebar."
}
]
}
}
},
Expand Down Expand Up @@ -47146,6 +47171,14 @@
"default": "",
"description": "Used to get the child elements of the component."
},
{
"name": "content",
"optional": false,
"readonly": false,
"type": "ReactNode | Function",
"default": "",
"description": "Specifies a custom content for the toast. For more complex markup, use the \"content\" slot instead."
},
{
"name": "position",
"optional": true,
Expand Down Expand Up @@ -47183,19 +47216,6 @@
"callbacks": {
"description": "Defines callbacks that determine the behavior of the component based on a given condition or report the actions that the component takes.",
"values": [
{
"name": "content",
"parameters": [
{
"name": "props",
"optional": false,
"type": "ContentProps",
"description": "The values of toast."
}
],
"returnType": "ReactNode",
"description": "Specifies a custom content for the toast. For more complex markup, use the \"content\" slot instead."
},
{
"name": "onClick",
"parameters": [
Expand Down
14 changes: 13 additions & 1 deletion components/lib/confirmpopup/confirmpopup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,21 @@ interface ConfirmPopupOptions {
* @see {@link ConfirmPopupProps.content}
*/
interface ContentProps {
/**
* Reference for the accept button. Used to focus the element and execute the action.
*/
acceptBtnRef: React.RefObject<HTMLButtonElement>;
/**
* Reference for the reject button. Used to focus the element and execute the action.
*/
rejectBtnRef: React.RefObject<HTMLButtonElement>;
/**
* Message value of confirm popup.
*/
message: React.ReactNode | string;
/**
* Hide action of confirm popup.
*/
hide(): void;
}

Expand Down Expand Up @@ -272,7 +284,7 @@ export interface ConfirmPopupProps {
* @param {ContentProps} props - The values of dialog.
* @return {React.ReactNode}
*/
content?(props: ContentProps): React.ReactNode;
content: React.ReactNode | ((props: ContentProps) => React.ReactNode);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion components/lib/dialog/dialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ export interface DialogProps {
* @param {ContentProps} props - The values of dialog.
* @return {React.ReactNode}
*/
content?(props: ContentProps): React.ReactNode;
content: React.ReactNode | ((props: ContentProps) => React.ReactNode);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion components/lib/sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const Sidebar = React.forwardRef((inProps, ref) => {
);

const createTemplateElement = () => {
const templateElementProps = { sidebarRef, closeIconRef, hide: onClose };
const templateElementProps = { closeIconRef, hide: onClose };

return (
<div {...maskProps}>
Expand Down
24 changes: 23 additions & 1 deletion components/lib/sidebar/sidebar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,27 @@ export interface SidebarState {
containerVisible: boolean;
}

/**
* Defines current content values and refs for headless development.
* @see {@link SidebarProps.content}
*/
interface ContentProps {
/**
* Allows you to specify the close button of the sidebar.
*/
closeIconRef: React.RefObject<HTMLButtonElement | HTMLElement>;
/**
* Callback for hiding the sidebar.
* @param {React.SyntheticEvent} event - Used to get the event of the element.
*/
hide(event: React.SyntheticEvent): void;
}

/**
* Defines valid properties in Sidebar component. In addition to these, all properties of HTMLDivElement can be used in this component.
* @group Properties
*/
export interface SidebarProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'ref'> {
export interface SidebarProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'ref' | 'content'> {
/**
* Inline style of the mask.
*/
Expand Down Expand Up @@ -195,6 +211,12 @@ export interface SidebarProps extends Omit<React.DetailedHTMLProps<React.HTMLAtt
* @defaultValue false
*/
unstyled?: boolean;
/**
* Specifies a custom content for the sidebar. For more complex markup, use the "content" slot instead.
* @param {ContentProps} props - The values of sidebar.
* @return {React.ReactNode}
*/
content: React.ReactNode | ((props: ContentProps) => React.ReactNode);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion components/lib/toast/toast.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export interface ToastProps extends Omit<React.DetailedHTMLProps<React.HTMLAttri
* @param {ContentProps} props - The values of toast.
* @return {React.ReactNode}
*/
content?(props: ContentProps): React.ReactNode;
content: React.ReactNode | ((props: ContentProps) => React.ReactNode);
}

/**
Expand Down

0 comments on commit 78d2c79

Please sign in to comment.