@splunk/visualizations-shared 28.9.0 → 28.10.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.
package/Tooltip.js ADDED
@@ -0,0 +1,756 @@
1
+ /* Copyright © 2020 Splunk Inc.
2
+ SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
3
+ in part without a valid written license from Splunk Inc. is PROHIBITED. */
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __defProps = Object.defineProperties;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
11
+ var __getProtoOf = Object.getPrototypeOf;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __spreadValues = (a, b) => {
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ if (__getOwnPropSymbols)
20
+ for (var prop of __getOwnPropSymbols(b)) {
21
+ if (__propIsEnum.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ }
24
+ return a;
25
+ };
26
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
+ var __objRest = (source, exclude) => {
28
+ var target = {};
29
+ for (var prop in source)
30
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
31
+ target[prop] = source[prop];
32
+ if (source != null && __getOwnPropSymbols)
33
+ for (var prop of __getOwnPropSymbols(source)) {
34
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
35
+ target[prop] = source[prop];
36
+ }
37
+ return target;
38
+ };
39
+ var __export = (target, all) => {
40
+ for (var name in all)
41
+ __defProp(target, name, { get: all[name], enumerable: true });
42
+ };
43
+ var __copyProps = (to, from, except, desc) => {
44
+ if (from && typeof from === "object" || typeof from === "function") {
45
+ for (let key of __getOwnPropNames(from))
46
+ if (!__hasOwnProp.call(to, key) && key !== except)
47
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
48
+ }
49
+ return to;
50
+ };
51
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
52
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
53
+ // If the importer is in node compatibility mode or this is not an ESM
54
+ // file that has been converted to a CommonJS file using a Babel-
55
+ // compatible transform (i.e. "__esModule" has not been set), then set
56
+ // "default" to the CommonJS "module.exports" for node compatibility.
57
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
58
+ mod
59
+ ));
60
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
61
+
62
+ // src/Tooltip.tsx
63
+ var Tooltip_exports = {};
64
+ __export(Tooltip_exports, {
65
+ TooltipContent: () => TooltipContent,
66
+ TooltipLabel: () => TooltipLabel,
67
+ TooltipPopover: () => TooltipPopover,
68
+ TooltipRow: () => TooltipRow,
69
+ TooltipSection: () => TooltipSection,
70
+ TooltipSwatch: () => TooltipSwatch,
71
+ TooltipTable: () => TooltipTable,
72
+ TooltipTitle: () => TooltipTitle,
73
+ TooltipValue: () => TooltipValue
74
+ });
75
+ module.exports = __toCommonJS(Tooltip_exports);
76
+
77
+ // esm-externals:react
78
+ var react_exports = {};
79
+ __export(react_exports, {
80
+ default: () => react_default
81
+ });
82
+ var defaultImport = __toESM(require("react"));
83
+ __reExport(react_exports, require("react"));
84
+ var react_default = "default" in defaultImport ? defaultImport.default : defaultImport;
85
+
86
+ // esm-externals:@splunk/react-ui/Popover
87
+ var Popover_exports = {};
88
+ __export(Popover_exports, {
89
+ default: () => Popover_default
90
+ });
91
+ var defaultImport2 = __toESM(require("@splunk/react-ui/Popover"));
92
+ __reExport(Popover_exports, require("@splunk/react-ui/Popover"));
93
+ var Popover_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
94
+
95
+ // esm-externals:@splunk/themes
96
+ var themes_exports = {};
97
+ __export(themes_exports, {
98
+ default: () => themes_default
99
+ });
100
+ var defaultImport3 = __toESM(require("@splunk/themes"));
101
+ __reExport(themes_exports, require("@splunk/themes"));
102
+ var themes_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
103
+
104
+ // esm-externals:styled-components
105
+ var styled_components_exports = {};
106
+ __export(styled_components_exports, {
107
+ default: () => styled_components_default
108
+ });
109
+ var defaultImport4 = __toESM(require("styled-components"));
110
+ __reExport(styled_components_exports, require("styled-components"));
111
+ var styled_components_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;
112
+
113
+ // esm-externals:lodash/get
114
+ var get_exports = {};
115
+ __export(get_exports, {
116
+ default: () => get_default
117
+ });
118
+ var defaultImport5 = __toESM(require("lodash/get"));
119
+ __reExport(get_exports, require("lodash/get"));
120
+ var get_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
121
+
122
+ // esm-externals:@splunk/themes/getSettingsFromThemedProps
123
+ var getSettingsFromThemedProps_exports = {};
124
+ __export(getSettingsFromThemedProps_exports, {
125
+ default: () => getSettingsFromThemedProps_default
126
+ });
127
+ var defaultImport6 = __toESM(require("@splunk/themes/getSettingsFromThemedProps"));
128
+ __reExport(getSettingsFromThemedProps_exports, require("@splunk/themes/getSettingsFromThemedProps"));
129
+ var getSettingsFromThemedProps_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;
130
+
131
+ // src/themeUtils.ts
132
+ var isSplunk1cdTheme = (theme, appearance) => {
133
+ var _a;
134
+ if ((appearance == null ? void 0 : appearance.style) === "gradient") {
135
+ return true;
136
+ }
137
+ if ((appearance == null ? void 0 : appearance.style) === "flat") {
138
+ return false;
139
+ }
140
+ const visualizationTheme = theme;
141
+ if (visualizationTheme == null ? void 0 : visualizationTheme.visualizationThemeFamily) {
142
+ return visualizationTheme.visualizationThemeFamily === "splunk-1cd";
143
+ }
144
+ if ((visualizationTheme == null ? void 0 : visualizationTheme.name) === "splunk1cdLight" || (visualizationTheme == null ? void 0 : visualizationTheme.name) === "splunk1cdDark") {
145
+ return true;
146
+ }
147
+ const customizer = (_a = visualizationTheme == null ? void 0 : visualizationTheme.splunkThemeV1) == null ? void 0 : _a.customizer;
148
+ return customizer === themes_exports.unstable_splunk1cdThemeCustomizer || (customizer == null ? void 0 : customizer.name) === themes_exports.unstable_splunk1cdThemeCustomizer.name;
149
+ };
150
+
151
+ // src/Tooltip.tsx
152
+ var TooltipContent = styled_components_default.div.attrs({ "data-tooltip-content": true })``;
153
+ var TooltipTable = styled_components_default.table.attrs({ "data-tooltip-table": true })``;
154
+ var TooltipSection = styled_components_default.div.attrs({ "data-tooltip-section": true })``;
155
+ var TooltipRow = styled_components_default.div.attrs({ "data-tooltip-row": true })``;
156
+ var TooltipTitle = styled_components_default.div.attrs({
157
+ "data-tooltip-title": true,
158
+ "data-tooltip-heading": true
159
+ })``;
160
+ var TooltipLabel = styled_components_default.div.attrs((props) => ({
161
+ "data-tooltip-label-cell": true,
162
+ "data-tooltip-label": props["data-tooltip-title"] ? void 0 : true
163
+ }))``;
164
+ var TooltipValue = styled_components_default.div.attrs({ "data-tooltip-value": true })``;
165
+ var TooltipSwatch = styled_components_default.div.attrs({ "data-tooltip-color": true })``;
166
+ var tooltipSpacing = {
167
+ columnGap: "8px",
168
+ swatchSize: "12px"
169
+ };
170
+ var tooltipTypography = styled_components_exports.css`
171
+ font-family: ${themes_exports.variables.fontFamily};
172
+ font-size: ${themes_exports.variables.fontSizeSmall};
173
+ line-height: ${themes_exports.variables.lineHeightComfortable};
174
+ `;
175
+ var tooltipContentColor = styled_components_exports.css`
176
+ color: ${(0, themes_exports.pick)({
177
+ dark: "#fafafa",
178
+ light: "#2c2c2c"
179
+ })};
180
+ @supports (color: oklch(0 0 0)) {
181
+ color: ${themes_exports.variables.contentColorActive};
182
+ }
183
+ `;
184
+ var TOOLTIP_BACKDROP_COLOR = {
185
+ light: "rgba(255, 255, 255, 0.5)",
186
+ dark: "rgba(0, 0, 0, 0.5)"
187
+ };
188
+ var TOOLTIP_BACKDROP_FILTER = "blur(50px)";
189
+ var getTooltipBackdropColor = (isDark) => isDark ? TOOLTIP_BACKDROP_COLOR.dark : TOOLTIP_BACKDROP_COLOR.light;
190
+ var getTooltipArrowEdge = (arrow) => ["top", "right", "bottom", "left"].find((edge) => Number.parseFloat(arrow.style[edge]) === 0);
191
+ var getCompositeSurfacePath = (outer, body, arrow, edge) => {
192
+ const x = body.left - outer.left;
193
+ const y = body.top - outer.top;
194
+ const { width } = body;
195
+ const { height } = body;
196
+ if (width <= 0 || height <= 0) {
197
+ return void 0;
198
+ }
199
+ const round = Math.min(4, width / 2, height / 2);
200
+ const arrowLeft = arrow.left - outer.left;
201
+ const arrowTop = arrow.top - outer.top;
202
+ const arrowRight = arrow.right - outer.left;
203
+ const arrowBottom = arrow.bottom - outer.top;
204
+ const clamp = (value, min, max) => Math.max(min, Math.min(value, max));
205
+ const point = (value) => Number(value.toFixed(2)).toString();
206
+ const commands = [`M ${point(x + round)} ${point(y)}`];
207
+ if (edge === "top") {
208
+ commands.push(
209
+ `L ${point(clamp(arrowLeft, x, x + width))} ${point(y)}`,
210
+ `L ${point((arrowLeft + arrowRight) / 2)} ${point(Math.min(arrowTop, y))}`,
211
+ `L ${point(clamp(arrowRight, x, x + width))} ${point(y)}`
212
+ );
213
+ }
214
+ commands.push(
215
+ `L ${point(x + width - round)} ${point(y)}`,
216
+ `Q ${point(x + width)} ${point(y)} ${point(x + width)} ${point(y + round)}`
217
+ );
218
+ if (edge === "right") {
219
+ commands.push(
220
+ `L ${point(x + width)} ${point(clamp(arrowTop, y, y + height))}`,
221
+ `L ${point(Math.max(arrowRight, x + width))} ${point((arrowTop + arrowBottom) / 2)}`,
222
+ `L ${point(x + width)} ${point(clamp(arrowBottom, y, y + height))}`
223
+ );
224
+ }
225
+ commands.push(
226
+ `L ${point(x + width)} ${point(y + height - round)}`,
227
+ `Q ${point(x + width)} ${point(y + height)} ${point(x + width - round)} ${point(y + height)}`
228
+ );
229
+ if (edge === "bottom") {
230
+ commands.push(
231
+ `L ${point(clamp(arrowRight, x, x + width))} ${point(y + height)}`,
232
+ `L ${point((arrowLeft + arrowRight) / 2)} ${point(Math.max(arrowBottom, y + height))}`,
233
+ `L ${point(clamp(arrowLeft, x, x + width))} ${point(y + height)}`
234
+ );
235
+ }
236
+ commands.push(
237
+ `L ${point(x + round)} ${point(y + height)}`,
238
+ `Q ${point(x)} ${point(y + height)} ${point(x)} ${point(y + height - round)}`
239
+ );
240
+ if (edge === "left") {
241
+ commands.push(
242
+ `L ${point(x)} ${point(clamp(arrowBottom, y, y + height))}`,
243
+ `L ${point(Math.min(arrowLeft, x))} ${point((arrowTop + arrowBottom) / 2)}`,
244
+ `L ${point(x)} ${point(clamp(arrowTop, y, y + height))}`
245
+ );
246
+ }
247
+ commands.push(
248
+ `L ${point(x)} ${point(y + round)}`,
249
+ `Q ${point(x)} ${point(y)} ${point(x + round)} ${point(y)}`,
250
+ "Z"
251
+ );
252
+ return commands.join(" ");
253
+ };
254
+ var svgBackground = (svg) => `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
255
+ var getTooltipMaskSvg = ({ path, width, height }) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}"><path fill="white" d="${path}"/></svg>`;
256
+ var getTooltipMaskImage = (geometry) => svgBackground(getTooltipMaskSvg(geometry));
257
+ var nextBackdropFilterId = 0;
258
+ var createBackdropClip = (element) => {
259
+ var _a, _b;
260
+ const document = element.ownerDocument;
261
+ if (!/\b(?:Chrome|Chromium)\//.test((_b = (_a = document.defaultView) == null ? void 0 : _a.navigator.userAgent) != null ? _b : "")) return void 0;
262
+ const { dataset } = element;
263
+ const ns = "http://www.w3.org/2000/svg";
264
+ const svg = document.createElementNS(ns, "svg");
265
+ svg.setAttribute("aria-hidden", "true");
266
+ svg.setAttribute("focusable", "false");
267
+ svg.style.cssText = "position:absolute;width:0;height:0;pointer-events:none";
268
+ const filter = document.createElementNS(ns, "filter");
269
+ let id;
270
+ do {
271
+ id = `tooltip-backdrop-${nextBackdropFilterId}`;
272
+ nextBackdropFilterId += 1;
273
+ } while (document.getElementById(id));
274
+ filter.id = id;
275
+ filter.setAttribute("filterUnits", "userSpaceOnUse");
276
+ filter.setAttribute("color-interpolation-filters", "sRGB");
277
+ filter.setAttribute("x", "0");
278
+ filter.setAttribute("y", "0");
279
+ const image = document.createElementNS(ns, "feImage");
280
+ image.setAttribute("result", "shape");
281
+ image.setAttribute("x", "0");
282
+ image.setAttribute("y", "0");
283
+ const composite = document.createElementNS(ns, "feComposite");
284
+ composite.setAttribute("in", "SourceGraphic");
285
+ composite.setAttribute("in2", "shape");
286
+ composite.setAttribute("operator", "in");
287
+ filter.append(image, composite);
288
+ svg.append(filter);
289
+ element.append(svg);
290
+ return {
291
+ update: (geometry) => {
292
+ filter.setAttribute("width", String(geometry.width));
293
+ filter.setAttribute("height", String(geometry.height));
294
+ image.setAttribute("width", String(geometry.width));
295
+ image.setAttribute("height", String(geometry.height));
296
+ image.setAttribute(
297
+ "href",
298
+ `data:image/svg+xml,${encodeURIComponent(getTooltipMaskSvg(geometry))}`
299
+ );
300
+ element.style.setProperty(
301
+ "--tooltip-shaped-backdrop",
302
+ `${TOOLTIP_BACKDROP_FILTER} url("#${id}")`
303
+ );
304
+ dataset.tooltipFilterClip = "";
305
+ },
306
+ remove: () => {
307
+ svg.remove();
308
+ delete dataset.tooltipFilterClip;
309
+ element.style.removeProperty("--tooltip-shaped-backdrop");
310
+ }
311
+ };
312
+ };
313
+ var getTooltipImages = ({ path, width, height }, isDark) => {
314
+ const borderColor = isDark ? "rgba(255, 255, 255, 0.3)" : "#FFFFFF";
315
+ const outline = svgBackground(
316
+ `<svg
317
+ xmlns="http://www.w3.org/2000/svg"
318
+ width="${width}"
319
+ height="${height}"
320
+ viewBox="0 0 ${width} ${height}"
321
+ >
322
+ <path
323
+ d="${path}"
324
+ fill="none"
325
+ stroke="${borderColor}"
326
+ stroke-width="2"
327
+ stroke-linejoin="round"
328
+ />
329
+ </svg>`
330
+ );
331
+ const surface = svgBackground(
332
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
333
+ <path d="${path}" fill="${getTooltipBackdropColor(isDark)}" stroke="${borderColor}"
334
+ stroke-width="2" stroke-linejoin="round" clip-path="url(#inside)" />
335
+ <defs><clipPath id="inside"><path d="${path}" /></clipPath></defs>
336
+ </svg>`
337
+ );
338
+ const shadow = svgBackground(
339
+ `<svg
340
+ xmlns="http://www.w3.org/2000/svg"
341
+ width="${width + 54}"
342
+ height="${height + 54}"
343
+ viewBox="-27 -27 ${width + 54} ${height + 54}"
344
+ >
345
+ <defs>
346
+ <filter id="shadow" x="-50%" y="-50%" width="200%" height="200%">
347
+ <feGaussianBlur in="SourceAlpha" stdDeviation="9" result="blur" />
348
+ <feFlood
349
+ flood-color="#000000"
350
+ flood-opacity="${isDark ? "0.46" : "0.26"}"
351
+ result="shadowColor"
352
+ />
353
+ <feComposite in="shadowColor" in2="blur" operator="in" />
354
+ </filter>
355
+ <clipPath id="outside" clipPathUnits="userSpaceOnUse">
356
+ <path
357
+ d="M -10000 -10000 H 10000 V 10000 H -10000 Z ${path}"
358
+ fill-rule="evenodd"
359
+ clip-rule="evenodd"
360
+ />
361
+ </clipPath>
362
+ </defs>
363
+ <path d="${path}" fill="#000000" filter="url(#shadow)" clip-path="url(#outside)" />
364
+ </svg>`
365
+ );
366
+ return { outline, shadow, surface };
367
+ };
368
+ var StyledTooltipPopover = styled_components_default(Popover_default)`
369
+ /* Anchor both decorative layers to the popover's measured bounds. */
370
+ position: relative;
371
+
372
+ /* Decorations cover the surface without affecting layout or intercepting input. */
373
+ &::before,
374
+ &::after {
375
+ content: '';
376
+ position: absolute;
377
+ pointer-events: none;
378
+ background-repeat: no-repeat;
379
+ background-size: 100% 100%;
380
+ }
381
+
382
+ /* Mask the translucent background and outline to the body-and-arrow shape.
383
+ The absent fallback mask hides the surface until its geometry has been measured. */
384
+ &::before {
385
+ inset: 0;
386
+ z-index: 0;
387
+ background-color: var(--tooltip-backdrop);
388
+ background-image: var(--tooltip-outline, none);
389
+ /* Keep the blur on the same masked surface as the tint so the blur follows
390
+ the tooltip body and arrow instead of the popover's rectangular bounds. */
391
+ backdrop-filter: ${TOOLTIP_BACKDROP_FILTER};
392
+ -webkit-backdrop-filter: ${TOOLTIP_BACKDROP_FILTER};
393
+ mask-image: var(--tooltip-mask, none);
394
+ -webkit-mask-image: var(--tooltip-mask, none);
395
+ mask-size: 100% 100%;
396
+ -webkit-mask-size: 100% 100%;
397
+ mask-repeat: no-repeat;
398
+ -webkit-mask-repeat: no-repeat;
399
+ }
400
+
401
+ /* Clip the blurred pixels inside the filter itself. A CSS mask can be lost
402
+ under a rounded iframe ancestor; blending instead prevents real popover
403
+ layers from sampling the chart backdrop. Neither is needed on this path. */
404
+ &[data-tooltip-filter-clip]::before {
405
+ background-color: transparent;
406
+ background-image: var(--tooltip-surface, none);
407
+ mask-image: none;
408
+ -webkit-mask-image: none;
409
+ backdrop-filter: var(--tooltip-shaped-backdrop);
410
+ -webkit-backdrop-filter: var(--tooltip-shaped-backdrop);
411
+ }
412
+
413
+ /* Leave 27px around the shape for the shadow blur; the SVG clips away its interior. */
414
+ &::after {
415
+ inset: -27px;
416
+ z-index: 1;
417
+ background-image: var(--tooltip-shadow, none);
418
+ }
419
+
420
+ /* Preserve SUI's arrow measurements and positioning while hiding its original skin. */
421
+ > [data-test='popover-arrow'] {
422
+ opacity: 0;
423
+ pointer-events: none;
424
+ }
425
+
426
+ /* Keep content above the decorations and replace SUI's opaque skin with theme typography. */
427
+ > div:not([data-test='popover-arrow']) {
428
+ position: relative;
429
+ z-index: 2;
430
+ background: transparent;
431
+ border: 0;
432
+ border-radius: 4px;
433
+ box-shadow: none;
434
+ ${tooltipTypography}
435
+ }
436
+ `;
437
+ var TooltipContentStyles = styled_components_default.div`
438
+ display: inline-block;
439
+ vertical-align: top;
440
+
441
+ [data-tooltip-content] {
442
+ display: flex;
443
+ flex-direction: column;
444
+ row-gap: ${themes_exports.variables.spacingXSmall};
445
+ min-width: 150px;
446
+ max-width: 500px;
447
+ padding: ${(props) => props.$useTooltipPadding ? styled_components_exports.css`
448
+ ${themes_exports.variables.spacingMedium} ${themes_exports.variables.spacingLarge}
449
+ ` : "0"};
450
+ ${tooltipTypography}
451
+ ${tooltipContentColor}
452
+ }
453
+
454
+ [data-tooltip-table] {
455
+ width: 100%;
456
+ border-collapse: separate;
457
+ border-spacing: 0 ${themes_exports.variables.spacingXSmall};
458
+ margin-top: -${themes_exports.variables.spacingXSmall};
459
+ margin-bottom: -${themes_exports.variables.spacingXSmall};
460
+ table-layout: auto;
461
+ font: inherit;
462
+ color: inherit;
463
+ }
464
+
465
+ [data-tooltip-table] td,
466
+ [data-tooltip-table] th {
467
+ padding: 0;
468
+ vertical-align: top;
469
+ }
470
+
471
+ [data-tooltip-row] {
472
+ margin: 0;
473
+ font-size: inherit;
474
+ line-height: inherit;
475
+ color: inherit;
476
+ }
477
+
478
+ div[data-tooltip-row] {
479
+ display: flex;
480
+ justify-content: space-between;
481
+ align-items: flex-start;
482
+ column-gap: ${themes_exports.variables.spacingLarge};
483
+ }
484
+
485
+ [data-tooltip-section] {
486
+ display: flex;
487
+ flex-direction: column;
488
+ row-gap: ${themes_exports.variables.spacingXSmall};
489
+ margin: 0;
490
+ }
491
+
492
+ [data-tooltip-section]:empty {
493
+ display: none;
494
+ }
495
+
496
+ div[data-tooltip-label-cell] {
497
+ display: flex;
498
+ align-items: center;
499
+ column-gap: ${tooltipSpacing.columnGap};
500
+ min-width: 0;
501
+ }
502
+
503
+ [data-tooltip-table] td[data-tooltip-label] {
504
+ padding-right: ${themes_exports.variables.spacingLarge};
505
+ }
506
+
507
+ [data-tooltip-heading] {
508
+ margin: 0;
509
+ }
510
+
511
+ thead[data-tooltip-heading] th {
512
+ font: inherit;
513
+ color: inherit;
514
+ text-align: left;
515
+ }
516
+
517
+ [data-tooltip-title],
518
+ [data-tooltip-label],
519
+ [data-tooltip-value] {
520
+ ${tooltipContentColor}
521
+ font-size: ${themes_exports.variables.fontSizeSmall};
522
+ }
523
+
524
+ [data-tooltip-label-cell],
525
+ [data-tooltip-title],
526
+ [data-tooltip-value] {
527
+ min-width: 0;
528
+ white-space: normal;
529
+ word-break: normal;
530
+ overflow-wrap: anywhere;
531
+ }
532
+
533
+ [data-tooltip-label] {
534
+ overflow-wrap: break-word;
535
+ }
536
+
537
+ [data-tooltip-title] {
538
+ font-weight: ${themes_exports.variables.fontWeightNormal};
539
+ /* Fade the text color so nested swatches retain their own opacity. */
540
+ color: ${(0, themes_exports.pick)({
541
+ dark: "rgba(250, 250, 250, 0.7)",
542
+ light: "rgba(44, 44, 44, 0.7)"
543
+ })};
544
+ @supports (color: oklch(0 0 0)) {
545
+ color: color-mix(in srgb, ${themes_exports.variables.contentColorActive} 70%, transparent);
546
+ }
547
+ }
548
+
549
+ [data-tooltip-label] {
550
+ font-weight: ${themes_exports.variables.fontWeightNormal};
551
+ opacity: 1;
552
+ }
553
+
554
+ [data-tooltip-value] {
555
+ white-space: pre-wrap;
556
+ text-align: right;
557
+ font-weight: ${themes_exports.variables.fontWeightSemiBold};
558
+ opacity: 1;
559
+ }
560
+
561
+ [data-tooltip-compact] {
562
+ padding: 3px 8px;
563
+ min-width: 20px;
564
+ text-align: center;
565
+ line-height: ${themes_exports.variables.lineHeightNormal};
566
+ }
567
+
568
+ [data-tooltip-color] {
569
+ box-sizing: border-box;
570
+ display: inline-block;
571
+ vertical-align: middle;
572
+ flex-shrink: 0;
573
+ width: ${tooltipSpacing.swatchSize};
574
+ height: ${tooltipSpacing.swatchSize};
575
+ margin: 0 ${tooltipSpacing.columnGap} 0 0;
576
+ transform: translateY(-1px);
577
+ border-radius: 1.5px;
578
+ position: relative;
579
+ border: 1px solid var(--tooltip-color);
580
+ background-color: transparent;
581
+ }
582
+
583
+ [data-tooltip-color-shape='square'] {
584
+ border-radius: 1.5px;
585
+ }
586
+
587
+ [data-tooltip-color-shape='circle'] {
588
+ border-radius: 50%;
589
+ }
590
+
591
+ [data-tooltip-color]::before {
592
+ content: '';
593
+ position: absolute;
594
+ inset: 0px;
595
+ border-radius: inherit;
596
+ background-color: var(--tooltip-color);
597
+ opacity: 0.5;
598
+ pointer-events: none;
599
+ }
600
+
601
+ [data-tooltip-color-shape='square']::before {
602
+ border-radius: 0.5px;
603
+ }
604
+
605
+ [data-tooltip-color-fill='opaque']::before {
606
+ opacity: 1;
607
+ }
608
+
609
+ div[data-tooltip-label-cell] > [data-tooltip-color] {
610
+ margin-right: 0;
611
+ }
612
+
613
+ [data-tooltip-icon] {
614
+ margin-left: ${themes_exports.variables.spacingXSmall};
615
+ display: inline-block;
616
+ vertical-align: middle;
617
+ }
618
+ `;
619
+ var useTooltipTheme = () => {
620
+ var _a;
621
+ const theme = (0, themes_exports.useSplunkTheme)();
622
+ const themeContext = react_default.useContext(styled_components_exports.ThemeContext);
623
+ return {
624
+ is1cd: isSplunk1cdTheme(themeContext),
625
+ isDark: ((_a = themeContext == null ? void 0 : themeContext.visualizationColorScheme) != null ? _a : theme == null ? void 0 : theme.colorScheme) === "dark"
626
+ };
627
+ };
628
+ var TooltipPopover = (_a) => {
629
+ var _b = _a, {
630
+ children,
631
+ useTooltipPadding = true
632
+ } = _b, props = __objRest(_b, [
633
+ "children",
634
+ "useTooltipPadding"
635
+ ]);
636
+ var _a2;
637
+ const { is1cd, isDark } = useTooltipTheme();
638
+ const { elementRef, style } = props;
639
+ const surfaceRef = react_default.useRef();
640
+ const isDarkRef = react_default.useRef(isDark);
641
+ const cleanupRef = react_default.useRef();
642
+ react_default.useLayoutEffect(() => {
643
+ if (isDarkRef.current === isDark) return;
644
+ isDarkRef.current = isDark;
645
+ const surface = surfaceRef.current;
646
+ if (surface == null ? void 0 : surface.geometry) {
647
+ const images = getTooltipImages(surface.geometry, isDark);
648
+ surface.element.style.setProperty("--tooltip-mask", getTooltipMaskImage(surface.geometry));
649
+ surface.element.style.setProperty("--tooltip-outline", images.outline);
650
+ surface.element.style.setProperty("--tooltip-shadow", images.shadow);
651
+ surface.element.style.setProperty("--tooltip-surface", images.surface);
652
+ }
653
+ }, [isDark]);
654
+ const setPopoverElementRef = react_default.useCallback(
655
+ (element) => {
656
+ var _a3;
657
+ (_a3 = cleanupRef.current) == null ? void 0 : _a3.call(cleanupRef);
658
+ cleanupRef.current = void 0;
659
+ surfaceRef.current = void 0;
660
+ if (element) {
661
+ const outer = element.parentElement;
662
+ const arrow = element.querySelector('[data-test="popover-arrow"]');
663
+ const content = element.querySelector(
664
+ ':scope > div:not([data-test="popover-arrow"])'
665
+ );
666
+ if (outer && arrow && content) {
667
+ const backdropClip = createBackdropClip(element);
668
+ const surface = { element, geometry: void 0 };
669
+ surfaceRef.current = surface;
670
+ let disposed = false;
671
+ let frame;
672
+ const updateSurfaceShape = () => {
673
+ var _a4, _b2, _c;
674
+ if (disposed) return;
675
+ const edge = getTooltipArrowEdge(arrow);
676
+ if (!edge) return;
677
+ const popoverRect = element.getBoundingClientRect();
678
+ const contentRect = content.getBoundingClientRect();
679
+ const arrowRect = arrow.getBoundingClientRect();
680
+ const path = getCompositeSurfacePath(popoverRect, contentRect, arrowRect, edge);
681
+ if (!path || popoverRect.width <= 0 || popoverRect.height <= 0) return;
682
+ const width = Number(popoverRect.width.toFixed(2));
683
+ const height = Number(popoverRect.height.toFixed(2));
684
+ if (path !== ((_a4 = surface.geometry) == null ? void 0 : _a4.path) || width !== ((_b2 = surface.geometry) == null ? void 0 : _b2.width) || height !== ((_c = surface.geometry) == null ? void 0 : _c.height)) {
685
+ const images = getTooltipImages({ path, width, height }, isDarkRef.current);
686
+ const geometry = { path, width, height };
687
+ element.style.setProperty("--tooltip-mask", getTooltipMaskImage(geometry));
688
+ element.style.setProperty("--tooltip-outline", images.outline);
689
+ element.style.setProperty("--tooltip-shadow", images.shadow);
690
+ element.style.setProperty("--tooltip-surface", images.surface);
691
+ backdropClip == null ? void 0 : backdropClip.update(geometry);
692
+ surface.geometry = geometry;
693
+ }
694
+ };
695
+ const scheduleSurfaceUpdate = () => {
696
+ if (disposed || frame !== void 0) return;
697
+ if (typeof requestAnimationFrame === "function") {
698
+ frame = requestAnimationFrame(() => {
699
+ frame = void 0;
700
+ updateSurfaceShape();
701
+ });
702
+ } else {
703
+ updateSurfaceShape();
704
+ }
705
+ };
706
+ updateSurfaceShape();
707
+ scheduleSurfaceUpdate();
708
+ const mutationObserver = typeof MutationObserver === "undefined" ? void 0 : new MutationObserver(scheduleSurfaceUpdate);
709
+ mutationObserver == null ? void 0 : mutationObserver.observe(outer, { attributes: true, attributeFilter: ["style"] });
710
+ mutationObserver == null ? void 0 : mutationObserver.observe(arrow, { attributes: true, attributeFilter: ["style"] });
711
+ const resizeObserver = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(scheduleSurfaceUpdate);
712
+ resizeObserver == null ? void 0 : resizeObserver.observe(element);
713
+ resizeObserver == null ? void 0 : resizeObserver.observe(content);
714
+ cleanupRef.current = () => {
715
+ disposed = true;
716
+ if (frame !== void 0) cancelAnimationFrame(frame);
717
+ mutationObserver == null ? void 0 : mutationObserver.disconnect();
718
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
719
+ element.style.removeProperty("--tooltip-mask");
720
+ element.style.removeProperty("--tooltip-outline");
721
+ element.style.removeProperty("--tooltip-shadow");
722
+ element.style.removeProperty("--tooltip-surface");
723
+ backdropClip == null ? void 0 : backdropClip.remove();
724
+ };
725
+ }
726
+ }
727
+ if (typeof elementRef === "function") {
728
+ elementRef(element);
729
+ } else if (elementRef) {
730
+ elementRef.current = element;
731
+ }
732
+ },
733
+ [elementRef]
734
+ );
735
+ const surfaceStyle = react_default.useMemo(
736
+ () => __spreadProps(__spreadValues({}, style), {
737
+ "--tooltip-backdrop": getTooltipBackdropColor(isDark)
738
+ }),
739
+ [isDark, style]
740
+ );
741
+ if (!is1cd) {
742
+ return /* @__PURE__ */ react_default.createElement(Popover_default, __spreadValues({}, props), /* @__PURE__ */ react_default.createElement(TooltipContentStyles, { $useTooltipPadding: useTooltipPadding }, children));
743
+ }
744
+ return /* @__PURE__ */ react_default.createElement(
745
+ StyledTooltipPopover,
746
+ __spreadProps(__spreadValues({}, props), {
747
+ elementRef: setPopoverElementRef,
748
+ style: surfaceStyle,
749
+ appearance: "normal",
750
+ hideArrow: false,
751
+ animation: (_a2 = props.animation) != null ? _a2 : false
752
+ }),
753
+ /* @__PURE__ */ react_default.createElement(TooltipContentStyles, { $useTooltipPadding: useTooltipPadding }, children)
754
+ );
755
+ };
756
+ //# sourceMappingURL=Tooltip.js.map