@fluentui/react-utilities 9.7.0 → 9.7.2
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 +30 -0
- package/CHANGELOG.json +49 -1
- package/CHANGELOG.md +23 -2
- package/dist/index.d.ts +16 -4
- package/lib/compose/getSlots.js +3 -3
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/index.js.map +1 -1
- package/lib/compose/isResolvedShorthand.js.map +1 -1
- package/lib/compose/resolveShorthand.js.map +1 -1
- package/lib/compose/types.js +1 -1
- package/lib/compose/types.js.map +1 -1
- package/lib/events/index.js.map +1 -1
- package/lib/events/mouseTouchHelpers.js +1 -0
- package/lib/events/mouseTouchHelpers.js.map +1 -1
- package/lib/hooks/index.js.map +1 -1
- 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/useIsomorphicLayoutEffect.js +1 -2
- package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js +16 -9
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnScrollOutside.js +3 -1
- package/lib/hooks/useOnScrollOutside.js.map +1 -1
- package/lib/hooks/usePrevious.js.map +1 -1
- package/lib/hooks/useScrollbarWidth.js.map +1 -1
- package/lib/hooks/useTimeout.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/ssr/SSRContext.js +2 -2
- package/lib/ssr/SSRContext.js.map +1 -1
- package/lib/ssr/canUseDOM.js +1 -2
- package/lib/ssr/canUseDOM.js.map +1 -1
- package/lib/ssr/index.js.map +1 -1
- package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib/trigger/getTriggerChild.js.map +1 -1
- package/lib/trigger/index.js.map +1 -1
- package/lib/trigger/isFluentTrigger.js +1 -0
- package/lib/trigger/isFluentTrigger.js.map +1 -1
- package/lib/trigger/types.js +1 -1
- package/lib/trigger/types.js.map +1 -1
- package/lib/utils/clamp.js +1 -2
- package/lib/utils/clamp.js.map +1 -1
- package/lib/utils/getNativeElementProps.js +2 -2
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.js +1 -2
- package/lib/utils/getRTLSafeKey.js.map +1 -1
- package/lib/utils/getReactCallbackName.js +1 -0
- package/lib/utils/getReactCallbackName.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isHTMLElement.js +12 -7
- package/lib/utils/isHTMLElement.js.map +1 -1
- package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib/utils/mergeCallbacks.js +1 -2
- package/lib/utils/mergeCallbacks.js.map +1 -1
- package/lib/utils/omit.js +1 -2
- package/lib/utils/omit.js.map +1 -1
- package/lib/utils/properties.js +24 -51
- package/lib/utils/properties.js.map +1 -1
- package/lib-commonjs/compose/getSlots.js +48 -55
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/index.js +8 -7
- package/lib-commonjs/compose/index.js.map +1 -1
- package/lib-commonjs/compose/isResolvedShorthand.js +9 -37
- package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.js +25 -32
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/compose/types.js +5 -2
- package/lib-commonjs/compose/types.js.map +1 -1
- package/lib-commonjs/events/index.js +5 -4
- package/lib-commonjs/events/index.js.map +1 -1
- package/lib-commonjs/events/mouseTouchHelpers.js +40 -37
- package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
- package/lib-commonjs/hooks/index.js +16 -15
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useControllableState.js +63 -64
- package/lib-commonjs/hooks/useControllableState.js.map +1 -1
- package/lib-commonjs/hooks/useEventCallback.js +25 -31
- package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
- package/lib-commonjs/hooks/useFirstMount.js +15 -23
- package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
- package/lib-commonjs/hooks/useForceUpdate.js +9 -11
- package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
- package/lib-commonjs/hooks/useId.js +47 -46
- package/lib-commonjs/hooks/useId.js.map +1 -1
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +10 -16
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib-commonjs/hooks/useMergedRefs.js +25 -27
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js +118 -114
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnScrollOutside.js +35 -36
- package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
- package/lib-commonjs/hooks/usePrevious.js +17 -15
- package/lib-commonjs/hooks/usePrevious.js.map +1 -1
- package/lib-commonjs/hooks/useScrollbarWidth.js +32 -32
- package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
- package/lib-commonjs/hooks/useTimeout.js +30 -30
- package/lib-commonjs/hooks/useTimeout.js.map +1 -1
- package/lib-commonjs/index.js +52 -214
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/ssr/SSRContext.js +57 -59
- package/lib-commonjs/ssr/SSRContext.js.map +1 -1
- package/lib-commonjs/ssr/canUseDOM.js +12 -12
- package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
- package/lib-commonjs/ssr/index.js +6 -5
- package/lib-commonjs/ssr/index.js.map +1 -1
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js +29 -31
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib-commonjs/trigger/getTriggerChild.js +16 -36
- package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
- package/lib-commonjs/trigger/index.js +8 -7
- package/lib-commonjs/trigger/index.js.map +1 -1
- package/lib-commonjs/trigger/isFluentTrigger.js +10 -11
- package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
- package/lib-commonjs/trigger/types.js +5 -2
- package/lib-commonjs/trigger/types.js.map +1 -1
- package/lib-commonjs/utils/clamp.js +10 -9
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/getNativeElementProps.js +54 -61
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.js +22 -21
- package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
- package/lib-commonjs/utils/getReactCallbackName.js +24 -24
- package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
- package/lib-commonjs/utils/index.js +12 -11
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/isHTMLElement.js +22 -15
- package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/isInteractiveHTMLElement.js +20 -24
- package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/mergeCallbacks.js +14 -13
- package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
- package/lib-commonjs/utils/omit.js +18 -17
- package/lib-commonjs/utils/omit.js.map +1 -1
- package/lib-commonjs/utils/properties.js +327 -223
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/package.json +5 -4
- package/lib-amd/compose/getSlots.js +0 -58
- package/lib-amd/compose/getSlots.js.map +0 -1
- package/lib-amd/compose/index.js +0 -9
- package/lib-amd/compose/index.js.map +0 -1
- package/lib-amd/compose/isResolvedShorthand.js +0 -40
- package/lib-amd/compose/isResolvedShorthand.js.map +0 -1
- package/lib-amd/compose/resolveShorthand.js +0 -27
- package/lib-amd/compose/resolveShorthand.js.map +0 -1
- package/lib-amd/compose/types.js +0 -5
- package/lib-amd/compose/types.js.map +0 -1
- package/lib-amd/events/index.js +0 -6
- package/lib-amd/events/index.js.map +0 -1
- package/lib-amd/events/mouseTouchHelpers.js +0 -39
- package/lib-amd/events/mouseTouchHelpers.js.map +0 -1
- package/lib-amd/hooks/index.js +0 -17
- package/lib-amd/hooks/index.js.map +0 -1
- package/lib-amd/hooks/useControllableState.js +0 -81
- package/lib-amd/hooks/useControllableState.js.map +0 -1
- package/lib-amd/hooks/useEventCallback.js +0 -36
- package/lib-amd/hooks/useEventCallback.js.map +0 -1
- package/lib-amd/hooks/useFirstMount.js +0 -26
- package/lib-amd/hooks/useFirstMount.js.map +0 -1
- package/lib-amd/hooks/useForceUpdate.js +0 -14
- package/lib-amd/hooks/useForceUpdate.js.map +0 -1
- package/lib-amd/hooks/useId.js +0 -54
- package/lib-amd/hooks/useId.js.map +0 -1
- package/lib-amd/hooks/useIsomorphicLayoutEffect.js +0 -17
- package/lib-amd/hooks/useIsomorphicLayoutEffect.js.map +0 -1
- package/lib-amd/hooks/useMergedRefs.js +0 -34
- package/lib-amd/hooks/useMergedRefs.js.map +0 -1
- package/lib-amd/hooks/useOnClickOutside.js +0 -114
- package/lib-amd/hooks/useOnClickOutside.js.map +0 -1
- package/lib-amd/hooks/useOnScrollOutside.js +0 -31
- package/lib-amd/hooks/useOnScrollOutside.js.map +0 -1
- package/lib-amd/hooks/usePrevious.js +0 -17
- package/lib-amd/hooks/usePrevious.js.map +0 -1
- package/lib-amd/hooks/useScrollbarWidth.js +0 -32
- package/lib-amd/hooks/useScrollbarWidth.js.map +0 -1
- package/lib-amd/hooks/useTimeout.js +0 -33
- package/lib-amd/hooks/useTimeout.js.map +0 -1
- package/lib-amd/index.js +0 -40
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/ssr/SSRContext.js +0 -69
- package/lib-amd/ssr/SSRContext.js.map +0 -1
- package/lib-amd/ssr/canUseDOM.js +0 -16
- package/lib-amd/ssr/canUseDOM.js.map +0 -1
- package/lib-amd/ssr/index.js +0 -7
- package/lib-amd/ssr/index.js.map +0 -1
- package/lib-amd/trigger/applyTriggerPropsToChildren.js +0 -40
- package/lib-amd/trigger/applyTriggerPropsToChildren.js.map +0 -1
- package/lib-amd/trigger/getTriggerChild.js +0 -40
- package/lib-amd/trigger/getTriggerChild.js.map +0 -1
- package/lib-amd/trigger/index.js +0 -9
- package/lib-amd/trigger/index.js.map +0 -1
- package/lib-amd/trigger/isFluentTrigger.js +0 -15
- package/lib-amd/trigger/isFluentTrigger.js.map +0 -1
- package/lib-amd/trigger/types.js +0 -5
- package/lib-amd/trigger/types.js.map +0 -1
- package/lib-amd/utils/clamp.js +0 -16
- package/lib-amd/utils/clamp.js.map +0 -1
- package/lib-amd/utils/getNativeElementProps.js +0 -64
- package/lib-amd/utils/getNativeElementProps.js.map +0 -1
- package/lib-amd/utils/getRTLSafeKey.js +0 -24
- package/lib-amd/utils/getRTLSafeKey.js.map +0 -1
- package/lib-amd/utils/index.js +0 -13
- package/lib-amd/utils/index.js.map +0 -1
- package/lib-amd/utils/isHTMLElement.js +0 -22
- package/lib-amd/utils/isHTMLElement.js.map +0 -1
- package/lib-amd/utils/isInteractiveHTMLElement.js +0 -25
- package/lib-amd/utils/isInteractiveHTMLElement.js.map +0 -1
- package/lib-amd/utils/mergeCallbacks.js +0 -40
- package/lib-amd/utils/mergeCallbacks.js.map +0 -1
- package/lib-amd/utils/omit.js +0 -31
- package/lib-amd/utils/omit.js.map +0 -1
- package/lib-amd/utils/properties.js +0 -450
- package/lib-amd/utils/properties.js.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useForceUpdate.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useForceUpdate.ts"],"names":[],"mappings":";;;;IAEA;;;OAGG;IACH,SAAgB,cAAc;QAC5B,OAAO,kBAAU,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAFD,wCAEC","sourcesContent":["import { useReducer } from 'react';\n\n/**\n * @internal\n * Forces a re-render, similar to `forceUpdate` in class components.\n */\nexport function useForceUpdate() {\n return useReducer(x => x + 1, 0)[1];\n}\n"]}
|
package/lib-amd/hooks/useId.js
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
define(["require", "exports", "react", "../ssr/index"], function (require, exports, React, index_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.useId = exports.resetIdsForTests = exports.IdPrefixProvider = void 0;
|
5
|
-
var IdPrefixContext = React.createContext(undefined);
|
6
|
-
/**
|
7
|
-
* Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions
|
8
|
-
* between different bundles.
|
9
|
-
*/
|
10
|
-
exports.IdPrefixProvider = IdPrefixContext.Provider;
|
11
|
-
function useIdPrefix() {
|
12
|
-
return React.useContext(IdPrefixContext) || '';
|
13
|
-
}
|
14
|
-
/**
|
15
|
-
* Resets generated IDs, should be used only in tests.
|
16
|
-
*/
|
17
|
-
function resetIdsForTests() {
|
18
|
-
index_1.defaultSSRContextValue.current = 0;
|
19
|
-
}
|
20
|
-
exports.resetIdsForTests = resetIdsForTests;
|
21
|
-
/**
|
22
|
-
* Hook to generate a unique ID.
|
23
|
-
*
|
24
|
-
* @param prefix - Optional prefix for the ID. Defaults to 'fui-'.
|
25
|
-
* @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,
|
26
|
-
* without conditioning the hook call
|
27
|
-
* @returns The ID
|
28
|
-
*/
|
29
|
-
function useId(prefix, providedId) {
|
30
|
-
if (prefix === void 0) { prefix = 'fui-'; }
|
31
|
-
var contextValue = index_1.useSSRContext();
|
32
|
-
var idPrefix = useIdPrefix();
|
33
|
-
// Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to
|
34
|
-
// prevent bundlers from complaining with older versions of React.
|
35
|
-
var _useId = React['use' + 'Id'];
|
36
|
-
if (_useId) {
|
37
|
-
var generatedId_1 = _useId();
|
38
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
39
|
-
var escapedId = React.useMemo(function () { return generatedId_1.replace(/:/g, ''); }, [generatedId_1]);
|
40
|
-
return providedId || "" + idPrefix + prefix + escapedId;
|
41
|
-
}
|
42
|
-
// Hooks appear to be running conditionally, but they will always run in the same order since it's based on
|
43
|
-
// the version of React being used. This is safe to ignore.
|
44
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
45
|
-
return React.useMemo(function () {
|
46
|
-
if (providedId) {
|
47
|
-
return providedId;
|
48
|
-
}
|
49
|
-
return "" + idPrefix + prefix + ++contextValue.current;
|
50
|
-
}, [idPrefix, prefix, providedId, contextValue]);
|
51
|
-
}
|
52
|
-
exports.useId = useId;
|
53
|
-
});
|
54
|
-
//# sourceMappingURL=useId.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useId.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useId.ts"],"names":[],"mappings":";;;;IAGA,IAAM,eAAe,GAAG,KAAK,CAAC,aAAa,CAAqB,SAAS,CAAC,CAAC;IAE3E;;;OAGG;IACU,QAAA,gBAAgB,GAAG,eAAe,CAAC,QAAQ,CAAC;IAEzD,SAAS,WAAW;QAClB,OAAO,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,SAAgB,gBAAgB;QAC9B,8BAAsB,CAAC,OAAO,GAAG,CAAC,CAAC;IACrC,CAAC;IAFD,4CAEC;IAED;;;;;;;OAOG;IACH,SAAgB,KAAK,CAAC,MAAuB,EAAE,UAAmB;QAA5C,uBAAA,EAAA,eAAuB;QAC3C,IAAM,YAAY,GAAG,qBAAa,EAAE,CAAC;QACrC,IAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAE/B,mHAAmH;QACnH,kEAAkE;QAClE,IAAM,MAAM,GAAI,KAAe,CAAC,KAAK,GAAG,IAAI,CAA+B,CAAC;QAE5E,IAAI,MAAM,EAAE;YACV,IAAM,aAAW,GAAG,MAAM,EAAE,CAAC;YAE7B,sDAAsD;YACtD,IAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,cAAM,OAAA,aAAW,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAA7B,CAA6B,EAAE,CAAC,aAAW,CAAC,CAAC,CAAC;YAEpF,OAAO,UAAU,IAAI,KAAG,QAAQ,GAAG,MAAM,GAAG,SAAW,CAAC;SACzD;QAED,2GAA2G;QAC3G,2DAA2D;QAC3D,sDAAsD;QACtD,OAAO,KAAK,CAAC,OAAO,CAAC;YACnB,IAAI,UAAU,EAAE;gBACd,OAAO,UAAU,CAAC;aACnB;YAED,OAAO,KAAG,QAAQ,GAAG,MAAM,GAAG,EAAE,YAAY,CAAC,OAAS,CAAC;QACzD,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;IACnD,CAAC;IA3BD,sBA2BC","sourcesContent":["import * as React from 'react';\nimport { defaultSSRContextValue, useSSRContext } from '../ssr/index';\n\nconst IdPrefixContext = React.createContext<string | undefined>(undefined);\n\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 */\nexport const IdPrefixProvider = IdPrefixContext.Provider;\n\nfunction useIdPrefix(): string {\n return React.useContext(IdPrefixContext) || '';\n}\n\n/**\n * Resets generated IDs, should be used only in tests.\n */\nexport function resetIdsForTests(): void {\n defaultSSRContextValue.current = 0;\n}\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 */\nexport function useId(prefix: string = 'fui-', providedId?: string): string {\n const contextValue = useSSRContext();\n const idPrefix = useIdPrefix();\n\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 as never)['use' + 'Id'] as (() => string) | undefined;\n\n if (_useId) {\n const generatedId = _useId();\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const escapedId = React.useMemo(() => generatedId.replace(/:/g, ''), [generatedId]);\n\n return providedId || `${idPrefix}${prefix}${escapedId}`;\n }\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\n return `${idPrefix}${prefix}${++contextValue.current}`;\n }, [idPrefix, prefix, providedId, contextValue]);\n}\n"]}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
define(["require", "exports", "react", "../ssr/index"], function (require, exports, React, index_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.useIsomorphicLayoutEffect = void 0;
|
5
|
-
/**
|
6
|
-
* React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally
|
7
|
-
* useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to
|
8
|
-
* ensure we don't get a render flash for certain operations, but we may also need affected components to render on
|
9
|
-
* the server.
|
10
|
-
*
|
11
|
-
* https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
|
12
|
-
* https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
|
13
|
-
*/
|
14
|
-
// eslint-disable-next-line no-restricted-properties
|
15
|
-
exports.useIsomorphicLayoutEffect = index_1.canUseDOM() ? React.useLayoutEffect : React.useEffect;
|
16
|
-
});
|
17
|
-
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useIsomorphicLayoutEffect.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":";;;;IAGA;;;;;;;;OAQG;IACH,oDAAoD;IACvC,QAAA,yBAAyB,GAA2B,iBAAS,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC","sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '../ssr/index';\n\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 */\n// eslint-disable-next-line no-restricted-properties\nexport const useIsomorphicLayoutEffect: typeof React.useEffect = canUseDOM() ? React.useLayoutEffect : React.useEffect;\n"]}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
define(["require", "exports", "tslib", "react"], function (require, exports, tslib_1, React) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.useMergedRefs = void 0;
|
5
|
-
/**
|
6
|
-
* React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that
|
7
|
-
* updates all provided refs
|
8
|
-
* @param refs - Refs to collectively update with one ref value.
|
9
|
-
* @returns A function with an attached "current" prop, so that it can be treated like a RefObject.
|
10
|
-
*/
|
11
|
-
function useMergedRefs() {
|
12
|
-
var refs = [];
|
13
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
14
|
-
refs[_i] = arguments[_i];
|
15
|
-
}
|
16
|
-
var mergedCallback = React.useCallback(function (value) {
|
17
|
-
// Update the "current" prop hanging on the function.
|
18
|
-
mergedCallback.current = value;
|
19
|
-
for (var _i = 0, refs_1 = refs; _i < refs_1.length; _i++) {
|
20
|
-
var ref = refs_1[_i];
|
21
|
-
if (typeof ref === 'function') {
|
22
|
-
ref(value);
|
23
|
-
}
|
24
|
-
else if (ref) {
|
25
|
-
// work around the immutability of the React.Ref type
|
26
|
-
ref.current = value;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
}, tslib_1.__spreadArray([], refs));
|
30
|
-
return mergedCallback;
|
31
|
-
}
|
32
|
-
exports.useMergedRefs = useMergedRefs;
|
33
|
-
});
|
34
|
-
//# sourceMappingURL=useMergedRefs.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useMergedRefs.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useMergedRefs.ts"],"names":[],"mappings":";;;;IAQA;;;;;OAKG;IACH,SAAgB,aAAa;QAAI,cAAqC;aAArC,UAAqC,EAArC,qBAAqC,EAArC,IAAqC;YAArC,yBAAqC;;QACpE,IAAM,cAAc,GAAyB,KAAK,CAAC,WAAW,CAC5D,UAAC,KAAQ;YACP,qDAAqD;YACpD,cAAuD,CAAC,OAAO,GAAG,KAAK,CAAC;YAEzE,KAAkB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE;gBAAnB,IAAM,GAAG,aAAA;gBACZ,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;oBAC7B,GAAG,CAAC,KAAK,CAAC,CAAC;iBACZ;qBAAM,IAAI,GAAG,EAAE;oBACd,qDAAqD;oBACpD,GAA4C,CAAC,OAAO,GAAG,KAAK,CAAC;iBAC/D;aACF;QACH,CAAC,4BAEG,IAAI,EAC0B,CAAC;QAErC,OAAO,cAAc,CAAC;IACxB,CAAC;IApBD,sCAoBC","sourcesContent":["import * as React from 'react';\n\n/**\n * A Ref function which can be treated like a ref object in that it has an attached\n * current property, which will be updated as the ref is evaluated.\n */\nexport type RefObjectFunction<T> = React.RefObject<T> & ((value: T) => void);\n\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 */\nexport function useMergedRefs<T>(...refs: (React.Ref<T> | undefined)[]): RefObjectFunction<T> {\n const mergedCallback: RefObjectFunction<T> = React.useCallback(\n (value: T) => {\n // Update the \"current\" prop hanging on the function.\n (mergedCallback as unknown as React.MutableRefObject<T>).current = value;\n\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 as unknown as React.MutableRefObject<T>).current = value;\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive\n [...refs],\n ) as unknown as RefObjectFunction<T>;\n\n return mergedCallback;\n}\n"]}
|
@@ -1,114 +0,0 @@
|
|
1
|
-
define(["require", "exports", "react", "./useEventCallback"], function (require, exports, React, useEventCallback_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.useOnClickOutside = void 0;
|
5
|
-
/**
|
6
|
-
* @internal
|
7
|
-
* Utility to perform checks where a click/touch event was made outside a component
|
8
|
-
*/
|
9
|
-
var useOnClickOutside = function (options) {
|
10
|
-
var refs = options.refs, callback = options.callback, element = options.element, disabled = options.disabled, containsProp = options.contains;
|
11
|
-
var timeoutId = React.useRef(undefined);
|
12
|
-
useIFrameFocus(options);
|
13
|
-
var listener = useEventCallback_1.useEventCallback(function (ev) {
|
14
|
-
var contains = containsProp || (function (parent, child) { return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child)); });
|
15
|
-
var isOutside = refs.every(function (ref) { return !contains(ref.current || null, ev.target); });
|
16
|
-
if (isOutside && !disabled) {
|
17
|
-
callback(ev);
|
18
|
-
}
|
19
|
-
});
|
20
|
-
React.useEffect(function () {
|
21
|
-
// Store the current event to avoid triggering handlers immediately
|
22
|
-
// Note this depends on a deprecated but extremely well supported quirk of the web platform
|
23
|
-
// https://github.com/facebook/react/issues/20074
|
24
|
-
var currentEvent = getWindowEvent(window);
|
25
|
-
var conditionalHandler = function (event) {
|
26
|
-
// Skip if this event is the same as the one running when we added the handlers
|
27
|
-
if (event === currentEvent) {
|
28
|
-
currentEvent = undefined;
|
29
|
-
return;
|
30
|
-
}
|
31
|
-
listener(event);
|
32
|
-
};
|
33
|
-
if (!disabled) {
|
34
|
-
// use capture phase because React can update DOM before the event bubbles to the document
|
35
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('click', conditionalHandler, true);
|
36
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('touchstart', conditionalHandler, true);
|
37
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('contextmenu', conditionalHandler, true);
|
38
|
-
}
|
39
|
-
// Garbage collect this event after it's no longer useful to avoid memory leaks
|
40
|
-
timeoutId.current = window.setTimeout(function () {
|
41
|
-
currentEvent = undefined;
|
42
|
-
}, 1);
|
43
|
-
return function () {
|
44
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('click', conditionalHandler, true);
|
45
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);
|
46
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('contextmenu', conditionalHandler, true);
|
47
|
-
clearTimeout(timeoutId.current);
|
48
|
-
currentEvent = undefined;
|
49
|
-
};
|
50
|
-
}, [listener, element, disabled]);
|
51
|
-
};
|
52
|
-
exports.useOnClickOutside = useOnClickOutside;
|
53
|
-
var getWindowEvent = function (target) {
|
54
|
-
var _a, _b, _c;
|
55
|
-
if (target) {
|
56
|
-
if (typeof target.window === 'object' && target.window === target) {
|
57
|
-
// eslint-disable-next-line deprecation/deprecation
|
58
|
-
return target.event;
|
59
|
-
}
|
60
|
-
// eslint-disable-next-line deprecation/deprecation
|
61
|
-
return (_c = (_b = (_a = target.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.event) !== null && _c !== void 0 ? _c : undefined;
|
62
|
-
}
|
63
|
-
return undefined;
|
64
|
-
};
|
65
|
-
var FUI_FRAME_EVENT = 'fuiframefocus';
|
66
|
-
/**
|
67
|
-
* Since click events do not propagate past iframes, we use focus to detect if a
|
68
|
-
* click has happened inside an iframe, since the only ways of focusing inside an
|
69
|
-
* iframe are:
|
70
|
-
* - clicking inside
|
71
|
-
* - tabbing inside
|
72
|
-
*
|
73
|
-
* Polls the value of `document.activeElement`. If it is an iframe, then dispatch
|
74
|
-
* a custom DOM event. When the custom event is received call the provided callback
|
75
|
-
*/
|
76
|
-
var useIFrameFocus = function (options) {
|
77
|
-
var disabled = options.disabled, targetDocument = options.element, callback = options.callback, _a = options.contains, containsProp = _a === void 0 ? function (parent, child) { return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child)); } : _a, _b = options.pollDuration, pollDuration = _b === void 0 ? 1000 : _b, refs = options.refs;
|
78
|
-
var timeoutRef = React.useRef();
|
79
|
-
var listener = useEventCallback_1.useEventCallback(function (e) {
|
80
|
-
var contains = containsProp || (function (parent, child) { return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child)); });
|
81
|
-
var isOutside = refs.every(function (ref) { return !contains(ref.current || null, e.target); });
|
82
|
-
if (isOutside && !disabled) {
|
83
|
-
callback(e);
|
84
|
-
}
|
85
|
-
});
|
86
|
-
// Adds listener to the custom iframe focus event
|
87
|
-
React.useEffect(function () {
|
88
|
-
if (!disabled) {
|
89
|
-
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener(FUI_FRAME_EVENT, listener, true);
|
90
|
-
return function () {
|
91
|
-
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener(FUI_FRAME_EVENT, listener, true);
|
92
|
-
};
|
93
|
-
}
|
94
|
-
}, [targetDocument, disabled, listener]);
|
95
|
-
// Starts polling for the active element
|
96
|
-
React.useEffect(function () {
|
97
|
-
var _a;
|
98
|
-
if (!disabled) {
|
99
|
-
timeoutRef.current = (_a = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) === null || _a === void 0 ? void 0 : _a.setInterval(function () {
|
100
|
-
var activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;
|
101
|
-
if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'IFRAME' || (activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'WEBVIEW') {
|
102
|
-
var event_1 = new CustomEvent(FUI_FRAME_EVENT, { bubbles: true });
|
103
|
-
activeElement.dispatchEvent(event_1);
|
104
|
-
}
|
105
|
-
}, pollDuration);
|
106
|
-
}
|
107
|
-
return function () {
|
108
|
-
var _a;
|
109
|
-
(_a = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) === null || _a === void 0 ? void 0 : _a.clearTimeout(timeoutRef.current);
|
110
|
-
};
|
111
|
-
}, [targetDocument, disabled, pollDuration]);
|
112
|
-
};
|
113
|
-
});
|
114
|
-
//# sourceMappingURL=useOnClickOutside.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useOnClickOutside.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useOnClickOutside.ts"],"names":[],"mappings":"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","sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\n\n/**\n * @internal\n */\nexport type UseOnClickOrScrollOutsideOptions = {\n /**\n * The element to listen for the click event\n */\n element: Document | undefined;\n /**\n * Refs to elements that check if the click is outside\n */\n refs: React.MutableRefObject<HTMLElement | undefined | null>[];\n\n /**\n * By default uses element.contains, but custom contain function can be provided\n * @param parentRef - provided parent ref\n * @param child - event target element\n */\n contains?(parent: HTMLElement | null, child: HTMLElement): boolean;\n\n /**\n * Disables event listeners\n */\n disabled?: boolean;\n\n /**\n * Called if the click is outside the element refs\n */\n callback: (ev: MouseEvent | TouchEvent) => void;\n};\n\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */\nexport const useOnClickOutside = (options: UseOnClickOrScrollOutsideOptions) => {\n const { refs, callback, element, disabled, contains: containsProp } = options;\n const timeoutId = React.useRef<number | undefined>(undefined);\n useIFrameFocus(options);\n\n const listener = useEventCallback((ev: MouseEvent | TouchEvent) => {\n const contains: UseOnClickOrScrollOutsideOptions['contains'] =\n containsProp || ((parent, child) => !!parent?.contains(child));\n\n const isOutside = refs.every(ref => !contains(ref.current || null, ev.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n\n React.useEffect(() => {\n // Store the current event to avoid triggering handlers immediately\n // Note this depends on a deprecated but extremely well supported quirk of the web platform\n // https://github.com/facebook/react/issues/20074\n let currentEvent = getWindowEvent(window);\n\n const conditionalHandler = (event: MouseEvent | TouchEvent) => {\n // Skip if this event is the same as the one running when we added the handlers\n if (event === currentEvent) {\n currentEvent = undefined;\n return;\n }\n\n listener(event);\n };\n\n if (!disabled) {\n // use capture phase because React can update DOM before the event bubbles to the document\n element?.addEventListener('click', conditionalHandler, true);\n element?.addEventListener('touchstart', conditionalHandler, true);\n element?.addEventListener('contextmenu', conditionalHandler, true);\n }\n\n // Garbage collect this event after it's no longer useful to avoid memory leaks\n timeoutId.current = window.setTimeout(() => {\n currentEvent = undefined;\n }, 1);\n\n return () => {\n element?.removeEventListener('click', conditionalHandler, true);\n element?.removeEventListener('touchstart', conditionalHandler, true);\n element?.removeEventListener('contextmenu', conditionalHandler, true);\n\n clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [listener, element, disabled]);\n};\n\nconst getWindowEvent = (target: Node | Window): Event | undefined => {\n if (target) {\n if (typeof (target as Window).window === 'object' && (target as Window).window === target) {\n // eslint-disable-next-line deprecation/deprecation\n return target.event;\n }\n\n // eslint-disable-next-line deprecation/deprecation\n return (target as Node).ownerDocument?.defaultView?.event ?? undefined;\n }\n\n return undefined;\n};\n\nconst FUI_FRAME_EVENT = 'fuiframefocus';\n\ninterface UseIFrameFocusOptions extends UseOnClickOrScrollOutsideOptions {\n /**\n * Millisecond duration to poll\n */\n pollDuration?: number;\n}\n\n/**\n * Since click events do not propagate past iframes, we use focus to detect if a\n * click has happened inside an iframe, since the only ways of focusing inside an\n * iframe are:\n * - clicking inside\n * - tabbing inside\n *\n * Polls the value of `document.activeElement`. If it is an iframe, then dispatch\n * a custom DOM event. When the custom event is received call the provided callback\n */\nconst useIFrameFocus = (options: UseIFrameFocusOptions) => {\n const {\n disabled,\n element: targetDocument,\n callback,\n contains: containsProp = (parent, child) => !!parent?.contains(child),\n pollDuration = 1000,\n refs,\n } = options;\n const timeoutRef = React.useRef<number>();\n\n const listener = useEventCallback((e: Event) => {\n const contains = containsProp || ((parent, child) => !!parent?.contains(child));\n\n const isOutside = refs.every(ref => !contains(ref.current || null, e.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(e as MouseEvent);\n }\n });\n\n // Adds listener to the custom iframe focus event\n React.useEffect(() => {\n if (!disabled) {\n targetDocument?.addEventListener(FUI_FRAME_EVENT, listener, true);\n return () => {\n targetDocument?.removeEventListener(FUI_FRAME_EVENT, listener, true);\n };\n }\n }, [targetDocument, disabled, listener]);\n\n // Starts polling for the active element\n React.useEffect(() => {\n if (!disabled) {\n timeoutRef.current = targetDocument?.defaultView?.setInterval(() => {\n const activeElement = targetDocument?.activeElement;\n if (activeElement?.tagName === 'IFRAME' || activeElement?.tagName === 'WEBVIEW') {\n const event = new CustomEvent(FUI_FRAME_EVENT, { bubbles: true });\n activeElement.dispatchEvent(event);\n }\n }, pollDuration);\n }\n return () => {\n targetDocument?.defaultView?.clearTimeout(timeoutRef.current);\n };\n }, [targetDocument, disabled, pollDuration]);\n};\n"]}
|
@@ -1,31 +0,0 @@
|
|
1
|
-
define(["require", "exports", "react", "./useEventCallback"], function (require, exports, React, useEventCallback_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.useOnScrollOutside = void 0;
|
5
|
-
/**
|
6
|
-
* @internal
|
7
|
-
* Utility to perform checks where a click/touch event was made outside a component
|
8
|
-
*/
|
9
|
-
var useOnScrollOutside = function (options) {
|
10
|
-
var refs = options.refs, callback = options.callback, element = options.element, disabled = options.disabled, containsProp = options.contains;
|
11
|
-
var listener = useEventCallback_1.useEventCallback(function (ev) {
|
12
|
-
var contains = containsProp || (function (parent, child) { return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child)); });
|
13
|
-
var isOutside = refs.every(function (ref) { return !contains(ref.current || null, ev.target); });
|
14
|
-
if (isOutside && !disabled) {
|
15
|
-
callback(ev);
|
16
|
-
}
|
17
|
-
});
|
18
|
-
React.useEffect(function () {
|
19
|
-
if (!disabled) {
|
20
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('wheel', listener);
|
21
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('touchmove', listener);
|
22
|
-
}
|
23
|
-
return function () {
|
24
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('wheel', listener);
|
25
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('touchmove', listener);
|
26
|
-
};
|
27
|
-
}, [listener, element, disabled]);
|
28
|
-
};
|
29
|
-
exports.useOnScrollOutside = useOnScrollOutside;
|
30
|
-
});
|
31
|
-
//# sourceMappingURL=useOnScrollOutside.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useOnScrollOutside.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useOnScrollOutside.ts"],"names":[],"mappings":";;;;IAIA;;;OAGG;IACI,IAAM,kBAAkB,GAAG,UAAC,OAAyC;QAClE,IAAA,IAAI,GAA0D,OAAO,KAAjE,EAAE,QAAQ,GAAgD,OAAO,SAAvD,EAAE,OAAO,GAAuC,OAAO,QAA9C,EAAE,QAAQ,GAA6B,OAAO,SAApC,EAAY,YAAY,GAAK,OAAO,SAAZ,CAAa;QAE9E,IAAM,QAAQ,GAAG,mCAAgB,CAAC,UAAC,EAA2B;YAC5D,IAAM,QAAQ,GACZ,YAAY,IAAI,CAAC,UAAC,MAAM,EAAE,KAAK,IAAK,OAAA,CAAC,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,CAAC,KAAK,CAAC,CAAA,EAAzB,CAAyB,CAAC,CAAC;YAEjE,IAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,UAAA,GAAG,IAAI,OAAA,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,EAAE,EAAE,CAAC,MAAqB,CAAC,EAAxD,CAAwD,CAAC,CAAC;YAC9F,IAAI,SAAS,IAAI,CAAC,QAAQ,EAAE;gBAC1B,QAAQ,CAAC,EAAE,CAAC,CAAC;aACd;QACH,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,SAAS,CAAC;YACd,IAAI,CAAC,QAAQ,EAAE;gBACb,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;gBAC7C,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;aAClD;YAED,OAAO;gBACL,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;gBAChD,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;YACtD,CAAC,CAAC;QACJ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;IACpC,CAAC,CAAC;IAxBW,QAAA,kBAAkB,sBAwB7B","sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\nimport type { UseOnClickOrScrollOutsideOptions } from './useOnClickOutside';\n\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */\nexport const useOnScrollOutside = (options: UseOnClickOrScrollOutsideOptions) => {\n const { refs, callback, element, disabled, contains: containsProp } = options;\n\n const listener = useEventCallback((ev: MouseEvent | TouchEvent) => {\n const contains: UseOnClickOrScrollOutsideOptions['contains'] =\n containsProp || ((parent, child) => !!parent?.contains(child));\n\n const isOutside = refs.every(ref => !contains(ref.current || null, ev.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n\n React.useEffect(() => {\n if (!disabled) {\n element?.addEventListener('wheel', listener);\n element?.addEventListener('touchmove', listener);\n }\n\n return () => {\n element?.removeEventListener('wheel', listener);\n element?.removeEventListener('touchmove', listener);\n };\n }, [listener, element, disabled]);\n};\n"]}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
define(["require", "exports", "react"], function (require, exports, React) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.usePrevious = void 0;
|
5
|
-
/**
|
6
|
-
* @internal
|
7
|
-
*/
|
8
|
-
var usePrevious = function (value) {
|
9
|
-
var ref = React.useRef(null);
|
10
|
-
React.useEffect(function () {
|
11
|
-
ref.current = value;
|
12
|
-
}, [value]);
|
13
|
-
return ref.current;
|
14
|
-
};
|
15
|
-
exports.usePrevious = usePrevious;
|
16
|
-
});
|
17
|
-
//# sourceMappingURL=usePrevious.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"usePrevious.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/usePrevious.ts"],"names":[],"mappings":";;;;IAEA;;OAEG;IACI,IAAM,WAAW,GAAG,UAAsB,KAAgB;QAC/D,IAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAmB,IAAI,CAAC,CAAC;QACjD,KAAK,CAAC,SAAS,CAAC;YACd,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;QACtB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QACZ,OAAO,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC,CAAC;IANW,QAAA,WAAW,eAMtB","sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n */\nexport const usePrevious = <ValueType = unknown>(value: ValueType) => {\n const ref = React.useRef<ValueType | null>(null);\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref.current;\n};\n"]}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
define(["require", "exports", "react"], function (require, exports, React) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.useScrollbarWidth = void 0;
|
5
|
-
var cache = new WeakMap();
|
6
|
-
/**
|
7
|
-
* @returns The width in pixels of the scrollbar in the user agent
|
8
|
-
*/
|
9
|
-
function useScrollbarWidth(options) {
|
10
|
-
var targetDocument = options.targetDocument, force = options.force;
|
11
|
-
return React.useMemo(function () {
|
12
|
-
if (!targetDocument) {
|
13
|
-
return 0;
|
14
|
-
}
|
15
|
-
if (!force && cache.has(targetDocument)) {
|
16
|
-
return cache.get(targetDocument);
|
17
|
-
}
|
18
|
-
var outer = targetDocument.createElement('div');
|
19
|
-
outer.style.visibility = 'hidden';
|
20
|
-
outer.style.overflow = 'scroll';
|
21
|
-
var inner = targetDocument.createElement('div');
|
22
|
-
outer.appendChild(inner);
|
23
|
-
targetDocument.body.appendChild(outer);
|
24
|
-
var scrollbarWidth = outer.offsetWidth - inner.offsetWidth;
|
25
|
-
outer.remove();
|
26
|
-
cache.set(targetDocument, scrollbarWidth);
|
27
|
-
return scrollbarWidth;
|
28
|
-
}, [targetDocument, force]);
|
29
|
-
}
|
30
|
-
exports.useScrollbarWidth = useScrollbarWidth;
|
31
|
-
});
|
32
|
-
//# sourceMappingURL=useScrollbarWidth.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useScrollbarWidth.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useScrollbarWidth.ts"],"names":[],"mappings":";;;;IAEA,IAAM,KAAK,GAAG,IAAI,OAAO,EAAoB,CAAC;IAc9C;;OAEG;IACH,SAAgB,iBAAiB,CAAC,OAAiC;QACzD,IAAA,cAAc,GAAY,OAAO,eAAnB,EAAE,KAAK,GAAK,OAAO,MAAZ,CAAa;QAC1C,OAAO,KAAK,CAAC,OAAO,CAAC;YACnB,IAAI,CAAC,cAAc,EAAE;gBACnB,OAAO,CAAC,CAAC;aACV;YAED,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE;gBACvC,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;aAClC;YAED,IAAM,KAAK,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAClD,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,QAAQ,CAAC;YAClC,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAEhC,IAAM,KAAK,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAClD,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAEzB,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACvC,IAAM,cAAc,GAAG,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;YAC7D,KAAK,CAAC,MAAM,EAAE,CAAC;YACf,KAAK,CAAC,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;YAC1C,OAAO,cAAc,CAAC;QACxB,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC;IAC9B,CAAC;IAxBD,8CAwBC","sourcesContent":["import * as React from 'react';\n\nconst cache = new WeakMap<Document, number>();\n\ninterface UseScrollbarWidthOptions {\n /**\n * Reference document to measure the scrollbar width\n */\n targetDocument: Document | null | undefined;\n\n /**\n * Does not use the cache and recalculates the scrollbar width\n */\n force?: boolean;\n}\n\n/**\n * @returns The width in pixels of the scrollbar in the user agent\n */\nexport function useScrollbarWidth(options: UseScrollbarWidthOptions) {\n const { targetDocument, force } = options;\n return React.useMemo(() => {\n if (!targetDocument) {\n return 0;\n }\n\n if (!force && cache.has(targetDocument)) {\n return cache.get(targetDocument);\n }\n\n const outer = targetDocument.createElement('div');\n outer.style.visibility = 'hidden';\n outer.style.overflow = 'scroll';\n\n const inner = targetDocument.createElement('div');\n outer.appendChild(inner);\n\n targetDocument.body.appendChild(outer);\n const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;\n outer.remove();\n cache.set(targetDocument, scrollbarWidth);\n return scrollbarWidth;\n }, [targetDocument, force]);\n}\n"]}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
define(["require", "exports", "react"], function (require, exports, React) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.useTimeout = void 0;
|
5
|
-
/**
|
6
|
-
* @internal
|
7
|
-
* Helper to manage a browser timeout.
|
8
|
-
* Ensures that the timeout isn't set multiple times at once,
|
9
|
-
* and is cleaned up when the component is unloaded.
|
10
|
-
*
|
11
|
-
* @returns A pair of [setTimeout, clearTimeout] that are stable between renders.
|
12
|
-
*/
|
13
|
-
function useTimeout() {
|
14
|
-
var timeout = React.useState(function () { return ({
|
15
|
-
id: undefined,
|
16
|
-
set: function (fn, delay) {
|
17
|
-
timeout.clear();
|
18
|
-
timeout.id = setTimeout(fn, delay);
|
19
|
-
},
|
20
|
-
clear: function () {
|
21
|
-
if (timeout.id !== undefined) {
|
22
|
-
clearTimeout(timeout.id);
|
23
|
-
timeout.id = undefined;
|
24
|
-
}
|
25
|
-
},
|
26
|
-
}); })[0];
|
27
|
-
// Clean up the timeout when the component is unloaded
|
28
|
-
React.useEffect(function () { return timeout.clear; }, [timeout]);
|
29
|
-
return [timeout.set, timeout.clear];
|
30
|
-
}
|
31
|
-
exports.useTimeout = useTimeout;
|
32
|
-
});
|
33
|
-
//# sourceMappingURL=useTimeout.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useTimeout.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useTimeout.ts"],"names":[],"mappings":";;;;IAEA;;;;;;;OAOG;IACH,SAAgB,UAAU;QACjB,IAAA,OAAO,GAAI,KAAK,CAAC,QAAQ,CAAC,cAAM,OAAA,CAAC;YACtC,EAAE,EAAE,SAAsD;YAC1D,GAAG,EAAE,UAAC,EAAc,EAAE,KAAa;gBACjC,OAAO,CAAC,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YACrC,CAAC;YACD,KAAK,EAAE;gBACL,IAAI,OAAO,CAAC,EAAE,KAAK,SAAS,EAAE;oBAC5B,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;oBACzB,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;iBACxB;YACH,CAAC;SACF,CAAC,EAZqC,CAYrC,CAAC,GAZW,CAYV;QAEJ,sDAAsD;QACtD,KAAK,CAAC,SAAS,CAAC,cAAM,OAAA,OAAO,CAAC,KAAK,EAAb,CAAa,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QAEhD,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAU,CAAC;IAC/C,CAAC;IAnBD,gCAmBC","sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once,\n * and is cleaned up when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */\nexport function useTimeout() {\n const [timeout] = React.useState(() => ({\n id: undefined as ReturnType<typeof setTimeout> | undefined,\n set: (fn: () => void, delay: number) => {\n timeout.clear();\n timeout.id = setTimeout(fn, delay);\n },\n clear: () => {\n if (timeout.id !== undefined) {\n clearTimeout(timeout.id);\n timeout.id = undefined;\n }\n },\n }));\n\n // Clean up the timeout when the component is unloaded\n React.useEffect(() => timeout.clear, [timeout]);\n\n return [timeout.set, timeout.clear] as const;\n}\n"]}
|
package/lib-amd/index.js
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
define(["require", "exports", "./compose/index", "./hooks/index", "./ssr/index", "./utils/index", "./trigger/index", "./events/index"], function (require, exports, index_1, index_2, index_3, index_4, index_5, index_6) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.getEventClientCoords = exports.isMouseEvent = exports.isTouchEvent = exports.isFluentTrigger = exports.getTriggerChild = exports.applyTriggerPropsToChildren = exports.omit = exports.isInteractiveHTMLElement = exports.isHTMLElement = exports.mergeCallbacks = exports.getRTLSafeKey = exports.getPartitionedNativeProps = exports.getNativeElementProps = exports.clamp = exports.SSRProvider = exports.useIsSSR = exports.canUseDOM = exports.useTimeout = exports.useScrollbarWidth = exports.usePrevious = exports.useOnScrollOutside = exports.useOnClickOutside = exports.useMergedRefs = exports.useIsomorphicLayoutEffect = exports.useId = exports.useForceUpdate = exports.useFirstMount = exports.useEventCallback = exports.useControllableState = exports.resetIdsForTests = exports.IdPrefixProvider = exports.isResolvedShorthand = exports.resolveShorthand = exports.getSlots = void 0;
|
5
|
-
Object.defineProperty(exports, "getSlots", { enumerable: true, get: function () { return index_1.getSlots; } });
|
6
|
-
Object.defineProperty(exports, "resolveShorthand", { enumerable: true, get: function () { return index_1.resolveShorthand; } });
|
7
|
-
Object.defineProperty(exports, "isResolvedShorthand", { enumerable: true, get: function () { return index_1.isResolvedShorthand; } });
|
8
|
-
Object.defineProperty(exports, "IdPrefixProvider", { enumerable: true, get: function () { return index_2.IdPrefixProvider; } });
|
9
|
-
Object.defineProperty(exports, "resetIdsForTests", { enumerable: true, get: function () { return index_2.resetIdsForTests; } });
|
10
|
-
Object.defineProperty(exports, "useControllableState", { enumerable: true, get: function () { return index_2.useControllableState; } });
|
11
|
-
Object.defineProperty(exports, "useEventCallback", { enumerable: true, get: function () { return index_2.useEventCallback; } });
|
12
|
-
Object.defineProperty(exports, "useFirstMount", { enumerable: true, get: function () { return index_2.useFirstMount; } });
|
13
|
-
Object.defineProperty(exports, "useForceUpdate", { enumerable: true, get: function () { return index_2.useForceUpdate; } });
|
14
|
-
Object.defineProperty(exports, "useId", { enumerable: true, get: function () { return index_2.useId; } });
|
15
|
-
Object.defineProperty(exports, "useIsomorphicLayoutEffect", { enumerable: true, get: function () { return index_2.useIsomorphicLayoutEffect; } });
|
16
|
-
Object.defineProperty(exports, "useMergedRefs", { enumerable: true, get: function () { return index_2.useMergedRefs; } });
|
17
|
-
Object.defineProperty(exports, "useOnClickOutside", { enumerable: true, get: function () { return index_2.useOnClickOutside; } });
|
18
|
-
Object.defineProperty(exports, "useOnScrollOutside", { enumerable: true, get: function () { return index_2.useOnScrollOutside; } });
|
19
|
-
Object.defineProperty(exports, "usePrevious", { enumerable: true, get: function () { return index_2.usePrevious; } });
|
20
|
-
Object.defineProperty(exports, "useScrollbarWidth", { enumerable: true, get: function () { return index_2.useScrollbarWidth; } });
|
21
|
-
Object.defineProperty(exports, "useTimeout", { enumerable: true, get: function () { return index_2.useTimeout; } });
|
22
|
-
Object.defineProperty(exports, "canUseDOM", { enumerable: true, get: function () { return index_3.canUseDOM; } });
|
23
|
-
Object.defineProperty(exports, "useIsSSR", { enumerable: true, get: function () { return index_3.useIsSSR; } });
|
24
|
-
Object.defineProperty(exports, "SSRProvider", { enumerable: true, get: function () { return index_3.SSRProvider; } });
|
25
|
-
Object.defineProperty(exports, "clamp", { enumerable: true, get: function () { return index_4.clamp; } });
|
26
|
-
Object.defineProperty(exports, "getNativeElementProps", { enumerable: true, get: function () { return index_4.getNativeElementProps; } });
|
27
|
-
Object.defineProperty(exports, "getPartitionedNativeProps", { enumerable: true, get: function () { return index_4.getPartitionedNativeProps; } });
|
28
|
-
Object.defineProperty(exports, "getRTLSafeKey", { enumerable: true, get: function () { return index_4.getRTLSafeKey; } });
|
29
|
-
Object.defineProperty(exports, "mergeCallbacks", { enumerable: true, get: function () { return index_4.mergeCallbacks; } });
|
30
|
-
Object.defineProperty(exports, "isHTMLElement", { enumerable: true, get: function () { return index_4.isHTMLElement; } });
|
31
|
-
Object.defineProperty(exports, "isInteractiveHTMLElement", { enumerable: true, get: function () { return index_4.isInteractiveHTMLElement; } });
|
32
|
-
Object.defineProperty(exports, "omit", { enumerable: true, get: function () { return index_4.omit; } });
|
33
|
-
Object.defineProperty(exports, "applyTriggerPropsToChildren", { enumerable: true, get: function () { return index_5.applyTriggerPropsToChildren; } });
|
34
|
-
Object.defineProperty(exports, "getTriggerChild", { enumerable: true, get: function () { return index_5.getTriggerChild; } });
|
35
|
-
Object.defineProperty(exports, "isFluentTrigger", { enumerable: true, get: function () { return index_5.isFluentTrigger; } });
|
36
|
-
Object.defineProperty(exports, "isTouchEvent", { enumerable: true, get: function () { return index_6.isTouchEvent; } });
|
37
|
-
Object.defineProperty(exports, "isMouseEvent", { enumerable: true, get: function () { return index_6.isMouseEvent; } });
|
38
|
-
Object.defineProperty(exports, "getEventClientCoords", { enumerable: true, get: function () { return index_6.getEventClientCoords; } });
|
39
|
-
});
|
40
|
-
//# sourceMappingURL=index.js.map
|
package/lib-amd/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-utilities/src/index.ts"],"names":[],"mappings":";;;;IAAS,iGAAA,QAAQ,OAAA;IAAE,yGAAA,gBAAgB,OAAA;IAAE,4GAAA,mBAAmB,OAAA;IAiBtD,yGAAA,gBAAgB,OAAA;IAChB,yGAAA,gBAAgB,OAAA;IAChB,6GAAA,oBAAoB,OAAA;IACpB,yGAAA,gBAAgB,OAAA;IAChB,sGAAA,aAAa,OAAA;IACb,uGAAA,cAAc,OAAA;IACd,8FAAA,KAAK,OAAA;IACL,kHAAA,yBAAyB,OAAA;IACzB,sGAAA,aAAa,OAAA;IACb,0GAAA,iBAAiB,OAAA;IACjB,2GAAA,kBAAkB,OAAA;IAClB,oGAAA,WAAW,OAAA;IACX,0GAAA,iBAAiB,OAAA;IACjB,mGAAA,UAAU,OAAA;IAIH,kGAAA,SAAS,OAAA;IAAE,iGAAA,QAAQ,OAAA;IAAE,oGAAA,WAAW,OAAA;IAGvC,8FAAA,KAAK,OAAA;IACL,8GAAA,qBAAqB,OAAA;IACrB,kHAAA,yBAAyB,OAAA;IACzB,sGAAA,aAAa,OAAA;IACb,uGAAA,cAAc,OAAA;IACd,sGAAA,aAAa,OAAA;IACb,iHAAA,wBAAwB,OAAA;IACxB,6FAAA,IAAI,OAAA;IAGG,oHAAA,2BAA2B,OAAA;IAAE,wGAAA,eAAe,OAAA;IAAE,wGAAA,eAAe,OAAA;IAQ7D,qGAAA,YAAY,OAAA;IAAE,qGAAA,YAAY,OAAA;IAAE,6GAAA,oBAAoB,OAAA","sourcesContent":["export { getSlots, resolveShorthand, isResolvedShorthand } from './compose/index';\nexport type {\n ExtractSlotProps,\n ComponentProps,\n ComponentState,\n ForwardRefComponent,\n ResolveShorthandFunction,\n ResolveShorthandOptions,\n Slot,\n Slots,\n SlotClassNames,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n} from './compose/index';\n\nexport {\n IdPrefixProvider,\n resetIdsForTests,\n useControllableState,\n useEventCallback,\n useFirstMount,\n useForceUpdate,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n useOnClickOutside,\n useOnScrollOutside,\n usePrevious,\n useScrollbarWidth,\n useTimeout,\n} from './hooks/index';\nexport type { RefObjectFunction, UseControllableStateOptions, UseOnClickOrScrollOutsideOptions } from './hooks/index';\n\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\n\nexport {\n clamp,\n getNativeElementProps,\n getPartitionedNativeProps,\n getRTLSafeKey,\n mergeCallbacks,\n isHTMLElement,\n isInteractiveHTMLElement,\n omit,\n} from './utils/index';\n\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\n\nexport type { FluentTriggerComponent, TriggerProps } from './trigger/index';\n\n/**\n * Event utils\n */\nexport type { NativeTouchOrMouseEvent, ReactTouchOrMouseEvent, TouchOrMouseEvent } from './events/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\n"]}
|
@@ -1,69 +0,0 @@
|
|
1
|
-
define(["require", "exports", "react", "./canUseDOM"], function (require, exports, React, canUseDOM_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.useIsSSR = exports.SSRProvider = exports.useSSRContext = exports.SSRContext = exports.defaultSSRContextValue = void 0;
|
5
|
-
/**
|
6
|
-
* Default context value to use in case there is no SSRProvider. This is fine for client-only apps.
|
7
|
-
*
|
8
|
-
* @internal
|
9
|
-
*/
|
10
|
-
exports.defaultSSRContextValue = {
|
11
|
-
current: 0,
|
12
|
-
};
|
13
|
-
exports.SSRContext = React.createContext(undefined);
|
14
|
-
/**
|
15
|
-
* @internal
|
16
|
-
*/
|
17
|
-
function useSSRContext() {
|
18
|
-
var _a;
|
19
|
-
return (_a = React.useContext(exports.SSRContext)) !== null && _a !== void 0 ? _a : exports.defaultSSRContextValue;
|
20
|
-
}
|
21
|
-
exports.useSSRContext = useSSRContext;
|
22
|
-
/**
|
23
|
-
* When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids
|
24
|
-
* are consistent between the client and server.
|
25
|
-
*
|
26
|
-
* @public
|
27
|
-
*/
|
28
|
-
var SSRProvider = function (props) {
|
29
|
-
var value = React.useState(function () { return ({ current: 0 }); })[0];
|
30
|
-
return React.createElement(exports.SSRContext.Provider, { value: value }, props.children);
|
31
|
-
};
|
32
|
-
exports.SSRProvider = SSRProvider;
|
33
|
-
/**
|
34
|
-
* Returns whether the component is currently being server side rendered or hydrated on the client. Can be used to delay
|
35
|
-
* browser-specific rendering until after hydration. May cause re-renders on a client when is used within SSRProvider.
|
36
|
-
*/
|
37
|
-
function useIsSSR() {
|
38
|
-
var isInSSRContext = useSSRContext() !== exports.defaultSSRContextValue;
|
39
|
-
var _a = React.useState(isInSSRContext), isSSR = _a[0], setIsSSR = _a[1];
|
40
|
-
// If we are rendering in a non-DOM environment, and there's no SSRProvider, provide a warning to hint to the
|
41
|
-
// developer to add one.
|
42
|
-
if (process.env.NODE_ENV !== 'production') {
|
43
|
-
if (!isInSSRContext && !canUseDOM_1.canUseDOM()) {
|
44
|
-
// eslint-disable-next-line no-console
|
45
|
-
console.error([
|
46
|
-
'@fluentui/react-components: ',
|
47
|
-
'When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are ' +
|
48
|
-
'generated between the client and server.',
|
49
|
-
'\n',
|
50
|
-
'\n',
|
51
|
-
'Check documentation at https://aka.ms/fluentui-ssr',
|
52
|
-
].join(''));
|
53
|
-
}
|
54
|
-
}
|
55
|
-
// If on the client, and the component was initially server rendered, then schedule a layout effect to update the
|
56
|
-
// component after hydration.
|
57
|
-
if (canUseDOM_1.canUseDOM() && isInSSRContext) {
|
58
|
-
// This if statement technically breaks the rules of hooks, but is safe because the condition never changes after
|
59
|
-
// mounting.
|
60
|
-
// eslint-disable-next-line
|
61
|
-
React.useLayoutEffect(function () {
|
62
|
-
setIsSSR(false);
|
63
|
-
}, []);
|
64
|
-
}
|
65
|
-
return isSSR;
|
66
|
-
}
|
67
|
-
exports.useIsSSR = useIsSSR;
|
68
|
-
});
|
69
|
-
//# sourceMappingURL=SSRContext.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"SSRContext.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/ssr/SSRContext.tsx"],"names":[],"mappings":";;;;IAaA;;;;OAIG;IACU,QAAA,sBAAsB,GAAoB;QACrD,OAAO,EAAE,CAAC;KACX,CAAC;IAEW,QAAA,UAAU,GAAG,KAAK,CAAC,aAAa,CAA8B,SAAS,CAAmC,CAAC;IAExH;;OAEG;IACH,SAAgB,aAAa;;QAC3B,OAAO,MAAA,KAAK,CAAC,UAAU,CAAC,kBAAU,CAAC,mCAAI,8BAAsB,CAAC;IAChE,CAAC;IAFD,sCAEC;IAED;;;;;OAKG;IACI,IAAM,WAAW,GAA4C,UAAA,KAAK;QAChE,IAAA,KAAK,GAAI,KAAK,CAAC,QAAQ,CAAkB,cAAM,OAAA,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAhB,CAAgB,CAAC,GAA3D,CAA4D;QAExE,OAAO,oBAAC,kBAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,KAAK,CAAC,QAAQ,CAAuB,CAAC;IACnF,CAAC,CAAC;IAJW,QAAA,WAAW,eAItB;IAEF;;;OAGG;IACH,SAAgB,QAAQ;QACtB,IAAM,cAAc,GAAG,aAAa,EAAE,KAAK,8BAAsB,CAAC;QAC5D,IAAA,KAAoB,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAjD,KAAK,QAAA,EAAE,QAAQ,QAAkC,CAAC;QAEzD,6GAA6G;QAC7G,wBAAwB;QACxB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;YACzC,IAAI,CAAC,cAAc,IAAI,CAAC,qBAAS,EAAE,EAAE;gBACnC,sCAAsC;gBACtC,OAAO,CAAC,KAAK,CACX;oBACE,8BAA8B;oBAC9B,yGAAyG;wBACvG,0CAA0C;oBAC5C,IAAI;oBACJ,IAAI;oBACJ,oDAAoD;iBACrD,CAAC,IAAI,CAAC,EAAE,CAAC,CACX,CAAC;aACH;SACF;QAED,iHAAiH;QACjH,6BAA6B;QAC7B,IAAI,qBAAS,EAAE,IAAI,cAAc,EAAE;YACjC,iHAAiH;YACjH,YAAY;YACZ,2BAA2B;YAC3B,KAAK,CAAC,eAAe,CAAC;gBACpB,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC,EAAE,EAAE,CAAC,CAAC;SACR;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAlCD,4BAkCC","sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from './canUseDOM';\n\n/**\n * To support SSR, the auto incrementing id counter is stored in a context. This allows it to be reset on every request\n * to ensure the client and server are consistent.\n *\n * @internal\n */\nexport type SSRContextValue = {\n current: number;\n};\n\n/**\n * Default context value to use in case there is no SSRProvider. This is fine for client-only apps.\n *\n * @internal\n */\nexport const defaultSSRContextValue: SSRContextValue = {\n current: 0,\n};\n\nexport const SSRContext = React.createContext<SSRContextValue | undefined>(undefined) as React.Context<SSRContextValue>;\n\n/**\n * @internal\n */\nexport function useSSRContext(): SSRContextValue {\n return React.useContext(SSRContext) ?? defaultSSRContextValue;\n}\n\n/**\n * When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids\n * are consistent between the client and server.\n *\n * @public\n */\nexport const SSRProvider: React.FC<{ children: React.ReactNode }> = props => {\n const [value] = React.useState<SSRContextValue>(() => ({ current: 0 }));\n\n return <SSRContext.Provider value={value}>{props.children}</SSRContext.Provider>;\n};\n\n/**\n * Returns whether the component is currently being server side rendered or hydrated on the client. Can be used to delay\n * browser-specific rendering until after hydration. May cause re-renders on a client when is used within SSRProvider.\n */\nexport function useIsSSR(): boolean {\n const isInSSRContext = useSSRContext() !== defaultSSRContextValue;\n const [isSSR, setIsSSR] = React.useState(isInSSRContext);\n\n // If we are rendering in a non-DOM environment, and there's no SSRProvider, provide a warning to hint to the\n // developer to add one.\n if (process.env.NODE_ENV !== 'production') {\n if (!isInSSRContext && !canUseDOM()) {\n // eslint-disable-next-line no-console\n console.error(\n [\n '@fluentui/react-components: ',\n 'When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are ' +\n 'generated between the client and server.',\n '\\n',\n '\\n',\n 'Check documentation at https://aka.ms/fluentui-ssr',\n ].join(''),\n );\n }\n }\n\n // If on the client, and the component was initially server rendered, then schedule a layout effect to update the\n // component after hydration.\n if (canUseDOM() && isInSSRContext) {\n // This if statement technically breaks the rules of hooks, but is safe because the condition never changes after\n // mounting.\n // eslint-disable-next-line\n React.useLayoutEffect(() => {\n setIsSSR(false);\n }, []);\n }\n\n return isSSR;\n}\n"]}
|
package/lib-amd/ssr/canUseDOM.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
define(["require", "exports"], function (require, exports) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.canUseDOM = void 0;
|
5
|
-
/**
|
6
|
-
* Verifies if an application can use DOM.
|
7
|
-
*/
|
8
|
-
function canUseDOM() {
|
9
|
-
return (typeof window !== 'undefined' &&
|
10
|
-
!!(window.document &&
|
11
|
-
// eslint-disable-next-line deprecation/deprecation
|
12
|
-
window.document.createElement));
|
13
|
-
}
|
14
|
-
exports.canUseDOM = canUseDOM;
|
15
|
-
});
|
16
|
-
//# sourceMappingURL=canUseDOM.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"canUseDOM.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/ssr/canUseDOM.ts"],"names":[],"mappings":";;;;IAAA;;OAEG;IACH,SAAgB,SAAS;QACvB,OAAO,CACL,OAAO,MAAM,KAAK,WAAW;YAC7B,CAAC,CAAC,CACA,MAAM,CAAC,QAAQ;gBACf,mDAAmD;gBACnD,MAAM,CAAC,QAAQ,CAAC,aAAa,CAC9B,CACF,CAAC;IACJ,CAAC;IATD,8BASC","sourcesContent":["/**\n * Verifies if an application can use DOM.\n */\nexport function canUseDOM(): boolean {\n return (\n typeof window !== 'undefined' &&\n !!(\n window.document &&\n // eslint-disable-next-line deprecation/deprecation\n window.document.createElement\n )\n );\n}\n"]}
|
package/lib-amd/ssr/index.js
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
define(["require", "exports", "tslib", "./canUseDOM", "./SSRContext"], function (require, exports, tslib_1, canUseDOM_1, SSRContext_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
tslib_1.__exportStar(canUseDOM_1, exports);
|
5
|
-
tslib_1.__exportStar(SSRContext_1, exports);
|
6
|
-
});
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/lib-amd/ssr/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/ssr/index.ts"],"names":[],"mappings":";;;IAAA,2CAA4B;IAC5B,4CAA6B","sourcesContent":["export * from './canUseDOM';\nexport * from './SSRContext';\n"]}
|