@perses-dev/components 0.14.0 → 0.16.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 (178) hide show
  1. package/dist/{TimeRangeSelector → DateTimeRangePicker}/AbsoluteTimePicker.d.ts +0 -0
  2. package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts.map +1 -0
  3. package/dist/{TimeRangeSelector → DateTimeRangePicker}/AbsoluteTimePicker.js +38 -33
  4. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js.map +1 -0
  5. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +11 -0
  6. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -0
  7. package/dist/DateTimeRangePicker/DateTimeRangePicker.js +77 -0
  8. package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -0
  9. package/dist/{TimeRangeSelector → DateTimeRangePicker}/TimeRangeSelector.d.ts +0 -0
  10. package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -0
  11. package/dist/{TimeRangeSelector → DateTimeRangePicker}/TimeRangeSelector.js +0 -0
  12. package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -0
  13. package/dist/{TimeRangeSelector → DateTimeRangePicker}/index.d.ts +1 -0
  14. package/dist/DateTimeRangePicker/index.d.ts.map +1 -0
  15. package/dist/{TimeRangeSelector → DateTimeRangePicker}/index.js +1 -0
  16. package/dist/DateTimeRangePicker/index.js.map +1 -0
  17. package/dist/{TimeRangeSelector → DateTimeRangePicker}/utils.d.ts +0 -0
  18. package/dist/DateTimeRangePicker/utils.d.ts.map +1 -0
  19. package/dist/{TimeRangeSelector → DateTimeRangePicker}/utils.js +0 -0
  20. package/dist/DateTimeRangePicker/utils.js.map +1 -0
  21. package/dist/Legend/CompactLegend.d.ts +6 -1
  22. package/dist/Legend/CompactLegend.d.ts.map +1 -1
  23. package/dist/Legend/CompactLegend.js +16 -7
  24. package/dist/Legend/CompactLegend.js.map +1 -1
  25. package/dist/Legend/Legend.d.ts.map +1 -1
  26. package/dist/Legend/Legend.js +4 -9
  27. package/dist/Legend/Legend.js.map +1 -1
  28. package/dist/Legend/ListLegend.d.ts +3 -0
  29. package/dist/Legend/ListLegend.d.ts.map +1 -1
  30. package/dist/Legend/ListLegend.js +18 -2
  31. package/dist/Legend/ListLegend.js.map +1 -1
  32. package/dist/Legend/ListLegendItem.d.ts +2 -1
  33. package/dist/Legend/ListLegendItem.d.ts.map +1 -1
  34. package/dist/Legend/ListLegendItem.js +11 -9
  35. package/dist/Legend/ListLegendItem.js.map +1 -1
  36. package/dist/LineChart/LineChart.js +2 -1
  37. package/dist/LineChart/LineChart.js.map +1 -1
  38. package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts +13 -0
  39. package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts.map +1 -0
  40. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +28 -0
  41. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -0
  42. package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts +5 -0
  43. package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts.map +1 -0
  44. package/dist/OptionsEditorLayout/OptionsEditorControl.js +50 -0
  45. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -0
  46. package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts +13 -0
  47. package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts.map +1 -0
  48. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +26 -0
  49. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -0
  50. package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts +13 -0
  51. package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts.map +1 -0
  52. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +36 -0
  53. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -0
  54. package/dist/OptionsEditorLayout/index.d.ts +5 -0
  55. package/dist/OptionsEditorLayout/index.d.ts.map +1 -0
  56. package/dist/OptionsEditorLayout/index.js +18 -0
  57. package/dist/OptionsEditorLayout/index.js.map +1 -0
  58. package/dist/Tooltip/SeriesInfo.d.ts +1 -0
  59. package/dist/Tooltip/SeriesInfo.d.ts.map +1 -1
  60. package/dist/Tooltip/SeriesInfo.js +3 -3
  61. package/dist/Tooltip/SeriesInfo.js.map +1 -1
  62. package/dist/Tooltip/Tooltip.d.ts +2 -1
  63. package/dist/Tooltip/Tooltip.d.ts.map +1 -1
  64. package/dist/Tooltip/Tooltip.js +2 -2
  65. package/dist/Tooltip/Tooltip.js.map +1 -1
  66. package/dist/Tooltip/TooltipContent.d.ts.map +1 -1
  67. package/dist/Tooltip/TooltipContent.js +2 -1
  68. package/dist/Tooltip/TooltipContent.js.map +1 -1
  69. package/dist/Tooltip/focused-series.d.ts +4 -3
  70. package/dist/Tooltip/focused-series.d.ts.map +1 -1
  71. package/dist/Tooltip/focused-series.js +6 -3
  72. package/dist/Tooltip/focused-series.js.map +1 -1
  73. package/dist/Tooltip/focused-series.test.js +20 -2
  74. package/dist/Tooltip/focused-series.test.js.map +1 -1
  75. package/dist/UnitSelector/UnitSelector.d.ts +8 -0
  76. package/dist/UnitSelector/UnitSelector.d.ts.map +1 -0
  77. package/dist/UnitSelector/UnitSelector.js +112 -0
  78. package/dist/UnitSelector/UnitSelector.js.map +1 -0
  79. package/dist/UnitSelector/UnitSelector.test.d.ts +2 -0
  80. package/dist/UnitSelector/UnitSelector.test.d.ts.map +1 -0
  81. package/dist/UnitSelector/UnitSelector.test.js +211 -0
  82. package/dist/UnitSelector/UnitSelector.test.js.map +1 -0
  83. package/dist/UnitSelector/index.d.ts +2 -0
  84. package/dist/UnitSelector/index.d.ts.map +1 -0
  85. package/dist/UnitSelector/index.js +15 -0
  86. package/dist/UnitSelector/index.js.map +1 -0
  87. package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/AbsoluteTimePicker.js +37 -32
  88. package/dist/cjs/DateTimeRangePicker/DateTimeRangePicker.js +83 -0
  89. package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/TimeRangeSelector.js +0 -0
  90. package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/index.js +1 -0
  91. package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/utils.js +0 -0
  92. package/dist/cjs/Legend/CompactLegend.js +12 -6
  93. package/dist/cjs/Legend/Legend.js +4 -9
  94. package/dist/cjs/Legend/ListLegend.js +15 -1
  95. package/dist/cjs/Legend/ListLegendItem.js +48 -13
  96. package/dist/cjs/LineChart/LineChart.js +2 -1
  97. package/dist/cjs/OptionsEditorLayout/OptionsEditorColumn.js +32 -0
  98. package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +61 -0
  99. package/dist/cjs/OptionsEditorLayout/OptionsEditorGrid.js +29 -0
  100. package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +40 -0
  101. package/dist/cjs/OptionsEditorLayout/index.js +31 -0
  102. package/dist/cjs/Tooltip/SeriesInfo.js +3 -3
  103. package/dist/cjs/Tooltip/Tooltip.js +2 -2
  104. package/dist/cjs/Tooltip/TooltipContent.js +2 -1
  105. package/dist/cjs/Tooltip/focused-series.js +6 -3
  106. package/dist/cjs/Tooltip/focused-series.test.js +20 -2
  107. package/dist/cjs/UnitSelector/UnitSelector.js +118 -0
  108. package/dist/cjs/UnitSelector/UnitSelector.test.js +218 -0
  109. package/dist/cjs/UnitSelector/index.js +28 -0
  110. package/dist/cjs/index.js +4 -2
  111. package/dist/cjs/model/units/bytes.js +60 -0
  112. package/dist/cjs/model/units/constants.js +23 -0
  113. package/dist/cjs/model/units/decimal.js +67 -0
  114. package/dist/cjs/model/units/index.js +30 -0
  115. package/dist/cjs/model/units/percent.js +64 -0
  116. package/dist/cjs/model/units/time.js +138 -0
  117. package/dist/cjs/model/units/types.js +28 -0
  118. package/dist/cjs/model/units/units.js +104 -0
  119. package/dist/cjs/utils/component-ids.js +31 -0
  120. package/dist/cjs/utils/index.js +1 -0
  121. package/dist/index.d.ts +4 -2
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js +4 -2
  124. package/dist/index.js.map +1 -1
  125. package/dist/model/units/bytes.d.ts +12 -0
  126. package/dist/model/units/bytes.d.ts.map +1 -0
  127. package/dist/model/units/bytes.js +48 -0
  128. package/dist/model/units/bytes.js.map +1 -0
  129. package/dist/model/units/constants.d.ts +2 -0
  130. package/dist/model/units/constants.d.ts.map +1 -0
  131. package/dist/model/units/constants.js +17 -0
  132. package/dist/model/units/constants.js.map +1 -0
  133. package/dist/model/units/decimal.d.ts +24 -0
  134. package/dist/model/units/decimal.d.ts.map +1 -0
  135. package/dist/model/units/decimal.js +59 -0
  136. package/dist/model/units/decimal.js.map +1 -0
  137. package/dist/model/units/index.d.ts +4 -0
  138. package/dist/model/units/index.d.ts.map +1 -0
  139. package/dist/model/units/index.js +17 -0
  140. package/dist/model/units/index.js.map +1 -0
  141. package/dist/model/units/percent.d.ts +12 -0
  142. package/dist/model/units/percent.d.ts.map +1 -0
  143. package/dist/model/units/percent.js +51 -0
  144. package/dist/model/units/percent.js.map +1 -0
  145. package/dist/model/units/time.d.ts +11 -0
  146. package/dist/model/units/time.d.ts.map +1 -0
  147. package/dist/model/units/time.js +125 -0
  148. package/dist/model/units/time.js.map +1 -0
  149. package/dist/model/units/types.d.ts +38 -0
  150. package/dist/model/units/types.d.ts.map +1 -0
  151. package/dist/model/units/types.js +22 -0
  152. package/dist/model/units/types.js.map +1 -0
  153. package/dist/model/units/units.d.ts +40 -0
  154. package/dist/model/units/units.d.ts.map +1 -0
  155. package/dist/model/units/units.js +83 -0
  156. package/dist/model/units/units.js.map +1 -0
  157. package/dist/utils/component-ids.d.ts +8 -0
  158. package/dist/utils/component-ids.d.ts.map +1 -0
  159. package/dist/utils/component-ids.js +27 -0
  160. package/dist/utils/component-ids.js.map +1 -0
  161. package/dist/utils/index.d.ts +1 -0
  162. package/dist/utils/index.d.ts.map +1 -1
  163. package/dist/utils/index.js +1 -0
  164. package/dist/utils/index.js.map +1 -1
  165. package/package.json +2 -2
  166. package/dist/TimeRangeSelector/AbsoluteTimePicker.d.ts.map +0 -1
  167. package/dist/TimeRangeSelector/AbsoluteTimePicker.js.map +0 -1
  168. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +0 -1
  169. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +0 -1
  170. package/dist/TimeRangeSelector/index.d.ts.map +0 -1
  171. package/dist/TimeRangeSelector/index.js.map +0 -1
  172. package/dist/TimeRangeSelector/utils.d.ts.map +0 -1
  173. package/dist/TimeRangeSelector/utils.js.map +0 -1
  174. package/dist/cjs/model/units.js +0 -203
  175. package/dist/model/units.d.ts +0 -36
  176. package/dist/model/units.d.ts.map +0 -1
  177. package/dist/model/units.js +0 -196
  178. package/dist/model/units.js.map +0 -1
@@ -0,0 +1,17 @@
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 './units';
14
+ export * from './constants';
15
+ export * from './types';
16
+
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/model/units/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 './units';\nexport * from './constants';\nexport * from './types';\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,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { UnitGroupConfig, UnitConfig } from './types';
2
+ declare const percentUnitKinds: readonly ["Percent", "PercentDecimal", "%"];
3
+ declare type PercentUnitKind = typeof percentUnitKinds[number];
4
+ export declare type PercentUnitOptions = {
5
+ kind: PercentUnitKind;
6
+ decimal_places?: number;
7
+ };
8
+ export declare const DECIMAL_GROUP_CONFIG: UnitGroupConfig;
9
+ export declare const PERCENT_UNIT_CONFIG: Readonly<Record<PercentUnitKind, UnitConfig>>;
10
+ export declare function formatPercent(value: number, unitOptions: PercentUnitOptions): string;
11
+ export {};
12
+ //# sourceMappingURL=percent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"percent.d.ts","sourceRoot":"","sources":["../../../src/model/units/percent.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGtD,QAAA,MAAM,gBAAgB,6CAA8C,CAAC;AACrE,aAAK,eAAe,GAAG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACvD,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,EAAE,eAAe,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AACF,eAAO,MAAM,oBAAoB,EAAE,eAIlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,UAAU,CAAC,CAgB7E,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,kBAAkB,GAAG,MAAM,CAQpF"}
@@ -0,0 +1,51 @@
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 { DEFAULT_DECIMAL_PLACES } from './constants';
14
+ const percentUnitKinds = [
15
+ 'Percent',
16
+ 'PercentDecimal',
17
+ '%'
18
+ ];
19
+ export const DECIMAL_GROUP_CONFIG = {
20
+ label: 'Decimal',
21
+ decimal_places: true,
22
+ abbreviate: true
23
+ };
24
+ const PERCENT_GROUP = 'Percent';
25
+ export const PERCENT_UNIT_CONFIG = {
26
+ Percent: {
27
+ group: PERCENT_GROUP,
28
+ label: 'Percent (0-100)'
29
+ },
30
+ PercentDecimal: {
31
+ group: PERCENT_GROUP,
32
+ label: 'Percent (0.0-1.0)'
33
+ },
34
+ '%': {
35
+ // This option is not shown in the selector because it is a shorthand
36
+ // duplicate of `Percent`.
37
+ disableSelectorOption: true,
38
+ group: PERCENT_GROUP,
39
+ label: '%'
40
+ }
41
+ };
42
+ export function formatPercent(value, unitOptions) {
43
+ var _decimal_places;
44
+ const decimals = (_decimal_places = unitOptions.decimal_places) !== null && _decimal_places !== void 0 ? _decimal_places : DEFAULT_DECIMAL_PLACES;
45
+ if (unitOptions.kind === 'PercentDecimal') {
46
+ value = value * 100;
47
+ }
48
+ return value.toFixed(decimals) + '%';
49
+ }
50
+
51
+ //# sourceMappingURL=percent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/model/units/percent.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 { UnitGroupConfig, UnitConfig } from './types';\nimport { DEFAULT_DECIMAL_PLACES } from './constants';\n\nconst percentUnitKinds = ['Percent', 'PercentDecimal', '%'] as const;\ntype PercentUnitKind = typeof percentUnitKinds[number];\nexport type PercentUnitOptions = {\n kind: PercentUnitKind;\n decimal_places?: number;\n};\nexport const DECIMAL_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Decimal',\n decimal_places: true,\n abbreviate: true,\n};\nconst PERCENT_GROUP = 'Percent';\nexport const PERCENT_UNIT_CONFIG: Readonly<Record<PercentUnitKind, UnitConfig>> = {\n Percent: {\n group: PERCENT_GROUP,\n label: 'Percent (0-100)',\n },\n PercentDecimal: {\n group: PERCENT_GROUP,\n label: 'Percent (0.0-1.0)',\n },\n '%': {\n // This option is not shown in the selector because it is a shorthand\n // duplicate of `Percent`.\n disableSelectorOption: true,\n group: PERCENT_GROUP,\n label: '%',\n },\n};\n\nexport function formatPercent(value: number, unitOptions: PercentUnitOptions): string {\n const decimals = unitOptions.decimal_places ?? DEFAULT_DECIMAL_PLACES;\n\n if (unitOptions.kind === 'PercentDecimal') {\n value = value * 100;\n }\n\n return value.toFixed(decimals) + '%';\n}\n"],"names":["DEFAULT_DECIMAL_PLACES","percentUnitKinds","DECIMAL_GROUP_CONFIG","label","decimal_places","abbreviate","PERCENT_GROUP","PERCENT_UNIT_CONFIG","Percent","group","PercentDecimal","disableSelectorOption","formatPercent","value","unitOptions","decimals","kind","toFixed"],"mappings":"AAAA,o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itKinds: readonly ["Milliseconds", "Seconds", "Minutes", "Hours", "Days", "Weeks", "Months", "Years"];
3
+ declare type TimeUnitKind = typeof timeUnitKinds[number];
4
+ export declare type TimeUnitOptions = {
5
+ kind: TimeUnitKind;
6
+ };
7
+ export declare const TIME_GROUP_CONFIG: UnitGroupConfig;
8
+ export declare const TIME_UNIT_CONFIG: Readonly<Record<TimeUnitKind, UnitConfig>>;
9
+ export declare function formatTime(value: number, unitOptions: TimeUnitOptions): string;
10
+ export {};
11
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/model/units/time.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtD,QAAA,MAAM,aAAa,8FAA+F,CAAC;AACnH,aAAK,YAAY,GAAG,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;AACjD,oBAAY,eAAe,GAAG;IAC5B,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAE/B,CAAC;AACF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAiCvE,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,GAAG,MAAM,CAmE9E"}
@@ -0,0 +1,125 @@
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 { milliseconds } from 'date-fns';
14
+ const timeUnitKinds = [
15
+ 'Milliseconds',
16
+ 'Seconds',
17
+ 'Minutes',
18
+ 'Hours',
19
+ 'Days',
20
+ 'Weeks',
21
+ 'Months',
22
+ 'Years'
23
+ ];
24
+ const TIME_GROUP = 'Time';
25
+ export const TIME_GROUP_CONFIG = {
26
+ label: 'Time'
27
+ };
28
+ export const TIME_UNIT_CONFIG = {
29
+ Milliseconds: {
30
+ group: TIME_GROUP,
31
+ label: 'Milliseconds'
32
+ },
33
+ Seconds: {
34
+ group: TIME_GROUP,
35
+ label: 'Seconds'
36
+ },
37
+ Minutes: {
38
+ group: TIME_GROUP,
39
+ label: 'Minutes'
40
+ },
41
+ Hours: {
42
+ group: TIME_GROUP,
43
+ label: 'Hours'
44
+ },
45
+ Days: {
46
+ group: TIME_GROUP,
47
+ label: 'Days'
48
+ },
49
+ Weeks: {
50
+ group: TIME_GROUP,
51
+ label: 'Weeks'
52
+ },
53
+ Months: {
54
+ group: TIME_GROUP,
55
+ label: 'Months'
56
+ },
57
+ Years: {
58
+ group: TIME_GROUP,
59
+ label: 'Years'
60
+ }
61
+ };
62
+ export function formatTime(value, unitOptions) {
63
+ // Create a Duration from the value based on what time unit it is
64
+ const duration = {};
65
+ switch(unitOptions.kind){
66
+ case 'Milliseconds':
67
+ duration.seconds = value / 1000;
68
+ break;
69
+ case 'Seconds':
70
+ duration.seconds = value;
71
+ break;
72
+ case 'Minutes':
73
+ duration.minutes = value;
74
+ break;
75
+ case 'Hours':
76
+ duration.hours = value;
77
+ break;
78
+ case 'Days':
79
+ duration.days = value;
80
+ break;
81
+ case 'Weeks':
82
+ duration.weeks = value;
83
+ break;
84
+ case 'Months':
85
+ duration.months = value;
86
+ break;
87
+ case 'Years':
88
+ duration.years = value;
89
+ break;
90
+ default:
91
+ {
92
+ const exhaustive = unitOptions.kind;
93
+ throw new Error(`Unknown time unit type ${exhaustive}`);
94
+ }
95
+ }
96
+ // Find the largest whole time unit we can display the value in and use it
97
+ const ms = milliseconds(duration);
98
+ const seconds = ms / 1000;
99
+ if (seconds < 1) {
100
+ return `${ms.toFixed()} milliseconds`;
101
+ }
102
+ const minutes = seconds / 60;
103
+ if (minutes < 1) {
104
+ return `${seconds.toFixed()} seconds`;
105
+ }
106
+ const hours = minutes / 60;
107
+ if (hours < 1) {
108
+ return `${minutes.toFixed()} minutes`;
109
+ }
110
+ const days = hours / 24;
111
+ if (days < 1) {
112
+ return `${hours.toFixed()} hours`;
113
+ }
114
+ const weeks = days / 7;
115
+ if (weeks < 1) {
116
+ return `${days.toFixed()} days`;
117
+ }
118
+ const years = weeks / 52;
119
+ if (years < 1) {
120
+ return `${weeks.toFixed()} weeks`;
121
+ }
122
+ return `${years.toFixed()} years`;
123
+ }
124
+
125
+ //# sourceMappingURL=time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/model/units/time.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 { Duration, milliseconds } from 'date-fns';\nimport { UnitGroupConfig, UnitConfig } from './types';\n\nconst timeUnitKinds = ['Milliseconds', 'Seconds', 'Minutes', 'Hours', 'Days', 'Weeks', 'Months', 'Years'] as const;\ntype TimeUnitKind = typeof timeUnitKinds[number];\nexport type TimeUnitOptions = {\n kind: TimeUnitKind;\n};\nconst TIME_GROUP = 'Time';\nexport const TIME_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Time',\n};\nexport const TIME_UNIT_CONFIG: Readonly<Record<TimeUnitKind, UnitConfig>> = {\n Milliseconds: {\n group: TIME_GROUP,\n label: 'Milliseconds',\n },\n Seconds: {\n group: TIME_GROUP,\n label: 'Seconds',\n },\n Minutes: {\n group: TIME_GROUP,\n label: 'Minutes',\n },\n Hours: {\n group: TIME_GROUP,\n label: 'Hours',\n },\n Days: {\n group: TIME_GROUP,\n label: 'Days',\n },\n Weeks: {\n group: TIME_GROUP,\n label: 'Weeks',\n },\n Months: {\n group: TIME_GROUP,\n label: 'Months',\n },\n Years: {\n group: TIME_GROUP,\n label: 'Years',\n },\n};\n\nexport function formatTime(value: number, unitOptions: TimeUnitOptions): string {\n // Create a Duration from the value based on what time unit it is\n const duration: Duration = {};\n switch (unitOptions.kind) {\n case 'Milliseconds':\n duration.seconds = value / 1000;\n break;\n case 'Seconds':\n duration.seconds = value;\n break;\n case 'Minutes':\n duration.minutes = value;\n break;\n case 'Hours':\n duration.hours = value;\n break;\n case 'Days':\n duration.days = value;\n break;\n case 'Weeks':\n duration.weeks = value;\n break;\n case 'Months':\n duration.months = value;\n break;\n case 'Years':\n duration.years = value;\n break;\n default: {\n const exhaustive: never = unitOptions.kind;\n throw new Error(`Unknown time unit type ${exhaustive}`);\n }\n }\n\n // Find the largest whole time unit we can display the value in and use it\n const ms = milliseconds(duration);\n const seconds = ms / 1000;\n if (seconds < 1) {\n return `${ms.toFixed()} milliseconds`;\n }\n\n const minutes = seconds / 60;\n if (minutes < 1) {\n return `${seconds.toFixed()} seconds`;\n }\n\n const hours = minutes / 60;\n if (hours < 1) {\n return `${minutes.toFixed()} minutes`;\n }\n\n const days = hours / 24;\n if (days < 1) {\n return `${hours.toFixed()} hours`;\n }\n\n const weeks = days / 7;\n if (weeks < 1) {\n return `${days.toFixed()} days`;\n }\n\n const years = weeks / 52;\n if (years < 1) {\n return `${weeks.toFixed()} weeks`;\n }\n\n return `${years.toFixed()} years`;\n}\n"],"names":["milliseconds","timeUnitKinds","TIME_GROUP","TIME_GROUP_CONFIG","label","TIME_UNIT_CONFIG","Milliseconds","group","Seconds","Minutes","Hours","Days","Weeks","Months","Years","formatTime","value","unitOptions","duration","kind","seconds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AC,CAAC;IACxC,CAAC;IAED,MAAMR,KAAK,GAAGD,OAAO,GAAG,EAAE,AAAC;IAC3B,IAAIC,KAAK,GAAG,CAAC,EAAE;QACb,OAAO,CAAC,EAAED,OAAO,CAACS,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED,MAAMP,IAAI,GAAGD,KAAK,GAAG,EAAE,AAAC;IACxB,IAAIC,IAAI,GAAG,CAAC,EAAE;QACZ,OAAO,CAAC,EAAED,KAAK,CAACQ,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,MAAMN,KAAK,GAAGD,IAAI,GAAG,CAAC,AAAC;IACvB,IAAIC,KAAK,GAAG,CAAC,EAAE;QACb,OAAO,CAAC,EAAED,IAAI,CAACO,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,MAAMJ,KAAK,GAAGF,KAAK,GAAG,EAAE,AAAC;IACzB,IAAIE,KAAK,GAAG,CAAC,EAAE;QACb,OAAO,CAAC,EAAEF,KAAK,CAACM,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,CAAC,EAAEJ,KAAK,CAACI,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,38 @@
1
+ export declare const UNIT_GROUPS: readonly ["Time", "Percent", "Decimal", "Bytes"];
2
+ export declare type UnitGroup = typeof UNIT_GROUPS[number];
3
+ /**
4
+ * Configuration for rendering units that are part of a group.
5
+ */
6
+ export declare type UnitGroupConfig = {
7
+ /**
8
+ * The label that is shown in the UI.
9
+ */
10
+ label: string;
11
+ /**
12
+ * When true, the unit group supports setting decimal places.
13
+ */
14
+ decimal_places?: boolean;
15
+ /**
16
+ * When true, the unit group supports enabling abbreviate.
17
+ */
18
+ abbreviate?: boolean;
19
+ };
20
+ /**
21
+ * Configuration for rendering a specific unit.
22
+ */
23
+ export declare type UnitConfig = {
24
+ /**
25
+ * The group the unit is part of. This will inform common rendering behavior.
26
+ */
27
+ group: UnitGroup;
28
+ /**
29
+ * When true, this unit will not be displayed in the unit selector. This is
30
+ * useful for units that are shorthand variants of other units.
31
+ */
32
+ disableSelectorOption?: boolean;
33
+ /**
34
+ * The label that is shown in the UI.
35
+ */
36
+ label: string;
37
+ };
38
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/model/units/types.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,WAAW,kDAAmD,CAAC;AAC5E,oBAAY,SAAS,GAAG,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAEnD;;GAEG;AACH,oBAAY,eAAe,GAAG;IAC5B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,oBAAY,UAAU,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IAEjB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
@@ -0,0 +1,22 @@
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
+ // Common types needed across individual unit groups and the overall combined
14
+ // units.
15
+ export const UNIT_GROUPS = [
16
+ 'Time',
17
+ 'Percent',
18
+ 'Decimal',
19
+ 'Bytes'
20
+ ];
21
+
22
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/model/units/types.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\n// Common types needed across individual unit groups and the overall combined\n// units.\n\nexport const UNIT_GROUPS = ['Time', 'Percent', 'Decimal', 'Bytes'] as const;\nexport type UnitGroup = typeof UNIT_GROUPS[number];\n\n/**\n * Configuration for rendering units that are part of a group.\n */\nexport type UnitGroupConfig = {\n /**\n * The label that is shown in the UI.\n */\n label: string;\n /**\n * When true, the unit group supports setting decimal places.\n */\n decimal_places?: boolean;\n /**\n * When true, the unit group supports enabling abbreviate.\n */\n abbreviate?: boolean;\n};\n\n/**\n * Configuration for rendering a specific unit.\n */\nexport type UnitConfig = {\n /**\n * The group the unit is part of. This will inform common rendering behavior.\n */\n group: UnitGroup;\n\n /**\n * When true, this unit will not be displayed in the unit selector. This is\n * useful for units that are shorthand variants of other units.\n */\n disableSelectorOption?: boolean;\n\n /**\n * The label that is shown in the UI.\n */\n label: string;\n};\n"],"names":["UNIT_GROUPS"],"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,6EAA6E;AAC7E,SAAS;AAET,OAAO,MAAMA,WAAW,GAAG;IAAC,MAAM;IAAE,SAAS;IAAE,SAAS;IAAE,OAAO;CAAC,AAAS,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { BytesUnitOptions } from './bytes';
2
+ import { DecimalUnitOptions } from './decimal';
3
+ import { PercentUnitOptions } from './percent';
4
+ import { TimeUnitOptions } from './time';
5
+ import { UnitGroup, UnitGroupConfig, UnitConfig } from './types';
6
+ export declare const UNIT_GROUP_CONFIG: Readonly<Record<UnitGroup, UnitGroupConfig>>;
7
+ export declare const UNIT_CONFIG: {
8
+ readonly Bytes: UnitConfig;
9
+ readonly Decimal: UnitConfig;
10
+ readonly Percent: UnitConfig;
11
+ readonly PercentDecimal: UnitConfig;
12
+ readonly "%": UnitConfig;
13
+ readonly Milliseconds: UnitConfig;
14
+ readonly Seconds: UnitConfig;
15
+ readonly Minutes: UnitConfig;
16
+ readonly Hours: UnitConfig;
17
+ readonly Days: UnitConfig;
18
+ readonly Weeks: UnitConfig;
19
+ readonly Months: UnitConfig;
20
+ readonly Years: UnitConfig;
21
+ };
22
+ export declare type UnitOptions = TimeUnitOptions | PercentUnitOptions | DecimalUnitOptions | BytesUnitOptions;
23
+ declare type HasDecimalPlaces<UnitOpt> = UnitOpt extends {
24
+ decimal_places?: number;
25
+ } ? UnitOpt : never;
26
+ declare type HasAbbreviate<UnitOpt> = UnitOpt extends {
27
+ abbreviate?: boolean;
28
+ } ? UnitOpt : never;
29
+ export declare function formatValue(value: number, unitOptions?: UnitOptions): string;
30
+ export declare function getUnitKindConfig(unitOptions: UnitOptions): UnitConfig;
31
+ export declare function getUnitGroup(unitOptions: UnitOptions): UnitGroup;
32
+ export declare function getUnitGroupConfig(unitOptions: UnitOptions): UnitGroupConfig;
33
+ export declare function isTimeUnit(unitOptions: UnitOptions): unitOptions is TimeUnitOptions;
34
+ export declare function isPercentUnit(unitOptions: UnitOptions): unitOptions is PercentUnitOptions;
35
+ export declare function isDecimalUnit(unitOptions: UnitOptions): unitOptions is DecimalUnitOptions;
36
+ export declare function isBytesUnit(unitOptions: UnitOptions): unitOptions is BytesUnitOptions;
37
+ export declare function isUnitWithDecimalPlaces(unitOptions: UnitOptions): unitOptions is HasDecimalPlaces<UnitOptions>;
38
+ export declare function isUnitWithAbbreviate(unitOptions: UnitOptions): unitOptions is HasAbbreviate<UnitOptions>;
39
+ export {};
40
+ //# sourceMappingURL=units.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../../src/model/units/units.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAsD,MAAM,SAAS,CAAC;AAE/F,OAAO,EAAE,kBAAkB,EAA4D,MAAM,WAAW,CAAC;AACzG,OAAO,EAAuC,kBAAkB,EAAuB,MAAM,WAAW,CAAC;AACzG,OAAO,EAAc,eAAe,EAAuC,MAAM,QAAQ,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEjE,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,CAK1E,CAAC;AACF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;CAKd,CAAC;AAEX,oBAAY,WAAW,GAAG,eAAe,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;AAEvG,aAAK,gBAAgB,CAAC,OAAO,IAAI,OAAO,SAAS;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,GAAG,KAAK,CAAC;AAC/F,aAAK,aAAa,CAAC,OAAO,IAAI,OAAO,SAAS;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,GAAG,KAAK,CAAC;AAEzF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAwB5E;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,WAAW,GAAG,UAAU,CAEtE;AAED,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,SAAS,CAEhE;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,eAAe,CAG5E;AAGD,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,IAAI,eAAe,CAEnF;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,IAAI,kBAAkB,CAEzF;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,IAAI,kBAAkB,CAEzF;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,IAAI,gBAAgB,CAErF;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAI9G;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,IAAI,aAAa,CAAC,WAAW,CAAC,CAIxG"}
@@ -0,0 +1,83 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { BYTES_GROUP_CONFIG, BYTES_UNIT_CONFIG, formatBytes } from './bytes';
14
+ import { DEFAULT_DECIMAL_PLACES } from './constants';
15
+ import { DECIMAL_UNIT_CONFIG, formatDecimal, PERCENT_GROUP_CONFIG } from './decimal';
16
+ import { DECIMAL_GROUP_CONFIG, formatPercent, PERCENT_UNIT_CONFIG } from './percent';
17
+ import { formatTime, TIME_GROUP_CONFIG, TIME_UNIT_CONFIG } from './time';
18
+ export const UNIT_GROUP_CONFIG = {
19
+ Time: TIME_GROUP_CONFIG,
20
+ Percent: PERCENT_GROUP_CONFIG,
21
+ Decimal: DECIMAL_GROUP_CONFIG,
22
+ Bytes: BYTES_GROUP_CONFIG
23
+ };
24
+ export const UNIT_CONFIG = {
25
+ ...TIME_UNIT_CONFIG,
26
+ ...PERCENT_UNIT_CONFIG,
27
+ ...DECIMAL_UNIT_CONFIG,
28
+ ...BYTES_UNIT_CONFIG
29
+ };
30
+ export function formatValue(value, unitOptions) {
31
+ if (unitOptions === undefined) {
32
+ return value.toString();
33
+ }
34
+ if (isDecimalUnit(unitOptions)) {
35
+ return formatDecimal(value, unitOptions);
36
+ }
37
+ if (isTimeUnit(unitOptions)) {
38
+ return formatTime(value, unitOptions);
39
+ }
40
+ if (isPercentUnit(unitOptions)) {
41
+ return formatPercent(value, unitOptions);
42
+ }
43
+ if (isBytesUnit(unitOptions)) {
44
+ var _decimal_places;
45
+ const decimals = (_decimal_places = unitOptions.decimal_places) !== null && _decimal_places !== void 0 ? _decimal_places : DEFAULT_DECIMAL_PLACES;
46
+ return formatBytes(value, decimals);
47
+ }
48
+ const exhaustive = unitOptions;
49
+ throw new Error(`Unknown unit options ${exhaustive}`);
50
+ }
51
+ export function getUnitKindConfig(unitOptions) {
52
+ return UNIT_CONFIG[unitOptions.kind];
53
+ }
54
+ export function getUnitGroup(unitOptions) {
55
+ return getUnitKindConfig(unitOptions).group;
56
+ }
57
+ export function getUnitGroupConfig(unitOptions) {
58
+ const unitConfig = getUnitKindConfig(unitOptions);
59
+ return UNIT_GROUP_CONFIG[unitConfig.group];
60
+ }
61
+ // Type guards
62
+ export function isTimeUnit(unitOptions) {
63
+ return getUnitGroup(unitOptions) === 'Time';
64
+ }
65
+ export function isPercentUnit(unitOptions) {
66
+ return getUnitGroup(unitOptions) === 'Percent';
67
+ }
68
+ export function isDecimalUnit(unitOptions) {
69
+ return getUnitGroup(unitOptions) === 'Decimal';
70
+ }
71
+ export function isBytesUnit(unitOptions) {
72
+ return getUnitGroup(unitOptions) === 'Bytes';
73
+ }
74
+ export function isUnitWithDecimalPlaces(unitOptions) {
75
+ const groupConfig = getUnitGroupConfig(unitOptions);
76
+ return !!groupConfig.decimal_places;
77
+ }
78
+ export function isUnitWithAbbreviate(unitOptions) {
79
+ const groupConfig = getUnitGroupConfig(unitOptions);
80
+ return !!groupConfig.abbreviate;
81
+ }
82
+
83
+ //# sourceMappingURL=units.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/model/units/units.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 { BytesUnitOptions, BYTES_GROUP_CONFIG, BYTES_UNIT_CONFIG, formatBytes } from './bytes';\nimport { DEFAULT_DECIMAL_PLACES } from './constants';\nimport { DecimalUnitOptions, DECIMAL_UNIT_CONFIG, formatDecimal, PERCENT_GROUP_CONFIG } from './decimal';\nimport { DECIMAL_GROUP_CONFIG, formatPercent, PercentUnitOptions, PERCENT_UNIT_CONFIG } from './percent';\nimport { formatTime, TimeUnitOptions, TIME_GROUP_CONFIG, TIME_UNIT_CONFIG } from './time';\nimport { UnitGroup, UnitGroupConfig, UnitConfig } from './types';\n\nexport const UNIT_GROUP_CONFIG: Readonly<Record<UnitGroup, UnitGroupConfig>> = {\n Time: TIME_GROUP_CONFIG,\n Percent: PERCENT_GROUP_CONFIG,\n Decimal: DECIMAL_GROUP_CONFIG,\n Bytes: BYTES_GROUP_CONFIG,\n};\nexport const UNIT_CONFIG = {\n ...TIME_UNIT_CONFIG,\n ...PERCENT_UNIT_CONFIG,\n ...DECIMAL_UNIT_CONFIG,\n ...BYTES_UNIT_CONFIG,\n} as const;\n\nexport type UnitOptions = TimeUnitOptions | PercentUnitOptions | DecimalUnitOptions | BytesUnitOptions;\n\ntype HasDecimalPlaces<UnitOpt> = UnitOpt extends { decimal_places?: number } ? UnitOpt : never;\ntype HasAbbreviate<UnitOpt> = UnitOpt extends { abbreviate?: boolean } ? UnitOpt : never;\n\nexport function formatValue(value: number, unitOptions?: UnitOptions): string {\n if (unitOptions === undefined) {\n return value.toString();\n }\n\n if (isDecimalUnit(unitOptions)) {\n return formatDecimal(value, unitOptions);\n }\n\n if (isTimeUnit(unitOptions)) {\n return formatTime(value, unitOptions);\n }\n\n if (isPercentUnit(unitOptions)) {\n return formatPercent(value, unitOptions);\n }\n\n if (isBytesUnit(unitOptions)) {\n const decimals = unitOptions.decimal_places ?? DEFAULT_DECIMAL_PLACES;\n return formatBytes(value, decimals);\n }\n\n const exhaustive: never = unitOptions;\n throw new Error(`Unknown unit options ${exhaustive}`);\n}\n\nexport function getUnitKindConfig(unitOptions: UnitOptions): UnitConfig {\n return UNIT_CONFIG[unitOptions.kind];\n}\n\nexport function getUnitGroup(unitOptions: UnitOptions): UnitGroup {\n return getUnitKindConfig(unitOptions).group;\n}\n\nexport function getUnitGroupConfig(unitOptions: UnitOptions): UnitGroupConfig {\n const unitConfig = getUnitKindConfig(unitOptions);\n return UNIT_GROUP_CONFIG[unitConfig.group];\n}\n\n// Type guards\nexport function isTimeUnit(unitOptions: UnitOptions): unitOptions is TimeUnitOptions {\n return getUnitGroup(unitOptions) === 'Time';\n}\n\nexport function isPercentUnit(unitOptions: UnitOptions): unitOptions is PercentUnitOptions {\n return getUnitGroup(unitOptions) === 'Percent';\n}\n\nexport function isDecimalUnit(unitOptions: UnitOptions): unitOptions is DecimalUnitOptions {\n return getUnitGroup(unitOptions) === 'Decimal';\n}\n\nexport function isBytesUnit(unitOptions: UnitOptions): unitOptions is BytesUnitOptions {\n return getUnitGroup(unitOptions) === 'Bytes';\n}\n\nexport function isUnitWithDecimalPlaces(unitOptions: UnitOptions): unitOptions is HasDecimalPlaces<UnitOptions> {\n const groupConfig = getUnitGroupConfig(unitOptions);\n\n return !!groupConfig.decimal_places;\n}\n\nexport function isUnitWithAbbreviate(unitOptions: UnitOptions): unitOptions is HasAbbreviate<UnitOptions> {\n const groupConfig = getUnitGroupConfig(unitOptions);\n\n return !!groupConfig.abbreviate;\n}\n"],"names":["BYTES_GROUP_CONFIG","BYTES_UNIT_CONFIG","formatBytes","DEFAULT_DECIMAL_PLACES","DECIMAL_UNIT_CONFIG","formatDecimal","PERCENT_GROUP_CONFIG","DECIMAL_GROUP_CONFIG","formatPercent","PERCENT_UNIT_CONFIG","formatTime","TIME_GROUP_CONFIG","TIME_UNIT_CONFIG","UNIT_GROUP_CONFIG","Time","Percent","Decimal","Bytes","UNIT_CONFIG","formatValue","value","unitOptions","undefined","toString","isDecimalUnit","isTimeUnit","isPercentUnit","isBytesUnit","decimals","decimal_places","exhaustive","Error","getUnitKindConfig","kind","getUnitGroup","group","getUnitGroupConfig","unitConfig","isUnitWithDecimalPlaces","groupConfig","isUnitWithAbbreviate","abbreviate"],"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,SAA2BA,kBAAkB,EAAEC,iBAAiB,EAAEC,WAAW,QAAQ,SAAS,CAAC;AAC/F,SAASC,sBAAsB,QAAQ,aAAa,CAAC;AACrD,SAA6BC,mBAAmB,EAAEC,aAAa,EAAEC,oBAAoB,QAAQ,WAAW,CAAC;AACzG,SAASC,oBAAoB,EAAEC,aAAa,EAAsBC,mBAAmB,QAAQ,WAAW,CAAC;AACzG,SAASC,UAAU,EAAmBC,iBAAiB,EAAEC,gBAAgB,QAAQ,QAAQ,CAAC;AAG1F,OAAO,MAAMC,iBAAiB,GAAiD;IAC7EC,IAAI,EAAEH,iBA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AAED,OAAO,SAASC,YAAY,CAACb,WAAwB,EAAa;IAChE,OAAOW,iBAAiB,CAACX,WAAW,CAAC,CAACc,KAAK,CAAC;AAC9C,CAAC;AAED,OAAO,SAASC,kBAAkB,CAACf,WAAwB,EAAmB;IAC5E,MAAMgB,UAAU,GAAGL,iBAAiB,CAACX,WAAW,CAAC,AAAC;IAClD,OAAOR,iBAAiB,CAACwB,UAAU,CAACF,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED,cAAc;AACd,OAAO,SAASV,UAAU,CAACJ,WAAwB,EAAkC;IACnF,OAAOa,YAAY,CAACb,WAAW,CAAC,KAAK,MAAM,CAAC;AAC9C,CAAC;AAED,OAAO,SAASK,aAAa,CAACL,WAAwB,EAAqC;IACzF,OAAOa,YAAY,CAACb,WAAW,CAAC,KAAK,SAAS,CAAC;AACjD,CAAC;AAED,OAAO,SAASG,aAAa,CAACH,WAAwB,EAAqC;IACzF,OAAOa,YAAY,CAACb,WAAW,CAAC,KAAK,SAAS,CAAC;AACjD,CAAC;AAED,OAAO,SAASM,WAAW,CAACN,WAAwB,EAAmC;IACrF,OAAOa,YAAY,CAACb,WAAW,CAAC,KAAK,OAAO,CAAC;AAC/C,CAAC;AAED,OAAO,SAASiB,uBAAuB,CAACjB,WAAwB,EAAgD;IAC9G,MAAMkB,WAAW,GAAGH,kBAAkB,CAACf,WAAW,CAAC,AAAC;IAEpD,OAAO,CAAC,CAACkB,WAAW,CAACV,cAAc,CAAC;AACtC,CAAC;AAED,OAAO,SAASW,oBAAoB,CAACnB,WAAwB,EAA6C;IACxG,MAAMkB,WAAW,GAAGH,kBAAkB,CAACf,WAAW,CAAC,AAAC;IAEpD,OAAO,CAAC,CAACkB,WAAW,CAACE,UAAU,CAAC;AAClC,CAAC"}
@@ -0,0 +1,8 @@
1
+ declare global {
2
+ var useIdValue: number;
3
+ }
4
+ /**
5
+ * Generates a unique (stable) ID for a component. Should be replaced with React.useId once we support only React 18.
6
+ */
7
+ export declare function useId(prefix: string): string;
8
+ //# sourceMappingURL=component-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-ids.d.ts","sourceRoot":"","sources":["../../src/utils/component-ids.ts"],"names":[],"mappings":"AAeA,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,UAAU,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,UAUnC"}
@@ -0,0 +1,27 @@
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 { useRef } from 'react';
14
+ /**
15
+ * Generates a unique (stable) ID for a component. Should be replaced with React.useId once we support only React 18.
16
+ */ export function useId(prefix) {
17
+ if (globalThis.useIdValue === undefined) {
18
+ globalThis.useIdValue = 0;
19
+ }
20
+ const id = useRef(undefined);
21
+ if (id.current === undefined) {
22
+ id.current = `${prefix}-${globalThis.useIdValue++}`;
23
+ }
24
+ return id.current;
25
+ }
26
+
27
+ //# sourceMappingURL=component-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/component-ids.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 { useRef } from 'react';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var useIdValue: number;\n}\n\n/**\n * Generates a unique (stable) ID for a component. Should be replaced with React.useId once we support only React 18.\n */\nexport function useId(prefix: string) {\n if (globalThis.useIdValue === undefined) {\n globalThis.useIdValue = 0;\n }\n\n const id = useRef<string | undefined>(undefined);\n if (id.current === undefined) {\n id.current = `${prefix}-${globalThis.useIdValue++}`;\n }\n return id.current;\n}\n"],"names":["useRef","useId","prefix","globalThis","useIdValue","undefined","id","current"],"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,MAAM,QAAQ,OAAO,CAAC;AAO/B;;CAEC,GACD,OAAO,SAASC,KAAK,CAACC,MAAc,EAAE;IACpC,IAAIC,UAAU,CAACC,UAAU,KAAKC,SAAS,EAAE;QACvCF,UAAU,CAACC,UAAU,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,MAAME,EAAE,GAAGN,MAAM,CAAqBK,SAAS,CAAC,AAAC;IACjD,IAAIC,EAAE,CAACC,OAAO,KAAKF,SAAS,EAAE;QAC5BC,EAAE,CAACC,OAAO,GAAG,CAAC,EAAEL,MAAM,CAAC,CAAC,EAAEC,UAAU,CAACC,UAAU,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC;IACD,OAAOE,EAAE,CAACC,OAAO,CAAC;AACpB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './combine-sx';
2
2
  export * from './theme-gen';
3
+ export * from './component-ids';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
@@ -12,5 +12,6 @@
12
12
  // limitations under the License.
13
13
  export * from './combine-sx';
14
14
  export * from './theme-gen';
15
+ export * from './component-ids';
15
16
 
16
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/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 './combine-sx';\nexport * from './theme-gen';\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,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/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 './combine-sx';\nexport * from './theme-gen';\nexport * from './component-ids';\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,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/components",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "Common UI components used across Perses features",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@mui/x-date-pickers": "^5.0.0-beta.1",
36
- "@perses-dev/core": "^0.14.0",
36
+ "@perses-dev/core": "^0.16.0",
37
37
  "date-fns": "^2.28.0",
38
38
  "echarts": "^5.3.3",
39
39
  "lodash-es": "^4.17.21",
@@ -1 +0,0 @@
1
- {"version":3,"file":"AbsoluteTimePicker.d.ts","sourceRoot":"","sources":["../../src/TimeRangeSelector/AbsoluteTimePicker.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAKrD,UAAU,qBAAqB;IAC7B,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,QAAQ,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,kBAAkB,mCAAoC,qBAAqB,gBAmIvF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/TimeRangeSelector/AbsoluteTimePicker.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { Box, Stack, TextField, Divider } from '@mui/material';\nimport { LocalizationProvider, StaticDateTimePicker } from '@mui/x-date-pickers';\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';\nimport { format } from 'date-fns';\nimport { AbsoluteTimeRange } from '@perses-dev/core';\nimport { validateDateRange } from './utils';\n\nconst DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';\n\ninterface AbsoluteTimeFormProps {\n initialTimeRange: AbsoluteTimeRange;\n onChange: (timeRange: AbsoluteTimeRange) => void;\n}\n\nexport const AbsoluteTimePicker = ({ initialTimeRange, onChange }: AbsoluteTimeFormProps) => {\n const [timeRange, setTimeRange] = useState<AbsoluteTimeRange>(initialTimeRange);\n const [showStartCalendar, setShowStartCalendar] = useState<boolean>(true);\n\n // validate start and end time, propagate changes\n const updateDateRange = (input: string, isStartDate: boolean) => {\n const newDate = new Date(input);\n if (isStartDate === true) {\n const isValidDateRange = validateDateRange(newDate, timeRange.end);\n if (isValidDateRange === true) {\n setTimeRange((current) => {\n const updatedRange = { start: newDate, end: current.end };\n onChange(updatedRange);\n return updatedRange;\n });\n }\n } else {\n const isValidDateRange = validateDateRange(timeRange.start, newDate);\n if (isValidDateRange === true) {\n setTimeRange((current) => {\n const updatedRange = { start: current.start, end: newDate };\n onChange(updatedRange);\n return updatedRange;\n });\n }\n }\n };\n\n return (\n <LocalizationProvider dateAdapter={AdapterDateFns}>\n <Stack spacing={3} sx={{ padding: (theme) => theme.spacing(1, 2, 3) }}>\n {showStartCalendar && (\n <Box\n sx={(theme) => ({\n // TODO: create separate reusable calendar component\n '.MuiPickerStaticWrapper-content': {\n backgroundColor: theme.palette.background.default,\n },\n // reposition AM and PM buttons\n '.MuiIconButton-sizeMedium': {\n top: 80,\n bottom: 'auto',\n margin: theme.spacing(0, 3),\n },\n })}\n >\n <h3>Select Start Time</h3>\n <StaticDateTimePicker\n displayStaticWrapperAs=\"desktop\"\n openTo=\"day\"\n disableHighlightToday={true}\n value={initialTimeRange.start}\n onChange={(newValue) => {\n if (newValue === null) return;\n setTimeRange((current) => {\n return { start: newValue, end: current.end };\n });\n }}\n onAccept={() => {\n setShowStartCalendar(false);\n }}\n renderInput={(params) => <TextField {...params} />}\n />\n </Box>\n )}\n {!showStartCalendar && (\n <Box\n sx={(theme) => ({\n '.MuiPickerStaticWrapper-content': {\n backgroundColor: theme.palette.background.default,\n },\n // reposition AM and PM buttons\n '.MuiIconButton-sizeMedium': {\n top: 80,\n bottom: 'auto',\n margin: theme.spacing(0, 3),\n },\n })}\n >\n <h3>Select End Time</h3>\n <StaticDateTimePicker\n displayStaticWrapperAs=\"desktop\"\n openTo=\"day\"\n disableHighlightToday={true}\n value={initialTimeRange.end}\n minDateTime={timeRange.start}\n onChange={(newValue) => {\n if (newValue === null) return;\n setTimeRange((current) => {\n return { start: current.start, end: newValue };\n });\n }}\n onAccept={() => {\n setShowStartCalendar(true);\n onChange(timeRange);\n }}\n renderInput={(params) => <TextField {...params} />}\n />\n </Box>\n )}\n <TextField\n fullWidth\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n // TODO: add helperText, fix validation after we decide on form state solution\n updateDateRange(event.target.value, true);\n }}\n value={format(timeRange.start, DATE_TIME_FORMAT)}\n label=\"Start Time\"\n placeholder=\"mm/dd/yyyy hh:mm\"\n // tel used to match MUI DateTimePicker, may change in future: https://github.com/mui/material-ui/issues/27590\n type=\"tel\"\n />\n <Divider\n sx={(theme) => ({\n margin: theme.spacing(2, 0),\n borderColor: theme.palette.grey['500'],\n })}\n />\n <TextField\n fullWidth\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n updateDateRange(event.target.value, false);\n }}\n value={format(timeRange.end, DATE_TIME_FORMAT)}\n label=\"End Time\"\n placeholder=\"mm/dd/yyyy hh:mm\"\n type=\"tel\"\n />\n </Stack>\n </LocalizationProvider>\n );\n};\n"],"names":["useState","Box","Stack","TextField","Divider","LocalizationProvider","StaticDateTimePicker","AdapterDateFns","format","validateDateRange","DATE_TIME_FORMAT","AbsoluteTimePicker","initialTimeRange","onChange","timeRange","setTimeRange","showStartCalendar","setShowStartCalendar","updateDateRange","input","isStartDate","newDate","Date","isValidDateRange","end","current","updatedRange","start","dateAdapter","spacing","sx","padding","theme","backgroundColor","palette","background","default","top","bottom","margin","h3","displayStaticWrapperAs","openTo","disableHighlightToday","value","newValue","onAccept","renderInput","params","minDateTime","fullWidth","event","target","label","placeholder","type","borderColor","grey"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,GAAG,EAAEC,KAAK,EAAEC,SAAS,EAAEC,OAAO,QAAQ,eAAe,CAAC;AAC/D,SAASC,oBAAoB,EAAEC,oBAAoB,QAAQ,qBAAqB,CAAC;AACjF,SAASC,cAAc,QAAQ,oCAAoC,CAAC;AACpE,SAASC,MAAM,QAAQ,UAAU,CAAC;AAElC,SAASC,iBAAiB,QAAQ,SAAS,CAAC;AAE5C,MAAMC,gBAAgB,GAAG,qBAAqB,AAAC;AAO/C,OAAO,MAAMC,kBAAkB,GAAG,CAAC,EAAEC,gBAAgB,CAAA,EAAEC,QAAQ,CAAA,EAAyB,GAAK;IAC3F,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGf,QAAQ,CAAoBY,gBAAgB,CAAC,AAAC;IAChF,MAAM,CAACI,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGjB,QAAQ,CAAU,IAAI,CAAC,AAAC;IAE1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AAE,EAAE,CAACE,KAAK,GAAM,CAAA;4BACdO,MAAM,EAAEP,KAAK,CAACH,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;4BAC3B2B,WAAW,EAAExB,KAAK,CAACE,OAAO,CAACuB,IAAI,CAAC,KAAK,CAAC;yBACvC,CAAA,AAAC;kBACF;8BACF,KAACtD,SAAS;oBACR+C,SAAS;oBACTrC,QAAQ,EAAE,CAACsC,KAA0C,GAAK;wBACxDjC,eAAe,CAACiC,KAAK,CAACC,MAAM,CAACR,KAAK,EAAE,KAAK,CAAC,CAAC;oBAC7C,CAAC;oBACDA,KAAK,EAAEpC,MAAM,CAACM,SAAS,CAACU,GAAG,EAAEd,gBAAgB,CAAC;oBAC9C2C,KAAK,EAAC,UAAU;oBAChBC,WAAW,EAAC,kBAAkB;oBAC9BC,IAAI,EAAC,KAAK;kBACV;;UACI;MACa,CACvB;AACJ,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"TimeRangeSelector.d.ts","sourceRoot":"","sources":["../../src/TimeRangeSelector/TimeRangeSelector.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAoB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAuB,MAAM,kBAAkB,CAAC;AAK1F,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,iBAAiB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,cAAc,CAAC;IACtB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,cAAc,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IAC3D,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eA0C9D"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/TimeRangeSelector/TimeRangeSelector.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MenuItem, Select, SelectChangeEvent } from '@mui/material';\nimport Calendar from 'mdi-material-ui/Calendar';\nimport { TimeRangeValue, RelativeTimeRange, isRelativeTimeRange } from '@perses-dev/core';\nimport { formatAbsoluteRange } from './utils';\n\nconst DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';\n\nexport interface TimeOption {\n value: RelativeTimeRange;\n display: string;\n}\n\ninterface TimeRangeSelectorProps {\n value: TimeRangeValue;\n timeOptions: TimeOption[];\n onSelectChange: (event: SelectChangeEvent<string>) => void;\n onCustomClick: () => void;\n}\n\nexport function TimeRangeSelector(props: TimeRangeSelectorProps) {\n const { value, timeOptions, onSelectChange, onCustomClick } = props;\n const formattedValue = !isRelativeTimeRange(value)\n ? formatAbsoluteRange(value, DATE_TIME_FORMAT)\n : value.pastDuration;\n return (\n <Select\n value={formattedValue}\n onChange={onSelectChange}\n IconComponent={Calendar}\n sx={{\n '.MuiSelect-icon': {\n marginTop: '1px',\n },\n }}\n >\n {timeOptions.map((item, idx) => (\n <MenuItem key={idx} value={item.value.pastDuration}>\n {item.display}\n </MenuItem>\n ))}\n\n {isRelativeTimeRange(value) ? (\n <MenuItem\n onClick={() => {\n onCustomClick();\n }}\n >\n Custom time range\n </MenuItem>\n ) : (\n <MenuItem\n value={formattedValue}\n onClick={() => {\n onCustomClick();\n }}\n >\n {formattedValue}\n </MenuItem>\n )}\n </Select>\n );\n}\n"],"names":["MenuItem","Select","Calendar","isRelativeTimeRange","formatAbsoluteRange","DATE_TIME_FORMAT","TimeRangeSelector","props","value","timeOptions","onSelectChange","onCustomClick","formattedValue","pastDuration","onChange","IconComponent","sx","marginTop","map","item","idx","display","onClick"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,EAAEC,MAAM,QAA2B,eAAe,CAAC;AACpE,OAAOC,QAAQ,MAAM,0BAA0B,CAAC;AAChD,SAA4CC,mBAAmB,QAAQ,kBAAkB,CAAC;AAC1F,SAASC,mBAAmB,QAAQ,SAAS,CAAC;AAE9C,MAAMC,gBAAgB,GAAG,qBAAqB,AAAC;AAc/C,OAAO,SAASC,iBAAiB,CAACC,KAA6B,EAAE;IAC/D,MAAM,EAAEC,KAAK,CAAA,EAAEC,WAAW,CAAA,EAAEC,cAAc,CAAA,EAAEC,aAAa,CAAA,EAAE,GAAGJ,KAAK,AAAC;IACpE,MAAMK,cAAc,GAAG,CAACT,mBAAmB,CAACK,KAAK,CAAC,GAC9CJ,mBAAmB,CAACI,KAAK,EAAEH,gBAAgB,CAAC,GAC5CG,KAAK,CAACK,YAAY,AAAC;IACvB,qBACE,MAACZ,MAAM;QACLO,KAAK,EAAEI,cAAc;QACrBE,QAAQ,EAAEJ,cAAc;QACxBK,aAAa,EAAEb,QAAQ;QACvBc,EAAE,EAAE;YACF,iBAAiB,EAAE;gBACjBC,SAAS,EAAE,KAAK;aACjB;SACF;;YAEAR,WAAW,CAACS,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,iBACzB,KAACpB,QAAQ;oBAAWQ,KAAK,EAAEW,IAAI,CAACX,KAAK,CAACK,YAAY;8BAC/CM,IAAI,CAACE,OAAO;mBADAD,GAAG,CAEP,AACZ,CAAC;YAEDjB,mBAAmB,CAACK,KAAK,CAAC,iBACzB,KAACR,QA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