@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
@@ -0,0 +1,67 @@
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
+ import React__default from 'react';
9
+ import PropTypes from 'prop-types';
10
+ import cx from 'classnames';
11
+ import { useId } from '../../internal/useId.js';
12
+ import { usePrefix } from '../../internal/usePrefix.js';
13
+
14
+ var variants = ['on-page', 'disclosed'];
15
+
16
+ function ContainedList(_ref) {
17
+ var action = _ref.action,
18
+ children = _ref.children,
19
+ className = _ref.className,
20
+ _ref$kind = _ref.kind,
21
+ kind = _ref$kind === void 0 ? variants[0] : _ref$kind,
22
+ label = _ref.label;
23
+ var labelId = "".concat(useId('contained-list'), "-header");
24
+ var prefix = usePrefix();
25
+ var classes = cx("".concat(prefix, "--contained-list"), "".concat(prefix, "--contained-list--").concat(kind), className);
26
+ return /*#__PURE__*/React__default.createElement("div", {
27
+ className: classes
28
+ }, /*#__PURE__*/React__default.createElement("div", {
29
+ className: "".concat(prefix, "--contained-list__header")
30
+ }, /*#__PURE__*/React__default.createElement("div", {
31
+ id: labelId,
32
+ className: "".concat(prefix, "--contained-list__label")
33
+ }, label), action && /*#__PURE__*/React__default.createElement("div", {
34
+ className: "".concat(prefix, "--contained-list__action")
35
+ }, action)), /*#__PURE__*/React__default.createElement("ul", {
36
+ "aria-labelledby": labelId
37
+ }, children));
38
+ }
39
+
40
+ ContainedList.propTypes = {
41
+ /**
42
+ * A slot for a possible interactive element to render.
43
+ */
44
+ action: PropTypes.node,
45
+
46
+ /**
47
+ * A collection of ContainedListItems to be rendered in the ContainedList
48
+ */
49
+ children: PropTypes.node,
50
+
51
+ /**
52
+ * Additional CSS class names.
53
+ */
54
+ className: PropTypes.string,
55
+
56
+ /**
57
+ * The kind of ContainedList you want to display
58
+ */
59
+ kind: PropTypes.oneOf(variants),
60
+
61
+ /**
62
+ * A label describing the contained list.
63
+ */
64
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired
65
+ };
66
+
67
+ export { ContainedList as default };
@@ -0,0 +1,76 @@
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
+ import { defineProperty as _defineProperty } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React__default from 'react';
10
+ import PropTypes from 'prop-types';
11
+ import cx from 'classnames';
12
+ import { usePrefix } from '../../../internal/usePrefix.js';
13
+
14
+ function ContainedListItem(_ref) {
15
+ var _classNames;
16
+
17
+ var action = _ref.action,
18
+ children = _ref.children,
19
+ className = _ref.className,
20
+ _ref$disabled = _ref.disabled,
21
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
22
+ onClick = _ref.onClick,
23
+ IconElement = _ref.renderIcon;
24
+ var prefix = usePrefix();
25
+ var isClickable = onClick !== undefined;
26
+ var classes = cx("".concat(prefix, "--contained-list-item"), className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "--contained-list-item--clickable"), isClickable), _defineProperty(_classNames, "".concat(prefix, "--contained-list-item--with-icon"), IconElement), _defineProperty(_classNames, "".concat(prefix, "--contained-list-item--with-action"), action), _classNames));
27
+ var content = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, IconElement && /*#__PURE__*/React__default.createElement("div", {
28
+ className: "".concat(prefix, "--contained-list-item__icon")
29
+ }, /*#__PURE__*/React__default.createElement(IconElement, null)), /*#__PURE__*/React__default.createElement("div", null, children));
30
+ return /*#__PURE__*/React__default.createElement("li", {
31
+ className: classes
32
+ }, isClickable ? /*#__PURE__*/React__default.createElement("button", {
33
+ className: "".concat(prefix, "--contained-list-item__content"),
34
+ type: "button",
35
+ disabled: disabled,
36
+ onClick: onClick
37
+ }, content) : /*#__PURE__*/React__default.createElement("div", {
38
+ className: "".concat(prefix, "--contained-list-item__content")
39
+ }, content), action && /*#__PURE__*/React__default.createElement("div", {
40
+ className: "".concat(prefix, "--contained-list-item__action")
41
+ }, action));
42
+ }
43
+
44
+ ContainedListItem.propTypes = {
45
+ /**
46
+ * A slot for a possible interactive element to render within the item.
47
+ */
48
+ action: PropTypes.node,
49
+
50
+ /**
51
+ * The content of this item. Must not contain any interactive elements. Use props.action to include those.
52
+ */
53
+ children: PropTypes.node,
54
+
55
+ /**
56
+ * Additional CSS class names.
57
+ */
58
+ className: PropTypes.string,
59
+
60
+ /**
61
+ * Whether this item is disabled.
62
+ */
63
+ disabled: PropTypes.bool,
64
+
65
+ /**
66
+ * Provide an optional function to be called when the item is clicked.
67
+ */
68
+ onClick: PropTypes.func,
69
+
70
+ /**
71
+ * Provide an optional icon to render in front of the item's content.
72
+ */
73
+ renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
74
+ };
75
+
76
+ export { ContainedListItem as default };
@@ -0,0 +1,13 @@
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
+ import ContainedList from './ContainedList.js';
9
+ export { default } from './ContainedList.js';
10
+ import ContainedListItem from './ContainedListItem/ContainedListItem.js';
11
+ export { default as ContainedListItem } from './ContainedListItem/ContainedListItem.js';
12
+
13
+ ContainedList.ContainedListItem = ContainedListItem;
@@ -19,7 +19,7 @@ import { defaultSortRow } from './tools/sorting.js';
19
19
  import setupGetInstanceId from './tools/instanceId.js';
20
20
 
21
21
  var _excluded = ["header", "onClick", "isSortable"],
22
- _excluded2 = ["onClick"],
22
+ _excluded2 = ["onClick", "onExpand"],
23
23
  _excluded3 = ["row", "onClick"],
24
24
  _excluded4 = ["onClick", "row"];
25
25
 
@@ -97,6 +97,7 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
97
97
  _defineProperty(_assertThisInitialized(_this), "getExpandHeaderProps", function () {
98
98
  var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
99
99
  onClick = _ref2.onClick,
100
+ onExpand = _ref2.onExpand,
100
101
  rest = _objectWithoutProperties(_ref2, _excluded2);
101
102
 
102
103
  var t = _this.props.translateWithId;
@@ -113,7 +114,7 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
113
114
  isExpanded: isExpanded,
114
115
  // Compose the event handlers so we don't overwrite a consumer's `onClick`
115
116
  // handler
116
- onExpand: composeEventHandlers([_this.handleOnExpandAll, onClick ? _this.handleOnExpandHeaderClick(onClick, {
117
+ onExpand: composeEventHandlers([_this.handleOnExpandAll, onExpand, onClick ? _this.handleOnExpandHeaderClick(onClick, {
117
118
  isExpanded: isExpanded
118
119
  }) : null])
119
120
  });
@@ -44,6 +44,9 @@ var getDerivedStateFromProps = function getDerivedStateFromProps(props, prevStat
44
44
  state.rowIds = _rowIds;
45
45
  }
46
46
 
47
+ state.isExpandedAll = state.rowIds.every(function (id) {
48
+ return state.rowsById[id].isExpanded === true;
49
+ });
47
50
  return state;
48
51
  };
49
52
 
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { useRef } from 'react';
8
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React__default, { useContext, useState, useRef } from 'react';
10
10
  import { useSelect } from 'downshift';
11
11
  import cx from 'classnames';
12
12
  import PropTypes from 'prop-types';
@@ -15,6 +15,7 @@ import '../ListBox/index.js';
15
15
  import mergeRefs from '../../tools/mergeRefs.js';
16
16
  import { useFeatureFlag } from '../FeatureFlags/index.js';
17
17
  import { usePrefix } from '../../internal/usePrefix.js';
18
+ import { FormContext } from '../FluidForm/FormContext.js';
18
19
  import ListBox from '../ListBox/ListBox.js';
19
20
  import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
20
21
 
@@ -60,6 +61,9 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function Dropdown(_ref, re
60
61
 
61
62
  var prefix = usePrefix();
62
63
 
64
+ var _useContext = useContext(FormContext),
65
+ isFluid = _useContext.isFluid;
66
+
63
67
  var selectProps = _objectSpread2(_objectSpread2({}, downshiftProps), {}, {
64
68
  items: items,
65
69
  itemToString: itemToString,
@@ -85,19 +89,26 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function Dropdown(_ref, re
85
89
  var inline = type === 'inline';
86
90
  var showWarning = !invalid && warn;
87
91
  var enabled = useFeatureFlag('enable-v11-release');
92
+
93
+ var _useState = useState(false),
94
+ _useState2 = _slicedToArray(_useState, 2),
95
+ isFocused = _useState2[0],
96
+ setIsFocused = _useState2[1];
97
+
88
98
  var className = cx("".concat(prefix, "--dropdown"), [enabled ? null : containerClassName], (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--dropdown--invalid"), invalid), _defineProperty(_cx, "".concat(prefix, "--dropdown--warning"), showWarning), _defineProperty(_cx, "".concat(prefix, "--dropdown--open"), isOpen), _defineProperty(_cx, "".concat(prefix, "--dropdown--inline"), inline), _defineProperty(_cx, "".concat(prefix, "--dropdown--disabled"), disabled), _defineProperty(_cx, "".concat(prefix, "--dropdown--light"), light), _defineProperty(_cx, "".concat(prefix, "--dropdown--").concat(size), size), _defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _cx));
89
99
  var titleClasses = cx("".concat(prefix, "--label"), (_cx2 = {}, _defineProperty(_cx2, "".concat(prefix, "--label--disabled"), disabled), _defineProperty(_cx2, "".concat(prefix, "--visually-hidden"), hideLabel), _cx2));
90
100
  var helperClasses = cx("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
91
- var wrapperClasses = cx("".concat(prefix, "--dropdown__wrapper"), "".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null], (_cx4 = {}, _defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline"), inline), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline"), inline), _defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline--invalid"), inline && invalid), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline--invalid"), inline && invalid), _cx4)); // needs to be Capitalized for react to render it correctly
101
+ var wrapperClasses = cx("".concat(prefix, "--dropdown__wrapper"), "".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null], (_cx4 = {}, _defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline"), inline), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline"), inline), _defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline--invalid"), inline && invalid), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline--invalid"), inline && invalid), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--fluid--invalid"), isFluid && invalid), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--fluid--focus"), isFluid && isFocused && !isOpen), _cx4)); // needs to be Capitalized for react to render it correctly
92
102
 
93
103
  var ItemToElement = itemToElement;
94
104
  var toggleButtonProps = getToggleButtonProps();
95
- var helper = helperText ? /*#__PURE__*/React__default.createElement("div", {
105
+ var helper = helperText && !isFluid ? /*#__PURE__*/React__default.createElement("div", {
96
106
  className: helperClasses
97
107
  }, helperText) : null;
98
108
 
99
109
  function onSelectedItemChange(_ref2) {
100
110
  var selectedItem = _ref2.selectedItem;
111
+ setIsFocused(false);
101
112
 
102
113
  if (onChange) {
103
114
  onChange({
@@ -109,11 +120,18 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function Dropdown(_ref, re
109
120
  var menuItemOptionRefs = useRef(items.map(function (_) {
110
121
  return /*#__PURE__*/React__default.createRef();
111
122
  }));
123
+
124
+ var handleFocus = function handleFocus(evt) {
125
+ setIsFocused(evt.type === 'focus' ? true : false);
126
+ };
127
+
112
128
  return /*#__PURE__*/React__default.createElement("div", _extends({
113
129
  className: wrapperClasses
114
130
  }, other), titleText && /*#__PURE__*/React__default.createElement("label", _extends({
115
131
  className: titleClasses
116
132
  }, getLabelProps()), titleText), /*#__PURE__*/React__default.createElement(ListBox, {
133
+ onFocus: handleFocus,
134
+ onBlur: handleFocus,
117
135
  "aria-label": ariaLabel,
118
136
  size: size,
119
137
  className: className,
@@ -5,13 +5,22 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default, { useState, useRef } from 'react';
10
10
  import cx from 'classnames';
11
11
  import Search from '../Search/index.js';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
13
+ import { composeEventHandlers } from '../../tools/events.js';
14
+
15
+ var _excluded = ["onBlur", "onChange", "onExpand", "onFocus"];
16
+
17
+ function ExpandableSearch(_ref) {
18
+ var onBlur = _ref.onBlur,
19
+ onChange = _ref.onChange,
20
+ onExpand = _ref.onExpand,
21
+ onFocus = _ref.onFocus,
22
+ props = _objectWithoutProperties(_ref, _excluded);
13
23
 
14
- function ExpandableSearch(props) {
15
24
  var _useState = useState(false),
16
25
  _useState2 = _slicedToArray(_useState, 2),
17
26
  expanded = _useState2[0],
@@ -39,20 +48,24 @@ function ExpandableSearch(props) {
39
48
  }
40
49
  }
41
50
 
51
+ function handleChange(evt) {
52
+ setHasContent(evt.target.value !== '');
53
+ }
54
+
55
+ function handleExpand() {
56
+ var _searchRef$current$fo, _searchRef$current;
57
+
58
+ (_searchRef$current$fo = (_searchRef$current = searchRef.current).focus) === null || _searchRef$current$fo === void 0 ? void 0 : _searchRef$current$fo.call(_searchRef$current);
59
+ }
60
+
42
61
  var classes = cx("".concat(prefix, "--search--expandable"), _defineProperty({}, "".concat(prefix, "--search--expanded"), expanded), props.className);
43
62
  return /*#__PURE__*/React__default.createElement(Search, _extends({}, props, {
44
63
  ref: searchRef,
45
64
  className: classes,
46
- onFocus: handleFocus,
47
- onBlur: handleBlur,
48
- onChange: function onChange(event) {
49
- setHasContent(event.target.value !== '');
50
- },
51
- onExpand: function onExpand() {
52
- var _searchRef$current$fo, _searchRef$current;
53
-
54
- (_searchRef$current$fo = (_searchRef$current = searchRef.current).focus) === null || _searchRef$current$fo === void 0 ? void 0 : _searchRef$current$fo.call(_searchRef$current);
55
- }
65
+ onFocus: composeEventHandlers([onFocus, handleFocus]),
66
+ onBlur: composeEventHandlers([onBlur, handleBlur]),
67
+ onChange: composeEventHandlers([onChange, handleChange]),
68
+ onExpand: composeEventHandlers([onExpand, handleExpand])
56
69
  }));
57
70
  }
58
71
 
@@ -0,0 +1,41 @@
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
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import PropTypes from 'prop-types';
10
+ import React__default from 'react';
11
+ import cx from 'classnames';
12
+ import { usePrefix } from '../../internal/usePrefix.js';
13
+
14
+ var _excluded = ["className"];
15
+
16
+ var FluidDropdownSkeleton = function FluidDropdownSkeleton(_ref) {
17
+ var className = _ref.className,
18
+ rest = _objectWithoutProperties(_ref, _excluded);
19
+
20
+ var prefix = usePrefix();
21
+ var wrapperClasses = cx(className, "".concat(prefix, "--skeleton"), "".concat(prefix, "--list-box"));
22
+ return /*#__PURE__*/React__default.createElement("div", {
23
+ className: "".concat(prefix, "--list-box__wrapper--fluid")
24
+ }, /*#__PURE__*/React__default.createElement("div", _extends({
25
+ className: wrapperClasses
26
+ }, rest), /*#__PURE__*/React__default.createElement("span", {
27
+ className: "".concat(prefix, "--list-box__label")
28
+ }), /*#__PURE__*/React__default.createElement("div", {
29
+ className: "".concat(prefix, "--list-box__field")
30
+ })));
31
+ };
32
+
33
+ FluidDropdownSkeleton.propTypes = {
34
+ /**
35
+ * Specify an optional className to add.
36
+ */
37
+ className: PropTypes.string
38
+ };
39
+ var FluidDropdownSkeleton$1 = FluidDropdownSkeleton;
40
+
41
+ export { FluidDropdownSkeleton$1 as default };
@@ -0,0 +1,140 @@
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
+ import { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import PropTypes from 'prop-types';
10
+ import React__default from 'react';
11
+ import cx from 'classnames';
12
+ import Dropdown from '../Dropdown/Dropdown.js';
13
+ import { usePrefix } from '../../internal/usePrefix.js';
14
+ import { FormContext } from '../FluidForm/FormContext.js';
15
+
16
+ var _excluded = ["className", "isCondensed"];
17
+ var FluidDropdown = /*#__PURE__*/React__default.forwardRef(function FluidDropdown(_ref, ref) {
18
+ var className = _ref.className,
19
+ isCondensed = _ref.isCondensed,
20
+ other = _objectWithoutProperties(_ref, _excluded);
21
+
22
+ var prefix = usePrefix();
23
+ var classNames = cx("".concat(prefix, "--list-box__wrapper--fluid"), className, _defineProperty({}, "".concat(prefix, "--list-box__wrapper--fluid--condensed"), isCondensed));
24
+ return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
25
+ value: {
26
+ isFluid: true
27
+ }
28
+ }, /*#__PURE__*/React__default.createElement(Dropdown, _extends({
29
+ ref: ref,
30
+ className: classNames
31
+ }, other)));
32
+ });
33
+ FluidDropdown.propTypes = {
34
+ /**
35
+ * Specify an optional className to be applied to the outer FluidForm wrapper
36
+ */
37
+ className: PropTypes.string,
38
+
39
+ /**
40
+ * Specify the direction of the dropdown. Can be either top or bottom.
41
+ */
42
+ direction: PropTypes.oneOf(['top', 'bottom']),
43
+
44
+ /**
45
+ * Specify whether the `<input>` should be disabled
46
+ */
47
+ disabled: PropTypes.bool,
48
+
49
+ /**
50
+ * Specify a custom `id` for the `<input>`
51
+ */
52
+ id: PropTypes.string.isRequired,
53
+
54
+ /**
55
+ * Allow users to pass in an arbitrary item or a string (in case their items are an array of strings)
56
+ * from their collection that are pre-selected
57
+ */
58
+ initialSelectedItem: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.number]),
59
+
60
+ /**
61
+ * Specify if the currently selected value is invalid.
62
+ */
63
+ invalid: PropTypes.bool,
64
+
65
+ /**
66
+ * Provide the text that is displayed when the control is in an invalid state
67
+ */
68
+ invalidText: PropTypes.node,
69
+
70
+ /**
71
+ * Specify if the `FluidDropdown` should render its menu items in condensed mode
72
+ */
73
+ isCondensed: PropTypes.bool,
74
+
75
+ /**
76
+ * Function to render items as custom components instead of strings.
77
+ * Defaults to null and is overridden by a getter
78
+ */
79
+ itemToElement: PropTypes.func,
80
+
81
+ /**
82
+ * Helper function passed to downshift that allows the library to render a
83
+ * given item to a string label. By default, it extracts the `label` field
84
+ * from a given item to serve as the item label in the list.
85
+ */
86
+ itemToString: PropTypes.func,
87
+
88
+ /**
89
+ * We try to stay as generic as possible here to allow individuals to pass
90
+ * in a collection of whatever kind of data structure they prefer
91
+ */
92
+ items: PropTypes.array.isRequired,
93
+
94
+ /**
95
+ * Generic `label` that will be used as the textual representation of what
96
+ * this field is for
97
+ */
98
+ label: PropTypes.node.isRequired,
99
+
100
+ /**
101
+ * `onChange` is a utility for this controlled component to communicate to a
102
+ * consuming component what kind of internal state changes are occurring.
103
+ */
104
+ onChange: PropTypes.func,
105
+
106
+ /**
107
+ * An optional callback to render the currently selected item as a react element instead of only
108
+ * as a string.
109
+ */
110
+ renderSelectedItem: PropTypes.func,
111
+
112
+ /**
113
+ * In the case you want to control the dropdown selection entirely.
114
+ */
115
+ selectedItem: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.number]),
116
+
117
+ /**
118
+ * Provide the title text that will be read by a screen reader when
119
+ * visiting this control
120
+ */
121
+ titleText: PropTypes.node,
122
+
123
+ /**
124
+ * Callback function for translating ListBoxMenuIcon SVG title
125
+ */
126
+ translateWithId: PropTypes.func,
127
+
128
+ /**
129
+ * Specify whether the control is currently in warning state
130
+ */
131
+ warn: PropTypes.bool,
132
+
133
+ /**
134
+ * Provide the text that is displayed when the control is in warning state
135
+ */
136
+ warnText: PropTypes.node
137
+ };
138
+ var FluidDropdown$1 = FluidDropdown;
139
+
140
+ export { FluidDropdown$1 as default };
@@ -0,0 +1,42 @@
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
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import PropTypes from 'prop-types';
10
+ import React__default from 'react';
11
+ import cx from 'classnames';
12
+ import { usePrefix } from '../../internal/usePrefix.js';
13
+ import { FormContext } from '../FluidForm/FormContext.js';
14
+
15
+ var _excluded = ["className"];
16
+
17
+ function FluidTextAreaSkeleton(_ref) {
18
+ var className = _ref.className,
19
+ other = _objectWithoutProperties(_ref, _excluded);
20
+
21
+ var prefix = usePrefix();
22
+ return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
23
+ value: {
24
+ isFluid: true
25
+ }
26
+ }, /*#__PURE__*/React__default.createElement("div", _extends({
27
+ className: cx("".concat(prefix, "--form-item ").concat(prefix, "--text-area--fluid__skeleton"), className)
28
+ }, other), /*#__PURE__*/React__default.createElement("span", {
29
+ className: "".concat(prefix, "--label ").concat(prefix, "--skeleton")
30
+ }), /*#__PURE__*/React__default.createElement("div", {
31
+ className: "".concat(prefix, "--skeleton ").concat(prefix, "--text-area")
32
+ })));
33
+ }
34
+
35
+ FluidTextAreaSkeleton.propTypes = {
36
+ /**
37
+ * Specify an optional className to be applied to the outer FluidForm wrapper
38
+ */
39
+ className: PropTypes.string
40
+ };
41
+
42
+ export { FluidTextAreaSkeleton as default };
@@ -0,0 +1,42 @@
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
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import PropTypes from 'prop-types';
10
+ import React__default from 'react';
11
+ import cx from 'classnames';
12
+ import { usePrefix } from '../../internal/usePrefix.js';
13
+ import { FormContext } from '../FluidForm/FormContext.js';
14
+
15
+ var _excluded = ["className"];
16
+
17
+ function FluidTextInputSkeleton(_ref) {
18
+ var className = _ref.className,
19
+ other = _objectWithoutProperties(_ref, _excluded);
20
+
21
+ var prefix = usePrefix();
22
+ return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
23
+ value: {
24
+ isFluid: true
25
+ }
26
+ }, /*#__PURE__*/React__default.createElement("div", _extends({
27
+ className: cx("".concat(prefix, "--form-item ").concat(prefix, "--text-input--fluid__skeleton"), className)
28
+ }, other), /*#__PURE__*/React__default.createElement("span", {
29
+ className: "".concat(prefix, "--label ").concat(prefix, "--skeleton")
30
+ }), /*#__PURE__*/React__default.createElement("div", {
31
+ className: "".concat(prefix, "--skeleton ").concat(prefix, "--text-input")
32
+ })));
33
+ }
34
+
35
+ FluidTextInputSkeleton.propTypes = {
36
+ /**
37
+ * Specify an optional className to be applied to the outer FluidForm wrapper
38
+ */
39
+ className: PropTypes.string
40
+ };
41
+
42
+ export { FluidTextInputSkeleton as default };
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import cx from 'classnames';
10
- import React__default from 'react';
10
+ import React__default, { useContext } from 'react';
11
11
  import PropTypes from 'prop-types';
12
12
  import { ListBoxSize, ListBoxType } from './ListBoxPropTypes.js';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
@@ -16,6 +16,7 @@ import ListBoxMenu from './ListBoxMenu.js';
16
16
  import ListBoxMenuIcon from './ListBoxMenuIcon.js';
17
17
  import ListBoxMenuItem from './ListBoxMenuItem.js';
18
18
  import ListBoxSelection from './ListBoxSelection.js';
19
+ import { FormContext } from '../FluidForm/FormContext.js';
19
20
 
20
21
  var _excluded = ["children", "className", "disabled", "type", "size", "invalid", "invalidText", "warn", "warnText", "light", "isOpen"];
21
22
 
@@ -52,15 +53,21 @@ var ListBox = /*#__PURE__*/React__default.forwardRef(function ListBox(_ref, ref)
52
53
  rest = _objectWithoutProperties(_ref, _excluded);
53
54
 
54
55
  var prefix = usePrefix();
56
+
57
+ var _useContext = useContext(FormContext),
58
+ isFluid = _useContext.isFluid;
59
+
55
60
  var showWarning = !invalid && warn;
56
- var className = cx((_cx = {}, _defineProperty(_cx, containerClassName, !!containerClassName), _defineProperty(_cx, "".concat(prefix, "--list-box"), true), _defineProperty(_cx, "".concat(prefix, "--list-box--").concat(size), size), _defineProperty(_cx, "".concat(prefix, "--list-box--inline"), type === 'inline'), _defineProperty(_cx, "".concat(prefix, "--list-box--disabled"), disabled), _defineProperty(_cx, "".concat(prefix, "--list-box--light"), light), _defineProperty(_cx, "".concat(prefix, "--list-box--expanded"), isOpen), _defineProperty(_cx, "".concat(prefix, "--list-box--warning"), showWarning), _cx));
61
+ var className = cx((_cx = {}, _defineProperty(_cx, containerClassName, !!containerClassName), _defineProperty(_cx, "".concat(prefix, "--list-box"), true), _defineProperty(_cx, "".concat(prefix, "--list-box--").concat(size), size), _defineProperty(_cx, "".concat(prefix, "--list-box--inline"), type === 'inline'), _defineProperty(_cx, "".concat(prefix, "--list-box--disabled"), disabled), _defineProperty(_cx, "".concat(prefix, "--list-box--light"), light), _defineProperty(_cx, "".concat(prefix, "--list-box--expanded"), isOpen), _defineProperty(_cx, "".concat(prefix, "--list-box--invalid"), invalid), _defineProperty(_cx, "".concat(prefix, "--list-box--warning"), showWarning), _cx));
57
62
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
58
63
  className: className,
59
64
  ref: ref,
60
65
  onKeyDown: handleOnKeyDown,
61
66
  onClick: handleClick,
62
67
  "data-invalid": invalid || undefined
63
- }), children), invalid ? /*#__PURE__*/React__default.createElement("div", {
68
+ }), children), isFluid && /*#__PURE__*/React__default.createElement("hr", {
69
+ className: "".concat(prefix, "--list-box__divider")
70
+ }), invalid ? /*#__PURE__*/React__default.createElement("div", {
64
71
  className: "".concat(prefix, "--form-requirement")
65
72
  }, invalidText) : null, showWarning ? /*#__PURE__*/React__default.createElement("div", {
66
73
  className: "".concat(prefix, "--form-requirement")