@perses-dev/histogram-chart-plugin 0.9.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 (107) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +23 -0
  3. package/__mf/css/async/341.1e19d050.css +1 -0
  4. package/__mf/css/async/759.1e19d050.css +1 -0
  5. package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
  6. package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
  7. package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
  8. package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
  9. package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
  10. package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
  11. package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
  12. package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
  13. package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
  14. package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
  15. package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
  16. package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
  17. package/__mf/js/HistogramChart.93af6e55.js +5 -0
  18. package/__mf/js/async/173.1e8a2c14.js +2 -0
  19. package/__mf/js/async/173.1e8a2c14.js.LICENSE.txt +19 -0
  20. package/__mf/js/async/293.280a8f4f.js +1 -0
  21. package/__mf/js/async/39.719defa2.js +144 -0
  22. package/__mf/js/async/39.719defa2.js.LICENSE.txt +21 -0
  23. package/__mf/js/async/774.b18c4a5c.js +1 -0
  24. package/__mf/js/async/790.15c77240.js +1 -0
  25. package/__mf/js/async/814.7ccaa658.js +10 -0
  26. package/__mf/js/async/814.7ccaa658.js.LICENSE.txt +61 -0
  27. package/__mf/js/async/863.bd42f0c4.js +2 -0
  28. package/__mf/js/async/863.bd42f0c4.js.LICENSE.txt +9 -0
  29. package/__mf/js/async/934.27722fd3.js +2 -0
  30. package/__mf/js/async/934.27722fd3.js.LICENSE.txt +37 -0
  31. package/__mf/js/async/964.b6419e33.js +2 -0
  32. package/__mf/js/async/964.b6419e33.js.LICENSE.txt +9 -0
  33. package/__mf/js/async/981.b29ba452.js +2 -0
  34. package/__mf/js/async/981.b29ba452.js.LICENSE.txt +8 -0
  35. package/__mf/js/async/__federation_expose_HistogramChart.d98de268.js +1 -0
  36. package/__mf/js/main.534b29fb.js +5 -0
  37. package/lib/HistogramChart.d.ts +8 -0
  38. package/lib/HistogramChart.d.ts.map +1 -0
  39. package/lib/HistogramChart.js +34 -0
  40. package/lib/HistogramChart.js.map +1 -0
  41. package/lib/bootstrap.d.ts +2 -0
  42. package/lib/bootstrap.d.ts.map +1 -0
  43. package/lib/bootstrap.js +19 -0
  44. package/lib/bootstrap.js.map +1 -0
  45. package/lib/cjs/HistogramChart.js +40 -0
  46. package/lib/cjs/bootstrap.js +26 -0
  47. package/lib/cjs/components/HistogramChart.js +154 -0
  48. package/lib/cjs/components/HistogramChartOptionsEditorSettings.js +120 -0
  49. package/lib/cjs/components/HistogramChartPanel.js +103 -0
  50. package/lib/cjs/components/index.js +32 -0
  51. package/lib/cjs/env.d.js +14 -0
  52. package/lib/cjs/getPluginModule.js +27 -0
  53. package/lib/cjs/histogram-chart-model.js +60 -0
  54. package/lib/cjs/index-federation.js +55 -0
  55. package/lib/cjs/index.js +47 -0
  56. package/lib/cjs/setup-tests.js +19 -0
  57. package/lib/cjs/utils/index.js +30 -0
  58. package/lib/cjs/utils/thresholds.js +22 -0
  59. package/lib/components/HistogramChart.d.ts +16 -0
  60. package/lib/components/HistogramChart.d.ts.map +1 -0
  61. package/lib/components/HistogramChart.js +146 -0
  62. package/lib/components/HistogramChart.js.map +1 -0
  63. package/lib/components/HistogramChartOptionsEditorSettings.d.ts +4 -0
  64. package/lib/components/HistogramChartOptionsEditorSettings.d.ts.map +1 -0
  65. package/lib/components/HistogramChartOptionsEditorSettings.js +107 -0
  66. package/lib/components/HistogramChartOptionsEditorSettings.js.map +1 -0
  67. package/lib/components/HistogramChartPanel.d.ts +7 -0
  68. package/lib/components/HistogramChartPanel.d.ts.map +1 -0
  69. package/lib/components/HistogramChartPanel.js +90 -0
  70. package/lib/components/HistogramChartPanel.js.map +1 -0
  71. package/lib/components/index.d.ts +4 -0
  72. package/lib/components/index.d.ts.map +1 -0
  73. package/lib/components/index.js +17 -0
  74. package/lib/components/index.js.map +1 -0
  75. package/lib/env.d.js +15 -0
  76. package/lib/env.d.js.map +1 -0
  77. package/lib/getPluginModule.d.ts +6 -0
  78. package/lib/getPluginModule.d.ts.map +1 -0
  79. package/lib/getPluginModule.js +16 -0
  80. package/lib/getPluginModule.js.map +1 -0
  81. package/lib/histogram-chart-model.d.ts +29 -0
  82. package/lib/histogram-chart-model.d.ts.map +1 -0
  83. package/lib/histogram-chart-model.js +31 -0
  84. package/lib/histogram-chart-model.js.map +1 -0
  85. package/lib/index-federation.d.ts +1 -0
  86. package/lib/index-federation.d.ts.map +1 -0
  87. package/lib/index-federation.js +15 -0
  88. package/lib/index-federation.js.map +1 -0
  89. package/lib/index.d.ts +5 -0
  90. package/lib/index.d.ts.map +1 -0
  91. package/lib/index.js +18 -0
  92. package/lib/index.js.map +1 -0
  93. package/lib/setup-tests.d.ts +2 -0
  94. package/lib/setup-tests.d.ts.map +1 -0
  95. package/lib/setup-tests.js +17 -0
  96. package/lib/setup-tests.js.map +1 -0
  97. package/lib/utils/index.d.ts +2 -0
  98. package/lib/utils/index.d.ts.map +1 -0
  99. package/lib/utils/index.js +15 -0
  100. package/lib/utils/index.js.map +1 -0
  101. package/lib/utils/thresholds.d.ts +4 -0
  102. package/lib/utils/thresholds.d.ts.map +1 -0
  103. package/lib/utils/thresholds.js +14 -0
  104. package/lib/utils/thresholds.js.map +1 -0
  105. package/mf-manifest.json +169 -0
  106. package/mf-stats.json +199 -0
  107. package/package.json +55 -0
@@ -0,0 +1,47 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ HistogramChartPanel: function() {
25
+ return _components.HistogramChartPanel;
26
+ },
27
+ getPluginModule: function() {
28
+ return _getPluginModule.getPluginModule;
29
+ }
30
+ });
31
+ const _getPluginModule = require("./getPluginModule");
32
+ const _components = require("./components");
33
+ _export_star(require("./histogram-chart-model"), exports);
34
+ _export_star(require("./HistogramChart"), exports);
35
+ function _export_star(from, to) {
36
+ Object.keys(from).forEach(function(k) {
37
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
38
+ Object.defineProperty(to, k, {
39
+ enumerable: true,
40
+ get: function() {
41
+ return from[k];
42
+ }
43
+ });
44
+ }
45
+ });
46
+ return from;
47
+ }
@@ -0,0 +1,19 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ require("@testing-library/jest-dom");
18
+ // Always mock e-charts during tests since we don't have a proper canvas in jsdom
19
+ jest.mock('echarts/core');
@@ -0,0 +1,30 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _export_star(require("./thresholds"), exports);
18
+ function _export_star(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
+ Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ }
28
+ });
29
+ return from;
30
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getColorFromThresholds", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getColorFromThresholds;
9
+ }
10
+ });
11
+ function getColorFromThresholds(value, thresholds, chartsTheme, defaultColor) {
12
+ if (thresholds?.steps) {
13
+ const matchingColors = thresholds.steps.map((step, index)=>{
14
+ if (value >= step.value) {
15
+ return step.color ?? chartsTheme.thresholds.palette[index] ?? thresholds.defaultColor ?? defaultColor;
16
+ }
17
+ return null;
18
+ }).filter((color)=>color !== null);
19
+ return matchingColors[matchingColors.length - 1] ?? thresholds.defaultColor ?? defaultColor;
20
+ }
21
+ return thresholds?.defaultColor ?? defaultColor;
22
+ }
@@ -0,0 +1,16 @@
1
+ import { ReactElement } from 'react';
2
+ import { FormatOptions, BucketTuple, ThresholdOptions } from '@perses-dev/core';
3
+ export interface HistogramChartData {
4
+ buckets: BucketTuple[];
5
+ }
6
+ export interface HistogramChartProps {
7
+ width: number;
8
+ height: number;
9
+ data: HistogramChartData;
10
+ format?: FormatOptions;
11
+ min?: number;
12
+ max?: number;
13
+ thresholds?: ThresholdOptions;
14
+ }
15
+ export declare function HistogramChart({ width, height, data, format, min, max, thresholds, }: HistogramChartProps): ReactElement | null;
16
+ //# sourceMappingURL=HistogramChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HistogramChart.d.ts","sourceRoot":"","sources":["../../../src/components/HistogramChart.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAShF,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAE/B;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,MAAM,EACN,IAAI,EACJ,MAAM,EACN,GAAG,EACH,GAAG,EACH,UAAU,GACX,EAAE,mBAAmB,GAAG,YAAY,GAAG,IAAI,CAqG3C"}
@@ -0,0 +1,146 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { useMemo } from 'react';
15
+ import { EChart, getFormattedAxis, useChartsTheme } from '@perses-dev/components';
16
+ import { use } from 'echarts/core';
17
+ import { CustomChart } from 'echarts/charts';
18
+ import { getColorFromThresholds } from '../utils';
19
+ use([
20
+ CustomChart
21
+ ]);
22
+ export function HistogramChart({ width, height, data, format, min, max, thresholds }) {
23
+ const chartsTheme = useChartsTheme();
24
+ const transformedData = useMemo(()=>{
25
+ return data.buckets.map(([bucket, lowerBound, upperBound, count])=>{
26
+ return {
27
+ value: [
28
+ parseFloat(lowerBound),
29
+ parseFloat(upperBound),
30
+ parseFloat(count),
31
+ bucket
32
+ ],
33
+ itemStyle: {
34
+ color: getColorFromThresholds(parseFloat(lowerBound), thresholds, chartsTheme, chartsTheme.echartsTheme[0])
35
+ }
36
+ };
37
+ });
38
+ }, [
39
+ chartsTheme,
40
+ data.buckets,
41
+ thresholds
42
+ ]);
43
+ const minXAxis = useMemo(()=>{
44
+ if (min) {
45
+ return min;
46
+ }
47
+ if (transformedData && transformedData[0]) {
48
+ return Math.min(0, Math.floor(transformedData[0]?.value[0] ?? 0));
49
+ }
50
+ return undefined;
51
+ }, [
52
+ min,
53
+ transformedData
54
+ ]);
55
+ const maxXAxis = useMemo(()=>{
56
+ if (max) {
57
+ return max;
58
+ }
59
+ if (transformedData && transformedData[transformedData.length - 1]) {
60
+ return Math.ceil(transformedData[transformedData.length - 1]?.value[1] ?? 1);
61
+ }
62
+ return undefined;
63
+ }, [
64
+ max,
65
+ transformedData
66
+ ]);
67
+ const option = useMemo(()=>{
68
+ if (!transformedData) return chartsTheme.noDataOption;
69
+ return {
70
+ title: {
71
+ show: false
72
+ },
73
+ tooltip: {},
74
+ xAxis: {
75
+ scale: false,
76
+ min: minXAxis,
77
+ max: maxXAxis
78
+ },
79
+ yAxis: getFormattedAxis({}, format),
80
+ series: [
81
+ {
82
+ type: 'custom',
83
+ renderItem: function(params, api) {
84
+ const yValue = api.value(2);
85
+ const start = api.coord([
86
+ api.value(0),
87
+ yValue
88
+ ]);
89
+ const size = api.size?.([
90
+ api.value(1) - api.value(0),
91
+ yValue
92
+ ]);
93
+ const style = api.style?.();
94
+ return {
95
+ type: 'rect',
96
+ shape: {
97
+ x: start[0],
98
+ y: start[1],
99
+ width: size[0],
100
+ height: size[1]
101
+ },
102
+ style: style
103
+ };
104
+ },
105
+ label: {
106
+ show: false
107
+ },
108
+ dimensions: [
109
+ 'from',
110
+ 'to'
111
+ ],
112
+ encode: {
113
+ x: [
114
+ 0,
115
+ 1
116
+ ],
117
+ y: 2,
118
+ tooltip: [
119
+ 0,
120
+ 1
121
+ ],
122
+ itemName: 2
123
+ },
124
+ data: transformedData
125
+ }
126
+ ]
127
+ };
128
+ }, [
129
+ chartsTheme.noDataOption,
130
+ format,
131
+ maxXAxis,
132
+ minXAxis,
133
+ transformedData
134
+ ]);
135
+ return /*#__PURE__*/ _jsx(EChart, {
136
+ sx: {
137
+ width: width,
138
+ height: height,
139
+ padding: `${chartsTheme.container.padding.default}px`
140
+ },
141
+ option: option,
142
+ theme: chartsTheme.echartsTheme
143
+ });
144
+ }
145
+
146
+ //# sourceMappingURL=HistogramChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/HistogramChart.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useMemo } from 'react';\nimport { FormatOptions, BucketTuple, ThresholdOptions } from '@perses-dev/core';\nimport { EChart, getFormattedAxis, useChartsTheme } from '@perses-dev/components';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { CustomSeriesRenderItemAPI, CustomSeriesRenderItemParams } from 'echarts';\nimport { CustomChart } from 'echarts/charts';\nimport { getColorFromThresholds } from '../utils';\n\nuse([CustomChart]);\n\nexport interface HistogramChartData {\n buckets: BucketTuple[];\n}\n\nexport interface HistogramChartProps {\n width: number;\n height: number;\n data: HistogramChartData;\n format?: FormatOptions;\n min?: number;\n max?: number;\n thresholds?: ThresholdOptions;\n // TODO: exponential?: boolean;\n}\n\nexport function HistogramChart({\n width,\n height,\n data,\n format,\n min,\n max,\n thresholds,\n}: HistogramChartProps): ReactElement | null {\n const chartsTheme = useChartsTheme();\n\n const transformedData = useMemo(() => {\n return data.buckets.map(([bucket, lowerBound, upperBound, count]) => {\n return {\n value: [parseFloat(lowerBound), parseFloat(upperBound), parseFloat(count), bucket],\n itemStyle: {\n color: getColorFromThresholds(\n parseFloat(lowerBound),\n thresholds,\n chartsTheme,\n chartsTheme.echartsTheme[0] as string\n ),\n },\n };\n });\n }, [chartsTheme, data.buckets, thresholds]);\n\n const minXAxis: number | undefined = useMemo(() => {\n if (min) {\n return min;\n }\n\n if (transformedData && transformedData[0]) {\n return Math.min(0, Math.floor(transformedData[0]?.value[0] ?? 0));\n }\n return undefined;\n }, [min, transformedData]);\n\n const maxXAxis: number | undefined = useMemo(() => {\n if (max) {\n return max;\n }\n if (transformedData && transformedData[transformedData.length - 1]) {\n return Math.ceil(transformedData[transformedData.length - 1]?.value[1] ?? 1);\n }\n return undefined;\n }, [max, transformedData]);\n\n const option: EChartsCoreOption = useMemo(() => {\n if (!transformedData) return chartsTheme.noDataOption;\n\n return {\n title: {\n show: false,\n },\n tooltip: {},\n xAxis: {\n scale: false,\n min: minXAxis,\n max: maxXAxis,\n },\n yAxis: getFormattedAxis({}, format),\n series: [\n {\n type: 'custom',\n renderItem: function (params: CustomSeriesRenderItemParams, api: CustomSeriesRenderItemAPI) {\n const yValue = api.value(2);\n const start = api.coord([api.value(0), yValue]);\n const size = api.size?.([(api.value(1) as number) - (api.value(0) as number), yValue]) as number[];\n const style = api.style?.();\n\n return {\n type: 'rect',\n shape: {\n x: start[0],\n y: start[1],\n width: size[0],\n height: size[1],\n },\n style: style,\n };\n },\n label: {\n show: false,\n },\n dimensions: ['from', 'to'],\n encode: {\n x: [0, 1],\n y: 2,\n tooltip: [0, 1],\n itemName: 2,\n },\n data: transformedData,\n },\n ],\n };\n }, [chartsTheme.noDataOption, format, maxXAxis, minXAxis, transformedData]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n padding: `${chartsTheme.container.padding.default}px`,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n );\n}\n"],"names":["useMemo","EChart","getFormattedAxis","useChartsTheme","use","CustomChart","getColorFromThresholds","HistogramChart","width","height","data","format","min","max","thresholds","chartsTheme","transformedData","buckets","map","bucket","lowerBound","upperBound","count","value","parseFloat","itemStyle","color","echartsTheme","minXAxis","Math","floor","undefined","maxXAxis","length","ceil","option","noDataOption","title","show","tooltip","xAxis","scale","yAxis","series","type","renderItem","params","api","yValue","start","coord","size","style","shape","x","y","label","dimensions","encode","itemName","sx","padding","container","default","theme"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,OAAO,QAAQ,QAAQ;AAE9C,SAASC,MAAM,EAAEC,gBAAgB,EAAEC,cAAc,QAAQ,yBAAyB;AAClF,SAASC,GAAG,QAA2B,eAAe;AAEtD,SAASC,WAAW,QAA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 -0,0 +1,4 @@
1
+ import { ReactElement } from 'react';
2
+ import { HistogramChartOptionsEditorProps } from '../histogram-chart-model';
3
+ export declare function HistogramChartOptionsEditorSettings(props: HistogramChartOptionsEditorProps): ReactElement;
4
+ //# sourceMappingURL=HistogramChartOptionsEditorSettings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HistogramChartOptionsEditorSettings.d.ts","sourceRoot":"","sources":["../../../src/components/HistogramChartOptionsEditorSettings.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAQL,gCAAgC,EACjC,MAAM,0BAA0B,CAAC;AAElC,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,gCAAgC,GAAG,YAAY,CA2FzG"}
@@ -0,0 +1,107 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { TextField } from '@mui/material';
15
+ import { FormatControls, OptionsEditorColumn, OptionsEditorControl, OptionsEditorGrid, OptionsEditorGroup, ThresholdsEditor } from '@perses-dev/components';
16
+ import { produce } from 'immer';
17
+ import merge from 'lodash/merge';
18
+ import { DEFAULT_FORMAT, DEFAULT_MAX_PERCENT, DEFAULT_MAX_PERCENT_DECIMAL, DEFAULT_MIN_PERCENT, DEFAULT_MIN_PERCENT_DECIMAL, DEFAULT_THRESHOLDS } from '../histogram-chart-model';
19
+ export function HistogramChartOptionsEditorSettings(props) {
20
+ const { onChange, value } = props;
21
+ const handleUnitChange = (newFormat)=>{
22
+ onChange(produce(value, (draft)=>{
23
+ draft.format = newFormat;
24
+ }));
25
+ };
26
+ const handleThresholdsChange = (thresholds)=>{
27
+ onChange(produce(value, (draft)=>{
28
+ draft.thresholds = thresholds;
29
+ }));
30
+ };
31
+ // ensures decimalPlaces defaults to correct value
32
+ const format = merge({}, DEFAULT_FORMAT, value.format);
33
+ const thresholds = merge({}, DEFAULT_THRESHOLDS, value.thresholds);
34
+ // max only needs to be set explicitly for units other than percent and percent-decimal
35
+ let minPlaceholder = 'Enter value';
36
+ if (format.unit === 'percent') {
37
+ minPlaceholder = DEFAULT_MIN_PERCENT.toString();
38
+ } else if (format.unit === 'percent-decimal') {
39
+ minPlaceholder = DEFAULT_MIN_PERCENT_DECIMAL.toString();
40
+ }
41
+ // max only needs to be set explicitly for units other than percent and percent-decimal
42
+ let maxPlaceholder = 'Enter value';
43
+ if (format.unit === 'percent') {
44
+ maxPlaceholder = DEFAULT_MAX_PERCENT.toString();
45
+ } else if (format.unit === 'percent-decimal') {
46
+ maxPlaceholder = DEFAULT_MAX_PERCENT_DECIMAL.toString();
47
+ }
48
+ return /*#__PURE__*/ _jsxs(OptionsEditorGrid, {
49
+ children: [
50
+ /*#__PURE__*/ _jsx(OptionsEditorColumn, {
51
+ children: /*#__PURE__*/ _jsxs(OptionsEditorGroup, {
52
+ title: "Misc",
53
+ children: [
54
+ /*#__PURE__*/ _jsx(FormatControls, {
55
+ value: format,
56
+ onChange: handleUnitChange
57
+ }),
58
+ /*#__PURE__*/ _jsx(OptionsEditorControl, {
59
+ label: "Min",
60
+ control: /*#__PURE__*/ _jsx(TextField, {
61
+ type: "number",
62
+ value: value.min ?? '',
63
+ onChange: (e)=>{
64
+ // ensure empty value resets to undef to allow chart to calculate max
65
+ const newValue = e.target.value ? Number(e.target.value) : undefined;
66
+ onChange(produce(value, (draft)=>{
67
+ draft.min = newValue;
68
+ }));
69
+ },
70
+ placeholder: minPlaceholder,
71
+ sx: {
72
+ width: '100%'
73
+ }
74
+ })
75
+ }),
76
+ /*#__PURE__*/ _jsx(OptionsEditorControl, {
77
+ label: "Max",
78
+ control: /*#__PURE__*/ _jsx(TextField, {
79
+ type: "number",
80
+ value: value.max ?? '',
81
+ onChange: (e)=>{
82
+ // ensure empty value resets to undef to allow chart to calculate max
83
+ const newValue = e.target.value ? Number(e.target.value) : undefined;
84
+ onChange(produce(value, (draft)=>{
85
+ draft.max = newValue;
86
+ }));
87
+ },
88
+ placeholder: maxPlaceholder,
89
+ sx: {
90
+ width: '100%'
91
+ }
92
+ })
93
+ })
94
+ ]
95
+ })
96
+ }),
97
+ /*#__PURE__*/ _jsx(OptionsEditorColumn, {
98
+ children: /*#__PURE__*/ _jsx(ThresholdsEditor, {
99
+ thresholds: thresholds,
100
+ onChange: handleThresholdsChange
101
+ })
102
+ })
103
+ ]
104
+ });
105
+ }
106
+
107
+ //# sourceMappingURL=HistogramChartOptionsEditorSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/HistogramChartOptionsEditorSettings.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TextField } from '@mui/material';\nimport {\n FormatControls,\n FormatControlsProps,\n OptionsEditorColumn,\n OptionsEditorControl,\n OptionsEditorGrid,\n OptionsEditorGroup,\n ThresholdsEditor,\n ThresholdsEditorProps,\n} from '@perses-dev/components';\nimport { produce } from 'immer';\nimport merge from 'lodash/merge';\nimport { ReactElement } from 'react';\nimport {\n DEFAULT_FORMAT,\n DEFAULT_MAX_PERCENT,\n DEFAULT_MAX_PERCENT_DECIMAL,\n DEFAULT_MIN_PERCENT,\n DEFAULT_MIN_PERCENT_DECIMAL,\n DEFAULT_THRESHOLDS,\n HistogramChartOptions,\n HistogramChartOptionsEditorProps,\n} from '../histogram-chart-model';\n\nexport function HistogramChartOptionsEditorSettings(props: HistogramChartOptionsEditorProps): ReactElement {\n const { onChange, value } = props;\n\n const handleUnitChange: FormatControlsProps['onChange'] = (newFormat) => {\n onChange(\n produce(value, (draft: HistogramChartOptions) => {\n draft.format = newFormat;\n })\n );\n };\n\n const handleThresholdsChange: ThresholdsEditorProps['onChange'] = (thresholds) => {\n onChange(\n produce(value, (draft: HistogramChartOptions) => {\n draft.thresholds = thresholds;\n })\n );\n };\n\n // ensures decimalPlaces defaults to correct value\n const format = merge({}, DEFAULT_FORMAT, value.format);\n const thresholds = merge({}, DEFAULT_THRESHOLDS, value.thresholds);\n\n // max only needs to be set explicitly for units other than percent and percent-decimal\n let minPlaceholder = 'Enter value';\n if (format.unit === 'percent') {\n minPlaceholder = DEFAULT_MIN_PERCENT.toString();\n } else if (format.unit === 'percent-decimal') {\n minPlaceholder = DEFAULT_MIN_PERCENT_DECIMAL.toString();\n }\n\n // max only needs to be set explicitly for units other than percent and percent-decimal\n let maxPlaceholder = 'Enter value';\n if (format.unit === 'percent') {\n maxPlaceholder = DEFAULT_MAX_PERCENT.toString();\n } else if (format.unit === 'percent-decimal') {\n maxPlaceholder = DEFAULT_MAX_PERCENT_DECIMAL.toString();\n }\n\n return (\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Misc\">\n <FormatControls value={format} onChange={handleUnitChange} />\n <OptionsEditorControl\n label=\"Min\"\n control={\n <TextField\n type=\"number\"\n value={value.min ?? ''}\n onChange={(e) => {\n // ensure empty value resets to undef to allow chart to calculate max\n const newValue = e.target.value ? Number(e.target.value) : undefined;\n onChange(\n produce(value, (draft: HistogramChartOptions) => {\n draft.min = newValue;\n })\n );\n }}\n placeholder={minPlaceholder}\n sx={{ width: '100%' }}\n />\n }\n />\n <OptionsEditorControl\n label=\"Max\"\n control={\n <TextField\n type=\"number\"\n value={value.max ?? ''}\n onChange={(e) => {\n // ensure empty value resets to undef to allow chart to calculate max\n const newValue = e.target.value ? Number(e.target.value) : undefined;\n onChange(\n produce(value, (draft: HistogramChartOptions) => {\n draft.max = newValue;\n })\n );\n }}\n placeholder={maxPlaceholder}\n sx={{ width: '100%' }}\n />\n }\n />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <ThresholdsEditor thresholds={thresholds} onChange={handleThresholdsChange} />\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n );\n}\n"],"names":["TextField","FormatControls","OptionsEditorColumn","OptionsEditorControl","OptionsEditorGrid","OptionsEditorGroup","ThresholdsEditor","produce","merge","DEFAULT_FORMAT","DEFAULT_MAX_PERCENT","DEFAULT_MAX_PERCENT_DECIMAL","DEFAULT_MIN_PERCENT","DEFAULT_MIN_PERCENT_DECIMAL","DEFAULT_THRESHOLDS","HistogramChartOptionsEditorSettings","props","onChange","value","handleUnitChange","newFormat","draft","format","handleThresholdsChange","thresholds","minPlaceholder","unit","toString","maxPlaceholder","title","label","control","type","min","e","newValue","target","Number","undefined","placeholder","sx","width","max"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,SAAS,QAAQ,gBAAgB;AAC1C,SACEC,cAAc,EAEdC,mBAAmB,EACnBC,oBAAoB,EACpBC,iBAAiB,EACjBC,kBAAkB,EAClBC,gBAAgB,QAEX,yBAAyB;AAChC,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,WAAW,eAAe;AAEjC,SACEC,cAAc,EACdC,mBAAmB,EACnBC,2BAA2B,EAC3BC,mBAAmB,EACnBC,2BAA2B,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QAAQW,OAAO,CAACG;wCACdA,MAAMY,GAAG,GAAGE;oCACd;gCAEJ;gCACAI,aAAad;gCACbe,IAAI;oCAAEC,OAAO;gCAAO;;;sCAI1B,KAACtC;4BACC2B,OAAM;4BACNC,uBACE,KAAC/B;gCACCgC,MAAK;gCACLd,OAAOA,MAAMwB,GAAG,IAAI;gCACpBzB,UAAU,CAACiB;oCACT,qEAAqE;oCACrE,MAAMC,WAAWD,EAAEE,MAAM,CAAClB,KAAK,GAAGmB,OAAOH,EAAEE,MAAM,CAAClB,KAAK,IAAIoB;oCAC3DrB,SACEV,QAAQW,OAAO,CAACG;wCACdA,MAAMqB,GAAG,GAAGP;oCACd;gCAEJ;gCACAI,aAAaX;gCACbY,IAAI;oCAAEC,OAAO;gCAAO;;;;;;0BAM9B,KAACvC;0BACC,cAAA,KAACI;oBAAiBkB,YAAYA;oBAAYP,UAAUM;;;;;AAI5D"}
@@ -0,0 +1,7 @@
1
+ import { TimeSeriesData } from '@perses-dev/core';
2
+ import { PanelProps } from '@perses-dev/plugin-system';
3
+ import { ReactElement } from 'react';
4
+ import { HistogramChartOptions } from '../histogram-chart-model';
5
+ export type HistogramChartPanelProps = PanelProps<HistogramChartOptions, TimeSeriesData>;
6
+ export declare function HistogramChartPanel(props: HistogramChartPanelProps): ReactElement | null;
7
+ //# sourceMappingURL=HistogramChartPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HistogramChartPanel.d.ts","sourceRoot":"","sources":["../../../src/components/HistogramChartPanel.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAsC,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAKrG,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC,qBAAqB,EAAE,cAAc,CAAC,CAAC;AAEzF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,YAAY,GAAG,IAAI,CA0ExF"}
@@ -0,0 +1,90 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { Box, Stack, Typography } from '@mui/material';
15
+ import merge from 'lodash/merge';
16
+ import { useMemo } from 'react';
17
+ import { useChartsTheme } from '@perses-dev/components';
18
+ import { DEFAULT_FORMAT, DEFAULT_THRESHOLDS } from '../histogram-chart-model';
19
+ import { HistogramChart } from './HistogramChart';
20
+ const HISTOGRAM_MIN_WIDTH = 90;
21
+ export function HistogramChartPanel(props) {
22
+ const { spec: pluginSpec, contentDimensions, queryResults } = props;
23
+ const { min, max } = pluginSpec;
24
+ const chartsTheme = useChartsTheme();
25
+ // ensures all default format properties set if undef
26
+ const format = merge({}, DEFAULT_FORMAT, pluginSpec.format);
27
+ const thresholds = merge({}, DEFAULT_THRESHOLDS, pluginSpec.thresholds);
28
+ const histogramData = useMemo(()=>{
29
+ const histograms = [];
30
+ for (const result of queryResults){
31
+ for (const timeSeries of result.data.series){
32
+ if (!timeSeries.histograms || timeSeries.histograms.length === 0) {
33
+ continue;
34
+ }
35
+ const [, histoBuckets] = timeSeries.histograms[0];
36
+ if (histoBuckets && histoBuckets.buckets) {
37
+ histograms.push({
38
+ buckets: histoBuckets.buckets
39
+ });
40
+ }
41
+ }
42
+ }
43
+ return histograms;
44
+ }, [
45
+ queryResults
46
+ ]);
47
+ // no data message handled inside chart component
48
+ if (histogramData.length === 0) {
49
+ return /*#__PURE__*/ _jsx(Stack, {
50
+ justifyContent: "center",
51
+ height: "100%",
52
+ children: /*#__PURE__*/ _jsx(Typography, {
53
+ variant: "body2",
54
+ textAlign: "center",
55
+ children: "No data available (only native histograms are supported for now)"
56
+ })
57
+ });
58
+ }
59
+ if (contentDimensions === undefined) return null;
60
+ // accounts for showing a separate chart for each time series
61
+ let chartWidth = contentDimensions.width / histogramData.length - chartsTheme.container.padding.default;
62
+ if (chartWidth < HISTOGRAM_MIN_WIDTH && histogramData.length > 1) {
63
+ // enables horizontal scroll when charts overflow outside of panel
64
+ chartWidth = HISTOGRAM_MIN_WIDTH;
65
+ }
66
+ return /*#__PURE__*/ _jsx(Stack, {
67
+ direction: "row",
68
+ justifyContent: "center",
69
+ alignItems: "center",
70
+ sx: {
71
+ // so scrollbar only shows when necessary
72
+ overflowX: histogramData.length > 1 ? 'scroll' : 'auto'
73
+ },
74
+ children: histogramData.map((series, seriesIndex)=>{
75
+ return /*#__PURE__*/ _jsx(Box, {
76
+ children: /*#__PURE__*/ _jsx(HistogramChart, {
77
+ width: chartWidth,
78
+ height: contentDimensions.height,
79
+ data: series,
80
+ format: format,
81
+ min: min,
82
+ max: max,
83
+ thresholds: thresholds
84
+ })
85
+ }, `histogram-series-${seriesIndex}`);
86
+ })
87
+ });
88
+ }
89
+
90
+ //# sourceMappingURL=HistogramChartPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/HistogramChartPanel.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Stack, Typography } from '@mui/material';\nimport { TimeSeriesData } from '@perses-dev/core';\nimport { PanelProps } from '@perses-dev/plugin-system';\nimport merge from 'lodash/merge';\nimport { ReactElement, useMemo } from 'react';\nimport { useChartsTheme } from '@perses-dev/components';\nimport { DEFAULT_FORMAT, DEFAULT_THRESHOLDS, HistogramChartOptions } from '../histogram-chart-model';\nimport { HistogramChart, HistogramChartData } from './HistogramChart';\n\nconst HISTOGRAM_MIN_WIDTH = 90;\n\nexport type HistogramChartPanelProps = PanelProps<HistogramChartOptions, TimeSeriesData>;\n\nexport function HistogramChartPanel(props: HistogramChartPanelProps): ReactElement | null {\n const { spec: pluginSpec, contentDimensions, queryResults } = props;\n const { min, max } = pluginSpec;\n\n const chartsTheme = useChartsTheme();\n // ensures all default format properties set if undef\n const format = merge({}, DEFAULT_FORMAT, pluginSpec.format);\n const thresholds = merge({}, DEFAULT_THRESHOLDS, pluginSpec.thresholds);\n\n const histogramData: HistogramChartData[] = useMemo(() => {\n const histograms: HistogramChartData[] = [];\n\n for (const result of queryResults) {\n for (const timeSeries of result.data.series) {\n if (!timeSeries.histograms || timeSeries.histograms.length === 0) {\n continue;\n }\n\n const [, histoBuckets] = timeSeries.histograms[0]!;\n if (histoBuckets && histoBuckets.buckets) {\n histograms.push({ buckets: histoBuckets.buckets });\n }\n }\n }\n return histograms;\n }, [queryResults]);\n\n // no data message handled inside chart component\n if (histogramData.length === 0) {\n return (\n <Stack justifyContent=\"center\" height=\"100%\">\n <Typography variant=\"body2\" textAlign=\"center\">\n No data available (only native histograms are supported for now)\n </Typography>\n </Stack>\n );\n }\n\n if (contentDimensions === undefined) return null;\n\n // accounts for showing a separate chart for each time series\n let chartWidth = contentDimensions.width / histogramData.length - chartsTheme.container.padding.default;\n if (chartWidth < HISTOGRAM_MIN_WIDTH && histogramData.length > 1) {\n // enables horizontal scroll when charts overflow outside of panel\n chartWidth = HISTOGRAM_MIN_WIDTH;\n }\n\n return (\n <Stack\n direction=\"row\"\n justifyContent=\"center\"\n alignItems=\"center\"\n sx={{\n // so scrollbar only shows when necessary\n overflowX: histogramData.length > 1 ? 'scroll' : 'auto',\n }}\n >\n {histogramData.map((series, seriesIndex) => {\n return (\n <Box key={`histogram-series-${seriesIndex}`}>\n <HistogramChart\n width={chartWidth}\n height={contentDimensions.height}\n data={series}\n format={format}\n min={min}\n max={max}\n thresholds={thresholds}\n />\n </Box>\n );\n })}\n </Stack>\n );\n}\n"],"names":["Box","Stack","Typography","merge","useMemo","useChartsTheme","DEFAULT_FORMAT","DEFAULT_THRESHOLDS","HistogramChart","HISTOGRAM_MIN_WIDTH","HistogramChartPanel","props","spec","pluginSpec","contentDimensions","queryResults","min","max","chartsTheme","format","thresholds","histogramData","histograms","result","timeSeries","data","series","length","histoBuckets","buckets","push","justifyContent","height","variant","textAlign","undefined","chartWidth","width","container","padding","default","direction","alignItems","sx","overflowX","map","seriesIndex"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,GAAG,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAGvD,OAAOC,WAAW,eAAe;AACjC,SAAuBC,OAAO,QAAQ,QAAQ;AAC9C,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,cAAc,EAAEC,kBAAkB,QAA+B,2BAA2B;AACrG,SAASC,cAAc,QAA4B,mBAAmB;AAEtE,MAAMC,sBAAsB;AAI5B,OAAO,SAASC,oBAAoBC,KAA+B;IACjE,MAAM,EAAEC,MAAMC,UAAU,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGJ;IAC9D,MAAM,EAAEK,GAAG,EAAEC,GAAG,EAAE,GAAGJ;IAErB,MAAMK,cAAcb;IACpB,qDAAqD;IACrD,MAAMc,SAAShB,MAAM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QlB,kBAAkBkB,MAAM;oBAChCP,MAAMC;oBACNP,QAAQA;oBACRH,KAAKA;oBACLC,KAAKA;oBACLG,YAAYA;;eARN,CAAC,iBAAiB,EAAE0B,aAAa;QAY/C;;AAGN"}
@@ -0,0 +1,4 @@
1
+ export * from './HistogramChartOptionsEditorSettings';
2
+ export * from './HistogramChartPanel';
3
+ export * from './HistogramChart';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,17 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './HistogramChartOptionsEditorSettings';
14
+ export * from './HistogramChartPanel';
15
+ export * from './HistogramChart';
16
+
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/index.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './HistogramChartOptionsEditorSettings';\nexport * from './HistogramChartPanel';\nexport * from './HistogramChart';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,wCAAwC;AACtD,cAAc,wBAAwB;AACtC,cAAc,mBAAmB"}
package/lib/env.d.js ADDED
@@ -0,0 +1,15 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /// <reference types="@rsbuild/core/types" />
14
+
15
+ //# sourceMappingURL=env.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/env.d.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/// <reference types=\"@rsbuild/core/types\" />\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6CAA6C"}
@@ -0,0 +1,6 @@
1
+ import { PluginModuleResource } from '@perses-dev/plugin-system';
2
+ /**
3
+ * Returns the plugin module information from package.json
4
+ */
5
+ export declare function getPluginModule(): PluginModuleResource;
6
+ //# sourceMappingURL=getPluginModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAGnF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}