@perses-dev/components 0.35.0 → 0.36.1
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 +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.d.ts.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js +4 -2
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +9 -3
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js +17 -7
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +1 -1
- package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -1
- package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -1
- package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts +2 -5
- package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -1
- package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
- package/dist/GaugeChart/GaugeChart.d.ts +1 -1
- package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
- package/dist/GaugeChart/GaugeChart.js +1 -2
- package/dist/GaugeChart/GaugeChart.js.map +1 -1
- package/dist/Legend/CompactLegend.d.ts +3 -1
- package/dist/Legend/CompactLegend.d.ts.map +1 -1
- package/dist/Legend/CompactLegend.js +5 -2
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.d.ts +11 -2
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +4 -2
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/ListLegend.d.ts +3 -1
- package/dist/Legend/ListLegend.d.ts.map +1 -1
- package/dist/Legend/ListLegend.js +5 -4
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +15 -2
- package/dist/Legend/ListLegendItem.d.ts.map +1 -1
- package/dist/Legend/ListLegendItem.js +17 -5
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts +4 -2
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js +8 -2
- package/dist/Legend/TableLegend.js.map +1 -1
- package/dist/LineChart/LineChart.d.ts +17 -3
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +33 -7
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/LineChart/index.d.ts +1 -1
- package/dist/LineChart/index.d.ts.map +1 -1
- package/dist/LineChart/index.js +1 -0
- package/dist/LineChart/index.js.map +1 -1
- package/dist/LineChart/utils.d.ts +2 -1
- package/dist/LineChart/utils.d.ts.map +1 -1
- package/dist/LineChart/utils.js +14 -1
- package/dist/LineChart/utils.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts +12 -0
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts.map +1 -0
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +45 -0
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -0
- package/dist/RefreshIntervalPicker/index.d.ts +2 -0
- package/dist/RefreshIntervalPicker/index.d.ts.map +1 -0
- package/dist/{model/units → RefreshIntervalPicker}/index.js +1 -3
- package/dist/RefreshIntervalPicker/index.js.map +1 -0
- package/dist/StatChart/StatChart.d.ts +1 -1
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +1 -1
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/Table/InnerTable.js +2 -2
- package/dist/Table/InnerTable.js.map +1 -1
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +57 -9
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableCell.d.ts +11 -1
- package/dist/Table/TableCell.d.ts.map +1 -1
- package/dist/Table/TableCell.js +8 -3
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.js +1 -1
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableHeaderCell.d.ts +23 -0
- package/dist/Table/TableHeaderCell.d.ts.map +1 -0
- package/dist/Table/TableHeaderCell.js +53 -0
- package/dist/Table/TableHeaderCell.js.map +1 -0
- package/dist/Table/VirtualizedTable.d.ts +3 -3
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +43 -8
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +71 -7
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +6 -2
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +2 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +2 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +2 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +2 -11
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/UnitSelector/UnitSelector.d.ts +1 -1
- package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
- package/dist/UnitSelector/UnitSelector.js +1 -2
- package/dist/UnitSelector/UnitSelector.js.map +1 -1
- package/dist/cjs/ContentWithLegend/ContentWithLegend.js +4 -2
- package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +17 -7
- package/dist/cjs/GaugeChart/GaugeChart.js +2 -3
- package/dist/cjs/Legend/CompactLegend.js +5 -2
- package/dist/cjs/Legend/Legend.js +4 -2
- package/dist/cjs/Legend/ListLegend.js +5 -4
- package/dist/cjs/Legend/ListLegendItem.js +17 -5
- package/dist/cjs/Legend/TableLegend.js +8 -2
- package/dist/cjs/LineChart/LineChart.js +31 -5
- package/dist/cjs/LineChart/index.js +1 -0
- package/dist/cjs/LineChart/utils.js +14 -3
- package/dist/cjs/RefreshIntervalPicker/RefreshIntervalPicker.js +51 -0
- package/dist/cjs/{model/units → RefreshIntervalPicker}/index.js +1 -3
- package/dist/cjs/StatChart/StatChart.js +4 -4
- package/dist/cjs/Table/InnerTable.js +2 -2
- package/dist/cjs/Table/Table.js +56 -8
- package/dist/cjs/Table/TableCell.js +8 -3
- package/dist/cjs/Table/TableCheckbox.js +1 -1
- package/dist/cjs/Table/TableHeaderCell.js +59 -0
- package/dist/cjs/Table/VirtualizedTable.js +43 -8
- package/dist/cjs/Table/model/table-model.js +6 -2
- package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +2 -1
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +2 -11
- package/dist/cjs/UnitSelector/UnitSelector.js +6 -7
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/model/index.js +1 -1
- package/dist/{model/units/types.js → cjs/model/timeOption.js} +4 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/index.d.ts +1 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/theme.d.ts +1 -4
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/model/timeOption.d.ts +6 -0
- package/dist/model/timeOption.d.ts.map +1 -0
- package/dist/model/{units/constants.js → timeOption.js} +2 -4
- package/dist/model/timeOption.js.map +1 -0
- package/package.json +3 -4
- package/dist/cjs/model/units/bytes.js +0 -84
- package/dist/cjs/model/units/constants.js +0 -23
- package/dist/cjs/model/units/decimal.js +0 -62
- package/dist/cjs/model/units/percent.js +0 -73
- package/dist/cjs/model/units/time.js +0 -105
- package/dist/cjs/model/units/types.js +0 -28
- package/dist/cjs/model/units/units.js +0 -101
- package/dist/cjs/model/units/utils.js +0 -42
- package/dist/model/units/bytes.d.ts +0 -13
- package/dist/model/units/bytes.d.ts.map +0 -1
- package/dist/model/units/bytes.js +0 -66
- package/dist/model/units/bytes.js.map +0 -1
- package/dist/model/units/constants.d.ts +0 -2
- package/dist/model/units/constants.d.ts.map +0 -1
- package/dist/model/units/constants.js.map +0 -1
- package/dist/model/units/decimal.d.ts +0 -13
- package/dist/model/units/decimal.d.ts.map +0 -1
- package/dist/model/units/decimal.js +0 -49
- package/dist/model/units/decimal.js.map +0 -1
- package/dist/model/units/index.d.ts +0 -4
- package/dist/model/units/index.d.ts.map +0 -1
- package/dist/model/units/index.js.map +0 -1
- package/dist/model/units/percent.d.ts +0 -12
- package/dist/model/units/percent.d.ts.map +0 -1
- package/dist/model/units/percent.js +0 -60
- package/dist/model/units/percent.js.map +0 -1
- package/dist/model/units/time.d.ts +0 -22
- package/dist/model/units/time.d.ts.map +0 -1
- package/dist/model/units/time.js +0 -91
- package/dist/model/units/time.js.map +0 -1
- package/dist/model/units/types.d.ts +0 -47
- package/dist/model/units/types.d.ts.map +0 -1
- package/dist/model/units/types.js.map +0 -1
- package/dist/model/units/units.d.ts +0 -40
- package/dist/model/units/units.d.ts.map +0 -1
- package/dist/model/units/units.js +0 -80
- package/dist/model/units/units.js.map +0 -1
- package/dist/model/units/utils.d.ts +0 -4
- package/dist/model/units/utils.d.ts.map +0 -1
- package/dist/model/units/utils.js +0 -32
- package/dist/model/units/utils.js.map +0 -1
|
@@ -20,11 +20,10 @@ Object.defineProperty(exports, "UnitSelector", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
|
-
const
|
|
24
|
-
const _utils = require("../model/units/utils");
|
|
23
|
+
const _core = require("@perses-dev/core");
|
|
25
24
|
const _optionsEditorLayout = require("../OptionsEditorLayout");
|
|
26
25
|
const _settingsAutocomplete = require("../SettingsAutocomplete");
|
|
27
|
-
const KIND_OPTIONS = Object.entries(
|
|
26
|
+
const KIND_OPTIONS = Object.entries(_core.UNIT_CONFIG).map(([id, config])=>{
|
|
28
27
|
return {
|
|
29
28
|
id: id,
|
|
30
29
|
...config
|
|
@@ -66,8 +65,8 @@ function getOptionByDecimalPlaces(decimal_places) {
|
|
|
66
65
|
return DECIMAL_PLACES_OPTIONS.find((o)=>o.decimal_places === decimal_places);
|
|
67
66
|
}
|
|
68
67
|
function UnitSelector({ value , onChange }) {
|
|
69
|
-
const hasDecimalPlaces = (0,
|
|
70
|
-
const hasAbbreviate = (0,
|
|
68
|
+
const hasDecimalPlaces = (0, _core.isUnitWithDecimalPlaces)(value);
|
|
69
|
+
const hasAbbreviate = (0, _core.isUnitWithAbbreviate)(value);
|
|
71
70
|
const handleKindChange = (_, newValue)=>{
|
|
72
71
|
onChange({
|
|
73
72
|
kind: newValue.id
|
|
@@ -89,13 +88,13 @@ function UnitSelector({ value , onChange }) {
|
|
|
89
88
|
});
|
|
90
89
|
}
|
|
91
90
|
};
|
|
92
|
-
const kindConfig =
|
|
91
|
+
const kindConfig = _core.UNIT_CONFIG[value.kind];
|
|
93
92
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
94
93
|
children: [
|
|
95
94
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
|
|
96
95
|
label: "Abbreviate",
|
|
97
96
|
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
98
|
-
checked: hasAbbreviate ? (0,
|
|
97
|
+
checked: hasAbbreviate ? (0, _core.shouldAbbreviate)(value.abbreviate) : false,
|
|
99
98
|
onChange: handleAbbreviateChange,
|
|
100
99
|
disabled: !hasAbbreviate
|
|
101
100
|
})
|
package/dist/cjs/index.js
CHANGED
|
@@ -42,6 +42,7 @@ _exportStar(require("./utils"), exports);
|
|
|
42
42
|
_exportStar(require("./model"), exports);
|
|
43
43
|
_exportStar(require("./test-utils"), exports);
|
|
44
44
|
_exportStar(require("./theme"), exports);
|
|
45
|
+
_exportStar(require("./RefreshIntervalPicker"), exports);
|
|
45
46
|
function _exportStar(from, to) {
|
|
46
47
|
Object.keys(from).forEach(function(k) {
|
|
47
48
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
_exportStar(require("./graph"), exports);
|
|
18
18
|
_exportStar(require("./theme"), exports);
|
|
19
|
-
_exportStar(require("./
|
|
19
|
+
_exportStar(require("./timeOption"), exports);
|
|
20
20
|
function _exportStar(from, to) {
|
|
21
21
|
Object.keys(from).forEach(function(k) {
|
|
22
22
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
@@ -10,13 +10,7 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'Percent',
|
|
18
|
-
'Decimal',
|
|
19
|
-
'Bytes'
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=types.js.map
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
package/dist/index.d.ts
CHANGED
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,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,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,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"}
|
|
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,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,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;AACxB,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
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 './ContentWithLegend';\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 './LineChart';\nexport * from './OptionsEditorLayout';\nexport * from './SettingsAutocomplete';\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,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,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,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"}
|
|
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 './ContentWithLegend';\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 './LineChart';\nexport * from './OptionsEditorLayout';\nexport * from './SettingsAutocomplete';\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';\nexport * from './RefreshIntervalPicker';\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,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,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,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;AACxB,cAAc,yBAAyB,CAAC"}
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
|
package/dist/model/index.js
CHANGED
package/dist/model/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/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 './graph';\nexport * from './theme';\nexport * from './
|
|
1
|
+
{"version":3,"sources":["../../src/model/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 './graph';\nexport * from './theme';\nexport * from './timeOption';\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,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
|
package/dist/model/theme.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ThresholdColorPalette } from '@perses-dev/core';
|
|
1
2
|
import type { EChartsOption, BarSeriesOption, LineSeriesOption, GaugeSeriesOption, TitleComponentOption, ComposeOption, XAXisComponentOption, YAXisComponentOption } from 'echarts';
|
|
2
3
|
export interface PersesChartsTheme {
|
|
3
4
|
echartsTheme: EChartsTheme;
|
|
@@ -24,9 +25,5 @@ export interface EChartsTheme extends EChartsOption {
|
|
|
24
25
|
line?: LineSeriesOption;
|
|
25
26
|
gauge?: GaugeSeriesOption;
|
|
26
27
|
}
|
|
27
|
-
export interface ThresholdColorPalette {
|
|
28
|
-
defaultColor: string;
|
|
29
|
-
palette: string[];
|
|
30
|
-
}
|
|
31
28
|
export declare type NoDataOption = ComposeOption<TitleComponentOption | XAXisComponentOption | YAXisComponentOption>;
|
|
32
29
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/model/theme.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF;;OAEG;IACH,SAAS,EAAE;QACT;;WAEG;QACH,OAAO,EAAE;YACP,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;IACF,UAAU,EAAE,qBAAqB,CAAC;CACnC;AAGD,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B;AAED,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/model/theme.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF;;OAEG;IACH,SAAS,EAAE;QACT;;WAEG;QACH,OAAO,EAAE;YACP,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;IACF,UAAU,EAAE,qBAAqB,CAAC;CACnC;AAGD,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B;AAED,oBAAY,YAAY,GAAG,aAAa,CAAC,oBAAoB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC,CAAC"}
|
package/dist/model/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/theme.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 type {\n EChartsOption,\n BarSeriesOption,\n LineSeriesOption,\n GaugeSeriesOption,\n TitleComponentOption,\n ComposeOption,\n XAXisComponentOption,\n YAXisComponentOption,\n} from 'echarts';\n\nexport interface PersesChartsTheme {\n echartsTheme: EChartsTheme;\n noDataOption: NoDataOption;\n sparkline: {\n width: number;\n color: string;\n };\n /**\n * Theming for the container that wraps a chart.\n */\n container: {\n /**\n * Padding in pixels.\n */\n padding: {\n default: number;\n };\n };\n thresholds: ThresholdColorPalette;\n}\n\n// https://github.com/apache/echarts/issues/12489#issuecomment-643185207\nexport interface EChartsTheme extends EChartsOption {\n bar?: BarSeriesOption;\n line?: LineSeriesOption;\n gauge?: GaugeSeriesOption;\n}\n\nexport
|
|
1
|
+
{"version":3,"sources":["../../src/model/theme.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 { ThresholdColorPalette } from '@perses-dev/core';\nimport type {\n EChartsOption,\n BarSeriesOption,\n LineSeriesOption,\n GaugeSeriesOption,\n TitleComponentOption,\n ComposeOption,\n XAXisComponentOption,\n YAXisComponentOption,\n} from 'echarts';\n\nexport interface PersesChartsTheme {\n echartsTheme: EChartsTheme;\n noDataOption: NoDataOption;\n sparkline: {\n width: number;\n color: string;\n };\n /**\n * Theming for the container that wraps a chart.\n */\n container: {\n /**\n * Padding in pixels.\n */\n padding: {\n default: number;\n };\n };\n thresholds: ThresholdColorPalette;\n}\n\n// https://github.com/apache/echarts/issues/12489#issuecomment-643185207\nexport interface EChartsTheme extends EChartsOption {\n bar?: BarSeriesOption;\n line?: LineSeriesOption;\n gauge?: GaugeSeriesOption;\n}\n\nexport type NoDataOption = ComposeOption<TitleComponentOption | XAXisComponentOption | YAXisComponentOption>;\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,WAwC6G"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeOption.d.ts","sourceRoot":"","sources":["../../src/model/timeOption.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,iBAAiB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
|
|
14
|
-
// combined units.
|
|
15
|
-
export const MAX_SIGNIFICANT_DIGITS = 3;
|
|
13
|
+
export { };
|
|
16
14
|
|
|
17
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=timeOption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/timeOption.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 { RelativeTimeRange } from '@perses-dev/core';\n\nexport interface TimeOption {\n value: RelativeTimeRange;\n display: string;\n}\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,WAKC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.1",
|
|
4
4
|
"description": "Common UI components used across Perses features",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@codemirror/lang-json": "^6.0.1",
|
|
37
37
|
"@fontsource/lato": "^4.5.10",
|
|
38
38
|
"@mui/x-date-pickers": "^5.0.0-beta.1",
|
|
39
|
-
"@perses-dev/core": "0.
|
|
39
|
+
"@perses-dev/core": "0.36.1",
|
|
40
40
|
"@tanstack/react-table": "^8.9.1",
|
|
41
41
|
"@uiw/react-codemirror": "^4.19.1",
|
|
42
42
|
"date-fns": "^2.28.0",
|
|
@@ -45,13 +45,12 @@
|
|
|
45
45
|
"lodash": "^4.17.21",
|
|
46
46
|
"mathjs": "^10.6.4",
|
|
47
47
|
"mdi-material-ui": "^7.4.0",
|
|
48
|
-
"numbro": "^2.3.6",
|
|
49
48
|
"react-colorful": "^5.6.1",
|
|
50
49
|
"react-error-boundary": "^3.1.4",
|
|
51
50
|
"react-virtuoso": "^4.3.6"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
|
-
"@perses-dev/storybook": "0.
|
|
53
|
+
"@perses-dev/storybook": "0.36.1"
|
|
55
54
|
},
|
|
56
55
|
"peerDependencies": {
|
|
57
56
|
"@mui/material": "^5.10.0",
|
|
@@ -1,84 +0,0 @@
|
|
|
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
|
-
BYTES_GROUP_CONFIG: ()=>BYTES_GROUP_CONFIG,
|
|
25
|
-
BYTES_UNIT_CONFIG: ()=>BYTES_UNIT_CONFIG,
|
|
26
|
-
formatBytes: ()=>formatBytes
|
|
27
|
-
});
|
|
28
|
-
const _numbro = /*#__PURE__*/ _interopRequireDefault(require("numbro"));
|
|
29
|
-
const _constants = require("./constants");
|
|
30
|
-
const _utils = require("./utils");
|
|
31
|
-
function _interopRequireDefault(obj) {
|
|
32
|
-
return obj && obj.__esModule ? obj : {
|
|
33
|
-
default: obj
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
const DEFAULT_NUMBRO_MANTISSA = 2;
|
|
37
|
-
const bytesUnitKinds = [
|
|
38
|
-
'Bytes'
|
|
39
|
-
];
|
|
40
|
-
const BYTES_GROUP_CONFIG = {
|
|
41
|
-
label: 'Bytes',
|
|
42
|
-
decimal_places: true,
|
|
43
|
-
abbreviate: true
|
|
44
|
-
};
|
|
45
|
-
const BYTES_UNIT_CONFIG = {
|
|
46
|
-
// These units are powers of 1000.
|
|
47
|
-
// In other words, 1 KB = 1000 bytes.
|
|
48
|
-
Bytes: {
|
|
49
|
-
group: 'Bytes',
|
|
50
|
-
label: 'Bytes'
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
function formatBytes(bytes, options) {
|
|
54
|
-
const { abbreviate , decimal_places } = options;
|
|
55
|
-
if (!(0, _utils.shouldAbbreviate)(abbreviate) || Math.abs(bytes) < 1000) {
|
|
56
|
-
const formatterOptions = {
|
|
57
|
-
style: 'unit',
|
|
58
|
-
unit: 'byte',
|
|
59
|
-
unitDisplay: 'long',
|
|
60
|
-
useGrouping: true
|
|
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);
|
|
72
|
-
}
|
|
73
|
-
// numbro is able to add units like KB, MB, GB, etc. correctly
|
|
74
|
-
return (0, _numbro.default)(bytes).format({
|
|
75
|
-
output: 'byte',
|
|
76
|
-
base: 'decimal',
|
|
77
|
-
spaceSeparated: true,
|
|
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)
|
|
83
|
-
});
|
|
84
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
// Common constants needed across individual unit groups and the overall
|
|
14
|
-
// combined units.
|
|
15
|
-
"use strict";
|
|
16
|
-
Object.defineProperty(exports, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "MAX_SIGNIFICANT_DIGITS", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: ()=>MAX_SIGNIFICANT_DIGITS
|
|
22
|
-
});
|
|
23
|
-
const MAX_SIGNIFICANT_DIGITS = 3;
|
|
@@ -1,62 +0,0 @@
|
|
|
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
|
-
DECIMAL_GROUP_CONFIG: ()=>DECIMAL_GROUP_CONFIG,
|
|
25
|
-
DECIMAL_UNIT_CONFIG: ()=>DECIMAL_UNIT_CONFIG,
|
|
26
|
-
formatDecimal: ()=>formatDecimal
|
|
27
|
-
});
|
|
28
|
-
const _constants = require("./constants");
|
|
29
|
-
const _utils = require("./utils");
|
|
30
|
-
const decimalUnitKinds = [
|
|
31
|
-
'Decimal'
|
|
32
|
-
];
|
|
33
|
-
const DECIMAL_GROUP_CONFIG = {
|
|
34
|
-
label: 'Decimal',
|
|
35
|
-
decimal_places: true,
|
|
36
|
-
abbreviate: true
|
|
37
|
-
};
|
|
38
|
-
const DECIMAL_UNIT_CONFIG = {
|
|
39
|
-
Decimal: {
|
|
40
|
-
group: 'Decimal',
|
|
41
|
-
label: 'Decimal'
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
function formatDecimal(value, options) {
|
|
45
|
-
const { abbreviate , decimal_places } = options;
|
|
46
|
-
const formatterOptions = {
|
|
47
|
-
style: 'decimal',
|
|
48
|
-
useGrouping: true
|
|
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);
|
|
62
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
PERCENT_GROUP_CONFIG: ()=>PERCENT_GROUP_CONFIG,
|
|
25
|
-
PERCENT_UNIT_CONFIG: ()=>PERCENT_UNIT_CONFIG,
|
|
26
|
-
formatPercent: ()=>formatPercent
|
|
27
|
-
});
|
|
28
|
-
const _constants = require("./constants");
|
|
29
|
-
const _utils = require("./utils");
|
|
30
|
-
const percentUnitKinds = [
|
|
31
|
-
'Percent',
|
|
32
|
-
'PercentDecimal',
|
|
33
|
-
'%'
|
|
34
|
-
];
|
|
35
|
-
const PERCENT_GROUP_CONFIG = {
|
|
36
|
-
label: 'Percent',
|
|
37
|
-
decimal_places: true
|
|
38
|
-
};
|
|
39
|
-
const PERCENT_GROUP = 'Percent';
|
|
40
|
-
const PERCENT_UNIT_CONFIG = {
|
|
41
|
-
Percent: {
|
|
42
|
-
group: PERCENT_GROUP,
|
|
43
|
-
label: 'Percent (0-100)'
|
|
44
|
-
},
|
|
45
|
-
PercentDecimal: {
|
|
46
|
-
group: PERCENT_GROUP,
|
|
47
|
-
label: 'Percent (0.0-1.0)'
|
|
48
|
-
},
|
|
49
|
-
'%': {
|
|
50
|
-
// This option is not shown in the selector because it is a shorthand
|
|
51
|
-
// duplicate of `Percent`.
|
|
52
|
-
disableSelectorOption: true,
|
|
53
|
-
group: PERCENT_GROUP,
|
|
54
|
-
label: '%'
|
|
55
|
-
}
|
|
56
|
-
};
|
|
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;
|
|
61
|
-
}
|
|
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);
|
|
73
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
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
|
-
PersesTimeToIntlTime: ()=>PersesTimeToIntlTime,
|
|
25
|
-
TIME_GROUP_CONFIG: ()=>TIME_GROUP_CONFIG,
|
|
26
|
-
TIME_UNIT_CONFIG: ()=>TIME_UNIT_CONFIG,
|
|
27
|
-
formatTime: ()=>formatTime
|
|
28
|
-
});
|
|
29
|
-
const _constants = require("./constants");
|
|
30
|
-
const _utils = require("./utils");
|
|
31
|
-
const timeUnitKinds = [
|
|
32
|
-
'Milliseconds',
|
|
33
|
-
'Seconds',
|
|
34
|
-
'Minutes',
|
|
35
|
-
'Hours',
|
|
36
|
-
'Days',
|
|
37
|
-
'Weeks',
|
|
38
|
-
'Months',
|
|
39
|
-
'Years'
|
|
40
|
-
];
|
|
41
|
-
const TIME_GROUP = 'Time';
|
|
42
|
-
const TIME_GROUP_CONFIG = {
|
|
43
|
-
label: 'Time',
|
|
44
|
-
decimal_places: true
|
|
45
|
-
};
|
|
46
|
-
const TIME_UNIT_CONFIG = {
|
|
47
|
-
Milliseconds: {
|
|
48
|
-
group: TIME_GROUP,
|
|
49
|
-
label: 'Milliseconds'
|
|
50
|
-
},
|
|
51
|
-
Seconds: {
|
|
52
|
-
group: TIME_GROUP,
|
|
53
|
-
label: 'Seconds'
|
|
54
|
-
},
|
|
55
|
-
Minutes: {
|
|
56
|
-
group: TIME_GROUP,
|
|
57
|
-
label: 'Minutes'
|
|
58
|
-
},
|
|
59
|
-
Hours: {
|
|
60
|
-
group: TIME_GROUP,
|
|
61
|
-
label: 'Hours'
|
|
62
|
-
},
|
|
63
|
-
Days: {
|
|
64
|
-
group: TIME_GROUP,
|
|
65
|
-
label: 'Days'
|
|
66
|
-
},
|
|
67
|
-
Weeks: {
|
|
68
|
-
group: TIME_GROUP,
|
|
69
|
-
label: 'Weeks'
|
|
70
|
-
},
|
|
71
|
-
Months: {
|
|
72
|
-
group: TIME_GROUP,
|
|
73
|
-
label: 'Months'
|
|
74
|
-
},
|
|
75
|
-
Years: {
|
|
76
|
-
group: TIME_GROUP,
|
|
77
|
-
label: 'Years'
|
|
78
|
-
}
|
|
79
|
-
};
|
|
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 = {
|
|
94
|
-
style: 'unit',
|
|
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);
|
|
105
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
// Common types needed across individual unit groups and the overall combined
|
|
14
|
-
// units.
|
|
15
|
-
"use strict";
|
|
16
|
-
Object.defineProperty(exports, "__esModule", {
|
|
17
|
-
value: true
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "UNIT_GROUPS", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: ()=>UNIT_GROUPS
|
|
22
|
-
});
|
|
23
|
-
const UNIT_GROUPS = [
|
|
24
|
-
'Time',
|
|
25
|
-
'Percent',
|
|
26
|
-
'Decimal',
|
|
27
|
-
'Bytes'
|
|
28
|
-
];
|