@visns-studio/visns-components 3.1.0 → 3.1.2
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.
|
@@ -11,30 +11,22 @@ const SortableItem = ({
|
|
|
11
11
|
handleClick,
|
|
12
12
|
handleEdit,
|
|
13
13
|
handleDelete,
|
|
14
|
+
showImage,
|
|
14
15
|
value,
|
|
15
16
|
}) => {
|
|
16
17
|
const renderImage = (d) => {
|
|
17
18
|
let htmlContainer = '';
|
|
18
|
-
if (d.hasOwnProperty('image_url') && d.image_url !== '') {
|
|
19
|
-
htmlContainer = (
|
|
20
|
-
<div className="sortimg">
|
|
21
|
-
<img src={d.image_url} />
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
19
|
|
|
26
|
-
if (
|
|
27
|
-
|
|
20
|
+
if (showImage) {
|
|
21
|
+
const imageUrl = d.image_url || d.file_url;
|
|
22
|
+
htmlContainer = imageUrl ? (
|
|
28
23
|
<div className="sortimg">
|
|
29
|
-
<img src={
|
|
24
|
+
<img src={imageUrl} alt="" />
|
|
30
25
|
</div>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (htmlContainer === '') {
|
|
35
|
-
htmlContainer = (
|
|
26
|
+
) : (
|
|
36
27
|
<div className="sortimg">
|
|
37
|
-
|
|
28
|
+
{/* Placeholder image */}
|
|
29
|
+
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAYAAAA4TnrqAAACoUlEQVR4Xu3cO47CMBAAUNMhGiQ6qDkv5+Ac1BwBUUKHRIOgYteg7AaS+Ds/O0OFSPyZp/FEQZYn+/3+uVgszHQ6NfrpF7jf7+ZyuZjJ8Xh82i/r9drM53P1+hK4Xq/mcDgYm1CT0+n0nM1mrx8U7FOqgbIut9vtjbVcLk37gmaY6Xicz+d/LGuqYO/M6nPoYCnYcML0Yo0ZzLWyBrHGCOYrQU6sMYH5oKyFF2sMYCFQwVg1g4VCRWHVCBYDFY1VE1gsVBJWDWApUMlYJYOlQmVhlQiWA5WNVRJYLhQIVglgEFBgWJLBoKBAsSSCQUKBY0kCg4ZCwZIAhgGFhsUJhgWFisUBhgmFjkUJhg1FgkUBRgFFhoUJRgVFioUBRglFjgUJRg3FggUBxgHFhpUDxgXFipUCxgnFjhUDxg0lAisETAKUGCwXmBQoUVh9YJKgxGG1wezmOru3QNJOxKC9DjYIys/vTsQXlAVbrVaUQzvHEofVLD3NLE+OfNcorVkDYEMwksBELEMfiO86VVFjxwqFCL0PE44VKxYg9n5oODas1MBT20HAsWDlBpzbPhWOHAsqUKh+YuBIsaADhO7PB0eGhRUYVr99cCRY2AFh99/AoWNRBUIxDioWRQDt5YI9HhoW9sSHijHmuChYmBP2PbFC/tMP6YOkwHNDNUFizAM0szAmmJoFGBkGhiUNCiPDQLCkQkGDZWNJh4IEy8IqBQoKLBmrNCgIsCSsUqFywaKxSofKAYvCqgUqFSwYqzaoFLAgrFqhYsG8WLVDxYDpWTStl09fYgxi+RrmvOBKbuuKuxdrrFC+JdnBGjuUC+wDS6E+C8S3xx+WnibZraTb7dY8Hg+z2+3MZrN5nyap55S6HzlNhr3OKdUTc3P5+YE3B/mgEymnzCGDgAAAABJRU5ErkJggg==" />
|
|
38
30
|
</div>
|
|
39
31
|
);
|
|
40
32
|
}
|
|
@@ -42,40 +34,50 @@ const SortableItem = ({
|
|
|
42
34
|
return htmlContainer;
|
|
43
35
|
};
|
|
44
36
|
|
|
37
|
+
const renderEditButton = () => {
|
|
38
|
+
if (!handleEdit) return null;
|
|
39
|
+
|
|
40
|
+
if (showImage) {
|
|
41
|
+
if (
|
|
42
|
+
value.hasOwnProperty('file_title') &&
|
|
43
|
+
value.hasOwnProperty('file_description')
|
|
44
|
+
) {
|
|
45
|
+
return <EditButton />;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return <EditButton />;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const EditButton = () => (
|
|
54
|
+
<Pencil
|
|
55
|
+
className="delete pencil-edit"
|
|
56
|
+
strokeWidth={1}
|
|
57
|
+
size={26}
|
|
58
|
+
onClick={(e) => {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
e.stopPropagation();
|
|
61
|
+
handleEdit(value);
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
|
|
45
66
|
return (
|
|
46
67
|
<li
|
|
47
68
|
onClick={(e) => {
|
|
48
69
|
e.preventDefault();
|
|
49
|
-
|
|
50
70
|
if (handleClick) {
|
|
51
71
|
handleClick(containerIndex);
|
|
52
72
|
}
|
|
53
73
|
}}
|
|
54
74
|
>
|
|
55
75
|
<DragHandle />
|
|
56
|
-
{value.label
|
|
57
|
-
? value.label
|
|
58
|
-
: value.file_title
|
|
59
|
-
? value.file_title
|
|
60
|
-
: value.file_name}
|
|
76
|
+
{value.label || value.file_title || value.file_name}
|
|
61
77
|
|
|
62
78
|
{renderImage(value)}
|
|
63
79
|
|
|
64
|
-
{
|
|
65
|
-
value.hasOwnProperty('file_title') &&
|
|
66
|
-
value.hasOwnProperty('file_description') && (
|
|
67
|
-
<Pencil
|
|
68
|
-
className="delete pencil-edit"
|
|
69
|
-
strokeWidth={1}
|
|
70
|
-
size={26}
|
|
71
|
-
onClick={(e) => {
|
|
72
|
-
e.preventDefault();
|
|
73
|
-
e.stopPropagation();
|
|
74
|
-
|
|
75
|
-
handleEdit(value);
|
|
76
|
-
}}
|
|
77
|
-
/>
|
|
78
|
-
)}
|
|
80
|
+
{renderEditButton()}
|
|
79
81
|
|
|
80
82
|
{handleDelete && (
|
|
81
83
|
<TrashCan
|
|
@@ -85,10 +87,9 @@ const SortableItem = ({
|
|
|
85
87
|
onClick={(e) => {
|
|
86
88
|
e.preventDefault();
|
|
87
89
|
e.stopPropagation();
|
|
88
|
-
|
|
89
90
|
handleDelete(
|
|
90
|
-
value.id
|
|
91
|
-
value.label
|
|
91
|
+
value.id || containerIndex,
|
|
92
|
+
value.label || value.file_name
|
|
92
93
|
);
|
|
93
94
|
}}
|
|
94
95
|
/>
|
|
@@ -2,7 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import VisnsSortableItem from './Item';
|
|
3
3
|
import { SortableContainer } from 'react-sortable-hoc';
|
|
4
4
|
|
|
5
|
-
const SortableList = ({
|
|
5
|
+
const SortableList = ({
|
|
6
|
+
handleClick,
|
|
7
|
+
handleDelete,
|
|
8
|
+
handleEdit,
|
|
9
|
+
items,
|
|
10
|
+
showImage,
|
|
11
|
+
}) => {
|
|
6
12
|
return (
|
|
7
13
|
<ul className="sortlist">
|
|
8
14
|
{items.map((value, index) => (
|
|
@@ -10,10 +16,11 @@ const SortableList = ({ handleClick, handleDelete, handleEdit, items }) => {
|
|
|
10
16
|
key={`item-${index}`}
|
|
11
17
|
containerIndex={index}
|
|
12
18
|
index={index}
|
|
13
|
-
value={value}
|
|
14
19
|
handleClick={handleClick}
|
|
15
20
|
handleDelete={handleDelete}
|
|
16
21
|
handleEdit={handleEdit}
|
|
22
|
+
showImage={showImage}
|
|
23
|
+
value={value}
|
|
17
24
|
/>
|
|
18
25
|
))}
|
|
19
26
|
</ul>
|
package/package.json
CHANGED