@elliemae/ds-floating-context 3.44.0-rc.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 (98) hide show
  1. package/dist/cjs/DSFloatingContext.js +151 -0
  2. package/dist/cjs/DSFloatingContext.js.map +7 -0
  3. package/dist/cjs/index.js +42 -0
  4. package/dist/cjs/index.js.map +7 -0
  5. package/dist/cjs/package.json +7 -0
  6. package/dist/cjs/parts/FloatingWrapper/FloatingWrapper.js +95 -0
  7. package/dist/cjs/parts/FloatingWrapper/FloatingWrapper.js.map +7 -0
  8. package/dist/cjs/parts/FloatingWrapper/config/useFloatingWrapper.js +58 -0
  9. package/dist/cjs/parts/FloatingWrapper/config/useFloatingWrapper.js.map +7 -0
  10. package/dist/cjs/parts/FloatingWrapper/config/useValidateProps.js +39 -0
  11. package/dist/cjs/parts/FloatingWrapper/config/useValidateProps.js.map +7 -0
  12. package/dist/cjs/parts/FloatingWrapper/constants/index.js +40 -0
  13. package/dist/cjs/parts/FloatingWrapper/constants/index.js.map +7 -0
  14. package/dist/cjs/parts/FloatingWrapper/index.js +37 -0
  15. package/dist/cjs/parts/FloatingWrapper/index.js.map +7 -0
  16. package/dist/cjs/parts/FloatingWrapper/react-desc-prop-types.js +63 -0
  17. package/dist/cjs/parts/FloatingWrapper/react-desc-prop-types.js.map +7 -0
  18. package/dist/cjs/parts/FloatingWrapper/styled.js +77 -0
  19. package/dist/cjs/parts/FloatingWrapper/styled.js.map +7 -0
  20. package/dist/cjs/parts/PopoverArrow.js +114 -0
  21. package/dist/cjs/parts/PopoverArrow.js.map +7 -0
  22. package/dist/cjs/react-desc-prop-types.js +84 -0
  23. package/dist/cjs/react-desc-prop-types.js.map +7 -0
  24. package/dist/cjs/utils/computeOffsets.js +90 -0
  25. package/dist/cjs/utils/computeOffsets.js.map +7 -0
  26. package/dist/cjs/utils/computePosition.js +105 -0
  27. package/dist/cjs/utils/computePosition.js.map +7 -0
  28. package/dist/cjs/utils/detectOverflow.js +82 -0
  29. package/dist/cjs/utils/detectOverflow.js.map +7 -0
  30. package/dist/cjs/utils/getAlteredPosition.js +44 -0
  31. package/dist/cjs/utils/getAlteredPosition.js.map +7 -0
  32. package/dist/cjs/utils/getArrowOffset.js +41 -0
  33. package/dist/cjs/utils/getArrowOffset.js.map +7 -0
  34. package/dist/cjs/utils/getExpandedFallbackPlacements.js +58 -0
  35. package/dist/cjs/utils/getExpandedFallbackPlacements.js.map +7 -0
  36. package/dist/cjs/utils/getOppositePlacement.js +44 -0
  37. package/dist/cjs/utils/getOppositePlacement.js.map +7 -0
  38. package/dist/cjs/utils/getOppositeVariationPlacement.js +46 -0
  39. package/dist/cjs/utils/getOppositeVariationPlacement.js.map +7 -0
  40. package/dist/esm/DSFloatingContext.js +125 -0
  41. package/dist/esm/DSFloatingContext.js.map +7 -0
  42. package/dist/esm/index.js +12 -0
  43. package/dist/esm/index.js.map +7 -0
  44. package/dist/esm/package.json +7 -0
  45. package/dist/esm/parts/FloatingWrapper/FloatingWrapper.js +65 -0
  46. package/dist/esm/parts/FloatingWrapper/FloatingWrapper.js.map +7 -0
  47. package/dist/esm/parts/FloatingWrapper/config/useFloatingWrapper.js +28 -0
  48. package/dist/esm/parts/FloatingWrapper/config/useFloatingWrapper.js.map +7 -0
  49. package/dist/esm/parts/FloatingWrapper/config/useValidateProps.js +9 -0
  50. package/dist/esm/parts/FloatingWrapper/config/useValidateProps.js.map +7 -0
  51. package/dist/esm/parts/FloatingWrapper/constants/index.js +10 -0
  52. package/dist/esm/parts/FloatingWrapper/constants/index.js.map +7 -0
  53. package/dist/esm/parts/FloatingWrapper/index.js +7 -0
  54. package/dist/esm/parts/FloatingWrapper/index.js.map +7 -0
  55. package/dist/esm/parts/FloatingWrapper/react-desc-prop-types.js +38 -0
  56. package/dist/esm/parts/FloatingWrapper/react-desc-prop-types.js.map +7 -0
  57. package/dist/esm/parts/FloatingWrapper/styled.js +47 -0
  58. package/dist/esm/parts/FloatingWrapper/styled.js.map +7 -0
  59. package/dist/esm/parts/PopoverArrow.js +84 -0
  60. package/dist/esm/parts/PopoverArrow.js.map +7 -0
  61. package/dist/esm/react-desc-prop-types.js +54 -0
  62. package/dist/esm/react-desc-prop-types.js.map +7 -0
  63. package/dist/esm/utils/computeOffsets.js +60 -0
  64. package/dist/esm/utils/computeOffsets.js.map +7 -0
  65. package/dist/esm/utils/computePosition.js +75 -0
  66. package/dist/esm/utils/computePosition.js.map +7 -0
  67. package/dist/esm/utils/detectOverflow.js +52 -0
  68. package/dist/esm/utils/detectOverflow.js.map +7 -0
  69. package/dist/esm/utils/getAlteredPosition.js +14 -0
  70. package/dist/esm/utils/getAlteredPosition.js.map +7 -0
  71. package/dist/esm/utils/getArrowOffset.js +11 -0
  72. package/dist/esm/utils/getArrowOffset.js.map +7 -0
  73. package/dist/esm/utils/getExpandedFallbackPlacements.js +28 -0
  74. package/dist/esm/utils/getExpandedFallbackPlacements.js.map +7 -0
  75. package/dist/esm/utils/getOppositePlacement.js +14 -0
  76. package/dist/esm/utils/getOppositePlacement.js.map +7 -0
  77. package/dist/esm/utils/getOppositeVariationPlacement.js +16 -0
  78. package/dist/esm/utils/getOppositeVariationPlacement.js.map +7 -0
  79. package/dist/types/DSFloatingContext.d.ts +34 -0
  80. package/dist/types/index.d.ts +4 -0
  81. package/dist/types/parts/FloatingWrapper/FloatingWrapper.d.ts +5 -0
  82. package/dist/types/parts/FloatingWrapper/config/useFloatingWrapper.d.ts +12 -0
  83. package/dist/types/parts/FloatingWrapper/config/useValidateProps.d.ts +3 -0
  84. package/dist/types/parts/FloatingWrapper/constants/index.d.ts +4 -0
  85. package/dist/types/parts/FloatingWrapper/index.d.ts +1 -0
  86. package/dist/types/parts/FloatingWrapper/react-desc-prop-types.d.ts +30 -0
  87. package/dist/types/parts/FloatingWrapper/styled.d.ts +8 -0
  88. package/dist/types/parts/PopoverArrow.d.ts +8 -0
  89. package/dist/types/react-desc-prop-types.d.ts +23 -0
  90. package/dist/types/utils/computeOffsets.d.ts +5 -0
  91. package/dist/types/utils/computePosition.d.ts +23 -0
  92. package/dist/types/utils/detectOverflow.d.ts +7 -0
  93. package/dist/types/utils/getAlteredPosition.d.ts +1 -0
  94. package/dist/types/utils/getArrowOffset.d.ts +7 -0
  95. package/dist/types/utils/getExpandedFallbackPlacements.d.ts +2 -0
  96. package/dist/types/utils/getOppositePlacement.d.ts +1 -0
  97. package/dist/types/utils/getOppositeVariationPlacement.d.ts +1 -0
  98. package/package.json +68 -0
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var styled_exports = {};
30
+ __export(styled_exports, {
31
+ StyledFloatingAnimation: () => StyledFloatingAnimation,
32
+ StyledFloatingWrapper: () => StyledFloatingWrapper
33
+ });
34
+ module.exports = __toCommonJS(styled_exports);
35
+ var React = __toESM(require("react"));
36
+ var import_ds_system = require("@elliemae/ds-system");
37
+ var import_constants = require("./constants/index.js");
38
+ const showAnimation = import_ds_system.kfrm`
39
+ from {
40
+ opacity: 0;
41
+ transform: scale(0.8);
42
+ }
43
+
44
+ to {
45
+ opacity: 1;
46
+ transform: scale(1);
47
+ visibility: visible;
48
+ }
49
+ `;
50
+ const hideAnimation = import_ds_system.kfrm`
51
+ from {
52
+ opacity: 1;
53
+ transform: scale(1);
54
+ }
55
+
56
+ to {
57
+ opacity: 0;
58
+ transform: scale(0.8);
59
+ visibility: hidden;
60
+ }
61
+ `;
62
+ const StyledFloatingAnimation = import_ds_system.styled.div`
63
+ background-color: #fff;
64
+ box-shadow:
65
+ 0 0 0 1px rgba(16, 22, 26, 0.1),
66
+ 0 2px 4px rgba(16, 22, 26, 0.2),
67
+ 0 8px 24px rgba(16, 22, 26, 0.2);
68
+
69
+ ${({ isOpen, animationDuration, withoutAnimation }) => !withoutAnimation && import_ds_system.css`
70
+ animation: ${isOpen ? showAnimation : hideAnimation} ${animationDuration ?? 100}ms ease-in;
71
+ `}
72
+ `;
73
+ const StyledFloatingWrapper = (0, import_ds_system.styled)("div", {
74
+ name: import_constants.DSFloatingWrapperName,
75
+ slot: import_constants.DSFloatingWrapperSlots.ROOT
76
+ })``;
77
+ //# sourceMappingURL=styled.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/parts/FloatingWrapper/styled.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import { styled, css, kfrm } from '@elliemae/ds-system';\nimport { DSFloatingWrapperSlots, DSFloatingWrapperName } from './constants/index.js';\ninterface StyledAnimatedPopperPropsT {\n isOpen?: boolean;\n animationDuration?: number;\n withoutAnimation?: boolean;\n}\n\nconst showAnimation = kfrm`\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n\n to {\n opacity: 1;\n transform: scale(1);\n visibility: visible;\n }\n`;\n\nconst hideAnimation = kfrm`\n from {\n opacity: 1;\n transform: scale(1);\n }\n\n to {\n opacity: 0;\n transform: scale(0.8);\n visibility: hidden;\n }\n`;\n\nexport const StyledFloatingAnimation = styled.div<StyledAnimatedPopperPropsT>`\n background-color: #fff;\n box-shadow:\n 0 0 0 1px rgba(16, 22, 26, 0.1),\n 0 2px 4px rgba(16, 22, 26, 0.2),\n 0 8px 24px rgba(16, 22, 26, 0.2);\n\n ${({ isOpen, animationDuration, withoutAnimation }) =>\n !withoutAnimation &&\n css`\n animation: ${isOpen ? showAnimation : hideAnimation} ${animationDuration ?? 100}ms ease-in;\n `}\n`;\n\nexport const StyledFloatingWrapper = styled('div', {\n name: DSFloatingWrapperName,\n slot: DSFloatingWrapperSlots.ROOT,\n})``;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAkC;AAClC,uBAA8D;AAO9D,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAatB,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaf,MAAM,0BAA0B,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO1C,CAAC,EAAE,QAAQ,mBAAmB,iBAAiB,MAC/C,CAAC,oBACD;AAAA,mBACe,SAAS,gBAAgB,aAAa,IAAI,qBAAqB,GAAG;AAAA,KAChF;AAAA;AAGE,MAAM,4BAAwB,yBAAO,OAAO;AAAA,EACjD,MAAM;AAAA,EACN,MAAM,wCAAuB;AAC/B,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var PopoverArrow_exports = {};
30
+ __export(PopoverArrow_exports, {
31
+ PopoverArrow: () => PopoverArrow
32
+ });
33
+ module.exports = __toCommonJS(PopoverArrow_exports);
34
+ var React = __toESM(require("react"));
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_ds_system = require("@elliemae/ds-system");
37
+ const arrowWidth = 18;
38
+ const arrowHeight = 18;
39
+ const StyledArrow = import_ds_system.styled.div`
40
+ position: absolute;
41
+ width: ${arrowWidth}px;
42
+ height: ${arrowHeight}px;
43
+ pointer-events: none;
44
+ background-color: transparent;
45
+ & .stroke {
46
+ fill: rgb(105, 116, 137);
47
+ fill-opacity: 0.4;
48
+ }
49
+ & .fill {
50
+ fill: rgb(255, 255, 255);
51
+ }
52
+
53
+ &[data-placement^='top'] {
54
+ svg {
55
+ transform: rotateZ(180deg);
56
+ }
57
+ bottom: -${arrowHeight}px;
58
+ left: ${(props) => {
59
+ if (props["data-placement"].endsWith("start")) return `25%`;
60
+ if (props["data-placement"].endsWith("end")) return `75%`;
61
+ return "";
62
+ }};
63
+ }
64
+ &[data-placement^='right'] {
65
+ svg {
66
+ transform: rotateZ(-90deg);
67
+ }
68
+ left: -${arrowWidth}px;
69
+ }
70
+ &[data-placement^='bottom'] {
71
+ top: -${arrowHeight}px;
72
+ left: ${(props) => {
73
+ if (props["data-placement"].endsWith("start")) return `25%`;
74
+ if (props["data-placement"].endsWith("end")) return `75%`;
75
+ return "";
76
+ }};
77
+ }
78
+ &[data-placement^='left'] {
79
+ svg {
80
+ transform: rotateZ(90deg);
81
+ }
82
+ right: -${arrowWidth}px;
83
+ }
84
+ margin-left: ${(props) => props["data-placement"].startsWith("top") || props["data-placement"].startsWith("bottom") ? `-${arrowWidth / 2}px;` : "0;"};
85
+ margin-top: ${(props) => props["data-placement"].startsWith("left") || props["data-placement"].startsWith("right") ? `-${arrowHeight / 2}px;` : "0;"};
86
+ `;
87
+ const PopoverArrow = ({ placement, style, arrowElementRef }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
88
+ StyledArrow,
89
+ {
90
+ "data-placement": placement,
91
+ style,
92
+ innerRef: arrowElementRef,
93
+ "data-testid": "ds-tooltip-arrow",
94
+ "aria-hidden": "true",
95
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { viewBox: "0 0 30 30", children: [
96
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
97
+ "path",
98
+ {
99
+ className: "stroke",
100
+ d: "M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26\n C26.7,29,24.6,28.1,23.7,27.1z"
101
+ }
102
+ ),
103
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
104
+ "path",
105
+ {
106
+ className: "fill",
107
+ d: "M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z"
108
+ }
109
+ )
110
+ ] })
111
+ },
112
+ "popper-arrow"
113
+ );
114
+ //# sourceMappingURL=PopoverArrow.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/parts/PopoverArrow.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import React from 'react';\nimport { styled } from '@elliemae/ds-system';\n\ninterface PopoverArrowT {\n placement: string;\n style: React.CSSProperties;\n arrowElementRef?: React.Dispatch<React.SetStateAction<HTMLDivElement | null>>;\n}\nconst arrowWidth = 18;\nconst arrowHeight = 18;\n\nconst StyledArrow = styled.div<{ 'data-placement': string }>`\n position: absolute;\n width: ${arrowWidth}px;\n height: ${arrowHeight}px;\n pointer-events: none;\n background-color: transparent;\n & .stroke {\n fill: rgb(105, 116, 137);\n fill-opacity: 0.4;\n }\n & .fill {\n fill: rgb(255, 255, 255);\n }\n\n &[data-placement^='top'] {\n svg {\n transform: rotateZ(180deg);\n }\n bottom: -${arrowHeight}px;\n left: ${(props) => {\n if (props['data-placement'].endsWith('start')) return `25%`;\n if (props['data-placement'].endsWith('end')) return `75%`;\n return '';\n }};\n }\n &[data-placement^='right'] {\n svg {\n transform: rotateZ(-90deg);\n }\n left: -${arrowWidth}px;\n }\n &[data-placement^='bottom'] {\n top: -${arrowHeight}px;\n left: ${(props) => {\n if (props['data-placement'].endsWith('start')) return `25%`;\n if (props['data-placement'].endsWith('end')) return `75%`;\n return '';\n }};\n }\n &[data-placement^='left'] {\n svg {\n transform: rotateZ(90deg);\n }\n right: -${arrowWidth}px;\n }\n margin-left: ${(props) =>\n props['data-placement'].startsWith('top') || props['data-placement'].startsWith('bottom')\n ? `-${arrowWidth / 2}px;`\n : '0;'};\n margin-top: ${(props) =>\n props['data-placement'].startsWith('left') || props['data-placement'].startsWith('right')\n ? `-${arrowHeight / 2}px;`\n : '0;'};\n`;\n\nexport const PopoverArrow = ({ placement, style, arrowElementRef }: PopoverArrowT): React.ReactElement => (\n <StyledArrow\n key=\"popper-arrow\"\n data-placement={placement}\n style={style}\n innerRef={arrowElementRef}\n data-testid=\"ds-tooltip-arrow\"\n aria-hidden=\"true\"\n >\n <svg viewBox=\"0 0 30 30\">\n <path\n className=\"stroke\"\n d=\"M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26\n C26.7,29,24.6,28.1,23.7,27.1z\"\n />\n <path\n className=\"fill\"\n d=\"M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z\"\n />\n </svg>\n </StyledArrow>\n);\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD2EnB;AA1EJ,uBAAuB;AAOvB,MAAM,aAAa;AACnB,MAAM,cAAc;AAEpB,MAAM,cAAc,wBAAO;AAAA;AAAA,WAEhB,UAAU;AAAA,YACT,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAeR,WAAW;AAAA,YACd,CAAC,UAAU;AACjB,MAAI,MAAM,gBAAgB,EAAE,SAAS,OAAO,EAAG,QAAO;AACtD,MAAI,MAAM,gBAAgB,EAAE,SAAS,KAAK,EAAG,QAAO;AACpD,SAAO;AACT,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAMQ,UAAU;AAAA;AAAA;AAAA,YAGX,WAAW;AAAA,YACX,CAAC,UAAU;AACjB,MAAI,MAAM,gBAAgB,EAAE,SAAS,OAAO,EAAG,QAAO;AACtD,MAAI,MAAM,gBAAgB,EAAE,SAAS,KAAK,EAAG,QAAO;AACpD,SAAO;AACT,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAMS,UAAU;AAAA;AAAA,iBAEP,CAAC,UACd,MAAM,gBAAgB,EAAE,WAAW,KAAK,KAAK,MAAM,gBAAgB,EAAE,WAAW,QAAQ,IACpF,IAAI,aAAa,CAAC,QAClB,IAAI;AAAA,gBACI,CAAC,UACb,MAAM,gBAAgB,EAAE,WAAW,MAAM,KAAK,MAAM,gBAAgB,EAAE,WAAW,OAAO,IACpF,IAAI,cAAc,CAAC,QACnB,IAAI;AAAA;AAGL,MAAM,eAAe,CAAC,EAAE,WAAW,OAAO,gBAAgB,MAC/D;AAAA,EAAC;AAAA;AAAA,IAEC,kBAAgB;AAAA,IAChB;AAAA,IACA,UAAU;AAAA,IACV,eAAY;AAAA,IACZ,eAAY;AAAA,IAEZ,uDAAC,SAAI,SAAQ,aACX;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,GAAE;AAAA;AAAA,MAEJ;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,GAAE;AAAA;AAAA,MACJ;AAAA,OACF;AAAA;AAAA,EAjBI;AAkBN;",
6
+ "names": []
7
+ }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var react_desc_prop_types_exports = {};
30
+ __export(react_desc_prop_types_exports, {
31
+ DSFloatingContextPropTypes: () => DSFloatingContextPropTypes,
32
+ defaultProps: () => defaultProps
33
+ });
34
+ module.exports = __toCommonJS(react_desc_prop_types_exports);
35
+ var React = __toESM(require("react"));
36
+ var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
37
+ const defaultProps = {
38
+ withoutAnimation: false,
39
+ animationDuration: 300,
40
+ portalDOMContainer: document.body,
41
+ withoutPortal: false,
42
+ placement: "top",
43
+ customOffset: [12, 12]
44
+ };
45
+ const DSFloatingContextPropTypes = {
46
+ withoutPortal: import_ds_props_helpers.PropTypes.bool.description("If true, the tooltip will not be rendered inside a portal.").defaultValue(false),
47
+ withoutAnimation: import_ds_props_helpers.PropTypes.bool.description("If true, the tooltip will not have an animation.").defaultValue(false),
48
+ portalDOMContainer: import_ds_props_helpers.PropTypes.instanceOf(HTMLElement).description("The DOM element where the tooltip will be rendered.").defaultValue(document.body),
49
+ animationDuration: import_ds_props_helpers.PropTypes.number.description("The duration of the animation in milliseconds.").defaultValue(300),
50
+ placement: import_ds_props_helpers.PropTypes.oneOf([
51
+ "top-start",
52
+ "top",
53
+ "top-end",
54
+ "right-start",
55
+ "right",
56
+ "right-end",
57
+ "bottom-end",
58
+ "bottom",
59
+ "bottom-start",
60
+ "left-end",
61
+ "left",
62
+ "left-start"
63
+ ]).description("The placement of the tooltip.").defaultValue("top"),
64
+ customOffset: import_ds_props_helpers.PropTypes.arrayOf(import_ds_props_helpers.PropTypes.number).description("The custom offset of the tooltip.").defaultValue([12, 12]),
65
+ placementOrderPreference: import_ds_props_helpers.PropTypes.arrayOf(
66
+ import_ds_props_helpers.PropTypes.oneOf([
67
+ "top-start",
68
+ "top",
69
+ "top-end",
70
+ "right-start",
71
+ "right",
72
+ "right-end",
73
+ "bottom-end",
74
+ "bottom",
75
+ "bottom-start",
76
+ "left-end",
77
+ "left",
78
+ "left-start"
79
+ ])
80
+ ).description("The order of the placement preference."),
81
+ onOpen: import_ds_props_helpers.PropTypes.func.description("Callback when the tooltip is opened."),
82
+ onClose: import_ds_props_helpers.PropTypes.func.description("Callback when the tooltip is closed.")
83
+ };
84
+ //# sourceMappingURL=react-desc-prop-types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/react-desc-prop-types.ts", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type { DSPropTypesSchema } from '@elliemae/ds-props-helpers';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\nexport declare namespace DSHookFloatingContextT {\n export interface DefaultProps {\n withoutPortal: boolean;\n withoutAnimation: boolean;\n portalDOMContainer: HTMLElement;\n animationDuration: number;\n placement: PopperPlacementsT;\n customOffset: [number, number];\n }\n\n export interface OptionalProps {\n placementOrderPreference?: PopperPlacementsT[];\n onOpen?: () => void;\n onClose?: () => void;\n }\n export interface Props extends Partial<DefaultProps>, OptionalProps {}\n\n export interface InternalProps extends DefaultProps, OptionalProps {}\n\n export type PopperPlacementsT =\n | 'top-start'\n | 'top'\n | 'top-end'\n | 'right-start'\n | 'right'\n | 'right-end'\n | 'bottom-end'\n | 'bottom'\n | 'bottom-start'\n | 'left-end'\n | 'left'\n | 'left-start';\n}\n\nexport const defaultProps: DSHookFloatingContextT.DefaultProps = {\n withoutAnimation: false,\n animationDuration: 300,\n portalDOMContainer: document.body,\n withoutPortal: false,\n placement: 'top',\n customOffset: [12, 12],\n};\n\nexport const DSFloatingContextPropTypes: DSPropTypesSchema<DSHookFloatingContextT.Props> = {\n withoutPortal: PropTypes.bool\n .description('If true, the tooltip will not be rendered inside a portal.')\n .defaultValue(false),\n withoutAnimation: PropTypes.bool.description('If true, the tooltip will not have an animation.').defaultValue(false),\n portalDOMContainer: PropTypes.instanceOf(HTMLElement)\n .description('The DOM element where the tooltip will be rendered.')\n .defaultValue(document.body),\n animationDuration: PropTypes.number.description('The duration of the animation in milliseconds.').defaultValue(300),\n placement: PropTypes.oneOf([\n 'top-start',\n 'top',\n 'top-end',\n 'right-start',\n 'right',\n 'right-end',\n 'bottom-end',\n 'bottom',\n 'bottom-start',\n 'left-end',\n 'left',\n 'left-start',\n ])\n .description('The placement of the tooltip.')\n .defaultValue('top'),\n customOffset: PropTypes.arrayOf(PropTypes.number)\n .description('The custom offset of the tooltip.')\n .defaultValue([12, 12]),\n placementOrderPreference: PropTypes.arrayOf(\n PropTypes.oneOf([\n 'top-start',\n 'top',\n 'top-end',\n 'right-start',\n 'right',\n 'right-end',\n 'bottom-end',\n 'bottom',\n 'bottom-start',\n 'left-end',\n 'left',\n 'left-start',\n ]),\n ).description('The order of the placement preference.'),\n onOpen: PropTypes.func.description('Callback when the tooltip is opened.'),\n onClose: PropTypes.func.description('Callback when the tooltip is closed.'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,8BAA0B;AAmCnB,MAAM,eAAoD;AAAA,EAC/D,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,oBAAoB,SAAS;AAAA,EAC7B,eAAe;AAAA,EACf,WAAW;AAAA,EACX,cAAc,CAAC,IAAI,EAAE;AACvB;AAEO,MAAM,6BAA8E;AAAA,EACzF,eAAe,kCAAU,KACtB,YAAY,4DAA4D,EACxE,aAAa,KAAK;AAAA,EACrB,kBAAkB,kCAAU,KAAK,YAAY,kDAAkD,EAAE,aAAa,KAAK;AAAA,EACnH,oBAAoB,kCAAU,WAAW,WAAW,EACjD,YAAY,qDAAqD,EACjE,aAAa,SAAS,IAAI;AAAA,EAC7B,mBAAmB,kCAAU,OAAO,YAAY,gDAAgD,EAAE,aAAa,GAAG;AAAA,EAClH,WAAW,kCAAU,MAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC,EACE,YAAY,+BAA+B,EAC3C,aAAa,KAAK;AAAA,EACrB,cAAc,kCAAU,QAAQ,kCAAU,MAAM,EAC7C,YAAY,mCAAmC,EAC/C,aAAa,CAAC,IAAI,EAAE,CAAC;AAAA,EACxB,0BAA0B,kCAAU;AAAA,IAClC,kCAAU,MAAM;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,EAAE,YAAY,wCAAwC;AAAA,EACtD,QAAQ,kCAAU,KAAK,YAAY,sCAAsC;AAAA,EACzE,SAAS,kCAAU,KAAK,YAAY,sCAAsC;AAC5E;",
6
+ "names": []
7
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var computeOffsets_exports = {};
30
+ __export(computeOffsets_exports, {
31
+ default: () => computeOffsets
32
+ });
33
+ module.exports = __toCommonJS(computeOffsets_exports);
34
+ var React = __toESM(require("react"));
35
+ function getMainAxisFromPlacement(placement) {
36
+ return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
37
+ }
38
+ function computeOffsets(placement, referenceRect, floatingRect) {
39
+ const basePlacement = placement.split("-")[0];
40
+ const constiation = placement.split("-")[1];
41
+ const commonX = referenceRect.x + referenceRect.width / 2 - floatingRect.width / 2;
42
+ const commonY = referenceRect.y + referenceRect.height / 2 - floatingRect.height / 2;
43
+ let offsets = { x: 0, y: 0 };
44
+ switch (basePlacement) {
45
+ case "top":
46
+ offsets = {
47
+ x: commonX,
48
+ y: referenceRect.y - floatingRect.height
49
+ };
50
+ break;
51
+ case "bottom":
52
+ offsets = {
53
+ x: commonX,
54
+ y: referenceRect.y + referenceRect.height
55
+ };
56
+ break;
57
+ case "right":
58
+ offsets = {
59
+ x: referenceRect.x + referenceRect.width,
60
+ y: commonY
61
+ };
62
+ break;
63
+ case "left":
64
+ offsets = {
65
+ x: referenceRect.x - floatingRect.width,
66
+ y: commonY
67
+ };
68
+ break;
69
+ default:
70
+ offsets = {
71
+ x: referenceRect.x,
72
+ y: referenceRect.y
73
+ };
74
+ }
75
+ const mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
76
+ if (mainAxis != null) {
77
+ const len = mainAxis === "y" ? "height" : "width";
78
+ switch (constiation) {
79
+ case "start":
80
+ offsets[mainAxis] = offsets[mainAxis] - (referenceRect[len] / 2 - floatingRect[len] / 2);
81
+ break;
82
+ case "end":
83
+ offsets[mainAxis] = offsets[mainAxis] + (referenceRect[len] / 2 - floatingRect[len] / 2);
84
+ break;
85
+ default:
86
+ }
87
+ }
88
+ return offsets;
89
+ }
90
+ //# sourceMappingURL=computeOffsets.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/computeOffsets.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["/* eslint-disable operator-assignment */\nimport type { DSHookFloatingContextT } from '../react-desc-prop-types.js';\n\nfunction getMainAxisFromPlacement(placement: DSHookFloatingContextT.PopperPlacementsT) {\n return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';\n}\n\nexport default function computeOffsets(\n placement: DSHookFloatingContextT.PopperPlacementsT,\n referenceRect: DOMRect,\n floatingRect: DOMRect,\n) {\n const basePlacement = placement.split('-')[0];\n const constiation = placement.split('-')[1];\n const commonX = referenceRect.x + referenceRect.width / 2 - floatingRect.width / 2;\n const commonY = referenceRect.y + referenceRect.height / 2 - floatingRect.height / 2;\n let offsets: { x: number; y: number } = { x: 0, y: 0 };\n\n switch (basePlacement) {\n case 'top':\n offsets = {\n x: commonX,\n y: referenceRect.y - floatingRect.height,\n };\n break;\n\n case 'bottom':\n offsets = {\n x: commonX,\n y: referenceRect.y + referenceRect.height,\n };\n break;\n\n case 'right':\n offsets = {\n x: referenceRect.x + referenceRect.width,\n y: commonY,\n };\n break;\n\n case 'left':\n offsets = {\n x: referenceRect.x - floatingRect.width,\n y: commonY,\n };\n break;\n\n default:\n offsets = {\n x: referenceRect.x,\n y: referenceRect.y,\n };\n }\n\n const mainAxis = basePlacement\n ? getMainAxisFromPlacement(basePlacement as DSHookFloatingContextT.PopperPlacementsT)\n : null;\n\n if (mainAxis != null) {\n const len = mainAxis === 'y' ? 'height' : 'width';\n\n switch (constiation) {\n case 'start':\n offsets[mainAxis] = offsets[mainAxis] - (referenceRect[len] / 2 - floatingRect[len] / 2);\n\n break;\n\n case 'end':\n offsets[mainAxis] = offsets[mainAxis] + (referenceRect[len] / 2 - floatingRect[len] / 2);\n break;\n\n default:\n }\n }\n\n return offsets;\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,SAAS,yBAAyB,WAAqD;AACrF,SAAO,CAAC,OAAO,QAAQ,EAAE,QAAQ,SAAS,KAAK,IAAI,MAAM;AAC3D;AAEe,SAAR,eACL,WACA,eACA,cACA;AACA,QAAM,gBAAgB,UAAU,MAAM,GAAG,EAAE,CAAC;AAC5C,QAAM,cAAc,UAAU,MAAM,GAAG,EAAE,CAAC;AAC1C,QAAM,UAAU,cAAc,IAAI,cAAc,QAAQ,IAAI,aAAa,QAAQ;AACjF,QAAM,UAAU,cAAc,IAAI,cAAc,SAAS,IAAI,aAAa,SAAS;AACnF,MAAI,UAAoC,EAAE,GAAG,GAAG,GAAG,EAAE;AAErD,UAAQ,eAAe;AAAA,IACrB,KAAK;AACH,gBAAU;AAAA,QACR,GAAG;AAAA,QACH,GAAG,cAAc,IAAI,aAAa;AAAA,MACpC;AACA;AAAA,IAEF,KAAK;AACH,gBAAU;AAAA,QACR,GAAG;AAAA,QACH,GAAG,cAAc,IAAI,cAAc;AAAA,MACrC;AACA;AAAA,IAEF,KAAK;AACH,gBAAU;AAAA,QACR,GAAG,cAAc,IAAI,cAAc;AAAA,QACnC,GAAG;AAAA,MACL;AACA;AAAA,IAEF,KAAK;AACH,gBAAU;AAAA,QACR,GAAG,cAAc,IAAI,aAAa;AAAA,QAClC,GAAG;AAAA,MACL;AACA;AAAA,IAEF;AACE,gBAAU;AAAA,QACR,GAAG,cAAc;AAAA,QACjB,GAAG,cAAc;AAAA,MACnB;AAAA,EACJ;AAEA,QAAM,WAAW,gBACb,yBAAyB,aAAyD,IAClF;AAEJ,MAAI,YAAY,MAAM;AACpB,UAAM,MAAM,aAAa,MAAM,WAAW;AAE1C,YAAQ,aAAa;AAAA,MACnB,KAAK;AACH,gBAAQ,QAAQ,IAAI,QAAQ,QAAQ,KAAK,cAAc,GAAG,IAAI,IAAI,aAAa,GAAG,IAAI;AAEtF;AAAA,MAEF,KAAK;AACH,gBAAQ,QAAQ,IAAI,QAAQ,QAAQ,KAAK,cAAc,GAAG,IAAI,IAAI,aAAa,GAAG,IAAI;AACtF;AAAA,MAEF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var computePosition_exports = {};
30
+ __export(computePosition_exports, {
31
+ computePosition: () => computePosition
32
+ });
33
+ module.exports = __toCommonJS(computePosition_exports);
34
+ var React = __toESM(require("react"));
35
+ var import_getExpandedFallbackPlacements = require("./getExpandedFallbackPlacements.js");
36
+ var import_getArrowOffset = require("./getArrowOffset.js");
37
+ var import_getOppositePlacement = __toESM(require("./getOppositePlacement.js"));
38
+ var import_detectOverflow = require("./detectOverflow.js");
39
+ const findFixedParent = (el) => {
40
+ let element = el;
41
+ while (element && element !== document.body) {
42
+ const style = getComputedStyle(element);
43
+ if (style.position === "fixed" || style.position === "absolute") {
44
+ return element;
45
+ }
46
+ element = element.parentElement;
47
+ }
48
+ return null;
49
+ };
50
+ const adjustForFixedParent = (child) => {
51
+ const fixedParent = findFixedParent(child);
52
+ if (fixedParent) {
53
+ const rect = fixedParent.getBoundingClientRect();
54
+ return { top: rect.top, left: rect.left };
55
+ }
56
+ return {
57
+ top: 0,
58
+ left: 0
59
+ };
60
+ };
61
+ const computePosition = (props) => {
62
+ const { reference, floating, placement, placementOrderPreference, customOffset, withoutPortal } = props;
63
+ const parentOffsets = withoutPortal ? adjustForFixedParent(reference) : {
64
+ top: 0,
65
+ left: 0
66
+ };
67
+ const referenceRect = reference.getBoundingClientRect();
68
+ const floatingRect = floating.getBoundingClientRect();
69
+ const variationPlacement = placement.split("-")[1];
70
+ const fallbackPlacements = placementOrderPreference || (0, import_getExpandedFallbackPlacements.getExpandedFallbackPlacements)(placement);
71
+ const coords = {};
72
+ let isVertical = false;
73
+ const placements = [placement].concat(fallbackPlacements);
74
+ let finalPlacement = "";
75
+ for (let i = 0; i < placements.length; i += 1) {
76
+ const currentPlacement = placements[i];
77
+ const currentBasePlacement = currentPlacement.split("-")[0];
78
+ isVertical = ["top", "bottom"].indexOf(currentBasePlacement) >= 0;
79
+ const overflows = (0, import_detectOverflow.detectOverflow)(referenceRect, floatingRect, currentPlacement, customOffset);
80
+ const checks = [];
81
+ const isStartVariation = variationPlacement === "start";
82
+ let mainVariationSide = isVertical ? isStartVariation ? "right" : "left" : isStartVariation ? "bottom" : "top";
83
+ const len = isVertical ? "width" : "height";
84
+ if (referenceRect[len] > floatingRect[len]) {
85
+ mainVariationSide = (0, import_getOppositePlacement.default)(mainVariationSide);
86
+ }
87
+ const altVariationSide = (0, import_getOppositePlacement.default)(mainVariationSide);
88
+ checks.push(overflows[currentBasePlacement] <= 0);
89
+ checks.push(overflows[mainVariationSide] <= 0, overflows[altVariationSide] <= 0);
90
+ if (checks.every((check) => {
91
+ return check;
92
+ })) {
93
+ coords.top = -overflows.top + window.scrollY - parentOffsets.top;
94
+ coords.left = -overflows.left + window.scrollX - parentOffsets.left;
95
+ finalPlacement = currentPlacement;
96
+ break;
97
+ }
98
+ }
99
+ return {
100
+ coordsStyle: { transform: `translate(${coords.left}px, ${coords.top}px)` },
101
+ finalPlacement,
102
+ coordsArrow: (0, import_getArrowOffset.getArrowOffset)(finalPlacement, isVertical)
103
+ };
104
+ };
105
+ //# sourceMappingURL=computePosition.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/computePosition.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["/* eslint-disable no-nested-ternary */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable max-params */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable arrow-body-style */\nimport type { DSHookFloatingContextT } from '../react-desc-prop-types.js';\nimport { getExpandedFallbackPlacements } from './getExpandedFallbackPlacements.js';\nimport { getArrowOffset } from './getArrowOffset.js';\nimport getOppositePlacement from './getOppositePlacement.js';\nimport { detectOverflow } from './detectOverflow.js';\n\ninterface ComputePositionProps {\n reference: Element;\n floating: HTMLElement;\n placement: DSHookFloatingContextT.PopperPlacementsT;\n placementOrderPreference?: DSHookFloatingContextT.PopperPlacementsT[];\n customOffset: [number, number];\n withoutPortal: boolean;\n}\n\nconst findFixedParent = (el: Element | null) => {\n let element = el;\n while (element && element !== document.body) {\n const style = getComputedStyle(element);\n if (style.position === 'fixed' || style.position === 'absolute') {\n return element;\n }\n element = element.parentElement;\n }\n return null;\n};\n\nconst adjustForFixedParent = (child: Element) => {\n const fixedParent = findFixedParent(child);\n if (fixedParent) {\n const rect = fixedParent.getBoundingClientRect();\n return { top: rect.top, left: rect.left };\n }\n return {\n top: 0,\n left: 0,\n };\n};\n\nexport const computePosition = (props: ComputePositionProps) => {\n const { reference, floating, placement, placementOrderPreference, customOffset, withoutPortal } = props;\n\n const parentOffsets = withoutPortal\n ? adjustForFixedParent(reference)\n : {\n top: 0,\n left: 0,\n };\n const referenceRect = reference.getBoundingClientRect();\n const floatingRect = floating.getBoundingClientRect();\n\n const variationPlacement = placement.split('-')[1];\n const fallbackPlacements = placementOrderPreference || getExpandedFallbackPlacements(placement);\n\n const coords: { top?: number; left?: number; bottom?: number; right?: number } = {};\n\n let isVertical = false;\n const placements = [placement].concat(fallbackPlacements as DSHookFloatingContextT.PopperPlacementsT[]);\n let finalPlacement = '';\n\n for (let i = 0; i < placements.length; i += 1) {\n const currentPlacement = placements[i];\n\n const currentBasePlacement = currentPlacement.split('-')[0] as keyof typeof coords;\n isVertical = ['top', 'bottom'].indexOf(currentBasePlacement) >= 0;\n\n const overflows = detectOverflow(referenceRect, floatingRect, currentPlacement, customOffset);\n\n const checks: boolean[] = [];\n\n const isStartVariation = variationPlacement === 'start';\n\n let mainVariationSide: keyof typeof coords = isVertical\n ? isStartVariation\n ? 'right'\n : 'left'\n : isStartVariation\n ? 'bottom'\n : 'top';\n\n const len = isVertical ? 'width' : 'height';\n\n if (referenceRect[len] > floatingRect[len]) {\n mainVariationSide = getOppositePlacement(mainVariationSide) as keyof typeof coords;\n }\n\n const altVariationSide = getOppositePlacement(mainVariationSide) as keyof typeof coords;\n\n checks.push(overflows[currentBasePlacement] <= 0);\n checks.push(overflows[mainVariationSide] <= 0, overflows[altVariationSide] <= 0);\n\n if (\n checks.every((check) => {\n return check;\n })\n ) {\n coords.top = -overflows.top + window.scrollY - parentOffsets.top;\n coords.left = -overflows.left + window.scrollX - parentOffsets.left;\n finalPlacement = currentPlacement;\n\n break;\n }\n }\n\n return {\n coordsStyle: { transform: `translate(${coords.left}px, ${coords.top}px)` },\n finalPlacement,\n coordsArrow: getArrowOffset(finalPlacement, isVertical),\n };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADQvB,2CAA8C;AAC9C,4BAA+B;AAC/B,kCAAiC;AACjC,4BAA+B;AAW/B,MAAM,kBAAkB,CAAC,OAAuB;AAC9C,MAAI,UAAU;AACd,SAAO,WAAW,YAAY,SAAS,MAAM;AAC3C,UAAM,QAAQ,iBAAiB,OAAO;AACtC,QAAI,MAAM,aAAa,WAAW,MAAM,aAAa,YAAY;AAC/D,aAAO;AAAA,IACT;AACA,cAAU,QAAQ;AAAA,EACpB;AACA,SAAO;AACT;AAEA,MAAM,uBAAuB,CAAC,UAAmB;AAC/C,QAAM,cAAc,gBAAgB,KAAK;AACzC,MAAI,aAAa;AACf,UAAM,OAAO,YAAY,sBAAsB;AAC/C,WAAO,EAAE,KAAK,KAAK,KAAK,MAAM,KAAK,KAAK;AAAA,EAC1C;AACA,SAAO;AAAA,IACL,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AACF;AAEO,MAAM,kBAAkB,CAAC,UAAgC;AAC9D,QAAM,EAAE,WAAW,UAAU,WAAW,0BAA0B,cAAc,cAAc,IAAI;AAElG,QAAM,gBAAgB,gBAClB,qBAAqB,SAAS,IAC9B;AAAA,IACE,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AACJ,QAAM,gBAAgB,UAAU,sBAAsB;AACtD,QAAM,eAAe,SAAS,sBAAsB;AAEpD,QAAM,qBAAqB,UAAU,MAAM,GAAG,EAAE,CAAC;AACjD,QAAM,qBAAqB,gCAA4B,oEAA8B,SAAS;AAE9F,QAAM,SAA2E,CAAC;AAElF,MAAI,aAAa;AACjB,QAAM,aAAa,CAAC,SAAS,EAAE,OAAO,kBAAgE;AACtG,MAAI,iBAAiB;AAErB,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK,GAAG;AAC7C,UAAM,mBAAmB,WAAW,CAAC;AAErC,UAAM,uBAAuB,iBAAiB,MAAM,GAAG,EAAE,CAAC;AAC1D,iBAAa,CAAC,OAAO,QAAQ,EAAE,QAAQ,oBAAoB,KAAK;AAEhE,UAAM,gBAAY,sCAAe,eAAe,cAAc,kBAAkB,YAAY;AAE5F,UAAM,SAAoB,CAAC;AAE3B,UAAM,mBAAmB,uBAAuB;AAEhD,QAAI,oBAAyC,aACzC,mBACE,UACA,SACF,mBACA,WACA;AAEJ,UAAM,MAAM,aAAa,UAAU;AAEnC,QAAI,cAAc,GAAG,IAAI,aAAa,GAAG,GAAG;AAC1C,8BAAoB,4BAAAA,SAAqB,iBAAiB;AAAA,IAC5D;AAEA,UAAM,uBAAmB,4BAAAA,SAAqB,iBAAiB;AAE/D,WAAO,KAAK,UAAU,oBAAoB,KAAK,CAAC;AAChD,WAAO,KAAK,UAAU,iBAAiB,KAAK,GAAG,UAAU,gBAAgB,KAAK,CAAC;AAE/E,QACE,OAAO,MAAM,CAAC,UAAU;AACtB,aAAO;AAAA,IACT,CAAC,GACD;AACA,aAAO,MAAM,CAAC,UAAU,MAAM,OAAO,UAAU,cAAc;AAC7D,aAAO,OAAO,CAAC,UAAU,OAAO,OAAO,UAAU,cAAc;AAC/D,uBAAiB;AAEjB;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,aAAa,EAAE,WAAW,aAAa,OAAO,IAAI,OAAO,OAAO,GAAG,MAAM;AAAA,IACzE;AAAA,IACA,iBAAa,sCAAe,gBAAgB,UAAU;AAAA,EACxD;AACF;",
6
+ "names": ["getOppositePlacement"]
7
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var detectOverflow_exports = {};
30
+ __export(detectOverflow_exports, {
31
+ detectOverflow: () => detectOverflow
32
+ });
33
+ module.exports = __toCommonJS(detectOverflow_exports);
34
+ var React = __toESM(require("react"));
35
+ var import_computeOffsets = __toESM(require("./computeOffsets.js"));
36
+ const paddingObject = { top: 0, right: 0, bottom: 0, left: 0 };
37
+ function rectToClientRect(rect) {
38
+ return { ...rect, left: rect.x, top: rect.y, right: rect.x + rect.width, bottom: rect.y + rect.height };
39
+ }
40
+ function domRectToObject(rect) {
41
+ return {
42
+ x: rect.x,
43
+ y: rect.y,
44
+ width: rect.width,
45
+ height: rect.height,
46
+ top: rect.top,
47
+ right: rect.right,
48
+ bottom: rect.bottom,
49
+ left: rect.left,
50
+ toJSON: () => {
51
+ }
52
+ };
53
+ }
54
+ const detectOverflow = (referenceRect, floatingRect, placement, customOffset) => {
55
+ const basePlacement = placement.split("-")[0];
56
+ const isVertical = ["top", "bottom"].indexOf(basePlacement) >= 0;
57
+ const clippingClientRect = {
58
+ top: 0,
59
+ right: document.documentElement.clientWidth,
60
+ bottom: document.documentElement.clientHeight,
61
+ left: 0
62
+ };
63
+ const popperOffsets = (0, import_computeOffsets.default)(placement, referenceRect, floatingRect);
64
+ const popperClientRect = rectToClientRect({ ...domRectToObject(floatingRect), ...popperOffsets });
65
+ const overflowOffsets = {
66
+ top: clippingClientRect.top - popperClientRect.top + paddingObject.top,
67
+ bottom: popperClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
68
+ left: clippingClientRect.left - popperClientRect.left + paddingObject.left,
69
+ right: popperClientRect.right - clippingClientRect.right + paddingObject.right
70
+ };
71
+ const offset = {
72
+ x: !isVertical ? basePlacement === "left" ? -(customOffset?.[0] ?? 12) : customOffset?.[0] ?? 12 : 0,
73
+ y: isVertical ? basePlacement === "top" ? -(customOffset?.[1] ?? 12) : customOffset?.[1] ?? 12 : 0
74
+ };
75
+ Object.keys(overflowOffsets).forEach((key) => {
76
+ const multiply = ["right", "bottom"].indexOf(key) >= 0 ? 1 : -1;
77
+ const axis = ["top", "bottom"].indexOf(key) >= 0 ? "y" : "x";
78
+ overflowOffsets[key] += offset[axis] * multiply;
79
+ });
80
+ return overflowOffsets;
81
+ };
82
+ //# sourceMappingURL=detectOverflow.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/detectOverflow.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["/* eslint-disable no-nested-ternary */\n/* eslint-disable max-params */\nimport { type DSHookFloatingContextT } from '../react-desc-prop-types.js';\nimport computeOffsets from './computeOffsets.js';\n\nconst paddingObject = { top: 0, right: 0, bottom: 0, left: 0 };\n\nfunction rectToClientRect(rect: DOMRect) {\n return { ...rect, left: rect.x, top: rect.y, right: rect.x + rect.width, bottom: rect.y + rect.height };\n}\n\nfunction domRectToObject(rect: {\n x: number;\n y: number;\n width: number;\n height: number;\n top: number;\n right: number;\n bottom: number;\n left: number;\n}): DOMRect {\n return {\n x: rect.x,\n y: rect.y,\n width: rect.width,\n height: rect.height,\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom,\n left: rect.left,\n toJSON: () => {},\n };\n}\n\nexport const detectOverflow = (\n referenceRect: DOMRect,\n floatingRect: DOMRect,\n placement: DSHookFloatingContextT.PopperPlacementsT,\n customOffset: [number, number],\n) => {\n const basePlacement = placement.split('-')[0];\n const isVertical = ['top', 'bottom'].indexOf(basePlacement) >= 0;\n const clippingClientRect = {\n top: 0,\n right: document.documentElement.clientWidth,\n bottom: document.documentElement.clientHeight,\n left: 0,\n };\n const popperOffsets = computeOffsets(placement, referenceRect, floatingRect);\n const popperClientRect = rectToClientRect({ ...domRectToObject(floatingRect), ...popperOffsets });\n\n const overflowOffsets = {\n top: clippingClientRect.top - popperClientRect.top + paddingObject.top,\n bottom: popperClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,\n left: clippingClientRect.left - popperClientRect.left + paddingObject.left,\n right: popperClientRect.right - clippingClientRect.right + paddingObject.right,\n };\n\n const offset = {\n x: !isVertical ? (basePlacement === 'left' ? -(customOffset?.[0] ?? 12) : customOffset?.[0] ?? 12) : 0,\n y: isVertical ? (basePlacement === 'top' ? -(customOffset?.[1] ?? 12) : customOffset?.[1] ?? 12) : 0,\n };\n\n Object.keys(overflowOffsets).forEach((key) => {\n const multiply = ['right', 'bottom'].indexOf(key) >= 0 ? 1 : -1;\n const axis = ['top', 'bottom'].indexOf(key) >= 0 ? 'y' : 'x';\n overflowOffsets[key as keyof typeof overflowOffsets] += offset[axis] * multiply;\n });\n return overflowOffsets;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,4BAA2B;AAE3B,MAAM,gBAAgB,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,EAAE;AAE7D,SAAS,iBAAiB,MAAe;AACvC,SAAO,EAAE,GAAG,MAAM,MAAM,KAAK,GAAG,KAAK,KAAK,GAAG,OAAO,KAAK,IAAI,KAAK,OAAO,QAAQ,KAAK,IAAI,KAAK,OAAO;AACxG;AAEA,SAAS,gBAAgB,MASb;AACV,SAAO;AAAA,IACL,GAAG,KAAK;AAAA,IACR,GAAG,KAAK;AAAA,IACR,OAAO,KAAK;AAAA,IACZ,QAAQ,KAAK;AAAA,IACb,KAAK,KAAK;AAAA,IACV,OAAO,KAAK;AAAA,IACZ,QAAQ,KAAK;AAAA,IACb,MAAM,KAAK;AAAA,IACX,QAAQ,MAAM;AAAA,IAAC;AAAA,EACjB;AACF;AAEO,MAAM,iBAAiB,CAC5B,eACA,cACA,WACA,iBACG;AACH,QAAM,gBAAgB,UAAU,MAAM,GAAG,EAAE,CAAC;AAC5C,QAAM,aAAa,CAAC,OAAO,QAAQ,EAAE,QAAQ,aAAa,KAAK;AAC/D,QAAM,qBAAqB;AAAA,IACzB,KAAK;AAAA,IACL,OAAO,SAAS,gBAAgB;AAAA,IAChC,QAAQ,SAAS,gBAAgB;AAAA,IACjC,MAAM;AAAA,EACR;AACA,QAAM,oBAAgB,sBAAAA,SAAe,WAAW,eAAe,YAAY;AAC3E,QAAM,mBAAmB,iBAAiB,EAAE,GAAG,gBAAgB,YAAY,GAAG,GAAG,cAAc,CAAC;AAEhG,QAAM,kBAAkB;AAAA,IACtB,KAAK,mBAAmB,MAAM,iBAAiB,MAAM,cAAc;AAAA,IACnE,QAAQ,iBAAiB,SAAS,mBAAmB,SAAS,cAAc;AAAA,IAC5E,MAAM,mBAAmB,OAAO,iBAAiB,OAAO,cAAc;AAAA,IACtE,OAAO,iBAAiB,QAAQ,mBAAmB,QAAQ,cAAc;AAAA,EAC3E;AAEA,QAAM,SAAS;AAAA,IACb,GAAG,CAAC,aAAc,kBAAkB,SAAS,EAAE,eAAe,CAAC,KAAK,MAAM,eAAe,CAAC,KAAK,KAAM;AAAA,IACrG,GAAG,aAAc,kBAAkB,QAAQ,EAAE,eAAe,CAAC,KAAK,MAAM,eAAe,CAAC,KAAK,KAAM;AAAA,EACrG;AAEA,SAAO,KAAK,eAAe,EAAE,QAAQ,CAAC,QAAQ;AAC5C,UAAM,WAAW,CAAC,SAAS,QAAQ,EAAE,QAAQ,GAAG,KAAK,IAAI,IAAI;AAC7D,UAAM,OAAO,CAAC,OAAO,QAAQ,EAAE,QAAQ,GAAG,KAAK,IAAI,MAAM;AACzD,oBAAgB,GAAmC,KAAK,OAAO,IAAI,IAAI;AAAA,EACzE,CAAC;AACD,SAAO;AACT;",
6
+ "names": ["computeOffsets"]
7
+ }