ag-common 0.0.798 → 0.0.799

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 (170) hide show
  1. package/dist/ui/components/DarkMode/Base.js +6 -36
  2. package/dist/ui/components/index.d.ts +0 -33
  3. package/dist/ui/components/index.js +0 -33
  4. package/dist/ui/components/shadcn/button.d.ts +1 -1
  5. package/dist/ui/components/shadcn/dropdown-list.d.ts +13 -0
  6. package/dist/ui/components/shadcn/dropdown-list.js +57 -0
  7. package/dist/ui/components/shadcn/sheet.d.ts +1 -1
  8. package/dist/ui/icons/index.d.ts +1 -6
  9. package/dist/ui/icons/index.js +1 -4
  10. package/dist/ui/styles/common.d.ts +21 -14
  11. package/dist/ui/styles/common.js +44 -45
  12. package/dist/ui/styles/index.d.ts +0 -1
  13. package/dist/ui/styles/index.js +0 -1
  14. package/package.json +8 -13
  15. package/dist/ui/components/BarChart/Base.d.ts +0 -8
  16. package/dist/ui/components/BarChart/Base.js +0 -49
  17. package/dist/ui/components/BarChart/Item.d.ts +0 -12
  18. package/dist/ui/components/BarChart/Item.js +0 -38
  19. package/dist/ui/components/BarChart/Legend.d.ts +0 -8
  20. package/dist/ui/components/BarChart/Legend.js +0 -83
  21. package/dist/ui/components/BarChart/TooltipContent.d.ts +0 -8
  22. package/dist/ui/components/BarChart/TooltipContent.js +0 -51
  23. package/dist/ui/components/BarChart/getLegendItems.d.ts +0 -17
  24. package/dist/ui/components/BarChart/getLegendItems.js +0 -24
  25. package/dist/ui/components/BarChart/index.d.ts +0 -2
  26. package/dist/ui/components/BarChart/index.js +0 -17
  27. package/dist/ui/components/BarChart/types.d.ts +0 -9
  28. package/dist/ui/components/BarChart/types.js +0 -2
  29. package/dist/ui/components/BorderGradient/index.d.ts +0 -21
  30. package/dist/ui/components/BorderGradient/index.js +0 -77
  31. package/dist/ui/components/Chevron/index.d.ts +0 -12
  32. package/dist/ui/components/Chevron/index.js +0 -45
  33. package/dist/ui/components/Close/index.d.ts +0 -6
  34. package/dist/ui/components/Close/index.js +0 -41
  35. package/dist/ui/components/Confirm/Dialog.d.ts +0 -7
  36. package/dist/ui/components/Confirm/Dialog.js +0 -54
  37. package/dist/ui/components/Confirm/Modal.d.ts +0 -3
  38. package/dist/ui/components/Confirm/Modal.js +0 -53
  39. package/dist/ui/components/Confirm/index.d.ts +0 -3
  40. package/dist/ui/components/Confirm/index.js +0 -18
  41. package/dist/ui/components/Confirm/types.d.ts +0 -18
  42. package/dist/ui/components/Confirm/types.js +0 -2
  43. package/dist/ui/components/DropdownList/Base.d.ts +0 -3
  44. package/dist/ui/components/DropdownList/Base.js +0 -178
  45. package/dist/ui/components/DropdownList/Dialog.d.ts +0 -7
  46. package/dist/ui/components/DropdownList/Dialog.js +0 -54
  47. package/dist/ui/components/DropdownList/index.d.ts +0 -2
  48. package/dist/ui/components/DropdownList/index.js +0 -18
  49. package/dist/ui/components/DropdownList/types.d.ts +0 -37
  50. package/dist/ui/components/DropdownList/types.js +0 -2
  51. package/dist/ui/components/FlexColumn/index.d.ts +0 -3
  52. package/dist/ui/components/FlexColumn/index.js +0 -31
  53. package/dist/ui/components/FlexRow/index.d.ts +0 -3
  54. package/dist/ui/components/FlexRow/index.js +0 -37
  55. package/dist/ui/components/HorizontalScrollBar/index.d.ts +0 -5
  56. package/dist/ui/components/HorizontalScrollBar/index.js +0 -66
  57. package/dist/ui/components/Icon/index.d.ts +0 -31
  58. package/dist/ui/components/Icon/index.js +0 -69
  59. package/dist/ui/components/Image/index.d.ts +0 -13
  60. package/dist/ui/components/Image/index.js +0 -104
  61. package/dist/ui/components/InfiniteScroll/index.d.ts +0 -17
  62. package/dist/ui/components/InfiniteScroll/index.js +0 -99
  63. package/dist/ui/components/KebabDots/index.d.ts +0 -5
  64. package/dist/ui/components/KebabDots/index.js +0 -16
  65. package/dist/ui/components/LineChart/Base.d.ts +0 -3
  66. package/dist/ui/components/LineChart/Base.js +0 -121
  67. package/dist/ui/components/LineChart/LegendX.d.ts +0 -11
  68. package/dist/ui/components/LineChart/LegendX.js +0 -107
  69. package/dist/ui/components/LineChart/LegendY.d.ts +0 -7
  70. package/dist/ui/components/LineChart/LegendY.js +0 -44
  71. package/dist/ui/components/LineChart/TooltipContent.d.ts +0 -8
  72. package/dist/ui/components/LineChart/TooltipContent.js +0 -52
  73. package/dist/ui/components/LineChart/dateHelpers.d.ts +0 -3
  74. package/dist/ui/components/LineChart/dateHelpers.js +0 -36
  75. package/dist/ui/components/LineChart/getLegendItems.d.ts +0 -18
  76. package/dist/ui/components/LineChart/getLegendItems.js +0 -75
  77. package/dist/ui/components/LineChart/index.d.ts +0 -2
  78. package/dist/ui/components/LineChart/index.js +0 -17
  79. package/dist/ui/components/LineChart/interpolate.d.ts +0 -17
  80. package/dist/ui/components/LineChart/interpolate.js +0 -58
  81. package/dist/ui/components/LineChart/types.d.ts +0 -32
  82. package/dist/ui/components/LineChart/types.js +0 -2
  83. package/dist/ui/components/Loader/index.d.ts +0 -15
  84. package/dist/ui/components/Loader/index.js +0 -93
  85. package/dist/ui/components/MinSidebar/index.d.ts +0 -13
  86. package/dist/ui/components/MinSidebar/index.js +0 -93
  87. package/dist/ui/components/Modal/Dialog.d.ts +0 -8
  88. package/dist/ui/components/Modal/Dialog.js +0 -47
  89. package/dist/ui/components/Modal/Modal.d.ts +0 -7
  90. package/dist/ui/components/Modal/Modal.js +0 -178
  91. package/dist/ui/components/Modal/index.d.ts +0 -3
  92. package/dist/ui/components/Modal/index.js +0 -18
  93. package/dist/ui/components/Modal/types.d.ts +0 -16
  94. package/dist/ui/components/Modal/types.js +0 -2
  95. package/dist/ui/components/PieChart/index.d.ts +0 -11
  96. package/dist/ui/components/PieChart/index.js +0 -43
  97. package/dist/ui/components/ProgressBar/index.d.ts +0 -15
  98. package/dist/ui/components/ProgressBar/index.js +0 -96
  99. package/dist/ui/components/Prompt/Dialog.d.ts +0 -2
  100. package/dist/ui/components/Prompt/Dialog.js +0 -26
  101. package/dist/ui/components/Prompt/Modal.d.ts +0 -3
  102. package/dist/ui/components/Prompt/Modal.js +0 -111
  103. package/dist/ui/components/Prompt/index.d.ts +0 -3
  104. package/dist/ui/components/Prompt/index.js +0 -18
  105. package/dist/ui/components/Prompt/types.d.ts +0 -23
  106. package/dist/ui/components/Prompt/types.js +0 -2
  107. package/dist/ui/components/PulseRing/index.d.ts +0 -19
  108. package/dist/ui/components/PulseRing/index.js +0 -75
  109. package/dist/ui/components/RowOrColumn/index.d.ts +0 -15
  110. package/dist/ui/components/RowOrColumn/index.js +0 -46
  111. package/dist/ui/components/Search/AutoHideSearchBox.d.ts +0 -8
  112. package/dist/ui/components/Search/AutoHideSearchBox.js +0 -114
  113. package/dist/ui/components/Search/Dialog.d.ts +0 -7
  114. package/dist/ui/components/Search/Dialog.js +0 -60
  115. package/dist/ui/components/Search/Inline.d.ts +0 -3
  116. package/dist/ui/components/Search/Inline.js +0 -137
  117. package/dist/ui/components/Search/Modal.d.ts +0 -3
  118. package/dist/ui/components/Search/Modal.js +0 -28
  119. package/dist/ui/components/Search/SearchBox.d.ts +0 -16
  120. package/dist/ui/components/Search/SearchBox.js +0 -107
  121. package/dist/ui/components/Search/index.d.ts +0 -6
  122. package/dist/ui/components/Search/index.js +0 -21
  123. package/dist/ui/components/Search/types.d.ts +0 -49
  124. package/dist/ui/components/Search/types.js +0 -2
  125. package/dist/ui/components/Sidebar/index.d.ts +0 -11
  126. package/dist/ui/components/Sidebar/index.js +0 -194
  127. package/dist/ui/components/SparkLine/index.d.ts +0 -16
  128. package/dist/ui/components/SparkLine/index.js +0 -64
  129. package/dist/ui/components/TabBar/index.d.ts +0 -27
  130. package/dist/ui/components/TabBar/index.js +0 -100
  131. package/dist/ui/components/Table/index.d.ts +0 -11
  132. package/dist/ui/components/Table/index.js +0 -49
  133. package/dist/ui/components/TextEdit/CheckboxEdit.d.ts +0 -14
  134. package/dist/ui/components/TextEdit/CheckboxEdit.js +0 -104
  135. package/dist/ui/components/TextEdit/ColourEdit.d.ts +0 -5
  136. package/dist/ui/components/TextEdit/ColourEdit.js +0 -63
  137. package/dist/ui/components/TextEdit/LengthBox.d.ts +0 -5
  138. package/dist/ui/components/TextEdit/LengthBox.js +0 -28
  139. package/dist/ui/components/TextEdit/ListboxEdit.d.ts +0 -14
  140. package/dist/ui/components/TextEdit/ListboxEdit.js +0 -61
  141. package/dist/ui/components/TextEdit/TextEdit.d.ts +0 -3
  142. package/dist/ui/components/TextEdit/TextEdit.js +0 -145
  143. package/dist/ui/components/TextEdit/common.d.ts +0 -19
  144. package/dist/ui/components/TextEdit/common.js +0 -61
  145. package/dist/ui/components/TextEdit/index.d.ts +0 -5
  146. package/dist/ui/components/TextEdit/index.js +0 -20
  147. package/dist/ui/components/TextEdit/types.d.ts +0 -65
  148. package/dist/ui/components/TextEdit/types.js +0 -2
  149. package/dist/ui/components/TextWithButton/index.d.ts +0 -10
  150. package/dist/ui/components/TextWithButton/index.js +0 -89
  151. package/dist/ui/components/Timeline/index.d.ts +0 -22
  152. package/dist/ui/components/Timeline/index.js +0 -72
  153. package/dist/ui/components/TimelineChart/index.d.ts +0 -21
  154. package/dist/ui/components/TimelineChart/index.js +0 -63
  155. package/dist/ui/components/TreeChart/TooltipContent.d.ts +0 -7
  156. package/dist/ui/components/TreeChart/TooltipContent.js +0 -34
  157. package/dist/ui/components/TreeChart/base.d.ts +0 -3
  158. package/dist/ui/components/TreeChart/base.js +0 -144
  159. package/dist/ui/components/TreeChart/helpers.d.ts +0 -4
  160. package/dist/ui/components/TreeChart/helpers.js +0 -41
  161. package/dist/ui/components/TreeChart/index.d.ts +0 -2
  162. package/dist/ui/components/TreeChart/index.js +0 -17
  163. package/dist/ui/components/TreeChart/types.d.ts +0 -27
  164. package/dist/ui/components/TreeChart/types.js +0 -2
  165. package/dist/ui/components/UserImage/index.d.ts +0 -26
  166. package/dist/ui/components/UserImage/index.js +0 -109
  167. package/dist/ui/icons/CrossIcon.d.ts +0 -5
  168. package/dist/ui/icons/CrossIcon.js +0 -24
  169. package/dist/ui/styles/standaloneStyles.d.ts +0 -24
  170. package/dist/ui/styles/standaloneStyles.js +0 -69
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- export interface IInfiniteScroll {
3
- children: any[];
4
- className?: string;
5
- startIndex?: number;
6
- onScroll?: (e: {
7
- scrollTop: number;
8
- isDown: boolean;
9
- }) => void;
10
- /** how many to initially show, and to add per scroll. default 10 */
11
- incrementNumber?: number;
12
- /** if true, can only scroll by button press. default false */
13
- scrollDisabled?: boolean;
14
- /** eg 'showing x of y results' */
15
- renderResultsLine?: (min: number, max: number) => React.ReactNode;
16
- }
17
- export declare const InfiniteScroll: (p: IInfiniteScroll) => React.JSX.Element;
@@ -1,99 +0,0 @@
1
- "use strict";
2
- 'use client';
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.InfiniteScroll = void 0;
41
- const styled_1 = __importDefault(require("@emotion/styled"));
42
- const react_1 = __importStar(require("react"));
43
- const debounce_1 = require("../../helpers/debounce");
44
- const dom_1 = require("../../helpers/dom");
45
- const Base = styled_1.default.div `
46
- overflow-y: auto;
47
- height: 100%;
48
- width: 100%;
49
- &[data-no-scroll='true'] {
50
- overflow-y: initial;
51
- }
52
- `;
53
- //if we see this, then we havent shown user enough items - allow click to load more
54
- const LoadMore = styled_1.default.div `
55
- cursor: pointer;
56
- text-decoration: underline;
57
- `;
58
- const InfiniteScroll = (p) => {
59
- var _a, _b;
60
- const { incrementNumber = 10, scrollDisabled = false } = p;
61
- const ref = (0, react_1.createRef)();
62
- const [startIndex] = (0, react_1.useState)((_a = p.startIndex) !== null && _a !== void 0 ? _a : 0);
63
- const [endIndex, setEndIndex] = (0, react_1.useState)(startIndex + incrementNumber);
64
- const [startScrollTop, setStartScrollTop] = (0, react_1.useState)(0);
65
- const handleScrollTop = (e) => {
66
- const { scrollTop, clientHeight, scrollHeight } = e.currentTarget;
67
- const hasReachedEnd = scrollTop + clientHeight === scrollHeight;
68
- if (hasReachedEnd) {
69
- setEndIndex(endIndex + incrementNumber);
70
- }
71
- };
72
- (0, react_1.useEffect)(() => {
73
- setStartScrollTop(ref.current.scrollTop);
74
- // eslint-disable-next-line react-hooks/exhaustive-deps
75
- }, []);
76
- const sliced = p.children.slice(0, endIndex);
77
- const lastDisplayIndex = Math.min(p.children.length, endIndex);
78
- const renderResultsLine = (_b = p.renderResultsLine) === null || _b === void 0 ? void 0 : _b.call(p, lastDisplayIndex, p.children.length);
79
- return (react_1.default.createElement(Base, Object.assign({ "data-no-scroll": scrollDisabled, ref: ref, className: p.className, onScroll: (e) => {
80
- if (scrollDisabled) {
81
- return;
82
- }
83
- const { scrollTop } = e.currentTarget;
84
- handleScrollTop(e);
85
- //
86
- (0, debounce_1.debounce)(() => {
87
- var _a;
88
- setStartScrollTop(scrollTop);
89
- (_a = p.onScroll) === null || _a === void 0 ? void 0 : _a.call(p, { scrollTop, isDown: startScrollTop < scrollTop });
90
- }, {
91
- key: 'in-scr',
92
- time: 50,
93
- });
94
- } }, (0, dom_1.filterDataProps)(p)),
95
- sliced,
96
- renderResultsLine,
97
- lastDisplayIndex < p.children.length && (react_1.default.createElement(LoadMore, { onClick: () => setEndIndex(endIndex + incrementNumber) }, "Load More?"))));
98
- };
99
- exports.InfiniteScroll = InfiniteScroll;
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- export interface IKebabDots {
3
- onClick?: () => Promise<void>;
4
- }
5
- export declare const KebabDots: ({ onClick }: IKebabDots) => React.JSX.Element;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- 'use client';
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.KebabDots = void 0;
8
- const styled_1 = __importDefault(require("@emotion/styled"));
9
- const react_1 = __importDefault(require("react"));
10
- const HorizontalDots_1 = require("../../icons/HorizontalDots");
11
- const Icon_1 = require("../Icon");
12
- const IconStyled = (0, styled_1.default)(Icon_1.Icon) `
13
- position: absolute;
14
- `;
15
- const KebabDots = ({ onClick }) => (react_1.default.createElement(IconStyled, { style: { width: '2rem', height: '2rem' }, onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(), "data-icon": "kebab" }, HorizontalDots_1.HorizontalDots));
16
- exports.KebabDots = KebabDots;
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- import type { ILineChart } from './types';
3
- export declare const LineChart: (p: ILineChart) => React.JSX.Element;
@@ -1,121 +0,0 @@
1
- "use strict";
2
- 'use client';
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.LineChart = void 0;
8
- const styled_1 = __importDefault(require("@emotion/styled"));
9
- const react_1 = __importDefault(require("react"));
10
- const array_1 = require("../../../common/helpers/array");
11
- const math_1 = require("../../../common/helpers/math");
12
- const useTooltip_1 = require("../../helpers/useTooltip");
13
- const common_1 = require("../../styles/common");
14
- const FlexRow_1 = require("../FlexRow");
15
- const dateHelpers_1 = require("./dateHelpers");
16
- const getLegendItems_1 = require("./getLegendItems");
17
- const interpolate_1 = require("./interpolate");
18
- const LegendX_1 = require("./LegendX");
19
- const LegendY_1 = require("./LegendY");
20
- const TooltipContent_1 = require("./TooltipContent");
21
- const Base = styled_1.default.div `
22
- padding: 0.5rem;
23
- width: calc(100% - 1rem);
24
- height: calc(100% - 1rem);
25
-
26
- display: flex;
27
- flex-flow: column;
28
- justify-content: center;
29
- align-items: flex-end;
30
- overflow: hidden;
31
- position: relative;
32
- `;
33
- const Svg = styled_1.default.svg `
34
- padding: 2px;
35
- width: calc(100% - 5px);
36
- height: calc(100% - 5px);
37
-
38
- @keyframes dash {
39
- to {
40
- stroke-dashoffset: 1000;
41
- }
42
- }
43
- `;
44
- const LineChart = (p) => {
45
- var _a;
46
- const UT = (0, useTooltip_1.useTooltip)();
47
- const style = (0, common_1.getVarStyles)(p.style);
48
- const { points, xTime } = (0, interpolate_1.interpolate)(p.data);
49
- let tt = p.tooltipTitle;
50
- if (!tt && xTime) {
51
- tt = dateHelpers_1.timeTooltipTitle;
52
- }
53
- tt !== null && tt !== void 0 ? tt : (tt = (s) => s.toString());
54
- let lt = p.legendTitle;
55
- if (!lt && xTime) {
56
- lt = dateHelpers_1.timeLegendTitle;
57
- }
58
- lt !== null && lt !== void 0 ? lt : (lt = (s) => s.toString());
59
- const lt2 = lt;
60
- const tt2 = tt;
61
- const legendItems = (0, getLegendItems_1.getLegendItems)(Object.assign(Object.assign({ colours: p.colours, data: p.data, legendData: p.legendData, tt: tt2, lt: lt2 }, (_a = UT.pos) === null || _a === void 0 ? void 0 : _a.data), { fixed: false }));
62
- const SvgC = (react_1.default.createElement(Svg, { style: {
63
- borderLeft: `solid 1px ${style.borderColor}`,
64
- borderTop: `solid 1px ${style.borderColor}`,
65
- }, transform: "scale(-1,1) scale(-1,-1)", strokeWidth: '3px', fillOpacity: 1, preserveAspectRatio: "none", onMouseMove: (element) => {
66
- const parent = element.currentTarget.closest("[data-type='lcb']");
67
- const bb = parent === null || parent === void 0 ? void 0 : parent.getBoundingClientRect();
68
- if (!bb) {
69
- return;
70
- }
71
- const relativeX = (0, math_1.rangePercentage)({
72
- value: element.pageX,
73
- min: bb.left,
74
- max: bb.left + bb.width,
75
- }) * 100;
76
- let selectedPoints = points.filter((p) => relativeX >= p.x1 && relativeX < p.x2);
77
- //if there are just single dots on the graph, choose the ones that are closest (share the smallest gap distance)
78
- if (selectedPoints.length === 0) {
79
- const sp1 = points
80
- .map((p) => (Object.assign(Object.assign({}, p), { gap: Math.abs(p.x1 - relativeX) })))
81
- .sort((a, b) => (a.gap < b.gap ? -1 : 1));
82
- const mingap = sp1[0].gap;
83
- selectedPoints = sp1.filter((r) => r.gap === mingap);
84
- }
85
- const selectedXs = (0, array_1.distinctBy)(p.data.filter(({ x, y }) => selectedPoints.find((a) => a.origX === x && a.origY === y)), (s) => JSON.stringify(s));
86
- UT.setPos({
87
- element,
88
- parent,
89
- data: {
90
- selectedPoints: selectedPoints.map((a) => ({
91
- x: a.origX,
92
- y: a.origY,
93
- })),
94
- selectedXs,
95
- },
96
- });
97
- } }, points.map((p2) => {
98
- var _a, _b, _c;
99
- const isSelected = p2.origX === ((_c = (_b = (_a = UT.pos) === null || _a === void 0 ? void 0 : _a.data.selectedXs) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.x);
100
- return (react_1.default.createElement(react_1.default.Fragment, { key: JSON.stringify(p2) },
101
- //mouse selected
102
- (isSelected ||
103
- //only single date point
104
- p2.x1 === p2.x2 ||
105
- //is the last point
106
- p2.isLast) && (react_1.default.createElement("circle", Object.assign({ cx: `${p2.x2}%`, cy: `${p2.y2}%`, r: "8px", style: { zIndex: 1 } }, (p2.isToday && p2.isLast && !isSelected
107
- ? { stroke: p.colours[p2.name], fill: 'transparent' }
108
- : { fill: p.colours[p2.name] })))),
109
- p2.x1 !== p2.x2 && (react_1.default.createElement("line", { strokeOpacity: legendItems.part.find((f) => f.name === p2.name) ? 1 : 0.3, x1: `${p2.x1}%`, x2: `${p2.x2}%`, y1: `${p2.y1}%`, y2: `${p2.y2}%`, style: Object.assign({ stroke: p.colours[p2.name] }, (p2.isToday && {
110
- strokeDasharray: 10,
111
- animation: 'dash 50s linear reverse infinite',
112
- })) }))));
113
- })));
114
- return (react_1.default.createElement(Base, { className: p.className, "data-type": "lcb", onMouseLeave: () => UT.setPos(undefined), style: style },
115
- react_1.default.createElement(UT.Comp, { pos: UT.pos }, (p2) => (react_1.default.createElement(TooltipContent_1.TooltipContent, Object.assign({}, p2, { colours: p.colours, data: p.data, lt: lt2, tt: tt2, legendItems: legendItems, style: style })))),
116
- react_1.default.createElement(FlexRow_1.FlexRow, { noWrap: true },
117
- react_1.default.createElement(LegendY_1.LegendY, { data: p.data, style: style }),
118
- SvgC),
119
- react_1.default.createElement(LegendX_1.LegendX, { data: p.data, legendData: p.legendData, colours: p.colours, lt: lt, tt: tt, style: style })));
120
- };
121
- exports.LineChart = LineChart;
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import type { IVarStyles } from '../../styles/common';
3
- import type { ILineChartItemRaw } from './types';
4
- export declare const LegendX: ({ data, legendData, lt, tt, colours, style, }: {
5
- data: ILineChartItemRaw[];
6
- legendData?: ILineChartItemRaw[];
7
- colours: Record<string, string>;
8
- lt: (a: number) => string;
9
- tt: (a: number) => string;
10
- style: IVarStyles;
11
- }) => React.JSX.Element;
@@ -1,107 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.LegendX = void 0;
7
- const styled_1 = __importDefault(require("@emotion/styled"));
8
- const react_1 = __importDefault(require("react"));
9
- const common_1 = require("../../../common");
10
- const styles_1 = require("../../styles");
11
- const getLegendItems_1 = require("./getLegendItems");
12
- const Base = styled_1.default.div `
13
- display: flex;
14
- flex-flow: column;
15
- width: 100%;
16
- `;
17
- const Bar = styled_1.default.div `
18
- width: 100%;
19
- display: flex;
20
- flex-flow: row;
21
- position: relative;
22
- margin-bottom: 0.25rem;
23
- `;
24
- const Line = styled_1.default.div `
25
- position: absolute;
26
- top: calc(50% - 1px);
27
- height: 2px;
28
- left: 0;
29
- right: 0;
30
- `;
31
- const Numbers = styled_1.default.div `
32
- width: 100%;
33
- display: flex;
34
- flex-flow: row;
35
- justify-content: space-between;
36
- z-index: 1;
37
-
38
- @media ${styles_1.smallScreen} {
39
- [data-group='1'],
40
- [data-group='2'] {
41
- display: none;
42
- }
43
- }
44
- `;
45
- const Items = styled_1.default.div `
46
- width: 100%;
47
- display: flex;
48
- flex-flow: row wrap;
49
- position: relative;
50
- justify-content: space-between;
51
- margin-top: 0.5rem;
52
- `;
53
- const Item = styled_1.default.div `
54
- display: flex;
55
- flex-flow: row;
56
- position: relative;
57
- align-items: center;
58
- &:not(:first-of-type) {
59
- padding-left: 0.5rem;
60
- }
61
- &:not(:last-of-type) {
62
- padding-right: 0.5rem;
63
- }
64
- `;
65
- const Col = styled_1.default.div `
66
- width: 1rem;
67
- height: 1rem;
68
- border-radius: 50%;
69
- margin-right: 0.25rem;
70
- `;
71
- const LegendX = ({ data, legendData, lt, tt, colours, style, }) => {
72
- const legendItems = (0, getLegendItems_1.getLegendItems)({
73
- data,
74
- legendData,
75
- colours,
76
- fixed: true,
77
- lt,
78
- tt,
79
- }).part;
80
- const xs = data.map((a) => a.x);
81
- const minX = Math.min(...xs);
82
- const maxX = Math.max(...xs);
83
- const itemsRaw = [{ v: minX, group: 0 }];
84
- const gc = 4;
85
- const gap = (maxX - minX) / gc;
86
- if (gap > common_1.twelveHMs) {
87
- for (let a = 1; a < gc; a += 1) {
88
- itemsRaw.push({ v: itemsRaw[a - 1].v + gap, group: (a % 3) + 1 });
89
- }
90
- }
91
- itemsRaw.push({ v: maxX, group: 0 });
92
- const items = itemsRaw.map((d) => ({ v: lt(d.v), group: d.group }));
93
- return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { width: 'calc(100% - 2.5rem)', marginLeft: '2.5rem' }) },
94
- react_1.default.createElement(Bar, null,
95
- react_1.default.createElement(Line, { style: { backgroundColor: style.color } }),
96
- react_1.default.createElement(Numbers, null, items.map((i, i2) => (react_1.default.createElement("span", {
97
- // eslint-disable-next-line react/no-array-index-key
98
- key: i.v + i2, "data-group": i.group, style: {
99
- backgroundColor: style.backgroundColor,
100
- writingMode: 'vertical-rl',
101
- textOrientation: 'mixed',
102
- } }, i.v))))),
103
- legendItems.length > 1 && (react_1.default.createElement(Items, null, legendItems.map((k) => (react_1.default.createElement(Item, { key: k.name },
104
- react_1.default.createElement(Col, { style: { backgroundColor: k.colour } }),
105
- k.name)))))));
106
- };
107
- exports.LegendX = LegendX;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import type { IVarStyles } from '../../styles/common';
3
- import type { ILineChartItemRaw } from './types';
4
- export declare const LegendY: ({ data, style, }: {
5
- data: ILineChartItemRaw[];
6
- style: IVarStyles;
7
- }) => React.JSX.Element;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.LegendY = void 0;
7
- const styled_1 = __importDefault(require("@emotion/styled"));
8
- const react_1 = __importDefault(require("react"));
9
- const math_1 = require("../../../common/helpers/math");
10
- const Base = styled_1.default.div `
11
- display: flex;
12
- flex-flow: row;
13
- width: 100%;
14
- `;
15
- const Numbers = styled_1.default.div `
16
- width: 100%;
17
- display: flex;
18
- flex-flow: column-reverse;
19
- justify-content: space-between;
20
- z-index: 1;
21
- > span {
22
- text-align: right;
23
- }
24
- `;
25
- const LegendY = ({ data, style, }) => {
26
- const ys = data.map((a) => a.y);
27
- const minY = Math.min(...ys);
28
- const maxY = Math.max(...ys);
29
- const items = [minY];
30
- const gc = 3;
31
- const gap = (maxY - minY) / gc;
32
- for (let a = 1; a < gc; a += 1) {
33
- items.push(Math.floor(items[a - 1] + gap));
34
- }
35
- items.push(maxY);
36
- return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { width: '2.5rem', paddingRight: '1ch' }) },
37
- react_1.default.createElement(Numbers, null, items.map((i, i2) => (react_1.default.createElement("span", {
38
- // eslint-disable-next-line react/no-array-index-key
39
- key: i + i2, style: {
40
- color: style.color,
41
- backgroundColor: style.backgroundColor,
42
- } }, (0, math_1.toFixed)(i, 2)))))));
43
- };
44
- exports.LegendY = LegendY;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import type { IVarStyles } from '../../styles/common';
3
- import type { ILegendItems } from './getLegendItems';
4
- import type { ILineChartTooltip } from './types';
5
- export declare const TooltipContent: (p: ILineChartTooltip & {
6
- legendItems: ILegendItems;
7
- style: IVarStyles;
8
- }) => React.JSX.Element;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TooltipContent = void 0;
7
- const styled_1 = __importDefault(require("@emotion/styled"));
8
- const react_1 = __importDefault(require("react"));
9
- const math_1 = require("../../../common/helpers/math");
10
- const Base = styled_1.default.div `
11
- padding: 0.5rem;
12
- `;
13
- const Title = styled_1.default.div `
14
- font-weight: bold;
15
- `;
16
- const Row = styled_1.default.div `
17
- width: 100%;
18
- display: flex;
19
- `;
20
- const ItemTitle = styled_1.default.span `
21
- &[data-selected='true'] {
22
- font-weight: bold;
23
- text-decoration: underline;
24
- }
25
- `;
26
- const Total = styled_1.default.span `
27
- margin-left: auto;
28
- padding-left: 0.5rem;
29
-
30
- &[data-selected='true'] {
31
- font-weight: bold;
32
- text-decoration: underline;
33
- }
34
- `;
35
- const TooltipContent = (p) => {
36
- var _a, _b;
37
- const name = p.tt((_b = (_a = p.selectedXs) === null || _a === void 0 ? void 0 : _a[0].x) !== null && _b !== void 0 ? _b : 0);
38
- return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, p.style), { border: `solid 1px ${p.style.borderColor}` }) },
39
- react_1.default.createElement(Title, null, name),
40
- react_1.default.createElement(Row, null,
41
- react_1.default.createElement("span", null, "total"),
42
- react_1.default.createElement(Total, null, (0, math_1.toFixed)(p.legendItems.total, 2))),
43
- p.legendItems.part.map((v) => (react_1.default.createElement(Row, { key: v.name + v.y, style: { color: v.colour } },
44
- react_1.default.createElement(ItemTitle, null, v.name),
45
- react_1.default.createElement(Total, null, (0, math_1.toFixed)(v.y, 2))))),
46
- p.legendItems.rest.length > 0 && (react_1.default.createElement(Row, null,
47
- react_1.default.createElement("span", null,
48
- p.legendItems.rest.length,
49
- " more"),
50
- react_1.default.createElement(Total, null, (0, math_1.toFixed)(p.legendItems.restTotal, 2))))));
51
- };
52
- exports.TooltipContent = TooltipContent;
@@ -1,3 +0,0 @@
1
- export declare const timeLegendTitle: (s: number) => string;
2
- export declare const timeTooltipTitle: (s: number) => string;
3
- export declare const isToday: (s: number) => boolean;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isToday = exports.timeTooltipTitle = exports.timeLegendTitle = void 0;
4
- const date_1 = require("../../helpers/date");
5
- const timeLegendTitle = (s) => {
6
- const ret = (0, date_1.getDMY)(new Date(s), { short: true });
7
- return ret;
8
- };
9
- exports.timeLegendTitle = timeLegendTitle;
10
- const timeTooltipTitle = (s) => {
11
- if (!s) {
12
- return '';
13
- }
14
- const dmy = (0, date_1.getDMY)(new Date(s));
15
- let diff = '';
16
- const d = new Date();
17
- const td = d.getTime() - Number(s);
18
- //today
19
- if (td < 0) {
20
- diff = 'Today';
21
- }
22
- else {
23
- const d1 = (0, date_1.dateDiffToString)(new Date(Number(s)), d);
24
- diff = `(${d1})`;
25
- }
26
- return `${dmy} ${diff}`;
27
- };
28
- exports.timeTooltipTitle = timeTooltipTitle;
29
- const isToday = (s) => {
30
- if (!s) {
31
- return false;
32
- }
33
- const td = new Date().getTime() - Number(s);
34
- return td < 0;
35
- };
36
- exports.isToday = isToday;
@@ -1,18 +0,0 @@
1
- import type { ILineChartItemRaw, ILineChartTooltip } from './types';
2
- export interface ILegendItem {
3
- y: number;
4
- colour: string;
5
- name: string;
6
- }
7
- export interface ILegendItems {
8
- part: ILegendItem[];
9
- rest: ILegendItem[];
10
- restTotal: number;
11
- total: number;
12
- }
13
- export declare const getLegendItems: (p: ILineChartTooltip & {
14
- /** if true, will only return top items */
15
- fixed: boolean;
16
- /** optional dataset used for legend/tooltip computations */
17
- legendData?: ILineChartItemRaw[];
18
- }) => ILegendItems;
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLegendItems = void 0;
4
- const array_1 = require("../../../common/helpers/array");
5
- const math_1 = require("../../../common/helpers/math");
6
- const object_1 = require("../../../common/helpers/object");
7
- const shownResults = 4;
8
- const getTopItems = ({ data, colours, }) => {
9
- const val = {};
10
- data.forEach((d) => {
11
- var _a;
12
- const key = (_a = d.legendName) !== null && _a !== void 0 ? _a : d.name;
13
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
14
- if (!val[key]) {
15
- val[key] = { colour: colours[d.name], name: key, value: d.y };
16
- }
17
- else {
18
- val[key].value += d.y;
19
- }
20
- });
21
- const values = Object.values(val).sort((a, b) => a.value < b.value ? 1 : -1);
22
- const legendItems = (0, array_1.take)(values, shownResults).part.map((v) => ({
23
- colour: v.colour,
24
- name: v.name,
25
- y: v.value,
26
- x: 0,
27
- }));
28
- return legendItems;
29
- };
30
- const getLegendItems = (p) => {
31
- var _a;
32
- const dataSource = (_a = p.legendData) !== null && _a !== void 0 ? _a : p.data;
33
- let values = [];
34
- if (p.selectedXs && p.selectedXs.length > 0) {
35
- const sx = p.selectedXs[0].x;
36
- const grouped = {};
37
- dataSource
38
- .filter((d) => d.x === sx)
39
- .forEach((d) => {
40
- var _a;
41
- const key = (_a = d.legendName) !== null && _a !== void 0 ? _a : d.name;
42
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
43
- if (!grouped[key]) {
44
- grouped[key] = {
45
- value: d.y,
46
- colour: p.colours[d.name],
47
- name: key,
48
- };
49
- }
50
- else {
51
- grouped[key].value += d.y;
52
- }
53
- });
54
- values = Object.values(grouped).map((g) => ({
55
- colour: g.colour,
56
- name: g.name,
57
- y: g.value,
58
- x: sx,
59
- }));
60
- }
61
- if (p.fixed || values.length === 0) {
62
- values = getTopItems({ data: dataSource, colours: p.colours });
63
- }
64
- const total = (0, math_1.sumArray)(values.map((a) => a.y));
65
- const min = total * 0.1;
66
- let part = values.sort((a, b) => (a.y < b.y ? 1 : -1));
67
- let rest = [];
68
- if (part.length > shownResults) {
69
- part = (0, array_1.take)(part.filter((r) => r.y > min), shownResults).part;
70
- rest = (0, object_1.copy)(values).filter((r) => !part.find((p) => p.name === r.name));
71
- }
72
- const restTotal = (0, math_1.sumArray)(rest.map((s) => s.y));
73
- return { part, rest, restTotal, total };
74
- };
75
- exports.getLegendItems = getLegendItems;
@@ -1,2 +0,0 @@
1
- export * from './Base';
2
- export type * from './types';
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Base"), exports);