@perses-dev/components 0.29.1 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +1 -7
- 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 +45 -11
- 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 +34 -99
- 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/LineChart/LineChart.d.ts +2 -1
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +35 -22
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +5 -1
- 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 +3 -2
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +63 -17
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts +5 -3
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +81 -44
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/index.d.ts +1 -1
- package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/index.js +1 -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 +12 -4
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +10 -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 +7 -15
- 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/cjs/DateTimeRangePicker/TimeRangeSelector.js +7 -1
- package/dist/cjs/EChart/EChart.js +1 -7
- package/dist/cjs/Legend/CompactLegend.js +4 -1
- package/dist/cjs/Legend/Legend.js +45 -11
- package/dist/cjs/Legend/ListLegend.js +33 -98
- package/dist/cjs/Legend/ListLegendItem.js +8 -11
- package/dist/cjs/LineChart/LineChart.js +35 -22
- package/dist/cjs/StatChart/StatChart.js +5 -1
- 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 +67 -16
- package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +85 -43
- package/dist/cjs/TimeSeriesTooltip/index.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +206 -0
- package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +15 -3
- package/dist/cjs/TimeSeriesTooltip/utils.js +6 -14
- package/dist/cjs/UnitSelector/UnitSelector.js +39 -16
- package/dist/cjs/context/SnackbarProvider.js +66 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/model/legend.js +7 -1
- 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 +15 -22
- package/dist/cjs/model/units/time.js +24 -20
- 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/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 +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/model/legend.d.ts +10 -2
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +5 -0
- 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 +1 -1
- package/dist/model/units/percent.d.ts.map +1 -1
- package/dist/model/units/percent.js +14 -21
- package/dist/model/units/percent.js.map +1 -1
- package/dist/model/units/time.d.ts +1 -1
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js +24 -20
- package/dist/model/units/time.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/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
|
@@ -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,19 +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
|
+
const _constants = require("./constants");
|
|
29
|
+
const _utils = require("./utils");
|
|
28
30
|
const percentUnitKinds = [
|
|
29
31
|
'Percent',
|
|
30
32
|
'PercentDecimal',
|
|
31
33
|
'%'
|
|
32
34
|
];
|
|
33
|
-
const
|
|
34
|
-
label: '
|
|
35
|
-
decimal_places: true
|
|
36
|
-
abbreviate: true
|
|
35
|
+
const PERCENT_GROUP_CONFIG = {
|
|
36
|
+
label: 'Percent',
|
|
37
|
+
decimal_places: true
|
|
37
38
|
};
|
|
38
39
|
const PERCENT_GROUP = 'Percent';
|
|
39
40
|
const PERCENT_UNIT_CONFIG = {
|
|
@@ -53,28 +54,20 @@ const PERCENT_UNIT_CONFIG = {
|
|
|
53
54
|
label: '%'
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
|
-
const MAX_SIGNIFICANT_DIGITS = 3;
|
|
57
57
|
function formatPercent(value, { kind , decimal_places }) {
|
|
58
58
|
// Intl.NumberFormat translates 0 -> 0%, 0.5 -> 50%, 1 -> 100%
|
|
59
59
|
if (kind === 'Percent') {
|
|
60
60
|
value = value / 100;
|
|
61
61
|
}
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
useGrouping: true
|
|
70
|
-
});
|
|
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);
|
|
71
69
|
} else {
|
|
72
|
-
|
|
73
|
-
formatter = new Intl.NumberFormat('en-US', {
|
|
74
|
-
style: 'percent',
|
|
75
|
-
maximumSignificantDigits: MAX_SIGNIFICANT_DIGITS,
|
|
76
|
-
useGrouping: true
|
|
77
|
-
});
|
|
70
|
+
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
78
71
|
}
|
|
79
|
-
return
|
|
72
|
+
return Intl.NumberFormat('en-US', formatterOptions).format(value);
|
|
80
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
|
-
})(
|
|
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 = {}));
|
|
90
91
|
function formatTime(value, { kind , decimal_places }) {
|
|
91
|
-
const decimalPlaces = decimal_places !== null && decimal_places !== void 0 ? decimal_places : _constants.DEFAULT_DECIMAL_PLACES;
|
|
92
|
-
const timeUnit = TimeIntlDuration[kind];
|
|
93
92
|
const isMonthOrYear = kind === 'Months' || kind === 'Years';
|
|
94
|
-
const
|
|
93
|
+
const formatterOptions = {
|
|
95
94
|
style: 'unit',
|
|
96
|
-
unit:
|
|
97
|
-
unitDisplay: isMonthOrYear ? 'long' : 'narrow'
|
|
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
|
};
|
|
@@ -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
|
@@ -13,12 +13,14 @@ export * from './LegendOptionsEditor';
|
|
|
13
13
|
export * from './LineChart';
|
|
14
14
|
export * from './OptionsEditorLayout';
|
|
15
15
|
export * from './StatChart';
|
|
16
|
+
export * from './Table';
|
|
16
17
|
export * from './ThresholdsEditor';
|
|
17
18
|
export * from './TimeSeriesTooltip';
|
|
18
19
|
export * from './UnitSelector';
|
|
19
20
|
export * from './YAxisLabel';
|
|
20
21
|
export * from './context/ChartsThemeProvider';
|
|
21
22
|
export * from './context/TimeZoneProvider';
|
|
23
|
+
export * from './context/SnackbarProvider';
|
|
22
24
|
export * from './utils';
|
|
23
25
|
export * from './model';
|
|
24
26
|
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,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
|
@@ -25,12 +25,14 @@ export * from './LegendOptionsEditor';
|
|
|
25
25
|
export * from './LineChart';
|
|
26
26
|
export * from './OptionsEditorLayout';
|
|
27
27
|
export * from './StatChart';
|
|
28
|
+
export * from './Table';
|
|
28
29
|
export * from './ThresholdsEditor';
|
|
29
30
|
export * from './TimeSeriesTooltip';
|
|
30
31
|
export * from './UnitSelector';
|
|
31
32
|
export * from './YAxisLabel';
|
|
32
33
|
export * from './context/ChartsThemeProvider';
|
|
33
34
|
export * from './context/TimeZoneProvider';
|
|
35
|
+
export * from './context/SnackbarProvider';
|
|
34
36
|
export * from './utils';
|
|
35
37
|
export * from './model';
|
|
36
38
|
export * from './test-utils';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"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\nexport * from './ColorPicker';\nexport * from './DateTimeRangePicker';\nexport * from './Dialog';\nexport * from './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './GaugeChart';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LegendOptionsEditor';\nexport * from './LineChart';\nexport * from './OptionsEditorLayout';\nexport * from './StatChart';\nexport * from './ThresholdsEditor';\nexport * from './TimeSeriesTooltip';\nexport * from './UnitSelector';\nexport * from './YAxisLabel';\nexport * from './context/ChartsThemeProvider';\nexport * from './context/TimeZoneProvider';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\nexport * from './theme';\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,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,"sources":["../src/index.ts"],"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\nexport * from './ColorPicker';\nexport * from './DateTimeRangePicker';\nexport * from './Dialog';\nexport * from './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './GaugeChart';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LegendOptionsEditor';\nexport * from './LineChart';\nexport * from './OptionsEditorLayout';\nexport * from './StatChart';\nexport * from './Table';\nexport * from './ThresholdsEditor';\nexport * from './TimeSeriesTooltip';\nexport * from './UnitSelector';\nexport * from './YAxisLabel';\nexport * from './context/ChartsThemeProvider';\nexport * from './context/TimeZoneProvider';\nexport * from './context/SnackbarProvider';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\nexport * from './theme';\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,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,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/model/legend.d.ts
CHANGED
|
@@ -7,16 +7,24 @@ export interface LegendOptions {
|
|
|
7
7
|
export interface LegendItem {
|
|
8
8
|
id: string;
|
|
9
9
|
label: string;
|
|
10
|
-
isSelected: boolean;
|
|
11
10
|
color: string;
|
|
12
|
-
onClick
|
|
11
|
+
onClick?: MouseEventHandler<HTMLElement>;
|
|
13
12
|
}
|
|
14
13
|
export declare type LegendPositionConfig = {
|
|
15
14
|
label: string;
|
|
16
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* State of selected items in the legend.
|
|
18
|
+
* - When "ALL", all legend items are selected, but not visually highlighted.
|
|
19
|
+
* - Otherwise, it is a Record that associates legend item ids with a boolean
|
|
20
|
+
* value. When the associated entry for a legend item is `true`, that item
|
|
21
|
+
* will be treated as selected and visually highlighted.
|
|
22
|
+
*/
|
|
23
|
+
export declare type SelectedLegendItemState = Record<LegendItem['id'], boolean> | 'ALL';
|
|
17
24
|
export declare const LEGEND_POSITIONS_CONFIG: Readonly<Record<LegendPositions, LegendPositionConfig>>;
|
|
18
25
|
export declare const DEFAULT_LEGEND: LegendOptions;
|
|
19
26
|
export declare function getLegendPosition(position?: LegendPositions): "Bottom" | "Right";
|
|
20
27
|
export declare function isValidLegendPosition(position: LegendPositions): boolean;
|
|
21
28
|
export declare function validateLegendSpec(legend?: LegendOptions): boolean;
|
|
29
|
+
export declare function isLegendItemVisuallySelected(item: LegendItem, selectedItems: SelectedLegendItemState): boolean;
|
|
22
30
|
//# sourceMappingURL=legend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/model/legend.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,eAAO,MAAM,eAAe,8BAA+B,CAAC;AAE5D,oBAAY,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,
|
|
1
|
+
{"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/model/legend.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,eAAO,MAAM,eAAe,8BAA+B,CAAC;AAE5D,oBAAY,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAC1C;AAED,oBAAY,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;GAMG;AACH,oBAAY,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;AAEhF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAG3F,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,aAE5B,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,eAAe,sBAQ3D;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,WAE9D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,aAAa,WASxD;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,uBAAuB,WAIpG"}
|
package/dist/model/legend.js
CHANGED
|
@@ -47,5 +47,10 @@ export function validateLegendSpec(legend) {
|
|
|
47
47
|
}
|
|
48
48
|
return true;
|
|
49
49
|
}
|
|
50
|
+
export function isLegendItemVisuallySelected(item, selectedItems) {
|
|
51
|
+
// In the "ALL" case, technically all legend items are selected, but we do
|
|
52
|
+
// not render them differently.
|
|
53
|
+
return selectedItems !== 'ALL' && !!selectedItems[item.id];
|
|
54
|
+
}
|
|
50
55
|
|
|
51
56
|
//# sourceMappingURL=legend.js.map
|
package/dist/model/legend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/legend.ts"],"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 { MouseEventHandler } from 'react';\n\nexport const legendPositions = ['Bottom', 'Right'] as const;\n\nexport type LegendPositions = (typeof legendPositions)[number];\n\nexport interface LegendOptions {\n position: LegendPositions;\n}\n\nexport interface LegendItem {\n id: string;\n label: string;\n
|
|
1
|
+
{"version":3,"sources":["../../src/model/legend.ts"],"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 { MouseEventHandler } from 'react';\n\nexport const legendPositions = ['Bottom', 'Right'] as const;\n\nexport type LegendPositions = (typeof legendPositions)[number];\n\nexport interface LegendOptions {\n position: LegendPositions;\n}\n\nexport interface LegendItem {\n id: string;\n label: string;\n color: string;\n onClick?: MouseEventHandler<HTMLElement>;\n}\n\nexport type LegendPositionConfig = {\n label: string;\n};\n\n/**\n * State of selected items in the legend.\n * - When \"ALL\", all legend items are selected, but not visually highlighted.\n * - Otherwise, it is a Record that associates legend item ids with a boolean\n * value. When the associated entry for a legend item is `true`, that item\n * will be treated as selected and visually highlighted.\n */\nexport type SelectedLegendItemState = Record<LegendItem['id'], boolean> | 'ALL';\n\nexport const LEGEND_POSITIONS_CONFIG: Readonly<Record<LegendPositions, LegendPositionConfig>> = {\n Bottom: { label: 'Bottom' },\n Right: { label: 'Right' },\n};\n\nexport const DEFAULT_LEGEND: LegendOptions = {\n position: 'Bottom',\n};\n\nexport function getLegendPosition(position?: LegendPositions) {\n if (position === undefined) {\n return DEFAULT_LEGEND.position;\n }\n if (isValidLegendPosition(position)) {\n return position;\n }\n return DEFAULT_LEGEND.position;\n}\n\nexport function isValidLegendPosition(position: LegendPositions) {\n return (legendPositions as readonly string[]).includes(position);\n}\n\nexport function validateLegendSpec(legend?: LegendOptions) {\n if (legend === undefined) {\n // undefined is valid since this is how legend is hidden by default\n return true;\n }\n if (!isValidLegendPosition(legend.position)) {\n return false;\n }\n return true;\n}\n\nexport function isLegendItemVisuallySelected(item: LegendItem, selectedItems: SelectedLegendItemState) {\n // In the \"ALL\" case, technically all legend items are selected, but we do\n // not render them differently.\n return selectedItems !== 'ALL' && !!selectedItems[item.id];\n}\n"],"names":["legendPositions","LEGEND_POSITIONS_CONFIG","Bottom","label","Right","DEFAULT_LEGEND","position","getLegendPosition","undefined","isValidLegendPosition","includes","validateLegendSpec","legend","isLegendItemVisuallySelected","item","selectedItems","id"],"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;AAIjC,OAAO,MAAMA,eAAe,GAAG;IAAC,QAAQ;IAAE,OAAO;CAAC,AAAS,CAAC;AA4B5D,OAAO,MAAMC,uBAAuB,GAA4D;IAC9FC,MAAM,EAAE;QAAEC,KAAK,EAAE,QAAQ;KAAE;IAC3BC,KAAK,EAAE;QAAED,KAAK,EAAE,OAAO;KAAE;CAC1B,CAAC;AAEF,OAAO,MAAME,cAAc,GAAkB;IAC3CC,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF,OAAO,SAASC,iBAAiB,CAACD,QAA0B,EAAE;IAC5D,IAAIA,QAAQ,KAAKE,SAAS,EAAE;QAC1B,OAAOH,cAAc,CAACC,QAAQ,CAAC;IACjC,CAAC;IACD,IAAIG,qBAAqB,CAACH,QAAQ,CAAC,EAAE;QACnC,OAAOA,QAAQ,CAAC;IAClB,CAAC;IACD,OAAOD,cAAc,CAACC,QAAQ,CAAC;AACjC,CAAC;AAED,OAAO,SAASG,qBAAqB,CAACH,QAAyB,EAAE;IAC/D,OAAO,AAACN,eAAe,CAAuBU,QAAQ,CAACJ,QAAQ,CAAC,CAAC;AACnE,CAAC;AAED,OAAO,SAASK,kBAAkB,CAACC,MAAsB,EAAE;IACzD,IAAIA,MAAM,KAAKJ,SAAS,EAAE;QACxB,mEAAmE;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAACC,qBAAqB,CAACG,MAAM,CAACN,QAAQ,CAAC,EAAE;QAC3C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,OAAO,SAASO,4BAA4B,CAACC,IAAgB,EAAEC,aAAsC,EAAE;IACrG,0EAA0E;IAC1E,+BAA+B;IAC/B,OAAOA,aAAa,KAAK,KAAK,IAAI,CAAC,CAACA,aAAa,CAACD,IAAI,CAACE,EAAE,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -8,6 +8,6 @@ export declare type BytesUnitOptions = {
|
|
|
8
8
|
};
|
|
9
9
|
export declare const BYTES_GROUP_CONFIG: UnitGroupConfig;
|
|
10
10
|
export declare const BYTES_UNIT_CONFIG: Readonly<Record<BytesUnitKind, UnitConfig>>;
|
|
11
|
-
export declare function formatBytes(bytes: number,
|
|
11
|
+
export declare function formatBytes(bytes: number, options: BytesUnitOptions): string;
|
|
12
12
|
export {};
|
|
13
13
|
//# sourceMappingURL=bytes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../../src/model/units/bytes.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../../src/model/units/bytes.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAKtD,QAAA,MAAM,cAAc,oBAAqB,CAAC;AAC1C,aAAK,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AACrD,oBAAY,gBAAgB,GAAG;IAC7B,IAAI,EAAE,aAAa,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AACF,eAAO,MAAM,kBAAkB,EAAE,eAIhC,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,CAOzE,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,UAmCnE"}
|