@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;
|
|
@@ -12,6 +12,8 @@ import FilterableMultiSelect from './FilterableMultiSelect.js';
|
|
|
12
12
|
export { default as FilterableMultiSelect } from './FilterableMultiSelect.js';
|
|
13
13
|
|
|
14
14
|
FilterableMultiSelect.displayName = 'MultiSelect.Filterable';
|
|
15
|
+
// @ts-expect-error: The attribute indeed does not exist on the object,
|
|
16
|
+
// but since it is already deprecated, we do not have to fix it.
|
|
15
17
|
MultiSelect.Filterable = FilterableMultiSelect;
|
|
16
18
|
if (process.env.NODE_ENV !== "production") {
|
|
17
19
|
deprecateFieldOnObject(MultiSelect, 'Filterable', FilterableMultiSelect);
|
|
@@ -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;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import invariant from 'invariant';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
|
-
import React__default
|
|
11
|
+
import React__default from 'react';
|
|
12
12
|
import cx from 'classnames';
|
|
13
13
|
import ClickListener from '../../internal/ClickListener.js';
|
|
14
14
|
import FloatingMenu, { DIRECTION_TOP, DIRECTION_BOTTOM } from '../../internal/FloatingMenu.js';
|
|
@@ -93,10 +93,16 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
class OverflowMenu extends Component {
|
|
96
|
+
class OverflowMenu extends React__default.Component {
|
|
97
97
|
constructor() {
|
|
98
98
|
super(...arguments);
|
|
99
|
-
_defineProperty(this, "state", {
|
|
99
|
+
_defineProperty(this, "state", {
|
|
100
|
+
open: false,
|
|
101
|
+
// Set a default value for 'open'
|
|
102
|
+
hasMountedTrigger: false,
|
|
103
|
+
// Set a default value for 'hasMountedTrigger'
|
|
104
|
+
click: false // Set a default value for 'click'
|
|
105
|
+
});
|
|
100
106
|
_defineProperty(this, "instanceId", getInstanceId());
|
|
101
107
|
/**
|
|
102
108
|
* The handle of `onfocusin` or `focus` event handler.
|
|
@@ -130,8 +136,8 @@ class OverflowMenu extends Component {
|
|
|
130
136
|
}
|
|
131
137
|
});
|
|
132
138
|
_defineProperty(this, "closeMenuAndFocus", () => {
|
|
133
|
-
|
|
134
|
-
|
|
139
|
+
const wasClicked = this.state.click;
|
|
140
|
+
const wasOpen = this.state.open;
|
|
135
141
|
this.closeMenu(() => {
|
|
136
142
|
if (wasOpen && !wasClicked) {
|
|
137
143
|
this.focusMenuEl();
|
|
@@ -139,7 +145,7 @@ class OverflowMenu extends Component {
|
|
|
139
145
|
});
|
|
140
146
|
});
|
|
141
147
|
_defineProperty(this, "closeMenuOnEscape", () => {
|
|
142
|
-
|
|
148
|
+
const wasOpen = this.state.open;
|
|
143
149
|
this.closeMenu(() => {
|
|
144
150
|
if (wasOpen) {
|
|
145
151
|
this.focusMenuEl();
|
|
@@ -201,7 +207,7 @@ class OverflowMenu extends Component {
|
|
|
201
207
|
direction
|
|
202
208
|
} = _ref;
|
|
203
209
|
const enabledIndices = React__default.Children.toArray(this.props.children).reduce((acc, curr, i) => {
|
|
204
|
-
if (!curr.props.disabled) {
|
|
210
|
+
if ( /*#__PURE__*/React__default.isValidElement(curr) && !curr.props.disabled) {
|
|
205
211
|
acc.push(i);
|
|
206
212
|
}
|
|
207
213
|
return acc;
|
|
@@ -226,6 +232,7 @@ class OverflowMenu extends Component {
|
|
|
226
232
|
* @param {Element} menuBody The DOM element of the menu body.
|
|
227
233
|
* @private
|
|
228
234
|
*/
|
|
235
|
+
_defineProperty(this, "_menuBody", null);
|
|
229
236
|
_defineProperty(this, "_bindMenuBody", menuBody => {
|
|
230
237
|
if (!menuBody) {
|
|
231
238
|
this._menuBody = menuBody;
|
|
@@ -268,7 +275,7 @@ class OverflowMenu extends Component {
|
|
|
268
275
|
const {
|
|
269
276
|
current: triggerEl
|
|
270
277
|
} = this._triggerRef;
|
|
271
|
-
return triggerEl && triggerEl.closest('[data-floating-menu-container]') || document.body;
|
|
278
|
+
return triggerEl instanceof Element && triggerEl.closest('[data-floating-menu-container]') || document.body;
|
|
272
279
|
});
|
|
273
280
|
}
|
|
274
281
|
componentDidUpdate(_, prevState) {
|
|
@@ -349,18 +356,19 @@ class OverflowMenu extends Component {
|
|
|
349
356
|
[`${prefix}--overflow-menu-options--${size}`]: size
|
|
350
357
|
});
|
|
351
358
|
const overflowMenuIconClasses = cx(`${prefix}--overflow-menu__icon`, iconClass);
|
|
352
|
-
const childrenWithProps = React__default.Children.toArray(children).map((child, index) => /*#__PURE__*/React__default.cloneElement(child, {
|
|
353
|
-
|
|
359
|
+
const childrenWithProps = React__default.Children.toArray(children).map((child, index) => /*#__PURE__*/React__default.isValidElement(child) ? /*#__PURE__*/React__default.cloneElement(child, {
|
|
360
|
+
// @ts-expect-error: PropTypes are not expressive enough to cover this case
|
|
361
|
+
closeMenu: child.props.closeMenu || this.closeMenuAndFocus,
|
|
354
362
|
handleOverflowMenuItemFocus: this.handleOverflowMenuItemFocus,
|
|
355
363
|
ref: e => {
|
|
356
364
|
this[`overflowMenuItem${index}`] = e;
|
|
357
365
|
},
|
|
358
366
|
index
|
|
359
|
-
}));
|
|
367
|
+
}) : null);
|
|
360
368
|
const menuBodyId = `overflow-menu-${this.instanceId}__menu-body`;
|
|
361
369
|
const menuBody = /*#__PURE__*/React__default.createElement("ul", {
|
|
362
370
|
className: overflowMenuOptionsClasses,
|
|
363
|
-
tabIndex:
|
|
371
|
+
tabIndex: -1,
|
|
364
372
|
role: "menu",
|
|
365
373
|
"aria-label": ariaLabel || deprecatedAriaLabel,
|
|
366
374
|
onKeyDown: this.handleKeyPress,
|
|
@@ -387,12 +395,12 @@ class OverflowMenu extends Component {
|
|
|
387
395
|
onClickOutside: this.handleClickOutside
|
|
388
396
|
}, /*#__PURE__*/React__default.createElement("span", {
|
|
389
397
|
className: `${prefix}--overflow-menu__wrapper`,
|
|
390
|
-
"aria-owns": open ? menuBodyId :
|
|
398
|
+
"aria-owns": open ? menuBodyId : undefined
|
|
391
399
|
}, /*#__PURE__*/React__default.createElement(IconButton, _extends({}, other, {
|
|
392
400
|
type: "button",
|
|
393
401
|
"aria-haspopup": true,
|
|
394
402
|
"aria-expanded": open,
|
|
395
|
-
"aria-controls": open ? menuBodyId :
|
|
403
|
+
"aria-controls": open ? menuBodyId : undefined,
|
|
396
404
|
className: overflowMenuClasses,
|
|
397
405
|
onClick: this.handleClick,
|
|
398
406
|
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 };
|
|
@@ -52,10 +52,10 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
|
|
|
52
52
|
}, size !== defaultSize && `${prefix}--overflow-menu--${size}`);
|
|
53
53
|
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
|
54
54
|
className: containerClasses,
|
|
55
|
-
"aria-owns": open ? id :
|
|
55
|
+
"aria-owns": open ? id : undefined,
|
|
56
56
|
ref: forwardRef
|
|
57
57
|
}), /*#__PURE__*/React__default.createElement(IconButton, {
|
|
58
|
-
"aria-controls": open ? id :
|
|
58
|
+
"aria-controls": open ? id : undefined,
|
|
59
59
|
"aria-haspopup": true,
|
|
60
60
|
"aria-expanded": open,
|
|
61
61
|
className: triggerClasses,
|
|
@@ -97,8 +97,9 @@ OverflowMenu.propTypes = {
|
|
|
97
97
|
*/
|
|
98
98
|
menuAlignment: PropTypes.oneOf(['top-start', 'top-end', 'bottom-start', 'bottom-end']),
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
100
|
+
* Optionally provide a custom icon to be rendered on the trigger button.
|
|
101
101
|
*/
|
|
102
|
+
// @ts-expect-error: PropTypes are not expressive enough to cover this case
|
|
102
103
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
103
104
|
/**
|
|
104
105
|
* Specify the size of the menu, from a list of available sizes.
|
|
@@ -68,10 +68,10 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
|
|
|
68
68
|
pageSize: controlledPageSize,
|
|
69
69
|
pageSizeInputDisabled,
|
|
70
70
|
pageSizes: controlledPageSizes,
|
|
71
|
-
pageText =
|
|
71
|
+
pageText = page => `page ${page}`,
|
|
72
72
|
pagesUnknown = false,
|
|
73
73
|
size = 'md',
|
|
74
|
-
totalItems
|
|
74
|
+
totalItems,
|
|
75
75
|
...rest
|
|
76
76
|
} = _ref;
|
|
77
77
|
const prefix = usePrefix();
|
|
@@ -93,7 +93,7 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
|
|
|
93
93
|
[`${prefix}--pagination--${size}`]: size,
|
|
94
94
|
[customClassName]: !!customClassName
|
|
95
95
|
});
|
|
96
|
-
const totalPages = Math.max(Math.ceil(totalItems / pageSize), 1);
|
|
96
|
+
const totalPages = totalItems ? Math.max(Math.ceil(totalItems / pageSize), 1) : NaN;
|
|
97
97
|
const backButtonDisabled = disabled || page === 1;
|
|
98
98
|
const backButtonClasses = cx({
|
|
99
99
|
[`${prefix}--pagination__button`]: true,
|
|
@@ -145,7 +145,7 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
|
|
|
145
145
|
}
|
|
146
146
|
function handlePageInputChange(event) {
|
|
147
147
|
const page = Number(event.target.value);
|
|
148
|
-
if (page > 0 && page <= Math.max(Math.ceil(totalItems / pageSize), 1)) {
|
|
148
|
+
if (page > 0 && totalItems && page <= Math.max(Math.ceil(totalItems / pageSize), 1)) {
|
|
149
149
|
setPage(page);
|
|
150
150
|
if (onChange) {
|
|
151
151
|
onChange({
|
|
@@ -218,11 +218,11 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
|
|
|
218
218
|
text: String(sizeObj.text)
|
|
219
219
|
}))), /*#__PURE__*/React__default.createElement("span", {
|
|
220
220
|
className: `${prefix}--pagination__text ${prefix}--pagination__items-count`
|
|
221
|
-
}, 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.createElement("div", {
|
|
221
|
+
}, 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.createElement("div", {
|
|
222
222
|
className: `${prefix}--pagination__right`
|
|
223
223
|
}, pagesUnknown ? /*#__PURE__*/React__default.createElement("span", {
|
|
224
|
-
className: `${prefix}--pagination__text ${prefix}--pagination__page-text`
|
|
225
|
-
},
|
|
224
|
+
className: `${prefix}--pagination__text ${prefix}--pagination__page-text ${prefix}--pagination__unknown-pages-text`
|
|
225
|
+
}, pageText(page)) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Select, {
|
|
226
226
|
id: `${prefix}-pagination-select-${inputId}-right`,
|
|
227
227
|
className: `${prefix}--select__page-number`,
|
|
228
228
|
labelText: `Page number, of ${totalPages} pages`,
|
|
@@ -231,9 +231,9 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
|
|
|
231
231
|
onChange: handlePageInputChange,
|
|
232
232
|
value: page,
|
|
233
233
|
disabled: pageInputDisabled || disabled
|
|
234
|
-
}, selectItems),
|
|
234
|
+
}, selectItems), /*#__PURE__*/React__default.createElement("span", {
|
|
235
235
|
className: `${prefix}--pagination__text`
|
|
236
|
-
},
|
|
236
|
+
}, pageRangeText(page, totalPages))), /*#__PURE__*/React__default.createElement("div", {
|
|
237
237
|
className: `${prefix}--pagination__control-buttons`
|
|
238
238
|
}, /*#__PURE__*/React__default.createElement(IconButton, {
|
|
239
239
|
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;
|
|
@@ -27,6 +27,7 @@ const RadioButton = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
27
27
|
onChange = () => {},
|
|
28
28
|
value = '',
|
|
29
29
|
slug,
|
|
30
|
+
required,
|
|
30
31
|
...rest
|
|
31
32
|
} = props;
|
|
32
33
|
const prefix = usePrefix();
|
|
@@ -60,7 +61,8 @@ const RadioButton = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
60
61
|
ref: mergeRefs(inputRef, ref),
|
|
61
62
|
disabled: disabled,
|
|
62
63
|
value: value,
|
|
63
|
-
name: name
|
|
64
|
+
name: name,
|
|
65
|
+
required: required
|
|
64
66
|
})), /*#__PURE__*/React__default.createElement("label", {
|
|
65
67
|
htmlFor: uniqueId,
|
|
66
68
|
className: `${prefix}--radio-button__label`
|
|
@@ -119,6 +121,10 @@ RadioButton.propTypes = {
|
|
|
119
121
|
* Provide a handler that is invoked when a user clicks on the control
|
|
120
122
|
*/
|
|
121
123
|
onClick: PropTypes.func,
|
|
124
|
+
/**
|
|
125
|
+
* `true` to specify if the control is required.
|
|
126
|
+
*/
|
|
127
|
+
required: PropTypes.bool,
|
|
122
128
|
/**
|
|
123
129
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButton` component
|
|
124
130
|
*/
|
|
@@ -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;
|