@carbon/react 1.38.0 → 1.39.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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1391 -782
- package/es/components/CodeSnippet/CodeSnippet.js +9 -2
- package/es/components/ComboBox/ComboBox.d.ts +30 -27
- package/es/components/ComboBox/ComboBox.js +23 -24
- package/es/components/Copy/Copy.js +6 -1
- package/es/components/CopyButton/CopyButton.js +6 -0
- package/es/components/FileUploader/FileUploader.js +1 -1
- package/es/components/Grid/index.d.ts +1 -0
- package/es/components/Link/Link.d.ts +1 -1
- package/es/components/Link/index.d.ts +2 -2
- package/es/components/MultiSelect/MultiSelect.d.ts +24 -0
- package/es/components/MultiSelect/MultiSelect.js +26 -0
- package/es/components/Popover/index.d.ts +9 -5
- package/es/components/Popover/index.js +2 -3
- package/es/components/StructuredList/StructuredList.Skeleton.d.ts +32 -0
- package/es/components/StructuredList/StructuredList.Skeleton.js +16 -26
- package/es/components/StructuredList/StructuredList.d.ts +271 -0
- package/es/components/StructuredList/StructuredList.js +14 -33
- package/es/components/StructuredList/index.d.ts +8 -0
- package/es/components/UIShell/HeaderContainer.d.ts +1 -1
- package/es/components/UIShell/HeaderMenuButton.d.ts +4 -2
- package/es/components/UIShell/HeaderMenuItem.d.ts +1 -1
- package/es/components/UIShell/HeaderName.d.ts +1 -1
- package/es/components/UIShell/HeaderNavigation.d.ts +2 -5
- package/es/components/UIShell/HeaderSideNavItems.d.ts +1 -1
- package/es/components/UIShell/SideNav.d.ts +1 -1
- package/es/components/UIShell/SideNavDivider.js +2 -2
- package/es/components/UIShell/SkipToContent.d.ts +1 -1
- package/es/components/UIShell/index.d.ts +8 -8
- package/es/index.js +3 -2
- package/lib/components/CodeSnippet/CodeSnippet.js +9 -2
- package/lib/components/ComboBox/ComboBox.d.ts +30 -27
- package/lib/components/ComboBox/ComboBox.js +22 -23
- package/lib/components/Copy/Copy.js +6 -1
- package/lib/components/CopyButton/CopyButton.js +6 -0
- package/lib/components/FileUploader/FileUploader.js +1 -1
- package/lib/components/Grid/index.d.ts +1 -0
- package/lib/components/Link/Link.d.ts +1 -1
- package/lib/components/Link/index.d.ts +2 -2
- package/lib/components/MultiSelect/MultiSelect.d.ts +24 -0
- package/lib/components/MultiSelect/MultiSelect.js +26 -0
- package/lib/components/Popover/index.d.ts +9 -5
- package/lib/components/Popover/index.js +2 -3
- package/lib/components/StructuredList/StructuredList.Skeleton.d.ts +32 -0
- package/lib/components/StructuredList/StructuredList.Skeleton.js +16 -26
- package/lib/components/StructuredList/StructuredList.d.ts +271 -0
- package/lib/components/StructuredList/StructuredList.js +14 -33
- package/lib/components/StructuredList/index.d.ts +8 -0
- package/lib/components/UIShell/HeaderContainer.d.ts +1 -1
- package/lib/components/UIShell/HeaderMenuButton.d.ts +4 -2
- package/lib/components/UIShell/HeaderMenuItem.d.ts +1 -1
- package/lib/components/UIShell/HeaderName.d.ts +1 -1
- package/lib/components/UIShell/HeaderNavigation.d.ts +2 -5
- package/lib/components/UIShell/HeaderSideNavItems.d.ts +1 -1
- package/lib/components/UIShell/SideNav.d.ts +1 -1
- package/lib/components/UIShell/SideNavDivider.js +2 -2
- package/lib/components/UIShell/SkipToContent.d.ts +1 -1
- package/lib/components/UIShell/index.d.ts +8 -8
- package/lib/index.js +11 -9
- package/package.json +5 -6
|
@@ -27,6 +27,7 @@ const defaultMinCollapsedNumberOfRows = 3;
|
|
|
27
27
|
const defaultMinExpandedNumberOfRows = 16;
|
|
28
28
|
function CodeSnippet(_ref) {
|
|
29
29
|
let {
|
|
30
|
+
align = 'bottom',
|
|
30
31
|
className,
|
|
31
32
|
type,
|
|
32
33
|
children,
|
|
@@ -146,6 +147,7 @@ function CodeSnippet(_ref) {
|
|
|
146
147
|
}, children));
|
|
147
148
|
}
|
|
148
149
|
return /*#__PURE__*/React__default.createElement(Copy, _extends({}, rest, {
|
|
150
|
+
align: align,
|
|
149
151
|
onClick: handleCopyClick,
|
|
150
152
|
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
151
153
|
"aria-describedby": uid,
|
|
@@ -200,6 +202,7 @@ function CodeSnippet(_ref) {
|
|
|
200
202
|
}), hasRightOverflow && type !== 'multi' && /*#__PURE__*/React__default.createElement("div", {
|
|
201
203
|
className: `${prefix}--snippet__overflow-indicator--right`
|
|
202
204
|
}), !hideCopyButton && /*#__PURE__*/React__default.createElement(CopyButton, {
|
|
205
|
+
align: align,
|
|
203
206
|
size: type === 'multi' ? 'sm' : 'md',
|
|
204
207
|
disabled: disabled,
|
|
205
208
|
onClick: handleCopyClick,
|
|
@@ -222,13 +225,17 @@ function CodeSnippet(_ref) {
|
|
|
222
225
|
}
|
|
223
226
|
CodeSnippet.propTypes = {
|
|
224
227
|
/**
|
|
225
|
-
* Specify
|
|
228
|
+
* Specify how the trigger should align with the tooltip
|
|
229
|
+
*/
|
|
230
|
+
align: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
|
|
231
|
+
/**
|
|
232
|
+
* Specify a label to be read by screen readers on the containing textbox
|
|
226
233
|
* node
|
|
227
234
|
*/
|
|
228
235
|
['aria-label']: PropTypes.string,
|
|
229
236
|
/**
|
|
230
237
|
* Deprecated, please use `aria-label` instead.
|
|
231
|
-
* Specify a label to be read by screen readers on the containing
|
|
238
|
+
* Specify a label to be read by screen readers on the containing textbox
|
|
232
239
|
* node
|
|
233
240
|
*/
|
|
234
241
|
ariaLabel: deprecate(PropTypes.string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'),
|
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import Downshift from 'downshift';
|
|
8
|
-
import {
|
|
9
|
-
import React from 'react';
|
|
8
|
+
import { type ComponentProps, type ReactNode, type ComponentType, type ReactElement, type RefAttributes, type PropsWithChildren, type PropsWithoutRef, type InputHTMLAttributes, type MouseEvent } from 'react';
|
|
10
9
|
import { ListBoxType, ListBoxSize } from '../ListBox';
|
|
11
10
|
type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type' | 'size';
|
|
12
|
-
|
|
11
|
+
interface OnChangeData<ItemType> {
|
|
12
|
+
selectedItem: ItemType | null;
|
|
13
|
+
}
|
|
14
|
+
type ItemToStringHandler<ItemType> = (item: ItemType | null) => string;
|
|
15
|
+
export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
|
|
13
16
|
/**
|
|
14
17
|
* Specify a label to be read by screen readers on the container node
|
|
15
18
|
* 'aria-label' of the ListBox component.
|
|
@@ -35,12 +38,12 @@ export interface ComboBoxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
35
38
|
/**
|
|
36
39
|
* Additional props passed to Downshift
|
|
37
40
|
*/
|
|
38
|
-
downshiftProps?:
|
|
41
|
+
downshiftProps?: ComponentProps<typeof Downshift<ItemType>>;
|
|
39
42
|
/**
|
|
40
43
|
* Provide helper text that is used alongside the control label for
|
|
41
44
|
* additional help
|
|
42
45
|
*/
|
|
43
|
-
helperText?:
|
|
46
|
+
helperText?: ReactNode;
|
|
44
47
|
/**
|
|
45
48
|
* Specify a custom `id` for the input
|
|
46
49
|
*/
|
|
@@ -49,7 +52,7 @@ export interface ComboBoxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
49
52
|
* Allow users to pass in an arbitrary item or a string (in case their items are an array of strings)
|
|
50
53
|
* from their collection that are pre-selected
|
|
51
54
|
*/
|
|
52
|
-
initialSelectedItem?:
|
|
55
|
+
initialSelectedItem?: ItemType;
|
|
53
56
|
/**
|
|
54
57
|
* Specify if the currently selected value is invalid.
|
|
55
58
|
*/
|
|
@@ -57,23 +60,23 @@ export interface ComboBoxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
57
60
|
/**
|
|
58
61
|
* Message which is displayed if the value is invalid.
|
|
59
62
|
*/
|
|
60
|
-
invalidText?:
|
|
63
|
+
invalidText?: ReactNode;
|
|
61
64
|
/**
|
|
62
65
|
* Optional function to render items as custom components instead of strings.
|
|
63
66
|
* Defaults to null and is overridden by a getter
|
|
64
67
|
*/
|
|
65
|
-
itemToElement?:
|
|
68
|
+
itemToElement?: ComponentType<ItemType> | null;
|
|
66
69
|
/**
|
|
67
70
|
* Helper function passed to downshift that allows the library to render a
|
|
68
71
|
* given item to a string label. By default, it extracts the `label` field
|
|
69
72
|
* from a given item to serve as the item label in the list
|
|
70
73
|
*/
|
|
71
|
-
itemToString?:
|
|
74
|
+
itemToString?: ItemToStringHandler<ItemType>;
|
|
72
75
|
/**
|
|
73
76
|
* We try to stay as generic as possible here to allow individuals to pass
|
|
74
77
|
* in a collection of whatever kind of data structure they prefer
|
|
75
78
|
*/
|
|
76
|
-
items:
|
|
79
|
+
items: ItemType[];
|
|
77
80
|
/**
|
|
78
81
|
* @deprecated
|
|
79
82
|
* should use "light theme" (white background)?
|
|
@@ -85,9 +88,7 @@ export interface ComboBoxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
85
88
|
* `({ selectedItem }) => void`
|
|
86
89
|
// * @param {{ selectedItem }}
|
|
87
90
|
*/
|
|
88
|
-
onChange: (data:
|
|
89
|
-
selectedItem: any;
|
|
90
|
-
}) => void;
|
|
91
|
+
onChange: (data: OnChangeData<ItemType>) => void;
|
|
91
92
|
/**
|
|
92
93
|
* Callback function to notify consumer when the text input changes.
|
|
93
94
|
* This provides support to change available items based on the text.
|
|
@@ -95,18 +96,12 @@ export interface ComboBoxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
95
96
|
* @param {string} inputText
|
|
96
97
|
*/
|
|
97
98
|
onInputChange?: (inputText: string) => void;
|
|
98
|
-
/**
|
|
99
|
-
* Helper function passed to Downshift that allows the user to observe internal
|
|
100
|
-
* state changes
|
|
101
|
-
* `(changes, stateAndHelpers) => void`
|
|
102
|
-
*/
|
|
103
|
-
onStateChange?: (changes: object, stateAndHelpers: object) => void;
|
|
104
99
|
/**
|
|
105
100
|
* Callback function that fires when the combobox menu toggle is clicked
|
|
106
101
|
* `(evt) => void`
|
|
107
102
|
* @param {MouseEvent} event
|
|
108
103
|
*/
|
|
109
|
-
onToggleClick?: (evt: MouseEvent) => void;
|
|
104
|
+
onToggleClick?: (evt: MouseEvent<HTMLButtonElement>) => void;
|
|
110
105
|
/**
|
|
111
106
|
* Used to provide a placeholder text node before a user enters any input.
|
|
112
107
|
* This is only present if the control has no items selected
|
|
@@ -119,13 +114,17 @@ export interface ComboBoxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
119
114
|
/**
|
|
120
115
|
* For full control of the selection
|
|
121
116
|
*/
|
|
122
|
-
selectedItem?:
|
|
117
|
+
selectedItem?: ItemType | null;
|
|
123
118
|
/**
|
|
124
119
|
* Specify your own filtering logic by passing in a `shouldFilterItem`
|
|
125
120
|
* function that takes in the current input and an item and passes back
|
|
126
121
|
* whether or not the item should be filtered.
|
|
127
122
|
*/
|
|
128
|
-
shouldFilterItem?: (input:
|
|
123
|
+
shouldFilterItem?: (input: {
|
|
124
|
+
item: ItemType;
|
|
125
|
+
itemToString?: ItemToStringHandler<ItemType>;
|
|
126
|
+
inputValue: string | null;
|
|
127
|
+
}) => boolean;
|
|
129
128
|
/**
|
|
130
129
|
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
131
130
|
*/
|
|
@@ -134,12 +133,12 @@ export interface ComboBoxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
134
133
|
* Provide text to be used in a `<label>` element that is tied to the
|
|
135
134
|
* combobox via ARIA attributes.
|
|
136
135
|
*/
|
|
137
|
-
titleText?:
|
|
136
|
+
titleText?: ReactNode;
|
|
138
137
|
/**
|
|
139
138
|
* Specify a custom translation function that takes in a message identifier
|
|
140
139
|
* and returns the localized string for the message
|
|
141
140
|
*/
|
|
142
|
-
translateWithId?: (id:
|
|
141
|
+
translateWithId?: (id: string) => string;
|
|
143
142
|
/**
|
|
144
143
|
* Currently supports either the default type, or an inline variant
|
|
145
144
|
*/
|
|
@@ -151,7 +150,11 @@ export interface ComboBoxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
151
150
|
/**
|
|
152
151
|
* Provide the text that is displayed when the control is in warning state
|
|
153
152
|
*/
|
|
154
|
-
warnText?:
|
|
153
|
+
warnText?: ReactNode;
|
|
154
|
+
}
|
|
155
|
+
type ComboboxComponentProps<ItemType> = PropsWithoutRef<PropsWithChildren<ComboBoxProps<ItemType>> & RefAttributes<HTMLInputElement>>;
|
|
156
|
+
interface ComboBoxComponent {
|
|
157
|
+
<ItemType>(props: ComboboxComponentProps<ItemType>): ReactElement | null;
|
|
155
158
|
}
|
|
156
|
-
declare const
|
|
157
|
-
export default
|
|
159
|
+
declare const _default: ComboBoxComponent;
|
|
160
|
+
export default _default;
|
|
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
|
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import Downshift from 'downshift';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
|
-
import React__default, { useContext, useRef, useState, useEffect } from 'react';
|
|
12
|
+
import React__default, { forwardRef, useContext, useRef, useState, useEffect } from 'react';
|
|
13
13
|
import '../Text/index.js';
|
|
14
14
|
import { WarningFilled, WarningAltFilled, Checkmark } from '@carbon/icons-react';
|
|
15
15
|
import ListBox from '../ListBox/index.js';
|
|
@@ -38,7 +38,13 @@ const defaultItemToString = item => {
|
|
|
38
38
|
if (typeof item === 'string') {
|
|
39
39
|
return item;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
if (typeof item === 'number') {
|
|
42
|
+
return `${item}`;
|
|
43
|
+
}
|
|
44
|
+
if (item !== null && typeof item === 'object' && 'label' in item && typeof item['label'] === 'string') {
|
|
45
|
+
return item['label'];
|
|
46
|
+
}
|
|
47
|
+
return '';
|
|
42
48
|
};
|
|
43
49
|
const defaultShouldFilterItem = () => true;
|
|
44
50
|
const getInputValue = _ref => {
|
|
@@ -74,10 +80,10 @@ const findHighlightedIndex = (_ref2, inputValue) => {
|
|
|
74
80
|
return -1;
|
|
75
81
|
};
|
|
76
82
|
const getInstanceId = setupGetInstanceId();
|
|
77
|
-
const ComboBox = /*#__PURE__*/
|
|
83
|
+
const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
78
84
|
var _Text;
|
|
79
85
|
const {
|
|
80
|
-
['aria-label']: ariaLabel,
|
|
86
|
+
['aria-label']: ariaLabel = 'Choose an item',
|
|
81
87
|
ariaLabel: deprecatedAriaLabel,
|
|
82
88
|
className: containerClassName,
|
|
83
89
|
direction,
|
|
@@ -90,7 +96,7 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
90
96
|
invalidText,
|
|
91
97
|
items,
|
|
92
98
|
itemToElement,
|
|
93
|
-
itemToString,
|
|
99
|
+
itemToString = defaultItemToString,
|
|
94
100
|
light,
|
|
95
101
|
onChange,
|
|
96
102
|
onInputChange,
|
|
@@ -98,14 +104,13 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
98
104
|
placeholder,
|
|
99
105
|
readOnly,
|
|
100
106
|
selectedItem,
|
|
101
|
-
shouldFilterItem,
|
|
107
|
+
shouldFilterItem = defaultShouldFilterItem,
|
|
102
108
|
size,
|
|
103
109
|
titleText,
|
|
104
110
|
translateWithId,
|
|
105
111
|
type: _type,
|
|
106
112
|
warn,
|
|
107
113
|
warnText,
|
|
108
|
-
onStateChange: _onStateChange,
|
|
109
114
|
...rest
|
|
110
115
|
} = props;
|
|
111
116
|
const prefix = usePrefix();
|
|
@@ -168,7 +173,7 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
168
173
|
const {
|
|
169
174
|
inputValue
|
|
170
175
|
} = changes;
|
|
171
|
-
const filteredItems = filterItems(items, itemToString, inputValue);
|
|
176
|
+
const filteredItems = filterItems(items, itemToString, inputValue || null);
|
|
172
177
|
const indexToHighlight = findHighlightedIndex({
|
|
173
178
|
...props,
|
|
174
179
|
items: filteredItems
|
|
@@ -176,7 +181,7 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
176
181
|
setHighlightedIndex(indexToHighlight);
|
|
177
182
|
return indexToHighlight;
|
|
178
183
|
}
|
|
179
|
-
return highlightedIndex;
|
|
184
|
+
return highlightedIndex || 0;
|
|
180
185
|
};
|
|
181
186
|
const handleOnStateChange = (changes, _ref3) => {
|
|
182
187
|
let {
|
|
@@ -351,7 +356,7 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
351
356
|
disabled: disabled,
|
|
352
357
|
className: inputClasses,
|
|
353
358
|
type: "text",
|
|
354
|
-
tabIndex:
|
|
359
|
+
tabIndex: 0,
|
|
355
360
|
"aria-autocomplete": "list",
|
|
356
361
|
"aria-expanded": rootProps['aria-expanded'],
|
|
357
362
|
"aria-haspopup": "listbox",
|
|
@@ -378,24 +383,24 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
378
383
|
}))), /*#__PURE__*/React__default.createElement(ListBox.Menu, getMenuProps({
|
|
379
384
|
'aria-label': deprecatedAriaLabel || ariaLabel
|
|
380
385
|
}), isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
|
|
386
|
+
const isObject = item !== null && typeof item === 'object';
|
|
387
|
+
const title = isObject && 'text' in item && itemToElement ? item.text?.toString() : itemToString(item);
|
|
388
|
+
const disabled = isObject && 'disabled' in item ? !!item.disabled : undefined;
|
|
381
389
|
const itemProps = getItemProps({
|
|
382
390
|
item,
|
|
383
391
|
index,
|
|
384
392
|
['aria-current']: selectedItem === item ? 'true' : 'false',
|
|
385
393
|
['aria-selected']: highlightedIndex === index ? 'true' : 'false',
|
|
386
|
-
disabled
|
|
394
|
+
disabled
|
|
387
395
|
});
|
|
388
396
|
return /*#__PURE__*/React__default.createElement(ListBox.MenuItem, _extends({
|
|
389
397
|
key: itemProps.id,
|
|
390
398
|
isActive: selectedItem === item,
|
|
391
399
|
isHighlighted: highlightedIndex === index,
|
|
392
|
-
title:
|
|
393
|
-
}, itemProps),
|
|
394
|
-
/*#__PURE__*/
|
|
395
|
-
// @ts-ignore
|
|
396
|
-
React__default.createElement(ItemToElement, _extends({
|
|
400
|
+
title: title
|
|
401
|
+
}, itemProps), ItemToElement ? /*#__PURE__*/React__default.createElement(ItemToElement, _extends({
|
|
397
402
|
key: itemProps.id
|
|
398
|
-
}, item)) : itemToString
|
|
403
|
+
}, item)) : itemToString(item), selectedItem === item && /*#__PURE__*/React__default.createElement(Checkmark, {
|
|
399
404
|
className: `${prefix}--list-box__menu-item__selected-icon`
|
|
400
405
|
}));
|
|
401
406
|
}) : null)), helperText && !invalid && !warn && !isFluid && (_Text || (_Text = /*#__PURE__*/React__default.createElement(Text, {
|
|
@@ -439,7 +444,7 @@ ComboBox.propTypes = {
|
|
|
439
444
|
* Provide helper text that is used alongside the control label for
|
|
440
445
|
* additional help
|
|
441
446
|
*/
|
|
442
|
-
helperText: PropTypes.
|
|
447
|
+
helperText: PropTypes.node,
|
|
443
448
|
/**
|
|
444
449
|
* Specify a custom `id` for the input
|
|
445
450
|
*/
|
|
@@ -491,12 +496,6 @@ ComboBox.propTypes = {
|
|
|
491
496
|
* @param {string} inputText
|
|
492
497
|
*/
|
|
493
498
|
onInputChange: PropTypes.func,
|
|
494
|
-
/**
|
|
495
|
-
* Helper function passed to Downshift that allows the user to observe internal
|
|
496
|
-
* state changes
|
|
497
|
-
* `(changes, stateAndHelpers) => void`
|
|
498
|
-
*/
|
|
499
|
-
onStateChange: PropTypes.func,
|
|
500
499
|
/**
|
|
501
500
|
* Callback function that fires when the combobox menu toggle is clicked
|
|
502
501
|
* `(evt) => void`
|
|
@@ -16,6 +16,7 @@ import { IconButton } from '../IconButton/index.js';
|
|
|
16
16
|
|
|
17
17
|
function Copy(_ref) {
|
|
18
18
|
let {
|
|
19
|
+
align = 'bottom',
|
|
19
20
|
children,
|
|
20
21
|
className,
|
|
21
22
|
feedback,
|
|
@@ -49,7 +50,7 @@ function Copy(_ref) {
|
|
|
49
50
|
const initialLabel = other['aria-label'] ?? '';
|
|
50
51
|
return /*#__PURE__*/React__default.createElement(IconButton, _extends({
|
|
51
52
|
closeOnActivation: false,
|
|
52
|
-
align:
|
|
53
|
+
align: align,
|
|
53
54
|
className: classNames,
|
|
54
55
|
label: animation ? feedback : initialLabel,
|
|
55
56
|
onClick: composeEventHandlers([onClick, handleClick]),
|
|
@@ -59,6 +60,10 @@ function Copy(_ref) {
|
|
|
59
60
|
}), children);
|
|
60
61
|
}
|
|
61
62
|
Copy.propTypes = {
|
|
63
|
+
/**
|
|
64
|
+
* Specify how the trigger should align with the tooltip
|
|
65
|
+
*/
|
|
66
|
+
align: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
|
|
62
67
|
/**
|
|
63
68
|
* Pass in content to be rendered in the underlying `<button>`
|
|
64
69
|
*/
|
|
@@ -16,6 +16,7 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
16
16
|
|
|
17
17
|
function CopyButton(_ref) {
|
|
18
18
|
let {
|
|
19
|
+
align = 'bottom',
|
|
19
20
|
iconDescription,
|
|
20
21
|
className,
|
|
21
22
|
...other
|
|
@@ -27,6 +28,7 @@ function CopyButton(_ref) {
|
|
|
27
28
|
max: 'lg'
|
|
28
29
|
}
|
|
29
30
|
}, /*#__PURE__*/React__default.createElement(Copy, _extends({
|
|
31
|
+
align: align,
|
|
30
32
|
className: cx(className, `${prefix}--copy-btn`),
|
|
31
33
|
"aria-label": iconDescription
|
|
32
34
|
}, other), /*#__PURE__*/React__default.createElement(Copy$1, {
|
|
@@ -34,6 +36,10 @@ function CopyButton(_ref) {
|
|
|
34
36
|
})));
|
|
35
37
|
}
|
|
36
38
|
CopyButton.propTypes = {
|
|
39
|
+
/**
|
|
40
|
+
* Specify how the trigger should align with the tooltip
|
|
41
|
+
*/
|
|
42
|
+
align: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
|
|
37
43
|
/**
|
|
38
44
|
* Specify an optional className to be applied to the underlying `<button>`
|
|
39
45
|
*/
|
|
@@ -28,7 +28,7 @@ class FileUploader extends React__default.Component {
|
|
|
28
28
|
evt.stopPropagation();
|
|
29
29
|
const filenames = Array.prototype.map.call(evt.target.files, file => file.name);
|
|
30
30
|
this.setState({
|
|
31
|
-
filenames: this.props.multiple ? this.state.filenames
|
|
31
|
+
filenames: this.props.multiple ? [...new Set([...this.state.filenames, ...filenames])] : filenames
|
|
32
32
|
});
|
|
33
33
|
if (this.props.onChange) {
|
|
34
34
|
this.props.onChange(evt);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, { AnchorHTMLAttributes, AriaAttributes, ComponentType, HTMLAttributeAnchorTarget } from 'react';
|
|
8
|
-
interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
8
|
+
export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
9
9
|
/**
|
|
10
10
|
* @description Indicates the element that represents the
|
|
11
11
|
* current item within a container or set of related
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import Link from './Link';
|
|
7
|
+
import Link, { type LinkProps } from './Link';
|
|
8
8
|
export default Link;
|
|
9
|
-
export { Link };
|
|
9
|
+
export { Link, type LinkProps };
|
|
@@ -21,7 +21,31 @@ interface SortItemsOptions<ItemType> extends SharedOptions, DownshiftTypedProps<
|
|
|
21
21
|
selectedItems: ItemType[];
|
|
22
22
|
}
|
|
23
23
|
interface MultiSelectSortingProps<ItemType> {
|
|
24
|
+
/**
|
|
25
|
+
* Provide a compare function that is used to determine the ordering of
|
|
26
|
+
* options. See 'sortItems' for more control.
|
|
27
|
+
*/
|
|
24
28
|
compareItems?(item1: ItemType, item2: ItemType, options: SharedOptions): number;
|
|
29
|
+
/**
|
|
30
|
+
* Provide a method that sorts all options in the control. Overriding this
|
|
31
|
+
* prop means that you also have to handle the sort logic for selected versus
|
|
32
|
+
* un-selected items. If you just want to control ordering, consider the
|
|
33
|
+
* `compareItems` prop instead.
|
|
34
|
+
*
|
|
35
|
+
* The return value should be a number whose sign indicates the relative order
|
|
36
|
+
* of the two elements: negative if a is less than b, positive if a is greater
|
|
37
|
+
* than b, and zero if they are equal.
|
|
38
|
+
*
|
|
39
|
+
* sortItems :
|
|
40
|
+
* (items: Array<Item>, {
|
|
41
|
+
* selectedItems: Array<Item>,
|
|
42
|
+
* itemToString: Item => string,
|
|
43
|
+
* compareItems: (itemA: string, itemB: string, {
|
|
44
|
+
* locale: string
|
|
45
|
+
* }) => number,
|
|
46
|
+
* locale: string,
|
|
47
|
+
* }) => Array<Item>
|
|
48
|
+
*/
|
|
25
49
|
sortItems?(items: ReadonlyArray<ItemType>, options: SortItemsOptions<ItemType>): ItemType[];
|
|
26
50
|
}
|
|
27
51
|
export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<ItemType>, InternationalProps<'close.menu' | 'open.menu' | 'clear.all' | 'clear.selection'> {
|
|
@@ -390,6 +390,11 @@ MultiSelect.propTypes = {
|
|
|
390
390
|
* Specify the text that should be read for screen readers to clear selection.
|
|
391
391
|
*/
|
|
392
392
|
clearSelectionText: PropTypes.string,
|
|
393
|
+
/**
|
|
394
|
+
* Provide a compare function that is used to determine the ordering of
|
|
395
|
+
* options. See 'sortItems' for more control.
|
|
396
|
+
*/
|
|
397
|
+
compareItems: PropTypes.func.isRequired,
|
|
393
398
|
/**
|
|
394
399
|
* Specify the direction of the multiselect dropdown. Can be either top or bottom.
|
|
395
400
|
*/
|
|
@@ -491,6 +496,27 @@ MultiSelect.propTypes = {
|
|
|
491
496
|
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
492
497
|
*/
|
|
493
498
|
size: ListBoxSize,
|
|
499
|
+
/**
|
|
500
|
+
* Provide a method that sorts all options in the control. Overriding this
|
|
501
|
+
* prop means that you also have to handle the sort logic for selected versus
|
|
502
|
+
* un-selected items. If you just want to control ordering, consider the
|
|
503
|
+
* `compareItems` prop instead.
|
|
504
|
+
*
|
|
505
|
+
* The return value should be a number whose sign indicates the relative order
|
|
506
|
+
* of the two elements: negative if a is less than b, positive if a is greater
|
|
507
|
+
* than b, and zero if they are equal.
|
|
508
|
+
*
|
|
509
|
+
* sortItems :
|
|
510
|
+
* (items: Array<Item>, {
|
|
511
|
+
* selectedItems: Array<Item>,
|
|
512
|
+
* itemToString: Item => string,
|
|
513
|
+
* compareItems: (itemA: string, itemB: string, {
|
|
514
|
+
* locale: string
|
|
515
|
+
* }) => number,
|
|
516
|
+
* locale: string,
|
|
517
|
+
* }) => Array<Item>
|
|
518
|
+
*/
|
|
519
|
+
sortItems: PropTypes.func.isRequired,
|
|
494
520
|
/**
|
|
495
521
|
* Provide text to be used in a `<label>` element that is tied to the
|
|
496
522
|
* multiselect via ARIA attributes.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { type WeakValidationMap, type ElementType } from 'react';
|
|
7
|
+
import React, { type ForwardedRef, type WeakValidationMap, type ElementType } from 'react';
|
|
8
8
|
import { type PolymorphicProps } from '../../types/common';
|
|
9
9
|
export type PopoverAlignment = 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'left-bottom' | 'left-top' | 'right' | 'right-bottom' | 'right-top';
|
|
10
10
|
interface PopoverBaseProps {
|
|
@@ -52,10 +52,14 @@ interface PopoverBaseProps {
|
|
|
52
52
|
open: boolean;
|
|
53
53
|
}
|
|
54
54
|
export type PopoverProps<E extends ElementType> = PolymorphicProps<E, PopoverBaseProps>;
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
55
|
+
export interface PopoverComponent {
|
|
56
|
+
<E extends ElementType = 'span'>(props: PopoverProps<E> & {
|
|
57
|
+
forwardRef?: ForwardedRef<ElementType>;
|
|
58
|
+
}): JSX.Element | null;
|
|
59
|
+
displayName?: string;
|
|
60
|
+
propTypes?: WeakValidationMap<PopoverProps<any>>;
|
|
61
|
+
}
|
|
62
|
+
export declare const Popover: PopoverComponent;
|
|
59
63
|
export type PopoverContentProps = React.HTMLAttributes<HTMLSpanElement>;
|
|
60
64
|
export declare const PopoverContent: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLSpanElement>>;
|
|
61
65
|
export {};
|
|
@@ -19,7 +19,7 @@ const PopoverContext = /*#__PURE__*/React__default.createContext({
|
|
|
19
19
|
current: null
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
function PopoverRenderFunction(_ref, forwardRef) {
|
|
22
|
+
const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFunction(_ref, forwardRef) {
|
|
23
23
|
let {
|
|
24
24
|
isTabTip,
|
|
25
25
|
align = isTabTip ? 'bottom-left' : 'bottom',
|
|
@@ -179,8 +179,7 @@ function PopoverRenderFunction(_ref, forwardRef) {
|
|
|
179
179
|
className: className,
|
|
180
180
|
ref: ref
|
|
181
181
|
}), isTabTip ? mappedChildren : children));
|
|
182
|
-
}
|
|
183
|
-
const Popover = /*#__PURE__*/React__default.forwardRef(PopoverRenderFunction);
|
|
182
|
+
});
|
|
184
183
|
|
|
185
184
|
// Note: this displayName is temporarily set so that Storybook ArgTable
|
|
186
185
|
// correctly displays the name of this component
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
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
|
+
/// <reference types="react" />
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
export interface StructuredListSkeletonProps {
|
|
10
|
+
/**
|
|
11
|
+
* Specify an optional className to add.
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* number of table rows
|
|
16
|
+
*/
|
|
17
|
+
rowCount?: number;
|
|
18
|
+
}
|
|
19
|
+
declare function StructuredListSkeleton({ rowCount, className, ...rest }: StructuredListSkeletonProps): JSX.Element;
|
|
20
|
+
declare namespace StructuredListSkeleton {
|
|
21
|
+
var propTypes: {
|
|
22
|
+
/**
|
|
23
|
+
* Specify an optional className to add.
|
|
24
|
+
*/
|
|
25
|
+
className: PropTypes.Requireable<string>;
|
|
26
|
+
/**
|
|
27
|
+
* number of table rows
|
|
28
|
+
*/
|
|
29
|
+
rowCount: PropTypes.Requireable<number>;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export default StructuredListSkeleton;
|
|
@@ -12,32 +12,26 @@ import cx from 'classnames';
|
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
13
|
|
|
14
14
|
var _span, _span2, _span3;
|
|
15
|
-
|
|
15
|
+
function StructuredListSkeleton(_ref) {
|
|
16
16
|
let {
|
|
17
|
-
rowCount,
|
|
17
|
+
rowCount = 5,
|
|
18
18
|
className,
|
|
19
19
|
...rest
|
|
20
20
|
} = _ref;
|
|
21
21
|
const prefix = usePrefix();
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
34
|
-
className: `${prefix}--structured-list-td`
|
|
35
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
36
|
-
className: `${prefix}--structured-list-td`
|
|
37
|
-
})));
|
|
38
|
-
}
|
|
22
|
+
const classNames = cx(`${prefix}--skeleton`, `${prefix}--structured-list`, className);
|
|
23
|
+
const rows = new Array(rowCount).fill(null).map((_, i) => /*#__PURE__*/React__default.createElement("div", {
|
|
24
|
+
className: `${prefix}--structured-list-row`,
|
|
25
|
+
key: i
|
|
26
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
27
|
+
className: `${prefix}--structured-list-td`
|
|
28
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
29
|
+
className: `${prefix}--structured-list-td`
|
|
30
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
31
|
+
className: `${prefix}--structured-list-td`
|
|
32
|
+
})));
|
|
39
33
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
40
|
-
className:
|
|
34
|
+
className: classNames
|
|
41
35
|
}, rest), /*#__PURE__*/React__default.createElement("div", {
|
|
42
36
|
className: `${prefix}--structured-list-thead`
|
|
43
37
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -51,7 +45,7 @@ const StructuredListSkeleton = _ref => {
|
|
|
51
45
|
}, _span3 || (_span3 = /*#__PURE__*/React__default.createElement("span", null))))), /*#__PURE__*/React__default.createElement("div", {
|
|
52
46
|
className: `${prefix}--structured-list-tbody`
|
|
53
47
|
}, rows));
|
|
54
|
-
}
|
|
48
|
+
}
|
|
55
49
|
StructuredListSkeleton.propTypes = {
|
|
56
50
|
/**
|
|
57
51
|
* Specify an optional className to add.
|
|
@@ -62,9 +56,5 @@ StructuredListSkeleton.propTypes = {
|
|
|
62
56
|
*/
|
|
63
57
|
rowCount: PropTypes.number
|
|
64
58
|
};
|
|
65
|
-
StructuredListSkeleton.defaultProps = {
|
|
66
|
-
rowCount: 5
|
|
67
|
-
};
|
|
68
|
-
var StructuredListSkeleton$1 = StructuredListSkeleton;
|
|
69
59
|
|
|
70
|
-
export { StructuredListSkeleton
|
|
60
|
+
export { StructuredListSkeleton as default };
|