@fluentui/react-positioning 9.0.0-alpha.9 → 9.0.0-beta.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. package/CHANGELOG.json +1279 -1
  2. package/CHANGELOG.md +577 -2
  3. package/dist/react-positioning.d.ts +95 -27
  4. package/lib/createArrowStyles.d.ts +27 -0
  5. package/lib/createArrowStyles.js +75 -0
  6. package/lib/createArrowStyles.js.map +1 -0
  7. package/lib/createVirtualElementFromClick.d.ts +6 -0
  8. package/lib/createVirtualElementFromClick.js +26 -0
  9. package/lib/createVirtualElementFromClick.js.map +1 -0
  10. package/lib/index.d.ts +4 -0
  11. package/lib/index.js +5 -0
  12. package/lib/index.js.map +1 -1
  13. package/lib/tsdoc-metadata.json +1 -1
  14. package/lib/types.d.ts +19 -29
  15. package/lib/types.js +1 -0
  16. package/lib/types.js.map +1 -1
  17. package/lib/usePopper.d.ts +21 -1
  18. package/lib/usePopper.js +364 -284
  19. package/lib/usePopper.js.map +1 -1
  20. package/lib/usePopperMouseTarget.d.ts +11 -0
  21. package/lib/usePopperMouseTarget.js +40 -0
  22. package/lib/usePopperMouseTarget.js.map +1 -0
  23. package/lib/utils/getBasePlacement.d.ts +8 -0
  24. package/lib/utils/getBasePlacement.js +10 -0
  25. package/lib/utils/getBasePlacement.js.map +1 -0
  26. package/lib/utils/getBoundary.d.ts +1 -1
  27. package/lib/utils/getBoundary.js +15 -11
  28. package/lib/utils/getBoundary.js.map +1 -1
  29. package/lib/utils/getReactFiberFromNode.d.ts +0 -1
  30. package/lib/utils/getReactFiberFromNode.js +39 -35
  31. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  32. package/lib/utils/getScrollParent.js +46 -32
  33. package/lib/utils/getScrollParent.js.map +1 -1
  34. package/lib/utils/index.d.ts +5 -3
  35. package/lib/utils/index.js +5 -3
  36. package/lib/utils/index.js.map +1 -1
  37. package/lib/utils/mergeArrowOffset.d.ts +10 -0
  38. package/lib/utils/mergeArrowOffset.js +42 -0
  39. package/lib/utils/mergeArrowOffset.js.map +1 -0
  40. package/lib/utils/positioningHelper.d.ts +3 -3
  41. package/lib/utils/positioningHelper.js +42 -34
  42. package/lib/utils/positioningHelper.js.map +1 -1
  43. package/lib/utils/resolvePositioningShorthand.d.ts +2 -0
  44. package/lib/utils/resolvePositioningShorthand.js +63 -0
  45. package/lib/utils/resolvePositioningShorthand.js.map +1 -0
  46. package/lib/utils/useCallbackRef.js +35 -29
  47. package/lib/utils/useCallbackRef.js.map +1 -1
  48. package/lib-commonjs/createArrowStyles.d.ts +27 -0
  49. package/lib-commonjs/createArrowStyles.js +84 -0
  50. package/lib-commonjs/createArrowStyles.js.map +1 -0
  51. package/lib-commonjs/createVirtualElementFromClick.d.ts +6 -0
  52. package/lib-commonjs/createVirtualElementFromClick.js +35 -0
  53. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -0
  54. package/lib-commonjs/index.d.ts +4 -0
  55. package/lib-commonjs/index.js +31 -2
  56. package/lib-commonjs/index.js.map +1 -1
  57. package/lib-commonjs/types.d.ts +19 -29
  58. package/lib-commonjs/types.js +4 -1
  59. package/lib-commonjs/types.js.map +1 -1
  60. package/lib-commonjs/usePopper.d.ts +21 -1
  61. package/lib-commonjs/usePopper.js +378 -287
  62. package/lib-commonjs/usePopper.js.map +1 -1
  63. package/lib-commonjs/usePopperMouseTarget.d.ts +11 -0
  64. package/lib-commonjs/usePopperMouseTarget.js +51 -0
  65. package/lib-commonjs/usePopperMouseTarget.js.map +1 -0
  66. package/lib-commonjs/utils/getBasePlacement.d.ts +8 -0
  67. package/lib-commonjs/utils/getBasePlacement.js +19 -0
  68. package/lib-commonjs/utils/getBasePlacement.js.map +1 -0
  69. package/lib-commonjs/utils/getBoundary.d.ts +1 -1
  70. package/lib-commonjs/utils/getBoundary.js +24 -13
  71. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  72. package/lib-commonjs/utils/getReactFiberFromNode.d.ts +0 -1
  73. package/lib-commonjs/utils/getReactFiberFromNode.js +45 -36
  74. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  75. package/lib-commonjs/utils/getScrollParent.js +56 -33
  76. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  77. package/lib-commonjs/utils/index.d.ts +5 -3
  78. package/lib-commonjs/utils/index.js +19 -5
  79. package/lib-commonjs/utils/index.js.map +1 -1
  80. package/lib-commonjs/utils/mergeArrowOffset.d.ts +10 -0
  81. package/lib-commonjs/utils/mergeArrowOffset.js +51 -0
  82. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -0
  83. package/lib-commonjs/utils/positioningHelper.d.ts +3 -3
  84. package/lib-commonjs/utils/positioningHelper.js +53 -35
  85. package/lib-commonjs/utils/positioningHelper.js.map +1 -1
  86. package/lib-commonjs/utils/resolvePositioningShorthand.d.ts +2 -0
  87. package/lib-commonjs/utils/resolvePositioningShorthand.js +72 -0
  88. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -0
  89. package/lib-commonjs/utils/useCallbackRef.js +46 -32
  90. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  91. package/package.json +13 -10
  92. package/config/api-extractor.json +0 -3
  93. package/etc/react-positioning.api.md +0 -70
  94. package/just.config.ts +0 -3
  95. package/lib/utils/isBrowser.d.ts +0 -1
  96. package/lib/utils/isBrowser.js +0 -4
  97. package/lib/utils/isBrowser.js.map +0 -1
  98. package/lib-amd/index.d.ts +0 -2
  99. package/lib-amd/index.js +0 -6
  100. package/lib-amd/index.js.map +0 -1
  101. package/lib-amd/types.d.ts +0 -78
  102. package/lib-amd/types.js +0 -5
  103. package/lib-amd/types.js.map +0 -1
  104. package/lib-amd/usePopper.d.ts +0 -15
  105. package/lib-amd/usePopper.js +0 -281
  106. package/lib-amd/usePopper.js.map +0 -1
  107. package/lib-amd/utils/getBoundary.d.ts +0 -6
  108. package/lib-amd/utils/getBoundary.js +0 -23
  109. package/lib-amd/utils/getBoundary.js.map +0 -1
  110. package/lib-amd/utils/getReactFiberFromNode.d.ts +0 -109
  111. package/lib-amd/utils/getReactFiberFromNode.js +0 -47
  112. package/lib-amd/utils/getReactFiberFromNode.js.map +0 -1
  113. package/lib-amd/utils/getScrollParent.d.ts +0 -12
  114. package/lib-amd/utils/getScrollParent.js +0 -55
  115. package/lib-amd/utils/getScrollParent.js.map +0 -1
  116. package/lib-amd/utils/index.d.ts +0 -6
  117. package/lib-amd/utils/index.js +0 -11
  118. package/lib-amd/utils/index.js.map +0 -1
  119. package/lib-amd/utils/isBrowser.d.ts +0 -1
  120. package/lib-amd/utils/isBrowser.js +0 -8
  121. package/lib-amd/utils/isBrowser.js.map +0 -1
  122. package/lib-amd/utils/positioningHelper.d.ts +0 -7
  123. package/lib-amd/utils/positioningHelper.js +0 -45
  124. package/lib-amd/utils/positioningHelper.js.map +0 -1
  125. package/lib-amd/utils/useCallbackRef.d.ts +0 -19
  126. package/lib-amd/utils/useCallbackRef.js +0 -54
  127. package/lib-amd/utils/useCallbackRef.js.map +0 -1
  128. package/lib-commonjs/utils/isBrowser.d.ts +0 -1
  129. package/lib-commonjs/utils/isBrowser.js +0 -6
  130. package/lib-commonjs/utils/isBrowser.js.map +0 -1
@@ -1,41 +1,49 @@
1
- var getPositionMap = function (rtl) { return ({
2
- above: 'top',
3
- below: 'bottom',
4
- before: rtl ? 'right' : 'left',
5
- after: rtl ? 'left' : 'right',
6
- }); };
7
- var getAlignmentMap = function (rtl) { return ({
8
- start: rtl ? 'end' : 'start',
9
- end: rtl ? 'start' : 'end',
10
- top: 'start',
11
- bottom: 'end',
12
- center: '',
13
- }); };
14
- var shouldAlignToCenter = function (p, a) {
15
- var positionedVertically = p === 'above' || p === 'below';
16
- var alignedVertically = a === 'top' || a === 'bottom';
17
- return (positionedVertically && alignedVertically) || (!positionedVertically && !alignedVertically);
1
+ const getPositionMap = rtl => ({
2
+ above: 'top',
3
+ below: 'bottom',
4
+ before: rtl ? 'right' : 'left',
5
+ after: rtl ? 'left' : 'right'
6
+ });
7
+
8
+ const getAlignmentMap = rtl => ({
9
+ start: rtl ? 'end' : 'start',
10
+ end: rtl ? 'start' : 'end',
11
+ top: 'start',
12
+ bottom: 'end',
13
+ center: ''
14
+ });
15
+
16
+ const shouldAlignToCenter = (p, a) => {
17
+ const positionedVertically = p === 'above' || p === 'below';
18
+ const alignedVertically = a === 'top' || a === 'bottom';
19
+ return positionedVertically && alignedVertically || !positionedVertically && !alignedVertically;
18
20
  };
19
21
  /**
20
22
  * @see positioninHelper.test.ts for expected placement values
21
23
  */
22
- export var getPlacement = function (align, position, rtl) {
23
- var alignment = shouldAlignToCenter(position, align) ? 'center' : align;
24
- var computedPosition = position && getPositionMap(rtl)[position];
25
- var computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];
26
- if (computedPosition && computedAlignmnent) {
27
- return computedPosition + "-" + computedAlignmnent;
28
- }
29
- return computedPosition || 'auto';
24
+
25
+
26
+ export const getPlacement = (align, position, rtl) => {
27
+ const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
28
+ const computedPosition = position && getPositionMap(rtl)[position];
29
+ const computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];
30
+
31
+ if (computedPosition && computedAlignmnent) {
32
+ return `${computedPosition}-${computedAlignmnent}`;
33
+ }
34
+
35
+ return computedPosition || 'auto';
30
36
  };
31
- export var applyRtlToOffset = function (offset) {
32
- if (typeof offset === 'undefined') {
33
- return undefined;
34
- }
35
- if (Array.isArray(offset)) {
36
- offset[0] = offset[0] * -1;
37
- return offset;
38
- }
39
- return (function (param) { return applyRtlToOffset(offset(param)); });
37
+ export const applyRtlToOffset = offset => {
38
+ if (typeof offset === 'undefined') {
39
+ return undefined;
40
+ }
41
+
42
+ if (Array.isArray(offset)) {
43
+ offset[0] = offset[0] * -1;
44
+ return offset;
45
+ }
46
+
47
+ return param => applyRtlToOffset(offset(param));
40
48
  };
41
49
  //# sourceMappingURL=positioningHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"positioningHelper.js","sourceRoot":"../src/","sources":["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,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,OAAO,CAAC;IAC5D,IAAM,iBAAiB,GAAG,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,QAAQ,CAAC;IAExD,OAAO,CAAC,oBAAoB,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,oBAAoB,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACtG,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,IAAM,YAAY,GAAG,UAAC,KAAiB,EAAE,QAAmB,EAAE,GAAa;IAChF,IAAM,SAAS,GAAG,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IAE1E,IAAM,gBAAgB,GAAG,QAAQ,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;IACnE,IAAM,kBAAkB,GAAG,SAAS,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC;IAExE,IAAI,gBAAgB,IAAI,kBAAkB,EAAE;QAC1C,OAAU,gBAAgB,SAAI,kBAA0C,CAAC;KAC1E;IAED,OAAO,gBAAgB,IAAK,MAA6B,CAAC;AAC5D,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,gBAAgB,GAAG,UAAC,MAA0B;IACzD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC;QAE5B,OAAO,MAAM,CAAC;KACf;IAED,OAAO,CAAC,UAAC,KAA0B,IAAK,OAAA,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAA/B,CAA+B,CAAmB,CAAC;AAC7F,CAAC,CAAC","sourcesContent":["import * as PopperJs from '@popperjs/core';\nimport { 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"]}
1
+ {"version":3,"sources":["../../src/utils/positioningHelper.ts"],"names":[],"mappings":"AAMA,MAAM,cAAc,GAAI,GAAD,KAAyD;AAC9E,EAAA,KAAK,EAAE,KADuE;AAE9E,EAAA,KAAK,EAAE,QAFuE;AAG9E,EAAA,MAAM,EAAE,GAAG,GAAG,OAAH,GAAa,MAHsD;AAI9E,EAAA,KAAK,EAAE,GAAG,GAAG,MAAH,GAAY;AAJwD,CAAzD,CAAvB;;AAOA,MAAM,eAAe,GAAI,GAAD,KAAuD;AAC7E,EAAA,KAAK,EAAE,GAAG,GAAG,KAAH,GAAW,OADwD;AAE7E,EAAA,GAAG,EAAE,GAAG,GAAG,OAAH,GAAa,KAFwD;AAG7E,EAAA,GAAG,EAAE,OAHwE;AAI7E,EAAA,MAAM,EAAE,KAJqE;AAK7E,EAAA,MAAM,EAAE;AALqE,CAAvD,CAAxB;;AAQA,MAAM,mBAAmB,GAAG,CAAC,CAAD,EAAe,CAAf,KAAyC;AACnE,QAAM,oBAAoB,GAAG,CAAC,KAAK,OAAN,IAAiB,CAAC,KAAK,OAApD;AACA,QAAM,iBAAiB,GAAG,CAAC,KAAK,KAAN,IAAe,CAAC,KAAK,QAA/C;AAEA,SAAQ,oBAAoB,IAAI,iBAAzB,IAAgD,CAAC,oBAAD,IAAyB,CAAC,iBAAjF;AACD,CALD;AAOA;;AAEG;;;AACH,OAAO,MAAM,YAAY,GAAG,CAAC,KAAD,EAAoB,QAApB,EAAyC,GAAzC,KAA8E;AACxG,QAAM,SAAS,GAAG,mBAAmB,CAAC,QAAD,EAAW,KAAX,CAAnB,GAAuC,QAAvC,GAAkD,KAApE;AAEA,QAAM,gBAAgB,GAAG,QAAQ,IAAI,cAAc,CAAC,GAAD,CAAd,CAAoB,QAApB,CAArC;AACA,QAAM,kBAAkB,GAAG,SAAS,IAAI,eAAe,CAAC,GAAD,CAAf,CAAqB,SAArB,CAAxC;;AAEA,MAAI,gBAAgB,IAAI,kBAAxB,EAA4C;AAC1C,WAAO,GAAG,gBAAgB,IAAI,kBAAkB,EAAhD;AACD;;AAED,SAAO,gBAAgB,IAAK,MAA5B;AACD,CAXM;AAaP,OAAO,MAAM,gBAAgB,GAAI,MAAD,IAAmD;AACjF,MAAI,OAAO,MAAP,KAAkB,WAAtB,EAAmC;AACjC,WAAO,SAAP;AACD;;AAED,MAAI,KAAK,CAAC,OAAN,CAAc,MAAd,CAAJ,EAA2B;AACzB,IAAA,MAAM,CAAC,CAAD,CAAN,GAAY,MAAM,CAAC,CAAD,CAAN,GAAa,CAAC,CAA1B;AAEA,WAAO,MAAP;AACD;;AAED,SAAS,KAAD,IAAgC,gBAAgB,CAAC,MAAM,CAAC,KAAD,CAAP,CAAxD;AACD,CAZM","sourceRoot":""}
@@ -0,0 +1,2 @@
1
+ import type { PositioningShorthand, PositioningProps } from '../types';
2
+ export declare function resolvePositioningShorthand(shorthand: PositioningShorthand | undefined | null): Readonly<PositioningProps>;
@@ -0,0 +1,63 @@
1
+ // Look up table for shorthand to avoid parsing strings
2
+ const shorthandLookup = {
3
+ above: {
4
+ position: 'above',
5
+ align: 'center'
6
+ },
7
+ 'above-start': {
8
+ position: 'above',
9
+ align: 'start'
10
+ },
11
+ 'above-end': {
12
+ position: 'above',
13
+ align: 'end'
14
+ },
15
+ below: {
16
+ position: 'below',
17
+ align: 'center'
18
+ },
19
+ 'below-start': {
20
+ position: 'below',
21
+ align: 'start'
22
+ },
23
+ 'below-end': {
24
+ position: 'below',
25
+ align: 'end'
26
+ },
27
+ before: {
28
+ position: 'before',
29
+ align: 'center'
30
+ },
31
+ 'before-top': {
32
+ position: 'before',
33
+ align: 'top'
34
+ },
35
+ 'before-bottom': {
36
+ position: 'before',
37
+ align: 'bottom'
38
+ },
39
+ after: {
40
+ position: 'after',
41
+ align: 'center'
42
+ },
43
+ 'after-top': {
44
+ position: 'after',
45
+ align: 'top'
46
+ },
47
+ 'after-bottom': {
48
+ position: 'after',
49
+ align: 'bottom'
50
+ }
51
+ };
52
+ export function resolvePositioningShorthand(shorthand) {
53
+ if (shorthand === undefined || shorthand === null) {
54
+ return {};
55
+ }
56
+
57
+ if (typeof shorthand === 'string') {
58
+ return shorthandLookup[shorthand];
59
+ }
60
+
61
+ return shorthand;
62
+ }
63
+ //# sourceMappingURL=resolvePositioningShorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/resolvePositioningShorthand.ts"],"names":[],"mappings":"AAEA;AACA,MAAM,eAAe,GAAoF;AACvG,EAAA,KAAK,EAAE;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GADgG;AAEvG,iBAAe;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAFwF;AAGvG,eAAa;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAH0F;AAIvG,EAAA,KAAK,EAAE;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAJgG;AAKvG,iBAAe;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GALwF;AAMvG,eAAa;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAN0F;AAOvG,EAAA,MAAM,EAAE;AAAE,IAAA,QAAQ,EAAE,QAAZ;AAAsB,IAAA,KAAK,EAAE;AAA7B,GAP+F;AAQvG,gBAAc;AAAE,IAAA,QAAQ,EAAE,QAAZ;AAAsB,IAAA,KAAK,EAAE;AAA7B,GARyF;AASvG,mBAAiB;AAAE,IAAA,QAAQ,EAAE,QAAZ;AAAsB,IAAA,KAAK,EAAE;AAA7B,GATsF;AAUvG,EAAA,KAAK,EAAE;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAVgG;AAWvG,eAAa;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAX0F;AAYvG,kBAAgB;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B;AAZuF,CAAzG;AAeA,OAAM,SAAU,2BAAV,CACJ,SADI,EAC8C;AAElD,MAAI,SAAS,KAAK,SAAd,IAA2B,SAAS,KAAK,IAA7C,EAAmD;AACjD,WAAO,EAAP;AACD;;AAED,MAAI,OAAO,SAAP,KAAqB,QAAzB,EAAmC;AACjC,WAAO,eAAe,CAAC,SAAD,CAAtB;AACD;;AAED,SAAO,SAAP;AACD","sourceRoot":""}
@@ -17,35 +17,41 @@ import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
17
17
  * ref.current = 1;
18
18
  * // prints 0 -> 1
19
19
  */
20
+
20
21
  export function useCallbackRef(initialValue, callback, skipInitialResolve) {
21
- var isFirst = React.useRef(true);
22
- var ref = React.useState(function () { return ({
23
- // value
24
- value: initialValue,
25
- // last callback
26
- callback: callback,
27
- // "memoized" public interface
28
- facade: {
29
- get current() {
30
- return ref.value;
31
- },
32
- set current(value) {
33
- var last = ref.value;
34
- if (last !== value) {
35
- ref.value = value;
36
- if (skipInitialResolve && isFirst.current) {
37
- return;
38
- }
39
- ref.callback(value, last);
40
- }
41
- },
42
- },
43
- }); })[0];
44
- useIsomorphicLayoutEffect(function () {
45
- isFirst.current = false;
46
- }, []);
47
- // update callback
48
- ref.callback = callback;
49
- return ref.facade;
22
+ const isFirst = React.useRef(true);
23
+ const [ref] = React.useState(() => ({
24
+ // value
25
+ value: initialValue,
26
+ // last callback
27
+ callback,
28
+ // "memoized" public interface
29
+ facade: {
30
+ get current() {
31
+ return ref.value;
32
+ },
33
+
34
+ set current(value) {
35
+ const last = ref.value;
36
+
37
+ if (last !== value) {
38
+ ref.value = value;
39
+
40
+ if (skipInitialResolve && isFirst.current) {
41
+ return;
42
+ }
43
+
44
+ ref.callback(value, last);
45
+ }
46
+ }
47
+
48
+ }
49
+ }));
50
+ useIsomorphicLayoutEffect(() => {
51
+ isFirst.current = false;
52
+ }, []); // update callback
53
+
54
+ ref.callback = callback;
55
+ return ref.facade;
50
56
  }
51
57
  //# sourceMappingURL=useCallbackRef.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCallbackRef.js","sourceRoot":"../src/","sources":["utils/useCallbackRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAsB,EACtB,QAA2D,EAC3D,kBAA4B;IAE5B,IAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAA;;;;;;;;;;;;;;;;;;;;;aAAG,CAwBN;IAEJ,yBAAyB,CAAC;QACxB,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;IAC1B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,kBAAkB;IAClB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAExB,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,CAAC","sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\n\n/**\n * Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content\n * changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via\n * React.useState(), but it will cause re-renders always.\n *\n * https://reactjs.org/docs/hooks-reference.html#useref\n * https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref\n *\n * @param initialValue - initial ref value\n * @param callback - a callback to run when value changes\n * @param skipInitialResolve - a flag to skip an initial ref report\n *\n * @example\n * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);\n * ref.current = 1;\n * // prints 0 -> 1\n */\nexport function useCallbackRef<T>(\n initialValue: T | null,\n callback: (newValue: T | null, lastValue: T | null) => void,\n skipInitialResolve?: boolean,\n): React.MutableRefObject<T | null> {\n const isFirst = React.useRef(true);\n const [ref] = React.useState(() => ({\n // value\n value: initialValue,\n // last callback\n callback,\n // \"memoized\" public interface\n facade: {\n get current() {\n return ref.value;\n },\n set current(value) {\n const last = ref.value;\n\n if (last !== value) {\n ref.value = value;\n\n if (skipInitialResolve && isFirst.current) {\n return;\n }\n\n ref.callback(value, last);\n }\n },\n },\n }));\n\n useIsomorphicLayoutEffect(() => {\n isFirst.current = false;\n }, []);\n\n // update callback\n ref.callback = callback;\n\n return ref.facade;\n}\n"]}
1
+ {"version":3,"sources":["../../src/utils/useCallbackRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,yBAAT,QAA0C,2BAA1C;AAEA;;;;;;;;;;;;;;;;AAgBG;;AACH,OAAM,SAAU,cAAV,CACJ,YADI,EAEJ,QAFI,EAGJ,kBAHI,EAGwB;AAE5B,QAAM,OAAO,GAAG,KAAK,CAAC,MAAN,CAAa,IAAb,CAAhB;AACA,QAAM,CAAC,GAAD,IAAQ,KAAK,CAAC,QAAN,CAAe,OAAO;AAClC;AACA,IAAA,KAAK,EAAE,YAF2B;AAGlC;AACA,IAAA,QAJkC;AAKlC;AACA,IAAA,MAAM,EAAE;AACN,UAAI,OAAJ,GAAW;AACT,eAAO,GAAG,CAAC,KAAX;AACD,OAHK;;AAIN,UAAI,OAAJ,CAAY,KAAZ,EAAiB;AACf,cAAM,IAAI,GAAG,GAAG,CAAC,KAAjB;;AAEA,YAAI,IAAI,KAAK,KAAb,EAAoB;AAClB,UAAA,GAAG,CAAC,KAAJ,GAAY,KAAZ;;AAEA,cAAI,kBAAkB,IAAI,OAAO,CAAC,OAAlC,EAA2C;AACzC;AACD;;AAED,UAAA,GAAG,CAAC,QAAJ,CAAa,KAAb,EAAoB,IAApB;AACD;AACF;;AAhBK;AAN0B,GAAP,CAAf,CAAd;AA0BA,EAAA,yBAAyB,CAAC,MAAK;AAC7B,IAAA,OAAO,CAAC,OAAR,GAAkB,KAAlB;AACD,GAFwB,EAEtB,EAFsB,CAAzB,CA7B4B,CAiC5B;;AACA,EAAA,GAAG,CAAC,QAAJ,GAAe,QAAf;AAEA,SAAO,GAAG,CAAC,MAAX;AACD","sourceRoot":""}
@@ -0,0 +1,27 @@
1
+ import type { MakeStylesStyleRule } from '@fluentui/make-styles';
2
+ import type { Theme } from '@fluentui/react-theme';
3
+ /**
4
+ * Helper that creates a makeStyles rule for an arrow element.
5
+ * For runtime arrow size toggling simply create extra classnames to apply to the arrow element
6
+ *
7
+ * ```ts
8
+ * makeStyles({
9
+ * arrowWithSize: createArrowStyles(5),
10
+ *
11
+ * arrowWithoutSize: createArrowStyles(),
12
+ * mediumArrow: { aspectRatio: 1, width: '4px' }
13
+ * smallArrow: { aspectRatio: 1, width: '2px' }
14
+ * })
15
+ * ...
16
+ *
17
+ * state.arrowWithSize.clasName = styles.arrowWithSize
18
+ * state.arrowWithoutSize.className = mergeClases(
19
+ * styles.arrowWithoutSize,
20
+ * state.smallArrow && styles.smallArrow,
21
+ * state.mediumArrow && styles.mediumArrow,
22
+ * )
23
+ * ```
24
+ *
25
+ * @param size - dimensions of the square arrow element in pixels.
26
+ */
27
+ export declare function createArrowStyles(size?: number): MakeStylesStyleRule<Theme>;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createArrowStyles = void 0;
7
+ /**
8
+ * Helper that creates a makeStyles rule for an arrow element.
9
+ * For runtime arrow size toggling simply create extra classnames to apply to the arrow element
10
+ *
11
+ * ```ts
12
+ * makeStyles({
13
+ * arrowWithSize: createArrowStyles(5),
14
+ *
15
+ * arrowWithoutSize: createArrowStyles(),
16
+ * mediumArrow: { aspectRatio: 1, width: '4px' }
17
+ * smallArrow: { aspectRatio: 1, width: '2px' }
18
+ * })
19
+ * ...
20
+ *
21
+ * state.arrowWithSize.clasName = styles.arrowWithSize
22
+ * state.arrowWithoutSize.className = mergeClases(
23
+ * styles.arrowWithoutSize,
24
+ * state.smallArrow && styles.smallArrow,
25
+ * state.mediumArrow && styles.mediumArrow,
26
+ * )
27
+ * ```
28
+ *
29
+ * @param size - dimensions of the square arrow element in pixels.
30
+ */
31
+
32
+ function createArrowStyles(size) {
33
+ return theme => {
34
+ const arrowHCBorderStyle = `1px solid transparent`;
35
+ const arrowHCBorder = {
36
+ borderRight: arrowHCBorderStyle,
37
+ borderBottom: arrowHCBorderStyle
38
+ };
39
+ return {
40
+ position: 'absolute',
41
+ background: 'inherit',
42
+ visibility: 'hidden',
43
+ zIndex: -1,
44
+ ...(size && {
45
+ aspectRatio: 1,
46
+ width: `${size}px`
47
+ }),
48
+ ':before': {
49
+ content: '""',
50
+ borderRadius: '4px',
51
+ position: 'absolute',
52
+ width: 'inherit',
53
+ height: 'inherit',
54
+ background: 'inherit',
55
+ visibility: 'visible',
56
+ borderBottomRightRadius: theme.borderRadiusSmall,
57
+ transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)'
58
+ },
59
+ ':global([data-popper-placement])': {
60
+ ':before': arrowHCBorder
61
+ },
62
+ // Popper sets data-popper-placement on the root element, which is used to align the arrow
63
+ ':global([data-popper-placement^="top"])': {
64
+ bottom: 0,
65
+ '--angle': '0'
66
+ },
67
+ ':global([data-popper-placement^="right"])': {
68
+ left: 0,
69
+ '--angle': '90deg'
70
+ },
71
+ ':global([data-popper-placement^="bottom"])': {
72
+ top: 0,
73
+ '--angle': '180deg'
74
+ },
75
+ ':global([data-popper-placement^="left"])': {
76
+ right: 0,
77
+ '--angle': '270deg'
78
+ }
79
+ };
80
+ };
81
+ }
82
+
83
+ exports.createArrowStyles = createArrowStyles;
84
+ //# sourceMappingURL=createArrowStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/createArrowStyles.ts"],"names":[],"mappings":";;;;;;AAGA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;;AACH,SAAgB,iBAAhB,CAAkC,IAAlC,EAA+C;AAC7C,SAAO,KAAK,IAAG;AACb,UAAM,kBAAkB,GAAG,uBAA3B;AACA,UAAM,aAAa,GAAG;AACpB,MAAA,WAAW,EAAE,kBADO;AAEpB,MAAA,YAAY,EAAE;AAFM,KAAtB;AAKA,WAAO;AACL,MAAA,QAAQ,EAAE,UADL;AAEL,MAAA,UAAU,EAAE,SAFP;AAGL,MAAA,UAAU,EAAE,QAHP;AAIL,MAAA,MAAM,EAAE,CAAC,CAJJ;AAML,UAAI,IAAI,IAAI;AACV,QAAA,WAAW,EAAE,CADH;AAEV,QAAA,KAAK,EAAE,GAAG,IAAI;AAFJ,OAAZ,CANK;AAWL,iBAAW;AACT,QAAA,OAAO,EAAE,IADA;AAET,QAAA,YAAY,EAAE,KAFL;AAGT,QAAA,QAAQ,EAAE,UAHD;AAIT,QAAA,KAAK,EAAE,SAJE;AAKT,QAAA,MAAM,EAAE,SALC;AAMT,QAAA,UAAU,EAAE,SANH;AAOT,QAAA,UAAU,EAAE,SAPH;AAQT,QAAA,uBAAuB,EAAE,KAAK,CAAC,iBARtB;AAST,QAAA,SAAS,EAAE;AATF,OAXN;AAuBL,0CAAoC;AAClC,mBAAW;AADuB,OAvB/B;AA2BL;AACA,iDAA2C;AACzC,QAAA,MAAM,EAAE,CADiC;AAEzC,mBAAW;AAF8B,OA5BtC;AAiCL,mDAA6C;AAC3C,QAAA,IAAI,EAAE,CADqC;AAE3C,mBAAW;AAFgC,OAjCxC;AAqCL,oDAA8C;AAC5C,QAAA,GAAG,EAAE,CADuC;AAE5C,mBAAW;AAFiC,OArCzC;AAyCL,kDAA4C;AAC1C,QAAA,KAAK,EAAE,CADmC;AAE1C,mBAAW;AAF+B;AAzCvC,KAAP;AA8CD,GArDD;AAsDD;;AAvDD,OAAA,CAAA,iBAAA,GAAA,iBAAA","sourceRoot":""}
@@ -0,0 +1,6 @@
1
+ import type { PopperVirtualElement } from './types';
2
+ /**
3
+ * Creates a virtual element based on the position of a click event
4
+ * Can be used as a target for popper in scenarios such as context menus
5
+ */
6
+ export declare function createVirtualElementFromClick(nativeEvent: MouseEvent): PopperVirtualElement;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createVirtualElementFromClick = void 0;
7
+ /**
8
+ * Creates a virtual element based on the position of a click event
9
+ * Can be used as a target for popper in scenarios such as context menus
10
+ */
11
+
12
+ function createVirtualElementFromClick(nativeEvent) {
13
+ const left = nativeEvent.clientX;
14
+ const top = nativeEvent.clientY;
15
+ const right = left + 1;
16
+ const bottom = top + 1;
17
+
18
+ function getBoundingClientRect() {
19
+ return {
20
+ left,
21
+ top,
22
+ right,
23
+ bottom,
24
+ height: 1,
25
+ width: 1
26
+ };
27
+ }
28
+
29
+ return {
30
+ getBoundingClientRect
31
+ };
32
+ }
33
+
34
+ exports.createVirtualElementFromClick = createVirtualElementFromClick;
35
+ //# sourceMappingURL=createVirtualElementFromClick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/createVirtualElementFromClick.ts"],"names":[],"mappings":";;;;;;AAEA;;;AAGG;;AACH,SAAgB,6BAAhB,CAA8C,WAA9C,EAAqE;AACnE,QAAM,IAAI,GAAG,WAAW,CAAC,OAAzB;AACA,QAAM,GAAG,GAAG,WAAW,CAAC,OAAxB;AACA,QAAM,KAAK,GAAG,IAAI,GAAG,CAArB;AACA,QAAM,MAAM,GAAG,GAAG,GAAG,CAArB;;AAEA,WAAS,qBAAT,GAA8B;AAC5B,WAAO;AACL,MAAA,IADK;AAEL,MAAA,GAFK;AAGL,MAAA,KAHK;AAIL,MAAA,MAJK;AAML,MAAA,MAAM,EAAE,CANH;AAOL,MAAA,KAAK,EAAE;AAPF,KAAP;AASD;;AAED,SAAO;AACL,IAAA;AADK,GAAP;AAGD;;AArBD,OAAA,CAAA,6BAAA,GAAA,6BAAA","sourceRoot":""}
@@ -1,2 +1,6 @@
1
+ export * from './createVirtualElementFromClick';
2
+ export * from './createArrowStyles';
1
3
  export * from './usePopper';
4
+ export * from './usePopperMouseTarget';
5
+ export { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';
2
6
  export * from './types';
@@ -1,5 +1,34 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mergeArrowOffset = exports.resolvePositioningShorthand = void 0;
7
+
8
+ const tslib_1 = /*#__PURE__*/require("tslib");
9
+
10
+ tslib_1.__exportStar(require("./createVirtualElementFromClick"), exports);
11
+
12
+ tslib_1.__exportStar(require("./createArrowStyles"), exports);
13
+
4
14
  tslib_1.__exportStar(require("./usePopper"), exports);
15
+
16
+ tslib_1.__exportStar(require("./usePopperMouseTarget"), exports);
17
+
18
+ var index_1 = /*#__PURE__*/require("./utils/index");
19
+
20
+ Object.defineProperty(exports, "resolvePositioningShorthand", {
21
+ enumerable: true,
22
+ get: function () {
23
+ return index_1.resolvePositioningShorthand;
24
+ }
25
+ });
26
+ Object.defineProperty(exports, "mergeArrowOffset", {
27
+ enumerable: true,
28
+ get: function () {
29
+ return index_1.mergeArrowOffset;
30
+ }
31
+ });
32
+
33
+ tslib_1.__exportStar(require("./types"), exports);
5
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B","sourcesContent":["export * from './usePopper';\nexport * from './types';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iCAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,IAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,6BAAA,EAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,GAAA,EAAA,YAAA;AAAA,WAAA,OAAA,CAAA,2BAAA;AAA2B;AAA3B,CAAA;AAA6B,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,GAAA,EAAA,YAAA;AAAA,WAAA,OAAA,CAAA,gBAAA;AAAgB;AAAhB,CAAA;;AACtC,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA","sourceRoot":""}
@@ -9,21 +9,21 @@ export declare type OffsetFunction = (param: OffsetFunctionParam) => [number | n
9
9
  export declare type Offset = OffsetFunction | [number | null | undefined, number | null | undefined];
10
10
  export declare type Position = 'above' | 'below' | 'before' | 'after';
11
11
  export declare type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';
12
+ export declare type AutoSize = 'height' | 'height-always' | 'width' | 'width-always' | 'always' | boolean;
12
13
  export declare type Boundary = PopperJs.Boundary | 'scrollParent' | 'window';
13
14
  export declare type PopperRefHandle = {
14
15
  updatePosition: () => void;
15
16
  };
17
+ export declare type PopperVirtualElement = PopperJs.VirtualElement;
16
18
  export interface PositioningProps {
17
- /**
18
- * Alignment for the component.
19
- */
19
+ /** Alignment for the component. Only has an effect if used with the @see position option */
20
20
  align?: Alignment;
21
21
  /** The element which will define the boundaries of the popper position for the flip behavior. */
22
22
  flipBoundary?: Boundary;
23
23
  /** The element which will define the boundaries of the popper position for the overflow behavior. */
24
24
  overflowBoundary?: Boundary;
25
25
  /** An imperative handle to Popper methods. */
26
- containerRef?: React.Ref<PopperRefHandle>;
26
+ popperRef?: React.Ref<PopperRefHandle>;
27
27
  /**
28
28
  * Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')
29
29
  * and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'
@@ -31,11 +31,6 @@ export interface PositioningProps {
31
31
  * then provided value for 'align' will be ignored and 'center' will be used instead.
32
32
  */
33
33
  position?: Position;
34
- /**
35
- * Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')
36
- * @default false
37
- */
38
- positionFixed?: boolean;
39
34
  /**
40
35
  * Lets you displace a popper element from its reference element.
41
36
  * This can be useful if you need to apply some margin between them or if you need to fine tune the
@@ -48,31 +43,26 @@ export interface PositioningProps {
48
43
  */
49
44
  arrowPadding?: number;
50
45
  /**
51
- * When the reference element or the viewport is outside viewport allows a popper element to be fully in viewport.
52
- * "all" enables this behavior for all axis.
53
- */
54
- unstable_disableTether?: boolean | 'all';
55
- /**
56
- * Disables automatic repositioning of the component; it will always be placed according to the values of `align` and
57
- * `position` props, regardless of the size of the component, the reference element or the viewport.
46
+ * Applies max-height and max-width on popper to fit it within the available space in viewport.
47
+ * true enables this for both width and height when overflow happens.
48
+ * 'always' applies `max-height`/`max-width` regardless of overflow.
49
+ * 'height' applies `max-height` when overflow happens, and 'width' for `max-width`
50
+ * `height-always` applies `max-height` regardless of overflow, and 'width-always' for always applying `max-width`
58
51
  */
59
- unstable_pinned?: boolean;
52
+ autoSize?: AutoSize;
60
53
  /**
61
- * Applies max-height and max-width on popper to fit it within the available space in viewport.
62
- * true enables this for both width and height.
63
- * 'height' applies only `max-height` and 'width' for `max-width`
54
+ * Manual override for popper target. Useful for scenarios where a component accepts user prop to override target
64
55
  */
65
- autoSize?: 'height' | 'width' | boolean;
66
- }
67
- export interface PopperOptions extends PositioningProps {
56
+ target?: HTMLElement | PopperVirtualElement | null;
68
57
  /**
69
- * If false, delays Popper's creation.
70
- * @default true
58
+ * Modifies position and alignment to cover the target
71
59
  */
72
- enabled?: boolean;
60
+ coverTarget?: boolean;
73
61
  /**
74
- * Array of conditions to be met in order to trigger a subsequent render to reposition the elements.
62
+ * Disables automatic repositioning of the component; it will always be placed according to the values of `align` and
63
+ * `position` props, regardless of the size of the component, the reference element or the viewport.
75
64
  */
76
- positioningDependencies?: React.DependencyList;
77
- onStateUpdate?: (state: Partial<PopperJs.State>) => void;
65
+ pinned?: boolean;
78
66
  }
67
+ export declare type PositioningShorthandValue = 'above' | 'above-start' | 'above-end' | 'below' | 'below-start' | 'below-end' | 'before' | 'before-top' | 'before-bottom' | 'after' | 'after-top' | 'after-bottom';
68
+ export declare type PositioningShorthand = PositioningProps | PositioningShorthandValue;
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"../src/","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import * as PopperJs from '@popperjs/core';\nimport * as React from 'react';\n\nexport type OffsetFunctionParam = {\n popper: PopperJs.Rect;\n reference: PopperJs.Rect;\n placement: PopperJs.Placement;\n};\n\nexport type OffsetFunction = (param: OffsetFunctionParam) => [number | null | undefined, number | null | undefined];\n\nexport type Offset = OffsetFunction | [number | null | undefined, number | null | undefined];\n\nexport type Position = 'above' | 'below' | 'before' | 'after';\nexport type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';\n\nexport type Boundary = PopperJs.Boundary | 'scrollParent' | 'window';\n\nexport type PopperRefHandle = { updatePosition: () => void };\n\nexport interface PositioningProps {\n /**\n * Alignment for the component.\n */\n align?: Alignment;\n\n /** The element which will define the boundaries of the popper position for the flip behavior. */\n flipBoundary?: Boundary;\n\n /** The element which will define the boundaries of the popper position for the overflow behavior. */\n overflowBoundary?: Boundary;\n\n /** An imperative handle to Popper methods. */\n containerRef?: React.Ref<PopperRefHandle>;\n\n /**\n * Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')\n * and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'\n * and 'start' | 'end' respectively),\n * then provided value for 'align' will be ignored and 'center' will be used instead.\n */\n position?: Position;\n\n /**\n * Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')\n * @default false\n */\n positionFixed?: boolean;\n\n /**\n * Lets you displace a popper element from its reference element.\n * This can be useful if you need to apply some margin between them or if you need to fine tune the\n * position according to some custom logic.\n */\n offset?: Offset;\n\n /**\n * Defines padding between the corner of the popup element and the arrow.\n * Use to prevent the arrow from overlapping a rounded corner, for example.\n */\n arrowPadding?: number;\n\n /**\n * When the reference element or the viewport is outside viewport allows a popper element to be fully in viewport.\n * \"all\" enables this behavior for all axis.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether?: boolean | 'all';\n\n /**\n * Disables automatic repositioning of the component; it will always be placed according to the values of `align` and\n * `position` props, regardless of the size of the component, the reference element or the viewport.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_pinned?: boolean;\n\n /**\n * Applies max-height and max-width on popper to fit it within the available space in viewport.\n * true enables this for both width and height.\n * 'height' applies only `max-height` and 'width' for `max-width`\n */\n autoSize?: 'height' | 'width' | boolean;\n}\n\nexport interface PopperOptions extends PositioningProps {\n /**\n * If false, delays Popper's creation.\n * @default true\n */\n enabled?: boolean;\n\n /**\n * Array of conditions to be met in order to trigger a subsequent render to reposition the elements.\n */\n positioningDependencies?: React.DependencyList;\n\n onStateUpdate?: (state: Partial<PopperJs.State>) => void;\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}
@@ -1,5 +1,24 @@
1
+ import * as PopperJs from '@popperjs/core';
1
2
  import * as React from 'react';
2
- import { PopperOptions } from './types';
3
+ import type { PositioningProps } from './types';
4
+ interface PopperOptions extends PositioningProps {
5
+ /**
6
+ * If false, delays Popper's creation.
7
+ * @default true
8
+ */
9
+ enabled?: boolean;
10
+ onStateUpdate?: (state: Partial<PopperJs.State>) => void;
11
+ /**
12
+ * Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')
13
+ * @default false
14
+ */
15
+ positionFixed?: boolean;
16
+ /**
17
+ * When the reference element or the viewport is outside viewport allows a popper element to be fully in viewport.
18
+ * "all" enables this behavior for all axis.
19
+ */
20
+ unstable_disableTether?: boolean | 'all';
21
+ }
3
22
  /**
4
23
  * Exposes Popper positioning API via React hook. Contains few important differences between an official "react-popper"
5
24
  * package:
@@ -13,3 +32,4 @@ export declare function usePopper(options?: PopperOptions): {
13
32
  containerRef: React.MutableRefObject<any>;
14
33
  arrowRef: React.MutableRefObject<any>;
15
34
  };
35
+ export {};