@elliemae/ds-dataviz-pie 3.6.0-next.3
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/cjs/Pie.js +49 -0
- package/dist/cjs/Pie.js.map +7 -0
- package/dist/cjs/PieContext.js +44 -0
- package/dist/cjs/PieContext.js.map +7 -0
- package/dist/cjs/config/useKeyboardNavigation.js +121 -0
- package/dist/cjs/config/useKeyboardNavigation.js.map +7 -0
- package/dist/cjs/config/usePie.js +61 -0
- package/dist/cjs/config/usePie.js.map +7 -0
- package/dist/cjs/index.js +32 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/parts/ChartContainer.js +64 -0
- package/dist/cjs/parts/ChartContainer.js.map +7 -0
- package/dist/cjs/parts/ColorLegend.js +70 -0
- package/dist/cjs/parts/ColorLegend.js.map +7 -0
- package/dist/cjs/parts/Pie.js +67 -0
- package/dist/cjs/parts/Pie.js.map +7 -0
- package/dist/cjs/parts/Point.js +81 -0
- package/dist/cjs/parts/Point.js.map +7 -0
- package/dist/cjs/parts/Slice.js +103 -0
- package/dist/cjs/parts/Slice.js.map +7 -0
- package/dist/cjs/parts/Tooltip.js +55 -0
- package/dist/cjs/parts/Tooltip.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +44 -0
- package/dist/cjs/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/styles.js +99 -0
- package/dist/cjs/styles.js.map +7 -0
- package/dist/esm/Pie.js +23 -0
- package/dist/esm/Pie.js.map +7 -0
- package/dist/esm/PieContext.js +18 -0
- package/dist/esm/PieContext.js.map +7 -0
- package/dist/esm/config/useKeyboardNavigation.js +95 -0
- package/dist/esm/config/useKeyboardNavigation.js.map +7 -0
- package/dist/esm/config/usePie.js +35 -0
- package/dist/esm/config/usePie.js.map +7 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/parts/ChartContainer.js +38 -0
- package/dist/esm/parts/ChartContainer.js.map +7 -0
- package/dist/esm/parts/ColorLegend.js +44 -0
- package/dist/esm/parts/ColorLegend.js.map +7 -0
- package/dist/esm/parts/Pie.js +41 -0
- package/dist/esm/parts/Pie.js.map +7 -0
- package/dist/esm/parts/Point.js +55 -0
- package/dist/esm/parts/Point.js.map +7 -0
- package/dist/esm/parts/Slice.js +77 -0
- package/dist/esm/parts/Slice.js.map +7 -0
- package/dist/esm/parts/Tooltip.js +29 -0
- package/dist/esm/parts/Tooltip.js.map +7 -0
- package/dist/esm/react-desc-prop-types.js +18 -0
- package/dist/esm/react-desc-prop-types.js.map +7 -0
- package/dist/esm/styles.js +73 -0
- package/dist/esm/styles.js.map +7 -0
- package/package.json +76 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var Point_exports = {};
|
|
26
|
+
__export(Point_exports, {
|
|
27
|
+
Point: () => Point
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(Point_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_ds_tooltip = require("@elliemae/ds-tooltip");
|
|
34
|
+
var import_styles = require("../styles");
|
|
35
|
+
var import_PieContext = require("../PieContext");
|
|
36
|
+
const Point = ({ x, y, id, label, opacity }) => {
|
|
37
|
+
const {
|
|
38
|
+
activePoint,
|
|
39
|
+
props: { circleRadius, xAxis }
|
|
40
|
+
} = (0, import_react.useContext)(import_PieContext.PieContext);
|
|
41
|
+
const isFocused = activePoint === id;
|
|
42
|
+
const focusableElement = (0, import_react.useRef)();
|
|
43
|
+
const handleRef = (0, import_react.useCallback)(
|
|
44
|
+
(newRef) => {
|
|
45
|
+
if (focusableElement.current)
|
|
46
|
+
focusableElement.current = newRef;
|
|
47
|
+
if (isFocused)
|
|
48
|
+
newRef?.focus();
|
|
49
|
+
},
|
|
50
|
+
[isFocused]
|
|
51
|
+
);
|
|
52
|
+
return (0, import_react.useMemo)(
|
|
53
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
54
|
+
transform: `translate(${x},${y})`,
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledPoint, {
|
|
57
|
+
id: `${id}-mark`,
|
|
58
|
+
isFocused,
|
|
59
|
+
r: circleRadius,
|
|
60
|
+
opacity
|
|
61
|
+
}),
|
|
62
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("foreignObject", {
|
|
63
|
+
width: circleRadius * 2,
|
|
64
|
+
height: circleRadius * 2,
|
|
65
|
+
style: { transform: `translate(-${circleRadius}px, -${circleRadius}px)` },
|
|
66
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_tooltip.DSTooltipV3, {
|
|
67
|
+
withoutAnimation: true,
|
|
68
|
+
text: label,
|
|
69
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyleFocusableRegion, {
|
|
70
|
+
s: circleRadius,
|
|
71
|
+
tabIndex: -1,
|
|
72
|
+
ref: handleRef
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
]
|
|
77
|
+
}),
|
|
78
|
+
[circleRadius, handleRef, id, isFocused, label, opacity, x, y]
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=Point.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/parts/Point.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useMemo, useRef, useCallback } from 'react';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport { StyledPoint, StyleFocusableRegion } from '../styles';\nimport { PieContext } from '../PieContext';\n\nexport const Point = ({ x, y, id, label, opacity }) => {\n const {\n activePoint,\n\n props: { circleRadius, xAxis },\n } = useContext(PieContext);\n\n const isFocused = activePoint === id;\n\n const focusableElement = useRef<HTMLDivElement>();\n const handleRef = useCallback(\n (newRef: HTMLDivElement) => {\n if (focusableElement.current) focusableElement.current = newRef;\n if (isFocused) newRef?.focus();\n },\n [isFocused],\n );\n\n return useMemo(\n () => (\n <g transform={`translate(${x},${y})`}>\n <StyledPoint id={`${id}-mark`} isFocused={isFocused} r={circleRadius} opacity={opacity}></StyledPoint>\n <foreignObject\n width={circleRadius * 2}\n height={circleRadius * 2}\n style={{ transform: `translate(-${circleRadius}px, -${circleRadius}px)` }}\n >\n <DSTooltipV3 withoutAnimation text={label}>\n <StyleFocusableRegion\n s={circleRadius}\n // aria-label={`${xValue} ${d[yValue]}`}\n tabIndex={-1}\n ref={handleRef}\n ></StyleFocusableRegion>\n </DSTooltipV3>\n </foreignObject>\n </g>\n ),\n [circleRadius, handleRef, id, isFocused, label, opacity, x, y],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAAA,mBAAgE;AAChE,wBAA4B;AAC5B,oBAAkD;AAClD,wBAA2B;AAEpB,MAAM,QAAQ,CAAC,EAAE,GAAG,GAAG,IAAI,OAAO,QAAQ,MAAM;AACrD,QAAM;AAAA,IACJ;AAAA,IAEA,OAAO,EAAE,cAAc,MAAM;AAAA,EAC/B,QAAI,yBAAW,4BAAU;AAEzB,QAAM,YAAY,gBAAgB;AAElC,QAAM,uBAAmB,qBAAuB;AAChD,QAAM,gBAAY;AAAA,IAChB,CAAC,WAA2B;AAC1B,UAAI,iBAAiB;AAAS,yBAAiB,UAAU;AACzD,UAAI;AAAW,gBAAQ,MAAM;AAAA,IAC/B;AAAA,IACA,CAAC,SAAS;AAAA,EACZ;AAEA,aAAO;AAAA,IACL,MACE,6CAAC;AAAA,MAAE,WAAW,aAAa,KAAK;AAAA,MAC9B;AAAA,oDAAC;AAAA,UAAY,IAAI,GAAG;AAAA,UAAW;AAAA,UAAsB,GAAG;AAAA,UAAc;AAAA,SAAkB;AAAA,QACxF,4CAAC;AAAA,UACC,OAAO,eAAe;AAAA,UACtB,QAAQ,eAAe;AAAA,UACvB,OAAO,EAAE,WAAW,cAAc,oBAAoB,kBAAkB;AAAA,UAExE,sDAAC;AAAA,YAAY,kBAAgB;AAAA,YAAC,MAAM;AAAA,YAClC,sDAAC;AAAA,cACC,GAAG;AAAA,cAEH,UAAU;AAAA,cACV,KAAK;AAAA,aACN;AAAA,WACH;AAAA,SACF;AAAA;AAAA,KACF;AAAA,IAEF,CAAC,cAAc,WAAW,IAAI,WAAW,OAAO,SAAS,GAAG,CAAC;AAAA,EAC/D;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var Slice_exports = {};
|
|
26
|
+
__export(Slice_exports, {
|
|
27
|
+
Slice: () => Slice
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(Slice_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_d3 = require("d3");
|
|
34
|
+
var import_PieContext = require("../PieContext");
|
|
35
|
+
var import_Tooltip = require("./Tooltip");
|
|
36
|
+
const Slice = ({ data }) => {
|
|
37
|
+
const {
|
|
38
|
+
innerHeight,
|
|
39
|
+
innerWidth,
|
|
40
|
+
activeSerie,
|
|
41
|
+
setActiveSerie,
|
|
42
|
+
props: { series, innerRadius: innerRadiusProp, isHalfPie, TooltipRenderer }
|
|
43
|
+
} = (0, import_react.useContext)(import_PieContext.PieContext);
|
|
44
|
+
const [isTooltipShown, setIsTooltipShown] = (0, import_react.useState)(false);
|
|
45
|
+
const innerRadius = innerRadiusProp ?? 0;
|
|
46
|
+
const tooltipRef = (0, import_react.useRef)(null);
|
|
47
|
+
const arcRef = (0, import_react.useRef)(null);
|
|
48
|
+
const radius = isHalfPie ? Math.min(innerWidth, innerHeight) : Math.min(innerWidth, innerHeight) / 2;
|
|
49
|
+
const { startAngle, endAngle, index, value } = data;
|
|
50
|
+
const currentStartAngle = isHalfPie ? startAngle / 2 : startAngle;
|
|
51
|
+
const currentEndAngle = isHalfPie ? endAngle / 2 : endAngle;
|
|
52
|
+
const serieData = series?.find((serie) => serie.name === data.data[0]);
|
|
53
|
+
const { color, name } = serieData;
|
|
54
|
+
const sliceData = (0, import_d3.arc)().innerRadius(innerRadius).outerRadius(radius).startAngle(currentStartAngle).endAngle(currentEndAngle);
|
|
55
|
+
const deltaAngle = currentStartAngle + (currentEndAngle - currentStartAngle) / 2;
|
|
56
|
+
const x = radius * Math.sin(deltaAngle);
|
|
57
|
+
const y = -radius * Math.cos(deltaAngle);
|
|
58
|
+
const isOpen = (0, import_react.useMemo)(
|
|
59
|
+
() => activeSerie === "" && isTooltipShown || activeSerie === `${name}-${index}` && !isTooltipShown,
|
|
60
|
+
[activeSerie, index, isTooltipShown, name]
|
|
61
|
+
);
|
|
62
|
+
(0, import_react.useEffect)(() => {
|
|
63
|
+
if (arcRef.current) {
|
|
64
|
+
(0, import_d3.select)(arcRef.current).attr("d", sliceData());
|
|
65
|
+
}
|
|
66
|
+
}, [sliceData]);
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
68
|
+
onMouseEnter: () => {
|
|
69
|
+
setActiveSerie("");
|
|
70
|
+
setIsTooltipShown(true);
|
|
71
|
+
},
|
|
72
|
+
onMouseLeave: (e) => {
|
|
73
|
+
setIsTooltipShown(false);
|
|
74
|
+
},
|
|
75
|
+
transform: isHalfPie ? "rotate(-90)" : "",
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
|
|
78
|
+
ref: arcRef,
|
|
79
|
+
fill: color,
|
|
80
|
+
stroke: "white"
|
|
81
|
+
}),
|
|
82
|
+
name !== "no-data" && TooltipRenderer && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("foreignObject", {
|
|
83
|
+
x,
|
|
84
|
+
y,
|
|
85
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Tooltip.Tooltip, {
|
|
86
|
+
isTooltipShown: isOpen,
|
|
87
|
+
withoutAnimation: true,
|
|
88
|
+
onFocus: () => {
|
|
89
|
+
setActiveSerie(`${name}-${index}`);
|
|
90
|
+
},
|
|
91
|
+
onBlur: () => {
|
|
92
|
+
setActiveSerie("");
|
|
93
|
+
},
|
|
94
|
+
startPlacementPreference: "bottom",
|
|
95
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipRenderer, {
|
|
96
|
+
data: serieData
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=Slice.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/parts/Slice.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useState, useEffect, useMemo, useRef, useContext } from 'react';\nimport { arc, select } from 'd3';\nimport { PieContext } from '../PieContext';\nimport { Tooltip } from './Tooltip';\nexport const Slice = ({ data }) => {\n const {\n innerHeight,\n innerWidth,\n activeSerie,\n setActiveSerie,\n props: { series, innerRadius: innerRadiusProp, isHalfPie, TooltipRenderer },\n } = useContext(PieContext);\n\n const [isTooltipShown, setIsTooltipShown] = useState(false);\n\n const innerRadius = innerRadiusProp ?? 0;\n const tooltipRef = useRef(null);\n const arcRef = useRef(null);\n\n const radius = isHalfPie ? Math.min(innerWidth, innerHeight) : Math.min(innerWidth, innerHeight) / 2;\n const { startAngle, endAngle, index, value } = data;\n const currentStartAngle = isHalfPie ? startAngle / 2 : startAngle;\n const currentEndAngle = isHalfPie ? endAngle / 2 : endAngle;\n\n const serieData = series?.find((serie) => serie.name === data.data[0]);\n const { color, name } = serieData;\n\n const sliceData = arc()\n .innerRadius(innerRadius)\n .outerRadius(radius)\n .startAngle(currentStartAngle)\n .endAngle(currentEndAngle);\n const deltaAngle = currentStartAngle + (currentEndAngle - currentStartAngle) / 2;\n const x = radius * Math.sin(deltaAngle);\n const y = -radius * Math.cos(deltaAngle);\n\n const isOpen = useMemo(\n () => (activeSerie === '' && isTooltipShown) || (activeSerie === `${name}-${index}` && !isTooltipShown),\n [activeSerie, index, isTooltipShown, name],\n );\n\n useEffect(() => {\n if (arcRef.current) {\n select(arcRef.current).attr('d', sliceData());\n }\n }, [sliceData]);\n\n return (\n <g\n onMouseEnter={() => {\n setActiveSerie('');\n setIsTooltipShown(true);\n }}\n onMouseLeave={(e) => {\n setIsTooltipShown(false);\n }}\n transform={isHalfPie ? 'rotate(-90)' : ''}\n >\n <path ref={arcRef} fill={color} stroke=\"white\"></path>\n {name !== 'no-data' && TooltipRenderer && (\n <foreignObject x={x} y={y}>\n <Tooltip\n isTooltipShown={isOpen}\n withoutAnimation\n onFocus={() => {\n setActiveSerie(`${name}-${index}`);\n }}\n onBlur={() => {\n setActiveSerie('');\n }}\n startPlacementPreference=\"bottom\"\n >\n <TooltipRenderer data={serieData} />\n </Tooltip>\n </foreignObject>\n )}\n\n {/* {isOpen && (\n <g>\n <circle r=\"5\" fill={color} cx={x} cy={y} stroke=\"black\" />\n </g>\n )} */}\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAAA,mBAAwE;AACxE,gBAA4B;AAC5B,wBAA2B;AAC3B,qBAAwB;AACjB,MAAM,QAAQ,CAAC,EAAE,KAAK,MAAM;AACjC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,QAAQ,aAAa,iBAAiB,WAAW,gBAAgB;AAAA,EAC5E,QAAI,yBAAW,4BAAU;AAEzB,QAAM,CAAC,gBAAgB,iBAAiB,QAAI,uBAAS,KAAK;AAE1D,QAAM,cAAc,mBAAmB;AACvC,QAAM,iBAAa,qBAAO,IAAI;AAC9B,QAAM,aAAS,qBAAO,IAAI;AAE1B,QAAM,SAAS,YAAY,KAAK,IAAI,YAAY,WAAW,IAAI,KAAK,IAAI,YAAY,WAAW,IAAI;AACnG,QAAM,EAAE,YAAY,UAAU,OAAO,MAAM,IAAI;AAC/C,QAAM,oBAAoB,YAAY,aAAa,IAAI;AACvD,QAAM,kBAAkB,YAAY,WAAW,IAAI;AAEnD,QAAM,YAAY,QAAQ,KAAK,CAAC,UAAU,MAAM,SAAS,KAAK,KAAK,EAAE;AACrE,QAAM,EAAE,OAAO,KAAK,IAAI;AAExB,QAAM,gBAAY,eAAI,EACnB,YAAY,WAAW,EACvB,YAAY,MAAM,EAClB,WAAW,iBAAiB,EAC5B,SAAS,eAAe;AAC3B,QAAM,aAAa,qBAAqB,kBAAkB,qBAAqB;AAC/E,QAAM,IAAI,SAAS,KAAK,IAAI,UAAU;AACtC,QAAM,IAAI,CAAC,SAAS,KAAK,IAAI,UAAU;AAEvC,QAAM,aAAS;AAAA,IACb,MAAO,gBAAgB,MAAM,kBAAoB,gBAAgB,GAAG,QAAQ,WAAW,CAAC;AAAA,IACxF,CAAC,aAAa,OAAO,gBAAgB,IAAI;AAAA,EAC3C;AAEA,8BAAU,MAAM;AACd,QAAI,OAAO,SAAS;AAClB,4BAAO,OAAO,OAAO,EAAE,KAAK,KAAK,UAAU,CAAC;AAAA,IAC9C;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAEd,SACE,6CAAC;AAAA,IACC,cAAc,MAAM;AAClB,qBAAe,EAAE;AACjB,wBAAkB,IAAI;AAAA,IACxB;AAAA,IACA,cAAc,CAAC,MAAM;AACnB,wBAAkB,KAAK;AAAA,IACzB;AAAA,IACA,WAAW,YAAY,gBAAgB;AAAA,IAEvC;AAAA,kDAAC;AAAA,QAAK,KAAK;AAAA,QAAQ,MAAM;AAAA,QAAO,QAAO;AAAA,OAAQ;AAAA,MAC9C,SAAS,aAAa,mBACrB,4CAAC;AAAA,QAAc;AAAA,QAAM;AAAA,QACnB,sDAAC;AAAA,UACC,gBAAgB;AAAA,UAChB,kBAAgB;AAAA,UAChB,SAAS,MAAM;AACb,2BAAe,GAAG,QAAQ,OAAO;AAAA,UACnC;AAAA,UACA,QAAQ,MAAM;AACZ,2BAAe,EAAE;AAAA,UACnB;AAAA,UACA,0BAAyB;AAAA,UAEzB,sDAAC;AAAA,YAAgB,MAAM;AAAA,WAAW;AAAA,SACpC;AAAA,OACF;AAAA;AAAA,GAQJ;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var Tooltip_exports = {};
|
|
26
|
+
__export(Tooltip_exports, {
|
|
27
|
+
Tooltip: () => Tooltip
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(Tooltip_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_ds_popperjs = require("@elliemae/ds-popperjs");
|
|
34
|
+
const Tooltip = (props) => {
|
|
35
|
+
const { children, innerRef, isTooltipShown, onFocus, onBlur, ...extraPopperJsProps } = props;
|
|
36
|
+
const [referenceElement, setReferenceElement] = (0, import_react.useState)();
|
|
37
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
38
|
+
onFocus,
|
|
39
|
+
onBlur,
|
|
40
|
+
tabIndex: 0,
|
|
41
|
+
ref: setReferenceElement,
|
|
42
|
+
className: "myclass",
|
|
43
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_popperjs.DSPopperJS, {
|
|
44
|
+
referenceElement,
|
|
45
|
+
showPopover: isTooltipShown,
|
|
46
|
+
zIndex: 3e3,
|
|
47
|
+
...extraPopperJsProps,
|
|
48
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
49
|
+
style: { backgroundColor: "white" },
|
|
50
|
+
children
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/parts/Tooltip.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\nimport React, { useState } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\n\nexport const Tooltip: React.ComponentType<any> = (props) => {\n const { children, innerRef, isTooltipShown, onFocus, onBlur, ...extraPopperJsProps } = props;\n\n const [referenceElement, setReferenceElement] = useState<HTMLSpanElement | null>();\n\n return (\n <div onFocus={onFocus} onBlur={onBlur} tabIndex={0} ref={setReferenceElement} className=\"myclass\">\n <DSPopperJS\n referenceElement={referenceElement}\n showPopover={isTooltipShown}\n zIndex={3000}\n {...extraPopperJsProps}\n >\n <div style={{ backgroundColor: 'white' }}>{children}</div>\n </DSPopperJS>\n </div>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,mBAAgC;AAChC,yBAA2B;AAEpB,MAAM,UAAoC,CAAC,UAAU;AAC1D,QAAM,EAAE,UAAU,UAAU,gBAAgB,SAAS,WAAW,mBAAmB,IAAI;AAEvF,QAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAAiC;AAEjF,SACE,4CAAC;AAAA,IAAI;AAAA,IAAkB;AAAA,IAAgB,UAAU;AAAA,IAAG,KAAK;AAAA,IAAqB,WAAU;AAAA,IACtF,sDAAC;AAAA,MACC;AAAA,MACA,aAAa;AAAA,MACb,QAAQ;AAAA,MACP,GAAG;AAAA,MAEJ,sDAAC;AAAA,QAAI,OAAO,EAAE,iBAAiB,QAAQ;AAAA,QAAI;AAAA,OAAS;AAAA,KACtD;AAAA,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var react_desc_prop_types_exports = {};
|
|
26
|
+
__export(react_desc_prop_types_exports, {
|
|
27
|
+
propTypes: () => propTypes
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(react_desc_prop_types_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
32
|
+
const propTypes = {
|
|
33
|
+
...import_ds_utilities.globalAttributesPropTypes,
|
|
34
|
+
height: import_ds_utilities.PropTypes.number.isRequired.description("height").defaultValue(""),
|
|
35
|
+
width: import_ds_utilities.PropTypes.number.isRequired.description("height").defaultValue(""),
|
|
36
|
+
margin: import_ds_utilities.PropTypes.shape({
|
|
37
|
+
top: import_ds_utilities.PropTypes.number,
|
|
38
|
+
bottom: import_ds_utilities.PropTypes.number,
|
|
39
|
+
left: import_ds_utilities.PropTypes.number,
|
|
40
|
+
right: import_ds_utilities.PropTypes.number
|
|
41
|
+
}).isRequired.description("margin").defaultValue(""),
|
|
42
|
+
series: import_ds_utilities.PropTypes.arrayOf(import_ds_utilities.PropTypes.object).description("yValue").defaultValue("")
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/react-desc-prop-types.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-utilities';\n\ntype MarginT = {\n top: number;\n left: number;\n right: number;\n bottom: number;\n};\n\nexport declare namespace DSPieT {\n export interface SeriesT {\n name: string;\n data: number;\n color: string;\n }\n export interface Props {\n series: SeriesT[];\n height: number;\n width: number;\n margin: MarginT;\n }\n}\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n height: PropTypes.number.isRequired.description('height').defaultValue(''),\n width: PropTypes.number.isRequired.description('height').defaultValue(''),\n margin: PropTypes.shape({\n top: PropTypes.number,\n bottom: PropTypes.number,\n left: PropTypes.number,\n right: PropTypes.number,\n })\n .isRequired.description('margin')\n .defaultValue(''),\n series: PropTypes.arrayOf(PropTypes.object).description('yValue').defaultValue(''),\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,0BAAqD;AAuB9C,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,QAAQ,8BAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACzE,OAAO,8BAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACxE,QAAQ,8BAAU,MAAM;AAAA,IACtB,KAAK,8BAAU;AAAA,IACf,QAAQ,8BAAU;AAAA,IAClB,MAAM,8BAAU;AAAA,IAChB,OAAO,8BAAU;AAAA,EACnB,CAAC,EACE,WAAW,YAAY,QAAQ,EAC/B,aAAa,EAAE;AAAA,EAClB,QAAQ,8BAAU,QAAQ,8BAAU,MAAM,EAAE,YAAY,QAAQ,EAAE,aAAa,EAAE;AACnF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var styles_exports = {};
|
|
26
|
+
__export(styles_exports, {
|
|
27
|
+
StyleFocusableRegion: () => StyleFocusableRegion,
|
|
28
|
+
StyledArea: () => StyledArea,
|
|
29
|
+
StyledAxis: () => StyledAxis,
|
|
30
|
+
StyledGrid: () => StyledGrid,
|
|
31
|
+
StyledLine: () => StyledLine,
|
|
32
|
+
StyledMark: () => StyledMark,
|
|
33
|
+
StyledPoint: () => StyledPoint,
|
|
34
|
+
StyledSVGWrapper: () => StyledSVGWrapper
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(styles_exports);
|
|
37
|
+
var React = __toESM(require("react"));
|
|
38
|
+
var import_ds_system = require("@elliemae/ds-system");
|
|
39
|
+
const StyledSVGWrapper = import_ds_system.styled.div`
|
|
40
|
+
:focus {
|
|
41
|
+
outline: none;
|
|
42
|
+
}
|
|
43
|
+
:focus-within {
|
|
44
|
+
outline: none;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
const StyledAxis = (0, import_ds_system.styled)("g")`
|
|
48
|
+
text {
|
|
49
|
+
fill: #635f5d;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
text.axis-label {
|
|
53
|
+
font-size: 2.5em;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.tick text {
|
|
57
|
+
${({ color }) => color ? `fill: ${color}` : ""}
|
|
58
|
+
}
|
|
59
|
+
.tick line {
|
|
60
|
+
${({ color }) => color ? `stroke: ${color}` : ""}
|
|
61
|
+
}
|
|
62
|
+
line {
|
|
63
|
+
stroke: #c0c0bb;
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
const StyledGrid = (0, import_ds_system.styled)("g")`
|
|
67
|
+
line {
|
|
68
|
+
stroke: #c0c0bb;
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
const borderCircle = import_ds_system.css`
|
|
72
|
+
stroke: red;
|
|
73
|
+
stroke-width: 2;
|
|
74
|
+
`;
|
|
75
|
+
const StyledMark = (0, import_ds_system.styled)("rect")`
|
|
76
|
+
${({ isFocused }) => isFocused ? borderCircle : ""};
|
|
77
|
+
`;
|
|
78
|
+
const StyleFocusableRegion = (0, import_ds_system.styled)("div")`
|
|
79
|
+
width: ${({ s }) => s * 2}px;
|
|
80
|
+
height: ${({ s }) => s * 2}px;
|
|
81
|
+
:focus {
|
|
82
|
+
outline: none;
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
const StyledLine = (0, import_ds_system.styled)("path")`
|
|
86
|
+
fill: none;
|
|
87
|
+
stroke-width: ${({ isActiveLine }) => isActiveLine ? 5 : 3};
|
|
88
|
+
stroke-linejoin: round;
|
|
89
|
+
`;
|
|
90
|
+
const StyledArea = (0, import_ds_system.styled)("path")`
|
|
91
|
+
stroke-width: ${({ isActiveLine }) => isActiveLine ? 5 : 3};
|
|
92
|
+
stroke-linejoin: round;
|
|
93
|
+
opacity: 0.8;
|
|
94
|
+
`;
|
|
95
|
+
const StyledPoint = (0, import_ds_system.styled)("circle")`
|
|
96
|
+
opacity: ${({ opacity }) => opacity};
|
|
97
|
+
${({ isFocused }) => isFocused ? borderCircle : ""};
|
|
98
|
+
`;
|
|
99
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/styles.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { styled, css } from '@elliemae/ds-system';\n\nexport const StyledSVGWrapper = styled.div`\n :focus {\n outline: none;\n }\n :focus-within {\n outline: none;\n }\n`;\n\nexport const StyledAxis = styled('g')`\n text {\n fill: #635f5d;\n }\n\n text.axis-label {\n font-size: 2.5em;\n }\n\n .tick text {\n ${({ color }) => (color ? `fill: ${color}` : '')}\n }\n .tick line {\n ${({ color }) => (color ? `stroke: ${color}` : '')}\n }\n line {\n stroke: #c0c0bb;\n }\n`;\n\nexport const StyledGrid = styled('g')`\n line {\n stroke: #c0c0bb;\n }\n`;\n\nconst borderCircle = css`\n stroke: red;\n stroke-width: 2;\n`;\nexport const StyledMark = styled('rect')<{ isFocused: boolean }>`\n ${({ isFocused }) => (isFocused ? borderCircle : '')};\n`;\n\nexport const StyleFocusableRegion = styled('div')<{ s: number }>`\n width: ${({ s }) => s * 2 ?? '1'}px;\n height: ${({ s }) => s * 2 ?? '1'}px;\n :focus {\n outline: none;\n }\n`;\n\nexport const StyledLine = styled('path')`\n fill: none;\n stroke-width: ${({ isActiveLine }) => (isActiveLine ? 5 : 3)};\n stroke-linejoin: round;\n`;\nexport const StyledArea = styled('path')`\n stroke-width: ${({ isActiveLine }) => (isActiveLine ? 5 : 3)};\n stroke-linejoin: round;\n opacity: 0.8;\n`;\n\nexport const StyledPoint = styled('circle')<{ isFocused: boolean }>`\n opacity: ${({ opacity }) => opacity};\n ${({ isFocused }) => (isFocused ? borderCircle : '')};\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA4B;AAErB,MAAM,mBAAmB,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAShC,MAAM,iBAAa,yBAAO,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAU9B,CAAC,EAAE,MAAM,MAAO,QAAQ,SAAS,UAAU;AAAA;AAAA;AAAA,MAG3C,CAAC,EAAE,MAAM,MAAO,QAAQ,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAO5C,MAAM,iBAAa,yBAAO,GAAG;AAAA;AAAA;AAAA;AAAA;AAMpC,MAAM,eAAe;AAAA;AAAA;AAAA;AAId,MAAM,iBAAa,yBAAO,MAAM;AAAA,IACnC,CAAC,EAAE,UAAU,MAAO,YAAY,eAAe;AAAA;AAG5C,MAAM,2BAAuB,yBAAO,KAAK;AAAA,WACrC,CAAC,EAAE,EAAE,MAAM,IAAI;AAAA,YACd,CAAC,EAAE,EAAE,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA;AAMpB,MAAM,iBAAa,yBAAO,MAAM;AAAA;AAAA,kBAErB,CAAC,EAAE,aAAa,MAAO,eAAe,IAAI;AAAA;AAAA;AAGrD,MAAM,iBAAa,yBAAO,MAAM;AAAA,kBACrB,CAAC,EAAE,aAAa,MAAO,eAAe,IAAI;AAAA;AAAA;AAAA;AAKrD,MAAM,kBAAc,yBAAO,QAAQ;AAAA,aAC7B,CAAC,EAAE,QAAQ,MAAM;AAAA,IAC1B,CAAC,EAAE,UAAU,MAAO,YAAY,eAAe;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/Pie.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ChartContainer } from "./parts/ChartContainer";
|
|
4
|
+
import { Pie } from "./parts/Pie";
|
|
5
|
+
import { PieContext } from "./PieContext";
|
|
6
|
+
import { usePie } from "./config/usePie";
|
|
7
|
+
import { ColorLegend } from "./parts/ColorLegend";
|
|
8
|
+
const PieChart = (props) => {
|
|
9
|
+
const ctx = usePie(props);
|
|
10
|
+
return /* @__PURE__ */ jsx(PieContext.Provider, {
|
|
11
|
+
value: ctx,
|
|
12
|
+
children: /* @__PURE__ */ jsxs(ChartContainer, {
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ jsx(ColorLegend, {}),
|
|
15
|
+
/* @__PURE__ */ jsx(Pie, {})
|
|
16
|
+
]
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
PieChart
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=Pie.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/Pie.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { ChartContainer } from './parts/ChartContainer';\nimport { Pie } from './parts/Pie';\nimport { PieContext } from './PieContext';\nimport { usePie } from './config/usePie';\nimport type { DSPieT } from './react-desc-prop-types';\nimport { ColorLegend } from './parts/ColorLegend';\nexport const PieChart: React.ComponentType<DSPieT.Props> = (props) => {\n const ctx = usePie(props);\n return (\n <PieContext.Provider value={ctx}>\n <ChartContainer>\n <ColorLegend />\n <Pie />\n </ChartContainer>\n </PieContext.Provider>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAS,sBAAsB;AAC/B,SAAS,WAAW;AACpB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAEvB,SAAS,mBAAmB;AACrB,MAAM,WAA8C,CAAC,UAAU;AACpE,QAAM,MAAM,OAAO,KAAK;AACxB,SACE,oBAAC,WAAW,UAAX;AAAA,IAAoB,OAAO;AAAA,IAC1B,+BAAC;AAAA,MACC;AAAA,4BAAC,eAAY;AAAA,QACb,oBAAC,OAAI;AAAA;AAAA,KACP;AAAA,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { createContext, createRef } from "react";
|
|
3
|
+
import { scaleOrdinal } from "d3";
|
|
4
|
+
const pieChartdefaultContext = {
|
|
5
|
+
innerHeight: 0,
|
|
6
|
+
innerWidth: 0,
|
|
7
|
+
activeSerie: "",
|
|
8
|
+
setActiveSerie: () => {
|
|
9
|
+
},
|
|
10
|
+
containerRef: createRef(),
|
|
11
|
+
groups: [],
|
|
12
|
+
colorScale: scaleOrdinal()
|
|
13
|
+
};
|
|
14
|
+
const PieContext = createContext(pieChartdefaultContext);
|
|
15
|
+
export {
|
|
16
|
+
PieContext
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=PieContext.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/PieContext.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext, createRef } from 'react';\nimport { scaleOrdinal, ScaleOrdinal } from 'd3';\nimport { DSPieT } from './react-desc-prop-types';\n\ninterface PieChartContextT {\n props: Partial<DSPieT.Props>;\n innerHeight: number;\n innerWidth: number;\n activeSerie: string;\n setActiveSerie: React.Dispatch<React.SetStateAction<string>>;\n containerRef: React.RefObject<HTMLDivElement>;\n groups: string[];\n colorScale: ScaleOrdinal<string, unknown, never>;\n}\n\nconst pieChartdefaultContext: PieChartContextT = {\n // props: defaultProps,\n innerHeight: 0,\n innerWidth: 0,\n activeSerie: '',\n setActiveSerie: () => {},\n containerRef: createRef<HTMLDivElement>(),\n groups: [],\n colorScale: scaleOrdinal(),\n};\n\nexport const PieContext = createContext(pieChartdefaultContext);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe,iBAAiB;AACzC,SAAS,oBAAkC;AAc3C,MAAM,yBAA2C;AAAA,EAE/C,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,cAAc,UAA0B;AAAA,EACxC,QAAQ,CAAC;AAAA,EACT,YAAY,aAAa;AAC3B;AAEO,MAAM,aAAa,cAAc,sBAAsB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useContext, useMemo, useState } from "react";
|
|
3
|
+
import { PieContext } from "../PieContext";
|
|
4
|
+
const findInCircularList = (list, from, step = 1) => {
|
|
5
|
+
for (let i = (from + step + list.length) % list.length; i !== from && from > -1; i = (i + step + list.length) % list.length) {
|
|
6
|
+
if (list[i])
|
|
7
|
+
return i;
|
|
8
|
+
}
|
|
9
|
+
return from;
|
|
10
|
+
};
|
|
11
|
+
const useKeyboardNavigation = () => {
|
|
12
|
+
const {
|
|
13
|
+
activePoint,
|
|
14
|
+
setActivePoint,
|
|
15
|
+
containerRef,
|
|
16
|
+
groups,
|
|
17
|
+
yScale,
|
|
18
|
+
props: { data }
|
|
19
|
+
} = useContext(PieContext);
|
|
20
|
+
const [currentFocusedDataset, setCurrentFocusedDataset] = useState(groups[0]);
|
|
21
|
+
const currentGroup = useMemo(() => data.find((d) => d.name === currentFocusedDataset), [currentFocusedDataset, data]);
|
|
22
|
+
const currentItemIndex = useMemo(
|
|
23
|
+
() => currentGroup.data.findIndex((opt) => opt.key === activePoint),
|
|
24
|
+
[activePoint, currentGroup]
|
|
25
|
+
);
|
|
26
|
+
const handleOnFocus = useCallback(
|
|
27
|
+
(e) => {
|
|
28
|
+
console.log("focus");
|
|
29
|
+
if (containerRef?.current === e.target) {
|
|
30
|
+
setActivePoint(currentGroup.data[0].key);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
[containerRef, currentGroup, setActivePoint]
|
|
34
|
+
);
|
|
35
|
+
const handleOnBlur = useCallback(() => {
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
if (!containerRef?.current?.contains(document.activeElement) || containerRef?.current === document.activeElement) {
|
|
38
|
+
console.log("blur");
|
|
39
|
+
setActivePoint("");
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}, [containerRef, setActivePoint]);
|
|
43
|
+
const navigateSerie = useCallback(
|
|
44
|
+
(step) => {
|
|
45
|
+
const newValue = findInCircularList(
|
|
46
|
+
currentGroup.data.map((d) => d.value),
|
|
47
|
+
currentItemIndex,
|
|
48
|
+
step
|
|
49
|
+
);
|
|
50
|
+
setActivePoint(currentGroup.data[newValue].key);
|
|
51
|
+
},
|
|
52
|
+
[currentGroup.data, currentItemIndex, setActivePoint]
|
|
53
|
+
);
|
|
54
|
+
const changeSerie = useCallback(
|
|
55
|
+
(step) => {
|
|
56
|
+
setCurrentFocusedDataset((prev) => {
|
|
57
|
+
const nextGroup = findInCircularList(
|
|
58
|
+
groups,
|
|
59
|
+
groups.findIndex((item) => item === prev),
|
|
60
|
+
step
|
|
61
|
+
);
|
|
62
|
+
const nextGroupData = data.find((d) => d.name === groups[nextGroup]);
|
|
63
|
+
setActivePoint(nextGroupData.data[currentItemIndex].key);
|
|
64
|
+
return groups[nextGroup];
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
[currentItemIndex, data, setActivePoint, groups]
|
|
68
|
+
);
|
|
69
|
+
const onInputKeyDown = useCallback(
|
|
70
|
+
(e) => {
|
|
71
|
+
if (e.code !== "Tab") {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
}
|
|
74
|
+
if (["ArrowLeft", "ArrowRight"].includes(e.code)) {
|
|
75
|
+
if (yScale.bandwidth)
|
|
76
|
+
changeSerie(e.code === "ArrowLeft" ? -1 : 1);
|
|
77
|
+
else
|
|
78
|
+
navigateSerie(e.code === "ArrowLeft" ? -1 : 1);
|
|
79
|
+
}
|
|
80
|
+
if (["ArrowDown", "ArrowUp"].includes(e.code)) {
|
|
81
|
+
if (yScale.bandwidth)
|
|
82
|
+
navigateSerie(e.code === "ArrowDown" ? -1 : 1);
|
|
83
|
+
else
|
|
84
|
+
changeSerie(e.code === "ArrowDown" ? -1 : 1);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
[changeSerie, navigateSerie, yScale.bandwidth]
|
|
88
|
+
);
|
|
89
|
+
return { onInputKeyDown, handleOnBlur, handleOnFocus };
|
|
90
|
+
};
|
|
91
|
+
export {
|
|
92
|
+
findInCircularList,
|
|
93
|
+
useKeyboardNavigation
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=useKeyboardNavigation.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useKeyboardNavigation.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext, useMemo, useState } from 'react';\nimport { PieContext } from '../PieContext';\n\nexport const findInCircularList = (\n list,\n from: number,\n //criteria: (item) => boolean,\n step = 1,\n // eslint-disable-next-line max-params\n): number => {\n for (\n let i = (from + step + list.length) % list.length;\n i !== from && from > -1;\n i = (i + step + list.length) % list.length\n ) {\n if (list[i]) return i;\n }\n return from; // return same item\n};\n\nexport const useKeyboardNavigation = () => {\n const {\n activePoint,\n setActivePoint,\n containerRef,\n groups,\n yScale,\n props: { data },\n } = useContext(PieContext);\n\n const [currentFocusedDataset, setCurrentFocusedDataset] = useState(groups[0]);\n\n const currentGroup = useMemo(() => data.find((d) => d.name === currentFocusedDataset), [currentFocusedDataset, data]);\n\n const currentItemIndex = useMemo(\n () => currentGroup.data.findIndex((opt) => opt.key === activePoint),\n [activePoint, currentGroup],\n );\n\n const handleOnFocus: React.FocusEventHandler<HTMLDivElement> = useCallback(\n (e) => {\n console.log('focus');\n\n if (containerRef?.current === e.target) {\n setActivePoint(currentGroup.data[0].key);\n }\n },\n [containerRef, currentGroup, setActivePoint],\n );\n\n const handleOnBlur: React.FocusEventHandler<HTMLInputElement> = useCallback(() => {\n setTimeout(() => {\n if (\n !containerRef?.current?.contains(document.activeElement) ||\n containerRef?.current === document.activeElement\n ) {\n console.log('blur');\n setActivePoint('');\n }\n });\n }, [containerRef, setActivePoint]);\n\n const navigateSerie = useCallback(\n (step: number) => {\n const newValue = findInCircularList(\n currentGroup.data.map((d) => d.value),\n currentItemIndex,\n step,\n );\n setActivePoint(currentGroup.data[newValue].key);\n },\n [currentGroup.data, currentItemIndex, setActivePoint],\n );\n\n const changeSerie = useCallback(\n (step: number) => {\n setCurrentFocusedDataset((prev) => {\n const nextGroup = findInCircularList(\n groups,\n groups.findIndex((item) => item === prev),\n step,\n );\n const nextGroupData = data.find((d) => d.name === groups[nextGroup]);\n setActivePoint(nextGroupData.data[currentItemIndex].key);\n return groups[nextGroup];\n });\n },\n [currentItemIndex, data, setActivePoint, groups],\n );\n\n const onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement> = useCallback(\n (e) => {\n if (e.code !== 'Tab') {\n e.preventDefault();\n }\n if (['ArrowLeft', 'ArrowRight'].includes(e.code)) {\n if (yScale.bandwidth) changeSerie(e.code === 'ArrowLeft' ? -1 : 1);\n else navigateSerie(e.code === 'ArrowLeft' ? -1 : 1);\n }\n\n if (['ArrowDown', 'ArrowUp'].includes(e.code)) {\n if (yScale.bandwidth) navigateSerie(e.code === 'ArrowDown' ? -1 : 1);\n else changeSerie(e.code === 'ArrowDown' ? -1 : 1);\n }\n },\n [changeSerie, navigateSerie, yScale.bandwidth],\n );\n\n return { onInputKeyDown, handleOnBlur, handleOnFocus };\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|