@fluentui/react-utilities 9.18.8 → 9.18.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,31 @@
1
1
  # Change Log - @fluentui/react-utilities
2
2
 
3
- This log was last generated on Mon, 06 May 2024 12:48:54 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 06 Jun 2024 15:22:25 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.18.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.18.10)
8
+
9
+ Thu, 06 Jun 2024 15:22:25 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.18.9..@fluentui/react-utilities_v9.18.10)
11
+
12
+ ### Patches
13
+
14
+ - chore: useControllableState warns if controlled and uncontrolled at the same time ([PR #31461](https://github.com/microsoft/fluentui/pull/31461) by bernardo.sunderhus@gmail.com)
15
+ - fix: use globals from Fluent context. ([PR #30967](https://github.com/microsoft/fluentui/pull/30967) by seanmonahan@microsoft.com)
16
+
17
+ ## [9.18.9](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.18.9)
18
+
19
+ Mon, 20 May 2024 12:45:09 GMT
20
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.18.8..@fluentui/react-utilities_v9.18.9)
21
+
22
+ ### Patches
23
+
24
+ - Bump @fluentui/react-shared-contexts to v9.19.0 ([PR #26682](https://github.com/microsoft/fluentui/pull/26682) by beachball)
25
+
7
26
  ## [9.18.8](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.18.8)
8
27
 
9
- Mon, 06 May 2024 12:48:54 GMT
28
+ Mon, 06 May 2024 12:55:02 GMT
10
29
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.18.7..@fluentui/react-utilities_v9.18.8)
11
30
 
12
31
  ### Patches
@@ -1,5 +1,5 @@
1
- import { canUseDOM } from '../ssr/canUseDOM';
2
1
  import { useBrowserTimer } from './useBrowserTimer';
2
+ import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
3
3
  const setAnimationFrameNoop = (callback)=>{
4
4
  callback(0);
5
5
  return 0;
@@ -13,9 +13,9 @@ const cancelAnimationFrameNoop = (handle)=>handle;
13
13
  *
14
14
  * @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.
15
15
  */ export function useAnimationFrame() {
16
- const isDOM = canUseDOM();
17
- // TODO: figure it out a way to not call global.requestAnimationFrame and instead infer window from some context
18
- const setAnimationFrame = isDOM ? requestAnimationFrame : setAnimationFrameNoop;
19
- const clearAnimationFrame = isDOM ? cancelAnimationFrame : cancelAnimationFrameNoop;
16
+ const { targetDocument } = useFluent();
17
+ const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
18
+ const setAnimationFrame = win ? win.requestAnimationFrame : setAnimationFrameNoop;
19
+ const clearAnimationFrame = win ? win.cancelAnimationFrame : cancelAnimationFrameNoop;
20
20
  return useBrowserTimer(setAnimationFrame, clearAnimationFrame);
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["useAnimationFrame.ts"],"sourcesContent":["import { canUseDOM } from '../ssr/canUseDOM';\nimport { useBrowserTimer } from './useBrowserTimer';\n\nconst setAnimationFrameNoop = (callback: FrameRequestCallback) => {\n callback(0);\n return 0;\n};\nconst cancelAnimationFrameNoop = (handle: number) => handle;\n\n/**\n * @internal\n * Helper to manage a browser requestAnimationFrame.\n * Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.\n */\nexport function useAnimationFrame() {\n const isDOM = canUseDOM();\n\n // TODO: figure it out a way to not call global.requestAnimationFrame and instead infer window from some context\n const setAnimationFrame = isDOM ? requestAnimationFrame : setAnimationFrameNoop;\n const clearAnimationFrame = isDOM ? cancelAnimationFrame : cancelAnimationFrameNoop;\n\n return useBrowserTimer(setAnimationFrame, clearAnimationFrame);\n}\n"],"names":["canUseDOM","useBrowserTimer","setAnimationFrameNoop","callback","cancelAnimationFrameNoop","handle","useAnimationFrame","isDOM","setAnimationFrame","requestAnimationFrame","clearAnimationFrame","cancelAnimationFrame"],"mappings":"AAAA,SAASA,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,eAAe,QAAQ,oBAAoB;AAEpD,MAAMC,wBAAwB,CAACC;IAC7BA,SAAS;IACT,OAAO;AACT;AACA,MAAMC,2BAA2B,CAACC,SAAmBA;AAErD;;;;;;;CAOC,GACD,OAAO,SAASC;IACd,MAAMC,QAAQP;IAEd,gHAAgH;IAChH,MAAMQ,oBAAoBD,QAAQE,wBAAwBP;IAC1D,MAAMQ,sBAAsBH,QAAQI,uBAAuBP;IAE3D,OAAOH,gBAAgBO,mBAAmBE;AAC5C"}
1
+ {"version":3,"sources":["useAnimationFrame.ts"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nconst setAnimationFrameNoop = (callback: FrameRequestCallback) => {\n callback(0);\n return 0;\n};\nconst cancelAnimationFrameNoop = (handle: number) => handle;\n\n/**\n * @internal\n * Helper to manage a browser requestAnimationFrame.\n * Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.\n */\nexport function useAnimationFrame() {\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n\n const setAnimationFrame = win ? win.requestAnimationFrame : setAnimationFrameNoop;\n const clearAnimationFrame = win ? win.cancelAnimationFrame : cancelAnimationFrameNoop;\n\n return useBrowserTimer(setAnimationFrame, clearAnimationFrame);\n}\n"],"names":["useBrowserTimer","useFluent_unstable","useFluent","setAnimationFrameNoop","callback","cancelAnimationFrameNoop","handle","useAnimationFrame","targetDocument","win","defaultView","setAnimationFrame","requestAnimationFrame","clearAnimationFrame","cancelAnimationFrame"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AACpD,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF,MAAMC,wBAAwB,CAACC;IAC7BA,SAAS;IACT,OAAO;AACT;AACA,MAAMC,2BAA2B,CAACC,SAAmBA;AAErD;;;;;;;CAOC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,cAAc,EAAE,GAAGN;IAC3B,MAAMO,MAAMD,2BAAAA,qCAAAA,eAAgBE,WAAW;IAEvC,MAAMC,oBAAoBF,MAAMA,IAAIG,qBAAqB,GAAGT;IAC5D,MAAMU,sBAAsBJ,MAAMA,IAAIK,oBAAoB,GAAGT;IAE7D,OAAOL,gBAAgBW,mBAAmBE;AAC5C"}
@@ -19,6 +19,16 @@ function isFactoryDispatch(newState) {
19
19
  * Meaning that if a state is `controlled`, calls to the dispatcher do not modify the state.
20
20
  *
21
21
  */ export const useControllableState = (options)=>{
22
+ if (process.env.NODE_ENV !== 'production') {
23
+ if (options.state !== undefined && options.defaultState !== undefined) {
24
+ // eslint-disable-next-line no-console
25
+ console.error(`@fluentui/react-utilities [useControllableState]:
26
+ A component must be either controlled or uncontrolled (specify either the state or the defaultState, but not both).
27
+ Decide between using a controlled or uncontrolled component and remove one of this props.
28
+ More info: https://reactjs.org/link/controlled-components
29
+ ${new Error().stack}`);
30
+ }
31
+ }
22
32
  const [internalState, setInternalState] = React.useState(()=>{
23
33
  if (options.defaultState === undefined) {
24
34
  return options.initialState;
@@ -64,7 +74,7 @@ function isInitializer(value) {
64
74
  const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';
65
75
  const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';
66
76
  // eslint-disable-next-line no-console
67
- console.error(`@fluentui/react-utilities [${useControllableState.name}]:
77
+ console.error(`@fluentui/react-utilities [useControllableState]:
68
78
  A component is changing ${controlWarning}. This is likely caused by the value changing from ${undefinedWarning} value, which should not happen.
69
79
  Decide between using a controlled or uncontrolled input element for the lifetime of the component.
70
80
  More info: https://reactjs.org/link/controlled-components
@@ -1 +1 @@
1
- {"version":3,"sources":["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`](https://reactjs.org/docs/hooks-reference.html#usestate)-like hook\n * to manage a value that could be either `controlled` or `uncontrolled`,\n * such as a checked state or text input string.\n *\n * @see https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components for more details on `controlled`/`uncontrolled`\n *\n * @returns an array of the current value and an updater (dispatcher) function.\n * The updater function is referentially stable (won't change during the component's lifecycle).\n * It can take either a new value, or a function which is passed the previous value and returns the new value.\n *\n * ❗️❗️ Calls to the dispatcher will only modify the state if the state is `uncontrolled`.\n * Meaning that if a state is `controlled`, calls to the dispatcher do not modify the state.\n *\n */\nexport const useControllableState = <State>(\n options: UseControllableStateOptions<State>,\n): [State, React.Dispatch<React.SetStateAction<State>>] => {\n const [internalState, setInternalState] = React.useState<State>(() => {\n if (options.defaultState === undefined) {\n return options.initialState;\n }\n return isInitializer(options.defaultState) ? options.defaultState() : options.defaultState;\n });\n\n // Heads up!\n // This part is specific for controlled mode and mocks behavior of React dispatcher function.\n\n const stateValueRef = React.useRef<State | undefined>(options.state);\n\n React.useEffect(() => {\n stateValueRef.current = options.state;\n }, [options.state]);\n\n const setControlledState = React.useCallback((newState: React.SetStateAction<State>) => {\n if (isFactoryDispatch(newState)) {\n newState(stateValueRef.current as State);\n }\n }, []);\n\n return useIsControlled(options.state) ? [options.state, setControlledState] : [internalState, setInternalState];\n};\n\nfunction isInitializer<State>(value: State | (() => State)): value is () => State {\n return typeof value === 'function';\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 = <V>(controlledValue: V | undefined): controlledValue is V => {\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(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [${useControllableState.name}]:\n A component is changing ${controlWarning}. This is likely caused by the value 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 `);\n }\n }, [isControlled, controlledValue]);\n }\n\n return isControlled;\n};\n"],"names":["React","isFactoryDispatch","newState","useControllableState","options","internalState","setInternalState","useState","defaultState","undefined","initialState","isInitializer","stateValueRef","useRef","state","useEffect","current","setControlledState","useCallback","useIsControlled","value","controlledValue","isControlled","process","env","NODE_ENV","error","Error","controlWarning","undefinedWarning","console","name","stack"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAqB/B,SAASC,kBAAyBC,QAAqC;IACrE,OAAO,OAAOA,aAAa;AAC7B;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,uBAAuB,CAClCC;IAEA,MAAM,CAACC,eAAeC,iBAAiB,GAAGN,MAAMO,QAAQ,CAAQ;QAC9D,IAAIH,QAAQI,YAAY,KAAKC,WAAW;YACtC,OAAOL,QAAQM,YAAY;QAC7B;QACA,OAAOC,cAAcP,QAAQI,YAAY,IAAIJ,QAAQI,YAAY,KAAKJ,QAAQI,YAAY;IAC5F;IAEA,YAAY;IACZ,6FAA6F;IAE7F,MAAMI,gBAAgBZ,MAAMa,MAAM,CAAoBT,QAAQU,KAAK;IAEnEd,MAAMe,SAAS,CAAC;QACdH,cAAcI,OAAO,GAAGZ,QAAQU,KAAK;IACvC,GAAG;QAACV,QAAQU,KAAK;KAAC;IAElB,MAAMG,qBAAqBjB,MAAMkB,WAAW,CAAC,CAAChB;QAC5C,IAAID,kBAAkBC,WAAW;YAC/BA,SAASU,cAAcI,OAAO;QAChC;IACF,GAAG,EAAE;IAEL,OAAOG,gBAAgBf,QAAQU,KAAK,IAAI;QAACV,QAAQU,KAAK;QAAEG;KAAmB,GAAG;QAACZ;QAAeC;KAAiB;AACjH,EAAE;AAEF,SAASK,cAAqBS,KAA4B;IACxD,OAAO,OAAOA,UAAU;AAC1B;AAEA;;;;CAIC,GACD,MAAMD,kBAAkB,CAAIE;IAC1B,MAAM,CAACC,aAAa,GAAGtB,MAAMO,QAAQ,CAAU,IAAMc,oBAAoBZ;IAEzE,IAAIc,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,wFAAwF;QACxF,sDAAsD;QACtDzB,MAAMe,SAAS,CAAC;YACd,IAAIO,iBAAkBD,CAAAA,oBAAoBZ,SAAQ,GAAI;gBACpD,MAAMiB,QAAQ,IAAIC;gBAElB,MAAMC,iBAAiBN,eACnB,0CACA;gBAEJ,MAAMO,mBAAmBP,eAAe,4BAA4B;gBAEpE,sCAAsC;gBACtCQ,QAAQJ,KAAK,CAAuB,CAAC,2BACR,EAAEvB,qBAAqB4B,IAAI,CAAC;wBAC/B,EAAEH,eAAe,mDAAmD,EAAEC,iBAAiB;;;AAG/G,EAAEH,MAAMM,KAAK,CAAC,AAChB,CAAC;YACH;QACF,GAAG;YAACV;YAAcD;SAAgB;IACpC;IAEA,OAAOC;AACT"}
1
+ {"version":3,"sources":["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`](https://reactjs.org/docs/hooks-reference.html#usestate)-like hook\n * to manage a value that could be either `controlled` or `uncontrolled`,\n * such as a checked state or text input string.\n *\n * @see https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components for more details on `controlled`/`uncontrolled`\n *\n * @returns an array of the current value and an updater (dispatcher) function.\n * The updater function is referentially stable (won't change during the component's lifecycle).\n * It can take either a new value, or a function which is passed the previous value and returns the new value.\n *\n * ❗️❗️ Calls to the dispatcher will only modify the state if the state is `uncontrolled`.\n * Meaning that if a state is `controlled`, calls to the dispatcher do not modify the state.\n *\n */\nexport const useControllableState = <State>(\n options: UseControllableStateOptions<State>,\n): [State, React.Dispatch<React.SetStateAction<State>>] => {\n if (process.env.NODE_ENV !== 'production') {\n if (options.state !== undefined && options.defaultState !== undefined) {\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [useControllableState]:\n A component must be either controlled or uncontrolled (specify either the state or the defaultState, but not both).\n Decide between using a controlled or uncontrolled component and remove one of this props.\n More info: https://reactjs.org/link/controlled-components\n ${new Error().stack}\n `);\n }\n }\n const [internalState, setInternalState] = React.useState<State>(() => {\n if (options.defaultState === undefined) {\n return options.initialState;\n }\n return isInitializer(options.defaultState) ? options.defaultState() : options.defaultState;\n });\n\n // Heads up!\n // This part is specific for controlled mode and mocks behavior of React dispatcher function.\n\n const stateValueRef = React.useRef<State | undefined>(options.state);\n\n React.useEffect(() => {\n stateValueRef.current = options.state;\n }, [options.state]);\n\n const setControlledState = React.useCallback((newState: React.SetStateAction<State>) => {\n if (isFactoryDispatch(newState)) {\n newState(stateValueRef.current as State);\n }\n }, []);\n\n return useIsControlled(options.state) ? [options.state, setControlledState] : [internalState, setInternalState];\n};\n\nfunction isInitializer<State>(value: State | (() => State)): value is () => State {\n return typeof value === 'function';\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 = <V>(controlledValue: V | undefined): controlledValue is V => {\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(/** #__DE-INDENT__ */ `\n @fluentui/react-utilities [useControllableState]:\n A component is changing ${controlWarning}. This is likely caused by the value 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 `);\n }\n }, [isControlled, controlledValue]);\n }\n\n return isControlled;\n};\n"],"names":["React","isFactoryDispatch","newState","useControllableState","options","process","env","NODE_ENV","state","undefined","defaultState","console","error","Error","stack","internalState","setInternalState","useState","initialState","isInitializer","stateValueRef","useRef","useEffect","current","setControlledState","useCallback","useIsControlled","value","controlledValue","isControlled","controlWarning","undefinedWarning"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAqB/B,SAASC,kBAAyBC,QAAqC;IACrE,OAAO,OAAOA,aAAa;AAC7B;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,uBAAuB,CAClCC;IAEA,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAIH,QAAQI,KAAK,KAAKC,aAAaL,QAAQM,YAAY,KAAKD,WAAW;YACrE,sCAAsC;YACtCE,QAAQC,KAAK,CAAuB,CAAC;;;;AAKrC,EAAE,IAAIC,QAAQC,KAAK,CAAC,AACtB,CAAC;QACD;IACF;IACA,MAAM,CAACC,eAAeC,iBAAiB,GAAGhB,MAAMiB,QAAQ,CAAQ;QAC9D,IAAIb,QAAQM,YAAY,KAAKD,WAAW;YACtC,OAAOL,QAAQc,YAAY;QAC7B;QACA,OAAOC,cAAcf,QAAQM,YAAY,IAAIN,QAAQM,YAAY,KAAKN,QAAQM,YAAY;IAC5F;IAEA,YAAY;IACZ,6FAA6F;IAE7F,MAAMU,gBAAgBpB,MAAMqB,MAAM,CAAoBjB,QAAQI,KAAK;IAEnER,MAAMsB,SAAS,CAAC;QACdF,cAAcG,OAAO,GAAGnB,QAAQI,KAAK;IACvC,GAAG;QAACJ,QAAQI,KAAK;KAAC;IAElB,MAAMgB,qBAAqBxB,MAAMyB,WAAW,CAAC,CAACvB;QAC5C,IAAID,kBAAkBC,WAAW;YAC/BA,SAASkB,cAAcG,OAAO;QAChC;IACF,GAAG,EAAE;IAEL,OAAOG,gBAAgBtB,QAAQI,KAAK,IAAI;QAACJ,QAAQI,KAAK;QAAEgB;KAAmB,GAAG;QAACT;QAAeC;KAAiB;AACjH,EAAE;AAEF,SAASG,cAAqBQ,KAA4B;IACxD,OAAO,OAAOA,UAAU;AAC1B;AAEA;;;;CAIC,GACD,MAAMD,kBAAkB,CAAIE;IAC1B,MAAM,CAACC,aAAa,GAAG7B,MAAMiB,QAAQ,CAAU,IAAMW,oBAAoBnB;IAEzE,IAAIJ,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,wFAAwF;QACxF,sDAAsD;QACtDP,MAAMsB,SAAS,CAAC;YACd,IAAIO,iBAAkBD,CAAAA,oBAAoBnB,SAAQ,GAAI;gBACpD,MAAMG,QAAQ,IAAIC;gBAElB,MAAMiB,iBAAiBD,eACnB,0CACA;gBAEJ,MAAME,mBAAmBF,eAAe,4BAA4B;gBAEpE,sCAAsC;gBACtClB,QAAQC,KAAK,CAAuB,CAAC;wBAEX,EAAEkB,eAAe,mDAAmD,EAAEC,iBAAiB;;;AAG/G,EAAEnB,MAAME,KAAK,CAAC,AAChB,CAAC;YACH;QACF,GAAG;YAACe;YAAcD;SAAgB;IACpC;IAEA,OAAOC;AACT"}
@@ -1,4 +1,7 @@
1
1
  import { useBrowserTimer } from './useBrowserTimer';
2
+ import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
3
+ const setTimeoutNoop = (_callback)=>-1;
4
+ const clearTimeoutNoop = (_handle)=>undefined;
2
5
  /**
3
6
  * @internal
4
7
  * Helper to manage a browser timeout.
@@ -7,6 +10,9 @@ import { useBrowserTimer } from './useBrowserTimer';
7
10
  *
8
11
  * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.
9
12
  */ export function useTimeout() {
10
- // TODO: figure it out a way to not call global.setTimeout and instead infer window from some context
11
- return useBrowserTimer(setTimeout, clearTimeout);
13
+ const { targetDocument } = useFluent();
14
+ const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
15
+ const setTimerFn = win ? win.setTimeout : setTimeoutNoop;
16
+ const clearTimerFn = win ? win.clearTimeout : clearTimeoutNoop;
17
+ return useBrowserTimer(setTimerFn, clearTimerFn);
12
18
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["useTimeout.ts"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\n\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */\nexport function useTimeout() {\n // TODO: figure it out a way to not call global.setTimeout and instead infer window from some context\n return useBrowserTimer(setTimeout, clearTimeout);\n}\n"],"names":["useBrowserTimer","useTimeout","setTimeout","clearTimeout"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AAEpD;;;;;;;CAOC,GACD,OAAO,SAASC;IACd,qGAAqG;IACrG,OAAOD,gBAAgBE,YAAYC;AACrC"}
1
+ {"version":3,"sources":["useTimeout.ts"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nconst setTimeoutNoop = (_callback: Function) => -1;\nconst clearTimeoutNoop = (_handle: number) => undefined;\n\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */\nexport function useTimeout() {\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n\n const setTimerFn = win ? win.setTimeout : setTimeoutNoop;\n const clearTimerFn = win ? win.clearTimeout : clearTimeoutNoop;\n\n return useBrowserTimer(setTimerFn, clearTimerFn);\n}\n"],"names":["useBrowserTimer","useFluent_unstable","useFluent","setTimeoutNoop","_callback","clearTimeoutNoop","_handle","undefined","useTimeout","targetDocument","win","defaultView","setTimerFn","setTimeout","clearTimerFn","clearTimeout"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AACpD,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF,MAAMC,iBAAiB,CAACC,YAAwB,CAAC;AACjD,MAAMC,mBAAmB,CAACC,UAAoBC;AAE9C;;;;;;;CAOC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,cAAc,EAAE,GAAGP;IAC3B,MAAMQ,MAAMD,2BAAAA,qCAAAA,eAAgBE,WAAW;IAEvC,MAAMC,aAAaF,MAAMA,IAAIG,UAAU,GAAGV;IAC1C,MAAMW,eAAeJ,MAAMA,IAAIK,YAAY,GAAGV;IAE9C,OAAOL,gBAAgBY,YAAYE;AACrC"}
@@ -8,17 +8,17 @@ Object.defineProperty(exports, "useAnimationFrame", {
8
8
  return useAnimationFrame;
9
9
  }
10
10
  });
11
- const _canUseDOM = require("../ssr/canUseDOM");
12
11
  const _useBrowserTimer = require("./useBrowserTimer");
12
+ const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
13
13
  const setAnimationFrameNoop = (callback)=>{
14
14
  callback(0);
15
15
  return 0;
16
16
  };
17
17
  const cancelAnimationFrameNoop = (handle)=>handle;
18
18
  function useAnimationFrame() {
19
- const isDOM = (0, _canUseDOM.canUseDOM)();
20
- // TODO: figure it out a way to not call global.requestAnimationFrame and instead infer window from some context
21
- const setAnimationFrame = isDOM ? requestAnimationFrame : setAnimationFrameNoop;
22
- const clearAnimationFrame = isDOM ? cancelAnimationFrame : cancelAnimationFrameNoop;
19
+ const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
20
+ const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
21
+ const setAnimationFrame = win ? win.requestAnimationFrame : setAnimationFrameNoop;
22
+ const clearAnimationFrame = win ? win.cancelAnimationFrame : cancelAnimationFrameNoop;
23
23
  return (0, _useBrowserTimer.useBrowserTimer)(setAnimationFrame, clearAnimationFrame);
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["useAnimationFrame.js"],"sourcesContent":["import { canUseDOM } from '../ssr/canUseDOM';\nimport { useBrowserTimer } from './useBrowserTimer';\nconst setAnimationFrameNoop = (callback)=>{\n callback(0);\n return 0;\n};\nconst cancelAnimationFrameNoop = (handle)=>handle;\n/**\n * @internal\n * Helper to manage a browser requestAnimationFrame.\n * Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.\n */ export function useAnimationFrame() {\n const isDOM = canUseDOM();\n // TODO: figure it out a way to not call global.requestAnimationFrame and instead infer window from some context\n const setAnimationFrame = isDOM ? requestAnimationFrame : setAnimationFrameNoop;\n const clearAnimationFrame = isDOM ? cancelAnimationFrame : cancelAnimationFrameNoop;\n return useBrowserTimer(setAnimationFrame, clearAnimationFrame);\n}\n"],"names":["useAnimationFrame","setAnimationFrameNoop","callback","cancelAnimationFrameNoop","handle","isDOM","canUseDOM","setAnimationFrame","requestAnimationFrame","clearAnimationFrame","cancelAnimationFrame","useBrowserTimer"],"mappings":";;;;+BAcoBA;;;eAAAA;;;2BAdM;iCACM;AAChC,MAAMC,wBAAwB,CAACC;IAC3BA,SAAS;IACT,OAAO;AACX;AACA,MAAMC,2BAA2B,CAACC,SAASA;AAQhC,SAASJ;IAChB,MAAMK,QAAQC,IAAAA,oBAAS;IACvB,gHAAgH;IAChH,MAAMC,oBAAoBF,QAAQG,wBAAwBP;IAC1D,MAAMQ,sBAAsBJ,QAAQK,uBAAuBP;IAC3D,OAAOQ,IAAAA,gCAAe,EAACJ,mBAAmBE;AAC9C"}
1
+ {"version":3,"sources":["useAnimationFrame.js"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nconst setAnimationFrameNoop = (callback)=>{\n callback(0);\n return 0;\n};\nconst cancelAnimationFrameNoop = (handle)=>handle;\n/**\n * @internal\n * Helper to manage a browser requestAnimationFrame.\n * Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.\n */ export function useAnimationFrame() {\n const { targetDocument } = useFluent();\n const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;\n const setAnimationFrame = win ? win.requestAnimationFrame : setAnimationFrameNoop;\n const clearAnimationFrame = win ? win.cancelAnimationFrame : cancelAnimationFrameNoop;\n return useBrowserTimer(setAnimationFrame, clearAnimationFrame);\n}\n"],"names":["useAnimationFrame","setAnimationFrameNoop","callback","cancelAnimationFrameNoop","handle","targetDocument","useFluent","win","defaultView","setAnimationFrame","requestAnimationFrame","clearAnimationFrame","cancelAnimationFrame","useBrowserTimer"],"mappings":";;;;+BAcoBA;;;eAAAA;;;iCAdY;qCACgB;AAChD,MAAMC,wBAAwB,CAACC;IAC3BA,SAAS;IACT,OAAO;AACX;AACA,MAAMC,2BAA2B,CAACC,SAASA;AAQhC,SAASJ;IAChB,MAAM,EAAEK,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,MAAMF,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeG,WAAW;IACtG,MAAMC,oBAAoBF,MAAMA,IAAIG,qBAAqB,GAAGT;IAC5D,MAAMU,sBAAsBJ,MAAMA,IAAIK,oBAAoB,GAAGT;IAC7D,OAAOU,IAAAA,gCAAe,EAACJ,mBAAmBE;AAC9C"}
@@ -14,6 +14,16 @@ function isFactoryDispatch(newState) {
14
14
  return typeof newState === 'function';
15
15
  }
16
16
  const useControllableState = (options)=>{
17
+ if (process.env.NODE_ENV !== 'production') {
18
+ if (options.state !== undefined && options.defaultState !== undefined) {
19
+ // eslint-disable-next-line no-console
20
+ console.error(`@fluentui/react-utilities [useControllableState]:
21
+ A component must be either controlled or uncontrolled (specify either the state or the defaultState, but not both).
22
+ Decide between using a controlled or uncontrolled component and remove one of this props.
23
+ More info: https://reactjs.org/link/controlled-components
24
+ ${new Error().stack}`);
25
+ }
26
+ }
17
27
  const [internalState, setInternalState] = _react.useState(()=>{
18
28
  if (options.defaultState === undefined) {
19
29
  return options.initialState;
@@ -59,7 +69,7 @@ function isInitializer(value) {
59
69
  const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';
60
70
  const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';
61
71
  // eslint-disable-next-line no-console
62
- console.error(`@fluentui/react-utilities [${useControllableState.name}]:
72
+ console.error(`@fluentui/react-utilities [useControllableState]:
63
73
  A component is changing ${controlWarning}. This is likely caused by the value changing from ${undefinedWarning} value, which should not happen.
64
74
  Decide between using a controlled or uncontrolled input element for the lifetime of the component.
65
75
  More info: https://reactjs.org/link/controlled-components
@@ -1 +1 @@
1
- {"version":3,"sources":["useControllableState.js"],"sourcesContent":["import * as React from 'react';\nfunction isFactoryDispatch(newState) {\n return typeof newState === 'function';\n}\n/**\n * @internal\n *\n * A [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate)-like hook\n * to manage a value that could be either `controlled` or `uncontrolled`,\n * such as a checked state or text input string.\n *\n * @see https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components for more details on `controlled`/`uncontrolled`\n *\n * @returns an array of the current value and an updater (dispatcher) function.\n * The updater function is referentially stable (won't change during the component's lifecycle).\n * It can take either a new value, or a function which is passed the previous value and returns the new value.\n *\n * ❗️❗️ Calls to the dispatcher will only modify the state if the state is `uncontrolled`.\n * Meaning that if a state is `controlled`, calls to the dispatcher do not modify the state.\n *\n */ export const useControllableState = (options)=>{\n const [internalState, setInternalState] = React.useState(()=>{\n if (options.defaultState === undefined) {\n return options.initialState;\n }\n return isInitializer(options.defaultState) ? options.defaultState() : options.defaultState;\n });\n // Heads up!\n // This part is specific for controlled mode and mocks behavior of React dispatcher function.\n const stateValueRef = React.useRef(options.state);\n React.useEffect(()=>{\n stateValueRef.current = options.state;\n }, [\n options.state\n ]);\n const setControlledState = React.useCallback((newState)=>{\n if (isFactoryDispatch(newState)) {\n newState(stateValueRef.current);\n }\n }, []);\n return useIsControlled(options.state) ? [\n options.state,\n setControlledState\n ] : [\n internalState,\n setInternalState\n ];\n};\nfunction isInitializer(value) {\n return typeof value === 'function';\n}\n/**\n * Helper hook to handle previous comparison of controlled/uncontrolled\n * Prints an error when isControlled value switches between subsequent renders\n * @returns - whether the value is controlled\n */ const useIsControlled = (controlledValue)=>{\n const [isControlled] = React.useState(()=>controlledValue !== undefined);\n if (process.env.NODE_ENV !== 'production') {\n // We don't want these warnings in production even though it is against native behaviour\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(()=>{\n if (isControlled !== (controlledValue !== undefined)) {\n const error = new Error();\n const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';\n const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';\n // eslint-disable-next-line no-console\n console.error(`@fluentui/react-utilities [${useControllableState.name}]:\nA component is changing ${controlWarning}. This is likely caused by the value changing from ${undefinedWarning} value, which should not happen.\nDecide between using a controlled or uncontrolled input element for the lifetime of the component.\nMore info: https://reactjs.org/link/controlled-components\n${error.stack}`);\n }\n }, [\n isControlled,\n controlledValue\n ]);\n }\n return isControlled;\n};\n"],"names":["useControllableState","isFactoryDispatch","newState","options","internalState","setInternalState","React","useState","defaultState","undefined","initialState","isInitializer","stateValueRef","useRef","state","useEffect","current","setControlledState","useCallback","useIsControlled","value","controlledValue","isControlled","process","env","NODE_ENV","error","Error","controlWarning","undefinedWarning","console","name","stack"],"mappings":";;;;+BAoBiBA;;;eAAAA;;;;iEApBM;AACvB,SAASC,kBAAkBC,QAAQ;IAC/B,OAAO,OAAOA,aAAa;AAC/B;AAiBW,MAAMF,uBAAuB,CAACG;IACrC,MAAM,CAACC,eAAeC,iBAAiB,GAAGC,OAAMC,QAAQ,CAAC;QACrD,IAAIJ,QAAQK,YAAY,KAAKC,WAAW;YACpC,OAAON,QAAQO,YAAY;QAC/B;QACA,OAAOC,cAAcR,QAAQK,YAAY,IAAIL,QAAQK,YAAY,KAAKL,QAAQK,YAAY;IAC9F;IACA,YAAY;IACZ,6FAA6F;IAC7F,MAAMI,gBAAgBN,OAAMO,MAAM,CAACV,QAAQW,KAAK;IAChDR,OAAMS,SAAS,CAAC;QACZH,cAAcI,OAAO,GAAGb,QAAQW,KAAK;IACzC,GAAG;QACCX,QAAQW,KAAK;KAChB;IACD,MAAMG,qBAAqBX,OAAMY,WAAW,CAAC,CAAChB;QAC1C,IAAID,kBAAkBC,WAAW;YAC7BA,SAASU,cAAcI,OAAO;QAClC;IACJ,GAAG,EAAE;IACL,OAAOG,gBAAgBhB,QAAQW,KAAK,IAAI;QACpCX,QAAQW,KAAK;QACbG;KACH,GAAG;QACAb;QACAC;KACH;AACL;AACA,SAASM,cAAcS,KAAK;IACxB,OAAO,OAAOA,UAAU;AAC5B;AACA;;;;CAIC,GAAG,MAAMD,kBAAkB,CAACE;IACzB,MAAM,CAACC,aAAa,GAAGhB,OAAMC,QAAQ,CAAC,IAAIc,oBAAoBZ;IAC9D,IAAIc,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACvC,wFAAwF;QACxF,sDAAsD;QACtDnB,OAAMS,SAAS,CAAC;YACZ,IAAIO,iBAAkBD,CAAAA,oBAAoBZ,SAAQ,GAAI;gBAClD,MAAMiB,QAAQ,IAAIC;gBAClB,MAAMC,iBAAiBN,eAAe,0CAA0C;gBAChF,MAAMO,mBAAmBP,eAAe,4BAA4B;gBACpE,sCAAsC;gBACtCQ,QAAQJ,KAAK,CAAC,CAAC,2BAA2B,EAAE1B,qBAAqB+B,IAAI,CAAC;wBAC9D,EAAEH,eAAe,mDAAmD,EAAEC,iBAAiB;;;AAG/G,EAAEH,MAAMM,KAAK,CAAC,CAAC;YACH;QACJ,GAAG;YACCV;YACAD;SACH;IACL;IACA,OAAOC;AACX"}
1
+ {"version":3,"sources":["useControllableState.js"],"sourcesContent":["import * as React from 'react';\nfunction isFactoryDispatch(newState) {\n return typeof newState === 'function';\n}\n/**\n * @internal\n *\n * A [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate)-like hook\n * to manage a value that could be either `controlled` or `uncontrolled`,\n * such as a checked state or text input string.\n *\n * @see https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components for more details on `controlled`/`uncontrolled`\n *\n * @returns an array of the current value and an updater (dispatcher) function.\n * The updater function is referentially stable (won't change during the component's lifecycle).\n * It can take either a new value, or a function which is passed the previous value and returns the new value.\n *\n * ❗️❗️ Calls to the dispatcher will only modify the state if the state is `uncontrolled`.\n * Meaning that if a state is `controlled`, calls to the dispatcher do not modify the state.\n *\n */ export const useControllableState = (options)=>{\n if (process.env.NODE_ENV !== 'production') {\n if (options.state !== undefined && options.defaultState !== undefined) {\n // eslint-disable-next-line no-console\n console.error(`@fluentui/react-utilities [useControllableState]:\nA component must be either controlled or uncontrolled (specify either the state or the defaultState, but not both).\nDecide between using a controlled or uncontrolled component and remove one of this props.\nMore info: https://reactjs.org/link/controlled-components\n${new Error().stack}`);\n }\n }\n const [internalState, setInternalState] = React.useState(()=>{\n if (options.defaultState === undefined) {\n return options.initialState;\n }\n return isInitializer(options.defaultState) ? options.defaultState() : options.defaultState;\n });\n // Heads up!\n // This part is specific for controlled mode and mocks behavior of React dispatcher function.\n const stateValueRef = React.useRef(options.state);\n React.useEffect(()=>{\n stateValueRef.current = options.state;\n }, [\n options.state\n ]);\n const setControlledState = React.useCallback((newState)=>{\n if (isFactoryDispatch(newState)) {\n newState(stateValueRef.current);\n }\n }, []);\n return useIsControlled(options.state) ? [\n options.state,\n setControlledState\n ] : [\n internalState,\n setInternalState\n ];\n};\nfunction isInitializer(value) {\n return typeof value === 'function';\n}\n/**\n * Helper hook to handle previous comparison of controlled/uncontrolled\n * Prints an error when isControlled value switches between subsequent renders\n * @returns - whether the value is controlled\n */ const useIsControlled = (controlledValue)=>{\n const [isControlled] = React.useState(()=>controlledValue !== undefined);\n if (process.env.NODE_ENV !== 'production') {\n // We don't want these warnings in production even though it is against native behaviour\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(()=>{\n if (isControlled !== (controlledValue !== undefined)) {\n const error = new Error();\n const controlWarning = isControlled ? 'a controlled value to be uncontrolled' : 'an uncontrolled value to be controlled';\n const undefinedWarning = isControlled ? 'defined to an undefined' : 'undefined to a defined';\n // eslint-disable-next-line no-console\n console.error(`@fluentui/react-utilities [useControllableState]:\nA component is changing ${controlWarning}. This is likely caused by the value changing from ${undefinedWarning} value, which should not happen.\nDecide between using a controlled or uncontrolled input element for the lifetime of the component.\nMore info: https://reactjs.org/link/controlled-components\n${error.stack}`);\n }\n }, [\n isControlled,\n controlledValue\n ]);\n }\n return isControlled;\n};\n"],"names":["useControllableState","isFactoryDispatch","newState","options","process","env","NODE_ENV","state","undefined","defaultState","console","error","Error","stack","internalState","setInternalState","React","useState","initialState","isInitializer","stateValueRef","useRef","useEffect","current","setControlledState","useCallback","useIsControlled","value","controlledValue","isControlled","controlWarning","undefinedWarning"],"mappings":";;;;+BAoBiBA;;;eAAAA;;;;iEApBM;AACvB,SAASC,kBAAkBC,QAAQ;IAC/B,OAAO,OAAOA,aAAa;AAC/B;AAiBW,MAAMF,uBAAuB,CAACG;IACrC,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACvC,IAAIH,QAAQI,KAAK,KAAKC,aAAaL,QAAQM,YAAY,KAAKD,WAAW;YACnE,sCAAsC;YACtCE,QAAQC,KAAK,CAAC,CAAC;;;;AAI3B,EAAE,IAAIC,QAAQC,KAAK,CAAC,CAAC;QACb;IACJ;IACA,MAAM,CAACC,eAAeC,iBAAiB,GAAGC,OAAMC,QAAQ,CAAC;QACrD,IAAId,QAAQM,YAAY,KAAKD,WAAW;YACpC,OAAOL,QAAQe,YAAY;QAC/B;QACA,OAAOC,cAAchB,QAAQM,YAAY,IAAIN,QAAQM,YAAY,KAAKN,QAAQM,YAAY;IAC9F;IACA,YAAY;IACZ,6FAA6F;IAC7F,MAAMW,gBAAgBJ,OAAMK,MAAM,CAAClB,QAAQI,KAAK;IAChDS,OAAMM,SAAS,CAAC;QACZF,cAAcG,OAAO,GAAGpB,QAAQI,KAAK;IACzC,GAAG;QACCJ,QAAQI,KAAK;KAChB;IACD,MAAMiB,qBAAqBR,OAAMS,WAAW,CAAC,CAACvB;QAC1C,IAAID,kBAAkBC,WAAW;YAC7BA,SAASkB,cAAcG,OAAO;QAClC;IACJ,GAAG,EAAE;IACL,OAAOG,gBAAgBvB,QAAQI,KAAK,IAAI;QACpCJ,QAAQI,KAAK;QACbiB;KACH,GAAG;QACAV;QACAC;KACH;AACL;AACA,SAASI,cAAcQ,KAAK;IACxB,OAAO,OAAOA,UAAU;AAC5B;AACA;;;;CAIC,GAAG,MAAMD,kBAAkB,CAACE;IACzB,MAAM,CAACC,aAAa,GAAGb,OAAMC,QAAQ,CAAC,IAAIW,oBAAoBpB;IAC9D,IAAIJ,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACvC,wFAAwF;QACxF,sDAAsD;QACtDU,OAAMM,SAAS,CAAC;YACZ,IAAIO,iBAAkBD,CAAAA,oBAAoBpB,SAAQ,GAAI;gBAClD,MAAMG,QAAQ,IAAIC;gBAClB,MAAMkB,iBAAiBD,eAAe,0CAA0C;gBAChF,MAAME,mBAAmBF,eAAe,4BAA4B;gBACpE,sCAAsC;gBACtCnB,QAAQC,KAAK,CAAC,CAAC;wBACP,EAAEmB,eAAe,mDAAmD,EAAEC,iBAAiB;;;AAG/G,EAAEpB,MAAME,KAAK,CAAC,CAAC;YACH;QACJ,GAAG;YACCgB;YACAD;SACH;IACL;IACA,OAAOC;AACX"}
@@ -9,7 +9,13 @@ Object.defineProperty(exports, "useTimeout", {
9
9
  }
10
10
  });
11
11
  const _useBrowserTimer = require("./useBrowserTimer");
12
+ const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
13
+ const setTimeoutNoop = (_callback)=>-1;
14
+ const clearTimeoutNoop = (_handle)=>undefined;
12
15
  function useTimeout() {
13
- // TODO: figure it out a way to not call global.setTimeout and instead infer window from some context
14
- return (0, _useBrowserTimer.useBrowserTimer)(setTimeout, clearTimeout);
16
+ const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
17
+ const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
18
+ const setTimerFn = win ? win.setTimeout : setTimeoutNoop;
19
+ const clearTimerFn = win ? win.clearTimeout : clearTimeoutNoop;
20
+ return (0, _useBrowserTimer.useBrowserTimer)(setTimerFn, clearTimerFn);
15
21
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["useTimeout.js"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */ export function useTimeout() {\n // TODO: figure it out a way to not call global.setTimeout and instead infer window from some context\n return useBrowserTimer(setTimeout, clearTimeout);\n}\n"],"names":["useTimeout","useBrowserTimer","setTimeout","clearTimeout"],"mappings":";;;;+BAQoBA;;;eAAAA;;;iCARY;AAQrB,SAASA;IAChB,qGAAqG;IACrG,OAAOC,IAAAA,gCAAe,EAACC,YAAYC;AACvC"}
1
+ {"version":3,"sources":["useTimeout.js"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nconst setTimeoutNoop = (_callback)=>-1;\nconst clearTimeoutNoop = (_handle)=>undefined;\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */ export function useTimeout() {\n const { targetDocument } = useFluent();\n const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;\n const setTimerFn = win ? win.setTimeout : setTimeoutNoop;\n const clearTimerFn = win ? win.clearTimeout : clearTimeoutNoop;\n return useBrowserTimer(setTimerFn, clearTimerFn);\n}\n"],"names":["useTimeout","setTimeoutNoop","_callback","clearTimeoutNoop","_handle","undefined","targetDocument","useFluent","win","defaultView","setTimerFn","setTimeout","clearTimerFn","clearTimeout","useBrowserTimer"],"mappings":";;;;+BAWoBA;;;eAAAA;;;iCAXY;qCACgB;AAChD,MAAMC,iBAAiB,CAACC,YAAY,CAAC;AACrC,MAAMC,mBAAmB,CAACC,UAAUC;AAQzB,SAASL;IAChB,MAAM,EAAEM,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,MAAMF,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeG,WAAW;IACtG,MAAMC,aAAaF,MAAMA,IAAIG,UAAU,GAAGV;IAC1C,MAAMW,eAAeJ,MAAMA,IAAIK,YAAY,GAAGV;IAC9C,OAAOW,IAAAA,gCAAe,EAACJ,YAAYE;AACvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-utilities",
3
- "version": "9.18.8",
3
+ "version": "9.18.10",
4
4
  "description": "A set of general React-specific utilities.",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -19,7 +19,7 @@
19
19
  "just": "just-scripts",
20
20
  "lint": "just-scripts lint",
21
21
  "test": "jest --passWithNoTests",
22
- "type-check": "tsc -b tsconfig.json",
22
+ "type-check": "just-scripts type-check",
23
23
  "generate-api": "just-scripts generate-api",
24
24
  "test-ssr": "test-ssr \"./stories/**/*.stories.tsx\"",
25
25
  "e2e": "cypress run --component",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@fluentui/keyboard-keys": "^9.0.7",
35
- "@fluentui/react-shared-contexts": "^9.18.0",
35
+ "@fluentui/react-shared-contexts": "^9.19.0",
36
36
  "@swc/helpers": "^0.5.1"
37
37
  },
38
38
  "peerDependencies": {