@carbon/react 1.56.0 → 1.57.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 +902 -908
- package/es/components/ComboBox/ComboBox.js +1 -0
- package/es/components/ContainedList/ContainedList.d.ts +45 -0
- package/es/components/ContainedList/ContainedList.js +18 -3
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +35 -0
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +3 -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/TableToolbarSearch.js +1 -1
- package/es/components/DataTable/stories/examples/TableToolbarFilter.d.ts +51 -0
- package/es/components/DatePicker/DatePicker.d.ts +5 -4
- package/es/components/DatePicker/plugins/rangePlugin.js +5 -6
- package/es/components/Dialog/index.d.ts +31 -0
- package/es/components/ListBox/next/ListBoxTrigger.js +4 -3
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +177 -0
- package/es/components/MultiSelect/FilterableMultiSelect.js +388 -313
- 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/OverflowMenu/OverflowMenu.d.ts +300 -0
- package/es/components/OverflowMenu/OverflowMenu.js +22 -14
- package/es/components/OverflowMenu/next/index.d.ts +39 -0
- package/es/components/OverflowMenu/next/index.js +4 -3
- package/es/components/Pagination/Pagination.js +9 -9
- package/es/components/RadioButton/RadioButton.d.ts +4 -0
- package/es/components/RadioButton/RadioButton.js +7 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +4 -0
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +7 -1
- package/es/components/RadioTile/RadioTile.d.ts +4 -0
- package/es/components/RadioTile/RadioTile.js +7 -1
- package/es/components/Slider/Slider.js +3 -3
- package/es/components/StructuredList/StructuredList.js +6 -2
- package/es/components/TileGroup/TileGroup.d.ts +8 -0
- package/es/components/TileGroup/TileGroup.js +7 -1
- package/es/components/TimePicker/TimePicker.js +1 -1
- package/es/index.js +2 -0
- package/es/internal/Selection.js +4 -1
- package/lib/components/ComboBox/ComboBox.js +1 -0
- package/lib/components/ContainedList/ContainedList.d.ts +45 -0
- package/lib/components/ContainedList/ContainedList.js +18 -3
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +35 -0
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +3 -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/TableToolbarSearch.js +1 -1
- package/lib/components/DataTable/stories/examples/TableToolbarFilter.d.ts +51 -0
- package/lib/components/DatePicker/DatePicker.d.ts +5 -4
- package/lib/components/DatePicker/plugins/rangePlugin.js +5 -6
- package/lib/components/Dialog/index.d.ts +31 -0
- package/lib/components/ListBox/next/ListBoxTrigger.js +4 -3
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +177 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.js +387 -312
- 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/OverflowMenu/OverflowMenu.d.ts +300 -0
- package/lib/components/OverflowMenu/OverflowMenu.js +21 -13
- package/lib/components/OverflowMenu/next/index.d.ts +39 -0
- package/lib/components/OverflowMenu/next/index.js +4 -3
- package/lib/components/Pagination/Pagination.js +9 -9
- package/lib/components/RadioButton/RadioButton.d.ts +4 -0
- package/lib/components/RadioButton/RadioButton.js +7 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +4 -0
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +7 -1
- package/lib/components/RadioTile/RadioTile.d.ts +4 -0
- package/lib/components/RadioTile/RadioTile.js +7 -1
- package/lib/components/Slider/Slider.js +3 -3
- package/lib/components/StructuredList/StructuredList.js +6 -2
- package/lib/components/TileGroup/TileGroup.d.ts +8 -0
- package/lib/components/TileGroup/TileGroup.js +7 -1
- package/lib/components/TimePicker/TimePicker.js +1 -1
- package/lib/index.js +2 -0
- package/lib/internal/Selection.js +4 -1
- package/package.json +8 -8
- package/telemetry.yml +1 -1
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
export declare const sortingPropTypes: {
|
|
9
|
+
/**
|
|
10
|
+
* Provide a compare function that is used to determine the ordering of
|
|
11
|
+
* options. `compareItems` has the following function signature:
|
|
12
|
+
*
|
|
13
|
+
* compareFunction :
|
|
14
|
+
* (itemA: string, itemB: string, { locale: string }) => number
|
|
15
|
+
*/
|
|
16
|
+
compareItems: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
|
+
/**
|
|
18
|
+
* Provide a method that sorts all options in the control. Overriding this
|
|
19
|
+
* prop means that you also have to handle the sort logic for selected versus
|
|
20
|
+
* un-selected items. If you just want to control ordering, consider the
|
|
21
|
+
* `compareItems` prop instead.
|
|
22
|
+
*
|
|
23
|
+
* `sortItems` has the following signature:
|
|
24
|
+
*
|
|
25
|
+
* sortItems :
|
|
26
|
+
* (items: Array<Item>, {
|
|
27
|
+
* selectedItems: Array<Item>,
|
|
28
|
+
* itemToString: Item => string,
|
|
29
|
+
* compareItems: (itemA: string, itemB: string, {
|
|
30
|
+
* locale: string
|
|
31
|
+
* }) => number,
|
|
32
|
+
* locale: string,
|
|
33
|
+
* }) => Array<Item>
|
|
34
|
+
*/
|
|
35
|
+
sortItems: PropTypes.Requireable<(...args: any[]) => any>;
|
|
36
|
+
};
|
|
37
|
+
export interface ItemBase {
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface SortingPropTypes<Item extends ItemBase> {
|
|
41
|
+
/**
|
|
42
|
+
* Provide a compare function that is used
|
|
43
|
+
* to determine the ordering of options.
|
|
44
|
+
*/
|
|
45
|
+
compareItems(itemA: string, itemB: string, ctx: {
|
|
46
|
+
locale: string;
|
|
47
|
+
}): number;
|
|
48
|
+
/**
|
|
49
|
+
* Provide a method that sorts all options in the control. Overriding this
|
|
50
|
+
* prop means that you also have to handle the sort logic for selected versus
|
|
51
|
+
* un-selected items. If you just want to control ordering, consider the
|
|
52
|
+
* `compareItems` prop instead.
|
|
53
|
+
*/
|
|
54
|
+
sortItems(items: Item[], state: {
|
|
55
|
+
selectedItems: Item[];
|
|
56
|
+
itemToString(item: Item): string;
|
|
57
|
+
compareItems(itemA: string, itemB: string, ctx: {
|
|
58
|
+
locale: string;
|
|
59
|
+
}): number;
|
|
60
|
+
locale: string;
|
|
61
|
+
}): Item[];
|
|
62
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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 MultiSelect from './MultiSelect';
|
|
8
|
+
import { default as FilterableMultiSelect } from './FilterableMultiSelect';
|
|
9
|
+
export { FilterableMultiSelect, MultiSelect };
|
|
10
|
+
export default MultiSelect;
|
|
@@ -14,6 +14,8 @@ var MultiSelect = require('./MultiSelect.js');
|
|
|
14
14
|
var FilterableMultiSelect = require('./FilterableMultiSelect.js');
|
|
15
15
|
|
|
16
16
|
FilterableMultiSelect["default"].displayName = 'MultiSelect.Filterable';
|
|
17
|
+
// @ts-expect-error: The attribute indeed does not exist on the object,
|
|
18
|
+
// but since it is already deprecated, we do not have to fix it.
|
|
17
19
|
MultiSelect["default"].Filterable = FilterableMultiSelect["default"];
|
|
18
20
|
if (process.env.NODE_ENV !== "production") {
|
|
19
21
|
deprecateFieldOnObject.deprecateFieldOnObject(MultiSelect["default"], 'Filterable', FilterableMultiSelect["default"]);
|
|
@@ -0,0 +1,300 @@
|
|
|
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 React from 'react';
|
|
9
|
+
/**
|
|
10
|
+
* @param {Element} menuBody The menu body with the menu arrow.
|
|
11
|
+
* @param {string} direction The floating menu direction.
|
|
12
|
+
* @returns {FloatingMenu~offset} The adjustment of the floating menu position, upon the position of the menu arrow.
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
export declare const getMenuOffset: (menuBody: any, direction: any, trigger: any, flip: any) => {
|
|
16
|
+
left: number;
|
|
17
|
+
top: number;
|
|
18
|
+
} | undefined;
|
|
19
|
+
interface Offset {
|
|
20
|
+
top: number;
|
|
21
|
+
left: number;
|
|
22
|
+
}
|
|
23
|
+
interface OverflowMenuProps {
|
|
24
|
+
/**
|
|
25
|
+
* Specify a label to be read by screen readers on the container node
|
|
26
|
+
*/
|
|
27
|
+
['aria-label']: string;
|
|
28
|
+
/**
|
|
29
|
+
* Deprecated, please use `aria-label` instead.
|
|
30
|
+
* Specify a label to be read by screen readers on the container note.
|
|
31
|
+
* @deprecated
|
|
32
|
+
* */
|
|
33
|
+
ariaLabel: string;
|
|
34
|
+
/**
|
|
35
|
+
* The child nodes.
|
|
36
|
+
* */
|
|
37
|
+
children: React.ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* The CSS class names.
|
|
40
|
+
* */
|
|
41
|
+
className?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The menu direction.
|
|
44
|
+
*/
|
|
45
|
+
direction?: string;
|
|
46
|
+
/**
|
|
47
|
+
* `true` if the menu alignment should be flipped.
|
|
48
|
+
*/
|
|
49
|
+
flipped?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Enable or disable focus trap behavior
|
|
52
|
+
*/
|
|
53
|
+
focusTrap?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The CSS class for the icon.
|
|
56
|
+
*/
|
|
57
|
+
iconClass?: string;
|
|
58
|
+
/**
|
|
59
|
+
* The element ID.
|
|
60
|
+
*/
|
|
61
|
+
id?: string;
|
|
62
|
+
/**
|
|
63
|
+
* The icon description.
|
|
64
|
+
*/
|
|
65
|
+
iconDescription?: string;
|
|
66
|
+
/**
|
|
67
|
+
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
68
|
+
* Don't use this to make OverflowMenu background color same as container background color.
|
|
69
|
+
*/
|
|
70
|
+
light?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The adjustment in position applied to the floating menu.
|
|
73
|
+
*/
|
|
74
|
+
menuOffset?: Offset | (() => void);
|
|
75
|
+
/**
|
|
76
|
+
* The adjustment in position applied to the floating menu.
|
|
77
|
+
*/
|
|
78
|
+
menuOffsetFlip?: Offset | (() => void);
|
|
79
|
+
/**
|
|
80
|
+
* The class to apply to the menu options
|
|
81
|
+
*/
|
|
82
|
+
menuOptionsClass?: string;
|
|
83
|
+
/**
|
|
84
|
+
* The event handler for the `click` event.
|
|
85
|
+
*/
|
|
86
|
+
onClick?: (evt?: any) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Function called when menu is closed
|
|
89
|
+
*/
|
|
90
|
+
onClose?: () => void;
|
|
91
|
+
/**
|
|
92
|
+
* Function called when menu is opened
|
|
93
|
+
*/
|
|
94
|
+
onOpen?: () => void;
|
|
95
|
+
/**
|
|
96
|
+
* `true` if the menu should be open.
|
|
97
|
+
*/
|
|
98
|
+
open?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Function called to override icon rendering.
|
|
101
|
+
*/
|
|
102
|
+
renderIcon?: React.ElementType;
|
|
103
|
+
/**
|
|
104
|
+
* Specify a CSS selector that matches the DOM element that should
|
|
105
|
+
* be focused when the OverflowMenu opens
|
|
106
|
+
*/
|
|
107
|
+
selectorPrimaryFocus?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Specify the size of the OverflowMenu. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
|
|
110
|
+
*/
|
|
111
|
+
size?: 'sm' | 'md' | 'lg';
|
|
112
|
+
/**
|
|
113
|
+
* The ref to the HTML element that should receive focus when the OverflowMenu opens
|
|
114
|
+
*/
|
|
115
|
+
innerRef?: React.Ref<any>;
|
|
116
|
+
}
|
|
117
|
+
interface OverflowMenuState {
|
|
118
|
+
open: boolean;
|
|
119
|
+
prevOpen?: boolean;
|
|
120
|
+
hasMountedTrigger: boolean;
|
|
121
|
+
click: boolean;
|
|
122
|
+
}
|
|
123
|
+
interface ReleaseHandle {
|
|
124
|
+
release: () => null;
|
|
125
|
+
}
|
|
126
|
+
declare class OverflowMenu extends React.Component<OverflowMenuProps, OverflowMenuState> {
|
|
127
|
+
state: OverflowMenuState;
|
|
128
|
+
instanceId: number;
|
|
129
|
+
static propTypes: {
|
|
130
|
+
/**
|
|
131
|
+
* Specify a label to be read by screen readers on the container node
|
|
132
|
+
*/
|
|
133
|
+
"aria-label": PropTypes.Requireable<string>;
|
|
134
|
+
/**
|
|
135
|
+
* Deprecated, please use `aria-label` instead.
|
|
136
|
+
* Specify a label to be read by screen readers on the container note.
|
|
137
|
+
*/
|
|
138
|
+
ariaLabel: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
139
|
+
/**
|
|
140
|
+
* The child nodes.
|
|
141
|
+
*/
|
|
142
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
143
|
+
/**
|
|
144
|
+
* The CSS class names.
|
|
145
|
+
*/
|
|
146
|
+
className: PropTypes.Requireable<string>;
|
|
147
|
+
/**
|
|
148
|
+
* The menu direction.
|
|
149
|
+
*/
|
|
150
|
+
direction: PropTypes.Requireable<string>;
|
|
151
|
+
/**
|
|
152
|
+
* `true` if the menu alignment should be flipped.
|
|
153
|
+
*/
|
|
154
|
+
flipped: PropTypes.Requireable<boolean>;
|
|
155
|
+
/**
|
|
156
|
+
* Enable or disable focus trap behavior
|
|
157
|
+
*/
|
|
158
|
+
focusTrap: PropTypes.Requireable<boolean>;
|
|
159
|
+
/**
|
|
160
|
+
* The CSS class for the icon.
|
|
161
|
+
*/
|
|
162
|
+
iconClass: PropTypes.Requireable<string>;
|
|
163
|
+
/**
|
|
164
|
+
* The icon description.
|
|
165
|
+
*/
|
|
166
|
+
iconDescription: PropTypes.Requireable<string>;
|
|
167
|
+
/**
|
|
168
|
+
* The element ID.
|
|
169
|
+
*/
|
|
170
|
+
id: PropTypes.Requireable<string>;
|
|
171
|
+
/**
|
|
172
|
+
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
173
|
+
* Don't use this to make OverflowMenu background color same as container background color.
|
|
174
|
+
*/
|
|
175
|
+
light: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
176
|
+
/**
|
|
177
|
+
* The adjustment in position applied to the floating menu.
|
|
178
|
+
*/
|
|
179
|
+
menuOffset: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.InferProps<{
|
|
180
|
+
top: PropTypes.Requireable<number>;
|
|
181
|
+
left: PropTypes.Requireable<number>;
|
|
182
|
+
}> | null | undefined>>;
|
|
183
|
+
/**
|
|
184
|
+
* The adjustment in position applied to the floating menu.
|
|
185
|
+
*/
|
|
186
|
+
menuOffsetFlip: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.InferProps<{
|
|
187
|
+
top: PropTypes.Requireable<number>;
|
|
188
|
+
left: PropTypes.Requireable<number>;
|
|
189
|
+
}> | null | undefined>>;
|
|
190
|
+
/**
|
|
191
|
+
* The class to apply to the menu options
|
|
192
|
+
*/
|
|
193
|
+
menuOptionsClass: PropTypes.Requireable<string>;
|
|
194
|
+
/**
|
|
195
|
+
* The event handler for the `click` event.
|
|
196
|
+
*/
|
|
197
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
198
|
+
/**
|
|
199
|
+
* Function called when menu is closed
|
|
200
|
+
*/
|
|
201
|
+
onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
202
|
+
/**
|
|
203
|
+
* The event handler for the `focus` event.
|
|
204
|
+
*/
|
|
205
|
+
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
206
|
+
/**
|
|
207
|
+
* The event handler for the `keydown` event.
|
|
208
|
+
*/
|
|
209
|
+
onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
210
|
+
/**
|
|
211
|
+
* Function called when menu is opened
|
|
212
|
+
*/
|
|
213
|
+
onOpen: PropTypes.Requireable<(...args: any[]) => any>;
|
|
214
|
+
/**
|
|
215
|
+
* `true` if the menu should be open.
|
|
216
|
+
*/
|
|
217
|
+
open: PropTypes.Requireable<boolean>;
|
|
218
|
+
/**
|
|
219
|
+
* Function called to override icon rendering.
|
|
220
|
+
*/
|
|
221
|
+
renderIcon: PropTypes.Requireable<object>;
|
|
222
|
+
/**
|
|
223
|
+
* Specify a CSS selector that matches the DOM element that should
|
|
224
|
+
* be focused when the OverflowMenu opens
|
|
225
|
+
*/
|
|
226
|
+
selectorPrimaryFocus: PropTypes.Requireable<string>;
|
|
227
|
+
/**
|
|
228
|
+
* Specify the size of the OverflowMenu. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
|
|
229
|
+
*/
|
|
230
|
+
size: PropTypes.Requireable<string>;
|
|
231
|
+
};
|
|
232
|
+
static contextType: React.Context<string>;
|
|
233
|
+
/**
|
|
234
|
+
* The handle of `onfocusin` or `focus` event handler.
|
|
235
|
+
* @private
|
|
236
|
+
*/
|
|
237
|
+
_hFocusIn: ReleaseHandle | null;
|
|
238
|
+
/**
|
|
239
|
+
* The timeout handle for handling `blur` event.
|
|
240
|
+
* @private
|
|
241
|
+
*/
|
|
242
|
+
_hBlurTimeout: any;
|
|
243
|
+
/**
|
|
244
|
+
* The element ref of the tooltip's trigger button.
|
|
245
|
+
* @type {React.RefObject<Element>}
|
|
246
|
+
* @private
|
|
247
|
+
*/
|
|
248
|
+
_triggerRef: React.RefObject<unknown>;
|
|
249
|
+
componentDidUpdate(_: any, prevState: any): void;
|
|
250
|
+
componentDidMount(): void;
|
|
251
|
+
static getDerivedStateFromProps({ open }: {
|
|
252
|
+
open: any;
|
|
253
|
+
}, state: any): {
|
|
254
|
+
open: any;
|
|
255
|
+
prevOpen: any;
|
|
256
|
+
} | null;
|
|
257
|
+
componentWillUnmount(): void;
|
|
258
|
+
handleClick: (evt: any) => void;
|
|
259
|
+
closeMenuAndFocus: () => void;
|
|
260
|
+
closeMenuOnEscape: () => void;
|
|
261
|
+
handleKeyPress: (evt: any) => void;
|
|
262
|
+
handleClickOutside: (evt: any) => void;
|
|
263
|
+
closeMenu: (onCloseMenu?: any) => void;
|
|
264
|
+
focusMenuEl: () => void;
|
|
265
|
+
/**
|
|
266
|
+
* Focuses the next enabled overflow menu item given the currently focused
|
|
267
|
+
* item index and direction to move
|
|
268
|
+
* @param {object} params
|
|
269
|
+
* @param {number} params.currentIndex - the index of the currently focused
|
|
270
|
+
* overflow menu item in the list of overflow menu items
|
|
271
|
+
* @param {number} params.direction - number denoting the direction to move
|
|
272
|
+
* focus (1 for forwards, -1 for backwards)
|
|
273
|
+
*/
|
|
274
|
+
handleOverflowMenuItemFocus: ({ currentIndex, direction }: {
|
|
275
|
+
currentIndex: any;
|
|
276
|
+
direction: any;
|
|
277
|
+
}) => void;
|
|
278
|
+
/**
|
|
279
|
+
* Handles the floating menu being unmounted or non-floating menu being
|
|
280
|
+
* mounted or unmounted.
|
|
281
|
+
* @param {Element} menuBody The DOM element of the menu body.
|
|
282
|
+
* @private
|
|
283
|
+
*/
|
|
284
|
+
_menuBody: HTMLElement | null;
|
|
285
|
+
_bindMenuBody: (menuBody: HTMLElement | null) => void;
|
|
286
|
+
/**
|
|
287
|
+
* Handles the floating menu being placed.
|
|
288
|
+
* @param {Element} menuBody The DOM element of the menu body.
|
|
289
|
+
* @private
|
|
290
|
+
*/
|
|
291
|
+
_handlePlace: (menuBody: any) => void;
|
|
292
|
+
/**
|
|
293
|
+
* @returns {Element} The DOM element where the floating menu is placed in.
|
|
294
|
+
*/
|
|
295
|
+
_getTarget: () => Element;
|
|
296
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
297
|
+
}
|
|
298
|
+
export { OverflowMenu };
|
|
299
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<unknown>>;
|
|
300
|
+
export default _default;
|
|
@@ -104,10 +104,16 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
|
-
class OverflowMenu extends
|
|
107
|
+
class OverflowMenu extends React__default["default"].Component {
|
|
108
108
|
constructor() {
|
|
109
109
|
super(...arguments);
|
|
110
|
-
_rollupPluginBabelHelpers.defineProperty(this, "state", {
|
|
110
|
+
_rollupPluginBabelHelpers.defineProperty(this, "state", {
|
|
111
|
+
open: false,
|
|
112
|
+
// Set a default value for 'open'
|
|
113
|
+
hasMountedTrigger: false,
|
|
114
|
+
// Set a default value for 'hasMountedTrigger'
|
|
115
|
+
click: false // Set a default value for 'click'
|
|
116
|
+
});
|
|
111
117
|
_rollupPluginBabelHelpers.defineProperty(this, "instanceId", getInstanceId());
|
|
112
118
|
/**
|
|
113
119
|
* The handle of `onfocusin` or `focus` event handler.
|
|
@@ -141,8 +147,8 @@ class OverflowMenu extends React.Component {
|
|
|
141
147
|
}
|
|
142
148
|
});
|
|
143
149
|
_rollupPluginBabelHelpers.defineProperty(this, "closeMenuAndFocus", () => {
|
|
144
|
-
|
|
145
|
-
|
|
150
|
+
const wasClicked = this.state.click;
|
|
151
|
+
const wasOpen = this.state.open;
|
|
146
152
|
this.closeMenu(() => {
|
|
147
153
|
if (wasOpen && !wasClicked) {
|
|
148
154
|
this.focusMenuEl();
|
|
@@ -150,7 +156,7 @@ class OverflowMenu extends React.Component {
|
|
|
150
156
|
});
|
|
151
157
|
});
|
|
152
158
|
_rollupPluginBabelHelpers.defineProperty(this, "closeMenuOnEscape", () => {
|
|
153
|
-
|
|
159
|
+
const wasOpen = this.state.open;
|
|
154
160
|
this.closeMenu(() => {
|
|
155
161
|
if (wasOpen) {
|
|
156
162
|
this.focusMenuEl();
|
|
@@ -212,7 +218,7 @@ class OverflowMenu extends React.Component {
|
|
|
212
218
|
direction
|
|
213
219
|
} = _ref;
|
|
214
220
|
const enabledIndices = React__default["default"].Children.toArray(this.props.children).reduce((acc, curr, i) => {
|
|
215
|
-
if (!curr.props.disabled) {
|
|
221
|
+
if ( /*#__PURE__*/React__default["default"].isValidElement(curr) && !curr.props.disabled) {
|
|
216
222
|
acc.push(i);
|
|
217
223
|
}
|
|
218
224
|
return acc;
|
|
@@ -237,6 +243,7 @@ class OverflowMenu extends React.Component {
|
|
|
237
243
|
* @param {Element} menuBody The DOM element of the menu body.
|
|
238
244
|
* @private
|
|
239
245
|
*/
|
|
246
|
+
_rollupPluginBabelHelpers.defineProperty(this, "_menuBody", null);
|
|
240
247
|
_rollupPluginBabelHelpers.defineProperty(this, "_bindMenuBody", menuBody => {
|
|
241
248
|
if (!menuBody) {
|
|
242
249
|
this._menuBody = menuBody;
|
|
@@ -279,7 +286,7 @@ class OverflowMenu extends React.Component {
|
|
|
279
286
|
const {
|
|
280
287
|
current: triggerEl
|
|
281
288
|
} = this._triggerRef;
|
|
282
|
-
return triggerEl && triggerEl.closest('[data-floating-menu-container]') || document.body;
|
|
289
|
+
return triggerEl instanceof Element && triggerEl.closest('[data-floating-menu-container]') || document.body;
|
|
283
290
|
});
|
|
284
291
|
}
|
|
285
292
|
componentDidUpdate(_, prevState) {
|
|
@@ -360,18 +367,19 @@ class OverflowMenu extends React.Component {
|
|
|
360
367
|
[`${prefix}--overflow-menu-options--${size}`]: size
|
|
361
368
|
});
|
|
362
369
|
const overflowMenuIconClasses = cx__default["default"](`${prefix}--overflow-menu__icon`, iconClass);
|
|
363
|
-
const childrenWithProps = React__default["default"].Children.toArray(children).map((child, index) => /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
364
|
-
|
|
370
|
+
const childrenWithProps = React__default["default"].Children.toArray(children).map((child, index) => /*#__PURE__*/React__default["default"].isValidElement(child) ? /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
371
|
+
// @ts-expect-error: PropTypes are not expressive enough to cover this case
|
|
372
|
+
closeMenu: child.props.closeMenu || this.closeMenuAndFocus,
|
|
365
373
|
handleOverflowMenuItemFocus: this.handleOverflowMenuItemFocus,
|
|
366
374
|
ref: e => {
|
|
367
375
|
this[`overflowMenuItem${index}`] = e;
|
|
368
376
|
},
|
|
369
377
|
index
|
|
370
|
-
}));
|
|
378
|
+
}) : null);
|
|
371
379
|
const menuBodyId = `overflow-menu-${this.instanceId}__menu-body`;
|
|
372
380
|
const menuBody = /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
373
381
|
className: overflowMenuOptionsClasses,
|
|
374
|
-
tabIndex:
|
|
382
|
+
tabIndex: -1,
|
|
375
383
|
role: "menu",
|
|
376
384
|
"aria-label": ariaLabel || deprecatedAriaLabel,
|
|
377
385
|
onKeyDown: this.handleKeyPress,
|
|
@@ -398,12 +406,12 @@ class OverflowMenu extends React.Component {
|
|
|
398
406
|
onClickOutside: this.handleClickOutside
|
|
399
407
|
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
400
408
|
className: `${prefix}--overflow-menu__wrapper`,
|
|
401
|
-
"aria-owns": open ? menuBodyId :
|
|
409
|
+
"aria-owns": open ? menuBodyId : undefined
|
|
402
410
|
}, /*#__PURE__*/React__default["default"].createElement(index.IconButton, _rollupPluginBabelHelpers["extends"]({}, other, {
|
|
403
411
|
type: "button",
|
|
404
412
|
"aria-haspopup": true,
|
|
405
413
|
"aria-expanded": open,
|
|
406
|
-
"aria-controls": open ? menuBodyId :
|
|
414
|
+
"aria-controls": open ? menuBodyId : undefined,
|
|
407
415
|
className: overflowMenuClasses,
|
|
408
416
|
onClick: this.handleClick,
|
|
409
417
|
id: id,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2020, 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 React, { type ComponentType, type FunctionComponent } from 'react';
|
|
8
|
+
interface OverflowMenuProps {
|
|
9
|
+
/**
|
|
10
|
+
* A collection of MenuItems to be rendered within this OverflowMenu.
|
|
11
|
+
*/
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Additional CSS class names for the trigger button.
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* A label describing the options available. Is used in the trigger tooltip and as the menu's accessible label.
|
|
19
|
+
*/
|
|
20
|
+
label?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Experimental property. Specify how the menu should align with the button element
|
|
23
|
+
*/
|
|
24
|
+
menuAlignment?: 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';
|
|
25
|
+
/**
|
|
26
|
+
* Optionally provide a custom icon to be rendered on the trigger button.
|
|
27
|
+
*/
|
|
28
|
+
renderIcon?: ComponentType | FunctionComponent;
|
|
29
|
+
/**
|
|
30
|
+
* Specify the size of the menu, from a list of available sizes.
|
|
31
|
+
*/
|
|
32
|
+
size?: 'sm' | 'md' | 'lg';
|
|
33
|
+
/**
|
|
34
|
+
* Specify how the trigger tooltip should be aligned.
|
|
35
|
+
*/
|
|
36
|
+
tooltipAlignment?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
|
|
37
|
+
}
|
|
38
|
+
declare const OverflowMenu: React.ForwardRefExoticComponent<OverflowMenuProps & React.RefAttributes<HTMLDivElement>>;
|
|
39
|
+
export { OverflowMenu };
|
|
@@ -62,10 +62,10 @@ const OverflowMenu = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
62
62
|
}, size !== defaultSize && `${prefix}--overflow-menu--${size}`);
|
|
63
63
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
64
64
|
className: containerClasses,
|
|
65
|
-
"aria-owns": open ? id :
|
|
65
|
+
"aria-owns": open ? id : undefined,
|
|
66
66
|
ref: forwardRef
|
|
67
67
|
}), /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
|
|
68
|
-
"aria-controls": open ? id :
|
|
68
|
+
"aria-controls": open ? id : undefined,
|
|
69
69
|
"aria-haspopup": true,
|
|
70
70
|
"aria-expanded": open,
|
|
71
71
|
className: triggerClasses,
|
|
@@ -107,8 +107,9 @@ OverflowMenu.propTypes = {
|
|
|
107
107
|
*/
|
|
108
108
|
menuAlignment: PropTypes__default["default"].oneOf(['top-start', 'top-end', 'bottom-start', 'bottom-end']),
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
110
|
+
* Optionally provide a custom icon to be rendered on the trigger button.
|
|
111
111
|
*/
|
|
112
|
+
// @ts-expect-error: PropTypes are not expressive enough to cover this case
|
|
112
113
|
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
|
|
113
114
|
/**
|
|
114
115
|
* Specify the size of the menu, from a list of available sizes.
|
|
@@ -78,10 +78,10 @@ const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pa
|
|
|
78
78
|
pageSize: controlledPageSize,
|
|
79
79
|
pageSizeInputDisabled,
|
|
80
80
|
pageSizes: controlledPageSizes,
|
|
81
|
-
pageText =
|
|
81
|
+
pageText = page => `page ${page}`,
|
|
82
82
|
pagesUnknown = false,
|
|
83
83
|
size = 'md',
|
|
84
|
-
totalItems
|
|
84
|
+
totalItems,
|
|
85
85
|
...rest
|
|
86
86
|
} = _ref;
|
|
87
87
|
const prefix = usePrefix.usePrefix();
|
|
@@ -103,7 +103,7 @@ const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pa
|
|
|
103
103
|
[`${prefix}--pagination--${size}`]: size,
|
|
104
104
|
[customClassName]: !!customClassName
|
|
105
105
|
});
|
|
106
|
-
const totalPages = Math.max(Math.ceil(totalItems / pageSize), 1);
|
|
106
|
+
const totalPages = totalItems ? Math.max(Math.ceil(totalItems / pageSize), 1) : NaN;
|
|
107
107
|
const backButtonDisabled = disabled || page === 1;
|
|
108
108
|
const backButtonClasses = cx__default["default"]({
|
|
109
109
|
[`${prefix}--pagination__button`]: true,
|
|
@@ -155,7 +155,7 @@ const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pa
|
|
|
155
155
|
}
|
|
156
156
|
function handlePageInputChange(event) {
|
|
157
157
|
const page = Number(event.target.value);
|
|
158
|
-
if (page > 0 && page <= Math.max(Math.ceil(totalItems / pageSize), 1)) {
|
|
158
|
+
if (page > 0 && totalItems && page <= Math.max(Math.ceil(totalItems / pageSize), 1)) {
|
|
159
159
|
setPage(page);
|
|
160
160
|
if (onChange) {
|
|
161
161
|
onChange({
|
|
@@ -228,11 +228,11 @@ const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pa
|
|
|
228
228
|
text: String(sizeObj.text)
|
|
229
229
|
}))), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
230
230
|
className: `${prefix}--pagination__text ${prefix}--pagination__items-count`
|
|
231
|
-
}, pagesUnknown ? itemText(pageSize * (page - 1) + 1, page * pageSize) : itemRangeText(Math.min(pageSize * (page - 1) + 1, totalItems), Math.min(page * pageSize, totalItems), totalItems))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
231
|
+
}, pagesUnknown || !totalItems ? itemText(pageSize * (page - 1) + 1, page * pageSize) : itemRangeText(Math.min(pageSize * (page - 1) + 1, totalItems), Math.min(page * pageSize, totalItems), totalItems))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
232
232
|
className: `${prefix}--pagination__right`
|
|
233
233
|
}, pagesUnknown ? /*#__PURE__*/React__default["default"].createElement("span", {
|
|
234
|
-
className: `${prefix}--pagination__text ${prefix}--pagination__page-text`
|
|
235
|
-
},
|
|
234
|
+
className: `${prefix}--pagination__text ${prefix}--pagination__page-text ${prefix}--pagination__unknown-pages-text`
|
|
235
|
+
}, pageText(page)) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Select["default"], {
|
|
236
236
|
id: `${prefix}-pagination-select-${inputId}-right`,
|
|
237
237
|
className: `${prefix}--select__page-number`,
|
|
238
238
|
labelText: `Page number, of ${totalPages} pages`,
|
|
@@ -241,9 +241,9 @@ const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pa
|
|
|
241
241
|
onChange: handlePageInputChange,
|
|
242
242
|
value: page,
|
|
243
243
|
disabled: pageInputDisabled || disabled
|
|
244
|
-
}, selectItems),
|
|
244
|
+
}, selectItems), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
245
245
|
className: `${prefix}--pagination__text`
|
|
246
|
-
},
|
|
246
|
+
}, pageRangeText(page, totalPages))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
247
247
|
className: `${prefix}--pagination__control-buttons`
|
|
248
248
|
}, /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
|
|
249
249
|
align: "top",
|
|
@@ -63,6 +63,10 @@ export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
63
63
|
* Specify the value of the `<RadioButton>`
|
|
64
64
|
*/
|
|
65
65
|
value?: string | number;
|
|
66
|
+
/**
|
|
67
|
+
* `true` to specify if the input is required.
|
|
68
|
+
*/
|
|
69
|
+
required?: boolean;
|
|
66
70
|
}
|
|
67
71
|
declare const RadioButton: React.ForwardRefExoticComponent<RadioButtonProps & React.RefAttributes<unknown>>;
|
|
68
72
|
export default RadioButton;
|
|
@@ -37,6 +37,7 @@ const RadioButton = /*#__PURE__*/React__default["default"].forwardRef((props, re
|
|
|
37
37
|
onChange = () => {},
|
|
38
38
|
value = '',
|
|
39
39
|
slug,
|
|
40
|
+
required,
|
|
40
41
|
...rest
|
|
41
42
|
} = props;
|
|
42
43
|
const prefix = usePrefix.usePrefix();
|
|
@@ -70,7 +71,8 @@ const RadioButton = /*#__PURE__*/React__default["default"].forwardRef((props, re
|
|
|
70
71
|
ref: mergeRefs["default"](inputRef, ref),
|
|
71
72
|
disabled: disabled,
|
|
72
73
|
value: value,
|
|
73
|
-
name: name
|
|
74
|
+
name: name,
|
|
75
|
+
required: required
|
|
74
76
|
})), /*#__PURE__*/React__default["default"].createElement("label", {
|
|
75
77
|
htmlFor: uniqueId,
|
|
76
78
|
className: `${prefix}--radio-button__label`
|
|
@@ -129,6 +131,10 @@ RadioButton.propTypes = {
|
|
|
129
131
|
* Provide a handler that is invoked when a user clicks on the control
|
|
130
132
|
*/
|
|
131
133
|
onClick: PropTypes__default["default"].func,
|
|
134
|
+
/**
|
|
135
|
+
* `true` to specify if the control is required.
|
|
136
|
+
*/
|
|
137
|
+
required: PropTypes__default["default"].bool,
|
|
132
138
|
/**
|
|
133
139
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButton` component
|
|
134
140
|
*/
|
|
@@ -79,6 +79,10 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
|
|
|
79
79
|
* Specify the value that is currently selected in the group
|
|
80
80
|
*/
|
|
81
81
|
valueSelected?: string | number;
|
|
82
|
+
/**
|
|
83
|
+
* `true` to specify if input selection in group is required.
|
|
84
|
+
*/
|
|
85
|
+
required?: boolean;
|
|
82
86
|
}
|
|
83
87
|
declare const RadioButtonGroup: React.ForwardRefExoticComponent<RadioButtonGroupProps & React.RefAttributes<unknown>>;
|
|
84
88
|
export default RadioButtonGroup;
|