@fluentui/react-positioning 0.0.0-nightly-20220302-0405.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CHANGELOG.json +1614 -0
  2. package/CHANGELOG.md +719 -0
  3. package/LICENSE +15 -0
  4. package/README.md +25 -0
  5. package/dist/react-positioning.d.ts +221 -0
  6. package/lib/createArrowStyles.d.ts +64 -0
  7. package/lib/createArrowStyles.js +87 -0
  8. package/lib/createArrowStyles.js.map +1 -0
  9. package/lib/createVirtualElementFromClick.d.ts +6 -0
  10. package/lib/createVirtualElementFromClick.js +26 -0
  11. package/lib/createVirtualElementFromClick.js.map +1 -0
  12. package/lib/index.d.ts +6 -0
  13. package/lib/index.js +7 -0
  14. package/lib/index.js.map +1 -0
  15. package/lib/isIntersectingModifier.d.ts +4 -0
  16. package/lib/isIntersectingModifier.js +26 -0
  17. package/lib/isIntersectingModifier.js.map +1 -0
  18. package/lib/tsdoc-metadata.json +11 -0
  19. package/lib/types.d.ts +89 -0
  20. package/lib/types.js +2 -0
  21. package/lib/types.js.map +1 -0
  22. package/lib/usePopper.d.ts +23 -0
  23. package/lib/usePopper.js +407 -0
  24. package/lib/usePopper.js.map +1 -0
  25. package/lib/usePopperMouseTarget.d.ts +11 -0
  26. package/lib/usePopperMouseTarget.js +40 -0
  27. package/lib/usePopperMouseTarget.js.map +1 -0
  28. package/lib/utils/getBasePlacement.d.ts +8 -0
  29. package/lib/utils/getBasePlacement.js +10 -0
  30. package/lib/utils/getBasePlacement.js.map +1 -0
  31. package/lib/utils/getBoundary.d.ts +6 -0
  32. package/lib/utils/getBoundary.js +23 -0
  33. package/lib/utils/getBoundary.js.map +1 -0
  34. package/lib/utils/getReactFiberFromNode.d.ts +108 -0
  35. package/lib/utils/getReactFiberFromNode.js +46 -0
  36. package/lib/utils/getReactFiberFromNode.js.map +1 -0
  37. package/lib/utils/getScrollParent.d.ts +12 -0
  38. package/lib/utils/getScrollParent.js +65 -0
  39. package/lib/utils/getScrollParent.js.map +1 -0
  40. package/lib/utils/index.d.ts +8 -0
  41. package/lib/utils/index.js +9 -0
  42. package/lib/utils/index.js.map +1 -0
  43. package/lib/utils/mergeArrowOffset.d.ts +10 -0
  44. package/lib/utils/mergeArrowOffset.js +42 -0
  45. package/lib/utils/mergeArrowOffset.js.map +1 -0
  46. package/lib/utils/positioningHelper.d.ts +7 -0
  47. package/lib/utils/positioningHelper.js +49 -0
  48. package/lib/utils/positioningHelper.js.map +1 -0
  49. package/lib/utils/resolvePositioningShorthand.d.ts +2 -0
  50. package/lib/utils/resolvePositioningShorthand.js +63 -0
  51. package/lib/utils/resolvePositioningShorthand.js.map +1 -0
  52. package/lib/utils/useCallbackRef.d.ts +19 -0
  53. package/lib/utils/useCallbackRef.js +57 -0
  54. package/lib/utils/useCallbackRef.js.map +1 -0
  55. package/lib-commonjs/createArrowStyles.d.ts +64 -0
  56. package/lib-commonjs/createArrowStyles.js +100 -0
  57. package/lib-commonjs/createArrowStyles.js.map +1 -0
  58. package/lib-commonjs/createVirtualElementFromClick.d.ts +6 -0
  59. package/lib-commonjs/createVirtualElementFromClick.js +35 -0
  60. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -0
  61. package/lib-commonjs/index.d.ts +6 -0
  62. package/lib-commonjs/index.js +34 -0
  63. package/lib-commonjs/index.js.map +1 -0
  64. package/lib-commonjs/isIntersectingModifier.d.ts +4 -0
  65. package/lib-commonjs/isIntersectingModifier.js +34 -0
  66. package/lib-commonjs/isIntersectingModifier.js.map +1 -0
  67. package/lib-commonjs/types.d.ts +89 -0
  68. package/lib-commonjs/types.js +6 -0
  69. package/lib-commonjs/types.js.map +1 -0
  70. package/lib-commonjs/usePopper.d.ts +23 -0
  71. package/lib-commonjs/usePopper.js +422 -0
  72. package/lib-commonjs/usePopper.js.map +1 -0
  73. package/lib-commonjs/usePopperMouseTarget.d.ts +11 -0
  74. package/lib-commonjs/usePopperMouseTarget.js +51 -0
  75. package/lib-commonjs/usePopperMouseTarget.js.map +1 -0
  76. package/lib-commonjs/utils/getBasePlacement.d.ts +8 -0
  77. package/lib-commonjs/utils/getBasePlacement.js +19 -0
  78. package/lib-commonjs/utils/getBasePlacement.js.map +1 -0
  79. package/lib-commonjs/utils/getBoundary.d.ts +6 -0
  80. package/lib-commonjs/utils/getBoundary.js +33 -0
  81. package/lib-commonjs/utils/getBoundary.js.map +1 -0
  82. package/lib-commonjs/utils/getReactFiberFromNode.d.ts +108 -0
  83. package/lib-commonjs/utils/getReactFiberFromNode.js +54 -0
  84. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -0
  85. package/lib-commonjs/utils/getScrollParent.d.ts +12 -0
  86. package/lib-commonjs/utils/getScrollParent.js +76 -0
  87. package/lib-commonjs/utils/getScrollParent.js.map +1 -0
  88. package/lib-commonjs/utils/index.d.ts +8 -0
  89. package/lib-commonjs/utils/index.js +24 -0
  90. package/lib-commonjs/utils/index.js.map +1 -0
  91. package/lib-commonjs/utils/mergeArrowOffset.d.ts +10 -0
  92. package/lib-commonjs/utils/mergeArrowOffset.js +51 -0
  93. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -0
  94. package/lib-commonjs/utils/positioningHelper.d.ts +7 -0
  95. package/lib-commonjs/utils/positioningHelper.js +61 -0
  96. package/lib-commonjs/utils/positioningHelper.js.map +1 -0
  97. package/lib-commonjs/utils/resolvePositioningShorthand.d.ts +2 -0
  98. package/lib-commonjs/utils/resolvePositioningShorthand.js +72 -0
  99. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -0
  100. package/lib-commonjs/utils/useCallbackRef.d.ts +19 -0
  101. package/lib-commonjs/utils/useCallbackRef.js +68 -0
  102. package/lib-commonjs/utils/useCallbackRef.js.map +1 -0
  103. package/package.json +55 -0
@@ -0,0 +1,108 @@
1
+ import * as React from 'react';
2
+ declare type ReactEventResponder<E, C> = {
3
+ $$typeof: Symbol | number;
4
+ displayName: string;
5
+ targetEventTypes: null | string[];
6
+ rootEventTypes: null | string[];
7
+ getInitialState: null | ((props: Object) => Object);
8
+ onEvent: null | ((event: E, context: C, props: Object, state: Object) => void);
9
+ onRootEvent: null | ((event: E, context: C, props: Object, state: Object) => void);
10
+ onMount: null | ((context: C, props: Object, state: Object) => void);
11
+ onUnmount: null | ((context: C, props: Object, state: Object) => void);
12
+ };
13
+ declare type ReactEventResponderInstance<E, C> = {
14
+ fiber: Object;
15
+ props: Object;
16
+ responder: ReactEventResponder<E, C>;
17
+ rootEventTypes: null | Set<string>;
18
+ state: Object;
19
+ };
20
+ export declare type HookType = 'useState' | 'useReducer' | 'useContext' | 'useRef' | 'useEffect' | 'useLayoutEffect' | 'useCallback' | 'useMemo' | 'useImperativeHandle' | 'useDebugValue' | 'useResponder';
21
+ declare type ReactProviderType<T> = {
22
+ $$typeof: Symbol | number;
23
+ _context: ReactContext<T>;
24
+ };
25
+ declare type ReactContext<T> = {
26
+ $$typeof: Symbol | number;
27
+ Consumer: ReactContext<T>;
28
+ Provider: ReactProviderType<T>;
29
+ _calculateChangedBits: ((a: T, b: T) => number) | null;
30
+ _currentValue: T;
31
+ _currentValue2: T;
32
+ _threadCount: number;
33
+ _currentRenderer?: Object | null;
34
+ _currentRenderer2?: Object | null;
35
+ };
36
+ declare type ContextDependency<T> = {
37
+ context: ReactContext<T>;
38
+ observedBits: number;
39
+ next: ContextDependency<any> | null;
40
+ };
41
+ declare enum WorkTag {
42
+ FunctionComponent = 0,
43
+ ClassComponent = 1,
44
+ IndeterminateComponent = 2,
45
+ HostRoot = 3,
46
+ HostPortal = 4,
47
+ HostComponent = 5,
48
+ HostText = 6,
49
+ Fragment = 7,
50
+ Mode = 8,
51
+ ContextConsumer = 9,
52
+ ContextProvider = 10,
53
+ ForwardRef = 11,
54
+ Profiler = 12,
55
+ SuspenseComponent = 13,
56
+ MemoComponent = 14,
57
+ SimpleMemoComponent = 15,
58
+ LazyComponent = 16,
59
+ IncompleteClassComponent = 17,
60
+ DehydratedFragment = 18,
61
+ SuspenseListComponent = 19,
62
+ FundamentalComponent = 20,
63
+ ScopeComponent = 21
64
+ }
65
+ declare type Source = {
66
+ fileName: string;
67
+ lineNumber: number;
68
+ };
69
+ declare type ExpirationTime = number;
70
+ declare type Dependencies = {
71
+ expirationTime: ExpirationTime;
72
+ firstContext: ContextDependency<any> | null;
73
+ responders: Map<ReactEventResponder<any, any>, ReactEventResponderInstance<any, any>> | null;
74
+ };
75
+ export declare type Fiber = {
76
+ tag: WorkTag;
77
+ key: null | string;
78
+ elementType: any;
79
+ type: any;
80
+ stateNode: any;
81
+ return: Fiber | null;
82
+ child: Fiber | null;
83
+ sibling: Fiber | null;
84
+ index: number;
85
+ ref: React.Ref<any>;
86
+ pendingProps: any;
87
+ memoizedProps: any;
88
+ memoizedState: any;
89
+ dependencies: Dependencies | null;
90
+ nextEffect: Fiber | null;
91
+ firstEffect: Fiber | null;
92
+ lastEffect: Fiber | null;
93
+ expirationTime: ExpirationTime;
94
+ childExpirationTime: ExpirationTime;
95
+ alternate: Fiber | null;
96
+ actualDuration?: number;
97
+ actualStartTime?: number;
98
+ selfBaseDuration?: number;
99
+ treeBaseDuration?: number;
100
+ _debugID?: number;
101
+ _debugSource?: Source | null;
102
+ _debugOwner?: Fiber | null;
103
+ _debugIsCurrentlyTiming?: boolean;
104
+ _debugNeedsRemount?: boolean;
105
+ _debugHookTypes?: HookType[] | null;
106
+ };
107
+ export declare function getReactFiberFromNode(elm: Node | undefined): Fiber | null;
108
+ export {};
@@ -0,0 +1,46 @@
1
+ var WorkTag;
2
+
3
+ (function (WorkTag) {
4
+ WorkTag[WorkTag["FunctionComponent"] = 0] = "FunctionComponent";
5
+ WorkTag[WorkTag["ClassComponent"] = 1] = "ClassComponent";
6
+ WorkTag[WorkTag["IndeterminateComponent"] = 2] = "IndeterminateComponent";
7
+ WorkTag[WorkTag["HostRoot"] = 3] = "HostRoot";
8
+ WorkTag[WorkTag["HostPortal"] = 4] = "HostPortal";
9
+ WorkTag[WorkTag["HostComponent"] = 5] = "HostComponent";
10
+ WorkTag[WorkTag["HostText"] = 6] = "HostText";
11
+ WorkTag[WorkTag["Fragment"] = 7] = "Fragment";
12
+ WorkTag[WorkTag["Mode"] = 8] = "Mode";
13
+ WorkTag[WorkTag["ContextConsumer"] = 9] = "ContextConsumer";
14
+ WorkTag[WorkTag["ContextProvider"] = 10] = "ContextProvider";
15
+ WorkTag[WorkTag["ForwardRef"] = 11] = "ForwardRef";
16
+ WorkTag[WorkTag["Profiler"] = 12] = "Profiler";
17
+ WorkTag[WorkTag["SuspenseComponent"] = 13] = "SuspenseComponent";
18
+ WorkTag[WorkTag["MemoComponent"] = 14] = "MemoComponent";
19
+ WorkTag[WorkTag["SimpleMemoComponent"] = 15] = "SimpleMemoComponent";
20
+ WorkTag[WorkTag["LazyComponent"] = 16] = "LazyComponent";
21
+ WorkTag[WorkTag["IncompleteClassComponent"] = 17] = "IncompleteClassComponent";
22
+ WorkTag[WorkTag["DehydratedFragment"] = 18] = "DehydratedFragment";
23
+ WorkTag[WorkTag["SuspenseListComponent"] = 19] = "SuspenseListComponent";
24
+ WorkTag[WorkTag["FundamentalComponent"] = 20] = "FundamentalComponent";
25
+ WorkTag[WorkTag["ScopeComponent"] = 21] = "ScopeComponent";
26
+ })(WorkTag || (WorkTag = {}));
27
+
28
+ export function getReactFiberFromNode(elm) {
29
+ if (!elm) {
30
+ return null;
31
+ }
32
+
33
+ for (const k in elm) {
34
+ // React 16 uses "__reactInternalInstance$" prefix
35
+ // React 17 uses "__reactFiber$" prefix
36
+ // https://github.com/facebook/react/pull/18377
37
+ if (k.indexOf('__reactInternalInstance$') === 0 || k.indexOf('__reactFiber$') === 0) {
38
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
39
+ // @ts-ignore
40
+ return elm[k];
41
+ }
42
+ }
43
+
44
+ throw new Error('getReactFiber(): Failed to find a React Fiber on a node');
45
+ }
46
+ //# sourceMappingURL=getReactFiberFromNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/getReactFiberFromNode.ts"],"names":[],"mappings":"AAuEA,IAAK,OAAL;;AAAA,CAAA,UAAK,OAAL,EAAY;AACV,EAAA,OAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,mBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,gBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,wBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA,GAAA,YAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,eAAA,CAAA,GAAA,CAAA,CAAA,GAAA,eAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,iBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,iBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,YAAA,CAAA,GAAA,EAAA,CAAA,GAAA,YAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,EAAA,CAAA,GAAA,UAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,mBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,eAAA,CAAA,GAAA,EAAA,CAAA,GAAA,eAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,qBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,eAAA,CAAA,GAAA,EAAA,CAAA,GAAA,eAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,0BAAA,CAAA,GAAA,EAAA,CAAA,GAAA,0BAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,oBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,uBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,uBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,sBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,gBAAA;AACD,CAvBD,EAAK,OAAO,KAAP,OAAO,GAAA,EAAA,CAAZ;;AAsLA,OAAM,SAAU,qBAAV,CAAgC,GAAhC,EAAqD;AACzD,MAAI,CAAC,GAAL,EAAU;AACR,WAAO,IAAP;AACD;;AAED,OAAK,MAAM,CAAX,IAAgB,GAAhB,EAAqB;AACnB;AACA;AACA;AACA,QAAI,CAAC,CAAC,OAAF,CAAU,0BAAV,MAA0C,CAA1C,IAA+C,CAAC,CAAC,OAAF,CAAU,eAAV,MAA+B,CAAlF,EAAqF;AACnF;AACA;AACA,aAAO,GAAG,CAAC,CAAD,CAAV;AACD;AACF;;AAED,QAAM,IAAI,KAAJ,CAAU,yDAAV,CAAN;AACD","sourcesContent":["import * as React from 'react';\n\n// ========================================================\n// react/packages/shared/ReactTypes.js\n// ========================================================\n\ntype ReactEventResponder<E, C> = {\n $$typeof: Symbol | number;\n displayName: string;\n targetEventTypes: null | string[];\n rootEventTypes: null | string[];\n getInitialState: null | ((props: Object) => Object);\n onEvent: null | ((event: E, context: C, props: Object, state: Object) => void);\n onRootEvent: null | ((event: E, context: C, props: Object, state: Object) => void);\n onMount: null | ((context: C, props: Object, state: Object) => void);\n onUnmount: null | ((context: C, props: Object, state: Object) => void);\n};\n\ntype ReactEventResponderInstance<E, C> = {\n fiber: Object;\n props: Object;\n responder: ReactEventResponder<E, C>;\n rootEventTypes: null | Set<string>;\n state: Object;\n};\n\n// ========================================================\n// react/packages/react-reconciler/src/ReactFiberHooks.js\n// ========================================================\n\nexport type HookType =\n | 'useState'\n | 'useReducer'\n | 'useContext'\n | 'useRef'\n | 'useEffect'\n | 'useLayoutEffect'\n | 'useCallback'\n | 'useMemo'\n | 'useImperativeHandle'\n | 'useDebugValue'\n | 'useResponder';\n\ntype ReactProviderType<T> = {\n $$typeof: Symbol | number;\n _context: ReactContext<T>;\n};\n\ntype ReactContext<T> = {\n $$typeof: Symbol | number;\n Consumer: ReactContext<T>;\n Provider: ReactProviderType<T>;\n\n _calculateChangedBits: ((a: T, b: T) => number) | null;\n\n _currentValue: T;\n _currentValue2: T;\n _threadCount: number;\n\n // DEV only\n _currentRenderer?: Object | null;\n _currentRenderer2?: Object | null;\n};\n\ntype ContextDependency<T> = {\n context: ReactContext<T>;\n observedBits: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n next: ContextDependency<any> | null;\n};\n\nenum WorkTag {\n FunctionComponent = 0,\n ClassComponent = 1,\n IndeterminateComponent = 2, // Before we know whether it is function or class\n HostRoot = 3, // Root of a host tree. Could be nested inside another node.\n HostPortal = 4, // A subtree. Could be an entry point to a different renderer.\n HostComponent = 5,\n HostText = 6,\n Fragment = 7,\n Mode = 8,\n ContextConsumer = 9,\n ContextProvider = 10,\n ForwardRef = 11,\n Profiler = 12,\n SuspenseComponent = 13,\n MemoComponent = 14,\n SimpleMemoComponent = 15,\n LazyComponent = 16,\n IncompleteClassComponent = 17,\n DehydratedFragment = 18,\n SuspenseListComponent = 19,\n FundamentalComponent = 20,\n ScopeComponent = 21,\n}\n\ntype Source = {\n fileName: string;\n lineNumber: number;\n};\n\ntype ExpirationTime = number;\n\ntype Dependencies = {\n expirationTime: ExpirationTime;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n firstContext: ContextDependency<any> | null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n responders: Map<ReactEventResponder<any, any>, ReactEventResponderInstance<any, any>> | null;\n};\n\n// ========================================================\n// react/packages/react-reconciler/src/ReactFiber.js\n// ========================================================\n\n// A Fiber is work on a Component that needs to be done or was done. There can\n// be more than one per component.\n\nexport type Fiber = {\n // These first fields are conceptually members of an Instance. This used to\n // be split into a separate type and intersected with the other Fiber fields,\n // but until Flow fixes its intersection bugs, we've merged them into a\n // single type.\n\n // An Instance is shared between all versions of a component. We can easily\n // break this out into a separate object to avoid copying so much to the\n // alternate versions of the tree. We put this on a single object for now to\n // minimize the number of objects created during the initial render.\n\n // Tag identifying the type of fiber.\n tag: WorkTag;\n\n // Unique identifier of this child.\n key: null | string;\n\n // The value of element.type which is used to preserve the identity during\n // reconciliation of this child.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementType: any;\n\n // The resolved function/class/ associated with this fiber.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type: any;\n\n // The local state associated with this fiber.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stateNode: any;\n\n // Conceptual aliases\n // parent : Instance -> return The parent happens to be the same as the\n // return fiber since we've merged the fiber and instance.\n\n // Remaining fields belong to Fiber\n\n // The Fiber to return to after finishing processing this one.\n // This is effectively the parent, but there can be multiple parents (two)\n // so this is only the parent of the thing we're currently processing.\n // It is conceptually the same as the return address of a stack frame.\n return: Fiber | null;\n\n // Singly Linked List Tree Structure.\n child: Fiber | null;\n sibling: Fiber | null;\n index: number;\n\n // The ref last used to attach this node.\n // I'll avoid adding an owner field for prod and model that as functions.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref: React.Ref<any>;\n\n // Input is the data coming into process this fiber. Arguments. Props.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n pendingProps: any; // This type will be more specific once we overload the tag.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n memoizedProps: any; // The props used to create the output.\n\n // A queue of state updates and callbacks.\n // updateQueue: UpdateQueue<any> | null,\n\n // The state used to create the output\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n memoizedState: any;\n\n // Dependencies (contexts, events) for this fiber, if it has any\n dependencies: Dependencies | null;\n\n // // Bitfield that describes properties about the fiber and its subtree. E.g.\n // // the ConcurrentMode flag indicates whether the subtree should be async-by-\n // // default. When a fiber is created, it inherits the mode of its\n // // parent. Additional flags can be set at creation time, but after that the\n // // value should remain unchanged throughout the fiber's lifetime, particularly\n // // before its child fibers are created.\n // mode: TypeOfMode\n //\n // // Effect\n // effectTag: SideEffectTag\n\n // Singly linked list fast path to the next fiber with side-effects.\n nextEffect: Fiber | null;\n\n // The first and last fiber with side-effect within this subtree. This allows\n // us to reuse a slice of the linked list when we reuse the work done within\n // this fiber.\n firstEffect: Fiber | null;\n lastEffect: Fiber | null;\n\n // Represents a time in the future by which this work should be completed.\n // Does not include work found in its subtree.\n expirationTime: ExpirationTime;\n\n // This is used to quickly determine if a subtree has no pending changes.\n childExpirationTime: ExpirationTime;\n\n // This is a pooled version of a Fiber. Every fiber that gets updated will\n // eventually have a pair. There are cases when we can clean up pairs to save\n // memory if we need to.\n alternate: Fiber | null;\n\n // Time spent rendering this Fiber and its descendants for the current update.\n // This tells us how well the tree makes use of sCU for memoization.\n // It is reset to 0 each time we render and only updated when we don't bailout.\n // This field is only set when the enableProfilerTimer flag is enabled.\n actualDuration?: number;\n\n // If the Fiber is currently active in the \"render\" phase,\n // This marks the time at which the work began.\n // This field is only set when the enableProfilerTimer flag is enabled.\n actualStartTime?: number;\n\n // Duration of the most recent render time for this Fiber.\n // This value is not updated when we bailout for memoization purposes.\n // This field is only set when the enableProfilerTimer flag is enabled.\n selfBaseDuration?: number;\n\n // Sum of base times for all descendants of this Fiber.\n // This value bubbles up during the \"complete\" phase.\n // This field is only set when the enableProfilerTimer flag is enabled.\n treeBaseDuration?: number;\n\n // Conceptual aliases\n // workInProgress : Fiber -> alternate The alternate used for reuse happens\n // to be the same as work in progress.\n // __DEV__ only\n _debugID?: number;\n _debugSource?: Source | null;\n _debugOwner?: Fiber | null;\n _debugIsCurrentlyTiming?: boolean;\n _debugNeedsRemount?: boolean;\n\n // Used to verify that the order of hooks does not change between renders.\n _debugHookTypes?: HookType[] | null;\n};\n\nexport function getReactFiberFromNode(elm: Node | undefined): Fiber | null {\n if (!elm) {\n return null;\n }\n\n for (const k in elm) {\n // React 16 uses \"__reactInternalInstance$\" prefix\n // React 17 uses \"__reactFiber$\" prefix\n // https://github.com/facebook/react/pull/18377\n if (k.indexOf('__reactInternalInstance$') === 0 || k.indexOf('__reactFiber$') === 0) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return elm[k];\n }\n }\n\n throw new Error('getReactFiber(): Failed to find a React Fiber on a node');\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,65 @@
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 const getParentNode = node => {
7
+ if (node.nodeName === 'HTML') {
8
+ return node;
9
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+
11
+
12
+ return node.parentNode || node.host;
13
+ };
14
+ /**
15
+ * Returns CSS styles of the given node.
16
+ * @param node - DOM node.
17
+ * @returns - CSS styles.
18
+ */
19
+
20
+ const getStyleComputedProperty = node => {
21
+ var _a;
22
+
23
+ if (node.nodeType !== 1) {
24
+ return {};
25
+ }
26
+
27
+ const window = (_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
28
+ return window.getComputedStyle(node, null);
29
+ };
30
+ /**
31
+ * Returns the first scrollable parent of the given element.
32
+ * @param node - DOM node.
33
+ * @returns - the first scrollable parent.
34
+ */
35
+
36
+
37
+ export const getScrollParent = node => {
38
+ // Return body, `getScroll` will take care to get the correct `scrollTop` from it
39
+ const parentNode = node && getParentNode(node); // eslint-disable-next-line
40
+
41
+ if (!parentNode) return document.body;
42
+
43
+ switch (parentNode.nodeName) {
44
+ case 'HTML':
45
+ case 'BODY':
46
+ return parentNode.ownerDocument.body;
47
+
48
+ case '#document':
49
+ return parentNode.body;
50
+ } // If any of the overflow props is defined for the node then we return it as the parent
51
+
52
+
53
+ const {
54
+ overflow,
55
+ overflowX,
56
+ overflowY
57
+ } = getStyleComputedProperty(parentNode);
58
+
59
+ if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
60
+ return parentNode;
61
+ }
62
+
63
+ return getScrollParent(parentNode);
64
+ };
65
+ //# sourceMappingURL=getScrollParent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/getScrollParent.ts"],"names":[],"mappings":"AAAA;;;;AAIG;AACH,OAAO,MAAM,aAAa,GAAI,IAAD,IAAmC;AAC9D,MAAI,IAAI,CAAC,QAAL,KAAkB,MAAtB,EAA8B;AAC5B,WAAO,IAAP;AACD,GAH6D,CAI9D;;;AACA,SAAO,IAAI,CAAC,UAAL,IAAoB,IAAY,CAAC,IAAxC;AACD,CANM;AAQP;;;;AAIG;;AACH,MAAM,wBAAwB,GAAI,IAAD,IAAoD;;;AACnF,MAAI,IAAI,CAAC,QAAL,KAAkB,CAAtB,EAAyB;AACvB,WAAO,EAAP;AACD;;AAED,QAAM,MAAM,GAAG,CAAA,EAAA,GAAA,IAAI,CAAC,aAAL,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,WAAnC;AACA,SAAO,MAAO,CAAC,gBAAR,CAAyB,IAAzB,EAA+B,IAA/B,CAAP;AACD,CAPD;AASA;;;;AAIG;;;AACH,OAAO,MAAM,eAAe,GAAI,IAAD,IAAqD;AAClF;AACA,QAAM,UAAU,GAAG,IAAI,IAAI,aAAa,CAAC,IAAD,CAAxC,CAFkF,CAGlF;;AACA,MAAI,CAAC,UAAL,EAAiB,OAAO,QAAQ,CAAC,IAAhB;;AAEjB,UAAQ,UAAU,CAAC,QAAnB;AACE,SAAK,MAAL;AACA,SAAK,MAAL;AACE,aAAO,UAAU,CAAC,aAAX,CAA0B,IAAjC;;AACF,SAAK,WAAL;AACE,aAAS,UAAmC,CAAC,IAA7C;AALJ,GANkF,CAclF;;;AACA,QAAM;AAAE,IAAA,QAAF;AAAY,IAAA,SAAZ;AAAuB,IAAA;AAAvB,MAAqC,wBAAwB,CAAC,UAAD,CAAnE;;AACA,MAAI,wBAAwB,IAAxB,CAA6B,QAAS,GAAG,SAAZ,GAAyB,SAAtD,CAAJ,EAAsE;AACpE,WAAO,UAAP;AACD;;AAED,SAAO,eAAe,CAAC,UAAD,CAAtB;AACD,CArBM","sourcesContent":["/**\n * Returns the parent node or the host of the node argument.\n * @param node - DOM node.\n * @returns - parent DOM node.\n */\nexport const getParentNode = (node: HTMLElement): HTMLElement => {\n if (node.nodeName === 'HTML') {\n return node;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return node.parentNode || (node as any).host;\n};\n\n/**\n * Returns CSS styles of the given node.\n * @param node - DOM node.\n * @returns - CSS styles.\n */\nconst getStyleComputedProperty = (node: HTMLElement): Partial<CSSStyleDeclaration> => {\n if (node.nodeType !== 1) {\n return {};\n }\n\n const window = node.ownerDocument?.defaultView;\n return window!.getComputedStyle(node, null);\n};\n\n/**\n * Returns the first scrollable parent of the given element.\n * @param node - DOM node.\n * @returns - the first scrollable parent.\n */\nexport const getScrollParent = (node: Document | HTMLElement | null): HTMLElement => {\n // Return body, `getScroll` will take care to get the correct `scrollTop` from it\n const parentNode = node && getParentNode(node as HTMLElement);\n // eslint-disable-next-line\n if (!parentNode) return document.body;\n\n switch (parentNode.nodeName) {\n case 'HTML':\n case 'BODY':\n return parentNode.ownerDocument!.body;\n case '#document':\n return ((parentNode as unknown) as Document).body;\n }\n\n // If any of the overflow props is defined for the node then we return it as the parent\n const { overflow, overflowX, overflowY } = getStyleComputedProperty(parentNode);\n if (/(auto|scroll|overlay)/.test(overflow! + overflowY! + overflowX)) {\n return parentNode;\n }\n\n return getScrollParent(parentNode);\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,8 @@
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';
@@ -0,0 +1,9 @@
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';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './getBasePlacement';\nexport * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './positioningHelper';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\n"]}
@@ -0,0 +1,10 @@
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;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
3
+ * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
4
+ *
5
+ * @param userOffset - The offset provided by the user
6
+ * @param arrowHeight - The height of the arrow in px
7
+ * @returns User offset augmented with arrow height
8
+ */
9
+ export function mergeArrowOffset(userOffset, arrowHeight) {
10
+ let offsetWithArrow = userOffset;
11
+
12
+ if (!userOffset) {
13
+ return [0, arrowHeight];
14
+ }
15
+
16
+ if (Array.isArray(offsetWithArrow)) {
17
+ setArrowOffset(offsetWithArrow, arrowHeight);
18
+ return offsetWithArrow;
19
+ }
20
+
21
+ if (typeof offsetWithArrow === 'function') {
22
+ const userOffsetFn = offsetWithArrow;
23
+
24
+ offsetWithArrow = offsetParams => {
25
+ const offset = userOffsetFn(offsetParams);
26
+ setArrowOffset(offset, arrowHeight);
27
+ return offset;
28
+ };
29
+ } // This should never happen
30
+
31
+
32
+ return [0, 0];
33
+ }
34
+
35
+ const setArrowOffset = (offset, arrowHeight) => {
36
+ if (offset[1] !== null && offset[1] !== undefined) {
37
+ offset[1] += arrowHeight;
38
+ } else {
39
+ offset[1] = arrowHeight;
40
+ }
41
+ };
42
+ //# sourceMappingURL=mergeArrowOffset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/mergeArrowOffset.ts"],"names":[],"mappings":"AAEA;;;;;;;AAOG;AACH,OAAM,SAAU,gBAAV,CAA2B,UAA3B,EAAkE,WAAlE,EAAqF;AACzF,MAAI,eAAe,GAAG,UAAtB;;AACA,MAAI,CAAC,UAAL,EAAiB;AACf,WAAO,CAAC,CAAD,EAAI,WAAJ,CAAP;AACD;;AAED,MAAI,KAAK,CAAC,OAAN,CAAc,eAAd,CAAJ,EAAoC;AAClC,IAAA,cAAc,CAAC,eAAD,EAAkB,WAAlB,CAAd;AACA,WAAO,eAAP;AACD;;AAED,MAAI,OAAO,eAAP,KAA2B,UAA/B,EAA2C;AACzC,UAAM,YAAY,GAAG,eAArB;;AACA,IAAA,eAAe,GAAG,YAAY,IAAG;AAC/B,YAAM,MAAM,GAAG,YAAY,CAAC,YAAD,CAA3B;AACA,MAAA,cAAc,CAAC,MAAD,EAAS,WAAT,CAAd;AACA,aAAO,MAAP;AACD,KAJD;AAKD,GAlBwF,CAoBzF;;;AACA,SAAO,CAAC,CAAD,EAAI,CAAJ,CAAP;AACD;;AAED,MAAM,cAAc,GAAG,CAAC,MAAD,EAAiE,WAAjE,KAAwF;AAC7G,MAAI,MAAM,CAAC,CAAD,CAAN,KAAc,IAAd,IAAsB,MAAM,CAAC,CAAD,CAAN,KAAc,SAAxC,EAAmD;AACjD,IAAA,MAAM,CAAC,CAAD,CAAN,IAAa,WAAb;AACD,GAFD,MAEO;AACL,IAAA,MAAM,CAAC,CAAD,CAAN,GAAY,WAAZ;AACD;AACF,CAND","sourcesContent":["import type { Offset } from '../types';\n\n/**\n * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the\n * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset\n *\n * @param userOffset - The offset provided by the user\n * @param arrowHeight - The height of the arrow in px\n * @returns User offset augmented with arrow height\n */\nexport function mergeArrowOffset(userOffset: Offset | undefined | null, arrowHeight: number): Offset {\n let offsetWithArrow = userOffset;\n if (!userOffset) {\n return [0, arrowHeight];\n }\n\n if (Array.isArray(offsetWithArrow)) {\n setArrowOffset(offsetWithArrow, arrowHeight);\n return offsetWithArrow;\n }\n\n if (typeof offsetWithArrow === 'function') {\n const userOffsetFn = offsetWithArrow;\n offsetWithArrow = offsetParams => {\n const offset = userOffsetFn(offsetParams);\n setArrowOffset(offset, arrowHeight);\n return offset;\n };\n }\n\n // This should never happen\n return [0, 0] as never;\n}\n\nconst setArrowOffset = (offset: [number | null | undefined, number | null | undefined], arrowHeight: number) => {\n if (offset[1] !== null && offset[1] !== undefined) {\n offset[1] += arrowHeight;\n } else {\n offset[1] = arrowHeight;\n }\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,7 @@
1
+ import * as PopperJs from '@popperjs/core';
2
+ import type { Alignment, Offset, Position } from '../types';
3
+ /**
4
+ * @see positioninHelper.test.ts for expected placement values
5
+ */
6
+ export declare const getPlacement: (align?: Alignment | undefined, position?: Position | undefined, rtl?: boolean | undefined) => PopperJs.Placement;
7
+ export declare const applyRtlToOffset: (offset: Offset | undefined) => Offset | undefined;
@@ -0,0 +1,49 @@
1
+ const getPositionMap = rtl => ({
2
+ above: 'top',
3
+ below: 'bottom',
4
+ before: rtl ? 'right' : 'left',
5
+ after: rtl ? 'left' : 'right'
6
+ });
7
+
8
+ const getAlignmentMap = rtl => ({
9
+ start: rtl ? 'end' : 'start',
10
+ end: rtl ? 'start' : 'end',
11
+ top: 'start',
12
+ bottom: 'end',
13
+ center: ''
14
+ });
15
+
16
+ const shouldAlignToCenter = (p, a) => {
17
+ const positionedVertically = p === 'above' || p === 'below';
18
+ const alignedVertically = a === 'top' || a === 'bottom';
19
+ return positionedVertically && alignedVertically || !positionedVertically && !alignedVertically;
20
+ };
21
+ /**
22
+ * @see positioninHelper.test.ts for expected placement values
23
+ */
24
+
25
+
26
+ export const getPlacement = (align, position, rtl) => {
27
+ const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
28
+ const computedPosition = position && getPositionMap(rtl)[position];
29
+ const computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];
30
+
31
+ if (computedPosition && computedAlignmnent) {
32
+ return `${computedPosition}-${computedAlignmnent}`;
33
+ }
34
+
35
+ return computedPosition || 'auto';
36
+ };
37
+ export const applyRtlToOffset = offset => {
38
+ if (typeof offset === 'undefined') {
39
+ return undefined;
40
+ }
41
+
42
+ if (Array.isArray(offset)) {
43
+ offset[0] = offset[0] * -1;
44
+ return offset;
45
+ }
46
+
47
+ return param => applyRtlToOffset(offset(param));
48
+ };
49
+ //# sourceMappingURL=positioningHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/positioningHelper.ts"],"names":[],"mappings":"AAMA,MAAM,cAAc,GAAI,GAAD,KAAyD;AAC9E,EAAA,KAAK,EAAE,KADuE;AAE9E,EAAA,KAAK,EAAE,QAFuE;AAG9E,EAAA,MAAM,EAAE,GAAG,GAAG,OAAH,GAAa,MAHsD;AAI9E,EAAA,KAAK,EAAE,GAAG,GAAG,MAAH,GAAY;AAJwD,CAAzD,CAAvB;;AAOA,MAAM,eAAe,GAAI,GAAD,KAAuD;AAC7E,EAAA,KAAK,EAAE,GAAG,GAAG,KAAH,GAAW,OADwD;AAE7E,EAAA,GAAG,EAAE,GAAG,GAAG,OAAH,GAAa,KAFwD;AAG7E,EAAA,GAAG,EAAE,OAHwE;AAI7E,EAAA,MAAM,EAAE,KAJqE;AAK7E,EAAA,MAAM,EAAE;AALqE,CAAvD,CAAxB;;AAQA,MAAM,mBAAmB,GAAG,CAAC,CAAD,EAAe,CAAf,KAAyC;AACnE,QAAM,oBAAoB,GAAG,CAAC,KAAK,OAAN,IAAiB,CAAC,KAAK,OAApD;AACA,QAAM,iBAAiB,GAAG,CAAC,KAAK,KAAN,IAAe,CAAC,KAAK,QAA/C;AAEA,SAAQ,oBAAoB,IAAI,iBAAzB,IAAgD,CAAC,oBAAD,IAAyB,CAAC,iBAAjF;AACD,CALD;AAOA;;AAEG;;;AACH,OAAO,MAAM,YAAY,GAAG,CAAC,KAAD,EAAoB,QAApB,EAAyC,GAAzC,KAA8E;AACxG,QAAM,SAAS,GAAG,mBAAmB,CAAC,QAAD,EAAW,KAAX,CAAnB,GAAuC,QAAvC,GAAkD,KAApE;AAEA,QAAM,gBAAgB,GAAG,QAAQ,IAAI,cAAc,CAAC,GAAD,CAAd,CAAoB,QAApB,CAArC;AACA,QAAM,kBAAkB,GAAG,SAAS,IAAI,eAAe,CAAC,GAAD,CAAf,CAAqB,SAArB,CAAxC;;AAEA,MAAI,gBAAgB,IAAI,kBAAxB,EAA4C;AAC1C,WAAO,GAAG,gBAAgB,IAAI,kBAAkB,EAAhD;AACD;;AAED,SAAO,gBAAgB,IAAK,MAA5B;AACD,CAXM;AAaP,OAAO,MAAM,gBAAgB,GAAI,MAAD,IAAmD;AACjF,MAAI,OAAO,MAAP,KAAkB,WAAtB,EAAmC;AACjC,WAAO,SAAP;AACD;;AAED,MAAI,KAAK,CAAC,OAAN,CAAc,MAAd,CAAJ,EAA2B;AACzB,IAAA,MAAM,CAAC,CAAD,CAAN,GAAY,MAAM,CAAC,CAAD,CAAN,GAAa,CAAC,CAA1B;AAEA,WAAO,MAAP;AACD;;AAED,SAAS,KAAD,IAAgC,gBAAgB,CAAC,MAAM,CAAC,KAAD,CAAP,CAAxD;AACD,CAZM","sourcesContent":["import * as PopperJs from '@popperjs/core';\nimport type { Alignment, Offset, OffsetFunction, OffsetFunctionParam, Position } from '../types';\n\ntype PlacementPosition = 'top' | 'bottom' | 'left' | 'right';\ntype PlacementAlign = 'start' | 'end' | ''; // '' represents center\n\nconst getPositionMap = (rtl?: boolean): Record<Position, PlacementPosition> => ({\n above: 'top',\n below: 'bottom',\n before: rtl ? 'right' : 'left',\n after: rtl ? 'left' : 'right',\n});\n\nconst getAlignmentMap = (rtl?: boolean): Record<Alignment, PlacementAlign> => ({\n start: rtl ? 'end' : 'start',\n end: rtl ? 'start' : 'end',\n top: 'start',\n bottom: 'end',\n center: '',\n});\n\nconst shouldAlignToCenter = (p?: Position, a?: Alignment): boolean => {\n const positionedVertically = p === 'above' || p === 'below';\n const alignedVertically = a === 'top' || a === 'bottom';\n\n return (positionedVertically && alignedVertically) || (!positionedVertically && !alignedVertically);\n};\n\n/**\n * @see positioninHelper.test.ts for expected placement values\n */\nexport const getPlacement = (align?: Alignment, position?: Position, rtl?: boolean): PopperJs.Placement => {\n const alignment = shouldAlignToCenter(position, align) ? 'center' : align;\n\n const computedPosition = position && getPositionMap(rtl)[position];\n const computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];\n\n if (computedPosition && computedAlignmnent) {\n return `${computedPosition}-${computedAlignmnent}` as PopperJs.Placement;\n }\n\n return computedPosition || ('auto' as PopperJs.Placement);\n};\n\nexport const applyRtlToOffset = (offset: Offset | undefined): Offset | undefined => {\n if (typeof offset === 'undefined') {\n return undefined;\n }\n\n if (Array.isArray(offset)) {\n offset[0] = offset[0]! * -1;\n\n return offset;\n }\n\n return ((param: OffsetFunctionParam) => applyRtlToOffset(offset(param))) as OffsetFunction;\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,2 @@
1
+ import type { PositioningShorthand, PositioningProps } from '../types';
2
+ export declare function resolvePositioningShorthand(shorthand: PositioningShorthand | undefined | null): Readonly<PositioningProps>;
@@ -0,0 +1,63 @@
1
+ // Look up table for shorthand to avoid parsing strings
2
+ const shorthandLookup = {
3
+ above: {
4
+ position: 'above',
5
+ align: 'center'
6
+ },
7
+ 'above-start': {
8
+ position: 'above',
9
+ align: 'start'
10
+ },
11
+ 'above-end': {
12
+ position: 'above',
13
+ align: 'end'
14
+ },
15
+ below: {
16
+ position: 'below',
17
+ align: 'center'
18
+ },
19
+ 'below-start': {
20
+ position: 'below',
21
+ align: 'start'
22
+ },
23
+ 'below-end': {
24
+ position: 'below',
25
+ align: 'end'
26
+ },
27
+ before: {
28
+ position: 'before',
29
+ align: 'center'
30
+ },
31
+ 'before-top': {
32
+ position: 'before',
33
+ align: 'top'
34
+ },
35
+ 'before-bottom': {
36
+ position: 'before',
37
+ align: 'bottom'
38
+ },
39
+ after: {
40
+ position: 'after',
41
+ align: 'center'
42
+ },
43
+ 'after-top': {
44
+ position: 'after',
45
+ align: 'top'
46
+ },
47
+ 'after-bottom': {
48
+ position: 'after',
49
+ align: 'bottom'
50
+ }
51
+ };
52
+ export function resolvePositioningShorthand(shorthand) {
53
+ if (shorthand === undefined || shorthand === null) {
54
+ return {};
55
+ }
56
+
57
+ if (typeof shorthand === 'string') {
58
+ return shorthandLookup[shorthand];
59
+ }
60
+
61
+ return shorthand;
62
+ }
63
+ //# sourceMappingURL=resolvePositioningShorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/resolvePositioningShorthand.ts"],"names":[],"mappings":"AAEA;AACA,MAAM,eAAe,GAAoF;AACvG,EAAA,KAAK,EAAE;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GADgG;AAEvG,iBAAe;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAFwF;AAGvG,eAAa;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAH0F;AAIvG,EAAA,KAAK,EAAE;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAJgG;AAKvG,iBAAe;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GALwF;AAMvG,eAAa;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAN0F;AAOvG,EAAA,MAAM,EAAE;AAAE,IAAA,QAAQ,EAAE,QAAZ;AAAsB,IAAA,KAAK,EAAE;AAA7B,GAP+F;AAQvG,gBAAc;AAAE,IAAA,QAAQ,EAAE,QAAZ;AAAsB,IAAA,KAAK,EAAE;AAA7B,GARyF;AASvG,mBAAiB;AAAE,IAAA,QAAQ,EAAE,QAAZ;AAAsB,IAAA,KAAK,EAAE;AAA7B,GATsF;AAUvG,EAAA,KAAK,EAAE;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAVgG;AAWvG,eAAa;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAX0F;AAYvG,kBAAgB;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B;AAZuF,CAAzG;AAeA,OAAM,SAAU,2BAAV,CACJ,SADI,EAC8C;AAElD,MAAI,SAAS,KAAK,SAAd,IAA2B,SAAS,KAAK,IAA7C,EAAmD;AACjD,WAAO,EAAP;AACD;;AAED,MAAI,OAAO,SAAP,KAAqB,QAAzB,EAAmC;AACjC,WAAO,eAAe,CAAC,SAAD,CAAtB;AACD;;AAED,SAAO,SAAP;AACD","sourcesContent":["import type { PositioningShorthand, PositioningShorthandValue, PositioningProps } from '../types';\n\n// Look up table for shorthand to avoid parsing strings\nconst shorthandLookup: Record<PositioningShorthandValue, Pick<PositioningProps, 'position' | 'align'>> = {\n above: { position: 'above', align: 'center' },\n 'above-start': { position: 'above', align: 'start' },\n 'above-end': { position: 'above', align: 'end' },\n below: { position: 'below', align: 'center' },\n 'below-start': { position: 'below', align: 'start' },\n 'below-end': { position: 'below', align: 'end' },\n before: { position: 'before', align: 'center' },\n 'before-top': { position: 'before', align: 'top' },\n 'before-bottom': { position: 'before', align: 'bottom' },\n after: { position: 'after', align: 'center' },\n 'after-top': { position: 'after', align: 'top' },\n 'after-bottom': { position: 'after', align: 'bottom' },\n};\n\nexport function resolvePositioningShorthand(\n shorthand: PositioningShorthand | undefined | null,\n): Readonly<PositioningProps> {\n if (shorthand === undefined || shorthand === null) {\n return {};\n }\n\n if (typeof shorthand === 'string') {\n return shorthandLookup[shorthand];\n }\n\n return shorthand as Readonly<PositioningProps>;\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,19 @@
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>;
@@ -0,0 +1,57 @@
1
+ import * as React from 'react';
2
+ import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
3
+ /**
4
+ * Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content
5
+ * changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via
6
+ * React.useState(), but it will cause re-renders always.
7
+ *
8
+ * https://reactjs.org/docs/hooks-reference.html#useref
9
+ * https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
10
+ *
11
+ * @param initialValue - initial ref value
12
+ * @param callback - a callback to run when value changes
13
+ * @param skipInitialResolve - a flag to skip an initial ref report
14
+ *
15
+ * @example
16
+ * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
17
+ * ref.current = 1;
18
+ * // prints 0 -> 1
19
+ */
20
+
21
+ export function useCallbackRef(initialValue, callback, skipInitialResolve) {
22
+ const isFirst = React.useRef(true);
23
+ const [ref] = React.useState(() => ({
24
+ // value
25
+ value: initialValue,
26
+ // last callback
27
+ callback,
28
+ // "memoized" public interface
29
+ facade: {
30
+ get current() {
31
+ return ref.value;
32
+ },
33
+
34
+ set current(value) {
35
+ const last = ref.value;
36
+
37
+ if (last !== value) {
38
+ ref.value = value;
39
+
40
+ if (skipInitialResolve && isFirst.current) {
41
+ return;
42
+ }
43
+
44
+ ref.callback(value, last);
45
+ }
46
+ }
47
+
48
+ }
49
+ }));
50
+ useIsomorphicLayoutEffect(() => {
51
+ isFirst.current = false;
52
+ }, []); // update callback
53
+
54
+ ref.callback = callback;
55
+ return ref.facade;
56
+ }
57
+ //# sourceMappingURL=useCallbackRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/useCallbackRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,yBAAT,QAA0C,2BAA1C;AAEA;;;;;;;;;;;;;;;;AAgBG;;AACH,OAAM,SAAU,cAAV,CACJ,YADI,EAEJ,QAFI,EAGJ,kBAHI,EAGwB;AAE5B,QAAM,OAAO,GAAG,KAAK,CAAC,MAAN,CAAa,IAAb,CAAhB;AACA,QAAM,CAAC,GAAD,IAAQ,KAAK,CAAC,QAAN,CAAe,OAAO;AAClC;AACA,IAAA,KAAK,EAAE,YAF2B;AAGlC;AACA,IAAA,QAJkC;AAKlC;AACA,IAAA,MAAM,EAAE;AACN,UAAI,OAAJ,GAAW;AACT,eAAO,GAAG,CAAC,KAAX;AACD,OAHK;;AAIN,UAAI,OAAJ,CAAY,KAAZ,EAAiB;AACf,cAAM,IAAI,GAAG,GAAG,CAAC,KAAjB;;AAEA,YAAI,IAAI,KAAK,KAAb,EAAoB;AAClB,UAAA,GAAG,CAAC,KAAJ,GAAY,KAAZ;;AAEA,cAAI,kBAAkB,IAAI,OAAO,CAAC,OAAlC,EAA2C;AACzC;AACD;;AAED,UAAA,GAAG,CAAC,QAAJ,CAAa,KAAb,EAAoB,IAApB;AACD;AACF;;AAhBK;AAN0B,GAAP,CAAf,CAAd;AA0BA,EAAA,yBAAyB,CAAC,MAAK;AAC7B,IAAA,OAAO,CAAC,OAAR,GAAkB,KAAlB;AACD,GAFwB,EAEtB,EAFsB,CAAzB,CA7B4B,CAiC5B;;AACA,EAAA,GAAG,CAAC,QAAJ,GAAe,QAAf;AAEA,SAAO,GAAG,CAAC,MAAX;AACD","sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\n\n/**\n * Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content\n * changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via\n * React.useState(), but it will cause re-renders always.\n *\n * https://reactjs.org/docs/hooks-reference.html#useref\n * https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref\n *\n * @param initialValue - initial ref value\n * @param callback - a callback to run when value changes\n * @param skipInitialResolve - a flag to skip an initial ref report\n *\n * @example\n * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);\n * ref.current = 1;\n * // prints 0 -> 1\n */\nexport function useCallbackRef<T>(\n initialValue: T | null,\n callback: (newValue: T | null, lastValue: T | null) => void,\n skipInitialResolve?: boolean,\n): React.MutableRefObject<T | null> {\n const isFirst = React.useRef(true);\n const [ref] = React.useState(() => ({\n // value\n value: initialValue,\n // last callback\n callback,\n // \"memoized\" public interface\n facade: {\n get current() {\n return ref.value;\n },\n set current(value) {\n const last = ref.value;\n\n if (last !== value) {\n ref.value = value;\n\n if (skipInitialResolve && isFirst.current) {\n return;\n }\n\n ref.callback(value, last);\n }\n },\n },\n }));\n\n useIsomorphicLayoutEffect(() => {\n isFirst.current = false;\n }, []);\n\n // update callback\n ref.callback = callback;\n\n return ref.facade;\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,64 @@
1
+ import type { GriffelStyle } from '@griffel/react';
2
+ /**
3
+ * Options parameter for the createArrowStyles function
4
+ */
5
+ export declare type CreateArrowStylesOptions = {
6
+ /**
7
+ * The height of the arrow from the base to the tip, in px. The base width of the arrow is always twice its height.
8
+ *
9
+ * This can be undefined to leave out the arrow size styles. You must then add styles created by
10
+ * createArrowHeightStyles to set the arrow's size correctly. This can be useful if the arrow can be different sizes.
11
+ */
12
+ arrowHeight: number | undefined;
13
+ /**
14
+ * The borderWidth of the arrow. Should be the same borderWidth as the parent element.
15
+ *
16
+ * @defaultvalue 1px
17
+ */
18
+ borderWidth?: GriffelStyle['borderBottomWidth'];
19
+ /**
20
+ * The borderStyle for the arrow. Should be the same borderStyle as the parent element.
21
+ *
22
+ * @defaultvalue solid
23
+ */
24
+ borderStyle?: GriffelStyle['borderBottomStyle'];
25
+ /**
26
+ * The borderColor of the arrow. Should be the same borderColor as the parent element.
27
+ *
28
+ * @defaultvalue tokens.colorTransparentStroke
29
+ */
30
+ borderColor?: GriffelStyle['borderBottomColor'];
31
+ };
32
+ /**
33
+ * Helper that creates a makeStyles rule for an arrow element.
34
+ * For runtime arrow size toggling simply create extra classnames to apply to the arrow element
35
+ *
36
+ * ```ts
37
+ * makeStyles({
38
+ * arrowWithSize: createArrowStyles({ arrowHeight: 6 }),
39
+ *
40
+ * arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),
41
+ * mediumArrow: createArrowHeightStyles(4),
42
+ * smallArrow: createArrowHeightStyles(2),
43
+ * })
44
+ * ...
45
+ *
46
+ * state.arrowWithSize.className = styles.arrowWithSize;
47
+ * state.arrowWithoutSize.className = mergeClasses(
48
+ * styles.arrowWithoutSize,
49
+ * state.smallArrow && styles.smallArrow,
50
+ * state.mediumArrow && styles.mediumArrow,
51
+ * )
52
+ * ```
53
+ */
54
+ export declare function createArrowStyles(options: CreateArrowStylesOptions): GriffelStyle;
55
+ /**
56
+ * Creates CSS styles to size the arrow created by createArrowStyles to the given height.
57
+ *
58
+ * Use this when you need to create classes for several different arrow sizes. If you only need a
59
+ * constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.
60
+ */
61
+ export declare function createArrowHeightStyles(arrowHeight: number): {
62
+ width: string;
63
+ height: string;
64
+ };