@itwin/itwinui-react 3.0.0-dev.2 → 3.0.0-dev.4
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/Alert/Alert.d.ts +2 -2
- package/cjs/core/Avatar/Avatar.d.ts +0 -4
- package/cjs/core/Avatar/Avatar.js +1 -5
- package/cjs/core/Avatar/index.d.ts +1 -1
- package/cjs/core/Avatar/index.js +1 -2
- package/cjs/core/AvatarGroup/AvatarGroup.d.ts +0 -4
- package/cjs/core/AvatarGroup/AvatarGroup.js +1 -5
- package/cjs/core/AvatarGroup/index.d.ts +1 -1
- package/cjs/core/AvatarGroup/index.js +1 -2
- package/cjs/core/FileUpload/FileUpload.d.ts +3 -4
- package/cjs/core/FileUpload/FileUpload.js +2 -2
- package/cjs/core/FileUpload/FileUploadTemplate.d.ts +1 -0
- package/cjs/core/FileUpload/FileUploadTemplate.js +1 -0
- package/cjs/core/Header/Header.d.ts +1 -20
- package/cjs/core/Header/Header.js +1 -2
- package/cjs/core/ProgressIndicators/ProgressRadial/ProgressRadial.d.ts +2 -2
- package/cjs/core/ProgressIndicators/ProgressRadial/ProgressRadial.js +10 -17
- package/cjs/core/Slider/Slider.d.ts +2 -1
- package/cjs/core/Slider/Thumb.d.ts +2 -2
- package/cjs/core/Slider/Thumb.js +1 -1
- package/cjs/core/Stepper/index.d.ts +0 -4
- package/cjs/core/Stepper/index.js +1 -4
- package/cjs/core/Tabs/Tabs.d.ts +0 -36
- package/cjs/core/Tabs/Tabs.js +1 -29
- package/cjs/core/Tabs/index.d.ts +1 -1
- package/cjs/core/Tabs/index.js +1 -3
- package/cjs/core/ThemeProvider/ThemeProvider.js +5 -2
- package/cjs/core/Tile/Tile.d.ts +157 -99
- package/cjs/core/Tile/Tile.js +273 -99
- package/cjs/core/Toast/Toast.d.ts +5 -10
- package/cjs/core/Toast/Toast.js +15 -13
- package/cjs/core/Toast/Toaster.d.ts +24 -26
- package/cjs/core/Toast/Toaster.js +91 -116
- package/cjs/core/Toast/index.d.ts +1 -4
- package/cjs/core/Toast/index.js +3 -6
- package/cjs/core/Tooltip/Tooltip.d.ts +67 -7
- package/cjs/core/Tooltip/Tooltip.js +96 -7
- package/cjs/core/index.d.ts +6 -7
- package/cjs/core/index.js +4 -12
- package/cjs/core/utils/components/Popover.d.ts +1 -1
- package/cjs/core/utils/functions/dom.d.ts +0 -8
- package/cjs/core/utils/functions/dom.js +1 -24
- package/cjs/core/utils/functions/polymorphic.d.ts +1 -1
- package/cjs/styles.js +1 -5
- package/esm/core/Alert/Alert.d.ts +2 -2
- package/esm/core/Avatar/Avatar.d.ts +0 -4
- package/esm/core/Avatar/Avatar.js +0 -4
- package/esm/core/Avatar/index.d.ts +1 -1
- package/esm/core/Avatar/index.js +1 -1
- package/esm/core/AvatarGroup/AvatarGroup.d.ts +0 -4
- package/esm/core/AvatarGroup/AvatarGroup.js +0 -4
- package/esm/core/AvatarGroup/index.d.ts +1 -1
- package/esm/core/AvatarGroup/index.js +1 -1
- package/esm/core/FileUpload/FileUpload.d.ts +3 -4
- package/esm/core/FileUpload/FileUpload.js +2 -2
- package/esm/core/FileUpload/FileUploadTemplate.d.ts +1 -0
- package/esm/core/FileUpload/FileUploadTemplate.js +1 -0
- package/esm/core/Header/Header.d.ts +1 -20
- package/esm/core/Header/Header.js +1 -2
- package/esm/core/ProgressIndicators/ProgressRadial/ProgressRadial.d.ts +2 -2
- package/esm/core/ProgressIndicators/ProgressRadial/ProgressRadial.js +11 -18
- package/esm/core/Slider/Slider.d.ts +2 -1
- package/esm/core/Slider/Thumb.d.ts +2 -2
- package/esm/core/Slider/Thumb.js +1 -1
- package/esm/core/Stepper/index.d.ts +0 -4
- package/esm/core/Stepper/index.js +0 -2
- package/esm/core/Tabs/Tabs.d.ts +0 -36
- package/esm/core/Tabs/Tabs.js +0 -26
- package/esm/core/Tabs/index.d.ts +1 -1
- package/esm/core/Tabs/index.js +1 -1
- package/esm/core/ThemeProvider/ThemeProvider.js +5 -2
- package/esm/core/Tile/Tile.d.ts +157 -99
- package/esm/core/Tile/Tile.js +273 -99
- package/esm/core/Toast/Toast.d.ts +5 -10
- package/esm/core/Toast/Toast.js +16 -14
- package/esm/core/Toast/Toaster.d.ts +24 -26
- package/esm/core/Toast/Toaster.js +85 -116
- package/esm/core/Toast/index.d.ts +1 -4
- package/esm/core/Toast/index.js +1 -3
- package/esm/core/Tooltip/Tooltip.d.ts +67 -7
- package/esm/core/Tooltip/Tooltip.js +97 -7
- package/esm/core/index.d.ts +6 -7
- package/esm/core/index.js +5 -5
- package/esm/core/utils/components/Popover.d.ts +1 -1
- package/esm/core/utils/functions/dom.d.ts +0 -8
- package/esm/core/utils/functions/dom.js +0 -19
- package/esm/core/utils/functions/polymorphic.d.ts +1 -1
- package/esm/styles.js +1 -5
- package/package.json +4 -3
- package/styles.css +55 -52
- package/cjs/core/Stepper/Wizard.d.ts +0 -46
- package/cjs/core/Stepper/Wizard.js +0 -55
- package/cjs/core/Toast/ToastWrapper.d.ts +0 -10
- package/cjs/core/Toast/ToastWrapper.js +0 -49
- package/esm/core/Stepper/Wizard.d.ts +0 -46
- package/esm/core/Stepper/Wizard.js +0 -29
- package/esm/core/Toast/ToastWrapper.d.ts +0 -10
- package/esm/core/Toast/ToastWrapper.js +0 -20
package/cjs/core/Tile/Tile.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.Tile =
|
|
29
|
+
exports.Tile = void 0;
|
|
30
30
|
/*---------------------------------------------------------------------------------------------
|
|
31
31
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
32
32
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -38,51 +38,21 @@ const index_js_2 = require("../DropdownMenu/index.js");
|
|
|
38
38
|
const index_js_3 = require("../Buttons/index.js");
|
|
39
39
|
const index_js_4 = require("../ProgressIndicators/index.js");
|
|
40
40
|
const TileContext = React.createContext(undefined);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return React.createElement(index_js_1.LinkAction, { ref: forwardedRef, ...props });
|
|
57
|
-
});
|
|
58
|
-
/**
|
|
59
|
-
* Tile component that displays content and actions in a card-like format.
|
|
60
|
-
* @example
|
|
61
|
-
* <Tile
|
|
62
|
-
* name='Tile name'
|
|
63
|
-
* description='Tile description that takes upto 3 lines'
|
|
64
|
-
* metadata={<TagContainer><Tag variant='basic'>Tag 1</Tag></TagContainer>}
|
|
65
|
-
* thumbnail='/url/to/image.jpg'
|
|
66
|
-
* badge={<Badge backgroundColor='blue'>Badge label</Badge>}
|
|
67
|
-
* buttons={[<Button>Button 1</Button>, <Button>Button 2</Button>]}
|
|
68
|
-
* moreOptions={[<MenuItem>Item 1</MenuItem>, <MenuItem>Item 2</MenuItem>]}
|
|
69
|
-
* leftIcon={<IconButton><SvgInfo /></IconButton>}
|
|
70
|
-
* rightIcon={<IconButton><SvgStar /></IconButton>}
|
|
71
|
-
* isSelected={true}
|
|
72
|
-
* isNew={false}
|
|
73
|
-
* />
|
|
74
|
-
*/
|
|
75
|
-
exports.Tile = Object.assign(React.forwardRef((props, forwardedRef) => {
|
|
76
|
-
const { className, name, description, metadata, thumbnail, buttons, leftIcon, rightIcon, badge, isNew, isSelected, moreOptions, variant = 'default', children, isActionable: isActionableProp, status, isLoading = false, isDisabled = false, onClick, ...rest } = props;
|
|
77
|
-
const [isMenuVisible, setIsMenuVisible] = React.useState(false);
|
|
78
|
-
const showMenu = React.useCallback(() => setIsMenuVisible(true), []);
|
|
79
|
-
const hideMenu = React.useCallback(() => setIsMenuVisible(false), []);
|
|
80
|
-
const [localActionable, setLocalActionable] = React.useState(isActionableProp);
|
|
81
|
-
const isActionable = isActionableProp ?? localActionable;
|
|
82
|
-
const tileName = (React.createElement(index_js_1.Box, { className: 'iui-tile-name' },
|
|
83
|
-
React.createElement(TitleIcon, { isLoading: isLoading, isSelected: isSelected, isNew: isNew, status: status }),
|
|
84
|
-
React.createElement(index_js_1.Box, { as: 'span', className: 'iui-tile-name-label' }, isActionable && onClick ? (React.createElement(index_js_1.LinkAction, { as: 'button', onClick: !isDisabled ? onClick : undefined, "aria-disabled": isDisabled }, name)) : (name))));
|
|
85
|
-
return (React.createElement(TileContext.Provider, { value: { setActionable: setLocalActionable } },
|
|
41
|
+
TileContext.displayName = 'TileContext';
|
|
42
|
+
const TileComponent = React.forwardRef((props, forwardedRef) => {
|
|
43
|
+
const { className, status, variant, isNew, isSelected, isLoading, isDisabled, ...rest } = props;
|
|
44
|
+
const [localActionable, setLocalActionable] = React.useState(false);
|
|
45
|
+
const isActionable = localActionable;
|
|
46
|
+
return (React.createElement(TileContext.Provider, { value: {
|
|
47
|
+
status,
|
|
48
|
+
variant,
|
|
49
|
+
isNew,
|
|
50
|
+
isSelected,
|
|
51
|
+
isLoading,
|
|
52
|
+
isActionable,
|
|
53
|
+
isDisabled,
|
|
54
|
+
setActionable: setLocalActionable,
|
|
55
|
+
} },
|
|
86
56
|
React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-tile', {
|
|
87
57
|
'iui-folder': variant === 'folder',
|
|
88
58
|
'iui-new': isNew,
|
|
@@ -90,65 +60,269 @@ exports.Tile = Object.assign(React.forwardRef((props, forwardedRef) => {
|
|
|
90
60
|
'iui-actionable': isActionable,
|
|
91
61
|
[`iui-${status}`]: !!status,
|
|
92
62
|
'iui-loading': isLoading,
|
|
93
|
-
}, className), "aria-disabled": isDisabled, ref: forwardedRef, ...rest }
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
63
|
+
}, className), "aria-disabled": isDisabled, ref: forwardedRef, ...rest })));
|
|
64
|
+
});
|
|
65
|
+
TileComponent.displayName = 'Tile';
|
|
66
|
+
// ----------------------------------------------------------------------------
|
|
67
|
+
// Tile.Action component
|
|
68
|
+
const TileAction = React.forwardRef((props, forwardedRef) => {
|
|
69
|
+
const { onClick, children, href, ...rest } = props;
|
|
70
|
+
const { setActionable, isDisabled } = (0, index_js_1.useSafeContext)(TileContext);
|
|
71
|
+
React.useEffect(() => {
|
|
72
|
+
if (!(0, index_js_1.supportsHas)()) {
|
|
73
|
+
setActionable(true);
|
|
74
|
+
}
|
|
75
|
+
}, [setActionable]);
|
|
76
|
+
return (React.createElement(index_js_1.LinkAction, { as: (!!props.href ? 'a' : 'button'), href: href, onClick: !isDisabled ? onClick : undefined, "aria-disabled": isDisabled, ref: forwardedRef, ...rest }, children));
|
|
77
|
+
});
|
|
78
|
+
TileAction.displayName = 'Tile.Action';
|
|
79
|
+
// ----------------------------------------------------------------------------
|
|
80
|
+
// Tile.ThumbnailArea component
|
|
81
|
+
const TileThumbnailArea = (0, index_js_1.polymorphic)('iui-tile-thumbnail');
|
|
82
|
+
TileThumbnailArea.displayName = 'Tile.ThumbnailArea';
|
|
83
|
+
const TileThumbnailPicture = React.forwardRef((props, forwardedRef) => {
|
|
84
|
+
const { className, url, children, ...rest } = props;
|
|
85
|
+
if (url) {
|
|
86
|
+
return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-tile-thumbnail-picture', className), style: {
|
|
87
|
+
backgroundImage: typeof url === 'string' ? `url(${url})` : undefined,
|
|
88
|
+
}, ref: forwardedRef, ...rest }));
|
|
89
|
+
}
|
|
90
|
+
return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-thumbnail-icon', className), ref: forwardedRef, ...rest }, children));
|
|
91
|
+
});
|
|
92
|
+
TileThumbnailPicture.displayName = 'Tile.TileThumbnailPicture';
|
|
93
|
+
// ----------------------------------------------------------------------------
|
|
94
|
+
// Tile.QuickAction component
|
|
95
|
+
const TileQuickAction = (0, index_js_1.polymorphic)('iui-tile-thumbnail-quick-action');
|
|
96
|
+
TileQuickAction.displayName = 'Tile.QuickAction';
|
|
97
|
+
// ----------------------------------------------------------------------------
|
|
98
|
+
// Tile.TypeIndicator component
|
|
99
|
+
const TileTypeIndicator = (0, index_js_1.polymorphic)('iui-tile-thumbnail-type-indicator');
|
|
100
|
+
TileTypeIndicator.displayName = 'Tile.TypeIndicator';
|
|
101
|
+
// ----------------------------------------------------------------------------
|
|
102
|
+
// Tile.IconButton component
|
|
103
|
+
const TileIconButton = React.forwardRef((props, forwardedRef) => {
|
|
104
|
+
const { className, children, ...rest } = props;
|
|
105
|
+
return (React.createElement(index_js_3.IconButton, { className: className, styleType: 'borderless', size: 'small', ref: forwardedRef, ...rest }, children));
|
|
106
|
+
});
|
|
107
|
+
TileIconButton.displayName = 'Tile.IconButton';
|
|
108
|
+
// ----------------------------------------------------------------------------
|
|
109
|
+
// Tile.BadgeContainer component
|
|
110
|
+
const TileBadgeContainer = (0, index_js_1.polymorphic)('iui-tile-thumbnail-badge-container');
|
|
111
|
+
TileBadgeContainer.displayName = 'Tile.BadgeContainer';
|
|
112
|
+
const TileName = React.forwardRef((props, forwardedRef) => {
|
|
113
|
+
const { className, children, name, ...rest } = props;
|
|
114
|
+
return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-tile-name', className), ref: forwardedRef, ...rest }, children ?? name));
|
|
137
115
|
});
|
|
138
|
-
|
|
116
|
+
TileBadgeContainer.displayName = 'Tile.Name';
|
|
117
|
+
// ----------------------------------------------------------------------------
|
|
118
|
+
// Tile.NameIcon component
|
|
119
|
+
const TileNameIcon = React.forwardRef((props, forwardedRef) => {
|
|
120
|
+
const { children, className, ...rest } = props;
|
|
121
|
+
const { status, isLoading, isSelected, isNew } = (0, index_js_1.useSafeContext)(TileContext);
|
|
139
122
|
const StatusIcon = !!status && index_js_1.StatusIconMap[status];
|
|
123
|
+
let icon;
|
|
124
|
+
if (StatusIcon) {
|
|
125
|
+
icon = React.createElement(StatusIcon, { "aria-hidden": true });
|
|
126
|
+
}
|
|
140
127
|
if (isLoading) {
|
|
141
|
-
|
|
128
|
+
icon = React.createElement(index_js_4.ProgressRadial, { size: 'x-small', "aria-hidden": true, indeterminate: true });
|
|
142
129
|
}
|
|
143
130
|
if (isSelected) {
|
|
144
|
-
|
|
131
|
+
icon = React.createElement(index_js_1.SvgCheckmark, { "aria-hidden": true });
|
|
145
132
|
}
|
|
146
133
|
if (isNew) {
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
if (StatusIcon) {
|
|
150
|
-
return React.createElement(StatusIcon, { className: 'iui-tile-status-icon' });
|
|
134
|
+
icon = React.createElement(index_js_1.SvgNew, { "aria-hidden": true });
|
|
151
135
|
}
|
|
152
|
-
return null;
|
|
153
|
-
};
|
|
136
|
+
return children || icon ? (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-tile-status-icon', className), ref: forwardedRef, ...rest }, children ?? icon)) : null;
|
|
137
|
+
});
|
|
138
|
+
TileNameIcon.displayName = 'Tile.NameIcon';
|
|
139
|
+
// ----------------------------------------------------------------------------
|
|
140
|
+
// Tile.NameLabel component
|
|
141
|
+
const TileNameLabel = index_js_1.polymorphic.span('iui-tile-name-label');
|
|
142
|
+
TileNameLabel.displayName = 'Tile.NameLabel';
|
|
143
|
+
// ----------------------------------------------------------------------------
|
|
144
|
+
// Tile.ContentArea component
|
|
145
|
+
const TileContentArea = (0, index_js_1.polymorphic)('iui-tile-content');
|
|
146
|
+
TileContentArea.displayName = 'Tile.ContentArea';
|
|
147
|
+
// ----------------------------------------------------------------------------
|
|
148
|
+
// Tile.Description component
|
|
149
|
+
const TileDescription = (0, index_js_1.polymorphic)('iui-tile-description');
|
|
150
|
+
TileDescription.displayName = 'Tile.Description';
|
|
151
|
+
// ----------------------------------------------------------------------------
|
|
152
|
+
// Tile.Metadata component
|
|
153
|
+
const TileMetadata = (0, index_js_1.polymorphic)('iui-tile-metadata');
|
|
154
|
+
TileMetadata.displayName = 'Tile.Metadata';
|
|
155
|
+
const TileMoreOptions = React.forwardRef((props, forwardedRef) => {
|
|
156
|
+
const { className, children = [], buttonProps, ...rest } = props;
|
|
157
|
+
const [isMenuVisible, setIsMenuVisible] = React.useState(false);
|
|
158
|
+
return (React.createElement(index_js_2.DropdownMenu, { onShow: React.useCallback(() => setIsMenuVisible(true), []), onHide: React.useCallback(() => setIsMenuVisible(false), []), menuItems: (close) => children?.map((option) => React.cloneElement(option, {
|
|
159
|
+
onClick: (value) => {
|
|
160
|
+
close();
|
|
161
|
+
option.props.onClick?.(value);
|
|
162
|
+
},
|
|
163
|
+
})) },
|
|
164
|
+
React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-tile-more-options', {
|
|
165
|
+
'iui-visible': isMenuVisible,
|
|
166
|
+
}, className), ref: forwardedRef, ...rest },
|
|
167
|
+
React.createElement(index_js_3.IconButton, { styleType: 'borderless', size: 'small', "aria-label": 'More options', ...buttonProps },
|
|
168
|
+
React.createElement(index_js_1.SvgMore, null)))));
|
|
169
|
+
});
|
|
170
|
+
TileMoreOptions.displayName = 'Tile.MoreOptions';
|
|
171
|
+
// ----------------------------------------------------------------------------
|
|
172
|
+
// Tile.Buttons component
|
|
173
|
+
const TileButtons = (0, index_js_1.polymorphic)('iui-tile-buttons');
|
|
174
|
+
TileButtons.displayName = 'Tile.Buttons';
|
|
175
|
+
/**
|
|
176
|
+
* Tile with customizable Thumbnail, Name, Content and Buttons subcomponents
|
|
177
|
+
* @example
|
|
178
|
+
* <Tile>
|
|
179
|
+
* <Tile.ThumbnailArea>
|
|
180
|
+
* <Tile.ThumbnailPicture/>
|
|
181
|
+
* <Tile.Badge/>
|
|
182
|
+
* <Tile.TypeIndicator/>
|
|
183
|
+
* <Tile.QuickAction/>
|
|
184
|
+
* </Tile.ThumbnailArea>
|
|
185
|
+
* <Tile.Name>
|
|
186
|
+
* <Tile.NameIcon/>
|
|
187
|
+
* <Tile.NameLabel/>
|
|
188
|
+
* <Tile.Name/>
|
|
189
|
+
* <Tile.ContentArea>
|
|
190
|
+
* <Tile.Description />
|
|
191
|
+
* <Tile.Metadata/>
|
|
192
|
+
* <Tile.MoreOptions/>
|
|
193
|
+
* </Tile.ContentArea>
|
|
194
|
+
* <Tile.Buttons/>
|
|
195
|
+
* </Tile>
|
|
196
|
+
*/
|
|
197
|
+
exports.Tile = Object.assign(TileComponent, {
|
|
198
|
+
/**
|
|
199
|
+
* ThumbnailArea subcomponent that contains `ThumbnailPicture`, `QuickAction`, `TypeIndicator` or `BadgeContainer`
|
|
200
|
+
* @example
|
|
201
|
+
* <Tile.ThumbnailArea>
|
|
202
|
+
* <Tile.ThumbnailPicture/>
|
|
203
|
+
* // or
|
|
204
|
+
* <Tile.ThumbnailAvatar/>
|
|
205
|
+
* <Tile.QuickAction/>
|
|
206
|
+
* <Tile.TypeIndicator/>
|
|
207
|
+
* <Tile.BadgeContainer/>
|
|
208
|
+
* </Tile.ThumbnailArea>
|
|
209
|
+
*/
|
|
210
|
+
ThumbnailArea: TileThumbnailArea,
|
|
211
|
+
/**
|
|
212
|
+
* Thumbnail image url, a custom component or an svg for thumbnail avatar.
|
|
213
|
+
* @example
|
|
214
|
+
* <Tile>
|
|
215
|
+
* // ...
|
|
216
|
+
* <Tile.ThumbnailArea>
|
|
217
|
+
* <Tile.ThumbnailPicture url = '/url/to/image.jpg'/>
|
|
218
|
+
* </Tile.ThumbnailArea>
|
|
219
|
+
* </Tile>
|
|
220
|
+
* or
|
|
221
|
+
* <Tile>
|
|
222
|
+
* // ...
|
|
223
|
+
* <Tile.ThumbnailArea>
|
|
224
|
+
* <Tile.ThumbnailPicture>
|
|
225
|
+
* {<Avatar image={<img src='icon.png' />} />}
|
|
226
|
+
* // or
|
|
227
|
+
* {<SvgImodelHollow />}
|
|
228
|
+
* </Tile.ThumbnailPicture>
|
|
229
|
+
* </Tile.ThumbnailArea>
|
|
230
|
+
* /Tile>
|
|
231
|
+
*/
|
|
232
|
+
ThumbnailPicture: TileThumbnailPicture,
|
|
233
|
+
/**
|
|
234
|
+
* `QuickAction` subcomponent shown on top left of the tile.
|
|
235
|
+
* Recommended to use an invisible `IconButton`.
|
|
236
|
+
*/
|
|
237
|
+
QuickAction: TileQuickAction,
|
|
238
|
+
/**
|
|
239
|
+
* `TypeIndicator` subcomponent shown on top left of the tile.
|
|
240
|
+
* Recommended to use an invisible `IconButton`.
|
|
241
|
+
*/
|
|
242
|
+
TypeIndicator: TileTypeIndicator,
|
|
243
|
+
/**
|
|
244
|
+
* `BadgeContainer` subcomponent shown on the bottom right of thumbnail.
|
|
245
|
+
*/
|
|
246
|
+
BadgeContainer: TileBadgeContainer,
|
|
247
|
+
/**
|
|
248
|
+
* `IconButton` subcomponent: custom icon for `QuickAction` and `TypeIndicator` buttons.
|
|
249
|
+
*/
|
|
250
|
+
IconButton: TileIconButton,
|
|
251
|
+
/**
|
|
252
|
+
* `Name` subcomponent under thumbnail or top of the Tile if no thumbnail present.
|
|
253
|
+
*/
|
|
254
|
+
Name: TileName,
|
|
255
|
+
/**
|
|
256
|
+
* `NameIcon` next to name of the tile. Goes under <Tile.Name>
|
|
257
|
+
* @example
|
|
258
|
+
* <Tile>
|
|
259
|
+
* <Tile.Name>
|
|
260
|
+
* <Tile.NameIcon/>
|
|
261
|
+
* </Tile.Name>
|
|
262
|
+
* <Tile/>
|
|
263
|
+
*/
|
|
264
|
+
NameIcon: TileNameIcon,
|
|
265
|
+
/*
|
|
266
|
+
* `NameLabel` of the tile
|
|
267
|
+
* @example
|
|
268
|
+
* <Tile>
|
|
269
|
+
* <Tile.Name>
|
|
270
|
+
* <Tile.NameLabel> Tile Name <Tile.NameLabel/>
|
|
271
|
+
* </Tile.Name/>
|
|
272
|
+
* <Tile/>
|
|
273
|
+
*/
|
|
274
|
+
NameLabel: TileNameLabel,
|
|
275
|
+
/**
|
|
276
|
+
* Polymorphic Tile action component. Recommended to be used in `Tile.NameLabel` subcomponent.
|
|
277
|
+
* Renders `a` element by default.
|
|
278
|
+
* @example
|
|
279
|
+
* <Tile.Name>
|
|
280
|
+
* <Tile.NameLabel>
|
|
281
|
+
* {<Tile.Action href='/new-page'>Tile Name<Tile.Action/>}
|
|
282
|
+
* <Tile.NameLabel/>
|
|
283
|
+
* </Tile.Name>
|
|
284
|
+
*/
|
|
285
|
+
Action: TileAction,
|
|
286
|
+
/**
|
|
287
|
+
* Tile content area that contains `Description`, `Metadata` and `MoreOptions` Tile subcomponents
|
|
288
|
+
* @example
|
|
289
|
+
* <Tile>
|
|
290
|
+
* <Tile.ContentArea>
|
|
291
|
+
* <Tile.Description/>
|
|
292
|
+
* <Tile.Metadata/>
|
|
293
|
+
* <Tile.MoreOptions/>
|
|
294
|
+
* </Tile.ContentArea>
|
|
295
|
+
* </Tile>
|
|
296
|
+
*/
|
|
297
|
+
ContentArea: TileContentArea,
|
|
298
|
+
/**
|
|
299
|
+
* Description text of the tile.
|
|
300
|
+
* Gets truncated if it can't fit in the tile.
|
|
301
|
+
*/
|
|
302
|
+
Description: TileDescription,
|
|
303
|
+
/**
|
|
304
|
+
* Metadata section located below description.
|
|
305
|
+
* @example
|
|
306
|
+
* <Tile.Metadata>
|
|
307
|
+
* // ...
|
|
308
|
+
* 'basic metadata'
|
|
309
|
+
* // or
|
|
310
|
+
* {<span><SvgClock /> 2021-01-01, 04:30 AM</span>}
|
|
311
|
+
* // or
|
|
312
|
+
* {<>
|
|
313
|
+
* <SvgTag2 />
|
|
314
|
+
* <TagContainer><Tag variant='basic'>Tag 1</Tag><Tag variant='basic'>Tag 2</Tag></TagContainer>
|
|
315
|
+
* </>}
|
|
316
|
+
* </Tile.Metadata>
|
|
317
|
+
*/
|
|
318
|
+
Metadata: TileMetadata,
|
|
319
|
+
/**
|
|
320
|
+
* Dropdown menu containing `MenuItem`s.
|
|
321
|
+
*/
|
|
322
|
+
MoreOptions: TileMoreOptions,
|
|
323
|
+
/**
|
|
324
|
+
* Upto two buttons shown at the bottom of the tile.
|
|
325
|
+
*/
|
|
326
|
+
Buttons: TileButtons,
|
|
327
|
+
});
|
|
154
328
|
exports.default = exports.Tile;
|
|
@@ -22,10 +22,9 @@ export declare type ToastProps = {
|
|
|
22
22
|
*/
|
|
23
23
|
type?: 'persisting' | 'temporary';
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* When false, will close the Toast and call onRemove when finished closing.
|
|
25
|
+
* Controlled boolean prop indicating whether the toast is visible.
|
|
27
26
|
*/
|
|
28
|
-
isVisible
|
|
27
|
+
isVisible?: boolean;
|
|
29
28
|
/**
|
|
30
29
|
* Duration of the toast in millisecond.
|
|
31
30
|
* @default 7000
|
|
@@ -37,12 +36,12 @@ export declare type ToastProps = {
|
|
|
37
36
|
*/
|
|
38
37
|
hasCloseButton?: boolean;
|
|
39
38
|
/**
|
|
40
|
-
*
|
|
39
|
+
* Props for a button/link that can be used to perform an action
|
|
40
|
+
* (e.g. to show additional information).
|
|
41
41
|
*/
|
|
42
42
|
link?: {
|
|
43
|
-
onClick: () => void;
|
|
44
43
|
title: string;
|
|
45
|
-
}
|
|
44
|
+
} & Omit<React.ComponentPropsWithoutRef<'button'>, 'children'>;
|
|
46
45
|
/**
|
|
47
46
|
* Function called when the toast is all the way closed.
|
|
48
47
|
*/
|
|
@@ -51,10 +50,6 @@ export declare type ToastProps = {
|
|
|
51
50
|
* Element to which the toast will animate out to.
|
|
52
51
|
*/
|
|
53
52
|
animateOutTo?: HTMLElement | null;
|
|
54
|
-
/**
|
|
55
|
-
* Parent toaster placement position for smoother animation.
|
|
56
|
-
*/
|
|
57
|
-
placementPosition?: 'top' | 'bottom';
|
|
58
53
|
};
|
|
59
54
|
/**
|
|
60
55
|
* Generic Toast Component
|
package/cjs/core/Toast/Toast.js
CHANGED
|
@@ -36,6 +36,7 @@ const react_transition_group_1 = require("react-transition-group");
|
|
|
36
36
|
const classnames_1 = __importDefault(require("classnames"));
|
|
37
37
|
const index_js_1 = require("../utils/index.js");
|
|
38
38
|
const index_js_2 = require("../Buttons/index.js");
|
|
39
|
+
const Toaster_js_1 = require("./Toaster.js");
|
|
39
40
|
const isMotionOk = () => (0, index_js_1.getWindow)()?.matchMedia?.('(prefers-reduced-motion: no-preference)')?.matches;
|
|
40
41
|
/**
|
|
41
42
|
* Generic Toast Component
|
|
@@ -46,9 +47,12 @@ const isMotionOk = () => (0, index_js_1.getWindow)()?.matchMedia?.('(prefers-red
|
|
|
46
47
|
* <Toast type='persisting' content='Job processing error.' category='negative' />
|
|
47
48
|
*/
|
|
48
49
|
const Toast = (props) => {
|
|
49
|
-
const { content, category, type = 'temporary', isVisible, link, duration = 7000, hasCloseButton, onRemove, animateOutTo,
|
|
50
|
+
const { content, category, type = 'temporary', isVisible: isVisibleProp, link, duration = 7000, hasCloseButton, onRemove, animateOutTo, } = props;
|
|
50
51
|
const closeTimeout = React.useRef(0);
|
|
51
|
-
const
|
|
52
|
+
const { placement } = (0, index_js_1.useSafeContext)(Toaster_js_1.ToasterStateContext).settings;
|
|
53
|
+
const placementPosition = placement.startsWith('top') ? 'top' : 'bottom';
|
|
54
|
+
const [visible, setVisible] = React.useState(isVisibleProp ?? true);
|
|
55
|
+
const isVisible = isVisibleProp ?? visible;
|
|
52
56
|
const [height, setHeight] = React.useState(0);
|
|
53
57
|
const thisElement = React.useRef(null);
|
|
54
58
|
const [margin, setMargin] = React.useState(0);
|
|
@@ -67,9 +71,6 @@ const Toast = (props) => {
|
|
|
67
71
|
};
|
|
68
72
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
69
73
|
}, [duration, type]);
|
|
70
|
-
React.useEffect(() => {
|
|
71
|
-
setVisible(isVisible);
|
|
72
|
-
}, [isVisible]);
|
|
73
74
|
React.useEffect(() => {
|
|
74
75
|
// if we don't have animateOutTo point and not isVisible, set negative margin to move other toasts up.
|
|
75
76
|
// Close all and close on toasts with no anchor.
|
|
@@ -113,7 +114,7 @@ const Toast = (props) => {
|
|
|
113
114
|
}
|
|
114
115
|
return { translateX, translateY };
|
|
115
116
|
};
|
|
116
|
-
return (React.createElement(react_transition_group_1.Transition, { timeout: { enter: 240, exit: animateOutTo ? 400 : 120 }, in:
|
|
117
|
+
return (React.createElement(react_transition_group_1.Transition, { timeout: { enter: 240, exit: animateOutTo ? 400 : 120 }, in: isVisible, appear: true, unmountOnExit: true, onEnter: (node) => {
|
|
117
118
|
if (isMotionOk()) {
|
|
118
119
|
node.style.transform = 'translateY(15%)';
|
|
119
120
|
node.style.transitionTimingFunction = 'ease';
|
|
@@ -132,12 +133,13 @@ const Toast = (props) => {
|
|
|
132
133
|
node.style.transitionDuration = animateOutTo ? '400ms' : '120ms';
|
|
133
134
|
node.style.transitionTimingFunction = 'cubic-bezier(0.4, 0, 1, 1)';
|
|
134
135
|
}
|
|
135
|
-
}, onExited: onRemove },
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
React.createElement(
|
|
136
|
+
}, onExited: onRemove },
|
|
137
|
+
React.createElement(index_js_1.Box, { ref: thisElement, className: 'iui-toast-all', style: {
|
|
138
|
+
height,
|
|
139
|
+
...marginStyle(),
|
|
140
|
+
} },
|
|
141
|
+
React.createElement("div", { ref: onRef },
|
|
142
|
+
React.createElement(exports.ToastPresentation, { category: category, content: content, link: link, type: type, hasCloseButton: hasCloseButton, onClose: close })))));
|
|
141
143
|
};
|
|
142
144
|
exports.Toast = Toast;
|
|
143
145
|
/**
|
|
@@ -150,7 +152,7 @@ const ToastPresentation = (props) => {
|
|
|
150
152
|
return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)(`iui-toast iui-${category}`, className), ...rest },
|
|
151
153
|
React.createElement(index_js_1.Box, { className: 'iui-status-area' }, React.createElement(StatusIcon, { className: 'iui-icon' })),
|
|
152
154
|
React.createElement(index_js_1.Box, { className: 'iui-message' }, content),
|
|
153
|
-
link && (React.createElement(index_js_1.Box, { as: '
|
|
155
|
+
link && (React.createElement(index_js_1.Box, { as: 'button', className: 'iui-toast-anchor', ...link, title: undefined }, link.title)),
|
|
154
156
|
(type === 'persisting' || hasCloseButton) && (React.createElement(index_js_2.IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
|
|
155
157
|
React.createElement(index_js_1.SvgCloseSmall, null)))));
|
|
156
158
|
};
|
|
@@ -4,45 +4,43 @@ export declare type ToasterSettings = {
|
|
|
4
4
|
/**
|
|
5
5
|
* Order of toasts.
|
|
6
6
|
* When set to 'descending', most recent toasts are on top. When set to 'ascending', most recent toasts are on bottom.
|
|
7
|
-
|
|
8
|
-
* When `placement` is set to a top value,
|
|
7
|
+
*
|
|
8
|
+
* When set to `auto`, it will behave like 'descending' when `placement` is set to a top value, otherwise 'ascending'.
|
|
9
|
+
*
|
|
10
|
+
* @default 'auto'
|
|
9
11
|
*/
|
|
10
|
-
order
|
|
12
|
+
order: 'descending' | 'ascending' | 'auto';
|
|
11
13
|
/**
|
|
12
14
|
* Placement of toasts.
|
|
13
15
|
* Changes placement of toasts. Start indicates left side of viewport. End - right side of viewport.
|
|
14
16
|
* @default 'top'
|
|
15
17
|
*/
|
|
16
|
-
placement
|
|
18
|
+
placement: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end';
|
|
17
19
|
};
|
|
18
20
|
export declare type ToastOptions = Omit<ToastProps, 'category' | 'isVisible' | 'id' | 'content'>;
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
private lastId;
|
|
22
|
-
private settings;
|
|
23
|
-
private toastsRef;
|
|
24
|
-
private isInitialized;
|
|
25
|
-
private asyncInit;
|
|
26
|
-
/**
|
|
27
|
-
* Set global Toaster settings for toasts order and placement.
|
|
28
|
-
* Settings will be applied to new toasts on the page.
|
|
29
|
-
*/
|
|
30
|
-
setSettings(newSettings: ToasterSettings): void;
|
|
31
|
-
positive(content: React.ReactNode, options?: ToastOptions): {
|
|
21
|
+
export declare const useToaster: () => {
|
|
22
|
+
positive: (content: React.ReactNode, options?: ToastOptions) => {
|
|
32
23
|
close: () => void;
|
|
33
24
|
};
|
|
34
|
-
informational(content: React.ReactNode, options?: ToastOptions)
|
|
25
|
+
informational: (content: React.ReactNode, options?: ToastOptions) => {
|
|
35
26
|
close: () => void;
|
|
36
27
|
};
|
|
37
|
-
negative(content: React.ReactNode, options?: ToastOptions)
|
|
28
|
+
negative: (content: React.ReactNode, options?: ToastOptions) => {
|
|
38
29
|
close: () => void;
|
|
39
30
|
};
|
|
40
|
-
warning(content: React.ReactNode, options?: ToastOptions)
|
|
31
|
+
warning: (content: React.ReactNode, options?: ToastOptions) => {
|
|
41
32
|
close: () => void;
|
|
42
33
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
closeAll: () => void;
|
|
35
|
+
setSettings: (settings: Partial<ToasterSettings>) => void;
|
|
36
|
+
};
|
|
37
|
+
export declare const Toaster: () => JSX.Element;
|
|
38
|
+
export declare const ToastProvider: ({ children }: {
|
|
39
|
+
children: React.ReactNode;
|
|
40
|
+
}) => JSX.Element;
|
|
41
|
+
export declare const ToasterStateContext: React.Context<ToasterState | undefined>;
|
|
42
|
+
declare type ToasterState = {
|
|
43
|
+
toasts: ToastProps[];
|
|
44
|
+
settings: ToasterSettings;
|
|
45
|
+
};
|
|
46
|
+
export {};
|