@itwin/itwinui-react 3.2.4 → 3.3.1
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/CHANGELOG.md +28 -0
- package/cjs/core/ComboBox/ComboBox.d.ts +3 -1
- package/cjs/core/ComboBox/ComboBox.js +3 -4
- package/cjs/core/ComboBox/ComboBoxInputContainer.js +1 -1
- package/cjs/core/Dialog/DialogContent.d.ts +1 -2
- package/cjs/core/Dialog/DialogContent.js +1 -42
- package/cjs/core/Dialog/DialogContext.d.ts +1 -0
- package/cjs/core/Dialog/DialogMain.js +2 -24
- package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +7 -4
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +25 -12
- package/cjs/core/InputGrid/InputGrid.d.ts +7 -5
- package/cjs/core/InputGrid/InputGrid.js +175 -6
- package/cjs/core/InputGroup/InputGroup.d.ts +1 -1
- package/cjs/core/InputGroup/InputGroup.js +4 -13
- package/cjs/core/LabeledInput/LabeledInput.d.ts +1 -2
- package/cjs/core/LabeledInput/LabeledInput.js +11 -8
- package/cjs/core/LabeledSelect/LabeledSelect.d.ts +18 -0
- package/cjs/core/LabeledSelect/LabeledSelect.js +5 -20
- package/cjs/core/List/ListItem.d.ts +10 -0
- package/cjs/core/List/ListItem.js +14 -0
- package/cjs/core/Menu/MenuItem.d.ts +1 -1
- package/cjs/core/Modal/Modal.d.ts +3 -4
- package/cjs/core/Select/Select.js +2 -2
- package/cjs/core/StatusMessage/StatusMessage.d.ts +4 -2
- package/cjs/core/StatusMessage/StatusMessage.js +3 -1
- package/cjs/core/Table/Table.js +4 -0
- package/cjs/core/Table/TableCell.js +7 -22
- package/cjs/core/Table/columns/selectionColumn.d.ts +1 -1
- package/cjs/core/Table/columns/selectionColumn.js +3 -3
- package/cjs/core/Table/utils.d.ts +6 -0
- package/cjs/core/Table/utils.js +18 -1
- package/cjs/core/utils/components/InputWithIcon.d.ts +2 -0
- package/cjs/core/utils/components/InputWithIcon.js +11 -0
- package/cjs/core/utils/components/Portal.d.ts +5 -1
- package/cjs/core/utils/components/Portal.js +6 -2
- package/cjs/core/utils/components/index.d.ts +1 -0
- package/cjs/core/utils/components/index.js +1 -0
- package/esm/core/ComboBox/ComboBox.d.ts +3 -1
- package/esm/core/ComboBox/ComboBox.js +3 -3
- package/esm/core/ComboBox/ComboBoxInputContainer.js +2 -2
- package/esm/core/Dialog/DialogContent.d.ts +1 -2
- package/esm/core/Dialog/DialogContent.js +2 -17
- package/esm/core/Dialog/DialogContext.d.ts +1 -0
- package/esm/core/Dialog/DialogMain.js +3 -25
- package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +7 -4
- package/esm/core/ExpandableBlock/ExpandableBlock.js +26 -13
- package/esm/core/InputGrid/InputGrid.d.ts +7 -5
- package/esm/core/InputGrid/InputGrid.js +176 -7
- package/esm/core/InputGroup/InputGroup.d.ts +1 -1
- package/esm/core/InputGroup/InputGroup.js +5 -14
- package/esm/core/LabeledInput/LabeledInput.d.ts +1 -2
- package/esm/core/LabeledInput/LabeledInput.js +8 -9
- package/esm/core/LabeledSelect/LabeledSelect.d.ts +18 -0
- package/esm/core/LabeledSelect/LabeledSelect.js +5 -19
- package/esm/core/List/ListItem.d.ts +10 -0
- package/esm/core/List/ListItem.js +14 -0
- package/esm/core/Menu/MenuItem.d.ts +1 -1
- package/esm/core/Modal/Modal.d.ts +3 -4
- package/esm/core/Select/Select.js +3 -3
- package/esm/core/StatusMessage/StatusMessage.d.ts +4 -2
- package/esm/core/StatusMessage/StatusMessage.js +3 -1
- package/esm/core/Table/Table.js +5 -1
- package/esm/core/Table/TableCell.js +8 -23
- package/esm/core/Table/columns/selectionColumn.d.ts +1 -1
- package/esm/core/Table/columns/selectionColumn.js +3 -3
- package/esm/core/Table/utils.d.ts +6 -0
- package/esm/core/Table/utils.js +16 -0
- package/esm/core/utils/components/InputWithIcon.d.ts +2 -0
- package/esm/core/utils/components/InputWithIcon.js +8 -0
- package/esm/core/utils/components/Portal.d.ts +5 -1
- package/esm/core/utils/components/Portal.js +6 -2
- package/esm/core/utils/components/index.d.ts +1 -0
- package/esm/core/utils/components/index.js +1 -0
- package/package.json +3 -3
- package/styles.css +10 -10
|
@@ -10,6 +10,22 @@ export type LabeledSelectProps<T> = {
|
|
|
10
10
|
label?: React.ReactNode;
|
|
11
11
|
/**
|
|
12
12
|
* Message below the select. Does not apply to 'inline' select.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <caption>strings</caption>
|
|
16
|
+
* <LabeledSelect message='Positive Message' … />
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* <caption>Using StatusMessage for complete customization (e.g. icon)</caption>
|
|
20
|
+
* <LabeledSelect
|
|
21
|
+
* status="positive"
|
|
22
|
+
* message={
|
|
23
|
+
* <StatusMessage status="positive" startIcon={<SvgStar />}>
|
|
24
|
+
* Help message
|
|
25
|
+
* </StatusMessage>
|
|
26
|
+
* }
|
|
27
|
+
* …
|
|
28
|
+
* />
|
|
13
29
|
*/
|
|
14
30
|
message?: React.ReactNode;
|
|
15
31
|
/**
|
|
@@ -18,6 +34,8 @@ export type LabeledSelectProps<T> = {
|
|
|
18
34
|
*/
|
|
19
35
|
status?: 'positive' | 'warning' | 'negative';
|
|
20
36
|
/**
|
|
37
|
+
* @deprecated Pass a `<StatusMessage startIcon={svgIcon} />` to the `message` prop instead.
|
|
38
|
+
*
|
|
21
39
|
* Custom svg icon. Will override status icon if specified.
|
|
22
40
|
*/
|
|
23
41
|
svgIcon?: JSX.Element;
|
|
@@ -30,11 +30,9 @@ exports.LabeledSelect = void 0;
|
|
|
30
30
|
*--------------------------------------------------------------------------------------------*/
|
|
31
31
|
const React = __importStar(require("react"));
|
|
32
32
|
const Select_js_1 = require("../Select/Select.js");
|
|
33
|
-
const index_js_1 = require("../utils/index.js");
|
|
34
33
|
const StatusMessage_js_1 = require("../StatusMessage/StatusMessage.js");
|
|
35
34
|
const InputGrid_js_1 = require("../InputGrid/InputGrid.js");
|
|
36
35
|
const Label_js_1 = require("../Label/Label.js");
|
|
37
|
-
const Icon_js_1 = require("../Icon/Icon.js");
|
|
38
36
|
/**
|
|
39
37
|
* Labeled select component to select value from options.
|
|
40
38
|
* @example
|
|
@@ -69,23 +67,10 @@ const Icon_js_1 = require("../Icon/Icon.js");
|
|
|
69
67
|
* />
|
|
70
68
|
*/
|
|
71
69
|
exports.LabeledSelect = React.forwardRef((props, forwardedRef) => {
|
|
72
|
-
const { className, disabled = false, label, message, status, svgIcon, displayStyle = 'default', style, required = false,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
if (status && message) {
|
|
79
|
-
return index_js_1.StatusIconMap[status]();
|
|
80
|
-
}
|
|
81
|
-
return undefined;
|
|
82
|
-
};
|
|
83
|
-
return (React.createElement(InputGrid_js_1.InputGrid, { labelPlacement: displayStyle, ...wrapperProps },
|
|
84
|
-
label && (React.createElement(Label_js_1.Label, { as: 'div', required: required, disabled: disabled, id: labelId, ...labelProps }, label)),
|
|
85
|
-
React.createElement(Select_js_1.Select, { disabled: disabled, className: className, style: style, status: status, ...rest, ref: forwardedRef, triggerProps: {
|
|
86
|
-
'aria-labelledby': labelId,
|
|
87
|
-
...triggerProps,
|
|
88
|
-
} }),
|
|
89
|
-
typeof message === 'string' ? (React.createElement(StatusMessage_js_1.StatusMessage, { status: status, startIcon: displayStyle === 'default' ? icon() : undefined, iconProps: messageIconProps, contentProps: messageContentProps }, message)) : (message)));
|
|
70
|
+
const { className, disabled = false, label, message, status, svgIcon, displayStyle = 'default', style, required = false, wrapperProps, labelProps, messageContentProps, messageIconProps, ...rest } = props;
|
|
71
|
+
return (React.createElement(InputGrid_js_1.InputGrid, { labelPlacement: displayStyle, "data-iui-status": status, ...wrapperProps },
|
|
72
|
+
label && (React.createElement(Label_js_1.Label, { as: 'div', required: required, disabled: disabled, ...labelProps }, label)),
|
|
73
|
+
React.createElement(Select_js_1.Select, { disabled: disabled, className: className, style: style, ...rest, ref: forwardedRef }),
|
|
74
|
+
typeof message === 'string' ? (React.createElement(StatusMessage_js_1.StatusMessage, { status: status, startIcon: svgIcon, iconProps: messageIconProps, contentProps: messageContentProps }, message)) : (message)));
|
|
90
75
|
});
|
|
91
76
|
exports.default = exports.LabeledSelect;
|
|
@@ -68,4 +68,14 @@ export declare const ListItem: PolymorphicForwardRefComponent<"li", ListItemOwnP
|
|
|
68
68
|
* </ListItem>
|
|
69
69
|
*/
|
|
70
70
|
Description: PolymorphicForwardRefComponent<NonNullable<keyof JSX.IntrinsicElements>, {}>;
|
|
71
|
+
/**
|
|
72
|
+
* Wrapper over [LinkAction](https://itwinui.bentley.com/docs/linkaction) which allows rendering a link inside a ListItem.
|
|
73
|
+
* This ensures that clicking anywhere on the ListItem will trigger the link.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* <ListItem>
|
|
77
|
+
* <ListItem.Action href='https://example.com'>Example link</ListItem.Action>
|
|
78
|
+
* </ListItem>
|
|
79
|
+
*/
|
|
80
|
+
Action: PolymorphicForwardRefComponent<"a", {}>;
|
|
71
81
|
};
|
|
@@ -34,6 +34,7 @@ exports.ListItem = void 0;
|
|
|
34
34
|
const React = __importStar(require("react"));
|
|
35
35
|
const classnames_1 = __importDefault(require("classnames"));
|
|
36
36
|
const index_js_1 = require("../utils/index.js");
|
|
37
|
+
const LinkAction_js_1 = require("../LinkAction/LinkAction.js");
|
|
37
38
|
const ListItemComponent = React.forwardRef((props, ref) => {
|
|
38
39
|
const { size = 'default', disabled = false, active = false, actionable = false, focused = false, className, ...rest } = props;
|
|
39
40
|
return (React.createElement(index_js_1.Box, { as: 'li', className: (0, classnames_1.default)('iui-list-item', className), "data-iui-active": active ? 'true' : undefined, "data-iui-disabled": disabled ? 'true' : undefined, "data-iui-size": size === 'large' ? 'large' : undefined, "data-iui-actionable": actionable ? 'true' : undefined, "data-iui-focused": focused ? 'true' : undefined, ref: ref, ...rest }));
|
|
@@ -49,6 +50,9 @@ ListItemContent.displayName = 'ListItem.Content';
|
|
|
49
50
|
const ListItemDescription = (0, index_js_1.polymorphic)('iui-list-item-description');
|
|
50
51
|
ListItemDescription.displayName = 'ListItem.Description';
|
|
51
52
|
// ----------------------------------------------------------------------------
|
|
53
|
+
const ListItemAction = LinkAction_js_1.LinkAction;
|
|
54
|
+
ListItemAction.displayName = 'ListItem.Action';
|
|
55
|
+
// ----------------------------------------------------------------------------
|
|
52
56
|
// Exported compound component
|
|
53
57
|
/**
|
|
54
58
|
* A generic ListItem component that can be used simply for displaying data, or as a base
|
|
@@ -90,4 +94,14 @@ exports.ListItem = Object.assign(ListItemComponent, {
|
|
|
90
94
|
* </ListItem>
|
|
91
95
|
*/
|
|
92
96
|
Description: ListItemDescription,
|
|
97
|
+
/**
|
|
98
|
+
* Wrapper over [LinkAction](https://itwinui.bentley.com/docs/linkaction) which allows rendering a link inside a ListItem.
|
|
99
|
+
* This ensures that clicking anywhere on the ListItem will trigger the link.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* <ListItem>
|
|
103
|
+
* <ListItem.Action href='https://example.com'>Example link</ListItem.Action>
|
|
104
|
+
* </ListItem>
|
|
105
|
+
*/
|
|
106
|
+
Action: ListItemAction,
|
|
93
107
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
2
|
+
import type { PolymorphicForwardRefComponent, PortalProps } from '../utils/index.js';
|
|
3
3
|
import type { DialogMainProps } from '../Dialog/DialogMain.js';
|
|
4
4
|
type ModalProps = {
|
|
5
5
|
/**
|
|
@@ -33,12 +33,11 @@ type ModalProps = {
|
|
|
33
33
|
* If true, the dialog will be portaled into a <div> inside the nearest `ThemeProvider`.
|
|
34
34
|
*
|
|
35
35
|
* Can be set to an object with a `to` property to portal into a specific element.
|
|
36
|
+
* If `to`/`to()` === `null`/`undefined`, the default behavior will be used (i.e. as if `portal` is not passed).
|
|
36
37
|
*
|
|
37
38
|
* @default true
|
|
38
39
|
*/
|
|
39
|
-
portal?:
|
|
40
|
-
to: HTMLElement;
|
|
41
|
-
};
|
|
40
|
+
portal?: PortalProps['portal'];
|
|
42
41
|
/**
|
|
43
42
|
* Content of the modal.
|
|
44
43
|
*/
|
|
@@ -98,7 +98,7 @@ const isSingleOnChange = (onChange, multiple) => {
|
|
|
98
98
|
*/
|
|
99
99
|
exports.Select = React.forwardRef((props, forwardedRef) => {
|
|
100
100
|
const uid = (0, index_js_1.useId)();
|
|
101
|
-
const { options, value: valueProp, onChange: onChangeProp, placeholder, disabled = false, size, itemRenderer, selectedItemRenderer,
|
|
101
|
+
const { options, value: valueProp, onChange: onChangeProp, placeholder, disabled = false, size, itemRenderer, selectedItemRenderer, menuClassName, menuStyle, multiple = false, triggerProps, status, popoverProps, ...rest } = props;
|
|
102
102
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
103
103
|
const [liveRegionSelection, setLiveRegionSelection] = React.useState('');
|
|
104
104
|
const [uncontrolledValue, setUncontrolledValue] = React.useState();
|
|
@@ -189,7 +189,7 @@ exports.Select = React.forwardRef((props, forwardedRef) => {
|
|
|
189
189
|
onVisibleChange: (open) => (open ? show() : hide()),
|
|
190
190
|
});
|
|
191
191
|
return (React.createElement(React.Fragment, null,
|
|
192
|
-
React.createElement(index_js_1.
|
|
192
|
+
React.createElement(index_js_1.InputWithIcon, { ...rest, ref: (0, index_js_1.useMergedRefs)(popover.refs.setPositionReference, forwardedRef) },
|
|
193
193
|
React.createElement(index_js_1.Box, { ...popover.getReferenceProps(), tabIndex: 0, role: 'combobox', "data-iui-size": size, "data-iui-status": status, "aria-disabled": disabled, "aria-autocomplete": 'none', "aria-expanded": isOpen, "aria-haspopup": 'listbox', "aria-controls": `${uid}-menu`, ...triggerProps, ref: (0, index_js_1.useMergedRefs)(selectRef, triggerProps?.ref, popover.refs.setReference), className: (0, classnames_1.default)('iui-select-button', {
|
|
194
194
|
'iui-placeholder': (!selectedItems || selectedItems.length === 0) &&
|
|
195
195
|
!!placeholder,
|
|
@@ -4,9 +4,11 @@ import { Icon } from '../Icon/Icon.js';
|
|
|
4
4
|
type StatusMessageProps = {
|
|
5
5
|
/**
|
|
6
6
|
* Custom icon to be displayed at the beginning.
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
|
+
* - It will default to the `status` icon, if `status` is set.
|
|
9
|
+
* - If `startIcon` is set to `null`, no icon will be displayed, even if `status` is set.
|
|
8
10
|
*/
|
|
9
|
-
startIcon?: JSX.Element;
|
|
11
|
+
startIcon?: JSX.Element | null;
|
|
10
12
|
/**
|
|
11
13
|
* Message content.
|
|
12
14
|
*/
|
|
@@ -44,8 +44,10 @@ const Icon_js_1 = require("../Icon/Icon.js");
|
|
|
44
44
|
exports.StatusMessage = React.forwardRef((props, ref) => {
|
|
45
45
|
const { children, startIcon: userStartIcon, status, className, iconProps, contentProps, ...rest } = props;
|
|
46
46
|
const icon = userStartIcon ?? (status && index_js_1.StatusIconMap[status]());
|
|
47
|
+
// If user passes null, we don't want to show the icon
|
|
48
|
+
const shouldShowIcon = userStartIcon !== null && !!icon;
|
|
47
49
|
return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-status-message', className), "data-iui-status": status, ref: ref, ...rest },
|
|
48
|
-
|
|
50
|
+
shouldShowIcon ? (React.createElement(Icon_js_1.Icon, { "aria-hidden": true, ...iconProps }, icon)) : null,
|
|
49
51
|
React.createElement(index_js_1.Box, { ...contentProps }, children)));
|
|
50
52
|
});
|
|
51
53
|
exports.default = exports.StatusMessage;
|
package/cjs/core/Table/Table.js
CHANGED
|
@@ -429,6 +429,9 @@ const Table = (props) => {
|
|
|
429
429
|
React.createElement(index_js_1.Box, { as: 'div', ...headerProps, className: (0, classnames_1.default)('iui-table-header', headerProps?.className) },
|
|
430
430
|
React.createElement(index_js_1.Box, { ...headerGroupProps }, headerGroup.headers.map((column, index) => {
|
|
431
431
|
const { onClick, ...restSortProps } = column.getSortByToggleProps();
|
|
432
|
+
const columnHasExpanders = hasAnySubRows &&
|
|
433
|
+
index ===
|
|
434
|
+
headerGroup.headers.findIndex((c) => c.id !== index_js_5.SELECTION_CELL_ID);
|
|
432
435
|
const columnProps = column.getHeaderProps({
|
|
433
436
|
...restSortProps,
|
|
434
437
|
className: (0, classnames_1.default)('iui-table-cell', {
|
|
@@ -438,6 +441,7 @@ const Table = (props) => {
|
|
|
438
441
|
}, column.columnClassName),
|
|
439
442
|
style: {
|
|
440
443
|
...(0, utils_js_1.getCellStyle)(column, !!state.isTableResizing),
|
|
444
|
+
...(columnHasExpanders && (0, utils_js_1.getSubRowStyle)({ density })),
|
|
441
445
|
...(0, utils_js_1.getStickyStyle)(column, visibleColumns),
|
|
442
446
|
flexWrap: 'unset',
|
|
443
447
|
},
|
|
@@ -42,34 +42,19 @@ const TableCell = (props) => {
|
|
|
42
42
|
const { cell, cellIndex, isDisabled, tableHasSubRows, tableInstance, expanderCell, density, } = props;
|
|
43
43
|
const hasSubRowExpander = cellIndex ===
|
|
44
44
|
cell.row.cells.findIndex((c) => c.column.id !== index_js_1.SELECTION_CELL_ID);
|
|
45
|
-
const getSubRowStyle = () => {
|
|
46
|
-
if (!tableHasSubRows || !hasSubRowExpander) {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
// If it doesn't have sub-rows then shift by another level to align with expandable rows on the same depth
|
|
50
|
-
const dynamicMargin = cell.row.depth + (cell.row.canExpand ? 0 : 1);
|
|
51
|
-
let cellPadding = 16;
|
|
52
|
-
let expanderMargin = 8;
|
|
53
|
-
if (density === 'condensed') {
|
|
54
|
-
cellPadding = 12;
|
|
55
|
-
expanderMargin = 4;
|
|
56
|
-
}
|
|
57
|
-
else if (density === 'extra-condensed') {
|
|
58
|
-
cellPadding = 8;
|
|
59
|
-
expanderMargin = 4;
|
|
60
|
-
}
|
|
61
|
-
const multiplier = 26 + expanderMargin; // 26 = expander width
|
|
62
|
-
return {
|
|
63
|
-
paddingInlineStart: cellPadding + dynamicMargin * multiplier,
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
45
|
const cellElementProps = cell.getCellProps({
|
|
67
46
|
className: (0, classnames_1.default)('iui-table-cell', cell.column.cellClassName, {
|
|
68
47
|
'iui-table-cell-sticky': !!cell.column.sticky,
|
|
69
48
|
}),
|
|
70
49
|
style: {
|
|
71
50
|
...(0, utils_js_1.getCellStyle)(cell.column, !!tableInstance.state.isTableResizing),
|
|
72
|
-
...
|
|
51
|
+
...(tableHasSubRows &&
|
|
52
|
+
hasSubRowExpander &&
|
|
53
|
+
(0, utils_js_1.getSubRowStyle)({
|
|
54
|
+
density,
|
|
55
|
+
// If it doesn't have sub-rows then shift by another level to align with expandable rows on the same depth
|
|
56
|
+
depth: cell.row.depth + (cell.row.canExpand ? 0 : 1),
|
|
57
|
+
})),
|
|
73
58
|
...(0, utils_js_1.getStickyStyle)(cell.column, tableInstance.visibleColumns),
|
|
74
59
|
},
|
|
75
60
|
});
|
|
@@ -27,7 +27,7 @@ export declare const SelectionColumn: <T extends Record<string, unknown>>(props?
|
|
|
27
27
|
maxWidth: number;
|
|
28
28
|
columnClassName: string;
|
|
29
29
|
cellClassName: string;
|
|
30
|
-
Header: ({ getToggleAllRowsSelectedProps, toggleAllRowsSelected, rows,
|
|
30
|
+
Header: ({ getToggleAllRowsSelectedProps, toggleAllRowsSelected, rows, preFilteredFlatRows, state, }: HeaderProps<T>) => React.JSX.Element;
|
|
31
31
|
Cell: ({ row }: CellProps<T>) => React.JSX.Element;
|
|
32
32
|
cellRenderer: (props: CellRendererProps<T>) => React.JSX.Element;
|
|
33
33
|
};
|
|
@@ -57,9 +57,9 @@ const SelectionColumn = (props = {}) => {
|
|
|
57
57
|
maxWidth: densityWidth,
|
|
58
58
|
columnClassName: 'iui-slot',
|
|
59
59
|
cellClassName: 'iui-slot',
|
|
60
|
-
Header: ({ getToggleAllRowsSelectedProps, toggleAllRowsSelected, rows,
|
|
61
|
-
const disabled =
|
|
62
|
-
const checked =
|
|
60
|
+
Header: ({ getToggleAllRowsSelectedProps, toggleAllRowsSelected, rows, preFilteredFlatRows, state, }) => {
|
|
61
|
+
const disabled = preFilteredFlatRows.every((row) => isDisabled?.(row.original));
|
|
62
|
+
const checked = preFilteredFlatRows.every((row) => state.selectedRowIds[row.id] || isDisabled?.(row.original));
|
|
63
63
|
const indeterminate = !checked && Object.keys(state.selectedRowIds).length > 0;
|
|
64
64
|
return (React.createElement(Checkbox_js_1.Checkbox, { ...getToggleAllRowsSelectedProps(), style: {}, title: '' // Removes default title that comes from react-table
|
|
65
65
|
, checked: checked && !disabled, indeterminate: indeterminate, disabled: disabled, onChange: () => toggleAllRowsSelected(!rows.some((row) => row.isSelected)) }));
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { ColumnInstance } from '../../react-table/react-table.js';
|
|
2
2
|
export declare const getCellStyle: <T extends Record<string, unknown>>(column: ColumnInstance<T>, isTableResizing: boolean) => React.CSSProperties | undefined;
|
|
3
3
|
export declare const getStickyStyle: <T extends Record<string, unknown>>(column: ColumnInstance<T>, columnList: ColumnInstance<T>[]) => React.CSSProperties;
|
|
4
|
+
export declare const getSubRowStyle: ({ density, depth }: {
|
|
5
|
+
density?: string | undefined;
|
|
6
|
+
depth?: number | undefined;
|
|
7
|
+
}) => {
|
|
8
|
+
paddingInlineStart: number;
|
|
9
|
+
};
|
package/cjs/core/Table/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStickyStyle = exports.getCellStyle = void 0;
|
|
3
|
+
exports.getSubRowStyle = exports.getStickyStyle = exports.getCellStyle = void 0;
|
|
4
4
|
const getCellStyle = (column, isTableResizing) => {
|
|
5
5
|
const style = {};
|
|
6
6
|
style.flex = `1 1 145px`;
|
|
@@ -48,3 +48,20 @@ const getStickyStyle = (column, columnList) => {
|
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
exports.getStickyStyle = getStickyStyle;
|
|
51
|
+
const getSubRowStyle = ({ density = 'default', depth = 1 }) => {
|
|
52
|
+
let cellPadding = 16;
|
|
53
|
+
let expanderMargin = 8;
|
|
54
|
+
if (density === 'condensed') {
|
|
55
|
+
cellPadding = 12;
|
|
56
|
+
expanderMargin = 4;
|
|
57
|
+
}
|
|
58
|
+
else if (density === 'extra-condensed') {
|
|
59
|
+
cellPadding = 8;
|
|
60
|
+
expanderMargin = 4;
|
|
61
|
+
}
|
|
62
|
+
const multiplier = 26 + expanderMargin; // 26 = expander width
|
|
63
|
+
return {
|
|
64
|
+
paddingInlineStart: cellPadding + depth * multiplier,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
exports.getSubRowStyle = getSubRowStyle;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InputWithIcon = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
const polymorphic_js_1 = require("../functions/polymorphic.js");
|
|
9
|
+
/** @private */
|
|
10
|
+
exports.InputWithIcon = polymorphic_js_1.polymorphic.div('iui-input-with-icon');
|
|
11
|
+
exports.InputWithIcon.displayName = 'InputWithIcon';
|
|
@@ -9,10 +9,12 @@ export type PortalProps = {
|
|
|
9
9
|
*
|
|
10
10
|
* Otherwise, it will portal to the element passed to `to`.
|
|
11
11
|
*
|
|
12
|
+
* If `to`/`to()` === `null`/`undefined`, the default behavior will be used (i.e. as if `portal` is not passed).
|
|
13
|
+
*
|
|
12
14
|
* @default true
|
|
13
15
|
*/
|
|
14
16
|
portal?: boolean | {
|
|
15
|
-
to: HTMLElement | (() => HTMLElement);
|
|
17
|
+
to: HTMLElement | null | undefined | (() => HTMLElement | null | undefined);
|
|
16
18
|
};
|
|
17
19
|
};
|
|
18
20
|
/**
|
|
@@ -21,6 +23,8 @@ export type PortalProps = {
|
|
|
21
23
|
* - if `portal` is set to true, renders into nearest ThemeContext.portalContainer
|
|
22
24
|
* - if `portal` is set to false, renders as-is without portal
|
|
23
25
|
* - otherwise renders into `portal.to` (can be an element or a function)
|
|
26
|
+
* - If `to`/`to()` === `null`/`undefined`, the default behavior will be used (i.e. as if `portal` is not passed).
|
|
27
|
+
* - E.g. `portal={{ to: () => document.querySelector('.may-not-exist') }}`.
|
|
24
28
|
*
|
|
25
29
|
* @private
|
|
26
30
|
*/
|
|
@@ -40,6 +40,8 @@ const useIsClient_js_1 = require("../hooks/useIsClient.js");
|
|
|
40
40
|
* - if `portal` is set to true, renders into nearest ThemeContext.portalContainer
|
|
41
41
|
* - if `portal` is set to false, renders as-is without portal
|
|
42
42
|
* - otherwise renders into `portal.to` (can be an element or a function)
|
|
43
|
+
* - If `to`/`to()` === `null`/`undefined`, the default behavior will be used (i.e. as if `portal` is not passed).
|
|
44
|
+
* - E.g. `portal={{ to: () => document.querySelector('.may-not-exist') }}`.
|
|
43
45
|
*
|
|
44
46
|
* @private
|
|
45
47
|
*/
|
|
@@ -56,8 +58,10 @@ exports.Portal = Portal;
|
|
|
56
58
|
// ----------------------------------------------------------------------------
|
|
57
59
|
const usePortalTo = (portal) => {
|
|
58
60
|
const themeInfo = React.useContext(ThemeContext_js_1.ThemeContext);
|
|
61
|
+
const defaultPortalTo = themeInfo?.portalContainer ?? (0, dom_js_1.getDocument)()?.body;
|
|
59
62
|
if (typeof portal === 'boolean') {
|
|
60
|
-
return portal ?
|
|
63
|
+
return portal ? defaultPortalTo : null;
|
|
61
64
|
}
|
|
62
|
-
|
|
65
|
+
const portalTo = typeof portal.to === 'function' ? portal.to() : portal.to;
|
|
66
|
+
return portalTo ?? defaultPortalTo;
|
|
63
67
|
};
|
|
@@ -2,6 +2,7 @@ export * from './Resizer.js';
|
|
|
2
2
|
export * from './FocusTrap.js';
|
|
3
3
|
export * from './InputContainer.js';
|
|
4
4
|
export * from './InputFlexContainer.js';
|
|
5
|
+
export * from './InputWithIcon.js';
|
|
5
6
|
export * from './WithCSSTransition.js';
|
|
6
7
|
export * from './MiddleTextTruncation.js';
|
|
7
8
|
export * from './VirtualScroll.js';
|
|
@@ -22,6 +22,7 @@ __exportStar(require("./Resizer.js"), exports);
|
|
|
22
22
|
__exportStar(require("./FocusTrap.js"), exports);
|
|
23
23
|
__exportStar(require("./InputContainer.js"), exports);
|
|
24
24
|
__exportStar(require("./InputFlexContainer.js"), exports);
|
|
25
|
+
__exportStar(require("./InputWithIcon.js"), exports);
|
|
25
26
|
__exportStar(require("./WithCSSTransition.js"), exports);
|
|
26
27
|
__exportStar(require("./MiddleTextTruncation.js"), exports);
|
|
27
28
|
__exportStar(require("./VirtualScroll.js"), exports);
|
|
@@ -102,5 +102,7 @@ export type ComboBoxProps<T> = {
|
|
|
102
102
|
* onChange={() => {}}
|
|
103
103
|
* />
|
|
104
104
|
*/
|
|
105
|
-
export declare const ComboBox: <T>(props: ComboBoxProps<T>
|
|
105
|
+
export declare const ComboBox: <T>(props: ComboBoxProps<T> & {
|
|
106
|
+
ref?: React.ForwardedRef<HTMLElement> | undefined;
|
|
107
|
+
}) => JSX.Element;
|
|
106
108
|
export default ComboBox;
|
|
@@ -39,7 +39,7 @@ const getOptionId = (option, idPrefix) => {
|
|
|
39
39
|
* onChange={() => {}}
|
|
40
40
|
* />
|
|
41
41
|
*/
|
|
42
|
-
export const ComboBox = (props) => {
|
|
42
|
+
export const ComboBox = React.forwardRef((props, forwardedRef) => {
|
|
43
43
|
const idPrefix = useId();
|
|
44
44
|
const { options, value: valueProp, onChange, filterFunction, inputProps, endIconProps, dropdownMenuProps, emptyStateMessage = 'No options found', itemRenderer, enableVirtualization = false, multiple = false, onShow: onShowProp, onHide: onHideProp, id = inputProps?.id ? `iui-${inputProps.id}-cb` : idPrefix, ...rest } = props;
|
|
45
45
|
// Refs get set in subcomponents
|
|
@@ -299,7 +299,7 @@ export const ComboBox = (props) => {
|
|
|
299
299
|
show,
|
|
300
300
|
hide,
|
|
301
301
|
} },
|
|
302
|
-
React.createElement(ComboBoxInputContainer, { disabled: inputProps?.disabled, ...rest },
|
|
302
|
+
React.createElement(ComboBoxInputContainer, { ref: forwardedRef, disabled: inputProps?.disabled, ...rest },
|
|
303
303
|
React.createElement(React.Fragment, null,
|
|
304
304
|
React.createElement(ComboBoxInput, { value: inputValue, disabled: inputProps?.disabled, ...inputProps, onChange: handleOnInput, selectTags: isMultipleEnabled(selected, multiple)
|
|
305
305
|
? selected.map((index) => {
|
|
@@ -312,5 +312,5 @@ export const ComboBox = (props) => {
|
|
|
312
312
|
React.createElement(ComboBoxMenu, { as: 'div', ...dropdownMenuProps }, filteredOptions.length > 0 && !enableVirtualization
|
|
313
313
|
? filteredOptions.map(getMenuItem)
|
|
314
314
|
: emptyContent)))));
|
|
315
|
-
};
|
|
315
|
+
});
|
|
316
316
|
export default ComboBox;
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { StatusMessage } from '../StatusMessage/StatusMessage.js';
|
|
7
|
-
import { InputContainer, useSafeContext,
|
|
7
|
+
import { InputContainer, useSafeContext, InputWithIcon, } from '../utils/index.js';
|
|
8
8
|
import { ComboBoxStateContext } from './helpers.js';
|
|
9
9
|
export const ComboBoxInputContainer = React.forwardRef((props, forwardedRef) => {
|
|
10
10
|
const { className, status, message, children, ...rest } = props;
|
|
11
11
|
const { id } = useSafeContext(ComboBoxStateContext);
|
|
12
12
|
return (React.createElement(InputContainer, { className: className, status: status, statusMessage: typeof message === 'string' ? (React.createElement(StatusMessage, { status: status }, message)) : (React.isValidElement(message) &&
|
|
13
13
|
React.cloneElement(message, { status })), ref: forwardedRef, ...rest, id: id },
|
|
14
|
-
React.createElement(
|
|
14
|
+
React.createElement(InputWithIcon, null, children)));
|
|
15
15
|
});
|
|
16
16
|
ComboBoxInputContainer.displayName = 'ComboBoxInputContainer';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
2
1
|
/**
|
|
3
2
|
* Container for content in `Dialog`. Recommended to be used as a child of `Dialog`.
|
|
4
3
|
* @example
|
|
@@ -6,5 +5,5 @@ import type { PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
|
6
5
|
* My dialog content
|
|
7
6
|
* </Dialog.Content>
|
|
8
7
|
*/
|
|
9
|
-
export declare const DialogContent: PolymorphicForwardRefComponent<"div", {}>;
|
|
8
|
+
export declare const DialogContent: import("../utils/props.js").PolymorphicForwardRefComponent<"div", {}>;
|
|
10
9
|
export default DialogContent;
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import
|
|
6
|
-
import cx from 'classnames';
|
|
7
|
-
import { supportsHas, useMergedRefs, Box } from '../utils/index.js';
|
|
5
|
+
import { polymorphic } from '../utils/index.js';
|
|
8
6
|
/**
|
|
9
7
|
* Container for content in `Dialog`. Recommended to be used as a child of `Dialog`.
|
|
10
8
|
* @example
|
|
@@ -12,18 +10,5 @@ import { supportsHas, useMergedRefs, Box } from '../utils/index.js';
|
|
|
12
10
|
* My dialog content
|
|
13
11
|
* </Dialog.Content>
|
|
14
12
|
*/
|
|
15
|
-
export const DialogContent =
|
|
16
|
-
const { children, className, ...rest } = props;
|
|
17
|
-
const contentRef = React.useRef(null);
|
|
18
|
-
React.useEffect(() => {
|
|
19
|
-
// firefox hack for adding data-iui-flex in absence of :has
|
|
20
|
-
if (!supportsHas()) {
|
|
21
|
-
const dialog = contentRef.current?.closest('[role=dialog]');
|
|
22
|
-
if (dialog instanceof HTMLElement) {
|
|
23
|
-
dialog.dataset.iuiFlex = 'true';
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}, []);
|
|
27
|
-
return (React.createElement(Box, { className: cx('iui-dialog-content', className), ref: useMergedRefs(contentRef, ref), ...rest }, children));
|
|
28
|
-
});
|
|
13
|
+
export const DialogContent = polymorphic.div('iui-dialog-content');
|
|
29
14
|
export default DialogContent;
|
|
@@ -67,6 +67,7 @@ export type DialogContextProps = {
|
|
|
67
67
|
* Recommended to set to true when for modal dialogs that use `relativeTo='viewport'`.
|
|
68
68
|
*
|
|
69
69
|
* Can be set to an object with a `to` property to portal into a specific element.
|
|
70
|
+
* If `to`/`to()` === `null`/`undefined`, the default behavior will be used (i.e. as if `portal` is not passed).
|
|
70
71
|
*
|
|
71
72
|
* Defaults to false if using `Dialog` and true if using `Modal`.
|
|
72
73
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import cx from 'classnames';
|
|
7
|
-
import { FocusTrap, getTranslateValuesFromElement, Resizer, useMergedRefs, useIsomorphicLayoutEffect, Box,
|
|
7
|
+
import { FocusTrap, getTranslateValuesFromElement, Resizer, useMergedRefs, useIsomorphicLayoutEffect, Box, } from '../utils/index.js';
|
|
8
8
|
import { useDialogContext } from './DialogContext.js';
|
|
9
9
|
import { CSSTransition } from 'react-transition-group';
|
|
10
10
|
import { DialogDragContext } from './DialogDragContext.js';
|
|
@@ -34,7 +34,6 @@ export const DialogMain = React.forwardRef((props, ref) => {
|
|
|
34
34
|
const { className, children, styleType = 'default', isOpen = dialogContext.isOpen, isDismissible = dialogContext.isDismissible, onClose = dialogContext.onClose, closeOnEsc = dialogContext.closeOnEsc, trapFocus = dialogContext.trapFocus, setFocus = dialogContext.setFocus, preventDocumentScroll = dialogContext.preventDocumentScroll, onKeyDown, isDraggable = dialogContext.isDraggable, isResizable = dialogContext.isResizable, style: propStyle, placement = dialogContext.placement, ...rest } = props;
|
|
35
35
|
const [style, setStyle] = React.useState();
|
|
36
36
|
const dialogRef = React.useRef(null);
|
|
37
|
-
const [dialogElement, setDialogElement] = React.useState();
|
|
38
37
|
const hasBeenResized = React.useRef(false);
|
|
39
38
|
const previousFocusedElement = React.useRef();
|
|
40
39
|
const originalBodyOverflow = React.useRef('');
|
|
@@ -102,17 +101,13 @@ export const DialogMain = React.forwardRef((props, ref) => {
|
|
|
102
101
|
...newStyle,
|
|
103
102
|
}));
|
|
104
103
|
}, []);
|
|
105
|
-
const roundedTransform = useRoundedTransform({
|
|
106
|
-
element: dialogElement,
|
|
107
|
-
transform,
|
|
108
|
-
});
|
|
109
104
|
const content = (React.createElement(Box, { className: cx('iui-dialog', {
|
|
110
105
|
'iui-dialog-default': styleType === 'default',
|
|
111
106
|
'iui-dialog-full-page': styleType === 'fullPage',
|
|
112
107
|
'iui-dialog-visible': isOpen,
|
|
113
108
|
'iui-dialog-draggable': isDraggable,
|
|
114
|
-
}, className), role: 'dialog', ref: useMergedRefs(dialogRef, ref
|
|
115
|
-
transform
|
|
109
|
+
}, className), role: 'dialog', ref: useMergedRefs(dialogRef, ref), onKeyDown: handleKeyDown, tabIndex: -1, "data-iui-placement": placement, style: {
|
|
110
|
+
transform,
|
|
116
111
|
...style,
|
|
117
112
|
...propStyle,
|
|
118
113
|
}, ...rest },
|
|
@@ -144,20 +139,3 @@ export const DialogMain = React.forwardRef((props, ref) => {
|
|
|
144
139
|
!trapFocus && content)));
|
|
145
140
|
});
|
|
146
141
|
export default DialogMain;
|
|
147
|
-
// ----------------------------------------------------------------------------
|
|
148
|
-
/**
|
|
149
|
-
* Rounds off an element's transform value based on the device's pixel grid, to avoid blurring.
|
|
150
|
-
*/
|
|
151
|
-
const useRoundedTransform = ({ element, transform, }) => {
|
|
152
|
-
const [roundedStyles, setRoundedStyles] = React.useState(transform);
|
|
153
|
-
useIsomorphicLayoutEffect(() => {
|
|
154
|
-
if (!element || typeof DOMMatrix === 'undefined') {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const [x, y] = transform
|
|
158
|
-
? getTranslateValues(transform)
|
|
159
|
-
: getTranslateValuesFromElement(element);
|
|
160
|
-
setRoundedStyles(`translate(${roundByDPR(x)}px, ${roundByDPR(y)}px)`);
|
|
161
|
-
}, [element, transform]);
|
|
162
|
-
return roundedStyles;
|
|
163
|
-
};
|
|
@@ -73,7 +73,7 @@ export declare const ExpandableBlock: PolymorphicForwardRefComponent<"div", Expa
|
|
|
73
73
|
* <ExpandableBlock.EndIcon/>
|
|
74
74
|
* </ExpandableBlock.Trigger>
|
|
75
75
|
*/
|
|
76
|
-
Trigger: PolymorphicForwardRefComponent<"
|
|
76
|
+
Trigger: PolymorphicForwardRefComponent<"div", ExpandableBlockTriggerOwnProps>;
|
|
77
77
|
/**
|
|
78
78
|
* The expanding icon on the left of header
|
|
79
79
|
*/
|
|
@@ -90,11 +90,11 @@ export declare const ExpandableBlock: PolymorphicForwardRefComponent<"div", Expa
|
|
|
90
90
|
/**
|
|
91
91
|
* The main text displayed on the block header, regardless of state.
|
|
92
92
|
*/
|
|
93
|
-
Title: PolymorphicForwardRefComponent<"
|
|
93
|
+
Title: PolymorphicForwardRefComponent<"button", {}>;
|
|
94
94
|
/**
|
|
95
95
|
* Small note displayed below title, regardless of state.
|
|
96
96
|
*/
|
|
97
|
-
Caption: PolymorphicForwardRefComponent<
|
|
97
|
+
Caption: PolymorphicForwardRefComponent<"div", {}>;
|
|
98
98
|
/**
|
|
99
99
|
* Svg icon displayed at the end of the main text.
|
|
100
100
|
* Will override status icon if specified. Used inside `Header` subcomponent.
|
|
@@ -110,7 +110,10 @@ export declare const ExpandableBlock: PolymorphicForwardRefComponent<"div", Expa
|
|
|
110
110
|
fill?: "default" | "informational" | "negative" | "positive" | "warning" | import("../utils/types.js").AnyString | undefined;
|
|
111
111
|
padded?: boolean | undefined;
|
|
112
112
|
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
113
|
-
as?: "span" | undefined;
|
|
113
|
+
as?: "span" | undefined; /**
|
|
114
|
+
* Status of the block.
|
|
115
|
+
* When set, a colored status icon is shown at the end of the main text.
|
|
116
|
+
*/
|
|
114
117
|
}, "ref">>;
|
|
115
118
|
/**
|
|
116
119
|
* Content shown in the block's body when fully expanded.
|