@cloudtower/eagle 0.35.6 → 0.35.8

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 (34) hide show
  1. package/dist/cjs/core/Duration/index.js +78 -0
  2. package/dist/cjs/core/index.js +15 -12
  3. package/dist/cjs/hooks/useFormatDuration.js +35 -0
  4. package/dist/cjs/index.js +247 -245
  5. package/dist/cjs/stats1.html +1 -1
  6. package/dist/cjs/utils/formatDuration.js +67 -0
  7. package/dist/components.css +1506 -1506
  8. package/dist/esm/core/Duration/index.js +72 -0
  9. package/dist/esm/core/index.js +4 -2
  10. package/dist/esm/hooks/useFormatDuration.js +33 -0
  11. package/dist/esm/index.js +1 -0
  12. package/dist/esm/stats1.html +1 -1
  13. package/dist/esm/utils/formatDuration.js +65 -0
  14. package/dist/linaria.merged.scss +1897 -1897
  15. package/dist/src/core/Duration/duration.type.d.ts +42 -0
  16. package/dist/src/core/Duration/index.d.ts +4 -0
  17. package/dist/src/core/index.d.ts +4 -0
  18. package/dist/src/coreX/Copy/CopyButton.d.ts +5 -0
  19. package/dist/src/coreX/Copy/CopyButton.type.d.ts +8 -0
  20. package/dist/src/coreX/Copy/CopyTooltip.d.ts +5 -0
  21. package/dist/src/coreX/Copy/CopyTooltip.typs.d.ts +16 -0
  22. package/dist/src/coreX/Copy/index.d.ts +2 -0
  23. package/dist/src/coreX/index.d.ts +1 -0
  24. package/dist/src/hooks/__tests__/useFormatDuration.test.d.ts +1 -0
  25. package/dist/src/hooks/index.d.ts +1 -0
  26. package/dist/src/hooks/useFormatDuration.d.ts +31 -0
  27. package/dist/src/utils/__test__/formatDuration.spec.d.ts +1 -0
  28. package/dist/src/utils/formatDuration.d.ts +28 -0
  29. package/dist/src/utils/index.d.ts +1 -0
  30. package/dist/stories/docs/core/Duration.stories.d.ts +88 -0
  31. package/dist/stories/docs/coreX/Copy/CopyButton.stories.d.ts +66 -0
  32. package/dist/stories/docs/coreX/Copy/CopyTooltip.stories.d.ts +66 -0
  33. package/dist/style.css +1506 -1506
  34. package/package.json +6 -4
@@ -0,0 +1,72 @@
1
+ import React__default from 'react';
2
+ import { cx } from '@linaria/core';
3
+ import Empty from '../Empty/index.js';
4
+ import { ParrotTrans } from '../ParrotTrans/index.js';
5
+ import { useFormatDuration } from '../../hooks/useFormatDuration.js';
6
+ import isEmpty from '../../utils/isEmpty.js';
7
+ import { formatDuration } from '../../utils/formatDuration.js';
8
+ import { UnitStyle } from '../Styled/index.js';
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __spreadValues = (a, b) => {
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ if (__getOwnPropSymbols)
20
+ for (var prop of __getOwnPropSymbols(b)) {
21
+ if (__propIsEnum.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ }
24
+ return a;
25
+ };
26
+ const Duration = ({
27
+ rawValue,
28
+ valueClassName,
29
+ unitClassName,
30
+ abbreviate,
31
+ emptyProps,
32
+ maxDisplayUnits = 2,
33
+ minUnit = "second",
34
+ noUnitOnZero = false,
35
+ contentRender
36
+ }) => {
37
+ const { parts } = useFormatDuration(rawValue != null ? rawValue : 0, {
38
+ maxDisplayUnits,
39
+ useAbbreviation: abbreviate,
40
+ minUnit
41
+ });
42
+ if (isEmpty(rawValue)) {
43
+ return /* @__PURE__ */ React__default.createElement(Empty, __spreadValues({}, emptyProps));
44
+ }
45
+ if (parts.length === 0) {
46
+ return /* @__PURE__ */ React__default.createElement(Empty, __spreadValues({}, emptyProps));
47
+ }
48
+ if (contentRender) {
49
+ const formatItems = formatDuration(rawValue, {
50
+ maxDisplayUnits,
51
+ minUnit
52
+ });
53
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, contentRender(formatItems));
54
+ }
55
+ const allZero = parts.every((part) => part.value === 0);
56
+ if (noUnitOnZero && allZero) {
57
+ return /* @__PURE__ */ React__default.createElement("span", { className: cx("value", valueClassName) }, "0");
58
+ }
59
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, parts.map((part, index) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, { key: `${part.unit}-${index}` }, index > 0 && /* @__PURE__ */ React__default.createElement("span", null, " "), /* @__PURE__ */ React__default.createElement(
60
+ ParrotTrans,
61
+ {
62
+ parent: "span",
63
+ i18nKey: part.i18nKey,
64
+ count: part.value
65
+ },
66
+ /* @__PURE__ */ React__default.createElement("span", { className: cx("value", valueClassName) }),
67
+ /* @__PURE__ */ React__default.createElement("span", { className: cx("unit", UnitStyle, unitClassName) })
68
+ ))));
69
+ };
70
+ var Duration$1 = Duration;
71
+
72
+ export { Duration$1 as default };
@@ -3,6 +3,7 @@ import BitPerSecond from './BitPerSecond/index.js';
3
3
  import Bps from './Bps/index.js';
4
4
  import Byte from './Byte/index.js';
5
5
  import BytePerSecond from './BytePerSecond/index.js';
6
+ import Duration from './Duration/index.js';
6
7
  import Frequency from './Frequency/index.js';
7
8
  import Percent from './Percent/index.js';
8
9
  import Second from './Second/index.js';
@@ -17,7 +18,8 @@ const units = {
17
18
  Bps,
18
19
  BitPerSecond,
19
20
  Bit,
20
- Second
21
+ Second,
22
+ Duration
21
23
  };
22
24
 
23
- export { Bit, BitPerSecond, Bps, Byte, BytePerSecond, Frequency, Percent, Second, Speed, units as Units, units };
25
+ export { Bit, BitPerSecond, Bps, Byte, BytePerSecond, Duration, Frequency, Percent, Second, Speed, units as Units, units };
@@ -0,0 +1,33 @@
1
+ import { useMemo } from 'react';
2
+ import { formatDuration } from '../utils/formatDuration.js';
3
+
4
+ function useFormatDuration(milliseconds, options = {
5
+ maxDisplayUnits: 2,
6
+ useAbbreviation: false,
7
+ minUnit: "second"
8
+ }) {
9
+ const {
10
+ maxDisplayUnits = 2,
11
+ useAbbreviation = false,
12
+ minUnit = "second"
13
+ } = options;
14
+ const result = useMemo(() => {
15
+ const items = formatDuration(milliseconds, { maxDisplayUnits, minUnit });
16
+ const shouldUseAbbreviation = items.length > 1 && useAbbreviation;
17
+ const parts = items.map((item) => {
18
+ const suffix = shouldUseAbbreviation ? "_abbreviation" : "";
19
+ const i18nKey = `unit.${item.unit}${suffix}`;
20
+ return {
21
+ value: item.value,
22
+ unit: item.unit,
23
+ i18nKey
24
+ };
25
+ });
26
+ return {
27
+ parts
28
+ };
29
+ }, [milliseconds, maxDisplayUnits, useAbbreviation, minUnit]);
30
+ return result;
31
+ }
32
+
33
+ export { useFormatDuration };
package/dist/esm/index.js CHANGED
@@ -31,6 +31,7 @@ export { default as DeprecatedProgress } from './core/DeprecatedProgress/index.j
31
31
  export { default as DetailCard } from './core/DetailCard/index.js';
32
32
  export { default as DonutChart, DonutChartColor, formatChartData, formatCollapse } from './core/DonutChart/index.js';
33
33
  export { default as DropdownMenu, RenderMenuItem } from './core/DropdownMenu/index.js';
34
+ export { default as Duration } from './core/Duration/index.js';
34
35
  export { default as Empty } from './core/Empty/index.js';
35
36
  export { default as Error } from './core/Error/index.js';
36
37
  export { default as ErrorBoundary } from './core/ErrorBoundary/index.js';