@perses-dev/components 0.18.0 → 0.20.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/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +4 -6
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/StatChart/StatChart.test.js +35 -21
- package/dist/StatChart/StatChart.test.js.map +1 -1
- package/dist/UnitSelector/UnitSelector.test.js +0 -6
- package/dist/UnitSelector/UnitSelector.test.js.map +1 -1
- package/dist/cjs/LineChart/LineChart.js +6 -8
- package/dist/cjs/StatChart/StatChart.test.js +36 -27
- package/dist/cjs/UnitSelector/UnitSelector.test.js +0 -6
- package/dist/cjs/model/graph.js +3 -3
- package/dist/cjs/model/units/time.js +26 -62
- package/dist/cjs/theme/theme.js +19 -0
- package/dist/model/graph.d.ts +1 -1
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/graph.js +2 -1
- package/dist/model/graph.js.map +1 -1
- package/dist/model/units/time.d.ts +11 -0
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js +25 -62
- package/dist/model/units/time.js.map +1 -1
- package/dist/theme/theme.d.ts +2 -2
- package/dist/theme/theme.d.ts.map +1 -1
- package/dist/theme/theme.js +19 -0
- package/dist/theme/theme.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/LineChart/LineChart.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAA6B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/LineChart/LineChart.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAA6B,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAEV,mBAAmB,EAEnB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAiBjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAA0E,aAAa,EAAE,MAAM,SAAS,CAAC;AAiBhH,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,SAAS,CAAC,EAAE,wBAAwB,EAAE,CAAC;IACvC,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;CACzC;AAED,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,SAAS,EACT,UAAU,EACV,aAAa,GACd,EAAE,cAAc,eAkJhB"}
|
|
@@ -12,14 +12,12 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { useMemo, useRef, useState } from 'react';
|
|
15
|
-
import { useDeepMemo } from '@perses-dev/core';
|
|
16
15
|
import { Box } from '@mui/material';
|
|
17
16
|
import { use } from 'echarts/core';
|
|
18
17
|
import { LineChart as EChartsLineChart } from 'echarts/charts';
|
|
19
18
|
import { GridComponent, DataZoomComponent, MarkAreaComponent, MarkLineComponent, MarkPointComponent, TitleComponent, ToolboxComponent, TooltipComponent, LegendComponent, VisualMapComponent } from 'echarts/components';
|
|
20
19
|
import { CanvasRenderer } from 'echarts/renderers';
|
|
21
20
|
import { EChart } from '../EChart';
|
|
22
|
-
import { PROGRESSIVE_MODE_SERIES_LIMIT } from '../model/graph';
|
|
23
21
|
import { useChartsTheme } from '../context/ChartsThemeProvider';
|
|
24
22
|
import { Tooltip } from '../Tooltip/Tooltip';
|
|
25
23
|
import { enableDataZoom, getDateRange, getFormattedDate, getYAxes, restoreChart } from './utils';
|
|
@@ -105,10 +103,9 @@ export function LineChart({ height , data , yAxis , unit , grid , legend , visua
|
|
|
105
103
|
setShowTooltip(false);
|
|
106
104
|
setPinTooltip(false);
|
|
107
105
|
};
|
|
108
|
-
const option =
|
|
106
|
+
const option = useMemo(()=>{
|
|
109
107
|
if (data.timeSeries === undefined) return {};
|
|
110
108
|
if (data.timeSeries === null || data.timeSeries.length === 0) return chartsTheme.noDataOption;
|
|
111
|
-
const showPointsOnHover = data.timeSeries.length < PROGRESSIVE_MODE_SERIES_LIMIT;
|
|
112
109
|
var _rangeMs;
|
|
113
110
|
const rangeMs = (_rangeMs = data.rangeMs) !== null && _rangeMs !== void 0 ? _rangeMs : getDateRange(data.xAxis);
|
|
114
111
|
const option = {
|
|
@@ -126,11 +123,12 @@ export function LineChart({ height , data , yAxis , unit , grid , legend , visua
|
|
|
126
123
|
yAxis: getYAxes(yAxis, unit),
|
|
127
124
|
animation: false,
|
|
128
125
|
tooltip: {
|
|
129
|
-
show:
|
|
126
|
+
show: true,
|
|
130
127
|
trigger: 'axis',
|
|
131
128
|
showContent: false,
|
|
132
129
|
axisPointer: {
|
|
133
|
-
type: '
|
|
130
|
+
type: 'line',
|
|
131
|
+
z: 0
|
|
134
132
|
}
|
|
135
133
|
},
|
|
136
134
|
toolbox: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/LineChart/LineChart.tsx"],"sourcesContent":["// Copyright 2022 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 { MouseEvent, useMemo, useRef, useState } from 'react';\nimport { useDeepMemo } from '@perses-dev/core';\nimport { Box } from '@mui/material';\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n LegendComponentOption,\n VisualMapComponentOption,\n YAXisComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\nimport { LineChart as EChartsLineChart } from 'echarts/charts';\nimport {\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n VisualMapComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, OnEventsType } from '../EChart';\nimport { PROGRESSIVE_MODE_SERIES_LIMIT, EChartsDataFormat } from '../model/graph';\nimport { UnitOptions } from '../model/units';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { Tooltip } from '../Tooltip/Tooltip';\nimport { enableDataZoom, getDateRange, getFormattedDate, getYAxes, restoreChart, ZoomEventData } from './utils';\n\nuse([\n EChartsLineChart,\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n VisualMapComponent,\n CanvasRenderer,\n]);\n\ninterface LineChartProps {\n height: number;\n data: EChartsDataFormat;\n yAxis?: YAXisComponentOption;\n unit?: UnitOptions;\n grid?: GridComponentOption;\n legend?: LegendComponentOption;\n visualMap?: VisualMapComponentOption[];\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n}\n\nexport function LineChart({\n height,\n data,\n yAxis,\n unit,\n grid,\n legend,\n visualMap,\n onDataZoom,\n onDoubleClick,\n}: LineChartProps) {\n const chartsTheme = useChartsTheme();\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [pinTooltip, setPinTooltip] = useState<boolean>(false);\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params) => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setPinTooltip(false);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const startIndex = params.batch[0].startValue ?? 0;\n const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;\n const xAxisStartValue = data.xAxis[startIndex];\n const xAxisEndValue = data.xAxis[endIndex];\n\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n startIndex,\n endIndex,\n };\n onDataZoom(zoomEvent);\n }\n },\n // TODO: use legendselectchanged event to fix tooltip when legend selected\n };\n }, [data, onDataZoom, setPinTooltip]);\n\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n\n const handleOnClick = () => setPinTooltip((current) => !current);\n\n const handleOnDoubleClick = (e: MouseEvent) => {\n setPinTooltip(false);\n // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior\n if (onDoubleClick === undefined) {\n if (chartRef.current !== undefined) {\n restoreChart(chartRef.current);\n }\n } else {\n onDoubleClick(e);\n }\n };\n\n const handleOnMouseDown = (e: MouseEvent) => {\n // hide tooltip when user drags to zoom, but allow clicking inside tooltip to copy labels\n if (e.target instanceof HTMLCanvasElement) {\n setShowTooltip(false);\n }\n };\n\n const handleOnMouseUp = () => {\n setShowTooltip(true);\n };\n\n const handleOnMouseEnter = () => {\n setShowTooltip(true);\n };\n\n const handleOnMouseLeave = () => {\n setShowTooltip(false);\n setPinTooltip(false);\n };\n\n const option: EChartsCoreOption = useDeepMemo(() => {\n if (data.timeSeries === undefined) return {};\n if (data.timeSeries === null || data.timeSeries.length === 0) return chartsTheme.noDataOption;\n\n const showPointsOnHover = data.timeSeries.length < PROGRESSIVE_MODE_SERIES_LIMIT;\n\n const rangeMs = data.rangeMs ?? getDateRange(data.xAxis);\n\n const option: EChartsCoreOption = {\n series: data.timeSeries,\n xAxis: {\n type: 'category',\n data: data.xAxis,\n max: data.xAxisMax,\n axisLabel: {\n formatter: (value: number) => {\n return getFormattedDate(value, rangeMs);\n },\n },\n },\n yAxis: getYAxes(yAxis, unit),\n animation: false,\n tooltip: {\n show: showPointsOnHover,\n trigger: 'axis',\n showContent: false,\n axisPointer: {\n type: 'none',\n },\n },\n toolbox: {\n feature: {\n dataZoom: {\n icon: null, // https://stackoverflow.com/a/67684076/17575201\n yAxisIndex: 'none',\n },\n },\n },\n grid,\n legend,\n visualMap,\n };\n\n return option;\n }, [data, yAxis, grid, legend, visualMap]);\n\n return (\n <Box\n sx={{\n height,\n }}\n onClick={handleOnClick}\n onDoubleClick={handleOnDoubleClick}\n onMouseDown={handleOnMouseDown}\n onMouseUp={handleOnMouseUp}\n onMouseLeave={handleOnMouseLeave}\n onMouseEnter={handleOnMouseEnter}\n >\n {showTooltip === true && (\n <Tooltip chartRef={chartRef} chartData={data} wrapLabels={true} pinTooltip={pinTooltip} unit={unit}></Tooltip>\n )}\n\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n onEvents={handleEvents}\n _instance={chartRef}\n />\n </Box>\n );\n}\n"],"names":["useMemo","useRef","useState","useDeepMemo","Box","use","LineChart","EChartsLineChart","GridComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","LegendComponent","VisualMapComponent","CanvasRenderer","EChart","PROGRESSIVE_MODE_SERIES_LIMIT","useChartsTheme","Tooltip","enableDataZoom","getDateRange","getFormattedDate","getYAxes","restoreChart","height","data","yAxis","unit","grid","legend","visualMap","onDataZoom","onDoubleClick","chartsTheme","chartRef","showTooltip","setShowTooltip","pinTooltip","setPinTooltip","handleEvents","datazoom","params","undefined","setTimeout","batch","startIndex","startValue","endIndex","endValue","xAxis","length","xAxisStartValue","xAxisEndValue","zoomEvent","start","end","current","handleOnClick","handleOnDoubleClick","e","handleOnMouseDown","target","HTMLCanvasElement","handleOnMouseUp","handleOnMouseEnter","handleOnMouseLeave","option","timeSeries","noDataOption","showPointsOnHover","rangeMs","series","type","max","xAxisMax","axisLabel","formatter","value","animation","tooltip","show","trigger","showContent","axisPointer","toolbox","feature","dataZoom","icon","yAxisIndex","sx","onClick","onMouseDown","onMouseUp","onMouseLeave","onMouseEnter","chartData","wrapLabels","width","theme","echartsTheme","onEvents","_instance"],"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;AAAA,SAAqBA,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC9D,SAASC,WAAW,QAAQ,kBAAkB,CAAC;AAC/C,SAASC,GAAG,QAAQ,eAAe,CAAC;AASpC,SAAqCC,GAAG,QAAQ,cAAc,CAAC;AAC/D,SAASC,SAAS,IAAIC,gBAAgB,QAAQ,gBAAgB,CAAC;AAC/D,SACEC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,iBAAiB,EACjBC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,EAChBC,eAAe,EACfC,kBAAkB,QACb,oBAAoB,CAAC;AAC5B,SAASC,cAAc,QAAQ,mBAAmB,CAAC;AACnD,SAASC,MAAM,QAAsB,WAAW,CAAC;AACjD,SAASC,6BAA6B,QAA2B,gBAAgB,CAAC;AAElF,SAASC,cAAc,QAAQ,gCAAgC,CAAC;AAChE,SAASC,OAAO,QAAQ,oBAAoB,CAA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BAED,KAACZ,MAAM;gBACL0E,EAAE,EAAE;oBACFQ,KAAK,EAAE,MAAM;oBACbzE,MAAM,EAAE,MAAM;iBACf;gBACD0C,MAAM,EAAEA,MAAM;gBACdgC,KAAK,EAAEjE,WAAW,CAACkE,YAAY;gBAC/BC,QAAQ,EAAE7D,YAAY;gBACtB8D,SAAS,EAAEnE,QAAQ;cACnB;;MACE,CACN;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/LineChart/LineChart.tsx"],"sourcesContent":["// Copyright 2022 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 { MouseEvent, useMemo, useRef, useState } from 'react';\nimport { Box } from '@mui/material';\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n LegendComponentOption,\n VisualMapComponentOption,\n YAXisComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\nimport { LineChart as EChartsLineChart } from 'echarts/charts';\nimport {\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n VisualMapComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, OnEventsType } from '../EChart';\nimport { EChartsDataFormat } from '../model/graph';\nimport { UnitOptions } from '../model/units';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { Tooltip } from '../Tooltip/Tooltip';\nimport { enableDataZoom, getDateRange, getFormattedDate, getYAxes, restoreChart, ZoomEventData } from './utils';\n\nuse([\n EChartsLineChart,\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n VisualMapComponent,\n CanvasRenderer,\n]);\n\ninterface LineChartProps {\n height: number;\n data: EChartsDataFormat;\n yAxis?: YAXisComponentOption;\n unit?: UnitOptions;\n grid?: GridComponentOption;\n legend?: LegendComponentOption;\n visualMap?: VisualMapComponentOption[];\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n}\n\nexport function LineChart({\n height,\n data,\n yAxis,\n unit,\n grid,\n legend,\n visualMap,\n onDataZoom,\n onDoubleClick,\n}: LineChartProps) {\n const chartsTheme = useChartsTheme();\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [pinTooltip, setPinTooltip] = useState<boolean>(false);\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params) => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setPinTooltip(false);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const startIndex = params.batch[0].startValue ?? 0;\n const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;\n const xAxisStartValue = data.xAxis[startIndex];\n const xAxisEndValue = data.xAxis[endIndex];\n\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n startIndex,\n endIndex,\n };\n onDataZoom(zoomEvent);\n }\n },\n // TODO: use legendselectchanged event to fix tooltip when legend selected\n };\n }, [data, onDataZoom, setPinTooltip]);\n\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n\n const handleOnClick = () => setPinTooltip((current) => !current);\n\n const handleOnDoubleClick = (e: MouseEvent) => {\n setPinTooltip(false);\n // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior\n if (onDoubleClick === undefined) {\n if (chartRef.current !== undefined) {\n restoreChart(chartRef.current);\n }\n } else {\n onDoubleClick(e);\n }\n };\n\n const handleOnMouseDown = (e: MouseEvent) => {\n // hide tooltip when user drags to zoom, but allow clicking inside tooltip to copy labels\n if (e.target instanceof HTMLCanvasElement) {\n setShowTooltip(false);\n }\n };\n\n const handleOnMouseUp = () => {\n setShowTooltip(true);\n };\n\n const handleOnMouseEnter = () => {\n setShowTooltip(true);\n };\n\n const handleOnMouseLeave = () => {\n setShowTooltip(false);\n setPinTooltip(false);\n };\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data.timeSeries === undefined) return {};\n if (data.timeSeries === null || data.timeSeries.length === 0) return chartsTheme.noDataOption;\n\n const rangeMs = data.rangeMs ?? getDateRange(data.xAxis);\n\n const option: EChartsCoreOption = {\n series: data.timeSeries,\n xAxis: {\n type: 'category',\n data: data.xAxis,\n max: data.xAxisMax,\n axisLabel: {\n formatter: (value: number) => {\n return getFormattedDate(value, rangeMs);\n },\n },\n },\n yAxis: getYAxes(yAxis, unit),\n animation: false,\n tooltip: {\n show: true,\n trigger: 'axis',\n showContent: false, // echarts tooltip content hidden since we use custom tooltip instead\n axisPointer: {\n type: 'line',\n z: 0, // ensure point symbol shows on top of dashed line\n },\n },\n toolbox: {\n feature: {\n dataZoom: {\n icon: null, // https://stackoverflow.com/a/67684076/17575201\n yAxisIndex: 'none',\n },\n },\n },\n grid,\n legend,\n visualMap,\n };\n\n return option;\n }, [data, yAxis, grid, legend, visualMap]);\n\n return (\n <Box\n sx={{\n height,\n }}\n onClick={handleOnClick}\n onDoubleClick={handleOnDoubleClick}\n onMouseDown={handleOnMouseDown}\n onMouseUp={handleOnMouseUp}\n onMouseLeave={handleOnMouseLeave}\n onMouseEnter={handleOnMouseEnter}\n >\n {showTooltip === true && (\n <Tooltip chartRef={chartRef} chartData={data} wrapLabels={true} pinTooltip={pinTooltip} unit={unit}></Tooltip>\n )}\n\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n onEvents={handleEvents}\n _instance={chartRef}\n />\n </Box>\n );\n}\n"],"names":["useMemo","useRef","useState","Box","use","LineChart","EChartsLineChart","GridComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","LegendComponent","VisualMapComponent","CanvasRenderer","EChart","useChartsTheme","Tooltip","enableDataZoom","getDateRange","getFormattedDate","getYAxes","restoreChart","height","data","yAxis","unit","grid","legend","visualMap","onDataZoom","onDoubleClick","chartsTheme","chartRef","showTooltip","setShowTooltip","pinTooltip","setPinTooltip","handleEvents","datazoom","params","undefined","setTimeout","batch","startIndex","startValue","endIndex","endValue","xAxis","length","xAxisStartValue","xAxisEndValue","zoomEvent","start","end","current","handleOnClick","handleOnDoubleClick","e","handleOnMouseDown","target","HTMLCanvasElement","handleOnMouseUp","handleOnMouseEnter","handleOnMouseLeave","option","timeSeries","noDataOption","rangeMs","series","type","max","xAxisMax","axisLabel","formatter","value","animation","tooltip","show","trigger","showContent","axisPointer","z","toolbox","feature","dataZoom","icon","yAxisIndex","sx","onClick","onMouseDown","onMouseUp","onMouseLeave","onMouseEnter","chartData","wrapLabels","width","theme","echartsTheme","onEvents","_instance"],"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;AAAA,SAAqBA,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC9D,SAASC,GAAG,QAAQ,eAAe,CAAC;AASpC,SAAqCC,GAAG,QAAQ,cAAc,CAAC;AAC/D,SAASC,SAAS,IAAIC,gBAAgB,QAAQ,gBAAgB,CAAC;AAC/D,SACEC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,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AAkB;;YAE/B7B,WAAW,KAAK,IAAI,kBACnB,KAACjB,OAAO;gBAACgB,QAAQ,EAAEA,QAAQ;gBAAE6D,SAAS,EAAEtE,IAAI;gBAAEuE,UAAU,EAAE,IAAI;gBAAE3D,UAAU,EAAEA,UAAU;gBAAEV,IAAI,EAAEA,IAAI;cAAY,AAC/G;0BAED,KAACX,MAAM;gBACLyE,EAAE,EAAE;oBACFQ,KAAK,EAAE,MAAM;oBACbzE,MAAM,EAAE,MAAM;iBACf;gBACD0C,MAAM,EAAEA,MAAM;gBACdgC,KAAK,EAAEjE,WAAW,CAACkE,YAAY;gBAC/BC,QAAQ,EAAE7D,YAAY;gBACtB8D,SAAS,EAAEnE,QAAQ;cACnB;;MACE,CACN;AACJ,CAAC"}
|
|
@@ -11,19 +11,25 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import React from 'react';
|
|
15
14
|
import { render, screen } from '@testing-library/react';
|
|
16
15
|
import { ChartsThemeProvider } from '../context/ChartsThemeProvider';
|
|
17
16
|
import { testChartsTheme } from '../test-utils';
|
|
18
17
|
import { StatChart } from './StatChart';
|
|
19
18
|
describe('StatChart', ()=>{
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const renderChart = (unit)=>{
|
|
20
|
+
const contentDimensions = {
|
|
21
|
+
width: 200,
|
|
22
|
+
height: 200
|
|
23
|
+
};
|
|
24
|
+
render(/*#__PURE__*/ _jsx(ChartsThemeProvider, {
|
|
25
|
+
chartsTheme: testChartsTheme,
|
|
26
|
+
children: /*#__PURE__*/ _jsx(StatChart, {
|
|
27
|
+
width: contentDimensions.width,
|
|
28
|
+
height: contentDimensions.height,
|
|
29
|
+
data: mockStatData,
|
|
30
|
+
unit: unit
|
|
31
|
+
})
|
|
32
|
+
}));
|
|
27
33
|
};
|
|
28
34
|
const mockStatData = {
|
|
29
35
|
calculatedValue: 7.72931659687181,
|
|
@@ -54,19 +60,27 @@ describe('StatChart', ()=>{
|
|
|
54
60
|
]
|
|
55
61
|
}
|
|
56
62
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
it('render default options (no sparkline)', ()=>{
|
|
64
|
+
const unit = {
|
|
65
|
+
kind: 'Decimal',
|
|
66
|
+
decimal_places: 2
|
|
67
|
+
};
|
|
68
|
+
renderChart(unit);
|
|
69
|
+
expect(screen.getByText('7.73')).toBeInTheDocument();
|
|
70
|
+
});
|
|
71
|
+
it('show value with time unit formatting', ()=>{
|
|
72
|
+
const unit = {
|
|
73
|
+
kind: 'Seconds'
|
|
74
|
+
};
|
|
75
|
+
renderChart(unit);
|
|
76
|
+
expect(screen.getByText('7.73 seconds')).toBeInTheDocument();
|
|
77
|
+
});
|
|
78
|
+
it('show value with time unit formatting', ()=>{
|
|
79
|
+
const unit = {
|
|
80
|
+
kind: 'Months'
|
|
81
|
+
};
|
|
82
|
+
renderChart(unit);
|
|
83
|
+
expect(screen.getByText('7.73 months')).toBeInTheDocument();
|
|
70
84
|
});
|
|
71
85
|
});
|
|
72
86
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/StatChart/StatChart.test.tsx"],"sourcesContent":["// Copyright 2022 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
|
|
1
|
+
{"version":3,"sources":["../../src/StatChart/StatChart.test.tsx"],"sourcesContent":["// Copyright 2022 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 { render, screen } from '@testing-library/react';\nimport { ChartsThemeProvider } from '../context/ChartsThemeProvider';\nimport { UnitOptions } from '../model';\nimport { testChartsTheme } from '../test-utils';\nimport { StatChart, StatChartData } from './StatChart';\n\ndescribe('StatChart', () => {\n const renderChart = (unit: UnitOptions) => {\n const contentDimensions = {\n width: 200,\n height: 200,\n };\n render(\n <ChartsThemeProvider chartsTheme={testChartsTheme}>\n <StatChart width={contentDimensions.width} height={contentDimensions.height} data={mockStatData} unit={unit} />\n </ChartsThemeProvider>\n );\n };\n\n const mockStatData: StatChartData = {\n calculatedValue: 7.72931659687181,\n name: 'Example Stat Chart',\n seriesData: {\n name: '(((count(count(node_cpu_seconds_total{job=\"example\"}) by (cpu))',\n values: [\n [1654006170000, 7.736401673473903],\n [1654006185000, 7.733891213538757],\n [1654006200000, 7.731101813010433],\n [1654006215000, 7.722454672079215],\n [1654006230000, 7.722733612256738],\n ],\n },\n };\n\n it('render default options (no sparkline)', () => {\n const unit: UnitOptions = {\n kind: 'Decimal',\n decimal_places: 2,\n };\n renderChart(unit);\n expect(screen.getByText('7.73')).toBeInTheDocument();\n });\n\n it('show value with time unit formatting', () => {\n const unit: UnitOptions = {\n kind: 'Seconds',\n };\n renderChart(unit);\n expect(screen.getByText('7.73 seconds')).toBeInTheDocument();\n });\n\n it('show value with time unit formatting', () => {\n const unit: UnitOptions = {\n kind: 'Months',\n };\n renderChart(unit);\n expect(screen.getByText('7.73 months')).toBeInTheDocument();\n });\n});\n"],"names":["render","screen","ChartsThemeProvider","testChartsTheme","StatChart","describe","renderChart","unit","contentDimensions","width","height","chartsTheme","data","mockStatData","calculatedValue","name","seriesData","values","it","kind","decimal_places","expect","getByText","toBeInTheDocument"],"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;AAAA,SAASA,MAAM,EAAEC,MAAM,QAAQ,wBAAwB,CAAC;AACxD,SAASC,mBAAmB,QAAQ,gCAAgC,CAAC;AAErE,SAASC,eAAe,QAAQ,eAAe,CAAC;AAChD,SAASC,SAAS,QAAuB,aAAa,CAAC;AAEvDC,QAAQ,CAAC,WAAW,EAAE,IAAM;IAC1B,MAAMC,WAAW,GAAG,CAACC,IAAiB,GAAK;QACzC,MAAMC,iBAAiB,GAAG;YACxBC,KAAK,EAAE,GAAG;YACVC,MAAM,EAAE,GAAG;SACZ,AAAC;QACFV,MAAM,eACJ,KAACE,mBAAmB;YAACS,WAAW,EAAER,eAAe;sBAC/C,cAAA,KAACC,SAAS;gBAACK,KAAK,EAAED,iBAAiB,CAACC,KAAK;gBAAEC,MAAM,EAAEF,iBAAiB,CAACE,MAAM;gBAAEE,IAAI,EAAEC,YAAY;gBAAEN,IAAI,EAAEA,IAAI;cAAI;UAC3F,CACvB,CAAC;IACJ,CAAC,AAAC;IAEF,MAAMM,YAAY,GAAkB;QAClCC,eAAe,EAAE,gBAAgB;QACjCC,IAAI,EAAE,oBAAoB;QAC1BC,UAAU,EAAE;YACVD,IAAI,EAAE,iEAAiE;YACvEE,MAAM,EAAE;gBACN;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;gBAClC;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;gBAClC;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;gBAClC;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;gBAClC;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;aACnC;SACF;KACF,AAAC;IAEFC,EAAE,CAAC,uCAAuC,EAAE,IAAM;QAChD,MAAMX,IAAI,GAAgB;YACxBY,IAAI,EAAE,SAAS;YACfC,cAAc,EAAE,CAAC;SAClB,AAAC;QACFd,WAAW,CAACC,IAAI,CAAC,CAAC;QAClBc,MAAM,CAACpB,MAAM,CAACqB,SAAS,CAAC,MAAM,CAAC,CAAC,CAACC,iBAAiB,EAAE,CAAC;IACvD,CAAC,CAAC,CAAC;IAEHL,EAAE,CAAC,sCAAsC,EAAE,IAAM;QAC/C,MAAMX,IAAI,GAAgB;YACxBY,IAAI,EAAE,SAAS;SAChB,AAAC;QACFb,WAAW,CAACC,IAAI,CAAC,CAAC;QAClBc,MAAM,CAACpB,MAAM,CAACqB,SAAS,CAAC,cAAc,CAAC,CAAC,CAACC,iBAAiB,EAAE,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEHL,EAAE,CAAC,sCAAsC,EAAE,IAAM;QAC/C,MAAMX,IAAI,GAAgB;YACxBY,IAAI,EAAE,QAAQ;SACf,AAAC;QACFb,WAAW,CAACC,IAAI,CAAC,CAAC;QAClBc,MAAM,CAACpB,MAAM,CAACqB,SAAS,CAAC,aAAa,CAAC,CAAC,CAACC,iBAAiB,EAAE,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -140,12 +140,6 @@ describe('UnitSelector', ()=>{
|
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
142
|
describe('with a time unit selected', ()=>{
|
|
143
|
-
it('does not allow the user to modify the decimal places', ()=>{
|
|
144
|
-
renderUnitSelector({
|
|
145
|
-
kind: 'Hours'
|
|
146
|
-
});
|
|
147
|
-
expect(getDecimalSelector()).toBeDisabled();
|
|
148
|
-
});
|
|
149
143
|
it('does not allow the user to set abbreviate', ()=>{
|
|
150
144
|
renderUnitSelector({
|
|
151
145
|
kind: 'Minutes'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/UnitSelector/UnitSelector.test.tsx"],"sourcesContent":["// Copyright 2022 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 { render, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { UnitOptions } from '../model';\nimport { UnitSelector } from './UnitSelector';\n\ndescribe('UnitSelector', () => {\n const renderUnitSelector = (value: UnitOptions, onChange = jest.fn()) => {\n render(\n <div>\n <UnitSelector value={value} onChange={onChange} />\n </div>\n );\n };\n\n const getUnitSelector = () => {\n return screen.getByRole('combobox', { name: 'Units' });\n };\n\n const getDecimalSelector = () => {\n return screen.getByRole('combobox', { name: 'Decimal' });\n };\n\n const getAbbreviateSwitch = () => {\n return screen.getByRole('checkbox', { name: 'Abbreviate' });\n };\n\n it('can change the unit kind by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Minutes' }, onChange);\n\n const unitSelector = getUnitSelector();\n userEvent.click(unitSelector);\n const decimalOption = screen.getByRole('option', {\n name: 'Decimal',\n });\n userEvent.click(decimalOption);\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n });\n });\n\n it('can change the unit kind using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Bytes' }, onChange);\n\n const unitSelector = getUnitSelector();\n // Note that this tab order can change depending on the type because the\n // abbreviate comes first and is disabled in some cases.\n userEvent.tab();\n expect(unitSelector).toHaveFocus();\n\n userEvent.clear(unitSelector);\n userEvent.keyboard('years');\n screen.getByRole('option', {\n name: 'Years',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Years',\n });\n });\n\n it('can change the decimal places by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 0, abbreviate: true }, onChange);\n\n userEvent.click(getDecimalSelector());\n const decimalOption = screen.getByRole('option', {\n name: '1',\n });\n userEvent.click(decimalOption);\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 1,\n abbreviate: true,\n });\n });\n\n it('can change the decimal places using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Percent' }, onChange);\n\n const decimalSelector = getDecimalSelector();\n userEvent.tab();\n userEvent.tab();\n expect(decimalSelector).toHaveFocus();\n\n userEvent.clear(decimalSelector);\n userEvent.keyboard('3');\n screen.getByRole('option', {\n name: '3',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Percent',\n decimal_places: 3,\n });\n });\n\n it('can change abbreviate by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 3, abbreviate: true }, onChange);\n\n userEvent.click(getAbbreviateSwitch());\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 3,\n abbreviate: false,\n });\n });\n\n it('can change abbreviate using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 0 }, onChange);\n\n userEvent.tab();\n userEvent.keyboard('{space}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 0,\n abbreviate: true,\n });\n });\n\n describe('with a time unit selected', () => {\n it('does not allow the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Hours' });\n expect(getDecimalSelector()).toBeDisabled();\n });\n\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Minutes' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n describe('with a percent unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Percent' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'PercentDecimal' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n describe('with a decimal unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Decimal' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('allows the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Decimal' });\n expect(getAbbreviateSwitch()).toBeEnabled();\n });\n });\n\n describe('with a bytes unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Bytes' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Bytes' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n it('should not show an option for disabled units', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal' }, onChange);\n\n userEvent.click(getUnitSelector());\n const percentShorthandOption = screen.queryByRole('option', {\n name: '%',\n });\n expect(percentShorthandOption).not.toBeInTheDocument();\n });\n});\n"],"names":["render","screen","userEvent","UnitSelector","describe","renderUnitSelector","value","onChange","jest","fn","div","getUnitSelector","getByRole","name","getDecimalSelector","getAbbreviateSwitch","it","kind","unitSelector","click","decimalOption","expect","toHaveBeenCalledWith","tab","toHaveFocus","clear","keyboard","decimal_places","abbreviate","decimalSelector","toBeDisabled","toBeEnabled","percentShorthandOption","queryByRole","not","toBeInTheDocument"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAi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AAC;YACtCI,MAAM,CAACN,mBAAmB,EAAE,CAAC,CAACe,YAAY,EAAE,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEHd,EAAE,CAAC,8CAA8C,EAAE,IAAM;QACvD,MAAMT,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,AAAC;QAC3BJ,kBAAkB,CAAC;YAAEY,IAAI,EAAE,SAAS;SAAE,EAAEV,QAAQ,CAAC,CAAC;QAElDL,SAAS,CAACiB,KAAK,CAACR,eAAe,EAAE,CAAC,CAAC;QACnC,MAAMqB,sBAAsB,GAAG/B,MAAM,CAACgC,WAAW,CAAC,QAAQ,EAAE;YAC1DpB,IAAI,EAAE,GAAG;SACV,CAAC,AAAC;QACHQ,MAAM,CAACW,sBAAsB,CAAC,CAACE,GAAG,CAACC,iBAAiB,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/UnitSelector/UnitSelector.test.tsx"],"sourcesContent":["// Copyright 2022 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 { render, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { UnitOptions } from '../model';\nimport { UnitSelector } from './UnitSelector';\n\ndescribe('UnitSelector', () => {\n const renderUnitSelector = (value: UnitOptions, onChange = jest.fn()) => {\n render(\n <div>\n <UnitSelector value={value} onChange={onChange} />\n </div>\n );\n };\n\n const getUnitSelector = () => {\n return screen.getByRole('combobox', { name: 'Units' });\n };\n\n const getDecimalSelector = () => {\n return screen.getByRole('combobox', { name: 'Decimal' });\n };\n\n const getAbbreviateSwitch = () => {\n return screen.getByRole('checkbox', { name: 'Abbreviate' });\n };\n\n it('can change the unit kind by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Minutes' }, onChange);\n\n const unitSelector = getUnitSelector();\n userEvent.click(unitSelector);\n const decimalOption = screen.getByRole('option', {\n name: 'Decimal',\n });\n userEvent.click(decimalOption);\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n });\n });\n\n it('can change the unit kind using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Bytes' }, onChange);\n\n const unitSelector = getUnitSelector();\n // Note that this tab order can change depending on the type because the\n // abbreviate comes first and is disabled in some cases.\n userEvent.tab();\n expect(unitSelector).toHaveFocus();\n\n userEvent.clear(unitSelector);\n userEvent.keyboard('years');\n screen.getByRole('option', {\n name: 'Years',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Years',\n });\n });\n\n it('can change the decimal places by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 0, abbreviate: true }, onChange);\n\n userEvent.click(getDecimalSelector());\n const decimalOption = screen.getByRole('option', {\n name: '1',\n });\n userEvent.click(decimalOption);\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 1,\n abbreviate: true,\n });\n });\n\n it('can change the decimal places using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Percent' }, onChange);\n\n const decimalSelector = getDecimalSelector();\n userEvent.tab();\n userEvent.tab();\n expect(decimalSelector).toHaveFocus();\n\n userEvent.clear(decimalSelector);\n userEvent.keyboard('3');\n screen.getByRole('option', {\n name: '3',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Percent',\n decimal_places: 3,\n });\n });\n\n it('can change abbreviate by clicking', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 3, abbreviate: true }, onChange);\n\n userEvent.click(getAbbreviateSwitch());\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 3,\n abbreviate: false,\n });\n });\n\n it('can change abbreviate using a keyboard', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal', decimal_places: 0 }, onChange);\n\n userEvent.tab();\n userEvent.keyboard('{space}');\n\n expect(onChange).toHaveBeenCalledWith({\n kind: 'Decimal',\n decimal_places: 0,\n abbreviate: true,\n });\n });\n\n describe('with a time unit selected', () => {\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Minutes' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n describe('with a percent unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Percent' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'PercentDecimal' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n describe('with a decimal unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Decimal' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('allows the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Decimal' });\n expect(getAbbreviateSwitch()).toBeEnabled();\n });\n });\n\n describe('with a bytes unit selected', () => {\n it('allows the user to modify the decimal places', () => {\n renderUnitSelector({ kind: 'Bytes' });\n expect(getDecimalSelector()).toBeEnabled();\n });\n\n it('does not allow the user to set abbreviate', () => {\n renderUnitSelector({ kind: 'Bytes' });\n expect(getAbbreviateSwitch()).toBeDisabled();\n });\n });\n\n it('should not show an option for disabled units', () => {\n const onChange = jest.fn();\n renderUnitSelector({ kind: 'Decimal' }, onChange);\n\n userEvent.click(getUnitSelector());\n const percentShorthandOption = screen.queryByRole('option', {\n name: '%',\n });\n expect(percentShorthandOption).not.toBeInTheDocument();\n });\n});\n"],"names":["render","screen","userEvent","UnitSelector","describe","renderUnitSelector","value","onChange","jest","fn","div","getUnitSelector","getByRole","name","getDecimalSelector","getAbbreviateSwitch","it","kind","unitSelector","click","decimalOption","expect","toHaveBeenCalledWith","tab","toHaveFocus","clear","keyboard","decimal_places","abbreviate","decimalSelector","toBeDisabled","toBeEnabled","percentShorthandOption","queryByRole","not","toBeInTheDocument"],"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;AAAA,SAASA,MAAM,EAAEC,MAAM,QAAQ,wBAAwB,CAAC;AACxD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AAEpD,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAE9CC,QAAQ,CAAC,cAAc,EAAE,IAAM;IAC7B,MAAMC,kBAAkB,GAAG,CAACC,KAAkB,EAAEC,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,GAAK;QACvET,MAAM,eACJ,KAACU,KAAG;sBACF,cAAA,KAACP,YAAY;gBAACG,KAAK,EAAEA,KAAK;gBAAEC,QAAQ,EAAEA,QAAQ;cAAI;UAC9C,CACP,CAAC;IACJ,CAAC,AAAC;IAEF,MAAMI,eAAe,GAAG,IAAM;QAC5B,OAAOV,MAAM,CAACW,SAAS,CAAC,UAAU,EAAE;YAAEC,IAAI,EAAE,OAAO;SAAE,CAAC,CAAC;IACzD,CAAC,AAAC;IAEF,MAAMC,kBAAkB,GAAG,IAAM;QAC/B,OAAOb,MAAM,CAACW,SAAS,CAAC,UAAU,EAAE;YAAEC,IAAI,EAAE,SAAS;SAAE,CAAC,CAAC;IAC3D,CAAC,AAAC;IAEF,MAAME,mBAAmB,GAAG,IAAM;QAChC,OAAOd,MAAM,CAACW,SAAS,CAAC,UAAU,EAAE;YAA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Y,IAAI,EAAE,OAAO;aAAE,CAAC,CAAC;YACtCI,MAAM,CAACP,kBAAkB,EAAE,CAAC,CAACiB,WAAW,EAAE,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEHf,EAAE,CAAC,2CAA2C,EAAE,IAAM;YACpDX,kBAAkB,CAAC;gBAAEY,IAAI,EAAE,OAAO;aAAE,CAAC,CAAC;YACtCI,MAAM,CAACN,mBAAmB,EAAE,CAAC,CAACe,YAAY,EAAE,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEHd,EAAE,CAAC,8CAA8C,EAAE,IAAM;QACvD,MAAMT,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,AAAC;QAC3BJ,kBAAkB,CAAC;YAAEY,IAAI,EAAE,SAAS;SAAE,EAAEV,QAAQ,CAAC,CAAC;QAElDL,SAAS,CAACiB,KAAK,CAACR,eAAe,EAAE,CAAC,CAAC;QACnC,MAAMqB,sBAAsB,GAAG/B,MAAM,CAACgC,WAAW,CAAC,QAAQ,EAAE;YAC1DpB,IAAI,EAAE,GAAG;SACV,CAAC,AAAC;QACHQ,MAAM,CAACW,sBAAsB,CAAC,CAACE,GAAG,CAACC,iBAAiB,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -20,18 +20,16 @@ Object.defineProperty(exports, "LineChart", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _react = require("react");
|
|
23
|
-
const _core = require("@perses-dev/core");
|
|
24
23
|
const _material = require("@mui/material");
|
|
25
|
-
const
|
|
24
|
+
const _core = require("echarts/core");
|
|
26
25
|
const _charts = require("echarts/charts");
|
|
27
26
|
const _components = require("echarts/components");
|
|
28
27
|
const _renderers = require("echarts/renderers");
|
|
29
28
|
const _echart = require("../EChart");
|
|
30
|
-
const _graph = require("../model/graph");
|
|
31
29
|
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
32
30
|
const _tooltip = require("../Tooltip/Tooltip");
|
|
33
31
|
const _utils = require("./utils");
|
|
34
|
-
(0,
|
|
32
|
+
(0, _core.use)([
|
|
35
33
|
_charts.LineChart,
|
|
36
34
|
_components.GridComponent,
|
|
37
35
|
_components.DataZoomComponent,
|
|
@@ -113,10 +111,9 @@ function LineChart({ height , data , yAxis , unit , grid , legend , visualMap ,
|
|
|
113
111
|
setShowTooltip(false);
|
|
114
112
|
setPinTooltip(false);
|
|
115
113
|
};
|
|
116
|
-
const option = (0,
|
|
114
|
+
const option = (0, _react.useMemo)(()=>{
|
|
117
115
|
if (data.timeSeries === undefined) return {};
|
|
118
116
|
if (data.timeSeries === null || data.timeSeries.length === 0) return chartsTheme.noDataOption;
|
|
119
|
-
const showPointsOnHover = data.timeSeries.length < _graph.PROGRESSIVE_MODE_SERIES_LIMIT;
|
|
120
117
|
var _rangeMs;
|
|
121
118
|
const rangeMs = (_rangeMs = data.rangeMs) !== null && _rangeMs !== void 0 ? _rangeMs : (0, _utils.getDateRange)(data.xAxis);
|
|
122
119
|
const option = {
|
|
@@ -134,11 +131,12 @@ function LineChart({ height , data , yAxis , unit , grid , legend , visualMap ,
|
|
|
134
131
|
yAxis: (0, _utils.getYAxes)(yAxis, unit),
|
|
135
132
|
animation: false,
|
|
136
133
|
tooltip: {
|
|
137
|
-
show:
|
|
134
|
+
show: true,
|
|
138
135
|
trigger: 'axis',
|
|
139
136
|
showContent: false,
|
|
140
137
|
axisPointer: {
|
|
141
|
-
type: '
|
|
138
|
+
type: 'line',
|
|
139
|
+
z: 0
|
|
142
140
|
}
|
|
143
141
|
},
|
|
144
142
|
toolbox: {
|
|
@@ -15,24 +15,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
-
const _react =
|
|
19
|
-
const _react1 = require("@testing-library/react");
|
|
18
|
+
const _react = require("@testing-library/react");
|
|
20
19
|
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
21
20
|
const _testUtils = require("../test-utils");
|
|
22
21
|
const _statChart = require("./StatChart");
|
|
23
|
-
function _interopRequireDefault(obj) {
|
|
24
|
-
return obj && obj.__esModule ? obj : {
|
|
25
|
-
default: obj
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
22
|
describe('StatChart', ()=>{
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
const renderChart = (unit)=>{
|
|
24
|
+
const contentDimensions = {
|
|
25
|
+
width: 200,
|
|
26
|
+
height: 200
|
|
27
|
+
};
|
|
28
|
+
(0, _react.render)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_chartsThemeProvider.ChartsThemeProvider, {
|
|
29
|
+
chartsTheme: _testUtils.testChartsTheme,
|
|
30
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_statChart.StatChart, {
|
|
31
|
+
width: contentDimensions.width,
|
|
32
|
+
height: contentDimensions.height,
|
|
33
|
+
data: mockStatData,
|
|
34
|
+
unit: unit
|
|
35
|
+
})
|
|
36
|
+
}));
|
|
36
37
|
};
|
|
37
38
|
const mockStatData = {
|
|
38
39
|
calculatedValue: 7.72931659687181,
|
|
@@ -63,18 +64,26 @@ describe('StatChart', ()=>{
|
|
|
63
64
|
]
|
|
64
65
|
}
|
|
65
66
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
it('render default options (no sparkline)', ()=>{
|
|
68
|
+
const unit = {
|
|
69
|
+
kind: 'Decimal',
|
|
70
|
+
decimal_places: 2
|
|
71
|
+
};
|
|
72
|
+
renderChart(unit);
|
|
73
|
+
expect(_react.screen.getByText('7.73')).toBeInTheDocument();
|
|
74
|
+
});
|
|
75
|
+
it('show value with time unit formatting', ()=>{
|
|
76
|
+
const unit = {
|
|
77
|
+
kind: 'Seconds'
|
|
78
|
+
};
|
|
79
|
+
renderChart(unit);
|
|
80
|
+
expect(_react.screen.getByText('7.73 seconds')).toBeInTheDocument();
|
|
81
|
+
});
|
|
82
|
+
it('show value with time unit formatting', ()=>{
|
|
83
|
+
const unit = {
|
|
84
|
+
kind: 'Months'
|
|
85
|
+
};
|
|
86
|
+
renderChart(unit);
|
|
87
|
+
expect(_react.screen.getByText('7.73 months')).toBeInTheDocument();
|
|
79
88
|
});
|
|
80
89
|
});
|
|
@@ -149,12 +149,6 @@ describe('UnitSelector', ()=>{
|
|
|
149
149
|
});
|
|
150
150
|
});
|
|
151
151
|
describe('with a time unit selected', ()=>{
|
|
152
|
-
it('does not allow the user to modify the decimal places', ()=>{
|
|
153
|
-
renderUnitSelector({
|
|
154
|
-
kind: 'Hours'
|
|
155
|
-
});
|
|
156
|
-
expect(getDecimalSelector()).toBeDisabled();
|
|
157
|
-
});
|
|
158
152
|
it('does not allow the user to set abbreviate', ()=>{
|
|
159
153
|
renderUnitSelector({
|
|
160
154
|
kind: 'Minutes'
|
package/dist/cjs/model/graph.js
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "OPTIMIZED_MODE_SERIES_LIMIT", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()=>
|
|
19
|
+
get: ()=>OPTIMIZED_MODE_SERIES_LIMIT
|
|
20
20
|
});
|
|
21
|
-
const
|
|
21
|
+
const OPTIMIZED_MODE_SERIES_LIMIT = 1000;
|
|
@@ -21,11 +21,12 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
TimeIntlDuration: ()=>TimeIntlDuration,
|
|
24
25
|
TIME_GROUP_CONFIG: ()=>TIME_GROUP_CONFIG,
|
|
25
26
|
TIME_UNIT_CONFIG: ()=>TIME_UNIT_CONFIG,
|
|
26
27
|
formatTime: ()=>formatTime
|
|
27
28
|
});
|
|
28
|
-
const
|
|
29
|
+
const _constants = require("./constants");
|
|
29
30
|
const timeUnitKinds = [
|
|
30
31
|
'Milliseconds',
|
|
31
32
|
'Seconds',
|
|
@@ -38,7 +39,8 @@ const timeUnitKinds = [
|
|
|
38
39
|
];
|
|
39
40
|
const TIME_GROUP = 'Time';
|
|
40
41
|
const TIME_GROUP_CONFIG = {
|
|
41
|
-
label: 'Time'
|
|
42
|
+
label: 'Time',
|
|
43
|
+
decimal_places: true
|
|
42
44
|
};
|
|
43
45
|
const TIME_UNIT_CONFIG = {
|
|
44
46
|
Milliseconds: {
|
|
@@ -74,65 +76,27 @@ const TIME_UNIT_CONFIG = {
|
|
|
74
76
|
label: 'Years'
|
|
75
77
|
}
|
|
76
78
|
};
|
|
79
|
+
var TimeIntlDuration;
|
|
80
|
+
(function(TimeIntlDuration) {
|
|
81
|
+
TimeIntlDuration["Milliseconds"] = 'millisecond';
|
|
82
|
+
TimeIntlDuration["Seconds"] = 'second';
|
|
83
|
+
TimeIntlDuration["Minutes"] = 'minute';
|
|
84
|
+
TimeIntlDuration["Hours"] = 'hour';
|
|
85
|
+
TimeIntlDuration["Days"] = 'day';
|
|
86
|
+
TimeIntlDuration["Weeks"] = 'week';
|
|
87
|
+
TimeIntlDuration["Months"] = 'month';
|
|
88
|
+
TimeIntlDuration["Years"] = 'year';
|
|
89
|
+
})(TimeIntlDuration || (TimeIntlDuration = {}));
|
|
77
90
|
function formatTime(value, unitOptions) {
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
break;
|
|
90
|
-
case 'Hours':
|
|
91
|
-
duration.hours = value;
|
|
92
|
-
break;
|
|
93
|
-
case 'Days':
|
|
94
|
-
duration.days = value;
|
|
95
|
-
break;
|
|
96
|
-
case 'Weeks':
|
|
97
|
-
duration.weeks = value;
|
|
98
|
-
break;
|
|
99
|
-
case 'Months':
|
|
100
|
-
duration.months = value;
|
|
101
|
-
break;
|
|
102
|
-
case 'Years':
|
|
103
|
-
duration.years = value;
|
|
104
|
-
break;
|
|
105
|
-
default:
|
|
106
|
-
{
|
|
107
|
-
const exhaustive = unitOptions.kind;
|
|
108
|
-
throw new Error(`Unknown time unit type ${exhaustive}`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
// Find the largest whole time unit we can display the value in and use it
|
|
112
|
-
const ms = (0, _dateFns.milliseconds)(duration);
|
|
113
|
-
const seconds = ms / 1000;
|
|
114
|
-
if (seconds < 1) {
|
|
115
|
-
return `${ms.toFixed()} milliseconds`;
|
|
116
|
-
}
|
|
117
|
-
const minutes = seconds / 60;
|
|
118
|
-
if (minutes < 1) {
|
|
119
|
-
return `${seconds.toFixed()} seconds`;
|
|
120
|
-
}
|
|
121
|
-
const hours = minutes / 60;
|
|
122
|
-
if (hours < 1) {
|
|
123
|
-
return `${minutes.toFixed()} minutes`;
|
|
124
|
-
}
|
|
125
|
-
const days = hours / 24;
|
|
126
|
-
if (days < 1) {
|
|
127
|
-
return `${hours.toFixed()} hours`;
|
|
128
|
-
}
|
|
129
|
-
const weeks = days / 7;
|
|
130
|
-
if (weeks < 1) {
|
|
131
|
-
return `${days.toFixed()} days`;
|
|
132
|
-
}
|
|
133
|
-
const years = weeks / 52;
|
|
134
|
-
if (years < 1) {
|
|
135
|
-
return `${weeks.toFixed()} weeks`;
|
|
136
|
-
}
|
|
137
|
-
return `${years.toFixed()} years`;
|
|
91
|
+
var _decimal_places;
|
|
92
|
+
const decimals = (_decimal_places = unitOptions.decimal_places) !== null && _decimal_places !== void 0 ? _decimal_places : _constants.DEFAULT_DECIMAL_PLACES;
|
|
93
|
+
const timeUnit = TimeIntlDuration[unitOptions.kind];
|
|
94
|
+
const formatter = new Intl.NumberFormat('en', {
|
|
95
|
+
style: 'unit',
|
|
96
|
+
unit: timeUnit,
|
|
97
|
+
unitDisplay: 'long',
|
|
98
|
+
minimumFractionDigits: decimals,
|
|
99
|
+
maximumFractionDigits: decimals
|
|
100
|
+
});
|
|
101
|
+
return formatter.format(value);
|
|
138
102
|
}
|
package/dist/cjs/theme/theme.js
CHANGED
|
@@ -21,6 +21,15 @@ Object.defineProperty(exports, "getTheme", {
|
|
|
21
21
|
const _material = require("@mui/material");
|
|
22
22
|
const _paletteOptions = require("./palette/palette-options");
|
|
23
23
|
const _typography = require("./typography");
|
|
24
|
+
const getModalBackgroundStyle = ({ theme })=>{
|
|
25
|
+
const backgroundStyle = theme.palette.mode === 'light' ? {} : {
|
|
26
|
+
backgroundImage: 'unset',
|
|
27
|
+
backgroundColor: theme.palette.designSystem.grey[800]
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
...backgroundStyle
|
|
31
|
+
};
|
|
32
|
+
};
|
|
24
33
|
function getTheme(mode) {
|
|
25
34
|
const theme = (0, _material.createTheme)({
|
|
26
35
|
palette: (0, _paletteOptions.getPaletteOptions)(mode),
|
|
@@ -41,5 +50,15 @@ const components = {
|
|
|
41
50
|
defaultProps: {
|
|
42
51
|
size: 'small'
|
|
43
52
|
}
|
|
53
|
+
},
|
|
54
|
+
MuiDrawer: {
|
|
55
|
+
styleOverrides: {
|
|
56
|
+
paper: getModalBackgroundStyle
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
MuiDialog: {
|
|
60
|
+
styleOverrides: {
|
|
61
|
+
paper: getModalBackgroundStyle
|
|
62
|
+
}
|
|
44
63
|
}
|
|
45
64
|
};
|
package/dist/model/graph.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MouseEventHandler } from 'react';
|
|
2
2
|
import { LineSeriesOption } from 'echarts/charts';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const OPTIMIZED_MODE_SERIES_LIMIT = 1000;
|
|
4
4
|
export declare type UnixTimeMs = number;
|
|
5
5
|
export declare type GraphSeriesValueTuple = [timestamp: UnixTimeMs, value: number];
|
|
6
6
|
export interface GraphSeries {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/model/graph.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/model/graph.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD,oBAAY,UAAU,GAAG,MAAM,CAAC;AAEhC,oBAAY,qBAAqB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAE3E,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;CACzC;AAED,oBAAY,aAAa,GAAG,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC;AAEhD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAEvE,IAAI,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GAAG,aAAa,EAAE,CAAC;CACzD;AAED,oBAAY,iBAAiB,GAAG;IAC9B,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;CAC3C"}
|
package/dist/model/graph.js
CHANGED
|
@@ -10,6 +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
|
-
|
|
13
|
+
// adjust display when there are many time series to help with performance
|
|
14
|
+
export const OPTIMIZED_MODE_SERIES_LIMIT = 1000;
|
|
14
15
|
|
|
15
16
|
//# sourceMappingURL=graph.js.map
|
package/dist/model/graph.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/graph.ts"],"sourcesContent":["// Copyright 2022 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';\nimport { LineSeriesOption } from 'echarts/charts';\n\nexport const
|
|
1
|
+
{"version":3,"sources":["../../src/model/graph.ts"],"sourcesContent":["// Copyright 2022 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';\nimport { LineSeriesOption } from 'echarts/charts';\n\n// adjust display when there are many time series to help with performance\nexport const OPTIMIZED_MODE_SERIES_LIMIT = 1000;\n\nexport type UnixTimeMs = number;\n\nexport type GraphSeriesValueTuple = [timestamp: UnixTimeMs, value: number];\n\nexport interface GraphSeries {\n name: string;\n values: Iterable<GraphSeriesValueTuple>;\n}\n\nexport type EChartsValues = number | null | '-';\n\nexport interface EChartsTimeSeries extends Omit<LineSeriesOption, 'data'> {\n // TODO: support dataset and both category / time xAxis types\n data: Iterable<GraphSeriesValueTuple> | EChartsValues[];\n}\n\nexport type EChartsDataFormat = {\n timeSeries: EChartsTimeSeries[];\n xAxis: number[];\n legendItems?: LegendItem[];\n xAxisMax?: number | string;\n rangeMs?: number;\n};\n\n/**\n * Supported legend options\n */\nexport interface LegendOptions {\n position?: 'bottom' | 'right';\n}\n\nexport interface LegendItem {\n id: string;\n label: string;\n isSelected: boolean;\n color: string;\n onClick: MouseEventHandler<HTMLLIElement>;\n}\n"],"names":["OPTIMIZED_MODE_SERIES_LIMIT"],"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;AAKjC,0EAA0E;AAC1E,OAAO,MAAMA,2BAA2B,GAAG,IAAI,CAAC"}
|
|
@@ -3,9 +3,20 @@ declare const timeUnitKinds: readonly ["Milliseconds", "Seconds", "Minutes", "Ho
|
|
|
3
3
|
declare type TimeUnitKind = typeof timeUnitKinds[number];
|
|
4
4
|
export declare type TimeUnitOptions = {
|
|
5
5
|
kind: TimeUnitKind;
|
|
6
|
+
decimal_places?: number;
|
|
6
7
|
};
|
|
7
8
|
export declare const TIME_GROUP_CONFIG: UnitGroupConfig;
|
|
8
9
|
export declare const TIME_UNIT_CONFIG: Readonly<Record<TimeUnitKind, UnitConfig>>;
|
|
10
|
+
export declare enum TimeIntlDuration {
|
|
11
|
+
Milliseconds = "millisecond",
|
|
12
|
+
Seconds = "second",
|
|
13
|
+
Minutes = "minute",
|
|
14
|
+
Hours = "hour",
|
|
15
|
+
Days = "day",
|
|
16
|
+
Weeks = "week",
|
|
17
|
+
Months = "month",
|
|
18
|
+
Years = "year"
|
|
19
|
+
}
|
|
9
20
|
export declare function formatTime(value: number, unitOptions: TimeUnitOptions): string;
|
|
10
21
|
export {};
|
|
11
22
|
//# sourceMappingURL=time.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/model/units/time.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtD,QAAA,MAAM,aAAa,8FAA+F,CAAC;AACnH,aAAK,YAAY,GAAG,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;AACjD,oBAAY,eAAe,GAAG;IAC5B,IAAI,EAAE,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/model/units/time.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtD,QAAA,MAAM,aAAa,8FAA+F,CAAC;AACnH,aAAK,YAAY,GAAG,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;AACjD,oBAAY,eAAe,GAAG;IAC5B,IAAI,EAAE,YAAY,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAG/B,CAAC;AACF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAiCvE,CAAC;AAIF,oBAAY,gBAAgB;IAC1B,YAAY,gBAAgB;IAC5B,OAAO,WAAW;IAClB,OAAO,WAAW;IAClB,KAAK,SAAS;IACd,IAAI,QAAQ;IACZ,KAAK,SAAS;IACd,MAAM,UAAU;IAChB,KAAK,SAAS;CACf;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,GAAG,MAAM,CAW9E"}
|
package/dist/model/units/time.js
CHANGED
|
@@ -10,7 +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
|
-
import {
|
|
13
|
+
import { DEFAULT_DECIMAL_PLACES } from './constants';
|
|
14
14
|
const timeUnitKinds = [
|
|
15
15
|
'Milliseconds',
|
|
16
16
|
'Seconds',
|
|
@@ -23,7 +23,8 @@ const timeUnitKinds = [
|
|
|
23
23
|
];
|
|
24
24
|
const TIME_GROUP = 'Time';
|
|
25
25
|
export const TIME_GROUP_CONFIG = {
|
|
26
|
-
label: 'Time'
|
|
26
|
+
label: 'Time',
|
|
27
|
+
decimal_places: true
|
|
27
28
|
};
|
|
28
29
|
export const TIME_UNIT_CONFIG = {
|
|
29
30
|
Milliseconds: {
|
|
@@ -59,67 +60,29 @@ export const TIME_UNIT_CONFIG = {
|
|
|
59
60
|
label: 'Years'
|
|
60
61
|
}
|
|
61
62
|
};
|
|
63
|
+
export var TimeIntlDuration;
|
|
64
|
+
(function(TimeIntlDuration) {
|
|
65
|
+
TimeIntlDuration["Milliseconds"] = 'millisecond';
|
|
66
|
+
TimeIntlDuration["Seconds"] = 'second';
|
|
67
|
+
TimeIntlDuration["Minutes"] = 'minute';
|
|
68
|
+
TimeIntlDuration["Hours"] = 'hour';
|
|
69
|
+
TimeIntlDuration["Days"] = 'day';
|
|
70
|
+
TimeIntlDuration["Weeks"] = 'week';
|
|
71
|
+
TimeIntlDuration["Months"] = 'month';
|
|
72
|
+
TimeIntlDuration["Years"] = 'year';
|
|
73
|
+
})(TimeIntlDuration || (TimeIntlDuration = {}));
|
|
62
74
|
export function formatTime(value, unitOptions) {
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
break;
|
|
75
|
-
case 'Hours':
|
|
76
|
-
duration.hours = value;
|
|
77
|
-
break;
|
|
78
|
-
case 'Days':
|
|
79
|
-
duration.days = value;
|
|
80
|
-
break;
|
|
81
|
-
case 'Weeks':
|
|
82
|
-
duration.weeks = value;
|
|
83
|
-
break;
|
|
84
|
-
case 'Months':
|
|
85
|
-
duration.months = value;
|
|
86
|
-
break;
|
|
87
|
-
case 'Years':
|
|
88
|
-
duration.years = value;
|
|
89
|
-
break;
|
|
90
|
-
default:
|
|
91
|
-
{
|
|
92
|
-
const exhaustive = unitOptions.kind;
|
|
93
|
-
throw new Error(`Unknown time unit type ${exhaustive}`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
// Find the largest whole time unit we can display the value in and use it
|
|
97
|
-
const ms = milliseconds(duration);
|
|
98
|
-
const seconds = ms / 1000;
|
|
99
|
-
if (seconds < 1) {
|
|
100
|
-
return `${ms.toFixed()} milliseconds`;
|
|
101
|
-
}
|
|
102
|
-
const minutes = seconds / 60;
|
|
103
|
-
if (minutes < 1) {
|
|
104
|
-
return `${seconds.toFixed()} seconds`;
|
|
105
|
-
}
|
|
106
|
-
const hours = minutes / 60;
|
|
107
|
-
if (hours < 1) {
|
|
108
|
-
return `${minutes.toFixed()} minutes`;
|
|
109
|
-
}
|
|
110
|
-
const days = hours / 24;
|
|
111
|
-
if (days < 1) {
|
|
112
|
-
return `${hours.toFixed()} hours`;
|
|
113
|
-
}
|
|
114
|
-
const weeks = days / 7;
|
|
115
|
-
if (weeks < 1) {
|
|
116
|
-
return `${days.toFixed()} days`;
|
|
117
|
-
}
|
|
118
|
-
const years = weeks / 52;
|
|
119
|
-
if (years < 1) {
|
|
120
|
-
return `${weeks.toFixed()} weeks`;
|
|
121
|
-
}
|
|
122
|
-
return `${years.toFixed()} years`;
|
|
75
|
+
var _decimal_places;
|
|
76
|
+
const decimals = (_decimal_places = unitOptions.decimal_places) !== null && _decimal_places !== void 0 ? _decimal_places : DEFAULT_DECIMAL_PLACES;
|
|
77
|
+
const timeUnit = TimeIntlDuration[unitOptions.kind];
|
|
78
|
+
const formatter = new Intl.NumberFormat('en', {
|
|
79
|
+
style: 'unit',
|
|
80
|
+
unit: timeUnit,
|
|
81
|
+
unitDisplay: 'long',
|
|
82
|
+
minimumFractionDigits: decimals,
|
|
83
|
+
maximumFractionDigits: decimals
|
|
84
|
+
});
|
|
85
|
+
return formatter.format(value);
|
|
123
86
|
}
|
|
124
87
|
|
|
125
88
|
//# sourceMappingURL=time.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/model/units/time.ts"],"sourcesContent":["// Copyright 2022 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 {
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/time.ts"],"sourcesContent":["// Copyright 2022 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 { DEFAULT_DECIMAL_PLACES } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\n\nconst timeUnitKinds = ['Milliseconds', 'Seconds', 'Minutes', 'Hours', 'Days', 'Weeks', 'Months', 'Years'] as const;\ntype TimeUnitKind = typeof timeUnitKinds[number];\nexport type TimeUnitOptions = {\n kind: TimeUnitKind;\n decimal_places?: number;\n};\nconst TIME_GROUP = 'Time';\nexport const TIME_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Time',\n decimal_places: true,\n};\nexport const TIME_UNIT_CONFIG: Readonly<Record<TimeUnitKind, UnitConfig>> = {\n Milliseconds: {\n group: TIME_GROUP,\n label: 'Milliseconds',\n },\n Seconds: {\n group: TIME_GROUP,\n label: 'Seconds',\n },\n Minutes: {\n group: TIME_GROUP,\n label: 'Minutes',\n },\n Hours: {\n group: TIME_GROUP,\n label: 'Hours',\n },\n Days: {\n group: TIME_GROUP,\n label: 'Days',\n },\n Weeks: {\n group: TIME_GROUP,\n label: 'Weeks',\n },\n Months: {\n group: TIME_GROUP,\n label: 'Months',\n },\n Years: {\n group: TIME_GROUP,\n label: 'Years',\n },\n};\n\n// Mapping of time units to what Intl.NumberFormat formatter expects\n// https://v8.dev/features/intl-numberformat#units\nexport enum TimeIntlDuration {\n Milliseconds = 'millisecond',\n Seconds = 'second',\n Minutes = 'minute',\n Hours = 'hour',\n Days = 'day',\n Weeks = 'week',\n Months = 'month',\n Years = 'year',\n}\n\nexport function formatTime(value: number, unitOptions: TimeUnitOptions): string {\n const decimals = unitOptions.decimal_places ?? DEFAULT_DECIMAL_PLACES;\n const timeUnit: string = TimeIntlDuration[unitOptions.kind];\n const formatter = new Intl.NumberFormat('en', {\n style: 'unit',\n unit: timeUnit,\n unitDisplay: 'long',\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n });\n return formatter.format(value);\n}\n"],"names":["DEFAULT_DECIMAL_PLACES","timeUnitKinds","TIME_GROUP","TIME_GROUP_CONFIG","label","decimal_places","TIME_UNIT_CONFIG","Milliseconds","group","Seconds","Minutes","Hours","Days","Weeks","Months","Years","TimeIntlDuration","formatTime","value","unitOptions","decimals","timeUnit","kind","formatter","Intl","NumberFormat","style","unit","unitDisplay","minimumFractionDigits","maximumFractionDigits","format"],"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,sBAAsB,QAAQ,aAAa,CAAC;AAGrD,MAAMC,aAAa,GAAG;IAAC,cAAc;IAAE,SAAS;IAAE,SAAS;IAAE,OAAO;IAAE,MAAM;IAAE,OAAO;IAAE,QAAQ;IAAE,OAAO;CAAC,AAAS,AAAC;AAMnH,MAAMC,UAAU,GAAG,MAAM,AAAC;AAC1B,OAAO,MAAMC,iBAAiB,GAAoB;IAChDC,KAAK,EAAE,MAAM;IACbC,cAAc,EAAE,IAAI;CACrB,CAAC;AACF,OAAO,MAAMC,gBAAgB,GAA+C;IAC1EC,YAAY,EAAE;QACZC,KAAK,EAAEN,UAAU;QACjBE,KAAK,EAAE,cAAc;KACtB;IACDK,OAAO,EAAE;QACPD,KAAK,EAAEN,UAAU;QACjBE,KAAK,EAAE,SAAS;KACjB;IACDM,OAAO,EAAE;QACPF,KAAK,EAAEN,UAAU;QACjBE,KAAK,EAAE,SAAS;KACjB;IACDO,KAAK,EAAE;QACLH,KAAK,EAAEN,UAAU;QACjBE,KAAK,EAAE,OAAO;KACf;IACDQ,IAAI,EAAE;QACJJ,KAAK,EAAEN,UAAU;QACjB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me/theme.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PaletteMode } from '@mui/material';
|
|
1
|
+
import { PaletteMode, Theme } from '@mui/material';
|
|
2
2
|
/**
|
|
3
3
|
* Gets theme used by all components for the provided mode. For more details, see:
|
|
4
4
|
* - Base colors, typography, sizing - go/chrono-ui-theme
|
|
@@ -9,5 +9,5 @@ import { PaletteMode } from '@mui/material';
|
|
|
9
9
|
* Need to reinstantiate the theme everytime to support switching between light and dark themes
|
|
10
10
|
* https://github.com/mui-org/material-ui/issues/18831
|
|
11
11
|
*/
|
|
12
|
-
export declare function getTheme(mode: PaletteMode):
|
|
12
|
+
export declare function getTheme(mode: PaletteMode): Theme;
|
|
13
13
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,WAAW,EAAgB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,WAAW,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AAiB9E;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,SAQzC"}
|
package/dist/theme/theme.js
CHANGED
|
@@ -13,6 +13,15 @@
|
|
|
13
13
|
import { createTheme } from '@mui/material';
|
|
14
14
|
import { getPaletteOptions } from './palette/palette-options';
|
|
15
15
|
import { typography } from './typography';
|
|
16
|
+
const getModalBackgroundStyle = ({ theme })=>{
|
|
17
|
+
const backgroundStyle = theme.palette.mode === 'light' ? {} : {
|
|
18
|
+
backgroundImage: 'unset',
|
|
19
|
+
backgroundColor: theme.palette.designSystem.grey[800]
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
...backgroundStyle
|
|
23
|
+
};
|
|
24
|
+
};
|
|
16
25
|
/**
|
|
17
26
|
* Gets theme used by all components for the provided mode. For more details, see:
|
|
18
27
|
* - Base colors, typography, sizing - go/chrono-ui-theme
|
|
@@ -42,6 +51,16 @@ const components = {
|
|
|
42
51
|
defaultProps: {
|
|
43
52
|
size: 'small'
|
|
44
53
|
}
|
|
54
|
+
},
|
|
55
|
+
MuiDrawer: {
|
|
56
|
+
styleOverrides: {
|
|
57
|
+
paper: getModalBackgroundStyle
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
MuiDialog: {
|
|
61
|
+
styleOverrides: {
|
|
62
|
+
paper: getModalBackgroundStyle
|
|
63
|
+
}
|
|
45
64
|
}
|
|
46
65
|
};
|
|
47
66
|
|
package/dist/theme/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/theme/theme.ts"],"sourcesContent":["// Copyright 2022 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 { createTheme, PaletteMode, ThemeOptions } from '@mui/material';\nimport { getPaletteOptions } from './palette/palette-options';\nimport { typography } from './typography';\n\n/**\n * Gets theme used by all components for the provided mode. For more details, see:\n * - Base colors, typography, sizing - go/chrono-ui-theme\n * - Material UI defaults: https://material-ui.com/customization/default-theme/\n * - Material UI variables: https://material-ui.com/customization/theming/#theme-configuration-variables\n * - Material UI global overrides and default props: https://material-ui.com/customization/globals/#css\n *\n * Need to reinstantiate the theme everytime to support switching between light and dark themes\n * https://github.com/mui-org/material-ui/issues/18831\n */\nexport function getTheme(mode: PaletteMode) {\n const theme = createTheme({\n palette: getPaletteOptions(mode),\n typography,\n mixins: {},\n components,\n });\n return theme;\n}\n\n// Overrides for component default prop values and styles go here\nconst components: ThemeOptions['components'] = {\n MuiFormControl: {\n defaultProps: {\n size: 'small',\n },\n },\n MuiTextField: {\n defaultProps: {\n size: 'small',\n },\n },\n};\n"],"names":["createTheme","getPaletteOptions","typography","
|
|
1
|
+
{"version":3,"sources":["../../src/theme/theme.ts"],"sourcesContent":["// Copyright 2022 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 { createTheme, PaletteMode, ThemeOptions, Theme } from '@mui/material';\nimport { getPaletteOptions } from './palette/palette-options';\nimport { typography } from './typography';\n\nconst getModalBackgroundStyle = ({ theme }: { theme: Omit<Theme, 'components'> }) => {\n const backgroundStyle =\n theme.palette.mode === 'light'\n ? {}\n : {\n backgroundImage: 'unset',\n backgroundColor: theme.palette.designSystem.grey[800],\n };\n return {\n ...backgroundStyle,\n };\n};\n\n/**\n * Gets theme used by all components for the provided mode. For more details, see:\n * - Base colors, typography, sizing - go/chrono-ui-theme\n * - Material UI defaults: https://material-ui.com/customization/default-theme/\n * - Material UI variables: https://material-ui.com/customization/theming/#theme-configuration-variables\n * - Material UI global overrides and default props: https://material-ui.com/customization/globals/#css\n *\n * Need to reinstantiate the theme everytime to support switching between light and dark themes\n * https://github.com/mui-org/material-ui/issues/18831\n */\nexport function getTheme(mode: PaletteMode) {\n const theme = createTheme({\n palette: getPaletteOptions(mode),\n typography,\n mixins: {},\n components,\n });\n return theme;\n}\n\n// Overrides for component default prop values and styles go here\nconst components: ThemeOptions['components'] = {\n MuiFormControl: {\n defaultProps: {\n size: 'small',\n },\n },\n MuiTextField: {\n defaultProps: {\n size: 'small',\n },\n },\n MuiDrawer: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n MuiDialog: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n};\n"],"names":["createTheme","getPaletteOptions","typography","getModalBackgroundStyle","theme","backgroundStyle","palette","mode","backgroundImage","backgroundColor","designSystem","grey","getTheme","mixins","components","MuiFormControl","defaultProps","size","MuiTextField","MuiDrawer","styleOverrides","paper","MuiDialog"],"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,QAA0C,eAAe,CAAC;AAC9E,SAASC,iBAAiB,QAAQ,2BAA2B,CAAC;AAC9D,SAASC,UAAU,QAAQ,cAAc,CAAC;AAE1C,MAAMC,uBAAuB,GAAG,CAAC,EAAEC,KAAK,CAAA,EAAwC,GAAK;IACnF,MAAMC,eAAe,GACnBD,KAAK,CAACE,OAAO,CAACC,IAAI,KAAK,OAAO,GAC1B,EAAE,GACF;QACEC,eAAe,EAAE,OAAO;QACxBC,eAAe,EAAEL,KAAK,CAACE,OAAO,CAACI,YAAY,CAACC,IAAI,CAAC,GAAG,CAAC;KACtD,AAAC;IACR,OAAO;QACL,GAAGN,eAAe;KACnB,CAAC;AACJ,CAAC,AAAC;AAEF;;;;;;;;;CASC,GACD,OAAO,SAASO,QAAQ,CAACL,IAAiB,EAAE;IAC1C,MAAMH,KAAK,GAAGJ,WAAW,CAAC;QACxBM,OAAO,EAAEL,iBAAiB,CAACM,IAAI,CAAC;QAChCL,UAAU;QACVW,MAAM,EAAE,EAAE;QACVC,UAAU;KACX,CAAC,AAAC;IACH,OAAOV,KAAK,CAAC;AACf,CAAC;AAED,iEAAiE;AACjE,MAAMU,UAAU,GAA+B;IAC7CC,cAAc,EAAE;QACdC,YAAY,EAAE;YACZC,IAAI,EAAE,OAAO;SACd;KACF;IACDC,YAAY,EAAE;QACZF,YAAY,EAAE;YACZC,IAAI,EAAE,OAAO;SACd;KACF;IACDE,SAAS,EAAE;QACTC,cAAc,EAAE;YACdC,KAAK,EAAElB,uBAAuB;SAC/B;KACF;IACDmB,SAAS,EAAE;QACTF,cAAc,EAAE;YACdC,KAAK,EAAElB,uBAAuB;SAC/B;KACF;CACF,AAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
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",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@fontsource/lato": "^4.5.10",
|
|
36
36
|
"@mui/x-date-pickers": "^5.0.0-beta.1",
|
|
37
|
-
"@perses-dev/core": "^0.
|
|
37
|
+
"@perses-dev/core": "^0.20.0",
|
|
38
38
|
"date-fns": "^2.28.0",
|
|
39
39
|
"echarts": "^5.3.3",
|
|
40
40
|
"lodash-es": "^4.17.21",
|