@carbon/react 1.50.0-rc.0 → 1.51.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 +1005 -1038
- package/es/components/Accordion/AccordionItem.js +10 -15
- package/es/components/ChatButton/ChatButton.Skeleton.js +40 -0
- package/es/components/ChatButton/ChatButton.js +81 -0
- package/es/components/ComposedModal/ComposedModal.js +32 -8
- package/es/components/Copy/Copy.js +1 -1
- package/es/components/DataTable/DataTable.d.ts +21 -0
- package/es/components/DataTable/DataTable.js +19 -0
- package/es/components/DataTable/TableCell.d.ts +28 -3
- package/es/components/DataTable/TableCell.js +22 -5
- package/es/components/DataTable/TableExpandRow.js +1 -1
- package/es/components/DataTable/TableHeader.js +2 -2
- package/es/components/DataTable/TableRow.js +12 -1
- package/es/components/DataTable/TableToolbarSearch.d.ts +11 -38
- package/es/components/DataTable/TableToolbarSearch.js +1 -1
- package/es/components/DataTable/tools/normalize.js +3 -1
- package/es/components/Modal/Modal.js +25 -6
- package/es/components/MultiSelect/MultiSelect.d.ts +4 -0
- package/es/components/MultiSelect/MultiSelect.js +10 -1
- package/es/components/NumberInput/NumberInput.js +1 -1
- package/es/components/PaginationNav/PaginationNav.d.ts +45 -0
- package/es/components/PaginationNav/PaginationNav.js +24 -25
- package/es/components/PaginationNav/index.d.ts +9 -0
- package/es/components/Tabs/Tabs.js +2 -1
- package/es/components/Tile/Tile.d.ts +2 -2
- package/es/components/Tile/Tile.js +2 -2
- package/es/index.d.ts +1 -0
- package/es/index.js +3 -1
- package/lib/components/Accordion/AccordionItem.js +9 -14
- package/lib/components/ChatButton/ChatButton.Skeleton.js +50 -0
- package/lib/components/ChatButton/ChatButton.js +91 -0
- package/lib/components/ComposedModal/ComposedModal.js +32 -7
- package/lib/components/Copy/Copy.js +1 -1
- package/lib/components/DataTable/DataTable.d.ts +21 -0
- package/lib/components/DataTable/DataTable.js +19 -0
- package/lib/components/DataTable/TableCell.d.ts +28 -3
- package/lib/components/DataTable/TableCell.js +27 -5
- package/lib/components/DataTable/TableExpandRow.js +1 -1
- package/lib/components/DataTable/TableHeader.js +2 -2
- package/lib/components/DataTable/TableRow.js +12 -1
- package/lib/components/DataTable/TableToolbarSearch.d.ts +11 -38
- package/lib/components/DataTable/TableToolbarSearch.js +1 -1
- package/lib/components/DataTable/tools/normalize.js +3 -1
- package/lib/components/Modal/Modal.js +25 -5
- package/lib/components/MultiSelect/MultiSelect.d.ts +4 -0
- package/lib/components/MultiSelect/MultiSelect.js +10 -1
- package/lib/components/NumberInput/NumberInput.js +1 -1
- package/lib/components/PaginationNav/PaginationNav.d.ts +45 -0
- package/lib/components/PaginationNav/PaginationNav.js +24 -25
- package/lib/components/PaginationNav/index.d.ts +9 -0
- package/lib/components/Tabs/Tabs.js +2 -1
- package/lib/components/Tile/Tile.d.ts +2 -2
- package/lib/components/Tile/Tile.js +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +6 -2
- package/package.json +5 -5
- package/scss/components/chat-button/_chat-button.scss +9 -0
- package/scss/components/chat-button/_index.scss +9 -0
|
@@ -51,6 +51,10 @@ interface MultiSelectSortingProps<ItemType> {
|
|
|
51
51
|
}
|
|
52
52
|
export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<ItemType>, InternationalProps<'close.menu' | 'open.menu' | 'clear.all' | 'clear.selection'> {
|
|
53
53
|
className?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Specify the text that should be read for screen readers that describes that all items are deleted
|
|
56
|
+
*/
|
|
57
|
+
clearAnnouncement?: string;
|
|
54
58
|
/**
|
|
55
59
|
* Specify the text that should be read for screen readers that describes total items selected
|
|
56
60
|
*/
|
|
@@ -71,6 +71,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
71
71
|
sortItems = defaultSortItems,
|
|
72
72
|
compareItems = defaultCompareItems,
|
|
73
73
|
clearSelectionText = 'To clear selection, press Delete or Backspace',
|
|
74
|
+
clearAnnouncement = 'all items have been cleared',
|
|
74
75
|
clearSelectionDescription = 'Total items selected: ',
|
|
75
76
|
light,
|
|
76
77
|
invalid,
|
|
@@ -102,6 +103,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
102
103
|
const [isOpen, setIsOpen] = useState(open || false);
|
|
103
104
|
const [prevOpenProp, setPrevOpenProp] = useState(open);
|
|
104
105
|
const [topItems, setTopItems] = useState([]);
|
|
106
|
+
const [itemsCleared, setItemsCleared] = useState(false);
|
|
105
107
|
const {
|
|
106
108
|
selectedItems: controlledSelectedItems,
|
|
107
109
|
onItemChange,
|
|
@@ -148,7 +150,11 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
148
150
|
clearSelection();
|
|
149
151
|
e.stopPropagation();
|
|
150
152
|
}
|
|
153
|
+
if (!isOpen && match(e, Delete) && selectedItems.length > 0) {
|
|
154
|
+
setItemsCleared(true);
|
|
155
|
+
}
|
|
151
156
|
if ((match(e, Space) || match(e, ArrowDown) || match(e, Enter)) && !isOpen) {
|
|
157
|
+
setItemsCleared(false);
|
|
152
158
|
setIsOpenWrapper(true);
|
|
153
159
|
}
|
|
154
160
|
}
|
|
@@ -383,7 +389,10 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
383
389
|
}, itemToElement ? /*#__PURE__*/React__default.createElement(ItemToElement, _extends({
|
|
384
390
|
key: itemProps.id
|
|
385
391
|
}, item)) : itemText)));
|
|
386
|
-
}))
|
|
392
|
+
})), itemsCleared && /*#__PURE__*/React__default.createElement("span", {
|
|
393
|
+
"aria-live": "assertive",
|
|
394
|
+
"aria-label": clearAnnouncement
|
|
395
|
+
})), !inline && !invalid && !warn && helperText && /*#__PURE__*/React__default.createElement("div", {
|
|
387
396
|
id: helperId,
|
|
388
397
|
className: helperClasses
|
|
389
398
|
}, helperText));
|
|
@@ -130,7 +130,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
const state = {
|
|
133
|
-
value: event.target.value,
|
|
133
|
+
value: Number(event.target.value),
|
|
134
134
|
direction: value < event.target.value ? 'up' : 'down'
|
|
135
135
|
};
|
|
136
136
|
setValue(state.value);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2020
|
|
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 from 'react';
|
|
8
|
+
interface PaginationNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
|
|
9
|
+
/**
|
|
10
|
+
* Additional CSS class names.
|
|
11
|
+
*/
|
|
12
|
+
className?: string;
|
|
13
|
+
/**
|
|
14
|
+
* If true, the '...' pagination overflow will not render page links between the first and last rendered buttons.
|
|
15
|
+
* Set this to true if you are having performance problems with large data sets.
|
|
16
|
+
*/
|
|
17
|
+
disableOverflow?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The number of items to be shown.
|
|
20
|
+
*/
|
|
21
|
+
itemsShown?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Whether user should be able to loop through the items when reaching first / last.
|
|
24
|
+
*/
|
|
25
|
+
loop?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The callback function called when the current page changes.
|
|
28
|
+
*/
|
|
29
|
+
onChange?: (data: number) => void;
|
|
30
|
+
/**
|
|
31
|
+
* The index of current page.
|
|
32
|
+
*/
|
|
33
|
+
page?: number;
|
|
34
|
+
/**
|
|
35
|
+
* The total number of items.
|
|
36
|
+
*/
|
|
37
|
+
totalItems?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Specify a custom translation function that takes in a message identifier
|
|
40
|
+
* and returns the localized string for the message
|
|
41
|
+
*/
|
|
42
|
+
translateWithId?: (id: string) => string;
|
|
43
|
+
}
|
|
44
|
+
declare const PaginationNav: React.ForwardRefExoticComponent<PaginationNavProps & React.RefAttributes<HTMLElement>>;
|
|
45
|
+
export default PaginationNav;
|
|
@@ -27,23 +27,23 @@ function translateWithId(messageId) {
|
|
|
27
27
|
|
|
28
28
|
// https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
|
|
29
29
|
function usePrevious(value) {
|
|
30
|
-
const ref = useRef();
|
|
30
|
+
const ref = useRef(null);
|
|
31
31
|
useEffect(() => {
|
|
32
32
|
ref.current = value;
|
|
33
33
|
});
|
|
34
34
|
return ref.current;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function calculateCuts(page, totalItems, itemsDisplayedOnPage) {
|
|
37
37
|
let splitPoint = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
38
|
-
if (
|
|
38
|
+
if (itemsDisplayedOnPage >= totalItems) {
|
|
39
39
|
return {
|
|
40
40
|
front: 0,
|
|
41
41
|
back: 0
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
const split = splitPoint || Math.ceil(
|
|
44
|
+
const split = splitPoint || Math.ceil(itemsDisplayedOnPage / 2) - 1;
|
|
45
45
|
let frontHidden = page + 1 - split;
|
|
46
|
-
let backHidden = totalItems - page - (
|
|
46
|
+
let backHidden = totalItems - page - (itemsDisplayedOnPage - split) + 1;
|
|
47
47
|
if (frontHidden <= 1) {
|
|
48
48
|
backHidden -= frontHidden <= 0 ? Math.abs(frontHidden) + 1 : 0;
|
|
49
49
|
frontHidden = 0;
|
|
@@ -93,15 +93,15 @@ function PaginationItem(_ref2) {
|
|
|
93
93
|
}),
|
|
94
94
|
onClick: onClick,
|
|
95
95
|
"data-page": page,
|
|
96
|
-
"aria-current": isActive ? 'page' :
|
|
96
|
+
"aria-current": isActive ? 'page' : undefined
|
|
97
97
|
}, /*#__PURE__*/React__default.createElement("span", {
|
|
98
98
|
className: `${prefix}--pagination-nav__accessibility-label`
|
|
99
99
|
}, isActive ? `${t('carbon.pagination-nav.active')}, ${itemLabel}` : itemLabel), page));
|
|
100
100
|
}
|
|
101
101
|
function PaginationOverflow(_ref3) {
|
|
102
102
|
let {
|
|
103
|
-
fromIndex,
|
|
104
|
-
count,
|
|
103
|
+
fromIndex = NaN,
|
|
104
|
+
count = NaN,
|
|
105
105
|
onSelect,
|
|
106
106
|
// eslint-disable-next-line react/prop-types
|
|
107
107
|
disableOverflow,
|
|
@@ -135,7 +135,7 @@ function PaginationOverflow(_ref3) {
|
|
|
135
135
|
"aria-label": `Select ${t('carbon.pagination-nav.item')} number`,
|
|
136
136
|
onChange: e => {
|
|
137
137
|
const index = Number(e.target.value);
|
|
138
|
-
onSelect(index);
|
|
138
|
+
onSelect?.(index);
|
|
139
139
|
}
|
|
140
140
|
}, _option || (_option = /*#__PURE__*/React__default.createElement("option", {
|
|
141
141
|
value: "",
|
|
@@ -155,7 +155,7 @@ function PaginationOverflow(_ref3) {
|
|
|
155
155
|
page: fromIndex + 1,
|
|
156
156
|
translateWithId: t,
|
|
157
157
|
onClick: () => {
|
|
158
|
-
onSelect(fromIndex);
|
|
158
|
+
onSelect?.(fromIndex);
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
161
|
}
|
|
@@ -165,7 +165,7 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
165
165
|
let {
|
|
166
166
|
className,
|
|
167
167
|
onChange = () => {},
|
|
168
|
-
totalItems,
|
|
168
|
+
totalItems = NaN,
|
|
169
169
|
disableOverflow,
|
|
170
170
|
itemsShown = 10,
|
|
171
171
|
page = 0,
|
|
@@ -174,8 +174,8 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
174
174
|
...rest
|
|
175
175
|
} = _ref4;
|
|
176
176
|
const [currentPage, setCurrentPage] = useState(page);
|
|
177
|
-
const [
|
|
178
|
-
const [cuts, setCuts] = useState(
|
|
177
|
+
const [itemsDisplayedOnPage, setItemsDisplayedOnPage] = useState(itemsShown >= 4 ? itemsShown : 4);
|
|
178
|
+
const [cuts, setCuts] = useState(calculateCuts(currentPage, totalItems, itemsDisplayedOnPage));
|
|
179
179
|
const prevPage = usePrevious(currentPage);
|
|
180
180
|
const prefix = usePrefix();
|
|
181
181
|
const [isOverflowDisabled, setIsOverFlowDisabled] = useState(disableOverflow);
|
|
@@ -206,7 +206,7 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
function pageWouldBeHidden(page) {
|
|
209
|
-
const startOffset =
|
|
209
|
+
const startOffset = itemsDisplayedOnPage <= 4 && page > 1 ? 0 : 1;
|
|
210
210
|
const wouldBeHiddenInFront = page >= startOffset && page <= cuts.front;
|
|
211
211
|
const wouldBeHiddenInBack = page >= totalItems - cuts.back - 1 && page <= totalItems - 2;
|
|
212
212
|
return wouldBeHiddenInFront || wouldBeHiddenInBack;
|
|
@@ -219,20 +219,20 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
219
219
|
|
|
220
220
|
// re-calculate cuts if props.totalItems or props.itemsShown change
|
|
221
221
|
useEffect(() => {
|
|
222
|
-
|
|
223
|
-
setCuts(
|
|
222
|
+
setItemsDisplayedOnPage(itemsShown >= 4 ? itemsShown : 4);
|
|
223
|
+
setCuts(calculateCuts(currentPage, totalItems, itemsShown));
|
|
224
224
|
}, [totalItems, itemsShown]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
225
225
|
|
|
226
226
|
// update cuts if necessary whenever currentPage changes
|
|
227
227
|
useEffect(() => {
|
|
228
228
|
if (pageWouldBeHidden(currentPage)) {
|
|
229
|
-
const delta = currentPage - prevPage || 0;
|
|
229
|
+
const delta = currentPage - (prevPage || 0);
|
|
230
230
|
if (delta > 0) {
|
|
231
|
-
const splitPoint =
|
|
232
|
-
setCuts(
|
|
231
|
+
const splitPoint = itemsDisplayedOnPage - 3;
|
|
232
|
+
setCuts(calculateCuts(currentPage, totalItems, itemsDisplayedOnPage, splitPoint));
|
|
233
233
|
} else {
|
|
234
|
-
const splitPoint =
|
|
235
|
-
setCuts(
|
|
234
|
+
const splitPoint = itemsDisplayedOnPage > 4 ? 2 : 1;
|
|
235
|
+
setCuts(calculateCuts(currentPage, totalItems, itemsDisplayedOnPage, splitPoint));
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
}, [currentPage]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
@@ -243,7 +243,7 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
243
243
|
const classNames = cx(`${prefix}--pagination-nav`, className);
|
|
244
244
|
const backwardButtonDisabled = !loop && currentPage === 0;
|
|
245
245
|
const forwardButtonDisabled = !loop && currentPage === totalItems - 1;
|
|
246
|
-
const startOffset =
|
|
246
|
+
const startOffset = itemsDisplayedOnPage <= 4 && currentPage > 1 ? 0 : 1;
|
|
247
247
|
return /*#__PURE__*/React__default.createElement("nav", _extends({
|
|
248
248
|
className: classNames,
|
|
249
249
|
ref: ref
|
|
@@ -259,7 +259,7 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
259
259
|
}),
|
|
260
260
|
// render first item if at least 5 items can be displayed or
|
|
261
261
|
// 4 items can be displayed and the current page is either 0 or 1
|
|
262
|
-
(
|
|
262
|
+
(itemsDisplayedOnPage >= 5 || itemsDisplayedOnPage <= 4 && currentPage <= 1) && /*#__PURE__*/React__default.createElement(PaginationItem, {
|
|
263
263
|
page: 1,
|
|
264
264
|
translateWithId: t,
|
|
265
265
|
isActive: currentPage === 0,
|
|
@@ -401,6 +401,5 @@ PaginationNav.propTypes = {
|
|
|
401
401
|
*/
|
|
402
402
|
translateWithId: PropTypes.func
|
|
403
403
|
};
|
|
404
|
-
var PaginationNav$1 = PaginationNav;
|
|
405
404
|
|
|
406
|
-
export { PaginationNav
|
|
405
|
+
export { PaginationNav as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2020
|
|
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 PaginationNav from './PaginationNav';
|
|
8
|
+
export default PaginationNav;
|
|
9
|
+
export { PaginationNav };
|
|
@@ -228,7 +228,8 @@ function TabList(_ref2) {
|
|
|
228
228
|
function onKeyDown(event) {
|
|
229
229
|
if (matches(event, [ArrowRight, ArrowLeft, Home, End])) {
|
|
230
230
|
event.preventDefault();
|
|
231
|
-
const
|
|
231
|
+
const filtredTabs = tabs.current.filter(tab => tab !== null);
|
|
232
|
+
const activeTabs = filtredTabs.filter(tab => !tab.disabled);
|
|
232
233
|
const currentIndex = activeTabs.indexOf(tabs.current[activation === 'automatic' ? selectedIndex : activeIndex]);
|
|
233
234
|
const nextIndex = tabs.current.indexOf(activeTabs[getNextIndex(event, activeTabs.length, currentIndex)]);
|
|
234
235
|
if (activation === 'automatic') {
|
|
@@ -180,11 +180,11 @@ export interface TileAboveTheFoldContentProps {
|
|
|
180
180
|
*/
|
|
181
181
|
children?: ReactNode;
|
|
182
182
|
}
|
|
183
|
-
export declare const TileAboveTheFoldContent: React.ForwardRefExoticComponent<TileAboveTheFoldContentProps & React.RefAttributes<
|
|
183
|
+
export declare const TileAboveTheFoldContent: React.ForwardRefExoticComponent<TileAboveTheFoldContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
184
184
|
export interface TileBelowTheFoldContentProps {
|
|
185
185
|
/**
|
|
186
186
|
* The child nodes.
|
|
187
187
|
*/
|
|
188
188
|
children?: ReactNode;
|
|
189
189
|
}
|
|
190
|
-
export declare const TileBelowTheFoldContent: React.ForwardRefExoticComponent<TileBelowTheFoldContentProps & React.RefAttributes<
|
|
190
|
+
export declare const TileBelowTheFoldContent: React.ForwardRefExoticComponent<TileBelowTheFoldContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -604,7 +604,7 @@ const TileAboveTheFoldContent = /*#__PURE__*/React__default.forwardRef(function
|
|
|
604
604
|
children
|
|
605
605
|
} = _ref5;
|
|
606
606
|
const prefix = usePrefix();
|
|
607
|
-
return /*#__PURE__*/React__default.createElement("
|
|
607
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
608
608
|
ref: ref,
|
|
609
609
|
className: `${prefix}--tile-content__above-the-fold`
|
|
610
610
|
}, children);
|
|
@@ -621,7 +621,7 @@ const TileBelowTheFoldContent = /*#__PURE__*/React__default.forwardRef(function
|
|
|
621
621
|
children
|
|
622
622
|
} = _ref6;
|
|
623
623
|
const prefix = usePrefix();
|
|
624
|
-
return /*#__PURE__*/React__default.createElement("
|
|
624
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
625
625
|
ref: ref,
|
|
626
626
|
className: `${prefix}--tile-content__below-the-fold`
|
|
627
627
|
}, children);
|
package/es/index.d.ts
CHANGED
|
@@ -115,6 +115,7 @@ export { PageSelector as unstable_PageSelector, Pagination as unstable_Paginatio
|
|
|
115
115
|
export * from './components/Popover';
|
|
116
116
|
export * from './components/ProgressBar';
|
|
117
117
|
export { Slug as unstable__Slug, SlugContent as unstable__SlugContent, SlugActions as unstable__SlugActions, } from './components/Slug';
|
|
118
|
+
export { ChatButton as unstable__ChatButton, ChatButtonSkeleton as unstable__ChatButtonSkeleton, } from './components/ChatButton';
|
|
118
119
|
export * from './components/Stack';
|
|
119
120
|
export * from './components/Tooltip';
|
|
120
121
|
export { Text as unstable_Text, TextDirection as unstable_TextDirection, } from './components/Text';
|
package/es/index.js
CHANGED
|
@@ -72,6 +72,7 @@ export { default as OrderedList } from './components/OrderedList/OrderedList.js'
|
|
|
72
72
|
export { default as OverflowMenu } from './components/OverflowMenu/index.js';
|
|
73
73
|
export { default as OverflowMenuItem } from './components/OverflowMenuItem/OverflowMenuItem.js';
|
|
74
74
|
export { default as PaginationSkeleton } from './components/Pagination/Pagination.Skeleton.js';
|
|
75
|
+
export { default as PaginationNav } from './components/PaginationNav/PaginationNav.js';
|
|
75
76
|
export { default as PrimaryButton } from './components/PrimaryButton/PrimaryButton.js';
|
|
76
77
|
export { default as ProgressIndicatorSkeleton } from './components/ProgressIndicator/ProgressIndicator.Skeleton.js';
|
|
77
78
|
export { ProgressIndicator, ProgressStep } from './components/ProgressIndicator/ProgressIndicator.js';
|
|
@@ -189,6 +190,8 @@ export { default as unstable__FluidTimePickerSkeleton } from './components/Fluid
|
|
|
189
190
|
export { default as unstable__FluidTimePickerSelect } from './components/FluidTimePickerSelect/FluidTimePickerSelect.js';
|
|
190
191
|
export { LayoutDirection as unstable_LayoutDirection } from './components/LayoutDirection/LayoutDirection.js';
|
|
191
192
|
export { useLayoutDirection as unstable_useLayoutDirection } from './components/LayoutDirection/useLayoutDirection.js';
|
|
193
|
+
export { default as unstable__ChatButton } from './components/ChatButton/ChatButton.js';
|
|
194
|
+
export { default as unstable__ChatButtonSkeleton } from './components/ChatButton/ChatButton.Skeleton.js';
|
|
192
195
|
export { Text as unstable_Text } from './components/Text/Text.js';
|
|
193
196
|
export { TextDirection as unstable_TextDirection } from './components/Text/TextDirection.js';
|
|
194
197
|
export { default as DataTable } from './components/DataTable/DataTable.js';
|
|
@@ -216,7 +219,6 @@ export { default as TableToolbarMenu } from './components/DataTable/TableToolbar
|
|
|
216
219
|
export { default as FilterableMultiSelect } from './components/MultiSelect/FilterableMultiSelect.js';
|
|
217
220
|
export { default as MultiSelect } from './components/MultiSelect/MultiSelect.js';
|
|
218
221
|
export { default as Pagination } from './components/Pagination/Pagination.js';
|
|
219
|
-
export { default as PaginationNav } from './components/PaginationNav/PaginationNav.js';
|
|
220
222
|
export { default as ControlledPasswordInput } from './components/TextInput/ControlledPasswordInput.js';
|
|
221
223
|
export { default as PasswordInput } from './components/TextInput/PasswordInput.js';
|
|
222
224
|
export { default as RadioTile } from './components/RadioTile/RadioTile.js';
|
|
@@ -61,7 +61,15 @@ function AccordionItem(_ref) {
|
|
|
61
61
|
});
|
|
62
62
|
const Toggle = renderToggle || renderExpando; // remove renderExpando in next major release
|
|
63
63
|
|
|
64
|
-
const content =
|
|
64
|
+
const content = React__default["default"].useCallback(node => {
|
|
65
|
+
if (!node) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (isOpen) {
|
|
69
|
+
// accordion closes
|
|
70
|
+
node.style.maxBlockSize = '';
|
|
71
|
+
}
|
|
72
|
+
}, [isOpen]);
|
|
65
73
|
if (open !== prevIsOpen) {
|
|
66
74
|
setIsOpen(open);
|
|
67
75
|
setPrevIsOpen(open);
|
|
@@ -70,19 +78,6 @@ function AccordionItem(_ref) {
|
|
|
70
78
|
// When the AccordionItem heading is clicked, toggle the open state of the
|
|
71
79
|
// panel
|
|
72
80
|
function onClick(event) {
|
|
73
|
-
// type guard for ref
|
|
74
|
-
if (!content.current) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (isOpen) {
|
|
78
|
-
// accordion closes
|
|
79
|
-
content.current.style.maxBlockSize = '';
|
|
80
|
-
} else {
|
|
81
|
-
// accordion opens
|
|
82
|
-
content.current.style.maxBlockSize =
|
|
83
|
-
// Scroll height plus top/bottom padding
|
|
84
|
-
content.current.scrollHeight + 32 + 'px';
|
|
85
|
-
}
|
|
86
81
|
const nextValue = !isOpen;
|
|
87
82
|
setIsOpen(nextValue);
|
|
88
83
|
if (onHeadingClick) {
|
|
@@ -0,0 +1,50 @@
|
|
|
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 _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
+
var PropTypes = require('prop-types');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var cx = require('classnames');
|
|
16
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
21
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
23
|
+
|
|
24
|
+
const ChatButtonSkeleton = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
className,
|
|
27
|
+
size,
|
|
28
|
+
...rest
|
|
29
|
+
} = _ref;
|
|
30
|
+
const prefix = usePrefix.usePrefix();
|
|
31
|
+
const skeletonClasses = cx__default["default"](className, `${prefix}--skeleton`, `${prefix}--btn`, `${prefix}--chat-btn`, {
|
|
32
|
+
[`${prefix}--layout--size-${size}`]: size
|
|
33
|
+
});
|
|
34
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
35
|
+
className: skeletonClasses
|
|
36
|
+
}, rest));
|
|
37
|
+
};
|
|
38
|
+
ChatButtonSkeleton.propTypes = {
|
|
39
|
+
/**
|
|
40
|
+
* Specify an optional className to add.
|
|
41
|
+
*/
|
|
42
|
+
className: PropTypes__default["default"].string,
|
|
43
|
+
/**
|
|
44
|
+
* Specify the size of the `ChatButtonSkeleton`, from the following list of sizes:
|
|
45
|
+
*/
|
|
46
|
+
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg'])
|
|
47
|
+
};
|
|
48
|
+
var ChatButtonSkeleton$1 = ChatButtonSkeleton;
|
|
49
|
+
|
|
50
|
+
exports["default"] = ChatButtonSkeleton$1;
|
|
@@ -0,0 +1,91 @@
|
|
|
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 _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
+
var PropTypes = require('prop-types');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var cx = require('classnames');
|
|
16
|
+
var Button = require('../Button/Button.js');
|
|
17
|
+
require('../Button/Button.Skeleton.js');
|
|
18
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
|
+
|
|
20
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
|
+
|
|
22
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
23
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
24
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
25
|
+
|
|
26
|
+
const ChatButton = /*#__PURE__*/React__default["default"].forwardRef(function ChatButton(_ref, ref) {
|
|
27
|
+
let {
|
|
28
|
+
className,
|
|
29
|
+
children,
|
|
30
|
+
disabled,
|
|
31
|
+
isQuickAction,
|
|
32
|
+
isSelected,
|
|
33
|
+
kind,
|
|
34
|
+
size,
|
|
35
|
+
...other
|
|
36
|
+
} = _ref;
|
|
37
|
+
const prefix = usePrefix.usePrefix();
|
|
38
|
+
const classNames = cx__default["default"](className, {
|
|
39
|
+
[`${prefix}--chat-btn`]: true,
|
|
40
|
+
[`${prefix}--chat-btn--quick-action`]: isQuickAction,
|
|
41
|
+
[`${prefix}--chat-btn--quick-action--selected`]: isSelected
|
|
42
|
+
});
|
|
43
|
+
const allowedSizes = ['sm', 'md', 'lg'];
|
|
44
|
+
if (isQuickAction) {
|
|
45
|
+
kind = 'ghost';
|
|
46
|
+
size = 'sm';
|
|
47
|
+
} else {
|
|
48
|
+
// Do not allow size larger than `lg`
|
|
49
|
+
size = allowedSizes.includes(size) ? size : 'lg';
|
|
50
|
+
}
|
|
51
|
+
return /*#__PURE__*/React__default["default"].createElement(Button["default"], _rollupPluginBabelHelpers["extends"]({
|
|
52
|
+
disabled: disabled,
|
|
53
|
+
className: classNames,
|
|
54
|
+
kind: kind,
|
|
55
|
+
ref: ref,
|
|
56
|
+
size: size
|
|
57
|
+
}, other), children);
|
|
58
|
+
});
|
|
59
|
+
ChatButton.propTypes = {
|
|
60
|
+
/**
|
|
61
|
+
* Provide the contents of your Select
|
|
62
|
+
*/
|
|
63
|
+
children: PropTypes__default["default"].node,
|
|
64
|
+
/**
|
|
65
|
+
* Specify an optional className to be applied to the node containing the label and the select box
|
|
66
|
+
*/
|
|
67
|
+
className: PropTypes__default["default"].string,
|
|
68
|
+
/**
|
|
69
|
+
* Specify whether the `ChatButton` should be disabled
|
|
70
|
+
*/
|
|
71
|
+
disabled: PropTypes__default["default"].bool,
|
|
72
|
+
/**
|
|
73
|
+
* Specify whether the `ChatButton` should be rendered as a quick action button
|
|
74
|
+
*/
|
|
75
|
+
isQuickAction: PropTypes__default["default"].bool,
|
|
76
|
+
/**
|
|
77
|
+
* Specify whether the quick action `ChatButton` should be rendered as selected. This disables the input
|
|
78
|
+
*/
|
|
79
|
+
isSelected: PropTypes__default["default"].bool,
|
|
80
|
+
/**
|
|
81
|
+
* Specify the kind of `ChatButton` you want to create
|
|
82
|
+
*/
|
|
83
|
+
kind: PropTypes__default["default"].oneOf(['primary', 'secondary', 'danger', 'ghost', 'tertiary']),
|
|
84
|
+
/**
|
|
85
|
+
* Specify the size of the `ChatButton`, from the following list of sizes:
|
|
86
|
+
*/
|
|
87
|
+
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg'])
|
|
88
|
+
};
|
|
89
|
+
var ChatButton$1 = ChatButton;
|
|
90
|
+
|
|
91
|
+
exports["default"] = ChatButton$1;
|
|
@@ -15,6 +15,9 @@ var reactIs = require('react-is');
|
|
|
15
15
|
var PropTypes = require('prop-types');
|
|
16
16
|
var ModalHeader = require('./ModalHeader.js');
|
|
17
17
|
var ModalFooter = require('./ModalFooter.js');
|
|
18
|
+
var debounce = require('lodash.debounce');
|
|
19
|
+
var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
|
|
20
|
+
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
18
21
|
var cx = require('classnames');
|
|
19
22
|
var toggleClass = require('../../tools/toggleClass.js');
|
|
20
23
|
var requiredIfGivenPropIsTruthy = require('../../prop-types/requiredIfGivenPropIsTruthy.js');
|
|
@@ -27,6 +30,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
27
30
|
|
|
28
31
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
29
32
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
33
|
+
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
30
34
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
31
35
|
|
|
32
36
|
const ModalBody = /*#__PURE__*/React__default["default"].forwardRef(function ModalBody(_ref, ref) {
|
|
@@ -38,18 +42,39 @@ const ModalBody = /*#__PURE__*/React__default["default"].forwardRef(function Mod
|
|
|
38
42
|
...rest
|
|
39
43
|
} = _ref;
|
|
40
44
|
const prefix = usePrefix.usePrefix();
|
|
41
|
-
const
|
|
42
|
-
const
|
|
45
|
+
const contentRef = React.useRef(null);
|
|
46
|
+
const [isScrollable, setIsScrollable] = React.useState(false);
|
|
47
|
+
const contentClass = cx__default["default"]({
|
|
48
|
+
[`${prefix}--modal-content`]: true,
|
|
49
|
+
[`${prefix}--modal-content--with-form`]: hasForm,
|
|
50
|
+
[`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable,
|
|
51
|
+
customClassName
|
|
52
|
+
});
|
|
53
|
+
useIsomorphicEffect["default"](() => {
|
|
54
|
+
if (contentRef.current) {
|
|
55
|
+
setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
|
|
56
|
+
}
|
|
57
|
+
function handler() {
|
|
58
|
+
if (contentRef.current) {
|
|
59
|
+
setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const debouncedHandler = debounce__default["default"](handler, 200);
|
|
63
|
+
window.addEventListener('resize', debouncedHandler);
|
|
64
|
+
return () => {
|
|
65
|
+
debouncedHandler.cancel();
|
|
66
|
+
window.removeEventListener('resize', debouncedHandler);
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
69
|
+
const hasScrollingContentProps = hasScrollingContent || isScrollable ? {
|
|
43
70
|
tabIndex: 0,
|
|
44
71
|
role: 'region'
|
|
45
72
|
} : {};
|
|
46
|
-
return /*#__PURE__*/React__default["default"].createElement(
|
|
73
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
47
74
|
className: contentClass
|
|
48
75
|
}, hasScrollingContentProps, rest, {
|
|
49
|
-
ref: ref
|
|
50
|
-
}), children)
|
|
51
|
-
className: `${prefix}--modal-content--overflow-indicator`
|
|
52
|
-
}));
|
|
76
|
+
ref: mergeRefs["default"](contentRef, ref)
|
|
77
|
+
}), children);
|
|
53
78
|
});
|
|
54
79
|
ModalBody.propTypes = {
|
|
55
80
|
/**
|
|
@@ -53,6 +53,7 @@ export interface DataTableRow<ColTypes extends any[]> {
|
|
|
53
53
|
export interface DataTableHeader {
|
|
54
54
|
key: string;
|
|
55
55
|
header: React.ReactNode;
|
|
56
|
+
slug?: React.ReactElement;
|
|
56
57
|
}
|
|
57
58
|
export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
|
|
58
59
|
headers: Array<DataTableHeader>;
|
|
@@ -152,6 +153,12 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
|
|
|
152
153
|
stickyHeader?: boolean;
|
|
153
154
|
useStaticWidth?: boolean;
|
|
154
155
|
};
|
|
156
|
+
getCellProps: (getCellPropsArgs: {
|
|
157
|
+
cell: DataTableCell<ColTypes>;
|
|
158
|
+
}) => {
|
|
159
|
+
[key: string]: unknown;
|
|
160
|
+
hasSlugHeader?: boolean;
|
|
161
|
+
};
|
|
155
162
|
onInputChange: (e: React.ChangeEvent<HTMLInputElement>, defaultValue?: string) => void;
|
|
156
163
|
sortBy: (headerKey: string) => void;
|
|
157
164
|
selectAll: () => void;
|
|
@@ -334,6 +341,7 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
|
|
|
334
341
|
sortDirection: DataTableSortState;
|
|
335
342
|
isSortable: boolean | undefined;
|
|
336
343
|
isSortHeader: boolean;
|
|
344
|
+
slug: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
337
345
|
onClick: (event: any) => void;
|
|
338
346
|
};
|
|
339
347
|
/**
|
|
@@ -468,6 +476,19 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
|
|
|
468
476
|
stickyHeader: boolean | undefined;
|
|
469
477
|
useStaticWidth: boolean | undefined;
|
|
470
478
|
};
|
|
479
|
+
/**
|
|
480
|
+
* Get the props associated with the given table cell.
|
|
481
|
+
*
|
|
482
|
+
* @param {object} config
|
|
483
|
+
* @param {object} config.cell the cell we want the props for
|
|
484
|
+
* @returns {object}
|
|
485
|
+
*/
|
|
486
|
+
getCellProps: ({ cell, ...rest }: {
|
|
487
|
+
[x: string]: any;
|
|
488
|
+
cell: any;
|
|
489
|
+
}) => {
|
|
490
|
+
hasSlugHeader: any;
|
|
491
|
+
};
|
|
471
492
|
/**
|
|
472
493
|
* Helper utility to get all the currently selected rows
|
|
473
494
|
* @returns {Array<string>} the array of rowIds that are currently selected
|