@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.
Files changed (160) hide show
  1. package/.swcrc +39 -0
  2. package/CHANGELOG.json +5 -5
  3. package/CHANGELOG.md +5 -5
  4. package/lib/compose/getSlots.js +6 -7
  5. package/lib/compose/getSlots.js.map +1 -1
  6. package/lib/compose/index.js +4 -4
  7. package/lib/compose/index.js.map +1 -1
  8. package/lib/compose/isResolvedShorthand.js +2 -2
  9. package/lib/compose/isResolvedShorthand.js.map +1 -1
  10. package/lib/compose/resolveShorthand.js +3 -3
  11. package/lib/compose/resolveShorthand.js.map +1 -1
  12. package/lib/compose/types.js +1 -1
  13. package/lib/compose/types.js.map +1 -1
  14. package/lib/events/index.js +1 -1
  15. package/lib/events/index.js.map +1 -1
  16. package/lib/events/mouseTouchHelpers.js +5 -4
  17. package/lib/events/mouseTouchHelpers.js.map +1 -1
  18. package/lib/hooks/index.js +12 -12
  19. package/lib/hooks/index.js.map +1 -1
  20. package/lib/hooks/useControllableState.js +7 -7
  21. package/lib/hooks/useControllableState.js.map +1 -1
  22. package/lib/hooks/useEventCallback.js +3 -3
  23. package/lib/hooks/useEventCallback.js.map +1 -1
  24. package/lib/hooks/useFirstMount.js +1 -1
  25. package/lib/hooks/useFirstMount.js.map +1 -1
  26. package/lib/hooks/useForceUpdate.js +1 -1
  27. package/lib/hooks/useForceUpdate.js.map +1 -1
  28. package/lib/hooks/useId.js +6 -6
  29. package/lib/hooks/useId.js.map +1 -1
  30. package/lib/hooks/useIsomorphicLayoutEffect.js +3 -4
  31. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  32. package/lib/hooks/useMergedRefs.js +2 -2
  33. package/lib/hooks/useMergedRefs.js.map +1 -1
  34. package/lib/hooks/useOnClickOutside.js +20 -23
  35. package/lib/hooks/useOnClickOutside.js.map +1 -1
  36. package/lib/hooks/useOnScrollOutside.js +7 -7
  37. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  38. package/lib/hooks/usePrevious.js +1 -1
  39. package/lib/hooks/usePrevious.js.map +1 -1
  40. package/lib/hooks/useScrollbarWidth.js +5 -5
  41. package/lib/hooks/useScrollbarWidth.js.map +1 -1
  42. package/lib/hooks/useTimeout.js +1 -1
  43. package/lib/hooks/useTimeout.js.map +1 -1
  44. package/lib/index.js +6 -6
  45. package/lib/index.js.map +1 -1
  46. package/lib/ssr/SSRContext.js +5 -6
  47. package/lib/ssr/SSRContext.js.map +1 -1
  48. package/lib/ssr/canUseDOM.js +2 -3
  49. package/lib/ssr/canUseDOM.js.map +1 -1
  50. package/lib/ssr/index.js +2 -2
  51. package/lib/ssr/index.js.map +1 -1
  52. package/lib/trigger/applyTriggerPropsToChildren.js +4 -4
  53. package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
  54. package/lib/trigger/getTriggerChild.js +2 -2
  55. package/lib/trigger/getTriggerChild.js.map +1 -1
  56. package/lib/trigger/index.js +4 -4
  57. package/lib/trigger/index.js.map +1 -1
  58. package/lib/trigger/isFluentTrigger.js +1 -0
  59. package/lib/trigger/isFluentTrigger.js.map +1 -1
  60. package/lib/trigger/types.js +1 -1
  61. package/lib/trigger/types.js.map +1 -1
  62. package/lib/utils/clamp.js +1 -2
  63. package/lib/utils/clamp.js.map +1 -1
  64. package/lib/utils/getNativeElementProps.js +4 -4
  65. package/lib/utils/getNativeElementProps.js.map +1 -1
  66. package/lib/utils/getRTLSafeKey.js +6 -7
  67. package/lib/utils/getRTLSafeKey.js.map +1 -1
  68. package/lib/utils/getReactCallbackName.js +3 -2
  69. package/lib/utils/getReactCallbackName.js.map +1 -1
  70. package/lib/utils/index.js +8 -8
  71. package/lib/utils/index.js.map +1 -1
  72. package/lib/utils/isHTMLElement.js +2 -4
  73. package/lib/utils/isHTMLElement.js.map +1 -1
  74. package/lib/utils/isInteractiveHTMLElement.js +5 -5
  75. package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
  76. package/lib/utils/mergeCallbacks.js +3 -4
  77. package/lib/utils/mergeCallbacks.js.map +1 -1
  78. package/lib/utils/omit.js +1 -2
  79. package/lib/utils/omit.js.map +1 -1
  80. package/lib/utils/properties.js +28 -55
  81. package/lib/utils/properties.js.map +1 -1
  82. package/lib-commonjs/compose/getSlots.js +47 -55
  83. package/lib-commonjs/compose/getSlots.js.map +1 -1
  84. package/lib-commonjs/compose/index.js +8 -7
  85. package/lib-commonjs/compose/index.js.map +1 -1
  86. package/lib-commonjs/compose/isResolvedShorthand.js +9 -37
  87. package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
  88. package/lib-commonjs/compose/resolveShorthand.js +25 -32
  89. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  90. package/lib-commonjs/compose/types.js +5 -2
  91. package/lib-commonjs/compose/types.js.map +1 -1
  92. package/lib-commonjs/events/index.js +5 -4
  93. package/lib-commonjs/events/index.js.map +1 -1
  94. package/lib-commonjs/events/mouseTouchHelpers.js +40 -37
  95. package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
  96. package/lib-commonjs/hooks/index.js +16 -15
  97. package/lib-commonjs/hooks/index.js.map +1 -1
  98. package/lib-commonjs/hooks/useControllableState.js +63 -64
  99. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  100. package/lib-commonjs/hooks/useEventCallback.js +25 -31
  101. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  102. package/lib-commonjs/hooks/useFirstMount.js +15 -23
  103. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  104. package/lib-commonjs/hooks/useForceUpdate.js +9 -11
  105. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  106. package/lib-commonjs/hooks/useId.js +48 -47
  107. package/lib-commonjs/hooks/useId.js.map +1 -1
  108. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +10 -16
  109. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  110. package/lib-commonjs/hooks/useMergedRefs.js +25 -27
  111. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  112. package/lib-commonjs/hooks/useOnClickOutside.js +109 -115
  113. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  114. package/lib-commonjs/hooks/useOnScrollOutside.js +33 -36
  115. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  116. package/lib-commonjs/hooks/usePrevious.js +17 -15
  117. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  118. package/lib-commonjs/hooks/useScrollbarWidth.js +32 -32
  119. package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
  120. package/lib-commonjs/hooks/useTimeout.js +30 -30
  121. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  122. package/lib-commonjs/index.js +52 -214
  123. package/lib-commonjs/index.js.map +1 -1
  124. package/lib-commonjs/ssr/SSRContext.js +56 -59
  125. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  126. package/lib-commonjs/ssr/canUseDOM.js +12 -12
  127. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  128. package/lib-commonjs/ssr/index.js +6 -5
  129. package/lib-commonjs/ssr/index.js.map +1 -1
  130. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js +29 -31
  131. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
  132. package/lib-commonjs/trigger/getTriggerChild.js +16 -36
  133. package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
  134. package/lib-commonjs/trigger/index.js +8 -7
  135. package/lib-commonjs/trigger/index.js.map +1 -1
  136. package/lib-commonjs/trigger/isFluentTrigger.js +10 -11
  137. package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
  138. package/lib-commonjs/trigger/types.js +5 -2
  139. package/lib-commonjs/trigger/types.js.map +1 -1
  140. package/lib-commonjs/utils/clamp.js +10 -9
  141. package/lib-commonjs/utils/clamp.js.map +1 -1
  142. package/lib-commonjs/utils/getNativeElementProps.js +54 -61
  143. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  144. package/lib-commonjs/utils/getRTLSafeKey.js +22 -21
  145. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  146. package/lib-commonjs/utils/getReactCallbackName.js +24 -24
  147. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
  148. package/lib-commonjs/utils/index.js +12 -11
  149. package/lib-commonjs/utils/index.js.map +1 -1
  150. package/lib-commonjs/utils/isHTMLElement.js +12 -12
  151. package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
  152. package/lib-commonjs/utils/isInteractiveHTMLElement.js +20 -24
  153. package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
  154. package/lib-commonjs/utils/mergeCallbacks.js +14 -13
  155. package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
  156. package/lib-commonjs/utils/omit.js +18 -17
  157. package/lib-commonjs/utils/omit.js.map +1 -1
  158. package/lib-commonjs/utils/properties.js +327 -223
  159. package/lib-commonjs/utils/properties.js.map +1 -1
  160. package/package.json +4 -4
@@ -1,19 +1,20 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
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);
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,"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
+ {"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
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useControllableState", {
6
+ enumerable: true,
7
+ get: ()=>useControllableState
5
8
  });
6
- exports.useControllableState = void 0;
7
- const React = /*#__PURE__*/require("react");
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
- return typeof newState === 'function';
12
+ return typeof newState === "function";
10
13
  }
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];
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 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
- };
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,"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
+ {"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
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useEventCallback", {
6
+ enumerable: true,
7
+ get: ()=>useEventCallback
5
8
  });
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;
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,"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
+ {"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
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useFirstMount", {
6
+ enumerable: true,
7
+ get: ()=>useFirstMount
5
8
  });
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
- */
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
19
11
  function useFirstMount() {
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;
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,"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
+ {"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
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useForceUpdate", {
6
+ enumerable: true,
7
+ get: ()=>useForceUpdate
5
8
  });
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
- */
9
+ const _react = require("react");
12
10
  function useForceUpdate() {
13
- return react_1.useReducer(x => x + 1, 0)[1];
14
- }
15
- exports.useForceUpdate = useForceUpdate;
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,"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
+ {"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
- value: true
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
- 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;
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
- return React.useContext(IdPrefixContext) || '';
22
+ return _react.useContext(IdPrefixContext) || "";
17
23
  }
18
- /**
19
- * Resets generated IDs, should be used only in tests.
20
- */
21
24
  function resetIdsForTests() {
22
- index_1.defaultSSRContextValue.current = 0;
25
+ _index.defaultSSRContextValue.current = 0;
23
26
  }
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();
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
- return `${idPrefix}${prefix}${++contextValue.current}`;
53
- }, [idPrefix, prefix, providedId, contextValue]);
54
- }
55
- exports.useId = useId;
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,"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
+ {"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
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useIsomorphicLayoutEffect", {
6
+ enumerable: true,
7
+ get: ()=>useIsomorphicLayoutEffect
5
8
  });
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;
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,"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"}
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"}