react-ui-basics 0.0.175 → 0.0.178
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/Animated.js.map +1 -1
- package/AutocompleteSelect.js.map +1 -1
- package/Button.js.map +1 -1
- package/CalendarMonthView.css +20 -0
- package/CalendarMonthView.d.ts +12 -0
- package/CalendarMonthView.js +52 -0
- package/CalendarMonthView.js.map +1 -0
- package/Checkbox.js.map +1 -1
- package/CircleProgress.js.map +1 -1
- package/CommonFields.js.map +1 -1
- package/DNDContainer.js.map +1 -1
- package/DNDDraggable.js.map +1 -1
- package/DNDDroppable.js.map +1 -1
- package/DatePicker.css +93 -0
- package/DatePicker.d.ts +32 -0
- package/DatePicker.js +116 -0
- package/DatePicker.js.map +1 -0
- package/DateTools.d.ts +39 -0
- package/DateTools.js +73 -0
- package/DateTools.js.map +1 -0
- package/Dialog.js.map +1 -1
- package/DropFileInput.js.map +1 -1
- package/DroppableHorizontalList.js.map +1 -1
- package/DroppableList.js.map +1 -1
- package/Dropzone.js.map +1 -1
- package/FilteredList.js.map +1 -1
- package/FloatingActionButton.js.map +1 -1
- package/FormUploadProgress.js.map +1 -1
- package/ImageGallery.js.map +1 -1
- package/MaterialIcon.js.map +1 -1
- package/Modal.js.map +1 -1
- package/ModalMenu.js.map +1 -1
- package/ReactConstants.js.map +1 -1
- package/ReactCreateElement.js.map +1 -1
- package/ReadyListener.js.map +1 -1
- package/Scrollable.js.map +1 -1
- package/ScrollableTable.js.map +1 -1
- package/Size.js.map +1 -1
- package/Snackbar.js.map +1 -1
- package/SpinningProgress.js.map +1 -1
- package/Switch.js.map +1 -1
- package/Table.js.map +1 -1
- package/Tabs.css +65 -0
- package/Tabs.d.ts +22 -0
- package/TextField.js.map +1 -1
- package/Tools.d.ts +2 -2
- package/Tools.js.map +1 -1
- package/bundle.css +726 -587
- package/index.js +4 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/router/HistoryTools.js.map +1 -1
- package/router/Link.js.map +1 -1
- package/router/NavLink.js.map +1 -1
- package/router/Route.js.map +1 -1
- package/router/index.js.map +1 -1
- package/src/Animated.css +7 -0
- package/src/Animated.js +219 -0
- package/src/Animated.scss +8 -0
- package/src/AutocompleteSelect.css +256 -0
- package/src/AutocompleteSelect.js +473 -0
- package/src/AutocompleteSelect.scss +322 -0
- package/src/Button.css +138 -0
- package/src/Button.js +104 -0
- package/src/Button.scss +177 -0
- package/src/CalendarMonthView.css +20 -0
- package/src/CalendarMonthView.scss +25 -0
- package/src/CalendarMonthView.tsx +80 -0
- package/src/Checkbox.css +56 -0
- package/src/Checkbox.js +52 -0
- package/src/Checkbox.scss +87 -0
- package/src/CircleProgress.css +11 -0
- package/src/CircleProgress.js +38 -0
- package/src/CircleProgress.scss +13 -0
- package/src/CommonFields.js +21 -0
- package/src/DNDContainer.css +26 -0
- package/src/DNDContainer.js +263 -0
- package/src/DNDContainer.scss +33 -0
- package/src/DNDDraggable.js +55 -0
- package/src/DNDDroppable.js +58 -0
- package/src/DatePicker.css +93 -0
- package/src/DatePicker.scss +118 -0
- package/src/DatePicker.tsx +179 -0
- package/src/DateTools.ts +85 -0
- package/src/Dialog.css +36 -0
- package/src/Dialog.js +160 -0
- package/src/Dialog.scss +42 -0
- package/src/DropFileInput.css +24 -0
- package/src/DropFileInput.js +45 -0
- package/src/DropFileInput.scss +28 -0
- package/src/DroppableHorizontalList.js +190 -0
- package/src/DroppableList.css +14 -0
- package/src/DroppableList.js +201 -0
- package/src/DroppableList.scss +27 -0
- package/src/Dropzone.css +54 -0
- package/src/Dropzone.js +140 -0
- package/src/Dropzone.scss +66 -0
- package/src/FilteredList.css +68 -0
- package/src/FilteredList.js +196 -0
- package/src/FilteredList.scss +86 -0
- package/src/FloatingActionButton.css +20 -0
- package/src/FloatingActionButton.js +35 -0
- package/src/FloatingActionButton.scss +25 -0
- package/src/FormUploadProgress.css +61 -0
- package/src/FormUploadProgress.js +87 -0
- package/src/FormUploadProgress.scss +78 -0
- package/src/ImageGallery.css +196 -0
- package/src/ImageGallery.js +935 -0
- package/src/ImageGallery.scss +256 -0
- package/src/MaterialIcon.js +1837 -0
- package/src/Modal.css +61 -0
- package/src/Modal.js +160 -0
- package/src/Modal.scss +73 -0
- package/src/ModalMenu.css +30 -0
- package/src/ModalMenu.js +59 -0
- package/src/ModalMenu.scss +36 -0
- package/src/ReactConstants.ts +42 -0
- package/src/ReactCreateElement.js +5 -0
- package/src/ReadyListener.js +53 -0
- package/src/ResizeObserver.ts +50 -0
- package/src/Scrollable.css +80 -0
- package/src/Scrollable.js +388 -0
- package/src/Scrollable.scss +100 -0
- package/src/ScrollableTable.css +6 -0
- package/src/ScrollableTable.scss +12 -0
- package/src/ScrollableTable.tsx +39 -0
- package/src/Size.js +56 -0
- package/src/Snackbar.css +40 -0
- package/src/Snackbar.js +71 -0
- package/src/Snackbar.scss +47 -0
- package/src/SpinningProgress.css +49 -0
- package/src/SpinningProgress.js +19 -0
- package/src/SpinningProgress.scss +57 -0
- package/src/Switch.css +69 -0
- package/src/Switch.js +54 -0
- package/src/Switch.scss +73 -0
- package/src/Table.css +94 -0
- package/src/Table.scss +121 -0
- package/src/Table.tsx +360 -0
- package/src/Tabs.css +65 -0
- package/src/Tabs.scss +77 -0
- package/src/Tabs.tsx +63 -0
- package/src/TextField.css +122 -0
- package/src/TextField.js +162 -0
- package/src/TextField.scss +160 -0
- package/src/Tools.test.js +105 -0
- package/src/Tools.ts +231 -0
- package/src/global.css +1 -0
- package/src/global.scss +6 -0
- package/src/index.js +84 -0
- package/src/router/HistoryTools.js +32 -0
- package/src/router/Link.js +27 -0
- package/src/router/NavLink.js +25 -0
- package/src/router/README.md +55 -0
- package/src/router/Route.js +209 -0
- package/src/router/Route.test.js +139 -0
- package/src/router/index.js +14 -0
- package/src/store/ProxyTools.js +91 -0
- package/src/store/ProxyTools.test.js +97 -0
- package/src/store/Store.ts +91 -0
- package/store/ProxyTools.js.map +1 -1
- package/store/Store.js.map +1 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './DatePicker.css'
|
|
3
|
+
import TextField from "./TextField";
|
|
4
|
+
import * as DateTools from "./DateTools";
|
|
5
|
+
import {orNoop, classNames, preventDefault} from "./Tools";
|
|
6
|
+
import Button from './Button'
|
|
7
|
+
import CalendarMonthView from "./CalendarMonthView";
|
|
8
|
+
import MaterialIcon from "./MaterialIcon";
|
|
9
|
+
import {DateExtended} from "./DateTools";
|
|
10
|
+
|
|
11
|
+
const DayRenderer = ({day, selected, minDate, onClick}: {
|
|
12
|
+
day: DateExtended,
|
|
13
|
+
selected: Date,
|
|
14
|
+
minDate: Date,
|
|
15
|
+
onClick: (day: Date) => void
|
|
16
|
+
}) =>
|
|
17
|
+
<span
|
|
18
|
+
className={classNames('value',
|
|
19
|
+
minDate && (day.isBefore(minDate) && !day.isSameDate(minDate)) && 'inactive',
|
|
20
|
+
selected && day.isSameDate(selected) && 'selected',
|
|
21
|
+
)}
|
|
22
|
+
onClick={e => {
|
|
23
|
+
preventDefault(e);
|
|
24
|
+
if (minDate && (day.isBefore(minDate) && !day.isSameDate(minDate))) return;
|
|
25
|
+
|
|
26
|
+
onClick(day);
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
{DateTools.get(day, DateTools.TimeUnit.DAY)}
|
|
30
|
+
</span>;
|
|
31
|
+
|
|
32
|
+
export interface DatePickerProps {
|
|
33
|
+
id?: number | string
|
|
34
|
+
name?: string
|
|
35
|
+
value: Date
|
|
36
|
+
minDate?: Date
|
|
37
|
+
formatter: (date: Date) => string
|
|
38
|
+
parser: (date: string) => Date
|
|
39
|
+
onChange: (e) => void
|
|
40
|
+
dayOfWeekToString: (day: number) => string | JSX.Element
|
|
41
|
+
monthToString: (day: number) => string | JSX.Element
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface DatePickerState {
|
|
45
|
+
focused: boolean,
|
|
46
|
+
value: Date,
|
|
47
|
+
selectedMonth: DateExtended,
|
|
48
|
+
text: string,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
class DatePicker extends React.Component<DatePickerProps, DatePickerState> {
|
|
52
|
+
private el: HTMLDivElement;
|
|
53
|
+
private listener: (e) => void;
|
|
54
|
+
|
|
55
|
+
constructor(props: DatePickerProps) {
|
|
56
|
+
super(props);
|
|
57
|
+
const date = props.value || new Date();
|
|
58
|
+
this.state = {
|
|
59
|
+
focused: false,
|
|
60
|
+
value: date,
|
|
61
|
+
text: props.formatter(date),
|
|
62
|
+
selectedMonth: DateTools.dateOf(date).resetTime().set(1, DateTools.TimeUnit.DAY),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
67
|
+
if (this.props.value !== prevProps.value)
|
|
68
|
+
this.setState({
|
|
69
|
+
value: this.props.value,
|
|
70
|
+
selectedMonth: DateTools.dateOf(this.props.value).resetTime().set(1, DateTools.TimeUnit.DAY),
|
|
71
|
+
text: this.props.formatter(this.props.value)
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
componentDidMount() {
|
|
76
|
+
document.addEventListener('mousedown', this.listener = (e) => {
|
|
77
|
+
if (this.state.focused && !this.el.contains(e.target))
|
|
78
|
+
this.setState({focused: false});
|
|
79
|
+
})
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
componentWillUnmount() {
|
|
83
|
+
document.removeEventListener('mousedown', this.listener)
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
shouldComponentUpdate(nextProps, nextState, nextContext) {
|
|
87
|
+
if (!DateTools.equals(this.props.value, nextProps.value))
|
|
88
|
+
return true;
|
|
89
|
+
|
|
90
|
+
if (!DateTools.equals(this.state.value, nextState.value))
|
|
91
|
+
return true;
|
|
92
|
+
|
|
93
|
+
if (this.state.text !== nextState.text)
|
|
94
|
+
return true;
|
|
95
|
+
|
|
96
|
+
if (this.state.focused !== nextState.focused)
|
|
97
|
+
return true;
|
|
98
|
+
|
|
99
|
+
if (this.state.selectedMonth !== nextState.selectedMonth)
|
|
100
|
+
return true;
|
|
101
|
+
|
|
102
|
+
if (!DateTools.equals(this.props.minDate, nextProps.minDate))
|
|
103
|
+
return true;
|
|
104
|
+
|
|
105
|
+
return false;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
render() {
|
|
109
|
+
const {minDate, formatter, parser, dayOfWeekToString, monthToString} = this.props;
|
|
110
|
+
const {value, text, focused, selectedMonth} = this.state;
|
|
111
|
+
|
|
112
|
+
return <div className={`DatePicker`} ref={el => this.el = el}>
|
|
113
|
+
<TextField id={'value'} value={text}
|
|
114
|
+
autoComplete="off"
|
|
115
|
+
onFocus={() => this.setState({focused: true})}
|
|
116
|
+
onChange={e => {
|
|
117
|
+
const text = e.target.value;
|
|
118
|
+
try {
|
|
119
|
+
const date = parser(text);
|
|
120
|
+
if (date instanceof Date && !Number.isNaN(date.getTime())) {
|
|
121
|
+
if (date && value.getTime() !== date.getTime())
|
|
122
|
+
this.onChange(date);
|
|
123
|
+
}
|
|
124
|
+
this.setState({text})
|
|
125
|
+
} catch (ignored) {
|
|
126
|
+
}
|
|
127
|
+
}}
|
|
128
|
+
onKeyDown={e => {
|
|
129
|
+
if ((e.keyCode === 27/*esc*/ || e.keyCode === 13/*enter*/) && focused) {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
this.setState({text: formatter(value), focused: false});
|
|
132
|
+
}
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
<div className={`calendar ${focused && 'focused'}`}>
|
|
136
|
+
<div className={'row monthSelect'}>
|
|
137
|
+
<span>
|
|
138
|
+
{monthToString(selectedMonth.get(DateTools.TimeUnit.MONTH))}
|
|
139
|
+
{selectedMonth.get(DateTools.TimeUnit.YEAR)}
|
|
140
|
+
</span>
|
|
141
|
+
<Button flat={true} round={true} disabled={minDate && DateTools.dateOf(selectedMonth).isBefore(minDate)} onClick={() => {
|
|
142
|
+
this.setState({selectedMonth: DateTools.dateOf(selectedMonth).subtract(1, DateTools.TimeUnit.MONTH)})
|
|
143
|
+
}}>
|
|
144
|
+
<MaterialIcon icon={'chevron_left'}/>
|
|
145
|
+
</Button>
|
|
146
|
+
<Button flat={true} round={true} onClick={() => {
|
|
147
|
+
this.setState({selectedMonth: DateTools.dateOf(selectedMonth).add(1, DateTools.TimeUnit.MONTH)})
|
|
148
|
+
}}>
|
|
149
|
+
<MaterialIcon icon={'chevron_right'}/>
|
|
150
|
+
</Button>
|
|
151
|
+
</div>
|
|
152
|
+
<CalendarMonthView monthOf={selectedMonth}
|
|
153
|
+
dayOfWeekToString={dayOfWeekToString}
|
|
154
|
+
dayRenderer={(date) => <DayRenderer
|
|
155
|
+
day={DateTools.dateOf(date)}
|
|
156
|
+
selected={value}
|
|
157
|
+
minDate={minDate}
|
|
158
|
+
onClick={value => {
|
|
159
|
+
this.onChange(value)
|
|
160
|
+
this.setState({focused: false, text: formatter(value)});
|
|
161
|
+
}}
|
|
162
|
+
/>}/>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
onChange = (value: Date) => {
|
|
168
|
+
this.setState({value});
|
|
169
|
+
orNoop(this.props.onChange)({
|
|
170
|
+
target: {
|
|
171
|
+
id: this.props.id,
|
|
172
|
+
name: this.props.name,
|
|
173
|
+
value,
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default DatePicker;
|
package/src/DateTools.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export const resetTime = (date: Date) => {
|
|
2
|
+
date.setHours(0, 0, 0, 0);
|
|
3
|
+
return date
|
|
4
|
+
};
|
|
5
|
+
export const timeOf = (date: Date) => date.getTime();
|
|
6
|
+
export const equals = (a: Date, b: Date) => a && b && timeOf(a) === timeOf(b);
|
|
7
|
+
export const isBefore = (a: Date, b: Date) => a && b && timeOf(a) < timeOf(b);
|
|
8
|
+
export const isAfter = (a: Date, b: Date) => a && b && timeOf(a) > timeOf(b);
|
|
9
|
+
export const max = (a: Date, b: Date) => {
|
|
10
|
+
if (!b) return a;
|
|
11
|
+
if (!a) return b;
|
|
12
|
+
return timeOf(a) > timeOf(b) ? a : b;
|
|
13
|
+
};
|
|
14
|
+
export const min = (a: Date, b: Date) => {
|
|
15
|
+
if (!b) return a;
|
|
16
|
+
if (!a) return b;
|
|
17
|
+
return timeOf(a) < timeOf(b) ? a : b;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export class TimeUnit {
|
|
21
|
+
static MILLISECOND = new TimeUnit('Milliseconds');
|
|
22
|
+
static SECOND = new TimeUnit('Seconds');
|
|
23
|
+
static MINUTE = new TimeUnit('Minutes');
|
|
24
|
+
static HOUR = new TimeUnit('Hours');
|
|
25
|
+
static DAY = new TimeUnit('Date');
|
|
26
|
+
static MONTH = new TimeUnit('Month');
|
|
27
|
+
static YEAR = new TimeUnit('FullYear');
|
|
28
|
+
set: (date: Date, value: number) => void;
|
|
29
|
+
get: (date: Date) => number;
|
|
30
|
+
|
|
31
|
+
constructor(field) {
|
|
32
|
+
const getter = 'get' + field;
|
|
33
|
+
const setter = 'set' + field;
|
|
34
|
+
// this.getter = getter;
|
|
35
|
+
// this.setter = setter;
|
|
36
|
+
this.toString = () => field;
|
|
37
|
+
this.get = (date) => date[getter]();
|
|
38
|
+
this.set = (date, value) => date[setter](value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const get = (date: Date, timeUnit: TimeUnit) => timeUnit.get(date);
|
|
44
|
+
export const set = (date: Date, value: number, timeUnit: TimeUnit): Date => {
|
|
45
|
+
timeUnit.set(date, value);
|
|
46
|
+
return date;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const add = (date: Date, amount: number, timeUnit: TimeUnit): Date => {
|
|
50
|
+
timeUnit.set(date, timeUnit.get(date) + amount);
|
|
51
|
+
return date;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const subtract = (date: Date, amount: number, timeUnit: TimeUnit): Date => add(date, -amount, timeUnit);
|
|
55
|
+
|
|
56
|
+
export interface DateExtended extends Date {
|
|
57
|
+
get: (timeUnit: TimeUnit) => number;
|
|
58
|
+
set: (value: number, timeUnit: TimeUnit) => DateExtended;
|
|
59
|
+
add: (amount: number, timeUnit: TimeUnit) => DateExtended;
|
|
60
|
+
subtract: (amount: number, timeUnit: TimeUnit) => DateExtended;
|
|
61
|
+
isBefore: (after: Date) => boolean;
|
|
62
|
+
isAfter: (before: Date) => boolean;
|
|
63
|
+
isSameDate: (another: Date) => boolean;
|
|
64
|
+
equals: (another: Date) => boolean;
|
|
65
|
+
resetTime: () => DateExtended;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const extend = (date:Date):DateExtended => {
|
|
69
|
+
const d = date as DateExtended
|
|
70
|
+
d.get = (timeUnit) => get(date, timeUnit);
|
|
71
|
+
d.set = (value, timeUnit) => set(date, value, timeUnit) as DateExtended;
|
|
72
|
+
d.add = (amount, timeUnit) => add(date, amount, timeUnit) as DateExtended;
|
|
73
|
+
d.subtract = (amount, timeUnit) => subtract(date, amount, timeUnit) as DateExtended;
|
|
74
|
+
d.isBefore = (after) => isBefore(date, after);
|
|
75
|
+
d.isAfter = (before) => isAfter(date, before);
|
|
76
|
+
d.isSameDate = (another) => isSameDay(date, another);
|
|
77
|
+
d.equals = (another) => equals(date, another);
|
|
78
|
+
d.resetTime = () => resetTime(date) as DateExtended;
|
|
79
|
+
return d;
|
|
80
|
+
};
|
|
81
|
+
export const dateOf = (date?: string | Date): DateExtended => extend(date ? new Date(date) : new Date());
|
|
82
|
+
export const now = dateOf;
|
|
83
|
+
export const copy = dateOf;
|
|
84
|
+
|
|
85
|
+
export const isSameDay = (dateA: Date, dateB: Date) => dateA.getDate() === dateB.getDate() && dateA.getMonth() === dateB.getMonth() && dateA.getFullYear() === dateB.getFullYear();
|
package/src/Dialog.css
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.DialogModal {
|
|
2
|
+
overflow: hidden;
|
|
3
|
+
}
|
|
4
|
+
.DialogModal .content {
|
|
5
|
+
top: 20vh;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.Dialog {
|
|
9
|
+
background-color: white;
|
|
10
|
+
min-width: 460px;
|
|
11
|
+
max-width: 40vw;
|
|
12
|
+
padding: 15px;
|
|
13
|
+
}
|
|
14
|
+
.Dialog .title {
|
|
15
|
+
margin-bottom: 15px;
|
|
16
|
+
padding: 20px 50px 0px 30px;
|
|
17
|
+
font-size: 1.25rem;
|
|
18
|
+
line-height: 2rem;
|
|
19
|
+
font-weight: 400;
|
|
20
|
+
letter-spacing: 0.0125em;
|
|
21
|
+
}
|
|
22
|
+
.Dialog .description {
|
|
23
|
+
color: rgba(0, 0, 0, 0.54);
|
|
24
|
+
font-size: 1rem;
|
|
25
|
+
line-height: 1.5rem;
|
|
26
|
+
font-weight: 400;
|
|
27
|
+
letter-spacing: 0.03125em;
|
|
28
|
+
margin-top: 20px;
|
|
29
|
+
padding: 0 24px 24px;
|
|
30
|
+
}
|
|
31
|
+
.Dialog > div.row {
|
|
32
|
+
margin-bottom: 15px;
|
|
33
|
+
}
|
|
34
|
+
.Dialog > div.row:last-child {
|
|
35
|
+
margin-bottom: 0;
|
|
36
|
+
}
|
package/src/Dialog.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import ReactConstants from "./../ReactConstants";
|
|
2
|
+
import {clientHeight as __clientHeight, clientWidth as __clientWidth, createAccessor as __createAccessor, data as __data, height as __height, left as __left, length as __length, pageX as __pageX, pageY as __pageY, props as __props, scrollLeft as __scrollLeft, scrollTop as __scrollTop, state as __state, style as __style, target as __target, top as __top, value as __value, width as __width} from "./../CommonFields";
|
|
3
|
+
import React, {Component} from 'react';
|
|
4
|
+
import {toConsumableArray as __toConsumableArray} from "./../_virtual/_rollupPluginBabelHelpers";
|
|
5
|
+
import {extends as __extends} from "./../_virtual/_rollupPluginBabelHelpers";
|
|
6
|
+
import {inherits as __inherits} from "./../_virtual/_rollupPluginBabelHelpers";
|
|
7
|
+
import './Dialog.css';
|
|
8
|
+
import ReactCreateElement from './ReactCreateElement';
|
|
9
|
+
import './Dialog.css'
|
|
10
|
+
import Button from "./Button";
|
|
11
|
+
import Modal from "./Modal";
|
|
12
|
+
import {isUndefined, orNoop, preventDefault, ref, UNDEFINED, classNames, createRef} from "./Tools";
|
|
13
|
+
import {PureComponent, render, componentDidMount, propsGetter, stateGSs} from "./ReactConstants";
|
|
14
|
+
import PropTypes from "prop-types";
|
|
15
|
+
|
|
16
|
+
class Dialog extends PureComponent {
|
|
17
|
+
constructor(properties) {
|
|
18
|
+
super(properties);
|
|
19
|
+
|
|
20
|
+
this[ReactConstants[3]] = () => {
|
|
21
|
+
const {title, description, accept, cancel, onAccept, onCancel, children} = __props(this);
|
|
22
|
+
return <div className="Dialog">
|
|
23
|
+
{title && <div className="title">{title}</div>}
|
|
24
|
+
{description && <div className="description">{description}</div>}
|
|
25
|
+
{children}
|
|
26
|
+
<div className="row right">
|
|
27
|
+
{cancel && <Button flat={true} onClick={onCancel}>{cancel}</Button>}
|
|
28
|
+
{accept && <Button flat={true} onClick={onAccept}>{accept}</Button>}
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Dialog.defaultProps = {
|
|
36
|
+
accept: 'Accept',
|
|
37
|
+
cancel: 'Decline',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const throwIfPropExists = (key, props) => {
|
|
41
|
+
if (props[key]) throw Error(key + " was already set by props")
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
class DialogWrapper extends Component {
|
|
45
|
+
|
|
46
|
+
constructor(properties) {
|
|
47
|
+
super(properties);
|
|
48
|
+
const that = this;
|
|
49
|
+
that.state = {};
|
|
50
|
+
|
|
51
|
+
const props = propsGetter(that);
|
|
52
|
+
const openRef = createRef();
|
|
53
|
+
const closeRef = createRef();
|
|
54
|
+
|
|
55
|
+
const [titleState,
|
|
56
|
+
descriptionState,
|
|
57
|
+
onAcceptState,
|
|
58
|
+
onCancelState,
|
|
59
|
+
acceptState,
|
|
60
|
+
cancelState
|
|
61
|
+
] = stateGSs(that, 6);
|
|
62
|
+
|
|
63
|
+
const onCancel = (e) => {
|
|
64
|
+
preventDefault(e);
|
|
65
|
+
orNoop(props().onCancel || onCancelState())();
|
|
66
|
+
closeRef()();
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const onAccept = (e) => {
|
|
70
|
+
preventDefault(e);
|
|
71
|
+
orNoop(props().onAccept || onAcceptState())();
|
|
72
|
+
closeRef()();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
that[ReactConstants[3]] = () => {
|
|
76
|
+
const {top, className, ...other} = props();
|
|
77
|
+
return (
|
|
78
|
+
<Modal
|
|
79
|
+
top={top}
|
|
80
|
+
className={classNames('DialogModal', className)}
|
|
81
|
+
open={openRef}
|
|
82
|
+
close={closeRef}
|
|
83
|
+
onClose={onCancel}
|
|
84
|
+
>
|
|
85
|
+
<Dialog title={titleState()} description={descriptionState()} accept={acceptState()} cancel={cancelState()} {...other} onAccept={onAccept} onCancel={onCancel}/>
|
|
86
|
+
</Modal>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
that.open = (onAccept, onCancel, title, description, accept, cancel) => {
|
|
91
|
+
titleState(UNDEFINED);
|
|
92
|
+
descriptionState(UNDEFINED);
|
|
93
|
+
onAcceptState(UNDEFINED);
|
|
94
|
+
onCancelState(UNDEFINED);
|
|
95
|
+
acceptState(UNDEFINED);
|
|
96
|
+
cancelState(UNDEFINED);
|
|
97
|
+
|
|
98
|
+
const _props = props();
|
|
99
|
+
if (!isUndefined(onAccept)) {
|
|
100
|
+
throwIfPropExists("onAccept", _props);
|
|
101
|
+
onAcceptState(onAccept);
|
|
102
|
+
}
|
|
103
|
+
if (!isUndefined(onCancel)) {
|
|
104
|
+
throwIfPropExists("onCancel", _props);
|
|
105
|
+
onCancelState(onCancel);
|
|
106
|
+
}
|
|
107
|
+
if (!isUndefined(title)) {
|
|
108
|
+
throwIfPropExists("title", _props);
|
|
109
|
+
titleState(title);
|
|
110
|
+
}
|
|
111
|
+
if (!isUndefined(description)) {
|
|
112
|
+
throwIfPropExists("description", _props);
|
|
113
|
+
descriptionState(description);
|
|
114
|
+
}
|
|
115
|
+
if (!isUndefined(accept)) {
|
|
116
|
+
throwIfPropExists("accept", _props);
|
|
117
|
+
acceptState(accept);
|
|
118
|
+
}
|
|
119
|
+
if (!isUndefined(cancel)) {
|
|
120
|
+
throwIfPropExists("cancel", _props);
|
|
121
|
+
cancelState(cancel);
|
|
122
|
+
}
|
|
123
|
+
openRef()();
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
that[ReactConstants[0]] = () => {
|
|
127
|
+
const _props = props();
|
|
128
|
+
orNoop(_props.open)(that.open);
|
|
129
|
+
orNoop(_props.close)(closeRef());
|
|
130
|
+
_props.show && that.open();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export default DialogWrapper;
|
|
136
|
+
|
|
137
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
138
|
+
DialogWrapper.propTypes = {
|
|
139
|
+
title: PropTypes.oneOfType([
|
|
140
|
+
PropTypes.string,
|
|
141
|
+
PropTypes.element
|
|
142
|
+
]),
|
|
143
|
+
description: PropTypes.oneOfType([
|
|
144
|
+
PropTypes.string,
|
|
145
|
+
PropTypes.element
|
|
146
|
+
]),
|
|
147
|
+
accept: PropTypes.oneOfType([
|
|
148
|
+
PropTypes.string,
|
|
149
|
+
PropTypes.element
|
|
150
|
+
]),
|
|
151
|
+
cancel: PropTypes.oneOfType([
|
|
152
|
+
PropTypes.string,
|
|
153
|
+
PropTypes.element
|
|
154
|
+
]),
|
|
155
|
+
onAccept: PropTypes.func,
|
|
156
|
+
onCancel: PropTypes.func,
|
|
157
|
+
[ReactConstants[5]]: PropTypes.string,
|
|
158
|
+
top: PropTypes.number,
|
|
159
|
+
};
|
|
160
|
+
}
|
package/src/Dialog.scss
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.DialogModal {
|
|
2
|
+
overflow: hidden;
|
|
3
|
+
|
|
4
|
+
.content {
|
|
5
|
+
top: 20vh;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.Dialog {
|
|
10
|
+
background-color: white;
|
|
11
|
+
min-width: 460px;
|
|
12
|
+
max-width: 40vw;
|
|
13
|
+
padding: 15px;
|
|
14
|
+
|
|
15
|
+
.title {
|
|
16
|
+
margin-bottom: 15px;
|
|
17
|
+
padding: 20px 50px 0px 30px;
|
|
18
|
+
font-size: 1.25rem;
|
|
19
|
+
line-height: 2rem;
|
|
20
|
+
font-weight: 400;
|
|
21
|
+
letter-spacing: .0125em;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.description {
|
|
25
|
+
color: rgba(0, 0, 0, .54);
|
|
26
|
+
font-size: 1rem;
|
|
27
|
+
line-height: 1.5rem;
|
|
28
|
+
font-weight: 400;
|
|
29
|
+
letter-spacing: .03125em;
|
|
30
|
+
margin-top: 20px;
|
|
31
|
+
padding: 0 24px 24px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
> div.row {
|
|
36
|
+
margin-bottom: 15px;
|
|
37
|
+
|
|
38
|
+
&:last-child {
|
|
39
|
+
margin-bottom: 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.DropFileInput {
|
|
2
|
+
flex-grow: 1;
|
|
3
|
+
}
|
|
4
|
+
.DropFileInput .Dropzone {
|
|
5
|
+
border: 1px dashed #808080;
|
|
6
|
+
padding: 12px;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-flow: row nowrap;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
align-items: center;
|
|
11
|
+
color: gray;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
border-radius: 3px;
|
|
14
|
+
font-weight: normal;
|
|
15
|
+
line-height: 22px;
|
|
16
|
+
font-size: 14px;
|
|
17
|
+
color: #7E7E7E;
|
|
18
|
+
max-width: 100%;
|
|
19
|
+
word-break: break-all;
|
|
20
|
+
word-break: break-word;
|
|
21
|
+
}
|
|
22
|
+
.DropFileInput .Dropzone .icon.withText {
|
|
23
|
+
margin-right: 10px;
|
|
24
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import ReactConstants from "./../ReactConstants";
|
|
2
|
+
import {clientHeight as __clientHeight, clientWidth as __clientWidth, createAccessor as __createAccessor, data as __data, height as __height, left as __left, length as __length, pageX as __pageX, pageY as __pageY, props as __props, scrollLeft as __scrollLeft, scrollTop as __scrollTop, state as __state, style as __style, target as __target, top as __top, value as __value, width as __width} from "./../CommonFields";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import {toConsumableArray as __toConsumableArray} from "./../_virtual/_rollupPluginBabelHelpers";
|
|
5
|
+
import {extends as __extends} from "./../_virtual/_rollupPluginBabelHelpers";
|
|
6
|
+
import {inherits as __inherits} from "./../_virtual/_rollupPluginBabelHelpers";
|
|
7
|
+
import './DropFileInput.css';
|
|
8
|
+
import ReactCreateElement from './ReactCreateElement';
|
|
9
|
+
import './DropFileInput.css'
|
|
10
|
+
import Dropzone from "./Dropzone";
|
|
11
|
+
import PropTypes from "prop-types";
|
|
12
|
+
import {classNames} from "./Tools";
|
|
13
|
+
import MaterialIcon from "./MaterialIcon";
|
|
14
|
+
|
|
15
|
+
const DropFileInput = ({icon, label, onDrop, droppable, multiple, accept}) => (
|
|
16
|
+
<section className="DropFileInput">
|
|
17
|
+
<Dropzone droppable={droppable} onDrop={onDrop} accept={accept} multiple={multiple}>
|
|
18
|
+
<MaterialIcon className={classNames(`icon`, label && 'withText')} icon={icon}/>
|
|
19
|
+
{label && <div>{label}</div>}
|
|
20
|
+
</Dropzone>
|
|
21
|
+
</section>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
DropFileInput.defaultProps = {
|
|
25
|
+
icon: 'cloud_upload',
|
|
26
|
+
droppable: false,
|
|
27
|
+
multiple: true,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
31
|
+
DropFileInput.propTypes = {
|
|
32
|
+
icon: MaterialIcon.propTypes.icon,
|
|
33
|
+
label: PropTypes.oneOfType([
|
|
34
|
+
PropTypes.string,
|
|
35
|
+
PropTypes.element
|
|
36
|
+
]),
|
|
37
|
+
droppable: PropTypes.bool,
|
|
38
|
+
onDrop: PropTypes.func,
|
|
39
|
+
multiple: PropTypes.bool,
|
|
40
|
+
accept: PropTypes.string,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
export default DropFileInput;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.DropFileInput {
|
|
2
|
+
flex-grow: 1;
|
|
3
|
+
|
|
4
|
+
.Dropzone {
|
|
5
|
+
border: 1px dashed #808080;
|
|
6
|
+
padding: 12px;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-flow: row nowrap;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
align-items: center;
|
|
11
|
+
color: gray;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
border-radius: 3px;
|
|
14
|
+
|
|
15
|
+
font-weight: normal;
|
|
16
|
+
line-height: 22px;
|
|
17
|
+
font-size: 14px;
|
|
18
|
+
|
|
19
|
+
color: #7E7E7E;
|
|
20
|
+
max-width: 100%;
|
|
21
|
+
word-break: break-all;
|
|
22
|
+
word-break: break-word;
|
|
23
|
+
|
|
24
|
+
.icon.withText {
|
|
25
|
+
margin-right: 10px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|