@fluentui/react-utilities 9.23.2 → 9.24.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 (62) hide show
  1. package/CHANGELOG.md +28 -2
  2. package/dist/index.d.ts +18 -12
  3. package/lib/compose/assertSlots.js +1 -1
  4. package/lib/compose/assertSlots.js.map +1 -1
  5. package/lib/compose/deprecated/getSlots.js +3 -2
  6. package/lib/compose/deprecated/getSlots.js.map +1 -1
  7. package/lib/compose/deprecated/getSlotsNext.js.map +1 -1
  8. package/lib/compose/getIntrinsicElementProps.js.map +1 -1
  9. package/lib/compose/getSlotClassNameProp.js.map +1 -1
  10. package/lib/hooks/useAnimationFrame.js.map +1 -1
  11. package/lib/hooks/useBrowserTimer.js.map +1 -1
  12. package/lib/hooks/useEventCallback.js.map +1 -1
  13. package/lib/hooks/useFirstMount.js +7 -8
  14. package/lib/hooks/useFirstMount.js.map +1 -1
  15. package/lib/hooks/useForceUpdate.js.map +1 -1
  16. package/lib/hooks/useMergedRefs.js.map +1 -1
  17. package/lib/hooks/useOnClickOutside.js.map +1 -1
  18. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  19. package/lib/hooks/usePrevious.js.map +1 -1
  20. package/lib/hooks/useScrollbarWidth.js.map +1 -1
  21. package/lib/hooks/useTimeout.js.map +1 -1
  22. package/lib/index.js +1 -1
  23. package/lib/index.js.map +1 -1
  24. package/lib/selection/useSelection.js.map +1 -1
  25. package/lib/utils/getNativeElementProps.js.map +1 -1
  26. package/lib/utils/getRTLSafeKey.js.map +1 -1
  27. package/lib/utils/getReactElementRef.js +16 -0
  28. package/lib/utils/getReactElementRef.js.map +1 -0
  29. package/lib/utils/index.js +1 -0
  30. package/lib/utils/index.js.map +1 -1
  31. package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
  32. package/lib/utils/mergeCallbacks.js.map +1 -1
  33. package/lib-commonjs/compose/assertSlots.js.map +1 -1
  34. package/lib-commonjs/compose/deprecated/getSlots.js +3 -2
  35. package/lib-commonjs/compose/deprecated/getSlots.js.map +1 -1
  36. package/lib-commonjs/compose/deprecated/getSlotsNext.js.map +1 -1
  37. package/lib-commonjs/compose/getIntrinsicElementProps.js.map +1 -1
  38. package/lib-commonjs/compose/getSlotClassNameProp.js.map +1 -1
  39. package/lib-commonjs/hooks/useAnimationFrame.js.map +1 -1
  40. package/lib-commonjs/hooks/useBrowserTimer.js.map +1 -1
  41. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  42. package/lib-commonjs/hooks/useFirstMount.js +5 -4
  43. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  44. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  45. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  46. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  47. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  48. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  49. package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
  50. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  51. package/lib-commonjs/index.js +3 -0
  52. package/lib-commonjs/index.js.map +1 -1
  53. package/lib-commonjs/selection/useSelection.js.map +1 -1
  54. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  55. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  56. package/lib-commonjs/utils/getReactElementRef.js +22 -0
  57. package/lib-commonjs/utils/getReactElementRef.js.map +1 -0
  58. package/lib-commonjs/utils/index.js +4 -0
  59. package/lib-commonjs/utils/index.js.map +1 -1
  60. package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
  61. package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
  62. package/package.json +4 -4
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getReactElementRef", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getReactElementRef;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const IS_REACT_19_OR_HIGHER = parseInt(_react.version, 10) >= 19;
14
+ function getReactElementRef(element) {
15
+ if (!element) {
16
+ return undefined;
17
+ }
18
+ if (IS_REACT_19_OR_HIGHER) {
19
+ return element.props.ref;
20
+ }
21
+ return element.ref;
22
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/getReactElementRef.ts"],"sourcesContent":["import * as React from 'react';\n\nconst IS_REACT_19_OR_HIGHER = parseInt(React.version, 10) >= 19;\n\n/**\n * Returns a ref for the React element in a backwards-compatible way.\n *\n * @param element - The element to get the ref for.\n * @returns The ref for the element.\n */\nexport function getReactElementRef<T>(element: React.ReactElement | null | undefined): React.Ref<T> | undefined {\n if (!element) {\n return undefined;\n }\n\n if (IS_REACT_19_OR_HIGHER) {\n return element.props.ref;\n }\n\n return (element as React.ReactElement & { ref: React.Ref<T> | undefined }).ref;\n}\n"],"names":["getReactElementRef","IS_REACT_19_OR_HIGHER","parseInt","React","version","element","undefined","props","ref"],"mappings":";;;;+BAUgBA;;;eAAAA;;;;iEAVO;AAEvB,MAAMC,wBAAwBC,SAASC,OAAMC,OAAO,EAAE,OAAO;AAQtD,SAASJ,mBAAsBK,OAA8C;IAClF,IAAI,CAACA,SAAS;QACZ,OAAOC;IACT;IAEA,IAAIL,uBAAuB;QACzB,OAAOI,QAAQE,KAAK,CAACC,GAAG;IAC1B;IAEA,OAAO,AAACH,QAAmEG,GAAG;AAChF"}
@@ -61,6 +61,9 @@ _export(exports, {
61
61
  getRTLSafeKey: function() {
62
62
  return _getRTLSafeKey.getRTLSafeKey;
63
63
  },
64
+ getReactElementRef: function() {
65
+ return _getReactElementRef.getReactElementRef;
66
+ },
64
67
  htmlElementProperties: function() {
65
68
  return _properties.htmlElementProperties;
66
69
  },
@@ -127,6 +130,7 @@ _export(exports, {
127
130
  });
128
131
  const _clamp = require("./clamp");
129
132
  const _getNativeElementProps = require("./getNativeElementProps");
133
+ const _getReactElementRef = require("./getReactElementRef");
130
134
  const _getRTLSafeKey = require("./getRTLSafeKey");
131
135
  const _mergeCallbacks = require("./mergeCallbacks");
132
136
  const _omit = require("./omit");
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/index.ts"],"sourcesContent":["export { clamp } from './clamp';\nexport {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n getNativeElementProps,\n getPartitionedNativeProps,\n} from './getNativeElementProps';\nexport { getRTLSafeKey } from './getRTLSafeKey';\nexport { mergeCallbacks } from './mergeCallbacks';\nexport { omit } from './omit';\nexport {\n anchorProperties,\n audioProperties,\n baseElementEvents,\n baseElementProperties,\n buttonProperties,\n colGroupProperties,\n colProperties,\n dialogProperties,\n divProperties,\n fieldsetProperties,\n formProperties,\n getNativeProps,\n htmlElementProperties,\n iframeProperties,\n imgProperties,\n inputProperties,\n labelProperties,\n liProperties,\n microdataProperties,\n olProperties,\n optionProperties,\n selectProperties,\n tableProperties,\n tdProperties,\n textAreaProperties,\n thProperties,\n timeProperties,\n trProperties,\n videoProperties,\n} from './properties';\nexport { isHTMLElement } from './isHTMLElement';\nexport { isInteractiveHTMLElement } from './isInteractiveHTMLElement';\nexport type { PriorityQueue, PriorityQueueCompareFn } from './priorityQueue';\nexport { createPriorityQueue } from './priorityQueue';\n"],"names":["anchorProperties","audioProperties","baseElementEvents","baseElementProperties","buttonProperties","clamp","colGroupProperties","colProperties","createPriorityQueue","dialogProperties","divProperties","fieldsetProperties","formProperties","getNativeElementProps","getNativeProps","getPartitionedNativeProps","getRTLSafeKey","htmlElementProperties","iframeProperties","imgProperties","inputProperties","isHTMLElement","isInteractiveHTMLElement","labelProperties","liProperties","mergeCallbacks","microdataProperties","olProperties","omit","optionProperties","selectProperties","tableProperties","tdProperties","textAreaProperties","thProperties","timeProperties","trProperties","videoProperties"],"mappings":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C;sBACV;4BA+Bd;+BACuB;0CACW;+BAEL"}
1
+ {"version":3,"sources":["../src/utils/index.ts"],"sourcesContent":["export { clamp } from './clamp';\nexport {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n getNativeElementProps,\n getPartitionedNativeProps,\n} from './getNativeElementProps';\nexport { getReactElementRef } from './getReactElementRef';\nexport { getRTLSafeKey } from './getRTLSafeKey';\nexport { mergeCallbacks } from './mergeCallbacks';\nexport { omit } from './omit';\nexport {\n anchorProperties,\n audioProperties,\n baseElementEvents,\n baseElementProperties,\n buttonProperties,\n colGroupProperties,\n colProperties,\n dialogProperties,\n divProperties,\n fieldsetProperties,\n formProperties,\n getNativeProps,\n htmlElementProperties,\n iframeProperties,\n imgProperties,\n inputProperties,\n labelProperties,\n liProperties,\n microdataProperties,\n olProperties,\n optionProperties,\n selectProperties,\n tableProperties,\n tdProperties,\n textAreaProperties,\n thProperties,\n timeProperties,\n trProperties,\n videoProperties,\n} from './properties';\nexport { isHTMLElement } from './isHTMLElement';\nexport { isInteractiveHTMLElement } from './isInteractiveHTMLElement';\nexport type { PriorityQueue, PriorityQueueCompareFn } from './priorityQueue';\nexport { createPriorityQueue } from './priorityQueue';\n"],"names":["anchorProperties","audioProperties","baseElementEvents","baseElementProperties","buttonProperties","clamp","colGroupProperties","colProperties","createPriorityQueue","dialogProperties","divProperties","fieldsetProperties","formProperties","getNativeElementProps","getNativeProps","getPartitionedNativeProps","getRTLSafeKey","getReactElementRef","htmlElementProperties","iframeProperties","imgProperties","inputProperties","isHTMLElement","isInteractiveHTMLElement","labelProperties","liProperties","mergeCallbacks","microdataProperties","olProperties","omit","optionProperties","selectProperties","tableProperties","tdProperties","textAreaProperties","thProperties","timeProperties","trProperties","videoProperties"],"mappings":";;;;;;;;;;;IAWEA,gBAAgB;eAAhBA,4BAAgB;;IAChBC,eAAe;eAAfA,2BAAe;;IACfC,iBAAiB;eAAjBA,6BAAiB;;IACjBC,qBAAqB;eAArBA,iCAAqB;;IACrBC,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Content":["import { isHTMLElement } from './isHTMLElement';\n\n/**\n * @internal\n * Checks that the element has default behaviour from user input on click or 'Enter'/'Space' keys\n */\nexport function isInteractiveHTMLElement(element: unknown) {\n if (!isHTMLElement(element)) {\n return false;\n }\n\n const { tagName } = element;\n switch (tagName) {\n case 'BUTTON':\n case 'A':\n case 'INPUT':\n case 'TEXTAREA':\n return true;\n }\n\n return element.isContentEditable;\n}\n"],"names":["isInteractiveHTMLElement","element","isHTMLElement","tagName","isContentEditable"],"mappings":";;;;+BAMgBA;;;eAAAA;;;+BANc;AAMvB,SAASA,yBAAyBC,OAAgB;IACvD,IAAI,CAACC,IAAAA,4BAAa,EAACD,UAAU;QAC3B,OAAO;IACT;IAEA,MAAM,EAAEE,OAAO,EAAE,GAAGF;IACpB,OAAQE;QACN,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;YACH,OAAO;IACX;IAEA,OAAOF,QAAQG,iBAAiB;AAClC"}
1
+ {"version":3,"sources":["../src/utils/isInteractiveHTMLElement.ts"],"sourcesContent":["import { isHTMLElement } from './isHTMLElement';\n\n/**\n * @internal\n * Checks that the element has default behaviour from user input on click or 'Enter'/'Space' keys\n */\nexport function isInteractiveHTMLElement(element: unknown): boolean {\n if (!isHTMLElement(element)) {\n return false;\n }\n\n const { tagName } = element;\n switch (tagName) {\n case 'BUTTON':\n case 'A':\n case 'INPUT':\n case 'TEXTAREA':\n return true;\n }\n\n return element.isContentEditable;\n}\n"],"names":["isInteractiveHTMLElement","element","isHTMLElement","tagName","isContentEditable"],"mappings":";;;;+BAMgBA;;;eAAAA;;;+BANc;AAMvB,SAASA,yBAAyBC,OAAgB;IACvD,IAAI,CAACC,IAAAA,4BAAa,EAACD,UAAU;QAC3B,OAAO;IACT;IAEA,MAAM,EAAEE,OAAO,EAAE,GAAGF;IACpB,OAAQE;QACN,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;YACH,OAAO;IACX;IAEA,OAAOF,QAAQG,iBAAiB;AAClC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/mergeCallbacks.ts"],"sourcesContent":["/**\n * @internal\n * Combine two event callbacks into a single callback function that calls each one in order.\n *\n * Usage example:\n * ```ts\n * state.slot.onChange = mergeCallbacks(state.slot.onChange, ev => {\n * // Handle onChange\n * });\n * ```\n *\n * The primary use is to avoid the need to capture an existing callback (`state.slot.onChange` in the example) to a\n * local variable before replacing with a new listener that calls the existing one. This helps avoid bugs like:\n * * Infinite recursion by calling the re-assigned state.slot.onChange if it's not captured to a local variable.\n * * Missing a call to the original onChange due to an early return or other conditional.\n *\n * If you need a callback that is stable between renders, wrap the result in {@link useEventCallback}.\n *\n * @param callback1 - The first callback to be called, or undefined\n * @param callback2 - The second callback to be called, or undefined\n *\n * @returns A function that that calls the provided functions in order\n */\nexport function mergeCallbacks<Args extends unknown[]>(\n callback1: ((...args: Args) => void) | undefined,\n callback2: ((...args: Args) => void) | undefined,\n) {\n return (...args: Args) => {\n callback1?.(...args);\n callback2?.(...args);\n };\n}\n"],"names":["mergeCallbacks","callback1","callback2","args"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;CAsBC;;;;+BACeA;;;eAAAA;;;AAAT,SAASA,eACdC,SAAgD,EAChDC,SAAgD;IAEhD,OAAO,CAAC,GAAGC;QACTF,sBAAAA,gCAAAA,aAAeE;QACfD,sBAAAA,gCAAAA,aAAeC;IACjB;AACF"}
1
+ {"version":3,"sources":["../src/utils/mergeCallbacks.ts"],"sourcesContent":["/**\n * @internal\n * Combine two event callbacks into a single callback function that calls each one in order.\n *\n * Usage example:\n * ```ts\n * state.slot.onChange = mergeCallbacks(state.slot.onChange, ev => {\n * // Handle onChange\n * });\n * ```\n *\n * The primary use is to avoid the need to capture an existing callback (`state.slot.onChange` in the example) to a\n * local variable before replacing with a new listener that calls the existing one. This helps avoid bugs like:\n * * Infinite recursion by calling the re-assigned state.slot.onChange if it's not captured to a local variable.\n * * Missing a call to the original onChange due to an early return or other conditional.\n *\n * If you need a callback that is stable between renders, wrap the result in {@link useEventCallback}.\n *\n * @param callback1 - The first callback to be called, or undefined\n * @param callback2 - The second callback to be called, or undefined\n *\n * @returns A function that that calls the provided functions in order\n */\nexport function mergeCallbacks<Args extends unknown[]>(\n callback1: ((...args: Args) => void) | undefined,\n callback2: ((...args: Args) => void) | undefined,\n): (...args: Args) => void {\n return (...args: Args) => {\n callback1?.(...args);\n callback2?.(...args);\n };\n}\n"],"names":["mergeCallbacks","callback1","callback2","args"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;CAsBC;;;;+BACeA;;;eAAAA;;;AAAT,SAASA,eACdC,SAAgD,EAChDC,SAAgD;IAEhD,OAAO,CAAC,GAAGC;QACTF,sBAAAA,gCAAAA,aAAeE;QACfD,sBAAAA,gCAAAA,aAAeC;IACjB;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-utilities",
3
- "version": "9.23.2",
3
+ "version": "9.24.1",
4
4
  "description": "A set of general React-specific utilities.",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -18,12 +18,12 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@fluentui/keyboard-keys": "^9.0.8",
21
- "@fluentui/react-shared-contexts": "^9.24.1",
21
+ "@fluentui/react-shared-contexts": "^9.25.1",
22
22
  "@swc/helpers": "^0.5.1"
23
23
  },
24
24
  "peerDependencies": {
25
- "@types/react": ">=16.14.0 <19.0.0",
26
- "react": ">=16.14.0 <19.0.0"
25
+ "@types/react": ">=16.14.0 <20.0.0",
26
+ "react": ">=16.14.0 <20.0.0"
27
27
  },
28
28
  "beachball": {
29
29
  "disallowedChangeTypes": [