@tecsinapse/cortex-react 1.8.0 → 1.8.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.
|
@@ -4,7 +4,18 @@ var React = require('react');
|
|
|
4
4
|
var Node = require('./Node.js');
|
|
5
5
|
|
|
6
6
|
const Root = ({ segmented = false, children }) => {
|
|
7
|
-
const
|
|
7
|
+
const initialSelectedIndex = React.useMemo(() => {
|
|
8
|
+
let initialIndex = null;
|
|
9
|
+
React.Children.forEach(children, (child, index) => {
|
|
10
|
+
if (React.isValidElement(child) && child.props.selected) {
|
|
11
|
+
initialIndex = index;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return initialIndex;
|
|
15
|
+
}, [children]);
|
|
16
|
+
const [selectedNode, setSelectedNode] = React.useState(
|
|
17
|
+
initialSelectedIndex
|
|
18
|
+
);
|
|
8
19
|
const childrenCount = React.useMemo(
|
|
9
20
|
() => React.Children.count(children),
|
|
10
21
|
[children]
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import React__default, {
|
|
1
|
+
import React__default, { useMemo, useState, useCallback } from 'react';
|
|
2
2
|
import { Node } from './Node.js';
|
|
3
3
|
|
|
4
4
|
const Root = ({ segmented = false, children }) => {
|
|
5
|
-
const
|
|
5
|
+
const initialSelectedIndex = useMemo(() => {
|
|
6
|
+
let initialIndex = null;
|
|
7
|
+
React__default.Children.forEach(children, (child, index) => {
|
|
8
|
+
if (React__default.isValidElement(child) && child.props.selected) {
|
|
9
|
+
initialIndex = index;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return initialIndex;
|
|
13
|
+
}, [children]);
|
|
14
|
+
const [selectedNode, setSelectedNode] = useState(
|
|
15
|
+
initialSelectedIndex
|
|
16
|
+
);
|
|
6
17
|
const childrenCount = useMemo(
|
|
7
18
|
() => React__default.Children.count(children),
|
|
8
19
|
[children]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"react-dom": ">=18.0.0",
|
|
49
49
|
"tailwind": ">=3.3.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "cf952ad2726a6201a662afd397a75b3bee435c60"
|
|
52
52
|
}
|