@perses-dev/components 0.14.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/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/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/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/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -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
|
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,CAAoBY,gBAAgB,CAAC,AAAC;IAChF,MAAM,CAACI,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGjB,QAAQ,CAAU,IAAI,CAAC,AAAC;IAE1E,iDAAiD;IACjD,MAAMkB,eAAe,GAAG,CAACC,KAAa,EAAEC,WAAoB,GAAK;QAC/D,MAAMC,OAAO,GAAG,IAAIC,IAAI,CAACH,KAAK,CAAC,AAAC;QAChC,IAAIC,WAAW,KAAK,IAAI,EAAE;YACxB,MAAMG,gBAAgB,GAAGd,iBAAiB,CAACY,OAAO,EAAEP,SAAS,CAACU,GAAG,CAAC,AAAC;YACnE,IAAID,gBAAgB,KAAK,IAAI,EAAE;gBAC7BR,YAAY,CAAC,CAACU,OAAO,GAAK;oBACxB,MAAMC,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E,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,KAAK,AAAC;IAE/C,MAAM,CAACI,sBAAsB,EAAEC,yBAAyB,CAAC,GAAGhB,QAAQ,CAAC,KAAK,CAAC,AAAC;IAC5E,MAAMiB,QAAQ,GAAGlB,MAAM,EAAE,AAAC;IAE1B,MAAMmB,kBAAkB,GAAGjB,OAAO,CAAC,IAAM;QACvC,OAAOK,mBAAmB,CAACM,KAAK,CAAC,GAAGL,mBAAmB,CAACK,KAAK,CAAC,GAAGA,KAAK,CAAC;IACzE,CAAC,EAAE;QAACA,KAAK;KAAC,CAAC,AAAC;IAEZ,qBACE,MAACP,KAAK;QAACc,SAAS,EAAC,KAAK;QAACC,OAAO,EAAE,CAAC;;0BAC/B,KAAChB,OAAO;gBACNa,QAAQ,EAAEA,QAAQ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imeRangePicker/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,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,EAAEC,MAAM,QAA2B,eAAe,CAAC;AACpE,OAAOC,QAAQ,MAAM,0BAA0B,CAAC;AAChD,SAA4CC,mBAAmB,QAAQ,kBAAkB,CAAC;AAC1F,SAASC,mBAAmB,QAAQ,SAAS,CAAC;AAE9C,MAAMC,gBAAgB,GAAG,qBAAqB,AAAC;AAc/C,OAAO,SAASC,iBAAiB,CAACC,KAA6B,EAAE;IAC/D,MAAM,EAAEC,KAAK,CAAA,EAAEC,WAAW,CAAA,EAAEC,cAAc,CAAA,EAAEC,aAAa,CAAA,EAAE,GAAGJ,KAAK,AAAC;IACpE,MAAMK,cAAc,GAAG,CAACT,mBAAmB,CAACK,KAAK,CAAC,GAC9CJ,mBAAmB,CAACI,KAAK,EAAEH,gBAAgB,CAAC,GAC5CG,KAAK,CAACK,YAAY,AAAC;IACvB,qBACE,MAACZ,MAAM;QACLO,KAAK,EAAEI,cAAc;QACrBE,QAAQ,EAAEJ,cAAc;QACxBK,aAAa,EAAEb,QAAQ;QACvBc,EAAE,EAAE;YACF,iBAAiB,EAAE;gBACjBC,SAAS,EAAE,KAAK;aACjB;SACF;;YAEAR,WAAW,CAACS,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,iBACzB,KAACpB,QAAQ;oBAAWQ,KAAK,EAAEW,IAAI,CAACX,KAAK,CAACK,YAAY;8BAC/CM,IAAI,CAACE,OAAO;mBADAD,GAAG,CAEP,AACZ,CAAC;YAEDjB,mBAAmB,CAACK,KAAK,CAAC,iBACzB,KAACR,QAAQ;gBACPsB,OAAO,EAAE,IAAM;oBACbX,aAAa,EAAE,CAAC;gBAClB,CAAC;0BACF,mBAED;cAAW,iBAEX,KAACX,QAAQ;gBACPQ,KAAK,EAAEI,cAAc;gBACrBU,OAAO,EAAE,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","formattedEnd","end"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,QAAQ,EAAEC,OAAO,EAAEC,MAAM,QAAQ,UAAU,CAAC;AAGrD;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAACC,SAAe,EAAEC,OAAa,EAAE;IAChE,oCAAoC;IACpC,IAAI,CAACJ,OAAO,CAACG,SAAS,CAAC,IAAI,CAACH,OAAO,CAACI,OAAO,CAAC,EAAE;QAC5CC,OAAO,CAACC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAACP,QAAQ,CAACI,SAAS,EAAEC,OAAO,CAAC,EAAE;QACjCC,OAAO,CAACC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;CAEC,GACD,OAAO,SAASC,mBAAmB,CAACC,SAA4B,EAAEC,UAAkB,EAAE;IACpF,MAAMC,cAAc,GAAGT,MAAM,CAACO,SAAS,CAACG,KAAK,EAAEF,UAAU,CAAC,AAAC;IAC3D,MAAMG,YAAY,GAAGX,MAAM,CAACO,SAAS,CAACK,GAAG,EAAEJ,UAAU,CAAC,AAAC;IACvD,OAAO,CAAC,EAAEC,cAAc,CAAC,GAAG,EAAEE,YAAY,CAAC,CAAC,CAAC;AAC/C,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"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ListItemProps } from '@mui/material';
|
|
2
3
|
import { LegendItem } from '../model';
|
|
3
|
-
interface ListLegendItemProps {
|
|
4
|
+
interface ListLegendItemProps extends ListItemProps {
|
|
4
5
|
item: LegendItem;
|
|
5
6
|
}
|
|
6
7
|
export declare const ListLegendItem: React.NamedExoticComponent<ListLegendItemProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListLegendItem.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegendItem.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ListLegendItem.d.ts","sourceRoot":"","sources":["../../src/Legend/ListLegendItem.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA+B,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,UAAU,mBAAoB,SAAQ,aAAa;IACjD,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,eAAO,MAAM,cAAc,iDAuBzB,CAAC"}
|
|
@@ -10,20 +10,22 @@
|
|
|
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 { jsx as _jsx
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { createElement as _createElement } from "react";
|
|
14
15
|
import React from 'react';
|
|
15
16
|
import { Box, ListItemText, ListItem } from '@mui/material';
|
|
17
|
+
import { combineSx } from '../utils';
|
|
16
18
|
import { LegendColorBadge } from './LegendColorBadge';
|
|
17
|
-
export const ListLegendItem = /*#__PURE__*/ React.memo(function ListLegendItem({ item
|
|
18
|
-
return /*#__PURE__*/
|
|
19
|
-
|
|
20
|
-
sx: {
|
|
21
|
-
display: 'flex',
|
|
22
|
-
maxWidth: 270,
|
|
19
|
+
export const ListLegendItem = /*#__PURE__*/ React.memo(function ListLegendItem({ item , sx , ...others }) {
|
|
20
|
+
return /*#__PURE__*/ _createElement(ListItem, {
|
|
21
|
+
...others,
|
|
22
|
+
sx: combineSx({
|
|
23
23
|
padding: 0,
|
|
24
24
|
cursor: 'pointer'
|
|
25
|
-
},
|
|
25
|
+
}, sx),
|
|
26
|
+
dense: true,
|
|
26
27
|
"data-testid": `legend-item-${item.color}`,
|
|
28
|
+
key: item.id,
|
|
27
29
|
onClick: item.onClick,
|
|
28
30
|
selected: item.isSelected,
|
|
29
31
|
children: [
|
|
@@ -40,7 +42,7 @@ export const ListLegendItem = /*#__PURE__*/ React.memo(function ListLegendItem({
|
|
|
40
42
|
primary: item.label
|
|
41
43
|
})
|
|
42
44
|
]
|
|
43
|
-
}
|
|
45
|
+
});
|
|
44
46
|
});
|
|
45
47
|
|
|
46
48
|
//# sourceMappingURL=ListLegendItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/ListLegendItem.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 React from 'react';\nimport { Box, ListItemText, ListItem } from '@mui/material';\nimport { LegendItem } from '../model';\nimport { LegendColorBadge } from './LegendColorBadge';\n\ninterface ListLegendItemProps {\n item: LegendItem;\n}\n\nexport const ListLegendItem = React.memo(function ListLegendItem({ item }: ListLegendItemProps) {\n return (\n <ListItem\n
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/ListLegendItem.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 React from 'react';\nimport { Box, ListItemText, ListItem, ListItemProps } from '@mui/material';\nimport { LegendItem } from '../model';\nimport { combineSx } from '../utils';\nimport { LegendColorBadge } from './LegendColorBadge';\n\ninterface ListLegendItemProps extends ListItemProps {\n item: LegendItem;\n}\n\nexport const ListLegendItem = React.memo(function ListLegendItem({ item, sx, ...others }: ListLegendItemProps) {\n return (\n <ListItem\n {...others}\n sx={combineSx(\n {\n padding: 0,\n cursor: 'pointer',\n },\n sx\n )}\n dense={true}\n data-testid={`legend-item-${item.color}`}\n key={item.id}\n onClick={item.onClick}\n selected={item.isSelected}\n >\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n <LegendColorBadge color={item.color} />\n </Box>\n <ListItemText primary={item.label}></ListItemText>\n </ListItem>\n );\n});\n"],"names":["React","Box","ListItemText","ListItem","combineSx","LegendColorBadge","ListLegendItem","memo","item","sx","others","padding","cursor","dense","data-testid","color","key","id","onClick","selected","isSelected","display","alignItems","primary","label"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;AAAA,OAAOA,KAAK,MAAM,OAAO,CAAC;AAC1B,SAASC,GAAG,EAAEC,YAAY,EAAEC,QAAQ,QAAuB,eAAe,CAAC;AAE3E,SAASC,SAAS,QAAQ,UAAU,CAAC;AACrC,SAASC,gBAAgB,QAAQ,oBAAoB,CAAC;AAMtD,OAAO,MAAMC,cAAc,iBAAGN,KAAK,CAACO,IAAI,CAAC,SAASD,cAAc,CAAC,EAAEE,IAAI,CAAA,EAAEC,EAAE,CAAA,EAAE,GAAGC,MAAM,EAAuB,EAAE;IAC7G,qBACE,eAACP,QAAQ;QACN,GAAGO,MAAM;QACVD,EAAE,EAAEL,SAAS,CACX;YACEO,OAAO,EAAE,CAAC;YACVC,MAAM,EAAE,SAAS;SAClB,EACDH,EAAE,CACH;QACDI,KAAK,EAAE,IAAI;QACXC,aAAW,EAAE,CAAC,YAAY,EAAEN,IAAI,CAACO,KAAK,CAAC,CAAC;QACxCC,GAAG,EAAER,IAAI,CAACS,EAAE;QACZC,OAAO,EAAEV,IAAI,CAACU,OAAO;QACrBC,QAAQ,EAAEX,IAAI,CAACY,UAAU;;0BAEzB,KAACnB,GAAG;gBAACQ,EAAE,EAAE;oBAAEY,OAAO,EAAE,MAAM;oBAAEC,UAAU,EAAE,QAAQ;iBAAE;0BAChD,cAAA,KAACjB,gBAAgB;oBAACU,KAAK,EAAEP,IAAI,CAACO,KAAK;kBAAI;cACnC;0BACN,KAACb,YAAY;gBAACqB,OAAO,EAAEf,IAAI,CAACgB,KAAK;cAAiB;;MACzC,CACX;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -61,10 +61,10 @@ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
|
61
61
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.LocalizationProvider, {
|
|
62
62
|
dateAdapter: _adapterDateFns.AdapterDateFns,
|
|
63
63
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
64
|
-
spacing:
|
|
65
|
-
sx: {
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
spacing: 2,
|
|
65
|
+
sx: (theme)=>({
|
|
66
|
+
padding: theme.spacing(1, 0, 2)
|
|
67
|
+
}),
|
|
68
68
|
children: [
|
|
69
69
|
showStartCalendar && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
70
70
|
sx: (theme)=>({
|
|
@@ -80,7 +80,9 @@ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
|
80
80
|
}
|
|
81
81
|
}),
|
|
82
82
|
children: [
|
|
83
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
83
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
84
|
+
variant: "h3",
|
|
85
|
+
padding: 1,
|
|
84
86
|
children: "Select Start Time"
|
|
85
87
|
}),
|
|
86
88
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.StaticDateTimePicker, {
|
|
@@ -119,7 +121,9 @@ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
|
119
121
|
}
|
|
120
122
|
}),
|
|
121
123
|
children: [
|
|
122
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
124
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
125
|
+
variant: "h3",
|
|
126
|
+
padding: 1,
|
|
123
127
|
children: "Select End Time"
|
|
124
128
|
}),
|
|
125
129
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.StaticDateTimePicker, {
|
|
@@ -147,33 +151,34 @@ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
|
147
151
|
})
|
|
148
152
|
]
|
|
149
153
|
}),
|
|
150
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
154
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
155
|
+
direction: "row",
|
|
156
|
+
alignItems: "center",
|
|
157
|
+
gap: 1,
|
|
158
|
+
pl: 1,
|
|
159
|
+
pr: 1,
|
|
160
|
+
children: [
|
|
161
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
162
|
+
onChange: (event)=>{
|
|
163
|
+
// TODO: add helperText, fix validation after we decide on form state solution
|
|
164
|
+
updateDateRange(event.target.value, true);
|
|
165
|
+
},
|
|
166
|
+
value: (0, _dateFns.format)(timeRange.start, DATE_TIME_FORMAT),
|
|
167
|
+
label: "Start Time",
|
|
168
|
+
placeholder: "mm/dd/yyyy hh:mm",
|
|
169
|
+
// tel used to match MUI DateTimePicker, may change in future: https://github.com/mui/material-ui/issues/27590
|
|
170
|
+
type: "tel"
|
|
171
|
+
}),
|
|
172
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
173
|
+
onChange: (event)=>{
|
|
174
|
+
updateDateRange(event.target.value, false);
|
|
175
|
+
},
|
|
176
|
+
value: (0, _dateFns.format)(timeRange.end, DATE_TIME_FORMAT),
|
|
177
|
+
label: "End Time",
|
|
178
|
+
placeholder: "mm/dd/yyyy hh:mm",
|
|
179
|
+
type: "tel"
|
|
166
180
|
})
|
|
167
|
-
|
|
168
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
169
|
-
fullWidth: true,
|
|
170
|
-
onChange: (event)=>{
|
|
171
|
-
updateDateRange(event.target.value, false);
|
|
172
|
-
},
|
|
173
|
-
value: (0, _dateFns.format)(timeRange.end, DATE_TIME_FORMAT),
|
|
174
|
-
label: "End Time",
|
|
175
|
-
placeholder: "mm/dd/yyyy hh:mm",
|
|
176
|
-
type: "tel"
|
|
181
|
+
]
|
|
177
182
|
})
|
|
178
183
|
]
|
|
179
184
|
})
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "DateTimeRangePicker", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>DateTimeRangePicker
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _core = require("@perses-dev/core");
|
|
25
|
+
const _absoluteTimePicker = require("./AbsoluteTimePicker");
|
|
26
|
+
const _timeRangeSelector = require("./TimeRangeSelector");
|
|
27
|
+
function DateTimeRangePicker(props) {
|
|
28
|
+
const { value , onChange , timeOptions } = props;
|
|
29
|
+
const [showCustomDateSelector, setShowCustomDateSelector] = (0, _react.useState)(false);
|
|
30
|
+
const anchorEl = (0, _react.useRef)();
|
|
31
|
+
const convertedTimeRange = (0, _react.useMemo)(()=>{
|
|
32
|
+
return (0, _core.isRelativeTimeRange)(value) ? (0, _core.toAbsoluteTimeRange)(value) : value;
|
|
33
|
+
}, [
|
|
34
|
+
value
|
|
35
|
+
]);
|
|
36
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
37
|
+
direction: "row",
|
|
38
|
+
spacing: 1,
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Popover, {
|
|
41
|
+
anchorEl: anchorEl.current,
|
|
42
|
+
anchorOrigin: {
|
|
43
|
+
vertical: 'bottom',
|
|
44
|
+
horizontal: 'center'
|
|
45
|
+
},
|
|
46
|
+
open: showCustomDateSelector,
|
|
47
|
+
onClose: ()=>setShowCustomDateSelector(false),
|
|
48
|
+
sx: (theme)=>({
|
|
49
|
+
padding: theme.spacing(2)
|
|
50
|
+
}),
|
|
51
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_absoluteTimePicker.AbsoluteTimePicker, {
|
|
52
|
+
initialTimeRange: convertedTimeRange,
|
|
53
|
+
onChange: (value)=>{
|
|
54
|
+
onChange(value);
|
|
55
|
+
setShowCustomDateSelector(false);
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
}),
|
|
59
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControl, {
|
|
60
|
+
fullWidth: true,
|
|
61
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
62
|
+
ref: anchorEl,
|
|
63
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeSelector.TimeRangeSelector, {
|
|
64
|
+
timeOptions: timeOptions,
|
|
65
|
+
value: value,
|
|
66
|
+
onSelectChange: (event)=>{
|
|
67
|
+
const duration = event.target.value;
|
|
68
|
+
const relativeTimeInput = {
|
|
69
|
+
pastDuration: duration,
|
|
70
|
+
end: new Date()
|
|
71
|
+
};
|
|
72
|
+
onChange(relativeTimeInput);
|
|
73
|
+
setShowCustomDateSelector(false);
|
|
74
|
+
},
|
|
75
|
+
onCustomClick: ()=>{
|
|
76
|
+
setShowCustomDateSelector(true);
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
File without changes
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
+
_exportStar(require("./DateTimeRangePicker"), exports);
|
|
17
18
|
_exportStar(require("./TimeRangeSelector"), exports);
|
|
18
19
|
_exportStar(require("./AbsoluteTimePicker"), exports);
|
|
19
20
|
function _exportStar(from, to) {
|
|
File without changes
|
|
@@ -21,15 +21,21 @@ Object.defineProperty(exports, "CompactLegend", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _listLegendItem = require("./ListLegendItem");
|
|
24
|
-
function CompactLegend({ items }) {
|
|
25
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.
|
|
26
|
-
direction: "row",
|
|
27
|
-
spacing: 2,
|
|
24
|
+
function CompactLegend({ height , items }) {
|
|
25
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
28
26
|
sx: {
|
|
29
|
-
|
|
27
|
+
width: '100%',
|
|
28
|
+
height,
|
|
29
|
+
paddingTop: 1,
|
|
30
|
+
overflowY: 'scroll'
|
|
30
31
|
},
|
|
31
32
|
children: items.map((item)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegendItem.ListLegendItem, {
|
|
32
|
-
item: item
|
|
33
|
+
item: item,
|
|
34
|
+
sx: {
|
|
35
|
+
width: 'auto',
|
|
36
|
+
float: 'left',
|
|
37
|
+
paddingRight: 1.5
|
|
38
|
+
}
|
|
33
39
|
}, item.id))
|
|
34
40
|
});
|
|
35
41
|
}
|
|
@@ -27,7 +27,7 @@ function Legend({ width , height , options , data }) {
|
|
|
27
27
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
28
28
|
sx: {
|
|
29
29
|
width: width,
|
|
30
|
-
height:
|
|
30
|
+
height: '100%',
|
|
31
31
|
position: 'absolute',
|
|
32
32
|
top: 0,
|
|
33
33
|
right: 0,
|
|
@@ -38,13 +38,8 @@ function Legend({ width , height , options , data }) {
|
|
|
38
38
|
})
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
overflowY: 'scroll'
|
|
45
|
-
},
|
|
46
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_compactLegend.CompactLegend, {
|
|
47
|
-
items: data
|
|
48
|
-
})
|
|
41
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_compactLegend.CompactLegend, {
|
|
42
|
+
items: data,
|
|
43
|
+
height: height
|
|
49
44
|
});
|
|
50
45
|
}
|
|
@@ -22,9 +22,23 @@ const _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _listLegendItem = require("./ListLegendItem");
|
|
24
24
|
function ListLegend({ items }) {
|
|
25
|
+
// show full labels on hover when there are many total series
|
|
26
|
+
const truncateLabels = items.length > 5;
|
|
25
27
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.List, {
|
|
26
28
|
children: items.map((item)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegendItem.ListLegendItem, {
|
|
27
|
-
item: item
|
|
29
|
+
item: item,
|
|
30
|
+
sx: {
|
|
31
|
+
width: 190,
|
|
32
|
+
textOverflow: 'ellipsis',
|
|
33
|
+
wordBreak: 'break-word',
|
|
34
|
+
overflow: truncateLabels ? 'hidden' : 'visible',
|
|
35
|
+
whiteSpace: truncateLabels ? 'nowrap' : 'normal',
|
|
36
|
+
// TODO: add optional hover effect to show unformatted label
|
|
37
|
+
'&:hover': {
|
|
38
|
+
overflow: 'visible',
|
|
39
|
+
whiteSpace: 'normal'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
28
42
|
}, item.id))
|
|
29
43
|
});
|
|
30
44
|
}
|
|
@@ -19,24 +19,59 @@ Object.defineProperty(exports, "ListLegendItem", {
|
|
|
19
19
|
get: ()=>ListLegendItem
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _react = /*#__PURE__*/
|
|
22
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
|
+
const _utils = require("../utils");
|
|
24
25
|
const _legendColorBadge = require("./LegendColorBadge");
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
27
|
+
if (typeof WeakMap !== "function") return null;
|
|
28
|
+
var cacheBabelInterop = new WeakMap();
|
|
29
|
+
var cacheNodeInterop = new WeakMap();
|
|
30
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
31
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
32
|
+
})(nodeInterop);
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
35
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
39
|
+
return {
|
|
40
|
+
default: obj
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
44
|
+
if (cache && cache.has(obj)) {
|
|
45
|
+
return cache.get(obj);
|
|
46
|
+
}
|
|
47
|
+
var newObj = {};
|
|
48
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
49
|
+
for(var key in obj){
|
|
50
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
51
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
52
|
+
if (desc && (desc.get || desc.set)) {
|
|
53
|
+
Object.defineProperty(newObj, key, desc);
|
|
54
|
+
} else {
|
|
55
|
+
newObj[key] = obj[key];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
newObj.default = obj;
|
|
60
|
+
if (cache) {
|
|
61
|
+
cache.set(obj, newObj);
|
|
62
|
+
}
|
|
63
|
+
return newObj;
|
|
64
|
+
}
|
|
65
|
+
const ListLegendItem = /*#__PURE__*/ _react.default.memo(function ListLegendItem({ item , sx , ...others }) {
|
|
66
|
+
return /*#__PURE__*/ (0, _react.createElement)(_material.ListItem, {
|
|
67
|
+
...others,
|
|
68
|
+
sx: (0, _utils.combineSx)({
|
|
36
69
|
padding: 0,
|
|
37
70
|
cursor: 'pointer'
|
|
38
|
-
},
|
|
71
|
+
}, sx),
|
|
72
|
+
dense: true,
|
|
39
73
|
"data-testid": `legend-item-${item.color}`,
|
|
74
|
+
key: item.id,
|
|
40
75
|
onClick: item.onClick,
|
|
41
76
|
selected: item.isSelected,
|
|
42
77
|
children: [
|
|
@@ -53,5 +88,5 @@ const ListLegendItem = /*#__PURE__*/ _react.default.memo(function ListLegendItem
|
|
|
53
88
|
primary: item.label
|
|
54
89
|
})
|
|
55
90
|
]
|
|
56
|
-
}
|
|
91
|
+
});
|
|
57
92
|
});
|
package/dist/cjs/index.js
CHANGED
|
@@ -24,7 +24,7 @@ _exportStar(require("./Legend"), exports);
|
|
|
24
24
|
_exportStar(require("./LineChart"), exports);
|
|
25
25
|
_exportStar(require("./GaugeChart"), exports);
|
|
26
26
|
_exportStar(require("./StatChart"), exports);
|
|
27
|
-
_exportStar(require("./
|
|
27
|
+
_exportStar(require("./DateTimeRangePicker"), exports);
|
|
28
28
|
_exportStar(require("./context/ChartsThemeProvider"), exports);
|
|
29
29
|
_exportStar(require("./utils"), exports);
|
|
30
30
|
_exportStar(require("./model"), exports);
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export * from './Legend';
|
|
|
8
8
|
export * from './LineChart';
|
|
9
9
|
export * from './GaugeChart';
|
|
10
10
|
export * from './StatChart';
|
|
11
|
-
export * from './
|
|
11
|
+
export * from './DateTimeRangePicker';
|
|
12
12
|
export * from './context/ChartsThemeProvider';
|
|
13
13
|
export * from './utils';
|
|
14
14
|
export * from './model';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ export * from './Legend';
|
|
|
20
20
|
export * from './LineChart';
|
|
21
21
|
export * from './GaugeChart';
|
|
22
22
|
export * from './StatChart';
|
|
23
|
-
export * from './
|
|
23
|
+
export * from './DateTimeRangePicker';
|
|
24
24
|
export * from './context/ChartsThemeProvider';
|
|
25
25
|
export * from './utils';
|
|
26
26
|
export * from './model';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/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 './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LineChart';\nexport * from './GaugeChart';\nexport * from './StatChart';\nexport * from './
|
|
1
|
+
{"version":3,"sources":["../src/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 './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LineChart';\nexport * from './GaugeChart';\nexport * from './StatChart';\nexport * from './DateTimeRangePicker';\nexport * from './context/ChartsThemeProvider';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\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,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@mui/x-date-pickers": "^5.0.0-beta.1",
|
|
36
|
-
"@perses-dev/core": "^0.
|
|
36
|
+
"@perses-dev/core": "^0.15.0",
|
|
37
37
|
"date-fns": "^2.28.0",
|
|
38
38
|
"echarts": "^5.3.3",
|
|
39
39
|
"lodash-es": "^4.17.21",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AbsoluteTimePicker.d.ts","sourceRoot":"","sources":["../../src/TimeRangeSelector/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,gBAmIvF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeRangeSelector/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, Divider } 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 spacing={3} sx={{ padding: (theme) => theme.spacing(1, 2, 3) }}>\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 <h3>Select Start Time</h3>\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 <h3>Select End Time</h3>\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 <TextField\n fullWidth\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 <Divider\n sx={(theme) => ({\n margin: theme.spacing(2, 0),\n borderColor: theme.palette.grey['500'],\n })}\n />\n <TextField\n fullWidth\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 </LocalizationProvider>\n );\n};\n"],"names":["useState","Box","Stack","TextField","Divider","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","padding","theme","backgroundColor","palette","background","default","top","bottom","margin","h3","displayStaticWrapperAs","openTo","disableHighlightToday","value","newValue","onAccept","renderInput","params","minDateTime","fullWidth","event","target","label","placeholder","type","borderColor","grey"],"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,OAAO,QAAQ,eAAe,CAAC;AAC/D,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,CAAoBY,gBAAgB,CAAC,AAAC;IAChF,MAAM,CAACI,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGjB,QAAQ,CAAU,IAAI,CAAC,AAAC;IAE1E,iDAAiD;IACjD,MAAMkB,eAAe,GAAG,CAACC,KAAa,EAAEC,WAAoB,GAAK;QAC/D,MAAMC,OAAO,GAAG,IAAIC,IAAI,CAACH,KAAK,CAAC,AAAC;QAChC,IAAIC,WAAW,KAAK,IAAI,EAA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K,CAAC;yBACvC,CAAA,AAAC;kBACF;8BACF,KAACtD,SAAS;oBACR+C,SAAS;oBACTrC,QAAQ,EAAE,CAACsC,KAA0C,GAAK;wBACxDjC,eAAe,CAACiC,KAAK,CAACC,MAAM,CAACR,KAAK,EAAE,KAAK,CAAC,CAAC;oBAC7C,CAAC;oBACDA,KAAK,EAAEpC,MAAM,CAACM,SAAS,CAACU,GAAG,EAAEd,gBAAgB,CAAC;oBAC9C2C,KAAK,EAAC,UAAU;oBAChBC,WAAW,EAAC,kBAAkB;oBAC9BC,IAAI,EAAC,KAAK;kBACV;;UACI;MACa,CACvB;AACJ,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TimeRangeSelector.d.ts","sourceRoot":"","sources":["../../src/TimeRangeSelector/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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeRangeSelector/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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BACrBU,OAAO,EAAE,IAAM;oBACbX,aAAa,EAAE,CAAC;gBAClB,CAAC;0BAEAC,cAAc;cACN,AACZ;;MACM,CACT;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TimeRangeSelector/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeRangeSelector/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 './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,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/TimeRangeSelector/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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeRangeSelector/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","formattedEnd","end"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,QAAQ,EAAEC,OAAO,EAAEC,MAAM,QAAQ,UAAU,CAAC;AAGrD;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAACC,SAAe,EAAEC,OAAa,EAAE;IAChE,oCAAoC;IACpC,IAAI,CAACJ,OAAO,CAACG,SAAS,CAAC,IAAI,CAACH,OAAO,CAACI,OAAO,CAAC,EAAE;QAC5CC,OAAO,CAACC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAACP,QAAQ,CAACI,SAAS,EAAEC,OAAO,CAAC,EAAE;QACjCC,OAAO,CAACC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;CAEC,GACD,OAAO,SAASC,mBAAmB,CAACC,SAA4B,EAAEC,UAAkB,EAAE;IACpF,MAAMC,cAAc,GAAGT,MAAM,CAACO,SAAS,CAACG,KAAK,EAAEF,UAAU,CAAC,AAAC;IAC3D,MAAMG,YAAY,GAAGX,MAAM,CAACO,SAAS,CAACK,GAAG,EAAEJ,UAAU,CAAC,AAAC;IACvD,OAAO,CAAC,EAAEC,cAAc,CAAC,GAAG,EAAEE,YAAY,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|