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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. package/CHANGELOG.json +494 -10
  2. package/CHANGELOG.md +221 -71
  3. package/dist/index.d.ts +247 -0
  4. package/{lib → dist}/tsdoc-metadata.json +0 -0
  5. package/lib/createArrowStyles.js +87 -0
  6. package/lib/createArrowStyles.js.map +1 -0
  7. package/lib/createVirtualElementFromClick.js +19 -15
  8. package/lib/createVirtualElementFromClick.js.map +1 -1
  9. package/lib/index.js +4 -4
  10. package/lib/index.js.map +1 -1
  11. package/lib/isIntersectingModifier.js +26 -0
  12. package/lib/isIntersectingModifier.js.map +1 -0
  13. package/lib/types.js.map +1 -1
  14. package/lib/usePositioning.js +408 -0
  15. package/lib/usePositioning.js.map +1 -0
  16. package/lib/usePositioningMouseTarget.js +40 -0
  17. package/lib/usePositioningMouseTarget.js.map +1 -0
  18. package/lib/utils/fromPopperPlacement.js +40 -0
  19. package/lib/utils/fromPopperPlacement.js.map +1 -0
  20. package/lib/utils/getBoundary.js +15 -10
  21. package/lib/utils/getBoundary.js.map +1 -1
  22. package/lib/utils/getPopperOffset.js +44 -0
  23. package/lib/utils/getPopperOffset.js.map +1 -0
  24. package/lib/utils/getReactFiberFromNode.js +39 -35
  25. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  26. package/lib/utils/getScrollParent.js +46 -32
  27. package/lib/utils/getScrollParent.js.map +1 -1
  28. package/lib/utils/index.js +1 -1
  29. package/lib/utils/index.js.map +1 -1
  30. package/lib/utils/mergeArrowOffset.js +31 -25
  31. package/lib/utils/mergeArrowOffset.js.map +1 -1
  32. package/lib/utils/parsePopperPlacement.js +14 -0
  33. package/lib/utils/parsePopperPlacement.js.map +1 -0
  34. package/lib/utils/positioningHelper.js +42 -34
  35. package/lib/utils/positioningHelper.js.map +1 -1
  36. package/lib/utils/resolvePositioningShorthand.js +58 -20
  37. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  38. package/lib/utils/useCallbackRef.js +35 -29
  39. package/lib/utils/useCallbackRef.js.map +1 -1
  40. package/lib-commonjs/createArrowStyles.js +100 -0
  41. package/lib-commonjs/createArrowStyles.js.map +1 -0
  42. package/lib-commonjs/createVirtualElementFromClick.js +25 -16
  43. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  44. package/lib-commonjs/index.js +62 -10
  45. package/lib-commonjs/index.js.map +1 -1
  46. package/lib-commonjs/isIntersectingModifier.js +34 -0
  47. package/lib-commonjs/isIntersectingModifier.js.map +1 -0
  48. package/lib-commonjs/types.js +4 -1
  49. package/lib-commonjs/types.js.map +1 -1
  50. package/lib-commonjs/usePositioning.js +424 -0
  51. package/lib-commonjs/usePositioning.js.map +1 -0
  52. package/lib-commonjs/usePositioningMouseTarget.js +51 -0
  53. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -0
  54. package/lib-commonjs/utils/fromPopperPlacement.js +50 -0
  55. package/lib-commonjs/utils/fromPopperPlacement.js.map +1 -0
  56. package/lib-commonjs/utils/getBoundary.js +23 -12
  57. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  58. package/lib-commonjs/utils/getPopperOffset.js +54 -0
  59. package/lib-commonjs/utils/getPopperOffset.js.map +1 -0
  60. package/lib-commonjs/utils/getReactFiberFromNode.js +44 -36
  61. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  62. package/lib-commonjs/utils/getScrollParent.js +53 -33
  63. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  64. package/lib-commonjs/utils/index.js +15 -3
  65. package/lib-commonjs/utils/index.js.map +1 -1
  66. package/lib-commonjs/utils/mergeArrowOffset.js +37 -26
  67. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  68. package/lib-commonjs/utils/parsePopperPlacement.js +23 -0
  69. package/lib-commonjs/utils/parsePopperPlacement.js.map +1 -0
  70. package/lib-commonjs/utils/positioningHelper.js +50 -35
  71. package/lib-commonjs/utils/positioningHelper.js.map +1 -1
  72. package/lib-commonjs/utils/resolvePositioningShorthand.js +66 -23
  73. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  74. package/lib-commonjs/utils/useCallbackRef.js +45 -32
  75. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  76. package/package.json +17 -14
  77. package/dist/react-positioning.d.ts +0 -143
  78. package/lib/createVirtualElementFromClick.d.ts +0 -6
  79. package/lib/index.d.ts +0 -5
  80. package/lib/types.d.ts +0 -68
  81. package/lib/usePopper.d.ts +0 -35
  82. package/lib/usePopper.js +0 -357
  83. package/lib/usePopper.js.map +0 -1
  84. package/lib/usePopperMouseTarget.d.ts +0 -11
  85. package/lib/usePopperMouseTarget.js +0 -34
  86. package/lib/usePopperMouseTarget.js.map +0 -1
  87. package/lib/utils/getBasePlacement.d.ts +0 -8
  88. package/lib/utils/getBasePlacement.js +0 -10
  89. package/lib/utils/getBasePlacement.js.map +0 -1
  90. package/lib/utils/getBoundary.d.ts +0 -6
  91. package/lib/utils/getReactFiberFromNode.d.ts +0 -109
  92. package/lib/utils/getScrollParent.d.ts +0 -12
  93. package/lib/utils/index.d.ts +0 -8
  94. package/lib/utils/mergeArrowOffset.d.ts +0 -10
  95. package/lib/utils/positioningHelper.d.ts +0 -7
  96. package/lib/utils/resolvePositioningShorthand.d.ts +0 -2
  97. package/lib/utils/useCallbackRef.d.ts +0 -19
  98. package/lib-commonjs/createVirtualElementFromClick.d.ts +0 -6
  99. package/lib-commonjs/index.d.ts +0 -5
  100. package/lib-commonjs/types.d.ts +0 -68
  101. package/lib-commonjs/usePopper.d.ts +0 -35
  102. package/lib-commonjs/usePopper.js +0 -361
  103. package/lib-commonjs/usePopper.js.map +0 -1
  104. package/lib-commonjs/usePopperMouseTarget.d.ts +0 -11
  105. package/lib-commonjs/usePopperMouseTarget.js +0 -38
  106. package/lib-commonjs/usePopperMouseTarget.js.map +0 -1
  107. package/lib-commonjs/utils/getBasePlacement.d.ts +0 -8
  108. package/lib-commonjs/utils/getBasePlacement.js +0 -14
  109. package/lib-commonjs/utils/getBasePlacement.js.map +0 -1
  110. package/lib-commonjs/utils/getBoundary.d.ts +0 -6
  111. package/lib-commonjs/utils/getReactFiberFromNode.d.ts +0 -109
  112. package/lib-commonjs/utils/getScrollParent.d.ts +0 -12
  113. package/lib-commonjs/utils/index.d.ts +0 -8
  114. package/lib-commonjs/utils/mergeArrowOffset.d.ts +0 -10
  115. package/lib-commonjs/utils/positioningHelper.d.ts +0 -7
  116. package/lib-commonjs/utils/resolvePositioningShorthand.d.ts +0 -2
  117. package/lib-commonjs/utils/useCallbackRef.d.ts +0 -19
@@ -1 +1 @@
1
- {"version":3,"file":"getBoundary.js","sourceRoot":"","sources":["../../src/utils/getBoundary.ts"],"names":[],"mappings":";;;AAEA,qDAAoD;AAGpD;;GAEG;AACH,SAAgB,WAAW,CAAC,OAA2B,EAAE,QAAmB;IAC1E,IAAI,QAAQ,KAAK,QAAQ,EAAE;QACzB,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAE,eAAe,CAAC;KAChD;IAED,IAAI,QAAQ,KAAK,cAAc,EAAE;QAC/B,IAAI,cAAc,GAA4B,iCAAe,CAAC,OAAO,CAAC,CAAC;QAEvE,IAAI,cAAc,CAAC,QAAQ,KAAK,MAAM,EAAE;YACtC,cAAc,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAE,eAAe,CAAC;SAC1D;QAED,OAAO,cAAc,CAAC;KACvB;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAhBD,kCAgBC"}
1
+ {"version":3,"sources":["utils/getBoundary.ts"],"names":[],"mappings":";;;;;;;AAEA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;AAGA;;AAEG;;;AACH,SAAgB,WAAhB,CAA4B,OAA5B,EAAyD,QAAzD,EAA4E;AAC1E,MAAI,QAAQ,KAAK,QAAjB,EAA2B;AACzB,WAAO,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,CAAwB,eAA/B;AACD;;AAED,MAAI,QAAQ,KAAK,cAAjB,EAAiC;AAC/B,QAAI,cAAc,GAA4B,iBAAA,CAAA,eAAA,CAAgB,OAAhB,CAA9C;;AAEA,QAAI,cAAc,CAAC,QAAf,KAA4B,MAAhC,EAAwC;AACtC,MAAA,cAAc,GAAG,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,CAAwB,eAAzC;AACD;;AAED,WAAO,cAAP;AACD;;AAED,SAAO,QAAP;AACD;;AAhBD,OAAA,CAAA,WAAA,GAAA,WAAA","sourcesContent":["import * as PopperJs from '@popperjs/core';\n\nimport { getScrollParent } from './getScrollParent';\nimport type { Boundary } from '../types';\n\n/**\n * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.\n */\nexport function getBoundary(element: HTMLElement | null, boundary?: Boundary): PopperJs.Boundary | undefined {\n if (boundary === 'window') {\n return element?.ownerDocument!.documentElement;\n }\n\n if (boundary === 'scrollParent') {\n let boundariesNode: HTMLElement | undefined = getScrollParent(element);\n\n if (boundariesNode.nodeName === 'BODY') {\n boundariesNode = element?.ownerDocument!.documentElement;\n }\n\n return boundariesNode;\n }\n\n return boundary;\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPopperOffset = void 0;
7
+
8
+ const fromPopperPlacement_1 = /*#__PURE__*/require("./fromPopperPlacement");
9
+ /**
10
+ * Shim to transform offset values from this library to Popper.js
11
+ * @param rawOffset Offset from this library
12
+ * @returns An offset value compatible with Popper.js
13
+ */
14
+
15
+
16
+ function getPopperOffset(rawOffset) {
17
+ if (rawOffset === undefined || rawOffset === null) {
18
+ return rawOffset;
19
+ }
20
+
21
+ if (typeof rawOffset === 'number') {
22
+ return [0, rawOffset];
23
+ }
24
+
25
+ if (typeof rawOffset === 'object') {
26
+ return [rawOffset.crossAxis, rawOffset.mainAxis];
27
+ }
28
+
29
+ return ({
30
+ popper,
31
+ reference,
32
+ placement
33
+ }) => {
34
+ const {
35
+ position,
36
+ alignment
37
+ } = fromPopperPlacement_1.fromPopperPlacement(placement);
38
+ const computedOffset = rawOffset({
39
+ positionedRect: popper,
40
+ targetRect: reference,
41
+ position,
42
+ alignment
43
+ });
44
+
45
+ if (typeof computedOffset === 'number') {
46
+ return [0, computedOffset];
47
+ }
48
+
49
+ return [computedOffset.crossAxis, computedOffset.mainAxis];
50
+ };
51
+ }
52
+
53
+ exports.getPopperOffset = getPopperOffset;
54
+ //# sourceMappingURL=getPopperOffset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/getPopperOffset.ts"],"names":[],"mappings":";;;;;;;AAEA,MAAA,qBAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;AAyBA;;;;AAIG;;;AACH,SAAgB,eAAhB,CAAgC,SAAhC,EAA6D;AAC3D,MAAI,SAAS,KAAK,SAAd,IAA2B,SAAS,KAAK,IAA7C,EAAmD;AACjD,WAAO,SAAP;AACD;;AAED,MAAI,OAAO,SAAP,KAAqB,QAAzB,EAAmC;AACjC,WAAO,CAAC,CAAD,EAAI,SAAJ,CAAP;AACD;;AAED,MAAI,OAAO,SAAP,KAAqB,QAAzB,EAAmC;AACjC,WAAO,CAAC,SAAS,CAAC,SAAX,EAAsB,SAAS,CAAC,QAAhC,CAAP;AACD;;AAED,SAAO,CAAC;AAAE,IAAA,MAAF;AAAU,IAAA,SAAV;AAAqB,IAAA;AAArB,GAAD,KAAqC;AAC1C,UAAM;AAAE,MAAA,QAAF;AAAY,MAAA;AAAZ,QAA0B,qBAAA,CAAA,mBAAA,CAAoB,SAApB,CAAhC;AACA,UAAM,cAAc,GAAG,SAAS,CAAC;AAAE,MAAA,cAAc,EAAE,MAAlB;AAA0B,MAAA,UAAU,EAAE,SAAtC;AAAiD,MAAA,QAAjD;AAA2D,MAAA;AAA3D,KAAD,CAAhC;;AACA,QAAI,OAAO,cAAP,KAA0B,QAA9B,EAAwC;AACtC,aAAO,CAAC,CAAD,EAAI,cAAJ,CAAP;AACD;;AAED,WAAO,CAAC,cAAc,CAAC,SAAhB,EAA2B,cAAc,CAAC,QAA1C,CAAP;AACD,GARD;AASD;;AAtBD,OAAA,CAAA,eAAA,GAAA,eAAA","sourcesContent":["import type { Offset } from '../types';\nimport type { Rect, Placement } from '@popperjs/core';\nimport { fromPopperPlacement } from './fromPopperPlacement';\n/**\n * Type taken from Popper since it is not exported\n */\nexport type PopperOffsetValue = [number | null | undefined, number | null | undefined];\n\n/**\n * Type taken from Popper since it is not exported\n */\nexport type PopperOffset = PopperOffsetValue | PopperOffsetFunction;\n\n/**\n * Type taken from Popper.js since it is not exported\n */\nexport type PopperOffsetFunctionParam = {\n popper: Rect;\n reference: Rect;\n placement: Placement;\n};\n\n/**\n * Type taken from Popper.js since it is not exported\n */\nexport type PopperOffsetFunction = (args: { popper: Rect; reference: Rect; placement: Placement }) => PopperOffsetValue;\n\n/**\n * Shim to transform offset values from this library to Popper.js\n * @param rawOffset Offset from this library\n * @returns An offset value compatible with Popper.js\n */\nexport function getPopperOffset(rawOffset: Offset | undefined): PopperOffsetValue | PopperOffsetFunction | undefined {\n if (rawOffset === undefined || rawOffset === null) {\n return rawOffset;\n }\n\n if (typeof rawOffset === 'number') {\n return [0, rawOffset];\n }\n\n if (typeof rawOffset === 'object') {\n return [rawOffset.crossAxis, rawOffset.mainAxis];\n }\n\n return ({ popper, reference, placement }) => {\n const { position, alignment } = fromPopperPlacement(placement);\n const computedOffset = rawOffset({ positionedRect: popper, targetRect: reference, position, alignment });\n if (typeof computedOffset === 'number') {\n return [0, computedOffset];\n }\n\n return [computedOffset.crossAxis, computedOffset.mainAxis];\n };\n}\n"],"sourceRoot":"../src/"}
@@ -1,46 +1,54 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.getReactFiberFromNode = void 0;
4
7
  var WorkTag;
8
+
5
9
  (function (WorkTag) {
6
- WorkTag[WorkTag["FunctionComponent"] = 0] = "FunctionComponent";
7
- WorkTag[WorkTag["ClassComponent"] = 1] = "ClassComponent";
8
- WorkTag[WorkTag["IndeterminateComponent"] = 2] = "IndeterminateComponent";
9
- WorkTag[WorkTag["HostRoot"] = 3] = "HostRoot";
10
- WorkTag[WorkTag["HostPortal"] = 4] = "HostPortal";
11
- WorkTag[WorkTag["HostComponent"] = 5] = "HostComponent";
12
- WorkTag[WorkTag["HostText"] = 6] = "HostText";
13
- WorkTag[WorkTag["Fragment"] = 7] = "Fragment";
14
- WorkTag[WorkTag["Mode"] = 8] = "Mode";
15
- WorkTag[WorkTag["ContextConsumer"] = 9] = "ContextConsumer";
16
- WorkTag[WorkTag["ContextProvider"] = 10] = "ContextProvider";
17
- WorkTag[WorkTag["ForwardRef"] = 11] = "ForwardRef";
18
- WorkTag[WorkTag["Profiler"] = 12] = "Profiler";
19
- WorkTag[WorkTag["SuspenseComponent"] = 13] = "SuspenseComponent";
20
- WorkTag[WorkTag["MemoComponent"] = 14] = "MemoComponent";
21
- WorkTag[WorkTag["SimpleMemoComponent"] = 15] = "SimpleMemoComponent";
22
- WorkTag[WorkTag["LazyComponent"] = 16] = "LazyComponent";
23
- WorkTag[WorkTag["IncompleteClassComponent"] = 17] = "IncompleteClassComponent";
24
- WorkTag[WorkTag["DehydratedFragment"] = 18] = "DehydratedFragment";
25
- WorkTag[WorkTag["SuspenseListComponent"] = 19] = "SuspenseListComponent";
26
- WorkTag[WorkTag["FundamentalComponent"] = 20] = "FundamentalComponent";
27
- WorkTag[WorkTag["ScopeComponent"] = 21] = "ScopeComponent";
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";
28
32
  })(WorkTag || (WorkTag = {}));
33
+
29
34
  function getReactFiberFromNode(elm) {
30
- if (!elm) {
31
- return null;
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];
32
47
  }
33
- for (var 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
- throw new Error('getReactFiber(): Failed to find a React Fiber on a node');
48
+ }
49
+
50
+ throw new Error('getReactFiber(): Failed to find a React Fiber on a node');
44
51
  }
52
+
45
53
  exports.getReactFiberFromNode = getReactFiberFromNode;
46
54
  //# sourceMappingURL=getReactFiberFromNode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getReactFiberFromNode.js","sourceRoot":"","sources":["../../src/utils/getReactFiberFromNode.ts"],"names":[],"mappings":";;;AAuEA,IAAK,OAuBJ;AAvBD,WAAK,OAAO;IACV,+DAAqB,CAAA;IACrB,yDAAkB,CAAA;IAClB,yEAA0B,CAAA;IAC1B,6CAAY,CAAA;IACZ,iDAAc,CAAA;IACd,uDAAiB,CAAA;IACjB,6CAAY,CAAA;IACZ,6CAAY,CAAA;IACZ,qCAAQ,CAAA;IACR,2DAAmB,CAAA;IACnB,4DAAoB,CAAA;IACpB,kDAAe,CAAA;IACf,8CAAa,CAAA;IACb,gEAAsB,CAAA;IACtB,wDAAkB,CAAA;IAClB,oEAAwB,CAAA;IACxB,wDAAkB,CAAA;IAClB,8EAA6B,CAAA;IAC7B,kEAAuB,CAAA;IACvB,wEAA0B,CAAA;IAC1B,sEAAyB,CAAA;IACzB,0DAAmB,CAAA;AACrB,CAAC,EAvBI,OAAO,KAAP,OAAO,QAuBX;AA+JD,SAAgB,qBAAqB,CAAC,GAAqB;IACzD,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,IAAI,CAAC;K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C,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/"}
@@ -1,56 +1,76 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.getScrollParent = exports.getParentNode = void 0;
4
7
  /**
5
8
  * Returns the parent node or the host of the node argument.
6
9
  * @param node - DOM node.
7
10
  * @returns - parent DOM node.
8
11
  */
9
- var getParentNode = function (node) {
10
- if (node.nodeName === 'HTML') {
11
- return node;
12
- }
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- return node.parentNode || node.host;
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;
15
20
  };
21
+
16
22
  exports.getParentNode = getParentNode;
17
23
  /**
18
24
  * Returns CSS styles of the given node.
19
25
  * @param node - DOM node.
20
26
  * @returns - CSS styles.
21
27
  */
22
- var getStyleComputedProperty = function (node) {
23
- var _a;
24
- if (node.nodeType !== 1) {
25
- return {};
26
- }
27
- var window = (_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
28
- return window.getComputedStyle(node, null);
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);
29
38
  };
30
39
  /**
31
40
  * Returns the first scrollable parent of the given element.
32
41
  * @param node - DOM node.
33
42
  * @returns - the first scrollable parent.
34
43
  */
35
- var getScrollParent = function (node) {
36
- // Return body, `getScroll` will take care to get the correct `scrollTop` from it
37
- var parentNode = node && exports.getParentNode(node);
38
- // eslint-disable-next-line
39
- if (!parentNode)
40
- return document.body;
41
- switch (parentNode.nodeName) {
42
- case 'HTML':
43
- case 'BODY':
44
- return parentNode.ownerDocument.body;
45
- case '#document':
46
- return parentNode.body;
47
- }
48
- // If any of the overflow props is defined for the node then we return it as the parent
49
- var _a = getStyleComputedProperty(parentNode), overflow = _a.overflow, overflowX = _a.overflowX, overflowY = _a.overflowY;
50
- if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
51
- return parentNode;
52
- }
53
- return exports.getScrollParent(parentNode);
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);
54
73
  };
74
+
55
75
  exports.getScrollParent = getScrollParent;
56
76
  //# sourceMappingURL=getScrollParent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getScrollParent.js","sourceRoot":"","sources":["../../src/utils/getScrollParent.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACI,IAAM,aAAa,GAAG,UAAC,IAAiB;IAC7C,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM,EAAE;QAC5B,OAAO,IAAI,CAAC;KACb;IACD,8DAA8D;IAC9D,OAAO,IAAI,CAAC,UAAU,IAAK,IAAY,CAAC,IAAI,CAAC;AAC/C,CAAC,CAAC;AANW,QAAA,aAAa,iBAMxB;AAEF;;;;GAIG;AACH,IAAM,wBAAwB,GAAG,UAAC,IAAiB;;IACjD,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE;QACvB,OAAO,EAAE,CAAC;KACX;IAED,IAAM,MAAM,SAAG,IAAI,CAAC,aAAa,0CAAE,WAAW,CAAC;IAC/C,OAAO,MAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;GAIG;AACI,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AA,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/"}
@@ -1,12 +1,24 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./getBasePlacement"), exports);
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
5
9
  tslib_1.__exportStar(require("./getBoundary"), exports);
10
+
6
11
  tslib_1.__exportStar(require("./getReactFiberFromNode"), exports);
12
+
7
13
  tslib_1.__exportStar(require("./getScrollParent"), exports);
14
+
8
15
  tslib_1.__exportStar(require("./mergeArrowOffset"), exports);
16
+
9
17
  tslib_1.__exportStar(require("./positioningHelper"), exports);
18
+
10
19
  tslib_1.__exportStar(require("./resolvePositioningShorthand"), exports);
20
+
11
21
  tslib_1.__exportStar(require("./useCallbackRef"), exports);
22
+
23
+ tslib_1.__exportStar(require("./parsePopperPlacement"), exports);
12
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,wDAA8B;AAC9B,kEAAwC;AACxC,4DAAkC;AAClC,6DAAmC;AACnC,8DAAoC;AACpC,wEAA8C;AAC9C,2DAAiC"}
1
+ {"version":3,"sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,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;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './positioningHelper';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\nexport * from './parsePopperPlacement';\n"],"sourceRoot":"../src/"}
@@ -1,5 +1,8 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.mergeArrowOffset = void 0;
4
7
  /**
5
8
  * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
@@ -9,33 +12,41 @@ exports.mergeArrowOffset = void 0;
9
12
  * @param arrowHeight - The height of the arrow in px
10
13
  * @returns User offset augmented with arrow height
11
14
  */
15
+
12
16
  function mergeArrowOffset(userOffset, arrowHeight) {
13
- var offsetWithArrow = userOffset;
14
- if (!userOffset) {
15
- return [0, arrowHeight];
16
- }
17
- if (Array.isArray(offsetWithArrow)) {
18
- setArrowOffset(offsetWithArrow, arrowHeight);
19
- return offsetWithArrow;
20
- }
21
- if (typeof offsetWithArrow === 'function') {
22
- var userOffsetFn_1 = offsetWithArrow;
23
- offsetWithArrow = function (offsetParams) {
24
- var offset = userOffsetFn_1(offsetParams);
25
- setArrowOffset(offset, arrowHeight);
26
- return offset;
27
- };
28
- }
29
- // This should never happen
30
- return [0, 0];
17
+ if (typeof userOffset === 'number') {
18
+ return addArrowOffset(userOffset, arrowHeight);
19
+ }
20
+
21
+ if (typeof userOffset === 'object' && userOffset !== null) {
22
+ return addArrowOffset(userOffset, arrowHeight);
23
+ }
24
+
25
+ if (typeof userOffset === 'function') {
26
+ return offsetParams => {
27
+ const offset = userOffset(offsetParams);
28
+ return addArrowOffset(offset, arrowHeight);
29
+ };
30
+ }
31
+
32
+ return {
33
+ mainAxis: arrowHeight
34
+ };
31
35
  }
36
+
32
37
  exports.mergeArrowOffset = mergeArrowOffset;
33
- var setArrowOffset = function (offset, arrowHeight) {
34
- if (offset[1] !== null && offset[1] !== undefined) {
35
- offset[1] += arrowHeight;
36
- }
37
- else {
38
- offset[1] = arrowHeight;
39
- }
38
+
39
+ const addArrowOffset = (offset, arrowHeight) => {
40
+ var _a;
41
+
42
+ if (typeof offset === 'number') {
43
+ return {
44
+ mainAxis: offset + arrowHeight
45
+ };
46
+ }
47
+
48
+ return { ...offset,
49
+ mainAxis: ((_a = offset.mainAxis) !== null && _a !== void 0 ? _a : 0) + arrowHeight
50
+ };
40
51
  };
41
52
  //# sourceMappingURL=mergeArrowOffset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeArrowOffset.js","sourceRoot":"","sources":["../../src/utils/mergeArrowOffset.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAAC,UAAqC,EAAE,WAAmB;IACzF,IAAI,eAAe,GAAG,UAAU,CAAC;IACjC,IAAI,CAAC,UAAU,EAAE;QACf,OAA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AACpB,YAAM,MAAM,GAAG,UAAU,CAAC,YAAD,CAAzB;AACA,aAAO,cAAc,CAAC,MAAD,EAAS,WAAT,CAArB;AACD,KAHD;AAID;;AAED,SAAO;AAAE,IAAA,QAAQ,EAAE;AAAZ,GAAP;AACD;;AAjBD,OAAA,CAAA,gBAAA,GAAA,gBAAA;;AAmBA,MAAM,cAAc,GAAG,CAAC,MAAD,EAAgC,WAAhC,KAAqE;;;AAC1F,MAAI,OAAO,MAAP,KAAkB,QAAtB,EAAgC;AAC9B,WAAO;AAAE,MAAA,QAAQ,EAAE,MAAM,GAAG;AAArB,KAAP;AACD;;AAED,SAAO,EAAE,GAAG,MAAL;AAAa,IAAA,QAAQ,EAAE,CAAC,CAAA,EAAA,GAAA,MAAM,CAAC,QAAP,MAAe,IAAf,IAAe,EAAA,KAAA,KAAA,CAAf,GAAe,EAAf,GAAmB,CAApB,IAAyB;AAAhD,GAAP;AACD,CAND","sourcesContent":["import type { Offset, OffsetObject } 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 if (typeof userOffset === 'number') {\n return addArrowOffset(userOffset, arrowHeight);\n }\n\n if (typeof userOffset === 'object' && userOffset !== null) {\n return addArrowOffset(userOffset, arrowHeight);\n }\n\n if (typeof userOffset === 'function') {\n return offsetParams => {\n const offset = userOffset(offsetParams);\n return addArrowOffset(offset, arrowHeight);\n };\n }\n\n return { mainAxis: arrowHeight };\n}\n\nconst addArrowOffset = (offset: OffsetObject | number, arrowHeight: number): OffsetObject => {\n if (typeof offset === 'number') {\n return { mainAxis: offset + arrowHeight };\n }\n\n return { ...offset, mainAxis: (offset.mainAxis ?? 0) + arrowHeight };\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parsePopperPlacement = void 0;
7
+ /**
8
+ * Parses Popper placement and returns the different components
9
+ * @param placement - the Popper.js placement (i.e. bottom-start)
10
+ *
11
+ * @returns side and alignment components of the placement
12
+ */
13
+
14
+ function parsePopperPlacement(placement) {
15
+ const tokens = placement.split('-');
16
+ return {
17
+ basePlacement: tokens[0],
18
+ alignment: tokens[1]
19
+ };
20
+ }
21
+
22
+ exports.parsePopperPlacement = parsePopperPlacement;
23
+ //# sourceMappingURL=parsePopperPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/parsePopperPlacement.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;AAKG;;AACH,SAAgB,oBAAhB,CAAqC,SAArC,EAAyD;AACvD,QAAM,MAAM,GAAG,SAAS,CAAC,KAAV,CAAgB,GAAhB,CAAf;AACA,SAAO;AACL,IAAA,aAAa,EAAE,MAAM,CAAC,CAAD,CADhB;AAEL,IAAA,SAAS,EAAE,MAAM,CAAC,CAAD;AAFZ,GAAP;AAID;;AAND,OAAA,CAAA,oBAAA,GAAA,oBAAA","sourcesContent":["import type { BasePlacement, Placement, Variation } from '@popperjs/core';\n\n/**\n * Parses Popper placement and returns the different components\n * @param placement - the Popper.js placement (i.e. bottom-start)\n *\n * @returns side and alignment components of the placement\n */\nexport function parsePopperPlacement(placement: Placement): { basePlacement: BasePlacement; alignment: Variation } {\n const tokens = placement.split('-');\n return {\n basePlacement: tokens[0] as BasePlacement,\n alignment: tokens[1] as Variation,\n };\n}\n"],"sourceRoot":"../src/"}
@@ -1,46 +1,61 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.applyRtlToOffset = exports.getPlacement = void 0;
4
- var getPositionMap = function (rtl) { return ({
5
- above: 'top',
6
- below: 'bottom',
7
- before: rtl ? 'right' : 'left',
8
- after: rtl ? 'left' : 'right',
9
- }); };
10
- var getAlignmentMap = function (rtl) { return ({
11
- start: rtl ? 'end' : 'start',
12
- end: rtl ? 'start' : 'end',
13
- top: 'start',
14
- bottom: 'end',
15
- center: '',
16
- }); };
17
- var shouldAlignToCenter = function (p, a) {
18
- var positionedVertically = p === 'above' || p === 'below';
19
- var alignedVertically = a === 'top' || a === 'bottom';
20
- return (positionedVertically && alignedVertically) || (!positionedVertically && !alignedVertically);
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;
21
27
  };
22
28
  /**
23
29
  * @see positioninHelper.test.ts for expected placement values
24
30
  */
25
- var getPlacement = function (align, position, rtl) {
26
- var alignment = shouldAlignToCenter(position, align) ? 'center' : align;
27
- var computedPosition = position && getPositionMap(rtl)[position];
28
- var computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];
29
- if (computedPosition && computedAlignmnent) {
30
- return computedPosition + "-" + computedAlignmnent;
31
- }
32
- return computedPosition || 'auto';
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';
33
43
  };
44
+
34
45
  exports.getPlacement = getPlacement;
35
- var applyRtlToOffset = function (offset) {
36
- if (typeof offset === 'undefined') {
37
- return undefined;
38
- }
39
- if (Array.isArray(offset)) {
40
- offset[0] = offset[0] * -1;
41
- return offset;
42
- }
43
- return (function (param) { return exports.applyRtlToOffset(offset(param)); });
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));
44
58
  };
59
+
45
60
  exports.applyRtlToOffset = applyRtlToOffset;
46
61
  //# sourceMappingURL=positioningHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"positioningHelper.js","sourceRoot":"","sources":["../../src/utils/positioningHelper.ts"],"names":[],"mappings":";;;AAMA,IAAM,cAAc,GAAG,UAAC,GAAa,IAA0C,OAAA,CAAC;IAC9E,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;IAC9B,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;CAC9B,CAAC,EAL6E,CAK7E,CAAC;AAEH,IAAM,eAAe,GAAG,UAAC,GAAa,IAAwC,OAAA,CAAC;IAC7E,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO;IAC5B,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK;IAC1B,GAAG,EAAE,OAAO;IACZ,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,EAAE;CACX,CAAC,EAN4E,CAM5E,CAAC;AAEH,IAAM,mBAAmB,GAAG,UAAC,CAAY,EAAE,CAAa;IACtD,IAAM,oBAAoB,GAAG,CA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GAAG,gBAAgB,IAAI,kBAAkB,EAAhD;AACD;;AAED,SAAO,gBAAgB,IAAK,MAA5B;AACD,CAXM;;AAAM,OAAA,CAAA,YAAA,GAAY,YAAZ;;AAaN,MAAM,gBAAgB,GAAI,MAAD,IAA+D;AAC7F,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,IAAsC,OAAA,CAAA,gBAAA,CAAiB,MAAM,CAAC,KAAD,CAAvB,CAA9C;AACD,CAZM;;AAAM,OAAA,CAAA,gBAAA,GAAgB,gBAAhB","sourcesContent":["import * as PopperJs from '@popperjs/core';\nimport type { Alignment, Position } from '../types';\nimport { PopperOffset, PopperOffsetFunction, PopperOffsetFunctionParam } from './getPopperOffset';\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: PopperOffset | undefined): PopperOffset | 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: PopperOffsetFunctionParam) => applyRtlToOffset(offset(param))) as PopperOffsetFunction;\n};\n"],"sourceRoot":"../src/"}