@carbon/react 1.68.0 → 1.69.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 +871 -871
- package/README.md +3 -3
- package/es/components/Accordion/AccordionItem.js +0 -1
- package/es/components/Button/Button.js +6 -0
- package/es/components/Checkbox/Checkbox.js +1 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +1 -2
- package/es/components/CheckboxGroup/index.d.ts +10 -0
- package/es/components/ComboBox/ComboBox.js +13 -18
- package/es/components/ComboButton/index.js +10 -3
- package/es/components/DataTable/TableCell.d.ts +1 -4
- package/es/components/DataTable/TableCell.js +3 -2
- package/es/components/Disclosure/index.d.ts +18 -0
- package/es/components/Dropdown/Dropdown.js +11 -9
- package/es/components/FileUploader/FileUploader.d.ts +8 -92
- package/es/components/FileUploader/FileUploader.js +116 -137
- package/es/components/Grid/CSSGrid.js +8 -1
- package/es/components/Grid/Grid.js +4 -0
- package/es/components/IdPrefix/index.d.ts +26 -0
- package/es/components/ListBox/next/ListBoxSelection.d.ts +9 -1
- package/es/components/ListBox/next/ListBoxSelection.js +12 -5
- package/es/components/Menu/MenuItem.js +1 -4
- package/es/components/MenuButton/index.d.ts +4 -0
- package/es/components/MenuButton/index.js +19 -5
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +4 -0
- package/es/components/MultiSelect/FilterableMultiSelect.js +32 -6
- package/es/components/MultiSelect/MultiSelect.js +11 -9
- package/es/components/OverflowMenu/next/index.d.ts +4 -0
- package/es/components/OverflowMenu/next/index.js +19 -9
- package/es/components/PaginationNav/PaginationNav.js +1 -1
- package/es/components/Popover/index.js +18 -14
- package/es/components/Portal/index.d.ts +25 -0
- package/es/components/Slider/Slider.js +2 -2
- package/es/components/Tabs/Tabs.js +46 -20
- package/es/components/Tag/DismissibleTag.js +2 -2
- package/es/components/Tag/OperationalTag.d.ts +2 -10
- package/es/components/Tag/OperationalTag.js +2 -14
- package/es/components/Tag/SelectableTag.d.ts +18 -10
- package/es/components/Tag/SelectableTag.js +22 -28
- package/es/components/Toggle/Toggle.js +2 -0
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
- package/es/components/ToggleSmall/index.d.ts +7 -0
- package/es/components/TreeView/TreeNode.js +4 -2
- package/es/components/TreeView/TreeView.js +4 -4
- package/es/components/UIShell/SideNavMenuItem.d.ts +4 -3
- package/es/components/UIShell/SideNavMenuItem.js +1 -4
- package/es/index.js +1 -1
- package/es/internal/useIdPrefix.d.ts +9 -0
- package/lib/components/Accordion/AccordionItem.js +0 -1
- package/lib/components/Button/Button.js +6 -0
- package/lib/components/Checkbox/Checkbox.js +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -2
- package/lib/components/CheckboxGroup/index.d.ts +10 -0
- package/lib/components/ComboBox/ComboBox.js +18 -23
- package/lib/components/ComboButton/index.js +12 -5
- package/lib/components/DataTable/TableCell.d.ts +1 -4
- package/lib/components/DataTable/TableCell.js +3 -2
- package/lib/components/Disclosure/index.d.ts +18 -0
- package/lib/components/Dropdown/Dropdown.js +18 -16
- package/lib/components/FileUploader/FileUploader.d.ts +8 -92
- package/lib/components/FileUploader/FileUploader.js +113 -134
- package/lib/components/Grid/CSSGrid.js +8 -1
- package/lib/components/Grid/Grid.js +4 -0
- package/lib/components/IdPrefix/index.d.ts +26 -0
- package/lib/components/ListBox/next/ListBoxSelection.d.ts +9 -1
- package/lib/components/ListBox/next/ListBoxSelection.js +12 -5
- package/lib/components/Menu/MenuItem.js +1 -4
- package/lib/components/MenuButton/index.d.ts +4 -0
- package/lib/components/MenuButton/index.js +19 -5
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +4 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.js +32 -6
- package/lib/components/MultiSelect/MultiSelect.js +18 -16
- package/lib/components/OverflowMenu/next/index.d.ts +4 -0
- package/lib/components/OverflowMenu/next/index.js +21 -11
- package/lib/components/PaginationNav/PaginationNav.js +1 -1
- package/lib/components/Popover/index.js +18 -14
- package/lib/components/Portal/index.d.ts +25 -0
- package/lib/components/Slider/Slider.js +2 -2
- package/lib/components/Tabs/Tabs.js +46 -20
- package/lib/components/Tag/DismissibleTag.js +2 -2
- package/lib/components/Tag/OperationalTag.d.ts +2 -10
- package/lib/components/Tag/OperationalTag.js +2 -14
- package/lib/components/Tag/SelectableTag.d.ts +18 -10
- package/lib/components/Tag/SelectableTag.js +22 -28
- package/lib/components/Toggle/Toggle.js +2 -0
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
- package/lib/components/ToggleSmall/index.d.ts +7 -0
- package/lib/components/TreeView/TreeNode.js +4 -2
- package/lib/components/TreeView/TreeView.js +4 -4
- package/lib/components/UIShell/SideNavMenuItem.d.ts +4 -3
- package/lib/components/UIShell/SideNavMenuItem.js +1 -4
- package/lib/index.js +2 -2
- package/lib/internal/useIdPrefix.d.ts +9 -0
- package/package.json +10 -9
- package/telemetry.yml +809 -809
|
@@ -19,7 +19,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
19
19
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
20
20
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
21
21
|
|
|
22
|
-
const TableCell = _ref => {
|
|
22
|
+
const TableCell = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
|
|
23
23
|
let {
|
|
24
24
|
children,
|
|
25
25
|
className,
|
|
@@ -33,9 +33,10 @@ const TableCell = _ref => {
|
|
|
33
33
|
});
|
|
34
34
|
return /*#__PURE__*/React__default["default"].createElement("td", _rollupPluginBabelHelpers["extends"]({
|
|
35
35
|
className: tableCellClassNames ? tableCellClassNames : undefined,
|
|
36
|
+
ref: ref,
|
|
36
37
|
colSpan: colSpan
|
|
37
38
|
}, rest), children);
|
|
38
|
-
};
|
|
39
|
+
});
|
|
39
40
|
TableCell.displayName = 'TableCell';
|
|
40
41
|
|
|
41
42
|
exports["default"] = TableCell;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
declare function useDisclosure(id: any): {
|
|
8
|
+
buttonProps: {
|
|
9
|
+
'aria-controls': any;
|
|
10
|
+
'aria-expanded': boolean;
|
|
11
|
+
onClick(): void;
|
|
12
|
+
};
|
|
13
|
+
contentProps: {
|
|
14
|
+
id: any;
|
|
15
|
+
};
|
|
16
|
+
open: boolean;
|
|
17
|
+
};
|
|
18
|
+
export { useDisclosure };
|
|
@@ -15,7 +15,7 @@ var Downshift = require('downshift');
|
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
var PropTypes = require('prop-types');
|
|
17
17
|
var iconsReact = require('@carbon/icons-react');
|
|
18
|
-
var index = require('../ListBox/index.js');
|
|
18
|
+
var index$1 = require('../ListBox/index.js');
|
|
19
19
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
20
20
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
21
21
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
@@ -24,6 +24,7 @@ var FormContext = require('../FluidForm/FormContext.js');
|
|
|
24
24
|
var useId = require('../../internal/useId.js');
|
|
25
25
|
var react = require('@floating-ui/react');
|
|
26
26
|
var floatingUi_dom = require('../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js');
|
|
27
|
+
var index = require('../FeatureFlags/index.js');
|
|
27
28
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
28
29
|
|
|
29
30
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -81,11 +82,12 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
81
82
|
slug,
|
|
82
83
|
...other
|
|
83
84
|
} = _ref;
|
|
85
|
+
const enableFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles');
|
|
84
86
|
const {
|
|
85
87
|
refs,
|
|
86
88
|
floatingStyles,
|
|
87
89
|
middlewareData
|
|
88
|
-
} = react.useFloating(autoAlign ? {
|
|
90
|
+
} = react.useFloating(enableFloatingStyles || autoAlign ? {
|
|
89
91
|
placement: direction,
|
|
90
92
|
// The floating element is positioned relative to its nearest
|
|
91
93
|
// containing block (usually the viewport). It will in many cases also
|
|
@@ -103,12 +105,14 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
103
105
|
width: `${rects.reference.width}px`
|
|
104
106
|
});
|
|
105
107
|
}
|
|
106
|
-
}), react.flip(), floatingUi_dom.hide()],
|
|
108
|
+
}), autoAlign && react.flip(), autoAlign && floatingUi_dom.hide()],
|
|
107
109
|
whileElementsMounted: react.autoUpdate
|
|
108
|
-
} : {}
|
|
110
|
+
} : {}
|
|
111
|
+
// When autoAlign is turned off & the `enable-v12-dynamic-floating-styles` feature flag is not
|
|
112
|
+
// enabled, floating-ui will not be used
|
|
109
113
|
);
|
|
110
114
|
React.useEffect(() => {
|
|
111
|
-
if (autoAlign) {
|
|
115
|
+
if (enableFloatingStyles || autoAlign) {
|
|
112
116
|
const updatedFloatingStyles = {
|
|
113
117
|
...floatingStyles,
|
|
114
118
|
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
@@ -247,9 +251,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
247
251
|
// NOTE: does not prevent click
|
|
248
252
|
evt.preventDefault();
|
|
249
253
|
// focus on the element as per readonly input behavior
|
|
250
|
-
|
|
251
|
-
mergedRef.current.focus();
|
|
252
|
-
}
|
|
254
|
+
mergedRef?.current?.focus();
|
|
253
255
|
},
|
|
254
256
|
onKeyDown: evt => {
|
|
255
257
|
const selectAccessKeys = ['ArrowDown', 'ArrowUp', ' ', 'Enter'];
|
|
@@ -277,7 +279,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
277
279
|
}
|
|
278
280
|
};
|
|
279
281
|
const menuProps = React.useMemo(() => getMenuProps({
|
|
280
|
-
ref: autoAlign ? refs.setFloating : null
|
|
282
|
+
ref: enableFloatingStyles || autoAlign ? refs.setFloating : null
|
|
281
283
|
}), [autoAlign, getMenuProps, refs.setFloating]);
|
|
282
284
|
|
|
283
285
|
// Slug is always size `mini`
|
|
@@ -291,7 +293,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
291
293
|
className: wrapperClasses
|
|
292
294
|
}, other), titleText && /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
293
295
|
className: titleClasses
|
|
294
|
-
}, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index["default"], {
|
|
296
|
+
}, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index$1["default"], {
|
|
295
297
|
onFocus: handleFocus,
|
|
296
298
|
onBlur: handleFocus,
|
|
297
299
|
size: size,
|
|
@@ -302,7 +304,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
302
304
|
warnText: warnText,
|
|
303
305
|
light: light,
|
|
304
306
|
isOpen: isOpen,
|
|
305
|
-
ref: autoAlign ? refs.setReference : null,
|
|
307
|
+
ref: enableFloatingStyles || autoAlign ? refs.setReference : null,
|
|
306
308
|
id: id
|
|
307
309
|
}, invalid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
|
|
308
310
|
className: `${prefix}--list-box__invalid-icon`
|
|
@@ -322,23 +324,23 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
322
324
|
ref: mergedRef
|
|
323
325
|
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
324
326
|
className: `${prefix}--list-box__label`
|
|
325
|
-
}, selectedItem ? renderSelectedItem ? renderSelectedItem(selectedItem) : itemToString(selectedItem) : label), /*#__PURE__*/React__default["default"].createElement(index["default"].MenuIcon, {
|
|
327
|
+
}, selectedItem ? renderSelectedItem ? renderSelectedItem(selectedItem) : itemToString(selectedItem) : label), /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuIcon, {
|
|
326
328
|
isOpen: isOpen,
|
|
327
329
|
translateWithId: translateWithId
|
|
328
|
-
})), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen && items.map((item, index
|
|
330
|
+
})), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index$1["default"].Menu, menuProps, isOpen && items.map((item, index) => {
|
|
329
331
|
const isObject = item !== null && typeof item === 'object';
|
|
330
332
|
const itemProps = getItemProps({
|
|
331
333
|
item,
|
|
332
|
-
index
|
|
334
|
+
index
|
|
333
335
|
});
|
|
334
336
|
if (item !== null && typeof item === 'object' && Object.prototype.hasOwnProperty.call(item, 'id')) {
|
|
335
337
|
itemProps.id = item['id'];
|
|
336
338
|
}
|
|
337
339
|
const title = isObject && 'text' in item && itemToElement ? item.text : itemToString(item);
|
|
338
|
-
return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
340
|
+
return /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
339
341
|
key: itemProps.id,
|
|
340
342
|
isActive: selectedItem === item,
|
|
341
|
-
isHighlighted: highlightedIndex === index
|
|
343
|
+
isHighlighted: highlightedIndex === index,
|
|
342
344
|
title: title,
|
|
343
345
|
disabled: itemProps['aria-disabled']
|
|
344
346
|
}, itemProps), typeof item === 'object' && ItemToElement !== undefined && ItemToElement !== null ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
|
|
@@ -4,8 +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
|
|
8
|
-
import React from 'react';
|
|
7
|
+
import { ReactElement } from 'react';
|
|
9
8
|
import { ReactAttr } from '../../types/common';
|
|
10
9
|
export interface FileUploaderProps extends ReactAttr<HTMLSpanElement> {
|
|
11
10
|
/**
|
|
@@ -74,93 +73,10 @@ export interface FileUploaderProps extends ReactAttr<HTMLSpanElement> {
|
|
|
74
73
|
*/
|
|
75
74
|
size?: 'sm' | 'small' | 'md' | 'field' | 'lg';
|
|
76
75
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
accept: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
85
|
-
/**
|
|
86
|
-
* Specify the type of the `<FileUploaderButton>`
|
|
87
|
-
*/
|
|
88
|
-
buttonKind: PropTypes.Requireable<string>;
|
|
89
|
-
/**
|
|
90
|
-
* Provide the label text to be read by screen readers when interacting with
|
|
91
|
-
* the `<FileUploaderButton>`
|
|
92
|
-
*/
|
|
93
|
-
buttonLabel: PropTypes.Requireable<string>;
|
|
94
|
-
/**
|
|
95
|
-
* Provide a custom className to be applied to the container node
|
|
96
|
-
*/
|
|
97
|
-
className: PropTypes.Requireable<string>;
|
|
98
|
-
/**
|
|
99
|
-
* Specify whether file input is disabled
|
|
100
|
-
*/
|
|
101
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
102
|
-
/**
|
|
103
|
-
* Specify the status of the File Upload
|
|
104
|
-
*/
|
|
105
|
-
filenameStatus: PropTypes.Validator<string>;
|
|
106
|
-
/**
|
|
107
|
-
* Provide a description for the complete/close icon that can be read by screen readers
|
|
108
|
-
*/
|
|
109
|
-
iconDescription: PropTypes.Requireable<string>;
|
|
110
|
-
/**
|
|
111
|
-
* Specify the description text of this `<FileUploader>`
|
|
112
|
-
*/
|
|
113
|
-
labelDescription: PropTypes.Requireable<string>;
|
|
114
|
-
/**
|
|
115
|
-
* Specify the title text of this `<FileUploader>`
|
|
116
|
-
*/
|
|
117
|
-
labelTitle: PropTypes.Requireable<string>;
|
|
118
|
-
/**
|
|
119
|
-
* Specify if the component should accept multiple files to upload
|
|
120
|
-
*/
|
|
121
|
-
multiple: PropTypes.Requireable<boolean>;
|
|
122
|
-
/**
|
|
123
|
-
* Provide a name for the underlying `<input>` node
|
|
124
|
-
*/
|
|
125
|
-
name: PropTypes.Requireable<string>;
|
|
126
|
-
/**
|
|
127
|
-
* Provide an optional `onChange` hook that is called each time the input is
|
|
128
|
-
* changed
|
|
129
|
-
*/
|
|
130
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
131
|
-
/**
|
|
132
|
-
* Provide an optional `onClick` hook that is called each time the
|
|
133
|
-
* FileUploader is clicked
|
|
134
|
-
*/
|
|
135
|
-
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
136
|
-
/**
|
|
137
|
-
* Provide an optional `onDelete` hook that is called when an uploaded item
|
|
138
|
-
* is removed
|
|
139
|
-
*/
|
|
140
|
-
onDelete: PropTypes.Requireable<(...args: any[]) => any>;
|
|
141
|
-
/**
|
|
142
|
-
* Specify the size of the FileUploaderButton, from a list of available
|
|
143
|
-
* sizes.
|
|
144
|
-
*/
|
|
145
|
-
size: PropTypes.Requireable<string>;
|
|
146
|
-
};
|
|
147
|
-
static contextType: React.Context<string>;
|
|
148
|
-
state: {
|
|
149
|
-
filenames: string[];
|
|
150
|
-
};
|
|
151
|
-
nodes: HTMLElement[];
|
|
152
|
-
uploaderButton: React.RefObject<HTMLLabelElement>;
|
|
153
|
-
static getDerivedStateFromProps({ filenameStatus }: {
|
|
154
|
-
filenameStatus: any;
|
|
155
|
-
}, state: any): {
|
|
156
|
-
filenameStatus: any;
|
|
157
|
-
prevFilenameStatus: any;
|
|
158
|
-
} | null;
|
|
159
|
-
handleChange: (evt: any) => void;
|
|
160
|
-
handleClick: (evt: any, { index, filenameStatus }: {
|
|
161
|
-
index: any;
|
|
162
|
-
filenameStatus: any;
|
|
163
|
-
}) => void;
|
|
164
|
-
clearFiles: () => void;
|
|
165
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
166
|
-
}
|
|
76
|
+
declare const FileUploader: {
|
|
77
|
+
<ItemType>(props: FileUploaderProps): ReactElement;
|
|
78
|
+
propTypes?: any;
|
|
79
|
+
contextTypes?: any;
|
|
80
|
+
defaultProps?: any;
|
|
81
|
+
};
|
|
82
|
+
export default FileUploader;
|
|
@@ -18,6 +18,7 @@ var FileUploaderButton = require('./FileUploaderButton.js');
|
|
|
18
18
|
var types = require('../../prop-types/types.js');
|
|
19
19
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
20
20
|
require('../Text/index.js');
|
|
21
|
+
var useId = require('../../internal/useId.js');
|
|
21
22
|
var Text = require('../Text/Text.js');
|
|
22
23
|
var match = require('../../internal/keyboard/match.js');
|
|
23
24
|
var keys = require('../../internal/keyboard/keys.js');
|
|
@@ -28,144 +29,123 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
28
29
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
29
30
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
const FileUploader = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
|
|
33
|
+
let {
|
|
34
|
+
accept,
|
|
35
|
+
buttonKind,
|
|
36
|
+
buttonLabel,
|
|
37
|
+
className,
|
|
38
|
+
disabled,
|
|
39
|
+
filenameStatus,
|
|
40
|
+
iconDescription,
|
|
41
|
+
labelDescription,
|
|
42
|
+
labelTitle,
|
|
43
|
+
multiple,
|
|
44
|
+
name,
|
|
45
|
+
onChange,
|
|
46
|
+
onClick,
|
|
47
|
+
onDelete,
|
|
48
|
+
size,
|
|
49
|
+
...other
|
|
50
|
+
} = _ref;
|
|
51
|
+
const fileUploaderInstanceId = useId.useId('file-uploader');
|
|
52
|
+
const [state, updateState] = React.useState({
|
|
53
|
+
fileNames: []
|
|
54
|
+
});
|
|
55
|
+
const nodes = [];
|
|
56
|
+
const prefix = usePrefix.usePrefix();
|
|
57
|
+
const handleChange = evt => {
|
|
58
|
+
evt.stopPropagation();
|
|
59
|
+
const filenames = Array.prototype.map.call(evt.target.files, file => file.name);
|
|
60
|
+
updateState(prevState => ({
|
|
61
|
+
fileNames: multiple ? [...new Set([...prevState.fileNames, ...filenames])] : filenames
|
|
62
|
+
}));
|
|
63
|
+
if (onChange) {
|
|
64
|
+
onChange(evt);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const handleClick = (evt, _ref2) => {
|
|
68
|
+
let {
|
|
69
|
+
index,
|
|
70
|
+
filenameStatus
|
|
71
|
+
} = _ref2;
|
|
72
|
+
if (filenameStatus === 'edit') {
|
|
40
73
|
evt.stopPropagation();
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
74
|
+
const filteredArray = state.fileNames.filter(filename => filename !== nodes[index]?.innerText?.trim());
|
|
75
|
+
updateState({
|
|
76
|
+
fileNames: filteredArray
|
|
44
77
|
});
|
|
45
|
-
if (
|
|
46
|
-
|
|
78
|
+
if (onDelete) {
|
|
79
|
+
onDelete(evt);
|
|
80
|
+
uploaderButton.current?.focus?.();
|
|
47
81
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
82
|
+
onClick?.(evt);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const uploaderButton = /*#__PURE__*/React__default["default"].createRef();
|
|
86
|
+
const classes = cx__default["default"]({
|
|
87
|
+
[`${prefix}--form-item`]: true,
|
|
88
|
+
[className]: className
|
|
89
|
+
});
|
|
90
|
+
const getHelperLabelClasses = baseClass => cx__default["default"](baseClass, {
|
|
91
|
+
[`${prefix}--label-description--disabled`]: disabled
|
|
92
|
+
});
|
|
93
|
+
const selectedFileClasses = cx__default["default"](`${prefix}--file__selected-file`, {
|
|
94
|
+
[`${prefix}--file__selected-file--md`]: size === 'field' || size === 'md',
|
|
95
|
+
[`${prefix}--file__selected-file--sm`]: size === 'small' || size === 'sm'
|
|
96
|
+
});
|
|
97
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
98
|
+
className: classes
|
|
99
|
+
}, other), !labelTitle ? null : /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
100
|
+
as: "h3",
|
|
101
|
+
className: getHelperLabelClasses(`${prefix}--file--label`)
|
|
102
|
+
}, labelTitle), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
103
|
+
as: "p",
|
|
104
|
+
className: getHelperLabelClasses(`${prefix}--label-description`),
|
|
105
|
+
id: fileUploaderInstanceId
|
|
106
|
+
}, labelDescription), /*#__PURE__*/React__default["default"].createElement(FileUploaderButton["default"], {
|
|
107
|
+
innerRef: uploaderButton,
|
|
108
|
+
disabled: disabled,
|
|
109
|
+
labelText: buttonLabel,
|
|
110
|
+
multiple: multiple,
|
|
111
|
+
buttonKind: buttonKind,
|
|
112
|
+
onChange: handleChange,
|
|
113
|
+
disableLabelChanges: true,
|
|
114
|
+
accept: accept,
|
|
115
|
+
name: name,
|
|
116
|
+
size: size,
|
|
117
|
+
"aria-describedby": fileUploaderInstanceId
|
|
118
|
+
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
119
|
+
className: `${prefix}--file-container`
|
|
120
|
+
}, state.fileNames.length === 0 ? null : state.fileNames.map((name, index) => /*#__PURE__*/React__default["default"].createElement("span", _rollupPluginBabelHelpers["extends"]({
|
|
121
|
+
key: index,
|
|
122
|
+
className: selectedFileClasses,
|
|
123
|
+
ref: node => nodes[index] = node // eslint-disable-line
|
|
124
|
+
}, other), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
125
|
+
as: "p",
|
|
126
|
+
className: `${prefix}--file-filename`,
|
|
127
|
+
id: name
|
|
128
|
+
}, name), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
129
|
+
className: `${prefix}--file__state-container`
|
|
130
|
+
}, /*#__PURE__*/React__default["default"].createElement(Filename["default"], {
|
|
131
|
+
name: name,
|
|
132
|
+
iconDescription: iconDescription,
|
|
133
|
+
status: filenameStatus,
|
|
134
|
+
onKeyDown: evt => {
|
|
135
|
+
if (match.matches(evt, [keys.Enter, keys.Space])) {
|
|
136
|
+
handleClick(evt, {
|
|
137
|
+
index,
|
|
138
|
+
filenameStatus
|
|
59
139
|
});
|
|
60
|
-
if (this.props.onDelete) {
|
|
61
|
-
this.props.onDelete(evt);
|
|
62
|
-
this.uploaderButton.current?.focus?.();
|
|
63
|
-
}
|
|
64
|
-
this.props.onClick?.(evt);
|
|
65
140
|
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.setState({
|
|
70
|
-
filenames: []
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
static getDerivedStateFromProps(_ref2, state) {
|
|
75
|
-
let {
|
|
141
|
+
},
|
|
142
|
+
onClick: evt => handleClick(evt, {
|
|
143
|
+
index,
|
|
76
144
|
filenameStatus
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return prevFilenameStatus === filenameStatus ? null : {
|
|
82
|
-
filenameStatus,
|
|
83
|
-
prevFilenameStatus: filenameStatus
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
render() {
|
|
87
|
-
const {
|
|
88
|
-
iconDescription,
|
|
89
|
-
buttonLabel = '',
|
|
90
|
-
buttonKind = 'primary',
|
|
91
|
-
disabled = false,
|
|
92
|
-
filenameStatus = 'uploading',
|
|
93
|
-
labelDescription,
|
|
94
|
-
labelTitle,
|
|
95
|
-
className,
|
|
96
|
-
multiple = false,
|
|
97
|
-
accept = [],
|
|
98
|
-
name,
|
|
99
|
-
size = 'md',
|
|
100
|
-
onDelete,
|
|
101
|
-
// eslint-disable-line
|
|
102
|
-
...other
|
|
103
|
-
} = this.props;
|
|
104
|
-
const prefix = this.context;
|
|
105
|
-
const classes = cx__default["default"]({
|
|
106
|
-
[`${prefix}--form-item`]: true,
|
|
107
|
-
[className]: className
|
|
108
|
-
});
|
|
109
|
-
const getHelperLabelClasses = baseClass => cx__default["default"](baseClass, {
|
|
110
|
-
[`${prefix}--label-description--disabled`]: disabled
|
|
111
|
-
});
|
|
112
|
-
const selectedFileClasses = cx__default["default"](`${prefix}--file__selected-file`, {
|
|
113
|
-
[`${prefix}--file__selected-file--md`]: size === 'field' || size === 'md',
|
|
114
|
-
[`${prefix}--file__selected-file--sm`]: size === 'small' || size === 'sm'
|
|
115
|
-
});
|
|
116
|
-
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
117
|
-
className: classes
|
|
118
|
-
}, other), !labelTitle ? null : /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
119
|
-
as: "h3",
|
|
120
|
-
className: getHelperLabelClasses(`${prefix}--file--label`)
|
|
121
|
-
}, labelTitle), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
122
|
-
as: "p",
|
|
123
|
-
className: getHelperLabelClasses(`${prefix}--label-description`),
|
|
124
|
-
id: "description"
|
|
125
|
-
}, labelDescription), /*#__PURE__*/React__default["default"].createElement(FileUploaderButton["default"], {
|
|
126
|
-
innerRef: this.uploaderButton,
|
|
127
|
-
disabled: disabled,
|
|
128
|
-
labelText: buttonLabel,
|
|
129
|
-
multiple: multiple,
|
|
130
|
-
buttonKind: buttonKind,
|
|
131
|
-
onChange: this.handleChange,
|
|
132
|
-
disableLabelChanges: true,
|
|
133
|
-
accept: accept,
|
|
134
|
-
name: name,
|
|
135
|
-
size: size,
|
|
136
|
-
"aria-describedby": "description"
|
|
137
|
-
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
138
|
-
className: `${prefix}--file-container`
|
|
139
|
-
}, this.state.filenames.length === 0 ? null : this.state.filenames.map((name, index) => /*#__PURE__*/React__default["default"].createElement("span", _rollupPluginBabelHelpers["extends"]({
|
|
140
|
-
key: index,
|
|
141
|
-
className: selectedFileClasses,
|
|
142
|
-
ref: node => this.nodes[index] = node // eslint-disable-line
|
|
143
|
-
}, other), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
144
|
-
as: "p",
|
|
145
|
-
className: `${prefix}--file-filename`,
|
|
146
|
-
id: name
|
|
147
|
-
}, name), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
148
|
-
className: `${prefix}--file__state-container`
|
|
149
|
-
}, /*#__PURE__*/React__default["default"].createElement(Filename["default"], {
|
|
150
|
-
name: name,
|
|
151
|
-
iconDescription: iconDescription,
|
|
152
|
-
status: filenameStatus,
|
|
153
|
-
onKeyDown: evt => {
|
|
154
|
-
if (match.matches(evt, [keys.Enter, keys.Space])) {
|
|
155
|
-
this.handleClick(evt, {
|
|
156
|
-
index,
|
|
157
|
-
filenameStatus
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
onClick: evt => this.handleClick(evt, {
|
|
162
|
-
index,
|
|
163
|
-
filenameStatus
|
|
164
|
-
})
|
|
165
|
-
}))))));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
_rollupPluginBabelHelpers.defineProperty(FileUploader, "propTypes", {
|
|
145
|
+
})
|
|
146
|
+
}))))));
|
|
147
|
+
});
|
|
148
|
+
FileUploader.propTypes = {
|
|
169
149
|
/**
|
|
170
150
|
* Specify the types of files that this input should be able to receive
|
|
171
151
|
*/
|
|
@@ -231,7 +211,6 @@ _rollupPluginBabelHelpers.defineProperty(FileUploader, "propTypes", {
|
|
|
231
211
|
* sizes.
|
|
232
212
|
*/
|
|
233
213
|
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg'])
|
|
234
|
-
}
|
|
235
|
-
_rollupPluginBabelHelpers.defineProperty(FileUploader, "contextType", usePrefix.PrefixContext);
|
|
214
|
+
};
|
|
236
215
|
|
|
237
216
|
exports["default"] = FileUploader;
|
|
@@ -24,6 +24,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
24
24
|
|
|
25
25
|
function CSSGrid(_ref) {
|
|
26
26
|
let {
|
|
27
|
+
align,
|
|
27
28
|
as: BaseComponent = 'div',
|
|
28
29
|
children,
|
|
29
30
|
className: customClassName,
|
|
@@ -56,7 +57,9 @@ function CSSGrid(_ref) {
|
|
|
56
57
|
[`${prefix}--css-grid`]: true,
|
|
57
58
|
[`${prefix}--css-grid--condensed`]: mode === 'condensed',
|
|
58
59
|
[`${prefix}--css-grid--narrow`]: mode === 'narrow',
|
|
59
|
-
[`${prefix}--css-grid--full-width`]: fullWidth
|
|
60
|
+
[`${prefix}--css-grid--full-width`]: fullWidth,
|
|
61
|
+
[`${prefix}--css-grid--start`]: align === 'start',
|
|
62
|
+
[`${prefix}--css-grid--end`]: align === 'end'
|
|
60
63
|
});
|
|
61
64
|
|
|
62
65
|
// cast as any to let TypeScript allow passing in attributes to base component
|
|
@@ -69,6 +72,10 @@ function CSSGrid(_ref) {
|
|
|
69
72
|
}, rest), children));
|
|
70
73
|
}
|
|
71
74
|
CSSGrid.propTypes = {
|
|
75
|
+
/**
|
|
76
|
+
* Specify grid aligment. Default is center
|
|
77
|
+
*/
|
|
78
|
+
align: PropTypes__default["default"].oneOf(['start', 'center', 'end']),
|
|
72
79
|
/**
|
|
73
80
|
* Provide a custom element to render instead of the default <div>
|
|
74
81
|
*/
|
|
@@ -28,6 +28,10 @@ function Grid(props) {
|
|
|
28
28
|
return /*#__PURE__*/React__default["default"].createElement(FlexGrid.FlexGrid, props);
|
|
29
29
|
}
|
|
30
30
|
Grid.propTypes = {
|
|
31
|
+
/**
|
|
32
|
+
* Specify grid aligment. Default is center
|
|
33
|
+
*/
|
|
34
|
+
align: PropTypes__default["default"].oneOf(['start', 'center', 'end']),
|
|
31
35
|
/**
|
|
32
36
|
* Provide a custom element to render instead of the default <div>
|
|
33
37
|
*/
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
9
|
+
type IdPrefixProps = {
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* The value used to prefix the auto-generated id placed on some DOM elements
|
|
13
|
+
*/
|
|
14
|
+
prefix?: string;
|
|
15
|
+
};
|
|
16
|
+
declare function IdPrefix({ children, prefix }: PropsWithChildren<IdPrefixProps>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare namespace IdPrefix {
|
|
18
|
+
var propTypes: {
|
|
19
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
20
|
+
/**
|
|
21
|
+
* The value used to prefix the auto-generated id placed on some DOM elements
|
|
22
|
+
*/
|
|
23
|
+
prefix: PropTypes.Requireable<string>;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export { IdPrefix };
|
|
@@ -37,6 +37,10 @@ export interface ListBoxSelectionProps {
|
|
|
37
37
|
* Specify whether or not the clear selection element should be disabled
|
|
38
38
|
*/
|
|
39
39
|
disabled?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether or not the listbox is readonly
|
|
42
|
+
*/
|
|
43
|
+
readOnly?: boolean;
|
|
40
44
|
/**
|
|
41
45
|
* Specify an optional `onClearSelection` handler that is called when the underlying
|
|
42
46
|
* element is cleared
|
|
@@ -58,7 +62,7 @@ export interface ListBoxSelectionProps {
|
|
|
58
62
|
*/
|
|
59
63
|
onMouseUp?: React.MouseEventHandler<HTMLButtonElement>;
|
|
60
64
|
}
|
|
61
|
-
declare function ListBoxSelection({ clearSelection, selectionCount, translateWithId: t, disabled, onClearSelection, ...rest }: ListBoxSelectionProps): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
declare function ListBoxSelection({ clearSelection, selectionCount, translateWithId: t, disabled, readOnly, onClearSelection, ...rest }: ListBoxSelectionProps): import("react/jsx-runtime").JSX.Element;
|
|
62
66
|
declare namespace ListBoxSelection {
|
|
63
67
|
var propTypes: {
|
|
64
68
|
/**
|
|
@@ -70,6 +74,10 @@ declare namespace ListBoxSelection {
|
|
|
70
74
|
* Specify whether or not the clear selection element should be disabled
|
|
71
75
|
*/
|
|
72
76
|
disabled: PropTypes.Requireable<boolean>;
|
|
77
|
+
/**
|
|
78
|
+
* Whether or not the listbox is readonly
|
|
79
|
+
*/
|
|
80
|
+
readOnly: PropTypes.Requireable<boolean>;
|
|
73
81
|
/**
|
|
74
82
|
* Specify an optional `onClearSelection` handler that is called when the underlying
|
|
75
83
|
* element is cleared
|