@perses-dev/components 0.35.0 → 0.36.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 (182) hide show
  1. package/dist/ContentWithLegend/ContentWithLegend.d.ts +1 -1
  2. package/dist/ContentWithLegend/ContentWithLegend.d.ts.map +1 -1
  3. package/dist/ContentWithLegend/ContentWithLegend.js +4 -2
  4. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  5. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +9 -3
  6. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
  7. package/dist/ContentWithLegend/model/content-with-legend-model.js +17 -7
  8. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
  9. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +1 -1
  10. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -1
  11. package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -1
  12. package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts +2 -5
  13. package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -1
  14. package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
  15. package/dist/GaugeChart/GaugeChart.d.ts +1 -1
  16. package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
  17. package/dist/GaugeChart/GaugeChart.js +1 -2
  18. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  19. package/dist/Legend/CompactLegend.d.ts +3 -1
  20. package/dist/Legend/CompactLegend.d.ts.map +1 -1
  21. package/dist/Legend/CompactLegend.js +5 -2
  22. package/dist/Legend/CompactLegend.js.map +1 -1
  23. package/dist/Legend/Legend.d.ts +11 -2
  24. package/dist/Legend/Legend.d.ts.map +1 -1
  25. package/dist/Legend/Legend.js +4 -2
  26. package/dist/Legend/Legend.js.map +1 -1
  27. package/dist/Legend/ListLegend.d.ts +3 -1
  28. package/dist/Legend/ListLegend.d.ts.map +1 -1
  29. package/dist/Legend/ListLegend.js +5 -4
  30. package/dist/Legend/ListLegend.js.map +1 -1
  31. package/dist/Legend/ListLegendItem.d.ts +15 -2
  32. package/dist/Legend/ListLegendItem.d.ts.map +1 -1
  33. package/dist/Legend/ListLegendItem.js +17 -5
  34. package/dist/Legend/ListLegendItem.js.map +1 -1
  35. package/dist/Legend/TableLegend.d.ts +4 -2
  36. package/dist/Legend/TableLegend.d.ts.map +1 -1
  37. package/dist/Legend/TableLegend.js +8 -2
  38. package/dist/Legend/TableLegend.js.map +1 -1
  39. package/dist/LineChart/LineChart.d.ts +17 -3
  40. package/dist/LineChart/LineChart.d.ts.map +1 -1
  41. package/dist/LineChart/LineChart.js +33 -7
  42. package/dist/LineChart/LineChart.js.map +1 -1
  43. package/dist/LineChart/index.d.ts +1 -1
  44. package/dist/LineChart/index.d.ts.map +1 -1
  45. package/dist/LineChart/index.js +1 -0
  46. package/dist/LineChart/index.js.map +1 -1
  47. package/dist/LineChart/utils.d.ts +2 -1
  48. package/dist/LineChart/utils.d.ts.map +1 -1
  49. package/dist/LineChart/utils.js +14 -1
  50. package/dist/LineChart/utils.js.map +1 -1
  51. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts +12 -0
  52. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts.map +1 -0
  53. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +45 -0
  54. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -0
  55. package/dist/RefreshIntervalPicker/index.d.ts +2 -0
  56. package/dist/RefreshIntervalPicker/index.d.ts.map +1 -0
  57. package/dist/{model/units → RefreshIntervalPicker}/index.js +1 -3
  58. package/dist/RefreshIntervalPicker/index.js.map +1 -0
  59. package/dist/StatChart/StatChart.d.ts +1 -1
  60. package/dist/StatChart/StatChart.d.ts.map +1 -1
  61. package/dist/StatChart/StatChart.js +1 -1
  62. package/dist/StatChart/StatChart.js.map +1 -1
  63. package/dist/Table/InnerTable.js +2 -2
  64. package/dist/Table/InnerTable.js.map +1 -1
  65. package/dist/Table/Table.d.ts +1 -1
  66. package/dist/Table/Table.d.ts.map +1 -1
  67. package/dist/Table/Table.js +57 -9
  68. package/dist/Table/Table.js.map +1 -1
  69. package/dist/Table/TableCell.d.ts +11 -1
  70. package/dist/Table/TableCell.d.ts.map +1 -1
  71. package/dist/Table/TableCell.js +8 -3
  72. package/dist/Table/TableCell.js.map +1 -1
  73. package/dist/Table/TableCheckbox.js +1 -1
  74. package/dist/Table/TableCheckbox.js.map +1 -1
  75. package/dist/Table/TableHeaderCell.d.ts +23 -0
  76. package/dist/Table/TableHeaderCell.d.ts.map +1 -0
  77. package/dist/Table/TableHeaderCell.js +53 -0
  78. package/dist/Table/TableHeaderCell.js.map +1 -0
  79. package/dist/Table/VirtualizedTable.d.ts +3 -3
  80. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  81. package/dist/Table/VirtualizedTable.js +43 -8
  82. package/dist/Table/VirtualizedTable.js.map +1 -1
  83. package/dist/Table/model/table-model.d.ts +71 -7
  84. package/dist/Table/model/table-model.d.ts.map +1 -1
  85. package/dist/Table/model/table-model.js +6 -2
  86. package/dist/Table/model/table-model.js.map +1 -1
  87. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +2 -1
  88. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
  89. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +2 -1
  90. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
  91. package/dist/TimeSeriesTooltip/nearby-series.d.ts +2 -1
  92. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  93. package/dist/TimeSeriesTooltip/nearby-series.js +2 -11
  94. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  95. package/dist/UnitSelector/UnitSelector.d.ts +1 -1
  96. package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
  97. package/dist/UnitSelector/UnitSelector.js +1 -2
  98. package/dist/UnitSelector/UnitSelector.js.map +1 -1
  99. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +4 -2
  100. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +17 -7
  101. package/dist/cjs/GaugeChart/GaugeChart.js +2 -3
  102. package/dist/cjs/Legend/CompactLegend.js +5 -2
  103. package/dist/cjs/Legend/Legend.js +4 -2
  104. package/dist/cjs/Legend/ListLegend.js +5 -4
  105. package/dist/cjs/Legend/ListLegendItem.js +17 -5
  106. package/dist/cjs/Legend/TableLegend.js +8 -2
  107. package/dist/cjs/LineChart/LineChart.js +31 -5
  108. package/dist/cjs/LineChart/index.js +1 -0
  109. package/dist/cjs/LineChart/utils.js +14 -3
  110. package/dist/cjs/RefreshIntervalPicker/RefreshIntervalPicker.js +51 -0
  111. package/dist/cjs/{model/units → RefreshIntervalPicker}/index.js +1 -3
  112. package/dist/cjs/StatChart/StatChart.js +4 -4
  113. package/dist/cjs/Table/InnerTable.js +2 -2
  114. package/dist/cjs/Table/Table.js +56 -8
  115. package/dist/cjs/Table/TableCell.js +8 -3
  116. package/dist/cjs/Table/TableCheckbox.js +1 -1
  117. package/dist/cjs/Table/TableHeaderCell.js +59 -0
  118. package/dist/cjs/Table/VirtualizedTable.js +43 -8
  119. package/dist/cjs/Table/model/table-model.js +6 -2
  120. package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +2 -1
  121. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +2 -11
  122. package/dist/cjs/UnitSelector/UnitSelector.js +6 -7
  123. package/dist/cjs/index.js +1 -0
  124. package/dist/cjs/model/index.js +1 -1
  125. package/dist/{model/units/types.js → cjs/model/timeOption.js} +4 -10
  126. package/dist/index.d.ts +1 -0
  127. package/dist/index.d.ts.map +1 -1
  128. package/dist/index.js +1 -0
  129. package/dist/index.js.map +1 -1
  130. package/dist/model/index.d.ts +1 -1
  131. package/dist/model/index.d.ts.map +1 -1
  132. package/dist/model/index.js +1 -1
  133. package/dist/model/index.js.map +1 -1
  134. package/dist/model/theme.d.ts +1 -4
  135. package/dist/model/theme.d.ts.map +1 -1
  136. package/dist/model/theme.js.map +1 -1
  137. package/dist/model/timeOption.d.ts +6 -0
  138. package/dist/model/timeOption.d.ts.map +1 -0
  139. package/dist/model/{units/constants.js → timeOption.js} +2 -4
  140. package/dist/model/timeOption.js.map +1 -0
  141. package/package.json +3 -4
  142. package/dist/cjs/model/units/bytes.js +0 -84
  143. package/dist/cjs/model/units/constants.js +0 -23
  144. package/dist/cjs/model/units/decimal.js +0 -62
  145. package/dist/cjs/model/units/percent.js +0 -73
  146. package/dist/cjs/model/units/time.js +0 -105
  147. package/dist/cjs/model/units/types.js +0 -28
  148. package/dist/cjs/model/units/units.js +0 -101
  149. package/dist/cjs/model/units/utils.js +0 -42
  150. package/dist/model/units/bytes.d.ts +0 -13
  151. package/dist/model/units/bytes.d.ts.map +0 -1
  152. package/dist/model/units/bytes.js +0 -66
  153. package/dist/model/units/bytes.js.map +0 -1
  154. package/dist/model/units/constants.d.ts +0 -2
  155. package/dist/model/units/constants.d.ts.map +0 -1
  156. package/dist/model/units/constants.js.map +0 -1
  157. package/dist/model/units/decimal.d.ts +0 -13
  158. package/dist/model/units/decimal.d.ts.map +0 -1
  159. package/dist/model/units/decimal.js +0 -49
  160. package/dist/model/units/decimal.js.map +0 -1
  161. package/dist/model/units/index.d.ts +0 -4
  162. package/dist/model/units/index.d.ts.map +0 -1
  163. package/dist/model/units/index.js.map +0 -1
  164. package/dist/model/units/percent.d.ts +0 -12
  165. package/dist/model/units/percent.d.ts.map +0 -1
  166. package/dist/model/units/percent.js +0 -60
  167. package/dist/model/units/percent.js.map +0 -1
  168. package/dist/model/units/time.d.ts +0 -22
  169. package/dist/model/units/time.d.ts.map +0 -1
  170. package/dist/model/units/time.js +0 -91
  171. package/dist/model/units/time.js.map +0 -1
  172. package/dist/model/units/types.d.ts +0 -47
  173. package/dist/model/units/types.d.ts.map +0 -1
  174. package/dist/model/units/types.js.map +0 -1
  175. package/dist/model/units/units.d.ts +0 -40
  176. package/dist/model/units/units.d.ts.map +0 -1
  177. package/dist/model/units/units.js +0 -80
  178. package/dist/model/units/units.js.map +0 -1
  179. package/dist/model/units/utils.d.ts +0 -4
  180. package/dist/model/units/utils.d.ts.map +0 -1
  181. package/dist/model/units/utils.js +0 -32
  182. package/dist/model/units/utils.js.map +0 -1
@@ -20,11 +20,10 @@ Object.defineProperty(exports, "UnitSelector", {
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _material = require("@mui/material");
23
- const _model = require("../model");
24
- const _utils = require("../model/units/utils");
23
+ const _core = require("@perses-dev/core");
25
24
  const _optionsEditorLayout = require("../OptionsEditorLayout");
26
25
  const _settingsAutocomplete = require("../SettingsAutocomplete");
27
- const KIND_OPTIONS = Object.entries(_model.UNIT_CONFIG).map(([id, config])=>{
26
+ const KIND_OPTIONS = Object.entries(_core.UNIT_CONFIG).map(([id, config])=>{
28
27
  return {
29
28
  id: id,
30
29
  ...config
@@ -66,8 +65,8 @@ function getOptionByDecimalPlaces(decimal_places) {
66
65
  return DECIMAL_PLACES_OPTIONS.find((o)=>o.decimal_places === decimal_places);
67
66
  }
68
67
  function UnitSelector({ value , onChange }) {
69
- const hasDecimalPlaces = (0, _model.isUnitWithDecimalPlaces)(value);
70
- const hasAbbreviate = (0, _model.isUnitWithAbbreviate)(value);
68
+ const hasDecimalPlaces = (0, _core.isUnitWithDecimalPlaces)(value);
69
+ const hasAbbreviate = (0, _core.isUnitWithAbbreviate)(value);
71
70
  const handleKindChange = (_, newValue)=>{
72
71
  onChange({
73
72
  kind: newValue.id
@@ -89,13 +88,13 @@ function UnitSelector({ value , onChange }) {
89
88
  });
90
89
  }
91
90
  };
92
- const kindConfig = _model.UNIT_CONFIG[value.kind];
91
+ const kindConfig = _core.UNIT_CONFIG[value.kind];
93
92
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
94
93
  children: [
95
94
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
96
95
  label: "Abbreviate",
97
96
  control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
98
- checked: hasAbbreviate ? (0, _utils.shouldAbbreviate)(value.abbreviate) : false,
97
+ checked: hasAbbreviate ? (0, _core.shouldAbbreviate)(value.abbreviate) : false,
99
98
  onChange: handleAbbreviateChange,
100
99
  disabled: !hasAbbreviate
101
100
  })
package/dist/cjs/index.js CHANGED
@@ -42,6 +42,7 @@ _exportStar(require("./utils"), exports);
42
42
  _exportStar(require("./model"), exports);
43
43
  _exportStar(require("./test-utils"), exports);
44
44
  _exportStar(require("./theme"), exports);
45
+ _exportStar(require("./RefreshIntervalPicker"), exports);
45
46
  function _exportStar(from, to) {
46
47
  Object.keys(from).forEach(function(k) {
47
48
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  _exportStar(require("./graph"), exports);
18
18
  _exportStar(require("./theme"), exports);
19
- _exportStar(require("./units"), exports);
19
+ _exportStar(require("./timeOption"), exports);
20
20
  function _exportStar(from, to) {
21
21
  Object.keys(from).forEach(function(k) {
22
22
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
@@ -10,13 +10,7 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
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
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
package/dist/index.d.ts CHANGED
@@ -26,4 +26,5 @@ export * from './utils';
26
26
  export * from './model';
27
27
  export * from './test-utils';
28
28
  export * from './theme';
29
+ export * from './RefreshIntervalPicker';
29
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -38,5 +38,6 @@ export * from './utils';
38
38
  export * from './model';
39
39
  export * from './test-utils';
40
40
  export * from './theme';
41
+ export * from './RefreshIntervalPicker';
41
42
 
42
43
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './ColorPicker';\nexport * from './ContentWithLegend';\nexport * from './DateTimeRangePicker';\nexport * from './Dialog';\nexport * from './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './GaugeChart';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LineChart';\nexport * from './OptionsEditorLayout';\nexport * from './SettingsAutocomplete';\nexport * from './StatChart';\nexport * from './Table';\nexport * from './ThresholdsEditor';\nexport * from './TimeSeriesTooltip';\nexport * from './UnitSelector';\nexport * from './YAxisLabel';\nexport * from './context/ChartsThemeProvider';\nexport * from './context/TimeZoneProvider';\nexport * from './context/SnackbarProvider';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\nexport * from './theme';\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,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './ColorPicker';\nexport * from './ContentWithLegend';\nexport * from './DateTimeRangePicker';\nexport * from './Dialog';\nexport * from './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './GaugeChart';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LineChart';\nexport * from './OptionsEditorLayout';\nexport * from './SettingsAutocomplete';\nexport * from './StatChart';\nexport * from './Table';\nexport * from './ThresholdsEditor';\nexport * from './TimeSeriesTooltip';\nexport * from './UnitSelector';\nexport * from './YAxisLabel';\nexport * from './context/ChartsThemeProvider';\nexport * from './context/TimeZoneProvider';\nexport * from './context/SnackbarProvider';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\nexport * from './theme';\nexport * from './RefreshIntervalPicker';\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,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  export * from './graph';
2
2
  export * from './theme';
3
- export * from './units';
3
+ export * from './timeOption';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
@@ -12,6 +12,6 @@
12
12
  // limitations under the License.
13
13
  export * from './graph';
14
14
  export * from './theme';
15
- export * from './units';
15
+ export * from './timeOption';
16
16
 
17
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './graph';\nexport * from './theme';\nexport * from './units';\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,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './graph';\nexport * from './theme';\nexport * from './timeOption';\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,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { ThresholdColorPalette } from '@perses-dev/core';
1
2
  import type { EChartsOption, BarSeriesOption, LineSeriesOption, GaugeSeriesOption, TitleComponentOption, ComposeOption, XAXisComponentOption, YAXisComponentOption } from 'echarts';
2
3
  export interface PersesChartsTheme {
3
4
  echartsTheme: EChartsTheme;
@@ -24,9 +25,5 @@ export interface EChartsTheme extends EChartsOption {
24
25
  line?: LineSeriesOption;
25
26
  gauge?: GaugeSeriesOption;
26
27
  }
27
- export interface ThresholdColorPalette {
28
- defaultColor: string;
29
- palette: string[];
30
- }
31
28
  export declare type NoDataOption = ComposeOption<TitleComponentOption | XAXisComponentOption | YAXisComponentOption>;
32
29
  //# sourceMappingURL=theme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/model/theme.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF;;OAEG;IACH,SAAS,EAAE;QACT;;WAEG;QACH,OAAO,EAAE;YACP,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;IACF,UAAU,EAAE,qBAAqB,CAAC;CACnC;AAGD,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,oBAAY,YAAY,GAAG,aAAa,CAAC,oBAAoB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC,CAAC"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/model/theme.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF;;OAEG;IACH,SAAS,EAAE;QACT;;WAEG;QACH,OAAO,EAAE;YACP,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;IACF,UAAU,EAAE,qBAAqB,CAAC;CACnC;AAGD,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B;AAED,oBAAY,YAAY,GAAG,aAAa,CAAC,oBAAoB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/theme.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {\n EChartsOption,\n BarSeriesOption,\n LineSeriesOption,\n GaugeSeriesOption,\n TitleComponentOption,\n ComposeOption,\n XAXisComponentOption,\n YAXisComponentOption,\n} from 'echarts';\n\nexport interface PersesChartsTheme {\n echartsTheme: EChartsTheme;\n noDataOption: NoDataOption;\n sparkline: {\n width: number;\n color: string;\n };\n /**\n * Theming for the container that wraps a chart.\n */\n container: {\n /**\n * Padding in pixels.\n */\n padding: {\n default: number;\n };\n };\n thresholds: ThresholdColorPalette;\n}\n\n// https://github.com/apache/echarts/issues/12489#issuecomment-643185207\nexport interface EChartsTheme extends EChartsOption {\n bar?: BarSeriesOption;\n line?: LineSeriesOption;\n gauge?: GaugeSeriesOption;\n}\n\nexport interface ThresholdColorPalette {\n defaultColor: string;\n palette: string[];\n}\n\nexport type NoDataOption = ComposeOption<TitleComponentOption | XAXisComponentOption | YAXisComponentOption>;\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,WA4C6G"}
1
+ {"version":3,"sources":["../../src/model/theme.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ThresholdColorPalette } from '@perses-dev/core';\nimport type {\n EChartsOption,\n BarSeriesOption,\n LineSeriesOption,\n GaugeSeriesOption,\n TitleComponentOption,\n ComposeOption,\n XAXisComponentOption,\n YAXisComponentOption,\n} from 'echarts';\n\nexport interface PersesChartsTheme {\n echartsTheme: EChartsTheme;\n noDataOption: NoDataOption;\n sparkline: {\n width: number;\n color: string;\n };\n /**\n * Theming for the container that wraps a chart.\n */\n container: {\n /**\n * Padding in pixels.\n */\n padding: {\n default: number;\n };\n };\n thresholds: ThresholdColorPalette;\n}\n\n// https://github.com/apache/echarts/issues/12489#issuecomment-643185207\nexport interface EChartsTheme extends EChartsOption {\n bar?: BarSeriesOption;\n line?: LineSeriesOption;\n gauge?: GaugeSeriesOption;\n}\n\nexport type NoDataOption = ComposeOption<TitleComponentOption | XAXisComponentOption | YAXisComponentOption>;\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,WAwC6G"}
@@ -0,0 +1,6 @@
1
+ import { RelativeTimeRange } from '@perses-dev/core';
2
+ export interface TimeOption {
3
+ value: RelativeTimeRange;
4
+ display: string;
5
+ }
6
+ //# sourceMappingURL=timeOption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeOption.d.ts","sourceRoot":"","sources":["../../src/model/timeOption.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,iBAAiB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -10,8 +10,6 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- // Common constants needed across individual unit groups and the overall
14
- // combined units.
15
- export const MAX_SIGNIFICANT_DIGITS = 3;
13
+ export { };
16
14
 
17
- //# sourceMappingURL=constants.js.map
15
+ //# sourceMappingURL=timeOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/timeOption.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { RelativeTimeRange } from '@perses-dev/core';\n\nexport interface TimeOption {\n value: RelativeTimeRange;\n display: string;\n}\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,WAKC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/components",
3
- "version": "0.35.0",
3
+ "version": "0.36.1",
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",
@@ -36,7 +36,7 @@
36
36
  "@codemirror/lang-json": "^6.0.1",
37
37
  "@fontsource/lato": "^4.5.10",
38
38
  "@mui/x-date-pickers": "^5.0.0-beta.1",
39
- "@perses-dev/core": "0.35.0",
39
+ "@perses-dev/core": "0.36.1",
40
40
  "@tanstack/react-table": "^8.9.1",
41
41
  "@uiw/react-codemirror": "^4.19.1",
42
42
  "date-fns": "^2.28.0",
@@ -45,13 +45,12 @@
45
45
  "lodash": "^4.17.21",
46
46
  "mathjs": "^10.6.4",
47
47
  "mdi-material-ui": "^7.4.0",
48
- "numbro": "^2.3.6",
49
48
  "react-colorful": "^5.6.1",
50
49
  "react-error-boundary": "^3.1.4",
51
50
  "react-virtuoso": "^4.3.6"
52
51
  },
53
52
  "devDependencies": {
54
- "@perses-dev/storybook": "0.35.0"
53
+ "@perses-dev/storybook": "0.36.1"
55
54
  },
56
55
  "peerDependencies": {
57
56
  "@mui/material": "^5.10.0",
@@ -1,84 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- BYTES_GROUP_CONFIG: ()=>BYTES_GROUP_CONFIG,
25
- BYTES_UNIT_CONFIG: ()=>BYTES_UNIT_CONFIG,
26
- formatBytes: ()=>formatBytes
27
- });
28
- const _numbro = /*#__PURE__*/ _interopRequireDefault(require("numbro"));
29
- const _constants = require("./constants");
30
- const _utils = require("./utils");
31
- function _interopRequireDefault(obj) {
32
- return obj && obj.__esModule ? obj : {
33
- default: obj
34
- };
35
- }
36
- const DEFAULT_NUMBRO_MANTISSA = 2;
37
- const bytesUnitKinds = [
38
- 'Bytes'
39
- ];
40
- const BYTES_GROUP_CONFIG = {
41
- label: 'Bytes',
42
- decimal_places: true,
43
- abbreviate: true
44
- };
45
- const BYTES_UNIT_CONFIG = {
46
- // These units are powers of 1000.
47
- // In other words, 1 KB = 1000 bytes.
48
- Bytes: {
49
- group: 'Bytes',
50
- label: 'Bytes'
51
- }
52
- };
53
- function formatBytes(bytes, options) {
54
- const { abbreviate , decimal_places } = options;
55
- if (!(0, _utils.shouldAbbreviate)(abbreviate) || Math.abs(bytes) < 1000) {
56
- const formatterOptions = {
57
- style: 'unit',
58
- unit: 'byte',
59
- unitDisplay: 'long',
60
- useGrouping: true
61
- };
62
- if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
63
- formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
64
- formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
65
- } else {
66
- // This can happen if bytes is between -1000 and 1000
67
- if ((0, _utils.shouldAbbreviate)(abbreviate)) {
68
- formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
69
- }
70
- }
71
- return Intl.NumberFormat('en-US', formatterOptions).format(bytes);
72
- }
73
- // numbro is able to add units like KB, MB, GB, etc. correctly
74
- return (0, _numbro.default)(bytes).format({
75
- output: 'byte',
76
- base: 'decimal',
77
- spaceSeparated: true,
78
- mantissa: (0, _utils.hasDecimalPlaces)(decimal_places) ? decimal_places : DEFAULT_NUMBRO_MANTISSA,
79
- // trimMantissa trims trailing 0s
80
- trimMantissa: !(0, _utils.hasDecimalPlaces)(decimal_places),
81
- // optionalMantissa excludes all the decimal places if they're all zeros
82
- optionalMantissa: !(0, _utils.hasDecimalPlaces)(decimal_places)
83
- });
84
- }
@@ -1,23 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- // Common constants needed across individual unit groups and the overall
14
- // combined units.
15
- "use strict";
16
- Object.defineProperty(exports, "__esModule", {
17
- value: true
18
- });
19
- Object.defineProperty(exports, "MAX_SIGNIFICANT_DIGITS", {
20
- enumerable: true,
21
- get: ()=>MAX_SIGNIFICANT_DIGITS
22
- });
23
- const MAX_SIGNIFICANT_DIGITS = 3;
@@ -1,62 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- DECIMAL_GROUP_CONFIG: ()=>DECIMAL_GROUP_CONFIG,
25
- DECIMAL_UNIT_CONFIG: ()=>DECIMAL_UNIT_CONFIG,
26
- formatDecimal: ()=>formatDecimal
27
- });
28
- const _constants = require("./constants");
29
- const _utils = require("./utils");
30
- const decimalUnitKinds = [
31
- 'Decimal'
32
- ];
33
- const DECIMAL_GROUP_CONFIG = {
34
- label: 'Decimal',
35
- decimal_places: true,
36
- abbreviate: true
37
- };
38
- const DECIMAL_UNIT_CONFIG = {
39
- Decimal: {
40
- group: 'Decimal',
41
- label: 'Decimal'
42
- }
43
- };
44
- function formatDecimal(value, options) {
45
- const { abbreviate , decimal_places } = options;
46
- const formatterOptions = {
47
- style: 'decimal',
48
- useGrouping: true
49
- };
50
- if ((0, _utils.shouldAbbreviate)(abbreviate)) {
51
- formatterOptions.notation = 'compact';
52
- }
53
- if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
54
- formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
55
- formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
56
- } else {
57
- if ((0, _utils.shouldAbbreviate)(abbreviate)) {
58
- formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
59
- }
60
- }
61
- return Intl.NumberFormat('en-US', formatterOptions).format(value);
62
- }
@@ -1,73 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- PERCENT_GROUP_CONFIG: ()=>PERCENT_GROUP_CONFIG,
25
- PERCENT_UNIT_CONFIG: ()=>PERCENT_UNIT_CONFIG,
26
- formatPercent: ()=>formatPercent
27
- });
28
- const _constants = require("./constants");
29
- const _utils = require("./utils");
30
- const percentUnitKinds = [
31
- 'Percent',
32
- 'PercentDecimal',
33
- '%'
34
- ];
35
- const PERCENT_GROUP_CONFIG = {
36
- label: 'Percent',
37
- decimal_places: true
38
- };
39
- const PERCENT_GROUP = 'Percent';
40
- const PERCENT_UNIT_CONFIG = {
41
- Percent: {
42
- group: PERCENT_GROUP,
43
- label: 'Percent (0-100)'
44
- },
45
- PercentDecimal: {
46
- group: PERCENT_GROUP,
47
- label: 'Percent (0.0-1.0)'
48
- },
49
- '%': {
50
- // This option is not shown in the selector because it is a shorthand
51
- // duplicate of `Percent`.
52
- disableSelectorOption: true,
53
- group: PERCENT_GROUP,
54
- label: '%'
55
- }
56
- };
57
- function formatPercent(value, { kind , decimal_places }) {
58
- // Intl.NumberFormat translates 0 -> 0%, 0.5 -> 50%, 1 -> 100%
59
- if (kind === 'Percent') {
60
- value = value / 100;
61
- }
62
- const formatterOptions = {
63
- style: 'percent',
64
- useGrouping: true
65
- };
66
- if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
67
- formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
68
- formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
69
- } else {
70
- formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
71
- }
72
- return Intl.NumberFormat('en-US', formatterOptions).format(value);
73
- }
@@ -1,105 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- PersesTimeToIntlTime: ()=>PersesTimeToIntlTime,
25
- TIME_GROUP_CONFIG: ()=>TIME_GROUP_CONFIG,
26
- TIME_UNIT_CONFIG: ()=>TIME_UNIT_CONFIG,
27
- formatTime: ()=>formatTime
28
- });
29
- const _constants = require("./constants");
30
- const _utils = require("./utils");
31
- const timeUnitKinds = [
32
- 'Milliseconds',
33
- 'Seconds',
34
- 'Minutes',
35
- 'Hours',
36
- 'Days',
37
- 'Weeks',
38
- 'Months',
39
- 'Years'
40
- ];
41
- const TIME_GROUP = 'Time';
42
- const TIME_GROUP_CONFIG = {
43
- label: 'Time',
44
- decimal_places: true
45
- };
46
- const TIME_UNIT_CONFIG = {
47
- Milliseconds: {
48
- group: TIME_GROUP,
49
- label: 'Milliseconds'
50
- },
51
- Seconds: {
52
- group: TIME_GROUP,
53
- label: 'Seconds'
54
- },
55
- Minutes: {
56
- group: TIME_GROUP,
57
- label: 'Minutes'
58
- },
59
- Hours: {
60
- group: TIME_GROUP,
61
- label: 'Hours'
62
- },
63
- Days: {
64
- group: TIME_GROUP,
65
- label: 'Days'
66
- },
67
- Weeks: {
68
- group: TIME_GROUP,
69
- label: 'Weeks'
70
- },
71
- Months: {
72
- group: TIME_GROUP,
73
- label: 'Months'
74
- },
75
- Years: {
76
- group: TIME_GROUP,
77
- label: 'Years'
78
- }
79
- };
80
- var PersesTimeToIntlTime;
81
- (function(PersesTimeToIntlTime) {
82
- PersesTimeToIntlTime["Milliseconds"] = 'millisecond';
83
- PersesTimeToIntlTime["Seconds"] = 'second';
84
- PersesTimeToIntlTime["Minutes"] = 'minute';
85
- PersesTimeToIntlTime["Hours"] = 'hour';
86
- PersesTimeToIntlTime["Days"] = 'day';
87
- PersesTimeToIntlTime["Weeks"] = 'week';
88
- PersesTimeToIntlTime["Months"] = 'month';
89
- PersesTimeToIntlTime["Years"] = 'year';
90
- })(PersesTimeToIntlTime || (PersesTimeToIntlTime = {}));
91
- function formatTime(value, { kind , decimal_places }) {
92
- const isMonthOrYear = kind === 'Months' || kind === 'Years';
93
- const formatterOptions = {
94
- style: 'unit',
95
- unit: PersesTimeToIntlTime[kind],
96
- unitDisplay: isMonthOrYear ? 'long' : 'narrow'
97
- };
98
- if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
99
- formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
100
- formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
101
- } else {
102
- formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
103
- }
104
- return Intl.NumberFormat('en-US', formatterOptions).format(value);
105
- }
@@ -1,28 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- // Common types needed across individual unit groups and the overall combined
14
- // units.
15
- "use strict";
16
- Object.defineProperty(exports, "__esModule", {
17
- value: true
18
- });
19
- Object.defineProperty(exports, "UNIT_GROUPS", {
20
- enumerable: true,
21
- get: ()=>UNIT_GROUPS
22
- });
23
- const UNIT_GROUPS = [
24
- 'Time',
25
- 'Percent',
26
- 'Decimal',
27
- 'Bytes'
28
- ];