@perses-dev/components 0.0.0-snapshot-color-palette-gen-test-0ebddd6 → 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/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -1
- package/dist/DateTimeRangePicker/TimeRangeSelector.js +7 -1
- package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
- package/dist/EChart/EChart.d.ts.map +1 -1
- package/dist/EChart/EChart.js +9 -1
- 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 +83 -36
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +23 -15
- 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 +40 -17
- package/dist/UnitSelector/UnitSelector.js.map +1 -1
- package/dist/YAxisLabel.d.ts.map +1 -1
- package/dist/YAxisLabel.js +1 -0
- package/dist/YAxisLabel.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/DateTimeRangePicker/TimeRangeSelector.js +7 -1
- package/dist/cjs/EChart/EChart.js +9 -1
- 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 +83 -36
- package/dist/cjs/StatChart/StatChart.js +23 -15
- 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 +39 -16
- package/dist/cjs/YAxisLabel.js +1 -0
- 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 +25 -21
- package/dist/cjs/model/units/constants.js +3 -3
- package/dist/cjs/model/units/decimal.js +22 -19
- package/dist/cjs/model/units/percent.js +20 -11
- package/dist/cjs/model/units/time.js +26 -22
- package/dist/cjs/model/units/units.js +2 -2
- package/dist/cjs/model/units/utils.js +42 -0
- package/dist/cjs/theme/palette/grey.js +6 -2
- package/dist/cjs/utils/theme-gen.js +8 -13
- 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 +1 -1
- package/dist/model/units/bytes.d.ts.map +1 -1
- package/dist/model/units/bytes.js +26 -22
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/constants.d.ts +1 -1
- package/dist/model/units/constants.js +1 -1
- package/dist/model/units/constants.js.map +1 -1
- package/dist/model/units/decimal.d.ts +2 -2
- package/dist/model/units/decimal.d.ts.map +1 -1
- package/dist/model/units/decimal.js +22 -19
- package/dist/model/units/decimal.js.map +1 -1
- package/dist/model/units/percent.d.ts +2 -2
- package/dist/model/units/percent.d.ts.map +1 -1
- package/dist/model/units/percent.js +20 -11
- package/dist/model/units/percent.js.map +1 -1
- package/dist/model/units/time.d.ts +2 -2
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js +26 -22
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/types.d.ts +9 -0
- package/dist/model/units/types.d.ts.map +1 -1
- package/dist/model/units/types.js.map +1 -1
- package/dist/model/units/units.js +2 -2
- package/dist/model/units/units.js.map +1 -1
- package/dist/model/units/utils.d.ts +4 -0
- package/dist/model/units/utils.d.ts.map +1 -0
- package/dist/model/units/utils.js +32 -0
- package/dist/model/units/utils.js.map +1 -0
- 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/dist/utils/theme-gen.d.ts.map +1 -1
- package/dist/utils/theme-gen.js +8 -13
- package/dist/utils/theme-gen.js.map +1 -1
- package/package.json +6 -6
- package/dist/TimeSeriesTooltip/focused-series.d.ts +0 -25
- package/dist/TimeSeriesTooltip/focused-series.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/focused-series.js +0 -111
- package/dist/TimeSeriesTooltip/focused-series.js.map +0 -1
- package/dist/cjs/TimeSeriesTooltip/focused-series.js +0 -117
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
|
+
}
|
|
@@ -27,11 +27,13 @@ _export(exports, {
|
|
|
27
27
|
});
|
|
28
28
|
const _numbro = /*#__PURE__*/ _interopRequireDefault(require("numbro"));
|
|
29
29
|
const _constants = require("./constants");
|
|
30
|
+
const _utils = require("./utils");
|
|
30
31
|
function _interopRequireDefault(obj) {
|
|
31
32
|
return obj && obj.__esModule ? obj : {
|
|
32
33
|
default: obj
|
|
33
34
|
};
|
|
34
35
|
}
|
|
36
|
+
const DEFAULT_NUMBRO_MANTISSA = 2;
|
|
35
37
|
const bytesUnitKinds = [
|
|
36
38
|
'Bytes'
|
|
37
39
|
];
|
|
@@ -41,40 +43,42 @@ const BYTES_GROUP_CONFIG = {
|
|
|
41
43
|
abbreviate: true
|
|
42
44
|
};
|
|
43
45
|
const BYTES_UNIT_CONFIG = {
|
|
44
|
-
//
|
|
45
|
-
// In other words,
|
|
46
|
+
// These units are powers of 1000.
|
|
47
|
+
// In other words, 1 KB = 1000 bytes.
|
|
46
48
|
Bytes: {
|
|
47
49
|
group: 'Bytes',
|
|
48
50
|
label: 'Bytes'
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
|
-
function formatBytes(bytes,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumfractiondigits
|
|
56
|
-
if (decimal_places < 0) {
|
|
57
|
-
decimal_places = 0;
|
|
58
|
-
} else if (decimal_places > 20) {
|
|
59
|
-
decimal_places = 20;
|
|
60
|
-
}
|
|
61
|
-
const showFullNumber = abbreviate == false || bytes < 1000;
|
|
62
|
-
if (showFullNumber) {
|
|
63
|
-
const formatter = new Intl.NumberFormat('en-US', {
|
|
53
|
+
function formatBytes(bytes, options) {
|
|
54
|
+
const { abbreviate , decimal_places } = options;
|
|
55
|
+
if (!(0, _utils.shouldAbbreviate)(abbreviate) || Math.abs(bytes) < 1000) {
|
|
56
|
+
const formatterOptions = {
|
|
64
57
|
style: 'unit',
|
|
65
58
|
unit: 'byte',
|
|
66
59
|
unitDisplay: 'long',
|
|
67
|
-
maximumFractionDigits: decimal_places,
|
|
68
60
|
useGrouping: true
|
|
69
|
-
}
|
|
70
|
-
|
|
61
|
+
};
|
|
62
|
+
if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
|
|
63
|
+
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
64
|
+
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
65
|
+
} else {
|
|
66
|
+
// This can happen if bytes is between -1000 and 1000
|
|
67
|
+
if ((0, _utils.shouldAbbreviate)(abbreviate)) {
|
|
68
|
+
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return Intl.NumberFormat('en-US', formatterOptions).format(bytes);
|
|
71
72
|
}
|
|
73
|
+
// numbro is able to add units like KB, MB, GB, etc. correctly
|
|
72
74
|
return (0, _numbro.default)(bytes).format({
|
|
73
75
|
output: 'byte',
|
|
74
76
|
base: 'decimal',
|
|
75
77
|
spaceSeparated: true,
|
|
76
|
-
mantissa: decimal_places,
|
|
77
|
-
trimMantissa
|
|
78
|
-
|
|
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)
|
|
79
83
|
});
|
|
80
84
|
}
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", {
|
|
17
17
|
value: true
|
|
18
18
|
});
|
|
19
|
-
Object.defineProperty(exports, "
|
|
19
|
+
Object.defineProperty(exports, "MAX_SIGNIFICANT_DIGITS", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: ()=>
|
|
21
|
+
get: ()=>MAX_SIGNIFICANT_DIGITS
|
|
22
22
|
});
|
|
23
|
-
const
|
|
23
|
+
const MAX_SIGNIFICANT_DIGITS = 3;
|
|
@@ -21,17 +21,19 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
24
|
+
DECIMAL_GROUP_CONFIG: ()=>DECIMAL_GROUP_CONFIG,
|
|
25
25
|
DECIMAL_UNIT_CONFIG: ()=>DECIMAL_UNIT_CONFIG,
|
|
26
26
|
formatDecimal: ()=>formatDecimal
|
|
27
27
|
});
|
|
28
28
|
const _constants = require("./constants");
|
|
29
|
+
const _utils = require("./utils");
|
|
29
30
|
const decimalUnitKinds = [
|
|
30
31
|
'Decimal'
|
|
31
32
|
];
|
|
32
|
-
const
|
|
33
|
-
label: '
|
|
34
|
-
decimal_places: true
|
|
33
|
+
const DECIMAL_GROUP_CONFIG = {
|
|
34
|
+
label: 'Decimal',
|
|
35
|
+
decimal_places: true,
|
|
36
|
+
abbreviate: true
|
|
35
37
|
};
|
|
36
38
|
const DECIMAL_UNIT_CONFIG = {
|
|
37
39
|
Decimal: {
|
|
@@ -39,21 +41,22 @@ const DECIMAL_UNIT_CONFIG = {
|
|
|
39
41
|
label: 'Decimal'
|
|
40
42
|
}
|
|
41
43
|
};
|
|
42
|
-
function formatDecimal(value,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumfractiondigits
|
|
46
|
-
if (decimal_places < 0) {
|
|
47
|
-
decimal_places = 0;
|
|
48
|
-
} else if (decimal_places > 20) {
|
|
49
|
-
decimal_places = 20;
|
|
50
|
-
}
|
|
51
|
-
const showFullNumber = abbreviate == false || value < 1000;
|
|
52
|
-
const formatter = new Intl.NumberFormat('en-US', {
|
|
44
|
+
function formatDecimal(value, options) {
|
|
45
|
+
const { abbreviate , decimal_places } = options;
|
|
46
|
+
const formatterOptions = {
|
|
53
47
|
style: 'decimal',
|
|
54
|
-
notation: showFullNumber ? 'standard' : 'compact',
|
|
55
|
-
maximumFractionDigits: decimal_places,
|
|
56
48
|
useGrouping: true
|
|
57
|
-
}
|
|
58
|
-
|
|
49
|
+
};
|
|
50
|
+
if ((0, _utils.shouldAbbreviate)(abbreviate)) {
|
|
51
|
+
formatterOptions.notation = 'compact';
|
|
52
|
+
}
|
|
53
|
+
if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
|
|
54
|
+
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
55
|
+
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
56
|
+
} else {
|
|
57
|
+
if ((0, _utils.shouldAbbreviate)(abbreviate)) {
|
|
58
|
+
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return Intl.NumberFormat('en-US', formatterOptions).format(value);
|
|
59
62
|
}
|
|
@@ -21,20 +21,20 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
24
|
+
PERCENT_GROUP_CONFIG: ()=>PERCENT_GROUP_CONFIG,
|
|
25
25
|
PERCENT_UNIT_CONFIG: ()=>PERCENT_UNIT_CONFIG,
|
|
26
26
|
formatPercent: ()=>formatPercent
|
|
27
27
|
});
|
|
28
28
|
const _constants = require("./constants");
|
|
29
|
+
const _utils = require("./utils");
|
|
29
30
|
const percentUnitKinds = [
|
|
30
31
|
'Percent',
|
|
31
32
|
'PercentDecimal',
|
|
32
33
|
'%'
|
|
33
34
|
];
|
|
34
|
-
const
|
|
35
|
-
label: '
|
|
36
|
-
decimal_places: true
|
|
37
|
-
abbreviate: true
|
|
35
|
+
const PERCENT_GROUP_CONFIG = {
|
|
36
|
+
label: 'Percent',
|
|
37
|
+
decimal_places: true
|
|
38
38
|
};
|
|
39
39
|
const PERCENT_GROUP = 'Percent';
|
|
40
40
|
const PERCENT_UNIT_CONFIG = {
|
|
@@ -54,11 +54,20 @@ const PERCENT_UNIT_CONFIG = {
|
|
|
54
54
|
label: '%'
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
function formatPercent(value,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
value = value * 100;
|
|
57
|
+
function formatPercent(value, { kind , decimal_places }) {
|
|
58
|
+
// Intl.NumberFormat translates 0 -> 0%, 0.5 -> 50%, 1 -> 100%
|
|
59
|
+
if (kind === 'Percent') {
|
|
60
|
+
value = value / 100;
|
|
62
61
|
}
|
|
63
|
-
|
|
62
|
+
const formatterOptions = {
|
|
63
|
+
style: 'percent',
|
|
64
|
+
useGrouping: true
|
|
65
|
+
};
|
|
66
|
+
if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
|
|
67
|
+
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
68
|
+
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
69
|
+
} else {
|
|
70
|
+
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
71
|
+
}
|
|
72
|
+
return Intl.NumberFormat('en-US', formatterOptions).format(value);
|
|
64
73
|
}
|
|
@@ -21,12 +21,13 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
24
|
+
PersesTimeToIntlTime: ()=>PersesTimeToIntlTime,
|
|
25
25
|
TIME_GROUP_CONFIG: ()=>TIME_GROUP_CONFIG,
|
|
26
26
|
TIME_UNIT_CONFIG: ()=>TIME_UNIT_CONFIG,
|
|
27
27
|
formatTime: ()=>formatTime
|
|
28
28
|
});
|
|
29
29
|
const _constants = require("./constants");
|
|
30
|
+
const _utils = require("./utils");
|
|
30
31
|
const timeUnitKinds = [
|
|
31
32
|
'Milliseconds',
|
|
32
33
|
'Seconds',
|
|
@@ -76,26 +77,29 @@ const TIME_UNIT_CONFIG = {
|
|
|
76
77
|
label: 'Years'
|
|
77
78
|
}
|
|
78
79
|
};
|
|
79
|
-
var
|
|
80
|
-
(function(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})(
|
|
90
|
-
function formatTime(value,
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
const timeUnit = TimeIntlDuration[unitOptions.kind];
|
|
94
|
-
const formatter = new Intl.NumberFormat('en-US', {
|
|
80
|
+
var PersesTimeToIntlTime;
|
|
81
|
+
(function(PersesTimeToIntlTime) {
|
|
82
|
+
PersesTimeToIntlTime["Milliseconds"] = 'millisecond';
|
|
83
|
+
PersesTimeToIntlTime["Seconds"] = 'second';
|
|
84
|
+
PersesTimeToIntlTime["Minutes"] = 'minute';
|
|
85
|
+
PersesTimeToIntlTime["Hours"] = 'hour';
|
|
86
|
+
PersesTimeToIntlTime["Days"] = 'day';
|
|
87
|
+
PersesTimeToIntlTime["Weeks"] = 'week';
|
|
88
|
+
PersesTimeToIntlTime["Months"] = 'month';
|
|
89
|
+
PersesTimeToIntlTime["Years"] = 'year';
|
|
90
|
+
})(PersesTimeToIntlTime || (PersesTimeToIntlTime = {}));
|
|
91
|
+
function formatTime(value, { kind , decimal_places }) {
|
|
92
|
+
const isMonthOrYear = kind === 'Months' || kind === 'Years';
|
|
93
|
+
const formatterOptions = {
|
|
95
94
|
style: 'unit',
|
|
96
|
-
unit:
|
|
97
|
-
unitDisplay: 'long'
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
unit: PersesTimeToIntlTime[kind],
|
|
96
|
+
unitDisplay: isMonthOrYear ? 'long' : 'narrow'
|
|
97
|
+
};
|
|
98
|
+
if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
|
|
99
|
+
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
100
|
+
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
|
|
101
|
+
} else {
|
|
102
|
+
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
103
|
+
}
|
|
104
|
+
return Intl.NumberFormat('en-US', formatterOptions).format(value);
|
|
101
105
|
}
|
|
@@ -40,8 +40,8 @@ const _percent = require("./percent");
|
|
|
40
40
|
const _time = require("./time");
|
|
41
41
|
const UNIT_GROUP_CONFIG = {
|
|
42
42
|
Time: _time.TIME_GROUP_CONFIG,
|
|
43
|
-
Percent:
|
|
44
|
-
Decimal:
|
|
43
|
+
Percent: _percent.PERCENT_GROUP_CONFIG,
|
|
44
|
+
Decimal: _decimal.DECIMAL_GROUP_CONFIG,
|
|
45
45
|
Bytes: _bytes.BYTES_GROUP_CONFIG
|
|
46
46
|
};
|
|
47
47
|
const UNIT_CONFIG = {
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
shouldAbbreviate: ()=>shouldAbbreviate,
|
|
25
|
+
hasDecimalPlaces: ()=>hasDecimalPlaces,
|
|
26
|
+
limitDecimalPlaces: ()=>limitDecimalPlaces
|
|
27
|
+
});
|
|
28
|
+
function shouldAbbreviate(abbreviate) {
|
|
29
|
+
return abbreviate !== false;
|
|
30
|
+
}
|
|
31
|
+
function hasDecimalPlaces(decimal_places) {
|
|
32
|
+
return typeof decimal_places === 'number';
|
|
33
|
+
}
|
|
34
|
+
function limitDecimalPlaces(num) {
|
|
35
|
+
if (!num) return num;
|
|
36
|
+
if (num < 0) {
|
|
37
|
+
num = 0;
|
|
38
|
+
} else if (num > 20) {
|
|
39
|
+
num = 20;
|
|
40
|
+
}
|
|
41
|
+
return num;
|
|
42
|
+
}
|
|
@@ -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
|
};
|
|
@@ -40,20 +40,15 @@ function generateChartsTheme(muiTheme, echartsTheme) {
|
|
|
40
40
|
left: 20,
|
|
41
41
|
containLabel: true
|
|
42
42
|
},
|
|
43
|
-
// Accessible categorical palette from: https://
|
|
43
|
+
// Accessible categorical palette from: https://davidmathlogic.com/colorblind
|
|
44
44
|
color: [
|
|
45
|
-
'#
|
|
46
|
-
'#
|
|
47
|
-
'#
|
|
48
|
-
'#
|
|
49
|
-
'#
|
|
50
|
-
'#
|
|
51
|
-
'#
|
|
52
|
-
'#ff7f00',
|
|
53
|
-
'#cab2d6',
|
|
54
|
-
'#6a3d9a',
|
|
55
|
-
'#ffff99',
|
|
56
|
-
'#b15928'
|
|
45
|
+
'#56B4E9',
|
|
46
|
+
'#009E73',
|
|
47
|
+
'#0072B2',
|
|
48
|
+
'#CC79A7',
|
|
49
|
+
'#F0E442',
|
|
50
|
+
'#E69F00',
|
|
51
|
+
'#D55E00'
|
|
57
52
|
],
|
|
58
53
|
categoryAxis: {
|
|
59
54
|
show: true,
|
|
@@ -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"}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
import { useCallback } from 'react';
|
|
14
|
+
import { SnackbarProvider as NotistackProvider, useSnackbar as useNotistack } from 'notistack';
|
|
15
|
+
/**
|
|
16
|
+
* Application-wide provider for showing snackbars/toasts.
|
|
17
|
+
*/ export { NotistackProvider as SnackbarProvider };
|
|
18
|
+
/**
|
|
19
|
+
* Gets the SnackbarContext with methods for displaying snackbars/toasts.
|
|
20
|
+
*/ export function useSnackbar() {
|
|
21
|
+
const { enqueueSnackbar , closeSnackbar } = useNotistack();
|
|
22
|
+
// Create variant-specific callbacks
|
|
23
|
+
const errorSnackbar = useEnqueueFunction(enqueueSnackbar, 'error');
|
|
24
|
+
const infoSnackbar = useEnqueueFunction(enqueueSnackbar, 'info');
|
|
25
|
+
const warningSnackbar = useEnqueueFunction(enqueueSnackbar, 'warning');
|
|
26
|
+
const successSnackbar = useEnqueueFunction(enqueueSnackbar, 'success');
|
|
27
|
+
const exceptionSnackbar = useCallback((error, options)=>{
|
|
28
|
+
// Try to use message prop, but fallback to a default message that
|
|
29
|
+
// will just stringify the error provided
|
|
30
|
+
const message = error instanceof Error ? error.message : `An unexpected error occurred: ${error}`;
|
|
31
|
+
return errorSnackbar(message, options);
|
|
32
|
+
}, [
|
|
33
|
+
errorSnackbar
|
|
34
|
+
]);
|
|
35
|
+
return {
|
|
36
|
+
enqueueSnackbar,
|
|
37
|
+
closeSnackbar,
|
|
38
|
+
errorSnackbar,
|
|
39
|
+
infoSnackbar,
|
|
40
|
+
warningSnackbar,
|
|
41
|
+
successSnackbar,
|
|
42
|
+
exceptionSnackbar
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
// Helper to create a variant-specific enqueue function
|
|
46
|
+
function useEnqueueFunction(enqueueSnackbar, variant) {
|
|
47
|
+
return useCallback((message, options)=>{
|
|
48
|
+
const allOptions = {
|
|
49
|
+
...options,
|
|
50
|
+
variant
|
|
51
|
+
};
|
|
52
|
+
return enqueueSnackbar(message, allOptions);
|
|
53
|
+
}, [
|
|
54
|
+
enqueueSnackbar,
|
|
55
|
+
variant
|
|
56
|
+
]);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=SnackbarProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/SnackbarProvider.tsx"],"sourcesContent":["// Copyright 2023 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 { useCallback } from 'react';\nimport {\n SnackbarProvider as NotistackProvider,\n ProviderContext as NotistackContext,\n useSnackbar as useNotistack,\n SnackbarMessage,\n OptionsObject,\n SnackbarKey,\n} from 'notistack';\n\nexport interface SnackbarContext extends NotistackContext {\n errorSnackbar: EnqueueFunction;\n infoSnackbar: EnqueueFunction;\n warningSnackbar: EnqueueFunction;\n successSnackbar: EnqueueFunction;\n\n /**\n * Useful for catch blocks where the error will be of type `unknown`, tries\n * to show the `message` property if passed an instance of `Error`.\n */\n exceptionSnackbar: (error: unknown, options?: SnackbarOptions) => SnackbarKey;\n}\n\ntype EnqueueFunction = (message: SnackbarMessage, options?: SnackbarOptions) => SnackbarKey;\n\ntype SnackbarOptions = Omit<OptionsObject, 'variant'>;\n\n/**\n * Application-wide provider for showing snackbars/toasts.\n */\nexport { NotistackProvider as SnackbarProvider };\n\n/**\n * Gets the SnackbarContext with methods for displaying snackbars/toasts.\n */\nexport function useSnackbar(): SnackbarContext {\n const { enqueueSnackbar, closeSnackbar } = useNotistack();\n\n // Create variant-specific callbacks\n const errorSnackbar = useEnqueueFunction(enqueueSnackbar, 'error');\n const infoSnackbar = useEnqueueFunction(enqueueSnackbar, 'info');\n const warningSnackbar = useEnqueueFunction(enqueueSnackbar, 'warning');\n const successSnackbar = useEnqueueFunction(enqueueSnackbar, 'success');\n\n const exceptionSnackbar: SnackbarContext['exceptionSnackbar'] = useCallback(\n (error, options) => {\n // Try to use message prop, but fallback to a default message that\n // will just stringify the error provided\n const message = error instanceof Error ? error.message : `An unexpected error occurred: ${error}`;\n\n return errorSnackbar(message, options);\n },\n [errorSnackbar]\n );\n\n return {\n enqueueSnackbar,\n closeSnackbar,\n errorSnackbar,\n infoSnackbar,\n warningSnackbar,\n successSnackbar,\n exceptionSnackbar,\n };\n}\n\n// Helper to create a variant-specific enqueue function\nfunction useEnqueueFunction(\n enqueueSnackbar: NotistackContext['enqueueSnackbar'],\n variant: OptionsObject['variant']\n): EnqueueFunction {\n return useCallback(\n (message, options) => {\n const allOptions: OptionsObject = {\n ...options,\n variant,\n };\n return enqueueSnackbar(message, allOptions);\n },\n [enqueueSnackbar, variant]\n );\n}\n"],"names":["useCallback","SnackbarProvider","NotistackProvider","useSnackbar","useNotistack","enqueueSnackbar","closeSnackbar","errorSnackbar","useEnqueueFunction","infoSnackbar","warningSnackbar","successSnackbar","exceptionSnackbar","error","options","message","Error","variant","allOptions"],"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,WAAW,QAAQ,OAAO,CAAC;AACpC,SACEC,gBAAgB,IAAIC,iBAAiB,EAErCC,WAAW,IAAIC,YAAY,QAItB,WAAW,CAAC;AAmBnB;;CAEC,GACD,SAASF,iBAAiB,IAAID,gBAAgB,GAAG;AAEjD;;CAEC,GACD,OAAO,SAASE,WAAW,GAAoB;IAC7C,MAAM,EAAEE,eAAe,CAAA,EAAEC,aAAa,CAAA,EAAE,GAAGF,YAAY,EAAE,AAAC;IAE1D,oCAAoC;IACpC,MAAMG,aAAa,GAAGC,kBAAkB,CAACH,eAAe,EAAE,OAAO,CAAC,AAAC;IACnE,MAAMI,YAAY,GAAGD,kBAAkB,CAACH,eAAe,EAAE,MAAM,CAAC,AAAC;IACjE,MAAMK,eAAe,GAAGF,kBAAkB,CAACH,eAAe,EAAE,SAAS,CAAC,AAAC;IACvE,MAAMM,eAAe,GAAGH,kBAAkB,CAACH,eAAe,EAAE,SAAS,CAAC,AAAC;IAEvE,MAAMO,iBAAiB,GAAyCZ,WAAW,CACzE,CAACa,KAAK,EAAEC,OAAO,GAAK;QAClB,kEAAkE;QAClE,yCAAyC;QACzC,MAAMC,OAAO,GAAGF,KAAK,YAAYG,KAAK,GAAGH,KAAK,CAACE,OAAO,GAAG,CAAC,8BAA8B,EAAEF,KAAK,CAAC,CAAC,AAAC;QAElG,OAAON,aAAa,CAACQ,OAAO,EAAED,OAAO,CAAC,CAAC;IACzC,CAAC,EACD;QAACP,aAAa;KAAC,CAChB,AAAC;IAEF,OAAO;QACLF,eAAe;QACfC,aAAa;QACbC,aAAa;QACbE,YAAY;QACZC,eAAe;QACfC,eAAe;QACfC,iBAAiB;KAClB,CAAC;AACJ,CAAC;AAED,uDAAuD;AACvD,SAASJ,kBAAkB,CACzBH,eAAoD,EACpDY,OAAiC,EAChB;IACjB,OAAOjB,WAAW,CAChB,CAACe,OAAO,EAAED,OAAO,GAAK;QACpB,MAAMI,UAAU,GAAkB;YAChC,GAAGJ,OAAO;YACVG,OAAO;SACR,AAAC;QACF,OAAOZ,eAAe,CAACU,OAAO,EAAEG,UAAU,CAAC,CAAC;IAC9C,CAAC,EACD;QAACb,eAAe;QAAEY,OAAO;KAAC,CAC3B,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './ColorPicker';
|
|
2
|
+
export * from './ContentWithLegend';
|
|
2
3
|
export * from './DateTimeRangePicker';
|
|
3
4
|
export * from './Dialog';
|
|
4
5
|
export * from './Drawer';
|
|
@@ -13,12 +14,14 @@ export * from './LegendOptionsEditor';
|
|
|
13
14
|
export * from './LineChart';
|
|
14
15
|
export * from './OptionsEditorLayout';
|
|
15
16
|
export * from './StatChart';
|
|
17
|
+
export * from './Table';
|
|
16
18
|
export * from './ThresholdsEditor';
|
|
17
19
|
export * from './TimeSeriesTooltip';
|
|
18
20
|
export * from './UnitSelector';
|
|
19
21
|
export * from './YAxisLabel';
|
|
20
22
|
export * from './context/ChartsThemeProvider';
|
|
21
23
|
export * from './context/TimeZoneProvider';
|
|
24
|
+
export * from './context/SnackbarProvider';
|
|
22
25
|
export * from './utils';
|
|
23
26
|
export * from './model';
|
|
24
27
|
export * from './test-utils';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
export * from './ColorPicker';
|
|
14
|
+
export * from './ContentWithLegend';
|
|
14
15
|
export * from './DateTimeRangePicker';
|
|
15
16
|
export * from './Dialog';
|
|
16
17
|
export * from './Drawer';
|
|
@@ -25,12 +26,14 @@ export * from './LegendOptionsEditor';
|
|
|
25
26
|
export * from './LineChart';
|
|
26
27
|
export * from './OptionsEditorLayout';
|
|
27
28
|
export * from './StatChart';
|
|
29
|
+
export * from './Table';
|
|
28
30
|
export * from './ThresholdsEditor';
|
|
29
31
|
export * from './TimeSeriesTooltip';
|
|
30
32
|
export * from './UnitSelector';
|
|
31
33
|
export * from './YAxisLabel';
|
|
32
34
|
export * from './context/ChartsThemeProvider';
|
|
33
35
|
export * from './context/TimeZoneProvider';
|
|
36
|
+
export * from './context/SnackbarProvider';
|
|
34
37
|
export * from './utils';
|
|
35
38
|
export * from './model';
|
|
36
39
|
export * from './test-utils';
|