@cloudtower/eagle 0.22.14 → 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.
Files changed (27) hide show
  1. package/dist/esm/index.js +216 -15
  2. package/dist/esm/stats1.html +1 -1
  3. package/dist/spec/base.d.ts +7 -0
  4. package/dist/style.css +1258 -1257
  5. package/dist/umd/index.js +218 -17
  6. package/dist/umd/stats1.html +1 -1
  7. package/package.json +7 -6
  8. package/dist/components/BaseIcon/BaseIcon.stories.d.ts +0 -5
  9. package/dist/components/Button/Button.stories.d.ts +0 -18
  10. package/dist/components/Button/HoverableElement.stories.d.ts +0 -5
  11. package/dist/components/Fields/FieldsBoolean/FieldsBoolean.stories.d.ts +0 -5
  12. package/dist/components/Fields/FieldsDateTimeRange/FieldsDateTimeRange.stories.d.ts +0 -11
  13. package/dist/components/Fields/FieldsEnum/FieldsEnum.stories.d.ts +0 -7
  14. package/dist/components/Fields/FieldsInteger/FieldsInteger.stories.d.ts +0 -6
  15. package/dist/components/Fields/FieldsString/FieldsString.stories.d.ts +0 -19
  16. package/dist/components/Fields/FieldsTimePicker/FieldsTimePicker.stories.d.ts +0 -11
  17. package/dist/components/Icon/Icon.stories.d.ts +0 -22
  18. package/dist/components/Input/Input.stories.d.ts +0 -29
  19. package/dist/components/Metric/Metric.stories.d.ts +0 -6
  20. package/dist/components/Modal/Modal.stories.d.ts +0 -5
  21. package/dist/components/SearchInput/SearchInput.stories.d.ts +0 -4
  22. package/dist/components/Select/Select.stories.d.ts +0 -16
  23. package/dist/components/SimplePagination/SimplePagination.stories.d.ts +0 -5
  24. package/dist/components/Space/Space.stories.d.ts +0 -5
  25. package/dist/components/Table/Table.stories.d.ts +0 -9
  26. package/dist/components/TimeZoneSelect/TimeZoneSelect.stories.d.ts +0 -18
  27. package/dist/stories/icons-react.stories.d.ts +0 -5
package/dist/esm/index.js CHANGED
@@ -3,13 +3,13 @@ export { Col, Row } from 'antd';
3
3
  import cs from 'classnames';
4
4
  import React, { useState, useMemo, Fragment, useRef, useEffect, useCallback, useLayoutEffect, createContext, useContext } from 'react';
5
5
  import _, { sortBy, uniqBy } from 'lodash';
6
+ import { parrotI18n } from '@cloudtower/parrot';
7
+ export * from '@cloudtower/parrot';
6
8
  import moment from 'moment';
7
9
  import { findDOMNode } from 'react-dom';
8
10
  import { isElement } from 'react-is';
9
11
  import { styled } from '@linaria/react';
10
12
  import { CloseCircleFilled, CheckOutlined, SearchOutlined } from '@ant-design/icons';
11
- import { parrotI18n } from '@cloudtower/parrot';
12
- export * from '@cloudtower/parrot';
13
13
  import { combineReducers, createStore } from 'redux';
14
14
  import { createDispatchHook, createSelectorHook, Provider } from 'react-redux';
15
15
  import { cx } from '@linaria/core';
@@ -20,10 +20,130 @@ import dayjs from 'dayjs';
20
20
  import 'recharts';
21
21
 
22
22
  const MAGIC_METRIC_NULL = -2;
23
+ function formatBits(bits, decimals = 2) {
24
+ if (bits <= 0 || bits === MAGIC_METRIC_NULL) {
25
+ return {
26
+ value: 0,
27
+ unit: "b"
28
+ };
29
+ }
30
+ const k = 1e3;
31
+ const units = ["b", "Kb", "Mb", "Gb", "Tb", "Pb"];
32
+ let i = Math.floor(Math.log(bits) / Math.log(k));
33
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
34
+ return {
35
+ value: parseFloat((bits / Math.pow(k, i)).toFixed(decimals)),
36
+ unit: units[i]
37
+ };
38
+ }
39
+ function formatFrequency(frequency, decimals = 2) {
40
+ if (frequency <= 0 || frequency === MAGIC_METRIC_NULL) {
41
+ return {
42
+ value: 0,
43
+ unit: "Hz"
44
+ };
45
+ }
46
+ const k = 1e3;
47
+ const units = ["Hz", "KHz", "MHz", "GHz", "THz"];
48
+ let i = Math.floor(Math.log(frequency) / Math.log(k));
49
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
50
+ return {
51
+ value: parseFloat((frequency / Math.pow(k, i)).toFixed(decimals)),
52
+ unit: units[i]
53
+ };
54
+ }
23
55
  const SECOND = 1;
24
56
  const MINUTE = 60 * SECOND;
25
57
  const HOUR = 60 * MINUTE;
26
58
  const DAY = 24 * HOUR;
59
+ const WEEK = 7 * DAY;
60
+ function formatSeconds(seconds, decimals = 0) {
61
+ if (seconds <= MAGIC_METRIC_NULL) {
62
+ seconds = 0;
63
+ }
64
+ const units = [
65
+ {
66
+ value: WEEK,
67
+ unit: "week"
68
+ },
69
+ {
70
+ value: DAY,
71
+ unit: "day"
72
+ },
73
+ {
74
+ value: HOUR,
75
+ unit: "hour"
76
+ },
77
+ {
78
+ value: MINUTE,
79
+ unit: "minute"
80
+ },
81
+ {
82
+ value: SECOND,
83
+ unit: "second"
84
+ }
85
+ ];
86
+ for (const unit of units) {
87
+ if (seconds > unit.value) {
88
+ return {
89
+ value: parseFloat((seconds / unit.value).toFixed(decimals)),
90
+ unit: unit.unit
91
+ };
92
+ }
93
+ }
94
+ return {
95
+ value: parseFloat((seconds / SECOND).toFixed(decimals)),
96
+ unit: "second"
97
+ };
98
+ }
99
+ function formatBitPerSecond(input, decimals = 1) {
100
+ if (input <= 0 || input === MAGIC_METRIC_NULL) {
101
+ return {
102
+ value: 0,
103
+ unit: "bps"
104
+ };
105
+ }
106
+ const k = 1e3;
107
+ const units = ["bps", "Kbps", "Mbps", "Gbps", "Tbps"];
108
+ let i = Math.floor(Math.log(input) / Math.log(k));
109
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
110
+ return {
111
+ value: parseFloat((input / Math.pow(k, i)).toFixed(decimals)),
112
+ unit: units[i]
113
+ };
114
+ }
115
+ function formatBps(input, decimals = 1) {
116
+ if (input <= 0 || input === MAGIC_METRIC_NULL) {
117
+ return {
118
+ value: 0,
119
+ unit: "Bps"
120
+ };
121
+ }
122
+ const k = 1e3;
123
+ const units = ["Bps", "KBps", "MBps", "GBps", "TBps"];
124
+ let i = Math.floor(Math.log(input) / Math.log(k));
125
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
126
+ return {
127
+ value: parseFloat((input / Math.pow(k, i)).toFixed(decimals)),
128
+ unit: units[i]
129
+ };
130
+ }
131
+ function formatBytes(bytes, decimals = 2) {
132
+ if (bytes <= 0 || bytes === MAGIC_METRIC_NULL) {
133
+ return {
134
+ value: 0,
135
+ unit: "B"
136
+ };
137
+ }
138
+ const k = 1024;
139
+ const units = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
140
+ let i = Math.floor(Math.log(bytes) / Math.log(k));
141
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
142
+ return {
143
+ value: parseFloat((bytes / Math.pow(k, i)).toFixed(decimals)),
144
+ unit: units[i]
145
+ };
146
+ }
27
147
  function formatPercent(input, decimals = 2) {
28
148
  if (input <= 0 || input === MAGIC_METRIC_NULL) {
29
149
  input = 0;
@@ -49,6 +169,19 @@ function formatPercent(input, decimals = 2) {
49
169
  unit: "%"
50
170
  };
51
171
  }
172
+ function formatSpeed(input, decimals = 0) {
173
+ input /= 1e3;
174
+ if (input < 1)
175
+ return { value: "-", unit: "" };
176
+ const units = ["KbE", "MbE", "GbE", "TbE"];
177
+ const k = 1e3;
178
+ let i = Math.floor(Math.log(input) / Math.log(k));
179
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
180
+ return {
181
+ value: parseFloat((input / Math.pow(k, i)).toFixed(decimals)),
182
+ unit: units[i]
183
+ };
184
+ }
52
185
 
53
186
  const EMPTY_FUNCTION = () => {
54
187
  };
@@ -212,15 +345,14 @@ const Icon = React.forwardRef((props, ref) => {
212
345
  onMouseMove,
213
346
  className,
214
347
  iconWidth = 16,
215
- iconHeight,
348
+ iconHeight = 16,
216
349
  cursor,
217
350
  style,
218
- children,
219
351
  isRotate,
220
352
  prefix,
221
353
  suffix
222
354
  } = _a,
223
- restProps = __objRest$n(_a, ["src", "hoverSrc", "active", "activeSrc", "onMouseEnter", "onMouseLeave", "onMouseMove", "className", "iconWidth", "iconHeight", "cursor", "style", "children", "isRotate", "prefix", "suffix"]);
355
+ restProps = __objRest$n(_a, ["src", "hoverSrc", "active", "activeSrc", "onMouseEnter", "onMouseLeave", "onMouseMove", "className", "iconWidth", "iconHeight", "cursor", "style", "isRotate", "prefix", "suffix"]);
224
356
  const [hover, setHover] = useState(false);
225
357
  const _src = useMemo(() => {
226
358
  if (active && activeSrc) {
@@ -343,6 +475,39 @@ const Alert = (_a) => {
343
475
  );
344
476
  };
345
477
 
478
+ function isEmpty(rawValue) {
479
+ if (rawValue === null || rawValue === void 0 || rawValue === MAGIC_METRIC_NULL || Number.isNaN(rawValue)) {
480
+ return true;
481
+ }
482
+ return false;
483
+ }
484
+
485
+ const Empty = /* @__PURE__ */ React.createElement(React.Fragment, null, "-");
486
+
487
+ const Bit = ({ rawValue, decimals }) => {
488
+ if (isEmpty(rawValue)) {
489
+ return Empty;
490
+ }
491
+ const { value, unit } = formatBits(rawValue, decimals);
492
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value), /* @__PURE__ */ React.createElement("span", { className: "unit" }, ` ${unit}`));
493
+ };
494
+
495
+ const BitPerSeconds = ({ rawValue, decimals }) => {
496
+ if (isEmpty(rawValue)) {
497
+ return Empty;
498
+ }
499
+ const { value, unit } = formatBitPerSecond(rawValue, decimals);
500
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value), /* @__PURE__ */ React.createElement("span", { className: "unit" }, ` ${unit}`));
501
+ };
502
+
503
+ const Bps = ({ rawValue, decimals }) => {
504
+ if (isEmpty(rawValue)) {
505
+ return Empty;
506
+ }
507
+ const { value, unit } = formatBps(rawValue, decimals);
508
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value), /* @__PURE__ */ React.createElement("span", { className: "unit" }, ` ${unit}`));
509
+ };
510
+
346
511
  const d1_bold_title = "d6j0lbj";
347
512
  const d1s_bold_title = "d1xhvvxe";
348
513
  const d1_regular_title = "dk10mxq";
@@ -556,6 +721,20 @@ const Button = React.forwardRef((props, ref) => {
556
721
  }));
557
722
  });
558
723
 
724
+ const Byte = ({ rawValue, noUnitOnZero, decimals }) => {
725
+ if (isEmpty(rawValue)) {
726
+ return Empty;
727
+ }
728
+ if (rawValue === -1) {
729
+ return /* @__PURE__ */ React.createElement("span", null, parrotI18n.t("common.calculation"));
730
+ }
731
+ const { value, unit } = formatBytes(rawValue, decimals);
732
+ if (noUnitOnZero && value === 0) {
733
+ return /* @__PURE__ */ React.createElement("span", { className: "value" }, value);
734
+ }
735
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value), /* @__PURE__ */ React.createElement("span", { className: "unit" }, ` ${unit}`));
736
+ };
737
+
559
738
  var __defProp$o = Object.defineProperty;
560
739
  var __defProps$i = Object.defineProperties;
561
740
  var __getOwnPropDescs$i = Object.getOwnPropertyDescriptors;
@@ -1814,6 +1993,14 @@ const fields = {
1814
1993
  DateTimeRange: FieldsDateTimeRange
1815
1994
  };
1816
1995
 
1996
+ const Frequency = ({ rawValue, decimals }) => {
1997
+ if (isEmpty(rawValue)) {
1998
+ return Empty;
1999
+ }
2000
+ const { value, unit } = formatFrequency(rawValue, decimals);
2001
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value), /* @__PURE__ */ React.createElement("span", { className: "unit" }, ` ${unit}`));
2002
+ };
2003
+
1817
2004
  const _exp = () => Input$1.Group;
1818
2005
  const InputGroup = /*#__PURE__*/styled(_exp())({
1819
2006
  name: "InputGroup",
@@ -2289,15 +2476,6 @@ const Pagination = props => {
2289
2476
  }))));
2290
2477
  };
2291
2478
 
2292
- function isEmpty(rawValue) {
2293
- if (rawValue === null || rawValue === void 0 || rawValue === MAGIC_METRIC_NULL || Number.isNaN(rawValue)) {
2294
- return true;
2295
- }
2296
- return false;
2297
- }
2298
-
2299
- const Empty = /* @__PURE__ */ React.createElement(React.Fragment, null, "-");
2300
-
2301
2479
  const Percent = ({
2302
2480
  rawValue,
2303
2481
  decimals,
@@ -2479,6 +2657,14 @@ const SearchInput = (props) => {
2479
2657
  );
2480
2658
  };
2481
2659
 
2660
+ const Second = ({ rawValue, decimals, abbreviate }) => {
2661
+ if (isEmpty(rawValue)) {
2662
+ return Empty;
2663
+ }
2664
+ const { value, unit } = formatSeconds(rawValue, decimals);
2665
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value, " "), /* @__PURE__ */ React.createElement("span", { className: "unit" }, parrotI18n.t(`common.${abbreviate ? `${unit}_abbreviation` : unit}`)));
2666
+ };
2667
+
2482
2668
  const inputStyle = "igz4le8";
2483
2669
  const SimplePagination = props => {
2484
2670
  const {
@@ -2550,6 +2736,14 @@ const SimplePagination = props => {
2550
2736
  })));
2551
2737
  };
2552
2738
 
2739
+ const Speed = ({ rawValue, decimals }) => {
2740
+ if (isEmpty(rawValue)) {
2741
+ return Empty;
2742
+ }
2743
+ const { value, unit } = formatSpeed(rawValue, decimals);
2744
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: "value" }, value), /* @__PURE__ */ React.createElement("span", { className: "unit" }, ` ${unit}`));
2745
+ };
2746
+
2553
2747
  function canScroll(el, direction = "vertical") {
2554
2748
  const overflow = window.getComputedStyle(el).getPropertyValue("overflow");
2555
2749
  if (overflow === "hidden")
@@ -2934,7 +3128,14 @@ function getAntdKit() {
2934
3128
  checkbox: Checkbox,
2935
3129
  fields,
2936
3130
  units: {
2937
- Percent
3131
+ Percent,
3132
+ Byte,
3133
+ Frequency,
3134
+ Speed,
3135
+ Bps,
3136
+ BitPerSecond: BitPerSeconds,
3137
+ Bit,
3138
+ Second
2938
3139
  },
2939
3140
  inputGroup: InputGroup,
2940
3141
  alert: Alert,