@carbon/react 1.45.0 → 1.46.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 +922 -881
- package/README.md +9 -0
- package/es/components/ComposedModal/ComposedModal.d.ts +5 -0
- package/es/components/ComposedModal/ComposedModal.js +20 -3
- package/es/components/Grid/Column.js +2 -2
- package/es/components/Modal/Modal.d.ts +5 -0
- package/es/components/Modal/Modal.js +17 -3
- package/es/components/PaginationNav/PaginationNav.js +35 -2
- package/lib/components/ComposedModal/ComposedModal.d.ts +5 -0
- package/lib/components/ComposedModal/ComposedModal.js +20 -3
- package/lib/components/Grid/Column.js +2 -2
- package/lib/components/Modal/Modal.d.ts +5 -0
- package/lib/components/Modal/Modal.js +17 -3
- package/lib/components/PaginationNav/PaginationNav.js +35 -2
- package/package.json +7 -7
- package/telemetry.yml +816 -0
package/README.md
CHANGED
|
@@ -113,3 +113,12 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md)! 👀
|
|
|
113
113
|
## 📝 License
|
|
114
114
|
|
|
115
115
|
Licensed under the [Apache 2.0 License](/LICENSE).
|
|
116
|
+
|
|
117
|
+
## <picture><source height="20" width="20" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-dark.svg"><source height="20" width="20" media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg"><img height="20" width="20" alt="IBM Telemetry" src="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg"></picture> IBM Telemetry
|
|
118
|
+
|
|
119
|
+
This package uses IBM Telemetry to collect metrics data. By installing this
|
|
120
|
+
package as a dependency you are agreeing to telemetry collection. To opt out,
|
|
121
|
+
see
|
|
122
|
+
[Opting out of IBM Telemetry data collection](https://github.com/ibm-telemetry/telemetry-js/tree/main#opting-out-of-ibm-telemetry-data-collection).
|
|
123
|
+
For more information on the data being collected, please see the
|
|
124
|
+
[IBM Telemetry documentation](https://github.com/ibm-telemetry/telemetry-js/tree/main#ibm-telemetry-collection-basics).
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { type MouseEvent, type KeyboardEvent, type HTMLAttributes, type ReactNode, type RefObject } from 'react';
|
|
2
|
+
import { ReactNodeLike } from 'prop-types';
|
|
2
3
|
export interface ModalBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
4
|
/** Specify the content to be placed in the ModalBody. */
|
|
4
5
|
children?: ReactNode;
|
|
@@ -69,6 +70,10 @@ export interface ComposedModalProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
69
70
|
/** Specify the CSS selectors that match the floating menus. */
|
|
70
71
|
selectorsFloatingMenus?: Array<string | null | undefined>;
|
|
71
72
|
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
73
|
+
/**
|
|
74
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `ComposedModal` component
|
|
75
|
+
*/
|
|
76
|
+
slug?: ReactNodeLike;
|
|
72
77
|
}
|
|
73
78
|
declare const ComposedModal: React.ForwardRefExoticComponent<ComposedModalProps & React.RefAttributes<HTMLDivElement>>;
|
|
74
79
|
export default ComposedModal;
|
|
@@ -81,6 +81,7 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
|
|
|
81
81
|
selectorsFloatingMenus,
|
|
82
82
|
size,
|
|
83
83
|
launcherButtonRef,
|
|
84
|
+
slug,
|
|
84
85
|
...rest
|
|
85
86
|
} = _ref2;
|
|
86
87
|
const prefix = usePrefix();
|
|
@@ -149,7 +150,11 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
|
|
|
149
150
|
setIsOpen(false);
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
|
-
const modalClass = cx(`${prefix}--modal`,
|
|
153
|
+
const modalClass = cx(`${prefix}--modal`, {
|
|
154
|
+
'is-visible': isOpen,
|
|
155
|
+
[`${prefix}--modal--danger`]: danger,
|
|
156
|
+
[`${prefix}--modal--slug`]: slug
|
|
157
|
+
}, customClassName);
|
|
153
158
|
const containerClass = cx(`${prefix}--modal-container`, size && `${prefix}--modal-container--${size}`, isFullWidth && `${prefix}--modal-container--full-width`, containerClassName);
|
|
154
159
|
|
|
155
160
|
// Generate aria-label based on Modal Header label if one is not provided (L253)
|
|
@@ -202,6 +207,14 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
|
|
|
202
207
|
focusButton(innerModal.current);
|
|
203
208
|
}
|
|
204
209
|
}, [open, selectorPrimaryFocus, isOpen]);
|
|
210
|
+
|
|
211
|
+
// Slug is always size `lg`
|
|
212
|
+
let normalizedSlug;
|
|
213
|
+
if (slug && slug['type']?.displayName === 'Slug') {
|
|
214
|
+
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
215
|
+
size: 'lg'
|
|
216
|
+
});
|
|
217
|
+
}
|
|
205
218
|
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
|
206
219
|
role: "presentation",
|
|
207
220
|
ref: ref,
|
|
@@ -223,7 +236,7 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
|
|
|
223
236
|
}, "Focus sentinel"), /*#__PURE__*/React__default.createElement("div", {
|
|
224
237
|
ref: innerModal,
|
|
225
238
|
className: `${prefix}--modal-container-body`
|
|
226
|
-
}, childrenWithProps), /*#__PURE__*/React__default.createElement("button", {
|
|
239
|
+
}, normalizedSlug, childrenWithProps), /*#__PURE__*/React__default.createElement("button", {
|
|
227
240
|
type: "button",
|
|
228
241
|
ref: endSentinel,
|
|
229
242
|
className: `${prefix}--visually-hidden`
|
|
@@ -293,7 +306,11 @@ ComposedModal.propTypes = {
|
|
|
293
306
|
/**
|
|
294
307
|
* Specify the size variant.
|
|
295
308
|
*/
|
|
296
|
-
size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg'])
|
|
309
|
+
size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg']),
|
|
310
|
+
/**
|
|
311
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `ComposedModal` component
|
|
312
|
+
*/
|
|
313
|
+
slug: PropTypes.node
|
|
297
314
|
};
|
|
298
315
|
|
|
299
316
|
export { ModalBody, ComposedModal as default };
|
|
@@ -225,10 +225,10 @@ function getClassNameForBreakpoints(breakpoints, prefix) {
|
|
|
225
225
|
continue;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
// If our breakpoint is a string, the user
|
|
228
|
+
// If our breakpoint is a string, the user might have specified a percent
|
|
229
229
|
// they'd like this column to span.
|
|
230
230
|
if (typeof breakpoint === 'string') {
|
|
231
|
-
classNames.push(`${prefix}--${name}:col-span-${breakpoint.
|
|
231
|
+
classNames.push(`${prefix}--${name}:col-span-${breakpoint.replace('%', '')}`);
|
|
232
232
|
continue;
|
|
233
233
|
}
|
|
234
234
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
+
import { ReactNodeLike } from 'prop-types';
|
|
7
8
|
import React from 'react';
|
|
8
9
|
import { ReactAttr } from '../../types/common';
|
|
9
10
|
import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
|
|
@@ -150,6 +151,10 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
|
|
|
150
151
|
* Specify the size variant.
|
|
151
152
|
*/
|
|
152
153
|
size?: ModalSize;
|
|
154
|
+
/**
|
|
155
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `Modal` component
|
|
156
|
+
*/
|
|
157
|
+
slug?: ReactNodeLike;
|
|
153
158
|
}
|
|
154
159
|
declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLDivElement>>;
|
|
155
160
|
export default Modal;
|
|
@@ -59,6 +59,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
59
59
|
loadingDescription,
|
|
60
60
|
loadingIconDescription,
|
|
61
61
|
onLoadingSuccess = noopFn,
|
|
62
|
+
slug,
|
|
62
63
|
...rest
|
|
63
64
|
} = _ref;
|
|
64
65
|
const prefix = usePrefix();
|
|
@@ -124,7 +125,8 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
124
125
|
const modalClasses = cx(`${prefix}--modal`, {
|
|
125
126
|
[`${prefix}--modal-tall`]: !passiveModal,
|
|
126
127
|
'is-visible': open,
|
|
127
|
-
[`${prefix}--modal--danger`]: danger
|
|
128
|
+
[`${prefix}--modal--danger`]: danger,
|
|
129
|
+
[`${prefix}--modal--slug`]: slug
|
|
128
130
|
}, className);
|
|
129
131
|
const containerClasses = cx(`${prefix}--modal-container`, {
|
|
130
132
|
[`${prefix}--modal-container--${size}`]: size,
|
|
@@ -191,6 +193,14 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
191
193
|
focusButton(innerModal.current);
|
|
192
194
|
}
|
|
193
195
|
}, [open, selectorPrimaryFocus, danger, prefix]);
|
|
196
|
+
|
|
197
|
+
// Slug is always size `lg`
|
|
198
|
+
let normalizedSlug;
|
|
199
|
+
if (slug && slug['type']?.displayName === 'Slug') {
|
|
200
|
+
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
201
|
+
size: 'lg'
|
|
202
|
+
});
|
|
203
|
+
}
|
|
194
204
|
const modalButton = /*#__PURE__*/React__default.createElement("button", {
|
|
195
205
|
className: modalCloseButtonClass,
|
|
196
206
|
type: "button",
|
|
@@ -222,7 +232,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
222
232
|
as: "h3",
|
|
223
233
|
id: modalHeadingId,
|
|
224
234
|
className: `${prefix}--modal-header__heading`
|
|
225
|
-
}, modalHeading), !passiveModal && modalButton), /*#__PURE__*/React__default.createElement("div", _extends({
|
|
235
|
+
}, modalHeading), normalizedSlug, !passiveModal && modalButton), /*#__PURE__*/React__default.createElement("div", _extends({
|
|
226
236
|
id: modalBodyId,
|
|
227
237
|
className: contentClasses
|
|
228
238
|
}, hasScrollingContentProps), children), hasScrollingContent && /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -432,7 +442,11 @@ Modal.propTypes = {
|
|
|
432
442
|
/**
|
|
433
443
|
* Specify the size variant.
|
|
434
444
|
*/
|
|
435
|
-
size: PropTypes.oneOf(ModalSizes)
|
|
445
|
+
size: PropTypes.oneOf(ModalSizes),
|
|
446
|
+
/**
|
|
447
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `Modal` component
|
|
448
|
+
*/
|
|
449
|
+
slug: PropTypes.node
|
|
436
450
|
};
|
|
437
451
|
|
|
438
452
|
export { ModalSizes, Modal as default };
|
|
@@ -103,9 +103,28 @@ function PaginationOverflow(_ref3) {
|
|
|
103
103
|
fromIndex,
|
|
104
104
|
count,
|
|
105
105
|
onSelect,
|
|
106
|
+
// eslint-disable-next-line react/prop-types
|
|
107
|
+
disableOverflow,
|
|
106
108
|
translateWithId: t = translateWithId
|
|
107
109
|
} = _ref3;
|
|
108
110
|
const prefix = usePrefix();
|
|
111
|
+
|
|
112
|
+
//If overflow is disabled, return a select tag with no select options
|
|
113
|
+
if (disableOverflow === true && count > 1) {
|
|
114
|
+
return /*#__PURE__*/React__default.createElement("li", {
|
|
115
|
+
className: `${prefix}--pagination-nav__list-item`
|
|
116
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
117
|
+
className: `${prefix}--pagination-nav__select`
|
|
118
|
+
}, /*#__PURE__*/React__default.createElement("select", {
|
|
119
|
+
className: `${prefix}--pagination-nav__page ${prefix}--pagination-nav__page--select`,
|
|
120
|
+
"aria-label": `Select ${t('carbon.pagination-nav.item')} number`,
|
|
121
|
+
disabled: true
|
|
122
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
123
|
+
className: `${prefix}--pagination-nav__select-icon-wrapper`
|
|
124
|
+
}, /*#__PURE__*/React__default.createElement(OverflowMenuHorizontal, {
|
|
125
|
+
className: `${prefix}--pagination-nav__select-icon`
|
|
126
|
+
}))));
|
|
127
|
+
}
|
|
109
128
|
if (count > 1) {
|
|
110
129
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
111
130
|
className: `${prefix}--pagination-nav__list-item`
|
|
@@ -147,6 +166,7 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
147
166
|
className,
|
|
148
167
|
onChange = () => {},
|
|
149
168
|
totalItems,
|
|
169
|
+
disableOverflow,
|
|
150
170
|
itemsShown = 10,
|
|
151
171
|
page = 0,
|
|
152
172
|
loop = false,
|
|
@@ -158,6 +178,7 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
158
178
|
const [cuts, setCuts] = useState(getCuts(currentPage, totalItems, itemsThatFit));
|
|
159
179
|
const prevPage = usePrevious(currentPage);
|
|
160
180
|
const prefix = usePrefix();
|
|
181
|
+
const [isOverflowDisabled, setIsOverFlowDisabled] = useState(disableOverflow);
|
|
161
182
|
function jumpToItem(index) {
|
|
162
183
|
if (index >= 0 && index < totalItems) {
|
|
163
184
|
setCurrentPage(index);
|
|
@@ -216,6 +237,9 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
216
237
|
}
|
|
217
238
|
}, [currentPage]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
218
239
|
|
|
240
|
+
useEffect(() => {
|
|
241
|
+
setIsOverFlowDisabled(disableOverflow);
|
|
242
|
+
}, [disableOverflow]);
|
|
219
243
|
const classNames = cx(`${prefix}--pagination-nav`, className);
|
|
220
244
|
const backwardButtonDisabled = !loop && currentPage === 0;
|
|
221
245
|
const forwardButtonDisabled = !loop && currentPage === totalItems - 1;
|
|
@@ -245,7 +269,8 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
245
269
|
}), /*#__PURE__*/React__default.createElement(PaginationOverflow, {
|
|
246
270
|
fromIndex: startOffset,
|
|
247
271
|
count: cuts.front,
|
|
248
|
-
onSelect: jumpToItem
|
|
272
|
+
onSelect: jumpToItem,
|
|
273
|
+
disableOverflow: isOverflowDisabled
|
|
249
274
|
}),
|
|
250
275
|
// render items between overflows
|
|
251
276
|
[...Array(totalItems)].map((e, i) => i).slice(startOffset + cuts.front, (1 + cuts.back) * -1).map(item => /*#__PURE__*/React__default.createElement(PaginationItem, {
|
|
@@ -259,7 +284,8 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
259
284
|
})), /*#__PURE__*/React__default.createElement(PaginationOverflow, {
|
|
260
285
|
fromIndex: totalItems - cuts.back - 1,
|
|
261
286
|
count: cuts.back,
|
|
262
|
-
onSelect: jumpToItem
|
|
287
|
+
onSelect: jumpToItem,
|
|
288
|
+
disableOverflow: isOverflowDisabled
|
|
263
289
|
}),
|
|
264
290
|
// render last item unless there is only one in total
|
|
265
291
|
totalItems > 1 && /*#__PURE__*/React__default.createElement(PaginationItem, {
|
|
@@ -342,6 +368,13 @@ PaginationNav.propTypes = {
|
|
|
342
368
|
* Additional CSS class names.
|
|
343
369
|
*/
|
|
344
370
|
className: PropTypes.string,
|
|
371
|
+
/**
|
|
372
|
+
* If true, the '...' pagination overflow will not render page links between the first and last rendered buttons.
|
|
373
|
+
* Set this to true if you are having performance problems with large data sets.
|
|
374
|
+
*/
|
|
375
|
+
disableOverflow: PropTypes.bool,
|
|
376
|
+
// eslint-disable-line react/prop-types
|
|
377
|
+
|
|
345
378
|
/**
|
|
346
379
|
* The number of items to be shown.
|
|
347
380
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { type MouseEvent, type KeyboardEvent, type HTMLAttributes, type ReactNode, type RefObject } from 'react';
|
|
2
|
+
import { ReactNodeLike } from 'prop-types';
|
|
2
3
|
export interface ModalBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
4
|
/** Specify the content to be placed in the ModalBody. */
|
|
4
5
|
children?: ReactNode;
|
|
@@ -69,6 +70,10 @@ export interface ComposedModalProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
69
70
|
/** Specify the CSS selectors that match the floating menus. */
|
|
70
71
|
selectorsFloatingMenus?: Array<string | null | undefined>;
|
|
71
72
|
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
73
|
+
/**
|
|
74
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `ComposedModal` component
|
|
75
|
+
*/
|
|
76
|
+
slug?: ReactNodeLike;
|
|
72
77
|
}
|
|
73
78
|
declare const ComposedModal: React.ForwardRefExoticComponent<ComposedModalProps & React.RefAttributes<HTMLDivElement>>;
|
|
74
79
|
export default ComposedModal;
|
|
@@ -91,6 +91,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
91
91
|
selectorsFloatingMenus,
|
|
92
92
|
size,
|
|
93
93
|
launcherButtonRef,
|
|
94
|
+
slug,
|
|
94
95
|
...rest
|
|
95
96
|
} = _ref2;
|
|
96
97
|
const prefix = usePrefix.usePrefix();
|
|
@@ -159,7 +160,11 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
159
160
|
setIsOpen(false);
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
|
-
const modalClass = cx__default["default"](`${prefix}--modal`,
|
|
163
|
+
const modalClass = cx__default["default"](`${prefix}--modal`, {
|
|
164
|
+
'is-visible': isOpen,
|
|
165
|
+
[`${prefix}--modal--danger`]: danger,
|
|
166
|
+
[`${prefix}--modal--slug`]: slug
|
|
167
|
+
}, customClassName);
|
|
163
168
|
const containerClass = cx__default["default"](`${prefix}--modal-container`, size && `${prefix}--modal-container--${size}`, isFullWidth && `${prefix}--modal-container--full-width`, containerClassName);
|
|
164
169
|
|
|
165
170
|
// Generate aria-label based on Modal Header label if one is not provided (L253)
|
|
@@ -212,6 +217,14 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
212
217
|
focusButton(innerModal.current);
|
|
213
218
|
}
|
|
214
219
|
}, [open, selectorPrimaryFocus, isOpen]);
|
|
220
|
+
|
|
221
|
+
// Slug is always size `lg`
|
|
222
|
+
let normalizedSlug;
|
|
223
|
+
if (slug && slug['type']?.displayName === 'Slug') {
|
|
224
|
+
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
225
|
+
size: 'lg'
|
|
226
|
+
});
|
|
227
|
+
}
|
|
215
228
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
216
229
|
role: "presentation",
|
|
217
230
|
ref: ref,
|
|
@@ -233,7 +246,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
233
246
|
}, "Focus sentinel"), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
234
247
|
ref: innerModal,
|
|
235
248
|
className: `${prefix}--modal-container-body`
|
|
236
|
-
}, childrenWithProps), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
249
|
+
}, normalizedSlug, childrenWithProps), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
237
250
|
type: "button",
|
|
238
251
|
ref: endSentinel,
|
|
239
252
|
className: `${prefix}--visually-hidden`
|
|
@@ -303,7 +316,11 @@ ComposedModal.propTypes = {
|
|
|
303
316
|
/**
|
|
304
317
|
* Specify the size variant.
|
|
305
318
|
*/
|
|
306
|
-
size: PropTypes__default["default"].oneOf(['xs', 'sm', 'md', 'lg'])
|
|
319
|
+
size: PropTypes__default["default"].oneOf(['xs', 'sm', 'md', 'lg']),
|
|
320
|
+
/**
|
|
321
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `ComposedModal` component
|
|
322
|
+
*/
|
|
323
|
+
slug: PropTypes__default["default"].node
|
|
307
324
|
};
|
|
308
325
|
|
|
309
326
|
exports.ModalBody = ModalBody;
|
|
@@ -254,10 +254,10 @@ function getClassNameForBreakpoints(breakpoints, prefix) {
|
|
|
254
254
|
continue;
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
// If our breakpoint is a string, the user
|
|
257
|
+
// If our breakpoint is a string, the user might have specified a percent
|
|
258
258
|
// they'd like this column to span.
|
|
259
259
|
if (typeof breakpoint === 'string') {
|
|
260
|
-
classNames.push(`${prefix}--${name}:col-span-${breakpoint.
|
|
260
|
+
classNames.push(`${prefix}--${name}:col-span-${breakpoint.replace('%', '')}`);
|
|
261
261
|
continue;
|
|
262
262
|
}
|
|
263
263
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
+
import { ReactNodeLike } from 'prop-types';
|
|
7
8
|
import React from 'react';
|
|
8
9
|
import { ReactAttr } from '../../types/common';
|
|
9
10
|
import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
|
|
@@ -150,6 +151,10 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
|
|
|
150
151
|
* Specify the size variant.
|
|
151
152
|
*/
|
|
152
153
|
size?: ModalSize;
|
|
154
|
+
/**
|
|
155
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `Modal` component
|
|
156
|
+
*/
|
|
157
|
+
slug?: ReactNodeLike;
|
|
153
158
|
}
|
|
154
159
|
declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLDivElement>>;
|
|
155
160
|
export default Modal;
|
|
@@ -69,6 +69,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
|
|
|
69
69
|
loadingDescription,
|
|
70
70
|
loadingIconDescription,
|
|
71
71
|
onLoadingSuccess = noopFn.noopFn,
|
|
72
|
+
slug,
|
|
72
73
|
...rest
|
|
73
74
|
} = _ref;
|
|
74
75
|
const prefix = usePrefix.usePrefix();
|
|
@@ -134,7 +135,8 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
|
|
|
134
135
|
const modalClasses = cx__default["default"](`${prefix}--modal`, {
|
|
135
136
|
[`${prefix}--modal-tall`]: !passiveModal,
|
|
136
137
|
'is-visible': open,
|
|
137
|
-
[`${prefix}--modal--danger`]: danger
|
|
138
|
+
[`${prefix}--modal--danger`]: danger,
|
|
139
|
+
[`${prefix}--modal--slug`]: slug
|
|
138
140
|
}, className);
|
|
139
141
|
const containerClasses = cx__default["default"](`${prefix}--modal-container`, {
|
|
140
142
|
[`${prefix}--modal-container--${size}`]: size,
|
|
@@ -201,6 +203,14 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
|
|
|
201
203
|
focusButton(innerModal.current);
|
|
202
204
|
}
|
|
203
205
|
}, [open, selectorPrimaryFocus, danger, prefix]);
|
|
206
|
+
|
|
207
|
+
// Slug is always size `lg`
|
|
208
|
+
let normalizedSlug;
|
|
209
|
+
if (slug && slug['type']?.displayName === 'Slug') {
|
|
210
|
+
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
211
|
+
size: 'lg'
|
|
212
|
+
});
|
|
213
|
+
}
|
|
204
214
|
const modalButton = /*#__PURE__*/React__default["default"].createElement("button", {
|
|
205
215
|
className: modalCloseButtonClass,
|
|
206
216
|
type: "button",
|
|
@@ -232,7 +242,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
|
|
|
232
242
|
as: "h3",
|
|
233
243
|
id: modalHeadingId,
|
|
234
244
|
className: `${prefix}--modal-header__heading`
|
|
235
|
-
}, modalHeading), !passiveModal && modalButton), /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
245
|
+
}, modalHeading), normalizedSlug, !passiveModal && modalButton), /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
236
246
|
id: modalBodyId,
|
|
237
247
|
className: contentClasses
|
|
238
248
|
}, hasScrollingContentProps), children), hasScrollingContent && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -442,7 +452,11 @@ Modal.propTypes = {
|
|
|
442
452
|
/**
|
|
443
453
|
* Specify the size variant.
|
|
444
454
|
*/
|
|
445
|
-
size: PropTypes__default["default"].oneOf(ModalSizes)
|
|
455
|
+
size: PropTypes__default["default"].oneOf(ModalSizes),
|
|
456
|
+
/**
|
|
457
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `Modal` component
|
|
458
|
+
*/
|
|
459
|
+
slug: PropTypes__default["default"].node
|
|
446
460
|
};
|
|
447
461
|
|
|
448
462
|
exports.ModalSizes = ModalSizes;
|
|
@@ -113,9 +113,28 @@ function PaginationOverflow(_ref3) {
|
|
|
113
113
|
fromIndex,
|
|
114
114
|
count,
|
|
115
115
|
onSelect,
|
|
116
|
+
// eslint-disable-next-line react/prop-types
|
|
117
|
+
disableOverflow,
|
|
116
118
|
translateWithId: t = translateWithId
|
|
117
119
|
} = _ref3;
|
|
118
120
|
const prefix = usePrefix.usePrefix();
|
|
121
|
+
|
|
122
|
+
//If overflow is disabled, return a select tag with no select options
|
|
123
|
+
if (disableOverflow === true && count > 1) {
|
|
124
|
+
return /*#__PURE__*/React__default["default"].createElement("li", {
|
|
125
|
+
className: `${prefix}--pagination-nav__list-item`
|
|
126
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
127
|
+
className: `${prefix}--pagination-nav__select`
|
|
128
|
+
}, /*#__PURE__*/React__default["default"].createElement("select", {
|
|
129
|
+
className: `${prefix}--pagination-nav__page ${prefix}--pagination-nav__page--select`,
|
|
130
|
+
"aria-label": `Select ${t('carbon.pagination-nav.item')} number`,
|
|
131
|
+
disabled: true
|
|
132
|
+
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
133
|
+
className: `${prefix}--pagination-nav__select-icon-wrapper`
|
|
134
|
+
}, /*#__PURE__*/React__default["default"].createElement(iconsReact.OverflowMenuHorizontal, {
|
|
135
|
+
className: `${prefix}--pagination-nav__select-icon`
|
|
136
|
+
}))));
|
|
137
|
+
}
|
|
119
138
|
if (count > 1) {
|
|
120
139
|
return /*#__PURE__*/React__default["default"].createElement("li", {
|
|
121
140
|
className: `${prefix}--pagination-nav__list-item`
|
|
@@ -157,6 +176,7 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
157
176
|
className,
|
|
158
177
|
onChange = () => {},
|
|
159
178
|
totalItems,
|
|
179
|
+
disableOverflow,
|
|
160
180
|
itemsShown = 10,
|
|
161
181
|
page = 0,
|
|
162
182
|
loop = false,
|
|
@@ -168,6 +188,7 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
168
188
|
const [cuts, setCuts] = React.useState(getCuts(currentPage, totalItems, itemsThatFit));
|
|
169
189
|
const prevPage = usePrevious(currentPage);
|
|
170
190
|
const prefix = usePrefix.usePrefix();
|
|
191
|
+
const [isOverflowDisabled, setIsOverFlowDisabled] = React.useState(disableOverflow);
|
|
171
192
|
function jumpToItem(index) {
|
|
172
193
|
if (index >= 0 && index < totalItems) {
|
|
173
194
|
setCurrentPage(index);
|
|
@@ -226,6 +247,9 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
226
247
|
}
|
|
227
248
|
}, [currentPage]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
228
249
|
|
|
250
|
+
React.useEffect(() => {
|
|
251
|
+
setIsOverFlowDisabled(disableOverflow);
|
|
252
|
+
}, [disableOverflow]);
|
|
229
253
|
const classNames = cx__default["default"](`${prefix}--pagination-nav`, className);
|
|
230
254
|
const backwardButtonDisabled = !loop && currentPage === 0;
|
|
231
255
|
const forwardButtonDisabled = !loop && currentPage === totalItems - 1;
|
|
@@ -255,7 +279,8 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
255
279
|
}), /*#__PURE__*/React__default["default"].createElement(PaginationOverflow, {
|
|
256
280
|
fromIndex: startOffset,
|
|
257
281
|
count: cuts.front,
|
|
258
|
-
onSelect: jumpToItem
|
|
282
|
+
onSelect: jumpToItem,
|
|
283
|
+
disableOverflow: isOverflowDisabled
|
|
259
284
|
}),
|
|
260
285
|
// render items between overflows
|
|
261
286
|
[...Array(totalItems)].map((e, i) => i).slice(startOffset + cuts.front, (1 + cuts.back) * -1).map(item => /*#__PURE__*/React__default["default"].createElement(PaginationItem, {
|
|
@@ -269,7 +294,8 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
269
294
|
})), /*#__PURE__*/React__default["default"].createElement(PaginationOverflow, {
|
|
270
295
|
fromIndex: totalItems - cuts.back - 1,
|
|
271
296
|
count: cuts.back,
|
|
272
|
-
onSelect: jumpToItem
|
|
297
|
+
onSelect: jumpToItem,
|
|
298
|
+
disableOverflow: isOverflowDisabled
|
|
273
299
|
}),
|
|
274
300
|
// render last item unless there is only one in total
|
|
275
301
|
totalItems > 1 && /*#__PURE__*/React__default["default"].createElement(PaginationItem, {
|
|
@@ -352,6 +378,13 @@ PaginationNav.propTypes = {
|
|
|
352
378
|
* Additional CSS class names.
|
|
353
379
|
*/
|
|
354
380
|
className: PropTypes__default["default"].string,
|
|
381
|
+
/**
|
|
382
|
+
* If true, the '...' pagination overflow will not render page links between the first and last rendered buttons.
|
|
383
|
+
* Set this to true if you are having performance problems with large data sets.
|
|
384
|
+
*/
|
|
385
|
+
disableOverflow: PropTypes__default["default"].bool,
|
|
386
|
+
// eslint-disable-line react/prop-types
|
|
387
|
+
|
|
355
388
|
/**
|
|
356
389
|
* The number of items to be shown.
|
|
357
390
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.46.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"icons/index.esm.js",
|
|
21
21
|
"icons/index.d.ts",
|
|
22
22
|
"icons/package.json",
|
|
23
|
-
".playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json"
|
|
23
|
+
".playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json",
|
|
24
|
+
"telemetry.yml"
|
|
24
25
|
],
|
|
25
26
|
"keywords": [
|
|
26
27
|
"ibm",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
"scripts": {
|
|
37
38
|
"build": "yarn clean && node tasks/build-styles.js && node tasks/build.js",
|
|
38
39
|
"clean": "rimraf es lib icons/index.js icons/index.d.ts icons/index.esm.js storybook-static",
|
|
39
|
-
"postinstall": "
|
|
40
|
+
"postinstall": "npx -y @ibm/telemetry-js --config=telemetry.yml",
|
|
40
41
|
"storybook": "storybook dev -p 3000",
|
|
41
42
|
"storybook:build": "storybook build"
|
|
42
43
|
},
|
|
@@ -48,10 +49,9 @@
|
|
|
48
49
|
"dependencies": {
|
|
49
50
|
"@babel/runtime": "^7.18.3",
|
|
50
51
|
"@carbon/feature-flags": "^0.16.0",
|
|
51
|
-
"@carbon/icons-react": "^11.
|
|
52
|
+
"@carbon/icons-react": "^11.33.0",
|
|
52
53
|
"@carbon/layout": "^11.20.0",
|
|
53
|
-
"@carbon/styles": "^1.
|
|
54
|
-
"@carbon/telemetry": "0.1.0",
|
|
54
|
+
"@carbon/styles": "^1.46.0",
|
|
55
55
|
"classnames": "2.3.2",
|
|
56
56
|
"copy-to-clipboard": "^3.3.1",
|
|
57
57
|
"downshift": "8.2.3",
|
|
@@ -137,5 +137,5 @@
|
|
|
137
137
|
"**/*.scss",
|
|
138
138
|
"**/*.css"
|
|
139
139
|
],
|
|
140
|
-
"gitHead": "
|
|
140
|
+
"gitHead": "5dfe589ff6ce498c8f8040a55f05a15624e84df5"
|
|
141
141
|
}
|