@sproutsocial/seeds-react-data-viz 0.7.32 → 0.15.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 (47) hide show
  1. package/dist/axis-DXzufRRj.d.mts +116 -0
  2. package/dist/axis-PJwu5Xmo.d.ts +116 -0
  3. package/dist/bar/index.d.mts +98 -0
  4. package/dist/bar/index.d.ts +98 -0
  5. package/dist/bar/index.js +186 -0
  6. package/dist/bar/index.js.map +1 -0
  7. package/dist/chartExport-CKYpuhik.d.mts +28 -0
  8. package/dist/chartExport-CKYpuhik.d.ts +28 -0
  9. package/dist/chunk-EEVKTTT3.js +968 -0
  10. package/dist/chunk-EEVKTTT3.js.map +1 -0
  11. package/dist/chunk-JXARPHQE.js +193 -0
  12. package/dist/chunk-JXARPHQE.js.map +1 -0
  13. package/dist/chunk-VSZSIN34.js +796 -0
  14. package/dist/chunk-VSZSIN34.js.map +1 -0
  15. package/dist/esm/bar/index.js +186 -0
  16. package/dist/esm/bar/index.js.map +1 -0
  17. package/dist/esm/chunk-HQM3EIZW.js +193 -0
  18. package/dist/esm/chunk-HQM3EIZW.js.map +1 -0
  19. package/dist/esm/chunk-LC3HGWDD.js +968 -0
  20. package/dist/esm/chunk-LC3HGWDD.js.map +1 -0
  21. package/dist/esm/chunk-OAN5VC7M.js +796 -0
  22. package/dist/esm/chunk-OAN5VC7M.js.map +1 -0
  23. package/dist/esm/export/index.js +41 -0
  24. package/dist/esm/export/index.js.map +1 -0
  25. package/dist/esm/index.js +262 -1315
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/line-area/index.js +151 -0
  28. package/dist/esm/line-area/index.js.map +1 -0
  29. package/dist/esm/pdfExportLibs-NWLZH5KL.js +10 -0
  30. package/dist/esm/pdfExportLibs-NWLZH5KL.js.map +1 -0
  31. package/dist/export/index.d.mts +25 -0
  32. package/dist/export/index.d.ts +25 -0
  33. package/dist/export/index.js +41 -0
  34. package/dist/export/index.js.map +1 -0
  35. package/dist/index.d.mts +56 -93
  36. package/dist/index.d.ts +56 -93
  37. package/dist/index.js +407 -1544
  38. package/dist/index.js.map +1 -1
  39. package/dist/line-area/index.d.mts +83 -0
  40. package/dist/line-area/index.d.ts +83 -0
  41. package/dist/line-area/index.js +151 -0
  42. package/dist/line-area/index.js.map +1 -0
  43. package/dist/pdfExportLibs-BZR2D3RA.js +10 -0
  44. package/dist/pdfExportLibs-BZR2D3RA.js.map +1 -0
  45. package/dist/types-B7ILUQ6_.d.mts +99 -0
  46. package/dist/types-B7ILUQ6_.d.ts +99 -0
  47. package/package.json +37 -11
@@ -0,0 +1,968 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/components/ColorBox/ColorBox.tsx
2
+ var _styledcomponents = require('styled-components'); var _styledcomponents2 = _interopRequireDefault(_styledcomponents);
3
+ var _seedsreactbox = require('@sproutsocial/seeds-react-box');
4
+
5
+ // ../seeds-react-theme-provider/dist/index.mjs
6
+ var _react = require('react');
7
+
8
+
9
+
10
+
11
+ var _seedsreacttheme = require('@sproutsocial/seeds-react-theme');
12
+ var _jsxruntime = require('react/jsx-runtime');
13
+ var GlobalTokenStyles = _styledcomponents.createGlobalStyle`
14
+ :root {
15
+ --color-container-bg-ai-generated: radial-gradient(
16
+ circle at bottom left,
17
+ color-mix(in srgb, #205bc3, transparent 80%) 0%,
18
+ color-mix(in srgb, #6f5ed3, transparent 80%) 61%,
19
+ color-mix(in srgb, #f282f5, transparent 80%) 100%
20
+ ), #f3f4f4;
21
+ }
22
+ `;
23
+
24
+ // src/components/ColorBox/ColorBox.tsx
25
+
26
+
27
+ var ColorBox = ({
28
+ display = "inline-block",
29
+ height = "16px",
30
+ width = "16px",
31
+ minWidth = width,
32
+ borderRadius = "400",
33
+ ...props
34
+ }) => {
35
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
36
+ _seedsreactbox.Box,
37
+ {
38
+ ...props,
39
+ display,
40
+ height,
41
+ width,
42
+ minWidth,
43
+ borderRadius,
44
+ css: _styledcomponents.css`
45
+ cursor: ${(props2) => _optionalChain([props2, 'optionalAccess', _ => _.onClick]) ? "pointer" : "default"};
46
+ `
47
+ }
48
+ );
49
+ };
50
+
51
+ // src/components/ColorBox/DatavizColorBox.tsx
52
+
53
+
54
+ var DatavizColorBox = _styledcomponents2.default.call(void 0, ColorBox).attrs(
55
+ ({ colorIndex }) => ({
56
+ style: {
57
+ background: getDatavizColor(colorIndex),
58
+ opacity: getDatavizOpacity(colorIndex)
59
+ }
60
+ })
61
+ )``;
62
+ var getDatavizColor = (colorIndex) => _seedsreacttheme.theme.colors.DATAVIZ_COLORS_LIST[colorIndex % _seedsreacttheme.theme.colors.DATAVIZ_COLORS_LIST.length] || "";
63
+ var getDatavizOpacity = (colorIndex) => {
64
+ const opacitySteps = [1, 0.6, 0.4, 0.2];
65
+ const opacityStep = Math.floor(colorIndex / _seedsreacttheme.theme.colors.DATAVIZ_COLORS_LIST.length) % opacitySteps.length;
66
+ return opacitySteps[opacityStep];
67
+ };
68
+ var getDatavizColorWithAlpha = (colorIndex) => {
69
+ const color = getDatavizColor(colorIndex);
70
+ const opacity = getDatavizOpacity(colorIndex);
71
+ if (opacity < 0 || opacity > 1) {
72
+ return color;
73
+ }
74
+ return `${color}${Math.floor(opacity * 255).toString(16).padStart(2, "0")}`;
75
+ };
76
+
77
+ // src/components/ColorBox/NetworkColorBox.tsx
78
+ var _seedsnetworkcolor = require('@sproutsocial/seeds-networkcolor'); var _seedsnetworkcolor2 = _interopRequireDefault(_seedsnetworkcolor);
79
+
80
+ var NetworkColorBox = ({
81
+ networkColor,
82
+ ...props
83
+ }) => {
84
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ColorBox, { ...props, bg: _seedsnetworkcolor2.default[networkColor] });
85
+ };
86
+
87
+ // src/components/ChartLegend/components/ChartLegendLabel.tsx
88
+
89
+
90
+
91
+ var _seedsreacttext = require('@sproutsocial/seeds-react-text');
92
+
93
+ var StyledBox = _styledcomponents2.default.call(void 0, _seedsreactbox.Box)`
94
+ list-style: none;
95
+ display: flex;
96
+ align-items: center;
97
+ gap: ${({ theme: theme6 }) => theme6.space[300]};
98
+ `;
99
+ var ChartLegendLabel = _react.memo.call(void 0,
100
+ function ChartLegendLabel2({
101
+ children,
102
+ color = "#CCC",
103
+ containerBoxProps = {}
104
+ }) {
105
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, StyledBox, { ...containerBoxProps, children: [
106
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ColorBox, { bg: color }),
107
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacttext.Text, { as: "div", fontSize: 200, color: "text.subtext", children })
108
+ ] });
109
+ }
110
+ );
111
+
112
+ // src/components/ChartLegend/ChartLegend.tsx
113
+
114
+
115
+
116
+
117
+ var ChartLegend = _react.memo.call(void 0, function ChartLegend2({
118
+ legendLabels,
119
+ containerBoxProps = {},
120
+ stacked = false
121
+ }) {
122
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
123
+ _seedsreactbox.Box,
124
+ {
125
+ as: "ul",
126
+ "aria-hidden": "true",
127
+ display: "flex",
128
+ justifyContent: "center",
129
+ flexDirection: stacked ? "column" : "row",
130
+ flexWrap: "wrap",
131
+ columnGap: 450,
132
+ rowGap: 200,
133
+ m: 0,
134
+ p: 0,
135
+ ...containerBoxProps,
136
+ children: legendLabels.map(({ color, content }, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
137
+ ChartLegendLabel,
138
+ {
139
+ color: color || _seedsreacttheme.theme.colors.DATAVIZ_COLORS_LIST[index],
140
+ containerBoxProps: { as: "li" },
141
+ children: content
142
+ },
143
+ `chart-legend-label-${index}`
144
+ ))
145
+ }
146
+ );
147
+ });
148
+
149
+ // src/components/ChartTooltip/ChartTooltip.tsx
150
+
151
+
152
+
153
+
154
+ var StyledBox2 = _styledcomponents2.default.call(void 0, _seedsreactbox.Box)`
155
+ .Icon,
156
+ .logo {
157
+ stroke: none;
158
+ }
159
+ `;
160
+ var ChartTooltip = _react.memo.call(void 0, function ChartTooltip2({
161
+ children
162
+ }) {
163
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
164
+ StyledBox2,
165
+ {
166
+ bg: "container.background.base",
167
+ boxShadow: "medium",
168
+ border: 500,
169
+ borderColor: "container.border.base",
170
+ borderRadius: 500,
171
+ p: 400,
172
+ minWidth: 285,
173
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreactbox.Box, { display: "flex", flexDirection: "column", gap: 350, children })
174
+ }
175
+ );
176
+ });
177
+
178
+ // src/components/ChartTooltip/components/ChartTooltipFooter.tsx
179
+
180
+
181
+
182
+ var ChartTooltipFooter = _react.memo.call(void 0,
183
+ function ChartTooltipFooter2({ children }) {
184
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
185
+ _seedsreactbox.Box,
186
+ {
187
+ borderTop: 500,
188
+ borderColor: "container.border.base",
189
+ mx: -400,
190
+ mb: -200,
191
+ px: 400,
192
+ pt: 350,
193
+ children
194
+ }
195
+ );
196
+ }
197
+ );
198
+
199
+ // src/components/ChartTooltip/components/ChartTooltipHeader.tsx
200
+
201
+
202
+
203
+ var ChartTooltipHeader = _react.memo.call(void 0,
204
+ function ChartTooltipHeader2({ children }) {
205
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
206
+ _seedsreactbox.Box,
207
+ {
208
+ borderBottom: 500,
209
+ borderColor: "container.border.base",
210
+ mx: -400,
211
+ mt: -200,
212
+ px: 400,
213
+ pb: 350,
214
+ children
215
+ }
216
+ );
217
+ }
218
+ );
219
+
220
+ // src/components/ChartTooltip/components/ChartTooltipPortal.tsx
221
+
222
+ var _reactdom = require('react-dom');
223
+ var generateChartTooltipPortalId = (chartId) => `highcharts-custom-tooltip-${chartId}`;
224
+ var ChartTooltipPortal = _react.memo.call(void 0,
225
+ function ChartTooltipPortal2({
226
+ chart,
227
+ renderContent
228
+ }) {
229
+ const isInitialized = _react.useRef.call(void 0, false);
230
+ const [node, setNode] = _react.useState.call(void 0, null);
231
+ const [context, setContext] = _react.useState.call(void 0, null);
232
+ _react.useEffect.call(void 0, () => {
233
+ const formatter = function() {
234
+ if (!isInitialized.current) {
235
+ isInitialized.current = true;
236
+ chart.tooltip.refresh.apply(chart.tooltip, [this.point]);
237
+ chart.tooltip.hide(0);
238
+ }
239
+ setContext(this);
240
+ return `<div id="${generateChartTooltipPortalId(
241
+ chart.index
242
+ )}" role='tooltip'></div>`;
243
+ };
244
+ chart.update({ tooltip: { formatter } });
245
+ }, [chart]);
246
+ _react.useEffect.call(void 0, () => {
247
+ if (_optionalChain([context, 'optionalAccess', _2 => _2.series, 'optionalAccess', _3 => _3.chart, 'optionalAccess', _4 => _4.tooltip])) {
248
+ const tooltip = context.series.chart.tooltip;
249
+ const textElement = tooltip.label.text.element;
250
+ tooltip.label.box.attr({
251
+ height: textElement.offsetHeight,
252
+ width: textElement.offsetWidth
253
+ });
254
+ setNode(
255
+ document.getElementById(generateChartTooltipPortalId(chart.index))
256
+ );
257
+ }
258
+ }, [context, chart.index]);
259
+ return node && context ? _reactdom.createPortal.call(void 0, renderContent(context), node) : null;
260
+ }
261
+ );
262
+
263
+ // src/components/ChartTable/ChartTable.tsx
264
+
265
+
266
+
267
+ var _seedsreacttable = require('@sproutsocial/seeds-react-table');
268
+
269
+ var StyledSeedsTable = _styledcomponents2.default.call(void 0, _seedsreacttable.Table)`
270
+ tbody tr:last-child {
271
+ border-bottom: none;
272
+ }
273
+ tr:last-child td,
274
+ tr:last-child th {
275
+ padding-bottom: 0;
276
+ }
277
+ tr:first-child td,
278
+ tr:first-child th {
279
+ padding-top: 0;
280
+ }
281
+ tr th {
282
+ padding-left: 0;
283
+ }
284
+ tr td:last-child {
285
+ padding-right: 0;
286
+ }
287
+ `;
288
+ var StyledSeedsTableRow = _styledcomponents2.default.call(void 0, _seedsreacttable.Table.TableRow)`
289
+ ${({ $isAppendedRow, theme: theme6 }) => $isAppendedRow ? `border-top: 2px solid ${theme6.colors.container.border.base}` : ""}
290
+ `;
291
+ var ChartTable = _react.memo.call(void 0, function ChartTable2({
292
+ rows
293
+ }) {
294
+ if (!rows || rows.length === 0) {
295
+ return null;
296
+ }
297
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StyledSeedsTable, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacttable.Table.TableBody, { children: rows.map(({ cells, isAppendedRow }, rowIndex) => {
298
+ if (!cells || cells.length === 0) {
299
+ return null;
300
+ }
301
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
302
+ StyledSeedsTableRow,
303
+ {
304
+ $isAppendedRow: isAppendedRow,
305
+ children: cells.map(
306
+ ({ content, align = "left", colSpan = 1 }, cellIndex) => {
307
+ const uniqueIdentifier = `chart-tooltip-table-cell-${cellIndex}`;
308
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
309
+ _seedsreacttable.Table.Cell,
310
+ {
311
+ id: uniqueIdentifier,
312
+ scope: cellIndex === 0 ? "row" : void 0,
313
+ align,
314
+ colSpan,
315
+ py: 200,
316
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacttext.Text.SmallBodyCopy, { as: "div", children: content })
317
+ },
318
+ uniqueIdentifier
319
+ );
320
+ }
321
+ )
322
+ },
323
+ `chart-tooltip-table-row-${rowIndex}`
324
+ );
325
+ }) }) });
326
+ });
327
+
328
+ // src/components/ChartTooltip/components/ChartTooltipTable.tsx
329
+
330
+
331
+ var ChartTooltipTable = _react.memo.call(void 0,
332
+ function ChartTooltipTable2({ rows }) {
333
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChartTable, { rows });
334
+ }
335
+ );
336
+
337
+ // src/components/ChartTooltip/components/ChartTooltipTitle.tsx
338
+
339
+
340
+
341
+ var ChartTooltipTitle = _react.memo.call(void 0,
342
+ function ChartTooltipTitle2({ children }) {
343
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _seedsreacttext.Text.SmallSubHeadline, { as: "p", children });
344
+ }
345
+ );
346
+
347
+ // src/helpers/transformDataToSeries.ts
348
+ var transformDataToSeries = ({
349
+ data
350
+ }, type) => {
351
+ const hasCategoricalData = data.some(
352
+ (series) => series.points.some((point) => typeof point.x === "string")
353
+ );
354
+ return data.map((dataItem, dataIndex) => {
355
+ const points = dataItem.points || [];
356
+ const dataPoints = points.map((point, pointsIndex) => {
357
+ let enableMarker = false;
358
+ const isFirstPoint = pointsIndex === 0;
359
+ const isLastPoint = pointsIndex === points.length - 1;
360
+ const previousY = isFirstPoint ? null : points[pointsIndex - 1].y;
361
+ const nextY = isLastPoint ? null : points[pointsIndex + 1].y;
362
+ if (isFirstPoint && nextY === null) {
363
+ enableMarker = true;
364
+ } else if (isLastPoint && previousY === null) {
365
+ enableMarker = true;
366
+ } else if (previousY === null && nextY === null) {
367
+ enableMarker = true;
368
+ }
369
+ return {
370
+ x: hasCategoricalData ? pointsIndex : point.x,
371
+ y: point.y,
372
+ marker: {
373
+ enabled: enableMarker ? enableMarker : void 0,
374
+ symbol: enableMarker ? "circle" : void 0
375
+ },
376
+ // For categorical data, store the original category name
377
+ ...hasCategoricalData && { name: point.x }
378
+ };
379
+ });
380
+ return {
381
+ colorIndex: dataIndex,
382
+ data: dataPoints,
383
+ name: dataItem.name,
384
+ type
385
+ };
386
+ });
387
+ };
388
+
389
+ // src/helpers/transformTimeSeriesTooltipData.ts
390
+
391
+ var transformTimeSeriesTooltipData = ({
392
+ context,
393
+ data
394
+ }) => {
395
+ return (context.series.chart.series || []).map((series, index) => {
396
+ const pointIndex = context.point.index;
397
+ const y = _optionalChain([series, 'optionalAccess', _5 => _5.points, 'optionalAccess', _6 => _6[pointIndex], 'optionalAccess', _7 => _7.y]);
398
+ return {
399
+ color: _optionalChain([data, 'access', _8 => _8[index], 'optionalAccess', _9 => _9.styles, 'optionalAccess', _10 => _10.color]) || _seedsreacttheme.theme.colors.DATAVIZ_COLORS_LIST[index],
400
+ ..._optionalChain([data, 'access', _11 => _11[index], 'optionalAccess', _12 => _12.icon]) ? { icon: _optionalChain([data, 'access', _13 => _13[index], 'optionalAccess', _14 => _14.icon]) } : {},
401
+ name: series.name,
402
+ value: typeof y === "number" ? y : null
403
+ };
404
+ });
405
+ };
406
+
407
+ // src/helpers/yAxisLabelFormatter.ts
408
+ var _seedsreactduration = require('@sproutsocial/seeds-react-duration');
409
+ var _seedsreactnumeral = require('@sproutsocial/seeds-react-numeral');
410
+ var yAxisLabelFormatter = ({
411
+ numberLocale,
412
+ textLocale,
413
+ tickPositions,
414
+ value,
415
+ currency = "USD",
416
+ numberFormat = "decimal"
417
+ }) => {
418
+ const numberValue = Number(value);
419
+ if (numberValue === 0) {
420
+ return _seedsreactnumeral.formatNumeral.call(void 0, {
421
+ locale: numberLocale,
422
+ number: numberValue
423
+ });
424
+ }
425
+ if (numberFormat === "duration") {
426
+ return _seedsreactduration.formatDuration.call(void 0, {
427
+ display: "narrow",
428
+ locale: textLocale,
429
+ milliseconds: numberValue
430
+ });
431
+ }
432
+ const maxValue = tickPositions && tickPositions.length > 0 ? tickPositions[tickPositions.length - 1] : void 0;
433
+ const abbreviate = typeof maxValue === "number" && maxValue > 9999 ? 1e3 : true;
434
+ return _seedsreactnumeral.formatNumeral.call(void 0, {
435
+ abbreviate,
436
+ currency,
437
+ format: numberFormat,
438
+ locale: numberLocale,
439
+ number: numberValue
440
+ });
441
+ };
442
+
443
+ // src/helpers/xAxisLabelFormatter.ts
444
+ var getDatePartsInTimezone = (date, timezone) => {
445
+ const formatter = new Intl.DateTimeFormat("en-US", {
446
+ year: "numeric",
447
+ month: "numeric",
448
+ day: "numeric",
449
+ timeZone: timezone
450
+ });
451
+ const parts = formatter.formatToParts(date);
452
+ return {
453
+ day: parseInt(_nullishCoalesce(_optionalChain([parts, 'access', _15 => _15.find, 'call', _16 => _16((p) => p.type === "day"), 'optionalAccess', _17 => _17.value]), () => ( "0")), 10),
454
+ month: parseInt(_nullishCoalesce(_optionalChain([parts, 'access', _18 => _18.find, 'call', _19 => _19((p) => p.type === "month"), 'optionalAccess', _20 => _20.value]), () => ( "0")), 10),
455
+ year: parseInt(_nullishCoalesce(_optionalChain([parts, 'access', _21 => _21.find, 'call', _22 => _22((p) => p.type === "year"), 'optionalAccess', _23 => _23.value]), () => ( "0")), 10)
456
+ };
457
+ };
458
+ var xAxisLabelFormatter = ({
459
+ textLocale,
460
+ tickPositions = [],
461
+ unitName,
462
+ value,
463
+ // optional
464
+ timeFormat = "12",
465
+ timezone = "UTC"
466
+ }) => {
467
+ if (typeof value === "string") {
468
+ return `<span>${value}</span>`;
469
+ }
470
+ const tickIndex = tickPositions.indexOf(value);
471
+ const isFirst = tickIndex === 0;
472
+ const previousValue = tickPositions[tickIndex - 1];
473
+ const valueDate = new Date(value);
474
+ const valueParts = getDatePartsInTimezone(valueDate, timezone);
475
+ const previousValueDate = previousValue ? new Date(previousValue) : void 0;
476
+ const previousValueParts = previousValueDate ? getDatePartsInTimezone(previousValueDate, timezone) : void 0;
477
+ let firstPartOptions = {};
478
+ let secondPartOptions = {};
479
+ switch (unitName) {
480
+ case "hour":
481
+ firstPartOptions = timeFormat === "24" ? { hour: "numeric", minute: "numeric", hour12: false } : { hour: "numeric" };
482
+ if (isFirst || valueParts.day !== _optionalChain([previousValueParts, 'optionalAccess', _24 => _24.day])) {
483
+ secondPartOptions = { day: "numeric", month: "short" };
484
+ }
485
+ break;
486
+ case "day":
487
+ case "week":
488
+ firstPartOptions = { day: "numeric" };
489
+ if (isFirst || valueParts.month !== _optionalChain([previousValueParts, 'optionalAccess', _25 => _25.month])) {
490
+ secondPartOptions = { month: "short" };
491
+ }
492
+ break;
493
+ case "month":
494
+ firstPartOptions = { month: "short" };
495
+ if (isFirst || valueParts.year !== _optionalChain([previousValueParts, 'optionalAccess', _26 => _26.year])) {
496
+ secondPartOptions = { year: "numeric" };
497
+ }
498
+ break;
499
+ case "year":
500
+ firstPartOptions = { year: "numeric" };
501
+ break;
502
+ default:
503
+ firstPartOptions = {};
504
+ break;
505
+ }
506
+ const firstPart = new Intl.DateTimeFormat(textLocale, {
507
+ ...firstPartOptions,
508
+ timeZone: timezone
509
+ }).format(valueDate);
510
+ const secondPart = Object.keys(secondPartOptions).length > 0 ? new Intl.DateTimeFormat(textLocale, {
511
+ ...secondPartOptions,
512
+ timeZone: timezone
513
+ }).format(valueDate) : void 0;
514
+ return `<span>${firstPart}</span>${secondPart ? `<span>${secondPart}</span>` : ""}`;
515
+ };
516
+
517
+ // src/helpers/isHourlyTimeData.ts
518
+ function isHourlyTimeData(data) {
519
+ if (!data.length) return false;
520
+ const xVals = data.flatMap((series) => series.points.map((p) => p.x));
521
+ if (!xVals.length) return false;
522
+ if (xVals.some((x) => typeof x === "string")) return false;
523
+ const dates = xVals.map((x) => {
524
+ const d = new Date(x);
525
+ return `${d.getUTCFullYear()}-${d.getUTCMonth()}-${d.getUTCDate()}`;
526
+ });
527
+ const uniqueDates = new Set(dates);
528
+ if (uniqueDates.size !== 1) return false;
529
+ return xVals.every((x) => {
530
+ const d = new Date(x);
531
+ const hour = d.getUTCHours();
532
+ const minutes = d.getUTCMinutes();
533
+ const seconds = d.getUTCSeconds();
534
+ return hour >= 0 && hour <= 23 && minutes === 0 && seconds === 0;
535
+ });
536
+ }
537
+
538
+ // src/helpers/isCategoricalHourData.ts
539
+ function isCategoricalHourData(data) {
540
+ if (!data.length) return false;
541
+ const xVals = data.flatMap((series) => series.points.map((p) => p.x));
542
+ if (!xVals.length) return false;
543
+ if (xVals.some((x) => typeof x !== "string")) return false;
544
+ const hour12Pattern = /^\d{1,2} (AM|PM)$/;
545
+ const hour24Pattern = /^([01]?\d|2[0-3]):([0-5]\d)$/;
546
+ const stringValues = xVals;
547
+ const allMatch12Hour = stringValues.every((x) => hour12Pattern.test(x));
548
+ const allMatch24Hour = stringValues.every((x) => hour24Pattern.test(x));
549
+ return allMatch12Hour || allMatch24Hour;
550
+ }
551
+
552
+ // src/helpers/getStorybookRandomColor.ts
553
+ var getStorybookRandomColor = () => {
554
+ const letters = "0123456789ABCDEF";
555
+ let color = "#";
556
+ for (let i = 0; i < 6; i++) {
557
+ color += letters[Math.floor(Math.random() * 16)];
558
+ }
559
+ return color;
560
+ };
561
+
562
+ // src/helpers/getStorybookCategoricalData.ts
563
+ var getStorybookCategoricalData = ({
564
+ showNulls,
565
+ showNegativeValues,
566
+ numberOfSeries,
567
+ yAxisMax,
568
+ showCustomColors,
569
+ showDashedLines,
570
+ categoryType
571
+ }) => {
572
+ const categoryOptions = {
573
+ hours: [
574
+ "12 AM",
575
+ "1 AM",
576
+ "2 AM",
577
+ "3 AM",
578
+ "4 AM",
579
+ "5 AM",
580
+ "6 AM",
581
+ "7 AM",
582
+ "8 AM",
583
+ "9 AM",
584
+ "10 AM",
585
+ "11 AM",
586
+ "12 PM",
587
+ "1 PM",
588
+ "2 PM",
589
+ "3 PM",
590
+ "4 PM",
591
+ "5 PM",
592
+ "6 PM",
593
+ "7 PM",
594
+ "8 PM",
595
+ "9 PM",
596
+ "10 PM",
597
+ "11 PM"
598
+ ],
599
+ hours24: [
600
+ "00:00",
601
+ "01:00",
602
+ "02:00",
603
+ "03:00",
604
+ "04:00",
605
+ "05:00",
606
+ "06:00",
607
+ "07:00",
608
+ "08:00",
609
+ "09:00",
610
+ "10:00",
611
+ "11:00",
612
+ "12:00",
613
+ "13:00",
614
+ "14:00",
615
+ "15:00",
616
+ "16:00",
617
+ "17:00",
618
+ "18:00",
619
+ "19:00",
620
+ "20:00",
621
+ "21:00",
622
+ "22:00",
623
+ "23:00"
624
+ ],
625
+ days: [
626
+ "Monday",
627
+ "Tuesday",
628
+ "Wednesday",
629
+ "Thursday",
630
+ "Friday",
631
+ "Saturday",
632
+ "Sunday"
633
+ ],
634
+ months: [
635
+ "January",
636
+ "February",
637
+ "March",
638
+ "April",
639
+ "May",
640
+ "June",
641
+ "July",
642
+ "August",
643
+ "September",
644
+ "October",
645
+ "November",
646
+ "December"
647
+ ],
648
+ custom: [
649
+ "Category A",
650
+ "Category B",
651
+ "Category C",
652
+ "Category D",
653
+ "Category E"
654
+ ]
655
+ };
656
+ const categories = categoryOptions[categoryType];
657
+ const numberOfPoints = categories.length;
658
+ return [...Array(numberOfSeries).keys()].map((seriesIndex) => {
659
+ let nullsArray = [];
660
+ if (showNulls) {
661
+ const nullsArrayLength = Math.floor(numberOfPoints / 5);
662
+ nullsArray = [...Array(nullsArrayLength)].map(
663
+ () => Math.floor(Math.random() * numberOfPoints)
664
+ );
665
+ }
666
+ return {
667
+ points: categories.map((category, pointIndex) => {
668
+ const showNull = nullsArray && nullsArray.length > 0 ? nullsArray.includes(pointIndex) : false;
669
+ const randomValue = Math.random();
670
+ const positiveOrNegativeYAxisMax = showNegativeValues ? randomValue < 0.5 ? -yAxisMax : yAxisMax : yAxisMax;
671
+ return {
672
+ x: category,
673
+ y: showNull ? null : Math.floor(randomValue * positiveOrNegativeYAxisMax)
674
+ };
675
+ }),
676
+ name: `Series ${seriesIndex + 1}`,
677
+ styles: {
678
+ color: showCustomColors ? getStorybookRandomColor() : void 0,
679
+ pattern: showDashedLines ? "dashed" : "solid"
680
+ }
681
+ };
682
+ });
683
+ };
684
+
685
+ // src/helpers/getStorybookSparseTimelineData.ts
686
+ var getStorybookSparseTimelineData = ({
687
+ showNulls,
688
+ showNegativeValues,
689
+ numberOfSeries,
690
+ yAxisMax,
691
+ showCustomColors,
692
+ showDashedLines,
693
+ numberOfPoints = 5,
694
+ timeSpanHours = 24
695
+ }) => {
696
+ const seriesNames = [
697
+ "Posts Published",
698
+ "Comments",
699
+ "Likes",
700
+ "Shares",
701
+ "Clicks",
702
+ "Views",
703
+ "Saves",
704
+ "Reposts",
705
+ "Mentions",
706
+ "Reactions"
707
+ ];
708
+ const baseDate = /* @__PURE__ */ new Date("2024-01-01T00:00:00Z");
709
+ const timeSpanMs = timeSpanHours * 60 * 60 * 1e3;
710
+ return [...Array(numberOfSeries).keys()].map((seriesIndex) => {
711
+ let nullsArray = [];
712
+ if (showNulls) {
713
+ const nullsArrayLength = Math.floor(numberOfPoints / 5);
714
+ nullsArray = [...Array(nullsArrayLength)].map(
715
+ () => Math.floor(Math.random() * numberOfPoints)
716
+ );
717
+ }
718
+ const timestamps = [...Array(numberOfPoints)].map(() => {
719
+ const randomOffset = Math.random() * timeSpanMs;
720
+ return baseDate.getTime() + randomOffset;
721
+ }).sort((a, b) => a - b);
722
+ return {
723
+ points: timestamps.map((timestamp, pointIndex) => {
724
+ const showNull = nullsArray && nullsArray.length > 0 ? nullsArray.includes(pointIndex) : false;
725
+ const randomValue = Math.random();
726
+ const positiveOrNegativeYAxisMax = showNegativeValues ? randomValue < 0.5 ? -yAxisMax : yAxisMax : yAxisMax;
727
+ return {
728
+ x: timestamp,
729
+ y: showNull ? null : Math.floor(randomValue * positiveOrNegativeYAxisMax)
730
+ };
731
+ }),
732
+ name: seriesNames[seriesIndex] || `Series ${seriesIndex + 1}`,
733
+ styles: {
734
+ color: showCustomColors ? getStorybookRandomColor() : void 0,
735
+ pattern: showDashedLines ? "dashed" : "solid"
736
+ }
737
+ };
738
+ });
739
+ };
740
+
741
+ // src/styles/chartStyles.ts
742
+
743
+
744
+ require('highcharts/css/highcharts.css');
745
+ var GlobalChartStyleOverrides = _styledcomponents.createGlobalStyle`
746
+ // USAGE NOTE:
747
+ // Put general styles in baseChartStyles instead when possible to avoid excessive global styling.
748
+ // This global component is only for styles that can't override highcharts defaults when scoped.
749
+
750
+ .highcharts-tooltip-container {
751
+ z-index: 7 !important;
752
+ }
753
+ .highcharts-tooltip-box {
754
+ fill: transparent !important;
755
+ }
756
+ `;
757
+ var baseChartStyles = _styledcomponents.css`
758
+ --highcharts-background-color: ${({ theme: theme6 }) => theme6.colors.container.background.base};
759
+
760
+ // set color variables and map to each series
761
+ ${({ $colors }) => $colors.map((color, index) => {
762
+ const chartColor = color || _seedsreacttheme.theme.colors.DATAVIZ_COLORS_LIST[index];
763
+ return `
764
+ // map colors to custom assigned colors or fallback to default data viz color rotation
765
+ --highcharts-color-${index}: ${chartColor};
766
+
767
+ // highcharts already accounts for 10 series, but if we have more, we need to add them
768
+ .highcharts-color-${index} {
769
+ color: var(--highcharts-color-${index});
770
+ stroke: var(--highcharts-color-${index});
771
+ fill: var(--highcharts-color-${index});
772
+ }`;
773
+ }).join("\n")}
774
+
775
+ // set overall chart background color
776
+ .highcharts-background {
777
+ fill: ${({ theme: theme6 }) => theme6.colors.container.background.base};
778
+ }
779
+
780
+ g.highcharts-annotation-label {
781
+ display: none;
782
+ }
783
+
784
+ div.highcharts-annotation-label {
785
+ top: 0 !important;
786
+ transform: translateX(-50%); // centers the label on the targeted axis point
787
+ pointer-events: none; // prevents tooltip hover from being interrupted by this element since it renders after on the dom
788
+ }
789
+ `;
790
+ var timeSeriesChartStyles = _styledcomponents.css`
791
+ ${baseChartStyles}
792
+
793
+ // vertical crosshair styles
794
+ .highcharts-crosshair {
795
+ stroke: ${({ theme: theme6 }) => theme6.colors.container.border.decorative.neutral};
796
+ stroke-width: 1;
797
+ }
798
+
799
+ // axis and gridline styles
800
+ .highcharts-grid-line {
801
+ stroke: ${({ theme: theme6 }) => theme6.colors.container.border.base};
802
+ }
803
+
804
+ .highcharts-axis-line {
805
+ stroke: ${({ theme: theme6 }) => theme6.colors.container.border.base};
806
+ }
807
+
808
+ .highcharts-tick {
809
+ stroke: none;
810
+ }
811
+ .highcharts-xaxis-labels,
812
+ .highcharts-yaxis-labels {
813
+ // v1 HTML labels (useHTML: true). v2 SVG label styles live in
814
+ // charts/shared/styles.ts (axisLabelV2Styles) — don't add v2 rules here.
815
+ > span {
816
+ font-family: ${({ theme: theme6 }) => theme6.fontFamily};
817
+ ${({ theme: theme6 }) => theme6.typography[100]};
818
+ font-weight: ${({ theme: theme6 }) => theme6.fontWeights.normal};
819
+ color: ${({ theme: theme6 }) => theme6.colors.text.subtext};
820
+ }
821
+ }
822
+ .highcharts-xaxis-labels {
823
+ // v1 HTML stacked labels (useHTML: true). v2 SVG stacked-label styles live
824
+ // in charts/shared/styles.ts (axisLabelV2Styles).
825
+ > span {
826
+ display: flex;
827
+ flex-direction: column;
828
+ align-items: center;
829
+ > span:nth-of-type(2) {
830
+ font-weight: ${({ theme: theme6 }) => theme6.fontWeights.semibold};
831
+ }
832
+ }
833
+ }
834
+
835
+ // we don't want to drop the opacity when another item is hovered
836
+ .highcharts-series-inactive {
837
+ opacity: 1;
838
+ }
839
+
840
+ // apply cursor pointer when click functionality is turned on
841
+ ${({ $hasOnClick }) => $hasOnClick && `
842
+ .highcharts-series,
843
+ .highcharts-point {
844
+ cursor: pointer;
845
+ }
846
+ .highcharts-plot-background,
847
+ .highcharts-crosshair,
848
+ .highcharts-grid-line {
849
+ fill: transparent;
850
+ cursor: pointer;
851
+ }`}
852
+
853
+ path.highcharts-plot-line.y-axis-zero-line {
854
+ stroke: ${({ theme: theme6 }) => theme6.colors.container.border.decorative.neutral};
855
+ }
856
+ `;
857
+ var lineChartStyles = _styledcomponents.css`
858
+ ${timeSeriesChartStyles}
859
+
860
+ // set the line stroke
861
+ .highcharts-graph {
862
+ stroke-width: 3;
863
+ }
864
+
865
+ // dashed line styles
866
+ ${({ $patterns }) => $patterns.map((pattern, index) => {
867
+ return pattern === "dashed" ? `
868
+ // highcharts already accounts for 10 series, but if we have more, we need to add them
869
+ .highcharts-series-${index} {
870
+ stroke-dasharray: 2, 8;
871
+ }` : "";
872
+ })}
873
+ `;
874
+ var areaChartStyles = _styledcomponents.css`
875
+ ${timeSeriesChartStyles}
876
+
877
+ // don't need to show a stroke for the line part of each area
878
+ .highcharts-graph {
879
+ stroke-width: 0;
880
+ }
881
+
882
+ // fill areas to full opacity
883
+ .highcharts-area {
884
+ fill-opacity: 1;
885
+ }
886
+ `;
887
+ var donutChartStyles = _styledcomponents.css`
888
+ ${baseChartStyles}
889
+
890
+ // remove 250ms fade in/out when hovering over different donut chart slices
891
+ .highcharts-point {
892
+ transition: opacity 0s;
893
+ }
894
+
895
+ // remove stroke on donut slices
896
+ .highcharts-pie-series .highcharts-point {
897
+ stroke: none;
898
+ }
899
+
900
+ // don't reduce opacity when hovering
901
+ .highcharts-point-hover {
902
+ fill-opacity: none;
903
+ }
904
+
905
+ // apply cursor pointer when click functionality is turned on
906
+ ${({ $hasOnClick }) => $hasOnClick && `
907
+ .highcharts-series,
908
+ .highcharts-point {
909
+ cursor: pointer;
910
+ }
911
+ .highcharts-plot-background,
912
+ .highcharts-crosshair,
913
+ .highcharts-grid-line {
914
+ fill: transparent;
915
+ cursor: pointer;
916
+ }`}
917
+ `;
918
+
919
+ // src/components/ChartLegend/components/ChartLegendLabelContentWithIcon.tsx
920
+
921
+
922
+
923
+ var ChartLegendLabelContentWithIcon = _react.memo.call(void 0,
924
+ function ChartLegendLabelContentWithIcon2({
925
+ children,
926
+ icon
927
+ }) {
928
+ return icon ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _seedsreactbox.Box, { display: "flex", alignItems: "center", gap: 200, children: [
929
+ icon,
930
+ children
931
+ ] }) : children;
932
+ }
933
+ );
934
+
935
+
936
+
937
+
938
+
939
+
940
+
941
+
942
+
943
+
944
+
945
+
946
+
947
+
948
+
949
+
950
+
951
+
952
+
953
+
954
+
955
+
956
+
957
+
958
+
959
+
960
+
961
+
962
+
963
+
964
+
965
+
966
+
967
+ exports.ColorBox = ColorBox; exports.DatavizColorBox = DatavizColorBox; exports.getDatavizColor = getDatavizColor; exports.getDatavizOpacity = getDatavizOpacity; exports.getDatavizColorWithAlpha = getDatavizColorWithAlpha; exports.NetworkColorBox = NetworkColorBox; exports.ChartLegendLabel = ChartLegendLabel; exports.ChartLegend = ChartLegend; exports.ChartLegendLabelContentWithIcon = ChartLegendLabelContentWithIcon; exports.ChartTooltip = ChartTooltip; exports.ChartTooltipFooter = ChartTooltipFooter; exports.ChartTooltipHeader = ChartTooltipHeader; exports.generateChartTooltipPortalId = generateChartTooltipPortalId; exports.ChartTooltipPortal = ChartTooltipPortal; exports.ChartTable = ChartTable; exports.ChartTooltipTable = ChartTooltipTable; exports.ChartTooltipTitle = ChartTooltipTitle; exports.transformDataToSeries = transformDataToSeries; exports.transformTimeSeriesTooltipData = transformTimeSeriesTooltipData; exports.yAxisLabelFormatter = yAxisLabelFormatter; exports.xAxisLabelFormatter = xAxisLabelFormatter; exports.isHourlyTimeData = isHourlyTimeData; exports.isCategoricalHourData = isCategoricalHourData; exports.getStorybookCategoricalData = getStorybookCategoricalData; exports.getStorybookSparseTimelineData = getStorybookSparseTimelineData; exports.GlobalChartStyleOverrides = GlobalChartStyleOverrides; exports.baseChartStyles = baseChartStyles; exports.timeSeriesChartStyles = timeSeriesChartStyles; exports.lineChartStyles = lineChartStyles; exports.areaChartStyles = areaChartStyles; exports.donutChartStyles = donutChartStyles;
968
+ //# sourceMappingURL=chunk-EEVKTTT3.js.map