@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.
Files changed (99) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/cjs/core/Alert/Alert.d.ts +2 -2
  3. package/cjs/core/Avatar/Avatar.d.ts +0 -4
  4. package/cjs/core/Avatar/Avatar.js +1 -5
  5. package/cjs/core/Avatar/index.d.ts +1 -1
  6. package/cjs/core/Avatar/index.js +1 -2
  7. package/cjs/core/AvatarGroup/AvatarGroup.d.ts +0 -4
  8. package/cjs/core/AvatarGroup/AvatarGroup.js +1 -5
  9. package/cjs/core/AvatarGroup/index.d.ts +1 -1
  10. package/cjs/core/AvatarGroup/index.js +1 -2
  11. package/cjs/core/FileUpload/FileUpload.d.ts +3 -4
  12. package/cjs/core/FileUpload/FileUpload.js +2 -2
  13. package/cjs/core/FileUpload/FileUploadTemplate.d.ts +1 -0
  14. package/cjs/core/FileUpload/FileUploadTemplate.js +1 -0
  15. package/cjs/core/Header/Header.d.ts +1 -20
  16. package/cjs/core/Header/Header.js +1 -2
  17. package/cjs/core/ProgressIndicators/ProgressRadial/ProgressRadial.d.ts +2 -2
  18. package/cjs/core/ProgressIndicators/ProgressRadial/ProgressRadial.js +10 -17
  19. package/cjs/core/Slider/Slider.d.ts +2 -1
  20. package/cjs/core/Slider/Thumb.d.ts +2 -2
  21. package/cjs/core/Slider/Thumb.js +1 -1
  22. package/cjs/core/Stepper/index.d.ts +0 -4
  23. package/cjs/core/Stepper/index.js +1 -4
  24. package/cjs/core/Tabs/Tabs.d.ts +0 -36
  25. package/cjs/core/Tabs/Tabs.js +1 -29
  26. package/cjs/core/Tabs/index.d.ts +1 -1
  27. package/cjs/core/Tabs/index.js +1 -3
  28. package/cjs/core/ThemeProvider/ThemeProvider.js +5 -2
  29. package/cjs/core/Tile/Tile.d.ts +157 -99
  30. package/cjs/core/Tile/Tile.js +273 -99
  31. package/cjs/core/Toast/Toast.d.ts +5 -10
  32. package/cjs/core/Toast/Toast.js +15 -13
  33. package/cjs/core/Toast/Toaster.d.ts +24 -26
  34. package/cjs/core/Toast/Toaster.js +91 -116
  35. package/cjs/core/Toast/index.d.ts +1 -4
  36. package/cjs/core/Toast/index.js +3 -6
  37. package/cjs/core/Tooltip/Tooltip.d.ts +67 -7
  38. package/cjs/core/Tooltip/Tooltip.js +96 -7
  39. package/cjs/core/index.d.ts +6 -7
  40. package/cjs/core/index.js +4 -12
  41. package/cjs/core/utils/components/Popover.d.ts +1 -1
  42. package/cjs/core/utils/functions/dom.d.ts +0 -8
  43. package/cjs/core/utils/functions/dom.js +1 -24
  44. package/cjs/core/utils/functions/polymorphic.d.ts +1 -1
  45. package/cjs/styles.js +1 -5
  46. package/esm/core/Alert/Alert.d.ts +2 -2
  47. package/esm/core/Avatar/Avatar.d.ts +0 -4
  48. package/esm/core/Avatar/Avatar.js +0 -4
  49. package/esm/core/Avatar/index.d.ts +1 -1
  50. package/esm/core/Avatar/index.js +1 -1
  51. package/esm/core/AvatarGroup/AvatarGroup.d.ts +0 -4
  52. package/esm/core/AvatarGroup/AvatarGroup.js +0 -4
  53. package/esm/core/AvatarGroup/index.d.ts +1 -1
  54. package/esm/core/AvatarGroup/index.js +1 -1
  55. package/esm/core/FileUpload/FileUpload.d.ts +3 -4
  56. package/esm/core/FileUpload/FileUpload.js +2 -2
  57. package/esm/core/FileUpload/FileUploadTemplate.d.ts +1 -0
  58. package/esm/core/FileUpload/FileUploadTemplate.js +1 -0
  59. package/esm/core/Header/Header.d.ts +1 -20
  60. package/esm/core/Header/Header.js +1 -2
  61. package/esm/core/ProgressIndicators/ProgressRadial/ProgressRadial.d.ts +2 -2
  62. package/esm/core/ProgressIndicators/ProgressRadial/ProgressRadial.js +11 -18
  63. package/esm/core/Slider/Slider.d.ts +2 -1
  64. package/esm/core/Slider/Thumb.d.ts +2 -2
  65. package/esm/core/Slider/Thumb.js +1 -1
  66. package/esm/core/Stepper/index.d.ts +0 -4
  67. package/esm/core/Stepper/index.js +0 -2
  68. package/esm/core/Tabs/Tabs.d.ts +0 -36
  69. package/esm/core/Tabs/Tabs.js +0 -26
  70. package/esm/core/Tabs/index.d.ts +1 -1
  71. package/esm/core/Tabs/index.js +1 -1
  72. package/esm/core/ThemeProvider/ThemeProvider.js +5 -2
  73. package/esm/core/Tile/Tile.d.ts +157 -99
  74. package/esm/core/Tile/Tile.js +273 -99
  75. package/esm/core/Toast/Toast.d.ts +5 -10
  76. package/esm/core/Toast/Toast.js +16 -14
  77. package/esm/core/Toast/Toaster.d.ts +24 -26
  78. package/esm/core/Toast/Toaster.js +85 -116
  79. package/esm/core/Toast/index.d.ts +1 -4
  80. package/esm/core/Toast/index.js +1 -3
  81. package/esm/core/Tooltip/Tooltip.d.ts +67 -7
  82. package/esm/core/Tooltip/Tooltip.js +97 -7
  83. package/esm/core/index.d.ts +6 -7
  84. package/esm/core/index.js +5 -5
  85. package/esm/core/utils/components/Popover.d.ts +1 -1
  86. package/esm/core/utils/functions/dom.d.ts +0 -8
  87. package/esm/core/utils/functions/dom.js +0 -19
  88. package/esm/core/utils/functions/polymorphic.d.ts +1 -1
  89. package/esm/styles.js +1 -5
  90. package/package.json +4 -3
  91. package/styles.css +55 -52
  92. package/cjs/core/Stepper/Wizard.d.ts +0 -46
  93. package/cjs/core/Stepper/Wizard.js +0 -55
  94. package/cjs/core/Toast/ToastWrapper.d.ts +0 -10
  95. package/cjs/core/Toast/ToastWrapper.js +0 -49
  96. package/esm/core/Stepper/Wizard.d.ts +0 -46
  97. package/esm/core/Stepper/Wizard.js +0 -29
  98. package/esm/core/Toast/ToastWrapper.d.ts +0 -10
  99. package/esm/core/Toast/ToastWrapper.js +0 -20
@@ -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 = exports.TileAction = void 0;
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
- * Polymorphic Tile action component. Recommended to be used in a "name" of `Tile`.
43
- * Renders `a` element by default.
44
- * @example
45
- * <Tile
46
- * name={<Tile.Action href='/new-page'>Tile name<Tile.Action/>}
47
- * />
48
- */
49
- exports.TileAction = React.forwardRef((props, forwardedRef) => {
50
- const tileContext = (0, index_js_1.useSafeContext)(TileContext);
51
- React.useEffect(() => {
52
- if (!(0, index_js_1.supportsHas)()) {
53
- tileContext.setActionable(true);
54
- }
55
- }, [tileContext]);
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
- variant !== 'folder' ? tileName : null,
95
- thumbnail && (React.createElement(index_js_1.Box, { className: 'iui-tile-thumbnail' },
96
- typeof thumbnail === 'string' ? (React.createElement(index_js_1.Box, { className: 'iui-tile-thumbnail-picture', style: { backgroundImage: `url(${thumbnail})` } })) : thumbnail && thumbnail.type === 'img' ? (React.cloneElement(thumbnail, {
97
- className: 'iui-tile-thumbnail-picture',
98
- })) : (React.createElement(index_js_1.Box, { as: 'span', className: 'iui-thumbnail-icon' }, thumbnail)),
99
- leftIcon &&
100
- React.cloneElement(leftIcon, {
101
- className: 'iui-tile-thumbnail-type-indicator',
102
- 'data-iui-size': 'small',
103
- }),
104
- rightIcon &&
105
- React.cloneElement(rightIcon, {
106
- className: 'iui-tile-thumbnail-quick-action',
107
- 'data-iui-size': 'small',
108
- }),
109
- badge && (React.createElement(index_js_1.Box, { className: 'iui-tile-thumbnail-badge-container' }, badge)))),
110
- React.createElement(index_js_1.Box, { className: 'iui-tile-content' },
111
- variant === 'folder' ? tileName : null,
112
- description != undefined && (React.createElement(index_js_1.Box, { className: 'iui-tile-description' }, description)),
113
- metadata != undefined && (React.createElement(index_js_1.Box, { className: 'iui-tile-metadata' }, metadata)),
114
- moreOptions && (React.createElement(index_js_2.DropdownMenu, { onShow: showMenu, onHide: hideMenu, menuItems: (close) => moreOptions.map((option) => React.cloneElement(option, {
115
- onClick: (value) => {
116
- close();
117
- option.props.onClick?.(value);
118
- },
119
- })) },
120
- React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-tile-more-options', {
121
- 'iui-visible': isMenuVisible,
122
- }) },
123
- React.createElement(index_js_3.IconButton, { styleType: 'borderless', size: 'small', "aria-label": 'More options' },
124
- React.createElement(index_js_1.SvgMore, null))))),
125
- children),
126
- buttons && React.createElement(index_js_1.Box, { className: 'iui-tile-buttons' }, buttons))));
127
- }), {
128
- /**
129
- * Polymorphic Tile action component. Recommended to be used in a "name" of `Tile`.
130
- * Renders `a` element by default.
131
- * @example
132
- * <Tile
133
- * name={<Tile.Action href='/new-page'>Tile name<Tile.Action/>}
134
- * />
135
- */
136
- Action: exports.TileAction,
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
- const TitleIcon = ({ isLoading = false, isSelected = false, isNew = false, status, }) => {
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
- return (React.createElement(index_js_4.ProgressRadial, { className: 'iui-tile-status-icon', "aria-hidden": true, indeterminate: true }));
128
+ icon = React.createElement(index_js_4.ProgressRadial, { size: 'x-small', "aria-hidden": true, indeterminate: true });
142
129
  }
143
130
  if (isSelected) {
144
- return React.createElement(index_js_1.SvgCheckmark, { className: 'iui-tile-status-icon', "aria-hidden": true });
131
+ icon = React.createElement(index_js_1.SvgCheckmark, { "aria-hidden": true });
145
132
  }
146
133
  if (isNew) {
147
- return React.createElement(index_js_1.SvgNew, { className: 'iui-tile-status-icon', "aria-hidden": true });
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
- * Boolean indicating when the toast is visible.
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: boolean;
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
- * A Callback that can be used to add additional information to a Toast
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
@@ -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, placementPosition = 'top', } = props;
50
+ const { content, category, type = 'temporary', isVisible: isVisibleProp, link, duration = 7000, hasCloseButton, onRemove, animateOutTo, } = props;
50
51
  const closeTimeout = React.useRef(0);
51
- const [visible, setVisible] = React.useState(isVisible);
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: visible, appear: true, unmountOnExit: true, onEnter: (node) => {
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 }, React.createElement(index_js_1.Box, { ref: thisElement, className: 'iui-toast-all', style: {
136
- height,
137
- ...marginStyle(),
138
- } },
139
- React.createElement("div", { ref: onRef },
140
- React.createElement(exports.ToastPresentation, { category: category, content: content, link: link, type: type, hasCloseButton: hasCloseButton, onClose: close })))));
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: 'a', className: 'iui-toast-anchor', onClick: link.onClick }, link.title)),
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, order defaults to 'descending', otherwise 'ascending'.
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?: 'descending' | 'ascending';
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?: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end';
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 default class Toaster {
20
- private toasts;
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
- private createToast;
44
- private removeToast;
45
- private updateView;
46
- private closeToast;
47
- closeAll(): void;
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 {};