@cccsaurora/clue-ui 1.0.2 → 1.1.0-dev.10

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 (180) hide show
  1. package/ActionForm-D4ryHO0M.js +436 -0
  2. package/AnnotationDetails-YAPoqw3R.js +175 -0
  3. package/AnnotationPreview-DiQDjt9s.js +188 -0
  4. package/ClueEnrichContext-DIn6g8tw.js +522 -0
  5. package/FlexOne-BSYAhhtG.js +9 -0
  6. package/_Map-kgDsDYxq.js +64 -0
  7. package/_MapCache-DabaaWfq.js +161 -0
  8. package/_Uint8Array-BlVVH1tp.js +129 -0
  9. package/_baseAssignValue-CNbcU6Nb.js +25 -0
  10. package/_baseClone-D3a8Pa4T.js +284 -0
  11. package/_baseExtremum-B1o1zHjR.js +33 -0
  12. package/_baseFlatten-D4huXoEI.js +92 -0
  13. package/_baseGet-BSK_nnoz.js +109 -0
  14. package/_baseIsEqual-B5xLoweL.js +238 -0
  15. package/_baseIteratee-p6Nj07-n.js +126 -0
  16. package/_baseSlice-GAv_YFTT.js +20 -0
  17. package/_baseSum-D0WC1dN0.js +13 -0
  18. package/_baseUniq-CpupKWcL.js +89 -0
  19. package/_commonjsHelpers-CUmg6egw.js +6 -0
  20. package/_createAggregator-BpVy5xMi.js +63 -0
  21. package/_getPrototype-D1LAdQKO.js +5 -0
  22. package/_getTag-D3ToyefI.js +126 -0
  23. package/cloneDeep-CjP5k9zW.js +8 -0
  24. package/components/AnnotationBody.js +49 -34
  25. package/components/AnnotationDetailPopover.js +36 -30
  26. package/components/AnnotationDetails.js +6 -6
  27. package/components/AnnotationEntry.js +50 -47
  28. package/components/AnnotationPreview.js +5 -5
  29. package/components/ClassificationChip.js +44 -23
  30. package/components/CountBadge.js +31 -26
  31. package/components/EnrichedCard.js +104 -92
  32. package/components/EnrichedChip.js +134 -109
  33. package/components/EnrichedTypography.js +136 -110
  34. package/components/ErrorBoundary.js +28 -24
  35. package/components/RetryFailedEnrichments.js +10 -9
  36. package/components/SourcePicker.js +57 -49
  37. package/components/actions/ActionForm.js +4 -4
  38. package/components/actions/ExecutePopover.js +64 -50
  39. package/components/actions/ResultModal.js +37 -34
  40. package/components/actions/form/schemaAdapter.js +39 -20
  41. package/components/display/graph/ExpandMoreButton.js +10 -10
  42. package/components/display/graph/elements/NodeCard.js +92 -76
  43. package/components/display/graph/elements/NodeTag.js +15 -13
  44. package/components/display/graph/index.js +258 -200
  45. package/components/display/graph/visualizations/Leaf.js +88 -69
  46. package/components/display/graph/visualizations/cloud/index.js +98 -81
  47. package/components/display/graph/visualizations/icons/BaseIcon.js +26 -21
  48. package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
  49. package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
  50. package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
  51. package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
  52. package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
  53. package/components/display/graph/visualizations/icons/index.js +14 -13
  54. package/components/display/graph/visualizations/panels/NodePanel.js +10 -8
  55. package/components/display/graph/visualizations/tree/BundleLine.js +108 -81
  56. package/components/display/graph/visualizations/tree/Triangle.js +13 -13
  57. package/components/display/graph/visualizations/tree/index.js +407 -305
  58. package/components/display/icons/Iconified.js +27 -12
  59. package/components/display/json/index.js +4 -4
  60. package/components/display/markdown/DynamicTabs.js +22 -17
  61. package/components/display/markdown/index.js +8527 -5670
  62. package/components/display/markdown/markdownPlugins/tabs.js +1 -1
  63. package/components/enrichment/EnrichPopover.js +55 -47
  64. package/components/fetchers/Fetcher.js +123 -95
  65. package/components/fetchers/PreviewModal.js +20 -17
  66. package/components/fetchers/StatusChip.js +22 -18
  67. package/components/group/Entry.js +13 -11
  68. package/components/group/Group.js +13 -10
  69. package/components/group/GroupControl.js +76 -65
  70. package/components/stats/QueryStatus.js +37 -28
  71. package/countBy-C69WslUA.js +14 -0
  72. package/data/event.js +6 -4
  73. package/database/index.js +2 -2
  74. package/debounce-bV0h5FC5.js +92 -0
  75. package/get-D3C3lEU3.js +8 -0
  76. package/groupBy-DC2oOuBN.js +14 -0
  77. package/hooks/ClueActionContext.js +6 -6
  78. package/hooks/ClueComponentContext.js +29 -23
  79. package/hooks/ClueConfigProvider.js +14 -12
  80. package/hooks/ClueDatabaseContext.js +19 -13
  81. package/hooks/ClueEnrichContext.js +8 -8
  82. package/hooks/ClueFetcherContext.js +74 -46
  83. package/hooks/ClueGroupContext.js +17 -14
  84. package/hooks/CluePopupContext.js +5 -5
  85. package/hooks/ClueProvider.js +12 -10
  86. package/hooks/selectors.js +22 -11
  87. package/hooks/useAnnotations.js +45 -29
  88. package/hooks/useClue.js +6 -4
  89. package/hooks/useClueActions.js +3 -3
  90. package/hooks/useClueConfig.js +5 -5
  91. package/hooks/useClueTypeConfig.js +3 -3
  92. package/hooks/useComparator.js +722 -435
  93. package/hooks/useErrors.js +22 -18
  94. package/hooks/useMyHighlights.js +66 -36
  95. package/hooks/useMyLocalStorage.js +63 -43
  96. package/iconify-CXMreGTg.js +1782 -0
  97. package/icons/Action.js +66 -49
  98. package/icons/Assessment.js +84 -68
  99. package/icons/Context.js +75 -61
  100. package/icons/Opinion.js +77 -65
  101. package/icons/iconMap.js +2 -2
  102. package/identity-CPGTqrE4.js +6 -0
  103. package/index-BDVjGvMI.js +696 -0
  104. package/index-BHPT3qoB.js +1172 -0
  105. package/index-BMxyILVD.js +465 -0
  106. package/index-BbPn6-Mw.js +15750 -0
  107. package/index-Dz1kF2MU.js +17654 -0
  108. package/isEmpty-BQkZubqU.js +29 -0
  109. package/isNil-CIubwp4T.js +6 -0
  110. package/isObject-FTY-5JQX.js +7 -0
  111. package/isObjectLike-OAgjjZye.js +48 -0
  112. package/isSymbol-Xd2FsJyp.js +8 -0
  113. package/last-CUCl67Im.js +7 -0
  114. package/main.js +58 -58
  115. package/package.json +1 -1
  116. package/sortBy-B-UKp4GT.js +100 -0
  117. package/sumBy-MYkDPHZL.js +8 -0
  118. package/tabs-xGuUGsJd.js +254 -0
  119. package/text/Frequency.js +42 -23
  120. package/toFinite-Bc55msYj.js +16 -0
  121. package/toNumber-DPxy1FBy.js +39 -0
  122. package/useClueTypeConfig-CH-nGq6a.js +3184 -0
  123. package/utils/chain.js +91 -64
  124. package/utils/classificationParser.js +519 -256
  125. package/utils/constants.js +35 -10
  126. package/utils/graph.js +72 -45
  127. package/utils/hashUtil.js +7 -7
  128. package/utils/line.js +131 -81
  129. package/utils/loggerUtil.js +5 -3
  130. package/utils/sessionStorage.js +41 -29
  131. package/utils/utils.js +9 -9
  132. package/utils/window.js +21 -10
  133. package/utils-Dr4wbKBZ.js +4182 -0
  134. package/ActionForm-BtTv0s4P.js +0 -340
  135. package/AnnotationDetails-D5tBIeEw.js +0 -160
  136. package/AnnotationPreview-CZr_CcZC.js +0 -140
  137. package/ClueEnrichContext-DH9lqjwH.js +0 -401
  138. package/FlexOne-BXWFOd1T.js +0 -6
  139. package/_Map-DXNg_Z-q.js +0 -54
  140. package/_MapCache-Cu25RRDU.js +0 -129
  141. package/_Uint8Array-DlJCtTvG.js +0 -102
  142. package/_baseAssignValue-CUmzp727.js +0 -20
  143. package/_baseClone-BlMmRXeX.js +0 -208
  144. package/_baseExtremum-P_0akmCi.js +0 -27
  145. package/_baseFlatten-CN7vDNEQ.js +0 -72
  146. package/_baseGet-Dgf6_xCm.js +0 -80
  147. package/_baseIsEqual-Cpjtfb3Q.js +0 -173
  148. package/_baseIteratee-CP1bocOX.js +0 -95
  149. package/_baseSlice-M5RKzt1A.js +0 -10
  150. package/_baseSum-wEbgNeUs.js +0 -10
  151. package/_baseUniq-tMFmk80M.js +0 -61
  152. package/_commonjsHelpers-C6fGbg64.js +0 -6
  153. package/_createAggregator-B4Cav8ZM.js +0 -53
  154. package/_getPrototype-CHAFQYL_.js +0 -5
  155. package/_getTag-BV_UoLYG.js +0 -90
  156. package/cloneDeep-BPVpFBzJ.js +0 -8
  157. package/countBy-DOutsa_w.js +0 -8
  158. package/debounce-DryYcbJ4.js +0 -56
  159. package/get-Bow1vKwx.js +0 -8
  160. package/groupBy-BheQYl6f.js +0 -8
  161. package/iconify-BBckr5AQ.js +0 -1263
  162. package/identity-ByMq8VxU.js +0 -6
  163. package/index-BUcHmehh.js +0 -975
  164. package/index-Bo-v5IAc.js +0 -12754
  165. package/index-CnaCBNrd.js +0 -358
  166. package/index-E7g8cRyW.js +0 -568
  167. package/index-p5_wX7q1.js +0 -11729
  168. package/isEmpty-g47Qir2A.js +0 -21
  169. package/isNil-CjWwlQS3.js +0 -6
  170. package/isObject-B53jY8Qg.js +0 -7
  171. package/isObjectLike-BatpeCIi.js +0 -29
  172. package/isSymbol-C3_SC0Qp.js +0 -8
  173. package/last-7CdUxN0r.js +0 -7
  174. package/sortBy-ITdmD17L.js +0 -79
  175. package/sumBy-DxJUU2E8.js +0 -8
  176. package/tabs-CgADNA57.js +0 -195
  177. package/toFinite-BMy6GObD.js +0 -14
  178. package/toNumber-YVhnnJv4.js +0 -31
  179. package/useClueTypeConfig-CneP98N_.js +0 -2260
  180. package/utils-CD0rFIFU.js +0 -2704
@@ -1,151 +1,176 @@
1
- import { jsx as l, jsxs as O } from "react/jsx-runtime";
2
- import { Chip as B, Tooltip as G, Box as $, Stack as H, CircularProgress as J } from "@mui/material";
3
- import K from "./display/icons/Iconified.js";
4
- import { ClueComponentContext as L } from "../hooks/ClueComponentContext.js";
5
- import { ClueGroupContext as N } from "../hooks/ClueGroupContext.js";
6
- import { C as E } from "../AnnotationPreview-CZr_CcZC.js";
7
- import { useClueEnrichSelector as Q } from "../hooks/selectors.js";
8
- import U from "../hooks/useAnnotations.js";
9
- import V from "../icons/Action.js";
10
- import v from "../icons/Assessment.js";
11
- import q from "../icons/Context.js";
12
- import z from "../icons/Opinion.js";
13
- import W from "../text/Frequency.js";
14
- import X, { useRef as Y, useMemo as x, useCallback as Z, useEffect as _, memo as F } from "react";
15
- import { u as d } from "../index-E7g8cRyW.js";
16
- const D = X.memo(
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Chip, Tooltip, Box, Stack, CircularProgress } from "@mui/material";
3
+ import Iconified from "./display/icons/Iconified.js";
4
+ import { ClueComponentContext } from "../hooks/ClueComponentContext.js";
5
+ import { ClueGroupContext } from "../hooks/ClueGroupContext.js";
6
+ import { C as CluePopupContext } from "../AnnotationPreview-DiQDjt9s.js";
7
+ import { useClueEnrichSelector } from "../hooks/selectors.js";
8
+ import useAnnotations from "../hooks/useAnnotations.js";
9
+ import ActionIcon from "../icons/Action.js";
10
+ import AssessmentIcon from "../icons/Assessment.js";
11
+ import ContextIcon from "../icons/Context.js";
12
+ import OpinionIcon from "../icons/Opinion.js";
13
+ import FrequencyText from "../text/Frequency.js";
14
+ import React__default, { useRef, useMemo, useCallback, useEffect, memo } from "react";
15
+ import { u as useContextSelector } from "../index-BDVjGvMI.js";
16
+ const EnrichedChip = React__default.memo(
17
17
  ({
18
- type: b,
19
- value: o,
20
- classification: k,
21
- contextIcon: y = !1,
22
- counters: a = !1,
23
- hideDetails: T = !1,
24
- hideLoading: A = !1,
25
- forceDetails: f = !1,
26
- setForceDetails: u = null,
27
- useDetailsIcon: p = !1,
28
- skipEnrichment: R = !1,
29
- slotProps: s = {},
30
- ...t
18
+ type: _type,
19
+ value,
20
+ classification: _classification,
21
+ contextIcon = false,
22
+ counters = false,
23
+ hideDetails = false,
24
+ hideLoading = false,
25
+ forceDetails = false,
26
+ setForceDetails = null,
27
+ useDetailsIcon = false,
28
+ skipEnrichment = false,
29
+ slotProps = {},
30
+ ...otherProps
31
31
  }) => {
32
- const { t: j } = d(L, (i) => i.i18next), C = Y(), S = d(N, (i) => i == null ? void 0 : i.type), w = Q((i) => i.defaultClassification), n = x(() => b ?? S, [b, S]), e = x(
33
- () => k ?? w,
34
- [k, w]
32
+ const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
33
+ const anchorRef = useRef();
34
+ const groupType = useContextSelector(ClueGroupContext, (ctx) => ctx == null ? void 0 : ctx.type);
35
+ const defaultClassification = useClueEnrichSelector((ctx) => ctx.defaultClassification);
36
+ const type = useMemo(() => _type ?? groupType, [_type, groupType]);
37
+ const classification = useMemo(
38
+ () => _classification ?? defaultClassification,
39
+ [_classification, defaultClassification]
35
40
  );
36
- if (!n)
41
+ if (!type) {
37
42
  throw new Error("Type was not provided as a prop, and component is not used in a group context.");
38
- const [m, c] = U(n, o, e, { skipEnrichment: R }), g = d(E, (i) => i.showInfo), M = d(E, (i) => i.closeInfo), h = Z(() => {
39
- const i = {};
40
- return u && (i.onClose = () => u(!1)), s != null && s.popover && (i.popoverProps = s.popover), i;
41
- }, [u, s.popover]), I = x(
42
- () => c ? (
43
+ }
44
+ const [annotations, loading] = useAnnotations(type, value, classification, { skipEnrichment });
45
+ const showInfo = useContextSelector(CluePopupContext, (ctx) => ctx.showInfo);
46
+ const closeInfo = useContextSelector(CluePopupContext, (ctx) => ctx.closeInfo);
47
+ const buildOptions = useCallback(() => {
48
+ const options = {};
49
+ if (setForceDetails) {
50
+ options.onClose = () => setForceDetails(false);
51
+ }
52
+ if (slotProps == null ? void 0 : slotProps.popover) {
53
+ options.popoverProps = slotProps.popover;
54
+ }
55
+ return options;
56
+ }, [setForceDetails, slotProps.popover]);
57
+ const clicker = useMemo(
58
+ () => !loading ? !hideDetails || useDetailsIcon ? (e) => {
59
+ var _a;
60
+ showInfo("details", anchorRef.current, { type, value, classification }, buildOptions());
61
+ (_a = otherProps.onClick) == null ? void 0 : _a.call(otherProps, e);
62
+ e.stopPropagation();
63
+ e.preventDefault();
64
+ } : otherProps.onClick : (
43
65
  // We need to give a dummy callback when loading so the popover doesn't get confused
44
- (i) => {
45
- var r;
46
- (r = t.onClick) == null || r.call(t, i);
66
+ (e) => {
67
+ var _a;
68
+ (_a = otherProps.onClick) == null ? void 0 : _a.call(otherProps, e);
47
69
  }
48
- ) : !T || p ? (i) => {
49
- var r;
50
- g("details", C.current, { type: n, value: o, classification: e }, h()), (r = t.onClick) == null || r.call(t, i), i.stopPropagation(), i.preventDefault();
51
- } : t.onClick,
70
+ ),
52
71
  // eslint-disable-next-line react-hooks/exhaustive-deps
53
- [c, T, p, t, n, o, e]
72
+ [loading, hideDetails, useDetailsIcon, otherProps, type, value, classification]
54
73
  );
55
- return _(() => {
56
- f ? g("details", C.current, { type: n, value: o, classification: e }, h()) : M("details", {
57
- type: n,
58
- value: o,
59
- classification: e
60
- });
61
- }, [e, f, n, o]), /* @__PURE__ */ l(
62
- B,
74
+ useEffect(() => {
75
+ if (forceDetails) {
76
+ showInfo("details", anchorRef.current, { type, value, classification }, buildOptions());
77
+ } else {
78
+ closeInfo("details", {
79
+ type,
80
+ value,
81
+ classification
82
+ });
83
+ }
84
+ }, [classification, forceDetails, type, value]);
85
+ return /* @__PURE__ */ jsx(
86
+ Chip,
63
87
  {
64
- ...t,
65
- ref: C,
66
- variant: t.variant || "outlined",
88
+ ...otherProps,
89
+ ref: anchorRef,
90
+ variant: otherProps.variant || "outlined",
67
91
  sx: {
68
- height: t.size !== "small" ? "40px" : "unset",
92
+ height: otherProps.size !== "small" ? "40px" : "unset",
69
93
  "& .MuiChip-label": { overflow: "visible" },
70
- ...t.sx ?? {}
94
+ ...otherProps.sx ?? {}
71
95
  },
72
- label: /* @__PURE__ */ O(H, { direction: "row", spacing: 1, alignItems: "center", children: [
73
- /* @__PURE__ */ l(
74
- v,
96
+ label: /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
97
+ /* @__PURE__ */ jsx(
98
+ AssessmentIcon,
75
99
  {
76
- ubiquitous: !0,
77
- value: { type: n, value: o, classification: e },
78
- annotations: m,
79
- counters: a,
80
- disableTooltip: f,
100
+ ubiquitous: true,
101
+ value: { type, value, classification },
102
+ annotations,
103
+ counters,
104
+ disableTooltip: forceDetails,
81
105
  style: { flexShrink: 0 }
82
106
  }
83
107
  ),
84
- /* @__PURE__ */ l(
85
- z,
108
+ /* @__PURE__ */ jsx(
109
+ OpinionIcon,
86
110
  {
87
- ubiquitous: !0,
88
- value: { type: n, value: o, classification: e },
89
- annotations: m,
90
- counters: a,
91
- disableTooltip: f,
111
+ ubiquitous: true,
112
+ value: { type, value, classification },
113
+ annotations,
114
+ counters,
115
+ disableTooltip: forceDetails,
92
116
  style: { flexShrink: 0 }
93
117
  }
94
118
  ),
95
- /* @__PURE__ */ l(
96
- q,
119
+ /* @__PURE__ */ jsx(
120
+ ContextIcon,
97
121
  {
98
- ubiquitous: !0,
99
- value: { type: n, value: o, classification: e },
100
- annotations: m,
101
- counters: a,
102
- showExtraIcon: y,
103
- disableTooltip: f,
122
+ ubiquitous: true,
123
+ value: { type, value, classification },
124
+ annotations,
125
+ counters,
126
+ showExtraIcon: contextIcon,
127
+ disableTooltip: forceDetails,
104
128
  style: { flexShrink: 0 }
105
129
  }
106
130
  ),
107
- t.label ?? /* @__PURE__ */ l(W, { fontSize: "inherit", annotations: m, value: o }),
108
- /* @__PURE__ */ l(
109
- v,
131
+ otherProps.label ?? /* @__PURE__ */ jsx(FrequencyText, { fontSize: "inherit", annotations, value }),
132
+ /* @__PURE__ */ jsx(
133
+ AssessmentIcon,
110
134
  {
111
- value: { type: n, value: o, classification: e },
112
- annotations: m,
113
- counters: a,
114
- disableTooltip: f,
135
+ value: { type, value, classification },
136
+ annotations,
137
+ counters,
138
+ disableTooltip: forceDetails,
115
139
  style: { flexShrink: 0 }
116
140
  }
117
141
  ),
118
- /* @__PURE__ */ l(
119
- z,
142
+ /* @__PURE__ */ jsx(
143
+ OpinionIcon,
120
144
  {
121
- value: { type: n, value: o, classification: e },
122
- annotations: m,
123
- counters: a,
124
- disableTooltip: f,
145
+ value: { type, value, classification },
146
+ annotations,
147
+ counters,
148
+ disableTooltip: forceDetails,
125
149
  style: { flexShrink: 0 }
126
150
  }
127
151
  ),
128
- /* @__PURE__ */ l(
129
- q,
152
+ /* @__PURE__ */ jsx(
153
+ ContextIcon,
130
154
  {
131
- value: { type: n, value: o, classification: e },
132
- annotations: m,
133
- counters: a,
134
- showExtraIcon: y,
135
- disableTooltip: f,
155
+ value: { type, value, classification },
156
+ annotations,
157
+ counters,
158
+ showExtraIcon: contextIcon,
159
+ disableTooltip: forceDetails,
136
160
  style: { flexShrink: 0 }
137
161
  }
138
162
  ),
139
- /* @__PURE__ */ l(V, { counters: a, value: { type: n, value: o, classification: e }, disableTooltip: f }),
140
- c && !A && /* @__PURE__ */ l(J, { color: "primary", size: 16 })
163
+ /* @__PURE__ */ jsx(ActionIcon, { counters, value: { type, value, classification }, disableTooltip: forceDetails }),
164
+ loading && !hideLoading && /* @__PURE__ */ jsx(CircularProgress, { color: "primary", size: 16 })
141
165
  ] }),
142
- onClick: p ? void 0 : I,
143
- onDelete: !c && p ? I : void 0,
144
- deleteIcon: p ? /* @__PURE__ */ l(G, { title: j("details.open"), children: /* @__PURE__ */ l($, { component: "span", sx: { pr: 1 }, children: /* @__PURE__ */ l(K, { icon: "ic:outline-info" }) }) }) : null
166
+ onClick: !useDetailsIcon ? clicker : void 0,
167
+ onDelete: !loading && useDetailsIcon ? clicker : void 0,
168
+ deleteIcon: useDetailsIcon ? /* @__PURE__ */ jsx(Tooltip, { title: t("details.open"), children: /* @__PURE__ */ jsx(Box, { component: "span", sx: { pr: 1 }, children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:outline-info" }) }) }) : null
145
169
  }
146
170
  );
147
171
  }
148
- ), ui = F(D);
172
+ );
173
+ const EnrichedChip$1 = memo(EnrichedChip);
149
174
  export {
150
- ui as default
175
+ EnrichedChip$1 as default
151
176
  };
@@ -1,152 +1,178 @@
1
- import { jsxs as J, jsx as a } from "react/jsx-runtime";
2
- import { useTheme as K, Stack as L, CircularProgress as N, Tooltip as Q, IconButton as U } from "@mui/material";
3
- import V from "./display/icons/Iconified.js";
4
- import { ClueComponentContext as W } from "../hooks/ClueComponentContext.js";
5
- import { ClueGroupContext as X } from "../hooks/ClueGroupContext.js";
6
- import { C as S } from "../AnnotationPreview-CZr_CcZC.js";
7
- import { useClueEnrichSelector as Y } from "../hooks/selectors.js";
8
- import Z from "../hooks/useAnnotations.js";
9
- import F from "../icons/Action.js";
10
- import j from "../icons/Assessment.js";
11
- import z from "../icons/Context.js";
12
- import O from "../icons/Opinion.js";
13
- import _ from "../text/Frequency.js";
14
- import { memo as D, useRef as P, useMemo as y, useCallback as ii, useEffect as ni } from "react";
15
- import { u as C } from "../index-E7g8cRyW.js";
16
- const oi = ({
17
- type: k,
18
- value: t,
19
- classification: s,
20
- contextIcon: g = !1,
21
- counters: r = !1,
22
- hideDetails: l = !1,
23
- hideLoading: R = !1,
24
- forceDetails: c = !1,
25
- setForceDetails: b = null,
26
- useDetailsIcon: p = !1,
27
- skipEnrichment: $ = !1,
28
- slotProps: n = {},
29
- children: G,
30
- ...m
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useTheme, Stack, CircularProgress, Tooltip, IconButton } from "@mui/material";
3
+ import Iconified from "./display/icons/Iconified.js";
4
+ import { ClueComponentContext } from "../hooks/ClueComponentContext.js";
5
+ import { ClueGroupContext } from "../hooks/ClueGroupContext.js";
6
+ import { C as CluePopupContext } from "../AnnotationPreview-DiQDjt9s.js";
7
+ import { useClueEnrichSelector } from "../hooks/selectors.js";
8
+ import useAnnotations from "../hooks/useAnnotations.js";
9
+ import ActionIcon from "../icons/Action.js";
10
+ import AssessmentIcon from "../icons/Assessment.js";
11
+ import ContextIcon from "../icons/Context.js";
12
+ import OpinionIcon from "../icons/Opinion.js";
13
+ import FrequencyText from "../text/Frequency.js";
14
+ import { memo, useRef, useMemo, useCallback, useEffect } from "react";
15
+ import { u as useContextSelector } from "../index-BDVjGvMI.js";
16
+ const EnrichedTypography = ({
17
+ type: _type,
18
+ value,
19
+ classification: _classification,
20
+ contextIcon = false,
21
+ counters = false,
22
+ hideDetails = false,
23
+ hideLoading = false,
24
+ forceDetails = false,
25
+ setForceDetails = null,
26
+ useDetailsIcon = false,
27
+ skipEnrichment = false,
28
+ slotProps = {},
29
+ children,
30
+ ...otherProps
31
31
  }) => {
32
- var q, v, B;
33
- const { t: M } = C(W, (i) => i.i18next), x = K(), T = P(), I = C(X, (i) => i == null ? void 0 : i.type), w = Y((i) => i.defaultClassification), o = y(() => k ?? I, [k, I]), e = y(
34
- () => s ?? w,
35
- [s, w]
32
+ var _a, _b, _c;
33
+ const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
34
+ const theme = useTheme();
35
+ const anchorRef = useRef();
36
+ const groupType = useContextSelector(ClueGroupContext, (ctx) => ctx == null ? void 0 : ctx.type);
37
+ const defaultClassification = useClueEnrichSelector((ctx) => ctx.defaultClassification);
38
+ const type = useMemo(() => _type ?? groupType, [_type, groupType]);
39
+ const classification = useMemo(
40
+ () => _classification ?? defaultClassification,
41
+ [_classification, defaultClassification]
36
42
  );
37
- if (!o)
43
+ if (!type) {
38
44
  throw new Error("Type was not provided as a prop, and component is not used in a group context.");
39
- const [f, d] = Z(o, t, e, { skipEnrichment: $ }), E = C(S, (i) => i.showInfo), H = C(S, (i) => i.closeInfo), h = ii(() => {
40
- const i = {};
41
- return b && (i.onClose = () => b(!1)), n != null && n.popover && (i.popoverProps = n.popover), i;
42
- }, [b, n.popover]), A = y(
43
- () => d ? (
45
+ }
46
+ const [annotations, loading] = useAnnotations(type, value, classification, { skipEnrichment });
47
+ const showInfo = useContextSelector(CluePopupContext, (state) => state.showInfo);
48
+ const closeInfo = useContextSelector(CluePopupContext, (state) => state.closeInfo);
49
+ const buildOptions = useCallback(() => {
50
+ const options = {};
51
+ if (setForceDetails) {
52
+ options.onClose = () => setForceDetails(false);
53
+ }
54
+ if (slotProps == null ? void 0 : slotProps.popover) {
55
+ options.popoverProps = slotProps.popover;
56
+ }
57
+ return options;
58
+ }, [setForceDetails, slotProps.popover]);
59
+ const clicker = useMemo(
60
+ () => !loading ? !hideDetails || useDetailsIcon ? (e) => {
61
+ var _a2;
62
+ showInfo("details", anchorRef.current, { type, value, classification }, buildOptions());
63
+ (_a2 = otherProps.onClick) == null ? void 0 : _a2.call(otherProps, e);
64
+ e.stopPropagation();
65
+ e.preventDefault();
66
+ } : otherProps.onClick : (
44
67
  // We need to give a dummy callback when loading so the popover doesn't get confused
45
- (i) => {
46
- var u;
47
- (u = m.onClick) == null || u.call(m, i);
68
+ (e) => {
69
+ var _a2;
70
+ (_a2 = otherProps.onClick) == null ? void 0 : _a2.call(otherProps, e);
48
71
  }
49
- ) : !l || p ? (i) => {
50
- var u;
51
- E("details", T.current, { type: o, value: t, classification: e }, h()), (u = m.onClick) == null || u.call(m, i), i.stopPropagation(), i.preventDefault();
52
- } : m.onClick,
72
+ ),
53
73
  // eslint-disable-next-line react-hooks/exhaustive-deps
54
- [d, l, p, m, o, t, e]
74
+ [loading, hideDetails, useDetailsIcon, otherProps, type, value, classification]
55
75
  );
56
- return ni(() => {
57
- c ? E("details", T.current, { type: o, value: t, classification: e }, h()) : H("details", {
58
- type: o,
59
- value: t,
60
- classification: e
61
- });
62
- }, [e, c, o, t]), /* @__PURE__ */ J(
63
- L,
76
+ useEffect(() => {
77
+ if (forceDetails) {
78
+ showInfo("details", anchorRef.current, { type, value, classification }, buildOptions());
79
+ } else {
80
+ closeInfo("details", {
81
+ type,
82
+ value,
83
+ classification
84
+ });
85
+ }
86
+ }, [classification, forceDetails, type, value]);
87
+ return /* @__PURE__ */ jsxs(
88
+ Stack,
64
89
  {
65
- ref: T,
90
+ ref: anchorRef,
66
91
  direction: "row",
67
92
  spacing: 1,
68
93
  alignItems: "center",
69
- ...n == null ? void 0 : n.stack,
94
+ ...slotProps == null ? void 0 : slotProps.stack,
70
95
  sx: [
71
96
  {
72
- cursor: !d && !l ? "pointer" : "inherit",
97
+ cursor: !loading && !hideDetails ? "pointer" : "inherit",
73
98
  borderBottom: "1px solid transparent",
74
- transition: x.transitions.create(["border-bottom-color"]),
99
+ transition: theme.transitions.create(["border-bottom-color"]),
75
100
  "&:hover": {
76
- borderBottomColor: !d && (l ? null : x.palette.primary.light)
101
+ borderBottomColor: !loading && (!hideDetails ? theme.palette.primary.light : null)
77
102
  }
78
103
  },
79
- ...Array.isArray((q = n == null ? void 0 : n.stack) == null ? void 0 : q.sx) ? (v = n == null ? void 0 : n.stack) == null ? void 0 : v.sx : [(B = n == null ? void 0 : n.stack) == null ? void 0 : B.sx]
104
+ ...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]
80
105
  ],
81
- onClick: p ? void 0 : A,
106
+ onClick: !useDetailsIcon ? clicker : void 0,
82
107
  children: [
83
- /* @__PURE__ */ a(
84
- j,
108
+ /* @__PURE__ */ jsx(
109
+ AssessmentIcon,
85
110
  {
86
- ubiquitous: !0,
87
- value: { type: o, value: t, classification: e },
88
- annotations: f,
89
- counters: r,
90
- disableTooltip: c
111
+ ubiquitous: true,
112
+ value: { type, value, classification },
113
+ annotations,
114
+ counters,
115
+ disableTooltip: forceDetails
91
116
  }
92
117
  ),
93
- /* @__PURE__ */ a(
94
- O,
118
+ /* @__PURE__ */ jsx(
119
+ OpinionIcon,
95
120
  {
96
- ubiquitous: !0,
97
- value: { type: o, value: t, classification: e },
98
- annotations: f,
99
- counters: r,
100
- disableTooltip: c
121
+ ubiquitous: true,
122
+ value: { type, value, classification },
123
+ annotations,
124
+ counters,
125
+ disableTooltip: forceDetails
101
126
  }
102
127
  ),
103
- /* @__PURE__ */ a(
104
- z,
128
+ /* @__PURE__ */ jsx(
129
+ ContextIcon,
105
130
  {
106
- ubiquitous: !0,
107
- value: { type: o, value: t, classification: e },
108
- annotations: f,
109
- counters: r,
110
- showExtraIcon: g,
111
- disableTooltip: c
131
+ ubiquitous: true,
132
+ value: { type, value, classification },
133
+ annotations,
134
+ counters,
135
+ showExtraIcon: contextIcon,
136
+ disableTooltip: forceDetails
112
137
  }
113
138
  ),
114
- G ?? /* @__PURE__ */ a(_, { id: `enriched-${o}-value`, ...m, annotations: f, value: t }),
115
- /* @__PURE__ */ a(
116
- j,
139
+ children ?? /* @__PURE__ */ jsx(FrequencyText, { id: `enriched-${type}-value`, ...otherProps, annotations, value }),
140
+ /* @__PURE__ */ jsx(
141
+ AssessmentIcon,
117
142
  {
118
- value: { type: o, value: t, classification: e },
119
- annotations: f,
120
- counters: r,
121
- disableTooltip: c
143
+ value: { type, value, classification },
144
+ annotations,
145
+ counters,
146
+ disableTooltip: forceDetails
122
147
  }
123
148
  ),
124
- /* @__PURE__ */ a(
125
- O,
149
+ /* @__PURE__ */ jsx(
150
+ OpinionIcon,
126
151
  {
127
- value: { type: o, value: t, classification: e },
128
- annotations: f,
129
- counters: r,
130
- disableTooltip: c
152
+ value: { type, value, classification },
153
+ annotations,
154
+ counters,
155
+ disableTooltip: forceDetails
131
156
  }
132
157
  ),
133
- /* @__PURE__ */ a(
134
- z,
158
+ /* @__PURE__ */ jsx(
159
+ ContextIcon,
135
160
  {
136
- value: { type: o, value: t, classification: e },
137
- annotations: f,
138
- counters: r,
139
- showExtraIcon: g,
140
- disableTooltip: c
161
+ value: { type, value, classification },
162
+ annotations,
163
+ counters,
164
+ showExtraIcon: contextIcon,
165
+ disableTooltip: forceDetails
141
166
  }
142
167
  ),
143
- /* @__PURE__ */ a(F, { counters: r, value: { type: o, value: t, classification: e }, disableTooltip: c }),
144
- d && !R && /* @__PURE__ */ a(N, { color: "primary", size: 18 }),
145
- !d && p && /* @__PURE__ */ a(Q, { title: M("details.open"), children: /* @__PURE__ */ a(U, { size: "small", onClick: A, sx: { color: x.palette.action.disabled }, children: /* @__PURE__ */ a(V, { icon: "ic:outline-info" }) }) })
168
+ /* @__PURE__ */ jsx(ActionIcon, { counters, value: { type, value, classification }, disableTooltip: forceDetails }),
169
+ loading && !hideLoading && /* @__PURE__ */ jsx(CircularProgress, { color: "primary", size: 18 }),
170
+ !loading && useDetailsIcon && /* @__PURE__ */ jsx(Tooltip, { title: t("details.open"), children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: clicker, sx: { color: theme.palette.action.disabled }, children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:outline-info" }) }) })
146
171
  ]
147
172
  }
148
173
  );
149
- }, yi = D(oi);
174
+ };
175
+ const EnrichedTypography$1 = memo(EnrichedTypography);
150
176
  export {
151
- yi as default
177
+ EnrichedTypography$1 as default
152
178
  };
@@ -1,32 +1,36 @@
1
- import { jsx as r, jsxs as o } from "react/jsx-runtime";
2
- import { Box as n, Accordion as i, AccordionSummary as a, Typography as t, AccordionDetails as s } from "@mui/material";
3
- import c from "./display/icons/Iconified.js";
4
- import d from "react";
5
- class f extends d.Component {
6
- constructor(e) {
7
- super(e), this.state = { hasError: !1, error: null };
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Box, Accordion, AccordionSummary, Typography, AccordionDetails } from "@mui/material";
3
+ import Iconified from "./display/icons/Iconified.js";
4
+ import React__default from "react";
5
+ class ErrorBoundary extends React__default.Component {
6
+ constructor(props) {
7
+ super(props);
8
+ this.state = { hasError: false, error: null };
8
9
  }
9
- static getDerivedStateFromError(e) {
10
- return { hasError: !0, error: e };
10
+ static getDerivedStateFromError(error) {
11
+ return { hasError: true, error };
11
12
  }
12
- componentDidCatch(e) {
13
- this.setState({ hasError: !0, error: e });
13
+ componentDidCatch(error) {
14
+ this.setState({ hasError: true, error });
14
15
  }
15
16
  render() {
16
- return this.state.hasError ? /* @__PURE__ */ r(n, { pt: 6, textAlign: "center", fontSize: 20, children: /* @__PURE__ */ o(i, { elevation: 0, children: [
17
- /* @__PURE__ */ r(
18
- a,
19
- {
20
- expandIcon: /* @__PURE__ */ r(c, { icon: "ic:baseline-expand-more" }),
21
- "aria-controls": "panel1-content",
22
- id: "panel1-header",
23
- children: /* @__PURE__ */ r(t, { align: "center", sx: { width: "100%", fontSize: "1.2rem" }, variant: "h5", children: this.state.error.message })
24
- }
25
- ),
26
- /* @__PURE__ */ r(s, { children: /* @__PURE__ */ r("code", { children: /* @__PURE__ */ r(t, { variant: "h6", children: this.state.error.stack }) }) })
27
- ] }) }) : this.props.children;
17
+ if (this.state.hasError) {
18
+ return /* @__PURE__ */ jsx(Box, { pt: 6, textAlign: "center", fontSize: 20, children: /* @__PURE__ */ jsxs(Accordion, { elevation: 0, children: [
19
+ /* @__PURE__ */ jsx(
20
+ AccordionSummary,
21
+ {
22
+ expandIcon: /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-expand-more" }),
23
+ "aria-controls": "panel1-content",
24
+ id: "panel1-header",
25
+ children: /* @__PURE__ */ jsx(Typography, { align: "center", sx: { width: "100%", fontSize: "1.2rem" }, variant: "h5", children: this.state.error.message })
26
+ }
27
+ ),
28
+ /* @__PURE__ */ jsx(AccordionDetails, { children: /* @__PURE__ */ jsx("code", { children: /* @__PURE__ */ jsx(Typography, { variant: "h6", children: this.state.error.stack }) }) })
29
+ ] }) });
30
+ }
31
+ return this.props.children;
28
32
  }
29
33
  }
30
34
  export {
31
- f as default
35
+ ErrorBoundary as default
32
36
  };