@fluentui/react-utilities 9.12.0 → 9.13.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/CHANGELOG.json +63 -1
- package/CHANGELOG.md +28 -2
- package/dist/index.d.ts +4 -0
- package/lib/compose/assertSlots.js +8 -3
- package/lib/compose/assertSlots.js.map +1 -1
- package/lib/compose/getSlots.js +1 -1
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/getSlotsNext.js +1 -1
- package/lib/compose/getSlotsNext.js.map +1 -1
- package/lib/compose/isResolvedShorthand.js.map +1 -1
- package/lib/compose/isSlot.js +2 -1
- package/lib/compose/isSlot.js.map +1 -1
- package/lib/compose/resolveShorthand.js +2 -1
- package/lib/compose/resolveShorthand.js.map +1 -1
- package/lib/compose/slot.js +7 -7
- package/lib/compose/slot.js.map +1 -1
- package/lib/events/mouseTouchHelpers.js.map +1 -1
- package/lib/hooks/useAnimationFrame.js +10 -1
- package/lib/hooks/useAnimationFrame.js.map +1 -1
- package/lib/hooks/useBrowserTimer.js.map +1 -1
- package/lib/hooks/useControllableState.js +5 -8
- package/lib/hooks/useControllableState.js.map +1 -1
- package/lib/hooks/useEventCallback.js.map +1 -1
- package/lib/hooks/useFirstMount.js.map +1 -1
- package/lib/hooks/useForceUpdate.js.map +1 -1
- package/lib/hooks/useId.js.map +1 -1
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js +34 -29
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnScrollOutside.js +9 -6
- package/lib/hooks/useOnScrollOutside.js.map +1 -1
- package/lib/hooks/usePrevious.js.map +1 -1
- package/lib/hooks/useScrollbarWidth.js +1 -1
- package/lib/hooks/useScrollbarWidth.js.map +1 -1
- package/lib/hooks/useTimeout.js.map +1 -1
- package/lib/selection/useSelection.js +2 -2
- package/lib/selection/useSelection.js.map +1 -1
- package/lib/ssr/SSRContext.js +5 -7
- package/lib/ssr/SSRContext.js.map +1 -1
- package/lib/ssr/canUseDOM.js.map +1 -1
- package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib/trigger/getTriggerChild.js.map +1 -1
- package/lib/trigger/isFluentTrigger.js.map +1 -1
- package/lib/utils/createSetFromIterable.js.map +1 -1
- package/lib/utils/getNativeElementProps.js +1 -1
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.js.map +1 -1
- package/lib/utils/getReactCallbackName.js +2 -4
- package/lib/utils/getReactCallbackName.js.map +1 -1
- package/lib/utils/isHTMLElement.js +2 -2
- package/lib/utils/isHTMLElement.js.map +1 -1
- package/lib/utils/isInteractiveHTMLElement.js +1 -1
- package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib/utils/mergeCallbacks.js +3 -2
- package/lib/utils/mergeCallbacks.js.map +1 -1
- package/lib/utils/omit.js.map +1 -1
- package/lib/utils/priorityQueue.js.map +1 -1
- package/lib/utils/properties.js +2 -1
- package/lib/utils/properties.js.map +1 -1
- package/lib-commonjs/compose/assertSlots.js +13 -6
- package/lib-commonjs/compose/assertSlots.js.map +1 -1
- package/lib-commonjs/compose/constants.js +6 -2
- package/lib-commonjs/compose/constants.js.map +1 -1
- package/lib-commonjs/compose/getSlots.js +6 -4
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/getSlotsNext.js +6 -4
- package/lib-commonjs/compose/getSlotsNext.js.map +1 -1
- package/lib-commonjs/compose/index.js +14 -12
- package/lib-commonjs/compose/index.js.map +1 -1
- package/lib-commonjs/compose/isResolvedShorthand.js +3 -1
- package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
- package/lib-commonjs/compose/isSlot.js +5 -2
- package/lib-commonjs/compose/isSlot.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.js +7 -4
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/compose/slot.js +18 -12
- package/lib-commonjs/compose/slot.js.map +1 -1
- package/lib-commonjs/compose/types.js +2 -2
- package/lib-commonjs/compose/types.js.map +1 -1
- package/lib-commonjs/events/index.js +2 -2
- package/lib-commonjs/events/index.js.map +1 -1
- package/lib-commonjs/events/mouseTouchHelpers.js +11 -5
- package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
- package/lib-commonjs/hooks/index.js +14 -14
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useAnimationFrame.js +13 -2
- package/lib-commonjs/hooks/useAnimationFrame.js.map +1 -1
- package/lib-commonjs/hooks/useBrowserTimer.js +5 -3
- package/lib-commonjs/hooks/useBrowserTimer.js.map +1 -1
- package/lib-commonjs/hooks/useControllableState.js +10 -11
- package/lib-commonjs/hooks/useControllableState.js.map +1 -1
- package/lib-commonjs/hooks/useEventCallback.js +5 -3
- package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
- package/lib-commonjs/hooks/useFirstMount.js +5 -3
- package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
- package/lib-commonjs/hooks/useForceUpdate.js +3 -1
- package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
- package/lib-commonjs/hooks/useId.js +11 -5
- package/lib-commonjs/hooks/useId.js.map +1 -1
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +5 -3
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib-commonjs/hooks/useMergedRefs.js +5 -3
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js +38 -32
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnScrollOutside.js +14 -9
- package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
- package/lib-commonjs/hooks/usePrevious.js +5 -3
- package/lib-commonjs/hooks/usePrevious.js.map +1 -1
- package/lib-commonjs/hooks/useScrollbarWidth.js +6 -4
- package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
- package/lib-commonjs/hooks/useTimeout.js +3 -1
- package/lib-commonjs/hooks/useTimeout.js.map +1 -1
- package/lib-commonjs/index.js +129 -43
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/selection/index.js +3 -3
- package/lib-commonjs/selection/index.js.map +1 -1
- package/lib-commonjs/selection/types.js +2 -2
- package/lib-commonjs/selection/types.js.map +1 -1
- package/lib-commonjs/selection/useSelection.js +7 -5
- package/lib-commonjs/selection/useSelection.js.map +1 -1
- package/lib-commonjs/ssr/SSRContext.js +22 -14
- package/lib-commonjs/ssr/SSRContext.js.map +1 -1
- package/lib-commonjs/ssr/canUseDOM.js +3 -1
- package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
- package/lib-commonjs/ssr/index.js +3 -3
- package/lib-commonjs/ssr/index.js.map +1 -1
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js +5 -3
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib-commonjs/trigger/getTriggerChild.js +5 -3
- package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
- package/lib-commonjs/trigger/index.js +5 -5
- package/lib-commonjs/trigger/index.js.map +1 -1
- package/lib-commonjs/trigger/isFluentTrigger.js +5 -3
- package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
- package/lib-commonjs/trigger/types.js +2 -2
- package/lib-commonjs/trigger/types.js.map +1 -1
- package/lib-commonjs/utils/clamp.js +3 -1
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/createSetFromIterable.js +3 -1
- package/lib-commonjs/utils/createSetFromIterable.js.map +1 -1
- package/lib-commonjs/utils/getNativeElementProps.js +9 -5
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.js +3 -1
- package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
- package/lib-commonjs/utils/getReactCallbackName.js +7 -7
- package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
- package/lib-commonjs/utils/index.js +10 -10
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/isHTMLElement.js +5 -3
- package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/isInteractiveHTMLElement.js +4 -2
- package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/mergeCallbacks.js +6 -3
- package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
- package/lib-commonjs/utils/omit.js +3 -1
- package/lib-commonjs/utils/omit.js.map +1 -1
- package/lib-commonjs/utils/priorityQueue.js +3 -1
- package/lib-commonjs/utils/priorityQueue.js.map +1 -1
- package/lib-commonjs/utils/properties.js +89 -30
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/package.json +5 -5
@@ -9,12 +9,18 @@ function _export(target, all) {
|
|
9
9
|
});
|
10
10
|
}
|
11
11
|
_export(exports, {
|
12
|
-
isTouchEvent: ()
|
13
|
-
|
14
|
-
|
12
|
+
isTouchEvent: function() {
|
13
|
+
return isTouchEvent;
|
14
|
+
},
|
15
|
+
isMouseEvent: function() {
|
16
|
+
return isMouseEvent;
|
17
|
+
},
|
18
|
+
getEventClientCoords: function() {
|
19
|
+
return getEventClientCoords;
|
20
|
+
}
|
15
21
|
});
|
16
|
-
const
|
17
|
-
const _react = /*#__PURE__*/
|
22
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
23
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
18
24
|
function isTouchEvent(event) {
|
19
25
|
return event.type.startsWith('touch');
|
20
26
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["mouseTouchHelpers.js"],"sourcesContent":["import * as React from 'react';\n/**\n * Returns true if event is a touch event. Useful when sharing logic between touch and mouse interactions.\n */ export function isTouchEvent(event) {\n return event.type.startsWith('touch');\n}\n/**\n * Returns true if event is a mouse event. Useful when sharing logic between touch and mouse interactions.\n */ export function isMouseEvent(event) {\n return event.type.startsWith('mouse') || [\n 'click',\n 'contextmenu',\n 'dblclick'\n ].indexOf(event.type) > -1;\n}\n/**\n * Returns an object with clientX, clientY for TouchOrMouseEvent.\n * Returns zeros in case the event is not a mouse or a touch event.\n */ export function getEventClientCoords(event) {\n if (isMouseEvent(event)) {\n return {\n clientX: event.clientX,\n clientY: event.clientY\n };\n } else if (isTouchEvent(event)) {\n return {\n clientX: event.touches[0].clientX,\n clientY: event.touches[0].clientY\n };\n } else {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('@fluentui/react-utilities]: Unable to get clientX. Unknown event type.');\n }\n return {\n clientX: 0,\n clientY: 0\n };\n }\n}\n"],"names":["isTouchEvent","isMouseEvent","getEventClientCoords","event","type","startsWith","indexOf","clientX","clientY","touches","process","env","NODE_ENV","Error"],"mappings":";;;;;;;;;;;IAGoBA,YAAY
|
1
|
+
{"version":3,"sources":["mouseTouchHelpers.js"],"sourcesContent":["import * as React from 'react';\n/**\n * Returns true if event is a touch event. Useful when sharing logic between touch and mouse interactions.\n */ export function isTouchEvent(event) {\n return event.type.startsWith('touch');\n}\n/**\n * Returns true if event is a mouse event. Useful when sharing logic between touch and mouse interactions.\n */ export function isMouseEvent(event) {\n return event.type.startsWith('mouse') || [\n 'click',\n 'contextmenu',\n 'dblclick'\n ].indexOf(event.type) > -1;\n}\n/**\n * Returns an object with clientX, clientY for TouchOrMouseEvent.\n * Returns zeros in case the event is not a mouse or a touch event.\n */ export function getEventClientCoords(event) {\n if (isMouseEvent(event)) {\n return {\n clientX: event.clientX,\n clientY: event.clientY\n };\n } else if (isTouchEvent(event)) {\n return {\n clientX: event.touches[0].clientX,\n clientY: event.touches[0].clientY\n };\n } else {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('@fluentui/react-utilities]: Unable to get clientX. Unknown event type.');\n }\n return {\n clientX: 0,\n clientY: 0\n };\n }\n}\n"],"names":["isTouchEvent","isMouseEvent","getEventClientCoords","event","type","startsWith","indexOf","clientX","clientY","touches","process","env","NODE_ENV","Error"],"mappings":";;;;;;;;;;;IAGoBA,YAAY;eAAZA;;IAKAC,YAAY;eAAZA;;IAUAC,oBAAoB;eAApBA;;;;iEAlBG;AAGZ,SAASF,aAAaG,KAAK;IAClC,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC;AACjC;AAGW,SAASJ,aAAaE,KAAK;IAClC,OAAOA,MAAMC,IAAI,CAACC,UAAU,CAAC,YAAY;QACrC;QACA;QACA;KACH,CAACC,OAAO,CAACH,MAAMC,IAAI,IAAI,CAAC;AAC7B;AAIW,SAASF,qBAAqBC,KAAK;IAC1C,IAAIF,aAAaE,QAAQ;QACrB,OAAO;YACHI,SAASJ,MAAMI,OAAO;YACtBC,SAASL,MAAMK,OAAO;QAC1B;IACJ,OAAO,IAAIR,aAAaG,QAAQ;QAC5B,OAAO;YACHI,SAASJ,MAAMM,OAAO,CAAC,EAAE,CAACF,OAAO;YACjCC,SAASL,MAAMM,OAAO,CAAC,EAAE,CAACD,OAAO;QACrC;IACJ,OAAO;QACH,IAAIE,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACvC,MAAM,IAAIC,MAAM;QACpB;QACA,OAAO;YACHN,SAAS;YACTC,SAAS;QACb;IACJ;AACJ"}
|
@@ -2,17 +2,17 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
3
3
|
value: true
|
4
4
|
});
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
6
|
+
_export_star._(require("./useAnimationFrame"), exports);
|
7
|
+
_export_star._(require("./useControllableState"), exports);
|
8
|
+
_export_star._(require("./useEventCallback"), exports);
|
9
|
+
_export_star._(require("./useFirstMount"), exports);
|
10
|
+
_export_star._(require("./useForceUpdate"), exports);
|
11
|
+
_export_star._(require("./useId"), exports);
|
12
|
+
_export_star._(require("./useIsomorphicLayoutEffect"), exports);
|
13
|
+
_export_star._(require("./useMergedRefs"), exports);
|
14
|
+
_export_star._(require("./useOnClickOutside"), exports);
|
15
|
+
_export_star._(require("./useOnScrollOutside"), exports);
|
16
|
+
_export_star._(require("./usePrevious"), exports);
|
17
|
+
_export_star._(require("./useScrollbarWidth"), exports);
|
18
|
+
_export_star._(require("./useTimeout"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './useAnimationFrame';\nexport * from './useControllableState';\nexport * from './useEventCallback';\nexport * from './useFirstMount';\nexport * from './useForceUpdate';\nexport * from './useId';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMergedRefs';\nexport * from './useOnClickOutside';\nexport * from './useOnScrollOutside';\nexport * from './usePrevious';\nexport * from './useScrollbarWidth';\nexport * from './useTimeout';\n"],"names":[],"mappings":";;;;;
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './useAnimationFrame';\nexport * from './useControllableState';\nexport * from './useEventCallback';\nexport * from './useFirstMount';\nexport * from './useForceUpdate';\nexport * from './useId';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMergedRefs';\nexport * from './useOnClickOutside';\nexport * from './useOnScrollOutside';\nexport * from './usePrevious';\nexport * from './useScrollbarWidth';\nexport * from './useTimeout';\n"],"names":[],"mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA"}
|
@@ -4,10 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "useAnimationFrame", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return useAnimationFrame;
|
9
|
+
}
|
8
10
|
});
|
11
|
+
const _canUseDOM = require("../ssr/canUseDOM");
|
9
12
|
const _useBrowserTimer = require("./useBrowserTimer");
|
13
|
+
const setAnimationFrameNoop = (callback)=>{
|
14
|
+
callback(0);
|
15
|
+
return 0;
|
16
|
+
};
|
17
|
+
const cancelAnimationFrameNoop = (handle)=>handle;
|
10
18
|
function useAnimationFrame() {
|
19
|
+
const isDOM = (0, _canUseDOM.canUseDOM)();
|
11
20
|
// TODO: figure it out a way to not call global.requestAnimationFrame and instead infer window from some context
|
12
|
-
|
21
|
+
const setAnimationFrame = isDOM ? requestAnimationFrame : setAnimationFrameNoop;
|
22
|
+
const clearAnimationFrame = isDOM ? cancelAnimationFrame : cancelAnimationFrameNoop;
|
23
|
+
return (0, _useBrowserTimer.useBrowserTimer)(setAnimationFrame, clearAnimationFrame);
|
13
24
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useAnimationFrame.js"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\n/**\n * @internal\n * Helper to manage a browser requestAnimationFrame.\n * Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.\n */ export function useAnimationFrame() {\n // TODO: figure it out a way to not call global.requestAnimationFrame and instead infer window from some context\n return useBrowserTimer(
|
1
|
+
{"version":3,"sources":["useAnimationFrame.js"],"sourcesContent":["import { canUseDOM } from '../ssr/canUseDOM';\nimport { useBrowserTimer } from './useBrowserTimer';\nconst setAnimationFrameNoop = (callback)=>{\n callback(0);\n return 0;\n};\nconst cancelAnimationFrameNoop = (handle)=>handle;\n/**\n * @internal\n * Helper to manage a browser requestAnimationFrame.\n * Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.\n */ export function useAnimationFrame() {\n const isDOM = canUseDOM();\n // TODO: figure it out a way to not call global.requestAnimationFrame and instead infer window from some context\n const setAnimationFrame = isDOM ? requestAnimationFrame : setAnimationFrameNoop;\n const clearAnimationFrame = isDOM ? cancelAnimationFrame : cancelAnimationFrameNoop;\n return useBrowserTimer(setAnimationFrame, clearAnimationFrame);\n}\n"],"names":["useAnimationFrame","setAnimationFrameNoop","callback","cancelAnimationFrameNoop","handle","isDOM","canUseDOM","setAnimationFrame","requestAnimationFrame","clearAnimationFrame","cancelAnimationFrame","useBrowserTimer"],"mappings":";;;;+BAcoBA;;;eAAAA;;;2BAdM;iCACM;AAChC,MAAMC,wBAAwB,CAACC;IAC3BA,SAAS;IACT,OAAO;AACX;AACA,MAAMC,2BAA2B,CAACC,SAASA;AAQhC,SAASJ;IAChB,MAAMK,QAAQC,IAAAA,oBAAS;IACvB,gHAAgH;IAChH,MAAMC,oBAAoBF,QAAQG,wBAAwBP;IAC1D,MAAMQ,sBAAsBJ,QAAQK,uBAAuBP;IAC3D,OAAOQ,IAAAA,gCAAe,EAACJ,mBAAmBE;AAC9C"}
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "useBrowserTimer", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return useBrowserTimer;
|
9
|
+
}
|
8
10
|
});
|
9
|
-
const
|
10
|
-
const _react = /*#__PURE__*/
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
11
13
|
function useBrowserTimer(setTimer, cancelTimer) {
|
12
14
|
const id = _react.useRef(undefined);
|
13
15
|
const set = _react.useCallback((fn, delay)=>{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useBrowserTimer.js"],"sourcesContent":["import * as React from 'react';\n/**\n * @internal\n * Helper to manage a browser timer.\n * Ensures that the timer isn't set multiple times at once,\n * and is cleaned up when the component is unloaded.\n *\n * @param setTimer - The timer setter function\n * @param cancelTimer - The timer cancel function\n * @returns A pair of [setTimer, cancelTimer] that are stable between renders.\n *\n * @example\n * const [setTimer, cancelTimer] = useBrowserTimer(setTimeout, cancelTimeout);\n *\n * setTimer(() => console.log('Hello world!'), 1000);\n * cancelTimer();\n */ export function useBrowserTimer(setTimer, cancelTimer) {\n const id = React.useRef(undefined);\n const set = React.useCallback((fn, delay)=>{\n if (id.current !== undefined) {\n cancelTimer(id.current);\n }\n id.current = setTimer(fn, delay);\n return id.current;\n }, [\n cancelTimer,\n setTimer\n ]);\n const cancel = React.useCallback(()=>{\n if (id.current !== undefined) {\n cancelTimer(id.current);\n id.current = undefined;\n }\n }, [\n cancelTimer\n ]);\n // Clean up the timeout when the component is unloaded\n React.useEffect(()=>cancel, [\n cancel\n ]);\n return [\n set,\n cancel\n ];\n}\n"],"names":["useBrowserTimer","setTimer","cancelTimer","id","React","useRef","undefined","set","useCallback","fn","delay","current","cancel","useEffect"],"mappings":";;;;+BAgBoBA
|
1
|
+
{"version":3,"sources":["useBrowserTimer.js"],"sourcesContent":["import * as React from 'react';\n/**\n * @internal\n * Helper to manage a browser timer.\n * Ensures that the timer isn't set multiple times at once,\n * and is cleaned up when the component is unloaded.\n *\n * @param setTimer - The timer setter function\n * @param cancelTimer - The timer cancel function\n * @returns A pair of [setTimer, cancelTimer] that are stable between renders.\n *\n * @example\n * const [setTimer, cancelTimer] = useBrowserTimer(setTimeout, cancelTimeout);\n *\n * setTimer(() => console.log('Hello world!'), 1000);\n * cancelTimer();\n */ export function useBrowserTimer(setTimer, cancelTimer) {\n const id = React.useRef(undefined);\n const set = React.useCallback((fn, delay)=>{\n if (id.current !== undefined) {\n cancelTimer(id.current);\n }\n id.current = setTimer(fn, delay);\n return id.current;\n }, [\n cancelTimer,\n setTimer\n ]);\n const cancel = React.useCallback(()=>{\n if (id.current !== undefined) {\n cancelTimer(id.current);\n id.current = undefined;\n }\n }, [\n cancelTimer\n ]);\n // Clean up the timeout when the component is unloaded\n React.useEffect(()=>cancel, [\n cancel\n ]);\n return [\n set,\n cancel\n ];\n}\n"],"names":["useBrowserTimer","setTimer","cancelTimer","id","React","useRef","undefined","set","useCallback","fn","delay","current","cancel","useEffect"],"mappings":";;;;+BAgBoBA;;;eAAAA;;;;iEAhBG;AAgBZ,SAASA,gBAAgBC,QAAQ,EAAEC,WAAW;IACrD,MAAMC,KAAKC,OAAMC,MAAM,CAACC;IACxB,MAAMC,MAAMH,OAAMI,WAAW,CAAC,CAACC,IAAIC;QAC/B,IAAIP,GAAGQ,OAAO,KAAKL,WAAW;YAC1BJ,YAAYC,GAAGQ,OAAO;QAC1B;QACAR,GAAGQ,OAAO,GAAGV,SAASQ,IAAIC;QAC1B,OAAOP,GAAGQ,OAAO;IACrB,GAAG;QACCT;QACAD;KACH;IACD,MAAMW,SAASR,OAAMI,WAAW,CAAC;QAC7B,IAAIL,GAAGQ,OAAO,KAAKL,WAAW;YAC1BJ,YAAYC,GAAGQ,OAAO;YACtBR,GAAGQ,OAAO,GAAGL;QACjB;IACJ,GAAG;QACCJ;KACH;IACD,sDAAsD;IACtDE,OAAMS,SAAS,CAAC,IAAID,QAAQ;QACxBA;KACH;IACD,OAAO;QACHL;QACAK;KACH;AACL"}
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "useControllableState", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return useControllableState;
|
9
|
+
}
|
8
10
|
});
|
9
|
-
const
|
10
|
-
const _react = /*#__PURE__*/
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
11
13
|
function isFactoryDispatch(newState) {
|
12
14
|
return typeof newState === 'function';
|
13
15
|
}
|
@@ -57,14 +59,11 @@ function isInitializer(value) {
|
|
57
59
|
const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';
|
58
60
|
const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';
|
59
61
|
// eslint-disable-next-line no-console
|
60
|
-
console.error([
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
'More info: https://reactjs.org/link/controlled-components',
|
66
|
-
error.stack
|
67
|
-
].join(' '));
|
62
|
+
console.error(`@fluentui/react-utilities [${useControllableState.name}]:
|
63
|
+
A component is changing ${controlWarning}. This is likely caused by the value changing from ${undefinedWarning} value, which should not happen.
|
64
|
+
Decide between using a controlled or uncontrolled input element for the lifetime of the component.
|
65
|
+
More info: https://reactjs.org/link/controlled-components
|
66
|
+
${error.stack}`);
|
68
67
|
}
|
69
68
|
}, [
|
70
69
|
isControlled,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useControllableState.js"],"sourcesContent":["import * as React from 'react';\nfunction isFactoryDispatch(newState) {\n return typeof newState === 'function';\n}\n/**\n * @internal\n *\n * A [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate)-like hook\n * to manage a value that could be either `controlled` or `uncontrolled`,\n * such as a checked state or text input string.\n *\n * @see https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components for more details on `controlled`/`uncontrolled`\n *\n * @returns an array of the current value and an updater (dispatcher) function.\n * The updater function is referentially stable (won't change during the component's lifecycle).\n * It can take either a new value, or a function which is passed the previous value and returns the new value.\n *\n * ❗️❗️ Calls to the dispatcher will only modify the state if the state is `uncontrolled`.\n * Meaning that if a state is `controlled`, calls to the dispatcher do not modify the state.\n *\n */ export const useControllableState = (options)=>{\n const [internalState, setInternalState] = React.useState(()=>{\n if (options.defaultState === undefined) {\n return options.initialState;\n }\n return isInitializer(options.defaultState) ? options.defaultState() : options.defaultState;\n });\n // Heads up!\n // This part is specific for controlled mode and mocks behavior of React dispatcher function.\n const stateValueRef = React.useRef(options.state);\n React.useEffect(()=>{\n stateValueRef.current = options.state;\n }, [\n options.state\n ]);\n const setControlledState = React.useCallback((newState)=>{\n if (isFactoryDispatch(newState)) {\n newState(stateValueRef.current);\n }\n }, []);\n return useIsControlled(options.state) ? [\n options.state,\n setControlledState\n ] : [\n internalState,\n setInternalState\n ];\n};\nfunction isInitializer(value) {\n return typeof value === 'function';\n}\n/**\n * Helper hook to handle previous comparison of controlled/uncontrolled\n * Prints an error when isControlled value switches between subsequent renders\n * @returns - whether the value is controlled\n */ const useIsControlled = (controlledValue)=>{\n const [isControlled] = React.useState(()=>controlledValue !== undefined);\n if (process.env.NODE_ENV !== 'production') {\n // We don't want these warnings in production even though it is against native behaviour\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(()=>{\n if (isControlled !== (controlledValue !== undefined)) {\n const error = new Error();\n const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';\n const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';\n // eslint-disable-next-line no-console\n console.error(
|
1
|
+
{"version":3,"sources":["useControllableState.js"],"sourcesContent":["import * as React from 'react';\nfunction isFactoryDispatch(newState) {\n return typeof newState === 'function';\n}\n/**\n * @internal\n *\n * A [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate)-like hook\n * to manage a value that could be either `controlled` or `uncontrolled`,\n * such as a checked state or text input string.\n *\n * @see https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components for more details on `controlled`/`uncontrolled`\n *\n * @returns an array of the current value and an updater (dispatcher) function.\n * The updater function is referentially stable (won't change during the component's lifecycle).\n * It can take either a new value, or a function which is passed the previous value and returns the new value.\n *\n * ❗️❗️ Calls to the dispatcher will only modify the state if the state is `uncontrolled`.\n * Meaning that if a state is `controlled`, calls to the dispatcher do not modify the state.\n *\n */ export const useControllableState = (options)=>{\n const [internalState, setInternalState] = React.useState(()=>{\n if (options.defaultState === undefined) {\n return options.initialState;\n }\n return isInitializer(options.defaultState) ? options.defaultState() : options.defaultState;\n });\n // Heads up!\n // This part is specific for controlled mode and mocks behavior of React dispatcher function.\n const stateValueRef = React.useRef(options.state);\n React.useEffect(()=>{\n stateValueRef.current = options.state;\n }, [\n options.state\n ]);\n const setControlledState = React.useCallback((newState)=>{\n if (isFactoryDispatch(newState)) {\n newState(stateValueRef.current);\n }\n }, []);\n return useIsControlled(options.state) ? [\n options.state,\n setControlledState\n ] : [\n internalState,\n setInternalState\n ];\n};\nfunction isInitializer(value) {\n return typeof value === 'function';\n}\n/**\n * Helper hook to handle previous comparison of controlled/uncontrolled\n * Prints an error when isControlled value switches between subsequent renders\n * @returns - whether the value is controlled\n */ const useIsControlled = (controlledValue)=>{\n const [isControlled] = React.useState(()=>controlledValue !== undefined);\n if (process.env.NODE_ENV !== 'production') {\n // We don't want these warnings in production even though it is against native behaviour\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(()=>{\n if (isControlled !== (controlledValue !== undefined)) {\n const error = new Error();\n const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';\n const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';\n // eslint-disable-next-line no-console\n console.error(`@fluentui/react-utilities [${useControllableState.name}]:\nA component is changing ${controlWarning}. This is likely caused by the value changing from ${undefinedWarning} value, which should not happen.\nDecide between using a controlled or uncontrolled input element for the lifetime of the component.\nMore info: https://reactjs.org/link/controlled-components\n${error.stack}`);\n }\n }, [\n isControlled,\n controlledValue\n ]);\n }\n return isControlled;\n};\n"],"names":["useControllableState","isFactoryDispatch","newState","options","internalState","setInternalState","React","useState","defaultState","undefined","initialState","isInitializer","stateValueRef","useRef","state","useEffect","current","setControlledState","useCallback","useIsControlled","value","controlledValue","isControlled","process","env","NODE_ENV","error","Error","controlWarning","undefinedWarning","console","name","stack"],"mappings":";;;;+BAoBiBA;;;eAAAA;;;;iEApBM;AACvB,SAASC,kBAAkBC,QAAQ;IAC/B,OAAO,OAAOA,aAAa;AAC/B;AAiBW,MAAMF,uBAAuB,CAACG;IACrC,MAAM,CAACC,eAAeC,iBAAiB,GAAGC,OAAMC,QAAQ,CAAC;QACrD,IAAIJ,QAAQK,YAAY,KAAKC,WAAW;YACpC,OAAON,QAAQO,YAAY;QAC/B;QACA,OAAOC,cAAcR,QAAQK,YAAY,IAAIL,QAAQK,YAAY,KAAKL,QAAQK,YAAY;IAC9F;IACA,YAAY;IACZ,6FAA6F;IAC7F,MAAMI,gBAAgBN,OAAMO,MAAM,CAACV,QAAQW,KAAK;IAChDR,OAAMS,SAAS,CAAC;QACZH,cAAcI,OAAO,GAAGb,QAAQW,KAAK;IACzC,GAAG;QACCX,QAAQW,KAAK;KAChB;IACD,MAAMG,qBAAqBX,OAAMY,WAAW,CAAC,CAAChB;QAC1C,IAAID,kBAAkBC,WAAW;YAC7BA,SAASU,cAAcI,OAAO;QAClC;IACJ,GAAG,EAAE;IACL,OAAOG,gBAAgBhB,QAAQW,KAAK,IAAI;QACpCX,QAAQW,KAAK;QACbG;KACH,GAAG;QACAb;QACAC;KACH;AACL;AACA,SAASM,cAAcS,KAAK;IACxB,OAAO,OAAOA,UAAU;AAC5B;AACA;;;;CAIC,GAAG,MAAMD,kBAAkB,CAACE;IACzB,MAAM,CAACC,aAAa,GAAGhB,OAAMC,QAAQ,CAAC,IAAIc,oBAAoBZ;IAC9D,IAAIc,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACvC,wFAAwF;QACxF,sDAAsD;QACtDnB,OAAMS,SAAS,CAAC;YACZ,IAAIO,iBAAkBD,CAAAA,oBAAoBZ,SAAQ,GAAI;gBAClD,MAAMiB,QAAQ,IAAIC;gBAClB,MAAMC,iBAAiBN,eAAe,0CAA0C;gBAChF,MAAMO,mBAAmBP,eAAe,4BAA4B;gBACpE,sCAAsC;gBACtCQ,QAAQJ,KAAK,CAAC,CAAC,2BAA2B,EAAE1B,qBAAqB+B,IAAI,CAAC;wBAC9D,EAAEH,eAAe,mDAAmD,EAAEC,iBAAiB;;;AAG/G,EAAEH,MAAMM,KAAK,CAAC,CAAC;YACH;QACJ,GAAG;YACCV;YACAD;SACH;IACL;IACA,OAAOC;AACX"}
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "useEventCallback", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return useEventCallback;
|
9
|
+
}
|
8
10
|
});
|
9
|
-
const
|
10
|
-
const _react = /*#__PURE__*/
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
11
13
|
const _useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect");
|
12
14
|
const useEventCallback = (fn)=>{
|
13
15
|
const callbackRef = _react.useRef(()=>{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useEventCallback.js"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n/**\n * @internal\n * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n *\n * Modified `useCallback` that can be used when dependencies change too frequently. Can occur when\n * e.g. user props are dependencies which could change on every render\n * e.g. volatile values (i.e. useState/useDispatch) are dependencies which could change frequently\n *\n * This should not be used often, but can be a useful re-render optimization since the callback is a ref and\n * will not be invalidated between re-renders\n *\n * @param fn - The callback function that will be used\n */ export const useEventCallback = (fn)=>{\n const callbackRef = React.useRef(()=>{\n throw new Error('Cannot call an event handler while rendering');\n });\n useIsomorphicLayoutEffect(()=>{\n callbackRef.current = fn;\n }, [\n fn\n ]);\n return React.useCallback((...args)=>{\n const callback = callbackRef.current;\n return callback(...args);\n }, [\n callbackRef\n ]);\n};\n"],"names":["useEventCallback","fn","callbackRef","React","useRef","Error","useIsomorphicLayoutEffect","current","useCallback","args","callback"],"mappings":";;;;+BAciBA
|
1
|
+
{"version":3,"sources":["useEventCallback.js"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n/**\n * @internal\n * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n *\n * Modified `useCallback` that can be used when dependencies change too frequently. Can occur when\n * e.g. user props are dependencies which could change on every render\n * e.g. volatile values (i.e. useState/useDispatch) are dependencies which could change frequently\n *\n * This should not be used often, but can be a useful re-render optimization since the callback is a ref and\n * will not be invalidated between re-renders\n *\n * @param fn - The callback function that will be used\n */ export const useEventCallback = (fn)=>{\n const callbackRef = React.useRef(()=>{\n throw new Error('Cannot call an event handler while rendering');\n });\n useIsomorphicLayoutEffect(()=>{\n callbackRef.current = fn;\n }, [\n fn\n ]);\n return React.useCallback((...args)=>{\n const callback = callbackRef.current;\n return callback(...args);\n }, [\n callbackRef\n ]);\n};\n"],"names":["useEventCallback","fn","callbackRef","React","useRef","Error","useIsomorphicLayoutEffect","current","useCallback","args","callback"],"mappings":";;;;+BAciBA;;;eAAAA;;;;iEAdM;2CACmB;AAa/B,MAAMA,mBAAmB,CAACC;IACjC,MAAMC,cAAcC,OAAMC,MAAM,CAAC;QAC7B,MAAM,IAAIC,MAAM;IACpB;IACAC,IAAAA,oDAAyB,EAAC;QACtBJ,YAAYK,OAAO,GAAGN;IAC1B,GAAG;QACCA;KACH;IACD,OAAOE,OAAMK,WAAW,CAAC,CAAC,GAAGC;QACzB,MAAMC,WAAWR,YAAYK,OAAO;QACpC,OAAOG,YAAYD;IACvB,GAAG;QACCP;KACH;AACL"}
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "useFirstMount", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return useFirstMount;
|
9
|
+
}
|
8
10
|
});
|
9
|
-
const
|
10
|
-
const _react = /*#__PURE__*/
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
11
13
|
function useFirstMount() {
|
12
14
|
const isFirst = _react.useRef(true);
|
13
15
|
if (isFirst.current) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useFirstMount.js"],"sourcesContent":["import * as React from 'react';\n/**\n * @internal\n * Checks if components was mounted the first time.\n * Since concurrent mode will be released in the future this needs to be verified\n * Currently (React 17) will always render the initial mount once\n * https://codesandbox.io/s/heuristic-brook-s4w0q?file=/src/App.jsx\n * https://codesandbox.io/s/holy-grass-8nieu?file=/src/App.jsx\n *\n * @example\n * const isFirstMount = useFirstMount();\n */ export function useFirstMount() {\n const isFirst = React.useRef(true);\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n return isFirst.current;\n}\n"],"names":["useFirstMount","isFirst","React","useRef","current"],"mappings":";;;;+BAWoBA
|
1
|
+
{"version":3,"sources":["useFirstMount.js"],"sourcesContent":["import * as React from 'react';\n/**\n * @internal\n * Checks if components was mounted the first time.\n * Since concurrent mode will be released in the future this needs to be verified\n * Currently (React 17) will always render the initial mount once\n * https://codesandbox.io/s/heuristic-brook-s4w0q?file=/src/App.jsx\n * https://codesandbox.io/s/holy-grass-8nieu?file=/src/App.jsx\n *\n * @example\n * const isFirstMount = useFirstMount();\n */ export function useFirstMount() {\n const isFirst = React.useRef(true);\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n return isFirst.current;\n}\n"],"names":["useFirstMount","isFirst","React","useRef","current"],"mappings":";;;;+BAWoBA;;;eAAAA;;;;iEAXG;AAWZ,SAASA;IAChB,MAAMC,UAAUC,OAAMC,MAAM,CAAC;IAC7B,IAAIF,QAAQG,OAAO,EAAE;QACjBH,QAAQG,OAAO,GAAG;QAClB,OAAO;IACX;IACA,OAAOH,QAAQG,OAAO;AAC1B"}
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "useForceUpdate", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return useForceUpdate;
|
9
|
+
}
|
8
10
|
});
|
9
11
|
const _react = require("react");
|
10
12
|
function useForceUpdate() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useForceUpdate.js"],"sourcesContent":["import { useReducer } from 'react';\n/**\n * @internal\n * Forces a re-render, similar to `forceUpdate` in class components.\n */ export function useForceUpdate() {\n return useReducer((x)=>x + 1, 0)[1];\n}\n"],"names":["useForceUpdate","useReducer","x"],"mappings":";;;;+BAIoBA
|
1
|
+
{"version":3,"sources":["useForceUpdate.js"],"sourcesContent":["import { useReducer } from 'react';\n/**\n * @internal\n * Forces a re-render, similar to `forceUpdate` in class components.\n */ export function useForceUpdate() {\n return useReducer((x)=>x + 1, 0)[1];\n}\n"],"names":["useForceUpdate","useReducer","x"],"mappings":";;;;+BAIoBA;;;eAAAA;;;uBAJO;AAIhB,SAASA;IAChB,OAAOC,IAAAA,iBAAU,EAAC,CAACC,IAAIA,IAAI,GAAG,EAAE,CAAC,EAAE;AACvC"}
|
@@ -9,12 +9,18 @@ function _export(target, all) {
|
|
9
9
|
});
|
10
10
|
}
|
11
11
|
_export(exports, {
|
12
|
-
IdPrefixProvider: ()
|
13
|
-
|
14
|
-
|
12
|
+
IdPrefixProvider: function() {
|
13
|
+
return IdPrefixProvider;
|
14
|
+
},
|
15
|
+
resetIdsForTests: function() {
|
16
|
+
return resetIdsForTests;
|
17
|
+
},
|
18
|
+
useId: function() {
|
19
|
+
return useId;
|
20
|
+
}
|
15
21
|
});
|
16
|
-
const
|
17
|
-
const _react = /*#__PURE__*/
|
22
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
23
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
18
24
|
const _index = require("../ssr/index");
|
19
25
|
const IdPrefixContext = /*#__PURE__*/ _react.createContext(undefined);
|
20
26
|
const IdPrefixProvider = IdPrefixContext.Provider;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useId.js"],"sourcesContent":["import * as React from 'react';\nimport { defaultSSRContextValue, useSSRContext } from '../ssr/index';\nconst IdPrefixContext = React.createContext(undefined);\n/**\n * Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions\n * between different bundles.\n */ export const IdPrefixProvider = IdPrefixContext.Provider;\nfunction useIdPrefix() {\n return React.useContext(IdPrefixContext) || '';\n}\n/**\n * Resets generated IDs, should be used only in tests.\n */ export function resetIdsForTests() {\n defaultSSRContextValue.current = 0;\n}\n/**\n * Hook to generate a unique ID.\n *\n * @param prefix - Optional prefix for the ID. Defaults to 'fui-'.\n * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,\n * without conditioning the hook call\n * @returns The ID\n */ export function useId(prefix = 'fui-', providedId) {\n const contextValue = useSSRContext();\n const idPrefix = useIdPrefix();\n // Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to\n // prevent bundlers from complaining with older versions of React.\n const _useId = React['use' + 'Id'];\n if (_useId) {\n const generatedId = _useId();\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const escapedId = React.useMemo(()=>generatedId.replace(/:/g, ''), [\n generatedId\n ]);\n return providedId || `${idPrefix}${prefix}${escapedId}`;\n }\n // Hooks appear to be running conditionally, but they will always run in the same order since it's based on\n // the version of React being used. This is safe to ignore.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return React.useMemo(()=>{\n if (providedId) {\n return providedId;\n }\n return `${idPrefix}${prefix}${++contextValue.current}`;\n }, [\n idPrefix,\n prefix,\n providedId,\n contextValue\n ]);\n}\n"],"names":["IdPrefixProvider","resetIdsForTests","useId","IdPrefixContext","React","createContext","undefined","Provider","useIdPrefix","useContext","defaultSSRContextValue","current","prefix","providedId","contextValue","useSSRContext","idPrefix","_useId","generatedId","escapedId","useMemo","replace"],"mappings":";;;;;;;;;;;IAMiBA,gBAAgB
|
1
|
+
{"version":3,"sources":["useId.js"],"sourcesContent":["import * as React from 'react';\nimport { defaultSSRContextValue, useSSRContext } from '../ssr/index';\nconst IdPrefixContext = React.createContext(undefined);\n/**\n * Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions\n * between different bundles.\n */ export const IdPrefixProvider = IdPrefixContext.Provider;\nfunction useIdPrefix() {\n return React.useContext(IdPrefixContext) || '';\n}\n/**\n * Resets generated IDs, should be used only in tests.\n */ export function resetIdsForTests() {\n defaultSSRContextValue.current = 0;\n}\n/**\n * Hook to generate a unique ID.\n *\n * @param prefix - Optional prefix for the ID. Defaults to 'fui-'.\n * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,\n * without conditioning the hook call\n * @returns The ID\n */ export function useId(prefix = 'fui-', providedId) {\n const contextValue = useSSRContext();\n const idPrefix = useIdPrefix();\n // Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to\n // prevent bundlers from complaining with older versions of React.\n const _useId = React['use' + 'Id'];\n if (_useId) {\n const generatedId = _useId();\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const escapedId = React.useMemo(()=>generatedId.replace(/:/g, ''), [\n generatedId\n ]);\n return providedId || `${idPrefix}${prefix}${escapedId}`;\n }\n // Hooks appear to be running conditionally, but they will always run in the same order since it's based on\n // the version of React being used. This is safe to ignore.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return React.useMemo(()=>{\n if (providedId) {\n return providedId;\n }\n return `${idPrefix}${prefix}${++contextValue.current}`;\n }, [\n idPrefix,\n prefix,\n providedId,\n contextValue\n ]);\n}\n"],"names":["IdPrefixProvider","resetIdsForTests","useId","IdPrefixContext","React","createContext","undefined","Provider","useIdPrefix","useContext","defaultSSRContextValue","current","prefix","providedId","contextValue","useSSRContext","idPrefix","_useId","generatedId","escapedId","useMemo","replace"],"mappings":";;;;;;;;;;;IAMiBA,gBAAgB;eAAhBA;;IAMGC,gBAAgB;eAAhBA;;IAUAC,KAAK;eAALA;;;;iEAtBG;uBAC+B;AACtD,MAAMC,gCAAkBC,OAAMC,aAAa,CAACC;AAIjC,MAAMN,mBAAmBG,gBAAgBI,QAAQ;AAC5D,SAASC;IACL,OAAOJ,OAAMK,UAAU,CAACN,oBAAoB;AAChD;AAGW,SAASF;IAChBS,6BAAsB,CAACC,OAAO,GAAG;AACrC;AAQW,SAAST,MAAMU,SAAS,MAAM,EAAEC,UAAU;IACjD,MAAMC,eAAeC,IAAAA,oBAAa;IAClC,MAAMC,WAAWR;IACjB,mHAAmH;IACnH,kEAAkE;IAClE,MAAMS,SAASb,MAAK,CAAC,QAAQ,KAAK;IAClC,IAAIa,QAAQ;QACR,MAAMC,cAAcD;QACpB,sDAAsD;QACtD,MAAME,YAAYf,OAAMgB,OAAO,CAAC,IAAIF,YAAYG,OAAO,CAAC,MAAM,KAAK;YAC/DH;SACH;QACD,OAAOL,cAAc,CAAC,EAAEG,SAAS,EAAEJ,OAAO,EAAEO,UAAU,CAAC;IAC3D;IACA,2GAA2G;IAC3G,2DAA2D;IAC3D,sDAAsD;IACtD,OAAOf,OAAMgB,OAAO,CAAC;QACjB,IAAIP,YAAY;YACZ,OAAOA;QACX;QACA,OAAO,CAAC,EAAEG,SAAS,EAAEJ,OAAO,EAAE,EAAEE,aAAaH,OAAO,CAAC,CAAC;IAC1D,GAAG;QACCK;QACAJ;QACAC;QACAC;KACH;AACL"}
|
@@ -4,9 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "useIsomorphicLayoutEffect", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return useIsomorphicLayoutEffect;
|
9
|
+
}
|
8
10
|
});
|
9
|
-
const
|
10
|
-
const _react = /*#__PURE__*/
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
11
13
|
const _index = require("../ssr/index");
|
12
14
|
const useIsomorphicLayoutEffect = (0, _index.canUseDOM)() ? _react.useLayoutEffect : _react.useEffect;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useIsomorphicLayoutEffect.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '../ssr/index';\n/**\n * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally\n * useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to\n * ensure we don't get a render flash for certain operations, but we may also need affected components to render on\n * the server.\n *\n * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\n * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js\n */ // eslint-disable-next-line no-restricted-properties\nexport const useIsomorphicLayoutEffect = canUseDOM() ? React.useLayoutEffect : React.useEffect;\n"],"names":["useIsomorphicLayoutEffect","canUseDOM","React","useLayoutEffect","useEffect"],"mappings":";;;;+BAWaA
|
1
|
+
{"version":3,"sources":["useIsomorphicLayoutEffect.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '../ssr/index';\n/**\n * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally\n * useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to\n * ensure we don't get a render flash for certain operations, but we may also need affected components to render on\n * the server.\n *\n * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\n * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js\n */ // eslint-disable-next-line no-restricted-properties\nexport const useIsomorphicLayoutEffect = canUseDOM() ? React.useLayoutEffect : React.useEffect;\n"],"names":["useIsomorphicLayoutEffect","canUseDOM","React","useLayoutEffect","useEffect"],"mappings":";;;;+BAWaA;;;eAAAA;;;;iEAXU;uBACG;AAUnB,MAAMA,4BAA4BC,IAAAA,gBAAS,MAAKC,OAAMC,eAAe,GAAGD,OAAME,SAAS"}
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "useMergedRefs", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return useMergedRefs;
|
9
|
+
}
|
8
10
|
});
|
9
|
-
const
|
10
|
-
const _react = /*#__PURE__*/
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
11
13
|
function useMergedRefs(...refs) {
|
12
14
|
const mergedCallback = _react.useCallback((value)=>{
|
13
15
|
// Update the "current" prop hanging on the function.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useMergedRefs.js"],"sourcesContent":["import * as React from 'react';\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */ export function useMergedRefs(...refs) {\n const mergedCallback = React.useCallback((value)=>{\n // Update the \"current\" prop hanging on the function.\n mergedCallback.current = value;\n for (const ref of refs){\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n // work around the immutability of the React.Ref type\n ref.current = value;\n }\n }\n }, // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive\n [\n ...refs\n ]);\n return mergedCallback;\n}\n"],"names":["useMergedRefs","refs","mergedCallback","React","useCallback","value","current","ref"],"mappings":";;;;+BAMoBA
|
1
|
+
{"version":3,"sources":["useMergedRefs.js"],"sourcesContent":["import * as React from 'react';\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */ export function useMergedRefs(...refs) {\n const mergedCallback = React.useCallback((value)=>{\n // Update the \"current\" prop hanging on the function.\n mergedCallback.current = value;\n for (const ref of refs){\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n // work around the immutability of the React.Ref type\n ref.current = value;\n }\n }\n }, // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive\n [\n ...refs\n ]);\n return mergedCallback;\n}\n"],"names":["useMergedRefs","refs","mergedCallback","React","useCallback","value","current","ref"],"mappings":";;;;+BAMoBA;;;eAAAA;;;;iEANG;AAMZ,SAASA,cAAc,GAAGC,IAAI;IACrC,MAAMC,iBAAiBC,OAAMC,WAAW,CAAC,CAACC;QACtC,qDAAqD;QACrDH,eAAeI,OAAO,GAAGD;QACzB,KAAK,MAAME,OAAON,KAAK;YACnB,IAAI,OAAOM,QAAQ,YAAY;gBAC3BA,IAAIF;YACR,OAAO,IAAIE,KAAK;gBACZ,qDAAqD;gBACrDA,IAAID,OAAO,GAAGD;YAClB;QACJ;IACJ,GACA;WACOJ;KACN;IACD,OAAOC;AACX"}
|
@@ -4,19 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
Object.defineProperty(exports, "useOnClickOutside", {
|
6
6
|
enumerable: true,
|
7
|
-
get: ()
|
7
|
+
get: function() {
|
8
|
+
return useOnClickOutside;
|
9
|
+
}
|
8
10
|
});
|
9
|
-
const
|
10
|
-
const _react = /*#__PURE__*/
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
11
13
|
const _useEventCallback = require("./useEventCallback");
|
14
|
+
const DEFAULT_CONTAINS = (parent, child)=>{
|
15
|
+
var _parent;
|
16
|
+
return !!((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.contains(child));
|
17
|
+
};
|
12
18
|
const useOnClickOutside = (options)=>{
|
13
|
-
const { refs
|
19
|
+
const { refs, callback, element, disabled, disabledFocusOnIframe, contains = DEFAULT_CONTAINS } = options;
|
14
20
|
const timeoutId = _react.useRef(undefined);
|
15
|
-
useIFrameFocus(
|
16
|
-
|
17
|
-
|
18
|
-
|
21
|
+
useIFrameFocus({
|
22
|
+
element,
|
23
|
+
disabled: disabledFocusOnIframe || disabled,
|
24
|
+
callback,
|
25
|
+
refs,
|
26
|
+
contains
|
19
27
|
});
|
28
|
+
const isMouseDownInsideRef = _react.useRef(false);
|
20
29
|
const listener = (0, _useEventCallback.useEventCallback)((ev)=>{
|
21
30
|
if (isMouseDownInsideRef.current) {
|
22
31
|
isMouseDownInsideRef.current = false;
|
@@ -35,6 +44,7 @@ const useOnClickOutside = (options)=>{
|
|
35
44
|
isMouseDownInsideRef.current = refs.some((ref)=>contains(ref.current || null, ev.target));
|
36
45
|
});
|
37
46
|
_react.useEffect(()=>{
|
47
|
+
var _element, _element1, _element2;
|
38
48
|
if (disabled) {
|
39
49
|
return;
|
40
50
|
}
|
@@ -50,20 +60,18 @@ const useOnClickOutside = (options)=>{
|
|
50
60
|
}
|
51
61
|
listener(event);
|
52
62
|
};
|
53
|
-
|
54
|
-
element === null ||
|
55
|
-
element === null ||
|
56
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('contextmenu', conditionalHandler, true);
|
57
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('mousedown', handleMouseDown, true);
|
63
|
+
(_element = element) === null || _element === void 0 ? void 0 : _element.addEventListener('touchstart', conditionalHandler, true);
|
64
|
+
(_element1 = element) === null || _element1 === void 0 ? void 0 : _element1.addEventListener('mouseup', conditionalHandler, true);
|
65
|
+
(_element2 = element) === null || _element2 === void 0 ? void 0 : _element2.addEventListener('mousedown', handleMouseDown, true);
|
58
66
|
// Garbage collect this event after it's no longer useful to avoid memory leaks
|
59
67
|
timeoutId.current = window.setTimeout(()=>{
|
60
68
|
currentEvent = undefined;
|
61
69
|
}, 1);
|
62
70
|
return ()=>{
|
63
|
-
|
64
|
-
element === null ||
|
65
|
-
element === null ||
|
66
|
-
element === null ||
|
71
|
+
var _element, _element1, _element2;
|
72
|
+
(_element = element) === null || _element === void 0 ? void 0 : _element.removeEventListener('touchstart', conditionalHandler, true);
|
73
|
+
(_element1 = element) === null || _element1 === void 0 ? void 0 : _element1.removeEventListener('mouseup', conditionalHandler, true);
|
74
|
+
(_element2 = element) === null || _element2 === void 0 ? void 0 : _element2.removeEventListener('mousedown', handleMouseDown, true);
|
67
75
|
clearTimeout(timeoutId.current);
|
68
76
|
currentEvent = undefined;
|
69
77
|
};
|
@@ -76,7 +84,7 @@ const useOnClickOutside = (options)=>{
|
|
76
84
|
};
|
77
85
|
const getWindowEvent = (target)=>{
|
78
86
|
if (target) {
|
79
|
-
var
|
87
|
+
var _target_ownerDocument_defaultView, _target_ownerDocument;
|
80
88
|
if (typeof target.window === 'object' && target.window === target) {
|
81
89
|
// eslint-disable-next-line deprecation/deprecation
|
82
90
|
return target.event;
|
@@ -98,14 +106,9 @@ const FUI_FRAME_EVENT = 'fuiframefocus';
|
|
98
106
|
* Polls the value of `document.activeElement`. If it is an iframe, then dispatch
|
99
107
|
* a custom DOM event. When the custom event is received call the provided callback
|
100
108
|
*/ const useIFrameFocus = (options)=>{
|
101
|
-
const { disabled
|
102
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
103
|
-
} , pollDuration =1000 , refs } = options;
|
109
|
+
const { disabled, element: targetDocument, callback, contains = DEFAULT_CONTAINS, pollDuration = 1000, refs } = options;
|
104
110
|
const timeoutRef = _react.useRef();
|
105
111
|
const listener = (0, _useEventCallback.useEventCallback)((e)=>{
|
106
|
-
const contains = containsProp || ((parent, child)=>{
|
107
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
108
|
-
});
|
109
112
|
const isOutside = refs.every((ref)=>!contains(ref.current || null, e.target));
|
110
113
|
if (isOutside && !disabled) {
|
111
114
|
callback(e);
|
@@ -113,12 +116,14 @@ const FUI_FRAME_EVENT = 'fuiframefocus';
|
|
113
116
|
});
|
114
117
|
// Adds listener to the custom iframe focus event
|
115
118
|
_react.useEffect(()=>{
|
119
|
+
var _targetDocument;
|
116
120
|
if (disabled) {
|
117
121
|
return;
|
118
122
|
}
|
119
|
-
targetDocument === null ||
|
123
|
+
(_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.addEventListener(FUI_FRAME_EVENT, listener, true);
|
120
124
|
return ()=>{
|
121
|
-
|
125
|
+
var _targetDocument;
|
126
|
+
(_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.removeEventListener(FUI_FRAME_EVENT, listener, true);
|
122
127
|
};
|
123
128
|
}, [
|
124
129
|
targetDocument,
|
@@ -127,13 +132,14 @@ const FUI_FRAME_EVENT = 'fuiframefocus';
|
|
127
132
|
]);
|
128
133
|
// Starts polling for the active element
|
129
134
|
_react.useEffect(()=>{
|
130
|
-
var _targetDocument_defaultView;
|
135
|
+
var _targetDocument_defaultView, _targetDocument;
|
131
136
|
if (disabled) {
|
132
137
|
return;
|
133
138
|
}
|
134
|
-
timeoutRef.current = targetDocument === null ||
|
135
|
-
|
136
|
-
|
139
|
+
timeoutRef.current = (_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = _targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.setInterval(()=>{
|
140
|
+
var _targetDocument, _activeElement, _activeElement1;
|
141
|
+
const activeElement = (_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.activeElement;
|
142
|
+
if (((_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.tagName) === 'IFRAME' || ((_activeElement1 = activeElement) === null || _activeElement1 === void 0 ? void 0 : _activeElement1.tagName) === 'WEBVIEW') {
|
137
143
|
const event = new CustomEvent(FUI_FRAME_EVENT, {
|
138
144
|
bubbles: true
|
139
145
|
});
|
@@ -141,8 +147,8 @@ const FUI_FRAME_EVENT = 'fuiframefocus';
|
|
141
147
|
}
|
142
148
|
}, pollDuration);
|
143
149
|
return ()=>{
|
144
|
-
var _targetDocument_defaultView;
|
145
|
-
targetDocument === null ||
|
150
|
+
var _targetDocument_defaultView, _targetDocument;
|
151
|
+
(_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = _targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.clearTimeout(timeoutRef.current);
|
146
152
|
};
|
147
153
|
}, [
|
148
154
|
targetDocument,
|