@visns-studio/visns-components 4.7.1 → 4.7.3

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.
Files changed (96) hide show
  1. package/package.json +13 -9
  2. package/src/components/cms/DataGrid.jsx +1461 -0
  3. package/src/components/cms/DropZone.jsx +349 -0
  4. package/src/components/cms/Field.jsx +802 -0
  5. package/src/components/cms/Form.jsx +476 -0
  6. package/src/components/cms/generic/CmsDetail.jsx +36 -0
  7. package/src/components/cms/generic/CmsIndex.jsx +73 -0
  8. package/src/components/cms/generic/CmsSort.jsx +125 -0
  9. package/src/components/cms/sorting/Item.jsx +115 -0
  10. package/src/components/cms/sorting/List.jsx +30 -0
  11. package/src/components/crm/AsyncSelect.jsx +125 -0
  12. package/src/components/crm/Autocomplete.jsx +174 -0
  13. package/src/components/crm/Breadcrumb.jsx +52 -0
  14. package/src/components/crm/Call.jsx +220 -0
  15. package/src/components/crm/DataGrid.jsx +2701 -0
  16. package/src/components/crm/Download.jsx +101 -0
  17. package/src/components/crm/Fetch.jsx +119 -0
  18. package/src/components/crm/Field.jsx +1557 -0
  19. package/src/components/crm/Form.jsx +1409 -0
  20. package/src/components/crm/Loader.jsx +29 -0
  21. package/src/components/crm/MultiSelect.jsx +78 -0
  22. package/src/components/crm/Navigation.jsx +619 -0
  23. package/src/components/crm/Notification.jsx +197 -0
  24. package/src/components/crm/QrCode.jsx +83 -0
  25. package/src/components/crm/Select.jsx +58 -0
  26. package/src/components/crm/SelectList.jsx +21 -0
  27. package/src/components/crm/TableFilter.jsx +198 -0
  28. package/src/components/crm/auth/Login.jsx +223 -0
  29. package/src/components/crm/auth/Profile.jsx +280 -0
  30. package/src/components/crm/auth/Reset.jsx +111 -0
  31. package/src/components/crm/auth/Verify.jsx +174 -0
  32. package/src/components/crm/auth/styles/Login.module.scss +243 -0
  33. package/src/components/crm/auth/styles/Profile.module.scss +222 -0
  34. package/src/components/crm/auth/styles/Reset.module.scss +216 -0
  35. package/src/components/crm/auth/styles/Verify.module.scss +216 -0
  36. package/src/components/crm/generic/AuditLog.jsx +108 -0
  37. package/src/components/crm/generic/AuditLogs.jsx +115 -0
  38. package/src/components/crm/generic/GenericAuth.jsx +166 -0
  39. package/src/components/crm/generic/GenericDashboard.jsx +42 -0
  40. package/src/components/crm/generic/GenericDetail.jsx +1499 -0
  41. package/src/components/crm/generic/GenericDynamic.jsx +915 -0
  42. package/src/components/crm/generic/GenericFormBuilder.jsx +1765 -0
  43. package/src/components/crm/generic/GenericIndex.jsx +376 -0
  44. package/src/components/crm/generic/GenericMain.jsx +129 -0
  45. package/src/components/crm/generic/GenericSort.jsx +188 -0
  46. package/src/components/crm/generic/NotificationList.jsx +64 -0
  47. package/src/components/crm/generic/styles/AuditLog.module.scss +147 -0
  48. package/src/components/crm/generic/styles/AuditLogs.module.scss +92 -0
  49. package/src/components/crm/generic/styles/GenericDetail.module.scss +634 -0
  50. package/src/components/crm/generic/styles/GenericDynamic.module.scss +932 -0
  51. package/src/components/crm/generic/styles/GenericFormBuilder.module.scss +944 -0
  52. package/src/components/crm/generic/styles/GenericIndex.module.scss +247 -0
  53. package/src/components/crm/generic/styles/GenericMain.module.scss +91 -0
  54. package/src/components/crm/generic/styles/GenericSort.module.scss +123 -0
  55. package/src/components/crm/generic/styles/NotificationList.module.scss +67 -0
  56. package/src/components/crm/sorting/Item.jsx +117 -0
  57. package/src/components/crm/sorting/List.jsx +32 -0
  58. package/src/components/crm/sorting/styles/Item.module.scss +68 -0
  59. package/src/components/crm/sorting/styles/List.module.scss +68 -0
  60. package/src/components/crm/styles/AsyncSelect.module.scss +8 -0
  61. package/src/components/crm/styles/Autocomplete.module.scss +44 -0
  62. package/src/components/crm/styles/DataGrid.module.scss +210 -0
  63. package/src/components/crm/styles/Field.module.scss +311 -0
  64. package/src/components/crm/styles/Form.module.scss +499 -0
  65. package/src/components/crm/styles/Loader.module.scss +94 -0
  66. package/src/components/crm/styles/MultiSelect.module.scss +8 -0
  67. package/src/components/crm/styles/Navigation.module.scss +978 -0
  68. package/src/components/crm/styles/Notification.module.scss +147 -0
  69. package/src/components/crm/styles/QrCode.module.scss +87 -0
  70. package/src/components/crm/styles/TableFilter.module.scss +52 -0
  71. package/src/components/styles/global.css +73 -0
  72. package/src/index.js +86 -0
  73. package/dist/104e5636d8ddb791614c.woff2 +0 -0
  74. package/dist/11fe6a83d647de5daf95.woff +0 -0
  75. package/dist/141e2a8c7836495afe2a.woff +0 -0
  76. package/dist/2ba5877f7079830b5383.woff +0 -0
  77. package/dist/2d6836f45b2037be41f3.woff +0 -0
  78. package/dist/399.0a0f3e0d21be1057d599.css +0 -8
  79. package/dist/399.b8f57fa3f8c0c10119e4.js +0 -1
  80. package/dist/47d566c3b1293dfd9d77.woff +0 -0
  81. package/dist/6282a13cbba671a71913.woff2 +0 -0
  82. package/dist/78266f551031aa9db127.woff +0 -0
  83. package/dist/7b7da89f1e3fdcbfe36c.woff2 +0 -0
  84. package/dist/7e78e8338af7efeda712.woff2 +0 -0
  85. package/dist/7fa387951673abf164b1.woff2 +0 -0
  86. package/dist/819d59862c2d0640aad8.woff +0 -0
  87. package/dist/b615e1a6c838ea059a56.woff +0 -0
  88. package/dist/b9b1aa739c660c4ce67c.woff2 +0 -0
  89. package/dist/c5f3640b11df9414facb.woff +0 -0
  90. package/dist/da26d162ff5af71d6590.woff2 +0 -0
  91. package/dist/dd5b2912dbf896310865.woff2 +0 -0
  92. package/dist/f282b331272463c1aa6c.woff2 +0 -0
  93. package/dist/main.83b033670d64419bb497.css +0 -1
  94. package/dist/main.b1723d17cd2d3513ab62.js +0 -1
  95. package/dist/report.html +0 -39
  96. package/dist/runtime.33c276593b23f8035b8d.js +0 -1
@@ -0,0 +1,197 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import { useNavigate } from 'react-router-dom';
3
+ import moment from 'moment';
4
+ import parse from 'html-react-parser';
5
+ import { toast } from 'react-toastify';
6
+ import { Bell, CircleX } from 'akar-icons';
7
+ import CustomFetch from './Fetch';
8
+ import styles from './styles/Notification.module.scss';
9
+
10
+ function Notification(props) {
11
+ let interval;
12
+ const navigate = useNavigate();
13
+ const wrapperRef = useRef(null);
14
+ const [items, setItems] = useState([]);
15
+ const [show, setShow] = useState(false);
16
+ const { setSystemAuth } = props;
17
+
18
+ const fetchNotification = () => {
19
+ CustomFetch(
20
+ '/ajax/user/notifications',
21
+ 'POST',
22
+ {},
23
+ function (result) {
24
+ setItems(result.data);
25
+ },
26
+ function (error) {
27
+ if (String(error) === 'CSRF token mismatch.') {
28
+ window.open('/login');
29
+ } else {
30
+ if (error === 'Unauthenticated.') {
31
+ setSystemAuth(false);
32
+ }
33
+ toast.error(String(error));
34
+ }
35
+ }
36
+ );
37
+ };
38
+
39
+ const handleClick = (e) => {
40
+ if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
41
+ setShow(false);
42
+ }
43
+ };
44
+
45
+ const markAsRead = (e) => {
46
+ e.preventDefault();
47
+
48
+ let array = items;
49
+ let index = e.target.dataset.index;
50
+ let id = e.target.dataset.id;
51
+
52
+ if (index >= 0) {
53
+ array.splice(index, 1);
54
+ setItems(array);
55
+ }
56
+
57
+ let formData = { id: id };
58
+
59
+ CustomFetch(
60
+ '/ajax/user/notification/markasread',
61
+ 'POST',
62
+ formData,
63
+ function () {
64
+ fetchNotification();
65
+ }
66
+ );
67
+ };
68
+
69
+ const markAllAsRead = (e) => {
70
+ e.preventDefault();
71
+
72
+ let array = items;
73
+ setItems([]);
74
+
75
+ array.map((item) => {
76
+ let formData = { id: item.id };
77
+
78
+ CustomFetch(
79
+ '/ajax/user/notification/markasread',
80
+ 'POST',
81
+ formData,
82
+ function () {
83
+ fetchNotification();
84
+ }
85
+ );
86
+ });
87
+ };
88
+
89
+ const toggleNotification = () => {
90
+ setShow(!show);
91
+ };
92
+
93
+ const showAllNotifications = () => {
94
+ navigate('/notifications');
95
+ setShow(false);
96
+ };
97
+
98
+ useEffect(() => {
99
+ fetchNotification();
100
+
101
+ interval = setInterval(() => {
102
+ if (!document.hidden) {
103
+ fetchNotification();
104
+ }
105
+ }, 60000);
106
+
107
+ document.addEventListener('mousedown', handleClick, false);
108
+
109
+ return function cleanup() {
110
+ clearInterval(interval);
111
+ document.removeEventListener('mousedown', handleClick, false);
112
+ };
113
+ }, []);
114
+
115
+ return (
116
+ <>
117
+ <a
118
+ href="#"
119
+ onClick={toggleNotification}
120
+ data-tooltip-id="system-tooltip"
121
+ data-tooltip-content="Notification"
122
+ >
123
+ <Bell
124
+ size={19}
125
+ strokeWidth={2}
126
+ className={
127
+ items.length > 0
128
+ ? styles.noti
129
+ : styles['cis-bell-exclamation']
130
+ }
131
+ />
132
+ </a>
133
+
134
+ {show && (
135
+ <div ref={wrapperRef}>
136
+ {items.length > 0 ? (
137
+ <div className={styles.notibox}>
138
+ <div className={styles.notiscrollwrap}>
139
+ {items.map((item, index) => (
140
+ <div
141
+ className={styles['notibox-item']}
142
+ key={item.id}
143
+ >
144
+ <Bell
145
+ size={19}
146
+ strokeWidth={2}
147
+ className={
148
+ styles.cisBellExclamation
149
+ }
150
+ />{' '}
151
+ {parse(item.data.label)}{' '}
152
+ <span>
153
+ [
154
+ {moment(item.created_at).format(
155
+ 'DD/MM - H:mma'
156
+ )}
157
+ ]
158
+ </span>{' '}
159
+ <button onClick={markAsRead}>
160
+ <CircleX
161
+ size={24}
162
+ data-id={item.id}
163
+ data-index={index}
164
+ className={styles.notiRead}
165
+ />
166
+ </button>
167
+ </div>
168
+ ))}
169
+ </div>
170
+ <div className={styles['notibox-actions']}>
171
+ <button onClick={showAllNotifications}>
172
+ View All
173
+ </button>
174
+ <button onClick={markAllAsRead}>
175
+ Clear All
176
+ </button>
177
+ </div>
178
+ </div>
179
+ ) : (
180
+ <div className={styles.notibox}>
181
+ <div className={styles['notibox-item']}>
182
+ No new notifications available.
183
+ </div>
184
+ <div className={styles['notibox-actions']}>
185
+ <button onClick={showAllNotifications}>
186
+ View All
187
+ </button>
188
+ </div>
189
+ </div>
190
+ )}
191
+ </div>
192
+ )}
193
+ </>
194
+ );
195
+ }
196
+
197
+ export default Notification;
@@ -0,0 +1,83 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import ReactToPrint from 'react-to-print';
3
+
4
+ import CustomFetch from './Fetch';
5
+ import styles from './styles/QrCode.module.scss';
6
+
7
+ const QrCode = ({ config, dataId }) => {
8
+ const printComponentRef = useRef();
9
+ const [qrCodeData, setQrCodeData] = useState({
10
+ logo: '',
11
+ qrCode: '',
12
+ title: '',
13
+ });
14
+
15
+ const fetchQrCode = async ({ url }) => {
16
+ try {
17
+ const res = await CustomFetch(`${url}/${dataId}`, 'POST', {});
18
+
19
+ setQrCodeData((prevState) => ({ ...prevState, ...res.data }));
20
+ } catch (error) {
21
+ console.error(error);
22
+ }
23
+ };
24
+
25
+ useEffect(() => {
26
+ fetchQrCode(config);
27
+ }, []);
28
+
29
+ return (
30
+ <>
31
+ <div className={styles.gridtxt} ref={printComponentRef}>
32
+ {qrCodeData.logo && qrCodeData.logo !== '' && (
33
+ <ul className={styles.customer__overview}>
34
+ <li
35
+ className={styles['fw-grid-item']}
36
+ style={{
37
+ textAlign: 'center',
38
+ }}
39
+ >
40
+ <img
41
+ src={qrCodeData.logo}
42
+ alt="Dawn Projects"
43
+ width="40%"
44
+ />
45
+ </li>
46
+ </ul>
47
+ )}
48
+ <ul className={styles.customer__overview}>
49
+ <li
50
+ className={styles['fw-grid-item']}
51
+ style={{
52
+ textAlign: 'center',
53
+ }}
54
+ >
55
+ {qrCodeData.title}
56
+ </li>
57
+ </ul>
58
+ <ul className={styles.customer__overview}>
59
+ <li
60
+ className={styles['fw-grid-item']}
61
+ style={{ textAlign: 'center' }}
62
+ >
63
+ {qrCodeData.qrCode && qrCodeData.qrCode !== '' && (
64
+ <img
65
+ src={`data:image/svg+xml;base64, ${qrCodeData.qrCode}`}
66
+ alt="SVG Image"
67
+ width="80%"
68
+ />
69
+ )}
70
+ </li>
71
+ </ul>
72
+ </div>
73
+ <div className={styles.polActions}>
74
+ <ReactToPrint
75
+ trigger={() => <button className="btn">Print</button>}
76
+ content={() => printComponentRef.current}
77
+ />
78
+ </div>
79
+ </>
80
+ );
81
+ };
82
+
83
+ export default QrCode;
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+
3
+ const Select = (props) => {
4
+ const { className, dataOptions, inputValue, onChange, options, settings } =
5
+ props;
6
+
7
+ return (
8
+ <select
9
+ data-name={settings.id}
10
+ className={className}
11
+ onChange={onChange}
12
+ value={inputValue}
13
+ data-show={settings.show ? JSON.stringify(settings.show) : ''}
14
+ >
15
+ <option value="">
16
+ {settings.placeholder
17
+ ? settings.placeholder
18
+ : 'Please select an option'}
19
+ </option>
20
+ {options.map((item, index) =>
21
+ item.options ? (
22
+ item.options.length > 0 ? ( // Check if the item contains nested options (indicating an optgroup)
23
+ <optgroup
24
+ key={settings.id + '-' + item.id}
25
+ label={item.label}
26
+ >
27
+ {item.options.map((subItem, subIndex) => (
28
+ <option
29
+ key={
30
+ settings.id +
31
+ '-' +
32
+ item.id +
33
+ '-' +
34
+ subItem.id
35
+ }
36
+ value={subItem.id}
37
+ {...dataOptions[subIndex]}
38
+ >
39
+ {subItem.label}
40
+ </option>
41
+ ))}
42
+ </optgroup>
43
+ ) : null
44
+ ) : (
45
+ <option
46
+ key={settings.id + '-' + item.id}
47
+ value={item.id}
48
+ {...dataOptions[index]}
49
+ >
50
+ {item.label}
51
+ </option>
52
+ )
53
+ )}
54
+ </select>
55
+ );
56
+ };
57
+
58
+ export default Select;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { FixedSizeList } from 'react-window';
3
+
4
+ function SelectList(props) {
5
+ const { options, children, maxHeight, getValue } = props;
6
+ const [value] = getValue();
7
+ const initialOffset = options.indexOf(value) * 50;
8
+
9
+ return (
10
+ <FixedSizeList
11
+ height={maxHeight}
12
+ itemCount={children.length}
13
+ itemSize={height}
14
+ initialScrollOffset={initialOffset}
15
+ >
16
+ {({ index, style }) => <div style={style}>{children[index]}</div>}
17
+ </FixedSizeList>
18
+ );
19
+ }
20
+
21
+ export default SelectList;
@@ -0,0 +1,198 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import styles from './styles/TableFilter.module.scss';
3
+
4
+ function TableFilter({
5
+ collapsible = false,
6
+ filters,
7
+ setFilters,
8
+ setSettings,
9
+ type,
10
+ }) {
11
+ const [visibleChildren, setVisibleChildren] = useState(null);
12
+ const isFirstRender = useRef(true);
13
+
14
+ useEffect(() => {
15
+ if (
16
+ isFirstRender.current &&
17
+ filters.length > 0 &&
18
+ filters[0].children &&
19
+ filters[0].children.length > 0
20
+ ) {
21
+ setVisibleChildren(filters[0].id);
22
+ isFirstRender.current = false;
23
+ }
24
+ }, [filters]);
25
+
26
+ const filterTable = (e) => {
27
+ const { id, parent, filtertype, url, value } = e.target.dataset;
28
+
29
+ const updateFilter = (filter) => {
30
+ let isActive = false;
31
+
32
+ if (filter.hasOwnProperty('value')) {
33
+ isActive = parseInt(value) === parseInt(filter.value);
34
+ } else {
35
+ isActive = filter.id === id;
36
+ }
37
+
38
+ const isParent =
39
+ parent && filtertype === 'children' && filter.id === parent;
40
+
41
+ const updatedChildren = isParent
42
+ ? filter.children.map((child) => ({
43
+ ...child,
44
+ class: child.id === id ? 'subactivechildren' : '',
45
+ show: child.id === id ? true : false,
46
+ }))
47
+ : filter.children
48
+ ? filter.children.map((child, childKey) => ({
49
+ ...child,
50
+ class:
51
+ childKey === 0 && isActive ? 'subactivechildren' : '',
52
+ show: childKey === 0 && isActive ? true : false,
53
+ }))
54
+ : [];
55
+
56
+ return {
57
+ ...filter,
58
+ class:
59
+ isActive || isParent
60
+ ? type === 'simple'
61
+ ? 'activetab'
62
+ : 'subactive'
63
+ : '',
64
+ show: isActive || isParent,
65
+ children: updatedChildren,
66
+ };
67
+ };
68
+
69
+ setFilters((prevFilters) => prevFilters.map(updateFilter));
70
+
71
+ if (url && url !== '') {
72
+ window.open(url);
73
+ } else {
74
+ if (setSettings) {
75
+ setSettings((prevState) => {
76
+ if (prevState.ajaxSetting) {
77
+ let _where = prevState.ajaxSetting.where.reduce(
78
+ (acc, a) => {
79
+ if (
80
+ a.id === id &&
81
+ !acc.some((b) => b.id === id)
82
+ ) {
83
+ acc.push({ id: id, value: value });
84
+ } else {
85
+ acc.push(a);
86
+ }
87
+ return acc;
88
+ },
89
+ []
90
+ );
91
+
92
+ return {
93
+ ...prevState,
94
+ ajaxSetting: {
95
+ ...prevState.ajaxSetting,
96
+ where: _where,
97
+ },
98
+ };
99
+ } else {
100
+ let w = prevState.where
101
+ ? prevState.where.map((a) => {
102
+ if (id === a.id) {
103
+ return { ...a, value: value };
104
+ }
105
+ return a;
106
+ })
107
+ : [];
108
+
109
+ return { ...prevState, where: w };
110
+ }
111
+ });
112
+ }
113
+ }
114
+
115
+ // Handle collapsible functionality
116
+ if (collapsible && filtertype === 'parent') {
117
+ setVisibleChildren(id);
118
+ }
119
+ };
120
+
121
+ const renderContent = (d) => {
122
+ const parentClass = `${styles.link} ${styles[d.class] || ''}`;
123
+ const childClass = (child) =>
124
+ `${styles.link} ${styles[child.class] || ''}`;
125
+
126
+ if (type === 'simple') {
127
+ return (
128
+ <li className={styles[d.class]}>
129
+ <button
130
+ data-id={d.id}
131
+ data-filtertype="parent"
132
+ data-url={d.url || ''}
133
+ data-value={d.hasOwnProperty('value') ? d.value : ''}
134
+ onClick={filterTable}
135
+ >
136
+ {d.label}
137
+ </button>
138
+ </li>
139
+ );
140
+ } else {
141
+ return (
142
+ <li>
143
+ <a
144
+ data-id={d.id}
145
+ data-filtertype="parent"
146
+ data-url={d.url || ''}
147
+ data-value={d.hasOwnProperty('value') ? d.value : ''}
148
+ onClick={filterTable}
149
+ className={parentClass}
150
+ >
151
+ {d.label}
152
+ </a>
153
+ {d.children && d.children.length > 0 && (
154
+ <ul
155
+ className={`${styles.collapsibleMenu} ${
156
+ visibleChildren === d.id
157
+ ? styles.visibleMenu
158
+ : ''
159
+ }`}
160
+ >
161
+ {d.children.map((child, key) => (
162
+ <li key={`table-filter-child-${d.id}-${key}`}>
163
+ <a
164
+ className={childClass(child)}
165
+ data-id={child.id}
166
+ data-value={
167
+ child.hasOwnProperty('value')
168
+ ? child.value
169
+ : ''
170
+ }
171
+ data-url={child.url || ''}
172
+ data-filtertype="children"
173
+ data-parent={d.id}
174
+ onClick={filterTable}
175
+ >
176
+ {child.label}
177
+ </a>
178
+ </li>
179
+ ))}
180
+ </ul>
181
+ )}
182
+ </li>
183
+ );
184
+ }
185
+ };
186
+
187
+ return (
188
+ <ul className={styles.tableFilter}>
189
+ {filters.map((item, key) => (
190
+ <React.Fragment key={'table-filter-' + key}>
191
+ {renderContent(item)}
192
+ </React.Fragment>
193
+ ))}
194
+ </ul>
195
+ );
196
+ }
197
+
198
+ export default TableFilter;