@odigos/ui-kit 0.0.17 → 0.0.19

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 (37) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/lib/components/index.d.ts +1 -0
  3. package/lib/components/scroll-x/index.d.ts +10 -0
  4. package/lib/components.js +13 -44
  5. package/lib/constants.js +5 -9
  6. package/lib/containers/data-flow/nodes/scroll-node.d.ts +3 -14
  7. package/lib/containers.js +42 -94
  8. package/lib/functions.js +9 -15
  9. package/lib/hooks.js +10 -10
  10. package/lib/icons.js +3 -4
  11. package/lib/{index-Hz7AAE0t.js → index-7-KCQK-x.js} +1 -1
  12. package/lib/{index-G4WmxXds.js → index-BFRz3l_w.js} +21 -4
  13. package/lib/index-BazfJyRh.js +687 -0
  14. package/lib/{index-C3nz3TIx.js → index-CD_BQJCD.js} +5 -3
  15. package/lib/{index-BiNX-Cge.js → index-CvuVOtkr.js} +154 -119
  16. package/lib/{index-CIXQeSHu.js → index-DGel4E-Z.js} +8 -1
  17. package/lib/{index-BQW5EUgp.js → index-DSzybApb.js} +6 -4
  18. package/lib/{index-BxQTUOME.js → index-WSle42rz.js} +5 -3
  19. package/lib/store.js +3 -6
  20. package/lib/theme.js +3 -86
  21. package/lib/types.js +215 -6
  22. package/lib/useSourceSelectionFormData-_2PggiXn.js +563 -0
  23. package/lib/{useTimeAgo-weEj7br6.js → useTransition-bXMKBfST.js} +113 -544
  24. package/package.json +1 -2
  25. package/lib/index-B72aw6tI.js +0 -23
  26. package/lib/index-BQs4sULy.js +0 -32
  27. package/lib/index-BVVVevuY.js +0 -100
  28. package/lib/index-BWqrekK4.js +0 -11
  29. package/lib/index-C1PCuZgw.js +0 -18
  30. package/lib/index-CIgHU72d.js +0 -52
  31. package/lib/index-DbfrGXPH.js +0 -8
  32. package/lib/index-RBS1MqCQ.js +0 -37
  33. package/lib/react-CjImwkhV.js +0 -44
  34. package/lib/useDarkMode-DxhIuVNi.js +0 -201
  35. package/lib/useSelectedStore-93bIo1kE.js +0 -97
  36. package/lib/useSetupStore-CoYx1UQw.js +0 -211
  37. package/lib/useTransition-D0wUpPGk.js +0 -128
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odigos/ui-kit",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "author": "Odigos",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,6 @@
19
19
  "publishConfig": {
20
20
  "access": "public"
21
21
  },
22
- "sideEffects": false,
23
22
  "exports": {
24
23
  "./components": {
25
24
  "types": "./lib/components/index.d.ts",
@@ -1,23 +0,0 @@
1
- var NodeTypes;
2
- (function (NodeTypes) {
3
- NodeTypes["Header"] = "header";
4
- NodeTypes["Add"] = "add";
5
- NodeTypes["Base"] = "base";
6
- NodeTypes["Edged"] = "edged";
7
- NodeTypes["Frame"] = "frame";
8
- NodeTypes["Scroll"] = "scroll";
9
- NodeTypes["Skeleton"] = "skeleton";
10
- })(NodeTypes || (NodeTypes = {}));
11
- var EdgeTypes;
12
- (function (EdgeTypes) {
13
- EdgeTypes["Labeled"] = "labeled";
14
- })(EdgeTypes || (EdgeTypes = {}));
15
- var AddNodeTypes;
16
- (function (AddNodeTypes) {
17
- AddNodeTypes["AddRule"] = "addRule";
18
- AddNodeTypes["AddSource"] = "addSource";
19
- AddNodeTypes["AddAction"] = "addAction";
20
- AddNodeTypes["AddDestination"] = "addDestination";
21
- })(AddNodeTypes || (AddNodeTypes = {}));
22
-
23
- export { AddNodeTypes as A, EdgeTypes as E, NodeTypes as N };
@@ -1,32 +0,0 @@
1
- const getEntityId = (item) => {
2
- if ('ruleId' in item && !!item.ruleId) {
3
- // Instrumentation Rule
4
- return item.ruleId;
5
- }
6
- else if ('id' in item && !!item.id) {
7
- // Destination or Action
8
- return item.id;
9
- }
10
- else if ('namespace' in item && !!item.namespace && 'kind' in item && !!item.kind && 'name' in item && !!item.name) {
11
- // Source
12
- return {
13
- namespace: item.namespace,
14
- name: item.name,
15
- kind: item.kind,
16
- };
17
- }
18
- else if ('name' in item && !!item.name) {
19
- // Namespace
20
- return item.name;
21
- }
22
- console.warn('getEntityId() - cannot get ID of entity:', item);
23
- return undefined;
24
- };
25
-
26
- const isTimeElapsed = (originDate, difference = 0) => {
27
- const now = new Date().getTime();
28
- const compareWith = new Date(originDate).getTime();
29
- return now - compareWith >= difference;
30
- };
31
-
32
- export { getEntityId as g, isTimeElapsed as i };
@@ -1,100 +0,0 @@
1
- var Tier;
2
- (function (Tier) {
3
- Tier["Community"] = "community";
4
- Tier["Cloud"] = "cloud";
5
- Tier["Onprem"] = "onprem";
6
- })(Tier || (Tier = {}));
7
- var PlatformType;
8
- (function (PlatformType) {
9
- PlatformType["K8s"] = "k8s";
10
- PlatformType["Vm"] = "vm";
11
- })(PlatformType || (PlatformType = {}));
12
- var ProgrammingLanguages;
13
- (function (ProgrammingLanguages) {
14
- ProgrammingLanguages["Go"] = "go";
15
- ProgrammingLanguages["JavaScript"] = "javascript";
16
- ProgrammingLanguages["Python"] = "python";
17
- ProgrammingLanguages["Java"] = "java";
18
- ProgrammingLanguages["DotNet"] = "dotnet";
19
- ProgrammingLanguages["CSharp"] = "csharp";
20
- ProgrammingLanguages["CPlusPlus"] = "cplusplus";
21
- ProgrammingLanguages["Php"] = "php";
22
- ProgrammingLanguages["Ruby"] = "ruby";
23
- ProgrammingLanguages["Rust"] = "rust";
24
- ProgrammingLanguages["Swift"] = "swift";
25
- ProgrammingLanguages["Elixir"] = "elixir";
26
- ProgrammingLanguages["MySql"] = "mysql";
27
- ProgrammingLanguages["Nginx"] = "nginx";
28
- ProgrammingLanguages["Postgres"] = "postgres";
29
- ProgrammingLanguages["Redis"] = "redis";
30
- ProgrammingLanguages["Kafka"] = "kafka";
31
- ProgrammingLanguages["Ignored"] = "ignored";
32
- ProgrammingLanguages["Unknown"] = "unknown";
33
- ProgrammingLanguages["Processing"] = "processing";
34
- ProgrammingLanguages["NoContainers"] = "no containers";
35
- ProgrammingLanguages["NoRunningPods"] = "no running pods";
36
- })(ProgrammingLanguages || (ProgrammingLanguages = {}));
37
- var Crud;
38
- (function (Crud) {
39
- Crud["Create"] = "Create";
40
- Crud["Read"] = "Read";
41
- Crud["Update"] = "Update";
42
- Crud["Delete"] = "Delete";
43
- })(Crud || (Crud = {}));
44
- var EntityTypes;
45
- (function (EntityTypes) {
46
- EntityTypes["Namespace"] = "Namespace";
47
- EntityTypes["Source"] = "Source";
48
- EntityTypes["Destination"] = "Destination";
49
- EntityTypes["Action"] = "Action";
50
- EntityTypes["InstrumentationRule"] = "InstrumentationRule";
51
- })(EntityTypes || (EntityTypes = {}));
52
- var FieldTypes;
53
- (function (FieldTypes) {
54
- FieldTypes["Input"] = "input";
55
- FieldTypes["MultiInput"] = "multiInput";
56
- FieldTypes["MultiTabledInput"] = "multiTabledInput";
57
- FieldTypes["KeyValuePair"] = "keyValuePairs";
58
- FieldTypes["TextArea"] = "textarea";
59
- FieldTypes["Dropdown"] = "dropdown";
60
- FieldTypes["Checkbox"] = "checkbox";
61
- FieldTypes["Toggle"] = "toggle";
62
- })(FieldTypes || (FieldTypes = {}));
63
- var CrdTypes;
64
- (function (CrdTypes) {
65
- CrdTypes["OdigosConfig"] = "OdigosConfiguration";
66
- CrdTypes["CollectorsGroup"] = "CollectorsGroup";
67
- CrdTypes["Source"] = "Source";
68
- CrdTypes["InstrumentationConfig"] = "InstrumentationConfig";
69
- CrdTypes["InstrumentationInstance"] = "InstrumentationInstance";
70
- CrdTypes["Destination"] = "Destination";
71
- CrdTypes["InstrumentationRule"] = "InstrumentationRule";
72
- CrdTypes["Processor"] = "Processor";
73
- CrdTypes["AddClusterInfo"] = "AddClusterInfo";
74
- CrdTypes["DeleteAttributes"] = "DeleteAttribute";
75
- CrdTypes["RenameAttributes"] = "RenameAttribute";
76
- CrdTypes["PiiMasking"] = "PiiMasking";
77
- CrdTypes["ErrorSampler"] = "ErrorSampler";
78
- CrdTypes["LatencySampler"] = "LatencySampler";
79
- CrdTypes["ProbabilisticSampler"] = "ProbabilisticSampler";
80
- })(CrdTypes || (CrdTypes = {}));
81
- var StatusType;
82
- (function (StatusType) {
83
- StatusType["Warning"] = "warning";
84
- StatusType["Error"] = "error";
85
- StatusType["Success"] = "success";
86
- StatusType["Info"] = "info";
87
- StatusType["Default"] = "default";
88
- })(StatusType || (StatusType = {}));
89
- var OtherStatus;
90
- (function (OtherStatus) {
91
- OtherStatus["Loading"] = "loading";
92
- OtherStatus["Disabled"] = "disabled";
93
- })(OtherStatus || (OtherStatus = {}));
94
- var SortDirection;
95
- (function (SortDirection) {
96
- SortDirection["Ascending"] = "asc";
97
- SortDirection["Descending"] = "desc";
98
- })(SortDirection || (SortDirection = {}));
99
-
100
- export { Crud as C, EntityTypes as E, FieldTypes as F, OtherStatus as O, PlatformType as P, StatusType as S, Tier as T, ProgrammingLanguages as a, CrdTypes as b, SortDirection as c };
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import Theme from './theme.js';
3
-
4
- const ImageErrorIcon = ({ size = 16, fill: f, rotate = 0, onClick }) => {
5
- const theme = Theme.useTheme();
6
- const fill = f || theme.text.secondary;
7
- return (React.createElement("svg", { width: size, height: size, viewBox: '0 0 24 24', xmlns: 'http://www.w3.org/2000/svg', fill: 'none', style: { transform: `rotate(${rotate}deg)` }, onClick: onClick },
8
- React.createElement("path", { stroke: fill, strokeLinecap: 'round', strokeLinejoin: 'round', d: 'M17.2 21.0002L19.6 18.6002M19.6 18.6002L22 16.2002M19.6 18.6002L17.2 16.2002M19.6 18.6002L22 21.0002M22 12.1944V11C22 10.6449 22 10.3123 21.9989 10M13.1992 21H10C9.24401 21 8.59006 21 8.01712 20.9893M21.9989 10H21C19.607 10 18.9104 10 18.324 10.0603C12.9031 10.6176 8.61758 14.9031 8.06029 20.324C8.03963 20.5249 8.02605 20.7388 8.01712 20.9893M21.9989 10C21.9912 7.84993 21.9309 6.66397 21.455 5.73005C20.9757 4.78924 20.2108 4.02433 19.27 3.54497C18.2004 3 16.8003 3 14 3H10C7.19974 3 5.79961 3 4.73005 3.54497C3.78924 4.02433 3.02433 4.78924 2.54497 5.73005C2 6.79961 2 8.19974 2 11V13C2 15.8003 2 17.2004 2.54497 18.27C3.02433 19.2108 3.78924 19.9757 4.73005 20.455C5.51086 20.8529 6.46784 20.9603 8.01712 20.9893M7.5 9.5C6.94772 9.5 6.5 9.05228 6.5 8.5C6.5 7.94772 6.94772 7.5 7.5 7.5C8.05228 7.5 8.5 7.94772 8.5 8.5C8.5 9.05228 8.05228 9.5 7.5 9.5Z' })));
9
- };
10
-
11
- export { ImageErrorIcon as I };
@@ -1,18 +0,0 @@
1
- import { S as SignalType } from './index-DbfrGXPH.js';
2
-
3
- const MONITORS_OPTIONS = [
4
- {
5
- id: SignalType.Logs,
6
- value: 'Logs',
7
- },
8
- {
9
- id: SignalType.Metrics,
10
- value: 'Metrics',
11
- },
12
- {
13
- id: SignalType.Traces,
14
- value: 'Traces',
15
- },
16
- ];
17
-
18
- export { MONITORS_OPTIONS as M };
@@ -1,52 +0,0 @@
1
- var DestinationTypes;
2
- (function (DestinationTypes) {
3
- DestinationTypes["AppDynamics"] = "appdynamics";
4
- DestinationTypes["Axiom"] = "axiom";
5
- DestinationTypes["AzureBlob"] = "azureblob";
6
- DestinationTypes["BetterStack"] = "betterstack";
7
- DestinationTypes["Causely"] = "causely";
8
- DestinationTypes["Chronosphere"] = "chronosphere";
9
- DestinationTypes["ClickHouse"] = "clickhouse";
10
- DestinationTypes["CloudWatch"] = "cloudwatch";
11
- DestinationTypes["Coralogix"] = "coralogix";
12
- DestinationTypes["Dash0"] = "dash0";
13
- DestinationTypes["Datadog"] = "datadog";
14
- DestinationTypes["Dynatrace"] = "dynatrace";
15
- DestinationTypes["ElasticApm"] = "elasticapm";
16
- DestinationTypes["ElasticSearch"] = "elasticsearch";
17
- DestinationTypes["GoogleCloud"] = "googlecloud";
18
- DestinationTypes["GrafanaCloudLoki"] = "grafanacloudloki";
19
- DestinationTypes["GrafanaCloudPrometheus"] = "grafanacloudprometheus";
20
- DestinationTypes["GrafanaCloudTempo"] = "grafanacloudtempo";
21
- DestinationTypes["Groundcover"] = "groundcover";
22
- DestinationTypes["Honeycomb"] = "honeycomb";
23
- DestinationTypes["HyperDX"] = "hyperdx";
24
- DestinationTypes["Instana"] = "instana";
25
- DestinationTypes["Jaeger"] = "jaeger";
26
- DestinationTypes["Kafka"] = "kafka";
27
- DestinationTypes["Kloudmate"] = "kloudmate";
28
- DestinationTypes["Last9"] = "last9";
29
- DestinationTypes["Lightstep"] = "lightstep";
30
- DestinationTypes["LogzIo"] = "logzio";
31
- DestinationTypes["Loki"] = "loki";
32
- DestinationTypes["Lumigo"] = "lumigo";
33
- DestinationTypes["Middleware"] = "middleware";
34
- DestinationTypes["NewRelic"] = "newrelic";
35
- DestinationTypes["Opsverse"] = "opsverse";
36
- DestinationTypes["OTLP"] = "otlp";
37
- DestinationTypes["OTLPHttp"] = "otlphttp";
38
- DestinationTypes["Prometheus"] = "prometheus";
39
- DestinationTypes["Qryn"] = "qryn";
40
- DestinationTypes["QrynOss"] = "qryn-oss";
41
- DestinationTypes["Quickwit"] = "quickwit";
42
- DestinationTypes["S3"] = "s3";
43
- DestinationTypes["Signoz"] = "signoz";
44
- DestinationTypes["Splunk"] = "splunk";
45
- DestinationTypes["SumoLogic"] = "sumologic";
46
- DestinationTypes["Tempo"] = "tempo";
47
- DestinationTypes["Traceloop"] = "traceloop";
48
- DestinationTypes["Uptrace"] = "uptrace";
49
- DestinationTypes["XRay"] = "xray";
50
- })(DestinationTypes || (DestinationTypes = {}));
51
-
52
- export { DestinationTypes as D };
@@ -1,8 +0,0 @@
1
- var SignalType;
2
- (function (SignalType) {
3
- SignalType["Logs"] = "logs";
4
- SignalType["Metrics"] = "metrics";
5
- SignalType["Traces"] = "traces";
6
- })(SignalType || (SignalType = {}));
7
-
8
- export { SignalType as S };
@@ -1,37 +0,0 @@
1
- var ActionType;
2
- (function (ActionType) {
3
- ActionType["K8sAttributes"] = "K8sAttributesResolver";
4
- ActionType["AddClusterInfo"] = "AddClusterInfo";
5
- ActionType["DeleteAttributes"] = "DeleteAttribute";
6
- ActionType["RenameAttributes"] = "RenameAttribute";
7
- ActionType["ErrorSampler"] = "ErrorSampler";
8
- ActionType["ProbabilisticSampler"] = "ProbabilisticSampler";
9
- ActionType["LatencySampler"] = "LatencySampler";
10
- ActionType["PiiMasking"] = "PiiMasking";
11
- })(ActionType || (ActionType = {}));
12
-
13
- var InstrumentationRuleType;
14
- (function (InstrumentationRuleType) {
15
- InstrumentationRuleType["PayloadCollection"] = "PayloadCollection";
16
- InstrumentationRuleType["CodeAttributes"] = "CodeAttributes";
17
- InstrumentationRuleType["UnknownType"] = "UnknownType";
18
- })(InstrumentationRuleType || (InstrumentationRuleType = {}));
19
- var PayloadCollectionKeyTypes;
20
- (function (PayloadCollectionKeyTypes) {
21
- PayloadCollectionKeyTypes["HttpRequest"] = "httpRequest";
22
- PayloadCollectionKeyTypes["HttpResponse"] = "httpResponse";
23
- PayloadCollectionKeyTypes["DbQuery"] = "dbQuery";
24
- PayloadCollectionKeyTypes["Messaging"] = "messaging";
25
- })(PayloadCollectionKeyTypes || (PayloadCollectionKeyTypes = {}));
26
- // Code Attributes for Instrumentation Rules
27
- var CodeAttributesKeyTypes;
28
- (function (CodeAttributesKeyTypes) {
29
- CodeAttributesKeyTypes["Column"] = "column";
30
- CodeAttributesKeyTypes["FilePath"] = "filePath";
31
- CodeAttributesKeyTypes["Function"] = "function";
32
- CodeAttributesKeyTypes["LineNumber"] = "lineNumber";
33
- CodeAttributesKeyTypes["Namespace"] = "namespace";
34
- CodeAttributesKeyTypes["StackTrace"] = "stacktrace";
35
- })(CodeAttributesKeyTypes || (CodeAttributesKeyTypes = {}));
36
-
37
- export { ActionType as A, CodeAttributesKeyTypes as C, InstrumentationRuleType as I, PayloadCollectionKeyTypes as P };
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
-
3
- const createStoreImpl = (createState) => {
4
- let state;
5
- const listeners = /* @__PURE__ */ new Set();
6
- const setState = (partial, replace) => {
7
- const nextState = typeof partial === "function" ? partial(state) : partial;
8
- if (!Object.is(nextState, state)) {
9
- const previousState = state;
10
- state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
11
- listeners.forEach((listener) => listener(state, previousState));
12
- }
13
- };
14
- const getState = () => state;
15
- const getInitialState = () => initialState;
16
- const subscribe = (listener) => {
17
- listeners.add(listener);
18
- return () => listeners.delete(listener);
19
- };
20
- const api = { setState, getState, getInitialState, subscribe };
21
- const initialState = state = createState(setState, getState, api);
22
- return api;
23
- };
24
- const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
25
-
26
- const identity = (arg) => arg;
27
- function useStore(api, selector = identity) {
28
- const slice = React.useSyncExternalStore(
29
- api.subscribe,
30
- () => selector(api.getState()),
31
- () => selector(api.getInitialState())
32
- );
33
- React.useDebugValue(slice);
34
- return slice;
35
- }
36
- const createImpl = (createState) => {
37
- const api = createStore(createState);
38
- const useBoundStore = (selector) => useStore(api, selector);
39
- Object.assign(useBoundStore, api);
40
- return useBoundStore;
41
- };
42
- const create = (createState) => createState ? createImpl(createState) : createImpl;
43
-
44
- export { create as c };
@@ -1,201 +0,0 @@
1
- import { c as create } from './react-CjImwkhV.js';
2
-
3
- function createJSONStorage(getStorage, options) {
4
- let storage;
5
- try {
6
- storage = getStorage();
7
- } catch (e) {
8
- return;
9
- }
10
- const persistStorage = {
11
- getItem: (name) => {
12
- var _a;
13
- const parse = (str2) => {
14
- if (str2 === null) {
15
- return null;
16
- }
17
- return JSON.parse(str2, undefined );
18
- };
19
- const str = (_a = storage.getItem(name)) != null ? _a : null;
20
- if (str instanceof Promise) {
21
- return str.then(parse);
22
- }
23
- return parse(str);
24
- },
25
- setItem: (name, newValue) => storage.setItem(
26
- name,
27
- JSON.stringify(newValue, undefined )
28
- ),
29
- removeItem: (name) => storage.removeItem(name)
30
- };
31
- return persistStorage;
32
- }
33
- const toThenable = (fn) => (input) => {
34
- try {
35
- const result = fn(input);
36
- if (result instanceof Promise) {
37
- return result;
38
- }
39
- return {
40
- then(onFulfilled) {
41
- return toThenable(onFulfilled)(result);
42
- },
43
- catch(_onRejected) {
44
- return this;
45
- }
46
- };
47
- } catch (e) {
48
- return {
49
- then(_onFulfilled) {
50
- return this;
51
- },
52
- catch(onRejected) {
53
- return toThenable(onRejected)(e);
54
- }
55
- };
56
- }
57
- };
58
- const persistImpl = (config, baseOptions) => (set, get, api) => {
59
- let options = {
60
- storage: createJSONStorage(() => localStorage),
61
- partialize: (state) => state,
62
- version: 0,
63
- merge: (persistedState, currentState) => ({
64
- ...currentState,
65
- ...persistedState
66
- }),
67
- ...baseOptions
68
- };
69
- let hasHydrated = false;
70
- const hydrationListeners = /* @__PURE__ */ new Set();
71
- const finishHydrationListeners = /* @__PURE__ */ new Set();
72
- let storage = options.storage;
73
- if (!storage) {
74
- return config(
75
- (...args) => {
76
- console.warn(
77
- `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
78
- );
79
- set(...args);
80
- },
81
- get,
82
- api
83
- );
84
- }
85
- const setItem = () => {
86
- const state = options.partialize({ ...get() });
87
- return storage.setItem(options.name, {
88
- state,
89
- version: options.version
90
- });
91
- };
92
- const savedSetState = api.setState;
93
- api.setState = (state, replace) => {
94
- savedSetState(state, replace);
95
- void setItem();
96
- };
97
- const configResult = config(
98
- (...args) => {
99
- set(...args);
100
- void setItem();
101
- },
102
- get,
103
- api
104
- );
105
- api.getInitialState = () => configResult;
106
- let stateFromStorage;
107
- const hydrate = () => {
108
- var _a, _b;
109
- if (!storage) return;
110
- hasHydrated = false;
111
- hydrationListeners.forEach((cb) => {
112
- var _a2;
113
- return cb((_a2 = get()) != null ? _a2 : configResult);
114
- });
115
- const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? undefined : _b.call(options, (_a = get()) != null ? _a : configResult)) || undefined;
116
- return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
117
- if (deserializedStorageValue) {
118
- if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
119
- if (options.migrate) {
120
- const migration = options.migrate(
121
- deserializedStorageValue.state,
122
- deserializedStorageValue.version
123
- );
124
- if (migration instanceof Promise) {
125
- return migration.then((result) => [true, result]);
126
- }
127
- return [true, migration];
128
- }
129
- console.error(
130
- `State loaded from storage couldn't be migrated since no migrate function was provided`
131
- );
132
- } else {
133
- return [false, deserializedStorageValue.state];
134
- }
135
- }
136
- return [false, undefined];
137
- }).then((migrationResult) => {
138
- var _a2;
139
- const [migrated, migratedState] = migrationResult;
140
- stateFromStorage = options.merge(
141
- migratedState,
142
- (_a2 = get()) != null ? _a2 : configResult
143
- );
144
- set(stateFromStorage, true);
145
- if (migrated) {
146
- return setItem();
147
- }
148
- }).then(() => {
149
- postRehydrationCallback == null ? undefined : postRehydrationCallback(stateFromStorage, undefined);
150
- stateFromStorage = get();
151
- hasHydrated = true;
152
- finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
153
- }).catch((e) => {
154
- postRehydrationCallback == null ? undefined : postRehydrationCallback(undefined, e);
155
- });
156
- };
157
- api.persist = {
158
- setOptions: (newOptions) => {
159
- options = {
160
- ...options,
161
- ...newOptions
162
- };
163
- if (newOptions.storage) {
164
- storage = newOptions.storage;
165
- }
166
- },
167
- clearStorage: () => {
168
- storage == null ? undefined : storage.removeItem(options.name);
169
- },
170
- getOptions: () => options,
171
- rehydrate: () => hydrate(),
172
- hasHydrated: () => hasHydrated,
173
- onHydrate: (cb) => {
174
- hydrationListeners.add(cb);
175
- return () => {
176
- hydrationListeners.delete(cb);
177
- };
178
- },
179
- onFinishHydration: (cb) => {
180
- finishHydrationListeners.add(cb);
181
- return () => {
182
- finishHydrationListeners.delete(cb);
183
- };
184
- }
185
- };
186
- if (!options.skipHydration) {
187
- hydrate();
188
- }
189
- return stateFromStorage || configResult;
190
- };
191
- const persist = persistImpl;
192
-
193
- const useDarkMode = create()(persist((set) => ({
194
- darkMode: true,
195
- setDarkMode: (bool) => set({ darkMode: bool }),
196
- }), {
197
- name: 'odigos-dark-mode',
198
- storage: typeof window !== 'undefined' ? createJSONStorage(() => localStorage) : undefined,
199
- }));
200
-
201
- export { useDarkMode as u };
@@ -1,97 +0,0 @@
1
- import { c as create } from './react-CjImwkhV.js';
2
- import { E as EntityTypes } from './index-BVVVevuY.js';
3
-
4
- const getEmptyState = () => ({
5
- searchText: '',
6
- statuses: [],
7
- platformTypes: [],
8
- namespaces: [],
9
- kinds: [],
10
- monitors: [],
11
- languages: [],
12
- errors: [],
13
- onlyErrors: false,
14
- });
15
- const useFilterStore = create((set) => ({
16
- searchText: '',
17
- setSearchText: (searchText) => set({ searchText }),
18
- statuses: [],
19
- setStatuses: (statuses) => set({ statuses }),
20
- platformTypes: [],
21
- setPlatformTypes: (platformTypes) => set({ platformTypes }),
22
- namespaces: [],
23
- setNamespaces: (namespaces) => set({ namespaces }),
24
- kinds: [],
25
- setKinds: (kinds) => set({ kinds }),
26
- monitors: [],
27
- setMonitors: (monitors) => set({ monitors }),
28
- languages: [],
29
- setLanguages: (languages) => set({ languages }),
30
- errors: [],
31
- setErrors: (errors) => set({ errors }),
32
- onlyErrors: false,
33
- setOnlyErrors: (onlyErrors) => set({ onlyErrors }),
34
- setAll: (params) => set(params),
35
- clearAll: () => set(getEmptyState()),
36
- getEmptyState,
37
- }));
38
-
39
- const useInstrumentStore = create((set) => ({
40
- isAwaitingInstrumentation: false,
41
- sourcesToCreate: 0,
42
- sourcesCreated: 0,
43
- sourcesToDelete: 0,
44
- sourcesDeleted: 0,
45
- setInstrumentAwait: (v) => set({ isAwaitingInstrumentation: v }),
46
- setInstrumentCount: (k, v) => set({ [k]: v }),
47
- }));
48
-
49
- const itemsAreEqual = (item1, item2) => {
50
- const entityTypesEqual = item1.entityType === item2.entityType;
51
- const idsEqual = typeof item1.entityId === 'string' && typeof item2.entityId === 'string'
52
- ? item1.entityId === item2.entityId
53
- : typeof item1.entityId === 'object' && typeof item2.entityId === 'object'
54
- ? item1.entityId.namespace === item2.entityId.namespace && item1.entityId.name === item2.entityId.name && item1.entityId.kind === item2.entityId.kind
55
- : !item1.entityId && !item2.entityId;
56
- return entityTypesEqual && idsEqual;
57
- };
58
- const usePendingStore = create((set, get) => ({
59
- pendingItems: [],
60
- setPendingItems: (arr) => set({ pendingItems: arr }),
61
- addPendingItems: (arr) => set((state) => ({
62
- pendingItems: state.pendingItems.concat(arr.filter((addItem) => !state.pendingItems.some((existingItem) => itemsAreEqual(existingItem, addItem)))),
63
- })),
64
- removePendingItems: (arr) => set((state) => ({
65
- pendingItems: state.pendingItems.filter((existingItem) => !arr.find((removeItem) => itemsAreEqual(existingItem, removeItem))),
66
- })),
67
- // Pass an item to check if it's in the pending items array.
68
- // This is used to show loading spinners, toasts etc.
69
- isThisPending: (item) => {
70
- const { pendingItems } = get();
71
- let bool = false;
72
- for (let i = 0; i < pendingItems.length; i++) {
73
- const pendingItem = pendingItems[i];
74
- if (pendingItem.entityType === item.entityType &&
75
- (!item.entityId ||
76
- (pendingItem.entityType === EntityTypes.Source
77
- ? !!pendingItem.entityId &&
78
- !!item.entityId &&
79
- pendingItem.entityId.namespace === item.entityId.namespace &&
80
- pendingItem.entityId.name === item.entityId.name &&
81
- pendingItem.entityId.kind === item.entityId.kind
82
- : pendingItem.entityId === item.entityId))) {
83
- bool = true;
84
- break;
85
- }
86
- }
87
- return bool;
88
- },
89
- }));
90
-
91
- const useSelectedStore = create((set) => ({
92
- selectedSources: {},
93
- setSelectedSources: (payload) => set({ selectedSources: payload }),
94
- resetSelectedState: () => set(() => ({ selectedSources: {} })),
95
- }));
96
-
97
- export { useInstrumentStore as a, usePendingStore as b, useSelectedStore as c, useFilterStore as u };