@perses-dev/components 0.46.0-rc1 → 0.47.0-rc0

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 (136) hide show
  1. package/dist/AlignSelector/AlignSelector.d.ts +8 -0
  2. package/dist/AlignSelector/AlignSelector.d.ts.map +1 -0
  3. package/dist/AlignSelector/AlignSelector.js +45 -0
  4. package/dist/AlignSelector/AlignSelector.js.map +1 -0
  5. package/dist/AlignSelector/index.d.ts +2 -0
  6. package/dist/AlignSelector/index.d.ts.map +1 -0
  7. package/dist/AlignSelector/index.js +15 -0
  8. package/dist/AlignSelector/index.js.map +1 -0
  9. package/dist/ColorPicker/OptionsColorPicker.d.ts +7 -0
  10. package/dist/ColorPicker/OptionsColorPicker.d.ts.map +1 -0
  11. package/dist/{ThresholdsEditor/ThresholdColorPicker.js → ColorPicker/OptionsColorPicker.js} +5 -5
  12. package/dist/ColorPicker/OptionsColorPicker.js.map +1 -0
  13. package/dist/ColorPicker/index.d.ts +1 -0
  14. package/dist/ColorPicker/index.d.ts.map +1 -1
  15. package/dist/ColorPicker/index.js +1 -0
  16. package/dist/ColorPicker/index.js.map +1 -1
  17. package/dist/DensitySelector/DensitySelector.d.ts +7 -0
  18. package/dist/DensitySelector/DensitySelector.d.ts.map +1 -0
  19. package/dist/DensitySelector/DensitySelector.js +46 -0
  20. package/dist/DensitySelector/DensitySelector.js.map +1 -0
  21. package/dist/DensitySelector/index.d.ts +2 -0
  22. package/dist/DensitySelector/index.d.ts.map +1 -0
  23. package/dist/DensitySelector/index.js +15 -0
  24. package/dist/DensitySelector/index.js.map +1 -0
  25. package/dist/Dialog/Dialog.d.ts +2 -7
  26. package/dist/Dialog/Dialog.d.ts.map +1 -1
  27. package/dist/Dialog/Dialog.js +7 -2
  28. package/dist/Dialog/Dialog.js.map +1 -1
  29. package/dist/LinksEditor/LinksEditor.d.ts +6 -1
  30. package/dist/LinksEditor/LinksEditor.d.ts.map +1 -1
  31. package/dist/LinksEditor/LinksEditor.js +15 -8
  32. package/dist/LinksEditor/LinksEditor.js.map +1 -1
  33. package/dist/Overlay/Overlay.d.ts +15 -0
  34. package/dist/Overlay/Overlay.d.ts.map +1 -0
  35. package/dist/Overlay/Overlay.js +52 -0
  36. package/dist/Overlay/Overlay.js.map +1 -0
  37. package/dist/Overlay/index.d.ts +2 -0
  38. package/dist/Overlay/index.d.ts.map +1 -0
  39. package/dist/Overlay/index.js +15 -0
  40. package/dist/Overlay/index.js.map +1 -0
  41. package/dist/SortSelector/SortSelectorButtons.d.ts +8 -0
  42. package/dist/SortSelector/SortSelectorButtons.d.ts.map +1 -0
  43. package/dist/SortSelector/SortSelectorButtons.js +45 -0
  44. package/dist/SortSelector/SortSelectorButtons.js.map +1 -0
  45. package/dist/SortSelector/index.d.ts +1 -0
  46. package/dist/SortSelector/index.d.ts.map +1 -1
  47. package/dist/SortSelector/index.js +2 -1
  48. package/dist/SortSelector/index.js.map +1 -1
  49. package/dist/Table/InnerTable.d.ts.map +1 -1
  50. package/dist/Table/InnerTable.js +2 -1
  51. package/dist/Table/InnerTable.js.map +1 -1
  52. package/dist/Table/TableCell.d.ts +1 -1
  53. package/dist/Table/TableCell.d.ts.map +1 -1
  54. package/dist/Table/TableCell.js +3 -1
  55. package/dist/Table/TableCell.js.map +1 -1
  56. package/dist/Table/TableHeaderCell.d.ts +1 -1
  57. package/dist/Table/TableHeaderCell.d.ts.map +1 -1
  58. package/dist/Table/TableHeaderCell.js.map +1 -1
  59. package/dist/Table/model/table-model.d.ts +1 -1
  60. package/dist/Table/model/table-model.d.ts.map +1 -1
  61. package/dist/Table/model/table-model.js +25 -20
  62. package/dist/Table/model/table-model.js.map +1 -1
  63. package/dist/ThresholdsEditor/ThresholdInput.js +2 -2
  64. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  65. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
  66. package/dist/ThresholdsEditor/ThresholdsEditor.js +2 -2
  67. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  68. package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts +18 -0
  69. package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts.map +1 -0
  70. package/dist/{DateTimeRangePicker/AbsoluteTimePicker.js → TimeRangeSelector/DateTimeRangePicker.js} +45 -28
  71. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -0
  72. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +35 -0
  73. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +1 -0
  74. package/dist/TimeRangeSelector/TimeRangeSelector.js +119 -0
  75. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -0
  76. package/dist/{DateTimeRangePicker → TimeRangeSelector}/index.d.ts +1 -2
  77. package/dist/TimeRangeSelector/index.d.ts.map +1 -0
  78. package/dist/{DateTimeRangePicker → TimeRangeSelector}/index.js +2 -3
  79. package/dist/TimeRangeSelector/index.js.map +1 -0
  80. package/dist/TimeRangeSelector/utils.d.ts +25 -0
  81. package/dist/TimeRangeSelector/utils.d.ts.map +1 -0
  82. package/dist/{DateTimeRangePicker → TimeRangeSelector}/utils.js +23 -2
  83. package/dist/TimeRangeSelector/utils.js.map +1 -0
  84. package/dist/cjs/AlignSelector/AlignSelector.js +53 -0
  85. package/dist/cjs/AlignSelector/index.js +30 -0
  86. package/dist/cjs/{ThresholdsEditor/ThresholdColorPicker.js → ColorPicker/OptionsColorPicker.js} +6 -6
  87. package/dist/cjs/ColorPicker/index.js +1 -0
  88. package/dist/cjs/DensitySelector/DensitySelector.js +54 -0
  89. package/dist/cjs/DensitySelector/index.js +30 -0
  90. package/dist/cjs/Dialog/Dialog.js +7 -2
  91. package/dist/cjs/LinksEditor/LinksEditor.js +15 -8
  92. package/dist/cjs/Overlay/Overlay.js +71 -0
  93. package/dist/cjs/Overlay/index.js +30 -0
  94. package/dist/cjs/SortSelector/SortSelectorButtons.js +53 -0
  95. package/dist/cjs/SortSelector/index.js +2 -1
  96. package/dist/cjs/Table/InnerTable.js +2 -1
  97. package/dist/cjs/Table/TableCell.js +3 -1
  98. package/dist/cjs/Table/model/table-model.js +25 -20
  99. package/dist/cjs/ThresholdsEditor/ThresholdInput.js +2 -2
  100. package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +2 -2
  101. package/dist/cjs/{DateTimeRangePicker/AbsoluteTimePicker.js → TimeRangeSelector/DateTimeRangePicker.js} +39 -30
  102. package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +127 -0
  103. package/dist/cjs/{DateTimeRangePicker → TimeRangeSelector}/index.js +2 -3
  104. package/dist/cjs/{DateTimeRangePicker → TimeRangeSelector}/utils.js +24 -1
  105. package/dist/cjs/index.js +4 -1
  106. package/dist/cjs/model/timeOption.js +19 -1
  107. package/dist/index.d.ts +4 -1
  108. package/dist/index.d.ts.map +1 -1
  109. package/dist/index.js +4 -1
  110. package/dist/index.js.map +1 -1
  111. package/dist/model/timeOption.d.ts +2 -1
  112. package/dist/model/timeOption.d.ts.map +1 -1
  113. package/dist/model/timeOption.js +13 -2
  114. package/dist/model/timeOption.js.map +1 -1
  115. package/package.json +7 -6
  116. package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts +0 -9
  117. package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts.map +0 -1
  118. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js.map +0 -1
  119. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +0 -11
  120. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +0 -1
  121. package/dist/DateTimeRangePicker/DateTimeRangePicker.js +0 -80
  122. package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +0 -1
  123. package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts +0 -13
  124. package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +0 -1
  125. package/dist/DateTimeRangePicker/TimeRangeSelector.js +0 -67
  126. package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +0 -1
  127. package/dist/DateTimeRangePicker/index.d.ts.map +0 -1
  128. package/dist/DateTimeRangePicker/index.js.map +0 -1
  129. package/dist/DateTimeRangePicker/utils.d.ts +0 -7
  130. package/dist/DateTimeRangePicker/utils.d.ts.map +0 -1
  131. package/dist/DateTimeRangePicker/utils.js.map +0 -1
  132. package/dist/ThresholdsEditor/ThresholdColorPicker.d.ts +0 -3
  133. package/dist/ThresholdsEditor/ThresholdColorPicker.d.ts.map +0 -1
  134. package/dist/ThresholdsEditor/ThresholdColorPicker.js.map +0 -1
  135. package/dist/cjs/DateTimeRangePicker/DateTimeRangePicker.js +0 -88
  136. package/dist/cjs/DateTimeRangePicker/TimeRangeSelector.js +0 -80
@@ -1,67 +0,0 @@
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 } from "react/jsx-runtime";
14
- import { MenuItem, Select } from '@mui/material';
15
- import Calendar from 'mdi-material-ui/Calendar';
16
- import { isRelativeTimeRange } from '@perses-dev/core';
17
- import { useTimeZone } from '../context/TimeZoneProvider';
18
- import { formatAbsoluteRange } from './utils';
19
- const DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
20
- export function TimeRangeSelector(props) {
21
- const { value, timeOptions, onSelectChange, onCustomClick, height } = props;
22
- const { timeZone } = useTimeZone();
23
- const formattedValue = !isRelativeTimeRange(value) ? formatAbsoluteRange(value, DATE_TIME_FORMAT, timeZone) : value.pastDuration;
24
- return /*#__PURE__*/ _jsxs(Select, {
25
- value: formattedValue,
26
- onChange: onSelectChange,
27
- IconComponent: Calendar,
28
- inputProps: {
29
- 'aria-label': `Select time range. Currently set to ${formattedValue}`
30
- },
31
- sx: {
32
- // `transform: none` prevents calendar icon from flipping over when menu is open
33
- '.MuiSelect-icon': {
34
- marginTop: '1px',
35
- transform: 'none'
36
- },
37
- // paddingRight creates more space for the calendar icon (it's a bigger icon)
38
- '.MuiSelect-select.MuiSelect-outlined.MuiInputBase-input': {
39
- paddingRight: '36px'
40
- },
41
- '.MuiSelect-select': height ? {
42
- lineHeight: height,
43
- paddingY: 0
44
- } : {}
45
- },
46
- children: [
47
- timeOptions.map((item, idx)=>/*#__PURE__*/ _jsx(MenuItem, {
48
- value: item.value.pastDuration,
49
- children: item.display
50
- }, idx)),
51
- isRelativeTimeRange(value) ? /*#__PURE__*/ _jsx(MenuItem, {
52
- onClick: ()=>{
53
- onCustomClick();
54
- },
55
- children: "Custom time range"
56
- }) : /*#__PURE__*/ _jsx(MenuItem, {
57
- value: formattedValue,
58
- onClick: ()=>{
59
- onCustomClick();
60
- },
61
- children: formattedValue
62
- })
63
- ]
64
- });
65
- }
66
-
67
- //# sourceMappingURL=TimeRangeSelector.js.map
@@ -1 +0,0 @@
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, isRelativeTimeRange } from '@perses-dev/core';\nimport { useTimeZone } from '../context/TimeZoneProvider';\nimport { TimeOption } from '../model';\nimport { formatAbsoluteRange } from './utils';\n\nconst DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';\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 // `transform: none` prevents calendar icon from flipping over when menu is open\n '.MuiSelect-icon': {\n marginTop: '1px',\n transform: 'none',\n },\n // paddingRight creates more space for the calendar icon (it's a bigger icon)\n '.MuiSelect-select.MuiSelect-outlined.MuiInputBase-input': {\n paddingRight: '36px',\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","transform","paddingRight","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,SAASA,QAAQ,EAAEC,MAAM,QAA2B,gBAAgB;AACpE,OAAOC,cAAc,2BAA2B;AAChD,SAAyBC,mBAAmB,QAAQ,mBAAmB;AACvE,SAASC,WAAW,QAAQ,8BAA8B;AAE1D,SAASC,mBAAmB,QAAQ,UAAU;AAE9C,MAAMC,mBAAmB;AAUzB,OAAO,SAASC,kBAAkBC,KAA6B;IAC7D,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAEC,cAAc,EAAEC,aAAa,EAAEC,MAAM,EAAE,GAAGL;IACtE,MAAM,EAAEM,QAAQ,EAAE,GAAGV;IACrB,MAAMW,iBAAiB,CAACZ,oBAAoBM,SACxCJ,oBAAoBI,OAAOH,kBAAkBQ,YAC7CL,MAAMO,YAAY;IACtB,qBACE,MAACf;QACCQ,OAAOM;QACPE,UAAUN;QACVO,eAAehB;QACfiB,YAAY;YACV,cAAc,CAAC,oCAAoC,EAAEJ,eAAe,CAAC;QACvE;QACAK,IAAI;YACF,gFAAgF;YAChF,mBAAmB;gBACjBC,WAAW;gBACXC,WAAW;YACb;YACA,6EAA6E;YAC7E,2DAA2D;gBACzDC,cAAc;YAChB;YACA,qBAAqBV,SAAS;gBAAEW,YAAYX;gBAAQY,UAAU;YAAE,IAAI,CAAC;QACvE;;YAECf,YAAYgB,GAAG,CAAC,CAACC,MAAMC,oBACtB,KAAC5B;oBAAmBS,OAAOkB,KAAKlB,KAAK,CAACO,YAAY;8BAC/CW,KAAKE,OAAO;mBADAD;YAKhBzB,oBAAoBM,uBACnB,KAACT;gBACC8B,SAAS;oBACPlB;gBACF;0BACD;+BAID,KAACZ;gBACCS,OAAOM;gBACPe,SAAS;oBACPlB;gBACF;0BAECG;;;;AAKX"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DateTimeRangePicker/index.ts"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/DateTimeRangePicker/index.ts"],"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 './DateTimeRangePicker';\nexport * from './TimeRangeSelector';\nexport * from './AbsoluteTimePicker';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,wBAAwB;AACtC,cAAc,sBAAsB;AACpC,cAAc,uBAAuB"}
@@ -1,7 +0,0 @@
1
- import { AbsoluteTimeRange } from '@perses-dev/core';
2
- export declare function validateDateRange(startDate: Date, endDate: Date): boolean;
3
- /**
4
- * Format start and end time based on provided date format
5
- */
6
- export declare function formatAbsoluteRange(timeRange: AbsoluteTimeRange, dateFormat: string, timeZone?: string): string;
7
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/DateTimeRangePicker/utils.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,WAW/D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,UAItG"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/DateTimeRangePicker/utils.ts"],"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 { isBefore, isValid } from 'date-fns';\nimport { AbsoluteTimeRange } from '@perses-dev/core';\nimport { formatWithTimeZone } from '../utils';\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, timeZone?: string) {\n const formattedStart = formatWithTimeZone(timeRange.start, dateFormat, timeZone);\n const formattedEnd = formatWithTimeZone(timeRange.end, dateFormat, timeZone);\n return `${formattedStart} - ${formattedEnd}`;\n}\n"],"names":["isBefore","isValid","formatWithTimeZone","validateDateRange","startDate","endDate","console","error","formatAbsoluteRange","timeRange","dateFormat","timeZone","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,QAAQ,WAAW;AAE7C,SAASC,kBAAkB,QAAQ,WAAW;AAE9C;;CAEC,GACD,OAAO,SAASC,kBAAkBC,SAAe,EAAEC,OAAa;IAC9D,oCAAoC;IACpC,IAAI,CAACJ,QAAQG,cAAc,CAACH,QAAQI,UAAU;QAC5CC,QAAQC,KAAK,CAAC;QACd,OAAO;IACT;IACA,IAAI,CAACP,SAASI,WAAWC,UAAU;QACjCC,QAAQC,KAAK,CAAC;QACd,OAAO;IACT;IACA,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,SAASC,oBAAoBC,SAA4B,EAAEC,UAAkB,EAAEC,QAAiB;IACrG,MAAMC,iBAAiBV,mBAAmBO,UAAUI,KAAK,EAAEH,YAAYC;IACvE,MAAMG,eAAeZ,mBAAmBO,UAAUM,GAAG,EAAEL,YAAYC;IACnE,OAAO,CAAC,EAAEC,eAAe,GAAG,EAAEE,aAAa,CAAC;AAC9C"}
@@ -1,3 +0,0 @@
1
- import { ThresholdInputProps } from './ThresholdInput';
2
- export declare function ThresholdColorPicker({ color, onColorChange, label, }: Pick<ThresholdInputProps, 'color' | 'onColorChange' | 'label'>): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=ThresholdColorPicker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThresholdColorPicker.d.ts","sourceRoot":"","sources":["../../src/ThresholdsEditor/ThresholdColorPicker.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,aAAa,EACb,KAAK,GACN,EAAE,IAAI,CAAC,mBAAmB,EAAE,OAAO,GAAG,eAAe,GAAG,OAAO,CAAC,2CA8ChE"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/ThresholdsEditor/ThresholdColorPicker.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 { styled, IconButton, Popover } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { useChartsTheme } from '../context/ChartsProvider';\nimport { ColorPicker } from '../ColorPicker';\nimport { ThresholdInputProps } from './ThresholdInput';\n\nexport function ThresholdColorPicker({\n color,\n onColorChange,\n label,\n}: Pick<ThresholdInputProps, 'color' | 'onColorChange' | 'label'>) {\n const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(null);\n const isOpen = Boolean(anchorEl);\n\n const openColorPicker = (event: React.MouseEvent<HTMLButtonElement>) => {\n setAnchorEl(event.currentTarget);\n };\n\n const closeColorPicker = () => {\n setAnchorEl(null);\n };\n\n const {\n thresholds: { defaultColor, palette },\n } = useChartsTheme();\n\n return (\n <>\n <ColorIconButton\n size=\"small\"\n aria-label={`change threshold ${label} color`}\n isSelected={isOpen}\n iconColor={color}\n onClick={openColorPicker}\n >\n <CircleIcon />\n </ColorIconButton>\n <Popover\n data-testid=\"threshold color picker\"\n open={isOpen}\n anchorEl={anchorEl}\n onClose={closeColorPicker}\n PaperProps={{ sx: { padding: (theme) => theme.spacing(2) } }}\n anchorOrigin={{\n vertical: 'top',\n horizontal: 'left',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'right',\n }}\n >\n <ColorPicker color={color} onChange={onColorChange} palette={[defaultColor, ...palette]} />\n </Popover>\n </>\n );\n}\n\nconst ColorIconButton = styled(IconButton, {\n shouldForwardProp: (props) => props !== 'isSelected' && props !== 'iconColor',\n})<{\n iconColor?: string;\n isSelected?: boolean;\n}>(({ iconColor, isSelected }) => ({\n backgroundColor: isSelected && iconColor ? `${iconColor}3F` : 'undefined', // 3F represents 25% opacity\n color: iconColor,\n}));\n"],"names":["React","styled","IconButton","Popover","CircleIcon","useChartsTheme","ColorPicker","ThresholdColorPicker","color","onColorChange","label","anchorEl","setAnchorEl","useState","isOpen","Boolean","openColorPicker","event","currentTarget","closeColorPicker","thresholds","defaultColor","palette","ColorIconButton","size","aria-label","isSelected","iconColor","onClick","data-testid","open","onClose","PaperProps","sx","padding","theme","spacing","anchorOrigin","vertical","horizontal","transformOrigin","onChange","shouldForwardProp","props","backgroundColor"],"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,OAAOA,WAAW,QAAQ;AAC1B,SAASC,MAAM,EAAEC,UAAU,EAAEC,OAAO,QAAQ,gBAAgB;AAC5D,OAAOC,gBAAgB,yBAAyB;AAChD,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,WAAW,QAAQ,iBAAiB;AAG7C,OAAO,SAASC,qBAAqB,EACnCC,KAAK,EACLC,aAAa,EACbC,KAAK,EAC0D;IAC/D,MAAM,CAACC,UAAUC,YAAY,GAAGZ,MAAMa,QAAQ,CAA2B;IACzE,MAAMC,SAASC,QAAQJ;IAEvB,MAAMK,kBAAkB,CAACC;QACvBL,YAAYK,MAAMC,aAAa;IACjC;IAEA,MAAMC,mBAAmB;QACvBP,YAAY;IACd;IAEA,MAAM,EACJQ,YAAY,EAAEC,YAAY,EAAEC,OAAO,EAAE,EACtC,GAAGjB;IAEJ,qBACE;;0BACE,KAACkB;gBACCC,MAAK;gBACLC,cAAY,CAAC,iBAAiB,EAAEf,MAAM,MAAM,CAAC;gBAC7CgB,YAAYZ;gBACZa,WAAWnB;gBACXoB,SAASZ;0BAET,cAAA,KAACZ;;0BAEH,KAACD;gBACC0B,eAAY;gBACZC,MAAMhB;gBACNH,UAAUA;gBACVoB,SAASZ;gBACTa,YAAY;oBAAEC,IAAI;wBAAEC,SAAS,CAACC,QAAUA,MAAMC,OAAO,CAAC;oBAAG;gBAAE;gBAC3DC,cAAc;oBACZC,UAAU;oBACVC,YAAY;gBACd;gBACAC,iBAAiB;oBACfF,UAAU;oBACVC,YAAY;gBACd;0BAEA,cAAA,KAACjC;oBAAYE,OAAOA;oBAAOiC,UAAUhC;oBAAea,SAAS;wBAACD;2BAAiBC;qBAAQ;;;;;AAI/F;AAEA,MAAMC,kBAAkBtB,OAAOC,YAAY;IACzCwC,mBAAmB,CAACC,QAAUA,UAAU,gBAAgBA,UAAU;AACpE,GAGG,CAAC,EAAEhB,SAAS,EAAED,UAAU,EAAE,GAAM,CAAA;QACjCkB,iBAAiBlB,cAAcC,YAAY,CAAC,EAAEA,UAAU,EAAE,CAAC,GAAG;QAC9DnB,OAAOmB;IACT,CAAA"}
@@ -1,88 +0,0 @@
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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "DateTimeRangePicker", {
18
- enumerable: true,
19
- get: function() {
20
- return DateTimeRangePicker;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _react = require("react");
25
- const _material = require("@mui/material");
26
- const _core = require("@perses-dev/core");
27
- const _AbsoluteTimePicker = require("./AbsoluteTimePicker");
28
- const _TimeRangeSelector = require("./TimeRangeSelector");
29
- function DateTimeRangePicker(props) {
30
- const { value, onChange, timeOptions, height } = props;
31
- const [showCustomDateSelector, setShowCustomDateSelector] = (0, _react.useState)(false);
32
- const anchorEl = (0, _react.useRef)();
33
- const convertedTimeRange = (0, _react.useMemo)(()=>{
34
- return (0, _core.isRelativeTimeRange)(value) ? (0, _core.toAbsoluteTimeRange)(value) : value;
35
- }, [
36
- value
37
- ]);
38
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
39
- direction: "row",
40
- spacing: 1,
41
- height: height,
42
- children: [
43
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Popover, {
44
- anchorEl: anchorEl.current,
45
- anchorOrigin: {
46
- vertical: 'bottom',
47
- horizontal: 'center'
48
- },
49
- open: showCustomDateSelector,
50
- onClose: ()=>setShowCustomDateSelector(false),
51
- sx: (theme)=>({
52
- padding: theme.spacing(2)
53
- }),
54
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_AbsoluteTimePicker.AbsoluteTimePicker, {
55
- initialTimeRange: convertedTimeRange,
56
- onChange: (value)=>{
57
- onChange(value);
58
- setShowCustomDateSelector(false);
59
- },
60
- onCancel: ()=>setShowCustomDateSelector(false)
61
- })
62
- }),
63
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControl, {
64
- fullWidth: true,
65
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
66
- ref: anchorEl,
67
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeRangeSelector.TimeRangeSelector, {
68
- timeOptions: timeOptions,
69
- value: value,
70
- height: height,
71
- onSelectChange: (event)=>{
72
- const duration = event.target.value;
73
- const relativeTimeInput = {
74
- pastDuration: duration,
75
- end: new Date()
76
- };
77
- onChange(relativeTimeInput);
78
- setShowCustomDateSelector(false);
79
- },
80
- onCustomClick: ()=>{
81
- setShowCustomDateSelector(true);
82
- }
83
- })
84
- })
85
- })
86
- ]
87
- });
88
- }
@@ -1,80 +0,0 @@
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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "TimeRangeSelector", {
18
- enumerable: true,
19
- get: function() {
20
- return TimeRangeSelector;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _material = require("@mui/material");
25
- const _Calendar = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Calendar"));
26
- const _core = require("@perses-dev/core");
27
- const _TimeZoneProvider = require("../context/TimeZoneProvider");
28
- const _utils = require("./utils");
29
- function _interop_require_default(obj) {
30
- return obj && obj.__esModule ? obj : {
31
- default: obj
32
- };
33
- }
34
- const DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
35
- function TimeRangeSelector(props) {
36
- const { value, timeOptions, onSelectChange, onCustomClick, height } = props;
37
- const { timeZone } = (0, _TimeZoneProvider.useTimeZone)();
38
- const formattedValue = !(0, _core.isRelativeTimeRange)(value) ? (0, _utils.formatAbsoluteRange)(value, DATE_TIME_FORMAT, timeZone) : value.pastDuration;
39
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Select, {
40
- value: formattedValue,
41
- onChange: onSelectChange,
42
- IconComponent: _Calendar.default,
43
- inputProps: {
44
- 'aria-label': `Select time range. Currently set to ${formattedValue}`
45
- },
46
- sx: {
47
- // `transform: none` prevents calendar icon from flipping over when menu is open
48
- '.MuiSelect-icon': {
49
- marginTop: '1px',
50
- transform: 'none'
51
- },
52
- // paddingRight creates more space for the calendar icon (it's a bigger icon)
53
- '.MuiSelect-select.MuiSelect-outlined.MuiInputBase-input': {
54
- paddingRight: '36px'
55
- },
56
- '.MuiSelect-select': height ? {
57
- lineHeight: height,
58
- paddingY: 0
59
- } : {}
60
- },
61
- children: [
62
- timeOptions.map((item, idx)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
63
- value: item.value.pastDuration,
64
- children: item.display
65
- }, idx)),
66
- (0, _core.isRelativeTimeRange)(value) ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
67
- onClick: ()=>{
68
- onCustomClick();
69
- },
70
- children: "Custom time range"
71
- }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
72
- value: formattedValue,
73
- onClick: ()=>{
74
- onCustomClick();
75
- },
76
- children: formattedValue
77
- })
78
- ]
79
- });
80
- }