@perses-dev/components 0.54.0-beta.0 → 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 (192) 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/Table/Table.d.ts +1 -1
  24. package/dist/Table/Table.d.ts.map +1 -1
  25. package/dist/Table/Table.js +26 -6
  26. package/dist/Table/Table.js.map +1 -1
  27. package/dist/Table/TableToolbar.d.ts +34 -0
  28. package/dist/Table/TableToolbar.d.ts.map +1 -0
  29. package/dist/Table/TableToolbar.js +127 -0
  30. package/dist/Table/TableToolbar.js.map +1 -0
  31. package/dist/Table/VirtualizedTable.d.ts +3 -1
  32. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  33. package/dist/Table/VirtualizedTable.js +128 -117
  34. package/dist/Table/VirtualizedTable.js.map +1 -1
  35. package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -1
  36. package/dist/Table/VirtualizedTableContainer.js +5 -1
  37. package/dist/Table/VirtualizedTableContainer.js.map +1 -1
  38. package/dist/Table/hooks/useFuzzySearch.d.ts +12 -0
  39. package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -0
  40. package/dist/Table/hooks/useFuzzySearch.js +43 -0
  41. package/dist/Table/hooks/useFuzzySearch.js.map +1 -0
  42. package/dist/Table/model/table-model.d.ts +37 -3
  43. package/dist/Table/model/table-model.d.ts.map +1 -1
  44. package/dist/Table/model/table-model.js.map +1 -1
  45. package/dist/ThresholdsEditor/ThresholdInput.d.ts +1 -1
  46. package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -1
  47. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  48. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts +1 -1
  49. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
  50. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  51. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +1 -2
  52. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  53. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  54. package/dist/TimeSeriesTooltip/nearby-series.d.ts +2 -2
  55. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  56. package/dist/TimeSeriesTooltip/nearby-series.js +1 -2
  57. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  58. package/dist/TransformsEditor/TransformEditor.d.ts +1 -1
  59. package/dist/TransformsEditor/TransformEditor.d.ts.map +1 -1
  60. package/dist/TransformsEditor/TransformEditor.js.map +1 -1
  61. package/dist/TransformsEditor/TransformEditorContainer.d.ts.map +1 -1
  62. package/dist/TransformsEditor/TransformEditorContainer.js +1 -1
  63. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  64. package/dist/TransformsEditor/TransformsEditor.d.ts +1 -1
  65. package/dist/TransformsEditor/TransformsEditor.d.ts.map +1 -1
  66. package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
  67. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +2 -2
  68. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +2 -2
  69. package/dist/cjs/FormatControls/FormatControls.js +4 -4
  70. package/dist/cjs/FormatControls/UnitSelector.js +3 -3
  71. package/dist/cjs/Legend/Legend.js +2 -2
  72. package/dist/cjs/Table/Table.js +24 -4
  73. package/dist/cjs/Table/TableToolbar.js +140 -0
  74. package/dist/cjs/Table/VirtualizedTable.js +126 -115
  75. package/dist/cjs/Table/VirtualizedTableContainer.js +5 -1
  76. package/dist/cjs/Table/hooks/useFuzzySearch.js +48 -0
  77. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +2 -3
  78. package/dist/cjs/TransformsEditor/TransformEditorContainer.js +2 -2
  79. package/dist/cjs/model/action.js +43 -0
  80. package/dist/cjs/model/bits.js +113 -0
  81. package/dist/cjs/model/bytes.js +115 -0
  82. package/dist/cjs/model/constants.js +23 -0
  83. package/dist/cjs/model/currency.js +126 -0
  84. package/dist/cjs/model/date.js +297 -0
  85. package/dist/cjs/model/decimal.js +72 -0
  86. package/dist/cjs/model/formatterCache.js +120 -0
  87. package/dist/cjs/model/index.js +16 -0
  88. package/dist/cjs/model/legend.js +101 -0
  89. package/dist/cjs/model/percent.js +82 -0
  90. package/dist/cjs/model/temperature.js +72 -0
  91. package/dist/cjs/model/thresholds.js +16 -0
  92. package/dist/cjs/model/throughput.js +161 -0
  93. package/dist/cjs/model/time.js +178 -0
  94. package/dist/cjs/model/transforms.js +29 -0
  95. package/dist/cjs/model/types.js +16 -0
  96. package/dist/cjs/model/units.js +186 -0
  97. package/dist/cjs/model/utils.js +48 -0
  98. package/dist/cjs/utils/axis.js +5 -5
  99. package/dist/cjs/utils/index.js +1 -0
  100. package/dist/cjs/utils/request-interpolation.js +49 -0
  101. package/dist/model/action.d.ts +4 -0
  102. package/dist/model/action.d.ts.map +1 -0
  103. package/dist/model/action.js +27 -0
  104. package/dist/model/action.js.map +1 -0
  105. package/dist/model/bits.d.ts +12 -0
  106. package/dist/model/bits.d.ts.map +1 -0
  107. package/dist/model/bits.js +89 -0
  108. package/dist/model/bits.js.map +1 -0
  109. package/dist/model/bytes.d.ts +12 -0
  110. package/dist/model/bytes.d.ts.map +1 -0
  111. package/dist/model/bytes.js +91 -0
  112. package/dist/model/bytes.js.map +1 -0
  113. package/dist/model/constants.d.ts +2 -0
  114. package/dist/model/constants.d.ts.map +1 -0
  115. package/dist/model/constants.js +15 -0
  116. package/dist/model/constants.js.map +1 -0
  117. package/dist/model/currency.d.ts +11 -0
  118. package/dist/model/currency.d.ts.map +1 -0
  119. package/dist/model/currency.js +107 -0
  120. package/dist/model/currency.js.map +1 -0
  121. package/dist/model/date.d.ts +28 -0
  122. package/dist/model/date.d.ts.map +1 -0
  123. package/dist/model/date.js +278 -0
  124. package/dist/model/date.js.map +1 -0
  125. package/dist/model/decimal.d.ts +12 -0
  126. package/dist/model/decimal.d.ts.map +1 -0
  127. package/dist/model/decimal.js +53 -0
  128. package/dist/model/decimal.js.map +1 -0
  129. package/dist/model/formatterCache.d.ts +11 -0
  130. package/dist/model/formatterCache.d.ts.map +1 -0
  131. package/dist/model/formatterCache.js +104 -0
  132. package/dist/model/formatterCache.js.map +1 -0
  133. package/dist/model/index.d.ts +16 -0
  134. package/dist/model/index.d.ts.map +1 -1
  135. package/dist/model/index.js +16 -0
  136. package/dist/model/index.js.map +1 -1
  137. package/dist/model/legend.d.ts +19 -0
  138. package/dist/model/legend.d.ts.map +1 -0
  139. package/dist/model/legend.js +61 -0
  140. package/dist/model/legend.js.map +1 -0
  141. package/dist/model/percent.d.ts +11 -0
  142. package/dist/model/percent.d.ts.map +1 -0
  143. package/dist/model/percent.js +63 -0
  144. package/dist/model/percent.js.map +1 -0
  145. package/dist/model/temperature.d.ts +11 -0
  146. package/dist/model/temperature.d.ts.map +1 -0
  147. package/dist/model/temperature.js +53 -0
  148. package/dist/model/temperature.js.map +1 -0
  149. package/dist/model/theme.d.ts +1 -1
  150. package/dist/model/theme.d.ts.map +1 -1
  151. package/dist/model/theme.js.map +1 -1
  152. package/dist/model/thresholds.d.ts +16 -0
  153. package/dist/model/thresholds.d.ts.map +1 -0
  154. package/dist/model/thresholds.js +15 -0
  155. package/dist/model/thresholds.js.map +1 -0
  156. package/dist/model/throughput.d.ts +12 -0
  157. package/dist/model/throughput.d.ts.map +1 -0
  158. package/dist/model/throughput.js +142 -0
  159. package/dist/model/throughput.js.map +1 -0
  160. package/dist/model/time.d.ts +23 -0
  161. package/dist/model/time.d.ts.map +1 -0
  162. package/dist/model/time.js +158 -0
  163. package/dist/model/time.js.map +1 -0
  164. package/dist/model/transforms.d.ts +43 -0
  165. package/dist/model/transforms.d.ts.map +1 -0
  166. package/dist/model/transforms.js +22 -0
  167. package/dist/model/transforms.js.map +1 -0
  168. package/dist/model/types.d.ts +56 -0
  169. package/dist/model/types.d.ts.map +1 -0
  170. package/dist/model/types.js +15 -0
  171. package/dist/model/types.js.map +1 -0
  172. package/dist/model/units.d.ts +105 -0
  173. package/dist/model/units.d.ts.map +1 -0
  174. package/dist/model/units.js +132 -0
  175. package/dist/model/units.js.map +1 -0
  176. package/dist/model/utils.d.ts +4 -0
  177. package/dist/model/utils.d.ts.map +1 -0
  178. package/dist/model/utils.js +32 -0
  179. package/dist/model/utils.js.map +1 -0
  180. package/dist/utils/axis.d.ts +1 -1
  181. package/dist/utils/axis.d.ts.map +1 -1
  182. package/dist/utils/axis.js +1 -1
  183. package/dist/utils/axis.js.map +1 -1
  184. package/dist/utils/index.d.ts +1 -0
  185. package/dist/utils/index.d.ts.map +1 -1
  186. package/dist/utils/index.js +1 -0
  187. package/dist/utils/index.js.map +1 -1
  188. package/dist/utils/request-interpolation.d.ts +6 -0
  189. package/dist/utils/request-interpolation.d.ts.map +1 -0
  190. package/dist/utils/request-interpolation.js +33 -0
  191. package/dist/utils/request-interpolation.js.map +1 -0
  192. package/package.json +2 -1
@@ -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
+ }
@@ -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
+ }
@@ -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);
@@ -0,0 +1,49 @@
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 interpolateHeaders () {
25
+ return interpolateHeaders;
26
+ },
27
+ get interpolateQueryParams () {
28
+ return interpolateQueryParams;
29
+ }
30
+ });
31
+ const _variableinterpolation = require("./variable-interpolation");
32
+ function interpolateHeaders(headers, variableState) {
33
+ const result = {};
34
+ for (const [key, value] of Object.entries(headers)){
35
+ result[key] = (0, _variableinterpolation.replaceVariables)(value, variableState);
36
+ }
37
+ return result;
38
+ }
39
+ function interpolateQueryParams(queryParams, variableState) {
40
+ const result = {};
41
+ for (const [key, value] of Object.entries(queryParams)){
42
+ if (Array.isArray(value)) {
43
+ result[key] = value.map((v)=>(0, _variableinterpolation.replaceVariables)(v, variableState));
44
+ } else {
45
+ result[key] = (0, _variableinterpolation.replaceVariables)(value, variableState);
46
+ }
47
+ }
48
+ return result;
49
+ }
@@ -0,0 +1,4 @@
1
+ export type Action = 'create' | 'read' | 'update' | 'delete' | '*';
2
+ export declare function getTitleAction(action: Action, isDraft: boolean): string;
3
+ export declare function getSubmitText(action: Action, isDraft: boolean): string;
4
+ //# sourceMappingURL=action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/model/action.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,GAAG,CAAC;AAEnE,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAMvE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAKtE"}
@@ -0,0 +1,27 @@
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
+ export function getTitleAction(action, isDraft) {
14
+ if (action === 'read') return 'View';
15
+ if (isDraft && action === 'create') return 'Add';
16
+ if (!isDraft && action === 'create') return 'Create';
17
+ if (action === 'update') return 'Edit';
18
+ return '';
19
+ }
20
+ export function getSubmitText(action, isDraft) {
21
+ if (isDraft && action === 'create') return 'Add';
22
+ if (isDraft && action === 'update') return 'Apply';
23
+ if (!isDraft) return 'Save';
24
+ return '';
25
+ }
26
+
27
+ //# sourceMappingURL=action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/action.ts"],"sourcesContent":["// Copyright 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 type Action = 'create' | 'read' | 'update' | 'delete' | '*';\n\nexport function getTitleAction(action: Action, isDraft: boolean): string {\n if (action === 'read') return 'View';\n if (isDraft && action === 'create') return 'Add';\n if (!isDraft && action === 'create') return 'Create';\n if (action === 'update') return 'Edit';\n return '';\n}\n\nexport function getSubmitText(action: Action, isDraft: boolean): string {\n if (isDraft && action === 'create') return 'Add';\n if (isDraft && action === 'update') return 'Apply';\n if (!isDraft) return 'Save';\n return '';\n}\n"],"names":["getTitleAction","action","isDraft","getSubmitText"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,SAASA,eAAeC,MAAc,EAAEC,OAAgB;IAC7D,IAAID,WAAW,QAAQ,OAAO;IAC9B,IAAIC,WAAWD,WAAW,UAAU,OAAO;IAC3C,IAAI,CAACC,WAAWD,WAAW,UAAU,OAAO;IAC5C,IAAIA,WAAW,UAAU,OAAO;IAChC,OAAO;AACT;AAEA,OAAO,SAASE,cAAcF,MAAc,EAAEC,OAAgB;IAC5D,IAAIA,WAAWD,WAAW,UAAU,OAAO;IAC3C,IAAIC,WAAWD,WAAW,UAAU,OAAO;IAC3C,IAAI,CAACC,SAAS,OAAO;IACrB,OAAO;AACT"}
@@ -0,0 +1,12 @@
1
+ import { UnitGroupConfig, UnitConfig } from './types';
2
+ type BitsUnit = 'bits' | 'decbits';
3
+ export type BitsFormatOptions = {
4
+ unit?: BitsUnit;
5
+ decimalPlaces?: number;
6
+ shortValues?: boolean;
7
+ };
8
+ export declare const BITS_GROUP_CONFIG: UnitGroupConfig;
9
+ export declare const BITS_UNIT_CONFIG: Readonly<Record<BitsUnit, UnitConfig>>;
10
+ export declare function formatBits(bits: number, { unit, shortValues, decimalPlaces }: BitsFormatOptions): string;
11
+ export {};
12
+ //# sourceMappingURL=bits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bits.d.ts","sourceRoot":"","sources":["../../src/model/bits.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAoBtD,KAAK,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAEnC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAI/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CASnE,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAa,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,iBAAiB,GAAG,MAAM,CA4DjH"}