superdesk-ui-framework 3.0.52 → 3.0.54
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/app/styles/primereact/_pr-general.scss +2 -2
- package/app-typescript/components/SelectWithTemplate.tsx +12 -2
- package/app-typescript/components/avatar/avatar-image.tsx +22 -6
- package/app-typescript/components/avatar/avatar-placeholder.tsx +23 -3
- package/app-typescript/components/avatar/avatar.tsx +38 -11
- package/dist/examples.bundle.js +251 -210
- package/dist/superdesk-ui.bundle.css +3 -3
- package/dist/superdesk-ui.bundle.js +231 -190
- package/package.json +1 -1
- package/react/components/SelectWithTemplate.d.ts +3 -0
- package/react/components/SelectWithTemplate.js +7 -1
- package/react/components/avatar/avatar-image.d.ts +1 -0
- package/react/components/avatar/avatar-image.js +22 -6
- package/react/components/avatar/avatar-placeholder.d.ts +1 -1
- package/react/components/avatar/avatar-placeholder.js +13 -3
- package/react/components/avatar/avatar.d.ts +11 -0
- package/react/components/avatar/avatar.js +13 -4
@@ -36,7 +36,7 @@
|
|
36
36
|
@mixin pr-input-item-base {
|
37
37
|
display: inline-flex;
|
38
38
|
align-items: center;
|
39
|
-
height: $height-input--default;
|
39
|
+
min-height: $height-input--default;
|
40
40
|
border-bottom: 1px solid var(--color-input-border);
|
41
41
|
background-color: var(--color-input-bg);
|
42
42
|
font-size: 1.4rem;
|
@@ -48,7 +48,7 @@
|
|
48
48
|
background-color: var(--color-input-bg--hover);
|
49
49
|
border-color: var(--color-input-border-hover);
|
50
50
|
}
|
51
|
-
|
51
|
+
|
52
52
|
&:focus, &:focus-within, &.p-focus {
|
53
53
|
background-color: var(--sd-colour-interactive--alpha-20);
|
54
54
|
box-shadow: 0 1px 0 0 $sd-colour-interactive;
|
@@ -12,6 +12,7 @@ interface IProps<T> extends IInputWrapper {
|
|
12
12
|
onChange(value: T): void;
|
13
13
|
areEqual(a: T, b: T): boolean; // Using reference equality for objects is error prone.
|
14
14
|
itemTemplate: React.ComponentType<{option: T | null}>;
|
15
|
+
valueTemplate?: React.ComponentType<{option: T | null}>;
|
15
16
|
noResultsFoundMessage: string;
|
16
17
|
filterPlaceholder?: string;
|
17
18
|
autoFocus?: boolean;
|
@@ -55,6 +56,7 @@ export class SelectWithTemplate<T> extends React.Component<IProps<T>, IState<T>>
|
|
55
56
|
}
|
56
57
|
render() {
|
57
58
|
const ItemTemplate = this.props.itemTemplate;
|
59
|
+
const ValueTemplate = this.props.valueTemplate;
|
58
60
|
const {loading, options} = this.state;
|
59
61
|
const {
|
60
62
|
value,
|
@@ -115,8 +117,16 @@ export class SelectWithTemplate<T> extends React.Component<IProps<T>, IState<T>>
|
|
115
117
|
filterBy={labelKey}
|
116
118
|
showClear={!required}
|
117
119
|
emptyFilterMessage={emptyFilterMessage}
|
118
|
-
|
119
|
-
|
120
|
+
itemTemplate={(option) => <ItemTemplate option={option?.original ?? null} />}
|
121
|
+
valueTemplate={(option) => ValueTemplate != null
|
122
|
+
? (
|
123
|
+
<ValueTemplate option={option?.original ?? null} />
|
124
|
+
|
125
|
+
)
|
126
|
+
: (
|
127
|
+
<ItemTemplate option={option?.original ?? null} />
|
128
|
+
)
|
129
|
+
}
|
120
130
|
disabled={disabled}
|
121
131
|
required={required}
|
122
132
|
autoFocus={autoFocus}
|
@@ -3,22 +3,38 @@ import {IPropsBase} from './interfaces';
|
|
3
3
|
|
4
4
|
interface IPropsImageAvatar extends IPropsBase {
|
5
5
|
imageUrl?: string | null; // defaults to a placeholder image
|
6
|
+
onClick?(): void;
|
6
7
|
}
|
7
8
|
|
8
9
|
export class AvatarContentImage extends React.PureComponent<IPropsImageAvatar> {
|
9
10
|
render() {
|
10
|
-
|
11
|
+
const {imageUrl, tooltipText, onClick} = this.props;
|
12
|
+
|
13
|
+
const maybeButtonProps: React.HTMLAttributes<HTMLSpanElement> = onClick == null ? {} : {
|
14
|
+
role: 'button',
|
15
|
+
onClick: () => onClick(),
|
16
|
+
};
|
17
|
+
|
18
|
+
if (imageUrl == null) {
|
11
19
|
return (
|
12
|
-
<span
|
20
|
+
<span
|
21
|
+
{...maybeButtonProps}
|
22
|
+
className="sd-avatar-content sd-avatar-content--dummy-img"
|
23
|
+
title={tooltipText}
|
24
|
+
>
|
13
25
|
<svg width="200" height="200" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg">
|
14
|
-
<circle cx="100" cy="100" r="100" fill="white"
|
15
|
-
<path
|
26
|
+
<circle cx="100" cy="100" r="100" fill="white" fillOpacity="0.01"/>
|
27
|
+
<path fillRule="evenodd" clipRule="evenodd" d="M40 153V145.384C40 141.557 41.16 137.981 43.16 135C49.14 126.057 66.24 119.711 77.14 118C82.74 117.115 90.16 116.538 100 116.538C109.84 116.538 117.26 117.115 122.86 118C133.76 119.711 150.86 126.057 156.84 135C158.84 137.981 160 141.557 160 145.384V153C150 165 130 180 100 180C70 180 50 165 40 153ZM100 30C122.08 30 140 47.2307 140 68.4614C140 89.6922 122.08 106.923 100 106.923C77.92 106.923 60 89.6922 60 68.4614C60 47.2307 77.92 30 100 30Z" fill="var(--sd-colour-avatar-dummy)" fillOpacity="1"/>
|
16
28
|
</svg>
|
17
29
|
</span>);
|
18
30
|
} else {
|
19
31
|
return (
|
20
|
-
<span
|
21
|
-
|
32
|
+
<span
|
33
|
+
{...maybeButtonProps}
|
34
|
+
className="sd-avatar-content"
|
35
|
+
title={tooltipText}
|
36
|
+
>
|
37
|
+
<img src={imageUrl} />
|
22
38
|
</span>
|
23
39
|
);
|
24
40
|
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import {AvatarWrapper} from './avatar-wrapper';
|
3
3
|
import {AvatarContentAdd} from './avatar-action-add';
|
4
|
+
import {AvatarContentImage} from './avatar-image';
|
4
5
|
|
5
6
|
export interface IPropsAvatarPlaceholder {
|
6
7
|
// kind is used to it's easy to add
|
7
8
|
// other types of placeholders without breaking existing usages
|
8
|
-
kind: 'plus-button';
|
9
|
+
kind: 'plus-button' | 'user-icon';
|
9
10
|
tooltip?: string | null; // nullable, but mandatory to communicate importance
|
10
11
|
|
11
12
|
size: 'x-small' | 'small' | 'medium' | 'large' | 'x-large' | 'xx-large';
|
@@ -20,7 +21,7 @@ export interface IPropsAvatarPlaceholder {
|
|
20
21
|
|
21
22
|
export class AvatarPlaceholder extends React.PureComponent<IPropsAvatarPlaceholder> {
|
22
23
|
render() {
|
23
|
-
const {size, tooltip, icon} = this.props;
|
24
|
+
const {size, tooltip, icon, kind, onClick} = this.props;
|
24
25
|
|
25
26
|
return (
|
26
27
|
<AvatarWrapper
|
@@ -28,7 +29,26 @@ export class AvatarPlaceholder extends React.PureComponent<IPropsAvatarPlacehold
|
|
28
29
|
isEmpty={false}
|
29
30
|
icon={icon}
|
30
31
|
>
|
31
|
-
|
32
|
+
{(() => {
|
33
|
+
if (kind === 'plus-button') {
|
34
|
+
return (
|
35
|
+
<AvatarContentAdd
|
36
|
+
tooltipText={tooltip ?? undefined}
|
37
|
+
onClick={onClick}
|
38
|
+
/>
|
39
|
+
);
|
40
|
+
} else if (kind === 'user-icon') {
|
41
|
+
return (
|
42
|
+
<AvatarContentImage
|
43
|
+
imageUrl={null}
|
44
|
+
tooltipText={tooltip ?? undefined}
|
45
|
+
onClick={onClick}
|
46
|
+
/>
|
47
|
+
);
|
48
|
+
} else {
|
49
|
+
return null;
|
50
|
+
}
|
51
|
+
})()}
|
32
52
|
</AvatarWrapper>
|
33
53
|
);
|
34
54
|
}
|
@@ -18,11 +18,35 @@ export interface IPropsAvatar {
|
|
18
18
|
name: string;
|
19
19
|
color?: string;
|
20
20
|
};
|
21
|
+
|
22
|
+
/**
|
23
|
+
* displayName is shown as tooltip by default
|
24
|
+
* use this if you need to add additional information (it will be added on a new line)
|
25
|
+
*/
|
26
|
+
tooltip?: string;
|
27
|
+
|
28
|
+
/**
|
29
|
+
* JSX resulting from rendering of one of the following components:
|
30
|
+
* AvatarContentText
|
31
|
+
* AvatarContentImage
|
32
|
+
*/
|
33
|
+
customContent?: JSX.Element;
|
21
34
|
}
|
22
35
|
|
23
36
|
export class Avatar extends React.PureComponent<IPropsAvatar> {
|
24
37
|
render() {
|
25
|
-
const {
|
38
|
+
const {
|
39
|
+
imageUrl,
|
40
|
+
initials,
|
41
|
+
size,
|
42
|
+
statusIndicator,
|
43
|
+
administratorIndicator,
|
44
|
+
icon,
|
45
|
+
displayName,
|
46
|
+
customContent,
|
47
|
+
} = this.props;
|
48
|
+
|
49
|
+
const tooltipCombined = [displayName, this.props.tooltip].filter((str) => (str ?? '').trim().length > 0).join('\n');
|
26
50
|
|
27
51
|
return (
|
28
52
|
<AvatarWrapper
|
@@ -32,16 +56,19 @@ export class Avatar extends React.PureComponent<IPropsAvatar> {
|
|
32
56
|
icon={icon}
|
33
57
|
isEmpty={false}
|
34
58
|
>
|
35
|
-
{
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
59
|
+
{(() => {
|
60
|
+
if (customContent != null) {
|
61
|
+
return customContent;
|
62
|
+
} else if (imageUrl != null || initials == null) {
|
63
|
+
return (
|
64
|
+
<AvatarContentImage imageUrl={imageUrl} tooltipText={tooltipCombined} />
|
65
|
+
);
|
66
|
+
} else {
|
67
|
+
return (
|
68
|
+
<AvatarContentText text={initials} tooltipText={tooltipCombined} />
|
69
|
+
);
|
70
|
+
}
|
71
|
+
})()}
|
45
72
|
</AvatarWrapper>
|
46
73
|
);
|
47
74
|
}
|