Skip to content
Closed
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
0b3d545
init
ling1726 Feb 17, 2022
707a4a1
final touches
ling1726 Feb 22, 2022
36904c7
Change files
ling1726 Feb 22, 2022
4bd223f
Merge branch 'master' into chore/floating-ui
ling1726 Feb 22, 2022
9738d0c
support imperative handle
ling1726 Feb 22, 2022
ccfbfd5
Merge branch 'master' into chore/floating-ui
ling1726 Feb 23, 2022
8ca61b2
debounce
ling1726 Feb 24, 2022
005166f
changes
ling1726 Feb 25, 2022
fb1c088
finally understood scroll jumping fix
ling1726 Feb 25, 2022
cfe0909
disableTether and positionFixed
ling1726 Feb 26, 2022
5196d59
gpu accel
ling1726 Feb 26, 2022
02b0f8c
remove firstUpdate concept
ling1726 Feb 26, 2022
1eec43e
change doc
ling1726 Feb 26, 2022
7e89d6f
merge master
ling1726 Feb 26, 2022
f5cb3c1
merge master
ling1726 Mar 1, 2022
9775df4
hide middleware and intersection observer
ling1726 Mar 1, 2022
7bb4808
remove old middleware
ling1726 Mar 1, 2022
4b34449
remove popper from deps
ling1726 Mar 1, 2022
636b23c
cleanup event listeners
ling1726 Mar 1, 2022
add88c4
update md
ling1726 Mar 1, 2022
d793aab
cleanup
ling1726 Mar 1, 2022
212326f
cleanup
ling1726 Mar 1, 2022
f178729
add autofocus warning
ling1726 Mar 1, 2022
b4f21e9
fix tests
ling1726 Mar 1, 2022
a6f909d
fix lint
ling1726 Mar 1, 2022
2a6c646
fix typing
ling1726 Mar 1, 2022
11ea988
Merge remote-tracking branch 'origin/master' into chore/floating-ui
ling1726 Mar 1, 2022
6d3bbd2
fix types
ling1726 Mar 1, 2022
d44bc44
bump to latest prerelease
ling1726 Mar 2, 2022
1957163
use custom offset middleware
ling1726 Mar 2, 2022
15e84d8
cleanup
ling1726 Mar 2, 2022
999261f
add comment
ling1726 Mar 2, 2022
6b12cca
unnecessary export
ling1726 Mar 2, 2022
4249318
cleanup
ling1726 Mar 2, 2022
f15c862
remove unnecessary middleware wrapper
ling1726 Mar 2, 2022
3393023
import middleware correctly
ling1726 Mar 2, 2022
566c787
fix rtl placement
ling1726 Mar 2, 2022
f4142fc
rtl independent placement
ling1726 Mar 2, 2022
593cd9e
alignment rtl handled by floating ui
ling1726 Mar 2, 2022
050ea14
use hide middleware twice
ling1726 Mar 2, 2022
be6a273
use only @floating-ui/dom
ling1726 Mar 3, 2022
4b89ff5
merge master
ling1726 Mar 7, 2022
4541dd0
dedupe lock
ling1726 Mar 7, 2022
7a891e2
fix typos
ling1726 Mar 7, 2022
19da8b2
mergeArrowOffset
ling1726 Mar 7, 2022
86bd0ef
rename getBasePlacement to getSide
ling1726 Mar 7, 2022
574556e
docs for debounce
ling1726 Mar 7, 2022
4eefe8e
rename toggleScrollListener
ling1726 Mar 7, 2022
44f1bd6
rename constants
ling1726 Mar 7, 2022
0c26ea5
nit
ling1726 Mar 7, 2022
a545823
update shift middleware
ling1726 Mar 7, 2022
1db7e04
rename middleware to base*
ling1726 Mar 7, 2022
c44a724
rename to intersecting middleware
ling1726 Mar 7, 2022
865a07e
remove middleawre spreading
ling1726 Mar 7, 2022
39fe5f6
fix typo
ling1726 Mar 7, 2022
0f789cd
update change files
ling1726 Mar 7, 2022
7ccb4a6
refactor docs to use new offset values
ling1726 Mar 7, 2022
7560f97
import type
ling1726 Mar 7, 2022
7943657
import type
ling1726 Mar 7, 2022
81e678f
PopperVirtualElement to PositioningVirtualElement
ling1726 Mar 7, 2022
b55f428
fix positioning helper tests
ling1726 Mar 7, 2022
462d537
Popper to Floating UI
ling1726 Mar 7, 2022
162ff51
simplify effects
ling1726 Mar 7, 2022
5ef2430
remove unsed useIsFirstMount
ling1726 Mar 7, 2022
f59159d
improve middleware types
ling1726 Mar 7, 2022
d60fda3
debounce as named export
ling1726 Mar 7, 2022
6388ba6
add position fixed comment
ling1726 Mar 7, 2022
6cb837a
local functions for assignments
ling1726 Mar 7, 2022
bfc3076
hasScrollParent util
ling1726 Mar 7, 2022
6b178c8
Merge branch 'master' into chore/floating-ui
ling1726 Mar 11, 2022
68ec50c
bump, remove custom offset middleware
ling1726 Mar 11, 2022
aef9ff8
create separate ref hooks for elements
ling1726 Mar 11, 2022
08c7f3d
fix useFirstMount tests
ling1726 Mar 11, 2022
13d0e10
Change files
ling1726 Mar 11, 2022
5bd005e
Merge remote-tracking branch 'origin/master' into chore/floating-ui
ling1726 Mar 14, 2022
db1de63
add extra data- attribute
ling1726 Mar 14, 2022
4c5d39d
pr issues
ling1726 Mar 14, 2022
1e178b2
add comment
ling1726 Mar 14, 2022
199597c
move usePopper to top
ling1726 Mar 14, 2022
77386bd
update md
ling1726 Mar 14, 2022
604471b
update API
ling1726 Mar 14, 2022
9d4ceeb
fix tests
ling1726 Mar 17, 2022
8e25099
copy types to retain TS minbar
ling1726 Mar 17, 2022
fffea0b
Merge branch 'master' into chore/floating-ui
ling1726 Mar 30, 2022
e33610f
patch floating ui for minbar test
ling1726 Mar 30, 2022
661689d
remove type layer
ling1726 Mar 30, 2022
dbcbf8f
Merge branch 'master' into chore/floating-ui
ling1726 Mar 30, 2022
03b40a2
update md
ling1726 Mar 30, 2022
7b770a1
Merge branch 'master' into chore/floating-ui
ling1726 Apr 7, 2022
f277cf5
remove first mount update
ling1726 Apr 8, 2022
4f15da7
remove unnecessary changefile
ling1726 Apr 8, 2022
d10771f
Merge branch 'master' into chore/floating-ui
ling1726 Apr 8, 2022
a6e32ef
use window from context
ling1726 Apr 8, 2022
ef658f4
remove jsdoc
ling1726 Apr 8, 2022
4fae144
update API to wrap around floating UI completely
ling1726 Apr 10, 2022
d6d41f8
update react-positioning usages
ling1726 Apr 10, 2022
b296be4
remove export *
ling1726 Apr 10, 2022
02309b9
remove poppse from hook names
ling1726 Apr 10, 2022
c2b3a49
merge master
ling1726 Apr 13, 2022
4759559
Merge branch 'chore/floating-ui' of https://github.com/ling1726/fluen…
ling1726 Apr 13, 2022
b961173
remove duplicate import
ling1726 Apr 13, 2022
3e24d1c
Update change/@fluentui-react-popover-7c1b5c26-eb72-4d8b-8951-f6a5501…
ling1726 Apr 13, 2022
c21ca5a
Update change/@fluentui-react-tooltip-3f810af7-b574-4988-bf02-21dbdde…
ling1726 Apr 13, 2022
b880b4a
change file
ling1726 Apr 13, 2022
31f605f
Merge branch 'chore/floating-ui' of https://github.com/ling1726/fluen…
ling1726 Apr 13, 2022
8445272
Update change/@fluentui-react-menu-16ea1e78-a70f-4378-9515-49a0254f32…
ling1726 Apr 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/node_modules/@floating-ui/core/src/types.d.ts b/node_modules/@floating-ui/core/src/types.d.ts
index f5c4f1b..14cc9b3 100644
--- a/node_modules/@floating-ui/core/src/types.d.ts
+++ b/node_modules/@floating-ui/core/src/types.d.ts
@@ -1,6 +1,14 @@
export declare type Alignment = 'start' | 'end';
export declare type Side = 'top' | 'right' | 'bottom' | 'left';
-export declare type AlignedPlacement = `${Side}-${Alignment}`;
+export declare type AlignedPlacement =
+ | 'top-start'
+ | 'top-end'
+ | 'right-start'
+ | 'right-end'
+ | 'bottom-start'
+ | 'bottom-end'
+ | 'left-start'
+ | 'left-end';
export declare type Placement = Side | AlignedPlacement;
export declare type Strategy = 'absolute' | 'fixed';
export declare type Axis = 'x' | 'y';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diff --git a/node_modules/@floating-ui/dom/src/utils/getOverflowAncestors.d.ts b/node_modules/@floating-ui/dom/src/utils/getOverflowAncestors.d.ts
index 461f170..86d7a4a 100644
--- a/node_modules/@floating-ui/dom/src/utils/getOverflowAncestors.d.ts
+++ b/node_modules/@floating-ui/dom/src/utils/getOverflowAncestors.d.ts
@@ -1 +1 @@
-export declare function getOverflowAncestors(node: Node, list?: Array<Element | Window>): Array<Element | Window | VisualViewport>;
+export declare function getOverflowAncestors(node: Node, list?: Array<Element | Window>): Array<Element | Window>;
Comment thread
ling1726 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Patches for TS minbar test

Some partners might be on incompatible versions of typescript, but are willing to patch incompatible
types on their end. If this is the case, simply create a similar patch for the affected code with
[patch-package](https://github.com/ds300/patch-package) and drop the resulting patch in this folder.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we provide copy pastable command to achieve that ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add the command, but it will still involve updating node_modules there's no way around that unfortunately

17 changes: 14 additions & 3 deletions apps/ts-minbar-test-react-components/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import config from '@fluentui/scripts/config';
import * as fs from 'fs-extra';
import * as fsExtra from 'fs-extra';
Comment thread
ling1726 marked this conversation as resolved.
Outdated
import * as path from 'path';
import {
addResolutionPathsForProjectPackages,
Expand All @@ -21,9 +22,14 @@ async function performTest() {
logger(`✔️ Temporary directories created under ${tempPaths.root}`);

// Install dependencies, using the minimum TS version supported for consumers
const dependencies = ['@types/react', '@types/react-dom', 'react', 'react-dom', `typescript@${tsVersion}`].join(
' ',
);
const dependencies = [
'@types/react',
'@types/react-dom',
'react',
'react-dom',
`typescript@${tsVersion}`,
'patch-package',
].join(' ');
await shEcho(`yarn add ${dependencies}`, tempPaths.testApp);
logger(`✔️ Dependencies were installed`);

Expand All @@ -37,6 +43,11 @@ async function performTest() {
fs.mkdirSync(path.join(tempPaths.testApp, 'src'));
fs.copyFileSync(scaffoldPath('index.tsx'), path.join(tempPaths.testApp, 'src/index.tsx'));
fs.copyFileSync(scaffoldPath('tsconfig.json'), path.join(tempPaths.testApp, 'tsconfig.json'));

fs.mkdirSync(path.join(tempPaths.testApp, 'patches/'));
fsExtra.copySync(scaffoldPath('patches/'), path.join(tempPaths.testApp, 'patches/'));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering why we need library abstraction for Node native api ? https://nodejs.org/docs/latest-v14.x/api/fs.html#fs_fs_copyfilesync_src_dest_mode

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because native fs.copyFile is not recursive and does not handle directories

await shEcho(`yarn patch-package`, tempPaths.testApp);

logger(`✔️ Source and configs were copied`);

await shEcho(`npx npm-which yarn`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
usePopper,
createArrowStyles,
PositioningProps,
PopperVirtualElement,
PositioningVirtualElement,
PopperRefHandle,
} from '@fluentui/react-positioning';
import { makeStyles, mergeClasses, shorthands } from '@griffel/react';
Expand Down Expand Up @@ -134,7 +134,7 @@ const Offset = () => {
const positionedRefs = positions.reduce<ReturnType<typeof usePopper>[]>((acc, cur) => {
// this loop is deterministic
// eslint-disable-next-line react-hooks/rules-of-hooks
const popperRefs = usePopper({ position: cur[0], align: cur[1], offset: [10, 10] });
const popperRefs = usePopper({ position: cur[0], align: cur[1], offset: { crossAxis: 10, mainAxis: 10 } });
acc.push(popperRefs);
return acc;
}, []);
Expand All @@ -156,7 +156,7 @@ const OffsetFunction = () => {
const positionedRefs = positions.reduce<ReturnType<typeof usePopper>[]>((acc, cur) => {
// this loop is deterministic
// eslint-disable-next-line react-hooks/rules-of-hooks
const popperRefs = usePopper({ position: cur[0], align: cur[1], offset: () => [10, 10] });
const popperRefs = usePopper({ position: cur[0], align: cur[1], offset: () => ({ crossAxis: 10, mainAxis: 10 }) });
acc.push(popperRefs);
return acc;
}, []);
Expand Down Expand Up @@ -375,17 +375,20 @@ const AutoSize = () => {

const DisableTether = () => {
const styles = useStyles();
const [boundary, setBoundary] = React.useState<HTMLDivElement | null>(null);
const { containerRef, targetRef } = usePopper({
position: 'above',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/naming-convention
unstable_disableTether: 'all',
overflowBoundary: boundary,
});

return (
<>
<div
ref={setBoundary}
className={styles.boundary}
style={{
display: 'flex',
Expand All @@ -396,7 +399,7 @@ const DisableTether = () => {
position: 'relative',
}}
>
<button style={{ position: 'absolute', top: -1000 }} ref={targetRef}>
<button style={{ position: 'absolute', top: -50 }} ref={targetRef}>
Target
</button>
<Box ref={containerRef}>Untethered</Box>
Expand All @@ -418,7 +421,7 @@ const VirtualElement = () => {

React.useEffect(() => {
if (target) {
const virtualElement: PopperVirtualElement = {
const virtualElement: PositioningVirtualElement = {
getBoundingClientRect: () => target.getBoundingClientRect(),
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "fix: Update usages of react-positioning",
Comment thread
ling1726 marked this conversation as resolved.
Outdated
"packageName": "@fluentui/react-popover",
"email": "lingfangao@hotmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "BREAKING: Upgrade PopperJS for FloatingUI",
"packageName": "@fluentui/react-positioning",
"email": "lingfangao@hotmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "fix: update usages of positioning API",
Comment thread
ling1726 marked this conversation as resolved.
Outdated
"packageName": "@fluentui/react-tooltip",
"email": "lingfangao@hotmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "BREAKING: useFirstMount now returns a function getter so that it can be used in closures",
"packageName": "@fluentui/react-utilities",
"email": "lingfangao@hotmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ CoverTarget.parameters = {

CoverTarget.decorators = [
(Story: React.ElementType) => (
<div style={{ height: 700, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<div style={{ height: 700, display: 'flex', alignItems: 'center' }}>
<Story />
</div>
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Tooltip } from '@fluentui/react-components';
import { PopperRefHandle, PopperVirtualElement } from '@fluentui/react-positioning';
import { PopperRefHandle, PositioningVirtualElement } from '@fluentui/react-positioning';

export const ImperativeAnchorTarget = () => {
const popperRef = React.useRef<PopperRefHandle>(null);
Expand All @@ -19,7 +19,7 @@ export const ImperativeAnchorTarget = () => {
y,
});
};
const virtualElement: PopperVirtualElement = {
const virtualElement: PositioningVirtualElement = {
getBoundingClientRect: getRect(e.clientX, e.clientY),
};
popperRef.current?.setTarget(virtualElement);
Expand All @@ -40,7 +40,7 @@ export const ImperativeAnchorTarget = () => {
<>
<Tooltip
visible={open}
positioning={{ popperRef, offset: [0, 15] }}
positioning={{ popperRef, offset: { crossAxis: 0, mainAxis: 15 } }}
content="Follows the cursor"
relationship="label"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Button } from '@fluentui/react-button';
import { PositioningProps } from '@fluentui/react-positioning';

export const OffsetFunction = () => {
const offset: PositioningProps['offset'] = ({ popper, reference, placement }) => {
return [10, popper.width / 2];
const offset: PositioningProps['offset'] = ({ floating, reference, placement }) => {
Comment thread
ling1726 marked this conversation as resolved.
Outdated
return { crossAxis: 10, mainAxis: floating.width / 2 };
};

return (
Expand All @@ -25,11 +25,11 @@ OffsetFunction.parameters = {
description: {
story: [
'The positioned element can be offset from the target element by using a callback function.',
'The callback function provides the arguments and are a values used directly by Popper.',
'The callback function provides the arguments and are a values used directly by Floating UI.',
'',
'- Dimensions and position of the positioned element',
'- Dimensions and position of the reference element',
'- The Popper.JS placement value',
'- The Floating UI placement value',
].join('\n'),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,27 @@ import { Popover, PopoverTrigger, PopoverSurface } from '@fluentui/react-popover
import { Button } from '@fluentui/react-button';

export const OffsetValue = () => {
const [offsetY, setOffsetY] = React.useState(10);
const [offsetX, setOffsetX] = React.useState(10);
const [crossAxis, setCrossAxis] = React.useState(10);
const [mainAxis, setMainAxis] = React.useState(10);

const onChangeY = (e: React.ChangeEvent<HTMLInputElement>) => {
setOffsetY(parseInt(e.target.value, 10));
setCrossAxis(parseInt(e.target.value, 10));
};

const onChangeX = (e: React.ChangeEvent<HTMLInputElement>) => {
setOffsetX(parseInt(e.target.value, 10));
setMainAxis(parseInt(e.target.value, 10));
};
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
<label style={{ display: 'flex', gap: 10 }}>
Offset Y
<input onChange={onChangeY} value={offsetY} type="number" />
Cross axis
<input onChange={onChangeY} value={crossAxis} type="number" />
</label>
<label style={{ display: 'flex', gap: 10 }}>
Offset X
<input onChange={onChangeX} value={offsetX} type="number" />
Main axis
<input onChange={onChangeX} value={mainAxis} type="number" />
</label>
<Popover positioning={{ position: 'after', offset: [offsetY, offsetX] }} noArrow>
<PopoverTrigger>
<Button appearance="primary">Click me</Button>
</PopoverTrigger>

<PopoverSurface style={{ minWidth: 100 }}>Container</PopoverSurface>
</Popover>
<Popover positioning={{ position: 'after', offset: () => [offsetY, offsetX] }} noArrow>
<Popover positioning={{ position: 'after', offset: { crossAxis, mainAxis } }} noArrow>
<PopoverTrigger>
<Button appearance="primary">Click me</Button>
</PopoverTrigger>
Expand All @@ -47,9 +40,16 @@ OffsetValue.parameters = {
description: {
story: [
'The positioned element can be offset from the target element. The offset value can be set either by:',
'Offset is determined by',
'',
'- Cross axis: The distance the positioning element slides from the target',
'- Main axis: The distance between positioning element and the target',
'',
'Offset is determined by',
'',
'- An object with cross axis and main axis values',
'- A function that returns the offset object',
'',
'- Simple array with X and Y axis values',
'- A function that returns the array offset value',
].join('\n'),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ ShorthandPositions.parameters = {

ShorthandPositions.decorators = [
(Story: React.ElementType) => (
<div style={{ height: 700, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<div style={{ height: 700, display: 'flex', alignItems: 'center' }}>
<Story />
</div>
),
Expand Down
4 changes: 2 additions & 2 deletions packages/react-popover/etc/react-popover.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import type { ContextSelector } from '@fluentui/react-context-selector';
import type { FluentTriggerComponent } from '@fluentui/react-utilities';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import { JSXElementConstructor } from 'react';
import type { PopperVirtualElement } from '@fluentui/react-positioning';
import type { PortalProps } from '@fluentui/react-portal';
import type { PositioningShorthand } from '@fluentui/react-positioning';
import type { PositioningVirtualElement } from '@fluentui/react-positioning';
import * as React_2 from 'react';
import { ReactElement } from 'react';
import type { Slot } from '@fluentui/react-utilities';
Expand Down Expand Up @@ -55,7 +55,7 @@ export type PopoverState = PopoverCommons & Pick<PopoverProps, 'children'> & {
triggerRef: React_2.MutableRefObject<HTMLElement | null>;
contentRef: React_2.MutableRefObject<HTMLElement | null>;
arrowRef: React_2.MutableRefObject<HTMLDivElement | null>;
contextTarget: PopperVirtualElement | undefined;
contextTarget: PositioningVirtualElement | undefined;
setContextTarget: ReturnType<typeof usePopperMouseTarget>[1];
size: NonNullable<PopoverProps['size']>;
popoverTrigger: React_2.ReactElement | undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import type { PopperVirtualElement, PositioningShorthand, usePopperMouseTarget } from '@fluentui/react-positioning';
import type {
PositioningVirtualElement,
PositioningShorthand,
usePopperMouseTarget,
} from '@fluentui/react-positioning';
import type { PortalProps } from '@fluentui/react-portal';

/**
Expand Down Expand Up @@ -95,7 +99,7 @@ export type PopoverState = PopoverCommons &
/**
* Anchors the popper to the mouse click for context events
*/
contextTarget: PopperVirtualElement | undefined;
contextTarget: PositioningVirtualElement | undefined;
/**
* A callback to set the target of the popper to the mouse click for context events
*/
Expand Down
Loading