superdesk-ui-framework 3.0.43 → 3.0.45
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-typescript/components/Menu.tsx +1 -1
- package/app-typescript/components/{TreeSelect.tsx → TreeSelect/TreeSelect.tsx} +228 -257
- package/app-typescript/components/TreeSelect/TreeSelectItem.tsx +84 -0
- package/app-typescript/components/TreeSelect/TreeSelectPill.tsx +53 -0
- package/app-typescript/index.ts +1 -1
- package/dist/examples.bundle.js +1026 -913
- package/dist/react/TreeSelect.tsx +1 -1
- package/dist/superdesk-ui.bundle.js +773 -660
- package/dist/vendor.bundle.js +23 -23
- package/examples/pages/react/TreeSelect.tsx +1 -1
- package/package.json +1 -1
- package/react/components/Menu.js +1 -1
- package/react/components/{TreeSelect.d.ts → TreeSelect/TreeSelect.d.ts} +2 -2
- package/react/components/{TreeSelect.js → TreeSelect/TreeSelect.js} +82 -144
- package/react/components/TreeSelect/TreeSelectItem.d.ts +20 -0
- package/react/components/TreeSelect/TreeSelectItem.js +90 -0
- package/react/components/TreeSelect/TreeSelectPill.d.ts +14 -0
- package/react/components/TreeSelect/TreeSelectPill.js +71 -0
- package/react/index.d.ts +1 -1
- package/react/index.js +1 -1
@@ -0,0 +1,84 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { Icon } from "../Icon";
|
3
|
+
import {getTextColor} from '../Label';
|
4
|
+
import {ITreeNode} from './TreeSelect';
|
5
|
+
|
6
|
+
export function getPrefixedItemId(id: string) {
|
7
|
+
return id + '-focus';
|
8
|
+
}
|
9
|
+
|
10
|
+
interface IProps<T> {
|
11
|
+
option: ITreeNode<T>;
|
12
|
+
selectedItem: boolean;
|
13
|
+
allowMultiple?: boolean;
|
14
|
+
handleTree(event: React.MouseEvent<HTMLLIElement, MouseEvent>, option: ITreeNode<T>): any;
|
15
|
+
getLabel(item: T): string;
|
16
|
+
getId(item: T): string;
|
17
|
+
getBackgroundColor?(item: T): string;
|
18
|
+
getBorderColor?(item: T): string;
|
19
|
+
optionTemplate?(item: T): React.ComponentType<T> | JSX.Element;
|
20
|
+
onClick?: () => void;
|
21
|
+
onKeyDown?: () => void;
|
22
|
+
}
|
23
|
+
|
24
|
+
export class TreeSelectItem<T> extends React.Component<IProps<T>> {
|
25
|
+
render() {
|
26
|
+
return (
|
27
|
+
<li
|
28
|
+
className='suggestion-item suggestion-item--multi-select'
|
29
|
+
onClick={(event) => {
|
30
|
+
this.props.onClick?.();
|
31
|
+
event.preventDefault();
|
32
|
+
event.stopPropagation();
|
33
|
+
this.props.handleTree(event, this.props.option);
|
34
|
+
}}
|
35
|
+
>
|
36
|
+
<button
|
37
|
+
// the className is generated in order to focus the element later
|
38
|
+
className={`suggestion-item--btn ${getPrefixedItemId(this.props.getId(this.props.option.value))}`}
|
39
|
+
onKeyDown={(event) => {
|
40
|
+
if (event.key === 'Enter' && this.props.option.children) {
|
41
|
+
this.props.onKeyDown?.();
|
42
|
+
}
|
43
|
+
}}
|
44
|
+
>
|
45
|
+
{(this.props.getBorderColor && !this.props.allowMultiple)
|
46
|
+
&& <div
|
47
|
+
className="item-border"
|
48
|
+
style={{
|
49
|
+
backgroundColor: this.props.getBorderColor(this.props.option.value),
|
50
|
+
}}
|
51
|
+
>
|
52
|
+
</div>
|
53
|
+
}
|
54
|
+
|
55
|
+
<span
|
56
|
+
className={
|
57
|
+
'suggestion-item--bgcolor'
|
58
|
+
+ (this.props.selectedItem ? ' suggestion-item--disabled' : '')}
|
59
|
+
style={
|
60
|
+
(this.props.getBackgroundColor && this.props.option.value)
|
61
|
+
? {
|
62
|
+
backgroundColor: this.props.getBackgroundColor(this.props.option.value),
|
63
|
+
color: getTextColor(this.props.getBackgroundColor(this.props.option.value),
|
64
|
+
),
|
65
|
+
}
|
66
|
+
: undefined
|
67
|
+
}
|
68
|
+
>
|
69
|
+
{this.props.optionTemplate
|
70
|
+
? this.props.optionTemplate(this.props.option.value)
|
71
|
+
: this.props.getLabel(this.props.option.value)
|
72
|
+
}
|
73
|
+
</span>
|
74
|
+
|
75
|
+
{this.props.option.children
|
76
|
+
&& <span className="suggestion-item__icon">
|
77
|
+
<Icon name="chevron-right-thin"></Icon>
|
78
|
+
</span>
|
79
|
+
}
|
80
|
+
</button>
|
81
|
+
</li>
|
82
|
+
);
|
83
|
+
}
|
84
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import {Icon} from "../Icon";
|
3
|
+
import {getTextColor} from '../Label';
|
4
|
+
|
5
|
+
interface IProps<T> {
|
6
|
+
item: T;
|
7
|
+
readOnly?: boolean;
|
8
|
+
disabled?: boolean;
|
9
|
+
backgroundColor: string | undefined;
|
10
|
+
onRemove(): void;
|
11
|
+
valueTemplate?(item: T, Wrapper: React.ElementType): React.ComponentType<T> | JSX.Element;
|
12
|
+
getBackgroundColor?(item: T): string;
|
13
|
+
}
|
14
|
+
|
15
|
+
export class TreeSelectPill<T> extends React.Component<IProps<T>> {
|
16
|
+
render() {
|
17
|
+
return (
|
18
|
+
<li
|
19
|
+
className={
|
20
|
+
"tags-input__tag-item tags-input__tag-item--multi-select"
|
21
|
+
+ (this.props.readOnly ? ' tags-input__tag-item--readonly' : '')
|
22
|
+
}
|
23
|
+
onClick={() => (!this.props.readOnly && !this.props.disabled)
|
24
|
+
&& this.props.onRemove()
|
25
|
+
}
|
26
|
+
style={
|
27
|
+
this.props.valueTemplate
|
28
|
+
? {backgroundColor: this.props.backgroundColor}
|
29
|
+
: this.props.getBackgroundColor
|
30
|
+
&& {backgroundColor: this.props.getBackgroundColor(this.props.item)}
|
31
|
+
}
|
32
|
+
>
|
33
|
+
<span
|
34
|
+
className="tags-input__helper-box"
|
35
|
+
style={{
|
36
|
+
color: this.props.backgroundColor
|
37
|
+
? getTextColor(this.props.backgroundColor)
|
38
|
+
: this.props.getBackgroundColor
|
39
|
+
&& getTextColor(this.props.getBackgroundColor(this.props.item)),
|
40
|
+
}}
|
41
|
+
>
|
42
|
+
{this.props.children}
|
43
|
+
|
44
|
+
{!this.props.readOnly
|
45
|
+
&& <span className="tags-input__remove-button">
|
46
|
+
<Icon name="close-small"></Icon>
|
47
|
+
</span>
|
48
|
+
}
|
49
|
+
</span>
|
50
|
+
</li>
|
51
|
+
);
|
52
|
+
}
|
53
|
+
}
|
package/app-typescript/index.ts
CHANGED
@@ -90,7 +90,7 @@ export { Text } from './components/Text/Text';
|
|
90
90
|
export { Time } from './components/Text/Time';
|
91
91
|
export { Heading } from './components/Text/Heading';
|
92
92
|
export { BottomNav } from './components/Navigation/BottomNav';
|
93
|
-
export { TreeSelect } from './components/TreeSelect';
|
93
|
+
export { TreeSelect } from './components/TreeSelect/TreeSelect';
|
94
94
|
export { TableList, TableListItem } from './components/Lists/TableList';
|
95
95
|
export { ContentListItem } from './components/Lists/ContentList';
|
96
96
|
export { MultiSelect } from './components/MultiSelect';
|