@visns-studio/visns-components 4.10.25 → 4.10.27

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/package.json CHANGED
@@ -77,7 +77,7 @@
77
77
  "react-dom": "^17.0.0 || ^18.0.0"
78
78
  },
79
79
  "name": "@visns-studio/visns-components",
80
- "version": "4.10.25",
80
+ "version": "4.10.27",
81
81
  "description": "Various packages to assist in the development of our Custom Applications.",
82
82
  "main": "src/index.js",
83
83
  "files": [
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
  import { Link } from 'react-router-dom';
3
3
  import { CircleChevronRight } from 'akar-icons';
4
+ import moment from 'moment';
4
5
 
5
6
  function Breadcrumb({ data, page }) {
6
7
  // Function to get nested data, handling array of keys
7
8
  const getNestedData = (data, keys) => {
9
+ console.info(page);
8
10
  return Array.isArray(keys)
9
11
  ? keys.reduce(
10
12
  (acc, key) => (acc && acc[key] ? acc[key] : null),
@@ -62,7 +64,13 @@ function Breadcrumb({ data, page }) {
62
64
  ))
63
65
  ) : (
64
66
  // If titleKey is a single string, display the corresponding data
65
- <>{data[page.titleKey]}</>
67
+ <>
68
+ {page.titleType === 'date'
69
+ ? moment(data[page.titleKey]).format(
70
+ 'DD-MM-YYYY'
71
+ )
72
+ : data[page.titleKey]}
73
+ </>
66
74
  )}
67
75
  </>
68
76
  )}
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useEffect, useState, useRef } from 'react';
2
2
  import CustomFetch from './Fetch';
3
3
  import SelectList from './SelectList';
4
4
  import Select, { createFilter } from 'react-select';
@@ -19,6 +19,7 @@ function MultiSelect({
19
19
  }) {
20
20
  const [selectOptions, setSelectOptions] = useState([]);
21
21
  const [selectValue, setSelectValue] = useState([]);
22
+ const prevInputValueRef = useRef();
22
23
 
23
24
  useEffect(() => {
24
25
  const _options = Array.isArray(options)
@@ -32,14 +33,34 @@ function MultiSelect({
32
33
  }, [options]);
33
34
 
34
35
  useEffect(() => {
35
- const _values = Array.isArray(inputValue)
36
- ? inputValue.map((a) => ({
37
- value: a.id,
38
- label: a.label || a.name || a.description || 'Unknown',
39
- ...a,
40
- }))
41
- : [];
42
- setSelectValue(_values);
36
+ // Only update if `inputValue` content has changed
37
+ if (
38
+ JSON.stringify(prevInputValueRef.current) !==
39
+ JSON.stringify(inputValue)
40
+ ) {
41
+ const _values = Array.isArray(inputValue)
42
+ ? inputValue.map((a) => ({
43
+ value: a.id,
44
+ label: a.label || a.name || a.description || 'Unknown',
45
+ ...a,
46
+ }))
47
+ : inputValue && typeof inputValue === 'object'
48
+ ? [
49
+ {
50
+ value: inputValue.id,
51
+ label:
52
+ inputValue.label ||
53
+ inputValue.name ||
54
+ inputValue.description ||
55
+ 'Unknown',
56
+ ...inputValue,
57
+ },
58
+ ]
59
+ : [];
60
+
61
+ setSelectValue(_values);
62
+ prevInputValueRef.current = inputValue;
63
+ }
43
64
  }, [inputValue]);
44
65
 
45
66
  const handleCreate = async (inputValue) => {