-
Notifications
You must be signed in to change notification settings - Fork 359
feat(popup): add multiple instance methods to popup component #3925
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
Open
RSS1102
wants to merge
2
commits into
develop
Choose a base branch
from
rss1102/feat/popup/get-popper
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+93
−2
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSS1102 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,66 +1,76 @@ | ||
| :: BASE_DOC :: | ||
|
|
||
| ### Called Popup via plugin | ||
|
|
||
| Calling Popup through the plug-in method is used to render Popup in a scene with existing nodes. At the same time, no matter how it is called, it will only be mounted on one node, which is used to reduce the number of Popup rendering nodes on the page. | ||
|
|
||
| Support functional calls `PopupPlugin` 。 | ||
| - `PopupPlugin(triggerElement, content, popupProps)` | ||
|
|
||
| {{ plugin }} | ||
|
|
||
| ### Dynamic Adaptation | ||
|
|
||
| When the trigger or popup display content changes dynamically, the position is adjusted adaptively | ||
|
|
||
| {{ dynamic }} | ||
|
|
||
| ### popperOptions usage | ||
|
|
||
| https://popper.js.org/docs/v2/constructors/#types | ||
|
|
||
| - `popperOptions` = `Options` | ||
|
|
||
| {{ popper-options }} | ||
|
|
||
| ## FAQ | ||
|
|
||
| ### How to solve the problem of position offset when nesting `Popup` components? | ||
|
|
||
| Currently, this can be solved by `Fragment` or other `HTML` elements | ||
|
|
||
| ```js | ||
| <Popup content="Popup Content"> | ||
| <> | ||
| {children} | ||
| </> | ||
| </Popup> | ||
| ``` | ||
|
|
||
| ## API | ||
| ### Popup Props | ||
|
|
||
| name | type | default | description | required | ||
| -- | -- | -- | -- | -- | ||
| attach | String / Function | 'body' | Typescript:`AttachNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| children | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| content | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| delay | Number / Array | - | delay to show or hide popover。Typescript:`number \| Array<number>` | N | ||
| destroyOnClose | Boolean | false | \- | N | ||
| disabled | Boolean | - | \- | N | ||
| hideEmptyPopup | Boolean | false | \- | N | ||
| overlayClassName | String / Object / Array | - | Typescript:`ClassName`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| overlayInnerClassName | String / Object / Array | - | Typescript:`ClassName`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| overlayInnerStyle | Boolean / Object / Function | - | Typescript:`Styles \| ((triggerElement: HTMLElement, popupElement: HTMLElement) => Styles)`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| overlayStyle | Boolean / Object / Function | - | Typescript:`Styles \| ((triggerElement: HTMLElement, popupElement: HTMLElement) => Styles)`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| placement | String | top | Typescript:`PopupPlacement` `type PopupPlacement = 'top'\|'left'\|'right'\|'bottom'\|'top-left'\|'top-right'\|'bottom-left'\|'bottom-right'\|'left-top'\|'left-bottom'\|'right-top'\|'right-bottom'`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/popup/type.ts) | N | ||
| popperOptions | Object | - | popper initial options,details refer to https://popper.js.org/docs | N | ||
| showArrow | Boolean | false | \- | N | ||
| trigger | String | hover | options:hover/click/focus/mousedown/context-menu | N | ||
| triggerElement | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| visible | Boolean | - | Typescript:`boolean` | N | ||
| defaultVisible | Boolean | - | uncontrolled property。Typescript:`boolean` | N | ||
| zIndex | Number | - | \- | N | ||
| onScroll | Function | | Typescript:`(context: { e: WheelEvent }) => void`<br/> | N | ||
| onScrollToBottom | Function | | Typescript:`(context: { e: WheelEvent }) => void`<br/> | N | ||
| onVisibleChange | Function | | Typescript:`(visible: boolean, context: PopupVisibleChangeContext) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/popup/type.ts)。<br/>`interface PopupVisibleChangeContext { e?: PopupTriggerEvent; trigger?: PopupTriggerSource }`<br/><br/>`type PopupTriggerEvent = MouseEvent \| FocusEvent \| KeyboardEvent`<br/><br/>`type PopupTriggerSource = 'document' \| 'trigger-element-click' \| 'trigger-element-hover' \| 'trigger-element-blur' \| 'trigger-element-focus' \| 'trigger-element-mousedown' \| 'context-menu' \| 'keydown-esc'`<br/> | N | ||
| :: BASE_DOC :: | ||
|
|
||
| ### Called Popup via plugin | ||
|
|
||
| Calling Popup through the plug-in method is used to render Popup in a scene with existing nodes. At the same time, no matter how it is called, it will only be mounted on one node, which is used to reduce the number of Popup rendering nodes on the page. | ||
|
|
||
| Support functional calls `PopupPlugin` 。 | ||
| - `PopupPlugin(triggerElement, content, popupProps)` | ||
|
|
||
| {{ plugin }} | ||
|
|
||
| ### Dynamic Adaptation | ||
|
|
||
| When the trigger or popup display content changes dynamically, the position is adjusted adaptively | ||
|
|
||
| {{ dynamic }} | ||
|
|
||
| ### popperOptions usage | ||
|
|
||
| https://popper.js.org/docs/v2/constructors/#types | ||
|
|
||
| - `popperOptions` = `Options` | ||
|
|
||
| {{ popper-options }} | ||
|
|
||
| ## FAQ | ||
|
|
||
| ### How to solve the problem of position offset when nesting `Popup` components? | ||
|
|
||
| Currently, this can be solved by `Fragment` or other `HTML` elements | ||
|
|
||
| ```js | ||
| <Popup content="Popup Content"> | ||
| <> | ||
| {children} | ||
| </> | ||
| </Popup> | ||
| ``` | ||
|
|
||
| ## API | ||
|
|
||
| ### Popup Props | ||
|
|
||
| name | type | default | description | required | ||
| -- | -- | -- | -- | -- | ||
| attach | String / Function | 'body' | Typescript:`AttachNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| children | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| content | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| delay | Number / Array | - | delay to show or hide popover。Typescript:`number \| Array<number>` | N | ||
| destroyOnClose | Boolean | false | \- | N | ||
| disabled | Boolean | - | \- | N | ||
| hideEmptyPopup | Boolean | false | \- | N | ||
| overlayClassName | String / Object / Array | - | Typescript:`ClassName`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| overlayInnerClassName | String / Object / Array | - | Typescript:`ClassName`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| overlayInnerStyle | Boolean / Object / Function | - | Typescript:`Styles \| ((triggerElement: HTMLElement, popupElement: HTMLElement) => Styles)`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| overlayStyle | Boolean / Object / Function | - | Typescript:`Styles \| ((triggerElement: HTMLElement, popupElement: HTMLElement) => Styles)`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| placement | String | top | Typescript:`PopupPlacement` `type PopupPlacement = 'top'\|'left'\|'right'\|'bottom'\|'top-left'\|'top-right'\|'bottom-left'\|'bottom-right'\|'left-top'\|'left-bottom'\|'right-top'\|'right-bottom'`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/popup/type.ts) | N | ||
| popperOptions | Object | - | popper initial options,details refer to https://popper.js.org/docs | N | ||
| showArrow | Boolean | false | \- | N | ||
| trigger | String | hover | options:hover/click/focus/mousedown/context-menu | N | ||
| triggerElement | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N | ||
| visible | Boolean | - | Typescript:`boolean` | N | ||
| defaultVisible | Boolean | - | uncontrolled property。Typescript:`boolean` | N | ||
| zIndex | Number | - | \- | N | ||
| onScroll | Function | | Typescript:`(context: { e: WheelEvent }) => void`<br/> | N | ||
| onScrollToBottom | Function | | Typescript:`(context: { e: WheelEvent }) => void`<br/> | N | ||
| onVisibleChange | Function | | Typescript:`(visible: boolean, context: PopupVisibleChangeContext) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/popup/type.ts)。<br/>`interface PopupVisibleChangeContext { e?: PopupTriggerEvent; trigger?: PopupTriggerSource }`<br/><br/>`type PopupTriggerEvent = MouseEvent \| FocusEvent \| KeyboardEvent`<br/><br/>`type PopupTriggerSource = 'document' \| 'trigger-element-click' \| 'trigger-element-hover' \| 'trigger-element-blur' \| 'trigger-element-focus' \| 'trigger-element-mousedown' \| 'context-menu' \| 'keydown-esc'`<br/> | N | ||
|
|
||
| ### PopupInstanceFunctions 组件实例方法 | ||
|
|
||
| name | params | return | description | ||
| -- | -- | -- | -- | ||
| getOverlay | \- | `HTMLElement \| null` | used to get overly html element | ||
| getOverlayState | \- | `{ hover: boolean }` | get mouseover state of overlay | ||
| getPopper | \- | `Instance \| null` | get the popup component popper instance。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/popup/type.ts)。<br/>`import { Instance } from '@popperjs/core'`<br/> | ||
| update | \- | \- | used to update overlay content |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.