@perses-dev/components 0.51.0-beta.0 → 0.51.0-beta.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/BarChart/BarChart.js.map +1 -1
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/DragAndDrop/DropIndicator.js.map +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.d.ts.map +1 -1
- package/dist/EChart/EChart.js +16 -1
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/GaugeChart/GaugeChart.js.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
- package/dist/JSONEditor.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/StatChart/calculateFontSize.js.map +1 -1
- package/dist/StatusHistoryChart/utils/get-color.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 +2 -1
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableCell.d.ts +2 -1
- package/dist/Table/TableCell.d.ts.map +1 -1
- package/dist/Table/TableCell.js +4 -2
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/VirtualizedTable.d.ts +2 -2
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +3 -1
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +8 -1
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +4 -2
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeChart/TimeChart.js +4 -4
- package/dist/TimeChart/TimeChart.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeRangeSelector/utils.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/cjs/EChart/EChart.js +15 -0
- package/dist/cjs/Table/Table.js +2 -1
- package/dist/cjs/Table/TableCell.js +4 -2
- package/dist/cjs/Table/VirtualizedTable.js +3 -1
- package/dist/cjs/Table/model/table-model.js +7 -2
- package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +9 -9
- package/dist/cjs/TimeChart/TimeChart.js +3 -3
- package/dist/cjs/TimeRangeSelector/DateTimeRangePicker.js +2 -2
- package/dist/context/SnackbarProvider.js.map +1 -1
- package/dist/model/timeOption.js.map +1 -1
- package/dist/theme/component-overrides/alert.js.map +1 -1
- package/dist/utils/component-ids.js.map +1 -1
- package/package.json +5 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/BarChart/BarChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useMemo } from 'react';\nimport { FormatOptions, formatValue } from '@perses-dev/core';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { BarChart as EChartsBarChart } from 'echarts/charts';\nimport { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { Box } from '@mui/material';\nimport { useChartsTheme } from '../context';\nimport { EChart } from '../EChart';\nimport { ModeOption } from '../ModeSelector';\nimport { getFormattedAxis } from '../utils';\n\nuse([EChartsBarChart, GridComponent, DatasetComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst BAR_WIN_WIDTH = 14;\nconst BAR_GAP = 6;\n\nexport interface BarChartData {\n label: string;\n value: number | null;\n}\n\nexport interface BarChartProps {\n width: number;\n height: number;\n data: BarChartData[] | null;\n format?: FormatOptions;\n mode?: ModeOption;\n}\n\nexport function BarChart(props: BarChartProps): ReactElement {\n const { width, height, data, format = { unit: 'decimal' }, mode = 'value' } = props;\n const chartsTheme = useChartsTheme();\n\n const option: EChartsCoreOption = useMemo(() => {\n if (!data || !data.length) return chartsTheme.noDataOption;\n\n const source: Array<Array<BarChartData['label'] | BarChartData['value']>> = [];\n data.map((d) => {\n source.push([d.label, d.value]);\n });\n\n return {\n title: {\n show: false,\n },\n dataset: [\n {\n dimensions: ['label', 'value'],\n source: source,\n },\n ],\n xAxis: getFormattedAxis({}, format),\n yAxis: {\n type: 'category',\n splitLine: {\n show: false,\n },\n axisLabel: {\n overflow: 'truncate',\n width: width / 3,\n },\n },\n series: {\n type: 'bar',\n label: {\n show: true,\n position: 'right',\n formatter: (params: { data: number[] }): string | undefined => {\n if (!params.data[1]) {\n return undefined;\n }\n\n if (mode === 'percentage') {\n return formatValue(params.data[1]!, {\n unit: 'percent',\n decimalPlaces: format.decimalPlaces,\n });\n }\n return formatValue(params.data[1], format);\n },\n barMinWidth: BAR_WIN_WIDTH,\n barCategoryGap: BAR_GAP,\n },\n itemStyle: {\n borderRadius: 4,\n color: chartsTheme.echartsTheme[0],\n },\n },\n tooltip: {\n appendToBody: true,\n confine: true,\n formatter: (params: { name: string; data: number[] }) =>\n params.data[1] && `<b>${params.name}</b>   ${formatValue(params.data[1], format)}`,\n },\n // increase distance between grid and container to prevent y axis labels from getting cut off\n grid: {\n left: '5%',\n right: '5%',\n },\n };\n }, [data, chartsTheme, width, mode, format]);\n\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{ overflow: 'auto' }}\n >\n <EChart\n sx={{\n minHeight: height,\n height: data ? data.length * (BAR_WIN_WIDTH + BAR_GAP) : '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n </Box>\n );\n}\n"],"names":["useMemo","formatValue","use","BarChart","EChartsBarChart","GridComponent","DatasetComponent","TitleComponent","TooltipComponent","CanvasRenderer","Box","useChartsTheme","EChart","getFormattedAxis","BAR_WIN_WIDTH","BAR_GAP","props","width","height","data","format","unit","mode","chartsTheme","option","length","noDataOption","source","map","d","push","label","value","title","show","dataset","dimensions","xAxis","yAxis","type","splitLine","axisLabel","overflow","series","position","formatter","params","undefined","decimalPlaces","barMinWidth","barCategoryGap","itemStyle","borderRadius","color","echartsTheme","tooltip","appendToBody","confine","name","grid","left","right","style","sx","minHeight","theme"],"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,SAAuBA,OAAO,QAAQ,QAAQ;AAC9C,SAAwBC,WAAW,QAAQ,mBAAmB;AAC9D,SAASC,GAAG,QAA2B,eAAe;AACtD,SAASC,YAAYC,eAAe,QAAQ,iBAAiB;AAC7D,SAASC,aAAa,EAAEC,gBAAgB,EAAEC,cAAc,EAAEC,gBAAgB,QAA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AAG;gCAClCE,MAAM;gCACN2B,eAAe5B,OAAO4B,aAAa;4BACrC;wBACF;wBACA,OAAO/C,YAAY6C,OAAO3B,IAAI,CAAC,EAAE,EAAEC;oBACrC;oBACA6B,aAAanC;oBACboC,gBAAgBnC;gBAClB;gBACAoC,WAAW;oBACTC,cAAc;oBACdC,OAAO9B,YAAY+B,YAAY,CAAC,EAAE;gBACpC;YACF;YACAC,SAAS;gBACPC,cAAc;gBACdC,SAAS;gBACTZ,WAAW,CAACC,SACVA,OAAO3B,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE2B,OAAOY,IAAI,CAAC,YAAY,EAAEzD,YAAY6C,OAAO3B,IAAI,CAAC,EAAE,EAAEC,
|
|
1
|
+
{"version":3,"sources":["../../src/BarChart/BarChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useMemo } from 'react';\nimport { FormatOptions, formatValue } from '@perses-dev/core';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { BarChart as EChartsBarChart } from 'echarts/charts';\nimport { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { Box } from '@mui/material';\nimport { useChartsTheme } from '../context';\nimport { EChart } from '../EChart';\nimport { ModeOption } from '../ModeSelector';\nimport { getFormattedAxis } from '../utils';\n\nuse([EChartsBarChart, GridComponent, DatasetComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst BAR_WIN_WIDTH = 14;\nconst BAR_GAP = 6;\n\nexport interface BarChartData {\n label: string;\n value: number | null;\n}\n\nexport interface BarChartProps {\n width: number;\n height: number;\n data: BarChartData[] | null;\n format?: FormatOptions;\n mode?: ModeOption;\n}\n\nexport function BarChart(props: BarChartProps): ReactElement {\n const { width, height, data, format = { unit: 'decimal' }, mode = 'value' } = props;\n const chartsTheme = useChartsTheme();\n\n const option: EChartsCoreOption = useMemo(() => {\n if (!data || !data.length) return chartsTheme.noDataOption;\n\n const source: Array<Array<BarChartData['label'] | BarChartData['value']>> = [];\n data.map((d) => {\n source.push([d.label, d.value]);\n });\n\n return {\n title: {\n show: false,\n },\n dataset: [\n {\n dimensions: ['label', 'value'],\n source: source,\n },\n ],\n xAxis: getFormattedAxis({}, format),\n yAxis: {\n type: 'category',\n splitLine: {\n show: false,\n },\n axisLabel: {\n overflow: 'truncate',\n width: width / 3,\n },\n },\n series: {\n type: 'bar',\n label: {\n show: true,\n position: 'right',\n formatter: (params: { data: number[] }): string | undefined => {\n if (!params.data[1]) {\n return undefined;\n }\n\n if (mode === 'percentage') {\n return formatValue(params.data[1]!, {\n unit: 'percent',\n decimalPlaces: format.decimalPlaces,\n });\n }\n return formatValue(params.data[1], format);\n },\n barMinWidth: BAR_WIN_WIDTH,\n barCategoryGap: BAR_GAP,\n },\n itemStyle: {\n borderRadius: 4,\n color: chartsTheme.echartsTheme[0],\n },\n },\n tooltip: {\n appendToBody: true,\n confine: true,\n formatter: (params: { name: string; data: number[] }) =>\n params.data[1] && `<b>${params.name}</b>   ${formatValue(params.data[1], format)}`,\n },\n // increase distance between grid and container to prevent y axis labels from getting cut off\n grid: {\n left: '5%',\n right: '5%',\n },\n };\n }, [data, chartsTheme, width, mode, format]);\n\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{ overflow: 'auto' }}\n >\n <EChart\n sx={{\n minHeight: height,\n height: data ? data.length * (BAR_WIN_WIDTH + BAR_GAP) : '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n </Box>\n );\n}\n"],"names":["useMemo","formatValue","use","BarChart","EChartsBarChart","GridComponent","DatasetComponent","TitleComponent","TooltipComponent","CanvasRenderer","Box","useChartsTheme","EChart","getFormattedAxis","BAR_WIN_WIDTH","BAR_GAP","props","width","height","data","format","unit","mode","chartsTheme","option","length","noDataOption","source","map","d","push","label","value","title","show","dataset","dimensions","xAxis","yAxis","type","splitLine","axisLabel","overflow","series","position","formatter","params","undefined","decimalPlaces","barMinWidth","barCategoryGap","itemStyle","borderRadius","color","echartsTheme","tooltip","appendToBody","confine","name","grid","left","right","style","sx","minHeight","theme"],"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,SAAuBA,OAAO,QAAQ,QAAQ;AAC9C,SAAwBC,WAAW,QAAQ,mBAAmB;AAC9D,SAASC,GAAG,QAA2B,eAAe;AACtD,SAASC,YAAYC,eAAe,QAAQ,iBAAiB;AAC7D,SAASC,aAAa,EAAEC,gBAAgB,EAAEC,cAAc,EAAEC,gBAAgB,QAAQ,qBAAqB;AACvG,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,GAAG,QAAQ,gBAAgB;AACpC,SAASC,cAAc,QAAQ,aAAa;AAC5C,SAASC,MAAM,QAAQ,YAAY;AAEnC,SAASC,gBAAgB,QAAQ,WAAW;AAE5CX,IAAI;IAACE;IAAiBC;IAAeC;IAAkBC;IAAgBC;IAAkBC;CAAe;AAExG,MAAMK,gBAAgB;AACtB,MAAMC,UAAU;AAehB,OAAO,SAASZ,SAASa,KAAoB;IAC3C,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS;QAAEC,MAAM;IAAU,CAAC,EAAEC,OAAO,OAAO,EAAE,GAAGN;IAC9E,MAAMO,cAAcZ;IAEpB,MAAMa,SAA4BxB,QAAQ;QACxC,IAA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OAAO;YACT;QACF;IACF,GAAG;QAAC1C;QAAMI;QAAaN;QAAOK;QAAMF;KAAO;IAE3C,qBACE,KAACV;QACCoD,OAAO;YACL7C,OAAOA;YACPC,QAAQA;QACV;QACA6C,IAAI;YAAErB,UAAU;QAAO;kBAEvB,cAAA,KAAC9B;YACCmD,IAAI;gBACFC,WAAW9C;gBACXA,QAAQC,OAAOA,KAAKM,MAAM,GAAIX,CAAAA,gBAAgBC,OAAM,IAAK;YAC3D;YACAS,QAAQA;YACRyC,OAAO1C,YAAY+B,YAAY;;;AAIvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ColorPicker/ColorPicker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { IconButton, Stack, TextField } from '@mui/material';\nimport { ChangeEvent, ReactElement, useState } from 'react';\nimport { HexColorPicker } from 'react-colorful';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport DeleteIcon from 'mdi-material-ui/Delete';\n\ninterface ColorPickerProps {\n color: string;\n onChange?: (color: string) => void;\n onClear?: () => void;\n /**\n * Preset color palette\n */\n palette?: string[];\n}\n\nexport const ColorPicker = ({ color, onChange, onClear, palette }: ColorPickerProps): ReactElement => {\n // value is the visible value for the controlled text input\n const [value, setValue] = useState(color);\n\n const handleColorChange = (color: string): void => {\n setValue(color);\n onChange?.(color);\n };\n\n // we should update this if https://github.com/omgovich/react-colorful/issues/157 is resolved\n const handleInputChange = (e: ChangeEvent<HTMLInputElement>): void => {\n const inputValue = e.target.value.replace(/([^0-9A-F]+)/gi, '').substring(0, 8);\n setValue(`#${inputValue}`); // always prefix input value with # to indicate hex format\n // only set color if input value is a valid hex color\n if (isValidHex(e.target.value)) {\n onChange?.(e.target.value);\n }\n };\n\n return (\n <Stack spacing={1}>\n <HexColorPicker color={color} onChange={handleColorChange} style={{ width: '100%' }} />\n <Stack direction=\"row\" flexWrap=\"wrap\" justifyContent=\"space-evenly\" width=\"200px\">\n {palette &&\n palette.map((color, i) => (\n <IconButton\n key={i}\n size=\"small\"\n aria-label={`change color to ${color}`}\n sx={{ color }}\n onClick={() => handleColorChange(color)}\n >\n <CircleIcon />\n </IconButton>\n ))}\n </Stack>\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <TextField\n inputProps={{ 'aria-label': 'enter hex color' }}\n fullWidth\n value={value}\n onChange={handleInputChange}\n />\n {onClear && (\n <IconButton onClick={onClear}>\n <DeleteIcon />\n </IconButton>\n )}\n </Stack>\n </Stack>\n );\n};\n\nconst isValidHex = (value: string, alpha?: boolean): boolean => {\n const matcher = /^#?([0-9A-F]{3,8})$/i;\n const match = matcher.exec(value);\n const length = match && match[1] ? match[1].length : 0;\n return (\n length === 3 || // '#rgb' format\n length === 6 || // '#rrggbb' format\n (!!alpha && length === 4) || // '#rgba' format\n (!!alpha && length === 8) // '#rrggbbaa' format\n );\n};\n"],"names":["IconButton","Stack","TextField","useState","HexColorPicker","CircleIcon","DeleteIcon","ColorPicker","color","onChange","onClear","palette","value","setValue","handleColorChange","handleInputChange","e","inputValue","target","replace","substring","isValidHex","spacing","style","width","direction","flexWrap","justifyContent","map","i","size","aria-label","sx","onClick","gap","alignItems","inputProps","fullWidth","alpha","matcher","match","exec","length"],"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,UAAU,EAAEC,KAAK,EAAEC,SAAS,QAAQ,gBAAgB;AAC7D,SAAoCC,QAAQ,QAAQ,QAAQ;AAC5D,SAASC,cAAc,QAAQ,iBAAiB;AAChD,OAAOC,gBAAgB,yBAAyB;AAChD,OAAOC,gBAAgB,yBAAyB;AAYhD,OAAO,MAAMC,cAAc,CAAC,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,EAAoB;IACjF,2DAA2D;IAC3D,MAAM,CAACC,OAAOC,SAAS,GAAGV,SAASK;IAEnC,MAAMM,oBAAoB,CAACN;QACzBK,SAASL;QACTC,WAAWD;IACb;IAEA,6FAA6F;IAC7F,MAAMO,oBAAoB,CAACC;QACzB,MAAMC,aAAaD,EAAEE,MAAM,CAACN,KAAK,CAACO,OAAO,CAAC,kBAAkB,IAAIC,SAAS,CAAC,GAAG;QAC7EP,SAAS,CAAC,CAAC,EAAEI,
|
|
1
|
+
{"version":3,"sources":["../../src/ColorPicker/ColorPicker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { IconButton, Stack, TextField } from '@mui/material';\nimport { ChangeEvent, ReactElement, useState } from 'react';\nimport { HexColorPicker } from 'react-colorful';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport DeleteIcon from 'mdi-material-ui/Delete';\n\ninterface ColorPickerProps {\n color: string;\n onChange?: (color: string) => void;\n onClear?: () => void;\n /**\n * Preset color palette\n */\n palette?: string[];\n}\n\nexport const ColorPicker = ({ color, onChange, onClear, palette }: ColorPickerProps): ReactElement => {\n // value is the visible value for the controlled text input\n const [value, setValue] = useState(color);\n\n const handleColorChange = (color: string): void => {\n setValue(color);\n onChange?.(color);\n };\n\n // we should update this if https://github.com/omgovich/react-colorful/issues/157 is resolved\n const handleInputChange = (e: ChangeEvent<HTMLInputElement>): void => {\n const inputValue = e.target.value.replace(/([^0-9A-F]+)/gi, '').substring(0, 8);\n setValue(`#${inputValue}`); // always prefix input value with # to indicate hex format\n // only set color if input value is a valid hex color\n if (isValidHex(e.target.value)) {\n onChange?.(e.target.value);\n }\n };\n\n return (\n <Stack spacing={1}>\n <HexColorPicker color={color} onChange={handleColorChange} style={{ width: '100%' }} />\n <Stack direction=\"row\" flexWrap=\"wrap\" justifyContent=\"space-evenly\" width=\"200px\">\n {palette &&\n palette.map((color, i) => (\n <IconButton\n key={i}\n size=\"small\"\n aria-label={`change color to ${color}`}\n sx={{ color }}\n onClick={() => handleColorChange(color)}\n >\n <CircleIcon />\n </IconButton>\n ))}\n </Stack>\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <TextField\n inputProps={{ 'aria-label': 'enter hex color' }}\n fullWidth\n value={value}\n onChange={handleInputChange}\n />\n {onClear && (\n <IconButton onClick={onClear}>\n <DeleteIcon />\n </IconButton>\n )}\n </Stack>\n </Stack>\n );\n};\n\nconst isValidHex = (value: string, alpha?: boolean): boolean => {\n const matcher = /^#?([0-9A-F]{3,8})$/i;\n const match = matcher.exec(value);\n const length = match && match[1] ? match[1].length : 0;\n return (\n length === 3 || // '#rgb' format\n length === 6 || // '#rrggbb' format\n (!!alpha && length === 4) || // '#rgba' format\n (!!alpha && length === 8) // '#rrggbbaa' format\n );\n};\n"],"names":["IconButton","Stack","TextField","useState","HexColorPicker","CircleIcon","DeleteIcon","ColorPicker","color","onChange","onClear","palette","value","setValue","handleColorChange","handleInputChange","e","inputValue","target","replace","substring","isValidHex","spacing","style","width","direction","flexWrap","justifyContent","map","i","size","aria-label","sx","onClick","gap","alignItems","inputProps","fullWidth","alpha","matcher","match","exec","length"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE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kBN;kCAEjC,cAAA,KAACH;uBANIwB;;0BAUb,MAAC5B;gBAAMwB,WAAU;gBAAMS,KAAK;gBAAGC,YAAW;;kCACxC,KAACjC;wBACCkC,YAAY;4BAAE,cAAc;wBAAkB;wBAC9CC,SAAS;wBACTzB,OAAOA;wBACPH,UAAUM;;oBAEXL,yBACC,KAACV;wBAAWiC,SAASvB;kCACnB,cAAA,KAACJ;;;;;;AAMb,EAAE;AAEF,MAAMe,aAAa,CAACT,OAAe0B;IACjC,MAAMC,UAAU;IAChB,MAAMC,QAAQD,QAAQE,IAAI,CAAC7B;IAC3B,MAAM8B,SAASF,SAASA,KAAK,CAAC,EAAE,GAAGA,KAAK,CAAC,EAAE,CAACE,MAAM,GAAG;IACrD,OACEA,WAAW,KAAK,gBAAgB;IAChCA,WAAW,KAAK,mBAAmB;IAClC,CAAC,CAACJ,SAASI,WAAW,KAAM,iBAAiB;IAC7C,CAAC,CAACJ,SAASI,WAAW,EAAG,qBAAqB;;AAEnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ColorPicker/OptionsColorPicker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useState, MouseEvent } from 'react';\nimport { styled, IconButton, Popover } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { useChartsTheme } from '../context';\nimport { ColorPicker } from './ColorPicker';\n\nexport interface OptionsColorPickerProps {\n label: string;\n color: string;\n onColorChange: (color: string) => void;\n onClear?: () => void;\n}\n\nexport function OptionsColorPicker({ label, color, onColorChange, onClear }: OptionsColorPickerProps): ReactElement {\n const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);\n const isOpen = Boolean(anchorEl);\n\n const openColorPicker = (event: MouseEvent<HTMLButtonElement>): void => {\n setAnchorEl(event.currentTarget);\n };\n\n const closeColorPicker = (): void => {\n setAnchorEl(null);\n };\n\n const {\n thresholds: { defaultColor, palette },\n } = useChartsTheme();\n\n return (\n <>\n <ColorIconButton\n size=\"small\"\n aria-label={`change ${label} color`}\n isSelected={isOpen}\n iconColor={color}\n onClick={openColorPicker}\n >\n <CircleIcon />\n </ColorIconButton>\n <Popover\n data-testid=\"options color picker\"\n open={isOpen}\n anchorEl={anchorEl}\n onClose={closeColorPicker}\n slotProps={{ paper: { sx: { padding: (theme) => theme.spacing(2) } } }}\n anchorOrigin={{\n vertical: 'top',\n horizontal: 'left',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'right',\n }}\n >\n <ColorPicker color={color} palette={[defaultColor, ...palette]} onChange={onColorChange} onClear={onClear} />\n </Popover>\n </>\n );\n}\n\nconst ColorIconButton = styled(IconButton, {\n shouldForwardProp: (props) => props !== 'isSelected' && props !== 'iconColor',\n})<{\n iconColor?: string;\n isSelected?: boolean;\n}>(({ iconColor, isSelected }) => ({\n backgroundColor: isSelected && iconColor ? `${iconColor}3F` : 'undefined', // 3F represents 25% opacity\n color: iconColor,\n}));\n"],"names":["useState","styled","IconButton","Popover","CircleIcon","useChartsTheme","ColorPicker","OptionsColorPicker","label","color","onColorChange","onClear","anchorEl","setAnchorEl","isOpen","Boolean","openColorPicker","event","currentTarget","closeColorPicker","thresholds","defaultColor","palette","ColorIconButton","size","aria-label","isSelected","iconColor","onClick","data-testid","open","onClose","slotProps","paper","sx","padding","theme","spacing","anchorOrigin","vertical","horizontal","transformOrigin","onChange","shouldForwardProp","props","backgroundColor"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC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ACC,QAAUA,UAAU,gBAAgBA,UAAU;AACpE,GAGG,CAAC,EAAEjB,SAAS,EAAED,UAAU,EAAE,GAAM,CAAA;QACjCmB,iBAAiBnB,cAAcC,YAAY,
|
|
1
|
+
{"version":3,"sources":["../../src/ColorPicker/OptionsColorPicker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useState, MouseEvent } from 'react';\nimport { styled, IconButton, Popover } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { useChartsTheme } from '../context';\nimport { ColorPicker } from './ColorPicker';\n\nexport interface OptionsColorPickerProps {\n label: string;\n color: string;\n onColorChange: (color: string) => void;\n onClear?: () => void;\n}\n\nexport function OptionsColorPicker({ label, color, onColorChange, onClear }: OptionsColorPickerProps): ReactElement {\n const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);\n const isOpen = Boolean(anchorEl);\n\n const openColorPicker = (event: MouseEvent<HTMLButtonElement>): void => {\n setAnchorEl(event.currentTarget);\n };\n\n const closeColorPicker = (): void => {\n setAnchorEl(null);\n };\n\n const {\n thresholds: { defaultColor, palette },\n } = useChartsTheme();\n\n return (\n <>\n <ColorIconButton\n size=\"small\"\n aria-label={`change ${label} color`}\n isSelected={isOpen}\n iconColor={color}\n onClick={openColorPicker}\n >\n <CircleIcon />\n </ColorIconButton>\n <Popover\n data-testid=\"options color picker\"\n open={isOpen}\n anchorEl={anchorEl}\n onClose={closeColorPicker}\n slotProps={{ paper: { sx: { padding: (theme) => theme.spacing(2) } } }}\n anchorOrigin={{\n vertical: 'top',\n horizontal: 'left',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'right',\n }}\n >\n <ColorPicker color={color} palette={[defaultColor, ...palette]} onChange={onColorChange} onClear={onClear} />\n </Popover>\n </>\n );\n}\n\nconst ColorIconButton = styled(IconButton, {\n shouldForwardProp: (props) => props !== 'isSelected' && props !== 'iconColor',\n})<{\n iconColor?: string;\n isSelected?: boolean;\n}>(({ iconColor, isSelected }) => ({\n backgroundColor: isSelected && iconColor ? `${iconColor}3F` : 'undefined', // 3F represents 25% opacity\n color: iconColor,\n}));\n"],"names":["useState","styled","IconButton","Popover","CircleIcon","useChartsTheme","ColorPicker","OptionsColorPicker","label","color","onColorChange","onClear","anchorEl","setAnchorEl","isOpen","Boolean","openColorPicker","event","currentTarget","closeColorPicker","thresholds","defaultColor","palette","ColorIconButton","size","aria-label","isSelected","iconColor","onClick","data-testid","open","onClose","slotProps","paper","sx","padding","theme","spacing","anchorOrigin","vertical","horizontal","transformOrigin","onChange","shouldForwardProp","props","backgroundColor"],"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,SAAuBA,QAAQ,QAAoB,QAAQ;AAC3D,SAASC,MAAM,EAAEC,UAAU,EAAEC,OAAO,QAAQ,gBAAgB;AAC5D,OAAOC,gBAAgB,yBAAyB;AAChD,SAASC,cAAc,QAAQ,aAAa;AAC5C,SAASC,WAAW,QAAQ,gBAAgB;AAS5C,OAAO,SAASC,mBAAmB,EAAEC,KAAK,EAAEC,KAAK,EAAEC,aAAa,EAAEC,OAAO,EAA2B;IAClG,MAAM,CAACC,UAAUC,YAAY,GAAGb,SAAmC;IACnE,MAAMc,SAASC,QAAQH;IAEvB,MAAMI,kBAAkB,CAACC;QACvBJ,YAAYI,MAAMC,aAAa;IACjC;IAEA,MAAMC,mBAAmB;QACvBN,YAAY;IACd;IAEA,MAAM,EACJO,YAAY,EAAEC,YAAY,EAAEC,OAAO,EAAE,EACtC,GAAGjB;IAEJ,qBACE;;0BACE,KAACkB;gBACCC,MAAK;gBACLC,cAAY,CAAC,OAAO,EAAEjB,MAAM,MAAM,CAAC;gBACnCkB,YAAYZ;gBACZa,WAAWlB;gBACXmB,SAASZ;0BAET,cAAA,KAACZ;;0BAEH,KAACD;gBACC0B,eAAY;gBACZC,MAAMhB;gBACNF,UAAUA;gBACVmB,SAASZ;gBACTa,WAAW;oBAAEC,OAAO;wBAAEC,IAAI;4BAAEC,SAAS,CAACC,QAAUA,MAAMC,OAAO,CAAC;wBAAG;oBAAE;gBAAE;gBACrEC,cAAc;oBACZC,UAAU;oBACVC,YAAY;gBACd;gBACAC,iBAAiB;oBACfF,UAAU;oBACVC,YAAY;gBACd;0BAEA,cAAA,KAAClC;oBAAYG,OAAOA;oBAAOa,SAAS;wBAACD;2BAAiBC;qBAAQ;oBAAEoB,UAAUhC;oBAAeC,SAASA;;;;;AAI1G;AAEA,MAAMY,kBAAkBtB,OAAOC,YAAY;IACzCyC,mBAAmB,CAACC,QAAUA,UAAU,gBAAgBA,UAAU;AACpE,GAGG,CAAC,EAAEjB,SAAS,EAAED,UAAU,EAAE,GAAM,CAAA;QACjCmB,iBAAiBnB,cAAcC,YAAY,GAAGA,UAAU,EAAE,CAAC,GAAG;QAC9DlB,OAAOkB;IACT,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ContentWithLegend/ContentWithLegend.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement } from 'react';\nimport { Box, useTheme } from '@mui/material';\nimport { getLegendSize } from '@perses-dev/core';\nimport { Legend } from '../Legend';\nimport { ContentWithLegendProps, getContentWithLegendLayout } from './model/content-with-legend-model';\n\n/**\n * Component to help lay out content alongside a `Legend` component based on the\n * configuration of the legend.\n *\n * See the documentation for the `Legend` component for more details about the\n * features and configuration of the legend.\n */\nexport function ContentWithLegend({\n children,\n legendProps,\n width,\n height,\n spacing = 0,\n legendSize,\n minChildrenWidth = 100,\n minChildrenHeight = 100,\n}: ContentWithLegendProps): ReactElement {\n const theme = useTheme();\n const { content, legend, margin } = getContentWithLegendLayout({\n width,\n height,\n legendProps,\n minChildrenHeight,\n minChildrenWidth,\n spacing,\n theme,\n legendSize: getLegendSize(legendSize),\n });\n\n return (\n <Box\n style={{\n width,\n height,\n }}\n sx={{\n position: 'relative',\n overflow: 'hidden',\n }}\n >\n <Box\n style={{\n width: content.width,\n height: content.height,\n }}\n sx={{\n marginRight: `${margin.right}px`,\n marginBottom: `${margin.bottom}px`,\n overflow: 'hidden',\n }}\n >\n {typeof children === 'function' ? children({ width: content.width, height: content.height }) : children}\n </Box>\n {legendProps && legend.show && <Legend {...legendProps} height={legend.height} width={legend.width} />}\n </Box>\n );\n}\n"],"names":["Box","useTheme","getLegendSize","Legend","getContentWithLegendLayout","ContentWithLegend","children","legendProps","width","height","spacing","legendSize","minChildrenWidth","minChildrenHeight","theme","content","legend","margin","style","sx","position","overflow","marginRight","right","marginBottom","bottom","show"],"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;;AAGjC,SAASA,GAAG,EAAEC,QAAQ,QAAQ,gBAAgB;AAC9C,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,MAAM,QAAQ,YAAY;AACnC,SAAiCC,0BAA0B,QAAQ,oCAAoC;AAEvG;;;;;;CAMC,GACD,OAAO,SAASC,kBAAkB,EAChCC,QAAQ,EACRC,WAAW,EACXC,KAAK,EACLC,MAAM,EACNC,UAAU,CAAC,EACXC,UAAU,EACVC,mBAAmB,GAAG,EACtBC,oBAAoB,GAAG,EACA;IACvB,MAAMC,QAAQb;IACd,MAAM,EAAEc,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGb,2BAA2B;QAC7DI;QACAC;QACAF;QACAM;QACAD;QACAF;QACAI;QACAH,YAAYT,cAAcS;IAC5B;IAEA,qBACE,MAACX;QACCkB,OAAO;YACLV;YACAC;QACF;QACAU,IAAI;YACFC,UAAU;YACVC,UAAU;QACZ;;0BAEA,KAACrB;gBACCkB,OAAO;oBACLV,OAAOO,QAAQP,KAAK;oBACpBC,QAAQM,QAAQN,MAAM;gBACxB;gBACAU,IAAI;oBACFG,aAAa,
|
|
1
|
+
{"version":3,"sources":["../../src/ContentWithLegend/ContentWithLegend.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement } from 'react';\nimport { Box, useTheme } from '@mui/material';\nimport { getLegendSize } from '@perses-dev/core';\nimport { Legend } from '../Legend';\nimport { ContentWithLegendProps, getContentWithLegendLayout } from './model/content-with-legend-model';\n\n/**\n * Component to help lay out content alongside a `Legend` component based on the\n * configuration of the legend.\n *\n * See the documentation for the `Legend` component for more details about the\n * features and configuration of the legend.\n */\nexport function ContentWithLegend({\n children,\n legendProps,\n width,\n height,\n spacing = 0,\n legendSize,\n minChildrenWidth = 100,\n minChildrenHeight = 100,\n}: ContentWithLegendProps): ReactElement {\n const theme = useTheme();\n const { content, legend, margin } = getContentWithLegendLayout({\n width,\n height,\n legendProps,\n minChildrenHeight,\n minChildrenWidth,\n spacing,\n theme,\n legendSize: getLegendSize(legendSize),\n });\n\n return (\n <Box\n style={{\n width,\n height,\n }}\n sx={{\n position: 'relative',\n overflow: 'hidden',\n }}\n >\n <Box\n style={{\n width: content.width,\n height: content.height,\n }}\n sx={{\n marginRight: `${margin.right}px`,\n marginBottom: `${margin.bottom}px`,\n overflow: 'hidden',\n }}\n >\n {typeof children === 'function' ? children({ width: content.width, height: content.height }) : children}\n </Box>\n {legendProps && legend.show && <Legend {...legendProps} height={legend.height} width={legend.width} />}\n </Box>\n );\n}\n"],"names":["Box","useTheme","getLegendSize","Legend","getContentWithLegendLayout","ContentWithLegend","children","legendProps","width","height","spacing","legendSize","minChildrenWidth","minChildrenHeight","theme","content","legend","margin","style","sx","position","overflow","marginRight","right","marginBottom","bottom","show"],"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;;AAGjC,SAASA,GAAG,EAAEC,QAAQ,QAAQ,gBAAgB;AAC9C,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,MAAM,QAAQ,YAAY;AACnC,SAAiCC,0BAA0B,QAAQ,oCAAoC;AAEvG;;;;;;CAMC,GACD,OAAO,SAASC,kBAAkB,EAChCC,QAAQ,EACRC,WAAW,EACXC,KAAK,EACLC,MAAM,EACNC,UAAU,CAAC,EACXC,UAAU,EACVC,mBAAmB,GAAG,EACtBC,oBAAoB,GAAG,EACA;IACvB,MAAMC,QAAQb;IACd,MAAM,EAAEc,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGb,2BAA2B;QAC7DI;QACAC;QACAF;QACAM;QACAD;QACAF;QACAI;QACAH,YAAYT,cAAcS;IAC5B;IAEA,qBACE,MAACX;QACCkB,OAAO;YACLV;YACAC;QACF;QACAU,IAAI;YACFC,UAAU;YACVC,UAAU;QACZ;;0BAEA,KAACrB;gBACCkB,OAAO;oBACLV,OAAOO,QAAQP,KAAK;oBACpBC,QAAQM,QAAQN,MAAM;gBACxB;gBACAU,IAAI;oBACFG,aAAa,GAAGL,OAAOM,KAAK,CAAC,EAAE,CAAC;oBAChCC,cAAc,GAAGP,OAAOQ,MAAM,CAAC,EAAE,CAAC;oBAClCJ,UAAU;gBACZ;0BAEC,OAAOf,aAAa,aAAaA,SAAS;oBAAEE,OAAOO,QAAQP,KAAK;oBAAEC,QAAQM,QAAQN,MAAM;gBAAC,KAAKH;;YAEhGC,eAAeS,OAAOU,IAAI,kBAAI,KAACvB;gBAAQ,GAAGI,WAAW;gBAAEE,QAAQO,OAAOP,MAAM;gBAAED,OAAOQ,OAAOR,KAAK;;;;AAGxG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/DragAndDrop/DropIndicator.tsx"],"sourcesContent":["// Copyright 2024 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 { Box, Stack } from '@mui/material';\nimport { ReactElement } from 'react';\n\nexport function DropIndicator(): ReactElement {\n return (\n <Stack direction=\"row\" alignItems=\"center\">\n <Box\n sx={{\n content: '\"\"',\n width: 8,\n height: 8,\n boxSizing: 'border-box',\n position: 'absolute',\n backgroundColor: (theme) => theme.palette.background.default,\n border: (theme) => `2px solid ${theme.palette.info.main}`,\n borderRadius: '50%',\n }}\n ></Box>\n <Box\n sx={{\n content: '\"\"',\n height: 2,\n background: (theme) => theme.palette.info.main,\n width: '100%',\n }}\n ></Box>\n </Stack>\n );\n}\n"],"names":["Box","Stack","DropIndicator","direction","alignItems","sx","content","width","height","boxSizing","position","backgroundColor","theme","palette","background","default","border","info","main","borderRadius"],"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,GAAG,EAAEC,KAAK,QAAQ,gBAAgB;AAG3C,OAAO,SAASC;IACd,qBACE,MAACD;QAAME,WAAU;QAAMC,YAAW;;0BAChC,KAACJ;gBACCK,IAAI;oBACFC,SAAS;oBACTC,OAAO;oBACPC,QAAQ;oBACRC,WAAW;oBACXC,UAAU;oBACVC,iBAAiB,CAACC,QAAUA,MAAMC,OAAO,CAACC,UAAU,CAACC,OAAO;oBAC5DC,QAAQ,CAACJ,QAAU,CAAC,UAAU,EAAEA,MAAMC,OAAO,CAACI,IAAI,CAACC,IAAI,
|
|
1
|
+
{"version":3,"sources":["../../src/DragAndDrop/DropIndicator.tsx"],"sourcesContent":["// Copyright 2024 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 { Box, Stack } from '@mui/material';\nimport { ReactElement } from 'react';\n\nexport function DropIndicator(): ReactElement {\n return (\n <Stack direction=\"row\" alignItems=\"center\">\n <Box\n sx={{\n content: '\"\"',\n width: 8,\n height: 8,\n boxSizing: 'border-box',\n position: 'absolute',\n backgroundColor: (theme) => theme.palette.background.default,\n border: (theme) => `2px solid ${theme.palette.info.main}`,\n borderRadius: '50%',\n }}\n ></Box>\n <Box\n sx={{\n content: '\"\"',\n height: 2,\n background: (theme) => theme.palette.info.main,\n width: '100%',\n }}\n ></Box>\n </Stack>\n );\n}\n"],"names":["Box","Stack","DropIndicator","direction","alignItems","sx","content","width","height","boxSizing","position","backgroundColor","theme","palette","background","default","border","info","main","borderRadius"],"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,GAAG,EAAEC,KAAK,QAAQ,gBAAgB;AAG3C,OAAO,SAASC;IACd,qBACE,MAACD;QAAME,WAAU;QAAMC,YAAW;;0BAChC,KAACJ;gBACCK,IAAI;oBACFC,SAAS;oBACTC,OAAO;oBACPC,QAAQ;oBACRC,WAAW;oBACXC,UAAU;oBACVC,iBAAiB,CAACC,QAAUA,MAAMC,OAAO,CAACC,UAAU,CAACC,OAAO;oBAC5DC,QAAQ,CAACJ,QAAU,CAAC,UAAU,EAAEA,MAAMC,OAAO,CAACI,IAAI,CAACC,IAAI,EAAE;oBACzDC,cAAc;gBAChB;;0BAEF,KAACnB;gBACCK,IAAI;oBACFC,SAAS;oBACTE,QAAQ;oBACRM,YAAY,CAACF,QAAUA,MAAMC,OAAO,CAACI,IAAI,CAACC,IAAI;oBAC9CX,OAAO;gBACT;;;;AAIR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Drawer/Drawer.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Drawer as MuiDrawer, DrawerProps as MuiDrawerProps, useMediaQuery } from '@mui/material';\nimport { ReactElement } from 'react';\nimport { combineSx } from '../utils';\n\nexport interface DrawerProps extends MuiDrawerProps {\n isOpen: boolean;\n onClose: () => void;\n anchor?: 'left' | 'right';\n}\n\nconst DRAWER_DEFAULT_WIDTH = 1080;\n\nexport const Drawer = ({\n anchor = 'right',\n isOpen,\n onClose,\n PaperProps,\n children,\n ...rest\n}: DrawerProps): ReactElement => {\n const isSmaller = useMediaQuery(`(max-width:${DRAWER_DEFAULT_WIDTH}px)`);\n\n return (\n <MuiDrawer\n {...rest}\n open={isOpen}\n onClose={onClose}\n anchor={anchor}\n PaperProps={{\n ...PaperProps,\n sx: combineSx(\n {\n width: isSmaller ? '100%' : `${DRAWER_DEFAULT_WIDTH}px`,\n overflow: 'hidden',\n },\n PaperProps?.sx\n ),\n }}\n >\n {children}\n </MuiDrawer>\n );\n};\n"],"names":["Drawer","MuiDrawer","useMediaQuery","combineSx","DRAWER_DEFAULT_WIDTH","anchor","isOpen","onClose","PaperProps","children","rest","isSmaller","open","sx","width","overflow"],"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,UAAUC,SAAS,EAAiCC,aAAa,QAAQ,gBAAgB;AAElG,SAASC,SAAS,QAAQ,WAAW;AAQrC,MAAMC,uBAAuB;AAE7B,OAAO,MAAMJ,SAAS,CAAC,EACrBK,SAAS,OAAO,EAChBC,MAAM,EACNC,OAAO,EACPC,UAAU,EACVC,QAAQ,EACR,GAAGC,MACS;IACZ,MAAMC,YAAYT,cAAc,CAAC,WAAW,EAAEE,qBAAqB,GAAG,CAAC;IAEvE,qBACE,KAACH;QACE,GAAGS,IAAI;QACRE,MAAMN;QACNC,SAASA;QACTF,QAAQA;QACRG,YAAY;YACV,GAAGA,UAAU;YACbK,IAAIV,UACF;gBACEW,OAAOH,YAAY,SAAS,
|
|
1
|
+
{"version":3,"sources":["../../src/Drawer/Drawer.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Drawer as MuiDrawer, DrawerProps as MuiDrawerProps, useMediaQuery } from '@mui/material';\nimport { ReactElement } from 'react';\nimport { combineSx } from '../utils';\n\nexport interface DrawerProps extends MuiDrawerProps {\n isOpen: boolean;\n onClose: () => void;\n anchor?: 'left' | 'right';\n}\n\nconst DRAWER_DEFAULT_WIDTH = 1080;\n\nexport const Drawer = ({\n anchor = 'right',\n isOpen,\n onClose,\n PaperProps,\n children,\n ...rest\n}: DrawerProps): ReactElement => {\n const isSmaller = useMediaQuery(`(max-width:${DRAWER_DEFAULT_WIDTH}px)`);\n\n return (\n <MuiDrawer\n {...rest}\n open={isOpen}\n onClose={onClose}\n anchor={anchor}\n PaperProps={{\n ...PaperProps,\n sx: combineSx(\n {\n width: isSmaller ? '100%' : `${DRAWER_DEFAULT_WIDTH}px`,\n overflow: 'hidden',\n },\n PaperProps?.sx\n ),\n }}\n >\n {children}\n </MuiDrawer>\n );\n};\n"],"names":["Drawer","MuiDrawer","useMediaQuery","combineSx","DRAWER_DEFAULT_WIDTH","anchor","isOpen","onClose","PaperProps","children","rest","isSmaller","open","sx","width","overflow"],"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,UAAUC,SAAS,EAAiCC,aAAa,QAAQ,gBAAgB;AAElG,SAASC,SAAS,QAAQ,WAAW;AAQrC,MAAMC,uBAAuB;AAE7B,OAAO,MAAMJ,SAAS,CAAC,EACrBK,SAAS,OAAO,EAChBC,MAAM,EACNC,OAAO,EACPC,UAAU,EACVC,QAAQ,EACR,GAAGC,MACS;IACZ,MAAMC,YAAYT,cAAc,CAAC,WAAW,EAAEE,qBAAqB,GAAG,CAAC;IAEvE,qBACE,KAACH;QACE,GAAGS,IAAI;QACRE,MAAMN;QACNC,SAASA;QACTF,QAAQA;QACRG,YAAY;YACV,GAAGA,UAAU;YACbK,IAAIV,UACF;gBACEW,OAAOH,YAAY,SAAS,GAAGP,qBAAqB,EAAE,CAAC;gBACvDW,UAAU;YACZ,GACAP,YAAYK;QAEhB;kBAECJ;;AAGP,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EChart.d.ts","sourceRoot":"","sources":["../../src/EChart/EChart.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"EChart.d.ts","sourceRoot":"","sources":["../../src/EChart/EChart.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAsB,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAO,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAcpD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAgBxC,MAAM,WAAW,qBAAqB,CAAC,CAAC;I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EAAE,qBAAqB,KAAK,IAAI,CAAC;AAEpE,QAAA,MAAM,WAAW,gDAAiD,CAAC;AAEnE,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,KAAK,cAAc,GAAG,UAAU,CAAC;AAIjC,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;KAC3B,cAAc,IAAI,cAAc,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;CACxD,GAAG;KACD,cAAc,IAAI,cAAc,CAAC,CAAC,EAAE,oBAAoB;CAC1D,GAAG;KACD,SAAS,IAAI,cAAc,CAAC,CAAC,EAAE,MAAM,IAAI;CAC3C,CAAC;AAEF,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC9B,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC5B,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,MAAM,iIAShB,aAAa,CAAC,CAAC,8CAsFhB,CAAC"}
|
package/dist/EChart/EChart.js
CHANGED
|
@@ -12,10 +12,25 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { memo, useEffect, useLayoutEffect, useRef } from 'react';
|
|
15
|
-
import { init, connect } from 'echarts/core';
|
|
15
|
+
import { init, connect, use } from 'echarts/core';
|
|
16
16
|
import { Box } from '@mui/material';
|
|
17
17
|
import isEqual from 'lodash/isEqual';
|
|
18
18
|
import debounce from 'lodash/debounce';
|
|
19
|
+
import { ScatterChart as EChartsScatterChart } from 'echarts/charts';
|
|
20
|
+
import { DatasetComponent, DataZoomComponent, LegendComponent, GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';
|
|
21
|
+
import { CanvasRenderer } from 'echarts/renderers';
|
|
22
|
+
// Loading the ECharts extensions should happen in the respective plugin (in this case, the scatterplot plugin).
|
|
23
|
+
// This is a workaround for https://github.com/perses/plugins/issues/83.
|
|
24
|
+
use([
|
|
25
|
+
DatasetComponent,
|
|
26
|
+
DataZoomComponent,
|
|
27
|
+
LegendComponent,
|
|
28
|
+
EChartsScatterChart,
|
|
29
|
+
GridComponent,
|
|
30
|
+
TitleComponent,
|
|
31
|
+
TooltipComponent,
|
|
32
|
+
CanvasRenderer
|
|
33
|
+
]);
|
|
19
34
|
const mouseEvents = [
|
|
20
35
|
'click',
|
|
21
36
|
'dblclick',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/EChart/EChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { memo, useEffect, useLayoutEffect, useRef } from 'react';\nimport { ECharts, EChartsCoreOption, init, connect } from 'echarts/core';\nimport { Box, SxProps, Theme } from '@mui/material';\nimport isEqual from 'lodash/isEqual';\nimport debounce from 'lodash/debounce';\nimport { EChartsTheme } from '../model';\n\n// see docs for info about each property: https://echarts.apache.org/en/api.html#events\nexport interface MouseEventsParameters<T> {\n componentType: string;\n seriesType: string;\n seriesIndex: number;\n seriesName: string;\n name: string;\n dataIndex: number;\n data: Record<string, unknown> & T;\n dataType: string;\n value: number | number[];\n color: string;\n info: Record<string, unknown>;\n}\n\ntype OnEventFunction<T> = (\n params: MouseEventsParameters<T>,\n // This is potentially undefined for testing purposes\n instance?: ECharts\n) => void;\n\nconst mouseEvents = [\n 'click',\n 'dblclick',\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'mouseover',\n 'mouseout',\n 'globalout',\n 'contextmenu',\n] as const;\n\nexport type MouseEventName = (typeof mouseEvents)[number];\n\n// batch event types\nexport interface DataZoomPayloadBatchItem {\n dataZoomId: string;\n // start and end not returned unless dataZoom is based on percentProp,\n // which is for cases when a dataZoom component controls multiple axes\n start?: number;\n end?: number;\n // startValue and endValue return data index for 'category' axes,\n // for axis types 'value' and 'time', actual values are returned\n startValue?: number;\n endValue?: number;\n}\n\nexport interface HighlightPayloadBatchItem {\n dataIndex: number;\n dataIndexInside: number;\n seriesIndex: number;\n // highlight action can effect multiple connected charts\n escapeConnect?: boolean;\n // whether blur state was triggered\n notBlur?: boolean;\n}\n\nexport interface BatchEventsParameters {\n type: BatchEventName;\n batch: DataZoomPayloadBatchItem[] & HighlightPayloadBatchItem[];\n}\n\ntype OnBatchEventFunction = (params: BatchEventsParameters) => void;\n\nconst batchEvents = ['datazoom', 'downplay', 'highlight'] as const;\n\nexport type BatchEventName = (typeof batchEvents)[number];\n\ntype ChartEventName = 'finished';\n\ntype EventName = MouseEventName | ChartEventName | BatchEventName;\n\nexport type OnEventsType<T> = {\n [mouseEventName in MouseEventName]?: OnEventFunction<T>;\n} & {\n [batchEventName in BatchEventName]?: OnBatchEventFunction;\n} & {\n [eventName in ChartEventName]?: () => void;\n};\n\nexport interface EChartsProps<T> {\n option: EChartsCoreOption;\n theme?: string | EChartsTheme;\n renderer?: 'canvas' | 'svg';\n sx?: SxProps<Theme>;\n onEvents?: OnEventsType<T>;\n _instance?: React.MutableRefObject<ECharts | undefined>;\n syncGroup?: string;\n onChartInitialized?: (instance: ECharts) => void;\n}\n\nexport const EChart = memo(function EChart<T>({\n option,\n theme,\n renderer,\n sx,\n onEvents,\n _instance,\n syncGroup,\n onChartInitialized,\n}: EChartsProps<T>) {\n const initialOption = useRef<EChartsCoreOption>(option);\n const prevOption = useRef<EChartsCoreOption>(option);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const chartElement = useRef<ECharts | null>(null);\n\n // Initialize chart, dispose on unmount\n useLayoutEffect(() => {\n if (containerRef.current === null || chartElement.current !== null) return;\n chartElement.current = init(containerRef.current, theme, { renderer: renderer ?? 'canvas' });\n if (chartElement.current === undefined) return;\n chartElement.current.setOption(initialOption.current, true);\n onChartInitialized?.(chartElement.current);\n if (_instance !== undefined) {\n _instance.current = chartElement.current;\n }\n return (): void => {\n if (chartElement.current === null) return;\n chartElement.current.dispose();\n chartElement.current = null;\n };\n }, [_instance, onChartInitialized, theme, renderer]);\n\n // When syncGroup is explicitly set, charts within same group share interactions such as crosshair\n useEffect(() => {\n if (!chartElement.current || !syncGroup) return;\n chartElement.current.group = syncGroup;\n connect([chartElement.current]); // more info: https://echarts.apache.org/en/api.html#echarts.connect\n }, [syncGroup, chartElement]);\n\n // Update chart data when option changes\n useEffect(() => {\n if (prevOption.current === undefined || isEqual(prevOption.current, option)) return;\n if (!chartElement.current) return;\n chartElement.current.setOption(option, true);\n prevOption.current = option;\n }, [option]);\n\n // Resize chart, cleanup listener on unmount\n useLayoutEffect(() => {\n const updateSize = debounce(() => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n }, 200);\n window.addEventListener('resize', updateSize);\n updateSize();\n return (): void => {\n window.removeEventListener('resize', updateSize);\n };\n }, []);\n\n // Bind and unbind chart events passed as prop\n useEffect(() => {\n const chart = chartElement.current;\n if (!chart || onEvents === undefined) return;\n bindEvents(chart, onEvents);\n return (): void => {\n if (chart === undefined) return;\n if (chart.isDisposed() === true) return;\n for (const event in onEvents) {\n chart.off(event);\n }\n };\n }, [onEvents]);\n\n // TODO: re-evaluate how this is triggered. It's technically working right\n // now because the sx prop is an object that gets re-created, but that also\n // means it runs unnecessarily some of the time and theoretically might\n // not run in some other cases. Maybe it should use a resize observer?\n useEffect(() => {\n // TODO: fix this debouncing. This likely isn't working as intended because\n // the debounced function is re-created every time this useEffect is called.\n const updateSize = debounce(\n () => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n },\n 200,\n {\n leading: true,\n }\n );\n updateSize();\n }, [sx]);\n\n return <Box ref={containerRef} sx={sx}></Box>;\n});\n\n// Validate event config and bind custom events\nfunction bindEvents<T>(instance: ECharts, events?: OnEventsType<T>): void {\n if (events === undefined) return;\n\n function bindEvent(eventName: EventName, OnEventFunction: unknown): void {\n if (typeof OnEventFunction === 'function') {\n if (isMouseEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params, instance));\n } else if (isBatchEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params));\n } else {\n instance.on(eventName, () => OnEventFunction(null, instance));\n }\n }\n }\n\n for (const eventName in events) {\n if (Object.prototype.hasOwnProperty.call(events, eventName)) {\n const customEvent = events[eventName as EventName] ?? null;\n if (customEvent) {\n bindEvent(eventName as EventName, customEvent);\n }\n }\n }\n}\n\nfunction isMouseEvent(eventName: EventName): eventName is MouseEventName {\n return (mouseEvents as readonly string[]).includes(eventName);\n}\n\nfunction isBatchEvent(eventName: EventName): eventName is BatchEventName {\n return (batchEvents as readonly string[]).includes(eventName);\n}\n"],"names":["memo","useEffect","useLayoutEffect","useRef","init","connect","Box","isEqual","debounce","mouseEvents","batchEvents","EChart","option","theme","renderer","sx","onEvents","_instance","syncGroup","onChartInitialized","initialOption","prevOption","containerRef","chartElement","current","undefined","setOption","dispose","group","updateSize","resize","window","addEventListener","removeEventListener","chart","bindEvents","isDisposed","event","off","leading","ref","instance","events","bindEvent","eventName","OnEventFunction","isMouseEvent","on","params","isBatchEvent","Object","prototype","hasOwnProperty","call","customEvent","includes"],"mappings":"AAAA,oCAAoC;AACpC,kEAAk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E;YAC3BD,aAAaC,OAAO,CAACM,MAAM;QAC7B,GACA,KACA;YACES,SAAS;QACX;QAEFV;IACF,GAAG;QAACd;KAAG;IAEP,qBAAO,KAACT;QAAIkC,KAAKlB;QAAcP,IAAIA;;AACrC,GAAG;AAEH,+CAA+C;AAC/C,SAASoB,WAAcM,QAAiB,EAAEC,MAAwB;IAChE,IAAIA,WAAWjB,WAAW;IAE1B,SAASkB,UAAUC,SAAoB,EAAEC,eAAwB;QAC/D,IAAI,OAAOA,oBAAoB,YAAY;YACzC,IAAIC,aAAaF,YAAY;gBAC3BH,SAASM,EAAE,CAACH,WAAW,CAACI,SAAWH,gBAAgBG,QAAQP;YAC7D,OAAO,IAAIQ,aAAaL,YAAY;gBAClCH,SAASM,EAAE,CAACH,WAAW,CAACI,SAAWH,gBAAgBG;YACrD,OAAO;gBACLP,SAASM,EAAE,CAACH,WAAW,IAAMC,gBAAgB,MAAMJ;YACrD;QACF;IACF;IAEA,IAAK,MAAMG,aAAaF,OAAQ;QAC9B,IAAIQ,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACX,QAAQE,YAAY;YAC3D,MAAMU,cAAcZ,MAAM,CAACE,UAAuB,IAAI;YACtD,IAAIU,aAAa;gBACfX,UAAUC,WAAwBU;YACpC;QACF;IACF;AACF;AAEA,SAASR,aAAaF,SAAoB;IACxC,OAAO,AAACnC,YAAkC8C,QAAQ,CAACX;AACrD;AAEA,SAASK,aAAaL,SAAoB;IACxC,OAAO,AAAClC,YAAkC6C,QAAQ,CAACX;AACrD"}
|
|
1
|
+
{"version":3,"sources":["../../src/EChart/EChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { memo, useEffect, useLayoutEffect, useRef } from 'react';\nimport { ECharts, EChartsCoreOption, init, connect, use } from 'echarts/core';\nimport { Box, SxProps, Theme } from '@mui/material';\nimport isEqual from 'lodash/isEqual';\nimport debounce from 'lodash/debounce';\n\nimport { ScatterChart as EChartsScatterChart } from 'echarts/charts';\nimport {\n DatasetComponent,\n DataZoomComponent,\n LegendComponent,\n GridComponent,\n TitleComponent,\n TooltipComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChartsTheme } from '../model';\n\n// Loading the ECharts extensions should happen in the respective plugin (in this case, the scatterplot plugin).\n// This is a workaround for https://github.com/perses/plugins/issues/83.\nuse([\n DatasetComponent,\n DataZoomComponent,\n LegendComponent,\n EChartsScatterChart,\n GridComponent,\n TitleComponent,\n TooltipComponent,\n CanvasRenderer,\n]);\n\n// see docs for info about each property: https://echarts.apache.org/en/api.html#events\nexport interface MouseEventsParameters<T> {\n componentType: string;\n seriesType: string;\n seriesIndex: number;\n seriesName: string;\n name: string;\n dataIndex: number;\n data: Record<string, unknown> & T;\n dataType: string;\n value: number | number[];\n color: string;\n info: Record<string, unknown>;\n}\n\ntype OnEventFunction<T> = (\n params: MouseEventsParameters<T>,\n // This is potentially undefined for testing purposes\n instance?: ECharts\n) => void;\n\nconst mouseEvents = [\n 'click',\n 'dblclick',\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'mouseover',\n 'mouseout',\n 'globalout',\n 'contextmenu',\n] as const;\n\nexport type MouseEventName = (typeof mouseEvents)[number];\n\n// batch event types\nexport interface DataZoomPayloadBatchItem {\n dataZoomId: string;\n // start and end not returned unless dataZoom is based on percentProp,\n // which is for cases when a dataZoom component controls multiple axes\n start?: number;\n end?: number;\n // startValue and endValue return data index for 'category' axes,\n // for axis types 'value' and 'time', actual values are returned\n startValue?: number;\n endValue?: number;\n}\n\nexport interface HighlightPayloadBatchItem {\n dataIndex: number;\n dataIndexInside: number;\n seriesIndex: number;\n // highlight action can effect multiple connected charts\n escapeConnect?: boolean;\n // whether blur state was triggered\n notBlur?: boolean;\n}\n\nexport interface BatchEventsParameters {\n type: BatchEventName;\n batch: DataZoomPayloadBatchItem[] & HighlightPayloadBatchItem[];\n}\n\ntype OnBatchEventFunction = (params: BatchEventsParameters) => void;\n\nconst batchEvents = ['datazoom', 'downplay', 'highlight'] as const;\n\nexport type BatchEventName = (typeof batchEvents)[number];\n\ntype ChartEventName = 'finished';\n\ntype EventName = MouseEventName | ChartEventName | BatchEventName;\n\nexport type OnEventsType<T> = {\n [mouseEventName in MouseEventName]?: OnEventFunction<T>;\n} & {\n [batchEventName in BatchEventName]?: OnBatchEventFunction;\n} & {\n [eventName in ChartEventName]?: () => void;\n};\n\nexport interface EChartsProps<T> {\n option: EChartsCoreOption;\n theme?: string | EChartsTheme;\n renderer?: 'canvas' | 'svg';\n sx?: SxProps<Theme>;\n onEvents?: OnEventsType<T>;\n _instance?: React.MutableRefObject<ECharts | undefined>;\n syncGroup?: string;\n onChartInitialized?: (instance: ECharts) => void;\n}\n\nexport const EChart = memo(function EChart<T>({\n option,\n theme,\n renderer,\n sx,\n onEvents,\n _instance,\n syncGroup,\n onChartInitialized,\n}: EChartsProps<T>) {\n const initialOption = useRef<EChartsCoreOption>(option);\n const prevOption = useRef<EChartsCoreOption>(option);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const chartElement = useRef<ECharts | null>(null);\n\n // Initialize chart, dispose on unmount\n useLayoutEffect(() => {\n if (containerRef.current === null || chartElement.current !== null) return;\n chartElement.current = init(containerRef.current, theme, { renderer: renderer ?? 'canvas' });\n if (chartElement.current === undefined) return;\n chartElement.current.setOption(initialOption.current, true);\n onChartInitialized?.(chartElement.current);\n if (_instance !== undefined) {\n _instance.current = chartElement.current;\n }\n return (): void => {\n if (chartElement.current === null) return;\n chartElement.current.dispose();\n chartElement.current = null;\n };\n }, [_instance, onChartInitialized, theme, renderer]);\n\n // When syncGroup is explicitly set, charts within same group share interactions such as crosshair\n useEffect(() => {\n if (!chartElement.current || !syncGroup) return;\n chartElement.current.group = syncGroup;\n connect([chartElement.current]); // more info: https://echarts.apache.org/en/api.html#echarts.connect\n }, [syncGroup, chartElement]);\n\n // Update chart data when option changes\n useEffect(() => {\n if (prevOption.current === undefined || isEqual(prevOption.current, option)) return;\n if (!chartElement.current) return;\n chartElement.current.setOption(option, true);\n prevOption.current = option;\n }, [option]);\n\n // Resize chart, cleanup listener on unmount\n useLayoutEffect(() => {\n const updateSize = debounce(() => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n }, 200);\n window.addEventListener('resize', updateSize);\n updateSize();\n return (): void => {\n window.removeEventListener('resize', updateSize);\n };\n }, []);\n\n // Bind and unbind chart events passed as prop\n useEffect(() => {\n const chart = chartElement.current;\n if (!chart || onEvents === undefined) return;\n bindEvents(chart, onEvents);\n return (): void => {\n if (chart === undefined) return;\n if (chart.isDisposed() === true) return;\n for (const event in onEvents) {\n chart.off(event);\n }\n };\n }, [onEvents]);\n\n // TODO: re-evaluate how this is triggered. It's technically working right\n // now because the sx prop is an object that gets re-created, but that also\n // means it runs unnecessarily some of the time and theoretically might\n // not run in some other cases. Maybe it should use a resize observer?\n useEffect(() => {\n // TODO: fix this debouncing. This likely isn't working as intended because\n // the debounced function is re-created every time this useEffect is called.\n const updateSize = debounce(\n () => {\n if (!chartElement.current) return;\n chartElement.current.resize();\n },\n 200,\n {\n leading: true,\n }\n );\n updateSize();\n }, [sx]);\n\n return <Box ref={containerRef} sx={sx}></Box>;\n});\n\n// Validate event config and bind custom events\nfunction bindEvents<T>(instance: ECharts, events?: OnEventsType<T>): void {\n if (events === undefined) return;\n\n function bindEvent(eventName: EventName, OnEventFunction: unknown): void {\n if (typeof OnEventFunction === 'function') {\n if (isMouseEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params, instance));\n } else if (isBatchEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params));\n } else {\n instance.on(eventName, () => OnEventFunction(null, instance));\n }\n }\n }\n\n for (const eventName in events) {\n if (Object.prototype.hasOwnProperty.call(events, eventName)) {\n const customEvent = events[eventName as EventName] ?? null;\n if (customEvent) {\n bindEvent(eventName as EventName, customEvent);\n }\n }\n }\n}\n\nfunction isMouseEvent(eventName: EventName): eventName is MouseEventName {\n return (mouseEvents as readonly string[]).includes(eventName);\n}\n\nfunction isBatchEvent(eventName: EventName): eventName is BatchEventName {\n return (batchEvents as readonly string[]).includes(eventName);\n}\n"],"names":["memo","useEffect","useLayoutEffect","useRef","init","connect","use","Box","isEqual","debounce","ScatterChart","EChartsScatterChart","DatasetComponent","DataZoomComponent","LegendComponent","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","mouseEvents","batchEvents","EChart","option","theme","renderer","sx","onEvents","_instance","syncGroup","onChartInitialized","initialOption","prevOption","containerRef","chartElement","current","undefined","setOption","dispose","group","updateSize","resize","window","addEventListener","removeEventListener","chart","bindEvents","isDisposed","event","off","leading","ref","instance","events","bindEvent","eventName","OnEventFunction","isMouseEvent","on","params","isBatchEvent","Object","prototype","hasOwnProperty","call","customEvent","includes"],"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,IAAI,EAAEC,SAAS,EAAEC,eAAe,EAAEC,MAAM,QAAQ,QAAQ;AACjE,SAAqCC,IAAI,EAAEC,OAAO,EAAEC,GAAG,QAAQ,eAAe;AAC9E,SAASC,GAAG,QAAwB,gBAAgB;AACpD,OAAOC,aAAa,iBAAiB;AACrC,OAAOC,cAAc,kBAAkB;AAEvC,SAASC,gBAAgBC,mBAAmB,QAAQ,iBAAiB;AACrE,SACEC,gBAAgB,EAChBC,iBAAiB,EACjBC,eAAe,EACfC,aAA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G;AAEH,+CAA+C;AAC/C,SAASoB,WAAcM,QAAiB,EAAEC,MAAwB;IAChE,IAAIA,WAAWjB,WAAW;IAE1B,SAASkB,UAAUC,SAAoB,EAAEC,eAAwB;QAC/D,IAAI,OAAOA,oBAAoB,YAAY;YACzC,IAAIC,aAAaF,YAAY;gBAC3BH,SAASM,EAAE,CAACH,WAAW,CAACI,SAAWH,gBAAgBG,QAAQP;YAC7D,OAAO,IAAIQ,aAAaL,YAAY;gBAClCH,SAASM,EAAE,CAACH,WAAW,CAACI,SAAWH,gBAAgBG;YACrD,OAAO;gBACLP,SAASM,EAAE,CAACH,WAAW,IAAMC,gBAAgB,MAAMJ;YACrD;QACF;IACF;IAEA,IAAK,MAAMG,aAAaF,OAAQ;QAC9B,IAAIQ,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACX,QAAQE,YAAY;YAC3D,MAAMU,cAAcZ,MAAM,CAACE,UAAuB,IAAI;YACtD,IAAIU,aAAa;gBACfX,UAAUC,WAAwBU;YACpC;QACF;IACF;AACF;AAEA,SAASR,aAAaF,SAAoB;IACxC,OAAO,AAACnC,YAAkC8C,QAAQ,CAACX;AACrD;AAEA,SAASK,aAAaL,SAAoB;IACxC,OAAO,AAAClC,YAAkC6C,QAAQ,CAACX;AACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/GaugeChart/GaugeChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { formatValue, useDeepMemo, FormatOptions } from '@perses-dev/core';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { GaugeChart as EChartsGaugeChart, GaugeSeriesOption } from 'echarts/charts';\nimport { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { ReactElement } from 'react';\nimport { useChartsTheme } from '../context';\nimport { EChart } from '../EChart';\n\nuse([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst PROGRESS_WIDTH = 16;\n\n// adjusts when to show pointer icon\nconst GAUGE_SMALL_BREAKPOINT = 170;\n\nexport type GaugeChartValue = number | null | undefined;\n\nexport type GaugeSeries = {\n value: GaugeChartValue;\n label: string;\n};\n\nexport interface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeSeries;\n format: FormatOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps): ReactElement {\n const { width, height, data, format, axisLine, max } = props;\n const chartsTheme = useChartsTheme();\n\n // useDeepMemo ensures value size util does not rerun everytime you hover on the chart\n const option: EChartsCoreOption = useDeepMemo(() => {\n if (data.value === undefined) return chartsTheme.noDataOption;\n\n // adjusts fontSize depending on number of characters\n const valueSizeClamp = getResponsiveValueSize(data.value, format, width, height);\n\n return {\n title: {\n show: false,\n },\n tooltip: {\n show: false,\n },\n series: [\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '86%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n silent: true,\n progress: {\n show: true,\n width: PROGRESS_WIDTH,\n itemStyle: {\n color: 'auto',\n },\n },\n pointer: {\n show: false,\n },\n axisLine: {\n lineStyle: {\n color: [[1, 'rgba(127,127,127,0.35)']], // TODO (sjcobb): use future chart theme colors\n width: PROGRESS_WIDTH,\n },\n },\n axisTick: {\n show: false,\n distance: 0,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n distance: -18,\n color: '#999',\n fontSize: 12,\n },\n anchor: {\n show: false,\n },\n title: {\n show: false,\n },\n detail: {\n show: false,\n },\n data: [\n {\n value: data.value,\n },\n ],\n },\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '100%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n pointer: {\n show: true,\n // pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade\n icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',\n length: 10,\n width: 5,\n offsetCenter: [0, '-49%'],\n itemStyle: {\n color: 'auto',\n },\n },\n axisLine,\n axisTick: {\n show: false,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n },\n detail: {\n show: true,\n width: '60%',\n borderRadius: 8,\n offsetCenter: [0, '-9%'],\n color: 'inherit', // allows value color to match active threshold color\n fontSize: valueSizeClamp,\n formatter:\n data.value === null\n ? // We use a different function when we *know* the value is null\n // at this level because the `formatter` function argument is `NaN`\n // when the value is `null`, making it difficult to differentiate\n // `null` from a true `NaN` case.\n (): string => 'null'\n : (value: number): string | undefined => {\n return formatValue(value, format);\n },\n },\n data: [\n {\n value: data.value,\n name: data.label,\n // TODO: new UX for series names, create separate React component or reuse ListLegendItem\n // https://echarts.apache.org/en/option.html#series-gauge.data.title\n title: {\n show: true,\n color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit', // series name font color\n offsetCenter: [0, '55%'],\n overflow: 'truncate',\n fontSize: 12,\n width: width * 0.8,\n },\n },\n ],\n },\n ],\n };\n }, [data, width, height, chartsTheme, format, axisLine, max]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n padding: `${chartsTheme.container.padding.default}px`,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n );\n}\n\n/**\n * Responsive font size depending on number of characters, clamp used\n * to ensure size stays within given range\n */\nexport function getResponsiveValueSize(\n value: number | null,\n format: FormatOptions,\n width: number,\n height: number\n): string {\n const MIN_SIZE = 3;\n const MAX_SIZE = 24;\n const SIZE_MULTIPLIER = 0.7;\n const formattedValue = typeof value === 'number' ? formatValue(value, format) : `${value}`;\n const valueCharacters = formattedValue.length ?? 2;\n const valueSize = (Math.min(width, height) / valueCharacters) * SIZE_MULTIPLIER;\n return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;\n}\n"],"names":["formatValue","useDeepMemo","use","GaugeChart","EChartsGaugeChart","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","EChart","PROGRESS_WIDTH","GAUGE_SMALL_BREAKPOINT","props","width","height","data","format","axisLine","max","chartsTheme","option","value","undefined","noDataOption","valueSizeClamp","getResponsiveValueSize","title","show","tooltip","series","type","center","radius","startAngle","endAngle","min","silent","progress","itemStyle","color","pointer","lineStyle","axisTick","distance","splitLine","axisLabel","fontSize","anchor","detail","icon","length","offsetCenter","borderRadius","formatter","name","label","echartsTheme","textStyle","overflow","sx","padding","container","default","theme","MIN_SIZE","MAX_SIZE","SIZE_MULTIPLIER","formattedValue","valueCharacters","valueSize","Math"],"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,EAAEC,WAAW,QAAuB,mBAAmB;AAC3E,SAASC,GAAG,QAA2B,eAAe;AACtD,SAASC,cAAcC,iBAAiB,QAA2B,iBAAiB;AACpF,SAASC,aAAa,EAAEC,cAAc,EAAEC,gBAAgB,QAAQ,qBAAqB;AACrF,SAASC,cAAc,QAAQ,oBAAoB;AAEnD,SAASC,cAAc,QAAQ,aAAa;AAC5C,SAASC,MAAM,QAAQ,YAAY;AAEnCR,IAAI;IAACE;IAAmBC;IAAeC;IAAgBC;IAAkBC;CAAe;AAExF,MAAMG,iBAAiB;AAEvB,oCAAoC;AACpC,MAAMC,yBAAyB;AAkB/B,OAAO,SAAST,WAAWU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rBH,KAAa,EACbC,MAAc;IAEd,MAAMkD,WAAW;IACjB,MAAMC,WAAW;IACjB,MAAMC,kBAAkB;IACxB,MAAMC,iBAAiB,OAAO9C,UAAU,WAAWtB,YAAYsB,OAAOL,UAAU,CAAC,EAAEK,MAAM,CAAC;IAC1F,MAAM+C,kBAAkBD,eAAejB,MAAM,IAAI;IACjD,MAAMmB,YAAY,AAACC,KAAKnC,GAAG,CAACtB,OAAOC,UAAUsD,kBAAmBF;IAChE,OAAO,CAAC,MAAM,EAAEF,SAAS,IAAI,EAAEK,UAAU,IAAI,EAAEJ,SAAS,GAAG,CAAC;AAC9D"}
|
|
1
|
+
{"version":3,"sources":["../../src/GaugeChart/GaugeChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { formatValue, useDeepMemo, FormatOptions } from '@perses-dev/core';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { GaugeChart as EChartsGaugeChart, GaugeSeriesOption } from 'echarts/charts';\nimport { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { ReactElement } from 'react';\nimport { useChartsTheme } from '../context';\nimport { EChart } from '../EChart';\n\nuse([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst PROGRESS_WIDTH = 16;\n\n// adjusts when to show pointer icon\nconst GAUGE_SMALL_BREAKPOINT = 170;\n\nexport type GaugeChartValue = number | null | undefined;\n\nexport type GaugeSeries = {\n value: GaugeChartValue;\n label: string;\n};\n\nexport interface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeSeries;\n format: FormatOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps): ReactElement {\n const { width, height, data, format, axisLine, max } = props;\n const chartsTheme = useChartsTheme();\n\n // useDeepMemo ensures value size util does not rerun everytime you hover on the chart\n const option: EChartsCoreOption = useDeepMemo(() => {\n if (data.value === undefined) return chartsTheme.noDataOption;\n\n // adjusts fontSize depending on number of characters\n const valueSizeClamp = getResponsiveValueSize(data.value, format, width, height);\n\n return {\n title: {\n show: false,\n },\n tooltip: {\n show: false,\n },\n series: [\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '86%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n silent: true,\n progress: {\n show: true,\n width: PROGRESS_WIDTH,\n itemStyle: {\n color: 'auto',\n },\n },\n pointer: {\n show: false,\n },\n axisLine: {\n lineStyle: {\n color: [[1, 'rgba(127,127,127,0.35)']], // TODO (sjcobb): use future chart theme colors\n width: PROGRESS_WIDTH,\n },\n },\n axisTick: {\n show: false,\n distance: 0,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n distance: -18,\n color: '#999',\n fontSize: 12,\n },\n anchor: {\n show: false,\n },\n title: {\n show: false,\n },\n detail: {\n show: false,\n },\n data: [\n {\n value: data.value,\n },\n ],\n },\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '100%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n pointer: {\n show: true,\n // pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade\n icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',\n length: 10,\n width: 5,\n offsetCenter: [0, '-49%'],\n itemStyle: {\n color: 'auto',\n },\n },\n axisLine,\n axisTick: {\n show: false,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n },\n detail: {\n show: true,\n width: '60%',\n borderRadius: 8,\n offsetCenter: [0, '-9%'],\n color: 'inherit', // allows value color to match active threshold color\n fontSize: valueSizeClamp,\n formatter:\n data.value === null\n ? // We use a different function when we *know* the value is null\n // at this level because the `formatter` function argument is `NaN`\n // when the value is `null`, making it difficult to differentiate\n // `null` from a true `NaN` case.\n (): string => 'null'\n : (value: number): string | undefined => {\n return formatValue(value, format);\n },\n },\n data: [\n {\n value: data.value,\n name: data.label,\n // TODO: new UX for series names, create separate React component or reuse ListLegendItem\n // https://echarts.apache.org/en/option.html#series-gauge.data.title\n title: {\n show: true,\n color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit', // series name font color\n offsetCenter: [0, '55%'],\n overflow: 'truncate',\n fontSize: 12,\n width: width * 0.8,\n },\n },\n ],\n },\n ],\n };\n }, [data, width, height, chartsTheme, format, axisLine, max]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n padding: `${chartsTheme.container.padding.default}px`,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n );\n}\n\n/**\n * Responsive font size depending on number of characters, clamp used\n * to ensure size stays within given range\n */\nexport function getResponsiveValueSize(\n value: number | null,\n format: FormatOptions,\n width: number,\n height: number\n): string {\n const MIN_SIZE = 3;\n const MAX_SIZE = 24;\n const SIZE_MULTIPLIER = 0.7;\n const formattedValue = typeof value === 'number' ? formatValue(value, format) : `${value}`;\n const valueCharacters = formattedValue.length ?? 2;\n const valueSize = (Math.min(width, height) / valueCharacters) * SIZE_MULTIPLIER;\n return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;\n}\n"],"names":["formatValue","useDeepMemo","use","GaugeChart","EChartsGaugeChart","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","EChart","PROGRESS_WIDTH","GAUGE_SMALL_BREAKPOINT","props","width","height","data","format","axisLine","max","chartsTheme","option","value","undefined","noDataOption","valueSizeClamp","getResponsiveValueSize","title","show","tooltip","series","type","center","radius","startAngle","endAngle","min","silent","progress","itemStyle","color","pointer","lineStyle","axisTick","distance","splitLine","axisLabel","fontSize","anchor","detail","icon","length","offsetCenter","borderRadius","formatter","name","label","echartsTheme","textStyle","overflow","sx","padding","container","default","theme","MIN_SIZE","MAX_SIZE","SIZE_MULTIPLIER","formattedValue","valueCharacters","valueSize","Math"],"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,EAAEC,WAAW,QAAuB,mBAAmB;AAC3E,SAASC,GAAG,QAA2B,eAAe;AACtD,SAASC,cAAcC,iBAAiB,QAA2B,iBAAiB;AACpF,SAASC,aAAa,EAAEC,cAAc,EAAEC,gBAAgB,QAAQ,qBAAqB;AACrF,SAASC,cAAc,QAAQ,oBAAoB;AAEnD,SAASC,cAAc,QAAQ,aAAa;AAC5C,SAASC,MAAM,QAAQ,YAAY;AAEnCR,IAAI;IAACE;IAAmBC;IAAeC;IAAgBC;IAAkBC;CAAe;AAExF,MAAMG,iBAAiB;AAEvB,oCAAoC;AACpC,MAAMC,yBAAyB;AAkB/B,OAAO,SAAST,WAAWU,KAAsB;IAC/C,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,GAAG,EAAE,GAAGN;IACvD,MAAMO,cAAcX;IAEpB,sFAAsF;IACtF,MAAMY,SAA4BpB,YAAY;QAC5C,IAAIe,KAAKM,KAAK,KAAKC,WAAW,OAAOH,YAAYI,YAAY;QAE7D,qDAAqD;QACrD,MAAMC,iBAAiBC,uBAAuBV,KAAKM,KAAK,EAAEL,QAAQH,OAAOC;QAEzE,OAAO;YACLY,OAAO;gBACLC,MAAM;YACR;YACAC,SAAS;gBACPD,MAAM;YACR;YACAE,QAAQ;gBACN;oBACEC,MA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foTooltip/InfoTooltip.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, ReactNode } from 'react';\nimport {\n styled,\n TooltipProps as MuiTooltipProps,\n Tooltip as MuiTooltip,\n tooltipClasses,\n Typography,\n} from '@mui/material';\n\nexport type TooltipPlacement = 'top' | 'left' | 'right' | 'bottom';\n\ninterface InfoTooltipProps {\n description: string;\n children: ReactNode;\n id?: string;\n title?: string;\n placement?: TooltipPlacement;\n enterDelay?: number; // default is 500ms\n enterNextDelay?: number; // default is 500ms\n}\n\nexport const InfoTooltip = ({\n id,\n title,\n description,\n placement,\n children,\n enterDelay,\n enterNextDelay,\n}: InfoTooltipProps): ReactElement => {\n // Wrap children in a span to cover the following use cases:\n // - Disabled buttons. MUI console.errors on putting these inside a tooltip.\n // - Non-element tooltip children (e.g. text). The tooltip needs something that\n // can have a ref as a child.\n // We wrap in a `span` and not a `div` to minimize the impact on page layout\n // and styles.\n const wrappedChildren = <span>{children}</span>;\n\n return (\n <StyledTooltip\n arrow\n id={id}\n placement={placement ?? 'top'}\n title={<TooltipContent title={title} description={description} />}\n enterDelay={enterDelay ?? 500}\n enterNextDelay={enterNextDelay ?? 500}\n >\n {wrappedChildren}\n </StyledTooltip>\n );\n};\n\nconst TooltipContent = ({ title, description }: Pick<InfoTooltipProps, 'title' | 'description'>): ReactElement => {\n return (\n <>\n {title && (\n <Typography\n variant=\"body2\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n fontWeight: theme.typography.fontWeightMedium,\n })}\n >\n {title}\n </Typography>\n )}\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n whiteSpace: 'pre-line',\n })}\n >\n {description}\n </Typography>\n </>\n );\n};\n\nconst StyledTooltip = styled(({ className, ...props }: MuiTooltipProps) => (\n <MuiTooltip {...props} classes={{ popper: className }} />\n))(({ theme }) => ({\n [`& .${tooltipClasses.tooltip}`]: {\n backgroundColor: theme.palette.background.tooltip,\n color: theme.palette.text.primary,\n maxWidth: '300px',\n padding: theme.spacing(1),\n boxShadow: theme.shadows[1],\n },\n [`& .${tooltipClasses.arrow}`]: {\n color: theme.palette.background.tooltip,\n },\n}));\n"],"names":["styled","Tooltip","MuiTooltip","tooltipClasses","Typography","InfoTooltip","id","title","description","placement","children","enterDelay","enterNextDelay","wrappedChildren","span","StyledTooltip","arrow","TooltipContent","variant","sx","theme","color","palette","text","primary","fontWeight","typography","fontWeightMedium","whiteSpace","className","props","classes","popper","tooltip","backgroundColor","background","maxWidth","padding","spacing","boxShadow","shadows"],"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;;AAGjC,SACEA,MAAM,EAENC,WAAWC,UAAU,EACrBC,cAAc,EACdC,UAAU,QACL,gBAAgB;AAcvB,OAAO,MAAMC,cAAc,CAAC,EAC1BC,EAAE,EACFC,KAAK,EACLC,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,UAAU,EACVC,cAAc,EACG;IACjB,4DAA4D;IAC5D,6EAA6E;IAC7E,gFAAgF;IAChF,+BAA+B;IAC/B,4EAA4E;IAC5E,cAAc;IACd,MAAMC,gCAAkB,KAACC;kBAAMJ;;IAE/B,qBACE,KAACK;QACCC,KAAK;QACLV,IAAIA;QACJG,WAAWA,aAAa;QACxBF,qBAAO,KAACU;YAAeV,OAAOA;YAAOC,aAAaA;;QAClDG,YAAYA,cAAc;QAC1BC,gBAAgBA,kBAAkB;kBAEjCC;;AAGP,EAAE;AAEF,MAAMI,iBAAiB,CAAC,EAAEV,KAAK,EAAEC,WAAW,EAAmD;IAC7F,qBACE;;YACGD,uBACC,KAACH;gBACCc,SAAQ;gBACRC,IAAI,CAACC,QAAW,CAAA;wBACdC,OAAOD,MAAME,OAAO,CAACC,IAAI,CAACC,OAAO;wBACjCC,YAAYL,MAAMM,UAAU,CAACC,gBAAgB;oBAC/C,CAAA;0BAECpB;;0BAGL,KAACH;gBACCc,SAAQ;gBACRC,IAAI,CAACC,QAAW,CAAA;wBACdC,OAAOD,MAAME,OAAO,CAACC,IAAI,CAACC,OAAO;wBACjCI,YAAY;oBACd,CAAA;0BAECpB;;;;AAIT;AAEA,MAAMO,gBAAgBf,OAAO,CAAC,EAAE6B,SAAS,EAAE,GAAGC,OAAwB,iBACpE,KAAC5B;QAAY,GAAG4B,KAAK;QAAEC,SAAS;YAAEC,QAAQH;QAAU;QACnD,CAAC,EAAET,KAAK,EAAE,GAAM,CAAA;QACjB,CAAC,CAAC,GAAG,EAAEjB,eAAe8B,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../src/InfoTooltip/InfoTooltip.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, ReactNode } from 'react';\nimport {\n styled,\n TooltipProps as MuiTooltipProps,\n Tooltip as MuiTooltip,\n tooltipClasses,\n Typography,\n} from '@mui/material';\n\nexport type TooltipPlacement = 'top' | 'left' | 'right' | 'bottom';\n\ninterface InfoTooltipProps {\n description: string;\n children: ReactNode;\n id?: string;\n title?: string;\n placement?: TooltipPlacement;\n enterDelay?: number; // default is 500ms\n enterNextDelay?: number; // default is 500ms\n}\n\nexport const InfoTooltip = ({\n id,\n title,\n description,\n placement,\n children,\n enterDelay,\n enterNextDelay,\n}: InfoTooltipProps): ReactElement => {\n // Wrap children in a span to cover the following use cases:\n // - Disabled buttons. MUI console.errors on putting these inside a tooltip.\n // - Non-element tooltip children (e.g. text). The tooltip needs something that\n // can have a ref as a child.\n // We wrap in a `span` and not a `div` to minimize the impact on page layout\n // and styles.\n const wrappedChildren = <span>{children}</span>;\n\n return (\n <StyledTooltip\n arrow\n id={id}\n placement={placement ?? 'top'}\n title={<TooltipContent title={title} description={description} />}\n enterDelay={enterDelay ?? 500}\n enterNextDelay={enterNextDelay ?? 500}\n >\n {wrappedChildren}\n </StyledTooltip>\n );\n};\n\nconst TooltipContent = ({ title, description }: Pick<InfoTooltipProps, 'title' | 'description'>): ReactElement => {\n return (\n <>\n {title && (\n <Typography\n variant=\"body2\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n fontWeight: theme.typography.fontWeightMedium,\n })}\n >\n {title}\n </Typography>\n )}\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.text.primary,\n whiteSpace: 'pre-line',\n })}\n >\n {description}\n </Typography>\n </>\n );\n};\n\nconst StyledTooltip = styled(({ className, ...props }: MuiTooltipProps) => (\n <MuiTooltip {...props} classes={{ popper: className }} />\n))(({ theme }) => ({\n [`& .${tooltipClasses.tooltip}`]: {\n backgroundColor: theme.palette.background.tooltip,\n color: theme.palette.text.primary,\n maxWidth: '300px',\n padding: theme.spacing(1),\n boxShadow: theme.shadows[1],\n },\n [`& .${tooltipClasses.arrow}`]: {\n color: theme.palette.background.tooltip,\n },\n}));\n"],"names":["styled","Tooltip","MuiTooltip","tooltipClasses","Typography","InfoTooltip","id","title","description","placement","children","enterDelay","enterNextDelay","wrappedChildren","span","StyledTooltip","arrow","TooltipContent","variant","sx","theme","color","palette","text","primary","fontWeight","typography","fontWeightMedium","whiteSpace","className","props","classes","popper","tooltip","backgroundColor","background","maxWidth","padding","spacing","boxShadow","shadows"],"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;;AAGjC,SACEA,MAAM,EAENC,WAAWC,UAAU,EACrBC,cAAc,EACdC,UAAU,QACL,gBAAgB;AAcvB,OAAO,MAAMC,cAAc,CAAC,EAC1BC,EAAE,EACFC,KAAK,EACLC,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,UAAU,EACVC,cAAc,EACG;IACjB,4DAA4D;IAC5D,6EAA6E;IAC7E,gFAAgF;IAChF,+BAA+B;IAC/B,4EAA4E;IAC5E,cAAc;IACd,MAAMC,gCAAkB,KAACC;kBAAMJ;;IAE/B,qBACE,KAACK;QACCC,KAAK;QACLV,IAAIA;QACJG,WAAWA,aAAa;QACxBF,qBAAO,KAACU;YAAeV,OAAOA;YAAOC,aAAaA;;QAClDG,YAAYA,cAAc;QAC1BC,gBAAgBA,kBAAkB;kBAEjCC;;AAGP,EAAE;AAEF,MAAMI,iBAAiB,CAAC,EAAEV,KAAK,EAAEC,WAAW,EAAmD;IAC7F,qBACE;;YACGD,uBACC,KAACH;gBACCc,SAAQ;gBACRC,IAAI,CAACC,QAAW,CAAA;wBACdC,OAAOD,MAAME,OAAO,CAACC,IAAI,CAACC,OAAO;wBACjCC,YAAYL,MAAMM,UAAU,CAACC,gBAAgB;oBAC/C,CAAA;0BAECpB;;0BAGL,KAACH;gBACCc,SAAQ;gBACRC,IAAI,CAACC,QAAW,CAAA;wBACdC,OAAOD,MAAME,OAAO,CAACC,IAAI,CAACC,OAAO;wBACjCI,YAAY;oBACd,CAAA;0BAECpB;;;;AAIT;AAEA,MAAMO,gBAAgBf,OAAO,CAAC,EAAE6B,SAAS,EAAE,GAAGC,OAAwB,iBACpE,KAAC5B;QAAY,GAAG4B,KAAK;QAAEC,SAAS;YAAEC,QAAQH;QAAU;QACnD,CAAC,EAAET,KAAK,EAAE,GAAM,CAAA;QACjB,CAAC,CAAC,GAAG,EAAEjB,eAAe8B,OAAO,EAAE,CAAC,EAAE;YAChCC,iBAAiBd,MAAME,OAAO,CAACa,UAAU,CAACF,OAAO;YACjDZ,OAAOD,MAAME,OAAO,CAACC,IAAI,CAACC,OAAO;YACjCY,UAAU;YACVC,SAASjB,MAAMkB,OAAO,CAAC;YACvBC,WAAWnB,MAAMoB,OAAO,CAAC,EAAE;QAC7B;QACA,CAAC,CAAC,GAAG,EAAErC,eAAea,KAAK,EAAE,CAAC,EAAE;YAC9BK,OAAOD,MAAME,OAAO,CAACa,UAAU,CAACF,OAAO;QACzC;IACF,CAAA"}
|
package/dist/JSONEditor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/JSONEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useEffect, useState } from 'react';\nimport CodeMirror from '@uiw/react-codemirror';\nimport { json, jsonParseLinter } from '@codemirror/lang-json';\nimport { linter, lintGutter } from '@codemirror/lint';\nimport { useTheme } from '@mui/material';\nimport { ReactCodeMirrorProps } from '@uiw/react-codemirror/src';\n\ntype JSONEditorProps<T> = Omit<ReactCodeMirrorProps, 'onBlur' | 'theme' | 'extensions' | 'onChange' | 'value'> & {\n value: T;\n placeholder?: string;\n onChange?: (next: string) => void;\n};\n\nexport function JSONEditor<T>(props: JSONEditorProps<T>): ReactElement {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n\n const [value, setValue] = useState(() => JSON.stringify(props.value, null, 2));\n const [lastProcessedValue, setLastProcessedValue] = useState<string>(value);\n\n useEffect(() => {\n setValue(JSON.stringify(props.value, null, 2));\n }, [props.value]);\n\n return (\n <CodeMirror\n {...props}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n extensions={[json(), linter(jsonParseLinter()), lintGutter()]}\n value={value}\n onChange={(newValue) => {\n setValue(newValue);\n }}\n onBlur={() => {\n // Don't trigger the provided onChange if the last processed value is equal to the current value.\n // This prevents e.g CTRL+F to trigger value refresh downstream, which would cause the embedded\n // find & replace interface to close immediately.\n if (lastProcessedValue !== value && props.onChange !== undefined) {\n props.onChange(value);\n setLastProcessedValue(value);\n }\n }}\n placeholder={props.placeholder}\n />\n );\n}\n"],"names":["useEffect","useState","CodeMirror","json","jsonParseLinter","linter","lintGutter","useTheme","JSONEditor","props","theme","isDarkMode","palette","mode","value","setValue","JSON","stringify","lastProcessedValue","setLastProcessedValue","style","border","divider","extensions","onChange","newValue","onBlur","undefined","placeholder"],"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,SAAuBA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAC1D,OAAOC,gBAAgB,wBAAwB;AAC/C,SAASC,IAAI,EAAEC,eAAe,QAAQ,wBAAwB;AAC9D,SAASC,MAAM,EAAEC,UAAU,QAAQ,mBAAmB;AACtD,SAASC,QAAQ,QAAQ,gBAAgB;AASzC,OAAO,SAASC,WAAcC,KAAyB;IACrD,MAAMC,QAAQH;IACd,MAAMI,aAAaD,MAAME,OAAO,CAACC,IAAI,KAAK;IAE1C,MAAM,CAACC,OAAOC,SAAS,GAAGd,SAAS,IAAMe,KAAKC,SAAS,CAACR,MAAMK,KAAK,EAAE,MAAM;IAC3E,MAAM,CAACI,oBAAoBC,sBAAsB,GAAGlB,SAAiBa;IAErEd,UAAU;QACRe,SAASC,KAAKC,SAAS,CAACR,MAAMK,KAAK,EAAE,MAAM;IAC7C,GAAG;QAACL,MAAMK,KAAK;KAAC;IAEhB,qBACE,KAACZ;QACE,GAAGO,KAAK;QACTW,OAAO;YAAEC,QAAQ,CAAC,UAAU,EAAEX,MAAME,OAAO,CAACU,OAAO,
|
|
1
|
+
{"version":3,"sources":["../src/JSONEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useEffect, useState } from 'react';\nimport CodeMirror from '@uiw/react-codemirror';\nimport { json, jsonParseLinter } from '@codemirror/lang-json';\nimport { linter, lintGutter } from '@codemirror/lint';\nimport { useTheme } from '@mui/material';\nimport { ReactCodeMirrorProps } from '@uiw/react-codemirror/src';\n\ntype JSONEditorProps<T> = Omit<ReactCodeMirrorProps, 'onBlur' | 'theme' | 'extensions' | 'onChange' | 'value'> & {\n value: T;\n placeholder?: string;\n onChange?: (next: string) => void;\n};\n\nexport function JSONEditor<T>(props: JSONEditorProps<T>): ReactElement {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n\n const [value, setValue] = useState(() => JSON.stringify(props.value, null, 2));\n const [lastProcessedValue, setLastProcessedValue] = useState<string>(value);\n\n useEffect(() => {\n setValue(JSON.stringify(props.value, null, 2));\n }, [props.value]);\n\n return (\n <CodeMirror\n {...props}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n extensions={[json(), linter(jsonParseLinter()), lintGutter()]}\n value={value}\n onChange={(newValue) => {\n setValue(newValue);\n }}\n onBlur={() => {\n // Don't trigger the provided onChange if the last processed value is equal to the current value.\n // This prevents e.g CTRL+F to trigger value refresh downstream, which would cause the embedded\n // find & replace interface to close immediately.\n if (lastProcessedValue !== value && props.onChange !== undefined) {\n props.onChange(value);\n setLastProcessedValue(value);\n }\n }}\n placeholder={props.placeholder}\n />\n );\n}\n"],"names":["useEffect","useState","CodeMirror","json","jsonParseLinter","linter","lintGutter","useTheme","JSONEditor","props","theme","isDarkMode","palette","mode","value","setValue","JSON","stringify","lastProcessedValue","setLastProcessedValue","style","border","divider","extensions","onChange","newValue","onBlur","undefined","placeholder"],"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,SAAuBA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAC1D,OAAOC,gBAAgB,wBAAwB;AAC/C,SAASC,IAAI,EAAEC,eAAe,QAAQ,wBAAwB;AAC9D,SAASC,MAAM,EAAEC,UAAU,QAAQ,mBAAmB;AACtD,SAASC,QAAQ,QAAQ,gBAAgB;AASzC,OAAO,SAASC,WAAcC,KAAyB;IACrD,MAAMC,QAAQH;IACd,MAAMI,aAAaD,MAAME,OAAO,CAACC,IAAI,KAAK;IAE1C,MAAM,CAACC,OAAOC,SAAS,GAAGd,SAAS,IAAMe,KAAKC,SAAS,CAACR,MAAMK,KAAK,EAAE,MAAM;IAC3E,MAAM,CAACI,oBAAoBC,sBAAsB,GAAGlB,SAAiBa;IAErEd,UAAU;QACRe,SAASC,KAAKC,SAAS,CAACR,MAAMK,KAAK,EAAE,MAAM;IAC7C,GAAG;QAACL,MAAMK,KAAK;KAAC;IAEhB,qBACE,KAACZ;QACE,GAAGO,KAAK;QACTW,OAAO;YAAEC,QAAQ,CAAC,UAAU,EAAEX,MAAME,OAAO,CAACU,OAAO,EAAE;QAAC;QACtDZ,OAAOC,aAAa,SAAS;QAC7BY,YAAY;YAACpB;YAAQE,OAAOD;YAAoBE;SAAa;QAC7DQ,OAAOA;QACPU,UAAU,CAACC;YACTV,SAASU;QACX;QACAC,QAAQ;YACN,iGAAiG;YACjG,+FAA+F;YAC/F,iDAAiD;YACjD,IAAIR,uBAAuBJ,SAASL,MAAMe,QAAQ,KAAKG,WAAW;gBAChElB,MAAMe,QAAQ,CAACV;gBACfK,sBAAsBL;YACxB;QACF;QACAc,aAAanB,MAAMmB,WAAW;;AAGpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/OptionsEditorLayout/OptionsEditorControl.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormControl, FormLabel, FormControlLabelProps, Stack, Box, IconButton } from '@mui/material';\nimport React, { ReactElement } from 'react';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport { useId } from '../utils';\nimport { InfoTooltip } from '../InfoTooltip';\n\nexport type OptionsEditorControlProps = Pick<FormControlLabelProps, 'label' | 'control'> & {\n description?: string;\n};\n\nexport const OptionsEditorControl = ({ label, control, description }: OptionsEditorControlProps): ReactElement => {\n // Make sure we have a unique ID we can use for associating labels and\n // controls for a11y.\n const generatedControlId = useId('EditorSectionControl');\n const controlId = `${generatedControlId}-control`;\n\n const controlProps = {\n id: controlId,\n };\n\n return (\n <FormControl>\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\">\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"center\">\n <FormLabel htmlFor={controlId}>{label}</FormLabel>\n {description && (\n <InfoTooltip description={description} enterDelay={100}>\n <IconButton\n size=\"small\"\n sx={(theme) => ({ borderRadius: theme.shape.borderRadius, padding: '4x', margin: '0 2px' })}\n >\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n fontSize=\"inherit\"\n sx={{ color: (theme) => theme.palette.grey[700] }}\n />\n </IconButton>\n </InfoTooltip>\n )}\n </Stack>\n <Box sx={{ width: '180px', textAlign: 'right' }}> {React.cloneElement(control, controlProps)}</Box>\n </Stack>\n </FormControl>\n );\n};\n"],"names":["FormControl","FormLabel","Stack","Box","IconButton","React","InformationOutlineIcon","useId","InfoTooltip","OptionsEditorControl","label","control","description","generatedControlId","controlId","controlProps","id","direction","alignItems","justifyContent","htmlFor","enterDelay","size","sx","theme","borderRadius","shape","padding","margin","aria-describedby","aria-hidden","fontSize","color","palette","grey","width","textAlign","cloneElement"],"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,EAAEC,SAAS,EAAyBC,KAAK,EAAEC,GAAG,EAAEC,UAAU,QAAQ,gBAAgB;AACtG,OAAOC,WAA6B,QAAQ;AAC5C,OAAOC,4BAA4B,qCAAqC;AACxE,SAASC,KAAK,QAAQ,WAAW;AACjC,SAASC,WAAW,QAAQ,iBAAiB;AAM7C,OAAO,MAAMC,uBAAuB,CAAC,EAAEC,KAAK,EAAEC,OAAO,EAAEC,WAAW,EAA6B;IAC7F,sEAAsE;IACtE,qBAAqB;IACrB,MAAMC,qBAAqBN,MAAM;IACjC,MAAMO,YAAY,
|
|
1
|
+
{"version":3,"sources":["../../src/OptionsEditorLayout/OptionsEditorControl.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormControl, FormLabel, FormControlLabelProps, Stack, Box, IconButton } from '@mui/material';\nimport React, { ReactElement } from 'react';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport { useId } from '../utils';\nimport { InfoTooltip } from '../InfoTooltip';\n\nexport type OptionsEditorControlProps = Pick<FormControlLabelProps, 'label' | 'control'> & {\n description?: string;\n};\n\nexport const OptionsEditorControl = ({ label, control, description }: OptionsEditorControlProps): ReactElement => {\n // Make sure we have a unique ID we can use for associating labels and\n // controls for a11y.\n const generatedControlId = useId('EditorSectionControl');\n const controlId = `${generatedControlId}-control`;\n\n const controlProps = {\n id: controlId,\n };\n\n return (\n <FormControl>\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\">\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"center\">\n <FormLabel htmlFor={controlId}>{label}</FormLabel>\n {description && (\n <InfoTooltip description={description} enterDelay={100}>\n <IconButton\n size=\"small\"\n sx={(theme) => ({ borderRadius: theme.shape.borderRadius, padding: '4x', margin: '0 2px' })}\n >\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n fontSize=\"inherit\"\n sx={{ color: (theme) => theme.palette.grey[700] }}\n />\n </IconButton>\n </InfoTooltip>\n )}\n </Stack>\n <Box sx={{ width: '180px', textAlign: 'right' }}> {React.cloneElement(control, controlProps)}</Box>\n </Stack>\n </FormControl>\n );\n};\n"],"names":["FormControl","FormLabel","Stack","Box","IconButton","React","InformationOutlineIcon","useId","InfoTooltip","OptionsEditorControl","label","control","description","generatedControlId","controlId","controlProps","id","direction","alignItems","justifyContent","htmlFor","enterDelay","size","sx","theme","borderRadius","shape","padding","margin","aria-describedby","aria-hidden","fontSize","color","palette","grey","width","textAlign","cloneElement"],"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,EAAEC,SAAS,EAAyBC,KAAK,EAAEC,GAAG,EAAEC,UAAU,QAAQ,gBAAgB;AACtG,OAAOC,WAA6B,QAAQ;AAC5C,OAAOC,4BAA4B,qCAAqC;AACxE,SAASC,KAAK,QAAQ,WAAW;AACjC,SAASC,WAAW,QAAQ,iBAAiB;AAM7C,OAAO,MAAMC,uBAAuB,CAAC,EAAEC,KAAK,EAAEC,OAAO,EAAEC,WAAW,EAA6B;IAC7F,sEAAsE;IACtE,qBAAqB;IACrB,MAAMC,qBAAqBN,MAAM;IACjC,MAAMO,YAAY,GAAGD,mBAAmB,QAAQ,CAAC;IAEjD,MAAME,eAAe;QACnBC,IAAIF;IACN;IAEA,qBACE,KAACd;kBACC,cAAA,MAACE;YAAMe,WAAU;YAAMC,YAAW;YAASC,gBAAe;;8BACxD,MAACjB;oBAAMe,WAAU;oBAAMC,YAAW;oBAASC,gBAAe;;sCACxD,KAAClB;4BAAUmB,SAASN;sCAAYJ;;wBAC/BE,6BACC,KAACJ;4BAAYI,aAAaA;4BAAaS,YAAY;sCACjD,cAAA,KAACjB;gCACCkB,MAAK;gCACLC,IAAI,CAACC,QAAW,CAAA;wCAAEC,cAAcD,MAAME,KAAK,CAACD,YAAY;wCAAEE,SAAS;wCAAMC,QAAQ;oCAAQ,CAAA;0CAEzF,cAAA,KAACtB;oCACCuB,oBAAiB;oCACjBC,eAAa;oCACbC,UAAS;oCACTR,IAAI;wCAAES,OAAO,CAACR,QAAUA,MAAMS,OAAO,CAACC,IAAI,CAAC,IAAI;oCAAC;;;;;;8BAM1D,MAAC/B;oBAAIoB,IAAI;wBAAEY,OAAO;wBAASC,WAAW;oBAAQ;;wBAAG;sCAAE/B,MAAMgC,YAAY,CAAC1B,SAASI;;;;;;AAIvF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Overlay/Overlay.tsx"],"sourcesContent":["// Copyright 2024 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 { Skeleton, SkeletonOwnProps, Stack, Typography } from '@mui/material';\nimport { ReactElement } from 'react';\n\ninterface TextOverlayProps {\n message: string;\n}\n\nexport function TextOverlay(props: TextOverlayProps): ReactElement {\n const { message } = props;\n\n return (\n <Stack sx={{ height: '100%', alignItems: 'center', justifyContent: 'center' }}>\n <Typography>{message}</Typography>\n </Stack>\n );\n}\n\ninterface NoDataOverlayProps {\n resource: string;\n}\n\nexport function NoDataOverlay(props: NoDataOverlayProps): ReactElement {\n const { resource } = props;\n\n return <TextOverlay message={`No ${resource}`} />;\n}\n\ninterface LoadingOverlayProps {\n variant?: SkeletonOwnProps['variant'];\n}\n\nexport function LoadingOverlay(props: LoadingOverlayProps): ReactElement {\n const { variant = 'rounded' } = props;\n\n return (\n <Stack sx={{ height: '100%', alignItems: 'center', justifyContent: 'center', px: 1 }}>\n <Skeleton variant={variant} width=\"100%\" height=\"30%\" aria-label=\"Loading...\" />\n </Stack>\n );\n}\n"],"names":["Skeleton","Stack","Typography","TextOverlay","props","message","sx","height","alignItems","justifyContent","NoDataOverlay","resource","LoadingOverlay","variant","px","width","aria-label"],"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,QAAQ,EAAoBC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAO9E,OAAO,SAASC,YAAYC,KAAuB;IACjD,MAAM,EAAEC,OAAO,EAAE,GAAGD;IAEpB,qBACE,KAACH;QAAMK,IAAI;YAAEC,QAAQ;YAAQC,YAAY;YAAUC,gBAAgB;QAAS;kBAC1E,cAAA,KAACP;sBAAYG;;;AAGnB;AAMA,OAAO,SAASK,cAAcN,KAAyB;IACrD,MAAM,EAAEO,QAAQ,EAAE,GAAGP;IAErB,qBAAO,KAACD;QAAYE,SAAS,CAAC,GAAG,EAAEM,
|
|
1
|
+
{"version":3,"sources":["../../src/Overlay/Overlay.tsx"],"sourcesContent":["// Copyright 2024 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 { Skeleton, SkeletonOwnProps, Stack, Typography } from '@mui/material';\nimport { ReactElement } from 'react';\n\ninterface TextOverlayProps {\n message: string;\n}\n\nexport function TextOverlay(props: TextOverlayProps): ReactElement {\n const { message } = props;\n\n return (\n <Stack sx={{ height: '100%', alignItems: 'center', justifyContent: 'center' }}>\n <Typography>{message}</Typography>\n </Stack>\n );\n}\n\ninterface NoDataOverlayProps {\n resource: string;\n}\n\nexport function NoDataOverlay(props: NoDataOverlayProps): ReactElement {\n const { resource } = props;\n\n return <TextOverlay message={`No ${resource}`} />;\n}\n\ninterface LoadingOverlayProps {\n variant?: SkeletonOwnProps['variant'];\n}\n\nexport function LoadingOverlay(props: LoadingOverlayProps): ReactElement {\n const { variant = 'rounded' } = props;\n\n return (\n <Stack sx={{ height: '100%', alignItems: 'center', justifyContent: 'center', px: 1 }}>\n <Skeleton variant={variant} width=\"100%\" height=\"30%\" aria-label=\"Loading...\" />\n </Stack>\n );\n}\n"],"names":["Skeleton","Stack","Typography","TextOverlay","props","message","sx","height","alignItems","justifyContent","NoDataOverlay","resource","LoadingOverlay","variant","px","width","aria-label"],"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,QAAQ,EAAoBC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAO9E,OAAO,SAASC,YAAYC,KAAuB;IACjD,MAAM,EAAEC,OAAO,EAAE,GAAGD;IAEpB,qBACE,KAACH;QAAMK,IAAI;YAAEC,QAAQ;YAAQC,YAAY;YAAUC,gBAAgB;QAAS;kBAC1E,cAAA,KAACP;sBAAYG;;;AAGnB;AAMA,OAAO,SAASK,cAAcN,KAAyB;IACrD,MAAM,EAAEO,QAAQ,EAAE,GAAGP;IAErB,qBAAO,KAACD;QAAYE,SAAS,CAAC,GAAG,EAAEM,UAAU;;AAC/C;AAMA,OAAO,SAASC,eAAeR,KAA0B;IACvD,MAAM,EAAES,UAAU,SAAS,EAAE,GAAGT;IAEhC,qBACE,KAACH;QAAMK,IAAI;YAAEC,QAAQ;YAAQC,YAAY;YAAUC,gBAAgB;YAAUK,IAAI;QAAE;kBACjF,cAAA,KAACd;YAASa,SAASA;YAASE,OAAM;YAAOR,QAAO;YAAMS,cAAW;;;AAGvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/RefreshIntervalPicker/RefreshIntervalPicker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, FormControl, MenuItem, Select } from '@mui/material';\nimport { DurationString } from '@perses-dev/core';\nimport { ReactElement, useMemo } from 'react';\nimport { TimeOption } from '../model';\n\ninterface RefreshIntervalPickerProps {\n timeOptions: TimeOption[];\n value?: DurationString;\n onChange: (value: DurationString) => void;\n height?: string;\n}\n\nexport function RefreshIntervalPicker(props: RefreshIntervalPickerProps): ReactElement {\n const { value, onChange, timeOptions, height } = props;\n const formattedValue = value;\n\n // If the dashboard refresh interval is not provided in timeOptions, it will create a specific option for the select\n const customInterval = useMemo(() => {\n if (value && !timeOptions.some((option) => option.value.pastDuration === value)) {\n return <MenuItem value={value}>{value}</MenuItem>;\n }\n }, [timeOptions, value]);\n\n return (\n <FormControl>\n <Box>\n <Select\n id=\"refreshInterval\"\n value={formattedValue}\n onChange={(event) => {\n const duration = event.target.value as DurationString;\n onChange(duration);\n }}\n inputProps={{\n 'aria-label': `Select refresh interval. Currently set to ${formattedValue}`,\n }}\n sx={{\n '.MuiSelect-select': height ? { lineHeight: height, paddingY: 0 } : {},\n }}\n >\n {timeOptions.map((item, idx) => (\n <MenuItem key={idx} value={item.value.pastDuration}>\n {item.display}\n </MenuItem>\n ))}\n {customInterval}\n </Select>\n </Box>\n </FormControl>\n );\n}\n"],"names":["Box","FormControl","MenuItem","Select","useMemo","RefreshIntervalPicker","props","value","onChange","timeOptions","height","formattedValue","customInterval","some","option","pastDuration","id","event","duration","target","inputProps","sx","lineHeight","paddingY","map","item","idx","display"],"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,GAAG,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,gBAAgB;AAEnE,SAAuBC,OAAO,QAAQ,QAAQ;AAU9C,OAAO,SAASC,sBAAsBC,KAAiC;IACrE,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,MAAM,EAAE,GAAGJ;IACjD,MAAMK,iBAAiBJ;IAEvB,oHAAoH;IACpH,MAAMK,iBAAiBR,QAAQ;QAC7B,IAAIG,SAAS,CAACE,YAAYI,IAAI,CAAC,CAACC,SAAWA,OAAOP,KAAK,CAACQ,YAAY,KAAKR,QAAQ;YAC/E,qBAAO,KAACL;gBAASK,OAAOA;0BAAQA;;QAClC;IACF,GAAG;QAACE;QAAaF;KAAM;IAEvB,qBACE,KAACN;kBACC,cAAA,KAACD;sBACC,cAAA,MAACG;gBACCa,IAAG;gBACHT,OAAOI;gBACPH,UAAU,CAACS;oBACT,MAAMC,WAAWD,MAAME,MAAM,CAACZ,KAAK;oBACnCC,SAASU;gBACX;gBACAE,YAAY;oBACV,cAAc,CAAC,0CAA0C,EAAET,
|
|
1
|
+
{"version":3,"sources":["../../src/RefreshIntervalPicker/RefreshIntervalPicker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, FormControl, MenuItem, Select } from '@mui/material';\nimport { DurationString } from '@perses-dev/core';\nimport { ReactElement, useMemo } from 'react';\nimport { TimeOption } from '../model';\n\ninterface RefreshIntervalPickerProps {\n timeOptions: TimeOption[];\n value?: DurationString;\n onChange: (value: DurationString) => void;\n height?: string;\n}\n\nexport function RefreshIntervalPicker(props: RefreshIntervalPickerProps): ReactElement {\n const { value, onChange, timeOptions, height } = props;\n const formattedValue = value;\n\n // If the dashboard refresh interval is not provided in timeOptions, it will create a specific option for the select\n const customInterval = useMemo(() => {\n if (value && !timeOptions.some((option) => option.value.pastDuration === value)) {\n return <MenuItem value={value}>{value}</MenuItem>;\n }\n }, [timeOptions, value]);\n\n return (\n <FormControl>\n <Box>\n <Select\n id=\"refreshInterval\"\n value={formattedValue}\n onChange={(event) => {\n const duration = event.target.value as DurationString;\n onChange(duration);\n }}\n inputProps={{\n 'aria-label': `Select refresh interval. Currently set to ${formattedValue}`,\n }}\n sx={{\n '.MuiSelect-select': height ? { lineHeight: height, paddingY: 0 } : {},\n }}\n >\n {timeOptions.map((item, idx) => (\n <MenuItem key={idx} value={item.value.pastDuration}>\n {item.display}\n </MenuItem>\n ))}\n {customInterval}\n </Select>\n </Box>\n </FormControl>\n );\n}\n"],"names":["Box","FormControl","MenuItem","Select","useMemo","RefreshIntervalPicker","props","value","onChange","timeOptions","height","formattedValue","customInterval","some","option","pastDuration","id","event","duration","target","inputProps","sx","lineHeight","paddingY","map","item","idx","display"],"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,GAAG,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,gBAAgB;AAEnE,SAAuBC,OAAO,QAAQ,QAAQ;AAU9C,OAAO,SAASC,sBAAsBC,KAAiC;IACrE,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,MAAM,EAAE,GAAGJ;IACjD,MAAMK,iBAAiBJ;IAEvB,oHAAoH;IACpH,MAAMK,iBAAiBR,QAAQ;QAC7B,IAAIG,SAAS,CAACE,YAAYI,IAAI,CAAC,CAACC,SAAWA,OAAOP,KAAK,CAACQ,YAAY,KAAKR,QAAQ;YAC/E,qBAAO,KAACL;gBAASK,OAAOA;0BAAQA;;QAClC;IACF,GAAG;QAACE;QAAaF;KAAM;IAEvB,qBACE,KAACN;kBACC,cAAA,KAACD;sBACC,cAAA,MAACG;gBACCa,IAAG;gBACHT,OAAOI;gBACPH,UAAU,CAACS;oBACT,MAAMC,WAAWD,MAAME,MAAM,CAACZ,KAAK;oBACnCC,SAASU;gBACX;gBACAE,YAAY;oBACV,cAAc,CAAC,0CAA0C,EAAET,gBAAgB;gBAC7E;gBACAU,IAAI;oBACF,qBAAqBX,SAAS;wBAAEY,YAAYZ;wBAAQa,UAAU;oBAAE,IAAI,CAAC;gBACvE;;oBAECd,YAAYe,GAAG,CAAC,CAACC,MAAMC,oBACtB,KAACxB;4BAAmBK,OAAOkB,KAAKlB,KAAK,CAACQ,YAAY;sCAC/CU,KAAKE,OAAO;2BADAD;oBAIhBd;;;;;AAKX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/SettingsAutocomplete/SettingsAutocomplete.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n Autocomplete,\n AutocompleteProps,\n TextField,\n Typography,\n UseAutocompleteProps,\n createFilterOptions,\n} from '@mui/material';\nimport { ReactElement, ReactNode } from 'react';\n\n/**\n * Interface to extend from for `options` when using `SettingsAutocomplete`.\n */\nexport interface SettingsAutocompleteOption {\n /**\n * Unique identifier for the option.\n */\n id: string;\n\n /**\n * Optional value that is presented to the user for each option. If not set,\n * the `id` will be used instead.\n */\n label?: string;\n\n /**\n * Optional description that will be rendered below the `label` to provide the\n * user with additional information about the option.\n */\n description?: ReactNode;\n\n /**\n * When `true`, the option will be disabled.\n */\n disabled?: boolean;\n}\n\nexport interface SettingsAutocompleteProps<\n OptionType extends SettingsAutocompleteOption,\n Multiple extends boolean | undefined,\n DisableClearable extends boolean | undefined,\n // Note that the last `false` in the generic arguments sets the `freeSolo` option to `false`.\n // This component is intended to be used with a discrete list of options, so `freeSolo` never\n // needs to be `true`.\n> extends Omit<AutocompleteProps<OptionType, Multiple, DisableClearable, false>, 'renderInput'> {\n // Modifying this to optional, so we can define a sensible default below that\n // is used in many of the simple cases.\n renderInput?: AutocompleteProps<OptionType, Multiple, DisableClearable, false>['renderInput'];\n}\n\n/**\n * Opinionated autocomplete component useful for providing users with a dropdown\n * for settings that require selecting one or more options from a list.\n *\n * **Note: This component is currently experimental and is likely to have significant breaking changes in the near future. Use with caution outside of the core Perses codebase.**\n */\nexport function SettingsAutocomplete<\n OptionType extends SettingsAutocompleteOption,\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n>({\n options,\n renderInput = (params): ReactElement => <TextField {...params} />,\n ...otherProps\n}: SettingsAutocompleteProps<OptionType, Multiple, DisableClearable>): ReactElement {\n const getOptionLabel: UseAutocompleteProps<OptionType, undefined, boolean, undefined>['getOptionLabel'] = (\n option\n ) => {\n return option.label ?? option.id;\n };\n\n // Note: this component currently is not virtualized because it is specific\n // to being used for settings, which generally have a pretty small list of\n // options. If this changes to include values with many options, virtualization\n // should be added using react-virtuoso.\n return (\n <Autocomplete\n isOptionEqualToValue={(option, value) => option.id === value.id}\n getOptionDisabled={(option) => !!option.disabled}\n getOptionLabel={getOptionLabel}\n options={options}\n renderInput={renderInput}\n renderOption={({ key, ...props }, option) => {\n return (\n <li key={key} {...props}>\n <div>\n <Typography variant=\"body1\" component=\"div\">\n {getOptionLabel(option)}\n </Typography>\n {option.description && (\n <Typography variant=\"body2\" component=\"div\" sx={{ color: (theme) => theme.palette.text.secondary }}>\n {option.description}\n </Typography>\n )}\n </div>\n </li>\n );\n }}\n filterOptions={createFilterOptions({\n // Include the label and the description in search.\n stringify: (option) => `${getOptionLabel(option)} ${option.description || ''}`,\n })}\n {...otherProps}\n />\n );\n}\n"],"names":["Autocomplete","TextField","Typography","createFilterOptions","SettingsAutocomplete","options","renderInput","params","otherProps","getOptionLabel","option","label","id","isOptionEqualToValue","value","getOptionDisabled","disabled","renderOption","key","props","li","div","variant","component","description","sx","color","theme","palette","text","secondary","filterOptions","stringify"],"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,SACEA,YAAY,EAEZC,SAAS,EACTC,UAAU,EAEVC,mBAAmB,QACd,gBAAgB;AA2CvB;;;;;CAKC,GACD,OAAO,SAASC,qBAId,EACAC,OAAO,EACPC,cAAc,CAACC,uBAAyB,KAACN;QAAW,GAAGM,MAAM;MAAI,EACjE,GAAGC,YAC+D;IAClE,MAAMC,iBAAoG,CACxGC;QAEA,OAAOA,OAAOC,KAAK,IAAID,OAAOE,EAAE;IAClC;IAEA,2EAA2E;IAC3E,0EAA0E;IAC1E,+EAA+E;IAC/E,wCAAwC;IACxC,qBACE,KAACZ;QACCa,sBAAsB,CAACH,QAAQI,QAAUJ,OAAOE,EAAE,KAAKE,MAAMF,EAAE;QAC/DG,mBAAmB,CAACL,SAAW,CAAC,CAACA,OAAOM,QAAQ;QAChDP,gBAAgBA;QAChBJ,SAASA;QACTC,aAAaA;QACbW,cAAc,CAAC,EAAEC,GAAG,EAAE,GAAGC,OAAO,EAAET;YAChC,qBACE,KAACU;gBAAc,GAAGD,KAAK;0BACrB,cAAA,MAACE;;sCACC,KAACnB;4BAAWoB,SAAQ;4BAAQC,WAAU;sCACnCd,eAAeC;;wBAEjBA,OAAOc,WAAW,kBACjB,KAACtB;4BAAWoB,SAAQ;4BAAQC,WAAU;4BAAME,IAAI;gCAAEC,OAAO,CAACC,QAAUA,MAAMC,OAAO,CAACC,IAAI,CAACC,SAAS;4BAAC;sCAC9FpB,OAAOc,WAAW;;;;eAPlBN;QAab;QACAa,eAAe5B,oBAAoB;YACjC,mDAAmD;YACnD6B,WAAW,CAACtB,SAAW,
|
|
1
|
+
{"version":3,"sources":["../../src/SettingsAutocomplete/SettingsAutocomplete.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n Autocomplete,\n AutocompleteProps,\n TextField,\n Typography,\n UseAutocompleteProps,\n createFilterOptions,\n} from '@mui/material';\nimport { ReactElement, ReactNode } from 'react';\n\n/**\n * Interface to extend from for `options` when using `SettingsAutocomplete`.\n */\nexport interface SettingsAutocompleteOption {\n /**\n * Unique identifier for the option.\n */\n id: string;\n\n /**\n * Optional value that is presented to the user for each option. If not set,\n * the `id` will be used instead.\n */\n label?: string;\n\n /**\n * Optional description that will be rendered below the `label` to provide the\n * user with additional information about the option.\n */\n description?: ReactNode;\n\n /**\n * When `true`, the option will be disabled.\n */\n disabled?: boolean;\n}\n\nexport interface SettingsAutocompleteProps<\n OptionType extends SettingsAutocompleteOption,\n Multiple extends boolean | undefined,\n DisableClearable extends boolean | undefined,\n // Note that the last `false` in the generic arguments sets the `freeSolo` option to `false`.\n // This component is intended to be used with a discrete list of options, so `freeSolo` never\n // needs to be `true`.\n> extends Omit<AutocompleteProps<OptionType, Multiple, DisableClearable, false>, 'renderInput'> {\n // Modifying this to optional, so we can define a sensible default below that\n // is used in many of the simple cases.\n renderInput?: AutocompleteProps<OptionType, Multiple, DisableClearable, false>['renderInput'];\n}\n\n/**\n * Opinionated autocomplete component useful for providing users with a dropdown\n * for settings that require selecting one or more options from a list.\n *\n * **Note: This component is currently experimental and is likely to have significant breaking changes in the near future. Use with caution outside of the core Perses codebase.**\n */\nexport function SettingsAutocomplete<\n OptionType extends SettingsAutocompleteOption,\n Multiple extends boolean | undefined = false,\n DisableClearable extends boolean | undefined = false,\n>({\n options,\n renderInput = (params): ReactElement => <TextField {...params} />,\n ...otherProps\n}: SettingsAutocompleteProps<OptionType, Multiple, DisableClearable>): ReactElement {\n const getOptionLabel: UseAutocompleteProps<OptionType, undefined, boolean, undefined>['getOptionLabel'] = (\n option\n ) => {\n return option.label ?? option.id;\n };\n\n // Note: this component currently is not virtualized because it is specific\n // to being used for settings, which generally have a pretty small list of\n // options. If this changes to include values with many options, virtualization\n // should be added using react-virtuoso.\n return (\n <Autocomplete\n isOptionEqualToValue={(option, value) => option.id === value.id}\n getOptionDisabled={(option) => !!option.disabled}\n getOptionLabel={getOptionLabel}\n options={options}\n renderInput={renderInput}\n renderOption={({ key, ...props }, option) => {\n return (\n <li key={key} {...props}>\n <div>\n <Typography variant=\"body1\" component=\"div\">\n {getOptionLabel(option)}\n </Typography>\n {option.description && (\n <Typography variant=\"body2\" component=\"div\" sx={{ color: (theme) => theme.palette.text.secondary }}>\n {option.description}\n </Typography>\n )}\n </div>\n </li>\n );\n }}\n filterOptions={createFilterOptions({\n // Include the label and the description in search.\n stringify: (option) => `${getOptionLabel(option)} ${option.description || ''}`,\n })}\n {...otherProps}\n />\n );\n}\n"],"names":["Autocomplete","TextField","Typography","createFilterOptions","SettingsAutocomplete","options","renderInput","params","otherProps","getOptionLabel","option","label","id","isOptionEqualToValue","value","getOptionDisabled","disabled","renderOption","key","props","li","div","variant","component","description","sx","color","theme","palette","text","secondary","filterOptions","stringify"],"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,SACEA,YAAY,EAEZC,SAAS,EACTC,UAAU,EAEVC,mBAAmB,QACd,gBAAgB;AA2CvB;;;;;CAKC,GACD,OAAO,SAASC,qBAId,EACAC,OAAO,EACPC,cAAc,CAACC,uBAAyB,KAACN;QAAW,GAAGM,MAAM;MAAI,EACjE,GAAGC,YAC+D;IAClE,MAAMC,iBAAoG,CACxGC;QAEA,OAAOA,OAAOC,KAAK,IAAID,OAAOE,EAAE;IAClC;IAEA,2EAA2E;IAC3E,0EAA0E;IAC1E,+EAA+E;IAC/E,wCAAwC;IACxC,qBACE,KAACZ;QACCa,sBAAsB,CAACH,QAAQI,QAAUJ,OAAOE,EAAE,KAAKE,MAAMF,EAAE;QAC/DG,mBAAmB,CAACL,SAAW,CAAC,CAACA,OAAOM,QAAQ;QAChDP,gBAAgBA;QAChBJ,SAASA;QACTC,aAAaA;QACbW,cAAc,CAAC,EAAEC,GAAG,EAAE,GAAGC,OAAO,EAAET;YAChC,qBACE,KAACU;gBAAc,GAAGD,KAAK;0BACrB,cAAA,MAACE;;sCACC,KAACnB;4BAAWoB,SAAQ;4BAAQC,WAAU;sCACnCd,eAAeC;;wBAEjBA,OAAOc,WAAW,kBACjB,KAACtB;4BAAWoB,SAAQ;4BAAQC,WAAU;4BAAME,IAAI;gCAAEC,OAAO,CAACC,QAAUA,MAAMC,OAAO,CAACC,IAAI,CAACC,SAAS;4BAAC;sCAC9FpB,OAAOc,WAAW;;;;eAPlBN;QAab;QACAa,eAAe5B,oBAAoB;YACjC,mDAAmD;YACnD6B,WAAW,CAACtB,SAAW,GAAGD,eAAeC,QAAQ,CAAC,EAAEA,OAAOc,WAAW,IAAI,IAAI;QAChF;QACC,GAAGhB,UAAU;;AAGpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/StatChart/StatChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FC, useMemo } from 'react';\nimport { FormatOptions } from '@perses-dev/core';\nimport { Box, Typography, styled } from '@mui/material';\nimport merge from 'lodash/merge';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { LineChart as EChartsLineChart, LineSeriesOption } from 'echarts/charts';\nimport { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { useChartsTheme } from '../context';\nimport { EChart } from '../EChart';\nimport { GraphSeries } from '../model';\nimport { FontSizeOption } from '../FontSizeSelector';\nimport { useOptimalFontSize } from './calculateFontSize';\nimport { formatStatChartValue } from './utils/formatStatChartValue';\n\nuse([EChartsLineChart, GridComponent, DatasetComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst LINE_HEIGHT = 1.2;\nconst SERIES_NAME_MAX_FONT_SIZE = 30;\nconst SERIES_NAME_FONT_WEIGHT = 400;\nconst VALUE_FONT_WEIGHT = 700;\n\nexport interface StatChartData {\n color: string;\n calculatedValue?: string | number | null;\n seriesData?: GraphSeries;\n}\n\nexport interface StatChartProps {\n width: number;\n height: number;\n data: StatChartData;\n format?: FormatOptions;\n sparkline?: LineSeriesOption;\n showSeriesName?: boolean;\n valueFontSize?: FontSizeOption;\n}\n\nexport const StatChart: FC<StatChartProps> = (props) => {\n const { width, height, data, sparkline, showSeriesName, format, valueFontSize } = props;\n const chartsTheme = useChartsTheme();\n const color = data.color;\n\n const formattedValue = formatStatChartValue(data.calculatedValue, format);\n\n const containerPadding = chartsTheme.container.padding.default;\n\n // calculate series name font size and height\n let seriesNameFontSize = useOptimalFontSize({\n text: data?.seriesData?.name ?? '',\n fontWeight: SERIES_NAME_FONT_WEIGHT,\n width,\n height: height * 0.125, // assume series name will take 12.5% of available height\n lineHeight: LINE_HEIGHT,\n maxSize: SERIES_NAME_MAX_FONT_SIZE,\n });\n\n const seriesNameHeight = showSeriesName ? seriesNameFontSize * LINE_HEIGHT + containerPadding : 0;\n\n // calculate value font size and height\n const availableWidth = width - containerPadding * 2;\n const availableHeight = height - seriesNameHeight;\n const optimalValueFontSize = useOptimalFontSize({\n text: formattedValue,\n // override the font size if user selects it in the settings\n fontSizeOverride: valueFontSize,\n fontWeight: VALUE_FONT_WEIGHT,\n // without sparkline, use only 50% of the available width so it looks better for multiseries\n width: sparkline ? availableWidth : availableWidth * 0.5,\n // with sparkline, use only 25% of available height to leave room for chart\n // without sparkline, value should take up 90% of available space\n height: sparkline ? availableHeight * 0.25 : availableHeight * 0.9,\n lineHeight: LINE_HEIGHT,\n });\n const valueFontHeight = optimalValueFontSize * LINE_HEIGHT;\n\n // make sure the series name font size is slightly smaller than value font size\n seriesNameFontSize = Math.min(optimalValueFontSize * 0.7, seriesNameFontSize);\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data.seriesData === undefined) return chartsTheme.noDataOption;\n\n const series = data.seriesData;\n const statSeries: LineSeriesOption[] = [];\n\n if (sparkline !== undefined) {\n const lineSeries = {\n type: 'line',\n name: series.name,\n data: series.values,\n zlevel: 1,\n symbol: 'none',\n animation: false,\n silent: true,\n };\n const mergedSeries = merge(lineSeries, sparkline);\n statSeries.push(mergedSeries);\n }\n\n const option = {\n title: {\n show: false,\n },\n grid: {\n show: false,\n top: '35%', // adds space above sparkline\n right: 0,\n bottom: 0,\n left: 0,\n containLabel: false,\n },\n xAxis: {\n type: 'time',\n show: false,\n boundaryGap: false,\n },\n yAxis: {\n type: 'value',\n show: false,\n min: (value: { min: number; max: number }): number => {\n if (value.min >= 0 && value.min <= 1) {\n // helps with percent-decimal units, or datasets that return 0 or 1 booleans\n return 0;\n }\n return value.min;\n },\n },\n tooltip: {\n show: false,\n },\n series: statSeries,\n };\n\n return option;\n }, [data, chartsTheme, sparkline]);\n\n const textAlignment = sparkline ? 'auto' : 'center';\n const textStyles = {\n display: 'flex',\n flexDirection: 'column',\n justifyContent: textAlignment,\n alignItems: textAlignment,\n };\n\n return (\n <Box sx={{ height: '100%', width: '100%', ...textStyles }}>\n {showSeriesName && (\n <SeriesName padding={containerPadding} fontSize={seriesNameFontSize}>\n {data.seriesData?.name}\n </SeriesName>\n )}\n <Value variant=\"h3\" color={color} fontSize={optimalValueFontSize} padding={containerPadding}>\n {formattedValue}\n </Value>\n {sparkline !== undefined && (\n <EChart\n sx={{\n width: '100%',\n height: height - seriesNameHeight - valueFontHeight,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n renderer=\"svg\"\n />\n )}\n </Box>\n );\n};\n\nconst SeriesName = styled(Typography, {\n shouldForwardProp: (prop) => prop !== 'padding' && prop !== 'fontSize',\n})<{ padding?: number; fontSize?: number; textAlignment?: string }>(({ theme, padding, fontSize }) => ({\n color: theme.palette.text.secondary,\n padding: `${padding}px`,\n fontSize: `${fontSize}px`,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}));\n\nconst Value = styled(Typography, {\n shouldForwardProp: (prop) => prop !== 'color' && prop !== 'padding' && prop !== 'fontSize' && prop !== 'sparkline',\n})<{ color?: string; padding?: number; fontSize?: number; sparkline?: boolean }>(\n ({ theme, color, padding, fontSize, sparkline }) => ({\n color: color ?? theme.palette.text.primary,\n fontSize: `${fontSize}px`,\n padding: sparkline ? `${padding}px ${padding}px 0 ${padding}px` : ` 0 ${padding}px`,\n whiteSpace: 'nowrap',\n lineHeight: LINE_HEIGHT,\n })\n);\n"],"names":["useMemo","Box","Typography","styled","merge","use","LineChart","EChartsLineChart","GridComponent","DatasetComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","EChart","useOptimalFontSize","formatStatChartValue","LINE_HEIGHT","SERIES_NAME_MAX_FONT_SIZE","SERIES_NAME_FONT_WEIGHT","VALUE_FONT_WEIGHT","StatChart","props","width","height","data","sparkline","showSeriesName","format","valueFontSize","chartsTheme","color","formattedValue","calculatedValue","containerPadding","container","padding","default","seriesNameFontSize","text","seriesData","name","fontWeight","lineHeight","maxSize","seriesNameHeight","availableWidth","availableHeight","optimalValueFontSize","fontSizeOverride","valueFontHeight","Math","min","option","undefined","noDataOption","series","statSeries","lineSeries","type","values","zlevel","symbol","animation","silent","mergedSeries","push","title","show","grid","top","right","bottom","left","containLabel","xAxis","boundaryGap","yAxis","value","tooltip","textAlignment","textStyles","display","flexDirection","justifyContent","alignItems","sx","SeriesName","fontSize","Value","variant","theme","echartsTheme","renderer","shouldForwardProp","prop","palette","secondary","overflow","textOverflow","whiteSpace","primary"],"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,SAAaA,OAAO,QAAQ,QAAQ;AAEpC,SAASC,GAAG,EAAE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AAO;QAC1Cb,UAAU,CAAC,EAAEA,SAAS,EAAE,CAAC;QACzBpD,SAASV,YAAY,CAAC,EAAEU,QAAQ,GAAG,EAAEA,QAAQ,KAAK,EAAEA,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,EAAEA,QAAQ,EAAE,CAAC;QACnFgE,YAAY;QACZzD,YAAY1B;IACd,CAAA"}
|
|
1
|
+
{"version":3,"sources":["../../src/StatChart/StatChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FC, useMemo } from 'react';\nimport { FormatOptions } from '@perses-dev/core';\nimport { Box, Typography, styled } from '@mui/material';\nimport merge from 'lodash/merge';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { LineChart as EChartsLineChart, LineSeriesOption } from 'echarts/charts';\nimport { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { useChartsTheme } from '../context';\nimport { EChart } from '../EChart';\nimport { GraphSeries } from '../model';\nimport { FontSizeOption } from '../FontSizeSelector';\nimport { useOptimalFontSize } from './calculateFontSize';\nimport { formatStatChartValue } from './utils/formatStatChartValue';\n\nuse([EChartsLineChart, GridComponent, DatasetComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst LINE_HEIGHT = 1.2;\nconst SERIES_NAME_MAX_FONT_SIZE = 30;\nconst SERIES_NAME_FONT_WEIGHT = 400;\nconst VALUE_FONT_WEIGHT = 700;\n\nexport interface StatChartData {\n color: string;\n calculatedValue?: string | number | null;\n seriesData?: GraphSeries;\n}\n\nexport interface StatChartProps {\n width: number;\n height: number;\n data: StatChartData;\n format?: FormatOptions;\n sparkline?: LineSeriesOption;\n showSeriesName?: boolean;\n valueFontSize?: FontSizeOption;\n}\n\nexport const StatChart: FC<StatChartProps> = (props) => {\n const { width, height, data, sparkline, showSeriesName, format, valueFontSize } = props;\n const chartsTheme = useChartsTheme();\n const color = data.color;\n\n const formattedValue = formatStatChartValue(data.calculatedValue, format);\n\n const containerPadding = chartsTheme.container.padding.default;\n\n // calculate series name font size and height\n let seriesNameFontSize = useOptimalFontSize({\n text: data?.seriesData?.name ?? '',\n fontWeight: SERIES_NAME_FONT_WEIGHT,\n width,\n height: height * 0.125, // assume series name will take 12.5% of available height\n lineHeight: LINE_HEIGHT,\n maxSize: SERIES_NAME_MAX_FONT_SIZE,\n });\n\n const seriesNameHeight = showSeriesName ? seriesNameFontSize * LINE_HEIGHT + containerPadding : 0;\n\n // calculate value font size and height\n const availableWidth = width - containerPadding * 2;\n const availableHeight = height - seriesNameHeight;\n const optimalValueFontSize = useOptimalFontSize({\n text: formattedValue,\n // override the font size if user selects it in the settings\n fontSizeOverride: valueFontSize,\n fontWeight: VALUE_FONT_WEIGHT,\n // without sparkline, use only 50% of the available width so it looks better for multiseries\n width: sparkline ? availableWidth : availableWidth * 0.5,\n // with sparkline, use only 25% of available height to leave room for chart\n // without sparkline, value should take up 90% of available space\n height: sparkline ? availableHeight * 0.25 : availableHeight * 0.9,\n lineHeight: LINE_HEIGHT,\n });\n const valueFontHeight = optimalValueFontSize * LINE_HEIGHT;\n\n // make sure the series name font size is slightly smaller than value font size\n seriesNameFontSize = Math.min(optimalValueFontSize * 0.7, seriesNameFontSize);\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data.seriesData === undefined) return chartsTheme.noDataOption;\n\n const series = data.seriesData;\n const statSeries: LineSeriesOption[] = [];\n\n if (sparkline !== undefined) {\n const lineSeries = {\n type: 'line',\n name: series.name,\n data: series.values,\n zlevel: 1,\n symbol: 'none',\n animation: false,\n silent: true,\n };\n const mergedSeries = merge(lineSeries, sparkline);\n statSeries.push(mergedSeries);\n }\n\n const option = {\n title: {\n show: false,\n },\n grid: {\n show: false,\n top: '35%', // adds space above sparkline\n right: 0,\n bottom: 0,\n left: 0,\n containLabel: false,\n },\n xAxis: {\n type: 'time',\n show: false,\n boundaryGap: false,\n },\n yAxis: {\n type: 'value',\n show: false,\n min: (value: { min: number; max: number }): number => {\n if (value.min >= 0 && value.min <= 1) {\n // helps with percent-decimal units, or datasets that return 0 or 1 booleans\n return 0;\n }\n return value.min;\n },\n },\n tooltip: {\n show: false,\n },\n series: statSeries,\n };\n\n return option;\n }, [data, chartsTheme, sparkline]);\n\n const textAlignment = sparkline ? 'auto' : 'center';\n const textStyles = {\n display: 'flex',\n flexDirection: 'column',\n justifyContent: textAlignment,\n alignItems: textAlignment,\n };\n\n return (\n <Box sx={{ height: '100%', width: '100%', ...textStyles }}>\n {showSeriesName && (\n <SeriesName padding={containerPadding} fontSize={seriesNameFontSize}>\n {data.seriesData?.name}\n </SeriesName>\n )}\n <Value variant=\"h3\" color={color} fontSize={optimalValueFontSize} padding={containerPadding}>\n {formattedValue}\n </Value>\n {sparkline !== undefined && (\n <EChart\n sx={{\n width: '100%',\n height: height - seriesNameHeight - valueFontHeight,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n renderer=\"svg\"\n />\n )}\n </Box>\n );\n};\n\nconst SeriesName = styled(Typography, {\n shouldForwardProp: (prop) => prop !== 'padding' && prop !== 'fontSize',\n})<{ padding?: number; fontSize?: number; textAlignment?: string }>(({ theme, padding, fontSize }) => ({\n color: theme.palette.text.secondary,\n padding: `${padding}px`,\n fontSize: `${fontSize}px`,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}));\n\nconst Value = styled(Typography, {\n shouldForwardProp: (prop) => prop !== 'color' && prop !== 'padding' && prop !== 'fontSize' && prop !== 'sparkline',\n})<{ color?: string; padding?: number; fontSize?: number; sparkline?: boolean }>(\n ({ theme, color, padding, fontSize, sparkline }) => ({\n color: color ?? theme.palette.text.primary,\n fontSize: `${fontSize}px`,\n padding: sparkline ? `${padding}px ${padding}px 0 ${padding}px` : ` 0 ${padding}px`,\n whiteSpace: 'nowrap',\n lineHeight: LINE_HEIGHT,\n })\n);\n"],"names":["useMemo","Box","Typography","styled","merge","use","LineChart","EChartsLineChart","GridComponent","DatasetComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","EChart","useOptimalFontSize","formatStatChartValue","LINE_HEIGHT","SERIES_NAME_MAX_FONT_SIZE","SERIES_NAME_FONT_WEIGHT","VALUE_FONT_WEIGHT","StatChart","props","width","height","data","sparkline","showSeriesName","format","valueFontSize","chartsTheme","color","formattedValue","calculatedValue","containerPadding","container","padding","default","seriesNameFontSize","text","seriesData","name","fontWeight","lineHeight","maxSize","seriesNameHeight","availableWidth","availableHeight","optimalValueFontSize","fontSizeOverride","valueFontHeight","Math","min","option","undefined","noDataOption","series","statSeries","lineSeries","type","values","zlevel","symbol","animation","silent","mergedSeries","push","title","show","grid","top","right","bottom","left","containLabel","xAxis","boundaryGap","yAxis","value","tooltip","textAlignment","textStyles","display","flexDirection","justifyContent","alignItems","sx","SeriesName","fontSize","Value","variant","theme","echartsTheme","renderer","shouldForwardProp","prop","palette","secondary","overflow","textOverflow","whiteSpace","primary"],"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,SAAaA,OAAO,QAAQ,QAAQ;AAEpC,SAASC,GAAG,EAAEC,UAAU,EAAEC,MAAM,QAAQ,gBAAgB;AACxD,OAAOC,WAAW,eAAe;AACjC,SAASC,GAAG,QAA2B,eAAe;AACtD,SAASC,aAAaC,gBAAgB,QAA0B,iBAAiB;AACjF,SAASC,aAAa,EAAEC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