@itwin/itwinui-react 2.4.0-dev.3 → 2.4.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 +35 -0
- package/cjs/core/Avatar/Avatar.d.ts +2 -3
- package/cjs/core/Avatar/Avatar.js +4 -2
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +1 -1
- package/cjs/core/ThemeProvider/ThemeProvider.js +3 -6
- package/esm/core/Avatar/Avatar.d.ts +2 -3
- package/esm/core/Avatar/Avatar.js +4 -2
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +1 -1
- package/esm/core/ThemeProvider/ThemeProvider.js +3 -6
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 054bc3ba: `<Avatar>`'s `image` now supports passing `<svg>` too
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
<Avatar image={<SvgUser />} />
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- 06476ada: Added new `Flex` utility component and optional `Flex.Spacer`/`Flex.Item` subcomponents to make it easier to work with CSS flexbox and use iTwinUI design tokens for gap.
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
<Flex gap='xl' justifyContent='center'>
|
|
17
|
+
<div>...</div>
|
|
18
|
+
<div>...</div>
|
|
19
|
+
</Flex>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```jsx
|
|
23
|
+
<Flex>
|
|
24
|
+
<Flex.Item>...</Flex.Item>
|
|
25
|
+
<Flex.Spacer />
|
|
26
|
+
<Flex.Item>...</Flex.Item>
|
|
27
|
+
<Flex.Item>...</Flex.Item>
|
|
28
|
+
</Flex>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- 44446e50: `DropdownButton` now exposes `dropdownMenuProps` to allow control over all popover props, such as `placement`.
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies
|
|
36
|
+
- @itwin/itwinui-css@1.5.0
|
|
37
|
+
|
|
3
38
|
## 2.3.0
|
|
4
39
|
|
|
5
40
|
### Minor Changes
|
|
@@ -28,12 +28,11 @@ export declare type AvatarProps = {
|
|
|
28
28
|
*/
|
|
29
29
|
abbreviation?: string;
|
|
30
30
|
/**
|
|
31
|
-
* User image to be displayed.
|
|
31
|
+
* User image to be displayed. Can be `<img>` or `<svg>` or anything else.
|
|
32
32
|
*/
|
|
33
33
|
image?: JSX.Element;
|
|
34
34
|
/**
|
|
35
|
-
* Color of the icon. You can use `getUserColor` function to generate color from user name or email.
|
|
36
|
-
* @default 'white'
|
|
35
|
+
* Color of the icon. You can use `getUserColor` function to generate color from user name or email. If not provided, default background color from CSS styling will be used (hsl(72, 51%, 56%) / olive green).
|
|
37
36
|
*/
|
|
38
37
|
backgroundColor?: string;
|
|
39
38
|
/**
|
|
@@ -34,10 +34,12 @@ exports.defaultStatusTitles = {
|
|
|
34
34
|
* <Avatar size='x-large' title='Terry Rivers' abbreviation='TR' backgroundColor='green' image={<img src="https://cdn.example.com/user/profile/pic.png" />}/>
|
|
35
35
|
*/
|
|
36
36
|
const Avatar = (props) => {
|
|
37
|
-
const { size = 'small', status, abbreviation, image, backgroundColor
|
|
37
|
+
const { size = 'small', status, abbreviation, image, backgroundColor, title, translatedStatusTitles, className, style, ...rest } = props;
|
|
38
38
|
(0, utils_1.useTheme)();
|
|
39
39
|
const statusTitles = { ...exports.defaultStatusTitles, ...translatedStatusTitles };
|
|
40
|
-
return (react_1.default.createElement("span", { className: (0, classnames_1.default)('iui-avatar', { [`iui-${size}`]: size !== 'medium' }, className), title: title, style:
|
|
40
|
+
return (react_1.default.createElement("span", { className: (0, classnames_1.default)('iui-avatar', { [`iui-${size}`]: size !== 'medium' }, className), title: title, style: { backgroundColor, ...style }, ...rest },
|
|
41
|
+
!image && (react_1.default.createElement("abbr", { className: 'iui-initials' }, abbreviation === null || abbreviation === void 0 ? void 0 : abbreviation.substring(0, 2))),
|
|
42
|
+
image,
|
|
41
43
|
react_1.default.createElement("span", { className: 'iui-stroke' }),
|
|
42
44
|
status && (react_1.default.createElement("span", { title: statusTitles[status], className: (0, classnames_1.default)('iui-status', {
|
|
43
45
|
[`iui-${status}`]: !!status,
|
|
@@ -13,7 +13,7 @@ declare type RootProps = {
|
|
|
13
13
|
*
|
|
14
14
|
* @default 'light'
|
|
15
15
|
*/
|
|
16
|
-
theme?: ThemeType
|
|
16
|
+
theme?: ThemeType;
|
|
17
17
|
themeOptions?: Pick<ThemeOptions, 'highContrast'> & {
|
|
18
18
|
/**
|
|
19
19
|
* Whether or not the element should apply the recommended `background-color` on itself.
|
|
@@ -40,17 +40,15 @@ require("@itwin/itwinui-variables/index.css");
|
|
|
40
40
|
* </ThemeProvider>
|
|
41
41
|
*/
|
|
42
42
|
exports.ThemeProvider = react_1.default.forwardRef((props, ref) => {
|
|
43
|
-
|
|
44
|
-
const { theme: themeProp, children, themeOptions, ...rest } = props;
|
|
43
|
+
const { theme, children, themeOptions, ...rest } = props;
|
|
45
44
|
const rootRef = react_1.default.useRef(null);
|
|
46
45
|
const mergedRefs = (0, utils_1.useMergedRefs)(rootRef, ref);
|
|
47
46
|
const hasChildren = react_1.default.Children.count(children) > 0;
|
|
48
47
|
const parentContext = react_1.default.useContext(exports.ThemeContext);
|
|
49
|
-
const theme = themeProp === 'inherit' ? (_a = parentContext === null || parentContext === void 0 ? void 0 : parentContext.theme) !== null && _a !== void 0 ? _a : 'light' : themeProp;
|
|
50
48
|
const contextValue = react_1.default.useMemo(() => ({ theme, themeOptions, rootRef }), [theme, themeOptions]);
|
|
51
49
|
// if no children, then fallback to this wrapper component which calls useTheme
|
|
52
50
|
if (!hasChildren) {
|
|
53
|
-
return (react_1.default.createElement(ThemeLogicWrapper, { theme: theme, themeOptions: themeOptions !== null && themeOptions !== void 0 ? themeOptions : parentContext === null || parentContext === void 0 ? void 0 : parentContext.themeOptions }));
|
|
51
|
+
return (react_1.default.createElement(ThemeLogicWrapper, { theme: theme !== null && theme !== void 0 ? theme : parentContext === null || parentContext === void 0 ? void 0 : parentContext.theme, themeOptions: themeOptions !== null && themeOptions !== void 0 ? themeOptions : parentContext === null || parentContext === void 0 ? void 0 : parentContext.themeOptions }));
|
|
54
52
|
}
|
|
55
53
|
// now that we know there are children, we can render the root and provide the context value
|
|
56
54
|
return (react_1.default.createElement(Root, { theme: theme, themeOptions: themeOptions, ref: mergedRefs, ...rest },
|
|
@@ -71,8 +69,7 @@ const Root = react_1.default.forwardRef((props, forwardedRef) => {
|
|
|
71
69
|
const shouldApplyBackground = (_c = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.applyBackground) !== null && _c !== void 0 ? _c : !isThemeAlreadySet.current;
|
|
72
70
|
return (react_1.default.createElement(Element, { className: (0, classnames_1.default)('iui-root', { 'iui-root-background': shouldApplyBackground }, className), "data-iui-theme": shouldApplyDark ? 'dark' : 'light', "data-iui-contrast": shouldApplyHC ? 'high' : 'default', ref: mergedRefs, ...rest }, children));
|
|
73
71
|
});
|
|
74
|
-
const ThemeLogicWrapper = (
|
|
75
|
-
const { theme, themeOptions } = props;
|
|
72
|
+
const ThemeLogicWrapper = ({ theme, themeOptions }) => {
|
|
76
73
|
(0, utils_1.useTheme)(theme, themeOptions);
|
|
77
74
|
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
78
75
|
};
|
|
@@ -28,12 +28,11 @@ export declare type AvatarProps = {
|
|
|
28
28
|
*/
|
|
29
29
|
abbreviation?: string;
|
|
30
30
|
/**
|
|
31
|
-
* User image to be displayed.
|
|
31
|
+
* User image to be displayed. Can be `<img>` or `<svg>` or anything else.
|
|
32
32
|
*/
|
|
33
33
|
image?: JSX.Element;
|
|
34
34
|
/**
|
|
35
|
-
* Color of the icon. You can use `getUserColor` function to generate color from user name or email.
|
|
36
|
-
* @default 'white'
|
|
35
|
+
* Color of the icon. You can use `getUserColor` function to generate color from user name or email. If not provided, default background color from CSS styling will be used (hsl(72, 51%, 56%) / olive green).
|
|
37
36
|
*/
|
|
38
37
|
backgroundColor?: string;
|
|
39
38
|
/**
|
|
@@ -28,10 +28,12 @@ export const defaultStatusTitles = {
|
|
|
28
28
|
* <Avatar size='x-large' title='Terry Rivers' abbreviation='TR' backgroundColor='green' image={<img src="https://cdn.example.com/user/profile/pic.png" />}/>
|
|
29
29
|
*/
|
|
30
30
|
export const Avatar = (props) => {
|
|
31
|
-
const { size = 'small', status, abbreviation, image, backgroundColor
|
|
31
|
+
const { size = 'small', status, abbreviation, image, backgroundColor, title, translatedStatusTitles, className, style, ...rest } = props;
|
|
32
32
|
useTheme();
|
|
33
33
|
const statusTitles = { ...defaultStatusTitles, ...translatedStatusTitles };
|
|
34
|
-
return (React.createElement("span", { className: cx('iui-avatar', { [`iui-${size}`]: size !== 'medium' }, className), title: title, style:
|
|
34
|
+
return (React.createElement("span", { className: cx('iui-avatar', { [`iui-${size}`]: size !== 'medium' }, className), title: title, style: { backgroundColor, ...style }, ...rest },
|
|
35
|
+
!image && (React.createElement("abbr", { className: 'iui-initials' }, abbreviation === null || abbreviation === void 0 ? void 0 : abbreviation.substring(0, 2))),
|
|
36
|
+
image,
|
|
35
37
|
React.createElement("span", { className: 'iui-stroke' }),
|
|
36
38
|
status && (React.createElement("span", { title: statusTitles[status], className: cx('iui-status', {
|
|
37
39
|
[`iui-${status}`]: !!status,
|
|
@@ -13,7 +13,7 @@ declare type RootProps = {
|
|
|
13
13
|
*
|
|
14
14
|
* @default 'light'
|
|
15
15
|
*/
|
|
16
|
-
theme?: ThemeType
|
|
16
|
+
theme?: ThemeType;
|
|
17
17
|
themeOptions?: Pick<ThemeOptions, 'highContrast'> & {
|
|
18
18
|
/**
|
|
19
19
|
* Whether or not the element should apply the recommended `background-color` on itself.
|
|
@@ -34,17 +34,15 @@ import '@itwin/itwinui-variables/index.css';
|
|
|
34
34
|
* </ThemeProvider>
|
|
35
35
|
*/
|
|
36
36
|
export const ThemeProvider = React.forwardRef((props, ref) => {
|
|
37
|
-
|
|
38
|
-
const { theme: themeProp, children, themeOptions, ...rest } = props;
|
|
37
|
+
const { theme, children, themeOptions, ...rest } = props;
|
|
39
38
|
const rootRef = React.useRef(null);
|
|
40
39
|
const mergedRefs = useMergedRefs(rootRef, ref);
|
|
41
40
|
const hasChildren = React.Children.count(children) > 0;
|
|
42
41
|
const parentContext = React.useContext(ThemeContext);
|
|
43
|
-
const theme = themeProp === 'inherit' ? (_a = parentContext === null || parentContext === void 0 ? void 0 : parentContext.theme) !== null && _a !== void 0 ? _a : 'light' : themeProp;
|
|
44
42
|
const contextValue = React.useMemo(() => ({ theme, themeOptions, rootRef }), [theme, themeOptions]);
|
|
45
43
|
// if no children, then fallback to this wrapper component which calls useTheme
|
|
46
44
|
if (!hasChildren) {
|
|
47
|
-
return (React.createElement(ThemeLogicWrapper, { theme: theme, themeOptions: themeOptions !== null && themeOptions !== void 0 ? themeOptions : parentContext === null || parentContext === void 0 ? void 0 : parentContext.themeOptions }));
|
|
45
|
+
return (React.createElement(ThemeLogicWrapper, { theme: theme !== null && theme !== void 0 ? theme : parentContext === null || parentContext === void 0 ? void 0 : parentContext.theme, themeOptions: themeOptions !== null && themeOptions !== void 0 ? themeOptions : parentContext === null || parentContext === void 0 ? void 0 : parentContext.themeOptions }));
|
|
48
46
|
}
|
|
49
47
|
// now that we know there are children, we can render the root and provide the context value
|
|
50
48
|
return (React.createElement(Root, { theme: theme, themeOptions: themeOptions, ref: mergedRefs, ...rest },
|
|
@@ -65,8 +63,7 @@ const Root = React.forwardRef((props, forwardedRef) => {
|
|
|
65
63
|
const shouldApplyBackground = (_c = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.applyBackground) !== null && _c !== void 0 ? _c : !isThemeAlreadySet.current;
|
|
66
64
|
return (React.createElement(Element, { className: cx('iui-root', { 'iui-root-background': shouldApplyBackground }, className), "data-iui-theme": shouldApplyDark ? 'dark' : 'light', "data-iui-contrast": shouldApplyHC ? 'high' : 'default', ref: mergedRefs, ...rest }, children));
|
|
67
65
|
});
|
|
68
|
-
const ThemeLogicWrapper = (
|
|
69
|
-
const { theme, themeOptions } = props;
|
|
66
|
+
const ThemeLogicWrapper = ({ theme, themeOptions }) => {
|
|
70
67
|
useTheme(theme, themeOptions);
|
|
71
68
|
return React.createElement(React.Fragment, null);
|
|
72
69
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/itwinui-react",
|
|
3
|
-
"version": "2.4.0
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"author": "Bentley Systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"dev:types": "concurrently \"tsc -p tsconfig.cjs.json --emitDeclarationOnly --watch --preserveWatchOutput\" \"tsc -p tsconfig.esm.json --emitDeclarationOnly --watch --preserveWatchOutput\""
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@itwin/itwinui-css": "1.5.0
|
|
65
|
+
"@itwin/itwinui-css": "^1.5.0",
|
|
66
66
|
"@itwin/itwinui-illustrations-react": "^2.0.0",
|
|
67
|
-
"@itwin/itwinui-variables": "
|
|
67
|
+
"@itwin/itwinui-variables": "^1.0.0",
|
|
68
68
|
"@tippyjs/react": "^4.2.6",
|
|
69
69
|
"@types/react-table": "^7.0.18",
|
|
70
70
|
"classnames": "^2.2.6",
|