@itwin/itwinui-react 3.0.0-dev.3 → 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 +28 -0
- 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/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/Tile/Tile.d.ts +157 -99
- package/cjs/core/Tile/Tile.js +273 -99
- package/cjs/core/Tooltip/Tooltip.d.ts +67 -7
- package/cjs/core/Tooltip/Tooltip.js +96 -7
- package/cjs/core/index.d.ts +5 -5
- package/cjs/core/index.js +3 -8
- package/cjs/styles.js +1 -5
- 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/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/Tile/Tile.d.ts +157 -99
- package/esm/core/Tile/Tile.js +273 -99
- package/esm/core/Tooltip/Tooltip.d.ts +67 -7
- package/esm/core/Tooltip/Tooltip.js +97 -7
- package/esm/core/index.d.ts +5 -5
- package/esm/core/index.js +4 -4
- package/esm/styles.js +1 -5
- package/package.json +4 -3
- package/styles.css +54 -52
- package/cjs/core/Stepper/Wizard.d.ts +0 -46
- package/cjs/core/Stepper/Wizard.js +0 -55
- package/esm/core/Stepper/Wizard.d.ts +0 -46
- package/esm/core/Stepper/Wizard.js +0 -29
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;
|
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { Placement } from '@floating-ui/react';
|
|
3
|
+
import type { PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
4
|
+
declare type TooltipOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* Placement of the Tooltip
|
|
7
|
+
* @default 'top'
|
|
8
|
+
*/
|
|
9
|
+
placement?: Placement;
|
|
10
|
+
/**
|
|
11
|
+
* Property for manual visibility control
|
|
12
|
+
*/
|
|
13
|
+
visible?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* autoUpdate options that recalculates position
|
|
16
|
+
* to ensure the floating element remains anchored
|
|
17
|
+
* to its reference element, such as when scrolling
|
|
18
|
+
* and resizing the screen
|
|
19
|
+
*
|
|
20
|
+
* https://floating-ui.com/docs/autoUpdate#options
|
|
21
|
+
*/
|
|
22
|
+
autoUpdateOptions?: {
|
|
23
|
+
ancestorScroll?: boolean;
|
|
24
|
+
ancestorResize?: boolean;
|
|
25
|
+
elementResize?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Use this if you want Tooltip to follow moving trigger element
|
|
28
|
+
*/
|
|
29
|
+
animationFrame?: boolean;
|
|
30
|
+
layoutShift?: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Tooltip middleware options.
|
|
34
|
+
* https://floating-ui.com/docs/offset
|
|
35
|
+
*/
|
|
36
|
+
middleware?: {
|
|
37
|
+
offset?: number;
|
|
38
|
+
flip?: boolean;
|
|
39
|
+
shift?: boolean;
|
|
40
|
+
size?: boolean;
|
|
41
|
+
autoPlacement?: boolean;
|
|
42
|
+
hide?: boolean;
|
|
43
|
+
inline?: boolean;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
declare type TooltipOwnProps = {
|
|
4
47
|
/**
|
|
5
48
|
* Content of the tooltip.
|
|
6
49
|
*/
|
|
@@ -9,18 +52,35 @@ export declare type TooltipProps = {
|
|
|
9
52
|
* Element to have tooltip on. Has to be a valid JSX element and needs to forward its ref.
|
|
10
53
|
* If not specified, the `reference` prop should be used instead.
|
|
11
54
|
*/
|
|
12
|
-
children?:
|
|
13
|
-
|
|
55
|
+
children?: React.ReactNode;
|
|
56
|
+
/**
|
|
57
|
+
* Element to portal tooltip to.
|
|
58
|
+
* Portals to ThemeProvider portalContainerRef by default.
|
|
59
|
+
* @default true;
|
|
60
|
+
*/
|
|
61
|
+
portal?: boolean | {
|
|
62
|
+
to: HTMLElement;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Sets reference point to user provided element.
|
|
66
|
+
* @example
|
|
67
|
+
* const buttonRef = React.useRef();
|
|
68
|
+
* ...
|
|
69
|
+
* <Button ref={buttonRef} />
|
|
70
|
+
* <Tooltip content='tooltip text' reference={buttonRef} />
|
|
71
|
+
*/
|
|
72
|
+
reference?: React.RefObject<HTMLElement>;
|
|
73
|
+
};
|
|
14
74
|
/**
|
|
15
75
|
* Basic tooltip component to display informative content when an element is hovered or focused.
|
|
16
|
-
* Uses
|
|
76
|
+
* Uses [FloatingUI](https://floating-ui.com/).
|
|
17
77
|
* @example
|
|
18
|
-
* <Tooltip content='tooltip text' placement='top'
|
|
78
|
+
* <Tooltip content='tooltip text' placement='top'>Hover here</Tooltip>
|
|
19
79
|
* @example
|
|
20
80
|
* const buttonRef = React.useRef();
|
|
21
81
|
* ...
|
|
22
82
|
* <Button ref={buttonRef} />
|
|
23
83
|
* <Tooltip content='tooltip text' reference={buttonRef} />
|
|
24
84
|
*/
|
|
25
|
-
export declare const Tooltip:
|
|
85
|
+
export declare const Tooltip: PolymorphicForwardRefComponent<"div", TooltipOwnProps & TooltipOptions>;
|
|
26
86
|
export default Tooltip;
|
|
@@ -33,21 +33,110 @@ exports.Tooltip = void 0;
|
|
|
33
33
|
*--------------------------------------------------------------------------------------------*/
|
|
34
34
|
const React = __importStar(require("react"));
|
|
35
35
|
const classnames_1 = __importDefault(require("classnames"));
|
|
36
|
+
const react_1 = require("@floating-ui/react");
|
|
36
37
|
const index_js_1 = require("../utils/index.js");
|
|
38
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
39
|
+
const useTooltip = (options = {}) => {
|
|
40
|
+
const { placement, visible: controlledOpen, middleware = {
|
|
41
|
+
flip: true,
|
|
42
|
+
shift: true,
|
|
43
|
+
}, autoUpdateOptions = {}, } = options;
|
|
44
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(false);
|
|
45
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
46
|
+
const data = (0, react_1.useFloating)({
|
|
47
|
+
placement,
|
|
48
|
+
open,
|
|
49
|
+
onOpenChange: setUncontrolledOpen,
|
|
50
|
+
whileElementsMounted: (referenceEl, floatingEl, update) => (0, react_1.autoUpdate)(referenceEl, floatingEl, update, {
|
|
51
|
+
animationFrame: autoUpdateOptions.animationFrame,
|
|
52
|
+
ancestorScroll: autoUpdateOptions.ancestorScroll,
|
|
53
|
+
ancestorResize: autoUpdateOptions.ancestorResize,
|
|
54
|
+
elementResize: autoUpdateOptions.elementResize,
|
|
55
|
+
layoutShift: autoUpdateOptions.layoutShift,
|
|
56
|
+
}),
|
|
57
|
+
middleware: [
|
|
58
|
+
middleware.offset !== undefined ? (0, react_1.offset)(middleware.offset) : (0, react_1.offset)(4),
|
|
59
|
+
middleware.flip && (0, react_1.flip)(),
|
|
60
|
+
middleware.shift && (0, react_1.shift)(),
|
|
61
|
+
middleware.size && (0, react_1.size)(),
|
|
62
|
+
middleware.autoPlacement && (0, react_1.autoPlacement)(),
|
|
63
|
+
middleware.inline && (0, react_1.inline)(),
|
|
64
|
+
middleware.hide && (0, react_1.hide)(),
|
|
65
|
+
].filter(Boolean),
|
|
66
|
+
});
|
|
67
|
+
const context = data.context;
|
|
68
|
+
const hover = (0, react_1.useHover)(context, {
|
|
69
|
+
enabled: controlledOpen == null,
|
|
70
|
+
delay: {
|
|
71
|
+
open: 50,
|
|
72
|
+
close: 250,
|
|
73
|
+
},
|
|
74
|
+
handleClose: (0, react_1.safePolygon)({ buffer: -Infinity }),
|
|
75
|
+
});
|
|
76
|
+
const focus = (0, react_1.useFocus)(context, {
|
|
77
|
+
enabled: controlledOpen == null,
|
|
78
|
+
});
|
|
79
|
+
const click = (0, react_1.useClick)(context, {
|
|
80
|
+
enabled: controlledOpen == null,
|
|
81
|
+
});
|
|
82
|
+
const dismiss = (0, react_1.useDismiss)(context, {
|
|
83
|
+
enabled: controlledOpen == null,
|
|
84
|
+
});
|
|
85
|
+
const role = (0, react_1.useRole)(context, { role: 'tooltip' });
|
|
86
|
+
const interactions = (0, react_1.useInteractions)([click, hover, focus, dismiss, role]);
|
|
87
|
+
return React.useMemo(() => ({
|
|
88
|
+
open,
|
|
89
|
+
setUncontrolledOpen,
|
|
90
|
+
...interactions,
|
|
91
|
+
...data,
|
|
92
|
+
}), [open, interactions, data]);
|
|
93
|
+
};
|
|
37
94
|
/**
|
|
38
95
|
* Basic tooltip component to display informative content when an element is hovered or focused.
|
|
39
|
-
* Uses
|
|
96
|
+
* Uses [FloatingUI](https://floating-ui.com/).
|
|
40
97
|
* @example
|
|
41
|
-
* <Tooltip content='tooltip text' placement='top'
|
|
98
|
+
* <Tooltip content='tooltip text' placement='top'>Hover here</Tooltip>
|
|
42
99
|
* @example
|
|
43
100
|
* const buttonRef = React.useRef();
|
|
44
101
|
* ...
|
|
45
102
|
* <Button ref={buttonRef} />
|
|
46
103
|
* <Tooltip content='tooltip text' reference={buttonRef} />
|
|
47
104
|
*/
|
|
48
|
-
|
|
49
|
-
const { content, children,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
105
|
+
exports.Tooltip = React.forwardRef((props, forwardRef) => {
|
|
106
|
+
const { content, children, portal = true, placement = 'top', autoUpdateOptions, middleware, style, className, visible, reference, ...rest } = props;
|
|
107
|
+
const tooltip = useTooltip({
|
|
108
|
+
placement,
|
|
109
|
+
visible,
|
|
110
|
+
autoUpdateOptions,
|
|
111
|
+
middleware,
|
|
112
|
+
});
|
|
113
|
+
const context = (0, index_js_1.useGlobals)();
|
|
114
|
+
React.useEffect(() => {
|
|
115
|
+
if (reference) {
|
|
116
|
+
tooltip.refs.setReference(reference.current);
|
|
117
|
+
}
|
|
118
|
+
}, [reference, tooltip.refs]);
|
|
119
|
+
const portalTo = typeof portal !== 'boolean'
|
|
120
|
+
? portal.to
|
|
121
|
+
: portal
|
|
122
|
+
? context?.portalContainerRef?.current ?? (0, index_js_1.getDocument)()?.body
|
|
123
|
+
: null;
|
|
124
|
+
const contentBox = (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-tooltip', className), ref: (0, index_js_1.useMergedRefs)(tooltip.refs.setFloating, forwardRef), style: { ...tooltip.floatingStyles, ...style }, ...tooltip.getFloatingProps(), ...rest }, content));
|
|
125
|
+
const childrenRef = React.isValidElement(children) &&
|
|
126
|
+
(0, index_js_1.mergeRefs)(tooltip.refs.setReference,
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
+
children.ref);
|
|
129
|
+
return (React.createElement(React.Fragment, null,
|
|
130
|
+
React.isValidElement(children)
|
|
131
|
+
? React.cloneElement(children, tooltip.getReferenceProps({
|
|
132
|
+
ref: childrenRef,
|
|
133
|
+
...children.props,
|
|
134
|
+
}))
|
|
135
|
+
: null,
|
|
136
|
+
tooltip.open
|
|
137
|
+
? portalTo
|
|
138
|
+
? react_dom_1.default.createPortal(contentBox, portalTo)
|
|
139
|
+
: contentBox
|
|
140
|
+
: null));
|
|
141
|
+
});
|
|
53
142
|
exports.default = exports.Tooltip;
|
package/cjs/core/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Alert } from './Alert/index.js';
|
|
2
|
-
export { Avatar
|
|
3
|
-
export { AvatarGroup
|
|
2
|
+
export { Avatar } from './Avatar/index.js';
|
|
3
|
+
export { AvatarGroup } from './AvatarGroup/index.js';
|
|
4
4
|
export { Backdrop } from './Backdrop/index.js';
|
|
5
5
|
export { Badge } from './Badge/index.js';
|
|
6
6
|
export { Breadcrumbs } from './Breadcrumbs/index.js';
|
|
@@ -23,7 +23,7 @@ export type { FooterElement, TitleTranslations } from './Footer/index.js';
|
|
|
23
23
|
export { Header, HeaderBreadcrumbs, HeaderButton, HeaderLogo, } from './Header/index.js';
|
|
24
24
|
export { List, ListItem } from './List/index.js';
|
|
25
25
|
export { TransferList } from './TransferList/index.js';
|
|
26
|
-
export {
|
|
26
|
+
export { Tabs, Tab } from './Tabs/index.js';
|
|
27
27
|
export { InformationPanel, InformationPanelWrapper, InformationPanelHeader, InformationPanelBody, InformationPanelContent, } from './InformationPanel/index.js';
|
|
28
28
|
export { Input } from './Input/index.js';
|
|
29
29
|
export { Label } from './Label/index.js';
|
|
@@ -59,7 +59,7 @@ export { Tooltip } from './Tooltip/index.js';
|
|
|
59
59
|
export { Tree, TreeNode, TreeNodeExpander } from './Tree/index.js';
|
|
60
60
|
export type { NodeData, NodeRenderProps } from './Tree/index.js';
|
|
61
61
|
export { Anchor, Blockquote, Code, Kbd, KbdKeys, Text, } from './Typography/index.js';
|
|
62
|
-
export {
|
|
63
|
-
export type { StepProperties,
|
|
62
|
+
export { Stepper, WorkflowDiagram } from './Stepper/index.js';
|
|
63
|
+
export type { StepProperties, StepperLocalization } from './Stepper/index.js';
|
|
64
64
|
export { SearchBox } from './SearchBox/index.js';
|
|
65
65
|
export { getUserColor, ColorValue, MiddleTextTruncation, LinkBox, LinkAction, Icon, Flex, VisuallyHidden, Divider, } from './utils/index.js';
|