@carbon/react 1.7.0 → 1.9.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 (87) hide show
  1. package/es/components/ComposedModal/ComposedModal.js +1 -1
  2. package/es/components/ComposedModal/index.js +4 -4
  3. package/es/components/ComposedModal/next/ComposedModal.js +1 -1
  4. package/es/components/DataTable/DataTable.js +1 -1
  5. package/es/components/DataTable/Table.js +10 -2
  6. package/es/components/DataTable/TableContainer.js +20 -5
  7. package/es/components/DataTable/TableContext.js +15 -0
  8. package/es/components/DataTable/TableSelectRow.js +1 -1
  9. package/es/components/FileUploader/FileUploader.js +8 -1
  10. package/es/components/FileUploader/FileUploaderButton.js +3 -1
  11. package/es/components/FileUploader/FileUploaderDropContainer.js +3 -1
  12. package/es/components/FileUploader/FileUploaderItem.js +3 -1
  13. package/es/components/InlineLoading/InlineLoading.js +9 -5
  14. package/es/components/Loading/Loading.js +7 -18
  15. package/es/components/Menu/Menu.js +1 -1
  16. package/es/components/Modal/Modal.js +204 -273
  17. package/es/components/Modal/index.js +2 -8
  18. package/es/components/ModalWrapper/ModalWrapper.js +1 -1
  19. package/es/components/MultiSelect/FilterableMultiSelect.js +345 -386
  20. package/es/components/MultiSelect/index.js +4 -8
  21. package/es/components/Notification/Notification.js +322 -189
  22. package/es/components/NumberInput/NumberInput.Skeleton.js +3 -4
  23. package/es/components/NumberInput/NumberInput.js +308 -359
  24. package/es/components/RadioButton/RadioButton.js +58 -99
  25. package/es/components/RadioButton/index.js +2 -8
  26. package/es/components/RadioButtonGroup/RadioButtonGroup.js +72 -121
  27. package/es/components/RadioButtonGroup/index.js +2 -8
  28. package/es/components/Slider/Slider.js +2 -1
  29. package/es/components/Switch/Switch.js +0 -1
  30. package/es/components/TreeView/TreeView.js +19 -11
  31. package/es/components/UIShell/HeaderMenu.js +1 -1
  32. package/es/components/UIShell/HeaderMenuButton.js +4 -0
  33. package/es/components/UIShell/SideNavLink.js +6 -9
  34. package/es/index.js +10 -9
  35. package/es/internal/createClassWrapper.js +2 -5
  36. package/lib/components/ComposedModal/index.js +7 -7
  37. package/lib/components/ComposedModal/next/ComposedModal.js +1 -1
  38. package/lib/components/DataTable/DataTable.js +5 -5
  39. package/lib/components/DataTable/Table.js +9 -1
  40. package/lib/components/DataTable/TableContainer.js +19 -4
  41. package/lib/components/DataTable/TableContext.js +19 -0
  42. package/lib/components/DataTable/TableSelectRow.js +2 -2
  43. package/lib/components/FileUploader/FileUploader.js +8 -1
  44. package/lib/components/FileUploader/FileUploaderButton.js +3 -1
  45. package/lib/components/FileUploader/FileUploaderDropContainer.js +3 -1
  46. package/lib/components/FileUploader/FileUploaderItem.js +3 -1
  47. package/lib/components/InlineLoading/InlineLoading.js +9 -5
  48. package/lib/components/Loading/Loading.js +6 -17
  49. package/lib/components/Menu/Menu.js +1 -1
  50. package/lib/components/Modal/Modal.js +201 -270
  51. package/lib/components/Modal/index.js +2 -25
  52. package/lib/components/ModalWrapper/ModalWrapper.js +2 -2
  53. package/lib/components/MultiSelect/FilterableMultiSelect.js +341 -382
  54. package/lib/components/MultiSelect/index.js +5 -28
  55. package/lib/components/Notification/Notification.js +321 -188
  56. package/lib/components/NumberInput/NumberInput.Skeleton.js +3 -4
  57. package/lib/components/NumberInput/NumberInput.js +305 -376
  58. package/lib/components/RadioButton/RadioButton.js +57 -99
  59. package/lib/components/RadioButton/index.js +2 -25
  60. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +68 -117
  61. package/lib/components/RadioButtonGroup/index.js +2 -25
  62. package/lib/components/Slider/Slider.js +2 -1
  63. package/lib/components/Switch/Switch.js +0 -1
  64. package/lib/components/TreeView/TreeView.js +18 -10
  65. package/lib/components/UIShell/HeaderMenu.js +1 -0
  66. package/lib/components/UIShell/HeaderMenuButton.js +4 -0
  67. package/lib/components/UIShell/SideNavLink.js +6 -9
  68. package/lib/index.js +95 -95
  69. package/lib/internal/createClassWrapper.js +2 -5
  70. package/package.json +7 -7
  71. package/scss/utilities/_hide-at-breakpoint.scss +9 -0
  72. package/es/components/Modal/next/Modal.js +0 -274
  73. package/es/components/MultiSelect/next/FilterableMultiSelect.js +0 -544
  74. package/es/components/Notification/index.js +0 -42
  75. package/es/components/Notification/next/Notification.js +0 -663
  76. package/es/components/RadioButton/next/RadioButton.js +0 -130
  77. package/es/components/RadioButtonGroup/next/RadioButtonGroup.js +0 -141
  78. package/es/internal/FeatureFlags.js +0 -52
  79. package/es/prop-types/requiredIfValueExists.js +0 -32
  80. package/lib/components/Modal/next/Modal.js +0 -284
  81. package/lib/components/MultiSelect/next/FilterableMultiSelect.js +0 -556
  82. package/lib/components/Notification/index.js +0 -51
  83. package/lib/components/Notification/next/Notification.js +0 -677
  84. package/lib/components/RadioButton/next/RadioButton.js +0 -140
  85. package/lib/components/RadioButtonGroup/next/RadioButtonGroup.js +0 -151
  86. package/lib/internal/FeatureFlags.js +0 -56
  87. package/lib/prop-types/requiredIfValueExists.js +0 -36
@@ -1,140 +0,0 @@
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
- var useId = require('../../../internal/useId.js');
18
- require('../../Text/index.js');
19
- var Text = require('../../Text/Text.js');
20
-
21
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
-
23
- var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
24
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
25
- var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
26
-
27
- var _excluded = ["className", "disabled", "hideLabel", "id", "labelPosition", "labelText", "name", "onChange", "value"];
28
- var RadioButton = /*#__PURE__*/React__default["default"].forwardRef(function RadioButton(_ref, ref) {
29
- var className = _ref.className,
30
- disabled = _ref.disabled,
31
- hideLabel = _ref.hideLabel,
32
- id = _ref.id,
33
- _ref$labelPosition = _ref.labelPosition,
34
- labelPosition = _ref$labelPosition === void 0 ? 'right' : _ref$labelPosition,
35
- _ref$labelText = _ref.labelText,
36
- labelText = _ref$labelText === void 0 ? '' : _ref$labelText,
37
- name = _ref.name,
38
- _ref$onChange = _ref.onChange,
39
- onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
40
- _ref$value = _ref.value,
41
- value = _ref$value === void 0 ? '' : _ref$value,
42
- rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
43
-
44
- var prefix = usePrefix.usePrefix();
45
- var uid = useId.useId('radio-button');
46
- var uniqueId = id || uid;
47
-
48
- function handleOnChange(event) {
49
- onChange(value, name, event);
50
- }
51
-
52
- var innerLabelClasses = cx__default["default"](_rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--visually-hidden"), hideLabel));
53
- var wrapperClasses = cx__default["default"](className, "".concat(prefix, "--radio-button-wrapper"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--radio-button-wrapper--label-").concat(labelPosition), labelPosition !== 'right'));
54
- return /*#__PURE__*/React__default["default"].createElement("div", {
55
- className: wrapperClasses
56
- }, /*#__PURE__*/React__default["default"].createElement("input", _rollupPluginBabelHelpers["extends"]({}, rest, {
57
- type: "radio",
58
- className: "".concat(prefix, "--radio-button"),
59
- onChange: handleOnChange,
60
- id: uniqueId,
61
- ref: ref,
62
- disabled: disabled,
63
- value: value,
64
- name: name
65
- })), /*#__PURE__*/React__default["default"].createElement("label", {
66
- htmlFor: uniqueId,
67
- className: "".concat(prefix, "--radio-button__label")
68
- }, /*#__PURE__*/React__default["default"].createElement("span", {
69
- className: "".concat(prefix, "--radio-button__appearance")
70
- }), labelText && /*#__PURE__*/React__default["default"].createElement(Text.Text, {
71
- className: innerLabelClasses
72
- }, labelText)));
73
- });
74
- RadioButton.propTypes = {
75
- /**
76
- * Specify whether the `<RadioButton>` is currently checked
77
- */
78
- checked: PropTypes__default["default"].bool,
79
-
80
- /**
81
- * Provide an optional className to be applied to the containing node
82
- */
83
- className: PropTypes__default["default"].string,
84
-
85
- /**
86
- * Specify whether the `<RadioButton>` should be checked by default
87
- */
88
- defaultChecked: PropTypes__default["default"].bool,
89
-
90
- /**
91
- * Specify whether the control is disabled
92
- */
93
- disabled: PropTypes__default["default"].bool,
94
-
95
- /**
96
- * Specify whether the label should be hidden, or not
97
- */
98
- hideLabel: PropTypes__default["default"].bool,
99
-
100
- /**
101
- * Provide a unique id for the underlying `<input>` node
102
- */
103
- id: PropTypes__default["default"].string,
104
-
105
- /**
106
- * Provide where label text should be placed
107
- * NOTE: `top`/`bottom` are deprecated
108
- */
109
- labelPosition: PropTypes__default["default"].oneOf(['right', 'left']),
110
-
111
- /**
112
- * Provide label text to be read by screen readers when interacting with the
113
- * control
114
- */
115
- labelText: PropTypes__default["default"].node.isRequired,
116
-
117
- /**
118
- * Provide a name for the underlying `<input>` node
119
- */
120
- name: PropTypes__default["default"].string,
121
-
122
- /**
123
- * Provide an optional `onChange` hook that is called each time the value of
124
- * the underlying `<input>` changes
125
- */
126
- onChange: PropTypes__default["default"].func,
127
-
128
- /**
129
- * Provide a handler that is invoked when a user clicks on the control
130
- */
131
- onClick: PropTypes__default["default"].func,
132
-
133
- /**
134
- * Specify the value of the `<RadioButton>`
135
- */
136
- value: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number]).isRequired
137
- };
138
- var RadioButtonNext = RadioButton;
139
-
140
- exports["default"] = RadioButtonNext;
@@ -1,151 +0,0 @@
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 index = require('../../Text/index.js');
17
- var usePrefix = require('../../../internal/usePrefix.js');
18
-
19
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
-
21
- var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
22
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
23
- var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
24
-
25
- var RadioButtonGroup = /*#__PURE__*/React__default["default"].forwardRef(function RadioButtonGroup(_ref, ref) {
26
- var _classNames;
27
-
28
- var children = _ref.children,
29
- className = _ref.className,
30
- defaultSelected = _ref.defaultSelected,
31
- disabled = _ref.disabled,
32
- _ref$labelPosition = _ref.labelPosition,
33
- labelPosition = _ref$labelPosition === void 0 ? 'right' : _ref$labelPosition,
34
- legendText = _ref.legendText,
35
- name = _ref.name,
36
- _ref$onChange = _ref.onChange,
37
- onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
38
- _ref$orientation = _ref.orientation,
39
- orientation = _ref$orientation === void 0 ? 'horizontal' : _ref$orientation,
40
- valueSelected = _ref.valueSelected;
41
- var prefix = usePrefix.usePrefix();
42
-
43
- var _useState = React.useState(valueSelected !== null && valueSelected !== void 0 ? valueSelected : defaultSelected),
44
- _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
45
- selected = _useState2[0],
46
- setSelected = _useState2[1];
47
-
48
- var _useState3 = React.useState(valueSelected),
49
- _useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
50
- prevValueSelected = _useState4[0],
51
- setPrevValueSelected = _useState4[1];
52
- /**
53
- * prop + state alignment - getDerivedStateFromProps
54
- * only update if selected prop changes
55
- */
56
-
57
-
58
- if (valueSelected !== prevValueSelected) {
59
- setSelected(valueSelected);
60
- setPrevValueSelected(valueSelected);
61
- }
62
-
63
- function getRadioButtons() {
64
- var mappedChildren = React__default["default"].Children.map(children, function (radioButton) {
65
- var value = radioButton.props.value;
66
- return /*#__PURE__*/React__default["default"].cloneElement(radioButton, {
67
- name: name,
68
- key: value,
69
- value: value,
70
- onChange: handleOnChange,
71
- checked: value === selected
72
- });
73
- });
74
- return mappedChildren;
75
- }
76
-
77
- function handleOnChange(newSelection, value, evt) {
78
- if (newSelection !== selected) {
79
- setSelected(newSelection);
80
- onChange(newSelection, name, evt);
81
- }
82
- }
83
-
84
- var fieldsetClasses = cx__default["default"]("".concat(prefix, "--radio-button-group"), (_classNames = {}, _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--radio-button-group--").concat(orientation), orientation === 'vertical'), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--radio-button-group--label-").concat(labelPosition), labelPosition), _classNames));
85
- var wrapperClasses = cx__default["default"]("".concat(prefix, "--form-item"), className);
86
- return /*#__PURE__*/React__default["default"].createElement("div", {
87
- className: wrapperClasses,
88
- ref: ref
89
- }, /*#__PURE__*/React__default["default"].createElement("fieldset", {
90
- className: fieldsetClasses,
91
- disabled: disabled
92
- }, legendText && /*#__PURE__*/React__default["default"].createElement(index.Legend, {
93
- className: "".concat(prefix, "--label")
94
- }, legendText), getRadioButtons()));
95
- });
96
- RadioButtonGroup.propTypes = {
97
- /**
98
- * Provide a collection of `<RadioButton>` components to render in the group
99
- */
100
- children: PropTypes__default["default"].node,
101
-
102
- /**
103
- * Provide an optional className to be applied to the container node
104
- */
105
- className: PropTypes__default["default"].string,
106
-
107
- /**
108
- * Specify the `<RadioButton>` to be selected by default
109
- */
110
- defaultSelected: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number]),
111
-
112
- /**
113
- * Specify whether the group is disabled
114
- */
115
- disabled: PropTypes__default["default"].bool,
116
-
117
- /**
118
- * Provide where label text should be placed
119
- */
120
- labelPosition: PropTypes__default["default"].oneOf(['left', 'right']),
121
-
122
- /**
123
- * Provide a legend to the RadioButtonGroup input that you are
124
- * exposing to the user
125
- */
126
- legendText: PropTypes__default["default"].node,
127
-
128
- /**
129
- * Specify the name of the underlying `<input>` nodes
130
- */
131
- name: PropTypes__default["default"].string.isRequired,
132
-
133
- /**
134
- * Provide an optional `onChange` hook that is called whenever the value of
135
- * the group changes
136
- */
137
- onChange: PropTypes__default["default"].func,
138
-
139
- /**
140
- * Provide where radio buttons should be placed
141
- */
142
- orientation: PropTypes__default["default"].oneOf(['horizontal', 'vertical']),
143
-
144
- /**
145
- * Specify the value that is currently selected in the group
146
- */
147
- valueSelected: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number])
148
- };
149
- var RadioButtonGroupNext = RadioButtonGroup;
150
-
151
- exports["default"] = RadioButtonGroupNext;
@@ -1,56 +0,0 @@
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 FeatureFlags = require('@carbon/feature-flags');
13
-
14
- /**
15
- * This file contains the list of the default values of compile-time feature flags.
16
- *
17
- * Build toolchain can replace variable here and/or the references
18
- * in order to apply non-default values to those feature flags.
19
- *
20
- * @example Render `foo` if `aFeatureFlag` is `true`, render `bar` otherwise.
21
- * import { aFeatureFlag } from '/path/to/FeatureFlags';
22
- * ...
23
- * const MyComponent = props => (<div {...props}>{aFeatureFlag ? 'foo' : 'bar'}</div>);
24
- */
25
-
26
- /**
27
- * With this flag, certain components will be created in either a controlled or controlled
28
- * mode based on the existence of a value prop.
29
- *
30
- * The following components will have the significance of their props slightly altered as outlined below.
31
- *
32
- * Components: `<NumberInput>`
33
- *
34
- * * `value` → when provided, enables controlled mode.
35
- * For the rest of the component's lifecycle, it will be controlled by this prop as it's single source of truth.
36
- * * `defaultValue` → Optional starting value, used for for uncontrolled mode only (no value prop).
37
- * The value prop takes precedence over defaultValue.
38
- * * `onChange` → Optional event handler.
39
- * However, if value is provided and a handler is not, we'll throw a warning indicating the component is now read-only
40
- * * `readOnly` → silences the above warning, acknowledging the read-only state of the component
41
- *
42
- * This flag also disables prop -> state sync in several components, notably `<NumberInput>`.
43
- *
44
- * This flag also updates event handlers to pass an up-to-date value in the second parameter,
45
- * so applications can use it in both controlled and uncontrolled components.
46
- *
47
- * * _With_ this feature flag, the signature of the event handler will be altered to provide additional context in the second parameter: `onChange(event, { value, ...rest })` where:
48
- * * `event` is the (React) raw event
49
- * * `value` is the new value
50
- * * `rest` tells you additional information based on the source component
51
- * * _Without_ this feature flag the event handler has component-specific signature, e.g. `onChange(event, direction)`.
52
- */
53
-
54
- var useControlledStateWithValue = FeatureFlags.enabled('enable-use-controlled-state-with-value');
55
-
56
- exports.useControlledStateWithValue = useControlledStateWithValue;
@@ -1,36 +0,0 @@
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
- /**
13
- * @param {Function} propType The original prop type checker.
14
- * @returns {Function} The new prop type checker for `onChange` that makes it required if `value` exists and `readOnly` does not exist.
15
- */
16
- function requiredIfValueExists(propType) {
17
- return function check(props, propName, componentName) {
18
- var onChange = props[propName],
19
- value = props.value,
20
- readOnly = props.readOnly;
21
- var exists = onChange !== undefined;
22
- var valueExists = value !== undefined;
23
-
24
- if (process.env.NODE_ENV !== "production" && !exists && valueExists && !readOnly) {
25
- return new Error("You provided a value prop to `".concat(componentName, "` without an `onChange` handler. ") + 'This will render a read-only field. ' + 'If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.');
26
- }
27
-
28
- for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
29
- rest[_key - 3] = arguments[_key];
30
- }
31
-
32
- return propType.apply(void 0, [props, propName, componentName].concat(rest));
33
- };
34
- }
35
-
36
- exports["default"] = requiredIfValueExists;