@visns-studio/visns-components 1.0.1-2.1 → 1.0.1
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/components/visns-table-filter.jsx +124 -0
- package/index.js +11 -41
- package/package.json +3 -11
- package/components/cms/sorting/item.jsx +0 -21
- package/components/cms/sorting/list.jsx +0 -21
- package/components/cms/visns-data-grid.jsx +0 -597
- package/components/cms/visns-dropzone.jsx +0 -161
- package/components/cms/visns-field.jsx +0 -673
- package/components/cms/visns-form.jsx +0 -427
- package/components/crm/visns-table-filter.jsx +0 -130
- /package/components/{crm/visns-async-select.jsx → visns-async-select.jsx} +0 -0
- /package/components/{crm/visns-autocomplete.jsx → visns-autocomplete.jsx} +0 -0
- /package/components/{crm/visns-call.jsx → visns-call.jsx} +0 -0
- /package/components/{crm/visns-data-grid.jsx → visns-data-grid.jsx} +0 -0
- /package/components/{crm/visns-download.jsx → visns-download.jsx} +0 -0
- /package/components/{crm/visns-fetch.jsx → visns-fetch.jsx} +0 -0
- /package/components/{crm/visns-field.jsx → visns-field.jsx} +0 -0
- /package/components/{crm/visns-form.jsx → visns-form.jsx} +0 -0
- /package/components/{crm/visns-loader.jsx → visns-loader.jsx} +0 -0
- /package/components/{crm/visns-multi-select.jsx → visns-multi-select.jsx} +0 -0
- /package/components/{crm/visns-notification.jsx → visns-notification.jsx} +0 -0
- /package/components/{crm/visns-select-list.jsx → visns-select-list.jsx} +0 -0
- /package/components/{crm/visns-select.jsx → visns-select.jsx} +0 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
function TableFilter(props) {
|
|
4
|
+
const { filters, setFilters, setSettings } = props;
|
|
5
|
+
const [data, setData] = useState([]);
|
|
6
|
+
|
|
7
|
+
const filterTable = (e) => {
|
|
8
|
+
if (props.hasOwnProperty('setSettings') === true) {
|
|
9
|
+
setSettings((prevState) => {
|
|
10
|
+
if (prevState.ajaxSetting) {
|
|
11
|
+
let _where = [];
|
|
12
|
+
|
|
13
|
+
prevState.ajaxSetting.where.forEach((a) => {
|
|
14
|
+
if (a.id === e.target.dataset.id) {
|
|
15
|
+
let _push = true;
|
|
16
|
+
|
|
17
|
+
_where.forEach((b) => {
|
|
18
|
+
if (b.id === e.target.dataset.id) {
|
|
19
|
+
_push = false;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (_push === true) {
|
|
24
|
+
_where.push({
|
|
25
|
+
id: e.target.dataset.id,
|
|
26
|
+
value: e.target.dataset.value,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
_where.push(a);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
let _push = true;
|
|
35
|
+
|
|
36
|
+
_where.forEach((a) => {
|
|
37
|
+
if (a.id === e.target.dataset.id) {
|
|
38
|
+
_push = false;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (_push === true) {
|
|
43
|
+
_where.push({
|
|
44
|
+
id: e.target.dataset.id,
|
|
45
|
+
value: e.target.dataset.value,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
...prevState,
|
|
51
|
+
ajaxSetting: {
|
|
52
|
+
...prevState.ajaxSetting,
|
|
53
|
+
where: _where,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
} else {
|
|
57
|
+
let w = prevState.where;
|
|
58
|
+
|
|
59
|
+
prevState.where.forEach((a, b) => {
|
|
60
|
+
if (e.target.dataset.id === a.id) {
|
|
61
|
+
w[b].value = e.target.dataset.value;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return { ...prevState, where: w };
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let tempFilters = filters;
|
|
71
|
+
|
|
72
|
+
filters.map((item, index) => {
|
|
73
|
+
if (
|
|
74
|
+
e.target.dataset.hasOwnProperty('value') &&
|
|
75
|
+
parseInt(e.target.dataset.value) >= 0
|
|
76
|
+
) {
|
|
77
|
+
if (parseInt(e.target.dataset.value) === parseInt(item.value)) {
|
|
78
|
+
tempFilters[index].class = 'subactive';
|
|
79
|
+
tempFilters[index].show = true;
|
|
80
|
+
} else {
|
|
81
|
+
tempFilters[index].class = '';
|
|
82
|
+
tempFilters[index].show = false;
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
if (e.target.dataset.id === item.id) {
|
|
86
|
+
tempFilters[index].class = 'subactive';
|
|
87
|
+
tempFilters[index].show = true;
|
|
88
|
+
} else {
|
|
89
|
+
tempFilters[index].class = '';
|
|
90
|
+
tempFilters[index].show = false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
setFilters(tempFilters);
|
|
96
|
+
setFilters((prevState) => [...prevState]);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
setData(filters);
|
|
101
|
+
}, [filters]);
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<ul>
|
|
105
|
+
{data.map((item, key) => (
|
|
106
|
+
<li key={'table-filter-' + key}>
|
|
107
|
+
<a
|
|
108
|
+
data-id={item.id}
|
|
109
|
+
data-value={
|
|
110
|
+
item.hasOwnProperty('value') ? item.value : ''
|
|
111
|
+
}
|
|
112
|
+
data-url={item.url || ''}
|
|
113
|
+
onClick={filterTable}
|
|
114
|
+
className={item.class}
|
|
115
|
+
>
|
|
116
|
+
{item.label}
|
|
117
|
+
</a>
|
|
118
|
+
</li>
|
|
119
|
+
))}
|
|
120
|
+
</ul>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export default TableFilter;
|
package/index.js
CHANGED
|
@@ -1,42 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import DataGrid from "./components/
|
|
4
|
-
import
|
|
5
|
-
import SortableList from "./components/cms/sorting/list";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReactDOM from "react-dom";
|
|
3
|
+
import DataGrid from "./components/visns-data-grid";
|
|
4
|
+
import Fetch from "./components/visns-fetch";
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import Form from "./components/crm/visns-form";
|
|
15
|
-
import Loader from "./components/crm/visns-loader";
|
|
16
|
-
import MultiSelect from "./components/crm/visns-multi-select";
|
|
17
|
-
import Notification from "./components/crm/visns-notification";
|
|
18
|
-
import SelectList from "./components/crm/visns-select-list";
|
|
19
|
-
import Select from "./components/crm/visns-select";
|
|
20
|
-
import Table from "./components/crm/visns-data-grid";
|
|
21
|
-
import TableFilter from "./components/crm/visns-table-filter";
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
AsyncSelect,
|
|
25
|
-
Autocomplete,
|
|
26
|
-
Call,
|
|
27
|
-
CmsForm,
|
|
28
|
-
CustomFetch,
|
|
29
|
-
DataGrid,
|
|
30
|
-
Download,
|
|
31
|
-
DropZone,
|
|
32
|
-
Field,
|
|
33
|
-
Form,
|
|
34
|
-
Loader,
|
|
35
|
-
MultiSelect,
|
|
36
|
-
Notification,
|
|
37
|
-
SelectList,
|
|
38
|
-
Select,
|
|
39
|
-
SortableList,
|
|
40
|
-
Table,
|
|
41
|
-
TableFilter,
|
|
42
|
-
};
|
|
6
|
+
ReactDOM.render(
|
|
7
|
+
<React.Fragment>
|
|
8
|
+
<DataGrid />
|
|
9
|
+
<Fetch />
|
|
10
|
+
</React.Fragment>,
|
|
11
|
+
document.getElementById("root")
|
|
12
|
+
);
|
package/package.json
CHANGED
|
@@ -9,30 +9,22 @@
|
|
|
9
9
|
"lodash": "^4.17.21",
|
|
10
10
|
"moment": "^2.29.4",
|
|
11
11
|
"numeral": "^2.0.6",
|
|
12
|
+
"react": "^18.2.0",
|
|
12
13
|
"react-confirm-alert": "^3.0.6",
|
|
13
14
|
"react-datepicker": "^4.14.0",
|
|
14
15
|
"react-number-format": "^5.2.2",
|
|
15
16
|
"react-promise-tracker": "^2.1.1",
|
|
16
17
|
"react-quill": "^2.0.0",
|
|
18
|
+
"react-router-dom": "^6.13.0",
|
|
17
19
|
"react-select": "^5.7.3",
|
|
18
|
-
"react-slugify": "^3.0.2",
|
|
19
|
-
"react-sortable-hoc": "^2.0.0",
|
|
20
20
|
"react-toastify": "^9.1.3",
|
|
21
21
|
"react-toggle": "^4.1.3",
|
|
22
22
|
"react-tooltip": "^5.14.0",
|
|
23
23
|
"react-window": "^1.8.9",
|
|
24
24
|
"reactjs-popup": "^2.0.5"
|
|
25
25
|
},
|
|
26
|
-
"devDependecies": {
|
|
27
|
-
"react": "^18.2.0",
|
|
28
|
-
"react-dom": "^18.2.0"
|
|
29
|
-
},
|
|
30
|
-
"peerDependencies": {
|
|
31
|
-
"react": ">=18.2.0",
|
|
32
|
-
"react-dom": ">=18.2.0"
|
|
33
|
-
},
|
|
34
26
|
"name": "@visns-studio/visns-components",
|
|
35
|
-
"version": "1.0.
|
|
27
|
+
"version": "1.0.1",
|
|
36
28
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
37
29
|
"main": "index.js",
|
|
38
30
|
"devDependencies": {},
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SortableElement } from 'react-sortable-hoc';
|
|
3
|
-
import { ChevronVertical } from 'akar-icons';
|
|
4
|
-
|
|
5
|
-
const SortableItem = (props) => {
|
|
6
|
-
const { value, index } = props;
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<li>
|
|
10
|
-
<ChevronVertical strokeWidth={1} size={26} />
|
|
11
|
-
{value.label}
|
|
12
|
-
{value.hasOwnProperty('image_url') && value.image_url !== '' ? (
|
|
13
|
-
<div className="sortimg">
|
|
14
|
-
<img src={value.image_url} />
|
|
15
|
-
</div>
|
|
16
|
-
) : null}
|
|
17
|
-
</li>
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default SortableElement(SortableItem);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import VisnsSortableItem from './item';
|
|
3
|
-
import { SortableContainer } from 'react-sortable-hoc';
|
|
4
|
-
|
|
5
|
-
const SortableList = (props) => {
|
|
6
|
-
const { items } = props;
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<ul className="sortlist">
|
|
10
|
-
{items.map((value, index) => (
|
|
11
|
-
<VisnsSortableItem
|
|
12
|
-
key={`item-${index}`}
|
|
13
|
-
index={index}
|
|
14
|
-
value={value}
|
|
15
|
-
/>
|
|
16
|
-
))}
|
|
17
|
-
</ul>
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default SortableContainer(SortableList);
|