@perses-dev/components 0.51.1 → 0.52.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/ContentWithLegend/ContentWithLegend.d.ts.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js +1 -2
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/FormatControls/FormatControls.d.ts.map +1 -1
- package/dist/FormatControls/FormatControls.js +8 -7
- package/dist/FormatControls/FormatControls.js.map +1 -1
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +4 -2
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/cjs/ContentWithLegend/ContentWithLegend.js +1 -2
- package/dist/cjs/FormatControls/FormatControls.js +7 -6
- package/dist/cjs/Legend/Legend.js +4 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentWithLegend.d.ts","sourceRoot":"","sources":["../../src/ContentWithLegend/ContentWithLegend.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAIrC,OAAO,EAAE,sBAAsB,EAA8B,MAAM,mCAAmC,CAAC;AAEvG;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,WAAW,EACX,KAAK,EACL,MAAM,EACN,OAAW,EACX,UAAU,EACV,gBAAsB,EACtB,iBAAuB,GACxB,EAAE,sBAAsB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"ContentWithLegend.d.ts","sourceRoot":"","sources":["../../src/ContentWithLegend/ContentWithLegend.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAIrC,OAAO,EAAE,sBAAsB,EAA8B,MAAM,mCAAmC,CAAC;AAEvG;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,WAAW,EACX,KAAK,EACL,MAAM,EACN,OAAW,EACX,UAAU,EACV,gBAAsB,EACtB,iBAAuB,GACxB,EAAE,sBAAsB,GAAG,YAAY,CAuCvC"}
|
|
@@ -50,8 +50,7 @@ import { getContentWithLegendLayout } from './model/content-with-legend-model';
|
|
|
50
50
|
},
|
|
51
51
|
sx: {
|
|
52
52
|
marginRight: `${margin.right}px`,
|
|
53
|
-
marginBottom: `${margin.bottom}px
|
|
54
|
-
overflow: 'hidden'
|
|
53
|
+
marginBottom: `${margin.bottom}px`
|
|
55
54
|
},
|
|
56
55
|
children: typeof children === 'function' ? children({
|
|
57
56
|
width: content.width,
|
|
@@ -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
|
|
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 }}\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;gBACpC;0BAEC,OAAOnB,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,"file":"FormatControls.d.ts","sourceRoot":"","sources":["../../src/FormatControls/FormatControls.tsx"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"FormatControls.d.ts","sourceRoot":"","sources":["../../src/FormatControls/FormatControls.tsx"],"names":[],"mappings":"AAaA,OAAO,EACL,aAAa,EAMd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAIrC,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA+BD,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAgB,EAAE,EAAE,mBAAmB,GAAG,YAAY,CA0EvG"}
|
|
@@ -12,13 +12,14 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
14
|
import { Switch } from '@mui/material';
|
|
15
|
-
import {
|
|
15
|
+
import { UNIT_CONFIG, isUnitWithDecimalPlaces, isUnitWithShortValues, shouldShortenValues } from '@perses-dev/core';
|
|
16
16
|
import { OptionsEditorControl } from '../OptionsEditorLayout';
|
|
17
17
|
import { SettingsAutocomplete } from '../SettingsAutocomplete';
|
|
18
18
|
const KIND_OPTIONS = Object.entries(UNIT_CONFIG).map(([id, config])=>{
|
|
19
19
|
return {
|
|
20
|
+
...config,
|
|
20
21
|
id: id,
|
|
21
|
-
|
|
22
|
+
group: config.group || 'Decimal'
|
|
22
23
|
};
|
|
23
24
|
}).filter((config)=>!config.disableSelectorOption);
|
|
24
25
|
const DECIMAL_PLACES_OPTIONS = [
|
|
@@ -61,8 +62,8 @@ export function FormatControls({ value, onChange, disabled = false }) {
|
|
|
61
62
|
const hasShortValues = isUnitWithShortValues(value);
|
|
62
63
|
const handleKindChange = (_, newValue)=>{
|
|
63
64
|
onChange({
|
|
64
|
-
unit: newValue
|
|
65
|
-
});
|
|
65
|
+
unit: newValue?.id || 'decimal'
|
|
66
|
+
}); // Fallback to 'decimal' if no unit is selected
|
|
66
67
|
};
|
|
67
68
|
const handleDecimalPlacesChange = ({ decimalPlaces })=>{
|
|
68
69
|
if (hasDecimalPlaces) {
|
|
@@ -80,7 +81,7 @@ export function FormatControls({ value, onChange, disabled = false }) {
|
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
83
|
};
|
|
83
|
-
const unitConfig = UNIT_CONFIG[value
|
|
84
|
+
const unitConfig = UNIT_CONFIG[value?.unit || 'decimal'];
|
|
84
85
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
85
86
|
children: [
|
|
86
87
|
/*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
@@ -95,11 +96,11 @@ export function FormatControls({ value, onChange, disabled = false }) {
|
|
|
95
96
|
label: "Unit",
|
|
96
97
|
control: /*#__PURE__*/ _jsx(SettingsAutocomplete, {
|
|
97
98
|
value: {
|
|
98
|
-
id: value
|
|
99
|
+
id: value?.unit || 'decimal',
|
|
99
100
|
...unitConfig
|
|
100
101
|
},
|
|
101
102
|
options: KIND_OPTIONS,
|
|
102
|
-
groupBy: (option)=>option.group,
|
|
103
|
+
groupBy: (option)=>option.group ?? 'Decimal',
|
|
103
104
|
onChange: handleKindChange,
|
|
104
105
|
disableClearable: true,
|
|
105
106
|
disabled: disabled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/FormatControls/FormatControls.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.\nimport { Switch, SwitchProps } from '@mui/material';\nimport {\n
|
|
1
|
+
{"version":3,"sources":["../../src/FormatControls/FormatControls.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.\nimport { Switch, SwitchProps } from '@mui/material';\nimport {\n FormatOptions,\n UNIT_CONFIG,\n UnitConfig,\n isUnitWithDecimalPlaces,\n isUnitWithShortValues,\n shouldShortenValues,\n} from '@perses-dev/core';\nimport { ReactElement } from 'react';\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\nimport { SettingsAutocomplete } from '../SettingsAutocomplete';\n\nexport interface FormatControlsProps {\n value: FormatOptions;\n onChange: (unit: FormatOptions) => void;\n disabled?: boolean;\n}\n\ntype AutocompleteUnitOption = UnitConfig & {\n id: NonNullable<FormatOptions['unit']>;\n};\n\nconst KIND_OPTIONS: readonly AutocompleteUnitOption[] = Object.entries(UNIT_CONFIG)\n .map<AutocompleteUnitOption>(([id, config]) => {\n return {\n ...config,\n id: id as AutocompleteUnitOption['id'],\n group: config.group || 'Decimal',\n };\n })\n .filter((config) => !config.disableSelectorOption);\n\nconst DECIMAL_PLACES_OPTIONS: Array<{ id: string; label: string; decimalPlaces?: number }> = [\n { id: 'default', label: 'Default', decimalPlaces: undefined },\n { id: '0', label: '0', decimalPlaces: 0 },\n { id: '1', label: '1', decimalPlaces: 1 },\n { id: '2', label: '2', decimalPlaces: 2 },\n { id: '3', label: '3', decimalPlaces: 3 },\n { id: '4', label: '4', decimalPlaces: 4 },\n];\n\nfunction getOptionByDecimalPlaces(\n decimalPlaces?: number\n): { id: string; label: string; decimalPlaces?: number } | undefined {\n return DECIMAL_PLACES_OPTIONS.find((o) => o.decimalPlaces === decimalPlaces);\n}\n\nexport function FormatControls({ value, onChange, disabled = false }: FormatControlsProps): ReactElement {\n const hasDecimalPlaces = isUnitWithDecimalPlaces(value);\n const hasShortValues = isUnitWithShortValues(value);\n\n const handleKindChange = (_: unknown, newValue: AutocompleteUnitOption | null): void => {\n onChange({ unit: newValue?.id || 'decimal' } as FormatOptions); // Fallback to 'decimal' if no unit is selected\n };\n\n const handleDecimalPlacesChange = ({\n decimalPlaces,\n }: {\n id: string;\n label: string;\n decimalPlaces?: number;\n }): void => {\n if (hasDecimalPlaces) {\n onChange({\n ...value,\n decimalPlaces: decimalPlaces,\n });\n }\n };\n\n const handleShortValuesChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n if (hasShortValues) {\n onChange({\n ...value,\n shortValues: checked,\n });\n }\n };\n\n const unitConfig = UNIT_CONFIG[value?.unit || 'decimal'];\n\n return (\n <>\n <OptionsEditorControl\n label=\"Short values\"\n control={\n <Switch\n checked={hasShortValues ? shouldShortenValues(value.shortValues) : false}\n onChange={handleShortValuesChange}\n disabled={!hasShortValues}\n />\n }\n />\n <OptionsEditorControl\n label=\"Unit\"\n control={\n <SettingsAutocomplete<AutocompleteUnitOption, false, true>\n value={{ id: value?.unit || 'decimal', ...unitConfig }}\n options={KIND_OPTIONS}\n groupBy={(option) => option.group ?? 'Decimal'}\n onChange={handleKindChange}\n disableClearable\n disabled={disabled}\n />\n }\n />\n <OptionsEditorControl\n label=\"Decimals\"\n control={\n <SettingsAutocomplete\n value={getOptionByDecimalPlaces(value.decimalPlaces)}\n options={DECIMAL_PLACES_OPTIONS}\n getOptionLabel={(o) => o.label}\n onChange={(_, value) => handleDecimalPlacesChange(value)}\n disabled={!hasDecimalPlaces}\n disableClearable\n />\n }\n />\n </>\n );\n}\n"],"names":["Switch","UNIT_CONFIG","isUnitWithDecimalPlaces","isUnitWithShortValues","shouldShortenValues","OptionsEditorControl","SettingsAutocomplete","KIND_OPTIONS","Object","entries","map","id","config","group","filter","disableSelectorOption","DECIMAL_PLACES_OPTIONS","label","decimalPlaces","undefined","getOptionByDecimalPlaces","find","o","FormatControls","value","onChange","disabled","hasDecimalPlaces","hasShortValues","handleKindChange","_","newValue","unit","handleDecimalPlacesChange","handleShortValuesChange","checked","shortValues","unitConfig","control","options","groupBy","option","disableClearable","getOptionLabel"],"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;;AACjC,SAASA,MAAM,QAAqB,gBAAgB;AACpD,SAEEC,WAAW,EAEXC,uBAAuB,EACvBC,qBAAqB,EACrBC,mBAAmB,QACd,mBAAmB;AAE1B,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,oBAAoB,QAAQ,0BAA0B;AAY/D,MAAMC,eAAkDC,OAAOC,OAAO,CAACR,aACpES,GAAG,CAAyB,CAAC,CAACC,IAAIC,OAAO;IACxC,OAAO;QACL,GAAGA,MAAM;QACTD,IAAIA;QACJE,OAAOD,OAAOC,KAAK,IAAI;IACzB;AACF,GACCC,MAAM,CAAC,CAACF,SAAW,CAACA,OAAOG,qBAAqB;AAEnD,MAAMC,yBAAuF;IAC3F;QAAEL,IAAI;QAAWM,OAAO;QAAWC,eAAeC;IAAU;IAC5D;QAAER,IAAI;QAAKM,OAAO;QAAKC,eAAe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AI,EACJ,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,UAAU,GACX,EAAE,WAAW,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/Legend/Legend.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAa,MAAM,OAAO,CAAC;AAIhD,OAAO,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,OAAO,EAAE,sBAAsB,CAAC;IAEhC;;;;;OAKG;IACH,aAAa,EAAE,uBAAuB,CAAC;IAEvC;;OAEG;IACH,qBAAqB,EAAE,CAAC,WAAW,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAEtE;;OAEG;IACH,eAAe,CAAC,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAErD;;OAEG;IACH,cAAc,CAAC,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAEnD;;OAEG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,iBAAiB,GAAG,SAAS,CAAC,CAAC;CAChF;AASD,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,MAAM,EACN,OAAO,EACP,IAAI,EACJ,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,UAAU,GACX,EAAE,WAAW,GAAG,YAAY,CAoG5B"}
|
package/dist/Legend/Legend.js
CHANGED
|
@@ -99,7 +99,8 @@ export function Legend({ width, height, options, data, selectedItems, onSelected
|
|
|
99
99
|
sx: {
|
|
100
100
|
position: 'absolute',
|
|
101
101
|
top: 0,
|
|
102
|
-
right: 0
|
|
102
|
+
right: 0,
|
|
103
|
+
backgroundColor: (theme)=>`${theme.palette.background.default}`
|
|
103
104
|
},
|
|
104
105
|
children: legendContent
|
|
105
106
|
});
|
|
@@ -112,7 +113,8 @@ export function Legend({ width, height, options, data, selectedItems, onSelected
|
|
|
112
113
|
},
|
|
113
114
|
sx: {
|
|
114
115
|
position: 'absolute',
|
|
115
|
-
bottom: 0
|
|
116
|
+
bottom: 0,
|
|
117
|
+
backgroundColor: (theme)=>`${theme.palette.background.default}`
|
|
116
118
|
},
|
|
117
119
|
children: legendContent
|
|
118
120
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/Legend.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 } from '@mui/material';\nimport { produce } from 'immer';\nimport { ReactElement, ReactNode } from 'react';\nimport { getLegendMode } from '@perses-dev/core';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\nimport { TableLegend, TableLegendProps } from './TableLegend';\nimport { LegendItem, LegendComponentOptions, SelectedLegendItemState } from './legend-model';\nimport { ListLegendItemProps } from './ListLegendItem';\n\nexport interface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendComponentOptions;\n\n /**\n * State of selected items in the legend.\n *\n * Selected legend item state is a controlled value that should be managed using a\n * combination of this prop and `onSelectedChange`.\n */\n selectedItems: SelectedLegendItemState;\n\n /**\n * Callback fired when the selected items in the legend changes.\n */\n onSelectedItemsChange: (newSelected: SelectedLegendItemState) => void;\n\n /**\n * Callback fired when the mouse is moved over a legend item.\n */\n onItemMouseOver?: ListLegendItemProps['onMouseOver'];\n\n /**\n * Callback fired when the mouse is moved out of a legend item.\n */\n onItemMouseOut?: ListLegendItemProps['onMouseOut'];\n\n /**\n * Props specific to legend with `mode` set to `table`.\n */\n tableProps?: Pick<TableLegendProps, 'columns' | 'onSortingChange' | 'sorting'>;\n}\n\n// When the number of items to display is above this number, it is likely to\n// cause performance issues in the browser. The legend will be displayed in a\n// format (list) that allows for virtualization to minimize the performance impact.\n// Set this number based on testing, but it may need to be tuned a bit on the\n// future as people test this out on different machines.\nconst NEED_VIRTUALIZATION_LIMIT = 500;\n\nexport function Legend({\n width,\n height,\n options,\n data,\n selectedItems,\n onSelectedItemsChange,\n onItemMouseOver,\n onItemMouseOut,\n tableProps,\n}: LegendProps): ReactElement {\n const onLegendItemClick = (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string): void => {\n const isModifiedClick = e.metaKey || e.shiftKey;\n\n const newSelected = produce(selectedItems, (draft) => {\n if (draft === 'ALL') {\n return {\n [seriesId]: true,\n };\n }\n\n const isSelected = !!draft[seriesId];\n\n // Clicks with modifier key can select multiple items.\n if (isModifiedClick) {\n if (isSelected) {\n // Modified click on already selected item. Remove that item.\n delete draft[seriesId];\n } else {\n // Modified click on not-selected item. Add it.\n draft[seriesId] = true;\n }\n return draft;\n }\n\n if (isSelected) {\n // Clicked item was already selected. Unselect it and return to\n // ALL state.\n return 'ALL' as const;\n }\n\n // Select clicked item.\n return { [seriesId]: true };\n });\n onSelectedItemsChange(newSelected);\n };\n\n const mode = getLegendMode(options.mode);\n\n // The bottom legend is displayed as a list when the number of items is too\n // large and requires virtualization. Otherwise, it is rendered more compactly.\n // We do not need this check for the right-side legend because it is always\n // a virtualized list.\n const needsVirtualization = data.length >= NEED_VIRTUALIZATION_LIMIT;\n\n const commonLegendProps = {\n height,\n items: data,\n selectedItems,\n onLegendItemClick,\n onItemMouseOver,\n onItemMouseOut,\n };\n\n let legendContent: ReactNode;\n if (mode === 'table') {\n legendContent = (\n <TableLegend {...commonLegendProps} onSelectedItemsChange={onSelectedItemsChange} width={width} {...tableProps} />\n );\n } else if (options.position === 'right' || needsVirtualization) {\n legendContent = <ListLegend {...commonLegendProps} width={width} onLegendItemClick={onLegendItemClick} />;\n } else {\n legendContent = <CompactLegend {...commonLegendProps} onLegendItemClick={onLegendItemClick} />;\n }\n\n if (options.position === 'right') {\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{\n position: 'absolute',\n top: 0,\n right: 0,\n }}\n >\n {legendContent}\n </Box>\n );\n }\n\n // Position bottom\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{\n position: 'absolute',\n bottom: 0,\n }}\n >\n {legendContent}\n </Box>\n );\n}\n"],"names":["Box","produce","getLegendMode","ListLegend","CompactLegend","TableLegend","NEED_VIRTUALIZATION_LIMIT","Legend","width","height","options","data","selectedItems","onSelectedItemsChange","onItemMouseOver","onItemMouseOut","tableProps","onLegendItemClick","e","seriesId","isModifiedClick","metaKey","shiftKey","newSelected","draft","isSelected","mode","needsVirtualization","length","commonLegendProps","items","legendContent","position","style","sx","top","right","bottom"],"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,QAAQ,gBAAgB;AACpC,SAASC,OAAO,QAAQ,QAAQ;AAEhC,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,WAAW,QAA0B,gBAAgB;AAuC9D,4EAA4E;AAC5E,6EAA6E;AAC7E,mFAAmF;AACnF,6EAA6E;AAC7E,wDAAwD;AACxD,MAAMC,4BAA4B;AAEl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AOS,mBAAmBA;;IACtF,OAAO;QACLc,8BAAgB,KAAC3B;YAAe,GAAGyB,iBAAiB;YAAEZ,mBAAmBA;;IAC3E;IAEA,IAAIP,QAAQsB,QAAQ,KAAK,SAAS;QAChC,qBACE,KAAChC;YACCiC,OAAO;gBACLzB,OAAOA;gBACPC,QAAQA;YACV;YACAyB,IAAI;gBACFF,UAAU;gBACVG,KAAK;gBACLC,OAAO;
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/Legend.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 } from '@mui/material';\nimport { produce } from 'immer';\nimport { ReactElement, ReactNode } from 'react';\nimport { getLegendMode } from '@perses-dev/core';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\nimport { TableLegend, TableLegendProps } from './TableLegend';\nimport { LegendItem, LegendComponentOptions, SelectedLegendItemState } from './legend-model';\nimport { ListLegendItemProps } from './ListLegendItem';\n\nexport interface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendComponentOptions;\n\n /**\n * State of selected items in the legend.\n *\n * Selected legend item state is a controlled value that should be managed using a\n * combination of this prop and `onSelectedChange`.\n */\n selectedItems: SelectedLegendItemState;\n\n /**\n * Callback fired when the selected items in the legend changes.\n */\n onSelectedItemsChange: (newSelected: SelectedLegendItemState) => void;\n\n /**\n * Callback fired when the mouse is moved over a legend item.\n */\n onItemMouseOver?: ListLegendItemProps['onMouseOver'];\n\n /**\n * Callback fired when the mouse is moved out of a legend item.\n */\n onItemMouseOut?: ListLegendItemProps['onMouseOut'];\n\n /**\n * Props specific to legend with `mode` set to `table`.\n */\n tableProps?: Pick<TableLegendProps, 'columns' | 'onSortingChange' | 'sorting'>;\n}\n\n// When the number of items to display is above this number, it is likely to\n// cause performance issues in the browser. The legend will be displayed in a\n// format (list) that allows for virtualization to minimize the performance impact.\n// Set this number based on testing, but it may need to be tuned a bit on the\n// future as people test this out on different machines.\nconst NEED_VIRTUALIZATION_LIMIT = 500;\n\nexport function Legend({\n width,\n height,\n options,\n data,\n selectedItems,\n onSelectedItemsChange,\n onItemMouseOver,\n onItemMouseOut,\n tableProps,\n}: LegendProps): ReactElement {\n const onLegendItemClick = (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string): void => {\n const isModifiedClick = e.metaKey || e.shiftKey;\n\n const newSelected = produce(selectedItems, (draft) => {\n if (draft === 'ALL') {\n return {\n [seriesId]: true,\n };\n }\n\n const isSelected = !!draft[seriesId];\n\n // Clicks with modifier key can select multiple items.\n if (isModifiedClick) {\n if (isSelected) {\n // Modified click on already selected item. Remove that item.\n delete draft[seriesId];\n } else {\n // Modified click on not-selected item. Add it.\n draft[seriesId] = true;\n }\n return draft;\n }\n\n if (isSelected) {\n // Clicked item was already selected. Unselect it and return to\n // ALL state.\n return 'ALL' as const;\n }\n\n // Select clicked item.\n return { [seriesId]: true };\n });\n onSelectedItemsChange(newSelected);\n };\n\n const mode = getLegendMode(options.mode);\n\n // The bottom legend is displayed as a list when the number of items is too\n // large and requires virtualization. Otherwise, it is rendered more compactly.\n // We do not need this check for the right-side legend because it is always\n // a virtualized list.\n const needsVirtualization = data.length >= NEED_VIRTUALIZATION_LIMIT;\n\n const commonLegendProps = {\n height,\n items: data,\n selectedItems,\n onLegendItemClick,\n onItemMouseOver,\n onItemMouseOut,\n };\n\n let legendContent: ReactNode;\n if (mode === 'table') {\n legendContent = (\n <TableLegend {...commonLegendProps} onSelectedItemsChange={onSelectedItemsChange} width={width} {...tableProps} />\n );\n } else if (options.position === 'right' || needsVirtualization) {\n legendContent = <ListLegend {...commonLegendProps} width={width} onLegendItemClick={onLegendItemClick} />;\n } else {\n legendContent = <CompactLegend {...commonLegendProps} onLegendItemClick={onLegendItemClick} />;\n }\n\n if (options.position === 'right') {\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{\n position: 'absolute',\n top: 0,\n right: 0,\n backgroundColor: (theme) => `${theme.palette.background.default}`,\n }}\n >\n {legendContent}\n </Box>\n );\n }\n\n // Position bottom\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{\n position: 'absolute',\n bottom: 0,\n backgroundColor: (theme) => `${theme.palette.background.default}`,\n }}\n >\n {legendContent}\n </Box>\n );\n}\n"],"names":["Box","produce","getLegendMode","ListLegend","CompactLegend","TableLegend","NEED_VIRTUALIZATION_LIMIT","Legend","width","height","options","data","selectedItems","onSelectedItemsChange","onItemMouseOver","onItemMouseOut","tableProps","onLegendItemClick","e","seriesId","isModifiedClick","metaKey","shiftKey","newSelected","draft","isSelected","mode","needsVirtualization","length","commonLegendProps","items","legendContent","position","style","sx","top","right","backgroundColor","theme","palette","background","default","bottom"],"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,QAAQ,gBAAgB;AACpC,SAASC,OAAO,QAAQ,QAAQ;AAEhC,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,WAAW,QAA0B,gBAAgB;AAuC9D,4EAA4E;AAC5E,6EAA6E;AAC7E,mFAAmF;AACnF,6EAA6E;AAC7E,wDAAwD;AACxD,MAAMC,4BAA4B;AAElC,OAAO,SAASC,OAAO,EACrBC,KAAK,EACLC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,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AEZ,mBAAmBA;;IAC3E;IAEA,IAAIP,QAAQsB,QAAQ,KAAK,SAAS;QAChC,qBACE,KAAChC;YACCiC,OAAO;gBACLzB,OAAOA;gBACPC,QAAQA;YACV;YACAyB,IAAI;gBACFF,UAAU;gBACVG,KAAK;gBACLC,OAAO;gBACPC,iBAAiB,CAACC,QAAU,GAAGA,MAAMC,OAAO,CAACC,UAAU,CAACC,OAAO,EAAE;YACnE;sBAECV;;IAGP;IAEA,kBAAkB;IAClB,qBACE,KAAC/B;QACCiC,OAAO;YACLzB,OAAOA;YACPC,QAAQA;QACV;QACAyB,IAAI;YACFF,UAAU;YACVU,QAAQ;YACRL,iBAAiB,CAACC,QAAU,GAAGA,MAAMC,OAAO,CAACC,UAAU,CAACC,OAAO,EAAE;QACnE;kBAECV;;AAGP"}
|
|
@@ -54,8 +54,7 @@ function ContentWithLegend({ children, legendProps, width, height, spacing = 0,
|
|
|
54
54
|
},
|
|
55
55
|
sx: {
|
|
56
56
|
marginRight: `${margin.right}px`,
|
|
57
|
-
marginBottom: `${margin.bottom}px
|
|
58
|
-
overflow: 'hidden'
|
|
57
|
+
marginBottom: `${margin.bottom}px`
|
|
59
58
|
},
|
|
60
59
|
children: typeof children === 'function' ? children({
|
|
61
60
|
width: content.width,
|
|
@@ -27,8 +27,9 @@ const _OptionsEditorLayout = require("../OptionsEditorLayout");
|
|
|
27
27
|
const _SettingsAutocomplete = require("../SettingsAutocomplete");
|
|
28
28
|
const KIND_OPTIONS = Object.entries(_core.UNIT_CONFIG).map(([id, config])=>{
|
|
29
29
|
return {
|
|
30
|
+
...config,
|
|
30
31
|
id: id,
|
|
31
|
-
|
|
32
|
+
group: config.group || 'Decimal'
|
|
32
33
|
};
|
|
33
34
|
}).filter((config)=>!config.disableSelectorOption);
|
|
34
35
|
const DECIMAL_PLACES_OPTIONS = [
|
|
@@ -71,8 +72,8 @@ function FormatControls({ value, onChange, disabled = false }) {
|
|
|
71
72
|
const hasShortValues = (0, _core.isUnitWithShortValues)(value);
|
|
72
73
|
const handleKindChange = (_, newValue)=>{
|
|
73
74
|
onChange({
|
|
74
|
-
unit: newValue
|
|
75
|
-
});
|
|
75
|
+
unit: newValue?.id || 'decimal'
|
|
76
|
+
}); // Fallback to 'decimal' if no unit is selected
|
|
76
77
|
};
|
|
77
78
|
const handleDecimalPlacesChange = ({ decimalPlaces })=>{
|
|
78
79
|
if (hasDecimalPlaces) {
|
|
@@ -90,7 +91,7 @@ function FormatControls({ value, onChange, disabled = false }) {
|
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
93
|
};
|
|
93
|
-
const unitConfig = _core.UNIT_CONFIG[value
|
|
94
|
+
const unitConfig = _core.UNIT_CONFIG[value?.unit || 'decimal'];
|
|
94
95
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
95
96
|
children: [
|
|
96
97
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsEditorLayout.OptionsEditorControl, {
|
|
@@ -105,11 +106,11 @@ function FormatControls({ value, onChange, disabled = false }) {
|
|
|
105
106
|
label: "Unit",
|
|
106
107
|
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_SettingsAutocomplete.SettingsAutocomplete, {
|
|
107
108
|
value: {
|
|
108
|
-
id: value
|
|
109
|
+
id: value?.unit || 'decimal',
|
|
109
110
|
...unitConfig
|
|
110
111
|
},
|
|
111
112
|
options: KIND_OPTIONS,
|
|
112
|
-
groupBy: (option)=>option.group,
|
|
113
|
+
groupBy: (option)=>option.group ?? 'Decimal',
|
|
113
114
|
onChange: handleKindChange,
|
|
114
115
|
disableClearable: true,
|
|
115
116
|
disabled: disabled
|
|
@@ -109,7 +109,8 @@ function Legend({ width, height, options, data, selectedItems, onSelectedItemsCh
|
|
|
109
109
|
sx: {
|
|
110
110
|
position: 'absolute',
|
|
111
111
|
top: 0,
|
|
112
|
-
right: 0
|
|
112
|
+
right: 0,
|
|
113
|
+
backgroundColor: (theme)=>`${theme.palette.background.default}`
|
|
113
114
|
},
|
|
114
115
|
children: legendContent
|
|
115
116
|
});
|
|
@@ -122,7 +123,8 @@ function Legend({ width, height, options, data, selectedItems, onSelectedItemsCh
|
|
|
122
123
|
},
|
|
123
124
|
sx: {
|
|
124
125
|
position: 'absolute',
|
|
125
|
-
bottom: 0
|
|
126
|
+
bottom: 0,
|
|
127
|
+
backgroundColor: (theme)=>`${theme.palette.background.default}`
|
|
126
128
|
},
|
|
127
129
|
children: legendContent
|
|
128
130
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0-beta.1",
|
|
4
4
|
"description": "Common UI components used across Perses features",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@codemirror/lang-json": "^6.0.1",
|
|
34
34
|
"@fontsource/lato": "^4.5.10",
|
|
35
35
|
"@mui/x-date-pickers": "^7.23.1",
|
|
36
|
-
"@perses-dev/core": "0.
|
|
36
|
+
"@perses-dev/core": "0.52.0-beta.1",
|
|
37
37
|
"@tanstack/react-table": "^8.20.5",
|
|
38
38
|
"@uiw/react-codemirror": "^4.19.1",
|
|
39
39
|
"date-fns": "^4.1.0",
|