@carbon/react 1.57.0-rc.0 → 1.58.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 +1022 -1028
- package/es/components/Button/Button.js +2 -2
- package/es/components/Checkbox/Checkbox.d.ts +6 -7
- package/es/components/ComboBox/ComboBox.d.ts +4 -5
- package/es/components/ComboBox/ComboBox.js +268 -260
- package/es/components/ComposedModal/ComposedModal.d.ts +1 -2
- package/es/components/ContainedList/ContainedList.d.ts +7 -3
- package/es/components/ContainedList/ContainedList.js +3 -2
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -2
- package/es/components/ContainedList/ContainedListItem/index.d.ts +9 -0
- package/es/components/ContainedList/index.d.ts +11 -0
- package/es/components/ContainedList/index.js +13 -0
- package/es/components/DataTable/TableHeader.d.ts +4 -5
- package/es/components/DataTable/TableSlugRow.d.ts +3 -2
- package/es/components/DataTable/stories/examples/TableToolbarFilter.d.ts +51 -0
- package/es/components/DatePicker/DatePicker.d.ts +9 -9
- package/es/components/DatePicker/plugins/rangePlugin.js +5 -6
- package/es/components/Dialog/index.d.ts +31 -0
- package/es/components/Dropdown/Dropdown.d.ts +5 -6
- package/es/components/IconButton/index.d.ts +3 -4
- package/es/components/ListBox/next/ListBoxTrigger.js +5 -3
- package/es/components/Menu/Menu.js +1 -1
- package/es/components/Menu/MenuItem.js +13 -2
- package/es/components/Modal/Modal.d.ts +8 -9
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +176 -0
- package/es/components/MultiSelect/FilterableMultiSelect.js +388 -313
- package/es/components/MultiSelect/MultiSelect.d.ts +10 -9
- package/es/components/MultiSelect/MultiSelect.js +1 -2
- package/es/components/MultiSelect/MultiSelectPropTypes.d.ts +62 -0
- package/es/components/MultiSelect/index.d.ts +10 -0
- package/es/components/MultiSelect/index.js +2 -0
- package/es/components/Notification/Notification.d.ts +2 -2
- package/es/components/NumberInput/NumberInput.d.ts +1 -2
- package/es/components/Pagination/Pagination.js +9 -9
- package/es/components/PasswordInput/index.d.ts +3 -0
- package/es/components/Popover/index.d.ts +8 -2
- package/es/components/Popover/index.js +26 -1
- package/es/components/RadioButton/RadioButton.d.ts +7 -4
- package/es/components/RadioButton/RadioButton.js +7 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +11 -8
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +7 -1
- package/es/components/Select/Select.d.ts +1 -2
- package/es/components/Slider/Slider.d.ts +5 -5
- package/es/components/Slider/Slider.js +1 -1
- package/es/components/Tag/DismissibleTag.d.ts +3 -3
- package/es/components/Tag/OperationalTag.d.ts +3 -3
- package/es/components/Tag/SelectableTag.d.ts +3 -3
- package/es/components/Tag/Tag.d.ts +3 -3
- package/es/components/TextArea/TextArea.d.ts +6 -7
- package/es/components/TextInput/PasswordInput.d.ts +5 -6
- package/es/components/TextInput/PasswordInput.js +2 -2
- package/es/components/TextInput/TextInput.d.ts +1 -2
- package/es/components/Theme/index.d.ts +1 -0
- package/es/components/Theme/index.js +8 -2
- package/es/components/Tile/Tile.d.ts +3 -4
- package/es/components/TileGroup/TileGroup.d.ts +3 -2
- package/es/components/TileGroup/index.d.ts +9 -0
- package/es/components/TimePicker/TimePicker.js +1 -1
- package/es/components/Toggle/Toggle.js +1 -1
- package/es/components/Tooltip/DefinitionTooltip.js +1 -1
- package/es/index.js +7 -5
- package/es/prop-types/deprecateValuesWithin.js +35 -0
- package/lib/components/Button/Button.js +2 -2
- package/lib/components/Checkbox/Checkbox.d.ts +6 -7
- package/lib/components/ComboBox/ComboBox.d.ts +4 -5
- package/lib/components/ComboBox/ComboBox.js +267 -260
- package/lib/components/ComposedModal/ComposedModal.d.ts +1 -2
- package/lib/components/ContainedList/ContainedList.d.ts +7 -3
- package/lib/components/ContainedList/ContainedList.js +3 -2
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -2
- package/lib/components/ContainedList/ContainedListItem/index.d.ts +9 -0
- package/lib/components/ContainedList/index.d.ts +11 -0
- package/lib/components/ContainedList/index.js +19 -0
- package/lib/components/DataTable/TableHeader.d.ts +4 -5
- package/lib/components/DataTable/TableSlugRow.d.ts +3 -2
- package/lib/components/DataTable/stories/examples/TableToolbarFilter.d.ts +51 -0
- package/lib/components/DatePicker/DatePicker.d.ts +9 -9
- package/lib/components/DatePicker/plugins/rangePlugin.js +5 -6
- package/lib/components/Dialog/index.d.ts +31 -0
- package/lib/components/Dropdown/Dropdown.d.ts +5 -6
- package/lib/components/IconButton/index.d.ts +3 -4
- package/lib/components/ListBox/next/ListBoxTrigger.js +5 -3
- package/lib/components/Menu/Menu.js +1 -1
- package/lib/components/Menu/MenuItem.js +13 -2
- package/lib/components/Modal/Modal.d.ts +8 -9
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +176 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.js +387 -312
- package/lib/components/MultiSelect/MultiSelect.d.ts +10 -9
- package/lib/components/MultiSelect/MultiSelect.js +1 -2
- package/lib/components/MultiSelect/MultiSelectPropTypes.d.ts +62 -0
- package/lib/components/MultiSelect/index.d.ts +10 -0
- package/lib/components/MultiSelect/index.js +2 -0
- package/lib/components/Notification/Notification.d.ts +2 -2
- package/lib/components/NumberInput/NumberInput.d.ts +1 -2
- package/lib/components/Pagination/Pagination.js +9 -9
- package/lib/components/PasswordInput/index.d.ts +3 -0
- package/lib/components/Popover/index.d.ts +8 -2
- package/lib/components/Popover/index.js +26 -1
- package/lib/components/RadioButton/RadioButton.d.ts +7 -4
- package/lib/components/RadioButton/RadioButton.js +7 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +11 -8
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +7 -1
- package/lib/components/Select/Select.d.ts +1 -2
- package/lib/components/Slider/Slider.d.ts +5 -5
- package/lib/components/Slider/Slider.js +1 -1
- package/lib/components/Tag/DismissibleTag.d.ts +3 -3
- package/lib/components/Tag/OperationalTag.d.ts +3 -3
- package/lib/components/Tag/SelectableTag.d.ts +3 -3
- package/lib/components/Tag/Tag.d.ts +3 -3
- package/lib/components/TextArea/TextArea.d.ts +6 -7
- package/lib/components/TextInput/PasswordInput.d.ts +5 -6
- package/lib/components/TextInput/PasswordInput.js +2 -2
- package/lib/components/TextInput/TextInput.d.ts +1 -2
- package/lib/components/Theme/index.d.ts +1 -0
- package/lib/components/Theme/index.js +8 -1
- package/lib/components/Tile/Tile.d.ts +3 -4
- package/lib/components/TileGroup/TileGroup.d.ts +3 -2
- package/lib/components/TileGroup/index.d.ts +9 -0
- package/lib/components/TimePicker/TimePicker.js +1 -1
- package/lib/components/Toggle/Toggle.js +1 -1
- package/lib/components/Tooltip/DefinitionTooltip.js +1 -1
- package/lib/index.js +34 -31
- package/lib/prop-types/deprecateValuesWithin.js +39 -0
- package/package.json +8 -8
- package/es/components/TileGroup/index.js +0 -13
- package/lib/components/TileGroup/index.js +0 -18
|
@@ -16,6 +16,7 @@ var cx = require('classnames');
|
|
|
16
16
|
var index = require('../Layout/index.js');
|
|
17
17
|
var useId = require('../../internal/useId.js');
|
|
18
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
|
+
var ContainedListItem = require('./ContainedListItem/ContainedListItem.js');
|
|
19
20
|
|
|
20
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
22
|
|
|
@@ -140,6 +141,6 @@ ContainedList.propTypes = {
|
|
|
140
141
|
*/
|
|
141
142
|
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg', 'xl'])
|
|
142
143
|
};
|
|
143
|
-
|
|
144
|
+
ContainedList.ContainedListItem = ContainedListItem["default"];
|
|
144
145
|
|
|
145
|
-
exports["default"] = ContainedList
|
|
146
|
+
exports["default"] = ContainedList;
|
|
@@ -86,6 +86,5 @@ ContainedListItem.propTypes = {
|
|
|
86
86
|
// @ts-expect-error: PropTypes are not expressive enough to cover this case
|
|
87
87
|
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object])
|
|
88
88
|
};
|
|
89
|
-
var ContainedListItem$1 = ContainedListItem;
|
|
90
89
|
|
|
91
|
-
exports["default"] = ContainedListItem
|
|
90
|
+
exports["default"] = ContainedListItem;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2022
|
|
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 ContainedListItem from './ContainedListItem';
|
|
8
|
+
export default ContainedListItem;
|
|
9
|
+
export { ContainedListItem };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2022
|
|
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 ContainedList from './ContainedList';
|
|
8
|
+
import ContainedListItem from './ContainedListItem';
|
|
9
|
+
export { ContainedListItem };
|
|
10
|
+
export default ContainedList;
|
|
11
|
+
export { ContainedList };
|
|
@@ -0,0 +1,19 @@
|
|
|
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 ContainedList = require('./ContainedList.js');
|
|
13
|
+
var ContainedListItem = require('./ContainedListItem/ContainedListItem.js');
|
|
14
|
+
|
|
15
|
+
ContainedList["default"].ContainedListItem = ContainedListItem["default"];
|
|
16
|
+
|
|
17
|
+
exports.ContainedList = ContainedList["default"];
|
|
18
|
+
exports["default"] = ContainedList["default"];
|
|
19
|
+
exports.ContainedListItem = ContainedListItem["default"];
|
|
@@ -4,14 +4,13 @@
|
|
|
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, { type MouseEventHandler } from 'react';
|
|
7
|
+
import React, { type MouseEventHandler, ReactNode } from 'react';
|
|
9
8
|
import { sortStates } from './state/sorting';
|
|
10
9
|
import { ReactAttr } from '../../types/common';
|
|
11
10
|
import { DataTableSortState } from './state/sortStates';
|
|
12
11
|
export type TableHeaderTranslationKey = 'carbon.table.header.icon.description';
|
|
13
12
|
export interface TableHeaderTranslationArgs {
|
|
14
|
-
header:
|
|
13
|
+
header: ReactNode;
|
|
15
14
|
isSortHeader?: boolean;
|
|
16
15
|
sortDirection?: DataTableSortState;
|
|
17
16
|
sortStates: typeof sortStates;
|
|
@@ -20,7 +19,7 @@ interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonEl
|
|
|
20
19
|
/**
|
|
21
20
|
* Pass in children that will be embedded in the table header label
|
|
22
21
|
*/
|
|
23
|
-
children?:
|
|
22
|
+
children?: ReactNode;
|
|
24
23
|
/**
|
|
25
24
|
* Specify an optional className to be applied to the container node
|
|
26
25
|
*/
|
|
@@ -56,7 +55,7 @@ interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonEl
|
|
|
56
55
|
/**
|
|
57
56
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `TableSlugRow` component
|
|
58
57
|
*/
|
|
59
|
-
slug?:
|
|
58
|
+
slug?: ReactNode;
|
|
60
59
|
/**
|
|
61
60
|
* Specify which direction we are currently sorting by, should be one of DESC,
|
|
62
61
|
* NONE, or ASC.
|
|
@@ -4,7 +4,8 @@
|
|
|
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 PropTypes
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { ReactNode } from 'react';
|
|
8
9
|
export interface TableSlugRowProps {
|
|
9
10
|
/**
|
|
10
11
|
* The CSS class names of the cell that wraps the underlying input control
|
|
@@ -13,7 +14,7 @@ export interface TableSlugRowProps {
|
|
|
13
14
|
/**
|
|
14
15
|
* Provide a `Slug` component to be rendered inside the `TableSlugRow` component
|
|
15
16
|
*/
|
|
16
|
-
slug?:
|
|
17
|
+
slug?: ReactNode;
|
|
17
18
|
}
|
|
18
19
|
declare const TableSlugRow: {
|
|
19
20
|
({ className, slug }: TableSlugRowProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ChangeEvent } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
export type PopoverAlignment = 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-end' | 'left-start' | 'right-end' | 'right-start';
|
|
4
|
+
interface TableToolbarFilterProps {
|
|
5
|
+
/**
|
|
6
|
+
* Specify how the popover should align with the trigger element
|
|
7
|
+
*/
|
|
8
|
+
align?: PopoverAlignment;
|
|
9
|
+
/**
|
|
10
|
+
* Provide an optional class name for the toolbar filter
|
|
11
|
+
*/
|
|
12
|
+
className?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Provide an optional hook that is called each time the input is updated
|
|
15
|
+
*/
|
|
16
|
+
onChange?: (event: '' | ChangeEvent<HTMLInputElement>, value?: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Provide an function that is called when the apply button is clicked
|
|
19
|
+
*/
|
|
20
|
+
onApplyFilter?: (selectedCheckboxes: Array<string>) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Provide an function that is called when the reset button is clicked
|
|
23
|
+
*/
|
|
24
|
+
onResetFilter?: () => void;
|
|
25
|
+
}
|
|
26
|
+
declare const TableToolbarFilter: {
|
|
27
|
+
({ align, onApplyFilter, onResetFilter, className, ...rest }: TableToolbarFilterProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
propTypes: {
|
|
29
|
+
/**
|
|
30
|
+
* Specify how the popover should align with the trigger element
|
|
31
|
+
*/
|
|
32
|
+
align: PropTypes.Requireable<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Provide an optional class name for the search container
|
|
35
|
+
*/
|
|
36
|
+
className: PropTypes.Requireable<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Provide an function that is called when the apply button is clicked
|
|
39
|
+
*/
|
|
40
|
+
onApplyFilter: PropTypes.Requireable<(...args: any[]) => any>;
|
|
41
|
+
/**
|
|
42
|
+
* Provide an optional hook that is called each time the input is updated
|
|
43
|
+
*/
|
|
44
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
45
|
+
/**
|
|
46
|
+
* Provide an function that is called when the reset button is clicked
|
|
47
|
+
*/
|
|
48
|
+
onResetFilter: PropTypes.Requireable<(...args: any[]) => any>;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export default TableToolbarFilter;
|
|
@@ -4,9 +4,9 @@
|
|
|
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 React, { ReactNode } from 'react';
|
|
9
8
|
import flatpickr from 'flatpickr';
|
|
9
|
+
import { DateLimit, DateOption } from 'flatpickr/dist/types/options';
|
|
10
10
|
export type DatePickerTypes = 'simple' | 'single' | 'range';
|
|
11
11
|
export type CalRef = {
|
|
12
12
|
inline: boolean;
|
|
@@ -33,7 +33,7 @@ interface DatePickerProps {
|
|
|
33
33
|
/**
|
|
34
34
|
* The child nodes.
|
|
35
35
|
*/
|
|
36
|
-
children:
|
|
36
|
+
children: ReactNode | object;
|
|
37
37
|
/**
|
|
38
38
|
* The CSS class names.
|
|
39
39
|
*/
|
|
@@ -57,11 +57,11 @@ interface DatePickerProps {
|
|
|
57
57
|
/**
|
|
58
58
|
* The flatpickr `disable` option that allows a user to disable certain dates.
|
|
59
59
|
*/
|
|
60
|
-
disable?:
|
|
60
|
+
disable?: DateLimit<DateOption>[];
|
|
61
61
|
/**
|
|
62
62
|
* The flatpickr `enable` option that allows a user to enable certain dates.
|
|
63
63
|
*/
|
|
64
|
-
enable?:
|
|
64
|
+
enable?: DateLimit<DateOption>[];
|
|
65
65
|
/**
|
|
66
66
|
* The flatpickr `inline` option.
|
|
67
67
|
*/
|
|
@@ -73,7 +73,7 @@ interface DatePickerProps {
|
|
|
73
73
|
/**
|
|
74
74
|
* Provide the text that is displayed when the control is in error state (Fluid Only)
|
|
75
75
|
*/
|
|
76
|
-
invalidText?:
|
|
76
|
+
invalidText?: ReactNode;
|
|
77
77
|
/**
|
|
78
78
|
* `true` to use the light version.
|
|
79
79
|
*/
|
|
@@ -85,11 +85,11 @@ interface DatePickerProps {
|
|
|
85
85
|
/**
|
|
86
86
|
* The maximum date that a user can pick to.
|
|
87
87
|
*/
|
|
88
|
-
maxDate?:
|
|
88
|
+
maxDate?: DateOption;
|
|
89
89
|
/**
|
|
90
90
|
* The minimum date that a user can start picking from.
|
|
91
91
|
*/
|
|
92
|
-
minDate?:
|
|
92
|
+
minDate?: DateOption;
|
|
93
93
|
/**
|
|
94
94
|
* The `change` event handler.
|
|
95
95
|
*/
|
|
@@ -128,7 +128,7 @@ interface DatePickerProps {
|
|
|
128
128
|
/**
|
|
129
129
|
* Provide the text that is displayed when the control is in warning state (Fluid only)
|
|
130
130
|
*/
|
|
131
|
-
warnText?:
|
|
131
|
+
warnText?: ReactNode;
|
|
132
132
|
}
|
|
133
133
|
declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<HTMLDivElement>>;
|
|
134
134
|
export default DatePicker;
|
|
@@ -35,14 +35,13 @@ var carbonFlatpickrRangePlugin = (config => {
|
|
|
35
35
|
// where Flatpickr's range plugin takes care of fixing the first `<input>`
|
|
36
36
|
if (!triggerChange) {
|
|
37
37
|
const {
|
|
38
|
-
_input:
|
|
38
|
+
_input: inputDates
|
|
39
39
|
} = fp;
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
[inputFrom, inputTo].forEach((input, i) => {
|
|
40
|
+
const inputDatesArray = inputDates.value.split(' ');
|
|
41
|
+
fp.close();
|
|
42
|
+
[inputDatesArray[0], inputDatesArray[2]].forEach((input, i) => {
|
|
44
43
|
if (input) {
|
|
45
|
-
input
|
|
44
|
+
input = !dates[i] ? '' : fp.formatDate(new Date(dates[i]), fp.config.dateFormat);
|
|
46
45
|
}
|
|
47
46
|
});
|
|
48
47
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2014, 2024
|
|
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 'wicg-inert';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { ReactAttr } from '../../types/common';
|
|
10
|
+
export interface DialogProps extends ReactAttr<HTMLDialogElement> {
|
|
11
|
+
/**
|
|
12
|
+
* Provide the contents of the Dialog
|
|
13
|
+
*/
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Specifies whether the dialog is modal or non-modal
|
|
17
|
+
*/
|
|
18
|
+
modal?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Specify a handler for closing Dialog.
|
|
21
|
+
* The handler should care of closing Dialog, e.g. changing `open` prop.
|
|
22
|
+
*/
|
|
23
|
+
onRequestClose?: React.ReactEventHandler<HTMLElement>;
|
|
24
|
+
/**
|
|
25
|
+
* Specify whether the Dialog is currently open
|
|
26
|
+
*/
|
|
27
|
+
open?: boolean;
|
|
28
|
+
}
|
|
29
|
+
declare const Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<unknown>>;
|
|
30
|
+
export { Dialog };
|
|
31
|
+
export default Dialog;
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { ReactNode } from 'react';
|
|
8
8
|
import { UseSelectProps } from 'downshift';
|
|
9
|
-
import { ReactNodeLike } from 'prop-types';
|
|
10
9
|
import { type ListBoxMenuIconTranslationKey, ListBoxSize, ListBoxType } from '../ListBox';
|
|
11
10
|
import { ReactAttr } from '../../types/common';
|
|
12
11
|
type ExcludedAttributes = 'id' | 'onChange';
|
|
@@ -40,7 +39,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
40
39
|
* Provide helper text that is used alongside the control label for
|
|
41
40
|
* additional help
|
|
42
41
|
*/
|
|
43
|
-
helperText?:
|
|
42
|
+
helperText?: ReactNode;
|
|
44
43
|
/**
|
|
45
44
|
* Specify whether the title text should be hidden or not
|
|
46
45
|
*/
|
|
@@ -61,7 +60,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
61
60
|
/**
|
|
62
61
|
* Message which is displayed if the value is invalid.
|
|
63
62
|
*/
|
|
64
|
-
invalidText?:
|
|
63
|
+
invalidText?: ReactNode;
|
|
65
64
|
/**
|
|
66
65
|
* Function to render items as custom components instead of strings.
|
|
67
66
|
* Defaults to null and is overridden by a getter
|
|
@@ -114,12 +113,12 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
114
113
|
/**
|
|
115
114
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `Dropdown` component
|
|
116
115
|
*/
|
|
117
|
-
slug?:
|
|
116
|
+
slug?: ReactNode;
|
|
118
117
|
/**
|
|
119
118
|
* Provide the title text that will be read by a screen reader when
|
|
120
119
|
* visiting this control
|
|
121
120
|
*/
|
|
122
|
-
titleText?:
|
|
121
|
+
titleText?: ReactNode;
|
|
123
122
|
/**
|
|
124
123
|
* Callback function for translating ListBoxMenuIcon SVG title
|
|
125
124
|
*/
|
|
@@ -135,7 +134,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
135
134
|
/**
|
|
136
135
|
* Provide the text that is displayed when the control is in warning state
|
|
137
136
|
*/
|
|
138
|
-
warnText?:
|
|
137
|
+
warnText?: ReactNode;
|
|
139
138
|
}
|
|
140
139
|
export type DropdownTranslationKey = ListBoxMenuIconTranslationKey;
|
|
141
140
|
type DropdownComponentProps<ItemType> = React.PropsWithoutRef<React.PropsWithChildren<DropdownProps<ItemType>> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -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 React, { ReactNode } from 'react';
|
|
9
8
|
import { ButtonSize } from '../Button';
|
|
10
9
|
export declare const IconButtonKinds: readonly ["primary", "secondary", "ghost", "tertiary"];
|
|
11
10
|
export type IconButtonKind = (typeof IconButtonKinds)[number];
|
|
@@ -17,7 +16,7 @@ interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>
|
|
|
17
16
|
/**
|
|
18
17
|
* Provide an icon or asset to be rendered inside of the IconButton
|
|
19
18
|
*/
|
|
20
|
-
children?:
|
|
19
|
+
children?: ReactNode;
|
|
21
20
|
/**
|
|
22
21
|
* Specify an optional className to be added to your Button
|
|
23
22
|
*/
|
|
@@ -52,7 +51,7 @@ interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>
|
|
|
52
51
|
* This means that if you have text in the child node it will not be
|
|
53
52
|
* announced to the screen reader.
|
|
54
53
|
*/
|
|
55
|
-
label:
|
|
54
|
+
label: ReactNode;
|
|
56
55
|
/**
|
|
57
56
|
* Specify the duration in milliseconds to delay before hiding the tooltip
|
|
58
57
|
*/
|
|
@@ -37,7 +37,8 @@ const defaultTranslateWithId = id => defaultTranslations[id];
|
|
|
37
37
|
* `ListBoxTrigger` is used to orient the icon up or down depending on the
|
|
38
38
|
* state of the menu for a given `ListBox`
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
const ListBoxTrigger = /*#__PURE__*/React__default["default"].forwardRef(function ListBoxTrigger(_ref, ref) {
|
|
41
42
|
let {
|
|
42
43
|
isOpen,
|
|
43
44
|
translateWithId: t = defaultTranslateWithId,
|
|
@@ -54,9 +55,10 @@ const ListBoxTrigger = _ref => {
|
|
|
54
55
|
title: description,
|
|
55
56
|
className: className,
|
|
56
57
|
type: "button",
|
|
57
|
-
tabIndex: "-1"
|
|
58
|
+
tabIndex: "-1",
|
|
59
|
+
ref: ref
|
|
58
60
|
}), _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default["default"].createElement(iconsReact.ChevronDown, null)));
|
|
59
|
-
};
|
|
61
|
+
});
|
|
60
62
|
ListBoxTrigger.propTypes = {
|
|
61
63
|
/**
|
|
62
64
|
* Specify whether the menu is currently open, which will influence the
|
|
@@ -140,7 +140,7 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(_ref, forwardRef) {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
function focusItem(e) {
|
|
143
|
-
const currentItem = focusableItems.findIndex(item => item.ref
|
|
143
|
+
const currentItem = focusableItems.findIndex(item => item.ref?.current?.contains(document.activeElement));
|
|
144
144
|
let indexToFocus = currentItem;
|
|
145
145
|
|
|
146
146
|
// if currentItem is -1, no menu item is focused yet.
|
|
@@ -34,6 +34,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
34
34
|
|
|
35
35
|
var _CaretLeft, _CaretRight;
|
|
36
36
|
const hoverIntentDelay = 150; // in ms
|
|
37
|
+
const leaveIntentDelay = 300; // in ms
|
|
37
38
|
|
|
38
39
|
const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(_ref, forwardRef) {
|
|
39
40
|
let {
|
|
@@ -59,6 +60,7 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(_ref, forwardRe
|
|
|
59
60
|
const hasChildren = Boolean(children);
|
|
60
61
|
const [submenuOpen, setSubmenuOpen] = React.useState(false);
|
|
61
62
|
const hoverIntentTimeout = React.useRef(null);
|
|
63
|
+
const leaveIntentTimeout = React.useRef(null);
|
|
62
64
|
const isDisabled = disabled && !hasChildren;
|
|
63
65
|
const isDanger = kind === 'danger' && !hasChildren;
|
|
64
66
|
function registerItem() {
|
|
@@ -113,6 +115,11 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(_ref, forwardRe
|
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
function handleMouseEnter() {
|
|
118
|
+
if (leaveIntentTimeout.current) {
|
|
119
|
+
// When mouse reenters before closing keep sub menu open
|
|
120
|
+
clearTimeout(leaveIntentTimeout.current);
|
|
121
|
+
leaveIntentTimeout.current = null;
|
|
122
|
+
}
|
|
116
123
|
hoverIntentTimeout.current = setTimeout(() => {
|
|
117
124
|
openSubmenu();
|
|
118
125
|
}, hoverIntentDelay);
|
|
@@ -120,8 +127,12 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(_ref, forwardRe
|
|
|
120
127
|
function handleMouseLeave() {
|
|
121
128
|
if (hoverIntentTimeout.current) {
|
|
122
129
|
clearTimeout(hoverIntentTimeout.current);
|
|
123
|
-
|
|
124
|
-
|
|
130
|
+
// Avoid closing the sub menu as soon as mouse leaves
|
|
131
|
+
// prevents accidental closure due to scroll bar
|
|
132
|
+
leaveIntentTimeout.current = setTimeout(() => {
|
|
133
|
+
closeSubmenu();
|
|
134
|
+
menuItem.current?.focus();
|
|
135
|
+
}, leaveIntentDelay);
|
|
125
136
|
}
|
|
126
137
|
}
|
|
127
138
|
function handleKeyDown(e) {
|
|
@@ -4,14 +4,13 @@
|
|
|
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 React, { ReactNode } from 'react';
|
|
9
8
|
import { ReactAttr } from '../../types/common';
|
|
10
9
|
import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
|
|
11
10
|
export declare const ModalSizes: readonly ["xs", "sm", "md", "lg"];
|
|
12
11
|
export type ModalSize = (typeof ModalSizes)[number];
|
|
13
12
|
export interface ModalSecondaryButton {
|
|
14
|
-
buttonText?: string |
|
|
13
|
+
buttonText?: string | ReactNode;
|
|
15
14
|
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
16
15
|
}
|
|
17
16
|
export interface ModalProps extends ReactAttr<HTMLDivElement> {
|
|
@@ -27,7 +26,7 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
|
|
|
27
26
|
/**
|
|
28
27
|
* Provide the contents of your Modal
|
|
29
28
|
*/
|
|
30
|
-
children?:
|
|
29
|
+
children?: ReactNode;
|
|
31
30
|
/**
|
|
32
31
|
* Specify an optional className to be applied to the modal root node
|
|
33
32
|
*/
|
|
@@ -75,11 +74,11 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
|
|
|
75
74
|
/**
|
|
76
75
|
* Specify the content of the modal header title.
|
|
77
76
|
*/
|
|
78
|
-
modalHeading?:
|
|
77
|
+
modalHeading?: ReactNode;
|
|
79
78
|
/**
|
|
80
79
|
* Specify the content of the modal header label.
|
|
81
80
|
*/
|
|
82
|
-
modalLabel?:
|
|
81
|
+
modalLabel?: ReactNode;
|
|
83
82
|
/**
|
|
84
83
|
* Specify a handler for keypresses.
|
|
85
84
|
* @deprecated this property is unused
|
|
@@ -124,11 +123,11 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
|
|
|
124
123
|
/**
|
|
125
124
|
* Specify the text for the primary button
|
|
126
125
|
*/
|
|
127
|
-
primaryButtonText?:
|
|
126
|
+
primaryButtonText?: ReactNode;
|
|
128
127
|
/**
|
|
129
128
|
* Specify the text for the secondary button
|
|
130
129
|
*/
|
|
131
|
-
secondaryButtonText?:
|
|
130
|
+
secondaryButtonText?: ReactNode;
|
|
132
131
|
/**
|
|
133
132
|
* Specify an array of config objects for secondary buttons
|
|
134
133
|
*/
|
|
@@ -154,7 +153,7 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
|
|
|
154
153
|
/**
|
|
155
154
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `Modal` component
|
|
156
155
|
*/
|
|
157
|
-
slug?:
|
|
156
|
+
slug?: ReactNode;
|
|
158
157
|
}
|
|
159
158
|
declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLDivElement>>;
|
|
160
159
|
export default Modal;
|