@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,465 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { ClickAwayListener, TextField, InputAdornment, Popper, Paper, MenuList, MenuItem, ListItemText, useTheme, Stack, Skeleton } from "@mui/material";
|
|
6
|
+
import { useRef, useState, useEffect, useMemo, lazy } from "react";
|
|
7
|
+
import { r as removeEmpty, s as searchObject, f as flatten } from "./utils-CxIhC2xH.js";
|
|
8
|
+
import { ClueComponentContext } from "./hooks/ClueComponentContext.js";
|
|
9
|
+
import { useMyLocalStorageItem } from "./hooks/useMyLocalStorage.js";
|
|
10
|
+
import { StorageKey } from "./utils/constants.js";
|
|
11
|
+
import { u as useContextSelector } from "./index-BDVjGvMI.js";
|
|
12
|
+
const ENTER = "Enter";
|
|
13
|
+
const ESCAPE = "Escape";
|
|
14
|
+
const ARROW_LEFT = "ArrowLeft";
|
|
15
|
+
const ARROW_UP = "ArrowUp";
|
|
16
|
+
const ARROW_RIGHT = "ArrowRight";
|
|
17
|
+
const ARROW_DOWN = "ArrowDown";
|
|
18
|
+
const BACKSPACE = "Backspace";
|
|
19
|
+
const SPACE = " ";
|
|
20
|
+
function is(key, check) {
|
|
21
|
+
return key === check;
|
|
22
|
+
}
|
|
23
|
+
function isArrowUp(key) {
|
|
24
|
+
return is(key, ARROW_UP);
|
|
25
|
+
}
|
|
26
|
+
function isArrowDown(key) {
|
|
27
|
+
return is(key, ARROW_DOWN);
|
|
28
|
+
}
|
|
29
|
+
function isArrowLeft(key) {
|
|
30
|
+
return is(key, ARROW_LEFT);
|
|
31
|
+
}
|
|
32
|
+
function isArrowRight(key) {
|
|
33
|
+
return is(key, ARROW_RIGHT);
|
|
34
|
+
}
|
|
35
|
+
function isEscape(key) {
|
|
36
|
+
return is(key, ESCAPE);
|
|
37
|
+
}
|
|
38
|
+
function isEnter(key) {
|
|
39
|
+
return is(key, ENTER);
|
|
40
|
+
}
|
|
41
|
+
function isBackspace(key) {
|
|
42
|
+
return is(key, BACKSPACE);
|
|
43
|
+
}
|
|
44
|
+
function isSpace(key) {
|
|
45
|
+
return is(key, SPACE);
|
|
46
|
+
}
|
|
47
|
+
function parseEvent(event) {
|
|
48
|
+
return {
|
|
49
|
+
key: event.key,
|
|
50
|
+
isCtrl: event.ctrlKey,
|
|
51
|
+
isEnter: isEnter(event.key),
|
|
52
|
+
isSpace: isSpace(event.key),
|
|
53
|
+
isBackspace: isBackspace(event.key),
|
|
54
|
+
isEscape: isEscape(event.key),
|
|
55
|
+
isArrowLeft: isArrowLeft(event.key),
|
|
56
|
+
isArrowRight: isArrowRight(event.key),
|
|
57
|
+
isArrowUp: isArrowUp(event.key),
|
|
58
|
+
isArrowDown: isArrowDown(event.key)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
class TuiPhraseLexer {
|
|
62
|
+
constructor() {
|
|
63
|
+
__publicField(this, "_phrase", null);
|
|
64
|
+
__publicField(this, "_buffer", null);
|
|
65
|
+
__publicField(this, "_tokens", null);
|
|
66
|
+
__publicField(this, "_consumers", null);
|
|
67
|
+
__publicField(this, "_consumer", null);
|
|
68
|
+
__publicField(this, "_startIndex", 0);
|
|
69
|
+
__publicField(this, "_endIndex", -1);
|
|
70
|
+
}
|
|
71
|
+
find(cursor, tokens) {
|
|
72
|
+
const index = tokens.findIndex((t) => t.startIndex <= cursor && cursor <= t.endIndex);
|
|
73
|
+
const token = tokens.at(index);
|
|
74
|
+
return { index, token };
|
|
75
|
+
}
|
|
76
|
+
parse(phrase, cursor = 0) {
|
|
77
|
+
this._phrase = phrase;
|
|
78
|
+
this._buffer = [];
|
|
79
|
+
this._tokens = [];
|
|
80
|
+
this._consumers = this.consumers();
|
|
81
|
+
this._consumer = null;
|
|
82
|
+
this._startIndex = 0;
|
|
83
|
+
this._endIndex = -1;
|
|
84
|
+
for (let i = 0; i < this._phrase.length; i++) {
|
|
85
|
+
this._endIndex += 1;
|
|
86
|
+
const next = this._phrase[i];
|
|
87
|
+
this._buffer.push(next);
|
|
88
|
+
let newLock = false;
|
|
89
|
+
if (!this._consumer) {
|
|
90
|
+
this._consumer = this.lock();
|
|
91
|
+
if (this._consumer) {
|
|
92
|
+
newLock = true;
|
|
93
|
+
this._consumer.init(this._buffer, this);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (this._consumer) {
|
|
97
|
+
if (newLock) {
|
|
98
|
+
newLock = false;
|
|
99
|
+
} else {
|
|
100
|
+
this._consumer.append(next, this);
|
|
101
|
+
}
|
|
102
|
+
const token = this._consumer.consume(this);
|
|
103
|
+
if (token) {
|
|
104
|
+
this._tokens.push(token);
|
|
105
|
+
this._buffer = [];
|
|
106
|
+
this._consumer = null;
|
|
107
|
+
this._startIndex = this._endIndex + 1;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
this._tokens.push({ type: "eop", startIndex: phrase.length, endIndex: phrase.length, value: "" });
|
|
112
|
+
const flatTokens = this._tokens.flatMap((t) => t.children && t.children.length > 0 ? t.children : [t]);
|
|
113
|
+
const { token: parent, index: parentIndex } = this.find(cursor, this._tokens);
|
|
114
|
+
const { token: current, index: currentIndex } = this.find(cursor, flatTokens);
|
|
115
|
+
const filter = cursor === current.startIndex && flatTokens[currentIndex - 1] ? flatTokens[currentIndex - 1] : current;
|
|
116
|
+
return {
|
|
117
|
+
cursor,
|
|
118
|
+
parentIndex,
|
|
119
|
+
parent,
|
|
120
|
+
currentIndex,
|
|
121
|
+
current,
|
|
122
|
+
suggest: {
|
|
123
|
+
token: filter,
|
|
124
|
+
parent: this.find(filter.startIndex, this._tokens).token,
|
|
125
|
+
value: filter.value.substring(0, cursor - filter.startIndex)
|
|
126
|
+
},
|
|
127
|
+
tokens: this._tokens
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
lock() {
|
|
131
|
+
return this._consumers.find((c) => c.lock(this));
|
|
132
|
+
}
|
|
133
|
+
buffer() {
|
|
134
|
+
return this._buffer;
|
|
135
|
+
}
|
|
136
|
+
bufferValue() {
|
|
137
|
+
return this._buffer.join("");
|
|
138
|
+
}
|
|
139
|
+
start() {
|
|
140
|
+
return this._startIndex;
|
|
141
|
+
}
|
|
142
|
+
end() {
|
|
143
|
+
return this._endIndex;
|
|
144
|
+
}
|
|
145
|
+
ahead(inc) {
|
|
146
|
+
const start = this._endIndex + 1;
|
|
147
|
+
if (inc) {
|
|
148
|
+
return this._phrase.slice(start, start + inc);
|
|
149
|
+
}
|
|
150
|
+
return this._phrase.substring(start);
|
|
151
|
+
}
|
|
152
|
+
behind(inc) {
|
|
153
|
+
if (inc) {
|
|
154
|
+
return this.bufferValue().slice(-inc);
|
|
155
|
+
}
|
|
156
|
+
return this.bufferValue();
|
|
157
|
+
}
|
|
158
|
+
behindEndsWithAny(trim, ...values) {
|
|
159
|
+
const behind = trim ? this.behind().trimEnd() : this.behind();
|
|
160
|
+
return values.some((v) => behind.endsWith(v));
|
|
161
|
+
}
|
|
162
|
+
testBehind(regex) {
|
|
163
|
+
return regex.test(this.behind());
|
|
164
|
+
}
|
|
165
|
+
aheadStartsWithAny(trim, ...values) {
|
|
166
|
+
const ahead = trim ? this.ahead().trimStart() : this.ahead();
|
|
167
|
+
return values.some((v) => ahead.startsWith(v));
|
|
168
|
+
}
|
|
169
|
+
aheadIsEmpty(trim = false) {
|
|
170
|
+
return trim ? this.ahead().trim().length === 0 : this.ahead().length === 0;
|
|
171
|
+
}
|
|
172
|
+
testAhead(regex) {
|
|
173
|
+
return regex.test(this.ahead());
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
class TuiPhraseConsumer {
|
|
177
|
+
constructor() {
|
|
178
|
+
__publicField(this, "_buffer", []);
|
|
179
|
+
}
|
|
180
|
+
reset() {
|
|
181
|
+
this._buffer = [];
|
|
182
|
+
}
|
|
183
|
+
init(buffer, lexer) {
|
|
184
|
+
this._buffer = [...buffer];
|
|
185
|
+
}
|
|
186
|
+
append(next, lexer) {
|
|
187
|
+
this._buffer.push(next);
|
|
188
|
+
}
|
|
189
|
+
bufferValue() {
|
|
190
|
+
return this._buffer.join("");
|
|
191
|
+
}
|
|
192
|
+
endsWithAny(...values) {
|
|
193
|
+
const _bufferValue = this.bufferValue();
|
|
194
|
+
return values.some((v) => _bufferValue.endsWith(v));
|
|
195
|
+
}
|
|
196
|
+
test(regex) {
|
|
197
|
+
return regex.test(this.bufferValue());
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
class WhitespaceConsumer extends TuiPhraseConsumer {
|
|
201
|
+
lock(lexer) {
|
|
202
|
+
return lexer.bufferValue().match(/\s/) && lexer.ahead(1) !== " ";
|
|
203
|
+
}
|
|
204
|
+
consume(lexer) {
|
|
205
|
+
if (lexer.ahead(1) !== " ") {
|
|
206
|
+
return {
|
|
207
|
+
type: "whitespace",
|
|
208
|
+
startIndex: lexer.start(),
|
|
209
|
+
endIndex: lexer.end(),
|
|
210
|
+
value: this._buffer.join("")
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
class WordConsumer extends TuiPhraseConsumer {
|
|
217
|
+
lock(lexer) {
|
|
218
|
+
return !lexer.bufferValue().match(/\s/) && (lexer.ahead(1) === " " || lexer.ahead(1) === "");
|
|
219
|
+
}
|
|
220
|
+
consume(lexer) {
|
|
221
|
+
if (lexer.ahead(1) === " " || lexer.aheadIsEmpty(true)) {
|
|
222
|
+
return {
|
|
223
|
+
type: "word",
|
|
224
|
+
startIndex: lexer.start(),
|
|
225
|
+
endIndex: lexer.end(),
|
|
226
|
+
value: this._buffer.join("")
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
class WordLexer extends TuiPhraseLexer {
|
|
233
|
+
consumers() {
|
|
234
|
+
return [new WordConsumer(), new WhitespaceConsumer()];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
class WordSuggestor {
|
|
238
|
+
constructor(suggestions) {
|
|
239
|
+
this.suggestions = suggestions;
|
|
240
|
+
}
|
|
241
|
+
suggest(phrase) {
|
|
242
|
+
return this.suggestions.filter((s) => s.indexOf(phrase.suggest.value) > -1);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function TuiPhrase({
|
|
246
|
+
value = "",
|
|
247
|
+
variant = "outlined",
|
|
248
|
+
suggestions = [],
|
|
249
|
+
lexer,
|
|
250
|
+
suggester,
|
|
251
|
+
startAdornment,
|
|
252
|
+
endAdornment,
|
|
253
|
+
onChange,
|
|
254
|
+
onKeyDown,
|
|
255
|
+
...props
|
|
256
|
+
}) {
|
|
257
|
+
const containerRef = useRef();
|
|
258
|
+
const inputRef = useRef();
|
|
259
|
+
const menuRef = useRef();
|
|
260
|
+
const lexerRef = useRef(lexer || new WordLexer());
|
|
261
|
+
const analysisRef = useRef();
|
|
262
|
+
const suggesterRef = useRef(suggester || new WordSuggestor(suggestions));
|
|
263
|
+
const [optionsOpen, setOptionsOpen] = useState(false);
|
|
264
|
+
const [options, setOptions] = useState(suggestions);
|
|
265
|
+
useEffect(() => {
|
|
266
|
+
suggesterRef.current = suggester || new WordSuggestor(suggestions);
|
|
267
|
+
}, [suggester, suggestions]);
|
|
268
|
+
const lex = (inputValue, offset = 0) => {
|
|
269
|
+
let cursor = inputRef.current.querySelector("input").selectionStart + offset;
|
|
270
|
+
cursor = cursor < 0 ? 0 : cursor > inputValue.length ? inputValue.length : cursor;
|
|
271
|
+
analysisRef.current = lexerRef.current.parse(inputValue, cursor);
|
|
272
|
+
return analysisRef.current;
|
|
273
|
+
};
|
|
274
|
+
const _suggest = (inputValue, offset = 0) => {
|
|
275
|
+
const _suggestions = suggesterRef.current.suggest(lex(inputValue, offset));
|
|
276
|
+
setOptions((_suggestions == null ? void 0 : _suggestions.length) > 0 ? _suggestions : [...suggestions]);
|
|
277
|
+
};
|
|
278
|
+
const _onChange = (event) => {
|
|
279
|
+
onChange(event.target.value);
|
|
280
|
+
};
|
|
281
|
+
const _onInputKeyDown = (event) => {
|
|
282
|
+
const parsedEvent = parseEvent(event);
|
|
283
|
+
const { isEnter: isEnter2, isCtrl, isSpace: isSpace2, isEscape: isEscape2, isArrowDown: isArrowDown2 } = parsedEvent;
|
|
284
|
+
if (isArrowDown2) {
|
|
285
|
+
event.preventDefault();
|
|
286
|
+
menuRef.current.focus();
|
|
287
|
+
} else if (isCtrl && isSpace2) {
|
|
288
|
+
setOptionsOpen(true);
|
|
289
|
+
_suggest(value);
|
|
290
|
+
} else if (isEscape2) {
|
|
291
|
+
setOptionsOpen(!optionsOpen);
|
|
292
|
+
}
|
|
293
|
+
if (isEnter2 && optionsOpen && options.length === 1) {
|
|
294
|
+
onWordClick(options[0]);
|
|
295
|
+
event.preventDefault();
|
|
296
|
+
} else if (onKeyDown) {
|
|
297
|
+
onKeyDown(parsedEvent);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
const _onSelectCapture = (event) => {
|
|
301
|
+
if (optionsOpen) {
|
|
302
|
+
_suggest(event.target.value);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
const _onMenuKeyDown = (event) => {
|
|
306
|
+
const { isEscape: isEscape2 } = parseEvent(event);
|
|
307
|
+
if (isEscape2) {
|
|
308
|
+
inputRef.current.focus();
|
|
309
|
+
setOptionsOpen(false);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
const onWordClick = (word) => {
|
|
313
|
+
const { suggest } = analysisRef.current;
|
|
314
|
+
const inputEl = inputRef.current.querySelector("input");
|
|
315
|
+
inputEl.focus();
|
|
316
|
+
inputEl.setSelectionRange(suggest.token.startIndex, suggest.token.endIndex + 1);
|
|
317
|
+
document.execCommand("insertText", false, word);
|
|
318
|
+
setOptionsOpen(false);
|
|
319
|
+
};
|
|
320
|
+
return /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: () => setOptionsOpen(false), children: /* @__PURE__ */ jsxs("div", { ref: containerRef, style: { position: "relative" }, children: [
|
|
321
|
+
/* @__PURE__ */ jsx(
|
|
322
|
+
TextField,
|
|
323
|
+
{
|
|
324
|
+
ref: inputRef,
|
|
325
|
+
...props,
|
|
326
|
+
fullWidth: true,
|
|
327
|
+
autoComplete: "off",
|
|
328
|
+
value,
|
|
329
|
+
variant,
|
|
330
|
+
onChange: _onChange,
|
|
331
|
+
onKeyDown: _onInputKeyDown,
|
|
332
|
+
InputProps: {
|
|
333
|
+
...props.InputProps,
|
|
334
|
+
onSelectCapture: _onSelectCapture,
|
|
335
|
+
startAdornment: startAdornment && /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: startAdornment }),
|
|
336
|
+
endAdornment: endAdornment && /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: endAdornment })
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
),
|
|
340
|
+
/* @__PURE__ */ jsx(
|
|
341
|
+
Popper,
|
|
342
|
+
{
|
|
343
|
+
anchorEl: containerRef.current,
|
|
344
|
+
style: { width: "100%", zIndex: 100 },
|
|
345
|
+
open: optionsOpen && options.length > 0,
|
|
346
|
+
disablePortal: true,
|
|
347
|
+
children: /* @__PURE__ */ jsx(
|
|
348
|
+
Paper,
|
|
349
|
+
{
|
|
350
|
+
elevation: 2,
|
|
351
|
+
sx: { maxHeight: 200, overflow: "auto", borderTopRightRadius: 0, borderTopLeftRadius: 0 },
|
|
352
|
+
children: /* @__PURE__ */ jsx(
|
|
353
|
+
MenuList,
|
|
354
|
+
{
|
|
355
|
+
ref: menuRef,
|
|
356
|
+
onKeyDown: _onMenuKeyDown,
|
|
357
|
+
sx: {
|
|
358
|
+
"&:focus": {
|
|
359
|
+
outline: "none"
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
children: options == null ? void 0 : options.map((o) => /* @__PURE__ */ jsx(MenuItem, { onClick: () => onWordClick(o), children: /* @__PURE__ */ jsx(ListItemText, { children: o }) }, o))
|
|
363
|
+
}
|
|
364
|
+
)
|
|
365
|
+
}
|
|
366
|
+
)
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
] }) });
|
|
370
|
+
}
|
|
371
|
+
const JSONViewer = ({ data, collapse = true, forceCompact = false, slotProps }) => {
|
|
372
|
+
var _a, _b, _c;
|
|
373
|
+
const theme = useTheme();
|
|
374
|
+
const [compact] = useMyLocalStorageItem(StorageKey.COMPACT_JSON);
|
|
375
|
+
const [flat] = useMyLocalStorageItem(StorageKey.FLATTEN_JSON);
|
|
376
|
+
const _ProvidedReactJson = useContextSelector(ClueComponentContext, (ctx) => ctx == null ? void 0 : ctx.ReactJson);
|
|
377
|
+
const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx == null ? void 0 : ctx.i18next);
|
|
378
|
+
const [ReactJson, setReactJson] = useState(null);
|
|
379
|
+
const [query, setQuery] = useState("");
|
|
380
|
+
const isDark = useMemo(() => theme.palette.mode === "dark", [theme]);
|
|
381
|
+
const filteredData = useMemo(() => removeEmpty(data, compact || forceCompact), [compact, data, forceCompact]);
|
|
382
|
+
const searchedData = useMemo(() => {
|
|
383
|
+
const _searchedData = searchObject(filteredData, query);
|
|
384
|
+
return flat ? flatten(_searchedData) : _searchedData;
|
|
385
|
+
}, [filteredData, flat, query]);
|
|
386
|
+
const hasError = useMemo(() => {
|
|
387
|
+
try {
|
|
388
|
+
new RegExp(query);
|
|
389
|
+
return false;
|
|
390
|
+
} catch {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
}, [query]);
|
|
394
|
+
useEffect(() => {
|
|
395
|
+
if (_ProvidedReactJson) {
|
|
396
|
+
setReactJson(() => _ProvidedReactJson);
|
|
397
|
+
} else {
|
|
398
|
+
setReactJson(lazy(() => import("@microlink/react-json-view")));
|
|
399
|
+
}
|
|
400
|
+
}, [_ProvidedReactJson]);
|
|
401
|
+
const shouldCollapse = (field) => {
|
|
402
|
+
return field.name !== "root" && field.type !== "object" || field.namespace.length > 3;
|
|
403
|
+
};
|
|
404
|
+
return data ? /* @__PURE__ */ jsxs(
|
|
405
|
+
Stack,
|
|
406
|
+
{
|
|
407
|
+
direction: "column",
|
|
408
|
+
spacing: 1,
|
|
409
|
+
...slotProps == null ? void 0 : slotProps.stack,
|
|
410
|
+
sx: {
|
|
411
|
+
"& > div:first-of-type": { mt: 1, mr: 0.5 },
|
|
412
|
+
...Array.isArray((_a = slotProps == null ? void 0 : slotProps.stack) == null ? void 0 : _a.sx) ? (_b = slotProps == null ? void 0 : slotProps.stack) == null ? void 0 : _b.sx : [(_c = slotProps == null ? void 0 : slotProps.stack) == null ? void 0 : _c.sx]
|
|
413
|
+
},
|
|
414
|
+
children: [
|
|
415
|
+
/* @__PURE__ */ jsx(
|
|
416
|
+
TuiPhrase,
|
|
417
|
+
{
|
|
418
|
+
value: query,
|
|
419
|
+
onChange: setQuery,
|
|
420
|
+
size: "small",
|
|
421
|
+
error: hasError,
|
|
422
|
+
label: t("json.viewer.search.label"),
|
|
423
|
+
placeholder: t("json.viewer.search.prompt")
|
|
424
|
+
}
|
|
425
|
+
),
|
|
426
|
+
ReactJson && /* @__PURE__ */ jsx(
|
|
427
|
+
ReactJson,
|
|
428
|
+
{
|
|
429
|
+
src: searchedData,
|
|
430
|
+
theme: isDark ? "summerfruit" : "summerfruit:inverted",
|
|
431
|
+
indentWidth: 2,
|
|
432
|
+
displayDataTypes: !compact && !forceCompact,
|
|
433
|
+
displayObjectSize: !compact && !forceCompact,
|
|
434
|
+
shouldCollapse: collapse ? shouldCollapse : false,
|
|
435
|
+
quotesOnKeys: false,
|
|
436
|
+
style: {
|
|
437
|
+
flex: 1,
|
|
438
|
+
overflow: "auto",
|
|
439
|
+
height: "100%",
|
|
440
|
+
fontSize: compact || forceCompact ? "small" : "smaller",
|
|
441
|
+
borderRadius: theme.shape.borderRadius,
|
|
442
|
+
padding: theme.spacing(1)
|
|
443
|
+
},
|
|
444
|
+
enableClipboard: (_data) => {
|
|
445
|
+
if (typeof _data.src === "string") {
|
|
446
|
+
navigator.clipboard.writeText(_data.src);
|
|
447
|
+
} else {
|
|
448
|
+
navigator.clipboard.writeText(JSON.stringify(_data.src));
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
...{
|
|
452
|
+
// Type declaration is wrong - this is a valid prop
|
|
453
|
+
displayArrayKey: !compact && !forceCompact
|
|
454
|
+
},
|
|
455
|
+
...slotProps == null ? void 0 : slotProps.json
|
|
456
|
+
}
|
|
457
|
+
)
|
|
458
|
+
]
|
|
459
|
+
}
|
|
460
|
+
) : /* @__PURE__ */ jsx(Skeleton, { width: "100%", height: "95%", variant: "rounded" });
|
|
461
|
+
};
|
|
462
|
+
export {
|
|
463
|
+
JSONViewer as J,
|
|
464
|
+
parseEvent as p
|
|
465
|
+
};
|