@cccsaurora/clue-ui 1.3.0-dev.404 → 1.3.0

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 (224) hide show
  1. package/ActionForm-CHOSKfvu.js +4403 -0
  2. package/AnnotationDetails-Bqq6Ymmg.js +160 -0
  3. package/AnnotationPreview-CqXmC-j8.js +140 -0
  4. package/ClueEnrichContext-DL6aGe1k.js +432 -0
  5. package/FlexOne-BXWFOd1T.js +6 -0
  6. package/_MapCache-DRK-s2eK.js +179 -0
  7. package/_Set-DrS_bbSV.js +6 -0
  8. package/_Uint8Array-D9R2N9Lp.js +98 -0
  9. package/_arrayIncludes-Dcl_29E6.js +25 -0
  10. package/_arrayPush-DBJIuK2V.js +8 -0
  11. package/_baseAssignValue-Bx1cxHj5.js +12 -0
  12. package/_baseClone-DRhywkxm.js +211 -0
  13. package/_baseExtremum-DodEaEyF.js +16 -0
  14. package/_baseFlatten-CD9NgrYE.js +72 -0
  15. package/_baseGet-bVwDaGrA.js +80 -0
  16. package/_baseGetTag-CxDaTem-.js +25 -0
  17. package/_baseIsEqual-C-FKsm1J.js +150 -0
  18. package/_baseIteratee-D0FhC5bC.js +95 -0
  19. package/_baseRest-D_eW2E0d.js +8 -0
  20. package/_baseSlice-M5RKzt1A.js +10 -0
  21. package/_baseSum-wEbgNeUs.js +10 -0
  22. package/_baseUniq-D3N8igOm.js +41 -0
  23. package/_cacheHas-Wgl-hw34.js +22 -0
  24. package/_commonjsHelpers-C6fGbg64.js +6 -0
  25. package/_createAggregator-BVj8IAuF.js +53 -0
  26. package/_defineProperty-BZU4WKA3.js +11 -0
  27. package/_getPrototype-BGBCg-aX.js +5 -0
  28. package/_getTag-B7R9qBo7.js +73 -0
  29. package/_isIterateeCall-Dm0VTAYy.js +13 -0
  30. package/_setToArray-Ck4YZu0Z.js +9 -0
  31. package/cloneDeep-fV59zwUf.js +8 -0
  32. package/components/AnnotationBody.js +35 -49
  33. package/components/AnnotationDetailPopover.js +30 -36
  34. package/components/AnnotationDetails.js +7 -7
  35. package/components/AnnotationEntry.js +35 -35
  36. package/components/AnnotationPreview.js +5 -5
  37. package/components/ClassificationChip.js +23 -44
  38. package/components/CountBadge.js +26 -31
  39. package/components/EnrichedCard.js +97 -110
  40. package/components/EnrichedChip.js +105 -130
  41. package/components/EnrichedTypography.js +107 -133
  42. package/components/ErrorBoundary.js +24 -28
  43. package/components/RetryFailedEnrichments.js +9 -10
  44. package/components/SourcePicker.js +49 -57
  45. package/components/actions/ActionForm.js +4 -4
  46. package/components/actions/ExecutePopover.js +59 -75
  47. package/components/actions/ResultModal.js +4 -4
  48. package/components/actions/form/schemaAdapter.js +23 -39
  49. package/components/actions/formats/FileResult.js +59 -86
  50. package/components/actions/formats/index.js +25 -29
  51. package/components/display/graph/ExpandMoreButton.js +10 -10
  52. package/components/display/graph/elements/NodeCard.js +91 -111
  53. package/components/display/graph/elements/NodeTag.js +13 -15
  54. package/components/display/graph/index.js +202 -261
  55. package/components/display/graph/visualizations/Leaf.js +70 -89
  56. package/components/display/graph/visualizations/cloud/index.js +81 -98
  57. package/components/display/graph/visualizations/icons/BaseIcon.js +21 -26
  58. package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
  59. package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
  60. package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
  61. package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
  62. package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
  63. package/components/display/graph/visualizations/icons/index.js +13 -14
  64. package/components/display/graph/visualizations/panels/NodePanel.js +8 -10
  65. package/components/display/graph/visualizations/tree/BundleLine.js +81 -108
  66. package/components/display/graph/visualizations/tree/Triangle.js +13 -13
  67. package/components/display/graph/visualizations/tree/index.js +306 -408
  68. package/components/display/icons/Iconified.js +12 -27
  69. package/components/display/json/index.js +4 -4
  70. package/components/display/markdown/index.js +5770 -8678
  71. package/components/enrichment/EnrichPopover.js +46 -54
  72. package/components/fetchers/Fetcher.js +123 -166
  73. package/components/fetchers/FetcherResultView.js +27 -31
  74. package/components/fetchers/PreviewModal.js +16 -17
  75. package/components/fetchers/StatusChip.js +17 -21
  76. package/components/group/Entry.js +11 -13
  77. package/components/group/Group.js +10 -13
  78. package/components/group/GroupControl.js +65 -76
  79. package/components/stats/QueryStatus.js +32 -45
  80. package/countBy-B3rNuG4T.js +8 -0
  81. package/data/event.js +4 -6
  82. package/database/globals.js +2 -2
  83. package/database/index.js +3 -3
  84. package/database/replication.js +4 -4
  85. package/get-Bil3mzRD.js +8 -0
  86. package/groupBy-CrJC7sGa.js +8 -0
  87. package/hooks/ClueActionContext.js +6 -6
  88. package/hooks/ClueComponentContext.js +23 -29
  89. package/hooks/ClueConfigProvider.js +12 -14
  90. package/hooks/ClueDatabaseContext.js +23 -35
  91. package/hooks/ClueEnrichContext.js +11 -11
  92. package/hooks/ClueFetcherContext.js +56 -83
  93. package/hooks/ClueGroupContext.js +14 -17
  94. package/hooks/CluePopupContext.js +5 -5
  95. package/hooks/ClueProvider.js +11 -13
  96. package/hooks/ClueUIPluginContext.js +35 -49
  97. package/hooks/selectors.js +7 -7
  98. package/hooks/useActionResult.js +3 -3
  99. package/hooks/useAnnotations.js +32 -48
  100. package/hooks/useClue.js +4 -6
  101. package/hooks/useClueActions.js +3 -3
  102. package/hooks/useClueConfig.js +4 -6
  103. package/hooks/useClueTypeConfig.js +24 -49
  104. package/hooks/useClueUIPlugins.js +7 -8
  105. package/hooks/useComparator.js +435 -722
  106. package/hooks/useErrors.js +18 -22
  107. package/hooks/useFetcherResult.js +24 -33
  108. package/hooks/useMyHighlights.js +36 -66
  109. package/hooks/useMyLocalStorage.js +37 -66
  110. package/iconify-Ptb5dTKy.js +1270 -0
  111. package/icons/Action.js +49 -66
  112. package/icons/Assessment.js +69 -85
  113. package/icons/Context.js +63 -77
  114. package/icons/Opinion.js +60 -76
  115. package/icons/iconMap.js +2 -2
  116. package/identity-ByMq8VxU.js +6 -0
  117. package/index-BH-gBhtO.js +2282 -0
  118. package/index-BM9Sve5T.js +571 -0
  119. package/index-Cj4d5cGz.js +357 -0
  120. package/index-Dh2PP9h8.js +11747 -0
  121. package/index-DoFpWPHo.js +975 -0
  122. package/index-DzVIklWY.js +6464 -0
  123. package/isArguments-BWcXOE6a.js +24 -0
  124. package/isArray-WzO_os3q.js +4 -0
  125. package/isEmpty-DKxrY-_M.js +22 -0
  126. package/isNil-CjWwlQS3.js +6 -0
  127. package/isObject-B53jY8Qg.js +7 -0
  128. package/isObjectLike-CYbdrIBr.js +6 -0
  129. package/isSymbol-DE1Kcy2M.js +9 -0
  130. package/last-7CdUxN0r.js +7 -0
  131. package/main.js +62 -62
  132. package/maxBy-BOWDkL_D.js +8 -0
  133. package/package.json +1 -1
  134. package/plugins/ClueUIPlugin.js +96 -163
  135. package/plugins/file/index.js +15 -15
  136. package/plugins/graph/index.js +26 -29
  137. package/plugins/image/index.js +24 -28
  138. package/plugins/json/index.js +21 -21
  139. package/plugins/markdown/index.js +18 -18
  140. package/plugins/registry.js +6 -6
  141. package/plugins/store.js +4 -4
  142. package/plugins/test/index.js +17 -17
  143. package/plugins/utils.js +12 -13
  144. package/replication-WkKbPdwG.js +8453 -0
  145. package/sessionStorage-DFMae61b.js +90 -0
  146. package/sortBy-BHe812lF.js +74 -0
  147. package/store-DClHBq7r.js +1169 -0
  148. package/sumBy-B7f_bP_k.js +8 -0
  149. package/text/Frequency.js +23 -42
  150. package/toFinite-CBrE65MP.js +14 -0
  151. package/toNumber-CxmWey0f.js +31 -0
  152. package/uniq-B4UZ671_.js +7 -0
  153. package/utils/chain.js +65 -92
  154. package/utils/classificationParser.js +256 -519
  155. package/utils/constants.js +11 -37
  156. package/utils/graph.js +45 -72
  157. package/utils/hashUtil.js +7 -7
  158. package/utils/line.js +81 -131
  159. package/utils/loggerUtil.js +3 -5
  160. package/utils/sessionStorage.js +7 -7
  161. package/utils/time.js +427 -447
  162. package/utils/utils.js +10 -10
  163. package/utils/window.js +10 -21
  164. package/utils-SpTOhPYl.js +147 -0
  165. package/ActionForm-CqKcnDWC.js +0 -6099
  166. package/AnnotationDetails-BlPd3T8k.js +0 -176
  167. package/AnnotationPreview-Bl447SKT.js +0 -188
  168. package/ClueEnrichContext-B3YrTCaJ.js +0 -567
  169. package/FlexOne-BSYAhhtG.js +0 -9
  170. package/_MapCache-kuEY_iOH.js +0 -220
  171. package/_Set-BrSMTlHn.js +0 -6
  172. package/_Uint8Array-OPpgYQj7.js +0 -123
  173. package/_arrayIncludes-BNqL-9ZP.js +0 -31
  174. package/_arrayPush-CBkQqaE_.js +0 -10
  175. package/_baseAssignValue-CNUVPOBW.js +0 -16
  176. package/_baseClone-9FaRd1R2.js +0 -287
  177. package/_baseExtremum-wOGT4Dgw.js +0 -18
  178. package/_baseFlatten-Co6QHDlG.js +0 -92
  179. package/_baseGet-Cmp6FztG.js +0 -109
  180. package/_baseGetTag-Hj-0NTYF.js +0 -44
  181. package/_baseIsEqual-1CpU47TZ.js +0 -211
  182. package/_baseIteratee-BN7Vbe5g.js +0 -126
  183. package/_baseRest-BZ_hQ9PC.js +0 -8
  184. package/_baseSlice-GAv_YFTT.js +0 -20
  185. package/_baseSum-D0WC1dN0.js +0 -13
  186. package/_baseUniq-BnvS3JHL.js +0 -63
  187. package/_cacheHas-_aF2y2Xv.js +0 -25
  188. package/_commonjsHelpers-CUmg6egw.js +0 -6
  189. package/_createAggregator-BUZrP_is.js +0 -63
  190. package/_defineProperty-DolZLKmv.js +0 -12
  191. package/_getPrototype-Bb4gm-5m.js +0 -5
  192. package/_getTag-CML_cXiN.js +0 -105
  193. package/_isIterateeCall-B1IFEqVv.js +0 -17
  194. package/_setToArray-CqyqC8ib.js +0 -10
  195. package/cloneDeep-l3UkXG5M.js +0 -8
  196. package/countBy-Bqcp3VCs.js +0 -14
  197. package/get-CdMThM8x.js +0 -8
  198. package/groupBy-BVV07EGQ.js +0 -14
  199. package/iconify-DJxl6dC-.js +0 -1789
  200. package/identity-CPGTqrE4.js +0 -6
  201. package/index-CAvu7vwt.js +0 -1172
  202. package/index-CVUD9o3t.js +0 -15768
  203. package/index-DUEubgWN.js +0 -464
  204. package/index-Dj1N4IQP.js +0 -9314
  205. package/index-DpJxD74E.js +0 -3272
  206. package/index-_gpzM2Px.js +0 -702
  207. package/isArguments-CuYlEuhP.js +0 -27
  208. package/isArray-RJPfgWqI.js +0 -4
  209. package/isEmpty-BE656RUK.js +0 -30
  210. package/isNil-CIubwp4T.js +0 -6
  211. package/isObject-FTY-5JQX.js +0 -7
  212. package/isObjectLike-CeENW9FN.js +0 -6
  213. package/isSymbol-D_H4HPZQ.js +0 -9
  214. package/last-CUCl67Im.js +0 -7
  215. package/maxBy-BjjQmX5t.js +0 -8
  216. package/replication--gLEZw8a.js +0 -11777
  217. package/sessionStorage-B68y-wnE.js +0 -140
  218. package/sortBy-B8JVsLQY.js +0 -95
  219. package/store-B9sjQbcS.js +0 -2163
  220. package/sumBy-D-HCzM2i.js +0 -8
  221. package/toFinite-meZTg4Su.js +0 -16
  222. package/toNumber-B5JaA1vX.js +0 -39
  223. package/uniq-CahZPAwp.js +0 -7
  224. package/utils-CEySTPtg.js +0 -224
package/index-DUEubgWN.js DELETED
@@ -1,464 +0,0 @@
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, a as flatten } from "./utils-CEySTPtg.js";
8
- import { ClueComponentContext } from "./hooks/ClueComponentContext.js";
9
- import { useMyLocalStorageItem } from "./hooks/useMyLocalStorage.js";
10
- import { StorageKey } from "./utils/constants.js";
11
- import { a as useContextSelector } from "./index-_gpzM2Px.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, hideSearch = false, 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
- !hideSearch && /* @__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
- }
424
- ),
425
- ReactJson && /* @__PURE__ */ jsx(
426
- ReactJson,
427
- {
428
- src: searchedData,
429
- theme: isDark ? "summerfruit" : "summerfruit:inverted",
430
- indentWidth: 2,
431
- displayDataTypes: !compact && !forceCompact,
432
- displayObjectSize: !compact && !forceCompact,
433
- shouldCollapse: collapse ? shouldCollapse : false,
434
- quotesOnKeys: false,
435
- style: {
436
- flex: 1,
437
- overflow: "auto",
438
- height: "100%",
439
- fontSize: compact || forceCompact ? "small" : "smaller",
440
- borderRadius: theme.shape.borderRadius,
441
- padding: theme.spacing(1)
442
- },
443
- enableClipboard: (_data) => {
444
- if (typeof _data.src === "string") {
445
- navigator.clipboard.writeText(_data.src);
446
- } else {
447
- navigator.clipboard.writeText(JSON.stringify(_data.src));
448
- }
449
- },
450
- ...{
451
- // Type declaration is wrong - this is a valid prop
452
- displayArrayKey: !compact && !forceCompact
453
- },
454
- ...slotProps == null ? void 0 : slotProps.json
455
- }
456
- )
457
- ]
458
- }
459
- ) : /* @__PURE__ */ jsx(Skeleton, { width: "100%", height: "95%", variant: "rounded" });
460
- };
461
- export {
462
- JSONViewer as J,
463
- parseEvent as p
464
- };