@perses-dev/components 0.0.0-snapshot-tooltip-highlight-c995fc8 → 0.0.0-snapshot-saving-defaults-refinements-1b25cec
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/dist/ContentWithLegend/ContentWithLegend.d.ts +11 -0
- package/dist/ContentWithLegend/ContentWithLegend.d.ts.map +1 -0
- package/dist/ContentWithLegend/ContentWithLegend.js +65 -0
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -0
- package/dist/ContentWithLegend/index.d.ts +2 -0
- package/dist/ContentWithLegend/index.d.ts.map +1 -0
- package/dist/ContentWithLegend/index.js +15 -0
- package/dist/ContentWithLegend/index.js.map +1 -0
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +68 -0
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -0
- package/dist/ContentWithLegend/model/content-with-legend-model.js +90 -0
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -0
- package/dist/EChart/EChart.d.ts.map +1 -1
- package/dist/EChart/EChart.js +10 -8
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/Legend/CompactLegend.d.ts +6 -4
- package/dist/Legend/CompactLegend.d.ts.map +1 -1
- package/dist/Legend/CompactLegend.js +4 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.d.ts +11 -9
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +70 -21
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/ListLegend.d.ts +5 -8
- package/dist/Legend/ListLegend.d.ts.map +1 -1
- package/dist/Legend/ListLegend.js +17 -103
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +8 -8
- package/dist/Legend/ListLegendItem.d.ts.map +1 -1
- package/dist/Legend/ListLegendItem.js +9 -12
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts +12 -0
- package/dist/Legend/TableLegend.d.ts.map +1 -0
- package/dist/Legend/TableLegend.js +61 -0
- package/dist/Legend/TableLegend.js.map +1 -0
- package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
- package/dist/LegendOptionsEditor/LegendOptionsEditor.js +35 -3
- package/dist/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/LineChart/LineChart.d.ts +2 -1
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +79 -32
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +13 -2
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/Table/InnerTable.d.ts +9 -0
- package/dist/Table/InnerTable.d.ts.map +1 -0
- package/dist/Table/InnerTable.js +38 -0
- package/dist/Table/InnerTable.js.map +1 -0
- package/dist/Table/Table.d.ts +10 -0
- package/dist/Table/Table.d.ts.map +1 -0
- package/dist/Table/Table.js +101 -0
- package/dist/Table/Table.js.map +1 -0
- package/dist/Table/TableBody.d.ts +6 -0
- package/dist/Table/TableBody.d.ts.map +1 -0
- package/dist/Table/TableBody.js +23 -0
- package/dist/Table/TableBody.js.map +1 -0
- package/dist/Table/TableCell.d.ts +18 -0
- package/dist/Table/TableCell.d.ts.map +1 -0
- package/dist/Table/TableCell.js +91 -0
- package/dist/Table/TableCell.js.map +1 -0
- package/dist/Table/TableCheckbox.d.ts +9 -0
- package/dist/Table/TableCheckbox.d.ts.map +1 -0
- package/dist/Table/TableCheckbox.js +49 -0
- package/dist/Table/TableCheckbox.js.map +1 -0
- package/dist/Table/TableHead.d.ts +6 -0
- package/dist/Table/TableHead.d.ts.map +1 -0
- package/dist/Table/TableHead.js +23 -0
- package/dist/Table/TableHead.js.map +1 -0
- package/dist/Table/TableRow.d.ts +9 -0
- package/dist/Table/TableRow.d.ts.map +1 -0
- package/dist/Table/TableRow.js +29 -0
- package/dist/Table/TableRow.js.map +1 -0
- package/dist/Table/VirtualizedTable.d.ts +11 -0
- package/dist/Table/VirtualizedTable.d.ts.map +1 -0
- package/dist/Table/VirtualizedTable.js +152 -0
- package/dist/Table/VirtualizedTable.js.map +1 -0
- package/dist/Table/VirtualizedTableContainer.d.ts +6 -0
- package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -0
- package/dist/Table/VirtualizedTableContainer.js +24 -0
- package/dist/Table/VirtualizedTableContainer.js.map +1 -0
- package/dist/Table/hooks/useTableKeyboardNav.d.ts +32 -0
- package/dist/Table/hooks/useTableKeyboardNav.d.ts.map +1 -0
- package/dist/Table/hooks/useTableKeyboardNav.js +98 -0
- package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +29 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +89 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -0
- package/dist/Table/index.d.ts +4 -0
- package/dist/Table/index.d.ts.map +1 -0
- package/dist/Table/index.js +16 -0
- package/dist/Table/index.js.map +1 -0
- package/dist/Table/model/table-model.d.ts +83 -0
- package/dist/Table/model/table-model.d.ts.map +1 -0
- package/dist/Table/model/table-model.js +73 -0
- package/dist/Table/model/table-model.js.map +1 -0
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts +1 -0
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +11 -9
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +5 -4
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +50 -22
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts +3 -3
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +28 -67
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.d.ts +12 -0
- package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -0
- package/dist/TimeSeriesTooltip/TooltipHeader.js +160 -0
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -0
- package/dist/TimeSeriesTooltip/index.d.ts +2 -1
- package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/index.js +2 -1
- package/dist/TimeSeriesTooltip/index.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +46 -0
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -0
- package/dist/TimeSeriesTooltip/nearby-series.js +200 -0
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -0
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +17 -13
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +11 -2
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js +9 -17
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
- package/dist/UnitSelector/UnitSelector.js +2 -1
- package/dist/UnitSelector/UnitSelector.js.map +1 -1
- package/dist/cjs/ContentWithLegend/ContentWithLegend.js +70 -0
- package/dist/cjs/ContentWithLegend/index.js +28 -0
- package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +100 -0
- package/dist/cjs/EChart/EChart.js +10 -8
- package/dist/cjs/Legend/CompactLegend.js +4 -1
- package/dist/cjs/Legend/Legend.js +70 -21
- package/dist/cjs/Legend/ListLegend.js +17 -103
- package/dist/cjs/Legend/ListLegendItem.js +8 -11
- package/dist/cjs/Legend/TableLegend.js +67 -0
- package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.js +34 -2
- package/dist/cjs/LineChart/LineChart.js +79 -32
- package/dist/cjs/StatChart/StatChart.js +13 -2
- package/dist/cjs/Table/InnerTable.js +44 -0
- package/dist/cjs/Table/Table.js +102 -0
- package/dist/cjs/Table/TableBody.js +29 -0
- package/dist/cjs/Table/TableCell.js +97 -0
- package/dist/cjs/Table/TableCheckbox.js +55 -0
- package/dist/cjs/Table/TableHead.js +29 -0
- package/dist/cjs/Table/TableRow.js +35 -0
- package/dist/cjs/Table/VirtualizedTable.js +155 -0
- package/dist/cjs/Table/VirtualizedTableContainer.js +30 -0
- package/dist/cjs/Table/hooks/useTableKeyboardNav.js +99 -0
- package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +93 -0
- package/dist/cjs/Table/index.js +33 -0
- package/dist/cjs/Table/model/table-model.js +80 -0
- package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +10 -8
- package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +54 -21
- package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +26 -65
- package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +171 -0
- package/dist/cjs/TimeSeriesTooltip/index.js +2 -1
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +206 -0
- package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +17 -3
- package/dist/cjs/TimeSeriesTooltip/utils.js +8 -16
- package/dist/cjs/UnitSelector/UnitSelector.js +2 -1
- package/dist/cjs/context/SnackbarProvider.js +66 -0
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/model/legend.js +37 -2
- package/dist/cjs/model/units/bytes.js +9 -7
- package/dist/cjs/model/units/decimal.js +2 -2
- package/dist/cjs/model/units/percent.js +2 -2
- package/dist/cjs/model/units/time.js +2 -2
- package/dist/cjs/theme/palette/grey.js +6 -2
- package/dist/context/SnackbarProvider.d.ts +23 -0
- package/dist/context/SnackbarProvider.d.ts.map +1 -0
- package/dist/context/SnackbarProvider.js +59 -0
- package/dist/context/SnackbarProvider.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/model/legend.d.ts +19 -5
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +31 -1
- package/dist/model/legend.js.map +1 -1
- package/dist/model/units/bytes.d.ts.map +1 -1
- package/dist/model/units/bytes.js +9 -7
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/decimal.js +2 -2
- package/dist/model/units/decimal.js.map +1 -1
- package/dist/model/units/percent.js +2 -2
- package/dist/model/units/percent.js.map +1 -1
- package/dist/model/units/time.js +2 -2
- package/dist/model/units/time.js.map +1 -1
- package/dist/theme/palette/grey.d.ts.map +1 -1
- package/dist/theme/palette/grey.js +6 -2
- package/dist/theme/palette/grey.js.map +1 -1
- package/package.json +6 -6
- package/dist/TimeSeriesTooltip/focused-series.d.ts +0 -28
- package/dist/TimeSeriesTooltip/focused-series.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/focused-series.js +0 -140
- package/dist/TimeSeriesTooltip/focused-series.js.map +0 -1
- package/dist/cjs/TimeSeriesTooltip/focused-series.js +0 -148
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// Copyright 2023 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
|
+
INCREASE_NEARBY_SERIES_MULTIPLIER: ()=>INCREASE_NEARBY_SERIES_MULTIPLIER,
|
|
25
|
+
DYNAMIC_NEARBY_SERIES_MULTIPLIER: ()=>DYNAMIC_NEARBY_SERIES_MULTIPLIER,
|
|
26
|
+
SHOW_FEWER_SERIES_LIMIT: ()=>SHOW_FEWER_SERIES_LIMIT,
|
|
27
|
+
checkforNearbySeries: ()=>checkforNearbySeries,
|
|
28
|
+
getNearbySeriesData: ()=>getNearbySeriesData,
|
|
29
|
+
isWithinPercentageRange: ()=>isWithinPercentageRange,
|
|
30
|
+
getYBuffer: ()=>getYBuffer
|
|
31
|
+
});
|
|
32
|
+
const _model = require("../model");
|
|
33
|
+
const INCREASE_NEARBY_SERIES_MULTIPLIER = 5.5; // adjusts how many series show in tooltip (higher == more series shown)
|
|
34
|
+
const DYNAMIC_NEARBY_SERIES_MULTIPLIER = 30; // used for adjustment after series number divisor
|
|
35
|
+
const SHOW_FEWER_SERIES_LIMIT = 5;
|
|
36
|
+
function checkforNearbySeries(data, pointInGrid, yBuffer, chart, unit) {
|
|
37
|
+
const currentNearbySeriesData = [];
|
|
38
|
+
var ref;
|
|
39
|
+
const cursorX = (ref = pointInGrid[0]) !== null && ref !== void 0 ? ref : null;
|
|
40
|
+
var ref1;
|
|
41
|
+
const cursorY = (ref1 = pointInGrid[1]) !== null && ref1 !== void 0 ? ref1 : null;
|
|
42
|
+
if (cursorX === null || cursorY === null) {
|
|
43
|
+
return currentNearbySeriesData;
|
|
44
|
+
}
|
|
45
|
+
const nearbySeriesIndexes = [];
|
|
46
|
+
const emphasizedSeriesIndexes = [];
|
|
47
|
+
const nonEmphasizedSeriesIndexes = [];
|
|
48
|
+
const totalSeries = data.timeSeries.length;
|
|
49
|
+
if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {
|
|
50
|
+
for(let seriesIdx = 0; seriesIdx < totalSeries; seriesIdx++){
|
|
51
|
+
const currentSeries = data.timeSeries[seriesIdx];
|
|
52
|
+
if (currentNearbySeriesData.length >= _model.OPTIMIZED_MODE_SERIES_LIMIT) break;
|
|
53
|
+
if (currentSeries !== undefined) {
|
|
54
|
+
const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';
|
|
55
|
+
var _color;
|
|
56
|
+
const markerColor = (_color = currentSeries.color) !== null && _color !== void 0 ? _color : '#000';
|
|
57
|
+
if (Array.isArray(currentSeries.data)) {
|
|
58
|
+
for(let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++){
|
|
59
|
+
var _datumIdx;
|
|
60
|
+
const xValue = (_datumIdx = data.xAxis[datumIdx]) !== null && _datumIdx !== void 0 ? _datumIdx : 0;
|
|
61
|
+
const yValue = currentSeries.data[datumIdx];
|
|
62
|
+
// ensure null values not displayed in tooltip
|
|
63
|
+
if (yValue !== undefined && yValue !== null && cursorX === datumIdx) {
|
|
64
|
+
if (yValue !== '-' && cursorY <= yValue + yBuffer && cursorY >= yValue - yBuffer) {
|
|
65
|
+
// show fewer bold series in tooltip when many total series
|
|
66
|
+
const minPercentRange = totalSeries > SHOW_FEWER_SERIES_LIMIT ? 2 : 5;
|
|
67
|
+
const percentRangeToCheck = Math.max(minPercentRange, 100 / totalSeries);
|
|
68
|
+
const isClosestToCursor = isWithinPercentageRange({
|
|
69
|
+
valueToCheck: cursorY,
|
|
70
|
+
baseValue: yValue,
|
|
71
|
+
percentage: percentRangeToCheck
|
|
72
|
+
});
|
|
73
|
+
if (isClosestToCursor) {
|
|
74
|
+
emphasizedSeriesIndexes.push(seriesIdx);
|
|
75
|
+
} else {
|
|
76
|
+
nonEmphasizedSeriesIndexes.push(seriesIdx);
|
|
77
|
+
// ensure series not close to cursor are not highlighted
|
|
78
|
+
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
79
|
+
chart.dispatchAction({
|
|
80
|
+
type: 'downplay',
|
|
81
|
+
seriesIndex: seriesIdx
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
|
|
86
|
+
const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;
|
|
87
|
+
const formattedY = (0, _model.formatValue)(yValue, unit);
|
|
88
|
+
currentNearbySeriesData.push({
|
|
89
|
+
seriesIdx: seriesIdx,
|
|
90
|
+
datumIdx: datumIdx,
|
|
91
|
+
seriesName: currentSeriesName,
|
|
92
|
+
date: xValueMilliSeconds,
|
|
93
|
+
x: xValue,
|
|
94
|
+
y: yValue,
|
|
95
|
+
formattedY: formattedY,
|
|
96
|
+
markerColor: markerColor.toString(),
|
|
97
|
+
isClosestToCursor
|
|
98
|
+
});
|
|
99
|
+
nearbySeriesIndexes.push(seriesIdx);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
108
|
+
// Clears emphasis state of all lines that are not emphasized.
|
|
109
|
+
// Emphasized is a subset of just the nearby series that are closest to cursor.
|
|
110
|
+
chart.dispatchAction({
|
|
111
|
+
type: 'downplay',
|
|
112
|
+
seriesIndex: nonEmphasizedSeriesIndexes
|
|
113
|
+
});
|
|
114
|
+
// https://echarts.apache.org/en/api.html#action.highlight
|
|
115
|
+
if (emphasizedSeriesIndexes.length > 0) {
|
|
116
|
+
// Fadeout opacity of all series not closest to cursor.
|
|
117
|
+
chart.dispatchAction({
|
|
118
|
+
type: 'highlight',
|
|
119
|
+
seriesIndex: emphasizedSeriesIndexes,
|
|
120
|
+
notBlur: false
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
// When no emphasized series with bold text, notBlur allows opacity fadeout to not trigger.
|
|
124
|
+
chart.dispatchAction({
|
|
125
|
+
type: 'highlight',
|
|
126
|
+
seriesIndex: nearbySeriesIndexes,
|
|
127
|
+
notBlur: true
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return currentNearbySeriesData;
|
|
132
|
+
}
|
|
133
|
+
function getNearbySeriesData({ mousePos , pinnedPos , chartData , chart , unit , showAllSeries =false }) {
|
|
134
|
+
if (chart === undefined || mousePos === null) return [];
|
|
135
|
+
// prevents multiple tooltips showing from adjacent charts unless tooltip is pinned
|
|
136
|
+
let cursorTargetMatchesChart = false;
|
|
137
|
+
if (mousePos.target !== null) {
|
|
138
|
+
const currentParent = mousePos.target.parentElement;
|
|
139
|
+
if (currentParent !== null) {
|
|
140
|
+
const currentGrandparent = currentParent.parentElement;
|
|
141
|
+
if (currentGrandparent !== null) {
|
|
142
|
+
const chartDom = chart.getDom();
|
|
143
|
+
if (chartDom === currentGrandparent) {
|
|
144
|
+
cursorTargetMatchesChart = true;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// allows moving cursor inside tooltip without it fading away
|
|
150
|
+
if (pinnedPos !== null) {
|
|
151
|
+
mousePos = pinnedPos;
|
|
152
|
+
cursorTargetMatchesChart = true;
|
|
153
|
+
}
|
|
154
|
+
if (cursorTargetMatchesChart === false) return [];
|
|
155
|
+
if (chart['_model'] === undefined) return [];
|
|
156
|
+
const chartModel = chart['_model'];
|
|
157
|
+
const yInterval = chartModel.getComponent('yAxis').axis.scale._interval;
|
|
158
|
+
const totalSeries = chartData.timeSeries.length;
|
|
159
|
+
const yBuffer = getYBuffer({
|
|
160
|
+
yInterval,
|
|
161
|
+
totalSeries,
|
|
162
|
+
showAllSeries
|
|
163
|
+
});
|
|
164
|
+
var _x, _y;
|
|
165
|
+
const pointInPixel = [
|
|
166
|
+
(_x = mousePos.plotCanvas.x) !== null && _x !== void 0 ? _x : 0,
|
|
167
|
+
(_y = mousePos.plotCanvas.y) !== null && _y !== void 0 ? _y : 0
|
|
168
|
+
];
|
|
169
|
+
if (chart.containPixel('grid', pointInPixel)) {
|
|
170
|
+
const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
|
|
171
|
+
if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
|
|
172
|
+
return checkforNearbySeries(chartData, pointInGrid, yBuffer, chart, unit);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// clear all highlighted series when cursor exits canvas
|
|
176
|
+
// https://echarts.apache.org/en/api.html#action.downplay
|
|
177
|
+
for(let i = 0; i < totalSeries; i++){
|
|
178
|
+
if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
|
|
179
|
+
chart.dispatchAction({
|
|
180
|
+
type: 'downplay',
|
|
181
|
+
seriesIndex: i
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
function isWithinPercentageRange({ valueToCheck , baseValue , percentage }) {
|
|
188
|
+
const range = percentage / 100 * baseValue;
|
|
189
|
+
const lowerBound = baseValue - range;
|
|
190
|
+
const upperBound = baseValue + range;
|
|
191
|
+
return valueToCheck >= lowerBound && valueToCheck <= upperBound;
|
|
192
|
+
}
|
|
193
|
+
function getYBuffer({ yInterval , totalSeries , showAllSeries =false }) {
|
|
194
|
+
if (showAllSeries) {
|
|
195
|
+
return yInterval * 10; // roughly correlates with grid so entire canvas is searched
|
|
196
|
+
}
|
|
197
|
+
// never let nearby series range be less than roughly the size of a single tick
|
|
198
|
+
const yBufferMin = yInterval * 0.3;
|
|
199
|
+
// tooltip trigger area gets smaller with more series
|
|
200
|
+
if (totalSeries > SHOW_FEWER_SERIES_LIMIT) {
|
|
201
|
+
const adjustedBuffer = yInterval * DYNAMIC_NEARBY_SERIES_MULTIPLIER / totalSeries;
|
|
202
|
+
return Math.max(yBufferMin, adjustedBuffer);
|
|
203
|
+
}
|
|
204
|
+
// increase multiplier to expand nearby series range
|
|
205
|
+
return Math.max(yBufferMin, yInterval * INCREASE_NEARBY_SERIES_MULTIPLIER);
|
|
206
|
+
}
|
|
@@ -21,20 +21,30 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
TOOLTIP_MIN_WIDTH: ()=>TOOLTIP_MIN_WIDTH,
|
|
24
25
|
TOOLTIP_MAX_WIDTH: ()=>TOOLTIP_MAX_WIDTH,
|
|
25
26
|
TOOLTIP_MAX_HEIGHT: ()=>TOOLTIP_MAX_HEIGHT,
|
|
26
27
|
TOOLTIP_LABELS_MAX_WIDTH: ()=>TOOLTIP_LABELS_MAX_WIDTH,
|
|
27
|
-
|
|
28
|
+
TOOLTIP_ADJUST_Y_POS_MULTIPLIER: ()=>TOOLTIP_ADJUST_Y_POS_MULTIPLIER,
|
|
29
|
+
FALLBACK_CHART_WIDTH: ()=>FALLBACK_CHART_WIDTH,
|
|
30
|
+
NEARBY_SERIES_DESCRIPTION: ()=>NEARBY_SERIES_DESCRIPTION,
|
|
31
|
+
EMPHASIZED_SERIES_DESCRIPTION: ()=>EMPHASIZED_SERIES_DESCRIPTION,
|
|
32
|
+
TOOLTIP_BG_COLOR_FALLBACK: ()=>TOOLTIP_BG_COLOR_FALLBACK,
|
|
28
33
|
TOOLTIP_DATE_FORMAT: ()=>TOOLTIP_DATE_FORMAT,
|
|
29
34
|
defaultCursorData: ()=>defaultCursorData,
|
|
30
35
|
emptyTooltipData: ()=>emptyTooltipData,
|
|
31
36
|
useMousePosition: ()=>useMousePosition
|
|
32
37
|
});
|
|
33
38
|
const _react = require("react");
|
|
39
|
+
const TOOLTIP_MIN_WIDTH = 375;
|
|
34
40
|
const TOOLTIP_MAX_WIDTH = 650;
|
|
35
|
-
const TOOLTIP_MAX_HEIGHT =
|
|
41
|
+
const TOOLTIP_MAX_HEIGHT = 650;
|
|
36
42
|
const TOOLTIP_LABELS_MAX_WIDTH = TOOLTIP_MAX_WIDTH - 150;
|
|
37
|
-
const
|
|
43
|
+
const TOOLTIP_ADJUST_Y_POS_MULTIPLIER = 0.75;
|
|
44
|
+
const FALLBACK_CHART_WIDTH = 750;
|
|
45
|
+
const NEARBY_SERIES_DESCRIPTION = 'nearby series showing in tooltip';
|
|
46
|
+
const EMPHASIZED_SERIES_DESCRIPTION = 'emphasized series showing as bold in tooltip';
|
|
47
|
+
const TOOLTIP_BG_COLOR_FALLBACK = '#2E313E';
|
|
38
48
|
const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {
|
|
39
49
|
year: 'numeric',
|
|
40
50
|
month: 'short',
|
|
@@ -71,6 +81,10 @@ const useMousePosition = ()=>{
|
|
|
71
81
|
x: e.pageX,
|
|
72
82
|
y: e.pageY
|
|
73
83
|
},
|
|
84
|
+
client: {
|
|
85
|
+
x: e.clientX,
|
|
86
|
+
y: e.clientY
|
|
87
|
+
},
|
|
74
88
|
plotCanvas: {
|
|
75
89
|
x: e.offsetX,
|
|
76
90
|
y: e.offsetY
|
|
@@ -19,34 +19,26 @@ Object.defineProperty(exports, "assembleTransform", {
|
|
|
19
19
|
get: ()=>assembleTransform
|
|
20
20
|
});
|
|
21
21
|
const _tooltipModel = require("./tooltip-model");
|
|
22
|
-
function assembleTransform(mousePos,
|
|
22
|
+
function assembleTransform(mousePos, chartWidth, pinnedPos, tooltipHeight, tooltipWidth) {
|
|
23
23
|
if (mousePos === null) {
|
|
24
24
|
return 'translate3d(0, 0)';
|
|
25
25
|
}
|
|
26
|
+
const cursorPaddingX = 32;
|
|
27
|
+
const cursorPaddingY = 16;
|
|
26
28
|
if (pinnedPos !== null) {
|
|
27
29
|
mousePos = pinnedPos;
|
|
28
30
|
}
|
|
29
|
-
const cursorPaddingX = 32;
|
|
30
|
-
const cursorPaddingY = 16;
|
|
31
31
|
// Tooltip is located in a Portal attached to the body.
|
|
32
32
|
// Using page coordinates instead of viewport ensures the tooltip is
|
|
33
33
|
// absolutely positioned correctly as the user scrolls
|
|
34
34
|
const x = mousePos.page.x;
|
|
35
35
|
let y = mousePos.page.y + cursorPaddingY;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (seriesNum > 6) {
|
|
41
|
-
y = mousePos.page.y * 0.75;
|
|
42
|
-
} else {
|
|
43
|
-
y = mousePos.page.y * 0.9;
|
|
44
|
-
}
|
|
45
|
-
} else if (mousePos.plotCanvas.y > yPosAdjustThreshold) {
|
|
46
|
-
y = mousePos.page.y * 0.95;
|
|
36
|
+
// adjust so tooltip does not get cut off at bottom of chart
|
|
37
|
+
if (mousePos.client.y + tooltipHeight + cursorPaddingY > window.innerHeight) {
|
|
38
|
+
// multiplier ensures tooltip isn't overly adjusted and gets cut off at the top of the viewport
|
|
39
|
+
y = mousePos.page.y - tooltipHeight * _tooltipModel.TOOLTIP_ADJUST_Y_POS_MULTIPLIER;
|
|
47
40
|
}
|
|
48
|
-
// use tooltip width to determine when to repos from right to left
|
|
49
|
-
const tooltipWidth = seriesNum > 1 ? _tooltipModel.TOOLTIP_MAX_WIDTH : _tooltipModel.TOOLTIP_MAX_WIDTH / 2;
|
|
41
|
+
// use tooltip width to determine when to repos from right to left
|
|
50
42
|
const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;
|
|
51
43
|
// reposition so tooltip is never too close to right side of chart or left side of browser window
|
|
52
44
|
return mousePos.plotCanvas.x > xPosAdjustThreshold && x > _tooltipModel.TOOLTIP_MAX_WIDTH ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)` : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "UnitSelector", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _model = require("../model");
|
|
24
|
+
const _utils = require("../model/units/utils");
|
|
24
25
|
const _optionsEditorLayout = require("../OptionsEditorLayout");
|
|
25
26
|
const KIND_OPTIONS = Object.entries(_model.UNIT_CONFIG).map(([id, config])=>{
|
|
26
27
|
return {
|
|
@@ -87,7 +88,7 @@ function UnitSelector({ value , onChange }) {
|
|
|
87
88
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
|
|
88
89
|
label: "Abbreviate",
|
|
89
90
|
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
90
|
-
checked: hasAbbreviate ?
|
|
91
|
+
checked: hasAbbreviate ? (0, _utils.shouldAbbreviate)(value.abbreviate) : false,
|
|
91
92
|
onChange: handleAbbreviateChange,
|
|
92
93
|
disabled: !hasAbbreviate
|
|
93
94
|
})
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright 2023 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
|
+
SnackbarProvider: ()=>_notistack.SnackbarProvider,
|
|
25
|
+
useSnackbar: ()=>useSnackbar
|
|
26
|
+
});
|
|
27
|
+
const _react = require("react");
|
|
28
|
+
const _notistack = require("notistack");
|
|
29
|
+
function useSnackbar() {
|
|
30
|
+
const { enqueueSnackbar , closeSnackbar } = (0, _notistack.useSnackbar)();
|
|
31
|
+
// Create variant-specific callbacks
|
|
32
|
+
const errorSnackbar = useEnqueueFunction(enqueueSnackbar, 'error');
|
|
33
|
+
const infoSnackbar = useEnqueueFunction(enqueueSnackbar, 'info');
|
|
34
|
+
const warningSnackbar = useEnqueueFunction(enqueueSnackbar, 'warning');
|
|
35
|
+
const successSnackbar = useEnqueueFunction(enqueueSnackbar, 'success');
|
|
36
|
+
const exceptionSnackbar = (0, _react.useCallback)((error, options)=>{
|
|
37
|
+
// Try to use message prop, but fallback to a default message that
|
|
38
|
+
// will just stringify the error provided
|
|
39
|
+
const message = error instanceof Error ? error.message : `An unexpected error occurred: ${error}`;
|
|
40
|
+
return errorSnackbar(message, options);
|
|
41
|
+
}, [
|
|
42
|
+
errorSnackbar
|
|
43
|
+
]);
|
|
44
|
+
return {
|
|
45
|
+
enqueueSnackbar,
|
|
46
|
+
closeSnackbar,
|
|
47
|
+
errorSnackbar,
|
|
48
|
+
infoSnackbar,
|
|
49
|
+
warningSnackbar,
|
|
50
|
+
successSnackbar,
|
|
51
|
+
exceptionSnackbar
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Helper to create a variant-specific enqueue function
|
|
55
|
+
function useEnqueueFunction(enqueueSnackbar, variant) {
|
|
56
|
+
return (0, _react.useCallback)((message, options)=>{
|
|
57
|
+
const allOptions = {
|
|
58
|
+
...options,
|
|
59
|
+
variant
|
|
60
|
+
};
|
|
61
|
+
return enqueueSnackbar(message, allOptions);
|
|
62
|
+
}, [
|
|
63
|
+
enqueueSnackbar,
|
|
64
|
+
variant
|
|
65
|
+
]);
|
|
66
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
_exportStar(require("./ColorPicker"), exports);
|
|
18
|
+
_exportStar(require("./ContentWithLegend"), exports);
|
|
18
19
|
_exportStar(require("./DateTimeRangePicker"), exports);
|
|
19
20
|
_exportStar(require("./Dialog"), exports);
|
|
20
21
|
_exportStar(require("./Drawer"), exports);
|
|
@@ -29,12 +30,14 @@ _exportStar(require("./LegendOptionsEditor"), exports);
|
|
|
29
30
|
_exportStar(require("./LineChart"), exports);
|
|
30
31
|
_exportStar(require("./OptionsEditorLayout"), exports);
|
|
31
32
|
_exportStar(require("./StatChart"), exports);
|
|
33
|
+
_exportStar(require("./Table"), exports);
|
|
32
34
|
_exportStar(require("./ThresholdsEditor"), exports);
|
|
33
35
|
_exportStar(require("./TimeSeriesTooltip"), exports);
|
|
34
36
|
_exportStar(require("./UnitSelector"), exports);
|
|
35
37
|
_exportStar(require("./YAxisLabel"), exports);
|
|
36
38
|
_exportStar(require("./context/ChartsThemeProvider"), exports);
|
|
37
39
|
_exportStar(require("./context/TimeZoneProvider"), exports);
|
|
40
|
+
_exportStar(require("./context/SnackbarProvider"), exports);
|
|
38
41
|
_exportStar(require("./utils"), exports);
|
|
39
42
|
_exportStar(require("./model"), exports);
|
|
40
43
|
_exportStar(require("./test-utils"), exports);
|
package/dist/cjs/model/legend.js
CHANGED
|
@@ -22,16 +22,25 @@ function _export(target, all) {
|
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
24
|
legendPositions: ()=>legendPositions,
|
|
25
|
+
legendModes: ()=>legendModes,
|
|
25
26
|
LEGEND_POSITIONS_CONFIG: ()=>LEGEND_POSITIONS_CONFIG,
|
|
27
|
+
LEGEND_MODE_CONFIG: ()=>LEGEND_MODE_CONFIG,
|
|
26
28
|
DEFAULT_LEGEND: ()=>DEFAULT_LEGEND,
|
|
27
29
|
getLegendPosition: ()=>getLegendPosition,
|
|
28
30
|
isValidLegendPosition: ()=>isValidLegendPosition,
|
|
29
|
-
|
|
31
|
+
isValidLegendMode: ()=>isValidLegendMode,
|
|
32
|
+
getLegendMode: ()=>getLegendMode,
|
|
33
|
+
validateLegendSpec: ()=>validateLegendSpec,
|
|
34
|
+
isLegendItemVisuallySelected: ()=>isLegendItemVisuallySelected
|
|
30
35
|
});
|
|
31
36
|
const legendPositions = [
|
|
32
37
|
'Bottom',
|
|
33
38
|
'Right'
|
|
34
39
|
];
|
|
40
|
+
const legendModes = [
|
|
41
|
+
'List',
|
|
42
|
+
'Table'
|
|
43
|
+
];
|
|
35
44
|
const LEGEND_POSITIONS_CONFIG = {
|
|
36
45
|
Bottom: {
|
|
37
46
|
label: 'Bottom'
|
|
@@ -40,8 +49,17 @@ const LEGEND_POSITIONS_CONFIG = {
|
|
|
40
49
|
label: 'Right'
|
|
41
50
|
}
|
|
42
51
|
};
|
|
52
|
+
const LEGEND_MODE_CONFIG = {
|
|
53
|
+
List: {
|
|
54
|
+
label: 'List'
|
|
55
|
+
},
|
|
56
|
+
Table: {
|
|
57
|
+
label: 'Table'
|
|
58
|
+
}
|
|
59
|
+
};
|
|
43
60
|
const DEFAULT_LEGEND = {
|
|
44
|
-
position: 'Bottom'
|
|
61
|
+
position: 'Bottom',
|
|
62
|
+
mode: 'List'
|
|
45
63
|
};
|
|
46
64
|
function getLegendPosition(position) {
|
|
47
65
|
if (position === undefined) {
|
|
@@ -55,6 +73,15 @@ function getLegendPosition(position) {
|
|
|
55
73
|
function isValidLegendPosition(position) {
|
|
56
74
|
return legendPositions.includes(position);
|
|
57
75
|
}
|
|
76
|
+
function isValidLegendMode(mode) {
|
|
77
|
+
return legendModes.includes(mode);
|
|
78
|
+
}
|
|
79
|
+
function getLegendMode(mode) {
|
|
80
|
+
if (!mode || !isValidLegendMode(mode)) {
|
|
81
|
+
return DEFAULT_LEGEND.mode;
|
|
82
|
+
}
|
|
83
|
+
return mode;
|
|
84
|
+
}
|
|
58
85
|
function validateLegendSpec(legend) {
|
|
59
86
|
if (legend === undefined) {
|
|
60
87
|
// undefined is valid since this is how legend is hidden by default
|
|
@@ -63,5 +90,13 @@ function validateLegendSpec(legend) {
|
|
|
63
90
|
if (!isValidLegendPosition(legend.position)) {
|
|
64
91
|
return false;
|
|
65
92
|
}
|
|
93
|
+
if (legend.mode && !isValidLegendMode(legend.mode)) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
66
96
|
return true;
|
|
67
97
|
}
|
|
98
|
+
function isLegendItemVisuallySelected(item, selectedItems) {
|
|
99
|
+
// In the "ALL" case, technically all legend items are selected, but we do
|
|
100
|
+
// not render them differently.
|
|
101
|
+
return selectedItems !== 'ALL' && !!selectedItems[item.id];
|
|
102
|
+
}
|
|
@@ -43,8 +43,8 @@ const BYTES_GROUP_CONFIG = {
|
|
|
43
43
|
abbreviate: true
|
|
44
44
|
};
|
|
45
45
|
const BYTES_UNIT_CONFIG = {
|
|
46
|
-
//
|
|
47
|
-
// In other words,
|
|
46
|
+
// These units are powers of 1000.
|
|
47
|
+
// In other words, 1 KB = 1000 bytes.
|
|
48
48
|
Bytes: {
|
|
49
49
|
group: 'Bytes',
|
|
50
50
|
label: 'Bytes'
|
|
@@ -60,6 +60,7 @@ function formatBytes(bytes, options) {
|
|
|
60
60
|
useGrouping: true
|
|
61
61
|
};
|
|
62
62
|
if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
|
|
63
|
+
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
63
64
|
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
64
65
|
} else {
|
|
65
66
|
// This can happen if bytes is between -1000 and 1000
|
|
@@ -67,16 +68,17 @@ function formatBytes(bytes, options) {
|
|
|
67
68
|
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
return formatter.format(bytes);
|
|
71
|
+
return Intl.NumberFormat('en-US', formatterOptions).format(bytes);
|
|
72
72
|
}
|
|
73
73
|
// numbro is able to add units like KB, MB, GB, etc. correctly
|
|
74
74
|
return (0, _numbro.default)(bytes).format({
|
|
75
75
|
output: 'byte',
|
|
76
76
|
base: 'decimal',
|
|
77
77
|
spaceSeparated: true,
|
|
78
|
-
mantissa:
|
|
79
|
-
trimMantissa
|
|
80
|
-
|
|
78
|
+
mantissa: (0, _utils.hasDecimalPlaces)(decimal_places) ? decimal_places : DEFAULT_NUMBRO_MANTISSA,
|
|
79
|
+
// trimMantissa trims trailing 0s
|
|
80
|
+
trimMantissa: !(0, _utils.hasDecimalPlaces)(decimal_places),
|
|
81
|
+
// optionalMantissa excludes all the decimal places if they're all zeros
|
|
82
|
+
optionalMantissa: !(0, _utils.hasDecimalPlaces)(decimal_places)
|
|
81
83
|
});
|
|
82
84
|
}
|
|
@@ -51,12 +51,12 @@ function formatDecimal(value, options) {
|
|
|
51
51
|
formatterOptions.notation = 'compact';
|
|
52
52
|
}
|
|
53
53
|
if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
|
|
54
|
+
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
54
55
|
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
55
56
|
} else {
|
|
56
57
|
if ((0, _utils.shouldAbbreviate)(abbreviate)) {
|
|
57
58
|
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
return formatter.format(value);
|
|
61
|
+
return Intl.NumberFormat('en-US', formatterOptions).format(value);
|
|
62
62
|
}
|
|
@@ -64,10 +64,10 @@ function formatPercent(value, { kind , decimal_places }) {
|
|
|
64
64
|
useGrouping: true
|
|
65
65
|
};
|
|
66
66
|
if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
|
|
67
|
+
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
67
68
|
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
68
69
|
} else {
|
|
69
70
|
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
-
return formatter.format(value);
|
|
72
|
+
return Intl.NumberFormat('en-US', formatterOptions).format(value);
|
|
73
73
|
}
|
|
@@ -96,10 +96,10 @@ function formatTime(value, { kind , decimal_places }) {
|
|
|
96
96
|
unitDisplay: isMonthOrYear ? 'long' : 'narrow'
|
|
97
97
|
};
|
|
98
98
|
if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
|
|
99
|
+
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
99
100
|
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
100
101
|
} else {
|
|
101
102
|
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
-
return formatter.format(value);
|
|
104
|
+
return Intl.NumberFormat('en-US', formatterOptions).format(value);
|
|
105
105
|
}
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "greyOption", {
|
|
|
21
21
|
const _grey = require("./colors/grey");
|
|
22
22
|
const greyOption = (mode)=>{
|
|
23
23
|
return mode === 'light' ? {
|
|
24
|
+
50: _grey.grey[50],
|
|
24
25
|
100: _grey.grey[100],
|
|
25
26
|
200: _grey.grey[200],
|
|
26
27
|
300: _grey.grey[300],
|
|
@@ -29,8 +30,10 @@ const greyOption = (mode)=>{
|
|
|
29
30
|
600: _grey.grey[600],
|
|
30
31
|
700: _grey.grey[700],
|
|
31
32
|
800: _grey.grey[800],
|
|
32
|
-
900: _grey.grey[900]
|
|
33
|
+
900: _grey.grey[900],
|
|
34
|
+
950: _grey.grey[950]
|
|
33
35
|
} : {
|
|
36
|
+
50: _grey.grey[950],
|
|
34
37
|
100: _grey.grey[900],
|
|
35
38
|
200: _grey.grey[800],
|
|
36
39
|
300: _grey.grey[700],
|
|
@@ -39,6 +42,7 @@ const greyOption = (mode)=>{
|
|
|
39
42
|
600: _grey.grey[400],
|
|
40
43
|
700: _grey.grey[300],
|
|
41
44
|
800: _grey.grey[200],
|
|
42
|
-
900: _grey.grey[100]
|
|
45
|
+
900: _grey.grey[100],
|
|
46
|
+
950: _grey.grey[50]
|
|
43
47
|
};
|
|
44
48
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SnackbarProvider as NotistackProvider, ProviderContext as NotistackContext, SnackbarMessage, OptionsObject, SnackbarKey } from 'notistack';
|
|
2
|
+
export interface SnackbarContext extends NotistackContext {
|
|
3
|
+
errorSnackbar: EnqueueFunction;
|
|
4
|
+
infoSnackbar: EnqueueFunction;
|
|
5
|
+
warningSnackbar: EnqueueFunction;
|
|
6
|
+
successSnackbar: EnqueueFunction;
|
|
7
|
+
/**
|
|
8
|
+
* Useful for catch blocks where the error will be of type `unknown`, tries
|
|
9
|
+
* to show the `message` property if passed an instance of `Error`.
|
|
10
|
+
*/
|
|
11
|
+
exceptionSnackbar: (error: unknown, options?: SnackbarOptions) => SnackbarKey;
|
|
12
|
+
}
|
|
13
|
+
declare type EnqueueFunction = (message: SnackbarMessage, options?: SnackbarOptions) => SnackbarKey;
|
|
14
|
+
declare type SnackbarOptions = Omit<OptionsObject, 'variant'>;
|
|
15
|
+
/**
|
|
16
|
+
* Application-wide provider for showing snackbars/toasts.
|
|
17
|
+
*/
|
|
18
|
+
export { NotistackProvider as SnackbarProvider };
|
|
19
|
+
/**
|
|
20
|
+
* Gets the SnackbarContext with methods for displaying snackbars/toasts.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useSnackbar(): SnackbarContext;
|
|
23
|
+
//# sourceMappingURL=SnackbarProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SnackbarProvider.d.ts","sourceRoot":"","sources":["../../src/context/SnackbarProvider.tsx"],"names":[],"mappings":"AAcA,OAAO,EACL,gBAAgB,IAAI,iBAAiB,EACrC,eAAe,IAAI,gBAAgB,EAEnC,eAAe,EACf,aAAa,EACb,WAAW,EACZ,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,aAAa,EAAE,eAAe,CAAC;IAC/B,YAAY,EAAE,eAAe,CAAC;IAC9B,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,EAAE,eAAe,CAAC;IAEjC;;;OAGG;IACH,iBAAiB,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,WAAW,CAAC;CAC/E;AAED,aAAK,eAAe,GAAG,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,WAAW,CAAC;AAE5F,aAAK,eAAe,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;AAEtD;;GAEG;AACH,OAAO,EAAE,iBAAiB,IAAI,gBAAgB,EAAE,CAAC;AAEjD;;GAEG;AACH,wBAAgB,WAAW,IAAI,eAAe,CA6B7C"}
|