@fluentui/react-positioning 9.0.0-alpha.57 → 9.0.0-alpha.60
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/CHANGELOG.json +47 -2
- package/CHANGELOG.md +30 -3
- package/lib/createVirtualElementFromClick.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/usePopper.js.map +1 -1
- package/lib/usePopperMouseTarget.js.map +1 -1
- package/lib/utils/getBasePlacement.js.map +1 -1
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeArrowOffset.js.map +1 -1
- package/lib/utils/positioningHelper.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/usePopper.js.map +1 -1
- package/lib-commonjs/usePopperMouseTarget.js.map +1 -1
- package/lib-commonjs/utils/getBasePlacement.js.map +1 -1
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
- package/lib-commonjs/utils/positioningHelper.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/package.json +2 -2
- package/lib-amd/createVirtualElementFromClick.d.ts +0 -6
- package/lib-amd/createVirtualElementFromClick.js +0 -30
- package/lib-amd/createVirtualElementFromClick.js.map +0 -1
- package/lib-amd/index.d.ts +0 -5
- package/lib-amd/index.js +0 -12
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/types.d.ts +0 -68
- package/lib-amd/types.js +0 -5
- package/lib-amd/types.js.map +0 -1
- package/lib-amd/usePopper.d.ts +0 -35
- package/lib-amd/usePopper.js +0 -320
- package/lib-amd/usePopper.js.map +0 -1
- package/lib-amd/usePopperMouseTarget.d.ts +0 -11
- package/lib-amd/usePopperMouseTarget.js +0 -35
- package/lib-amd/usePopperMouseTarget.js.map +0 -1
- package/lib-amd/utils/getBasePlacement.d.ts +0 -8
- package/lib-amd/utils/getBasePlacement.js +0 -16
- package/lib-amd/utils/getBasePlacement.js.map +0 -1
- package/lib-amd/utils/getBoundary.d.ts +0 -6
- package/lib-amd/utils/getBoundary.js +0 -23
- package/lib-amd/utils/getBoundary.js.map +0 -1
- package/lib-amd/utils/getReactFiberFromNode.d.ts +0 -109
- package/lib-amd/utils/getReactFiberFromNode.js +0 -48
- package/lib-amd/utils/getReactFiberFromNode.js.map +0 -1
- package/lib-amd/utils/getScrollParent.d.ts +0 -12
- package/lib-amd/utils/getScrollParent.js +0 -58
- package/lib-amd/utils/getScrollParent.js.map +0 -1
- package/lib-amd/utils/index.d.ts +0 -8
- package/lib-amd/utils/index.js +0 -13
- package/lib-amd/utils/index.js.map +0 -1
- package/lib-amd/utils/mergeArrowOffset.d.ts +0 -10
- package/lib-amd/utils/mergeArrowOffset.js +0 -43
- package/lib-amd/utils/mergeArrowOffset.js.map +0 -1
- package/lib-amd/utils/positioningHelper.d.ts +0 -7
- package/lib-amd/utils/positioningHelper.js +0 -48
- package/lib-amd/utils/positioningHelper.js.map +0 -1
- package/lib-amd/utils/resolvePositioningShorthand.d.ts +0 -2
- package/lib-amd/utils/resolvePositioningShorthand.js +0 -31
- package/lib-amd/utils/resolvePositioningShorthand.js.map +0 -1
- package/lib-amd/utils/useCallbackRef.d.ts +0 -19
- package/lib-amd/utils/useCallbackRef.js +0 -55
- package/lib-amd/utils/useCallbackRef.js.map +0 -1
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
define(["require", "exports"], function (require, exports) {
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.resolvePositioningShorthand = void 0;
|
|
5
|
-
// Look up table for shorthand to avoid parsing strings
|
|
6
|
-
var shorthandLookup = {
|
|
7
|
-
above: { position: 'above', align: 'center' },
|
|
8
|
-
'above-start': { position: 'above', align: 'start' },
|
|
9
|
-
'above-end': { position: 'above', align: 'end' },
|
|
10
|
-
below: { position: 'below', align: 'center' },
|
|
11
|
-
'below-start': { position: 'below', align: 'start' },
|
|
12
|
-
'below-end': { position: 'below', align: 'end' },
|
|
13
|
-
before: { position: 'before', align: 'center' },
|
|
14
|
-
'before-top': { position: 'before', align: 'top' },
|
|
15
|
-
'before-bottom': { position: 'before', align: 'bottom' },
|
|
16
|
-
after: { position: 'after', align: 'center' },
|
|
17
|
-
'after-top': { position: 'after', align: 'top' },
|
|
18
|
-
'after-bottom': { position: 'after', align: 'bottom' },
|
|
19
|
-
};
|
|
20
|
-
function resolvePositioningShorthand(shorthand) {
|
|
21
|
-
if (shorthand === undefined || shorthand === null) {
|
|
22
|
-
return {};
|
|
23
|
-
}
|
|
24
|
-
if (typeof shorthand === 'string') {
|
|
25
|
-
return shorthandLookup[shorthand];
|
|
26
|
-
}
|
|
27
|
-
return shorthand;
|
|
28
|
-
}
|
|
29
|
-
exports.resolvePositioningShorthand = resolvePositioningShorthand;
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=resolvePositioningShorthand.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePositioningShorthand.js","sourceRoot":"../src/","sources":["utils/resolvePositioningShorthand.ts"],"names":[],"mappings":";;;;IAEA,uDAAuD;IACvD,IAAM,eAAe,GAAoF;QACvG,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC7C,aAAa,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;QACpD,WAAW,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;QAChD,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC7C,aAAa,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;QACpD,WAAW,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;QAChD,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC/C,YAAY,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE;QAClD,eAAe,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;QACxD,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC7C,WAAW,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;QAChD,cAAc,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE;KACvD,CAAC;IAEF,SAAgB,2BAA2B,CACzC,SAAkD;QAElD,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,IAAI,EAAE;YACjD,OAAO,EAAE,CAAC;SACX;QAED,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC;SACnC;QAED,OAAO,SAAuC,CAAC;IACjD,CAAC;IAZD,kEAYC","sourcesContent":["import type { PositioningShorthand, PositioningShorthandValue, PositioningProps } from '../types';\n\n// Look up table for shorthand to avoid parsing strings\nconst shorthandLookup: Record<PositioningShorthandValue, Pick<PositioningProps, 'position' | 'align'>> = {\n above: { position: 'above', align: 'center' },\n 'above-start': { position: 'above', align: 'start' },\n 'above-end': { position: 'above', align: 'end' },\n below: { position: 'below', align: 'center' },\n 'below-start': { position: 'below', align: 'start' },\n 'below-end': { position: 'below', align: 'end' },\n before: { position: 'before', align: 'center' },\n 'before-top': { position: 'before', align: 'top' },\n 'before-bottom': { position: 'before', align: 'bottom' },\n after: { position: 'after', align: 'center' },\n 'after-top': { position: 'after', align: 'top' },\n 'after-bottom': { position: 'after', align: 'bottom' },\n};\n\nexport function resolvePositioningShorthand(\n shorthand: PositioningShorthand | undefined | null,\n): Readonly<PositioningProps> {\n if (shorthand === undefined || shorthand === null) {\n return {};\n }\n\n if (typeof shorthand === 'string') {\n return shorthandLookup[shorthand];\n }\n\n return shorthand as Readonly<PositioningProps>;\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content
|
|
4
|
-
* changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via
|
|
5
|
-
* React.useState(), but it will cause re-renders always.
|
|
6
|
-
*
|
|
7
|
-
* https://reactjs.org/docs/hooks-reference.html#useref
|
|
8
|
-
* https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
|
|
9
|
-
*
|
|
10
|
-
* @param initialValue - initial ref value
|
|
11
|
-
* @param callback - a callback to run when value changes
|
|
12
|
-
* @param skipInitialResolve - a flag to skip an initial ref report
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
|
|
16
|
-
* ref.current = 1;
|
|
17
|
-
* // prints 0 -> 1
|
|
18
|
-
*/
|
|
19
|
-
export declare function useCallbackRef<T>(initialValue: T | null, callback: (newValue: T | null, lastValue: T | null) => void, skipInitialResolve?: boolean): React.MutableRefObject<T | null>;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
define(["require", "exports", "react", "@fluentui/react-utilities"], function (require, exports, React, react_utilities_1) {
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.useCallbackRef = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content
|
|
7
|
-
* changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via
|
|
8
|
-
* React.useState(), but it will cause re-renders always.
|
|
9
|
-
*
|
|
10
|
-
* https://reactjs.org/docs/hooks-reference.html#useref
|
|
11
|
-
* https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
|
|
12
|
-
*
|
|
13
|
-
* @param initialValue - initial ref value
|
|
14
|
-
* @param callback - a callback to run when value changes
|
|
15
|
-
* @param skipInitialResolve - a flag to skip an initial ref report
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
|
|
19
|
-
* ref.current = 1;
|
|
20
|
-
* // prints 0 -> 1
|
|
21
|
-
*/
|
|
22
|
-
function useCallbackRef(initialValue, callback, skipInitialResolve) {
|
|
23
|
-
var isFirst = React.useRef(true);
|
|
24
|
-
var ref = React.useState(function () { return ({
|
|
25
|
-
// value
|
|
26
|
-
value: initialValue,
|
|
27
|
-
// last callback
|
|
28
|
-
callback: callback,
|
|
29
|
-
// "memoized" public interface
|
|
30
|
-
facade: {
|
|
31
|
-
get current() {
|
|
32
|
-
return ref.value;
|
|
33
|
-
},
|
|
34
|
-
set current(value) {
|
|
35
|
-
var last = ref.value;
|
|
36
|
-
if (last !== value) {
|
|
37
|
-
ref.value = value;
|
|
38
|
-
if (skipInitialResolve && isFirst.current) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
ref.callback(value, last);
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
}); })[0];
|
|
46
|
-
react_utilities_1.useIsomorphicLayoutEffect(function () {
|
|
47
|
-
isFirst.current = false;
|
|
48
|
-
}, []);
|
|
49
|
-
// update callback
|
|
50
|
-
ref.callback = callback;
|
|
51
|
-
return ref.facade;
|
|
52
|
-
}
|
|
53
|
-
exports.useCallbackRef = useCallbackRef;
|
|
54
|
-
});
|
|
55
|
-
//# sourceMappingURL=useCallbackRef.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCallbackRef.js","sourceRoot":"../src/","sources":["utils/useCallbackRef.ts"],"names":[],"mappings":";;;;IAGA;;;;;;;;;;;;;;;;OAgBG;IACH,SAAgB,cAAc,CAC5B,YAAsB,EACtB,QAA2D,EAC3D,kBAA4B;QAE5B,IAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAA,GAAG,GAAI,KAAK,CAAC,QAAQ,CAAC,cAAM,OAAA,CAAC;YAClC,QAAQ;YACR,KAAK,EAAE,YAAY;YACnB,gBAAgB;YAChB,QAAQ,UAAA;YACR,8BAA8B;YAC9B,MAAM,EAAE;gBACN,IAAI,OAAO;oBACT,OAAO,GAAG,CAAC,KAAK,CAAC;gBACnB,CAAC;gBACD,IAAI,OAAO,CAAC,KAAK;oBACf,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC;oBAEvB,IAAI,IAAI,KAAK,KAAK,EAAE;wBAClB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;wBAElB,IAAI,kBAAkB,IAAI,OAAO,CAAC,OAAO,EAAE;4BACzC,OAAO;yBACR;wBAED,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;qBAC3B;gBACH,CAAC;aACF;SACF,CAAC,EAxBiC,CAwBjC,CAAC,GAxBO,CAwBN;QAEJ,2CAAyB,CAAC;YACxB,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;QAC1B,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,kBAAkB;QAClB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAExB,OAAO,GAAG,CAAC,MAAM,CAAC;IACpB,CAAC;IAxCD,wCAwCC","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"]}
|