@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
package/dist/cjs/Pie.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
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 Pie_exports = {};
|
|
26
|
+
__export(Pie_exports, {
|
|
27
|
+
PieChart: () => PieChart
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(Pie_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var import_ChartContainer = require("./parts/ChartContainer");
|
|
33
|
+
var import_Pie = require("./parts/Pie");
|
|
34
|
+
var import_PieContext = require("./PieContext");
|
|
35
|
+
var import_usePie = require("./config/usePie");
|
|
36
|
+
var import_ColorLegend = require("./parts/ColorLegend");
|
|
37
|
+
const PieChart = (props) => {
|
|
38
|
+
const ctx = (0, import_usePie.usePie)(props);
|
|
39
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_PieContext.PieContext.Provider, {
|
|
40
|
+
value: ctx,
|
|
41
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ChartContainer.ChartContainer, {
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ColorLegend.ColorLegend, {}),
|
|
44
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Pie.Pie, {})
|
|
45
|
+
]
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=Pie.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Pie.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,4BAA+B;AAC/B,iBAAoB;AACpB,wBAA2B;AAC3B,oBAAuB;AAEvB,yBAA4B;AACrB,MAAM,WAA8C,CAAC,UAAU;AACpE,QAAM,UAAM,sBAAO,KAAK;AACxB,SACE,4CAAC,6BAAW,UAAX;AAAA,IAAoB,OAAO;AAAA,IAC1B,uDAAC;AAAA,MACC;AAAA,oDAAC,kCAAY;AAAA,QACb,4CAAC,kBAAI;AAAA;AAAA,KACP;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 PieContext_exports = {};
|
|
26
|
+
__export(PieContext_exports, {
|
|
27
|
+
PieContext: () => PieContext
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(PieContext_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
var import_d3 = require("d3");
|
|
33
|
+
const pieChartdefaultContext = {
|
|
34
|
+
innerHeight: 0,
|
|
35
|
+
innerWidth: 0,
|
|
36
|
+
activeSerie: "",
|
|
37
|
+
setActiveSerie: () => {
|
|
38
|
+
},
|
|
39
|
+
containerRef: (0, import_react.createRef)(),
|
|
40
|
+
groups: [],
|
|
41
|
+
colorScale: (0, import_d3.scaleOrdinal)()
|
|
42
|
+
};
|
|
43
|
+
const PieContext = (0, import_react.createContext)(pieChartdefaultContext);
|
|
44
|
+
//# sourceMappingURL=PieContext.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/PieContext.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyC;AACzC,gBAA2C;AAc3C,MAAM,yBAA2C;AAAA,EAE/C,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,kBAAc,wBAA0B;AAAA,EACxC,QAAQ,CAAC;AAAA,EACT,gBAAY,wBAAa;AAC3B;AAEO,MAAM,iBAAa,4BAAc,sBAAsB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
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 useKeyboardNavigation_exports = {};
|
|
26
|
+
__export(useKeyboardNavigation_exports, {
|
|
27
|
+
findInCircularList: () => findInCircularList,
|
|
28
|
+
useKeyboardNavigation: () => useKeyboardNavigation
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(useKeyboardNavigation_exports);
|
|
31
|
+
var React = __toESM(require("react"));
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_PieContext = require("../PieContext");
|
|
34
|
+
const findInCircularList = (list, from, step = 1) => {
|
|
35
|
+
for (let i = (from + step + list.length) % list.length; i !== from && from > -1; i = (i + step + list.length) % list.length) {
|
|
36
|
+
if (list[i])
|
|
37
|
+
return i;
|
|
38
|
+
}
|
|
39
|
+
return from;
|
|
40
|
+
};
|
|
41
|
+
const useKeyboardNavigation = () => {
|
|
42
|
+
const {
|
|
43
|
+
activePoint,
|
|
44
|
+
setActivePoint,
|
|
45
|
+
containerRef,
|
|
46
|
+
groups,
|
|
47
|
+
yScale,
|
|
48
|
+
props: { data }
|
|
49
|
+
} = (0, import_react.useContext)(import_PieContext.PieContext);
|
|
50
|
+
const [currentFocusedDataset, setCurrentFocusedDataset] = (0, import_react.useState)(groups[0]);
|
|
51
|
+
const currentGroup = (0, import_react.useMemo)(() => data.find((d) => d.name === currentFocusedDataset), [currentFocusedDataset, data]);
|
|
52
|
+
const currentItemIndex = (0, import_react.useMemo)(
|
|
53
|
+
() => currentGroup.data.findIndex((opt) => opt.key === activePoint),
|
|
54
|
+
[activePoint, currentGroup]
|
|
55
|
+
);
|
|
56
|
+
const handleOnFocus = (0, import_react.useCallback)(
|
|
57
|
+
(e) => {
|
|
58
|
+
console.log("focus");
|
|
59
|
+
if (containerRef?.current === e.target) {
|
|
60
|
+
setActivePoint(currentGroup.data[0].key);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
[containerRef, currentGroup, setActivePoint]
|
|
64
|
+
);
|
|
65
|
+
const handleOnBlur = (0, import_react.useCallback)(() => {
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
if (!containerRef?.current?.contains(document.activeElement) || containerRef?.current === document.activeElement) {
|
|
68
|
+
console.log("blur");
|
|
69
|
+
setActivePoint("");
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}, [containerRef, setActivePoint]);
|
|
73
|
+
const navigateSerie = (0, import_react.useCallback)(
|
|
74
|
+
(step) => {
|
|
75
|
+
const newValue = findInCircularList(
|
|
76
|
+
currentGroup.data.map((d) => d.value),
|
|
77
|
+
currentItemIndex,
|
|
78
|
+
step
|
|
79
|
+
);
|
|
80
|
+
setActivePoint(currentGroup.data[newValue].key);
|
|
81
|
+
},
|
|
82
|
+
[currentGroup.data, currentItemIndex, setActivePoint]
|
|
83
|
+
);
|
|
84
|
+
const changeSerie = (0, import_react.useCallback)(
|
|
85
|
+
(step) => {
|
|
86
|
+
setCurrentFocusedDataset((prev) => {
|
|
87
|
+
const nextGroup = findInCircularList(
|
|
88
|
+
groups,
|
|
89
|
+
groups.findIndex((item) => item === prev),
|
|
90
|
+
step
|
|
91
|
+
);
|
|
92
|
+
const nextGroupData = data.find((d) => d.name === groups[nextGroup]);
|
|
93
|
+
setActivePoint(nextGroupData.data[currentItemIndex].key);
|
|
94
|
+
return groups[nextGroup];
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
[currentItemIndex, data, setActivePoint, groups]
|
|
98
|
+
);
|
|
99
|
+
const onInputKeyDown = (0, import_react.useCallback)(
|
|
100
|
+
(e) => {
|
|
101
|
+
if (e.code !== "Tab") {
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
}
|
|
104
|
+
if (["ArrowLeft", "ArrowRight"].includes(e.code)) {
|
|
105
|
+
if (yScale.bandwidth)
|
|
106
|
+
changeSerie(e.code === "ArrowLeft" ? -1 : 1);
|
|
107
|
+
else
|
|
108
|
+
navigateSerie(e.code === "ArrowLeft" ? -1 : 1);
|
|
109
|
+
}
|
|
110
|
+
if (["ArrowDown", "ArrowUp"].includes(e.code)) {
|
|
111
|
+
if (yScale.bandwidth)
|
|
112
|
+
navigateSerie(e.code === "ArrowDown" ? -1 : 1);
|
|
113
|
+
else
|
|
114
|
+
changeSerie(e.code === "ArrowDown" ? -1 : 1);
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
[changeSerie, navigateSerie, yScale.bandwidth]
|
|
118
|
+
);
|
|
119
|
+
return { onInputKeyDown, handleOnBlur, handleOnFocus };
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=useKeyboardNavigation.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/config/useKeyboardNavigation.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* 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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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 usePie_exports = {};
|
|
26
|
+
__export(usePie_exports, {
|
|
27
|
+
usePie: () => usePie
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(usePie_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
var import_d3 = require("d3");
|
|
33
|
+
const usePie = (props) => {
|
|
34
|
+
const { series, width, height, margin } = props;
|
|
35
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
36
|
+
const svgRef = (0, import_react.useRef)(null);
|
|
37
|
+
const [activeSerie, setActiveSerie] = (0, import_react.useState)("");
|
|
38
|
+
const innerHeight = height - margin.top - margin.bottom;
|
|
39
|
+
const innerWidth = width - margin.left - margin.right;
|
|
40
|
+
const groups = series.map((serie) => serie.name);
|
|
41
|
+
const data = series.reduce((acc, curr) => ({ ...acc, [curr.name]: curr.data }), {});
|
|
42
|
+
const pieGenerator = (0, import_d3.pie)().value(function(d) {
|
|
43
|
+
return d[1];
|
|
44
|
+
}).sort(null).padAngle(0.02);
|
|
45
|
+
const pieData = pieGenerator(Object.entries(data));
|
|
46
|
+
return (0, import_react.useMemo)(
|
|
47
|
+
() => ({
|
|
48
|
+
props,
|
|
49
|
+
innerHeight,
|
|
50
|
+
innerWidth,
|
|
51
|
+
groups,
|
|
52
|
+
svgRef,
|
|
53
|
+
containerRef,
|
|
54
|
+
activeSerie,
|
|
55
|
+
pieData,
|
|
56
|
+
setActiveSerie
|
|
57
|
+
}),
|
|
58
|
+
[props, pieData, innerHeight, innerWidth, groups, activeSerie]
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=usePie.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/config/usePie.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useMemo, useState, useRef } from 'react';\nimport { pie } from 'd3';\n// import { useValidateTypescriptPropTypes } from '@elliemae/ds-utilities';\nimport type { DSPieT } from '../react-desc-prop-types';\n\nexport const usePie = (props: DSPieT.Props) => {\n // useValidateTypescriptPropTypes(props, propTypes);\n\n const { series, width, height, margin } = props;\n\n const containerRef = useRef(null);\n const svgRef = useRef(null);\n\n const [activeSerie, setActiveSerie] = useState('');\n\n const innerHeight = height - margin.top - margin.bottom;\n const innerWidth = width - margin.left - margin.right;\n\n const groups = series.map((serie) => serie.name);\n\n const data = series.reduce((acc, curr) => ({ ...acc, [curr.name]: curr.data }), {});\n const pieGenerator = pie()\n .value(function (d) {\n return d[1];\n })\n .sort(null)\n .padAngle(0.02);\n const pieData = pieGenerator(Object.entries(data));\n\n return useMemo(\n () => ({\n props,\n innerHeight,\n innerWidth,\n groups,\n svgRef,\n containerRef,\n activeSerie,\n pieData,\n setActiveSerie,\n }),\n [props, pieData, innerHeight, innerWidth, groups, activeSerie],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA0C;AAC1C,gBAAoB;AAIb,MAAM,SAAS,CAAC,UAAwB;AAG7C,QAAM,EAAE,QAAQ,OAAO,QAAQ,OAAO,IAAI;AAE1C,QAAM,mBAAe,qBAAO,IAAI;AAChC,QAAM,aAAS,qBAAO,IAAI;AAE1B,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,EAAE;AAEjD,QAAM,cAAc,SAAS,OAAO,MAAM,OAAO;AACjD,QAAM,aAAa,QAAQ,OAAO,OAAO,OAAO;AAEhD,QAAM,SAAS,OAAO,IAAI,CAAC,UAAU,MAAM,IAAI;AAE/C,QAAM,OAAO,OAAO,OAAO,CAAC,KAAK,UAAU,EAAE,GAAG,KAAK,CAAC,KAAK,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;AAClF,QAAM,mBAAe,eAAI,EACtB,MAAM,SAAU,GAAG;AAClB,WAAO,EAAE;AAAA,EACX,CAAC,EACA,KAAK,IAAI,EACT,SAAS,IAAI;AAChB,QAAM,UAAU,aAAa,OAAO,QAAQ,IAAI,CAAC;AAEjD,aAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,OAAO,SAAS,aAAa,YAAY,QAAQ,WAAW;AAAA,EAC/D;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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 src_exports = {};
|
|
26
|
+
__export(src_exports, {
|
|
27
|
+
PieChart: () => import_Pie.PieChart
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(src_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_Pie = require("./Pie");
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export { PieChart } from './Pie';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,iBAAyB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 ChartContainer_exports = {};
|
|
26
|
+
__export(ChartContainer_exports, {
|
|
27
|
+
ChartContainer: () => ChartContainer
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(ChartContainer_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_styles = require("../styles");
|
|
34
|
+
var import_PieContext = require("../PieContext");
|
|
35
|
+
const ChartContainer = ({ children }) => {
|
|
36
|
+
const {
|
|
37
|
+
props: { width, height, margin, responsive },
|
|
38
|
+
containerRef,
|
|
39
|
+
activeSerie,
|
|
40
|
+
svgRef
|
|
41
|
+
} = (0, import_react.useContext)(import_PieContext.PieContext);
|
|
42
|
+
const dimensions = (0, import_react.useMemo)(
|
|
43
|
+
() => responsive ? {
|
|
44
|
+
viewBox: `0 0 ${width} ${height}`
|
|
45
|
+
} : {
|
|
46
|
+
width,
|
|
47
|
+
height
|
|
48
|
+
},
|
|
49
|
+
[height, responsive, width]
|
|
50
|
+
);
|
|
51
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledSVGWrapper, {
|
|
52
|
+
ref: containerRef,
|
|
53
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
|
|
54
|
+
ref: svgRef,
|
|
55
|
+
...dimensions,
|
|
56
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
57
|
+
className: "container",
|
|
58
|
+
transform: `translate(${margin.left},${margin.top})`,
|
|
59
|
+
children
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=ChartContainer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/parts/ChartContainer.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useMemo } from 'react';\nimport { StyledSVGWrapper } from '../styles';\n\nimport { PieContext } from '../PieContext';\n// import { useKeyboardNavigation } from '../config/useKeyboardNavigation';\ninterface ChartContainerT {\n children: JSX.Element | JSX.Element[] | string | string[];\n}\nexport const ChartContainer: React.ComponentType<ChartContainerT> = ({ children }) => {\n const {\n props: { width, height, margin, responsive },\n containerRef,\n activeSerie,\n svgRef,\n } = useContext(PieContext);\n\n const dimensions = useMemo(\n () =>\n responsive\n ? {\n viewBox: `0 0 ${width} ${height}`,\n }\n : {\n width,\n height,\n },\n [height, responsive, width],\n );\n // const { onInputKeyDown, handleOnBlur, handleOnFocus } = useKeyboardNavigation();\n return (\n <StyledSVGWrapper\n ref={containerRef}\n // onKeyDown={onInputKeyDown}\n // aria-hidden=\"true\"\n // tabIndex={activeSerie ? -1 : 0}\n // onBlur={handleOnBlur}\n // onFocus={handleOnFocus}\n // onMouseDown={(e) => e.preventDefault()}\n >\n <svg ref={svgRef} {...dimensions}>\n <g className=\"container\" transform={`translate(${margin.left},${margin.top})`}>\n {children}\n </g>\n </svg>\n </StyledSVGWrapper>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAAA,mBAA2C;AAC3C,oBAAiC;AAEjC,wBAA2B;AAKpB,MAAM,iBAAuD,CAAC,EAAE,SAAS,MAAM;AACpF,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO,QAAQ,QAAQ,WAAW;AAAA,IAC3C;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,yBAAW,4BAAU;AAEzB,QAAM,iBAAa;AAAA,IACjB,MACE,aACI;AAAA,MACE,SAAS,OAAO,SAAS;AAAA,IAC3B,IACA;AAAA,MACE;AAAA,MACA;AAAA,IACF;AAAA,IACN,CAAC,QAAQ,YAAY,KAAK;AAAA,EAC5B;AAEA,SACE,4CAAC;AAAA,IACC,KAAK;AAAA,IAQL,sDAAC;AAAA,MAAI,KAAK;AAAA,MAAS,GAAG;AAAA,MACpB,sDAAC;AAAA,QAAE,WAAU;AAAA,QAAY,WAAW,aAAa,OAAO,QAAQ,OAAO;AAAA,QACpE;AAAA,OACH;AAAA,KACF;AAAA,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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 ColorLegend_exports = {};
|
|
26
|
+
__export(ColorLegend_exports, {
|
|
27
|
+
ColorLegend: () => ColorLegend
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(ColorLegend_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_PieContext = require("../PieContext");
|
|
34
|
+
const ColorLegend = ({ tickSpacing = 20, tickSize = 10, tickTextOffset = 20 }) => {
|
|
35
|
+
const {
|
|
36
|
+
colorScale,
|
|
37
|
+
innerWidth,
|
|
38
|
+
props: { colorLegend, circleRadius }
|
|
39
|
+
} = (0, import_react.useContext)(import_PieContext.PieContext);
|
|
40
|
+
if (!colorLegend)
|
|
41
|
+
return null;
|
|
42
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
43
|
+
transform: `translate(${innerWidth + 30},30)`,
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
|
|
46
|
+
x: 35,
|
|
47
|
+
y: -25,
|
|
48
|
+
className: "axis-label",
|
|
49
|
+
textAnchor: "middle",
|
|
50
|
+
children: colorLegend.label
|
|
51
|
+
}),
|
|
52
|
+
colorScale.domain().map((domainValue, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
53
|
+
className: "tick",
|
|
54
|
+
transform: `translate(0,${i * tickSpacing})`,
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", {
|
|
57
|
+
fill: colorScale(domainValue),
|
|
58
|
+
r: circleRadius ?? tickSize
|
|
59
|
+
}),
|
|
60
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
|
|
61
|
+
x: tickTextOffset,
|
|
62
|
+
dy: ".32em",
|
|
63
|
+
children: domainValue
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
}))
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=ColorLegend.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/parts/ColorLegend.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useContext } from 'react';\nimport { PieContext } from '../PieContext';\n\nexport const ColorLegend = ({ tickSpacing = 20, tickSize = 10, tickTextOffset = 20 }) => {\n const {\n colorScale,\n innerWidth,\n props: { colorLegend, circleRadius },\n } = useContext(PieContext);\n\n if (!colorLegend) return null;\n return (\n <g transform={`translate(${innerWidth + 30},30)`}>\n <text x={35} y={-25} className=\"axis-label\" textAnchor=\"middle\">\n {colorLegend.label}\n </text>\n {colorScale.domain().map((domainValue, i) => (\n <g className=\"tick\" transform={`translate(0,${i * tickSpacing})`}>\n <circle fill={colorScale(domainValue)} r={circleRadius ?? tickSize} />\n <text x={tickTextOffset} dy=\".32em\">\n {domainValue}\n </text>\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,mBAAkC;AAClC,wBAA2B;AAEpB,MAAM,cAAc,CAAC,EAAE,cAAc,IAAI,WAAW,IAAI,iBAAiB,GAAG,MAAM;AACvF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO,EAAE,aAAa,aAAa;AAAA,EACrC,QAAI,yBAAW,4BAAU;AAEzB,MAAI,CAAC;AAAa,WAAO;AACzB,SACE,6CAAC;AAAA,IAAE,WAAW,aAAa,aAAa;AAAA,IACtC;AAAA,kDAAC;AAAA,QAAK,GAAG;AAAA,QAAI,GAAG;AAAA,QAAK,WAAU;AAAA,QAAa,YAAW;AAAA,QACpD,sBAAY;AAAA,OACf;AAAA,MACC,WAAW,OAAO,EAAE,IAAI,CAAC,aAAa,MACrC,6CAAC;AAAA,QAAE,WAAU;AAAA,QAAO,WAAW,eAAe,IAAI;AAAA,QAChD;AAAA,sDAAC;AAAA,YAAO,MAAM,WAAW,WAAW;AAAA,YAAG,GAAG,gBAAgB;AAAA,WAAU;AAAA,UACpE,4CAAC;AAAA,YAAK,GAAG;AAAA,YAAgB,IAAG;AAAA,YACzB;AAAA,WACH;AAAA;AAAA,OACF,CACD;AAAA;AAAA,GACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 Pie_exports = {};
|
|
26
|
+
__export(Pie_exports, {
|
|
27
|
+
Pie: () => Pie
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(Pie_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_Slice = require("./Slice");
|
|
34
|
+
var import_PieContext = require("../PieContext");
|
|
35
|
+
const Pie = () => {
|
|
36
|
+
const {
|
|
37
|
+
innerHeight,
|
|
38
|
+
innerWidth,
|
|
39
|
+
pieData,
|
|
40
|
+
props: { isHalfPie, label, innerRadius }
|
|
41
|
+
} = (0, import_react.useContext)(import_PieContext.PieContext);
|
|
42
|
+
const radius = Math.min(innerWidth, innerHeight) / 2;
|
|
43
|
+
const currentInnerHeight = isHalfPie ? innerHeight : innerHeight / 2;
|
|
44
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
45
|
+
transform: `translate(${innerWidth / 2},${currentInnerHeight})`,
|
|
46
|
+
children: [
|
|
47
|
+
pieData.map((slice) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Slice.Slice, {
|
|
48
|
+
data: slice
|
|
49
|
+
}, slice.index)),
|
|
50
|
+
!isHalfPie && label ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
|
|
51
|
+
x: 0,
|
|
52
|
+
y: 0,
|
|
53
|
+
textAnchor: "middle",
|
|
54
|
+
alignmentBaseline: "middle",
|
|
55
|
+
children: label
|
|
56
|
+
}) : null,
|
|
57
|
+
isHalfPie && label ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", {
|
|
58
|
+
x: 0,
|
|
59
|
+
y: -innerRadius / 4,
|
|
60
|
+
textAnchor: "middle",
|
|
61
|
+
alignmentBaseline: "middle",
|
|
62
|
+
children: label
|
|
63
|
+
}) : null
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=Pie.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/parts/Pie.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useContext } from 'react';\nimport { Slice } from './Slice';\nimport { PieContext } from '../PieContext';\n\nexport const Pie = () => {\n const {\n innerHeight,\n innerWidth,\n pieData,\n\n props: { isHalfPie, label, innerRadius },\n } = useContext(PieContext);\n\n const radius = Math.min(innerWidth, innerHeight) / 2;\n\n const currentInnerHeight = isHalfPie ? innerHeight : innerHeight / 2;\n return (\n <g transform={`translate(${innerWidth / 2},${currentInnerHeight})`}>\n {pieData.map((slice) => (\n <Slice key={slice.index} data={slice} />\n ))}\n {!isHalfPie && label ? (\n <text x={0} y={0} textAnchor=\"middle\" alignmentBaseline=\"middle\">\n {label}\n </text>\n ) : null}\n {isHalfPie && label ? (\n <text x={0} y={-innerRadius / 4} textAnchor=\"middle\" alignmentBaseline=\"middle\">\n {label}\n </text>\n ) : null}\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAAA,mBAAkC;AAClC,mBAAsB;AACtB,wBAA2B;AAEpB,MAAM,MAAM,MAAM;AACvB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IAEA,OAAO,EAAE,WAAW,OAAO,YAAY;AAAA,EACzC,QAAI,yBAAW,4BAAU;AAEzB,QAAM,SAAS,KAAK,IAAI,YAAY,WAAW,IAAI;AAEnD,QAAM,qBAAqB,YAAY,cAAc,cAAc;AACnE,SACE,6CAAC;AAAA,IAAE,WAAW,aAAa,aAAa,KAAK;AAAA,IAC1C;AAAA,cAAQ,IAAI,CAAC,UACZ,4CAAC;AAAA,QAAwB,MAAM;AAAA,SAAnB,MAAM,KAAoB,CACvC;AAAA,MACA,CAAC,aAAa,QACb,4CAAC;AAAA,QAAK,GAAG;AAAA,QAAG,GAAG;AAAA,QAAG,YAAW;AAAA,QAAS,mBAAkB;AAAA,QACrD;AAAA,OACH,IACE;AAAA,MACH,aAAa,QACZ,4CAAC;AAAA,QAAK,GAAG;AAAA,QAAG,GAAG,CAAC,cAAc;AAAA,QAAG,YAAW;AAAA,QAAS,mBAAkB;AAAA,QACpE;AAAA,OACH,IACE;AAAA;AAAA,GACN;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|