@fluentui/react-utilities 0.0.0-nightly-20230317-0436.1 → 0.0.0-nightly-20230317-1454.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.swcrc +39 -0
- package/CHANGELOG.json +5 -5
- package/CHANGELOG.md +5 -5
- package/lib/compose/getSlots.js +6 -7
- 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 +5 -4
- 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 +3 -4
- 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 +20 -23
- 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 +5 -6
- package/lib/ssr/SSRContext.js.map +1 -1
- package/lib/ssr/canUseDOM.js +2 -3
- 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 +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 +4 -4
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.js +6 -7
- package/lib/utils/getRTLSafeKey.js.map +1 -1
- package/lib/utils/getReactCallbackName.js +3 -2
- 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 +2 -4
- 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 +3 -4
- 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 +28 -55
- package/lib/utils/properties.js.map +1 -1
- package/lib-commonjs/compose/getSlots.js +47 -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 +48 -47
- 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 +109 -115
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnScrollOutside.js +33 -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 +56 -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 +12 -12
- 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 +4 -4
@@ -1,19 +1,20 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
5
4
|
});
|
6
|
-
const
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
5
|
+
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
6
|
+
_exportStar(require("./useControllableState"), exports);
|
7
|
+
_exportStar(require("./useEventCallback"), exports);
|
8
|
+
_exportStar(require("./useFirstMount"), exports);
|
9
|
+
_exportStar(require("./useForceUpdate"), exports);
|
10
|
+
_exportStar(require("./useId"), exports);
|
11
|
+
_exportStar(require("./useIsomorphicLayoutEffect"), exports);
|
12
|
+
_exportStar(require("./useMergedRefs"), exports);
|
13
|
+
_exportStar(require("./useOnClickOutside"), exports);
|
14
|
+
_exportStar(require("./useOnScrollOutside"), exports);
|
15
|
+
_exportStar(require("./usePrevious"), exports);
|
16
|
+
_exportStar(require("./useScrollbarWidth"), exports);
|
17
|
+
_exportStar(require("./useTimeout"), exports);
|
18
|
+
//# sourceMappingURL=index.js.map
|
19
|
+
|
19
20
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/hooks/index.js"],"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//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;CACd,iCAAiC"}
|
@@ -1,75 +1,74 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useControllableState", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>useControllableState
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
8
11
|
function isFactoryDispatch(newState) {
|
9
|
-
|
12
|
+
return typeof newState === "function";
|
10
13
|
}
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
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];
|
14
|
+
const useControllableState = (options)=>{
|
15
|
+
const isControlled = useIsControlled(options.state);
|
16
|
+
const initialState = typeof options.defaultState === "undefined" ? options.initialState : options.defaultState;
|
17
|
+
const [internalState, setInternalState] = _react.useState(initialState);
|
18
|
+
const state = isControlled ? options.state : internalState;
|
19
|
+
const stateRef = _react.useRef(state);
|
20
|
+
_react.useEffect(()=>{
|
21
|
+
stateRef.current = state;
|
22
|
+
}, [
|
23
|
+
state
|
24
|
+
]);
|
25
|
+
// To match the behavior of the setter returned by React.useState, this callback's identity
|
26
|
+
// should never change. This means it MUST NOT directly reference variables that can change.
|
27
|
+
const setState = _react.useCallback((newState)=>{
|
28
|
+
// React dispatch can use a factory
|
29
|
+
// https://reactjs.org/docs/hooks-reference.html#functional-updates
|
30
|
+
if (isFactoryDispatch(newState)) {
|
31
|
+
stateRef.current = newState(stateRef.current);
|
32
|
+
} else {
|
33
|
+
stateRef.current = newState;
|
34
|
+
}
|
35
|
+
setInternalState(stateRef.current);
|
36
|
+
}, []);
|
37
|
+
return [
|
38
|
+
state,
|
39
|
+
setState
|
40
|
+
];
|
49
41
|
};
|
50
|
-
exports.useControllableState = useControllableState;
|
51
42
|
/**
|
52
43
|
* Helper hook to handle previous comparison of controlled/uncontrolled
|
53
44
|
* Prints an error when isControlled value switches between subsequent renders
|
54
45
|
* @returns - whether the value is controlled
|
55
|
-
*/
|
56
|
-
const
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}
|
46
|
+
*/ const useIsControlled = (controlledValue)=>{
|
47
|
+
const [isControlled] = _react.useState(()=>controlledValue !== undefined);
|
48
|
+
if (process.env.NODE_ENV !== "production") {
|
49
|
+
// We don't want these warnings in production even though it is against native behaviour
|
50
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
51
|
+
_react.useEffect(()=>{
|
52
|
+
if (isControlled !== (controlledValue !== undefined)) {
|
53
|
+
const error = new Error();
|
54
|
+
const controlWarning = isControlled ? "a controlled value to be uncontrolled" : "an uncontrolled value to be controlled";
|
55
|
+
const undefinedWarning = isControlled ? "defined to an undefined" : "undefined to a defined";
|
56
|
+
// eslint-disable-next-line no-console
|
57
|
+
console.error([
|
58
|
+
// Default react error
|
59
|
+
"A component is changing " + controlWarning + ". This is likely caused by the value",
|
60
|
+
"changing from " + undefinedWarning + " value, which should not happen.",
|
61
|
+
"Decide between using a controlled or uncontrolled input element for the lifetime of the component.",
|
62
|
+
"More info: https://reactjs.org/link/controlled-components",
|
63
|
+
error.stack
|
64
|
+
].join(" "));
|
65
|
+
}
|
66
|
+
}, [
|
67
|
+
isControlled,
|
68
|
+
controlledValue
|
69
|
+
]);
|
70
|
+
}
|
71
|
+
return isControlled;
|
72
|
+
}; //# sourceMappingURL=useControllableState.js.map
|
73
|
+
|
75
74
|
//# sourceMappingURL=useControllableState.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/hooks/useControllableState.js"],"sourcesContent":["import * as React from \"react\";\nfunction isFactoryDispatch(newState) {\n return typeof newState === \"function\";\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 = options => {\n const isControlled = useIsControlled(options.state);\n const initialState = typeof options.defaultState === \"undefined\" ? options.initialState : options.defaultState;\n const [internalState, setInternalState] = React.useState(initialState);\n const state = isControlled ? options.state : internalState;\n const stateRef = React.useRef(state);\n React.useEffect(() => {\n stateRef.current = state;\n }, [state]);\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 => {\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 setInternalState(stateRef.current);\n }, []);\n return [state, setState];\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 => {\n const [isControlled] = React.useState(() => controlledValue !== undefined);\n if (process.env.NODE_ENV !== \"production\") {\n // We don't want these warnings in production even though it is against native behaviour\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (isControlled !== (controlledValue !== undefined)) {\n const error = new Error();\n const controlWarning = isControlled ? \"a controlled value to be uncontrolled\" : \"an uncontrolled value to be controlled\";\n const undefinedWarning = isControlled ? \"defined to an undefined\" : \"undefined to a defined\";\n // eslint-disable-next-line no-console\n console.error([\n // Default react error\n \"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(\" \"));\n }\n }, [isControlled, controlledValue]);\n }\n return isControlled;\n};\n//# sourceMappingURL=useControllableState.js.map"],"names":["useControllableState","isFactoryDispatch","newState","options","isControlled","useIsControlled","state","initialState","defaultState","internalState","setInternalState","React","useState","stateRef","useRef","useEffect","current","setState","useCallback","controlledValue","undefined","process","env","NODE_ENV","error","Error","controlWarning","undefinedWarning","console","stack","join"],"mappings":";;;;+BAoBaA;;aAAAA;;;6DApBU;AACvB,SAASC,kBAAkBC,QAAQ,EAAE;IACnC,OAAO,OAAOA,aAAa;AAC7B;AAiBO,MAAMF,uBAAuBG,CAAAA,UAAW;IAC7C,MAAMC,eAAeC,gBAAgBF,QAAQG,KAAK;IAClD,MAAMC,eAAe,OAAOJ,QAAQK,YAAY,KAAK,cAAcL,QAAQI,YAAY,GAAGJ,QAAQK,YAAY;IAC9G,MAAM,CAACC,eAAeC,iBAAiB,GAAGC,OAAMC,QAAQ,CAACL;IACzD,MAAMD,QAAQF,eAAeD,QAAQG,KAAK,GAAGG,aAAa;IAC1D,MAAMI,WAAWF,OAAMG,MAAM,CAACR;IAC9BK,OAAMI,SAAS,CAAC,IAAM;QACpBF,SAASG,OAAO,GAAGV;IACrB,GAAG;QAACA;KAAM;IACV,2FAA2F;IAC3F,4FAA4F;IAC5F,MAAMW,WAAWN,OAAMO,WAAW,CAAChB,CAAAA,WAAY;QAC7C,mCAAmC;QACnC,mEAAmE;QACnE,IAAID,kBAAkBC,WAAW;YAC/BW,SAASG,OAAO,GAAGd,SAASW,SAASG,OAAO;QAC9C,OAAO;YACLH,SAASG,OAAO,GAAGd;QACrB,CAAC;QACDQ,iBAAiBG,SAASG,OAAO;IACnC,GAAG,EAAE;IACL,OAAO;QAACV;QAAOW;KAAS;AAC1B;AACA;;;;CAIC,GACD,MAAMZ,kBAAkBc,CAAAA,kBAAmB;IACzC,MAAM,CAACf,aAAa,GAAGO,OAAMC,QAAQ,CAAC,IAAMO,oBAAoBC;IAChE,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,wFAAwF;QACxF,sDAAsD;QACtDZ,OAAMI,SAAS,CAAC,IAAM;YACpB,IAAIX,iBAAkBe,CAAAA,oBAAoBC,SAAQ,GAAI;gBACpD,MAAMI,QAAQ,IAAIC;gBAClB,MAAMC,iBAAiBtB,eAAe,0CAA0C,wCAAwC;gBACxH,MAAMuB,mBAAmBvB,eAAe,4BAA4B,wBAAwB;gBAC5F,sCAAsC;gBACtCwB,QAAQJ,KAAK,CAAC;oBACd,sBAAsB;oBACtB,6BAA6BE,iBAAiB;oBAAwC,mBAAmBC,mBAAmB;oBAAoC;oBAAsG;oBAA6DH,MAAMK,KAAK;iBAAC,CAACC,IAAI,CAAC;YACvV,CAAC;QACH,GAAG;YAAC1B;YAAce;SAAgB;IACpC,CAAC;IACD,OAAOf;AACT,GACA,gDAAgD"}
|
@@ -1,35 +1,29 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useEventCallback", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>useEventCallback
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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;
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect");
|
12
|
+
const useEventCallback = (fn)=>{
|
13
|
+
const callbackRef = _react.useRef(()=>{
|
14
|
+
throw new Error("Cannot call an event handler while rendering");
|
15
|
+
});
|
16
|
+
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(()=>{
|
17
|
+
callbackRef.current = fn;
|
18
|
+
}, [
|
19
|
+
fn
|
20
|
+
]);
|
21
|
+
return _react.useCallback((...args)=>{
|
22
|
+
const callback = callbackRef.current;
|
23
|
+
return callback(...args);
|
24
|
+
}, [
|
25
|
+
callbackRef
|
26
|
+
]);
|
27
|
+
}; //# sourceMappingURL=useEventCallback.js.map
|
28
|
+
|
35
29
|
//# sourceMappingURL=useEventCallback.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/hooks/useEventCallback.js"],"sourcesContent":["import * as React from \"react\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n/**\n * @internal\n * https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n *\n * Modified `useCallback` that can be used when dependencies change too frequently. Can occur when\n * e.g. user props are dependencies which could change on every render\n * e.g. volatile values (i.e. useState/useDispatch) are dependencies which could change frequently\n *\n * This should not be used often, but can be a useful re-render optimization since the callback is a ref and\n * will not be invalidated between re-renders\n *\n * @param fn - The callback function that will be used\n */\nexport const useEventCallback = fn => {\n const callbackRef = React.useRef(() => {\n throw new Error(\"Cannot call an event handler while rendering\");\n });\n useIsomorphicLayoutEffect(() => {\n callbackRef.current = fn;\n }, [fn]);\n return React.useCallback((...args) => {\n const callback = callbackRef.current;\n return callback(...args);\n }, [callbackRef]);\n};\n//# sourceMappingURL=useEventCallback.js.map"],"names":["useEventCallback","fn","callbackRef","React","useRef","Error","useIsomorphicLayoutEffect","current","useCallback","args","callback"],"mappings":";;;;+BAeaA;;aAAAA;;;6DAfU;2CACmB;AAcnC,MAAMA,mBAAmBC,CAAAA,KAAM;IACpC,MAAMC,cAAcC,OAAMC,MAAM,CAAC,IAAM;QACrC,MAAM,IAAIC,MAAM,gDAAgD;IAClE;IACAC,IAAAA,oDAAyB,EAAC,IAAM;QAC9BJ,YAAYK,OAAO,GAAGN;IACxB,GAAG;QAACA;KAAG;IACP,OAAOE,OAAMK,WAAW,CAAC,CAAC,GAAGC,OAAS;QACpC,MAAMC,WAAWR,YAAYK,OAAO;QACpC,OAAOG,YAAYD;IACrB,GAAG;QAACP;KAAY;AAClB,GACA,4CAA4C"}
|
@@ -1,28 +1,20 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useFirstMount", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>useFirstMount
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
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
|
-
*/
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
19
11
|
function useFirstMount() {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
27
|
-
|
12
|
+
const isFirst = _react.useRef(true);
|
13
|
+
if (isFirst.current) {
|
14
|
+
isFirst.current = false;
|
15
|
+
return true;
|
16
|
+
}
|
17
|
+
return isFirst.current;
|
18
|
+
} //# sourceMappingURL=useFirstMount.js.map
|
19
|
+
|
28
20
|
//# sourceMappingURL=useFirstMount.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/hooks/useFirstMount.js"],"sourcesContent":["import * as React from \"react\";\n/**\n * @internal\n * Checks if components was mounted the first time.\n * Since concurrent mode will be released in the future this needs to be verified\n * Currently (React 17) will always render the initial mount once\n * https://codesandbox.io/s/heuristic-brook-s4w0q?file=/src/App.jsx\n * https://codesandbox.io/s/holy-grass-8nieu?file=/src/App.jsx\n *\n * @example\n * const isFirstMount = useFirstMount();\n */\nexport function useFirstMount() {\n const isFirst = React.useRef(true);\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n return isFirst.current;\n}\n//# sourceMappingURL=useFirstMount.js.map"],"names":["useFirstMount","isFirst","React","useRef","current"],"mappings":";;;;+BAYgBA;;aAAAA;;;6DAZO;AAYhB,SAASA,gBAAgB;IAC9B,MAAMC,UAAUC,OAAMC,MAAM,CAAC,IAAI;IACjC,IAAIF,QAAQG,OAAO,EAAE;QACnBH,QAAQG,OAAO,GAAG,KAAK;QACvB,OAAO,IAAI;IACb,CAAC;IACD,OAAOH,QAAQG,OAAO;AACxB,EACA,yCAAyC"}
|
@@ -1,16 +1,14 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useForceUpdate", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>useForceUpdate
|
5
8
|
});
|
6
|
-
|
7
|
-
const react_1 = /*#__PURE__*/require("react");
|
8
|
-
/**
|
9
|
-
* @internal
|
10
|
-
* Forces a re-render, similar to `forceUpdate` in class components.
|
11
|
-
*/
|
9
|
+
const _react = require("react");
|
12
10
|
function useForceUpdate() {
|
13
|
-
|
14
|
-
}
|
15
|
-
|
11
|
+
return (0, _react.useReducer)((x)=>x + 1, 0)[1];
|
12
|
+
} //# sourceMappingURL=useForceUpdate.js.map
|
13
|
+
|
16
14
|
//# sourceMappingURL=useForceUpdate.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/hooks/useForceUpdate.js"],"sourcesContent":["import { useReducer } from \"react\";\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//# sourceMappingURL=useForceUpdate.js.map"],"names":["useForceUpdate","useReducer","x"],"mappings":";;;;+BAKgBA;;aAAAA;;uBALW;AAKpB,SAASA,iBAAiB;IAC/B,OAAOC,IAAAA,iBAAU,EAACC,CAAAA,IAAKA,IAAI,GAAG,EAAE,CAAC,EAAE;AACrC,EACA,0CAA0C"}
|
@@ -1,56 +1,57 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
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
|
5
15
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const IdPrefixContext = /*#__PURE__*/
|
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;
|
16
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
17
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
18
|
+
const _index = require("../ssr/index");
|
19
|
+
const IdPrefixContext = /*#__PURE__*/ _react.createContext(undefined);
|
20
|
+
const IdPrefixProvider = IdPrefixContext.Provider;
|
15
21
|
function useIdPrefix() {
|
16
|
-
|
22
|
+
return _react.useContext(IdPrefixContext) || "";
|
17
23
|
}
|
18
|
-
/**
|
19
|
-
* Resets generated IDs, should be used only in tests.
|
20
|
-
*/
|
21
24
|
function resetIdsForTests() {
|
22
|
-
|
25
|
+
_index.defaultSSRContextValue.current = 0;
|
23
26
|
}
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
// prevent bundlers from complaining with older versions of React.
|
38
|
-
const _useId = React['use' + 'Id'];
|
39
|
-
if (_useId) {
|
40
|
-
const generatedId = _useId();
|
41
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
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;
|
27
|
+
function useId(prefix = "fui-", providedId) {
|
28
|
+
const contextValue = (0, _index.useSSRContext)();
|
29
|
+
const idPrefix = useIdPrefix();
|
30
|
+
// Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to
|
31
|
+
// prevent bundlers from complaining with older versions of React.
|
32
|
+
const _useId = _react["use" + "Id"];
|
33
|
+
if (_useId) {
|
34
|
+
const generatedId = _useId();
|
35
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
36
|
+
const escapedId = _react.useMemo(()=>generatedId.replace(/:/g, ""), [
|
37
|
+
generatedId
|
38
|
+
]);
|
39
|
+
return providedId || `${idPrefix}${prefix}${escapedId}`;
|
51
40
|
}
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
41
|
+
// Hooks appear to be running conditionally, but they will always run in the same order since it's based on
|
42
|
+
// the version of React being used. This is safe to ignore.
|
43
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
44
|
+
return _react.useMemo(()=>{
|
45
|
+
if (providedId) {
|
46
|
+
return providedId;
|
47
|
+
}
|
48
|
+
return `${idPrefix}${prefix}${++contextValue.current}`;
|
49
|
+
}, [
|
50
|
+
idPrefix,
|
51
|
+
prefix,
|
52
|
+
providedId,
|
53
|
+
contextValue
|
54
|
+
]);
|
55
|
+
} //# sourceMappingURL=useId.js.map
|
56
|
+
|
56
57
|
//# sourceMappingURL=useId.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/hooks/useId.js"],"sourcesContent":["import * as React from \"react\";\nimport { defaultSSRContextValue, useSSRContext } from \"../ssr/index\";\nconst IdPrefixContext = /*#__PURE__*/React.createContext(undefined);\n/**\n * Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions\n * between different bundles.\n */\nexport const IdPrefixProvider = IdPrefixContext.Provider;\nfunction useIdPrefix() {\n return React.useContext(IdPrefixContext) || \"\";\n}\n/**\n * Resets generated IDs, should be used only in tests.\n */\nexport function resetIdsForTests() {\n defaultSSRContextValue.current = 0;\n}\n/**\n * Hook to generate a unique ID.\n *\n * @param prefix - Optional prefix for the ID. Defaults to 'fui-'.\n * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,\n * without conditioning the hook call\n * @returns The ID\n */\nexport function useId(prefix = \"fui-\", providedId) {\n const contextValue = useSSRContext();\n const idPrefix = useIdPrefix();\n // Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to\n // prevent bundlers from complaining with older versions of React.\n const _useId = React[\"use\" + \"Id\"];\n if (_useId) {\n const generatedId = _useId();\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const escapedId = React.useMemo(() => generatedId.replace(/:/g, \"\"), [generatedId]);\n return providedId || `${idPrefix}${prefix}${escapedId}`;\n }\n // Hooks appear to be running conditionally, but they will always run in the same order since it's based on\n // the version of React being used. This is safe to ignore.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return React.useMemo(() => {\n if (providedId) {\n return providedId;\n }\n return `${idPrefix}${prefix}${++contextValue.current}`;\n }, [idPrefix, prefix, providedId, contextValue]);\n}\n//# sourceMappingURL=useId.js.map"],"names":["IdPrefixProvider","resetIdsForTests","useId","IdPrefixContext","React","createContext","undefined","Provider","useIdPrefix","useContext","defaultSSRContextValue","current","prefix","providedId","contextValue","useSSRContext","idPrefix","_useId","generatedId","escapedId","useMemo","replace"],"mappings":";;;;;;;;;;;IAOaA,gBAAgB,MAAhBA;IAOGC,gBAAgB,MAAhBA;IAWAC,KAAK,MAALA;;;6DAzBO;uBAC+B;AACtD,MAAMC,kBAAkB,WAAW,GAAEC,OAAMC,aAAa,CAACC;AAKlD,MAAMN,mBAAmBG,gBAAgBI,QAAQ;AACxD,SAASC,cAAc;IACrB,OAAOJ,OAAMK,UAAU,CAACN,oBAAoB;AAC9C;AAIO,SAASF,mBAAmB;IACjCS,6BAAsB,CAACC,OAAO,GAAG;AACnC;AASO,SAAST,MAAMU,SAAS,MAAM,EAAEC,UAAU,EAAE;IACjD,MAAMC,eAAeC,IAAAA,oBAAa;IAClC,MAAMC,WAAWR;IACjB,mHAAmH;IACnH,kEAAkE;IAClE,MAAMS,SAASb,MAAK,CAAC,QAAQ,KAAK;IAClC,IAAIa,QAAQ;QACV,MAAMC,cAAcD;QACpB,sDAAsD;QACtD,MAAME,YAAYf,OAAMgB,OAAO,CAAC,IAAMF,YAAYG,OAAO,CAAC,MAAM,KAAK;YAACH;SAAY;QAClF,OAAOL,cAAc,CAAC,EAAEG,SAAS,EAAEJ,OAAO,EAAEO,UAAU,CAAC;IACzD,CAAC;IACD,2GAA2G;IAC3G,2DAA2D;IAC3D,sDAAsD;IACtD,OAAOf,OAAMgB,OAAO,CAAC,IAAM;QACzB,IAAIP,YAAY;YACd,OAAOA;QACT,CAAC;QACD,OAAO,CAAC,EAAEG,SAAS,EAAEJ,OAAO,EAAE,EAAEE,aAAaH,OAAO,CAAC,CAAC;IACxD,GAAG;QAACK;QAAUJ;QAAQC;QAAYC;KAAa;AACjD,EACA,iCAAiC"}
|
@@ -1,20 +1,14 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useIsomorphicLayoutEffect", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>useIsomorphicLayoutEffect
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
|
10
|
-
|
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;
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _index = require("../ssr/index");
|
12
|
+
const useIsomorphicLayoutEffect = /*#__PURE__*/ (0, _index.canUseDOM)() ? _react.useLayoutEffect : _react.useEffect; //# sourceMappingURL=useIsomorphicLayoutEffect.js.map
|
13
|
+
|
20
14
|
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../lib/hooks/useIsomorphicLayoutEffect.js"],"sourcesContent":["import * as React from \"react\";\nimport { canUseDOM } from \"../ssr/index\";\n/**\n * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally\n * useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to\n * ensure we don't get a render flash for certain operations, but we may also need affected components to render on\n * the server.\n *\n * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\n * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js\n */ // eslint-disable-next-line no-restricted-properties\nexport const useIsomorphicLayoutEffect = /*#__PURE__*/canUseDOM() ? React.useLayoutEffect : React.useEffect;\n//# sourceMappingURL=useIsomorphicLayoutEffect.js.map"],"names":["useIsomorphicLayoutEffect","canUseDOM","React","useLayoutEffect","useEffect"],"mappings":";;;;+BAWaA;;aAAAA;;;6DAXU;uBACG;AAUnB,MAAMA,4BAA4B,WAAW,GAAEC,IAAAA,gBAAS,MAAKC,OAAMC,eAAe,GAAGD,OAAME,SAAS,EAC3G,qDAAqD"}
|