@chtc/web-components 0.0.0-28 → 0.0.0-29
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/ColorBar/ColorBar.d.ts +25 -0
- package/dist/ColorBar/ColorBar.d.ts.map +1 -0
- package/dist/ColorBar/ColorBar.js +72 -0
- package/dist/ColorBar/ColorBar.js.map +1 -0
- package/dist/ColorBar/index.d.ts +2 -0
- package/dist/ColorBar/index.d.ts.map +1 -0
- package/dist/ColorBar/index.js +2 -0
- package/dist/ColorBar/index.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/DowntimeBar/DowntimeBar.d.ts +0 -19
- package/dist/DowntimeBar/DowntimeBar.d.ts.map +0 -1
- package/dist/DowntimeBar/DowntimeBar.js +0 -38
- package/dist/DowntimeBar/DowntimeBar.js.map +0 -1
- package/dist/DowntimeBar/index.d.ts +0 -2
- package/dist/DowntimeBar/index.d.ts.map +0 -1
- package/dist/DowntimeBar/index.js +0 -2
- package/dist/DowntimeBar/index.js.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface BarProps extends React.SVGProps<SVGRectElement> {
|
|
3
|
+
title?: string;
|
|
4
|
+
width: number;
|
|
5
|
+
x: number;
|
|
6
|
+
fill: string;
|
|
7
|
+
}
|
|
8
|
+
interface ColorBarProps extends React.SVGProps<SVGSVGElement> {
|
|
9
|
+
data: (boolean | undefined)[] | BarProps[];
|
|
10
|
+
grey?: string;
|
|
11
|
+
red?: string;
|
|
12
|
+
green?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* DowntimeBar consumes a boolean array of uptimes
|
|
16
|
+
* @param data True if Up, False if Down, Undefined if Unknown
|
|
17
|
+
* @param grey
|
|
18
|
+
* @param red
|
|
19
|
+
* @param green
|
|
20
|
+
* @param svgProps
|
|
21
|
+
* @constructor
|
|
22
|
+
*/
|
|
23
|
+
declare const ColorBar: ({ data, red, green, grey, ...svgProps }: ColorBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export default ColorBar;
|
|
25
|
+
//# sourceMappingURL=ColorBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorBar.d.ts","sourceRoot":"","sources":["../../src/ColorBar/ColorBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0D,MAAM,OAAO,CAAC;AAI/E,UAAU,QAAS,SAAQ,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;CACb;AAED,UAAU,aAAc,SAAQ,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC;IAC5D,IAAI,EAAE,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,QAAQ,4CAAsE,aAAa,4CAwChG,CAAC;AAkEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { useEffect, useMemo, useRef, useState, useCallback } from 'react';
|
|
14
|
+
import { grey as gry, red as r, green as grn } from '@mui/material/colors';
|
|
15
|
+
import { Tooltip } from "@mui/material";
|
|
16
|
+
/**
|
|
17
|
+
* DowntimeBar consumes a boolean array of uptimes
|
|
18
|
+
* @param data True if Up, False if Down, Undefined if Unknown
|
|
19
|
+
* @param grey
|
|
20
|
+
* @param red
|
|
21
|
+
* @param green
|
|
22
|
+
* @param svgProps
|
|
23
|
+
* @constructor
|
|
24
|
+
*/
|
|
25
|
+
const ColorBar = (_a) => {
|
|
26
|
+
var { data, red = r[500], green = grn[500], grey = gry[300] } = _a, svgProps = __rest(_a, ["data", "red", "green", "grey"]);
|
|
27
|
+
const containerRef = useRef(null);
|
|
28
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
29
|
+
const [containerHeight, setContainerHeight] = useState(0);
|
|
30
|
+
const updateContainerSize = useCallback(() => {
|
|
31
|
+
if (containerRef.current) {
|
|
32
|
+
setContainerWidth(containerRef.current.clientWidth);
|
|
33
|
+
setContainerHeight(containerRef.current.clientHeight);
|
|
34
|
+
}
|
|
35
|
+
}, [containerRef.current]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
updateContainerSize();
|
|
38
|
+
window.addEventListener('resize', updateContainerSize);
|
|
39
|
+
return () => window.removeEventListener('resize', updateContainerSize);
|
|
40
|
+
}, []);
|
|
41
|
+
let innerComponent = null;
|
|
42
|
+
if (data[0] instanceof Object) {
|
|
43
|
+
innerComponent = (_jsx(AdvancedColorBar, { data: data, containerHeight: containerHeight, containerWidth: containerWidth }));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
data = data;
|
|
47
|
+
innerComponent = (_jsx(SimpleColorBar, { containerWidth: containerWidth, containerHeight: containerHeight, data: data }));
|
|
48
|
+
}
|
|
49
|
+
return (_jsx("svg", Object.assign({ ref: containerRef }, svgProps, { children: innerComponent })));
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Complex color bar that needs to have the input scaled to the container
|
|
53
|
+
*
|
|
54
|
+
* Assumption is that the inputted data starts at 0
|
|
55
|
+
*/
|
|
56
|
+
const AdvancedColorBar = ({ data, containerHeight, containerWidth }) => {
|
|
57
|
+
const dataWidth = useMemo(() => {
|
|
58
|
+
return Math.max(...data.map(d => d.x + d.width));
|
|
59
|
+
}, [data]);
|
|
60
|
+
const widthRatio = containerWidth / dataWidth;
|
|
61
|
+
return (_jsx(_Fragment, { children: data.map((v, i) => {
|
|
62
|
+
const { title, width, x, height } = v, props = __rest(v, ["title", "width", "x", "height"]);
|
|
63
|
+
return (_jsx(Tooltip, { title: title, children: _jsx("rect", Object.assign({ x: x * widthRatio, width: width * widthRatio, y: 0, height: containerHeight }, props), i) }, i));
|
|
64
|
+
}) }));
|
|
65
|
+
};
|
|
66
|
+
const SimpleColorBar = ({ containerWidth, containerHeight, data, red = r[500], green = grn[500], grey = gry[300] }) => {
|
|
67
|
+
return (_jsx(_Fragment, { children: data.map((v, i) => {
|
|
68
|
+
return _jsx("rect", { x: i * containerWidth / data.length, y: 0, width: containerWidth / data.length, height: containerHeight, fill: v == undefined ? grey : v ? green : red }, i);
|
|
69
|
+
}) }));
|
|
70
|
+
};
|
|
71
|
+
export default ColorBar;
|
|
72
|
+
//# sourceMappingURL=ColorBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorBar.js","sourceRoot":"","sources":["../../src/ColorBar/ColorBar.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAc,EAAC,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAC,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAC,IAAI,IAAI,GAAG,EAAE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AAC,CAMN,IARyB,CAAC,CASnB,CACX,CAAC;QACH,CAAC,CAAC,GACA,CACJ,CAAC;AACH,CAAC,CAAC;AAQF,MAAM,cAAc,GAAG,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,GAAC,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,GAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,GAAC,GAAG,CAAC,GAAG,CAAC,EAAsB,EAAE,EAAE;IACnI,OAAO,CACL,4BACE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAClB,OAAO,eAEL,CAAC,EAAE,CAAC,GAAG,cAAc,GAAG,IAAI,CAAC,MAAM,EACnC,CAAC,EAAE,CAAC,EACJ,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC,MAAM,EACnC,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IALxC,CAAC,CAMN,CAAA;QACH,CAAC,CAAC,GACA,CACJ,CAAC;AACH,CAAC,CAAA;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ColorBar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ColorBar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export { default as TopStyledBlock } from "./TopStyledBlock";
|
|
|
4
4
|
export { default as Article } from "./Article";
|
|
5
5
|
export { default as PieChart } from "./PieChart";
|
|
6
6
|
export { default as Table } from "./Table";
|
|
7
|
-
export { default as
|
|
7
|
+
export { default as ColorBar } from "./ColorBar";
|
|
8
8
|
export * from './utils';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,6 @@ export { default as TopStyledBlock } from "./TopStyledBlock";
|
|
|
4
4
|
export { default as Article } from "./Article";
|
|
5
5
|
export { default as PieChart } from "./PieChart";
|
|
6
6
|
export { default as Table } from "./Table";
|
|
7
|
-
export { default as
|
|
7
|
+
export { default as ColorBar } from "./ColorBar";
|
|
8
8
|
export * from './utils';
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,cAAc,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface DowntimeBarProps extends React.SVGProps<SVGSVGElement> {
|
|
3
|
-
data: (boolean | undefined)[];
|
|
4
|
-
grey?: string;
|
|
5
|
-
red?: string;
|
|
6
|
-
green?: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* DowntimeBar consumes a boolean array of uptimes
|
|
10
|
-
* @param data
|
|
11
|
-
* @param grey
|
|
12
|
-
* @param red
|
|
13
|
-
* @param green
|
|
14
|
-
* @param svgProps
|
|
15
|
-
* @constructor
|
|
16
|
-
*/
|
|
17
|
-
declare const DowntimeBar: ({ data, red, green, grey, ...svgProps }: DowntimeBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
export default DowntimeBar;
|
|
19
|
-
//# sourceMappingURL=DowntimeBar.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DowntimeBar.d.ts","sourceRoot":"","sources":["../../src/DowntimeBar/DowntimeBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,UAAU,gBAAiB,SAAQ,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC;IAC/D,IAAI,EAAE,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,WAAW,4CAAsE,gBAAgB,4CA8BtG,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { useEffect, useRef, useState } from 'react';
|
|
14
|
-
import { grey as gry, red as r, green as grn } from '@mui/material/colors';
|
|
15
|
-
/**
|
|
16
|
-
* DowntimeBar consumes a boolean array of uptimes
|
|
17
|
-
* @param data
|
|
18
|
-
* @param grey
|
|
19
|
-
* @param red
|
|
20
|
-
* @param green
|
|
21
|
-
* @param svgProps
|
|
22
|
-
* @constructor
|
|
23
|
-
*/
|
|
24
|
-
const DowntimeBar = (_a) => {
|
|
25
|
-
var { data, red = r[500], green = grn[500], grey = gry[300] } = _a, svgProps = __rest(_a, ["data", "red", "green", "grey"]);
|
|
26
|
-
const containerRef = useRef(null);
|
|
27
|
-
const [width, setWidth] = useState(0);
|
|
28
|
-
const [height, setHeight] = useState(0);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (containerRef.current) {
|
|
31
|
-
setWidth(containerRef.current.clientWidth / data.length);
|
|
32
|
-
setHeight(containerRef.current.clientHeight);
|
|
33
|
-
}
|
|
34
|
-
}, [containerRef.current]);
|
|
35
|
-
return (_jsx("svg", Object.assign({ ref: containerRef }, svgProps, { children: data.map((v, i) => (_jsx("rect", { x: i * width, y: 0, width: width, height: height, fill: v == undefined ? grey : v ? green : red }, i))) })));
|
|
36
|
-
};
|
|
37
|
-
export default DowntimeBar;
|
|
38
|
-
//# sourceMappingURL=DowntimeBar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
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AAC,EACJ,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IALxC,CAAC,CAMN,CACH,CAAC,IACG,CACP,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DowntimeBar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DowntimeBar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
|