ag-common 0.0.656 → 0.0.658
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/ui/components/DropdownList/Base.js +7 -2
- package/dist/ui/components/DropdownList/Dialog.js +5 -2
- package/dist/ui/components/DropdownList/types.d.ts +2 -0
- package/dist/ui/components/LineChart/Base.js +9 -2
- package/dist/ui/components/LineChart/LegendX.js +13 -5
- package/dist/ui/components/LineChart/interpolate.d.ts +1 -0
- package/dist/ui/components/LineChart/interpolate.js +1 -0
- package/dist/ui/styles/common.js +1 -1
- package/package.json +1 -1
|
@@ -66,7 +66,6 @@ const ListItemStyle = styled_1.default.div `
|
|
|
66
66
|
padding-left: 0.5rem;
|
|
67
67
|
flex-grow: 1;
|
|
68
68
|
padding: 1rem;
|
|
69
|
-
height: calc(100% - 2rem);
|
|
70
69
|
cursor: pointer;
|
|
71
70
|
display: flex;
|
|
72
71
|
overflow: hidden;
|
|
@@ -93,7 +92,7 @@ const ListItemStyle = styled_1.default.div `
|
|
|
93
92
|
background-color: rgba(0, 0, 0, 0.2);
|
|
94
93
|
}
|
|
95
94
|
`;
|
|
96
|
-
const ListItem = ({ render, onChange, selected, defaultV = false, }) => (react_1.default.createElement(ListItemStyle, { "data-selected": selected, "data-default": defaultV, onClick: (e) => {
|
|
95
|
+
const ListItem = ({ render, onChange, selected, defaultV = false, }) => (react_1.default.createElement(ListItemStyle, { "data-type": "ddl-item", "data-selected": selected, "data-default": defaultV, onClick: (e) => {
|
|
97
96
|
if (!selected) {
|
|
98
97
|
onChange === null || onChange === void 0 ? void 0 : onChange();
|
|
99
98
|
}
|
|
@@ -107,8 +106,10 @@ function DropdownList(p) {
|
|
|
107
106
|
const [open, setOpen] = (0, react_1.useState)(p.open);
|
|
108
107
|
const [bounced, setBounced] = (0, react_1.useState)(false);
|
|
109
108
|
(0, useOnClickOutside_1.useOnClickOutside)({ disabled: !open, ref, moveMouseOutside: false }, () => {
|
|
109
|
+
var _a;
|
|
110
110
|
setOpen(false);
|
|
111
111
|
setBounced(false);
|
|
112
|
+
(_a = p.onClose) === null || _a === void 0 ? void 0 : _a.call(p);
|
|
112
113
|
});
|
|
113
114
|
(0, react_1.useEffect)(() => {
|
|
114
115
|
const newv = p.value;
|
|
@@ -154,9 +155,13 @@ function DropdownList(p) {
|
|
|
154
155
|
}
|
|
155
156
|
}, [bounced, open]);
|
|
156
157
|
return (react_1.default.createElement(Base, { className: p.className, ref: ref, title: p.placeholder, onClick: (e) => {
|
|
158
|
+
var _a;
|
|
157
159
|
e.stopPropagation();
|
|
158
160
|
e.preventDefault();
|
|
159
161
|
setOpen(!open);
|
|
162
|
+
if (open) {
|
|
163
|
+
(_a = p.onClose) === null || _a === void 0 ? void 0 : _a.call(p);
|
|
164
|
+
}
|
|
160
165
|
} },
|
|
161
166
|
react_1.default.createElement(DropItems, { "data-open": open, style: style, "data-bounced": bounced }, open &&
|
|
162
167
|
p.options.map((s, i) => (react_1.default.createElement(ListItem, { key: typeof s === 'string' ? s : p.renderF(s, i).key, render: p.renderF(s, i), onChange: () => p.onChange(s, i), selected: s === state })))),
|
|
@@ -19,8 +19,8 @@ const index_1 = require("./index");
|
|
|
19
19
|
const DropdownListDialog = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
20
|
return new Promise((res) => {
|
|
21
21
|
const id = 'ag-common-ddld';
|
|
22
|
+
//already open
|
|
22
23
|
if (document.querySelectorAll('#' + id).length) {
|
|
23
|
-
res(undefined);
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
const wrapper = document.body.appendChild(document.createElement('div'));
|
|
@@ -29,7 +29,10 @@ const DropdownListDialog = (p) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
29
29
|
wrapper.style.top = `${p.position.y}px`;
|
|
30
30
|
wrapper.style.left = `${p.position.x}px`;
|
|
31
31
|
const root = (0, client_1.createRoot)(wrapper);
|
|
32
|
-
root.render(react_1.default.createElement(index_1.DropdownList, Object.assign({}, p, { open: true,
|
|
32
|
+
root.render(react_1.default.createElement(index_1.DropdownList, Object.assign({}, p, { open: true, onClose: () => {
|
|
33
|
+
root.unmount();
|
|
34
|
+
wrapper.remove();
|
|
35
|
+
}, onChange: (v, i) => {
|
|
33
36
|
root.unmount();
|
|
34
37
|
wrapper.remove();
|
|
35
38
|
res(!v ? undefined : [v, i]);
|
|
@@ -100,9 +100,16 @@ const LineChart = (p) => {
|
|
|
100
100
|
});
|
|
101
101
|
} }, points.map((p2) => {
|
|
102
102
|
var _a, _b, _c;
|
|
103
|
+
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);
|
|
103
104
|
return (react_1.default.createElement(react_1.default.Fragment, { key: JSON.stringify(p2) },
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
//mouse selected
|
|
106
|
+
(isSelected ||
|
|
107
|
+
//only single date point
|
|
108
|
+
p2.x1 === p2.x2 ||
|
|
109
|
+
//is the last point
|
|
110
|
+
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
|
|
111
|
+
? { stroke: p.colours[p2.name], fill: 'transparent' }
|
|
112
|
+
: { fill: p.colours[p2.name] })))),
|
|
106
113
|
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 && {
|
|
107
114
|
strokeDasharray: 10,
|
|
108
115
|
animation: 'dash 50s linear reverse infinite',
|
|
@@ -7,6 +7,7 @@ exports.LegendX = void 0;
|
|
|
7
7
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const common_1 = require("../../../common");
|
|
10
|
+
const styles_1 = require("../../styles");
|
|
10
11
|
const getLegendItems_1 = require("./getLegendItems");
|
|
11
12
|
const Base = styled_1.default.div `
|
|
12
13
|
display: flex;
|
|
@@ -33,6 +34,13 @@ const Numbers = styled_1.default.div `
|
|
|
33
34
|
flex-flow: row;
|
|
34
35
|
justify-content: space-between;
|
|
35
36
|
z-index: 1;
|
|
37
|
+
|
|
38
|
+
@media ${styles_1.smallScreen} {
|
|
39
|
+
[data-group='1'],
|
|
40
|
+
[data-group='2'] {
|
|
41
|
+
display: none;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
36
44
|
`;
|
|
37
45
|
const Items = styled_1.default.div `
|
|
38
46
|
width: 100%;
|
|
@@ -73,23 +81,23 @@ const LegendX = ({ data, lt, tt, colours, style, }) => {
|
|
|
73
81
|
const minX = Math.min(...xs);
|
|
74
82
|
const maxX = Math.max(...xs);
|
|
75
83
|
const maxY = Math.max(...ys);
|
|
76
|
-
const itemsRaw = [minX];
|
|
84
|
+
const itemsRaw = [{ v: minX, group: 0 }];
|
|
77
85
|
const gc = 8;
|
|
78
86
|
const gap = (maxX - minX) / gc;
|
|
79
87
|
if (gap > common_1.twelveHMs) {
|
|
80
88
|
for (let a = 1; a < gc; a += 1) {
|
|
81
|
-
itemsRaw.push(itemsRaw[a - 1] + gap);
|
|
89
|
+
itemsRaw.push({ v: itemsRaw[a - 1].v + gap, group: (a % 3) + 1 });
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
|
-
itemsRaw.push(maxX);
|
|
85
|
-
const items = itemsRaw.map((d) => { var _a; return (_a = lt(d)) !== null && _a !== void 0 ? _a : d; });
|
|
92
|
+
itemsRaw.push({ v: maxX, group: 0 });
|
|
93
|
+
const items = itemsRaw.map((d) => { var _a; return ({ v: (_a = lt(d.v)) !== null && _a !== void 0 ? _a : d.v, group: d.group }); });
|
|
86
94
|
const ch = maxY.toString().length + 1;
|
|
87
95
|
return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { marginLeft: 'auto', width: `calc(100% - ${ch}ch)` }) },
|
|
88
96
|
react_1.default.createElement(Bar, null,
|
|
89
97
|
react_1.default.createElement(Line, { style: { backgroundColor: style.color } }),
|
|
90
98
|
react_1.default.createElement(Numbers, null, items.map((i, i2) => (react_1.default.createElement("span", {
|
|
91
99
|
// eslint-disable-next-line react/no-array-index-key
|
|
92
|
-
key: i + i2, style: { backgroundColor: style.backgroundColor } }, i))))),
|
|
100
|
+
key: i.v + i2, "data-group": i.group, style: { backgroundColor: style.backgroundColor } }, i.v))))),
|
|
93
101
|
legendItems.length > 1 && (react_1.default.createElement(Items, null, legendItems.map((k) => (react_1.default.createElement(Item, { key: k.name },
|
|
94
102
|
react_1.default.createElement(Col, { style: { backgroundColor: k.colour } }),
|
|
95
103
|
k.name)))))));
|
package/dist/ui/styles/common.js
CHANGED
|
@@ -21,7 +21,7 @@ const HardOutlineFilter = (outlineColour = 'white', sizePx = 1) => {
|
|
|
21
21
|
return `drop-shadow(${px} ${px} 0px ${outlineColour})
|
|
22
22
|
drop-shadow(-${px} ${px} 0px ${outlineColour})
|
|
23
23
|
drop-shadow(${px} -${px} 0px ${outlineColour})
|
|
24
|
-
drop-shadow(-${px} -${px} 0px ${outlineColour})
|
|
24
|
+
drop-shadow(-${px} -${px} 0px ${outlineColour})`;
|
|
25
25
|
};
|
|
26
26
|
exports.HardOutlineFilter = HardOutlineFilter;
|
|
27
27
|
/** disable user text selection */
|
package/package.json
CHANGED