@perses-dev/components 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ContentWithLegend/ContentWithLegend.js +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +3 -3
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js +12 -3
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/EChart/EChart.d.ts +2 -1
- package/dist/EChart/EChart.d.ts.map +1 -1
- package/dist/EChart/EChart.js +15 -3
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/Legend/CompactLegend.d.ts +1 -1
- package/dist/Legend/CompactLegend.d.ts.map +1 -1
- package/dist/Legend/CompactLegend.js +1 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.d.ts +8 -3
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +4 -3
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/ListLegend.d.ts +1 -1
- package/dist/Legend/ListLegend.d.ts.map +1 -1
- package/dist/Legend/ListLegend.js +1 -1
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +1 -1
- package/dist/Legend/ListLegendItem.d.ts.map +1 -1
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts +3 -2
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js +10 -2
- package/dist/Legend/TableLegend.js.map +1 -1
- package/dist/Legend/index.d.ts +1 -0
- package/dist/Legend/index.d.ts.map +1 -1
- package/dist/Legend/index.js +1 -0
- package/dist/Legend/index.js.map +1 -1
- package/dist/Legend/legend-model.d.ts +24 -0
- package/dist/Legend/legend-model.d.ts.map +1 -0
- package/dist/Legend/legend-model.js +19 -0
- package/dist/Legend/legend-model.js.map +1 -0
- package/dist/LineChart/LineChart.d.ts +2 -1
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +3 -2
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/LineChart/utils.js +1 -1
- package/dist/LineChart/utils.js.map +1 -1
- package/dist/StatChart/StatChart.js +1 -1
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/Table/InnerTable.js +1 -1
- package/dist/Table/InnerTable.js.map +1 -1
- package/dist/Table/Table.js +1 -1
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableCell.d.ts +6 -3
- package/dist/Table/TableCell.d.ts.map +1 -1
- package/dist/Table/TableCell.js +6 -3
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableRow.d.ts.map +1 -1
- package/dist/Table/TableRow.js +3 -3
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +11 -5
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +16 -2
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +18 -7
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +4 -2
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/cjs/ContentWithLegend/ContentWithLegend.js +1 -1
- package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +13 -4
- package/dist/cjs/EChart/EChart.js +22 -5
- package/dist/cjs/Legend/CompactLegend.js +2 -2
- package/dist/cjs/Legend/Legend.js +5 -4
- package/dist/cjs/Legend/ListLegend.js +2 -2
- package/dist/cjs/Legend/TableLegend.js +10 -2
- package/dist/cjs/Legend/index.js +1 -0
- package/dist/cjs/{LegendOptionsEditor/index.js → Legend/legend-model.js} +8 -11
- package/dist/cjs/LineChart/LineChart.js +3 -2
- package/dist/cjs/LineChart/utils.js +7 -2
- package/dist/cjs/StatChart/StatChart.js +7 -2
- package/dist/cjs/Table/InnerTable.js +1 -1
- package/dist/cjs/Table/Table.js +1 -1
- package/dist/cjs/Table/TableCell.js +6 -3
- package/dist/cjs/Table/TableRow.js +2 -2
- package/dist/cjs/Table/VirtualizedTable.js +11 -5
- package/dist/cjs/Table/model/table-model.js +18 -7
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +4 -2
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/model/index.js +0 -1
- package/dist/cjs/theme/component-overrides/paper.js +27 -0
- package/dist/cjs/theme/palette/background.js +2 -2
- package/dist/cjs/theme/theme.js +2 -0
- package/dist/cjs/utils/theme-gen.js +7 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/model/graph.d.ts +1 -1
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/graph.js.map +1 -1
- package/dist/model/index.d.ts +0 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +0 -1
- package/dist/model/index.js.map +1 -1
- package/dist/theme/component-overrides/paper.d.ts +3 -0
- package/dist/theme/component-overrides/paper.d.ts.map +1 -0
- package/dist/{LegendOptionsEditor/index.js → theme/component-overrides/paper.js} +8 -2
- package/dist/theme/component-overrides/paper.js.map +1 -0
- package/dist/theme/palette/background.js +2 -2
- package/dist/theme/palette/background.js.map +1 -1
- package/dist/theme/theme.d.ts.map +1 -1
- package/dist/theme/theme.js +2 -0
- package/dist/theme/theme.js.map +1 -1
- package/dist/utils/theme-gen.js +1 -1
- package/dist/utils/theme-gen.js.map +1 -1
- package/package.json +5 -8
- package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts +0 -8
- package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +0 -1
- package/dist/LegendOptionsEditor/LegendOptionsEditor.js +0 -109
- package/dist/LegendOptionsEditor/LegendOptionsEditor.js.map +0 -1
- package/dist/LegendOptionsEditor/index.d.ts +0 -2
- package/dist/LegendOptionsEditor/index.d.ts.map +0 -1
- package/dist/LegendOptionsEditor/index.js.map +0 -1
- package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.js +0 -115
- package/dist/cjs/model/legend.js +0 -102
- package/dist/model/legend.d.ts +0 -36
- package/dist/model/legend.d.ts.map +0 -1
- package/dist/model/legend.js +0 -81
- package/dist/model/legend.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/theme/palette/background.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PaletteMode, PaletteOptions } from '@mui/material';\nimport { blue, grey, white } from './colors';\n\nexport const background = (mode: PaletteMode): PaletteOptions['background'] => {\n const navigation = blue[150];\n const overlay = 'rgba(21, 23, 33, 0.75)'; // grey[900] with opacity 75%\n return mode === 'light'\n ? {\n navigation,\n overlay,\n default:
|
|
1
|
+
{"version":3,"sources":["../../../src/theme/palette/background.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PaletteMode, PaletteOptions } from '@mui/material';\nimport { blue, grey, white } from './colors';\n\nexport const background = (mode: PaletteMode): PaletteOptions['background'] => {\n const navigation = blue[150];\n const overlay = 'rgba(21, 23, 33, 0.75)'; // grey[900] with opacity 75%\n return mode === 'light'\n ? {\n navigation,\n overlay,\n default: white,\n paper: grey[50],\n tooltip: grey[100],\n border: grey[100],\n }\n : {\n navigation,\n overlay,\n default: grey[900],\n paper: grey[850],\n tooltip: grey[700],\n border: grey[600],\n };\n};\n"],"names":["blue","grey","white","background","mode","navigation","overlay","default","paper","tooltip","border"],"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,IAAI,EAAEC,IAAI,EAAEC,KAAK,QAAQ,UAAU,CAAC;AAE7C,OAAO,MAAMC,UAAU,GAAG,CAACC,IAAiB,GAAmC;IAC7E,MAAMC,UAAU,GAAGL,IAAI,CAAC,GAAG,CAAC,AAAC;IAC7B,MAAMM,OAAO,GAAG,wBAAwB,AAAC,EAAC,6BAA6B;IACvE,OAAOF,IAAI,KAAK,OAAO,GACnB;QACEC,UAAU;QACVC,OAAO;QACPC,OAAO,EAAEL,KAAK;QACdM,KAAK,EAAEP,IAAI,CAAC,EAAE,CAAC;QACfQ,OAAO,EAAER,IAAI,CAAC,GAAG,CAAC;QAClBS,MAAM,EAAET,IAAI,CAAC,GAAG,CAAC;KAClB,GACD;QACEI,UAAU;QACVC,OAAO;QACPC,OAAO,EAAEN,IAAI,CAAC,GAAG,CAAC;QAClBO,KAAK,EAAEP,IAAI,CAAC,GAAG,CAAC;QAChBQ,OAAO,EAAER,IAAI,CAAC,GAAG,CAAC;QAClBS,MAAM,EAAET,IAAI,CAAC,GAAG,CAAC;KAClB,CAAC;AACR,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,WAAW,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,WAAW,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AAmB9E;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,SAQzC"}
|
package/dist/theme/theme.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { createTheme } from '@mui/material';
|
|
14
14
|
import { MuiAlert } from './component-overrides/alert';
|
|
15
|
+
import { MuiPaper } from './component-overrides/paper';
|
|
15
16
|
import { getPaletteOptions } from './palette/palette-options';
|
|
16
17
|
import { typography } from './typography';
|
|
17
18
|
const getModalBackgroundStyle = ({ theme })=>{
|
|
@@ -49,6 +50,7 @@ const components = {
|
|
|
49
50
|
size: 'small'
|
|
50
51
|
}
|
|
51
52
|
},
|
|
53
|
+
MuiPaper,
|
|
52
54
|
MuiTextField: {
|
|
53
55
|
defaultProps: {
|
|
54
56
|
size: 'small'
|
package/dist/theme/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/theme/theme.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createTheme, PaletteMode, ThemeOptions, Theme } from '@mui/material';\nimport { MuiAlert } from './component-overrides/alert';\nimport { getPaletteOptions } from './palette/palette-options';\nimport { typography } from './typography';\n\nconst getModalBackgroundStyle = ({ theme }: { theme: Omit<Theme, 'components'> }) => {\n const backgroundStyle =\n theme.palette.mode === 'light'\n ? {}\n : {\n backgroundImage: 'unset',\n backgroundColor: theme.palette.designSystem.grey[800],\n };\n return {\n ...backgroundStyle,\n };\n};\n\n/**\n * Gets theme used by all components for the provided mode. For more details, see:\n * - Base colors, typography, sizing - go/chrono-ui-theme\n * - Material UI defaults: https://material-ui.com/customization/default-theme/\n * - Material UI variables: https://material-ui.com/customization/theming/#theme-configuration-variables\n * - Material UI global overrides and default props: https://material-ui.com/customization/globals/#css\n *\n * Need to reinstantiate the theme everytime to support switching between light and dark themes\n * https://github.com/mui-org/material-ui/issues/18831\n */\nexport function getTheme(mode: PaletteMode) {\n const theme = createTheme({\n palette: getPaletteOptions(mode),\n typography,\n mixins: {},\n components,\n });\n return theme;\n}\n\n// Overrides for component default prop values and styles go here\nconst components: ThemeOptions['components'] = {\n MuiAlert,\n MuiFormControl: {\n defaultProps: {\n size: 'small',\n },\n },\n MuiTextField: {\n defaultProps: {\n size: 'small',\n },\n },\n MuiDrawer: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n MuiDialog: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n MuiPopover: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n};\n"],"names":["createTheme","MuiAlert","getPaletteOptions","typography","getModalBackgroundStyle","theme","backgroundStyle","palette","mode","backgroundImage","backgroundColor","designSystem","grey","getTheme","mixins","components","MuiFormControl","defaultProps","size","MuiTextField","MuiDrawer","styleOverrides","paper","MuiDialog","MuiPopover"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAA0C,eAAe,CAAC;AAC9E,SAASC,QAAQ,QAAQ,6BAA6B,CAAC;AACvD,SAASC,iBAAiB,QAAQ,2BAA2B,CAAC;AAC9D,SAASC,UAAU,QAAQ,cAAc,CAAC;AAE1C,MAAMC,uBAAuB,GAAG,CAAC,EAAEC,KAAK,CAAA,EAAwC,GAAK;IACnF,MAAMC,eAAe,GACnBD,KAAK,CAACE,OAAO,CAACC,IAAI,KAAK,OAAO,GAC1B,EAAE,GACF;QACEC,eAAe,EAAE,OAAO;QACxBC,eAAe,EAAEL,KAAK,CAACE,OAAO,CAACI,YAAY,CAACC,IAAI,CAAC,GAAG,CAAC;KACtD,AAAC;IACR,OAAO;QACL,GAAGN,eAAe;KACnB,CAAC;AACJ,CAAC,AAAC;AAEF;;;;;;;;;CASC,GACD,OAAO,SAASO,QAAQ,CAACL,IAAiB,EAAE;IAC1C,MAAMH,KAAK,
|
|
1
|
+
{"version":3,"sources":["../../src/theme/theme.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createTheme, PaletteMode, ThemeOptions, Theme } from '@mui/material';\nimport { MuiAlert } from './component-overrides/alert';\nimport { MuiPaper } from './component-overrides/paper';\nimport { getPaletteOptions } from './palette/palette-options';\nimport { typography } from './typography';\n\nconst getModalBackgroundStyle = ({ theme }: { theme: Omit<Theme, 'components'> }) => {\n const backgroundStyle =\n theme.palette.mode === 'light'\n ? {}\n : {\n backgroundImage: 'unset',\n backgroundColor: theme.palette.designSystem.grey[800],\n };\n return {\n ...backgroundStyle,\n };\n};\n\n/**\n * Gets theme used by all components for the provided mode. For more details, see:\n * - Base colors, typography, sizing - go/chrono-ui-theme\n * - Material UI defaults: https://material-ui.com/customization/default-theme/\n * - Material UI variables: https://material-ui.com/customization/theming/#theme-configuration-variables\n * - Material UI global overrides and default props: https://material-ui.com/customization/globals/#css\n *\n * Need to reinstantiate the theme everytime to support switching between light and dark themes\n * https://github.com/mui-org/material-ui/issues/18831\n */\nexport function getTheme(mode: PaletteMode) {\n const theme = createTheme({\n palette: getPaletteOptions(mode),\n typography,\n mixins: {},\n components,\n });\n return theme;\n}\n\n// Overrides for component default prop values and styles go here\nconst components: ThemeOptions['components'] = {\n MuiAlert,\n MuiFormControl: {\n defaultProps: {\n size: 'small',\n },\n },\n MuiPaper,\n MuiTextField: {\n defaultProps: {\n size: 'small',\n },\n },\n MuiDrawer: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n MuiDialog: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n MuiPopover: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n};\n"],"names":["createTheme","MuiAlert","MuiPaper","getPaletteOptions","typography","getModalBackgroundStyle","theme","backgroundStyle","palette","mode","backgroundImage","backgroundColor","designSystem","grey","getTheme","mixins","components","MuiFormControl","defaultProps","size","MuiTextField","MuiDrawer","styleOverrides","paper","MuiDialog","MuiPopover"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAA0C,eAAe,CAAC;AAC9E,SAASC,QAAQ,QAAQ,6BAA6B,CAAC;AACvD,SAASC,QAAQ,QAAQ,6BAA6B,CAAC;AACvD,SAASC,iBAAiB,QAAQ,2BAA2B,CAAC;AAC9D,SAASC,UAAU,QAAQ,cAAc,CAAC;AAE1C,MAAMC,uBAAuB,GAAG,CAAC,EAAEC,KAAK,CAAA,EAAwC,GAAK;IACnF,MAAMC,eAAe,GACnBD,KAAK,CAACE,OAAO,CAACC,IAAI,KAAK,OAAO,GAC1B,EAAE,GACF;QACEC,eAAe,EAAE,OAAO;QACxBC,eAAe,EAAEL,KAAK,CAACE,OAAO,CAACI,YAAY,CAACC,IAAI,CAAC,GAAG,CAAC;KACtD,AAAC;IACR,OAAO;QACL,GAAGN,eAAe;KACnB,CAAC;AACJ,CAAC,AAAC;AAEF;;;;;;;;;CASC,GACD,OAAO,SAASO,QAAQ,CAACL,IAAiB,EAAE;IAC1C,MAAMH,KAAK,GAAGN,WAAW,CAAC;QACxBQ,OAAO,EAAEL,iBAAiB,CAACM,IAAI,CAAC;QAChCL,UAAU;QACVW,MAAM,EAAE,EAAE;QACVC,UAAU;KACX,CAAC,AAAC;IACH,OAAOV,KAAK,CAAC;AACf,CAAC;AAED,iEAAiE;AACjE,MAAMU,UAAU,GAA+B;IAC7Cf,QAAQ;IACRgB,cAAc,EAAE;QACdC,YAAY,EAAE;YACZC,IAAI,EAAE,OAAO;SACd;KACF;IACDjB,QAAQ;IACRkB,YAAY,EAAE;QACZF,YAAY,EAAE;YACZC,IAAI,EAAE,OAAO;SACd;KACF;IACDE,SAAS,EAAE;QACTC,cAAc,EAAE;YACdC,KAAK,EAAElB,uBAAuB;SAC/B;KACF;IACDmB,SAAS,EAAE;QACTF,cAAc,EAAE;YACdC,KAAK,EAAElB,uBAAuB;SAC/B;KACF;IACDoB,UAAU,EAAE;QACVH,cAAc,EAAE;YACdC,KAAK,EAAElB,uBAAuB;SAC/B;KACF;CACF,AAAC"}
|
package/dist/utils/theme-gen.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import
|
|
13
|
+
import merge from 'lodash/merge';
|
|
14
14
|
const DEFAULT_TEXT_COLOR = '#222';
|
|
15
15
|
export function generateChartsTheme(muiTheme, echartsTheme) {
|
|
16
16
|
var ref, ref1, ref2, ref3, ref4;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/theme-gen.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Theme } from '@mui/material';\nimport { merge } from 'lodash-es';\nimport { EChartsTheme, PersesChartsTheme } from '../model';\n\nconst DEFAULT_TEXT_COLOR = '#222';\n\n// avoid component override type errors since only palette and typography are used\ntype MuiTheme = Omit<Theme, 'components'>;\n\nexport function generateChartsTheme(muiTheme: MuiTheme, echartsTheme: EChartsTheme): PersesChartsTheme {\n const primaryTextColor = muiTheme.palette.text?.primary ?? DEFAULT_TEXT_COLOR;\n\n const muiConvertedTheme: EChartsTheme = {\n title: {\n show: false,\n },\n textStyle: {\n color: primaryTextColor,\n fontFamily: muiTheme.typography.fontFamily,\n fontSize: 12,\n },\n grid: {\n top: 5,\n right: 20,\n bottom: 0,\n left: 20,\n containLabel: true,\n },\n // Accessible categorical palette from: https://davidmathlogic.com/colorblind\n color: [\n '#56B4E9', // lt blue\n '#009E73', // med green\n '#0072B2', // dk blue\n '#CC79A7', // lt purple\n '#F0E442', // yellow\n '#E69F00', // orange\n '#D55E00', // red\n ],\n categoryAxis: {\n show: true,\n axisLabel: {\n show: true,\n color: primaryTextColor,\n margin: 15,\n },\n axisTick: {\n show: false,\n length: 6,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n axisLine: {\n show: true,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.6,\n },\n },\n splitArea: {\n show: false,\n areaStyle: {\n color: [muiTheme.palette.grey[300]],\n },\n },\n },\n valueAxis: {\n show: true,\n axisLabel: {\n color: primaryTextColor,\n margin: 12,\n },\n axisLine: {\n show: false,\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.6,\n },\n },\n },\n legend: {\n orient: 'horizontal',\n textStyle: {\n color: primaryTextColor,\n },\n pageTextStyle: {\n color: muiTheme.palette.grey[600],\n },\n pageIconColor: muiTheme?.palette?.action?.active,\n pageIconInactiveColor: muiTheme?.palette?.action?.disabled,\n },\n toolbox: {\n show: true,\n top: 10,\n right: 10,\n iconStyle: {\n borderColor: primaryTextColor,\n },\n },\n tooltip: {},\n line: {\n showSymbol: false,\n symbol: 'circle',\n symbolSize: 4,\n smooth: false,\n lineStyle: {\n width: 1,\n },\n emphasis: {\n lineStyle: {\n width: 1.5,\n },\n },\n },\n bar: {\n barMaxWidth: 150,\n itemStyle: {\n borderWidth: 0,\n borderColor: muiTheme.palette.grey[300],\n },\n },\n gauge: {\n detail: {\n fontSize: 18,\n fontWeight: 600,\n valueAnimation: false,\n },\n splitLine: {\n distance: 0,\n length: 4,\n lineStyle: {\n width: 1,\n },\n },\n splitNumber: 12,\n },\n };\n\n return {\n echartsTheme: merge(muiConvertedTheme, echartsTheme),\n noDataOption: {\n title: {\n show: true,\n textStyle: {\n color: primaryTextColor,\n fontSize: 16,\n fontWeight: 400,\n },\n text: 'No data',\n left: 'center',\n top: 'center',\n },\n xAxis: {\n show: false,\n },\n yAxis: {\n show: false,\n },\n },\n sparkline: {\n width: 2,\n color: '#1976d2',\n },\n container: {\n padding: {\n default: parseInt(muiTheme.spacing(1.5), 10),\n },\n },\n thresholds: {\n defaultColor: muiTheme.palette.success.main,\n palette: ['#FFCC00', muiTheme.palette.warning.main, muiTheme.palette.error.main],\n },\n };\n}\n"],"names":["merge","DEFAULT_TEXT_COLOR","generateChartsTheme","muiTheme","echartsTheme","primaryTextColor","palette","text","primary","muiConvertedTheme","title","show","textStyle","color","fontFamily","typography","fontSize","grid","top","right","bottom","left","containLabel","categoryAxis","axisLabel","margin","axisTick","length","lineStyle","grey","axisLine","splitLine","width","opacity","splitArea","areaStyle","valueAxis","legend","orient","pageTextStyle","pageIconColor","action","active","pageIconInactiveColor","disabled","toolbox","iconStyle","borderColor","tooltip","line","showSymbol","symbol","symbolSize","smooth","emphasis","bar","barMaxWidth","itemStyle","borderWidth","gauge","detail","fontWeight","valueAnimation","distance","splitNumber","noDataOption","xAxis","yAxis","sparkline","container","padding","default","parseInt","spacing","thresholds","defaultColor","success","main","warning","error"],"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,KAAK,QAAQ,WAAW,CAAC;AAGlC,MAAMC,kBAAkB,GAAG,MAAM,AAAC;AAKlC,OAAO,SAASC,mBAAmB,CAACC,QAAkB,EAAEC,YAA0B,EAAqB;QAC5ED,GAAqB,EAyF3BA,IAAiB,QACTA,IAAiB;QA1FnBA,IAA8B;IAAvD,MAAME,gBAAgB,GAAGF,CAAAA,IAA8B,GAA9BA,CAAAA,GAAqB,GAArBA,QAAQ,CAACG,OAAO,CAACC,IAAI,cAArBJ,GAAqB,WAAS,GAA9BA,KAAAA,CAA8B,GAA9BA,GAAqB,CAAEK,OAAO,cAA9BL,IAA8B,cAA9BA,IAA8B,GAAIF,kBAAkB,AAAC;IAE9E,MAAMQ,iBAAiB,GAAiB;QACtCC,KAAK,EAAE;YACLC,IAAI,EAAE,KAAK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C;YACRnB,KAAK,EAAE,SAAS;SACjB;QACDwD,SAAS,EAAE;YACTC,OAAO,EAAE;gBACPC,OAAO,EAAEC,QAAQ,CAACrE,QAAQ,CAACsE,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;aAC7C;SACF;QACDC,UAAU,EAAE;YACVC,YAAY,EAAExE,QAAQ,CAACG,OAAO,CAACsE,OAAO,CAACC,IAAI;YAC3CvE,OAAO,EAAE;gBAAC,SAAS;gBAAEH,QAAQ,CAACG,OAAO,CAACwE,OAAO,CAACD,IAAI;gBAAE1E,QAAQ,CAACG,OAAO,CAACyE,KAAK,CAACF,IAAI;aAAC;SACjF;KACF,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/theme-gen.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Theme } from '@mui/material';\nimport merge from 'lodash/merge';\nimport { EChartsTheme, PersesChartsTheme } from '../model';\n\nconst DEFAULT_TEXT_COLOR = '#222';\n\n// avoid component override type errors since only palette and typography are used\ntype MuiTheme = Omit<Theme, 'components'>;\n\nexport function generateChartsTheme(muiTheme: MuiTheme, echartsTheme: EChartsTheme): PersesChartsTheme {\n const primaryTextColor = muiTheme.palette.text?.primary ?? DEFAULT_TEXT_COLOR;\n\n const muiConvertedTheme: EChartsTheme = {\n title: {\n show: false,\n },\n textStyle: {\n color: primaryTextColor,\n fontFamily: muiTheme.typography.fontFamily,\n fontSize: 12,\n },\n grid: {\n top: 5,\n right: 20,\n bottom: 0,\n left: 20,\n containLabel: true,\n },\n // Accessible categorical palette from: https://davidmathlogic.com/colorblind\n color: [\n '#56B4E9', // lt blue\n '#009E73', // med green\n '#0072B2', // dk blue\n '#CC79A7', // lt purple\n '#F0E442', // yellow\n '#E69F00', // orange\n '#D55E00', // red\n ],\n categoryAxis: {\n show: true,\n axisLabel: {\n show: true,\n color: primaryTextColor,\n margin: 15,\n },\n axisTick: {\n show: false,\n length: 6,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n axisLine: {\n show: true,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.6,\n },\n },\n splitArea: {\n show: false,\n areaStyle: {\n color: [muiTheme.palette.grey[300]],\n },\n },\n },\n valueAxis: {\n show: true,\n axisLabel: {\n color: primaryTextColor,\n margin: 12,\n },\n axisLine: {\n show: false,\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.6,\n },\n },\n },\n legend: {\n orient: 'horizontal',\n textStyle: {\n color: primaryTextColor,\n },\n pageTextStyle: {\n color: muiTheme.palette.grey[600],\n },\n pageIconColor: muiTheme?.palette?.action?.active,\n pageIconInactiveColor: muiTheme?.palette?.action?.disabled,\n },\n toolbox: {\n show: true,\n top: 10,\n right: 10,\n iconStyle: {\n borderColor: primaryTextColor,\n },\n },\n tooltip: {},\n line: {\n showSymbol: false,\n symbol: 'circle',\n symbolSize: 4,\n smooth: false,\n lineStyle: {\n width: 1,\n },\n emphasis: {\n lineStyle: {\n width: 1.5,\n },\n },\n },\n bar: {\n barMaxWidth: 150,\n itemStyle: {\n borderWidth: 0,\n borderColor: muiTheme.palette.grey[300],\n },\n },\n gauge: {\n detail: {\n fontSize: 18,\n fontWeight: 600,\n valueAnimation: false,\n },\n splitLine: {\n distance: 0,\n length: 4,\n lineStyle: {\n width: 1,\n },\n },\n splitNumber: 12,\n },\n };\n\n return {\n echartsTheme: merge(muiConvertedTheme, echartsTheme),\n noDataOption: {\n title: {\n show: true,\n textStyle: {\n color: primaryTextColor,\n fontSize: 16,\n fontWeight: 400,\n },\n text: 'No data',\n left: 'center',\n top: 'center',\n },\n xAxis: {\n show: false,\n },\n yAxis: {\n show: false,\n },\n },\n sparkline: {\n width: 2,\n color: '#1976d2',\n },\n container: {\n padding: {\n default: parseInt(muiTheme.spacing(1.5), 10),\n },\n },\n thresholds: {\n defaultColor: muiTheme.palette.success.main,\n palette: ['#FFCC00', muiTheme.palette.warning.main, muiTheme.palette.error.main],\n },\n };\n}\n"],"names":["merge","DEFAULT_TEXT_COLOR","generateChartsTheme","muiTheme","echartsTheme","primaryTextColor","palette","text","primary","muiConvertedTheme","title","show","textStyle","color","fontFamily","typography","fontSize","grid","top","right","bottom","left","containLabel","categoryAxis","axisLabel","margin","axisTick","length","lineStyle","grey","axisLine","splitLine","width","opacity","splitArea","areaStyle","valueAxis","legend","orient","pageTextStyle","pageIconColor","action","active","pageIconInactiveColor","disabled","toolbox","iconStyle","borderColor","tooltip","line","showSymbol","symbol","symbolSize","smooth","emphasis","bar","barMaxWidth","itemStyle","borderWidth","gauge","detail","fontWeight","valueAnimation","distance","splitNumber","noDataOption","xAxis","yAxis","sparkline","container","padding","default","parseInt","spacing","thresholds","defaultColor","success","main","warning","error"],"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,OAAOA,KAAK,MAAM,cAAc,CAAC;AAGjC,MAAMC,kBAAkB,GAAG,MAAM,AAAC;AAKlC,OAAO,SAASC,mBAAmB,CAACC,QAAkB,EAAEC,YAA0B,EAAqB;QAC5ED,GAAqB,EAyF3BA,IAAiB,QACTA,IAAiB;QA1FnBA,IAA8B;IAAvD,MAAME,gBAAgB,GAAGF,CAAAA,IAA8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6C,UAAU,EAAE,GAAG;iBAChB;gBACDtD,IAAI,EAAE,SAAS;gBACfc,IAAI,EAAE,QAAQ;gBACdH,GAAG,EAAE,QAAQ;aACd;YACDgD,KAAK,EAAE;gBACLvD,IAAI,EAAE,KAAK;aACZ;YACDwD,KAAK,EAAE;gBACLxD,IAAI,EAAE,KAAK;aACZ;SACF;QACDyD,SAAS,EAAE;YACTpC,KAAK,EAAE,CAAC;YACRnB,KAAK,EAAE,SAAS;SACjB;QACDwD,SAAS,EAAE;YACTC,OAAO,EAAE;gBACPC,OAAO,EAAEC,QAAQ,CAACrE,QAAQ,CAACsE,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;aAC7C;SACF;QACDC,UAAU,EAAE;YACVC,YAAY,EAAExE,QAAQ,CAACG,OAAO,CAACsE,OAAO,CAACC,IAAI;YAC3CvE,OAAO,EAAE;gBAAC,SAAS;gBAAEH,QAAQ,CAACG,OAAO,CAACwE,OAAO,CAACD,IAAI;gBAAE1E,QAAQ,CAACG,OAAO,CAACyE,KAAK,CAACF,IAAI;aAAC;SACjF;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "Common UI components used across Perses features",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"@codemirror/lang-json": "^6.0.1",
|
|
37
37
|
"@fontsource/lato": "^4.5.10",
|
|
38
38
|
"@mui/x-date-pickers": "^5.0.0-beta.1",
|
|
39
|
-
"@perses-dev/core": "0.
|
|
39
|
+
"@perses-dev/core": "0.34.0",
|
|
40
40
|
"@tanstack/react-table": "^8.9.1",
|
|
41
41
|
"@uiw/react-codemirror": "^4.19.1",
|
|
42
42
|
"date-fns": "^2.28.0",
|
|
43
43
|
"date-fns-tz": "^1.3.7",
|
|
44
44
|
"echarts": "npm:echarts-nightly@5.5.0-dev.20230517",
|
|
45
|
-
"lodash
|
|
45
|
+
"lodash": "^4.17.21",
|
|
46
46
|
"mathjs": "^10.6.4",
|
|
47
47
|
"mdi-material-ui": "^7.4.0",
|
|
48
48
|
"numbro": "^2.3.6",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"react-virtuoso": "^4.3.6"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@perses-dev/storybook": "0.
|
|
54
|
+
"@perses-dev/storybook": "0.34.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@mui/material": "^5.10.0",
|
|
@@ -60,8 +60,5 @@
|
|
|
60
60
|
},
|
|
61
61
|
"files": [
|
|
62
62
|
"dist"
|
|
63
|
-
]
|
|
64
|
-
"typedoc": {
|
|
65
|
-
"entryPoint": "./src/index.ts"
|
|
66
|
-
}
|
|
63
|
+
]
|
|
67
64
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { LegendOptions } from '../model';
|
|
3
|
-
export interface LegendOptionsEditorProps {
|
|
4
|
-
value?: LegendOptions;
|
|
5
|
-
onChange: (legend?: LegendOptions) => void;
|
|
6
|
-
}
|
|
7
|
-
export declare function LegendOptionsEditor({ value, onChange }: LegendOptionsEditorProps): JSX.Element;
|
|
8
|
-
//# sourceMappingURL=LegendOptionsEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegendOptionsEditor.d.ts","sourceRoot":"","sources":["../../src/LegendOptionsEditor/LegendOptionsEditor.tsx"],"names":[],"mappings":";AAeA,OAAO,EAKL,aAAa,EAId,MAAM,UAAU,CAAC;AAqBlB,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;CAC5C;AAED,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,wBAAwB,eAwEhF"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
-
import { Autocomplete, Switch, TextField } from '@mui/material';
|
|
15
|
-
import { ErrorAlert } from '../ErrorAlert';
|
|
16
|
-
import { DEFAULT_LEGEND, getLegendPosition, validateLegendSpec, LEGEND_POSITIONS_CONFIG, LEGEND_MODE_CONFIG, getLegendMode } from '../model';
|
|
17
|
-
import { OptionsEditorControl } from '../OptionsEditorLayout';
|
|
18
|
-
const POSITION_OPTIONS = Object.entries(LEGEND_POSITIONS_CONFIG).map(([id, config])=>{
|
|
19
|
-
return {
|
|
20
|
-
id: id,
|
|
21
|
-
...config
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
const MODE_OPTIONS = Object.entries(LEGEND_MODE_CONFIG).map(([id, config])=>{
|
|
25
|
-
return {
|
|
26
|
-
id: id,
|
|
27
|
-
...config
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
export function LegendOptionsEditor({ value , onChange }) {
|
|
31
|
-
const handleLegendShowChange = (_, checked)=>{
|
|
32
|
-
// legend is hidden when legend obj is undefined
|
|
33
|
-
const legendValue = checked === true ? {
|
|
34
|
-
position: DEFAULT_LEGEND.position
|
|
35
|
-
} : undefined;
|
|
36
|
-
onChange(legendValue);
|
|
37
|
-
};
|
|
38
|
-
const handleLegendPositionChange = (_, newValue)=>{
|
|
39
|
-
onChange({
|
|
40
|
-
...value,
|
|
41
|
-
position: newValue.id
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
const handleLegendModeChange = (_, newValue)=>{
|
|
45
|
-
onChange({
|
|
46
|
-
...value,
|
|
47
|
-
position: currentPosition,
|
|
48
|
-
mode: newValue.id
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
const isValidLegend = validateLegendSpec(value);
|
|
52
|
-
const currentPosition = getLegendPosition(value === null || value === void 0 ? void 0 : value.position);
|
|
53
|
-
const legendPositionConfig = LEGEND_POSITIONS_CONFIG[currentPosition];
|
|
54
|
-
const currentMode = getLegendMode(value === null || value === void 0 ? void 0 : value.mode);
|
|
55
|
-
const legendModeConfig = LEGEND_MODE_CONFIG[currentMode];
|
|
56
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
57
|
-
children: [
|
|
58
|
-
!isValidLegend && /*#__PURE__*/ _jsx(ErrorAlert, {
|
|
59
|
-
error: {
|
|
60
|
-
name: 'invalid-legend',
|
|
61
|
-
message: 'Invalid legend spec'
|
|
62
|
-
}
|
|
63
|
-
}),
|
|
64
|
-
/*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
65
|
-
label: "Show",
|
|
66
|
-
control: /*#__PURE__*/ _jsx(Switch, {
|
|
67
|
-
checked: value !== undefined,
|
|
68
|
-
onChange: handleLegendShowChange
|
|
69
|
-
})
|
|
70
|
-
}),
|
|
71
|
-
/*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
72
|
-
label: "Position",
|
|
73
|
-
control: /*#__PURE__*/ _jsx(Autocomplete, {
|
|
74
|
-
value: {
|
|
75
|
-
...legendPositionConfig,
|
|
76
|
-
id: currentPosition
|
|
77
|
-
},
|
|
78
|
-
options: POSITION_OPTIONS,
|
|
79
|
-
isOptionEqualToValue: (option, value)=>option.id === value.id,
|
|
80
|
-
renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
|
|
81
|
-
...params
|
|
82
|
-
}),
|
|
83
|
-
onChange: handleLegendPositionChange,
|
|
84
|
-
disabled: value === undefined,
|
|
85
|
-
disableClearable: true
|
|
86
|
-
})
|
|
87
|
-
}),
|
|
88
|
-
/*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
89
|
-
label: "Mode",
|
|
90
|
-
control: /*#__PURE__*/ _jsx(Autocomplete, {
|
|
91
|
-
value: {
|
|
92
|
-
...legendModeConfig,
|
|
93
|
-
id: currentMode
|
|
94
|
-
},
|
|
95
|
-
options: MODE_OPTIONS,
|
|
96
|
-
isOptionEqualToValue: (option, value)=>option.id === value.id,
|
|
97
|
-
renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
|
|
98
|
-
...params
|
|
99
|
-
}),
|
|
100
|
-
onChange: handleLegendModeChange,
|
|
101
|
-
disabled: value === undefined,
|
|
102
|
-
disableClearable: true
|
|
103
|
-
})
|
|
104
|
-
})
|
|
105
|
-
]
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
//# sourceMappingURL=LegendOptionsEditor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/LegendOptionsEditor/LegendOptionsEditor.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 { Autocomplete, Switch, SwitchProps, TextField } from '@mui/material';\nimport { ErrorAlert } from '../ErrorAlert';\nimport {\n DEFAULT_LEGEND,\n getLegendPosition,\n validateLegendSpec,\n LEGEND_POSITIONS_CONFIG,\n LegendOptions,\n LegendSingleSelectConfig,\n LEGEND_MODE_CONFIG,\n getLegendMode,\n} from '../model';\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\n\ntype LegendPositionOption = LegendSingleSelectConfig & { id: LegendOptions['position'] };\n\nconst POSITION_OPTIONS: LegendPositionOption[] = Object.entries(LEGEND_POSITIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as LegendOptions['position'],\n ...config,\n };\n});\n\ntype LegendModeOption = LegendSingleSelectConfig & { id: LegendOptions['mode'] };\n\nconst MODE_OPTIONS: LegendModeOption[] = Object.entries(LEGEND_MODE_CONFIG).map(([id, config]) => {\n return {\n id: id as LegendOptions['mode'],\n ...config,\n };\n});\n\nexport interface LegendOptionsEditorProps {\n value?: LegendOptions;\n onChange: (legend?: LegendOptions) => void;\n}\n\nexport function LegendOptionsEditor({ value, onChange }: LegendOptionsEditorProps) {\n const handleLegendShowChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n // legend is hidden when legend obj is undefined\n const legendValue = checked === true ? { position: DEFAULT_LEGEND.position } : undefined;\n onChange(legendValue);\n };\n\n const handleLegendPositionChange = (_: unknown, newValue: LegendPositionOption) => {\n onChange({\n ...value,\n position: newValue.id,\n });\n };\n\n const handleLegendModeChange = (_: unknown, newValue: LegendModeOption) => {\n onChange({\n ...value,\n position: currentPosition,\n mode: newValue.id,\n });\n };\n\n const isValidLegend = validateLegendSpec(value);\n const currentPosition = getLegendPosition(value?.position);\n const legendPositionConfig = LEGEND_POSITIONS_CONFIG[currentPosition];\n\n const currentMode = getLegendMode(value?.mode);\n const legendModeConfig = LEGEND_MODE_CONFIG[currentMode];\n\n return (\n <>\n {!isValidLegend && <ErrorAlert error={{ name: 'invalid-legend', message: 'Invalid legend spec' }} />}\n <OptionsEditorControl\n label=\"Show\"\n control={<Switch checked={value !== undefined} onChange={handleLegendShowChange} />}\n />\n <OptionsEditorControl\n label=\"Position\"\n control={\n <Autocomplete\n value={{\n ...legendPositionConfig,\n id: currentPosition,\n }}\n options={POSITION_OPTIONS}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n renderInput={(params) => <TextField {...params} />}\n onChange={handleLegendPositionChange}\n disabled={value === undefined}\n disableClearable\n ></Autocomplete>\n }\n />\n <OptionsEditorControl\n label=\"Mode\"\n control={\n <Autocomplete\n value={{\n ...legendModeConfig,\n id: currentMode,\n }}\n options={MODE_OPTIONS}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n renderInput={(params) => <TextField {...params} />}\n onChange={handleLegendModeChange}\n disabled={value === undefined}\n disableClearable\n ></Autocomplete>\n }\n />\n </>\n );\n}\n"],"names":["Autocomplete","Switch","TextField","ErrorAlert","DEFAULT_LEGEND","getLegendPosition","validateLegendSpec","LEGEND_POSITIONS_CONFIG","LEGEND_MODE_CONFIG","getLegendMode","OptionsEditorControl","POSITION_OPTIONS","Object","entries","map","id","config","MODE_OPTIONS","LegendOptionsEditor","value","onChange","handleLegendShowChange","_","checked","legendValue","position","undefined","handleLegendPositionChange","newValue","handleLegendModeChange","currentPosition","mode","isValidLegend","legendPositionConfig","currentMode","legendModeConfig","error","name","message","label","control","options","isOptionEqualToValue","option","renderInput","params","disabled","disableClearable"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,YAAY,EAAEC,MAAM,EAAeC,SAAS,QAAQ,eAAe,CAAC;AAC7E,SAASC,UAAU,QAAQ,eAAe,CAAC;AAC3C,SACEC,cAAc,EACdC,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,EAG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AAgB;kBACF;cAElB;0BACF,KAACrC,oBAAoB;gBACnB6B,KAAK,EAAC,MAAM;gBACZC,OAAO,gBACL,KAACxC,YAAY;oBACXmB,KAAK,EAAE;wBACL,GAAGgB,gBAAgB;wBACnBpB,EAAE,EAAEmB,WAAW;qBAChB;oBACDO,OAAO,EAAExB,YAAY;oBACrByB,oBAAoB,EAAE,CAACC,MAAM,EAAExB,KAAK,GAAKwB,MAAM,CAAC5B,EAAE,KAAKI,KAAK,CAACJ,EAAE;oBAC/D6B,WAAW,EAAE,CAACC,MAAM,iBAAK,KAAC3C,SAAS;4BAAE,GAAG2C,MAAM;0BAAI;oBAClDzB,QAAQ,EAAES,sBAAsB;oBAChCiB,QAAQ,EAAE3B,KAAK,KAAKO,SAAS;oBAC7BqB,gBAAgB;kBACF;cAElB;;MACD,CACH;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/LegendOptionsEditor/index.ts"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/LegendOptionsEditor/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './LegendOptionsEditor';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "LegendOptionsEditor", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: ()=>LegendOptionsEditor
|
|
20
|
-
});
|
|
21
|
-
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _material = require("@mui/material");
|
|
23
|
-
const _errorAlert = require("../ErrorAlert");
|
|
24
|
-
const _model = require("../model");
|
|
25
|
-
const _optionsEditorLayout = require("../OptionsEditorLayout");
|
|
26
|
-
const POSITION_OPTIONS = Object.entries(_model.LEGEND_POSITIONS_CONFIG).map(([id, config])=>{
|
|
27
|
-
return {
|
|
28
|
-
id: id,
|
|
29
|
-
...config
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
const MODE_OPTIONS = Object.entries(_model.LEGEND_MODE_CONFIG).map(([id, config])=>{
|
|
33
|
-
return {
|
|
34
|
-
id: id,
|
|
35
|
-
...config
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
function LegendOptionsEditor({ value , onChange }) {
|
|
39
|
-
const handleLegendShowChange = (_, checked)=>{
|
|
40
|
-
// legend is hidden when legend obj is undefined
|
|
41
|
-
const legendValue = checked === true ? {
|
|
42
|
-
position: _model.DEFAULT_LEGEND.position
|
|
43
|
-
} : undefined;
|
|
44
|
-
onChange(legendValue);
|
|
45
|
-
};
|
|
46
|
-
const handleLegendPositionChange = (_, newValue)=>{
|
|
47
|
-
onChange({
|
|
48
|
-
...value,
|
|
49
|
-
position: newValue.id
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
const handleLegendModeChange = (_, newValue)=>{
|
|
53
|
-
onChange({
|
|
54
|
-
...value,
|
|
55
|
-
position: currentPosition,
|
|
56
|
-
mode: newValue.id
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
const isValidLegend = (0, _model.validateLegendSpec)(value);
|
|
60
|
-
const currentPosition = (0, _model.getLegendPosition)(value === null || value === void 0 ? void 0 : value.position);
|
|
61
|
-
const legendPositionConfig = _model.LEGEND_POSITIONS_CONFIG[currentPosition];
|
|
62
|
-
const currentMode = (0, _model.getLegendMode)(value === null || value === void 0 ? void 0 : value.mode);
|
|
63
|
-
const legendModeConfig = _model.LEGEND_MODE_CONFIG[currentMode];
|
|
64
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
65
|
-
children: [
|
|
66
|
-
!isValidLegend && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_errorAlert.ErrorAlert, {
|
|
67
|
-
error: {
|
|
68
|
-
name: 'invalid-legend',
|
|
69
|
-
message: 'Invalid legend spec'
|
|
70
|
-
}
|
|
71
|
-
}),
|
|
72
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
|
|
73
|
-
label: "Show",
|
|
74
|
-
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
75
|
-
checked: value !== undefined,
|
|
76
|
-
onChange: handleLegendShowChange
|
|
77
|
-
})
|
|
78
|
-
}),
|
|
79
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
|
|
80
|
-
label: "Position",
|
|
81
|
-
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Autocomplete, {
|
|
82
|
-
value: {
|
|
83
|
-
...legendPositionConfig,
|
|
84
|
-
id: currentPosition
|
|
85
|
-
},
|
|
86
|
-
options: POSITION_OPTIONS,
|
|
87
|
-
isOptionEqualToValue: (option, value)=>option.id === value.id,
|
|
88
|
-
renderInput: (params)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
89
|
-
...params
|
|
90
|
-
}),
|
|
91
|
-
onChange: handleLegendPositionChange,
|
|
92
|
-
disabled: value === undefined,
|
|
93
|
-
disableClearable: true
|
|
94
|
-
})
|
|
95
|
-
}),
|
|
96
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
|
|
97
|
-
label: "Mode",
|
|
98
|
-
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Autocomplete, {
|
|
99
|
-
value: {
|
|
100
|
-
...legendModeConfig,
|
|
101
|
-
id: currentMode
|
|
102
|
-
},
|
|
103
|
-
options: MODE_OPTIONS,
|
|
104
|
-
isOptionEqualToValue: (option, value)=>option.id === value.id,
|
|
105
|
-
renderInput: (params)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
106
|
-
...params
|
|
107
|
-
}),
|
|
108
|
-
onChange: handleLegendModeChange,
|
|
109
|
-
disabled: value === undefined,
|
|
110
|
-
disableClearable: true
|
|
111
|
-
})
|
|
112
|
-
})
|
|
113
|
-
]
|
|
114
|
-
});
|
|
115
|
-
}
|
package/dist/cjs/model/legend.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
function _export(target, all) {
|
|
18
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: all[name]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
legendPositions: ()=>legendPositions,
|
|
25
|
-
legendModes: ()=>legendModes,
|
|
26
|
-
LEGEND_POSITIONS_CONFIG: ()=>LEGEND_POSITIONS_CONFIG,
|
|
27
|
-
LEGEND_MODE_CONFIG: ()=>LEGEND_MODE_CONFIG,
|
|
28
|
-
DEFAULT_LEGEND: ()=>DEFAULT_LEGEND,
|
|
29
|
-
getLegendPosition: ()=>getLegendPosition,
|
|
30
|
-
isValidLegendPosition: ()=>isValidLegendPosition,
|
|
31
|
-
isValidLegendMode: ()=>isValidLegendMode,
|
|
32
|
-
getLegendMode: ()=>getLegendMode,
|
|
33
|
-
validateLegendSpec: ()=>validateLegendSpec,
|
|
34
|
-
isLegendItemVisuallySelected: ()=>isLegendItemVisuallySelected
|
|
35
|
-
});
|
|
36
|
-
const legendPositions = [
|
|
37
|
-
'Bottom',
|
|
38
|
-
'Right'
|
|
39
|
-
];
|
|
40
|
-
const legendModes = [
|
|
41
|
-
'List',
|
|
42
|
-
'Table'
|
|
43
|
-
];
|
|
44
|
-
const LEGEND_POSITIONS_CONFIG = {
|
|
45
|
-
Bottom: {
|
|
46
|
-
label: 'Bottom'
|
|
47
|
-
},
|
|
48
|
-
Right: {
|
|
49
|
-
label: 'Right'
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const LEGEND_MODE_CONFIG = {
|
|
53
|
-
List: {
|
|
54
|
-
label: 'List'
|
|
55
|
-
},
|
|
56
|
-
Table: {
|
|
57
|
-
label: 'Table'
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const DEFAULT_LEGEND = {
|
|
61
|
-
position: 'Bottom',
|
|
62
|
-
mode: 'List'
|
|
63
|
-
};
|
|
64
|
-
function getLegendPosition(position) {
|
|
65
|
-
if (position === undefined) {
|
|
66
|
-
return DEFAULT_LEGEND.position;
|
|
67
|
-
}
|
|
68
|
-
if (isValidLegendPosition(position)) {
|
|
69
|
-
return position;
|
|
70
|
-
}
|
|
71
|
-
return DEFAULT_LEGEND.position;
|
|
72
|
-
}
|
|
73
|
-
function isValidLegendPosition(position) {
|
|
74
|
-
return legendPositions.includes(position);
|
|
75
|
-
}
|
|
76
|
-
function isValidLegendMode(mode) {
|
|
77
|
-
return legendModes.includes(mode);
|
|
78
|
-
}
|
|
79
|
-
function getLegendMode(mode) {
|
|
80
|
-
if (!mode || !isValidLegendMode(mode)) {
|
|
81
|
-
return DEFAULT_LEGEND.mode;
|
|
82
|
-
}
|
|
83
|
-
return mode;
|
|
84
|
-
}
|
|
85
|
-
function validateLegendSpec(legend) {
|
|
86
|
-
if (legend === undefined) {
|
|
87
|
-
// undefined is valid since this is how legend is hidden by default
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
if (!isValidLegendPosition(legend.position)) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
if (legend.mode && !isValidLegendMode(legend.mode)) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
function isLegendItemVisuallySelected(item, selectedItems) {
|
|
99
|
-
// In the "ALL" case, technically all legend items are selected, but we do
|
|
100
|
-
// not render them differently.
|
|
101
|
-
return selectedItems !== 'ALL' && !!selectedItems[item.id];
|
|
102
|
-
}
|
package/dist/model/legend.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { MouseEventHandler } from 'react';
|
|
2
|
-
export declare const legendPositions: readonly ["Bottom", "Right"];
|
|
3
|
-
export declare type LegendPositions = (typeof legendPositions)[number];
|
|
4
|
-
export declare const legendModes: readonly ["List", "Table"];
|
|
5
|
-
export declare type LegendMode = (typeof legendModes)[number];
|
|
6
|
-
export interface LegendOptions {
|
|
7
|
-
position: LegendPositions;
|
|
8
|
-
mode?: LegendMode;
|
|
9
|
-
}
|
|
10
|
-
export interface LegendItem {
|
|
11
|
-
id: string;
|
|
12
|
-
label: string;
|
|
13
|
-
color: string;
|
|
14
|
-
onClick?: MouseEventHandler<HTMLElement>;
|
|
15
|
-
}
|
|
16
|
-
export declare type LegendSingleSelectConfig = {
|
|
17
|
-
label: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* State of selected items in the legend.
|
|
21
|
-
* - When "ALL", all legend items are selected, but not visually highlighted.
|
|
22
|
-
* - Otherwise, it is a Record that associates legend item ids with a boolean
|
|
23
|
-
* value. When the associated entry for a legend item is `true`, that item
|
|
24
|
-
* will be treated as selected and visually highlighted.
|
|
25
|
-
*/
|
|
26
|
-
export declare type SelectedLegendItemState = Record<LegendItem['id'], boolean> | 'ALL';
|
|
27
|
-
export declare const LEGEND_POSITIONS_CONFIG: Readonly<Record<LegendPositions, LegendSingleSelectConfig>>;
|
|
28
|
-
export declare const LEGEND_MODE_CONFIG: Readonly<Record<LegendMode, LegendSingleSelectConfig>>;
|
|
29
|
-
export declare const DEFAULT_LEGEND: Required<LegendOptions>;
|
|
30
|
-
export declare function getLegendPosition(position?: LegendPositions): "Bottom" | "Right";
|
|
31
|
-
export declare function isValidLegendPosition(position: LegendPositions): boolean;
|
|
32
|
-
export declare function isValidLegendMode(mode: LegendMode): boolean;
|
|
33
|
-
export declare function getLegendMode(mode?: LegendMode): "List" | "Table";
|
|
34
|
-
export declare function validateLegendSpec(legend?: LegendOptions): boolean;
|
|
35
|
-
export declare function isLegendItemVisuallySelected(item: LegendItem, selectedItems: SelectedLegendItemState): boolean;
|
|
36
|
-
//# sourceMappingURL=legend.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/model/legend.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,eAAO,MAAM,eAAe,8BAA+B,CAAC;AAC5D,oBAAY,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,eAAO,MAAM,WAAW,4BAA6B,CAAC;AACtD,oBAAY,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAC1C;AAED,oBAAY,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;GAMG;AACH,oBAAY,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;AAEhF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,wBAAwB,CAAC,CAG/F,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAGrF,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,QAAQ,C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