@carbon/react 1.16.0-rc.0 → 1.17.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 (73) hide show
  1. package/es/components/Checkbox/Checkbox.Skeleton.d.ts +18 -0
  2. package/es/components/Checkbox/Checkbox.Skeleton.js +1 -2
  3. package/es/components/Checkbox/Checkbox.d.ts +47 -0
  4. package/es/components/Checkbox/Checkbox.js +6 -7
  5. package/es/components/Checkbox/index.d.ts +10 -0
  6. package/es/components/Checkbox/index.js +10 -0
  7. package/es/components/CodeSnippet/CodeSnippet.js +0 -1
  8. package/es/components/DataTable/TableToolbarSearch.js +1 -1
  9. package/es/components/ExpandableSearch/ExpandableSearch.js +1 -1
  10. package/es/components/Grid/Grid.js +0 -5
  11. package/es/components/NumberInput/NumberInput.js +45 -1
  12. package/es/components/ProgressIndicator/ProgressIndicator.Skeleton.js +10 -4
  13. package/es/components/Search/Search.js +160 -184
  14. package/es/components/Search/index.js +2 -8
  15. package/es/components/Tab/index.js +1 -1
  16. package/es/components/Tabs/Tabs.Skeleton.js +6 -6
  17. package/es/components/Tabs/Tabs.js +582 -508
  18. package/es/components/Tabs/index.js +2 -12
  19. package/es/components/Tabs/{next/usePressable.js → usePressable.js} +1 -1
  20. package/es/components/Text/Text.d.ts +33 -0
  21. package/es/components/Text/Text.js +8 -5
  22. package/es/components/Text/TextDirection.d.ts +35 -0
  23. package/es/components/Text/TextDirectionContext.js +2 -0
  24. package/es/components/Text/createTextComponent.d.ts +18 -0
  25. package/es/components/Text/index.d.ts +18 -0
  26. package/es/components/Text/index.js +2 -0
  27. package/es/components/TextInput/TextInput.js +1 -1
  28. package/es/components/Tile/Tile.js +339 -502
  29. package/es/index.js +6 -6
  30. package/es/internal/useNormalizedInputProps.js +13 -17
  31. package/es/internal/usePrefix.d.ts +9 -0
  32. package/lib/components/Checkbox/Checkbox.Skeleton.d.ts +18 -0
  33. package/lib/components/Checkbox/Checkbox.Skeleton.js +1 -2
  34. package/lib/components/Checkbox/Checkbox.d.ts +47 -0
  35. package/lib/components/Checkbox/Checkbox.js +6 -7
  36. package/lib/components/Checkbox/index.d.ts +10 -0
  37. package/lib/components/Checkbox/index.js +18 -0
  38. package/lib/components/CodeSnippet/CodeSnippet.js +0 -1
  39. package/lib/components/DataTable/TableToolbarSearch.js +2 -2
  40. package/lib/components/ExpandableSearch/ExpandableSearch.js +3 -3
  41. package/lib/components/Grid/Grid.js +0 -5
  42. package/lib/components/NumberInput/NumberInput.js +45 -1
  43. package/lib/components/ProgressIndicator/ProgressIndicator.Skeleton.js +9 -3
  44. package/lib/components/Search/Search.js +159 -183
  45. package/lib/components/Search/index.js +2 -25
  46. package/lib/components/Tab/index.js +1 -1
  47. package/lib/components/Tabs/Tabs.Skeleton.js +6 -6
  48. package/lib/components/Tabs/Tabs.js +586 -507
  49. package/lib/components/Tabs/index.js +7 -33
  50. package/lib/components/Tabs/{next/usePressable.js → usePressable.js} +1 -1
  51. package/lib/components/Text/Text.d.ts +33 -0
  52. package/lib/components/Text/Text.js +8 -5
  53. package/lib/components/Text/TextDirection.d.ts +35 -0
  54. package/lib/components/Text/TextDirectionContext.js +2 -0
  55. package/lib/components/Text/createTextComponent.d.ts +18 -0
  56. package/lib/components/Text/index.d.ts +18 -0
  57. package/lib/components/Text/index.js +4 -0
  58. package/lib/components/TextInput/TextInput.js +1 -1
  59. package/lib/components/Tile/Tile.js +336 -499
  60. package/lib/index.js +71 -71
  61. package/lib/internal/useNormalizedInputProps.js +12 -16
  62. package/lib/internal/usePrefix.d.ts +9 -0
  63. package/package.json +8 -4
  64. package/es/components/Search/next/Search.js +0 -265
  65. package/es/components/Tabs/next/Tabs.Skeleton.js +0 -53
  66. package/es/components/Tabs/next/Tabs.js +0 -692
  67. package/es/components/Tile/index.js +0 -19
  68. package/es/components/Tile/next/Tile.js +0 -604
  69. package/lib/components/Search/next/Search.js +0 -275
  70. package/lib/components/Tabs/next/Tabs.Skeleton.js +0 -63
  71. package/lib/components/Tabs/next/Tabs.js +0 -708
  72. package/lib/components/Tile/index.js +0 -48
  73. package/lib/components/Tile/next/Tile.js +0 -619
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2018
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
+ import PropTypes from 'prop-types';
8
+ import { HTMLAttributes } from 'react';
9
+ declare const CheckboxSkeleton: {
10
+ ({ className, ...rest }: HTMLAttributes<HTMLDivElement>): JSX.Element;
11
+ propTypes: {
12
+ /**
13
+ * Specify an optional className to add.
14
+ */
15
+ className: PropTypes.Requireable<string>;
16
+ };
17
+ };
18
+ export default CheckboxSkeleton;
@@ -33,6 +33,5 @@ CheckboxSkeleton.propTypes = {
33
33
  */
34
34
  className: PropTypes.string
35
35
  };
36
- var CheckboxSkeleton$1 = CheckboxSkeleton;
37
36
 
38
- export { CheckboxSkeleton$1 as default };
37
+ export { CheckboxSkeleton as default };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2018
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
+ import { ReactNodeLike } from 'prop-types';
8
+ import React from 'react';
9
+ declare type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type';
10
+ export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
11
+ /**
12
+ * Provide an `id` to uniquely identify the Checkbox input
13
+ */
14
+ id: string;
15
+ /**
16
+ * Provide a label to provide a description of the Checkbox input that you are
17
+ * exposing to the user
18
+ */
19
+ labelText: NonNullable<ReactNodeLike>;
20
+ /**
21
+ * Specify whether the underlying input should be checked by default
22
+ */
23
+ defaultChecked?: boolean;
24
+ /**
25
+ * Specify whether the Checkbox should be disabled
26
+ */
27
+ disabled?: boolean;
28
+ /**
29
+ * Specify whether the label should be hidden, or not
30
+ */
31
+ hideLabel?: boolean;
32
+ /**
33
+ * Specify whether the Checkbox is in an indeterminate state
34
+ */
35
+ indeterminate?: boolean;
36
+ /**
37
+ * Provide an optional handler that is called when the internal state of
38
+ * Checkbox changes. This handler is called with event and state info.
39
+ * `(event, { checked, id }) => void`
40
+ */
41
+ onChange?: (evt: React.ChangeEvent<HTMLInputElement>, data: {
42
+ checked: boolean;
43
+ id: string;
44
+ }) => void;
45
+ }
46
+ declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<unknown>>;
47
+ export default Checkbox;
@@ -14,7 +14,7 @@ import { usePrefix } from '../../internal/usePrefix.js';
14
14
  import { Text } from '../Text/Text.js';
15
15
 
16
16
  var _excluded = ["className", "id", "labelText", "onChange", "indeterminate", "hideLabel", "title"];
17
- var Checkbox = /*#__PURE__*/React__default.forwardRef(function Checkbox(_ref, _ref2) {
17
+ var Checkbox = /*#__PURE__*/React__default.forwardRef(function (_ref, _ref2) {
18
18
  var className = _ref.className,
19
19
  id = _ref.id,
20
20
  labelText = _ref.labelText,
@@ -33,7 +33,7 @@ var Checkbox = /*#__PURE__*/React__default.forwardRef(function Checkbox(_ref, _r
33
33
  }, /*#__PURE__*/React__default.createElement("input", _extends({}, other, {
34
34
  type: "checkbox",
35
35
  onChange: function onChange(evt) {
36
- _onChange(evt, {
36
+ _onChange && _onChange(evt, {
37
37
  checked: evt.target.checked,
38
38
  id: id
39
39
  });
@@ -41,20 +41,20 @@ var Checkbox = /*#__PURE__*/React__default.forwardRef(function Checkbox(_ref, _r
41
41
  className: "".concat(prefix, "--checkbox"),
42
42
  id: id,
43
43
  ref: function ref(el) {
44
- if (el) {
44
+ if (el && indeterminate) {
45
45
  el.indeterminate = indeterminate;
46
46
  }
47
47
 
48
48
  if (typeof _ref2 === 'function') {
49
49
  _ref2(el);
50
- } else if (Object(_ref2) === _ref2) {
50
+ } else if (_ref2 && Object(_ref2) === _ref2) {
51
51
  _ref2.current = el;
52
52
  }
53
53
  }
54
54
  })), /*#__PURE__*/React__default.createElement("label", {
55
55
  htmlFor: id,
56
56
  className: "".concat(prefix, "--checkbox-label"),
57
- title: title || null
57
+ title: title
58
58
  }, /*#__PURE__*/React__default.createElement(Text, {
59
59
  className: innerLabelClasses
60
60
  }, labelText)));
@@ -118,6 +118,5 @@ Checkbox.defaultProps = {
118
118
  indeterminate: false
119
119
  };
120
120
  Checkbox.displayName = 'Checkbox';
121
- var Checkbox$1 = Checkbox;
122
121
 
123
- export { Checkbox$1 as default };
122
+ export { Checkbox as default };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2018
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
+ export { default as CheckboxSkeleton } from './Checkbox.Skeleton';
8
+ import Checkbox, { CheckboxProps } from './Checkbox';
9
+ export type { CheckboxProps };
10
+ export default Checkbox;
@@ -0,0 +1,10 @@
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
+ export { default as CheckboxSkeleton } from './Checkbox.Skeleton.js';
9
+ import Checkbox from './Checkbox.js';
10
+ export { default } from './Checkbox.js';
@@ -245,7 +245,6 @@ function CodeSnippet(_ref) {
245
245
  }, /*#__PURE__*/React__default.createElement("span", {
246
246
  className: "".concat(prefix, "--snippet-btn--text")
247
247
  }, expandCodeBtnText), /*#__PURE__*/React__default.createElement(ChevronDown, {
248
- "aria-label": expandCodeBtnText,
249
248
  className: "".concat(prefix, "--icon-chevron--down ").concat(prefix, "--snippet__icon"),
250
249
  name: "chevron--down",
251
250
  role: "img"
@@ -9,7 +9,7 @@ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _
9
9
  import cx from 'classnames';
10
10
  import PropTypes from 'prop-types';
11
11
  import React__default, { useRef, useState, useMemo, useEffect } from 'react';
12
- import Search from '../Search/index.js';
12
+ import Search from '../Search/Search.js';
13
13
  import setupGetInstanceId from './tools/instanceId.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
15
 
@@ -8,7 +8,7 @@
8
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
- import Search from '../Search/index.js';
11
+ import Search from '../Search/Search.js';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
13
13
  import { composeEventHandlers } from '../../tools/events.js';
14
14
 
@@ -37,11 +37,6 @@ Grid.propTypes = {
37
37
  */
38
38
  className: PropTypes.string,
39
39
 
40
- /**
41
- * Specify how many columns wide the Grid should span
42
- */
43
- columns: PropTypes.number,
44
-
45
40
  /**
46
41
  * Collapse the gutter to 1px. Useful for fluid layouts.
47
42
  * Rows have 1px of margin between them to match gutter.
@@ -16,7 +16,7 @@ import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
17
17
  import deprecate from '../../prop-types/deprecate.js';
18
18
 
19
- var _excluded = ["allowEmpty", "className", "disabled", "defaultValue", "helperText", "hideLabel", "hideSteppers", "iconDescription", "id", "label", "invalid", "invalidText", "light", "max", "min", "onChange", "onClick", "onKeyUp", "readOnly", "size", "step", "translateWithId", "warn", "warnText", "value"];
19
+ var _excluded = ["allowEmpty", "className", "disabled", "disableWheel", "defaultValue", "helperText", "hideLabel", "hideSteppers", "iconDescription", "id", "label", "invalid", "invalidText", "light", "max", "min", "onChange", "onClick", "onKeyUp", "readOnly", "size", "step", "translateWithId", "warn", "warnText", "value"];
20
20
 
21
21
  var _defaultTranslations, _Subtract, _Add;
22
22
  var translationIds = {
@@ -34,6 +34,8 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
34
34
  customClassName = props.className,
35
35
  _props$disabled = props.disabled,
36
36
  disabled = _props$disabled === void 0 ? false : _props$disabled,
37
+ _props$disableWheel = props.disableWheel,
38
+ disableWheelProp = _props$disableWheel === void 0 ? false : _props$disableWheel,
37
39
  defaultValue = props.defaultValue,
38
40
  _props$helperText = props.helperText,
39
41
  helperText = _props$helperText === void 0 ? '' : _props$helperText,
@@ -172,6 +174,24 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
172
174
  onClick: _onClick,
173
175
  onChange: handleOnChange,
174
176
  onKeyUp: onKeyUp,
177
+ onFocus: function onFocus(e) {
178
+ if (disableWheelProp) {
179
+ e.target.addEventListener('wheel', disableWheel);
180
+ }
181
+
182
+ if (rest.onFocus) {
183
+ rest.onFocus(e);
184
+ }
185
+ },
186
+ onBlur: function onBlur(e) {
187
+ if (disableWheelProp) {
188
+ e.target.removeEventListener('wheel', disableWheel);
189
+ }
190
+
191
+ if (rest.onBlur) {
192
+ rest.onBlur(e);
193
+ }
194
+ },
175
195
  pattern: "[0-9]*",
176
196
  readOnly: readOnly,
177
197
  step: step,
@@ -254,6 +274,11 @@ NumberInput.propTypes = {
254
274
  */
255
275
  defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
256
276
 
277
+ /**
278
+ * Specify if the wheel functionality for the input should be disabled, or not
279
+ */
280
+ disableWheel: PropTypes.bool,
281
+
257
282
  /**
258
283
  * Specify if the control should be disabled, or not
259
284
  */
@@ -449,6 +474,25 @@ function getInputValidity(_ref4) {
449
474
 
450
475
  return true;
451
476
  }
477
+ /**
478
+ * It prevents any wheel event from emitting.
479
+ *
480
+ * We want to prevent this input field from changing by the user accidentally
481
+ * when the user scrolling up or down in a long form. So we prevent the default
482
+ * behavior of wheel events when it is focused.
483
+ *
484
+ * Because React uses passive event handler by default, we can't just call
485
+ * `preventDefault` in the `onWheel` event handler. So we have to get the input
486
+ * ref and add our event handler manually.
487
+ *
488
+ * @see https://github.com/facebook/react/pull/19654
489
+ * @param {WheelEvent} e A wheel event.
490
+ */
491
+
492
+
493
+ function disableWheel(e) {
494
+ e.preventDefault();
495
+ }
452
496
  /**
453
497
  * Clamp the given value between the upper bound `max` and the lower bound `min`
454
498
  * @param {number} max
@@ -5,14 +5,14 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
10
  import React__default from 'react';
11
11
  import cx from 'classnames';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
13
13
  import { CircleDash } from '@carbon/icons-react';
14
14
 
15
- var _excluded = ["className"];
15
+ var _excluded = ["className", "vertical"];
16
16
 
17
17
  var _CircleDash, _Step, _Step2, _Step3, _Step4;
18
18
 
@@ -31,11 +31,12 @@ function Step() {
31
31
 
32
32
  function ProgressIndicatorSkeleton(_ref) {
33
33
  var className = _ref.className,
34
+ vertical = _ref.vertical,
34
35
  rest = _objectWithoutProperties(_ref, _excluded);
35
36
 
36
37
  var prefix = usePrefix();
37
38
  return /*#__PURE__*/React__default.createElement("ul", _extends({
38
- className: cx("".concat(prefix, "--progress"), "".concat(prefix, "--skeleton"), className)
39
+ className: cx("".concat(prefix, "--progress"), "".concat(prefix, "--skeleton"), _defineProperty({}, "".concat(prefix, "--progress--vertical"), vertical), className)
39
40
  }, rest), _Step || (_Step = /*#__PURE__*/React__default.createElement(Step, null)), _Step2 || (_Step2 = /*#__PURE__*/React__default.createElement(Step, null)), _Step3 || (_Step3 = /*#__PURE__*/React__default.createElement(Step, null)), _Step4 || (_Step4 = /*#__PURE__*/React__default.createElement(Step, null)));
40
41
  }
41
42
 
@@ -43,7 +44,12 @@ ProgressIndicatorSkeleton.propTypes = {
43
44
  /**
44
45
  * Specify an optional className to add.
45
46
  */
46
- className: PropTypes.string
47
+ className: PropTypes.string,
48
+
49
+ /**
50
+ * Determines whether or not the ProgressIndicator should be rendered vertically.
51
+ */
52
+ vertical: PropTypes.bool
47
53
  };
48
54
 
49
55
  export { ProgressIndicatorSkeleton as default };