@fluentui/react-positioning 9.0.0-nightly.f81b28ceb3.1 → 9.0.0-rc.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. package/CHANGELOG.json +494 -10
  2. package/CHANGELOG.md +221 -71
  3. package/dist/index.d.ts +247 -0
  4. package/{lib → dist}/tsdoc-metadata.json +0 -0
  5. package/lib/createArrowStyles.js +87 -0
  6. package/lib/createArrowStyles.js.map +1 -0
  7. package/lib/createVirtualElementFromClick.js +19 -15
  8. package/lib/createVirtualElementFromClick.js.map +1 -1
  9. package/lib/index.js +4 -4
  10. package/lib/index.js.map +1 -1
  11. package/lib/isIntersectingModifier.js +26 -0
  12. package/lib/isIntersectingModifier.js.map +1 -0
  13. package/lib/types.js.map +1 -1
  14. package/lib/usePositioning.js +408 -0
  15. package/lib/usePositioning.js.map +1 -0
  16. package/lib/usePositioningMouseTarget.js +40 -0
  17. package/lib/usePositioningMouseTarget.js.map +1 -0
  18. package/lib/utils/fromPopperPlacement.js +40 -0
  19. package/lib/utils/fromPopperPlacement.js.map +1 -0
  20. package/lib/utils/getBoundary.js +15 -10
  21. package/lib/utils/getBoundary.js.map +1 -1
  22. package/lib/utils/getPopperOffset.js +44 -0
  23. package/lib/utils/getPopperOffset.js.map +1 -0
  24. package/lib/utils/getReactFiberFromNode.js +39 -35
  25. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  26. package/lib/utils/getScrollParent.js +46 -32
  27. package/lib/utils/getScrollParent.js.map +1 -1
  28. package/lib/utils/index.js +1 -1
  29. package/lib/utils/index.js.map +1 -1
  30. package/lib/utils/mergeArrowOffset.js +31 -25
  31. package/lib/utils/mergeArrowOffset.js.map +1 -1
  32. package/lib/utils/parsePopperPlacement.js +14 -0
  33. package/lib/utils/parsePopperPlacement.js.map +1 -0
  34. package/lib/utils/positioningHelper.js +42 -34
  35. package/lib/utils/positioningHelper.js.map +1 -1
  36. package/lib/utils/resolvePositioningShorthand.js +58 -20
  37. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  38. package/lib/utils/useCallbackRef.js +35 -29
  39. package/lib/utils/useCallbackRef.js.map +1 -1
  40. package/lib-commonjs/createArrowStyles.js +100 -0
  41. package/lib-commonjs/createArrowStyles.js.map +1 -0
  42. package/lib-commonjs/createVirtualElementFromClick.js +25 -16
  43. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  44. package/lib-commonjs/index.js +62 -10
  45. package/lib-commonjs/index.js.map +1 -1
  46. package/lib-commonjs/isIntersectingModifier.js +34 -0
  47. package/lib-commonjs/isIntersectingModifier.js.map +1 -0
  48. package/lib-commonjs/types.js +4 -1
  49. package/lib-commonjs/types.js.map +1 -1
  50. package/lib-commonjs/usePositioning.js +424 -0
  51. package/lib-commonjs/usePositioning.js.map +1 -0
  52. package/lib-commonjs/usePositioningMouseTarget.js +51 -0
  53. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -0
  54. package/lib-commonjs/utils/fromPopperPlacement.js +50 -0
  55. package/lib-commonjs/utils/fromPopperPlacement.js.map +1 -0
  56. package/lib-commonjs/utils/getBoundary.js +23 -12
  57. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  58. package/lib-commonjs/utils/getPopperOffset.js +54 -0
  59. package/lib-commonjs/utils/getPopperOffset.js.map +1 -0
  60. package/lib-commonjs/utils/getReactFiberFromNode.js +44 -36
  61. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  62. package/lib-commonjs/utils/getScrollParent.js +53 -33
  63. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  64. package/lib-commonjs/utils/index.js +15 -3
  65. package/lib-commonjs/utils/index.js.map +1 -1
  66. package/lib-commonjs/utils/mergeArrowOffset.js +37 -26
  67. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  68. package/lib-commonjs/utils/parsePopperPlacement.js +23 -0
  69. package/lib-commonjs/utils/parsePopperPlacement.js.map +1 -0
  70. package/lib-commonjs/utils/positioningHelper.js +50 -35
  71. package/lib-commonjs/utils/positioningHelper.js.map +1 -1
  72. package/lib-commonjs/utils/resolvePositioningShorthand.js +66 -23
  73. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  74. package/lib-commonjs/utils/useCallbackRef.js +45 -32
  75. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  76. package/package.json +17 -14
  77. package/dist/react-positioning.d.ts +0 -143
  78. package/lib/createVirtualElementFromClick.d.ts +0 -6
  79. package/lib/index.d.ts +0 -5
  80. package/lib/types.d.ts +0 -68
  81. package/lib/usePopper.d.ts +0 -35
  82. package/lib/usePopper.js +0 -357
  83. package/lib/usePopper.js.map +0 -1
  84. package/lib/usePopperMouseTarget.d.ts +0 -11
  85. package/lib/usePopperMouseTarget.js +0 -34
  86. package/lib/usePopperMouseTarget.js.map +0 -1
  87. package/lib/utils/getBasePlacement.d.ts +0 -8
  88. package/lib/utils/getBasePlacement.js +0 -10
  89. package/lib/utils/getBasePlacement.js.map +0 -1
  90. package/lib/utils/getBoundary.d.ts +0 -6
  91. package/lib/utils/getReactFiberFromNode.d.ts +0 -109
  92. package/lib/utils/getScrollParent.d.ts +0 -12
  93. package/lib/utils/index.d.ts +0 -8
  94. package/lib/utils/mergeArrowOffset.d.ts +0 -10
  95. package/lib/utils/positioningHelper.d.ts +0 -7
  96. package/lib/utils/resolvePositioningShorthand.d.ts +0 -2
  97. package/lib/utils/useCallbackRef.d.ts +0 -19
  98. package/lib-commonjs/createVirtualElementFromClick.d.ts +0 -6
  99. package/lib-commonjs/index.d.ts +0 -5
  100. package/lib-commonjs/types.d.ts +0 -68
  101. package/lib-commonjs/usePopper.d.ts +0 -35
  102. package/lib-commonjs/usePopper.js +0 -361
  103. package/lib-commonjs/usePopper.js.map +0 -1
  104. package/lib-commonjs/usePopperMouseTarget.d.ts +0 -11
  105. package/lib-commonjs/usePopperMouseTarget.js +0 -38
  106. package/lib-commonjs/usePopperMouseTarget.js.map +0 -1
  107. package/lib-commonjs/utils/getBasePlacement.d.ts +0 -8
  108. package/lib-commonjs/utils/getBasePlacement.js +0 -14
  109. package/lib-commonjs/utils/getBasePlacement.js.map +0 -1
  110. package/lib-commonjs/utils/getBoundary.d.ts +0 -6
  111. package/lib-commonjs/utils/getReactFiberFromNode.d.ts +0 -109
  112. package/lib-commonjs/utils/getScrollParent.d.ts +0 -12
  113. package/lib-commonjs/utils/index.d.ts +0 -8
  114. package/lib-commonjs/utils/mergeArrowOffset.d.ts +0 -10
  115. package/lib-commonjs/utils/positioningHelper.d.ts +0 -7
  116. package/lib-commonjs/utils/resolvePositioningShorthand.d.ts +0 -2
  117. package/lib-commonjs/utils/useCallbackRef.d.ts +0 -19
@@ -1,109 +0,0 @@
1
- /// <reference types="custom-global" />
2
- import * as React from 'react';
3
- declare type ReactEventResponder<E, C> = {
4
- $$typeof: Symbol | number;
5
- displayName: string;
6
- targetEventTypes: null | string[];
7
- rootEventTypes: null | string[];
8
- getInitialState: null | ((props: Object) => Object);
9
- onEvent: null | ((event: E, context: C, props: Object, state: Object) => void);
10
- onRootEvent: null | ((event: E, context: C, props: Object, state: Object) => void);
11
- onMount: null | ((context: C, props: Object, state: Object) => void);
12
- onUnmount: null | ((context: C, props: Object, state: Object) => void);
13
- };
14
- declare type ReactEventResponderInstance<E, C> = {
15
- fiber: Object;
16
- props: Object;
17
- responder: ReactEventResponder<E, C>;
18
- rootEventTypes: null | Set<string>;
19
- state: Object;
20
- };
21
- export declare type HookType = 'useState' | 'useReducer' | 'useContext' | 'useRef' | 'useEffect' | 'useLayoutEffect' | 'useCallback' | 'useMemo' | 'useImperativeHandle' | 'useDebugValue' | 'useResponder';
22
- declare type ReactProviderType<T> = {
23
- $$typeof: Symbol | number;
24
- _context: ReactContext<T>;
25
- };
26
- declare type ReactContext<T> = {
27
- $$typeof: Symbol | number;
28
- Consumer: ReactContext<T>;
29
- Provider: ReactProviderType<T>;
30
- _calculateChangedBits: ((a: T, b: T) => number) | null;
31
- _currentValue: T;
32
- _currentValue2: T;
33
- _threadCount: number;
34
- _currentRenderer?: Object | null;
35
- _currentRenderer2?: Object | null;
36
- };
37
- declare type ContextDependency<T> = {
38
- context: ReactContext<T>;
39
- observedBits: number;
40
- next: ContextDependency<any> | null;
41
- };
42
- declare enum WorkTag {
43
- FunctionComponent = 0,
44
- ClassComponent = 1,
45
- IndeterminateComponent = 2,
46
- HostRoot = 3,
47
- HostPortal = 4,
48
- HostComponent = 5,
49
- HostText = 6,
50
- Fragment = 7,
51
- Mode = 8,
52
- ContextConsumer = 9,
53
- ContextProvider = 10,
54
- ForwardRef = 11,
55
- Profiler = 12,
56
- SuspenseComponent = 13,
57
- MemoComponent = 14,
58
- SimpleMemoComponent = 15,
59
- LazyComponent = 16,
60
- IncompleteClassComponent = 17,
61
- DehydratedFragment = 18,
62
- SuspenseListComponent = 19,
63
- FundamentalComponent = 20,
64
- ScopeComponent = 21
65
- }
66
- declare type Source = {
67
- fileName: string;
68
- lineNumber: number;
69
- };
70
- declare type ExpirationTime = number;
71
- declare type Dependencies = {
72
- expirationTime: ExpirationTime;
73
- firstContext: ContextDependency<any> | null;
74
- responders: Map<ReactEventResponder<any, any>, ReactEventResponderInstance<any, any>> | null;
75
- };
76
- export declare type Fiber = {
77
- tag: WorkTag;
78
- key: null | string;
79
- elementType: any;
80
- type: any;
81
- stateNode: any;
82
- return: Fiber | null;
83
- child: Fiber | null;
84
- sibling: Fiber | null;
85
- index: number;
86
- ref: React.Ref<any>;
87
- pendingProps: any;
88
- memoizedProps: any;
89
- memoizedState: any;
90
- dependencies: Dependencies | null;
91
- nextEffect: Fiber | null;
92
- firstEffect: Fiber | null;
93
- lastEffect: Fiber | null;
94
- expirationTime: ExpirationTime;
95
- childExpirationTime: ExpirationTime;
96
- alternate: Fiber | null;
97
- actualDuration?: number;
98
- actualStartTime?: number;
99
- selfBaseDuration?: number;
100
- treeBaseDuration?: number;
101
- _debugID?: number;
102
- _debugSource?: Source | null;
103
- _debugOwner?: Fiber | null;
104
- _debugIsCurrentlyTiming?: boolean;
105
- _debugNeedsRemount?: boolean;
106
- _debugHookTypes?: HookType[] | null;
107
- };
108
- export declare function getReactFiberFromNode(elm: Node | undefined): Fiber | null;
109
- export {};
@@ -1,12 +0,0 @@
1
- /**
2
- * Returns the parent node or the host of the node argument.
3
- * @param node - DOM node.
4
- * @returns - parent DOM node.
5
- */
6
- export declare const getParentNode: (node: HTMLElement) => HTMLElement;
7
- /**
8
- * Returns the first scrollable parent of the given element.
9
- * @param node - DOM node.
10
- * @returns - the first scrollable parent.
11
- */
12
- export declare const getScrollParent: (node: Document | HTMLElement | null) => HTMLElement;
@@ -1,8 +0,0 @@
1
- export * from './getBasePlacement';
2
- export * from './getBoundary';
3
- export * from './getReactFiberFromNode';
4
- export * from './getScrollParent';
5
- export * from './mergeArrowOffset';
6
- export * from './positioningHelper';
7
- export * from './resolvePositioningShorthand';
8
- export * from './useCallbackRef';
@@ -1,10 +0,0 @@
1
- import type { Offset } from '../types';
2
- /**
3
- * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
4
- * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
5
- *
6
- * @param userOffset - The offset provided by the user
7
- * @param arrowHeight - The height of the arrow in px
8
- * @returns User offset augmented with arrow height
9
- */
10
- export declare function mergeArrowOffset(userOffset: Offset | undefined | null, arrowHeight: number): Offset;
@@ -1,7 +0,0 @@
1
- import * as PopperJs from '@popperjs/core';
2
- import type { Offset } from '../types';
3
- /**
4
- * @see positioninHelper.test.ts for expected placement values
5
- */
6
- export declare const getPlacement: (align?: "top" | "bottom" | "start" | "end" | "center" | undefined, position?: "above" | "below" | "before" | "after" | undefined, rtl?: boolean | undefined) => PopperJs.Placement;
7
- export declare const applyRtlToOffset: (offset: Offset | undefined) => Offset | undefined;
@@ -1,2 +0,0 @@
1
- import type { PositioningShorthand, PositioningProps } from '../types';
2
- export declare function resolvePositioningShorthand(shorthand: PositioningShorthand | undefined | null): Readonly<PositioningProps>;
@@ -1,19 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content
4
- * changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via
5
- * React.useState(), but it will cause re-renders always.
6
- *
7
- * https://reactjs.org/docs/hooks-reference.html#useref
8
- * https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
9
- *
10
- * @param initialValue - initial ref value
11
- * @param callback - a callback to run when value changes
12
- * @param skipInitialResolve - a flag to skip an initial ref report
13
- *
14
- * @example
15
- * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
16
- * ref.current = 1;
17
- * // prints 0 -> 1
18
- */
19
- export declare function useCallbackRef<T>(initialValue: T | null, callback: (newValue: T | null, lastValue: T | null) => void, skipInitialResolve?: boolean): React.MutableRefObject<T | null>;