@perses-dev/components 0.13.0 → 0.15.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/{TimeRangeSelector → DateTimeRangePicker}/AbsoluteTimePicker.d.ts +0 -0
- package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/AbsoluteTimePicker.js +38 -33
- package/dist/DateTimeRangePicker/AbsoluteTimePicker.js.map +1 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +11 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.js +77 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/TimeRangeSelector.d.ts +0 -0
- package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/TimeRangeSelector.js +0 -0
- package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/index.d.ts +1 -0
- package/dist/DateTimeRangePicker/index.d.ts.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/index.js +1 -0
- package/dist/DateTimeRangePicker/index.js.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/utils.d.ts +0 -0
- package/dist/DateTimeRangePicker/utils.d.ts.map +1 -0
- package/dist/{TimeRangeSelector → DateTimeRangePicker}/utils.js +0 -0
- package/dist/DateTimeRangePicker/utils.js.map +1 -0
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +0 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/GaugeChart/GaugeChart.js +3 -3
- package/dist/GaugeChart/GaugeChart.js.map +1 -1
- package/dist/Legend/CompactLegend.d.ts +6 -1
- package/dist/Legend/CompactLegend.d.ts.map +1 -1
- package/dist/Legend/CompactLegend.js +16 -7
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +4 -9
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/ListLegend.d.ts +3 -0
- package/dist/Legend/ListLegend.d.ts.map +1 -1
- package/dist/Legend/ListLegend.js +18 -2
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +2 -1
- package/dist/Legend/ListLegendItem.d.ts.map +1 -1
- package/dist/Legend/ListLegendItem.js +11 -9
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/LineChart/LineChart.js +1 -1
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/StatChart/StatChart.js +1 -1
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/StatChart/StatChart.test.js +1 -2
- package/dist/StatChart/StatChart.test.js.map +1 -1
- package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/AbsoluteTimePicker.js +37 -32
- package/dist/cjs/DateTimeRangePicker/DateTimeRangePicker.js +83 -0
- package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/TimeRangeSelector.js +0 -0
- package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/index.js +1 -0
- package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/utils.js +0 -0
- package/dist/cjs/Drawer/Drawer.js +0 -1
- package/dist/cjs/GaugeChart/GaugeChart.js +3 -3
- package/dist/cjs/Legend/CompactLegend.js +12 -6
- package/dist/cjs/Legend/Legend.js +4 -9
- package/dist/cjs/Legend/ListLegend.js +15 -1
- package/dist/cjs/Legend/ListLegendItem.js +48 -13
- package/dist/cjs/LineChart/LineChart.js +1 -1
- package/dist/cjs/StatChart/StatChart.js +1 -1
- package/dist/cjs/StatChart/StatChart.test.js +2 -3
- package/dist/cjs/context/ChartsThemeProvider.js +1 -6
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/model/units.js +1 -1
- package/dist/cjs/test/index.js +0 -1
- package/dist/cjs/test-utils/index.js +28 -0
- package/dist/cjs/{test → test-utils}/theme.js +0 -1
- package/dist/cjs/utils/mathjs.js +25 -0
- package/dist/cjs/utils/theme-gen.js +1 -2
- package/dist/cjs/utils/theme-gen.test.js +1 -2
- package/dist/context/ChartsThemeProvider.d.ts +0 -1
- package/dist/context/ChartsThemeProvider.d.ts.map +1 -1
- package/dist/context/ChartsThemeProvider.js +1 -6
- package/dist/context/ChartsThemeProvider.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/model/theme.d.ts +0 -1
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/model/units.js +1 -1
- package/dist/model/units.js.map +1 -1
- package/dist/test/index.d.ts +0 -1
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +0 -1
- package/dist/test/index.js.map +1 -1
- package/dist/test-utils/index.d.ts +2 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/test-utils/index.js +15 -0
- package/dist/test-utils/index.js.map +1 -0
- package/dist/test-utils/theme.d.ts +3 -0
- package/dist/test-utils/theme.d.ts.map +1 -0
- package/dist/{test → test-utils}/theme.js +0 -1
- package/dist/test-utils/theme.js.map +1 -0
- package/dist/utils/mathjs.d.ts +6 -0
- package/dist/utils/mathjs.d.ts.map +1 -0
- package/dist/utils/mathjs.js +20 -0
- package/dist/utils/mathjs.js.map +1 -0
- package/dist/utils/theme-gen.d.ts +1 -1
- package/dist/utils/theme-gen.d.ts.map +1 -1
- package/dist/utils/theme-gen.js +1 -2
- package/dist/utils/theme-gen.js.map +1 -1
- package/dist/utils/theme-gen.test.js +1 -2
- package/dist/utils/theme-gen.test.js.map +1 -1
- package/package.json +7 -2
- package/dist/TimeRangeSelector/AbsoluteTimePicker.d.ts.map +0 -1
- package/dist/TimeRangeSelector/AbsoluteTimePicker.js.map +0 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +0 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +0 -1
- package/dist/TimeRangeSelector/index.d.ts.map +0 -1
- package/dist/TimeRangeSelector/index.js.map +0 -1
- package/dist/TimeRangeSelector/utils.d.ts.map +0 -1
- package/dist/TimeRangeSelector/utils.js.map +0 -1
- package/dist/test/theme.d.ts +0 -3
- package/dist/test/theme.d.ts.map +0 -1
- package/dist/test/theme.js.map +0 -1
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbsoluteTimePicker.d.ts","sourceRoot":"","sources":["../../src/DateTimeRangePicker/AbsoluteTimePicker.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAKrD,UAAU,qBAAqB;IAC7B,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,QAAQ,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,kBAAkB,mCAAoC,qBAAqB,gBAsIvF,CAAC"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { useState } from 'react';
|
|
15
|
-
import { Box, Stack, TextField,
|
|
15
|
+
import { Box, Stack, TextField, Typography } from '@mui/material';
|
|
16
16
|
import { LocalizationProvider, StaticDateTimePicker } from '@mui/x-date-pickers';
|
|
17
17
|
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
18
18
|
import { format } from 'date-fns';
|
|
@@ -53,10 +53,10 @@ export const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
|
53
53
|
return /*#__PURE__*/ _jsx(LocalizationProvider, {
|
|
54
54
|
dateAdapter: AdapterDateFns,
|
|
55
55
|
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
56
|
-
spacing:
|
|
57
|
-
sx: {
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
spacing: 2,
|
|
57
|
+
sx: (theme)=>({
|
|
58
|
+
padding: theme.spacing(1, 0, 2)
|
|
59
|
+
}),
|
|
60
60
|
children: [
|
|
61
61
|
showStartCalendar && /*#__PURE__*/ _jsxs(Box, {
|
|
62
62
|
sx: (theme)=>({
|
|
@@ -72,7 +72,9 @@ export const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
|
72
72
|
}
|
|
73
73
|
}),
|
|
74
74
|
children: [
|
|
75
|
-
/*#__PURE__*/ _jsx(
|
|
75
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
76
|
+
variant: "h3",
|
|
77
|
+
padding: 1,
|
|
76
78
|
children: "Select Start Time"
|
|
77
79
|
}),
|
|
78
80
|
/*#__PURE__*/ _jsx(StaticDateTimePicker, {
|
|
@@ -111,7 +113,9 @@ export const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
|
111
113
|
}
|
|
112
114
|
}),
|
|
113
115
|
children: [
|
|
114
|
-
/*#__PURE__*/ _jsx(
|
|
116
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
117
|
+
variant: "h3",
|
|
118
|
+
padding: 1,
|
|
115
119
|
children: "Select End Time"
|
|
116
120
|
}),
|
|
117
121
|
/*#__PURE__*/ _jsx(StaticDateTimePicker, {
|
|
@@ -139,33 +143,34 @@ export const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
|
139
143
|
})
|
|
140
144
|
]
|
|
141
145
|
}),
|
|
142
|
-
/*#__PURE__*/
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
146
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
147
|
+
direction: "row",
|
|
148
|
+
alignItems: "center",
|
|
149
|
+
gap: 1,
|
|
150
|
+
pl: 1,
|
|
151
|
+
pr: 1,
|
|
152
|
+
children: [
|
|
153
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
154
|
+
onChange: (event)=>{
|
|
155
|
+
// TODO: add helperText, fix validation after we decide on form state solution
|
|
156
|
+
updateDateRange(event.target.value, true);
|
|
157
|
+
},
|
|
158
|
+
value: format(timeRange.start, DATE_TIME_FORMAT),
|
|
159
|
+
label: "Start Time",
|
|
160
|
+
placeholder: "mm/dd/yyyy hh:mm",
|
|
161
|
+
// tel used to match MUI DateTimePicker, may change in future: https://github.com/mui/material-ui/issues/27590
|
|
162
|
+
type: "tel"
|
|
163
|
+
}),
|
|
164
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
165
|
+
onChange: (event)=>{
|
|
166
|
+
updateDateRange(event.target.value, false);
|
|
167
|
+
},
|
|
168
|
+
value: format(timeRange.end, DATE_TIME_FORMAT),
|
|
169
|
+
label: "End Time",
|
|
170
|
+
placeholder: "mm/dd/yyyy hh:mm",
|
|
171
|
+
type: "tel"
|
|
158
172
|
})
|
|
159
|
-
|
|
160
|
-
/*#__PURE__*/ _jsx(TextField, {
|
|
161
|
-
fullWidth: true,
|
|
162
|
-
onChange: (event)=>{
|
|
163
|
-
updateDateRange(event.target.value, false);
|
|
164
|
-
},
|
|
165
|
-
value: format(timeRange.end, DATE_TIME_FORMAT),
|
|
166
|
-
label: "End Time",
|
|
167
|
-
placeholder: "mm/dd/yyyy hh:mm",
|
|
168
|
-
type: "tel"
|
|
173
|
+
]
|
|
169
174
|
})
|
|
170
175
|
]
|
|
171
176
|
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/DateTimeRangePicker/AbsoluteTimePicker.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { Box, Stack, TextField, Typography } from '@mui/material';\nimport { LocalizationProvider, StaticDateTimePicker } from '@mui/x-date-pickers';\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';\nimport { format } from 'date-fns';\nimport { AbsoluteTimeRange } from '@perses-dev/core';\nimport { validateDateRange } from './utils';\n\nconst DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';\n\ninterface AbsoluteTimeFormProps {\n initialTimeRange: AbsoluteTimeRange;\n onChange: (timeRange: AbsoluteTimeRange) => void;\n}\n\nexport const AbsoluteTimePicker = ({ initialTimeRange, onChange }: AbsoluteTimeFormProps) => {\n const [timeRange, setTimeRange] = useState<AbsoluteTimeRange>(initialTimeRange);\n const [showStartCalendar, setShowStartCalendar] = useState<boolean>(true);\n\n // validate start and end time, propagate changes\n const updateDateRange = (input: string, isStartDate: boolean) => {\n const newDate = new Date(input);\n if (isStartDate === true) {\n const isValidDateRange = validateDateRange(newDate, timeRange.end);\n if (isValidDateRange === true) {\n setTimeRange((current) => {\n const updatedRange = { start: newDate, end: current.end };\n onChange(updatedRange);\n return updatedRange;\n });\n }\n } else {\n const isValidDateRange = validateDateRange(timeRange.start, newDate);\n if (isValidDateRange === true) {\n setTimeRange((current) => {\n const updatedRange = { start: current.start, end: newDate };\n onChange(updatedRange);\n return updatedRange;\n });\n }\n }\n };\n\n return (\n <LocalizationProvider dateAdapter={AdapterDateFns}>\n <Stack\n spacing={2}\n sx={(theme) => ({\n padding: theme.spacing(1, 0, 2),\n })}\n >\n {showStartCalendar && (\n <Box\n sx={(theme) => ({\n // TODO: create separate reusable calendar component\n '.MuiPickerStaticWrapper-content': {\n backgroundColor: theme.palette.background.default,\n },\n // reposition AM and PM buttons\n '.MuiIconButton-sizeMedium': {\n top: 80,\n bottom: 'auto',\n margin: theme.spacing(0, 3),\n },\n })}\n >\n <Typography variant=\"h3\" padding={1}>\n Select Start Time\n </Typography>\n <StaticDateTimePicker\n displayStaticWrapperAs=\"desktop\"\n openTo=\"day\"\n disableHighlightToday={true}\n value={initialTimeRange.start}\n onChange={(newValue) => {\n if (newValue === null) return;\n setTimeRange((current) => {\n return { start: newValue, end: current.end };\n });\n }}\n onAccept={() => {\n setShowStartCalendar(false);\n }}\n renderInput={(params) => <TextField {...params} />}\n />\n </Box>\n )}\n {!showStartCalendar && (\n <Box\n sx={(theme) => ({\n '.MuiPickerStaticWrapper-content': {\n backgroundColor: theme.palette.background.default,\n },\n // reposition AM and PM buttons\n '.MuiIconButton-sizeMedium': {\n top: 80,\n bottom: 'auto',\n margin: theme.spacing(0, 3),\n },\n })}\n >\n <Typography variant=\"h3\" padding={1}>\n Select End Time\n </Typography>\n <StaticDateTimePicker\n displayStaticWrapperAs=\"desktop\"\n openTo=\"day\"\n disableHighlightToday={true}\n value={initialTimeRange.end}\n minDateTime={timeRange.start}\n onChange={(newValue) => {\n if (newValue === null) return;\n setTimeRange((current) => {\n return { start: current.start, end: newValue };\n });\n }}\n onAccept={() => {\n setShowStartCalendar(true);\n onChange(timeRange);\n }}\n renderInput={(params) => <TextField {...params} />}\n />\n </Box>\n )}\n <Stack direction=\"row\" alignItems=\"center\" gap={1} pl={1} pr={1}>\n <TextField\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n // TODO: add helperText, fix validation after we decide on form state solution\n updateDateRange(event.target.value, true);\n }}\n value={format(timeRange.start, DATE_TIME_FORMAT)}\n label=\"Start Time\"\n placeholder=\"mm/dd/yyyy hh:mm\"\n // tel used to match MUI DateTimePicker, may change in future: https://github.com/mui/material-ui/issues/27590\n type=\"tel\"\n />\n <TextField\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n updateDateRange(event.target.value, false);\n }}\n value={format(timeRange.end, DATE_TIME_FORMAT)}\n label=\"End Time\"\n placeholder=\"mm/dd/yyyy hh:mm\"\n type=\"tel\"\n />\n </Stack>\n </Stack>\n </LocalizationProvider>\n );\n};\n"],"names":["useState","Box","Stack","TextField","Typography","LocalizationProvider","StaticDateTimePicker","AdapterDateFns","format","validateDateRange","DATE_TIME_FORMAT","AbsoluteTimePicker","initialTimeRange","onChange","timeRange","setTimeRange","showStartCalendar","setShowStartCalendar","updateDateRange","input","isStartDate","newDate","Date","isValidDateRange","end","current","updatedRange","start","dateAdapter","spacing","sx","theme","padding","backgroundColor","palette","background","default","top","bottom","margin","variant","displayStaticWrapperAs","openTo","disableHighlightToday","value","newValue","onAccept","renderInput","params","minDateTime","direction","alignItems","gap","pl","pr","event","target","label","placeholder","type"],"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,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,GAAG,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAClE,SAASC,oBAAoB,EAAEC,oBAAoB,QAAQ,qBAAqB,CAAC;AACjF,SAASC,cAAc,QAAQ,oCAAoC,CAAC;AACpE,SAASC,MAAM,QAAQ,UAAU,CAAC;AAElC,SAASC,iBAAiB,QAAQ,SAAS,CAAC;AAE5C,MAAMC,gBAAgB,GAAG,qBAAqB,AAAC;AAO/C,OAAO,MAAMC,kBAAkB,GAAG,CAAC,EAAEC,gBAAgB,CAAA,EAAEC,QAAQ,CAAA,EAAyB,GAAK;IAC3F,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGf,QAAQ,CAAoB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KAACnD,SAAS;4BACRU,QAAQ,EAAE,CAAC0C,KAA0C,GAAK;gCACxD,8EAA8E;gCAC9ErC,eAAe,CAACqC,KAAK,CAACC,MAAM,CAACZ,KAAK,EAAE,IAAI,CAAC,CAAC;4BAC5C,CAAC;4BACDA,KAAK,EAAEpC,MAAM,CAACM,SAAS,CAACa,KAAK,EAAEjB,gBAAgB,CAAC;4BAChD+C,KAAK,EAAC,YAAY;4BAClBC,WAAW,EAAC,kBAAkB;4BAC9B,8GAA8G;4BAC9GC,IAAI,EAAC,KAAK;0BACV;sCACF,KAACxD,SAAS;4BACRU,QAAQ,EAAE,CAAC0C,KAA0C,GAAK;gCACxDrC,eAAe,CAACqC,KAAK,CAACC,MAAM,CAACZ,KAAK,EAAE,KAAK,CAAC,CAAC;4BAC7C,CAAC;4BACDA,KAAK,EAAEpC,MAAM,CAACM,SAAS,CAACU,GAAG,EAAEd,gBAAgB,CAAC;4BAC9C+C,KAAK,EAAC,UAAU;4BAChBC,WAAW,EAAC,kBAAkB;4BAC9BC,IAAI,EAAC,KAAK;0BACV;;kBACI;;UACF;MACa,CACvB;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TimeRangeValue } from '@perses-dev/core';
|
|
3
|
+
import { TimeOption } from './TimeRangeSelector';
|
|
4
|
+
interface DateTimeRangePickerProps {
|
|
5
|
+
value: TimeRangeValue;
|
|
6
|
+
onChange: (value: TimeRangeValue) => void;
|
|
7
|
+
timeOptions: TimeOption[];
|
|
8
|
+
}
|
|
9
|
+
export declare function DateTimeRangePicker(props: DateTimeRangePickerProps): JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=DateTimeRangePicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimeRangePicker.d.ts","sourceRoot":"","sources":["../../src/DateTimeRangePicker/DateTimeRangePicker.tsx"],"names":[],"mappings":";AAeA,OAAO,EAML,cAAc,EACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAqB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEpE,UAAU,wBAAwB;IAChC,KAAK,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,eAsDlE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Copyright 2022 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 } from "react/jsx-runtime";
|
|
14
|
+
import { useRef, useState, useMemo } from 'react';
|
|
15
|
+
import { Box, FormControl, Popover, Stack } from '@mui/material';
|
|
16
|
+
import { isRelativeTimeRange, toAbsoluteTimeRange } from '@perses-dev/core';
|
|
17
|
+
import { AbsoluteTimePicker } from './AbsoluteTimePicker';
|
|
18
|
+
import { TimeRangeSelector } from './TimeRangeSelector';
|
|
19
|
+
export function DateTimeRangePicker(props) {
|
|
20
|
+
const { value , onChange , timeOptions } = props;
|
|
21
|
+
const [showCustomDateSelector, setShowCustomDateSelector] = useState(false);
|
|
22
|
+
const anchorEl = useRef();
|
|
23
|
+
const convertedTimeRange = useMemo(()=>{
|
|
24
|
+
return isRelativeTimeRange(value) ? toAbsoluteTimeRange(value) : value;
|
|
25
|
+
}, [
|
|
26
|
+
value
|
|
27
|
+
]);
|
|
28
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
29
|
+
direction: "row",
|
|
30
|
+
spacing: 1,
|
|
31
|
+
children: [
|
|
32
|
+
/*#__PURE__*/ _jsx(Popover, {
|
|
33
|
+
anchorEl: anchorEl.current,
|
|
34
|
+
anchorOrigin: {
|
|
35
|
+
vertical: 'bottom',
|
|
36
|
+
horizontal: 'center'
|
|
37
|
+
},
|
|
38
|
+
open: showCustomDateSelector,
|
|
39
|
+
onClose: ()=>setShowCustomDateSelector(false),
|
|
40
|
+
sx: (theme)=>({
|
|
41
|
+
padding: theme.spacing(2)
|
|
42
|
+
}),
|
|
43
|
+
children: /*#__PURE__*/ _jsx(AbsoluteTimePicker, {
|
|
44
|
+
initialTimeRange: convertedTimeRange,
|
|
45
|
+
onChange: (value)=>{
|
|
46
|
+
onChange(value);
|
|
47
|
+
setShowCustomDateSelector(false);
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
}),
|
|
51
|
+
/*#__PURE__*/ _jsx(FormControl, {
|
|
52
|
+
fullWidth: true,
|
|
53
|
+
children: /*#__PURE__*/ _jsx(Box, {
|
|
54
|
+
ref: anchorEl,
|
|
55
|
+
children: /*#__PURE__*/ _jsx(TimeRangeSelector, {
|
|
56
|
+
timeOptions: timeOptions,
|
|
57
|
+
value: value,
|
|
58
|
+
onSelectChange: (event)=>{
|
|
59
|
+
const duration = event.target.value;
|
|
60
|
+
const relativeTimeInput = {
|
|
61
|
+
pastDuration: duration,
|
|
62
|
+
end: new Date()
|
|
63
|
+
};
|
|
64
|
+
onChange(relativeTimeInput);
|
|
65
|
+
setShowCustomDateSelector(false);
|
|
66
|
+
},
|
|
67
|
+
onCustomClick: ()=>{
|
|
68
|
+
setShowCustomDateSelector(true);
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=DateTimeRangePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/DateTimeRangePicker/DateTimeRangePicker.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useRef, useState, useMemo } from 'react';\nimport { Box, FormControl, Popover, Stack } from '@mui/material';\nimport {\n DurationString,\n RelativeTimeRange,\n AbsoluteTimeRange,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n TimeRangeValue,\n} from '@perses-dev/core';\nimport { AbsoluteTimePicker } from './AbsoluteTimePicker';\nimport { TimeRangeSelector, TimeOption } from './TimeRangeSelector';\n\ninterface DateTimeRangePickerProps {\n value: TimeRangeValue;\n onChange: (value: TimeRangeValue) => void;\n timeOptions: TimeOption[];\n}\n\nexport function DateTimeRangePicker(props: DateTimeRangePickerProps) {\n const { value, onChange, timeOptions } = props;\n\n const [showCustomDateSelector, setShowCustomDateSelector] = useState(false);\n const anchorEl = useRef();\n\n const convertedTimeRange = useMemo(() => {\n return isRelativeTimeRange(value) ? toAbsoluteTimeRange(value) : value;\n }, [value]);\n\n return (\n <Stack direction=\"row\" spacing={1}>\n <Popover\n anchorEl={anchorEl.current}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'center',\n }}\n open={showCustomDateSelector}\n onClose={() => setShowCustomDateSelector(false)}\n sx={(theme) => ({\n padding: theme.spacing(2),\n })}\n >\n <AbsoluteTimePicker\n initialTimeRange={convertedTimeRange}\n onChange={(value: AbsoluteTimeRange) => {\n onChange(value);\n setShowCustomDateSelector(false);\n }}\n />\n </Popover>\n <FormControl fullWidth>\n <Box ref={anchorEl}>\n <TimeRangeSelector\n timeOptions={timeOptions}\n value={value}\n onSelectChange={(event) => {\n const duration = event.target.value;\n const relativeTimeInput: RelativeTimeRange = {\n pastDuration: duration as DurationString,\n end: new Date(),\n };\n onChange(relativeTimeInput);\n setShowCustomDateSelector(false);\n }}\n onCustomClick={() => {\n setShowCustomDateSelector(true);\n }}\n />\n </Box>\n </FormControl>\n </Stack>\n );\n}\n"],"names":["useRef","useState","useMemo","Box","FormControl","Popover","Stack","isRelativeTimeRange","toAbsoluteTimeRange","AbsoluteTimePicker","TimeRangeSelector","DateTimeRangePicker","props","value","onChange","timeOptions","showCustomDateSelector","setShowCustomDateSelector","anchorEl","convertedTimeRange","direction","spacing","current","anchorOrigin","vertical","horizontal","open","onClose","sx","theme","padding","initialTimeRange","fullWidth","ref","onSelectChange","event","duration","target","relativeTimeInput","pastDuration","end","Date","onCustomClick"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,EAAEC,QAAQ,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAClD,SAASC,GAAG,EAAEC,WAAW,EAAEC,OAAO,EAAEC,KAAK,QAAQ,eAAe,CAAC;AACjE,SAIEC,mBAAmB,EACnBC,mBAAmB,QAEd,kBAAkB,CAAC;AAC1B,SAASC,kBAAkB,QAAQ,sBAAsB,CAAC;AAC1D,SAASC,iBAAiB,QAAoB,qBAAqB,CAAC;AAQpE,OAAO,SAASC,mBAAmB,CAACC,KAA+B,EAAE;IACnE,MAAM,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAEC,WAAW,CAAA,EAAE,GAAGH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,MAAM,CAACxB,KAAK,AAAC;4BACpC,MAAMyB,iBAAiB,GAAsB;gCAC3CC,YAAY,EAAEH,QAAQ;gCACtBI,GAAG,EAAE,IAAIC,IAAI,EAAE;6BAChB,AAAC;4BACF3B,QAAQ,CAACwB,iBAAiB,CAAC,CAAC;4BAC5BrB,yBAAyB,CAAC,KAAK,CAAC,CAAC;wBACnC,CAAC;wBACDyB,aAAa,EAAE,IAAM;4BACnBzB,yBAAyB,CAAC,IAAI,CAAC,CAAC;wBAClC,CAAC;sBACD;kBACE;cACM;;MACR,CACR;AACJ,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeRangeSelector.d.ts","sourceRoot":"","sources":["../../src/DateTimeRangePicker/TimeRangeSelector.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAoB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAuB,MAAM,kBAAkB,CAAC;AAK1F,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,iBAAiB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,cAAc,CAAC;IACtB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,cAAc,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IAC3D,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eA0C9D"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/DateTimeRangePicker/TimeRangeSelector.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MenuItem, Select, SelectChangeEvent } from '@mui/material';\nimport Calendar from 'mdi-material-ui/Calendar';\nimport { TimeRangeValue, RelativeTimeRange, isRelativeTimeRange } from '@perses-dev/core';\nimport { formatAbsoluteRange } from './utils';\n\nconst DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';\n\nexport interface TimeOption {\n value: RelativeTimeRange;\n display: string;\n}\n\ninterface TimeRangeSelectorProps {\n value: TimeRangeValue;\n timeOptions: TimeOption[];\n onSelectChange: (event: SelectChangeEvent<string>) => void;\n onCustomClick: () => void;\n}\n\nexport function TimeRangeSelector(props: TimeRangeSelectorProps) {\n const { value, timeOptions, onSelectChange, onCustomClick } = props;\n const formattedValue = !isRelativeTimeRange(value)\n ? formatAbsoluteRange(value, DATE_TIME_FORMAT)\n : value.pastDuration;\n return (\n <Select\n value={formattedValue}\n onChange={onSelectChange}\n IconComponent={Calendar}\n sx={{\n '.MuiSelect-icon': {\n marginTop: '1px',\n },\n }}\n >\n {timeOptions.map((item, idx) => (\n <MenuItem key={idx} value={item.value.pastDuration}>\n {item.display}\n </MenuItem>\n ))}\n\n {isRelativeTimeRange(value) ? (\n <MenuItem\n onClick={() => {\n onCustomClick();\n }}\n >\n Custom time range\n </MenuItem>\n ) : (\n <MenuItem\n value={formattedValue}\n onClick={() => {\n onCustomClick();\n }}\n >\n {formattedValue}\n </MenuItem>\n )}\n </Select>\n );\n}\n"],"names":["MenuItem","Select","Calendar","isRelativeTimeRange","formatAbsoluteRange","DATE_TIME_FORMAT","TimeRangeSelector","props","value","timeOptions","onSelectChange","onCustomClick","formattedValue","pastDuration","onChange","IconComponent","sx","marginTop","map","item","idx","display","onClick"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE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AAE,IAAM;oBACbX,aAAa,EAAE,CAAC;gBAClB,CAAC;0BAEAC,cAAc;cACN,AACZ;;MACM,CACT;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DateTimeRangePicker/index.ts"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
+
export * from './DateTimeRangePicker';
|
|
13
14
|
export * from './TimeRangeSelector';
|
|
14
15
|
export * from './AbsoluteTimePicker';
|
|
15
16
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/DateTimeRangePicker/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './DateTimeRangePicker';\nexport * from './TimeRangeSelector';\nexport * from './AbsoluteTimePicker';\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;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/DateTimeRangePicker/utils.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAKrD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,WAW/D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAInF"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/DateTimeRangePicker/utils.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { isBefore, isValid, format } from 'date-fns';\nimport { AbsoluteTimeRange } from '@perses-dev/core';\n\n/*\n * Date validation and check if end is after start\n */\nexport function validateDateRange(startDate: Date, endDate: Date) {\n // TODO: display error as helperText\n if (!isValid(startDate) || !isValid(endDate)) {\n console.error('Invalid Date');\n return false;\n }\n if (!isBefore(startDate, endDate)) {\n console.error('End Time is before Start Time');\n return false;\n }\n return true;\n}\n\n/**\n * Format start and end time based on provided date format\n */\nexport function formatAbsoluteRange(timeRange: AbsoluteTimeRange, dateFormat: string) {\n const formattedStart = format(timeRange.start, dateFormat);\n const formattedEnd = format(timeRange.end, dateFormat);\n return `${formattedStart} - ${formattedEnd}`;\n}\n"],"names":["isBefore","isValid","format","validateDateRange","startDate","endDate","console","error","formatAbsoluteRange","timeRange","dateFormat","formattedStart","start","formattedE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,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAID,eAAO,MAAM,MAAM,+DAA0E,WAAW,
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../src/Drawer/Drawer.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAuB,WAAW,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;AAGnF,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAID,eAAO,MAAM,MAAM,+DAA0E,WAAW,gBAqBvG,CAAC"}
|
package/dist/Drawer/Drawer.js
CHANGED
|
@@ -24,7 +24,6 @@ export const Drawer = ({ anchor ='right' , isOpen , onClose , PaperProps , child
|
|
|
24
24
|
...PaperProps,
|
|
25
25
|
sx: combineSx({
|
|
26
26
|
width: `${DRAWER_DEFAULT_WIDTH}px`,
|
|
27
|
-
padding: (theme)=>theme.spacing(2),
|
|
28
27
|
overflow: 'hidden'
|
|
29
28
|
}, PaperProps === null || PaperProps === void 0 ? void 0 : PaperProps.sx)
|
|
30
29
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Drawer/Drawer.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Drawer as MuiDrawer, DrawerProps as MuiDrawerProps } from '@mui/material';\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 = 900;\n\nexport const Drawer = ({ anchor = 'right', isOpen, onClose, PaperProps, children, ...rest }: DrawerProps) => {\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: `${DRAWER_DEFAULT_WIDTH}px`,\n
|
|
1
|
+
{"version":3,"sources":["../../src/Drawer/Drawer.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Drawer as MuiDrawer, DrawerProps as MuiDrawerProps } from '@mui/material';\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 = 900;\n\nexport const Drawer = ({ anchor = 'right', isOpen, onClose, PaperProps, children, ...rest }: DrawerProps) => {\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: `${DRAWER_DEFAULT_WIDTH}px`,\n overflow: 'hidden',\n },\n PaperProps?.sx\n ),\n }}\n >\n {children}\n </MuiDrawer>\n );\n};\n"],"names":["Drawer","MuiDrawer","combineSx","DRAWER_DEFAULT_WIDTH","anchor","isOpen","onClose","PaperProps","children","rest","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;AAAA,SAASA,MAAM,IAAIC,SAAS,QAAuC,eAAe,CAAC;AACnF,SAASC,SAAS,QAAQ,UAAU,CAAC;AAQrC,MAAMC,oBAAoB,GAAG,GAAG,AAAC;AAEjC,OAAO,MAAMH,MAAM,GAAG,CAAC,EAAEI,MAAM,EAAG,OAAO,CAAA,EAAEC,MAAM,CAAA,EAAEC,OAAO,CAAA,EAAEC,UAAU,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGC,IAAI,EAAe,GAAK;IAC3G,qBACE,KAACR,SAAS;QACP,GAAGQ,IAAI;QACRC,IAAI,EAAEL,MAAM;QACZC,OAAO,EAAEA,OAAO;QAChBF,MAAM,EAAEA,MAAM;QACdG,UAAU,EAAE;YACV,GAAGA,UAAU;YACbI,EAAE,EAAET,SAAS,CACX;gBACEU,KAAK,EAAE,CAAC,EAAET,oBAAoB,CAAC,EAAE,CAAC;gBAClCU,QAAQ,EAAE,QAAQ;aACnB,EACDN,UAAU,aAAVA,UAAU,WAAI,GAAdA,KAAAA,CAAc,GAAdA,UAAU,CAAEI,EAAE,CACf;SACF;kBAEAH,QAAQ;MACC,CACZ;AACJ,CAAC,CAAC"}
|
|
@@ -46,7 +46,7 @@ export function GaugeChart(props) {
|
|
|
46
46
|
'50%',
|
|
47
47
|
'65%'
|
|
48
48
|
],
|
|
49
|
-
radius: '
|
|
49
|
+
radius: '86%',
|
|
50
50
|
startAngle: 200,
|
|
51
51
|
endAngle: -20,
|
|
52
52
|
min: 0,
|
|
@@ -107,7 +107,7 @@ export function GaugeChart(props) {
|
|
|
107
107
|
'50%',
|
|
108
108
|
'65%'
|
|
109
109
|
],
|
|
110
|
-
radius: '
|
|
110
|
+
radius: '100%',
|
|
111
111
|
startAngle: 200,
|
|
112
112
|
endAngle: -20,
|
|
113
113
|
min: 0,
|
|
@@ -165,7 +165,7 @@ export function GaugeChart(props) {
|
|
|
165
165
|
height: height
|
|
166
166
|
},
|
|
167
167
|
option: option,
|
|
168
|
-
theme: chartsTheme.
|
|
168
|
+
theme: chartsTheme.echartsTheme
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/GaugeChart/GaugeChart.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useMemo } from 'react';\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 { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { formatValue, UnitOptions } from '../model/units';\nimport { EChart } from '../EChart';\n\nuse([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nexport type GaugeChartData = number | null | undefined;\n\ninterface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeChartData;\n unit: UnitOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps) {\n const { width, height, data, unit, axisLine, max } = props;\n\n const chartsTheme = useChartsTheme();\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data === null || data === undefined) return chartsTheme.noDataOption;\n\n const calculatedValue = data;\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: '
|
|
1
|
+
{"version":3,"sources":["../../src/GaugeChart/GaugeChart.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useMemo } from 'react';\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 { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { formatValue, UnitOptions } from '../model/units';\nimport { EChart } from '../EChart';\n\nuse([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nexport type GaugeChartData = number | null | undefined;\n\ninterface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeChartData;\n unit: UnitOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps) {\n const { width, height, data, unit, axisLine, max } = props;\n\n const chartsTheme = useChartsTheme();\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data === null || data === undefined) return chartsTheme.noDataOption;\n\n const calculatedValue = data;\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: 22,\n itemStyle: {\n color: 'auto',\n },\n },\n pointer: {\n show: false,\n },\n axisLine: {\n lineStyle: {\n color: [[1, '#e1e5e9']], // TODO (sjcobb): use future chart theme colors\n width: 22,\n },\n },\n axisTick: {\n show: false,\n distance: 0,\n },\n splitLine: {\n show: true,\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: calculatedValue,\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: false,\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',\n formatter: (value: number) => {\n return formatValue(value, {\n kind: unit.kind,\n decimal_places: 0,\n });\n },\n },\n data: [\n {\n value: calculatedValue,\n },\n ],\n },\n ],\n };\n }, [data, chartsTheme, unit, axisLine, max]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n );\n}\n"],"names":["useMemo","use","GaugeChart","EChartsGaugeChart","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","formatValue","EChart","props","width","height","data","unit","axisLine","max","chartsTheme","option","undefined","noDataOption","calculatedValue","title","show","tooltip","series","type","center","radius","startAngle","endAngle","min","silent","progress","itemStyle","color","pointer","lineStyle","axisTick","distance","splitLine","axisLabel","fontSize","anchor","detail","value","borderRadius","offsetCenter","formatter","kind","decimal_places","sx","theme","echartsTheme"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;A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IAAI,EAAE,KAAK;qBACZ;oBACDiB,SAAS,EAAE;wBACTjB,IAAI,EAAE,KAAK;qBACZ;oBACDkB,SAAS,EAAE;wBACTlB,IAAI,EAAE,KAAK;qBACZ;oBACDqB,MAAM,EAAE;wBACNrB,IAAI,EAAE,IAAI;wBACVZ,KAAK,EAAE,KAAK;wBACZmC,YAAY,EAAE,CAAC;wBACfC,YAAY,EAAE;AAAC,6BAAC;4BAAE,KAAK;yBAAC;wBACxBZ,KAAK,EAAE,SAAS;wBAChBa,SAAS,EAAE,CAACH,KAAa,GAAK;4BAC5B,OAAOrC,WAAW,CAACqC,KAAK,EAAE;gCACxBI,IAAI,EAAEnC,IAAI,CAACmC,IAAI;gCACfC,cAAc,EAAE,CAAC;6BAClB,CAAC,CAAC;wBACL,CAAC;qBACF;oBACDrC,IAAI,EAAE;wBACJ;4BACEgC,KAAK,EAAExB,eAAe;yBACvB;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC,EAAE;QAACR,IAAI;QAAEI,WAAW;QAAEH,IAAI;QAAEC,QAAQ;QAAEC,GAAG;KAAC,CAAC,AAAC;IAE7C,qBACE,KAACP,MAAM;QACL0C,EAAE,EAAE;YACFxC,KAAK,EAAEA,KAAK;YACZC,MAAM,EAAEA,MAAM;SACf;QACDM,MAAM,EAAEA,MAAM;QACdkC,KAAK,EAAEnC,WAAW,CAACoC,YAAY;MAC/B,CACF;AACJ,CAAC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { LegendItem } from '../model';
|
|
3
3
|
interface CompactLegendProps {
|
|
4
|
+
height: number;
|
|
4
5
|
items: LegendItem[];
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* CompactLegend is default and used when legend items need to show side by side
|
|
9
|
+
* which corresponds to when legend.position is `bottom`
|
|
10
|
+
*/
|
|
11
|
+
export declare function CompactLegend({ height, items }: CompactLegendProps): JSX.Element;
|
|
7
12
|
export {};
|
|
8
13
|
//# sourceMappingURL=CompactLegend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompactLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/CompactLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,UAAU,kBAAkB;IAC1B,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"CompactLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/CompactLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,kBAAkB,eAgBlE"}
|
|
@@ -11,17 +11,26 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import {
|
|
14
|
+
import { Box } from '@mui/material';
|
|
15
15
|
import { ListLegendItem } from './ListLegendItem';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
/**
|
|
17
|
+
* CompactLegend is default and used when legend items need to show side by side
|
|
18
|
+
* which corresponds to when legend.position is `bottom`
|
|
19
|
+
*/ export function CompactLegend({ height , items }) {
|
|
20
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
20
21
|
sx: {
|
|
21
|
-
|
|
22
|
+
width: '100%',
|
|
23
|
+
height,
|
|
24
|
+
paddingTop: 1,
|
|
25
|
+
overflowY: 'scroll'
|
|
22
26
|
},
|
|
23
27
|
children: items.map((item)=>/*#__PURE__*/ _jsx(ListLegendItem, {
|
|
24
|
-
item: item
|
|
28
|
+
item: item,
|
|
29
|
+
sx: {
|
|
30
|
+
width: 'auto',
|
|
31
|
+
float: 'left',
|
|
32
|
+
paddingRight: 1.5
|
|
33
|
+
}
|
|
25
34
|
}, item.id))
|
|
26
35
|
});
|
|
27
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/CompactLegend.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/CompactLegend.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { LegendItem } from '../model';\nimport { ListLegendItem } from './ListLegendItem';\n\ninterface CompactLegendProps {\n height: number;\n items: LegendItem[];\n}\n\n/**\n * CompactLegend is default and used when legend items need to show side by side\n * which corresponds to when legend.position is `bottom`\n */\nexport function CompactLegend({ height, items }: CompactLegendProps) {\n return (\n <Box sx={{ width: '100%', height, paddingTop: 1, overflowY: 'scroll' }}>\n {items.map((item) => (\n <ListLegendItem\n key={item.id}\n item={item}\n sx={{\n width: 'auto',\n float: 'left',\n paddingRight: 1.5,\n }}\n />\n ))}\n </Box>\n );\n}\n"],"names":["Box","ListLegendItem","CompactLegend","height","items","sx","width","paddingTop","overflowY","map","item","float","paddingRight","id"],"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,GAAG,QAAQ,eAAe,CAAC;AAEpC,SAASC,cAAc,QAAQ,kBAAkB,CAAC;AAOlD;;;CAGC,GACD,OAAO,SAASC,aAAa,CAAC,EAAEC,MAAM,CAAA,EAAEC,KAAK,CAAA,EAAsB,EAAE;IACnE,qBACE,KAACJ,GAAG;QAACK,EAAE,EAAE;YAAEC,KAAK,EAAE,MAAM;YAAEH,MAAM;YAAEI,UAAU,EAAE,CAAC;YAAEC,SAAS,EAAE,QAAQ;SAAE;kBACnEJ,KAAK,CAACK,GAAG,CAAC,CAACC,IAAI,iBACd,KAACT,cAAc;gBAEbS,IAAI,EAAEA,IAAI;gBACVL,EAAE,EAAE;oBACFC,KAAK,EAAE,MAAM;oBACbK,KAAK,EAAE,MAAM;oBACbC,YAAY,EAAE,GAAG;iBAClB;eANIF,IAAI,CAACG,EAAE,CAOZ,AACH,CAAC;MACE,CACN;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/Legend/Legend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAIrD,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/Legend/Legend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAIrD,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,WAAW,eAmBnE"}
|
package/dist/Legend/Legend.js
CHANGED
|
@@ -19,7 +19,7 @@ export function Legend({ width , height , options , data }) {
|
|
|
19
19
|
return /*#__PURE__*/ _jsx(Box, {
|
|
20
20
|
sx: {
|
|
21
21
|
width: width,
|
|
22
|
-
height:
|
|
22
|
+
height: '100%',
|
|
23
23
|
position: 'absolute',
|
|
24
24
|
top: 0,
|
|
25
25
|
right: 0,
|
|
@@ -30,14 +30,9 @@ export function Legend({ width , height , options , data }) {
|
|
|
30
30
|
})
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
return /*#__PURE__*/ _jsx(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
overflowY: 'scroll'
|
|
37
|
-
},
|
|
38
|
-
children: /*#__PURE__*/ _jsx(CompactLegend, {
|
|
39
|
-
items: data
|
|
40
|
-
})
|
|
33
|
+
return /*#__PURE__*/ _jsx(CompactLegend, {
|
|
34
|
+
items: data,
|
|
35
|
+
height: height
|
|
41
36
|
});
|
|
42
37
|
}
|
|
43
38
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/Legend.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { LegendOptions, LegendItem } from '../model';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\n\ninterface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendOptions;\n}\n\nexport function Legend({ width, height, options, data }: LegendProps) {\n if (options.position === 'right') {\n return (\n <Box\n sx={{\n width: width,\n height:
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/Legend.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { LegendOptions, LegendItem } from '../model';\nimport { ListLegend } from './ListLegend';\nimport { CompactLegend } from './CompactLegend';\n\ninterface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendOptions;\n}\n\nexport function Legend({ width, height, options, data }: LegendProps) {\n if (options.position === 'right') {\n return (\n <Box\n sx={{\n width: width,\n height: '100%',\n position: 'absolute',\n top: 0,\n right: 0,\n overflowY: 'scroll',\n }}\n >\n <ListLegend items={data} />\n </Box>\n );\n }\n\n return <CompactLegend items={data} height={height} />;\n}\n"],"names":["Box","ListLegend","CompactLegend","Legend","width","height","options","data","position","sx","top","right","overflowY","items"],"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,GAAG,QAAQ,eAAe,CAAC;AAEpC,SAASC,UAAU,QAAQ,cAAc,CAAC;AAC1C,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAShD,OAAO,SAASC,MAAM,CAAC,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,OAAO,CAAA,EAAEC,IAAI,CAAA,EAAe,EAAE;IACpE,IAAID,OAAO,CAACE,QAAQ,KAAK,OAAO,EAAE;QAChC,qBACE,KAACR,GAAG;YACFS,EAAE,EAAE;gBACFL,KAAK,EAAEA,KAAK;gBACZC,MAAM,EAAE,MAAM;gBACdG,QAAQ,EAAE,UAAU;gBACpBE,GAAG,EAAE,CAAC;gBACNC,KAAK,EAAE,CAAC;gBACRC,SAAS,EAAE,QAAQ;aACpB;sBAED,cAAA,KAACX,UAAU;gBAACY,KAAK,EAAEN,IAAI;cAAI;UACvB,CACN;IACJ,CAAC;IAED,qBAAO,KAACL,aAAa;QAACW,KAAK,EAAEN,IAAI;QAAEF,MAAM,EAAEA,MAAM;MAAI,CAAC;AACxD,CAAC"}
|
|
@@ -3,6 +3,9 @@ import { LegendItem } from '../model';
|
|
|
3
3
|
interface ListLegendProps {
|
|
4
4
|
items: LegendItem[];
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* ListLegend is used when legend.position is 'right' since legend items are stacked
|
|
8
|
+
*/
|
|
6
9
|
export declare function ListLegend({ items }: ListLegendProps): JSX.Element;
|
|
7
10
|
export {};
|
|
8
11
|
//# sourceMappingURL=ListLegend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,UAAU,eAAe;IACvB,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"ListLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegend.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,UAAU,eAAe;IACvB,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,eAAe,eAyBpD"}
|
|
@@ -13,10 +13,26 @@
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { List } from '@mui/material';
|
|
15
15
|
import { ListLegendItem } from './ListLegendItem';
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* ListLegend is used when legend.position is 'right' since legend items are stacked
|
|
18
|
+
*/ export function ListLegend({ items }) {
|
|
19
|
+
// show full labels on hover when there are many total series
|
|
20
|
+
const truncateLabels = items.length > 5;
|
|
17
21
|
return /*#__PURE__*/ _jsx(List, {
|
|
18
22
|
children: items.map((item)=>/*#__PURE__*/ _jsx(ListLegendItem, {
|
|
19
|
-
item: item
|
|
23
|
+
item: item,
|
|
24
|
+
sx: {
|
|
25
|
+
width: 190,
|
|
26
|
+
textOverflow: 'ellipsis',
|
|
27
|
+
wordBreak: 'break-word',
|
|
28
|
+
overflow: truncateLabels ? 'hidden' : 'visible',
|
|
29
|
+
whiteSpace: truncateLabels ? 'nowrap' : 'normal',
|
|
30
|
+
// TODO: add optional hover effect to show unformatted label
|
|
31
|
+
'&:hover': {
|
|
32
|
+
overflow: 'visible',
|
|
33
|
+
whiteSpace: 'normal'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
20
36
|
}, item.id))
|
|
21
37
|
});
|
|
22
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/ListLegend.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { List } from '@mui/material';\nimport { LegendItem } from '../model';\nimport { ListLegendItem } from './ListLegendItem';\n\ninterface ListLegendProps {\n items: LegendItem[];\n}\n\nexport function ListLegend({ items }: ListLegendProps) {\n return (\n <List>\n {items.map((item) => (\n <ListLegendItem
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/ListLegend.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { List } from '@mui/material';\nimport { LegendItem } from '../model';\nimport { ListLegendItem } from './ListLegendItem';\n\ninterface ListLegendProps {\n items: LegendItem[];\n}\n\n/**\n * ListLegend is used when legend.position is 'right' since legend items are stacked\n */\nexport function ListLegend({ items }: ListLegendProps) {\n // show full labels on hover when there are many total series\n const truncateLabels = items.length > 5;\n return (\n <List>\n {items.map((item) => (\n <ListLegendItem\n key={item.id}\n item={item}\n sx={{\n width: 190,\n textOverflow: 'ellipsis',\n wordBreak: 'break-word',\n overflow: truncateLabels ? 'hidden' : 'visible',\n whiteSpace: truncateLabels ? 'nowrap' : 'normal',\n // TODO: add optional hover effect to show unformatted label\n '&:hover': {\n overflow: 'visible',\n whiteSpace: 'normal', // this allow you to see the full label on hover\n },\n }}\n />\n ))}\n </List>\n );\n}\n"],"names":["List","ListLegendItem","ListLegend","items","truncateLabels","length","map","item","sx","width","textOverflow","wordBreak","overflow","whiteSpace","id"],"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,IAAI,QAAQ,eAAe,CAAC;AAErC,SAASC,cAAc,QAAQ,kBAAkB,CAAC;AAMlD;;CAEC,GACD,OAAO,SAASC,UAAU,CAAC,EAAEC,KAAK,CAAA,EAAmB,EAAE;IACrD,6DAA6D;IAC7D,MAAMC,cAAc,GAAGD,KAAK,CAACE,MAAM,GAAG,CAAC,AAAC;IACxC,qBACE,KAACL,IAAI;kBACFG,KAAK,CAACG,GAAG,CAAC,CAACC,IAAI,iBACd,KAACN,cAAc;gBAEbM,IAAI,EAAEA,IAAI;gBACVC,EAAE,EAAE;oBACFC,KAAK,EAAE,GAAG;oBACVC,YAAY,EAAE,UAAU;oBACxBC,SAAS,EAAE,YAAY;oBACvBC,QAAQ,EAAER,cAAc,GAAG,QAAQ,GAAG,SAAS;oBAC/CS,UAAU,EAAET,cAAc,GAAG,QAAQ,GAAG,QAAQ;oBAChD,4DAA4D;oBAC5D,SAAS,EAAE;wBACTQ,QAAQ,EAAE,SAAS;wBACnBC,UAAU,EAAE,QAAQ;qBACrB;iBACF;eAbIN,IAAI,CAACO,EAAE,CAcZ,AACH,CAAC;MACG,CACP;AACJ,CAAC"}
|