@carbon/react 1.22.0-rc.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.
- package/es/{es/components → components}/Checkbox/Checkbox.Skeleton.d.ts +0 -0
- package/es/{es/components → components}/Checkbox/Checkbox.d.ts +0 -0
- package/es/{es/components → components}/Checkbox/index.d.ts +0 -0
- package/es/components/CodeSnippet/CodeSnippet.js +2 -2
- package/es/components/ComboBox/ComboBox.d.ts +151 -0
- package/es/components/ComboBox/ComboBox.js +28 -21
- package/es/components/ComposedModal/ComposedModal.js +2 -2
- package/es/{es/components → components}/DataTable/TableSelectAll.d.ts +0 -0
- package/es/components/DataTable/TableSelectRow.d.ts +88 -0
- package/es/components/DataTable/TableSelectRow.js +3 -5
- package/es/components/DatePicker/DatePicker.js +1 -1
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +10 -1
- package/es/components/DatePicker/plugins/rangePlugin.js +1 -1
- package/es/{es/components → components}/Dropdown/Dropdown.d.ts +0 -0
- package/es/{es/components → components}/Dropdown/index.d.ts +0 -0
- package/es/components/FileUploader/FileUploaderButton.js +14 -16
- package/es/{es/components → components}/FluidForm/FluidForm.d.ts +0 -0
- package/es/{es/components → components}/FluidForm/FormContext.d.ts +0 -0
- package/es/{es/components → components}/FluidForm/index.d.ts +0 -0
- package/es/components/FluidSelect/FluidSelect.js +1 -0
- package/es/components/IconButton/index.js +1 -0
- package/es/{es/components → components}/ListBox/ListBox.d.ts +0 -0
- package/es/{es/components → components}/ListBox/ListBoxField.d.ts +0 -0
- package/es/{es/components → components}/ListBox/ListBoxMenu.d.ts +0 -0
- package/es/{es/components → components}/ListBox/ListBoxMenuIcon.d.ts +0 -0
- package/es/{es/components → components}/ListBox/ListBoxMenuItem.d.ts +0 -0
- package/es/{es/components → components}/ListBox/ListBoxPropTypes.d.ts +0 -0
- package/es/{es/components → components}/ListBox/ListBoxSelection.d.ts +0 -0
- package/es/{es/components → components}/ListBox/index.d.ts +0 -0
- package/es/{es/components → components}/NumberInput/NumberInput.Skeleton.d.ts +0 -0
- package/es/components/NumberInput/NumberInput.d.ts +132 -0
- package/es/components/NumberInput/NumberInput.js +9 -7
- package/es/components/OverflowMenu/OverflowMenu.js +28 -34
- package/es/components/Pagination/Pagination.js +1 -0
- package/es/components/Pagination/experimental/PageSelector.js +1 -0
- package/es/components/Pagination/experimental/Pagination.js +1 -0
- package/es/components/Select/Select.Skeleton.d.ts +33 -0
- package/es/components/Select/index.js +1 -0
- package/es/{es/components → components}/Slider/Slider.Skeleton.d.ts +0 -0
- package/es/{es/components → components}/Text/Text.d.ts +0 -0
- package/es/{es/components → components}/Text/TextDirection.d.ts +0 -0
- package/es/{es/components → components}/Text/createTextComponent.d.ts +0 -0
- package/es/{es/components → components}/Text/index.d.ts +0 -0
- package/es/components/TextArea/TextArea.js +1 -0
- package/es/components/Toggle/Toggle.js +54 -33
- package/es/components/Toggletip/index.js +26 -1
- package/es/components/Tooltip/Tooltip.js +33 -4
- package/es/{es/index.d.ts → index.d.ts} +0 -0
- package/es/internal/FloatingMenu.js +1 -4
- package/es/internal/useNormalizedInputProps.js +3 -3
- package/es/{es/internal → internal}/usePrefix.d.ts +0 -0
- package/lib/{lib/components → components}/Checkbox/Checkbox.Skeleton.d.ts +0 -0
- package/lib/{lib/components → components}/Checkbox/Checkbox.d.ts +0 -0
- package/lib/{lib/components → components}/Checkbox/index.d.ts +0 -0
- package/lib/components/CodeSnippet/CodeSnippet.js +4 -3
- package/lib/components/ComboBox/ComboBox.d.ts +151 -0
- package/lib/components/ComboBox/ComboBox.js +28 -21
- package/lib/components/ComposedModal/ComposedModal.js +2 -2
- package/lib/{lib/components → components}/DataTable/TableSelectAll.d.ts +0 -0
- package/lib/components/DataTable/TableSelectRow.d.ts +88 -0
- package/lib/components/DataTable/TableSelectRow.js +2 -4
- package/lib/components/DatePicker/DatePicker.js +9 -8
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +10 -1
- package/lib/components/DatePicker/plugins/rangePlugin.js +6 -2
- package/lib/{lib/components → components}/Dropdown/Dropdown.d.ts +0 -0
- package/lib/{lib/components → components}/Dropdown/index.d.ts +0 -0
- package/lib/components/FileUploader/FileUploaderButton.js +14 -16
- package/lib/{lib/components → components}/FluidForm/FluidForm.d.ts +0 -0
- package/lib/{lib/components → components}/FluidForm/FormContext.d.ts +0 -0
- package/lib/{lib/components → components}/FluidForm/index.d.ts +0 -0
- package/lib/components/FluidSelect/FluidSelect.js +1 -0
- package/lib/components/IconButton/index.js +1 -0
- package/lib/{lib/components → components}/ListBox/ListBox.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/ListBoxField.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/ListBoxMenu.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/ListBoxMenuIcon.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/ListBoxMenuItem.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/ListBoxPropTypes.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/ListBoxSelection.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/index.d.ts +0 -0
- package/lib/{lib/components → components}/NumberInput/NumberInput.Skeleton.d.ts +0 -0
- package/lib/components/NumberInput/NumberInput.d.ts +132 -0
- package/lib/components/NumberInput/NumberInput.js +9 -7
- package/lib/components/OverflowMenu/OverflowMenu.js +27 -52
- package/lib/components/Pagination/Pagination.js +1 -0
- package/lib/components/Pagination/experimental/PageSelector.js +1 -0
- package/lib/components/Pagination/experimental/Pagination.js +1 -0
- package/lib/components/Select/Select.Skeleton.d.ts +33 -0
- package/lib/components/Select/index.js +2 -0
- package/lib/{lib/components → components}/Slider/Slider.Skeleton.d.ts +0 -0
- package/lib/{lib/components → components}/Text/Text.d.ts +0 -0
- package/lib/{lib/components → components}/Text/TextDirection.d.ts +0 -0
- package/lib/{lib/components → components}/Text/createTextComponent.d.ts +0 -0
- package/lib/{lib/components → components}/Text/index.d.ts +0 -0
- package/lib/components/TextArea/TextArea.js +1 -0
- package/lib/components/Toggle/Toggle.js +53 -32
- package/lib/components/Toggletip/index.js +26 -1
- package/lib/components/Tooltip/Tooltip.js +31 -2
- package/lib/{lib/index.d.ts → index.d.ts} +0 -0
- package/lib/internal/FloatingMenu.js +1 -4
- package/lib/internal/useNormalizedInputProps.js +3 -3
- package/lib/{lib/internal → internal}/usePrefix.d.ts +0 -0
- package/package.json +4 -6
- package/es/_virtual/ResizeObserver.es.js +0 -13
- package/es/_virtual/_commonjsHelpers.js +0 -42
- package/es/_virtual/index.js +0 -14
- package/es/_virtual/rangePlugin.js +0 -14
- package/es/node_modules/flatpickr/dist/l10n/index.js +0 -1423
- package/es/node_modules/flatpickr/dist/plugins/rangePlugin.js +0 -196
- package/es/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +0 -1112
- package/es/node_modules/use-resize-observer/polyfilled.js +0 -111
- package/lib/_virtual/ResizeObserver.es.js +0 -17
- package/lib/_virtual/_commonjsHelpers.js +0 -48
- package/lib/_virtual/index.js +0 -18
- package/lib/_virtual/rangePlugin.js +0 -18
- package/lib/node_modules/flatpickr/dist/l10n/index.js +0 -1427
- package/lib/node_modules/flatpickr/dist/plugins/rangePlugin.js +0 -200
- package/lib/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +0 -1116
- package/lib/node_modules/use-resize-observer/polyfilled.js +0 -119
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import React__default, { useRef, useEffect } from 'react';
|
|
@@ -15,9 +15,9 @@ import { useId } from '../../internal/useId.js';
|
|
|
15
15
|
import { useNoInteractiveChildren, getInteractiveContent } from '../../internal/useNoInteractiveChildren.js';
|
|
16
16
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
17
|
import { match } from '../../internal/keyboard/match.js';
|
|
18
|
-
import { Escape } from '../../internal/keyboard/keys.js';
|
|
18
|
+
import { Escape, Enter, Space } from '../../internal/keyboard/keys.js';
|
|
19
19
|
|
|
20
|
-
var _excluded = ["align", "className", "children", "label", "description", "enterDelayMs", "leaveDelayMs", "defaultOpen"];
|
|
20
|
+
var _excluded = ["align", "className", "children", "label", "description", "enterDelayMs", "leaveDelayMs", "defaultOpen", "closeOnActivation"];
|
|
21
21
|
|
|
22
22
|
function Tooltip(_ref) {
|
|
23
23
|
var _ref$align = _ref.align,
|
|
@@ -32,6 +32,8 @@ function Tooltip(_ref) {
|
|
|
32
32
|
leaveDelayMs = _ref$leaveDelayMs === void 0 ? 300 : _ref$leaveDelayMs,
|
|
33
33
|
_ref$defaultOpen = _ref.defaultOpen,
|
|
34
34
|
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
35
|
+
_ref$closeOnActivatio = _ref.closeOnActivation,
|
|
36
|
+
closeOnActivation = _ref$closeOnActivatio === void 0 ? false : _ref$closeOnActivatio,
|
|
35
37
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
36
38
|
|
|
37
39
|
var containerRef = useRef(null);
|
|
@@ -52,10 +54,28 @@ function Tooltip(_ref) {
|
|
|
52
54
|
onBlur: function onBlur() {
|
|
53
55
|
return setOpen(false);
|
|
54
56
|
},
|
|
57
|
+
onClick: function onClick() {
|
|
58
|
+
return closeOnActivation && setOpen(false);
|
|
59
|
+
},
|
|
55
60
|
// This should be placed on the trigger in case the element is disabled
|
|
56
61
|
onMouseEnter: onMouseEnter
|
|
57
62
|
};
|
|
58
63
|
|
|
64
|
+
function getChildEventHandlers(childProps) {
|
|
65
|
+
var eventHandlerFunctions = ['onFocus', 'onBlur', 'onClick', 'onMouseEnter'];
|
|
66
|
+
var eventHandlers = {};
|
|
67
|
+
eventHandlerFunctions.forEach(function (functionName) {
|
|
68
|
+
eventHandlers[functionName] = function (evt) {
|
|
69
|
+
triggerProps[functionName]();
|
|
70
|
+
|
|
71
|
+
if (childProps !== null && childProps !== void 0 && childProps[functionName]) {
|
|
72
|
+
childProps === null || childProps === void 0 ? void 0 : childProps[functionName](evt);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
return eventHandlers;
|
|
77
|
+
}
|
|
78
|
+
|
|
59
79
|
if (label) {
|
|
60
80
|
triggerProps['aria-labelledby'] = id;
|
|
61
81
|
} else {
|
|
@@ -67,6 +87,10 @@ function Tooltip(_ref) {
|
|
|
67
87
|
event.stopPropagation();
|
|
68
88
|
setOpen(false);
|
|
69
89
|
}
|
|
90
|
+
|
|
91
|
+
if (open && closeOnActivation && (match(event, Enter) || match(event, Space))) {
|
|
92
|
+
setOpen(false);
|
|
93
|
+
}
|
|
70
94
|
}
|
|
71
95
|
|
|
72
96
|
function onMouseEnter() {
|
|
@@ -94,7 +118,7 @@ function Tooltip(_ref) {
|
|
|
94
118
|
onMouseLeave: onMouseLeave,
|
|
95
119
|
open: open,
|
|
96
120
|
ref: containerRef
|
|
97
|
-
}), /*#__PURE__*/React__default.cloneElement(child, triggerProps), /*#__PURE__*/React__default.createElement(PopoverContent, {
|
|
121
|
+
}), /*#__PURE__*/React__default.cloneElement(child, _objectSpread2(_objectSpread2({}, triggerProps), getChildEventHandlers(child.props))), /*#__PURE__*/React__default.createElement(PopoverContent, {
|
|
98
122
|
"aria-hidden": "true",
|
|
99
123
|
className: "".concat(prefix, "--tooltip-content"),
|
|
100
124
|
id: id,
|
|
@@ -119,6 +143,11 @@ Tooltip.propTypes = {
|
|
|
119
143
|
*/
|
|
120
144
|
className: PropTypes.string,
|
|
121
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Determines wether the tooltip should close when inner content is activated (click, Enter or Space)
|
|
148
|
+
*/
|
|
149
|
+
closeOnActivation: PropTypes.bool,
|
|
150
|
+
|
|
122
151
|
/**
|
|
123
152
|
* Specify whether the tooltip should be open when it first renders
|
|
124
153
|
*/
|
|
File without changes
|
|
@@ -266,10 +266,7 @@ var FloatingMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
266
266
|
tabbableNode || // First sequentially focusable node
|
|
267
267
|
focusableNode || // First programmatic focusable node
|
|
268
268
|
menuBody;
|
|
269
|
-
|
|
270
|
-
if (_this.props.focusTrap) {
|
|
271
|
-
focusTarget.focus();
|
|
272
|
-
}
|
|
269
|
+
focusTarget.focus();
|
|
273
270
|
|
|
274
271
|
if (focusTarget === menuBody && process.env.NODE_ENV !== "production") {
|
|
275
272
|
process.env.NODE_ENV !== "production" ? warning(focusableNode === null, 'Floating Menus must have at least a programmatically focusable child. ' + 'This can be accomplished by adding tabIndex="-1" to the content element.') : void 0;
|
|
@@ -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 {
|
|
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 {
|
|
20
|
+
* @property {React.ReactNode | undefined} warnText - The validation message displayed in case the input is in warning state
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
/**
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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
|
|
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
|
-
|
|
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;
|
|
@@ -71,7 +71,8 @@ var getInputValue = function getInputValue(_ref) {
|
|
|
71
71
|
|
|
72
72
|
var findHighlightedIndex = function findHighlightedIndex(_ref2, inputValue) {
|
|
73
73
|
var items = _ref2.items,
|
|
74
|
-
itemToString = _ref2.itemToString
|
|
74
|
+
_ref2$itemToString = _ref2.itemToString,
|
|
75
|
+
itemToString = _ref2$itemToString === void 0 ? defaultItemToString : _ref2$itemToString;
|
|
75
76
|
|
|
76
77
|
if (!inputValue) {
|
|
77
78
|
return -1;
|
|
@@ -80,9 +81,9 @@ var findHighlightedIndex = function findHighlightedIndex(_ref2, inputValue) {
|
|
|
80
81
|
var searchValue = inputValue.toLowerCase();
|
|
81
82
|
|
|
82
83
|
for (var i = 0; i < items.length; i++) {
|
|
83
|
-
var
|
|
84
|
+
var _item = itemToString(items[i]).toLowerCase();
|
|
84
85
|
|
|
85
|
-
if (
|
|
86
|
+
if (_item.indexOf(searchValue) !== -1) {
|
|
86
87
|
return i;
|
|
87
88
|
}
|
|
88
89
|
}
|
|
@@ -92,7 +93,7 @@ var findHighlightedIndex = function findHighlightedIndex(_ref2, inputValue) {
|
|
|
92
93
|
|
|
93
94
|
var getInstanceId = setupGetInstanceId["default"]();
|
|
94
95
|
var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props, ref) {
|
|
95
|
-
var _cx, _ref4, _Text;
|
|
96
|
+
var _cx, _ref4, _cx4, _Text;
|
|
96
97
|
|
|
97
98
|
var ariaLabel = props.ariaLabel,
|
|
98
99
|
containerClassName = props.className,
|
|
@@ -129,7 +130,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
129
130
|
var _useContext = React.useContext(FormContext.FormContext),
|
|
130
131
|
isFluid = _useContext.isFluid;
|
|
131
132
|
|
|
132
|
-
var textInput = React.useRef();
|
|
133
|
+
var textInput = React.useRef(null);
|
|
133
134
|
var comboBoxInstanceId = getInstanceId();
|
|
134
135
|
|
|
135
136
|
var _useState = React.useState(getInputValue({
|
|
@@ -147,12 +148,12 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
147
148
|
isFocused = _useState4[0],
|
|
148
149
|
setIsFocused = _useState4[1];
|
|
149
150
|
|
|
150
|
-
var _useState5 = React.useState(
|
|
151
|
+
var _useState5 = React.useState(),
|
|
151
152
|
_useState6 = _rollupPluginBabelHelpers.slicedToArray(_useState5, 2),
|
|
152
153
|
prevSelectedItem = _useState6[0],
|
|
153
154
|
setPrevSelectedItem = _useState6[1];
|
|
154
155
|
|
|
155
|
-
var _useState7 = React.useState(
|
|
156
|
+
var _useState7 = React.useState(false),
|
|
156
157
|
_useState8 = _rollupPluginBabelHelpers.slicedToArray(_useState7, 2),
|
|
157
158
|
doneInitialSelectedItem = _useState8[0],
|
|
158
159
|
setDoneInitialSelectedItem = _useState8[1];
|
|
@@ -172,11 +173,11 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
172
173
|
|
|
173
174
|
var filterItems = function filterItems(items, itemToString, inputValue) {
|
|
174
175
|
return items.filter(function (item) {
|
|
175
|
-
return shouldFilterItem({
|
|
176
|
+
return shouldFilterItem ? shouldFilterItem({
|
|
176
177
|
item: item,
|
|
177
178
|
itemToString: itemToString,
|
|
178
179
|
inputValue: inputValue
|
|
179
|
-
});
|
|
180
|
+
}) : defaultShouldFilterItem();
|
|
180
181
|
});
|
|
181
182
|
};
|
|
182
183
|
|
|
@@ -239,7 +240,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
239
240
|
var comboBoxHelperId = !helperText ? undefined : "combobox-helper-text-".concat(comboBoxInstanceId);
|
|
240
241
|
var helperClasses = cx__default["default"]("".concat(prefix, "--form__helper-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
241
242
|
var wrapperClasses = cx__default["default"]("".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null, (_ref4 = {}, _rollupPluginBabelHelpers.defineProperty(_ref4, "".concat(prefix, "--list-box__wrapper--fluid--invalid"), isFluid && invalid), _rollupPluginBabelHelpers.defineProperty(_ref4, "".concat(prefix, "--list-box__wrapper--fluid--focus"), isFluid && isFocused), _ref4)]);
|
|
242
|
-
var inputClasses = cx__default["default"]("".concat(prefix, "--text-input"), _rollupPluginBabelHelpers.defineProperty(
|
|
243
|
+
var inputClasses = cx__default["default"]("".concat(prefix, "--text-input"), (_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--text-input--empty"), !inputValue), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--combo-box--input--focus"), isFocused && !isFluid), _cx4)); // needs to be Capitalized for react to render it correctly
|
|
243
244
|
|
|
244
245
|
var ItemToElement = itemToElement;
|
|
245
246
|
return /*#__PURE__*/React__default["default"].createElement(Downshift__default["default"], _rollupPluginBabelHelpers["extends"]({}, downshiftProps, {
|
|
@@ -275,7 +276,8 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
275
276
|
highlightedIndex = _ref5.highlightedIndex,
|
|
276
277
|
clearSelection = _ref5.clearSelection,
|
|
277
278
|
toggleMenu = _ref5.toggleMenu;
|
|
278
|
-
var rootProps = getRootProps(
|
|
279
|
+
var rootProps = getRootProps( // @ts-ignore this is not supposed to be a required property
|
|
280
|
+
{}, {
|
|
279
281
|
suppressRefError: true
|
|
280
282
|
});
|
|
281
283
|
var labelProps = getLabelProps();
|
|
@@ -317,11 +319,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
317
319
|
});
|
|
318
320
|
|
|
319
321
|
var handleFocus = function handleFocus(evt) {
|
|
320
|
-
|
|
321
|
-
setIsFocused(false);
|
|
322
|
-
} else {
|
|
323
|
-
setIsFocused(evt.type === 'focus' ? true : false);
|
|
324
|
-
}
|
|
322
|
+
setIsFocused(evt.type === 'focus');
|
|
325
323
|
};
|
|
326
324
|
|
|
327
325
|
var readOnlyEventHandlers = readOnly ? {
|
|
@@ -373,7 +371,8 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
373
371
|
clearSelection: clearSelection,
|
|
374
372
|
translateWithId: translateWithId,
|
|
375
373
|
disabled: disabled || readOnly,
|
|
376
|
-
onClearSelection: handleSelectionClear
|
|
374
|
+
onClearSelection: handleSelectionClear,
|
|
375
|
+
selectionCount: 0
|
|
377
376
|
}), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
|
|
378
377
|
isOpen: isOpen,
|
|
379
378
|
translateWithId: translateWithId
|
|
@@ -385,15 +384,18 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
385
384
|
var itemProps = getItemProps((_getItemProps = {
|
|
386
385
|
item: item,
|
|
387
386
|
index: index
|
|
388
|
-
}, _rollupPluginBabelHelpers.defineProperty(_getItemProps, 'aria-current', selectedItem === item ? true :
|
|
387
|
+
}, _rollupPluginBabelHelpers.defineProperty(_getItemProps, 'aria-current', selectedItem === item ? 'true' : 'false'), _rollupPluginBabelHelpers.defineProperty(_getItemProps, 'aria-selected', highlightedIndex === index ? 'true' : 'false'), _rollupPluginBabelHelpers.defineProperty(_getItemProps, "disabled", item.disabled), _getItemProps));
|
|
389
388
|
return /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
390
389
|
key: itemProps.id,
|
|
391
390
|
isActive: selectedItem === item,
|
|
392
391
|
isHighlighted: highlightedIndex === index || (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.id) && (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.id) === item.id || false,
|
|
393
|
-
title: itemToElement ? item.text : itemToString(item)
|
|
394
|
-
}, itemProps), itemToElement ?
|
|
392
|
+
title: itemToElement ? item.text : itemToString ? itemToString(item) : undefined
|
|
393
|
+
}, itemProps), itemToElement ?
|
|
394
|
+
/*#__PURE__*/
|
|
395
|
+
// @ts-ignore
|
|
396
|
+
React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
|
|
395
397
|
key: itemProps.id
|
|
396
|
-
}, item)) : itemToString(item), selectedItem === item && /*#__PURE__*/React__default["default"].createElement(iconsReact.Checkmark, {
|
|
398
|
+
}, item)) : itemToString ? itemToString(item) : defaultItemToString(item), selectedItem === item && /*#__PURE__*/React__default["default"].createElement(iconsReact.Checkmark, {
|
|
397
399
|
className: "".concat(prefix, "--list-box__menu-item__selected-icon")
|
|
398
400
|
}));
|
|
399
401
|
}) : null)), helperText && !invalid && !warn && !isFluid && (_Text || (_Text = /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
@@ -428,6 +430,7 @@ ComboBox.propTypes = {
|
|
|
428
430
|
/**
|
|
429
431
|
* Additional props passed to Downshift
|
|
430
432
|
*/
|
|
433
|
+
// @ts-ignore
|
|
431
434
|
downshiftProps: PropTypes__default["default"].shape(Downshift__default["default"].propTypes),
|
|
432
435
|
|
|
433
436
|
/**
|
|
@@ -484,6 +487,7 @@ ComboBox.propTypes = {
|
|
|
484
487
|
/**
|
|
485
488
|
* `onChange` is a utility for this controlled component to communicate to a
|
|
486
489
|
* consuming component when a specific dropdown item is selected.
|
|
490
|
+
* `({ selectedItem }) => void`
|
|
487
491
|
* @param {{ selectedItem }}
|
|
488
492
|
*/
|
|
489
493
|
onChange: PropTypes__default["default"].func.isRequired,
|
|
@@ -491,6 +495,7 @@ ComboBox.propTypes = {
|
|
|
491
495
|
/**
|
|
492
496
|
* Callback function to notify consumer when the text input changes.
|
|
493
497
|
* This provides support to change available items based on the text.
|
|
498
|
+
* `(inputText) => void`
|
|
494
499
|
* @param {string} inputText
|
|
495
500
|
*/
|
|
496
501
|
onInputChange: PropTypes__default["default"].func,
|
|
@@ -498,11 +503,13 @@ ComboBox.propTypes = {
|
|
|
498
503
|
/**
|
|
499
504
|
* Helper function passed to Downshift that allows the user to observe internal
|
|
500
505
|
* state changes
|
|
506
|
+
* `(changes, stateAndHelpers) => void`
|
|
501
507
|
*/
|
|
502
508
|
onStateChange: PropTypes__default["default"].func,
|
|
503
509
|
|
|
504
510
|
/**
|
|
505
511
|
* Callback function that fires when the combobox menu toggle is clicked
|
|
512
|
+
* `(evt) => void`
|
|
506
513
|
* @param {MouseEvent} event
|
|
507
514
|
*/
|
|
508
515
|
onToggleClick: PropTypes__default["default"].func,
|
|
@@ -104,7 +104,7 @@ var ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
104
104
|
onKeyDown(evt);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function
|
|
107
|
+
function handleMousedown(evt) {
|
|
108
108
|
if (!innerModal.current.contains(evt.target) && preventCloseOnClickOutside) {
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
@@ -204,7 +204,7 @@ var ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
204
204
|
ref: ref,
|
|
205
205
|
"aria-hidden": !open,
|
|
206
206
|
onBlur: handleBlur,
|
|
207
|
-
|
|
207
|
+
onMouseDown: handleMousedown,
|
|
208
208
|
onKeyDown: handleKeyDown,
|
|
209
209
|
className: modalClass,
|
|
210
210
|
tabIndex: "-1"
|
|
File without changes
|
|
@@ -0,0 +1,88 @@
|
|
|
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 React from 'react';
|
|
9
|
+
export interface TableSelectRowProps {
|
|
10
|
+
/**
|
|
11
|
+
* Specify the aria label for the underlying input control
|
|
12
|
+
*/
|
|
13
|
+
ariaLabel: string;
|
|
14
|
+
/**
|
|
15
|
+
* Specify whether this row is selected, or not
|
|
16
|
+
*/
|
|
17
|
+
checked: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The CSS class names of the cell that wraps the underlying input control
|
|
20
|
+
*/
|
|
21
|
+
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Specify whether the control is disabled
|
|
24
|
+
*/
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Provide an `id` for the underlying input control
|
|
28
|
+
*/
|
|
29
|
+
id: string;
|
|
30
|
+
/**
|
|
31
|
+
* Provide a `name` for the underlying input control
|
|
32
|
+
*/
|
|
33
|
+
name: string;
|
|
34
|
+
/**
|
|
35
|
+
* Provide an optional hook that is called each time the input is updated
|
|
36
|
+
*/
|
|
37
|
+
onChange?: (value: boolean, name: string, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Provide a handler to listen to when a user initiates a selection request
|
|
40
|
+
*/
|
|
41
|
+
onSelect: React.MouseEventHandler<HTMLInputElement>;
|
|
42
|
+
/**
|
|
43
|
+
* Specify whether the control should be a radio button or inline checkbox
|
|
44
|
+
*/
|
|
45
|
+
radio?: boolean;
|
|
46
|
+
}
|
|
47
|
+
declare const TableSelectRow: {
|
|
48
|
+
({ ariaLabel, checked, id, name, onSelect, onChange, disabled, radio, className, }: TableSelectRowProps): JSX.Element;
|
|
49
|
+
propTypes: {
|
|
50
|
+
/**
|
|
51
|
+
* Specify the aria label for the underlying input control
|
|
52
|
+
*/
|
|
53
|
+
ariaLabel: PropTypes.Validator<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Specify whether this row is selected, or not
|
|
56
|
+
*/
|
|
57
|
+
checked: PropTypes.Validator<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* The CSS class names of the cell that wraps the underlying input control
|
|
60
|
+
*/
|
|
61
|
+
className: PropTypes.Requireable<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Specify whether the control is disabled
|
|
64
|
+
*/
|
|
65
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Provide an `id` for the underlying input control
|
|
68
|
+
*/
|
|
69
|
+
id: PropTypes.Validator<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Provide a `name` for the underlying input control
|
|
72
|
+
*/
|
|
73
|
+
name: PropTypes.Validator<string>;
|
|
74
|
+
/**
|
|
75
|
+
* Provide an optional hook that is called each time the input is updated
|
|
76
|
+
*/
|
|
77
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
78
|
+
/**
|
|
79
|
+
* Provide a handler to listen to when a user initiates a selection request
|
|
80
|
+
*/
|
|
81
|
+
onSelect: PropTypes.Validator<(...args: any[]) => any>;
|
|
82
|
+
/**
|
|
83
|
+
* Specify whether the control should be a radio button or inline checkbox
|
|
84
|
+
*/
|
|
85
|
+
radio: PropTypes.Requireable<boolean>;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export default TableSelectRow;
|
|
@@ -24,8 +24,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
24
24
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
25
25
|
|
|
26
26
|
var TableSelectRow = function TableSelectRow(_ref) {
|
|
27
|
-
var _classNames;
|
|
28
|
-
|
|
29
27
|
var ariaLabel = _ref.ariaLabel,
|
|
30
28
|
checked = _ref.checked,
|
|
31
29
|
id = _ref.id,
|
|
@@ -45,7 +43,7 @@ var TableSelectRow = function TableSelectRow(_ref) {
|
|
|
45
43
|
disabled: disabled
|
|
46
44
|
};
|
|
47
45
|
var InlineInputComponent = radio ? RadioButton["default"] : InlineCheckbox["default"];
|
|
48
|
-
var tableSelectRowClasses = cx__default["default"]("".concat(prefix, "--table-column-checkbox"), (
|
|
46
|
+
var tableSelectRowClasses = cx__default["default"]("".concat(prefix, "--table-column-checkbox"), _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, className && _rollupPluginBabelHelpers.defineProperty({}, className, true)), {}, _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--table-column-radio"), radio)));
|
|
49
47
|
return /*#__PURE__*/React__default["default"].createElement("td", {
|
|
50
48
|
className: tableSelectRowClasses
|
|
51
49
|
}, /*#__PURE__*/React__default["default"].createElement(InlineInputComponent, _rollupPluginBabelHelpers["extends"]({}, selectionInputProps, radio && {
|
|
@@ -63,7 +61,7 @@ TableSelectRow.propTypes = {
|
|
|
63
61
|
ariaLabel: PropTypes__default["default"].string.isRequired,
|
|
64
62
|
|
|
65
63
|
/**
|
|
66
|
-
* Specify whether
|
|
64
|
+
* Specify whether this row is selected, or not
|
|
67
65
|
*/
|
|
68
66
|
checked: PropTypes__default["default"].bool.isRequired,
|
|
69
67
|
|