superdesk-ui-framework 4.0.33 → 4.0.35
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/CheckGroup.tsx +6 -1
- package/app-typescript/components/DateTimePicker.tsx +112 -94
- package/app-typescript/components/Label.tsx +31 -12
- package/app-typescript/components/Modal.tsx +2 -2
- package/app-typescript/components/RadioButtonGroup.tsx +1 -0
- package/app-typescript/components/TreeSelect/TreeSelectItem.tsx +1 -1
- package/dist/components/DateTimePicker.tsx +19 -10
- package/dist/examples.bundle.js +871 -2686
- package/dist/superdesk-ui.bundle.css +1 -1
- package/dist/superdesk-ui.bundle.js +860 -2675
- package/examples/pages/components/DateTimePicker.tsx +19 -10
- package/package.json +2 -2
- package/react/components/CheckGroup.d.ts +1 -0
- package/react/components/CheckGroup.js +1 -1
- package/react/components/DateTimePicker.d.ts +7 -7
- package/react/components/DateTimePicker.js +16 -10
- package/react/components/Label.d.ts +1 -0
- package/react/components/Label.js +6 -6
- package/react/components/Modal.d.ts +1 -1
- package/react/components/Modal.js +2 -2
- package/react/components/RadioButtonGroup.js +1 -1
- package/react/components/TreeSelect/TreeSelectItem.js +1 -1
@@ -5,6 +5,7 @@ interface IProps {
|
|
5
5
|
orientation?: 'horizontal' | 'vertical'; // defaults to 'horizontal'
|
6
6
|
children: React.ReactNode;
|
7
7
|
groupLabelledBy?: string;
|
8
|
+
'data-test-id'?: string;
|
8
9
|
}
|
9
10
|
|
10
11
|
export class CheckGroup extends React.PureComponent<IProps> {
|
@@ -14,7 +15,11 @@ export class CheckGroup extends React.PureComponent<IProps> {
|
|
14
15
|
});
|
15
16
|
|
16
17
|
return (
|
17
|
-
<div
|
18
|
+
<div
|
19
|
+
className={classes}
|
20
|
+
aria-labelledby={this.props.groupLabelledBy}
|
21
|
+
data-test-id={this.props['data-test-id']}
|
22
|
+
>
|
18
23
|
{this.props.children}
|
19
24
|
</div>
|
20
25
|
);
|
@@ -1,109 +1,127 @@
|
|
1
|
-
import * as React from
|
2
|
-
import {DatePicker} from
|
3
|
-
import {Spacer} from
|
4
|
-
import {defaultTo} from
|
5
|
-
import {TimePicker} from
|
6
|
-
import {IconButton} from
|
1
|
+
import * as React from "react";
|
2
|
+
import { DatePicker } from "../components/DatePicker";
|
3
|
+
import { Spacer } from "@superdesk/common";
|
4
|
+
import { defaultTo } from "lodash";
|
5
|
+
import { TimePicker } from "./TimePicker";
|
6
|
+
import { IconButton } from "./IconButton";
|
7
|
+
import { InputWrapper } from "./Form";
|
8
|
+
import { IInputWrapper } from "./Form/InputWrapper";
|
9
|
+
import nextId from "react-id-generator";
|
7
10
|
|
8
|
-
interface IProps {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
required?: boolean;
|
20
|
-
width?: React.CSSProperties['width'];
|
21
|
-
disabled?: boolean;
|
11
|
+
interface IProps extends IInputWrapper {
|
12
|
+
value: Date | null;
|
13
|
+
dateFormat: string;
|
14
|
+
onChange: (value: Date | null) => void;
|
15
|
+
preview?: boolean;
|
16
|
+
fullWidth?: boolean;
|
17
|
+
allowSeconds?: boolean;
|
18
|
+
required?: boolean;
|
19
|
+
disabled?: boolean;
|
20
|
+
ref?: React.LegacyRef<InputWrapper>;
|
21
|
+
'data-test-id'?: string;
|
22
22
|
}
|
23
23
|
|
24
|
-
const MIN_WIDTH = 348;
|
25
|
-
|
26
24
|
export class DateTimePicker extends React.PureComponent<IProps> {
|
27
|
-
|
28
|
-
const [hours, minutes] = time.split(':').map((x) => defaultTo(parseInt(x, 10), 0)); // handle NaN value
|
29
|
-
const origDate = this.props.value ? new Date(this.props.value) : new Date();
|
25
|
+
private htmlId: string = nextId();
|
30
26
|
|
31
|
-
|
27
|
+
handleTimeChange = (time: string) => {
|
28
|
+
const [hours, minutes] = time
|
29
|
+
.split(":")
|
30
|
+
.map((x) => defaultTo(parseInt(x, 10), 0)); // handle NaN value
|
31
|
+
const origDate = this.props.value ? new Date(this.props.value) : new Date();
|
32
32
|
|
33
|
-
|
34
|
-
}
|
33
|
+
origDate.setHours(hours, minutes);
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
this.props.onChange(null);
|
35
|
+
this.props.onChange(origDate);
|
36
|
+
}
|
39
37
|
|
40
|
-
|
41
|
-
|
38
|
+
handleDateChange = (date: Date | null) => {
|
39
|
+
if (date == null) {
|
40
|
+
this.props.onChange(null);
|
42
41
|
|
43
|
-
|
44
|
-
|
42
|
+
return;
|
43
|
+
}
|
45
44
|
|
46
|
-
|
45
|
+
const origDate = this.props.value ?? new Date();
|
46
|
+
const selectedDate = new Date(date);
|
47
47
|
|
48
|
-
|
49
|
-
}
|
48
|
+
selectedDate.setHours(origDate.getHours(), origDate.getMinutes());
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
}
|
50
|
+
this.props.onChange(selectedDate);
|
51
|
+
}
|
54
52
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
: '';
|
53
|
+
prepareFormat(unitOfTime: number) {
|
54
|
+
return unitOfTime.toString().padStart(2, "0");
|
55
|
+
}
|
59
56
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
57
|
+
render() {
|
58
|
+
const convertedTimeValue =
|
59
|
+
this.props.value != null
|
60
|
+
? `${this.prepareFormat(
|
61
|
+
this.props.value.getHours(),
|
62
|
+
)}:${this.prepareFormat(this.props.value.getMinutes())}`
|
63
|
+
: "";
|
64
|
+
|
65
|
+
return (
|
66
|
+
<InputWrapper
|
67
|
+
label={this.props.label}
|
68
|
+
error={this.props.error}
|
69
|
+
invalid={this.props.error != null}
|
70
|
+
required={this.props.required}
|
71
|
+
disabled={this.props.disabled}
|
72
|
+
info={this.props.info}
|
73
|
+
inlineLabel={this.props.inlineLabel}
|
74
|
+
labelHidden={this.props.labelHidden}
|
75
|
+
htmlId={this.htmlId}
|
76
|
+
tabindex={this.props.tabindex}
|
77
|
+
fullWidth={this.props.fullWidth}
|
78
|
+
data-test-id={this.props["data-test-id"]}
|
79
|
+
ref={this.props.ref}
|
80
|
+
>
|
81
|
+
<Spacer h gap="8" alignItems="end" noWrap>
|
82
|
+
<div style={{ flexGrow: 1 }}>
|
83
|
+
<DatePicker
|
84
|
+
disabled={this.props.disabled}
|
85
|
+
preview={this.props.preview}
|
86
|
+
required={this.props.required}
|
87
|
+
hideClearButton={true}
|
88
|
+
value={this.props.value}
|
89
|
+
onChange={(val) => {
|
90
|
+
this.handleDateChange(val);
|
91
|
+
}}
|
92
|
+
dateFormat={this.props.dateFormat}
|
93
|
+
inlineLabel
|
94
|
+
labelHidden
|
95
|
+
fullWidth={this.props.fullWidth}
|
96
|
+
/>
|
97
|
+
</div>
|
98
|
+
<div style={{ flexGrow: 1 }}>
|
99
|
+
<TimePicker
|
100
|
+
disabled={this.props.disabled}
|
101
|
+
preview={this.props.preview}
|
102
|
+
value={convertedTimeValue}
|
103
|
+
onChange={(val) => {
|
104
|
+
this.handleTimeChange(val);
|
105
|
+
}}
|
106
|
+
inlineLabel
|
107
|
+
labelHidden
|
108
|
+
allowSeconds={this.props.allowSeconds}
|
109
|
+
fullWidth={this.props.fullWidth}
|
110
|
+
required={this.props.required}
|
111
|
+
/>
|
112
|
+
</div>
|
113
|
+
{this.props.preview !== true && (
|
114
|
+
<IconButton
|
115
|
+
disabled={this.props.disabled}
|
116
|
+
icon="remove-sign"
|
117
|
+
onClick={() => {
|
118
|
+
this.props.onChange(null);
|
119
|
+
}}
|
120
|
+
ariaValue="Clear"
|
121
|
+
/>
|
122
|
+
)}
|
123
|
+
</Spacer>
|
124
|
+
</InputWrapper>
|
125
|
+
);
|
126
|
+
}
|
109
127
|
}
|
@@ -12,6 +12,7 @@ interface IProps {
|
|
12
12
|
noTransform?: boolean;
|
13
13
|
hexColor?: string;
|
14
14
|
style?: 'filled' | 'hollow' | 'translucent'; // defaults to 'filled'
|
15
|
+
'data-test-id'?: string;
|
15
16
|
}
|
16
17
|
export class Label extends React.PureComponent<IProps> {
|
17
18
|
render() {
|
@@ -23,13 +24,16 @@ export class Label extends React.PureComponent<IProps> {
|
|
23
24
|
[`label--${this.props.style}`]: this.props.style !== 'filled' && this.props.style !== undefined,
|
24
25
|
[`hollow-${this.props.color}`]: this.props.color && this.props.style === 'hollow',
|
25
26
|
});
|
27
|
+
|
26
28
|
if (this.props.link || this.props.onClick) {
|
27
29
|
if (this.props.style === 'hollow') {
|
28
30
|
return (
|
29
31
|
<a className={classes}
|
30
32
|
href={this.props.link}
|
31
33
|
onClick={this.props.onClick}
|
32
|
-
style={{color: this.props.hexColor, borderColor: this.props.hexColor}}
|
34
|
+
style={{color: this.props.hexColor, borderColor: this.props.hexColor}}
|
35
|
+
data-test-id={this.props['data-test-id']}
|
36
|
+
>
|
33
37
|
{this.props.text}
|
34
38
|
</a>
|
35
39
|
);
|
@@ -38,7 +42,9 @@ export class Label extends React.PureComponent<IProps> {
|
|
38
42
|
<a className={classes}
|
39
43
|
href={this.props.link}
|
40
44
|
onClick={this.props.onClick}
|
41
|
-
style={{color: this.props.hexColor, backgroundColor: `${this.props.hexColor}33`}}
|
45
|
+
style={{color: this.props.hexColor, backgroundColor: `${this.props.hexColor}33`}}
|
46
|
+
data-test-id={this.props['data-test-id']}
|
47
|
+
>
|
42
48
|
{this.props.text}
|
43
49
|
</a>
|
44
50
|
);
|
@@ -46,7 +52,9 @@ export class Label extends React.PureComponent<IProps> {
|
|
46
52
|
return (
|
47
53
|
<a className={classes}
|
48
54
|
href={this.props.link}
|
49
|
-
onClick={this.props.onClick} style={{backgroundColor: this.props.hexColor}}
|
55
|
+
onClick={this.props.onClick} style={{backgroundColor: this.props.hexColor}}
|
56
|
+
data-test-id={this.props['data-test-id']}
|
57
|
+
>
|
50
58
|
{this.props.text}
|
51
59
|
</a>
|
52
60
|
);
|
@@ -54,25 +62,36 @@ export class Label extends React.PureComponent<IProps> {
|
|
54
62
|
} else {
|
55
63
|
if (this.props.style === 'hollow') {
|
56
64
|
return (
|
57
|
-
<span
|
58
|
-
|
65
|
+
<span
|
66
|
+
className={classes}
|
67
|
+
style={{color: this.props.hexColor, borderColor: this.props.hexColor}}
|
68
|
+
data-test-id={this.props['data-test-id']}
|
69
|
+
>
|
59
70
|
{this.props.text}
|
60
71
|
</span>
|
61
72
|
);
|
62
73
|
} else if (this.props.style === 'translucent') {
|
63
74
|
return (
|
64
|
-
<span
|
65
|
-
|
75
|
+
<span
|
76
|
+
className={classes}
|
77
|
+
style={{color: this.props.hexColor, backgroundColor: `${this.props.hexColor}33`}}
|
78
|
+
data-test-id={this.props['data-test-id']}
|
79
|
+
>
|
66
80
|
{this.props.text}
|
67
81
|
</span>
|
68
82
|
);
|
69
83
|
} else {
|
70
84
|
return (
|
71
|
-
<span
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
85
|
+
<span
|
86
|
+
className={classes}
|
87
|
+
style={
|
88
|
+
this.props.hexColor
|
89
|
+
? {backgroundColor: this.props.hexColor, color: getTextColor(this.props.hexColor)}
|
90
|
+
: undefined
|
91
|
+
}
|
92
|
+
data-test-id={this.props['data-test-id']}
|
93
|
+
>
|
94
|
+
{this.props.text}
|
76
95
|
</span>
|
77
96
|
);
|
78
97
|
}
|
@@ -27,7 +27,7 @@ interface IProps {
|
|
27
27
|
maximizable?: boolean;
|
28
28
|
headerTemplate?: JSX.Element | string;
|
29
29
|
footerTemplate?: JSX.Element | string;
|
30
|
-
|
30
|
+
'data-test-id'?: string;
|
31
31
|
onShow?(): void;
|
32
32
|
onHide?(): void;
|
33
33
|
}
|
@@ -47,7 +47,6 @@ export class Modal extends React.Component<IProps, {}> {
|
|
47
47
|
<div
|
48
48
|
style={{display: 'content'}}
|
49
49
|
data-theme={this.props.theme !== 'dark' ? null : 'dark-ui' }
|
50
|
-
data-test-id={this.props['data-test-id']}
|
51
50
|
>
|
52
51
|
<PrimeDialog
|
53
52
|
id={this.props.id}
|
@@ -63,6 +62,7 @@ export class Modal extends React.Component<IProps, {}> {
|
|
63
62
|
zIndex={this.zIndex}
|
64
63
|
position={this.props.position}
|
65
64
|
closable={this.props.onHide != null ? true : false}
|
65
|
+
data-test-id={this.props['data-test-id']}
|
66
66
|
>
|
67
67
|
{this.props.children}
|
68
68
|
</PrimeDialog>
|
@@ -82,6 +82,7 @@ export class RadioButtonGroup extends React.Component<IProps> {
|
|
82
82
|
htmlFor={this.htmlId + index}
|
83
83
|
aria-label={item.labelHidden ? item.label : undefined}
|
84
84
|
data-test-id="item"
|
85
|
+
data-test-value={item.label}
|
85
86
|
>
|
86
87
|
|
87
88
|
{ item.icon ? <i className={`icon-${item.icon}`} aria-hidden="true" /> : null }
|
@@ -92,7 +92,7 @@ export class TreeSelectItem<T> extends React.Component<IProps<T>> {
|
|
92
92
|
</span>
|
93
93
|
|
94
94
|
{this.props.option.children
|
95
|
-
&& <span className="suggestion-item__icon" aria-hidden="true">
|
95
|
+
&& <span className="suggestion-item__icon" aria-hidden="true" data-test-id="children-indicator">
|
96
96
|
<Icon name="chevron-right-thin"></Icon>
|
97
97
|
</span>
|
98
98
|
}
|
@@ -14,10 +14,12 @@ class DateTimePickerExample extends React.PureComponent<{}, {dateTime: Date | nu
|
|
14
14
|
render() {
|
15
15
|
return (
|
16
16
|
<DateTimePicker
|
17
|
-
label=
|
17
|
+
label="Planning date"
|
18
|
+
labelHidden
|
19
|
+
inlineLabel
|
18
20
|
value={this.state.dateTime}
|
19
21
|
dateFormat="YYYY-MM-DD"
|
20
|
-
|
22
|
+
fullWidth
|
21
23
|
onChange={(val) => {
|
22
24
|
const parsedVal = val != null ? new Date(val) : null;
|
23
25
|
|
@@ -49,11 +51,14 @@ export default class DateTimePickerDoc extends React.Component<{}, IState> {
|
|
49
51
|
<h2 className="docs-page__h2">Date picker</h2>
|
50
52
|
<Markup.ReactMarkupCodePreview>{`
|
51
53
|
<DateTimePicker
|
52
|
-
label="Planning
|
53
|
-
value={this.state.
|
54
|
+
label="Planning date"
|
55
|
+
value={this.state.dateTime}
|
54
56
|
dateFormat="YYYY-MM-DD"
|
55
|
-
|
56
|
-
|
57
|
+
fullWidth
|
58
|
+
onChange={(val) => {
|
59
|
+
const parsedVal = val != null ? new Date(val) : null;
|
60
|
+
|
61
|
+
this.setState({dateTime: parsedVal});
|
57
62
|
}}
|
58
63
|
/>
|
59
64
|
`}</Markup.ReactMarkupCodePreview>
|
@@ -65,11 +70,15 @@ export default class DateTimePickerDoc extends React.Component<{}, IState> {
|
|
65
70
|
</Markup.ReactMarkupPreview>
|
66
71
|
<Markup.ReactMarkupCode>{`
|
67
72
|
<DateTimePicker
|
68
|
-
|
69
|
-
|
70
|
-
this.setState({date});
|
71
|
-
}}
|
73
|
+
label="Planning date"
|
74
|
+
value={this.state.dateTime}
|
72
75
|
dateFormat="YYYY-MM-DD"
|
76
|
+
fullWidth
|
77
|
+
onChange={(val) => {
|
78
|
+
const parsedVal = val != null ? new Date(val) : null;
|
79
|
+
|
80
|
+
this.setState({dateTime: parsedVal});
|
81
|
+
}}
|
73
82
|
/>
|
74
83
|
`}</Markup.ReactMarkupCode>
|
75
84
|
</Markup.ReactMarkup>
|