@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,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getReactFiberFromNode = void 0;
7
+ var WorkTag;
8
+
9
+ (function (WorkTag) {
10
+ WorkTag[WorkTag["FunctionComponent"] = 0] = "FunctionComponent";
11
+ WorkTag[WorkTag["ClassComponent"] = 1] = "ClassComponent";
12
+ WorkTag[WorkTag["IndeterminateComponent"] = 2] = "IndeterminateComponent";
13
+ WorkTag[WorkTag["HostRoot"] = 3] = "HostRoot";
14
+ WorkTag[WorkTag["HostPortal"] = 4] = "HostPortal";
15
+ WorkTag[WorkTag["HostComponent"] = 5] = "HostComponent";
16
+ WorkTag[WorkTag["HostText"] = 6] = "HostText";
17
+ WorkTag[WorkTag["Fragment"] = 7] = "Fragment";
18
+ WorkTag[WorkTag["Mode"] = 8] = "Mode";
19
+ WorkTag[WorkTag["ContextConsumer"] = 9] = "ContextConsumer";
20
+ WorkTag[WorkTag["ContextProvider"] = 10] = "ContextProvider";
21
+ WorkTag[WorkTag["ForwardRef"] = 11] = "ForwardRef";
22
+ WorkTag[WorkTag["Profiler"] = 12] = "Profiler";
23
+ WorkTag[WorkTag["SuspenseComponent"] = 13] = "SuspenseComponent";
24
+ WorkTag[WorkTag["MemoComponent"] = 14] = "MemoComponent";
25
+ WorkTag[WorkTag["SimpleMemoComponent"] = 15] = "SimpleMemoComponent";
26
+ WorkTag[WorkTag["LazyComponent"] = 16] = "LazyComponent";
27
+ WorkTag[WorkTag["IncompleteClassComponent"] = 17] = "IncompleteClassComponent";
28
+ WorkTag[WorkTag["DehydratedFragment"] = 18] = "DehydratedFragment";
29
+ WorkTag[WorkTag["SuspenseListComponent"] = 19] = "SuspenseListComponent";
30
+ WorkTag[WorkTag["FundamentalComponent"] = 20] = "FundamentalComponent";
31
+ WorkTag[WorkTag["ScopeComponent"] = 21] = "ScopeComponent";
32
+ })(WorkTag || (WorkTag = {}));
33
+
34
+ function getReactFiberFromNode(elm) {
35
+ if (!elm) {
36
+ return null;
37
+ }
38
+
39
+ for (const k in elm) {
40
+ // React 16 uses "__reactInternalInstance$" prefix
41
+ // React 17 uses "__reactFiber$" prefix
42
+ // https://github.com/facebook/react/pull/18377
43
+ if (k.indexOf('__reactInternalInstance$') === 0 || k.indexOf('__reactFiber$') === 0) {
44
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
45
+ // @ts-ignore
46
+ return elm[k];
47
+ }
48
+ }
49
+
50
+ throw new Error('getReactFiber(): Failed to find a React Fiber on a node');
51
+ }
52
+
53
+ exports.getReactFiberFromNode = getReactFiberFromNode;
54
+ //# 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,SAAgB,qBAAhB,CAAsC,GAAtC,EAA2D;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;;AAjBD,OAAA,CAAA,qBAAA,GAAA,qBAAA","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,76 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getScrollParent = exports.getParentNode = void 0;
7
+ /**
8
+ * Returns the parent node or the host of the node argument.
9
+ * @param node - DOM node.
10
+ * @returns - parent DOM node.
11
+ */
12
+
13
+ const getParentNode = node => {
14
+ if (node.nodeName === 'HTML') {
15
+ return node;
16
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+
18
+
19
+ return node.parentNode || node.host;
20
+ };
21
+
22
+ exports.getParentNode = getParentNode;
23
+ /**
24
+ * Returns CSS styles of the given node.
25
+ * @param node - DOM node.
26
+ * @returns - CSS styles.
27
+ */
28
+
29
+ const getStyleComputedProperty = node => {
30
+ var _a;
31
+
32
+ if (node.nodeType !== 1) {
33
+ return {};
34
+ }
35
+
36
+ const window = (_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
37
+ return window.getComputedStyle(node, null);
38
+ };
39
+ /**
40
+ * Returns the first scrollable parent of the given element.
41
+ * @param node - DOM node.
42
+ * @returns - the first scrollable parent.
43
+ */
44
+
45
+
46
+ const getScrollParent = node => {
47
+ // Return body, `getScroll` will take care to get the correct `scrollTop` from it
48
+ const parentNode = node && exports.getParentNode(node); // eslint-disable-next-line
49
+
50
+ if (!parentNode) return document.body;
51
+
52
+ switch (parentNode.nodeName) {
53
+ case 'HTML':
54
+ case 'BODY':
55
+ return parentNode.ownerDocument.body;
56
+
57
+ case '#document':
58
+ return parentNode.body;
59
+ } // If any of the overflow props is defined for the node then we return it as the parent
60
+
61
+
62
+ const {
63
+ overflow,
64
+ overflowX,
65
+ overflowY
66
+ } = getStyleComputedProperty(parentNode);
67
+
68
+ if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
69
+ return parentNode;
70
+ }
71
+
72
+ return exports.getScrollParent(parentNode);
73
+ };
74
+
75
+ exports.getScrollParent = getScrollParent;
76
+ //# sourceMappingURL=getScrollParent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/getScrollParent.ts"],"names":[],"mappings":";;;;;;AAAA;;;;AAIG;;AACI,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;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb;AAQb;;;;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;;;AACI,MAAM,eAAe,GAAI,IAAD,IAAqD;AAClF;AACA,QAAM,UAAU,GAAG,IAAI,IAAI,OAAA,CAAA,aAAA,CAAc,IAAd,CAA3B,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,OAAA,CAAA,eAAA,CAAgB,UAAhB,CAAP;AACD,CArBM;;AAAM,OAAA,CAAA,eAAA,GAAe,eAAf","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,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./getBasePlacement"), exports);
10
+
11
+ tslib_1.__exportStar(require("./getBoundary"), exports);
12
+
13
+ tslib_1.__exportStar(require("./getReactFiberFromNode"), exports);
14
+
15
+ tslib_1.__exportStar(require("./getScrollParent"), exports);
16
+
17
+ tslib_1.__exportStar(require("./mergeArrowOffset"), exports);
18
+
19
+ tslib_1.__exportStar(require("./positioningHelper"), exports);
20
+
21
+ tslib_1.__exportStar(require("./resolvePositioningShorthand"), exports);
22
+
23
+ tslib_1.__exportStar(require("./useCallbackRef"), exports);
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,+BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA","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"],"sourceRoot":"../src/"}
@@ -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,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mergeArrowOffset = void 0;
7
+ /**
8
+ * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
9
+ * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
10
+ *
11
+ * @param userOffset - The offset provided by the user
12
+ * @param arrowHeight - The height of the arrow in px
13
+ * @returns User offset augmented with arrow height
14
+ */
15
+
16
+ function mergeArrowOffset(userOffset, arrowHeight) {
17
+ let offsetWithArrow = userOffset;
18
+
19
+ if (!userOffset) {
20
+ return [0, arrowHeight];
21
+ }
22
+
23
+ if (Array.isArray(offsetWithArrow)) {
24
+ setArrowOffset(offsetWithArrow, arrowHeight);
25
+ return offsetWithArrow;
26
+ }
27
+
28
+ if (typeof offsetWithArrow === 'function') {
29
+ const userOffsetFn = offsetWithArrow;
30
+
31
+ offsetWithArrow = offsetParams => {
32
+ const offset = userOffsetFn(offsetParams);
33
+ setArrowOffset(offset, arrowHeight);
34
+ return offset;
35
+ };
36
+ } // This should never happen
37
+
38
+
39
+ return [0, 0];
40
+ }
41
+
42
+ exports.mergeArrowOffset = mergeArrowOffset;
43
+
44
+ const setArrowOffset = (offset, arrowHeight) => {
45
+ if (offset[1] !== null && offset[1] !== undefined) {
46
+ offset[1] += arrowHeight;
47
+ } else {
48
+ offset[1] = arrowHeight;
49
+ }
50
+ };
51
+ //# sourceMappingURL=mergeArrowOffset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/mergeArrowOffset.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;;;AAOG;;AACH,SAAgB,gBAAhB,CAAiC,UAAjC,EAAwE,WAAxE,EAA2F;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;;AAtBD,OAAA,CAAA,gBAAA,GAAA,gBAAA;;AAwBA,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,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.applyRtlToOffset = exports.getPlacement = void 0;
7
+
8
+ const getPositionMap = rtl => ({
9
+ above: 'top',
10
+ below: 'bottom',
11
+ before: rtl ? 'right' : 'left',
12
+ after: rtl ? 'left' : 'right'
13
+ });
14
+
15
+ const getAlignmentMap = rtl => ({
16
+ start: rtl ? 'end' : 'start',
17
+ end: rtl ? 'start' : 'end',
18
+ top: 'start',
19
+ bottom: 'end',
20
+ center: ''
21
+ });
22
+
23
+ const shouldAlignToCenter = (p, a) => {
24
+ const positionedVertically = p === 'above' || p === 'below';
25
+ const alignedVertically = a === 'top' || a === 'bottom';
26
+ return positionedVertically && alignedVertically || !positionedVertically && !alignedVertically;
27
+ };
28
+ /**
29
+ * @see positioninHelper.test.ts for expected placement values
30
+ */
31
+
32
+
33
+ const getPlacement = (align, position, rtl) => {
34
+ const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
35
+ const computedPosition = position && getPositionMap(rtl)[position];
36
+ const computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];
37
+
38
+ if (computedPosition && computedAlignmnent) {
39
+ return `${computedPosition}-${computedAlignmnent}`;
40
+ }
41
+
42
+ return computedPosition || 'auto';
43
+ };
44
+
45
+ exports.getPlacement = getPlacement;
46
+
47
+ const applyRtlToOffset = offset => {
48
+ if (typeof offset === 'undefined') {
49
+ return undefined;
50
+ }
51
+
52
+ if (Array.isArray(offset)) {
53
+ offset[0] = offset[0] * -1;
54
+ return offset;
55
+ }
56
+
57
+ return param => exports.applyRtlToOffset(offset(param));
58
+ };
59
+
60
+ exports.applyRtlToOffset = applyRtlToOffset;
61
+ //# 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;;;AACI,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;;AAAM,OAAA,CAAA,YAAA,GAAY,YAAZ;;AAaN,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,OAAA,CAAA,gBAAA,CAAiB,MAAM,CAAC,KAAD,CAAvB,CAAxC;AACD,CAZM;;AAAM,OAAA,CAAA,gBAAA,GAAgB,gBAAhB","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,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolvePositioningShorthand = void 0; // Look up table for shorthand to avoid parsing strings
7
+
8
+ const shorthandLookup = {
9
+ above: {
10
+ position: 'above',
11
+ align: 'center'
12
+ },
13
+ 'above-start': {
14
+ position: 'above',
15
+ align: 'start'
16
+ },
17
+ 'above-end': {
18
+ position: 'above',
19
+ align: 'end'
20
+ },
21
+ below: {
22
+ position: 'below',
23
+ align: 'center'
24
+ },
25
+ 'below-start': {
26
+ position: 'below',
27
+ align: 'start'
28
+ },
29
+ 'below-end': {
30
+ position: 'below',
31
+ align: 'end'
32
+ },
33
+ before: {
34
+ position: 'before',
35
+ align: 'center'
36
+ },
37
+ 'before-top': {
38
+ position: 'before',
39
+ align: 'top'
40
+ },
41
+ 'before-bottom': {
42
+ position: 'before',
43
+ align: 'bottom'
44
+ },
45
+ after: {
46
+ position: 'after',
47
+ align: 'center'
48
+ },
49
+ 'after-top': {
50
+ position: 'after',
51
+ align: 'top'
52
+ },
53
+ 'after-bottom': {
54
+ position: 'after',
55
+ align: 'bottom'
56
+ }
57
+ };
58
+
59
+ function resolvePositioningShorthand(shorthand) {
60
+ if (shorthand === undefined || shorthand === null) {
61
+ return {};
62
+ }
63
+
64
+ if (typeof shorthand === 'string') {
65
+ return shorthandLookup[shorthand];
66
+ }
67
+
68
+ return shorthand;
69
+ }
70
+
71
+ exports.resolvePositioningShorthand = resolvePositioningShorthand;
72
+ //# sourceMappingURL=resolvePositioningShorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/resolvePositioningShorthand.ts"],"names":[],"mappings":";;;;;8CAEA;;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,SAAgB,2BAAhB,CACE,SADF,EACoD;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;;AAZD,OAAA,CAAA,2BAAA,GAAA,2BAAA","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,68 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useCallbackRef = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
+ /**
12
+ * Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content
13
+ * changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via
14
+ * React.useState(), but it will cause re-renders always.
15
+ *
16
+ * https://reactjs.org/docs/hooks-reference.html#useref
17
+ * https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
18
+ *
19
+ * @param initialValue - initial ref value
20
+ * @param callback - a callback to run when value changes
21
+ * @param skipInitialResolve - a flag to skip an initial ref report
22
+ *
23
+ * @example
24
+ * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
25
+ * ref.current = 1;
26
+ * // prints 0 -> 1
27
+ */
28
+
29
+
30
+ function useCallbackRef(initialValue, callback, skipInitialResolve) {
31
+ const isFirst = React.useRef(true);
32
+ const [ref] = React.useState(() => ({
33
+ // value
34
+ value: initialValue,
35
+ // last callback
36
+ callback,
37
+ // "memoized" public interface
38
+ facade: {
39
+ get current() {
40
+ return ref.value;
41
+ },
42
+
43
+ set current(value) {
44
+ const last = ref.value;
45
+
46
+ if (last !== value) {
47
+ ref.value = value;
48
+
49
+ if (skipInitialResolve && isFirst.current) {
50
+ return;
51
+ }
52
+
53
+ ref.callback(value, last);
54
+ }
55
+ }
56
+
57
+ }
58
+ }));
59
+ react_utilities_1.useIsomorphicLayoutEffect(() => {
60
+ isFirst.current = false;
61
+ }, []); // update callback
62
+
63
+ ref.callback = callback;
64
+ return ref.facade;
65
+ }
66
+
67
+ exports.useCallbackRef = useCallbackRef;
68
+ //# sourceMappingURL=useCallbackRef.js.map