@perses-dev/components 0.53.1 → 0.54.0-beta.1

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 (232) hide show
  1. package/dist/ContentWithLegend/ContentWithLegend.js +1 -1
  2. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  3. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +1 -1
  4. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
  5. package/dist/ContentWithLegend/model/content-with-legend-model.js +1 -1
  6. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
  7. package/dist/FormEditor/FormActions.d.ts +1 -1
  8. package/dist/FormEditor/FormActions.d.ts.map +1 -1
  9. package/dist/FormEditor/FormActions.js.map +1 -1
  10. package/dist/FormatControls/FormatControls.d.ts +1 -1
  11. package/dist/FormatControls/FormatControls.d.ts.map +1 -1
  12. package/dist/FormatControls/FormatControls.js +1 -1
  13. package/dist/FormatControls/FormatControls.js.map +1 -1
  14. package/dist/FormatControls/UnitSelector.d.ts +1 -1
  15. package/dist/FormatControls/UnitSelector.d.ts.map +1 -1
  16. package/dist/FormatControls/UnitSelector.js +1 -1
  17. package/dist/FormatControls/UnitSelector.js.map +1 -1
  18. package/dist/Legend/Legend.js +1 -1
  19. package/dist/Legend/Legend.js.map +1 -1
  20. package/dist/Legend/legend-model.d.ts +1 -1
  21. package/dist/Legend/legend-model.d.ts.map +1 -1
  22. package/dist/Legend/legend-model.js.map +1 -1
  23. package/dist/LinksEditor/LinksEditor.d.ts +1 -1
  24. package/dist/LinksEditor/LinksEditor.js.map +1 -1
  25. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts +1 -1
  26. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  27. package/dist/Table/Table.d.ts +1 -1
  28. package/dist/Table/Table.d.ts.map +1 -1
  29. package/dist/Table/Table.js +26 -6
  30. package/dist/Table/Table.js.map +1 -1
  31. package/dist/Table/TableToolbar.d.ts +34 -0
  32. package/dist/Table/TableToolbar.d.ts.map +1 -0
  33. package/dist/Table/TableToolbar.js +127 -0
  34. package/dist/Table/TableToolbar.js.map +1 -0
  35. package/dist/Table/VirtualizedTable.d.ts +3 -1
  36. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  37. package/dist/Table/VirtualizedTable.js +128 -117
  38. package/dist/Table/VirtualizedTable.js.map +1 -1
  39. package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -1
  40. package/dist/Table/VirtualizedTableContainer.js +5 -1
  41. package/dist/Table/VirtualizedTableContainer.js.map +1 -1
  42. package/dist/Table/hooks/useFuzzySearch.d.ts +12 -0
  43. package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -0
  44. package/dist/Table/hooks/useFuzzySearch.js +43 -0
  45. package/dist/Table/hooks/useFuzzySearch.js.map +1 -0
  46. package/dist/Table/model/table-model.d.ts +38 -4
  47. package/dist/Table/model/table-model.d.ts.map +1 -1
  48. package/dist/Table/model/table-model.js.map +1 -1
  49. package/dist/ThresholdsEditor/ThresholdInput.d.ts +1 -1
  50. package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -1
  51. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  52. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts +1 -1
  53. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
  54. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  55. package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts +2 -3
  56. package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts.map +1 -1
  57. package/dist/TimeRangeSelector/DateTimeRangePicker.js +2 -0
  58. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  59. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +1 -1
  60. package/dist/TimeRangeSelector/TimeRangeSelector.js +1 -1
  61. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  62. package/dist/TimeRangeSelector/utils.d.ts +1 -1
  63. package/dist/TimeRangeSelector/utils.js +1 -1
  64. package/dist/TimeRangeSelector/utils.js.map +1 -1
  65. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +2 -2
  66. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  67. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  68. package/dist/TimeSeriesTooltip/nearby-series.d.ts +2 -2
  69. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  70. package/dist/TimeSeriesTooltip/nearby-series.js +1 -2
  71. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  72. package/dist/TransformsEditor/TransformEditor.d.ts +1 -1
  73. package/dist/TransformsEditor/TransformEditor.d.ts.map +1 -1
  74. package/dist/TransformsEditor/TransformEditor.js.map +1 -1
  75. package/dist/TransformsEditor/TransformEditorContainer.d.ts.map +1 -1
  76. package/dist/TransformsEditor/TransformEditorContainer.js +1 -1
  77. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  78. package/dist/TransformsEditor/TransformsEditor.d.ts +1 -1
  79. package/dist/TransformsEditor/TransformsEditor.d.ts.map +1 -1
  80. package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
  81. package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
  82. package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -1
  83. package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
  84. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +2 -2
  85. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +2 -2
  86. package/dist/cjs/FormatControls/FormatControls.js +4 -4
  87. package/dist/cjs/FormatControls/UnitSelector.js +3 -3
  88. package/dist/cjs/Legend/Legend.js +2 -2
  89. package/dist/cjs/Table/Table.js +24 -4
  90. package/dist/cjs/Table/TableToolbar.js +140 -0
  91. package/dist/cjs/Table/VirtualizedTable.js +126 -115
  92. package/dist/cjs/Table/VirtualizedTableContainer.js +5 -1
  93. package/dist/cjs/Table/hooks/useFuzzySearch.js +48 -0
  94. package/dist/cjs/TimeRangeSelector/DateTimeRangePicker.js +2 -0
  95. package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +3 -3
  96. package/dist/cjs/TimeRangeSelector/utils.js +2 -2
  97. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +2 -3
  98. package/dist/cjs/TransformsEditor/TransformEditorContainer.js +2 -2
  99. package/dist/cjs/model/action.js +43 -0
  100. package/dist/cjs/model/bits.js +113 -0
  101. package/dist/cjs/model/bytes.js +115 -0
  102. package/dist/cjs/model/constants.js +23 -0
  103. package/dist/cjs/model/currency.js +126 -0
  104. package/dist/cjs/model/date.js +297 -0
  105. package/dist/cjs/model/decimal.js +72 -0
  106. package/dist/cjs/model/formatterCache.js +120 -0
  107. package/dist/cjs/model/index.js +16 -0
  108. package/dist/cjs/model/legend.js +101 -0
  109. package/dist/cjs/model/percent.js +82 -0
  110. package/dist/cjs/model/temperature.js +72 -0
  111. package/dist/cjs/model/thresholds.js +16 -0
  112. package/dist/cjs/model/throughput.js +161 -0
  113. package/dist/cjs/model/time.js +178 -0
  114. package/dist/cjs/model/timeOption.js +2 -2
  115. package/dist/cjs/model/transforms.js +29 -0
  116. package/dist/cjs/model/types.js +16 -0
  117. package/dist/cjs/model/units.js +186 -0
  118. package/dist/cjs/model/utils.js +48 -0
  119. package/dist/cjs/theme/theme.js +44 -29
  120. package/dist/cjs/theme/typography.js +8 -7
  121. package/dist/cjs/utils/axis.js +5 -5
  122. package/dist/cjs/utils/index.js +1 -0
  123. package/dist/cjs/utils/request-interpolation.js +49 -0
  124. package/dist/model/action.d.ts +4 -0
  125. package/dist/model/action.d.ts.map +1 -0
  126. package/dist/model/action.js +27 -0
  127. package/dist/model/action.js.map +1 -0
  128. package/dist/model/bits.d.ts +12 -0
  129. package/dist/model/bits.d.ts.map +1 -0
  130. package/dist/model/bits.js +89 -0
  131. package/dist/model/bits.js.map +1 -0
  132. package/dist/model/bytes.d.ts +12 -0
  133. package/dist/model/bytes.d.ts.map +1 -0
  134. package/dist/model/bytes.js +91 -0
  135. package/dist/model/bytes.js.map +1 -0
  136. package/dist/model/constants.d.ts +2 -0
  137. package/dist/model/constants.d.ts.map +1 -0
  138. package/dist/model/constants.js +15 -0
  139. package/dist/model/constants.js.map +1 -0
  140. package/dist/model/currency.d.ts +11 -0
  141. package/dist/model/currency.d.ts.map +1 -0
  142. package/dist/model/currency.js +107 -0
  143. package/dist/model/currency.js.map +1 -0
  144. package/dist/model/date.d.ts +28 -0
  145. package/dist/model/date.d.ts.map +1 -0
  146. package/dist/model/date.js +278 -0
  147. package/dist/model/date.js.map +1 -0
  148. package/dist/model/decimal.d.ts +12 -0
  149. package/dist/model/decimal.d.ts.map +1 -0
  150. package/dist/model/decimal.js +53 -0
  151. package/dist/model/decimal.js.map +1 -0
  152. package/dist/model/formatterCache.d.ts +11 -0
  153. package/dist/model/formatterCache.d.ts.map +1 -0
  154. package/dist/model/formatterCache.js +104 -0
  155. package/dist/model/formatterCache.js.map +1 -0
  156. package/dist/model/graph.d.ts +1 -1
  157. package/dist/model/graph.js.map +1 -1
  158. package/dist/model/index.d.ts +16 -0
  159. package/dist/model/index.d.ts.map +1 -1
  160. package/dist/model/index.js +16 -0
  161. package/dist/model/index.js.map +1 -1
  162. package/dist/model/legend.d.ts +19 -0
  163. package/dist/model/legend.d.ts.map +1 -0
  164. package/dist/model/legend.js +61 -0
  165. package/dist/model/legend.js.map +1 -0
  166. package/dist/model/percent.d.ts +11 -0
  167. package/dist/model/percent.d.ts.map +1 -0
  168. package/dist/model/percent.js +63 -0
  169. package/dist/model/percent.js.map +1 -0
  170. package/dist/model/temperature.d.ts +11 -0
  171. package/dist/model/temperature.d.ts.map +1 -0
  172. package/dist/model/temperature.js +53 -0
  173. package/dist/model/temperature.js.map +1 -0
  174. package/dist/model/theme.d.ts +1 -1
  175. package/dist/model/theme.d.ts.map +1 -1
  176. package/dist/model/theme.js.map +1 -1
  177. package/dist/model/thresholds.d.ts +16 -0
  178. package/dist/model/thresholds.d.ts.map +1 -0
  179. package/dist/model/thresholds.js +15 -0
  180. package/dist/model/thresholds.js.map +1 -0
  181. package/dist/model/throughput.d.ts +12 -0
  182. package/dist/model/throughput.d.ts.map +1 -0
  183. package/dist/model/throughput.js +142 -0
  184. package/dist/model/throughput.js.map +1 -0
  185. package/dist/model/time.d.ts +23 -0
  186. package/dist/model/time.d.ts.map +1 -0
  187. package/dist/model/time.js +158 -0
  188. package/dist/model/time.js.map +1 -0
  189. package/dist/model/timeOption.d.ts +1 -1
  190. package/dist/model/timeOption.js +1 -1
  191. package/dist/model/timeOption.js.map +1 -1
  192. package/dist/model/transforms.d.ts +43 -0
  193. package/dist/model/transforms.d.ts.map +1 -0
  194. package/dist/model/transforms.js +22 -0
  195. package/dist/model/transforms.js.map +1 -0
  196. package/dist/model/types.d.ts +56 -0
  197. package/dist/model/types.d.ts.map +1 -0
  198. package/dist/model/types.js +15 -0
  199. package/dist/model/types.js.map +1 -0
  200. package/dist/model/units.d.ts +105 -0
  201. package/dist/model/units.d.ts.map +1 -0
  202. package/dist/model/units.js +132 -0
  203. package/dist/model/units.js.map +1 -0
  204. package/dist/model/utils.d.ts +4 -0
  205. package/dist/model/utils.d.ts.map +1 -0
  206. package/dist/model/utils.js +32 -0
  207. package/dist/model/utils.js.map +1 -0
  208. package/dist/theme/theme.d.ts +3 -1
  209. package/dist/theme/theme.d.ts.map +1 -1
  210. package/dist/theme/theme.js +46 -29
  211. package/dist/theme/theme.js.map +1 -1
  212. package/dist/theme/typography.d.ts +6 -4
  213. package/dist/theme/typography.d.ts.map +1 -1
  214. package/dist/theme/typography.js +8 -7
  215. package/dist/theme/typography.js.map +1 -1
  216. package/dist/utils/axis.d.ts +1 -1
  217. package/dist/utils/axis.d.ts.map +1 -1
  218. package/dist/utils/axis.js +1 -1
  219. package/dist/utils/axis.js.map +1 -1
  220. package/dist/utils/chart-actions.d.ts +1 -1
  221. package/dist/utils/chart-actions.js.map +1 -1
  222. package/dist/utils/index.d.ts +1 -0
  223. package/dist/utils/index.d.ts.map +1 -1
  224. package/dist/utils/index.js +1 -0
  225. package/dist/utils/index.js.map +1 -1
  226. package/dist/utils/request-interpolation.d.ts +6 -0
  227. package/dist/utils/request-interpolation.d.ts.map +1 -0
  228. package/dist/utils/request-interpolation.js +33 -0
  229. package/dist/utils/request-interpolation.js.map +1 -0
  230. package/dist/utils/variable-interpolation.d.ts +1 -1
  231. package/dist/utils/variable-interpolation.js.map +1 -1
  232. package/package.json +6 -2
@@ -0,0 +1,178 @@
1
+ // Copyright 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
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get PersesTimeToIntlTime () {
25
+ return PersesTimeToIntlTime;
26
+ },
27
+ get TIME_GROUP_CONFIG () {
28
+ return TIME_GROUP_CONFIG;
29
+ },
30
+ get TIME_UNIT_CONFIG () {
31
+ return TIME_UNIT_CONFIG;
32
+ },
33
+ get formatTime () {
34
+ return formatTime;
35
+ }
36
+ });
37
+ const _constants = require("./constants");
38
+ const _formatterCache = require("./formatterCache");
39
+ const _utils = require("./utils");
40
+ const TIME_GROUP = 'Time';
41
+ const TIME_GROUP_CONFIG = {
42
+ label: 'Time',
43
+ decimalPlaces: true
44
+ };
45
+ const TIME_UNIT_CONFIG = {
46
+ nanoseconds: {
47
+ group: TIME_GROUP,
48
+ label: 'Nanoseconds'
49
+ },
50
+ microseconds: {
51
+ group: TIME_GROUP,
52
+ label: 'Microseconds'
53
+ },
54
+ milliseconds: {
55
+ group: TIME_GROUP,
56
+ label: 'Milliseconds'
57
+ },
58
+ seconds: {
59
+ group: TIME_GROUP,
60
+ label: 'Seconds'
61
+ },
62
+ minutes: {
63
+ group: TIME_GROUP,
64
+ label: 'Minutes'
65
+ },
66
+ hours: {
67
+ group: TIME_GROUP,
68
+ label: 'Hours'
69
+ },
70
+ days: {
71
+ group: TIME_GROUP,
72
+ label: 'Days'
73
+ },
74
+ weeks: {
75
+ group: TIME_GROUP,
76
+ label: 'Weeks'
77
+ },
78
+ months: {
79
+ group: TIME_GROUP,
80
+ label: 'Months'
81
+ },
82
+ years: {
83
+ group: TIME_GROUP,
84
+ label: 'Years'
85
+ }
86
+ };
87
+ var PersesTimeToIntlTime = /*#__PURE__*/ function(PersesTimeToIntlTime) {
88
+ PersesTimeToIntlTime["nanoseconds"] = "nanosecond";
89
+ PersesTimeToIntlTime["microseconds"] = "microsecond";
90
+ PersesTimeToIntlTime["milliseconds"] = "millisecond";
91
+ PersesTimeToIntlTime["seconds"] = "second";
92
+ PersesTimeToIntlTime["minutes"] = "minute";
93
+ PersesTimeToIntlTime["hours"] = "hour";
94
+ PersesTimeToIntlTime["days"] = "day";
95
+ PersesTimeToIntlTime["weeks"] = "week";
96
+ PersesTimeToIntlTime["months"] = "month";
97
+ PersesTimeToIntlTime["years"] = "year";
98
+ return PersesTimeToIntlTime;
99
+ }({});
100
+ /**
101
+ * Note: This conversion will not be exactly accurate for months and years,
102
+ * due variations in the lengths of months (i.e. 28 - 31 days) and years (i.e. leap years).
103
+ * For precision with months and years, we would need more complex algorithms and/or external libraries.
104
+ * However, we expect that measurements in months and years will be rare.
105
+ */ const TIME_UNITS_IN_SECONDS = {
106
+ years: 31536000,
107
+ months: 2592000,
108
+ weeks: 604800,
109
+ days: 86400,
110
+ hours: 3600,
111
+ minutes: 60,
112
+ seconds: 1,
113
+ milliseconds: 0.001,
114
+ microseconds: 0.000001,
115
+ nanoseconds: 0.000000001
116
+ };
117
+ const LARGEST_TO_SMALLEST_TIME_UNITS = [
118
+ 'years',
119
+ 'months',
120
+ 'weeks',
121
+ 'days',
122
+ 'hours',
123
+ 'minutes',
124
+ 'seconds',
125
+ 'milliseconds',
126
+ 'microseconds',
127
+ 'nanoseconds'
128
+ ];
129
+ /**
130
+ * Choose the first time unit that produces a number greater than 1, starting from the biggest time unit.
131
+ */ function getValueAndKindForNaturalNumbers(value, unit) {
132
+ const valueInSeconds = value * TIME_UNITS_IN_SECONDS[unit];
133
+ // Initialize for TS
134
+ const largestTimeUnit = LARGEST_TO_SMALLEST_TIME_UNITS[0] || 'years';
135
+ let timeUnit = largestTimeUnit;
136
+ let valueInTimeUnit = valueInSeconds / TIME_UNITS_IN_SECONDS[largestTimeUnit];
137
+ for (timeUnit of LARGEST_TO_SMALLEST_TIME_UNITS){
138
+ valueInTimeUnit = valueInSeconds / TIME_UNITS_IN_SECONDS[timeUnit];
139
+ if (valueInTimeUnit >= 1) {
140
+ return {
141
+ value: valueInTimeUnit,
142
+ unit: timeUnit
143
+ };
144
+ }
145
+ }
146
+ // If we didn't find a time unit, we have to settle for the smallest time unit (which is the last time unit).
147
+ return {
148
+ value: valueInTimeUnit,
149
+ unit: timeUnit
150
+ };
151
+ }
152
+ function isMonthOrYear(unit) {
153
+ return unit === 'months' || unit === 'years';
154
+ }
155
+ function formatTime(value, { unit, decimalPlaces }) {
156
+ if (value === 0) return '0s';
157
+ const results = getValueAndKindForNaturalNumbers(value, unit ?? 'seconds');
158
+ const formatterOptions = {
159
+ style: 'unit',
160
+ unit: PersesTimeToIntlTime[results.unit],
161
+ unitDisplay: isMonthOrYear(results.unit) ? 'long' : 'narrow'
162
+ };
163
+ if ((0, _utils.hasDecimalPlaces)(decimalPlaces)) {
164
+ formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
165
+ formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
166
+ } else {
167
+ formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
168
+ }
169
+ const key = [
170
+ formatterOptions.style,
171
+ formatterOptions.unit,
172
+ formatterOptions.unitDisplay,
173
+ formatterOptions.maximumSignificantDigits,
174
+ decimalPlaces,
175
+ unit ?? 'seconds'
176
+ ];
177
+ return (0, _formatterCache.getFormatterFromCache)(key, 'time', formatterOptions, 'en-US')(results.value);
178
+ }
@@ -20,14 +20,14 @@ Object.defineProperty(exports, "buildRelativeTimeOption", {
20
20
  return buildRelativeTimeOption;
21
21
  }
22
22
  });
23
- const _core = require("@perses-dev/core");
23
+ const _spec = require("@perses-dev/spec");
24
24
  const _datefns = require("date-fns");
25
25
  function buildRelativeTimeOption(duration) {
26
26
  return {
27
27
  value: {
28
28
  pastDuration: duration
29
29
  },
30
- display: `Last ${(0, _datefns.formatDuration)((0, _core.parseDurationString)(duration), {
30
+ display: `Last ${(0, _datefns.formatDuration)((0, _spec.parseDurationString)(duration), {
31
31
  delimiter: ', '
32
32
  })}`
33
33
  };
@@ -0,0 +1,29 @@
1
+ // Copyright 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, "TRANSFORM_TEXT", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return TRANSFORM_TEXT;
21
+ }
22
+ });
23
+ const TRANSFORM_TEXT = {
24
+ JoinByColumnValue: 'Join by column value',
25
+ MergeColumns: 'Merge columns',
26
+ MergeIndexedColumns: 'Merge indexed columns',
27
+ MergeSeries: 'Merge series',
28
+ ExtractColumnFields: 'Extract column fields'
29
+ };
@@ -0,0 +1,16 @@
1
+ // Copyright 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
+ });
@@ -0,0 +1,186 @@
1
+ // Copyright 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
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get UNIT_CONFIG () {
25
+ return UNIT_CONFIG;
26
+ },
27
+ get UNIT_GROUP_CONFIG () {
28
+ return UNIT_GROUP_CONFIG;
29
+ },
30
+ get formatValue () {
31
+ return formatValue;
32
+ },
33
+ get getUnitConfig () {
34
+ return getUnitConfig;
35
+ },
36
+ get getUnitGroup () {
37
+ return getUnitGroup;
38
+ },
39
+ get getUnitGroupConfig () {
40
+ return getUnitGroupConfig;
41
+ },
42
+ get isBitsUnit () {
43
+ return isBitsUnit;
44
+ },
45
+ get isBytesUnit () {
46
+ return isBytesUnit;
47
+ },
48
+ get isCurrencyUnit () {
49
+ return isCurrencyUnit;
50
+ },
51
+ get isDateUnit () {
52
+ return isDateUnit;
53
+ },
54
+ get isDecimalUnit () {
55
+ return isDecimalUnit;
56
+ },
57
+ get isPercentUnit () {
58
+ return isPercentUnit;
59
+ },
60
+ get isTemperatureUnit () {
61
+ return isTemperatureUnit;
62
+ },
63
+ get isThroughputUnit () {
64
+ return isThroughputUnit;
65
+ },
66
+ get isTimeUnit () {
67
+ return isTimeUnit;
68
+ },
69
+ get isUnitWithDecimalPlaces () {
70
+ return isUnitWithDecimalPlaces;
71
+ },
72
+ get isUnitWithShortValues () {
73
+ return isUnitWithShortValues;
74
+ }
75
+ });
76
+ const _bytes = require("./bytes");
77
+ const _bits = require("./bits");
78
+ const _decimal = require("./decimal");
79
+ const _percent = require("./percent");
80
+ const _temperature = require("./temperature");
81
+ const _time = require("./time");
82
+ const _throughput = require("./throughput");
83
+ const _currency = require("./currency");
84
+ const _date = require("./date");
85
+ const UNIT_GROUP_CONFIG = {
86
+ Time: _time.TIME_GROUP_CONFIG,
87
+ Percent: _percent.PERCENT_GROUP_CONFIG,
88
+ Decimal: _decimal.DECIMAL_GROUP_CONFIG,
89
+ Bytes: _bytes.BYTES_GROUP_CONFIG,
90
+ Bits: _bits.BITS_GROUP_CONFIG,
91
+ Throughput: _throughput.THROUGHPUT_GROUP_CONFIG,
92
+ Currency: _currency.CURRENCY_GROUP_CONFIG,
93
+ Temperature: _temperature.TEMPERATURE_GROUP_CONFIG,
94
+ Date: _date.DATE_GROUP_CONFIG
95
+ };
96
+ const UNIT_CONFIG = {
97
+ ..._time.TIME_UNIT_CONFIG,
98
+ ..._percent.PERCENT_UNIT_CONFIG,
99
+ ..._decimal.DECIMAL_UNIT_CONFIG,
100
+ ..._bytes.BYTES_UNIT_CONFIG,
101
+ ..._bits.BITS_UNIT_CONFIG,
102
+ ..._throughput.THROUGHPUT_UNIT_CONFIG,
103
+ ..._currency.CURRENCY_UNIT_CONFIG,
104
+ ..._temperature.TEMPERATURE_UNIT_CONFIG,
105
+ ..._date.DATE_UNIT_CONFIG
106
+ };
107
+ function formatValue(value, formatOptions) {
108
+ if (!formatOptions) {
109
+ return value.toString();
110
+ }
111
+ if (isBytesUnit(formatOptions)) {
112
+ return (0, _bytes.formatBytes)(value, formatOptions);
113
+ }
114
+ if (isBitsUnit(formatOptions)) {
115
+ return (0, _bits.formatBits)(value, formatOptions);
116
+ }
117
+ if (isDecimalUnit(formatOptions)) {
118
+ return (0, _decimal.formatDecimal)(value, formatOptions);
119
+ }
120
+ if (isPercentUnit(formatOptions)) {
121
+ return (0, _percent.formatPercent)(value, formatOptions);
122
+ }
123
+ if (isTimeUnit(formatOptions)) {
124
+ return (0, _time.formatTime)(value, formatOptions);
125
+ }
126
+ if (isThroughputUnit(formatOptions)) {
127
+ return (0, _throughput.formatThroughput)(value, formatOptions);
128
+ }
129
+ if (isCurrencyUnit(formatOptions)) {
130
+ return (0, _currency.formatCurrency)(value, formatOptions);
131
+ }
132
+ if (isDateUnit(formatOptions)) {
133
+ return (0, _date.formatDate)(value, formatOptions);
134
+ }
135
+ if (isTemperatureUnit(formatOptions)) {
136
+ return (0, _temperature.formatTemperature)(value, formatOptions);
137
+ }
138
+ const exhaustive = formatOptions;
139
+ throw new Error(`Unknown unit options ${exhaustive}`);
140
+ }
141
+ function getUnitConfig(formatOptions) {
142
+ const unit = formatOptions.unit ?? 'decimal';
143
+ return UNIT_CONFIG[unit];
144
+ }
145
+ function getUnitGroup(formatOptions) {
146
+ return getUnitConfig(formatOptions).group ?? 'Decimal';
147
+ }
148
+ function getUnitGroupConfig(formatOptions) {
149
+ const unitConfig = getUnitConfig(formatOptions);
150
+ return UNIT_GROUP_CONFIG[unitConfig.group ?? 'Decimal'];
151
+ }
152
+ function isTimeUnit(formatOptions) {
153
+ return getUnitGroup(formatOptions) === 'Time';
154
+ }
155
+ function isPercentUnit(formatOptions) {
156
+ return getUnitGroup(formatOptions) === 'Percent';
157
+ }
158
+ function isDecimalUnit(formatOptions) {
159
+ return getUnitGroup(formatOptions) === 'Decimal';
160
+ }
161
+ function isBytesUnit(formatOptions) {
162
+ return getUnitGroup(formatOptions) === 'Bytes';
163
+ }
164
+ function isBitsUnit(formatOptions) {
165
+ return getUnitGroup(formatOptions) === 'Bits';
166
+ }
167
+ function isUnitWithDecimalPlaces(formatOptions) {
168
+ const groupConfig = getUnitGroupConfig(formatOptions);
169
+ return !!groupConfig.decimalPlaces;
170
+ }
171
+ function isUnitWithShortValues(formatOptions) {
172
+ const groupConfig = getUnitGroupConfig(formatOptions);
173
+ return !!groupConfig.shortValues;
174
+ }
175
+ function isThroughputUnit(formatOptions) {
176
+ return getUnitGroup(formatOptions) === 'Throughput';
177
+ }
178
+ function isCurrencyUnit(formatOptions) {
179
+ return getUnitGroup(formatOptions) === 'Currency';
180
+ }
181
+ function isDateUnit(formatOptions) {
182
+ return getUnitGroup(formatOptions) === 'Date';
183
+ }
184
+ function isTemperatureUnit(formatOptions) {
185
+ return getUnitGroup(formatOptions) === 'Temperature';
186
+ }
@@ -0,0 +1,48 @@
1
+ // Copyright 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
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get hasDecimalPlaces () {
25
+ return hasDecimalPlaces;
26
+ },
27
+ get limitDecimalPlaces () {
28
+ return limitDecimalPlaces;
29
+ },
30
+ get shouldShortenValues () {
31
+ return shouldShortenValues;
32
+ }
33
+ });
34
+ function shouldShortenValues(shortValues) {
35
+ return shortValues !== false;
36
+ }
37
+ function hasDecimalPlaces(decimalPlaces) {
38
+ return typeof decimalPlaces === 'number';
39
+ }
40
+ function limitDecimalPlaces(num) {
41
+ if (!num) return num;
42
+ if (num < 0) {
43
+ num = 0;
44
+ } else if (num > 20) {
45
+ num = 20;
46
+ }
47
+ return num;
48
+ }
@@ -34,42 +34,57 @@ const getModalBackgroundStyle = ({ theme })=>{
34
34
  ...backgroundStyle
35
35
  };
36
36
  };
37
- function getTheme(mode, options = {}) {
37
+ function getTheme(mode, options = {}, disableBodyOverride = false) {
38
38
  return (0, _material.createTheme)({
39
39
  palette: (0, _palette.getPaletteOptions)(mode),
40
40
  typography: _typography.typography,
41
41
  mixins: {},
42
- components,
42
+ components: getComponents(mode, disableBodyOverride),
43
43
  ...options
44
44
  });
45
45
  }
46
46
  // Overrides for component default prop values and styles go here
47
- const components = {
48
- MuiAlert: _alert.MuiAlert,
49
- MuiFormControl: {
50
- defaultProps: {
51
- size: 'small'
52
- }
53
- },
54
- MuiPaper: _paper.MuiPaper,
55
- MuiTextField: {
56
- defaultProps: {
57
- size: 'small'
58
- }
59
- },
60
- MuiDrawer: {
61
- styleOverrides: {
62
- paper: getModalBackgroundStyle
63
- }
64
- },
65
- MuiDialog: {
66
- styleOverrides: {
67
- paper: getModalBackgroundStyle
68
- }
69
- },
70
- MuiPopover: {
71
- styleOverrides: {
72
- paper: getModalBackgroundStyle
47
+ function getComponents(mode, disableBodyOverride) {
48
+ const components = {
49
+ MuiAlert: _alert.MuiAlert,
50
+ MuiFormControl: {
51
+ defaultProps: {
52
+ size: 'small'
53
+ }
54
+ },
55
+ MuiPaper: _paper.MuiPaper,
56
+ MuiTextField: {
57
+ defaultProps: {
58
+ size: 'small'
59
+ }
60
+ },
61
+ MuiDrawer: {
62
+ styleOverrides: {
63
+ paper: getModalBackgroundStyle
64
+ }
65
+ },
66
+ MuiDialog: {
67
+ styleOverrides: {
68
+ paper: getModalBackgroundStyle
69
+ }
70
+ },
71
+ MuiPopover: {
72
+ styleOverrides: {
73
+ paper: getModalBackgroundStyle
74
+ }
73
75
  }
76
+ };
77
+ if (disableBodyOverride) {
78
+ return components;
74
79
  }
75
- };
80
+ return {
81
+ MuiCssBaseline: {
82
+ styleOverrides: {
83
+ body: {
84
+ colorScheme: mode
85
+ }
86
+ }
87
+ },
88
+ ...components
89
+ };
90
+ }
@@ -20,18 +20,19 @@ Object.defineProperty(exports, "typography", {
20
20
  return typography;
21
21
  }
22
22
  });
23
- require("@fontsource/lato/300.css");
24
- require("@fontsource/lato/400.css");
25
- require("@fontsource/lato/700.css");
26
- require("@fontsource/lato/900.css");
23
+ require("@fontsource/inter/300.css");
24
+ require("@fontsource/inter/400.css");
25
+ require("@fontsource/inter/500.css");
26
+ require("@fontsource/inter/600.css");
27
+ require("@fontsource/inter/700.css");
28
+ require("@fontsource/inter/900.css");
27
29
  // Font weights need to correspond with the imports at the top of the file
28
- // (Lato supports 100, 300, 400, 700, 900)
29
30
  const fontWeightLight = 300;
30
31
  const fontWeightRegular = 400;
31
- const fontWeightMedium = 700;
32
+ const fontWeightMedium = 600;
32
33
  const fontWeightBold = 900;
33
34
  const typography = {
34
- fontFamily: '"Lato", sans-serif',
35
+ fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
35
36
  fontWeightLight,
36
37
  fontWeightRegular,
37
38
  fontWeightMedium,
@@ -29,7 +29,7 @@ _export(exports, {
29
29
  }
30
30
  });
31
31
  const _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
32
- const _core = require("@perses-dev/core");
32
+ const _model = require("../model");
33
33
  function _interop_require_default(obj) {
34
34
  return obj && obj.__esModule ? obj : {
35
35
  default: obj
@@ -41,7 +41,7 @@ const AXIS_LABEL_PADDING = 10; // Extra padding to avoid label clipping
41
41
  /**
42
42
  * Estimate the pixel width needed for an axis label using Canvas API.
43
43
  */ function estimateLabelWidth(format, maxValue) {
44
- const formattedLabel = (0, _core.formatValue)(maxValue, format);
44
+ const formattedLabel = (0, _model.formatValue)(maxValue, format);
45
45
  // Create a canvas element (reuse if possible for performance)
46
46
  const canvas = document.createElement('canvas');
47
47
  const context = canvas.getContext('2d');
@@ -62,7 +62,7 @@ function getFormattedAxis(axis, unit) {
62
62
  ],
63
63
  axisLabel: {
64
64
  formatter: (value)=>{
65
- return (0, _core.formatValue)(value, unit);
65
+ return (0, _model.formatValue)(value, unit);
66
66
  }
67
67
  }
68
68
  };
@@ -82,7 +82,7 @@ function getFormattedMultipleYAxes(baseAxis, baseFormat, additionalFormats, maxV
82
82
  ],
83
83
  axisLabel: {
84
84
  formatter: (value)=>{
85
- return (0, _core.formatValue)(value, baseFormat);
85
+ return (0, _model.formatValue)(value, baseFormat);
86
86
  },
87
87
  // Let ECharts handle width automatically
88
88
  overflow: 'truncate'
@@ -104,7 +104,7 @@ function getFormattedMultipleYAxes(baseAxis, baseFormat, additionalFormats, maxV
104
104
  ],
105
105
  axisLabel: {
106
106
  formatter: (value)=>{
107
- return (0, _core.formatValue)(value, format);
107
+ return (0, _model.formatValue)(value, format);
108
108
  }
109
109
  },
110
110
  splitLine: {
@@ -22,6 +22,7 @@ _export_star(require("./component-ids"), exports);
22
22
  _export_star(require("./data-field-interpolation"), exports);
23
23
  _export_star(require("./format"), exports);
24
24
  _export_star(require("./memo"), exports);
25
+ _export_star(require("./request-interpolation"), exports);
25
26
  _export_star(require("./selection-interpolation"), exports);
26
27
  _export_star(require("./theme-gen"), exports);
27
28
  _export_star(require("./variable-interpolation"), exports);