@perses-dev/components 0.8.0 → 0.9.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 (131) hide show
  1. package/dist/Drawer/Drawer.d.ts +3 -4
  2. package/dist/Drawer/Drawer.d.ts.map +1 -1
  3. package/dist/Drawer/Drawer.js +35 -1
  4. package/dist/Drawer/Drawer.js.map +1 -0
  5. package/dist/Drawer/index.js +15 -1
  6. package/dist/Drawer/index.js.map +1 -0
  7. package/dist/EChart.d.ts.map +1 -1
  8. package/dist/EChart.js +142 -1
  9. package/dist/EChart.js.map +1 -0
  10. package/dist/ErrorAlert.js +25 -1
  11. package/dist/ErrorAlert.js.map +1 -0
  12. package/dist/ErrorBoundary.js +16 -1
  13. package/dist/ErrorBoundary.js.map +1 -0
  14. package/dist/GaugeChart/GaugeChart.js +172 -1
  15. package/dist/GaugeChart/GaugeChart.js.map +1 -0
  16. package/dist/GaugeChart/index.js +15 -1
  17. package/dist/GaugeChart/index.js.map +1 -0
  18. package/dist/InfoTooltip/InfoTooltip.js +79 -1
  19. package/dist/InfoTooltip/InfoTooltip.js.map +1 -0
  20. package/dist/InfoTooltip/InfoTooltip.test.js +36 -1
  21. package/dist/InfoTooltip/InfoTooltip.test.js.map +1 -0
  22. package/dist/InfoTooltip/index.js +15 -1
  23. package/dist/InfoTooltip/index.js.map +1 -0
  24. package/dist/LineChart/LineChart.js +198 -1
  25. package/dist/LineChart/LineChart.js.map +1 -0
  26. package/dist/LineChart/index.js +15 -1
  27. package/dist/LineChart/index.js.map +1 -0
  28. package/dist/LineChart/utils.js +63 -1
  29. package/dist/LineChart/utils.js.map +1 -0
  30. package/dist/StatChart/StatChart.js +121 -1
  31. package/dist/StatChart/StatChart.js.map +1 -0
  32. package/dist/StatChart/StatChart.test.js +82 -1
  33. package/dist/StatChart/StatChart.test.js.map +1 -0
  34. package/dist/StatChart/index.js +15 -1
  35. package/dist/StatChart/index.js.map +1 -0
  36. package/dist/TimeRangeSelector/AbsoluteTimePicker.js +175 -1
  37. package/dist/TimeRangeSelector/AbsoluteTimePicker.js.map +1 -0
  38. package/dist/TimeRangeSelector/TimeRangeSelector.js +52 -1
  39. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -0
  40. package/dist/TimeRangeSelector/index.js +16 -1
  41. package/dist/TimeRangeSelector/index.js.map +1 -0
  42. package/dist/TimeRangeSelector/utils.js +36 -1
  43. package/dist/TimeRangeSelector/utils.js.map +1 -0
  44. package/dist/Tooltip/SeriesInfo.js +143 -1
  45. package/dist/Tooltip/SeriesInfo.js.map +1 -0
  46. package/dist/Tooltip/SeriesMarker.js +33 -1
  47. package/dist/Tooltip/SeriesMarker.js.map +1 -0
  48. package/dist/Tooltip/Tooltip.js +72 -1
  49. package/dist/Tooltip/Tooltip.js.map +1 -0
  50. package/dist/Tooltip/TooltipContent.js +89 -1
  51. package/dist/Tooltip/TooltipContent.js.map +1 -0
  52. package/dist/Tooltip/focused-series.js +108 -1
  53. package/dist/Tooltip/focused-series.js.map +1 -0
  54. package/dist/Tooltip/focused-series.test.js +75 -1
  55. package/dist/Tooltip/focused-series.test.js.map +1 -0
  56. package/dist/Tooltip/index.js +16 -1
  57. package/dist/Tooltip/index.js.map +1 -0
  58. package/dist/Tooltip/tooltip-model.js +80 -1
  59. package/dist/Tooltip/tooltip-model.js.map +1 -0
  60. package/dist/Tooltip/utils.js +46 -1
  61. package/dist/Tooltip/utils.js.map +1 -0
  62. package/dist/cjs/Drawer/Drawer.js +26 -13
  63. package/dist/cjs/Drawer/index.js +16 -17
  64. package/dist/cjs/EChart.js +114 -89
  65. package/dist/cjs/ErrorAlert.js +16 -12
  66. package/dist/cjs/ErrorBoundary.js +10 -6
  67. package/dist/cjs/GaugeChart/GaugeChart.js +90 -57
  68. package/dist/cjs/GaugeChart/index.js +16 -17
  69. package/dist/cjs/InfoTooltip/InfoTooltip.js +90 -33
  70. package/dist/cjs/InfoTooltip/InfoTooltip.test.js +27 -17
  71. package/dist/cjs/InfoTooltip/index.js +16 -17
  72. package/dist/cjs/LineChart/LineChart.js +122 -87
  73. package/dist/cjs/LineChart/index.js +16 -17
  74. package/dist/cjs/LineChart/utils.js +23 -23
  75. package/dist/cjs/StatChart/StatChart.js +107 -46
  76. package/dist/cjs/StatChart/StatChart.test.js +65 -21
  77. package/dist/cjs/StatChart/index.js +16 -17
  78. package/dist/cjs/TimeRangeSelector/AbsoluteTimePicker.js +144 -64
  79. package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +45 -22
  80. package/dist/cjs/TimeRangeSelector/index.js +17 -18
  81. package/dist/cjs/TimeRangeSelector/utils.js +19 -16
  82. package/dist/cjs/Tooltip/SeriesInfo.js +120 -48
  83. package/dist/cjs/Tooltip/SeriesMarker.js +20 -11
  84. package/dist/cjs/Tooltip/Tooltip.js +95 -67
  85. package/dist/cjs/Tooltip/TooltipContent.js +76 -31
  86. package/dist/cjs/Tooltip/focused-series.js +40 -36
  87. package/dist/cjs/Tooltip/focused-series.test.js +36 -16
  88. package/dist/cjs/Tooltip/index.js +17 -18
  89. package/dist/cjs/Tooltip/tooltip-model.js +46 -30
  90. package/dist/cjs/Tooltip/utils.js +13 -16
  91. package/dist/cjs/context/ChartsThemeProvider.js +65 -13
  92. package/dist/cjs/index.js +27 -28
  93. package/dist/cjs/model/graph.js +10 -5
  94. package/dist/cjs/model/index.js +18 -19
  95. package/dist/cjs/model/theme.js +4 -2
  96. package/dist/cjs/model/units.js +68 -51
  97. package/dist/cjs/test/index.js +16 -17
  98. package/dist/cjs/test/render.js +22 -12
  99. package/dist/cjs/test/setup-tests.js +4 -2
  100. package/dist/cjs/utils/combine-sx.js +15 -16
  101. package/dist/cjs/utils/index.js +17 -18
  102. package/dist/cjs/utils/theme-gen.js +64 -55
  103. package/dist/cjs/utils/theme-gen.test.js +14 -12
  104. package/dist/context/ChartsThemeProvider.js +36 -1
  105. package/dist/context/ChartsThemeProvider.js.map +1 -0
  106. package/dist/index.js +26 -1
  107. package/dist/index.js.map +1 -0
  108. package/dist/model/graph.js +15 -1
  109. package/dist/model/graph.js.map +1 -0
  110. package/dist/model/index.js +17 -1
  111. package/dist/model/index.js.map +1 -0
  112. package/dist/model/theme.js +15 -1
  113. package/dist/model/theme.js.map +1 -0
  114. package/dist/model/units.d.ts.map +1 -1
  115. package/dist/model/units.js +196 -1
  116. package/dist/model/units.js.map +1 -0
  117. package/dist/test/index.js +15 -1
  118. package/dist/test/index.js.map +1 -0
  119. package/dist/test/render.js +32 -1
  120. package/dist/test/render.js.map +1 -0
  121. package/dist/test/setup-tests.js +18 -1
  122. package/dist/test/setup-tests.js.map +1 -0
  123. package/dist/utils/combine-sx.js +27 -1
  124. package/dist/utils/combine-sx.js.map +1 -0
  125. package/dist/utils/index.js +16 -1
  126. package/dist/utils/index.js.map +1 -0
  127. package/dist/utils/theme-gen.js +183 -1
  128. package/dist/utils/theme-gen.js.map +1 -0
  129. package/dist/utils/theme-gen.test.js +196 -1
  130. package/dist/utils/theme-gen.test.js.map +1 -0
  131. package/package.json +8 -4
@@ -1 +1,82 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{render,screen}from"@testing-library/react";import{ChartsThemeProvider}from"../context/ChartsThemeProvider";import{StatChart}from"./StatChart";describe("StatChart",(()=>{const e={kind:"Decimal",decimal_places:2},t={calculatedValue:7.72931659687181,name:"Example Stat Chart",seriesData:{name:'(((count(count(node_cpu_seconds_total{job="example"}) by (cpu))',values:[[165400617e4,7.736401673473903],[1654006185e3,7.733891213538757],[16540062e5,7.731101813010433],[1654006215e3,7.722454672079215],[165400623e4,7.722733612256738]]}},r={themeName:"perses",echartsTheme:{},noDataOption:{},sparkline:{width:1,color:"#000000"}};describe("Render default options (no sparkline)",(()=>{it("should render",(()=>{render(_jsx(ChartsThemeProvider,{themeName:"perses",chartsTheme:r,children:_jsx(StatChart,{width:200,height:200,data:t,unit:e})})),expect(screen.getByText("7.73")).toBeInTheDocument()}))}))}));
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 } from "react/jsx-runtime";
14
+ import React from 'react';
15
+ import { render, screen } from '@testing-library/react';
16
+ import { ChartsThemeProvider } from '../context/ChartsThemeProvider';
17
+ import { StatChart } from './StatChart';
18
+ describe('StatChart', ()=>{
19
+ const contentDimensions = {
20
+ width: 200,
21
+ height: 200
22
+ };
23
+ const unit = {
24
+ kind: 'Decimal',
25
+ decimal_places: 2
26
+ };
27
+ const mockStatData = {
28
+ calculatedValue: 7.72931659687181,
29
+ name: 'Example Stat Chart',
30
+ seriesData: {
31
+ name: '(((count(count(node_cpu_seconds_total{job="example"}) by (cpu))',
32
+ values: [
33
+ [
34
+ 1654006170000,
35
+ 7.736401673473903
36
+ ],
37
+ [
38
+ 1654006185000,
39
+ 7.733891213538757
40
+ ],
41
+ [
42
+ 1654006200000,
43
+ 7.731101813010433
44
+ ],
45
+ [
46
+ 1654006215000,
47
+ 7.722454672079215
48
+ ],
49
+ [
50
+ 1654006230000,
51
+ 7.722733612256738
52
+ ]
53
+ ]
54
+ }
55
+ };
56
+ const exampleChartsTheme = {
57
+ themeName: 'perses',
58
+ echartsTheme: {},
59
+ noDataOption: {},
60
+ sparkline: {
61
+ width: 1,
62
+ color: '#000000'
63
+ }
64
+ };
65
+ describe('Render default options (no sparkline)', ()=>{
66
+ it('should render', ()=>{
67
+ render(/*#__PURE__*/ _jsx(ChartsThemeProvider, {
68
+ themeName: "perses",
69
+ chartsTheme: exampleChartsTheme,
70
+ children: /*#__PURE__*/ _jsx(StatChart, {
71
+ width: contentDimensions.width,
72
+ height: contentDimensions.height,
73
+ data: mockStatData,
74
+ unit: unit
75
+ })
76
+ }));
77
+ expect(screen.getByText('7.73')).toBeInTheDocument();
78
+ });
79
+ });
80
+ });
81
+
82
+ //# sourceMappingURL=StatChart.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/StatChart/StatChart.test.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 { render, screen } from '@testing-library/react';\nimport { ChartsThemeProvider } from '../context/ChartsThemeProvider';\nimport { UnitOptions } from '../model';\nimport { StatChart, StatChartData } from './StatChart';\n\ndescribe('StatChart', () => {\n const contentDimensions = {\n width: 200,\n height: 200,\n };\n\n const unit: UnitOptions = {\n kind: 'Decimal',\n decimal_places: 2,\n };\n\n const mockStatData: StatChartData = {\n calculatedValue: 7.72931659687181,\n name: 'Example Stat Chart',\n seriesData: {\n name: '(((count(count(node_cpu_seconds_total{job=\"example\"}) by (cpu))',\n values: [\n [1654006170000, 7.736401673473903],\n [1654006185000, 7.733891213538757],\n [1654006200000, 7.731101813010433],\n [1654006215000, 7.722454672079215],\n [1654006230000, 7.722733612256738],\n ],\n },\n };\n\n const exampleChartsTheme = {\n themeName: 'perses',\n echartsTheme: {},\n noDataOption: {},\n sparkline: {\n width: 1,\n color: '#000000',\n },\n };\n\n describe('Render default options (no sparkline)', () => {\n it('should render', () => {\n render(\n <ChartsThemeProvider themeName=\"perses\" chartsTheme={exampleChartsTheme}>\n <StatChart\n width={contentDimensions.width}\n height={contentDimensions.height}\n data={mockStatData}\n unit={unit}\n />\n </ChartsThemeProvider>\n );\n expect(screen.getByText('7.73')).toBeInTheDocument();\n });\n });\n});\n"],"names":["React","render","screen","ChartsThemeProvider","StatChart","describe","contentDimensions","width","height","unit","kind","decimal_places","mockStatData","calculatedValue","name","seriesData","values","exampleChartsTheme","themeName","echartsTheme","noDataOption","sparkline","color","it","chartsTheme","data","expect","getByText","toBeInTheDocument"],"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,MAAM,EAAEC,MAAM,QAAQ,wBAAwB,CAAC;AACxD,SAASC,mBAAmB,QAAQ,gCAAgC,CAAC;AAErE,SAASC,SAAS,QAAuB,aAAa,CAAC;AAEvDC,QAAQ,CAAC,WAAW,EAAE,IAAM;IAC1B,MAAMC,iBAAiB,GAAG;QACxBC,KAAK,EAAE,GAAG;QACVC,MAAM,EAAE,GAAG;KACZ,AAAC;IAEF,MAAMC,IAAI,GAAgB;QACxBC,IAAI,EAAE,SAAS;QACfC,cAAc,EAAE,CAAC;KAClB,AAAC;IAEF,MAAMC,YAAY,GAAkB;QAClCC,eAAe,EAAE,gBAAgB;QACjCC,IAAI,EAAE,oBAAoB;QAC1BC,UAAU,EAAE;YACVD,IAAI,EAAE,iEAAiE;YACvEE,MAAM,EAAE;gBACN;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;gBAClC;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;gBAClC;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;gBAClC;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;gBAClC;AAAC,iCAAa;AAAE,qCAAiB;iBAAC;aACnC;SACF;KACF,AAAC;IAEF,MAAMC,kBAAkB,GAAG;QACzBC,SAAS,EAAE,QAAQ;QACnBC,YAAY,EAAE,EAAE;QAChBC,YAAY,EAAE,EAAE;QAChBC,SAAS,EAAE;YACTd,KAAK,EAAE,CAAC;YACRe,KAAK,EAAE,SAAS;SACjB;KACF,AAAC;IAEFjB,QAAQ,CAAC,uCAAuC,EAAE,IAAM;QACtDkB,EAAE,CAAC,eAAe,EAAE,IAAM;YACxBtB,MAAM,eACJ,KAACE,mBAAmB;gBAACe,SAAS,EAAC,QAAQ;gBAACM,WAAW,EAAEP,kBAAkB;0BACrE,cAAA,KAACb,SAAS;oBACRG,KAAK,EAAED,iBAAiB,CAACC,KAAK;oBAC9BC,MAAM,EAAEF,iBAAiB,CAACE,MAAM;oBAChCiB,IAAI,EAAEb,YAAY;oBAClBH,IAAI,EAAEA,IAAI;kBACV;cACkB,CACvB,CAAC;YACFiB,MAAM,CAACxB,MAAM,CAACyB,SAAS,CAAC,MAAM,CAAC,CAAC,CAACC,iBAAiB,EAAE,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +1,15 @@
1
- export*from"./StatChart";
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
+ export * from './StatChart';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/StatChart/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 './StatChart';\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,aAAa,CAAC"}
@@ -1 +1,175 @@
1
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useState}from"react";import{Box,Stack,TextField,Divider}from"@mui/material";import{LocalizationProvider,StaticDateTimePicker}from"@mui/x-date-pickers";import{AdapterDateFns}from"@mui/x-date-pickers/AdapterDateFns";import{format}from"date-fns";import{validateDateRange}from"./utils";const DATE_TIME_FORMAT="yyyy-MM-dd HH:mm:ss";export const AbsoluteTimePicker=({initialTimeRange:e,onChange:t})=>{const[a,i]=useState(e),[r,n]=useState(!0),o=(e,r)=>{const n=new Date(e);!0===r?!0===validateDateRange(n,a.end)&&i((e=>{const a={start:n,end:e.end};return t(a),a})):!0===validateDateRange(a.start,n)&&i((e=>{const a={start:e.start,end:n};return t(a),a}))};return _jsx(LocalizationProvider,{dateAdapter:AdapterDateFns,children:_jsxs(Stack,{spacing:3,sx:{padding:e=>e.spacing(1,2,3)},children:[r&&_jsxs(Box,{sx:e=>({".MuiPickerStaticWrapper-content":{backgroundColor:e.palette.background.default},".MuiIconButton-sizeMedium":{top:80,bottom:"auto",margin:e.spacing(0,3)}}),children:[_jsx("h3",{children:"Select Start Time"}),_jsx(StaticDateTimePicker,{displayStaticWrapperAs:"desktop",openTo:"day",disableHighlightToday:!0,value:e.start,onChange:e=>{null!==e&&i((t=>({start:e,end:t.end})))},onAccept:()=>{n(!1)},renderInput:e=>_jsx(TextField,{...e})})]}),!r&&_jsxs(Box,{sx:e=>({".MuiPickerStaticWrapper-content":{backgroundColor:e.palette.background.default},".MuiIconButton-sizeMedium":{top:80,bottom:"auto",margin:e.spacing(0,3)}}),children:[_jsx("h3",{children:"Select End Time"}),_jsx(StaticDateTimePicker,{displayStaticWrapperAs:"desktop",openTo:"day",disableHighlightToday:!0,value:e.end,minDateTime:a.start,onChange:e=>{null!==e&&i((t=>({start:t.start,end:e})))},onAccept:()=>{n(!0),t(a)},renderInput:e=>_jsx(TextField,{...e})})]}),_jsx(TextField,{fullWidth:!0,onChange:e=>{o(e.target.value,!0)},value:format(a.start,DATE_TIME_FORMAT),label:"Start Time",placeholder:"mm/dd/yyyy hh:mm",type:"tel"}),_jsx(Divider,{sx:e=>({margin:e.spacing(2,0),borderColor:e.palette.grey[500]})}),_jsx(TextField,{fullWidth:!0,onChange:e=>{o(e.target.value,!1)},value:format(a.end,DATE_TIME_FORMAT),label:"End Time",placeholder:"mm/dd/yyyy hh:mm",type:"tel"})]})})};
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 { useState } from 'react';
15
+ import { Box, Stack, TextField, Divider } from '@mui/material';
16
+ import { LocalizationProvider, StaticDateTimePicker } from '@mui/x-date-pickers';
17
+ import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
18
+ import { format } from 'date-fns';
19
+ import { validateDateRange } from './utils';
20
+ const DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
21
+ export const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
22
+ const [timeRange, setTimeRange] = useState(initialTimeRange);
23
+ const [showStartCalendar, setShowStartCalendar] = useState(true);
24
+ // validate start and end time, propagate changes
25
+ const updateDateRange = (input, isStartDate)=>{
26
+ const newDate = new Date(input);
27
+ if (isStartDate === true) {
28
+ const isValidDateRange = validateDateRange(newDate, timeRange.end);
29
+ if (isValidDateRange === true) {
30
+ setTimeRange((current)=>{
31
+ const updatedRange = {
32
+ start: newDate,
33
+ end: current.end
34
+ };
35
+ onChange(updatedRange);
36
+ return updatedRange;
37
+ });
38
+ }
39
+ } else {
40
+ const isValidDateRange1 = validateDateRange(timeRange.start, newDate);
41
+ if (isValidDateRange1 === true) {
42
+ setTimeRange((current)=>{
43
+ const updatedRange = {
44
+ start: current.start,
45
+ end: newDate
46
+ };
47
+ onChange(updatedRange);
48
+ return updatedRange;
49
+ });
50
+ }
51
+ }
52
+ };
53
+ return /*#__PURE__*/ _jsx(LocalizationProvider, {
54
+ dateAdapter: AdapterDateFns,
55
+ children: /*#__PURE__*/ _jsxs(Stack, {
56
+ spacing: 3,
57
+ sx: {
58
+ padding: (theme)=>theme.spacing(1, 2, 3)
59
+ },
60
+ children: [
61
+ showStartCalendar && /*#__PURE__*/ _jsxs(Box, {
62
+ sx: (theme)=>({
63
+ // TODO: create separate reusable calendar component
64
+ '.MuiPickerStaticWrapper-content': {
65
+ backgroundColor: theme.palette.background.default
66
+ },
67
+ // reposition AM and PM buttons
68
+ '.MuiIconButton-sizeMedium': {
69
+ top: 80,
70
+ bottom: 'auto',
71
+ margin: theme.spacing(0, 3)
72
+ }
73
+ }),
74
+ children: [
75
+ /*#__PURE__*/ _jsx("h3", {
76
+ children: "Select Start Time"
77
+ }),
78
+ /*#__PURE__*/ _jsx(StaticDateTimePicker, {
79
+ displayStaticWrapperAs: "desktop",
80
+ openTo: "day",
81
+ disableHighlightToday: true,
82
+ value: initialTimeRange.start,
83
+ onChange: (newValue)=>{
84
+ if (newValue === null) return;
85
+ setTimeRange((current)=>{
86
+ return {
87
+ start: newValue,
88
+ end: current.end
89
+ };
90
+ });
91
+ },
92
+ onAccept: ()=>{
93
+ setShowStartCalendar(false);
94
+ },
95
+ renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
96
+ ...params
97
+ })
98
+ })
99
+ ]
100
+ }),
101
+ !showStartCalendar && /*#__PURE__*/ _jsxs(Box, {
102
+ sx: (theme)=>({
103
+ '.MuiPickerStaticWrapper-content': {
104
+ backgroundColor: theme.palette.background.default
105
+ },
106
+ // reposition AM and PM buttons
107
+ '.MuiIconButton-sizeMedium': {
108
+ top: 80,
109
+ bottom: 'auto',
110
+ margin: theme.spacing(0, 3)
111
+ }
112
+ }),
113
+ children: [
114
+ /*#__PURE__*/ _jsx("h3", {
115
+ children: "Select End Time"
116
+ }),
117
+ /*#__PURE__*/ _jsx(StaticDateTimePicker, {
118
+ displayStaticWrapperAs: "desktop",
119
+ openTo: "day",
120
+ disableHighlightToday: true,
121
+ value: initialTimeRange.end,
122
+ minDateTime: timeRange.start,
123
+ onChange: (newValue)=>{
124
+ if (newValue === null) return;
125
+ setTimeRange((current)=>{
126
+ return {
127
+ start: current.start,
128
+ end: newValue
129
+ };
130
+ });
131
+ },
132
+ onAccept: ()=>{
133
+ setShowStartCalendar(true);
134
+ onChange(timeRange);
135
+ },
136
+ renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
137
+ ...params
138
+ })
139
+ })
140
+ ]
141
+ }),
142
+ /*#__PURE__*/ _jsx(TextField, {
143
+ fullWidth: true,
144
+ onChange: (event)=>{
145
+ // TODO: add helperText, fix validation after we decide on form state solution
146
+ updateDateRange(event.target.value, true);
147
+ },
148
+ value: format(timeRange.start, DATE_TIME_FORMAT),
149
+ label: "Start Time",
150
+ placeholder: "mm/dd/yyyy hh:mm",
151
+ // tel used to match MUI DateTimePicker, may change in future: https://github.com/mui/material-ui/issues/27590
152
+ type: "tel"
153
+ }),
154
+ /*#__PURE__*/ _jsx(Divider, {
155
+ sx: (theme)=>({
156
+ margin: theme.spacing(2, 0),
157
+ borderColor: theme.palette.grey['500']
158
+ })
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"
169
+ })
170
+ ]
171
+ })
172
+ });
173
+ };
174
+
175
+ //# sourceMappingURL=AbsoluteTimePicker.js.map
@@ -0,0 +1 @@
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,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-runtime";import{MenuItem,Select}from"@mui/material";import EventIcon from"@mui/icons-material/Event";import{isRelativeTimeRange}from"@perses-dev/core";import{formatAbsoluteRange}from"./utils";const DATE_TIME_FORMAT="yyyy-MM-dd HH:mm:ss";export function TimeRangeSelector(e){const{value:t,timeOptions:n,onSelectChange:i,onCustomClick:o}=e,m=isRelativeTimeRange(t)?t.pastDuration:formatAbsoluteRange(t,DATE_TIME_FORMAT);return _jsxs(Select,{value:m,onChange:i,IconComponent:EventIcon,sx:{".MuiSelect-icon":{marginTop:"1px"}},children:[n.map(((e,t)=>_jsx(MenuItem,{value:e.value.pastDuration,children:e.display},t))),isRelativeTimeRange(t)?_jsx(MenuItem,{onClick:()=>{o()},children:"Custom time range"}):_jsx(MenuItem,{value:m,onClick:()=>{o()},children:m})]})}
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 { MenuItem, Select } from '@mui/material';
15
+ import EventIcon from '@mui/icons-material/Event';
16
+ import { isRelativeTimeRange } from '@perses-dev/core';
17
+ import { formatAbsoluteRange } from './utils';
18
+ const DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
19
+ export function TimeRangeSelector(props) {
20
+ const { value , timeOptions , onSelectChange , onCustomClick } = props;
21
+ const formattedValue = !isRelativeTimeRange(value) ? formatAbsoluteRange(value, DATE_TIME_FORMAT) : value.pastDuration;
22
+ return /*#__PURE__*/ _jsxs(Select, {
23
+ value: formattedValue,
24
+ onChange: onSelectChange,
25
+ IconComponent: EventIcon,
26
+ sx: {
27
+ '.MuiSelect-icon': {
28
+ marginTop: '1px'
29
+ }
30
+ },
31
+ children: [
32
+ timeOptions.map((item, idx)=>/*#__PURE__*/ _jsx(MenuItem, {
33
+ value: item.value.pastDuration,
34
+ children: item.display
35
+ }, idx)),
36
+ isRelativeTimeRange(value) ? /*#__PURE__*/ _jsx(MenuItem, {
37
+ onClick: ()=>{
38
+ onCustomClick();
39
+ },
40
+ children: "Custom time range"
41
+ }) : /*#__PURE__*/ _jsx(MenuItem, {
42
+ value: formattedValue,
43
+ onClick: ()=>{
44
+ onCustomClick();
45
+ },
46
+ children: formattedValue
47
+ })
48
+ ]
49
+ });
50
+ }
51
+
52
+ //# sourceMappingURL=TimeRangeSelector.js.map
@@ -0,0 +1 @@
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 EventIcon from '@mui/icons-material/Event';\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={EventIcon}\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","EventIcon","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,SAAS,MAAM,2BAA2B,CAAC;AAClD,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,SAAS;QACxBc,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"}
@@ -1 +1,16 @@
1
- export*from"./TimeRangeSelector";export*from"./AbsoluteTimePicker";
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
+ export * from './TimeRangeSelector';
14
+ export * from './AbsoluteTimePicker';
15
+
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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 +1,36 @@
1
- import{isBefore,isValid,format}from"date-fns";export function validateDateRange(e,r){return isValid(e)&&isValid(r)?!!isBefore(e,r)||(console.error("End Time is before Start Time"),!1):(console.error("Invalid Date"),!1)}export function formatAbsoluteRange(e,r){return`${format(e.start,r)} - ${format(e.end,r)}`}
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 { isBefore, isValid, format } from 'date-fns';
14
+ /*
15
+ * Date validation and check if end is after start
16
+ */ export function validateDateRange(startDate, endDate) {
17
+ // TODO: display error as helperText
18
+ if (!isValid(startDate) || !isValid(endDate)) {
19
+ console.error('Invalid Date');
20
+ return false;
21
+ }
22
+ if (!isBefore(startDate, endDate)) {
23
+ console.error('End Time is before Start Time');
24
+ return false;
25
+ }
26
+ return true;
27
+ }
28
+ /**
29
+ * Format start and end time based on provided date format
30
+ */ export function formatAbsoluteRange(timeRange, dateFormat) {
31
+ const formattedStart = format(timeRange.start, dateFormat);
32
+ const formattedEnd = format(timeRange.end, dateFormat);
33
+ return `${formattedStart} - ${formattedEnd}`;
34
+ }
35
+
36
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
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"}
@@ -1 +1,143 @@
1
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Box,Divider,Stack,Typography}from"@mui/material";import{SeriesMarker}from"./SeriesMarker";import{TOOLTIP_LABELS_MAX_WIDTH}from"./tooltip-model";export function SeriesInfo(e){const{seriesName:o,y:r,markerColor:t,totalSeries:i,wrapLabels:s}=e,l=o.replace(/[{}"]/g,"");if(1===i){const e="{"===o[0];return _jsxs(Stack,{spacing:.5,children:[_jsxs(Box,{sx:e=>({height:"16px",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"left",color:e.palette.common.white,fontSize:"11px"}),children:[_jsx(SeriesMarker,{markerColor:t}),_jsxs(Box,{component:"span",children:["value:",_jsx(Box,{component:"span",sx:e=>({color:e.palette.common.white,fontWeight:700,paddingLeft:"2px"}),children:r})]})]}),_jsx(Divider,{sx:e=>({borderColor:e.palette.grey[500]})}),_jsx(Box,{sx:e=>({color:e.palette.common.white}),children:l.split(",").map((o=>{if(o){const[r,t]=e?o.split(":"):o.split("=");return _jsxs(Box,{sx:{display:"flex",gap:"4px"},children:[_jsx(Typography,{sx:{fontSize:"11px"},children:void 0!==t?`${r}: `:r}),_jsx(Typography,{sx:e=>({color:e.palette.common.white,fontWeight:700,fontSize:"11px"}),children:t})]},o)}}))})]})}const n=l.replace(/[,]/g,", ").replace(/[:=]/g,": ");return _jsxs(Box,{sx:{display:"table-row",paddingTop:.5},children:[_jsxs(Box,{sx:{display:"table-cell",maxWidth:"520px"},children:[_jsx(SeriesMarker,{markerColor:t}),_jsx(Box,{component:"span",sx:e=>({color:e.palette.common.white,display:"inline-block",maxWidth:TOOLTIP_LABELS_MAX_WIDTH,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:s?"normal":"nowrap",width:"calc(100% - 20px)"}),children:n})]}),_jsx(Box,{sx:{display:"table-cell",fontWeight:"700",paddingLeft:1.5,textAlign:"right",verticalAlign:"top"},children:r})]})}
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 { Box, Divider, Stack, Typography } from '@mui/material';
15
+ import { SeriesMarker } from './SeriesMarker';
16
+ import { TOOLTIP_LABELS_MAX_WIDTH } from './tooltip-model';
17
+ export function SeriesInfo(props) {
18
+ const { seriesName , y , markerColor , totalSeries , wrapLabels } = props;
19
+ // TODO (sjcobb): regex to remove __name__, improve series labels
20
+ const formattedSeriesLabels = seriesName.replace(/[{}"]/g, '');
21
+ if (totalSeries === 1) {
22
+ const jsonFormattedSeries = seriesName[0] === '{' ? true : false;
23
+ return /*#__PURE__*/ _jsxs(Stack, {
24
+ spacing: 0.5,
25
+ children: [
26
+ /*#__PURE__*/ _jsxs(Box, {
27
+ sx: (theme)=>({
28
+ height: '16px',
29
+ display: 'flex',
30
+ flexDirection: 'row',
31
+ alignItems: 'center',
32
+ justifyContent: 'left',
33
+ color: theme.palette.common.white,
34
+ fontSize: '11px'
35
+ }),
36
+ children: [
37
+ /*#__PURE__*/ _jsx(SeriesMarker, {
38
+ markerColor: markerColor
39
+ }),
40
+ /*#__PURE__*/ _jsxs(Box, {
41
+ component: "span",
42
+ children: [
43
+ "value:",
44
+ /*#__PURE__*/ _jsx(Box, {
45
+ component: "span",
46
+ sx: (theme)=>({
47
+ color: theme.palette.common.white,
48
+ fontWeight: 700,
49
+ paddingLeft: '2px'
50
+ }),
51
+ children: y
52
+ })
53
+ ]
54
+ })
55
+ ]
56
+ }),
57
+ /*#__PURE__*/ _jsx(Divider, {
58
+ sx: (theme)=>({
59
+ borderColor: theme.palette.grey['500']
60
+ })
61
+ }),
62
+ /*#__PURE__*/ _jsx(Box, {
63
+ sx: (theme)=>({
64
+ color: theme.palette.common.white
65
+ }),
66
+ children: formattedSeriesLabels.split(',').map((name)=>{
67
+ if (name) {
68
+ const [key, value] = jsonFormattedSeries ? name.split(':') : name.split('=');
69
+ const formattedKey = value !== undefined ? `${key}: ` : key;
70
+ return /*#__PURE__*/ _jsxs(Box, {
71
+ sx: {
72
+ display: 'flex',
73
+ gap: '4px'
74
+ },
75
+ children: [
76
+ /*#__PURE__*/ _jsx(Typography, {
77
+ sx: {
78
+ fontSize: '11px'
79
+ },
80
+ children: formattedKey
81
+ }),
82
+ /*#__PURE__*/ _jsx(Typography, {
83
+ sx: (theme)=>({
84
+ color: theme.palette.common.white,
85
+ fontWeight: 700,
86
+ fontSize: '11px'
87
+ }),
88
+ children: value
89
+ })
90
+ ]
91
+ }, name);
92
+ }
93
+ })
94
+ })
95
+ ]
96
+ });
97
+ }
98
+ const inlineSeriesLabels = formattedSeriesLabels.replace(/[,]/g, ', ').replace(/[:=]/g, ': ');
99
+ return /*#__PURE__*/ _jsxs(Box, {
100
+ sx: {
101
+ display: 'table-row',
102
+ paddingTop: 0.5
103
+ },
104
+ children: [
105
+ /*#__PURE__*/ _jsxs(Box, {
106
+ sx: {
107
+ display: 'table-cell',
108
+ maxWidth: '520px'
109
+ },
110
+ children: [
111
+ /*#__PURE__*/ _jsx(SeriesMarker, {
112
+ markerColor: markerColor
113
+ }),
114
+ /*#__PURE__*/ _jsx(Box, {
115
+ component: "span",
116
+ sx: (theme)=>({
117
+ color: theme.palette.common.white,
118
+ display: 'inline-block',
119
+ maxWidth: TOOLTIP_LABELS_MAX_WIDTH,
120
+ overflow: 'hidden',
121
+ textOverflow: 'ellipsis',
122
+ whiteSpace: wrapLabels ? 'normal' : 'nowrap',
123
+ width: 'calc(100% - 20px)'
124
+ }),
125
+ children: inlineSeriesLabels
126
+ })
127
+ ]
128
+ }),
129
+ /*#__PURE__*/ _jsx(Box, {
130
+ sx: {
131
+ display: 'table-cell',
132
+ fontWeight: '700',
133
+ paddingLeft: 1.5,
134
+ textAlign: 'right',
135
+ verticalAlign: 'top'
136
+ },
137
+ children: y
138
+ })
139
+ ]
140
+ });
141
+ }
142
+
143
+ //# sourceMappingURL=SeriesInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Tooltip/SeriesInfo.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, Divider, Stack, Typography } from '@mui/material';\nimport { SeriesMarker } from './SeriesMarker';\nimport { TOOLTIP_LABELS_MAX_WIDTH } from './tooltip-model';\n\ninterface SeriesInfoProps {\n seriesName: string;\n y: number;\n markerColor: string;\n totalSeries: number;\n wrapLabels?: boolean;\n}\n\nexport function SeriesInfo(props: SeriesInfoProps) {\n const { seriesName, y, markerColor, totalSeries, wrapLabels } = props;\n\n // TODO (sjcobb): regex to remove __name__, improve series labels\n const formattedSeriesLabels = seriesName.replace(/[{}\"]/g, '');\n\n if (totalSeries === 1) {\n const jsonFormattedSeries = seriesName[0] === '{' ? true : false;\n return (\n <Stack spacing={0.5}>\n <Box\n sx={(theme) => ({\n height: '16px',\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'left',\n color: theme.palette.common.white,\n fontSize: '11px',\n })}\n >\n <SeriesMarker markerColor={markerColor} />\n <Box component=\"span\">\n value:\n <Box\n component=\"span\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n fontWeight: 700,\n paddingLeft: '2px',\n })}\n >\n {y}\n </Box>\n </Box>\n </Box>\n <Divider\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n })}\n />\n <Box\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {formattedSeriesLabels.split(',').map((name) => {\n if (name) {\n const [key, value] = jsonFormattedSeries ? name.split(':') : name.split('=');\n const formattedKey = value !== undefined ? `${key}: ` : key;\n return (\n <Box key={name} sx={{ display: 'flex', gap: '4px' }}>\n <Typography sx={{ fontSize: '11px' }}>{formattedKey}</Typography>\n <Typography\n sx={(theme) => ({\n color: theme.palette.common.white,\n fontWeight: 700,\n fontSize: '11px',\n })}\n >\n {value}\n </Typography>\n </Box>\n );\n }\n })}\n </Box>\n </Stack>\n );\n }\n\n const inlineSeriesLabels = formattedSeriesLabels.replace(/[,]/g, ', ').replace(/[:=]/g, ': ');\n return (\n <Box\n sx={{\n display: 'table-row',\n paddingTop: 0.5,\n }}\n >\n <Box\n sx={{\n display: 'table-cell',\n maxWidth: '520px',\n }}\n >\n <SeriesMarker markerColor={markerColor} />\n <Box\n component=\"span\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n display: 'inline-block',\n maxWidth: TOOLTIP_LABELS_MAX_WIDTH,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: wrapLabels ? 'normal' : 'nowrap',\n width: 'calc(100% - 20px)',\n })}\n >\n {inlineSeriesLabels}\n </Box>\n </Box>\n <Box\n sx={{\n display: 'table-cell',\n fontWeight: '700',\n paddingLeft: 1.5,\n textAlign: 'right',\n verticalAlign: 'top',\n }}\n >\n {y}\n </Box>\n </Box>\n );\n}\n"],"names":["Box","Divider","Stack","Typography","SeriesMarker","TOOLTIP_LABELS_MAX_WIDTH","SeriesInfo","props","seriesName","y","markerColor","totalSeries","wrapLabels","formattedSeriesLabels","replace","jsonFormattedSeries","spacing","sx","theme","height","display","flexDirection","alignItems","justifyContent","color","palette","common","white","fontSize","component","fontWeight","paddingLeft","borderColor","grey","split","map","name","key","value","formattedKey","undefined","gap","inlineSeriesLabels","paddingTop","maxWidth","overflow","textOverflow","whiteSpace","width","textAlign","verticalAlign"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC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