-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
react-positioning and popup menus (#17339)
* Port usePopper * remove unnecessary dep * export types * cleanup types * cleaning * Add tests * removed enum * fix lint * Change files * remove rtl option * fix syncpack * update API * update ADPI * Update packages/react-positioning/package.json Co-authored-by: Oleksandr Fediashov <alexander.mcgarret@gmail.com> * rename popperRef to containerRef * move usecallbackref * update API * removed escaped * remove see tag * Add comment about potential bug in concurrent * fix syncpack * Update packages/react-positioning/package.json Co-authored-by: Elizabeth Craig <ecraig12345@gmail.com> * Update packages/react-positioning/package.json Co-authored-by: Elizabeth Craig <ecraig12345@gmail.com> * Fix export * fix mouseleave trigger Co-authored-by: Oleksandr Fediashov <alexander.mcgarret@gmail.com> Co-authored-by: Elizabeth Craig <ecraig12345@gmail.com>
- Loading branch information
1 parent
869c2e5
commit fc0d872
Showing
37 changed files
with
1,462 additions
and
39 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-examples-b68c6466-b9fc-4fa9-9b15-19f61cc6ba66.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Improve popup menu examples", | ||
"packageName": "@fluentui/react-examples", | ||
"email": "lingfan.gao@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-menu-3d70c266-b666-449b-b40b-2a74d478cd96.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Use positioning for Menu", | ||
"packageName": "@fluentui/react-menu", | ||
"email": "lingfan.gao@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-positioning-b7985d83-f47a-4184-bbf4-f026a03194e8.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Initial package", | ||
"packageName": "@fluentui/react-positioning", | ||
"email": "lingfan.gao@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-utilities-a12f1320-0ab9-43bd-99a3-e001f5fcc581.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Add useCallbackRef and useFirstMount hooks", | ||
"packageName": "@fluentui/react-utilities", | ||
"email": "lingfan.gao@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": ["plugin:@fluentui/eslint-plugin/react"], | ||
"root": true | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
*.api.json | ||
*.config.js | ||
*.log | ||
*.nuspec | ||
*.test.* | ||
*.yml | ||
.editorconfig | ||
.eslintrc* | ||
.eslintcache | ||
.gitattributes | ||
.gitignore | ||
.vscode | ||
coverage | ||
dist/storybook | ||
dist/*.stats.html | ||
dist/*.stats.json | ||
dist/demo | ||
fabric-test* | ||
gulpfile.js | ||
images | ||
index.html | ||
jsconfig.json | ||
node_modules | ||
results | ||
src/**/* | ||
!src/**/examples/*.tsx | ||
!src/**/docs/**/*.md | ||
!src/**/*.types.ts | ||
temp | ||
tsconfig.json | ||
tsd.json | ||
tslint.json | ||
typings | ||
visualtests |
This file contains 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@fluentui/react-positioning | ||
|
||
Copyright (c) Microsoft Corporation | ||
|
||
All rights reserved. | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
Note: Usage of the fonts and icons referenced in Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license |
This file contains 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# @fluentui/react-positioning | ||
|
||
A react hook wrapper around [Popper.js](https://popper.js.org/) for Fluent UI. | ||
|
||
These are not production-ready utilities and **should never be used in product**. This space is useful for testing new utilities whose APIs might change before final release. | ||
|
||
## Usage | ||
|
||
```tsx | ||
import React from 'react'; | ||
import { usePopper } from '@fluentui/react-positioning'; | ||
|
||
function PopupExample: React.FC = ({ children }) => { | ||
const {targetRef, containerRef} = usePopper(); | ||
const [open, setOpen] = React.useState(false); | ||
|
||
const onClick = () => setOpen(s => !s); | ||
return ( | ||
<> | ||
<button ref={targetRef} onClick={onClick}> Toggle popup </button> | ||
{ open && <div ref={containerRef}>{children}</div> } | ||
</> | ||
) | ||
} | ||
``` |
This file contains 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@fluentui/scripts/api-extractor/api-extractor.common.json" | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
## API Report File for "@fluentui/react-positioning" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
```ts | ||
|
||
import * as PopperJs from '@popperjs/core'; | ||
import * as React from 'react'; | ||
|
||
// @public (undocumented) | ||
export type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center'; | ||
|
||
// @public (undocumented) | ||
export type Boundary = PopperJs.Boundary | 'scrollParent' | 'window'; | ||
|
||
// @public (undocumented) | ||
export type Offset = OffsetFunction | [number | null | undefined, number | null | undefined]; | ||
|
||
// @public (undocumented) | ||
export type OffsetFunction = (param: OffsetFunctionParam) => [number | null | undefined, number | null | undefined]; | ||
|
||
// @public (undocumented) | ||
export type OffsetFunctionParam = { | ||
popper: PopperJs.Rect; | ||
reference: PopperJs.Rect; | ||
placement: PopperJs.Placement; | ||
}; | ||
|
||
// @public (undocumented) | ||
export interface PopperOptions extends PositioningProps { | ||
enabled?: boolean; | ||
// (undocumented) | ||
onStateUpdate?: (state: Partial<PopperJs.State>) => void; | ||
positioningDependencies?: React.DependencyList; | ||
} | ||
|
||
// @public (undocumented) | ||
export type PopperRefHandle = { | ||
updatePosition: () => void; | ||
}; | ||
|
||
// @public (undocumented) | ||
export type Position = 'above' | 'below' | 'before' | 'after'; | ||
|
||
// @public (undocumented) | ||
export interface PositioningProps { | ||
align?: Alignment; | ||
autoSize?: 'height' | 'width' | boolean; | ||
containerRef?: React.Ref<PopperRefHandle>; | ||
flipBoundary?: Boundary; | ||
offset?: Offset; | ||
overflowBoundary?: Boundary; | ||
position?: Position; | ||
positionFixed?: boolean; | ||
unstable_disableTether?: boolean | 'all'; | ||
unstable_pinned?: boolean; | ||
} | ||
|
||
// @public | ||
export function usePopper(options?: PopperOptions): { | ||
targetRef: React.MutableRefObject<any>; | ||
containerRef: React.MutableRefObject<any>; | ||
arrowRef: React.MutableRefObject<any>; | ||
}; | ||
|
||
|
||
// (No @packageDocumentation comment for this package) | ||
|
||
``` |
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { createConfig } = require('@fluentui/scripts/jest/jest-resources'); | ||
|
||
const config = createConfig({}); | ||
|
||
module.exports = config; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { preset } from '@fluentui/scripts'; | ||
|
||
preset(); |
Oops, something went wrong.