@fluentui/react-utilities 0.0.0-nightly-20230317-1454.1 → 0.0.0-nightly-20230321-0440.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 +5 -5
- package/CHANGELOG.md +5 -5
- package/lib/compose/getSlots.js +7 -6
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/index.js +4 -4
- package/lib/compose/index.js.map +1 -1
- package/lib/compose/isResolvedShorthand.js +2 -2
- package/lib/compose/isResolvedShorthand.js.map +1 -1
- package/lib/compose/resolveShorthand.js +3 -3
- 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 +1 -1
- package/lib/events/index.js.map +1 -1
- package/lib/events/mouseTouchHelpers.js +4 -5
- package/lib/events/mouseTouchHelpers.js.map +1 -1
- package/lib/hooks/index.js +12 -12
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useControllableState.js +7 -7
- package/lib/hooks/useControllableState.js.map +1 -1
- package/lib/hooks/useEventCallback.js +3 -3
- package/lib/hooks/useEventCallback.js.map +1 -1
- package/lib/hooks/useFirstMount.js +1 -1
- package/lib/hooks/useFirstMount.js.map +1 -1
- package/lib/hooks/useForceUpdate.js +1 -1
- package/lib/hooks/useForceUpdate.js.map +1 -1
- package/lib/hooks/useId.js +6 -6
- package/lib/hooks/useId.js.map +1 -1
- package/lib/hooks/useIsomorphicLayoutEffect.js +4 -3
- package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib/hooks/useMergedRefs.js +2 -2
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js +23 -20
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnScrollOutside.js +7 -7
- package/lib/hooks/useOnScrollOutside.js.map +1 -1
- package/lib/hooks/usePrevious.js +1 -1
- package/lib/hooks/usePrevious.js.map +1 -1
- package/lib/hooks/useScrollbarWidth.js +5 -5
- package/lib/hooks/useScrollbarWidth.js.map +1 -1
- package/lib/hooks/useTimeout.js +1 -1
- package/lib/hooks/useTimeout.js.map +1 -1
- package/lib/index.js +6 -6
- package/lib/index.js.map +1 -1
- package/lib/ssr/SSRContext.js +6 -5
- package/lib/ssr/SSRContext.js.map +1 -1
- package/lib/ssr/canUseDOM.js +3 -2
- package/lib/ssr/canUseDOM.js.map +1 -1
- package/lib/ssr/index.js +2 -2
- package/lib/ssr/index.js.map +1 -1
- package/lib/trigger/applyTriggerPropsToChildren.js +4 -4
- package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib/trigger/getTriggerChild.js +2 -2
- package/lib/trigger/getTriggerChild.js.map +1 -1
- package/lib/trigger/index.js +4 -4
- package/lib/trigger/index.js.map +1 -1
- package/lib/trigger/isFluentTrigger.js +0 -1
- 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 +2 -1
- package/lib/utils/clamp.js.map +1 -1
- package/lib/utils/getNativeElementProps.js +4 -4
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.js +7 -6
- package/lib/utils/getRTLSafeKey.js.map +1 -1
- package/lib/utils/getReactCallbackName.js +2 -3
- package/lib/utils/getReactCallbackName.js.map +1 -1
- package/lib/utils/index.js +8 -8
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isHTMLElement.js +4 -2
- package/lib/utils/isHTMLElement.js.map +1 -1
- package/lib/utils/isInteractiveHTMLElement.js +5 -5
- package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib/utils/mergeCallbacks.js +4 -3
- package/lib/utils/mergeCallbacks.js.map +1 -1
- package/lib/utils/omit.js +2 -1
- package/lib/utils/omit.js.map +1 -1
- package/lib/utils/properties.js +55 -28
- package/lib/utils/properties.js.map +1 -1
- package/lib-commonjs/compose/getSlots.js +55 -47
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/index.js +7 -8
- package/lib-commonjs/compose/index.js.map +1 -1
- package/lib-commonjs/compose/isResolvedShorthand.js +37 -9
- package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.js +32 -25
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/compose/types.js +2 -5
- package/lib-commonjs/compose/types.js.map +1 -1
- package/lib-commonjs/events/index.js +4 -5
- package/lib-commonjs/events/index.js.map +1 -1
- package/lib-commonjs/events/mouseTouchHelpers.js +37 -40
- package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
- package/lib-commonjs/hooks/index.js +15 -16
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useControllableState.js +64 -63
- package/lib-commonjs/hooks/useControllableState.js.map +1 -1
- package/lib-commonjs/hooks/useEventCallback.js +31 -25
- package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
- package/lib-commonjs/hooks/useFirstMount.js +23 -15
- package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
- package/lib-commonjs/hooks/useForceUpdate.js +11 -9
- package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
- package/lib-commonjs/hooks/useId.js +47 -48
- package/lib-commonjs/hooks/useId.js.map +1 -1
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +16 -10
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib-commonjs/hooks/useMergedRefs.js +27 -25
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js +115 -109
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnScrollOutside.js +36 -33
- package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
- package/lib-commonjs/hooks/usePrevious.js +15 -17
- 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 +214 -52
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/ssr/SSRContext.js +59 -56
- 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 +5 -6
- package/lib-commonjs/ssr/index.js.map +1 -1
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js +31 -29
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib-commonjs/trigger/getTriggerChild.js +36 -16
- package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
- package/lib-commonjs/trigger/index.js +7 -8
- package/lib-commonjs/trigger/index.js.map +1 -1
- package/lib-commonjs/trigger/isFluentTrigger.js +11 -10
- package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
- package/lib-commonjs/trigger/types.js +2 -5
- package/lib-commonjs/trigger/types.js.map +1 -1
- package/lib-commonjs/utils/clamp.js +9 -10
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/getNativeElementProps.js +61 -54
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.js +21 -22
- 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 +11 -12
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/isHTMLElement.js +12 -12
- package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/isInteractiveHTMLElement.js +24 -20
- package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/mergeCallbacks.js +13 -14
- package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
- package/lib-commonjs/utils/omit.js +17 -18
- package/lib-commonjs/utils/omit.js.map +1 -1
- package/lib-commonjs/utils/properties.js +223 -327
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/package.json +5 -4
- package/.swcrc +0 -39
@@ -1,20 +1,19 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
+
value: true
|
4
5
|
});
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
//# sourceMappingURL=index.js.map
|
19
|
-
|
6
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
7
|
+
tslib_1.__exportStar(require("./useControllableState"), exports);
|
8
|
+
tslib_1.__exportStar(require("./useEventCallback"), exports);
|
9
|
+
tslib_1.__exportStar(require("./useFirstMount"), exports);
|
10
|
+
tslib_1.__exportStar(require("./useForceUpdate"), exports);
|
11
|
+
tslib_1.__exportStar(require("./useId"), exports);
|
12
|
+
tslib_1.__exportStar(require("./useIsomorphicLayoutEffect"), exports);
|
13
|
+
tslib_1.__exportStar(require("./useMergedRefs"), exports);
|
14
|
+
tslib_1.__exportStar(require("./useOnClickOutside"), exports);
|
15
|
+
tslib_1.__exportStar(require("./useOnScrollOutside"), exports);
|
16
|
+
tslib_1.__exportStar(require("./usePrevious"), exports);
|
17
|
+
tslib_1.__exportStar(require("./useScrollbarWidth"), exports);
|
18
|
+
tslib_1.__exportStar(require("./useTimeout"), exports);
|
20
19
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/index.ts"],"sourcesContent":["export * 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"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,4BAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,wBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,qBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,sBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,aAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,iCAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,qBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,yBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,0BAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,mBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,yBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,kBAAAC,OAAA"}
|
@@ -1,74 +1,75 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "useControllableState", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>useControllableState
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
6
|
+
exports.useControllableState = void 0;
|
7
|
+
const React = /*#__PURE__*/require("react");
|
11
8
|
function isFactoryDispatch(newState) {
|
12
|
-
|
9
|
+
return typeof newState === 'function';
|
13
10
|
}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
11
|
+
/**
|
12
|
+
* @internal
|
13
|
+
*
|
14
|
+
* A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
|
15
|
+
* such as a checked state or text input string.
|
16
|
+
*
|
17
|
+
* Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
|
18
|
+
* controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
|
19
|
+
*
|
20
|
+
* @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
|
21
|
+
* of the current value and an updater (dispatch) function. The updater function is referentially
|
22
|
+
* stable (won't change during the component's lifecycle). It can take either a new value, or a
|
23
|
+
* function which is passed the previous value and returns the new value. Unlike `setState`, calls
|
24
|
+
* to the updater function will only be respected if the component is uncontrolled.
|
25
|
+
* @see https://reactjs.org/docs/uncontrolled-components.html
|
26
|
+
*/
|
27
|
+
const useControllableState = options => {
|
28
|
+
const isControlled = useIsControlled(options.state);
|
29
|
+
const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;
|
30
|
+
const [internalState, setInternalState] = React.useState(initialState);
|
31
|
+
const state = isControlled ? options.state : internalState;
|
32
|
+
const stateRef = React.useRef(state);
|
33
|
+
React.useEffect(() => {
|
34
|
+
stateRef.current = state;
|
35
|
+
}, [state]);
|
36
|
+
// To match the behavior of the setter returned by React.useState, this callback's identity
|
37
|
+
// should never change. This means it MUST NOT directly reference variables that can change.
|
38
|
+
const setState = React.useCallback(newState => {
|
39
|
+
// React dispatch can use a factory
|
40
|
+
// https://reactjs.org/docs/hooks-reference.html#functional-updates
|
41
|
+
if (isFactoryDispatch(newState)) {
|
42
|
+
stateRef.current = newState(stateRef.current);
|
43
|
+
} else {
|
44
|
+
stateRef.current = newState;
|
45
|
+
}
|
46
|
+
setInternalState(stateRef.current);
|
47
|
+
}, []);
|
48
|
+
return [state, setState];
|
41
49
|
};
|
50
|
+
exports.useControllableState = useControllableState;
|
42
51
|
/**
|
43
52
|
* Helper hook to handle previous comparison of controlled/uncontrolled
|
44
53
|
* Prints an error when isControlled value switches between subsequent renders
|
45
54
|
* @returns - whether the value is controlled
|
46
|
-
*/
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
}, [
|
67
|
-
isControlled,
|
68
|
-
controlledValue
|
69
|
-
]);
|
70
|
-
}
|
71
|
-
return isControlled;
|
72
|
-
}; //# sourceMappingURL=useControllableState.js.map
|
73
|
-
|
55
|
+
*/
|
56
|
+
const useIsControlled = controlledValue => {
|
57
|
+
const [isControlled] = React.useState(() => controlledValue !== undefined);
|
58
|
+
if (process.env.NODE_ENV !== 'production') {
|
59
|
+
// We don't want these warnings in production even though it is against native behaviour
|
60
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
61
|
+
React.useEffect(() => {
|
62
|
+
if (isControlled !== (controlledValue !== undefined)) {
|
63
|
+
const error = new Error();
|
64
|
+
const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';
|
65
|
+
const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';
|
66
|
+
// eslint-disable-next-line no-console
|
67
|
+
console.error([
|
68
|
+
// Default react error
|
69
|
+
'A component is changing ' + controlWarning + '. This is likely caused by the value', 'changing from ' + undefinedWarning + ' value, which should not happen.', 'Decide between using a controlled or uncontrolled input element for the lifetime of the component.', 'More info: https://reactjs.org/link/controlled-components', error.stack].join(' '));
|
70
|
+
}
|
71
|
+
}, [isControlled, controlledValue]);
|
72
|
+
}
|
73
|
+
return isControlled;
|
74
|
+
};
|
74
75
|
//# sourceMappingURL=useControllableState.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["React","require","isFactoryDispatch","newState","useControllableState","options","isControlled","useIsControlled","state","initialState","defaultState","internalState","setInternalState","useState","stateRef","useRef","useEffect","current","setState","useCallback","exports","controlledValue","undefined","process","env","NODE_ENV","error","Error","controlWarning","undefinedWarning","console","stack","join"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useControllableState.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n */\nexport type UseControllableStateOptions<State> = {\n /**\n * User-provided default state or initializer, for uncontrolled usage.\n */\n defaultState?: State | (() => State);\n /**\n * User-provided controlled state. `undefined` means internal state will be used.\n */\n state: State | undefined;\n /**\n * Used as the initial state if `state` and `defaultState` are both `undefined`.\n * If `undefined` is the correct initial state, pass that here.\n */\n initialState: State;\n};\n\nfunction isFactoryDispatch<State>(newState: React.SetStateAction<State>): newState is (prevState: State) => State {\n return typeof newState === 'function';\n}\n\n/**\n * @internal\n *\n * A `useState`-like hook to manage a value that could be either controlled or uncontrolled,\n * such as a checked state or text input string.\n *\n * Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a\n * controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.\n *\n * @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array\n * of the current value and an updater (dispatch) function. The updater function is referentially\n * stable (won't change during the component's lifecycle). It can take either a new value, or a\n * function which is passed the previous value and returns the new value. Unlike `setState`, calls\n * to the updater function will only be respected if the component is uncontrolled.\n * @see https://reactjs.org/docs/uncontrolled-components.html\n */\nexport const useControllableState = <State>(\n options: UseControllableStateOptions<State>,\n): [State, React.Dispatch<React.SetStateAction<State>>] => {\n const isControlled = useIsControlled(options.state);\n const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;\n const [internalState, setInternalState] = React.useState<State>(initialState);\n\n const state = isControlled ? (options.state as State) : internalState;\n\n const stateRef = React.useRef(state);\n React.useEffect(() => {\n stateRef.current = state;\n }, [state]);\n\n // To match the behavior of the setter returned by React.useState, this callback's identity\n // should never change. This means it MUST NOT directly reference variables that can change.\n const setState = React.useCallback((newState: React.SetStateAction<State>) => {\n // React dispatch can use a factory\n // https://reactjs.org/docs/hooks-reference.html#functional-updates\n if (isFactoryDispatch(newState)) {\n stateRef.current = newState(stateRef.current);\n } else {\n stateRef.current = newState;\n }\n\n setInternalState(stateRef.current);\n }, []);\n\n return [state, setState];\n};\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 */\nconst useIsControlled = (controlledValue: unknown) => {\n const [isControlled] = React.useState<boolean>(() => controlledValue !== undefined);\n\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\n const controlWarning = isControlled\n ? 'a controlled value to be uncontrolled'\n : 'an uncontrolled value to be controlled';\n\n const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';\n\n // eslint-disable-next-line no-console\n console.error(\n [\n // Default react error\n 'A component is changing ' + controlWarning + '. This is likely caused by the value',\n 'changing from ' + undefinedWarning + ' value, which should not happen.',\n 'Decide between using a controlled or uncontrolled input element for the lifetime of the component.',\n 'More info: https://reactjs.org/link/controlled-components',\n error.stack,\n ].join(' '),\n );\n }\n }, [isControlled, controlledValue]);\n }\n\n return isControlled;\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AAqBA,SAASC,iBAAiBA,CAAQC,QAAqC;EACrE,OAAO,OAAOA,QAAQ,KAAK,UAAU;AACvC;AAEA;;;;;;;;;;;;;;;;AAgBO,MAAMC,oBAAoB,GAC/BC,OAA2C,IACa;EACxD,MAAMC,YAAY,GAAGC,eAAe,CAACF,OAAO,CAACG,KAAK,CAAC;EACnD,MAAMC,YAAY,GAAG,OAAOJ,OAAO,CAACK,YAAY,KAAK,WAAW,GAAGL,OAAO,CAACI,YAAY,GAAGJ,OAAO,CAACK,YAAY;EAC9G,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGZ,KAAK,CAACa,QAAQ,CAAQJ,YAAY,CAAC;EAE7E,MAAMD,KAAK,GAAGF,YAAY,GAAID,OAAO,CAACG,KAAe,GAAGG,aAAa;EAErE,MAAMG,QAAQ,GAAGd,KAAK,CAACe,MAAM,CAACP,KAAK,CAAC;EACpCR,KAAK,CAACgB,SAAS,CAAC,MAAK;IACnBF,QAAQ,CAACG,OAAO,GAAGT,KAAK;EAC1B,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX;EACA;EACA,MAAMU,QAAQ,GAAGlB,KAAK,CAACmB,WAAW,CAAEhB,QAAqC,IAAI;IAC3E;IACA;IACA,IAAID,iBAAiB,CAACC,QAAQ,CAAC,EAAE;MAC/BW,QAAQ,CAACG,OAAO,GAAGd,QAAQ,CAACW,QAAQ,CAACG,OAAO,CAAC;KAC9C,MAAM;MACLH,QAAQ,CAACG,OAAO,GAAGd,QAAQ;;IAG7BS,gBAAgB,CAACE,QAAQ,CAACG,OAAO,CAAC;EACpC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,CAACT,KAAK,EAAEU,QAAQ,CAAC;AAC1B,CAAC;AA7BYE,OAAA,CAAAhB,oBAAoB,GAAAA,oBAAA;AA+BjC;;;;;AAKA,MAAMG,eAAe,GAAIc,eAAwB,IAAI;EACnD,MAAM,CAACf,YAAY,CAAC,GAAGN,KAAK,CAACa,QAAQ,CAAU,MAAMQ,eAAe,KAAKC,SAAS,CAAC;EAEnF,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC;IACA;IACAzB,KAAK,CAACgB,SAAS,CAAC,MAAK;MACnB,IAAIV,YAAY,MAAMe,eAAe,KAAKC,SAAS,CAAC,EAAE;QACpD,MAAMI,KAAK,GAAG,IAAIC,KAAK,EAAE;QAEzB,MAAMC,cAAc,GAAGtB,YAAY,GAC/B,uCAAuC,GACvC,wCAAwC;QAE5C,MAAMuB,gBAAgB,GAAGvB,YAAY,GAAG,yBAAyB,GAAG,wBAAwB;QAE5F;QACAwB,OAAO,CAACJ,KAAK,CACX;QACE;QACA,0BAA0B,GAAGE,cAAc,GAAG,sCAAsC,EACpF,gBAAgB,GAAGC,gBAAgB,GAAG,kCAAkC,EACxE,oGAAoG,EACpG,2DAA2D,EAC3DH,KAAK,CAACK,KAAK,CACZ,CAACC,IAAI,CAAC,GAAG,CAAC,CACZ;;IAEL,CAAC,EAAE,CAAC1B,YAAY,EAAEe,eAAe,CAAC,CAAC;;EAGrC,OAAOf,YAAY;AACrB,CAAC"}
|
@@ -1,29 +1,35 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "useEventCallback", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>useEventCallback
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
11
|
-
const
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
6
|
+
exports.useEventCallback = void 0;
|
7
|
+
const React = /*#__PURE__*/require("react");
|
8
|
+
const useIsomorphicLayoutEffect_1 = /*#__PURE__*/require("./useIsomorphicLayoutEffect");
|
9
|
+
/**
|
10
|
+
* @internal
|
11
|
+
* https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
|
12
|
+
*
|
13
|
+
* Modified `useCallback` that can be used when dependencies change too frequently. Can occur when
|
14
|
+
* e.g. user props are dependencies which could change on every render
|
15
|
+
* e.g. volatile values (i.e. useState/useDispatch) are dependencies which could change frequently
|
16
|
+
*
|
17
|
+
* This should not be used often, but can be a useful re-render optimization since the callback is a ref and
|
18
|
+
* will not be invalidated between re-renders
|
19
|
+
*
|
20
|
+
* @param fn - The callback function that will be used
|
21
|
+
*/
|
22
|
+
const useEventCallback = fn => {
|
23
|
+
const callbackRef = React.useRef(() => {
|
24
|
+
throw new Error('Cannot call an event handler while rendering');
|
25
|
+
});
|
26
|
+
useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect(() => {
|
27
|
+
callbackRef.current = fn;
|
28
|
+
}, [fn]);
|
29
|
+
return React.useCallback((...args) => {
|
30
|
+
const callback = callbackRef.current;
|
31
|
+
return callback(...args);
|
32
|
+
}, [callbackRef]);
|
33
|
+
};
|
34
|
+
exports.useEventCallback = useEventCallback;
|
29
35
|
//# sourceMappingURL=useEventCallback.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["React","require","useIsomorphicLayoutEffect_1","useEventCallback","fn","callbackRef","useRef","Error","useIsomorphicLayoutEffect","current","useCallback","args","callback","exports"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useEventCallback.ts"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n\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 */\nexport const useEventCallback = <Args extends unknown[], Return>(fn: (...args: Args) => Return) => {\n const callbackRef = React.useRef<typeof fn>(() => {\n throw new Error('Cannot call an event handler while rendering');\n });\n\n useIsomorphicLayoutEffect(() => {\n callbackRef.current = fn;\n }, [fn]);\n\n return React.useCallback(\n (...args: Args) => {\n const callback = callbackRef.current;\n return callback(...args);\n },\n [callbackRef],\n );\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,2BAAA,gBAAAD,OAAA;AAEA;;;;;;;;;;;;;AAaO,MAAME,gBAAgB,GAAoCC,EAA6B,IAAI;EAChG,MAAMC,WAAW,GAAGL,KAAK,CAACM,MAAM,CAAY,MAAK;IAC/C,MAAM,IAAIC,KAAK,CAAC,8CAA8C,CAAC;EACjE,CAAC,CAAC;EAEFL,2BAAA,CAAAM,yBAAyB,CAAC,MAAK;IAC7BH,WAAW,CAACI,OAAO,GAAGL,EAAE;EAC1B,CAAC,EAAE,CAACA,EAAE,CAAC,CAAC;EAER,OAAOJ,KAAK,CAACU,WAAW,CACtB,CAAC,GAAGC,IAAU,KAAI;IAChB,MAAMC,QAAQ,GAAGP,WAAW,CAACI,OAAO;IACpC,OAAOG,QAAQ,CAAC,GAAGD,IAAI,CAAC;EAC1B,CAAC,EACD,CAACN,WAAW,CAAC,CACd;AACH,CAAC;AAhBYQ,OAAA,CAAAV,gBAAgB,GAAAA,gBAAA"}
|
@@ -1,20 +1,28 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "useFirstMount", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>useFirstMount
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
6
|
+
exports.useFirstMount = void 0;
|
7
|
+
const React = /*#__PURE__*/require("react");
|
8
|
+
/**
|
9
|
+
* @internal
|
10
|
+
* Checks if components was mounted the first time.
|
11
|
+
* Since concurrent mode will be released in the future this needs to be verified
|
12
|
+
* Currently (React 17) will always render the initial mount once
|
13
|
+
* https://codesandbox.io/s/heuristic-brook-s4w0q?file=/src/App.jsx
|
14
|
+
* https://codesandbox.io/s/holy-grass-8nieu?file=/src/App.jsx
|
15
|
+
*
|
16
|
+
* @example
|
17
|
+
* const isFirstMount = useFirstMount();
|
18
|
+
*/
|
11
19
|
function useFirstMount() {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
}
|
19
|
-
|
20
|
+
const isFirst = React.useRef(true);
|
21
|
+
if (isFirst.current) {
|
22
|
+
isFirst.current = false;
|
23
|
+
return true;
|
24
|
+
}
|
25
|
+
return isFirst.current;
|
26
|
+
}
|
27
|
+
exports.useFirstMount = useFirstMount;
|
20
28
|
//# sourceMappingURL=useFirstMount.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["React","require","useFirstMount","isFirst","useRef","current","exports"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useFirstMount.ts"],"sourcesContent":["import * as React from 'react';\n\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 */\nexport function useFirstMount(): boolean {\n const isFirst = React.useRef(true);\n\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n\n return isFirst.current;\n}\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AAEA;;;;;;;;;;;AAWA,SAAgBC,aAAaA,CAAA;EAC3B,MAAMC,OAAO,GAAGH,KAAK,CAACI,MAAM,CAAC,IAAI,CAAC;EAElC,IAAID,OAAO,CAACE,OAAO,EAAE;IACnBF,OAAO,CAACE,OAAO,GAAG,KAAK;IACvB,OAAO,IAAI;;EAGb,OAAOF,OAAO,CAACE,OAAO;AACxB;AATAC,OAAA,CAAAJ,aAAA,GAAAA,aAAA"}
|
@@ -1,14 +1,16 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "useForceUpdate", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>useForceUpdate
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
6
|
+
exports.useForceUpdate = void 0;
|
7
|
+
const react_1 = /*#__PURE__*/require("react");
|
8
|
+
/**
|
9
|
+
* @internal
|
10
|
+
* Forces a re-render, similar to `forceUpdate` in class components.
|
11
|
+
*/
|
10
12
|
function useForceUpdate() {
|
11
|
-
|
12
|
-
}
|
13
|
-
|
13
|
+
return react_1.useReducer(x => x + 1, 0)[1];
|
14
|
+
}
|
15
|
+
exports.useForceUpdate = useForceUpdate;
|
14
16
|
//# sourceMappingURL=useForceUpdate.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["react_1","require","useForceUpdate","useReducer","x","exports"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useForceUpdate.ts"],"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"],"mappings":";;;;;;AAAA,MAAAA,OAAA,gBAAAC,OAAA;AAEA;;;;AAIA,SAAgBC,cAAcA,CAAA;EAC5B,OAAOF,OAAA,CAAAG,UAAU,CAACC,CAAC,IAAIA,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC;AAFAC,OAAA,CAAAH,cAAA,GAAAA,cAAA"}
|
@@ -1,57 +1,56 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
function _export(target, all) {
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
7
|
-
enumerable: true,
|
8
|
-
get: all[name]
|
9
|
-
});
|
10
|
-
}
|
11
|
-
_export(exports, {
|
12
|
-
IdPrefixProvider: ()=>IdPrefixProvider,
|
13
|
-
resetIdsForTests: ()=>resetIdsForTests,
|
14
|
-
useId: ()=>useId
|
4
|
+
value: true
|
15
5
|
});
|
16
|
-
|
17
|
-
const
|
18
|
-
const
|
19
|
-
const IdPrefixContext = /*#__PURE__*/
|
20
|
-
|
6
|
+
exports.useId = exports.resetIdsForTests = exports.IdPrefixProvider = void 0;
|
7
|
+
const React = /*#__PURE__*/require("react");
|
8
|
+
const index_1 = /*#__PURE__*/require("../ssr/index");
|
9
|
+
const IdPrefixContext = /*#__PURE__*/React.createContext(undefined);
|
10
|
+
/**
|
11
|
+
* Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions
|
12
|
+
* between different bundles.
|
13
|
+
*/
|
14
|
+
exports.IdPrefixProvider = IdPrefixContext.Provider;
|
21
15
|
function useIdPrefix() {
|
22
|
-
|
16
|
+
return React.useContext(IdPrefixContext) || '';
|
23
17
|
}
|
18
|
+
/**
|
19
|
+
* Resets generated IDs, should be used only in tests.
|
20
|
+
*/
|
24
21
|
function resetIdsForTests() {
|
25
|
-
|
22
|
+
index_1.defaultSSRContextValue.current = 0;
|
26
23
|
}
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
24
|
+
exports.resetIdsForTests = resetIdsForTests;
|
25
|
+
/**
|
26
|
+
* Hook to generate a unique ID.
|
27
|
+
*
|
28
|
+
* @param prefix - Optional prefix for the ID. Defaults to 'fui-'.
|
29
|
+
* @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,
|
30
|
+
* without conditioning the hook call
|
31
|
+
* @returns The ID
|
32
|
+
*/
|
33
|
+
function useId(prefix = 'fui-', providedId) {
|
34
|
+
const contextValue = index_1.useSSRContext();
|
35
|
+
const idPrefix = useIdPrefix();
|
36
|
+
// Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to
|
37
|
+
// prevent bundlers from complaining with older versions of React.
|
38
|
+
const _useId = React['use' + 'Id'];
|
39
|
+
if (_useId) {
|
40
|
+
const generatedId = _useId();
|
43
41
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
}
|
56
|
-
|
42
|
+
const escapedId = React.useMemo(() => generatedId.replace(/:/g, ''), [generatedId]);
|
43
|
+
return providedId || `${idPrefix}${prefix}${escapedId}`;
|
44
|
+
}
|
45
|
+
// Hooks appear to be running conditionally, but they will always run in the same order since it's based on
|
46
|
+
// the version of React being used. This is safe to ignore.
|
47
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
48
|
+
return React.useMemo(() => {
|
49
|
+
if (providedId) {
|
50
|
+
return providedId;
|
51
|
+
}
|
52
|
+
return `${idPrefix}${prefix}${++contextValue.current}`;
|
53
|
+
}, [idPrefix, prefix, providedId, contextValue]);
|
54
|
+
}
|
55
|
+
exports.useId = useId;
|
57
56
|
//# sourceMappingURL=useId.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["React","require","index_1","IdPrefixContext","createContext","undefined","exports","IdPrefixProvider","Provider","useIdPrefix","useContext","resetIdsForTests","defaultSSRContextValue","current","useId","prefix","providedId","contextValue","useSSRContext","idPrefix","_useId","generatedId","escapedId","useMemo","replace"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useId.ts"],"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"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,OAAA,gBAAAD,OAAA;AAEA,MAAME,eAAe,gBAAGH,KAAK,CAACI,aAAa,CAAqBC,SAAS,CAAC;AAE1E;;;;AAIaC,OAAA,CAAAC,gBAAgB,GAAGJ,eAAe,CAACK,QAAQ;AAExD,SAASC,WAAWA,CAAA;EAClB,OAAOT,KAAK,CAACU,UAAU,CAACP,eAAe,CAAC,IAAI,EAAE;AAChD;AAEA;;;AAGA,SAAgBQ,gBAAgBA,CAAA;EAC9BT,OAAA,CAAAU,sBAAsB,CAACC,OAAO,GAAG,CAAC;AACpC;AAFAP,OAAA,CAAAK,gBAAA,GAAAA,gBAAA;AAIA;;;;;;;;AAQA,SAAgBG,KAAKA,CAACC,MAAA,GAAiB,MAAM,EAAEC,UAAmB;EAChE,MAAMC,YAAY,GAAGf,OAAA,CAAAgB,aAAa,EAAE;EACpC,MAAMC,QAAQ,GAAGV,WAAW,EAAE;EAE9B;EACA;EACA,MAAMW,MAAM,GAAIpB,KAAe,CAAC,KAAK,GAAG,IAAI,CAA+B;EAE3E,IAAIoB,MAAM,EAAE;IACV,MAAMC,WAAW,GAAGD,MAAM,EAAE;IAE5B;IACA,MAAME,SAAS,GAAGtB,KAAK,CAACuB,OAAO,CAAC,MAAMF,WAAW,CAACG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAACH,WAAW,CAAC,CAAC;IAEnF,OAAOL,UAAU,IAAI,GAAGG,QAAQ,GAAGJ,MAAM,GAAGO,SAAS,EAAE;;EAGzD;EACA;EACA;EACA,OAAOtB,KAAK,CAACuB,OAAO,CAAC,MAAK;IACxB,IAAIP,UAAU,EAAE;MACd,OAAOA,UAAU;;IAGnB,OAAO,GAAGG,QAAQ,GAAGJ,MAAM,GAAG,EAAEE,YAAY,CAACJ,OAAO,EAAE;EACxD,CAAC,EAAE,CAACM,QAAQ,EAAEJ,MAAM,EAAEC,UAAU,EAAEC,YAAY,CAAC,CAAC;AAClD;AA3BAX,OAAA,CAAAQ,KAAA,GAAAA,KAAA"}
|
@@ -1,14 +1,20 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "useIsomorphicLayoutEffect", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>useIsomorphicLayoutEffect
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
11
|
-
const
|
12
|
-
|
13
|
-
|
6
|
+
exports.useIsomorphicLayoutEffect = void 0;
|
7
|
+
const React = /*#__PURE__*/require("react");
|
8
|
+
const index_1 = /*#__PURE__*/require("../ssr/index");
|
9
|
+
/**
|
10
|
+
* React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally
|
11
|
+
* useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to
|
12
|
+
* ensure we don't get a render flash for certain operations, but we may also need affected components to render on
|
13
|
+
* the server.
|
14
|
+
*
|
15
|
+
* https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
|
16
|
+
* https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
|
17
|
+
*/
|
18
|
+
// eslint-disable-next-line no-restricted-properties
|
19
|
+
exports.useIsomorphicLayoutEffect = /*#__PURE__*/index_1.canUseDOM() ? React.useLayoutEffect : React.useEffect;
|
14
20
|
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"names":["React","require","index_1","exports","useIsomorphicLayoutEffect","canUseDOM","useLayoutEffect","useEffect"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useIsomorphicLayoutEffect.ts"],"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"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,OAAA,gBAAAD,OAAA;AAEA;;;;;;;;;AASA;AACaE,OAAA,CAAAC,yBAAyB,GAA2B,aAAAF,OAAA,CAAAG,SAAS,EAAE,GAAGL,KAAK,CAACM,eAAe,GAAGN,KAAK,CAACO,SAAS"}
|