@plesk/ui-library 3.39.0 → 3.40.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.
Files changed (80) hide show
  1. package/cjs/components/Button/Button.js +4 -22
  2. package/cjs/components/Card/CardButton.js +2 -3
  3. package/cjs/components/CardList/CardListToolbar.js +3 -8
  4. package/cjs/components/Dialog/Dialog.js +5 -27
  5. package/cjs/components/Drawer/Drawer.js +7 -20
  6. package/cjs/components/Dropdown/Dropdown.js +3 -11
  7. package/cjs/components/FormField/FormField.js +13 -26
  8. package/cjs/components/List/List.js +1 -14
  9. package/cjs/components/Progress/Progress.js +6 -5
  10. package/cjs/components/ProgressStep/ProgressStep.js +5 -14
  11. package/cjs/components/ProgressStep/index.js +6 -0
  12. package/cjs/components/Section/Section.js +11 -19
  13. package/cjs/components/TextArea/TextArea.js +49 -97
  14. package/cjs/components/TextArea/calculateNodeHeight.js +8 -8
  15. package/cjs/components/Toolbar/RegistryContextBeta.js +112 -0
  16. package/cjs/components/Toolbar/Toolbar.js +46 -2
  17. package/cjs/components/Toolbar/ToolbarBetaProvider.js +23 -0
  18. package/cjs/components/Toolbar/ToolbarGroup.js +66 -4
  19. package/cjs/components/Toolbar/ToolbarItem.js +27 -12
  20. package/cjs/components/Toolbar/ToolbarMenu.js +2 -1
  21. package/cjs/components/Toolbar/index.js +8 -1
  22. package/cjs/components/index.js +15 -1
  23. package/cjs/hooks/index.js +12 -0
  24. package/cjs/hooks/useResizeObserver.js +29 -0
  25. package/cjs/hooks/useSqueeze.js +48 -0
  26. package/cjs/index.js +1 -1
  27. package/dist/plesk-ui-library.js +586 -303
  28. package/dist/plesk-ui-library.js.map +1 -1
  29. package/dist/plesk-ui-library.min.js +6 -6
  30. package/dist/plesk-ui-library.min.js.map +1 -1
  31. package/esm/components/Button/Button.js +3 -21
  32. package/esm/components/Card/CardButton.js +2 -3
  33. package/esm/components/CardList/CardListToolbar.js +3 -8
  34. package/esm/components/Dialog/Dialog.js +5 -27
  35. package/esm/components/Drawer/Drawer.js +7 -20
  36. package/esm/components/Dropdown/Dropdown.js +3 -11
  37. package/esm/components/FormField/FormField.js +13 -26
  38. package/esm/components/List/List.js +1 -14
  39. package/esm/components/Progress/Progress.js +7 -6
  40. package/esm/components/ProgressStep/ProgressStep.js +4 -13
  41. package/esm/components/ProgressStep/index.js +1 -1
  42. package/esm/components/Section/Section.js +11 -19
  43. package/esm/components/TextArea/TextArea.js +50 -98
  44. package/esm/components/TextArea/calculateNodeHeight.js +8 -8
  45. package/esm/components/Toolbar/RegistryContextBeta.js +103 -0
  46. package/esm/components/Toolbar/Toolbar.js +47 -3
  47. package/esm/components/Toolbar/ToolbarBetaProvider.js +16 -0
  48. package/esm/components/Toolbar/ToolbarGroup.js +67 -5
  49. package/esm/components/Toolbar/ToolbarItem.js +27 -12
  50. package/esm/components/Toolbar/ToolbarMenu.js +2 -1
  51. package/esm/components/Toolbar/index.js +2 -1
  52. package/esm/components/index.js +2 -2
  53. package/esm/hooks/index.js +3 -0
  54. package/esm/hooks/useResizeObserver.js +22 -0
  55. package/esm/hooks/useSqueeze.js +41 -0
  56. package/esm/index.js +1 -1
  57. package/package.json +10 -10
  58. package/styleguide/build/bundle.505bc865.js +2 -0
  59. package/styleguide/index.html +2 -2
  60. package/types/src/components/Button/Button.d.ts +1 -0
  61. package/types/src/components/Dialog/Dialog.d.ts +1 -25
  62. package/types/src/components/Drawer/Drawer.d.ts +2 -5
  63. package/types/src/components/FormField/FormField.d.ts +1 -23
  64. package/types/src/components/ProgressStep/ProgressStep.d.ts +2 -13
  65. package/types/src/components/ProgressStep/index.d.ts +1 -1
  66. package/types/src/components/Section/Section.d.ts +2 -32
  67. package/types/src/components/TextArea/TextArea.d.ts +5 -32
  68. package/types/src/components/TextArea/calculateNodeHeight.d.ts +2 -6
  69. package/types/src/components/Toolbar/RegistryContextBeta.d.ts +25 -0
  70. package/types/src/components/Toolbar/Toolbar.d.ts +2 -22
  71. package/types/src/components/Toolbar/ToolbarBetaProvider.d.ts +5 -0
  72. package/types/src/components/Toolbar/ToolbarGroup.d.ts +2 -5
  73. package/types/src/components/Toolbar/ToolbarItem.d.ts +1 -1
  74. package/types/src/components/Toolbar/index.d.ts +1 -0
  75. package/types/src/components/index.d.ts +2 -2
  76. package/types/src/hooks/index.d.ts +1 -0
  77. package/types/src/hooks/useResizeObserver.d.ts +7 -0
  78. package/types/src/hooks/useSqueeze.d.ts +10 -0
  79. package/styleguide/build/bundle.c34e3753.js +0 -2
  80. /package/styleguide/build/{bundle.c34e3753.js.LICENSE.txt → bundle.505bc865.js.LICENSE.txt} +0 -0
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = void 0;
7
+ exports.default = exports.BUTTON_PROP_NAMES = void 0;
8
8
  var _react = require("react");
9
9
  var _classnames = _interopRequireDefault(require("classnames"));
10
10
  var _constants = require("../../constants");
@@ -69,6 +69,9 @@ const renderCaret = _ref2 => {
69
69
  }
70
70
  return caretElement;
71
71
  };
72
+
73
+ // For ToolbarMenu backward compatibility purposes
74
+ const BUTTON_PROP_NAMES = exports.BUTTON_PROP_NAMES = ['size', 'intent', 'ghost', 'selected', 'onToggle', 'state', 'disabled', 'tooltip', 'icon', 'caret', 'fill', 'children', 'component', 'className', 'baseClassName', 'arrow', 'onClick'];
72
75
  const Button = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
73
76
  let {
74
77
  baseClassName = `${_constants.CLS_PREFIX}button`,
@@ -182,27 +185,6 @@ const Button = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
182
185
  });
183
186
  Button.displayName = 'Button';
184
187
 
185
- // For ToolbarMenu backward compatibility purposes
186
- Button.defaultProps = {
187
- size: undefined,
188
- intent: undefined,
189
- ghost: false,
190
- selected: undefined,
191
- onToggle: undefined,
192
- state: undefined,
193
- disabled: false,
194
- tooltip: undefined,
195
- icon: undefined,
196
- caret: undefined,
197
- fill: false,
198
- children: undefined,
199
- component: 'button',
200
- className: undefined,
201
- baseClassName: `${_constants.CLS_PREFIX}button`,
202
- arrow: undefined,
203
- onClick: undefined
204
- };
205
-
206
188
  /**
207
189
  * `Button` component is used for executing actions, changing the application state, opening forms or dialog windows, and submitting data.
208
190
  * As a rule, you should not use buttons for navigation between individual pages (use `Link` instead).
@@ -16,10 +16,12 @@ var _jsxRuntime = require("react/jsx-runtime");
16
16
  const CardButton = _ref => {
17
17
  let {
18
18
  icon,
19
+ baseClassName = `${_constants.CLS_PREFIX}card-button`,
19
20
  ...props
20
21
  } = _ref;
21
22
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
22
23
  icon: _Icon.default.create(icon),
24
+ baseClassName: baseClassName,
23
25
  ...props
24
26
  });
25
27
  };
@@ -30,7 +32,4 @@ CardButton.propTypes = {
30
32
  baseClassName: _propTypes.default.string,
31
33
  icon: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object, _propTypes.default.element]).isRequired
32
34
  };
33
- CardButton.defaultProps = {
34
- baseClassName: `${_constants.CLS_PREFIX}card-button`
35
- };
36
35
  var _default = exports.default = CardButton;
@@ -120,9 +120,9 @@ const renderView = (onViewChange, currentView) => {
120
120
  const isToolbarExpander = element => /*#__PURE__*/(0, _react.isValidElement)(element) && element.type === _Toolbar.ToolbarExpander;
121
121
  const CardListToolbar = _ref2 => {
122
122
  let {
123
- baseClassName,
124
- selection,
125
- onViewChange,
123
+ baseClassName = `${_constants.CLS_PREFIX}card-list__toolbar`,
124
+ selection = null,
125
+ onViewChange = null,
126
126
  currentView,
127
127
  groups
128
128
  } = _ref2;
@@ -153,9 +153,4 @@ CardListToolbar.propTypes = {
153
153
  currentView: _propTypes.default.string.isRequired,
154
154
  baseClassName: _propTypes.default.string
155
155
  };
156
- CardListToolbar.defaultProps = {
157
- selection: null,
158
- onViewChange: null,
159
- baseClassName: `${_constants.CLS_PREFIX}card-list__toolbar`
160
- };
161
156
  var _default = exports.default = CardListToolbar;
@@ -29,11 +29,14 @@ const isProps = value => value && typeof value === 'object' && ! /*#__PURE__*/(0
29
29
  */
30
30
  const Dialog = _ref => {
31
31
  let {
32
- baseClassName,
32
+ baseClassName = `${_constants.CLS_PREFIX}dialog`,
33
+ isOpen = false,
34
+ size = 'md',
35
+ closable = true,
36
+ canClose = true,
33
37
  className,
34
38
  children,
35
39
  actions,
36
- isOpen,
37
40
  banner,
38
41
  image,
39
42
  title,
@@ -42,11 +45,8 @@ const Dialog = _ref => {
42
45
  cancelButton,
43
46
  buttons,
44
47
  form,
45
- size,
46
- closable,
47
48
  onClose,
48
49
  closingConfirmation,
49
- canClose,
50
50
  ...props
51
51
  } = _ref;
52
52
  const [isVisible, setIsVisible] = (0, _react.useState)(isOpen);
@@ -206,26 +206,4 @@ const Dialog = _ref => {
206
206
  }), closingConfirmationDialog]
207
207
  });
208
208
  };
209
- Dialog.defaultProps = {
210
- isOpen: false,
211
- banner: undefined,
212
- sideBanner: undefined,
213
- sideBannerContainer: undefined,
214
- image: undefined,
215
- title: undefined,
216
- subtitle: undefined,
217
- cancelTitle: undefined,
218
- cancelButton: undefined,
219
- buttons: undefined,
220
- actions: undefined,
221
- form: undefined,
222
- size: 'md',
223
- closable: true,
224
- canClose: true,
225
- onClose: undefined,
226
- closingConfirmation: undefined,
227
- children: undefined,
228
- className: undefined,
229
- baseClassName: `${_constants.CLS_PREFIX}dialog`
230
- };
231
209
  var _default = exports.default = Dialog;
@@ -19,24 +19,6 @@ var _DrawerProgress = _interopRequireDefault(require("./DrawerProgress"));
19
19
  var _jsxRuntime = require("react/jsx-runtime");
20
20
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
21
21
 
22
- const defaultProps = {
23
- isOpen: false,
24
- subtitle: undefined,
25
- backButton: undefined,
26
- hideButton: undefined,
27
- tabs: undefined,
28
- placement: 'left',
29
- size: 'md',
30
- onClose: undefined,
31
- closingConfirmation: undefined,
32
- form: undefined,
33
- sideBanner: undefined,
34
- sideBannerContainer: undefined,
35
- progress: undefined,
36
- children: null,
37
- className: undefined,
38
- baseClassName: `${_constants.CLS_PREFIX}drawer`
39
- };
40
22
  /**
41
23
  * `Drawer` component is used for working with properties of an object (or system) without leaving the context of the object.
42
24
  * [Read more when to use Drawer](#!/Drawers%2C%20pages%2C%20popovers).
@@ -44,7 +26,10 @@ const defaultProps = {
44
26
  */
45
27
  const Drawer = _ref => {
46
28
  let {
47
- baseClassName,
29
+ baseClassName = `${_constants.CLS_PREFIX}drawer`,
30
+ isOpen = false,
31
+ placement = 'left',
32
+ size = 'md',
48
33
  className,
49
34
  children,
50
35
  title,
@@ -146,6 +131,9 @@ const Drawer = _ref => {
146
131
  }, className),
147
132
  onClose: onCloseWithConfirmation,
148
133
  canCloseOnBackdropClick: true,
134
+ isOpen: isOpen,
135
+ placement: placement,
136
+ size: size,
149
137
  ...props,
150
138
  children: [takeApart(_ref5 => {
151
139
  let {
@@ -187,5 +175,4 @@ const Drawer = _ref => {
187
175
  }), closingConfirmationDialog]
188
176
  });
189
177
  };
190
- Drawer.defaultProps = defaultProps;
191
178
  var _default = exports.default = Drawer;
@@ -132,12 +132,12 @@ const useEnhancedMenu = (menu, _ref2) => {
132
132
  */
133
133
  const Dropdown = _ref3 => {
134
134
  let {
135
- baseClassName,
135
+ baseClassName = `${_constants.CLS_PREFIX}dropdown`,
136
136
  className,
137
137
  children,
138
138
  menu,
139
- menuPlacement,
140
- overlay,
139
+ menuPlacement = 'bottom-start',
140
+ overlay = false,
141
141
  locale,
142
142
  ...props
143
143
  } = _ref3;
@@ -206,12 +206,4 @@ const Dropdown = _ref3 => {
206
206
  })
207
207
  });
208
208
  };
209
- Dropdown.defaultProps = {
210
- menuPlacement: 'bottom-start',
211
- children: undefined,
212
- overlay: false,
213
- className: undefined,
214
- baseClassName: `${_constants.CLS_PREFIX}dropdown`,
215
- locale: undefined
216
- };
217
209
  var _default = exports.default = Dropdown;
@@ -28,28 +28,6 @@ var _jsxRuntime = require("react/jsx-runtime");
28
28
 
29
29
  const BASE_FORM_FIELD_CLASS_NAME = exports.BASE_FORM_FIELD_CLASS_NAME = `${_constants.CLS_PREFIX}form-field`;
30
30
  const defaultValue = undefined;
31
- const defaultProps = {
32
- id: undefined,
33
- name: undefined,
34
- value: defaultValue,
35
- onChange: null,
36
- label: undefined,
37
- description: undefined,
38
- errors: {},
39
- required: false,
40
- children: undefined,
41
- multi: undefined,
42
- disabled: undefined,
43
- locale: undefined,
44
- addMoreValidator: undefined,
45
- onRemoveRow: null,
46
- fullDescription: undefined,
47
- className: undefined,
48
- baseClassName: BASE_FORM_FIELD_CLASS_NAME,
49
- form: undefined,
50
- vertical: undefined,
51
- scrollableElement: undefined
52
- };
53
31
 
54
32
  /**
55
33
  * Simple helper to handle situations when we're expecting only array
@@ -455,8 +433,14 @@ class FormField extends _react.Component {
455
433
  * * [FormFieldSelect](#!/FormFieldSelect), [FormFieldCheckbox](#!/FormFieldCheckbox),
456
434
  * [FormFieldRadioButtons](#!/FormFieldRadioButtons) for selecting options.
457
435
  */
458
- (0, _defineProperty2.default)(FormField, "defaultProps", defaultProps);
459
- const FormFieldWrapper = props => {
436
+ const FormFieldWrapper = _ref => {
437
+ let {
438
+ value = defaultValue,
439
+ errors = {},
440
+ required = false,
441
+ baseClassName = BASE_FORM_FIELD_CLASS_NAME,
442
+ ...props
443
+ } = _ref;
460
444
  const form = (0, _react.useContext)(_FormContext.default);
461
445
  const verticalContext = (0, _react.useContext)(_VerticalContext.default);
462
446
  const vertical = props.vertical === undefined ? verticalContext : props.vertical;
@@ -467,9 +451,12 @@ const FormFieldWrapper = props => {
467
451
  form: form,
468
452
  vertical: vertical,
469
453
  scrollableElement: scrollableElement,
470
- disabled: props.disabled || disabled
454
+ disabled: props.disabled || disabled,
455
+ value: value,
456
+ errors: errors,
457
+ required: required,
458
+ baseClassName: baseClassName
471
459
  });
472
460
  };
473
461
  FormFieldWrapper.displayName = 'FormField';
474
- FormFieldWrapper.defaultProps = defaultProps;
475
462
  var _default = exports.default = FormFieldWrapper;
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("react");
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
10
  var _classnames = _interopRequireDefault(require("classnames"));
12
11
  var _reactTransitionGroup = require("react-transition-group");
13
12
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
@@ -41,7 +40,7 @@ function getRowKey(row, props) {
41
40
  }
42
41
  const Tbody = _ref => {
43
42
  let {
44
- baseClassName,
43
+ baseClassName = `${_constants.CLS_PREFIX}list__wrapper`,
45
44
  className,
46
45
  ...props
47
46
  } = _ref;
@@ -59,18 +58,6 @@ const Tbody = _ref => {
59
58
  })
60
59
  });
61
60
  };
62
- Tbody.propTypes = {
63
- onFocus: _propTypes.default.func,
64
- onBlur: _propTypes.default.func,
65
- className: _propTypes.default.string,
66
- baseClassName: _propTypes.default.string
67
- };
68
- Tbody.defaultProps = {
69
- onFocus: undefined,
70
- onBlur: undefined,
71
- className: undefined,
72
- baseClassName: `${_constants.CLS_PREFIX}list__wrapper`
73
- };
74
61
  const getHumanTotalRows = _ref2 => {
75
62
  let {
76
63
  selectedRows,
@@ -35,11 +35,12 @@ class Progress extends _react.Component {
35
35
  let isFailed = false;
36
36
  if (children) {
37
37
  _react.Children.forEach(children, child => {
38
- if ( /*#__PURE__*/(0, _react.isValidElement)(child) && child.props.status) {
39
- isNotStarted = isNotStarted && child.props.status === _ProgressStep.STATUS_NOT_STARTED;
40
- isFinished = isFinished && child.props.status === _ProgressStep.STATUS_DONE;
41
- isFinishedWithWarnings = isFinishedWithWarnings && [_ProgressStep.STATUS_DONE, _ProgressStep.STATUS_WARNING].includes(child.props.status);
42
- isFailed = isFailed || child.props.status === _ProgressStep.STATUS_ERROR;
38
+ if ( /*#__PURE__*/(0, _react.isValidElement)(child)) {
39
+ const status = child.props.status ?? _ProgressStep.PROGRESS_STEP_DEFAULT_STATUS;
40
+ isNotStarted = isNotStarted && status === _ProgressStep.STATUS_NOT_STARTED;
41
+ isFinished = isFinished && status === _ProgressStep.STATUS_DONE;
42
+ isFinishedWithWarnings = isFinishedWithWarnings && [_ProgressStep.STATUS_DONE, _ProgressStep.STATUS_WARNING].includes(status);
43
+ isFailed = isFailed || status === _ProgressStep.STATUS_ERROR;
43
44
  }
44
45
  });
45
46
  }
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = exports.STATUS_WARNING = exports.STATUS_RUNNING = exports.STATUS_NOT_STARTED = exports.STATUS_ERROR = exports.STATUS_DONE = exports.STATUS_CANCELED = void 0;
7
+ exports.default = exports.STATUS_WARNING = exports.STATUS_RUNNING = exports.STATUS_NOT_STARTED = exports.STATUS_ERROR = exports.STATUS_DONE = exports.STATUS_CANCELED = exports.PROGRESS_STEP_DEFAULT_STATUS = void 0;
8
8
  var _react = require("react");
9
9
  var _classnames = _interopRequireDefault(require("classnames"));
10
10
  var _Icon = _interopRequireWildcard(require("../Icon"));
@@ -23,6 +23,7 @@ const STATUS_DONE = exports.STATUS_DONE = 'done';
23
23
  const STATUS_WARNING = exports.STATUS_WARNING = 'warning';
24
24
  const STATUS_ERROR = exports.STATUS_ERROR = 'error';
25
25
  const STATUS_CANCELED = exports.STATUS_CANCELED = 'canceled';
26
+ const PROGRESS_STEP_DEFAULT_STATUS = exports.PROGRESS_STEP_DEFAULT_STATUS = STATUS_NOT_STARTED;
26
27
  /**
27
28
  * `ProgressStep` is a part of the [Progress](#!/Progress) component.
28
29
  * @since 1.10.0
@@ -34,9 +35,9 @@ const ProgressStep = _ref => {
34
35
  icon,
35
36
  title,
36
37
  statusText,
37
- progress,
38
- status,
39
- baseClassName,
38
+ progress = -1,
39
+ status = PROGRESS_STEP_DEFAULT_STATUS,
40
+ baseClassName = `${_constants.CLS_PREFIX}progress-step`,
40
41
  ...props
41
42
  } = _ref;
42
43
  let intent = null;
@@ -112,14 +113,4 @@ const ProgressStep = _ref => {
112
113
  })]
113
114
  });
114
115
  };
115
- ProgressStep.defaultProps = {
116
- icon: null,
117
- title: null,
118
- status: STATUS_NOT_STARTED,
119
- statusText: null,
120
- progress: -1,
121
- children: null,
122
- className: null,
123
- baseClassName: `${_constants.CLS_PREFIX}progress-step`
124
- };
125
116
  var _default = exports.default = ProgressStep;
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "PROGRESS_STEP_DEFAULT_STATUS", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _ProgressStep.PROGRESS_STEP_DEFAULT_STATUS;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "STATUS_CANCELED", {
7
13
  enumerable: true,
8
14
  get: function () {
@@ -42,21 +42,6 @@ const getErrorsForChildren = (form, children) => {
42
42
  return errors;
43
43
  };
44
44
  const SECTION_BASE_CLASS_NAME = exports.SECTION_BASE_CLASS_NAME = `${_constants.CLS_PREFIX}section`;
45
- const DEFAULT_PROPS = {
46
- title: undefined,
47
- intent: undefined,
48
- collapsible: false,
49
- collapsed: false,
50
- onTitleChange: undefined,
51
- onClose: undefined,
52
- onToggle: undefined,
53
- buttons: undefined,
54
- vertical: undefined,
55
- children: undefined,
56
- className: undefined,
57
- baseClassName: SECTION_BASE_CLASS_NAME,
58
- form: undefined
59
- };
60
45
  class Section extends _react.Component {
61
46
  constructor() {
62
47
  super(...arguments);
@@ -244,18 +229,25 @@ class Section extends _react.Component {
244
229
  * and comprehension of the presented information.
245
230
  * @since 0.0.54
246
231
  */
247
- (0, _defineProperty2.default)(Section, "defaultProps", DEFAULT_PROPS);
248
- const SectionWrapper = props => {
232
+ const SectionWrapper = _ref8 => {
233
+ let {
234
+ collapsible = false,
235
+ collapsed = false,
236
+ baseClassName = SECTION_BASE_CLASS_NAME,
237
+ ...props
238
+ } = _ref8;
249
239
  const form = (0, _react.useContext)(_FormContext.default);
250
240
  const verticalContext = (0, _react.useContext)(_VerticalContext.default);
251
241
  const vertical = props.vertical === undefined ? verticalContext : props.vertical;
252
242
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Section, {
253
243
  ...props,
254
244
  form: form,
255
- vertical: vertical
245
+ vertical: vertical,
246
+ collapsible: collapsible,
247
+ collapsed: collapsed,
248
+ baseClassName: baseClassName
256
249
  });
257
250
  };
258
251
  SectionWrapper.displayName = 'Section';
259
- SectionWrapper.defaultProps = DEFAULT_PROPS;
260
252
  SectionWrapper.WrappedComponent = Section;
261
253
  var _default = exports.default = SectionWrapper;
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
8
  var _classnames = _interopRequireDefault(require("classnames"));
10
9
  var _react = require("react");
11
10
  var _constants = require("../../constants");
@@ -24,109 +23,62 @@ const getMinMax = rows => {
24
23
  maxRows: rows.max
25
24
  };
26
25
  }
27
- return null;
26
+ return {};
28
27
  };
29
- const AVAILABLE_SIZES = ['sm', 'md', 'lg', 'xl', 'fill'];
28
+ const AVAILABLE_SIZES = new Set(['sm', 'md', 'lg', 'xl', 'fill']);
30
29
 
31
30
  /**
32
31
  * `TextArea` is used for entering long text (like email body, descriptions, comments).
33
32
  * @since 1.9.0
34
33
  */
35
-
36
- class TextArea extends _react.Component {
37
- constructor() {
38
- super(...arguments);
39
- (0, _defineProperty2.default)(this, "state", {
40
- textareaStyles: null
41
- });
42
- (0, _defineProperty2.default)(this, "rootRef", /*#__PURE__*/(0, _react.createRef)());
43
- (0, _defineProperty2.default)(this, "handleChange", e => {
44
- const {
45
- autoheight,
46
- onChange
47
- } = this.props;
48
- if (autoheight) {
49
- this.adjustHeight();
50
- }
51
- if (typeof onChange === 'function') {
52
- onChange(e);
53
- }
54
- });
55
- }
56
- static getDerivedStateFromProps(_ref) {
57
- let {
58
- rows
59
- } = _ref;
60
- if (rows) {
61
- return getMinMax(rows);
62
- }
63
- return null;
64
- }
65
- componentDidMount() {
66
- this.adjustHeight();
67
- }
68
- componentDidUpdate(prevProps) {
69
- const {
70
- autoheight
71
- } = this.props;
72
- if (autoheight !== prevProps.autoheight) {
73
- this.adjustHeight();
74
- }
75
- }
76
- adjustHeight() {
77
- const {
78
- autoheight
79
- } = this.props;
80
- if (!autoheight) {
81
- this.setState({
82
- textareaStyles: null
83
- });
34
+ const TextArea = _ref => {
35
+ let {
36
+ baseClassName = `${_constants.CLS_PREFIX}textarea`,
37
+ className,
38
+ rows = 4,
39
+ size = 'md',
40
+ autoheight = false,
41
+ onChange,
42
+ style,
43
+ ...props
44
+ } = _ref;
45
+ const rootRef = (0, _react.useRef)(null);
46
+ const useSizeModifier = size && AVAILABLE_SIZES.has(size);
47
+ const {
48
+ minRows,
49
+ maxRows
50
+ } = getMinMax(rows);
51
+ const [heightStyle, setHeightStyle] = (0, _react.useState)();
52
+ const adjustHeight = (0, _react.useCallback)(() => {
53
+ if (!autoheight || !rootRef.current) {
54
+ setHeightStyle(undefined);
84
55
  return;
85
56
  }
86
- const {
87
- minRows,
88
- maxRows
89
- } = this.state;
90
- if (this.rootRef.current) {
91
- const textareaStyles = (0, _calculateNodeHeight.default)(this.rootRef.current, false, minRows, maxRows);
92
- this.setState({
93
- textareaStyles
94
- });
57
+ setHeightStyle((0, _calculateNodeHeight.default)(rootRef.current, false, minRows, maxRows));
58
+ }, [autoheight, maxRows, minRows]);
59
+ (0, _react.useLayoutEffect)(() => {
60
+ adjustHeight();
61
+ }, [adjustHeight]);
62
+ const handleChange = e => {
63
+ if (autoheight) {
64
+ adjustHeight();
95
65
  }
96
- }
97
- render() {
98
- const {
99
- baseClassName,
100
- className,
101
- rows,
102
- size,
103
- autoheight,
104
- onChange,
105
- ...other
106
- } = this.props;
107
- const {
108
- textareaStyles,
109
- minRows
110
- } = this.state;
111
- const useSizeModifier = size && AVAILABLE_SIZES.indexOf(size) !== -1;
112
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
113
- className: (0, _classnames.default)(baseClassName, {
114
- [`${baseClassName}--size-${size}`]: useSizeModifier
115
- }, className),
116
- ref: this.rootRef,
117
- style: textareaStyles,
118
- onChange: this.handleChange,
119
- rows: minRows,
120
- ...other
121
- });
122
- }
123
- }
124
- (0, _defineProperty2.default)(TextArea, "defaultProps", {
125
- baseClassName: `${_constants.CLS_PREFIX}textarea`,
126
- className: null,
127
- rows: 4,
128
- size: 'md',
129
- autoheight: false,
130
- onChange: null
131
- });
66
+ if (typeof onChange === 'function') {
67
+ onChange(e);
68
+ }
69
+ };
70
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
71
+ ref: rootRef,
72
+ className: (0, _classnames.default)(baseClassName, {
73
+ [`${baseClassName}--size-${size}`]: useSizeModifier
74
+ }, className),
75
+ style: {
76
+ ...style,
77
+ ...heightStyle
78
+ },
79
+ onChange: handleChange,
80
+ rows: minRows,
81
+ ...props
82
+ });
83
+ };
132
84
  var _default = exports.default = TextArea;
@@ -47,8 +47,8 @@ const calculateNodeStyling = function (node) {
47
47
  // eslint-disable-next-line max-params
48
48
  function calculateNodeHeight(uiTextNode) {
49
49
  let useCache = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
50
- let minRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
51
- let maxRows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
50
+ let minRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
51
+ let maxRows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
52
52
  if (!hiddenTextarea) {
53
53
  hiddenTextarea = document.createElement('textarea');
54
54
  document.body.appendChild(hiddenTextarea);
@@ -70,8 +70,8 @@ function calculateNodeHeight(uiTextNode) {
70
70
  // Need to have the overflow attribute to hide the scrollbar otherwise text-lines will not calculated properly as the shadow will technically be narrower for content
71
71
  hiddenTextarea.setAttribute('style', `${sizingStyle};${HIDDEN_TEXTAREA_STYLE}`);
72
72
  hiddenTextarea.value = uiTextNode.value || uiTextNode.placeholder || '';
73
- let minHeight = null;
74
- let maxHeight = null;
73
+ let minHeight = undefined;
74
+ let maxHeight = undefined;
75
75
  let height = hiddenTextarea.scrollHeight;
76
76
  let overflowY;
77
77
  if (boxSizing === 'border-box') {
@@ -81,23 +81,23 @@ function calculateNodeHeight(uiTextNode) {
81
81
  // remove padding, since height = content
82
82
  height = height - paddingSize;
83
83
  }
84
- if (minRows !== null || maxRows !== null) {
84
+ if (minRows !== undefined || maxRows !== undefined) {
85
85
  // measure height of a textarea with a single row
86
86
  hiddenTextarea.value = ' ';
87
87
  const singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
88
- if (minRows !== null) {
88
+ if (minRows !== undefined) {
89
89
  minHeight = singleRowHeight * minRows;
90
90
  if (boxSizing === 'border-box') {
91
91
  minHeight = minHeight + paddingSize + borderSize;
92
92
  }
93
93
  height = Math.max(minHeight, height);
94
94
  }
95
- if (maxRows !== null) {
95
+ if (maxRows !== undefined) {
96
96
  maxHeight = singleRowHeight * maxRows;
97
97
  if (boxSizing === 'border-box') {
98
98
  maxHeight = maxHeight + paddingSize + borderSize;
99
99
  }
100
- overflowY = height > maxHeight ? '' : 'hidden';
100
+ overflowY = height > maxHeight ? undefined : 'hidden';
101
101
  height = Math.min(maxHeight, height);
102
102
  }
103
103
  }