superdesk-ui-framework 3.0.1-beta.5 → 3.0.1-beta.7
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/components/_sd-searchbar.scss +7 -0
- package/app/styles/form-elements/_inputs.scss +12 -0
- package/app/styles/primereact/_pr-dropdown.scss +17 -1
- package/app-typescript/components/DurationInput.tsx +52 -5
- package/app-typescript/components/Input.tsx +1 -1
- package/app-typescript/components/Lists/TableList.tsx +146 -142
- package/app-typescript/components/SearchBar.tsx +28 -9
- package/app-typescript/index.ts +2 -0
- package/dist/examples.bundle.js +28752 -28681
- package/dist/react/MultiSelect.tsx +1 -1
- package/dist/react/TableList.tsx +84 -82
- package/dist/superdesk-ui.bundle.css +51 -6
- package/dist/superdesk-ui.bundle.js +14337 -2518
- package/dist/vendor.bundle.js +23 -23
- package/examples/pages/react/MultiSelect.tsx +1 -1
- package/examples/pages/react/TableList.tsx +84 -82
- package/package.json +2 -1
- package/react/components/DurationInput.d.ts +2 -1
- package/react/components/DurationInput.js +51 -5
- package/react/components/Input.js +1 -1
- package/react/components/Lists/TableList.d.ts +42 -0
- package/react/components/Lists/TableList.js +145 -0
- package/react/components/SearchBar.d.ts +2 -1
- package/react/components/SearchBar.js +18 -2
- package/react/index.d.ts +2 -0
- package/react/index.js +7 -2
@@ -928,6 +928,8 @@
|
|
928
928
|
text-align: end;
|
929
929
|
width: 2.5ch;
|
930
930
|
font-size: 1.4rem;
|
931
|
+
padding: 0 !important;
|
932
|
+
line-height: 3.2rem;
|
931
933
|
&::-webkit-outer-spin-button,
|
932
934
|
&::-webkit-inner-spin-button {
|
933
935
|
-webkit-appearance: none;
|
@@ -983,6 +985,16 @@
|
|
983
985
|
}
|
984
986
|
}
|
985
987
|
|
988
|
+
.blink_me {
|
989
|
+
animation: blinker 1s linear infinite;
|
990
|
+
}
|
991
|
+
|
992
|
+
@keyframes blinker {
|
993
|
+
50% {
|
994
|
+
opacity: 0;
|
995
|
+
}
|
996
|
+
}
|
997
|
+
|
986
998
|
//&--boxed-style
|
987
999
|
|
988
1000
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
@import './../tag-labels';
|
2
2
|
@import './../form-elements/checkbox';
|
3
3
|
|
4
|
-
.p-dropdown
|
4
|
+
.p-dropdown {
|
5
5
|
@include pr-input-item-base;
|
6
6
|
padding-block-start: 6px;
|
7
7
|
padding-block-end: 6px;
|
@@ -10,6 +10,14 @@
|
|
10
10
|
color: $sd-text;
|
11
11
|
}
|
12
12
|
|
13
|
+
.p-multiselect {
|
14
|
+
@include pr-input-item-base;
|
15
|
+
height: auto !important;
|
16
|
+
min-height: 3.2rem !important;
|
17
|
+
color: $sd-text;
|
18
|
+
padding: 0.4rem;
|
19
|
+
}
|
20
|
+
|
13
21
|
.p-dropdown-clear-icon,
|
14
22
|
.p-multiselect-clear-icon {
|
15
23
|
position: static;
|
@@ -69,13 +77,21 @@
|
|
69
77
|
}
|
70
78
|
|
71
79
|
.p-multiselect-label {
|
80
|
+
margin: 0;
|
81
|
+
padding: 0;
|
82
|
+
list-style-type: none;
|
72
83
|
display: flex;
|
84
|
+
justify-content: flex-start;
|
73
85
|
align-items: center;
|
86
|
+
flex-wrap: wrap;
|
87
|
+
padding-inline-start: 0.4rem;
|
88
|
+
gap: 0.4rem;
|
74
89
|
}
|
75
90
|
|
76
91
|
.p-multiselect-token {
|
77
92
|
@extend .tag-label;
|
78
93
|
cursor: default;
|
94
|
+
margin: 0 !important;
|
79
95
|
|
80
96
|
.pi-times-circle {
|
81
97
|
overflow: inherit;
|
@@ -25,6 +25,7 @@ interface IState {
|
|
25
25
|
hours?: any;
|
26
26
|
minutes?: any;
|
27
27
|
seconds?: any;
|
28
|
+
blink?: string;
|
28
29
|
}
|
29
30
|
|
30
31
|
export class DurationInput extends React.PureComponent<IProps, IState> {
|
@@ -38,6 +39,7 @@ export class DurationInput extends React.PureComponent<IProps, IState> {
|
|
38
39
|
hours: this.stateUpdate('hours', this.props.hours, this.props.minutes, this.props.seconds),
|
39
40
|
minutes: this.stateUpdate('minutes', this.props.minutes, this.props.seconds),
|
40
41
|
seconds: this.stateUpdate('seconds', this.props.seconds),
|
42
|
+
blink: '',
|
41
43
|
};
|
42
44
|
|
43
45
|
this.hourRef = React.createRef();
|
@@ -68,10 +70,11 @@ export class DurationInput extends React.PureComponent<IProps, IState> {
|
|
68
70
|
return this.zeroPad(value);
|
69
71
|
}
|
70
72
|
|
71
|
-
componentDidUpdate(
|
73
|
+
componentDidUpdate(prevProps: any, prevState: IState) {
|
72
74
|
if (!this.hourRef.current || !this.minuteRef.current || !this.secondRef.current ) {
|
73
75
|
return;
|
74
76
|
}
|
77
|
+
|
75
78
|
if (this.state.hours !== prevState.hours) {
|
76
79
|
if (Number(this.hourRef.current.value) > 99) {
|
77
80
|
this.setState({
|
@@ -85,6 +88,10 @@ export class DurationInput extends React.PureComponent<IProps, IState> {
|
|
85
88
|
hours: this.zeroPad(Number(this.state.hours) + 1),
|
86
89
|
minutes: this.zeroPad(this.state.minutes % 60),
|
87
90
|
});
|
91
|
+
this.setState({blink: 'hour'});
|
92
|
+
setTimeout(() => {
|
93
|
+
this.setState({blink: ''});
|
94
|
+
}, 500);
|
88
95
|
}
|
89
96
|
if (Number(this.minuteRef.current.value) < 0) {
|
90
97
|
this.setState({
|
@@ -93,6 +100,10 @@ export class DurationInput extends React.PureComponent<IProps, IState> {
|
|
93
100
|
: this.zeroPad(Number(this.state.hours)),
|
94
101
|
minutes: 59,
|
95
102
|
});
|
103
|
+
this.setState({blink: 'hour'});
|
104
|
+
setTimeout(() => {
|
105
|
+
this.setState({blink: ''});
|
106
|
+
}, 500);
|
96
107
|
}
|
97
108
|
}
|
98
109
|
if (this.state.seconds !== prevState.seconds) {
|
@@ -101,14 +112,32 @@ export class DurationInput extends React.PureComponent<IProps, IState> {
|
|
101
112
|
minutes: this.zeroPad(Number(this.state.minutes) + 1),
|
102
113
|
seconds: this.zeroPad(this.state.seconds % 60),
|
103
114
|
});
|
115
|
+
this.setState({blink: 'minute'});
|
116
|
+
setTimeout(() => {
|
117
|
+
this.setState({blink: ''});
|
118
|
+
}, 500);
|
104
119
|
}
|
105
120
|
if (Number(this.secondRef.current.value) < 0) {
|
106
121
|
this.setState({
|
107
122
|
minutes: this.zeroPad(Number(this.state.minutes) - 1),
|
108
123
|
seconds: 59,
|
109
124
|
});
|
125
|
+
this.setState({blink: 'minute'});
|
126
|
+
setTimeout(() => {
|
127
|
+
this.setState({blink: ''});
|
128
|
+
}, 500);
|
110
129
|
}
|
111
130
|
}
|
131
|
+
|
132
|
+
if ((this.props.hours !== prevProps.hours)
|
133
|
+
|| (this.props.minutes !== prevProps.minutes)
|
134
|
+
|| (this.props.seconds !== prevProps.seconds)) {
|
135
|
+
this.setState({
|
136
|
+
hours: this.stateUpdate('hours', this.props.hours, this.props.minutes, this.props.seconds),
|
137
|
+
minutes: this.stateUpdate('minutes', this.props.minutes, this.props.seconds),
|
138
|
+
seconds: this.stateUpdate('seconds', this.props.seconds),
|
139
|
+
});
|
140
|
+
}
|
112
141
|
}
|
113
142
|
|
114
143
|
valueUpdate() {
|
@@ -213,7 +242,11 @@ export class DurationInput extends React.PureComponent<IProps, IState> {
|
|
213
242
|
handleChange(event: React.ChangeEvent<HTMLInputElement>, state: 'hours' | 'minutes' | 'seconds') {
|
214
243
|
let stateClone: IState = {};
|
215
244
|
if (event.target.value.length >= 2) {
|
216
|
-
|
245
|
+
if (event.target.selectionStart === 1 && event.target.selectionEnd === 1) {
|
246
|
+
stateClone[state] = event.target.value.slice(0, 1) + event.target.value.slice(2, 3);
|
247
|
+
} else {
|
248
|
+
stateClone[state] = event.target.value.slice(0, 2);
|
249
|
+
}
|
217
250
|
} else {
|
218
251
|
stateClone[state] = event.target.value;
|
219
252
|
}
|
@@ -263,7 +296,7 @@ export class DurationInput extends React.PureComponent<IProps, IState> {
|
|
263
296
|
tabindex={this.props.tabindex}>
|
264
297
|
<div className={InputClasses}>
|
265
298
|
<input
|
266
|
-
className=
|
299
|
+
className={`duration-input ${this.state.blink === 'hour' ? 'blink_me' : ''}`}
|
267
300
|
type='text'
|
268
301
|
id='hours'
|
269
302
|
max={99}
|
@@ -283,7 +316,7 @@ export class DurationInput extends React.PureComponent<IProps, IState> {
|
|
283
316
|
<span className='sd-input__suffix'>h</span>
|
284
317
|
|
285
318
|
<input
|
286
|
-
className=
|
319
|
+
className={`duration-input ${this.state.blink === 'minute' ? 'blink_me' : ''}`}
|
287
320
|
type='text'
|
288
321
|
id='minutes'
|
289
322
|
ref={this.minuteRef}
|
@@ -324,5 +357,19 @@ export class DurationInput extends React.PureComponent<IProps, IState> {
|
|
324
357
|
}
|
325
358
|
|
326
359
|
export function getDurationString(seconds: number) {
|
327
|
-
|
360
|
+
function zeroPad(value: number | string) {
|
361
|
+
if (value.toString().length === 1 || value === 0) {
|
362
|
+
return `0${value}`;
|
363
|
+
} else if (!value) {
|
364
|
+
return '00';
|
365
|
+
} else {
|
366
|
+
return value;
|
367
|
+
}
|
368
|
+
}
|
369
|
+
|
370
|
+
let hour = zeroPad(Math.floor(seconds / 3600));
|
371
|
+
let minute = zeroPad(Math.floor((seconds % 3600) / 60));
|
372
|
+
let second = zeroPad(Math.floor(seconds % 60));
|
373
|
+
|
374
|
+
return `${hour}h ${minute}m ${second}s`;
|
328
375
|
}
|
@@ -88,7 +88,7 @@ export class Input extends React.Component<IProps, IState> {
|
|
88
88
|
required={this.props.required}
|
89
89
|
disabled={this.props.disabled}
|
90
90
|
value={this.state.value}
|
91
|
-
invalid={this.
|
91
|
+
invalid={this.props.invalid}
|
92
92
|
info={this.props.info}
|
93
93
|
maxLength={this.props.maxLength}
|
94
94
|
inlineLabel={this.props.inlineLabel}
|
@@ -1,125 +1,51 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import classNames from 'classnames';
|
3
|
-
import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";
|
3
|
+
import { DragDropContext, Droppable, Draggable, DropResult } from "react-beautiful-dnd";
|
4
4
|
import { Tooltip } from '../Tooltip';
|
5
5
|
import { Button } from '../Button';
|
6
|
-
import { Dropdown } from '../Dropdown';
|
6
|
+
import { Dropdown, IMenuItem, ISubmenu, IMenuGroup } from '../Dropdown';
|
7
7
|
|
8
|
-
interface
|
9
|
-
start?: React.ReactNode;
|
10
|
-
center?: React.ReactNode;
|
11
|
-
end?: React.ReactNode;
|
12
|
-
action?: React.ReactNode;
|
13
|
-
addItem?: boolean;
|
14
|
-
itemsDropdown?: any;
|
15
|
-
dragAndDrop?: boolean;
|
16
|
-
onClick?(): void;
|
17
|
-
}
|
18
|
-
|
19
|
-
class TableListItem extends React.PureComponent<IPropsItem> {
|
20
|
-
render() {
|
21
|
-
return (
|
22
|
-
this.props.addItem ?
|
23
|
-
<li className='table-list__item-container'>
|
24
|
-
<div
|
25
|
-
onClick={this.props.onClick}
|
26
|
-
className={`table-list__item ${this.props.onClick && 'table-list__item--clickable'} ${this.props.dragAndDrop && 'table-list__item--draggable'}`}>
|
27
|
-
<div className='table-list__item-content'>
|
28
|
-
<div className='table-list__item-content-block'>
|
29
|
-
{this.props.start && this.props.start}
|
30
|
-
</div>
|
31
|
-
<div className='table-list__item-content-block table-list__item-content-block--center'>
|
32
|
-
{this.props.center && this.props.center}
|
33
|
-
</div>
|
34
|
-
<div className='table-list__item-content-block'>
|
35
|
-
{this.props.end && this.props.end}
|
36
|
-
</div>
|
37
|
-
</div>
|
38
|
-
{this.props.action && <div className='table-list__slide-in-actions'>
|
39
|
-
{this.props.action}
|
40
|
-
</div>}
|
41
|
-
</div>
|
42
|
-
<div className='table-list__add-bar-container'>
|
43
|
-
<Tooltip text='Add item' flow='top' appendToBody={true}>
|
44
|
-
<div className='table-list__add-bar'>
|
45
|
-
<Dropdown
|
46
|
-
items={this.props.itemsDropdown}>
|
47
|
-
<Button
|
48
|
-
type="primary"
|
49
|
-
icon="plus-large"
|
50
|
-
text="Add item"
|
51
|
-
size="small"
|
52
|
-
shape="round"
|
53
|
-
iconOnly={true}
|
54
|
-
onClick={() => false}
|
55
|
-
/>
|
56
|
-
</Dropdown>
|
57
|
-
</div>
|
58
|
-
</Tooltip>
|
59
|
-
</div>
|
60
|
-
</li>
|
61
|
-
: <li
|
62
|
-
className={`table-list__item ${this.props.onClick && 'table-list__item--clickable'} ${this.props.dragAndDrop && 'table-list__item--draggable'} table-list__item--margin`}
|
63
|
-
onClick={this.props.onClick}>
|
64
|
-
<div className='table-list__item-content'>
|
65
|
-
<div className='table-list__item-content-block'>
|
66
|
-
{this.props.start && this.props.start}
|
67
|
-
</div>
|
68
|
-
<div className='table-list__item-content-block table-list__item-content-block--center'>
|
69
|
-
{this.props.center && this.props.center}
|
70
|
-
</div>
|
71
|
-
<div className='table-list__item-content-block'>
|
72
|
-
{this.props.end && this.props.end}
|
73
|
-
</div>
|
74
|
-
</div>
|
75
|
-
{this.props.action && <div className='table-list__slide-in-actions'>
|
76
|
-
{this.props.action}
|
77
|
-
</div>}
|
78
|
-
</li>
|
79
|
-
);
|
80
|
-
}
|
81
|
-
}
|
82
|
-
|
83
|
-
interface IProps {
|
8
|
+
export interface IProps {
|
84
9
|
children?: React.ReactNode;
|
85
|
-
array
|
10
|
+
array: Array<IPropsArrayItem>;
|
86
11
|
addItem?: boolean;
|
87
12
|
dragAndDrop?: boolean;
|
88
|
-
itemsDropdown?:
|
13
|
+
itemsDropdown?: Array<IMenuItem | ISubmenu | IMenuGroup | 'divider'>;
|
89
14
|
className?: string;
|
90
|
-
|
15
|
+
onDrag?(start: number, end: number): void;
|
91
16
|
}
|
92
17
|
|
93
|
-
interface
|
18
|
+
export interface IPropsArrayItem {
|
94
19
|
start?: React.ReactNode;
|
95
20
|
center?: React.ReactNode;
|
96
21
|
end?: React.ReactNode;
|
97
22
|
action?: React.ReactNode;
|
23
|
+
onClick?(): void;
|
98
24
|
}
|
99
25
|
|
100
|
-
const reorder = (list
|
101
|
-
|
102
|
-
|
103
|
-
|
26
|
+
const reorder = (list: Array<IPropsArrayItem>, startIndex: number, endIndex: number) => {
|
27
|
+
const result = Array.from(list);
|
28
|
+
const [removed] = result.splice(startIndex, 1);
|
29
|
+
result.splice(endIndex, 0, removed);
|
104
30
|
|
105
|
-
|
31
|
+
return result;
|
106
32
|
};
|
107
33
|
|
108
|
-
class TableList extends React.PureComponent<IProps, {items:
|
109
|
-
constructor(props) {
|
34
|
+
class TableList extends React.PureComponent<IProps, { items: Array<IPropsArrayItem>}> {
|
35
|
+
constructor(props: Readonly<IProps>) {
|
110
36
|
super(props);
|
111
37
|
this.state = {
|
112
|
-
|
38
|
+
items: [],
|
113
39
|
};
|
114
40
|
|
115
41
|
this.onDragEnd = this.onDragEnd.bind(this);
|
116
42
|
}
|
117
43
|
|
118
44
|
componentDidMount(): void {
|
119
|
-
this.setState({items: this.props.array});
|
45
|
+
this.setState({ items: this.props.array });
|
120
46
|
}
|
121
47
|
|
122
|
-
componentDidUpdate(prevProps: Readonly<IProps
|
48
|
+
componentDidUpdate(prevProps: Readonly<IProps>): void {
|
123
49
|
if (prevProps.array !== this.props.array) {
|
124
50
|
this.setState({
|
125
51
|
items: this.props.array,
|
@@ -127,7 +53,7 @@ class TableList extends React.PureComponent<IProps, {items: any}> {
|
|
127
53
|
}
|
128
54
|
}
|
129
55
|
|
130
|
-
onDragEnd(result) {
|
56
|
+
onDragEnd(result: DropResult) {
|
131
57
|
if (!result.destination) {
|
132
58
|
return;
|
133
59
|
}
|
@@ -139,66 +65,144 @@ class TableList extends React.PureComponent<IProps, {items: any}> {
|
|
139
65
|
this.setState({
|
140
66
|
items,
|
141
67
|
});
|
68
|
+
|
69
|
+
return this.props.onDrag ?
|
70
|
+
this.props.onDrag(result.source.index, result.destination.index) : null;
|
142
71
|
}
|
143
72
|
|
144
73
|
render() {
|
145
74
|
let classes = classNames({
|
146
|
-
'table-list'
|
75
|
+
'table-list': !this.props.addItem,
|
147
76
|
[`${this.props.className}`]: this.props.className,
|
148
77
|
});
|
149
78
|
|
150
79
|
return (
|
151
80
|
this.props.array ?
|
152
81
|
this.props.dragAndDrop ?
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
82
|
+
<DragDropContext onDragEnd={this.onDragEnd}>
|
83
|
+
<Droppable droppableId="droppable">
|
84
|
+
{(provided, _snapshot) => (
|
85
|
+
<ul
|
86
|
+
className={classes}
|
87
|
+
ref={provided.innerRef}
|
88
|
+
{...provided.droppableProps} >
|
89
|
+
{this.state.items.map((item: IPropsArrayItem, index: number) => (
|
90
|
+
<Draggable key={index} draggableId={`${index}`} index={index}>
|
91
|
+
{(provided2, _snapshot2) => (
|
92
|
+
<div
|
93
|
+
ref={provided2.innerRef}
|
94
|
+
{...provided2.draggableProps}
|
95
|
+
{...provided2.dragHandleProps} >
|
96
|
+
<TableListItem
|
97
|
+
dragAndDrop={this.props.dragAndDrop}
|
98
|
+
start={item.start}
|
99
|
+
center={item.center}
|
100
|
+
end={item.end}
|
101
|
+
action={item.action}
|
102
|
+
onClick={item.onClick ? item.onClick : undefined}
|
103
|
+
addItem={this.props.addItem}
|
104
|
+
itemsDropdown={this.props.itemsDropdown} />
|
105
|
+
</div>
|
106
|
+
)}
|
107
|
+
</Draggable>
|
108
|
+
))}
|
109
|
+
{provided.placeholder}
|
110
|
+
</ul>
|
111
|
+
)}
|
112
|
+
</Droppable>
|
113
|
+
</DragDropContext>
|
114
|
+
: <ul className={classes}>
|
115
|
+
{this.state.items.map((item: IPropsArrayItem, index: number) => (
|
116
|
+
<TableListItem
|
117
|
+
key={index}
|
118
|
+
start={item.start}
|
119
|
+
center={item.center}
|
120
|
+
end={item.end}
|
121
|
+
action={item.action}
|
122
|
+
onClick={item.onClick ? item.onClick : undefined}
|
123
|
+
addItem={this.props.addItem}
|
124
|
+
itemsDropdown={this.props.itemsDropdown} />
|
125
|
+
))}
|
126
|
+
</ul>
|
127
|
+
: this.props.children &&
|
128
|
+
<ul className={classes}>
|
129
|
+
{this.props.children}
|
197
130
|
</ul>
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
131
|
+
);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
export interface IPropsItem {
|
136
|
+
start?: React.ReactNode;
|
137
|
+
center?: React.ReactNode;
|
138
|
+
end?: React.ReactNode;
|
139
|
+
action?: React.ReactNode;
|
140
|
+
addItem?: boolean;
|
141
|
+
itemsDropdown?: any;
|
142
|
+
dragAndDrop?: boolean;
|
143
|
+
onClick?(): void;
|
144
|
+
}
|
145
|
+
|
146
|
+
class TableListItem extends React.PureComponent<IPropsItem> {
|
147
|
+
render() {
|
148
|
+
return (
|
149
|
+
this.props.addItem ?
|
150
|
+
<li className='table-list__item-container'>
|
151
|
+
<div
|
152
|
+
onClick={this.props.onClick}
|
153
|
+
className={`table-list__item ${this.props.onClick && 'table-list__item--clickable'} ${this.props.dragAndDrop && 'table-list__item--draggable'}`}>
|
154
|
+
<div className='table-list__item-content'>
|
155
|
+
<div className='table-list__item-content-block'>
|
156
|
+
{this.props.start && this.props.start}
|
157
|
+
</div>
|
158
|
+
<div className='table-list__item-content-block table-list__item-content-block--center'>
|
159
|
+
{this.props.center && this.props.center}
|
160
|
+
</div>
|
161
|
+
<div className='table-list__item-content-block'>
|
162
|
+
{this.props.end && this.props.end}
|
163
|
+
</div>
|
164
|
+
</div>
|
165
|
+
{this.props.action && <div className='table-list__slide-in-actions'>
|
166
|
+
{this.props.action}
|
167
|
+
</div>}
|
168
|
+
</div>
|
169
|
+
<div className='table-list__add-bar-container'>
|
170
|
+
<Tooltip text='Add item' flow='top' appendToBody={true}>
|
171
|
+
<div className='table-list__add-bar'>
|
172
|
+
<Dropdown
|
173
|
+
items={this.props.itemsDropdown}>
|
174
|
+
<Button
|
175
|
+
type="primary"
|
176
|
+
icon="plus-large"
|
177
|
+
text="Add item"
|
178
|
+
size="small"
|
179
|
+
shape="round"
|
180
|
+
iconOnly={true}
|
181
|
+
onClick={() => false}
|
182
|
+
/>
|
183
|
+
</Dropdown>
|
184
|
+
</div>
|
185
|
+
</Tooltip>
|
186
|
+
</div>
|
187
|
+
</li>
|
188
|
+
: <li
|
189
|
+
className={`table-list__item ${this.props.onClick && 'table-list__item--clickable'} ${this.props.dragAndDrop && 'table-list__item--draggable'} table-list__item--margin`}
|
190
|
+
onClick={this.props.onClick}>
|
191
|
+
<div className='table-list__item-content'>
|
192
|
+
<div className='table-list__item-content-block'>
|
193
|
+
{this.props.start && this.props.start}
|
194
|
+
</div>
|
195
|
+
<div className='table-list__item-content-block table-list__item-content-block--center'>
|
196
|
+
{this.props.center && this.props.center}
|
197
|
+
</div>
|
198
|
+
<div className='table-list__item-content-block'>
|
199
|
+
{this.props.end && this.props.end}
|
200
|
+
</div>
|
201
|
+
</div>
|
202
|
+
{this.props.action && <div className='table-list__slide-in-actions'>
|
203
|
+
{this.props.action}
|
204
|
+
</div>}
|
205
|
+
</li>
|
202
206
|
);
|
203
207
|
}
|
204
208
|
}
|
@@ -8,7 +8,7 @@ interface IProps {
|
|
8
8
|
placeholder: string;
|
9
9
|
focused?: boolean;
|
10
10
|
boxed?: boolean;
|
11
|
-
onSubmit?(): void;
|
11
|
+
onSubmit?(value: string | number): void;
|
12
12
|
}
|
13
13
|
|
14
14
|
interface IState {
|
@@ -16,6 +16,7 @@ interface IState {
|
|
16
16
|
type: string;
|
17
17
|
focused: boolean;
|
18
18
|
boxed?: boolean;
|
19
|
+
keyDown?: boolean;
|
19
20
|
}
|
20
21
|
|
21
22
|
export class SearchBar extends React.PureComponent<IProps, IState> {
|
@@ -27,6 +28,7 @@ export class SearchBar extends React.PureComponent<IProps, IState> {
|
|
27
28
|
focused: this.props.focused ? this.props.focused : false,
|
28
29
|
type: this.props.type ? this.props.type : 'expanded',
|
29
30
|
boxed: this.props.boxed ? this.props.boxed : false,
|
31
|
+
keyDown: false,
|
30
32
|
};
|
31
33
|
this.inputRef = React.createRef();
|
32
34
|
}
|
@@ -57,20 +59,37 @@ export class SearchBar extends React.PureComponent<IProps, IState> {
|
|
57
59
|
<label className="sd-searchbar__icon"></label>
|
58
60
|
<input id="search-input"
|
59
61
|
ref={(input: any) => (input && this.props.focused) && input.focus()}
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
className="sd-searchbar__input"
|
63
|
+
type="text"
|
64
|
+
placeholder={this.props.placeholder}
|
65
|
+
value={this.state.inputValue}
|
66
|
+
onKeyPress={(event) => {
|
67
|
+
if (event.key === 'Enter') {
|
68
|
+
if (this.props.onSubmit) {
|
69
|
+
this.props.onSubmit(this.state.inputValue);
|
70
|
+
}
|
71
|
+
this.setState({keyDown: true});
|
72
|
+
}
|
73
|
+
}}
|
74
|
+
onKeyUp={(event) => {
|
75
|
+
if (event.key === 'Enter') {
|
76
|
+
this.setState({keyDown: false});
|
77
|
+
}
|
78
|
+
}}
|
79
|
+
onChange={(event) => this.setState({inputValue: event.target.value})}
|
80
|
+
onFocus={() => this.setState({focused: true})} />
|
66
81
|
{this.state.inputValue &&
|
67
82
|
<button className="sd-searchbar__cancel" onClick={() => this.setState({inputValue: ''})}>
|
68
83
|
<Icon name='remove-sign' />
|
69
84
|
</button>}
|
70
85
|
<button
|
71
86
|
id="sd-searchbar__search-btn"
|
72
|
-
className=
|
73
|
-
|
87
|
+
className={`sd-searchbar__search-btn ${this.state.keyDown ? 'sd-searchbar__search-btn--active' : ''}`}
|
88
|
+
onClick={() => {
|
89
|
+
if (this.props.onSubmit) {
|
90
|
+
this.props.onSubmit(this.state.inputValue);
|
91
|
+
}
|
92
|
+
}}>
|
74
93
|
<Icon name='chevron-right-thin' />
|
75
94
|
</button>
|
76
95
|
</div>
|
package/app-typescript/index.ts
CHANGED
@@ -18,6 +18,7 @@ export { IconButton } from './components/IconButton';
|
|
18
18
|
export { IconLabel } from './components/IconLabel';
|
19
19
|
export { Tooltip } from './components/Tooltip';
|
20
20
|
export { DurationInput } from './components/DurationInput';
|
21
|
+
export { getDurationString } from './components/DurationInput';
|
21
22
|
export { DatePicker } from './components/DatePicker';
|
22
23
|
export { DatePickerISO } from './components/DatePicker';
|
23
24
|
export { DatePickerLocaleSettings } from './components/DatePicker';
|
@@ -87,6 +88,7 @@ export { Time } from './components/Text/Time';
|
|
87
88
|
export { Heading } from './components/Text/Heading';
|
88
89
|
export { BottomNav } from './components/Navigation/BottomNav';
|
89
90
|
export { TreeSelect } from './components/TreeSelect';
|
91
|
+
export { TableList, TableListItem } from './components/Lists/TableList';
|
90
92
|
export { ContentListItem } from './components/Lists/ContentList';
|
91
93
|
|
92
94
|
// declare non-typescript exports to prevent errors
|