@perses-dev/components 0.22.0 → 0.23.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.
Files changed (59) hide show
  1. package/README.md +2 -3
  2. package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts +2 -1
  3. package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts.map +1 -1
  4. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js +87 -50
  5. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js.map +1 -1
  6. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -1
  7. package/dist/DateTimeRangePicker/DateTimeRangePicker.js +2 -1
  8. package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -1
  9. package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -1
  10. package/dist/DateTimeRangePicker/TimeRangeSelector.js +3 -0
  11. package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
  12. package/dist/Dialog/Dialog.d.ts +24 -0
  13. package/dist/Dialog/Dialog.d.ts.map +1 -0
  14. package/dist/Dialog/Dialog.js +74 -0
  15. package/dist/Dialog/Dialog.js.map +1 -0
  16. package/dist/Dialog/index.d.ts +2 -0
  17. package/dist/Dialog/index.d.ts.map +1 -0
  18. package/dist/Dialog/index.js +15 -0
  19. package/dist/Dialog/index.js.map +1 -0
  20. package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
  21. package/dist/GaugeChart/GaugeChart.js +2 -1
  22. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  23. package/dist/StatChart/StatChart.d.ts.map +1 -1
  24. package/dist/StatChart/StatChart.js +20 -11
  25. package/dist/StatChart/StatChart.js.map +1 -1
  26. package/dist/cjs/DateTimeRangePicker/AbsoluteTimePicker.js +86 -49
  27. package/dist/cjs/DateTimeRangePicker/DateTimeRangePicker.js +2 -1
  28. package/dist/cjs/DateTimeRangePicker/TimeRangeSelector.js +3 -0
  29. package/dist/cjs/Dialog/Dialog.js +85 -0
  30. package/dist/cjs/Dialog/index.js +28 -0
  31. package/dist/cjs/GaugeChart/GaugeChart.js +2 -1
  32. package/dist/cjs/StatChart/StatChart.js +20 -11
  33. package/dist/cjs/index.js +1 -0
  34. package/dist/cjs/model/units/decimal.js +4 -1
  35. package/dist/cjs/model/units/units.test.js +54 -0
  36. package/dist/cjs/test-utils/theme.js +5 -0
  37. package/dist/cjs/utils/theme-gen.js +5 -0
  38. package/dist/cjs/utils/theme-gen.test.js +5 -0
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +1 -0
  42. package/dist/index.js.map +1 -1
  43. package/dist/model/theme.d.ts +11 -0
  44. package/dist/model/theme.d.ts.map +1 -1
  45. package/dist/model/theme.js.map +1 -1
  46. package/dist/model/units/decimal.d.ts.map +1 -1
  47. package/dist/model/units/decimal.js +4 -1
  48. package/dist/model/units/decimal.js.map +1 -1
  49. package/dist/model/units/units.test.js +54 -0
  50. package/dist/model/units/units.test.js.map +1 -1
  51. package/dist/test-utils/theme.d.ts.map +1 -1
  52. package/dist/test-utils/theme.js +5 -0
  53. package/dist/test-utils/theme.js.map +1 -1
  54. package/dist/utils/theme-gen.d.ts.map +1 -1
  55. package/dist/utils/theme-gen.js +5 -0
  56. package/dist/utils/theme-gen.js.map +1 -1
  57. package/dist/utils/theme-gen.test.js +5 -0
  58. package/dist/utils/theme-gen.test.js.map +1 -1
  59. package/package.json +3 -3
package/README.md CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  This [package](https://www.npmjs.com/package/@perses-dev/components) includes individual components used in the Perses app and plugins. These components are broken up in a way that allows embedding in separate applications outside of Perses. For more info about corresponding packages see the [general UI README here](https://github.com/perses/perses/blob/main/ui/README.md) and markdown files in each component folder.
4
4
 
5
-
6
- ## Usage
5
+ ## Usage
7
6
 
8
7
  To import components from the components package use the syntax below:
9
8
 
@@ -11,7 +10,7 @@ To import components from the components package use the syntax below:
11
10
  import { LineChart } from "@perses-dev/components";
12
11
  ```
13
12
 
14
- For detailed examples of how to use certain components, see individual docs for:
13
+ For detailed examples of how to use certain components, see individual docs for:
15
14
 
16
15
  - [LineChart.md](./src/LineChart/LineChart.md)
17
16
  - [GaugeChart.md](./src/GaugeChart/GaugeChart.md)
@@ -3,7 +3,8 @@ import { AbsoluteTimeRange } from '@perses-dev/core';
3
3
  interface AbsoluteTimeFormProps {
4
4
  initialTimeRange: AbsoluteTimeRange;
5
5
  onChange: (timeRange: AbsoluteTimeRange) => void;
6
+ onCancel: () => void;
6
7
  }
7
- export declare const AbsoluteTimePicker: ({ initialTimeRange, onChange }: AbsoluteTimeFormProps) => JSX.Element;
8
+ export declare const AbsoluteTimePicker: ({ initialTimeRange, onChange, onCancel }: AbsoluteTimeFormProps) => JSX.Element;
8
9
  export {};
9
10
  //# sourceMappingURL=AbsoluteTimePicker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AbsoluteTimePicker.d.ts","sourceRoot":"","sources":["../../src/DateTimeRangePicker/AbsoluteTimePicker.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,UAAU,qBAAqB;IAC7B,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,QAAQ,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,kBAAkB,mCAAoC,qBAAqB,gBAuIvF,CAAC"}
1
+ {"version":3,"file":"AbsoluteTimePicker.d.ts","sourceRoot":"","sources":["../../src/DateTimeRangePicker/AbsoluteTimePicker.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,UAAU,qBAAqB;IAC7B,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,QAAQ,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACjD,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAMD,eAAO,MAAM,kBAAkB,6CAA8C,qBAAqB,gBAoLjG,CAAC"}
@@ -12,43 +12,66 @@
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, Typography } from '@mui/material';
15
+ import { Box, Stack, TextField, Typography, Button } 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 { useTimeZone } from '../context/TimeZoneProvider';
19
19
  import { validateDateRange } from './utils';
20
20
  const DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
21
- export const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
21
+ export const AbsoluteTimePicker = ({ initialTimeRange , onChange , onCancel })=>{
22
+ const { formatWithUserTimeZone } = useTimeZone();
23
+ // Time range values as dates that can be used as a time range.
22
24
  const [timeRange, setTimeRange] = useState(initialTimeRange);
25
+ // Time range values as strings used to populate the text inputs. May not
26
+ // be valid as dates when the user is typing.
27
+ const [timeRangeInputs, setTimeRangeInputs] = useState({
28
+ start: formatWithUserTimeZone(initialTimeRange.start, DATE_TIME_FORMAT),
29
+ end: formatWithUserTimeZone(initialTimeRange.end, DATE_TIME_FORMAT)
30
+ });
23
31
  const [showStartCalendar, setShowStartCalendar] = useState(true);
24
- const { formatWithUserTimeZone } = useTimeZone();
25
- // validate start and end time, propagate changes
26
- const updateDateRange = (input, isStartDate)=>{
27
- const newDate = new Date(input);
28
- if (isStartDate === true) {
29
- const isValidDateRange = validateDateRange(newDate, timeRange.end);
30
- if (isValidDateRange === true) {
31
- setTimeRange((current)=>{
32
- const updatedRange = {
33
- start: newDate,
34
- end: current.end
35
- };
36
- onChange(updatedRange);
37
- return updatedRange;
38
- });
39
- }
40
- } else {
41
- const isValidDateRange1 = validateDateRange(timeRange.start, newDate);
42
- if (isValidDateRange1 === true) {
43
- setTimeRange((current)=>{
44
- const updatedRange = {
45
- start: current.start,
46
- end: newDate
47
- };
48
- onChange(updatedRange);
49
- return updatedRange;
50
- });
51
- }
32
+ const changeTimeRange = (newTime, segment)=>{
33
+ const isInputChange = typeof newTime === 'string';
34
+ const newInputTime = isInputChange ? newTime : formatWithUserTimeZone(newTime, DATE_TIME_FORMAT);
35
+ setTimeRangeInputs((prevTimeRangeInputs)=>{
36
+ return {
37
+ ...prevTimeRangeInputs,
38
+ [segment]: newInputTime
39
+ };
40
+ });
41
+ // When the change is a string from an input, do not try to convert it to
42
+ // a date because there are likely to be interim stages of editing where it
43
+ // is not valid as a date. When the change is a Date from the calendar/clock
44
+ // interface, we can be sure it is a date.
45
+ if (!isInputChange) {
46
+ setTimeRange((prevTimeRange)=>{
47
+ return {
48
+ ...prevTimeRange,
49
+ [segment]: newTime
50
+ };
51
+ });
52
+ }
53
+ };
54
+ const onChangeStartTime = (newStartTime)=>{
55
+ changeTimeRange(newStartTime, 'start');
56
+ };
57
+ const onChangeEndTime = (newEndTime)=>{
58
+ changeTimeRange(newEndTime, 'end');
59
+ };
60
+ const updateDateRange = ()=>{
61
+ const newDates = {
62
+ start: new Date(timeRangeInputs.start),
63
+ end: new Date(timeRangeInputs.end)
64
+ };
65
+ const isValidDateRange = validateDateRange(newDates.start, newDates.end);
66
+ if (isValidDateRange) {
67
+ setTimeRange(newDates);
68
+ return newDates;
69
+ }
70
+ };
71
+ const onApply = ()=>{
72
+ const newDates = updateDateRange();
73
+ if (newDates) {
74
+ onChange(newDates);
52
75
  }
53
76
  };
54
77
  return /*#__PURE__*/ _jsx(LocalizationProvider, {
@@ -85,12 +108,7 @@ export const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
85
108
  value: initialTimeRange.start,
86
109
  onChange: (newValue)=>{
87
110
  if (newValue === null) return;
88
- setTimeRange((current)=>{
89
- return {
90
- start: newValue,
91
- end: current.end
92
- };
93
- });
111
+ onChangeStartTime(newValue);
94
112
  },
95
113
  onAccept: ()=>{
96
114
  setShowStartCalendar(false);
@@ -127,16 +145,12 @@ export const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
127
145
  minDateTime: timeRange.start,
128
146
  onChange: (newValue)=>{
129
147
  if (newValue === null) return;
130
- setTimeRange((current)=>{
131
- return {
132
- start: current.start,
133
- end: newValue
134
- };
135
- });
148
+ onChangeEndTime(newValue);
136
149
  },
137
- onAccept: ()=>{
150
+ onAccept: (newValue)=>{
151
+ if (newValue === null) return;
138
152
  setShowStartCalendar(true);
139
- onChange(timeRange);
153
+ onChangeEndTime(newValue);
140
154
  },
141
155
  renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
142
156
  ...params
@@ -154,24 +168,47 @@ export const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
154
168
  /*#__PURE__*/ _jsx(TextField, {
155
169
  onChange: (event)=>{
156
170
  // TODO: add helperText, fix validation after we decide on form state solution
157
- updateDateRange(event.target.value, true);
171
+ onChangeStartTime(event.target.value);
158
172
  },
159
- value: formatWithUserTimeZone(timeRange.start, DATE_TIME_FORMAT),
173
+ onBlur: ()=>updateDateRange(),
174
+ value: timeRangeInputs.start,
160
175
  label: "Start Time",
161
- placeholder: "mm/dd/yyyy hh:mm",
176
+ placeholder: DATE_TIME_FORMAT,
162
177
  // tel used to match MUI DateTimePicker, may change in future: https://github.com/mui/material-ui/issues/27590
163
178
  type: "tel"
164
179
  }),
165
180
  /*#__PURE__*/ _jsx(TextField, {
166
181
  onChange: (event)=>{
167
- updateDateRange(event.target.value, false);
182
+ onChangeEndTime(event.target.value);
168
183
  },
169
- value: formatWithUserTimeZone(timeRange.end, DATE_TIME_FORMAT),
184
+ onBlur: ()=>updateDateRange(),
185
+ value: timeRangeInputs.end,
170
186
  label: "End Time",
171
- placeholder: "mm/dd/yyyy hh:mm",
187
+ placeholder: DATE_TIME_FORMAT,
172
188
  type: "tel"
173
189
  })
174
190
  ]
191
+ }),
192
+ /*#__PURE__*/ _jsxs(Stack, {
193
+ direction: "row",
194
+ sx: {
195
+ padding: (theme)=>theme.spacing(0, 1)
196
+ },
197
+ gap: 1,
198
+ children: [
199
+ /*#__PURE__*/ _jsx(Button, {
200
+ variant: "contained",
201
+ onClick: ()=>onApply(),
202
+ fullWidth: true,
203
+ children: "Apply"
204
+ }),
205
+ /*#__PURE__*/ _jsx(Button, {
206
+ variant: "outlined",
207
+ onClick: ()=>onCancel(),
208
+ fullWidth: true,
209
+ children: "Cancel"
210
+ })
211
+ ]
175
212
  })
176
213
  ]
177
214
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/DateTimeRangePicker/AbsoluteTimePicker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { 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 { AbsoluteTimeRange } from '@perses-dev/core';\nimport { useTimeZone } from '../context/TimeZoneProvider';\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 const { formatWithUserTimeZone } = useTimeZone();\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={formatWithUserTimeZone(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={formatWithUserTimeZone(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","useTimeZone","validateDateRange","DATE_TIME_FORMAT","AbsoluteTimePicker","initialTimeRange","onChange","timeRange","setTimeRange","showStartCalendar","setShowStartCalendar","formatWithUserTimeZone","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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C,UAAU;4BAChBC,WAAW,EAAC,kBAAkB;4BAC9BC,IAAI,EAAC,KAAK;0BACV;;kBACI;;UACF;MACa,CACvB;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/DateTimeRangePicker/AbsoluteTimePicker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { Box, Stack, TextField, Typography, Button } from '@mui/material';\nimport { LocalizationProvider, StaticDateTimePicker } from '@mui/x-date-pickers';\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';\nimport { AbsoluteTimeRange } from '@perses-dev/core';\nimport { useTimeZone } from '../context/TimeZoneProvider';\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 onCancel: () => void;\n}\n\ntype AbsoluteTimeRangeInputValue = {\n [Property in keyof AbsoluteTimeRange]: string;\n};\n\nexport const AbsoluteTimePicker = ({ initialTimeRange, onChange, onCancel }: AbsoluteTimeFormProps) => {\n const { formatWithUserTimeZone } = useTimeZone();\n\n // Time range values as dates that can be used as a time range.\n const [timeRange, setTimeRange] = useState<AbsoluteTimeRange>(initialTimeRange);\n\n // Time range values as strings used to populate the text inputs. May not\n // be valid as dates when the user is typing.\n const [timeRangeInputs, setTimeRangeInputs] = useState<AbsoluteTimeRangeInputValue>({\n start: formatWithUserTimeZone(initialTimeRange.start, DATE_TIME_FORMAT),\n end: formatWithUserTimeZone(initialTimeRange.end, DATE_TIME_FORMAT),\n });\n\n const [showStartCalendar, setShowStartCalendar] = useState<boolean>(true);\n\n const changeTimeRange = (newTime: string | Date, segment: keyof AbsoluteTimeRange) => {\n const isInputChange = typeof newTime === 'string';\n const newInputTime = isInputChange ? newTime : formatWithUserTimeZone(newTime, DATE_TIME_FORMAT);\n\n setTimeRangeInputs((prevTimeRangeInputs) => {\n return {\n ...prevTimeRangeInputs,\n [segment]: newInputTime,\n };\n });\n\n // When the change is a string from an input, do not try to convert it to\n // a date because there are likely to be interim stages of editing where it\n // is not valid as a date. When the change is a Date from the calendar/clock\n // interface, we can be sure it is a date.\n if (!isInputChange) {\n setTimeRange((prevTimeRange) => {\n return {\n ...prevTimeRange,\n [segment]: newTime,\n };\n });\n }\n };\n\n const onChangeStartTime = (newStartTime: string | Date) => {\n changeTimeRange(newStartTime, 'start');\n };\n\n const onChangeEndTime = (newEndTime: string | Date) => {\n changeTimeRange(newEndTime, 'end');\n };\n\n const updateDateRange = () => {\n const newDates = {\n start: new Date(timeRangeInputs.start),\n end: new Date(timeRangeInputs.end),\n };\n const isValidDateRange = validateDateRange(newDates.start, newDates.end);\n if (isValidDateRange) {\n setTimeRange(newDates);\n return newDates;\n }\n };\n\n const onApply = () => {\n const newDates = updateDateRange();\n if (newDates) {\n onChange(newDates);\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 onChangeStartTime(newValue);\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 onChangeEndTime(newValue);\n }}\n onAccept={(newValue) => {\n if (newValue === null) return;\n setShowStartCalendar(true);\n onChangeEndTime(newValue);\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 onChangeStartTime(event.target.value);\n }}\n onBlur={() => updateDateRange()}\n value={timeRangeInputs.start}\n label=\"Start Time\"\n placeholder={DATE_TIME_FORMAT}\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 onChangeEndTime(event.target.value);\n }}\n onBlur={() => updateDateRange()}\n value={timeRangeInputs.end}\n label=\"End Time\"\n placeholder={DATE_TIME_FORMAT}\n type=\"tel\"\n />\n </Stack>\n <Stack direction=\"row\" sx={{ padding: (theme) => theme.spacing(0, 1) }} gap={1}>\n <Button variant=\"contained\" onClick={() => onApply()} fullWidth>\n Apply\n </Button>\n <Button variant=\"outlined\" onClick={() => onCancel()} fullWidth>\n Cancel\n </Button>\n </Stack>\n </Stack>\n </LocalizationProvider>\n );\n};\n"],"names":["useState","Box","Stack","TextField","Typography","Button","LocalizationProvider","StaticDateTimePicker","AdapterDateFns","useTimeZone","validateDateRange","DATE_TIME_FORMAT","AbsoluteTimePicker","initialTimeRange","onChange","onCancel","formatWithUserTimeZone","timeRange","setTimeRange","timeRangeInputs","setTimeRangeInputs","start","end","showStartCalendar","setShowStartCalendar","changeTimeRange","newTime","segment","isInputChange","newInputTime","prevTimeRangeInputs","prevTimeRange","onChangeStartTime","newStartTime","onChangeEndTime","newEndTime","updateDateRange","newDates","Date","isValidDateRange","onApply","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","onBlur","label","placeholder","type","onClick","fullWidth"],"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,EAAEC,MAAM,QAAQ,eAAe,CAAC;AAC1E,SAASC,oBAAoB,EAAEC,oBAAoB,QAAQ,qBAAqB,CAAC;AACjF,SAASC,cAAc,QAAQ,oCAAoC,CAAC;AAEpE,SAASC,WAAW,QAAQ,6BAA6B,CAAC;AAC1D,SAASC,iBAAiB,QAAQ,SAAS,CAAC;AAE5C,MAAMC,gBAAgB,GAAG,qBAAqB,AAAC;AAY/C,OAAO,MAAMC,kBAAkB,GAAG,CAAC,EAAEC,gBAAgB,CAAA,EAAEC,QAAQ,CAAA,EAAEC,QA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AAM,CAACZ,KAAK,CAAC,CAAC;4BACtC,CAAC;4BACDa,MAAM,EAAE,IAAMlC,eAAe,EAAE;4BAC/BqB,KAAK,EAAEtC,eAAe,CAACG,GAAG;4BAC1BiD,KAAK,EAAC,UAAU;4BAChBC,WAAW,EAAE7D,gBAAgB;4BAC7B8D,IAAI,EAAC,KAAK;0BACV;;kBACI;8BACR,MAACvE,KAAK;oBAAC6D,SAAS,EAAC,KAAK;oBAACpB,EAAE,EAAE;wBAAEE,OAAO,EAAE,CAACD,KAAK,GAAKA,KAAK,CAACF,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;qBAAE;oBAAEuB,GAAG,EAAE,CAAC;;sCAC5E,KAAC5D,MAAM;4BAACgD,OAAO,EAAC,WAAW;4BAACqB,OAAO,EAAE,IAAMlC,OAAO,EAAE;4BAAEmC,SAAS;sCAAC,OAEhE;0BAAS;sCACT,KAACtE,MAAM;4BAACgD,OAAO,EAAC,UAAU;4BAACqB,OAAO,EAAE,IAAM3D,QAAQ,EAAE;4BAAE4D,SAAS;sCAAC,QAEhE;0BAAS;;kBACH;;UACF;MACa,CACvB;AACJ,CAAC,CAAC"}
@@ -1 +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;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,eAuDlE"}
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;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,eAwDlE"}
@@ -46,7 +46,8 @@ export function DateTimeRangePicker(props) {
46
46
  onChange: (value)=>{
47
47
  onChange(value);
48
48
  setShowCustomDateSelector(false);
49
- }
49
+ },
50
+ onCancel: ()=>setShowCustomDateSelector(false)
50
51
  })
51
52
  }),
52
53
  /*#__PURE__*/ _jsx(FormControl, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/DateTimeRangePicker/DateTimeRangePicker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { 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 height?: string;\n}\n\nexport function DateTimeRangePicker(props: DateTimeRangePickerProps) {\n const { value, onChange, timeOptions, height } = 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} height={height}>\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 height={height}\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","height","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;AAC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W,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;wBACdC,OAAO,EAAED,KAAK,CAACR,OAAO,CAAC,CAAC,CAAC;qBAC1B,CAAA,AAAC;0BAEF,cAAA,KAACb,kBAAkB;oBACjBuB,gBAAgB,EAAEZ,kBAAkB;oBACpCN,QAAQ,EAAE,CAACD,KAAwB,GAAK;wBACtCC,QAAQ,CAACD,KAAK,CAAC,CAAC;wBAChBK,yBAAyB,CAAC,KAAK,CAAC,CAAC;oBACnC,CAAC;kBACD;cACM;0BACV,KAACd,WAAW;gBAAC6B,SAAS;0BACpB,cAAA,KAAC9B,GAAG;oBAAC+B,GAAG,EAAEf,QAAQ;8BAChB,cAAA,KAACT,iBAAiB;wBAChBK,WAAW,EAAEA,WAAW;wBACxBF,KAAK,EAAEA,KAAK;wBACZG,MAAM,EAAEA,MAAM;wBACdmB,cAAc,EAAE,CAACC,KAAK,GAAK;4BACzB,MAAMC,QAAQ,GAAGD,KAAK,CAACE,MAAM,CAACzB,KAAK,AAAC;4BACpC,MAAM0B,iBAAiB,GAAsB;gCAC3CC,YAAY,EAAEH,QAAQ;gCACtBI,GAAG,EAAE,IAAIC,IAAI,EAAE;6BAChB,AAAC;4BACF5B,QAAQ,CAACyB,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"}
1
+ {"version":3,"sources":["../../src/DateTimeRangePicker/DateTimeRangePicker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { 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 height?: string;\n}\n\nexport function DateTimeRangePicker(props: DateTimeRangePickerProps) {\n const { value, onChange, timeOptions, height } = 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} height={height}>\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 onCancel={() => setShowCustomDateSelector(false)}\n />\n </Popover>\n <FormControl fullWidth>\n <Box ref={anchorEl}>\n <TimeRangeSelector\n timeOptions={timeOptions}\n value={value}\n height={height}\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","height","showCustomDateSelector","setShowCustomDateSelector","anchorEl","convertedTimeRange","direction","spacing","current","anchorOrigin","vertical","horizontal","open","onClose","sx","theme","padding","initialTimeRange","onCancel","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;AASpE,OAAO,SAASC,mBAAmB,CAACC,KAA+B,EAAE;IACnE,MAAM,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAEC,WAAW,CAAA,EAAEC,MAAM,CAAA,EAAE,GAAGJ,KAAK,AAAC;IAEvD,MAAM,CAACK,sBAAsB,EAAEC,yBAAyB,CAAC,GAAGjB,QAAQ,CAAC,KAAK,CAAC,AAAC;IAC5E,MAAMkB,QAAQ,GAAGnB,MAAM,EAAE,AAAC;IAE1B,MAAMoB,kBAAkB,GAAGlB,OAAO,CAAC,IAAM;QACvC,OAAOK,mBAAmB,CAACM,KAAK,CAAC,GAAGL,mBAAmB,CAACK,KAAK,CAAC,GAAGA,KAAK,CAAC;IACzE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tB,yBAAyB,CAAC,KAAK,CAAC,CAAC;wBACnC,CAAC;wBACD0B,aAAa,EAAE,IAAM;4BACnB1B,yBAAyB,CAAC,IAAI,CAAC,CAAC;wBAClC,CAAC;sBACD;kBACE;cACM;;MACR,CACR;AACJ,CAAC"}
@@ -1 +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;AAM1F,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;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eA4C9D"}
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;AAM1F,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;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eA+C9D"}
@@ -25,6 +25,9 @@ export function TimeRangeSelector(props) {
25
25
  value: formattedValue,
26
26
  onChange: onSelectChange,
27
27
  IconComponent: Calendar,
28
+ inputProps: {
29
+ 'aria-label': `Select time range. Currently set to ${formattedValue}`
30
+ },
28
31
  sx: {
29
32
  '.MuiSelect-icon': {
30
33
  marginTop: '1px'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/DateTimeRangePicker/TimeRangeSelector.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MenuItem, Select, SelectChangeEvent } from '@mui/material';\nimport Calendar from 'mdi-material-ui/Calendar';\nimport { TimeRangeValue, RelativeTimeRange, isRelativeTimeRange } from '@perses-dev/core';\nimport { useTimeZone } from '../context/TimeZoneProvider';\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 height?: string;\n}\n\nexport function TimeRangeSelector(props: TimeRangeSelectorProps) {\n const { value, timeOptions, onSelectChange, onCustomClick, height } = props;\n const { timeZone } = useTimeZone();\n const formattedValue = !isRelativeTimeRange(value)\n ? formatAbsoluteRange(value, DATE_TIME_FORMAT, timeZone)\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 '.MuiSelect-select': height ? { lineHeight: height, paddingY: 0 } : {},\n }}\n >\n {timeOptions.map((item, idx) => (\n <MenuItem key={idx} value={item.value.pastDuration}>\n {item.display}\n </MenuItem>\n ))}\n\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","useTimeZone","formatAbsoluteRange","DATE_TIME_FORMAT","TimeRangeSelector","props","value","timeOptions","onSelectChange","onCustomClick","height","timeZone","formattedValue","pastDuration","onChange","IconComponent","sx","marginTop","lineHeight","paddingY","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,WAAW,QAAQ,6BAA6B,CAAC;AAC1D,SAASC,mBAAmB,QAAQ,SAAS,CAAC;AAE9C,MAAMC,gBAAgB,GAAG,qBAAqB,AAAC;AAe/C,OAAO,SAASC,iBAAiB,CAACC,KAA6B,EAAE;IAC/D,MAAM,EAAEC,KAAK,CAAA,EAAEC,WAAW,CAAA,EAAEC,cAAc,CAAA,EAAEC,aAAa,CAAA,EAAEC,MAAM,CAAA,EAAE,GAAGL,KAAK,AAAC;IAC5E,MAAM,EAAEM,QAAQ,CAAA,EAAE,GAAGV,WAAW,EAAE,AAAC;IACnC,MAAMW,cAAc,GAAG,CAACZ,mBAAmB,CAACM,KAAK,CAAC,GAC9CJ,mBAAmB,CAACI,KAAK,EAAEH,gBAAgB,EAAEQ,QAAQ,CAAC,GACtDL,KAAK,CAACO,YAAY,AAAC;IACvB,qBACE,MAACf,MAAM;QACLQ,KAAK,EAAEM,cAAc;QACrBE,QAAQ,EAAEN,cAAc;QACxBO,aAAa,EAAEhB,QAAQ;QACvBiB,EAAE,EAAE;YACF,iBAAiB,EAAE;gBACjBC,SAAS,EAAE,KAAK;aACjB;YACD,mBAAmB,EAAEP,MAAM,GAAG;gBAAEQ,UAAU,EAAER,MAAM;gBAAES,QAAQ,EAAE,CAAC;aAAE,GAAG,EAAE;SACvE;;YAEAZ,WAAW,CAACa,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,iBACzB,KAACzB,QAAQ;oBAAWS,KAAK,EAAEe,IAAI,CAACf,KAAK,CAACO,YAAY;8BAC/CQ,IAAI,CAACE,OAAO;mBADAD,GAAG,CAEP,AACZ,CAAC;YAEDtB,mBAAmB,CAACM,KAAK,CAAC,iBACzB,KAACT,QAAQ;gBACP2B,OAAO,EAAE,IAAM;oBACbf,aAAa,EAAE,CAAC;gBAClB,CAAC;0BACF,mBAED;cAAW,iBAEX,KAACZ,QAAQ;gBACPS,KAAK,EAAEM,cAAc;gBACrBY,OAAO,EAAE,IAAM;oBACbf,aAAa,EAAE,CAAC;gBAClB,CAAC;0BAEAG,cAAc;cACN,AACZ;;MACM,CACT;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/DateTimeRangePicker/TimeRangeSelector.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MenuItem, Select, SelectChangeEvent } from '@mui/material';\nimport Calendar from 'mdi-material-ui/Calendar';\nimport { TimeRangeValue, RelativeTimeRange, isRelativeTimeRange } from '@perses-dev/core';\nimport { useTimeZone } from '../context/TimeZoneProvider';\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 height?: string;\n}\n\nexport function TimeRangeSelector(props: TimeRangeSelectorProps) {\n const { value, timeOptions, onSelectChange, onCustomClick, height } = props;\n const { timeZone } = useTimeZone();\n const formattedValue = !isRelativeTimeRange(value)\n ? formatAbsoluteRange(value, DATE_TIME_FORMAT, timeZone)\n : value.pastDuration;\n return (\n <Select\n value={formattedValue}\n onChange={onSelectChange}\n IconComponent={Calendar}\n inputProps={{\n 'aria-label': `Select time range. Currently set to ${formattedValue}`,\n }}\n sx={{\n '.MuiSelect-icon': {\n marginTop: '1px',\n },\n '.MuiSelect-select': height ? { lineHeight: height, paddingY: 0 } : {},\n }}\n >\n {timeOptions.map((item, idx) => (\n <MenuItem key={idx} value={item.value.pastDuration}>\n {item.display}\n </MenuItem>\n ))}\n\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","useTimeZone","formatAbsoluteRange","DATE_TIME_FORMAT","TimeRangeSelector","props","value","timeOptions","onSelectChange","onCustomClick","height","timeZone","formattedValue","pastDuration","onChange","IconComponent","inputProps","sx","marginTop","lineHeight","paddingY","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,WAAW,QAAQ,6BAA6B,CAAC;AAC1D,SAASC,mBAAmB,QAAQ,SAAS,CAAC;AAE9C,MAAMC,gBAAgB,GAAG,qBAAqB,AAAC;AAe/C,OAAO,SAASC,iBAAiB,CAACC,KAA6B,EAAE;IAC/D,MAAM,EAAEC,KAAK,CAAA,EAAEC,WAAW,CAAA,EAAEC,cAAc,CAAA,EAAEC,aAAa,CAAA,EAAEC,MAAM,CAAA,EAAE,GAAGL,KAAK,AAAC;IAC5E,MAAM,EAAEM,QAAQ,CAAA,EAAE,GAAGV,WAAW,EAAE,AAAC;IACnC,MAAMW,cAAc,GAAG,CAACZ,mBAAmB,CAACM,KAAK,CAAC,GAC9CJ,mBAAmB,CAACI,KAAK,EAAEH,gBAAgB,EAAEQ,QAAQ,CAAC,GACtDL,KAAK,CAACO,YAAY,AAAC;IACvB,qBACE,MAACf,MAAM;QACLQ,KAAK,EAAEM,cAAc;QACrBE,QAAQ,EAAEN,cAAc;QACxBO,aAAa,EAAEhB,QAAQ;QACvBiB,UAAU,EAAE;YACV,YAAY,EAAE,CAAC,oCAAoC,EAAEJ,cAAc,CAAC,CAAC;SACtE;QACDK,EAAE,EAAE;YACF,iBAAiB,EAAE;gBACjBC,SAAS,EAAE,KAAK;aACjB;YACD,mBAAmB,EAAER,MAAM,GAAG;gBAAES,UAAU,EAAET,MAAM;gBAAEU,QAAQ,EAAE,CAAC;aAAE,GAAG,EAAE;SACvE;;YAEAb,WAAW,CAACc,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,iBACzB,KAAC1B,QAAQ;oBAAWS,KAAK,EAAEgB,IAAI,CAAChB,KAAK,CAACO,YAAY;8BAC/CS,IAAI,CAACE,OAAO;mBADAD,GAAG,CAEP,AACZ,CAAC;YAEDvB,mBAAmB,CAACM,KAAK,CAAC,iBACzB,KAACT,QAAQ;gBACP4B,OAAO,EAAE,IAAM;oBACbhB,aAAa,EAAE,CAAC;gBAClB,CAAC;0BACF,mBAED;cAAW,iBAEX,KAACZ,QAAQ;gBACPS,KAAK,EAAEM,cAAc;gBACrBa,OAAO,EAAE,IAAM;oBACbhB,aAAa,EAAE,CAAC;gBAClB,CAAC;0BAEAG,cAAc;cACN,AACZ;;MACM,CACT;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { ButtonProps, DialogActions, DialogContentProps as MuiDialogContentProps, DialogProps, DialogTitleProps } from '@mui/material';
3
+ export interface DialogHeaderProps extends DialogTitleProps {
4
+ /**
5
+ * Callback fired when close button is clicked. If undefined, close button will not appear in header.
6
+ */
7
+ onClose?: (e: React.MouseEvent<HTMLElement>) => void;
8
+ }
9
+ export declare type DialogButtonProps = Omit<ButtonProps, 'variant' | 'color' | 'type'>;
10
+ export interface DialogContentProps extends MuiDialogContentProps {
11
+ /**
12
+ * @default 500
13
+ */
14
+ width?: number;
15
+ }
16
+ export declare const Dialog: {
17
+ ({ children, ...props }: DialogProps): JSX.Element;
18
+ Header: ({ children, onClose, ...props }: DialogHeaderProps) => JSX.Element;
19
+ Content: ({ children, width, sx, ...props }: DialogContentProps) => JSX.Element;
20
+ PrimaryButton: ({ children, ...props }: DialogButtonProps) => JSX.Element;
21
+ SecondaryButton: ({ children, ...props }: DialogButtonProps) => JSX.Element;
22
+ Actions: typeof DialogActions;
23
+ };
24
+ //# sourceMappingURL=Dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../src/Dialog/Dialog.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAEL,WAAW,EAEX,aAAa,EAEb,kBAAkB,IAAI,qBAAqB,EAC3C,WAAW,EAEX,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AAIvB,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACtD;AAED,oBAAY,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC;AAEhF,MAAM,WAAW,kBAAmB,SAAQ,qBAAqB;IAC/D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAyCD,eAAO,MAAM,MAAM;6BAA4B,WAAW;8CAvCT,iBAAiB;iDAaR,kBAAkB;4CAM7B,iBAAiB;8CAMf,iBAAiB;;CAcyC,CAAC"}
@@ -0,0 +1,74 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
+ import React from 'react';
15
+ import { Button, Dialog as MuiDialog, DialogActions, DialogContent, DialogTitle, IconButton } from '@mui/material';
16
+ import CloseIcon from 'mdi-material-ui/Close';
17
+ import { combineSx } from '../utils';
18
+ const Header = ({ children , onClose , ...props })=>{
19
+ return /*#__PURE__*/ _jsxs(_Fragment, {
20
+ children: [
21
+ /*#__PURE__*/ _jsx(DialogTitle, {
22
+ ...props,
23
+ children: children
24
+ }),
25
+ onClose && /*#__PURE__*/ _jsx(IconButton, {
26
+ "aria-label": "Close",
27
+ onClick: onClose,
28
+ sx: dialogCloseIconButtonStyle,
29
+ children: /*#__PURE__*/ _jsx(CloseIcon, {})
30
+ })
31
+ ]
32
+ });
33
+ };
34
+ const Content = ({ children , width =500 , sx , ...props })=>/*#__PURE__*/ _jsx(DialogContent, {
35
+ dividers: true,
36
+ ...props,
37
+ sx: combineSx({
38
+ width: `${width}px`
39
+ }, sx),
40
+ children: children
41
+ });
42
+ const PrimaryButton = ({ children , ...props })=>/*#__PURE__*/ _jsx(Button, {
43
+ variant: "contained",
44
+ type: "submit",
45
+ ...props,
46
+ children: children
47
+ });
48
+ const SecondaryButton = ({ children , ...props })=>/*#__PURE__*/ _jsx(Button, {
49
+ variant: "outlined",
50
+ color: "secondary",
51
+ ...props,
52
+ children: children
53
+ });
54
+ /**
55
+ * Render the CSS of the dialog's close button, according to the given material theme.
56
+ * @param theme material theme
57
+ */ const dialogCloseIconButtonStyle = (theme)=>{
58
+ return {
59
+ position: 'absolute',
60
+ top: theme.spacing(0.5),
61
+ right: theme.spacing(0.5)
62
+ };
63
+ };
64
+ export const Dialog = ({ children , ...props })=>/*#__PURE__*/ _jsx(MuiDialog, {
65
+ ...props,
66
+ children: children
67
+ });
68
+ Dialog.Header = Header;
69
+ Dialog.Content = Content;
70
+ Dialog.PrimaryButton = PrimaryButton;
71
+ Dialog.SecondaryButton = SecondaryButton;
72
+ Dialog.Actions = DialogActions;
73
+
74
+ //# sourceMappingURL=Dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Dialog/Dialog.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React from 'react';\nimport {\n Button,\n ButtonProps,\n Dialog as MuiDialog,\n DialogActions,\n DialogContent,\n DialogContentProps as MuiDialogContentProps,\n DialogProps,\n DialogTitle,\n DialogTitleProps,\n IconButton,\n Theme,\n} from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { combineSx } from '../utils';\n\nexport interface DialogHeaderProps extends DialogTitleProps {\n /**\n * Callback fired when close button is clicked. If undefined, close button will not appear in header.\n */\n onClose?: (e: React.MouseEvent<HTMLElement>) => void;\n}\n\nexport type DialogButtonProps = Omit<ButtonProps, 'variant' | 'color' | 'type'>;\n\nexport interface DialogContentProps extends MuiDialogContentProps {\n /**\n * @default 500\n */\n width?: number;\n}\n\nconst Header = ({ children, onClose, ...props }: DialogHeaderProps) => {\n return (\n <>\n <DialogTitle {...props}>{children}</DialogTitle>\n {onClose && (\n <IconButton aria-label=\"Close\" onClick={onClose} sx={dialogCloseIconButtonStyle}>\n <CloseIcon />\n </IconButton>\n )}\n </>\n );\n};\n\nconst Content = ({ children, width = 500, sx, ...props }: DialogContentProps) => (\n <DialogContent dividers {...props} sx={combineSx({ width: `${width}px` }, sx)}>\n {children}\n </DialogContent>\n);\n\nconst PrimaryButton = ({ children, ...props }: DialogButtonProps) => (\n <Button variant=\"contained\" type=\"submit\" {...props}>\n {children}\n </Button>\n);\n\nconst SecondaryButton = ({ children, ...props }: DialogButtonProps) => (\n <Button variant=\"outlined\" color=\"secondary\" {...props}>\n {children}\n </Button>\n);\n\n/**\n * Render the CSS of the dialog's close button, according to the given material theme.\n * @param theme material theme\n */\nconst dialogCloseIconButtonStyle = (theme: Theme) => {\n return { position: 'absolute', top: theme.spacing(0.5), right: theme.spacing(0.5) };\n};\n\nexport const Dialog = ({ children, ...props }: DialogProps) => <MuiDialog {...props}>{children}</MuiDialog>;\n\nDialog.Header = Header;\nDialog.Content = Content;\nDialog.PrimaryButton = PrimaryButton;\nDialog.SecondaryButton = SecondaryButton;\nDialog.Actions = DialogActions;\n"],"names":["React","Button","Dialog","MuiDialog","DialogActions","DialogContent","DialogTitle","IconButton","CloseIcon","combineSx","Header","children","onClose","props","aria-label","onClick","sx","dialogCloseIconButtonStyle","Content","width","dividers","PrimaryButton","variant","type","SecondaryButton","color","theme","position","top","spacing","right","Actions"],"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,SACEC,MAAM,EAENC,MAAM,IAAIC,SAAS,EACnBC,aAAa,EACbC,aAAa,EAGbC,WAAW,EAEXC,UAAU,QAEL,eAAe,CAAC;AACvB,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,SAAS,QAAQ,UAAU,CAAC;AAkBrC,MAAMC,MAAM,GAAG,CAAC,EAAEC,QAAQ,CAAA,EAAEC,OAAO,CAAA,EAAE,GAAGC,KAAK,EAAqB,GAAK;IACrE,qBACE;;0BACE,KAACP,WAAW;gBAAE,GAAGO,KAAK;0BAAGF,QAAQ;cAAe;YAC/CC,OAAO,kBACN,KAACL,UAAU;gBAACO,YAAU,EAAC,OAAO;gBAACC,OAAO,EAAEH,OAAO;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MAAM,CAACQ,MAAM,GAAGA,MAAM,CAAC;AACvBR,MAAM,CAACgB,OAAO,GAAGA,OAAO,CAAC;AACzBhB,MAAM,CAACmB,aAAa,GAAGA,aAAa,CAAC;AACrCnB,MAAM,CAACsB,eAAe,GAAGA,eAAe,CAAC;AACzCtB,MAAM,CAAC6B,OAAO,GAAG3B,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './Dialog';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Dialog/index.tsx"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './Dialog';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Dialog/index.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './Dialog';\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"}
@@ -1 +1 @@
1
- {"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../src/GaugeChart/GaugeChart.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIpF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAU1D,oBAAY,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAExD,oBAAY,WAAW,GAAG;IACxB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eA+IhD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAQrG"}
1
+ {"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../src/GaugeChart/GaugeChart.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIpF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAU1D,oBAAY,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAExD,oBAAY,WAAW,GAAG;IACxB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eAgJhD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAQrG"}
@@ -191,7 +191,8 @@ export function GaugeChart(props) {
191
191
  return /*#__PURE__*/ _jsx(EChart, {
192
192
  sx: {
193
193
  width: width,
194
- height: height
194
+ height: height,
195
+ padding: `${chartsTheme.container.padding.default}px`
195
196
  },
196
197
  option: option,
197
198
  theme: chartsTheme.echartsTheme