@cloudtower/eagle 0.22.16 → 0.22.18

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.
package/dist/umd/index.js CHANGED
@@ -1,14 +1,134 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('antd'), require('classnames'), require('react'), require('lodash'), require('moment'), require('react-dom'), require('react-is'), require('@linaria/react'), require('@ant-design/icons'), require('@cloudtower/parrot'), require('redux'), require('react-redux'), require('@linaria/core'), require('rc-util/lib/getScrollBarSize'), require('timezones.json'), require('react-i18next'), require('dayjs'), require('recharts')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'antd', 'classnames', 'react', 'lodash', 'moment', 'react-dom', 'react-is', '@linaria/react', '@ant-design/icons', '@cloudtower/parrot', 'redux', 'react-redux', '@linaria/core', 'rc-util/lib/getScrollBarSize', 'timezones.json', 'react-i18next', 'dayjs', 'recharts'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.index = {}, global.antd, global.cs, global.React, global._, global.moment, global.reactDom, global.reactIs, global.react, global.icons, global.parrot, global.redux, global.reactRedux, global.core, null, global.TimeZones, global.reactI18next, global.dayjs));
5
- })(this, (function (exports, antd, cs, React, _, moment, reactDom, reactIs, react, icons, parrot, redux, reactRedux, core, getScrollBarSize, TimeZones, reactI18next, dayjs) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('antd'), require('classnames'), require('react'), require('lodash'), require('@cloudtower/parrot'), require('moment'), require('react-dom'), require('react-is'), require('@linaria/react'), require('@ant-design/icons'), require('redux'), require('react-redux'), require('@linaria/core'), require('rc-util/lib/getScrollBarSize'), require('timezones.json'), require('react-i18next'), require('dayjs'), require('recharts')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'antd', 'classnames', 'react', 'lodash', '@cloudtower/parrot', 'moment', 'react-dom', 'react-is', '@linaria/react', '@ant-design/icons', 'redux', 'react-redux', '@linaria/core', 'rc-util/lib/getScrollBarSize', 'timezones.json', 'react-i18next', 'dayjs', 'recharts'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.index = {}, global.antd, global.cs, global.React, global._, global.parrot, global.moment, global.reactDom, global.reactIs, global.react, global.icons, global.redux, global.reactRedux, global.core, null, global.TimeZones, global.reactI18next, global.dayjs));
5
+ })(this, (function (exports, antd, cs, React, _, parrot, moment, reactDom, reactIs, react, icons, redux, reactRedux, core, getScrollBarSize, TimeZones, reactI18next, dayjs) { 'use strict';
6
6
 
7
7
  const MAGIC_METRIC_NULL = -2;
8
+ function formatBits(bits, decimals = 2) {
9
+ if (bits <= 0 || bits === MAGIC_METRIC_NULL) {
10
+ return {
11
+ value: 0,
12
+ unit: "b"
13
+ };
14
+ }
15
+ const k = 1e3;
16
+ const units = ["b", "Kb", "Mb", "Gb", "Tb", "Pb"];
17
+ let i = Math.floor(Math.log(bits) / Math.log(k));
18
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
19
+ return {
20
+ value: parseFloat((bits / Math.pow(k, i)).toFixed(decimals)),
21
+ unit: units[i]
22
+ };
23
+ }
24
+ function formatFrequency(frequency, decimals = 2) {
25
+ if (frequency <= 0 || frequency === MAGIC_METRIC_NULL) {
26
+ return {
27
+ value: 0,
28
+ unit: "Hz"
29
+ };
30
+ }
31
+ const k = 1e3;
32
+ const units = ["Hz", "KHz", "MHz", "GHz", "THz"];
33
+ let i = Math.floor(Math.log(frequency) / Math.log(k));
34
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
35
+ return {
36
+ value: parseFloat((frequency / Math.pow(k, i)).toFixed(decimals)),
37
+ unit: units[i]
38
+ };
39
+ }
8
40
  const SECOND = 1;
9
41
  const MINUTE = 60 * SECOND;
10
42
  const HOUR = 60 * MINUTE;
11
43
  const DAY = 24 * HOUR;
44
+ const WEEK = 7 * DAY;
45
+ function formatSeconds(seconds, decimals = 0) {
46
+ if (seconds <= MAGIC_METRIC_NULL) {
47
+ seconds = 0;
48
+ }
49
+ const units = [
50
+ {
51
+ value: WEEK,
52
+ unit: "week"
53
+ },
54
+ {
55
+ value: DAY,
56
+ unit: "day"
57
+ },
58
+ {
59
+ value: HOUR,
60
+ unit: "hour"
61
+ },
62
+ {
63
+ value: MINUTE,
64
+ unit: "minute"
65
+ },
66
+ {
67
+ value: SECOND,
68
+ unit: "second"
69
+ }
70
+ ];
71
+ for (const unit of units) {
72
+ if (seconds > unit.value) {
73
+ return {
74
+ value: parseFloat((seconds / unit.value).toFixed(decimals)),
75
+ unit: unit.unit
76
+ };
77
+ }
78
+ }
79
+ return {
80
+ value: parseFloat((seconds / SECOND).toFixed(decimals)),
81
+ unit: "second"
82
+ };
83
+ }
84
+ function formatBitPerSecond(input, decimals = 1) {
85
+ if (input <= 0 || input === MAGIC_METRIC_NULL) {
86
+ return {
87
+ value: 0,
88
+ unit: "bps"
89
+ };
90
+ }
91
+ const k = 1e3;
92
+ const units = ["bps", "Kbps", "Mbps", "Gbps", "Tbps"];
93
+ let i = Math.floor(Math.log(input) / Math.log(k));
94
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
95
+ return {
96
+ value: parseFloat((input / Math.pow(k, i)).toFixed(decimals)),
97
+ unit: units[i]
98
+ };
99
+ }
100
+ function formatBps(input, decimals = 1) {
101
+ if (input <= 0 || input === MAGIC_METRIC_NULL) {
102
+ return {
103
+ value: 0,
104
+ unit: "Bps"
105
+ };
106
+ }
107
+ const k = 1e3;
108
+ const units = ["Bps", "KBps", "MBps", "GBps", "TBps"];
109
+ let i = Math.floor(Math.log(input) / Math.log(k));
110
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
111
+ return {
112
+ value: parseFloat((input / Math.pow(k, i)).toFixed(decimals)),
113
+ unit: units[i]
114
+ };
115
+ }
116
+ function formatBytes(bytes, decimals = 2) {
117
+ if (bytes <= 0 || bytes === MAGIC_METRIC_NULL) {
118
+ return {
119
+ value: 0,
120
+ unit: "B"
121
+ };
122
+ }
123
+ const k = 1024;
124
+ const units = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
125
+ let i = Math.floor(Math.log(bytes) / Math.log(k));
126
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
127
+ return {
128
+ value: parseFloat((bytes / Math.pow(k, i)).toFixed(decimals)),
129
+ unit: units[i]
130
+ };
131
+ }
12
132
  function formatPercent(input, decimals = 2) {
13
133
  if (input <= 0 || input === MAGIC_METRIC_NULL) {
14
134
  input = 0;
@@ -34,6 +154,19 @@
34
154
  unit: "%"
35
155
  };
36
156
  }
157
+ function formatSpeed(input, decimals = 0) {
158
+ input /= 1e3;
159
+ if (input < 1)
160
+ return { value: "-", unit: "" };
161
+ const units = ["KbE", "MbE", "GbE", "TbE"];
162
+ const k = 1e3;
163
+ let i = Math.floor(Math.log(input) / Math.log(k));
164
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
165
+ return {
166
+ value: parseFloat((input / Math.pow(k, i)).toFixed(decimals)),
167
+ unit: units[i]
168
+ };
169
+ }
37
170
 
38
171
  const EMPTY_FUNCTION = () => {
39
172
  };
@@ -200,12 +333,11 @@
200
333
  iconHeight = 16,
201
334
  cursor,
202
335
  style,
203
- children,
204
336
  isRotate,
205
337
  prefix,
206
338
  suffix
207
339
  } = _a,
208
- restProps = __objRest$n(_a, ["src", "hoverSrc", "active", "activeSrc", "onMouseEnter", "onMouseLeave", "onMouseMove", "className", "iconWidth", "iconHeight", "cursor", "style", "children", "isRotate", "prefix", "suffix"]);
340
+ restProps = __objRest$n(_a, ["src", "hoverSrc", "active", "activeSrc", "onMouseEnter", "onMouseLeave", "onMouseMove", "className", "iconWidth", "iconHeight", "cursor", "style", "isRotate", "prefix", "suffix"]);
209
341
  const [hover, setHover] = React.useState(false);
210
342
  const _src = React.useMemo(() => {
211
343
  if (active && activeSrc) {
@@ -328,6 +460,39 @@
328
460
  );
329
461
  };
330
462
 
463
+ function isEmpty(rawValue) {
464
+ if (rawValue === null || rawValue === void 0 || rawValue === MAGIC_METRIC_NULL || Number.isNaN(rawValue)) {
465
+ return true;
466
+ }
467
+ return false;
468
+ }
469
+
470
+ const Empty = /* @__PURE__ */ React.createElement(React.Fragment, null, "-");
471
+
472
+ const Bit = ({ rawValue, decimals }) => {
473
+ if (isEmpty(rawValue)) {
474
+ return Empty;
475
+ }
476
+ const { value, unit } = formatBits(rawValue, decimals);
477
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value), /* @__PURE__ */ React.createElement("span", { className: "unit" }, ` ${unit}`));
478
+ };
479
+
480
+ const BitPerSeconds = ({ rawValue, decimals }) => {
481
+ if (isEmpty(rawValue)) {
482
+ return Empty;
483
+ }
484
+ const { value, unit } = formatBitPerSecond(rawValue, decimals);
485
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value), /* @__PURE__ */ React.createElement("span", { className: "unit" }, ` ${unit}`));
486
+ };
487
+
488
+ const Bps = ({ rawValue, decimals }) => {
489
+ if (isEmpty(rawValue)) {
490
+ return Empty;
491
+ }
492
+ const { value, unit } = formatBps(rawValue, decimals);
493
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value), /* @__PURE__ */ React.createElement("span", { className: "unit" }, ` ${unit}`));
494
+ };
495
+
331
496
  const d1_bold_title = "d6j0lbj";
332
497
  const d1s_bold_title = "d1xhvvxe";
333
498
  const d1_regular_title = "dk10mxq";
@@ -541,6 +706,20 @@
541
706
  }));
542
707
  });
543
708
 
709
+ const Byte = ({ rawValue, noUnitOnZero, decimals }) => {
710
+ if (isEmpty(rawValue)) {
711
+ return Empty;
712
+ }
713
+ if (rawValue === -1) {
714
+ return /* @__PURE__ */ React.createElement("span", null, parrot.parrotI18n.t("common.calculation"));
715
+ }
716
+ const { value, unit } = formatBytes(rawValue, decimals);
717
+ if (noUnitOnZero && value === 0) {
718
+ return /* @__PURE__ */ React.createElement("span", { className: "value" }, value);
719
+ }
720
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value), /* @__PURE__ */ React.createElement("span", { className: "unit" }, ` ${unit}`));
721
+ };
722
+
544
723
  var __defProp$o = Object.defineProperty;
545
724
  var __defProps$i = Object.defineProperties;
546
725
  var __getOwnPropDescs$i = Object.getOwnPropertyDescriptors;
@@ -1799,6 +1978,14 @@
1799
1978
  DateTimeRange: FieldsDateTimeRange
1800
1979
  };
1801
1980
 
1981
+ const Frequency = ({ rawValue, decimals }) => {
1982
+ if (isEmpty(rawValue)) {
1983
+ return Empty;
1984
+ }
1985
+ const { value, unit } = formatFrequency(rawValue, decimals);
1986
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value), /* @__PURE__ */ React.createElement("span", { className: "unit" }, ` ${unit}`));
1987
+ };
1988
+
1802
1989
  const _exp = () => antd.Input.Group;
1803
1990
  const InputGroup = /*#__PURE__*/react.styled(_exp())({
1804
1991
  name: "InputGroup",
@@ -2274,15 +2461,6 @@
2274
2461
  }))));
2275
2462
  };
2276
2463
 
2277
- function isEmpty(rawValue) {
2278
- if (rawValue === null || rawValue === void 0 || rawValue === MAGIC_METRIC_NULL || Number.isNaN(rawValue)) {
2279
- return true;
2280
- }
2281
- return false;
2282
- }
2283
-
2284
- const Empty = /* @__PURE__ */ React.createElement(React.Fragment, null, "-");
2285
-
2286
2464
  const Percent = ({
2287
2465
  rawValue,
2288
2466
  decimals,
@@ -2464,6 +2642,14 @@
2464
2642
  );
2465
2643
  };
2466
2644
 
2645
+ const Second = ({ rawValue, decimals, abbreviate }) => {
2646
+ if (isEmpty(rawValue)) {
2647
+ return Empty;
2648
+ }
2649
+ const { value, unit } = formatSeconds(rawValue, decimals);
2650
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value, " "), /* @__PURE__ */ React.createElement("span", { className: "unit" }, parrot.parrotI18n.t(`common.${abbreviate ? `${unit}_abbreviation` : unit}`)));
2651
+ };
2652
+
2467
2653
  const inputStyle = "igz4le8";
2468
2654
  const SimplePagination = props => {
2469
2655
  const {
@@ -2535,6 +2721,14 @@
2535
2721
  })));
2536
2722
  };
2537
2723
 
2724
+ const Speed = ({ rawValue, decimals }) => {
2725
+ if (isEmpty(rawValue)) {
2726
+ return Empty;
2727
+ }
2728
+ const { value, unit } = formatSpeed(rawValue, decimals);
2729
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value), /* @__PURE__ */ React.createElement("span", { className: "unit" }, ` ${unit}`));
2730
+ };
2731
+
2538
2732
  function canScroll(el, direction = "vertical") {
2539
2733
  const overflow = window.getComputedStyle(el).getPropertyValue("overflow");
2540
2734
  if (overflow === "hidden")
@@ -2919,7 +3113,14 @@
2919
3113
  checkbox: Checkbox,
2920
3114
  fields,
2921
3115
  units: {
2922
- Percent
3116
+ Percent,
3117
+ Byte,
3118
+ Frequency,
3119
+ Speed,
3120
+ Bps,
3121
+ BitPerSecond: BitPerSeconds,
3122
+ Bit,
3123
+ Second
2923
3124
  },
2924
3125
  inputGroup: InputGroup,
2925
3126
  alert: Alert,