@reactivers/generic-ui 0.1.0
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/.babelrc +3 -0
- package/README.md +36 -0
- package/dist/bundle.css +1 -0
- package/dist/index.cjs.js +1566 -0
- package/dist/index.esm.js +1510 -0
- package/package.json +68 -0
- package/rollup.config.js +36 -0
- package/src/components/Badge/index.js +19 -0
- package/src/components/Button/index.js +63 -0
- package/src/components/Card/index.js +51 -0
- package/src/components/ColorPicker/index.js +44 -0
- package/src/components/EmptyResult/index.js +30 -0
- package/src/components/FadeAnimation/index.js +35 -0
- package/src/components/Form/index.js +25 -0
- package/src/components/Grid/index.js +1 -0
- package/src/components/Header/index.js +20 -0
- package/src/components/Image/index.js +63 -0
- package/src/components/IncDecField/index.js +35 -0
- package/src/components/InfiniteScroll/index.js +150 -0
- package/src/components/ListItem/index.js +81 -0
- package/src/components/Mapper/index.js +12 -0
- package/src/components/Modal/index.js +87 -0
- package/src/components/Notification/index.js +69 -0
- package/src/components/OverflowImages/index.js +38 -0
- package/src/components/Popover/index.js +109 -0
- package/src/components/Rate/index.js +33 -0
- package/src/components/Section/index.js +26 -0
- package/src/components/Selectfield/index.js +63 -0
- package/src/components/Show/index.js +15 -0
- package/src/components/Tag/index.js +67 -0
- package/src/components/TextListField/index.js +85 -0
- package/src/components/Textfield/index.js +51 -0
- package/src/components/ThreeDot/index.js +22 -0
- package/src/components/Upload/index.js +14 -0
- package/src/css/index.css +110 -0
- package/src/index.js +32 -0
- package/src/utils/styles.js +116 -0
@@ -0,0 +1,1510 @@
|
|
1
|
+
import React$1, { useEffect, useCallback, useRef, useState, cloneElement, forwardRef, useImperativeHandle, useMemo } from 'react';
|
2
|
+
import { coalasce, takeIf, isNullOrUndefined, useApi, generatedColorFromString, changeColor } from '@reactivers/use-utils';
|
3
|
+
import { SwatchesPicker } from 'react-color';
|
4
|
+
import { Field as Field$1 } from 'rc-field-form';
|
5
|
+
export { default as Form, useForm } from 'rc-field-form';
|
6
|
+
import { Col } from 'react-flexbox-grid';
|
7
|
+
export { Col, Grid, Row } from 'react-flexbox-grid';
|
8
|
+
import { createPortal } from 'react-dom';
|
9
|
+
import 'rc-notification/assets/index.css';
|
10
|
+
import Notification from 'rc-notification';
|
11
|
+
import UUpload from 'rc-upload';
|
12
|
+
|
13
|
+
const Badge = props => {
|
14
|
+
const {
|
15
|
+
title,
|
16
|
+
children
|
17
|
+
} = props;
|
18
|
+
return /*#__PURE__*/React$1.createElement("div", {
|
19
|
+
style: {
|
20
|
+
position: 'relative'
|
21
|
+
}
|
22
|
+
}, /*#__PURE__*/React$1.createElement("div", {
|
23
|
+
style: {
|
24
|
+
position: 'absolute',
|
25
|
+
right: 0,
|
26
|
+
top: 0,
|
27
|
+
borderRadius: 10,
|
28
|
+
backgroundColor: '#eee'
|
29
|
+
}
|
30
|
+
}, title), children);
|
31
|
+
};
|
32
|
+
|
33
|
+
const appStyles = {
|
34
|
+
stretchRow: {
|
35
|
+
display: 'flex',
|
36
|
+
alignItems: 'stretch',
|
37
|
+
flexFlow: 'row wrap'
|
38
|
+
},
|
39
|
+
defaultShadow: {
|
40
|
+
boxShadow: "0 0 5px -2.75px black"
|
41
|
+
},
|
42
|
+
cardBorderRadius: {
|
43
|
+
borderBottomLeftRadius: 20,
|
44
|
+
borderTopRightRadius: 20,
|
45
|
+
borderBottomRightRadius: 20
|
46
|
+
},
|
47
|
+
borderBottom: {
|
48
|
+
borderBottomWidth: 1,
|
49
|
+
borderBottomColor: '#eee'
|
50
|
+
},
|
51
|
+
center: {
|
52
|
+
display: "flex",
|
53
|
+
justifyContent: "center",
|
54
|
+
alignItems: 'center',
|
55
|
+
flexShrink: 0
|
56
|
+
},
|
57
|
+
centerInColumn: {
|
58
|
+
display: "flex",
|
59
|
+
justifyContent: "center",
|
60
|
+
alignItems: 'center',
|
61
|
+
flexDirection: 'column'
|
62
|
+
},
|
63
|
+
secondaryText: {
|
64
|
+
color: '#aaa'
|
65
|
+
},
|
66
|
+
imageStyle: {
|
67
|
+
height: "100%",
|
68
|
+
width: '100%',
|
69
|
+
borderRadius: 20,
|
70
|
+
resizeMode: 'contain'
|
71
|
+
},
|
72
|
+
listHeader: {
|
73
|
+
fontSize: 18,
|
74
|
+
fontWeight: 'bold'
|
75
|
+
},
|
76
|
+
spreadHorizontally: {
|
77
|
+
display: 'flex',
|
78
|
+
flexDirection: 'row',
|
79
|
+
justifyContent: 'space-between',
|
80
|
+
alignItems: 'center'
|
81
|
+
},
|
82
|
+
paddingHorizontal: value => ({
|
83
|
+
paddingLeft: value,
|
84
|
+
paddingRight: value
|
85
|
+
}),
|
86
|
+
paddingVertical: value => ({
|
87
|
+
paddingTop: value,
|
88
|
+
paddingBottom: value
|
89
|
+
}),
|
90
|
+
marginHorizontal: value => ({
|
91
|
+
marginLeft: value,
|
92
|
+
marginRight: value
|
93
|
+
}),
|
94
|
+
marginVertical: value => ({
|
95
|
+
marginTop: value,
|
96
|
+
marginBottom: value
|
97
|
+
}),
|
98
|
+
row: {
|
99
|
+
display: 'flex',
|
100
|
+
flexDirection: 'row'
|
101
|
+
},
|
102
|
+
card: {
|
103
|
+
backgroundColor: 'white'
|
104
|
+
},
|
105
|
+
grid: {
|
106
|
+
display: 'flex',
|
107
|
+
flexDirection: 'row',
|
108
|
+
flexWrap: 'wrap',
|
109
|
+
flexShrink: 'initial'
|
110
|
+
},
|
111
|
+
cardTitle: {
|
112
|
+
fontSize: 24,
|
113
|
+
fontWeight: 'bold',
|
114
|
+
color: 'black'
|
115
|
+
},
|
116
|
+
cardSubtitle: {
|
117
|
+
marginTop: 8,
|
118
|
+
marginBottom: 8,
|
119
|
+
fontSize: 14,
|
120
|
+
fontWeight: '300'
|
121
|
+
},
|
122
|
+
rounded: size => ({
|
123
|
+
width: size,
|
124
|
+
height: size,
|
125
|
+
borderRadius: size * 2
|
126
|
+
}),
|
127
|
+
roundedImage: {
|
128
|
+
width: '100%',
|
129
|
+
objectFit: "cover",
|
130
|
+
borderRadius: "50%"
|
131
|
+
},
|
132
|
+
threeDot: {
|
133
|
+
whiteSpace: 'nowrap',
|
134
|
+
width: '100%',
|
135
|
+
display: 'inline-block',
|
136
|
+
textOverflow: 'ellipsis',
|
137
|
+
overflow: 'hidden'
|
138
|
+
},
|
139
|
+
toolTip: {
|
140
|
+
backgroundColor: 'rgba(0,0,0,0.7)',
|
141
|
+
color: 'white',
|
142
|
+
padding: "2px 6px",
|
143
|
+
borderRadius: 10
|
144
|
+
}
|
145
|
+
};
|
146
|
+
|
147
|
+
const Show = props => {
|
148
|
+
const {
|
149
|
+
condition,
|
150
|
+
willUnmount,
|
151
|
+
children
|
152
|
+
} = props;
|
153
|
+
useEffect(() => {
|
154
|
+
return willUnmount;
|
155
|
+
}, [willUnmount]);
|
156
|
+
if (condition) return children;
|
157
|
+
return null;
|
158
|
+
};
|
159
|
+
|
160
|
+
const Button = props => {
|
161
|
+
const {
|
162
|
+
style,
|
163
|
+
icon,
|
164
|
+
title,
|
165
|
+
className: _className,
|
166
|
+
iconSize: _iconSize,
|
167
|
+
onClick: _onClick,
|
168
|
+
htmlType: _htmlType,
|
169
|
+
children
|
170
|
+
} = props;
|
171
|
+
const iconSize = coalasce(_iconSize, 32);
|
172
|
+
const htmlType = coalasce(_htmlType, "button");
|
173
|
+
const iconButton = !children && !title;
|
174
|
+
let className = `no-select `;
|
175
|
+
const onClick = useCallback(e => {
|
176
|
+
if (htmlType !== 'submit') e.preventDefault();
|
177
|
+
if (_onClick) _onClick(e);
|
178
|
+
}, [htmlType, _onClick]);
|
179
|
+
if (_className) className += ` ${_className || ""}`;
|
180
|
+
return /*#__PURE__*/React.createElement("button", {
|
181
|
+
style: {
|
182
|
+
justifyContent: 'center',
|
183
|
+
alignItems: 'center',
|
184
|
+
width: takeIf(iconButton, iconSize),
|
185
|
+
minWidth: takeIf(iconButton, iconSize),
|
186
|
+
height: takeIf(iconButton, iconSize),
|
187
|
+
minHeight: takeIf(iconButton, iconSize),
|
188
|
+
borderRadius: takeIf(iconButton, "50%"),
|
189
|
+
...(style || {})
|
190
|
+
},
|
191
|
+
type: htmlType,
|
192
|
+
onClick: onClick,
|
193
|
+
className: className
|
194
|
+
}, /*#__PURE__*/React.createElement(Show, {
|
195
|
+
condition: icon
|
196
|
+
}, /*#__PURE__*/React.createElement("div", {
|
197
|
+
style: {
|
198
|
+
marginRight: takeIf(!iconButton, 8),
|
199
|
+
fontSize: takeIf(iconButton, 18, 12),
|
200
|
+
width: takeIf(iconButton, "100%", 12),
|
201
|
+
height: takeIf(iconButton, "100%", 12),
|
202
|
+
...appStyles.center
|
203
|
+
}
|
204
|
+
}, icon)), /*#__PURE__*/React.createElement("div", null, children || title));
|
205
|
+
};
|
206
|
+
|
207
|
+
const ListItem = props => {
|
208
|
+
const {
|
209
|
+
style,
|
210
|
+
avatar,
|
211
|
+
title,
|
212
|
+
lastItem,
|
213
|
+
titleRenderer,
|
214
|
+
description,
|
215
|
+
className,
|
216
|
+
titleStyle,
|
217
|
+
subtitleStyle,
|
218
|
+
titleContainerStyle,
|
219
|
+
onClick,
|
220
|
+
onTitleClick,
|
221
|
+
subtitle,
|
222
|
+
subtitleRenderer,
|
223
|
+
headerContainerStyle,
|
224
|
+
avatarContainerStyle,
|
225
|
+
selected,
|
226
|
+
children
|
227
|
+
} = props;
|
228
|
+
const borderBottom = takeIf(lastItem, '1px solid #eee');
|
229
|
+
const titleContainerClassName = takeIf(onTitleClick, "clickable", "");
|
230
|
+
return /*#__PURE__*/React.createElement("div", {
|
231
|
+
style: {
|
232
|
+
borderBottom,
|
233
|
+
padding: 4,
|
234
|
+
...(style || {})
|
235
|
+
},
|
236
|
+
className: className,
|
237
|
+
onClick: onClick
|
238
|
+
}, /*#__PURE__*/React.createElement("div", {
|
239
|
+
style: {
|
240
|
+
display: "flex",
|
241
|
+
alignItems: 'center',
|
242
|
+
...(headerContainerStyle || {})
|
243
|
+
}
|
244
|
+
}, /*#__PURE__*/React.createElement(Show, {
|
245
|
+
condition: avatar
|
246
|
+
}, /*#__PURE__*/React.createElement("div", {
|
247
|
+
style: {
|
248
|
+
display: 'flex',
|
249
|
+
justifyContent: 'center',
|
250
|
+
marginRight: takeIf(!!title || !!titleRenderer, 8, 0),
|
251
|
+
...(avatarContainerStyle || {})
|
252
|
+
}
|
253
|
+
}, avatar)), /*#__PURE__*/React.createElement("div", {
|
254
|
+
style: {
|
255
|
+
width: '100%',
|
256
|
+
padding: 4,
|
257
|
+
...(titleContainerStyle || {})
|
258
|
+
},
|
259
|
+
onClick: onTitleClick,
|
260
|
+
className: titleContainerClassName
|
261
|
+
}, /*#__PURE__*/React.createElement(Show, {
|
262
|
+
condition: titleRenderer
|
263
|
+
}, titleRenderer), /*#__PURE__*/React.createElement(Show, {
|
264
|
+
condition: title
|
265
|
+
}, /*#__PURE__*/React.createElement("div", {
|
266
|
+
style: {
|
267
|
+
margin: 0,
|
268
|
+
color: takeIf(selected, "#1890ff"),
|
269
|
+
...(titleStyle || {})
|
270
|
+
}
|
271
|
+
}, title)), /*#__PURE__*/React.createElement(Show, {
|
272
|
+
condition: subtitle
|
273
|
+
}, /*#__PURE__*/React.createElement("div", {
|
274
|
+
style: {
|
275
|
+
margin: 0,
|
276
|
+
fontSize: 10,
|
277
|
+
color: 'black',
|
278
|
+
...(subtitleStyle || {})
|
279
|
+
}
|
280
|
+
}, subtitle)), /*#__PURE__*/React.createElement(Show, {
|
281
|
+
condition: subtitleRenderer
|
282
|
+
}, subtitleRenderer)), /*#__PURE__*/React.createElement(Show, {
|
283
|
+
condition: description
|
284
|
+
}, description)), children);
|
285
|
+
};
|
286
|
+
|
287
|
+
const Card = props => {
|
288
|
+
const {
|
289
|
+
style,
|
290
|
+
avatar,
|
291
|
+
title,
|
292
|
+
titleRenderer,
|
293
|
+
titleStyle,
|
294
|
+
headerStyle,
|
295
|
+
titleContainerStyle,
|
296
|
+
description,
|
297
|
+
onHeaderClick,
|
298
|
+
subtitle,
|
299
|
+
onTitleClick,
|
300
|
+
className,
|
301
|
+
cardStyle,
|
302
|
+
childrenContainerStyle,
|
303
|
+
children
|
304
|
+
} = props;
|
305
|
+
return /*#__PURE__*/React$1.createElement("div", {
|
306
|
+
style: {
|
307
|
+
borderRadius: 10,
|
308
|
+
padding: 16,
|
309
|
+
...(style || {})
|
310
|
+
},
|
311
|
+
className: className
|
312
|
+
}, /*#__PURE__*/React$1.createElement(Show, {
|
313
|
+
condition: avatar || title || titleRenderer || description || subtitle
|
314
|
+
}, /*#__PURE__*/React$1.createElement(ListItem, {
|
315
|
+
avatar: avatar,
|
316
|
+
title: title,
|
317
|
+
titleRenderer: titleRenderer,
|
318
|
+
style: {
|
319
|
+
margin: 0,
|
320
|
+
padding: 0,
|
321
|
+
...(titleContainerStyle || {})
|
322
|
+
},
|
323
|
+
titleContainerStyle: headerStyle,
|
324
|
+
titleStyle: {
|
325
|
+
fontSize: 18,
|
326
|
+
...(titleStyle || {})
|
327
|
+
},
|
328
|
+
description: description,
|
329
|
+
subtitle: subtitle,
|
330
|
+
onTitleClick: onTitleClick,
|
331
|
+
onClick: onHeaderClick
|
332
|
+
})), /*#__PURE__*/React$1.createElement(Show, {
|
333
|
+
condition: children
|
334
|
+
}, /*#__PURE__*/React$1.createElement("div", {
|
335
|
+
style: { ...appStyles.card,
|
336
|
+
...(cardStyle || {})
|
337
|
+
}
|
338
|
+
}, /*#__PURE__*/React$1.createElement("div", {
|
339
|
+
style: { ...(childrenContainerStyle || {})
|
340
|
+
}
|
341
|
+
}, children))));
|
342
|
+
};
|
343
|
+
|
344
|
+
const styles = {
|
345
|
+
popover: {
|
346
|
+
position: 'absolute',
|
347
|
+
zIndex: '2'
|
348
|
+
},
|
349
|
+
cover: {
|
350
|
+
position: 'fixed',
|
351
|
+
top: '0px',
|
352
|
+
right: '0px',
|
353
|
+
bottom: '0px',
|
354
|
+
left: '0px',
|
355
|
+
zIndex: 1
|
356
|
+
}
|
357
|
+
};
|
358
|
+
|
359
|
+
const Popover = props => {
|
360
|
+
const {
|
361
|
+
overlay,
|
362
|
+
trigger: _trigger,
|
363
|
+
alignment: _alignment,
|
364
|
+
children
|
365
|
+
} = props;
|
366
|
+
const trigger = coalasce(_trigger, "click");
|
367
|
+
const alignment = coalasce(_alignment, "bottom");
|
368
|
+
const target = useRef(null);
|
369
|
+
const [displayColorPicker, setDisplayColorPicker] = useState(false);
|
370
|
+
const [position, setPosition] = useState({});
|
371
|
+
const showPopover = useCallback(() => {
|
372
|
+
setDisplayColorPicker(true);
|
373
|
+
|
374
|
+
if (target.current) {
|
375
|
+
const {
|
376
|
+
left,
|
377
|
+
top,
|
378
|
+
bottom,
|
379
|
+
right,
|
380
|
+
height
|
381
|
+
} = target.current.getBoundingClientRect() || {};
|
382
|
+
|
383
|
+
switch (alignment) {
|
384
|
+
case "bottom":
|
385
|
+
setPosition({
|
386
|
+
left,
|
387
|
+
top: bottom
|
388
|
+
});
|
389
|
+
break;
|
390
|
+
|
391
|
+
case "top":
|
392
|
+
setPosition({
|
393
|
+
left,
|
394
|
+
bottom: top
|
395
|
+
});
|
396
|
+
break;
|
397
|
+
|
398
|
+
case "left":
|
399
|
+
setPosition({
|
400
|
+
right: left,
|
401
|
+
top: top
|
402
|
+
});
|
403
|
+
break;
|
404
|
+
|
405
|
+
case "right":
|
406
|
+
setPosition({
|
407
|
+
left: right,
|
408
|
+
top: top
|
409
|
+
});
|
410
|
+
break;
|
411
|
+
}
|
412
|
+
}
|
413
|
+
}, [target]);
|
414
|
+
const showPopoverClick = useCallback(e => {
|
415
|
+
if (trigger === "click") showPopover();
|
416
|
+
}, [showPopover, trigger]);
|
417
|
+
const showPopoverMouseEnter = useCallback(e => {
|
418
|
+
if (trigger === "mouse") showPopover();
|
419
|
+
}, [showPopover, trigger]);
|
420
|
+
const stopPropagation = useCallback(e => {
|
421
|
+
e.stopPropagation();
|
422
|
+
}, []);
|
423
|
+
const closePopover = useCallback(() => {
|
424
|
+
setDisplayColorPicker(false);
|
425
|
+
}, []);
|
426
|
+
const closePopoverClick = useCallback(() => {
|
427
|
+
if (trigger === "click") closePopover();
|
428
|
+
}, [target, closePopover]);
|
429
|
+
const closePopoverMouseEnter = useCallback(() => {
|
430
|
+
if (trigger === "mouse") closePopover();
|
431
|
+
}, [target, closePopover]);
|
432
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
433
|
+
onClick: showPopoverClick,
|
434
|
+
onMouseEnter: showPopoverMouseEnter,
|
435
|
+
ref: target
|
436
|
+
}, children), /*#__PURE__*/React.createElement(Show, {
|
437
|
+
condition: displayColorPicker
|
438
|
+
}, /*#__PURE__*/React.createElement("div", {
|
439
|
+
style: styles.cover,
|
440
|
+
onClick: closePopoverClick,
|
441
|
+
onMouseEnter: closePopoverMouseEnter
|
442
|
+
}, /*#__PURE__*/React.createElement("div", {
|
443
|
+
style: { ...styles.popover,
|
444
|
+
...position
|
445
|
+
},
|
446
|
+
onClick: stopPropagation,
|
447
|
+
onMouseEnter: stopPropagation
|
448
|
+
}, overlay))));
|
449
|
+
};
|
450
|
+
|
451
|
+
const ColorPicker = props => {
|
452
|
+
const {
|
453
|
+
label,
|
454
|
+
value: _value,
|
455
|
+
onChange: _onChange,
|
456
|
+
title,
|
457
|
+
inputClassName,
|
458
|
+
colorClassName,
|
459
|
+
children
|
460
|
+
} = props;
|
461
|
+
const onChange = useCallback(_ref => {
|
462
|
+
let {
|
463
|
+
hex
|
464
|
+
} = _ref;
|
465
|
+
|
466
|
+
_onChange(hex);
|
467
|
+
}, [_onChange]);
|
468
|
+
return /*#__PURE__*/React$1.createElement(Popover, {
|
469
|
+
overlay: /*#__PURE__*/React$1.createElement("div", {
|
470
|
+
style: {
|
471
|
+
backgroundColor: 'white',
|
472
|
+
padding: 16
|
473
|
+
}
|
474
|
+
}, /*#__PURE__*/React$1.createElement("h3", null, title || "Renk"), /*#__PURE__*/React$1.createElement(SwatchesPicker, {
|
475
|
+
onChange: onChange
|
476
|
+
}))
|
477
|
+
}, /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement(Show, {
|
478
|
+
condition: children
|
479
|
+
}, children), /*#__PURE__*/React$1.createElement(Show, {
|
480
|
+
condition: !children
|
481
|
+
}, /*#__PURE__*/React$1.createElement("div", {
|
482
|
+
className: inputClassName
|
483
|
+
}, /*#__PURE__*/React$1.createElement("p", {
|
484
|
+
style: {
|
485
|
+
fontWeight: 500
|
486
|
+
}
|
487
|
+
}, label), /*#__PURE__*/React$1.createElement("div", {
|
488
|
+
className: colorClassName,
|
489
|
+
style: {
|
490
|
+
backgroundColor: _value,
|
491
|
+
height: 32,
|
492
|
+
width: '100%'
|
493
|
+
}
|
494
|
+
})))));
|
495
|
+
};
|
496
|
+
|
497
|
+
const EmptyResult = props => {
|
498
|
+
const {
|
499
|
+
icon,
|
500
|
+
title,
|
501
|
+
style,
|
502
|
+
iconClassName,
|
503
|
+
size: _size
|
504
|
+
} = props;
|
505
|
+
const size = _size || 120;
|
506
|
+
return /*#__PURE__*/React$1.createElement("div", {
|
507
|
+
style: { ...(style || {})
|
508
|
+
}
|
509
|
+
}, /*#__PURE__*/React$1.createElement("div", {
|
510
|
+
style: {
|
511
|
+
width: '100%',
|
512
|
+
...appStyles.centerInColumn
|
513
|
+
}
|
514
|
+
}, /*#__PURE__*/React$1.createElement("div", {
|
515
|
+
className: iconClassName,
|
516
|
+
style: { ...appStyles.center,
|
517
|
+
...appStyles.rounded(size)
|
518
|
+
}
|
519
|
+
}, icon)), /*#__PURE__*/React$1.createElement("div", null, /*#__PURE__*/React$1.createElement("p", {
|
520
|
+
style: {
|
521
|
+
textAlign: 'center',
|
522
|
+
fontWeight: '100',
|
523
|
+
fontSize: 24,
|
524
|
+
whiteSpace: 'pre-wrap',
|
525
|
+
color: 'black',
|
526
|
+
marginTop: 16
|
527
|
+
}
|
528
|
+
}, title)));
|
529
|
+
};
|
530
|
+
|
531
|
+
const FadeAnimation = props => {
|
532
|
+
const {
|
533
|
+
style,
|
534
|
+
type: _type,
|
535
|
+
duration: _duration,
|
536
|
+
delay: _delay,
|
537
|
+
onAnimationComplete,
|
538
|
+
children
|
539
|
+
} = props;
|
540
|
+
const duration = _duration || 100;
|
541
|
+
const delay = _delay || 0;
|
542
|
+
const type = _type || "in";
|
543
|
+
const [opacity, setOpacity] = useState(type === "in" ? 0 : 1);
|
544
|
+
const toValue = type === "in" ? 1 : 0;
|
545
|
+
useEffect(() => {
|
546
|
+
if (opacity === toValue && onAnimationComplete) {
|
547
|
+
setTimeout(() => {
|
548
|
+
onAnimationComplete();
|
549
|
+
}, duration + delay);
|
550
|
+
}
|
551
|
+
}, [opacity]);
|
552
|
+
useEffect(() => {
|
553
|
+
if (type === "in") {
|
554
|
+
setOpacity(toValue);
|
555
|
+
} else {
|
556
|
+
setOpacity(toValue);
|
557
|
+
}
|
558
|
+
}, [type]);
|
559
|
+
return /*#__PURE__*/React$1.createElement("div", {
|
560
|
+
style: {
|
561
|
+
opacity: opacity,
|
562
|
+
transition: `${duration}`,
|
563
|
+
transitionDelay: delay,
|
564
|
+
...(style || {})
|
565
|
+
}
|
566
|
+
}, children);
|
567
|
+
};
|
568
|
+
|
569
|
+
const Field = props => {
|
570
|
+
const {
|
571
|
+
style,
|
572
|
+
name,
|
573
|
+
children
|
574
|
+
} = props;
|
575
|
+
return /*#__PURE__*/React.createElement("div", {
|
576
|
+
style: {
|
577
|
+
width: '100%',
|
578
|
+
margin: '16px 0',
|
579
|
+
...(style || {})
|
580
|
+
}
|
581
|
+
}, /*#__PURE__*/React.createElement(FieldOrChildren, {
|
582
|
+
name: name,
|
583
|
+
parentProps: props
|
584
|
+
}, children));
|
585
|
+
};
|
586
|
+
|
587
|
+
const FieldOrChildren = props => {
|
588
|
+
const {
|
589
|
+
name,
|
590
|
+
parentProps,
|
591
|
+
children
|
592
|
+
} = props;
|
593
|
+
|
594
|
+
if (isNullOrUndefined(name)) {
|
595
|
+
return children;
|
596
|
+
}
|
597
|
+
|
598
|
+
return /*#__PURE__*/React.createElement(Field$1, parentProps);
|
599
|
+
};
|
600
|
+
|
601
|
+
const Header = props => {
|
602
|
+
const {
|
603
|
+
title,
|
604
|
+
titleRenderer,
|
605
|
+
style,
|
606
|
+
titleStyle,
|
607
|
+
rightContent
|
608
|
+
} = props;
|
609
|
+
return /*#__PURE__*/React$1.createElement("div", {
|
610
|
+
style: { ...appStyles.row,
|
611
|
+
alignItems: 'center',
|
612
|
+
minHeight: 48,
|
613
|
+
...(style || {})
|
614
|
+
}
|
615
|
+
}, /*#__PURE__*/React$1.createElement("div", {
|
616
|
+
style: {
|
617
|
+
flex: 1,
|
618
|
+
...(titleStyle || {})
|
619
|
+
}
|
620
|
+
}, /*#__PURE__*/React$1.createElement(Show, {
|
621
|
+
condition: titleRenderer
|
622
|
+
}, /*#__PURE__*/React$1.createElement("div", {
|
623
|
+
style: {
|
624
|
+
margin: 0,
|
625
|
+
...appStyles.cardTitle
|
626
|
+
}
|
627
|
+
}, title))), rightContent);
|
628
|
+
};
|
629
|
+
|
630
|
+
function _extends() {
|
631
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
632
|
+
for (var i = 1; i < arguments.length; i++) {
|
633
|
+
var source = arguments[i];
|
634
|
+
|
635
|
+
for (var key in source) {
|
636
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
637
|
+
target[key] = source[key];
|
638
|
+
}
|
639
|
+
}
|
640
|
+
}
|
641
|
+
|
642
|
+
return target;
|
643
|
+
};
|
644
|
+
return _extends.apply(this, arguments);
|
645
|
+
}
|
646
|
+
|
647
|
+
const Image = props => {
|
648
|
+
const {
|
649
|
+
style,
|
650
|
+
className,
|
651
|
+
hidePlaceholder,
|
652
|
+
src,
|
653
|
+
alt,
|
654
|
+
onLoad: _onLoad,
|
655
|
+
placeholder: _placheholder,
|
656
|
+
size: _size,
|
657
|
+
...rest
|
658
|
+
} = props;
|
659
|
+
const [loaded, setLoaded] = useState(false);
|
660
|
+
const size = takeIf(_size, {
|
661
|
+
width: _size,
|
662
|
+
height: _size,
|
663
|
+
borderRadius: '50%'
|
664
|
+
}, {});
|
665
|
+
const placeholder = coalasce(_placheholder, "P");
|
666
|
+
const fontSize = takeIf(isNaN(_size / 2), 24, _size / 2);
|
667
|
+
const displayImage = takeIf(loaded, undefined, 'none');
|
668
|
+
const onLoad = useCallback(() => {
|
669
|
+
setLoaded(true);
|
670
|
+
if (_onLoad) _onLoad();
|
671
|
+
}, [_onLoad]);
|
672
|
+
return /*#__PURE__*/React.createElement("div", {
|
673
|
+
style: { ...size,
|
674
|
+
...appStyles.defaultShadow,
|
675
|
+
...appStyles.center,
|
676
|
+
backgroundColor: "#eee",
|
677
|
+
overflow: "hidden",
|
678
|
+
...style
|
679
|
+
},
|
680
|
+
className: className
|
681
|
+
}, /*#__PURE__*/React.createElement(Show, {
|
682
|
+
condition: src
|
683
|
+
}, /*#__PURE__*/React.createElement("img", _extends({
|
684
|
+
onLoad: onLoad,
|
685
|
+
src: src,
|
686
|
+
alt: alt,
|
687
|
+
style: { ...appStyles.roundedImage,
|
688
|
+
...style,
|
689
|
+
display: displayImage
|
690
|
+
}
|
691
|
+
}, rest))), /*#__PURE__*/React.createElement(Show, {
|
692
|
+
condition: !loaded && !hidePlaceholder
|
693
|
+
}, /*#__PURE__*/React.createElement("div", {
|
694
|
+
style: {
|
695
|
+
width: '100%',
|
696
|
+
height: '100%',
|
697
|
+
...appStyles.center
|
698
|
+
}
|
699
|
+
}, /*#__PURE__*/React.createElement("p", {
|
700
|
+
style: {
|
701
|
+
margin: 0,
|
702
|
+
fontSize,
|
703
|
+
fontWeight: 'bold',
|
704
|
+
padding: 4
|
705
|
+
}
|
706
|
+
}, placeholder))));
|
707
|
+
};
|
708
|
+
|
709
|
+
const IncDecField = props => {
|
710
|
+
const {
|
711
|
+
value,
|
712
|
+
onChange,
|
713
|
+
minusIcon,
|
714
|
+
plusIcon,
|
715
|
+
size: _size,
|
716
|
+
style,
|
717
|
+
minusDisabled,
|
718
|
+
plusDisabled,
|
719
|
+
children
|
720
|
+
} = props;
|
721
|
+
return /*#__PURE__*/React$1.createElement("div", {
|
722
|
+
style: {
|
723
|
+
marginVertical: 16,
|
724
|
+
...appStyles.row,
|
725
|
+
...appStyles.spreadHorizontally,
|
726
|
+
...(style || {})
|
727
|
+
}
|
728
|
+
}, /*#__PURE__*/React$1.createElement(Button, {
|
729
|
+
icon: minusIcon,
|
730
|
+
disabled: minusDisabled,
|
731
|
+
type: "primary",
|
732
|
+
style: {
|
733
|
+
borderRadius: 10
|
734
|
+
},
|
735
|
+
onClick: () => onChange(value - 1)
|
736
|
+
}), children, /*#__PURE__*/React$1.createElement(Button, {
|
737
|
+
icon: plusIcon,
|
738
|
+
disabled: plusDisabled,
|
739
|
+
type: "primary",
|
740
|
+
style: {
|
741
|
+
borderRadius: 10
|
742
|
+
},
|
743
|
+
onClick: () => onChange(value + 1)
|
744
|
+
}));
|
745
|
+
};
|
746
|
+
|
747
|
+
const Mapper = props => {
|
748
|
+
const {
|
749
|
+
items,
|
750
|
+
map,
|
751
|
+
children
|
752
|
+
} = props;
|
753
|
+
if (children) return (items || []).map((item, index) => {
|
754
|
+
return /*#__PURE__*/cloneElement(children, { ...item,
|
755
|
+
key: index
|
756
|
+
});
|
757
|
+
});
|
758
|
+
return (items || []).map(map);
|
759
|
+
};
|
760
|
+
|
761
|
+
const InfiniteScrollView = /*#__PURE__*/forwardRef((props, ref) => {
|
762
|
+
const {
|
763
|
+
style,
|
764
|
+
endpoint,
|
765
|
+
apiOptions: _apiOptions,
|
766
|
+
shimmer,
|
767
|
+
onDataChange,
|
768
|
+
render,
|
769
|
+
pageSize: _pageSize,
|
770
|
+
empty,
|
771
|
+
reload,
|
772
|
+
filterOptions,
|
773
|
+
onReload,
|
774
|
+
loadingRenderer
|
775
|
+
} = props;
|
776
|
+
const apiOptions = _apiOptions || {};
|
777
|
+
const {
|
778
|
+
method,
|
779
|
+
params,
|
780
|
+
onSuccess: apiOptionsOnSuccess
|
781
|
+
} = apiOptions;
|
782
|
+
const pageSize = _pageSize || 5;
|
783
|
+
const [page, setPage] = useState(1);
|
784
|
+
const [data, setData] = useState([]);
|
785
|
+
const [filter, setFilter] = useState({});
|
786
|
+
const reloaderRef = useRef(null);
|
787
|
+
|
788
|
+
const updateDataByIndex = (index, item) => {
|
789
|
+
setData(oldData => {
|
790
|
+
oldData[index] = item;
|
791
|
+
return oldData;
|
792
|
+
});
|
793
|
+
};
|
794
|
+
|
795
|
+
useImperativeHandle(ref, () => ({
|
796
|
+
updateDataByIndex
|
797
|
+
}));
|
798
|
+
const containerView = useRef(null);
|
799
|
+
|
800
|
+
const onSuccess = response => {
|
801
|
+
if (apiOptionsOnSuccess) {
|
802
|
+
apiOptionsOnSuccess(response);
|
803
|
+
}
|
804
|
+
|
805
|
+
setData(oldData => {
|
806
|
+
const newData = response.data.currentPage === 1 ? response.data.results || [] : [...oldData, ...(response.data.results || [])];
|
807
|
+
if (onDataChange) onDataChange(newData);
|
808
|
+
return newData;
|
809
|
+
});
|
810
|
+
};
|
811
|
+
|
812
|
+
const {
|
813
|
+
fetched,
|
814
|
+
firstTimeFetched,
|
815
|
+
load: apiLoad,
|
816
|
+
response
|
817
|
+
} = useApi({
|
818
|
+
onSuccess
|
819
|
+
});
|
820
|
+
const {
|
821
|
+
pageCount
|
822
|
+
} = response.data || {};
|
823
|
+
const hasNextPage = (page || 1) < (pageCount || 2);
|
824
|
+
const load = useCallback(() => {
|
825
|
+
const hasNextPage = (page || 1) <= (pageCount || 2);
|
826
|
+
if (!hasNextPage) return;
|
827
|
+
const _endpoint = `${endpoint}/${page}/${pageSize}`;
|
828
|
+
|
829
|
+
const _method = method || (filterOptions ? "POST" : "GET");
|
830
|
+
|
831
|
+
const _params = params || (filterOptions ? filter : undefined);
|
832
|
+
|
833
|
+
apiLoad({
|
834
|
+
endpoint: _endpoint,
|
835
|
+
method: _method,
|
836
|
+
params: _params
|
837
|
+
});
|
838
|
+
}, [page, pageCount, endpoint, pageSize, method, params, filterOptions, apiLoad, filter]);
|
839
|
+
const nextPage = useCallback(() => {
|
840
|
+
if (fetched && hasNextPage) {
|
841
|
+
setPage(oldPage => oldPage + 1);
|
842
|
+
}
|
843
|
+
}, [fetched, hasNextPage]);
|
844
|
+
const onRefresh = useCallback(() => {
|
845
|
+
if (page === 1) {
|
846
|
+
load();
|
847
|
+
} else {
|
848
|
+
setPage(1);
|
849
|
+
}
|
850
|
+
}, [load, page]);
|
851
|
+
const shouldFetchNextPage = useCallback(() => {
|
852
|
+
if (!reloaderRef.current) return false;
|
853
|
+
const reloaderRects = reloaderRef.current.getClientRects();
|
854
|
+
const reloaderOffsetY = reloaderRects[0].top;
|
855
|
+
const shouldFetch = reloaderOffsetY - 20 <= window.innerHeight;
|
856
|
+
return shouldFetch;
|
857
|
+
}, [reloaderRef]);
|
858
|
+
const onScroll = useCallback(event => {
|
859
|
+
if (shouldFetchNextPage()) {
|
860
|
+
nextPage();
|
861
|
+
}
|
862
|
+
}, [shouldFetchNextPage, nextPage]);
|
863
|
+
useEffect(() => {
|
864
|
+
if (shouldFetchNextPage()) nextPage();
|
865
|
+
}, [shouldFetchNextPage, nextPage]);
|
866
|
+
useEffect(() => {
|
867
|
+
load();
|
868
|
+
}, [load]);
|
869
|
+
useEffect(() => {
|
870
|
+
const appLayout = document.getElementsByTagName("body")[0];
|
871
|
+
appLayout.onscroll = onScroll;
|
872
|
+
}, [onScroll]);
|
873
|
+
useEffect(() => {
|
874
|
+
if (reload) {
|
875
|
+
onRefresh();
|
876
|
+
onReload();
|
877
|
+
}
|
878
|
+
}, [onRefresh, onReload, reload]);
|
879
|
+
|
880
|
+
if (!firstTimeFetched) {
|
881
|
+
return shimmer ? /*#__PURE__*/React.createElement(props.shimmer, null) : /*#__PURE__*/React.createElement(props.loadingRenderer, null);
|
882
|
+
}
|
883
|
+
|
884
|
+
const hasData = !!data.length;
|
885
|
+
return /*#__PURE__*/React.createElement("div", {
|
886
|
+
style: {
|
887
|
+
padding: 16,
|
888
|
+
...(style || {})
|
889
|
+
},
|
890
|
+
ref: containerView
|
891
|
+
}, /*#__PURE__*/React.createElement(Show, {
|
892
|
+
condition: hasData
|
893
|
+
}, /*#__PURE__*/React.createElement(Mapper, {
|
894
|
+
items: data,
|
895
|
+
map: (item, index) => render(item, index, {
|
896
|
+
page,
|
897
|
+
pageSize
|
898
|
+
})
|
899
|
+
}), /*#__PURE__*/React.createElement(Show, {
|
900
|
+
condition: hasNextPage
|
901
|
+
}, /*#__PURE__*/React.createElement("div", {
|
902
|
+
ref: reloaderRef
|
903
|
+
}, /*#__PURE__*/React.createElement(Show, {
|
904
|
+
condition: shimmer
|
905
|
+
}, /*#__PURE__*/React.createElement(props.shimmer, null)), /*#__PURE__*/React.createElement(Show, {
|
906
|
+
condition: loadingRenderer
|
907
|
+
}, /*#__PURE__*/React.createElement(props.loadingRenderer, {
|
908
|
+
style: {
|
909
|
+
marginTop: 16
|
910
|
+
}
|
911
|
+
}))))), /*#__PURE__*/React.createElement(Show, {
|
912
|
+
condition: !hasData
|
913
|
+
}, empty));
|
914
|
+
});
|
915
|
+
|
916
|
+
const ModalRenderer = props => {
|
917
|
+
const {
|
918
|
+
title,
|
919
|
+
children,
|
920
|
+
footer
|
921
|
+
} = props;
|
922
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
923
|
+
style: {
|
924
|
+
borderBottom: '1px solid #eee'
|
925
|
+
}
|
926
|
+
}, /*#__PURE__*/React.createElement("div", {
|
927
|
+
style: {
|
928
|
+
margin: 0,
|
929
|
+
padding: 16,
|
930
|
+
fontSize: "1.2em",
|
931
|
+
fontWeight: 500
|
932
|
+
}
|
933
|
+
}, title)), /*#__PURE__*/React.createElement("div", {
|
934
|
+
style: {
|
935
|
+
padding: 16
|
936
|
+
}
|
937
|
+
}, children), /*#__PURE__*/React.createElement(Show, {
|
938
|
+
condition: footer
|
939
|
+
}, /*#__PURE__*/React.createElement("div", {
|
940
|
+
style: {
|
941
|
+
borderTop: '1px solid #eee'
|
942
|
+
}
|
943
|
+
}, footer)));
|
944
|
+
};
|
945
|
+
|
946
|
+
const Overlay = props => {
|
947
|
+
const {
|
948
|
+
visible: _visible,
|
949
|
+
onClick: _onClick,
|
950
|
+
children
|
951
|
+
} = props;
|
952
|
+
const [visible, setVisible] = useState(_visible);
|
953
|
+
useEffect(() => {
|
954
|
+
setTimeout(() => {
|
955
|
+
setVisible(_visible);
|
956
|
+
}, 1);
|
957
|
+
}, [_visible]);
|
958
|
+
const onClick = useCallback(e => {
|
959
|
+
setVisible(false);
|
960
|
+
setTimeout(() => {
|
961
|
+
_onClick(e);
|
962
|
+
}, 400);
|
963
|
+
}, [_onClick]);
|
964
|
+
if (!_visible) return null;
|
965
|
+
return /*#__PURE__*/React.createElement("div", {
|
966
|
+
onClick: onClick,
|
967
|
+
style: {
|
968
|
+
position: 'fixed',
|
969
|
+
zIndex: 1,
|
970
|
+
backgroundColor: 'rgba(0,0,0,0.5)',
|
971
|
+
inset: 0,
|
972
|
+
width: '100%',
|
973
|
+
height: '100%',
|
974
|
+
transition: "0.4s",
|
975
|
+
opacity: takeIf(visible, 1, 0),
|
976
|
+
display: takeIf(visible, 'block', 'none'),
|
977
|
+
overflow: 'auto',
|
978
|
+
pointerEvents: takeIf(visible, "initial", "none"),
|
979
|
+
...appStyles.center
|
980
|
+
}
|
981
|
+
}, /*#__PURE__*/React.createElement(Col, {
|
982
|
+
onClick: e => e.stopPropagation(),
|
983
|
+
xs: 10,
|
984
|
+
sm: 10,
|
985
|
+
md: 8,
|
986
|
+
lg: 8,
|
987
|
+
xl: 6,
|
988
|
+
style: {
|
989
|
+
backgroundColor: 'white',
|
990
|
+
position: 'absolute',
|
991
|
+
width: takeIf(visible, "100%", "0%"),
|
992
|
+
overflow: 'auto',
|
993
|
+
transition: '0.4s',
|
994
|
+
maxHeight: takeIf(visible, "90%", "0%")
|
995
|
+
}
|
996
|
+
}, children));
|
997
|
+
};
|
998
|
+
|
999
|
+
const Modal = props => {
|
1000
|
+
const {
|
1001
|
+
visible,
|
1002
|
+
destroyOnClose,
|
1003
|
+
onClose,
|
1004
|
+
...rest
|
1005
|
+
} = props;
|
1006
|
+
return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(Overlay, {
|
1007
|
+
onClick: onClose,
|
1008
|
+
visible: visible
|
1009
|
+
}, /*#__PURE__*/React.createElement(ModalRenderer, rest)), document.body);
|
1010
|
+
};
|
1011
|
+
|
1012
|
+
let notification = null;
|
1013
|
+
Notification.newInstance({
|
1014
|
+
style: {
|
1015
|
+
right: 32,
|
1016
|
+
top: 32
|
1017
|
+
}
|
1018
|
+
}, _notification => {
|
1019
|
+
notification = _notification;
|
1020
|
+
});
|
1021
|
+
const notificationColors = {
|
1022
|
+
success: 'green',
|
1023
|
+
error: 'red',
|
1024
|
+
warning: 'orange',
|
1025
|
+
info: 'blue'
|
1026
|
+
};
|
1027
|
+
|
1028
|
+
const NotificationRenderer = props => {
|
1029
|
+
const {
|
1030
|
+
type,
|
1031
|
+
title,
|
1032
|
+
message,
|
1033
|
+
icon
|
1034
|
+
} = props;
|
1035
|
+
const color = notificationColors[type];
|
1036
|
+
return /*#__PURE__*/React$1.createElement(ListItem, {
|
1037
|
+
style: {
|
1038
|
+
borderLeft: `5px solid ${color}`,
|
1039
|
+
minWidth: 250,
|
1040
|
+
padding: 8
|
1041
|
+
},
|
1042
|
+
avatar: icon,
|
1043
|
+
avatarContainerStyle: {
|
1044
|
+
color: notificationColors[type],
|
1045
|
+
fontSize: 20,
|
1046
|
+
marginRight: 4
|
1047
|
+
},
|
1048
|
+
titleStyle: {
|
1049
|
+
fontWeight: 'bold'
|
1050
|
+
},
|
1051
|
+
title: title
|
1052
|
+
}, /*#__PURE__*/React$1.createElement("p", {
|
1053
|
+
style: {
|
1054
|
+
marginLeft: 28,
|
1055
|
+
fontSize: 12
|
1056
|
+
}
|
1057
|
+
}, message));
|
1058
|
+
};
|
1059
|
+
|
1060
|
+
const notificationPusher = props => {
|
1061
|
+
const {
|
1062
|
+
duration,
|
1063
|
+
title,
|
1064
|
+
message,
|
1065
|
+
icon,
|
1066
|
+
type,
|
1067
|
+
...rest
|
1068
|
+
} = props;
|
1069
|
+
notification.notice({
|
1070
|
+
duration: duration || 5,
|
1071
|
+
content: /*#__PURE__*/React$1.createElement(NotificationRenderer, {
|
1072
|
+
title: title,
|
1073
|
+
message: message,
|
1074
|
+
type: type,
|
1075
|
+
icon: icon
|
1076
|
+
}),
|
1077
|
+
style: {
|
1078
|
+
padding: 0
|
1079
|
+
},
|
1080
|
+
...rest
|
1081
|
+
});
|
1082
|
+
};
|
1083
|
+
|
1084
|
+
notification.success = props => {
|
1085
|
+
notificationPusher({ ...props,
|
1086
|
+
type: "success"
|
1087
|
+
});
|
1088
|
+
};
|
1089
|
+
|
1090
|
+
notification.error = props => {
|
1091
|
+
notificationPusher({ ...props,
|
1092
|
+
type: "error"
|
1093
|
+
});
|
1094
|
+
};
|
1095
|
+
|
1096
|
+
notification.warning = props => {
|
1097
|
+
notificationPusher({ ...props,
|
1098
|
+
type: "warning"
|
1099
|
+
});
|
1100
|
+
};
|
1101
|
+
|
1102
|
+
notification.info = props => {
|
1103
|
+
notificationPusher({ ...props,
|
1104
|
+
type: "info"
|
1105
|
+
});
|
1106
|
+
};
|
1107
|
+
|
1108
|
+
var notification$1 = notification;
|
1109
|
+
|
1110
|
+
const OverflowImages = props => {
|
1111
|
+
const {
|
1112
|
+
images,
|
1113
|
+
maxCount: _maxCount,
|
1114
|
+
size
|
1115
|
+
} = props;
|
1116
|
+
const maxCount = _maxCount || 3;
|
1117
|
+
const overflowItemsCount = images.length - maxCount;
|
1118
|
+
const count = takeIf(overflowItemsCount > 0, `+${overflowItemsCount}`);
|
1119
|
+
return /*#__PURE__*/React.createElement("div", {
|
1120
|
+
style: { ...appStyles.center,
|
1121
|
+
flexDirection: 'column',
|
1122
|
+
marginRight: 8
|
1123
|
+
}
|
1124
|
+
}, /*#__PURE__*/React.createElement(Badge, {
|
1125
|
+
title: count
|
1126
|
+
}, /*#__PURE__*/React.createElement("div", {
|
1127
|
+
style: { ...appStyles.center
|
1128
|
+
}
|
1129
|
+
}, /*#__PURE__*/React.createElement(Mapper, {
|
1130
|
+
items: images.filter((_, index) => index < maxCount)
|
1131
|
+
}, /*#__PURE__*/React.createElement(OverflowImage, {
|
1132
|
+
size: size
|
1133
|
+
})))));
|
1134
|
+
};
|
1135
|
+
|
1136
|
+
const OverflowImage = props => {
|
1137
|
+
const {
|
1138
|
+
src,
|
1139
|
+
index,
|
1140
|
+
size
|
1141
|
+
} = props;
|
1142
|
+
return /*#__PURE__*/React.createElement("div", {
|
1143
|
+
style: {
|
1144
|
+
border: '1px solid white',
|
1145
|
+
marginLeft: takeIf(index, -32),
|
1146
|
+
borderRadius: size
|
1147
|
+
},
|
1148
|
+
key: index
|
1149
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
1150
|
+
src: src,
|
1151
|
+
key: index,
|
1152
|
+
size: size
|
1153
|
+
}));
|
1154
|
+
};
|
1155
|
+
|
1156
|
+
const Rate = props => {
|
1157
|
+
const {
|
1158
|
+
value,
|
1159
|
+
total,
|
1160
|
+
size: _size,
|
1161
|
+
style
|
1162
|
+
} = props;
|
1163
|
+
const [stars, setStars] = useState([]);
|
1164
|
+
const size = _size || 24;
|
1165
|
+
useEffect(() => {
|
1166
|
+
const _stars = Array(total || 5).fill(0).map((i, index) => index < value ? 1 : 0);
|
1167
|
+
|
1168
|
+
setStars(_stars);
|
1169
|
+
}, [total, value]);
|
1170
|
+
return /*#__PURE__*/React$1.createElement("div", {
|
1171
|
+
style: { ...appStyles.center,
|
1172
|
+
...appStyles.grid,
|
1173
|
+
...(style || {})
|
1174
|
+
}
|
1175
|
+
}, stars.map((i, index) => {
|
1176
|
+
return /*#__PURE__*/React$1.createElement("div", {
|
1177
|
+
style: {
|
1178
|
+
margin: 4
|
1179
|
+
},
|
1180
|
+
key: index
|
1181
|
+
}, /*#__PURE__*/React$1.createElement(Show, {
|
1182
|
+
condition: i
|
1183
|
+
}, /*#__PURE__*/React$1.createElement(props.filledStarIcon, {
|
1184
|
+
style: {
|
1185
|
+
color: 'orange',
|
1186
|
+
fontSize: size
|
1187
|
+
}
|
1188
|
+
})), /*#__PURE__*/React$1.createElement(Show, {
|
1189
|
+
condition: !i
|
1190
|
+
}, /*#__PURE__*/React$1.createElement(props.emptyStarIcon, {
|
1191
|
+
style: {
|
1192
|
+
color: "orange",
|
1193
|
+
fontSize: size
|
1194
|
+
}
|
1195
|
+
})));
|
1196
|
+
}));
|
1197
|
+
};
|
1198
|
+
|
1199
|
+
const Section = props => {
|
1200
|
+
const {
|
1201
|
+
title,
|
1202
|
+
extra,
|
1203
|
+
className,
|
1204
|
+
style,
|
1205
|
+
children
|
1206
|
+
} = props;
|
1207
|
+
return /*#__PURE__*/React$1.createElement("div", {
|
1208
|
+
className: className,
|
1209
|
+
style: {
|
1210
|
+
border: '1px solid #ddd',
|
1211
|
+
borderRadius: 20,
|
1212
|
+
padding: 16,
|
1213
|
+
margin: 8,
|
1214
|
+
height: '100%',
|
1215
|
+
...(style || {})
|
1216
|
+
}
|
1217
|
+
}, /*#__PURE__*/React$1.createElement("div", {
|
1218
|
+
style: {
|
1219
|
+
display: 'flex',
|
1220
|
+
alignItems: 'center',
|
1221
|
+
justifyContent: 'space-between'
|
1222
|
+
}
|
1223
|
+
}, title ? /*#__PURE__*/React$1.createElement("div", {
|
1224
|
+
style: {
|
1225
|
+
fontWeight: 'bold',
|
1226
|
+
fontSize: 18
|
1227
|
+
}
|
1228
|
+
}, title) : null, extra), children);
|
1229
|
+
};
|
1230
|
+
|
1231
|
+
const Selectfield = props => {
|
1232
|
+
const {
|
1233
|
+
className,
|
1234
|
+
label,
|
1235
|
+
items,
|
1236
|
+
value,
|
1237
|
+
descriptionKey: _descriptionKey,
|
1238
|
+
valueKey: _valueKey,
|
1239
|
+
onChange: _onChange,
|
1240
|
+
selectFieldClassName: _selectFieldClassName
|
1241
|
+
} = props;
|
1242
|
+
let selectFieldClassName = "select-field ";
|
1243
|
+
if (_selectFieldClassName) selectFieldClassName += _selectFieldClassName;
|
1244
|
+
const valueKey = coalasce(_valueKey, "value");
|
1245
|
+
const descriptionKey = coalasce(_descriptionKey, "title");
|
1246
|
+
const onChange = useCallback(e => {
|
1247
|
+
const selectedValueKey = e.target.value;
|
1248
|
+
const [selectedValue] = items.filter(i => i[valueKey] === selectedValueKey);
|
1249
|
+
|
1250
|
+
_onChange(selectedValue);
|
1251
|
+
}, [_onChange, items, valueKey]);
|
1252
|
+
return /*#__PURE__*/React.createElement("div", {
|
1253
|
+
className: className
|
1254
|
+
}, /*#__PURE__*/React.createElement(Show, {
|
1255
|
+
condition: label
|
1256
|
+
}, /*#__PURE__*/React.createElement("p", {
|
1257
|
+
style: {
|
1258
|
+
fontWeight: 'bold'
|
1259
|
+
}
|
1260
|
+
}, label)), /*#__PURE__*/React.createElement("select", {
|
1261
|
+
name: label,
|
1262
|
+
value: value || "",
|
1263
|
+
onChange: onChange,
|
1264
|
+
className: selectFieldClassName
|
1265
|
+
}, /*#__PURE__*/React.createElement(Mapper, {
|
1266
|
+
items: items
|
1267
|
+
}, /*#__PURE__*/React.createElement(SelectfieldOption, {
|
1268
|
+
valueKey: valueKey,
|
1269
|
+
descriptionKey: descriptionKey,
|
1270
|
+
value: value
|
1271
|
+
}))));
|
1272
|
+
};
|
1273
|
+
|
1274
|
+
const SelectfieldOption = props => {
|
1275
|
+
const {
|
1276
|
+
valueKey,
|
1277
|
+
value: _value,
|
1278
|
+
descriptionKey,
|
1279
|
+
...rest
|
1280
|
+
} = props;
|
1281
|
+
const value = rest[valueKey];
|
1282
|
+
const description = rest[descriptionKey];
|
1283
|
+
return /*#__PURE__*/React.createElement("option", {
|
1284
|
+
value: value,
|
1285
|
+
selected: value === _value,
|
1286
|
+
className: "select-field-option"
|
1287
|
+
}, description);
|
1288
|
+
};
|
1289
|
+
|
1290
|
+
const Tag = props => {
|
1291
|
+
const {
|
1292
|
+
color: _color,
|
1293
|
+
className,
|
1294
|
+
description,
|
1295
|
+
generatedColor,
|
1296
|
+
type: _type,
|
1297
|
+
textStyle,
|
1298
|
+
style,
|
1299
|
+
onClick,
|
1300
|
+
onTextClick,
|
1301
|
+
closeIcon,
|
1302
|
+
onClear,
|
1303
|
+
closeButtonClassName,
|
1304
|
+
closeButtonStyle,
|
1305
|
+
children
|
1306
|
+
} = props;
|
1307
|
+
const type = _type || "outlined";
|
1308
|
+
const color = _color || (generatedColor ? generatedColorFromString(description) : "#cccccc");
|
1309
|
+
const textColor = type === "filled" ? '#ffffff' : color || "";
|
1310
|
+
const backgroundColor = type === "filled" ? color : `${changeColor(color, 150)}`;
|
1311
|
+
return /*#__PURE__*/React.createElement("div", {
|
1312
|
+
style: {
|
1313
|
+
padding: "8px 16px",
|
1314
|
+
borderRadius: 8,
|
1315
|
+
backgroundColor,
|
1316
|
+
maxWidth: 'calc(100% - 16px)',
|
1317
|
+
...appStyles.center,
|
1318
|
+
...(style || {})
|
1319
|
+
},
|
1320
|
+
className: `
|
1321
|
+
${takeIf(onClick, "clickable", "")}
|
1322
|
+
${className || ""}
|
1323
|
+
`,
|
1324
|
+
onClick: onClick
|
1325
|
+
}, /*#__PURE__*/React.createElement("div", {
|
1326
|
+
className: takeIf(onTextClick, "clickable", ""),
|
1327
|
+
style: {
|
1328
|
+
color: textColor,
|
1329
|
+
margin: 0,
|
1330
|
+
lineHeight: 1,
|
1331
|
+
width: '100%',
|
1332
|
+
...(textStyle || {})
|
1333
|
+
},
|
1334
|
+
onClick: onTextClick
|
1335
|
+
}, children), /*#__PURE__*/React.createElement(Show, {
|
1336
|
+
condition: onClear
|
1337
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
1338
|
+
icon: closeIcon,
|
1339
|
+
onClick: onClear,
|
1340
|
+
className: closeButtonClassName,
|
1341
|
+
style: {
|
1342
|
+
color: 'white',
|
1343
|
+
marginLeft: 8,
|
1344
|
+
...(closeButtonStyle || {})
|
1345
|
+
}
|
1346
|
+
})));
|
1347
|
+
};
|
1348
|
+
|
1349
|
+
const Textfield = props => {
|
1350
|
+
const {
|
1351
|
+
containerClassName,
|
1352
|
+
className,
|
1353
|
+
label,
|
1354
|
+
prefix,
|
1355
|
+
suffix,
|
1356
|
+
value,
|
1357
|
+
onChange,
|
1358
|
+
onBlur,
|
1359
|
+
onPressEnter,
|
1360
|
+
...rest
|
1361
|
+
} = props;
|
1362
|
+
const input = useRef(null);
|
1363
|
+
const focusInput = useCallback(() => {
|
1364
|
+
if (input.current) input.current.focus();
|
1365
|
+
}, [input]);
|
1366
|
+
const onKeyPress = useCallback(e => {
|
1367
|
+
if (["enter", "Enter"].indexOf(e.key) > -1) if (onPressEnter) onPressEnter(e);
|
1368
|
+
}, [onPressEnter]);
|
1369
|
+
return /*#__PURE__*/React$1.createElement("div", {
|
1370
|
+
className: containerClassName,
|
1371
|
+
style: {
|
1372
|
+
width: '100%'
|
1373
|
+
}
|
1374
|
+
}, /*#__PURE__*/React$1.createElement(Show, {
|
1375
|
+
condition: label
|
1376
|
+
}, /*#__PURE__*/React$1.createElement("p", {
|
1377
|
+
className: "no-select",
|
1378
|
+
style: {
|
1379
|
+
fontWeight: 500
|
1380
|
+
},
|
1381
|
+
onClick: focusInput
|
1382
|
+
}, label)), /*#__PURE__*/React$1.createElement("div", {
|
1383
|
+
style: { ...appStyles.row,
|
1384
|
+
alignItems: 'center'
|
1385
|
+
}
|
1386
|
+
}, prefix, /*#__PURE__*/React$1.createElement("input", _extends({
|
1387
|
+
className: `${className || ""} input`,
|
1388
|
+
style: {
|
1389
|
+
width: '100%'
|
1390
|
+
},
|
1391
|
+
value: value || "",
|
1392
|
+
ref: input,
|
1393
|
+
onChange: onChange,
|
1394
|
+
onBlur: onBlur,
|
1395
|
+
onKeyPress: onKeyPress
|
1396
|
+
}, rest)), suffix));
|
1397
|
+
};
|
1398
|
+
|
1399
|
+
const TextListField = props => {
|
1400
|
+
const {
|
1401
|
+
value: _value,
|
1402
|
+
onChange: _onChange,
|
1403
|
+
listContainerStyle,
|
1404
|
+
descriptionKey: _descriptionKey,
|
1405
|
+
valuesRenderer,
|
1406
|
+
textfieldContainerClassName,
|
1407
|
+
checkButton,
|
1408
|
+
label,
|
1409
|
+
checkIcon,
|
1410
|
+
valueTransformer
|
1411
|
+
} = props;
|
1412
|
+
const descriptionKey = useMemo(() => _descriptionKey || "name", [_descriptionKey]);
|
1413
|
+
const [value, setValue] = useState({});
|
1414
|
+
const values = useMemo(() => _value || [], [_value]);
|
1415
|
+
const onSave = useCallback(e => {
|
1416
|
+
if (e) e.preventDefault();
|
1417
|
+
const newValue = valueTransformer ? valueTransformer(value) : value;
|
1418
|
+
if (!newValue[descriptionKey]) return;
|
1419
|
+
|
1420
|
+
if (newValue.index !== undefined) {
|
1421
|
+
const {
|
1422
|
+
index
|
1423
|
+
} = newValue;
|
1424
|
+
delete newValue.index;
|
1425
|
+
values[index] = newValue;
|
1426
|
+
|
1427
|
+
_onChange([...values]);
|
1428
|
+
} else {
|
1429
|
+
_onChange([...values, newValue]);
|
1430
|
+
}
|
1431
|
+
|
1432
|
+
setValue({});
|
1433
|
+
}, [value, valueTransformer, values, _onChange, descriptionKey]);
|
1434
|
+
const onClear = useCallback(index => {
|
1435
|
+
values.splice(index, 1);
|
1436
|
+
|
1437
|
+
_onChange([...values]);
|
1438
|
+
}, [values, _onChange]);
|
1439
|
+
const commitChange = useCallback((index, _newValue) => {
|
1440
|
+
values[index] = valueTransformer ? valueTransformer(_newValue) : _newValue;
|
1441
|
+
|
1442
|
+
_onChange([...values]);
|
1443
|
+
}, [values, valueTransformer, _onChange]);
|
1444
|
+
const suffix = takeIf(checkButton, checkButton({
|
1445
|
+
disabled: !value[descriptionKey],
|
1446
|
+
onClick: onSave
|
1447
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
1448
|
+
icon: checkIcon,
|
1449
|
+
type: "primary",
|
1450
|
+
disabled: !value[descriptionKey],
|
1451
|
+
onClick: onSave
|
1452
|
+
}));
|
1453
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
1454
|
+
style: { ...appStyles.grid,
|
1455
|
+
...(listContainerStyle || {})
|
1456
|
+
}
|
1457
|
+
}, values.map((item, index) => valuesRenderer({
|
1458
|
+
item,
|
1459
|
+
index,
|
1460
|
+
onClear,
|
1461
|
+
setValue,
|
1462
|
+
onSave,
|
1463
|
+
onChange: commitChange
|
1464
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
1465
|
+
style: { ...appStyles.row,
|
1466
|
+
marginTop: 8
|
1467
|
+
}
|
1468
|
+
}, /*#__PURE__*/React.createElement(Textfield, {
|
1469
|
+
value: value[descriptionKey],
|
1470
|
+
containerClassName: textfieldContainerClassName,
|
1471
|
+
label: label,
|
1472
|
+
onChange: e => setValue({ ...value,
|
1473
|
+
[descriptionKey]: e.target.value
|
1474
|
+
}),
|
1475
|
+
onPressEnter: onSave,
|
1476
|
+
onBlur: onSave,
|
1477
|
+
suffix: suffix
|
1478
|
+
})));
|
1479
|
+
};
|
1480
|
+
|
1481
|
+
const ThreeDot = props => {
|
1482
|
+
const {
|
1483
|
+
title,
|
1484
|
+
children
|
1485
|
+
} = props;
|
1486
|
+
return /*#__PURE__*/React$1.createElement(Popover, {
|
1487
|
+
trigger: "mouse",
|
1488
|
+
alignment: "top",
|
1489
|
+
overlay: /*#__PURE__*/React$1.createElement("div", {
|
1490
|
+
style: appStyles.toolTip
|
1491
|
+
}, title || children)
|
1492
|
+
}, /*#__PURE__*/React$1.createElement("div", {
|
1493
|
+
style: appStyles.threeDot
|
1494
|
+
}, children));
|
1495
|
+
};
|
1496
|
+
|
1497
|
+
const Upload = props => {
|
1498
|
+
const {
|
1499
|
+
style,
|
1500
|
+
...rest
|
1501
|
+
} = props;
|
1502
|
+
return /*#__PURE__*/React$1.createElement(UUpload, _extends({
|
1503
|
+
style: {
|
1504
|
+
outline: 'none',
|
1505
|
+
...(style || {})
|
1506
|
+
}
|
1507
|
+
}, rest));
|
1508
|
+
};
|
1509
|
+
|
1510
|
+
export { Badge, Button, Card, ColorPicker, EmptyResult, FadeAnimation, Field, Header, Image, IncDecField, InfiniteScrollView as InfiniteScroll, ListItem, Mapper, Modal, OverflowImages, Popover, Rate, Section, Selectfield, Show, Tag, TextListField, Textfield, ThreeDot, Upload, appStyles, notification$1 as notification, notificationPusher };
|