@fluentui/react-motion 9.10.2 → 9.10.3
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,23 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-motion
|
|
2
2
|
|
|
3
|
-
This log was last generated on Thu,
|
|
3
|
+
This log was last generated on Thu, 21 Aug 2025 12:20:18 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.10.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.10.3)
|
|
8
|
+
|
|
9
|
+
Thu, 21 Aug 2025 12:20:18 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-motion_v9.10.2..@fluentui/react-motion_v9.10.3)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- refactor: move getRefFromReactElement to react-utilities ([PR #35030](https://github.com/microsoft/fluentui/pull/35030) by dmytrokirpa@microsoft.com)
|
|
15
|
+
- Bump @fluentui/react-shared-contexts to v9.25.0 ([PR #35055](https://github.com/microsoft/fluentui/pull/35055) by beachball)
|
|
16
|
+
- Bump @fluentui/react-utilities to v9.24.0 ([PR #35055](https://github.com/microsoft/fluentui/pull/35055) by beachball)
|
|
17
|
+
|
|
7
18
|
## [9.10.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-motion_v9.10.2)
|
|
8
19
|
|
|
9
|
-
Thu, 07 Aug 2025
|
|
20
|
+
Thu, 07 Aug 2025 10:03:25 GMT
|
|
10
21
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-motion_v9.10.1..@fluentui/react-motion_v9.10.2)
|
|
11
22
|
|
|
12
23
|
### Patches
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useMergedRefs } from '@fluentui/react-utilities';
|
|
3
|
-
const IS_REACT_19 = React.version.startsWith('19.');
|
|
2
|
+
import { getReactElementRef, useMergedRefs } from '@fluentui/react-utilities';
|
|
4
3
|
const CHILD_ERROR_MESSAGE = [
|
|
5
4
|
'@fluentui/react-motion: Invalid child element.',
|
|
6
5
|
'\n',
|
|
7
6
|
'Motion factories require a single child element to be passed. ',
|
|
8
7
|
'That element element should support ref forwarding i.e. it should be either an intrinsic element (e.g. div) or a component that uses React.forwardRef().'
|
|
9
8
|
].join('');
|
|
10
|
-
/**
|
|
11
|
-
* A backwards-compatible way to get the ref from a React element without console errors.
|
|
12
|
-
*/ function getRefFromReactElement(element) {
|
|
13
|
-
if (IS_REACT_19) {
|
|
14
|
-
return element.props.ref;
|
|
15
|
-
}
|
|
16
|
-
return element.ref;
|
|
17
|
-
}
|
|
18
9
|
/**
|
|
19
10
|
* Validates the child and returns a cloned child element with a ref.
|
|
20
11
|
*
|
|
@@ -37,7 +28,7 @@ const CHILD_ERROR_MESSAGE = [
|
|
|
37
28
|
if (React.isValidElement(child)) {
|
|
38
29
|
return [
|
|
39
30
|
React.cloneElement(child, {
|
|
40
|
-
ref: useMergedRefs(childRef,
|
|
31
|
+
ref: useMergedRefs(childRef, getReactElementRef(child))
|
|
41
32
|
}),
|
|
42
33
|
childRef
|
|
43
34
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/useChildElement.ts"],"sourcesContent":["import * as React from 'react';\nimport { useMergedRefs } from '@fluentui/react-utilities';\n\nconst
|
|
1
|
+
{"version":3,"sources":["../src/utils/useChildElement.ts"],"sourcesContent":["import * as React from 'react';\nimport { getReactElementRef, useMergedRefs } from '@fluentui/react-utilities';\n\nconst CHILD_ERROR_MESSAGE = [\n '@fluentui/react-motion: Invalid child element.',\n '\\n',\n 'Motion factories require a single child element to be passed. ',\n 'That element element should support ref forwarding i.e. it should be either an intrinsic element (e.g. div) or a component that uses React.forwardRef().',\n].join('');\n\n/**\n * Validates the child and returns a cloned child element with a ref.\n *\n * Throws an error if the child is not a valid React element, similar to \"React.Children.only\".\n * Logs a warning in development mode if the ref is not set as the component remains functional.\n */\nexport function useChildElement(\n children: React.ReactElement,\n mounted: boolean = true,\n): [React.ReactElement, React.RefObject<HTMLElement>] {\n const childRef = React.useRef<HTMLElement>(null);\n\n React.useEffect(() => {\n if (process.env.NODE_ENV !== 'production') {\n if (mounted && !childRef.current) {\n // eslint-disable-next-line no-console\n console.error(CHILD_ERROR_MESSAGE);\n }\n }\n }, [mounted]);\n\n try {\n const child = React.Children.only(children) as Parameters<typeof React.isValidElement>[0];\n\n if (React.isValidElement(child)) {\n return [\n React.cloneElement(child as React.ReactElement<{ ref: React.Ref<HTMLElement> }>, {\n ref: useMergedRefs(childRef, getReactElementRef(child)),\n }),\n childRef,\n ];\n }\n } catch {\n /* empty */\n }\n\n throw new Error(CHILD_ERROR_MESSAGE);\n}\n"],"names":["React","getReactElementRef","useMergedRefs","CHILD_ERROR_MESSAGE","join","useChildElement","children","mounted","childRef","useRef","useEffect","process","env","NODE_ENV","current","console","error","child","Children","only","isValidElement","cloneElement","ref","Error"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,4BAA4B;AAE9E,MAAMC,sBAAsB;IAC1B;IACA;IACA;IACA;CACD,CAACC,IAAI,CAAC;AAEP;;;;;CAKC,GACD,OAAO,SAASC,gBACdC,QAA4B,EAC5BC,UAAmB,IAAI;IAEvB,MAAMC,WAAWR,MAAMS,MAAM,CAAc;IAE3CT,MAAMU,SAAS,CAAC;QACd,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,IAAIN,WAAW,CAACC,SAASM,OAAO,EAAE;gBAChC,sCAAsC;gBACtCC,QAAQC,KAAK,CAACb;YAChB;QACF;IACF,GAAG;QAACI;KAAQ;IAEZ,IAAI;QACF,MAAMU,QAAQjB,MAAMkB,QAAQ,CAACC,IAAI,CAACb;QAElC,IAAIN,MAAMoB,cAAc,CAACH,QAAQ;YAC/B,OAAO;gBACLjB,MAAMqB,YAAY,CAACJ,OAA8D;oBAC/EK,KAAKpB,cAAcM,UAAUP,mBAAmBgB;gBAClD;gBACAT;aACD;QACH;IACF,EAAE,OAAM;IACN,SAAS,GACX;IAEA,MAAM,IAAIe,MAAMpB;AAClB"}
|
|
@@ -11,21 +11,12 @@ Object.defineProperty(exports, "useChildElement", {
|
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
13
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
14
|
-
const IS_REACT_19 = _react.version.startsWith('19.');
|
|
15
14
|
const CHILD_ERROR_MESSAGE = [
|
|
16
15
|
'@fluentui/react-motion: Invalid child element.',
|
|
17
16
|
'\n',
|
|
18
17
|
'Motion factories require a single child element to be passed. ',
|
|
19
18
|
'That element element should support ref forwarding i.e. it should be either an intrinsic element (e.g. div) or a component that uses React.forwardRef().'
|
|
20
19
|
].join('');
|
|
21
|
-
/**
|
|
22
|
-
* A backwards-compatible way to get the ref from a React element without console errors.
|
|
23
|
-
*/ function getRefFromReactElement(element) {
|
|
24
|
-
if (IS_REACT_19) {
|
|
25
|
-
return element.props.ref;
|
|
26
|
-
}
|
|
27
|
-
return element.ref;
|
|
28
|
-
}
|
|
29
20
|
function useChildElement(children, mounted = true) {
|
|
30
21
|
const childRef = _react.useRef(null);
|
|
31
22
|
_react.useEffect(()=>{
|
|
@@ -43,7 +34,7 @@ function useChildElement(children, mounted = true) {
|
|
|
43
34
|
if (_react.isValidElement(child)) {
|
|
44
35
|
return [
|
|
45
36
|
_react.cloneElement(child, {
|
|
46
|
-
ref: (0, _reactutilities.useMergedRefs)(childRef,
|
|
37
|
+
ref: (0, _reactutilities.useMergedRefs)(childRef, (0, _reactutilities.getReactElementRef)(child))
|
|
47
38
|
}),
|
|
48
39
|
childRef
|
|
49
40
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/useChildElement.ts"],"sourcesContent":["import * as React from 'react';\nimport { useMergedRefs } from '@fluentui/react-utilities';\n\nconst
|
|
1
|
+
{"version":3,"sources":["../src/utils/useChildElement.ts"],"sourcesContent":["import * as React from 'react';\nimport { getReactElementRef, useMergedRefs } from '@fluentui/react-utilities';\n\nconst CHILD_ERROR_MESSAGE = [\n '@fluentui/react-motion: Invalid child element.',\n '\\n',\n 'Motion factories require a single child element to be passed. ',\n 'That element element should support ref forwarding i.e. it should be either an intrinsic element (e.g. div) or a component that uses React.forwardRef().',\n].join('');\n\n/**\n * Validates the child and returns a cloned child element with a ref.\n *\n * Throws an error if the child is not a valid React element, similar to \"React.Children.only\".\n * Logs a warning in development mode if the ref is not set as the component remains functional.\n */\nexport function useChildElement(\n children: React.ReactElement,\n mounted: boolean = true,\n): [React.ReactElement, React.RefObject<HTMLElement>] {\n const childRef = React.useRef<HTMLElement>(null);\n\n React.useEffect(() => {\n if (process.env.NODE_ENV !== 'production') {\n if (mounted && !childRef.current) {\n // eslint-disable-next-line no-console\n console.error(CHILD_ERROR_MESSAGE);\n }\n }\n }, [mounted]);\n\n try {\n const child = React.Children.only(children) as Parameters<typeof React.isValidElement>[0];\n\n if (React.isValidElement(child)) {\n return [\n React.cloneElement(child as React.ReactElement<{ ref: React.Ref<HTMLElement> }>, {\n ref: useMergedRefs(childRef, getReactElementRef(child)),\n }),\n childRef,\n ];\n }\n } catch {\n /* empty */\n }\n\n throw new Error(CHILD_ERROR_MESSAGE);\n}\n"],"names":["useChildElement","CHILD_ERROR_MESSAGE","join","children","mounted","childRef","React","useRef","useEffect","process","env","NODE_ENV","current","console","error","child","Children","only","isValidElement","cloneElement","ref","useMergedRefs","getReactElementRef","Error"],"mappings":";;;;+BAgBgBA;;;eAAAA;;;;iEAhBO;gCAC2B;AAElD,MAAMC,sBAAsB;IAC1B;IACA;IACA;IACA;CACD,CAACC,IAAI,CAAC;AAQA,SAASF,gBACdG,QAA4B,EAC5BC,UAAmB,IAAI;IAEvB,MAAMC,WAAWC,OAAMC,MAAM,CAAc;IAE3CD,OAAME,SAAS,CAAC;QACd,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,IAAIP,WAAW,CAACC,SAASO,OAAO,EAAE;gBAChC,sCAAsC;gBACtCC,QAAQC,KAAK,CAACb;YAChB;QACF;IACF,GAAG;QAACG;KAAQ;IAEZ,IAAI;QACF,MAAMW,QAAQT,OAAMU,QAAQ,CAACC,IAAI,CAACd;QAElC,IAAIG,OAAMY,cAAc,CAACH,QAAQ;YAC/B,OAAO;gBACLT,OAAMa,YAAY,CAACJ,OAA8D;oBAC/EK,KAAKC,IAAAA,6BAAa,EAAChB,UAAUiB,IAAAA,kCAAkB,EAACP;gBAClD;gBACAV;aACD;QACH;IACF,EAAE,OAAM;IACN,SAAS,GACX;IAEA,MAAM,IAAIkB,MAAMtB;AAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-motion",
|
|
3
|
-
"version": "9.10.
|
|
3
|
+
"version": "9.10.3",
|
|
4
4
|
"description": "A package with utilities & motion definitions using Web Animations API",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@fluentui/scripts-cypress": "*"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@fluentui/react-shared-contexts": "^9.
|
|
29
|
-
"@fluentui/react-utilities": "^9.
|
|
28
|
+
"@fluentui/react-shared-contexts": "^9.25.0",
|
|
29
|
+
"@fluentui/react-utilities": "^9.24.0",
|
|
30
30
|
"@swc/helpers": "^0.5.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|