@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,17 +1,37 @@
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.
1
13
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
- const react_1 = require("@testing-library/react");
5
- const ChartsThemeProvider_1 = require("../context/ChartsThemeProvider");
6
- const StatChart_1 = require("./StatChart");
7
- describe('StatChart', () => {
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ const _jsxRuntime = require("react/jsx-runtime");
18
+ const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
19
+ const _react1 = require("@testing-library/react");
20
+ const _chartsThemeProvider = require("../context/ChartsThemeProvider");
21
+ const _statChart = require("./StatChart");
22
+ function _interopRequireDefault(obj) {
23
+ return obj && obj.__esModule ? obj : {
24
+ default: obj
25
+ };
26
+ }
27
+ describe('StatChart', ()=>{
8
28
  const contentDimensions = {
9
29
  width: 200,
10
- height: 200,
30
+ height: 200
11
31
  };
12
32
  const unit = {
13
33
  kind: 'Decimal',
14
- decimal_places: 2,
34
+ decimal_places: 2
15
35
  };
16
36
  const mockStatData = {
17
37
  calculatedValue: 7.72931659687181,
@@ -19,13 +39,28 @@ describe('StatChart', () => {
19
39
  seriesData: {
20
40
  name: '(((count(count(node_cpu_seconds_total{job="example"}) by (cpu))',
21
41
  values: [
22
- [1654006170000, 7.736401673473903],
23
- [1654006185000, 7.733891213538757],
24
- [1654006200000, 7.731101813010433],
25
- [1654006215000, 7.722454672079215],
26
- [1654006230000, 7.722733612256738],
27
- ],
28
- },
42
+ [
43
+ 1654006170000,
44
+ 7.736401673473903
45
+ ],
46
+ [
47
+ 1654006185000,
48
+ 7.733891213538757
49
+ ],
50
+ [
51
+ 1654006200000,
52
+ 7.731101813010433
53
+ ],
54
+ [
55
+ 1654006215000,
56
+ 7.722454672079215
57
+ ],
58
+ [
59
+ 1654006230000,
60
+ 7.722733612256738
61
+ ]
62
+ ]
63
+ }
29
64
  };
30
65
  const exampleChartsTheme = {
31
66
  themeName: 'perses',
@@ -33,13 +68,22 @@ describe('StatChart', () => {
33
68
  noDataOption: {},
34
69
  sparkline: {
35
70
  width: 1,
36
- color: '#000000',
37
- },
71
+ color: '#000000'
72
+ }
38
73
  };
39
- describe('Render default options (no sparkline)', () => {
40
- it('should render', () => {
41
- (0, react_1.render)((0, jsx_runtime_1.jsx)(ChartsThemeProvider_1.ChartsThemeProvider, { themeName: "perses", chartsTheme: exampleChartsTheme, children: (0, jsx_runtime_1.jsx)(StatChart_1.StatChart, { width: contentDimensions.width, height: contentDimensions.height, data: mockStatData, unit: unit }) }));
42
- expect(react_1.screen.getByText('7.73')).toBeInTheDocument();
74
+ describe('Render default options (no sparkline)', ()=>{
75
+ it('should render', ()=>{
76
+ (0, _react1.render)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_chartsThemeProvider.ChartsThemeProvider, {
77
+ themeName: "perses",
78
+ chartsTheme: exampleChartsTheme,
79
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_statChart.StatChart, {
80
+ width: contentDimensions.width,
81
+ height: contentDimensions.height,
82
+ data: mockStatData,
83
+ unit: unit
84
+ })
85
+ }));
86
+ expect(_react1.screen.getByText('7.73')).toBeInTheDocument();
43
87
  });
44
88
  });
45
89
  });
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  // Copyright 2022 The Perses Authors
3
2
  // Licensed under the Apache License, Version 2.0 (the "License");
4
3
  // you may not use this file except in compliance with the License.
@@ -11,19 +10,19 @@
11
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
11
  // See the License for the specific language governing permissions and
13
12
  // limitations under the License.
14
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- var desc = Object.getOwnPropertyDescriptor(m, k);
17
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
- desc = { enumerable: true, get: function() { return m[k]; } };
19
- }
20
- Object.defineProperty(o, k2, desc);
21
- }) : (function(o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- o[k2] = m[k];
24
- }));
25
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- __exportStar(require("./StatChart"), exports);
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./StatChart"), exports);
18
+ function _exportStar(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
26
+ });
27
+ return from;
28
+ }
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbsoluteTimePicker = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
1
  // Copyright 2022 The Perses Authors
6
2
  // Licensed under the Apache License, Version 2.0 (the "License");
7
3
  // you may not use this file except in compliance with the License.
@@ -14,88 +10,172 @@ const jsx_runtime_1 = require("react/jsx-runtime");
14
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
11
  // See the License for the specific language governing permissions and
16
12
  // limitations under the License.
17
- const react_1 = require("react");
18
- const material_1 = require("@mui/material");
19
- const x_date_pickers_1 = require("@mui/x-date-pickers");
20
- const AdapterDateFns_1 = require("@mui/x-date-pickers/AdapterDateFns");
21
- const date_fns_1 = require("date-fns");
22
- const utils_1 = require("./utils");
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "AbsoluteTimePicker", {
18
+ enumerable: true,
19
+ get: ()=>AbsoluteTimePicker
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _react = require("react");
23
+ const _material = require("@mui/material");
24
+ const _xDatePickers = require("@mui/x-date-pickers");
25
+ const _adapterDateFns = require("@mui/x-date-pickers/AdapterDateFns");
26
+ const _dateFns = require("date-fns");
27
+ const _utils = require("./utils");
23
28
  const DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
24
- const AbsoluteTimePicker = ({ initialTimeRange, onChange }) => {
25
- const [timeRange, setTimeRange] = (0, react_1.useState)(initialTimeRange);
26
- const [showStartCalendar, setShowStartCalendar] = (0, react_1.useState)(true);
29
+ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
30
+ const [timeRange, setTimeRange] = (0, _react.useState)(initialTimeRange);
31
+ const [showStartCalendar, setShowStartCalendar] = (0, _react.useState)(true);
27
32
  // validate start and end time, propagate changes
28
- const updateDateRange = (input, isStartDate) => {
33
+ const updateDateRange = (input, isStartDate)=>{
29
34
  const newDate = new Date(input);
30
35
  if (isStartDate === true) {
31
- const isValidDateRange = (0, utils_1.validateDateRange)(newDate, timeRange.end);
36
+ const isValidDateRange = (0, _utils.validateDateRange)(newDate, timeRange.end);
32
37
  if (isValidDateRange === true) {
33
- setTimeRange((current) => {
34
- const updatedRange = { start: newDate, end: current.end };
38
+ setTimeRange((current)=>{
39
+ const updatedRange = {
40
+ start: newDate,
41
+ end: current.end
42
+ };
35
43
  onChange(updatedRange);
36
44
  return updatedRange;
37
45
  });
38
46
  }
39
- }
40
- else {
41
- const isValidDateRange = (0, utils_1.validateDateRange)(timeRange.start, newDate);
42
- if (isValidDateRange === true) {
43
- setTimeRange((current) => {
44
- const updatedRange = { start: current.start, end: newDate };
47
+ } else {
48
+ const isValidDateRange1 = (0, _utils.validateDateRange)(timeRange.start, newDate);
49
+ if (isValidDateRange1 === true) {
50
+ setTimeRange((current)=>{
51
+ const updatedRange = {
52
+ start: current.start,
53
+ end: newDate
54
+ };
45
55
  onChange(updatedRange);
46
56
  return updatedRange;
47
57
  });
48
58
  }
49
59
  }
50
60
  };
51
- return ((0, jsx_runtime_1.jsx)(x_date_pickers_1.LocalizationProvider, { dateAdapter: AdapterDateFns_1.AdapterDateFns, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 3, sx: { padding: (theme) => theme.spacing(1, 2, 3) }, children: [showStartCalendar && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: (theme) => ({
52
- // TODO: create separate reusable calendar component
53
- '.MuiPickerStaticWrapper-content': {
54
- backgroundColor: theme.palette.background.default,
55
- },
56
- // reposition AM and PM buttons
57
- '.MuiIconButton-sizeMedium': {
58
- top: 80,
59
- bottom: 'auto',
60
- margin: theme.spacing(0, 3),
61
- },
62
- }), children: [(0, jsx_runtime_1.jsx)("h3", { children: "Select Start Time" }), (0, jsx_runtime_1.jsx)(x_date_pickers_1.StaticDateTimePicker, { displayStaticWrapperAs: "desktop", openTo: "day", disableHighlightToday: true, value: initialTimeRange.start, onChange: (newValue) => {
63
- if (newValue === null)
64
- return;
65
- setTimeRange((current) => {
66
- return { start: newValue, end: current.end };
61
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.LocalizationProvider, {
62
+ dateAdapter: _adapterDateFns.AdapterDateFns,
63
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
64
+ spacing: 3,
65
+ sx: {
66
+ padding: (theme)=>theme.spacing(1, 2, 3)
67
+ },
68
+ children: [
69
+ showStartCalendar && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
70
+ sx: (theme)=>({
71
+ // TODO: create separate reusable calendar component
72
+ '.MuiPickerStaticWrapper-content': {
73
+ backgroundColor: theme.palette.background.default
74
+ },
75
+ // reposition AM and PM buttons
76
+ '.MuiIconButton-sizeMedium': {
77
+ top: 80,
78
+ bottom: 'auto',
79
+ margin: theme.spacing(0, 3)
80
+ }
81
+ }),
82
+ children: [
83
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)("h3", {
84
+ children: "Select Start Time"
85
+ }),
86
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.StaticDateTimePicker, {
87
+ displayStaticWrapperAs: "desktop",
88
+ openTo: "day",
89
+ disableHighlightToday: true,
90
+ value: initialTimeRange.start,
91
+ onChange: (newValue)=>{
92
+ if (newValue === null) return;
93
+ setTimeRange((current)=>{
94
+ return {
95
+ start: newValue,
96
+ end: current.end
97
+ };
67
98
  });
68
- }, onAccept: () => {
99
+ },
100
+ onAccept: ()=>{
69
101
  setShowStartCalendar(false);
70
- }, renderInput: (params) => (0, jsx_runtime_1.jsx)(material_1.TextField, { ...params }) })] })), !showStartCalendar && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: (theme) => ({
71
- '.MuiPickerStaticWrapper-content': {
72
- backgroundColor: theme.palette.background.default,
73
- },
74
- // reposition AM and PM buttons
75
- '.MuiIconButton-sizeMedium': {
76
- top: 80,
77
- bottom: 'auto',
78
- margin: theme.spacing(0, 3),
79
- },
80
- }), children: [(0, jsx_runtime_1.jsx)("h3", { children: "Select End Time" }), (0, jsx_runtime_1.jsx)(x_date_pickers_1.StaticDateTimePicker, { displayStaticWrapperAs: "desktop", openTo: "day", disableHighlightToday: true, value: initialTimeRange.end, minDateTime: timeRange.start, onChange: (newValue) => {
81
- if (newValue === null)
82
- return;
83
- setTimeRange((current) => {
84
- return { start: current.start, end: newValue };
102
+ },
103
+ renderInput: (params)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
104
+ ...params
105
+ })
106
+ })
107
+ ]
108
+ }),
109
+ !showStartCalendar && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
110
+ sx: (theme)=>({
111
+ '.MuiPickerStaticWrapper-content': {
112
+ backgroundColor: theme.palette.background.default
113
+ },
114
+ // reposition AM and PM buttons
115
+ '.MuiIconButton-sizeMedium': {
116
+ top: 80,
117
+ bottom: 'auto',
118
+ margin: theme.spacing(0, 3)
119
+ }
120
+ }),
121
+ children: [
122
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)("h3", {
123
+ children: "Select End Time"
124
+ }),
125
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.StaticDateTimePicker, {
126
+ displayStaticWrapperAs: "desktop",
127
+ openTo: "day",
128
+ disableHighlightToday: true,
129
+ value: initialTimeRange.end,
130
+ minDateTime: timeRange.start,
131
+ onChange: (newValue)=>{
132
+ if (newValue === null) return;
133
+ setTimeRange((current)=>{
134
+ return {
135
+ start: current.start,
136
+ end: newValue
137
+ };
85
138
  });
86
- }, onAccept: () => {
139
+ },
140
+ onAccept: ()=>{
87
141
  setShowStartCalendar(true);
88
142
  onChange(timeRange);
89
- }, renderInput: (params) => (0, jsx_runtime_1.jsx)(material_1.TextField, { ...params }) })] })), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, onChange: (event) => {
143
+ },
144
+ renderInput: (params)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
145
+ ...params
146
+ })
147
+ })
148
+ ]
149
+ }),
150
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
151
+ fullWidth: true,
152
+ onChange: (event)=>{
90
153
  // TODO: add helperText, fix validation after we decide on form state solution
91
154
  updateDateRange(event.target.value, true);
92
- }, value: (0, date_fns_1.format)(timeRange.start, DATE_TIME_FORMAT), label: "Start Time", placeholder: "mm/dd/yyyy hh:mm",
155
+ },
156
+ value: (0, _dateFns.format)(timeRange.start, DATE_TIME_FORMAT),
157
+ label: "Start Time",
158
+ placeholder: "mm/dd/yyyy hh:mm",
93
159
  // tel used to match MUI DateTimePicker, may change in future: https://github.com/mui/material-ui/issues/27590
94
- type: "tel" }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: (theme) => ({
95
- margin: theme.spacing(2, 0),
96
- borderColor: theme.palette.grey['500'],
97
- }) }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, onChange: (event) => {
160
+ type: "tel"
161
+ }),
162
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Divider, {
163
+ sx: (theme)=>({
164
+ margin: theme.spacing(2, 0),
165
+ borderColor: theme.palette.grey['500']
166
+ })
167
+ }),
168
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
169
+ fullWidth: true,
170
+ onChange: (event)=>{
98
171
  updateDateRange(event.target.value, false);
99
- }, value: (0, date_fns_1.format)(timeRange.end, DATE_TIME_FORMAT), label: "End Time", placeholder: "mm/dd/yyyy hh:mm", type: "tel" })] }) }));
172
+ },
173
+ value: (0, _dateFns.format)(timeRange.end, DATE_TIME_FORMAT),
174
+ label: "End Time",
175
+ placeholder: "mm/dd/yyyy hh:mm",
176
+ type: "tel"
177
+ })
178
+ ]
179
+ })
180
+ });
100
181
  };
101
- exports.AbsoluteTimePicker = AbsoluteTimePicker;
@@ -1,10 +1,3 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TimeRangeSelector = void 0;
7
- const jsx_runtime_1 = require("react/jsx-runtime");
8
1
  // Copyright 2022 The Perses Authors
9
2
  // Licensed under the Apache License, Version 2.0 (the "License");
10
3
  // you may not use this file except in compliance with the License.
@@ -17,24 +10,54 @@ const jsx_runtime_1 = require("react/jsx-runtime");
17
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
11
  // See the License for the specific language governing permissions and
19
12
  // limitations under the License.
20
- const material_1 = require("@mui/material");
21
- const Event_1 = __importDefault(require("@mui/icons-material/Event"));
22
- const core_1 = require("@perses-dev/core");
23
- const utils_1 = require("./utils");
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "TimeRangeSelector", {
18
+ enumerable: true,
19
+ get: ()=>TimeRangeSelector
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const _event = /*#__PURE__*/ _interopRequireDefault(require("@mui/icons-material/Event"));
24
+ const _core = require("@perses-dev/core");
25
+ const _utils = require("./utils");
26
+ function _interopRequireDefault(obj) {
27
+ return obj && obj.__esModule ? obj : {
28
+ default: obj
29
+ };
30
+ }
24
31
  const DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
25
32
  function TimeRangeSelector(props) {
26
- const { value, timeOptions, onSelectChange, onCustomClick } = props;
27
- const formattedValue = !(0, core_1.isRelativeTimeRange)(value)
28
- ? (0, utils_1.formatAbsoluteRange)(value, DATE_TIME_FORMAT)
29
- : value.pastDuration;
30
- return ((0, jsx_runtime_1.jsxs)(material_1.Select, { value: formattedValue, onChange: onSelectChange, IconComponent: Event_1.default, sx: {
33
+ const { value , timeOptions , onSelectChange , onCustomClick } = props;
34
+ const formattedValue = !(0, _core.isRelativeTimeRange)(value) ? (0, _utils.formatAbsoluteRange)(value, DATE_TIME_FORMAT) : value.pastDuration;
35
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Select, {
36
+ value: formattedValue,
37
+ onChange: onSelectChange,
38
+ IconComponent: _event.default,
39
+ sx: {
31
40
  '.MuiSelect-icon': {
32
- marginTop: '1px',
33
- },
34
- }, children: [timeOptions.map((item, idx) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: item.value.pastDuration, children: item.display }, idx))), (0, core_1.isRelativeTimeRange)(value) ? ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { onClick: () => {
41
+ marginTop: '1px'
42
+ }
43
+ },
44
+ children: [
45
+ timeOptions.map((item, idx)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
46
+ value: item.value.pastDuration,
47
+ children: item.display
48
+ }, idx)),
49
+ (0, _core.isRelativeTimeRange)(value) ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
50
+ onClick: ()=>{
35
51
  onCustomClick();
36
- }, children: "Custom time range" })) : ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: formattedValue, onClick: () => {
52
+ },
53
+ children: "Custom time range"
54
+ }) : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
55
+ value: formattedValue,
56
+ onClick: ()=>{
37
57
  onCustomClick();
38
- }, children: formattedValue }))] }));
58
+ },
59
+ children: formattedValue
60
+ })
61
+ ]
62
+ });
39
63
  }
40
- exports.TimeRangeSelector = TimeRangeSelector;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  // Copyright 2022 The Perses Authors
3
2
  // Licensed under the Apache License, Version 2.0 (the "License");
4
3
  // you may not use this file except in compliance with the License.
@@ -11,20 +10,20 @@
11
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
11
  // See the License for the specific language governing permissions and
13
12
  // limitations under the License.
14
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- var desc = Object.getOwnPropertyDescriptor(m, k);
17
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
- desc = { enumerable: true, get: function() { return m[k]; } };
19
- }
20
- Object.defineProperty(o, k2, desc);
21
- }) : (function(o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- o[k2] = m[k];
24
- }));
25
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- __exportStar(require("./TimeRangeSelector"), exports);
30
- __exportStar(require("./AbsoluteTimePicker"), exports);
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./TimeRangeSelector"), exports);
18
+ _exportStar(require("./AbsoluteTimePicker"), exports);
19
+ function _exportStar(from, to) {
20
+ Object.keys(from).forEach(function(k) {
21
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ });
28
+ return from;
29
+ }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  // Copyright 2022 The Perses Authors
3
2
  // Licensed under the Apache License, Version 2.0 (the "License");
4
3
  // you may not use this file except in compliance with the License.
@@ -11,31 +10,35 @@
11
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
11
  // See the License for the specific language governing permissions and
13
12
  // limitations under the License.
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.formatAbsoluteRange = exports.validateDateRange = void 0;
16
- const date_fns_1 = require("date-fns");
17
- /*
18
- * Date validation and check if end is after start
19
- */
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ validateDateRange: ()=>validateDateRange,
25
+ formatAbsoluteRange: ()=>formatAbsoluteRange
26
+ });
27
+ const _dateFns = require("date-fns");
20
28
  function validateDateRange(startDate, endDate) {
21
29
  // TODO: display error as helperText
22
- if (!(0, date_fns_1.isValid)(startDate) || !(0, date_fns_1.isValid)(endDate)) {
30
+ if (!(0, _dateFns.isValid)(startDate) || !(0, _dateFns.isValid)(endDate)) {
23
31
  console.error('Invalid Date');
24
32
  return false;
25
33
  }
26
- if (!(0, date_fns_1.isBefore)(startDate, endDate)) {
34
+ if (!(0, _dateFns.isBefore)(startDate, endDate)) {
27
35
  console.error('End Time is before Start Time');
28
36
  return false;
29
37
  }
30
38
  return true;
31
39
  }
32
- exports.validateDateRange = validateDateRange;
33
- /**
34
- * Format start and end time based on provided date format
35
- */
36
40
  function formatAbsoluteRange(timeRange, dateFormat) {
37
- const formattedStart = (0, date_fns_1.format)(timeRange.start, dateFormat);
38
- const formattedEnd = (0, date_fns_1.format)(timeRange.end, dateFormat);
41
+ const formattedStart = (0, _dateFns.format)(timeRange.start, dateFormat);
42
+ const formattedEnd = (0, _dateFns.format)(timeRange.end, dateFormat);
39
43
  return `${formattedStart} - ${formattedEnd}`;
40
44
  }
41
- exports.formatAbsoluteRange = formatAbsoluteRange;