@cccsaurora/clue-ui 0.15.0 → 1.0.0-dev.49
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/ActionForm-c5hLIfQ-.js +436 -0
- package/AnnotationPreview-BvNpZOP0.js +188 -0
- package/ClueEnrichContext-m-4vn9rz.js +518 -0
- package/FlexOne-BSYAhhtG.js +9 -0
- package/_Map-kgDsDYxq.js +64 -0
- package/_MapCache-DabaaWfq.js +161 -0
- package/_Uint8Array-BlVVH1tp.js +129 -0
- package/_baseAssignValue-CNbcU6Nb.js +25 -0
- package/_baseClone-D3a8Pa4T.js +284 -0
- package/_baseExtremum-B1o1zHjR.js +33 -0
- package/_baseFlatten-D4huXoEI.js +92 -0
- package/_baseGet-BSK_nnoz.js +109 -0
- package/_baseIsEqual-B5xLoweL.js +238 -0
- package/_baseIteratee-p6Nj07-n.js +126 -0
- package/_baseSlice-GAv_YFTT.js +20 -0
- package/_baseSum-D0WC1dN0.js +13 -0
- package/_baseUniq-CpupKWcL.js +89 -0
- package/_commonjsHelpers-CUmg6egw.js +6 -0
- package/_createAggregator-BpVy5xMi.js +63 -0
- package/_getPrototype-D1LAdQKO.js +5 -0
- package/_getTag-D3ToyefI.js +126 -0
- package/api/lookup/enrich.d.ts +10 -0
- package/api/lookup/index.d.ts +5 -0
- package/api/lookup/types.d.ts +5 -0
- package/api/lookup/types_detection.d.ts +5 -0
- package/cloneDeep-CjP5k9zW.js +8 -0
- package/components/AnnotationBody.d.ts +6 -0
- package/components/AnnotationBody.js +56 -0
- package/components/AnnotationDetailPopover.d.ts +14 -0
- package/components/AnnotationDetailPopover.js +61 -0
- package/components/AnnotationDetails.d.ts +8 -0
- package/components/AnnotationDetails.js +172 -0
- package/components/AnnotationEntry.d.ts +6 -0
- package/components/AnnotationEntry.js +59 -0
- package/components/AnnotationPreview.d.ts +14 -0
- package/components/AnnotationPreview.js +11 -0
- package/components/ClassificationChip.d.ts +11 -0
- package/components/ClassificationChip.js +52 -0
- package/components/CountBadge.d.ts +8 -0
- package/components/CountBadge.js +34 -0
- package/components/EnrichedCard.d.ts +14 -0
- package/components/EnrichedCard.js +162 -0
- package/components/EnrichedChip.d.ts +9 -0
- package/components/EnrichedChip.js +176 -0
- package/components/EnrichedTypography.d.ts +16 -0
- package/components/EnrichedTypography.js +178 -0
- package/components/ErrorBoundary.d.ts +15 -0
- package/components/ErrorBoundary.js +36 -0
- package/components/RetryFailedEnrichments.d.ts +2 -0
- package/components/RetryFailedEnrichments.js +13 -0
- package/components/SourcePicker.d.ts +2 -0
- package/components/SourcePicker.js +98 -0
- package/components/actions/ActionForm.d.ts +6 -0
- package/components/actions/ActionForm.js +16 -0
- package/components/actions/ExecutePopover.d.ts +10 -0
- package/components/actions/ExecutePopover.js +93 -0
- package/components/actions/ResultModal.d.ts +9 -0
- package/components/actions/ResultModal.js +46 -0
- package/components/actions/form/schemaAdapter.d.ts +3 -0
- package/components/actions/form/schemaAdapter.js +47 -0
- package/components/display/graph/ExpandMoreButton.d.ts +7 -0
- package/components/display/graph/ExpandMoreButton.js +18 -0
- package/components/display/graph/elements/NodeCard.d.ts +10 -0
- package/components/display/graph/elements/NodeCard.js +146 -0
- package/components/display/graph/elements/NodeTag.d.ts +9 -0
- package/components/display/graph/elements/NodeTag.js +17 -0
- package/components/display/graph/index.d.ts +9 -0
- package/components/display/graph/index.js +438 -0
- package/components/display/graph/visualizations/Leaf.d.ts +25 -0
- package/components/display/graph/visualizations/Leaf.js +125 -0
- package/components/display/graph/visualizations/cloud/index.d.ts +24 -0
- package/components/display/graph/visualizations/cloud/index.js +141 -0
- package/components/display/graph/visualizations/icons/BaseIcon.d.ts +12 -0
- package/components/display/graph/visualizations/icons/BaseIcon.js +37 -0
- package/components/display/graph/visualizations/icons/BugIcon.d.ts +5 -0
- package/components/display/graph/visualizations/icons/BugIcon.js +18 -0
- package/components/display/graph/visualizations/icons/HostIcon.d.ts +5 -0
- package/components/display/graph/visualizations/icons/HostIcon.js +24 -0
- package/components/display/graph/visualizations/icons/NetworkIcon.d.ts +5 -0
- package/components/display/graph/visualizations/icons/NetworkIcon.js +24 -0
- package/components/display/graph/visualizations/icons/ProcessIcon.d.ts +5 -0
- package/components/display/graph/visualizations/icons/ProcessIcon.js +18 -0
- package/components/display/graph/visualizations/icons/TargetIcon.d.ts +5 -0
- package/components/display/graph/visualizations/icons/TargetIcon.js +19 -0
- package/components/display/graph/visualizations/icons/index.d.ts +2 -0
- package/components/display/graph/visualizations/icons/index.js +16 -0
- package/components/display/graph/visualizations/panels/NodePanel.d.ts +8 -0
- package/components/display/graph/visualizations/panels/NodePanel.js +12 -0
- package/components/display/graph/visualizations/tree/BundleLine.d.ts +29 -0
- package/components/display/graph/visualizations/tree/BundleLine.js +121 -0
- package/components/display/graph/visualizations/tree/Triangle.d.ts +9 -0
- package/components/display/graph/visualizations/tree/Triangle.js +26 -0
- package/components/display/graph/visualizations/tree/index.d.ts +36 -0
- package/components/display/graph/visualizations/tree/index.js +485 -0
- package/components/display/graph/visualizations/tree/types.d.ts +11 -0
- package/components/display/graph/visualizations/tree/types.js +1 -0
- package/components/display/icons/Iconified.d.ts +9 -0
- package/components/display/icons/Iconified.js +29 -0
- package/components/display/json/index.d.ts +14 -0
- package/components/display/json/index.js +12 -0
- package/components/display/markdown/DynamicTabs.d.ts +8 -0
- package/components/display/markdown/DynamicTabs.js +26 -0
- package/components/display/markdown/index.d.ts +9 -0
- package/components/display/markdown/index.js +13389 -0
- package/components/display/markdown/markdownPlugins/tabs.d.ts +3 -0
- package/components/display/markdown/markdownPlugins/tabs.js +4 -0
- package/components/enrichment/EnrichPopover.d.ts +10 -0
- package/components/enrichment/EnrichPopover.js +88 -0
- package/components/fetchers/Fetcher.d.ts +17 -0
- package/components/fetchers/Fetcher.js +188 -0
- package/components/fetchers/PreviewModal.d.ts +8 -0
- package/components/fetchers/PreviewModal.js +22 -0
- package/components/fetchers/StatusChip.d.ts +8 -0
- package/components/fetchers/StatusChip.js +30 -0
- package/components/group/Entry.d.ts +8 -0
- package/components/group/Entry.js +15 -0
- package/components/group/Group.d.ts +12 -0
- package/components/group/Group.js +15 -0
- package/components/group/GroupControl.d.ts +4 -0
- package/components/group/GroupControl.js +103 -0
- package/components/stats/QueryStatus.d.ts +4 -0
- package/components/stats/QueryStatus.js +61 -0
- package/countBy-C69WslUA.js +14 -0
- package/data/event.d.ts +12 -0
- package/data/event.js +8 -0
- package/database/index.d.ts +4 -0
- package/database/index.js +4 -0
- package/database/selector.schema.json.d.ts +119 -0
- package/database/status.schema.json.d.ts +38 -0
- package/database/types.d.ts +64 -0
- package/debounce-bV0h5FC5.js +92 -0
- package/en/translation.json +135 -0
- package/fr/translation.json +134 -0
- package/get-D3C3lEU3.js +8 -0
- package/groupBy-DC2oOuBN.js +14 -0
- package/hooks/ClueActionContext.d.ts +86 -0
- package/hooks/ClueActionContext.js +18 -0
- package/hooks/ClueComponentContext.d.ts +10 -0
- package/hooks/ClueComponentContext.js +40 -0
- package/hooks/ClueConfigProvider.d.ts +12 -0
- package/hooks/ClueConfigProvider.js +23 -0
- package/hooks/ClueDatabaseContext.d.ts +10 -0
- package/hooks/ClueDatabaseContext.js +23 -0
- package/hooks/ClueEnrichContext.d.ts +6 -0
- package/hooks/ClueEnrichContext.js +15 -0
- package/hooks/ClueEnrichContextType.d.ts +113 -0
- package/hooks/ClueEnrichProps.d.ts +81 -0
- package/hooks/ClueFetcherContext.d.ts +35 -0
- package/hooks/ClueFetcherContext.js +88 -0
- package/hooks/ClueGroupContext.d.ts +14 -0
- package/hooks/ClueGroupContext.js +23 -0
- package/hooks/CluePopupContext.d.ts +24 -0
- package/hooks/CluePopupContext.js +12 -0
- package/hooks/ClueProvider.d.ts +9 -0
- package/hooks/ClueProvider.js +14 -0
- package/hooks/selectors.d.ts +10 -0
- package/hooks/selectors.js +24 -0
- package/hooks/useAnnotations.d.ts +24 -0
- package/hooks/useAnnotations.js +69 -0
- package/hooks/useClue.d.ts +4 -0
- package/hooks/useClue.js +8 -0
- package/hooks/useClueActions.d.ts +4 -0
- package/hooks/useClueActions.js +5 -0
- package/hooks/useClueConfig.d.ts +1 -0
- package/hooks/useClueConfig.js +8 -0
- package/hooks/useClueTypeConfig.d.ts +17 -0
- package/hooks/useClueTypeConfig.js +7 -0
- package/hooks/useComparator.d.ts +16 -0
- package/hooks/useComparator.js +1060 -0
- package/hooks/useErrors.d.ts +17 -0
- package/hooks/useErrors.js +35 -0
- package/hooks/useMyHighlights.d.ts +11 -0
- package/hooks/useMyHighlights.js +74 -0
- package/hooks/useMyLocalStorage.d.ts +16 -0
- package/hooks/useMyLocalStorage.js +80 -0
- package/iconify-CXMreGTg.js +1782 -0
- package/icons/Action.d.ts +9 -0
- package/icons/Action.js +90 -0
- package/icons/Assessment.d.ts +11 -0
- package/icons/Assessment.js +123 -0
- package/icons/Context.d.ts +12 -0
- package/icons/Context.js +83 -0
- package/icons/Opinion.d.ts +11 -0
- package/icons/Opinion.js +125 -0
- package/icons/iconMap.d.ts +7 -0
- package/icons/iconMap.js +10 -0
- package/identity-CPGTqrE4.js +6 -0
- package/index-BDVjGvMI.js +696 -0
- package/index-BDrtH5ec.js +465 -0
- package/index-BbPn6-Mw.js +15750 -0
- package/index-C9lySIVX.js +1172 -0
- package/index-Dn2NHyXg.js +17654 -0
- package/index.css +21 -0
- package/isEmpty-BQkZubqU.js +29 -0
- package/isNil-CIubwp4T.js +6 -0
- package/isObject-FTY-5JQX.js +7 -0
- package/isObjectLike-OAgjjZye.js +48 -0
- package/isSymbol-Xd2FsJyp.js +8 -0
- package/isUndefined-CE8h73dH.js +10 -0
- package/last-CUCl67Im.js +7 -0
- package/main.d.ts +42 -0
- package/main.js +70 -0
- package/package.json +39 -143
- package/public/manifest.json +16 -0
- package/public/robots.txt +3 -0
- package/public/svg/dark/clue-h.svg +52 -0
- package/public/svg/dark/clue-icon1-simple.svg +33 -0
- package/public/svg/dark/clue-icon1.svg +44 -0
- package/public/svg/dark/clue-icon2-simple.svg +26 -0
- package/public/svg/dark/clue-icon2.svg +37 -0
- package/public/svg/dark/clue-name.svg +14 -0
- package/public/svg/dark/clue-v.svg +52 -0
- package/public/svg/light/clue-h.svg +60 -0
- package/public/svg/light/clue-icon1-simple.svg +37 -0
- package/public/svg/light/clue-icon1.svg +48 -0
- package/public/svg/light/clue-icon2-simple.svg +30 -0
- package/public/svg/light/clue-icon2.svg +41 -0
- package/public/svg/light/clue-name.svg +14 -0
- package/public/svg/light/clue-v.svg +60 -0
- package/sortBy-B-UKp4GT.js +100 -0
- package/sumBy-MYkDPHZL.js +8 -0
- package/tabs-xGuUGsJd.js +254 -0
- package/text/Frequency.d.ts +9 -0
- package/text/Frequency.js +49 -0
- package/toFinite-Bc55msYj.js +16 -0
- package/toNumber-DPxy1FBy.js +39 -0
- package/types/EnrichmentProps.d.ts +73 -0
- package/types/RunningActionData.d.ts +15 -0
- package/types/WithActionData.d.ts +9 -0
- package/types/action.d.ts +25 -0
- package/types/config.d.ts +16 -0
- package/types/fetcher.d.ts +60 -0
- package/types/graph.d.ts +101 -0
- package/types/lookup.d.ts +62 -0
- package/types/network.d.ts +9 -0
- package/useClueTypeConfig-D4zcy8Gr.js +3184 -0
- package/utils/chain.d.ts +14 -0
- package/utils/chain.js +106 -0
- package/utils/classificationParser.d.ts +195 -0
- package/utils/classificationParser.js +553 -0
- package/utils/constants.d.ts +27 -0
- package/utils/constants.js +37 -0
- package/utils/graph.d.ts +13 -0
- package/utils/graph.js +79 -0
- package/utils/hashUtil.d.ts +6 -0
- package/utils/hashUtil.js +11 -0
- package/utils/line.d.ts +28 -0
- package/utils/line.js +136 -0
- package/utils/loggerUtil.d.ts +6 -0
- package/utils/loggerUtil.js +8 -0
- package/utils/sessionStorage.d.ts +9 -0
- package/utils/sessionStorage.js +51 -0
- package/utils/utils.d.ts +13 -0
- package/utils/utils.js +11 -0
- package/utils/window.d.ts +3 -0
- package/utils/window.js +24 -0
- package/utils-CxIhC2xH.js +4182 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { materialRenderers, materialCells } from "@jsonforms/material-renderers";
|
|
3
|
+
import { JsonForms } from "@jsonforms/react";
|
|
4
|
+
import { Stack, Typography, IconButton, Modal, Paper, Box, Button, Divider, CircularProgress, Collapse } from "@mui/material";
|
|
5
|
+
import Iconified from "./components/display/icons/Iconified.js";
|
|
6
|
+
import { J as JSONViewer } from "./index-BDrtH5ec.js";
|
|
7
|
+
import { ClueComponentContext } from "./hooks/ClueComponentContext.js";
|
|
8
|
+
import { c as createContext, u as useContextSelector, a as useContext } from "./index-BDVjGvMI.js";
|
|
9
|
+
import { A as Ajv } from "./index-Dn2NHyXg.js";
|
|
10
|
+
import { a as api } from "./useClueTypeConfig-D4zcy8Gr.js";
|
|
11
|
+
import { useState, useCallback, useEffect, useMemo, memo } from "react";
|
|
12
|
+
import ErrorBoundary from "./components/ErrorBoundary.js";
|
|
13
|
+
import { adaptSchema } from "./components/actions/form/schemaAdapter.js";
|
|
14
|
+
import { d as toString } from "./_baseGet-BSK_nnoz.js";
|
|
15
|
+
import { b as baseSlice } from "./_baseSlice-GAv_YFTT.js";
|
|
16
|
+
import { i as isEqual } from "./utils-CxIhC2xH.js";
|
|
17
|
+
import ResultModal from "./components/actions/ResultModal.js";
|
|
18
|
+
import { SNACKBAR_EVENT_ID } from "./data/event.js";
|
|
19
|
+
import { safeDispatchEvent } from "./utils/window.js";
|
|
20
|
+
import useClue from "./hooks/useClue.js";
|
|
21
|
+
function castSlice(array, start, end) {
|
|
22
|
+
var length = array.length;
|
|
23
|
+
end = end === void 0 ? length : end;
|
|
24
|
+
return !start && end >= length ? array : baseSlice(array, start, end);
|
|
25
|
+
}
|
|
26
|
+
var rsAstralRange$1 = "\\ud800-\\udfff", rsComboMarksRange$1 = "\\u0300-\\u036f", reComboHalfMarksRange$1 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$1 = "\\u20d0-\\u20ff", rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1, rsVarRange$1 = "\\ufe0e\\ufe0f";
|
|
27
|
+
var rsZWJ$1 = "\\u200d";
|
|
28
|
+
var reHasUnicode = RegExp("[" + rsZWJ$1 + rsAstralRange$1 + rsComboRange$1 + rsVarRange$1 + "]");
|
|
29
|
+
function hasUnicode(string) {
|
|
30
|
+
return reHasUnicode.test(string);
|
|
31
|
+
}
|
|
32
|
+
function asciiToArray(string) {
|
|
33
|
+
return string.split("");
|
|
34
|
+
}
|
|
35
|
+
var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsVarRange = "\\ufe0e\\ufe0f";
|
|
36
|
+
var rsAstral = "[" + rsAstralRange + "]", rsCombo = "[" + rsComboRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsZWJ = "\\u200d";
|
|
37
|
+
var reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")";
|
|
38
|
+
var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
|
|
39
|
+
function unicodeToArray(string) {
|
|
40
|
+
return string.match(reUnicode) || [];
|
|
41
|
+
}
|
|
42
|
+
function stringToArray(string) {
|
|
43
|
+
return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);
|
|
44
|
+
}
|
|
45
|
+
function createCaseFirst(methodName) {
|
|
46
|
+
return function(string) {
|
|
47
|
+
string = toString(string);
|
|
48
|
+
var strSymbols = hasUnicode(string) ? stringToArray(string) : void 0;
|
|
49
|
+
var chr = strSymbols ? strSymbols[0] : string.charAt(0);
|
|
50
|
+
var trailing = strSymbols ? castSlice(strSymbols, 1).join("") : string.slice(1);
|
|
51
|
+
return chr[methodName]() + trailing;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var upperFirst = createCaseFirst("toUpperCase");
|
|
55
|
+
function capitalize(string) {
|
|
56
|
+
return upperFirst(toString(string).toLowerCase());
|
|
57
|
+
}
|
|
58
|
+
const AJV = new Ajv({ removeAdditional: true, coerceTypes: true, strict: false });
|
|
59
|
+
const ClueActionContext = createContext(null);
|
|
60
|
+
const ClueActionProvider = ({
|
|
61
|
+
baseURL,
|
|
62
|
+
children,
|
|
63
|
+
classification: defaultClassification,
|
|
64
|
+
getToken,
|
|
65
|
+
onNetworkCall
|
|
66
|
+
}) => {
|
|
67
|
+
const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
|
|
68
|
+
const { ready } = useClue();
|
|
69
|
+
const [runningActionData, setRunningActionData] = useState(null);
|
|
70
|
+
const [actionResults, setActionResults] = useState({});
|
|
71
|
+
const [showResultModal, setShowResultModal] = useState(false);
|
|
72
|
+
const [lastResult, setLastResult] = useState(null);
|
|
73
|
+
const [loading, setLoading] = useState(false);
|
|
74
|
+
const [availableActions, setAvailableActions] = useState({});
|
|
75
|
+
const refreshActions = useCallback(async () => {
|
|
76
|
+
if (!ready) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const headers = {};
|
|
80
|
+
const token = getToken == null ? void 0 : getToken();
|
|
81
|
+
if (token) {
|
|
82
|
+
headers.Authorization = `Bearer ${token}`;
|
|
83
|
+
}
|
|
84
|
+
let requestConfig = { baseURL, headers };
|
|
85
|
+
if (onNetworkCall) {
|
|
86
|
+
requestConfig = onNetworkCall(requestConfig);
|
|
87
|
+
}
|
|
88
|
+
const _actions = await api.actions.get(requestConfig);
|
|
89
|
+
if (_actions) {
|
|
90
|
+
setAvailableActions(_actions);
|
|
91
|
+
}
|
|
92
|
+
return _actions;
|
|
93
|
+
}, [baseURL, getToken, onNetworkCall, ready]);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
refreshActions();
|
|
96
|
+
}, [baseURL, ready]);
|
|
97
|
+
const getHashKey = useCallback(
|
|
98
|
+
(type, value, classification) => JSON.stringify({ type, value, classification: classification ?? defaultClassification }),
|
|
99
|
+
[defaultClassification]
|
|
100
|
+
);
|
|
101
|
+
const executeAction = useCallback(
|
|
102
|
+
async (actionId, selectors, params, options) => {
|
|
103
|
+
const { forceMenu, onComplete, skipMenu, timeout } = {
|
|
104
|
+
forceMenu: false,
|
|
105
|
+
skipMenu: false,
|
|
106
|
+
onComplete: null,
|
|
107
|
+
timeout: null,
|
|
108
|
+
...options
|
|
109
|
+
};
|
|
110
|
+
const headers = {};
|
|
111
|
+
const token = getToken == null ? void 0 : getToken();
|
|
112
|
+
if (token) {
|
|
113
|
+
headers.Authorization = `Bearer ${token}`;
|
|
114
|
+
}
|
|
115
|
+
if (!Object.keys(availableActions).includes(actionId)) {
|
|
116
|
+
throw new Error("Invalid action id");
|
|
117
|
+
}
|
|
118
|
+
const stringifiedSelectors = selectors.map(
|
|
119
|
+
(selector) => selector.type === "telemetry" ? { ...selector, value: JSON.stringify(selector.value) } : selector
|
|
120
|
+
);
|
|
121
|
+
const actionToRun = availableActions[actionId];
|
|
122
|
+
const validator = AJV.compile(actionToRun.params);
|
|
123
|
+
const validatedParams = { selectors: stringifiedSelectors, ...params };
|
|
124
|
+
setLoading(true);
|
|
125
|
+
if (!validator(validatedParams) || forceMenu) {
|
|
126
|
+
if (skipMenu && !forceMenu) {
|
|
127
|
+
console.error(`Form is not valid (${validator.errors.length} errors)`);
|
|
128
|
+
throw new Error("Form is not completed");
|
|
129
|
+
}
|
|
130
|
+
if ((runningActionData == null ? void 0 : runningActionData.id) === actionId) {
|
|
131
|
+
console.error(`Form is not valid (${validator.errors.length} errors)`);
|
|
132
|
+
safeDispatchEvent(
|
|
133
|
+
new CustomEvent(SNACKBAR_EVENT_ID, {
|
|
134
|
+
detail: {
|
|
135
|
+
message: t("action.error.validation"),
|
|
136
|
+
level: "error"
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
setRunningActionData({
|
|
142
|
+
id: actionId,
|
|
143
|
+
action: actionToRun,
|
|
144
|
+
selectors,
|
|
145
|
+
params: validatedParams ?? {},
|
|
146
|
+
onComplete,
|
|
147
|
+
timeout
|
|
148
|
+
});
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
let requestConfig = { baseURL, headers };
|
|
153
|
+
if (onNetworkCall) {
|
|
154
|
+
requestConfig = onNetworkCall(requestConfig);
|
|
155
|
+
}
|
|
156
|
+
const actionResult = await api.actions.post(
|
|
157
|
+
actionId,
|
|
158
|
+
stringifiedSelectors,
|
|
159
|
+
validatedParams ?? {},
|
|
160
|
+
{ timeout },
|
|
161
|
+
requestConfig
|
|
162
|
+
);
|
|
163
|
+
const actionResultWithData = { ...actionResult, actionId, action: actionToRun };
|
|
164
|
+
onComplete == null ? void 0 : onComplete(actionResultWithData);
|
|
165
|
+
setActionResults((_results) => {
|
|
166
|
+
const keys = selectors.map((value) => getHashKey(value.type, value.value, value.classification));
|
|
167
|
+
return {
|
|
168
|
+
..._results,
|
|
169
|
+
...keys.reduce(
|
|
170
|
+
(acc, key) => ({
|
|
171
|
+
...acc,
|
|
172
|
+
[key]: [..._results[key] ?? [], actionResultWithData]
|
|
173
|
+
}),
|
|
174
|
+
{}
|
|
175
|
+
)
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
safeDispatchEvent(
|
|
179
|
+
new CustomEvent(SNACKBAR_EVENT_ID, {
|
|
180
|
+
detail: {
|
|
181
|
+
message: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, width: "100%", children: [
|
|
182
|
+
/* @__PURE__ */ jsx(Typography, { children: actionResult.summary }),
|
|
183
|
+
actionResult.link && /* @__PURE__ */ jsx(IconButton, { component: "a", href: actionResult.link, size: "small", target: "_blank", children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-open-in-new", fontSize: "small" }) })
|
|
184
|
+
] }),
|
|
185
|
+
timeout: actionResult.link ? null : 5e3,
|
|
186
|
+
level: actionResult.outcome === "success" ? "success" : "error",
|
|
187
|
+
options: {
|
|
188
|
+
style: {
|
|
189
|
+
minWidth: 0
|
|
190
|
+
},
|
|
191
|
+
SnackbarProps: {
|
|
192
|
+
style: {
|
|
193
|
+
minWidth: 0
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
);
|
|
200
|
+
if (actionResult.outcome === "success") {
|
|
201
|
+
setRunningActionData(null);
|
|
202
|
+
}
|
|
203
|
+
if (actionResult.format) {
|
|
204
|
+
setLastResult({ ...actionResult, actionId, action: actionToRun });
|
|
205
|
+
if (actionResult.format !== "pivot") {
|
|
206
|
+
setShowResultModal(true);
|
|
207
|
+
} else {
|
|
208
|
+
window.open(actionResult.output, "_blank", "noreferrer");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
} catch (e) {
|
|
212
|
+
safeDispatchEvent(
|
|
213
|
+
new CustomEvent(SNACKBAR_EVENT_ID, {
|
|
214
|
+
detail: {
|
|
215
|
+
message: e.toString(),
|
|
216
|
+
level: "error"
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
);
|
|
220
|
+
} finally {
|
|
221
|
+
setLoading(false);
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
[availableActions, baseURL, getHashKey, getToken, onNetworkCall, runningActionData == null ? void 0 : runningActionData.id, t]
|
|
225
|
+
);
|
|
226
|
+
const cancelAction = useCallback(() => {
|
|
227
|
+
setRunningActionData(null);
|
|
228
|
+
setLoading(false);
|
|
229
|
+
}, []);
|
|
230
|
+
const getActionResults = useCallback(
|
|
231
|
+
(type, value, classification) => actionResults[getHashKey(type, value, classification)] ?? [],
|
|
232
|
+
[actionResults, getHashKey]
|
|
233
|
+
);
|
|
234
|
+
const context = useMemo(
|
|
235
|
+
() => ({
|
|
236
|
+
availableActions,
|
|
237
|
+
executeAction,
|
|
238
|
+
cancelAction,
|
|
239
|
+
getActionResults,
|
|
240
|
+
loading,
|
|
241
|
+
refreshActions
|
|
242
|
+
}),
|
|
243
|
+
[availableActions, cancelAction, executeAction, getActionResults, loading, refreshActions]
|
|
244
|
+
);
|
|
245
|
+
return /* @__PURE__ */ jsxs(ClueActionContext.Provider, { value: context, children: [
|
|
246
|
+
children,
|
|
247
|
+
/* @__PURE__ */ jsxs(ErrorBoundary, { children: [
|
|
248
|
+
runningActionData && /* @__PURE__ */ jsx(ActionForm$1, { runningActionData }),
|
|
249
|
+
/* @__PURE__ */ jsx(
|
|
250
|
+
ResultModal,
|
|
251
|
+
{
|
|
252
|
+
show: showResultModal && !!lastResult,
|
|
253
|
+
result: lastResult,
|
|
254
|
+
onClose: () => setShowResultModal(false)
|
|
255
|
+
}
|
|
256
|
+
)
|
|
257
|
+
] })
|
|
258
|
+
] });
|
|
259
|
+
};
|
|
260
|
+
const useClueActions = () => {
|
|
261
|
+
return useContext(ClueActionContext);
|
|
262
|
+
};
|
|
263
|
+
const WRAPPED_RENDERERS = materialRenderers.map((value) => ({
|
|
264
|
+
...value,
|
|
265
|
+
renderer: ({ ...props }) => /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(value.renderer, { ...props }) })
|
|
266
|
+
}));
|
|
267
|
+
const ActionForm = ({ runningActionData }) => {
|
|
268
|
+
const { executeAction, cancelAction } = useClueActions();
|
|
269
|
+
const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
|
|
270
|
+
const [loading, setLoading] = useState(false);
|
|
271
|
+
const [errors, setErrors] = useState(null);
|
|
272
|
+
const [formData, setFormData] = useState(runningActionData == null ? void 0 : runningActionData.params);
|
|
273
|
+
const [showFormDataJson, setShowFormDataJson] = useState(false);
|
|
274
|
+
const formSchema = useMemo(
|
|
275
|
+
() => (runningActionData == null ? void 0 : runningActionData.action) ? { ...adaptSchema(runningActionData.action.params), ...runningActionData.action.extra_schema ?? {} } : null,
|
|
276
|
+
[runningActionData == null ? void 0 : runningActionData.action]
|
|
277
|
+
);
|
|
278
|
+
const uiSchema = useMemo(
|
|
279
|
+
() => ({
|
|
280
|
+
type: "VerticalLayout",
|
|
281
|
+
elements: Object.entries((formSchema == null ? void 0 : formSchema.properties) ?? {}).sort(([a_key, a_ent], [b_key, b_ent]) => {
|
|
282
|
+
if (!!a_ent.order || !!b_ent.order) {
|
|
283
|
+
return a_ent.order - b_ent.order;
|
|
284
|
+
} else {
|
|
285
|
+
return +(formSchema == null ? void 0 : formSchema.required.includes(a_key)) - +(formSchema == null ? void 0 : formSchema.required.includes(b_key));
|
|
286
|
+
}
|
|
287
|
+
}).map(([key, value]) => ({
|
|
288
|
+
type: "Control",
|
|
289
|
+
scope: `#/properties/${key}`,
|
|
290
|
+
options: {
|
|
291
|
+
autocomplete: !!value.enum,
|
|
292
|
+
showUnfocusedDescription: true,
|
|
293
|
+
...value.options
|
|
294
|
+
},
|
|
295
|
+
rule: value.rule
|
|
296
|
+
}))
|
|
297
|
+
}),
|
|
298
|
+
[formSchema == null ? void 0 : formSchema.properties, formSchema == null ? void 0 : formSchema.required]
|
|
299
|
+
);
|
|
300
|
+
const execute = useCallback(async () => {
|
|
301
|
+
try {
|
|
302
|
+
setLoading(true);
|
|
303
|
+
const options = {};
|
|
304
|
+
if (runningActionData == null ? void 0 : runningActionData.onComplete) {
|
|
305
|
+
options.onComplete = runningActionData == null ? void 0 : runningActionData.onComplete;
|
|
306
|
+
}
|
|
307
|
+
if (runningActionData == null ? void 0 : runningActionData.timeout) {
|
|
308
|
+
options.timeout = runningActionData == null ? void 0 : runningActionData.timeout;
|
|
309
|
+
}
|
|
310
|
+
await executeAction(runningActionData == null ? void 0 : runningActionData.id, runningActionData == null ? void 0 : runningActionData.selectors, formData, options);
|
|
311
|
+
} catch (e) {
|
|
312
|
+
console.error(e);
|
|
313
|
+
} finally {
|
|
314
|
+
setLoading(false);
|
|
315
|
+
}
|
|
316
|
+
}, [
|
|
317
|
+
executeAction,
|
|
318
|
+
runningActionData == null ? void 0 : runningActionData.id,
|
|
319
|
+
runningActionData == null ? void 0 : runningActionData.selectors,
|
|
320
|
+
runningActionData == null ? void 0 : runningActionData.onComplete,
|
|
321
|
+
runningActionData == null ? void 0 : runningActionData.timeout,
|
|
322
|
+
formData
|
|
323
|
+
]);
|
|
324
|
+
if (!(runningActionData == null ? void 0 : runningActionData.action)) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
try {
|
|
328
|
+
return /* @__PURE__ */ jsx(Modal, { open: true, sx: { display: "flex", alignItems: "center", justifyContent: "center" }, onClose: cancelAction, children: /* @__PURE__ */ jsx(
|
|
329
|
+
Paper,
|
|
330
|
+
{
|
|
331
|
+
sx: { maxHeight: "80%", maxWidth: "80%", height: "100%", px: 2, pt: 2, minWidth: "750px", overflow: "auto" },
|
|
332
|
+
children: /* @__PURE__ */ jsxs(
|
|
333
|
+
Stack,
|
|
334
|
+
{
|
|
335
|
+
spacing: 1,
|
|
336
|
+
height: "100%",
|
|
337
|
+
sx: {
|
|
338
|
+
".MuiFormHelperText-root": {
|
|
339
|
+
marginLeft: "0 !important",
|
|
340
|
+
"&:last-of-type": { mb: 3 }
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
children: [
|
|
344
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, children: [
|
|
345
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "column", spacing: 1, children: [
|
|
346
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "h5", children: [
|
|
347
|
+
t("actions.executing"),
|
|
348
|
+
" ",
|
|
349
|
+
runningActionData == null ? void 0 : runningActionData.action.id.replace(/_/g, " ").split(" ").map(capitalize).join(" ")
|
|
350
|
+
] }),
|
|
351
|
+
(runningActionData == null ? void 0 : runningActionData.action.summary) && /* @__PURE__ */ jsx(Typography, { variant: "body1", color: "text.secondary", sx: { pb: 1.5 }, children: runningActionData == null ? void 0 : runningActionData.action.summary })
|
|
352
|
+
] }),
|
|
353
|
+
/* @__PURE__ */ jsx(Box, { flex: 1 }),
|
|
354
|
+
/* @__PURE__ */ jsx(Box, { alignContent: "end", children: /* @__PURE__ */ jsx(
|
|
355
|
+
Button,
|
|
356
|
+
{
|
|
357
|
+
variant: "outlined",
|
|
358
|
+
onClick: () => setShowFormDataJson((prev) => !prev),
|
|
359
|
+
startIcon: /* @__PURE__ */ jsx(
|
|
360
|
+
Box,
|
|
361
|
+
{
|
|
362
|
+
component: "span",
|
|
363
|
+
sx: (theme) => ({
|
|
364
|
+
transition: theme.transitions.create("transform"),
|
|
365
|
+
transform: showFormDataJson ? "rotate(180deg)" : "rotate(0deg)"
|
|
366
|
+
}),
|
|
367
|
+
children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-keyboard-double-arrow-right" })
|
|
368
|
+
}
|
|
369
|
+
),
|
|
370
|
+
children: !showFormDataJson ? t("actions.json.show") : t("actions.json.hide")
|
|
371
|
+
}
|
|
372
|
+
) })
|
|
373
|
+
] }),
|
|
374
|
+
/* @__PURE__ */ jsx(Divider, { orientation: "horizontal", variant: "middle" }),
|
|
375
|
+
/* @__PURE__ */ jsx(Box, { pt: 1.5 }),
|
|
376
|
+
/* @__PURE__ */ jsxs(Stack, { flexGrow: 1, direction: "row", spacing: 1, children: [
|
|
377
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "column", flexGrow: 1, children: [
|
|
378
|
+
/* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(
|
|
379
|
+
JsonForms,
|
|
380
|
+
{
|
|
381
|
+
schema: formSchema,
|
|
382
|
+
uischema: uiSchema,
|
|
383
|
+
renderers: WRAPPED_RENDERERS,
|
|
384
|
+
cells: materialCells,
|
|
385
|
+
data: formData,
|
|
386
|
+
onChange: ({ data, errors: _errors }) => {
|
|
387
|
+
if (!isEqual(data, formData)) {
|
|
388
|
+
setFormData(data);
|
|
389
|
+
}
|
|
390
|
+
setErrors(_errors);
|
|
391
|
+
},
|
|
392
|
+
config: {}
|
|
393
|
+
}
|
|
394
|
+
) }),
|
|
395
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, pb: 1, children: [
|
|
396
|
+
/* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
|
|
397
|
+
/* @__PURE__ */ jsx(Button, { color: "error", variant: "outlined", onClick: cancelAction, children: t("cancel") }),
|
|
398
|
+
/* @__PURE__ */ jsx(
|
|
399
|
+
Button,
|
|
400
|
+
{
|
|
401
|
+
color: "success",
|
|
402
|
+
variant: "outlined",
|
|
403
|
+
disabled: loading || (errors == null ? void 0 : errors.length) > 0,
|
|
404
|
+
onClick: execute,
|
|
405
|
+
endIcon: loading && /* @__PURE__ */ jsx(CircularProgress, { color: "inherit", size: 18 }),
|
|
406
|
+
children: t("actions.execute")
|
|
407
|
+
}
|
|
408
|
+
)
|
|
409
|
+
] })
|
|
410
|
+
] }),
|
|
411
|
+
/* @__PURE__ */ jsx(Collapse, { orientation: "horizontal", in: showFormDataJson, unmountOnExit: true, mountOnEnter: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "row", height: "100%", spacing: 1, children: [
|
|
412
|
+
/* @__PURE__ */ jsx(Divider, { orientation: "vertical" }),
|
|
413
|
+
/* @__PURE__ */ jsxs(Stack, { children: [
|
|
414
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h5", children: t("action.data") }),
|
|
415
|
+
/* @__PURE__ */ jsx(Box, { width: 600, height: "100%", children: /* @__PURE__ */ jsx(JSONViewer, { data: formData, slotProps: { stack: { height: "100%" }, json: { name: false } } }) })
|
|
416
|
+
] })
|
|
417
|
+
] }) })
|
|
418
|
+
] })
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
)
|
|
422
|
+
}
|
|
423
|
+
) });
|
|
424
|
+
} catch (e) {
|
|
425
|
+
console.warn(e);
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
const ActionForm$1 = memo(ActionForm);
|
|
430
|
+
export {
|
|
431
|
+
ActionForm$1 as A,
|
|
432
|
+
ClueActionProvider as C,
|
|
433
|
+
ClueActionContext as a,
|
|
434
|
+
capitalize as c,
|
|
435
|
+
useClueActions as u
|
|
436
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { I as Icon } from "./iconify-CXMreGTg.js";
|
|
3
|
+
import { useTheme, Popper, Fade, Paper, Stack, Typography, Divider } from "@mui/material";
|
|
4
|
+
import AnnotationDetailPopover from "./components/AnnotationDetailPopover.js";
|
|
5
|
+
import useAnnotations from "./hooks/useAnnotations.js";
|
|
6
|
+
import { t as twitterShort } from "./utils-CxIhC2xH.js";
|
|
7
|
+
import { useState, useRef, useCallback, useEffect, useMemo } from "react";
|
|
8
|
+
import { c as createContext, u as useContextSelector } from "./index-BDVjGvMI.js";
|
|
9
|
+
import { SHOW_EVENT_ID, HIDE_EVENT_ID } from "./data/event.js";
|
|
10
|
+
import { safeDispatchEvent, safeAddEventListener } from "./utils/window.js";
|
|
11
|
+
import { i as isNull } from "./isUndefined-CE8h73dH.js";
|
|
12
|
+
const CluePopupContext = createContext(null);
|
|
13
|
+
const CluePopupProvider = ({ children }) => {
|
|
14
|
+
const [popupType, setPopupType] = useState(null);
|
|
15
|
+
const [detailsAnchorEl, setDetailsAnchorEl] = useState(null);
|
|
16
|
+
const [detailsData, setDetailsData] = useState(null);
|
|
17
|
+
const [detailsContent, setDetailsContent] = useState(null);
|
|
18
|
+
const [popoverProps, setPopoverProps] = useState({});
|
|
19
|
+
const externalOnClose = useRef(null);
|
|
20
|
+
const showInfo = useCallback((type, anchorEl, value, options) => {
|
|
21
|
+
safeDispatchEvent(
|
|
22
|
+
new CustomEvent(SHOW_EVENT_ID, {
|
|
23
|
+
detail: {
|
|
24
|
+
type,
|
|
25
|
+
anchorEl,
|
|
26
|
+
value,
|
|
27
|
+
options
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
}, []);
|
|
32
|
+
const closeInfo = useCallback(
|
|
33
|
+
(type, value) => {
|
|
34
|
+
safeDispatchEvent(
|
|
35
|
+
new CustomEvent(HIDE_EVENT_ID, {
|
|
36
|
+
detail: {
|
|
37
|
+
type,
|
|
38
|
+
value
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
|
+
[]
|
|
45
|
+
);
|
|
46
|
+
const handleShowPopup = useCallback((event) => {
|
|
47
|
+
const { detail } = event;
|
|
48
|
+
setPopupType(detail.type);
|
|
49
|
+
setDetailsData(detail.value);
|
|
50
|
+
if (detail.options) {
|
|
51
|
+
if (detail.options.content) {
|
|
52
|
+
setDetailsContent(detail.options.content);
|
|
53
|
+
}
|
|
54
|
+
if (detail.options.onClose) {
|
|
55
|
+
externalOnClose.current = detail.options.onClose;
|
|
56
|
+
}
|
|
57
|
+
if (detail.options.popoverProps) {
|
|
58
|
+
setPopoverProps(detail.options.popoverProps);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
setDetailsAnchorEl(detail.anchorEl);
|
|
62
|
+
}, []);
|
|
63
|
+
const handleHidePopup = useCallback(
|
|
64
|
+
(event) => {
|
|
65
|
+
const { detail } = event;
|
|
66
|
+
if (detailsData && (detail.type !== popupType || detailsData.type !== detail.value.type || detailsData.value !== detail.value.value)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
setPopupType(null);
|
|
70
|
+
setDetailsAnchorEl(null);
|
|
71
|
+
setDetailsData(null);
|
|
72
|
+
setDetailsContent(null);
|
|
73
|
+
setPopoverProps({});
|
|
74
|
+
externalOnClose.current = null;
|
|
75
|
+
},
|
|
76
|
+
[detailsData, popupType]
|
|
77
|
+
);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const cleanupShow = safeAddEventListener(SHOW_EVENT_ID, handleShowPopup);
|
|
80
|
+
const cleanupHide = safeAddEventListener(HIDE_EVENT_ID, handleHidePopup);
|
|
81
|
+
return () => {
|
|
82
|
+
cleanupShow();
|
|
83
|
+
cleanupHide();
|
|
84
|
+
};
|
|
85
|
+
}, [handleShowPopup, handleHidePopup]);
|
|
86
|
+
const context = useMemo(
|
|
87
|
+
() => ({
|
|
88
|
+
showInfo,
|
|
89
|
+
closeInfo,
|
|
90
|
+
__detailsContent: detailsContent
|
|
91
|
+
}),
|
|
92
|
+
[closeInfo, detailsContent, showInfo]
|
|
93
|
+
);
|
|
94
|
+
return /* @__PURE__ */ jsxs(CluePopupContext.Provider, { value: context, children: [
|
|
95
|
+
children,
|
|
96
|
+
/* @__PURE__ */ jsx(
|
|
97
|
+
AnnotationDetailPopover,
|
|
98
|
+
{
|
|
99
|
+
...popoverProps,
|
|
100
|
+
anchorEl: detailsAnchorEl,
|
|
101
|
+
open: !!detailsAnchorEl && popupType === "details",
|
|
102
|
+
enrichRequest: detailsData,
|
|
103
|
+
onClose: () => {
|
|
104
|
+
if (externalOnClose.current) {
|
|
105
|
+
externalOnClose.current();
|
|
106
|
+
} else {
|
|
107
|
+
closeInfo("details", detailsData);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ jsx(
|
|
113
|
+
AnnotationPreview,
|
|
114
|
+
{
|
|
115
|
+
...popoverProps,
|
|
116
|
+
anchorEl: detailsAnchorEl,
|
|
117
|
+
open: !!detailsAnchorEl && !isNull(popupType) && popupType !== "details",
|
|
118
|
+
annotationType: popupType,
|
|
119
|
+
enrichRequest: detailsData
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
] });
|
|
123
|
+
};
|
|
124
|
+
const AnnotationPreview = ({ annotationType, anchorEl, enrichRequest, open, ...otherProps }) => {
|
|
125
|
+
const theme = useTheme();
|
|
126
|
+
const _detailsContent = useContextSelector(CluePopupContext, (state) => state.__detailsContent);
|
|
127
|
+
const [annotations] = useAnnotations(enrichRequest == null ? void 0 : enrichRequest.type, enrichRequest == null ? void 0 : enrichRequest.value, enrichRequest == null ? void 0 : enrichRequest.classification);
|
|
128
|
+
const filteredAnnotations = useMemo(
|
|
129
|
+
() => annotationType === "actionResults" ? [] : annotations.filter((annotation) => annotation.type === annotationType),
|
|
130
|
+
[annotationType, annotations]
|
|
131
|
+
);
|
|
132
|
+
const getZIndex = useCallback((_anchorEl) => {
|
|
133
|
+
try {
|
|
134
|
+
const zIndex = parseInt(window.getComputedStyle(_anchorEl, null).getPropertyValue("z-index"));
|
|
135
|
+
if (isNaN(zIndex)) {
|
|
136
|
+
return getZIndex(_anchorEl.parentElement);
|
|
137
|
+
}
|
|
138
|
+
return (zIndex + 2).toString();
|
|
139
|
+
} catch {
|
|
140
|
+
return "2";
|
|
141
|
+
}
|
|
142
|
+
}, []);
|
|
143
|
+
if (!filteredAnnotations.length && !_detailsContent) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
return /* @__PURE__ */ jsx(
|
|
147
|
+
Popper,
|
|
148
|
+
{
|
|
149
|
+
...otherProps,
|
|
150
|
+
open,
|
|
151
|
+
anchorEl,
|
|
152
|
+
placement: "bottom-start",
|
|
153
|
+
sx: [{ zIndex: getZIndex(anchorEl) }, ...Array.isArray(otherProps.sx) ? otherProps.sx : [otherProps.sx]],
|
|
154
|
+
children: /* @__PURE__ */ jsx(Fade, { in: !!anchorEl, children: /* @__PURE__ */ jsx(Paper, { sx: { overflowY: "auto", maxWidth: "500px", boxShadow: theme.shadows[2] }, children: /* @__PURE__ */ jsx(Stack, { direction: "column", sx: { p: 1 }, spacing: 1, divider: /* @__PURE__ */ jsx(Divider, { orientation: "horizontal" }), children: _detailsContent ?? filteredAnnotations.map((annotation) => /* @__PURE__ */ jsxs(
|
|
155
|
+
Stack,
|
|
156
|
+
{
|
|
157
|
+
direction: "column",
|
|
158
|
+
spacing: 1,
|
|
159
|
+
children: [
|
|
160
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
|
|
161
|
+
annotation.analytic_icon && /* @__PURE__ */ jsx(
|
|
162
|
+
Icon,
|
|
163
|
+
{
|
|
164
|
+
icon: annotation.analytic_icon,
|
|
165
|
+
style: { filter: "drop-shadow(0px 0px 1px rgb(0 0 0 / 0.4))" }
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { textTransform: "capitalize" }, children: annotation.analytic ?? annotation.author }),
|
|
169
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "caption", color: "text.secondary", children: [
|
|
170
|
+
"(",
|
|
171
|
+
twitterShort(annotation.timestamp),
|
|
172
|
+
")"
|
|
173
|
+
] })
|
|
174
|
+
] }),
|
|
175
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", children: annotation.summary }),
|
|
176
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: annotation.value })
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
annotation.analytic + annotation.author + annotation.value + annotation.link + annotation.summary + annotation.timestamp
|
|
180
|
+
)) }) }) })
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
export {
|
|
185
|
+
AnnotationPreview as A,
|
|
186
|
+
CluePopupContext as C,
|
|
187
|
+
CluePopupProvider as a
|
|
188
|
+
};
|