@visns-studio/visns-components 2.1.5 → 2.2.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.
@@ -3,6 +3,7 @@ import React, {
3
3
  useCallback,
4
4
  useEffect,
5
5
  useImperativeHandle,
6
+ useRef,
6
7
  useState,
7
8
  } from 'react';
8
9
  import { useNavigate } from 'react-router-dom';
@@ -32,6 +33,7 @@ import {
32
33
  Ribbon,
33
34
  Search,
34
35
  ShippingBoxV1,
36
+ SoundOn,
35
37
  TriangleAlert,
36
38
  } from 'akar-icons';
37
39
 
@@ -111,6 +113,16 @@ const DataGrid = forwardRef(
111
113
  ) => {
112
114
  const navigate = useNavigate();
113
115
 
116
+ /** Audio */
117
+ const audioRef = useRef(null);
118
+ const [audioSource, setAudioSource] = useState('');
119
+
120
+ useEffect(() => {
121
+ if (audioSource) {
122
+ audioRef.current.play();
123
+ }
124
+ }, [audioSource]);
125
+
114
126
  /** Modal States */
115
127
  const [formData, setFormData] = useState({});
116
128
  const [formType, setFormType] = useState('');
@@ -178,9 +190,6 @@ const DataGrid = forwardRef(
178
190
 
179
191
  const handleSettingClick = (s, d) => {
180
192
  switch (s.id) {
181
- case 'update':
182
- modalOpen('update', d.id);
183
- break;
184
193
  case 'delete':
185
194
  confirmAlert({
186
195
  title: 'Delete Item',
@@ -234,6 +243,35 @@ const DataGrid = forwardRef(
234
243
  ],
235
244
  });
236
245
  break;
246
+ case 'sound':
247
+ const soundRelation = s.relation.reduce((acc, id) => {
248
+ if (acc === '') {
249
+ return d[id];
250
+ } else {
251
+ if (acc && acc[id]) {
252
+ return acc[id];
253
+ } else {
254
+ return '';
255
+ }
256
+ }
257
+ }, '');
258
+
259
+ if (soundRelation && soundRelation[s.key] && s.url) {
260
+ CustomFetch(
261
+ `${s.url}/${soundRelation[s.key]}`,
262
+ 'POST',
263
+ {},
264
+ (res) => {
265
+ if (res && res !== '') {
266
+ setAudioSource(res);
267
+ }
268
+ }
269
+ );
270
+ }
271
+ break;
272
+ case 'update':
273
+ modalOpen('update', d.id);
274
+ break;
237
275
  default:
238
276
  confirmAlert({
239
277
  title: s.title,
@@ -587,6 +625,8 @@ const DataGrid = forwardRef(
587
625
  return getIconComponent(Ribbon);
588
626
  case 'restore':
589
627
  return getIconComponent(ArrowCounterClockwise);
628
+ case 'sound':
629
+ return getIconComponent(SoundOn);
590
630
  case 'ssa':
591
631
  return getIconComponent(Clock);
592
632
  case 'update':
@@ -1744,42 +1784,48 @@ const DataGrid = forwardRef(
1744
1784
  {renderSearch()}
1745
1785
  {renderCreateButton()}
1746
1786
  {limit && limit > 0 && (
1747
- <ReactDataGrid
1748
- columns={gridColumns}
1749
- dataSource={data}
1750
- filterValue={filterValue}
1751
- limit={limit}
1752
- enableColumnAutosize={false}
1753
- enableColumnFilterContextMenu={false}
1754
- enableSelection={false}
1755
- headerProps={headerProps}
1756
- idProperty={`visns-datagrid-${ajaxSetting.url.replace(
1757
- /\//g,
1758
- '-'
1759
- )}`}
1760
- minRowHeight={40}
1761
- onFilterValueChange={(filterValue) => {
1762
- handleFilterChange(filterValue);
1763
- }}
1764
- onLimitChange={setLimit}
1765
- onSortInfoChange={handleSort}
1766
- onRenderRow={onRenderRow}
1767
- pagination
1768
- renderColumnContextMenu={renderColumnContextMenu}
1769
- rowClassName="vs-datagrid--row"
1770
- rowHeight={null}
1771
- showZebraRows={true}
1772
- sortInfo={
1773
- ajaxSetting.sortBy && ajaxSetting.sort
1774
- ? {
1775
- name: ajaxSetting.sortBy,
1776
- dir: ajaxSetting.sort === 'asc' ? 1 : -1,
1777
- }
1778
- : null
1779
- }
1780
- style={gridStyle}
1781
- />
1787
+ <>
1788
+ <ReactDataGrid
1789
+ columns={gridColumns}
1790
+ dataSource={data}
1791
+ filterValue={filterValue}
1792
+ limit={limit}
1793
+ enableColumnAutosize={false}
1794
+ enableColumnFilterContextMenu={false}
1795
+ enableSelection={false}
1796
+ headerProps={headerProps}
1797
+ idProperty={`visns-datagrid-${ajaxSetting.url.replace(
1798
+ /\//g,
1799
+ '-'
1800
+ )}`}
1801
+ minRowHeight={40}
1802
+ onFilterValueChange={(filterValue) => {
1803
+ handleFilterChange(filterValue);
1804
+ }}
1805
+ onLimitChange={setLimit}
1806
+ onSortInfoChange={handleSort}
1807
+ onRenderRow={onRenderRow}
1808
+ pagination
1809
+ renderColumnContextMenu={renderColumnContextMenu}
1810
+ rowClassName="vs-datagrid--row"
1811
+ rowHeight={null}
1812
+ showZebraRows={true}
1813
+ sortInfo={
1814
+ ajaxSetting.sortBy && ajaxSetting.sort
1815
+ ? {
1816
+ name: ajaxSetting.sortBy,
1817
+ dir:
1818
+ ajaxSetting.sort === 'asc'
1819
+ ? 1
1820
+ : -1,
1821
+ }
1822
+ : null
1823
+ }
1824
+ style={gridStyle}
1825
+ />
1826
+ </>
1782
1827
  )}
1828
+ {audioSource && <audio src={audioSource} ref={audioRef} />}
1783
1829
  <Popup
1784
1830
  open={modalShow}
1785
1831
  onClose={modalClose}
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "akar-icons": "^1.9.28",
6
6
  "awesome-debounce-promise": "^2.1.0",
7
7
  "axios": "^1.4.0",
8
- "framer-motion": "^10.13.0",
8
+ "framer-motion": "^10.15.0",
9
9
  "html-react-parser": "^4.2.0",
10
10
  "lodash": "^4.17.21",
11
11
  "moment": "^2.29.4",
@@ -25,7 +25,7 @@
25
25
  "react-sortable-hoc": "^2.0.0",
26
26
  "react-toastify": "^9.1.3",
27
27
  "react-toggle": "^4.1.3",
28
- "react-tooltip": "^5.18.1",
28
+ "react-tooltip": "^5.19.0",
29
29
  "react-window": "^1.8.9",
30
30
  "reactjs-popup": "^2.0.5",
31
31
  "validator": "^13.9.0",
@@ -40,7 +40,7 @@
40
40
  "react-dom": "^17.0.1"
41
41
  },
42
42
  "name": "@visns-studio/visns-components",
43
- "version": "2.1.5",
43
+ "version": "2.2.1",
44
44
  "description": "Various packages to assist in the development of our Custom Applications.",
45
45
  "main": "index.js",
46
46
  "scripts": {