@cloudtower/eagle 0.22.16 → 0.22.19

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