baseui 0.0.0-next-50abd12 → 0.0.0-next-d5a66ca
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.
|
@@ -9,6 +9,8 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
|
+
var _reactIs = require("react-is");
|
|
13
|
+
|
|
12
14
|
var _overrides = require("../helpers/overrides");
|
|
13
15
|
|
|
14
16
|
var _styledComponents = require("./styled-components");
|
|
@@ -67,9 +69,13 @@ function StatelessAccordion(_ref) {
|
|
|
67
69
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
68
70
|
"data-baseweb": "accordion"
|
|
69
71
|
}, rootProps), React.Children.map(children, function (child, index) {
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
var normalizedChild = (0, _reactIs.isElement)(child) || (0, _reactIs.isPortal)(child) ? child :
|
|
73
|
+
/*#__PURE__*/
|
|
74
|
+
// if primitive value - wrap it in a fragment
|
|
75
|
+
React.createElement(React.Fragment, null, child);
|
|
76
|
+
var key = normalizedChild.key || String(index);
|
|
77
|
+
return /*#__PURE__*/React.cloneElement(normalizedChild, {
|
|
78
|
+
disabled: normalizedChild.props.disabled || disabled,
|
|
73
79
|
expanded: expanded.includes(key),
|
|
74
80
|
key: key,
|
|
75
81
|
onChange: // Don't bother constructing the wrapper function if no one is listening
|
|
@@ -97,7 +103,7 @@ function StatelessAccordion(_ref) {
|
|
|
97
103
|
expanded: next
|
|
98
104
|
});
|
|
99
105
|
} : onChange,
|
|
100
|
-
overrides:
|
|
106
|
+
overrides: normalizedChild.props.overrides || PanelOverrides,
|
|
101
107
|
renderAll: renderAll
|
|
102
108
|
});
|
|
103
109
|
}));
|
package/accordion/types.d.ts
CHANGED
|
@@ -33,14 +33,13 @@ export declare type OnChangeHandler = (a: {
|
|
|
33
33
|
export declare type AccordionOnChangeHandler = (a: {
|
|
34
34
|
expanded: Array<React.Key>;
|
|
35
35
|
}) => unknown;
|
|
36
|
-
declare type Children = Array<React.ReactElement<any>> | React.ReactElement<any>;
|
|
37
36
|
export declare type AccordionProps = {
|
|
38
37
|
/** Determines how many panels may be expanded at a time. If set to
|
|
39
38
|
* true it will collapse a current panel when a new panel is expanded.
|
|
40
39
|
* If set to false more than one panel may be expanded at a time. */
|
|
41
40
|
accordion?: boolean;
|
|
42
41
|
/** Accordion expandable items. See Panel API below for reference. */
|
|
43
|
-
children:
|
|
42
|
+
children: React.ReactNode;
|
|
44
43
|
/** If set to true all its children panels will be disabled from toggling. */
|
|
45
44
|
disabled?: boolean;
|
|
46
45
|
initialState?: AccordionState;
|
|
@@ -67,7 +66,7 @@ export declare type StatelessAccordionProps = {
|
|
|
67
66
|
* If set to false more than one panel may be expanded at a time. */
|
|
68
67
|
accordion?: boolean;
|
|
69
68
|
/** Accordion expandable items. See Panel API below for reference. */
|
|
70
|
-
children:
|
|
69
|
+
children: React.ReactNode;
|
|
71
70
|
/** If set to true all its children panels will be disabled from toggling. */
|
|
72
71
|
disabled?: boolean;
|
|
73
72
|
/** List of Panel keys which are expanded. */
|
|
@@ -7,6 +7,7 @@ This source code is licensed under the MIT license found in the
|
|
|
7
7
|
LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
import * as React from 'react';
|
|
10
|
+
import { isElement, isPortal } from 'react-is';
|
|
10
11
|
import { getOverrides } from '../helpers/overrides';
|
|
11
12
|
import { Root as StyledRoot } from './styled-components';
|
|
12
13
|
|
|
@@ -27,9 +28,13 @@ function StatelessAccordion({
|
|
|
27
28
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
28
29
|
"data-baseweb": "accordion"
|
|
29
30
|
}, rootProps), React.Children.map(children, (child, index) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
let normalizedChild = isElement(child) || isPortal(child) ? child :
|
|
32
|
+
/*#__PURE__*/
|
|
33
|
+
// if primitive value - wrap it in a fragment
|
|
34
|
+
React.createElement(React.Fragment, null, child);
|
|
35
|
+
const key = normalizedChild.key || String(index);
|
|
36
|
+
return /*#__PURE__*/React.cloneElement(normalizedChild, {
|
|
37
|
+
disabled: normalizedChild.props.disabled || disabled,
|
|
33
38
|
expanded: expanded.includes(key),
|
|
34
39
|
key,
|
|
35
40
|
onChange: // Don't bother constructing the wrapper function if no one is listening
|
|
@@ -55,7 +60,7 @@ function StatelessAccordion({
|
|
|
55
60
|
expanded: next
|
|
56
61
|
});
|
|
57
62
|
} : onChange,
|
|
58
|
-
overrides:
|
|
63
|
+
overrides: normalizedChild.props.overrides || PanelOverrides,
|
|
59
64
|
renderAll
|
|
60
65
|
});
|
|
61
66
|
}));
|
|
@@ -33,6 +33,7 @@ This source code is licensed under the MIT license found in the
|
|
|
33
33
|
LICENSE file in the root directory of this source tree.
|
|
34
34
|
*/
|
|
35
35
|
import * as React from 'react';
|
|
36
|
+
import { isElement, isPortal } from 'react-is';
|
|
36
37
|
import { getOverrides } from '../helpers/overrides';
|
|
37
38
|
import { Root as StyledRoot } from './styled-components';
|
|
38
39
|
|
|
@@ -58,9 +59,13 @@ function StatelessAccordion(_ref) {
|
|
|
58
59
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
59
60
|
"data-baseweb": "accordion"
|
|
60
61
|
}, rootProps), React.Children.map(children, function (child, index) {
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
var normalizedChild = isElement(child) || isPortal(child) ? child :
|
|
63
|
+
/*#__PURE__*/
|
|
64
|
+
// if primitive value - wrap it in a fragment
|
|
65
|
+
React.createElement(React.Fragment, null, child);
|
|
66
|
+
var key = normalizedChild.key || String(index);
|
|
67
|
+
return /*#__PURE__*/React.cloneElement(normalizedChild, {
|
|
68
|
+
disabled: normalizedChild.props.disabled || disabled,
|
|
64
69
|
expanded: expanded.includes(key),
|
|
65
70
|
key: key,
|
|
66
71
|
onChange: // Don't bother constructing the wrapper function if no one is listening
|
|
@@ -88,7 +93,7 @@ function StatelessAccordion(_ref) {
|
|
|
88
93
|
expanded: next
|
|
89
94
|
});
|
|
90
95
|
} : onChange,
|
|
91
|
-
overrides:
|
|
96
|
+
overrides: normalizedChild.props.overrides || PanelOverrides,
|
|
92
97
|
renderAll: renderAll
|
|
93
98
|
});
|
|
94
99
|
}));
|