@react-fabric/utilities 1.0.0-beta.19 → 1.0.0-beta.21

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.
@@ -27,18 +27,18 @@ var jsxRuntime = require('react/jsx-runtime');
27
27
  */
28
28
 
29
29
  var cloneChildren = function cloneChildren(children, callback) {
30
- var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
31
- return react.Children.map(children, function (c) {
30
+ var _Children$map;
31
+ return (_Children$map = react.Children.map(children, function (c) {
32
32
  if ( /*#__PURE__*/react.isValidElement(c)) {
33
33
  if (c.type === jsxRuntime.Fragment) {
34
34
  var _c$props;
35
35
  // just compare to `Fragment`
36
36
  return cloneChildren((_c$props = c.props) === null || _c$props === void 0 ? void 0 : _c$props.children, callback);
37
37
  }
38
- return callback(c, index++);
38
+ return c;
39
39
  }
40
40
  return c;
41
- });
41
+ })) === null || _Children$map === void 0 ? void 0 : _Children$map.flat().filter(Boolean).map(callback);
42
42
  };
43
43
 
44
44
  exports.cloneChildren = cloneChildren;
@@ -27,18 +27,18 @@ import { Fragment } from 'react/jsx-runtime';
27
27
  */
28
28
 
29
29
  var cloneChildren = function cloneChildren(children, callback) {
30
- var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
31
- return Children.map(children, function (c) {
30
+ var _Children$map;
31
+ return (_Children$map = Children.map(children, function (c) {
32
32
  if ( /*#__PURE__*/isValidElement(c)) {
33
33
  if (c.type === Fragment) {
34
34
  var _c$props;
35
35
  // just compare to `Fragment`
36
36
  return cloneChildren((_c$props = c.props) === null || _c$props === void 0 ? void 0 : _c$props.children, callback);
37
37
  }
38
- return callback(c, index++);
38
+ return c;
39
39
  }
40
40
  return c;
41
- });
41
+ })) === null || _Children$map === void 0 ? void 0 : _Children$map.flat().filter(Boolean).map(callback);
42
42
  };
43
43
 
44
44
  export { cloneChildren };
@@ -1,2 +1,2 @@
1
1
  import { type ReactNode } from "react";
2
- export declare const cloneChildren: (children: ReactNode, callback: (child: ReactNode, index: number) => ReactNode, index?: number) => ReactNode;
2
+ export declare const cloneChildren: (children: ReactNode, callback: (child: ReactNode, index: number) => ReactNode) => ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/utilities",
3
- "version": "1.0.0-beta.19",
3
+ "version": "1.0.0-beta.21",
4
4
  "description": "RUF: Utility package",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -44,5 +44,5 @@
44
44
  "node": ">=18.12.0",
45
45
  "npm": ">=8.19.0"
46
46
  },
47
- "gitHead": "1757660f7f30590d1bf5c7f2bd3526f6052dccd5"
47
+ "gitHead": "31c3d5c19bce7df519a62bd43efd1c9e6341be04"
48
48
  }
@@ -27,7 +27,6 @@ import { Fragment } from "react/jsx-runtime";
27
27
  export const cloneChildren = (
28
28
  children: ReactNode,
29
29
  callback: (child: ReactNode, index: number) => ReactNode,
30
- index = 0,
31
30
  ): ReactNode => {
32
31
  return Children.map(children, (c: ReactNode) => {
33
32
  if (isValidElement(c)) {
@@ -35,8 +34,11 @@ export const cloneChildren = (
35
34
  // just compare to `Fragment`
36
35
  return cloneChildren(c.props?.children, callback);
37
36
  }
38
- return callback(c, index++);
37
+ return c;
39
38
  }
40
39
  return c;
41
- });
40
+ })
41
+ ?.flat()
42
+ .filter(Boolean)
43
+ .map(callback);
42
44
  };