@visns-studio/visns-components 2.6.1 → 2.6.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.
@@ -0,0 +1,50 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <code_scheme name="Project" version="173">
3
+ <HTMLCodeStyleSettings>
4
+ <option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
5
+ <option name="HTML_QUOTE_STYLE" value="Single" />
6
+ <option name="HTML_ENFORCE_QUOTES" value="true" />
7
+ </HTMLCodeStyleSettings>
8
+ <JSCodeStyleSettings version="0">
9
+ <option name="FORCE_SEMICOLON_STYLE" value="true" />
10
+ <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
11
+ <option name="USE_DOUBLE_QUOTES" value="false" />
12
+ <option name="FORCE_QUOTE_STYlE" value="true" />
13
+ <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
14
+ <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
15
+ <option name="SPACES_WITHIN_IMPORTS" value="true" />
16
+ </JSCodeStyleSettings>
17
+ <TypeScriptCodeStyleSettings version="0">
18
+ <option name="FORCE_SEMICOLON_STYLE" value="true" />
19
+ <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
20
+ <option name="USE_DOUBLE_QUOTES" value="false" />
21
+ <option name="FORCE_QUOTE_STYlE" value="true" />
22
+ <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
23
+ <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
24
+ <option name="SPACES_WITHIN_IMPORTS" value="true" />
25
+ </TypeScriptCodeStyleSettings>
26
+ <VueCodeStyleSettings>
27
+ <option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
28
+ <option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
29
+ </VueCodeStyleSettings>
30
+ <codeStyleSettings language="HTML">
31
+ <option name="SOFT_MARGINS" value="80" />
32
+ <indentOptions>
33
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
34
+ </indentOptions>
35
+ </codeStyleSettings>
36
+ <codeStyleSettings language="JavaScript">
37
+ <option name="SOFT_MARGINS" value="80" />
38
+ </codeStyleSettings>
39
+ <codeStyleSettings language="TypeScript">
40
+ <option name="SOFT_MARGINS" value="80" />
41
+ </codeStyleSettings>
42
+ <codeStyleSettings language="Vue">
43
+ <option name="SOFT_MARGINS" value="80" />
44
+ <indentOptions>
45
+ <option name="INDENT_SIZE" value="4" />
46
+ <option name="TAB_SIZE" value="4" />
47
+ </indentOptions>
48
+ </codeStyleSettings>
49
+ </code_scheme>
50
+ </component>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="PublishConfigData" serverName="Local Dev" />
4
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/visns-components.iml" filepath="$PROJECT_DIR$/.idea/visns-components.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/php.xml ADDED
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="MessDetectorOptionsConfiguration">
4
+ <option name="transferred" value="true" />
5
+ </component>
6
+ <component name="PHPCSFixerOptionsConfiguration">
7
+ <option name="transferred" value="true" />
8
+ </component>
9
+ <component name="PHPCodeSnifferOptionsConfiguration">
10
+ <option name="highlightLevel" value="WARNING" />
11
+ <option name="transferred" value="true" />
12
+ </component>
13
+ <component name="PhpStanOptionsConfiguration">
14
+ <option name="transferred" value="true" />
15
+ </component>
16
+ <component name="PsalmOptionsConfiguration">
17
+ <option name="transferred" value="true" />
18
+ </component>
19
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
@@ -1,13 +1,13 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { useParams, Link } from 'react-router-dom';
1
+ import React, {useEffect, useState} from 'react';
2
+ import {useParams, Link} from 'react-router-dom';
3
3
  import moment from 'moment';
4
4
  import parse from 'html-react-parser';
5
5
  import Popup from 'reactjs-popup';
6
- import { motion } from 'framer-motion';
6
+ import {motion} from 'framer-motion';
7
7
  import Dropzone from 'react-dropzone';
8
- import { confirmAlert } from 'react-confirm-alert';
8
+ import {confirmAlert} from 'react-confirm-alert';
9
9
  import truncate from 'truncate';
10
- import { CopyToClipboard } from 'react-copy-to-clipboard';
10
+ import {CopyToClipboard} from 'react-copy-to-clipboard';
11
11
  import {
12
12
  CircleCheck,
13
13
  CircleChevronRight,
@@ -22,17 +22,18 @@ import CustomFetch from '../Fetch';
22
22
  import Form from '../Form';
23
23
  import Table from '../DataGrid';
24
24
  import TableFilter from '../TableFilter';
25
- import { toast } from 'react-toastify';
25
+ import {toast} from 'react-toastify';
26
26
 
27
- function GenericDetail({ setting, urlParam, userProfile }) {
27
+ function GenericDetail({setting, urlParam, userProfile}) {
28
28
  const routeParams = useParams();
29
- const { filters, page, stages, tabs } = setting;
29
+ const {filters, page, stages, tabs} = setting;
30
30
 
31
31
  /** Fileupload states */
32
32
  const [files, setFiles] = useState([]);
33
33
  const [loadingProgress, setLoadingProgress] = useState(0);
34
34
 
35
35
  /** General States */
36
+ const [activeStage, setActiveStage] = useState('');
36
37
  const [config, setConfig] = useState({});
37
38
  const [data, setData] = useState({});
38
39
  const [dataReload, setDataReload] = useState(0);
@@ -41,32 +42,40 @@ function GenericDetail({ setting, urlParam, userProfile }) {
41
42
  const [windowHeight, setWindowHeight] = useState(window.innerHeight);
42
43
 
43
44
  /** General Functions */
44
- const handleStageUpdate = async (stage) => {
45
- const activeTab = subnav.find((s) => s.show === true);
46
-
47
- if (activeTab) {
48
- const activeTabConfig = tabs.find((t) => t.id === activeTab.id);
49
-
50
- if (
51
- activeTabConfig.stages.url &&
52
- activeTabConfig.stages.url !== '' &&
53
- activeTabConfig.stages.key &&
54
- activeTabConfig.stages.key !== '' &&
55
- activeTabConfig.stages.urlParam &&
56
- activeTabConfig.stages.urlParam !== ''
57
- ) {
58
- const url = `${activeTabConfig.stages.url}/${routeParams[urlParam]}`;
59
-
60
- const res = await CustomFetch(url, 'POST', {
61
- [activeTabConfig.stages.key]: stage.id,
62
- });
63
-
64
- if (res.data.error === '') {
65
- handleReload();
45
+ const handleStageUpdate = async (stage, type) => {
46
+ try {
47
+ const activeTab = subnav.find((s) => s.show === true);
48
+
49
+ if (activeTab) {
50
+ const activeTabConfig = tabs.find((t) => t.id === activeTab.id);
51
+
52
+ if (type === 'view') {
53
+ setActiveStage(stage.id);
66
54
  } else {
67
- toast.error(res.data.error);
55
+ if (
56
+ activeTabConfig.stages.url &&
57
+ activeTabConfig.stages.url !== '' &&
58
+ activeTabConfig.stages.key &&
59
+ activeTabConfig.stages.key !== '' &&
60
+ activeTabConfig.stages.urlParam &&
61
+ activeTabConfig.stages.urlParam !== ''
62
+ ) {
63
+ const url = `${activeTabConfig.stages.url}/${routeParams[urlParam]}`;
64
+
65
+ const res = await CustomFetch(url, 'POST', {
66
+ [activeTabConfig.stages.key]: stage.id,
67
+ });
68
+
69
+ if (res.data.error === '') {
70
+ handleReload();
71
+ } else {
72
+ toast.error(res.data.error);
73
+ }
74
+ }
68
75
  }
69
76
  }
77
+ } catch (error) {
78
+ console.error(error);
70
79
  }
71
80
  };
72
81
 
@@ -108,7 +117,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
108
117
  };
109
118
 
110
119
  const renderValue = (item, data) => {
111
- const { type, id, relation, relationKey, size, truncateLength } = item;
120
+ const {type, id, relation, relationKey, size, truncateLength} = item;
112
121
  const value =
113
122
  relation && relation.length > 0
114
123
  ? getValueFromData(data, [...relation], id)
@@ -116,9 +125,10 @@ function GenericDetail({ setting, urlParam, userProfile }) {
116
125
  const stringValue = String(value ?? ''); // Convert value to a string
117
126
 
118
127
  // Conditionally truncate the value if the 'truncate' key is present
119
- const truncatedValue = truncateLength
120
- ? truncate(stringValue, truncateLength)
121
- : stringValue;
128
+ const truncatedValue =
129
+ truncateLength && truncateLength > 0
130
+ ? truncate(stringValue, truncateLength)
131
+ : stringValue;
122
132
 
123
133
  const formatDateValue = (date) => formatDate(date);
124
134
 
@@ -131,8 +141,8 @@ function GenericDetail({ setting, urlParam, userProfile }) {
131
141
 
132
142
  return name !== '' && description !== '' && formattedDate !== ''
133
143
  ? parse(
134
- `<br /><p>${name} - ${formattedDate}</p><p>${description}</p>`
135
- )
144
+ `<br /><p>${name} - ${formattedDate}</p><p>${description}</p>`
145
+ )
136
146
  : null;
137
147
  };
138
148
 
@@ -170,14 +180,12 @@ function GenericDetail({ setting, urlParam, userProfile }) {
170
180
  );
171
181
  };
172
182
 
173
- const renderDate = () => formatDateValue(truncatedValue);
183
+ const renderDate = () => formatDateValue(value);
174
184
 
175
185
  const renderExist = () => (truncatedValue ? 'Yes' : 'No');
176
186
 
177
187
  const renderJson = () =>
178
- truncatedValue ? (
179
- <pre>{JSON.stringify(JSON.parse(truncatedValue), null, 4)}</pre>
180
- ) : null;
188
+ value ? <pre>{JSON.stringify(value, null, 4)}</pre> : null;
181
189
 
182
190
  const renderLatestNotes = () => formatNoteValue();
183
191
 
@@ -282,7 +290,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
282
290
  <div className="progress">
283
291
  <motion.div
284
292
  className="progress__bar"
285
- initial={{ width: '0%' }}
293
+ initial={{width: '0%'}}
286
294
  animate={{
287
295
  width: loadingProgress + '%',
288
296
  }}
@@ -310,7 +318,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
310
318
  name: file.name,
311
319
  size: file.size,
312
320
  extension:
313
- response.extension,
321
+ response.extension,
314
322
  };
315
323
 
316
324
  CustomFetch(
@@ -331,7 +339,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
331
339
  });
332
340
  }}
333
341
  >
334
- {({ getRootProps, getInputProps }) => (
342
+ {({getRootProps, getInputProps}) => (
335
343
  <section className="dropzone__container">
336
344
  <div {...getRootProps()}>
337
345
  <input
@@ -422,7 +430,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
422
430
  routeParams[
423
431
  formField
424
432
  .urlParam
425
- ]
433
+ ]
426
434
  );
427
435
  }
428
436
  );
@@ -452,10 +460,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
452
460
  <div className="grid__full">
453
461
  {formConfig.stages.data.map(
454
462
  (stage) =>
455
- data[
456
- formConfig
457
- .stages.key
458
- ] === stage.id && (
463
+ parseInt(activeStage) === stage.id && (
459
464
  <React.Fragment
460
465
  key={`stage-form-${stage.id}`}
461
466
  >
@@ -480,7 +485,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
480
485
  columnId={
481
486
  routeParams[
482
487
  urlParam
483
- ]
488
+ ]
484
489
  }
485
490
  formSettings={
486
491
  stage.form
@@ -544,7 +549,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
544
549
  'update',
545
550
  routeParams[
546
551
  urlParam
547
- ]
552
+ ]
548
553
  )
549
554
  }
550
555
  >
@@ -568,7 +573,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
568
573
  </div>
569
574
  {section.content &&
570
575
  section.content.length >
571
- 0 && (
576
+ 0 && (
572
577
  <ul className="customer__overview">
573
578
  {section.content.map(
574
579
  (
@@ -702,21 +707,21 @@ function GenericDetail({ setting, urlParam, userProfile }) {
702
707
  (field.type ===
703
708
  'multi-dropdown-ajax' ||
704
709
  field.type ===
705
- 'multi-dropdown')
710
+ 'multi-dropdown')
706
711
  ) {
707
712
  field.value = {
708
713
  value: routeParams[
709
714
  field.urlParam
710
- ],
715
+ ],
711
716
  label: data[
712
717
  field.relationName
713
- ],
718
+ ],
714
719
  };
715
720
  } else {
716
721
  field.value =
717
722
  routeParams[
718
723
  field.urlParam
719
- ];
724
+ ];
720
725
  }
721
726
  }
722
727
 
@@ -757,6 +762,21 @@ function GenericDetail({ setting, urlParam, userProfile }) {
757
762
  }
758
763
  }, [subnav, tabs, routeParams]);
759
764
 
765
+
766
+ useEffect(() => {
767
+ if (tabs && tabs.length > 0 && data && data.id) {
768
+ const activeTab = subnav.find((s) => s.show === true);
769
+
770
+ if (activeTab) {
771
+ const activeTabConfig = tabs.find((t) => t.id === activeTab.id);
772
+
773
+ if (activeTabConfig.stages && activeTabConfig.stages.key) {
774
+ setActiveStage(data[activeTabConfig.stages.key]);
775
+ }
776
+ }
777
+ }
778
+ }, [data, tabs]);
779
+
760
780
  useEffect(() => {
761
781
  if (routeParams[urlParam] && routeParams[urlParam] > 0) {
762
782
  CustomFetch(
@@ -830,7 +850,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
830
850
  >
831
851
  {page && page.title ? page.title : null}
832
852
  </Link>{' '}
833
- <CircleChevronRight strokeWidth={2} size={18} />{' '}
853
+ <CircleChevronRight strokeWidth={2} size={18}/>{' '}
834
854
  {data && data[page.titleKey]
835
855
  ? data[page.titleKey]
836
856
  : null}
@@ -871,7 +891,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
871
891
  onClick={(e) => {
872
892
  e.preventDefault();
873
893
 
874
- handleStageUpdate(stage);
894
+ handleStageUpdate(stage, stages.type);
875
895
  }}
876
896
  >
877
897
  <a>
@@ -896,7 +916,7 @@ function GenericDetail({ setting, urlParam, userProfile }) {
896
916
  <div className="grid">
897
917
  <div className="grid__subrow">
898
918
  <div className="grid__subnav">
899
- <TableFilter filters={subnav} setFilters={setSubnav} />
919
+ <TableFilter filters={subnav} setFilters={setSubnav}/>
900
920
  </div>
901
921
  <div className="grid__subcontent">
902
922
  {config ? renderContent() : null}
package/package.json CHANGED
@@ -1,64 +1,64 @@
1
1
  {
2
- "dependencies": {
3
- "@inovua/reactdatagrid-community": "^5.10.2",
4
- "add": "^2.0.6",
5
- "akar-icons": "^1.9.29",
6
- "array-move": "^4.0.0",
7
- "awesome-debounce-promise": "^2.1.0",
8
- "axios": "^1.5.0",
9
- "framer-motion": "^10.16.4",
10
- "html-react-parser": "^4.2.2",
11
- "lodash": "^4.17.21",
12
- "moment": "^2.29.4",
13
- "motion": "^10.16.2",
14
- "numeral": "^2.0.6",
15
- "quill-image-uploader": "^1.3.0",
16
- "react-color": "^2.19.3",
17
- "react-confirm-alert": "^3.0.6",
18
- "react-copy-to-clipboard": "^5.1.0",
19
- "react-datepicker": "^4.16.0",
20
- "react-dropzone": "^14.2.3",
21
- "react-number-format": "^5.3.1",
22
- "react-password-strength-bar": "^0.4.1",
23
- "react-promise-tracker": "^2.1.1",
24
- "react-quill": "^2.0.0",
25
- "react-reveal": "^1.2.2",
26
- "react-select": "^5.7.4",
27
- "react-slugify": "^3.0.2",
28
- "react-sortable-hoc": "^2.0.0",
29
- "react-toastify": "^9.1.3",
30
- "react-toggle": "^4.1.3",
31
- "react-tooltip": "^5.21.3",
32
- "react-window": "^1.8.9",
33
- "reactjs-popup": "^2.0.6",
34
- "truncate": "^3.0.0",
35
- "validator": "^13.11.0",
36
- "yarn": "^1.22.19"
37
- },
38
- "devDependecies": {
39
- "react": "^18.2.0",
40
- "react-dom": "^18.2.0"
41
- },
42
- "peerDependencies": {
43
- "react": "^17.0.1",
44
- "react-dom": "^17.0.1"
45
- },
46
- "name": "@visns-studio/visns-components",
47
- "version": "2.6.1",
48
- "description": "Various packages to assist in the development of our Custom Applications.",
49
- "main": "index.js",
50
- "scripts": {
51
- "test": "echo \"Error: no test specified\" && exit 1"
52
- },
53
- "repository": {
54
- "type": "git",
55
- "url": "git+https://github.com/visnsstudio/visns-components.git"
56
- },
57
- "author": "Visns Studio",
58
- "license": "ISC",
59
- "bugs": {
60
- "url": "https://github.com/visnsstudio/visns-components/issues"
61
- },
62
- "homepage": "https://github.com/visnsstudio/visns-components#readme",
63
- "packageManager": "yarn@3.6.1"
2
+ "dependencies": {
3
+ "@inovua/reactdatagrid-community": "^5.10.2",
4
+ "add": "^2.0.6",
5
+ "akar-icons": "^1.9.29",
6
+ "array-move": "^4.0.0",
7
+ "awesome-debounce-promise": "^2.1.0",
8
+ "axios": "^1.5.0",
9
+ "framer-motion": "^10.16.4",
10
+ "html-react-parser": "^4.2.2",
11
+ "lodash": "^4.17.21",
12
+ "moment": "^2.29.4",
13
+ "motion": "^10.16.2",
14
+ "numeral": "^2.0.6",
15
+ "quill-image-uploader": "^1.3.0",
16
+ "react-color": "^2.19.3",
17
+ "react-confirm-alert": "^3.0.6",
18
+ "react-copy-to-clipboard": "^5.1.0",
19
+ "react-datepicker": "^4.16.0",
20
+ "react-dropzone": "^14.2.3",
21
+ "react-number-format": "^5.3.1",
22
+ "react-password-strength-bar": "^0.4.1",
23
+ "react-promise-tracker": "^2.1.1",
24
+ "react-quill": "^2.0.0",
25
+ "react-reveal": "^1.2.2",
26
+ "react-select": "^5.7.4",
27
+ "react-slugify": "^3.0.2",
28
+ "react-sortable-hoc": "^2.0.0",
29
+ "react-toastify": "^9.1.3",
30
+ "react-toggle": "^4.1.3",
31
+ "react-tooltip": "^5.21.3",
32
+ "react-window": "^1.8.9",
33
+ "reactjs-popup": "^2.0.6",
34
+ "truncate": "^3.0.0",
35
+ "validator": "^13.11.0",
36
+ "yarn": "^1.22.19"
37
+ },
38
+ "devDependecies": {
39
+ "react": "^18.2.0",
40
+ "react-dom": "^18.2.0"
41
+ },
42
+ "peerDependencies": {
43
+ "react": "^17.0.1",
44
+ "react-dom": "^17.0.1"
45
+ },
46
+ "name": "@visns-studio/visns-components",
47
+ "version": "2.6.3",
48
+ "description": "Various packages to assist in the development of our Custom Applications.",
49
+ "main": "index.js",
50
+ "scripts": {
51
+ "test": "echo \"Error: no test specified\" && exit 1"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/visnsstudio/visns-components.git"
56
+ },
57
+ "author": "Visns Studio",
58
+ "license": "ISC",
59
+ "bugs": {
60
+ "url": "https://github.com/visnsstudio/visns-components/issues"
61
+ },
62
+ "homepage": "https://github.com/visnsstudio/visns-components#readme",
63
+ "packageManager": "yarn@3.6.1"
64
64
  }