@carbon/react 1.42.1 → 1.44.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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +2843 -1416
- package/es/components/Breadcrumb/BreadcrumbItem.js +1 -2
- package/es/components/ComboBox/ComboBox.d.ts +5 -0
- package/es/components/ComboBox/ComboBox.js +28 -2
- package/es/components/ComboButton/index.js +2 -1
- package/es/components/ComposedModal/ComposedModal.d.ts +3 -3
- package/es/components/ComposedModal/ComposedModal.js +3 -3
- package/es/components/ComposedModal/ModalFooter.d.ts +18 -0
- package/es/components/ComposedModal/ModalFooter.js +48 -16
- package/es/components/ContextMenu/useContextMenu.js +2 -1
- package/es/components/DataTableSkeleton/DataTableSkeleton.js +1 -1
- package/es/components/DatePickerInput/DatePickerInput.d.ts +4 -0
- package/es/components/DatePickerInput/DatePickerInput.js +16 -2
- package/es/components/Dropdown/Dropdown.d.ts +5 -0
- package/es/components/Dropdown/Dropdown.js +20 -3
- package/es/components/InlineLoading/index.js +9 -0
- package/es/components/Link/Link.d.ts +5 -0
- package/es/components/Link/Link.js +9 -2
- package/es/components/Menu/Menu.js +14 -0
- package/es/components/Menu/MenuContext.js +1 -0
- package/es/components/Menu/MenuItem.js +19 -4
- package/es/components/MenuButton/index.js +3 -1
- package/es/components/Modal/Modal.d.ts +17 -0
- package/es/components/Modal/Modal.js +38 -3
- package/es/components/MultiSelect/FilterableMultiSelect.js +17 -3
- package/es/components/MultiSelect/MultiSelect.d.ts +5 -0
- package/es/components/MultiSelect/MultiSelect.js +17 -3
- package/es/components/NumberInput/NumberInput.d.ts +5 -0
- package/es/components/NumberInput/NumberInput.js +29 -4
- package/es/components/Select/Select.d.ts +6 -1
- package/es/components/Select/Select.js +16 -2
- package/es/components/Slug/index.js +187 -0
- package/es/components/TextArea/TextArea.d.ts +4 -0
- package/es/components/TextArea/TextArea.js +47 -31
- package/es/components/TextInput/TextInput.d.ts +5 -0
- package/es/components/TextInput/TextInput.js +16 -2
- package/es/components/UIShell/SideNav.js +1 -1
- package/es/components/UIShell/SideNavHeader.d.ts +29 -0
- package/es/components/UIShell/SideNavHeader.js +3 -3
- package/es/components/UIShell/Switcher.d.ts +38 -0
- package/es/components/UIShell/Switcher.js +14 -13
- package/es/components/UIShell/SwitcherDivider.d.ts +9 -0
- package/es/components/UIShell/SwitcherDivider.js +4 -5
- package/es/components/UIShell/SwitcherItem.d.ts +49 -0
- package/es/components/UIShell/SwitcherItem.js +13 -17
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/prop-types/tools/getDisplayName.js +34 -0
- package/lib/components/Breadcrumb/BreadcrumbItem.js +1 -2
- package/lib/components/ComboBox/ComboBox.d.ts +5 -0
- package/lib/components/ComboBox/ComboBox.js +28 -2
- package/lib/components/ComboButton/index.js +2 -1
- package/lib/components/ComposedModal/ComposedModal.d.ts +3 -3
- package/lib/components/ComposedModal/ComposedModal.js +3 -3
- package/lib/components/ComposedModal/ModalFooter.d.ts +18 -0
- package/lib/components/ComposedModal/ModalFooter.js +48 -16
- package/lib/components/ContextMenu/useContextMenu.js +2 -1
- package/lib/components/DataTableSkeleton/DataTableSkeleton.js +1 -1
- package/lib/components/DatePickerInput/DatePickerInput.d.ts +4 -0
- package/lib/components/DatePickerInput/DatePickerInput.js +16 -2
- package/lib/components/Dropdown/Dropdown.d.ts +5 -0
- package/lib/components/Dropdown/Dropdown.js +20 -3
- package/lib/components/InlineLoading/index.js +17 -0
- package/lib/components/Link/Link.d.ts +5 -0
- package/lib/components/Link/Link.js +9 -2
- package/lib/components/Menu/Menu.js +14 -0
- package/lib/components/Menu/MenuContext.js +1 -0
- package/lib/components/Menu/MenuItem.js +19 -4
- package/lib/components/MenuButton/index.js +3 -1
- package/lib/components/Modal/Modal.d.ts +17 -0
- package/lib/components/Modal/Modal.js +38 -3
- package/lib/components/MultiSelect/FilterableMultiSelect.js +17 -3
- package/lib/components/MultiSelect/MultiSelect.d.ts +5 -0
- package/lib/components/MultiSelect/MultiSelect.js +17 -3
- package/lib/components/NumberInput/NumberInput.d.ts +5 -0
- package/lib/components/NumberInput/NumberInput.js +28 -3
- package/lib/components/Select/Select.d.ts +6 -1
- package/lib/components/Select/Select.js +16 -2
- package/lib/components/Slug/index.js +199 -0
- package/lib/components/TextArea/TextArea.d.ts +4 -0
- package/lib/components/TextArea/TextArea.js +47 -31
- package/lib/components/TextInput/TextInput.d.ts +5 -0
- package/lib/components/TextInput/TextInput.js +16 -2
- package/lib/components/UIShell/SideNav.js +1 -1
- package/lib/components/UIShell/SideNavHeader.d.ts +29 -0
- package/lib/components/UIShell/SideNavHeader.js +3 -3
- package/lib/components/UIShell/Switcher.d.ts +38 -0
- package/lib/components/UIShell/Switcher.js +13 -12
- package/lib/components/UIShell/SwitcherDivider.d.ts +9 -0
- package/lib/components/UIShell/SwitcherDivider.js +4 -5
- package/lib/components/UIShell/SwitcherItem.d.ts +49 -0
- package/lib/components/UIShell/SwitcherItem.js +12 -16
- package/lib/index.d.ts +1 -0
- package/lib/index.js +45 -41
- package/lib/prop-types/tools/getDisplayName.js +38 -0
- package/package.json +6 -6
- package/scss/utilities/_ai-gradient.scss +9 -0
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default from 'react';
|
|
9
|
+
import React__default, { forwardRef } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
|
-
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
13
12
|
import Link from './Link.js';
|
|
14
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
+
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
15
15
|
import { match } from '../../internal/keyboard/match.js';
|
|
16
16
|
import { ArrowDown, ArrowUp } from '../../internal/keyboard/keys.js';
|
|
17
17
|
|
|
18
|
-
const SwitcherItem = /*#__PURE__*/
|
|
19
|
-
|
|
18
|
+
const SwitcherItem = /*#__PURE__*/forwardRef(function SwitcherItem(props, forwardRef) {
|
|
19
|
+
const {
|
|
20
20
|
'aria-label': ariaLabel,
|
|
21
21
|
'aria-labelledby': ariaLabelledBy,
|
|
22
22
|
className: customClassName,
|
|
@@ -28,10 +28,10 @@ const SwitcherItem = /*#__PURE__*/React__default.forwardRef(function SwitcherIte
|
|
|
28
28
|
handleSwitcherItemFocus,
|
|
29
29
|
onKeyDown = () => {},
|
|
30
30
|
...rest
|
|
31
|
-
} =
|
|
31
|
+
} = props;
|
|
32
32
|
const prefix = usePrefix();
|
|
33
|
-
const
|
|
34
|
-
[customClassName]: !!customClassName
|
|
33
|
+
const classNames = cx(`${prefix}--switcher__item`, {
|
|
34
|
+
[customClassName || '']: !!customClassName
|
|
35
35
|
});
|
|
36
36
|
const accessibilityLabel = {
|
|
37
37
|
'aria-label': ariaLabel,
|
|
@@ -44,36 +44,33 @@ const SwitcherItem = /*#__PURE__*/React__default.forwardRef(function SwitcherIte
|
|
|
44
44
|
if (match(evt, ArrowDown)) {
|
|
45
45
|
evt.preventDefault();
|
|
46
46
|
handleSwitcherItemFocus?.({
|
|
47
|
-
currentIndex: index,
|
|
47
|
+
currentIndex: index || -1,
|
|
48
48
|
direction: 1
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
if (match(evt, ArrowUp)) {
|
|
52
52
|
evt.preventDefault();
|
|
53
53
|
handleSwitcherItemFocus?.({
|
|
54
|
-
currentIndex: index,
|
|
54
|
+
currentIndex: index || -1,
|
|
55
55
|
direction: -1
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
60
|
-
className:
|
|
60
|
+
className: classNames
|
|
61
61
|
}, /*#__PURE__*/React__default.createElement(Link, _extends({
|
|
62
62
|
onKeyDown: evt => {
|
|
63
63
|
setTabFocus(evt);
|
|
64
64
|
onKeyDown(evt);
|
|
65
|
-
}
|
|
65
|
+
},
|
|
66
|
+
ref: forwardRef
|
|
66
67
|
}, rest, {
|
|
67
|
-
ref: ref,
|
|
68
68
|
className: linkClassName,
|
|
69
69
|
tabIndex: tabIndex
|
|
70
70
|
}, accessibilityLabel), children));
|
|
71
71
|
});
|
|
72
72
|
SwitcherItem.displayName = 'SwitcherItem';
|
|
73
73
|
SwitcherItem.propTypes = {
|
|
74
|
-
/**
|
|
75
|
-
* Required props for accessibility label on the underlying menuitem
|
|
76
|
-
*/
|
|
77
74
|
...AriaLabelPropType,
|
|
78
75
|
/**
|
|
79
76
|
* Specify the text content for the link
|
|
@@ -100,6 +97,5 @@ SwitcherItem.propTypes = {
|
|
|
100
97
|
*/
|
|
101
98
|
tabIndex: PropTypes.number
|
|
102
99
|
};
|
|
103
|
-
var SwitcherItem$1 = SwitcherItem;
|
|
104
100
|
|
|
105
|
-
export { SwitcherItem
|
|
101
|
+
export { SwitcherItem as default };
|
package/es/index.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ export { OverflowMenuV2 as unstable_OverflowMenuV2 } from './components/Overflow
|
|
|
114
114
|
export { PageSelector as unstable_PageSelector, Pagination as unstable_Pagination, } from './components/Pagination/experimental';
|
|
115
115
|
export * from './components/Popover';
|
|
116
116
|
export * from './components/ProgressBar';
|
|
117
|
+
export { Slug as unstable__Slug, SlugContent as unstable__SlugContent, SlugActions as unstable__SlugActions, } from './components/Slug';
|
|
117
118
|
export * from './components/Stack';
|
|
118
119
|
export * from './components/Tooltip';
|
|
119
120
|
export { Text as unstable_Text, TextDirection as unstable_TextDirection, } from './components/Text';
|
package/es/index.js
CHANGED
|
@@ -133,6 +133,7 @@ export { Layer, useLayer } from './components/Layer/index.js';
|
|
|
133
133
|
export { Layout as unstable_Layout } from './components/Layout/index.js';
|
|
134
134
|
export { OverflowMenuV2 as unstable_OverflowMenuV2 } from './components/OverflowMenuV2/index.js';
|
|
135
135
|
export { Popover, PopoverContent } from './components/Popover/index.js';
|
|
136
|
+
export { Slug as unstable__Slug, SlugActions as unstable__SlugActions, SlugContent as unstable__SlugContent } from './components/Slug/index.js';
|
|
136
137
|
export { HStack, VStack } from './components/Stack/index.js';
|
|
137
138
|
export { DefinitionTooltip } from './components/Tooltip/DefinitionTooltip.js';
|
|
138
139
|
export { Tooltip } from './components/Tooltip/Tooltip.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
|
|
8
|
+
const cachedDisplayNames = new WeakMap();
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* `getDisplayName` is a utility function for getting a name from a given
|
|
12
|
+
* component type. It supports names from React elements, Stateless Functional
|
|
13
|
+
* Components, and Class-based Components
|
|
14
|
+
*/
|
|
15
|
+
const getDisplayName = type => {
|
|
16
|
+
if (typeof type === 'string') {
|
|
17
|
+
return type;
|
|
18
|
+
}
|
|
19
|
+
if (cachedDisplayNames.has(type)) {
|
|
20
|
+
return cachedDisplayNames.get(type);
|
|
21
|
+
}
|
|
22
|
+
let displayName;
|
|
23
|
+
if (typeof type.displayName === 'string') {
|
|
24
|
+
displayName = type.displayName;
|
|
25
|
+
}
|
|
26
|
+
if (!displayName) {
|
|
27
|
+
displayName = type.name || 'Unknown';
|
|
28
|
+
}
|
|
29
|
+
cachedDisplayNames.set(type, displayName);
|
|
30
|
+
return displayName;
|
|
31
|
+
};
|
|
32
|
+
var getDisplayName$1 = getDisplayName;
|
|
33
|
+
|
|
34
|
+
export { getDisplayName$1 as default };
|
|
@@ -79,8 +79,7 @@ const BreadcrumbItem = /*#__PURE__*/React__default["default"].forwardRef(functio
|
|
|
79
79
|
});
|
|
80
80
|
BreadcrumbItem.displayName = 'BreadcrumbItem';
|
|
81
81
|
BreadcrumbItem.propTypes = {
|
|
82
|
-
|
|
83
|
-
'aria-current': PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].bool]),
|
|
82
|
+
'aria-current': PropTypes__default["default"].oneOfType([PropTypes__default["default"].bool, PropTypes__default["default"].oneOf(['false', 'true', 'page', 'step', 'location', 'date', 'time'])]),
|
|
84
83
|
/**
|
|
85
84
|
* Pass in content that will be inside of the BreadcrumbItem
|
|
86
85
|
*/
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import Downshift from 'downshift';
|
|
8
|
+
import { ReactNodeLike } from 'prop-types';
|
|
8
9
|
import { type ComponentProps, type ReactNode, type ComponentType, type ReactElement, type RefAttributes, type PropsWithChildren, type PropsWithoutRef, type InputHTMLAttributes, type MouseEvent } from 'react';
|
|
9
10
|
import { ListBoxSize } from '../ListBox';
|
|
10
11
|
type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type' | 'size';
|
|
@@ -135,6 +136,10 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
|
|
|
135
136
|
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
136
137
|
*/
|
|
137
138
|
size?: ListBoxSize;
|
|
139
|
+
/**
|
|
140
|
+
* Provide a `Slug` component to be rendered inside the `ComboBox` component
|
|
141
|
+
*/
|
|
142
|
+
slug?: ReactNodeLike;
|
|
138
143
|
/**
|
|
139
144
|
* Provide text to be used in a `<label>` element that is tied to the
|
|
140
145
|
* combobox via ARIA attributes.
|
|
@@ -123,6 +123,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
123
123
|
warn,
|
|
124
124
|
warnText,
|
|
125
125
|
allowCustomValue = false,
|
|
126
|
+
slug,
|
|
126
127
|
...rest
|
|
127
128
|
} = props;
|
|
128
129
|
const prefix = usePrefix.usePrefix();
|
|
@@ -254,7 +255,8 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
254
255
|
});
|
|
255
256
|
const wrapperClasses = cx__default["default"](`${prefix}--list-box__wrapper`, [containerClassName, {
|
|
256
257
|
[`${prefix}--list-box__wrapper--fluid--invalid`]: isFluid && invalid,
|
|
257
|
-
[`${prefix}--list-box__wrapper--fluid--focus`]: isFluid && isFocused
|
|
258
|
+
[`${prefix}--list-box__wrapper--fluid--focus`]: isFluid && isFocused,
|
|
259
|
+
[`${prefix}--list-box__wrapper--slug`]: slug
|
|
258
260
|
}]);
|
|
259
261
|
const inputClasses = cx__default["default"](`${prefix}--text-input`, {
|
|
260
262
|
[`${prefix}--text-input--empty`]: !inputValue,
|
|
@@ -263,6 +265,14 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
263
265
|
|
|
264
266
|
// needs to be Capitalized for react to render it correctly
|
|
265
267
|
const ItemToElement = itemToElement;
|
|
268
|
+
|
|
269
|
+
// Slug is always size `mini`
|
|
270
|
+
let normalizedSlug;
|
|
271
|
+
if (slug) {
|
|
272
|
+
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
273
|
+
size: 'mini'
|
|
274
|
+
});
|
|
275
|
+
}
|
|
266
276
|
return /*#__PURE__*/React__default["default"].createElement(Downshift__default["default"], _rollupPluginBabelHelpers["extends"]({}, downshiftProps, {
|
|
267
277
|
onChange: handleOnChange,
|
|
268
278
|
onInputValueChange: handleOnInputValueChange,
|
|
@@ -352,6 +362,18 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
352
362
|
if (match.match(event, keys.End) && event.code !== 'Numpad1') {
|
|
353
363
|
event.target.setSelectionRange(event.target.value.length, event.target.value.length);
|
|
354
364
|
}
|
|
365
|
+
if (event.altKey && event.key == 'ArrowDown') {
|
|
366
|
+
event.preventDownshiftDefault = true;
|
|
367
|
+
if (!isOpen) {
|
|
368
|
+
toggleMenu();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (event.altKey && event.key == 'ArrowUp') {
|
|
372
|
+
event.preventDownshiftDefault = true;
|
|
373
|
+
if (isOpen) {
|
|
374
|
+
toggleMenu();
|
|
375
|
+
}
|
|
376
|
+
}
|
|
355
377
|
}
|
|
356
378
|
});
|
|
357
379
|
const handleFocus = evt => {
|
|
@@ -413,7 +435,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
413
435
|
}), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
|
|
414
436
|
isOpen: isOpen,
|
|
415
437
|
translateWithId: translateWithId
|
|
416
|
-
}))), /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, getMenuProps({
|
|
438
|
+
}))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, getMenuProps({
|
|
417
439
|
'aria-label': deprecatedAriaLabel || ariaLabel
|
|
418
440
|
}), isOpen ? filterItems(items, itemToString, inputValue).map((item, index$1) => {
|
|
419
441
|
const isObject = item !== null && typeof item === 'object';
|
|
@@ -563,6 +585,10 @@ ComboBox.propTypes = {
|
|
|
563
585
|
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
564
586
|
*/
|
|
565
587
|
size: ListBoxPropTypes.ListBoxSize,
|
|
588
|
+
/**
|
|
589
|
+
* Provide a `Slug` component to be rendered inside the `ComboBox` component
|
|
590
|
+
*/
|
|
591
|
+
slug: PropTypes__default["default"].node,
|
|
566
592
|
/**
|
|
567
593
|
* Provide text to be used in a `<label>` element that is tied to the
|
|
568
594
|
* combobox via ARIA attributes.
|
|
@@ -78,7 +78,7 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
function handleOpen() {
|
|
81
|
-
menuRef.current.style.
|
|
81
|
+
menuRef.current.style.inlineSize = `${width}px`;
|
|
82
82
|
}
|
|
83
83
|
const containerClasses = cx__default["default"](`${prefix}--combo-button__container`, `${prefix}--combo-button__container--${size}`, {
|
|
84
84
|
[`${prefix}--combo-button__container--open`]: open
|
|
@@ -110,6 +110,7 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
110
110
|
ref: menuRef,
|
|
111
111
|
id: id,
|
|
112
112
|
label: t('carbon.combo-button.additional-actions'),
|
|
113
|
+
mode: "basic",
|
|
113
114
|
size: size,
|
|
114
115
|
open: open,
|
|
115
116
|
onClose: handleClose,
|
|
@@ -4,7 +4,7 @@ export interface ModalBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
4
4
|
children?: ReactNode;
|
|
5
5
|
/**
|
|
6
6
|
* Provide whether the modal content has a form element.
|
|
7
|
-
* If `true` is used here, non-form child content should have `
|
|
7
|
+
* If `true` is used here, non-form child content should have `cds--modal-content__regular-content` class.
|
|
8
8
|
*/
|
|
9
9
|
hasForm?: boolean;
|
|
10
10
|
/**
|
|
@@ -15,11 +15,11 @@ export interface ModalBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
15
15
|
export declare const ModalBody: React.ForwardRefExoticComponent<ModalBodyProps & React.RefAttributes<HTMLDivElement>>;
|
|
16
16
|
export interface ComposedModalProps extends HTMLAttributes<HTMLDivElement> {
|
|
17
17
|
/**
|
|
18
|
-
* Specify the aria-label for
|
|
18
|
+
* Specify the aria-label for cds--modal-container
|
|
19
19
|
*/
|
|
20
20
|
'aria-label'?: string;
|
|
21
21
|
/**
|
|
22
|
-
* Specify the aria-labelledby for
|
|
22
|
+
* Specify the aria-labelledby for cds--modal-container
|
|
23
23
|
*/
|
|
24
24
|
'aria-labelledby'?: string;
|
|
25
25
|
/**
|
|
@@ -66,7 +66,7 @@ ModalBody.propTypes = {
|
|
|
66
66
|
className: PropTypes__default["default"].string,
|
|
67
67
|
/**
|
|
68
68
|
* Provide whether the modal content has a form element.
|
|
69
|
-
* If `true` is used here, non-form child content should have `
|
|
69
|
+
* If `true` is used here, non-form child content should have `cds--modal-content__regular-content` class.
|
|
70
70
|
*/
|
|
71
71
|
hasForm: PropTypes__default["default"].bool,
|
|
72
72
|
/**
|
|
@@ -241,11 +241,11 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
241
241
|
});
|
|
242
242
|
ComposedModal.propTypes = {
|
|
243
243
|
/**
|
|
244
|
-
* Specify the aria-label for
|
|
244
|
+
* Specify the aria-label for cds--modal-container
|
|
245
245
|
*/
|
|
246
246
|
['aria-label']: PropTypes__default["default"].string,
|
|
247
247
|
/**
|
|
248
|
-
* Specify the aria-labelledby for
|
|
248
|
+
* Specify the aria-labelledby for cds--modal-container
|
|
249
249
|
*/
|
|
250
250
|
['aria-labelledby']: PropTypes__default["default"].string,
|
|
251
251
|
/**
|
|
@@ -5,6 +5,7 @@ interface SecondaryButtonProps {
|
|
|
5
5
|
}
|
|
6
6
|
export interface SecondaryButtonSetProps {
|
|
7
7
|
closeModal(evt: MouseEvent): void;
|
|
8
|
+
disabled?: boolean;
|
|
8
9
|
onRequestClose(evt: MouseEvent): void;
|
|
9
10
|
secondaryButtonText?: string;
|
|
10
11
|
secondaryButtons?: [SecondaryButtonProps, SecondaryButtonProps];
|
|
@@ -66,6 +67,23 @@ export interface ModalFooterProps {
|
|
|
66
67
|
* Specify a custom className to be applied to the secondary button
|
|
67
68
|
*/
|
|
68
69
|
secondaryClassName?: string;
|
|
70
|
+
/**
|
|
71
|
+
* loading status
|
|
72
|
+
*/
|
|
73
|
+
loadingStatus?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Specify the description for the loading text
|
|
76
|
+
*/
|
|
77
|
+
loadingDescription?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Specify the description for the loading text
|
|
80
|
+
*/
|
|
81
|
+
loadingIconDescription?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Provide an optional handler to be invoked when loading is
|
|
84
|
+
* successful
|
|
85
|
+
*/
|
|
86
|
+
onLoadingSuccess?(): void;
|
|
69
87
|
}
|
|
70
88
|
export declare const ModalFooter: React.ForwardRefExoticComponent<ModalFooterProps & React.RefAttributes<HTMLElement>>;
|
|
71
89
|
export {};
|
|
@@ -18,6 +18,7 @@ var ButtonSet = require('../ButtonSet/ButtonSet.js');
|
|
|
18
18
|
var cx = require('classnames');
|
|
19
19
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
20
20
|
var noopFn = require('../../internal/noopFn.js');
|
|
21
|
+
var InlineLoading = require('../InlineLoading/InlineLoading.js');
|
|
21
22
|
|
|
22
23
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
24
|
|
|
@@ -31,7 +32,8 @@ function SecondaryButtonSet(_ref) {
|
|
|
31
32
|
secondaryButtonText,
|
|
32
33
|
secondaryClassName,
|
|
33
34
|
closeModal,
|
|
34
|
-
onRequestClose
|
|
35
|
+
onRequestClose,
|
|
36
|
+
disabled
|
|
35
37
|
} = _ref;
|
|
36
38
|
function handleRequestClose(evt) {
|
|
37
39
|
closeModal(evt);
|
|
@@ -53,6 +55,7 @@ function SecondaryButtonSet(_ref) {
|
|
|
53
55
|
}
|
|
54
56
|
if (secondaryButtonText) {
|
|
55
57
|
return /*#__PURE__*/React__default["default"].createElement(Button["default"], {
|
|
58
|
+
disabled: disabled,
|
|
56
59
|
className: secondaryClassName,
|
|
57
60
|
onClick: handleRequestClose,
|
|
58
61
|
kind: "secondary"
|
|
@@ -62,6 +65,7 @@ function SecondaryButtonSet(_ref) {
|
|
|
62
65
|
}
|
|
63
66
|
SecondaryButtonSet.propTypes = {
|
|
64
67
|
closeModal: PropTypes__default["default"].func,
|
|
68
|
+
disabled: PropTypes__default["default"].bool,
|
|
65
69
|
onRequestClose: PropTypes__default["default"].func,
|
|
66
70
|
secondaryButtonText: PropTypes__default["default"].string,
|
|
67
71
|
secondaryButtons: (props, propName, componentName) => {
|
|
@@ -96,32 +100,43 @@ const ModalFooter = /*#__PURE__*/React__default["default"].forwardRef(function M
|
|
|
96
100
|
secondaryButtonText,
|
|
97
101
|
secondaryButtons,
|
|
98
102
|
secondaryClassName,
|
|
103
|
+
loadingStatus = 'inactive',
|
|
104
|
+
loadingDescription,
|
|
105
|
+
loadingIconDescription,
|
|
106
|
+
onLoadingSuccess = noopFn.noopFn,
|
|
99
107
|
...rest
|
|
100
108
|
} = _ref3;
|
|
101
109
|
const prefix = usePrefix.usePrefix();
|
|
102
110
|
const footerClass = cx__default["default"](`${prefix}--modal-footer`, customClassName, Array.isArray(secondaryButtons) && secondaryButtons.length === 2 ? `${prefix}--modal-footer--three-button` : null);
|
|
111
|
+
const primaryButtonClass = cx__default["default"](primaryClassName, loadingStatus !== 'inactive' ? `${prefix}--btn--loading` : null);
|
|
112
|
+
const loadingActive = loadingStatus !== 'inactive';
|
|
103
113
|
const secondaryButtonProps = {
|
|
104
114
|
closeModal,
|
|
105
115
|
secondaryButtons,
|
|
106
116
|
secondaryButtonText,
|
|
107
117
|
secondaryClassName,
|
|
108
|
-
onRequestClose
|
|
118
|
+
onRequestClose,
|
|
119
|
+
disabled: loadingActive
|
|
109
120
|
};
|
|
110
|
-
return (
|
|
111
|
-
|
|
121
|
+
return /*#__PURE__*/React__default["default"].createElement(ButtonSet["default"], _rollupPluginBabelHelpers["extends"]({
|
|
122
|
+
className: footerClass
|
|
123
|
+
}, rest, {
|
|
112
124
|
// @ts-expect-error: Invalid derived types, will be fine once explicit types are added
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
ref: ref,
|
|
126
|
+
"aria-busy": loadingActive
|
|
127
|
+
}), /*#__PURE__*/React__default["default"].createElement(SecondaryButtonSet, secondaryButtonProps), primaryButtonText && /*#__PURE__*/React__default["default"].createElement(Button["default"], {
|
|
128
|
+
onClick: onRequestSubmit,
|
|
129
|
+
className: primaryButtonClass,
|
|
130
|
+
disabled: loadingActive || primaryButtonDisabled,
|
|
131
|
+
kind: danger ? 'danger' : 'primary',
|
|
132
|
+
ref: inputref
|
|
133
|
+
}, loadingStatus === 'inactive' ? primaryButtonText : /*#__PURE__*/React__default["default"].createElement(InlineLoading["default"], {
|
|
134
|
+
status: loadingStatus,
|
|
135
|
+
description: loadingDescription,
|
|
136
|
+
iconDescription: loadingIconDescription,
|
|
137
|
+
className: `${prefix}--inline-loading--btn`,
|
|
138
|
+
onSuccess: onLoadingSuccess
|
|
139
|
+
})), children);
|
|
125
140
|
});
|
|
126
141
|
ModalFooter.propTypes = {
|
|
127
142
|
/**
|
|
@@ -148,6 +163,23 @@ ModalFooter.propTypes = {
|
|
|
148
163
|
inputref: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].shape({
|
|
149
164
|
current: PropTypes__default["default"].any
|
|
150
165
|
})]),
|
|
166
|
+
/**
|
|
167
|
+
* Specify the description for the loading text
|
|
168
|
+
*/
|
|
169
|
+
loadingDescription: PropTypes__default["default"].string,
|
|
170
|
+
/**
|
|
171
|
+
* Specify the description for the loading text
|
|
172
|
+
*/
|
|
173
|
+
loadingIconDescription: PropTypes__default["default"].string,
|
|
174
|
+
/**
|
|
175
|
+
* loading status
|
|
176
|
+
*/
|
|
177
|
+
loadingStatus: PropTypes__default["default"].oneOf(['inactive', 'active', 'finished', 'error']),
|
|
178
|
+
/**
|
|
179
|
+
* Provide an optional handler to be invoked when loading is
|
|
180
|
+
* successful
|
|
181
|
+
*/
|
|
182
|
+
onLoadingSuccess: PropTypes__default["default"].func,
|
|
151
183
|
/**
|
|
152
184
|
* Specify an optional function for when the modal is requesting to be
|
|
153
185
|
* closed
|
|
@@ -73,7 +73,7 @@ const DataTableSkeleton = _ref => {
|
|
|
73
73
|
}, rest), /*#__PURE__*/React__default["default"].createElement("thead", null, /*#__PURE__*/React__default["default"].createElement("tr", null, columnsArray.map(i => /*#__PURE__*/React__default["default"].createElement("th", {
|
|
74
74
|
key: i
|
|
75
75
|
}, headers ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
76
|
-
className: "
|
|
76
|
+
className: "cds--table-header-label"
|
|
77
77
|
}, headers[i]?.header) : _span2 || (_span2 = /*#__PURE__*/React__default["default"].createElement("span", null)))))), /*#__PURE__*/React__default["default"].createElement("tbody", null, rows)));
|
|
78
78
|
};
|
|
79
79
|
DataTableSkeleton.propTypes = {
|
|
@@ -76,6 +76,10 @@ interface DatePickerInputProps extends Omit<ReactAttr<HTMLInputElement>, Exclude
|
|
|
76
76
|
* Specify the size of the Date Picker Input. Currently supports either `sm`, `md`, or `lg` as an option.
|
|
77
77
|
*/
|
|
78
78
|
size?: 'sm' | 'md' | 'lg';
|
|
79
|
+
/**
|
|
80
|
+
* Provide a `Slug` component to be rendered inside the `DatePickerInput` component
|
|
81
|
+
*/
|
|
82
|
+
slug?: ReactNodeLike;
|
|
79
83
|
/**
|
|
80
84
|
* Specify the type of the `<input>`
|
|
81
85
|
*/
|
|
@@ -42,6 +42,7 @@ const DatePickerInput = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
42
42
|
pattern = '\\d{1,2}\\/\\d{1,2}\\/\\d{4}',
|
|
43
43
|
placeholder,
|
|
44
44
|
size = 'md',
|
|
45
|
+
slug,
|
|
45
46
|
type = 'text',
|
|
46
47
|
warn,
|
|
47
48
|
warnText,
|
|
@@ -70,7 +71,8 @@ const DatePickerInput = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
70
71
|
};
|
|
71
72
|
const wrapperClasses = cx__default["default"](`${prefix}--date-picker-input__wrapper`, {
|
|
72
73
|
[`${prefix}--date-picker-input__wrapper--invalid`]: invalid,
|
|
73
|
-
[`${prefix}--date-picker-input__wrapper--warn`]: warn
|
|
74
|
+
[`${prefix}--date-picker-input__wrapper--warn`]: warn,
|
|
75
|
+
[`${prefix}--date-picker-input__wrapper--slug`]: slug
|
|
74
76
|
});
|
|
75
77
|
const labelClasses = cx__default["default"](`${prefix}--label`, {
|
|
76
78
|
[`${prefix}--visually-hidden`]: hideLabel,
|
|
@@ -103,6 +105,14 @@ const DatePickerInput = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
103
105
|
inputProps['data-invalid'] = true;
|
|
104
106
|
}
|
|
105
107
|
const input = /*#__PURE__*/React__default["default"].createElement("input", inputProps);
|
|
108
|
+
|
|
109
|
+
// Slug is always size `mini`
|
|
110
|
+
let normalizedSlug;
|
|
111
|
+
if (slug) {
|
|
112
|
+
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
113
|
+
size: 'mini'
|
|
114
|
+
});
|
|
115
|
+
}
|
|
106
116
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
107
117
|
className: containerClasses
|
|
108
118
|
}, labelText && /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
@@ -111,7 +121,7 @@ const DatePickerInput = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
111
121
|
className: labelClasses
|
|
112
122
|
}, labelText), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
113
123
|
className: wrapperClasses
|
|
114
|
-
}, /*#__PURE__*/React__default["default"].createElement("span", null, input, isFluid && /*#__PURE__*/React__default["default"].createElement(DatePickerIcon, {
|
|
124
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", null, input, normalizedSlug, isFluid && /*#__PURE__*/React__default["default"].createElement(DatePickerIcon, {
|
|
115
125
|
datePickerType: datePickerType
|
|
116
126
|
}), /*#__PURE__*/React__default["default"].createElement(DatePickerIcon, {
|
|
117
127
|
datePickerType: datePickerType,
|
|
@@ -205,6 +215,10 @@ DatePickerInput.propTypes = {
|
|
|
205
215
|
* Specify the size of the Date Picker Input. Currently supports either `sm`, `md`, or `lg` as an option.
|
|
206
216
|
*/
|
|
207
217
|
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg']),
|
|
218
|
+
/**
|
|
219
|
+
* Provide a `Slug` component to be rendered inside the `DatePickerInput` component
|
|
220
|
+
*/
|
|
221
|
+
slug: PropTypes__default["default"].node,
|
|
208
222
|
/**
|
|
209
223
|
* Specify the type of the `<input>`
|
|
210
224
|
*/
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { ReactNode } from 'react';
|
|
8
8
|
import { UseSelectProps } from 'downshift';
|
|
9
|
+
import { ReactNodeLike } from 'prop-types';
|
|
9
10
|
import { ListBoxSize, ListBoxType } from '../ListBox';
|
|
10
11
|
import { ReactAttr } from '../../types/common';
|
|
11
12
|
type ExcludedAttributes = 'id' | 'onChange';
|
|
@@ -110,6 +111,10 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
110
111
|
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
111
112
|
*/
|
|
112
113
|
size?: ListBoxSize;
|
|
114
|
+
/**
|
|
115
|
+
* Provide a `Slug` component to be rendered inside the `Dropdown` component
|
|
116
|
+
*/
|
|
117
|
+
slug?: ReactNodeLike;
|
|
113
118
|
/**
|
|
114
119
|
* Provide the title text that will be read by a screen reader when
|
|
115
120
|
* visiting this control
|
|
@@ -79,6 +79,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
79
79
|
selectedItem: controlledSelectedItem,
|
|
80
80
|
downshiftProps,
|
|
81
81
|
readOnly,
|
|
82
|
+
slug,
|
|
82
83
|
...other
|
|
83
84
|
} = _ref;
|
|
84
85
|
const prefix = usePrefix.usePrefix();
|
|
@@ -169,7 +170,8 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
169
170
|
[`${prefix}--dropdown__wrapper--inline--invalid`]: inline && invalid,
|
|
170
171
|
[`${prefix}--list-box__wrapper--inline--invalid`]: inline && invalid,
|
|
171
172
|
[`${prefix}--list-box__wrapper--fluid--invalid`]: isFluid && invalid,
|
|
172
|
-
[`${prefix}--list-box__wrapper--fluid--focus`]: isFluid && isFocused && !isOpen
|
|
173
|
+
[`${prefix}--list-box__wrapper--fluid--focus`]: isFluid && isFocused && !isOpen,
|
|
174
|
+
[`${prefix}--list-box__wrapper--slug`]: slug
|
|
173
175
|
});
|
|
174
176
|
const helperId = !helperText ? undefined : `dropdown-helper-text-${dropdownInstanceId}`;
|
|
175
177
|
|
|
@@ -233,6 +235,14 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
233
235
|
}
|
|
234
236
|
};
|
|
235
237
|
const menuProps = getMenuProps();
|
|
238
|
+
|
|
239
|
+
// Slug is always size `mini`
|
|
240
|
+
let normalizedSlug;
|
|
241
|
+
if (slug) {
|
|
242
|
+
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
243
|
+
size: 'mini'
|
|
244
|
+
});
|
|
245
|
+
}
|
|
236
246
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
237
247
|
className: wrapperClasses
|
|
238
248
|
}, other), titleText && /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
@@ -271,12 +281,15 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
271
281
|
}, selectedItem ? renderSelectedItem ? renderSelectedItem(selectedItem) : itemToString(selectedItem) : label), /*#__PURE__*/React__default["default"].createElement(index["default"].MenuIcon, {
|
|
272
282
|
isOpen: isOpen,
|
|
273
283
|
translateWithId: translateWithId
|
|
274
|
-
})), /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen && items.map((item, index$1) => {
|
|
284
|
+
})), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen && items.map((item, index$1) => {
|
|
275
285
|
const isObject = item !== null && typeof item === 'object';
|
|
276
286
|
const itemProps = getItemProps({
|
|
277
287
|
item,
|
|
278
288
|
index: index$1
|
|
279
289
|
});
|
|
290
|
+
if (item !== null && typeof item === 'object' && Object.prototype.hasOwnProperty.call(item, 'id')) {
|
|
291
|
+
itemProps.id = item['id'];
|
|
292
|
+
}
|
|
280
293
|
const title = isObject && 'text' in item && itemToElement ? item.text : itemToString(item);
|
|
281
294
|
return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
282
295
|
key: itemProps.id,
|
|
@@ -304,7 +317,7 @@ Dropdown.propTypes = {
|
|
|
304
317
|
*/
|
|
305
318
|
ariaLabel: deprecate["default"](PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'),
|
|
306
319
|
/**
|
|
307
|
-
* Provide a custom className to be applied on the
|
|
320
|
+
* Provide a custom className to be applied on the cds--dropdown node
|
|
308
321
|
*/
|
|
309
322
|
className: PropTypes__default["default"].string,
|
|
310
323
|
/**
|
|
@@ -392,6 +405,10 @@ Dropdown.propTypes = {
|
|
|
392
405
|
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
393
406
|
*/
|
|
394
407
|
size: ListBoxPropTypes.ListBoxSize,
|
|
408
|
+
/**
|
|
409
|
+
* Provide a `Slug` component to be rendered inside the `Dropdown` component
|
|
410
|
+
*/
|
|
411
|
+
slug: PropTypes__default["default"].node,
|
|
395
412
|
/**
|
|
396
413
|
* Provide the title text that will be read by a screen reader when
|
|
397
414
|
* visiting this control
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var InlineLoading = require('./InlineLoading.js');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.InlineLoading = InlineLoading["default"];
|
|
17
|
+
exports["default"] = InlineLoading["default"];
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { AnchorHTMLAttributes, AriaAttributes, ComponentType, HTMLAttributeAnchorTarget } from 'react';
|
|
8
8
|
export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
9
|
+
/**
|
|
10
|
+
* Provide a custom element or component to render the top-level node for the
|
|
11
|
+
* component.
|
|
12
|
+
*/
|
|
13
|
+
as?: string | undefined;
|
|
9
14
|
/**
|
|
10
15
|
* @description Indicates the element that represents the
|
|
11
16
|
* current item within a container or set of related
|