@carbon/react 1.49.0 → 1.50.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 +1074 -996
- package/es/components/Accordion/AccordionItem.js +10 -15
- package/es/components/Button/Button.js +3 -2
- package/es/components/ChatButton/ChatButton.Skeleton.js +40 -0
- package/es/components/ChatButton/ChatButton.js +81 -0
- package/es/components/ComboButton/index.js +14 -0
- package/es/components/ContainedList/ContainedList.js +5 -3
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +5 -3
- 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/tools/normalize.js +3 -1
- package/es/components/Menu/Menu.d.ts +9 -1
- package/es/components/Menu/Menu.js +34 -0
- package/es/components/MenuButton/index.js +13 -0
- package/es/components/MultiSelect/MultiSelect.js +2 -1
- package/es/components/Notification/Notification.d.ts +75 -0
- package/es/components/Notification/Notification.js +84 -2
- package/es/components/Notification/index.d.ts +1 -1
- package/es/components/OverflowMenu/next/index.js +16 -2
- package/es/index.d.ts +1 -0
- package/es/index.js +3 -1
- package/es/internal/useNoInteractiveChildren.js +13 -1
- package/lib/components/Accordion/AccordionItem.js +9 -14
- package/lib/components/Button/Button.js +3 -2
- package/lib/components/ChatButton/ChatButton.Skeleton.js +50 -0
- package/lib/components/ChatButton/ChatButton.js +91 -0
- package/lib/components/ComboButton/index.js +14 -0
- package/lib/components/ContainedList/ContainedList.js +5 -3
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +5 -3
- 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/tools/normalize.js +3 -1
- package/lib/components/Menu/Menu.d.ts +9 -1
- package/lib/components/Menu/Menu.js +34 -0
- package/lib/components/MenuButton/index.js +13 -0
- package/lib/components/MultiSelect/MultiSelect.js +2 -1
- package/lib/components/Notification/Notification.d.ts +75 -0
- package/lib/components/Notification/Notification.js +83 -0
- package/lib/components/Notification/index.d.ts +1 -1
- package/lib/components/OverflowMenu/next/index.js +16 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +5 -0
- package/lib/internal/useNoInteractiveChildren.js +13 -0
- package/package.json +5 -5
- package/scss/components/chat-button/_chat-button.scss +9 -0
- package/scss/components/chat-button/_index.scss +9 -0
|
@@ -113,6 +113,7 @@ class DataTable extends React__default["default"].Component {
|
|
|
113
113
|
sortDirection,
|
|
114
114
|
isSortable,
|
|
115
115
|
isSortHeader: sortHeaderKey === header.key,
|
|
116
|
+
slug: header.slug,
|
|
116
117
|
onClick: event => {
|
|
117
118
|
const nextSortState = sorting.getNextSortState(this.props, this.state, {
|
|
118
119
|
key: header.key
|
|
@@ -349,6 +350,23 @@ class DataTable extends React__default["default"].Component {
|
|
|
349
350
|
useStaticWidth
|
|
350
351
|
};
|
|
351
352
|
});
|
|
353
|
+
/**
|
|
354
|
+
* Get the props associated with the given table cell.
|
|
355
|
+
*
|
|
356
|
+
* @param {object} config
|
|
357
|
+
* @param {object} config.cell the cell we want the props for
|
|
358
|
+
* @returns {object}
|
|
359
|
+
*/
|
|
360
|
+
_rollupPluginBabelHelpers.defineProperty(this, "getCellProps", _ref4 => {
|
|
361
|
+
let {
|
|
362
|
+
cell,
|
|
363
|
+
...rest
|
|
364
|
+
} = _ref4;
|
|
365
|
+
return {
|
|
366
|
+
...rest,
|
|
367
|
+
hasSlugHeader: cell.hasSlugHeader
|
|
368
|
+
};
|
|
369
|
+
});
|
|
352
370
|
/**
|
|
353
371
|
* Helper utility to get all the currently selected rows
|
|
354
372
|
* @returns {Array<string>} the array of rowIds that are currently selected
|
|
@@ -622,6 +640,7 @@ class DataTable extends React__default["default"].Component {
|
|
|
622
640
|
getBatchActionProps: this.getBatchActionProps,
|
|
623
641
|
getTableProps: this.getTableProps,
|
|
624
642
|
getTableContainerProps: this.getTableContainerProps,
|
|
643
|
+
getCellProps: this.getCellProps,
|
|
625
644
|
// Custom event handlers
|
|
626
645
|
onInputChange: this.handleOnInputValueChange,
|
|
627
646
|
// Expose internal state change actions
|
|
@@ -4,7 +4,32 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { ReactAttr } from '../../types/common';
|
|
9
|
+
interface TableCellProps extends ReactAttr<HTMLTableCellElement> {
|
|
10
|
+
/**
|
|
11
|
+
* Pass in children that will be embedded in the table header label
|
|
12
|
+
*/
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Specify an optional className to be applied to the container node
|
|
16
|
+
*/
|
|
17
|
+
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The width of the expanded row's internal cell
|
|
20
|
+
*/
|
|
21
|
+
colSpan?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Specify if the table cell is in an AI column
|
|
24
|
+
*/
|
|
25
|
+
hasSlugHeader?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43
|
|
28
|
+
*/
|
|
29
|
+
headers?: string;
|
|
30
|
+
}
|
|
31
|
+
declare const TableCell: {
|
|
32
|
+
({ children, className, hasSlugHeader, colSpan, ...rest }: TableCellProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
10
35
|
export default TableCell;
|
|
@@ -9,11 +9,33 @@
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
+
var React = require('react');
|
|
14
|
+
var cx = require('classnames');
|
|
15
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
+
|
|
19
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
20
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
21
|
+
|
|
22
|
+
const TableCell = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
children,
|
|
25
|
+
className,
|
|
26
|
+
hasSlugHeader,
|
|
27
|
+
colSpan,
|
|
28
|
+
...rest
|
|
29
|
+
} = _ref;
|
|
30
|
+
const prefix = usePrefix.usePrefix();
|
|
31
|
+
const tableCellClassNames = cx__default["default"](className, {
|
|
32
|
+
[`${prefix}--table-cell--column-slug`]: hasSlugHeader
|
|
33
|
+
});
|
|
34
|
+
return /*#__PURE__*/React__default["default"].createElement("td", _rollupPluginBabelHelpers["extends"]({
|
|
35
|
+
className: tableCellClassNames ? tableCellClassNames : undefined,
|
|
36
|
+
colSpan: colSpan
|
|
37
|
+
}, rest), children);
|
|
38
|
+
};
|
|
39
|
+
TableCell.displayName = 'TableCell';
|
|
18
40
|
|
|
19
41
|
exports["default"] = TableCell;
|
|
@@ -58,7 +58,7 @@ const TableExpandRow = /*#__PURE__*/React__default["default"].forwardRef((_ref,
|
|
|
58
58
|
[`${prefix}--parent-row`]: true,
|
|
59
59
|
[`${prefix}--expandable-row`]: isExpanded,
|
|
60
60
|
[`${prefix}--data-table--selected`]: isSelected,
|
|
61
|
-
[`${prefix}--
|
|
61
|
+
[`${prefix}--data-table--slug-row`]: rowHasSlug
|
|
62
62
|
}, rowClassName);
|
|
63
63
|
const previousValue = isExpanded ? 'collapsed' : undefined;
|
|
64
64
|
return /*#__PURE__*/React__default["default"].createElement("tr", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
@@ -134,13 +134,13 @@ const TableHeader = /*#__PURE__*/React__default["default"].forwardRef(function T
|
|
|
134
134
|
className: `${prefix}--table-sort__flex`
|
|
135
135
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
136
136
|
className: `${prefix}--table-header-label`
|
|
137
|
-
}, children),
|
|
137
|
+
}, children), /*#__PURE__*/React__default["default"].createElement(iconsReact.ArrowUp, {
|
|
138
138
|
size: 20,
|
|
139
139
|
className: `${prefix}--table-sort__icon`
|
|
140
140
|
}), /*#__PURE__*/React__default["default"].createElement(iconsReact.ArrowsVertical, {
|
|
141
141
|
size: 20,
|
|
142
142
|
className: `${prefix}--table-sort__icon-unsorted`
|
|
143
|
-
}))));
|
|
143
|
+
}), normalizedSlug)));
|
|
144
144
|
});
|
|
145
145
|
TableHeader.propTypes = {
|
|
146
146
|
/**
|
|
@@ -24,10 +24,21 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
24
24
|
|
|
25
25
|
const TableRow = props => {
|
|
26
26
|
const prefix = usePrefix.usePrefix();
|
|
27
|
+
let rowHasSlug;
|
|
28
|
+
if (props?.children) {
|
|
29
|
+
React__default["default"].Children.toArray(props.children).map(child => {
|
|
30
|
+
if (child.type?.displayName === 'TableSlugRow') {
|
|
31
|
+
if (child.props.slug) {
|
|
32
|
+
rowHasSlug = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
27
37
|
// Remove unnecessary props if provided to this component, these are
|
|
28
38
|
// only useful in `TableExpandRow`
|
|
29
39
|
const className = cx__default["default"](props.className, {
|
|
30
|
-
[`${prefix}--data-table--selected`]: props.isSelected
|
|
40
|
+
[`${prefix}--data-table--selected`]: props.isSelected,
|
|
41
|
+
[`${prefix}--data-table--slug-row`]: rowHasSlug
|
|
31
42
|
});
|
|
32
43
|
const cleanProps = {
|
|
33
44
|
...omit__default["default"](props, ['ariaLabel', 'aria-label', 'aria-controls', 'onExpand', 'isExpanded', 'isSelected']),
|
|
@@ -52,7 +52,8 @@ const normalize = function (rows, headers) {
|
|
|
52
52
|
}
|
|
53
53
|
headers.forEach((_ref, i) => {
|
|
54
54
|
let {
|
|
55
|
-
key
|
|
55
|
+
key,
|
|
56
|
+
slug
|
|
56
57
|
} = _ref;
|
|
57
58
|
const id = cells.getCellId(row.id, key);
|
|
58
59
|
// Initialize the cell info and state values, namely for editing
|
|
@@ -63,6 +64,7 @@ const normalize = function (rows, headers) {
|
|
|
63
64
|
isEditing: false,
|
|
64
65
|
isValid: true,
|
|
65
66
|
errors: null,
|
|
67
|
+
hasSlugHeader: !!slug,
|
|
66
68
|
info: {
|
|
67
69
|
header: key
|
|
68
70
|
}
|
|
@@ -4,8 +4,12 @@
|
|
|
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 React from 'react';
|
|
7
|
+
import React, { RefObject } from 'react';
|
|
8
8
|
interface MenuProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
9
|
+
/**
|
|
10
|
+
* The ref of the containing element, used for positioning and alignment of the menu
|
|
11
|
+
*/
|
|
12
|
+
containerRef?: RefObject<HTMLDivElement>;
|
|
9
13
|
/**
|
|
10
14
|
* A collection of MenuItems to be rendered within this Menu.
|
|
11
15
|
*/
|
|
@@ -18,6 +22,10 @@ interface MenuProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
|
18
22
|
* A label describing the Menu.
|
|
19
23
|
*/
|
|
20
24
|
label?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Specify how the menu should align with the button element
|
|
27
|
+
*/
|
|
28
|
+
menuAlignment?: string;
|
|
21
29
|
/**
|
|
22
30
|
* The mode of this menu. Defaults to full.
|
|
23
31
|
* `full` supports nesting and selectable menu items, but no icons.
|
|
@@ -34,7 +34,9 @@ const Menu = /*#__PURE__*/React__default["default"].forwardRef(function Menu(_re
|
|
|
34
34
|
let {
|
|
35
35
|
children,
|
|
36
36
|
className,
|
|
37
|
+
containerRef,
|
|
37
38
|
label,
|
|
39
|
+
menuAlignment,
|
|
38
40
|
mode = 'full',
|
|
39
41
|
onClose,
|
|
40
42
|
onOpen,
|
|
@@ -71,6 +73,15 @@ const Menu = /*#__PURE__*/React__default["default"].forwardRef(function Menu(_re
|
|
|
71
73
|
const [position, setPosition] = React.useState([-1, -1]);
|
|
72
74
|
const focusableItems = childContext.state.items.filter(item => !item.disabled && item.ref.current);
|
|
73
75
|
|
|
76
|
+
// Getting the width from the parent container element - controlled
|
|
77
|
+
let actionButtonWidth;
|
|
78
|
+
if (containerRef?.current) {
|
|
79
|
+
const {
|
|
80
|
+
width: w
|
|
81
|
+
} = containerRef.current.getBoundingClientRect();
|
|
82
|
+
actionButtonWidth = w;
|
|
83
|
+
}
|
|
84
|
+
|
|
74
85
|
// Set RTL based on document direction or `LayoutDirection`
|
|
75
86
|
const {
|
|
76
87
|
direction
|
|
@@ -184,6 +195,16 @@ const Menu = /*#__PURE__*/React__default["default"].forwardRef(function Menu(_re
|
|
|
184
195
|
}
|
|
185
196
|
};
|
|
186
197
|
|
|
198
|
+
// Avoid that the Menu render incorrectly when the postion is set in the right side of the screen
|
|
199
|
+
if (actionButtonWidth && actionButtonWidth < axes.x.size && (menuAlignment === 'bottom' || menuAlignment === 'top')) {
|
|
200
|
+
axes.x.size = actionButtonWidth;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// if 'axes.x.anchor' is lower than 87px dynamically switch render side
|
|
204
|
+
if (actionButtonWidth && (menuAlignment === 'bottom-end' || menuAlignment === 'top-end') && axes.x.anchor >= 87 && actionButtonWidth < axes.x.size) {
|
|
205
|
+
const diff = axes.x.anchor + axes.x.reversedAnchor;
|
|
206
|
+
axes.x.anchor = axes.x.anchor + diff;
|
|
207
|
+
}
|
|
187
208
|
const {
|
|
188
209
|
max,
|
|
189
210
|
size,
|
|
@@ -200,6 +221,14 @@ const Menu = /*#__PURE__*/React__default["default"].forwardRef(function Menu(_re
|
|
|
200
221
|
reversedAnchor - size >= 0 ? reversedAnchor - size + offset : false,
|
|
201
222
|
// align at max (second fallback)
|
|
202
223
|
max - spacing - size];
|
|
224
|
+
const topAlignment = menuAlignment === 'top' || menuAlignment === 'top-end' || menuAlignment === 'top-start';
|
|
225
|
+
|
|
226
|
+
// If the tooltip is not visible in the top, switch to the bototm
|
|
227
|
+
if (typeof options[0] === 'number' && topAlignment && options[0] >= 0 && !options[1] && axis === 'y') {
|
|
228
|
+
menu.current.style.transform = 'translate(0)';
|
|
229
|
+
} else if (topAlignment && !options[0] && axis === 'y') {
|
|
230
|
+
options[0] = anchor - offset;
|
|
231
|
+
}
|
|
203
232
|
|
|
204
233
|
// Previous array `options`, has at least one item that is a number (the last one - second fallback).
|
|
205
234
|
// That guarantees that the return of `find()` will always be a number
|
|
@@ -254,6 +283,7 @@ const Menu = /*#__PURE__*/React__default["default"].forwardRef(function Menu(_re
|
|
|
254
283
|
// visibility is needed for focusing elements.
|
|
255
284
|
// opacity is only set once the position has been set correctly
|
|
256
285
|
// to avoid a flicker effect when opening.
|
|
286
|
+
[`${prefix}--menu--box-shadow-top`]: menuAlignment && menuAlignment.slice(0, 3) === 'top',
|
|
257
287
|
[`${prefix}--menu--open`]: open,
|
|
258
288
|
[`${prefix}--menu--shown`]: position[0] >= 0 && position[1] >= 0,
|
|
259
289
|
[`${prefix}--menu--with-icons`]: childContext.state.hasIcons
|
|
@@ -284,6 +314,10 @@ Menu.propTypes = {
|
|
|
284
314
|
* A label describing the Menu.
|
|
285
315
|
*/
|
|
286
316
|
label: PropTypes__default["default"].string,
|
|
317
|
+
/**
|
|
318
|
+
* Specify how the menu should align with the button element
|
|
319
|
+
*/
|
|
320
|
+
menuAlignment: PropTypes__default["default"].string,
|
|
287
321
|
/**
|
|
288
322
|
* The mode of this menu. Defaults to full.
|
|
289
323
|
* `full` supports nesting and selectable menu items, but no icons.
|
|
@@ -40,6 +40,7 @@ const MenuButton = /*#__PURE__*/React__default["default"].forwardRef(function Me
|
|
|
40
40
|
kind = defaultButtonKind,
|
|
41
41
|
label,
|
|
42
42
|
size = 'lg',
|
|
43
|
+
menuAlignment = 'bottom',
|
|
43
44
|
tabIndex = 0,
|
|
44
45
|
...rest
|
|
45
46
|
} = _ref;
|
|
@@ -68,11 +69,16 @@ const MenuButton = /*#__PURE__*/React__default["default"].forwardRef(function Me
|
|
|
68
69
|
}
|
|
69
70
|
function handleOpen() {
|
|
70
71
|
menuRef.current.style.inlineSize = `${width}px`;
|
|
72
|
+
menuRef.current.style.minInlineSize = `${width}px`;
|
|
73
|
+
if (menuAlignment !== 'bottom' && menuAlignment !== 'top') {
|
|
74
|
+
menuRef.current.style.inlineSize = `fit-content`;
|
|
75
|
+
}
|
|
71
76
|
}
|
|
72
77
|
const containerClasses = cx__default["default"](`${prefix}--menu-button__container`, className);
|
|
73
78
|
const triggerClasses = cx__default["default"](`${prefix}--menu-button__trigger`, {
|
|
74
79
|
[`${prefix}--menu-button__trigger--open`]: open
|
|
75
80
|
});
|
|
81
|
+
const menuClasses = cx__default["default"](`${prefix}--menu-button__${menuAlignment}`);
|
|
76
82
|
const buttonKind = validButtonKinds.includes(kind) ? kind : defaultButtonKind;
|
|
77
83
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
78
84
|
ref: ref,
|
|
@@ -91,6 +97,9 @@ const MenuButton = /*#__PURE__*/React__default["default"].forwardRef(function Me
|
|
|
91
97
|
onMouseDown: handleMousedown,
|
|
92
98
|
"aria-controls": open ? id : null
|
|
93
99
|
}, label), /*#__PURE__*/React__default["default"].createElement(Menu.Menu, {
|
|
100
|
+
containerRef: triggerRef,
|
|
101
|
+
menuAlignment: menuAlignment,
|
|
102
|
+
className: menuClasses,
|
|
94
103
|
ref: menuRef,
|
|
95
104
|
id: id,
|
|
96
105
|
label: label,
|
|
@@ -124,6 +133,10 @@ MenuButton.propTypes = {
|
|
|
124
133
|
* Provide the label to be renderd on the trigger button.
|
|
125
134
|
*/
|
|
126
135
|
label: PropTypes__default["default"].string.isRequired,
|
|
136
|
+
/**
|
|
137
|
+
* Experimental property. Specify how the menu should align with the button element
|
|
138
|
+
*/
|
|
139
|
+
menuAlignment: PropTypes__default["default"].oneOf(['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end']),
|
|
127
140
|
/**
|
|
128
141
|
* Specify the size of the button and menu.
|
|
129
142
|
*/
|
|
@@ -317,13 +317,14 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
317
317
|
size: 'mini'
|
|
318
318
|
});
|
|
319
319
|
}
|
|
320
|
+
const itemsSelectedText = selectedItems.length > 0 && selectedItems.map(item => item.text);
|
|
320
321
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
321
322
|
className: wrapperClasses
|
|
322
323
|
}, /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
323
324
|
className: titleClasses
|
|
324
325
|
}, getLabelProps()), titleText && titleText, selectedItems.length > 0 && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
325
326
|
className: `${prefix}--visually-hidden`
|
|
326
|
-
}, clearSelectionDescription, " ", selectedItems.length, ",", clearSelectionText)), /*#__PURE__*/React__default["default"].createElement(index["default"], {
|
|
327
|
+
}, clearSelectionDescription, " ", selectedItems.length, ' ', itemsSelectedText, ",", clearSelectionText)), /*#__PURE__*/React__default["default"].createElement(index["default"], {
|
|
327
328
|
onFocus: isFluid ? handleFocus : undefined,
|
|
328
329
|
onBlur: isFluid ? handleFocus : undefined,
|
|
329
330
|
type: type,
|
|
@@ -513,3 +513,78 @@ export declare namespace ActionableNotification {
|
|
|
513
513
|
title: PropTypes.Requireable<string>;
|
|
514
514
|
};
|
|
515
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* StaticNotification
|
|
518
|
+
* ==================
|
|
519
|
+
*/
|
|
520
|
+
export interface StaticNotificationProps extends HTMLAttributes<HTMLDivElement> {
|
|
521
|
+
/**
|
|
522
|
+
* Specify the content
|
|
523
|
+
*/
|
|
524
|
+
children?: ReactNode;
|
|
525
|
+
/**
|
|
526
|
+
* Specify an optional className to be applied to the notification box
|
|
527
|
+
*/
|
|
528
|
+
className?: string;
|
|
529
|
+
/**
|
|
530
|
+
* Specify what state the notification represents
|
|
531
|
+
*/
|
|
532
|
+
kind?: 'error' | 'info' | 'info-square' | 'success' | 'warning' | 'warning-alt';
|
|
533
|
+
/**
|
|
534
|
+
* Specify whether you are using the low contrast variant of the StaticNotification.
|
|
535
|
+
*/
|
|
536
|
+
lowContrast?: boolean;
|
|
537
|
+
/**
|
|
538
|
+
* Provide a description for "status" icon that can be read by screen readers
|
|
539
|
+
*/
|
|
540
|
+
statusIconDescription?: string;
|
|
541
|
+
/**
|
|
542
|
+
* Specify the subtitle
|
|
543
|
+
*/
|
|
544
|
+
subtitle?: string;
|
|
545
|
+
/**
|
|
546
|
+
* Specify the title
|
|
547
|
+
*/
|
|
548
|
+
title?: string;
|
|
549
|
+
/**
|
|
550
|
+
* Specify the id for the element containing the title
|
|
551
|
+
*/
|
|
552
|
+
titleId?: string;
|
|
553
|
+
}
|
|
554
|
+
export declare function StaticNotification({ children, title, titleId, subtitle, statusIconDescription, className, kind, lowContrast, ...rest }: StaticNotificationProps): import("react/jsx-runtime").JSX.Element;
|
|
555
|
+
export declare namespace StaticNotification {
|
|
556
|
+
var propTypes: {
|
|
557
|
+
/**
|
|
558
|
+
* Specify the content
|
|
559
|
+
*/
|
|
560
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
561
|
+
/**
|
|
562
|
+
* Specify an optional className to be applied to the notification box
|
|
563
|
+
*/
|
|
564
|
+
className: PropTypes.Requireable<string>;
|
|
565
|
+
/**
|
|
566
|
+
* Specify what state the notification represents
|
|
567
|
+
*/
|
|
568
|
+
kind: PropTypes.Requireable<string>;
|
|
569
|
+
/**
|
|
570
|
+
* Specify whether you are using the low contrast variant of the StaticNotification.
|
|
571
|
+
*/
|
|
572
|
+
lowContrast: PropTypes.Requireable<boolean>;
|
|
573
|
+
/**
|
|
574
|
+
* Provide a description for "status" icon that can be read by screen readers
|
|
575
|
+
*/
|
|
576
|
+
statusIconDescription: PropTypes.Requireable<string>;
|
|
577
|
+
/**
|
|
578
|
+
* Specify the subtitle
|
|
579
|
+
*/
|
|
580
|
+
subtitle: PropTypes.Requireable<string>;
|
|
581
|
+
/**
|
|
582
|
+
* Specify the title
|
|
583
|
+
*/
|
|
584
|
+
title: PropTypes.Requireable<string>;
|
|
585
|
+
/**
|
|
586
|
+
* Specify the id for the element containing the title
|
|
587
|
+
*/
|
|
588
|
+
titleId: PropTypes.Requireable<string>;
|
|
589
|
+
};
|
|
590
|
+
}
|
|
@@ -688,8 +688,91 @@ ActionableNotification.propTypes = {
|
|
|
688
688
|
title: PropTypes__default["default"].string
|
|
689
689
|
};
|
|
690
690
|
|
|
691
|
+
/**
|
|
692
|
+
* StaticNotification
|
|
693
|
+
* ==================
|
|
694
|
+
*/
|
|
695
|
+
|
|
696
|
+
function StaticNotification(_ref8) {
|
|
697
|
+
let {
|
|
698
|
+
children,
|
|
699
|
+
title,
|
|
700
|
+
titleId,
|
|
701
|
+
subtitle,
|
|
702
|
+
statusIconDescription,
|
|
703
|
+
className,
|
|
704
|
+
kind = 'error',
|
|
705
|
+
lowContrast,
|
|
706
|
+
...rest
|
|
707
|
+
} = _ref8;
|
|
708
|
+
const prefix = usePrefix.usePrefix();
|
|
709
|
+
const containerClassName = cx__default["default"](className, {
|
|
710
|
+
[`${prefix}--inline-notification`]: true,
|
|
711
|
+
[`${prefix}--inline-notification--low-contrast`]: lowContrast,
|
|
712
|
+
[`${prefix}--inline-notification--${kind}`]: kind,
|
|
713
|
+
[`${prefix}--inline-notification--hide-close-button`]: true
|
|
714
|
+
});
|
|
715
|
+
const ref = React.useRef(null);
|
|
716
|
+
useNoInteractiveChildren.useInteractiveChildrenNeedDescription(ref, `interactive child node(s) should have an \`aria-describedby\` property with a value matching the value of \`titleId\``);
|
|
717
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
718
|
+
ref: ref
|
|
719
|
+
}, rest, {
|
|
720
|
+
className: containerClassName
|
|
721
|
+
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
722
|
+
className: `${prefix}--inline-notification__details`
|
|
723
|
+
}, /*#__PURE__*/React__default["default"].createElement(NotificationIcon, {
|
|
724
|
+
notificationType: "inline",
|
|
725
|
+
kind: kind,
|
|
726
|
+
iconDescription: statusIconDescription || `${kind} icon`
|
|
727
|
+
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
728
|
+
className: `${prefix}--inline-notification__text-wrapper`
|
|
729
|
+
}, title && /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
730
|
+
as: "div",
|
|
731
|
+
id: titleId,
|
|
732
|
+
className: `${prefix}--inline-notification__title`
|
|
733
|
+
}, title), subtitle && /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
734
|
+
as: "div",
|
|
735
|
+
className: `${prefix}--inline-notification__subtitle`
|
|
736
|
+
}, subtitle), children)));
|
|
737
|
+
}
|
|
738
|
+
StaticNotification.propTypes = {
|
|
739
|
+
/**
|
|
740
|
+
* Specify the content
|
|
741
|
+
*/
|
|
742
|
+
children: PropTypes__default["default"].node,
|
|
743
|
+
/**
|
|
744
|
+
* Specify an optional className to be applied to the notification box
|
|
745
|
+
*/
|
|
746
|
+
className: PropTypes__default["default"].string,
|
|
747
|
+
/**
|
|
748
|
+
* Specify what state the notification represents
|
|
749
|
+
*/
|
|
750
|
+
kind: PropTypes__default["default"].oneOf(['error', 'info', 'info-square', 'success', 'warning', 'warning-alt']),
|
|
751
|
+
/**
|
|
752
|
+
* Specify whether you are using the low contrast variant of the StaticNotification.
|
|
753
|
+
*/
|
|
754
|
+
lowContrast: PropTypes__default["default"].bool,
|
|
755
|
+
/**
|
|
756
|
+
* Provide a description for "status" icon that can be read by screen readers
|
|
757
|
+
*/
|
|
758
|
+
statusIconDescription: PropTypes__default["default"].string,
|
|
759
|
+
/**
|
|
760
|
+
* Specify the subtitle
|
|
761
|
+
*/
|
|
762
|
+
subtitle: PropTypes__default["default"].string,
|
|
763
|
+
/**
|
|
764
|
+
* Specify the title
|
|
765
|
+
*/
|
|
766
|
+
title: PropTypes__default["default"].string,
|
|
767
|
+
/**
|
|
768
|
+
* Specify the id for the element containing the title
|
|
769
|
+
*/
|
|
770
|
+
titleId: PropTypes__default["default"].string
|
|
771
|
+
};
|
|
772
|
+
|
|
691
773
|
exports.ActionableNotification = ActionableNotification;
|
|
692
774
|
exports.InlineNotification = InlineNotification;
|
|
693
775
|
exports.NotificationActionButton = NotificationActionButton;
|
|
694
776
|
exports.NotificationButton = NotificationButton;
|
|
777
|
+
exports.StaticNotification = StaticNotification;
|
|
695
778
|
exports.ToastNotification = ToastNotification;
|
|
@@ -4,4 +4,4 @@
|
|
|
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
|
-
export { NotificationActionButton, type NotificationActionButtonProps, NotificationButton, type NotificationButtonProps, ToastNotification, type ToastNotificationProps, InlineNotification, type InlineNotificationProps, ActionableNotification, type ActionableNotificationProps, } from './Notification';
|
|
7
|
+
export { NotificationActionButton, type NotificationActionButtonProps, NotificationButton, type NotificationButtonProps, ToastNotification, type ToastNotificationProps, InlineNotification, type InlineNotificationProps, ActionableNotification, type ActionableNotificationProps, StaticNotification, type StaticNotificationProps, } from './Notification';
|
|
@@ -35,6 +35,7 @@ const OverflowMenu = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
35
35
|
label = 'Options',
|
|
36
36
|
renderIcon: IconElement = iconsReact.OverflowMenuVertical,
|
|
37
37
|
size = defaultSize,
|
|
38
|
+
menuAlignment = 'bottom-start',
|
|
38
39
|
tooltipAlignment,
|
|
39
40
|
...rest
|
|
40
41
|
} = _ref;
|
|
@@ -45,11 +46,17 @@ const OverflowMenu = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
45
46
|
open,
|
|
46
47
|
x,
|
|
47
48
|
y,
|
|
48
|
-
handleClick,
|
|
49
|
+
handleClick: hookOnClick,
|
|
49
50
|
handleMousedown,
|
|
50
51
|
handleClose
|
|
51
52
|
} = useAttachedMenu.useAttachedMenu(triggerRef);
|
|
53
|
+
function handleTriggerClick() {
|
|
54
|
+
if (triggerRef.current) {
|
|
55
|
+
hookOnClick();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
52
58
|
const containerClasses = cx__default["default"](className, `${prefix}--overflow-menu__container`);
|
|
59
|
+
const menuClasses = cx__default["default"](`${prefix}--overflow-menu__${menuAlignment}`);
|
|
53
60
|
const triggerClasses = cx__default["default"](`${prefix}--overflow-menu`, {
|
|
54
61
|
[`${prefix}--overflow-menu--open`]: open
|
|
55
62
|
}, size !== defaultSize && `${prefix}--overflow-menu--${size}`);
|
|
@@ -62,7 +69,7 @@ const OverflowMenu = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
62
69
|
"aria-haspopup": true,
|
|
63
70
|
"aria-expanded": open,
|
|
64
71
|
className: triggerClasses,
|
|
65
|
-
onClick:
|
|
72
|
+
onClick: handleTriggerClick,
|
|
66
73
|
onMouseDown: handleMousedown,
|
|
67
74
|
ref: triggerRef,
|
|
68
75
|
label: label,
|
|
@@ -70,6 +77,9 @@ const OverflowMenu = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
70
77
|
}, /*#__PURE__*/React__default["default"].createElement(IconElement, {
|
|
71
78
|
className: `${prefix}--overflow-menu__icon`
|
|
72
79
|
})), /*#__PURE__*/React__default["default"].createElement(Menu.Menu, {
|
|
80
|
+
containerRef: triggerRef,
|
|
81
|
+
menuAlignment: menuAlignment,
|
|
82
|
+
className: menuClasses,
|
|
73
83
|
id: id,
|
|
74
84
|
size: size,
|
|
75
85
|
open: open,
|
|
@@ -92,6 +102,10 @@ OverflowMenu.propTypes = {
|
|
|
92
102
|
* A label describing the options available. Is used in the trigger tooltip and as the menu's accessible label.
|
|
93
103
|
*/
|
|
94
104
|
label: PropTypes__default["default"].string,
|
|
105
|
+
/**
|
|
106
|
+
* Experimental property. Specify how the menu should align with the button element
|
|
107
|
+
*/
|
|
108
|
+
menuAlignment: PropTypes__default["default"].oneOf(['top-start', 'top-end', 'bottom-start', 'bottom-end']),
|
|
95
109
|
/**
|
|
96
110
|
* Otionally provide a custom icon to be rendered on the trigger button.
|
|
97
111
|
*/
|
package/lib/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/lib/index.js
CHANGED
|
@@ -193,6 +193,8 @@ var FluidTimePicker_Skeleton = require('./components/FluidTimePicker/FluidTimePi
|
|
|
193
193
|
var FluidTimePickerSelect = require('./components/FluidTimePickerSelect/FluidTimePickerSelect.js');
|
|
194
194
|
var LayoutDirection = require('./components/LayoutDirection/LayoutDirection.js');
|
|
195
195
|
var useLayoutDirection = require('./components/LayoutDirection/useLayoutDirection.js');
|
|
196
|
+
var ChatButton = require('./components/ChatButton/ChatButton.js');
|
|
197
|
+
var ChatButton_Skeleton = require('./components/ChatButton/ChatButton.Skeleton.js');
|
|
196
198
|
var Text = require('./components/Text/Text.js');
|
|
197
199
|
var TextDirection = require('./components/Text/TextDirection.js');
|
|
198
200
|
var DataTable = require('./components/DataTable/DataTable.js');
|
|
@@ -300,6 +302,7 @@ exports.ActionableNotification = Notification.ActionableNotification;
|
|
|
300
302
|
exports.InlineNotification = Notification.InlineNotification;
|
|
301
303
|
exports.NotificationActionButton = Notification.NotificationActionButton;
|
|
302
304
|
exports.NotificationButton = Notification.NotificationButton;
|
|
305
|
+
exports.StaticNotification = Notification.StaticNotification;
|
|
303
306
|
exports.ToastNotification = Notification.ToastNotification;
|
|
304
307
|
exports.NumberInputSkeleton = NumberInput_Skeleton["default"];
|
|
305
308
|
exports.NumberInput = NumberInput.NumberInput;
|
|
@@ -456,6 +459,8 @@ exports.unstable__FluidTimePickerSkeleton = FluidTimePicker_Skeleton["default"];
|
|
|
456
459
|
exports.unstable__FluidTimePickerSelect = FluidTimePickerSelect["default"];
|
|
457
460
|
exports.unstable_LayoutDirection = LayoutDirection.LayoutDirection;
|
|
458
461
|
exports.unstable_useLayoutDirection = useLayoutDirection.useLayoutDirection;
|
|
462
|
+
exports.unstable__ChatButton = ChatButton["default"];
|
|
463
|
+
exports.unstable__ChatButtonSkeleton = ChatButton_Skeleton["default"];
|
|
459
464
|
exports.unstable_Text = Text.Text;
|
|
460
465
|
exports.unstable_TextDirection = TextDirection.TextDirection;
|
|
461
466
|
exports.DataTable = DataTable["default"];
|
|
@@ -23,6 +23,18 @@ function useNoInteractiveChildren(ref) {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
function useInteractiveChildrenNeedDescription(ref) {
|
|
27
|
+
let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : `interactive child node(s) should have an \`aria-describedby\` property`;
|
|
28
|
+
if (process.env.NODE_ENV !== "production") {
|
|
29
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
const node = ref.current ? getInteractiveContent(ref.current) : false;
|
|
32
|
+
if (node && !node.hasAttribute('aria-describedby')) {
|
|
33
|
+
throw new Error(`Error: ${message}.\n\nInstead found: ${node.outerHTML}`);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
26
38
|
|
|
27
39
|
/**
|
|
28
40
|
* Determines if a given DOM node has interactive content, or is itself
|
|
@@ -96,4 +108,5 @@ function isFocusable(element) {
|
|
|
96
108
|
|
|
97
109
|
exports.getInteractiveContent = getInteractiveContent;
|
|
98
110
|
exports.getRoleContent = getRoleContent;
|
|
111
|
+
exports.useInteractiveChildrenNeedDescription = useInteractiveChildrenNeedDescription;
|
|
99
112
|
exports.useNoInteractiveChildren = useNoInteractiveChildren;
|