@odigos/ui-kit 0.0.63 → 0.0.65
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/CHANGELOG.md +15 -0
- package/lib/components/key-value-input-list/index.d.ts +2 -0
- package/lib/components/toggle/index.d.ts +1 -1
- package/lib/components.js +7 -7
- package/lib/containers/index.d.ts +1 -0
- package/lib/containers/system-settings/index.d.ts +8 -0
- package/lib/containers/system-settings/settings/collector-gateway-settings.d.ts +4 -0
- package/lib/containers/system-settings/settings/collector-node-settings.d.ts +4 -0
- package/lib/containers/system-settings/settings/options.d.ts +7 -0
- package/lib/containers/system-settings/settings/other-settings.d.ts +4 -0
- package/lib/containers/system-settings/settings/styled.d.ts +2 -0
- package/lib/containers/system-settings/settings/types.d.ts +5 -0
- package/lib/containers/system-settings/settings/ui-settings.d.ts +4 -0
- package/lib/containers/system-settings/settings/user-instrumnetation-envs-settings.d.ts +4 -0
- package/lib/containers.js +277 -22
- package/lib/functions.js +2 -2
- package/lib/hooks/useGenericForm.d.ts +1 -1
- package/lib/hooks.js +3 -3
- package/lib/icons/common/gear-icon/index.d.ts +2 -0
- package/lib/icons/common/index.d.ts +1 -0
- package/lib/icons.js +2 -2
- package/lib/{index-1fcb0269.js → index-391844c6.js} +1 -8
- package/lib/{index-9e56485b.js → index-42f40e7c.js} +2 -7
- package/lib/{index-ec555530.js → index-5e5f7bda.js} +6 -1
- package/lib/{index-eb03f43f.js → index-7074fb24.js} +1 -1
- package/lib/{index-56ab40b8.js → index-c1df4281.js} +16 -1
- package/lib/{index-61caa474.js → index-f2da9ad4.js} +68 -72
- package/lib/mock-data/config/index.d.ts +2 -0
- package/lib/mock-data/index.d.ts +1 -0
- package/lib/snippets.js +5 -5
- package/lib/types/config/index.d.ts +89 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types.js +43 -1
- package/lib/{useTransition-750816e0.js → useTransition-c2aef0e4.js} +33 -13
- package/package.json +1 -1
|
@@ -1,32 +1,55 @@
|
|
|
1
1
|
import { z as useModalStore, O as useDrawerStore, Q as useActiveNodeStore } from './index-bd48e6e2.js';
|
|
2
2
|
import { AddNodeTypes, EntityTypes, PayloadCollectionKeyTypes, CodeAttributesKeyTypes, CustomInstrumentationsKeyTypes } from './types.js';
|
|
3
|
-
import React, { useState, useMemo,
|
|
3
|
+
import React, { useState, useMemo, useEffect, useRef, useCallback } from 'react';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
|
+
import { d as deepClone } from './index-5e5f7bda.js';
|
|
5
6
|
|
|
6
7
|
const useGenericForm = (initialFormData) => {
|
|
7
8
|
function copyInitial() {
|
|
8
9
|
// this is to avoid reference issues with the initial form data,
|
|
9
10
|
// when an object has arrays or objects as part of it's values, a simple spread operator won't work, the children would act as references,
|
|
10
11
|
// so we use JSON.parse(JSON.stringify()) to create a deep copy of the object without affecting the original
|
|
12
|
+
if (initialFormData === undefined)
|
|
13
|
+
return {};
|
|
11
14
|
return JSON.parse(JSON.stringify(initialFormData));
|
|
12
15
|
}
|
|
13
16
|
const [formData, setFormData] = useState(copyInitial());
|
|
14
17
|
const [formErrors, setFormErrors] = useState({});
|
|
18
|
+
const isFormDirty = useMemo(() => {
|
|
19
|
+
return initialFormData !== undefined && JSON.stringify(formData) !== JSON.stringify(initialFormData);
|
|
20
|
+
}, [initialFormData, formData]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (initialFormData !== undefined && JSON.stringify(formData) === '{}')
|
|
23
|
+
setFormData(copyInitial());
|
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
|
+
}, [initialFormData, formData]);
|
|
15
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
27
|
const handleFormChange = (key, val, obj) => {
|
|
17
28
|
if (key) {
|
|
18
29
|
// this is for cases where the form contains objects such as "exportedSignals",
|
|
19
30
|
// the object's child is targeted with a "." for example: "exportedSignals.logs"
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
...prev,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
const splittedKeys = key.toString().split('.');
|
|
32
|
+
if (splittedKeys.length === 1) {
|
|
33
|
+
setFormData((prev) => ({ ...prev, [key]: val }));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
setFormData((prev) => {
|
|
37
|
+
const payload = deepClone(prev);
|
|
38
|
+
let current = payload;
|
|
39
|
+
// Navigate to the parent of the final key, creating objects as needed
|
|
40
|
+
for (let i = 0; i < splittedKeys.length - 1; i++) {
|
|
41
|
+
const key = splittedKeys[i];
|
|
42
|
+
if (!current[key] || typeof current[key] !== 'object') {
|
|
43
|
+
current[key] = {};
|
|
44
|
+
}
|
|
45
|
+
current = current[key];
|
|
27
46
|
}
|
|
28
|
-
|
|
29
|
-
|
|
47
|
+
// Set the final value
|
|
48
|
+
const finalKey = splittedKeys[splittedKeys.length - 1];
|
|
49
|
+
current[finalKey] = val;
|
|
50
|
+
return payload;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
30
53
|
}
|
|
31
54
|
else if (obj) {
|
|
32
55
|
setFormData({ ...obj });
|
|
@@ -44,9 +67,6 @@ const useGenericForm = (initialFormData) => {
|
|
|
44
67
|
setFormData(copyInitial());
|
|
45
68
|
setFormErrors({});
|
|
46
69
|
};
|
|
47
|
-
const isFormDirty = useMemo(() => {
|
|
48
|
-
return JSON.stringify(formData) !== JSON.stringify(initialFormData);
|
|
49
|
-
}, [formData, initialFormData]);
|
|
50
70
|
return {
|
|
51
71
|
formData,
|
|
52
72
|
formErrors,
|