@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,78 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var core = require('@linaria/core');
5
+ var index = require('../Empty/index.js');
6
+ var index$1 = require('../ParrotTrans/index.js');
7
+ var useFormatDuration = require('../../hooks/useFormatDuration.js');
8
+ var isEmpty = require('../../utils/isEmpty.js');
9
+ var formatDuration = require('../../utils/formatDuration.js');
10
+ var index$2 = require('../Styled/index.js');
11
+
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ var React__default = /*#__PURE__*/_interopDefault(React);
15
+
16
+ var __defProp = Object.defineProperty;
17
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
18
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
19
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
20
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
21
+ var __spreadValues = (a, b) => {
22
+ for (var prop in b || (b = {}))
23
+ if (__hasOwnProp.call(b, prop))
24
+ __defNormalProp(a, prop, b[prop]);
25
+ if (__getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(b)) {
27
+ if (__propIsEnum.call(b, prop))
28
+ __defNormalProp(a, prop, b[prop]);
29
+ }
30
+ return a;
31
+ };
32
+ const Duration = ({
33
+ rawValue,
34
+ valueClassName,
35
+ unitClassName,
36
+ abbreviate,
37
+ emptyProps,
38
+ maxDisplayUnits = 2,
39
+ minUnit = "second",
40
+ noUnitOnZero = false,
41
+ contentRender
42
+ }) => {
43
+ const { parts } = useFormatDuration.useFormatDuration(rawValue != null ? rawValue : 0, {
44
+ maxDisplayUnits,
45
+ useAbbreviation: abbreviate,
46
+ minUnit
47
+ });
48
+ if (isEmpty(rawValue)) {
49
+ return /* @__PURE__ */ React__default.default.createElement(index, __spreadValues({}, emptyProps));
50
+ }
51
+ if (parts.length === 0) {
52
+ return /* @__PURE__ */ React__default.default.createElement(index, __spreadValues({}, emptyProps));
53
+ }
54
+ if (contentRender) {
55
+ const formatItems = formatDuration.formatDuration(rawValue, {
56
+ maxDisplayUnits,
57
+ minUnit
58
+ });
59
+ return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, contentRender(formatItems));
60
+ }
61
+ const allZero = parts.every((part) => part.value === 0);
62
+ if (noUnitOnZero && allZero) {
63
+ return /* @__PURE__ */ React__default.default.createElement("span", { className: core.cx("value", valueClassName) }, "0");
64
+ }
65
+ return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, parts.map((part, index) => /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, { key: `${part.unit}-${index}` }, index > 0 && /* @__PURE__ */ React__default.default.createElement("span", null, " "), /* @__PURE__ */ React__default.default.createElement(
66
+ index$1.ParrotTrans,
67
+ {
68
+ parent: "span",
69
+ i18nKey: part.i18nKey,
70
+ count: part.value
71
+ },
72
+ /* @__PURE__ */ React__default.default.createElement("span", { className: core.cx("value", valueClassName) }),
73
+ /* @__PURE__ */ React__default.default.createElement("span", { className: core.cx("unit", index$2.UnitStyle, unitClassName) })
74
+ ))));
75
+ };
76
+ var Duration$1 = Duration;
77
+
78
+ module.exports = Duration$1;
@@ -5,21 +5,23 @@ var index$8 = require('./BitPerSecond/index.js');
5
5
  var index$a = require('./Bps/index.js');
6
6
  var index$e = require('./Byte/index.js');
7
7
  var index$f = require('./BytePerSecond/index.js');
8
- var index$u = require('./Frequency/index.js');
9
- var index$O = require('./Percent/index.js');
10
- var index$R = require('./Second/index.js');
11
- var index$V = require('./Speed/index.js');
8
+ var index$n = require('./Duration/index.js');
9
+ var index$v = require('./Frequency/index.js');
10
+ var index$P = require('./Percent/index.js');
11
+ var index$S = require('./Second/index.js');
12
+ var index$W = require('./Speed/index.js');
12
13
 
13
14
  const units = {
14
- Percent: index$O,
15
+ Percent: index$P,
15
16
  Byte: index$e,
16
17
  BytePerSecond: index$f,
17
- Frequency: index$u,
18
- Speed: index$V,
18
+ Frequency: index$v,
19
+ Speed: index$W,
19
20
  Bps: index$a,
20
21
  BitPerSecond: index$8,
21
22
  Bit: index$7,
22
- Second: index$R
23
+ Second: index$S,
24
+ Duration: index$n
23
25
  };
24
26
 
25
27
  exports.Bit = index$7;
@@ -27,9 +29,10 @@ exports.BitPerSecond = index$8;
27
29
  exports.Bps = index$a;
28
30
  exports.Byte = index$e;
29
31
  exports.BytePerSecond = index$f;
30
- exports.Frequency = index$u;
31
- exports.Percent = index$O;
32
- exports.Second = index$R;
33
- exports.Speed = index$V;
32
+ exports.Duration = index$n;
33
+ exports.Frequency = index$v;
34
+ exports.Percent = index$P;
35
+ exports.Second = index$S;
36
+ exports.Speed = index$W;
34
37
  exports.Units = units;
35
38
  exports.units = units;
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var formatDuration = require('../utils/formatDuration.js');
5
+
6
+ function useFormatDuration(milliseconds, options = {
7
+ maxDisplayUnits: 2,
8
+ useAbbreviation: false,
9
+ minUnit: "second"
10
+ }) {
11
+ const {
12
+ maxDisplayUnits = 2,
13
+ useAbbreviation = false,
14
+ minUnit = "second"
15
+ } = options;
16
+ const result = React.useMemo(() => {
17
+ const items = formatDuration.formatDuration(milliseconds, { maxDisplayUnits, minUnit });
18
+ const shouldUseAbbreviation = items.length > 1 && useAbbreviation;
19
+ const parts = items.map((item) => {
20
+ const suffix = shouldUseAbbreviation ? "_abbreviation" : "";
21
+ const i18nKey = `unit.${item.unit}${suffix}`;
22
+ return {
23
+ value: item.value,
24
+ unit: item.unit,
25
+ i18nKey
26
+ };
27
+ });
28
+ return {
29
+ parts
30
+ };
31
+ }, [milliseconds, maxDisplayUnits, useAbbreviation, minUnit]);
32
+ return result;
33
+ }
34
+
35
+ exports.useFormatDuration = useFormatDuration;