@fluentui/react-positioning 0.0.0-nightly-20230316-0427.1 → 0.0.0-nightly-20230317-1454.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.
- package/.swcrc +39 -0
- package/CHANGELOG.json +24 -9
- package/CHANGELOG.md +16 -7
- package/lib/constants.js +4 -4
- package/lib/constants.js.map +1 -1
- package/lib/createArrowStyles.js +19 -19
- package/lib/createArrowStyles.js.map +1 -1
- package/lib/createPositionManager.js +13 -13
- package/lib/createPositionManager.js.map +1 -1
- package/lib/createVirtualElementFromClick.js +1 -2
- package/lib/createVirtualElementFromClick.js.map +1 -1
- package/lib/index.js +5 -5
- package/lib/index.js.map +1 -1
- package/lib/middleware/coverTarget.js +6 -6
- package/lib/middleware/coverTarget.js.map +1 -1
- package/lib/middleware/flip.js +4 -4
- package/lib/middleware/flip.js.map +1 -1
- package/lib/middleware/index.js +6 -6
- package/lib/middleware/index.js.map +1 -1
- package/lib/middleware/intersecting.js +2 -2
- package/lib/middleware/intersecting.js.map +1 -1
- package/lib/middleware/maxSize.js +8 -8
- package/lib/middleware/maxSize.js.map +1 -1
- package/lib/middleware/offset.js +2 -2
- package/lib/middleware/offset.js.map +1 -1
- package/lib/middleware/shift.js +5 -5
- package/lib/middleware/shift.js.map +1 -1
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/usePositioning.js +20 -26
- package/lib/usePositioning.js.map +1 -1
- package/lib/usePositioningMouseTarget.js +4 -4
- package/lib/usePositioningMouseTarget.js.map +1 -1
- package/lib/utils/debounce.js +1 -2
- package/lib/utils/debounce.js.map +1 -1
- package/lib/utils/fromFloatingUIPlacement.js +10 -10
- package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib/utils/getBoundary.js +8 -8
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/getFloatingUIOffset.js +2 -2
- package/lib/utils/getFloatingUIOffset.js.map +1 -1
- package/lib/utils/getReactFiberFromNode.js +3 -2
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js +7 -10
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/hasAutoFocusFilter.js +3 -4
- package/lib/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib/utils/index.js +15 -15
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeArrowOffset.js +6 -8
- package/lib/utils/mergeArrowOffset.js.map +1 -1
- package/lib/utils/parseFloatingUIPlacement.js +2 -3
- package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.js +33 -33
- package/lib/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib/utils/toFloatingUIPadding.js +3 -3
- package/lib/utils/toFloatingUIPadding.js.map +1 -1
- package/lib/utils/toFloatingUIPlacement.js +11 -11
- package/lib/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib/utils/toggleScrollListener.js +4 -4
- package/lib/utils/toggleScrollListener.js.map +1 -1
- package/lib/utils/useCallbackRef.js +2 -2
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib/utils/writeArrowUpdates.js +1 -2
- package/lib/utils/writeArrowUpdates.js.map +1 -1
- package/lib/utils/writeContainerupdates.js +7 -8
- package/lib/utils/writeContainerupdates.js.map +1 -1
- package/lib-commonjs/constants.js +18 -7
- package/lib-commonjs/constants.js.map +1 -1
- package/lib-commonjs/createArrowStyles.js +60 -88
- package/lib-commonjs/createArrowStyles.js.map +1 -1
- package/lib-commonjs/createPositionManager.js +103 -117
- package/lib-commonjs/createPositionManager.js.map +1 -1
- package/lib-commonjs/createVirtualElementFromClick.js +27 -26
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
- package/lib-commonjs/index.js +24 -51
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/middleware/coverTarget.js +34 -37
- package/lib-commonjs/middleware/coverTarget.js.map +1 -1
- package/lib-commonjs/middleware/flip.js +31 -38
- package/lib-commonjs/middleware/flip.js.map +1 -1
- package/lib-commonjs/middleware/index.js +10 -9
- package/lib-commonjs/middleware/index.js.map +1 -1
- package/lib-commonjs/middleware/intersecting.js +24 -22
- package/lib-commonjs/middleware/intersecting.js.map +1 -1
- package/lib-commonjs/middleware/maxSize.js +34 -40
- package/lib-commonjs/middleware/maxSize.js.map +1 -1
- package/lib-commonjs/middleware/offset.js +11 -12
- package/lib-commonjs/middleware/offset.js.map +1 -1
- package/lib-commonjs/middleware/shift.js +29 -37
- package/lib-commonjs/middleware/shift.js.map +1 -1
- package/lib-commonjs/types.js +5 -2
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/usePositioning.js +192 -164
- package/lib-commonjs/usePositioning.js.map +1 -1
- package/lib-commonjs/usePositioningMouseTarget.js +34 -37
- package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
- package/lib-commonjs/utils/debounce.js +22 -21
- package/lib-commonjs/utils/debounce.js.map +1 -1
- package/lib-commonjs/utils/fromFloatingUIPlacement.js +30 -35
- package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/getBoundary.js +21 -22
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getFloatingUIOffset.js +23 -35
- package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js +45 -41
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js +50 -56
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/hasAutoFocusFilter.js +17 -17
- package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib-commonjs/utils/index.js +19 -18
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js +32 -32
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
- package/lib-commonjs/utils/parseFloatingUIPlacement.js +15 -14
- package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.js +63 -61
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPadding.js +23 -25
- package/lib-commonjs/utils/toFloatingUIPadding.js.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPlacement.js +31 -33
- package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/toggleScrollListener.js +20 -24
- package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.js +39 -53
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/utils/writeArrowUpdates.js +19 -24
- package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
- package/lib-commonjs/utils/writeContainerupdates.js +36 -45
- package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/utils/toFloatingUIPadding.js"],"sourcesContent":["export function toFloatingUIPadding(padding, isRtl) {\n if (typeof padding === \"number\") {\n return padding;\n }\n const {\n start,\n end,\n ...verticalPadding\n } = padding;\n const paddingObject = verticalPadding;\n const left = isRtl ? \"end\" : \"start\";\n const right = isRtl ? \"start\" : \"end\";\n // assign properties explicitly since undefined values are actually handled by floating UI\n // TODO create floating UI issue\n if (padding[left]) {\n paddingObject.left = padding[left];\n }\n if (padding[right]) {\n paddingObject.right = padding[right];\n }\n return paddingObject;\n}\n//# sourceMappingURL=toFloatingUIPadding.js.map"],"names":["toFloatingUIPadding","padding","isRtl","start","end","verticalPadding","paddingObject","left","right"],"mappings":";;;;+BAAgBA;;aAAAA;;AAAT,SAASA,oBAAoBC,OAAO,EAAEC,KAAK,EAAE;IAClD,IAAI,OAAOD,YAAY,UAAU;QAC/B,OAAOA;IACT,CAAC;IACD,MAAM,EACJE,MAAK,EACLC,IAAG,EACH,GAAGC,iBACJ,GAAGJ;IACJ,MAAMK,gBAAgBD;IACtB,MAAME,OAAOL,QAAQ,QAAQ,OAAO;IACpC,MAAMM,QAAQN,QAAQ,UAAU,KAAK;IACrC,0FAA0F;IAC1F,gCAAgC;IAChC,IAAID,OAAO,CAACM,KAAK,EAAE;QACjBD,cAAcC,IAAI,GAAGN,OAAO,CAACM,KAAK;IACpC,CAAC;IACD,IAAIN,OAAO,CAACO,MAAM,EAAE;QAClBF,cAAcE,KAAK,GAAGP,OAAO,CAACO,MAAM;IACtC,CAAC;IACD,OAAOF;AACT,EACA,+CAA+C"}
|
|
@@ -1,41 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
below: 'bottom',
|
|
10
|
-
before: rtl ? 'right' : 'left',
|
|
11
|
-
after: rtl ? 'left' : 'right'
|
|
5
|
+
Object.defineProperty(exports, "toFloatingUIPlacement", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>toFloatingUIPlacement
|
|
12
8
|
});
|
|
9
|
+
const getPositionMap = (rtl)=>({
|
|
10
|
+
above: "top",
|
|
11
|
+
below: "bottom",
|
|
12
|
+
before: rtl ? "right" : "left",
|
|
13
|
+
after: rtl ? "left" : "right"
|
|
14
|
+
});
|
|
13
15
|
// Floating UI automatically flips alignment
|
|
14
16
|
// https://github.com/floating-ui/floating-ui/issues/1563
|
|
15
|
-
const getAlignmentMap = ()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
const shouldAlignToCenter = (p, a)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
const getAlignmentMap = ()=>({
|
|
18
|
+
start: "start",
|
|
19
|
+
end: "end",
|
|
20
|
+
top: "start",
|
|
21
|
+
bottom: "end",
|
|
22
|
+
center: undefined
|
|
23
|
+
});
|
|
24
|
+
const shouldAlignToCenter = (p, a)=>{
|
|
25
|
+
const positionedVertically = p === "above" || p === "below";
|
|
26
|
+
const alignedVertically = a === "top" || a === "bottom";
|
|
27
|
+
return positionedVertically && alignedVertically || !positionedVertically && !alignedVertically;
|
|
26
28
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return computedPosition;
|
|
39
|
-
};
|
|
40
|
-
exports.toFloatingUIPlacement = toFloatingUIPlacement;
|
|
29
|
+
const toFloatingUIPlacement = (align, position, rtl)=>{
|
|
30
|
+
const alignment = shouldAlignToCenter(position, align) ? "center" : align;
|
|
31
|
+
const computedPosition = position && getPositionMap(rtl)[position];
|
|
32
|
+
const computedAlignment = alignment && getAlignmentMap()[alignment];
|
|
33
|
+
if (computedPosition && computedAlignment) {
|
|
34
|
+
return `${computedPosition}-${computedAlignment}`;
|
|
35
|
+
}
|
|
36
|
+
return computedPosition;
|
|
37
|
+
}; //# sourceMappingURL=toFloatingUIPlacement.js.map
|
|
38
|
+
|
|
41
39
|
//# sourceMappingURL=toFloatingUIPlacement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/utils/toFloatingUIPlacement.js"],"sourcesContent":["const getPositionMap = rtl => ({\n above: \"top\",\n below: \"bottom\",\n before: rtl ? \"right\" : \"left\",\n after: rtl ? \"left\" : \"right\"\n});\n// Floating UI automatically flips alignment\n// https://github.com/floating-ui/floating-ui/issues/1563\nconst getAlignmentMap = () => ({\n start: \"start\",\n end: \"end\",\n top: \"start\",\n bottom: \"end\",\n center: undefined\n});\nconst shouldAlignToCenter = (p, a) => {\n const positionedVertically = p === \"above\" || p === \"below\";\n const alignedVertically = a === \"top\" || a === \"bottom\";\n return positionedVertically && alignedVertically || !positionedVertically && !alignedVertically;\n};\n/**\n * Maps internal positioning values to Floating UI placement\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const toFloatingUIPlacement = (align, position, rtl) => {\n const alignment = shouldAlignToCenter(position, align) ? \"center\" : align;\n const computedPosition = position && getPositionMap(rtl)[position];\n const computedAlignment = alignment && getAlignmentMap()[alignment];\n if (computedPosition && computedAlignment) {\n return `${computedPosition}-${computedAlignment}`;\n }\n return computedPosition;\n};\n//# sourceMappingURL=toFloatingUIPlacement.js.map"],"names":["toFloatingUIPlacement","getPositionMap","rtl","above","below","before","after","getAlignmentMap","start","end","top","bottom","center","undefined","shouldAlignToCenter","p","a","positionedVertically","alignedVertically","align","position","alignment","computedPosition","computedAlignment"],"mappings":";;;;+BAwBaA;;aAAAA;;AAxBb,MAAMC,iBAAiBC,CAAAA,MAAQ,CAAA;QAC7BC,OAAO;QACPC,OAAO;QACPC,QAAQH,MAAM,UAAU,MAAM;QAC9BI,OAAOJ,MAAM,SAAS,OAAO;IAC/B,CAAA;AACA,4CAA4C;AAC5C,yDAAyD;AACzD,MAAMK,kBAAkB,IAAO,CAAA;QAC7BC,OAAO;QACPC,KAAK;QACLC,KAAK;QACLC,QAAQ;QACRC,QAAQC;IACV,CAAA;AACA,MAAMC,sBAAsB,CAACC,GAAGC,IAAM;IACpC,MAAMC,uBAAuBF,MAAM,WAAWA,MAAM;IACpD,MAAMG,oBAAoBF,MAAM,SAASA,MAAM;IAC/C,OAAOC,wBAAwBC,qBAAqB,CAACD,wBAAwB,CAACC;AAChF;AAKO,MAAMlB,wBAAwB,CAACmB,OAAOC,UAAUlB,MAAQ;IAC7D,MAAMmB,YAAYP,oBAAoBM,UAAUD,SAAS,WAAWA,KAAK;IACzE,MAAMG,mBAAmBF,YAAYnB,eAAeC,IAAI,CAACkB,SAAS;IAClE,MAAMG,oBAAoBF,aAAad,iBAAiB,CAACc,UAAU;IACnE,IAAIC,oBAAoBC,mBAAmB;QACzC,OAAO,CAAC,EAAED,iBAAiB,CAAC,EAAEC,kBAAkB,CAAC;IACnD,CAAC;IACD,OAAOD;AACT,GACA,iDAAiD"}
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "toggleScrollListener", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>toggleScrollListener
|
|
5
8
|
});
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const getScrollParent_1 = /*#__PURE__*/require("./getScrollParent");
|
|
9
|
-
/**
|
|
10
|
-
* Toggles event listeners for scroll parent.
|
|
11
|
-
* Cleans up the event listeners for the previous element and adds them for the new scroll parent.
|
|
12
|
-
* @param next Next element
|
|
13
|
-
* @param prev Previous element
|
|
14
|
-
*/
|
|
9
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
|
10
|
+
const _getScrollParent = require("./getScrollParent");
|
|
15
11
|
function toggleScrollListener(next, prev, handler) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
12
|
+
if (next === prev) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if ((0, _reactUtilities.isHTMLElement)(prev)) {
|
|
16
|
+
const prevScrollParent = (0, _getScrollParent.getScrollParent)(prev);
|
|
17
|
+
prevScrollParent.removeEventListener("scroll", handler);
|
|
18
|
+
}
|
|
19
|
+
if ((0, _reactUtilities.isHTMLElement)(next)) {
|
|
20
|
+
const scrollParent = (0, _getScrollParent.getScrollParent)(next);
|
|
21
|
+
scrollParent.addEventListener("scroll", handler);
|
|
22
|
+
}
|
|
23
|
+
} //# sourceMappingURL=toggleScrollListener.js.map
|
|
24
|
+
|
|
29
25
|
//# sourceMappingURL=toggleScrollListener.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/utils/toggleScrollListener.js"],"sourcesContent":["import { isHTMLElement } from \"@fluentui/react-utilities\";\nimport { getScrollParent } from \"./getScrollParent\";\n/**\n * Toggles event listeners for scroll parent.\n * Cleans up the event listeners for the previous element and adds them for the new scroll parent.\n * @param next Next element\n * @param prev Previous element\n */\nexport function toggleScrollListener(next, prev, handler) {\n if (next === prev) {\n return;\n }\n if (isHTMLElement(prev)) {\n const prevScrollParent = getScrollParent(prev);\n prevScrollParent.removeEventListener(\"scroll\", handler);\n }\n if (isHTMLElement(next)) {\n const scrollParent = getScrollParent(next);\n scrollParent.addEventListener(\"scroll\", handler);\n }\n}\n//# sourceMappingURL=toggleScrollListener.js.map"],"names":["toggleScrollListener","next","prev","handler","isHTMLElement","prevScrollParent","getScrollParent","removeEventListener","scrollParent","addEventListener"],"mappings":";;;;+BAQgBA;;aAAAA;;gCARc;iCACE;AAOzB,SAASA,qBAAqBC,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAE;IACxD,IAAIF,SAASC,MAAM;QACjB;IACF,CAAC;IACD,IAAIE,IAAAA,6BAAa,EAACF,OAAO;QACvB,MAAMG,mBAAmBC,IAAAA,gCAAe,EAACJ;QACzCG,iBAAiBE,mBAAmB,CAAC,UAAUJ;IACjD,CAAC;IACD,IAAIC,IAAAA,6BAAa,EAACH,OAAO;QACvB,MAAMO,eAAeF,IAAAA,gCAAe,EAACL;QACrCO,aAAaC,gBAAgB,CAAC,UAAUN;IAC1C,CAAC;AACH,EACA,gDAAgD"}
|
|
@@ -1,58 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "useCallbackRef", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>useCallbackRef
|
|
5
8
|
});
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
/**
|
|
10
|
-
* Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content
|
|
11
|
-
* changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via
|
|
12
|
-
* React.useState(), but it will cause re-renders always.
|
|
13
|
-
*
|
|
14
|
-
* https://reactjs.org/docs/hooks-reference.html#useref
|
|
15
|
-
* https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
|
|
16
|
-
*
|
|
17
|
-
* @param initialValue - initial ref value
|
|
18
|
-
* @param callback - a callback to run when value changes
|
|
19
|
-
* @param skipInitialResolve - a flag to skip an initial ref report
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
|
|
23
|
-
* ref.current = 1;
|
|
24
|
-
* // prints 0 -> 1
|
|
25
|
-
*/
|
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
11
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
|
26
12
|
function useCallbackRef(initialValue, callback, skipInitialResolve) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
13
|
+
const isFirst = _react.useRef(true);
|
|
14
|
+
const [ref] = _react.useState(()=>({
|
|
15
|
+
// value
|
|
16
|
+
value: initialValue,
|
|
17
|
+
// last callback
|
|
18
|
+
callback,
|
|
19
|
+
// "memoized" public interface
|
|
20
|
+
facade: {
|
|
21
|
+
get current () {
|
|
22
|
+
return ref.value;
|
|
23
|
+
},
|
|
24
|
+
set current (value){
|
|
25
|
+
const last = ref.value;
|
|
26
|
+
if (last !== value) {
|
|
27
|
+
ref.value = value;
|
|
28
|
+
if (skipInitialResolve && isFirst.current) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
ref.callback(value, last);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}));
|
|
36
|
+
(0, _reactUtilities.useIsomorphicLayoutEffect)(()=>{
|
|
37
|
+
isFirst.current = false;
|
|
38
|
+
}, []);
|
|
39
|
+
// update callback
|
|
40
|
+
ref.callback = callback;
|
|
41
|
+
return ref.facade;
|
|
42
|
+
} //# sourceMappingURL=useCallbackRef.js.map
|
|
43
|
+
|
|
58
44
|
//# sourceMappingURL=useCallbackRef.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/utils/useCallbackRef.js"],"sourcesContent":["import * as React from \"react\";\nimport { useIsomorphicLayoutEffect } from \"@fluentui/react-utilities\";\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(initialValue, callback, skipInitialResolve) {\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 if (last !== value) {\n ref.value = value;\n if (skipInitialResolve && isFirst.current) {\n return;\n }\n ref.callback(value, last);\n }\n }\n }\n }));\n useIsomorphicLayoutEffect(() => {\n isFirst.current = false;\n }, []);\n // update callback\n ref.callback = callback;\n return ref.facade;\n}\n//# sourceMappingURL=useCallbackRef.js.map"],"names":["useCallbackRef","initialValue","callback","skipInitialResolve","isFirst","React","useRef","ref","useState","value","facade","current","last","useIsomorphicLayoutEffect"],"mappings":";;;;+BAmBgBA;;aAAAA;;;6DAnBO;gCACmB;AAkBnC,SAASA,eAAeC,YAAY,EAAEC,QAAQ,EAAEC,kBAAkB,EAAE;IACzE,MAAMC,UAAUC,OAAMC,MAAM,CAAC,IAAI;IACjC,MAAM,CAACC,IAAI,GAAGF,OAAMG,QAAQ,CAAC,IAAO,CAAA;YAClC,QAAQ;YACRC,OAAOR;YACP,gBAAgB;YAChBC;YACA,8BAA8B;YAC9BQ,QAAQ;gBACN,IAAIC,WAAU;oBACZ,OAAOJ,IAAIE,KAAK;gBAClB;gBACA,IAAIE,SAAQF,MAAO;oBACjB,MAAMG,OAAOL,IAAIE,KAAK;oBACtB,IAAIG,SAASH,OAAO;wBAClBF,IAAIE,KAAK,GAAGA;wBACZ,IAAIN,sBAAsBC,QAAQO,OAAO,EAAE;4BACzC;wBACF,CAAC;wBACDJ,IAAIL,QAAQ,CAACO,OAAOG;oBACtB,CAAC;gBACH;YACF;QACF,CAAA;IACAC,IAAAA,yCAAyB,EAAC,IAAM;QAC9BT,QAAQO,OAAO,GAAG,KAAK;IACzB,GAAG,EAAE;IACL,kBAAkB;IAClBJ,IAAIL,QAAQ,GAAGA;IACf,OAAOK,IAAIG,MAAM;AACnB,EACA,0CAA0C"}
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.writeArrowUpdates = void 0;
|
|
7
1
|
/**
|
|
8
2
|
* Writes all DOM element updates after position is computed
|
|
9
|
-
*/
|
|
3
|
+
*/ "use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "writeArrowUpdates", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: ()=>writeArrowUpdates
|
|
10
|
+
});
|
|
10
11
|
function writeArrowUpdates(options) {
|
|
11
|
-
|
|
12
|
-
arrow
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Object.assign(arrow.style, {
|
|
23
|
-
left: `${arrowX}px`,
|
|
24
|
-
top: `${arrowY}px`
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
exports.writeArrowUpdates = writeArrowUpdates;
|
|
12
|
+
const { arrow , middlewareData } = options;
|
|
13
|
+
if (!middlewareData.arrow || !arrow) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const { x: arrowX , y: arrowY } = middlewareData.arrow;
|
|
17
|
+
Object.assign(arrow.style, {
|
|
18
|
+
left: `${arrowX}px`,
|
|
19
|
+
top: `${arrowY}px`
|
|
20
|
+
});
|
|
21
|
+
} //# sourceMappingURL=writeArrowUpdates.js.map
|
|
22
|
+
|
|
28
23
|
//# sourceMappingURL=writeArrowUpdates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/utils/writeArrowUpdates.js"],"sourcesContent":["/**\n * Writes all DOM element updates after position is computed\n */export function writeArrowUpdates(options) {\n const {\n arrow,\n middlewareData\n } = options;\n if (!middlewareData.arrow || !arrow) {\n return;\n }\n const {\n x: arrowX,\n y: arrowY\n } = middlewareData.arrow;\n Object.assign(arrow.style, {\n left: `${arrowX}px`,\n top: `${arrowY}px`\n });\n}\n//# sourceMappingURL=writeArrowUpdates.js.map"],"names":["writeArrowUpdates","options","arrow","middlewareData","x","arrowX","y","arrowY","Object","assign","style","left","top"],"mappings":"AAAA;;CAEC;;;;+BAAkBA;;aAAAA;;AAAT,SAASA,kBAAkBC,OAAO,EAAE;IAC5C,MAAM,EACJC,MAAK,EACLC,eAAc,EACf,GAAGF;IACJ,IAAI,CAACE,eAAeD,KAAK,IAAI,CAACA,OAAO;QACnC;IACF,CAAC;IACD,MAAM,EACJE,GAAGC,OAAM,EACTC,GAAGC,OAAM,EACV,GAAGJ,eAAeD,KAAK;IACxBM,OAAOC,MAAM,CAACP,MAAMQ,KAAK,EAAE;QACzBC,MAAM,CAAC,EAAEN,OAAO,EAAE,CAAC;QACnBO,KAAK,CAAC,EAAEL,OAAO,EAAE,CAAC;IACpB;AACF,EACA,6CAA6C"}
|
|
@@ -1,50 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "writeContainerUpdates", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>writeContainerUpdates
|
|
5
8
|
});
|
|
6
|
-
|
|
7
|
-
const constants_1 = /*#__PURE__*/require("../constants");
|
|
8
|
-
/**
|
|
9
|
-
* Writes all container element position updates after the position is computed
|
|
10
|
-
*/
|
|
9
|
+
const _constants = require("../constants");
|
|
11
10
|
function writeContainerUpdates(options) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
container
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;
|
|
43
|
-
const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;
|
|
44
|
-
Object.assign(container.style, {
|
|
45
|
-
transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,
|
|
46
|
-
position: strategy
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
exports.writeContainerUpdates = writeContainerUpdates;
|
|
11
|
+
const { container , placement , middlewareData , strategy , lowPPI , coordinates } = options;
|
|
12
|
+
if (!container) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
container.setAttribute(_constants.DATA_POSITIONING_PLACEMENT, placement);
|
|
16
|
+
container.removeAttribute(_constants.DATA_POSITIONING_INTERSECTING);
|
|
17
|
+
if (middlewareData.intersectionObserver.intersecting) {
|
|
18
|
+
container.setAttribute(_constants.DATA_POSITIONING_INTERSECTING, "");
|
|
19
|
+
}
|
|
20
|
+
container.removeAttribute(_constants.DATA_POSITIONING_ESCAPED);
|
|
21
|
+
if (middlewareData.hide?.escaped) {
|
|
22
|
+
container.setAttribute(_constants.DATA_POSITIONING_ESCAPED, "");
|
|
23
|
+
}
|
|
24
|
+
container.removeAttribute(_constants.DATA_POSITIONING_HIDDEN);
|
|
25
|
+
if (middlewareData.hide?.referenceHidden) {
|
|
26
|
+
container.setAttribute(_constants.DATA_POSITIONING_HIDDEN, "");
|
|
27
|
+
}
|
|
28
|
+
// Round so that the coordinates land on device pixels.
|
|
29
|
+
// This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like
|
|
30
|
+
// `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.
|
|
31
|
+
// See https://github.com/microsoft/fluentui/issues/26764 for more info.
|
|
32
|
+
const devicePixelRatio = container.ownerDocument.defaultView?.devicePixelRatio || 1;
|
|
33
|
+
const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;
|
|
34
|
+
const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;
|
|
35
|
+
Object.assign(container.style, {
|
|
36
|
+
transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,
|
|
37
|
+
position: strategy
|
|
38
|
+
});
|
|
39
|
+
} //# sourceMappingURL=writeContainerupdates.js.map
|
|
40
|
+
|
|
50
41
|
//# sourceMappingURL=writeContainerupdates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/utils/writeContainerupdates.js"],"sourcesContent":["import { DATA_POSITIONING_ESCAPED, DATA_POSITIONING_HIDDEN, DATA_POSITIONING_INTERSECTING, DATA_POSITIONING_PLACEMENT } from \"../constants\";\n/**\n * Writes all container element position updates after the position is computed\n */\nexport function writeContainerUpdates(options) {\n const {\n container,\n placement,\n middlewareData,\n strategy,\n lowPPI,\n coordinates\n } = options;\n if (!container) {\n return;\n }\n container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);\n container.removeAttribute(DATA_POSITIONING_INTERSECTING);\n if (middlewareData.intersectionObserver.intersecting) {\n container.setAttribute(DATA_POSITIONING_INTERSECTING, \"\");\n }\n container.removeAttribute(DATA_POSITIONING_ESCAPED);\n if (middlewareData.hide?.escaped) {\n container.setAttribute(DATA_POSITIONING_ESCAPED, \"\");\n }\n container.removeAttribute(DATA_POSITIONING_HIDDEN);\n if (middlewareData.hide?.referenceHidden) {\n container.setAttribute(DATA_POSITIONING_HIDDEN, \"\");\n }\n // Round so that the coordinates land on device pixels.\n // This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like\n // `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.\n // See https://github.com/microsoft/fluentui/issues/26764 for more info.\n const devicePixelRatio = container.ownerDocument.defaultView?.devicePixelRatio || 1;\n const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;\n const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;\n Object.assign(container.style, {\n transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,\n position: strategy\n });\n}\n//# sourceMappingURL=writeContainerupdates.js.map"],"names":["writeContainerUpdates","options","container","placement","middlewareData","strategy","lowPPI","coordinates","setAttribute","DATA_POSITIONING_PLACEMENT","removeAttribute","DATA_POSITIONING_INTERSECTING","intersectionObserver","intersecting","DATA_POSITIONING_ESCAPED","hide","escaped","DATA_POSITIONING_HIDDEN","referenceHidden","devicePixelRatio","ownerDocument","defaultView","x","Math","round","y","Object","assign","style","transform","position"],"mappings":";;;;+BAIgBA;;aAAAA;;2BAJ6G;AAItH,SAASA,sBAAsBC,OAAO,EAAE;IAC7C,MAAM,EACJC,UAAS,EACTC,UAAS,EACTC,eAAc,EACdC,SAAQ,EACRC,OAAM,EACNC,YAAW,EACZ,GAAGN;IACJ,IAAI,CAACC,WAAW;QACd;IACF,CAAC;IACDA,UAAUM,YAAY,CAACC,qCAA0B,EAAEN;IACnDD,UAAUQ,eAAe,CAACC,wCAA6B;IACvD,IAAIP,eAAeQ,oBAAoB,CAACC,YAAY,EAAE;QACpDX,UAAUM,YAAY,CAACG,wCAA6B,EAAE;IACxD,CAAC;IACDT,UAAUQ,eAAe,CAACI,mCAAwB;IAClD,IAAIV,eAAeW,IAAI,EAAEC,SAAS;QAChCd,UAAUM,YAAY,CAACM,mCAAwB,EAAE;IACnD,CAAC;IACDZ,UAAUQ,eAAe,CAACO,kCAAuB;IACjD,IAAIb,eAAeW,IAAI,EAAEG,iBAAiB;QACxChB,UAAUM,YAAY,CAACS,kCAAuB,EAAE;IAClD,CAAC;IACD,uDAAuD;IACvD,oHAAoH;IACpH,wFAAwF;IACxF,wEAAwE;IACxE,MAAME,mBAAmBjB,UAAUkB,aAAa,CAACC,WAAW,EAAEF,oBAAoB;IAClF,MAAMG,IAAIC,KAAKC,KAAK,CAACjB,YAAYe,CAAC,GAAGH,oBAAoBA;IACzD,MAAMM,IAAIF,KAAKC,KAAK,CAACjB,YAAYkB,CAAC,GAAGN,oBAAoBA;IACzDO,OAAOC,MAAM,CAACzB,UAAU0B,KAAK,EAAE;QAC7BC,WAAWvB,SAAS,CAAC,UAAU,EAAEgB,EAAE,IAAI,EAAEG,EAAE,GAAG,CAAC,GAAG,CAAC,YAAY,EAAEH,EAAE,IAAI,EAAEG,EAAE,MAAM,CAAC;QAClFK,UAAUzB;IACZ;AACF,EACA,iDAAiD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-positioning",
|
|
3
|
-
"version": "0.0.0-nightly-
|
|
3
|
+
"version": "0.0.0-nightly-20230317-1454.1",
|
|
4
4
|
"description": "A react wrapper around Popper.js for Fluent UI",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lint": "just-scripts lint",
|
|
21
21
|
"test": "jest --passWithNoTests",
|
|
22
22
|
"type-check": "tsc -b tsconfig.json",
|
|
23
|
-
"generate-api": "
|
|
23
|
+
"generate-api": "just-scripts generate-api"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@fluentui/eslint-plugin": "*",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@floating-ui/dom": "^1.2.0",
|
|
32
|
-
"@fluentui/react-shared-contexts": "0.0.0-nightly-
|
|
33
|
-
"@fluentui/react-theme": "0.0.0-nightly-
|
|
34
|
-
"@fluentui/react-utilities": "0.0.0-nightly-
|
|
32
|
+
"@fluentui/react-shared-contexts": "0.0.0-nightly-20230317-1454.1",
|
|
33
|
+
"@fluentui/react-theme": "0.0.0-nightly-20230317-1454.1",
|
|
34
|
+
"@fluentui/react-utilities": "0.0.0-nightly-20230317-1454.1",
|
|
35
35
|
"@griffel/react": "^1.5.2",
|
|
36
|
-
"
|
|
36
|
+
"@swc/helpers": "^0.4.14"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@types/react": ">=16.8.0 <19.0.0",
|