@itwin/itwinui-react 3.18.2 → 3.19.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/CHANGELOG.md +50 -0
- package/DEV-cjs/core/ComboBox/ComboBoxMenuItem.js +1 -1
- package/DEV-cjs/core/Menu/MenuItem.js +8 -7
- package/DEV-cjs/core/Select/Select.js +18 -10
- package/DEV-cjs/core/SideNavigation/SideNavigation.js +2 -2
- package/DEV-cjs/core/Table/ColumnHeader.js +7 -3
- package/DEV-cjs/core/Table/Table.js +65 -5
- package/DEV-cjs/core/Table/cells/DefaultCell.js +14 -9
- package/DEV-cjs/core/Table/columns/actionColumn.js +1 -0
- package/DEV-cjs/core/Table/columns/expanderColumn.js +25 -20
- package/DEV-cjs/core/Table/columns/selectionColumn.js +14 -8
- package/DEV-cjs/core/Table/hooks/useExpanderCell.js +10 -6
- package/DEV-cjs/core/Tag/Tag.js +8 -2
- package/DEV-cjs/core/ThemeProvider/ThemeProvider.js +46 -46
- package/DEV-cjs/core/ToggleSwitch/ToggleSwitch.js +15 -4
- package/DEV-cjs/styles.js +1 -1
- package/DEV-cjs/utils/components/index.js +1 -1
- package/DEV-cjs/utils/components/lineClamp.js +23 -0
- package/DEV-cjs/utils/functions/react.js +18 -4
- package/DEV-cjs/utils/hooks/useControlledState.js +5 -1
- package/DEV-cjs/utils/providers/FutureFlagsProvider.js +48 -0
- package/DEV-cjs/utils/providers/index.js +1 -0
- package/DEV-esm/core/ComboBox/ComboBoxMenuItem.js +1 -1
- package/DEV-esm/core/Menu/MenuItem.js +8 -7
- package/DEV-esm/core/Select/Select.js +19 -10
- package/DEV-esm/core/SideNavigation/SideNavigation.js +2 -2
- package/DEV-esm/core/Table/ColumnHeader.js +8 -4
- package/DEV-esm/core/Table/Table.js +65 -5
- package/DEV-esm/core/Table/cells/DefaultCell.js +15 -10
- package/DEV-esm/core/Table/columns/actionColumn.js +1 -0
- package/DEV-esm/core/Table/columns/expanderColumn.js +25 -20
- package/DEV-esm/core/Table/columns/selectionColumn.js +14 -8
- package/DEV-esm/core/Table/hooks/useExpanderCell.js +10 -6
- package/DEV-esm/core/Tag/Tag.js +11 -3
- package/DEV-esm/core/ThemeProvider/ThemeProvider.js +48 -42
- package/DEV-esm/core/ToggleSwitch/ToggleSwitch.js +15 -5
- package/DEV-esm/styles.js +1 -1
- package/DEV-esm/utils/components/index.js +1 -1
- package/DEV-esm/utils/components/lineClamp.js +13 -0
- package/DEV-esm/utils/functions/react.js +6 -1
- package/DEV-esm/utils/hooks/useControlledState.js +5 -1
- package/DEV-esm/utils/providers/FutureFlagsProvider.js +28 -0
- package/DEV-esm/utils/providers/index.js +1 -0
- package/cjs/core/Buttons/DropdownButton.d.ts +1 -1
- package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +5 -16
- package/cjs/core/ComboBox/ComboBoxMenuItem.js +1 -1
- package/cjs/core/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/cjs/core/Menu/MenuItem.d.ts +7 -1
- package/cjs/core/Menu/MenuItem.js +8 -7
- package/cjs/core/Popover/Popover.d.ts +5 -3
- package/cjs/core/Select/Select.js +18 -10
- package/cjs/core/SideNavigation/SideNavigation.js +2 -2
- package/cjs/core/Table/ColumnHeader.js +7 -3
- package/cjs/core/Table/Table.d.ts +2 -2
- package/cjs/core/Table/Table.js +65 -5
- package/cjs/core/Table/cells/DefaultCell.js +14 -9
- package/cjs/core/Table/columns/actionColumn.d.ts +1 -0
- package/cjs/core/Table/columns/actionColumn.js +1 -0
- package/cjs/core/Table/columns/expanderColumn.d.ts +2 -2
- package/cjs/core/Table/columns/expanderColumn.js +25 -20
- package/cjs/core/Table/columns/selectionColumn.d.ts +2 -2
- package/cjs/core/Table/columns/selectionColumn.js +14 -8
- package/cjs/core/Table/hooks/useExpanderCell.js +10 -6
- package/cjs/core/Tabs/Tabs.d.ts +4 -1
- package/cjs/core/Tag/Tag.js +8 -2
- package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -2
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +8 -18
- package/cjs/core/ThemeProvider/ThemeProvider.js +46 -46
- package/cjs/core/ToggleSwitch/ToggleSwitch.d.ts +21 -0
- package/cjs/core/ToggleSwitch/ToggleSwitch.js +15 -4
- package/cjs/styles.js +1 -1
- package/cjs/utils/components/index.d.ts +1 -1
- package/cjs/utils/components/index.js +1 -1
- package/cjs/utils/components/lineClamp.d.ts +5 -0
- package/cjs/utils/components/lineClamp.js +23 -0
- package/cjs/utils/functions/react.d.ts +5 -0
- package/cjs/utils/functions/react.js +18 -4
- package/cjs/utils/hooks/useControlledState.d.ts +5 -2
- package/cjs/utils/hooks/useControlledState.js +5 -1
- package/cjs/utils/hooks/useGlobals.d.ts +0 -1
- package/cjs/utils/providers/FutureFlagsProvider.d.ts +37 -0
- package/cjs/utils/providers/FutureFlagsProvider.js +48 -0
- package/cjs/utils/providers/index.d.ts +1 -0
- package/cjs/utils/providers/index.js +1 -0
- package/esm/core/Buttons/DropdownButton.d.ts +1 -1
- package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +5 -16
- package/esm/core/ComboBox/ComboBoxMenuItem.js +1 -1
- package/esm/core/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/esm/core/Menu/MenuItem.d.ts +7 -1
- package/esm/core/Menu/MenuItem.js +8 -7
- package/esm/core/Popover/Popover.d.ts +5 -3
- package/esm/core/Select/Select.js +19 -10
- package/esm/core/SideNavigation/SideNavigation.js +2 -2
- package/esm/core/Table/ColumnHeader.js +8 -4
- package/esm/core/Table/Table.d.ts +2 -2
- package/esm/core/Table/Table.js +65 -5
- package/esm/core/Table/cells/DefaultCell.js +15 -10
- package/esm/core/Table/columns/actionColumn.d.ts +1 -0
- package/esm/core/Table/columns/actionColumn.js +1 -0
- package/esm/core/Table/columns/expanderColumn.d.ts +2 -2
- package/esm/core/Table/columns/expanderColumn.js +25 -20
- package/esm/core/Table/columns/selectionColumn.d.ts +2 -2
- package/esm/core/Table/columns/selectionColumn.js +14 -8
- package/esm/core/Table/hooks/useExpanderCell.js +10 -6
- package/esm/core/Tabs/Tabs.d.ts +4 -1
- package/esm/core/Tag/Tag.js +11 -3
- package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -2
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +8 -18
- package/esm/core/ThemeProvider/ThemeProvider.js +48 -42
- package/esm/core/ToggleSwitch/ToggleSwitch.d.ts +21 -0
- package/esm/core/ToggleSwitch/ToggleSwitch.js +15 -5
- package/esm/styles.js +1 -1
- package/esm/utils/components/index.d.ts +1 -1
- package/esm/utils/components/index.js +1 -1
- package/esm/utils/components/lineClamp.d.ts +5 -0
- package/esm/utils/components/lineClamp.js +13 -0
- package/esm/utils/functions/react.d.ts +5 -0
- package/esm/utils/functions/react.js +6 -1
- package/esm/utils/hooks/useControlledState.d.ts +5 -2
- package/esm/utils/hooks/useControlledState.js +5 -1
- package/esm/utils/hooks/useGlobals.d.ts +0 -1
- package/esm/utils/providers/FutureFlagsProvider.d.ts +37 -0
- package/esm/utils/providers/FutureFlagsProvider.js +28 -0
- package/esm/utils/providers/index.d.ts +1 -0
- package/esm/utils/providers/index.js +1 -0
- package/package.json +11 -5
- package/styles.css +10 -10
- package/DEV-cjs/utils/components/LineClamp.js +0 -50
- package/DEV-esm/utils/components/LineClamp.js +0 -36
- package/cjs/utils/components/LineClamp.d.ts +0 -5
- package/cjs/utils/components/LineClamp.js +0 -50
- package/esm/utils/components/LineClamp.d.ts +0 -5
- package/esm/utils/components/LineClamp.js +0 -36
|
@@ -24,15 +24,22 @@ const ToggleSwitch = _react.forwardRef((props, ref) => {
|
|
|
24
24
|
style,
|
|
25
25
|
size = 'default',
|
|
26
26
|
labelProps = {},
|
|
27
|
+
wrapperProps,
|
|
27
28
|
icon: iconProp,
|
|
28
29
|
...rest
|
|
29
30
|
} = props;
|
|
31
|
+
let { consistentPropsSpread } =
|
|
32
|
+
(0, _index.useFutureFlag)('ToggleSwitch') || {};
|
|
33
|
+
let shouldApplyClassNameAndStyleOnInput =
|
|
34
|
+
null != wrapperProps || consistentPropsSpread;
|
|
30
35
|
let shouldShowIcon =
|
|
31
36
|
void 0 === iconProp || (null !== iconProp && 'small' !== size);
|
|
32
37
|
return _react.createElement(
|
|
33
38
|
_index.Box,
|
|
34
39
|
{
|
|
35
40
|
as: label ? 'label' : 'div',
|
|
41
|
+
style: shouldApplyClassNameAndStyleOnInput ? void 0 : style,
|
|
42
|
+
...wrapperProps,
|
|
36
43
|
className: (0, _classnames.default)(
|
|
37
44
|
'iui-toggle-switch-wrapper',
|
|
38
45
|
{
|
|
@@ -40,19 +47,23 @@ const ToggleSwitch = _react.forwardRef((props, ref) => {
|
|
|
40
47
|
'iui-label-on-right': label && 'right' === labelPosition,
|
|
41
48
|
'iui-label-on-left': label && 'left' === labelPosition,
|
|
42
49
|
},
|
|
43
|
-
className,
|
|
50
|
+
shouldApplyClassNameAndStyleOnInput ? void 0 : className,
|
|
51
|
+
wrapperProps?.className,
|
|
44
52
|
),
|
|
45
53
|
'data-iui-size': size,
|
|
46
|
-
style: style,
|
|
47
54
|
},
|
|
48
55
|
_react.createElement(_index.Box, {
|
|
49
56
|
as: 'input',
|
|
50
|
-
className: 'iui-toggle-switch',
|
|
51
57
|
type: 'checkbox',
|
|
52
58
|
role: 'switch',
|
|
59
|
+
style: shouldApplyClassNameAndStyleOnInput ? style : void 0,
|
|
60
|
+
...rest,
|
|
61
|
+
className: (0, _classnames.default)(
|
|
62
|
+
'iui-toggle-switch',
|
|
63
|
+
shouldApplyClassNameAndStyleOnInput ? className : void 0,
|
|
64
|
+
),
|
|
53
65
|
disabled: disabled,
|
|
54
66
|
ref: ref,
|
|
55
|
-
...rest,
|
|
56
67
|
}),
|
|
57
68
|
shouldShowIcon &&
|
|
58
69
|
_react.createElement(
|
package/DEV-cjs/styles.js
CHANGED
|
@@ -14,6 +14,6 @@ _export_star._(require('./Box.js'), exports);
|
|
|
14
14
|
_export_star._(require('./ButtonBase.js'), exports);
|
|
15
15
|
_export_star._(require('./Portal.js'), exports);
|
|
16
16
|
_export_star._(require('./ShadowRoot.js'), exports);
|
|
17
|
-
_export_star._(require('./
|
|
17
|
+
_export_star._(require('./lineClamp.js'), exports);
|
|
18
18
|
_export_star._(require('./FieldsetBase.js'), exports);
|
|
19
19
|
_export_star._(require('./OverflowContainer.js'), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {
|
|
3
|
+
value: true,
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, 'lineClamp', {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function () {
|
|
8
|
+
return lineClamp;
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
const className = '_iui-line-clamp';
|
|
12
|
+
const css = `
|
|
13
|
+
.${className} {
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
display: -webkit-box;
|
|
16
|
+
-webkit-line-clamp: var(--_iui-line-clamp, 3);
|
|
17
|
+
-webkit-box-orient: vertical;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
const lineClamp = {
|
|
21
|
+
css,
|
|
22
|
+
className,
|
|
23
|
+
};
|
|
@@ -2,19 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, '__esModule', {
|
|
3
3
|
value: true,
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name],
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
cloneElementWithRef: function () {
|
|
8
14
|
return cloneElementWithRef;
|
|
9
15
|
},
|
|
16
|
+
isReact17or18: function () {
|
|
17
|
+
return isReact17or18;
|
|
18
|
+
},
|
|
10
19
|
});
|
|
11
20
|
const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
|
|
12
21
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react'));
|
|
13
22
|
const _useMergedRefs = require('../hooks/useMergedRefs.js');
|
|
23
|
+
const _React = _react;
|
|
24
|
+
const isReact17or18 = (() => {
|
|
25
|
+
let version = _React.version?.split('.')?.[0];
|
|
26
|
+
return ['17', '18'].includes(version);
|
|
27
|
+
})();
|
|
14
28
|
const cloneElementWithRef = (children, getProps) => {
|
|
15
29
|
if (!children) return null;
|
|
16
30
|
if (!_react.isValidElement(children)) return children;
|
|
17
|
-
let childrenRef = children
|
|
31
|
+
let childrenRef = isReact17or18 ? children?.ref : children.props?.ref;
|
|
18
32
|
let props = getProps(children);
|
|
19
33
|
let ref = (0, _useMergedRefs.mergeRefs)(
|
|
20
34
|
...[childrenRef, 'ref' in props ? props.ref : null].filter(Boolean),
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, 'useControlledState', {
|
|
|
10
10
|
});
|
|
11
11
|
const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react'));
|
|
13
|
+
const _useLatestRef = require('./useLatestRef.js');
|
|
13
14
|
const useControlledState = (
|
|
14
15
|
initialValue,
|
|
15
16
|
controlledState,
|
|
@@ -20,12 +21,15 @@ const useControlledState = (
|
|
|
20
21
|
() => (void 0 !== controlledState ? controlledState : uncontrolledState),
|
|
21
22
|
[controlledState, uncontrolledState],
|
|
22
23
|
);
|
|
24
|
+
let oldState = (0, _useLatestRef.useLatestRef)(state);
|
|
23
25
|
let setState = _react.useCallback(
|
|
24
26
|
(value) => {
|
|
27
|
+
if (value === oldState.current) return;
|
|
28
|
+
oldState.current = value;
|
|
25
29
|
setUncontrolledState(value);
|
|
26
30
|
setControlledState?.(value);
|
|
27
31
|
},
|
|
28
|
-
[
|
|
32
|
+
[oldState, setControlledState],
|
|
29
33
|
);
|
|
30
34
|
return [state, setState];
|
|
31
35
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {
|
|
3
|
+
value: true,
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name],
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
FutureFlagsProvider: function () {
|
|
14
|
+
return FutureFlagsProvider;
|
|
15
|
+
},
|
|
16
|
+
useFutureFlag: function () {
|
|
17
|
+
return useFutureFlag;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
|
|
21
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react'));
|
|
22
|
+
const _useSafeContext = require('../hooks/useSafeContext.js');
|
|
23
|
+
const FutureFlagsContext = _react.createContext({});
|
|
24
|
+
function useFutureFlag(key) {
|
|
25
|
+
let context = (0, _useSafeContext.useSafeContext)(FutureFlagsContext);
|
|
26
|
+
return context[key];
|
|
27
|
+
}
|
|
28
|
+
const FutureFlagsProvider = ({ children, value }) => {
|
|
29
|
+
if (true === value)
|
|
30
|
+
value = {
|
|
31
|
+
themeBridge: true,
|
|
32
|
+
};
|
|
33
|
+
let context = _react.useContext(FutureFlagsContext);
|
|
34
|
+
let combinedValue = {
|
|
35
|
+
...context,
|
|
36
|
+
...value,
|
|
37
|
+
};
|
|
38
|
+
return _react.createElement(
|
|
39
|
+
FutureFlagsContext.Provider,
|
|
40
|
+
{
|
|
41
|
+
value: _react.useMemo(
|
|
42
|
+
() => combinedValue,
|
|
43
|
+
[JSON.stringify(combinedValue)],
|
|
44
|
+
),
|
|
45
|
+
},
|
|
46
|
+
children,
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -41,7 +41,7 @@ export const ComboBoxMenuItem = React.memo(
|
|
|
41
41
|
disabled: disabled,
|
|
42
42
|
focused: focusedIndex === index,
|
|
43
43
|
ref: refs,
|
|
44
|
-
onClick: () => onClick?.(
|
|
44
|
+
onClick: () => onClick?.(),
|
|
45
45
|
role: role,
|
|
46
46
|
tabIndex: 'presentation' === role ? void 0 : -1,
|
|
47
47
|
'aria-selected': isSelected,
|
|
@@ -63,13 +63,10 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
|
|
|
63
63
|
}),
|
|
64
64
|
[hasSubMenu],
|
|
65
65
|
);
|
|
66
|
-
let onClick = () => {
|
|
66
|
+
let onClick = (event) => {
|
|
67
67
|
if (disabled) return;
|
|
68
68
|
if (shouldCloseMenuOnClick) dropdownMenu?.close();
|
|
69
|
-
onClickProp?.(value);
|
|
70
|
-
};
|
|
71
|
-
let handlers = {
|
|
72
|
-
onClick,
|
|
69
|
+
onClickProp?.(value ?? event);
|
|
73
70
|
};
|
|
74
71
|
let focusableItemIndex = parentMenu?.focusableElements.findIndex(
|
|
75
72
|
(el) => el === menuItemRef.current,
|
|
@@ -94,9 +91,13 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
|
|
|
94
91
|
...(parentMenu?.popoverGetItemProps != null
|
|
95
92
|
? parentMenu.popoverGetItemProps({
|
|
96
93
|
focusableItemIndex,
|
|
97
|
-
userProps:
|
|
94
|
+
userProps: {
|
|
95
|
+
onClick,
|
|
96
|
+
},
|
|
98
97
|
})
|
|
99
|
-
:
|
|
98
|
+
: {
|
|
99
|
+
onClick,
|
|
100
|
+
}),
|
|
100
101
|
...rest,
|
|
101
102
|
},
|
|
102
103
|
startIcon &&
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
useLatestRef,
|
|
13
13
|
InputWithIcon,
|
|
14
14
|
mergeEventHandlers,
|
|
15
|
+
isReact17or18,
|
|
15
16
|
} from '../../utils/index.js';
|
|
16
17
|
import { SelectTag } from './SelectTag.js';
|
|
17
18
|
import { SelectTagContainer } from './SelectTagContainer.js';
|
|
@@ -174,7 +175,13 @@ let CustomSelect = React.forwardRef((props, forwardedRef) => {
|
|
|
174
175
|
isSelected,
|
|
175
176
|
})
|
|
176
177
|
: React.createElement(MenuItem, null, option.label);
|
|
177
|
-
let {
|
|
178
|
+
let {
|
|
179
|
+
label,
|
|
180
|
+
icon,
|
|
181
|
+
startIcon: startIconProp,
|
|
182
|
+
value: _,
|
|
183
|
+
...restOption
|
|
184
|
+
} = option;
|
|
178
185
|
let startIcon = startIconProp ?? icon;
|
|
179
186
|
return React.cloneElement(menuItem, {
|
|
180
187
|
key: `${label}-${index}`,
|
|
@@ -451,15 +458,17 @@ let SelectListbox = React.forwardRef((props, forwardedRef) => {
|
|
|
451
458
|
}, []);
|
|
452
459
|
let children = React.useMemo(
|
|
453
460
|
() =>
|
|
454
|
-
React.Children.map(childrenProp, (child, index) =>
|
|
455
|
-
React.isValidElement(child)
|
|
456
|
-
?
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
React.Children.map(childrenProp, (child, index) => {
|
|
462
|
+
if (React.isValidElement(child)) {
|
|
463
|
+
let ref = isReact17or18 ? child.ref : child.props.ref;
|
|
464
|
+
return React.createElement(CompositeItem, {
|
|
465
|
+
key: index,
|
|
466
|
+
ref: ref,
|
|
467
|
+
render: child,
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
return child;
|
|
471
|
+
}),
|
|
463
472
|
[childrenProp],
|
|
464
473
|
);
|
|
465
474
|
return React.createElement(
|
|
@@ -30,9 +30,9 @@ export const SideNavigation = React.forwardRef((props, forwardedRef) => {
|
|
|
30
30
|
className: 'iui-sidenav-button iui-expand',
|
|
31
31
|
size: 'small',
|
|
32
32
|
onClick: React.useCallback(() => {
|
|
33
|
-
setIsExpanded(
|
|
33
|
+
setIsExpanded(!isExpanded);
|
|
34
34
|
onExpanderClick?.();
|
|
35
|
-
}, [onExpanderClick, setIsExpanded]),
|
|
35
|
+
}, [isExpanded, onExpanderClick, setIsExpanded]),
|
|
36
36
|
},
|
|
37
37
|
React.createElement(SvgChevronRight, null),
|
|
38
38
|
);
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
4
|
ShadowRoot,
|
|
5
|
-
|
|
5
|
+
lineClamp,
|
|
6
6
|
SvgSortDown,
|
|
7
7
|
SvgSortUp,
|
|
8
8
|
useMergedRefs,
|
|
@@ -103,10 +103,14 @@ export const ColumnHeader = React.forwardRef((props, forwardedRef) => {
|
|
|
103
103
|
'string' == typeof column.Header
|
|
104
104
|
? React.createElement(
|
|
105
105
|
ShadowRoot,
|
|
106
|
-
|
|
106
|
+
{
|
|
107
|
+
css: lineClamp.css,
|
|
108
|
+
},
|
|
107
109
|
React.createElement(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
'div',
|
|
111
|
+
{
|
|
112
|
+
className: lineClamp.className,
|
|
113
|
+
},
|
|
110
114
|
React.createElement('slot', null),
|
|
111
115
|
),
|
|
112
116
|
React.createElement('slot', {
|
|
@@ -113,6 +113,38 @@ export const Table = (props) => {
|
|
|
113
113
|
caption = 'Table',
|
|
114
114
|
role,
|
|
115
115
|
scrollToRow,
|
|
116
|
+
useControlledState,
|
|
117
|
+
autoResetExpanded,
|
|
118
|
+
autoResetFilters,
|
|
119
|
+
autoResetGlobalFilter,
|
|
120
|
+
autoResetHiddenColumns,
|
|
121
|
+
autoResetPage,
|
|
122
|
+
autoResetResize,
|
|
123
|
+
autoResetSelectedRows,
|
|
124
|
+
autoResetSortBy,
|
|
125
|
+
defaultCanFilter,
|
|
126
|
+
defaultCanSort,
|
|
127
|
+
defaultColumn: defaultColumnProp,
|
|
128
|
+
disableFilters,
|
|
129
|
+
disableGlobalFilter,
|
|
130
|
+
disableMultiSort,
|
|
131
|
+
disableSortRemove,
|
|
132
|
+
disabledMultiRemove,
|
|
133
|
+
expandSubRows,
|
|
134
|
+
globalFilter,
|
|
135
|
+
initialState,
|
|
136
|
+
isMultiSortEvent,
|
|
137
|
+
manualExpandedKey,
|
|
138
|
+
manualFilters,
|
|
139
|
+
manualGlobalFilter,
|
|
140
|
+
manualRowSelectedKey,
|
|
141
|
+
manualSortBy,
|
|
142
|
+
maxMultiSortColCount,
|
|
143
|
+
orderByFn,
|
|
144
|
+
pageCount,
|
|
145
|
+
sortTypes,
|
|
146
|
+
manualPagination,
|
|
147
|
+
paginateExpandedRows,
|
|
116
148
|
..._rest
|
|
117
149
|
} = props;
|
|
118
150
|
let { ariaRestAttributes, nonAriaRestAttributes } = React.useMemo(
|
|
@@ -153,8 +185,9 @@ export const Table = (props) => {
|
|
|
153
185
|
maxWidth: 0,
|
|
154
186
|
minWidth: 0,
|
|
155
187
|
width: 0,
|
|
188
|
+
...defaultColumnProp,
|
|
156
189
|
}),
|
|
157
|
-
[],
|
|
190
|
+
[defaultColumnProp],
|
|
158
191
|
);
|
|
159
192
|
let rowHeight = React.useMemo(() => {
|
|
160
193
|
if ('condensed' === density) return 50;
|
|
@@ -306,9 +339,36 @@ export const Table = (props) => {
|
|
|
306
339
|
);
|
|
307
340
|
let instance = useTable(
|
|
308
341
|
{
|
|
309
|
-
manualPagination: !paginatorRenderer,
|
|
310
|
-
paginateExpandedRows: false,
|
|
311
|
-
|
|
342
|
+
manualPagination: manualPagination ?? !paginatorRenderer,
|
|
343
|
+
paginateExpandedRows: paginateExpandedRows ?? false,
|
|
344
|
+
useControlledState,
|
|
345
|
+
autoResetExpanded,
|
|
346
|
+
autoResetFilters,
|
|
347
|
+
autoResetGlobalFilter,
|
|
348
|
+
autoResetHiddenColumns,
|
|
349
|
+
autoResetPage,
|
|
350
|
+
autoResetResize,
|
|
351
|
+
autoResetSelectedRows,
|
|
352
|
+
autoResetSortBy,
|
|
353
|
+
defaultCanFilter,
|
|
354
|
+
defaultCanSort,
|
|
355
|
+
disableFilters,
|
|
356
|
+
disableGlobalFilter,
|
|
357
|
+
disableMultiSort,
|
|
358
|
+
disableSortRemove,
|
|
359
|
+
disabledMultiRemove,
|
|
360
|
+
expandSubRows,
|
|
361
|
+
globalFilter,
|
|
362
|
+
isMultiSortEvent,
|
|
363
|
+
manualExpandedKey,
|
|
364
|
+
manualFilters,
|
|
365
|
+
manualGlobalFilter,
|
|
366
|
+
manualRowSelectedKey,
|
|
367
|
+
manualSortBy,
|
|
368
|
+
maxMultiSortColCount,
|
|
369
|
+
orderByFn,
|
|
370
|
+
pageCount: pageCount ?? -1,
|
|
371
|
+
sortTypes,
|
|
312
372
|
columns,
|
|
313
373
|
defaultColumn,
|
|
314
374
|
disableSortBy: !isSortable,
|
|
@@ -319,7 +379,7 @@ export const Table = (props) => {
|
|
|
319
379
|
getSubRows: subComponent ? getSubRowsWithSubComponents : getSubRows,
|
|
320
380
|
initialState: {
|
|
321
381
|
pageSize,
|
|
322
|
-
...
|
|
382
|
+
...initialState,
|
|
323
383
|
},
|
|
324
384
|
columnResizeMode,
|
|
325
385
|
getRowId: subComponent ? getRowIdWithSubComponents : getRowId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { defaultColumn } from 'react-table';
|
|
3
3
|
import cx from 'classnames';
|
|
4
|
-
import { Box,
|
|
4
|
+
import { Box, lineClamp, ShadowRoot } from '../../../utils/index.js';
|
|
5
5
|
import { TableInstanceContext } from '../utils.js';
|
|
6
6
|
export const DefaultCellRendererPropsChildren = React.createContext(void 0);
|
|
7
7
|
export const DefaultCell = (props) => {
|
|
@@ -14,6 +14,10 @@ export const DefaultCell = (props) => {
|
|
|
14
14
|
);
|
|
15
15
|
let isCellRendererChildrenCustom =
|
|
16
16
|
React.useContext(DefaultCellRendererPropsChildren) !== props.children;
|
|
17
|
+
let isDefaultTextCell =
|
|
18
|
+
'string' == typeof props.cellProps.value &&
|
|
19
|
+
!isCustomCell &&
|
|
20
|
+
!isCellRendererChildrenCustom;
|
|
17
21
|
let {
|
|
18
22
|
cellElementProps: {
|
|
19
23
|
className: cellElementClassName,
|
|
@@ -28,9 +32,7 @@ export const DefaultCell = (props) => {
|
|
|
28
32
|
className,
|
|
29
33
|
style,
|
|
30
34
|
status,
|
|
31
|
-
clamp =
|
|
32
|
-
!isCustomCell &&
|
|
33
|
-
!isCellRendererChildrenCustom,
|
|
35
|
+
clamp = isDefaultTextCell,
|
|
34
36
|
...rest
|
|
35
37
|
} = props;
|
|
36
38
|
let { key: cellElementKey, ...cellElementPropsRest } = cellElementProps;
|
|
@@ -61,12 +63,14 @@ export const DefaultCell = (props) => {
|
|
|
61
63
|
React.createElement(
|
|
62
64
|
TableCellContent,
|
|
63
65
|
{
|
|
64
|
-
shouldRenderWrapper:
|
|
66
|
+
shouldRenderWrapper: isDefaultTextCell,
|
|
65
67
|
},
|
|
66
68
|
clamp
|
|
67
69
|
? React.createElement(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
'div',
|
|
71
|
+
{
|
|
72
|
+
className: lineClamp.className,
|
|
73
|
+
},
|
|
70
74
|
React.createElement('slot', null),
|
|
71
75
|
)
|
|
72
76
|
: React.createElement('slot', null),
|
|
@@ -106,15 +110,15 @@ if ('development' === process.env.NODE_ENV)
|
|
|
106
110
|
let TableCellContent = (props) => {
|
|
107
111
|
let { children, shouldRenderWrapper } = props;
|
|
108
112
|
return shouldRenderWrapper
|
|
109
|
-
?
|
|
110
|
-
: React.createElement(
|
|
113
|
+
? React.createElement(
|
|
111
114
|
'div',
|
|
112
115
|
{
|
|
113
116
|
className: '_iui-table-cell-default-content',
|
|
114
117
|
onClick: (e) => e.stopPropagation(),
|
|
115
118
|
},
|
|
116
119
|
children,
|
|
117
|
-
)
|
|
120
|
+
)
|
|
121
|
+
: children;
|
|
118
122
|
};
|
|
119
123
|
let css = `
|
|
120
124
|
._iui-table-cell-default-content {
|
|
@@ -128,4 +132,5 @@ let css = `
|
|
|
128
132
|
inset: -6px;
|
|
129
133
|
z-index: -1;
|
|
130
134
|
}
|
|
135
|
+
${lineClamp.css}
|
|
131
136
|
`;
|
|
@@ -15,30 +15,35 @@ export const ExpanderColumn = (props = {}) => {
|
|
|
15
15
|
maxWidth: 48,
|
|
16
16
|
columnClassName: 'iui-slot',
|
|
17
17
|
cellClassName: 'iui-slot',
|
|
18
|
-
Cell: (
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
Cell: () => null,
|
|
19
|
+
cellRenderer: (props) => {
|
|
20
|
+
let { row } = props.cellProps;
|
|
21
|
+
let children = subComponent?.(row)
|
|
22
|
+
? React.createElement(
|
|
23
|
+
IconButton,
|
|
24
|
+
{
|
|
25
|
+
'aria-label': 'Toggle expandable content',
|
|
26
|
+
className: 'iui-table-row-expander',
|
|
27
|
+
styleType: 'borderless',
|
|
28
|
+
size: 'small',
|
|
29
|
+
onClick: (e) => {
|
|
30
|
+
e.stopPropagation();
|
|
31
|
+
row.toggleRowExpanded();
|
|
32
|
+
},
|
|
33
|
+
disabled: isDisabled?.(row.original),
|
|
34
|
+
'aria-expanded': row.isExpanded,
|
|
35
|
+
},
|
|
36
|
+
React.createElement(SvgChevronRight, null),
|
|
37
|
+
)
|
|
38
|
+
: null;
|
|
21
39
|
return React.createElement(
|
|
22
|
-
|
|
40
|
+
DefaultCell,
|
|
23
41
|
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
styleType: 'borderless',
|
|
27
|
-
size: 'small',
|
|
28
|
-
onClick: (e) => {
|
|
29
|
-
e.stopPropagation();
|
|
30
|
-
row.toggleRowExpanded();
|
|
31
|
-
},
|
|
32
|
-
disabled: isDisabled?.(props.row.original),
|
|
33
|
-
'aria-expanded': row.isExpanded,
|
|
42
|
+
...props,
|
|
43
|
+
isDisabled: (rowData) => !!isDisabled?.(rowData),
|
|
34
44
|
},
|
|
35
|
-
|
|
45
|
+
children,
|
|
36
46
|
);
|
|
37
47
|
},
|
|
38
|
-
cellRenderer: (props) =>
|
|
39
|
-
React.createElement(DefaultCell, {
|
|
40
|
-
...props,
|
|
41
|
-
isDisabled: (rowData) => !!isDisabled?.(rowData),
|
|
42
|
-
}),
|
|
43
48
|
};
|
|
44
49
|
};
|
|
@@ -44,8 +44,10 @@ export const SelectionColumn = (props = {}) => {
|
|
|
44
44
|
onChange: () => toggleAllRowsSelected(nextToggleState),
|
|
45
45
|
});
|
|
46
46
|
},
|
|
47
|
-
Cell: (
|
|
48
|
-
|
|
47
|
+
Cell: () => null,
|
|
48
|
+
cellRenderer: (props) => {
|
|
49
|
+
let { row, selectSubRows = true } = props.cellProps;
|
|
50
|
+
let children = React.createElement(Checkbox, {
|
|
49
51
|
...row.getToggleRowSelectedProps(),
|
|
50
52
|
style: {},
|
|
51
53
|
title: '',
|
|
@@ -65,11 +67,15 @@ export const SelectionColumn = (props = {}) => {
|
|
|
65
67
|
);
|
|
66
68
|
else row.toggleRowSelected(!row.isSelected);
|
|
67
69
|
},
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
});
|
|
71
|
+
return React.createElement(
|
|
72
|
+
DefaultCell,
|
|
73
|
+
{
|
|
74
|
+
...props,
|
|
75
|
+
isDisabled: (rowData) => !!isDisabled?.(rowData),
|
|
76
|
+
},
|
|
77
|
+
children,
|
|
78
|
+
);
|
|
79
|
+
},
|
|
74
80
|
};
|
|
75
81
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ExpanderColumn, EXPANDER_CELL_ID } from '../columns/index.js';
|
|
3
|
+
import { DefaultCell } from '../cells/DefaultCell.js';
|
|
3
4
|
export const useExpanderCell =
|
|
4
5
|
(subComponent, expanderCell, isRowDisabled) => (hooks) => {
|
|
5
6
|
if (!subComponent) return;
|
|
@@ -13,14 +14,17 @@ export const useExpanderCell =
|
|
|
13
14
|
return [
|
|
14
15
|
{
|
|
15
16
|
...expanderColumn,
|
|
16
|
-
|
|
17
|
-
? (
|
|
17
|
+
cellRenderer: expanderCell
|
|
18
|
+
? (props) =>
|
|
18
19
|
React.createElement(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
DefaultCell,
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
isDisabled: (rowData) => !!isRowDisabled?.(rowData),
|
|
24
|
+
},
|
|
25
|
+
expanderCell(props.cellProps),
|
|
22
26
|
)
|
|
23
|
-
: expanderColumn.
|
|
27
|
+
: expanderColumn.cellRenderer,
|
|
24
28
|
},
|
|
25
29
|
...columns,
|
|
26
30
|
];
|