@commercetools-uikit/collapsible-motion 12.2.4 → 12.2.5

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/README.md CHANGED
@@ -65,10 +65,24 @@ export default Example;
65
65
 
66
66
  ## Properties
67
67
 
68
- | Props | Type | Required | Default | Description |
69
- | ----------------- | -------- | :------: | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
70
- | `children` | `func` | ✅ | | A render function, called with the following named arguments: `isOpen` (boolean), `toggle` (function),&#xA;`containerStyles` (css-in-js object), `registerContentNode` (React reference to be used on the animated container).&#xA;<br/>&#xA;Siganture: `({ isOpen, containerStyles, toggle, registerContentNode }) => React.node` |
71
- | `isClosed` | `bool` | | | Determines the state of the toggle `isOpen`. Setting this prop will make the component **controlled** |
72
- | `onToggle` | `func` | | | A callback function called when the `toggle` function is called. This prop is required when the component is **controlled**. |
73
- | `minHeight` | `number` | | `0` | The minimal height of the container being animated. |
74
- | `isDefaultClosed` | `bool` | | | The initial value to the internal toggle state `isOpen`. |
68
+ | Props | Type | Required | Default | Description |
69
+ | ----------------- | ---------------------------------------------------- | :------: | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
70
+ | `children` | `Function`<br/>[See signature.](#signature-children) | ✅ | | A render function, called with the following named arguments: `isOpen` (boolean), `toggle` (function),&#xA;`containerStyles` (css-in-js object), `registerContentNode` (React reference to be used on the animated container).&#xA;<br/>&#xA;Siganture: `({ isOpen, containerStyles, toggle, registerContentNode }) => React.node` |
71
+ | `isClosed` | `boolean` | | | Determines the state of the toggle `isOpen`. Setting this prop will make the component **controlled** |
72
+ | `onToggle` | `Function`<br/>[See signature.](#signature-onToggle) | | | A callback function called when the `toggle` function is called. This prop is required when the component is **controlled**. |
73
+ | `minHeight` | `number` | | `0` | The minimal height of the container being animated. |
74
+ | `isDefaultClosed` | `boolean` | | | The initial value to the internal toggle state `isOpen`. |
75
+
76
+ ## Signatures
77
+
78
+ ### Signature `children`
79
+
80
+ ```ts
81
+ (options: TRenderFunctionOptions) => ReactNode;
82
+ ```
83
+
84
+ ### Signature `onToggle`
85
+
86
+ ```ts
87
+ () => void
88
+ ```
@@ -0,0 +1,2 @@
1
+ export * from "./declarations/src/index";
2
+ export { default } from "./declarations/src/index";
@@ -13,7 +13,7 @@ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/obje
13
13
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
14
14
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
15
15
  var _taggedTemplateLiteral = require('@babel/runtime-corejs3/helpers/taggedTemplateLiteral');
16
- var PropTypes = require('prop-types');
16
+ var _pt = require('prop-types');
17
17
  var react$1 = require('react');
18
18
  var utils = require('@commercetools-uikit/utils');
19
19
  var react = require('@emotion/react');
@@ -31,7 +31,7 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
31
31
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
32
32
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
33
33
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
34
- var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
34
+ var _pt__default = /*#__PURE__*/_interopDefault(_pt);
35
35
  var isNil__default = /*#__PURE__*/_interopDefault(isNil);
36
36
 
37
37
  var _templateObject, _templateObject2, _templateObject3, _templateObject4;
@@ -39,38 +39,6 @@ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
39
39
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
40
40
 
41
41
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
42
- var collapsibleMotionPropTypes = process.env.NODE_ENV !== "production" ? {
43
- /**
44
- * A render function, called with the following named arguments: `isOpen` (boolean), `toggle` (function),
45
- * `containerStyles` (css-in-js object), `registerContentNode` (React reference to be used on the animated container).
46
- * <br/>
47
- * Siganture: `({ isOpen, containerStyles, toggle, registerContentNode }) => React.node`
48
- */
49
- children: PropTypes__default["default"].func.isRequired,
50
-
51
- /**
52
- * Determines the state of the toggle `isOpen`. Setting this prop will make the component **controlled**
53
- */
54
- // eslint-disable-next-line react/no-unused-prop-types
55
- isClosed: PropTypes__default["default"].bool,
56
-
57
- /**
58
- * A callback function called when the `toggle` function is called. This prop is required when the component is **controlled**.
59
- */
60
- // eslint-disable-next-line react/no-unused-prop-types
61
- onToggle: PropTypes__default["default"].func,
62
-
63
- /**
64
- * The minimal height of the container being animated.
65
- */
66
- minHeight: PropTypes__default["default"].number,
67
-
68
- /**
69
- *The initial value to the internal toggle state `isOpen`.
70
- */
71
- // eslint-disable-next-line react/no-unused-prop-types
72
- isDefaultClosed: PropTypes__default["default"].bool
73
- } : {};
74
42
  var defaultProps = {
75
43
  minHeight: 0
76
44
  };
@@ -88,24 +56,25 @@ var createOpeningAnimation = function createOpeningAnimation(height) {
88
56
  return react.keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% { height: ", "; overflow: hidden; visibility: ", "; }\n 99% { height: ", "px; overflow: hidden; }\n 100% { height: auto; overflow: visible; }\n "])), getMinHeight(minHeight), getVisibility(minHeight), height);
89
57
  };
90
58
 
91
- var createClosingAnimation = function createClosingAnimation(height, minHeight) {
59
+ var createClosingAnimation = function createClosingAnimation(height) {
60
+ var minHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
92
61
  return react.keyframes(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n from { height: ", "px; }\n to { height: ", "; overflow: hidden; visibility: ", "; }\n "])), height, getMinHeight(minHeight), getVisibility(minHeight));
93
62
  };
94
63
 
95
- var useToggleAnimation = function useToggleAnimation(isOpen, toggle, minHeight) {
64
+ var useToggleAnimation = function useToggleAnimation(isOpen, toggle) {
65
+ var minHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
96
66
  var nodeRef = react$1.useRef();
97
67
  var animationRef = react$1.useRef(null);
98
68
  var prevIsOpen = hooks.usePrevious(isOpen);
99
69
  react$1.useEffect(function () {
100
70
  process.env.NODE_ENV !== "production" ? utils.warning(nodeRef.current, 'You need to call `registerContentNode` in order to use this component') : void 0;
101
71
  }, // to match the componentDidMount behaviour
102
- // eslint-disable-next-line react-hooks/exhaustive-deps
103
72
  [nodeRef]);
104
73
  var handleToggle = react$1.useCallback(function () {
105
74
  process.env.NODE_ENV !== "production" ? utils.warning(nodeRef.current, 'You need to call `registerContentNode` in order to use this component') : void 0; // set panel height to the height of the content,
106
75
  // so we can animate between the height and 0
107
76
 
108
- toggle();
77
+ toggle && toggle();
109
78
  }, [nodeRef, toggle]);
110
79
  var containerStyles = isOpen ? {
111
80
  height: 'auto'
@@ -115,7 +84,7 @@ var useToggleAnimation = function useToggleAnimation(isOpen, toggle, minHeight)
115
84
  visibility: getVisibility(minHeight)
116
85
  }; // if state has changed
117
86
 
118
- if (typeof prevIsOpen !== 'undefined' && prevIsOpen !== isOpen) {
87
+ if (typeof prevIsOpen !== 'undefined' && prevIsOpen !== isOpen && nodeRef.current) {
119
88
  animationRef.current = isOpen ? createOpeningAnimation(nodeRef.current.clientHeight, minHeight) : createClosingAnimation(nodeRef.current.clientHeight, minHeight);
120
89
  }
121
90
 
@@ -138,7 +107,7 @@ var ControlledCollapsibleMotion = function ControlledCollapsibleMotion(props) {
138
107
  if (animation) {
139
108
  // By calling `css`, emotion injects the required CSS into the document head.
140
109
  // eslint-disable-next-line no-unused-expressions
141
- css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n animation: ", " 200ms forwards;\n "])), animation);
110
+ css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n animation: ", " 200ms\n forwards;\n "])), animation);
142
111
  animationStyle = {
143
112
  animation: "".concat(animation.name, " 200ms forwards")
144
113
  };
@@ -154,8 +123,14 @@ var ControlledCollapsibleMotion = function ControlledCollapsibleMotion(props) {
154
123
  });
155
124
  };
156
125
 
126
+ ControlledCollapsibleMotion.propTypes = process.env.NODE_ENV !== "production" ? {
127
+ children: _pt__default["default"].func.isRequired,
128
+ isClosed: _pt__default["default"].bool,
129
+ onToggle: _pt__default["default"].func,
130
+ minHeight: _pt__default["default"].number,
131
+ isDefaultClosed: _pt__default["default"].bool
132
+ } : {};
157
133
  ControlledCollapsibleMotion.displayName = 'ControlledCollapsibleMotion';
158
- ControlledCollapsibleMotion.propTypes = process.env.NODE_ENV !== "production" ? collapsibleMotionPropTypes : {};
159
134
 
160
135
  var UncontrolledCollapsibleMotion = function UncontrolledCollapsibleMotion(props) {
161
136
  var _useToggleState = hooks.useToggleState(!props.isDefaultClosed),
@@ -178,7 +153,7 @@ var UncontrolledCollapsibleMotion = function UncontrolledCollapsibleMotion(props
178
153
  if (animation) {
179
154
  // By calling `css`, emotion injects the required CSS into the document head.
180
155
  // eslint-disable-next-line no-unused-expressions
181
- css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n animation: ", " 200ms forwards;\n "])), animation);
156
+ css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n animation: ", " 200ms\n forwards;\n "])), animation);
182
157
  animationStyle = {
183
158
  animation: "".concat(animation.name, " 200ms forwards")
184
159
  };
@@ -194,9 +169,15 @@ var UncontrolledCollapsibleMotion = function UncontrolledCollapsibleMotion(props
194
169
  });
195
170
  };
196
171
 
172
+ UncontrolledCollapsibleMotion.propTypes = process.env.NODE_ENV !== "production" ? {
173
+ children: _pt__default["default"].func.isRequired,
174
+ isClosed: _pt__default["default"].bool,
175
+ onToggle: _pt__default["default"].func,
176
+ minHeight: _pt__default["default"].number,
177
+ isDefaultClosed: _pt__default["default"].bool
178
+ } : {};
197
179
  UncontrolledCollapsibleMotion.displayName = 'UncontrolledCollapsibleMotion';
198
180
  UncontrolledCollapsibleMotion.defaultProps = defaultProps;
199
- UncontrolledCollapsibleMotion.propTypes = process.env.NODE_ENV !== "production" ? collapsibleMotionPropTypes : {};
200
181
 
201
182
  var CollapsibleMotion = function CollapsibleMotion(props) {
202
183
  var isControlledComponent = !isNil__default["default"](props.isClosed);
@@ -208,13 +189,19 @@ var CollapsibleMotion = function CollapsibleMotion(props) {
208
189
  return jsxRuntime.jsx(UncontrolledCollapsibleMotion, _objectSpread({}, props));
209
190
  };
210
191
 
192
+ CollapsibleMotion.propTypes = process.env.NODE_ENV !== "production" ? {
193
+ children: _pt__default["default"].func.isRequired,
194
+ isClosed: _pt__default["default"].bool,
195
+ onToggle: _pt__default["default"].func,
196
+ minHeight: _pt__default["default"].number,
197
+ isDefaultClosed: _pt__default["default"].bool
198
+ } : {};
211
199
  CollapsibleMotion.displayName = 'CollapsibleMotion';
212
200
  CollapsibleMotion.defaultProps = defaultProps;
213
- CollapsibleMotion.propTypes = process.env.NODE_ENV !== "production" ? collapsibleMotionPropTypes : {};
214
201
  var CollapsibleMotion$1 = CollapsibleMotion;
215
202
 
216
- // NOTE: This string will be replaced in the `prepare` script by the `scripts/version.js` file.
217
- var version = '12.2.4';
203
+ // NOTE: This string will be replaced on build time with the package version.
204
+ var version = "12.2.5";
218
205
 
219
206
  exports["default"] = CollapsibleMotion$1;
220
207
  exports.version = version;
@@ -55,22 +55,23 @@ var createOpeningAnimation = function createOpeningAnimation(height) {
55
55
  return react.keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% { height: ", "; overflow: hidden; visibility: ", "; }\n 99% { height: ", "px; overflow: hidden; }\n 100% { height: auto; overflow: visible; }\n "])), getMinHeight(minHeight), getVisibility(minHeight), height);
56
56
  };
57
57
 
58
- var createClosingAnimation = function createClosingAnimation(height, minHeight) {
58
+ var createClosingAnimation = function createClosingAnimation(height) {
59
+ var minHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
59
60
  return react.keyframes(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n from { height: ", "px; }\n to { height: ", "; overflow: hidden; visibility: ", "; }\n "])), height, getMinHeight(minHeight), getVisibility(minHeight));
60
61
  };
61
62
 
62
- var useToggleAnimation = function useToggleAnimation(isOpen, toggle, minHeight) {
63
+ var useToggleAnimation = function useToggleAnimation(isOpen, toggle) {
64
+ var minHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
63
65
  var nodeRef = react$1.useRef();
64
66
  var animationRef = react$1.useRef(null);
65
67
  var prevIsOpen = hooks.usePrevious(isOpen);
66
68
  react$1.useEffect(function () {
67
69
  }, // to match the componentDidMount behaviour
68
- // eslint-disable-next-line react-hooks/exhaustive-deps
69
70
  [nodeRef]);
70
71
  var handleToggle = react$1.useCallback(function () {
71
72
  // so we can animate between the height and 0
72
73
 
73
- toggle();
74
+ toggle && toggle();
74
75
  }, [nodeRef, toggle]);
75
76
  var containerStyles = isOpen ? {
76
77
  height: 'auto'
@@ -80,7 +81,7 @@ var useToggleAnimation = function useToggleAnimation(isOpen, toggle, minHeight)
80
81
  visibility: getVisibility(minHeight)
81
82
  }; // if state has changed
82
83
 
83
- if (typeof prevIsOpen !== 'undefined' && prevIsOpen !== isOpen) {
84
+ if (typeof prevIsOpen !== 'undefined' && prevIsOpen !== isOpen && nodeRef.current) {
84
85
  animationRef.current = isOpen ? createOpeningAnimation(nodeRef.current.clientHeight, minHeight) : createClosingAnimation(nodeRef.current.clientHeight, minHeight);
85
86
  }
86
87
 
@@ -103,7 +104,7 @@ var ControlledCollapsibleMotion = function ControlledCollapsibleMotion(props) {
103
104
  if (animation) {
104
105
  // By calling `css`, emotion injects the required CSS into the document head.
105
106
  // eslint-disable-next-line no-unused-expressions
106
- css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n animation: ", " 200ms forwards;\n "])), animation);
107
+ css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n animation: ", " 200ms\n forwards;\n "])), animation);
107
108
  animationStyle = {
108
109
  animation: "".concat(animation.name, " 200ms forwards")
109
110
  };
@@ -119,8 +120,8 @@ var ControlledCollapsibleMotion = function ControlledCollapsibleMotion(props) {
119
120
  });
120
121
  };
121
122
 
122
- ControlledCollapsibleMotion.displayName = 'ControlledCollapsibleMotion';
123
123
  ControlledCollapsibleMotion.propTypes = {};
124
+ ControlledCollapsibleMotion.displayName = 'ControlledCollapsibleMotion';
124
125
 
125
126
  var UncontrolledCollapsibleMotion = function UncontrolledCollapsibleMotion(props) {
126
127
  var _useToggleState = hooks.useToggleState(!props.isDefaultClosed),
@@ -143,7 +144,7 @@ var UncontrolledCollapsibleMotion = function UncontrolledCollapsibleMotion(props
143
144
  if (animation) {
144
145
  // By calling `css`, emotion injects the required CSS into the document head.
145
146
  // eslint-disable-next-line no-unused-expressions
146
- css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n animation: ", " 200ms forwards;\n "])), animation);
147
+ css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n animation: ", " 200ms\n forwards;\n "])), animation);
147
148
  animationStyle = {
148
149
  animation: "".concat(animation.name, " 200ms forwards")
149
150
  };
@@ -159,9 +160,9 @@ var UncontrolledCollapsibleMotion = function UncontrolledCollapsibleMotion(props
159
160
  });
160
161
  };
161
162
 
163
+ UncontrolledCollapsibleMotion.propTypes = {};
162
164
  UncontrolledCollapsibleMotion.displayName = 'UncontrolledCollapsibleMotion';
163
165
  UncontrolledCollapsibleMotion.defaultProps = defaultProps;
164
- UncontrolledCollapsibleMotion.propTypes = {};
165
166
 
166
167
  var CollapsibleMotion = function CollapsibleMotion(props) {
167
168
  var isControlledComponent = !isNil__default["default"](props.isClosed);
@@ -173,13 +174,13 @@ var CollapsibleMotion = function CollapsibleMotion(props) {
173
174
  return jsxRuntime.jsx(UncontrolledCollapsibleMotion, _objectSpread({}, props));
174
175
  };
175
176
 
177
+ CollapsibleMotion.propTypes = {};
176
178
  CollapsibleMotion.displayName = 'CollapsibleMotion';
177
179
  CollapsibleMotion.defaultProps = defaultProps;
178
- CollapsibleMotion.propTypes = {};
179
180
  var CollapsibleMotion$1 = CollapsibleMotion;
180
181
 
181
- // NOTE: This string will be replaced in the `prepare` script by the `scripts/version.js` file.
182
- var version = '12.2.4';
182
+ // NOTE: This string will be replaced on build time with the package version.
183
+ var version = "12.2.5";
183
184
 
184
185
  exports["default"] = CollapsibleMotion$1;
185
186
  exports.version = version;
@@ -9,7 +9,7 @@ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object
9
9
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
10
10
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
11
11
  import _taggedTemplateLiteral from '@babel/runtime-corejs3/helpers/esm/taggedTemplateLiteral';
12
- import PropTypes from 'prop-types';
12
+ import _pt from 'prop-types';
13
13
  import { useRef, useEffect, useCallback } from 'react';
14
14
  import { warning } from '@commercetools-uikit/utils';
15
15
  import { ClassNames, keyframes } from '@emotion/react';
@@ -22,38 +22,6 @@ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
22
22
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
23
23
 
24
24
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty(_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
25
- var collapsibleMotionPropTypes = process.env.NODE_ENV !== "production" ? {
26
- /**
27
- * A render function, called with the following named arguments: `isOpen` (boolean), `toggle` (function),
28
- * `containerStyles` (css-in-js object), `registerContentNode` (React reference to be used on the animated container).
29
- * <br/>
30
- * Siganture: `({ isOpen, containerStyles, toggle, registerContentNode }) => React.node`
31
- */
32
- children: PropTypes.func.isRequired,
33
-
34
- /**
35
- * Determines the state of the toggle `isOpen`. Setting this prop will make the component **controlled**
36
- */
37
- // eslint-disable-next-line react/no-unused-prop-types
38
- isClosed: PropTypes.bool,
39
-
40
- /**
41
- * A callback function called when the `toggle` function is called. This prop is required when the component is **controlled**.
42
- */
43
- // eslint-disable-next-line react/no-unused-prop-types
44
- onToggle: PropTypes.func,
45
-
46
- /**
47
- * The minimal height of the container being animated.
48
- */
49
- minHeight: PropTypes.number,
50
-
51
- /**
52
- *The initial value to the internal toggle state `isOpen`.
53
- */
54
- // eslint-disable-next-line react/no-unused-prop-types
55
- isDefaultClosed: PropTypes.bool
56
- } : {};
57
25
  var defaultProps = {
58
26
  minHeight: 0
59
27
  };
@@ -71,24 +39,25 @@ var createOpeningAnimation = function createOpeningAnimation(height) {
71
39
  return keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% { height: ", "; overflow: hidden; visibility: ", "; }\n 99% { height: ", "px; overflow: hidden; }\n 100% { height: auto; overflow: visible; }\n "])), getMinHeight(minHeight), getVisibility(minHeight), height);
72
40
  };
73
41
 
74
- var createClosingAnimation = function createClosingAnimation(height, minHeight) {
42
+ var createClosingAnimation = function createClosingAnimation(height) {
43
+ var minHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
75
44
  return keyframes(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n from { height: ", "px; }\n to { height: ", "; overflow: hidden; visibility: ", "; }\n "])), height, getMinHeight(minHeight), getVisibility(minHeight));
76
45
  };
77
46
 
78
- var useToggleAnimation = function useToggleAnimation(isOpen, toggle, minHeight) {
47
+ var useToggleAnimation = function useToggleAnimation(isOpen, toggle) {
48
+ var minHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
79
49
  var nodeRef = useRef();
80
50
  var animationRef = useRef(null);
81
51
  var prevIsOpen = usePrevious(isOpen);
82
52
  useEffect(function () {
83
53
  process.env.NODE_ENV !== "production" ? warning(nodeRef.current, 'You need to call `registerContentNode` in order to use this component') : void 0;
84
54
  }, // to match the componentDidMount behaviour
85
- // eslint-disable-next-line react-hooks/exhaustive-deps
86
55
  [nodeRef]);
87
56
  var handleToggle = useCallback(function () {
88
57
  process.env.NODE_ENV !== "production" ? warning(nodeRef.current, 'You need to call `registerContentNode` in order to use this component') : void 0; // set panel height to the height of the content,
89
58
  // so we can animate between the height and 0
90
59
 
91
- toggle();
60
+ toggle && toggle();
92
61
  }, [nodeRef, toggle]);
93
62
  var containerStyles = isOpen ? {
94
63
  height: 'auto'
@@ -98,7 +67,7 @@ var useToggleAnimation = function useToggleAnimation(isOpen, toggle, minHeight)
98
67
  visibility: getVisibility(minHeight)
99
68
  }; // if state has changed
100
69
 
101
- if (typeof prevIsOpen !== 'undefined' && prevIsOpen !== isOpen) {
70
+ if (typeof prevIsOpen !== 'undefined' && prevIsOpen !== isOpen && nodeRef.current) {
102
71
  animationRef.current = isOpen ? createOpeningAnimation(nodeRef.current.clientHeight, minHeight) : createClosingAnimation(nodeRef.current.clientHeight, minHeight);
103
72
  }
104
73
 
@@ -121,7 +90,7 @@ var ControlledCollapsibleMotion = function ControlledCollapsibleMotion(props) {
121
90
  if (animation) {
122
91
  // By calling `css`, emotion injects the required CSS into the document head.
123
92
  // eslint-disable-next-line no-unused-expressions
124
- css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n animation: ", " 200ms forwards;\n "])), animation);
93
+ css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n animation: ", " 200ms\n forwards;\n "])), animation);
125
94
  animationStyle = {
126
95
  animation: "".concat(animation.name, " 200ms forwards")
127
96
  };
@@ -137,8 +106,14 @@ var ControlledCollapsibleMotion = function ControlledCollapsibleMotion(props) {
137
106
  });
138
107
  };
139
108
 
109
+ ControlledCollapsibleMotion.propTypes = process.env.NODE_ENV !== "production" ? {
110
+ children: _pt.func.isRequired,
111
+ isClosed: _pt.bool,
112
+ onToggle: _pt.func,
113
+ minHeight: _pt.number,
114
+ isDefaultClosed: _pt.bool
115
+ } : {};
140
116
  ControlledCollapsibleMotion.displayName = 'ControlledCollapsibleMotion';
141
- ControlledCollapsibleMotion.propTypes = process.env.NODE_ENV !== "production" ? collapsibleMotionPropTypes : {};
142
117
 
143
118
  var UncontrolledCollapsibleMotion = function UncontrolledCollapsibleMotion(props) {
144
119
  var _useToggleState = useToggleState(!props.isDefaultClosed),
@@ -161,7 +136,7 @@ var UncontrolledCollapsibleMotion = function UncontrolledCollapsibleMotion(props
161
136
  if (animation) {
162
137
  // By calling `css`, emotion injects the required CSS into the document head.
163
138
  // eslint-disable-next-line no-unused-expressions
164
- css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n animation: ", " 200ms forwards;\n "])), animation);
139
+ css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n animation: ", " 200ms\n forwards;\n "])), animation);
165
140
  animationStyle = {
166
141
  animation: "".concat(animation.name, " 200ms forwards")
167
142
  };
@@ -177,9 +152,15 @@ var UncontrolledCollapsibleMotion = function UncontrolledCollapsibleMotion(props
177
152
  });
178
153
  };
179
154
 
155
+ UncontrolledCollapsibleMotion.propTypes = process.env.NODE_ENV !== "production" ? {
156
+ children: _pt.func.isRequired,
157
+ isClosed: _pt.bool,
158
+ onToggle: _pt.func,
159
+ minHeight: _pt.number,
160
+ isDefaultClosed: _pt.bool
161
+ } : {};
180
162
  UncontrolledCollapsibleMotion.displayName = 'UncontrolledCollapsibleMotion';
181
163
  UncontrolledCollapsibleMotion.defaultProps = defaultProps;
182
- UncontrolledCollapsibleMotion.propTypes = process.env.NODE_ENV !== "production" ? collapsibleMotionPropTypes : {};
183
164
 
184
165
  var CollapsibleMotion = function CollapsibleMotion(props) {
185
166
  var isControlledComponent = !isNil(props.isClosed);
@@ -191,12 +172,18 @@ var CollapsibleMotion = function CollapsibleMotion(props) {
191
172
  return jsx(UncontrolledCollapsibleMotion, _objectSpread({}, props));
192
173
  };
193
174
 
175
+ CollapsibleMotion.propTypes = process.env.NODE_ENV !== "production" ? {
176
+ children: _pt.func.isRequired,
177
+ isClosed: _pt.bool,
178
+ onToggle: _pt.func,
179
+ minHeight: _pt.number,
180
+ isDefaultClosed: _pt.bool
181
+ } : {};
194
182
  CollapsibleMotion.displayName = 'CollapsibleMotion';
195
183
  CollapsibleMotion.defaultProps = defaultProps;
196
- CollapsibleMotion.propTypes = process.env.NODE_ENV !== "production" ? collapsibleMotionPropTypes : {};
197
184
  var CollapsibleMotion$1 = CollapsibleMotion;
198
185
 
199
- // NOTE: This string will be replaced in the `prepare` script by the `scripts/version.js` file.
200
- var version = '12.2.4';
186
+ // NOTE: This string will be replaced on build time with the package version.
187
+ var version = "12.2.5";
201
188
 
202
189
  export { CollapsibleMotion$1 as default, version };
@@ -0,0 +1,30 @@
1
+ import { ReactNode, CSSProperties, LegacyRef } from 'react';
2
+ declare type TContainerStyles = {
3
+ height?: string | number;
4
+ overflow?: string;
5
+ visibility?: string;
6
+ name?: string;
7
+ animation?: string;
8
+ } & CSSProperties;
9
+ declare type TRenderFunctionOptions = {
10
+ isOpen: boolean;
11
+ containerStyles: TContainerStyles;
12
+ toggle: () => void;
13
+ registerContentNode: TNodeRefObject;
14
+ };
15
+ export declare type TCollapsibleMotionProps = {
16
+ children: (options: TRenderFunctionOptions) => ReactNode;
17
+ isClosed?: boolean;
18
+ onToggle?: () => void;
19
+ minHeight?: number;
20
+ isDefaultClosed?: boolean;
21
+ };
22
+ declare type TNodeRefObject = {
23
+ clientHeight: number;
24
+ } & LegacyRef<HTMLDivElement>;
25
+ declare const CollapsibleMotion: {
26
+ (props: TCollapsibleMotionProps): import("@emotion/react/jsx-runtime").JSX.Element;
27
+ displayName: string;
28
+ defaultProps: Pick<TCollapsibleMotionProps, "minHeight">;
29
+ };
30
+ export default CollapsibleMotion;
@@ -0,0 +1,2 @@
1
+ export { default } from './collapsible-motion';
2
+ export { default as version } from './version';
@@ -0,0 +1,2 @@
1
+ declare const _default: "__@UI_KIT_PACKAGE/VERSION_OF_RELEASE__";
2
+ export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/collapsible-motion",
3
3
  "description": "A component which allows building collapsible elements with an arbitrary height.",
4
- "version": "12.2.4",
4
+ "version": "12.2.5",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,24 +9,27 @@
9
9
  "directory": "packages/components/collapsible-motion"
10
10
  },
11
11
  "homepage": "https://uikit.commercetools.com",
12
- "keywords": ["javascript", "design system", "react", "uikit"],
12
+ "keywords": [
13
+ "javascript",
14
+ "design system",
15
+ "react",
16
+ "uikit"
17
+ ],
13
18
  "license": "MIT",
14
- "private": false,
15
19
  "publishConfig": {
16
20
  "access": "public"
17
21
  },
18
22
  "sideEffects": false,
19
23
  "main": "dist/commercetools-uikit-collapsible-motion.cjs.js",
20
24
  "module": "dist/commercetools-uikit-collapsible-motion.esm.js",
21
- "files": ["dist"],
22
- "scripts": {
23
- "prepare": "../../../scripts/version.js replace"
24
- },
25
+ "files": [
26
+ "dist"
27
+ ],
25
28
  "dependencies": {
26
- "@babel/runtime": "7.15.4",
27
- "@babel/runtime-corejs3": "7.15.4",
28
- "@commercetools-uikit/hooks": "12.2.3",
29
- "@commercetools-uikit/utils": "12.2.0",
29
+ "@babel/runtime": "7.16.3",
30
+ "@babel/runtime-corejs3": "7.16.3",
31
+ "@commercetools-uikit/hooks": "12.2.5",
32
+ "@commercetools-uikit/utils": "12.2.5",
30
33
  "@emotion/react": "^11.4.0",
31
34
  "@emotion/styled": "^11.3.0",
32
35
  "lodash": "4.17.21",