@carbon/react 1.22.0 → 1.23.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 (49) hide show
  1. package/es/components/CodeSnippet/CodeSnippet.js +2 -2
  2. package/es/components/ComboBox/ComboBox.d.ts +151 -0
  3. package/es/components/ComboBox/ComboBox.js +28 -21
  4. package/es/components/ComposedModal/ComposedModal.js +2 -2
  5. package/es/components/DataTable/TableSelectRow.d.ts +88 -0
  6. package/es/components/DataTable/TableSelectRow.js +3 -5
  7. package/es/components/DatePicker/DatePicker.js +1 -1
  8. package/es/components/DatePicker/plugins/fixEventsPlugin.js +10 -1
  9. package/es/components/DatePicker/plugins/rangePlugin.js +1 -1
  10. package/es/components/FileUploader/FileUploaderButton.js +14 -16
  11. package/es/components/NumberInput/NumberInput.d.ts +132 -0
  12. package/es/components/NumberInput/NumberInput.js +9 -7
  13. package/es/components/TextArea/TextArea.js +1 -0
  14. package/es/components/Toggle/Toggle.js +54 -33
  15. package/es/components/Toggletip/index.js +26 -1
  16. package/es/internal/useNormalizedInputProps.js +3 -3
  17. package/lib/components/CodeSnippet/CodeSnippet.js +4 -3
  18. package/lib/components/ComboBox/ComboBox.d.ts +151 -0
  19. package/lib/components/ComboBox/ComboBox.js +28 -21
  20. package/lib/components/ComposedModal/ComposedModal.js +2 -2
  21. package/lib/components/DataTable/TableSelectRow.d.ts +88 -0
  22. package/lib/components/DataTable/TableSelectRow.js +2 -4
  23. package/lib/components/DatePicker/DatePicker.js +9 -8
  24. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +10 -1
  25. package/lib/components/DatePicker/plugins/rangePlugin.js +6 -2
  26. package/lib/components/FileUploader/FileUploaderButton.js +14 -16
  27. package/lib/components/NumberInput/NumberInput.d.ts +132 -0
  28. package/lib/components/NumberInput/NumberInput.js +9 -7
  29. package/lib/components/TextArea/TextArea.js +1 -0
  30. package/lib/components/Toggle/Toggle.js +53 -32
  31. package/lib/components/Toggletip/index.js +26 -1
  32. package/lib/internal/useNormalizedInputProps.js +3 -3
  33. package/package.json +3 -5
  34. package/es/_virtual/ResizeObserver.es.js +0 -13
  35. package/es/_virtual/_commonjsHelpers.js +0 -42
  36. package/es/_virtual/index.js +0 -14
  37. package/es/_virtual/rangePlugin.js +0 -14
  38. package/es/node_modules/flatpickr/dist/l10n/index.js +0 -1423
  39. package/es/node_modules/flatpickr/dist/plugins/rangePlugin.js +0 -196
  40. package/es/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +0 -1112
  41. package/es/node_modules/use-resize-observer/polyfilled.js +0 -111
  42. package/lib/_virtual/ResizeObserver.es.js +0 -17
  43. package/lib/_virtual/_commonjsHelpers.js +0 -48
  44. package/lib/_virtual/index.js +0 -18
  45. package/lib/_virtual/rangePlugin.js +0 -18
  46. package/lib/node_modules/flatpickr/dist/l10n/index.js +0 -1427
  47. package/lib/node_modules/flatpickr/dist/plugins/rangePlugin.js +0 -200
  48. package/lib/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +0 -1116
  49. package/lib/node_modules/use-resize-observer/polyfilled.js +0 -119
@@ -0,0 +1,132 @@
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 React, { ReactNode } from 'react';
8
+ export declare const translationIds: {
9
+ 'increment.number': string;
10
+ 'decrement.number': string;
11
+ };
12
+ type ExcludedAttributes = 'defaultValue' | 'id' | 'min' | 'max' | 'onChange' | 'onClick' | 'size' | 'step' | 'value';
13
+ export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
14
+ /**
15
+ * `true` to allow empty string.
16
+ */
17
+ allowEmpty?: boolean;
18
+ /**
19
+ * Specify an optional className to be applied to the wrapper node
20
+ */
21
+ className?: string;
22
+ /**
23
+ * Optional starting value for uncontrolled state
24
+ */
25
+ defaultValue?: number | string;
26
+ /**
27
+ * Specify if the wheel functionality for the input should be disabled, or not
28
+ */
29
+ disableWheel?: boolean;
30
+ /**
31
+ * Specify if the control should be disabled, or not
32
+ */
33
+ disabled?: boolean;
34
+ /**
35
+ * Provide text that is used alongside the control label for additional help
36
+ */
37
+ helperText?: ReactNode;
38
+ /**
39
+ * Specify whether you want the underlying label to be visually hidden
40
+ */
41
+ hideLabel?: boolean;
42
+ /**
43
+ * Specify whether you want the steppers to be hidden
44
+ */
45
+ hideSteppers?: boolean;
46
+ /**
47
+ * Provide a description for up/down icons that can be read by screen readers
48
+ */
49
+ iconDescription?: string;
50
+ /**
51
+ * Specify a custom `id` for the input
52
+ */
53
+ id: string;
54
+ /**
55
+ * Specify if the currently value is invalid.
56
+ */
57
+ invalid?: boolean;
58
+ /**
59
+ * Message which is displayed if the value is invalid.
60
+ */
61
+ invalidText?: ReactNode;
62
+ /**
63
+ * Generic `label` that will be used as the textual representation of what
64
+ * this field is for
65
+ */
66
+ label?: ReactNode;
67
+ /**
68
+ * `true` to use the light version.
69
+ *
70
+ * @deprecated The `light` prop for `NumberInput` is no longer needed and has
71
+ * been deprecated in v11 in favor of the new `Layer` component. It will be moved in the next major release.
72
+ */
73
+ light?: boolean;
74
+ /**
75
+ * The maximum value.
76
+ */
77
+ max?: number;
78
+ /**
79
+ * The minimum value.
80
+ */
81
+ min?: number;
82
+ /**
83
+ * Provide an optional handler that is called when the internal state of
84
+ * NumberInput changes. This handler is called with event and state info.
85
+ * `(event, { value, direction }) => void`
86
+ */
87
+ onChange?: (event: React.MouseEvent<HTMLButtonElement>, state: {
88
+ value: number | string;
89
+ direction: string;
90
+ }) => void;
91
+ /**
92
+ * Provide an optional function to be called when the up/down button is clicked
93
+ */
94
+ onClick?: (event: React.MouseEvent<HTMLElement>, state?: {
95
+ value: number | string;
96
+ direction: string;
97
+ }) => void;
98
+ /**
99
+ * Provide an optional function to be called when a key is pressed in the number input
100
+ */
101
+ onKeyUp?: React.KeyboardEventHandler<HTMLInputElement>;
102
+ /**
103
+ * Specify if the component should be read-only
104
+ */
105
+ readOnly?: boolean;
106
+ /**
107
+ * Specify the size of the Number Input.
108
+ */
109
+ size?: 'sm' | 'md' | 'lg';
110
+ /**
111
+ * Specify how much the values should increase/decrease upon clicking on up/down button
112
+ */
113
+ step?: number;
114
+ /**
115
+ * Provide custom text for the component for each translation id
116
+ */
117
+ translateWithId?: (id: string) => string;
118
+ /**
119
+ * Specify the value of the input
120
+ */
121
+ value?: number | string;
122
+ /**
123
+ * Specify whether the control is currently in warning state
124
+ */
125
+ warn?: boolean;
126
+ /**
127
+ * Provide the text that is displayed when the control is in warning state
128
+ */
129
+ warnText?: ReactNode;
130
+ }
131
+ declare const NumberInput: React.ForwardRefExoticComponent<NumberInputProps & React.RefAttributes<unknown>>;
132
+ export { NumberInput };
@@ -127,11 +127,12 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
127
127
  var iconClasses = cx((_cx3 = {}, _defineProperty(_cx3, "".concat(prefix, "--number__invalid"), normalizedProps.invalid || normalizedProps.warn), _defineProperty(_cx3, "".concat(prefix, "--number__invalid--warning"), normalizedProps.warn), _cx3));
128
128
 
129
129
  if (controlledValue !== prevControlledValue) {
130
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
130
131
  setValue(controlledValue);
131
132
  setPrevControlledValue(controlledValue);
132
133
  }
133
134
 
134
- var ariaDescribedBy = null;
135
+ var ariaDescribedBy = undefined;
135
136
 
136
137
  if (normalizedProps.invalid) {
137
138
  ariaDescribedBy = normalizedProps.invalidId;
@@ -158,7 +159,7 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
158
159
  }
159
160
 
160
161
  var handleFocus = function handleFocus(evt) {
161
- if (evt.target.type === 'button') {
162
+ if ('type' in evt.target && evt.target.type === 'button') {
162
163
  setIsFocused(false);
163
164
  } else {
164
165
  setIsFocused(evt.type === 'focus' ? true : false);
@@ -166,10 +167,11 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
166
167
  };
167
168
 
168
169
  var outerElementClasses = cx("".concat(prefix, "--form-item"), (_cx4 = {}, _defineProperty(_cx4, customClassName, !!customClassName), _defineProperty(_cx4, "".concat(prefix, "--number-input--fluid--invalid"), isFluid && normalizedProps.invalid), _defineProperty(_cx4, "".concat(prefix, "--number-input--fluid--focus"), isFluid && isFocused), _defineProperty(_cx4, "".concat(prefix, "--number-input--fluid--disabled"), isFluid && disabled), _cx4));
170
+ var Icon = normalizedProps.icon;
169
171
  return /*#__PURE__*/React__default.createElement("div", {
170
172
  className: outerElementClasses,
171
- onFocus: isFluid ? handleFocus : null,
172
- onBlur: isFluid ? handleFocus : null
173
+ onFocus: isFluid ? handleFocus : undefined,
174
+ onBlur: isFluid ? handleFocus : undefined
173
175
  }, /*#__PURE__*/React__default.createElement("div", {
174
176
  className: numberInputClasses,
175
177
  "data-invalid": normalizedProps.invalid ? true : undefined
@@ -215,7 +217,7 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
215
217
  step: step,
216
218
  type: "number",
217
219
  value: value
218
- })), normalizedProps.icon ? /*#__PURE__*/React__default.createElement(normalizedProps.icon, {
220
+ })), Icon ? /*#__PURE__*/React__default.createElement(Icon, {
219
221
  className: iconClasses
220
222
  }) : null, !hideSteppers && /*#__PURE__*/React__default.createElement("div", {
221
223
  className: "".concat(prefix, "--number__controls")
@@ -238,7 +240,7 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
238
240
  _onClick(event, state);
239
241
  }
240
242
  },
241
- tabIndex: "-1",
243
+ tabIndex: -1,
242
244
  title: decrementNumLabel || iconDescription,
243
245
  type: "button"
244
246
  }, _Subtract || (_Subtract = /*#__PURE__*/React__default.createElement(Subtract, {
@@ -264,7 +266,7 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
264
266
  _onClick(event, state);
265
267
  }
266
268
  },
267
- tabIndex: "-1",
269
+ tabIndex: -1,
268
270
  title: incrementNumLabel || iconDescription,
269
271
  type: "button"
270
272
  }, _Add || (_Add = /*#__PURE__*/React__default.createElement(Add, {
@@ -104,6 +104,7 @@ var TextArea = /*#__PURE__*/React__default.forwardRef(function TextArea(_ref, fo
104
104
  useIsomorphicEffect(function () {
105
105
  if (other.cols) {
106
106
  textareaRef.current.style.width = null;
107
+ textareaRef.current.style.resize = 'none';
107
108
  } else {
108
109
  textareaRef.current.style.width = "100%";
109
110
  }
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default from 'react';
9
+ import React__default, { useRef } from 'react';
10
10
  import PropTypes from 'prop-types';
11
11
  import cx from 'classnames';
12
12
  import { useControllableState } from '../../internal/useControllableState.js';
@@ -41,6 +41,7 @@ function Toggle(_ref) {
41
41
  other = _objectWithoutProperties(_ref, _excluded);
42
42
 
43
43
  var prefix = usePrefix();
44
+ var buttonElement = useRef(null);
44
45
 
45
46
  var _useControllableState = useControllableState({
46
47
  value: toggled,
@@ -69,37 +70,53 @@ function Toggle(_ref) {
69
70
  var labelTextClasses = cx("".concat(prefix, "--toggle__label-text"), _defineProperty({}, "".concat(prefix, "--visually-hidden"), hideLabel));
70
71
  var appearanceClasses = cx("".concat(prefix, "--toggle__appearance"), _defineProperty({}, "".concat(prefix, "--toggle__appearance--sm"), isSm));
71
72
  var switchClasses = cx("".concat(prefix, "--toggle__switch"), _defineProperty({}, "".concat(prefix, "--toggle__switch--checked"), checked));
72
- return /*#__PURE__*/React__default.createElement("div", {
73
- className: wrapperClasses
74
- }, /*#__PURE__*/React__default.createElement("button", _extends({}, other, {
75
- id: id,
76
- className: "".concat(prefix, "--toggle__button"),
77
- role: "switch",
78
- type: "button",
79
- "aria-checked": checked,
80
- "aria-labelledby": ariaLabelledby,
81
- disabled: disabled,
82
- onClick: handleClick
83
- })), /*#__PURE__*/React__default.createElement(LabelComponent, {
84
- htmlFor: ariaLabelledby ? null : id,
85
- className: "".concat(prefix, "--toggle__label")
86
- }, labelText && /*#__PURE__*/React__default.createElement("span", {
87
- className: labelTextClasses
88
- }, labelText), /*#__PURE__*/React__default.createElement("div", {
89
- className: appearanceClasses
90
- }, /*#__PURE__*/React__default.createElement("div", {
91
- className: switchClasses
92
- }, isSm && /*#__PURE__*/React__default.createElement("svg", {
93
- className: "".concat(prefix, "--toggle__check"),
94
- width: "6px",
95
- height: "5px",
96
- viewBox: "0 0 6 5"
97
- }, _path || (_path = /*#__PURE__*/React__default.createElement("path", {
98
- d: "M2.2 2.7L5 0 6 1 2.2 5 0 2.7 1 1.5z"
99
- })))), renderSideLabel && /*#__PURE__*/React__default.createElement("span", {
100
- className: "".concat(prefix, "--toggle__text"),
101
- "aria-hidden": "true"
102
- }, sideLabel))));
73
+ return (
74
+ /*#__PURE__*/
75
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
76
+ React__default.createElement("div", {
77
+ className: wrapperClasses,
78
+ onClick: ariaLabelledby ? function (e) {
79
+ // the underlying <button> can only be activated by keyboard as it is visually hidden;
80
+ // therefore, if this event's target is the <button>, it had to be triggered by
81
+ // the keyboard event which already calls handleClick. if we wouldn't catch this, the
82
+ // onClick and onToggle functions would be called twice whenever the user activates the
83
+ // toggle by keyboard and props['aria-labelledby'] is passed.
84
+ if (buttonElement.current && e.target !== buttonElement.current) {
85
+ handleClick(e);
86
+ buttonElement.current.focus();
87
+ }
88
+ } : null
89
+ }, /*#__PURE__*/React__default.createElement("button", _extends({}, other, {
90
+ ref: buttonElement,
91
+ id: id,
92
+ className: "".concat(prefix, "--toggle__button"),
93
+ role: "switch",
94
+ type: "button",
95
+ "aria-checked": checked,
96
+ "aria-labelledby": ariaLabelledby,
97
+ disabled: disabled,
98
+ onClick: handleClick
99
+ })), /*#__PURE__*/React__default.createElement(LabelComponent, {
100
+ htmlFor: ariaLabelledby ? null : id,
101
+ className: "".concat(prefix, "--toggle__label")
102
+ }, labelText && /*#__PURE__*/React__default.createElement("span", {
103
+ className: labelTextClasses
104
+ }, labelText), /*#__PURE__*/React__default.createElement("div", {
105
+ className: appearanceClasses
106
+ }, /*#__PURE__*/React__default.createElement("div", {
107
+ className: switchClasses
108
+ }, isSm && /*#__PURE__*/React__default.createElement("svg", {
109
+ className: "".concat(prefix, "--toggle__check"),
110
+ width: "6px",
111
+ height: "5px",
112
+ viewBox: "0 0 6 5"
113
+ }, _path || (_path = /*#__PURE__*/React__default.createElement("path", {
114
+ d: "M2.2 2.7L5 0 6 1 2.2 5 0 2.7 1 1.5z"
115
+ })))), renderSideLabel && /*#__PURE__*/React__default.createElement("span", {
116
+ className: "".concat(prefix, "--toggle__text"),
117
+ "aria-hidden": "true"
118
+ }, sideLabel))))
119
+ );
103
120
  }
104
121
  Toggle.propTypes = {
105
122
  /**
@@ -123,7 +140,11 @@ Toggle.propTypes = {
123
140
  disabled: PropTypes.bool,
124
141
 
125
142
  /**
126
- * Specify whether the label should be hidden, or not
143
+ * If true, the side labels (props.labelA and props.labelB) will be replaced by
144
+ * props.labelText, so that the toggle doesn't render a top label. In order to fully
145
+ * hide any labels, you can use props['aria-labelledby'] to refer to another element
146
+ * that labels the toggle. props.labelText would no longer be required in that case
147
+ * and can therefore be omitted.
127
148
  */
128
149
  hideLabel: PropTypes.bool,
129
150
 
@@ -102,10 +102,34 @@ function Toggletip(_ref2) {
102
102
 
103
103
  function onKeyDown(event) {
104
104
  if (open && match(event, Escape)) {
105
- actions.close();
105
+ actions.close(); // If the menu is closed while focus is still inside the menu, it should return to the trigger button (#12922)
106
+
107
+ var button = ref.current.children[0];
108
+
109
+ if (button && button.type === 'button') {
110
+ button.focus();
111
+ }
106
112
  }
107
113
  }
108
114
 
115
+ function handleBlur(event) {
116
+ // Do not close if the menu itself is clicked, should only close on focus out
117
+ if (open && event.relatedTarget === null) {
118
+ return;
119
+ }
120
+
121
+ if (!event.currentTarget.contains(event.relatedTarget)) {
122
+ // The menu should be closed when focus leaves the `Toggletip` (#12922)
123
+ actions.close();
124
+ }
125
+ } // If the `Toggletip` is the last focusable item in the tab order, it shoudl also close when the browser window loses focus (#12922)
126
+
127
+
128
+ useWindowEvent('blur', function () {
129
+ if (open) {
130
+ actions.close();
131
+ }
132
+ });
109
133
  useWindowEvent('click', function (event) {
110
134
  if (open && !ref.current.contains(event.target)) {
111
135
  actions.close();
@@ -122,6 +146,7 @@ function Toggletip(_ref2) {
122
146
  highContrast: true,
123
147
  open: open,
124
148
  onKeyDown: onKeyDown,
149
+ onBlur: handleBlur,
125
150
  ref: ref
126
151
  }, children));
127
152
  }
@@ -12,12 +12,12 @@ import { usePrefix } from './usePrefix.js';
12
12
  /**
13
13
  * @typedef {object} InputProps
14
14
  * @property {string} id - The input's id
15
- * @property {boolean} readOnly - Whether the input should be readonly
15
+ * @property {boolean | undefined} readOnly - Whether the input should be readonly
16
16
  * @property {boolean} disabled - Whether the input should be disabled
17
17
  * @property {boolean} invalid - Whether the input should be marked as invalid
18
- * @property {string} invalidText - The validation message displayed in case the input is considered invalid
18
+ * @property {React.ReactNode | undefined} invalidText - The validation message displayed in case the input is considered invalid
19
19
  * @property {boolean} warn - Whether the input should be in warning state
20
- * @property {string} warnText - The validation message displayed in case the input is in warning state
20
+ * @property {React.ReactNode | undefined} warnText - The validation message displayed in case the input is in warning state
21
21
  */
22
22
 
23
23
  /**
@@ -13,7 +13,7 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
13
13
  var PropTypes = require('prop-types');
14
14
  var React = require('react');
15
15
  var cx = require('classnames');
16
- var polyfilled = require('../../node_modules/use-resize-observer/polyfilled.js');
16
+ var useResizeObserver = require('use-resize-observer/polyfilled');
17
17
  var iconsReact = require('@carbon/icons-react');
18
18
  var Copy = require('../Copy/Copy.js');
19
19
  var Button = require('../Button/Button.js');
@@ -28,6 +28,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
28
28
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
29
29
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
30
30
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
31
+ var useResizeObserver__default = /*#__PURE__*/_interopDefaultLegacy(useResizeObserver);
31
32
  var copy__default = /*#__PURE__*/_interopDefaultLegacy(copy);
32
33
 
33
34
  var _excluded = ["className", "type", "children", "disabled", "feedback", "feedbackTimeout", "onClick", "ariaLabel", "copyText", "copyButtonDescription", "light", "showMoreText", "showLessText", "hideCopyButton", "wrapText", "maxCollapsedNumberOfRows", "maxExpandedNumberOfRows", "minCollapsedNumberOfRows", "minExpandedNumberOfRows"];
@@ -128,7 +129,7 @@ function CodeSnippet(_ref) {
128
129
  setHasLeftOverflow(horizontalOverflow && !!codeScrollLeft);
129
130
  setHasRightOverflow(horizontalOverflow && codeScrollLeft + codeClientWidth !== codeScrollWidth);
130
131
  }, [type, getCodeRefDimensions]);
131
- polyfilled["default"]({
132
+ useResizeObserver__default["default"]({
132
133
  ref: getCodeRef(),
133
134
  onResize: function onResize() {
134
135
  if (codeContentRef !== null && codeContentRef !== void 0 && codeContentRef.current && type === 'multi') {
@@ -150,7 +151,7 @@ function CodeSnippet(_ref) {
150
151
  handleScroll();
151
152
  }
152
153
  }
153
- });
154
+ }, [type, maxCollapsedNumberOfRows, maxExpandedNumberOfRows, minExpandedNumberOfRows, rowHeightInPixels]);
154
155
  React.useEffect(function () {
155
156
  handleScroll();
156
157
  }, [handleScroll]);
@@ -0,0 +1,151 @@
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 Downshift from 'downshift';
8
+ import { ReactNodeLike } from 'prop-types';
9
+ import React from 'react';
10
+ import { ListBoxType, ListBoxSize } from '../ListBox';
11
+ type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type' | 'size';
12
+ export interface ComboBoxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
13
+ /**
14
+ * 'aria-label' of the ListBox component.
15
+ */
16
+ ariaLabel?: string;
17
+ /**
18
+ * An optional className to add to the container node
19
+ */
20
+ className?: string;
21
+ /**
22
+ * Specify the direction of the combobox dropdown. Can be either top or bottom.
23
+ */
24
+ direction?: 'top' | 'bottom';
25
+ /**
26
+ * Specify if the control should be disabled, or not
27
+ */
28
+ disabled?: boolean;
29
+ /**
30
+ * Additional props passed to Downshift
31
+ */
32
+ downshiftProps?: React.ComponentProps<typeof Downshift>;
33
+ /**
34
+ * Provide helper text that is used alongside the control label for
35
+ * additional help
36
+ */
37
+ helperText?: string;
38
+ /**
39
+ * Specify a custom `id` for the input
40
+ */
41
+ id: string;
42
+ /**
43
+ * Allow users to pass in an arbitrary item or a string (in case their items are an array of strings)
44
+ * from their collection that are pre-selected
45
+ */
46
+ initialSelectedItem?: object | string | number;
47
+ /**
48
+ * Specify if the currently selected value is invalid.
49
+ */
50
+ invalid?: boolean;
51
+ /**
52
+ * Message which is displayed if the value is invalid.
53
+ */
54
+ invalidText?: ReactNodeLike;
55
+ /**
56
+ * Optional function to render items as custom components instead of strings.
57
+ * Defaults to null and is overridden by a getter
58
+ */
59
+ itemToElement?: React.ComponentType | null;
60
+ /**
61
+ * Helper function passed to downshift that allows the library to render a
62
+ * given item to a string label. By default, it extracts the `label` field
63
+ * from a given item to serve as the item label in the list
64
+ */
65
+ itemToString?: (item: unknown) => string;
66
+ /**
67
+ * We try to stay as generic as possible here to allow individuals to pass
68
+ * in a collection of whatever kind of data structure they prefer
69
+ */
70
+ items: (object | string | number)[];
71
+ /**
72
+ * @deprecated
73
+ * should use "light theme" (white background)?
74
+ */
75
+ light?: boolean;
76
+ /**
77
+ * `onChange` is a utility for this controlled component to communicate to a
78
+ * consuming component when a specific dropdown item is selected.
79
+ * `({ selectedItem }) => void`
80
+ // * @param {{ selectedItem }}
81
+ */
82
+ onChange: (data: {
83
+ selectedItem: any;
84
+ }) => void;
85
+ /**
86
+ * Callback function to notify consumer when the text input changes.
87
+ * This provides support to change available items based on the text.
88
+ * `(inputText) => void`
89
+ * @param {string} inputText
90
+ */
91
+ onInputChange?: (inputText: string) => void;
92
+ /**
93
+ * Helper function passed to Downshift that allows the user to observe internal
94
+ * state changes
95
+ * `(changes, stateAndHelpers) => void`
96
+ */
97
+ onStateChange?: (changes: object, stateAndHelpers: object) => void;
98
+ /**
99
+ * Callback function that fires when the combobox menu toggle is clicked
100
+ * `(evt) => void`
101
+ * @param {MouseEvent} event
102
+ */
103
+ onToggleClick?: (evt: MouseEvent) => void;
104
+ /**
105
+ * Used to provide a placeholder text node before a user enters any input.
106
+ * This is only present if the control has no items selected
107
+ */
108
+ placeholder?: string;
109
+ /**
110
+ * Is the ComboBox readonly?
111
+ */
112
+ readOnly?: boolean;
113
+ /**
114
+ * For full control of the selection
115
+ */
116
+ selectedItem?: object | string | number;
117
+ /**
118
+ * Specify your own filtering logic by passing in a `shouldFilterItem`
119
+ * function that takes in the current input and an item and passes back
120
+ * whether or not the item should be filtered.
121
+ */
122
+ shouldFilterItem?: (input: any) => boolean;
123
+ /**
124
+ * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
125
+ */
126
+ size?: ListBoxSize;
127
+ /**
128
+ * Provide text to be used in a `<label>` element that is tied to the
129
+ * combobox via ARIA attributes.
130
+ */
131
+ titleText?: ReactNodeLike;
132
+ /**
133
+ * Specify a custom translation function that takes in a message identifier
134
+ * and returns the localized string for the message
135
+ */
136
+ translateWithId?: (id: any) => string;
137
+ /**
138
+ * Currently supports either the default type, or an inline variant
139
+ */
140
+ type?: ListBoxType;
141
+ /**
142
+ * Specify whether the control is currently in warning state
143
+ */
144
+ warn?: boolean;
145
+ /**
146
+ * Provide the text that is displayed when the control is in warning state
147
+ */
148
+ warnText?: ReactNodeLike;
149
+ }
150
+ declare const ComboBox: React.ForwardRefExoticComponent<ComboBoxProps & React.RefAttributes<unknown>>;
151
+ export default ComboBox;