@carbon/react 1.14.0 → 1.15.0-rc.0

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 (47) hide show
  1. package/es/components/ContainedList/ContainedList.js +67 -0
  2. package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +76 -0
  3. package/es/components/ContainedList/index.js +13 -0
  4. package/es/components/DataTable/DataTable.js +3 -2
  5. package/es/components/DataTable/state/getDerivedStateFromProps.js +3 -0
  6. package/es/components/Dropdown/Dropdown.js +22 -4
  7. package/es/components/ExpandableSearch/ExpandableSearch.js +25 -12
  8. package/es/components/FluidDropdown/FluidDropdown.Skeleton.js +41 -0
  9. package/es/components/FluidDropdown/FluidDropdown.js +140 -0
  10. package/es/components/FluidTextArea/FluidTextArea.Skeleton.js +42 -0
  11. package/es/components/FluidTextInput/FluidTextInput.Skeleton.js +42 -0
  12. package/es/components/ListBox/ListBox.js +10 -3
  13. package/es/components/Loading/Loading.js +8 -10
  14. package/es/components/MultiSelect/FilterableMultiSelect.js +5 -1
  15. package/es/components/Search/Search.js +2 -1
  16. package/es/components/Search/next/Search.js +11 -15
  17. package/es/components/Slider/Slider.js +25 -24
  18. package/es/components/TextInput/TextInput.js +1 -1
  19. package/es/index.js +8 -1
  20. package/lib/components/ContainedList/ContainedList.js +77 -0
  21. package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +86 -0
  22. package/lib/components/ContainedList/index.js +18 -0
  23. package/lib/components/DataTable/DataTable.js +3 -2
  24. package/lib/components/DataTable/state/getDerivedStateFromProps.js +3 -0
  25. package/lib/components/Dropdown/Dropdown.js +20 -2
  26. package/lib/components/ExpandableSearch/ExpandableSearch.js +24 -11
  27. package/lib/components/FluidDropdown/FluidDropdown.Skeleton.js +51 -0
  28. package/lib/components/FluidDropdown/FluidDropdown.js +150 -0
  29. package/lib/components/FluidTextArea/FluidTextArea.Skeleton.js +52 -0
  30. package/lib/components/FluidTextInput/FluidTextInput.Skeleton.js +52 -0
  31. package/lib/components/ListBox/ListBox.js +9 -2
  32. package/lib/components/Loading/Loading.js +8 -10
  33. package/lib/components/MultiSelect/FilterableMultiSelect.js +4 -0
  34. package/lib/components/Search/Search.js +2 -1
  35. package/lib/components/Search/next/Search.js +11 -15
  36. package/lib/components/Slider/Slider.js +25 -24
  37. package/lib/components/TextInput/TextInput.js +1 -1
  38. package/lib/index.js +15 -2
  39. package/package.json +4 -4
  40. package/scss/components/fluid-dropdown/_fluid-dropdown.scss +9 -0
  41. package/scss/components/fluid-dropdown/_index.scss +9 -0
  42. package/scss/components/fluid-list-box/_fluid-list-box.scss +9 -0
  43. package/scss/components/fluid-list-box/_index.scss +9 -0
  44. package/scss/components/fluid-text-area/_fluid-text-area.scss +9 -0
  45. package/scss/components/fluid-text-area/_index.scss +9 -0
  46. package/scss/components/fluid-text-input/_fluid-text-input.scss +9 -0
  47. package/scss/components/fluid-text-input/_index.scss +9 -0
@@ -17,11 +17,15 @@ var _excluded = ["active", "className", "withOverlay", "small", "description"];
17
17
  function Loading(_ref) {
18
18
  var _cx, _cx2;
19
19
 
20
- var active = _ref.active,
20
+ var _ref$active = _ref.active,
21
+ active = _ref$active === void 0 ? true : _ref$active,
21
22
  customClassName = _ref.className,
22
- withOverlay = _ref.withOverlay,
23
- small = _ref.small,
24
- description = _ref.description,
23
+ _ref$withOverlay = _ref.withOverlay,
24
+ withOverlay = _ref$withOverlay === void 0 ? true : _ref$withOverlay,
25
+ _ref$small = _ref.small,
26
+ small = _ref$small === void 0 ? false : _ref$small,
27
+ _ref$description = _ref.description,
28
+ description = _ref$description === void 0 ? 'loading' : _ref$description,
25
29
  rest = _objectWithoutProperties(_ref, _excluded);
26
30
 
27
31
  var prefix = usePrefix();
@@ -81,11 +85,5 @@ Loading.propTypes = {
81
85
  */
82
86
  withOverlay: PropTypes.bool
83
87
  };
84
- Loading.defaultProps = {
85
- active: true,
86
- withOverlay: true,
87
- small: false,
88
- description: 'loading'
89
- };
90
88
 
91
89
  export { Loading as default };
@@ -27,7 +27,7 @@ import ListBoxSelection from '../ListBox/next/ListBoxSelection.js';
27
27
  import ListBoxTrigger from '../ListBox/next/ListBoxTrigger.js';
28
28
  import ListBox from '../ListBox/ListBox.js';
29
29
  import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
30
- import { Space } from '../../internal/keyboard/keys.js';
30
+ import { Space, Tab } from '../../internal/keyboard/keys.js';
31
31
 
32
32
  var FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function FilterableMultiSelect(_ref, ref) {
33
33
  var _cx, _cx2, _cx3, _cx4;
@@ -280,6 +280,10 @@ var FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Filt
280
280
  if (match(event, Space)) {
281
281
  event.stopPropagation();
282
282
  }
283
+
284
+ if (match(event, Tab)) {
285
+ handleOnMenuChange(false);
286
+ }
283
287
  },
284
288
  onFocus: function onFocus() {
285
289
  setInputFocused(true);
@@ -19,7 +19,7 @@ import { Escape } from '../../internal/keyboard/keys.js';
19
19
 
20
20
  var _Close;
21
21
 
22
- var _excluded = ["className", "type", "id", "placeHolderText", "placeholder", "labelText", "closeButtonLabelText", "small", "size", "light", "disabled", "onChange", "onKeyDown", "renderIcon", "onClear"];
22
+ var _excluded = ["className", "type", "id", "placeHolderText", "placeholder", "labelText", "closeButtonLabelText", "small", "size", "light", "disabled", "onChange", "onKeyDown", "renderIcon", "onClear", "onExpand"];
23
23
 
24
24
  var Search = /*#__PURE__*/function (_Component) {
25
25
  _inherits(Search, _Component);
@@ -104,6 +104,7 @@ var Search = /*#__PURE__*/function (_Component) {
104
104
  onKeyDown = _this$props.onKeyDown,
105
105
  renderIcon = _this$props.renderIcon;
106
106
  _this$props.onClear;
107
+ _this$props.onExpand;
107
108
  var other = _objectWithoutProperties(_this$props, _excluded);
108
109
 
109
110
  var hasContent = this.state.hasContent;
@@ -78,19 +78,19 @@ var Search = /*#__PURE__*/React__default.forwardRef(function Search(_ref, forwar
78
78
  setPrevValue(value);
79
79
  }
80
80
 
81
- function clearInput(event) {
81
+ function clearInput() {
82
82
  if (!value) {
83
83
  inputRef.current.value = '';
84
- onChange(event);
85
- } else {
86
- var clearedEvt = Object.assign({}, event.target, {
87
- target: {
88
- value: ''
89
- }
90
- });
91
- onChange(clearedEvt);
92
84
  }
93
85
 
86
+ var inputTarget = Object.assign({}, inputRef.current, {
87
+ value: ''
88
+ });
89
+ var clearedEvt = {
90
+ target: inputTarget,
91
+ type: 'change'
92
+ };
93
+ onChange(clearedEvt);
94
94
  onClear();
95
95
  setHasContent(false);
96
96
  focus(inputRef);
@@ -103,7 +103,7 @@ var Search = /*#__PURE__*/React__default.forwardRef(function Search(_ref, forwar
103
103
  function handleKeyDown(event) {
104
104
  if (match(event, Escape)) {
105
105
  event.stopPropagation();
106
- clearInput(event);
106
+ clearInput();
107
107
  }
108
108
  }
109
109
 
@@ -114,11 +114,7 @@ var Search = /*#__PURE__*/React__default.forwardRef(function Search(_ref, forwar
114
114
  }, /*#__PURE__*/React__default.createElement("div", {
115
115
  role: onExpand ? 'button' : null,
116
116
  className: "".concat(prefix, "--search-magnifier"),
117
- onClick: function onClick() {
118
- if (onExpand) {
119
- onExpand();
120
- }
121
- }
117
+ onClick: onExpand
122
118
  }, /*#__PURE__*/React__default.createElement(CustomSearchIcon, {
123
119
  icon: renderIcon
124
120
  })), /*#__PURE__*/React__default.createElement("label", {
@@ -206,13 +206,14 @@ var Slider = /*#__PURE__*/function (_PureComponent) {
206
206
 
207
207
  _this.setState({
208
208
  value: value,
209
- left: left,
210
- needsOnRelease: true
209
+ left: left
211
210
  });
212
211
  }
213
212
  });
214
213
 
215
214
  _defineProperty(_assertThisInitialized(_this), "onBlur", function (evt) {
215
+ var _this$props$onBlur, _this$props;
216
+
216
217
  // Do nothing if we have no valid event, target, or value
217
218
  if (!evt || !('target' in evt) || typeof evt.target.value !== 'string') {
218
219
  return;
@@ -226,7 +227,7 @@ var Slider = /*#__PURE__*/function (_PureComponent) {
226
227
  isValid: validity
227
228
  });
228
229
 
229
- _this.props.onBlur({
230
+ (_this$props$onBlur = (_this$props = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props, {
230
231
  value: value
231
232
  });
232
233
  });
@@ -377,27 +378,27 @@ var Slider = /*#__PURE__*/function (_PureComponent) {
377
378
  value: function render() {
378
379
  var _this2 = this;
379
380
 
380
- var _this$props = this.props,
381
- ariaLabelInput = _this$props.ariaLabelInput,
382
- className = _this$props.className,
383
- hideTextInput = _this$props.hideTextInput,
384
- _this$props$id = _this$props.id,
385
- id = _this$props$id === void 0 ? this.inputId = this.inputId || "__carbon-slider_".concat(Math.random().toString(36).substr(2)) : _this$props$id,
386
- min = _this$props.min,
387
- minLabel = _this$props.minLabel,
388
- max = _this$props.max,
389
- maxLabel = _this$props.maxLabel,
390
- _this$props$formatLab = _this$props.formatLabel,
391
- formatLabel = _this$props$formatLab === void 0 ? defaultFormatLabel : _this$props$formatLab,
392
- labelText = _this$props.labelText,
393
- step = _this$props.step;
394
- _this$props.stepMultiplier;
395
- var inputType = _this$props.inputType,
396
- required = _this$props.required,
397
- disabled = _this$props.disabled,
398
- name = _this$props.name,
399
- light = _this$props.light,
400
- other = _objectWithoutProperties(_this$props, _excluded);
381
+ var _this$props2 = this.props,
382
+ ariaLabelInput = _this$props2.ariaLabelInput,
383
+ className = _this$props2.className,
384
+ hideTextInput = _this$props2.hideTextInput,
385
+ _this$props2$id = _this$props2.id,
386
+ id = _this$props2$id === void 0 ? this.inputId = this.inputId || "__carbon-slider_".concat(Math.random().toString(36).substr(2)) : _this$props2$id,
387
+ min = _this$props2.min,
388
+ minLabel = _this$props2.minLabel,
389
+ max = _this$props2.max,
390
+ maxLabel = _this$props2.maxLabel,
391
+ _this$props2$formatLa = _this$props2.formatLabel,
392
+ formatLabel = _this$props2$formatLa === void 0 ? defaultFormatLabel : _this$props2$formatLa,
393
+ labelText = _this$props2.labelText,
394
+ step = _this$props2.step;
395
+ _this$props2.stepMultiplier;
396
+ var inputType = _this$props2.inputType,
397
+ required = _this$props2.required,
398
+ disabled = _this$props2.disabled,
399
+ name = _this$props2.name,
400
+ light = _this$props2.light,
401
+ other = _objectWithoutProperties(_this$props2, _excluded);
401
402
 
402
403
  delete other.onRelease;
403
404
  delete other.invalid;
@@ -219,7 +219,7 @@ TextInput.propTypes = {
219
219
  light: PropTypes.bool,
220
220
 
221
221
  /**
222
- * Max character count allowed for the textarea. This is needed in order for enableCounter to display
222
+ * Max character count allowed for the input. This is needed in order for enableCounter to display
223
223
  */
224
224
  maxCount: PropTypes.number,
225
225
 
package/es/index.js CHANGED
@@ -92,6 +92,7 @@ export { default as TabsSkeleton } from './components/Tabs/Tabs.Skeleton.js';
92
92
  export { default as TextInputSkeleton } from './components/TextInput/TextInput.Skeleton.js';
93
93
  export { default as ToggleSmallSkeleton } from './components/ToggleSmall/ToggleSmall.Skeleton.js';
94
94
  export { default as IconSkeleton } from './components/Icon/Icon.Skeleton.js';
95
+ import './components/ContainedList/index.js';
95
96
  export { FeatureFlags as unstable_FeatureFlags, useFeatureFlag as unstable_useFeatureFlag, useFeatureFlags as unstable_useFeatureFlags } from './components/FeatureFlags/index.js';
96
97
  export { Heading, Section } from './components/Heading/index.js';
97
98
  export { IconButton } from './components/IconButton/index.js';
@@ -120,9 +121,12 @@ export { default as SideNavFooter } from './components/UIShell/SideNavFooter.js'
120
121
  export { default as SideNavIcon } from './components/UIShell/SideNavIcon.js';
121
122
  export { default as SideNavItem } from './components/UIShell/SideNavItem.js';
122
123
  export { default as SideNavLinkText } from './components/UIShell/SideNavLinkText.js';
124
+ export { default as unstable_ContainedListItem } from './components/ContainedList/ContainedListItem/ContainedListItem.js';
123
125
  export { default as unstable_useContextMenu } from './components/ContextMenu/useContextMenu.js';
124
- export { default as unstable__FluidTextInput } from './components/FluidTextInput/FluidTextInput.js';
125
126
  export { default as unstable__FluidTextArea } from './components/FluidTextArea/FluidTextArea.js';
127
+ export { default as unstable__FluidTextAreaSkeleton } from './components/FluidTextArea/FluidTextArea.Skeleton.js';
128
+ export { default as unstable__FluidTextInput } from './components/FluidTextInput/FluidTextInput.js';
129
+ export { default as unstable__FluidTextInputSkeleton } from './components/FluidTextInput/FluidTextInput.Skeleton.js';
126
130
  export { default as unstable_MenuDivider } from './components/Menu/MenuDivider.js';
127
131
  export { default as unstable_MenuGroup } from './components/Menu/MenuGroup.js';
128
132
  export { default as unstable_MenuItem } from './components/Menu/MenuItem.js';
@@ -134,6 +138,7 @@ export { default as ProgressBar } from './components/ProgressBar/ProgressBar.js'
134
138
  export { default as MultiSelect } from './components/MultiSelect/MultiSelect.js';
135
139
  export { default as TextInput } from './components/TextInput/TextInput.js';
136
140
  export { default as TreeView } from './components/TreeView/TreeView.js';
141
+ export { default as unstable_ContainedList } from './components/ContainedList/ContainedList.js';
137
142
  export { default as unstable_Menu } from './components/Menu/Menu.js';
138
143
  export { default as Breadcrumb } from './components/Breadcrumb/Breadcrumb.js';
139
144
  export { default as BreadcrumbItem } from './components/Breadcrumb/BreadcrumbItem.js';
@@ -194,6 +199,8 @@ export { default as SideNavLink } from './components/UIShell/SideNavLink.js';
194
199
  export { SideNavMenu } from './components/UIShell/SideNavMenu.js';
195
200
  export { default as SideNavMenuItem } from './components/UIShell/SideNavMenuItem.js';
196
201
  export { default as SideNavSwitcher } from './components/UIShell/SideNavSwitcher.js';
202
+ export { default as unstable__FluidDropdown } from './components/FluidDropdown/FluidDropdown.js';
203
+ export { default as unstable__FluidDropdownSkeleton } from './components/FluidDropdown/FluidDropdown.Skeleton.js';
197
204
  export { LayoutDirection as unstable_LayoutDirection } from './components/Layout/LayoutDirection.js';
198
205
  export { useLayoutDirection as unstable_useLayoutDirection } from './components/Layout/useLayoutDirection.js';
199
206
  export { Stack } from './components/Stack/Stack.js';
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var React = require('react');
13
+ var PropTypes = require('prop-types');
14
+ var cx = require('classnames');
15
+ var useId = require('../../internal/useId.js');
16
+ var usePrefix = require('../../internal/usePrefix.js');
17
+
18
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
+
20
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
21
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
22
+ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
23
+
24
+ var variants = ['on-page', 'disclosed'];
25
+
26
+ function ContainedList(_ref) {
27
+ var action = _ref.action,
28
+ children = _ref.children,
29
+ className = _ref.className,
30
+ _ref$kind = _ref.kind,
31
+ kind = _ref$kind === void 0 ? variants[0] : _ref$kind,
32
+ label = _ref.label;
33
+ var labelId = "".concat(useId.useId('contained-list'), "-header");
34
+ var prefix = usePrefix.usePrefix();
35
+ var classes = cx__default["default"]("".concat(prefix, "--contained-list"), "".concat(prefix, "--contained-list--").concat(kind), className);
36
+ return /*#__PURE__*/React__default["default"].createElement("div", {
37
+ className: classes
38
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
39
+ className: "".concat(prefix, "--contained-list__header")
40
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
41
+ id: labelId,
42
+ className: "".concat(prefix, "--contained-list__label")
43
+ }, label), action && /*#__PURE__*/React__default["default"].createElement("div", {
44
+ className: "".concat(prefix, "--contained-list__action")
45
+ }, action)), /*#__PURE__*/React__default["default"].createElement("ul", {
46
+ "aria-labelledby": labelId
47
+ }, children));
48
+ }
49
+
50
+ ContainedList.propTypes = {
51
+ /**
52
+ * A slot for a possible interactive element to render.
53
+ */
54
+ action: PropTypes__default["default"].node,
55
+
56
+ /**
57
+ * A collection of ContainedListItems to be rendered in the ContainedList
58
+ */
59
+ children: PropTypes__default["default"].node,
60
+
61
+ /**
62
+ * Additional CSS class names.
63
+ */
64
+ className: PropTypes__default["default"].string,
65
+
66
+ /**
67
+ * The kind of ContainedList you want to display
68
+ */
69
+ kind: PropTypes__default["default"].oneOf(variants),
70
+
71
+ /**
72
+ * A label describing the contained list.
73
+ */
74
+ label: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]).isRequired
75
+ };
76
+
77
+ exports["default"] = ContainedList;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
13
+ var React = require('react');
14
+ var PropTypes = require('prop-types');
15
+ var cx = require('classnames');
16
+ var usePrefix = require('../../../internal/usePrefix.js');
17
+
18
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
+
20
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
21
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
22
+ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
23
+
24
+ function ContainedListItem(_ref) {
25
+ var _classNames;
26
+
27
+ var action = _ref.action,
28
+ children = _ref.children,
29
+ className = _ref.className,
30
+ _ref$disabled = _ref.disabled,
31
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
32
+ onClick = _ref.onClick,
33
+ IconElement = _ref.renderIcon;
34
+ var prefix = usePrefix.usePrefix();
35
+ var isClickable = onClick !== undefined;
36
+ var classes = cx__default["default"]("".concat(prefix, "--contained-list-item"), className, (_classNames = {}, _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--contained-list-item--clickable"), isClickable), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--contained-list-item--with-icon"), IconElement), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--contained-list-item--with-action"), action), _classNames));
37
+ var content = /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, IconElement && /*#__PURE__*/React__default["default"].createElement("div", {
38
+ className: "".concat(prefix, "--contained-list-item__icon")
39
+ }, /*#__PURE__*/React__default["default"].createElement(IconElement, null)), /*#__PURE__*/React__default["default"].createElement("div", null, children));
40
+ return /*#__PURE__*/React__default["default"].createElement("li", {
41
+ className: classes
42
+ }, isClickable ? /*#__PURE__*/React__default["default"].createElement("button", {
43
+ className: "".concat(prefix, "--contained-list-item__content"),
44
+ type: "button",
45
+ disabled: disabled,
46
+ onClick: onClick
47
+ }, content) : /*#__PURE__*/React__default["default"].createElement("div", {
48
+ className: "".concat(prefix, "--contained-list-item__content")
49
+ }, content), action && /*#__PURE__*/React__default["default"].createElement("div", {
50
+ className: "".concat(prefix, "--contained-list-item__action")
51
+ }, action));
52
+ }
53
+
54
+ ContainedListItem.propTypes = {
55
+ /**
56
+ * A slot for a possible interactive element to render within the item.
57
+ */
58
+ action: PropTypes__default["default"].node,
59
+
60
+ /**
61
+ * The content of this item. Must not contain any interactive elements. Use props.action to include those.
62
+ */
63
+ children: PropTypes__default["default"].node,
64
+
65
+ /**
66
+ * Additional CSS class names.
67
+ */
68
+ className: PropTypes__default["default"].string,
69
+
70
+ /**
71
+ * Whether this item is disabled.
72
+ */
73
+ disabled: PropTypes__default["default"].bool,
74
+
75
+ /**
76
+ * Provide an optional function to be called when the item is clicked.
77
+ */
78
+ onClick: PropTypes__default["default"].func,
79
+
80
+ /**
81
+ * Provide an optional icon to render in front of the item's content.
82
+ */
83
+ renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object])
84
+ };
85
+
86
+ exports["default"] = ContainedListItem;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var ContainedList = require('./ContainedList.js');
13
+ var ContainedListItem = require('./ContainedListItem/ContainedListItem.js');
14
+
15
+ ContainedList["default"].ContainedListItem = ContainedListItem["default"];
16
+
17
+ exports["default"] = ContainedList["default"];
18
+ exports.ContainedListItem = ContainedListItem["default"];
@@ -29,7 +29,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
29
29
  var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
30
30
 
31
31
  var _excluded = ["header", "onClick", "isSortable"],
32
- _excluded2 = ["onClick"],
32
+ _excluded2 = ["onClick", "onExpand"],
33
33
  _excluded3 = ["row", "onClick"],
34
34
  _excluded4 = ["onClick", "row"];
35
35
 
@@ -107,6 +107,7 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
107
107
  _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "getExpandHeaderProps", function () {
108
108
  var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
109
109
  onClick = _ref2.onClick,
110
+ onExpand = _ref2.onExpand,
110
111
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref2, _excluded2);
111
112
 
112
113
  var t = _this.props.translateWithId;
@@ -123,7 +124,7 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
123
124
  isExpanded: isExpanded,
124
125
  // Compose the event handlers so we don't overwrite a consumer's `onClick`
125
126
  // handler
126
- onExpand: events.composeEventHandlers([_this.handleOnExpandAll, onClick ? _this.handleOnExpandHeaderClick(onClick, {
127
+ onExpand: events.composeEventHandlers([_this.handleOnExpandAll, onExpand, onClick ? _this.handleOnExpandHeaderClick(onClick, {
127
128
  isExpanded: isExpanded
128
129
  }) : null])
129
130
  });
@@ -48,6 +48,9 @@ var getDerivedStateFromProps = function getDerivedStateFromProps(props, prevStat
48
48
  state.rowIds = _rowIds;
49
49
  }
50
50
 
51
+ state.isExpandedAll = state.rowIds.every(function (id) {
52
+ return state.rowsById[id].isExpanded === true;
53
+ });
51
54
  return state;
52
55
  };
53
56
 
@@ -19,6 +19,7 @@ require('../ListBox/index.js');
19
19
  var mergeRefs = require('../../tools/mergeRefs.js');
20
20
  var index = require('../FeatureFlags/index.js');
21
21
  var usePrefix = require('../../internal/usePrefix.js');
22
+ var FormContext = require('../FluidForm/FormContext.js');
22
23
  var ListBox = require('../ListBox/ListBox.js');
23
24
  var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
24
25
 
@@ -70,6 +71,9 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function Dropdo
70
71
 
71
72
  var prefix = usePrefix.usePrefix();
72
73
 
74
+ var _useContext = React.useContext(FormContext.FormContext),
75
+ isFluid = _useContext.isFluid;
76
+
73
77
  var selectProps = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, downshiftProps), {}, {
74
78
  items: items,
75
79
  itemToString: itemToString,
@@ -95,19 +99,26 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function Dropdo
95
99
  var inline = type === 'inline';
96
100
  var showWarning = !invalid && warn;
97
101
  var enabled = index.useFeatureFlag('enable-v11-release');
102
+
103
+ var _useState = React.useState(false),
104
+ _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
105
+ isFocused = _useState2[0],
106
+ setIsFocused = _useState2[1];
107
+
98
108
  var className = cx__default["default"]("".concat(prefix, "--dropdown"), [enabled ? null : containerClassName], (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--warning"), showWarning), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--open"), isOpen), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--light"), light), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--").concat(size), size), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _cx));
99
109
  var titleClasses = cx__default["default"]("".concat(prefix, "--label"), (_cx2 = {}, _rollupPluginBabelHelpers.defineProperty(_cx2, "".concat(prefix, "--label--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_cx2, "".concat(prefix, "--visually-hidden"), hideLabel), _cx2));
100
110
  var helperClasses = cx__default["default"]("".concat(prefix, "--form__helper-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
101
- var wrapperClasses = cx__default["default"]("".concat(prefix, "--dropdown__wrapper"), "".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null], (_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline--invalid"), inline && invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline--invalid"), inline && invalid), _cx4)); // needs to be Capitalized for react to render it correctly
111
+ var wrapperClasses = cx__default["default"]("".concat(prefix, "--dropdown__wrapper"), "".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null], (_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline--invalid"), inline && invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline--invalid"), inline && invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--fluid--invalid"), isFluid && invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--fluid--focus"), isFluid && isFocused && !isOpen), _cx4)); // needs to be Capitalized for react to render it correctly
102
112
 
103
113
  var ItemToElement = itemToElement;
104
114
  var toggleButtonProps = getToggleButtonProps();
105
- var helper = helperText ? /*#__PURE__*/React__default["default"].createElement("div", {
115
+ var helper = helperText && !isFluid ? /*#__PURE__*/React__default["default"].createElement("div", {
106
116
  className: helperClasses
107
117
  }, helperText) : null;
108
118
 
109
119
  function onSelectedItemChange(_ref2) {
110
120
  var selectedItem = _ref2.selectedItem;
121
+ setIsFocused(false);
111
122
 
112
123
  if (onChange) {
113
124
  onChange({
@@ -119,11 +130,18 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function Dropdo
119
130
  var menuItemOptionRefs = React.useRef(items.map(function (_) {
120
131
  return /*#__PURE__*/React__default["default"].createRef();
121
132
  }));
133
+
134
+ var handleFocus = function handleFocus(evt) {
135
+ setIsFocused(evt.type === 'focus' ? true : false);
136
+ };
137
+
122
138
  return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
123
139
  className: wrapperClasses
124
140
  }, other), titleText && /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
125
141
  className: titleClasses
126
142
  }, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(ListBox["default"], {
143
+ onFocus: handleFocus,
144
+ onBlur: handleFocus,
127
145
  "aria-label": ariaLabel,
128
146
  size: size,
129
147
  className: className,
@@ -14,13 +14,22 @@ var React = require('react');
14
14
  var cx = require('classnames');
15
15
  var index = require('../Search/index.js');
16
16
  var usePrefix = require('../../internal/usePrefix.js');
17
+ var events = require('../../tools/events.js');
17
18
 
18
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
20
 
20
21
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
21
22
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
22
23
 
23
- function ExpandableSearch(props) {
24
+ var _excluded = ["onBlur", "onChange", "onExpand", "onFocus"];
25
+
26
+ function ExpandableSearch(_ref) {
27
+ var onBlur = _ref.onBlur,
28
+ onChange = _ref.onChange,
29
+ onExpand = _ref.onExpand,
30
+ onFocus = _ref.onFocus,
31
+ props = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
32
+
24
33
  var _useState = React.useState(false),
25
34
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
26
35
  expanded = _useState2[0],
@@ -48,20 +57,24 @@ function ExpandableSearch(props) {
48
57
  }
49
58
  }
50
59
 
60
+ function handleChange(evt) {
61
+ setHasContent(evt.target.value !== '');
62
+ }
63
+
64
+ function handleExpand() {
65
+ var _searchRef$current$fo, _searchRef$current;
66
+
67
+ (_searchRef$current$fo = (_searchRef$current = searchRef.current).focus) === null || _searchRef$current$fo === void 0 ? void 0 : _searchRef$current$fo.call(_searchRef$current);
68
+ }
69
+
51
70
  var classes = cx__default["default"]("".concat(prefix, "--search--expandable"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--search--expanded"), expanded), props.className);
52
71
  return /*#__PURE__*/React__default["default"].createElement(index["default"], _rollupPluginBabelHelpers["extends"]({}, props, {
53
72
  ref: searchRef,
54
73
  className: classes,
55
- onFocus: handleFocus,
56
- onBlur: handleBlur,
57
- onChange: function onChange(event) {
58
- setHasContent(event.target.value !== '');
59
- },
60
- onExpand: function onExpand() {
61
- var _searchRef$current$fo, _searchRef$current;
62
-
63
- (_searchRef$current$fo = (_searchRef$current = searchRef.current).focus) === null || _searchRef$current$fo === void 0 ? void 0 : _searchRef$current$fo.call(_searchRef$current);
64
- }
74
+ onFocus: events.composeEventHandlers([onFocus, handleFocus]),
75
+ onBlur: events.composeEventHandlers([onBlur, handleBlur]),
76
+ onChange: events.composeEventHandlers([onChange, handleChange]),
77
+ onExpand: events.composeEventHandlers([onExpand, handleExpand])
65
78
  }));
66
79
  }
67
80
 
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
+ var PropTypes = require('prop-types');
14
+ var React = require('react');
15
+ var cx = require('classnames');
16
+ var usePrefix = require('../../internal/usePrefix.js');
17
+
18
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
+
20
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
21
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
+ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
23
+
24
+ var _excluded = ["className"];
25
+
26
+ var FluidDropdownSkeleton = function FluidDropdownSkeleton(_ref) {
27
+ var className = _ref.className,
28
+ rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
29
+
30
+ var prefix = usePrefix.usePrefix();
31
+ var wrapperClasses = cx__default["default"](className, "".concat(prefix, "--skeleton"), "".concat(prefix, "--list-box"));
32
+ return /*#__PURE__*/React__default["default"].createElement("div", {
33
+ className: "".concat(prefix, "--list-box__wrapper--fluid")
34
+ }, /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
35
+ className: wrapperClasses
36
+ }, rest), /*#__PURE__*/React__default["default"].createElement("span", {
37
+ className: "".concat(prefix, "--list-box__label")
38
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
39
+ className: "".concat(prefix, "--list-box__field")
40
+ })));
41
+ };
42
+
43
+ FluidDropdownSkeleton.propTypes = {
44
+ /**
45
+ * Specify an optional className to add.
46
+ */
47
+ className: PropTypes__default["default"].string
48
+ };
49
+ var FluidDropdownSkeleton$1 = FluidDropdownSkeleton;
50
+
51
+ exports["default"] = FluidDropdownSkeleton$1;