@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/esm/core/Tile/Tile.d.ts
CHANGED
|
@@ -1,75 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Renders `a` element by default.
|
|
6
|
-
* @example
|
|
7
|
-
* <Tile
|
|
8
|
-
* name={<Tile.Action href='/new-page'>Tile name<Tile.Action/>}
|
|
9
|
-
* />
|
|
10
|
-
*/
|
|
11
|
-
export declare const TileAction: PolymorphicForwardRefComponent<"a", {}>;
|
|
12
|
-
declare type TileProps = {
|
|
13
|
-
/**
|
|
14
|
-
* Name or title of the tile.
|
|
15
|
-
*/
|
|
16
|
-
name: React.ReactNode;
|
|
17
|
-
/**
|
|
18
|
-
* Description text of the tile.
|
|
19
|
-
* Gets truncated if it can't fit in the tile.
|
|
20
|
-
*/
|
|
21
|
-
description?: React.ReactNode;
|
|
22
|
-
/**
|
|
23
|
-
* Metadata section located below description.
|
|
24
|
-
* @example
|
|
25
|
-
* <Tile
|
|
26
|
-
* // ...
|
|
27
|
-
* metadata='basic metadata'
|
|
28
|
-
* // or
|
|
29
|
-
* metadata={<span><SvgClock /> 2021-01-01, 04:30 AM</span>}
|
|
30
|
-
* // or
|
|
31
|
-
* metadata={<>
|
|
32
|
-
* <SvgTag2 />
|
|
33
|
-
* <TagContainer><Tag variant='basic'>Tag 1</Tag><Tag variant='basic'>Tag 2</Tag></TagContainer>
|
|
34
|
-
* </>}
|
|
35
|
-
* />
|
|
36
|
-
*/
|
|
37
|
-
metadata?: React.ReactNode;
|
|
38
|
-
/**
|
|
39
|
-
* Thumbnail image url, a custom component or an svg.
|
|
40
|
-
* @example
|
|
41
|
-
* <Tile
|
|
42
|
-
* // ...
|
|
43
|
-
* thumbnail='/url/to/image.jpg'
|
|
44
|
-
* // or
|
|
45
|
-
* thumbnail={<Avatar image={<img src='icon.png' />} />}
|
|
46
|
-
* // or
|
|
47
|
-
* thumbnail={<SvgImodelHollow />}
|
|
48
|
-
* />
|
|
49
|
-
*/
|
|
50
|
-
thumbnail?: string | React.ReactNode;
|
|
51
|
-
/**
|
|
52
|
-
* `Badge` shown on the bottom right of thumbnail.
|
|
53
|
-
*/
|
|
54
|
-
badge?: React.ReactNode;
|
|
55
|
-
/**
|
|
56
|
-
* Icon shown on top left of the tile. Also known as "type indicator".
|
|
57
|
-
* Recommended to use an invisible `IconButton`.
|
|
58
|
-
*/
|
|
59
|
-
leftIcon?: React.ReactNode;
|
|
60
|
-
/**
|
|
61
|
-
* Icon shown on top right of the tile. Also known as "quick action".
|
|
62
|
-
* Recommended to use an invisible `IconButton`.
|
|
63
|
-
*/
|
|
64
|
-
rightIcon?: React.ReactNode;
|
|
65
|
-
/**
|
|
66
|
-
* Upto two buttons shown at the bottom of the tile.
|
|
67
|
-
*/
|
|
68
|
-
buttons?: [React.ReactNode?, React.ReactNode?];
|
|
69
|
-
/**
|
|
70
|
-
* Dropdown menu containing `MenuItem`s.
|
|
71
|
-
*/
|
|
72
|
-
moreOptions?: React.ReactNode[];
|
|
3
|
+
import { IconButton } from '../Buttons/index.js';
|
|
4
|
+
declare type TileOwnProps = {
|
|
73
5
|
/**
|
|
74
6
|
* Status of the tile.
|
|
75
7
|
*/
|
|
@@ -88,15 +20,6 @@ declare type TileProps = {
|
|
|
88
20
|
* @default 'default'
|
|
89
21
|
*/
|
|
90
22
|
variant?: 'default' | 'folder';
|
|
91
|
-
/**
|
|
92
|
-
* Any custom nodes that will be appended to the tile's main content.
|
|
93
|
-
*/
|
|
94
|
-
children?: React.ReactNode;
|
|
95
|
-
/**
|
|
96
|
-
* Whether the tile is expected to be interactable (i.e. `onClick`).
|
|
97
|
-
* It becomes focusable and gets on hover styling.
|
|
98
|
-
*/
|
|
99
|
-
isActionable?: boolean;
|
|
100
23
|
/**
|
|
101
24
|
* Display a loading state.
|
|
102
25
|
* @default false
|
|
@@ -111,34 +34,169 @@ declare type TileProps = {
|
|
|
111
34
|
* @default false
|
|
112
35
|
*/
|
|
113
36
|
isDisabled?: boolean;
|
|
114
|
-
|
|
37
|
+
};
|
|
38
|
+
declare type TileThumbnailPictureOwnProps = {
|
|
39
|
+
url?: string;
|
|
40
|
+
} | {
|
|
41
|
+
url?: never;
|
|
42
|
+
children?: React.ReactNode;
|
|
43
|
+
};
|
|
44
|
+
declare type TileNameOwnProps = {
|
|
45
|
+
name?: React.ReactNode;
|
|
46
|
+
};
|
|
47
|
+
declare type TileMoreOptionsOwnProps = {
|
|
48
|
+
buttonProps?: React.ComponentPropsWithoutRef<typeof IconButton>;
|
|
49
|
+
children?: React.ReactElement[];
|
|
115
50
|
};
|
|
116
51
|
/**
|
|
117
|
-
* Tile
|
|
52
|
+
* Tile with customizable Thumbnail, Name, Content and Buttons subcomponents
|
|
118
53
|
* @example
|
|
119
|
-
* <Tile
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* />
|
|
54
|
+
* <Tile>
|
|
55
|
+
* <Tile.ThumbnailArea>
|
|
56
|
+
* <Tile.ThumbnailPicture/>
|
|
57
|
+
* <Tile.Badge/>
|
|
58
|
+
* <Tile.TypeIndicator/>
|
|
59
|
+
* <Tile.QuickAction/>
|
|
60
|
+
* </Tile.ThumbnailArea>
|
|
61
|
+
* <Tile.Name>
|
|
62
|
+
* <Tile.NameIcon/>
|
|
63
|
+
* <Tile.NameLabel/>
|
|
64
|
+
* <Tile.Name/>
|
|
65
|
+
* <Tile.ContentArea>
|
|
66
|
+
* <Tile.Description />
|
|
67
|
+
* <Tile.Metadata/>
|
|
68
|
+
* <Tile.MoreOptions/>
|
|
69
|
+
* </Tile.ContentArea>
|
|
70
|
+
* <Tile.Buttons/>
|
|
71
|
+
* </Tile>
|
|
132
72
|
*/
|
|
133
|
-
export declare const Tile: PolymorphicForwardRefComponent<"div",
|
|
73
|
+
export declare const Tile: PolymorphicForwardRefComponent<"div", TileOwnProps> & {
|
|
74
|
+
/**
|
|
75
|
+
* ThumbnailArea subcomponent that contains `ThumbnailPicture`, `QuickAction`, `TypeIndicator` or `BadgeContainer`
|
|
76
|
+
* @example
|
|
77
|
+
* <Tile.ThumbnailArea>
|
|
78
|
+
* <Tile.ThumbnailPicture/>
|
|
79
|
+
* // or
|
|
80
|
+
* <Tile.ThumbnailAvatar/>
|
|
81
|
+
* <Tile.QuickAction/>
|
|
82
|
+
* <Tile.TypeIndicator/>
|
|
83
|
+
* <Tile.BadgeContainer/>
|
|
84
|
+
* </Tile.ThumbnailArea>
|
|
85
|
+
*/
|
|
86
|
+
ThumbnailArea: PolymorphicForwardRefComponent<keyof JSX.IntrinsicElements, {}>;
|
|
87
|
+
/**
|
|
88
|
+
* Thumbnail image url, a custom component or an svg for thumbnail avatar.
|
|
89
|
+
* @example
|
|
90
|
+
* <Tile>
|
|
91
|
+
* // ...
|
|
92
|
+
* <Tile.ThumbnailArea>
|
|
93
|
+
* <Tile.ThumbnailPicture url = '/url/to/image.jpg'/>
|
|
94
|
+
* </Tile.ThumbnailArea>
|
|
95
|
+
* </Tile>
|
|
96
|
+
* or
|
|
97
|
+
* <Tile>
|
|
98
|
+
* // ...
|
|
99
|
+
* <Tile.ThumbnailArea>
|
|
100
|
+
* <Tile.ThumbnailPicture>
|
|
101
|
+
* {<Avatar image={<img src='icon.png' />} />}
|
|
102
|
+
* // or
|
|
103
|
+
* {<SvgImodelHollow />}
|
|
104
|
+
* </Tile.ThumbnailPicture>
|
|
105
|
+
* </Tile.ThumbnailArea>
|
|
106
|
+
* /Tile>
|
|
107
|
+
*/
|
|
108
|
+
ThumbnailPicture: PolymorphicForwardRefComponent<"div", TileThumbnailPictureOwnProps>;
|
|
109
|
+
/**
|
|
110
|
+
* `QuickAction` subcomponent shown on top left of the tile.
|
|
111
|
+
* Recommended to use an invisible `IconButton`.
|
|
112
|
+
*/
|
|
113
|
+
QuickAction: PolymorphicForwardRefComponent<keyof JSX.IntrinsicElements, {}>;
|
|
134
114
|
/**
|
|
135
|
-
*
|
|
115
|
+
* `TypeIndicator` subcomponent shown on top left of the tile.
|
|
116
|
+
* Recommended to use an invisible `IconButton`.
|
|
117
|
+
*/
|
|
118
|
+
TypeIndicator: PolymorphicForwardRefComponent<keyof JSX.IntrinsicElements, {}>;
|
|
119
|
+
/**
|
|
120
|
+
* `BadgeContainer` subcomponent shown on the bottom right of thumbnail.
|
|
121
|
+
*/
|
|
122
|
+
BadgeContainer: PolymorphicForwardRefComponent<keyof JSX.IntrinsicElements, {}>;
|
|
123
|
+
/**
|
|
124
|
+
* `IconButton` subcomponent: custom icon for `QuickAction` and `TypeIndicator` buttons.
|
|
125
|
+
*/
|
|
126
|
+
IconButton: PolymorphicForwardRefComponent<"button", Pick<Omit<Pick<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement>> & {
|
|
127
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
|
|
128
|
+
}, "label" | "as" | "size" | "styleType" | "isActive"> & {
|
|
129
|
+
isActive?: boolean | undefined;
|
|
130
|
+
label?: React.ReactNode;
|
|
131
|
+
} & Omit<import("../Buttons/Button/Button.js").ButtonProps, "startIcon" | "endIcon"> & {
|
|
132
|
+
as?: "button" | undefined;
|
|
133
|
+
}, "label" | "as" | "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement> | "size" | "styleType" | "isActive">>;
|
|
134
|
+
/**
|
|
135
|
+
* `Name` subcomponent under thumbnail or top of the Tile if no thumbnail present.
|
|
136
|
+
*/
|
|
137
|
+
Name: PolymorphicForwardRefComponent<"div", TileNameOwnProps>;
|
|
138
|
+
/**
|
|
139
|
+
* `NameIcon` next to name of the tile. Goes under <Tile.Name>
|
|
140
|
+
* @example
|
|
141
|
+
* <Tile>
|
|
142
|
+
* <Tile.Name>
|
|
143
|
+
* <Tile.NameIcon/>
|
|
144
|
+
* </Tile.Name>
|
|
145
|
+
* <Tile/>
|
|
146
|
+
*/
|
|
147
|
+
NameIcon: PolymorphicForwardRefComponent<"div", {}>;
|
|
148
|
+
NameLabel: PolymorphicForwardRefComponent<"span", {}>;
|
|
149
|
+
/**
|
|
150
|
+
* Polymorphic Tile action component. Recommended to be used in `Tile.NameLabel` subcomponent.
|
|
136
151
|
* Renders `a` element by default.
|
|
137
152
|
* @example
|
|
138
|
-
* <Tile
|
|
139
|
-
*
|
|
140
|
-
* />
|
|
153
|
+
* <Tile.Name>
|
|
154
|
+
* <Tile.NameLabel>
|
|
155
|
+
* {<Tile.Action href='/new-page'>Tile Name<Tile.Action/>}
|
|
156
|
+
* <Tile.NameLabel/>
|
|
157
|
+
* </Tile.Name>
|
|
141
158
|
*/
|
|
142
159
|
Action: PolymorphicForwardRefComponent<"a", {}>;
|
|
160
|
+
/**
|
|
161
|
+
* Tile content area that contains `Description`, `Metadata` and `MoreOptions` Tile subcomponents
|
|
162
|
+
* @example
|
|
163
|
+
* <Tile>
|
|
164
|
+
* <Tile.ContentArea>
|
|
165
|
+
* <Tile.Description/>
|
|
166
|
+
* <Tile.Metadata/>
|
|
167
|
+
* <Tile.MoreOptions/>
|
|
168
|
+
* </Tile.ContentArea>
|
|
169
|
+
* </Tile>
|
|
170
|
+
*/
|
|
171
|
+
ContentArea: PolymorphicForwardRefComponent<keyof JSX.IntrinsicElements, {}>;
|
|
172
|
+
/**
|
|
173
|
+
* Description text of the tile.
|
|
174
|
+
* Gets truncated if it can't fit in the tile.
|
|
175
|
+
*/
|
|
176
|
+
Description: PolymorphicForwardRefComponent<keyof JSX.IntrinsicElements, {}>;
|
|
177
|
+
/**
|
|
178
|
+
* Metadata section located below description.
|
|
179
|
+
* @example
|
|
180
|
+
* <Tile.Metadata>
|
|
181
|
+
* // ...
|
|
182
|
+
* 'basic metadata'
|
|
183
|
+
* // or
|
|
184
|
+
* {<span><SvgClock /> 2021-01-01, 04:30 AM</span>}
|
|
185
|
+
* // or
|
|
186
|
+
* {<>
|
|
187
|
+
* <SvgTag2 />
|
|
188
|
+
* <TagContainer><Tag variant='basic'>Tag 1</Tag><Tag variant='basic'>Tag 2</Tag></TagContainer>
|
|
189
|
+
* </>}
|
|
190
|
+
* </Tile.Metadata>
|
|
191
|
+
*/
|
|
192
|
+
Metadata: PolymorphicForwardRefComponent<keyof JSX.IntrinsicElements, {}>;
|
|
193
|
+
/**
|
|
194
|
+
* Dropdown menu containing `MenuItem`s.
|
|
195
|
+
*/
|
|
196
|
+
MoreOptions: PolymorphicForwardRefComponent<"div", TileMoreOptionsOwnProps>;
|
|
197
|
+
/**
|
|
198
|
+
* Upto two buttons shown at the bottom of the tile.
|
|
199
|
+
*/
|
|
200
|
+
Buttons: PolymorphicForwardRefComponent<keyof JSX.IntrinsicElements, {}>;
|
|
143
201
|
};
|
|
144
202
|
export default Tile;
|
package/esm/core/Tile/Tile.js
CHANGED
|
@@ -4,56 +4,26 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import cx from 'classnames';
|
|
7
|
-
import { StatusIconMap, SvgMore, SvgNew, SvgCheckmark, LinkAction, useSafeContext, supportsHas, Box, } from '../utils/index.js';
|
|
7
|
+
import { StatusIconMap, SvgMore, SvgNew, SvgCheckmark, LinkAction, useSafeContext, supportsHas, polymorphic, Box, } from '../utils/index.js';
|
|
8
8
|
import { DropdownMenu } from '../DropdownMenu/index.js';
|
|
9
9
|
import { IconButton } from '../Buttons/index.js';
|
|
10
10
|
import { ProgressRadial } from '../ProgressIndicators/index.js';
|
|
11
11
|
const TileContext = React.createContext(undefined);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return React.createElement(LinkAction, { ref: forwardedRef, ...props });
|
|
28
|
-
});
|
|
29
|
-
/**
|
|
30
|
-
* Tile component that displays content and actions in a card-like format.
|
|
31
|
-
* @example
|
|
32
|
-
* <Tile
|
|
33
|
-
* name='Tile name'
|
|
34
|
-
* description='Tile description that takes upto 3 lines'
|
|
35
|
-
* metadata={<TagContainer><Tag variant='basic'>Tag 1</Tag></TagContainer>}
|
|
36
|
-
* thumbnail='/url/to/image.jpg'
|
|
37
|
-
* badge={<Badge backgroundColor='blue'>Badge label</Badge>}
|
|
38
|
-
* buttons={[<Button>Button 1</Button>, <Button>Button 2</Button>]}
|
|
39
|
-
* moreOptions={[<MenuItem>Item 1</MenuItem>, <MenuItem>Item 2</MenuItem>]}
|
|
40
|
-
* leftIcon={<IconButton><SvgInfo /></IconButton>}
|
|
41
|
-
* rightIcon={<IconButton><SvgStar /></IconButton>}
|
|
42
|
-
* isSelected={true}
|
|
43
|
-
* isNew={false}
|
|
44
|
-
* />
|
|
45
|
-
*/
|
|
46
|
-
export const Tile = Object.assign(React.forwardRef((props, forwardedRef) => {
|
|
47
|
-
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;
|
|
48
|
-
const [isMenuVisible, setIsMenuVisible] = React.useState(false);
|
|
49
|
-
const showMenu = React.useCallback(() => setIsMenuVisible(true), []);
|
|
50
|
-
const hideMenu = React.useCallback(() => setIsMenuVisible(false), []);
|
|
51
|
-
const [localActionable, setLocalActionable] = React.useState(isActionableProp);
|
|
52
|
-
const isActionable = isActionableProp ?? localActionable;
|
|
53
|
-
const tileName = (React.createElement(Box, { className: 'iui-tile-name' },
|
|
54
|
-
React.createElement(TitleIcon, { isLoading: isLoading, isSelected: isSelected, isNew: isNew, status: status }),
|
|
55
|
-
React.createElement(Box, { as: 'span', className: 'iui-tile-name-label' }, isActionable && onClick ? (React.createElement(LinkAction, { as: 'button', onClick: !isDisabled ? onClick : undefined, "aria-disabled": isDisabled }, name)) : (name))));
|
|
56
|
-
return (React.createElement(TileContext.Provider, { value: { setActionable: setLocalActionable } },
|
|
12
|
+
TileContext.displayName = 'TileContext';
|
|
13
|
+
const TileComponent = React.forwardRef((props, forwardedRef) => {
|
|
14
|
+
const { className, status, variant, isNew, isSelected, isLoading, isDisabled, ...rest } = props;
|
|
15
|
+
const [localActionable, setLocalActionable] = React.useState(false);
|
|
16
|
+
const isActionable = localActionable;
|
|
17
|
+
return (React.createElement(TileContext.Provider, { value: {
|
|
18
|
+
status,
|
|
19
|
+
variant,
|
|
20
|
+
isNew,
|
|
21
|
+
isSelected,
|
|
22
|
+
isLoading,
|
|
23
|
+
isActionable,
|
|
24
|
+
isDisabled,
|
|
25
|
+
setActionable: setLocalActionable,
|
|
26
|
+
} },
|
|
57
27
|
React.createElement(Box, { className: cx('iui-tile', {
|
|
58
28
|
'iui-folder': variant === 'folder',
|
|
59
29
|
'iui-new': isNew,
|
|
@@ -61,65 +31,269 @@ export const Tile = Object.assign(React.forwardRef((props, forwardedRef) => {
|
|
|
61
31
|
'iui-actionable': isActionable,
|
|
62
32
|
[`iui-${status}`]: !!status,
|
|
63
33
|
'iui-loading': isLoading,
|
|
64
|
-
}, className), "aria-disabled": isDisabled, ref: forwardedRef, ...rest }
|
|
65
|
-
variant !== 'folder' ? tileName : null,
|
|
66
|
-
thumbnail && (React.createElement(Box, { className: 'iui-tile-thumbnail' },
|
|
67
|
-
typeof thumbnail === 'string' ? (React.createElement(Box, { className: 'iui-tile-thumbnail-picture', style: { backgroundImage: `url(${thumbnail})` } })) : thumbnail && thumbnail.type === 'img' ? (React.cloneElement(thumbnail, {
|
|
68
|
-
className: 'iui-tile-thumbnail-picture',
|
|
69
|
-
})) : (React.createElement(Box, { as: 'span', className: 'iui-thumbnail-icon' }, thumbnail)),
|
|
70
|
-
leftIcon &&
|
|
71
|
-
React.cloneElement(leftIcon, {
|
|
72
|
-
className: 'iui-tile-thumbnail-type-indicator',
|
|
73
|
-
'data-iui-size': 'small',
|
|
74
|
-
}),
|
|
75
|
-
rightIcon &&
|
|
76
|
-
React.cloneElement(rightIcon, {
|
|
77
|
-
className: 'iui-tile-thumbnail-quick-action',
|
|
78
|
-
'data-iui-size': 'small',
|
|
79
|
-
}),
|
|
80
|
-
badge && (React.createElement(Box, { className: 'iui-tile-thumbnail-badge-container' }, badge)))),
|
|
81
|
-
React.createElement(Box, { className: 'iui-tile-content' },
|
|
82
|
-
variant === 'folder' ? tileName : null,
|
|
83
|
-
description != undefined && (React.createElement(Box, { className: 'iui-tile-description' }, description)),
|
|
84
|
-
metadata != undefined && (React.createElement(Box, { className: 'iui-tile-metadata' }, metadata)),
|
|
85
|
-
moreOptions && (React.createElement(DropdownMenu, { onShow: showMenu, onHide: hideMenu, menuItems: (close) => moreOptions.map((option) => React.cloneElement(option, {
|
|
86
|
-
onClick: (value) => {
|
|
87
|
-
close();
|
|
88
|
-
option.props.onClick?.(value);
|
|
89
|
-
},
|
|
90
|
-
})) },
|
|
91
|
-
React.createElement(Box, { className: cx('iui-tile-more-options', {
|
|
92
|
-
'iui-visible': isMenuVisible,
|
|
93
|
-
}) },
|
|
94
|
-
React.createElement(IconButton, { styleType: 'borderless', size: 'small', "aria-label": 'More options' },
|
|
95
|
-
React.createElement(SvgMore, null))))),
|
|
96
|
-
children),
|
|
97
|
-
buttons && React.createElement(Box, { className: 'iui-tile-buttons' }, buttons))));
|
|
98
|
-
}), {
|
|
99
|
-
/**
|
|
100
|
-
* Polymorphic Tile action component. Recommended to be used in a "name" of `Tile`.
|
|
101
|
-
* Renders `a` element by default.
|
|
102
|
-
* @example
|
|
103
|
-
* <Tile
|
|
104
|
-
* name={<Tile.Action href='/new-page'>Tile name<Tile.Action/>}
|
|
105
|
-
* />
|
|
106
|
-
*/
|
|
107
|
-
Action: TileAction,
|
|
34
|
+
}, className), "aria-disabled": isDisabled, ref: forwardedRef, ...rest })));
|
|
108
35
|
});
|
|
109
|
-
|
|
36
|
+
TileComponent.displayName = 'Tile';
|
|
37
|
+
// ----------------------------------------------------------------------------
|
|
38
|
+
// Tile.Action component
|
|
39
|
+
const TileAction = React.forwardRef((props, forwardedRef) => {
|
|
40
|
+
const { onClick, children, href, ...rest } = props;
|
|
41
|
+
const { setActionable, isDisabled } = useSafeContext(TileContext);
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
if (!supportsHas()) {
|
|
44
|
+
setActionable(true);
|
|
45
|
+
}
|
|
46
|
+
}, [setActionable]);
|
|
47
|
+
return (React.createElement(LinkAction, { as: (!!props.href ? 'a' : 'button'), href: href, onClick: !isDisabled ? onClick : undefined, "aria-disabled": isDisabled, ref: forwardedRef, ...rest }, children));
|
|
48
|
+
});
|
|
49
|
+
TileAction.displayName = 'Tile.Action';
|
|
50
|
+
// ----------------------------------------------------------------------------
|
|
51
|
+
// Tile.ThumbnailArea component
|
|
52
|
+
const TileThumbnailArea = polymorphic('iui-tile-thumbnail');
|
|
53
|
+
TileThumbnailArea.displayName = 'Tile.ThumbnailArea';
|
|
54
|
+
const TileThumbnailPicture = React.forwardRef((props, forwardedRef) => {
|
|
55
|
+
const { className, url, children, ...rest } = props;
|
|
56
|
+
if (url) {
|
|
57
|
+
return (React.createElement(Box, { className: cx('iui-tile-thumbnail-picture', className), style: {
|
|
58
|
+
backgroundImage: typeof url === 'string' ? `url(${url})` : undefined,
|
|
59
|
+
}, ref: forwardedRef, ...rest }));
|
|
60
|
+
}
|
|
61
|
+
return (React.createElement(Box, { className: cx('iui-thumbnail-icon', className), ref: forwardedRef, ...rest }, children));
|
|
62
|
+
});
|
|
63
|
+
TileThumbnailPicture.displayName = 'Tile.TileThumbnailPicture';
|
|
64
|
+
// ----------------------------------------------------------------------------
|
|
65
|
+
// Tile.QuickAction component
|
|
66
|
+
const TileQuickAction = polymorphic('iui-tile-thumbnail-quick-action');
|
|
67
|
+
TileQuickAction.displayName = 'Tile.QuickAction';
|
|
68
|
+
// ----------------------------------------------------------------------------
|
|
69
|
+
// Tile.TypeIndicator component
|
|
70
|
+
const TileTypeIndicator = polymorphic('iui-tile-thumbnail-type-indicator');
|
|
71
|
+
TileTypeIndicator.displayName = 'Tile.TypeIndicator';
|
|
72
|
+
// ----------------------------------------------------------------------------
|
|
73
|
+
// Tile.IconButton component
|
|
74
|
+
const TileIconButton = React.forwardRef((props, forwardedRef) => {
|
|
75
|
+
const { className, children, ...rest } = props;
|
|
76
|
+
return (React.createElement(IconButton, { className: className, styleType: 'borderless', size: 'small', ref: forwardedRef, ...rest }, children));
|
|
77
|
+
});
|
|
78
|
+
TileIconButton.displayName = 'Tile.IconButton';
|
|
79
|
+
// ----------------------------------------------------------------------------
|
|
80
|
+
// Tile.BadgeContainer component
|
|
81
|
+
const TileBadgeContainer = polymorphic('iui-tile-thumbnail-badge-container');
|
|
82
|
+
TileBadgeContainer.displayName = 'Tile.BadgeContainer';
|
|
83
|
+
const TileName = React.forwardRef((props, forwardedRef) => {
|
|
84
|
+
const { className, children, name, ...rest } = props;
|
|
85
|
+
return (React.createElement(Box, { className: cx('iui-tile-name', className), ref: forwardedRef, ...rest }, children ?? name));
|
|
86
|
+
});
|
|
87
|
+
TileBadgeContainer.displayName = 'Tile.Name';
|
|
88
|
+
// ----------------------------------------------------------------------------
|
|
89
|
+
// Tile.NameIcon component
|
|
90
|
+
const TileNameIcon = React.forwardRef((props, forwardedRef) => {
|
|
91
|
+
const { children, className, ...rest } = props;
|
|
92
|
+
const { status, isLoading, isSelected, isNew } = useSafeContext(TileContext);
|
|
110
93
|
const StatusIcon = !!status && StatusIconMap[status];
|
|
94
|
+
let icon;
|
|
95
|
+
if (StatusIcon) {
|
|
96
|
+
icon = React.createElement(StatusIcon, { "aria-hidden": true });
|
|
97
|
+
}
|
|
111
98
|
if (isLoading) {
|
|
112
|
-
|
|
99
|
+
icon = React.createElement(ProgressRadial, { size: 'x-small', "aria-hidden": true, indeterminate: true });
|
|
113
100
|
}
|
|
114
101
|
if (isSelected) {
|
|
115
|
-
|
|
102
|
+
icon = React.createElement(SvgCheckmark, { "aria-hidden": true });
|
|
116
103
|
}
|
|
117
104
|
if (isNew) {
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
if (StatusIcon) {
|
|
121
|
-
return React.createElement(StatusIcon, { className: 'iui-tile-status-icon' });
|
|
105
|
+
icon = React.createElement(SvgNew, { "aria-hidden": true });
|
|
122
106
|
}
|
|
123
|
-
return null;
|
|
124
|
-
};
|
|
107
|
+
return children || icon ? (React.createElement(Box, { className: cx('iui-tile-status-icon', className), ref: forwardedRef, ...rest }, children ?? icon)) : null;
|
|
108
|
+
});
|
|
109
|
+
TileNameIcon.displayName = 'Tile.NameIcon';
|
|
110
|
+
// ----------------------------------------------------------------------------
|
|
111
|
+
// Tile.NameLabel component
|
|
112
|
+
const TileNameLabel = polymorphic.span('iui-tile-name-label');
|
|
113
|
+
TileNameLabel.displayName = 'Tile.NameLabel';
|
|
114
|
+
// ----------------------------------------------------------------------------
|
|
115
|
+
// Tile.ContentArea component
|
|
116
|
+
const TileContentArea = polymorphic('iui-tile-content');
|
|
117
|
+
TileContentArea.displayName = 'Tile.ContentArea';
|
|
118
|
+
// ----------------------------------------------------------------------------
|
|
119
|
+
// Tile.Description component
|
|
120
|
+
const TileDescription = polymorphic('iui-tile-description');
|
|
121
|
+
TileDescription.displayName = 'Tile.Description';
|
|
122
|
+
// ----------------------------------------------------------------------------
|
|
123
|
+
// Tile.Metadata component
|
|
124
|
+
const TileMetadata = polymorphic('iui-tile-metadata');
|
|
125
|
+
TileMetadata.displayName = 'Tile.Metadata';
|
|
126
|
+
const TileMoreOptions = React.forwardRef((props, forwardedRef) => {
|
|
127
|
+
const { className, children = [], buttonProps, ...rest } = props;
|
|
128
|
+
const [isMenuVisible, setIsMenuVisible] = React.useState(false);
|
|
129
|
+
return (React.createElement(DropdownMenu, { onShow: React.useCallback(() => setIsMenuVisible(true), []), onHide: React.useCallback(() => setIsMenuVisible(false), []), menuItems: (close) => children?.map((option) => React.cloneElement(option, {
|
|
130
|
+
onClick: (value) => {
|
|
131
|
+
close();
|
|
132
|
+
option.props.onClick?.(value);
|
|
133
|
+
},
|
|
134
|
+
})) },
|
|
135
|
+
React.createElement(Box, { className: cx('iui-tile-more-options', {
|
|
136
|
+
'iui-visible': isMenuVisible,
|
|
137
|
+
}, className), ref: forwardedRef, ...rest },
|
|
138
|
+
React.createElement(IconButton, { styleType: 'borderless', size: 'small', "aria-label": 'More options', ...buttonProps },
|
|
139
|
+
React.createElement(SvgMore, null)))));
|
|
140
|
+
});
|
|
141
|
+
TileMoreOptions.displayName = 'Tile.MoreOptions';
|
|
142
|
+
// ----------------------------------------------------------------------------
|
|
143
|
+
// Tile.Buttons component
|
|
144
|
+
const TileButtons = polymorphic('iui-tile-buttons');
|
|
145
|
+
TileButtons.displayName = 'Tile.Buttons';
|
|
146
|
+
/**
|
|
147
|
+
* Tile with customizable Thumbnail, Name, Content and Buttons subcomponents
|
|
148
|
+
* @example
|
|
149
|
+
* <Tile>
|
|
150
|
+
* <Tile.ThumbnailArea>
|
|
151
|
+
* <Tile.ThumbnailPicture/>
|
|
152
|
+
* <Tile.Badge/>
|
|
153
|
+
* <Tile.TypeIndicator/>
|
|
154
|
+
* <Tile.QuickAction/>
|
|
155
|
+
* </Tile.ThumbnailArea>
|
|
156
|
+
* <Tile.Name>
|
|
157
|
+
* <Tile.NameIcon/>
|
|
158
|
+
* <Tile.NameLabel/>
|
|
159
|
+
* <Tile.Name/>
|
|
160
|
+
* <Tile.ContentArea>
|
|
161
|
+
* <Tile.Description />
|
|
162
|
+
* <Tile.Metadata/>
|
|
163
|
+
* <Tile.MoreOptions/>
|
|
164
|
+
* </Tile.ContentArea>
|
|
165
|
+
* <Tile.Buttons/>
|
|
166
|
+
* </Tile>
|
|
167
|
+
*/
|
|
168
|
+
export const Tile = Object.assign(TileComponent, {
|
|
169
|
+
/**
|
|
170
|
+
* ThumbnailArea subcomponent that contains `ThumbnailPicture`, `QuickAction`, `TypeIndicator` or `BadgeContainer`
|
|
171
|
+
* @example
|
|
172
|
+
* <Tile.ThumbnailArea>
|
|
173
|
+
* <Tile.ThumbnailPicture/>
|
|
174
|
+
* // or
|
|
175
|
+
* <Tile.ThumbnailAvatar/>
|
|
176
|
+
* <Tile.QuickAction/>
|
|
177
|
+
* <Tile.TypeIndicator/>
|
|
178
|
+
* <Tile.BadgeContainer/>
|
|
179
|
+
* </Tile.ThumbnailArea>
|
|
180
|
+
*/
|
|
181
|
+
ThumbnailArea: TileThumbnailArea,
|
|
182
|
+
/**
|
|
183
|
+
* Thumbnail image url, a custom component or an svg for thumbnail avatar.
|
|
184
|
+
* @example
|
|
185
|
+
* <Tile>
|
|
186
|
+
* // ...
|
|
187
|
+
* <Tile.ThumbnailArea>
|
|
188
|
+
* <Tile.ThumbnailPicture url = '/url/to/image.jpg'/>
|
|
189
|
+
* </Tile.ThumbnailArea>
|
|
190
|
+
* </Tile>
|
|
191
|
+
* or
|
|
192
|
+
* <Tile>
|
|
193
|
+
* // ...
|
|
194
|
+
* <Tile.ThumbnailArea>
|
|
195
|
+
* <Tile.ThumbnailPicture>
|
|
196
|
+
* {<Avatar image={<img src='icon.png' />} />}
|
|
197
|
+
* // or
|
|
198
|
+
* {<SvgImodelHollow />}
|
|
199
|
+
* </Tile.ThumbnailPicture>
|
|
200
|
+
* </Tile.ThumbnailArea>
|
|
201
|
+
* /Tile>
|
|
202
|
+
*/
|
|
203
|
+
ThumbnailPicture: TileThumbnailPicture,
|
|
204
|
+
/**
|
|
205
|
+
* `QuickAction` subcomponent shown on top left of the tile.
|
|
206
|
+
* Recommended to use an invisible `IconButton`.
|
|
207
|
+
*/
|
|
208
|
+
QuickAction: TileQuickAction,
|
|
209
|
+
/**
|
|
210
|
+
* `TypeIndicator` subcomponent shown on top left of the tile.
|
|
211
|
+
* Recommended to use an invisible `IconButton`.
|
|
212
|
+
*/
|
|
213
|
+
TypeIndicator: TileTypeIndicator,
|
|
214
|
+
/**
|
|
215
|
+
* `BadgeContainer` subcomponent shown on the bottom right of thumbnail.
|
|
216
|
+
*/
|
|
217
|
+
BadgeContainer: TileBadgeContainer,
|
|
218
|
+
/**
|
|
219
|
+
* `IconButton` subcomponent: custom icon for `QuickAction` and `TypeIndicator` buttons.
|
|
220
|
+
*/
|
|
221
|
+
IconButton: TileIconButton,
|
|
222
|
+
/**
|
|
223
|
+
* `Name` subcomponent under thumbnail or top of the Tile if no thumbnail present.
|
|
224
|
+
*/
|
|
225
|
+
Name: TileName,
|
|
226
|
+
/**
|
|
227
|
+
* `NameIcon` next to name of the tile. Goes under <Tile.Name>
|
|
228
|
+
* @example
|
|
229
|
+
* <Tile>
|
|
230
|
+
* <Tile.Name>
|
|
231
|
+
* <Tile.NameIcon/>
|
|
232
|
+
* </Tile.Name>
|
|
233
|
+
* <Tile/>
|
|
234
|
+
*/
|
|
235
|
+
NameIcon: TileNameIcon,
|
|
236
|
+
/*
|
|
237
|
+
* `NameLabel` of the tile
|
|
238
|
+
* @example
|
|
239
|
+
* <Tile>
|
|
240
|
+
* <Tile.Name>
|
|
241
|
+
* <Tile.NameLabel> Tile Name <Tile.NameLabel/>
|
|
242
|
+
* </Tile.Name/>
|
|
243
|
+
* <Tile/>
|
|
244
|
+
*/
|
|
245
|
+
NameLabel: TileNameLabel,
|
|
246
|
+
/**
|
|
247
|
+
* Polymorphic Tile action component. Recommended to be used in `Tile.NameLabel` subcomponent.
|
|
248
|
+
* Renders `a` element by default.
|
|
249
|
+
* @example
|
|
250
|
+
* <Tile.Name>
|
|
251
|
+
* <Tile.NameLabel>
|
|
252
|
+
* {<Tile.Action href='/new-page'>Tile Name<Tile.Action/>}
|
|
253
|
+
* <Tile.NameLabel/>
|
|
254
|
+
* </Tile.Name>
|
|
255
|
+
*/
|
|
256
|
+
Action: TileAction,
|
|
257
|
+
/**
|
|
258
|
+
* Tile content area that contains `Description`, `Metadata` and `MoreOptions` Tile subcomponents
|
|
259
|
+
* @example
|
|
260
|
+
* <Tile>
|
|
261
|
+
* <Tile.ContentArea>
|
|
262
|
+
* <Tile.Description/>
|
|
263
|
+
* <Tile.Metadata/>
|
|
264
|
+
* <Tile.MoreOptions/>
|
|
265
|
+
* </Tile.ContentArea>
|
|
266
|
+
* </Tile>
|
|
267
|
+
*/
|
|
268
|
+
ContentArea: TileContentArea,
|
|
269
|
+
/**
|
|
270
|
+
* Description text of the tile.
|
|
271
|
+
* Gets truncated if it can't fit in the tile.
|
|
272
|
+
*/
|
|
273
|
+
Description: TileDescription,
|
|
274
|
+
/**
|
|
275
|
+
* Metadata section located below description.
|
|
276
|
+
* @example
|
|
277
|
+
* <Tile.Metadata>
|
|
278
|
+
* // ...
|
|
279
|
+
* 'basic metadata'
|
|
280
|
+
* // or
|
|
281
|
+
* {<span><SvgClock /> 2021-01-01, 04:30 AM</span>}
|
|
282
|
+
* // or
|
|
283
|
+
* {<>
|
|
284
|
+
* <SvgTag2 />
|
|
285
|
+
* <TagContainer><Tag variant='basic'>Tag 1</Tag><Tag variant='basic'>Tag 2</Tag></TagContainer>
|
|
286
|
+
* </>}
|
|
287
|
+
* </Tile.Metadata>
|
|
288
|
+
*/
|
|
289
|
+
Metadata: TileMetadata,
|
|
290
|
+
/**
|
|
291
|
+
* Dropdown menu containing `MenuItem`s.
|
|
292
|
+
*/
|
|
293
|
+
MoreOptions: TileMoreOptions,
|
|
294
|
+
/**
|
|
295
|
+
* Upto two buttons shown at the bottom of the tile.
|
|
296
|
+
*/
|
|
297
|
+
Buttons: TileButtons,
|
|
298
|
+
});
|
|
125
299
|
export default Tile;
|